@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/dist/graphql/core.mjs
CHANGED
|
@@ -1,30 +1,44 @@
|
|
|
1
1
|
import { normalizeStructTag, normalizeSuiAddress } from "../utils/sui-types.mjs";
|
|
2
|
+
import { ObjectError, SimulationError, TransactionError } from "../client/errors.mjs";
|
|
2
3
|
import { raceSignal } from "../client/mvr.mjs";
|
|
4
|
+
import { resolveCheckpointRange, resolveEventFilter, resolvePagination, resolveTransactionFilter } from "../client/query-filters.mjs";
|
|
3
5
|
import { CoreClient } from "../client/core.mjs";
|
|
4
|
-
import { TransactionDataBuilder } from "../transactions/TransactionData.mjs";
|
|
5
6
|
import { SUI_TYPE_ARG } from "../utils/constants.mjs";
|
|
6
|
-
import { formatMoveAbortMessage, isMockedGasObjectId, parseTransactionEffectsBcs, transactionBytesHaveEmptyGasPayment } from "../client/utils.mjs";
|
|
7
|
-
import { ObjectError, SimulationError, TransactionError } from "../client/errors.mjs";
|
|
8
|
-
import { DefaultSuinsNameDocument, ExecuteTransactionDocument, ExecutionStatus, GetAllBalancesDocument, GetBalanceDocument, GetChainIdentifierDocument, GetCoinMetadataDocument, GetCoinsDocument, GetCurrentSystemStateDocument, GetMoveFunctionDocument, GetOwnedObjectsDocument, GetProtocolConfigDocument, GetReferenceGasPriceDocument, GetTransactionBlockDocument, ListEventsDocument, ListTransactionsDocument, MultiGetObjectsDocument, ResolveNameServiceAddressDocument, ResolveTransactionDocument, SimulateTransactionDocument, VerifyZkLoginSignatureDocument, ZkLoginIntentScope } from "./generated/queries.mjs";
|
|
7
|
+
import { decodeSignature, formatMoveAbortMessage, isMockedGasObjectId, parseTransactionEffectsBcs, resolveVerifySignatureOptions, transactionBytesHaveEmptyGasPayment } from "../client/utils.mjs";
|
|
9
8
|
import { Transaction } from "../grpc/proto/sui/rpc/v2/transaction.mjs";
|
|
10
|
-
import {
|
|
9
|
+
import { TransactionDataBuilder } from "../transactions/TransactionData.mjs";
|
|
10
|
+
import { transactionDataToGrpcTransaction, transactionToGrpcJson } from "../client/transaction-resolver.mjs";
|
|
11
|
+
import { grpcTransactionToLedgerTransactionData } from "../client/transaction-data.mjs";
|
|
12
|
+
import { DefaultSuinsNameDocument, ExecuteTransactionDocument, ExecutionStatus, GetAllBalancesDocument, GetBalanceDocument, GetChainIdentifierDocument, GetCoinMetadataDocument, GetCoinsDocument, GetCurrentSystemStateDocument, GetDynamicFieldsDocument, GetMoveFunctionDocument, GetOwnedObjectsDocument, GetProtocolConfigDocument, GetReferenceGasPriceDocument, GetTransactionBlockDocument, GetTransactionEventsDocument, GetTransactionObjectChangesDocument, IntentScope, ListCheckpointsDocument, ListEventsDocument, ListTransactionsDocument, MultiGetObjectsDocument, ResolveNameServiceAddressDocument, ResolveTransactionDocument, SimulateTransactionDocument, VerifySignatureDocument } from "./generated/queries.mjs";
|
|
11
13
|
import { setAddressBalanceTransactionExpirationFromSimulatedEpoch } from "../client/address-balance-transaction-expiration.mjs";
|
|
12
14
|
import { BalanceChange } from "../grpc/proto/sui/rpc/v2/balance_change.mjs";
|
|
13
15
|
import { TransactionEffects } from "../grpc/proto/sui/rpc/v2/effects.mjs";
|
|
14
|
-
import {
|
|
16
|
+
import { toGraphQLCheckpointBounds, toGraphQLEventFilter, toGraphQLTransactionFilter } from "./filters.mjs";
|
|
17
|
+
import { graphQLLedgerStreamAdapter } from "./stream/index.mjs";
|
|
15
18
|
import { chunk, fromBase64, toBase64 } from "@mysten/utils";
|
|
19
|
+
import { isJsonObject } from "@protobuf-ts/runtime";
|
|
16
20
|
|
|
17
21
|
//#region src/graphql/core.ts
|
|
18
22
|
const GRAPHQL_OBJECT_BATCH_SIZE = 40;
|
|
19
23
|
var GraphQLCoreClient = class extends CoreClient {
|
|
20
24
|
#graphqlClient;
|
|
21
|
-
|
|
25
|
+
#subscribe;
|
|
26
|
+
constructor({ graphqlClient, mvr, restrictedMoveCalls, subscribe }) {
|
|
22
27
|
super({
|
|
23
28
|
network: graphqlClient.network,
|
|
24
29
|
base: graphqlClient,
|
|
25
|
-
mvr
|
|
30
|
+
mvr,
|
|
31
|
+
restrictedMoveCalls
|
|
26
32
|
});
|
|
27
33
|
this.#graphqlClient = graphqlClient;
|
|
34
|
+
this.#subscribe = subscribe;
|
|
35
|
+
}
|
|
36
|
+
createLedgerStreamAdapter(request) {
|
|
37
|
+
return graphQLLedgerStreamAdapter({
|
|
38
|
+
client: this.#graphqlClient,
|
|
39
|
+
subscribe: this.#subscribe,
|
|
40
|
+
mvr: this.mvr
|
|
41
|
+
}, request);
|
|
28
42
|
}
|
|
29
43
|
async #graphqlQuery(options, getData, createMissingDataError) {
|
|
30
44
|
const { data, errors } = await this.#graphqlClient.query(options);
|
|
@@ -33,6 +47,20 @@ var GraphQLCoreClient = class extends CoreClient {
|
|
|
33
47
|
if (extractedData == null) throw createMissingDataError?.() ?? /* @__PURE__ */ new Error("Missing response data");
|
|
34
48
|
return extractedData;
|
|
35
49
|
}
|
|
50
|
+
#withAllPages(transaction, signal) {
|
|
51
|
+
return withAllPages(transaction, {
|
|
52
|
+
events: (variables) => this.#graphqlQuery({
|
|
53
|
+
query: GetTransactionEventsDocument,
|
|
54
|
+
variables,
|
|
55
|
+
signal
|
|
56
|
+
}),
|
|
57
|
+
objectChanges: (variables) => this.#graphqlQuery({
|
|
58
|
+
query: GetTransactionObjectChangesDocument,
|
|
59
|
+
variables,
|
|
60
|
+
signal
|
|
61
|
+
})
|
|
62
|
+
});
|
|
63
|
+
}
|
|
36
64
|
async getObjects(options) {
|
|
37
65
|
const batches = chunk(options.objectIds, GRAPHQL_OBJECT_BATCH_SIZE);
|
|
38
66
|
const results = [];
|
|
@@ -214,19 +242,15 @@ var GraphQLCoreClient = class extends CoreClient {
|
|
|
214
242
|
};
|
|
215
243
|
}
|
|
216
244
|
async getTransaction(options) {
|
|
217
|
-
|
|
245
|
+
const result = await this.#graphqlQuery({
|
|
218
246
|
query: GetTransactionBlockDocument,
|
|
219
247
|
signal: options.signal,
|
|
220
248
|
variables: {
|
|
221
249
|
digest: options.digest,
|
|
222
|
-
|
|
223
|
-
includeEffects: options.include?.effects ?? false,
|
|
224
|
-
includeEvents: options.include?.events ?? false,
|
|
225
|
-
includeBalanceChanges: options.include?.balanceChanges ?? false,
|
|
226
|
-
includeObjectTypes: options.include?.objectTypes ?? false,
|
|
227
|
-
includeBcs: options.include?.bcs ?? false
|
|
250
|
+
...transactionIncludeVariables(options.include)
|
|
228
251
|
}
|
|
229
|
-
}, (result) => result.transaction, () => new TransactionError("notFound", options.digest))
|
|
252
|
+
}, (result$1) => result$1.transaction, () => new TransactionError("notFound", options.digest));
|
|
253
|
+
return parseTransaction(await this.#withAllPages(result, options.signal), options.include);
|
|
230
254
|
}
|
|
231
255
|
async executeTransaction(options) {
|
|
232
256
|
return parseTransaction((await this.#graphqlQuery({
|
|
@@ -235,12 +259,7 @@ var GraphQLCoreClient = class extends CoreClient {
|
|
|
235
259
|
variables: {
|
|
236
260
|
transactionDataBcs: toBase64(options.transaction),
|
|
237
261
|
signatures: options.signatures,
|
|
238
|
-
|
|
239
|
-
includeEffects: options.include?.effects ?? false,
|
|
240
|
-
includeEvents: options.include?.events ?? false,
|
|
241
|
-
includeBalanceChanges: options.include?.balanceChanges ?? false,
|
|
242
|
-
includeObjectTypes: options.include?.objectTypes ?? false,
|
|
243
|
-
includeBcs: options.include?.bcs ?? false
|
|
262
|
+
...transactionIncludeVariables(options.include)
|
|
244
263
|
}
|
|
245
264
|
}, (result) => result.executeTransaction)).effects?.transaction, options.include);
|
|
246
265
|
}
|
|
@@ -252,13 +271,8 @@ var GraphQLCoreClient = class extends CoreClient {
|
|
|
252
271
|
signal: options.signal,
|
|
253
272
|
variables: {
|
|
254
273
|
transaction: options.transaction instanceof Uint8Array ? { bcs: { value: toBase64(options.transaction) } } : transactionToGrpcJson(options.transaction),
|
|
255
|
-
|
|
256
|
-
includeEffects: options.include?.effects ?? false,
|
|
257
|
-
includeEvents: options.include?.events ?? false,
|
|
258
|
-
includeBalanceChanges: options.include?.balanceChanges ?? false,
|
|
259
|
-
includeObjectTypes: options.include?.objectTypes ?? false,
|
|
274
|
+
...transactionIncludeVariables(options.include),
|
|
260
275
|
includeCommandResults: options.include?.commandResults ?? false,
|
|
261
|
-
includeBcs: options.include?.bcs ?? false,
|
|
262
276
|
doGasSelection,
|
|
263
277
|
checksEnabled: options.checksEnabled ?? true
|
|
264
278
|
}
|
|
@@ -344,102 +358,149 @@ var GraphQLCoreClient = class extends CoreClient {
|
|
|
344
358
|
} };
|
|
345
359
|
}
|
|
346
360
|
async listDynamicFields(options) {
|
|
347
|
-
|
|
361
|
+
const includeValue = options.include?.value ?? false;
|
|
362
|
+
const result = await this.#graphqlQuery({
|
|
363
|
+
query: GetDynamicFieldsDocument,
|
|
364
|
+
signal: options.signal,
|
|
365
|
+
variables: {
|
|
366
|
+
parentId: options.parentId,
|
|
367
|
+
first: options.limit,
|
|
368
|
+
cursor: options.cursor,
|
|
369
|
+
includeValue
|
|
370
|
+
}
|
|
371
|
+
}, (result$1) => result$1.address?.dynamicFields);
|
|
372
|
+
return {
|
|
373
|
+
dynamicFields: result.nodes.map((dynamicField) => {
|
|
374
|
+
const nameType = dynamicField.name?.type?.repr;
|
|
375
|
+
const isDynamicObject = dynamicField.value?.__typename === "MoveObject";
|
|
376
|
+
const valueType = dynamicField.value?.__typename === "MoveObject" ? dynamicField.value.contents?.type?.repr : dynamicField.value?.type?.repr;
|
|
377
|
+
const fieldType = isDynamicObject ? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${nameType}>,0x2::object::ID>` : `0x2::dynamic_field::Field<${nameType},${valueType}>`;
|
|
378
|
+
let value;
|
|
379
|
+
if (includeValue) {
|
|
380
|
+
const valueBcs = dynamicField.value?.__typename === "MoveObject" ? dynamicField.value.contents?.bcs : dynamicField.value?.__typename === "MoveValue" ? dynamicField.value.bcs : null;
|
|
381
|
+
if (valueBcs == null) throw new Error(`Missing value for dynamic field ${dynamicField.address}`);
|
|
382
|
+
value = {
|
|
383
|
+
type: valueType,
|
|
384
|
+
bcs: fromBase64(valueBcs)
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
return {
|
|
388
|
+
$kind: isDynamicObject ? "DynamicObject" : "DynamicField",
|
|
389
|
+
fieldId: dynamicField.address,
|
|
390
|
+
type: normalizeStructTag(fieldType),
|
|
391
|
+
name: {
|
|
392
|
+
type: nameType,
|
|
393
|
+
bcs: fromBase64(dynamicField.name?.bcs)
|
|
394
|
+
},
|
|
395
|
+
valueType,
|
|
396
|
+
childId: dynamicField.value?.__typename === "MoveObject" ? dynamicField.value.address : void 0,
|
|
397
|
+
value
|
|
398
|
+
};
|
|
399
|
+
}),
|
|
400
|
+
cursor: result.pageInfo.endCursor ?? null,
|
|
401
|
+
hasNextPage: result.pageInfo.hasNextPage
|
|
402
|
+
};
|
|
348
403
|
}
|
|
349
404
|
async listTransactions(options) {
|
|
350
|
-
const
|
|
351
|
-
const
|
|
352
|
-
const
|
|
353
|
-
validateTransactionQuery(filter, pagination);
|
|
405
|
+
const { descending, after, before, limit } = resolvePagination(options);
|
|
406
|
+
const range = resolveCheckpointRange(options);
|
|
407
|
+
const graphqlFilter = toGraphQLTransactionFilter(options.filter ? await resolveTransactionFilter(this.mvr, options.filter, options.signal) : void 0, range);
|
|
354
408
|
const transactions = await this.#graphqlQuery({
|
|
355
409
|
query: ListTransactionsDocument,
|
|
356
410
|
signal: options.signal,
|
|
357
411
|
variables: {
|
|
358
|
-
filter:
|
|
359
|
-
sentAddress: filter.$kind === "sender" ? filter.sender : void 0,
|
|
360
|
-
function: filter.$kind === "function" ? [
|
|
361
|
-
filter.package,
|
|
362
|
-
filter.module,
|
|
363
|
-
filter.function
|
|
364
|
-
].filter(Boolean).join("::") : void 0
|
|
365
|
-
},
|
|
412
|
+
filter: graphqlFilter,
|
|
366
413
|
first: descending ? void 0 : limit,
|
|
367
414
|
after,
|
|
368
415
|
last: descending ? limit : void 0,
|
|
369
416
|
before,
|
|
370
|
-
|
|
371
|
-
includeEffects: options.include?.effects ?? false,
|
|
372
|
-
includeEvents: options.include?.events ?? false,
|
|
373
|
-
includeBalanceChanges: options.include?.balanceChanges ?? false,
|
|
374
|
-
includeObjectTypes: options.include?.objectTypes ?? false,
|
|
375
|
-
includeBcs: options.include?.bcs ?? false
|
|
417
|
+
...transactionIncludeVariables(options.include)
|
|
376
418
|
}
|
|
377
419
|
}, (result) => result.transactions);
|
|
420
|
+
const nodes = transactions.edges.map((edge) => edge.node);
|
|
421
|
+
if (descending) nodes.reverse();
|
|
422
|
+
const completed = [];
|
|
423
|
+
for (const transaction of nodes) completed.push(parseTransaction(await this.#withAllPages(transaction, options.signal), options.include));
|
|
378
424
|
return {
|
|
379
|
-
transactions:
|
|
380
|
-
|
|
381
|
-
startCursor: (descending ? transactions.pageInfo.endCursor : transactions.pageInfo.startCursor) ?? null,
|
|
382
|
-
endCursor: (descending ? transactions.pageInfo.startCursor : transactions.pageInfo.endCursor) ?? null
|
|
425
|
+
transactions: completed,
|
|
426
|
+
...listPageCursors(transactions, descending)
|
|
383
427
|
};
|
|
384
428
|
}
|
|
385
429
|
async listEvents(options) {
|
|
386
430
|
const { descending, after, before, limit } = resolvePagination(options);
|
|
387
|
-
const
|
|
431
|
+
const range = resolveCheckpointRange(options);
|
|
432
|
+
const graphqlFilter = toGraphQLEventFilter(options.filter ? await resolveEventFilter(this.mvr, options.filter, options.signal) : void 0, range);
|
|
388
433
|
const events = await this.#graphqlQuery({
|
|
389
434
|
query: ListEventsDocument,
|
|
390
435
|
signal: options.signal,
|
|
391
436
|
variables: {
|
|
392
|
-
filter:
|
|
393
|
-
sender: filter.$kind === "sender" ? filter.sender : void 0,
|
|
394
|
-
module: filter.$kind === "emitModule" ? `${filter.package}::${filter.module}` : void 0,
|
|
395
|
-
type: filter.$kind === "eventTypeModule" ? `${filter.package}::${filter.module}` : filter.$kind === "eventType" ? filter.eventType : void 0
|
|
396
|
-
},
|
|
437
|
+
filter: graphqlFilter,
|
|
397
438
|
first: descending ? void 0 : limit,
|
|
398
439
|
after,
|
|
399
440
|
last: descending ? limit : void 0,
|
|
400
441
|
before
|
|
401
442
|
}
|
|
402
443
|
}, (result) => result.events);
|
|
444
|
+
const nodes = events.edges.map((edge) => edge.node);
|
|
445
|
+
if (descending) nodes.reverse();
|
|
403
446
|
return {
|
|
404
|
-
events:
|
|
405
|
-
const
|
|
406
|
-
|
|
407
|
-
const sender = event.sender?.address;
|
|
408
|
-
const eventType = event.contents?.type?.repr;
|
|
409
|
-
const transactionDigest = event.transaction?.digest;
|
|
410
|
-
if (!packageId || !module || !sender || !eventType || !transactionDigest) throw new Error("listEvents response is missing expected event fields");
|
|
411
|
-
return {
|
|
412
|
-
packageId: normalizeSuiAddress(packageId),
|
|
413
|
-
module,
|
|
414
|
-
sender: normalizeSuiAddress(sender),
|
|
415
|
-
eventType: normalizeStructTag(eventType),
|
|
416
|
-
bcs: event.contents?.bcs ? fromBase64(event.contents.bcs) : new Uint8Array(),
|
|
417
|
-
json: event.contents?.json ?? null,
|
|
418
|
-
checkpoint: event.transaction?.effects?.checkpoint?.sequenceNumber?.toString() ?? null,
|
|
419
|
-
transactionDigest,
|
|
420
|
-
eventIndex: event.sequenceNumber
|
|
421
|
-
};
|
|
447
|
+
events: nodes.map((event) => {
|
|
448
|
+
const checkpoint = event.transaction?.effects?.checkpoint?.sequenceNumber;
|
|
449
|
+
return parseGraphQLEvent(event, checkpoint == null ? null : String(checkpoint), "listEvents");
|
|
422
450
|
}),
|
|
423
|
-
|
|
424
|
-
startCursor: (descending ? events.pageInfo.endCursor : events.pageInfo.startCursor) ?? null,
|
|
425
|
-
endCursor: (descending ? events.pageInfo.startCursor : events.pageInfo.endCursor) ?? null
|
|
451
|
+
...listPageCursors(events, descending)
|
|
426
452
|
};
|
|
427
453
|
}
|
|
428
|
-
async
|
|
429
|
-
const
|
|
430
|
-
const
|
|
431
|
-
|
|
454
|
+
async listCheckpoints(options) {
|
|
455
|
+
const { descending, after, before, limit } = resolvePagination(options);
|
|
456
|
+
const filter = toGraphQLCheckpointBounds(resolveCheckpointRange(options));
|
|
457
|
+
const checkpoints = await this.#graphqlQuery({
|
|
458
|
+
query: ListCheckpointsDocument,
|
|
432
459
|
signal: options.signal,
|
|
433
460
|
variables: {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
461
|
+
filter,
|
|
462
|
+
first: descending ? void 0 : limit,
|
|
463
|
+
after,
|
|
464
|
+
last: descending ? limit : void 0,
|
|
465
|
+
before
|
|
438
466
|
}
|
|
439
|
-
});
|
|
467
|
+
}, (result) => result.checkpoints);
|
|
468
|
+
const nodes = checkpoints.edges.map((edge) => edge.node);
|
|
469
|
+
if (descending) nodes.reverse();
|
|
440
470
|
return {
|
|
441
|
-
|
|
442
|
-
|
|
471
|
+
checkpoints: nodes.map((checkpoint) => parseGraphQLCheckpoint(checkpoint, "listCheckpoints")),
|
|
472
|
+
...listPageCursors(checkpoints, descending)
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
async verifySignature(options) {
|
|
476
|
+
const { intentScope, message, address, checkAddressAliases } = resolveVerifySignatureOptions(options);
|
|
477
|
+
const signature = decodeSignature(options.signature);
|
|
478
|
+
if (!signature) return {
|
|
479
|
+
valid: false,
|
|
480
|
+
reason: "Cannot parse signature"
|
|
481
|
+
};
|
|
482
|
+
const { data, errors } = await this.#graphqlClient.query({
|
|
483
|
+
query: VerifySignatureDocument,
|
|
484
|
+
signal: options.signal,
|
|
485
|
+
variables: {
|
|
486
|
+
message: toBase64(message),
|
|
487
|
+
signature: toBase64(signature),
|
|
488
|
+
intentScope: intentScope === "TransactionData" ? IntentScope.TransactionData : IntentScope.PersonalMessage,
|
|
489
|
+
author: address,
|
|
490
|
+
checkAddressAliases
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
const failure = errors?.find((error) => error.path?.[0] === "verifySignature" && error.extensions?.code === "BAD_USER_INPUT");
|
|
494
|
+
if (failure) return {
|
|
495
|
+
valid: false,
|
|
496
|
+
reason: failure.message
|
|
497
|
+
};
|
|
498
|
+
handleGraphQLErrors(errors);
|
|
499
|
+
const success = data?.verifySignature?.success;
|
|
500
|
+
if (typeof success !== "boolean") throw new Error("The node returned no signature verification verdict");
|
|
501
|
+
return success ? { valid: true } : {
|
|
502
|
+
valid: false,
|
|
503
|
+
reason: "Signature is not valid"
|
|
443
504
|
};
|
|
444
505
|
}
|
|
445
506
|
async defaultNameServiceName(options) {
|
|
@@ -611,11 +672,103 @@ function mapOwner(owner) {
|
|
|
611
672
|
};
|
|
612
673
|
}
|
|
613
674
|
}
|
|
675
|
+
/** `source` names the response in the error thrown when required fields are missing. */
|
|
676
|
+
function parseGraphQLCheckpoint(checkpoint, source) {
|
|
677
|
+
const timestampMs = checkpoint.timestamp ? Date.parse(checkpoint.timestamp) : NaN;
|
|
678
|
+
const epoch = checkpoint.epoch?.epochId;
|
|
679
|
+
if (!checkpoint.digest || Number.isNaN(timestampMs) || epoch == null) throw new Error(`${source} response is missing expected checkpoint fields`);
|
|
680
|
+
return {
|
|
681
|
+
sequenceNumber: String(checkpoint.sequenceNumber),
|
|
682
|
+
digest: checkpoint.digest,
|
|
683
|
+
epoch: String(epoch),
|
|
684
|
+
timestampMs
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
/** `source` names the response in the error thrown when required fields are missing. */
|
|
688
|
+
function parseGraphQLEventFields(event, source) {
|
|
689
|
+
const packageId = event.transactionModule?.package?.address;
|
|
690
|
+
const module = event.transactionModule?.name;
|
|
691
|
+
const eventType = event.contents?.type?.repr;
|
|
692
|
+
if (!packageId || !module || !eventType) throw new Error(`${source} response is missing expected event fields`);
|
|
693
|
+
return {
|
|
694
|
+
packageId: normalizeSuiAddress(packageId),
|
|
695
|
+
module,
|
|
696
|
+
sender: normalizeSuiAddress(event.sender?.address ?? "0x0"),
|
|
697
|
+
eventType: normalizeStructTag(eventType),
|
|
698
|
+
bcs: event.contents?.bcs ? fromBase64(event.contents.bcs) : new Uint8Array(),
|
|
699
|
+
json: event.contents?.json ?? null
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
/** `source` names the response in the error thrown when required fields are missing. */
|
|
703
|
+
function parseGraphQLEvent(event, checkpoint, source) {
|
|
704
|
+
const transactionDigest = event.transaction?.digest;
|
|
705
|
+
if (!transactionDigest || checkpoint == null) throw new Error(`${source} response is missing expected event fields`);
|
|
706
|
+
return {
|
|
707
|
+
...parseGraphQLEventFields(event, source),
|
|
708
|
+
checkpoint,
|
|
709
|
+
transactionDigest,
|
|
710
|
+
eventIndex: event.sequenceNumber
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
/** `TRANSACTION_FIELDS` variables for `include`, shared so every query selects the same fields. */
|
|
714
|
+
function transactionIncludeVariables(include = {}) {
|
|
715
|
+
return {
|
|
716
|
+
includeTransaction: include.transaction ?? false,
|
|
717
|
+
includeEffects: include.effects ?? false,
|
|
718
|
+
includeEvents: include.events ?? false,
|
|
719
|
+
includeBalanceChanges: include.balanceChanges ?? false,
|
|
720
|
+
includeObjectTypes: include.objectTypes ?? false,
|
|
721
|
+
includeBcs: include.bcs ?? false
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
/** Page size of the events and object changes nested in `TRANSACTION_FIELDS`. */
|
|
725
|
+
const NESTED_PAGE_SIZE = 50;
|
|
726
|
+
/**
|
|
727
|
+
* The transaction with all of its events and object changes. The nested lists carry no page info,
|
|
728
|
+
* which keeps checkpoint scans under the service's output-node limit, so a full nested list is read
|
|
729
|
+
* again by digest, to the end.
|
|
730
|
+
*/
|
|
731
|
+
async function withAllPages(transaction, read) {
|
|
732
|
+
const effects = transaction.effects;
|
|
733
|
+
const full = (list) => list?.nodes.length === NESTED_PAGE_SIZE;
|
|
734
|
+
if (!full(effects?.events) && !full(effects?.objectChanges)) return transaction;
|
|
735
|
+
const { digest } = transaction;
|
|
736
|
+
const [events, objectChanges] = await Promise.all([full(effects.events) ? readAll(digest, async (after) => {
|
|
737
|
+
return (await read.events({
|
|
738
|
+
digest,
|
|
739
|
+
after
|
|
740
|
+
})).transaction?.effects?.events;
|
|
741
|
+
}) : effects.events, full(effects.objectChanges) ? readAll(digest, async (after) => {
|
|
742
|
+
return (await read.objectChanges({
|
|
743
|
+
digest,
|
|
744
|
+
after
|
|
745
|
+
})).transaction?.effects?.objectChanges;
|
|
746
|
+
}) : effects.objectChanges]);
|
|
747
|
+
return {
|
|
748
|
+
...transaction,
|
|
749
|
+
effects: {
|
|
750
|
+
...effects,
|
|
751
|
+
events,
|
|
752
|
+
objectChanges
|
|
753
|
+
}
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
async function readAll(digest, next) {
|
|
757
|
+
const nodes = [];
|
|
758
|
+
let after = null;
|
|
759
|
+
for (;;) {
|
|
760
|
+
const page = await next(after);
|
|
761
|
+
if (!page) throw new Error(`Missing a page of transaction ${digest}`);
|
|
762
|
+
nodes.push(...page.nodes);
|
|
763
|
+
if (!page.pageInfo.hasNextPage || page.nodes.length === 0) return { nodes };
|
|
764
|
+
after = page.pageInfo.endCursor ?? null;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
614
767
|
function parseTransaction(transaction, include) {
|
|
615
768
|
const objectTypes = {};
|
|
616
769
|
if (include?.objectTypes) {
|
|
617
770
|
const effectsJson = transaction.effects?.effectsJson;
|
|
618
|
-
if (effectsJson) TransactionEffects.fromJson(effectsJson).changedObjects?.forEach((change) => {
|
|
771
|
+
if (effectsJson) TransactionEffects.fromJson(effectsJson, { ignoreUnknownFields: true }).changedObjects?.forEach((change) => {
|
|
619
772
|
if (change.objectId && change.objectType) objectTypes[change.objectId] = change.objectType;
|
|
620
773
|
});
|
|
621
774
|
const objectChanges = transaction.effects?.objectChanges?.nodes;
|
|
@@ -628,7 +781,7 @@ function parseTransaction(transaction, include) {
|
|
|
628
781
|
if (include?.balanceChanges) {
|
|
629
782
|
const balanceChangesJson = transaction.effects?.balanceChangesJson;
|
|
630
783
|
if (Array.isArray(balanceChangesJson)) balanceChanges = balanceChangesJson.map((json) => {
|
|
631
|
-
const change = BalanceChange.fromJson(json);
|
|
784
|
+
const change = BalanceChange.fromJson(json, { ignoreUnknownFields: true });
|
|
632
785
|
return {
|
|
633
786
|
coinType: change.coinType,
|
|
634
787
|
address: change.address,
|
|
@@ -645,21 +798,15 @@ function parseTransaction(transaction, include) {
|
|
|
645
798
|
error: parseGraphQLExecutionError(transaction.effects?.executionError)
|
|
646
799
|
};
|
|
647
800
|
let transactionData;
|
|
648
|
-
if (include?.transaction
|
|
649
|
-
|
|
650
|
-
transactionData = {
|
|
651
|
-
gasData: resolved.gasData,
|
|
652
|
-
sender: resolved.sender,
|
|
653
|
-
expiration: resolved.expiration,
|
|
654
|
-
commands: resolved.commands,
|
|
655
|
-
inputs: resolved.inputs,
|
|
656
|
-
version: resolved.version
|
|
657
|
-
};
|
|
801
|
+
if (include?.transaction) {
|
|
802
|
+
if (!transaction.transactionJson) throw new Error("Transaction data is required but missing from GraphQL response");
|
|
803
|
+
transactionData = grpcTransactionToLedgerTransactionData(Transaction.fromJson(unknownEnumsAsNumbers(Transaction, transaction.transactionJson), { ignoreUnknownFields: true }));
|
|
658
804
|
}
|
|
659
805
|
const bcsBytes = include?.bcs && transaction.transactionBcs ? fromBase64(transaction.transactionBcs) : void 0;
|
|
660
806
|
const timestampMs = transaction.effects?.timestamp ? Date.parse(transaction.effects.timestamp) : null;
|
|
661
807
|
const result = {
|
|
662
808
|
digest: transaction.digest,
|
|
809
|
+
sender: normalizeSuiAddress(transaction.sender?.address ?? "0x0"),
|
|
663
810
|
status,
|
|
664
811
|
effects: include?.effects ? parseTransactionEffectsBcs(fromBase64(transaction.effects?.effectsBcs)) : void 0,
|
|
665
812
|
epoch: transaction.effects?.epoch?.epochId?.toString() ?? null,
|
|
@@ -670,18 +817,7 @@ function parseTransaction(transaction, include) {
|
|
|
670
817
|
bcs: bcsBytes,
|
|
671
818
|
signatures: transaction.signatures.map((sig) => sig.signatureBytes),
|
|
672
819
|
balanceChanges,
|
|
673
|
-
events: include?.events ? transaction.effects?.events?.nodes.map((event) =>
|
|
674
|
-
const eventType = event.contents?.type?.repr;
|
|
675
|
-
const [packageId, module] = eventType.split("::");
|
|
676
|
-
return {
|
|
677
|
-
packageId,
|
|
678
|
-
module,
|
|
679
|
-
sender: event.sender?.address,
|
|
680
|
-
eventType,
|
|
681
|
-
bcs: event.contents?.bcs ? fromBase64(event.contents.bcs) : new Uint8Array(),
|
|
682
|
-
json: event.contents?.json ?? null
|
|
683
|
-
};
|
|
684
|
-
}) ?? [] : void 0
|
|
820
|
+
events: include?.events ? transaction.effects?.events?.nodes.map((event) => parseGraphQLEventFields(event, "Transaction")) ?? [] : void 0
|
|
685
821
|
};
|
|
686
822
|
return status.success ? {
|
|
687
823
|
$kind: "Transaction",
|
|
@@ -693,6 +829,26 @@ function parseTransaction(transaction, include) {
|
|
|
693
829
|
FailedTransaction: result
|
|
694
830
|
};
|
|
695
831
|
}
|
|
832
|
+
/**
|
|
833
|
+
* Replaces each enum string this SDK does not know with an unknown number, which is what binary
|
|
834
|
+
* decoding gives over gRPC, so the shared mapper treats it the same way. A lenient JSON parse would
|
|
835
|
+
* drop it, and the mapper would then read the field's default.
|
|
836
|
+
*/
|
|
837
|
+
function unknownEnumsAsNumbers(type, json) {
|
|
838
|
+
if (!isJsonObject(json) || type.typeName.startsWith("google.protobuf.")) return json;
|
|
839
|
+
const result = { ...json };
|
|
840
|
+
for (const field of type.fields) {
|
|
841
|
+
const key = field.jsonName in json ? field.jsonName : field.localName;
|
|
842
|
+
const value = json[key];
|
|
843
|
+
if (value == null) continue;
|
|
844
|
+
const map = (item) => field.kind === "message" ? unknownEnumsAsNumbers(field.T(), item) : field.kind === "enum" && typeof item === "string" && !isKnownEnum(field.T(), item) ? -1 : item;
|
|
845
|
+
result[key] = Array.isArray(value) ? value.map(map) : map(value);
|
|
846
|
+
}
|
|
847
|
+
return result;
|
|
848
|
+
}
|
|
849
|
+
function isKnownEnum([, values, prefix], name) {
|
|
850
|
+
return typeof values[prefix && name.startsWith(prefix) ? name.slice(prefix.length) : name] === "number";
|
|
851
|
+
}
|
|
696
852
|
function parseNormalizedSuiMoveType(type) {
|
|
697
853
|
let reference = null;
|
|
698
854
|
if (type.ref === "&") reference = "immutable";
|
|
@@ -703,11 +859,12 @@ function parseNormalizedSuiMoveType(type) {
|
|
|
703
859
|
};
|
|
704
860
|
}
|
|
705
861
|
function parseGraphQLExecutionError(executionError) {
|
|
706
|
-
|
|
862
|
+
const name = mapGraphQLExecutionErrorKind(executionError);
|
|
863
|
+
const commandMatch = executionError?.message?.match(/in (\d+)\w* command/);
|
|
864
|
+
const command = commandMatch ? parseInt(commandMatch[1], 10) - 1 : void 0;
|
|
865
|
+
if (name === "MoveAbort" && executionError?.abortCode != null) {
|
|
707
866
|
const location = parseGraphQLMoveLocation(executionError);
|
|
708
867
|
const cleverError = parseGraphQLCleverError(executionError);
|
|
709
|
-
const commandMatch = executionError.message?.match(/in (\d+)\w* command/);
|
|
710
|
-
const command = commandMatch ? parseInt(commandMatch[1], 10) - 1 : void 0;
|
|
711
868
|
return {
|
|
712
869
|
$kind: "MoveAbort",
|
|
713
870
|
message: formatMoveAbortMessage({
|
|
@@ -736,6 +893,7 @@ function parseGraphQLExecutionError(executionError) {
|
|
|
736
893
|
return {
|
|
737
894
|
$kind: "Unknown",
|
|
738
895
|
message: executionError?.message ?? "Transaction failed",
|
|
896
|
+
command,
|
|
739
897
|
Unknown: null
|
|
740
898
|
};
|
|
741
899
|
}
|
|
@@ -753,8 +911,10 @@ function parseGraphQLMoveLocation(executionError) {
|
|
|
753
911
|
};
|
|
754
912
|
}
|
|
755
913
|
function parseGraphQLCleverError(executionError) {
|
|
756
|
-
if (
|
|
914
|
+
if (executionError.sourceLineNumber == null) return;
|
|
915
|
+
const abortCode = BigInt(executionError.abortCode);
|
|
757
916
|
return {
|
|
917
|
+
errorCode: abortCode <= 255n ? Number(abortCode) : void 0,
|
|
758
918
|
constantName: executionError.identifier ?? void 0,
|
|
759
919
|
value: executionError.constant ?? void 0,
|
|
760
920
|
lineNumber: executionError.sourceLineNumber ?? void 0
|
|
@@ -789,7 +949,23 @@ function parseNormalizedSuiMoveTypeBody(type) {
|
|
|
789
949
|
};
|
|
790
950
|
throw new Error(`Unknown type: ${JSON.stringify(type)}`);
|
|
791
951
|
}
|
|
952
|
+
/**
|
|
953
|
+
* Page cursors for the list queries, matching the gRPC client: a page that can continue resumes
|
|
954
|
+
* from the server's cursor (which may be a scan position past the last item), a final page ends at
|
|
955
|
+
* its last item, and an empty final page has no cursors.
|
|
956
|
+
*/
|
|
957
|
+
function listPageCursors(connection, descending) {
|
|
958
|
+
const { pageInfo } = connection;
|
|
959
|
+
const edges = descending ? [...connection.edges].reverse() : connection.edges;
|
|
960
|
+
const resumeFrom = (descending ? pageInfo.startCursor : pageInfo.endCursor) ?? null;
|
|
961
|
+
const hasNextPage = resumeFrom !== null && (descending ? pageInfo.hasPreviousPage : pageInfo.hasNextPage);
|
|
962
|
+
return {
|
|
963
|
+
hasNextPage,
|
|
964
|
+
startCursor: edges[0]?.cursor ?? null,
|
|
965
|
+
endCursor: hasNextPage ? resumeFrom : edges.at(-1)?.cursor ?? null
|
|
966
|
+
};
|
|
967
|
+
}
|
|
792
968
|
|
|
793
969
|
//#endregion
|
|
794
|
-
export { GraphQLCoreClient };
|
|
970
|
+
export { GraphQLCoreClient, parseGraphQLCheckpoint, parseGraphQLEvent, parseTransaction, transactionIncludeVariables, withAllPages };
|
|
795
971
|
//# sourceMappingURL=core.mjs.map
|