diff --git a/.changeset/consolidate-graphql-schemas.md b/.changeset/consolidate-graphql-schemas.md
new file mode 100644
index 000000000..7c7b34a19
--- /dev/null
+++ b/.changeset/consolidate-graphql-schemas.md
@@ -0,0 +1,11 @@
+---
+'@mysten/sui': major
+---
+
+Consolidate GraphQL schema exports into a single version:
+
+- Removed versioned schema exports: `@mysten/sui/graphql/schemas/2024.1`, `@mysten/sui/graphql/schemas/2024.4`, `@mysten/sui/graphql/schemas/latest`
+- Added single unified schema export: `@mysten/sui/graphql/schema`
+- The SDK now tracks only the latest mainnet GraphQL schema version
+
+See the migration guide for updating your code to use the new export
diff --git a/.changeset/curly-boxes-follow.md b/.changeset/curly-boxes-follow.md
new file mode 100644
index 000000000..e7dba4469
--- /dev/null
+++ b/.changeset/curly-boxes-follow.md
@@ -0,0 +1,5 @@
+---
+'@mysten/dapp-kit': minor
+---
+
+Remove reportTransactionEffects feature
diff --git a/.changeset/dry-dingos-raise.md b/.changeset/dry-dingos-raise.md
new file mode 100644
index 000000000..66ba967e7
--- /dev/null
+++ b/.changeset/dry-dingos-raise.md
@@ -0,0 +1,6 @@
+---
+'@mysten/walrus': minor
+'@mysten/seal': minor
+---
+
+remove asClientExtension static method
diff --git a/.changeset/dull-bikes-bet.md b/.changeset/dull-bikes-bet.md
new file mode 100644
index 000000000..40ce8bb86
--- /dev/null
+++ b/.changeset/dull-bikes-bet.md
@@ -0,0 +1,5 @@
+---
+'@mysten/sui': patch
+---
+
+Change private key data on keypairs to be private fields to prevent accidental logging.
diff --git a/.changeset/fair-laws-jog.md b/.changeset/fair-laws-jog.md
new file mode 100644
index 000000000..78536de5a
--- /dev/null
+++ b/.changeset/fair-laws-jog.md
@@ -0,0 +1,5 @@
+---
+'@mysten/walrus': minor
+---
+
+WalrusClient can no longer be created with only an rpc url, pass in a Client instead
diff --git a/.changeset/fruity-cats-grab.md b/.changeset/fruity-cats-grab.md
new file mode 100644
index 000000000..db0677ccb
--- /dev/null
+++ b/.changeset/fruity-cats-grab.md
@@ -0,0 +1,5 @@
+---
+'@mysten/sui': major
+---
+
+Remove default client used for verifying zklogin signatures
diff --git a/.changeset/honest-cows-shave.md b/.changeset/honest-cows-shave.md
new file mode 100644
index 000000000..d430645a9
--- /dev/null
+++ b/.changeset/honest-cows-shave.md
@@ -0,0 +1,5 @@
+---
+'@mysten/sui': major
+---
+
+`network` is now a required option on SuiGraphQLClient and SuiJsonRpcClient
diff --git a/.changeset/little-chefs-shake.md b/.changeset/little-chefs-shake.md
new file mode 100644
index 000000000..fb15e6381
--- /dev/null
+++ b/.changeset/little-chefs-shake.md
@@ -0,0 +1,5 @@
+---
+'@mysten/sui': major
+---
+
+Make legacyAddress parameter in all methods to reduce confusion and inconsistency around default values
diff --git a/.changeset/mean-bikes-drum.md b/.changeset/mean-bikes-drum.md
new file mode 100644
index 000000000..0b4d6f089
--- /dev/null
+++ b/.changeset/mean-bikes-drum.md
@@ -0,0 +1,5 @@
+---
+'@mysten/wallet-standard': minor
+---
+
+Remove reportTransactionEffects feature
diff --git a/.changeset/remove-bcs-deprecated-exports.md b/.changeset/remove-bcs-deprecated-exports.md
new file mode 100644
index 000000000..7b54cebaf
--- /dev/null
+++ b/.changeset/remove-bcs-deprecated-exports.md
@@ -0,0 +1,5 @@
+---
+'@mysten/bcs': major
+---
+
+Remove deprecated exports: `toB58`, `fromB58`, `toB64`, `fromB64`, `toHEX`, `fromHEX`. Use `toBase58`, `fromBase58`, `toBase64`, `fromBase64`, `toHex`, `fromHex` instead.
diff --git a/.changeset/remove-kiosk-deprecated-params.md b/.changeset/remove-kiosk-deprecated-params.md
new file mode 100644
index 000000000..447c132bc
--- /dev/null
+++ b/.changeset/remove-kiosk-deprecated-params.md
@@ -0,0 +1,5 @@
+---
+'@mysten/kiosk': minor
+---
+
+Remove deprecated `transactionBlock` parameter from `KioskTransaction`, `TransferPolicyTransaction`, and `RuleResolvingParams`. Use `transaction` parameter instead.
diff --git a/.changeset/remove-signers-deprecated-methods.md b/.changeset/remove-signers-deprecated-methods.md
new file mode 100644
index 000000000..60933e47c
--- /dev/null
+++ b/.changeset/remove-signers-deprecated-methods.md
@@ -0,0 +1,5 @@
+---
+'@mysten/signers': minor
+---
+
+Remove deprecated `signData()` method from `AwsKmsSigner`, `GcpKmsSigner`, and `MultiSigSigner`. Use `sign()` method instead.
diff --git a/.changeset/remove-suiclient-exports.md b/.changeset/remove-suiclient-exports.md
new file mode 100644
index 000000000..d99b8f7e3
--- /dev/null
+++ b/.changeset/remove-suiclient-exports.md
@@ -0,0 +1,25 @@
+---
+'@mysten/sui': major
+---
+
+Remove SuiClient exports from @mysten/sui/client
+
+BREAKING CHANGE: All exports from `@mysten/sui/client` have been removed. Use `@mysten/sui/jsonRpc` instead:
+
+- `SuiClient` -> `SuiJsonRpcClient`
+- `SuiClientOptions` -> `SuiJsonRpcClientOptions`
+- `isSuiClient` -> `isSuiJsonRpcClient`
+- `SuiTransport` -> `JsonRpcTransport`
+- `getFullnodeUrl` -> `getJsonRpcFullnodeUrl`
+
+Migration example:
+
+```ts
+// Before
+import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
+const client = new SuiClient({ url: getFullnodeUrl('devnet'), network: 'devnet' });
+
+// After
+import { SuiJsonRpcClient, getJsonRpcFullnodeUrl } from '@mysten/sui/jsonRpc';
+const client = new SuiJsonRpcClient({ url: getJsonRpcFullnodeUrl('devnet'), network: 'devnet' });
+```
diff --git a/.changeset/remove-typescript-deprecated-exports.md b/.changeset/remove-typescript-deprecated-exports.md
new file mode 100644
index 000000000..7219beed0
--- /dev/null
+++ b/.changeset/remove-typescript-deprecated-exports.md
@@ -0,0 +1,15 @@
+---
+'@mysten/sui': major
+---
+
+Remove deprecated exports and properties:
+
+- Removed `fromB64`, `toB64`, `fromHEX`, `toHEX` exports from utils (use `fromBase64`, `toBase64`, `fromHex`, `toHex` instead)
+- Removed `schema` property from `ParsedKeypair` (use `scheme` instead)
+- Removed `requestType` parameter from `executeTransactionBlock`
+- Removed deprecated faucet methods: `requestSuiFromFaucetV0`, `requestSuiFromFaucetV1`, `getFaucetRequestStatus` (use `requestSuiFromFaucetV2` instead)
+- Removed deprecated subscription methods: `subscribeEvent`, `subscribeTransaction`
+- Removed `blockData` property from Transaction class (use `getData()` instead)
+- Removed `gasConfig` property from TransactionDataBuilder (use `gasData` instead)
+- Removed `NamedPackagesPluginCache` type export (use `NamedPackagesOverrides` instead)
+- Removed unnamed plugin registration methods from Transaction class
diff --git a/.changeset/stabilize-experimental-client-api.md b/.changeset/stabilize-experimental-client-api.md
new file mode 100644
index 000000000..63844af75
--- /dev/null
+++ b/.changeset/stabilize-experimental-client-api.md
@@ -0,0 +1,15 @@
+---
+'@mysten/sui': major
+---
+
+Stabilize experimental client API by moving it from `@mysten/sui/experimental` to `@mysten/sui/client`:
+
+- Moved client implementation from `src/experimental/` to `src/client/`
+- Removed `Experimental_` prefix from all client types and classes
+- Updated all internal packages to use the new stable API
+
+Breaking changes:
+
+- `@mysten/sui/experimental` module has been removed
+- All `Experimental_` prefixed types/classes have been renamed (e.g., `Experimental_CoreClient` → `CoreClient`)
+- Client types namespace changed from `Experimental_SuiClientTypes` to `SuiClientTypes`
diff --git a/.changeset/update-all-packages-suiclient.md b/.changeset/update-all-packages-suiclient.md
new file mode 100644
index 000000000..65cd39791
--- /dev/null
+++ b/.changeset/update-all-packages-suiclient.md
@@ -0,0 +1,19 @@
+---
+'@mysten/dapp-kit': minor
+'@mysten/kiosk': minor
+'@mysten/deepbook': minor
+'@mysten/deepbook-v3': minor
+'@mysten/suins': minor
+'@mysten/walrus': minor
+'@mysten/zksend': minor
+'@mysten/codegen': minor
+'@mysten/enoki': minor
+'@mysten/payment-kit': minor
+'@mysten/seal': minor
+'@mysten/signers': minor
+'@mysten/wallet-sdk': minor
+---
+
+Update to use SuiJsonRpcClient instead of SuiClient
+
+Updated all type signatures, internal usages, examples, and documentation to use `SuiJsonRpcClient` from `@mysten/sui/jsonRpc` instead of the deprecated `SuiClient` from `@mysten/sui/client`.
diff --git a/.eslintrc.js b/.eslintrc.js
index 48bc6dfc3..8a1464b61 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -38,6 +38,7 @@ module.exports = {
'packages/move-bytecode-template',
'packages/walrus-wasm',
'packages/walrus/src/node-api',
+ 'packages/walrus/src/contracts',
'generated',
'vite-env.d.ts',
],
diff --git a/packages/bcs/src/index.ts b/packages/bcs/src/index.ts
index 8c84e675b..88f6e6c17 100644
--- a/packages/bcs/src/index.ts
+++ b/packages/bcs/src/index.ts
@@ -62,21 +62,3 @@ export {
type EnumInputShape,
type EnumOutputShapeWithKeys,
};
-
-/** @deprecated use toBase58 instead */
-export const toB58 = toBase58;
-
-/** @deprecated use fromBase58 instead */
-export const fromB58 = fromBase58;
-
-/** @deprecated use toBase64 instead */
-export const toB64 = toBase64;
-
-/** @deprecated use fromBase64 instead */
-export const fromB64 = fromBase64;
-
-/** @deprecated use toHex instead */
-export const toHEX = toHex;
-
-/** @deprecated use fromHex instead */
-export const fromHEX = fromHex;
diff --git a/packages/codegen/README.md b/packages/codegen/README.md
index 3ecb3d356..ecb00be4e 100644
--- a/packages/codegen/README.md
+++ b/packages/codegen/README.md
@@ -31,8 +31,8 @@ export default config;
```
The `package` field should be the MVR name for your move package. If you have not registered your
-package on MVR yet, you can use the `@local-pkg` scope, and set up an override in your `SuiClient`
-to resolve it to the correct address.
+package on MVR yet, you can use the `@local-pkg` scope, and set up an override in your
+`SuiJsonRpcClient` to resolve it to the correct address.
## Generating code
@@ -65,14 +65,14 @@ or by adding something the following script to your package.json and running `pn
}
```
-## Setting up SuiClient
+## Setting up SuiJsonRpcClient
If your package is registered on MVR, the generated code should work without additional
-configuration. If you are using a `@local-pkg` name, you will need to configure your `SuiClient` to
-resolver the package name correctly:
+configuration. If you are using a `@local-pkg` name, you will need to configure your
+`SuiJsonRpcClient` to resolver the package name correctly:
```ts
-const client = new SuiClient({
+const client = new SuiJsonRpcClient({
network: 'testnet',
url: testnetRpcUrl,
mvr: {
@@ -90,7 +90,7 @@ If you are using `dapp-kit`, you may need to set up your network config and `Sui
```ts
const { networkConfig, useNetworkVariable, useNetworkVariables } = createNetworkConfig({
testnet: {
- url: getFullnodeUrl('testnet'),
+ url: getJsonRpcFullnodeUrl('testnet'),
variables: {
yourPackageId: YOUR_TESTNET_PACKAGE_ID,
},
@@ -103,7 +103,7 @@ const { networkConfig, useNetworkVariable, useNetworkVariables } = createNetwork
networks={networkConfig}
defaultNetwork="testnet"
createClient={(network, config) => {
- return new SuiClient({
+ return new SuiJsonRpcClient({
network,
url: config.url,
mvr: {
diff --git a/packages/create-dapp/templates/react-client-dapp/src/networkConfig.ts b/packages/create-dapp/templates/react-client-dapp/src/networkConfig.ts
index 96de92158..97bc1ee6b 100644
--- a/packages/create-dapp/templates/react-client-dapp/src/networkConfig.ts
+++ b/packages/create-dapp/templates/react-client-dapp/src/networkConfig.ts
@@ -1,16 +1,19 @@
-import { getFullnodeUrl } from "@mysten/sui/client";
+import { getJsonRpcFullnodeUrl } from "@mysten/sui/jsonRpc";
import { createNetworkConfig } from "@mysten/dapp-kit";
const { networkConfig, useNetworkVariable, useNetworkVariables } =
createNetworkConfig({
devnet: {
- url: getFullnodeUrl("devnet"),
+ url: getJsonRpcFullnodeUrl("devnet"),
+ network: "devnet",
},
testnet: {
- url: getFullnodeUrl("testnet"),
+ url: getJsonRpcFullnodeUrl("testnet"),
+ network: "testnet",
},
mainnet: {
- url: getFullnodeUrl("mainnet"),
+ url: getJsonRpcFullnodeUrl("mainnet"),
+ network: "mainnet",
},
});
diff --git a/packages/create-dapp/templates/react-e2e-counter/src/networkConfig.ts b/packages/create-dapp/templates/react-e2e-counter/src/networkConfig.ts
index 7b6f8b73d..351931614 100644
--- a/packages/create-dapp/templates/react-e2e-counter/src/networkConfig.ts
+++ b/packages/create-dapp/templates/react-e2e-counter/src/networkConfig.ts
@@ -1,4 +1,4 @@
-import { getFullnodeUrl } from "@mysten/sui/client";
+import { getJsonRpcFullnodeUrl } from "@mysten/sui/jsonRpc";
import {
DEVNET_COUNTER_PACKAGE_ID,
TESTNET_COUNTER_PACKAGE_ID,
@@ -9,19 +9,22 @@ import { createNetworkConfig } from "@mysten/dapp-kit";
const { networkConfig, useNetworkVariable, useNetworkVariables } =
createNetworkConfig({
devnet: {
- url: getFullnodeUrl("devnet"),
+ url: getJsonRpcFullnodeUrl("devnet"),
+ network: "devnet",
variables: {
counterPackageId: DEVNET_COUNTER_PACKAGE_ID,
},
},
testnet: {
- url: getFullnodeUrl("testnet"),
+ url: getJsonRpcFullnodeUrl("testnet"),
+ network: "testnet",
variables: {
counterPackageId: TESTNET_COUNTER_PACKAGE_ID,
},
},
mainnet: {
- url: getFullnodeUrl("mainnet"),
+ url: getJsonRpcFullnodeUrl("mainnet"),
+ network: "mainnet",
variables: {
counterPackageId: MAINNET_COUNTER_PACKAGE_ID,
},
diff --git a/packages/dapp-kit-next/examples/next-js/simple/app/dApp-kit.ts b/packages/dapp-kit-next/examples/next-js/simple/app/dApp-kit.ts
index 6ac309dac..c6f3a4115 100644
--- a/packages/dapp-kit-next/examples/next-js/simple/app/dApp-kit.ts
+++ b/packages/dapp-kit-next/examples/next-js/simple/app/dApp-kit.ts
@@ -2,14 +2,14 @@
// SPDX-License-Identifier: Apache-2.0
import { createDAppKit } from '@mysten/dapp-kit-react';
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
export const dAppKit = createDAppKit({
enableBurnerWallet: process.env.NODE_ENV === 'development',
networks: ['mainnet', 'testnet'],
defaultNetwork: 'testnet',
createClient(network) {
- return new SuiClient({ network, url: getFullnodeUrl(network) });
+ return new SuiJsonRpcClient({ network, url: getJsonRpcFullnodeUrl(network) });
},
});
diff --git a/packages/dapp-kit-next/examples/next-js/simple/app/globals.css b/packages/dapp-kit-next/examples/next-js/simple/app/globals.css
index f4eb179d7..f38fb903c 100644
--- a/packages/dapp-kit-next/examples/next-js/simple/app/globals.css
+++ b/packages/dapp-kit-next/examples/next-js/simple/app/globals.css
@@ -1,13 +1,13 @@
:root {
- font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
- line-height: 1.5;
- font-weight: 400;
+ font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
+ line-height: 1.5;
+ font-weight: 400;
- color: #213547;
- background-color: #ffffff;
+ color: #213547;
+ background-color: #ffffff;
- font-synthesis: none;
- text-rendering: optimizeLegibility;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
+ font-synthesis: none;
+ text-rendering: optimizeLegibility;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
}
diff --git a/packages/dapp-kit-next/examples/next-js/simple/eslint.config.mjs b/packages/dapp-kit-next/examples/next-js/simple/eslint.config.mjs
index 537c89b70..9b7e5ed98 100644
--- a/packages/dapp-kit-next/examples/next-js/simple/eslint.config.mjs
+++ b/packages/dapp-kit-next/examples/next-js/simple/eslint.config.mjs
@@ -2,12 +2,12 @@ import { FlatCompat } from '@eslint/eslintrc';
const compat = new FlatCompat({
baseDirectory: import.meta.dirname,
-})
+});
const eslintConfig = [
...compat.config({
extends: ['next'],
}),
-]
+];
-export default eslintConfig;
\ No newline at end of file
+export default eslintConfig;
diff --git a/packages/dapp-kit-next/examples/next-js/simple/tsconfig.json b/packages/dapp-kit-next/examples/next-js/simple/tsconfig.json
index 41a5af9a5..bc58dd01f 100644
--- a/packages/dapp-kit-next/examples/next-js/simple/tsconfig.json
+++ b/packages/dapp-kit-next/examples/next-js/simple/tsconfig.json
@@ -1,30 +1,30 @@
{
- "compilerOptions": {
- "target": "ES2017",
- "lib": ["dom", "dom.iterable", "esnext"],
- "allowJs": true,
- "skipLibCheck": true,
- "strict": true,
- "noEmit": true,
- "esModuleInterop": true,
- "module": "esnext",
- "moduleResolution": "bundler",
- "allowImportingTsExtensions": true,
- "resolveJsonModule": true,
- "isolatedModules": true,
- "jsx": "preserve",
- "incremental": true,
- "experimentalDecorators": true,
- "useDefineForClassFields": false,
- "plugins": [
- {
- "name": "next"
- }
- ],
- "paths": {
- "@/*": ["./*"]
- }
- },
- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
- "exclude": ["node_modules"]
+ "compilerOptions": {
+ "target": "ES2017",
+ "lib": ["dom", "dom.iterable", "esnext"],
+ "allowJs": true,
+ "skipLibCheck": true,
+ "strict": true,
+ "noEmit": true,
+ "esModuleInterop": true,
+ "module": "esnext",
+ "moduleResolution": "bundler",
+ "allowImportingTsExtensions": true,
+ "resolveJsonModule": true,
+ "isolatedModules": true,
+ "jsx": "preserve",
+ "incremental": true,
+ "experimentalDecorators": true,
+ "useDefineForClassFields": false,
+ "plugins": [
+ {
+ "name": "next"
+ }
+ ],
+ "paths": {
+ "@/*": ["./*"]
+ }
+ },
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
+ "exclude": ["node_modules"]
}
diff --git a/packages/dapp-kit-next/examples/react/simple/src/dApp-kit.ts b/packages/dapp-kit-next/examples/react/simple/src/dApp-kit.ts
index 58e3425ce..dd7742e4e 100644
--- a/packages/dapp-kit-next/examples/react/simple/src/dApp-kit.ts
+++ b/packages/dapp-kit-next/examples/react/simple/src/dApp-kit.ts
@@ -2,14 +2,14 @@
// SPDX-License-Identifier: Apache-2.0
import { createDAppKit } from '@mysten/dapp-kit-react';
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
export const dAppKit = createDAppKit({
enableBurnerWallet: import.meta.env.DEV,
networks: ['mainnet', 'testnet'],
defaultNetwork: 'testnet',
createClient(network) {
- return new SuiClient({ network, url: getFullnodeUrl(network) });
+ return new SuiJsonRpcClient({ network, url: getJsonRpcFullnodeUrl(network) });
},
});
diff --git a/packages/dapp-kit-next/examples/vanilla/simple/src/main.ts b/packages/dapp-kit-next/examples/vanilla/simple/src/main.ts
index 41b09c548..633afcb48 100644
--- a/packages/dapp-kit-next/examples/vanilla/simple/src/main.ts
+++ b/packages/dapp-kit-next/examples/vanilla/simple/src/main.ts
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { createDAppKit } from '@mysten/dapp-kit-core';
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import '@mysten/dapp-kit-core/web';
@@ -13,7 +13,7 @@ const dAppKit = createDAppKit({
networks: ['mainnet', 'testnet'],
defaultNetwork: 'testnet',
createClient(network) {
- return new SuiClient({ network, url: getFullnodeUrl(network) });
+ return new SuiJsonRpcClient({ network, url: getJsonRpcFullnodeUrl(network) });
},
});
diff --git a/packages/dapp-kit-next/examples/vue/simple/index.html b/packages/dapp-kit-next/examples/vue/simple/index.html
index 7f1788378..1dae23da3 100644
--- a/packages/dapp-kit-next/examples/vue/simple/index.html
+++ b/packages/dapp-kit-next/examples/vue/simple/index.html
@@ -6,7 +6,7 @@
DApp Kit Vue Simple Example App
-
+
diff --git a/packages/dapp-kit-next/examples/vue/simple/src/App.vue b/packages/dapp-kit-next/examples/vue/simple/src/App.vue
index 06bed5374..ba76f4272 100644
--- a/packages/dapp-kit-next/examples/vue/simple/src/App.vue
+++ b/packages/dapp-kit-next/examples/vue/simple/src/App.vue
@@ -5,4 +5,3 @@ import { dAppKit } from './dapp-kit';
-
diff --git a/packages/dapp-kit-next/examples/vue/simple/src/dapp-kit.ts b/packages/dapp-kit-next/examples/vue/simple/src/dapp-kit.ts
index 68e44b94b..f482afce3 100644
--- a/packages/dapp-kit-next/examples/vue/simple/src/dapp-kit.ts
+++ b/packages/dapp-kit-next/examples/vue/simple/src/dapp-kit.ts
@@ -2,13 +2,13 @@
// SPDX-License-Identifier: Apache-2.0
import { createDAppKit } from '@mysten/dapp-kit-core';
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
export const dAppKit = createDAppKit({
enableBurnerWallet: import.meta.env.DEV,
networks: ['mainnet', 'testnet'],
defaultNetwork: 'testnet',
createClient(network) {
- return new SuiClient({ network, url: getFullnodeUrl(network) });
+ return new SuiJsonRpcClient({ network, url: getJsonRpcFullnodeUrl(network) });
},
});
diff --git a/packages/dapp-kit-next/examples/vue/simple/tsconfig.app.json b/packages/dapp-kit-next/examples/vue/simple/tsconfig.app.json
index 11f33457d..26c680081 100644
--- a/packages/dapp-kit-next/examples/vue/simple/tsconfig.app.json
+++ b/packages/dapp-kit-next/examples/vue/simple/tsconfig.app.json
@@ -1,12 +1,12 @@
{
- "extends": "@vue/tsconfig/tsconfig.dom.json",
- "include": ["src/**/*", "src/**/*.vue"],
- "exclude": ["src/**/__tests__/*"],
- "compilerOptions": {
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
+ "extends": "@vue/tsconfig/tsconfig.dom.json",
+ "include": ["src/**/*", "src/**/*.vue"],
+ "exclude": ["src/**/__tests__/*"],
+ "compilerOptions": {
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
- "paths": {
- "@/*": ["./src/*"]
- }
- }
+ "paths": {
+ "@/*": ["./src/*"]
+ }
+ }
}
diff --git a/packages/dapp-kit-next/examples/vue/simple/tsconfig.json b/packages/dapp-kit-next/examples/vue/simple/tsconfig.json
index 66b5e5703..ae91ebf72 100644
--- a/packages/dapp-kit-next/examples/vue/simple/tsconfig.json
+++ b/packages/dapp-kit-next/examples/vue/simple/tsconfig.json
@@ -1,11 +1,11 @@
{
- "files": [],
- "references": [
- {
- "path": "./tsconfig.node.json"
- },
- {
- "path": "./tsconfig.app.json"
- }
- ]
+ "files": [],
+ "references": [
+ {
+ "path": "./tsconfig.node.json"
+ },
+ {
+ "path": "./tsconfig.app.json"
+ }
+ ]
}
diff --git a/packages/dapp-kit-next/examples/vue/simple/tsconfig.node.json b/packages/dapp-kit-next/examples/vue/simple/tsconfig.node.json
index a83dfc9d4..8731853d7 100644
--- a/packages/dapp-kit-next/examples/vue/simple/tsconfig.node.json
+++ b/packages/dapp-kit-next/examples/vue/simple/tsconfig.node.json
@@ -1,19 +1,19 @@
{
- "extends": "@tsconfig/node22/tsconfig.json",
- "include": [
- "vite.config.*",
- "vitest.config.*",
- "cypress.config.*",
- "nightwatch.conf.*",
- "playwright.config.*",
- "eslint.config.*"
- ],
- "compilerOptions": {
- "noEmit": true,
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
+ "extends": "@tsconfig/node22/tsconfig.json",
+ "include": [
+ "vite.config.*",
+ "vitest.config.*",
+ "cypress.config.*",
+ "nightwatch.conf.*",
+ "playwright.config.*",
+ "eslint.config.*"
+ ],
+ "compilerOptions": {
+ "noEmit": true,
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
- "module": "ESNext",
- "moduleResolution": "Bundler",
- "types": ["node"]
- }
+ "module": "ESNext",
+ "moduleResolution": "Bundler",
+ "types": ["node"]
+ }
}
diff --git a/packages/dapp-kit-next/packages/dapp-kit-core/src/core/types.ts b/packages/dapp-kit-next/packages/dapp-kit-core/src/core/types.ts
index ab4da3d00..00dfeb595 100644
--- a/packages/dapp-kit-next/packages/dapp-kit-core/src/core/types.ts
+++ b/packages/dapp-kit-next/packages/dapp-kit-core/src/core/types.ts
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { ClientWithCoreApi } from '@mysten/sui/experimental';
+import type { ClientWithCoreApi } from '@mysten/sui/client';
import type { Networks } from '../utils/networks.js';
import type { StateStorage } from '../utils/storage.js';
import type { WalletInitializer } from '../wallets/index.js';
diff --git a/packages/dapp-kit-next/packages/dapp-kit-core/src/index.ts b/packages/dapp-kit-next/packages/dapp-kit-core/src/index.ts
index 15b90a8c7..73861aacc 100644
--- a/packages/dapp-kit-next/packages/dapp-kit-core/src/index.ts
+++ b/packages/dapp-kit-next/packages/dapp-kit-core/src/index.ts
@@ -8,7 +8,7 @@ export type { DAppKitCompatibleClient } from './core/types.js';
export type { WalletConnection } from './core/store.js';
export type { Register, ResolvedRegister, RegisteredDAppKit } from './types.js';
export type { StateStorage } from './utils/storage.js';
-export type { ClientWithCoreApi } from '@mysten/sui/experimental';
+export type { ClientWithCoreApi } from '@mysten/sui/client';
export { getWalletUniqueIdentifier } from './utils/wallets.js';
export type { UiWallet, UiWalletAccount } from '@wallet-standard/ui';
diff --git a/packages/dapp-kit-next/packages/dapp-kit-core/src/utils/networks.ts b/packages/dapp-kit-next/packages/dapp-kit-core/src/utils/networks.ts
index 0955263a4..3da660c33 100644
--- a/packages/dapp-kit-next/packages/dapp-kit-core/src/utils/networks.ts
+++ b/packages/dapp-kit-next/packages/dapp-kit-core/src/utils/networks.ts
@@ -1,14 +1,14 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { Experimental_SuiClientTypes } from '@mysten/sui/experimental';
+import type { SuiClientTypes } from '@mysten/sui/client';
import type { IdentifierString } from '@mysten/wallet-standard';
import { DAppKitError } from './errors.js';
import type { DAppKitCompatibleClient } from '../core/types.js';
-export type Networks = Experimental_SuiClientTypes.Network[];
+export type Networks = SuiClientTypes.Network[];
-export function getChain(network: Experimental_SuiClientTypes.Network): IdentifierString {
+export function getChain(network: SuiClientTypes.Network): IdentifierString {
return `sui:${network}`;
}
diff --git a/packages/dapp-kit-next/packages/dapp-kit-core/src/utils/signer.ts b/packages/dapp-kit-next/packages/dapp-kit-core/src/utils/signer.ts
index 133403d0f..48bc8bac5 100644
--- a/packages/dapp-kit-next/packages/dapp-kit-core/src/utils/signer.ts
+++ b/packages/dapp-kit-next/packages/dapp-kit-core/src/utils/signer.ts
@@ -5,8 +5,8 @@ import type { PublicKey, SignatureScheme } from '@mysten/sui/cryptography';
import { SIGNATURE_FLAG_TO_SCHEME, Signer } from '@mysten/sui/cryptography';
import type { DAppKit } from '../core/index.js';
import type { Transaction } from '@mysten/sui/transactions';
-import type { Experimental_SuiClientTypes } from '@mysten/sui/experimental';
-import { parseTransactionBcs, parseTransactionEffectsBcs } from '@mysten/sui/experimental';
+import type { SuiClientTypes } from '@mysten/sui/client';
+import { parseTransactionBcs, parseTransactionEffectsBcs } from '@mysten/sui/client';
import { toBase64, fromBase64 } from '@mysten/sui/utils';
import { publicKeyFromSuiBytes } from '@mysten/sui/verify';
@@ -68,7 +68,7 @@ export class CurrentAccountSigner extends Signer {
transaction,
}: {
transaction: Transaction;
- }): Promise> {
+ }): Promise> {
const { bytes, signature, digest, effects } = await this.#dAppKit.signAndExecuteTransaction({
transaction,
});
@@ -78,17 +78,10 @@ export class CurrentAccountSigner extends Signer {
signatures: [signature],
epoch: null,
effects: parseTransactionEffectsBcs(fromBase64(effects)),
- objectTypes: {
- // oxlint-disable-next-line no-thenable
- get then() {
- const promise = Promise.reject>(
- new Error('objectTypes is not implemented for WalletSigner'),
- );
-
- return promise.then.bind(promise);
- },
- },
transaction: parseTransactionBcs(fromBase64(bytes)),
+ events: undefined,
+ objectTypes: undefined,
+ balanceChanges: undefined,
};
}
}
diff --git a/packages/dapp-kit-next/packages/dapp-kit-core/src/wallets/unsafe-burner.ts b/packages/dapp-kit-next/packages/dapp-kit-core/src/wallets/unsafe-burner.ts
index d5980fd5a..393c73629 100644
--- a/packages/dapp-kit-next/packages/dapp-kit-core/src/wallets/unsafe-burner.ts
+++ b/packages/dapp-kit-next/packages/dapp-kit-core/src/wallets/unsafe-burner.ts
@@ -26,7 +26,7 @@ import {
} from '@mysten/wallet-standard';
import type { Wallet } from '@mysten/wallet-standard';
import { toBase64 } from '@mysten/utils';
-import type { ClientWithCoreApi } from '@mysten/sui/experimental';
+import type { ClientWithCoreApi } from '@mysten/sui/client';
import type { WalletInitializer } from './index.js';
import { getChain } from '../utils/networks.js';
diff --git a/packages/dapp-kit-next/packages/dapp-kit-core/src/web/dapp-kit-connect-button.stories.ts b/packages/dapp-kit-next/packages/dapp-kit-core/src/web/dapp-kit-connect-button.stories.ts
index 97728b4c6..e7060b4ea 100644
--- a/packages/dapp-kit-next/packages/dapp-kit-core/src/web/dapp-kit-connect-button.stories.ts
+++ b/packages/dapp-kit-next/packages/dapp-kit-core/src/web/dapp-kit-connect-button.stories.ts
@@ -5,12 +5,12 @@ import type { Meta, StoryObj } from '@storybook/web-components';
import { html } from 'lit';
import type { DAppKitConnectButton } from './dapp-kit-connect-button.js';
import { createDAppKit } from '../core/index.js';
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
const dAppKit = createDAppKit({
networks: ['testnet'],
createClient(network) {
- return new SuiClient({ network, url: getFullnodeUrl(network) });
+ return new SuiJsonRpcClient({ network, url: getJsonRpcFullnodeUrl(network) });
},
});
diff --git a/packages/dapp-kit-next/packages/dapp-kit-core/src/web/dapp-kit-connect-modal.stories.ts b/packages/dapp-kit-next/packages/dapp-kit-core/src/web/dapp-kit-connect-modal.stories.ts
index 776acd464..6e54d85de 100644
--- a/packages/dapp-kit-next/packages/dapp-kit-core/src/web/dapp-kit-connect-modal.stories.ts
+++ b/packages/dapp-kit-next/packages/dapp-kit-core/src/web/dapp-kit-connect-modal.stories.ts
@@ -5,12 +5,12 @@ import type { Meta, StoryObj } from '@storybook/web-components';
import { html } from 'lit';
import type { DAppKitConnectModal } from './dapp-kit-connect-modal.js';
import { createDAppKit } from '../core/index.js';
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
const dAppKit = createDAppKit({
networks: ['testnet'],
createClient(network) {
- return new SuiClient({ network, url: getFullnodeUrl(network) });
+ return new SuiJsonRpcClient({ network, url: getJsonRpcFullnodeUrl(network) });
},
});
diff --git a/packages/dapp-kit-next/packages/dapp-kit-core/test/integration/actions/connect-wallet.test.ts b/packages/dapp-kit-next/packages/dapp-kit-core/test/integration/actions/connect-wallet.test.ts
index 30ff78500..2f74d9d4a 100644
--- a/packages/dapp-kit-next/packages/dapp-kit-core/test/integration/actions/connect-wallet.test.ts
+++ b/packages/dapp-kit-next/packages/dapp-kit-core/test/integration/actions/connect-wallet.test.ts
@@ -5,7 +5,7 @@ import { describe, expect, test, beforeEach } from 'vitest';
import { TEST_DEFAULT_NETWORK, TEST_NETWORKS, TestWalletInitializeResult } from '../../test-utils';
import { createMockWallets, MockWallet } from '../../mocks/mock-wallet';
import { createDAppKit, DAppKit } from '../../../src';
-import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
+import { SuiJsonRpcClient, getJsonRpcFullnodeUrl } from '@mysten/sui/jsonRpc';
import { getWallets } from '@mysten/wallet-standard';
import { createMockAccount } from '../../mocks/mock-account';
import { UiWallet } from '@wallet-standard/ui';
@@ -21,7 +21,7 @@ describe('[Integration] connectWallet action', () => {
networks: TEST_NETWORKS,
defaultNetwork: TEST_DEFAULT_NETWORK,
createClient(network) {
- return new SuiClient({ network, url: getFullnodeUrl(network) });
+ return new SuiJsonRpcClient({ network, url: getJsonRpcFullnodeUrl(network) });
},
walletInitializers: [
{
diff --git a/packages/dapp-kit-next/packages/dapp-kit-core/test/integration/actions/disconnect-wallet.test.ts b/packages/dapp-kit-next/packages/dapp-kit-core/test/integration/actions/disconnect-wallet.test.ts
index 0d4372e13..d56a43f82 100644
--- a/packages/dapp-kit-next/packages/dapp-kit-core/test/integration/actions/disconnect-wallet.test.ts
+++ b/packages/dapp-kit-next/packages/dapp-kit-core/test/integration/actions/disconnect-wallet.test.ts
@@ -5,7 +5,7 @@ import { describe, expect, test, beforeEach, vi, MockInstance } from 'vitest';
import { TEST_DEFAULT_NETWORK, TEST_NETWORKS, TestWalletInitializeResult } from '../../test-utils';
import { createMockWallets, MockWallet } from '../../mocks/mock-wallet';
import { createDAppKit, DAppKit } from '../../../src';
-import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
+import { SuiJsonRpcClient, getJsonRpcFullnodeUrl } from '@mysten/sui/jsonRpc';
import { getWallets } from '@mysten/wallet-standard';
import { createMockAccount } from '../../mocks/mock-account';
import { UiWallet } from '@wallet-standard/ui';
@@ -24,7 +24,7 @@ describe('[Integration] disconnectWallet action', () => {
networks: TEST_NETWORKS,
defaultNetwork: TEST_DEFAULT_NETWORK,
createClient(network) {
- return new SuiClient({ network, url: getFullnodeUrl(network) });
+ return new SuiJsonRpcClient({ network, url: getJsonRpcFullnodeUrl(network) });
},
walletInitializers: [
{
diff --git a/packages/dapp-kit-next/packages/dapp-kit-core/test/unit/unit-test-utils.ts b/packages/dapp-kit-next/packages/dapp-kit-core/test/unit/unit-test-utils.ts
index 82f60f32f..c7877d274 100644
--- a/packages/dapp-kit-next/packages/dapp-kit-core/test/unit/unit-test-utils.ts
+++ b/packages/dapp-kit-next/packages/dapp-kit-core/test/unit/unit-test-utils.ts
@@ -9,7 +9,7 @@ import {
TEST_NETWORKS,
unbindStoreListeners,
} from '../test-utils.js';
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import type { MockWalletOptions } from '../mocks/mock-wallet.js';
import { createMockWallets } from '../mocks/mock-wallet.js';
import { createMockAccount } from '../mocks/mock-account.js';
@@ -22,11 +22,11 @@ export function createTestStores({
const clients = Object.fromEntries(
[...TEST_NETWORKS].map((network) => [
network,
- new SuiClient({ network, url: getFullnodeUrl(network) }),
+ new SuiJsonRpcClient({ network, url: getJsonRpcFullnodeUrl(network) }),
]),
);
- return createStores({
+ return createStores({
defaultNetwork: currentNetwork,
getClient: (network) => clients[network as keyof typeof clients],
});
diff --git a/packages/dapp-kit/README.md b/packages/dapp-kit/README.md
index fa409d85e..465bd1213 100644
--- a/packages/dapp-kit/README.md
+++ b/packages/dapp-kit/README.md
@@ -35,13 +35,13 @@ pages.
```tsx
import { createNetworkConfig, SuiClientProvider, WalletProvider } from '@mysten/dapp-kit';
-import { getFullnodeUrl, type SuiClientOptions } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, type SuiClientOptions } from '@mysten/sui/jsonRpc';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
// Config options for the networks you want to connect to
const { networkConfig } = createNetworkConfig({
- localnet: { url: getFullnodeUrl('localnet') },
- mainnet: { url: getFullnodeUrl('mainnet') },
+ localnet: { url: getJsonRpcFullnodeUrl('localnet') },
+ mainnet: { url: getJsonRpcFullnodeUrl('mainnet') },
});
const queryClient = new QueryClient();
diff --git a/packages/dapp-kit/src/components/SuiClientProvider.tsx b/packages/dapp-kit/src/components/SuiClientProvider.tsx
index ffbcd8118..56cd1ba00 100644
--- a/packages/dapp-kit/src/components/SuiClientProvider.tsx
+++ b/packages/dapp-kit/src/components/SuiClientProvider.tsx
@@ -1,19 +1,17 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import { getFullnodeUrl, isSuiClient, SuiClient } from '@mysten/sui/client';
-import type { SuiClientOptions } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, isSuiJsonRpcClient, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
+import type { SuiJsonRpcClientOptions } from '@mysten/sui/jsonRpc';
import { createContext, useMemo, useState } from 'react';
import type { NetworkConfig } from '../hooks/networkConfig.js';
-type NetworkConfigs = Record<
- string,
- T
->;
+type NetworkConfigs =
+ Record;
export interface SuiClientProviderContext {
- client: SuiClient;
+ client: SuiJsonRpcClient;
networks: NetworkConfigs;
network: string;
config: NetworkConfig | null;
@@ -23,7 +21,7 @@ export interface SuiClientProviderContext {
export const SuiClientContext = createContext(null);
export type SuiClientProviderProps = {
- createClient?: (name: keyof T, config: T[keyof T]) => SuiClient;
+ createClient?: (name: keyof T, config: T[keyof T]) => SuiJsonRpcClient;
children: React.ReactNode;
networks?: T;
onNetworkChange?: (network: keyof T & string) => void;
@@ -39,18 +37,18 @@ export type SuiClientProviderProps = {
);
const DEFAULT_NETWORKS = {
- localnet: { url: getFullnodeUrl('localnet') },
+ localnet: { url: getJsonRpcFullnodeUrl('localnet') },
};
const DEFAULT_CREATE_CLIENT = function createClient(
_name: string,
- config: NetworkConfig | SuiClient,
+ config: NetworkConfig | SuiJsonRpcClient,
) {
- if (isSuiClient(config)) {
+ if (isSuiJsonRpcClient(config)) {
return config;
}
- return new SuiClient(config);
+ return new SuiJsonRpcClient(config);
};
export function SuiClientProvider(props: SuiClientProviderProps) {
@@ -75,9 +73,9 @@ export function SuiClientProvider(props: SuiClientProv
networks,
network: currentNetwork,
config:
- networks[currentNetwork] instanceof SuiClient
+ networks[currentNetwork] instanceof SuiJsonRpcClient
? null
- : (networks[currentNetwork] as SuiClientOptions),
+ : (networks[currentNetwork] as SuiJsonRpcClientOptions),
selectNetwork: (newNetwork) => {
if (currentNetwork === newNetwork) {
return;
diff --git a/packages/dapp-kit/src/constants/walletMutationKeys.ts b/packages/dapp-kit/src/constants/walletMutationKeys.ts
index 679d17c12..6d9212283 100644
--- a/packages/dapp-kit/src/constants/walletMutationKeys.ts
+++ b/packages/dapp-kit/src/constants/walletMutationKeys.ts
@@ -12,7 +12,6 @@ export const walletMutationKeys = {
signTransaction: formMutationKeyFn('sign-transaction'),
signAndExecuteTransaction: formMutationKeyFn('sign-and-execute-transaction'),
switchAccount: formMutationKeyFn('switch-account'),
- reportTransactionEffects: formMutationKeyFn('report-transaction-effects'),
};
function formMutationKeyFn(baseEntity: string) {
diff --git a/packages/dapp-kit/src/hooks/networkConfig.ts b/packages/dapp-kit/src/hooks/networkConfig.ts
index acdd645bb..f77f983cb 100644
--- a/packages/dapp-kit/src/hooks/networkConfig.ts
+++ b/packages/dapp-kit/src/hooks/networkConfig.ts
@@ -1,11 +1,11 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { SuiClientOptions } from '@mysten/sui/client';
+import type { SuiJsonRpcClientOptions } from '@mysten/sui/jsonRpc';
import { useSuiClientContext } from './useSuiClient.js';
-export type NetworkConfig = SuiClientOptions & {
+export type NetworkConfig = SuiJsonRpcClientOptions & {
variables?: T;
};
diff --git a/packages/dapp-kit/src/hooks/useResolveSuiNSNames.ts b/packages/dapp-kit/src/hooks/useResolveSuiNSNames.ts
index d85afe394..dd35ac359 100644
--- a/packages/dapp-kit/src/hooks/useResolveSuiNSNames.ts
+++ b/packages/dapp-kit/src/hooks/useResolveSuiNSNames.ts
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { ResolvedNameServiceNames } from '@mysten/sui/client';
+import type { ResolvedNameServiceNames } from '@mysten/sui/jsonRpc';
import type { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
import { useSuiClientQuery } from './useSuiClientQuery.js';
diff --git a/packages/dapp-kit/src/hooks/useSuiClient.ts b/packages/dapp-kit/src/hooks/useSuiClient.ts
index bd86165cb..a3f568c14 100644
--- a/packages/dapp-kit/src/hooks/useSuiClient.ts
+++ b/packages/dapp-kit/src/hooks/useSuiClient.ts
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { SuiClient } from '@mysten/sui/client';
+import type { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { useContext } from 'react';
import { SuiClientContext } from '../components/SuiClientProvider.js';
@@ -18,6 +18,6 @@ export function useSuiClientContext() {
return suiClient;
}
-export function useSuiClient(): SuiClient {
+export function useSuiClient(): SuiJsonRpcClient {
return useSuiClientContext().client;
}
diff --git a/packages/dapp-kit/src/hooks/useSuiClientInfiniteQuery.ts b/packages/dapp-kit/src/hooks/useSuiClientInfiniteQuery.ts
index ff2f0c7ed..3347b8fc4 100644
--- a/packages/dapp-kit/src/hooks/useSuiClientInfiniteQuery.ts
+++ b/packages/dapp-kit/src/hooks/useSuiClientInfiniteQuery.ts
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { SuiClient } from '@mysten/sui/client';
+import type { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import type {
InfiniteData,
UseInfiniteQueryOptions,
@@ -19,11 +19,15 @@ interface PaginatedResult {
}
export type SuiRpcPaginatedMethodName = {
- [K in keyof SuiClient]: SuiClient[K] extends (input: any) => Promise ? K : never;
-}[keyof SuiClient];
+ [K in keyof SuiJsonRpcClient]: SuiJsonRpcClient[K] extends (
+ input: any,
+ ) => Promise
+ ? K
+ : never;
+}[keyof SuiJsonRpcClient];
export type SuiRpcPaginatedMethods = {
- [K in SuiRpcPaginatedMethodName]: SuiClient[K] extends (
+ [K in SuiRpcPaginatedMethodName]: SuiJsonRpcClient[K] extends (
input: infer Params,
) => Promise<
infer Result extends { hasNextPage?: boolean | null; nextCursor?: infer Cursor | null }
diff --git a/packages/dapp-kit/src/hooks/useSuiClientQuery.ts b/packages/dapp-kit/src/hooks/useSuiClientQuery.ts
index e3f9c850a..69a6ea943 100644
--- a/packages/dapp-kit/src/hooks/useSuiClientQuery.ts
+++ b/packages/dapp-kit/src/hooks/useSuiClientQuery.ts
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { SuiClient } from '@mysten/sui/client';
+import type { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import type {
UndefinedInitialDataOptions,
UseQueryOptions,
@@ -14,19 +14,21 @@ import type { PartialBy } from '../types/utilityTypes.js';
import { useSuiClientContext } from './useSuiClient.js';
export type SuiRpcMethodName = {
- [K in keyof SuiClient]: SuiClient[K] extends ((input: any) => Promise) | (() => Promise)
+ [K in keyof SuiJsonRpcClient]: SuiJsonRpcClient[K] extends
+ | ((input: any) => Promise)
+ | (() => Promise)
? K
: never;
-}[keyof SuiClient];
+}[keyof SuiJsonRpcClient];
export type SuiRpcMethods = {
- [K in SuiRpcMethodName]: SuiClient[K] extends (input: infer P) => Promise
+ [K in SuiRpcMethodName]: SuiJsonRpcClient[K] extends (input: infer P) => Promise
? {
name: K;
result: R;
params: P;
}
- : SuiClient[K] extends () => Promise
+ : SuiJsonRpcClient[K] extends () => Promise
? {
name: K;
result: R;
@@ -41,7 +43,7 @@ export type UseSuiClientQueryOptions = Par
>;
export type GetSuiClientQueryOptions = {
- client: SuiClient;
+ client: SuiJsonRpcClient;
network: string;
method: T;
options?: PartialBy<
diff --git a/packages/dapp-kit/src/hooks/wallet/useReportTransactionEffects.ts b/packages/dapp-kit/src/hooks/wallet/useReportTransactionEffects.ts
deleted file mode 100644
index 554d93f4f..000000000
--- a/packages/dapp-kit/src/hooks/wallet/useReportTransactionEffects.ts
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright (c) Mysten Labs, Inc.
-// SPDX-License-Identifier: Apache-2.0
-
-import { toBase64 } from '@mysten/sui/utils';
-import type { SuiReportTransactionEffectsInput } from '@mysten/wallet-standard';
-import type { UseMutationOptions, UseMutationResult } from '@tanstack/react-query';
-import { useMutation } from '@tanstack/react-query';
-
-import { walletMutationKeys } from '../../constants/walletMutationKeys.js';
-import type { WalletFeatureNotSupportedError } from '../../errors/walletErrors.js';
-import {
- WalletNoAccountSelectedError,
- WalletNotConnectedError,
-} from '../../errors/walletErrors.js';
-import type { PartialBy } from '../../types/utilityTypes.js';
-import { useCurrentAccount } from './useCurrentAccount.js';
-import { useCurrentWallet } from './useCurrentWallet.js';
-
-type UseReportTransactionEffectsArgs = Omit<
- PartialBy,
- 'effects'
-> & {
- effects: string | number[];
-};
-
-type UseReportTransactionEffectsError =
- | WalletFeatureNotSupportedError
- | WalletNoAccountSelectedError
- | WalletNotConnectedError
- | Error;
-
-type UseReportTransactionEffectsMutationOptions = Omit<
- UseMutationOptions<
- void,
- UseReportTransactionEffectsError,
- UseReportTransactionEffectsArgs,
- unknown
- >,
- 'mutationFn'
->;
-
-/**
- * Mutation hook for prompting the user to sign a message.
- */
-export function useReportTransactionEffects({
- mutationKey,
- ...mutationOptions
-}: UseReportTransactionEffectsMutationOptions = {}): UseMutationResult<
- void,
- UseReportTransactionEffectsError,
- UseReportTransactionEffectsArgs
-> {
- const { currentWallet } = useCurrentWallet();
- const currentAccount = useCurrentAccount();
-
- return useMutation({
- mutationKey: walletMutationKeys.reportTransactionEffects(mutationKey),
- mutationFn: async ({ effects, chain = currentWallet?.chains[0], account = currentAccount }) => {
- if (!currentWallet) {
- throw new WalletNotConnectedError('No wallet is connected.');
- }
-
- if (!account) {
- throw new WalletNoAccountSelectedError(
- 'No wallet account is selected to report transaction effects for',
- );
- }
-
- const reportTransactionEffectsFeature =
- currentWallet.features['sui:reportTransactionEffects'];
-
- if (reportTransactionEffectsFeature) {
- return await reportTransactionEffectsFeature.reportTransactionEffects({
- effects: Array.isArray(effects) ? toBase64(new Uint8Array(effects)) : effects,
- account,
- chain: chain ?? currentWallet?.chains[0],
- });
- }
- },
- ...mutationOptions,
- });
-}
diff --git a/packages/dapp-kit/src/hooks/wallet/useSignAndExecuteTransaction.ts b/packages/dapp-kit/src/hooks/wallet/useSignAndExecuteTransaction.ts
index 27db7ee4d..9523fd2a4 100644
--- a/packages/dapp-kit/src/hooks/wallet/useSignAndExecuteTransaction.ts
+++ b/packages/dapp-kit/src/hooks/wallet/useSignAndExecuteTransaction.ts
@@ -21,7 +21,6 @@ import type { PartialBy } from '../../types/utilityTypes.js';
import { useSuiClientContext } from '../useSuiClient.js';
import { useCurrentAccount } from './useCurrentAccount.js';
import { useCurrentWallet } from './useCurrentWallet.js';
-import { useReportTransactionEffects } from './useReportTransactionEffects.js';
type UseSignAndExecuteTransactionArgs = PartialBy<
Omit,
@@ -78,7 +77,6 @@ export function useSignAndExecuteTransaction<
const { currentWallet, supportedIntents } = useCurrentWallet();
const currentAccount = useCurrentAccount();
const { client, network } = useSuiClientContext();
- const { mutate: reportTransactionEffects } = useReportTransactionEffects();
const executeTransaction: ({
bytes,
@@ -152,18 +150,6 @@ export function useSignAndExecuteTransaction<
const result = await executeTransaction({ bytes, signature });
- let effects: string;
-
- if ('effects' in result && result.effects?.bcs) {
- effects = result.effects.bcs;
- } else if ('rawEffects' in result) {
- effects = toBase64(new Uint8Array(result.rawEffects!));
- } else {
- throw new Error('Could not parse effects from transaction result.');
- }
-
- reportTransactionEffects({ effects, account: signerAccount, chain });
-
return result as Result;
},
...mutationOptions,
diff --git a/packages/dapp-kit/src/hooks/wallet/useSignTransaction.ts b/packages/dapp-kit/src/hooks/wallet/useSignTransaction.ts
index 6257f0d2c..3848c2c4b 100644
--- a/packages/dapp-kit/src/hooks/wallet/useSignTransaction.ts
+++ b/packages/dapp-kit/src/hooks/wallet/useSignTransaction.ts
@@ -17,7 +17,6 @@ import type { PartialBy } from '../../types/utilityTypes.js';
import { useSuiClientContext } from '../useSuiClient.js';
import { useCurrentAccount } from './useCurrentAccount.js';
import { useCurrentWallet } from './useCurrentWallet.js';
-import { useReportTransactionEffects } from './useReportTransactionEffects.js';
type UseSignTransactionArgs = PartialBy<
Omit,
@@ -26,9 +25,7 @@ type UseSignTransactionArgs = PartialBy<
transaction: Transaction | string;
};
-interface UseSignTransactionResult extends SignedTransaction {
- reportTransactionEffects: (effects: string) => void;
-}
+interface UseSignTransactionResult extends SignedTransaction {}
type UseSignTransactionError =
| WalletFeatureNotSupportedError
@@ -61,8 +58,6 @@ export function useSignTransaction({
const currentAccount = useCurrentAccount();
const { client, network } = useSuiClientContext();
- const { mutate: reportTransactionEffects } = useReportTransactionEffects();
-
return useMutation({
mutationKey: walletMutationKeys.signTransaction(mutationKey),
mutationFn: async ({ transaction, ...signTransactionArgs }) => {
@@ -110,13 +105,6 @@ export function useSignTransaction({
return {
bytes,
signature,
- reportTransactionEffects: (effects) => {
- reportTransactionEffects({
- effects,
- account: signerAccount,
- chain,
- });
- },
};
},
...mutationOptions,
diff --git a/packages/dapp-kit/src/hooks/wallet/useUnsafeBurnerWallet.ts b/packages/dapp-kit/src/hooks/wallet/useUnsafeBurnerWallet.ts
index 8d1a6f5bf..9364b764e 100644
--- a/packages/dapp-kit/src/hooks/wallet/useUnsafeBurnerWallet.ts
+++ b/packages/dapp-kit/src/hooks/wallet/useUnsafeBurnerWallet.ts
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { SuiClient } from '@mysten/sui/client';
+import type { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
import { Transaction } from '@mysten/sui/transactions';
import { toBase64 } from '@mysten/sui/utils';
@@ -37,7 +37,7 @@ export function useUnsafeBurnerWallet(enabled: boolean) {
}, [enabled, suiClient]);
}
-function registerUnsafeBurnerWallet(suiClient: SuiClient) {
+function registerUnsafeBurnerWallet(suiClient: SuiJsonRpcClient) {
const walletsApi = getWallets();
const registeredWallets = walletsApi.get();
diff --git a/packages/dapp-kit/src/index.ts b/packages/dapp-kit/src/index.ts
index 15d4c7a64..24ad8c71e 100644
--- a/packages/dapp-kit/src/index.ts
+++ b/packages/dapp-kit/src/index.ts
@@ -21,7 +21,6 @@ export * from './hooks/wallet/useDisconnectWallet.js';
export * from './hooks/wallet/useSignAndExecuteTransaction.js';
export * from './hooks/wallet/useSignPersonalMessage.js';
export * from './hooks/wallet/useSignTransaction.js';
-export * from './hooks/wallet/useReportTransactionEffects.js';
export * from './hooks/wallet/useSwitchAccount.js';
export * from './hooks/wallet/useWallets.js';
export * from './themes/lightTheme.js';
diff --git a/packages/dapp-kit/test/components/SuiClientProvider.test.tsx b/packages/dapp-kit/test/components/SuiClientProvider.test.tsx
index 1763c8fc3..4c94b34a4 100644
--- a/packages/dapp-kit/test/components/SuiClientProvider.test.tsx
+++ b/packages/dapp-kit/test/components/SuiClientProvider.test.tsx
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import { SuiClient } from '@mysten/sui/client';
+import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { screen } from '@testing-library/dom';
import { render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
@@ -20,10 +20,10 @@ describe('SuiClientProvider', () => {
expect(screen.getByText('Test')).toBeInTheDocument();
});
- it('provides a SuiClient instance to its children', () => {
+ it('provides a SuiJsonRpcClient instance to its children', () => {
const ChildComponent = () => {
const client = useSuiClient();
- expect(client).toBeInstanceOf(SuiClient);
+ expect(client).toBeInstanceOf(SuiJsonRpcClient);
return Test
;
};
@@ -35,10 +35,10 @@ describe('SuiClientProvider', () => {
});
it('can accept pre-configured SuiClients', () => {
- const suiClient = new SuiClient({ url: 'http://localhost:8080' });
+ const suiClient = new SuiJsonRpcClient({ url: 'http://localhost:8080', network: 'localnet' });
const ChildComponent = () => {
const client = useSuiClient();
- expect(client).toBeInstanceOf(SuiClient);
+ expect(client).toBeInstanceOf(SuiJsonRpcClient);
expect(client).toBe(suiClient);
return Test
;
};
@@ -74,16 +74,18 @@ describe('SuiClientProvider', () => {
networks={{
a: {
url: 'http://localhost:8080',
+ network: 'localnet',
custom: setSelectedNetwork,
},
b: {
url: 'http://localhost:8080',
+ network: 'localnet',
custom: setSelectedNetwork,
},
}}
createClient={(name, { custom, ...config }) => {
custom(name);
- return new SuiClient(config);
+ return new SuiJsonRpcClient(config);
}}
>
{`selected network: ${selectedNetwork}`}
@@ -127,10 +129,12 @@ describe('SuiClientProvider', () => {
networks={{
a: {
url: 'http://localhost:8080',
+ network: 'localnet',
custom: setSelectedNetwork,
},
b: {
url: 'http://localhost:8080',
+ network: 'localnet',
custom: setSelectedNetwork,
},
}}
@@ -180,10 +184,12 @@ describe('SuiClientProvider', () => {
networks={{
a: {
url: 'http://localhost:8080',
+ network: 'localnet',
custom: setSelectedNetwork,
},
b: {
url: 'http://localhost:8080',
+ network: 'localnet',
custom: setSelectedNetwork,
},
}}
diff --git a/packages/dapp-kit/test/hooks/useSignAndExecuteTransaction.test.tsx b/packages/dapp-kit/test/hooks/useSignAndExecuteTransaction.test.tsx
index fcd6b7a2c..76cd7a26f 100644
--- a/packages/dapp-kit/test/hooks/useSignAndExecuteTransaction.test.tsx
+++ b/packages/dapp-kit/test/hooks/useSignAndExecuteTransaction.test.tsx
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { bcs } from '@mysten/sui/bcs';
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { Transaction } from '@mysten/sui/transactions';
import { act, renderHook, waitFor } from '@testing-library/react';
import { expect, type Mock } from 'vitest';
@@ -62,7 +62,10 @@ describe('useSignAndExecuteTransaction', () => {
features: suiFeatures,
});
- const suiClient = new SuiClient({ url: getFullnodeUrl('localnet') });
+ const suiClient = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('localnet'),
+ network: 'localnet',
+ });
const mockSignTransactionFeature = mockWallet.features['sui:signTransaction'];
const signTransaction = mockSignTransactionFeature!.signTransaction as Mock;
@@ -71,11 +74,6 @@ describe('useSignAndExecuteTransaction', () => {
signature: '123',
});
- const reportEffectsFeature = mockWallet.features['sui:reportTransactionEffects'];
- const reportEffects = reportEffectsFeature!.reportTransactionEffects as Mock;
-
- reportEffects.mockImplementation(async () => {});
-
const executeTransaction = vi.spyOn(suiClient, 'executeTransactionBlock');
executeTransaction.mockResolvedValueOnce({
@@ -109,11 +107,6 @@ describe('useSignAndExecuteTransaction', () => {
signature: '123',
rawEffects: [10, 20, 30],
});
- expect(reportEffects).toHaveBeenCalledWith({
- effects: 'ChQe',
- chain: 'sui:testnet',
- account: mockWallet.accounts[0],
- });
const call = signTransaction.mock.calls[0];
@@ -139,11 +132,10 @@ describe('useSignAndExecuteTransaction', () => {
signature: '123',
});
- const reportEffectsFeature = mockWallet.features['sui:reportTransactionEffects'];
- const reportEffects = reportEffectsFeature!.reportTransactionEffects as Mock;
- reportEffects.mockImplementation(async () => {});
-
- const suiClient = new SuiClient({ url: getFullnodeUrl('localnet') });
+ const suiClient = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('localnet'),
+ network: 'localnet',
+ });
const executeTransaction = vi.spyOn(suiClient, 'executeTransactionBlock');
executeTransaction.mockResolvedValueOnce({
digest: '123',
@@ -167,11 +159,6 @@ describe('useSignAndExecuteTransaction', () => {
});
await waitFor(() => expect(result.current.useSignAndExecuteTransaction.isSuccess).toBe(true));
- expect(reportEffects).toHaveBeenCalledWith({
- effects: 'ChQe',
- chain: 'sui:test',
- account: mockWallet.accounts[0],
- });
expect(signTransaction).toHaveBeenCalledWith({
transaction: expect.any(Object),
@@ -188,7 +175,10 @@ describe('useSignAndExecuteTransaction', () => {
features: suiFeatures,
});
- const suiClient = new SuiClient({ url: getFullnodeUrl('localnet') });
+ const suiClient = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('localnet'),
+ network: 'localnet',
+ });
const mockSignMessageFeature = mockWallet.features['sui:signTransaction'];
const signTransaction = mockSignMessageFeature!.signTransaction as Mock;
@@ -197,11 +187,6 @@ describe('useSignAndExecuteTransaction', () => {
signature: '123',
});
- const reportEffectsFeature = mockWallet.features['sui:reportTransactionEffects'];
- const reportEffects = reportEffectsFeature!.reportTransactionEffects as Mock;
-
- reportEffects.mockImplementation(async () => {});
-
const wrapper = createWalletProviderContextWrapper({}, suiClient);
const fakeDigest = toBase58(
@@ -272,11 +257,6 @@ describe('useSignAndExecuteTransaction', () => {
custom: 123,
});
expect(result.current.useSignAndExecuteTransaction.data?.custom).toBe(123);
- expect(reportEffects).toHaveBeenCalledWith({
- account: mockWallet.accounts[0],
- chain: 'sui:testnet',
- effects: effectsBcs,
- });
const call = signTransaction.mock.calls[0];
diff --git a/packages/dapp-kit/test/hooks/useSignTransaction.test.tsx b/packages/dapp-kit/test/hooks/useSignTransaction.test.tsx
index 1b1562fc2..6968853de 100644
--- a/packages/dapp-kit/test/hooks/useSignTransaction.test.tsx
+++ b/packages/dapp-kit/test/hooks/useSignTransaction.test.tsx
@@ -87,7 +87,6 @@ describe('useSignTransaction', () => {
expect(result.current.signTransaction.data).toStrictEqual({
bytes: 'abc',
signature: '123',
- reportTransactionEffects: expect.any(Function),
});
expect(signTransactionMock).toHaveBeenCalledWith({
diff --git a/packages/dapp-kit/test/hooks/useSuiClient.test.tsx b/packages/dapp-kit/test/hooks/useSuiClient.test.tsx
index 64c39d616..4a3a41779 100644
--- a/packages/dapp-kit/test/hooks/useSuiClient.test.tsx
+++ b/packages/dapp-kit/test/hooks/useSuiClient.test.tsx
@@ -1,6 +1,6 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { renderHook } from '@testing-library/react';
import { useSuiClient } from '../../src/index.js';
@@ -13,8 +13,11 @@ describe('useSuiClient', () => {
);
});
- test('returns a SuiClient', () => {
- const suiClient = new SuiClient({ url: getFullnodeUrl('localnet') });
+ test('returns a SuiJsonRpcClient', () => {
+ const suiClient = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('localnet'),
+ network: 'localnet',
+ });
const wrapper = createSuiClientContextWrapper(suiClient);
const { result } = renderHook(() => useSuiClient(), { wrapper });
diff --git a/packages/dapp-kit/test/hooks/useSuiClientInfiniteQuery.test.tsx b/packages/dapp-kit/test/hooks/useSuiClientInfiniteQuery.test.tsx
index 687d13424..edfa5fb04 100644
--- a/packages/dapp-kit/test/hooks/useSuiClientInfiniteQuery.test.tsx
+++ b/packages/dapp-kit/test/hooks/useSuiClientInfiniteQuery.test.tsx
@@ -1,6 +1,6 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { act, renderHook, waitFor } from '@testing-library/react';
import { useSuiClientInfiniteQuery } from '../../src/hooks/useSuiClientInfiniteQuery.js';
@@ -8,7 +8,10 @@ import { createWalletProviderContextWrapper } from '../test-utils.js';
describe('useSuiClientInfiniteQuery', () => {
it('should fetch data', async () => {
- const suiClient = new SuiClient({ url: getFullnodeUrl('mainnet') });
+ const suiClient = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('mainnet'),
+ network: 'mainnet',
+ });
const wrapper = createWalletProviderContextWrapper({}, suiClient);
const queryTransactionBlocks = vi.spyOn(suiClient, 'queryTransactionBlocks');
diff --git a/packages/dapp-kit/test/hooks/useSuiClientMutation.test.tsx b/packages/dapp-kit/test/hooks/useSuiClientMutation.test.tsx
index e9293af14..f419b330b 100644
--- a/packages/dapp-kit/test/hooks/useSuiClientMutation.test.tsx
+++ b/packages/dapp-kit/test/hooks/useSuiClientMutation.test.tsx
@@ -1,6 +1,6 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { act, renderHook, waitFor } from '@testing-library/react';
import { useSuiClientMutation } from '../../src/hooks/useSuiClientMutation.js';
@@ -8,7 +8,10 @@ import { createWalletProviderContextWrapper } from '../test-utils.js';
describe('useSuiClientMutation', () => {
it('should fetch data', async () => {
- const suiClient = new SuiClient({ url: getFullnodeUrl('mainnet') });
+ const suiClient = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('mainnet'),
+ network: 'mainnet',
+ });
const wrapper = createWalletProviderContextWrapper({}, suiClient);
const queryTransactionBlocks = vi.spyOn(suiClient, 'queryTransactionBlocks');
diff --git a/packages/dapp-kit/test/hooks/useSuiClientQueries.test.tsx b/packages/dapp-kit/test/hooks/useSuiClientQueries.test.tsx
index 2dbfacc31..c042bd976 100644
--- a/packages/dapp-kit/test/hooks/useSuiClientQueries.test.tsx
+++ b/packages/dapp-kit/test/hooks/useSuiClientQueries.test.tsx
@@ -1,6 +1,6 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { renderHook, waitFor } from '@testing-library/react';
import { useSuiClientQueries } from '../../src/hooks/useSuiClientQueries.js';
@@ -21,7 +21,10 @@ const MOCK_QUERY_TRANSACTION_BLOCK_RESULT_DATA = {
};
describe('useSuiClientQueries', () => {
- const suiClient = new SuiClient({ url: getFullnodeUrl('mainnet') });
+ const suiClient = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('mainnet'),
+ network: 'mainnet',
+ });
const wrapper = createWalletProviderContextWrapper({}, suiClient);
test('should fetch data', async () => {
const getAllBalances = vi.spyOn(suiClient, 'getAllBalances');
diff --git a/packages/dapp-kit/test/hooks/useSuiClientQuery.test.tsx b/packages/dapp-kit/test/hooks/useSuiClientQuery.test.tsx
index 457d41920..290056e28 100644
--- a/packages/dapp-kit/test/hooks/useSuiClientQuery.test.tsx
+++ b/packages/dapp-kit/test/hooks/useSuiClientQuery.test.tsx
@@ -1,6 +1,6 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { renderHook, waitFor } from '@testing-library/react';
import { useSuiClientQuery } from '../../src/hooks/useSuiClientQuery.js';
@@ -8,7 +8,10 @@ import { createWalletProviderContextWrapper } from '../test-utils.js';
describe('useSuiClientQuery', () => {
it('should fetch data', async () => {
- const suiClient = new SuiClient({ url: getFullnodeUrl('mainnet') });
+ const suiClient = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('mainnet'),
+ network: 'mainnet',
+ });
const wrapper = createWalletProviderContextWrapper({}, suiClient);
const queryTransactionBlocks = vi.spyOn(suiClient, 'queryTransactionBlocks');
diff --git a/packages/dapp-kit/test/mocks/mockFeatures.ts b/packages/dapp-kit/test/mocks/mockFeatures.ts
index 27da03be9..e34689a62 100644
--- a/packages/dapp-kit/test/mocks/mockFeatures.ts
+++ b/packages/dapp-kit/test/mocks/mockFeatures.ts
@@ -39,8 +39,4 @@ export const suiFeatures: SuiFeatures = {
version: '2.0.0',
signAndExecuteTransaction: vi.fn(),
},
- 'sui:reportTransactionEffects': {
- version: '1.0.0',
- reportTransactionEffects: vi.fn(),
- },
};
diff --git a/packages/dapp-kit/test/test-utils.tsx b/packages/dapp-kit/test/test-utils.tsx
index 997b5cc26..3a8c2f4bb 100644
--- a/packages/dapp-kit/test/test-utils.tsx
+++ b/packages/dapp-kit/test/test-utils.tsx
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import type { IdentifierRecord, ReadonlyWalletAccount } from '@mysten/wallet-standard';
import { getWallets } from '@mysten/wallet-standard';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
@@ -12,7 +12,7 @@ import { SuiClientProvider } from '../src/index.js';
import { createMockAccount } from './mocks/mockAccount.js';
import { MockWallet } from './mocks/mockWallet.js';
-export function createSuiClientContextWrapper(client: SuiClient) {
+export function createSuiClientContextWrapper(client: SuiJsonRpcClient) {
return function SuiClientContextWrapper({ children }: { children: React.ReactNode }) {
return {children} ;
};
@@ -20,7 +20,10 @@ export function createSuiClientContextWrapper(client: SuiClient) {
export function createWalletProviderContextWrapper(
providerProps: Omit, 'children'> = {},
- suiClient: SuiClient = new SuiClient({ url: getFullnodeUrl('localnet') }),
+ suiClient: SuiJsonRpcClient = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('localnet'),
+ network: 'localnet',
+ }),
) {
const queryClient = new QueryClient();
return function WalletProviderContextWrapper({ children }: { children: React.ReactNode }) {
diff --git a/packages/dapp-kit/vitest.config.mts b/packages/dapp-kit/vitest.config.mts
index 1fb810ed3..214c9a36d 100644
--- a/packages/dapp-kit/vitest.config.mts
+++ b/packages/dapp-kit/vitest.config.mts
@@ -23,7 +23,7 @@ export default defineConfig({
'@mysten/utils': new URL('../utils/src', import.meta.url).pathname,
'@mysten/sui/keypairs/ed25519': new URL('../typescript/src/keypairs/ed25519', import.meta.url)
.pathname,
- '@mysten/sui/client': new URL('../typescript/src/client', import.meta.url).pathname,
+ '@mysten/sui/jsonRpc': new URL('../typescript/src/jsonRpc', import.meta.url).pathname,
'@mysten/sui/utils': new URL('../typescript/src/utils', import.meta.url).pathname,
'@mysten/sui/transactions': new URL('../typescript/src/transactions', import.meta.url)
.pathname,
diff --git a/packages/deepbook-v3/examples/accountOpenOrders.ts b/packages/deepbook-v3/examples/accountOpenOrders.ts
index 9a3945318..752633316 100644
--- a/packages/deepbook-v3/examples/accountOpenOrders.ts
+++ b/packages/deepbook-v3/examples/accountOpenOrders.ts
@@ -1,6 +1,6 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { DeepBookClient } from '../src/index.js'; // Adjust import source accordingly
@@ -18,8 +18,8 @@ import { DeepBookClient } from '../src/index.js'; // Adjust import source accord
const dbClient = new DeepBookClient({
address: '0x0',
env: env,
- client: new SuiClient({
- url: getFullnodeUrl(env),
+ client: new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl(env),
}),
balanceManagers: balanceManagers,
});
diff --git a/packages/deepbook-v3/examples/accountOrderMap.ts b/packages/deepbook-v3/examples/accountOrderMap.ts
index 23fce3b0b..0f68e0332 100644
--- a/packages/deepbook-v3/examples/accountOrderMap.ts
+++ b/packages/deepbook-v3/examples/accountOrderMap.ts
@@ -1,6 +1,6 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { DeepBookClient } from '../src/index.js'; // Adjust import source accordingly
@@ -19,8 +19,8 @@ import { DeepBookClient } from '../src/index.js'; // Adjust import source accord
const dbClient = new DeepBookClient({
address: '0x0',
env: env,
- client: new SuiClient({
- url: getFullnodeUrl(env),
+ client: new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl(env),
}),
balanceManagers: balanceManagers,
});
diff --git a/packages/deepbook-v3/examples/balance.ts b/packages/deepbook-v3/examples/balance.ts
index e292316cc..4b9930fbe 100644
--- a/packages/deepbook-v3/examples/balance.ts
+++ b/packages/deepbook-v3/examples/balance.ts
@@ -1,6 +1,6 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { DeepBookClient } from '../src/index.js'; // Adjust import source accordingly
@@ -18,8 +18,8 @@ import { DeepBookClient } from '../src/index.js'; // Adjust import source accord
const dbClient = new DeepBookClient({
address: '0x0',
env: env,
- client: new SuiClient({
- url: getFullnodeUrl(env),
+ client: new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl(env),
}),
balanceManagers: balanceManagers,
});
diff --git a/packages/deepbook-v3/examples/deepbookMarketMaker.ts b/packages/deepbook-v3/examples/deepbookMarketMaker.ts
index 5c463f792..99430b84c 100644
--- a/packages/deepbook-v3/examples/deepbookMarketMaker.ts
+++ b/packages/deepbook-v3/examples/deepbookMarketMaker.ts
@@ -1,6 +1,6 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { decodeSuiPrivateKey } from '@mysten/sui/cryptography';
import type { Keypair } from '@mysten/sui/cryptography';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
@@ -11,7 +11,7 @@ import type { BalanceManager } from '../src/types/index.js';
export class DeepBookMarketMaker extends DeepBookClient {
keypair: Keypair;
- suiClient: SuiClient;
+ suiClient: SuiJsonRpcClient;
constructor(
keypair: string | Keypair,
@@ -32,16 +32,16 @@ export class DeepBookMarketMaker extends DeepBookClient {
super({
address: address,
env: env,
- client: new SuiClient({
- url: getFullnodeUrl(env),
+ client: new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl(env),
}),
balanceManagers: balanceManagers,
adminCap: adminCap,
});
this.keypair = resolvedKeypair;
- this.suiClient = new SuiClient({
- url: getFullnodeUrl(env),
+ this.suiClient = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl(env),
});
}
diff --git a/packages/deepbook-v3/src/client.ts b/packages/deepbook-v3/src/client.ts
index 81216bf21..bca9b0f3f 100644
--- a/packages/deepbook-v3/src/client.ts
+++ b/packages/deepbook-v3/src/client.ts
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { bcs } from '@mysten/sui/bcs';
import { Account, Order, OrderDeepPrice, VecSet } from './types/bcs.js';
-import type { SuiClient } from '@mysten/sui/client';
+import type { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { Transaction } from '@mysten/sui/transactions';
import { normalizeSuiAddress } from '@mysten/sui/utils';
@@ -32,7 +32,7 @@ import { PoolProxyContract } from './transactions/poolProxy.js';
* DeepBookClient class for managing DeepBook operations.
*/
export class DeepBookClient {
- client: SuiClient;
+ client: SuiJsonRpcClient;
#config: DeepBookConfig;
#address: string;
balanceManager: BalanceManagerContract;
@@ -48,7 +48,7 @@ export class DeepBookClient {
poolProxy: PoolProxyContract;
/**
- * @param {SuiClient} client SuiClient instance
+ * @param {SuiJsonRpcClient} client SuiJsonRpcClient instance
* @param {string} address Address of the client
* @param {Environment} env Environment configuration
* @param {Object.} [balanceManagers] Optional initial BalanceManager map
@@ -71,7 +71,7 @@ export class DeepBookClient {
marginAdminCap,
marginMaintainerCap,
}: {
- client: SuiClient;
+ client: SuiJsonRpcClient;
address: string;
env: Environment;
balanceManagers?: { [key: string]: BalanceManager };
diff --git a/packages/deepbook-v3/src/pyth/pyth.ts b/packages/deepbook-v3/src/pyth/pyth.ts
index 305ae520b..3dbf81414 100644
--- a/packages/deepbook-v3/src/pyth/pyth.ts
+++ b/packages/deepbook-v3/src/pyth/pyth.ts
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { bcs } from '@mysten/sui/bcs';
-import type { SuiClient } from '@mysten/sui/client';
+import type { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import type { Transaction } from '@mysten/sui/transactions';
import { coinWithBalance } from '@mysten/sui/transactions';
import { fromBase64, fromHex, parseStructTag } from '@mysten/sui/utils';
@@ -31,11 +31,11 @@ export class SuiPythClient {
#priceFeedObjectIdCache: Map> = new Map();
#priceTableInfo?: Promise<{ id: ObjectId; fieldType: ObjectId }>;
#baseUpdateFee?: Promise;
- provider: SuiClient;
+ provider: SuiJsonRpcClient;
pythStateId: ObjectId;
wormholeStateId: ObjectId;
- constructor(provider: SuiClient, pythStateId: ObjectId, wormholeStateId: ObjectId) {
+ constructor(provider: SuiJsonRpcClient, pythStateId: ObjectId, wormholeStateId: ObjectId) {
this.provider = provider;
this.pythStateId = pythStateId;
this.wormholeStateId = wormholeStateId;
diff --git a/packages/deepbook/.prettierignore b/packages/deepbook/.prettierignore
index b0894a4b7..09f1d001d 100644
--- a/packages/deepbook/.prettierignore
+++ b/packages/deepbook/.prettierignore
@@ -7,3 +7,4 @@ yarn-error.log*
.swc/
out/
CHANGELOG.md
+test/e2e/data
diff --git a/packages/deepbook/src/client.ts b/packages/deepbook/src/client.ts
index ab4993997..c66d04865 100644
--- a/packages/deepbook/src/client.ts
+++ b/packages/deepbook/src/client.ts
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0
import { bcs } from '@mysten/sui/bcs';
-import type { OrderArguments, PaginatedEvents, PaginationArguments } from '@mysten/sui/client';
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import type { OrderArguments, PaginatedEvents, PaginationArguments } from '@mysten/sui/jsonRpc';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import type { Argument, TransactionObjectInput, TransactionResult } from '@mysten/sui/transactions';
import { Transaction } from '@mysten/sui/transactions';
import {
@@ -44,7 +44,10 @@ export class DeepBookClient {
* @param currentAddress (optional) address of the current user (default: DUMMY_ADDRESS)
*/
constructor(
- public suiClient: SuiClient = new SuiClient({ url: getFullnodeUrl('testnet') }),
+ public suiClient: SuiJsonRpcClient = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('testnet'),
+ network: 'testnet',
+ }),
public accountCap: string | undefined = undefined,
public currentAddress: string = DUMMY_ADDRESS,
private clientOrderId: number = 0,
diff --git a/packages/deepbook/src/types/index.ts b/packages/deepbook/src/types/index.ts
index d02e87336..8eea9af29 100644
--- a/packages/deepbook/src/types/index.ts
+++ b/packages/deepbook/src/types/index.ts
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { EventId } from '@mysten/sui/client';
+import type { EventId } from '@mysten/sui/jsonRpc';
export * from './bcs.js';
diff --git a/packages/deepbook/test/e2e/setup.ts b/packages/deepbook/test/e2e/setup.ts
index 5d31cb5fd..2d10d2365 100644
--- a/packages/deepbook/test/e2e/setup.ts
+++ b/packages/deepbook/test/e2e/setup.ts
@@ -7,8 +7,8 @@ import type {
SuiObjectChangeCreated,
SuiObjectChangePublished,
SuiTransactionBlockResponse,
-} from '@mysten/sui/client';
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+} from '@mysten/sui/jsonRpc';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { FaucetRateLimitError, getFaucetHost, requestSuiFromFaucetV2 } from '@mysten/sui/faucet';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
import { Transaction } from '@mysten/sui/transactions';
@@ -22,17 +22,17 @@ import type { PoolSummary } from '../../src/types/index.js';
import { FLOAT_SCALING_FACTOR, NORMALIZED_SUI_COIN_TYPE } from '../../src/utils/index.js';
const DEFAULT_FAUCET_URL = process.env.FAUCET_URL ?? getFaucetHost('localnet');
-const DEFAULT_FULLNODE_URL = process.env.FULLNODE_URL ?? getFullnodeUrl('localnet');
+const DEFAULT_FULLNODE_URL = process.env.FULLNODE_URL ?? getJsonRpcFullnodeUrl('localnet');
export const DEFAULT_TICK_SIZE = 1n * FLOAT_SCALING_FACTOR;
export const DEFAULT_LOT_SIZE = 1n;
export class TestToolbox {
keypair: Ed25519Keypair;
- client: SuiClient;
+ client: SuiJsonRpcClient;
configPath: string;
- constructor(keypair: Ed25519Keypair, client: SuiClient, configPath: string) {
+ constructor(keypair: Ed25519Keypair, client: SuiJsonRpcClient, configPath: string) {
this.keypair = keypair;
this.client = client;
this.configPath = configPath;
@@ -47,8 +47,8 @@ export class TestToolbox {
}
}
-export function getClient(): SuiClient {
- return new SuiClient({
+export function getClient(): SuiJsonRpcClient {
+ return new SuiJsonRpcClient({
url: DEFAULT_FULLNODE_URL,
});
}
diff --git a/packages/docs/content/dapp-kit/index.mdx b/packages/docs/content/dapp-kit/index.mdx
index 2054949f9..a094302d3 100644
--- a/packages/docs/content/dapp-kit/index.mdx
+++ b/packages/docs/content/dapp-kit/index.mdx
@@ -32,13 +32,13 @@ respective pages.
```tsx
import { createNetworkConfig, SuiClientProvider, WalletProvider } from '@mysten/dapp-kit';
-import { getFullnodeUrl } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl } from '@mysten/sui/jsonRpc';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
// Config options for the networks you want to connect to
const { networkConfig } = createNetworkConfig({
- localnet: { url: getFullnodeUrl('localnet') },
- mainnet: { url: getFullnodeUrl('mainnet') },
+ localnet: { url: getJsonRpcFullnodeUrl('localnet') },
+ mainnet: { url: getJsonRpcFullnodeUrl('mainnet') },
});
const queryClient = new QueryClient();
diff --git a/packages/docs/content/dapp-kit/sui-client-provider.mdx b/packages/docs/content/dapp-kit/sui-client-provider.mdx
index 1c1fb277b..96703cb14 100644
--- a/packages/docs/content/dapp-kit/sui-client-provider.mdx
+++ b/packages/docs/content/dapp-kit/sui-client-provider.mdx
@@ -2,25 +2,25 @@
title: SuiClientProvider
---
-The `SuiClientProvider` manages the active `SuiClient` that hooks and components use in the dApp
-Kit.
+The `SuiClientProvider` manages the active `SuiJsonRpcClient` that hooks and components use in the
+dApp Kit.
## Usage
Place the `SuiClientProvider` at the root of your app and wrap all components that use the dApp Kit
hooks.
-`SuiClientProvider` accepts a list of network configurations to create `SuiClient` instances for the
-currently active network.
+`SuiClientProvider` accepts a list of network configurations to create `SuiJsonRpcClient` instances
+for the currently active network.
```tsx
import { createNetworkConfig, SuiClientProvider, WalletProvider } from '@mysten/dapp-kit';
-import { getFullnodeUrl } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl } from '@mysten/sui/jsonRpc';
// Config options for the networks you want to connect to
const { networkConfig } = createNetworkConfig({
- localnet: { url: getFullnodeUrl('localnet') },
- mainnet: { url: getFullnodeUrl('mainnet') },
+ localnet: { url: getJsonRpcFullnodeUrl('localnet') },
+ mainnet: { url: getJsonRpcFullnodeUrl('mainnet') },
});
function App() {
@@ -35,15 +35,15 @@ function App() {
## Props
- `networks`: A map of networks you can use. The keys are the network names, and the values can be
- either a configuration object (`SuiClientOptions`) or a `SuiClient` instance.
+ either a configuration object (`SuiClientOptions`) or a `SuiJsonRpcClient` instance.
- `defaultNetwork`: The name of the network to use by default when using the `SuiClientProvider` as
an uncontrolled component.
- `network`: The name of the network to use when using the `SuiClientProvider` as a controlled
component.
- `onNetworkChange`: A callback when the active network changes.
-- `createClient`: A callback when a new `SuiClient` is created (for example, when the active network
- changes). It receives the network name and configuration object as arguments, returning a
- `SuiClient` instance.
+- `createClient`: A callback when a new `SuiJsonRpcClient` is created (for example, when the active
+ network changes). It receives the network name and configuration object as arguments, returning a
+ `SuiJsonRpcClient` instance.
## Controlled component
@@ -51,13 +51,13 @@ The following example demonstrates a `SuiClientProvider` used as a controlled co
```tsx
import { createNetworkConfig, SuiClientProvider } from '@mysten/dapp-kit';
-import { getFullnodeUrl } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl } from '@mysten/sui/jsonRpc';
import { useState } from 'react';
// Config options for the networks you want to connect to
const { networkConfig } = createNetworkConfig({
- localnet: { url: getFullnodeUrl('localnet') },
- mainnet: { url: getFullnodeUrl('mainnet') },
+ localnet: { url: getJsonRpcFullnodeUrl('localnet') },
+ mainnet: { url: getJsonRpcFullnodeUrl('mainnet') },
});
function App() {
@@ -77,18 +77,18 @@ function App() {
}
```
-## SuiClient customization
+## SuiJsonRpcClient customization
-The following example demonstrates how to create a custom `SuiClient`.
+The following example demonstrates how to create a custom `SuiJsonRpcClient`.
```tsx
import { SuiClientProvider } from '@mysten/dapp-kit';
-import { getFullnodeUrl, SuiClient, SuiHTTPTransport } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient, SuiHTTPTransport } from '@mysten/sui/jsonRpc';
// Config options for the networks you want to connect to
const networks = {
- localnet: { url: getFullnodeUrl('localnet') },
- mainnet: { url: getFullnodeUrl('mainnet') },
+ localnet: { url: getJsonRpcFullnodeUrl('localnet') },
+ mainnet: { url: getJsonRpcFullnodeUrl('mainnet') },
} satisfies Record;
function App() {
@@ -97,7 +97,7 @@ function App() {
networks={networks}
defaultNetwork="localnet"
createClient={(network, config) => {
- return new SuiClient({
+ return new SuiJsonRpcClient({
transport: new SuiHTTPTransport({
url: 'https://api.safecoin.org',
rpc: {
@@ -115,9 +115,9 @@ function App() {
}
```
-## Using the SuiClient from the provider
+## Using the SuiJsonRpcClient from the provider
-To use the `SuiClient` from the provider, import the `useSuiClient` function from the
+To use the `SuiJsonRpcClient` from the provider, import the `useSuiClient` function from the
`@mysten/dapp-kit` module.
```tsx
@@ -166,19 +166,19 @@ to get the variables defined in your configuration.
```tsx
import { createNetworkConfig, SuiClientProvider, WalletProvider } from '@mysten/dapp-kit';
-import { getFullnodeUrl } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl } from '@mysten/sui/jsonRpc';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
// Config options for the networks you want to connect to
const { networkConfig, useNetworkVariable } = createNetworkConfig({
localnet: {
- url: getFullnodeUrl('localnet'),
+ url: getJsonRpcFullnodeUrl('localnet'),
variables: {
myMovePackageId: '0x123',
},
},
mainnet: {
- url: getFullnodeUrl('mainnet'),
+ url: getJsonRpcFullnodeUrl('mainnet'),
variables: {
myMovePackageId: '0x456',
},
diff --git a/packages/docs/content/dapp-kit/wallet-hooks/_meta.json b/packages/docs/content/dapp-kit/wallet-hooks/_meta.json
index 12f0853d8..b275c19d5 100644
--- a/packages/docs/content/dapp-kit/wallet-hooks/_meta.json
+++ b/packages/docs/content/dapp-kit/wallet-hooks/_meta.json
@@ -9,6 +9,5 @@
"useSwitchAccount": "useSwitchAccount",
"useSignPersonalMessage": "useSignPersonalMessage",
"useSignTransaction": "useSignTransaction",
- "useSignAndExecuteTransaction": "useSignAndExecuteTransaction",
- "useReportTransactionEffects": "useReportTransactionEffects"
+ "useSignAndExecuteTransaction": "useSignAndExecuteTransaction"
}
diff --git a/packages/docs/content/dapp-kit/wallet-hooks/useReportTransactionEffects.mdx b/packages/docs/content/dapp-kit/wallet-hooks/useReportTransactionEffects.mdx
deleted file mode 100644
index 6f31e5f8c..000000000
--- a/packages/docs/content/dapp-kit/wallet-hooks/useReportTransactionEffects.mdx
+++ /dev/null
@@ -1,58 +0,0 @@
----
-title: useReportTransactionEffects
----
-
-import { UseSignTransactionExample } from '../../../examples/wallet-hooks';
-
-Use the `useReportTransactionEffects` hook can be used to report the effects of a transaction to the
-connected wallet. The `useSignAndExecuteTransaction` hook automatically reports effects, and the
-`useSignTransaction` hook provides a `reportTransactionEffects` callback to report effects manually,
-so this hook is only needed when using a non-standard flow for executing transactions.
-
-```ts
-import {
- ConnectButton,
- useCurrentAccount,
- useReportTransactionEffects,
- useSuiClient,
-} from '@mysten/dapp-kit';
-import { toBase64 } from '@mysten/sui/utils';
-import { useState } from 'react';
-
-function MyComponent() {
- const { mutateAsync: reportTransactionEffects } = useReportTransactionEffects();
- const [signature, setSignature] = useState('');
- const client = useSuiClient();
- const currentAccount = useCurrentAccount();
-
- return (
-
-
- {currentAccount && (
- <>
-
- {
- const { effects } = await executePreSignedTransaction();
- reportTransactionEffects({ effects });
- }}
- >
- Sign empty transaction
-
-
-
Signature: {signature}
- >
- )}
-
- );
-}
-```
-
-## Arguments
-
-- `effects`: The effects of an executed transaction. This can either be the `rawEffects` returned
- from the JSON-RPC `executeTransactionBlock` method (returned when showRawEffects is set to true),
- or the `effects.bcs` when executing with the GraphQL API.
-- `chain`: (optional) The chain identifier the transaction was executed on.
-- `account` (optional) the account that signed the transaction, defaults to the currently connected
- account
diff --git a/packages/docs/content/dapp-kit/wallet-hooks/useSignAndExecuteTransaction.mdx b/packages/docs/content/dapp-kit/wallet-hooks/useSignAndExecuteTransaction.mdx
index 15c9a2bc9..9544e960f 100644
--- a/packages/docs/content/dapp-kit/wallet-hooks/useSignAndExecuteTransaction.mdx
+++ b/packages/docs/content/dapp-kit/wallet-hooks/useSignAndExecuteTransaction.mdx
@@ -129,5 +129,5 @@ function MyComponent() {
- `execute`: (optional) A custom function to execute the transaction
In addition to these options, you can also pass any options that the
-[SuiClient.signAndExecuteTransaction](/typedoc/classes/_mysten_sui.client.SuiClient.html#signAndExecuteTransactionBlock)
+[SuiJsonRpcClient.signAndExecuteTransaction](/typedoc/classes/_mysten_sui.client.SuiJsonRpcClient.html#signAndExecuteTransactionBlock)
method accepts.
diff --git a/packages/docs/content/dapp-kit/wallet-hooks/useSignTransaction.mdx b/packages/docs/content/dapp-kit/wallet-hooks/useSignTransaction.mdx
index 95e6cc133..b48dbc91a 100644
--- a/packages/docs/content/dapp-kit/wallet-hooks/useSignTransaction.mdx
+++ b/packages/docs/content/dapp-kit/wallet-hooks/useSignTransaction.mdx
@@ -31,7 +31,7 @@ function MyComponent() {
{
- const { bytes, signature, reportTransactionEffects } = await signTransaction({
+ const { bytes, signature } = await signTransaction({
transaction: new Transaction(),
chain: 'sui:devnet',
});
@@ -44,8 +44,6 @@ function MyComponent() {
},
});
- // Always report transaction effects to the wallet after execution
- reportTransactionEffects(executeResult.rawEffects!);
console.log(executeResult);
}}
@@ -75,7 +73,3 @@ function MyComponent() {
- `signature`: The signature of the message, as a Base64-encoded `string`.
- `bytes`: The serialized transaction bytes, as a Base64-encoded `string`.
-- `reportTransactionEffects`: A function to report the transaction effects to the wallet. This
- callback should always be invoked after executing the signed transaction. This function accepts
- the `rawEffects` returned from JSON-RPC `executeTransactionBlock` method, or the `effects.bcs`
- when executing with the GraphQL API.
diff --git a/packages/docs/content/kiosk/advanced-examples.mdx b/packages/docs/content/kiosk/advanced-examples.mdx
index b5f85a006..c1410da5f 100644
--- a/packages/docs/content/kiosk/advanced-examples.mdx
+++ b/packages/docs/content/kiosk/advanced-examples.mdx
@@ -14,8 +14,8 @@ const capyType = `${packageId}::suifrens::SuiFren<${packageId}::capy::Capy>`;
// initialize a kioskClient.
const kioskClient = new KioskClient({
- client: new SuiClient({
- url: getFullnodeUrl('mainnet'),
+ client: new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('mainnet'),
}),
network: Network.MAINNET,
});
diff --git a/packages/docs/content/kiosk/from-v1.mdx b/packages/docs/content/kiosk/from-v1.mdx
index 48bd5da88..15878244e 100644
--- a/packages/docs/content/kiosk/from-v1.mdx
+++ b/packages/docs/content/kiosk/from-v1.mdx
@@ -48,8 +48,8 @@ Using the new SDK, you can build the same transaction as follows:
```typescript
/// You need to do this only once and re-use it in the application.
const kioskClient = new KioskClient({
- client: new SuiClient({
- url: getFullnodeUrl('mainnet'),
+ client: new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('mainnet'),
}),
network: Network.MAINNET,
});
@@ -103,8 +103,8 @@ Using the new SDK, you can build the same transaction as follows:
```typescript
/// You need to do this only once and re-use it in the application.
const kioskClient = new KioskClient({
- client: new SuiClient({
- url: getFullnodeUrl('mainnet'),
+ client: new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('mainnet'),
}),
network: Network.MAINNET,
});
@@ -133,9 +133,9 @@ import {
place,
testnetEnvironment,
} from '@mysten/kiosk';
-import { SuiClient } from '@mysten/sui/client';
+import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
-const client = new SuiClient({
+const client = new SuiJsonRpcClient({
url: 'https://fullnode.testnet.sui.io:443',
});
@@ -205,8 +205,8 @@ Using the new SDK, you can build the same transaction as follows:
```typescript
/// You need to do this only once and re-use it in the application.
const kioskClient = new KioskClient({
- client: new SuiClient({
- url: getFullnodeUrl('mainnet'),
+ client: new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('mainnet'),
}),
network: Network.MAINNET,
});
@@ -301,8 +301,8 @@ On the new SDK, the same transaction can be built as follows:
```typescript
/// You need to do this only once and re-use it in the application.
const kioskClient = new KioskClient({
- client: new SuiClient({
- url: getFullnodeUrl('mainnet'),
+ client: new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('mainnet'),
}),
network: Network.MAINNET,
});
diff --git a/packages/docs/content/kiosk/index.mdx b/packages/docs/content/kiosk/index.mdx
index 1215b4dd8..35c7ef1ff 100644
--- a/packages/docs/content/kiosk/index.mdx
+++ b/packages/docs/content/kiosk/index.mdx
@@ -14,7 +14,7 @@ npm i @mysten/kiosk
## About
To use the Kiosk SDK, you must create a `KioskClient` instance. This instance is used to hold the
-state of `SuiClient`, `Network`, and the rules and package IDs for interacting with Mysten Kiosk
-extension.
+state of `SuiJsonRpcClient`, `Network`, and the rules and package IDs for interacting with Mysten
+Kiosk extension.
- [Read more about `KioskClient`](/kiosk/kiosk-client/introduction)
diff --git a/packages/docs/content/kiosk/kiosk-client/introduction.mdx b/packages/docs/content/kiosk/kiosk-client/introduction.mdx
index e9e2b9f62..6fe265805 100644
--- a/packages/docs/content/kiosk/kiosk-client/introduction.mdx
+++ b/packages/docs/content/kiosk/kiosk-client/introduction.mdx
@@ -17,11 +17,11 @@ require constantly changing the package IDs)._
```typescript
import { KioskClient, Network } from '@mysten/kiosk';
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
-// We need a Sui Client. You can re-use the SuiClient of your project
+// We need a Sui Client. You can re-use the SuiJsonRpcClient of your project
// (it's not recommended to create a new one).
-const client = new SuiClient({ url: getFullnodeUrl('testnet') });
+const client = new SuiJsonRpcClient({ url: getJsonRpcFullnodeUrl('testnet'), network: 'testnet' });
// Now we can use it to create a kiosk Client.
const kioskClient = new KioskClient({
diff --git a/packages/docs/content/payment-kit/getting-started.mdx b/packages/docs/content/payment-kit/getting-started.mdx
index 51a40ed58..063b48a9f 100644
--- a/packages/docs/content/payment-kit/getting-started.mdx
+++ b/packages/docs/content/payment-kit/getting-started.mdx
@@ -27,16 +27,16 @@ npm install --save @mysten/payment-kit @mysten/sui
## Setting Up the Client
-The Payment Kit SDK extends the standard `SuiClient` to provide payment functionality. Here's how to
-set it up:
+The Payment Kit SDK extends the standard `SuiJsonRpcClient` to provide payment functionality. Here's
+how to set it up:
```ts
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { paymentKit } from '@mysten/payment-kit';
// Create a Sui client with Payment Kit extension
-const client = new SuiClient({
- url: getFullnodeUrl('testnet'),
+const client = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('testnet'),
network: 'testnet',
}).$extend(paymentKit());
```
diff --git a/packages/docs/content/payment-kit/index.mdx b/packages/docs/content/payment-kit/index.mdx
index a335a988b..aecfff685 100644
--- a/packages/docs/content/payment-kit/index.mdx
+++ b/packages/docs/content/payment-kit/index.mdx
@@ -43,12 +43,12 @@ npm install --save @mysten/payment-kit @mysten/sui
## Quick Start
```ts
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { paymentKit } from '@mysten/payment-kit';
// Create a Sui client with a Payment Kit extension
-const client = new SuiClient({
- url: getFullnodeUrl('testnet'),
+const client = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('testnet'),
network: 'testnet',
}).$extend(paymentKit());
@@ -76,7 +76,7 @@ Payment Kit supports the following Sui networks:
- **Testnet**: Testing environment
The SDK automatically configures the correct package and object IDs based on the network specified
-in your `SuiClient` configuration.
+in your `SuiJsonRpcClient` configuration.
## Core Concepts
diff --git a/packages/docs/content/payment-kit/payment-kit-sdk.mdx b/packages/docs/content/payment-kit/payment-kit-sdk.mdx
index 93f3701a7..8fc25c999 100644
--- a/packages/docs/content/payment-kit/payment-kit-sdk.mdx
+++ b/packages/docs/content/payment-kit/payment-kit-sdk.mdx
@@ -18,7 +18,7 @@ The main client class that provides access to Payment Kit functionality.
#### `paymentKit()`
-Function to create a Payment Kit client extension for `SuiClient`.
+Function to create a Payment Kit client extension for `SuiJsonRpcClient`.
```ts
paymentKit({
@@ -29,11 +29,11 @@ paymentKit({
**Example:**
```ts
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { paymentKit } from '@mysten/payment-kit';
-const client = new SuiClient({
- url: getFullnodeUrl('testnet'),
+const client = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('testnet'),
network: 'testnet',
}).$extend(paymentKit());
diff --git a/packages/docs/content/payment-kit/registry-management.mdx b/packages/docs/content/payment-kit/registry-management.mdx
index cd47842ef..e4b45a148 100644
--- a/packages/docs/content/payment-kit/registry-management.mdx
+++ b/packages/docs/content/payment-kit/registry-management.mdx
@@ -392,12 +392,12 @@ const record = await client.paymentKit.getPaymentRecord({
Here's a complete workflow for setting up a custom registry:
```ts
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { paymentKit } from '@mysten/payment-kit';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
-const client = new SuiClient({
- url: getFullnodeUrl('testnet'),
+const client = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('testnet'),
network: 'testnet',
}).$extend(paymentKit());
diff --git a/packages/docs/content/typescript/cryptography/keypairs.mdx b/packages/docs/content/typescript/cryptography/keypairs.mdx
index 9de140ba9..5fbf5cba8 100644
--- a/packages/docs/content/typescript/cryptography/keypairs.mdx
+++ b/packages/docs/content/typescript/cryptography/keypairs.mdx
@@ -116,13 +116,13 @@ Verifying transaction signatures is similar to personal message signature verifi
use `verifyTransactionSignature`:
```typescript
-// import SuiClient to create a network client and the getFullnodeUrl helper function
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+// import SuiJsonRpcClient to create a network client and the getJsonRpcFullnodeUrl helper function
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
import { verifyTransactionSignature } from '@mysten/sui/verify';
-// see Network Interactions with SuiClient for more info on creating clients
-const client = new SuiClient({ url: getFullnodeUrl('testnet') });
+// see Network Interactions with SuiJsonRpcClient for more info on creating clients
+const client = new SuiJsonRpcClient({ url: getJsonRpcFullnodeUrl('testnet'), network: 'testnet' });
const tx = new Transaction();
// ... add some transactions...
const bytes = await tx.build({ client });
diff --git a/packages/docs/content/typescript/executors.mdx b/packages/docs/content/typescript/executors.mdx
index c2d6c4fe0..f43e2542b 100644
--- a/packages/docs/content/typescript/executors.mdx
+++ b/packages/docs/content/typescript/executors.mdx
@@ -27,16 +27,16 @@ transactions to finish before sending the next one.
`SerialTransactionExecutor` can be configured with a number of options:
-- `client`: An instance of `SuiClient` used to execute transactions.
+- `client`: An instance of `SuiJsonRpcClient` used to execute transactions.
- `signer`: The signer/keypair used for signed transactions.
- `defaultBudget`: The default budget for transactions, which will be used if the transaction does
not specify a budget (default `50_000_000n`),
```ts
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { SerialTransactionExecutor } from '@mysten/sui/transactions';
-const client = new SuiClient({ url: getFullnodeUrl('devnet') });
+const client = new SuiJsonRpcClient({ url: getJsonRpcFullnodeUrl('devnet'), network: 'devnet' });
const executor = new SerialTransactionExecutor({
client,
@@ -68,7 +68,7 @@ will maintain a pool of gas coins, and automatically execute additional transact
gas pool as needed.
- Using SuiClient or wallets to execute additional transactions while `ParallelTransactionExecutor`
+ Using SuiJsonRpcClient or wallets to execute additional transactions while `ParallelTransactionExecutor`
is in use may consume/combine gas coins in the gasPool, causing transactions to fail. This may
also result in the coins becoming locked for the remainder of the current epoch, preventing them
from being used in future transactions.
@@ -84,7 +84,7 @@ way that avoids conflicts between transactions using the same object ids.
`ParallelTransactionExecutor` can be configured with a number of options:
-- `client`: An instance of `SuiClient` used to execute transactions.
+- `client`: An instance of `SuiJsonRpcClient` used to execute transactions.
- `signer`: The signer/keypair used for signed transactions.
- `coinBatchSize`: The maximum number of new coins to create when refilling the gas pool
(default 20)
@@ -103,10 +103,10 @@ way that avoids conflicts between transactions using the same object ids.
each epoch boundary to ensure the gas price is up-to-date for the next epoch. (default `1000`)
```ts
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { ParallelTransactionExecutor } from '@mysten/sui/transactions';
-const client = new SuiClient({ url: getFullnodeUrl('devnet') });
+const client = new SuiJsonRpcClient({ url: getJsonRpcFullnodeUrl('devnet'), network: 'devnet' });
const executor = new ParallelTransactionExecutor({
client,
diff --git a/packages/docs/content/typescript/graphql.mdx b/packages/docs/content/typescript/graphql.mdx
index a0b352fb6..17cd0fcc8 100644
--- a/packages/docs/content/typescript/graphql.mdx
+++ b/packages/docs/content/typescript/graphql.mdx
@@ -23,10 +23,11 @@ We'll start by creating our client, and executing a very basic query:
```typescript
import { SuiGraphQLClient } from '@mysten/sui/graphql';
-import { graphql } from '@mysten/sui/graphql/schemas/latest';
+import { graphql } from '@mysten/sui/graphql/schema';
const gqlClient = new SuiGraphQLClient({
url: 'https://graphql.testnet.sui.io/graphql',
+ network: 'testnet',
});
const chainIdentifierQuery = graphql(`
@@ -51,11 +52,8 @@ You may have noticed the example above does not include any type definitions for
automatically provide the required type information to ensure that your queries are properly typed
when executed through `SuiGraphQLClient`.
-The `graphql` function itself is imported from a versioned schema file, and you should ensure that
-you are using the version that corresponds to the latest release of the GraphQL API.
-
-The `graphql` also detects variables used by your query, and will ensure that the variables passed
-to your query are properly typed.
+The `graphql` function detects variables used by your query, and will ensure that the variables
+passed to your query are properly typed.
```typescript
const getSuinsName = graphql(`
diff --git a/packages/docs/content/typescript/hello-sui.mdx b/packages/docs/content/typescript/hello-sui.mdx
index f584b4642..c34617e22 100644
--- a/packages/docs/content/typescript/hello-sui.mdx
+++ b/packages/docs/content/typescript/hello-sui.mdx
@@ -52,15 +52,15 @@ address. You must be on Devnet, Testnet, or a local network to use a faucet for
Create a new `index.js` file in the root of your project with the following code.
```js
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { getFaucetHost, requestSuiFromFaucetV2 } from '@mysten/sui/faucet';
import { MIST_PER_SUI } from '@mysten/sui/utils';
// replace with your actual address, which is in the form 0x123...
const MY_ADDRESS = '';
-// create a new SuiClient object pointing to the network you want to use
-const suiClient = new SuiClient({ url: getFullnodeUrl('devnet') });
+// create a new SuiJsonRpcClient object pointing to the network you want to use
+const suiClient = new SuiJsonRpcClient({ url: getJsonRpcFullnodeUrl('devnet'), network: 'devnet' });
// Convert MIST to Sui
const balance = (balance) => {
@@ -99,9 +99,10 @@ node index.js
```
The code imports the `requestSuiFromFaucetV2` function from the SDK and calls it to mint SUI for the
-provided address. The code also imports `SuiClient` to create a new client on the Sui network that
-it uses to query the address and output the amount of SUI the address owns before and after using
-the faucet. You can check the total SUI for your address using the Sui Wallet or Sui Client CLI.
+provided address. The code also imports `SuiJsonRpcClient` to create a new client on the Sui network
+that it uses to query the address and output the amount of SUI the address owns before and after
+using the faucet. You can check the total SUI for your address using the Sui Wallet or Sui Client
+CLI.
Faucets on Devnet and Testnet are rate limited. If you run the script too many times, you surpass
diff --git a/packages/docs/content/typescript/migrations/0.38.mdx b/packages/docs/content/typescript/migrations/0.38.mdx
index ab736b8c7..abed7c0c3 100644
--- a/packages/docs/content/typescript/migrations/0.38.mdx
+++ b/packages/docs/content/typescript/migrations/0.38.mdx
@@ -25,14 +25,15 @@ The Sui TypeScript SDK deprecates the following classes with version 0.38.0:
- `JsonRpcProvider` - The `JsonRpcProvider` class is deprecated in favor of the `suiClient` class
when creating a client for a Sui network. See
- [Network Interactions with SuiClient](typescript/sui-client) for more information.
+ [Network Interactions with SuiJsonRpcClient](typescript/sui-client) for more information.
- `SignerWithProver` and `RawSigner` - Key pairs now directly support signing transactions and
messages without the need of a `Signer` class. See the
[Key pairs](typescript/cryptography/keypairs) topic for more information.
-- `signAndExecuteTransaction` - This method was not deprecated, but is now part of `SuiClient`.
+- `signAndExecuteTransaction` - This method was not deprecated, but is now part of
+ `SuiJsonRpcClient`.
- `Connection` classes - The `Connection` classes (`Connection`, `devnetConnection`, and so on) have
- been deprecated in favor of using `suiClient` for establishing the connection. See
- [Network Interactions with SuiClient](typescript/sui-client) for more information.
+ been deprecated in favor ofSuiJsonRpcClientuiClient` for establishing the connection. See
+ [Network Interactions with SuiJsonRpcClient](typescript/sui-client) for more information.
- The `superstruct` type definitions for `JsonRPCProvider` types are replaced with generated types
exported from `@mysten/sui/client`. The new type definitions are pure TypeScript types that you
can't use for runtime validation.
@@ -47,8 +48,8 @@ an example of transaction signing, see the
### Faucet requests
-The ability to request SUI from a faucet is not part of `SuiClient` as it was with
-`JsonRpcProvider`. Instead, you must use the `requestSuiFromFaucetV0` method from
+SuiJsonRpcClient The ability to request SUI from a faucet is not part of `SuiJsonRpcClient` as it
+was with `JsonRpcProvider`. Instead, you must use the `requestSuiFromFaucetV0` method from
`@mysten/sui/faucet`. The `@mysten/sui/faucet` import also provides a `getFaucetHost` method to
retrieve the faucet URL for `localnet`, `testnet`, or `devnet` networks.
diff --git a/packages/docs/content/typescript/migrations/sui-1.0.mdx b/packages/docs/content/typescript/migrations/sui-1.0.mdx
index 69b642d9a..143c0a3a2 100644
--- a/packages/docs/content/typescript/migrations/sui-1.0.mdx
+++ b/packages/docs/content/typescript/migrations/sui-1.0.mdx
@@ -32,8 +32,8 @@ npm install @mysten/sui
Then update all imports to use the new package name:
```diff
-- import { SuiClient } from '@mysten/sui.js'
-+ import { SuiClient } from '@mysten/sui'
+- import { SuiJsonRpcClient } from '@mysten/sui.js'
++ import { SuiJsonRpcClient } from '@mysten/sui'
```
### `@mysten/sui/transactions`
@@ -67,8 +67,8 @@ The `TransactionBlock` class has been renamed to `Transaction`, along with many
- `suiClient.signAndExecuteTransactionBlock({ transactionBlock })` ->
`suiClient.signAndExecuteTransaction({ transaction })`
-There are a few methods on SuiClient that retain the `TransactionBlock` name because they correspond
-to specific JSON RPC calls. The following methods are unchanged:
+There are a few methods on SuiJsonRpcClient that retain the `TransactionBlock` name because they
+correspond to specific JSON RPC calls. The following methods are unchanged:
- `suiClient.getTransactionBlock`
- `suiClient.queryTransactionBlocks`
diff --git a/packages/docs/content/typescript/migrations/sui-2.0.mdx b/packages/docs/content/typescript/migrations/sui-2.0.mdx
new file mode 100644
index 000000000..7ed3ce822
--- /dev/null
+++ b/packages/docs/content/typescript/migrations/sui-2.0.mdx
@@ -0,0 +1,223 @@
+---
+title: Migrate to version 2.0
+---
+
+# Migrating to @mysten/sui@2.0
+
+## ZkLogin `legacyAddress` parameter is now required
+
+The `legacyAddress` parameter is now **required** for all zkLogin address computation functions. In
+v1.x, this parameter had default values that varied by function, which could lead to confusion. You
+must now explicitly specify whether you want to use legacy address encoding.
+
+Update all calls to zkLogin functions to include the `legacyAddress` parameter. **To preserve
+existing behavior**, use the following migrations:
+
+```diff
+// computeZkLoginAddressFromSeed (previous default: true)
+- computeZkLoginAddressFromSeed(seed, iss)
++ computeZkLoginAddressFromSeed(seed, iss, true)
+
+// jwtToAddress (previous default: false)
+- jwtToAddress(jwt, userSalt)
++ jwtToAddress(jwt, userSalt, false)
+
+// computeZkLoginAddress (previous default: false)
+- computeZkLoginAddress({ claimName, claimValue, iss, aud, userSalt })
++ computeZkLoginAddress({ claimName, claimValue, iss, aud, userSalt, legacyAddress: false })
+
+// toZkLoginPublicIdentifier (no previous default, was optional)
+- toZkLoginPublicIdentifier(addressSeed, iss)
++ toZkLoginPublicIdentifier(addressSeed, iss, { legacyAddress: false })
+```
+
+## ZkLogin Signature verification
+
+In previous versions of the SDK, methods that verified ZkLogin signatures created a GraphQL client
+that used the GraphQL alpha to verify mainnet ZkLogin signatures. This default is being removed, as
+it was dependent on the GraphQL alpha endpoint, which is no longer available, and did not work for
+non-mainnet signatures.
+
+You will now need to pass a client (GraphQL, GRPC, or JSON RPC) to any methods that verify ZkLogin
+signatures.
+
+```ts
+const client: SuiGraphQLClient | SuiGrpcClient | SuiJsonRpcClient;
+
+verifyPersonalMessageSignature(message, signature, { client });
+verifyTransactionSignature(txBytes, signature, { client });
+parseSignature(signatureBytes, { client });
+
+// For ZkLoginPublicIdentifier, the client is passed in when it it created
+zkLoginPublicIdentifier = toZkLoginPublicIdentifier(seed, iss, { client, legacyAddress: false });
+zkLoginPublicIdentifier.verifyPersonalMessage(message, signature);
+zkLoginPublicIdentifier.verifyTransaction(transaction, signature);
+```
+
+## Network is now required for GraphQL and JSON RPC clients
+
+When creating a new `SuiGraphQLClient` or `SuiJsonRpcClient`, you must now provide a `network`
+parameter.
+
+```ts
+const client = new SuiGraphQLClient({
+ url: 'https://...',
+ network: 'mainnet', // or 'testnet', 'devnet', etc.
+});
+const client = new SuiJsonRpcClient({
+ url: 'https://...',
+ network: 'mainnet', // or 'testnet', 'devnet', etc.
+});
+```
+
+## Removal of SuiClient exports from @mysten/sui/client
+
+The `@mysten/sui/client` export path has been removed. All JSON-RPC client functionality is now
+exported from `@mysten/sui/jsonRpc`.
+
+The following exports have been removed from `@mysten/sui/client`:
+
+- `SuiClient` (use `SuiJsonRpcClient` instead)
+- `SuiClientOptions` (use `SuiJsonRpcClientOptions` instead)
+- `isSuiClient` (use `isSuiJsonRpcClient` instead)
+- `SuiTransport` (use `JsonRpcTransport` instead)
+- `SuiTransportRequestOptions` (use `JsonRpcTransportRequestOptions` instead)
+- `SuiTransportSubscribeOptions` (use `JsonRpcTransportSubscribeOptions` instead)
+- `SuiHTTPTransportOptions` (use `JsonRpcHTTPTransportOptions` instead)
+- `SuiHTTPTransport` (use `JsonRpcHTTPTransport` instead)
+- `getFullnodeUrl` (use `getJsonRpcFullnodeUrl` instead)
+- All JSON-RPC types (now exported from `@mysten/sui/jsonRpc`)
+
+**Migration:**
+
+Update all imports from `@mysten/sui/client` to `@mysten/sui/jsonRpc` and rename classes:
+
+```diff
+- import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
++ import { SuiJsonRpcClient, getJsonRpcFullnodeUrl } from '@mysten/sui/jsonRpc';
+
+- const client = new SuiClient({
+- url: getFullnodeUrl('devnet'),
++ const client = new SuiJsonRpcClient({
++ url: getJsonRpcFullnodeUrl('devnet'),
+ network: 'devnet',
+ });
+```
+
+## Removal of reportTransactionEffects API
+
+The `sui:reportTransactionEffects` wallet standard feature and associated hooks have been removed
+from both `@mysten/wallet-standard` and `@mysten/dapp-kit`.
+
+The following APIs have been removed:
+
+- `sui:reportTransactionEffects` feature from wallet standard
+- `useReportTransactionEffects` hook from dapp-kit
+- `reportTransactionEffects` callback from `useSignTransaction` hook's return value
+- Automatic transaction effects reporting in `useSignAndExecuteTransaction`
+
+**For dApp developers:**
+
+If you were using `useReportTransactionEffects`:
+
+```diff
+- const { mutateAsync: reportTransactionEffects } = useReportTransactionEffects();
+ const { effects } = await executePreSignedTransaction();
+- reportTransactionEffects({ effects });
+```
+
+If you were using the `reportTransactionEffects` callback from `useSignTransaction`:
+
+```diff
+const {
+ bytes,
+ signature,
+- reportTransactionEffects
+} = await signTransaction({
+ transaction: new Transaction(),
+});
+const executeResult = await client.executeTransactionBlock({
+ transactionBlock: bytes,
+ signature,
+});
+- reportTransactionEffects(executeResult.rawEffects!);
+```
+
+**For wallet developers:**
+
+Remove the `sui:reportTransactionEffects` feature implementation from your wallet.
+
+## Experimental Client API Stabilization
+
+The experimental client API has been stabilized and moved from `@mysten/sui/experimental` to
+`@mysten/sui/client`. All `Experimental_` prefixes have been removed from types and classes.
+
+**Breaking changes:**
+
+- The `@mysten/sui/experimental` module has been removed
+- All `Experimental_` prefixed types and classes have been renamed
+- Client types namespace changed from `Experimental_SuiClientTypes` to `SuiClientTypes`
+
+**Migration:**
+
+Update imports and remove `Experimental_` prefixes:
+
+```diff
+- import {
+- Experimental_BaseClient,
+- Experimental_CoreClient,
+- type Experimental_SuiClientTypes,
+- type Experimental_CoreClientOptions,
+- } from '@mysten/sui/experimental';
++ import {
++ BaseClient,
++ CoreClient,
++ type SuiClientTypes,
++ type CoreClientOptions,
++ } from '@mysten/sui/client';
+
+// Update class extensions
+- class MyClient extends Experimental_CoreClient {
++ class MyClient extends CoreClient {
+ async getObjects(
+- options: Experimental_SuiClientTypes.GetObjectsOptions,
+- ): Promise {
++ options: SuiClientTypes.GetObjectsOptions,
++ ): Promise {
+ // ...
+ }
+ }
+```
+
+**Common renames:**
+
+| Old Name | New Name |
+| -------------------------------- | ------------------- |
+| `Experimental_BaseClient` | `BaseClient` |
+| `Experimental_CoreClient` | `CoreClient` |
+| `Experimental_SuiClientTypes` | `SuiClientTypes` |
+| `Experimental_CoreClientOptions` | `CoreClientOptions` |
+
+## GraphQL Schema Consolidation
+
+The SDK now exports a single unified GraphQL schema instead of multiple versioned schemas. Now that
+the GraphQL API is more stable, there should always only be a single schema supported by the API.
+
+**Breaking changes:**
+
+The following versioned schema exports have been removed:
+
+- `@mysten/sui/graphql/schemas/2024.1`
+- `@mysten/sui/graphql/schemas/2024.4`
+- `@mysten/sui/graphql/schemas/latest`
+
+**Migration:**
+
+Replace all versioned schema imports with the new unified schema export:
+
+```diff
+- import { graphql } from '@mysten/sui/graphql/schemas/latest';
+- import { graphql } from '@mysten/sui/graphql/schemas/2024.4';
+- import { graphql } from '@mysten/sui/graphql/schemas/2024.1';
++ import { graphql } from '@mysten/sui/graphql/schema';
+```
diff --git a/packages/docs/content/typescript/sui-client.mdx b/packages/docs/content/typescript/sui-client.mdx
index bf06b6809..a6a7b30ac 100644
--- a/packages/docs/content/typescript/sui-client.mdx
+++ b/packages/docs/content/typescript/sui-client.mdx
@@ -1,5 +1,5 @@
---
-title: JsonRpcClient
+title: Network Interactions with SuiJsonRpcClient
---
@@ -17,19 +17,23 @@ compatibility) to connect to a network's JSON-RPC server.
`SuiJsonRpcClient` and can be used interchangeably.
+The Sui TypeScript SDK provides a `SuiJsonRpcClient` class to connect to a network's JSON-RPC
+sSuiJsonRpcCliente `SuiJsonRpcClient` for all JSON-RPC operations.
+
## Connecting to a Sui network
-To establish a connection to a network, import `SuiJsonRpcClient` from `@mysten/sui/jsonRpc` and
-pass the relevant URL to the `url` parameter. The following example establishes a connection to
-Devnet and get all `Coin` objects owned by an address.
+To establish a connection to a network, import `SuiJsonRpcClient` from `@mysten/sui/client` and pass
+the relevant URL to the `url` parameter. The following example establishes a connection to Devnet
+and get all `Coin` objects owned by an address.
```typescript
-import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
+
+// use getJsonRpcFullnodeUrl to define Devnet RPC location
+const rpcUrl = getJsonRpcFullnodeUrl('devnet');
// create a client connected to devnet
-const client = new SuiJsonRpcClient({
- url: 'https://fullnode.devnet.sui.io:443',
-});
+const client = new SuiJsonRpcClient({ url: rpcUrl, network: 'devnet' });
// get coins owned by an address
// replace with actual address in the form of 0x123...
@@ -38,17 +42,6 @@ await client.getCoins({
});
```
-Alternatively, you can use the `SuiClient` alias from `@mysten/sui/client` for backward
-compatibility:
-
-```typescript
-import { SuiClient } from '@mysten/sui/client';
-
-const client = new SuiClient({
- url: 'https://fullnode.devnet.sui.io:443',
-});
-```
-
Network URLs:
- `localnet`: `http://127.0.0.1:9000`
@@ -72,7 +65,6 @@ import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
const client = new SuiJsonRpcClient({
url: 'https://fullnode.devnet.sui.io:443',
});
-
// asynchronously call suix_getCommitteeInfo
const committeeInfo = await client.call('suix_getCommitteeInfo', []);
```
diff --git a/packages/docs/content/typescript/transaction-building/basics.mdx b/packages/docs/content/typescript/transaction-building/basics.mdx
index 96f49bd4c..fafef7b05 100644
--- a/packages/docs/content/typescript/transaction-building/basics.mdx
+++ b/packages/docs/content/typescript/transaction-building/basics.mdx
@@ -64,8 +64,8 @@ may not be immediately observable.
There are 2 ways to observe the results of a transaction. Methods like
`client.signAndExecuteTransaction` accept an `options` object with options like `showObjectChanges`
and `showBalanceChanges` (see
-[the SuiClient docs for more details](/typescript/sui-client#arguments)). These options will cause
-the request to contain additional details about the effects of the transaction that can be
+[the SuiJsonRpcClient docs for more details](/typescript/sui-client#arguments)). These options will
+cause the request to contain additional details about the effects of the transaction that can be
immediately displayed to the user, or used for further processing in your application.
The other way effects of transactions can be observed is by querying other RPC methods like
@@ -279,7 +279,7 @@ const tx = new Transaction();
await tx.build({ client });
```
-In most cases, building requires your SuiClient to fully resolve input values.
+In most cases, building requires your SuiJsonRpcClient to fully resolve input values.
If you have transaction bytes, you can also convert them back into a `Transaction` class:
diff --git a/packages/docs/content/walrus/index.mdx b/packages/docs/content/walrus/index.mdx
index ad2185024..fef1873d6 100644
--- a/packages/docs/content/walrus/index.mdx
+++ b/packages/docs/content/walrus/index.mdx
@@ -14,12 +14,11 @@ To use the walrus SDK you will need to create a Client from the typescript SDK,
the walrus SDK.
```ts
-import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
-import { getFullnodeUrl } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { walrus } from '@mysten/walrus';
const client = new SuiJsonRpcClient({
- url: getFullnodeUrl('testnet'),
+ url: getJsonRpcFullnodeUrl('testnet'),
// Setting network on your client is required for walrus to work correctly
network: 'testnet',
}).$extend(walrus());
@@ -30,12 +29,11 @@ testnet. You can also manually configure the walrus sdk to use a different set o
to connect to a different network or updated deployment of the walrus contracts.
```ts
-import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
-import { getFullnodeUrl } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { walrus } from '@mysten/walrus';
const client = new SuiJsonRpcClient({
- url: getFullnodeUrl('testnet'),
+ url: getJsonRpcFullnodeUrl('testnet'),
// Setting network on your client is required for walrus to work correctly
network: 'testnet',
}).$extend(
@@ -51,12 +49,11 @@ const client = new SuiJsonRpcClient({
For some environments you may need to customize how data is fetched:
```ts
-import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
-import { getFullnodeUrl } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { walrus } from '@mysten/walrus';
const client = new SuiJsonRpcClient({
- url: getFullnodeUrl('testnet'),
+ url: getJsonRpcFullnodeUrl('testnet'),
// Setting network on your client is required for walrus to work correctly
network: 'testnet',
}).$extend(
@@ -272,7 +269,7 @@ To use an upload relay, you can add the `uploadRelay` option when adding the wal
```ts
const client = new SuiJsonRpcClient({
- url: getFullnodeUrl('testnet'),
+ url: getJsonRpcFullnodeUrl('testnet'),
network: 'testnet',
}).$extend(
walrus({
@@ -301,7 +298,7 @@ A `const` will send a fixed amount for each blob written to the upload relay.
```ts
const client = new SuiJsonRpcClient({
- url: getFullnodeUrl('testnet'),
+ url: getJsonRpcFullnodeUrl('testnet'),
network: 'testnet',
}).$extend(
walrus({
@@ -325,7 +322,7 @@ multiplier based on the size of the blob.
```ts
const client = new SuiJsonRpcClient({
- url: getFullnodeUrl('testnet'),
+ url: getJsonRpcFullnodeUrl('testnet'),
network: 'testnet',
}).$extend(
walrus({
@@ -428,7 +425,7 @@ failed requests:
```ts
const client = new SuiJsonRpcClient({
- url: getFullnodeUrl('testnet'),
+ url: getJsonRpcFullnodeUrl('testnet'),
network: 'testnet',
}).$extend(
walrus({
@@ -457,7 +454,7 @@ import type { RequestInfo, RequestInit } from 'undici';
import { Agent, fetch } from 'undici';
const client = new SuiJsonRpcClient({
- url: getFullnodeUrl('testnet'),
+ url: getJsonRpcFullnodeUrl('testnet'),
network: 'testnet',
}).$extend(
walrus({
@@ -491,7 +488,7 @@ and then passed into the walrus client:
import walrusWasmUrl from '@mysten/walrus-wasm/web/walrus_wasm_bg.wasm?url';
const client = new SuiJsonRpcClient({
- url: getFullnodeUrl('testnet'),
+ url: getJsonRpcFullnodeUrl('testnet'),
network: 'testnet',
}).$extend(
walrus({
@@ -505,7 +502,7 @@ the wasm bindings, or load them from a CDN:
```ts
const client = new SuiJsonRpcClient({
- url: getFullnodeUrl('testnet'),
+ url: getJsonRpcFullnodeUrl('testnet'),
network: 'testnet',
}).$extend(
walrus({
diff --git a/packages/docs/examples/wallet-components.tsx b/packages/docs/examples/wallet-components.tsx
index fb76c0dae..849a55e51 100644
--- a/packages/docs/examples/wallet-components.tsx
+++ b/packages/docs/examples/wallet-components.tsx
@@ -10,7 +10,7 @@ import {
useCurrentAccount,
WalletProvider,
} from '@mysten/dapp-kit';
-import { getFullnodeUrl } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl } from '@mysten/sui/jsonRpc';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { useState } from 'react';
@@ -50,7 +50,7 @@ export const UncontrolledConnectModalExample = withProviders(() => {
function withProviders(Component: React.FunctionComponent) {
const queryClient = new QueryClient();
const networks = {
- mainnet: { url: getFullnodeUrl('mainnet') },
+ mainnet: { url: getJsonRpcFullnodeUrl('mainnet'), network: 'mainnet' as const },
};
return () => {
diff --git a/packages/docs/examples/wallet-hooks.tsx b/packages/docs/examples/wallet-hooks.tsx
index 17eb53ded..39c21d270 100644
--- a/packages/docs/examples/wallet-hooks.tsx
+++ b/packages/docs/examples/wallet-hooks.tsx
@@ -19,7 +19,7 @@ import {
useWallets,
WalletProvider,
} from '@mysten/dapp-kit';
-import { getFullnodeUrl } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl } from '@mysten/sui/jsonRpc';
import { Transaction } from '@mysten/sui/transactions';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import type { ComponentProps } from 'react';
@@ -309,7 +309,7 @@ function withProviders(
// Work around server-side pre-rendering
const queryClient = new QueryClient();
const networks = {
- mainnet: { url: getFullnodeUrl('mainnet') },
+ mainnet: { url: getJsonRpcFullnodeUrl('mainnet'), network: 'mainnet' as const },
};
return () => {
diff --git a/packages/enoki-connect/demo-dapp/src/networkConfig.ts b/packages/enoki-connect/demo-dapp/src/networkConfig.ts
index f81095781..d99276678 100644
--- a/packages/enoki-connect/demo-dapp/src/networkConfig.ts
+++ b/packages/enoki-connect/demo-dapp/src/networkConfig.ts
@@ -1,18 +1,21 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import { getFullnodeUrl } from "@mysten/sui/client";
+import { getJsonRpcFullnodeUrl } from "@mysten/sui/jsonRpc";
import { createNetworkConfig } from "@mysten/dapp-kit";
const { networkConfig, useNetworkVariable, useNetworkVariables } =
createNetworkConfig({
devnet: {
- url: getFullnodeUrl("devnet"),
+ network: "devnet",
+ url: getJsonRpcFullnodeUrl("devnet"),
},
testnet: {
- url: getFullnodeUrl("testnet"),
+ network: "testnet",
+ url: getJsonRpcFullnodeUrl("testnet"),
},
mainnet: {
- url: getFullnodeUrl("mainnet"),
+ network: "mainnet",
+ url: getJsonRpcFullnodeUrl("mainnet"),
},
});
diff --git a/packages/enoki/demo/main.tsx b/packages/enoki/demo/main.tsx
index 5bbbec106..c1cfc4bc1 100644
--- a/packages/enoki/demo/main.tsx
+++ b/packages/enoki/demo/main.tsx
@@ -8,9 +8,9 @@ import ReactDOM from 'react-dom/client';
import '@mysten/dapp-kit/dist/index.css';
-import { getFullnodeUrl } from '../../typescript/src/client/network.ts';
import { App } from './App.tsx';
import { RegisterEnokiWallets } from './RegisterEnokiWallets.tsx';
+import { getJsonRpcFullnodeUrl } from '@mysten/sui/jsonRpc';
const queryClient = new QueryClient();
@@ -20,9 +20,11 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
ClientWithCoreApi;
+ networks: readonly SuiClientTypes.Network[];
+ getClient: (network?: SuiClientTypes.Network) => ClientWithCoreApi;
}) {
const { unregister } = registerEnokiWallets({
...options,
diff --git a/packages/enoki/src/wallet/register.ts b/packages/enoki/src/wallet/register.ts
index 84e86986d..96a49eba4 100644
--- a/packages/enoki/src/wallet/register.ts
+++ b/packages/enoki/src/wallet/register.ts
@@ -4,7 +4,7 @@
import { EnokiWallet } from './wallet.js';
import type { RegisterEnokiWalletsOptions } from './types.js';
import { getWallets } from '@mysten/wallet-standard';
-import type { ClientWithCoreApi } from '@mysten/sui/experimental';
+import type { ClientWithCoreApi } from '@mysten/sui/client';
import type { AuthProvider } from '../EnokiClient/type.js';
import { isEnokiNetwork } from '../utils.js';
import { ENOKI_PROVIDER_WALLETS_INFO } from './providers.js';
diff --git a/packages/enoki/src/wallet/state.ts b/packages/enoki/src/wallet/state.ts
index 029cda90a..55de1e062 100644
--- a/packages/enoki/src/wallet/state.ts
+++ b/packages/enoki/src/wallet/state.ts
@@ -9,7 +9,7 @@ import { atom, onMount, onSet, task } from 'nanostores';
import type { Encryption } from '../encryption.js';
import { createDefaultEncryption } from '../encryption.js';
import type { EnokiClientConfig } from '../EnokiClient/index.js';
-import type { ClientWithCoreApi, Experimental_SuiClientTypes } from '@mysten/sui/experimental';
+import type { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';
import type { EnokiSessionContext, ZkLoginSession, ZkLoginState } from './types.js';
@@ -27,7 +27,7 @@ export class EnokiWalletState {
#encryptionKey: string;
#stateStore: UseStore;
- #sessionContextByNetwork: Map;
+ #sessionContextByNetwork: Map;
#zkLoginState: WritableAtom;
constructor(config: EnokiWalletStateConfig) {
@@ -63,7 +63,7 @@ export class EnokiWalletState {
return this.#sessionContextByNetwork;
}
- getSessionContext(network: Experimental_SuiClientTypes.Network) {
+ getSessionContext(network: SuiClientTypes.Network) {
const context = this.#sessionContextByNetwork.get(network);
if (!context) {
throw new Error(`The network ${network} isn't supported.`);
diff --git a/packages/enoki/src/wallet/types.ts b/packages/enoki/src/wallet/types.ts
index ab0905fc3..5e154b808 100644
--- a/packages/enoki/src/wallet/types.ts
+++ b/packages/enoki/src/wallet/types.ts
@@ -1,12 +1,12 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { SuiClient } from '@mysten/sui/client';
+import type { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import type { StandardEventsListeners, Wallet } from '@mysten/wallet-standard';
import type { EnokiClientConfig } from '../EnokiClient/index.js';
import type { AuthProvider, EnokiNetwork } from '../EnokiClient/type.js';
-import type { ClientWithCoreApi, Experimental_SuiClientTypes } from '@mysten/sui/experimental';
+import type { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';
import type { ZkLoginSignatureInputs } from '@mysten/sui/zklogin';
import type { UseStore } from 'idb-keyval';
import type { WritableAtom } from 'nanostores';
@@ -43,7 +43,7 @@ type ClientConfig = {
/**
* A function that returns the current network that the application is acting on.
*/
- getCurrentNetwork: () => Experimental_SuiClientTypes.Network;
+ getCurrentNetwork: () => SuiClientTypes.Network;
};
export type EnokiWalletOptions = {
@@ -89,9 +89,9 @@ export type RegisterEnokiWalletsOptions = {
| ClientConfig
| {
/**
- * The SuiClient instance to use when building and executing transactions.
+ * The SuiJsonRpcClient instance to use when building and executing transactions.
*/
- client: SuiClient;
+ client: SuiJsonRpcClient;
/**
* The network to use when building and executing transactions.
diff --git a/packages/enoki/src/wallet/wallet.ts b/packages/enoki/src/wallet/wallet.ts
index 32b3684b6..5538bf050 100644
--- a/packages/enoki/src/wallet/wallet.ts
+++ b/packages/enoki/src/wallet/wallet.ts
@@ -40,7 +40,7 @@ import type {
EnokiGetSessionMethod,
} from './features.js';
import { EnokiGetMetadata, EnokiGetSession } from './features.js';
-import type { Experimental_SuiClientTypes } from '@mysten/sui/experimental';
+import type { SuiClientTypes } from '@mysten/sui/client';
import { decodeJwt } from '@mysten/sui/zklogin';
import type { ExportedWebCryptoKeypair } from '@mysten/signers/webcrypto';
import { WebCryptoSigner } from '@mysten/signers/webcrypto';
@@ -72,7 +72,7 @@ export class EnokiWallet implements Wallet {
#clientId: string;
#redirectUrl: string;
#extraParams: Record | (() => Record) | undefined;
- #getCurrentNetwork: () => Experimental_SuiClientTypes.Network;
+ #getCurrentNetwork: () => SuiClientTypes.Network;
#windowFeatures?: string | (() => string);
get name() {
@@ -352,7 +352,7 @@ export class EnokiWallet implements Wallet {
return { client: sessionContext.client, keypair };
}
- async #createSession({ network }: { network: Experimental_SuiClientTypes.Network }) {
+ async #createSession({ network }: { network: SuiClientTypes.Network }) {
const popup = window.open(
undefined,
'_blank',
diff --git a/packages/kiosk/.prettierignore b/packages/kiosk/.prettierignore
index a3414d0fd..ef3c77828 100644
--- a/packages/kiosk/.prettierignore
+++ b/packages/kiosk/.prettierignore
@@ -1,2 +1,3 @@
dist
CHANGELOG.md
+test/e2e/data
diff --git a/packages/kiosk/src/client/kiosk-client.ts b/packages/kiosk/src/client/kiosk-client.ts
index f937731cf..0f040468f 100644
--- a/packages/kiosk/src/client/kiosk-client.ts
+++ b/packages/kiosk/src/client/kiosk-client.ts
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { PaginationArguments, SuiClient } from '@mysten/sui/client';
+import type { PaginationArguments, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import {
FLOOR_PRICE_RULE_ADDRESS,
@@ -33,7 +33,7 @@ import type {
* If you pass packageIds, all functionality will be managed using these packages.
*/
export class KioskClient {
- client: SuiClient;
+ client: SuiJsonRpcClient;
network: Network;
rules: TransferPolicyRule[];
packageIds?: BaseRulePackageIds;
diff --git a/packages/kiosk/src/client/kiosk-transaction.ts b/packages/kiosk/src/client/kiosk-transaction.ts
index cc345ded2..fc5a92899 100644
--- a/packages/kiosk/src/client/kiosk-transaction.ts
+++ b/packages/kiosk/src/client/kiosk-transaction.ts
@@ -26,8 +26,6 @@ export type KioskTransactionParams = {
/** The Transaction for this run */
transaction: Transaction;
- /** @deprecated use transaction instead */
- transactionBlock?: Transaction;
/**
* You can create a new KioskClient by calling `new KioskClient()`
*/
@@ -59,12 +57,7 @@ export class KioskTransaction {
// A flag that checks whether kiosk TX is finalized.
#finalized: boolean = false;
- constructor({
- transactionBlock,
- transaction = transactionBlock!,
- kioskClient,
- cap,
- }: KioskTransactionParams) {
+ constructor({ transaction, kioskClient, cap }: KioskTransactionParams) {
this.transaction = transaction;
this.kioskClient = kioskClient;
@@ -377,7 +370,6 @@ export class KioskTransaction {
await ruleDefinition.resolveRuleFunction({
packageId: ruleDefinition.packageId,
- transactionBlock: this.transaction,
transaction: this.transaction,
itemType,
itemId,
diff --git a/packages/kiosk/src/client/tp-transaction.ts b/packages/kiosk/src/client/tp-transaction.ts
index b27e61a5a..cdfa9bdf8 100644
--- a/packages/kiosk/src/client/tp-transaction.ts
+++ b/packages/kiosk/src/client/tp-transaction.ts
@@ -28,8 +28,6 @@ export type TransferPolicyBaseParams = {
export type TransferPolicyTransactionParams = {
kioskClient: KioskClient;
transaction: Transaction;
- /** @deprecated use transaction instead */
- transactionBlock?: Transaction;
cap?: TransferPolicyCap;
};
@@ -40,12 +38,7 @@ export class TransferPolicyTransaction {
policyCap?: ObjectArgument;
type?: string;
- constructor({
- kioskClient,
- transactionBlock,
- transaction = transactionBlock!,
- cap,
- }: TransferPolicyTransactionParams) {
+ constructor({ kioskClient, transaction, cap }: TransferPolicyTransactionParams) {
this.kioskClient = kioskClient;
this.transaction = transaction;
if (cap) this.setCap(cap);
diff --git a/packages/kiosk/src/query/kiosk.ts b/packages/kiosk/src/query/kiosk.ts
index 7d457c582..46b6386b8 100644
--- a/packages/kiosk/src/query/kiosk.ts
+++ b/packages/kiosk/src/query/kiosk.ts
@@ -4,10 +4,10 @@
import type {
PaginatedObjectsResponse,
PaginationArguments,
- SuiClient,
+ SuiJsonRpcClient,
SuiObjectData,
SuiObjectResponse,
-} from '@mysten/sui/client';
+} from '@mysten/sui/jsonRpc';
import { isValidSuiAddress } from '@mysten/sui/utils';
import type {
@@ -29,7 +29,7 @@ import {
} from '../utils.js';
export async function fetchKiosk(
- client: SuiClient,
+ client: SuiJsonRpcClient,
kioskId: string,
pagination: PaginationArguments,
options: FetchKioskOptions,
@@ -91,7 +91,7 @@ const DEFAULT_PAGE_SIZE = 50;
const PERSON_KIOSK_CURSOR = 'personal';
const OWNED_KIOSKS_CURSOR = 'owned';
export async function getOwnedKiosks(
- client: SuiClient,
+ client: SuiJsonRpcClient,
address: string,
options?: {
pagination?: PaginationArguments;
@@ -234,7 +234,7 @@ function formatOwnedKioskResponse(
// Get a kiosk extension data for a given kioskId and extensionType.
export async function fetchKioskExtension(
- client: SuiClient,
+ client: SuiJsonRpcClient,
kioskId: string,
extensionType: string,
): Promise {
diff --git a/packages/kiosk/src/query/transfer-policy.ts b/packages/kiosk/src/query/transfer-policy.ts
index 7b3af43a4..76ceda08f 100644
--- a/packages/kiosk/src/query/transfer-policy.ts
+++ b/packages/kiosk/src/query/transfer-policy.ts
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { SuiClient } from '@mysten/sui/client';
+import type { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { fromBase64, isValidSuiAddress } from '@mysten/sui/utils';
import '../bcs.js';
@@ -25,7 +25,7 @@ import { getAllOwnedObjects, parseTransferPolicyCapObject } from '../utils.js';
* @param type
*/
export async function queryTransferPolicy(
- client: SuiClient,
+ client: SuiJsonRpcClient,
type: string,
): Promise {
// console.log('event type: %s', `${TRANSFER_POLICY_CREATED_EVENT}<${type}>`);
@@ -70,7 +70,7 @@ export async function queryTransferPolicy(
* @returns TransferPolicyCap Object ID | undefined if not found.
*/
export async function queryTransferPolicyCapsByType(
- client: SuiClient,
+ client: SuiJsonRpcClient,
address: string,
type: string,
): Promise {
@@ -104,7 +104,7 @@ export async function queryTransferPolicyCapsByType(
* @returns TransferPolicyCap Object ID | undefined if not found.
*/
export async function queryOwnedTransferPolicies(
- client: SuiClient,
+ client: SuiJsonRpcClient,
address: string,
): Promise {
if (!isValidSuiAddress(address)) return;
diff --git a/packages/kiosk/src/types/index.ts b/packages/kiosk/src/types/index.ts
index 246e21569..f8fae4c42 100644
--- a/packages/kiosk/src/types/index.ts
+++ b/packages/kiosk/src/types/index.ts
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { SuiClient } from '@mysten/sui/client';
+import type { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import type { TransactionObjectArgument } from '@mysten/sui/transactions';
import type { BaseRulePackageIds } from '../constants.js';
@@ -29,7 +29,7 @@ export enum Network {
* The Client Options for Both KioskClient & TransferPolicyManager.
*/
export type KioskClientOptions = {
- client: SuiClient;
+ client: SuiJsonRpcClient;
network: Network;
packageIds?: BaseRulePackageIds;
};
diff --git a/packages/kiosk/src/types/kiosk.ts b/packages/kiosk/src/types/kiosk.ts
index 7f60ec66b..70dc23012 100644
--- a/packages/kiosk/src/types/kiosk.ts
+++ b/packages/kiosk/src/types/kiosk.ts
@@ -5,7 +5,7 @@ import type {
PaginatedObjectsResponse,
SuiObjectData,
SuiObjectDataOptions,
-} from '@mysten/sui/client';
+} from '@mysten/sui/jsonRpc';
import type { TransactionArgument } from '@mysten/sui/transactions';
import type { ObjectArgument } from './index.js';
diff --git a/packages/kiosk/src/types/transfer-policy.ts b/packages/kiosk/src/types/transfer-policy.ts
index e94f98722..b728c7784 100644
--- a/packages/kiosk/src/types/transfer-policy.ts
+++ b/packages/kiosk/src/types/transfer-policy.ts
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { ObjectOwner } from '@mysten/sui/client';
+import type { ObjectOwner } from '@mysten/sui/jsonRpc';
import type { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
import type { KioskClient } from '../client/kiosk-client.js';
@@ -54,8 +54,6 @@ export type TransferPolicyCreated = {
// e.g. `if(!'my_key' in ruleParams!) throw new Error("Can't resolve that rule!")`
export type RuleResolvingParams = {
transaction: Transaction;
- /** @deprecated use transaction instead */
- transactionBlock: Transaction;
itemType: string;
itemId: string;
price: string;
diff --git a/packages/kiosk/src/utils.ts b/packages/kiosk/src/utils.ts
index 6262e7347..3687c49c3 100644
--- a/packages/kiosk/src/utils.ts
+++ b/packages/kiosk/src/utils.ts
@@ -4,12 +4,12 @@
import type {
DynamicFieldInfo,
PaginationArguments,
- SuiClient,
+ SuiJsonRpcClient,
SuiObjectData,
SuiObjectDataFilter,
SuiObjectDataOptions,
SuiObjectResponse,
-} from '@mysten/sui/client';
+} from '@mysten/sui/jsonRpc';
import {
fromBase64,
normalizeStructTag,
@@ -24,7 +24,7 @@ import { chunk } from '@mysten/utils';
const DEFAULT_QUERY_LIMIT = 50;
-export async function getKioskObject(client: SuiClient, id: string): Promise {
+export async function getKioskObject(client: SuiJsonRpcClient, id: string): Promise {
const queryRes = await client.getObject({ id, options: { showBcs: true } });
if (!queryRes || queryRes.error || !queryRes.data) {
@@ -159,7 +159,7 @@ export function attachLockedItems(kioskData: KioskData, lockedItemIds: string[])
* RPC calls that allow filtering of Type / batch fetching of spec
*/
export async function getAllDynamicFields(
- client: SuiClient,
+ client: SuiJsonRpcClient,
parentId: string,
pagination: PaginationArguments,
) {
@@ -187,7 +187,7 @@ export async function getAllDynamicFields(
* Requests are sent using `Promise.all`.
*/
export async function getAllObjects(
- client: SuiClient,
+ client: SuiJsonRpcClient,
ids: string[],
options: SuiObjectDataOptions,
limit: number = DEFAULT_QUERY_LIMIT,
@@ -217,7 +217,7 @@ export async function getAllOwnedObjects({
limit = DEFAULT_QUERY_LIMIT,
options = { showType: true, showContent: true },
}: {
- client: SuiClient;
+ client: SuiJsonRpcClient;
owner: string;
filter?: SuiObjectDataFilter;
options?: SuiObjectDataOptions;
diff --git a/packages/kiosk/test/e2e/setup.ts b/packages/kiosk/test/e2e/setup.ts
index 5c6600e2d..e0a1af083 100644
--- a/packages/kiosk/test/e2e/setup.ts
+++ b/packages/kiosk/test/e2e/setup.ts
@@ -6,8 +6,8 @@ import type {
DevInspectResults,
SuiObjectChangePublished,
SuiTransactionBlockResponse,
-} from '@mysten/sui/client';
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+} from '@mysten/sui/jsonRpc';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { FaucetRateLimitError, getFaucetHost, requestSuiFromFaucetV2 } from '@mysten/sui/faucet';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
import { Transaction } from '@mysten/sui/transactions';
@@ -20,14 +20,14 @@ import type { KioskClient } from '../../src/index.js';
import { KioskTransaction } from '../../src/index.js';
const DEFAULT_FAUCET_URL = process.env.FAUCET_URL ?? getFaucetHost('localnet');
-const DEFAULT_FULLNODE_URL = process.env.FULLNODE_URL ?? getFullnodeUrl('localnet');
+const DEFAULT_FULLNODE_URL = process.env.FULLNODE_URL ?? getJsonRpcFullnodeUrl('localnet');
export class TestToolbox {
keypair: Ed25519Keypair;
- client: SuiClient;
+ client: SuiJsonRpcClient;
configPath: string;
- constructor(keypair: Ed25519Keypair, client: SuiClient, configPath: string) {
+ constructor(keypair: Ed25519Keypair, client: SuiJsonRpcClient, configPath: string) {
this.keypair = keypair;
this.client = client;
this.configPath = configPath;
@@ -42,8 +42,8 @@ export class TestToolbox {
}
}
-export function getClient(): SuiClient {
- return new SuiClient({
+export function getClient(): SuiJsonRpcClient {
+ return new SuiJsonRpcClient({
url: DEFAULT_FULLNODE_URL,
});
}
diff --git a/packages/move-bytecode-template/tests/universal.test.ts b/packages/move-bytecode-template/tests/universal.test.ts
index c11d4c88e..5e5b7ba8a 100644
--- a/packages/move-bytecode-template/tests/universal.test.ts
+++ b/packages/move-bytecode-template/tests/universal.test.ts
@@ -67,14 +67,14 @@ describe('move-binary-template', () => {
expect(
template
.get_constants(updatedConsts)
- .find((c) => toHex(c.value_bcs) === bcs.string().serialize('TMPL').toHex()),
+ .find((c: { value_bcs: Uint8Array }) => toHex(c.value_bcs) === bcs.string().serialize('TMPL').toHex()),
).toBeFalsy();
- console.log(
- template
- .get_constants(updatedConsts)
- .find((c) => toHex(c.value_bcs) === bcs.string().serialize('MCN').toHex()),
- );
+ // console.log(
+ // template
+ // .get_constants(updatedConsts)
+ // .find((c) => toHex(c.value_bcs) === bcs.string().serialize('MCN').toHex()),
+ // );
});
it('should not update constants if there is an expected_value value miss-match', () => {
diff --git a/packages/payment-kit/.prettierignore b/packages/payment-kit/.prettierignore
new file mode 100644
index 000000000..a3414d0fd
--- /dev/null
+++ b/packages/payment-kit/.prettierignore
@@ -0,0 +1,2 @@
+dist
+CHANGELOG.md
diff --git a/packages/payment-kit/README.md b/packages/payment-kit/README.md
index 925a02d88..58a721d18 100644
--- a/packages/payment-kit/README.md
+++ b/packages/payment-kit/README.md
@@ -12,11 +12,11 @@ npm install --save @mysten/payment-kit @mysten/sui
## Setup
-In order to use the Payment Kit SDK you will first need to create an instance of SuiClient from the
-Typescript SDK, and a client instance of the Payment Kit SDK.
+In order to use the Payment Kit SDK you will first need to create an instance of SuiJsonRpcClient
+from the Typescript SDK, and a client instance of the Payment Kit SDK.
```ts
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { paymentKit } from '@mysten/payment-kit';
// Create a Sui client with a Payment Kit extension
diff --git a/packages/payment-kit/src/client.ts b/packages/payment-kit/src/client.ts
index 5edf25c33..579be29d3 100644
--- a/packages/payment-kit/src/client.ts
+++ b/packages/payment-kit/src/client.ts
@@ -14,7 +14,7 @@ import type {
GetPaymentRecordOptions,
GetPaymentRecordResponse,
} from './types.js';
-import type { ClientWithCoreApi } from '@mysten/sui/experimental';
+import type { ClientWithCoreApi } from '@mysten/sui/client';
import { normalizeStructTag } from '@mysten/sui/utils';
import { PaymentKitTransactions } from './transactions.js';
import { PaymentKitCalls } from './calls.js';
@@ -98,7 +98,7 @@ export class PaymentKitClient {
const decoded = PaymentRecord.parse(result.dynamicField.value.bcs);
return {
- key: result.dynamicField.id,
+ key: result.dynamicField.fieldId,
paymentTransactionDigest: result.dynamicField.previousTransaction,
epochAtTimeOfRecord: decoded.epoch_at_time_of_record,
};
diff --git a/packages/payment-kit/src/types.ts b/packages/payment-kit/src/types.ts
index f944accdf..b9c5943ce 100644
--- a/packages/payment-kit/src/types.ts
+++ b/packages/payment-kit/src/types.ts
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { ClientWithCoreApi } from '@mysten/sui/experimental';
+import type { ClientWithCoreApi } from '@mysten/sui/client';
export type PaymentKitPackageConfig = {
packageId: string;
diff --git a/packages/seal/src/client.ts b/packages/seal/src/client.ts
index 53a356fd1..d9445ef94 100644
--- a/packages/seal/src/client.ts
+++ b/packages/seal/src/client.ts
@@ -31,7 +31,6 @@ import type {
GetDerivedKeysOptions,
KeyCacheKey,
KeyServerConfig,
- SealClientExtensionOptions,
SealClientOptions,
SealCompatibleClient,
SealOptions,
@@ -87,19 +86,6 @@ export class SealClient {
this.#timeout = options.timeout ?? 10_000;
}
- /** @deprecated Use `seal()` instead */
- static asClientExtension(options: SealClientExtensionOptions) {
- return {
- name: 'seal' as const,
- register: (client: SealCompatibleClient) => {
- return new SealClient({
- suiClient: client,
- ...options,
- });
- },
- };
- }
-
/**
* Return an encrypted message under the identity.
*
diff --git a/packages/seal/src/index.ts b/packages/seal/src/index.ts
index 36c9ae91b..b0e1eb259 100644
--- a/packages/seal/src/index.ts
+++ b/packages/seal/src/index.ts
@@ -8,7 +8,6 @@ export * from './error.js';
export type {
SealCompatibleClient,
SealClientOptions,
- SealClientExtensionOptions,
KeyServerConfig,
EncryptOptions,
DecryptOptions,
diff --git a/packages/seal/src/key-server.ts b/packages/seal/src/key-server.ts
index c28909674..a753b657b 100644
--- a/packages/seal/src/key-server.ts
+++ b/packages/seal/src/key-server.ts
@@ -34,7 +34,7 @@ export const SERVER_VERSION_REQUIREMENT = new Version('0.4.1');
* from onchain state containing name, objectId, URL and pk.
*
* @param objectIds - The key server object IDs.
- * @param client - The SuiClient to use.
+ * @param client - The SuiJsonRpcClient to use.
* @returns - An array of SealKeyServer.
*/
export async function retrieveKeyServers({
@@ -49,8 +49,9 @@ export async function retrieveKeyServers({
// First get the KeyServer object and validate it.
const res = await client.core.getObject({
objectId,
+ include: { content: true },
});
- const ks = KeyServerMove.parse(await res.object.content);
+ const ks = KeyServerMove.parse(res.object.content);
if (
EXPECTED_SERVER_VERSION < Number(ks.firstVersion) ||
EXPECTED_SERVER_VERSION > Number(ks.lastVersion)
diff --git a/packages/seal/src/types.ts b/packages/seal/src/types.ts
index f566c3226..dbc9bf712 100644
--- a/packages/seal/src/types.ts
+++ b/packages/seal/src/types.ts
@@ -1,25 +1,15 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { ClientWithExtensions, Experimental_CoreClient } from '@mysten/sui/experimental';
+import type { ClientWithExtensions, CoreClient } from '@mysten/sui/client';
import type { DemType, KemType } from './encrypt.js';
import type { SessionKey } from './session-key.js';
export type KeyCacheKey = `${string}:${string}`;
export type SealCompatibleClient = ClientWithExtensions<{
- core: Experimental_CoreClient;
+ core: CoreClient;
}>;
-/** Configuration options for initializing a SealClient*/
-export interface SealClientExtensionOptions {
- /** Array of key server configs consisting of objectId, weight, optional API key name and API key */
- serverConfigs: KeyServerConfig[];
- /** Whether to verify the key servers' authenticity. */
- verifyKeyServers?: boolean;
- /** Timeout in milliseconds for network requests. */
- timeout?: number;
-}
-
export interface SealOptions {
/** Array of key server configs consisting of objectId, weight, optional API key name and API key */
serverConfigs: KeyServerConfig[];
@@ -38,8 +28,15 @@ export interface KeyServerConfig {
apiKey?: string;
}
-export interface SealClientOptions extends SealClientExtensionOptions {
+/** Configuration options for initializing a SealClient*/
+export interface SealClientOptions {
suiClient: SealCompatibleClient;
+ /** Array of key server configs consisting of objectId, weight, optional API key name and API key */
+ serverConfigs: KeyServerConfig[];
+ /** Whether to verify the key servers' authenticity. */
+ verifyKeyServers?: boolean;
+ /** Timeout in milliseconds for network requests. */
+ timeout?: number;
}
export interface EncryptOptions {
diff --git a/packages/seal/test/unit/integration.test.ts b/packages/seal/test/unit/integration.test.ts
index d55887e6b..b9af606b8 100644
--- a/packages/seal/test/unit/integration.test.ts
+++ b/packages/seal/test/unit/integration.test.ts
@@ -24,7 +24,7 @@ import { decrypt } from '../../src/decrypt';
import { KeyCacheKey, SealCompatibleClient } from '../../src/types';
import { G1Element } from '../../src/bls12381';
import { createFullId } from '../../src/utils';
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { seal } from '../../src/client';
/**
@@ -122,7 +122,7 @@ describe('Integration test', () => {
'suiprivkey1qqgzvw5zc2zmga0uyp4rzcgk42pzzw6387zqhahr82pp95yz0scscffh2d8',
);
suiAddress = keypair.getPublicKey().toSuiAddress();
- suiClient = new SuiClient({ url: getFullnodeUrl('testnet') });
+ suiClient = new SuiJsonRpcClient({ url: getJsonRpcFullnodeUrl('testnet'), network: 'testnet' });
TESTNET_PACKAGE_ID = '0x8afa5d31dbaa0a8fb07082692940ca3d56b5e856c5126cb5a3693f0a4de63b82';
// Object ids pointing to ci key servers' urls
serverObjectId = '0x3cf2a38f061ede3239c1629cb80a9be0e0676b1c15d34c94d104d4ba9d99076f';
diff --git a/packages/seal/test/unit/key-server.test.ts b/packages/seal/test/unit/key-server.test.ts
index 6f8e90019..4bc3f5c22 100644
--- a/packages/seal/test/unit/key-server.test.ts
+++ b/packages/seal/test/unit/key-server.test.ts
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { fromBase64 } from '@mysten/bcs';
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { bcs } from '@mysten/sui/bcs';
@@ -14,7 +14,7 @@ import {
} from '../../src/key-server.js';
import { Version } from '../../src/utils.js';
-// Data for mock response from SuiClient
+// Data for mock response from SuiJsonRpcClient
const pk = fromBase64(
'oEC1VIuwQo+6FZiVwHCAy/3HbvAbuIyiztXIWwd4LgmXCh9WhOKg3T0+Mb62y9fqAsSaN5SybG09n/3JnkmEzJgdDXLpM8KvMwkha/cBHp6Cx7aCdogvGLoOp/RadyHb',
);
@@ -49,13 +49,13 @@ describe('key-server tests', () => {
};
});
- // Mock SuiClient
+ // Mock SuiJsonRpcClient
const mockSuiClient = {
core: {
getObject: mockGetObject,
getDynamicField: vi.fn(),
},
- } as unknown as SuiClient;
+ } as unknown as SuiJsonRpcClient;
await expect(
retrieveKeyServers({
@@ -76,7 +76,7 @@ describe('key-server tests', () => {
// Mock fetch with exact response from the real service
const keyServers = await retrieveKeyServers({
objectIds: [id],
- client: new SuiClient({ url: getFullnodeUrl('testnet') }),
+ client: new SuiJsonRpcClient({ url: getJsonRpcFullnodeUrl('testnet'), network: 'testnet' }),
});
vi.clearAllMocks();
const headers = new Headers();
diff --git a/packages/seal/test/unit/session-key.test.ts b/packages/seal/test/unit/session-key.test.ts
index f11f467eb..4bfe6fd84 100644
--- a/packages/seal/test/unit/session-key.test.ts
+++ b/packages/seal/test/unit/session-key.test.ts
@@ -5,13 +5,16 @@ import { describe, expect, it } from 'vitest';
import { SessionKey } from '../../src/session-key';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
import { UserError } from '../../src/error';
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
describe('Session key tests', () => {
const TESTNET_PACKAGE_ID = '0x9709d4ee371488c2bc09f508e98e881bd1d5335e0805d7e6a99edd54a7027954';
it('import and export session key', async () => {
const kp = Ed25519Keypair.generate();
- const suiClient = new SuiClient({ url: getFullnodeUrl('testnet') });
+ const suiClient = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('testnet'),
+ network: 'testnet',
+ });
const sessionKey = await SessionKey.create({
address: kp.getPublicKey().toSuiAddress(),
packageId: TESTNET_PACKAGE_ID,
diff --git a/packages/signers/README.md b/packages/signers/README.md
index 1faa0ec1a..1806ab7f1 100644
--- a/packages/signers/README.md
+++ b/packages/signers/README.md
@@ -174,12 +174,15 @@ cryptographic operations.
import Transport from '@ledgerhq/hw-transport-node-hid';
import SuiLedgerClient from '@mysten/ledgerjs-hw-app-sui';
import { LedgerSigner } from '@mysten/signers/ledger';
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { Transaction } from '@mysten/sui/transactions';
const transport = await Transport.open(undefined);
const ledgerClient = new SuiLedgerClient(transport);
-const suiClient = new SuiClient({ url: getFullnodeUrl('testnet') });
+const suiClient = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('testnet'),
+ network: 'testnet',
+});
const signer = await LedgerSigner.fromDerivationPath(
"m/44'/784'/0'/0'/0'",
diff --git a/packages/signers/src/aws/aws-kms-signer.ts b/packages/signers/src/aws/aws-kms-signer.ts
index 513cadfa8..b6aec5592 100644
--- a/packages/signers/src/aws/aws-kms-signer.ts
+++ b/packages/signers/src/aws/aws-kms-signer.ts
@@ -83,15 +83,6 @@ export class AwsKmsSigner extends Signer {
return getConcatenatedSignature(fromBase64(signResponse.Signature), this.getKeyScheme());
}
- /**
- * Synchronous signing is not supported by AWS KMS.
- * @throws Always throws an error indicating synchronous signing is unsupported.
- * @deprecated use `sign` instead
- */
- signData(): never {
- throw new Error('KMS Signer does not support sync signing');
- }
-
/**
* Prepares the signer by fetching and setting the public key from AWS KMS.
* It is recommended to initialize an `AwsKmsSigner` instance using this function.
diff --git a/packages/signers/src/gcp/gcp-kms-client.ts b/packages/signers/src/gcp/gcp-kms-client.ts
index 1fd204b01..9b51e5efa 100644
--- a/packages/signers/src/gcp/gcp-kms-client.ts
+++ b/packages/signers/src/gcp/gcp-kms-client.ts
@@ -86,15 +86,6 @@ export class GcpKmsSigner extends Signer {
return getConcatenatedSignature(signResponse.signature as Uint8Array, this.getKeyScheme());
}
- /**
- * Synchronous signing is not supported by GCP KMS.
- * @throws Always throws an error indicating synchronous signing is unsupported.
- * @deprecated use `sign` instead
- */
- signData(): never {
- throw new Error('GCP Signer does not support sync signing');
- }
-
/**
* Creates a GCP KMS signer from the provided options.
* Expects the credentials file to be set as an env variable
diff --git a/packages/signers/src/ledger/bcs.ts b/packages/signers/src/ledger/bcs.ts
index 4c2afc9ac..0056811cb 100644
--- a/packages/signers/src/ledger/bcs.ts
+++ b/packages/signers/src/ledger/bcs.ts
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { bcs, TypeTagSerializer } from '@mysten/sui/bcs';
-import type { ObjectOwner } from '@mysten/sui/client';
+import type { ObjectOwner } from '@mysten/sui/jsonRpc';
import {
fromBase64,
normalizeStructTag,
diff --git a/packages/signers/src/ledger/index.ts b/packages/signers/src/ledger/index.ts
index 5d4c7d4f1..a38c13999 100644
--- a/packages/signers/src/ledger/index.ts
+++ b/packages/signers/src/ledger/index.ts
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type SuiLedgerClient from '@mysten/ledgerjs-hw-app-sui';
-import type { SuiClient } from '@mysten/sui/client';
+import type { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import type { SignatureWithBytes } from '@mysten/sui/cryptography';
import { messageWithIntent, Signer, toSerializedSignature } from '@mysten/sui/cryptography';
import { Ed25519PublicKey } from '@mysten/sui/keypairs/ed25519';
@@ -22,7 +22,7 @@ export interface LedgerSignerOptions {
publicKey: Ed25519PublicKey;
derivationPath: string;
ledgerClient: SuiLedgerClient;
- suiClient: SuiClient;
+ suiClient: SuiJsonRpcClient;
}
/**
@@ -32,7 +32,7 @@ export class LedgerSigner extends Signer {
#derivationPath: string;
#publicKey: Ed25519PublicKey;
#ledgerClient: SuiLedgerClient;
- #suiClient: SuiClient;
+ #suiClient: SuiJsonRpcClient;
/**
* Creates an instance of LedgerSigner. It's expected to call the static `fromDerivationPath` method to create an instance.
@@ -126,7 +126,7 @@ export class LedgerSigner extends Signer {
static async fromDerivationPath(
derivationPath: string,
ledgerClient: SuiLedgerClient,
- suiClient: SuiClient,
+ suiClient: SuiJsonRpcClient,
) {
const { publicKey } = await ledgerClient.getPublicKey(derivationPath);
if (!publicKey) {
diff --git a/packages/signers/src/ledger/objects.ts b/packages/signers/src/ledger/objects.ts
index 829c30d2d..9d9e5bd05 100644
--- a/packages/signers/src/ledger/objects.ts
+++ b/packages/signers/src/ledger/objects.ts
@@ -2,10 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
import type { Transaction } from '@mysten/sui/transactions';
-import type { SuiClient } from '@mysten/sui/client';
+import type { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { SuiMoveObject } from './bcs.js';
-export const getInputObjects = async (transaction: Transaction, client: SuiClient) => {
+export const getInputObjects = async (transaction: Transaction, client: SuiJsonRpcClient) => {
const data = transaction.getData();
const gasObjectIds = data.gasData.payment?.map((object) => object.objectId) ?? [];
diff --git a/packages/suins-v2/src/client.ts b/packages/suins-v2/src/client.ts
index 304d11b04..509a48e5d 100644
--- a/packages/suins-v2/src/client.ts
+++ b/packages/suins-v2/src/client.ts
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { ClientWithCoreApi, SuiClientRegistration } from '@mysten/sui/src/experimental';
+import type { ClientWithCoreApi, SuiClientRegistration } from '@mysten/sui/client';
import { SuiNsCalls } from './calls.js';
import type { SuiNsObjectIds, SuiNsPackageIds } from './calls.js';
@@ -37,7 +37,7 @@ export class SuiNsClient {
this.#client = options.client;
if (this.#client.network !== 'mainnet' && this.#client.network !== 'testnet') {
if (this.#client.network === 'unknown') {
- throw new Error('network must be defined on SuiClient');
+ throw new Error('network must be defined on SuiJsonRpcClient');
}
throw new Error('SuiNsClient only supports mainnet and testnet');
}
diff --git a/packages/suins/examples/example.ts b/packages/suins/examples/example.ts
index d206141c7..1caa6e8df 100644
--- a/packages/suins/examples/example.ts
+++ b/packages/suins/examples/example.ts
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { Transaction } from '@mysten/sui/transactions';
import { SuinsClient } from '../src/suins-client.js';
@@ -10,9 +10,9 @@ import { SuinsTransaction } from '../src/suins-transaction.js';
// Initialize and execute the SuinsClient to fetch the renewal price list
(async () => {
const network = 'testnet';
- // Step 1: Create a SuiClient instance
- const suiClient = new SuiClient({
- url: getFullnodeUrl(network), // Sui testnet endpoint
+ // Step 1: Create a SuiJsonRpcClient instance
+ const suiClient = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl(network), // Sui testnet endpoint
});
// Step 2: Create a SuinsClient instance using TESTNET_CONFIG
diff --git a/packages/suins/src/pyth/pyth.ts b/packages/suins/src/pyth/pyth.ts
index 37a3c84bf..b40a59823 100644
--- a/packages/suins/src/pyth/pyth.ts
+++ b/packages/suins/src/pyth/pyth.ts
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { bcs } from '@mysten/sui/bcs';
-import type { SuiClient } from '@mysten/sui/client';
+import type { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import type { Transaction } from '@mysten/sui/transactions';
import { coinWithBalance } from '@mysten/sui/transactions';
import { fromBase64, fromHex, parseStructTag } from '@mysten/sui/utils';
@@ -31,11 +31,11 @@ export class SuiPythClient {
#priceFeedObjectIdCache: Map> = new Map();
#priceTableInfo?: Promise<{ id: ObjectId; fieldType: ObjectId }>;
#baseUpdateFee?: Promise;
- provider: SuiClient;
+ provider: SuiJsonRpcClient;
pythStateId: ObjectId;
wormholeStateId: ObjectId;
- constructor(provider: SuiClient, pythStateId: ObjectId, wormholeStateId: ObjectId) {
+ constructor(provider: SuiJsonRpcClient, pythStateId: ObjectId, wormholeStateId: ObjectId) {
this.provider = provider;
this.pythStateId = pythStateId;
this.wormholeStateId = wormholeStateId;
diff --git a/packages/suins/src/suins-client.ts b/packages/suins/src/suins-client.ts
index 93f8e42f3..2aee9f9c1 100644
--- a/packages/suins/src/suins-client.ts
+++ b/packages/suins/src/suins-client.ts
@@ -1,6 +1,6 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { SuiClient } from '@mysten/sui/client';
+import type { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import type { Transaction } from '@mysten/sui/transactions';
import { isValidSuiNSName, normalizeSuiNSName } from '@mysten/sui/utils';
@@ -27,7 +27,7 @@ import type {
/// The SuinsClient is the main entry point for the Suins SDK.
/// It allows you to interact with SuiNS.
export class SuinsClient {
- client: SuiClient;
+ client: SuiJsonRpcClient;
network: Network;
config: PackageInfo;
diff --git a/packages/suins/src/types.ts b/packages/suins/src/types.ts
index ee2eba87d..14bbbff23 100644
--- a/packages/suins/src/types.ts
+++ b/packages/suins/src/types.ts
@@ -1,6 +1,6 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { SuiClient } from '@mysten/sui/client';
+import type { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import type { TransactionObjectArgument, TransactionObjectInput } from '@mysten/sui/transactions';
// Interfaces
@@ -101,7 +101,7 @@ export type ReceiptParams = {
};
export type SuinsClientConfig = {
- client: SuiClient;
+ client: SuiJsonRpcClient;
network?: Network;
config?: Config;
};
diff --git a/packages/suins/test/pre-built.ts b/packages/suins/test/pre-built.ts
index 1cac6d3e1..299ccee86 100644
--- a/packages/suins/test/pre-built.ts
+++ b/packages/suins/test/pre-built.ts
@@ -1,6 +1,6 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { Transaction } from '@mysten/sui/transactions';
import { MIST_PER_SUI, normalizeSuiAddress } from '@mysten/sui/utils';
import { expect } from 'vitest';
@@ -8,7 +8,7 @@ import { expect } from 'vitest';
import { ALLOWED_METADATA, SuinsClient, SuinsTransaction } from '../src/index.js';
export const e2eLiveNetworkDryRunFlow = async (network: 'mainnet' | 'testnet') => {
- const client = new SuiClient({ url: getFullnodeUrl(network) });
+ const client = new SuiJsonRpcClient({ url: getJsonRpcFullnodeUrl(network), network });
const sender = normalizeSuiAddress('0x2');
const suinsClient = new SuinsClient({
diff --git a/packages/suins/test/toolbox.ts b/packages/suins/test/toolbox.ts
index 00d0d9049..b74d7fb52 100644
--- a/packages/suins/test/toolbox.ts
+++ b/packages/suins/test/toolbox.ts
@@ -4,7 +4,7 @@ import { execSync } from 'child_process';
import { mkdtemp } from 'fs/promises';
import { tmpdir } from 'os';
import path from 'path';
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { FaucetRateLimitError, getFaucetHost, requestSuiFromFaucetV2 } from '@mysten/sui/faucet';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
import { retry } from 'ts-retry-promise';
@@ -15,14 +15,14 @@ export const SUI_BIN = process.env.VITE_SUI_BIN ?? `sui`;
//@ts-ignore-next-line
const DEFAULT_FAUCET_URL = process.env.VITE_FAUCET_URL ?? getFaucetHost('localnet');
//@ts-ignore-next-line
-const DEFAULT_FULLNODE_URL = process.env.VITE_FULLNODE_URL ?? getFullnodeUrl('localnet');
+const DEFAULT_FULLNODE_URL = process.env.VITE_FULLNODE_URL ?? getJsonRpcFullnodeUrl('localnet');
export class TestToolbox {
keypair: Ed25519Keypair;
- client: SuiClient;
+ client: SuiJsonRpcClient;
configPath: string;
- constructor(keypair: Ed25519Keypair, client: SuiClient, configPath: string) {
+ constructor(keypair: Ed25519Keypair, client: SuiJsonRpcClient, configPath: string) {
this.keypair = keypair;
this.client = client;
this.configPath = configPath;
@@ -37,8 +37,9 @@ export class TestToolbox {
}
}
-export function getClient(): SuiClient {
- return new SuiClient({
+export function getClient(): SuiJsonRpcClient {
+ return new SuiJsonRpcClient({
+ network: 'localnet',
url: DEFAULT_FULLNODE_URL,
});
}
diff --git a/packages/typescript/README.md b/packages/typescript/README.md
index 1a588c8dc..98d0cf0aa 100644
--- a/packages/typescript/README.md
+++ b/packages/typescript/README.md
@@ -73,17 +73,17 @@ VITE_FAUCET_URL='https://faucet.devnet.sui.io:443/v2/gas' VITE_FULLNODE_URL='htt
## Connecting to Sui Network
-The `SuiClient` class provides a connection to the JSON-RPC Server and should be used for all
+The `SuiJsonRpcClient` class provides a connection to the JSON-RPC Server and should be used for all
read-only operations. The default URLs to connect with the RPC server are:
- local: http://127.0.0.1:9000
- Devnet: https://fullnode.devnet.sui.io
```typescript
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
// create a client connected to devnet
-const client = new SuiClient({ url: getFullnodeUrl('devnet') });
+const client = new SuiJsonRpcClient({ url: getJsonRpcFullnodeUrl('devnet'), network: 'devnet' });
// get coins owned by an address
await client.getCoins({
@@ -96,10 +96,13 @@ local network with a local validator, a fullnode, and a faucet server. Refer to
[this guide](https://docs.sui.io/build/sui-local-network) for more information.
```typescript
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
// create a client connected to devnet
-const client = new SuiClient({ url: getFullnodeUrl('localnet') });
+const client = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('localnet'),
+ network: 'localnet',
+});
// get coins owned by an address
await client.getCoins({
@@ -107,13 +110,13 @@ await client.getCoins({
});
```
-You can also construct your own in custom connections, with the URL for your own fullnode
+You can also construct your own SuiJsonRpcClient connections, with the URL for your own fullnode
```typescript
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcSuiJsonRpcClientrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
// create a client connected to devnet
-const client = new SuiClient({
+const client = new SuiJsonRpcClient({
url: 'https://fullnode.devnet.sui.io',
});
@@ -142,17 +145,17 @@ await requestSuiFromFaucetV2({
For a primer for building transactions, refer to
[this guide](https://docs.sui.io/build/prog-trans-ts-sdk).
-### Transfer Object
+### Transfer ObjectSuiJsonRpcClient
```typescript
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
import { Transaction } from '@mysten/sui/transactions';
-
+SuiJsonRpcClient;
// Generate a new Ed25519 Keypair
const keypair = new Ed25519Keypair();
-const client = new SuiClient({
- url: getFullnodeUrl('testnet'),
+const client = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('testnet'),
});
const tx = new Transaction();
@@ -169,17 +172,17 @@ console.log({ result });
### Transfer Sui
-To transfer `1000` MIST to another address:
+To transfer `1000` MIST to anothSuiJsonRpcClients:
```typescript
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
import { Transaction } from '@mysten/sui/transactions';
-
+SuiJsonRpcClient;
// Generate a new Ed25519 Keypair
const keypair = new Ed25519Keypair();
-const client = new SuiClient({
- url: getFullnodeUrl('testnet'),
+const client = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('testnet'),
});
const tx = new Transaction();
@@ -192,17 +195,17 @@ const result = await client.signAndExecuteTransaction({
console.log({ result });
```
-### Merge coins
+### Merge coinsSuiJsonRpcClient
```typescript
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
import { Transaction } from '@mysten/sui/transactions';
-
+SuiJsonRpcClient;
// Generate a new Ed25519 Keypair
const keypair = new Ed25519Keypair();
-const client = new SuiClient({
- url: getFullnodeUrl('testnet'),
+const client = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('testnet'),
});
const tx = new Transaction();
@@ -216,17 +219,17 @@ const result = await client.signAndExecuteTransaction({
console.log({ result });
```
-### Move Call
+### Move CallSuiJsonRpcClient
```typescript
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
import { Transaction } from '@mysten/sui/transactions';
-
+SuiJsonRpcClient;
// Generate a new Ed25519 Keypair
const keypair = new Ed25519Keypair();
-const client = new SuiClient({
- url: getFullnodeUrl('testnet'),
+const client = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('testnet'),
});
const packageObjectId = '0x...';
const tx = new Transaction();
@@ -243,18 +246,18 @@ console.log({ result });
### Publish Modules
-To publish a package:
+To publish a package:SuiJsonRpcClient
```typescript
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
import { Transaction } from '@mysten/sui/transactions';
-const { execSync } = require('child_process');
+const { execSync } SuiJsonRpcClient('child_process');
// Generate a new Ed25519 Keypair
const keypair = new Ed25519Keypair();
-const client = new SuiClient({
- url: getFullnodeUrl('testnet'),
+const client = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('testnet'),
});
const { modules, dependencies } = JSON.parse(
execSync(`${cliPath} move build --dump-bytecode-as-base64 --path ${packagePath}`, {
@@ -279,13 +282,13 @@ console.log({ result });
### Get Owned Objects
Fetch objects owned by the address
-`0xcc2bd176a478baea9a0de7a24cd927661cc6e860d5bacecb9a138ef20dbab231`
+`0xcc2bd176a478baea9a0de7a24cd92SuiJsonRpcClient60d5bacecb9a138ef20dbab231`
-```typescript
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+```typescriptSuiJsonRpcClient
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
-const client = new SuiClient({
- url: getFullnodeUrl('testnet'),
+const client = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('testnet'),
});
const objects = await client.getOwnedObjects({
owner: '0xcc2bd176a478baea9a0de7a24cd927661cc6e860d5bacecb9a138ef20dbab231',
@@ -295,13 +298,13 @@ const objects = await client.getOwnedObjects({
### Get Object
Fetch object details for the object with id
-`0xe19739da1a701eadc21683c5b127e62b553e833e8a15a4f292f4f48b4afea3f2`
+`0xe19739da1a701eadc21683c5b127eSuiJsonRpcClient3e8a15a4f292f4f48b4afea3f2`
-```typescript
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+```typescriptSuiJsonRpcClient
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
-const client = new SuiClient({
- url: getFullnodeUrl('testnet'),
+const client = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('testnet'),
});
const txn = await client.getObject({
id: '0xcc2bd176a478baea9a0de7a24cd927661cc6e860d5bacecb9a138ef20dbab231',
@@ -321,13 +324,13 @@ const txns = await client.multiGetObjects({
### Get Transaction
-Fetch transaction details from transaction digests:
+Fetch transaction details from tSuiJsonRpcClientn digests:
-```typescript
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+```typescriptSuiJsonRpcClient
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
-const client = new SuiClient({
- url: getFullnodeUrl('testnet'),
+const client = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('testnet'),
});
const txn = await client.getTransactionBlock({
digest: '9XFneskU8tW7UxQf7tE5qFRfcN4FadtC2Z3HAZkgeETd=',
@@ -389,13 +392,13 @@ client.getCheckpoint({ id: '1994010' }).then(function (checkpoint: Checkpoint) {
### Get Coins
Fetch coins of type `0x65b0553a591d7b13376e03a408e112c706dc0909a79080c810b93b06f922c458::usdc::USDC`
-owned by an address:
+owned by an address:SuiJsonRpcClient
-```typescript
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+```typescriptSuiJsonRpcClient
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
-const client = new SuiClient({
- url: getFullnodeUrl('testnet'),
+const client = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('testnet'),
});
const coins = await client.getCoins({
owner: '0xcc2bd176a478baea9a0de7a24cd927661cc6e860d5bacecb9a138ef20dbab231',
@@ -403,26 +406,26 @@ const coins = await client.getCoins({
});
```
-Fetch all coin objects owned by an address:
+Fetch all coin objects owned by SuiJsonRpcClients:
-```typescript
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+```typescriptSuiJsonRpcClient
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
-const client = new SuiClient({
- url: getFullnodeUrl('testnet'),
+const client = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('testnet'),
});
const allCoins = await client.getAllCoins({
owner: '0xcc2bd176a478baea9a0de7a24cd927661cc6e860d5bacecb9a138ef20dbab231',
});
```
-Fetch the total coin balance for one coin type, owned by an address:
+Fetch the total coin balance forSuiJsonRpcClient type, owned by an address:
-```typescript
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+```typescriptSuiJsonRpcClient
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
-const client = new SuiClient({
- url: getFullnodeUrl('testnet'),
+const client = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('testnet'),
});
// If coin type is not specified, it defaults to 0x2::sui::SUI
const coinBalance = await client.getBalance({
@@ -434,13 +437,13 @@ const coinBalance = await client.getBalance({
### Events API
Querying events created by transactions sent by account
-`0xcc2bd176a478baea9a0de7a24cd927661cc6e860d5bacecb9a138ef20dbab231`
+`0xcc2bd176a478baea9a0de7a24cd92SuiJsonRpcClient60d5bacecb9a138ef20dbab231`
-```typescript
-import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
+```typescriptSuiJsonRpcClient
+import { getJsonRpcFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
-const client = new SuiClient({
- url: getFullnodeUrl('testnet'),
+const client = new SuiJsonRpcClient({
+ url: getJsonRpcFullnodeUrl('testnet'),
});
const events = client.queryEvents({
query: { Sender: toolbox.address() },
diff --git a/packages/typescript/experimental/package.json b/packages/typescript/experimental/package.json
deleted file mode 100644
index c9e9c8ff6..000000000
--- a/packages/typescript/experimental/package.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "private": true,
- "import": "../dist/esm/experimental/index.js",
- "main": "../dist/cjs/experimental/index.js",
- "sideEffects": false
-}
diff --git a/packages/typescript/graphql/schema/package.json b/packages/typescript/graphql/schema/package.json
new file mode 100644
index 000000000..79254ab66
--- /dev/null
+++ b/packages/typescript/graphql/schema/package.json
@@ -0,0 +1,6 @@
+{
+ "private": true,
+ "import": "../../dist/esm/graphql/schema/index.js",
+ "main": "../../dist/cjs/graphql/schema/index.js",
+ "sideEffects": false
+}
diff --git a/packages/typescript/graphql/schemas/2024.1/package.json b/packages/typescript/graphql/schemas/2024.1/package.json
deleted file mode 100644
index 0fce1026a..000000000
--- a/packages/typescript/graphql/schemas/2024.1/package.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "private": true,
- "import": "../../../dist/esm/graphql/schemas/2024.1/index.js",
- "main": "../../../dist/cjs/graphql/schemas/2024.1/index.js",
- "sideEffects": false
-}
diff --git a/packages/typescript/graphql/schemas/2024.4/package.json b/packages/typescript/graphql/schemas/2024.4/package.json
deleted file mode 100644
index d719c7c9d..000000000
--- a/packages/typescript/graphql/schemas/2024.4/package.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "private": true,
- "import": "../../../dist/esm/graphql/schemas/2024.4/index.js",
- "main": "../../../dist/cjs/graphql/schemas/2024.4/index.js",
- "sideEffects": false
-}
diff --git a/packages/typescript/graphql/schemas/latest/package.json b/packages/typescript/graphql/schemas/latest/package.json
deleted file mode 100644
index afe903edf..000000000
--- a/packages/typescript/graphql/schemas/latest/package.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "private": true,
- "import": "../../../dist/esm/graphql/schemas/latest/index.js",
- "main": "../../../dist/cjs/graphql/schemas/latest/index.js",
- "sideEffects": false
-}
diff --git a/packages/typescript/package.json b/packages/typescript/package.json
index 7d10db4c1..5d46df372 100644
--- a/packages/typescript/package.json
+++ b/packages/typescript/package.json
@@ -45,10 +45,6 @@
"import": "./dist/esm/cryptography/index.js",
"require": "./dist/cjs/cryptography/index.js"
},
- "./experimental": {
- "import": "./dist/esm/experimental/index.js",
- "require": "./dist/cjs/experimental/index.js"
- },
"./faucet": {
"import": "./dist/esm/faucet/index.js",
"require": "./dist/cjs/faucet/index.js"
@@ -101,17 +97,9 @@
"import": "./dist/esm/zklogin/index.js",
"require": "./dist/cjs/zklogin/index.js"
},
- "./graphql/schemas/2024.1": {
- "import": "./dist/esm/graphql/schemas/2024.1/index.js",
- "require": "./dist/cjs/graphql/schemas/2024.1/index.js"
- },
- "./graphql/schemas/2024.4": {
- "import": "./dist/esm/graphql/schemas/2024.4/index.js",
- "require": "./dist/cjs/graphql/schemas/2024.4/index.js"
- },
- "./graphql/schemas/latest": {
- "import": "./dist/esm/graphql/schemas/latest/index.js",
- "require": "./dist/cjs/graphql/schemas/latest/index.js"
+ "./graphql/schema": {
+ "import": "./dist/esm/graphql/schema/index.js",
+ "require": "./dist/cjs/graphql/schema/index.js"
}
},
"scripts": {
@@ -137,8 +125,7 @@
"eslint:fix": "pnpm run eslint:check --fix",
"lint": "pnpm run eslint:check && pnpm run prettier:check",
"lint:fix": "pnpm run eslint:fix && pnpm run prettier:fix",
- "update-schemas": "pnpm tsx scripts/update-graphql-schemas.ts",
- "generate-schema": "gql.tada generate-output"
+ "update-graphql-schema": "pnpm tsx scripts/update-graphql-schema.ts"
},
"bugs": {
"url": "https://github.com/MystenLabs/ts-sdks/issues/new"
diff --git a/packages/typescript/scripts/update-graphql-schema.ts b/packages/typescript/scripts/update-graphql-schema.ts
new file mode 100644
index 000000000..f4d4124eb
--- /dev/null
+++ b/packages/typescript/scripts/update-graphql-schema.ts
@@ -0,0 +1,84 @@
+// Copyright (c) Mysten Labs, Inc.
+// SPDX-License-Identifier: Apache-2.0
+
+import { execSync } from 'child_process';
+import { readFile } from 'fs/promises';
+import { mkdir, writeFile } from 'node:fs/promises';
+import { resolve } from 'node:path';
+
+await addSchema(
+ 'https://raw.githubusercontent.com/MystenLabs/sui/refs/heads/main/crates/sui-indexer-alt-graphql/schema.graphql',
+);
+
+await addExportsToPackageJson();
+
+async function addExportsToPackageJson() {
+ const packageJsonPath = resolve(import.meta.url.slice(5), '../../package.json');
+ const packageJson = JSON.parse(await readFile(packageJsonPath, 'utf-8'));
+
+ packageJson.exports[`./graphql/schema`] = {
+ import: `./dist/esm/graphql/schema/index.js`,
+ require: `./dist/cjs/graphql/schema/index.js`,
+ };
+
+ await writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, '\t')}\n`);
+}
+
+async function addSchema(schema: string) {
+ const res = await fetch(schema);
+
+ if (!res.ok) {
+ throw new Error(`Failed to fetch schema from ${schema}`);
+ }
+ const schemaContent = await res.text();
+
+ const filePath = resolve(import.meta.url.slice(5), `../../src/graphql/generated/schema.graphql`);
+
+ await mkdir(resolve(filePath, '..'), { recursive: true });
+ await writeFile(filePath, schemaContent);
+
+ await writeFile(
+ resolve(filePath, '..', 'tsconfig.tada.json'),
+ `
+{
+ "compilerOptions": {
+ "plugins": [
+ {
+ "name": "@0no-co/graphqlsp",
+ "schema": "./schema.graphql",
+ "tadaOutputLocation": "src/graphql/generated/tada-env.ts"
+ }
+ ]
+ }
+}
+`.trimStart(),
+ );
+
+ execSync(`pnpm gql.tada generate-output -c ${resolve(filePath, '..', 'tsconfig.tada.json')}`, {
+ stdio: 'inherit',
+ });
+
+ await mkdir(resolve(filePath, '../../../schemas'), { recursive: true });
+ await writeFile(
+ resolve(filePath, `../../schema/index.ts`),
+ `
+// Copyright (c) Mysten Labs, Inc.
+// SPDX-License-Identifier: Apache-2.0
+
+import { initGraphQLTada } from 'gql.tada';
+
+import type { introspection } from '../generated/tada-env.js';
+import type { CustomScalars } from '../types.js';
+
+export type * from '../types.js';
+
+export type { FragmentOf, ResultOf, VariablesOf, TadaDocumentNode } from 'gql.tada';
+export { readFragment, maskFragments } from 'gql.tada';
+
+export const graphql = initGraphQLTada<{
+ introspection: typeof introspection;
+ scalars: CustomScalars;
+}>();
+`.trimStart(),
+ );
+}
diff --git a/packages/typescript/scripts/update-graphql-schemas.ts b/packages/typescript/scripts/update-graphql-schemas.ts
deleted file mode 100644
index a2b7b2f6c..000000000
--- a/packages/typescript/scripts/update-graphql-schemas.ts
+++ /dev/null
@@ -1,132 +0,0 @@
-// Copyright (c) Mysten Labs, Inc.
-// SPDX-License-Identifier: Apache-2.0
-
-import { execSync } from 'child_process';
-import { readFile } from 'fs/promises';
-import { mkdir, writeFile } from 'node:fs/promises';
-import { resolve } from 'node:path';
-
-const result = execSync(`git ls-remote -h git@github.com:MystenLabs/sui.git`)
- .toString()
- .trim()
- .split('\n')
- .map((ref) => {
- const branch = ref.trim().split('refs/heads/')[1];
- const match = branch?.match(/^releases\/sui-graphql-rpc-v([\d.]+)-release$/);
-
- if (!match) {
- return null;
- }
-
- const version = match[1];
- const [major, minor, patch] = version ? version.split('.') : [0, 0, 0];
-
- return match
- ? {
- version: match[1],
- minorVersion: `${major}.${minor}`,
- major,
- minor,
- patch,
- branch,
- schema: `https://raw.githubusercontent.com/MystenLabs/sui/${branch}/crates/sui-graphql-rpc/schema/current_progress_schema.graphql`,
- }
- : null;
- })
- .filter((x): x is NonNullable => x !== null);
-
-const releasesByVersion = new Map();
-for (const release of result) {
- const { minorVersion } = release;
- const existing = releasesByVersion.get(minorVersion);
- if (!existing || existing.patch < release.patch) {
- releasesByVersion.set(minorVersion, release);
- }
-}
-
-for (const { minorVersion, schema } of releasesByVersion.values()) {
- await addSchemaVersion(minorVersion, schema);
-}
-
-await addSchemaVersion(
- 'latest',
- 'https://raw.githubusercontent.com/MystenLabs/sui/refs/heads/main/crates/sui-indexer-alt-graphql/schema.graphql',
-);
-
-await addExportsToPackageJson([...releasesByVersion.keys(), 'latest']);
-
-async function addExportsToPackageJson(versions: string[]) {
- const packageJsonPath = resolve(import.meta.url.slice(5), '../../package.json');
- const packageJson = JSON.parse(await readFile(packageJsonPath, 'utf-8'));
-
- for (const version of versions) {
- packageJson.exports[`./graphql/schemas/${version}`] = {
- import: `./dist/esm/graphql/schemas/${version}/index.js`,
- require: `./dist/cjs/graphql/schemas/${version}/index.js`,
- };
- }
-
- await writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, '\t')}\n`);
-}
-
-async function addSchemaVersion(versionName: string, schema: string) {
- const res = await fetch(schema);
-
- if (!res.ok) {
- throw new Error(`Failed to fetch schema from ${schema}`);
- }
- const schemaContent = await res.text();
-
- const filePath = resolve(
- import.meta.url.slice(5),
- `../../src/graphql/generated/${versionName}/schema.graphql`,
- );
-
- await mkdir(resolve(filePath, '..'), { recursive: true });
- await writeFile(filePath, schemaContent);
-
- await writeFile(
- resolve(filePath, '..', 'tsconfig.tada.json'),
- `
-{
- "compilerOptions": {
- "plugins": [
- {
- "name": "@0no-co/graphqlsp",
- "schema": "./schema.graphql",
- "tadaOutputLocation": "src/graphql/generated/${versionName}/tada-env.ts"
- }
- ]
- }
-}
-`.trimStart(),
- );
-
- execSync(`pnpm run generate-schema -c ${resolve(filePath, '..', 'tsconfig.tada.json')}`, {
- stdio: 'inherit',
- });
-
- await mkdir(resolve(filePath, '../../../schemas', versionName), { recursive: true });
- await writeFile(
- resolve(filePath, `../../../schemas/${versionName}/index.ts`),
- `
-// Copyright (c) Mysten Labs, Inc.
-// SPDX-License-Identifier: Apache-2.0
-
-import { initGraphQLTada } from 'gql.tada';
-
-import type { introspection } from '../../generated/${versionName}/tada-env.js';
-import type { CustomScalars } from '../../types.js';
-
-export type * from '../../types.js';
-
-export type { FragmentOf, ResultOf, VariablesOf, TadaDocumentNode } from 'gql.tada';
-export { readFragment, maskFragments } from 'gql.tada';
-
-export const graphql = initGraphQLTada<{
- introspection: typeof introspection;
- scalars: CustomScalars;
-}>();
-`.trimStart(),
- );
-}
diff --git a/packages/typescript/src/experimental/cache.ts b/packages/typescript/src/client/cache.ts
similarity index 100%
rename from packages/typescript/src/experimental/cache.ts
rename to packages/typescript/src/client/cache.ts
diff --git a/packages/typescript/src/experimental/client.ts b/packages/typescript/src/client/client.ts
similarity index 73%
rename from packages/typescript/src/experimental/client.ts
rename to packages/typescript/src/client/client.ts
index 28ded47d0..490767849 100644
--- a/packages/typescript/src/experimental/client.ts
+++ b/packages/typescript/src/client/client.ts
@@ -4,29 +4,25 @@
import type { Simplify, UnionToIntersection } from '@mysten/utils';
import { ClientCache } from './cache.js';
-import type { Experimental_CoreClient } from './core.js';
-import type {
- ClientWithExtensions,
- Experimental_SuiClientTypes,
- SuiClientRegistration,
-} from './types.js';
+import type { CoreClient } from './core.js';
+import type { ClientWithExtensions, SuiClientTypes, SuiClientRegistration } from './types.js';
-export abstract class Experimental_BaseClient {
- network: Experimental_SuiClientTypes.Network;
+export abstract class BaseClient {
+ network: SuiClientTypes.Network;
cache: ClientCache;
- base: Experimental_BaseClient;
+ base: BaseClient;
constructor({
network,
base,
cache = base?.cache ?? new ClientCache(),
- }: Experimental_SuiClientTypes.SuiClientOptions) {
+ }: SuiClientTypes.SuiClientOptions) {
this.network = network;
this.base = base ?? this;
this.cache = cache;
}
- abstract core: Experimental_CoreClient;
+ abstract core: CoreClient;
$extend[]>(
...registrations: Registrations
diff --git a/packages/typescript/src/experimental/core.ts b/packages/typescript/src/client/core.ts
similarity index 51%
rename from packages/typescript/src/experimental/core.ts
rename to packages/typescript/src/client/core.ts
index 1b81c1a3b..49455efa2 100644
--- a/packages/typescript/src/experimental/core.ts
+++ b/packages/typescript/src/client/core.ts
@@ -5,18 +5,17 @@ import { TypeTagSerializer } from '../bcs/type-tag-serializer.js';
import type { TransactionPlugin } from '../transactions/index.js';
import { deriveDynamicFieldID } from '../utils/dynamic-fields.js';
import { normalizeStructTag, parseStructTag, SUI_ADDRESS_LENGTH } from '../utils/sui-types.js';
-import { Experimental_BaseClient } from './client.js';
-import type { ClientWithExtensions, Experimental_SuiClientTypes } from './types.js';
+import { BaseClient } from './client.js';
+import type { ClientWithExtensions, SuiClientTypes } from './types.js';
import { MvrClient } from './mvr.js';
export type ClientWithCoreApi = ClientWithExtensions<{
- core: Experimental_CoreClient;
+ core: CoreClient;
}>;
-export interface Experimental_CoreClientOptions
- extends Experimental_SuiClientTypes.SuiClientOptions {
- base: Experimental_BaseClient;
- mvr?: Experimental_SuiClientTypes.MvrOptions;
+export interface CoreClientOptions extends SuiClientTypes.SuiClientOptions {
+ base: BaseClient;
+ mvr?: SuiClientTypes.MvrOptions;
}
const DEFAULT_MVR_URLS: Record = {
@@ -24,14 +23,11 @@ const DEFAULT_MVR_URLS: Record = {
testnet: 'https://testnet.mvr.mystenlabs.com',
};
-export abstract class Experimental_CoreClient
- extends Experimental_BaseClient
- implements Experimental_SuiClientTypes.TransportMethods
-{
+export abstract class CoreClient extends BaseClient implements SuiClientTypes.TransportMethods {
core = this;
- mvr: Experimental_SuiClientTypes.MvrMethods;
+ mvr: SuiClientTypes.MvrMethods;
- constructor(options: Experimental_CoreClientOptions) {
+ constructor(options: CoreClientOptions) {
super(options);
this.mvr = new MvrClient({
@@ -42,76 +38,80 @@ export abstract class Experimental_CoreClient
});
}
- abstract getObjects(
- options: Experimental_SuiClientTypes.GetObjectsOptions,
- ): Promise;
+ abstract listObjects(
+ options: SuiClientTypes.ListObjectsOptions,
+ ): Promise>;
- async getObject(
- options: Experimental_SuiClientTypes.GetObjectOptions,
- ): Promise {
+ async getObject(
+ options: SuiClientTypes.GetObjectOptions,
+ ): Promise> {
const { objectId } = options;
const {
objects: [result],
- } = await this.getObjects({ objectIds: [objectId], signal: options.signal });
+ } = await this.listObjects({
+ objectIds: [objectId],
+ signal: options.signal,
+ include: options.include,
+ });
if (result instanceof Error) {
throw result;
}
return { object: result };
}
- abstract getCoins(
- options: Experimental_SuiClientTypes.GetCoinsOptions,
- ): Promise;
+ abstract listCoins(
+ options: SuiClientTypes.ListCoinsOptions,
+ ): Promise>;
- abstract getOwnedObjects(
- options: Experimental_SuiClientTypes.GetOwnedObjectsOptions,
- ): Promise;
+ abstract listOwnedObjects(
+ options: SuiClientTypes.ListOwnedObjectsOptions,
+ ): Promise>;
abstract getBalance(
- options: Experimental_SuiClientTypes.GetBalanceOptions,
- ): Promise;
+ options: SuiClientTypes.GetBalanceOptions,
+ ): Promise;
- abstract getAllBalances(
- options: Experimental_SuiClientTypes.GetAllBalancesOptions,
- ): Promise;
+ abstract listBalances(
+ options: SuiClientTypes.ListBalancesOptions,
+ ): Promise;
- abstract getTransaction(
- options: Experimental_SuiClientTypes.GetTransactionOptions,
- ): Promise;
+ abstract getTransaction(
+ options: SuiClientTypes.GetTransactionOptions,
+ ): Promise>;
- abstract executeTransaction(
- options: Experimental_SuiClientTypes.ExecuteTransactionOptions,
- ): Promise;
+ abstract executeTransaction(
+ options: SuiClientTypes.ExecuteTransactionOptions,
+ ): Promise>;
- abstract dryRunTransaction(
- options: Experimental_SuiClientTypes.DryRunTransactionOptions,
- ): Promise;
+ abstract simulateTransaction(
+ options: SuiClientTypes.SimulateTransactionOptions,
+ ): Promise>;
abstract getReferenceGasPrice(
- options?: Experimental_SuiClientTypes.GetReferenceGasPriceOptions,
- ): Promise;
+ options?: SuiClientTypes.GetReferenceGasPriceOptions,
+ ): Promise;
- abstract getDynamicFields(
- options: Experimental_SuiClientTypes.GetDynamicFieldsOptions,
- ): Promise;
+ abstract listDynamicFields(
+ options: SuiClientTypes.ListDynamicFieldsOptions,
+ ): Promise;
abstract resolveTransactionPlugin(): TransactionPlugin;
abstract verifyZkLoginSignature(
- options: Experimental_SuiClientTypes.VerifyZkLoginSignatureOptions,
- ): Promise;
+ options: SuiClientTypes.VerifyZkLoginSignatureOptions,
+ ): Promise;
abstract getMoveFunction(
- options: Experimental_SuiClientTypes.GetMoveFunctionOptions,
- ): Promise;
+ options: SuiClientTypes.GetMoveFunctionOptions,
+ ): Promise;
abstract defaultNameServiceName(
- options: Experimental_SuiClientTypes.DefaultNameServiceNameOptions,
- ): Promise;
+ options: SuiClientTypes.DefaultNameServiceNameOptions,
+ ): Promise;
async getDynamicField(
- options: Experimental_SuiClientTypes.GetDynamicFieldOptions,
- ): Promise {
+ options: SuiClientTypes.GetDynamicFieldOptions,
+ ): Promise {
const normalizedNameType = TypeTagSerializer.parseFromStr(
(
await this.core.mvr.resolveType({
@@ -122,9 +122,13 @@ export abstract class Experimental_CoreClient
const fieldId = deriveDynamicFieldID(options.parentId, normalizedNameType, options.name.bcs);
const {
objects: [fieldObject],
- } = await this.getObjects({
+ } = await this.listObjects({
objectIds: [fieldId],
signal: options.signal,
+ include: {
+ previousTransaction: true,
+ content: true,
+ },
});
if (fieldObject instanceof Error) {
@@ -136,7 +140,7 @@ export abstract class Experimental_CoreClient
return {
dynamicField: {
- id: fieldObject.id,
+ fieldId: fieldObject.objectId,
digest: fieldObject.digest,
version: fieldObject.version,
type: fieldObject.type,
@@ -159,7 +163,7 @@ export abstract class Experimental_CoreClient
};
}
- async waitForTransaction({
+ async waitForTransaction({
signal,
timeout = 60 * 1000,
...input
@@ -168,7 +172,9 @@ export abstract class Experimental_CoreClient
signal?: AbortSignal;
/** The amount of time to wait for transaction. Defaults to one minute. */
timeout?: number;
- } & Experimental_SuiClientTypes.GetTransactionOptions): Promise {
+ } & SuiClientTypes.GetTransactionOptions): Promise<
+ SuiClientTypes.GetTransactionResponse
+ > {
const abortSignal = signal
? AbortSignal.any([AbortSignal.timeout(timeout), signal])
: AbortSignal.timeout(timeout);
diff --git a/packages/typescript/src/experimental/errors.ts b/packages/typescript/src/client/errors.ts
similarity index 94%
rename from packages/typescript/src/experimental/errors.ts
rename to packages/typescript/src/client/errors.ts
index f5ed87fdf..47c7a2233 100644
--- a/packages/typescript/src/experimental/errors.ts
+++ b/packages/typescript/src/client/errors.ts
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import type { ObjectResponseError } from '../client/index.js';
+import type { ObjectResponseError } from '../jsonRpc/index.js';
export class SuiClientError extends Error {}
diff --git a/packages/typescript/src/client/index.ts b/packages/typescript/src/client/index.ts
index ebb7015cc..02a624d03 100644
--- a/packages/typescript/src/client/index.ts
+++ b/packages/typescript/src/client/index.ts
@@ -1,21 +1,20 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
+import { BaseClient } from './client.js';
+import type { ClientWithCoreApi, CoreClientOptions } from './core.js';
+import { CoreClient } from './core.js';
+import type { ClientWithExtensions, SuiClientTypes, SuiClientRegistration } from './types.js';
+export { parseTransactionBcs, parseTransactionEffectsBcs } from './utils.js';
+
export {
- type JsonRpcTransport as SuiTransport,
- type JsonRpcTransportRequestOptions as SuiTransportRequestOptions,
- type JsonRpcTransportSubscribeOptions as SuiTransportSubscribeOptions,
- type HttpHeaders,
- type JsonRpcHTTPTransportOptions as SuiHTTPTransportOptions,
- JsonRpcHTTPTransport as SuiHTTPTransport,
-} from '../jsonRpc/http-transport.js';
-export { getFullnodeUrl } from './network.js';
-export type * from '../jsonRpc/types/index.js';
-export {
- type SuiJsonRpcClientOptions as SuiClientOptions,
- type PaginationArguments,
- type OrderArguments,
- isSuiJsonRpcClient as isSuiClient,
- SuiJsonRpcClient as SuiClient,
-} from '../jsonRpc/client.js';
-export { SuiHTTPStatusError, SuiHTTPTransportError, JsonRpcError } from '../jsonRpc/errors.js';
+ BaseClient,
+ CoreClient,
+ type CoreClientOptions,
+ type ClientWithExtensions,
+ type SuiClientTypes,
+ type SuiClientRegistration,
+ type ClientWithCoreApi,
+};
+
+export { ClientCache, type ClientCacheOptions } from './cache.js';
diff --git a/packages/typescript/src/experimental/mvr.ts b/packages/typescript/src/client/mvr.ts
similarity index 95%
rename from packages/typescript/src/experimental/mvr.ts
rename to packages/typescript/src/client/mvr.ts
index d0af1aa56..047a50e45 100644
--- a/packages/typescript/src/experimental/mvr.ts
+++ b/packages/typescript/src/client/mvr.ts
@@ -13,7 +13,7 @@ import {
import type { ClientCache } from './cache.js';
import type { TransactionDataBuilder } from '../transactions/TransactionData.js';
import { PACKAGE_VERSION } from '../version.js';
-import type { Experimental_SuiClientTypes } from './types.js';
+import type { SuiClientTypes } from './types.js';
const NAME_SEPARATOR = '/';
const MVR_API_HEADER = {
@@ -30,7 +30,7 @@ export interface MvrClientOptions {
};
}
-export class MvrClient implements Experimental_SuiClientTypes.MvrMethods {
+export class MvrClient implements SuiClientTypes.MvrMethods {
#cache: ClientCache;
#url?: string;
#pageSize: number;
@@ -185,7 +185,7 @@ export class MvrClient implements Experimental_SuiClientTypes.MvrMethods {
async resolvePackage({
package: name,
- }: Experimental_SuiClientTypes.MvrResolvePackageOptions): Promise {
+ }: SuiClientTypes.MvrResolvePackageOptions): Promise {
if (!hasMvrName(name)) {
return {
package: name,
@@ -199,7 +199,7 @@ export class MvrClient implements Experimental_SuiClientTypes.MvrMethods {
async resolveType({
type,
- }: Experimental_SuiClientTypes.MvrResolveTypeOptions): Promise {
+ }: SuiClientTypes.MvrResolveTypeOptions): Promise {
if (!hasMvrName(type)) {
return {
type,
@@ -227,7 +227,7 @@ export class MvrClient implements Experimental_SuiClientTypes.MvrMethods {
async resolve({
types = [],
packages = [],
- }: Experimental_SuiClientTypes.MvrResolveOptions): Promise {
+ }: SuiClientTypes.MvrResolveOptions): Promise {
const mvrTypes = new Set();
for (const type of types ?? []) {
@@ -432,7 +432,7 @@ export function findNamesInTransaction(builder: TransactionDataBuilder): {
*/
export function replaceNames(
builder: TransactionDataBuilder,
- resolved: Experimental_SuiClientTypes.MvrResolveResponse,
+ resolved: SuiClientTypes.MvrResolveResponse,
) {
for (const command of builder.commands) {
// Replacements for `MakeMoveVec` commands (that can include types)
diff --git a/packages/typescript/src/client/transaction-resolver.ts b/packages/typescript/src/client/transaction-resolver.ts
new file mode 100644
index 000000000..950bc8764
--- /dev/null
+++ b/packages/typescript/src/client/transaction-resolver.ts
@@ -0,0 +1,279 @@
+// Copyright (c) Mysten Labs, Inc.
+// SPDX-License-Identifier: Apache-2.0
+
+import { fromBase64 } from '@mysten/bcs';
+import type { bcs } from '../bcs/index.js';
+import { TransactionDataBuilder } from '../transactions/TransactionData.js';
+import type { TransactionData } from '../transactions/data/internal.js';
+import type { Transaction as GrpcTransaction } from '../grpc/proto/sui/rpc/v2/transaction.js';
+import type { ObjectReference } from '../grpc/proto/sui/rpc/v2/object_reference.js';
+import type { Input } from '../grpc/proto/sui/rpc/v2/input.js';
+import { Input_InputKind } from '../grpc/proto/sui/rpc/v2/input.js';
+import type { Command } from '../grpc/proto/sui/rpc/v2/transaction.js';
+import type { CallArg, Command as BcsCommand } from '../transactions/data/internal.js';
+import type { Argument } from '../grpc/proto/sui/rpc/v2/argument.js';
+import { Argument_ArgumentKind } from '../grpc/proto/sui/rpc/v2/argument.js';
+import { TransactionExpiration_TransactionExpirationKind } from '../grpc/proto/sui/rpc/v2/transaction.js';
+
+/**
+ * Converts CallArg (TypeScript internal format) to gRPC Input format
+ */
+function callArgToGrpcInput(arg: CallArg): Input {
+ switch (arg.$kind) {
+ case 'Pure':
+ // Pure.bytes is a base64-encoded string that needs to be decoded
+ return {
+ kind: Input_InputKind.PURE,
+ pure: fromBase64(arg.Pure.bytes),
+ };
+
+ case 'Object':
+ if (arg.Object.$kind === 'ImmOrOwnedObject') {
+ return {
+ kind: Input_InputKind.IMMUTABLE_OR_OWNED,
+ objectId: arg.Object.ImmOrOwnedObject.objectId,
+ version: BigInt(arg.Object.ImmOrOwnedObject.version),
+ digest: arg.Object.ImmOrOwnedObject.digest,
+ };
+ } else if (arg.Object.$kind === 'SharedObject') {
+ return {
+ kind: Input_InputKind.SHARED,
+ objectId: arg.Object.SharedObject.objectId,
+ version: BigInt(arg.Object.SharedObject.initialSharedVersion),
+ mutable: arg.Object.SharedObject.mutable,
+ };
+ } else if (arg.Object.$kind === 'Receiving') {
+ return {
+ kind: Input_InputKind.RECEIVING,
+ objectId: arg.Object.Receiving.objectId,
+ version: BigInt(arg.Object.Receiving.version),
+ digest: arg.Object.Receiving.digest,
+ };
+ }
+ throw new Error(`Unknown Object kind: ${JSON.stringify(arg.Object)}`);
+
+ case 'UnresolvedObject':
+ const unresolved = arg.UnresolvedObject;
+ return {
+ objectId: unresolved.objectId,
+ version: unresolved.version
+ ? BigInt(unresolved.version)
+ : unresolved.initialSharedVersion
+ ? BigInt(unresolved.initialSharedVersion)
+ : undefined,
+ digest: unresolved.digest ?? undefined,
+ mutable: unresolved.mutable ?? undefined,
+ };
+
+ case 'UnresolvedPure':
+ throw new Error('UnresolvedPure arguments must be resolved before converting to gRPC format');
+
+ default:
+ throw new Error(`Unknown CallArg kind: ${JSON.stringify(arg)}`);
+ }
+}
+
+/**
+ * Converts a TypeScript Argument to gRPC Argument
+ */
+function tsArgumentToGrpcArgument(arg: typeof bcs.Argument.$inferInput): Argument {
+ if ('GasCoin' in arg) {
+ return { kind: Argument_ArgumentKind.GAS };
+ } else if ('Input' in arg) {
+ return { kind: Argument_ArgumentKind.INPUT, input: arg.Input };
+ } else if ('Result' in arg) {
+ return { kind: Argument_ArgumentKind.RESULT, result: arg.Result };
+ } else if ('NestedResult' in arg) {
+ return {
+ kind: Argument_ArgumentKind.RESULT,
+ result: arg.NestedResult[0],
+ subresult: arg.NestedResult[1],
+ };
+ }
+ throw new Error(`Unknown Argument: ${JSON.stringify(arg)}`);
+}
+
+/**
+ * Converts TypeScript Command to gRPC Command
+ */
+function tsCommandToGrpcCommand(cmd: BcsCommand): Command {
+ switch (cmd.$kind) {
+ case 'MoveCall':
+ return {
+ command: {
+ oneofKind: 'moveCall',
+ moveCall: {
+ package: cmd.MoveCall.package,
+ module: cmd.MoveCall.module,
+ function: cmd.MoveCall.function,
+ typeArguments: cmd.MoveCall.typeArguments,
+ arguments: cmd.MoveCall.arguments.map(tsArgumentToGrpcArgument),
+ },
+ },
+ };
+
+ case 'TransferObjects':
+ return {
+ command: {
+ oneofKind: 'transferObjects',
+ transferObjects: {
+ objects: cmd.TransferObjects.objects.map(tsArgumentToGrpcArgument),
+ address: tsArgumentToGrpcArgument(cmd.TransferObjects.address),
+ },
+ },
+ };
+
+ case 'SplitCoins':
+ return {
+ command: {
+ oneofKind: 'splitCoins',
+ splitCoins: {
+ coin: tsArgumentToGrpcArgument(cmd.SplitCoins.coin),
+ amounts: cmd.SplitCoins.amounts.map(tsArgumentToGrpcArgument),
+ },
+ },
+ };
+
+ case 'MergeCoins':
+ return {
+ command: {
+ oneofKind: 'mergeCoins',
+ mergeCoins: {
+ coin: tsArgumentToGrpcArgument(cmd.MergeCoins.destination),
+ coinsToMerge: cmd.MergeCoins.sources.map(tsArgumentToGrpcArgument),
+ },
+ },
+ };
+
+ case 'Publish':
+ return {
+ command: {
+ oneofKind: 'publish',
+ publish: {
+ // modules are base64-encoded strings in internal format
+ modules: cmd.Publish.modules.map((m) => fromBase64(m)),
+ dependencies: cmd.Publish.dependencies,
+ },
+ },
+ };
+
+ case 'MakeMoveVec':
+ return {
+ command: {
+ oneofKind: 'makeMoveVector',
+ makeMoveVector: {
+ elementType: cmd.MakeMoveVec.type ?? undefined,
+ elements: cmd.MakeMoveVec.elements.map(tsArgumentToGrpcArgument),
+ },
+ },
+ };
+
+ case 'Upgrade':
+ return {
+ command: {
+ oneofKind: 'upgrade',
+ upgrade: {
+ // modules are base64-encoded strings in internal format
+ modules: cmd.Upgrade.modules.map((m) => fromBase64(m)),
+ dependencies: cmd.Upgrade.dependencies,
+ package: cmd.Upgrade.package,
+ ticket: tsArgumentToGrpcArgument(cmd.Upgrade.ticket),
+ },
+ },
+ };
+
+ default:
+ throw new Error(`Unknown Command kind: ${JSON.stringify(cmd)}`);
+ }
+}
+
+export function transactionDataToGrpcTransaction(data: TransactionData): GrpcTransaction {
+ const grpcInputs = data.inputs.map(callArgToGrpcInput);
+
+ const grpcCommands = data.commands.map(tsCommandToGrpcCommand);
+
+ const transaction: GrpcTransaction = {
+ version: 1,
+ sender: data.sender || undefined,
+ kind: {
+ data: {
+ oneofKind: 'programmableTransaction',
+ programmableTransaction: {
+ inputs: grpcInputs,
+ commands: grpcCommands,
+ },
+ },
+ },
+ };
+
+ transaction.gasPayment = {
+ objects: data.gasData.payment
+ ? data.gasData.payment.map((ref) => ({
+ objectId: ref.objectId,
+ version: BigInt(ref.version),
+ digest: ref.digest,
+ }))
+ : [],
+ owner: data.gasData.owner ?? data.sender ?? undefined,
+ price: data.gasData.price ? BigInt(data.gasData.price) : undefined,
+ budget: data.gasData.budget ? BigInt(data.gasData.budget) : undefined,
+ };
+
+ if (data.expiration) {
+ if ('None' in data.expiration) {
+ transaction.expiration = {
+ kind: TransactionExpiration_TransactionExpirationKind.NONE,
+ };
+ } else if ('Epoch' in data.expiration) {
+ transaction.expiration = {
+ kind: TransactionExpiration_TransactionExpirationKind.EPOCH,
+ epoch: BigInt(data.expiration.Epoch),
+ };
+ }
+ }
+
+ return transaction;
+}
+
+export function applyGrpcResolvedTransaction(
+ transactionData: TransactionDataBuilder,
+ resolvedTransaction: GrpcTransaction,
+ options?: { onlyTransactionKind?: boolean },
+): void {
+ if (!resolvedTransaction.bcs?.value) {
+ throw new Error('Resolved transaction must contain BCS data');
+ }
+
+ const resolvedBuilder = TransactionDataBuilder.fromBytes(resolvedTransaction.bcs.value);
+ const resolved = resolvedBuilder.snapshot();
+
+ if (options?.onlyTransactionKind) {
+ transactionData.applyResolvedData({
+ ...resolved,
+ gasData: {
+ budget: null,
+ owner: null,
+ payment: null,
+ price: null,
+ },
+ expiration: null,
+ });
+ } else {
+ transactionData.applyResolvedData(resolved);
+ }
+}
+
+/**
+ * Converts an array of ObjectReferences from gRPC format to TypeScript SuiObjectRef format
+ */
+export function grpcObjectReferencesToBcs(refs: ObjectReference[]): {
+ objectId: string;
+ version: string;
+ digest: string;
+}[] {
+ return refs.map((ref) => ({
+ objectId: ref.objectId!,
+ version: ref.version?.toString()!,
+ digest: ref.digest!,
+ }));
+}
diff --git a/packages/typescript/src/experimental/types.ts b/packages/typescript/src/client/types.ts
similarity index 65%
rename from packages/typescript/src/experimental/types.ts
rename to packages/typescript/src/client/types.ts
index f653b7f81..84c22ccae 100644
--- a/packages/typescript/src/experimental/types.ts
+++ b/packages/typescript/src/client/types.ts
@@ -4,10 +4,10 @@
import type { SerializedTransactionDataV2, TransactionPlugin } from '../transactions/index.js';
import type { ClientCache } from './cache.js';
-import type { Experimental_BaseClient } from './client.js';
+import type { BaseClient } from './client.js';
export type SuiClientRegistration<
- T extends Experimental_BaseClient = Experimental_BaseClient,
+ T extends BaseClient = BaseClient,
Name extends string = string,
Extension = unknown,
> = {
@@ -15,17 +15,14 @@ export type SuiClientRegistration<
readonly register: (client: T) => Extension;
};
-export type ClientWithExtensions<
- T,
- Base extends Experimental_BaseClient = Experimental_BaseClient,
-> = Base & T;
+export type ClientWithExtensions = Base & T;
-export namespace Experimental_SuiClientTypes {
+export namespace SuiClientTypes {
export type Network = 'mainnet' | 'testnet' | 'devnet' | 'localnet' | (string & {});
export interface SuiClientOptions {
network: Network;
- base?: Experimental_BaseClient;
+ base?: BaseClient;
cache?: ClientCache;
}
@@ -44,36 +41,55 @@ export namespace Experimental_SuiClientTypes {
/** Object methods */
export interface TransportMethods {
- getObjects: (options: GetObjectsOptions) => Promise;
- getOwnedObjects: (options: GetOwnedObjectsOptions) => Promise;
- getCoins: (options: GetCoinsOptions) => Promise;
- getDynamicFields: (options: GetDynamicFieldsOptions) => Promise;
+ listObjects: (
+ options: ListObjectsOptions,
+ ) => Promise>;
+ listOwnedObjects: (
+ options: ListOwnedObjectsOptions,
+ ) => Promise>;
+ listCoins: (
+ options: ListCoinsOptions,
+ ) => Promise>;
+ listDynamicFields: (options: ListDynamicFieldsOptions) => Promise;
getDynamicField: (options: GetDynamicFieldOptions) => Promise;
}
- export interface GetObjectsOptions extends CoreClientMethodOptions {
+ export interface ObjectInclude {
+ content?: boolean;
+ previousTransaction?: boolean;
+ }
+
+ export interface ListObjectsOptions
+ extends CoreClientMethodOptions {
objectIds: string[];
+ include?: Include;
}
- export interface GetObjectOptions extends CoreClientMethodOptions {
+ export interface GetObjectOptions
+ extends CoreClientMethodOptions {
objectId: string;
+ include?: Include;
}
- export interface GetOwnedObjectsOptions extends CoreClientMethodOptions {
- address: string;
+ export interface ListOwnedObjectsOptions
+ extends CoreClientMethodOptions {
+ owner: string;
limit?: number;
cursor?: string | null;
type?: string;
+ include?: Include;
}
- export interface GetCoinsOptions extends CoreClientMethodOptions {
- address: string;
+ export interface ListCoinsOptions
+ extends CoreClientMethodOptions {
+ owner: string;
coinType: string;
limit?: number;
cursor?: string | null;
+ include?: Include;
}
- export interface GetDynamicFieldsOptions extends CoreClientMethodOptions {
+ export interface ListDynamicFieldsOptions extends CoreClientMethodOptions {
parentId: string;
limit?: number;
cursor?: string | null;
@@ -84,47 +100,49 @@ export namespace Experimental_SuiClientTypes {
name: DynamicFieldName;
}
- export interface GetObjectsResponse {
- objects: (ObjectResponse | Error)[];
+ export interface ListObjectsResponse {
+ objects: (ObjectResponse | Error)[];
}
- export interface GetObjectResponse {
- object: ObjectResponse;
+ export interface GetObjectResponse {
+ object: ObjectResponse;
}
- export interface GetOwnedObjectsResponse {
- objects: ObjectResponse[];
+ export interface ListOwnedObjectsResponse {
+ objects: ObjectResponse[];
hasNextPage: boolean;
cursor: string | null;
}
- export interface GetCoinsResponse {
- objects: CoinResponse[];
+ export interface ListCoinsResponse {
+ objects: CoinResponse[];
hasNextPage: boolean;
cursor: string | null;
}
- export interface ObjectResponse {
- id: string;
+ export interface ObjectResponse {
+ objectId: string;
version: string;
digest: string;
owner: ObjectOwner;
type: string;
- content: PromiseLike;
- previousTransaction: string | null;
+ content: Include extends { content: true } ? Uint8Array : undefined;
+ previousTransaction: Include extends { previousTransaction: true } ? string | null : undefined;
}
- export interface CoinResponse extends ObjectResponse {
+ export interface CoinResponse
+ extends ObjectResponse {
balance: string;
}
- export interface GetDynamicFieldsResponse {
+ export interface ListDynamicFieldsResponse {
hasNextPage: boolean;
cursor: string | null;
dynamicFields: {
- id: string;
+ fieldId: string;
type: string;
name: DynamicFieldName;
+ valueType: string;
}[];
}
@@ -132,7 +150,7 @@ export namespace Experimental_SuiClientTypes {
dynamicField: {
name: DynamicFieldName;
value: DynamicFieldValue;
- id: string;
+ fieldId: string;
version: string;
digest: string;
type: string;
@@ -153,11 +171,11 @@ export namespace Experimental_SuiClientTypes {
/** Balance methods */
export interface TransportMethods {
getBalance: (options: GetBalanceOptions) => Promise;
- getAllBalances: (options: GetAllBalancesOptions) => Promise;
+ listBalances: (options: ListBalancesOptions) => Promise;
}
export interface GetBalanceOptions extends CoreClientMethodOptions {
- address: string;
+ owner: string;
coinType: string;
}
@@ -170,13 +188,13 @@ export namespace Experimental_SuiClientTypes {
balance: CoinBalance;
}
- export interface GetAllBalancesOptions extends CoreClientMethodOptions {
- address: string;
+ export interface ListBalancesOptions extends CoreClientMethodOptions {
+ owner: string;
limit?: number;
cursor?: string | null;
}
- export interface GetAllBalancesResponse {
+ export interface ListBalancesResponse {
balances: CoinBalance[];
hasNextPage: boolean;
cursor: string | null;
@@ -184,22 +202,37 @@ export namespace Experimental_SuiClientTypes {
/** Transaction methods */
export interface TransportMethods {
- getTransaction: (options: GetTransactionOptions) => Promise;
- executeTransaction: (options: ExecuteTransactionOptions) => Promise;
- dryRunTransaction: (options: DryRunTransactionOptions) => Promise;
+ getTransaction: (
+ options: GetTransactionOptions,
+ ) => Promise>;
+ executeTransaction: (
+ options: ExecuteTransactionOptions,
+ ) => Promise>;
+ simulateTransaction: (
+ options: SimulateTransactionOptions,
+ ) => Promise>;
resolveTransactionPlugin: () => TransactionPlugin;
}
- export interface TransactionResponse {
+ export interface TransactionResponse {
digest: string;
signatures: string[];
epoch: string | null;
- effects: TransactionEffects;
- objectTypes: PromiseLike>;
- transaction: TransactionData;
- balanceChanges: BalanceChange[];
- // TODO: add events
- // events?: Uint8Array;
+ balanceChanges: Include extends { balanceChanges: true } ? BalanceChange[] : undefined;
+ effects: Include extends { effects: true } ? TransactionEffects : undefined;
+ events: Include extends { events: true } ? Event[] : undefined;
+ objectTypes: Include extends { objectTypes: true }
+ ? PromiseLike>
+ : undefined;
+ transaction: Include extends { transaction: true } ? TransactionData : undefined;
+ }
+
+ export interface TransactionInclude {
+ balanceChanges?: boolean;
+ effects?: boolean;
+ events?: boolean;
+ objectTypes?: boolean;
+ transaction?: boolean;
}
export interface BalanceChange {
@@ -212,29 +245,35 @@ export namespace Experimental_SuiClientTypes {
bcs: Uint8Array;
}
- export interface GetTransactionOptions extends CoreClientMethodOptions {
+ export interface GetTransactionOptions
+ extends CoreClientMethodOptions {
digest: string;
+ include?: Include;
}
- export interface GetTransactionResponse {
- transaction: TransactionResponse;
+ export interface GetTransactionResponse {
+ transaction: TransactionResponse;
}
- export interface ExecuteTransactionOptions extends CoreClientMethodOptions {
+ export interface ExecuteTransactionOptions
+ extends CoreClientMethodOptions {
transaction: Uint8Array;
signatures: string[];
+ include?: Include;
}
- export interface DryRunTransactionOptions extends CoreClientMethodOptions {
+ export interface SimulateTransactionOptions
+ extends CoreClientMethodOptions {
transaction: Uint8Array;
+ include?: Include;
}
- export interface DryRunTransactionResponse {
- transaction: TransactionResponse;
+ export interface SimulateTransactionResponse {
+ transaction: TransactionResponse;
}
- export interface ExecuteTransactionResponse {
- transaction: TransactionResponse;
+ export interface ExecuteTransactionResponse {
+ transaction: TransactionResponse;
}
export interface GetReferenceGasPriceOptions extends CoreClientMethodOptions {}
@@ -254,7 +293,7 @@ export namespace Experimental_SuiClientTypes {
bytes: string;
signature: string;
intentScope: 'TransactionData' | 'PersonalMessage';
- author: string;
+ address: string;
}
export interface ZkLoginVerifyResponse {
@@ -466,11 +505,19 @@ export namespace Experimental_SuiClientTypes {
export interface AddressOwner {
$kind: 'AddressOwner';
AddressOwner: string;
+ ObjectOwner?: never;
+ Shared?: never;
+ Immutable?: never;
+ ConsensusAddressOwner?: never;
}
export interface ParentOwner {
$kind: 'ObjectOwner';
ObjectOwner: string;
+ AddressOwner?: never;
+ Shared?: never;
+ Immutable?: never;
+ ConsensusAddressOwner?: never;
}
export interface SharedOwner {
@@ -478,11 +525,19 @@ export namespace Experimental_SuiClientTypes {
Shared: {
initialSharedVersion: string;
};
+ AddressOwner?: never;
+ ObjectOwner?: never;
+ Immutable?: never;
+ ConsensusAddressOwner?: never;
}
export interface ImmutableOwner {
$kind: 'Immutable';
Immutable: true;
+ AddressOwner?: never;
+ ObjectOwner?: never;
+ Shared?: never;
+ ConsensusAddressOwner?: never;
}
export interface ConsensusAddressOwner {
@@ -491,10 +546,19 @@ export namespace Experimental_SuiClientTypes {
owner: string;
startVersion: string;
};
+ AddressOwner?: never;
+ ObjectOwner?: never;
+ Shared?: never;
+ Immutable?: never;
}
export interface UnknownOwner {
$kind: 'Unknown';
+ AddressOwner?: never;
+ ObjectOwner?: never;
+ Shared?: never;
+ Immutable?: never;
+ ConsensusAddressOwner?: never;
}
export type ObjectOwner =
@@ -509,7 +573,6 @@ export namespace Experimental_SuiClientTypes {
export interface TransactionEffects {
bcs: Uint8Array | null;
- digest: string;
version: number;
status: ExecutionStatus;
gasUsed: GasCostSummary;
@@ -524,7 +587,7 @@ export namespace Experimental_SuiClientTypes {
}
export interface ChangedObject {
- id: string;
+ objectId: string;
inputState: 'Unknown' | 'DoesNotExist' | 'Exists';
inputVersion: string | null;
inputDigest: string | null;
@@ -567,3 +630,11 @@ export namespace Experimental_SuiClientTypes {
digest: string | null;
}
}
+
+export interface Event {
+ packageId: string;
+ module: string;
+ sender: string;
+ eventType: string;
+ bcs: Uint8Array;
+}
diff --git a/packages/typescript/src/experimental/transports/utils.ts b/packages/typescript/src/client/utils.ts
similarity index 80%
rename from packages/typescript/src/experimental/transports/utils.ts
rename to packages/typescript/src/client/utils.ts
index f5692b4b3..601776690 100644
--- a/packages/typescript/src/experimental/transports/utils.ts
+++ b/packages/typescript/src/client/utils.ts
@@ -1,22 +1,18 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import { bcs } from '../../bcs/index.js';
-import { TransactionDataBuilder } from '../../transactions/TransactionData.js';
-import type { Experimental_SuiClientTypes } from '../types.js';
+import { bcs } from '../bcs/index.js';
+import { TransactionDataBuilder } from '../transactions/TransactionData.js';
+import type { SuiClientTypes } from './types.js';
-export function parseTransactionBcs(
- bytes: Uint8Array,
-): Experimental_SuiClientTypes.TransactionResponse['transaction'] {
+export function parseTransactionBcs(bytes: Uint8Array): SuiClientTypes.TransactionData {
return {
...TransactionDataBuilder.fromBytes(bytes).snapshot(),
bcs: bytes,
};
}
-export function parseTransactionEffectsBcs(
- effects: Uint8Array,
-): Experimental_SuiClientTypes.TransactionEffects {
+export function parseTransactionEffectsBcs(effects: Uint8Array): SuiClientTypes.TransactionEffects {
const parsed = bcs.TransactionEffects.parse(effects);
switch (parsed.$kind) {
@@ -34,7 +30,7 @@ export function parseTransactionEffectsBcs(
function parseTransactionEffectsV1(_: {
bytes: Uint8Array;
effects: NonNullable<(typeof bcs.TransactionEffects.$inferType)['V1']>;
-}): Experimental_SuiClientTypes.TransactionEffects {
+}): SuiClientTypes.TransactionEffects {
throw new Error('V1 effects are not supported yet');
}
@@ -44,11 +40,11 @@ function parseTransactionEffectsV2({
}: {
bytes: Uint8Array;
effects: NonNullable<(typeof bcs.TransactionEffects.$inferType)['V2']>;
-}): Experimental_SuiClientTypes.TransactionEffects {
+}): SuiClientTypes.TransactionEffects {
const changedObjects = effects.changedObjects.map(
- ([id, change]): Experimental_SuiClientTypes.ChangedObject => {
+ ([id, change]): SuiClientTypes.ChangedObject => {
return {
- id,
+ objectId: id,
inputState: change.inputState.$kind === 'Exist' ? 'Exists' : 'DoesNotExist',
inputVersion: change.inputState.Exist?.[0][0] ?? null,
inputDigest: change.inputState.Exist?.[0][1] ?? null,
@@ -73,7 +69,6 @@ function parseTransactionEffectsV2({
return {
bcs: bytes,
- digest: effects.transactionDigest,
version: 2,
status:
effects.status.$kind === 'Success'
@@ -95,7 +90,7 @@ function parseTransactionEffectsV2({
lamportVersion: effects.lamportVersion,
changedObjects,
unchangedConsensusObjects: effects.unchangedSharedObjects.map(
- ([objectId, object]): Experimental_SuiClientTypes.UnchangedConsensusObject => {
+ ([objectId, object]): SuiClientTypes.UnchangedConsensusObject => {
return {
kind:
object.$kind === 'MutateDeleted'
diff --git a/packages/typescript/src/cryptography/keypair.ts b/packages/typescript/src/cryptography/keypair.ts
index 19d68ea5e..c2ff613ff 100644
--- a/packages/typescript/src/cryptography/keypair.ts
+++ b/packages/typescript/src/cryptography/keypair.ts
@@ -12,7 +12,7 @@ import { SIGNATURE_FLAG_TO_SCHEME, SIGNATURE_SCHEME_TO_FLAG } from './signature-
import type { SignatureScheme } from './signature-scheme.js';
import { toSerializedSignature } from './signature.js';
import type { Transaction } from '../transactions/Transaction.js';
-import type { ClientWithCoreApi, Experimental_SuiClientTypes } from '../experimental/index.js';
+import type { ClientWithCoreApi, SuiClientTypes } from '../client/index.js';
export const PRIVATE_KEY_SIZE = 32;
export const LEGACY_PRIVATE_KEY_SIZE = 64;
@@ -20,8 +20,6 @@ export const SUI_PRIVATE_KEY_PREFIX = 'suiprivkey';
export type ParsedKeypair = {
scheme: SignatureScheme;
- /** @deprecated use `scheme` instead */
- schema: SignatureScheme;
secretKey: Uint8Array;
};
@@ -84,13 +82,15 @@ export abstract class Signer {
transaction,
client,
}: SignAndExecuteOptions): Promise<
- Omit
+ SuiClientTypes.TransactionResponse<{ transaction: true; effects: true }>
> {
+ transaction.setSenderIfNotSet(this.toSuiAddress());
const bytes = await transaction.build({ client });
const { signature } = await this.signTransaction(bytes);
const response = await client.core.executeTransaction({
transaction: bytes,
signatures: [signature],
+ include: { transaction: true, effects: true },
});
return response.transaction;
@@ -135,7 +135,6 @@ export function decodeSuiPrivateKey(value: string): ParsedKeypair {
return {
scheme: signatureScheme,
- schema: signatureScheme,
secretKey: secretKey,
};
}
diff --git a/packages/typescript/src/experimental/index.ts b/packages/typescript/src/experimental/index.ts
deleted file mode 100644
index bd02af7df..000000000
--- a/packages/typescript/src/experimental/index.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) Mysten Labs, Inc.
-// SPDX-License-Identifier: Apache-2.0
-
-import { Experimental_BaseClient } from './client.js';
-import type { ClientWithCoreApi, Experimental_CoreClientOptions } from './core.js';
-import { Experimental_CoreClient } from './core.js';
-import type {
- ClientWithExtensions,
- Experimental_SuiClientTypes,
- SuiClientRegistration,
-} from './types.js';
-export { parseTransactionBcs, parseTransactionEffectsBcs } from './transports/utils.js';
-
-export {
- Experimental_BaseClient,
- Experimental_CoreClient,
- type Experimental_CoreClientOptions,
- type ClientWithExtensions,
- type Experimental_SuiClientTypes,
- type SuiClientRegistration,
- type ClientWithCoreApi,
-};
-
-export { ClientCache, type ClientCacheOptions } from './cache.js';
diff --git a/packages/typescript/src/faucet/faucet.ts b/packages/typescript/src/faucet/faucet.ts
index 9e8dd33d5..2cbb6dda1 100644
--- a/packages/typescript/src/faucet/faucet.ts
+++ b/packages/typescript/src/faucet/faucet.ts
@@ -9,26 +9,6 @@ type FaucetCoinInfo = {
transferTxDigest: string;
};
-type FaucetResponse = {
- transferredGasObjects: FaucetCoinInfo[];
- error?: string | null;
-};
-
-type BatchFaucetResponse = {
- task?: string | null;
- error?: string | null;
-};
-
-type BatchSendStatusType = {
- status: 'INPROGRESS' | 'SUCCEEDED' | 'DISCARDED';
- transferred_gas_objects: { sent: FaucetCoinInfo[] };
-};
-
-type BatchStatusFaucetResponse = {
- status: BatchSendStatusType;
- error?: string | null;
-};
-
type FaucetResponseV2 = {
status: 'Success' | FaucetFailure;
coins_sent: FaucetCoinInfo[] | null;
@@ -75,60 +55,6 @@ async function faucetRequest({ host, path, body, headers, method }: FaucetReq
}
}
-/**
- * @deprecated "Use requestSuiFromFaucetV2 instead"
- */
-export async function requestSuiFromFaucetV0(input: {
- host: string;
- recipient: string;
- headers?: HeadersInit;
-}): Promise {
- const response = await faucetRequest({
- host: input.host,
- path: '/gas',
- body: {
- FixedAmountRequest: {
- recipient: input.recipient,
- },
- },
- headers: input.headers,
- method: 'POST',
- });
-
- if (response.error) {
- throw new Error(`Faucet request failed: ${response.error}`);
- }
-
- return response;
-}
-
-/**
- * @deprecated "Use requestSuiFromFaucetV2 instead"
- */
-export async function requestSuiFromFaucetV1(input: {
- host: string;
- recipient: string;
- headers?: HeadersInit;
-}): Promise {
- const response = await faucetRequest({
- host: input.host,
- path: '/v1/gas',
- body: {
- FixedAmountRequest: {
- recipient: input.recipient,
- },
- },
- headers: input.headers,
- method: 'POST',
- });
-
- if (response.error) {
- throw new Error(`Faucet request failed: ${response.error}`);
- }
-
- return response;
-}
-
export async function requestSuiFromFaucetV2(input: {
host: string;
recipient: string;
@@ -153,28 +79,6 @@ export async function requestSuiFromFaucetV2(input: {
return response;
}
-/**
- * @deprecated "Use requestSuiFromFaucetV2 which returns directly a success or failure status"
- */
-export async function getFaucetRequestStatus(input: {
- host: string;
- taskId: string;
- headers?: HeadersInit;
-}) {
- const response = await faucetRequest({
- host: input.host,
- path: `/v1/status/${input.taskId}`,
- headers: input.headers,
- method: 'GET',
- });
-
- if (response.error) {
- throw new Error(`Faucet request failed: ${response.error}`);
- }
-
- return response;
-}
-
export function getFaucetHost(network: 'testnet' | 'devnet' | 'localnet') {
switch (network) {
case 'testnet':
diff --git a/packages/typescript/src/faucet/index.ts b/packages/typescript/src/faucet/index.ts
index 1c65eba3a..d3f1dcf80 100644
--- a/packages/typescript/src/faucet/index.ts
+++ b/packages/typescript/src/faucet/index.ts
@@ -1,11 +1,4 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-export {
- requestSuiFromFaucetV0,
- requestSuiFromFaucetV1,
- requestSuiFromFaucetV2,
- getFaucetRequestStatus,
- getFaucetHost,
- FaucetRateLimitError,
-} from './faucet.js';
+export { requestSuiFromFaucetV2, getFaucetHost, FaucetRateLimitError } from './faucet.js';
diff --git a/packages/typescript/src/graphql/client.ts b/packages/typescript/src/graphql/client.ts
index 81e116af9..a32411347 100644
--- a/packages/typescript/src/graphql/client.ts
+++ b/packages/typescript/src/graphql/client.ts
@@ -5,8 +5,8 @@ import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
import type { TadaDocumentNode } from 'gql.tada';
import type { DocumentNode } from 'graphql';
import { print } from 'graphql';
-import { Experimental_BaseClient } from '../experimental/index.js';
-import type { Experimental_SuiClientTypes } from '../experimental/index.js';
+import { BaseClient } from '../client/index.js';
+import type { SuiClientTypes } from '../client/index.js';
import { GraphQLCoreClient } from './core.js';
import type { TypedDocumentString } from './generated/queries.js';
@@ -51,8 +51,8 @@ export interface SuiGraphQLClientOptions;
queries?: Queries;
- network?: Experimental_SuiClientTypes.Network;
- mvr?: Experimental_SuiClientTypes.MvrOptions;
+ network: SuiClientTypes.Network;
+ mvr?: SuiClientTypes.MvrOptions;
}
export class SuiGraphQLRequestError extends Error {}
@@ -60,7 +60,7 @@ export class SuiGraphQLRequestError extends Error {}
export class SuiGraphQLClient<
// eslint-disable-next-line @typescript-eslint/ban-types
Queries extends Record = {},
-> extends Experimental_BaseClient {
+> extends BaseClient {
#url: string;
#queries: Queries;
#headers: Record;
@@ -72,7 +72,7 @@ export class SuiGraphQLClient<
fetch: fetchFn = fetch,
headers = {},
queries = {} as Queries,
- network = 'unknown',
+ network,
mvr,
}: SuiGraphQLClientOptions) {
super({
diff --git a/packages/typescript/src/graphql/core.ts b/packages/typescript/src/graphql/core.ts
index 0ec7407b4..d35d67c24 100644
--- a/packages/typescript/src/graphql/core.ts
+++ b/packages/typescript/src/graphql/core.ts
@@ -1,8 +1,8 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
-import { Experimental_CoreClient } from '../experimental/core.js';
-import type { Experimental_SuiClientTypes } from '../experimental/types.js';
+import { CoreClient } from '../client/core.js';
+import type { SuiClientTypes } from '../client/types.js';
import type { GraphQLQueryOptions, SuiGraphQLClient } from './client.js';
import type {
Object_Owner_FieldsFragment,
@@ -24,17 +24,14 @@ import {
VerifyZkLoginSignatureDocument,
ZkLoginIntentScope,
} from './generated/queries.js';
-import { ObjectError } from '../experimental/errors.js';
+import { ObjectError } from '../client/errors.js';
import { chunk, fromBase64, toBase64 } from '@mysten/utils';
import { normalizeStructTag, normalizeSuiAddress } from '../utils/sui-types.js';
import { deriveDynamicFieldID } from '../utils/dynamic-fields.js';
-import {
- parseTransactionBcs,
- parseTransactionEffectsBcs,
-} from '../experimental/transports/utils.js';
+import { parseTransactionBcs, parseTransactionEffectsBcs } from '../client/utils.js';
import type { OpenMoveTypeSignatureBody, OpenMoveTypeSignature } from './types.js';
-export class GraphQLCoreClient extends Experimental_CoreClient {
+export class GraphQLCoreClient extends CoreClient {
#graphqlClient: SuiGraphQLClient;
constructor({
@@ -42,7 +39,7 @@ export class GraphQLCoreClient extends Experimental_CoreClient {
mvr,
}: {
graphqlClient: SuiGraphQLClient;
- mvr?: Experimental_SuiClientTypes.MvrOptions;
+ mvr?: SuiClientTypes.MvrOptions;
}) {
super({ network: graphqlClient.network, base: graphqlClient, mvr });
this.#graphqlClient = graphqlClient;
@@ -69,11 +66,11 @@ export class GraphQLCoreClient extends Experimental_CoreClient {
return extractedData as NonNullable;
}
- async getObjects(
- options: Experimental_SuiClientTypes.GetObjectsOptions,
- ): Promise {
+ async listObjects(
+ options: SuiClientTypes.ListObjectsOptions,
+ ): Promise> {
const batches = chunk(options.objectIds, 50);
- const results: Experimental_SuiClientTypes.GetObjectsResponse['objects'] = [];
+ const results: SuiClientTypes.ListObjectsResponse['objects'] = [];
for (const batch of batches) {
const page = await this.#graphqlQuery(
@@ -81,6 +78,8 @@ export class GraphQLCoreClient extends Experimental_CoreClient {
query: MultiGetObjectsDocument,
variables: {
objectKeys: batch.map((address) => ({ address })),
+ includeContent: options.include?.content ?? false,
+ includePreviousTransaction: options.include?.previousTransaction ?? false,
},
},
(result) => result.multiGetObjects,
@@ -97,18 +96,30 @@ export class GraphQLCoreClient extends Experimental_CoreClient {
if (obj instanceof ObjectError) {
return obj;
}
+ const bcsContent = obj.asMoveObject?.contents?.bcs
+ ? fromBase64(obj.asMoveObject.contents.bcs)
+ : undefined;
+
+ // Determine object type: package or Move object
+ // GraphQL already returns normalized struct tags
+ let type: string;
+ if (obj.asMovePackage) {
+ type = 'package';
+ } else if (obj.asMoveObject?.contents?.type?.repr) {
+ type = obj.asMoveObject.contents.type.repr;
+ } else {
+ type = '';
+ }
+
return {
- id: obj.address,
+ objectId: obj.address,
version: obj.version?.toString()!,
digest: obj.digest!,
owner: mapOwner(obj.owner!),
- type: obj.asMoveObject?.contents?.type?.repr!,
- content: Promise.resolve(
- obj.asMoveObject?.contents?.bcs
- ? fromBase64(obj.asMoveObject.contents.bcs)
- : new Uint8Array(),
- ),
- previousTransaction: obj.previousTransaction?.digest ?? null,
+ type,
+ content: bcsContent as SuiClientTypes.ObjectResponse['content'],
+ previousTransaction: (obj.previousTransaction?.digest ??
+ undefined) as SuiClientTypes.ObjectResponse['previousTransaction'],
};
}),
);
@@ -118,51 +129,58 @@ export class GraphQLCoreClient extends Experimental_CoreClient {
objects: results,
};
}
- async getOwnedObjects(
- options: Experimental_SuiClientTypes.GetOwnedObjectsOptions,
- ): Promise {
+ async listOwnedObjects(
+ options: SuiClientTypes.ListOwnedObjectsOptions,
+ ): Promise> {
const objects = await this.#graphqlQuery(
{
query: GetOwnedObjectsDocument,
variables: {
- owner: options.address,
+ owner: options.owner,
limit: options.limit,
cursor: options.cursor,
filter: options.type
? { type: (await this.mvr.resolveType({ type: options.type })).type }
: undefined,
+ includeContent: options.include?.content ?? false,
+ includePreviousTransaction: options.include?.previousTransaction ?? false,
},
},
(result) => result.address?.objects,
);
return {
- objects: objects.nodes.map((obj) => ({
- id: obj.address,
- version: obj.version?.toString()!,
- digest: obj.digest!,
- owner: mapOwner(obj.owner!),
- type: obj.contents?.type?.repr!,
- content: Promise.resolve(
- obj.contents?.bcs ? fromBase64(obj.contents.bcs) : new Uint8Array(),
- ),
- previousTransaction: obj.previousTransaction?.digest ?? null,
- })),
+ objects: objects.nodes.map(
+ (obj): SuiClientTypes.ObjectResponse => ({
+ objectId: obj.address,
+ version: obj.version?.toString()!,
+ digest: obj.digest!,
+ owner: mapOwner(obj.owner!),
+ type: obj.contents?.type?.repr!,
+ content: (obj.contents?.bcs
+ ? fromBase64(obj.contents.bcs)
+ : undefined) as SuiClientTypes.ObjectResponse['content'],
+ previousTransaction: (obj.previousTransaction?.digest ??
+ undefined) as SuiClientTypes.ObjectResponse['previousTransaction'],
+ }),
+ ),
hasNextPage: objects.pageInfo.hasNextPage,
cursor: objects.pageInfo.endCursor ?? null,
};
}
- async getCoins(
- options: Experimental_SuiClientTypes.GetCoinsOptions,
- ): Promise {
+ async listCoins(
+ options: SuiClientTypes.ListCoinsOptions,
+ ): Promise> {
const coins = await this.#graphqlQuery(
{
query: GetCoinsDocument,
variables: {
- owner: options.address,
+ owner: options.owner,
cursor: options.cursor,
first: options.limit,
type: `0x2::coin::Coin<${(await this.mvr.resolveType({ type: options.coinType })).type}>`,
+ includeContent: options.include?.content ?? false,
+ includePreviousTransaction: options.include?.previousTransaction ?? false,
},
},
(result) => result.address?.objects,
@@ -171,29 +189,32 @@ export class GraphQLCoreClient extends Experimental_CoreClient {
return {
cursor: coins.pageInfo.endCursor ?? null,
hasNextPage: coins.pageInfo.hasNextPage,
- objects: coins.nodes.map((coin) => ({
- id: coin.address,
- version: coin.version?.toString()!,
- digest: coin.digest!,
- owner: mapOwner(coin.owner!),
- type: coin.contents?.type?.repr!,
- balance: (coin.contents?.json as { balance: string })?.balance,
- content: Promise.resolve(
- coin.contents?.bcs ? fromBase64(coin.contents.bcs) : new Uint8Array(),
- ),
- previousTransaction: coin.previousTransaction?.digest ?? null,
- })),
+ objects: coins.nodes.map(
+ (coin): SuiClientTypes.CoinResponse => ({
+ objectId: coin.address,
+ version: coin.version?.toString()!,
+ digest: coin.digest!,
+ owner: mapOwner(coin.owner!),
+ type: coin.contents?.type?.repr!,
+ balance: (coin.contents?.json as { balance: string })?.balance,
+ content: (coin.contents?.bcs
+ ? fromBase64(coin.contents.bcs)
+ : undefined) as SuiClientTypes.CoinResponse['content'],
+ previousTransaction: (coin.previousTransaction?.digest ??
+ undefined) as SuiClientTypes.CoinResponse['previousTransaction'],
+ }),
+ ),
};
}
async getBalance(
- options: Experimental_SuiClientTypes.GetBalanceOptions,
- ): Promise {
+ options: SuiClientTypes.GetBalanceOptions,
+ ): Promise {
const result = await this.#graphqlQuery(
{
query: GetBalanceDocument,
variables: {
- owner: options.address,
+ owner: options.owner,
type: (await this.mvr.resolveType({ type: options.coinType })).type,
},
},
@@ -202,18 +223,18 @@ export class GraphQLCoreClient extends Experimental_CoreClient {
return {
balance: {
- coinType: result.coinType?.repr!,
- balance: result.totalBalance!,
+ coinType: result.coinType?.repr ?? options.coinType,
+ balance: result.totalBalance ?? '0',
},
};
}
- async getAllBalances(
- options: Experimental_SuiClientTypes.GetAllBalancesOptions,
- ): Promise {
+ async listBalances(
+ options: SuiClientTypes.ListBalancesOptions,
+ ): Promise {
const balances = await this.#graphqlQuery(
{
query: GetAllBalancesDocument,
- variables: { owner: options.address },
+ variables: { owner: options.owner },
},
(result) => result.address?.balances,
);
@@ -227,30 +248,42 @@ export class GraphQLCoreClient extends Experimental_CoreClient {
})),
};
}
- async getTransaction(
- options: Experimental_SuiClientTypes.GetTransactionOptions,
- ): Promise {
+ async getTransaction(
+ options: SuiClientTypes.GetTransactionOptions,
+ ): Promise> {
const result = await this.#graphqlQuery(
{
query: GetTransactionBlockDocument,
- variables: { digest: options.digest },
+ variables: {
+ digest: options.digest,
+ includeTransaction: options.include?.transaction ?? false,
+ includeEffects: options.include?.effects ?? false,
+ includeEvents: options.include?.events ?? false,
+ includeBalanceChanges: options.include?.balanceChanges ?? false,
+ includeObjectTypes: options.include?.objectTypes ?? false,
+ },
},
(result) => result.transaction,
);
return {
- transaction: parseTransaction(result),
+ transaction: parseTransaction(result, options.include),
};
}
- async executeTransaction(
- options: Experimental_SuiClientTypes.ExecuteTransactionOptions,
- ): Promise {
+ async executeTransaction(
+ options: SuiClientTypes.ExecuteTransactionOptions,
+ ): Promise> {
const result = await this.#graphqlQuery(
{
query: ExecuteTransactionDocument,
variables: {
transactionDataBcs: toBase64(options.transaction),
signatures: options.signatures,
+ includeTransaction: options.include?.transaction ?? false,
+ includeEffects: options.include?.effects ?? false,
+ includeEvents: options.include?.events ?? false,
+ includeBalanceChanges: options.include?.balanceChanges ?? false,
+ includeObjectTypes: options.include?.objectTypes ?? false,
},
},
(result) => result.executeTransaction,
@@ -264,12 +297,12 @@ export class GraphQLCoreClient extends Experimental_CoreClient {
}
return {
- transaction: parseTransaction(result.effects?.transaction!),
+ transaction: parseTransaction(result.effects?.transaction!, options.include),
};
}
- async dryRunTransaction(
- options: Experimental_SuiClientTypes.DryRunTransactionOptions,
- ): Promise {
+ async simulateTransaction(
+ options: SuiClientTypes.SimulateTransactionOptions,
+ ): Promise> {
const result = await this.#graphqlQuery(
{
query: SimulateTransactionDocument,
@@ -279,6 +312,11 @@ export class GraphQLCoreClient extends Experimental_CoreClient {
value: toBase64(options.transaction),
},
},
+ includeTransaction: options.include?.transaction ?? false,
+ includeEffects: options.include?.effects ?? false,
+ includeEvents: options.include?.events ?? false,
+ includeBalanceChanges: options.include?.balanceChanges ?? false,
+ includeObjectTypes: options.include?.objectTypes ?? false,
},
},
(result) => result.simulateTransaction,
@@ -289,10 +327,10 @@ export class GraphQLCoreClient extends Experimental_CoreClient {
}
return {
- transaction: parseTransaction(result.effects?.transaction!),
+ transaction: parseTransaction(result.effects?.transaction!, options.include),
};
}
- async getReferenceGasPrice(): Promise {
+ async getReferenceGasPrice(): Promise {
const result = await this.#graphqlQuery(
{
query: GetReferenceGasPriceDocument,
@@ -305,13 +343,17 @@ export class GraphQLCoreClient extends Experimental_CoreClient {
};
}
- async getDynamicFields(
- options: Experimental_SuiClientTypes.GetDynamicFieldsOptions,
- ): Promise {
+ async listDynamicFields(
+ options: SuiClientTypes.ListDynamicFieldsOptions,
+ ): Promise {
const result = await this.#graphqlQuery(
{
query: GetDynamicFieldsDocument,
- variables: { parentId: options.parentId },
+ variables: {
+ parentId: options.parentId,
+ first: options.limit,
+ cursor: options.cursor,
+ },
},
(result) => result.address?.dynamicFields,
);
@@ -323,7 +365,7 @@ export class GraphQLCoreClient extends Experimental_CoreClient {
? dynamicField.value.contents?.type?.repr!
: dynamicField.value?.type?.repr!;
return {
- id: deriveDynamicFieldID(
+ fieldId: deriveDynamicFieldID(
options.parentId,
dynamicField.name?.type?.repr!,
fromBase64(dynamicField.name?.bcs!),
@@ -346,8 +388,8 @@ export class GraphQLCoreClient extends Experimental_CoreClient {
}
async verifyZkLoginSignature(
- options: Experimental_SuiClientTypes.VerifyZkLoginSignatureOptions,
- ): Promise {
+ options: SuiClientTypes.VerifyZkLoginSignatureOptions,
+ ): Promise {
const intentScope =
options.intentScope === 'TransactionData'
? ZkLoginIntentScope.TransactionData
@@ -360,7 +402,7 @@ export class GraphQLCoreClient extends Experimental_CoreClient {
bytes: options.bytes,
signature: options.signature,
intentScope,
- author: options.author,
+ author: options.address,
},
},
(result) => result.verifyZkLoginSignature,
@@ -373,8 +415,8 @@ export class GraphQLCoreClient extends Experimental_CoreClient {
}
async defaultNameServiceName(
- options: Experimental_SuiClientTypes.DefaultNameServiceNameOptions,
- ): Promise {
+ options: SuiClientTypes.DefaultNameServiceNameOptions,
+ ): Promise {
const name = await this.#graphqlQuery(
{
query: DefaultSuinsNameDocument,
@@ -392,8 +434,8 @@ export class GraphQLCoreClient extends Experimental_CoreClient {
}
async getMoveFunction(
- options: Experimental_SuiClientTypes.GetMoveFunctionOptions,
- ): Promise {
+ options: SuiClientTypes.GetMoveFunctionOptions,
+ ): Promise {
const moveFunction = await this.#graphqlQuery(
{
query: GetMoveFunctionDocument,
@@ -486,7 +528,7 @@ class GraphQLResponseError extends Error {
}
}
-function mapOwner(owner: Object_Owner_FieldsFragment): Experimental_SuiClientTypes.ObjectOwner {
+function mapOwner(owner: Object_Owner_FieldsFragment): SuiClientTypes.ObjectOwner {
switch (owner.__typename) {
case 'AddressOwner':
return { $kind: 'AddressOwner', AddressOwner: owner.address?.address! };
@@ -510,32 +552,35 @@ function mapOwner(owner: Object_Owner_FieldsFragment): Experimental_SuiClientTyp
}
}
-function parseTransaction(
+function parseTransaction(
transaction: Transaction_FieldsFragment,
-): Experimental_SuiClientTypes.TransactionResponse {
+ include?: Include,
+): SuiClientTypes.TransactionResponse {
const objectTypes: Record = {};
- transaction.effects?.unchangedConsensusObjects?.nodes.forEach((node) => {
- if (node.__typename === 'ConsensusObjectRead') {
- const type = node.object?.asMoveObject?.contents?.type?.repr;
- const address = node.object?.asMoveObject?.address;
+ if (include?.objectTypes) {
+ transaction.effects?.unchangedConsensusObjects?.nodes.forEach((node) => {
+ if (node.__typename === 'ConsensusObjectRead') {
+ const type = node.object?.asMoveObject?.contents?.type?.repr;
+ const address = node.object?.asMoveObject?.address;
- if (type && address) {
- objectTypes[address] = type;
+ if (type && address) {
+ objectTypes[address] = type;
+ }
}
- }
- });
+ });
- transaction.effects?.objectChanges?.nodes.forEach((node) => {
- const address = node.address;
- const type =
- node.inputState?.asMoveObject?.contents?.type?.repr ??
- node.outputState?.asMoveObject?.contents?.type?.repr;
+ transaction.effects?.objectChanges?.nodes.forEach((node) => {
+ const address = node.address;
+ const type =
+ node.inputState?.asMoveObject?.contents?.type?.repr ??
+ node.outputState?.asMoveObject?.contents?.type?.repr;
- if (address && type) {
- objectTypes[address] = type;
- }
- });
+ if (address && type) {
+ objectTypes[address] = type;
+ }
+ });
+ }
if (transaction.effects?.balanceChanges?.pageInfo.hasNextPage) {
throw new Error('Pagination for balance changes is not supported');
@@ -543,24 +588,37 @@ function parseTransaction(
return {
digest: transaction.digest!,
- effects: parseTransactionEffectsBcs(fromBase64(transaction.effects?.effectsBcs!)),
+ effects: (include?.effects
+ ? parseTransactionEffectsBcs(fromBase64(transaction.effects?.effectsBcs!))
+ : undefined) as SuiClientTypes.TransactionResponse['effects'],
epoch: transaction.effects?.epoch?.epochId?.toString() ?? null,
- objectTypes: Promise.resolve(objectTypes),
- transaction: parseTransactionBcs(fromBase64(transaction.transactionBcs!)),
+ objectTypes: (include?.objectTypes
+ ? Promise.resolve(objectTypes)
+ : undefined) as SuiClientTypes.TransactionResponse['objectTypes'],
+ transaction: (include?.transaction
+ ? parseTransactionBcs(fromBase64(transaction.transactionBcs!))
+ : undefined) as SuiClientTypes.TransactionResponse['transaction'],
signatures: transaction.signatures.map((sig) => sig.signatureBytes!),
- balanceChanges:
- transaction.effects?.balanceChanges?.nodes.map((change) => ({
- coinType: change?.coinType?.repr!,
- address: change.owner?.address!,
- amount: change.amount!,
- })) ?? [],
- // events: transaction.events?.pageInfo.hasNextPage
+ balanceChanges: (include?.balanceChanges
+ ? (transaction.effects?.balanceChanges?.nodes.map((change) => ({
+ coinType: change?.coinType?.repr!,
+ address: change.owner?.address!,
+ amount: change.amount!,
+ })) ?? [])
+ : undefined) as SuiClientTypes.TransactionResponse