@mysten/sui 2.39.1 → 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 +160 -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 +2 -2
- 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/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/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 +16 -10
- 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 +11 -10
- 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 +2 -3
- 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/dist/grpc/core.mjs
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { normalizeStructTag, normalizeSuiAddress } from "../utils/sui-types.mjs";
|
|
2
2
|
import { bcs as suiBcs } from "../bcs/index.mjs";
|
|
3
|
+
import { ObjectError, SimulationError, TransactionError } from "../client/errors.mjs";
|
|
3
4
|
import { raceSignal } from "../client/mvr.mjs";
|
|
5
|
+
import { SuiStreamError } from "../client/stream/errors.mjs";
|
|
6
|
+
import { resolveCheckpointRange, resolveEventFilter, resolvePagination, resolveTransactionFilter } from "../client/query-filters.mjs";
|
|
4
7
|
import { CoreClient } from "../client/core.mjs";
|
|
5
8
|
import { SUI_TYPE_ARG } from "../utils/constants.mjs";
|
|
6
|
-
import { formatMoveAbortMessage, isMockedGasObjectId, transactionBytesHaveEmptyGasPayment } from "../client/utils.mjs";
|
|
7
|
-
import { ObjectError, SimulationError, TransactionError } from "../client/errors.mjs";
|
|
9
|
+
import { decodeSignature, formatMoveAbortMessage, isMockedGasObjectId, resolveVerifySignatureOptions, transactionBytesHaveEmptyGasPayment } from "../client/utils.mjs";
|
|
8
10
|
import { Value } from "./proto/google/protobuf/struct.mjs";
|
|
9
11
|
import { Ability, FunctionDescriptor_Visibility, OpenSignatureBody_Type, OpenSignature_Reference } from "./proto/sui/rpc/v2/move_package.mjs";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
+
import { applyGrpcResolvedTransaction, grpcTimestampToMilliseconds, mapOwner, transactionDataToGrpcTransaction, transactionToGrpcTransaction } from "../client/transaction-resolver.mjs";
|
|
13
|
+
import { grpcTransactionToLedgerTransactionData } from "../client/transaction-data.mjs";
|
|
12
14
|
import { setAddressBalanceTransactionExpirationFromSimulatedEpoch } from "../client/address-balance-transaction-expiration.mjs";
|
|
13
|
-
import { CommandArgumentError_CommandArgumentErrorKind } from "./proto/sui/rpc/v2/execution_status.mjs";
|
|
15
|
+
import { CommandArgumentError_CommandArgumentErrorKind, ExecutionError_ExecutionErrorKind, PackageUpgradeError_PackageUpgradeErrorKind, TypeArgumentError_TypeArgumentErrorKind } from "./proto/sui/rpc/v2/execution_status.mjs";
|
|
14
16
|
import { ChangedObject_IdOperation, ChangedObject_InputObjectState, ChangedObject_OutputObjectState, UnchangedConsensusObject_UnchangedConsensusObjectKind } from "./proto/sui/rpc/v2/effects.mjs";
|
|
15
|
-
import { resolveEventFilter, resolvePagination, resolveTransactionFilter, validateTransactionQuery } from "../client/query-filters.mjs";
|
|
16
17
|
import { ExecutedTransaction } from "./proto/sui/rpc/v2/executed_transaction.mjs";
|
|
17
18
|
import { SimulateTransactionRequest_TransactionChecks, SimulateTransactionResponse } from "./proto/sui/rpc/v2/transaction_execution_service.mjs";
|
|
18
19
|
import { Ordering, QueryEndReason } from "./proto/sui/rpc/v2/query_options.mjs";
|
|
20
|
+
import { DynamicField_DynamicFieldKind } from "./proto/sui/rpc/v2/state_service.mjs";
|
|
19
21
|
import { toGrpcEventFilter, toGrpcTransactionFilter } from "./filters.mjs";
|
|
20
|
-
import {
|
|
22
|
+
import { GrpcLedgerStreamAdapter } from "./stream/index.mjs";
|
|
21
23
|
import { chunk, fromBase64, toBase64 } from "@mysten/utils";
|
|
22
24
|
import { RpcError } from "@protobuf-ts/runtime-rpc";
|
|
23
25
|
import { GrpcStatusCode } from "@protobuf-ts/grpcweb-transport";
|
|
@@ -29,14 +31,24 @@ function isNameServiceResolutionMiss(error) {
|
|
|
29
31
|
if (typeof code !== "string" || typeof message !== "string") return false;
|
|
30
32
|
if (code === GrpcStatusCode[GrpcStatusCode.NOT_FOUND]) return true;
|
|
31
33
|
if (code !== GrpcStatusCode[GrpcStatusCode.RESOURCE_EXHAUSTED]) return false;
|
|
32
|
-
|
|
33
|
-
return !hasDecodedStatusMessage(error) && message === "name%20has%20expired";
|
|
34
|
+
return message === "name has expired" || message === "name%20has%20expired";
|
|
34
35
|
}
|
|
35
36
|
var GrpcCoreClient = class extends CoreClient {
|
|
36
37
|
#client;
|
|
37
|
-
|
|
38
|
+
#transport;
|
|
39
|
+
constructor({ client, transport, ...options }) {
|
|
38
40
|
super(options);
|
|
39
41
|
this.#client = client;
|
|
42
|
+
this.#transport = transport;
|
|
43
|
+
}
|
|
44
|
+
createLedgerStreamAdapter(request) {
|
|
45
|
+
const transport = this.#transport;
|
|
46
|
+
if (!transport) throw new SuiStreamError("InvalidOptions", "Ledger streams need a `transport` option");
|
|
47
|
+
return new GrpcLedgerStreamAdapter({
|
|
48
|
+
transport,
|
|
49
|
+
mvr: this.mvr,
|
|
50
|
+
chainIdentifier: async (signal) => (await this.getChainIdentifier({ signal })).chainIdentifier
|
|
51
|
+
}, request);
|
|
40
52
|
}
|
|
41
53
|
async getObjects(options) {
|
|
42
54
|
const batches = chunk(options.objectIds, 50);
|
|
@@ -331,112 +343,134 @@ var GrpcCoreClient = class extends CoreClient {
|
|
|
331
343
|
} };
|
|
332
344
|
}
|
|
333
345
|
async listDynamicFields(options) {
|
|
334
|
-
|
|
346
|
+
const includeValue = options.include?.value ?? false;
|
|
347
|
+
const paths = [
|
|
348
|
+
"field_id",
|
|
349
|
+
"name",
|
|
350
|
+
"value_type",
|
|
351
|
+
"kind",
|
|
352
|
+
"child_id"
|
|
353
|
+
];
|
|
354
|
+
if (includeValue) paths.push("value", "child_object.contents");
|
|
355
|
+
const response = await this.#client.stateService.listDynamicFields({
|
|
356
|
+
parent: options.parentId,
|
|
357
|
+
pageToken: options.cursor ? fromBase64(options.cursor) : void 0,
|
|
358
|
+
pageSize: options.limit,
|
|
359
|
+
readMask: { paths }
|
|
360
|
+
}, { abort: options.signal });
|
|
361
|
+
return {
|
|
362
|
+
dynamicFields: response.response.dynamicFields.map((field) => {
|
|
363
|
+
const isDynamicObject = field.kind === DynamicField_DynamicFieldKind.OBJECT;
|
|
364
|
+
const nameType = field.name?.name;
|
|
365
|
+
const valueType = field.valueType;
|
|
366
|
+
const fieldType = isDynamicObject ? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${nameType}>,0x2::object::ID>` : `0x2::dynamic_field::Field<${nameType},${valueType}>`;
|
|
367
|
+
let value;
|
|
368
|
+
if (includeValue) {
|
|
369
|
+
const valueBcs = isDynamicObject ? field.childObject?.contents?.value : field.value?.value;
|
|
370
|
+
if (valueBcs == null) throw new Error(`Missing value for dynamic field ${field.fieldId}`);
|
|
371
|
+
value = {
|
|
372
|
+
type: valueType,
|
|
373
|
+
bcs: valueBcs
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
return {
|
|
377
|
+
$kind: isDynamicObject ? "DynamicObject" : "DynamicField",
|
|
378
|
+
fieldId: field.fieldId,
|
|
379
|
+
type: normalizeStructTag(fieldType),
|
|
380
|
+
name: {
|
|
381
|
+
type: nameType,
|
|
382
|
+
bcs: field.name?.value
|
|
383
|
+
},
|
|
384
|
+
valueType,
|
|
385
|
+
childId: isDynamicObject ? field.childId : void 0,
|
|
386
|
+
value
|
|
387
|
+
};
|
|
388
|
+
}),
|
|
389
|
+
cursor: response.response.nextPageToken ? toBase64(response.response.nextPageToken) : null,
|
|
390
|
+
hasNextPage: response.response.nextPageToken !== void 0
|
|
391
|
+
};
|
|
335
392
|
}
|
|
336
393
|
async listTransactions(options) {
|
|
337
394
|
const paths = transactionReadMaskPaths(options.include);
|
|
338
|
-
const filter = options.filter ? await resolveTransactionFilter(this.mvr, options.filter, options.signal) : void 0;
|
|
339
395
|
const pagination = resolvePagination(options);
|
|
340
|
-
|
|
341
|
-
const
|
|
396
|
+
const range = resolveCheckpointRange(options);
|
|
397
|
+
const filter = options.filter ? await resolveTransactionFilter(this.mvr, options.filter, options.signal) : void 0;
|
|
398
|
+
const { items, ...page } = await collectListPage(this.#client.ledgerService.listTransactions({
|
|
342
399
|
readMask: { paths },
|
|
343
|
-
filter:
|
|
400
|
+
filter: toGrpcTransactionFilter(filter),
|
|
401
|
+
startCheckpoint: range.start,
|
|
402
|
+
endCheckpoint: range.end,
|
|
344
403
|
options: toGrpcQueryOptions(pagination, pagination.limit + 1)
|
|
345
|
-
}, { abort: options.signal });
|
|
346
|
-
const transactions = [];
|
|
347
|
-
let startCursor = null;
|
|
348
|
-
let endCursor = null;
|
|
349
|
-
let frontier = null;
|
|
350
|
-
let end;
|
|
351
|
-
let sawLookaheadItem = false;
|
|
352
|
-
for await (const frame of call.responses) {
|
|
353
|
-
if (frame.watermark?.cursor) frontier = toBase64(frame.watermark.cursor);
|
|
354
|
-
if (frame.transaction) if (transactions.length >= pagination.limit) sawLookaheadItem = true;
|
|
355
|
-
else {
|
|
356
|
-
startCursor ??= frontier;
|
|
357
|
-
endCursor = frontier;
|
|
358
|
-
transactions.push(parseGrpcTransactionResponse(frame.transaction, { include: options.include }));
|
|
359
|
-
}
|
|
360
|
-
if (frame.end) end = frame.end;
|
|
361
|
-
}
|
|
362
|
-
const hasNextPage = sawLookaheadItem || end?.reason === QueryEndReason.SCAN_LIMIT || end?.reason === QueryEndReason.ITEM_LIMIT;
|
|
404
|
+
}, { abort: options.signal }).responses, pagination.limit, (frame) => frame.transaction, (transaction) => parseGrpcTransactionResponse(transaction, { include: options.include }));
|
|
363
405
|
return {
|
|
364
|
-
transactions,
|
|
365
|
-
|
|
366
|
-
startCursor,
|
|
367
|
-
endCursor: sawLookaheadItem ? endCursor : hasNextPage ? frontier ?? endCursor : endCursor
|
|
406
|
+
transactions: items,
|
|
407
|
+
...page
|
|
368
408
|
};
|
|
369
409
|
}
|
|
370
410
|
async listEvents(options) {
|
|
371
411
|
const pagination = resolvePagination(options);
|
|
372
|
-
const
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
"json",
|
|
380
|
-
"checkpoint",
|
|
381
|
-
"transaction_digest",
|
|
382
|
-
"event_index"
|
|
383
|
-
] },
|
|
384
|
-
filter: options.filter ? toGrpcEventFilter(await resolveEventFilter(this.mvr, options.filter, options.signal)) : void 0,
|
|
412
|
+
const range = resolveCheckpointRange(options);
|
|
413
|
+
const filter = options.filter ? await resolveEventFilter(this.mvr, options.filter, options.signal) : void 0;
|
|
414
|
+
const { items, ...page } = await collectListPage(this.#client.ledgerService.listEvents({
|
|
415
|
+
readMask: { paths: EVENT_READ_MASK_PATHS },
|
|
416
|
+
filter: toGrpcEventFilter(filter),
|
|
417
|
+
startCheckpoint: range.start,
|
|
418
|
+
endCheckpoint: range.end,
|
|
385
419
|
options: toGrpcQueryOptions(pagination, pagination.limit + 1)
|
|
386
|
-
}, { abort: options.signal });
|
|
387
|
-
const events = [];
|
|
388
|
-
let startCursor = null;
|
|
389
|
-
let endCursor = null;
|
|
390
|
-
let frontier = null;
|
|
391
|
-
let end;
|
|
392
|
-
let sawLookaheadItem = false;
|
|
393
|
-
for await (const frame of call.responses) {
|
|
394
|
-
if (frame.watermark?.cursor) frontier = toBase64(frame.watermark.cursor);
|
|
395
|
-
if (frame.event) if (events.length >= pagination.limit) sawLookaheadItem = true;
|
|
396
|
-
else {
|
|
397
|
-
startCursor ??= frontier;
|
|
398
|
-
endCursor = frontier;
|
|
399
|
-
const event = frame.event;
|
|
400
|
-
events.push({
|
|
401
|
-
packageId: normalizeSuiAddress(event.packageId),
|
|
402
|
-
module: event.module,
|
|
403
|
-
sender: normalizeSuiAddress(event.sender),
|
|
404
|
-
eventType: normalizeStructTag(event.eventType),
|
|
405
|
-
bcs: event.contents?.value ?? new Uint8Array(),
|
|
406
|
-
json: event.json ? Value.toJson(event.json) : null,
|
|
407
|
-
checkpoint: event.checkpoint?.toString() ?? null,
|
|
408
|
-
transactionDigest: event.transactionDigest,
|
|
409
|
-
eventIndex: event.eventIndex
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
if (frame.end) end = frame.end;
|
|
413
|
-
}
|
|
414
|
-
const hasNextPage = sawLookaheadItem || end?.reason === QueryEndReason.SCAN_LIMIT || end?.reason === QueryEndReason.ITEM_LIMIT;
|
|
420
|
+
}, { abort: options.signal }).responses, pagination.limit, (frame) => frame.event, (event) => parseGrpcEvent(event, "listEvents"));
|
|
415
421
|
return {
|
|
416
|
-
events,
|
|
417
|
-
|
|
418
|
-
startCursor,
|
|
419
|
-
endCursor: sawLookaheadItem ? endCursor : hasNextPage ? frontier ?? endCursor : endCursor
|
|
422
|
+
events: items,
|
|
423
|
+
...page
|
|
420
424
|
};
|
|
421
425
|
}
|
|
422
|
-
async
|
|
423
|
-
const
|
|
424
|
-
const
|
|
425
|
-
const {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
bcs: { value: fromBase64(options.signature) },
|
|
432
|
-
signature: { oneofKind: void 0 }
|
|
433
|
-
},
|
|
434
|
-
address: options.address,
|
|
435
|
-
jwks: []
|
|
436
|
-
}, { abort: options.signal });
|
|
426
|
+
async listCheckpoints(options) {
|
|
427
|
+
const pagination = resolvePagination(options);
|
|
428
|
+
const range = resolveCheckpointRange(options);
|
|
429
|
+
const { items, ...page } = await collectListPage(this.#client.ledgerService.listCheckpoints({
|
|
430
|
+
readMask: { paths: CHECKPOINT_READ_MASK_PATHS },
|
|
431
|
+
startCheckpoint: range.start,
|
|
432
|
+
endCheckpoint: range.end,
|
|
433
|
+
options: toGrpcQueryOptions(pagination, pagination.limit + 1)
|
|
434
|
+
}, { abort: options.signal }).responses, pagination.limit, (frame) => frame.checkpoint, (checkpoint) => parseGrpcCheckpoint(checkpoint, "listCheckpoints"));
|
|
437
435
|
return {
|
|
438
|
-
|
|
439
|
-
|
|
436
|
+
checkpoints: items,
|
|
437
|
+
...page
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
async verifySignature(options) {
|
|
441
|
+
const { intentScope, message, address, checkAddressAliases } = resolveVerifySignatureOptions(options);
|
|
442
|
+
const signature = decodeSignature(options.signature);
|
|
443
|
+
if (!signature) return {
|
|
444
|
+
valid: false,
|
|
445
|
+
reason: "Cannot parse signature"
|
|
446
|
+
};
|
|
447
|
+
let response;
|
|
448
|
+
try {
|
|
449
|
+
({response} = await this.#client.signatureVerificationService.verifySignature({
|
|
450
|
+
message: {
|
|
451
|
+
name: intentScope,
|
|
452
|
+
value: intentScope === "PersonalMessage" ? suiBcs.byteVector().serialize(message).toBytes() : message
|
|
453
|
+
},
|
|
454
|
+
signature: {
|
|
455
|
+
bcs: { value: signature },
|
|
456
|
+
signature: { oneofKind: void 0 }
|
|
457
|
+
},
|
|
458
|
+
address,
|
|
459
|
+
checkAddressAliases,
|
|
460
|
+
jwks: []
|
|
461
|
+
}, { abort: options.signal }));
|
|
462
|
+
} catch (error) {
|
|
463
|
+
if (error instanceof RpcError && error.code === GrpcStatusCode[GrpcStatusCode.INVALID_ARGUMENT]) return {
|
|
464
|
+
valid: false,
|
|
465
|
+
reason: error.message
|
|
466
|
+
};
|
|
467
|
+
throw error;
|
|
468
|
+
}
|
|
469
|
+
if (typeof response.isValid !== "boolean") throw new Error("The node returned no signature verification verdict");
|
|
470
|
+
if (checkAddressAliases && response.addressAliasesChecked !== true) throw new Error("The node does not support checking address aliases; pass `checkAddressAliases: false` to verify the exact address only.");
|
|
471
|
+
return response.isValid ? { valid: true } : {
|
|
472
|
+
valid: false,
|
|
473
|
+
reason: response.reason ?? "Signature is not valid"
|
|
440
474
|
};
|
|
441
475
|
}
|
|
442
476
|
async defaultNameServiceName(options) {
|
|
@@ -552,6 +586,88 @@ var GrpcCoreClient = class extends CoreClient {
|
|
|
552
586
|
};
|
|
553
587
|
}
|
|
554
588
|
};
|
|
589
|
+
const CHECKPOINT_READ_MASK_PATHS = [
|
|
590
|
+
"sequence_number",
|
|
591
|
+
"digest",
|
|
592
|
+
"summary.epoch",
|
|
593
|
+
"summary.timestamp"
|
|
594
|
+
];
|
|
595
|
+
const EVENT_READ_MASK_PATHS = [
|
|
596
|
+
"package_id",
|
|
597
|
+
"module",
|
|
598
|
+
"sender",
|
|
599
|
+
"event_type",
|
|
600
|
+
"contents",
|
|
601
|
+
"json",
|
|
602
|
+
"checkpoint",
|
|
603
|
+
"transaction_digest",
|
|
604
|
+
"event_index"
|
|
605
|
+
];
|
|
606
|
+
/** `source` names the response in the error thrown when required fields are missing. */
|
|
607
|
+
function parseGrpcCheckpoint(checkpoint, source) {
|
|
608
|
+
const timestamp = checkpoint.summary?.timestamp;
|
|
609
|
+
if (checkpoint.sequenceNumber == null || !checkpoint.digest || checkpoint.summary?.epoch == null || !timestamp) throw new Error(`${source} response is missing expected checkpoint fields`);
|
|
610
|
+
return {
|
|
611
|
+
sequenceNumber: checkpoint.sequenceNumber.toString(),
|
|
612
|
+
digest: checkpoint.digest,
|
|
613
|
+
epoch: checkpoint.summary.epoch.toString(),
|
|
614
|
+
timestampMs: Number(grpcTimestampToMilliseconds(timestamp))
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
/** `source` names the response in the error thrown when required fields are missing. */
|
|
618
|
+
function parseGrpcEventFields(event, source) {
|
|
619
|
+
if (!event.packageId || !event.module || !event.sender || !event.eventType) throw new Error(`${source} response is missing expected event fields`);
|
|
620
|
+
return {
|
|
621
|
+
packageId: normalizeSuiAddress(event.packageId),
|
|
622
|
+
module: event.module,
|
|
623
|
+
sender: normalizeSuiAddress(event.sender),
|
|
624
|
+
eventType: normalizeStructTag(event.eventType),
|
|
625
|
+
bcs: event.contents?.value ?? new Uint8Array(),
|
|
626
|
+
json: event.json ? Value.toJson(event.json) : null
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
/** `source` names the response in the error thrown when required fields are missing. */
|
|
630
|
+
function parseGrpcEvent(event, source) {
|
|
631
|
+
if (!event.transactionDigest || event.eventIndex == null || event.checkpoint == null) throw new Error(`${source} response is missing expected event fields`);
|
|
632
|
+
return {
|
|
633
|
+
...parseGrpcEventFields(event, source),
|
|
634
|
+
checkpoint: event.checkpoint.toString(),
|
|
635
|
+
transactionDigest: event.transactionDigest,
|
|
636
|
+
eventIndex: event.eventIndex
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Collects one page from a streaming ledger query (listTransactions, listEvents,
|
|
641
|
+
* listCheckpoints) that was sent with a limit of `limit + 1`. The extra item is a lookahead:
|
|
642
|
+
* the server reports its item limit as reached without scanning past it, so an exact-limit
|
|
643
|
+
* final page is otherwise indistinguishable from one with more results.
|
|
644
|
+
*/
|
|
645
|
+
async function collectListPage(responses, limit, pick, map) {
|
|
646
|
+
const items = [];
|
|
647
|
+
let startCursor = null;
|
|
648
|
+
let endCursor = null;
|
|
649
|
+
let frontier = null;
|
|
650
|
+
let end;
|
|
651
|
+
let sawLookaheadItem = false;
|
|
652
|
+
for await (const frame of responses) {
|
|
653
|
+
if (frame.watermark?.cursor) frontier = toBase64(frame.watermark.cursor);
|
|
654
|
+
const item = pick(frame);
|
|
655
|
+
if (item) if (items.length >= limit) sawLookaheadItem = true;
|
|
656
|
+
else {
|
|
657
|
+
startCursor ??= frontier;
|
|
658
|
+
endCursor = frontier;
|
|
659
|
+
items.push(map(item));
|
|
660
|
+
}
|
|
661
|
+
if (frame.end) end = frame.end;
|
|
662
|
+
}
|
|
663
|
+
const hasNextPage = sawLookaheadItem || end?.reason === QueryEndReason.SCAN_LIMIT || end?.reason === QueryEndReason.ITEM_LIMIT;
|
|
664
|
+
return {
|
|
665
|
+
items,
|
|
666
|
+
hasNextPage,
|
|
667
|
+
startCursor,
|
|
668
|
+
endCursor: sawLookaheadItem ? endCursor : hasNextPage ? frontier ?? endCursor : endCursor
|
|
669
|
+
};
|
|
670
|
+
}
|
|
555
671
|
function toGrpcQueryOptions(pagination, limit) {
|
|
556
672
|
return {
|
|
557
673
|
limit,
|
|
@@ -560,16 +676,22 @@ function toGrpcQueryOptions(pagination, limit) {
|
|
|
560
676
|
before: pagination.before ? fromBase64(pagination.before) : void 0
|
|
561
677
|
};
|
|
562
678
|
}
|
|
679
|
+
/**
|
|
680
|
+
* The read mask paths `parseGrpcTransactionResponse` needs for `include`, under `prefix` (such as
|
|
681
|
+
* `'transaction.'` for a simulation response).
|
|
682
|
+
*/
|
|
563
683
|
function transactionReadMaskPaths(include, prefix = "") {
|
|
564
684
|
const paths = [
|
|
565
685
|
"digest",
|
|
566
686
|
"transaction.digest",
|
|
687
|
+
"transaction.sender",
|
|
567
688
|
"signatures",
|
|
568
689
|
"effects.status",
|
|
690
|
+
"effects.epoch",
|
|
569
691
|
"timestamp",
|
|
570
692
|
"checkpoint"
|
|
571
693
|
];
|
|
572
|
-
if (include?.transaction) paths.push("transaction.
|
|
694
|
+
if (include?.transaction) paths.push("transaction.gas_payment", "transaction.expiration", "transaction.kind");
|
|
573
695
|
if (include?.bcs) paths.push("transaction.bcs");
|
|
574
696
|
if (include?.balanceChanges) paths.push("balance_changes");
|
|
575
697
|
if (include?.effects) paths.push("effects");
|
|
@@ -595,55 +717,23 @@ function mapDisplayProto(include, display) {
|
|
|
595
717
|
errors: display.errors !== void 0 ? Value.toJson(display.errors) : null
|
|
596
718
|
};
|
|
597
719
|
}
|
|
598
|
-
function mapOwner(owner) {
|
|
599
|
-
if (!owner) return null;
|
|
600
|
-
if (owner.kind === Owner_OwnerKind.IMMUTABLE) return {
|
|
601
|
-
$kind: "Immutable",
|
|
602
|
-
Immutable: true
|
|
603
|
-
};
|
|
604
|
-
if (owner.kind === Owner_OwnerKind.ADDRESS) return {
|
|
605
|
-
AddressOwner: owner.address,
|
|
606
|
-
$kind: "AddressOwner"
|
|
607
|
-
};
|
|
608
|
-
if (owner.kind === Owner_OwnerKind.OBJECT) return {
|
|
609
|
-
$kind: "ObjectOwner",
|
|
610
|
-
ObjectOwner: owner.address
|
|
611
|
-
};
|
|
612
|
-
if (owner.kind === Owner_OwnerKind.SHARED) return {
|
|
613
|
-
$kind: "Shared",
|
|
614
|
-
Shared: { initialSharedVersion: owner.version?.toString() }
|
|
615
|
-
};
|
|
616
|
-
if (owner.kind === Owner_OwnerKind.CONSENSUS_ADDRESS) return {
|
|
617
|
-
$kind: "ConsensusAddressOwner",
|
|
618
|
-
ConsensusAddressOwner: {
|
|
619
|
-
startVersion: owner.version?.toString(),
|
|
620
|
-
owner: owner.address
|
|
621
|
-
}
|
|
622
|
-
};
|
|
623
|
-
throw new Error(`Unknown owner kind ${JSON.stringify(owner, (_k, v) => typeof v === "bigint" ? v.toString() : v)}`);
|
|
624
|
-
}
|
|
625
720
|
function parseGrpcExecutionError(error) {
|
|
626
721
|
const message = error.description ?? "Unknown error";
|
|
627
722
|
const command = error.command != null ? Number(error.command) : void 0;
|
|
628
723
|
const details = error.errorDetails;
|
|
629
724
|
switch (details?.oneofKind) {
|
|
630
725
|
case "abort": {
|
|
631
|
-
const
|
|
632
|
-
const cleverError = abort.cleverError;
|
|
726
|
+
const moveAbort = parseMoveAbort(details.abort);
|
|
633
727
|
return {
|
|
634
728
|
$kind: "MoveAbort",
|
|
635
729
|
message: formatMoveAbortMessage({
|
|
636
730
|
command,
|
|
637
|
-
location:
|
|
638
|
-
abortCode:
|
|
639
|
-
cleverError: cleverError
|
|
640
|
-
lineNumber: cleverError.lineNumber != null ? Number(cleverError.lineNumber) : void 0,
|
|
641
|
-
constantName: cleverError.constantName,
|
|
642
|
-
value: cleverError.value?.oneofKind === "rendered" ? cleverError.value.rendered : void 0
|
|
643
|
-
} : void 0
|
|
731
|
+
location: moveAbort.location,
|
|
732
|
+
abortCode: moveAbort.abortCode,
|
|
733
|
+
cleverError: moveAbort.cleverError
|
|
644
734
|
}),
|
|
645
735
|
command,
|
|
646
|
-
MoveAbort:
|
|
736
|
+
MoveAbort: moveAbort
|
|
647
737
|
};
|
|
648
738
|
}
|
|
649
739
|
case "sizeError": return {
|
|
@@ -651,7 +741,7 @@ function parseGrpcExecutionError(error) {
|
|
|
651
741
|
message,
|
|
652
742
|
command,
|
|
653
743
|
SizeError: {
|
|
654
|
-
name: mapErrorName(error.kind),
|
|
744
|
+
name: mapErrorName(ExecutionError_ExecutionErrorKind, error.kind),
|
|
655
745
|
size: Number(details.sizeError.size ?? 0n),
|
|
656
746
|
maxSize: Number(details.sizeError.maxSize ?? 0n)
|
|
657
747
|
}
|
|
@@ -662,7 +752,7 @@ function parseGrpcExecutionError(error) {
|
|
|
662
752
|
command,
|
|
663
753
|
CommandArgumentError: {
|
|
664
754
|
argument: details.commandArgumentError.argument ?? 0,
|
|
665
|
-
name: mapErrorName(details.commandArgumentError.kind)
|
|
755
|
+
name: mapErrorName(CommandArgumentError_CommandArgumentErrorKind, details.commandArgumentError.kind)
|
|
666
756
|
}
|
|
667
757
|
};
|
|
668
758
|
case "typeArgumentError": return {
|
|
@@ -671,7 +761,7 @@ function parseGrpcExecutionError(error) {
|
|
|
671
761
|
command,
|
|
672
762
|
TypeArgumentError: {
|
|
673
763
|
typeArgument: details.typeArgumentError.typeArgument ?? 0,
|
|
674
|
-
name: mapErrorName(details.typeArgumentError.kind)
|
|
764
|
+
name: mapErrorName(TypeArgumentError_TypeArgumentErrorKind, details.typeArgumentError.kind)
|
|
675
765
|
}
|
|
676
766
|
};
|
|
677
767
|
case "packageUpgradeError": return {
|
|
@@ -679,7 +769,7 @@ function parseGrpcExecutionError(error) {
|
|
|
679
769
|
message,
|
|
680
770
|
command,
|
|
681
771
|
PackageUpgradeError: {
|
|
682
|
-
name: mapErrorName(details.packageUpgradeError.kind),
|
|
772
|
+
name: mapErrorName(PackageUpgradeError_PackageUpgradeErrorKind, details.packageUpgradeError.kind),
|
|
683
773
|
packageId: details.packageUpgradeError.packageId,
|
|
684
774
|
digest: details.packageUpgradeError.digest
|
|
685
775
|
}
|
|
@@ -698,7 +788,7 @@ function parseGrpcExecutionError(error) {
|
|
|
698
788
|
message,
|
|
699
789
|
command,
|
|
700
790
|
CoinDenyListError: {
|
|
701
|
-
name: mapErrorName(error.kind),
|
|
791
|
+
name: mapErrorName(ExecutionError_ExecutionErrorKind, error.kind),
|
|
702
792
|
coinType: details.coinDenyListError.coinType,
|
|
703
793
|
address: details.coinDenyListError.address
|
|
704
794
|
}
|
|
@@ -708,7 +798,7 @@ function parseGrpcExecutionError(error) {
|
|
|
708
798
|
message,
|
|
709
799
|
command,
|
|
710
800
|
CongestedObjects: {
|
|
711
|
-
name: mapErrorName(error.kind),
|
|
801
|
+
name: mapErrorName(ExecutionError_ExecutionErrorKind, error.kind),
|
|
712
802
|
objects: details.congestedObjects.objects
|
|
713
803
|
}
|
|
714
804
|
};
|
|
@@ -717,7 +807,7 @@ function parseGrpcExecutionError(error) {
|
|
|
717
807
|
message,
|
|
718
808
|
command,
|
|
719
809
|
ObjectIdError: {
|
|
720
|
-
name: mapErrorName(error.kind),
|
|
810
|
+
name: mapErrorName(ExecutionError_ExecutionErrorKind, error.kind),
|
|
721
811
|
objectId: details.objectId
|
|
722
812
|
}
|
|
723
813
|
};
|
|
@@ -732,7 +822,7 @@ function parseGrpcExecutionError(error) {
|
|
|
732
822
|
function parseMoveAbort(abort) {
|
|
733
823
|
return {
|
|
734
824
|
abortCode: String(abort.abortCode ?? 0n),
|
|
735
|
-
location:
|
|
825
|
+
location: abort.location && parseMoveLocation(abort.location),
|
|
736
826
|
cleverError: abort.cleverError ? {
|
|
737
827
|
errorCode: abort.cleverError.errorCode != null ? Number(abort.cleverError.errorCode) : void 0,
|
|
738
828
|
lineNumber: abort.cleverError.lineNumber != null ? Number(abort.cleverError.lineNumber) : void 0,
|
|
@@ -742,9 +832,19 @@ function parseMoveAbort(abort) {
|
|
|
742
832
|
} : void 0
|
|
743
833
|
};
|
|
744
834
|
}
|
|
745
|
-
function
|
|
835
|
+
/** Without the function index, which GraphQL does not report. */
|
|
836
|
+
function parseMoveLocation(location) {
|
|
837
|
+
return {
|
|
838
|
+
package: location.package,
|
|
839
|
+
module: location.module,
|
|
840
|
+
functionName: location.functionName,
|
|
841
|
+
instruction: location.instruction
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
/** The PascalCase name of a protobuf enum value, from that enum's reverse mapping. */
|
|
845
|
+
function mapErrorName(names, kind) {
|
|
746
846
|
if (kind == null) return "Unknown";
|
|
747
|
-
const name =
|
|
847
|
+
const name = names[kind];
|
|
748
848
|
if (!name || name.endsWith("_UNKNOWN")) return "Unknown";
|
|
749
849
|
return name.split("_").map((word) => word.charAt(0) + word.slice(1).toLowerCase()).join("");
|
|
750
850
|
}
|
|
@@ -860,15 +960,7 @@ function parseGrpcTransactionResponse(transaction, options) {
|
|
|
860
960
|
if (include?.transaction) {
|
|
861
961
|
const tx = transaction.transaction;
|
|
862
962
|
if (!tx) throw new Error("Transaction data is required but missing from gRPC response");
|
|
863
|
-
|
|
864
|
-
transactionData = {
|
|
865
|
-
gasData: resolved.gasData,
|
|
866
|
-
sender: resolved.sender,
|
|
867
|
-
expiration: resolved.expiration,
|
|
868
|
-
commands: resolved.commands,
|
|
869
|
-
inputs: resolved.inputs,
|
|
870
|
-
version: resolved.version
|
|
871
|
-
};
|
|
963
|
+
transactionData = grpcTransactionToLedgerTransactionData(tx);
|
|
872
964
|
}
|
|
873
965
|
const bcsBytes = include?.bcs ? transaction.transaction?.bcs?.value : void 0;
|
|
874
966
|
const effects = include?.effects ? parseTransactionEffects({ effects: transaction.effects }) : void 0;
|
|
@@ -883,8 +975,11 @@ function parseGrpcTransactionResponse(transaction, options) {
|
|
|
883
975
|
Unknown: null
|
|
884
976
|
}
|
|
885
977
|
};
|
|
978
|
+
const sender = transaction.transaction?.sender;
|
|
979
|
+
if (!sender) throw new Error("Transaction sender is missing from gRPC response; include `transaction.sender` in the read mask");
|
|
886
980
|
const result = {
|
|
887
981
|
digest: transaction.digest,
|
|
982
|
+
sender: normalizeSuiAddress(sender),
|
|
888
983
|
epoch: transaction.effects?.epoch?.toString() ?? null,
|
|
889
984
|
timestampMs: transaction.timestamp ? Number(transaction.timestamp.seconds) * 1e3 + Math.floor(transaction.timestamp.nanos / 1e6) : null,
|
|
890
985
|
checkpoint: transaction.checkpoint?.toString() ?? null,
|
|
@@ -899,14 +994,7 @@ function parseGrpcTransactionResponse(transaction, options) {
|
|
|
899
994
|
address: change.address,
|
|
900
995
|
amount: change.amount
|
|
901
996
|
})) ?? [] : void 0,
|
|
902
|
-
events: include?.events ? transaction.events?.events.map((event) => (
|
|
903
|
-
packageId: normalizeSuiAddress(event.packageId),
|
|
904
|
-
module: event.module,
|
|
905
|
-
sender: normalizeSuiAddress(event.sender),
|
|
906
|
-
eventType: event.eventType,
|
|
907
|
-
bcs: event.contents?.value ?? new Uint8Array(),
|
|
908
|
-
json: event.json ? Value.toJson(event.json) : null
|
|
909
|
-
})) ?? [] : void 0
|
|
997
|
+
events: include?.events ? transaction.events?.events.map((event) => parseGrpcEventFields(event, "Transaction")) ?? [] : void 0
|
|
910
998
|
};
|
|
911
999
|
return status.success ? {
|
|
912
1000
|
$kind: "Transaction",
|
|
@@ -977,5 +1065,5 @@ function parseNormalizedSuiMoveTypeBody(type) {
|
|
|
977
1065
|
}
|
|
978
1066
|
|
|
979
1067
|
//#endregion
|
|
980
|
-
export { GrpcCoreClient, parseGrpcSimulateTransactionResponse, parseGrpcTransactionResponse };
|
|
1068
|
+
export { CHECKPOINT_READ_MASK_PATHS, EVENT_READ_MASK_PATHS, GrpcCoreClient, parseGrpcCheckpoint, parseGrpcEvent, parseGrpcSimulateTransactionResponse, parseGrpcTransactionResponse, transactionReadMaskPaths };
|
|
981
1069
|
//# sourceMappingURL=core.mjs.map
|