@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publickey.mjs","names":["bcs"],"sources":["../../src/cryptography/publickey.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64, toBase64 } from '@mysten/bcs';\nimport { blake2b } from '@noble/hashes/blake2.js';\nimport { bytesToHex } from '@noble/hashes/utils.js';\n\nimport { bcs } from '../bcs/index.js';\nimport { normalizeSuiAddress, SUI_ADDRESS_LENGTH } from '../utils/sui-types.js';\nimport type { IntentScope } from './intent.js';\nimport { messageWithIntent } from './intent.js';\nimport { SIGNATURE_FLAG_TO_SCHEME, SIGNATURE_SCHEME_TO_SIZE } from './signature-scheme.js';\n\n/**\n * Value to be converted into public key.\n */\nexport type PublicKeyInitData = string | Uint8Array | Iterable<number>;\n\nexport function bytesEqual(a: Uint8Array, b: Uint8Array) {\n\tif (a === b) return true;\n\n\tif (a.length !== b.length) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < a.length; i++) {\n\t\tif (a[i] !== b[i]) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * A public key\n */\nexport abstract class PublicKey {\n\t/**\n\t * Checks if two public keys are equal\n\t */\n\tequals(publicKey: PublicKey) {\n\t\treturn bytesEqual(this.toRawBytes(), publicKey.toRawBytes());\n\t}\n\n\t/**\n\t * Return the base-64 representation of the public key\n\t */\n\ttoBase64() {\n\t\treturn toBase64(this.toRawBytes());\n\t}\n\n\ttoString(): never {\n\t\tthrow new Error(\n\t\t\t'`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.',\n\t\t);\n\t}\n\n\t/**\n\t * Return the Sui representation of the public key encoded in\n\t * base-64. A Sui public key is formed by the concatenation\n\t * of the scheme flag with the raw bytes of the public key\n\t */\n\ttoSuiPublicKey(): string {\n\t\tconst bytes = this.toSuiBytes();\n\t\treturn toBase64(bytes);\n\t}\n\n\tverifyWithIntent(\n\t\tbytes: Uint8Array,\n\t\tsignature: Uint8Array | string,\n\t\tintent: IntentScope,\n\t): Promise<boolean> {\n\t\tconst intentMessage = messageWithIntent(intent, bytes);\n\t\tconst digest = blake2b(intentMessage, { dkLen: 32 });\n\n\t\treturn this.verify(digest, signature);\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided PersonalMessage\n\t */\n\tverifyPersonalMessage(message: Uint8Array, signature: Uint8Array | string): Promise<boolean> {\n\t\treturn this.verifyWithIntent(\n\t\t\tbcs.byteVector().serialize(message).toBytes(),\n\t\t\tsignature,\n\t\t\t'PersonalMessage',\n\t\t);\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided Transaction\n\t */\n\tverifyTransaction(transaction: Uint8Array, signature: Uint8Array | string): Promise<boolean> {\n\t\treturn this.verifyWithIntent(transaction, signature, 'TransactionData');\n\t}\n\n\t/**\n\t * Verifies that the public key is associated with the provided address\n\t */\n\tverifyAddress(address: string): boolean {\n\t\treturn this.toSuiAddress() === address;\n\t}\n\n\t/**\n\t * Returns the bytes representation of the public key\n\t * prefixed with the signature scheme flag\n\t */\n\ttoSuiBytes(): Uint8Array<ArrayBuffer> {\n\t\tconst rawBytes = this.toRawBytes();\n\t\tconst suiBytes = new Uint8Array(rawBytes.length + 1);\n\t\tsuiBytes.set([this.flag()]);\n\t\tsuiBytes.set(rawBytes, 1);\n\n\t\treturn suiBytes;\n\t}\n\n\t/**\n\t * Return the Sui address associated with this Ed25519 public key\n\t */\n\ttoSuiAddress(): string {\n\t\t// Each hex char represents half a byte, hence hex address doubles the length\n\t\treturn normalizeSuiAddress(\n\t\t\tbytesToHex(blake2b(this.toSuiBytes(), { dkLen: 32 })).slice(0, SUI_ADDRESS_LENGTH * 2),\n\t\t);\n\t}\n\n\t/**\n\t * Return the byte array representation of the public key\n\t */\n\tabstract toRawBytes(): Uint8Array<ArrayBuffer>;\n\n\t/**\n\t * Return signature scheme flag of the public key\n\t */\n\tabstract flag(): number;\n\n\t/**\n\t * Verifies that the signature is valid for for the provided message\n\t */\n\tabstract verify(data: Uint8Array, signature: Uint8Array | string): Promise<boolean>;\n}\n\nexport function parseSerializedKeypairSignature(serializedSignature: string) {\n\tconst bytes = fromBase64(serializedSignature);\n\n\tconst signatureScheme =\n\t\tSIGNATURE_FLAG_TO_SCHEME[bytes[0] as keyof typeof SIGNATURE_FLAG_TO_SCHEME];\n\n\tswitch (signatureScheme) {\n\t\tcase 'ED25519':\n\t\tcase 'Secp256k1':\n\t\tcase 'Secp256r1':\n\t\tcase 'MLDSA65':\n\t\t\tconst size =\n\t\t\t\tSIGNATURE_SCHEME_TO_SIZE[signatureScheme as keyof typeof SIGNATURE_SCHEME_TO_SIZE];\n\t\t\tconst signature = bytes.slice(1, bytes.length - size);\n\t\t\tconst publicKey = bytes.slice(1 + signature.length);\n\n\t\t\treturn {\n\t\t\t\tserializedSignature,\n\t\t\t\tsignatureScheme,\n\t\t\t\tsignature,\n\t\t\t\tpublicKey,\n\t\t\t\tbytes,\n\t\t\t};\n\t\tdefault:\n\t\t\tthrow new Error('Unsupported signature scheme');\n\t}\n}\n"],"mappings":";;;;;;;;;AAkBA,SAAgB,WAAW,GAAe,GAAe;AACxD,KAAI,MAAM,EAAG,QAAO;AAEpB,KAAI,EAAE,WAAW,EAAE,OAClB,QAAO;AAGR,MAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,IAC7B,KAAI,EAAE,OAAO,EAAE,GACd,QAAO;AAGT,QAAO;;;;;AAMR,IAAsB,YAAtB,MAAgC;;;;CAI/B,OAAO,WAAsB;AAC5B,SAAO,WAAW,KAAK,YAAY,EAAE,UAAU,YAAY,CAAC;;;;;CAM7D,WAAW;AACV,SAAO,SAAS,KAAK,YAAY,CAAC;;CAGnC,WAAkB;AACjB,QAAM,IAAI,MACT,4FACA;;;;;;;CAQF,iBAAyB;AAExB,SAAO,SADO,KAAK,YAAY,CACT;;CAGvB,iBACC,OACA,WACA,QACmB;EAEnB,MAAM,SAAS,QADO,kBAAkB,QAAQ,MAAM,EAChB,EAAE,OAAO,IAAI,CAAC;AAEpD,SAAO,KAAK,OAAO,QAAQ,UAAU
|
|
1
|
+
{"version":3,"file":"publickey.mjs","names":["bcs"],"sources":["../../src/cryptography/publickey.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64, toBase64 } from '@mysten/bcs';\nimport { blake2b } from '@noble/hashes/blake2.js';\nimport { bytesToHex } from '@noble/hashes/utils.js';\n\nimport { bcs } from '../bcs/index.js';\nimport { normalizeSuiAddress, SUI_ADDRESS_LENGTH } from '../utils/sui-types.js';\nimport type { IntentScope } from './intent.js';\nimport { messageWithIntent } from './intent.js';\nimport { SIGNATURE_FLAG_TO_SCHEME, SIGNATURE_SCHEME_TO_SIZE } from './signature-scheme.js';\n\n/**\n * Value to be converted into public key.\n */\nexport type PublicKeyInitData = string | Uint8Array | Iterable<number>;\n\nexport function bytesEqual(a: Uint8Array, b: Uint8Array) {\n\tif (a === b) return true;\n\n\tif (a.length !== b.length) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < a.length; i++) {\n\t\tif (a[i] !== b[i]) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * A public key\n */\nexport abstract class PublicKey {\n\t/**\n\t * Checks if two public keys are equal\n\t */\n\tequals(publicKey: PublicKey) {\n\t\treturn bytesEqual(this.toRawBytes(), publicKey.toRawBytes());\n\t}\n\n\t/**\n\t * Return the base-64 representation of the public key\n\t */\n\ttoBase64() {\n\t\treturn toBase64(this.toRawBytes());\n\t}\n\n\ttoString(): never {\n\t\tthrow new Error(\n\t\t\t'`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.',\n\t\t);\n\t}\n\n\t/**\n\t * Return the Sui representation of the public key encoded in\n\t * base-64. A Sui public key is formed by the concatenation\n\t * of the scheme flag with the raw bytes of the public key\n\t */\n\ttoSuiPublicKey(): string {\n\t\tconst bytes = this.toSuiBytes();\n\t\treturn toBase64(bytes);\n\t}\n\n\tverifyWithIntent(\n\t\tbytes: Uint8Array,\n\t\tsignature: Uint8Array | string,\n\t\tintent: IntentScope,\n\t): Promise<boolean> {\n\t\tconst intentMessage = messageWithIntent(intent, bytes);\n\t\tconst digest = blake2b(intentMessage, { dkLen: 32 });\n\n\t\treturn this.verify(digest, signature);\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided PersonalMessage\n\t *\n\t * This checks only this key's own signature. It doesn't check address aliases or zkLogin\n\t * state. To check a signature for an account, use `verifyPersonalMessageSignature` or\n\t * `verifyTransactionSignature` from `@mysten/sui/verify` with `{ client, address }`.\n\t */\n\tverifyPersonalMessage(message: Uint8Array, signature: Uint8Array | string): Promise<boolean> {\n\t\treturn this.verifyWithIntent(\n\t\t\tbcs.byteVector().serialize(message).toBytes(),\n\t\t\tsignature,\n\t\t\t'PersonalMessage',\n\t\t);\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided Transaction\n\t *\n\t * This checks only this key's own signature. It doesn't check address aliases or zkLogin\n\t * state. To check a signature for an account, use `verifyPersonalMessageSignature` or\n\t * `verifyTransactionSignature` from `@mysten/sui/verify` with `{ client, address }`.\n\t */\n\tverifyTransaction(transaction: Uint8Array, signature: Uint8Array | string): Promise<boolean> {\n\t\treturn this.verifyWithIntent(transaction, signature, 'TransactionData');\n\t}\n\n\t/**\n\t * Verifies that the public key is associated with the provided address\n\t *\n\t * This only compares the address derived from this key. It doesn't check address aliases, so\n\t * it isn't an account check: use `@mysten/sui/verify` with `{ client, address }` for that.\n\t */\n\tverifyAddress(address: string): boolean {\n\t\treturn this.toSuiAddress() === normalizeSuiAddress(address);\n\t}\n\n\t/**\n\t * Returns the bytes representation of the public key\n\t * prefixed with the signature scheme flag\n\t */\n\ttoSuiBytes(): Uint8Array<ArrayBuffer> {\n\t\tconst rawBytes = this.toRawBytes();\n\t\tconst suiBytes = new Uint8Array(rawBytes.length + 1);\n\t\tsuiBytes.set([this.flag()]);\n\t\tsuiBytes.set(rawBytes, 1);\n\n\t\treturn suiBytes;\n\t}\n\n\t/**\n\t * Return the Sui address associated with this Ed25519 public key\n\t */\n\ttoSuiAddress(): string {\n\t\t// Each hex char represents half a byte, hence hex address doubles the length\n\t\treturn normalizeSuiAddress(\n\t\t\tbytesToHex(blake2b(this.toSuiBytes(), { dkLen: 32 })).slice(0, SUI_ADDRESS_LENGTH * 2),\n\t\t);\n\t}\n\n\t/**\n\t * Return the byte array representation of the public key\n\t */\n\tabstract toRawBytes(): Uint8Array<ArrayBuffer>;\n\n\t/**\n\t * Return signature scheme flag of the public key\n\t */\n\tabstract flag(): number;\n\n\t/**\n\t * Verifies that the signature is valid for for the provided message\n\t */\n\tabstract verify(data: Uint8Array, signature: Uint8Array | string): Promise<boolean>;\n}\n\nexport function parseSerializedKeypairSignature(serializedSignature: string) {\n\tconst bytes = fromBase64(serializedSignature);\n\n\tconst signatureScheme =\n\t\tSIGNATURE_FLAG_TO_SCHEME[bytes[0] as keyof typeof SIGNATURE_FLAG_TO_SCHEME];\n\n\tswitch (signatureScheme) {\n\t\tcase 'ED25519':\n\t\tcase 'Secp256k1':\n\t\tcase 'Secp256r1':\n\t\tcase 'MLDSA65':\n\t\t\tconst size =\n\t\t\t\tSIGNATURE_SCHEME_TO_SIZE[signatureScheme as keyof typeof SIGNATURE_SCHEME_TO_SIZE];\n\t\t\tconst signature = bytes.slice(1, bytes.length - size);\n\t\t\tconst publicKey = bytes.slice(1 + signature.length);\n\n\t\t\treturn {\n\t\t\t\tserializedSignature,\n\t\t\t\tsignatureScheme,\n\t\t\t\tsignature,\n\t\t\t\tpublicKey,\n\t\t\t\tbytes,\n\t\t\t};\n\t\tdefault:\n\t\t\tthrow new Error('Unsupported signature scheme');\n\t}\n}\n"],"mappings":";;;;;;;;;AAkBA,SAAgB,WAAW,GAAe,GAAe;AACxD,KAAI,MAAM,EAAG,QAAO;AAEpB,KAAI,EAAE,WAAW,EAAE,OAClB,QAAO;AAGR,MAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,IAC7B,KAAI,EAAE,OAAO,EAAE,GACd,QAAO;AAGT,QAAO;;;;;AAMR,IAAsB,YAAtB,MAAgC;;;;CAI/B,OAAO,WAAsB;AAC5B,SAAO,WAAW,KAAK,YAAY,EAAE,UAAU,YAAY,CAAC;;;;;CAM7D,WAAW;AACV,SAAO,SAAS,KAAK,YAAY,CAAC;;CAGnC,WAAkB;AACjB,QAAM,IAAI,MACT,4FACA;;;;;;;CA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s";
|
|
2
2
|
import { SignatureScheme } from "./signature-scheme.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { ParsedMultiSigStruct } from "../multisig/publickey.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/cryptography/signature.d.ts
|
|
6
6
|
/**
|
|
@@ -30,12 +30,6 @@ declare function parseSerializedSignature(serializedSignature: string): {
|
|
|
30
30
|
clientDataJson: string;
|
|
31
31
|
userSignature: Uint8Array<ArrayBuffer>;
|
|
32
32
|
publicKey: Uint8Array<ArrayBuffer>;
|
|
33
|
-
} | {
|
|
34
|
-
serializedSignature: string;
|
|
35
|
-
signatureScheme: "ED25519" | "Secp256k1" | "Secp256r1" | "MLDSA65";
|
|
36
|
-
signature: Uint8Array<ArrayBuffer>;
|
|
37
|
-
publicKey: Uint8Array<ArrayBuffer>;
|
|
38
|
-
bytes: Uint8Array<ArrayBuffer>;
|
|
39
33
|
} | {
|
|
40
34
|
serializedSignature: string;
|
|
41
35
|
signatureScheme: "ZkLogin";
|
|
@@ -60,10 +54,16 @@ declare function parseSerializedSignature(serializedSignature: string): {
|
|
|
60
54
|
};
|
|
61
55
|
signature: Uint8Array<ArrayBufferLike>;
|
|
62
56
|
publicKey: Uint8Array<ArrayBuffer>;
|
|
57
|
+
} | {
|
|
58
|
+
serializedSignature: string;
|
|
59
|
+
signatureScheme: "ED25519" | "Secp256k1" | "Secp256r1" | "MLDSA65";
|
|
60
|
+
signature: Uint8Array<ArrayBuffer>;
|
|
61
|
+
publicKey: Uint8Array<ArrayBuffer>;
|
|
62
|
+
bytes: Uint8Array<ArrayBuffer>;
|
|
63
63
|
} | {
|
|
64
64
|
serializedSignature: string;
|
|
65
65
|
signatureScheme: "MultiSig";
|
|
66
|
-
multisig:
|
|
66
|
+
multisig: ParsedMultiSigStruct;
|
|
67
67
|
bytes: Uint8Array<ArrayBuffer>;
|
|
68
68
|
signature: undefined;
|
|
69
69
|
};
|
|
@@ -26,13 +26,24 @@ function parseSerializedSignature(serializedSignature) {
|
|
|
26
26
|
const signatureScheme = SIGNATURE_FLAG_TO_SCHEME[bytes[0]];
|
|
27
27
|
switch (signatureScheme) {
|
|
28
28
|
case "Passkey": return parseSerializedPasskeySignature(serializedSignature);
|
|
29
|
-
case "MultiSig":
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
case "MultiSig": {
|
|
30
|
+
const parsed = suiBcs.MultiSig.parse(bytes.slice(1));
|
|
31
|
+
const multisigPk = {
|
|
32
|
+
...parsed.multisigPk,
|
|
33
|
+
pk_map: parsed.multisigPk.pkMap
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
serializedSignature,
|
|
37
|
+
signatureScheme,
|
|
38
|
+
multisig: {
|
|
39
|
+
...parsed,
|
|
40
|
+
multisigPk,
|
|
41
|
+
multisig_pk: multisigPk
|
|
42
|
+
},
|
|
43
|
+
bytes,
|
|
44
|
+
signature: void 0
|
|
45
|
+
};
|
|
46
|
+
}
|
|
36
47
|
case "ZkLogin": return parseSerializedZkLoginSignature(serializedSignature);
|
|
37
48
|
case "ED25519":
|
|
38
49
|
case "Secp256k1":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature.mjs","names":["bcs"],"sources":["../../src/cryptography/signature.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64, toBase64 } from '@mysten/bcs';\n\nimport { bcs } from '../bcs/index.js';\nimport { parseSerializedPasskeySignature } from '../keypairs/passkey/publickey.js';\nimport type {
|
|
1
|
+
{"version":3,"file":"signature.mjs","names":["bcs"],"sources":["../../src/cryptography/signature.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64, toBase64 } from '@mysten/bcs';\n\nimport { bcs } from '../bcs/index.js';\nimport { parseSerializedPasskeySignature } from '../keypairs/passkey/publickey.js';\nimport type { ParsedMultiSigStruct } from '../multisig/publickey.js';\nimport { parseSerializedZkLoginSignature } from '../zklogin/publickey.js';\nimport { parseSerializedKeypairSignature } from './publickey.js';\nimport type { PublicKey } from './publickey.js';\nimport type { SignatureScheme } from './signature-scheme.js';\nimport { SIGNATURE_FLAG_TO_SCHEME, SIGNATURE_SCHEME_TO_FLAG } from './signature-scheme.js';\n\n/**\n * Pair of signature and corresponding public key\n */\nexport type SerializeSignatureInput = {\n\tsignatureScheme: SignatureScheme;\n\t/** Base64-encoded signature */\n\tsignature: Uint8Array;\n\t/** Base64-encoded public key */\n\tpublicKey?: PublicKey;\n};\n\n/**\n * Takes in a signature, its associated signing scheme and a public key, then serializes this data\n */\nexport function toSerializedSignature({\n\tsignature,\n\tsignatureScheme,\n\tpublicKey,\n}: SerializeSignatureInput): string {\n\tif (!publicKey) {\n\t\tthrow new Error('`publicKey` is required');\n\t}\n\n\tconst pubKeyBytes = publicKey.toRawBytes();\n\tconst serializedSignature = new Uint8Array(1 + signature.length + pubKeyBytes.length);\n\tserializedSignature.set([SIGNATURE_SCHEME_TO_FLAG[signatureScheme]]);\n\tserializedSignature.set(signature, 1);\n\tserializedSignature.set(pubKeyBytes, 1 + signature.length);\n\treturn toBase64(serializedSignature);\n}\n\n/**\n * Decodes a serialized signature into its constituent components: the signature scheme, the actual signature, and the public key\n */\nexport function parseSerializedSignature(serializedSignature: string) {\n\tconst bytes = fromBase64(serializedSignature);\n\n\tconst signatureScheme =\n\t\tSIGNATURE_FLAG_TO_SCHEME[bytes[0] as keyof typeof SIGNATURE_FLAG_TO_SCHEME];\n\n\tswitch (signatureScheme) {\n\t\tcase 'Passkey':\n\t\t\treturn parseSerializedPasskeySignature(serializedSignature);\n\t\tcase 'MultiSig': {\n\t\t\tconst parsed = bcs.MultiSig.parse(bytes.slice(1));\n\t\t\tconst multisigPk = { ...parsed.multisigPk, pk_map: parsed.multisigPk.pkMap };\n\t\t\tconst multisig: ParsedMultiSigStruct = { ...parsed, multisigPk, multisig_pk: multisigPk };\n\t\t\treturn {\n\t\t\t\tserializedSignature,\n\t\t\t\tsignatureScheme,\n\t\t\t\tmultisig,\n\t\t\t\tbytes,\n\t\t\t\tsignature: undefined,\n\t\t\t};\n\t\t}\n\t\tcase 'ZkLogin':\n\t\t\treturn parseSerializedZkLoginSignature(serializedSignature);\n\t\tcase 'ED25519':\n\t\tcase 'Secp256k1':\n\t\tcase 'Secp256r1':\n\t\tcase 'MLDSA65':\n\t\t\treturn parseSerializedKeypairSignature(serializedSignature);\n\t\tdefault:\n\t\t\tthrow new Error('Unsupported signature scheme');\n\t}\n}\n"],"mappings":";;;;;;;;;;;AA4BA,SAAgB,sBAAsB,EACrC,WACA,iBACA,aACmC;AACnC,KAAI,CAAC,UACJ,OAAM,IAAI,MAAM,0BAA0B;CAG3C,MAAM,cAAc,UAAU,YAAY;CAC1C,MAAM,sBAAsB,IAAI,WAAW,IAAI,UAAU,SAAS,YAAY,OAAO;AACrF,qBAAoB,IAAI,CAAC,yBAAyB,iBAAiB,CAAC;AACpE,qBAAoB,IAAI,WAAW,EAAE;AACrC,qBAAoB,IAAI,aAAa,IAAI,UAAU,OAAO;AAC1D,QAAO,SAAS,oBAAoB;;;;;AAMrC,SAAgB,yBAAyB,qBAA6B;CACrE,MAAM,QAAQ,WAAW,oBAAoB;CAE7C,MAAM,kBACL,yBAAyB,MAAM;AAEhC,SAAQ,iBAAR;EACC,KAAK,UACJ,QAAO,gCAAgC,oBAAoB;EAC5D,KAAK,YAAY;GAChB,MAAM,SAASA,OAAI,SAAS,MAAM,MAAM,MAAM,EAAE,CAAC;GACjD,MAAM,aAAa;IAAE,GAAG,OAAO;IAAY,QAAQ,OAAO,WAAW;IAAO;AAE5E,UAAO;IACN;IACA;IACA,UAJsC;KAAE,GAAG;KAAQ;KAAY,aAAa;KAAY;IAKxF;IACA,WAAW;IACX;;EAEF,KAAK,UACJ,QAAO,gCAAgC,oBAAoB;EAC5D,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,UACJ,QAAO,gCAAgC,oBAAoB;EAC5D,QACC,OAAM,IAAI,MAAM,+BAA+B"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { SuiClientTypes } from "../client/types.mjs";
|
|
2
1
|
import { TransactionPlugin } from "../transactions/resolve.mjs";
|
|
2
|
+
import { SuiClientTypes } from "../client/types.mjs";
|
|
3
3
|
import "../transactions/index.mjs";
|
|
4
4
|
import { BaseClient } from "../client/client.mjs";
|
|
5
5
|
import "../client/index.mjs";
|
|
6
|
-
import { GraphQLCoreClient } from "./core.mjs";
|
|
7
6
|
import { TypedDocumentString } from "./generated/queries.mjs";
|
|
7
|
+
import { GraphQLCoreClient } from "./core.mjs";
|
|
8
|
+
import { SuiGraphQLRequestError } from "./errors.mjs";
|
|
8
9
|
import { DocumentNode } from "graphql";
|
|
9
10
|
import { TadaDocumentNode } from "gql.tada";
|
|
10
11
|
import { TypedDocumentNode } from "@graphql-typed-document-node/core";
|
|
@@ -16,13 +17,17 @@ type GraphQLQueryOptions<Result = Record<string, unknown>, Variables = Record<st
|
|
|
16
17
|
operationName?: string;
|
|
17
18
|
extensions?: Record<string, unknown>;
|
|
18
19
|
signal?: AbortSignal;
|
|
19
|
-
} & (
|
|
20
|
+
} & (Record<string, unknown> extends Variables ? {
|
|
21
|
+
variables?: Variables;
|
|
22
|
+
} : Variables extends {
|
|
20
23
|
[key: string]: never;
|
|
21
24
|
} ? {
|
|
22
25
|
variables?: Variables;
|
|
23
26
|
} : {
|
|
24
27
|
variables: Variables;
|
|
25
28
|
});
|
|
29
|
+
/** Internal: runs a subscription and calls `onOpen` once its event stream opens. */
|
|
30
|
+
type OpenSubscription = <Result, Variables>(options: GraphQLQueryOptions<Result, Variables>, onOpen: () => void) => AsyncGenerator<GraphQLQueryResult<Result>>;
|
|
26
31
|
type GraphQLQueryResult<Result = Record<string, unknown>> = {
|
|
27
32
|
data?: Result;
|
|
28
33
|
errors?: GraphQLResponseErrors;
|
|
@@ -35,43 +40,28 @@ type GraphQLResponseErrors = Array<{
|
|
|
35
40
|
column: number;
|
|
36
41
|
}[];
|
|
37
42
|
path?: (string | number)[];
|
|
43
|
+
extensions?: Record<string, unknown>;
|
|
38
44
|
}>;
|
|
39
45
|
interface SuiGraphQLClientOptions<Queries extends Record<string, GraphQLDocument>> {
|
|
40
46
|
url: string;
|
|
47
|
+
/** SSE endpoint; defaults to the query URL with `/subscriptions` appended. */
|
|
48
|
+
subscriptionUrl?: string;
|
|
41
49
|
fetch?: typeof fetch;
|
|
42
50
|
headers?: Record<string, string>;
|
|
43
51
|
queries?: Queries;
|
|
44
52
|
network: SuiClientTypes.Network;
|
|
45
53
|
mvr?: SuiClientTypes.MvrOptions;
|
|
46
|
-
}
|
|
47
|
-
declare class SuiGraphQLRequestError extends Error {}
|
|
48
|
-
declare const SUI_CLIENT_BRAND: never;
|
|
49
|
-
declare function isSuiGraphQLClient(client: unknown): client is SuiGraphQLClient;
|
|
50
|
-
interface GraphQLSimulateTransactionOptions<Include extends SuiClientTypes.SimulateTransactionInclude = {}> extends SuiClientTypes.SimulateTransactionOptions<Include> {
|
|
51
54
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* set to an empty list (`[]`); the server then pays gas from the sender's address balance or
|
|
56
|
-
* coin objects. Transactions with gas coins set are simulated as-is, and transactions without a
|
|
57
|
-
* gas payment are simulated with a mocked gas coin (reported as `gasPaymentMocked` on the
|
|
58
|
-
* result).
|
|
55
|
+
* `package`, `package::module` or `package::module::function` entries that transactions built
|
|
56
|
+
* with this client can't call. A per-call `restrictedMoveCalls` on `build` or `toJSON` takes
|
|
57
|
+
* precedence. Defaults to `DEFAULT_RESTRICTED_MOVE_CALLS`.
|
|
59
58
|
*/
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
interface DynamicFieldInclude {
|
|
63
|
-
value?: boolean;
|
|
64
|
-
}
|
|
65
|
-
type DynamicFieldEntryWithValue<Include extends DynamicFieldInclude = {}> = SuiClientTypes.DynamicFieldEntry & {
|
|
66
|
-
value: Include extends {
|
|
67
|
-
value: true;
|
|
68
|
-
} ? SuiClientTypes.DynamicFieldValue : undefined;
|
|
69
|
-
};
|
|
70
|
-
interface ListDynamicFieldsWithValueResponse<Include extends DynamicFieldInclude = {}> {
|
|
71
|
-
hasNextPage: boolean;
|
|
72
|
-
cursor: string | null;
|
|
73
|
-
dynamicFields: DynamicFieldEntryWithValue<Include>[];
|
|
59
|
+
restrictedMoveCalls?: readonly string[];
|
|
74
60
|
}
|
|
61
|
+
declare const SUI_CLIENT_BRAND: never;
|
|
62
|
+
declare function isSuiGraphQLClient(client: unknown): client is SuiGraphQLClient;
|
|
63
|
+
/** @deprecated Use SuiClientTypes.SimulateTransactionOptions */
|
|
64
|
+
type GraphQLSimulateTransactionOptions<Include extends SuiClientTypes.SimulateTransactionInclude = {}> = SuiClientTypes.SimulateTransactionOptions<Include>;
|
|
75
65
|
declare class SuiGraphQLClient<Queries extends Record<string, GraphQLDocument> = {}> extends BaseClient implements SuiClientTypes.TransportMethods {
|
|
76
66
|
#private;
|
|
77
67
|
[SUI_CLIENT_BRAND]: boolean;
|
|
@@ -79,13 +69,20 @@ declare class SuiGraphQLClient<Queries extends Record<string, GraphQLDocument> =
|
|
|
79
69
|
get mvr(): SuiClientTypes.MvrMethods;
|
|
80
70
|
constructor({
|
|
81
71
|
url,
|
|
72
|
+
subscriptionUrl,
|
|
82
73
|
fetch: fetchFn,
|
|
83
74
|
headers,
|
|
84
75
|
queries,
|
|
85
76
|
network,
|
|
86
|
-
mvr
|
|
77
|
+
mvr,
|
|
78
|
+
restrictedMoveCalls
|
|
87
79
|
}: SuiGraphQLClientOptions<Queries>);
|
|
88
80
|
query<Result = Record<string, unknown>, Variables = Record<string, unknown>>(options: GraphQLQueryOptions<Result, Variables>): Promise<GraphQLQueryResult<Result>>;
|
|
81
|
+
/**
|
|
82
|
+
* Run a GraphQL subscription over server-sent events. Does not reconnect; transport failures
|
|
83
|
+
* throw `SuiGraphQLRequestError`.
|
|
84
|
+
*/
|
|
85
|
+
subscribe<Result = Record<string, unknown>, Variables = Record<string, unknown>>(options: GraphQLQueryOptions<Result, Variables>): AsyncGenerator<GraphQLQueryResult<Result>>;
|
|
89
86
|
execute<const Query extends Extract<keyof Queries, string>, Result = (Queries[Query] extends GraphQLDocument<infer R, unknown> ? R : Record<string, unknown>), Variables = (Queries[Query] extends GraphQLDocument<unknown, infer V> ? V : Record<string, unknown>)>(query: Query, options: Omit<GraphQLQueryOptions<Result, Variables>, 'query'>): Promise<GraphQLQueryResult<Result>>;
|
|
90
87
|
getObjects<Include extends SuiClientTypes.ObjectInclude = {}>(input: SuiClientTypes.GetObjectsOptions<Include>): Promise<SuiClientTypes.GetObjectsResponse<Include>>;
|
|
91
88
|
getObject<Include extends SuiClientTypes.ObjectInclude = {}>(input: SuiClientTypes.GetObjectOptions<Include>): Promise<SuiClientTypes.GetObjectResponse<Include>>;
|
|
@@ -98,24 +95,43 @@ declare class SuiGraphQLClient<Queries extends Record<string, GraphQLDocument> =
|
|
|
98
95
|
executeTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(input: SuiClientTypes.ExecuteTransactionOptions<Include>): Promise<SuiClientTypes.TransactionResult<Include>>;
|
|
99
96
|
signAndExecuteTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(input: SuiClientTypes.SignAndExecuteTransactionOptions<Include>): Promise<SuiClientTypes.TransactionResult<Include>>;
|
|
100
97
|
waitForTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(input: SuiClientTypes.WaitForTransactionOptions<Include>): Promise<SuiClientTypes.TransactionResult<Include>>;
|
|
101
|
-
simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(input:
|
|
98
|
+
simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(input: SuiClientTypes.SimulateTransactionOptions<Include>): Promise<SuiClientTypes.SimulateTransactionResult<Include>>;
|
|
102
99
|
getReferenceGasPrice(input?: SuiClientTypes.GetReferenceGasPriceOptions): Promise<SuiClientTypes.GetReferenceGasPriceResponse>;
|
|
103
100
|
getCurrentSystemState(input?: SuiClientTypes.GetCurrentSystemStateOptions): Promise<SuiClientTypes.GetCurrentSystemStateResponse>;
|
|
104
101
|
getProtocolConfig(input?: SuiClientTypes.GetProtocolConfigOptions): Promise<SuiClientTypes.GetProtocolConfigResponse>;
|
|
105
102
|
getChainIdentifier(input?: SuiClientTypes.GetChainIdentifierOptions): Promise<SuiClientTypes.GetChainIdentifierResponse>;
|
|
106
|
-
listDynamicFields<Include extends DynamicFieldInclude = {}>(input: SuiClientTypes.ListDynamicFieldsOptions
|
|
107
|
-
include?: Include & DynamicFieldInclude;
|
|
108
|
-
}): Promise<ListDynamicFieldsWithValueResponse<Include>>;
|
|
103
|
+
listDynamicFields<Include extends SuiClientTypes.DynamicFieldInclude = {}>(input: SuiClientTypes.ListDynamicFieldsOptions<Include>): Promise<SuiClientTypes.ListDynamicFieldsResponse<Include>>;
|
|
109
104
|
getDynamicField(input: SuiClientTypes.GetDynamicFieldOptions): Promise<SuiClientTypes.GetDynamicFieldResponse>;
|
|
105
|
+
getAddressAliases(input: SuiClientTypes.GetAddressAliasesOptions): Promise<SuiClientTypes.GetAddressAliasesResponse>;
|
|
110
106
|
getDynamicObjectField<Include extends SuiClientTypes.ObjectInclude = {}>(input: SuiClientTypes.GetDynamicObjectFieldOptions<Include>): Promise<SuiClientTypes.GetDynamicObjectFieldResponse<Include>>;
|
|
111
107
|
listTransactions<Include extends SuiClientTypes.TransactionInclude = {}>(input: SuiClientTypes.ListTransactionsOptions<Include>): Promise<SuiClientTypes.ListTransactionsResponse<Include>>;
|
|
112
108
|
listEvents(input: SuiClientTypes.ListEventsOptions): Promise<SuiClientTypes.ListEventsResponse>;
|
|
109
|
+
listCheckpoints(input: SuiClientTypes.ListCheckpointsOptions): Promise<SuiClientTypes.ListCheckpointsResponse>;
|
|
110
|
+
/**
|
|
111
|
+
* Streams checkpoints in ledger order, resumable from any frame's `resumeToken`, following new
|
|
112
|
+
* checkpoints by default.
|
|
113
|
+
*/
|
|
114
|
+
streamCheckpoints<Include extends SuiClientTypes.StreamCheckpointInclude = {}, Frames extends SuiClientTypes.StreamFrameOptions = {}>(input?: SuiClientTypes.StreamCheckpointsOptions<Include, Frames>): AsyncGenerator<SuiClientTypes.StreamCheckpointFrame<Include, Frames>>;
|
|
115
|
+
/**
|
|
116
|
+
* Streams transactions matching `filter` in ledger order, resumable from any frame's
|
|
117
|
+
* `resumeToken`.
|
|
118
|
+
*/
|
|
119
|
+
streamTransactions<Include extends SuiClientTypes.TransactionInclude = {}, Frames extends SuiClientTypes.StreamFrameOptions = {}>(input?: SuiClientTypes.StreamTransactionsOptions<Include, Frames>): AsyncGenerator<SuiClientTypes.StreamTransactionFrame<Include, Frames>>;
|
|
120
|
+
/**
|
|
121
|
+
* Streams events matching `filter` in ledger order, resumable from any frame's `resumeToken`.
|
|
122
|
+
*/
|
|
123
|
+
streamEvents<Frames extends SuiClientTypes.StreamFrameOptions = {}>(input?: SuiClientTypes.StreamEventsOptions<Frames>): AsyncGenerator<SuiClientTypes.StreamEventFrame<Frames>>;
|
|
113
124
|
getMoveFunction(input: SuiClientTypes.GetMoveFunctionOptions): Promise<SuiClientTypes.GetMoveFunctionResponse>;
|
|
114
125
|
resolveTransactionPlugin(): TransactionPlugin;
|
|
126
|
+
verifySignature(input: SuiClientTypes.VerifySignatureOptions): Promise<SuiClientTypes.VerifySignatureResponse>;
|
|
127
|
+
/**
|
|
128
|
+
* @deprecated Use `verifySignature`. This method accepts signatures from the address's aliases,
|
|
129
|
+
* like `verifySignature` does by default.
|
|
130
|
+
*/
|
|
115
131
|
verifyZkLoginSignature(input: SuiClientTypes.VerifyZkLoginSignatureOptions): Promise<SuiClientTypes.ZkLoginVerifyResponse>;
|
|
116
132
|
defaultNameServiceName(input: SuiClientTypes.DefaultNameServiceNameOptions): Promise<SuiClientTypes.DefaultNameServiceNameResponse>;
|
|
117
133
|
resolveNameServiceAddress(input: SuiClientTypes.ResolveNameServiceAddressOptions): Promise<SuiClientTypes.ResolveNameServiceAddressResponse>;
|
|
118
134
|
}
|
|
119
135
|
//#endregion
|
|
120
|
-
export { GraphQLDocument, GraphQLQueryOptions, GraphQLQueryResult, GraphQLResponseErrors, GraphQLSimulateTransactionOptions, SuiGraphQLClient, SuiGraphQLClientOptions,
|
|
136
|
+
export { GraphQLDocument, GraphQLQueryOptions, GraphQLQueryResult, GraphQLResponseErrors, GraphQLSimulateTransactionOptions, OpenSubscription, SuiGraphQLClient, SuiGraphQLClientOptions, isSuiGraphQLClient };
|
|
121
137
|
//# sourceMappingURL=client.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.mts","names":[],"sources":["../../src/graphql/client.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.mts","names":[],"sources":["../../src/graphql/client.ts"],"mappings":";;;;;;;;;;;;;KAwBY,eAAA,UAAyB,MAAA,+BAAqC,MAAA,8BAEvE,YAAA,GACA,mBAAA,CAAoB,MAAA,EAAQ,SAAA,IAC5B,iBAAA,CAAkB,MAAA,EAAQ,SAAA,IAC1B,gBAAA,CAAiB,MAAA,EAAQ,SAAA;AAAA,KAEhB,mBAAA,UACF,MAAA,+BACG,MAAA;EAEZ,KAAA,EAAO,eAAA,CAAgB,MAAA,EAAQ,SAAA;EAC/B,aAAA;EACA,UAAA,GAAa,MAAA;EACb,MAAA,GAAS,WAAA;AAAA,KACL,MAAA,0BAAgC,SAAA;EAChC,SAAA,GAAY,SAAA;AAAA,IACd,SAAA;EAAA,CAAqB,GAAA;AAAA;EAClB,SAAA,GAAY,SAAA;AAAA;EACZ,SAAA,EAAW,SAAA;AAAA;;KAGL,gBAAA,uBACX,OAAA,EAAS,mBAAA,CAAoB,MAAA,EAAQ,SAAA,GACrC,MAAA,iBACI,cAAA,CAAe,kBAAA,CAAmB,MAAA;AAAA,KAE3B,kBAAA,UAA4B,MAAA;EACvC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AA,GAA4B,iBAAA;EAI5B,eAAA,CACC,KAAA,EAAO,cAAA,CAAe,sBAAA,GACpB,OAAA,CAAQ,cAAA,CAAe,uBAAA;EApZG;;;;EA4Z7B,sBAAA,CACC,KAAA,EAAO,cAAA,CAAe,6BAAA,GACpB,OAAA,CAAQ,cAAA,CAAe,qBAAA;EAI1B,sBAAA,CACC,KAAA,EAAO,cAAA,CAAe,6BAAA,GACpB,OAAA,CAAQ,cAAA,CAAe,8BAAA;EAI1B,yBAAA,CACC,KAAA,EAAO,cAAA,CAAe,gCAAA,GACpB,OAAA,CAAQ,cAAA,CAAe,iCAAA;AAAA"}
|
package/dist/graphql/client.mjs
CHANGED
|
@@ -1,20 +1,37 @@
|
|
|
1
|
-
import { normalizeStructTag } from "../utils/sui-types.mjs";
|
|
2
1
|
import { BaseClient } from "../client/client.mjs";
|
|
3
|
-
import {
|
|
2
|
+
import { httpStatusReason } from "../client/errors.mjs";
|
|
3
|
+
import { abortableAsyncGenerator } from "../utils/abort.mjs";
|
|
4
|
+
import { assertClientUrl } from "../client/utils.mjs";
|
|
4
5
|
import { CLIENT_PROTOCOL_VERSION_HEADER, MAX_PROTOCOL_VERSION } from "../client/protocol-version.mjs";
|
|
5
|
-
import {
|
|
6
|
+
import { SuiGraphQLRequestError } from "./errors.mjs";
|
|
6
7
|
import { GraphQLCoreClient } from "./core.mjs";
|
|
7
|
-
import {
|
|
8
|
+
import { readGraphQLSSE } from "./subscribe.mjs";
|
|
8
9
|
import { print } from "graphql";
|
|
9
10
|
|
|
10
11
|
//#region src/graphql/client.ts
|
|
11
|
-
|
|
12
|
+
/** Serialize the request body before `fetch`, so serialization errors are never retryable. */
|
|
13
|
+
function requestBody(options) {
|
|
14
|
+
return JSON.stringify({
|
|
15
|
+
query: typeof options.query === "string" || options.query instanceof String ? String(options.query) : print(options.query),
|
|
16
|
+
variables: options.variables,
|
|
17
|
+
extensions: options.extensions,
|
|
18
|
+
operationName: options.operationName
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/** `url` with `/subscriptions` appended to its path. */
|
|
22
|
+
function subscriptionUrlFor(url) {
|
|
23
|
+
const suffixAt = url.search(/[?#]/);
|
|
24
|
+
const path = suffixAt === -1 ? url : url.slice(0, suffixAt);
|
|
25
|
+
const suffix = suffixAt === -1 ? "" : url.slice(suffixAt);
|
|
26
|
+
return `${path.replace(/\/$/, "")}/subscriptions${suffix}`;
|
|
27
|
+
}
|
|
12
28
|
const SUI_CLIENT_BRAND = Symbol.for("@mysten/SuiGraphQLClient");
|
|
13
29
|
function isSuiGraphQLClient(client) {
|
|
14
30
|
return typeof client === "object" && client !== null && client[SUI_CLIENT_BRAND] === true;
|
|
15
31
|
}
|
|
16
32
|
var SuiGraphQLClient = class extends BaseClient {
|
|
17
33
|
#url;
|
|
34
|
+
#subscriptionUrl;
|
|
18
35
|
#queries;
|
|
19
36
|
#headers;
|
|
20
37
|
#fetch;
|
|
@@ -24,36 +41,87 @@ var SuiGraphQLClient = class extends BaseClient {
|
|
|
24
41
|
get [SUI_CLIENT_BRAND]() {
|
|
25
42
|
return true;
|
|
26
43
|
}
|
|
27
|
-
constructor({ url, fetch: fetchFn = fetch, headers = {}, queries = {}, network, mvr }) {
|
|
44
|
+
constructor({ url, subscriptionUrl = subscriptionUrlFor(url), fetch: fetchFn = fetch, headers = {}, queries = {}, network, mvr, restrictedMoveCalls }) {
|
|
28
45
|
super({ network });
|
|
46
|
+
assertClientUrl(url, "SuiGraphQLClient url");
|
|
47
|
+
assertClientUrl(subscriptionUrl, "SuiGraphQLClient subscriptionUrl");
|
|
29
48
|
this.#url = url;
|
|
49
|
+
this.#subscriptionUrl = subscriptionUrl;
|
|
30
50
|
this.#queries = queries;
|
|
31
51
|
this.#headers = headers;
|
|
32
52
|
this.#fetch = (...args) => fetchFn(...args);
|
|
33
53
|
this.core = new GraphQLCoreClient({
|
|
34
54
|
graphqlClient: this,
|
|
35
|
-
mvr
|
|
55
|
+
mvr,
|
|
56
|
+
restrictedMoveCalls,
|
|
57
|
+
subscribe: (options, onOpen) => this.#subscribe(options, onOpen)
|
|
36
58
|
});
|
|
37
59
|
}
|
|
38
60
|
async query(options) {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
61
|
+
const res = await this.#fetchResponse(this.#url, {
|
|
62
|
+
method: "POST",
|
|
63
|
+
headers: this.#requestHeaders({ "Content-Type": "application/json" }),
|
|
64
|
+
body: requestBody(options),
|
|
65
|
+
signal: options.signal
|
|
42
66
|
});
|
|
43
|
-
if (!
|
|
44
|
-
|
|
67
|
+
if (!res.ok) throw new SuiGraphQLRequestError(`GraphQL request failed: ${res.statusText} (${res.status})`, { reason: httpStatusReason(res.status) });
|
|
68
|
+
let body;
|
|
69
|
+
try {
|
|
70
|
+
body = await res.text();
|
|
71
|
+
} catch (cause) {
|
|
72
|
+
options.signal?.throwIfAborted();
|
|
73
|
+
throw new SuiGraphQLRequestError("GraphQL response body could not be read", {
|
|
74
|
+
reason: "Unavailable",
|
|
75
|
+
cause
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
return JSON.parse(body);
|
|
80
|
+
} catch (cause) {
|
|
81
|
+
throw new SuiGraphQLRequestError("Invalid GraphQL response", { cause });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Run a GraphQL subscription over server-sent events. Does not reconnect; transport failures
|
|
86
|
+
* throw `SuiGraphQLRequestError`.
|
|
87
|
+
*/
|
|
88
|
+
subscribe(options) {
|
|
89
|
+
return this.#subscribe(options);
|
|
90
|
+
}
|
|
91
|
+
#subscribe(options, onOpen) {
|
|
92
|
+
return abortableAsyncGenerator((signal) => this.#runSubscription(options, signal, onOpen), options.signal);
|
|
93
|
+
}
|
|
94
|
+
async *#runSubscription(options, signal, onOpen) {
|
|
95
|
+
yield* readGraphQLSSE(await this.#fetchResponse(this.#subscriptionUrl, {
|
|
45
96
|
method: "POST",
|
|
46
|
-
headers
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
variables: options.variables,
|
|
50
|
-
extensions: options.extensions,
|
|
51
|
-
operationName: options.operationName
|
|
97
|
+
headers: this.#requestHeaders({
|
|
98
|
+
"Content-Type": "application/json",
|
|
99
|
+
Accept: "text/event-stream"
|
|
52
100
|
}),
|
|
53
|
-
|
|
101
|
+
body: requestBody(options),
|
|
102
|
+
signal
|
|
103
|
+
}), signal, onOpen);
|
|
104
|
+
}
|
|
105
|
+
#requestHeaders(defaults) {
|
|
106
|
+
const headers = new Headers({
|
|
107
|
+
...defaults,
|
|
108
|
+
...this.#headers
|
|
54
109
|
});
|
|
55
|
-
if (!
|
|
56
|
-
return
|
|
110
|
+
if (!headers.has(CLIENT_PROTOCOL_VERSION_HEADER)) headers.set(CLIENT_PROTOCOL_VERSION_HEADER, String(MAX_PROTOCOL_VERSION));
|
|
111
|
+
return headers;
|
|
112
|
+
}
|
|
113
|
+
/** `fetch` that reports a network failure (a `TypeError`) as a retryable request error. */
|
|
114
|
+
async #fetchResponse(url, init) {
|
|
115
|
+
try {
|
|
116
|
+
return await this.#fetch(url, init);
|
|
117
|
+
} catch (cause) {
|
|
118
|
+
init.signal?.throwIfAborted();
|
|
119
|
+
if (!(cause instanceof TypeError)) throw cause;
|
|
120
|
+
throw new SuiGraphQLRequestError("GraphQL network request failed", {
|
|
121
|
+
reason: "Unavailable",
|
|
122
|
+
cause
|
|
123
|
+
});
|
|
124
|
+
}
|
|
57
125
|
}
|
|
58
126
|
async execute(query, options) {
|
|
59
127
|
return this.query({
|
|
@@ -109,57 +177,15 @@ var SuiGraphQLClient = class extends BaseClient {
|
|
|
109
177
|
getChainIdentifier(input) {
|
|
110
178
|
return this.core.getChainIdentifier(input);
|
|
111
179
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const { data, errors } = await this.query({
|
|
115
|
-
query: GetDynamicFieldsDocument,
|
|
116
|
-
signal: input.signal,
|
|
117
|
-
variables: {
|
|
118
|
-
parentId: input.parentId,
|
|
119
|
-
first: input.limit,
|
|
120
|
-
cursor: input.cursor,
|
|
121
|
-
includeValue
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
if (errors?.length) throw errors.length === 1 ? new Error(errors[0].message) : new AggregateError(errors.map((e) => new Error(e.message)));
|
|
125
|
-
const result = data?.address?.dynamicFields;
|
|
126
|
-
if (!result) throw new Error("Missing response data");
|
|
127
|
-
return {
|
|
128
|
-
dynamicFields: result.nodes.map((dynamicField) => {
|
|
129
|
-
const valueType = dynamicField.value?.__typename === "MoveObject" ? dynamicField.value.contents?.type?.repr : dynamicField.value?.type?.repr;
|
|
130
|
-
const isDynamicObject = dynamicField.value?.__typename === "MoveObject";
|
|
131
|
-
const derivedNameType = isDynamicObject ? `0x2::dynamic_object_field::Wrapper<${dynamicField.name?.type?.repr}>` : dynamicField.name?.type?.repr;
|
|
132
|
-
let value;
|
|
133
|
-
if (includeValue) {
|
|
134
|
-
let valueBcs;
|
|
135
|
-
if (dynamicField.value?.__typename === "MoveValue") valueBcs = fromBase64(dynamicField.value.bcs ?? "");
|
|
136
|
-
else if (dynamicField.value?.__typename === "MoveObject") valueBcs = fromBase64(dynamicField.value.contents?.bcs ?? "");
|
|
137
|
-
else valueBcs = new Uint8Array();
|
|
138
|
-
value = {
|
|
139
|
-
type: valueType,
|
|
140
|
-
bcs: valueBcs
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
return {
|
|
144
|
-
$kind: isDynamicObject ? "DynamicObject" : "DynamicField",
|
|
145
|
-
fieldId: deriveDynamicFieldID(input.parentId, derivedNameType, fromBase64(dynamicField.name?.bcs)),
|
|
146
|
-
type: normalizeStructTag(isDynamicObject ? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${dynamicField.name?.type?.repr}>,0x2::object::ID>` : `0x2::dynamic_field::Field<${dynamicField.name?.type?.repr},${valueType}>`),
|
|
147
|
-
name: {
|
|
148
|
-
type: dynamicField.name?.type?.repr,
|
|
149
|
-
bcs: fromBase64(dynamicField.name?.bcs)
|
|
150
|
-
},
|
|
151
|
-
valueType,
|
|
152
|
-
childId: isDynamicObject && dynamicField.value?.__typename === "MoveObject" ? dynamicField.value.address : void 0,
|
|
153
|
-
value: includeValue ? value : void 0
|
|
154
|
-
};
|
|
155
|
-
}),
|
|
156
|
-
cursor: result.pageInfo.endCursor ?? null,
|
|
157
|
-
hasNextPage: result.pageInfo.hasNextPage
|
|
158
|
-
};
|
|
180
|
+
listDynamicFields(input) {
|
|
181
|
+
return this.core.listDynamicFields(input);
|
|
159
182
|
}
|
|
160
183
|
getDynamicField(input) {
|
|
161
184
|
return this.core.getDynamicField(input);
|
|
162
185
|
}
|
|
186
|
+
getAddressAliases(input) {
|
|
187
|
+
return this.core.getAddressAliases(input);
|
|
188
|
+
}
|
|
163
189
|
getDynamicObjectField(input) {
|
|
164
190
|
return this.core.getDynamicObjectField(input);
|
|
165
191
|
}
|
|
@@ -169,12 +195,42 @@ var SuiGraphQLClient = class extends BaseClient {
|
|
|
169
195
|
listEvents(input) {
|
|
170
196
|
return this.core.listEvents(input);
|
|
171
197
|
}
|
|
198
|
+
listCheckpoints(input) {
|
|
199
|
+
return this.core.listCheckpoints(input);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Streams checkpoints in ledger order, resumable from any frame's `resumeToken`, following new
|
|
203
|
+
* checkpoints by default.
|
|
204
|
+
*/
|
|
205
|
+
streamCheckpoints(input) {
|
|
206
|
+
return this.core.streamCheckpoints(input);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Streams transactions matching `filter` in ledger order, resumable from any frame's
|
|
210
|
+
* `resumeToken`.
|
|
211
|
+
*/
|
|
212
|
+
streamTransactions(input) {
|
|
213
|
+
return this.core.streamTransactions(input);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Streams events matching `filter` in ledger order, resumable from any frame's `resumeToken`.
|
|
217
|
+
*/
|
|
218
|
+
streamEvents(input) {
|
|
219
|
+
return this.core.streamEvents(input);
|
|
220
|
+
}
|
|
172
221
|
getMoveFunction(input) {
|
|
173
222
|
return this.core.getMoveFunction(input);
|
|
174
223
|
}
|
|
175
224
|
resolveTransactionPlugin() {
|
|
176
225
|
return this.core.resolveTransactionPlugin();
|
|
177
226
|
}
|
|
227
|
+
verifySignature(input) {
|
|
228
|
+
return this.core.verifySignature(input);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* @deprecated Use `verifySignature`. This method accepts signatures from the address's aliases,
|
|
232
|
+
* like `verifySignature` does by default.
|
|
233
|
+
*/
|
|
178
234
|
verifyZkLoginSignature(input) {
|
|
179
235
|
return this.core.verifyZkLoginSignature(input);
|
|
180
236
|
}
|
|
@@ -187,5 +243,5 @@ var SuiGraphQLClient = class extends BaseClient {
|
|
|
187
243
|
};
|
|
188
244
|
|
|
189
245
|
//#endregion
|
|
190
|
-
export { SuiGraphQLClient,
|
|
246
|
+
export { SuiGraphQLClient, isSuiGraphQLClient };
|
|
191
247
|
//# sourceMappingURL=client.mjs.map
|