From 11cf4e68b18447031594789cfea91d6861c4494e Mon Sep 17 00:00:00 2001 From: Jordan Gensler Date: Tue, 10 Oct 2023 09:43:17 -0700 Subject: [PATCH] Remove deprecated APIs (#14152) ## Description Describe the changes or additions included in this PR. ## Test Plan How did you test the new or updated feature? --- If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes --- .changeset/nasty-weeks-clap.md | 6 + .../wallet/src/background/accounts/Account.ts | 2 +- .../src/background/keyring/AccountKeypair.ts | 2 +- apps/wallet/src/ui/app/LedgerSigner.ts | 4 +- pnpm-lock.yaml | 41 +- sdk/move-binary-format-wasm/package.json | 3 +- .../src/builder/TransactionBlock.ts | 44 +- sdk/typescript/src/cryptography/keypair.ts | 9 +- sdk/typescript/src/cryptography/multisig.ts | 2 +- sdk/typescript/src/cryptography/publickey.ts | 18 +- sdk/typescript/src/cryptography/signature.ts | 7 +- sdk/typescript/src/framework/framework.ts | 2 +- .../src/framework/sui-system-state.ts | 3 +- .../src/providers/json-rpc-provider.ts | 877 ------------------ sdk/typescript/src/rpc/connection.ts | 51 - sdk/typescript/src/signers/raw-signer.ts | 7 +- .../src/signers/signer-with-provider.ts | 45 +- sdk/typescript/src/types/checkpoints.ts | 80 -- sdk/typescript/src/types/coin.ts | 43 - sdk/typescript/src/types/common.ts | 30 - sdk/typescript/src/types/dynamic_fields.ts | 32 - sdk/typescript/src/types/epochs.ts | 44 - sdk/typescript/src/types/events.ts | 85 -- sdk/typescript/src/types/index.ts | 265 ------ sdk/typescript/src/types/metrics.ts | 28 - sdk/typescript/src/types/name-service.ts | 12 - sdk/typescript/src/types/objects.ts | 16 +- sdk/typescript/src/types/transactions.ts | 572 ------------ sdk/typescript/src/types/validator.ts | 204 ---- .../cryptography/ed25519-publickey.test.ts | 1 - .../cryptography/secp256k1-publickey.test.ts | 1 - .../cryptography/secp256r1-publickey.test.ts | 1 - .../react/src/UnsafeBurnerWallet.tsx | 2 +- 33 files changed, 79 insertions(+), 2460 deletions(-) create mode 100644 .changeset/nasty-weeks-clap.md delete mode 100644 sdk/typescript/src/providers/json-rpc-provider.ts delete mode 100644 sdk/typescript/src/rpc/connection.ts delete mode 100644 sdk/typescript/src/types/checkpoints.ts delete mode 100644 sdk/typescript/src/types/coin.ts delete mode 100644 sdk/typescript/src/types/dynamic_fields.ts delete mode 100644 sdk/typescript/src/types/epochs.ts delete mode 100644 sdk/typescript/src/types/events.ts delete mode 100644 sdk/typescript/src/types/metrics.ts delete mode 100644 sdk/typescript/src/types/name-service.ts delete mode 100644 sdk/typescript/src/types/transactions.ts delete mode 100644 sdk/typescript/src/types/validator.ts diff --git a/.changeset/nasty-weeks-clap.md b/.changeset/nasty-weeks-clap.md new file mode 100644 index 0000000000000..bb2e18358205b --- /dev/null +++ b/.changeset/nasty-weeks-clap.md @@ -0,0 +1,6 @@ +--- +'@mysten/wallet-kit': minor +'@mysten/sui.js': minor +--- + +Remove deprecated methods. diff --git a/apps/wallet/src/background/accounts/Account.ts b/apps/wallet/src/background/accounts/Account.ts index 94b3913b9f047..a3e91cf9174a9 100644 --- a/apps/wallet/src/background/accounts/Account.ts +++ b/apps/wallet/src/background/accounts/Account.ts @@ -80,7 +80,7 @@ export abstract class Account< return toSerializedSignature({ signature, signatureScheme, - pubKey: pubkey, + publicKey: pubkey, }); } diff --git a/apps/wallet/src/background/keyring/AccountKeypair.ts b/apps/wallet/src/background/keyring/AccountKeypair.ts index 8b1f2305c0d35..cb0b5edf0547d 100644 --- a/apps/wallet/src/background/keyring/AccountKeypair.ts +++ b/apps/wallet/src/background/keyring/AccountKeypair.ts @@ -26,7 +26,7 @@ export class AccountKeypair { return toSerializedSignature({ signature, signatureScheme, - pubKey: pubkey, + publicKey: pubkey, }); } diff --git a/apps/wallet/src/ui/app/LedgerSigner.ts b/apps/wallet/src/ui/app/LedgerSigner.ts index 52e428bb7fc6a..84dc8a7ff9493 100644 --- a/apps/wallet/src/ui/app/LedgerSigner.ts +++ b/apps/wallet/src/ui/app/LedgerSigner.ts @@ -54,11 +54,11 @@ export class LedgerSigner extends WalletSigner { async signData(data: Uint8Array): Promise { const ledgerClient = await this.#initializeSuiLedgerClient(); const { signature } = await ledgerClient.signTransaction(this.#derivationPath, data); - const pubKey = await this.getPublicKey(); + const publicKey = await this.getPublicKey(); return toSerializedSignature({ signature, signatureScheme: this.#signatureScheme, - pubKey, + publicKey, }); } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 60a2c36848153..1e989d8d42d76 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -829,7 +829,7 @@ importers: version: 8.0.1(webpack@5.79.0) eslint-webpack-plugin: specifier: ^4.0.1 - version: 4.0.1(webpack@5.79.0) + version: 4.0.1(eslint@8.45.0)(webpack@5.79.0) git-rev-sync: specifier: ^3.0.2 version: 3.0.2 @@ -1382,10 +1382,9 @@ importers: vitest: specifier: ^0.33.0 version: 0.33.0(@vitest/ui@0.33.0)(happy-dom@10.5.1) - - sdk/move-binary-format-wasm/pkg: {} - - sdk/move-binary-format/pkg: {} + wasm-pack: + specifier: ^0.12.1 + version: 0.12.1 sdk/suins-toolkit: dependencies: @@ -10997,6 +10996,14 @@ packages: engines: {node: '>=4'} dev: true + /axios@0.26.1: + resolution: {integrity: sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==} + dependencies: + follow-redirects: 1.15.1(debug@4.3.4) + transitivePeerDependencies: + - debug + dev: true + /axios@0.27.2(debug@4.3.4): resolution: {integrity: sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==} dependencies: @@ -11227,6 +11234,17 @@ packages: engines: {node: '>=8'} dev: true + /binary-install@1.1.0: + resolution: {integrity: sha512-rkwNGW+3aQVSZoD0/o3mfPN6Yxh3Id0R/xzTVBVVpGNlVz8EGwusksxRlbk/A5iKTZt9zkMn3qIqmAt3vpfbzg==} + engines: {node: '>=10'} + dependencies: + axios: 0.26.1 + rimraf: 3.0.2 + tar: 6.1.15 + transitivePeerDependencies: + - debug + dev: true + /bl@4.1.0: resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} dependencies: @@ -14066,7 +14084,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /eslint-webpack-plugin@4.0.1(webpack@5.79.0): + /eslint-webpack-plugin@4.0.1(eslint@8.45.0)(webpack@5.79.0): resolution: {integrity: sha512-fUFcXpui/FftGx3NzvWgLZXlLbu+m74sUxGEgxgoxYcUtkIQbS6SdNNZkS99m5ycb23TfoNYrDpp1k/CK5j6Hw==} engines: {node: '>= 14.15.0'} peerDependencies: @@ -14074,6 +14092,7 @@ packages: webpack: ^5.0.0 dependencies: '@types/eslint': 8.37.0 + eslint: 8.45.0 jest-worker: 29.5.0 micromatch: 4.0.5 normalize-path: 3.0.0 @@ -23672,6 +23691,16 @@ packages: makeerror: 1.0.12 dev: true + /wasm-pack@0.12.1: + resolution: {integrity: sha512-dIyKWUumPFsGohdndZjDXRFaokUT/kQS+SavbbiXVAvA/eN4riX5QNdB6AhXQx37zNxluxQkuixZUgJ8adKjOg==} + hasBin: true + requiresBuild: true + dependencies: + binary-install: 1.1.0 + transitivePeerDependencies: + - debug + dev: true + /watchpack@2.4.0: resolution: {integrity: sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==} engines: {node: '>=10.13.0'} diff --git a/sdk/move-binary-format-wasm/package.json b/sdk/move-binary-format-wasm/package.json index 9ed9084102253..26cc5289c0439 100644 --- a/sdk/move-binary-format-wasm/package.json +++ b/sdk/move-binary-format-wasm/package.json @@ -15,6 +15,7 @@ "devDependencies": { "tsup": "^7.1.0", "typescript": "^5.1.6", - "vitest": "^0.33.0" + "vitest": "^0.33.0", + "wasm-pack": "^0.12.1" } } diff --git a/sdk/typescript/src/builder/TransactionBlock.ts b/sdk/typescript/src/builder/TransactionBlock.ts index 7095059a9ee24..26219180f5b7a 100644 --- a/sdk/typescript/src/builder/TransactionBlock.ts +++ b/sdk/typescript/src/builder/TransactionBlock.ts @@ -9,7 +9,6 @@ import { bcs } from '../bcs/index.js'; import type { ProtocolConfig, SuiClient, SuiMoveNormalizedType } from '../client/index.js'; import type { Keypair, SignatureWithBytes } from '../cryptography/index.js'; import { SUI_TYPE_ARG } from '../framework/framework.js'; -import type { JsonRpcProvider } from '../providers/json-rpc-provider.js'; import type { SuiObjectResponse } from '../types/index.js'; import { extractMutableReference, @@ -96,13 +95,13 @@ function createTransactionResult(index: number): TransactionResult { } function expectClient(options: BuildOptions): SuiClient { - if (!options.client && !options.provider) { + if (!options.client) { throw new Error( `No provider passed to Transaction#build, but transaction data was not sufficient to build offline.`, ); } - return (options.client ?? options.provider!) as SuiClient; + return options.client; } const TRANSACTION_BRAND = Symbol.for('@mysten/transaction'); @@ -132,11 +131,7 @@ const chunk = (arr: T[], size: number): T[][] => ); interface BuildOptions { - /** - * @deprecated Use `client` instead. - */ - provider?: JsonRpcProvider | SuiClient; - client?: SuiClient | JsonRpcProvider; + client?: SuiClient; onlyTransactionKind?: boolean; /** Define a protocol config to build against, instead of having it fetched from the provider at build time. */ protocolConfig?: ProtocolConfig; @@ -156,13 +151,6 @@ export function isTransactionBlock(obj: unknown): obj is TransactionBlock { * Transaction Builder */ export class TransactionBlock { - /** Returns `true` if the object is an instance of the Transaction builder class. - * @deprecated Use `isTransactionBlock` from `@mysten/sui.js/transactions` instead. - */ - static is(obj: unknown): obj is TransactionBlock { - return !!obj && typeof obj === 'object' && (obj as any)[TRANSACTION_BRAND] === true; - } - /** * Converts from a serialize transaction kind (built with `build({ onlyTransactionKind: true })`) to a `Transaction` class. * Supports either a byte array, or base64-encoded bytes. @@ -198,22 +186,6 @@ export class TransactionBlock { return tx; } - /** - * A helper to retrieve the Transaction builder `Transactions` - * @deprecated Either use the helper methods on the `TransactionBlock` class, or import `Transactions` from `@mysten/sui.js/transactions`. - */ - static get Transactions() { - return Transactions; - } - - /** - * A helper to retrieve the Transaction builder `Inputs` - * * @deprecated Either use the helper methods on the `TransactionBlock` class, or import `Inputs` from `@mysten/sui.js/transactions`. - */ - static get Inputs() { - return Inputs; - } - setSender(sender: string) { this.#blockData.sender = sender; } @@ -526,10 +498,6 @@ export class TransactionBlock { /** Derive transaction digest */ async getDigest( options: { - /** - * @deprecated Use `client` instead. - */ - provider?: JsonRpcProvider | SuiClient; client?: SuiClient; } = {}, ): Promise { @@ -806,10 +774,8 @@ export class TransactionBlock { throw new Error('Missing transaction sender'); } - const client = options.client || options.provider; - - if (!options.protocolConfig && !options.limits && client) { - options.protocolConfig = await client.getProtocolConfig(); + if (!options.protocolConfig && !options.limits && options.client) { + options.protocolConfig = await options.client.getProtocolConfig(); } await Promise.all([this.#prepareGasPrice(options), this.#prepareTransactions(options)]); diff --git a/sdk/typescript/src/cryptography/keypair.ts b/sdk/typescript/src/cryptography/keypair.ts index fbe5e746d3755..b6af0f9c0f45e 100644 --- a/sdk/typescript/src/cryptography/keypair.ts +++ b/sdk/typescript/src/cryptography/keypair.ts @@ -40,7 +40,7 @@ export abstract class BaseSigner { const signature = toSerializedSignature({ signature: await this.sign(digest), signatureScheme: this.getKeyScheme(), - pubKey: this.getPublicKey(), + publicKey: this.getPublicKey(), }); return { @@ -64,13 +64,6 @@ export abstract class BaseSigner { ); } - /** - * @deprecated use `signPersonalMessage` instead - */ - async signMessage(bytes: Uint8Array) { - return this.signPersonalMessage(bytes); - } - toSuiAddress(): string { return this.getPublicKey().toSuiAddress(); } diff --git a/sdk/typescript/src/cryptography/multisig.ts b/sdk/typescript/src/cryptography/multisig.ts index 8825250f3675d..c4197724dca51 100644 --- a/sdk/typescript/src/cryptography/multisig.ts +++ b/sdk/typescript/src/cryptography/multisig.ts @@ -189,7 +189,7 @@ export function decodeMultiSig(signature: string): SignaturePubkeyPair[] { } function toPkWeightPair(pair: PubkeyWeightPair): PubkeyEnumWeightPair { - let pk_bytes = Array.from(pair.pubKey.toBytes().map((x) => Number(x))); + let pk_bytes = Array.from(pair.pubKey.toRawBytes().map((x) => Number(x))); switch (pair.pubKey.flag()) { case SIGNATURE_SCHEME_TO_FLAG['Secp256k1']: return { diff --git a/sdk/typescript/src/cryptography/publickey.ts b/sdk/typescript/src/cryptography/publickey.ts index 4b704fe1045b9..70cfc62190e50 100644 --- a/sdk/typescript/src/cryptography/publickey.ts +++ b/sdk/typescript/src/cryptography/publickey.ts @@ -48,13 +48,10 @@ export abstract class PublicKey { return toB64(this.toRawBytes()); } - /** - * @deprecated use toBase64 instead. - * - * Return the base-64 representation of the public key - */ - toString() { - return this.toBase64(); + toString(): never { + throw new Error( + '`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.', + ); } /** @@ -115,13 +112,6 @@ export abstract class PublicKey { return suiBytes; } - /** - * @deprecated use `toRawBytes` instead. - */ - toBytes() { - return this.toRawBytes(); - } - /** * Return the Sui address associated with this Ed25519 public key */ diff --git a/sdk/typescript/src/cryptography/signature.ts b/sdk/typescript/src/cryptography/signature.ts index b5e74c65e1633..9bfcf0b78d71a 100644 --- a/sdk/typescript/src/cryptography/signature.ts +++ b/sdk/typescript/src/cryptography/signature.ts @@ -23,8 +23,6 @@ export type SerializeSignatureInput = { signatureScheme: SignatureScheme; /** Base64-encoded signature */ signature: Uint8Array; - /** @deprecated use publicKey instead */ - pubKey?: PublicKey; /** Base64-encoded public key */ publicKey?: PublicKey; }; @@ -41,14 +39,13 @@ export type SerializedSignature = string; export function toSerializedSignature({ signature, signatureScheme, - pubKey, - publicKey = pubKey, + publicKey, }: SerializeSignatureInput): SerializedSignature { if (!publicKey) { throw new Error('`publicKey` is required'); } - const pubKeyBytes = publicKey.toBytes(); + const pubKeyBytes = publicKey.toRawBytes(); const serializedSignature = new Uint8Array(1 + signature.length + pubKeyBytes.length); serializedSignature.set([SIGNATURE_SCHEME_TO_FLAG[signatureScheme]]); serializedSignature.set(signature, 1); diff --git a/sdk/typescript/src/framework/framework.ts b/sdk/typescript/src/framework/framework.ts index 1a30be5441689..ac2293413cb3b 100644 --- a/sdk/typescript/src/framework/framework.ts +++ b/sdk/typescript/src/framework/framework.ts @@ -5,7 +5,7 @@ import type { Infer } from 'superstruct'; import { nullable, number, object, string } from 'superstruct'; import type { StructTag } from '../bcs/index.js'; -import type { CoinStruct } from '../types/coin.js'; +import type { CoinStruct } from '../client/types/index.js'; import type { SuiMoveObject, SuiObjectData, diff --git a/sdk/typescript/src/framework/sui-system-state.ts b/sdk/typescript/src/framework/sui-system-state.ts index 9f4592ea3af62..6775b1deccac7 100644 --- a/sdk/typescript/src/framework/sui-system-state.ts +++ b/sdk/typescript/src/framework/sui-system-state.ts @@ -3,7 +3,6 @@ import { TransactionBlock } from '../builder/index.js'; import type { SuiClient } from '../client/index.js'; -import type { JsonRpcProvider } from '../providers/json-rpc-provider.js'; import { getObjectReference } from '../types/index.js'; import { normalizeSuiObjectId } from '../utils/sui-types.js'; import { SUI_SYSTEM_ADDRESS } from './framework.js'; @@ -31,7 +30,7 @@ export class SuiSystemStateUtil { * @param gasBudget omittable only for DevInspect mode */ public static async newRequestAddStakeTxn( - client: JsonRpcProvider | SuiClient, + client: SuiClient, coins: string[], amount: bigint, validatorAddress: string, diff --git a/sdk/typescript/src/providers/json-rpc-provider.ts b/sdk/typescript/src/providers/json-rpc-provider.ts deleted file mode 100644 index a66fdddfa6c05..0000000000000 --- a/sdk/typescript/src/providers/json-rpc-provider.ts +++ /dev/null @@ -1,877 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// SPDX-License-Identifier: Apache-2.0 - -import { fromB58, toB64, toHEX } from '@mysten/bcs'; -import { any, array, nullable, string } from 'superstruct'; - -import type { TransactionBlock } from '../builder/index.js'; -import { isTransactionBlock } from '../builder/index.js'; -import type { SerializedSignature } from '../cryptography/signature.js'; -import { requestSuiFromFaucetV0 } from '../faucet/index.js'; -import type { CoinMetadata } from '../framework/framework.js'; -import { CoinMetadataStruct } from '../framework/framework.js'; -import type { HttpHeaders } from '../rpc/client.js'; -import { JsonRpcClient } from '../rpc/client.js'; -import type { Connection } from '../rpc/connection.js'; -import { devnetConnection } from '../rpc/connection.js'; -import type { WebsocketClientOptions } from '../rpc/websocket-client.js'; -import { DEFAULT_CLIENT_OPTIONS, WebsocketClient } from '../rpc/websocket-client.js'; -import { CheckpointPage } from '../types/checkpoints.js'; -import type { DynamicFieldName } from '../types/dynamic_fields.js'; -import { DynamicFieldPage } from '../types/dynamic_fields.js'; -import { EpochInfo, EpochPage } from '../types/epochs.js'; -import type { - CheckpointDigest, - ExecuteTransactionRequestType, - Order, - SuiEvent, - SuiEventFilter, - SuiObjectDataOptions, - SuiObjectResponseQuery, - SuiTransactionBlockResponseOptions, - SuiTransactionBlockResponseQuery, - TransactionEffects, - TransactionFilter, - Unsubscribe, -} from '../types/index.js'; -import { - Checkpoint, - CoinBalance, - CoinSupply, - CommitteeInfo, - DelegatedStake, - DevInspectResults, - DryRunTransactionBlockResponse, - MoveCallMetrics, - ObjectRead, - PaginatedCoins, - PaginatedEvents, - PaginatedObjectsResponse, - PaginatedTransactionResponse, - ProtocolConfig, - ResolvedNameServiceNames, - SuiMoveFunctionArgTypes, - SuiMoveNormalizedFunction, - SuiMoveNormalizedModule, - SuiMoveNormalizedModules, - SuiMoveNormalizedStruct, - SuiObjectResponse, - SuiSystemStateSummary, - SuiTransactionBlockResponse, - ValidatorsApy, -} from '../types/index.js'; -import { AddressMetrics, AllEpochsAddressMetrics, NetworkMetrics } from '../types/metrics.js'; -import { - isValidSuiAddress, - isValidSuiObjectId, - isValidTransactionDigest, - normalizeSuiAddress, - normalizeSuiObjectId, -} from '../utils/sui-types.js'; - -export interface PaginationArguments { - /** Optional paging cursor */ - cursor?: Cursor; - /** Maximum item returned per page */ - limit?: number | null; -} - -export interface OrderArguments { - order?: Order | null; -} - -/** - * Configuration options for the JsonRpcProvider. If the value of a field is not provided, - * value in `DEFAULT_OPTIONS` for that field will be used - */ -export type RpcProviderOptions = { - /** - * Configuration options for the websocket connection - * TODO: Move to connection. - */ - socketOptions?: WebsocketClientOptions; - /** - * Cache timeout in seconds for the RPC API Version - */ - versionCacheTimeoutInSeconds?: number; - - /** Allow defining a custom RPC client to use */ - rpcClient?: JsonRpcClient; - - /** Allow defining a custom websocket client to use */ - websocketClient?: WebsocketClient; -}; - -const DEFAULT_OPTIONS: RpcProviderOptions = { - socketOptions: DEFAULT_CLIENT_OPTIONS, - versionCacheTimeoutInSeconds: 600, -}; - -export class JsonRpcProvider { - public connection: Connection; - protected client: JsonRpcClient; - protected wsClient: WebsocketClient; - private rpcApiVersion: string | undefined; - private cacheExpiry: number | undefined; - /** - * Establish a connection to a Sui RPC endpoint - * - * @param connection The `Connection` object containing configuration for the network. - * @param options configuration options for the provider - */ - constructor( - // TODO: Probably remove the default endpoint here: - connection: Connection = devnetConnection, - public options: RpcProviderOptions = DEFAULT_OPTIONS, - ) { - this.connection = connection; - - const opts = { ...DEFAULT_OPTIONS, ...options }; - this.options = opts; - // TODO: add header for websocket request - this.client = opts.rpcClient ?? new JsonRpcClient(this.connection.fullnode); - - this.wsClient = - opts.websocketClient ?? new WebsocketClient(this.connection.websocket, opts.socketOptions); - } - - async getRpcApiVersion(): Promise { - if (this.rpcApiVersion && this.cacheExpiry && this.cacheExpiry <= Date.now()) { - return this.rpcApiVersion; - } - - try { - const resp = await this.client.requestWithType('rpc.discover', [], any()); - this.rpcApiVersion = resp.info.version; - this.cacheExpiry = - // Date.now() is in milliseconds, but the timeout is in seconds - Date.now() + (this.options.versionCacheTimeoutInSeconds ?? 0) * 1000; - return this.rpcApiVersion; - } catch (err) { - console.warn('Error fetching version number of the RPC API', err); - } - return undefined; - } - - /** @deprecated Use `@mysten/sui.js/faucet` instead. */ - async requestSuiFromFaucet(recipient: string, headers?: HttpHeaders) { - if (!this.connection.faucet) { - throw new Error('Faucet URL is not specified'); - } - - return requestSuiFromFaucetV0({ host: this.connection.faucet, recipient, headers }); - } - - /** - * Get all Coin<`coin_type`> objects owned by an address. - */ - async getCoins( - input: { - owner: string; - coinType?: string | null; - } & PaginationArguments, - ): Promise { - if (!input.owner || !isValidSuiAddress(normalizeSuiAddress(input.owner))) { - throw new Error('Invalid Sui address'); - } - - return await this.client.requestWithType( - 'suix_getCoins', - [input.owner, input.coinType, input.cursor, input.limit], - PaginatedCoins, - ); - } - - /** - * Get all Coin objects owned by an address. - */ - async getAllCoins( - input: { - owner: string; - } & PaginationArguments, - ): Promise { - if (!input.owner || !isValidSuiAddress(normalizeSuiAddress(input.owner))) { - throw new Error('Invalid Sui address'); - } - - return await this.client.requestWithType( - 'suix_getAllCoins', - [input.owner, input.cursor, input.limit], - PaginatedCoins, - ); - } - - /** - * Get the total coin balance for one coin type, owned by the address owner. - */ - async getBalance(input: { - owner: string; - /** optional fully qualified type names for the coin (e.g., 0x168da5bf1f48dafc111b0a488fa454aca95e0b5e::usdc::USDC), default to 0x2::sui::SUI if not specified. */ - coinType?: string | null; - }): Promise { - if (!input.owner || !isValidSuiAddress(normalizeSuiAddress(input.owner))) { - throw new Error('Invalid Sui address'); - } - return await this.client.requestWithType( - 'suix_getBalance', - [input.owner, input.coinType], - CoinBalance, - ); - } - - /** - * Get the total coin balance for all coin types, owned by the address owner. - */ - async getAllBalances(input: { owner: string }): Promise { - if (!input.owner || !isValidSuiAddress(normalizeSuiAddress(input.owner))) { - throw new Error('Invalid Sui address'); - } - return await this.client.requestWithType( - 'suix_getAllBalances', - [input.owner], - array(CoinBalance), - ); - } - - /** - * Fetch CoinMetadata for a given coin type - */ - async getCoinMetadata(input: { coinType: string }): Promise { - return await this.client.requestWithType( - 'suix_getCoinMetadata', - [input.coinType], - CoinMetadataStruct, - ); - } - - /** - * Fetch total supply for a coin - */ - async getTotalSupply(input: { coinType: string }): Promise { - return await this.client.requestWithType('suix_getTotalSupply', [input.coinType], CoinSupply); - } - - /** - * Invoke any RPC method - * @param method the method to be invoked - * @param args the arguments to be passed to the RPC request - */ - async call(method: string, params: any[]): Promise { - return await this.client.request(method, params); - } - - /** - * Get Move function argument types like read, write and full access - */ - async getMoveFunctionArgTypes(input: { - package: string; - module: string; - function: string; - }): Promise { - return await this.client.requestWithType( - 'sui_getMoveFunctionArgTypes', - [input.package, input.module, input.function], - SuiMoveFunctionArgTypes, - ); - } - - /** - * Get a map from module name to - * structured representations of Move modules - */ - async getNormalizedMoveModulesByPackage(input: { - package: string; - }): Promise { - return await this.client.requestWithType( - 'sui_getNormalizedMoveModulesByPackage', - [input.package], - SuiMoveNormalizedModules, - ); - } - - /** - * Get a structured representation of Move module - */ - async getNormalizedMoveModule(input: { - package: string; - module: string; - }): Promise { - return await this.client.requestWithType( - 'sui_getNormalizedMoveModule', - [input.package, input.module], - SuiMoveNormalizedModule, - ); - } - - /** - * Get a structured representation of Move function - */ - async getNormalizedMoveFunction(input: { - package: string; - module: string; - function: string; - }): Promise { - return await this.client.requestWithType( - 'sui_getNormalizedMoveFunction', - [input.package, input.module, input.function], - SuiMoveNormalizedFunction, - ); - } - - /** - * Get a structured representation of Move struct - */ - async getNormalizedMoveStruct(input: { - package: string; - module: string; - struct: string; - }): Promise { - return await this.client.requestWithType( - 'sui_getNormalizedMoveStruct', - [input.package, input.module, input.struct], - SuiMoveNormalizedStruct, - ); - } - - /** - * Get all objects owned by an address - */ - async getOwnedObjects( - input: { - owner: string; - } & PaginationArguments & - SuiObjectResponseQuery, - ): Promise { - if (!input.owner || !isValidSuiAddress(normalizeSuiAddress(input.owner))) { - throw new Error('Invalid Sui address'); - } - - return await this.client.requestWithType( - 'suix_getOwnedObjects', - [ - input.owner, - { - filter: input.filter, - options: input.options, - } as SuiObjectResponseQuery, - input.cursor, - input.limit, - ], - PaginatedObjectsResponse, - ); - } - - /** - * Get details about an object - */ - async getObject(input: { - id: string; - options?: SuiObjectDataOptions; - }): Promise { - if (!input.id || !isValidSuiObjectId(normalizeSuiObjectId(input.id))) { - throw new Error('Invalid Sui Object id'); - } - return await this.client.requestWithType( - 'sui_getObject', - [input.id, input.options], - SuiObjectResponse, - ); - } - - async tryGetPastObject(input: { - id: string; - version: number; - options?: SuiObjectDataOptions; - }): Promise { - return await this.client.requestWithType( - 'sui_tryGetPastObject', - [input.id, input.version, input.options], - ObjectRead, - ); - } - - /** - * Batch get details about a list of objects. If any of the object ids are duplicates the call will fail - */ - async multiGetObjects(input: { - ids: string[]; - options?: SuiObjectDataOptions; - }): Promise { - input.ids.forEach((id) => { - if (!id || !isValidSuiObjectId(normalizeSuiObjectId(id))) { - throw new Error(`Invalid Sui Object id ${id}`); - } - }); - const hasDuplicates = input.ids.length !== new Set(input.ids).size; - if (hasDuplicates) { - throw new Error(`Duplicate object ids in batch call ${input.ids}`); - } - - return await this.client.requestWithType( - 'sui_multiGetObjects', - [input.ids, input.options], - array(SuiObjectResponse), - ); - } - - /** - * Get transaction blocks for a given query criteria - */ - async queryTransactionBlocks( - input: SuiTransactionBlockResponseQuery & - PaginationArguments & - OrderArguments, - ): Promise { - return await this.client.requestWithType( - 'suix_queryTransactionBlocks', - [ - { - filter: input.filter, - options: input.options, - } as SuiTransactionBlockResponseQuery, - input.cursor, - input.limit, - (input.order || 'descending') === 'descending', - ], - PaginatedTransactionResponse, - ); - } - - async getTransactionBlock(input: { - digest: string; - options?: SuiTransactionBlockResponseOptions; - }): Promise { - if (!isValidTransactionDigest(input.digest)) { - throw new Error('Invalid Transaction digest'); - } - return await this.client.requestWithType( - 'sui_getTransactionBlock', - [input.digest, input.options], - SuiTransactionBlockResponse, - ); - } - - async multiGetTransactionBlocks(input: { - digests: string[]; - options?: SuiTransactionBlockResponseOptions; - }): Promise { - input.digests.forEach((d) => { - if (!isValidTransactionDigest(d)) { - throw new Error(`Invalid Transaction digest ${d}`); - } - }); - - const hasDuplicates = input.digests.length !== new Set(input.digests).size; - if (hasDuplicates) { - throw new Error(`Duplicate digests in batch call ${input.digests}`); - } - - return await this.client.requestWithType( - 'sui_multiGetTransactionBlocks', - [input.digests, input.options], - array(SuiTransactionBlockResponse), - ); - } - - async executeTransactionBlock(input: { - transactionBlock: Uint8Array | string; - signature: SerializedSignature | SerializedSignature[]; - options?: SuiTransactionBlockResponseOptions; - requestType?: ExecuteTransactionRequestType; - }): Promise { - return await this.client.requestWithType( - 'sui_executeTransactionBlock', - [ - typeof input.transactionBlock === 'string' - ? input.transactionBlock - : toB64(input.transactionBlock), - Array.isArray(input.signature) ? input.signature : [input.signature], - input.options, - input.requestType, - ], - SuiTransactionBlockResponse, - ); - } - - /** - * Get total number of transactions - */ - - async getTotalTransactionBlocks(): Promise { - const resp = await this.client.requestWithType('sui_getTotalTransactionBlocks', [], string()); - return BigInt(resp); - } - - /** - * Getting the reference gas price for the network - */ - async getReferenceGasPrice(): Promise { - const resp = await this.client.requestWithType('suix_getReferenceGasPrice', [], string()); - return BigInt(resp); - } - - /** - * Return the delegated stakes for an address - */ - async getStakes(input: { owner: string }): Promise { - if (!input.owner || !isValidSuiAddress(normalizeSuiAddress(input.owner))) { - throw new Error('Invalid Sui address'); - } - return await this.client.requestWithType( - 'suix_getStakes', - [input.owner], - array(DelegatedStake), - ); - } - - /** - * Return the delegated stakes queried by id. - */ - async getStakesByIds(input: { stakedSuiIds: string[] }): Promise { - input.stakedSuiIds.forEach((id) => { - if (!id || !isValidSuiObjectId(normalizeSuiObjectId(id))) { - throw new Error(`Invalid Sui Stake id ${id}`); - } - }); - return await this.client.requestWithType( - 'suix_getStakesByIds', - [input.stakedSuiIds], - array(DelegatedStake), - ); - } - - /** - * Return the latest system state content. - */ - async getLatestSuiSystemState(): Promise { - return await this.client.requestWithType( - 'suix_getLatestSuiSystemState', - [], - SuiSystemStateSummary, - ); - } - - /** - * Get events for a given query criteria - */ - async queryEvents( - input: { - /** the event query criteria. */ - query: SuiEventFilter; - } & PaginationArguments & - OrderArguments, - ): Promise { - return await this.client.requestWithType( - 'suix_queryEvents', - [input.query, input.cursor, input.limit, (input.order || 'descending') === 'descending'], - PaginatedEvents, - ); - } - - /** - * Subscribe to get notifications whenever an event matching the filter occurs - */ - async subscribeEvent(input: { - /** filter describing the subset of events to follow */ - filter: SuiEventFilter; - /** function to run when we receive a notification of a new event matching the filter */ - onMessage: (event: SuiEvent) => void; - }): Promise { - return this.wsClient.request({ - method: 'suix_subscribeEvent', - unsubscribe: 'suix_unsubscribeEvent', - params: [input.filter], - onMessage: input.onMessage, - }); - } - - async subscribeTransaction(input: { - /** filter describing the subset of events to follow */ - filter: TransactionFilter; - /** function to run when we receive a notification of a new event matching the filter */ - onMessage: (event: TransactionEffects) => void; - }): Promise { - return this.wsClient.request({ - method: 'suix_subscribeTransaction', - unsubscribe: 'suix_unsubscribeTransaction', - params: [input.filter], - onMessage: input.onMessage, - }); - } - - /** - * Runs the transaction block in dev-inspect mode. Which allows for nearly any - * transaction (or Move call) with any arguments. Detailed results are - * provided, including both the transaction effects and any return values. - */ - async devInspectTransactionBlock(input: { - transactionBlock: TransactionBlock | string | Uint8Array; - sender: string; - /** Default to use the network reference gas price stored in the Sui System State object */ - gasPrice?: bigint | number | null; - /** optional. Default to use the current epoch number stored in the Sui System State object */ - epoch?: string | null; - }): Promise { - let devInspectTxBytes; - if (isTransactionBlock(input.transactionBlock)) { - input.transactionBlock.setSenderIfNotSet(input.sender); - devInspectTxBytes = toB64( - await input.transactionBlock.build({ - provider: this, - onlyTransactionKind: true, - }), - ); - } else if (typeof input.transactionBlock === 'string') { - devInspectTxBytes = input.transactionBlock; - } else if (input.transactionBlock instanceof Uint8Array) { - devInspectTxBytes = toB64(input.transactionBlock); - } else { - throw new Error('Unknown transaction block format.'); - } - - return await this.client.requestWithType( - 'sui_devInspectTransactionBlock', - [input.sender, devInspectTxBytes, input.gasPrice, input.epoch], - DevInspectResults, - ); - } - - /** - * Dry run a transaction block and return the result. - */ - async dryRunTransactionBlock(input: { - transactionBlock: Uint8Array | string; - }): Promise { - return await this.client.requestWithType( - 'sui_dryRunTransactionBlock', - [ - typeof input.transactionBlock === 'string' - ? input.transactionBlock - : toB64(input.transactionBlock), - ], - DryRunTransactionBlockResponse, - ); - } - - /** - * Return the list of dynamic field objects owned by an object - */ - async getDynamicFields( - input: { - /** The id of the parent object */ - parentId: string; - } & PaginationArguments, - ): Promise { - if (!input.parentId || !isValidSuiObjectId(normalizeSuiObjectId(input.parentId))) { - throw new Error('Invalid Sui Object id'); - } - return await this.client.requestWithType( - 'suix_getDynamicFields', - [input.parentId, input.cursor, input.limit], - DynamicFieldPage, - ); - } - - /** - * Return the dynamic field object information for a specified object - */ - async getDynamicFieldObject(input: { - /** The ID of the quered parent object */ - parentId: string; - /** The name of the dynamic field */ - name: string | DynamicFieldName; - }): Promise { - return await this.client.requestWithType( - 'suix_getDynamicFieldObject', - [input.parentId, input.name], - SuiObjectResponse, - ); - } - - /** - * Get the sequence number of the latest checkpoint that has been executed - */ - async getLatestCheckpointSequenceNumber(): Promise { - const resp = await this.client.requestWithType( - 'sui_getLatestCheckpointSequenceNumber', - [], - string(), - ); - return String(resp); - } - - /** - * Returns information about a given checkpoint - */ - async getCheckpoint(input: { - /** The checkpoint digest or sequence number */ - id: CheckpointDigest | string; - }): Promise { - return await this.client.requestWithType('sui_getCheckpoint', [input.id], Checkpoint); - } - - /** - * Returns historical checkpoints paginated - */ - async getCheckpoints( - input: { - /** query result ordering, default to false (ascending order), oldest record first */ - descendingOrder: boolean; - } & PaginationArguments, - ): Promise { - const resp = await this.client.requestWithType( - 'sui_getCheckpoints', - [input.cursor, input?.limit, input.descendingOrder], - CheckpointPage, - ); - return resp; - } - - /** - * Return the committee information for the asked epoch - */ - async getCommitteeInfo(input?: { - /** The epoch of interest. If null, default to the latest epoch */ - epoch?: string | null; - }): Promise { - return await this.client.requestWithType( - 'suix_getCommitteeInfo', - [input?.epoch], - CommitteeInfo, - ); - } - - async getNetworkMetrics() { - return await this.client.requestWithType('suix_getNetworkMetrics', [], NetworkMetrics); - } - - async getAddressMetrics() { - return await this.client.requestWithType('suix_getLatestAddressMetrics', [], AddressMetrics); - } - - async getAllEpochAddressMetrics(input?: { descendingOrder?: boolean }) { - return await this.client.requestWithType( - 'suix_getAllEpochAddressMetrics', - [input?.descendingOrder], - AllEpochsAddressMetrics, - ); - } - - /** - * Return the committee information for the asked epoch - */ - async getEpochs( - input?: { - descendingOrder?: boolean; - } & PaginationArguments, - ): Promise { - return await this.client.requestWithType( - 'suix_getEpochs', - [input?.cursor, input?.limit, input?.descendingOrder], - EpochPage, - ); - } - - /** - * Returns list of top move calls by usage - */ - async getMoveCallMetrics(): Promise { - return await this.client.requestWithType('suix_getMoveCallMetrics', [], MoveCallMetrics); - } - - /** - * Return the committee information for the asked epoch - */ - async getCurrentEpoch(): Promise { - return await this.client.requestWithType('suix_getCurrentEpoch', [], EpochInfo); - } - - /** - * Return the Validators APYs - */ - async getValidatorsApy(): Promise { - return await this.client.requestWithType('suix_getValidatorsApy', [], ValidatorsApy); - } - - // TODO: Migrate this to `sui_getChainIdentifier` once it is widely available. - async getChainIdentifier(): Promise { - const checkpoint = await this.getCheckpoint({ id: '0' }); - const bytes = fromB58(checkpoint.digest); - return toHEX(bytes.slice(0, 4)); - } - - async resolveNameServiceAddress(input: { name: string }): Promise { - return await this.client.requestWithType( - 'suix_resolveNameServiceAddress', - [input.name], - nullable(string()), - ); - } - - async resolveNameServiceNames( - input: { - address: string; - } & PaginationArguments, - ): Promise { - return await this.client.requestWithType( - 'suix_resolveNameServiceNames', - [input.address], - ResolvedNameServiceNames, - ); - } - - async getProtocolConfig(input?: { version?: string }): Promise { - return await this.client.requestWithType( - 'sui_getProtocolConfig', - [input?.version], - ProtocolConfig, - ); - } - - /** - * Wait for a transaction block result to be available over the API. - * This can be used in conjunction with `executeTransactionBlock` to wait for the transaction to - * be available via the API. - * This currently polls the `getTransactionBlock` API to check for the transaction. - */ - async waitForTransactionBlock({ - signal, - timeout = 60 * 1000, - pollInterval = 2 * 1000, - ...input - }: { - /** An optional abort signal that can be used to cancel */ - signal?: AbortSignal; - /** The amount of time to wait for a transaction block. Defaults to one minute. */ - timeout?: number; - /** The amount of time to wait between checks for the transaction block. Defaults to 2 seconds. */ - pollInterval?: number; - } & Parameters[0]): Promise { - const timeoutSignal = AbortSignal.timeout(timeout); - const timeoutPromise = new Promise((_, reject) => { - timeoutSignal.addEventListener('abort', () => reject(timeoutSignal.reason)); - }); - - timeoutPromise.catch(() => { - // Swallow unhandled rejections that might be thrown after early return - }); - - while (!timeoutSignal.aborted) { - signal?.throwIfAborted(); - try { - return await this.getTransactionBlock(input); - } catch (e) { - // Wait for either the next poll interval, or the timeout. - await Promise.race([ - new Promise((resolve) => setTimeout(resolve, pollInterval)), - timeoutPromise, - ]); - } - } - - timeoutSignal.throwIfAborted(); - - // This should never happen, because the above case should always throw, but just adding it in the event that something goes horribly wrong. - throw new Error('Unexpected error while waiting for transaction block.'); - } -} diff --git a/sdk/typescript/src/rpc/connection.ts b/sdk/typescript/src/rpc/connection.ts deleted file mode 100644 index 9170717cc1bee..0000000000000 --- a/sdk/typescript/src/rpc/connection.ts +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// SPDX-License-Identifier: Apache-2.0 - -interface ConnectionOptions { - fullnode: string; - websocket?: string; - /** @deprecated Use the new faucet APIs from `@mysten/sui.js/faucet` instead. */ - faucet?: string; -} - -export class Connection { - #options: ConnectionOptions; - constructor(options: ConnectionOptions) { - this.#options = options; - } - - get fullnode() { - return this.#options.fullnode; - } - - // TODO: Decide if we should default the websocket URL like this: - get websocket() { - return this.#options.websocket || this.#options.fullnode; - } - - /** @deprecated Use the new faucet APIs from `@mysten/sui.js/faucet` instead. */ - get faucet() { - return this.#options.faucet; - } -} - -// TODO: Maybe don't have pre-built connections, and instead just have pre-built objects that folks -// can use with the connection? -export const localnetConnection = new Connection({ - fullnode: 'http://127.0.0.1:9000', - faucet: 'http://127.0.0.1:9123/gas', -}); - -export const devnetConnection = new Connection({ - fullnode: 'https://fullnode.devnet.sui.io:443/', - faucet: 'https://faucet.devnet.sui.io/gas', -}); - -export const testnetConnection = new Connection({ - fullnode: 'https://fullnode.testnet.sui.io:443/', - faucet: 'https://faucet.testnet.sui.io/gas', -}); - -export const mainnetConnection = new Connection({ - fullnode: 'https://fullnode.mainnet.sui.io:443/', -}); diff --git a/sdk/typescript/src/signers/raw-signer.ts b/sdk/typescript/src/signers/raw-signer.ts index 0d42b282001b9..1c10541a6bda4 100644 --- a/sdk/typescript/src/signers/raw-signer.ts +++ b/sdk/typescript/src/signers/raw-signer.ts @@ -7,13 +7,12 @@ import type { SuiClient } from '../client/index.js'; import type { Keypair } from '../cryptography/keypair.js'; import { toSerializedSignature } from '../cryptography/signature.js'; import type { SerializedSignature } from '../cryptography/signature.js'; -import type { JsonRpcProvider } from '../providers/json-rpc-provider.js'; import { SignerWithProvider } from './signer-with-provider.js'; export class RawSigner extends SignerWithProvider { private readonly keypair: Keypair; - constructor(keypair: Keypair, client: JsonRpcProvider | SuiClient) { + constructor(keypair: Keypair, client: SuiClient) { super(client); this.keypair = keypair; } @@ -31,11 +30,11 @@ export class RawSigner extends SignerWithProvider { return toSerializedSignature({ signatureScheme, signature, - pubKey: pubkey, + publicKey: pubkey, }); } - connect(client: SuiClient | JsonRpcProvider): SignerWithProvider { + connect(client: SuiClient): SignerWithProvider { return new RawSigner(this.keypair, client); } } diff --git a/sdk/typescript/src/signers/signer-with-provider.ts b/sdk/typescript/src/signers/signer-with-provider.ts index 989ccb9986906..f2c5f28d1656e 100644 --- a/sdk/typescript/src/signers/signer-with-provider.ts +++ b/sdk/typescript/src/signers/signer-with-provider.ts @@ -17,22 +17,12 @@ import type { } from '../client/index.js'; import { IntentScope, messageWithIntent } from '../cryptography/intent.js'; import type { SerializedSignature } from '../cryptography/signature.js'; -import type { JsonRpcProvider } from '../providers/json-rpc-provider.js'; -import type { HttpHeaders } from '../rpc/client.js'; -import { getTotalGasUsedUpperBound } from '../types/index.js'; import type { Signer } from './signer.js'; import type { SignedMessage, SignedTransaction } from './types.js'; /////////////////////////////// // Exported Abstracts export abstract class SignerWithProvider implements Signer { - /** - * @deprecated Use `client` instead. - */ - get provider(): JsonRpcProvider | SuiClient { - return this.client; - } - readonly client: SuiClient; /////////////////// @@ -48,26 +38,12 @@ export abstract class SignerWithProvider implements Signer { // Returns a new instance of the Signer, connected to provider. // This MAY throw if changing providers is not supported. - abstract connect(client: SuiClient | JsonRpcProvider): SignerWithProvider; + abstract connect(client: SuiClient): SignerWithProvider; /////////////////// // Sub-classes MAY override these - /** - * Request gas tokens from a faucet server and send to the signer - * address - * @param httpHeaders optional request headers - * @deprecated Use `@mysten/sui.js/faucet` instead. - */ - async requestSuiFromFaucet(httpHeaders?: HttpHeaders) { - if (!('requestSuiFromFaucet' in this.provider)) { - throw new Error('To request SUI from faucet, please use @mysten/sui.js/faucet instead'); - } - - return this.provider.requestSuiFromFaucet(await this.getAddress(), httpHeaders); - } - - constructor(client: JsonRpcProvider | SuiClient) { + constructor(client: SuiClient) { this.client = client as SuiClient; } @@ -171,7 +147,7 @@ export abstract class SignerWithProvider implements Signer { * provided, including both the transaction effects and any return values. */ async devInspectTransactionBlock( - input: Omit[0], 'sender'>, + input: Omit[0], 'sender'>, ): Promise { const address = await this.getAddress(); return this.client.devInspectTransactionBlock({ @@ -204,19 +180,4 @@ export abstract class SignerWithProvider implements Signer { transactionBlock: dryRunTxBytes, }); } - - /** - * Returns the estimated gas cost for the transaction - * @param tx The transaction to estimate the gas cost. When string it is assumed it's a serialized tx in base64 - * @returns total gas cost estimation - * @throws whens fails to estimate the gas cost - */ - async getGasCostEstimation(...args: Parameters) { - const txEffects = await this.dryRunTransactionBlock(...args); - const gasEstimation = getTotalGasUsedUpperBound(txEffects.effects); - if (typeof gasEstimation === 'undefined') { - throw new Error('Failed to estimate the gas cost from transaction'); - } - return gasEstimation; - } } diff --git a/sdk/typescript/src/types/checkpoints.ts b/sdk/typescript/src/types/checkpoints.ts deleted file mode 100644 index dcc4c1df037d5..0000000000000 --- a/sdk/typescript/src/types/checkpoints.ts +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// SPDX-License-Identifier: Apache-2.0 - -import type { Infer } from 'superstruct'; -import { - any, - array, - boolean, - nullable, - number, - object, - optional, - string, - tuple, -} from 'superstruct'; - -export const GasCostSummary = object({ - computationCost: string(), - storageCost: string(), - storageRebate: string(), - nonRefundableStorageFee: string(), -}); -export type GasCostSummary = Infer; - -/** @deprecated Use `string` instead. */ -export const CheckPointContentsDigest = string(); -/** @deprecated Use `string` instead. */ -export type CheckPointContentsDigest = Infer; - -/** @deprecated Use `string` instead. */ -export const CheckpointDigest = string(); -/** @deprecated Use `string` instead. */ -export type CheckpointDigest = Infer; - -export const ECMHLiveObjectSetDigest = object({ - digest: array(number()), -}); -export type ECMHLiveObjectSetDigest = Infer; - -export const CheckpointCommitment = any(); -export type CheckpointCommitment = Infer; - -/** @deprecated Use `string` instead. */ -export const ValidatorSignature = string(); -/** @deprecated Use `string` instead. */ -export type ValidatorSignature = Infer; - -export const EndOfEpochData = object({ - nextEpochCommittee: array(tuple([string(), string()])), - nextEpochProtocolVersion: string(), - epochCommitments: array(CheckpointCommitment), -}); -export type EndOfEpochData = Infer; - -export const ExecutionDigests = object({ - transaction: string(), - effects: string(), -}); - -export const Checkpoint = object({ - epoch: string(), - sequenceNumber: string(), - digest: string(), - networkTotalTransactions: string(), - previousDigest: optional(string()), - epochRollingGasCostSummary: GasCostSummary, - timestampMs: string(), - endOfEpochData: optional(EndOfEpochData), - validatorSignature: string(), - transactions: array(string()), - checkpointCommitments: array(CheckpointCommitment), -}); -export type Checkpoint = Infer; - -export const CheckpointPage = object({ - data: array(Checkpoint), - nextCursor: nullable(string()), - hasNextPage: boolean(), -}); -export type CheckpointPage = Infer; diff --git a/sdk/typescript/src/types/coin.ts b/sdk/typescript/src/types/coin.ts deleted file mode 100644 index 96324da510b44..0000000000000 --- a/sdk/typescript/src/types/coin.ts +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// SPDX-License-Identifier: Apache-2.0 - -import type { Infer } from 'superstruct'; -import { array, boolean, nullable, number, object, optional, string } from 'superstruct'; - -export const CoinStruct = object({ - coinType: string(), - // TODO(chris): rename this to objectId - coinObjectId: string(), - version: string(), - digest: string(), - balance: string(), - previousTransaction: string(), -}); - -export type CoinStruct = Infer; - -export const PaginatedCoins = object({ - data: array(CoinStruct), - nextCursor: nullable(string()), - hasNextPage: boolean(), -}); - -export type PaginatedCoins = Infer; - -export const CoinBalance = object({ - coinType: string(), - coinObjectCount: number(), - totalBalance: string(), - lockedBalance: object({ - epochId: optional(number()), - number: optional(number()), - }), -}); - -export type CoinBalance = Infer; - -export const CoinSupply = object({ - value: string(), -}); - -export type CoinSupply = Infer; diff --git a/sdk/typescript/src/types/common.ts b/sdk/typescript/src/types/common.ts index f26e26fb7713b..22645b4f9c2e6 100644 --- a/sdk/typescript/src/types/common.ts +++ b/sdk/typescript/src/types/common.ts @@ -6,36 +6,6 @@ import { boolean, define, literal, nullable, object, record, string, union } fro import type { CallArg } from '../bcs/index.js'; -/** @deprecated Use `string` instead. */ -export const TransactionDigest = string(); -/** @deprecated Use `string` instead. */ -export type TransactionDigest = Infer; - -/** @deprecated Use `string` instead. */ -export const TransactionEffectsDigest = string(); -/** @deprecated Use `string` instead. */ -export type TransactionEffectsDigest = Infer; - -/** @deprecated Use `string` instead. */ -export const TransactionEventDigest = string(); -/** @deprecated Use `string` instead. */ -export type TransactionEventDigest = Infer; - -/** @deprecated Use `string` instead. */ -export const ObjectId = string(); -/** @deprecated Use `string` instead. */ -export type ObjectId = Infer; - -/** @deprecated Use `string` instead. */ -export const SuiAddress = string(); -/** @deprecated Use `string` instead. */ -export type SuiAddress = Infer; - -/** @deprecated Use `string` instead. */ -export const SequenceNumber = string(); -/** @deprecated Use `string` instead. */ -export type SequenceNumber = Infer; - export const ObjectOwner = union([ object({ AddressOwner: string(), diff --git a/sdk/typescript/src/types/dynamic_fields.ts b/sdk/typescript/src/types/dynamic_fields.ts deleted file mode 100644 index f87b505288f99..0000000000000 --- a/sdk/typescript/src/types/dynamic_fields.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// SPDX-License-Identifier: Apache-2.0 - -import type { Infer } from 'superstruct'; -import { any, array, boolean, literal, nullable, number, object, string, union } from 'superstruct'; - -export const DynamicFieldType = union([literal('DynamicField'), literal('DynamicObject')]); -export type DynamicFieldType = Infer; - -export const DynamicFieldName = object({ - type: string(), - value: any(), -}); -export type DynamicFieldName = Infer; - -export const DynamicFieldInfo = object({ - name: DynamicFieldName, - bcsName: string(), - type: DynamicFieldType, - objectType: string(), - objectId: string(), - version: number(), - digest: string(), -}); -export type DynamicFieldInfo = Infer; - -export const DynamicFieldPage = object({ - data: array(DynamicFieldInfo), - nextCursor: nullable(string()), - hasNextPage: boolean(), -}); -export type DynamicFieldPage = Infer; diff --git a/sdk/typescript/src/types/epochs.ts b/sdk/typescript/src/types/epochs.ts deleted file mode 100644 index ba801772c3c87..0000000000000 --- a/sdk/typescript/src/types/epochs.ts +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// SPDX-License-Identifier: Apache-2.0 -import type { Infer } from 'superstruct'; -import { array, boolean, nullable, number, object, string } from 'superstruct'; - -import { SuiValidatorSummary } from './validator.js'; - -export const EndOfEpochInfo = object({ - lastCheckpointId: string(), - epochEndTimestamp: string(), - protocolVersion: string(), - referenceGasPrice: string(), - totalStake: string(), - storageFundReinvestment: string(), - storageCharge: string(), - storageRebate: string(), - storageFundBalance: string(), - stakeSubsidyAmount: string(), - totalGasFees: string(), - totalStakeRewardsDistributed: string(), - leftoverStorageFundInflow: string(), -}); - -export type EndOfEpochInfo = Infer; - -export const EpochInfo = object({ - epoch: string(), - validators: array(SuiValidatorSummary), - epochTotalTransactions: string(), - firstCheckpointId: string(), - epochStartTimestamp: string(), - endOfEpochInfo: nullable(EndOfEpochInfo), - referenceGasPrice: nullable(number()), -}); - -export type EpochInfo = Infer; - -export const EpochPage = object({ - data: array(EpochInfo), - nextCursor: nullable(string()), - hasNextPage: boolean(), -}); - -export type EpochPage = Infer; diff --git a/sdk/typescript/src/types/events.ts b/sdk/typescript/src/types/events.ts deleted file mode 100644 index b0f4ba0a2e6e8..0000000000000 --- a/sdk/typescript/src/types/events.ts +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// SPDX-License-Identifier: Apache-2.0 - -import type { Infer } from 'superstruct'; -import { any, array, boolean, nullable, object, optional, record, string } from 'superstruct'; - -import type { SuiJsonValue } from './common.js'; - -export const EventId = object({ - txDigest: string(), - eventSeq: string(), -}); - -// event types mirror those in "sui-json-rpc-types/src/sui_event.rs" - -export const SuiEvent = object({ - id: EventId, - // Move package where this event was emitted. - packageId: string(), - // Move module where this event was emitted. - transactionModule: string(), - // Sender's Sui address. - sender: string(), - // Move event type. - type: string(), - // Parsed json value of the event - parsedJson: optional(record(string(), any())), - // Base 58 encoded bcs bytes of the move event - bcs: optional(string()), - timestampMs: optional(string()), -}); - -export type SuiEvent = Infer; - -export type MoveEventField = { - path: string; - value: SuiJsonValue; -}; - -/** - * Sequential event ID, ie (transaction seq number, event seq number). - * 1) Serves as a unique event ID for each fullnode - * 2) Also serves to sequence events for the purposes of pagination and querying. - * A higher id is an event seen later by that fullnode. - * This ID is the "cursor" for event querying. - */ -export type EventId = Infer; - -// mirrors sui_json_rpc_types::SuiEventFilter -export type SuiEventFilter = - | { Package: string } - | { MoveModule: { package: string; module: string } } - | { MoveEventType: string } - | { MoveEventField: MoveEventField } - | { Transaction: string } - | { - TimeRange: { - // left endpoint of time interval, milliseconds since epoch, inclusive - startTime: string; - // right endpoint of time interval, milliseconds since epoch, exclusive - endTime: string; - }; - } - | { Sender: string } - | { All: SuiEventFilter[] } - | { Any: SuiEventFilter[] } - | { And: [SuiEventFilter, SuiEventFilter] } - | { Or: [SuiEventFilter, SuiEventFilter] }; - -export const PaginatedEvents = object({ - data: array(SuiEvent), - nextCursor: nullable(EventId), - hasNextPage: boolean(), -}); -export type PaginatedEvents = Infer; - -/* ------------------------------- EventData ------------------------------ */ - -export function getEventSender(event: SuiEvent): string { - return event.sender; -} - -export function getEventPackage(event: SuiEvent): string { - return event.packageId; -} diff --git a/sdk/typescript/src/types/index.ts b/sdk/typescript/src/types/index.ts index a54200c4e949f..05f475a922cb9 100644 --- a/sdk/typescript/src/types/index.ts +++ b/sdk/typescript/src/types/index.ts @@ -1,26 +1,6 @@ // Copyright (c) Mysten Labs, Inc. // SPDX-License-Identifier: Apache-2.0 -export { - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - ObjectOwner, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - ProtocolConfig, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiJsonValue, - /** @deprecated Use `string` instead. */ - SuiAddress, - /** @deprecated Use `string` instead. */ - SequenceNumber, - /** @deprecated Use `string` instead. */ - TransactionDigest, - /** @deprecated Use `string` instead. */ - TransactionEffectsDigest, - /** @deprecated Use `string` instead. */ - TransactionEventDigest, - /** @deprecated Use `string` instead. */ - ObjectId, -} from './common.js'; export { /** @deprecated Import type from `@mysten/sui.js/client` instead */ CheckpointedObjectId, @@ -34,8 +14,6 @@ export { MovePackageContent, /** @deprecated Import type from `@mysten/sui.js/client` instead */ ObjectContentFields, - /** @deprecated Use `string` instead. */ - ObjectDigest, /** @deprecated Import type from `@mysten/sui.js/client` instead */ ObjectRead, /** @deprecated This type will be removed in a future version */ @@ -117,148 +95,6 @@ export { /** @deprecated This method will be removed in a future version of the SDK */ isSuiObjectResponse, } from './objects.js'; -export { - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - EventId, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - type MoveEventField, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - PaginatedEvents, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiEvent, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - type SuiEventFilter, - getEventPackage, - /** @deprecated This method will be removed in a future version of the SDK */ - getEventSender, - /** @deprecated This method will be removed in a future version of the SDK */ -} from './events.js'; -export { - /** @deprecated Use `string` instead. */ - AuthorityName, - /** @deprecated Use `string` instead. */ - AuthoritySignature, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - BalanceChange, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - DevInspectResults, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - DryRunTransactionBlockResponse, - /** @deprecated Use `string` instead. */ - EpochId, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - type ExecuteTransactionRequestType, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - ExecutionStatus, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - ExecutionStatusType, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - Genesis, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - MoveCallSuiTransaction, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - OwnedObjectRef, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - PaginatedTransactionResponse, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - ProgrammableTransaction, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiArgument, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiCallArg, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiChangeEpoch, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiConsensusCommitPrologue, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiObjectChange, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiObjectChangeCreated, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiObjectChangeDeleted, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiObjectChangeMutated, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiObjectChangePublished, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiObjectChangeTransferred, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiObjectChangeWrapped, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiTransaction, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiTransactionBlock, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiTransactionBlockData, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiTransactionBlockResponse, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiTransactionBlockResponseOptions, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - type SuiTransactionBlockResponseQuery, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - TransactionEffects, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - TransactionEffectsModifiedAtVersions, - /** @deprecated Use SuiEvent[] from `@mysten/sui.js/client` instead */ - TransactionEvents, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - type TransactionFilter, - /** @deprecated This type will be removed in a future version of the SDK */ - type EmptySignInfo, - /** @deprecated This method will be removed in a future version of the SDK */ - getChangeEpochTransaction, - /** @deprecated This method will be removed in a future version of the SDK */ - getConsensusCommitPrologueTransaction, - /** @deprecated This method will be removed in a future version of the SDK */ - getCreatedObjects, - /** @deprecated This method will be removed in a future version of the SDK */ - getEvents, - /** @deprecated This method will be removed in a future version of the SDK */ - getExecutionStatus, - /** @deprecated This method will be removed in a future version of the SDK */ - getExecutionStatusError, - /** @deprecated This method will be removed in a future version of the SDK */ - getExecutionStatusGasSummary, - /** @deprecated This method will be removed in a future version of the SDK */ - getExecutionStatusType, - /** @deprecated This method will be removed in a future version of the SDK */ - getGasData, - /** @deprecated This method will be removed in a future version of the SDK */ - getNewlyCreatedCoinRefsAfterSplit, - /** @deprecated This method will be removed in a future version of the SDK */ - getObjectChanges, - /** @deprecated This method will be removed in a future version of the SDK */ - getProgrammableTransaction, - /** @deprecated This method will be removed in a future version of the SDK */ - getPublishedObjectChanges, - /** @deprecated This method will be removed in a future version of the SDK */ - getTimestampFromTransactionResponse, - /** @deprecated This method will be removed in a future version of the SDK */ - getTotalGasUsed, - /** @deprecated This method will be removed in a future version of the SDK */ - getTotalGasUsedUpperBound, - /** @deprecated This method will be removed in a future version of the SDK */ - getTransaction, - /** @deprecated This method will be removed in a future version of the SDK */ - getTransactionDigest, - /** @deprecated This method will be removed in a future version of the SDK */ - getTransactionEffects, - /** @deprecated This method will be removed in a future version of the SDK */ - getTransactionGasBudget, - /** @deprecated This method will be removed in a future version of the SDK */ - getTransactionGasObject, - /** @deprecated This method will be removed in a future version of the SDK */ - getTransactionGasPrice, - /** @deprecated This method will be removed in a future version of the SDK */ - getTransactionKind, - /** @deprecated This method will be removed in a future version of the SDK */ - getTransactionKindName, - /** @deprecated This method will be removed in a future version of the SDK */ - getTransactionSender, - /** @deprecated This method will be removed in a future version of the SDK */ - getTransactionSignature, -} from './transactions.js'; export { /** @deprecated Import type from `@mysten/sui.js/client` instead */ @@ -302,104 +138,3 @@ export { /** @deprecated This method will be removed in a future version of the SDK */ extractStructTag, } from './normalized.js'; -export { - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - Apy, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - Balance, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - CommitteeInfo, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - DelegatedStake, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - StakeObject, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiSystemStateSummary, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - SuiValidatorSummary, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - Validators, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - ValidatorsApy, -} from './validator.js'; -export { - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - CoinBalance, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - CoinStruct, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - CoinSupply, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - PaginatedCoins, -} from './coin.js'; -export { - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - EndOfEpochInfo, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - EpochInfo, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - EpochPage, -} from './epochs.js'; -export { - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - type Unsubscribe, -} from './subscriptions.js'; -export { - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - ResolvedNameServiceNames, -} from './name-service.js'; -export { - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - DynamicFieldInfo, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - DynamicFieldName, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - DynamicFieldPage, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - DynamicFieldType, -} from './dynamic_fields.js'; -export { - /** @deprecated Use `string` instead. */ - ValidatorSignature, - /** @deprecated Use `string` instead. */ - CheckPointContentsDigest, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - Checkpoint, - /** @deprecated Current type is an alias for `any`, use `unknown` instead */ - CheckpointCommitment, - /** @deprecated Use `string` instead. */ - CheckpointDigest, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - CheckpointPage, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - EndOfEpochData, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - GasCostSummary, -} from './checkpoints.js'; -export { - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - AddressMetrics, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - AllEpochsAddressMetrics, - /** @deprecated Import type from `@mysten/sui.js/client` instead */ - NetworkMetrics, -} from './metrics.js'; - -export { - /** @deprecated This method will be removed in a future version of the SDK */ - Contents, - /** @deprecated This method will be removed in a future version of the SDK */ - ContentsFields, - /** @deprecated This method will be removed in a future version of the SDK */ - ContentsFieldsWithdraw, - /** @deprecated This method will be removed in a future version of the SDK */ - DelegationStakingPool, - /** @deprecated This method will be removed in a future version of the SDK */ - DelegationStakingPoolFields, - /** @deprecated This method will be removed in a future version of the SDK */ - StakeSubsidy, - /** @deprecated This method will be removed in a future version of the SDK */ - StakeSubsidyFields, - /** @deprecated This method will be removed in a future version of the SDK */ - SuiSupplyFields, -} from './validator.js'; diff --git a/sdk/typescript/src/types/metrics.ts b/sdk/typescript/src/types/metrics.ts deleted file mode 100644 index f9bf60cb7cb9f..0000000000000 --- a/sdk/typescript/src/types/metrics.ts +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// SPDX-License-Identifier: Apache-2.0 - -import { array, number, object, string } from 'superstruct'; - -export const NetworkMetrics = object({ - currentTps: number(), - tps30Days: number(), - currentCheckpoint: string(), - currentEpoch: string(), - totalAddresses: string(), - totalObjects: string(), - totalPackages: string(), -}); -export type NetworkMetrics = typeof NetworkMetrics.TYPE; - -export const AddressMetrics = object({ - checkpoint: number(), - epoch: number(), - timestampMs: number(), - cumulativeAddresses: number(), - cumulativeActiveAddresses: number(), - dailyActiveAddresses: number(), -}); -export type AddressMetrics = typeof AddressMetrics.TYPE; - -export const AllEpochsAddressMetrics = array(AddressMetrics); -export type AllEpochsAddressMetrics = typeof AllEpochsAddressMetrics.TYPE; diff --git a/sdk/typescript/src/types/name-service.ts b/sdk/typescript/src/types/name-service.ts deleted file mode 100644 index 8b91088adf5be..0000000000000 --- a/sdk/typescript/src/types/name-service.ts +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// SPDX-License-Identifier: Apache-2.0 - -import type { Infer } from 'superstruct'; -import { array, boolean, nullable, object, string } from 'superstruct'; - -export const ResolvedNameServiceNames = object({ - data: array(string()), - hasNextPage: boolean(), - nextCursor: nullable(string()), -}); -export type ResolvedNameServiceNames = Infer; diff --git a/sdk/typescript/src/types/objects.ts b/sdk/typescript/src/types/objects.ts index d5e4d93a61e7b..7be253c31416e 100644 --- a/sdk/typescript/src/types/objects.ts +++ b/sdk/typescript/src/types/objects.ts @@ -22,7 +22,6 @@ import { } from 'superstruct'; import { ObjectOwner } from './common.js'; -import type { OwnedObjectRef } from './transactions.js'; export const ObjectType = union([string(), literal('package')]); export type ObjectType = Infer; @@ -37,6 +36,16 @@ export const SuiObjectRef = object({ }); export type SuiObjectRef = Infer; +export const OwnedObjectRef = object({ + owner: ObjectOwner, + reference: SuiObjectRef, +}); +export type OwnedObjectRef = Infer; +export const TransactionEffectsModifiedAtVersions = object({ + objectId: string(), + sequenceNumber: string(), +}); + export const SuiGasData = object({ payment: array(SuiObjectRef), /** Gas Object's owner */ @@ -110,11 +119,6 @@ export const SUI_DECIMALS = 9; export const MIST_PER_SUI = BigInt(1000000000); -/** @deprecated Use `string` instead. */ -export const ObjectDigest = string(); -/** @deprecated Use `string` instead. */ -export type ObjectDigest = Infer; - export const SuiObjectResponseError = object({ code: string(), error: optional(string()), diff --git a/sdk/typescript/src/types/transactions.ts b/sdk/typescript/src/types/transactions.ts deleted file mode 100644 index a01079721bd21..0000000000000 --- a/sdk/typescript/src/types/transactions.ts +++ /dev/null @@ -1,572 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// SPDX-License-Identifier: Apache-2.0 - -import type { Infer } from 'superstruct'; -import { - array, - assign, - boolean, - is, - literal, - nullable, - number, - object, - optional, - string, - tuple, - union, -} from 'superstruct'; - -import { ObjectOwner, SuiJsonValue } from './common.js'; -import { SuiEvent } from './events.js'; -import { SuiGasData, SuiMovePackage, SuiObjectRef } from './objects.js'; - -/** @deprecated Use `string` instead. */ -export const EpochId = string(); - -export const SuiChangeEpoch = object({ - epoch: string(), - storage_charge: string(), - computation_charge: string(), - storage_rebate: string(), - epoch_start_timestamp_ms: optional(string()), -}); -export type SuiChangeEpoch = Infer; - -export const SuiConsensusCommitPrologue = object({ - epoch: string(), - round: string(), - commit_timestamp_ms: string(), -}); -export type SuiConsensusCommitPrologue = Infer; - -export const Genesis = object({ - objects: array(string()), -}); -export type Genesis = Infer; - -export const SuiArgument = union([ - literal('GasCoin'), - object({ Input: number() }), - object({ Result: number() }), - object({ NestedResult: tuple([number(), number()]) }), -]); -export type SuiArgument = Infer; - -export const MoveCallSuiTransaction = object({ - arguments: optional(array(SuiArgument)), - type_arguments: optional(array(string())), - package: string(), - module: string(), - function: string(), -}); -export type MoveCallSuiTransaction = Infer; - -export const SuiTransaction = union([ - object({ MoveCall: MoveCallSuiTransaction }), - object({ TransferObjects: tuple([array(SuiArgument), SuiArgument]) }), - object({ SplitCoins: tuple([SuiArgument, array(SuiArgument)]) }), - object({ MergeCoins: tuple([SuiArgument, array(SuiArgument)]) }), - object({ - Publish: union([ - // TODO: Remove this after 0.34 is released: - tuple([SuiMovePackage, array(string())]), - array(string()), - ]), - }), - object({ - Upgrade: union([ - // TODO: Remove this after 0.34 is released: - tuple([SuiMovePackage, array(string()), string(), SuiArgument]), - tuple([array(string()), string(), SuiArgument]), - ]), - }), - object({ MakeMoveVec: tuple([nullable(string()), array(SuiArgument)]) }), -]); - -export const SuiCallArg = union([ - object({ - type: literal('pure'), - valueType: nullable(string()), - value: SuiJsonValue, - }), - object({ - type: literal('object'), - objectType: literal('immOrOwnedObject'), - objectId: string(), - version: string(), - digest: string(), - }), - object({ - type: literal('object'), - objectType: literal('sharedObject'), - objectId: string(), - initialSharedVersion: string(), - mutable: boolean(), - }), -]); -export type SuiCallArg = Infer; - -export const ProgrammableTransaction = object({ - transactions: array(SuiTransaction), - inputs: array(SuiCallArg), -}); -export type ProgrammableTransaction = Infer; -export type SuiTransaction = Infer; - -/** - * 1. WaitForEffectsCert: waits for TransactionEffectsCert and then returns to the client. - * This mode is a proxy for transaction finality. - * 2. WaitForLocalExecution: waits for TransactionEffectsCert and makes sure the node - * executed the transaction locally before returning to the client. The local execution - * makes sure this node is aware of this transaction when the client fires subsequent queries. - * However, if the node fails to execute the transaction locally in a timely manner, - * a bool type in the response is set to false to indicate the case. - */ -export type ExecuteTransactionRequestType = 'WaitForEffectsCert' | 'WaitForLocalExecution'; - -export type TransactionKindName = - | 'ChangeEpoch' - | 'ConsensusCommitPrologue' - | 'Genesis' - | 'ProgrammableTransaction'; - -export const SuiTransactionBlockKind = union([ - assign(SuiChangeEpoch, object({ kind: literal('ChangeEpoch') })), - assign( - SuiConsensusCommitPrologue, - object({ - kind: literal('ConsensusCommitPrologue'), - }), - ), - assign(Genesis, object({ kind: literal('Genesis') })), - assign(ProgrammableTransaction, object({ kind: literal('ProgrammableTransaction') })), -]); -export type SuiTransactionBlockKind = Infer; - -export const SuiTransactionBlockData = object({ - // Eventually this will become union(literal('v1'), literal('v2'), ...) - messageVersion: literal('v1'), - transaction: SuiTransactionBlockKind, - sender: string(), - gasData: SuiGasData, -}); -export type SuiTransactionBlockData = Infer; - -/** @deprecated Use `string` instead. */ -export const AuthoritySignature = string(); -export const GenericAuthoritySignature = union([string(), array(string())]); - -export const AuthorityQuorumSignInfo = object({ - epoch: string(), - signature: GenericAuthoritySignature, - signers_map: array(number()), -}); -export type AuthorityQuorumSignInfo = Infer; - -export const GasCostSummary = object({ - computationCost: string(), - storageCost: string(), - storageRebate: string(), - nonRefundableStorageFee: string(), -}); -export type GasCostSummary = Infer; - -export const ExecutionStatusType = union([literal('success'), literal('failure')]); -export type ExecutionStatusType = Infer; - -export const ExecutionStatus = object({ - status: ExecutionStatusType, - error: optional(string()), -}); -export type ExecutionStatus = Infer; - -export const OwnedObjectRef = object({ - owner: ObjectOwner, - reference: SuiObjectRef, -}); -export type OwnedObjectRef = Infer; -export const TransactionEffectsModifiedAtVersions = object({ - objectId: string(), - sequenceNumber: string(), -}); - -export const TransactionEffects = object({ - // Eventually this will become union(literal('v1'), literal('v2'), ...) - messageVersion: literal('v1'), - - /** The status of the execution */ - status: ExecutionStatus, - /** The epoch when this transaction was executed */ - executedEpoch: string(), - /** The version that every modified (mutated or deleted) object had before it was modified by this transaction. **/ - modifiedAtVersions: optional(array(TransactionEffectsModifiedAtVersions)), - gasUsed: GasCostSummary, - /** The object references of the shared objects used in this transaction. Empty if no shared objects were used. */ - sharedObjects: optional(array(SuiObjectRef)), - /** The transaction digest */ - transactionDigest: string(), - /** ObjectRef and owner of new objects created */ - created: optional(array(OwnedObjectRef)), - /** ObjectRef and owner of mutated objects, including gas object */ - mutated: optional(array(OwnedObjectRef)), - /** - * ObjectRef and owner of objects that are unwrapped in this transaction. - * Unwrapped objects are objects that were wrapped into other objects in the past, - * and just got extracted out. - */ - unwrapped: optional(array(OwnedObjectRef)), - /** Object Refs of objects now deleted (the old refs) */ - deleted: optional(array(SuiObjectRef)), - /** Object Refs of objects now deleted (the old refs) */ - unwrappedThenDeleted: optional(array(SuiObjectRef)), - /** Object refs of objects now wrapped in other objects */ - wrapped: optional(array(SuiObjectRef)), - /** - * The updated gas object reference. Have a dedicated field for convenient access. - * It's also included in mutated. - */ - gasObject: OwnedObjectRef, - /** The events emitted during execution. Note that only successful transactions emit events */ - eventsDigest: nullable(optional(string())), - /** The set of transaction digests this transaction depends on */ - dependencies: optional(array(string())), -}); -export type TransactionEffects = Infer; - -export const TransactionEvents = array(SuiEvent); -export type TransactionEvents = Infer; - -const ReturnValueType = tuple([array(number()), string()]); -const MutableReferenceOutputType = tuple([SuiArgument, array(number()), string()]); -const ExecutionResultType = object({ - mutableReferenceOutputs: optional(array(MutableReferenceOutputType)), - returnValues: optional(array(ReturnValueType)), -}); - -export const DevInspectResults = object({ - effects: TransactionEffects, - events: TransactionEvents, - results: optional(array(ExecutionResultType)), - error: optional(string()), -}); -export type DevInspectResults = Infer; - -export type SuiTransactionBlockResponseQuery = { - filter?: TransactionFilter; - options?: SuiTransactionBlockResponseOptions; -}; - -export type TransactionFilter = - | { FromOrToAddress: { addr: string } } - | { Checkpoint: string } - | { FromAndToAddress: { from: string; to: string } } - | { TransactionKind: string } - | { - MoveFunction: { - package: string; - module: string | null; - function: string | null; - }; - } - | { InputObject: string } - | { ChangedObject: string } - | { FromAddress: string } - | { ToAddress: string }; - -export type EmptySignInfo = object; - -/** @deprecated Use `string` instead. */ -export const AuthorityName = string(); -/** @deprecated Use `string` instead. */ -export type AuthorityName = Infer; - -export const SuiTransactionBlock = object({ - data: SuiTransactionBlockData, - txSignatures: array(string()), -}); -export type SuiTransactionBlock = Infer; - -export const SuiObjectChangePublished = object({ - type: literal('published'), - packageId: string(), - version: string(), - digest: string(), - modules: array(string()), -}); -export type SuiObjectChangePublished = Infer; - -export const SuiObjectChangeTransferred = object({ - type: literal('transferred'), - sender: string(), - recipient: ObjectOwner, - objectType: string(), - objectId: string(), - version: string(), - digest: string(), -}); -export type SuiObjectChangeTransferred = Infer; - -export const SuiObjectChangeMutated = object({ - type: literal('mutated'), - sender: string(), - owner: ObjectOwner, - objectType: string(), - objectId: string(), - version: string(), - previousVersion: string(), - digest: string(), -}); -export type SuiObjectChangeMutated = Infer; - -export const SuiObjectChangeDeleted = object({ - type: literal('deleted'), - sender: string(), - objectType: string(), - objectId: string(), - version: string(), -}); -export type SuiObjectChangeDeleted = Infer; - -export const SuiObjectChangeWrapped = object({ - type: literal('wrapped'), - sender: string(), - objectType: string(), - objectId: string(), - version: string(), -}); -export type SuiObjectChangeWrapped = Infer; - -export const SuiObjectChangeCreated = object({ - type: literal('created'), - sender: string(), - owner: ObjectOwner, - objectType: string(), - objectId: string(), - version: string(), - digest: string(), -}); -export type SuiObjectChangeCreated = Infer; - -export const SuiObjectChange = union([ - SuiObjectChangePublished, - SuiObjectChangeTransferred, - SuiObjectChangeMutated, - SuiObjectChangeDeleted, - SuiObjectChangeWrapped, - SuiObjectChangeCreated, -]); -export type SuiObjectChange = Infer; - -export const BalanceChange = object({ - owner: ObjectOwner, - coinType: string(), - /* Coin balance change(positive means receive, negative means send) */ - amount: string(), -}); - -export const SuiTransactionBlockResponse = object({ - digest: string(), - transaction: optional(SuiTransactionBlock), - effects: optional(TransactionEffects), - events: optional(TransactionEvents), - timestampMs: optional(string()), - checkpoint: optional(string()), - confirmedLocalExecution: optional(boolean()), - objectChanges: optional(array(SuiObjectChange)), - balanceChanges: optional(array(BalanceChange)), - /* Errors that occurred in fetching/serializing the transaction. */ - errors: optional(array(string())), -}); -export type SuiTransactionBlockResponse = Infer; - -export const SuiTransactionBlockResponseOptions = object({ - /* Whether to show transaction input data. Default to be false. */ - showInput: optional(boolean()), - /* Whether to show transaction effects. Default to be false. */ - showEffects: optional(boolean()), - /* Whether to show transaction events. Default to be false. */ - showEvents: optional(boolean()), - /* Whether to show object changes. Default to be false. */ - showObjectChanges: optional(boolean()), - /* Whether to show coin balance changes. Default to be false. */ - showBalanceChanges: optional(boolean()), -}); - -export type SuiTransactionBlockResponseOptions = Infer; - -export const PaginatedTransactionResponse = object({ - data: array(SuiTransactionBlockResponse), - nextCursor: nullable(string()), - hasNextPage: boolean(), -}); -export type PaginatedTransactionResponse = Infer; -export const DryRunTransactionBlockResponse = object({ - effects: TransactionEffects, - events: TransactionEvents, - objectChanges: array(SuiObjectChange), - balanceChanges: array(BalanceChange), - // TODO: Remove optional when this is rolled out to all networks: - input: optional(SuiTransactionBlockData), -}); -export type DryRunTransactionBlockResponse = Infer; - -/* -------------------------------------------------------------------------- */ -/* Helper functions */ -/* -------------------------------------------------------------------------- */ - -export function getTransaction(tx: SuiTransactionBlockResponse): SuiTransactionBlock | undefined { - return tx.transaction; -} - -export function getTransactionDigest(tx: SuiTransactionBlockResponse): string { - return tx.digest; -} - -export function getTransactionSignature(tx: SuiTransactionBlockResponse): string[] | undefined { - return tx.transaction?.txSignatures; -} - -/* ----------------------------- TransactionData ---------------------------- */ - -export function getTransactionSender(tx: SuiTransactionBlockResponse): string | undefined { - return tx.transaction?.data.sender; -} - -export function getGasData(tx: SuiTransactionBlockResponse): SuiGasData | undefined { - return tx.transaction?.data.gasData; -} - -export function getTransactionGasObject( - tx: SuiTransactionBlockResponse, -): SuiObjectRef[] | undefined { - return getGasData(tx)?.payment; -} - -export function getTransactionGasPrice(tx: SuiTransactionBlockResponse) { - return getGasData(tx)?.price; -} - -export function getTransactionGasBudget(tx: SuiTransactionBlockResponse) { - return getGasData(tx)?.budget; -} - -export function getChangeEpochTransaction( - data: SuiTransactionBlockKind, -): SuiChangeEpoch | undefined { - return data.kind === 'ChangeEpoch' ? data : undefined; -} - -export function getConsensusCommitPrologueTransaction( - data: SuiTransactionBlockKind, -): SuiConsensusCommitPrologue | undefined { - return data.kind === 'ConsensusCommitPrologue' ? data : undefined; -} - -export function getTransactionKind( - data: SuiTransactionBlockResponse, -): SuiTransactionBlockKind | undefined { - return data.transaction?.data.transaction; -} - -export function getTransactionKindName(data: SuiTransactionBlockKind): TransactionKindName { - return data.kind; -} - -export function getProgrammableTransaction( - data: SuiTransactionBlockKind, -): ProgrammableTransaction | undefined { - return data.kind === 'ProgrammableTransaction' ? data : undefined; -} - -/* ----------------------------- ExecutionStatus ---------------------------- */ - -export function getExecutionStatusType( - data: SuiTransactionBlockResponse, -): ExecutionStatusType | undefined { - return getExecutionStatus(data)?.status; -} - -export function getExecutionStatus(data: SuiTransactionBlockResponse): ExecutionStatus | undefined { - return getTransactionEffects(data)?.status; -} - -export function getExecutionStatusError(data: SuiTransactionBlockResponse): string | undefined { - return getExecutionStatus(data)?.error; -} - -export function getExecutionStatusGasSummary( - data: SuiTransactionBlockResponse | TransactionEffects, -): GasCostSummary | undefined { - if (is(data, TransactionEffects)) { - return data.gasUsed; - } - return getTransactionEffects(data)?.gasUsed; -} - -export function getTotalGasUsed( - data: SuiTransactionBlockResponse | TransactionEffects, -): bigint | undefined { - const gasSummary = getExecutionStatusGasSummary(data); - return gasSummary - ? BigInt(gasSummary.computationCost) + - BigInt(gasSummary.storageCost) - - BigInt(gasSummary.storageRebate) - : undefined; -} - -export function getTotalGasUsedUpperBound( - data: SuiTransactionBlockResponse | TransactionEffects, -): bigint | undefined { - const gasSummary = getExecutionStatusGasSummary(data); - return gasSummary - ? BigInt(gasSummary.computationCost) + BigInt(gasSummary.storageCost) - : undefined; -} - -export function getTransactionEffects( - data: SuiTransactionBlockResponse, -): TransactionEffects | undefined { - return data.effects; -} - -/* ---------------------------- Transaction Effects --------------------------- */ - -export function getEvents(data: SuiTransactionBlockResponse): SuiEvent[] | undefined { - return data.events; -} - -export function getCreatedObjects(data: SuiTransactionBlockResponse): OwnedObjectRef[] | undefined { - return getTransactionEffects(data)?.created; -} - -/* --------------------------- TransactionResponse -------------------------- */ - -export function getTimestampFromTransactionResponse( - data: SuiTransactionBlockResponse, -): string | undefined { - return data.timestampMs ?? undefined; -} - -/** - * Get the newly created coin refs after a split. - */ -export function getNewlyCreatedCoinRefsAfterSplit( - data: SuiTransactionBlockResponse, -): SuiObjectRef[] | undefined { - return getTransactionEffects(data)?.created?.map((c) => c.reference); -} - -export function getObjectChanges(data: SuiTransactionBlockResponse): SuiObjectChange[] | undefined { - return data.objectChanges; -} - -export function getPublishedObjectChanges( - data: SuiTransactionBlockResponse, -): SuiObjectChangePublished[] { - return ( - (data.objectChanges?.filter((a) => - is(a, SuiObjectChangePublished), - ) as SuiObjectChangePublished[]) ?? [] - ); -} diff --git a/sdk/typescript/src/types/validator.ts b/sdk/typescript/src/types/validator.ts deleted file mode 100644 index e6b0a0b28a51d..0000000000000 --- a/sdk/typescript/src/types/validator.ts +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// SPDX-License-Identifier: Apache-2.0 - -import type { Infer } from 'superstruct'; -import { - array, - boolean, - literal, - nullable, - number, - object, - optional, - string, - tuple, - union, -} from 'superstruct'; - -/* -------------- Types for the SuiSystemState Rust definition -------------- */ - -export type DelegatedStake = Infer; -export type CommitteeInfo = Infer; -export type StakeObject = Infer; - -// APY Response -export const Apy = object({ - apy: number(), - address: string(), -}); - -export const ValidatorsApy = object({ - epoch: string(), - apys: array(Apy), -}); - -export type ValidatorsApy = Infer; - -// Staking -export const Balance = object({ - value: number(), -}); - -export const StakeObject = object({ - stakedSuiId: string(), - stakeRequestEpoch: string(), - stakeActiveEpoch: string(), - principal: string(), - status: union([literal('Active'), literal('Pending'), literal('Unstaked')]), - estimatedReward: optional(string()), -}); - -export const DelegatedStake = object({ - validatorAddress: string(), - stakingPool: string(), - stakes: array(StakeObject), -}); - -export const StakeSubsidyFields = object({ - balance: object({ value: number() }), - distribution_counter: number(), - current_distribution_amount: number(), - stake_subsidy_period_length: number(), - stake_subsidy_decrease_rate: number(), -}); - -export const StakeSubsidy = object({ - type: string(), - fields: StakeSubsidyFields, -}); - -export const SuiSupplyFields = object({ - value: number(), -}); - -export const ContentsFields = object({ - id: string(), - size: number(), - head: object({ vec: array() }), - tail: object({ vec: array() }), -}); - -export const ContentsFieldsWithdraw = object({ - id: string(), - size: number(), -}); - -export const Contents = object({ - type: string(), - fields: ContentsFields, -}); - -export const DelegationStakingPoolFields = object({ - exchangeRates: object({ - id: string(), - size: number(), - }), - id: string(), - pendingStake: number(), - pendingPoolTokenWithdraw: number(), - pendingTotalSuiWithdraw: number(), - poolTokenBalance: number(), - rewardsPool: object({ value: number() }), - activationEpoch: object({ vec: array() }), - deactivationEpoch: object({ vec: array() }), - suiBalance: number(), -}); - -export const DelegationStakingPool = object({ - type: string(), - fields: DelegationStakingPoolFields, -}); - -export const Validators = array(tuple([string(), string()])); - -export const CommitteeInfo = object({ - epoch: string(), - /** Array of (validator public key, stake unit) tuple */ - validators: Validators, -}); - -export const SuiValidatorSummary = object({ - suiAddress: string(), - protocolPubkeyBytes: string(), - networkPubkeyBytes: string(), - workerPubkeyBytes: string(), - proofOfPossessionBytes: string(), - operationCapId: string(), - name: string(), - description: string(), - imageUrl: string(), - projectUrl: string(), - p2pAddress: string(), - netAddress: string(), - primaryAddress: string(), - workerAddress: string(), - nextEpochProtocolPubkeyBytes: nullable(string()), - nextEpochProofOfPossession: nullable(string()), - nextEpochNetworkPubkeyBytes: nullable(string()), - nextEpochWorkerPubkeyBytes: nullable(string()), - nextEpochNetAddress: nullable(string()), - nextEpochP2pAddress: nullable(string()), - nextEpochPrimaryAddress: nullable(string()), - nextEpochWorkerAddress: nullable(string()), - votingPower: string(), - gasPrice: string(), - commissionRate: string(), - nextEpochStake: string(), - nextEpochGasPrice: string(), - nextEpochCommissionRate: string(), - stakingPoolId: string(), - stakingPoolActivationEpoch: nullable(string()), - stakingPoolDeactivationEpoch: nullable(string()), - stakingPoolSuiBalance: string(), - rewardsPool: string(), - poolTokenBalance: string(), - pendingStake: string(), - pendingPoolTokenWithdraw: string(), - pendingTotalSuiWithdraw: string(), - exchangeRatesId: string(), - exchangeRatesSize: string(), -}); - -export type SuiValidatorSummary = Infer; - -export const SuiSystemStateSummary = object({ - epoch: string(), - protocolVersion: string(), - systemStateVersion: string(), - storageFundTotalObjectStorageRebates: string(), - storageFundNonRefundableBalance: string(), - referenceGasPrice: string(), - safeMode: boolean(), - safeModeStorageRewards: string(), - safeModeComputationRewards: string(), - safeModeStorageRebates: string(), - safeModeNonRefundableStorageFee: string(), - epochStartTimestampMs: string(), - epochDurationMs: string(), - stakeSubsidyStartEpoch: string(), - maxValidatorCount: string(), - minValidatorJoiningStake: string(), - validatorLowStakeThreshold: string(), - validatorVeryLowStakeThreshold: string(), - validatorLowStakeGracePeriod: string(), - stakeSubsidyBalance: string(), - stakeSubsidyDistributionCounter: string(), - stakeSubsidyCurrentDistributionAmount: string(), - stakeSubsidyPeriodLength: string(), - stakeSubsidyDecreaseRate: number(), - totalStake: string(), - activeValidators: array(SuiValidatorSummary), - pendingActiveValidatorsId: string(), - pendingActiveValidatorsSize: string(), - pendingRemovals: array(string()), - stakingPoolMappingsId: string(), - stakingPoolMappingsSize: string(), - inactivePoolsId: string(), - inactivePoolsSize: string(), - validatorCandidatesId: string(), - validatorCandidatesSize: string(), - atRiskValidators: array(tuple([string(), string()])), - validatorReportRecords: array(tuple([string(), array(string())])), -}); - -export type SuiSystemStateSummary = Infer; diff --git a/sdk/typescript/test/unit/cryptography/ed25519-publickey.test.ts b/sdk/typescript/test/unit/cryptography/ed25519-publickey.test.ts index 7f1b2e2da4ff1..31fe3542724bb 100644 --- a/sdk/typescript/test/unit/cryptography/ed25519-publickey.test.ts +++ b/sdk/typescript/test/unit/cryptography/ed25519-publickey.test.ts @@ -63,7 +63,6 @@ describe('Ed25519PublicKey', () => { it('toBase64', () => { const key = new Ed25519PublicKey(VALID_KEY_BASE64); expect(key.toBase64()).toEqual(VALID_KEY_BASE64); - expect(key.toString()).toEqual(VALID_KEY_BASE64); }); it('toBuffer', () => { diff --git a/sdk/typescript/test/unit/cryptography/secp256k1-publickey.test.ts b/sdk/typescript/test/unit/cryptography/secp256k1-publickey.test.ts index 1fa4e2dc7dd48..6c887e8135b0e 100644 --- a/sdk/typescript/test/unit/cryptography/secp256k1-publickey.test.ts +++ b/sdk/typescript/test/unit/cryptography/secp256k1-publickey.test.ts @@ -62,7 +62,6 @@ describe('Secp256k1PublicKey', () => { let pub_key_base64 = toB64(pub_key); const key = new Secp256k1PublicKey(pub_key_base64); expect(key.toBase64()).toEqual(pub_key_base64); - expect(key.toString()).toEqual(pub_key_base64); }); it('toBuffer', () => { diff --git a/sdk/typescript/test/unit/cryptography/secp256r1-publickey.test.ts b/sdk/typescript/test/unit/cryptography/secp256r1-publickey.test.ts index 38f26057eae97..fc238799f2119 100644 --- a/sdk/typescript/test/unit/cryptography/secp256r1-publickey.test.ts +++ b/sdk/typescript/test/unit/cryptography/secp256r1-publickey.test.ts @@ -47,7 +47,6 @@ describe('Secp256r1PublicKey', () => { let pub_key_base64 = toB64(pub_key); const key = new Secp256r1PublicKey(pub_key_base64); expect(key.toBase64()).toEqual(pub_key_base64); - expect(key.toString()).toEqual(pub_key_base64); }); it('toBuffer', () => { diff --git a/sdk/wallet-kit/react/src/UnsafeBurnerWallet.tsx b/sdk/wallet-kit/react/src/UnsafeBurnerWallet.tsx index ff7feb6fe718c..e094b8e4f0546 100644 --- a/sdk/wallet-kit/react/src/UnsafeBurnerWallet.tsx +++ b/sdk/wallet-kit/react/src/UnsafeBurnerWallet.tsx @@ -47,7 +47,7 @@ export function registerUnsafeBurnerWallet( address: keypair.getPublicKey().toSuiAddress(), chains: ['sui:unknown'], features: ['sui:signAndExecuteTransactionBlock', 'sui:signTransactionBlock'], - publicKey: keypair.getPublicKey().toBytes(), + publicKey: keypair.getPublicKey().toRawBytes(), }); class UnsafeBurnerWallet implements Wallet {