Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/clever-crews-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@iota/graphql-transport': minor
'@iota/iota-sdk': minor
---

Aligns the Typescript SDK for the "fixed gas price" protocol changes:

- Add typing support for IotaChangeEpochV2 (computationCharge, computationChargeBurned).
- Add Typescript SDK client support for versioned IotaSystemStateSummary.
12 changes: 6 additions & 6 deletions apps/explorer/src/hooks/useSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-License-Identifier: Apache-2.0

import { useIotaClientQuery, useIotaClient } from '@iota/dapp-kit';
import { type IotaClient, type IotaSystemStateSummary } from '@iota/iota-sdk/client';
import { type IotaSystemStateSummaryV1, type IotaClient } from '@iota/iota-sdk/client';
import {
isValidTransactionDigest,
isValidIotaAddress,
Expand Down Expand Up @@ -102,18 +102,18 @@ const getResultsForAddress = async (client: IotaClient, query: string): Promise<

// Query for validator by pool id or iota address.
const getResultsForValidatorByPoolIdOrIotaAddress = async (
systemStateSummery: IotaSystemStateSummary | null,
systemStateSummary: IotaSystemStateSummaryV1 | null,
query: string,
): Promise<Results | null> => {
const normalized = normalizeIotaObjectId(query);
if (
(!isValidIotaAddress(normalized) && !isValidIotaObjectId(normalized)) ||
!systemStateSummery
!systemStateSummary
)
return null;

// find validator by pool id or iota address
const validator = systemStateSummery.activeValidators?.find(
const validator = systemStateSummary.activeValidators?.find(
({ stakingPoolId, iotaAddress }) => stakingPoolId === normalized || iotaAddress === query,
);

Expand All @@ -130,7 +130,7 @@ const getResultsForValidatorByPoolIdOrIotaAddress = async (

export function useSearch(query: string): UseQueryResult<Results, Error> {
const client = useIotaClient();
const { data: systemStateSummery } = useIotaClientQuery('getLatestIotaSystemState');
const { data: systemStateSummary } = useIotaClientQuery('getLatestIotaSystemState');

return useQuery<Results, Error>({
// eslint-disable-next-line @tanstack/query/exhaustive-deps
Expand All @@ -142,7 +142,7 @@ export function useSearch(query: string): UseQueryResult<Results, Error> {
getResultsForCheckpoint(client, query),
getResultsForAddress(client, query),
getResultsForObject(client, query),
getResultsForValidatorByPoolIdOrIotaAddress(systemStateSummery || null, query),
getResultsForValidatorByPoolIdOrIotaAddress(systemStateSummary || null, query),
])
).filter(
(r) => r.status === 'fulfilled' && r.value,
Expand Down
4 changes: 2 additions & 2 deletions apps/explorer/src/pages/validator/ValidatorDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { useGetValidatorsApy, useGetValidatorsEvents } from '@iota/core';
import { useIotaClientQuery } from '@iota/dapp-kit';
import { type IotaSystemStateSummary } from '@iota/iota-sdk/client';
import { type IotaSystemStateSummaryV1 } from '@iota/iota-sdk/client';
import { useMemo } from 'react';
import { useParams } from 'react-router-dom';
import { PageLayout, ValidatorMeta, ValidatorStats } from '~/components';
Expand All @@ -14,7 +14,7 @@ import { InfoBox, InfoBoxStyle, InfoBoxType, LoadingIndicator } from '@iota/apps
import { Warning } from '@iota/apps-ui-icons';

const getAtRiskRemainingEpochs = (
data: IotaSystemStateSummary | undefined,
data: IotaSystemStateSummaryV1 | undefined,
validatorId: string | undefined,
): number | null => {
if (!data || !validatorId) return null;
Expand Down
4 changes: 2 additions & 2 deletions apps/wallet-dashboard/app/(protected)/staking/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ import {
useFormatCoin,
} from '@iota/core';
import { useCurrentAccount, useIotaClient, useIotaClientQuery } from '@iota/dapp-kit';
import { IotaSystemStateSummary } from '@iota/iota-sdk/client';
import { IotaSystemStateSummaryV1 } from '@iota/iota-sdk/client';
import { Info } from '@iota/apps-ui-icons';
import { useMemo } from 'react';
import { IotaSignAndExecuteTransactionOutput } from '@iota/wallet-standard';

function StakingDashboardPage(): React.JSX.Element {
const account = useCurrentAccount();
const { data: system } = useIotaClientQuery('getLatestIotaSystemState');
const activeValidators = (system as IotaSystemStateSummary)?.activeValidators;
const activeValidators = (system as IotaSystemStateSummaryV1)?.activeValidators;
const iotaClient = useIotaClient();

const {
Expand Down
2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ packages:
- "!sdk/typescript/utils"
- "!sdk/typescript/verify"
- "!sdk/move-bytecode-template/pkg"
- "!sdk/typescript/graphql/schemas/2024.11"
- "!sdk/typescript/graphql/schemas/2025.2"
2 changes: 1 addition & 1 deletion sdk/graphql-transport/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const header = `

const config: CodegenConfig = {
overwrite: true,
schema: '../typescript/src/graphql/generated/2024.11/schema.graphql',
schema: '../typescript/src/graphql/generated/2025.2/schema.graphql',
documents: ['src/queries/*.graphql'],
ignoreNoDocuments: true,
generates: {
Expand Down
71 changes: 66 additions & 5 deletions sdk/graphql-transport/src/generated/queries.ts

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions sdk/typescript/graphql/schemas/2024.11/package.json

This file was deleted.

6 changes: 6 additions & 0 deletions sdk/typescript/graphql/schemas/2025.2/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"import": "../../../dist/esm/graphql/schemas/2025.2/index.js",
"main": "../../../dist/cjs/graphql/schemas/2025.2/index.js",
"sideEffects": false
}
6 changes: 3 additions & 3 deletions sdk/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@
"import": "./dist/esm/verify/index.js",
"require": "./dist/cjs/verify/index.js"
},
"./graphql/schemas/2024.11": {
"import": "./dist/esm/graphql/schemas/2024.11/index.js",
"require": "./dist/cjs/graphql/schemas/2024.11/index.js"
"./graphql/schemas/2025.2": {
"import": "./dist/esm/graphql/schemas/2025.2/index.js",
"require": "./dist/cjs/graphql/schemas/2025.2/index.js"
}
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions sdk/typescript/scripts/update-graphql-schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
} from './generate-schema-lib.js';

const BRANCH = 'develop';
const MAJOR = 2024;
const MINOR = 11;
const MAJOR = 2025;
const MINOR = 2;
const PATCH = 0;

const VERSION = `${MAJOR}.${MINOR}.${PATCH}`;
Expand Down
17 changes: 15 additions & 2 deletions sdk/typescript/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import type {
GetTimelockedStakesParams,
DelegatedTimelockedStake,
GetTimelockedStakesByIdsParams,
IotaSystemStateSummaryV1,
} from './types/index.js';

export interface PaginationArguments<Cursor> {
Expand Down Expand Up @@ -536,15 +537,27 @@ export class IotaClient {
}

/**
* Return the latest system state content.
* Return the latest IOTA system state object on networks supporting protocol version `< 5`.
* These are networks with node software release version `< 0.11`.
*/
async getLatestIotaSystemState(): Promise<IotaSystemStateSummary> {
async getLatestIotaSystemState(): Promise<IotaSystemStateSummaryV1> {
return await this.transport.request({
method: 'iotax_getLatestIotaSystemState',
params: [],
});
}

/**
* Return the latest IOTA system state object on networks supporting protocol version `>= 5`.
* These are networks with node software release version `>= 0.11`.
*/
async getLatestIotaSystemStateV2(): Promise<IotaSystemStateSummary> {
return await this.transport.request({
method: 'iotax_getLatestIotaSystemStateV2',
params: [],
});
}

/**
* Get events for a given query criteria
*/
Expand Down
138 changes: 134 additions & 4 deletions sdk/typescript/src/client/types/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,14 @@ export interface IotaChangeEpoch {
storage_charge: string;
storage_rebate: string;
}
export interface IotaChangeEpochV2 {
computation_charge: string;
computation_charge_burned: string;
epoch: string;
epoch_start_timestamp_ms: string;
storage_charge: string;
storage_rebate: string;
}
export interface CoinMetadata {
/** Number of decimal places the coin uses. */
decimals: number;
Expand All @@ -501,6 +509,9 @@ export type IotaEndOfEpochTransactionKind =
| {
ChangeEpoch: IotaChangeEpoch;
}
| {
ChangeEpochV2: IotaChangeEpochV2;
}
| {
AuthenticatorStateExpire: IotaAuthenticatorStateExpire;
}
Expand Down Expand Up @@ -657,11 +668,23 @@ export interface MoveCallIotaTransaction {
type_arguments?: string[];
}
/**
* This is the JSON-RPC type for the IOTA system state object. It flattens all fields to make them
* top-level fields such that it as minimum dependencies to the internal data structures of the IOTA
* system state type.
* This is the JSON-RPC type for IOTA system state objects. It is an enum type that can represent
* either V1 or V2 system state objects.
*/
export type IotaSystemStateSummary =
| {
V1: IotaSystemStateSummaryV1;
}
| {
V2: IotaSystemStateSummaryV2;
};
/**
* This is the JSON-RPC type for the
* [`IotaSystemStateV1`](super::iota_system_state_inner_v1::IotaSystemStateV1) object. It flattens all
* fields to make them top-level fields such that it as minimum dependencies to the internal data
* structures of the IOTA system state type.
*/
export interface IotaSystemStateSummary {
export interface IotaSystemStateSummaryV1 {
/** The list of active validators in the current epoch. */
activeValidators: IotaValidatorSummary[];
/** Map storing the number of epochs for which each validator has been below the low stake threshold. */
Expand Down Expand Up @@ -760,6 +783,113 @@ export interface IotaSystemStateSummary {
*/
validatorVeryLowStakeThreshold: string;
}
/**
* This is the JSON-RPC type for the
* [`IotaSystemStateV2`](super::iota_system_state_inner_v2::IotaSystemStateV2) object. It flattens all
* fields to make them top-level fields such that it as minimum dependencies to the internal data
* structures of the IOTA system state type.
*/
export interface IotaSystemStateSummaryV2 {
/** The list of active validators in the current epoch. */
activeValidators: IotaValidatorSummary[];
/** Map storing the number of epochs for which each validator has been below the low stake threshold. */
atRiskValidators: [string, string][];
/** The current epoch ID, starting from 0. */
epoch: string;
/** The duration of an epoch, in milliseconds. */
epochDurationMs: string;
/** Unix timestamp of the current epoch start */
epochStartTimestampMs: string;
/**
* ID of the object that maps from a staking pool ID to the inactive validator that has that pool as
* its staking pool.
*/
inactivePoolsId: string;
/** Number of inactive staking pools. */
inactivePoolsSize: string;
/** The current IOTA supply. */
iotaTotalSupply: string;
/** The `TreasuryCap<IOTA>` object ID. */
iotaTreasuryCapId: string;
/**
* Maximum number of active validators at any moment. We do not allow the number of validators in any
* epoch to go above this.
*/
maxValidatorCount: string;
/**
* Minimum number of active validators at any moment. We do not allow the number of validators in any
* epoch to go under this.
*/
minValidatorCount: string;
/** Lower-bound on the amount of stake required to become a validator. */
minValidatorJoiningStake: string;
/** ID of the object that contains the list of new validators that will join at the end of the epoch. */
pendingActiveValidatorsId: string;
/** Number of new validators that will join at the end of the epoch. */
pendingActiveValidatorsSize: string;
/** Removal requests from the validators. Each element is an index pointing to `active_validators`. */
pendingRemovals: string[];
/** The current protocol version, starting from 1. */
protocolVersion: string;
/** The reference gas price for the current epoch. */
referenceGasPrice: string;
/**
* Whether the system is running in a downgraded safe mode due to a non-recoverable bug. This is set
* whenever we failed to execute advance_epoch, and ended up executing advance_epoch_safe_mode. It can
* be reset once we are able to successfully execute advance_epoch.
*/
safeMode: boolean;
/** Amount of computation charges accumulated (and not yet distributed) during safe mode. */
safeModeComputationCharges: string;
/** Amount of burned computation charges accumulated during safe mode. */
safeModeComputationChargesBurned: string;
/** Amount of non-refundable storage fee accumulated during safe mode. */
safeModeNonRefundableStorageFee: string;
/** Amount of storage charges accumulated (and not yet distributed) during safe mode. */
safeModeStorageCharges: string;
/** Amount of storage rebates accumulated (and not yet burned) during safe mode. */
safeModeStorageRebates: string;
/** ID of the object that maps from staking pool's ID to the iota address of a validator. */
stakingPoolMappingsId: string;
/** Number of staking pool mappings. */
stakingPoolMappingsSize: string;
/**
* The non-refundable portion of the storage fund coming from non-refundable storage rebates and any
* leftover staking rewards.
*/
storageFundNonRefundableBalance: string;
/** The storage rebates of all the objects on-chain stored in the storage fund. */
storageFundTotalObjectStorageRebates: string;
/** The current version of the system state data structure type. */
systemStateVersion: string;
/** Total amount of stake from all active validators at the beginning of the epoch. */
totalStake: string;
/**
* ID of the object that stores preactive validators, mapping their addresses to their `Validator`
* structs.
*/
validatorCandidatesId: string;
/** Number of preactive validators. */
validatorCandidatesSize: string;
/**
* A validator can have stake below `validator_low_stake_threshold` for this many epochs before being
* kicked out.
*/
validatorLowStakeGracePeriod: string;
/**
* Validators with stake amount below `validator_low_stake_threshold` are considered to have low stake
* and will be escorted out of the validator set after being below this threshold for more than
* `validator_low_stake_grace_period` number of epochs.
*/
validatorLowStakeThreshold: string;
/** A map storing the records of validator reporting each other. */
validatorReportRecords: [string, string[]][];
/**
* Validators with stake below `validator_very_low_stake_threshold` will be removed immediately at
* epoch change, no grace period.
*/
validatorVeryLowStakeThreshold: string;
}
/** A single transaction in a programmable transaction block. */
export type IotaTransaction =
/** A call to either an entry or a public Move function */
Expand Down
Loading
Loading