@mysten/sui 2.39.1 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +169 -0
- package/README.md +5 -188
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/bcs/bcs.d.mts.map +1 -1
- package/dist/bcs/bcs.mjs +49 -22
- package/dist/bcs/bcs.mjs.map +1 -1
- package/dist/bcs/effects.mjs +49 -20
- package/dist/bcs/effects.mjs.map +1 -1
- package/dist/bcs/index.d.mts +1441 -624
- package/dist/bcs/index.d.mts.map +1 -1
- package/dist/bcs/index.mjs +2 -1
- package/dist/bcs/index.mjs.map +1 -1
- package/dist/bcs/transactions.d.mts +1059 -0
- package/dist/bcs/transactions.d.mts.map +1 -0
- package/dist/bcs/transactions.mjs +33 -14
- package/dist/bcs/transactions.mjs.map +1 -1
- package/dist/bcs/types.d.mts +6 -1
- package/dist/bcs/types.d.mts.map +1 -1
- package/dist/client/core-resolver.mjs +4 -4
- package/dist/client/core-resolver.mjs.map +1 -1
- package/dist/client/core.d.mts +55 -4
- package/dist/client/core.d.mts.map +1 -1
- package/dist/client/core.mjs +98 -1
- package/dist/client/core.mjs.map +1 -1
- package/dist/client/errors.mjs +11 -1
- package/dist/client/errors.mjs.map +1 -1
- package/dist/client/index.d.mts +5 -3
- package/dist/client/index.mjs +6 -3
- package/dist/client/mvr.d.mts +12 -2
- package/dist/client/mvr.d.mts.map +1 -1
- package/dist/client/mvr.mjs +34 -13
- package/dist/client/mvr.mjs.map +1 -1
- package/dist/client/query-filters.mjs +80 -76
- package/dist/client/query-filters.mjs.map +1 -1
- package/dist/client/stream/adapter.d.mts +102 -0
- package/dist/client/stream/adapter.d.mts.map +1 -0
- package/dist/client/stream/errors.d.mts +14 -0
- package/dist/client/stream/errors.d.mts.map +1 -0
- package/dist/client/stream/errors.mjs +25 -0
- package/dist/client/stream/errors.mjs.map +1 -0
- package/dist/client/stream/filter.mjs +18 -0
- package/dist/client/stream/filter.mjs.map +1 -0
- package/dist/client/stream/follow.mjs +48 -0
- package/dist/client/stream/follow.mjs.map +1 -0
- package/dist/client/stream/index.d.mts +4 -0
- package/dist/client/stream/pager.mjs +123 -0
- package/dist/client/stream/pager.mjs.map +1 -0
- package/dist/client/stream/plan.mjs +79 -0
- package/dist/client/stream/plan.mjs.map +1 -0
- package/dist/client/stream/position.d.mts +30 -0
- package/dist/client/stream/position.d.mts.map +1 -0
- package/dist/client/stream/position.mjs +121 -0
- package/dist/client/stream/position.mjs.map +1 -0
- package/dist/client/stream/run.d.mts +2 -0
- package/dist/client/stream/run.mjs +99 -0
- package/dist/client/stream/run.mjs.map +1 -0
- package/dist/client/stream/session.mjs +205 -0
- package/dist/client/stream/session.mjs.map +1 -0
- package/dist/client/stream/status.mjs +47 -0
- package/dist/client/stream/status.mjs.map +1 -0
- package/dist/client/stream/token.mjs +80 -0
- package/dist/client/stream/token.mjs.map +1 -0
- package/dist/client/transaction-data.d.mts +17 -0
- package/dist/client/transaction-data.d.mts.map +1 -0
- package/dist/client/transaction-data.mjs +472 -0
- package/dist/client/transaction-data.mjs.map +1 -0
- package/dist/client/transaction-resolver.mjs +102 -58
- package/dist/client/transaction-resolver.mjs.map +1 -1
- package/dist/client/types.d.mts +560 -240
- package/dist/client/types.d.mts.map +1 -1
- package/dist/client/utils.d.mts +2 -2
- package/dist/client/utils.d.mts.map +1 -1
- package/dist/client/utils.mjs +91 -30
- package/dist/client/utils.mjs.map +1 -1
- package/dist/cryptography/index.d.mts +1 -1
- package/dist/cryptography/keypair.d.mts +1 -1
- package/dist/cryptography/publickey.d.mts +11 -0
- package/dist/cryptography/publickey.d.mts.map +1 -1
- package/dist/cryptography/publickey.mjs +12 -1
- package/dist/cryptography/publickey.mjs.map +1 -1
- package/dist/cryptography/signature.d.mts +8 -8
- package/dist/cryptography/signature.mjs +18 -7
- package/dist/cryptography/signature.mjs.map +1 -1
- package/dist/graphql/client.d.mts +51 -35
- package/dist/graphql/client.d.mts.map +1 -1
- package/dist/graphql/client.mjs +125 -69
- package/dist/graphql/client.mjs.map +1 -1
- package/dist/graphql/core.d.mts +14 -9
- package/dist/graphql/core.d.mts.map +1 -1
- package/dist/graphql/core.mjs +294 -118
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/errors.d.mts +20 -0
- package/dist/graphql/errors.d.mts.map +1 -0
- package/dist/graphql/errors.mjs +19 -0
- package/dist/graphql/errors.mjs.map +1 -0
- package/dist/graphql/filters.mjs +32 -0
- package/dist/graphql/filters.mjs.map +1 -0
- package/dist/graphql/generated/queries.d.mts.map +1 -1
- package/dist/graphql/generated/queries.mjs +1216 -208
- package/dist/graphql/generated/queries.mjs.map +1 -1
- package/dist/graphql/generated/tada-env.d.mts +820 -11
- package/dist/graphql/index.d.mts +2 -1
- package/dist/graphql/index.mjs +2 -1
- package/dist/graphql/sse-parser.mjs +82 -0
- package/dist/graphql/sse-parser.mjs.map +1 -0
- package/dist/graphql/stream/families.mjs +306 -0
- package/dist/graphql/stream/families.mjs.map +1 -0
- package/dist/graphql/stream/index.mjs +38 -0
- package/dist/graphql/stream/index.mjs.map +1 -0
- package/dist/graphql/stream/live.mjs +60 -0
- package/dist/graphql/stream/live.mjs.map +1 -0
- package/dist/graphql/stream/page.mjs +38 -0
- package/dist/graphql/stream/page.mjs.map +1 -0
- package/dist/graphql/stream/query.mjs +47 -0
- package/dist/graphql/stream/query.mjs.map +1 -0
- package/dist/graphql/subscribe.mjs +70 -0
- package/dist/graphql/subscribe.mjs.map +1 -0
- package/dist/grpc/client.d.mts +31 -27
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs +42 -46
- package/dist/grpc/client.mjs.map +1 -1
- package/dist/grpc/core.d.mts +13 -6
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +254 -166
- package/dist/grpc/core.mjs.map +1 -1
- package/dist/grpc/filters.mjs +44 -34
- package/dist/grpc/filters.mjs.map +1 -1
- package/dist/grpc/grpc-web-pull.mjs +245 -0
- package/dist/grpc/grpc-web-pull.mjs.map +1 -0
- package/dist/grpc/index.d.mts +2 -1
- package/dist/grpc/index.mjs +1 -1
- package/dist/grpc/network-error.mjs +31 -0
- package/dist/grpc/network-error.mjs.map +1 -0
- package/dist/grpc/proto/google/rpc/error_details.mjs +306 -0
- package/dist/grpc/proto/google/rpc/error_details.mjs.map +1 -0
- package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/error_reason.d.mts +176 -1
- package/dist/grpc/proto/sui/rpc/v2/error_reason.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/error_reason.mjs +175 -0
- package/dist/grpc/proto/sui/rpc/v2/error_reason.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/executed_transaction.d.mts +2 -2
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts +111 -0
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs +46 -0
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.d.mts +24 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.mjs +25 -7
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/object.mjs +1 -1
- package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts +111 -9
- package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/query_options.mjs +63 -19
- package/dist/grpc/proto/sui/rpc/v2/query_options.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature.d.mts +5 -5
- package/dist/grpc/proto/sui/rpc/v2/signature.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_scheme.d.mts +5 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_scheme.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_scheme.mjs +4 -0
- package/dist/grpc/proto/sui/rpc/v2/signature_scheme.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.d.mts +20 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.mjs +30 -13
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +20 -14
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs +8 -5
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts +11 -5
- package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction.mjs +6 -0
- package/dist/grpc/proto/sui/rpc/v2/transaction.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts +6 -2
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs.map +1 -1
- package/dist/grpc/proto/types.d.mts +7 -7
- package/dist/grpc/proto/types.mjs +3 -2
- package/dist/grpc/pull-call.d.mts +20 -0
- package/dist/grpc/pull-call.d.mts.map +1 -0
- package/dist/grpc/pull-call.mjs +28 -0
- package/dist/grpc/pull-call.mjs.map +1 -0
- package/dist/grpc/stream/call.mjs +238 -0
- package/dist/grpc/stream/call.mjs.map +1 -0
- package/dist/grpc/stream/families.d.mts +26 -0
- package/dist/grpc/stream/families.d.mts.map +1 -0
- package/dist/grpc/stream/families.mjs +145 -0
- package/dist/grpc/stream/families.mjs.map +1 -0
- package/dist/grpc/stream/index.d.mts +41 -0
- package/dist/grpc/stream/index.d.mts.map +1 -0
- package/dist/grpc/stream/index.mjs +127 -0
- package/dist/grpc/stream/index.mjs.map +1 -0
- package/dist/grpc/stream/live.mjs +31 -0
- package/dist/grpc/stream/live.mjs.map +1 -0
- package/dist/grpc/stream/page.mjs +120 -0
- package/dist/grpc/stream/page.mjs.map +1 -0
- package/dist/grpc/stream-types.d.mts +28 -0
- package/dist/grpc/stream-types.d.mts.map +1 -0
- package/dist/grpc/transport.d.mts +8 -3
- package/dist/grpc/transport.d.mts.map +1 -1
- package/dist/grpc/transport.mjs +88 -45
- package/dist/grpc/transport.mjs.map +1 -1
- package/dist/jsonRpc/index.d.mts +34 -12
- package/dist/jsonRpc/index.d.mts.map +1 -0
- package/dist/jsonRpc/index.mjs +39 -5
- package/dist/jsonRpc/index.mjs.map +1 -0
- package/dist/jsonRpc/types.d.mts +420 -0
- package/dist/jsonRpc/types.d.mts.map +1 -0
- package/dist/keypairs/passkey/keypair.d.mts +1 -1
- package/dist/multisig/publickey.d.mts +12 -4
- package/dist/multisig/publickey.d.mts.map +1 -1
- package/dist/multisig/publickey.mjs +5 -5
- package/dist/multisig/publickey.mjs.map +1 -1
- package/dist/multisig/signer.d.mts +1 -1
- package/dist/transactions/ObjectCache.d.mts +1 -1
- package/dist/transactions/ObjectCache.mjs +5 -5
- package/dist/transactions/ObjectCache.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +10 -9
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/transactions/Transaction.mjs +17 -6
- package/dist/transactions/Transaction.mjs.map +1 -1
- package/dist/transactions/data/internal.d.mts +2 -0
- package/dist/transactions/data/internal.d.mts.map +1 -1
- package/dist/transactions/data/internal.mjs +2 -1
- package/dist/transactions/data/internal.mjs.map +1 -1
- package/dist/transactions/executor/parallel.d.mts +2 -2
- package/dist/transactions/executor/serial.d.mts +1 -1
- package/dist/transactions/executor/serial.mjs +2 -2
- package/dist/transactions/executor/serial.mjs.map +1 -1
- package/dist/transactions/index.d.mts +3 -2
- package/dist/transactions/index.mjs +4 -3
- package/dist/transactions/intents/AllowanceBalance.mjs +1 -1
- package/dist/transactions/intents/CoinWithBalance.mjs +1 -1
- package/dist/transactions/resolve.d.mts +6 -0
- package/dist/transactions/resolve.d.mts.map +1 -1
- package/dist/transactions/resolve.mjs.map +1 -1
- package/dist/transactions/restricted-move-calls.d.mts +25 -0
- package/dist/transactions/restricted-move-calls.d.mts.map +1 -0
- package/dist/transactions/restricted-move-calls.mjs +47 -0
- package/dist/transactions/restricted-move-calls.mjs.map +1 -0
- package/dist/transactions/serializer.d.mts +1 -4
- package/dist/transactions/serializer.d.mts.map +1 -1
- package/dist/transactions/serializer.mjs +1 -44
- package/dist/transactions/serializer.mjs.map +1 -1
- package/dist/transactions/utils.d.mts +0 -1
- package/dist/transactions/utils.d.mts.map +1 -1
- package/dist/transactions/utils.mjs.map +1 -1
- package/dist/utils/abort.mjs +89 -0
- package/dist/utils/abort.mjs.map +1 -0
- package/dist/utils/coin-reservation.mjs +1 -4
- package/dist/utils/coin-reservation.mjs.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/sui-types.mjs +1 -1
- package/dist/verify/index.d.mts +2 -2
- package/dist/verify/verify.d.mts +74 -24
- package/dist/verify/verify.d.mts.map +1 -1
- package/dist/verify/verify.mjs +128 -42
- package/dist/verify/verify.mjs.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/dist/zklogin/publickey.d.mts.map +1 -1
- package/dist/zklogin/publickey.mjs +15 -20
- package/dist/zklogin/publickey.mjs.map +1 -1
- package/docs/bcs.md +2 -2
- package/docs/clients/core.md +19 -18
- package/docs/clients/executing.md +53 -8
- package/docs/clients/graphql.md +81 -11
- package/docs/clients/grpc.md +31 -15
- package/docs/clients/index.md +8 -7
- package/docs/clients/querying.md +134 -30
- package/docs/clients/streaming.md +324 -0
- package/docs/cryptography/index.md +85 -58
- package/docs/llms-index.md +4 -2
- package/docs/migrations/sui-2.0/dapp-kit.md +3 -2
- package/docs/migrations/sui-2.0/json-rpc-migration.md +106 -79
- package/docs/migrations/sui-3.0/index.md +247 -0
- package/docs/plugins.md +10 -10
- package/docs/sdk-building.md +3 -4
- package/docs/transactions/coins-and-balances.md +6 -11
- package/docs/transactions/reference.md +36 -1
- package/package.json +4 -5
- package/src/bcs/bcs.ts +80 -41
- package/src/bcs/effects.ts +61 -25
- package/src/bcs/index.ts +2 -0
- package/src/bcs/transactions.ts +36 -17
- package/src/bcs/types.ts +10 -4
- package/src/client/core-resolver.ts +3 -5
- package/src/client/core.ts +180 -8
- package/src/client/errors.ts +12 -0
- package/src/client/index.ts +4 -2
- package/src/client/mvr.ts +37 -10
- package/src/client/query-filters.ts +151 -97
- package/src/client/stream/adapter.ts +110 -0
- package/src/client/stream/errors.ts +40 -0
- package/src/client/stream/filter.ts +17 -0
- package/src/client/stream/follow.ts +63 -0
- package/src/client/stream/index.ts +9 -0
- package/src/client/stream/pager.ts +158 -0
- package/src/client/stream/plan.ts +147 -0
- package/src/client/stream/position.ts +143 -0
- package/src/client/stream/run.ts +147 -0
- package/src/client/stream/session.ts +259 -0
- package/src/client/stream/status.ts +44 -0
- package/src/client/stream/token.ts +104 -0
- package/src/client/transaction-data.ts +610 -0
- package/src/client/transaction-resolver.ts +158 -69
- package/src/client/types.ts +530 -115
- package/src/client/utils.ts +146 -61
- package/src/cryptography/publickey.ts +12 -1
- package/src/cryptography/signature.ts +6 -3
- package/src/graphql/client.ts +204 -135
- package/src/graphql/core.ts +446 -139
- package/src/graphql/errors.ts +24 -0
- package/src/graphql/filters.ts +48 -0
- package/src/graphql/generated/queries.ts +1455 -277
- package/src/graphql/generated/schema.graphql +282 -9
- package/src/graphql/generated/tada-env.ts +933 -4
- package/src/graphql/queries/checkpoints.graphql +34 -0
- package/src/graphql/queries/getDynamicFields.graphql +1 -0
- package/src/graphql/queries/listEvents.graphql +16 -24
- package/src/graphql/queries/streams.graphql +212 -0
- package/src/graphql/queries/transactions.graphql +71 -28
- package/src/graphql/queries/verifySignature.graphql +17 -0
- package/src/graphql/sse-parser.ts +99 -0
- package/src/graphql/stream/families.ts +515 -0
- package/src/graphql/stream/index.ts +55 -0
- package/src/graphql/stream/live.ts +70 -0
- package/src/graphql/stream/page.ts +47 -0
- package/src/graphql/stream/query.ts +52 -0
- package/src/graphql/subscribe.ts +83 -0
- package/src/grpc/client.ts +81 -79
- package/src/grpc/core.ts +388 -274
- package/src/grpc/filters.ts +59 -60
- package/src/grpc/grpc-web-pull.ts +360 -0
- package/src/grpc/index.ts +5 -0
- package/src/grpc/network-error.ts +33 -0
- package/src/grpc/proto/sui/rpc/v2/error_reason.ts +175 -0
- package/src/grpc/proto/sui/rpc/v2/ledger_service.ts +145 -0
- package/src/grpc/proto/sui/rpc/v2/move_package_service.ts +43 -1
- package/src/grpc/proto/sui/rpc/v2/query_options.ts +132 -8
- package/src/grpc/proto/sui/rpc/v2/signature.ts +4 -4
- package/src/grpc/proto/sui/rpc/v2/signature_scheme.ts +4 -0
- package/src/grpc/proto/sui/rpc/v2/signature_verification_service.ts +30 -0
- package/src/grpc/proto/sui/rpc/v2/subscription_service.client.ts +16 -10
- package/src/grpc/proto/sui/rpc/v2/transaction.ts +6 -0
- package/src/grpc/proto/sui/rpc/v2/transaction_execution_service.ts +5 -1
- package/src/grpc/pull-call.ts +54 -0
- package/src/grpc/stream/call.ts +317 -0
- package/src/grpc/stream/families.ts +228 -0
- package/src/grpc/stream/index.ts +182 -0
- package/src/grpc/stream/live.ts +33 -0
- package/src/grpc/stream/page.ts +161 -0
- package/src/grpc/stream-types.ts +33 -0
- package/src/grpc/transport.ts +116 -59
- package/src/jsonRpc/index.ts +60 -17
- package/src/jsonRpc/types.ts +421 -0
- package/src/multisig/publickey.ts +19 -7
- package/src/transactions/ObjectCache.ts +6 -6
- package/src/transactions/Transaction.ts +30 -6
- package/src/transactions/data/internal.ts +2 -0
- package/src/transactions/executor/serial.ts +2 -2
- package/src/transactions/index.ts +8 -1
- package/src/transactions/resolve.ts +6 -0
- package/src/transactions/restricted-move-calls.ts +87 -0
- package/src/transactions/serializer.ts +0 -70
- package/src/transactions/utils.ts +0 -37
- package/src/utils/abort.ts +101 -0
- package/src/verify/index.ts +1 -0
- package/src/verify/verify.ts +190 -62
- package/src/version.ts +1 -1
- package/src/zklogin/publickey.ts +18 -34
- package/dist/client/core-resolver.d.mts +0 -9
- package/dist/client/core-resolver.d.mts.map +0 -1
- package/dist/jsonRpc/client.d.mts +0 -507
- package/dist/jsonRpc/client.d.mts.map +0 -1
- package/dist/jsonRpc/client.mjs +0 -868
- package/dist/jsonRpc/client.mjs.map +0 -1
- package/dist/jsonRpc/core.d.mts +0 -168
- package/dist/jsonRpc/core.d.mts.map +0 -1
- package/dist/jsonRpc/core.mjs +0 -1054
- package/dist/jsonRpc/core.mjs.map +0 -1
- package/dist/jsonRpc/errors.d.mts +0 -27
- package/dist/jsonRpc/errors.d.mts.map +0 -1
- package/dist/jsonRpc/errors.mjs +0 -50
- package/dist/jsonRpc/errors.mjs.map +0 -1
- package/dist/jsonRpc/http-transport.d.mts +0 -62
- package/dist/jsonRpc/http-transport.d.mts.map +0 -1
- package/dist/jsonRpc/http-transport.mjs +0 -60
- package/dist/jsonRpc/http-transport.mjs.map +0 -1
- package/dist/jsonRpc/network.d.mts +0 -9
- package/dist/jsonRpc/network.d.mts.map +0 -1
- package/dist/jsonRpc/network.mjs +0 -18
- package/dist/jsonRpc/network.mjs.map +0 -1
- package/dist/jsonRpc/types/chain.d.mts +0 -169
- package/dist/jsonRpc/types/chain.d.mts.map +0 -1
- package/dist/jsonRpc/types/changes.d.mts +0 -48
- package/dist/jsonRpc/types/changes.d.mts.map +0 -1
- package/dist/jsonRpc/types/coins.d.mts +0 -15
- package/dist/jsonRpc/types/coins.d.mts.map +0 -1
- package/dist/jsonRpc/types/common.d.mts +0 -9
- package/dist/jsonRpc/types/common.d.mts.map +0 -1
- package/dist/jsonRpc/types/generated.d.mts +0 -1976
- package/dist/jsonRpc/types/generated.d.mts.map +0 -1
- package/dist/jsonRpc/types/index.d.mts +0 -6
- package/dist/jsonRpc/types/params.d.mts +0 -898
- package/dist/jsonRpc/types/params.d.mts.map +0 -1
- package/src/graphql/generated/tsconfig.tada.json +0 -11
- package/src/graphql/queries/verifyZkLoginSignature.graphql +0 -15
- package/src/jsonRpc/client.ts +0 -1252
- package/src/jsonRpc/core.ts +0 -1557
- package/src/jsonRpc/errors.ts +0 -57
- package/src/jsonRpc/http-transport.ts +0 -118
- package/src/jsonRpc/network.ts +0 -21
- package/src/jsonRpc/types/chain.ts +0 -190
- package/src/jsonRpc/types/changes.ts +0 -35
- package/src/jsonRpc/types/coins.ts +0 -14
- package/src/jsonRpc/types/common.ts +0 -8
- package/src/jsonRpc/types/generated.ts +0 -2165
- package/src/jsonRpc/types/index.ts +0 -9
- package/src/jsonRpc/types/params.ts +0 -908
|
@@ -114,99 +114,126 @@ console.log('Digest:', result.Transaction.digest);
|
|
|
114
114
|
|
|
115
115
|
## Verifying signatures
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
`PublicKey` that produced it, without needing the original signer.
|
|
117
|
+
Verify a signature for an account with `client.verifySignature`. Pass the signed `personalMessage`
|
|
118
|
+
(a string or bytes) or `transaction` bytes, the `signature`, and the `address` of the account:
|
|
120
119
|
|
|
121
120
|
```typescript
|
|
122
121
|
|
|
123
|
-
const
|
|
124
|
-
const message = new TextEncoder().encode('hello world');
|
|
125
|
-
const { signature } = await keypair.signPersonalMessage(message);
|
|
122
|
+
declare const message: string, signature: string, address: string;
|
|
126
123
|
|
|
127
|
-
const
|
|
124
|
+
const client = new SuiGrpcClient({
|
|
125
|
+
network: 'mainnet',
|
|
126
|
+
baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
127
|
+
});
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
const { valid, reason } = await client.verifySignature({
|
|
130
|
+
personalMessage: message,
|
|
131
|
+
signature,
|
|
132
|
+
address,
|
|
133
|
+
});
|
|
132
134
|
```
|
|
133
135
|
|
|
134
|
-
|
|
136
|
+
`valid` is `false` when the signature is invalid or malformed, or its signer isn't authorized for
|
|
137
|
+
`address`. `reason` says why, for logs only: its text differs between gRPC and GraphQL. The call
|
|
138
|
+
throws for network errors, and when the node can't check address aliases. Use a client for the
|
|
139
|
+
network the account is on. The signer can be one of the account's
|
|
140
|
+
[address aliases](#address-aliases), so a valid result identifies the account, not the signer's key.
|
|
135
141
|
|
|
136
|
-
|
|
137
|
-
throw if the signature is not valid for it:
|
|
142
|
+
Transaction signatures work the same way:
|
|
138
143
|
|
|
139
144
|
```typescript
|
|
140
145
|
|
|
141
|
-
const
|
|
142
|
-
const message = new TextEncoder().encode('hello world');
|
|
143
|
-
const { signature } = await keypair.signPersonalMessage(message);
|
|
146
|
+
declare const client: SuiGrpcClient, tx: Transaction, keypair: Ed25519Keypair;
|
|
144
147
|
|
|
145
|
-
await
|
|
148
|
+
const bytes = await tx.build({ client });
|
|
149
|
+
const { signature } = await keypair.signTransaction(bytes);
|
|
150
|
+
|
|
151
|
+
const { valid } = await client.verifySignature({
|
|
152
|
+
transaction: bytes,
|
|
153
|
+
signature,
|
|
146
154
|
address: keypair.toSuiAddress(),
|
|
147
155
|
});
|
|
148
156
|
```
|
|
149
157
|
|
|
150
|
-
###
|
|
158
|
+
### Online or offline
|
|
151
159
|
|
|
152
|
-
|
|
160
|
+
`client.verifySignature` verifies signatures on a Sui node, over gRPC or GraphQL. The node has the
|
|
161
|
+
onchain state a signature can depend on, so it can check:
|
|
153
162
|
|
|
154
|
-
|
|
163
|
+
- **zkLogin signatures**, which depend on the current epoch and the provider's JWKs.
|
|
164
|
+
- **Address aliases**: other addresses the account has authorized to sign for it, and ones it has
|
|
165
|
+
removed.
|
|
155
166
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const tx = new Transaction();
|
|
161
|
-
// ... add some transactions...
|
|
162
|
-
const bytes = await tx.build({ client });
|
|
167
|
+
The `@mysten/sui/verify` helpers verify the same way when you pass a `client`. Pass `offline: true`
|
|
168
|
+
instead to verify in your process, with no network request. Offline verification only checks that
|
|
169
|
+
the signature is valid and, if you pass `address`, that it was made by the key `address` was derived
|
|
170
|
+
from. It can't confirm zkLogin signatures or address aliases:
|
|
163
171
|
|
|
164
|
-
|
|
165
|
-
|
|
172
|
+
- zkLogin signatures, alone or in a multisig, throw.
|
|
173
|
+
- A signature from one of the account's aliases is rejected, even though the account authorized it.
|
|
174
|
+
- A signature from the account's original key still passes after the account has rotated that key
|
|
175
|
+
out of its alias set.
|
|
166
176
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
});
|
|
171
|
-
```
|
|
177
|
+
Verify online to know whether an account authorized a signature. Verify offline when you can't make
|
|
178
|
+
a network request, need to verify many signatures quickly, or control the keys and don't use zkLogin
|
|
179
|
+
or address aliases.
|
|
172
180
|
|
|
173
|
-
###
|
|
181
|
+
### Verify helpers
|
|
174
182
|
|
|
175
|
-
|
|
176
|
-
SDK uses the GraphQL API. This works for Mainnet signatures without any additional configuration.
|
|
177
|
-
For Testnet signatures, provide a Testnet GraphQL client:
|
|
183
|
+
The `@mysten/sui/verify` helpers return the signer's public key:
|
|
178
184
|
|
|
179
185
|
```typescript
|
|
180
186
|
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
187
|
+
declare const message: string, signature: string, address: string;
|
|
188
|
+
|
|
189
|
+
// Throws if the signature is invalid or not from `address`
|
|
190
|
+
const publicKey = await verifyPersonalMessageSignature(message, signature, {
|
|
191
|
+
offline: true,
|
|
192
|
+
address,
|
|
185
193
|
});
|
|
186
194
|
```
|
|
187
195
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
the
|
|
196
|
+
`verifyTransactionSignature` checks transaction signatures. `isValidPersonalMessageSignature` and
|
|
197
|
+
`isValidTransactionSignature` return `false` for an invalid signature, but still throw for network
|
|
198
|
+
errors, when the node can't check address aliases, and for zkLogin signatures offline.
|
|
199
|
+
|
|
200
|
+
The raw-bytes `verifySignature` and `isValidSignature` helpers, and `PublicKey` methods such as
|
|
201
|
+
`verifyPersonalMessage`, check a single key, not an account's alias set.
|
|
202
|
+
|
|
203
|
+
### zkLogin signatures
|
|
204
|
+
|
|
205
|
+
Use a client for the network the signature was created on, and pass the expected `address`: some
|
|
206
|
+
zkLogin accounts have two valid addresses, and the node accepts both the standard and
|
|
207
|
+
[legacy address](/sui/zklogin#legacy-addresses).
|
|
208
|
+
|
|
209
|
+
### Address aliases
|
|
210
|
+
|
|
211
|
+
An address can authorize other addresses to sign for it by adding them to its alias set, through the
|
|
212
|
+
`0x2::address_alias` Move module. Online verification accepts a signature from any current alias,
|
|
213
|
+
matching what the address can sign onchain. The result reflects the alias set at the time you
|
|
214
|
+
verify, so a stored signature can verify today and fail later.
|
|
215
|
+
|
|
216
|
+
Building a transaction that calls `0x2::address_alias` throws unless the `restrictedMoveCalls` list
|
|
217
|
+
on the client or the `build` call leaves it out (see
|
|
218
|
+
[Restricted Move calls](/sui/transactions/reference#restricted-move-calls)).
|
|
219
|
+
|
|
220
|
+
To accept only the address's own key, pass `checkAddressAliases: false`:
|
|
191
221
|
|
|
192
222
|
```typescript
|
|
193
223
|
|
|
194
|
-
const
|
|
195
|
-
client: new SuiGraphQLClient({
|
|
196
|
-
url: 'https://graphql.testnet.sui.io/graphql',
|
|
197
|
-
}),
|
|
198
|
-
// Throws if the signature is not valid for the provided address
|
|
199
|
-
address: '0x...expectedAddress',
|
|
200
|
-
});
|
|
201
|
-
// or
|
|
224
|
+
declare const client: SuiGrpcClient, message: string, signature: string, address: string;
|
|
202
225
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
226
|
+
await client.verifySignature({
|
|
227
|
+
personalMessage: message,
|
|
228
|
+
signature,
|
|
229
|
+
address,
|
|
230
|
+
checkAddressAliases: false,
|
|
231
|
+
});
|
|
206
232
|
```
|
|
207
233
|
|
|
208
|
-
|
|
209
|
-
|
|
234
|
+
`client.getAddressAliases({ address })` returns an account's current alias set and the `objectId` of
|
|
235
|
+
its alias set object. Pass `objectId` to `0x2::address_alias::add`, `remove` or `replace_all` to
|
|
236
|
+
change the set; `0x2::address_alias::enable` creates it.
|
|
210
237
|
|
|
211
238
|
## Choosing an implementation
|
|
212
239
|
|
package/docs/llms-index.md
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
- [Querying Data](./clients/querying.md): Read objects, coins, balances, dynamic fields, and history with any Sui client
|
|
8
8
|
- [Executing Transactions](./clients/executing.md): Simulate, execute, and wait for transactions with any Sui client
|
|
9
9
|
- [SuiGrpcClient](./clients/grpc.md): >- Connect to Sui over gRPC, with native service clients and real-time subscriptions
|
|
10
|
-
- [SuiGraphQLClient](./clients/graphql.md): Connect to Sui over GraphQL
|
|
10
|
+
- [SuiGraphQLClient](./clients/graphql.md): Connect to Sui over GraphQL with type-safe queries and subscriptions
|
|
11
|
+
- [Resumable Ledger Streams](./clients/streaming.md): Read checkpoint, transaction, and event history, then follow live data with resumable streams
|
|
11
12
|
- [Core API](./clients/core.md): The transport-agnostic client contract that SDKs and libraries build against
|
|
12
13
|
- [Building Transactions](./transactions/basics.md): Construct programmable transaction blocks with the Transaction API
|
|
13
14
|
- [Signing and Execution](./transactions/signing-and-execution.md): Sign transactions and execute them on the Sui network
|
|
@@ -31,10 +32,11 @@
|
|
|
31
32
|
- [Transaction Executors](./executors.md): Manage transaction execution with queuing and parallel strategies
|
|
32
33
|
- [Transaction Plugins](./plugins.md): Extend transaction building with reusable plugins.
|
|
33
34
|
- [Building SDKs](./sdk-building.md): Build custom SDKs on top of the Sui TypeScript SDK
|
|
35
|
+
- [Migrate to 3.0](./migrations/sui-3.0.md): Breaking changes in @mysten/sui 3.0, which removes the deprecated JSON-RPC transport
|
|
34
36
|
- [Migrate to 2.0](./migrations/sui-2.0.md): Migration guide for Sui TypeScript SDK 2.0 covering all @mysten packages
|
|
35
37
|
- [Agent Migration Prompt](./migrations/sui-2.0/agent-prompt.md): AI agent prompt for automated SDK 2.0 migration of your codebase.
|
|
36
38
|
- [@mysten/sui](./migrations/sui-2.0/sui.md): >- Migrate @mysten/sui from 1.x to 2.0 with gRPC clients, Core API, and BCS changes
|
|
37
|
-
- [Migrating from JSON-RPC](./migrations/sui-2.0/json-rpc-migration.md):
|
|
39
|
+
- [Migrating from JSON-RPC](./migrations/sui-2.0/json-rpc-migration.md): Move JSON-RPC code, removed in 3.0, to shared gRPC and GraphQL top-level methods
|
|
38
40
|
- [@mysten/dapp-kit](./migrations/sui-2.0/dapp-kit.md): Migrate @mysten/dapp-kit to the new dapp-kit-react package in 2.0
|
|
39
41
|
- [@mysten/kiosk](./migrations/sui-2.0/kiosk.md): >- Migrate @mysten/kiosk to 2.0 with client extension pattern and KioskTransaction
|
|
40
42
|
- [@mysten/zksend](./migrations/sui-2.0/zksend.md): Migrate @mysten/zksend to 2.0 with client extension pattern and simplified API
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
This guide helps you migrate from the original `@mysten/dapp-kit` (legacy) to the new
|
|
6
6
|
`@mysten/dapp-kit-react` package.
|
|
7
7
|
|
|
8
|
-
> **Note:** The
|
|
9
|
-
>
|
|
8
|
+
> **Note:** The original `@mysten/dapp-kit` package only works with the JSON-RPC client, which was removed in
|
|
9
|
+
> `@mysten/sui` 3.0, so it cannot be used with current SDK releases and receives no further updates.
|
|
10
|
+
> Migrate to `@mysten/dapp-kit-react` for gRPC and GraphQL support.
|
|
10
11
|
|
|
11
12
|
## Overview
|
|
12
13
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# Migrating from JSON-RPC
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Move JSON-RPC code, removed in 3.0, to shared gRPC and GraphQL top-level methods
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
> **Note:** `SuiJsonRpcClient` was removed in `@mysten/sui` 3.0. This guide still applies when moving JSON-RPC
|
|
6
|
+
> code to gRPC or GraphQL; see [Migrate to 3.0](/sui/migrations/sui-3.0) for the other 3.0 changes.
|
|
7
|
+
|
|
8
|
+
For most application code, migrate from `SuiJsonRpcClient` to [`SuiGrpcClient`](/sui/clients/grpc)
|
|
9
|
+
and call the gRPC client's top-level methods. Use [`SuiGraphQLClient`](/sui/clients/graphql) when
|
|
10
|
+
the code needs custom indexed queries, historical object versions, or custom GraphQL selection sets.
|
|
11
|
+
Standard transaction and event queries are available directly on both clients.
|
|
10
12
|
|
|
11
13
|
> **Note:** Create one client for the transport you want to use. Application code should usually call
|
|
12
14
|
> top-level methods like `client.getObject()` and `client.listTransactions()`. SDKs and libraries
|
|
@@ -18,7 +20,6 @@ are available directly on both clients.
|
|
|
18
20
|
| ------------------ | ---------------------------------------------------------------------------------- |
|
|
19
21
|
| `SuiGrpcClient` | Standard reads, writes, simulations, transaction/event queries, and streams |
|
|
20
22
|
| `SuiGraphQLClient` | The same shared methods plus custom indexed queries and historical object versions |
|
|
21
|
-
| `SuiJsonRpcClient` | Maintaining legacy JSON-RPC code while migrating |
|
|
22
23
|
|
|
23
24
|
## Quick migration to gRPC
|
|
24
25
|
|
|
@@ -69,7 +70,7 @@ const result = await client.signAndExecuteTransaction({
|
|
|
69
70
|
```
|
|
70
71
|
|
|
71
72
|
For SDKs and shared libraries, accept `ClientWithCoreApi` and use `client.core` so the caller can
|
|
72
|
-
provide `SuiGrpcClient
|
|
73
|
+
provide either `SuiGrpcClient` or `SuiGraphQLClient`:
|
|
73
74
|
|
|
74
75
|
```typescript
|
|
75
76
|
|
|
@@ -170,17 +171,33 @@ const { address } = await client.resolveNameServiceAddress({
|
|
|
170
171
|
});
|
|
171
172
|
```
|
|
172
173
|
|
|
173
|
-
|
|
174
|
-
GraphQL methods:
|
|
174
|
+
Protocol config, system state, and the chain identifier are top-level methods too:
|
|
175
175
|
|
|
176
176
|
```typescript
|
|
177
|
-
const { protocolConfig } = await client.
|
|
178
|
-
const { systemState } = await client.
|
|
179
|
-
const { chainIdentifier } = await client.
|
|
177
|
+
const { protocolConfig } = await client.getProtocolConfig();
|
|
178
|
+
const { systemState } = await client.getCurrentSystemState();
|
|
179
|
+
const { chainIdentifier } = await client.getChainIdentifier();
|
|
180
180
|
```
|
|
181
181
|
|
|
182
182
|
## Object and coin reads
|
|
183
183
|
|
|
184
|
+
### Migrating `getObject`
|
|
185
|
+
|
|
186
|
+
`getObject` throws when the object does not exist or cannot be read, where JSON-RPC returned
|
|
187
|
+
`{ error }`. Catch `ObjectError` and check its `reason` (`'notFound'`, `'deleted'` or `'unknown'`),
|
|
188
|
+
or use `getObjects`, which returns per-object errors in place instead of throwing.
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
|
|
192
|
+
try {
|
|
193
|
+
const { object } = await client.getObject({ objectId });
|
|
194
|
+
console.log(object.version);
|
|
195
|
+
} catch (error) {
|
|
196
|
+
if (!(error instanceof ObjectError) || error.reason !== 'notFound') throw error;
|
|
197
|
+
// the object does not exist
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
184
201
|
### Migrating `getOwnedObjects`
|
|
185
202
|
|
|
186
203
|
```diff
|
|
@@ -215,6 +232,17 @@ code.
|
|
|
215
232
|
+ });
|
|
216
233
|
```
|
|
217
234
|
|
|
235
|
+
An account can hold its balance as an address balance with no coin objects, so `listCoins` can
|
|
236
|
+
return nothing for an account with funds. Use `getBalance` or `listBalances` to read the total.
|
|
237
|
+
|
|
238
|
+
### Migrating `getBalance`
|
|
239
|
+
|
|
240
|
+
```diff
|
|
241
|
+
- const { totalBalance } = await jsonRpcClient.getBalance({ owner: '0xabc...' });
|
|
242
|
+
+ const { balance } = await client.getBalance({ owner: '0xabc...' });
|
|
243
|
+
+ const totalBalance = balance.balance; // coinBalance + addressBalance
|
|
244
|
+
```
|
|
245
|
+
|
|
218
246
|
### Migrating `getAllBalances`
|
|
219
247
|
|
|
220
248
|
Unlike `getAllBalances`, `listBalances` is paginated. It also returns normalized `balance`,
|
|
@@ -426,11 +454,13 @@ SDK code should call the same method through `client.core`.
|
|
|
426
454
|
|
|
427
455
|
Common transaction filter mappings:
|
|
428
456
|
|
|
429
|
-
| JSON-RPC Filter
|
|
430
|
-
|
|
|
431
|
-
| `FromAddress`
|
|
432
|
-
| `MoveFunction`
|
|
433
|
-
| `ToAddress`, `FromOrToAddress
|
|
457
|
+
| JSON-RPC Filter | gRPC/GraphQL Top-Level Filter |
|
|
458
|
+
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
459
|
+
| `FromAddress` | `sender` |
|
|
460
|
+
| `MoveFunction` | `function` |
|
|
461
|
+
| `ToAddress`, `FromOrToAddress` | `affectedAddress`: transactions the address sent or paid gas for, or that changed its objects or balance. Unlike `ToAddress`, it also returns transactions the address sent. |
|
|
462
|
+
| `ChangedObject`, `AffectedObject` | `affectedObject` |
|
|
463
|
+
| `Checkpoint` | `startCheckpoint` / `endCheckpoint`. `endCheckpoint` is exclusive, so `{ Checkpoint: n }` becomes `startCheckpoint: n, endCheckpoint: BigInt(n) + 1n` |
|
|
434
464
|
|
|
435
465
|
The response contains normalized transaction results plus ledger-position cursors:
|
|
436
466
|
|
|
@@ -481,10 +511,29 @@ Common event filter mappings:
|
|
|
481
511
|
| `MoveEventModule` | `eventType: 'package::module'` |
|
|
482
512
|
| `MoveEventType` | `eventType: 'package::module::Event'` |
|
|
483
513
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
514
|
+
`emitModule` matches the package version and module of the transaction's Move call that emitted the
|
|
515
|
+
event, so after an upgrade it needs the new version's ID. Filter by `eventType` to match events from
|
|
516
|
+
every version: a type keeps the ID of the package version that defined it, so only a type added in
|
|
517
|
+
an upgrade carries that upgrade's ID.
|
|
518
|
+
|
|
519
|
+
Event fields map as follows:
|
|
520
|
+
|
|
521
|
+
| JSON-RPC field | Event field |
|
|
522
|
+
| ---------------------- | -------------------------------------------- |
|
|
523
|
+
| `id.txDigest` | `transactionDigest` |
|
|
524
|
+
| `id.eventSeq` (string) | `eventIndex` (number) |
|
|
525
|
+
| `type` | `eventType` |
|
|
526
|
+
| `transactionModule` | `module` |
|
|
527
|
+
| `parsedJson` | `json` |
|
|
528
|
+
| `bcs` (encoded string) | `bcs` (`Uint8Array`) |
|
|
529
|
+
| `timestampMs` | None; use `checkpoint` and `listCheckpoints` |
|
|
530
|
+
| `packageId`, `sender` | Unchanged |
|
|
531
|
+
|
|
532
|
+
The top-level query methods handle pagination and cursor normalization. They also accept combined
|
|
533
|
+
predicates, `affectedAddress` and `affectedObject` filters, and `startCheckpoint`/`endCheckpoint`
|
|
534
|
+
ranges (see [Querying](/sui/clients/querying)). For filters beyond that, such as OR or negated
|
|
535
|
+
predicates, use the raw [`ledgerService`](/sui/clients/grpc#using-service-clients) on
|
|
536
|
+
`SuiGrpcClient` or a custom GraphQL query.
|
|
488
537
|
|
|
489
538
|
Use `after: result.endCursor` to continue an ascending query and `before: result.endCursor` to
|
|
490
539
|
continue a descending query. `startCursor` identifies the first item in a page and can be used with
|
|
@@ -494,19 +543,19 @@ continue a descending query. `startCursor` identifies the first item in a page a
|
|
|
494
543
|
|
|
495
544
|
Some JSON-RPC methods map to gRPC service clients rather than top-level methods:
|
|
496
545
|
|
|
497
|
-
| JSON-RPC Method | gRPC Replacement
|
|
498
|
-
| ----------------------------------- |
|
|
499
|
-
| `getCheckpoint` | `ledgerService.getCheckpoint`
|
|
500
|
-
| `getCheckpoints` | `ledgerService.listCheckpoints`
|
|
501
|
-
| `getLatestCheckpointSequenceNumber` | `
|
|
502
|
-
| `getCurrentEpoch` | `ledgerService.getEpoch` with no `epoch` argument
|
|
503
|
-
| `getCommitteeInfo` | `ledgerService.getEpoch` with `committee` in the read mask
|
|
504
|
-
| `getLatestSuiSystemState` | `client.
|
|
505
|
-
| `getProtocolConfig` | `client.
|
|
506
|
-
| `getTotalSupply` | `stateService.getCoinInfo` and read `treasury.totalSupply`
|
|
507
|
-
| `getNormalizedMoveModule` | `movePackageService.getPackage`
|
|
508
|
-
| `getNormalizedMoveModulesByPackage` | `movePackageService.getPackage`
|
|
509
|
-
| `getNormalizedMoveStruct` | `movePackageService.getDatatype`
|
|
546
|
+
| JSON-RPC Method | gRPC Replacement |
|
|
547
|
+
| ----------------------------------- | ---------------------------------------------------------------------------------------------------- |
|
|
548
|
+
| `getCheckpoint` | `ledgerService.getCheckpoint` |
|
|
549
|
+
| `getCheckpoints` | `client.listCheckpoints` for summaries; `ledgerService.listCheckpoints` for full checkpoint contents |
|
|
550
|
+
| `getLatestCheckpointSequenceNumber` | `client.listCheckpoints({ order: 'descending', limit: 1 })`, then read `sequenceNumber` |
|
|
551
|
+
| `getCurrentEpoch` | `ledgerService.getEpoch` with no `epoch` argument |
|
|
552
|
+
| `getCommitteeInfo` | `ledgerService.getEpoch` with `committee` in the read mask |
|
|
553
|
+
| `getLatestSuiSystemState` | `client.getCurrentSystemState` or `ledgerService.getEpoch` |
|
|
554
|
+
| `getProtocolConfig` | `client.getProtocolConfig` or `ledgerService.getEpoch` |
|
|
555
|
+
| `getTotalSupply` | `stateService.getCoinInfo` and read `treasury.totalSupply` |
|
|
556
|
+
| `getNormalizedMoveModule` | `movePackageService.getPackage` |
|
|
557
|
+
| `getNormalizedMoveModulesByPackage` | `movePackageService.getPackage` |
|
|
558
|
+
| `getNormalizedMoveStruct` | `movePackageService.getDatatype` |
|
|
510
559
|
|
|
511
560
|
```typescript
|
|
512
561
|
|
|
@@ -515,63 +564,41 @@ const client = new SuiGrpcClient({
|
|
|
515
564
|
network: 'mainnet',
|
|
516
565
|
});
|
|
517
566
|
|
|
518
|
-
const {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
if (latestCheckpoint == null) {
|
|
522
|
-
throw new Error('The server did not return a checkpoint height');
|
|
523
|
-
}
|
|
567
|
+
const {
|
|
568
|
+
checkpoints: [latest],
|
|
569
|
+
} = await client.listCheckpoints({ order: 'descending', limit: 1 });
|
|
524
570
|
|
|
571
|
+
// The summary has no transactions; read them from the full checkpoint.
|
|
525
572
|
const { response } = await client.ledgerService.getCheckpoint({
|
|
526
|
-
checkpointId: { oneofKind: 'sequenceNumber', sequenceNumber:
|
|
527
|
-
readMask: { paths: ['
|
|
573
|
+
checkpointId: { oneofKind: 'sequenceNumber', sequenceNumber: BigInt(latest.sequenceNumber) },
|
|
574
|
+
readMask: { paths: ['transactions.digest'] },
|
|
528
575
|
});
|
|
529
576
|
|
|
530
|
-
console.log(response.checkpoint?.
|
|
577
|
+
console.log(response.checkpoint?.transactions.map((transaction) => transaction.digest));
|
|
531
578
|
```
|
|
532
579
|
|
|
533
580
|
## Subscriptions
|
|
534
581
|
|
|
535
|
-
Replace
|
|
582
|
+
Replace JSON-RPC websocket subscriptions with [ledger streams](/sui/clients/streaming), available on
|
|
583
|
+
both clients. They take the same filters as `listTransactions` and `listEvents`, reconnect
|
|
584
|
+
automatically, and resume from a saved token:
|
|
536
585
|
|
|
537
|
-
| JSON-RPC Method |
|
|
538
|
-
| ---------------------- |
|
|
539
|
-
| `subscribeTransaction` | `
|
|
540
|
-
| `subscribeEvent` | `
|
|
586
|
+
| JSON-RPC Method | Replacement |
|
|
587
|
+
| ---------------------- | -------------------- |
|
|
588
|
+
| `subscribeTransaction` | `streamTransactions` |
|
|
589
|
+
| `subscribeEvent` | `streamEvents` |
|
|
541
590
|
|
|
542
591
|
```typescript
|
|
543
|
-
const
|
|
544
|
-
filter: {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
literals: [
|
|
548
|
-
{
|
|
549
|
-
negated: false,
|
|
550
|
-
predicate: {
|
|
551
|
-
oneofKind: 'eventType',
|
|
552
|
-
eventType: { eventType: '0x2::coin::CoinCreated' },
|
|
553
|
-
},
|
|
554
|
-
},
|
|
555
|
-
],
|
|
556
|
-
},
|
|
557
|
-
],
|
|
558
|
-
},
|
|
559
|
-
readMask: { paths: ['event_type', 'contents', 'json', 'checkpoint', 'transaction_digest'] },
|
|
560
|
-
});
|
|
561
|
-
|
|
562
|
-
for await (const frame of stream.responses) {
|
|
563
|
-
if (frame.event) {
|
|
564
|
-
console.log(frame.event.eventType, frame.event.json);
|
|
565
|
-
}
|
|
592
|
+
for await (const frame of client.streamEvents({
|
|
593
|
+
filter: { eventType: '0x2::coin::CoinCreated' },
|
|
594
|
+
})) {
|
|
595
|
+
console.log(frame.event.eventType, frame.event.json, frame.resumeToken);
|
|
566
596
|
}
|
|
567
597
|
```
|
|
568
598
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
the same protobuf filter and `options.after` cursor. Repeat the raw list call as the index advances
|
|
573
|
-
until it reaches the new subscription's start position. Do not pass the subscription filter or
|
|
574
|
-
cursor to top-level `client.listEvents()`: its Core filter and base64 cursor are different types.
|
|
599
|
+
For filters the Core API does not express, `SuiGrpcClient` streams accept a native gRPC filter as
|
|
600
|
+
`grpcFilter` (see [gRPC options](/sui/clients/streaming#grpc-options)). The raw
|
|
601
|
+
`subscriptionService` remains available; see [Subscriptions](/sui/clients/grpc#subscriptions).
|
|
575
602
|
|
|
576
603
|
## When to use GraphQL
|
|
577
604
|
|
|
@@ -592,7 +619,7 @@ GraphQL query; call `graphqlClient.listTransactions()` or `graphqlClient.listEve
|
|
|
592
619
|
```typescript
|
|
593
620
|
|
|
594
621
|
const graphqlClient = new SuiGraphQLClient({
|
|
595
|
-
url: 'https://
|
|
622
|
+
url: 'https://graphql.mainnet.sui.io/graphql',
|
|
596
623
|
network: 'mainnet',
|
|
597
624
|
});
|
|
598
625
|
|