@mysten/sui 2.39.0 → 3.0.0
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 +162 -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 +4 -2
- package/dist/client/index.mjs +5 -2
- 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 +12 -0
- package/dist/client/transaction-data.d.mts.map +1 -0
- package/dist/client/transaction-data.mjs +469 -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 +3 -1
- package/dist/client/utils.d.mts.map +1 -1
- package/dist/client/utils.mjs +91 -26
- 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 +293 -117
- 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.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.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 +14 -13
- 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 +135 -133
- 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/data/v1.d.mts +239 -239
- package/dist/transactions/data/v1.d.mts.map +1 -1
- package/dist/transactions/data/v2.d.mts +16 -16
- package/dist/transactions/data/v2.d.mts.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 +250 -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 +3 -4
- 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 -1
- 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 +587 -0
- package/src/client/transaction-resolver.ts +158 -69
- package/src/client/types.ts +530 -115
- package/src/client/utils.ts +147 -50
- 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
package/docs/clients/querying.md
CHANGED
|
@@ -255,8 +255,20 @@ for (const field of page.dynamicFields) {
|
|
|
255
255
|
}
|
|
256
256
|
```
|
|
257
257
|
|
|
258
|
-
|
|
259
|
-
|
|
258
|
+
Pass `include: { value: true }` to fetch each field's BCS-encoded value in the same request. For a
|
|
259
|
+
dynamic object field, `value` holds the child object's BCS-encoded content.
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
const page = await client.listDynamicFields({
|
|
263
|
+
parentId: '0x123...',
|
|
264
|
+
include: { value: true },
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
for (const field of page.dynamicFields) {
|
|
268
|
+
console.log(field.value.type); // same as field.valueType
|
|
269
|
+
console.log(field.value.bcs); // BCS-encoded value
|
|
270
|
+
}
|
|
271
|
+
```
|
|
260
272
|
|
|
261
273
|
### `getDynamicField`
|
|
262
274
|
|
|
@@ -276,6 +288,9 @@ console.log(dynamicField.value.type);
|
|
|
276
288
|
console.log(dynamicField.value.bcs); // BCS-encoded value
|
|
277
289
|
```
|
|
278
290
|
|
|
291
|
+
For a dynamic object field, pass the name type wrapped in `0x2::dynamic_object_field::Wrapper<...>`.
|
|
292
|
+
`value` then holds the child object's ID; use `getDynamicObjectField` to fetch the child object.
|
|
293
|
+
|
|
279
294
|
### `getDynamicObjectField`
|
|
280
295
|
|
|
281
296
|
Fetch a dynamic _object_ field and return the referenced object itself, with the same
|
|
@@ -341,12 +356,28 @@ for (const result of page.transactions) {
|
|
|
341
356
|
}
|
|
342
357
|
```
|
|
343
358
|
|
|
344
|
-
Transaction filters
|
|
359
|
+
Transaction filters combine their predicates with AND, and an empty filter matches every
|
|
360
|
+
transaction. A filter takes at most one of `affectedAddress`, `affectedObject`, or `function`, and
|
|
361
|
+
`sender` can be combined with any of them:
|
|
362
|
+
|
|
363
|
+
| Predicate | Description |
|
|
364
|
+
| ----------------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
365
|
+
| `sender` | Transactions sent by an address |
|
|
366
|
+
| `affectedAddress` | Transactions an address sent or paid gas for, or that changed objects it owned before or owns after, or its address balance |
|
|
367
|
+
| `affectedObject` | Transactions whose effects include a change to an object |
|
|
368
|
+
| `function` | Transactions calling a Move function (`pkg`, `pkg::mod`, or `pkg::mod::fn`), including transactions that aborted |
|
|
369
|
+
|
|
370
|
+
```typescript
|
|
371
|
+
// Calls into a package by one sender
|
|
372
|
+
const calls = await client.listTransactions({
|
|
373
|
+
filter: { sender: '0xabc...', function: '0xpkg...' },
|
|
374
|
+
});
|
|
345
375
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
376
|
+
// Every transaction that touched an object
|
|
377
|
+
const history = await client.listTransactions({
|
|
378
|
+
filter: { affectedObject: '0xobject...' },
|
|
379
|
+
});
|
|
380
|
+
```
|
|
350
381
|
|
|
351
382
|
### `listEvents`
|
|
352
383
|
|
|
@@ -365,22 +396,49 @@ for (const event of page.events) {
|
|
|
365
396
|
}
|
|
366
397
|
```
|
|
367
398
|
|
|
368
|
-
Event filters
|
|
399
|
+
Event filters also combine their predicates with AND. A filter cannot combine `emitModule` with
|
|
400
|
+
`eventType`, and `sender` can be combined with either:
|
|
401
|
+
|
|
402
|
+
| Predicate | Description |
|
|
403
|
+
| ------------ | ------------------------------------------------------------------------------------------------ |
|
|
404
|
+
| `sender` | Events from transactions sent by an address |
|
|
405
|
+
| `emitModule` | Events from Move calls into a package (`pkg`) or module (`pkg::mod`), whatever their type |
|
|
406
|
+
| `eventType` | Events with types defined in a package (`pkg`) or module (`pkg::mod`), or a fully qualified type |
|
|
407
|
+
|
|
408
|
+
A generic type name without type arguments (`pkg::mod::Wrapped`) matches every instantiation of that
|
|
409
|
+
type, while `pkg::mod::Wrapped<0x2::sui::SUI>` matches only that instantiation.
|
|
369
410
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
| `sender` | Events from transactions sent by an address |
|
|
373
|
-
| `emitModule` | Events emitted by a module (`pkg::mod`) |
|
|
374
|
-
| `eventType` | Events with types defined in a module (`pkg::mod`) or a fully qualified type name |
|
|
411
|
+
`emitModule` matches the called package version, so after an upgrade use the new ID; to follow a
|
|
412
|
+
type across upgrades, filter by `eventType`.
|
|
375
413
|
|
|
376
|
-
Both filters resolve [MVR](#move-registry-names) names automatically
|
|
377
|
-
|
|
378
|
-
[Pagination](#pagination).
|
|
414
|
+
Both filters resolve [MVR](#move-registry-names) names automatically. Both methods take a `limit`
|
|
415
|
+
and an `order`, can be limited to a range of checkpoints, and page through history with the cursors
|
|
416
|
+
described under [Pagination](#pagination).
|
|
379
417
|
|
|
380
|
-
For filters
|
|
381
|
-
|
|
382
|
-
[
|
|
383
|
-
|
|
418
|
+
For filters the Core API does not express (OR of predicates, negated or repeated predicates, or
|
|
419
|
+
event-based and package-write predicates on transactions), use the
|
|
420
|
+
[raw gRPC list RPCs](/sui/clients/grpc#using-service-clients). To follow new activity as it happens,
|
|
421
|
+
use [`streamTransactions` and `streamEvents`](/sui/clients/streaming), which take the same filters
|
|
422
|
+
and resume after a restart. For native filters, see
|
|
423
|
+
[`grpcFilter`](/sui/clients/streaming#grpc-options).
|
|
424
|
+
|
|
425
|
+
### `listCheckpoints`
|
|
426
|
+
|
|
427
|
+
Page through checkpoint summaries. Each `Checkpoint` carries its `sequenceNumber`, `digest`, and
|
|
428
|
+
`epoch` as strings, and `timestampMs` (milliseconds since the Unix epoch) as a number. It takes no
|
|
429
|
+
filter, but shares the `limit`, `order`, cursors, and checkpoint range of the other history methods:
|
|
430
|
+
|
|
431
|
+
```typescript
|
|
432
|
+
// The 10 most recent checkpoints
|
|
433
|
+
const latest = await client.listCheckpoints({ order: 'descending', limit: 10 });
|
|
434
|
+
|
|
435
|
+
for (const checkpoint of latest.checkpoints) {
|
|
436
|
+
console.log(checkpoint.sequenceNumber, checkpoint.epoch, new Date(checkpoint.timestampMs));
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// Checkpoints 1000 through 1009
|
|
440
|
+
const range = await client.listCheckpoints({ startCheckpoint: 1000, endCheckpoint: 1010 });
|
|
441
|
+
```
|
|
384
442
|
|
|
385
443
|
## Pagination
|
|
386
444
|
|
|
@@ -418,11 +476,12 @@ while (true) {
|
|
|
418
476
|
|
|
419
477
|
### History cursors
|
|
420
478
|
|
|
421
|
-
`listTransactions` and `
|
|
422
|
-
`after` and `before`, which are exclusive ledger-position bounds.
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
479
|
+
`listTransactions`, `listEvents`, and `listCheckpoints` read an ordered ledger instead of a
|
|
480
|
+
collection, so they take `after` and `before`, which are exclusive ledger-position bounds. Both
|
|
481
|
+
bounds work with either `order`, and they can be combined to read a window. Without an explicit
|
|
482
|
+
`order`, a query bounded only by `before` reads descending, and every other query reads ascending.
|
|
483
|
+
Each page reports the position of its first and last item as `startCursor` and `endCursor`, so a
|
|
484
|
+
feed can page in both directions from any point:
|
|
426
485
|
|
|
427
486
|
```typescript
|
|
428
487
|
// The most recent transactions
|
|
@@ -446,11 +505,50 @@ const newer = await client.listTransactions({
|
|
|
446
505
|
});
|
|
447
506
|
```
|
|
448
507
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
508
|
+
To page through a window, keep the fixed bound and replace the moving one with `endCursor`. This
|
|
509
|
+
reads everything between two known positions, newest first:
|
|
510
|
+
|
|
511
|
+
```typescript
|
|
512
|
+
// `start` and `end` are cursors from earlier pages of the same query
|
|
513
|
+
let page = await client.listTransactions({
|
|
514
|
+
filter: { sender: '0xabc...' },
|
|
515
|
+
after: start,
|
|
516
|
+
before: end,
|
|
517
|
+
order: 'descending',
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
while (page.hasNextPage) {
|
|
521
|
+
page = await client.listTransactions({
|
|
522
|
+
filter: { sender: '0xabc...' },
|
|
523
|
+
after: start,
|
|
524
|
+
before: page.endCursor,
|
|
525
|
+
order: 'descending',
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
Cursors are only valid for the query that produced them: pass them back with the same filter and
|
|
531
|
+
checkpoint range.
|
|
532
|
+
|
|
533
|
+
### Checkpoint ranges
|
|
534
|
+
|
|
535
|
+
`startCheckpoint` (inclusive) and `endCheckpoint` (exclusive) limit any history method to a range of
|
|
536
|
+
checkpoints, and combine with filters and cursors. Both accept a string, number, or bigint:
|
|
537
|
+
|
|
538
|
+
```typescript
|
|
539
|
+
// Events of one type emitted in checkpoints 1000 through 1999
|
|
540
|
+
const page = await client.listEvents({
|
|
541
|
+
filter: { eventType: '0xpkg...::my_module::MyEvent' },
|
|
542
|
+
startCheckpoint: 1000,
|
|
543
|
+
endCheckpoint: 2000,
|
|
544
|
+
});
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
> **Note:** Drive pagination off `hasNextPage` rather than page length. A filtered query is bounded in how
|
|
548
|
+
> much ledger it scans per request, so a page can come back shorter than `limit`, even empty, while
|
|
549
|
+
> `hasNextPage` is still `true`. On GraphQL, the page that reaches a cursor bound can also report
|
|
550
|
+
> `hasNextPage: true`, followed by an empty final page. Servers also cap page sizes (50 by default);
|
|
551
|
+
> over-large `limit` values are truncated on gRPC and rejected on GraphQL.
|
|
454
552
|
|
|
455
553
|
## Move functions
|
|
456
554
|
|
|
@@ -493,6 +591,12 @@ const {
|
|
|
493
591
|
});
|
|
494
592
|
```
|
|
495
593
|
|
|
594
|
+
## Signatures
|
|
595
|
+
|
|
596
|
+
`verifySignature` verifies a personal message or transaction signature for an address on the node.
|
|
597
|
+
See [Verifying signatures](/sui/cryptography#verifying-signatures). `getAddressAliases` returns the
|
|
598
|
+
addresses allowed to sign for an address; see [Address aliases](/sui/cryptography#address-aliases).
|
|
599
|
+
|
|
496
600
|
## Move Registry names
|
|
497
601
|
|
|
498
602
|
Wherever a method takes a Move type or package, it also accepts a Move Registry (MVR) name, a
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
# Resumable Ledger Streams
|
|
2
|
+
|
|
3
|
+
> Read checkpoint, transaction, and event history, then follow live data with resumable streams
|
|
4
|
+
|
|
5
|
+
`streamCheckpoints`, `streamTransactions`, and `streamEvents` read ledger history in order and then
|
|
6
|
+
follow new data. They are available on `SuiGrpcClient`, `SuiGraphQLClient`, and on `client.core` of
|
|
7
|
+
either, with the same options and results.
|
|
8
|
+
|
|
9
|
+
## Stream
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
|
|
13
|
+
const client = new SuiGrpcClient({
|
|
14
|
+
network: 'mainnet',
|
|
15
|
+
baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
16
|
+
});
|
|
17
|
+
const controller = new AbortController();
|
|
18
|
+
let count = 0;
|
|
19
|
+
|
|
20
|
+
for await (const frame of client.streamCheckpoints({ signal: controller.signal })) {
|
|
21
|
+
console.log(frame.checkpoint.sequenceNumber, frame.resumeToken);
|
|
22
|
+
if (++count === 10) break;
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Requests start when iteration begins. Without a `start`, a stream follows from the current tip;
|
|
27
|
+
`start: { checkpoint: 1000 }` replays from checkpoint 1000 and then follows live data. Streams
|
|
28
|
+
reconnect after transient failures and continue from the last frame, and
|
|
29
|
+
[`onStatus`](#connection-status) reports the connection state.
|
|
30
|
+
|
|
31
|
+
`break` closes the stream. Aborting the signal also closes it, but rejects the pending iteration
|
|
32
|
+
with the signal's reason.
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
try {
|
|
36
|
+
for await (const frame of client.streamCheckpoints({ signal: controller.signal })) {
|
|
37
|
+
console.log(frame.checkpoint.sequenceNumber);
|
|
38
|
+
}
|
|
39
|
+
} catch (error) {
|
|
40
|
+
if (!controller.signal.aborted) throw error;
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Filter
|
|
45
|
+
|
|
46
|
+
`filter` takes the same `TransactionFilter` and `EventFilter` as `listTransactions` and
|
|
47
|
+
`listEvents`, and `include` takes the same `TransactionInclude` as `listTransactions`. Every
|
|
48
|
+
predicate you set must match. Shared types are in `SuiClientTypes` from `@mysten/sui/client`.
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
for await (const frame of client.streamTransactions({
|
|
52
|
+
filter: { sender: '0x123' },
|
|
53
|
+
include: { effects: true, events: true },
|
|
54
|
+
start: { checkpoint: 1000 },
|
|
55
|
+
})) {
|
|
56
|
+
const tx = frame.transaction.Transaction ?? frame.transaction.FailedTransaction;
|
|
57
|
+
console.log(tx.digest, tx.effects.status);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`include: { transaction: true }` also returns system transactions such as genesis; see
|
|
62
|
+
[transaction data](./executing.mdx#transaction-data) for how to narrow them.
|
|
63
|
+
|
|
64
|
+
## Index whole checkpoints
|
|
65
|
+
|
|
66
|
+
`include: { transactions }` on `streamCheckpoints` delivers each checkpoint with all of its
|
|
67
|
+
transactions, in execution order, as the same `Transaction` or `FailedTransaction` results as
|
|
68
|
+
`streamTransactions`. A checkpoint is yielded only once all of its transactions have been read, so
|
|
69
|
+
an indexer can commit a checkpoint and its resume token together:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
for await (const frame of client.streamCheckpoints({
|
|
73
|
+
start: savedToken ? { resumeToken: savedToken } : { checkpoint: 1000 },
|
|
74
|
+
include: { transactions: { effects: true, events: true, balanceChanges: true } },
|
|
75
|
+
signal: controller.signal,
|
|
76
|
+
})) {
|
|
77
|
+
await database.transaction(async (db) => {
|
|
78
|
+
for (const result of frame.checkpoint.transactions) {
|
|
79
|
+
const tx = result.Transaction ?? result.FailedTransaction;
|
|
80
|
+
await db.processTransaction(frame.checkpoint.sequenceNumber, tx);
|
|
81
|
+
}
|
|
82
|
+
await db.saveResumeToken(frame.resumeToken);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Save and resume progress
|
|
88
|
+
|
|
89
|
+
Each item frame has a `resumeToken`. Store it with the work done for that item, then pass it back as
|
|
90
|
+
the start:
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
|
|
94
|
+
async function processEvents(savedToken?: SuiClientTypes.StreamResumeToken) {
|
|
95
|
+
for await (const frame of client.streamEvents({
|
|
96
|
+
filter: { eventType: '0x123::example::Created' },
|
|
97
|
+
start: savedToken ? { resumeToken: savedToken } : { checkpoint: 1000 },
|
|
98
|
+
signal: controller.signal,
|
|
99
|
+
})) {
|
|
100
|
+
await database.transaction(async (db) => {
|
|
101
|
+
await db.processEvent(frame.event);
|
|
102
|
+
await db.saveResumeToken(frame.resumeToken);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
A resume token start continues after the frame that carried the token, so save a token only once its
|
|
109
|
+
frame is processed. Commit each item's work and its token together, or make processing idempotent,
|
|
110
|
+
so a replay after a crash is harmless.
|
|
111
|
+
|
|
112
|
+
Tokens are opaque strings, so they fit in a text column. Resume on the same transport and chain,
|
|
113
|
+
with the same method, filter and order; otherwise the stream throws `SuiStreamError` with code
|
|
114
|
+
`IncompatibleToken`. `include` and `frames` can change between runs.
|
|
115
|
+
|
|
116
|
+
## Read a finite range
|
|
117
|
+
|
|
118
|
+
Pass an `end` to stop once a range is covered. Checkpoint starts are inclusive and ends are
|
|
119
|
+
exclusive, so this reads checkpoints 1000 through 1999, waiting for the server to index them if
|
|
120
|
+
needed:
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
for await (const frame of client.streamEvents({
|
|
124
|
+
start: { checkpoint: 1000 },
|
|
125
|
+
end: { checkpoint: 2000 },
|
|
126
|
+
signal: controller.signal,
|
|
127
|
+
})) {
|
|
128
|
+
console.log(frame.event);
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
To read the history indexed now and stop, set `follow: false`. Ascending `end` and `follow: false`
|
|
133
|
+
both need a `start`. A token records where to resume, not where to stop, so pass the same `end` or
|
|
134
|
+
`follow: false` again when resuming a finite read.
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
client.streamTransactions({
|
|
138
|
+
start: { checkpoint: 1000 },
|
|
139
|
+
follow: false,
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`order: 'descending'` reads newest first, from the tip or from `start` toward genesis, and never
|
|
144
|
+
follows. `start` is still inclusive and `end` exclusive, so `start: { checkpoint: 2000 }` with
|
|
145
|
+
`end: { checkpoint: 1000 }` reads 2000 down to 1001.
|
|
146
|
+
|
|
147
|
+
A descending read without an `end` completes with `reason: 'genesis'`, or with
|
|
148
|
+
`reason: 'retentionLimit'` at the oldest checkpoint a server that prunes history still keeps:
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
client.streamTransactions({
|
|
152
|
+
filter: { sender: '0x123' },
|
|
153
|
+
order: 'descending',
|
|
154
|
+
});
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Any other read of history the server has pruned fails with `SuiStreamError` code
|
|
158
|
+
`HistoryUnavailable`.
|
|
159
|
+
|
|
160
|
+
## Control frames
|
|
161
|
+
|
|
162
|
+
By default a stream yields only items. `frames` adds control frames:
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
for await (const frame of client.streamEvents({
|
|
166
|
+
start: { checkpoint: 1000 },
|
|
167
|
+
end: { checkpoint: 2000 },
|
|
168
|
+
frames: { completion: true, progress: true },
|
|
169
|
+
})) {
|
|
170
|
+
switch (frame.$kind) {
|
|
171
|
+
case 'Event':
|
|
172
|
+
console.log(frame.event);
|
|
173
|
+
break;
|
|
174
|
+
case 'Progress':
|
|
175
|
+
await saveResumeToken(frame.resumeToken);
|
|
176
|
+
break;
|
|
177
|
+
case 'Complete':
|
|
178
|
+
console.log(frame.reason);
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
| Frame | Option | When |
|
|
185
|
+
| ---------- | ------------ | ------------------------------------------------------------------------------------------- |
|
|
186
|
+
| `Complete` | `completion` | Once, after a finite range finishes, even an empty one. Not sent on abort, failure or exit. |
|
|
187
|
+
| `Progress` | `progress` | At resumable positions no item reported, so sparse filters can save their place. |
|
|
188
|
+
|
|
189
|
+
Save a progress token only after every earlier item is processed.
|
|
190
|
+
|
|
191
|
+
## Choose a delivery mode
|
|
192
|
+
|
|
193
|
+
| `delivery` | Latency | Use when |
|
|
194
|
+
| ----------------------- | ----------------------- | ----------------------------------------------- |
|
|
195
|
+
| `'subscribe'` (default) | Lowest | You want new data as soon as the server has it. |
|
|
196
|
+
| `'poll'` | Up to `pollInterval` ms | Your provider does not serve subscriptions. |
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
client.streamEvents({
|
|
200
|
+
start: { checkpoint: 1000 },
|
|
201
|
+
delivery: 'poll',
|
|
202
|
+
pollInterval: 1000,
|
|
203
|
+
});
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Finite reads always read history. On GraphQL, `'subscribe'` uses
|
|
207
|
+
[subscriptions](./graphql.mdx#subscriptions), so the provider must serve them.
|
|
208
|
+
|
|
209
|
+
## Connection status
|
|
210
|
+
|
|
211
|
+
`onStatus` reports what the stream is doing, for a status indicator, health check or alert. Frames
|
|
212
|
+
carry the data and the resume tokens; statuses are only for monitoring.
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
let state: 'connecting' | 'connected' | 'reconnecting' = 'connecting';
|
|
216
|
+
|
|
217
|
+
for await (const frame of client.streamEvents({
|
|
218
|
+
filter: { eventType: '0x123::example::Created' },
|
|
219
|
+
signal: controller.signal,
|
|
220
|
+
onStatus(status) {
|
|
221
|
+
if (status.$kind === 'Connected') state = 'connected';
|
|
222
|
+
if (status.$kind === 'Retrying') {
|
|
223
|
+
state = 'reconnecting';
|
|
224
|
+
if (status.reason !== 'Unavailable') console.warn(status.reason, status.error);
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
})) {
|
|
228
|
+
console.log(frame.event);
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Each attempt reports `Connecting`, then `Connected` once the server responds. A retryable failure
|
|
233
|
+
reports `Retrying`, and the next attempt starts again from `Connecting`:
|
|
234
|
+
|
|
235
|
+
```text
|
|
236
|
+
Connecting → Connected → Retrying → Connecting → Connected
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
| Status | Fields | When |
|
|
240
|
+
| ------------ | ------------------------------------- | --------------------------------------------------------------- |
|
|
241
|
+
| `Connecting` | `attempt` | An attempt starts. |
|
|
242
|
+
| `Connected` | | The first page, live frame or opened GraphQL subscription. |
|
|
243
|
+
| `Retrying` | `attempt`, `delay`, `reason`, `error` | The attempt failed with `error`; the next starts in `delay` ms. |
|
|
244
|
+
|
|
245
|
+
`attempt` counts consecutive failures without progress, the same count `retry.maxAttempts` bounds,
|
|
246
|
+
so `Connecting` reports 0 on the first attempt. [Retries](#retries) explains `reason`.
|
|
247
|
+
|
|
248
|
+
`Connected` is reported at most once per attempt.
|
|
249
|
+
|
|
250
|
+
`onStatus` is called synchronously and not awaited. Throwing from it ends the stream.
|
|
251
|
+
|
|
252
|
+
## Retries
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
client.streamEvents({
|
|
256
|
+
start: { checkpoint: 1000 },
|
|
257
|
+
retry: { initialDelay: 250, maxDelay: 30_000, maxAttempts: 10 },
|
|
258
|
+
onStatus(status) {
|
|
259
|
+
if (status.$kind === 'Retrying') console.log(status.reason, status.attempt, status.delay);
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Failures that may clear retry with exponential backoff, and the stream resumes from its last frame.
|
|
265
|
+
`maxAttempts` (10 by default) bounds consecutive failures without progress; once it runs out, the
|
|
266
|
+
stream throws the last error. Progress counts per phase: a failed history or gap page resets the
|
|
267
|
+
count if paging moved the resume point, and a failed subscription or live feed resets it only if the
|
|
268
|
+
feed itself moved it. `maxAttempts: 0` disables retries, including reconnecting a live feed that
|
|
269
|
+
ended. Startup requests (the chain identity and the indexed tip) have their own `maxAttempts`
|
|
270
|
+
budget, and the count starts over once the stream begins reading.
|
|
271
|
+
|
|
272
|
+
`reason` says why: `Unavailable` (the server could not be reached, the connection dropped or a live
|
|
273
|
+
feed ended) is routine on long-lived streams; `RateLimited` and `ServerError` can point at a
|
|
274
|
+
problem.
|
|
275
|
+
|
|
276
|
+
Retries don't bound waiting: a stream waiting for the index or for a sparse filter to match can stay
|
|
277
|
+
quiet indefinitely. Use a signal to bound the total time:
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
client.streamEvents({
|
|
281
|
+
start: { checkpoint: 1000 },
|
|
282
|
+
end: { checkpoint: 2000 },
|
|
283
|
+
signal: AbortSignal.timeout(60_000),
|
|
284
|
+
});
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## Errors
|
|
288
|
+
|
|
289
|
+
Once retries are exhausted or a failure is not retryable, transport errors are thrown unchanged:
|
|
290
|
+
`RpcError` on gRPC and `SuiGraphQLRequestError` on GraphQL, including GraphQL response `errors`.
|
|
291
|
+
Filters that use MVR names throw `MvrRequestError` when an MVR request fails. Other stream failures
|
|
292
|
+
throw `SuiStreamError` from `@mysten/sui/client` with a `code`:
|
|
293
|
+
|
|
294
|
+
| Code | Cause |
|
|
295
|
+
| -------------------- | ----------------------------------------------------------------- |
|
|
296
|
+
| `InvalidOptions` | An option, bound or filter was rejected. |
|
|
297
|
+
| `InvalidToken` | Not a resume token, or an unsupported or corrupted one. |
|
|
298
|
+
| `IncompatibleToken` | A token from another stream, or a changed order on resume. |
|
|
299
|
+
| `HistoryUnavailable` | The server has pruned history the stream needs. |
|
|
300
|
+
| `Protocol` | The server returned an invalid response. |
|
|
301
|
+
| `Disconnected` | The live feed kept ending without progress until retries ran out. |
|
|
302
|
+
|
|
303
|
+
```typescript
|
|
304
|
+
|
|
305
|
+
try {
|
|
306
|
+
for await (const frame of client.streamEvents({ start: { resumeToken: saved } })) {
|
|
307
|
+
await process(frame);
|
|
308
|
+
}
|
|
309
|
+
} catch (error) {
|
|
310
|
+
if (error instanceof SuiStreamError && error.code === 'IncompatibleToken') {
|
|
311
|
+
// The saved token belongs to another chain, transport, or filter.
|
|
312
|
+
}
|
|
313
|
+
throw error;
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
## gRPC options
|
|
318
|
+
|
|
319
|
+
`SuiGrpcClient` streams take a `grpcFilter`: a native `TransactionFilter` or `EventFilter` from the
|
|
320
|
+
generated types, for predicates the shared `filter` can't express. On `streamTransactions` and
|
|
321
|
+
`streamEvents` it replaces `filter`. On `streamCheckpoints` it streams only checkpoints that contain
|
|
322
|
+
a matching transaction.
|
|
323
|
+
|
|
324
|
+
For arbitrary GraphQL selection sets, use [native subscriptions](./graphql.mdx#subscriptions).
|