@mysten/sui 2.39.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +160 -0
- package/README.md +5 -188
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/bcs/bcs.d.mts.map +1 -1
- package/dist/bcs/bcs.mjs +49 -22
- package/dist/bcs/bcs.mjs.map +1 -1
- package/dist/bcs/effects.mjs +49 -20
- package/dist/bcs/effects.mjs.map +1 -1
- package/dist/bcs/index.d.mts +1441 -624
- package/dist/bcs/index.d.mts.map +1 -1
- package/dist/bcs/index.mjs +2 -1
- package/dist/bcs/index.mjs.map +1 -1
- package/dist/bcs/transactions.d.mts +1059 -0
- package/dist/bcs/transactions.d.mts.map +1 -0
- package/dist/bcs/transactions.mjs +33 -14
- package/dist/bcs/transactions.mjs.map +1 -1
- package/dist/bcs/types.d.mts +6 -1
- package/dist/bcs/types.d.mts.map +1 -1
- package/dist/client/core-resolver.mjs +4 -4
- package/dist/client/core-resolver.mjs.map +1 -1
- package/dist/client/core.d.mts +55 -4
- package/dist/client/core.d.mts.map +1 -1
- package/dist/client/core.mjs +98 -1
- package/dist/client/core.mjs.map +1 -1
- package/dist/client/errors.mjs +11 -1
- package/dist/client/errors.mjs.map +1 -1
- package/dist/client/index.d.mts +4 -2
- package/dist/client/index.mjs +5 -2
- package/dist/client/mvr.d.mts +12 -2
- package/dist/client/mvr.d.mts.map +1 -1
- package/dist/client/mvr.mjs +34 -13
- package/dist/client/mvr.mjs.map +1 -1
- package/dist/client/query-filters.mjs +80 -76
- package/dist/client/query-filters.mjs.map +1 -1
- package/dist/client/stream/adapter.d.mts +102 -0
- package/dist/client/stream/adapter.d.mts.map +1 -0
- package/dist/client/stream/errors.d.mts +14 -0
- package/dist/client/stream/errors.d.mts.map +1 -0
- package/dist/client/stream/errors.mjs +25 -0
- package/dist/client/stream/errors.mjs.map +1 -0
- package/dist/client/stream/filter.mjs +18 -0
- package/dist/client/stream/filter.mjs.map +1 -0
- package/dist/client/stream/follow.mjs +48 -0
- package/dist/client/stream/follow.mjs.map +1 -0
- package/dist/client/stream/index.d.mts +4 -0
- package/dist/client/stream/pager.mjs +123 -0
- package/dist/client/stream/pager.mjs.map +1 -0
- package/dist/client/stream/plan.mjs +79 -0
- package/dist/client/stream/plan.mjs.map +1 -0
- package/dist/client/stream/position.d.mts +30 -0
- package/dist/client/stream/position.d.mts.map +1 -0
- package/dist/client/stream/position.mjs +121 -0
- package/dist/client/stream/position.mjs.map +1 -0
- package/dist/client/stream/run.d.mts +2 -0
- package/dist/client/stream/run.mjs +99 -0
- package/dist/client/stream/run.mjs.map +1 -0
- package/dist/client/stream/session.mjs +205 -0
- package/dist/client/stream/session.mjs.map +1 -0
- package/dist/client/stream/status.mjs +47 -0
- package/dist/client/stream/status.mjs.map +1 -0
- package/dist/client/stream/token.mjs +80 -0
- package/dist/client/stream/token.mjs.map +1 -0
- package/dist/client/transaction-data.d.mts +12 -0
- package/dist/client/transaction-data.d.mts.map +1 -0
- package/dist/client/transaction-data.mjs +469 -0
- package/dist/client/transaction-data.mjs.map +1 -0
- package/dist/client/transaction-resolver.mjs +102 -58
- package/dist/client/transaction-resolver.mjs.map +1 -1
- package/dist/client/types.d.mts +560 -240
- package/dist/client/types.d.mts.map +1 -1
- package/dist/client/utils.d.mts +3 -1
- package/dist/client/utils.d.mts.map +1 -1
- package/dist/client/utils.mjs +91 -26
- package/dist/client/utils.mjs.map +1 -1
- package/dist/cryptography/index.d.mts +1 -1
- package/dist/cryptography/keypair.d.mts +1 -1
- package/dist/cryptography/publickey.d.mts +11 -0
- package/dist/cryptography/publickey.d.mts.map +1 -1
- package/dist/cryptography/publickey.mjs +12 -1
- package/dist/cryptography/publickey.mjs.map +1 -1
- package/dist/cryptography/signature.d.mts +2 -2
- package/dist/cryptography/signature.mjs +18 -7
- package/dist/cryptography/signature.mjs.map +1 -1
- package/dist/graphql/client.d.mts +51 -35
- package/dist/graphql/client.d.mts.map +1 -1
- package/dist/graphql/client.mjs +125 -69
- package/dist/graphql/client.mjs.map +1 -1
- package/dist/graphql/core.d.mts +14 -9
- package/dist/graphql/core.d.mts.map +1 -1
- package/dist/graphql/core.mjs +293 -117
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/errors.d.mts +20 -0
- package/dist/graphql/errors.d.mts.map +1 -0
- package/dist/graphql/errors.mjs +19 -0
- package/dist/graphql/errors.mjs.map +1 -0
- package/dist/graphql/filters.mjs +32 -0
- package/dist/graphql/filters.mjs.map +1 -0
- package/dist/graphql/generated/queries.d.mts.map +1 -1
- package/dist/graphql/generated/queries.mjs +1216 -208
- package/dist/graphql/generated/queries.mjs.map +1 -1
- package/dist/graphql/generated/tada-env.d.mts +820 -11
- package/dist/graphql/index.d.mts +2 -1
- package/dist/graphql/index.mjs +2 -1
- package/dist/graphql/sse-parser.mjs +82 -0
- package/dist/graphql/sse-parser.mjs.map +1 -0
- package/dist/graphql/stream/families.mjs +306 -0
- package/dist/graphql/stream/families.mjs.map +1 -0
- package/dist/graphql/stream/index.mjs +38 -0
- package/dist/graphql/stream/index.mjs.map +1 -0
- package/dist/graphql/stream/live.mjs +60 -0
- package/dist/graphql/stream/live.mjs.map +1 -0
- package/dist/graphql/stream/page.mjs +38 -0
- package/dist/graphql/stream/page.mjs.map +1 -0
- package/dist/graphql/stream/query.mjs +47 -0
- package/dist/graphql/stream/query.mjs.map +1 -0
- package/dist/graphql/subscribe.mjs +70 -0
- package/dist/graphql/subscribe.mjs.map +1 -0
- package/dist/grpc/client.d.mts +31 -27
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs +42 -46
- package/dist/grpc/client.mjs.map +1 -1
- package/dist/grpc/core.d.mts +13 -6
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +254 -166
- package/dist/grpc/core.mjs.map +1 -1
- package/dist/grpc/filters.mjs +44 -34
- package/dist/grpc/filters.mjs.map +1 -1
- package/dist/grpc/grpc-web-pull.mjs +245 -0
- package/dist/grpc/grpc-web-pull.mjs.map +1 -0
- package/dist/grpc/index.d.mts +2 -1
- package/dist/grpc/index.mjs +1 -1
- package/dist/grpc/network-error.mjs +31 -0
- package/dist/grpc/network-error.mjs.map +1 -0
- package/dist/grpc/proto/google/rpc/error_details.mjs +306 -0
- package/dist/grpc/proto/google/rpc/error_details.mjs.map +1 -0
- package/dist/grpc/proto/sui/rpc/v2/error_reason.d.mts +176 -1
- package/dist/grpc/proto/sui/rpc/v2/error_reason.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/error_reason.mjs +175 -0
- package/dist/grpc/proto/sui/rpc/v2/error_reason.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/executed_transaction.d.mts +2 -2
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts +111 -0
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs +46 -0
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.d.mts +24 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.mjs +25 -7
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/object.mjs +1 -1
- package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts +111 -9
- package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/query_options.mjs +63 -19
- package/dist/grpc/proto/sui/rpc/v2/query_options.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature.d.mts +5 -5
- package/dist/grpc/proto/sui/rpc/v2/signature.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_scheme.d.mts +5 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_scheme.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_scheme.mjs +4 -0
- package/dist/grpc/proto/sui/rpc/v2/signature_scheme.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.d.mts +20 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.mjs +30 -13
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +16 -10
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs +8 -5
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts +11 -5
- package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction.mjs +6 -0
- package/dist/grpc/proto/sui/rpc/v2/transaction.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts +6 -2
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs.map +1 -1
- package/dist/grpc/proto/types.d.mts +7 -7
- package/dist/grpc/proto/types.mjs +3 -2
- package/dist/grpc/pull-call.d.mts +20 -0
- package/dist/grpc/pull-call.d.mts.map +1 -0
- package/dist/grpc/pull-call.mjs +28 -0
- package/dist/grpc/pull-call.mjs.map +1 -0
- package/dist/grpc/stream/call.mjs +238 -0
- package/dist/grpc/stream/call.mjs.map +1 -0
- package/dist/grpc/stream/families.d.mts +26 -0
- package/dist/grpc/stream/families.d.mts.map +1 -0
- package/dist/grpc/stream/families.mjs +145 -0
- package/dist/grpc/stream/families.mjs.map +1 -0
- package/dist/grpc/stream/index.d.mts +41 -0
- package/dist/grpc/stream/index.d.mts.map +1 -0
- package/dist/grpc/stream/index.mjs +127 -0
- package/dist/grpc/stream/index.mjs.map +1 -0
- package/dist/grpc/stream/live.mjs +31 -0
- package/dist/grpc/stream/live.mjs.map +1 -0
- package/dist/grpc/stream/page.mjs +120 -0
- package/dist/grpc/stream/page.mjs.map +1 -0
- package/dist/grpc/stream-types.d.mts +28 -0
- package/dist/grpc/stream-types.d.mts.map +1 -0
- package/dist/grpc/transport.d.mts +8 -3
- package/dist/grpc/transport.d.mts.map +1 -1
- package/dist/grpc/transport.mjs +88 -45
- package/dist/grpc/transport.mjs.map +1 -1
- package/dist/jsonRpc/index.d.mts +34 -12
- package/dist/jsonRpc/index.d.mts.map +1 -0
- package/dist/jsonRpc/index.mjs +39 -5
- package/dist/jsonRpc/index.mjs.map +1 -0
- package/dist/jsonRpc/types.d.mts +420 -0
- package/dist/jsonRpc/types.d.mts.map +1 -0
- package/dist/keypairs/passkey/keypair.d.mts +1 -1
- package/dist/multisig/publickey.d.mts +12 -4
- package/dist/multisig/publickey.d.mts.map +1 -1
- package/dist/multisig/publickey.mjs +5 -5
- package/dist/multisig/publickey.mjs.map +1 -1
- package/dist/multisig/signer.d.mts +1 -1
- package/dist/transactions/ObjectCache.d.mts +1 -1
- package/dist/transactions/ObjectCache.mjs +5 -5
- package/dist/transactions/ObjectCache.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +11 -10
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/transactions/Transaction.mjs +17 -6
- package/dist/transactions/Transaction.mjs.map +1 -1
- package/dist/transactions/data/internal.d.mts +135 -133
- package/dist/transactions/data/internal.d.mts.map +1 -1
- package/dist/transactions/data/internal.mjs +2 -1
- package/dist/transactions/data/internal.mjs.map +1 -1
- package/dist/transactions/data/v1.d.mts +239 -239
- package/dist/transactions/data/v1.d.mts.map +1 -1
- package/dist/transactions/data/v2.d.mts +16 -16
- package/dist/transactions/data/v2.d.mts.map +1 -1
- package/dist/transactions/executor/parallel.d.mts +2 -2
- package/dist/transactions/executor/serial.d.mts +1 -1
- package/dist/transactions/executor/serial.mjs +2 -2
- package/dist/transactions/executor/serial.mjs.map +1 -1
- package/dist/transactions/index.d.mts +3 -2
- package/dist/transactions/index.mjs +4 -3
- package/dist/transactions/intents/AllowanceBalance.mjs +1 -1
- package/dist/transactions/intents/CoinWithBalance.mjs +1 -1
- package/dist/transactions/resolve.d.mts +6 -0
- package/dist/transactions/resolve.d.mts.map +1 -1
- package/dist/transactions/resolve.mjs.map +1 -1
- package/dist/transactions/restricted-move-calls.d.mts +25 -0
- package/dist/transactions/restricted-move-calls.d.mts.map +1 -0
- package/dist/transactions/restricted-move-calls.mjs +47 -0
- package/dist/transactions/restricted-move-calls.mjs.map +1 -0
- package/dist/transactions/serializer.d.mts +1 -4
- package/dist/transactions/serializer.d.mts.map +1 -1
- package/dist/transactions/serializer.mjs +1 -44
- package/dist/transactions/serializer.mjs.map +1 -1
- package/dist/transactions/utils.d.mts +0 -1
- package/dist/transactions/utils.d.mts.map +1 -1
- package/dist/transactions/utils.mjs.map +1 -1
- package/dist/utils/abort.mjs +89 -0
- package/dist/utils/abort.mjs.map +1 -0
- package/dist/utils/coin-reservation.mjs +1 -4
- package/dist/utils/coin-reservation.mjs.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/sui-types.mjs +1 -1
- package/dist/verify/index.d.mts +2 -2
- package/dist/verify/verify.d.mts +74 -24
- package/dist/verify/verify.d.mts.map +1 -1
- package/dist/verify/verify.mjs +128 -42
- package/dist/verify/verify.mjs.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/dist/zklogin/publickey.d.mts.map +1 -1
- package/dist/zklogin/publickey.mjs +15 -20
- package/dist/zklogin/publickey.mjs.map +1 -1
- package/docs/bcs.md +2 -2
- package/docs/clients/core.md +19 -18
- package/docs/clients/executing.md +53 -8
- package/docs/clients/graphql.md +81 -11
- package/docs/clients/grpc.md +31 -15
- package/docs/clients/index.md +8 -7
- package/docs/clients/querying.md +134 -30
- package/docs/clients/streaming.md +324 -0
- package/docs/cryptography/index.md +85 -58
- package/docs/llms-index.md +4 -2
- package/docs/migrations/sui-2.0/dapp-kit.md +3 -2
- package/docs/migrations/sui-2.0/json-rpc-migration.md +106 -79
- package/docs/migrations/sui-3.0/index.md +250 -0
- package/docs/plugins.md +10 -10
- package/docs/sdk-building.md +3 -4
- package/docs/transactions/coins-and-balances.md +6 -11
- package/docs/transactions/reference.md +36 -1
- package/package.json +2 -3
- package/src/bcs/bcs.ts +80 -41
- package/src/bcs/effects.ts +61 -25
- package/src/bcs/index.ts +2 -0
- package/src/bcs/transactions.ts +36 -17
- package/src/bcs/types.ts +10 -4
- package/src/client/core-resolver.ts +3 -5
- package/src/client/core.ts +180 -8
- package/src/client/errors.ts +12 -0
- package/src/client/index.ts +4 -1
- package/src/client/mvr.ts +37 -10
- package/src/client/query-filters.ts +151 -97
- package/src/client/stream/adapter.ts +110 -0
- package/src/client/stream/errors.ts +40 -0
- package/src/client/stream/filter.ts +17 -0
- package/src/client/stream/follow.ts +63 -0
- package/src/client/stream/index.ts +9 -0
- package/src/client/stream/pager.ts +158 -0
- package/src/client/stream/plan.ts +147 -0
- package/src/client/stream/position.ts +143 -0
- package/src/client/stream/run.ts +147 -0
- package/src/client/stream/session.ts +259 -0
- package/src/client/stream/status.ts +44 -0
- package/src/client/stream/token.ts +104 -0
- package/src/client/transaction-data.ts +587 -0
- package/src/client/transaction-resolver.ts +158 -69
- package/src/client/types.ts +530 -115
- package/src/client/utils.ts +147 -50
- package/src/cryptography/publickey.ts +12 -1
- package/src/cryptography/signature.ts +6 -3
- package/src/graphql/client.ts +204 -135
- package/src/graphql/core.ts +446 -139
- package/src/graphql/errors.ts +24 -0
- package/src/graphql/filters.ts +48 -0
- package/src/graphql/generated/queries.ts +1455 -277
- package/src/graphql/generated/schema.graphql +282 -9
- package/src/graphql/generated/tada-env.ts +933 -4
- package/src/graphql/queries/checkpoints.graphql +34 -0
- package/src/graphql/queries/getDynamicFields.graphql +1 -0
- package/src/graphql/queries/listEvents.graphql +16 -24
- package/src/graphql/queries/streams.graphql +212 -0
- package/src/graphql/queries/transactions.graphql +71 -28
- package/src/graphql/queries/verifySignature.graphql +17 -0
- package/src/graphql/sse-parser.ts +99 -0
- package/src/graphql/stream/families.ts +515 -0
- package/src/graphql/stream/index.ts +55 -0
- package/src/graphql/stream/live.ts +70 -0
- package/src/graphql/stream/page.ts +47 -0
- package/src/graphql/stream/query.ts +52 -0
- package/src/graphql/subscribe.ts +83 -0
- package/src/grpc/client.ts +81 -79
- package/src/grpc/core.ts +388 -274
- package/src/grpc/filters.ts +59 -60
- package/src/grpc/grpc-web-pull.ts +360 -0
- package/src/grpc/index.ts +5 -0
- package/src/grpc/network-error.ts +33 -0
- package/src/grpc/proto/sui/rpc/v2/error_reason.ts +175 -0
- package/src/grpc/proto/sui/rpc/v2/ledger_service.ts +145 -0
- package/src/grpc/proto/sui/rpc/v2/move_package_service.ts +43 -1
- package/src/grpc/proto/sui/rpc/v2/query_options.ts +132 -8
- package/src/grpc/proto/sui/rpc/v2/signature.ts +4 -4
- package/src/grpc/proto/sui/rpc/v2/signature_scheme.ts +4 -0
- package/src/grpc/proto/sui/rpc/v2/signature_verification_service.ts +30 -0
- package/src/grpc/proto/sui/rpc/v2/subscription_service.client.ts +16 -10
- package/src/grpc/proto/sui/rpc/v2/transaction.ts +6 -0
- package/src/grpc/proto/sui/rpc/v2/transaction_execution_service.ts +5 -1
- package/src/grpc/pull-call.ts +54 -0
- package/src/grpc/stream/call.ts +317 -0
- package/src/grpc/stream/families.ts +228 -0
- package/src/grpc/stream/index.ts +182 -0
- package/src/grpc/stream/live.ts +33 -0
- package/src/grpc/stream/page.ts +161 -0
- package/src/grpc/stream-types.ts +33 -0
- package/src/grpc/transport.ts +116 -59
- package/src/jsonRpc/index.ts +60 -17
- package/src/jsonRpc/types.ts +421 -0
- package/src/multisig/publickey.ts +19 -7
- package/src/transactions/ObjectCache.ts +6 -6
- package/src/transactions/Transaction.ts +30 -6
- package/src/transactions/data/internal.ts +2 -0
- package/src/transactions/executor/serial.ts +2 -2
- package/src/transactions/index.ts +8 -1
- package/src/transactions/resolve.ts +6 -0
- package/src/transactions/restricted-move-calls.ts +87 -0
- package/src/transactions/serializer.ts +0 -70
- package/src/transactions/utils.ts +0 -37
- package/src/utils/abort.ts +101 -0
- package/src/verify/index.ts +1 -0
- package/src/verify/verify.ts +190 -62
- package/src/version.ts +1 -1
- package/src/zklogin/publickey.ts +18 -34
- package/dist/client/core-resolver.d.mts +0 -9
- package/dist/client/core-resolver.d.mts.map +0 -1
- package/dist/jsonRpc/client.d.mts +0 -507
- package/dist/jsonRpc/client.d.mts.map +0 -1
- package/dist/jsonRpc/client.mjs +0 -868
- package/dist/jsonRpc/client.mjs.map +0 -1
- package/dist/jsonRpc/core.d.mts +0 -168
- package/dist/jsonRpc/core.d.mts.map +0 -1
- package/dist/jsonRpc/core.mjs +0 -1054
- package/dist/jsonRpc/core.mjs.map +0 -1
- package/dist/jsonRpc/errors.d.mts +0 -27
- package/dist/jsonRpc/errors.d.mts.map +0 -1
- package/dist/jsonRpc/errors.mjs +0 -50
- package/dist/jsonRpc/errors.mjs.map +0 -1
- package/dist/jsonRpc/http-transport.d.mts +0 -62
- package/dist/jsonRpc/http-transport.d.mts.map +0 -1
- package/dist/jsonRpc/http-transport.mjs +0 -60
- package/dist/jsonRpc/http-transport.mjs.map +0 -1
- package/dist/jsonRpc/network.d.mts +0 -9
- package/dist/jsonRpc/network.d.mts.map +0 -1
- package/dist/jsonRpc/network.mjs +0 -18
- package/dist/jsonRpc/network.mjs.map +0 -1
- package/dist/jsonRpc/types/chain.d.mts +0 -169
- package/dist/jsonRpc/types/chain.d.mts.map +0 -1
- package/dist/jsonRpc/types/changes.d.mts +0 -48
- package/dist/jsonRpc/types/changes.d.mts.map +0 -1
- package/dist/jsonRpc/types/coins.d.mts +0 -15
- package/dist/jsonRpc/types/coins.d.mts.map +0 -1
- package/dist/jsonRpc/types/common.d.mts +0 -9
- package/dist/jsonRpc/types/common.d.mts.map +0 -1
- package/dist/jsonRpc/types/generated.d.mts +0 -1976
- package/dist/jsonRpc/types/generated.d.mts.map +0 -1
- package/dist/jsonRpc/types/index.d.mts +0 -6
- package/dist/jsonRpc/types/params.d.mts +0 -898
- package/dist/jsonRpc/types/params.d.mts.map +0 -1
- package/src/graphql/generated/tsconfig.tada.json +0 -11
- package/src/graphql/queries/verifyZkLoginSignature.graphql +0 -15
- package/src/jsonRpc/client.ts +0 -1252
- package/src/jsonRpc/core.ts +0 -1557
- package/src/jsonRpc/errors.ts +0 -57
- package/src/jsonRpc/http-transport.ts +0 -118
- package/src/jsonRpc/network.ts +0 -21
- package/src/jsonRpc/types/chain.ts +0 -190
- package/src/jsonRpc/types/changes.ts +0 -35
- package/src/jsonRpc/types/coins.ts +0 -14
- package/src/jsonRpc/types/common.ts +0 -8
- package/src/jsonRpc/types/generated.ts +0 -2165
- package/src/jsonRpc/types/index.ts +0 -9
- package/src/jsonRpc/types/params.ts +0 -908
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Mysten Labs, Inc.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
export {
|
|
4
|
+
export { getPureBcsSchema } from './serializer.js';
|
|
5
5
|
|
|
6
6
|
export { Inputs } from './Inputs.js';
|
|
7
7
|
export {
|
|
@@ -46,6 +46,13 @@ export type {
|
|
|
46
46
|
TransactionPlugin,
|
|
47
47
|
} from './resolve.js';
|
|
48
48
|
|
|
49
|
+
export {
|
|
50
|
+
DEFAULT_RESTRICTED_MOVE_CALLS,
|
|
51
|
+
findRestrictedMoveCalls,
|
|
52
|
+
type RestrictedMoveCall,
|
|
53
|
+
validateRestrictedMoveCalls,
|
|
54
|
+
} from './restricted-move-calls.js';
|
|
55
|
+
|
|
49
56
|
export { Arguments } from './Arguments.js';
|
|
50
57
|
|
|
51
58
|
export { isArgument } from './utils.js';
|
|
@@ -22,6 +22,12 @@ export interface BuildTransactionOptions {
|
|
|
22
22
|
* address balance). Execution fails if the balances aren't there.
|
|
23
23
|
*/
|
|
24
24
|
assumeSufficientAddressBalances?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* `package`, `package::module` or `package::module::function` entries. Building or serializing a
|
|
27
|
+
* transaction with a MoveCall matching any of them throws. Takes precedence over the client's
|
|
28
|
+
* `restrictedMoveCalls`, then `DEFAULT_RESTRICTED_MOVE_CALLS`; pass `[]` to allow all calls.
|
|
29
|
+
*/
|
|
30
|
+
restrictedMoveCalls?: readonly string[];
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
export interface SerializeTransactionOptions extends BuildTransactionOptions {
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
isValidMoveIdentifier,
|
|
6
|
+
isValidSuiAddress,
|
|
7
|
+
normalizeSuiAddress,
|
|
8
|
+
} from '../utils/sui-types.js';
|
|
9
|
+
import type { Command } from './data/internal.js';
|
|
10
|
+
|
|
11
|
+
/** Move calls a transaction can't make unless the client or build call sets `restrictedMoveCalls`. */
|
|
12
|
+
export const DEFAULT_RESTRICTED_MOVE_CALLS: readonly string[] = Object.freeze([
|
|
13
|
+
'0x2::address_alias',
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
export interface RestrictedMoveCall {
|
|
17
|
+
/** Index of the MoveCall command in the transaction. */
|
|
18
|
+
index: number;
|
|
19
|
+
/** `pkg::module::function`, with a normalized package address. */
|
|
20
|
+
target: string;
|
|
21
|
+
/** The first `restrictedMoveCalls` entry that matched the call. */
|
|
22
|
+
matchedBy: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function normalizeEntry(entry: string) {
|
|
26
|
+
const [pkg, ...path] = entry.split('::');
|
|
27
|
+
if (
|
|
28
|
+
// normalizeSuiAddress pads these to the zero address.
|
|
29
|
+
!pkg ||
|
|
30
|
+
pkg.toLowerCase() === '0x' ||
|
|
31
|
+
!isValidSuiAddress(normalizeSuiAddress(pkg)) ||
|
|
32
|
+
path.length > 2 ||
|
|
33
|
+
!path.every(isValidMoveIdentifier)
|
|
34
|
+
) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
`Invalid restrictedMoveCalls entry "${entry}": expected "package", "package::module" or "package::module::function"`,
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
return [normalizeSuiAddress(pkg), ...path].join('::');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Throws if an entry isn't `package`, `package::module` or `package::module::function`. */
|
|
43
|
+
export function validateRestrictedMoveCalls(restrictedMoveCalls: readonly string[]) {
|
|
44
|
+
restrictedMoveCalls.forEach(normalizeEntry);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Finds MoveCall commands matching any of `restrictedMoveCalls` (`package`, `package::module` or
|
|
49
|
+
* `package::module::function`). Throws if an entry is malformed.
|
|
50
|
+
*/
|
|
51
|
+
export function findRestrictedMoveCalls(
|
|
52
|
+
data: { commands: readonly Command[] },
|
|
53
|
+
restrictedMoveCalls: readonly string[] = DEFAULT_RESTRICTED_MOVE_CALLS,
|
|
54
|
+
): RestrictedMoveCall[] {
|
|
55
|
+
const entries = restrictedMoveCalls.map((entry) => ({ entry, prefix: normalizeEntry(entry) }));
|
|
56
|
+
const result: RestrictedMoveCall[] = [];
|
|
57
|
+
|
|
58
|
+
data.commands.forEach((command, index) => {
|
|
59
|
+
if (!command.MoveCall) return;
|
|
60
|
+
const { package: pkg, module, function: fn } = command.MoveCall;
|
|
61
|
+
const target = `${normalizeSuiAddress(pkg)}::${module}::${fn}`;
|
|
62
|
+
// The `::` keeps `0x2::address_alias` from matching `0x2::address_alias_x`.
|
|
63
|
+
const match = entries.find(
|
|
64
|
+
({ prefix }) => target === prefix || target.startsWith(`${prefix}::`),
|
|
65
|
+
);
|
|
66
|
+
if (match) {
|
|
67
|
+
result.push({ index, target, matchedBy: match.entry });
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function assertNoRestrictedMoveCalls(
|
|
75
|
+
data: { commands: readonly Command[] },
|
|
76
|
+
restrictedMoveCalls: readonly string[] | undefined,
|
|
77
|
+
) {
|
|
78
|
+
const calls = findRestrictedMoveCalls(data, restrictedMoveCalls);
|
|
79
|
+
if (calls.length === 0) return;
|
|
80
|
+
|
|
81
|
+
const list = calls
|
|
82
|
+
.map((call) => `command ${call.index} calls ${call.target} (restricted by "${call.matchedBy}")`)
|
|
83
|
+
.join(', ');
|
|
84
|
+
throw new Error(
|
|
85
|
+
`Transaction has restricted Move calls: ${list}. To allow them, set \`restrictedMoveCalls\` on the client or in \`build()\`/\`toJSON()\` options (\`[]\` allows all).`,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import type { BcsType } from '@mysten/bcs';
|
|
5
5
|
|
|
6
6
|
import { bcs } from '../bcs/index.js';
|
|
7
|
-
import type { SuiMoveNormalizedType } from '../jsonRpc/index.js';
|
|
8
7
|
import { MOVE_STDLIB_ADDRESS, SUI_FRAMEWORK_ADDRESS } from '../utils/index.js';
|
|
9
8
|
import { normalizeSuiAddress } from '../utils/sui-types.js';
|
|
10
9
|
import type { SuiClientTypes } from '../client/types.js';
|
|
@@ -96,75 +95,6 @@ export function getPureBcsSchema(
|
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
97
|
|
|
99
|
-
export function normalizedTypeToMoveTypeSignature(
|
|
100
|
-
type: SuiMoveNormalizedType,
|
|
101
|
-
): SuiClientTypes.OpenSignature {
|
|
102
|
-
if (typeof type === 'object' && 'Reference' in type) {
|
|
103
|
-
return {
|
|
104
|
-
reference: 'immutable',
|
|
105
|
-
body: normalizedTypeToMoveTypeSignatureBody(type.Reference),
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
if (typeof type === 'object' && 'MutableReference' in type) {
|
|
109
|
-
return {
|
|
110
|
-
reference: 'mutable',
|
|
111
|
-
body: normalizedTypeToMoveTypeSignatureBody(type.MutableReference),
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
reference: null,
|
|
117
|
-
body: normalizedTypeToMoveTypeSignatureBody(type),
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function normalizedTypeToMoveTypeSignatureBody(
|
|
122
|
-
type: SuiMoveNormalizedType,
|
|
123
|
-
): SuiClientTypes.OpenSignatureBody {
|
|
124
|
-
if (typeof type === 'string') {
|
|
125
|
-
switch (type) {
|
|
126
|
-
case 'Address':
|
|
127
|
-
return { $kind: 'address' };
|
|
128
|
-
case 'Bool':
|
|
129
|
-
return { $kind: 'bool' };
|
|
130
|
-
case 'U8':
|
|
131
|
-
return { $kind: 'u8' };
|
|
132
|
-
case 'U16':
|
|
133
|
-
return { $kind: 'u16' };
|
|
134
|
-
case 'U32':
|
|
135
|
-
return { $kind: 'u32' };
|
|
136
|
-
case 'U64':
|
|
137
|
-
return { $kind: 'u64' };
|
|
138
|
-
case 'U128':
|
|
139
|
-
return { $kind: 'u128' };
|
|
140
|
-
case 'U256':
|
|
141
|
-
return { $kind: 'u256' };
|
|
142
|
-
default:
|
|
143
|
-
throw new Error(`Unexpected type ${type}`);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if ('Vector' in type) {
|
|
148
|
-
return { $kind: 'vector', vector: normalizedTypeToMoveTypeSignatureBody(type.Vector) };
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if ('Struct' in type) {
|
|
152
|
-
return {
|
|
153
|
-
$kind: 'datatype',
|
|
154
|
-
datatype: {
|
|
155
|
-
typeName: `${type.Struct.address}::${type.Struct.module}::${type.Struct.name}`,
|
|
156
|
-
typeParameters: type.Struct.typeArguments.map(normalizedTypeToMoveTypeSignatureBody),
|
|
157
|
-
},
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if ('TypeParameter' in type) {
|
|
162
|
-
return { $kind: 'typeParameter', index: type.TypeParameter };
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
throw new Error(`Unexpected type ${JSON.stringify(type)}`);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
98
|
export function pureBcsSchemaFromOpenSignatureBody(
|
|
169
99
|
typeSignature: SuiClientTypes.OpenSignatureBody,
|
|
170
100
|
): BcsType<any> {
|
|
@@ -3,47 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
import { is } from 'valibot';
|
|
5
5
|
|
|
6
|
-
import type { SuiMoveNormalizedType } from '../jsonRpc/index.js';
|
|
7
6
|
import { normalizeSuiAddress } from '../utils/sui-types.js';
|
|
8
7
|
import { ArgumentSchema } from './data/internal.js';
|
|
9
8
|
import type { Argument, CallArg, Command } from './data/internal.js';
|
|
10
9
|
|
|
11
|
-
export function extractMutableReference(
|
|
12
|
-
normalizedType: SuiMoveNormalizedType,
|
|
13
|
-
): SuiMoveNormalizedType | undefined {
|
|
14
|
-
return typeof normalizedType === 'object' && 'MutableReference' in normalizedType
|
|
15
|
-
? normalizedType.MutableReference
|
|
16
|
-
: undefined;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function extractReference(
|
|
20
|
-
normalizedType: SuiMoveNormalizedType,
|
|
21
|
-
): SuiMoveNormalizedType | undefined {
|
|
22
|
-
return typeof normalizedType === 'object' && 'Reference' in normalizedType
|
|
23
|
-
? normalizedType.Reference
|
|
24
|
-
: undefined;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function extractStructTag(
|
|
28
|
-
normalizedType: SuiMoveNormalizedType,
|
|
29
|
-
): Extract<SuiMoveNormalizedType, { Struct: unknown }> | undefined {
|
|
30
|
-
if (typeof normalizedType === 'object' && 'Struct' in normalizedType) {
|
|
31
|
-
return normalizedType;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const ref = extractReference(normalizedType);
|
|
35
|
-
const mutRef = extractMutableReference(normalizedType);
|
|
36
|
-
|
|
37
|
-
if (typeof ref === 'object' && 'Struct' in ref) {
|
|
38
|
-
return ref;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (typeof mutRef === 'object' && 'Struct' in mutRef) {
|
|
42
|
-
return mutRef;
|
|
43
|
-
}
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
10
|
export function getIdFromCallArg(arg: string | CallArg) {
|
|
48
11
|
if (typeof arg === 'string') {
|
|
49
12
|
return normalizeSuiAddress(arg);
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `abortableAsyncGenerator` owns one controller per iteration and aborts it whenever the generator
|
|
6
|
+
* ends. That signals cancellation to the work below it and unblocks a pending step; releasing
|
|
7
|
+
* resources, such as cancelling a response body that arrives late, stays with that work.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** A controller that aborts when `signal` aborts. Call `dispose` to detach from `signal`. */
|
|
11
|
+
export function linkedAbortController(signal?: AbortSignal) {
|
|
12
|
+
const controller = new AbortController();
|
|
13
|
+
const abort = () => controller.abort(signal?.reason);
|
|
14
|
+
if (signal?.aborted) abort();
|
|
15
|
+
else signal?.addEventListener('abort', abort, { once: true });
|
|
16
|
+
return { controller, dispose: () => signal?.removeEventListener('abort', abort) };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// The listener lives only as long as one wait, so a long stream does not accumulate them.
|
|
20
|
+
function raceAbort<T>(promise: Promise<T>, signal: AbortSignal): Promise<T> {
|
|
21
|
+
return new Promise<T>((resolve, reject) => {
|
|
22
|
+
const abort = () => reject(signal.reason);
|
|
23
|
+
// Attached first so a rejection of `promise` is handled even when the abort wins.
|
|
24
|
+
promise.then(resolve, reject).finally(() => signal.removeEventListener('abort', abort));
|
|
25
|
+
if (signal.aborted) abort();
|
|
26
|
+
else signal.addEventListener('abort', abort, { once: true });
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Runs `run` lazily on the first `next()` with a signal that aborts when the caller's signal
|
|
32
|
+
* aborts or the generator ends for any reason.
|
|
33
|
+
*/
|
|
34
|
+
export function abortableAsyncGenerator<T>(
|
|
35
|
+
run: (signal: AbortSignal) => AsyncGenerator<T>,
|
|
36
|
+
signal?: AbortSignal,
|
|
37
|
+
): AsyncGenerator<T> {
|
|
38
|
+
let controller: AbortController | undefined;
|
|
39
|
+
// The abort reason for `return()` and `throw()`, which end a pending step instead of failing it.
|
|
40
|
+
const ended = new DOMException('The iteration was ended', 'AbortError');
|
|
41
|
+
async function* generate(): AsyncGenerator<T> {
|
|
42
|
+
const linked = linkedAbortController(signal);
|
|
43
|
+
const childSignal = linked.controller.signal;
|
|
44
|
+
controller = linked.controller;
|
|
45
|
+
let inner: AsyncGenerator<T> | undefined;
|
|
46
|
+
try {
|
|
47
|
+
childSignal.throwIfAborted();
|
|
48
|
+
inner = run(childSignal);
|
|
49
|
+
while (true) {
|
|
50
|
+
let result: IteratorResult<T>;
|
|
51
|
+
try {
|
|
52
|
+
// `run` can wait on work that ignores the signal, such as a custom `fetch`, so every
|
|
53
|
+
// wait is raced against the abort.
|
|
54
|
+
result = await raceAbort(inner.next(), childSignal);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
// A pending `next()` ended by `return()` or `throw()` finishes the iteration; the queued
|
|
57
|
+
// call then settles on the finished generator.
|
|
58
|
+
if (error === ended) return;
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
if (result.done) return;
|
|
62
|
+
yield result.value;
|
|
63
|
+
}
|
|
64
|
+
} finally {
|
|
65
|
+
linked.controller.abort();
|
|
66
|
+
linked.dispose();
|
|
67
|
+
// Not awaited: it queues behind an inner `next()` that may never settle.
|
|
68
|
+
inner?.return(undefined).catch(() => {});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const iterator = generate();
|
|
72
|
+
// A generator suspended in `await` queues `return()` and `throw()` behind the pending `next()`.
|
|
73
|
+
// Aborting first makes that pending read (or timer) reject, so the call cannot deadlock.
|
|
74
|
+
const originalReturn = iterator.return.bind(iterator);
|
|
75
|
+
iterator.return = (value) => {
|
|
76
|
+
controller?.abort(ended);
|
|
77
|
+
return originalReturn(value);
|
|
78
|
+
};
|
|
79
|
+
const originalThrow = iterator.throw.bind(iterator);
|
|
80
|
+
iterator.throw = (error) => {
|
|
81
|
+
controller?.abort(ended);
|
|
82
|
+
return originalThrow(error);
|
|
83
|
+
};
|
|
84
|
+
return iterator;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Resolves after `delay` ms, or rejects with the abort reason. */
|
|
88
|
+
export function sleep(delay: number, signal: AbortSignal): Promise<void> {
|
|
89
|
+
return new Promise((resolve, reject) => {
|
|
90
|
+
if (signal.aborted) return reject(signal.reason);
|
|
91
|
+
const onAbort = () => {
|
|
92
|
+
clearTimeout(timer);
|
|
93
|
+
reject(signal.reason);
|
|
94
|
+
};
|
|
95
|
+
const timer = setTimeout(() => {
|
|
96
|
+
signal.removeEventListener('abort', onAbort);
|
|
97
|
+
resolve();
|
|
98
|
+
}, delay);
|
|
99
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
100
|
+
});
|
|
101
|
+
}
|
package/src/verify/index.ts
CHANGED