@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
package/src/graphql/core.ts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
// Copyright (c) Mysten Labs, Inc.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { CoreClient } from '../client/core.js';
|
|
4
|
+
import { CoreClient, type LedgerStreamRequest } from '../client/core.js';
|
|
5
|
+
import type { AnyLedgerStreamAdapter } from '../client/stream/adapter.js';
|
|
5
6
|
import { raceSignal } from '../client/mvr.js';
|
|
6
7
|
import type { SuiClientTypes } from '../client/types.js';
|
|
8
|
+
import { grpcTransactionToLedgerTransactionData } from '../client/transaction-data.js';
|
|
7
9
|
import { SUI_TYPE_ARG } from '../utils/constants.js';
|
|
8
|
-
import type { GraphQLQueryOptions, SuiGraphQLClient } from './client.js';
|
|
10
|
+
import type { GraphQLQueryOptions, OpenSubscription, SuiGraphQLClient } from './client.js';
|
|
9
11
|
import type {
|
|
12
|
+
Checkpoint_FieldsFragment,
|
|
13
|
+
GetTransactionEventsQuery,
|
|
14
|
+
GetTransactionEventsQueryVariables,
|
|
15
|
+
GetTransactionObjectChangesQuery,
|
|
16
|
+
GetTransactionObjectChangesQueryVariables,
|
|
17
|
+
Event_FieldsFragment,
|
|
10
18
|
Object_Owner_FieldsFragment,
|
|
19
|
+
Transaction_EventFragment,
|
|
11
20
|
Transaction_FieldsFragment,
|
|
12
21
|
} from './generated/queries.js';
|
|
13
22
|
|
|
@@ -24,62 +33,90 @@ import {
|
|
|
24
33
|
GetCoinMetadataDocument,
|
|
25
34
|
GetCoinsDocument,
|
|
26
35
|
GetCurrentSystemStateDocument,
|
|
36
|
+
GetDynamicFieldsDocument,
|
|
27
37
|
GetMoveFunctionDocument,
|
|
28
38
|
GetProtocolConfigDocument,
|
|
29
39
|
GetOwnedObjectsDocument,
|
|
30
40
|
GetReferenceGasPriceDocument,
|
|
31
41
|
GetTransactionBlockDocument,
|
|
42
|
+
GetTransactionEventsDocument,
|
|
43
|
+
GetTransactionObjectChangesDocument,
|
|
44
|
+
ListCheckpointsDocument,
|
|
32
45
|
ListEventsDocument,
|
|
33
46
|
ListTransactionsDocument,
|
|
34
47
|
MultiGetObjectsDocument,
|
|
35
48
|
ResolveNameServiceAddressDocument,
|
|
36
49
|
ResolveTransactionDocument,
|
|
37
50
|
SimulateTransactionDocument,
|
|
38
|
-
|
|
39
|
-
|
|
51
|
+
IntentScope,
|
|
52
|
+
VerifySignatureDocument,
|
|
40
53
|
} from './generated/queries.js';
|
|
41
54
|
import { ObjectError, SimulationError, TransactionError } from '../client/errors.js';
|
|
42
55
|
import { chunk, fromBase64, toBase64 } from '@mysten/utils';
|
|
43
56
|
import { normalizeStructTag, normalizeSuiAddress } from '../utils/sui-types.js';
|
|
44
57
|
import {
|
|
58
|
+
decodeSignature,
|
|
45
59
|
formatMoveAbortMessage,
|
|
46
60
|
isMockedGasObjectId,
|
|
47
61
|
parseTransactionEffectsBcs,
|
|
62
|
+
resolveVerifySignatureOptions,
|
|
48
63
|
transactionBytesHaveEmptyGasPayment,
|
|
49
64
|
} from '../client/utils.js';
|
|
50
65
|
import type { OpenMoveTypeSignatureBody, OpenMoveTypeSignature } from './types.js';
|
|
51
66
|
import {
|
|
52
67
|
transactionDataToGrpcTransaction,
|
|
53
68
|
transactionToGrpcJson,
|
|
54
|
-
grpcTransactionToTransactionData,
|
|
55
69
|
} from '../client/transaction-resolver.js';
|
|
56
70
|
import { setAddressBalanceTransactionExpirationFromSimulatedEpoch } from '../client/address-balance-transaction-expiration.js';
|
|
57
71
|
import { BalanceChange as BalanceChangeType } from '../grpc/proto/sui/rpc/v2/balance_change.js';
|
|
58
72
|
import { TransactionEffects as TransactionEffectsType } from '../grpc/proto/sui/rpc/v2/effects.js';
|
|
59
73
|
import { Transaction as GrpcTransactionType } from '../grpc/proto/sui/rpc/v2/transaction.js';
|
|
74
|
+
import { isJsonObject } from '@protobuf-ts/runtime';
|
|
75
|
+
import type { EnumInfo, IMessageType, JsonValue } from '@protobuf-ts/runtime';
|
|
60
76
|
import { TransactionDataBuilder } from '../transactions/TransactionData.js';
|
|
61
77
|
import type { BuildTransactionOptions } from '../transactions/index.js';
|
|
62
78
|
import {
|
|
79
|
+
resolveCheckpointRange,
|
|
63
80
|
resolveEventFilter,
|
|
64
81
|
resolvePagination,
|
|
65
82
|
resolveTransactionFilter,
|
|
66
|
-
validateTransactionQuery,
|
|
67
83
|
} from '../client/query-filters.js';
|
|
84
|
+
import {
|
|
85
|
+
toGraphQLCheckpointBounds,
|
|
86
|
+
toGraphQLEventFilter,
|
|
87
|
+
toGraphQLTransactionFilter,
|
|
88
|
+
} from './filters.js';
|
|
89
|
+
import { graphQLLedgerStreamAdapter } from './stream/index.js';
|
|
68
90
|
|
|
69
91
|
const GRAPHQL_OBJECT_BATCH_SIZE = 40;
|
|
70
92
|
|
|
71
93
|
export class GraphQLCoreClient extends CoreClient {
|
|
72
94
|
#graphqlClient: SuiGraphQLClient;
|
|
95
|
+
#subscribe: OpenSubscription;
|
|
73
96
|
|
|
74
97
|
constructor({
|
|
75
98
|
graphqlClient,
|
|
76
99
|
mvr,
|
|
100
|
+
restrictedMoveCalls,
|
|
101
|
+
subscribe,
|
|
77
102
|
}: {
|
|
78
103
|
graphqlClient: SuiGraphQLClient;
|
|
79
104
|
mvr?: SuiClientTypes.MvrOptions;
|
|
105
|
+
restrictedMoveCalls?: readonly string[];
|
|
106
|
+
subscribe: OpenSubscription;
|
|
80
107
|
}) {
|
|
81
|
-
super({ network: graphqlClient.network, base: graphqlClient, mvr });
|
|
108
|
+
super({ network: graphqlClient.network, base: graphqlClient, mvr, restrictedMoveCalls });
|
|
82
109
|
this.#graphqlClient = graphqlClient;
|
|
110
|
+
this.#subscribe = subscribe;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
protected override createLedgerStreamAdapter(
|
|
114
|
+
request: LedgerStreamRequest,
|
|
115
|
+
): AnyLedgerStreamAdapter {
|
|
116
|
+
return graphQLLedgerStreamAdapter(
|
|
117
|
+
{ client: this.#graphqlClient, subscribe: this.#subscribe, mvr: this.mvr },
|
|
118
|
+
request,
|
|
119
|
+
);
|
|
83
120
|
}
|
|
84
121
|
|
|
85
122
|
async #graphqlQuery<
|
|
@@ -104,6 +141,15 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
104
141
|
return extractedData as NonNullable<Data>;
|
|
105
142
|
}
|
|
106
143
|
|
|
144
|
+
#withAllPages(transaction: Transaction_FieldsFragment, signal?: AbortSignal) {
|
|
145
|
+
return withAllPages(transaction, {
|
|
146
|
+
events: (variables) =>
|
|
147
|
+
this.#graphqlQuery({ query: GetTransactionEventsDocument, variables, signal }),
|
|
148
|
+
objectChanges: (variables) =>
|
|
149
|
+
this.#graphqlQuery({ query: GetTransactionObjectChangesDocument, variables, signal }),
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
107
153
|
async getObjects<Include extends SuiClientTypes.ObjectInclude = {}>(
|
|
108
154
|
options: SuiClientTypes.GetObjectsOptions<Include>,
|
|
109
155
|
): Promise<SuiClientTypes.GetObjectsResponse<Include>> {
|
|
@@ -379,19 +425,14 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
379
425
|
signal: options.signal,
|
|
380
426
|
variables: {
|
|
381
427
|
digest: options.digest,
|
|
382
|
-
|
|
383
|
-
includeEffects: options.include?.effects ?? false,
|
|
384
|
-
includeEvents: options.include?.events ?? false,
|
|
385
|
-
includeBalanceChanges: options.include?.balanceChanges ?? false,
|
|
386
|
-
includeObjectTypes: options.include?.objectTypes ?? false,
|
|
387
|
-
includeBcs: options.include?.bcs ?? false,
|
|
428
|
+
...transactionIncludeVariables(options.include),
|
|
388
429
|
},
|
|
389
430
|
},
|
|
390
431
|
(result) => result.transaction,
|
|
391
432
|
() => new TransactionError('notFound', options.digest),
|
|
392
433
|
);
|
|
393
434
|
|
|
394
|
-
return parseTransaction(result, options.include);
|
|
435
|
+
return parseTransaction(await this.#withAllPages(result, options.signal), options.include);
|
|
395
436
|
}
|
|
396
437
|
async executeTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
397
438
|
options: SuiClientTypes.ExecuteTransactionOptions<Include>,
|
|
@@ -403,12 +444,7 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
403
444
|
variables: {
|
|
404
445
|
transactionDataBcs: toBase64(options.transaction),
|
|
405
446
|
signatures: options.signatures,
|
|
406
|
-
|
|
407
|
-
includeEffects: options.include?.effects ?? false,
|
|
408
|
-
includeEvents: options.include?.events ?? false,
|
|
409
|
-
includeBalanceChanges: options.include?.balanceChanges ?? false,
|
|
410
|
-
includeObjectTypes: options.include?.objectTypes ?? false,
|
|
411
|
-
includeBcs: options.include?.bcs ?? false,
|
|
447
|
+
...transactionIncludeVariables(options.include),
|
|
412
448
|
},
|
|
413
449
|
},
|
|
414
450
|
(result) => result.executeTransaction,
|
|
@@ -417,7 +453,7 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
417
453
|
return parseTransaction(result.effects?.transaction!, options.include);
|
|
418
454
|
}
|
|
419
455
|
async simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(
|
|
420
|
-
options: SuiClientTypes.SimulateTransactionOptions<Include
|
|
456
|
+
options: SuiClientTypes.SimulateTransactionOptions<Include>,
|
|
421
457
|
): Promise<SuiClientTypes.SimulateTransactionResult<Include>> {
|
|
422
458
|
if (!(options.transaction instanceof Uint8Array)) {
|
|
423
459
|
await options.transaction.prepareForSerialization({ client: this });
|
|
@@ -445,13 +481,8 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
445
481
|
},
|
|
446
482
|
}
|
|
447
483
|
: transactionToGrpcJson(options.transaction),
|
|
448
|
-
|
|
449
|
-
includeEffects: options.include?.effects ?? false,
|
|
450
|
-
includeEvents: options.include?.events ?? false,
|
|
451
|
-
includeBalanceChanges: options.include?.balanceChanges ?? false,
|
|
452
|
-
includeObjectTypes: options.include?.objectTypes ?? false,
|
|
484
|
+
...transactionIncludeVariables(options.include),
|
|
453
485
|
includeCommandResults: options.include?.commandResults ?? false,
|
|
454
|
-
includeBcs: options.include?.bcs ?? false,
|
|
455
486
|
doGasSelection,
|
|
456
487
|
checksEnabled: options.checksEnabled ?? true,
|
|
457
488
|
},
|
|
@@ -643,61 +674,113 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
643
674
|
};
|
|
644
675
|
}
|
|
645
676
|
|
|
646
|
-
async listDynamicFields(
|
|
647
|
-
options: SuiClientTypes.ListDynamicFieldsOptions
|
|
648
|
-
): Promise<SuiClientTypes.ListDynamicFieldsResponse
|
|
649
|
-
|
|
677
|
+
async listDynamicFields<Include extends SuiClientTypes.DynamicFieldInclude = {}>(
|
|
678
|
+
options: SuiClientTypes.ListDynamicFieldsOptions<Include>,
|
|
679
|
+
): Promise<SuiClientTypes.ListDynamicFieldsResponse<Include>> {
|
|
680
|
+
const includeValue = options.include?.value ?? false;
|
|
681
|
+
|
|
682
|
+
const result = await this.#graphqlQuery(
|
|
683
|
+
{
|
|
684
|
+
query: GetDynamicFieldsDocument,
|
|
685
|
+
signal: options.signal,
|
|
686
|
+
variables: {
|
|
687
|
+
parentId: options.parentId,
|
|
688
|
+
first: options.limit,
|
|
689
|
+
cursor: options.cursor,
|
|
690
|
+
includeValue,
|
|
691
|
+
},
|
|
692
|
+
},
|
|
693
|
+
(result) => result.address?.dynamicFields,
|
|
694
|
+
);
|
|
695
|
+
|
|
696
|
+
return {
|
|
697
|
+
dynamicFields: result.nodes.map((dynamicField) => {
|
|
698
|
+
const nameType = dynamicField.name?.type?.repr!;
|
|
699
|
+
const isDynamicObject = dynamicField.value?.__typename === 'MoveObject';
|
|
700
|
+
const valueType =
|
|
701
|
+
dynamicField.value?.__typename === 'MoveObject'
|
|
702
|
+
? dynamicField.value.contents?.type?.repr!
|
|
703
|
+
: dynamicField.value?.type?.repr!;
|
|
704
|
+
const fieldType = isDynamicObject
|
|
705
|
+
? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${nameType}>,0x2::object::ID>`
|
|
706
|
+
: `0x2::dynamic_field::Field<${nameType},${valueType}>`;
|
|
707
|
+
|
|
708
|
+
let value: SuiClientTypes.DynamicFieldValue | undefined;
|
|
709
|
+
if (includeValue) {
|
|
710
|
+
const valueBcs =
|
|
711
|
+
dynamicField.value?.__typename === 'MoveObject'
|
|
712
|
+
? dynamicField.value.contents?.bcs
|
|
713
|
+
: dynamicField.value?.__typename === 'MoveValue'
|
|
714
|
+
? dynamicField.value.bcs
|
|
715
|
+
: null;
|
|
716
|
+
if (valueBcs == null) {
|
|
717
|
+
throw new Error(`Missing value for dynamic field ${dynamicField.address}`);
|
|
718
|
+
}
|
|
719
|
+
value = { type: valueType, bcs: fromBase64(valueBcs) };
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
return {
|
|
723
|
+
$kind: isDynamicObject ? 'DynamicObject' : 'DynamicField',
|
|
724
|
+
fieldId: dynamicField.address,
|
|
725
|
+
type: normalizeStructTag(fieldType),
|
|
726
|
+
name: {
|
|
727
|
+
type: nameType,
|
|
728
|
+
bcs: fromBase64(dynamicField.name?.bcs!),
|
|
729
|
+
},
|
|
730
|
+
valueType,
|
|
731
|
+
childId:
|
|
732
|
+
dynamicField.value?.__typename === 'MoveObject'
|
|
733
|
+
? dynamicField.value.address
|
|
734
|
+
: undefined,
|
|
735
|
+
value,
|
|
736
|
+
} as SuiClientTypes.DynamicFieldEntry<Include>;
|
|
737
|
+
}),
|
|
738
|
+
cursor: result.pageInfo.endCursor ?? null,
|
|
739
|
+
hasNextPage: result.pageInfo.hasNextPage,
|
|
740
|
+
};
|
|
650
741
|
}
|
|
651
742
|
|
|
652
743
|
async listTransactions<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
653
744
|
options: SuiClientTypes.ListTransactionsOptions<Include>,
|
|
654
745
|
): Promise<SuiClientTypes.ListTransactionsResponse<Include>> {
|
|
655
|
-
const
|
|
656
|
-
const
|
|
746
|
+
const { descending, after, before, limit } = resolvePagination(options);
|
|
747
|
+
const range = resolveCheckpointRange(options);
|
|
657
748
|
const filter = options.filter
|
|
658
749
|
? await resolveTransactionFilter(this.mvr, options.filter, options.signal)
|
|
659
750
|
: undefined;
|
|
660
|
-
|
|
751
|
+
const graphqlFilter = toGraphQLTransactionFilter(filter, range);
|
|
661
752
|
|
|
662
753
|
const transactions = await this.#graphqlQuery(
|
|
663
754
|
{
|
|
664
755
|
query: ListTransactionsDocument,
|
|
665
756
|
signal: options.signal,
|
|
666
757
|
variables: {
|
|
667
|
-
filter:
|
|
668
|
-
sentAddress: filter.$kind === 'sender' ? filter.sender : undefined,
|
|
669
|
-
function:
|
|
670
|
-
filter.$kind === 'function'
|
|
671
|
-
? [filter.package, filter.module, filter.function].filter(Boolean).join('::')
|
|
672
|
-
: undefined,
|
|
673
|
-
},
|
|
758
|
+
filter: graphqlFilter,
|
|
674
759
|
first: descending ? undefined : limit,
|
|
675
760
|
after,
|
|
676
761
|
last: descending ? limit : undefined,
|
|
677
762
|
before,
|
|
678
|
-
|
|
679
|
-
includeEffects: options.include?.effects ?? false,
|
|
680
|
-
includeEvents: options.include?.events ?? false,
|
|
681
|
-
includeBalanceChanges: options.include?.balanceChanges ?? false,
|
|
682
|
-
includeObjectTypes: options.include?.objectTypes ?? false,
|
|
683
|
-
includeBcs: options.include?.bcs ?? false,
|
|
763
|
+
...transactionIncludeVariables(options.include),
|
|
684
764
|
},
|
|
685
765
|
},
|
|
686
766
|
(result) => result.transactions,
|
|
687
767
|
);
|
|
688
768
|
|
|
689
769
|
// Backwards pagination returns nodes in ascending order, so reverse them for descending reads
|
|
690
|
-
const nodes =
|
|
770
|
+
const nodes = transactions.edges.map((edge) => edge.node);
|
|
771
|
+
if (descending) nodes.reverse();
|
|
772
|
+
|
|
773
|
+
// One transaction at a time, so a page can't start dozens of nested reads at once
|
|
774
|
+
const completed = [];
|
|
775
|
+
for (const transaction of nodes) {
|
|
776
|
+
completed.push(
|
|
777
|
+
parseTransaction(await this.#withAllPages(transaction, options.signal), options.include),
|
|
778
|
+
);
|
|
779
|
+
}
|
|
691
780
|
|
|
692
781
|
return {
|
|
693
|
-
transactions:
|
|
694
|
-
|
|
695
|
-
? transactions.pageInfo.hasPreviousPage
|
|
696
|
-
: transactions.pageInfo.hasNextPage,
|
|
697
|
-
startCursor:
|
|
698
|
-
(descending ? transactions.pageInfo.endCursor : transactions.pageInfo.startCursor) ?? null,
|
|
699
|
-
endCursor:
|
|
700
|
-
(descending ? transactions.pageInfo.startCursor : transactions.pageInfo.endCursor) ?? null,
|
|
782
|
+
transactions: completed,
|
|
783
|
+
...listPageCursors(transactions, descending),
|
|
701
784
|
};
|
|
702
785
|
}
|
|
703
786
|
|
|
@@ -705,26 +788,18 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
705
788
|
options: SuiClientTypes.ListEventsOptions,
|
|
706
789
|
): Promise<SuiClientTypes.ListEventsResponse> {
|
|
707
790
|
const { descending, after, before, limit } = resolvePagination(options);
|
|
791
|
+
const range = resolveCheckpointRange(options);
|
|
708
792
|
const filter = options.filter
|
|
709
793
|
? await resolveEventFilter(this.mvr, options.filter, options.signal)
|
|
710
794
|
: undefined;
|
|
795
|
+
const graphqlFilter = toGraphQLEventFilter(filter, range);
|
|
711
796
|
|
|
712
797
|
const events = await this.#graphqlQuery(
|
|
713
798
|
{
|
|
714
799
|
query: ListEventsDocument,
|
|
715
800
|
signal: options.signal,
|
|
716
801
|
variables: {
|
|
717
|
-
filter:
|
|
718
|
-
sender: filter.$kind === 'sender' ? filter.sender : undefined,
|
|
719
|
-
module:
|
|
720
|
-
filter.$kind === 'emitModule' ? `${filter.package}::${filter.module}` : undefined,
|
|
721
|
-
type:
|
|
722
|
-
filter.$kind === 'eventTypeModule'
|
|
723
|
-
? `${filter.package}::${filter.module}`
|
|
724
|
-
: filter.$kind === 'eventType'
|
|
725
|
-
? filter.eventType
|
|
726
|
-
: undefined,
|
|
727
|
-
},
|
|
802
|
+
filter: graphqlFilter,
|
|
728
803
|
first: descending ? undefined : limit,
|
|
729
804
|
after,
|
|
730
805
|
last: descending ? limit : undefined,
|
|
@@ -735,61 +810,94 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
735
810
|
);
|
|
736
811
|
|
|
737
812
|
// Backwards pagination returns nodes in ascending order, so reverse them for descending reads
|
|
738
|
-
const nodes =
|
|
813
|
+
const nodes = events.edges.map((edge) => edge.node);
|
|
814
|
+
if (descending) nodes.reverse();
|
|
739
815
|
|
|
740
816
|
return {
|
|
741
|
-
events: nodes.map((event)
|
|
742
|
-
const
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
if (!packageId || !module || !sender || !eventType || !transactionDigest) {
|
|
749
|
-
throw new Error('listEvents response is missing expected event fields');
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
return {
|
|
753
|
-
packageId: normalizeSuiAddress(packageId),
|
|
754
|
-
module,
|
|
755
|
-
sender: normalizeSuiAddress(sender),
|
|
756
|
-
eventType: normalizeStructTag(eventType),
|
|
757
|
-
bcs: event.contents?.bcs ? fromBase64(event.contents.bcs) : new Uint8Array(),
|
|
758
|
-
json: (event.contents?.json as Record<string, unknown>) ?? null,
|
|
759
|
-
checkpoint: event.transaction?.effects?.checkpoint?.sequenceNumber?.toString() ?? null,
|
|
760
|
-
transactionDigest,
|
|
761
|
-
eventIndex: event.sequenceNumber,
|
|
762
|
-
};
|
|
817
|
+
events: nodes.map((event) => {
|
|
818
|
+
const checkpoint = event.transaction?.effects?.checkpoint?.sequenceNumber;
|
|
819
|
+
return parseGraphQLEvent(
|
|
820
|
+
event,
|
|
821
|
+
checkpoint == null ? null : String(checkpoint),
|
|
822
|
+
'listEvents',
|
|
823
|
+
);
|
|
763
824
|
}),
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
825
|
+
...listPageCursors(events, descending),
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
async listCheckpoints(
|
|
830
|
+
options: SuiClientTypes.ListCheckpointsOptions,
|
|
831
|
+
): Promise<SuiClientTypes.ListCheckpointsResponse> {
|
|
832
|
+
const { descending, after, before, limit } = resolvePagination(options);
|
|
833
|
+
const filter = toGraphQLCheckpointBounds(resolveCheckpointRange(options));
|
|
834
|
+
|
|
835
|
+
const checkpoints = await this.#graphqlQuery(
|
|
836
|
+
{
|
|
837
|
+
query: ListCheckpointsDocument,
|
|
838
|
+
signal: options.signal,
|
|
839
|
+
variables: {
|
|
840
|
+
filter,
|
|
841
|
+
first: descending ? undefined : limit,
|
|
842
|
+
after,
|
|
843
|
+
last: descending ? limit : undefined,
|
|
844
|
+
before,
|
|
845
|
+
},
|
|
846
|
+
},
|
|
847
|
+
(result) => result.checkpoints,
|
|
848
|
+
);
|
|
849
|
+
|
|
850
|
+
// Backwards pagination returns nodes in ascending order, so reverse them for descending reads
|
|
851
|
+
const nodes = checkpoints.edges.map((edge) => edge.node);
|
|
852
|
+
if (descending) nodes.reverse();
|
|
853
|
+
|
|
854
|
+
return {
|
|
855
|
+
checkpoints: nodes.map((checkpoint) => parseGraphQLCheckpoint(checkpoint, 'listCheckpoints')),
|
|
856
|
+
...listPageCursors(checkpoints, descending),
|
|
767
857
|
};
|
|
768
858
|
}
|
|
769
859
|
|
|
770
|
-
async
|
|
771
|
-
options: SuiClientTypes.
|
|
772
|
-
): Promise<SuiClientTypes.
|
|
773
|
-
const intentScope =
|
|
774
|
-
options
|
|
775
|
-
|
|
776
|
-
|
|
860
|
+
async verifySignature(
|
|
861
|
+
options: SuiClientTypes.VerifySignatureOptions,
|
|
862
|
+
): Promise<SuiClientTypes.VerifySignatureResponse> {
|
|
863
|
+
const { intentScope, message, address, checkAddressAliases } =
|
|
864
|
+
resolveVerifySignatureOptions(options);
|
|
865
|
+
const signature = decodeSignature(options.signature);
|
|
866
|
+
if (!signature) {
|
|
867
|
+
return { valid: false, reason: 'Cannot parse signature' };
|
|
868
|
+
}
|
|
777
869
|
|
|
778
|
-
const { data } = await this.#graphqlClient.query({
|
|
779
|
-
query:
|
|
870
|
+
const { data, errors } = await this.#graphqlClient.query({
|
|
871
|
+
query: VerifySignatureDocument,
|
|
780
872
|
signal: options.signal,
|
|
781
873
|
variables: {
|
|
782
|
-
|
|
783
|
-
signature:
|
|
784
|
-
intentScope
|
|
785
|
-
|
|
874
|
+
message: toBase64(message),
|
|
875
|
+
signature: toBase64(signature),
|
|
876
|
+
intentScope:
|
|
877
|
+
intentScope === 'TransactionData'
|
|
878
|
+
? IntentScope.TransactionData
|
|
879
|
+
: IntentScope.PersonalMessage,
|
|
880
|
+
author: address,
|
|
881
|
+
checkAddressAliases,
|
|
786
882
|
},
|
|
787
883
|
});
|
|
788
884
|
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
885
|
+
// The server reports an invalid signature, a signer outside the alias set and undecodable
|
|
886
|
+
// transaction bytes as bad user input on the field.
|
|
887
|
+
const failure = errors?.find(
|
|
888
|
+
(error) =>
|
|
889
|
+
error.path?.[0] === 'verifySignature' && error.extensions?.code === 'BAD_USER_INPUT',
|
|
890
|
+
);
|
|
891
|
+
if (failure) {
|
|
892
|
+
return { valid: false, reason: failure.message };
|
|
893
|
+
}
|
|
894
|
+
handleGraphQLErrors(errors);
|
|
895
|
+
|
|
896
|
+
const success = data?.verifySignature?.success;
|
|
897
|
+
if (typeof success !== 'boolean') {
|
|
898
|
+
throw new Error('The node returned no signature verification verdict');
|
|
899
|
+
}
|
|
900
|
+
return success ? { valid: true } : { valid: false, reason: 'Signature is not valid' };
|
|
793
901
|
}
|
|
794
902
|
|
|
795
903
|
async defaultNameServiceName(
|
|
@@ -992,6 +1100,7 @@ export type GraphQLResponseErrors = Array<{
|
|
|
992
1100
|
message: string;
|
|
993
1101
|
locations?: { line: number; column: number }[];
|
|
994
1102
|
path?: (string | number)[];
|
|
1103
|
+
extensions?: { code?: unknown };
|
|
995
1104
|
}>;
|
|
996
1105
|
|
|
997
1106
|
function mapDisplay(
|
|
@@ -1051,7 +1160,147 @@ function mapOwner(owner: Object_Owner_FieldsFragment): SuiClientTypes.ObjectOwne
|
|
|
1051
1160
|
}
|
|
1052
1161
|
}
|
|
1053
1162
|
|
|
1054
|
-
|
|
1163
|
+
/** `source` names the response in the error thrown when required fields are missing. */
|
|
1164
|
+
export function parseGraphQLCheckpoint(
|
|
1165
|
+
checkpoint: Checkpoint_FieldsFragment,
|
|
1166
|
+
source: string,
|
|
1167
|
+
): SuiClientTypes.Checkpoint {
|
|
1168
|
+
const timestampMs = checkpoint.timestamp ? Date.parse(checkpoint.timestamp) : NaN;
|
|
1169
|
+
const epoch = checkpoint.epoch?.epochId;
|
|
1170
|
+
|
|
1171
|
+
if (!checkpoint.digest || Number.isNaN(timestampMs) || epoch == null) {
|
|
1172
|
+
throw new Error(`${source} response is missing expected checkpoint fields`);
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
return {
|
|
1176
|
+
sequenceNumber: String(checkpoint.sequenceNumber),
|
|
1177
|
+
digest: checkpoint.digest,
|
|
1178
|
+
epoch: String(epoch),
|
|
1179
|
+
timestampMs,
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
/** `source` names the response in the error thrown when required fields are missing. */
|
|
1184
|
+
function parseGraphQLEventFields(
|
|
1185
|
+
event: Transaction_EventFragment,
|
|
1186
|
+
source: string,
|
|
1187
|
+
): SuiClientTypes.Event {
|
|
1188
|
+
const packageId = event.transactionModule?.package?.address;
|
|
1189
|
+
const module = event.transactionModule?.name;
|
|
1190
|
+
const eventType = event.contents?.type?.repr;
|
|
1191
|
+
|
|
1192
|
+
if (!packageId || !module || !eventType) {
|
|
1193
|
+
throw new Error(`${source} response is missing expected event fields`);
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
return {
|
|
1197
|
+
packageId: normalizeSuiAddress(packageId),
|
|
1198
|
+
module,
|
|
1199
|
+
// System transactions have no sender; gRPC reports the zero address for their events.
|
|
1200
|
+
sender: normalizeSuiAddress(event.sender?.address ?? '0x0'),
|
|
1201
|
+
eventType: normalizeStructTag(eventType),
|
|
1202
|
+
bcs: event.contents?.bcs ? fromBase64(event.contents.bcs) : new Uint8Array(),
|
|
1203
|
+
json: (event.contents?.json as Record<string, unknown>) ?? null,
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
/** `source` names the response in the error thrown when required fields are missing. */
|
|
1208
|
+
export function parseGraphQLEvent(
|
|
1209
|
+
event: Event_FieldsFragment,
|
|
1210
|
+
checkpoint: string | null,
|
|
1211
|
+
source: string,
|
|
1212
|
+
): SuiClientTypes.EventEntry {
|
|
1213
|
+
const transactionDigest = event.transaction?.digest;
|
|
1214
|
+
if (!transactionDigest || checkpoint == null) {
|
|
1215
|
+
throw new Error(`${source} response is missing expected event fields`);
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
return {
|
|
1219
|
+
...parseGraphQLEventFields(event, source),
|
|
1220
|
+
checkpoint,
|
|
1221
|
+
transactionDigest,
|
|
1222
|
+
eventIndex: event.sequenceNumber,
|
|
1223
|
+
};
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
/** `TRANSACTION_FIELDS` variables for `include`, shared so every query selects the same fields. */
|
|
1227
|
+
export function transactionIncludeVariables(include: SuiClientTypes.TransactionInclude = {}) {
|
|
1228
|
+
return {
|
|
1229
|
+
includeTransaction: include.transaction ?? false,
|
|
1230
|
+
includeEffects: include.effects ?? false,
|
|
1231
|
+
includeEvents: include.events ?? false,
|
|
1232
|
+
includeBalanceChanges: include.balanceChanges ?? false,
|
|
1233
|
+
includeObjectTypes: include.objectTypes ?? false,
|
|
1234
|
+
includeBcs: include.bcs ?? false,
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
export interface TransactionPageReaders {
|
|
1239
|
+
events: (variables: GetTransactionEventsQueryVariables) => Promise<GetTransactionEventsQuery>;
|
|
1240
|
+
objectChanges: (
|
|
1241
|
+
variables: GetTransactionObjectChangesQueryVariables,
|
|
1242
|
+
) => Promise<GetTransactionObjectChangesQuery>;
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
/** Page size of the events and object changes nested in `TRANSACTION_FIELDS`. */
|
|
1246
|
+
const NESTED_PAGE_SIZE = 50;
|
|
1247
|
+
|
|
1248
|
+
/**
|
|
1249
|
+
* The transaction with all of its events and object changes. The nested lists carry no page info,
|
|
1250
|
+
* which keeps checkpoint scans under the service's output-node limit, so a full nested list is read
|
|
1251
|
+
* again by digest, to the end.
|
|
1252
|
+
*/
|
|
1253
|
+
export async function withAllPages(
|
|
1254
|
+
transaction: Transaction_FieldsFragment,
|
|
1255
|
+
read: TransactionPageReaders,
|
|
1256
|
+
): Promise<Transaction_FieldsFragment> {
|
|
1257
|
+
const effects = transaction.effects;
|
|
1258
|
+
const full = (list?: { nodes: unknown[] } | null) => list?.nodes.length === NESTED_PAGE_SIZE;
|
|
1259
|
+
if (!full(effects?.events) && !full(effects?.objectChanges)) {
|
|
1260
|
+
return transaction;
|
|
1261
|
+
}
|
|
1262
|
+
const { digest } = transaction;
|
|
1263
|
+
const [events, objectChanges] = await Promise.all([
|
|
1264
|
+
full(effects!.events)
|
|
1265
|
+
? readAll(digest, async (after) => {
|
|
1266
|
+
const data = await read.events({ digest, after });
|
|
1267
|
+
return data.transaction?.effects?.events;
|
|
1268
|
+
})
|
|
1269
|
+
: effects!.events,
|
|
1270
|
+
full(effects!.objectChanges)
|
|
1271
|
+
? readAll(digest, async (after) => {
|
|
1272
|
+
const data = await read.objectChanges({ digest, after });
|
|
1273
|
+
return data.transaction?.effects?.objectChanges;
|
|
1274
|
+
})
|
|
1275
|
+
: effects!.objectChanges,
|
|
1276
|
+
]);
|
|
1277
|
+
return { ...transaction, effects: { ...effects!, events, objectChanges } };
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
async function readAll<Node>(
|
|
1281
|
+
digest: string,
|
|
1282
|
+
next: (
|
|
1283
|
+
after: string | null,
|
|
1284
|
+
) => Promise<
|
|
1285
|
+
| { pageInfo: { hasNextPage: boolean; endCursor?: string | null }; nodes: Node[] }
|
|
1286
|
+
| null
|
|
1287
|
+
| undefined
|
|
1288
|
+
>,
|
|
1289
|
+
): Promise<{ nodes: Node[] }> {
|
|
1290
|
+
const nodes: Node[] = [];
|
|
1291
|
+
let after: string | null = null;
|
|
1292
|
+
for (;;) {
|
|
1293
|
+
const page = await next(after);
|
|
1294
|
+
if (!page) {
|
|
1295
|
+
throw new Error(`Missing a page of transaction ${digest}`);
|
|
1296
|
+
}
|
|
1297
|
+
nodes.push(...page.nodes);
|
|
1298
|
+
if (!page.pageInfo.hasNextPage || page.nodes.length === 0) return { nodes };
|
|
1299
|
+
after = page.pageInfo.endCursor ?? null;
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
export function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
1055
1304
|
transaction: Transaction_FieldsFragment,
|
|
1056
1305
|
include?: Include,
|
|
1057
1306
|
): SuiClientTypes.TransactionResult<Include> {
|
|
@@ -1062,6 +1311,7 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}
|
|
|
1062
1311
|
if (effectsJson) {
|
|
1063
1312
|
const effects = TransactionEffectsType.fromJson(
|
|
1064
1313
|
effectsJson as Parameters<typeof TransactionEffectsType.fromJson>[0],
|
|
1314
|
+
{ ignoreUnknownFields: true },
|
|
1065
1315
|
);
|
|
1066
1316
|
effects.changedObjects?.forEach((change) => {
|
|
1067
1317
|
if (change.objectId && change.objectType) {
|
|
@@ -1088,6 +1338,7 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}
|
|
|
1088
1338
|
balanceChanges = balanceChangesJson.map((json) => {
|
|
1089
1339
|
const change = BalanceChangeType.fromJson(
|
|
1090
1340
|
json as Parameters<typeof BalanceChangeType.fromJson>[0],
|
|
1341
|
+
{ ignoreUnknownFields: true },
|
|
1091
1342
|
);
|
|
1092
1343
|
return {
|
|
1093
1344
|
coinType: change.coinType!,
|
|
@@ -1110,19 +1361,17 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}
|
|
|
1110
1361
|
};
|
|
1111
1362
|
|
|
1112
1363
|
let transactionData: SuiClientTypes.TransactionData | undefined;
|
|
1113
|
-
if (include?.transaction
|
|
1114
|
-
|
|
1115
|
-
|
|
1364
|
+
if (include?.transaction) {
|
|
1365
|
+
if (!transaction.transactionJson) {
|
|
1366
|
+
throw new Error('Transaction data is required but missing from GraphQL response');
|
|
1367
|
+
}
|
|
1368
|
+
// `transactionJson` is the gRPC JSON encoding. Unknown fields are ignored, as binary decoding
|
|
1369
|
+
// ignores them over gRPC.
|
|
1370
|
+
const grpcTransaction = GrpcTransactionType.fromJson(
|
|
1371
|
+
unknownEnumsAsNumbers(GrpcTransactionType, transaction.transactionJson as JsonValue),
|
|
1372
|
+
{ ignoreUnknownFields: true },
|
|
1116
1373
|
);
|
|
1117
|
-
|
|
1118
|
-
transactionData = {
|
|
1119
|
-
gasData: resolved.gasData,
|
|
1120
|
-
sender: resolved.sender,
|
|
1121
|
-
expiration: resolved.expiration,
|
|
1122
|
-
commands: resolved.commands,
|
|
1123
|
-
inputs: resolved.inputs,
|
|
1124
|
-
version: resolved.version,
|
|
1125
|
-
};
|
|
1374
|
+
transactionData = grpcTransactionToLedgerTransactionData(grpcTransaction);
|
|
1126
1375
|
}
|
|
1127
1376
|
|
|
1128
1377
|
const bcsBytes =
|
|
@@ -1133,6 +1382,8 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}
|
|
|
1133
1382
|
|
|
1134
1383
|
const result: SuiClientTypes.Transaction<Include> = {
|
|
1135
1384
|
digest: transaction.digest!,
|
|
1385
|
+
// System transactions have no sender over GraphQL; gRPC reports them as 0x0.
|
|
1386
|
+
sender: normalizeSuiAddress(transaction.sender?.address ?? '0x0'),
|
|
1136
1387
|
status,
|
|
1137
1388
|
effects: (include?.effects
|
|
1138
1389
|
? parseTransactionEffectsBcs(fromBase64(transaction.effects?.effectsBcs!))
|
|
@@ -1148,18 +1399,9 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}
|
|
|
1148
1399
|
signatures: transaction.signatures.map((sig) => sig.signatureBytes!),
|
|
1149
1400
|
balanceChanges: balanceChanges as SuiClientTypes.Transaction<Include>['balanceChanges'],
|
|
1150
1401
|
events: (include?.events
|
|
1151
|
-
? (transaction.effects?.events?.nodes.map((event) =>
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
return {
|
|
1155
|
-
packageId,
|
|
1156
|
-
module,
|
|
1157
|
-
sender: event.sender?.address!,
|
|
1158
|
-
eventType,
|
|
1159
|
-
bcs: event.contents?.bcs ? fromBase64(event.contents.bcs) : new Uint8Array(),
|
|
1160
|
-
json: (event.contents?.json as Record<string, unknown>) ?? null,
|
|
1161
|
-
};
|
|
1162
|
-
}) ?? [])
|
|
1402
|
+
? (transaction.effects?.events?.nodes.map((event) =>
|
|
1403
|
+
parseGraphQLEventFields(event, 'Transaction'),
|
|
1404
|
+
) ?? [])
|
|
1163
1405
|
: undefined) as SuiClientTypes.Transaction<Include>['events'],
|
|
1164
1406
|
};
|
|
1165
1407
|
|
|
@@ -1168,6 +1410,34 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}
|
|
|
1168
1410
|
: { $kind: 'FailedTransaction', Transaction: undefined as never, FailedTransaction: result };
|
|
1169
1411
|
}
|
|
1170
1412
|
|
|
1413
|
+
/**
|
|
1414
|
+
* Replaces each enum string this SDK does not know with an unknown number, which is what binary
|
|
1415
|
+
* decoding gives over gRPC, so the shared mapper treats it the same way. A lenient JSON parse would
|
|
1416
|
+
* drop it, and the mapper would then read the field's default.
|
|
1417
|
+
*/
|
|
1418
|
+
function unknownEnumsAsNumbers(type: IMessageType<object>, json: JsonValue): JsonValue {
|
|
1419
|
+
if (!isJsonObject(json) || type.typeName.startsWith('google.protobuf.')) return json;
|
|
1420
|
+
const result = { ...json };
|
|
1421
|
+
for (const field of type.fields) {
|
|
1422
|
+
const key = field.jsonName in json ? field.jsonName : field.localName;
|
|
1423
|
+
const value = json[key];
|
|
1424
|
+
if (value == null) continue;
|
|
1425
|
+
const map = (item: JsonValue): JsonValue =>
|
|
1426
|
+
field.kind === 'message'
|
|
1427
|
+
? unknownEnumsAsNumbers(field.T(), item)
|
|
1428
|
+
: field.kind === 'enum' && typeof item === 'string' && !isKnownEnum(field.T(), item)
|
|
1429
|
+
? -1
|
|
1430
|
+
: item;
|
|
1431
|
+
result[key] = Array.isArray(value) ? value.map(map) : map(value);
|
|
1432
|
+
}
|
|
1433
|
+
return result;
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
function isKnownEnum([, values, prefix]: EnumInfo, name: string) {
|
|
1437
|
+
const local = prefix && name.startsWith(prefix) ? name.slice(prefix.length) : name;
|
|
1438
|
+
return typeof (values as Record<string, unknown>)[local] === 'number';
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1171
1441
|
function parseNormalizedSuiMoveType(type: OpenMoveTypeSignature): SuiClientTypes.OpenSignature {
|
|
1172
1442
|
let reference: 'mutable' | 'immutable' | null = null;
|
|
1173
1443
|
|
|
@@ -1187,12 +1457,13 @@ function parseGraphQLExecutionError(
|
|
|
1187
1457
|
executionError: GraphQLExecutionError | null | undefined,
|
|
1188
1458
|
): SuiClientTypes.ExecutionError {
|
|
1189
1459
|
const name = mapGraphQLExecutionErrorKind(executionError);
|
|
1460
|
+
// The GraphQL schema has no field for the failing command; it is only in the message ("in 3rd command").
|
|
1461
|
+
const commandMatch = executionError?.message?.match(/in (\d+)\w* command/);
|
|
1462
|
+
const command = commandMatch ? parseInt(commandMatch[1], 10) - 1 : undefined;
|
|
1190
1463
|
|
|
1191
1464
|
if (name === 'MoveAbort' && executionError?.abortCode != null) {
|
|
1192
1465
|
const location = parseGraphQLMoveLocation(executionError);
|
|
1193
1466
|
const cleverError = parseGraphQLCleverError(executionError);
|
|
1194
|
-
const commandMatch = executionError.message?.match(/in (\d+)\w* command/);
|
|
1195
|
-
const command = commandMatch ? parseInt(commandMatch[1], 10) - 1 : undefined;
|
|
1196
1467
|
|
|
1197
1468
|
return {
|
|
1198
1469
|
$kind: 'MoveAbort',
|
|
@@ -1227,6 +1498,7 @@ function parseGraphQLExecutionError(
|
|
|
1227
1498
|
return {
|
|
1228
1499
|
$kind: 'Unknown',
|
|
1229
1500
|
message: executionError?.message ?? 'Transaction failed',
|
|
1501
|
+
command,
|
|
1230
1502
|
Unknown: null,
|
|
1231
1503
|
};
|
|
1232
1504
|
}
|
|
@@ -1261,12 +1533,17 @@ function parseGraphQLMoveLocation(
|
|
|
1261
1533
|
function parseGraphQLCleverError(
|
|
1262
1534
|
executionError: GraphQLExecutionError,
|
|
1263
1535
|
): SuiClientTypes.CleverError | undefined {
|
|
1264
|
-
|
|
1265
|
-
if (
|
|
1536
|
+
// The server reports a source line only when it resolved a clever error.
|
|
1537
|
+
if (executionError.sourceLineNumber == null) {
|
|
1266
1538
|
return undefined;
|
|
1267
1539
|
}
|
|
1268
1540
|
|
|
1541
|
+
// For a clever error that declares a code, the server reports that code (a u8) as the
|
|
1542
|
+
// abort code; otherwise the abort code is the raw clever error bitset.
|
|
1543
|
+
const abortCode = BigInt(executionError.abortCode!);
|
|
1544
|
+
|
|
1269
1545
|
return {
|
|
1546
|
+
errorCode: abortCode <= 255n ? Number(abortCode) : undefined,
|
|
1270
1547
|
constantName: executionError.identifier ?? undefined,
|
|
1271
1548
|
value: executionError.constant ?? undefined,
|
|
1272
1549
|
lineNumber: executionError.sourceLineNumber ?? undefined,
|
|
@@ -1325,3 +1602,33 @@ function parseNormalizedSuiMoveTypeBody(
|
|
|
1325
1602
|
|
|
1326
1603
|
throw new Error(`Unknown type: ${JSON.stringify(type)}`);
|
|
1327
1604
|
}
|
|
1605
|
+
|
|
1606
|
+
/**
|
|
1607
|
+
* Page cursors for the list queries, matching the gRPC client: a page that can continue resumes
|
|
1608
|
+
* from the server's cursor (which may be a scan position past the last item), a final page ends at
|
|
1609
|
+
* its last item, and an empty final page has no cursors.
|
|
1610
|
+
*/
|
|
1611
|
+
function listPageCursors(
|
|
1612
|
+
connection: {
|
|
1613
|
+
pageInfo: {
|
|
1614
|
+
hasNextPage: boolean;
|
|
1615
|
+
hasPreviousPage: boolean;
|
|
1616
|
+
startCursor?: string | null;
|
|
1617
|
+
endCursor?: string | null;
|
|
1618
|
+
};
|
|
1619
|
+
edges: { cursor: string }[];
|
|
1620
|
+
},
|
|
1621
|
+
descending: boolean,
|
|
1622
|
+
) {
|
|
1623
|
+
const { pageInfo } = connection;
|
|
1624
|
+
const edges = descending ? [...connection.edges].reverse() : connection.edges;
|
|
1625
|
+
const resumeFrom = (descending ? pageInfo.startCursor : pageInfo.endCursor) ?? null;
|
|
1626
|
+
const hasNextPage =
|
|
1627
|
+
resumeFrom !== null && (descending ? pageInfo.hasPreviousPage : pageInfo.hasNextPage);
|
|
1628
|
+
|
|
1629
|
+
return {
|
|
1630
|
+
hasNextPage,
|
|
1631
|
+
startCursor: edges[0]?.cursor ?? null,
|
|
1632
|
+
endCursor: hasNextPage ? resumeFrom : (edges.at(-1)?.cursor ?? null),
|
|
1633
|
+
};
|
|
1634
|
+
}
|