@mysten/sui 2.39.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +160 -0
- package/README.md +5 -188
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/bcs/bcs.d.mts.map +1 -1
- package/dist/bcs/bcs.mjs +49 -22
- package/dist/bcs/bcs.mjs.map +1 -1
- package/dist/bcs/effects.mjs +49 -20
- package/dist/bcs/effects.mjs.map +1 -1
- package/dist/bcs/index.d.mts +1441 -624
- package/dist/bcs/index.d.mts.map +1 -1
- package/dist/bcs/index.mjs +2 -1
- package/dist/bcs/index.mjs.map +1 -1
- package/dist/bcs/transactions.d.mts +1059 -0
- package/dist/bcs/transactions.d.mts.map +1 -0
- package/dist/bcs/transactions.mjs +33 -14
- package/dist/bcs/transactions.mjs.map +1 -1
- package/dist/bcs/types.d.mts +6 -1
- package/dist/bcs/types.d.mts.map +1 -1
- package/dist/client/core-resolver.mjs +4 -4
- package/dist/client/core-resolver.mjs.map +1 -1
- package/dist/client/core.d.mts +55 -4
- package/dist/client/core.d.mts.map +1 -1
- package/dist/client/core.mjs +98 -1
- package/dist/client/core.mjs.map +1 -1
- package/dist/client/errors.mjs +11 -1
- package/dist/client/errors.mjs.map +1 -1
- package/dist/client/index.d.mts +4 -2
- package/dist/client/index.mjs +5 -2
- package/dist/client/mvr.d.mts +12 -2
- package/dist/client/mvr.d.mts.map +1 -1
- package/dist/client/mvr.mjs +34 -13
- package/dist/client/mvr.mjs.map +1 -1
- package/dist/client/query-filters.mjs +80 -76
- package/dist/client/query-filters.mjs.map +1 -1
- package/dist/client/stream/adapter.d.mts +102 -0
- package/dist/client/stream/adapter.d.mts.map +1 -0
- package/dist/client/stream/errors.d.mts +14 -0
- package/dist/client/stream/errors.d.mts.map +1 -0
- package/dist/client/stream/errors.mjs +25 -0
- package/dist/client/stream/errors.mjs.map +1 -0
- package/dist/client/stream/filter.mjs +18 -0
- package/dist/client/stream/filter.mjs.map +1 -0
- package/dist/client/stream/follow.mjs +48 -0
- package/dist/client/stream/follow.mjs.map +1 -0
- package/dist/client/stream/index.d.mts +4 -0
- package/dist/client/stream/pager.mjs +123 -0
- package/dist/client/stream/pager.mjs.map +1 -0
- package/dist/client/stream/plan.mjs +79 -0
- package/dist/client/stream/plan.mjs.map +1 -0
- package/dist/client/stream/position.d.mts +30 -0
- package/dist/client/stream/position.d.mts.map +1 -0
- package/dist/client/stream/position.mjs +121 -0
- package/dist/client/stream/position.mjs.map +1 -0
- package/dist/client/stream/run.d.mts +2 -0
- package/dist/client/stream/run.mjs +99 -0
- package/dist/client/stream/run.mjs.map +1 -0
- package/dist/client/stream/session.mjs +205 -0
- package/dist/client/stream/session.mjs.map +1 -0
- package/dist/client/stream/status.mjs +47 -0
- package/dist/client/stream/status.mjs.map +1 -0
- package/dist/client/stream/token.mjs +80 -0
- package/dist/client/stream/token.mjs.map +1 -0
- package/dist/client/transaction-data.d.mts +12 -0
- package/dist/client/transaction-data.d.mts.map +1 -0
- package/dist/client/transaction-data.mjs +469 -0
- package/dist/client/transaction-data.mjs.map +1 -0
- package/dist/client/transaction-resolver.mjs +102 -58
- package/dist/client/transaction-resolver.mjs.map +1 -1
- package/dist/client/types.d.mts +560 -240
- package/dist/client/types.d.mts.map +1 -1
- package/dist/client/utils.d.mts +3 -1
- package/dist/client/utils.d.mts.map +1 -1
- package/dist/client/utils.mjs +91 -26
- package/dist/client/utils.mjs.map +1 -1
- package/dist/cryptography/index.d.mts +1 -1
- package/dist/cryptography/keypair.d.mts +1 -1
- package/dist/cryptography/publickey.d.mts +11 -0
- package/dist/cryptography/publickey.d.mts.map +1 -1
- package/dist/cryptography/publickey.mjs +12 -1
- package/dist/cryptography/publickey.mjs.map +1 -1
- package/dist/cryptography/signature.d.mts +2 -2
- package/dist/cryptography/signature.mjs +18 -7
- package/dist/cryptography/signature.mjs.map +1 -1
- package/dist/graphql/client.d.mts +51 -35
- package/dist/graphql/client.d.mts.map +1 -1
- package/dist/graphql/client.mjs +125 -69
- package/dist/graphql/client.mjs.map +1 -1
- package/dist/graphql/core.d.mts +14 -9
- package/dist/graphql/core.d.mts.map +1 -1
- package/dist/graphql/core.mjs +293 -117
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/errors.d.mts +20 -0
- package/dist/graphql/errors.d.mts.map +1 -0
- package/dist/graphql/errors.mjs +19 -0
- package/dist/graphql/errors.mjs.map +1 -0
- package/dist/graphql/filters.mjs +32 -0
- package/dist/graphql/filters.mjs.map +1 -0
- package/dist/graphql/generated/queries.d.mts.map +1 -1
- package/dist/graphql/generated/queries.mjs +1216 -208
- package/dist/graphql/generated/queries.mjs.map +1 -1
- package/dist/graphql/generated/tada-env.d.mts +820 -11
- package/dist/graphql/index.d.mts +2 -1
- package/dist/graphql/index.mjs +2 -1
- package/dist/graphql/sse-parser.mjs +82 -0
- package/dist/graphql/sse-parser.mjs.map +1 -0
- package/dist/graphql/stream/families.mjs +306 -0
- package/dist/graphql/stream/families.mjs.map +1 -0
- package/dist/graphql/stream/index.mjs +38 -0
- package/dist/graphql/stream/index.mjs.map +1 -0
- package/dist/graphql/stream/live.mjs +60 -0
- package/dist/graphql/stream/live.mjs.map +1 -0
- package/dist/graphql/stream/page.mjs +38 -0
- package/dist/graphql/stream/page.mjs.map +1 -0
- package/dist/graphql/stream/query.mjs +47 -0
- package/dist/graphql/stream/query.mjs.map +1 -0
- package/dist/graphql/subscribe.mjs +70 -0
- package/dist/graphql/subscribe.mjs.map +1 -0
- package/dist/grpc/client.d.mts +31 -27
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs +42 -46
- package/dist/grpc/client.mjs.map +1 -1
- package/dist/grpc/core.d.mts +13 -6
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +254 -166
- package/dist/grpc/core.mjs.map +1 -1
- package/dist/grpc/filters.mjs +44 -34
- package/dist/grpc/filters.mjs.map +1 -1
- package/dist/grpc/grpc-web-pull.mjs +245 -0
- package/dist/grpc/grpc-web-pull.mjs.map +1 -0
- package/dist/grpc/index.d.mts +2 -1
- package/dist/grpc/index.mjs +1 -1
- package/dist/grpc/network-error.mjs +31 -0
- package/dist/grpc/network-error.mjs.map +1 -0
- package/dist/grpc/proto/google/rpc/error_details.mjs +306 -0
- package/dist/grpc/proto/google/rpc/error_details.mjs.map +1 -0
- package/dist/grpc/proto/sui/rpc/v2/error_reason.d.mts +176 -1
- package/dist/grpc/proto/sui/rpc/v2/error_reason.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/error_reason.mjs +175 -0
- package/dist/grpc/proto/sui/rpc/v2/error_reason.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/executed_transaction.d.mts +2 -2
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts +111 -0
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs +46 -0
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.d.mts +24 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.mjs +25 -7
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/object.mjs +1 -1
- package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts +111 -9
- package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/query_options.mjs +63 -19
- package/dist/grpc/proto/sui/rpc/v2/query_options.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature.d.mts +5 -5
- package/dist/grpc/proto/sui/rpc/v2/signature.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_scheme.d.mts +5 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_scheme.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_scheme.mjs +4 -0
- package/dist/grpc/proto/sui/rpc/v2/signature_scheme.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.d.mts +20 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.mjs +30 -13
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +16 -10
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs +8 -5
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts +11 -5
- package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction.mjs +6 -0
- package/dist/grpc/proto/sui/rpc/v2/transaction.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts +6 -2
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs.map +1 -1
- package/dist/grpc/proto/types.d.mts +7 -7
- package/dist/grpc/proto/types.mjs +3 -2
- package/dist/grpc/pull-call.d.mts +20 -0
- package/dist/grpc/pull-call.d.mts.map +1 -0
- package/dist/grpc/pull-call.mjs +28 -0
- package/dist/grpc/pull-call.mjs.map +1 -0
- package/dist/grpc/stream/call.mjs +238 -0
- package/dist/grpc/stream/call.mjs.map +1 -0
- package/dist/grpc/stream/families.d.mts +26 -0
- package/dist/grpc/stream/families.d.mts.map +1 -0
- package/dist/grpc/stream/families.mjs +145 -0
- package/dist/grpc/stream/families.mjs.map +1 -0
- package/dist/grpc/stream/index.d.mts +41 -0
- package/dist/grpc/stream/index.d.mts.map +1 -0
- package/dist/grpc/stream/index.mjs +127 -0
- package/dist/grpc/stream/index.mjs.map +1 -0
- package/dist/grpc/stream/live.mjs +31 -0
- package/dist/grpc/stream/live.mjs.map +1 -0
- package/dist/grpc/stream/page.mjs +120 -0
- package/dist/grpc/stream/page.mjs.map +1 -0
- package/dist/grpc/stream-types.d.mts +28 -0
- package/dist/grpc/stream-types.d.mts.map +1 -0
- package/dist/grpc/transport.d.mts +8 -3
- package/dist/grpc/transport.d.mts.map +1 -1
- package/dist/grpc/transport.mjs +88 -45
- package/dist/grpc/transport.mjs.map +1 -1
- package/dist/jsonRpc/index.d.mts +34 -12
- package/dist/jsonRpc/index.d.mts.map +1 -0
- package/dist/jsonRpc/index.mjs +39 -5
- package/dist/jsonRpc/index.mjs.map +1 -0
- package/dist/jsonRpc/types.d.mts +420 -0
- package/dist/jsonRpc/types.d.mts.map +1 -0
- package/dist/keypairs/passkey/keypair.d.mts +1 -1
- package/dist/multisig/publickey.d.mts +12 -4
- package/dist/multisig/publickey.d.mts.map +1 -1
- package/dist/multisig/publickey.mjs +5 -5
- package/dist/multisig/publickey.mjs.map +1 -1
- package/dist/multisig/signer.d.mts +1 -1
- package/dist/transactions/ObjectCache.d.mts +1 -1
- package/dist/transactions/ObjectCache.mjs +5 -5
- package/dist/transactions/ObjectCache.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +11 -10
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/transactions/Transaction.mjs +17 -6
- package/dist/transactions/Transaction.mjs.map +1 -1
- package/dist/transactions/data/internal.d.mts +135 -133
- package/dist/transactions/data/internal.d.mts.map +1 -1
- package/dist/transactions/data/internal.mjs +2 -1
- package/dist/transactions/data/internal.mjs.map +1 -1
- package/dist/transactions/data/v1.d.mts +239 -239
- package/dist/transactions/data/v1.d.mts.map +1 -1
- package/dist/transactions/data/v2.d.mts +16 -16
- package/dist/transactions/data/v2.d.mts.map +1 -1
- package/dist/transactions/executor/parallel.d.mts +2 -2
- package/dist/transactions/executor/serial.d.mts +1 -1
- package/dist/transactions/executor/serial.mjs +2 -2
- package/dist/transactions/executor/serial.mjs.map +1 -1
- package/dist/transactions/index.d.mts +3 -2
- package/dist/transactions/index.mjs +4 -3
- package/dist/transactions/intents/AllowanceBalance.mjs +1 -1
- package/dist/transactions/intents/CoinWithBalance.mjs +1 -1
- package/dist/transactions/resolve.d.mts +6 -0
- package/dist/transactions/resolve.d.mts.map +1 -1
- package/dist/transactions/resolve.mjs.map +1 -1
- package/dist/transactions/restricted-move-calls.d.mts +25 -0
- package/dist/transactions/restricted-move-calls.d.mts.map +1 -0
- package/dist/transactions/restricted-move-calls.mjs +47 -0
- package/dist/transactions/restricted-move-calls.mjs.map +1 -0
- package/dist/transactions/serializer.d.mts +1 -4
- package/dist/transactions/serializer.d.mts.map +1 -1
- package/dist/transactions/serializer.mjs +1 -44
- package/dist/transactions/serializer.mjs.map +1 -1
- package/dist/transactions/utils.d.mts +0 -1
- package/dist/transactions/utils.d.mts.map +1 -1
- package/dist/transactions/utils.mjs.map +1 -1
- package/dist/utils/abort.mjs +89 -0
- package/dist/utils/abort.mjs.map +1 -0
- package/dist/utils/coin-reservation.mjs +1 -4
- package/dist/utils/coin-reservation.mjs.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/sui-types.mjs +1 -1
- package/dist/verify/index.d.mts +2 -2
- package/dist/verify/verify.d.mts +74 -24
- package/dist/verify/verify.d.mts.map +1 -1
- package/dist/verify/verify.mjs +128 -42
- package/dist/verify/verify.mjs.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/dist/zklogin/publickey.d.mts.map +1 -1
- package/dist/zklogin/publickey.mjs +15 -20
- package/dist/zklogin/publickey.mjs.map +1 -1
- package/docs/bcs.md +2 -2
- package/docs/clients/core.md +19 -18
- package/docs/clients/executing.md +53 -8
- package/docs/clients/graphql.md +81 -11
- package/docs/clients/grpc.md +31 -15
- package/docs/clients/index.md +8 -7
- package/docs/clients/querying.md +134 -30
- package/docs/clients/streaming.md +324 -0
- package/docs/cryptography/index.md +85 -58
- package/docs/llms-index.md +4 -2
- package/docs/migrations/sui-2.0/dapp-kit.md +3 -2
- package/docs/migrations/sui-2.0/json-rpc-migration.md +106 -79
- package/docs/migrations/sui-3.0/index.md +250 -0
- package/docs/plugins.md +10 -10
- package/docs/sdk-building.md +3 -4
- package/docs/transactions/coins-and-balances.md +6 -11
- package/docs/transactions/reference.md +36 -1
- package/package.json +2 -3
- package/src/bcs/bcs.ts +80 -41
- package/src/bcs/effects.ts +61 -25
- package/src/bcs/index.ts +2 -0
- package/src/bcs/transactions.ts +36 -17
- package/src/bcs/types.ts +10 -4
- package/src/client/core-resolver.ts +3 -5
- package/src/client/core.ts +180 -8
- package/src/client/errors.ts +12 -0
- package/src/client/index.ts +4 -1
- package/src/client/mvr.ts +37 -10
- package/src/client/query-filters.ts +151 -97
- package/src/client/stream/adapter.ts +110 -0
- package/src/client/stream/errors.ts +40 -0
- package/src/client/stream/filter.ts +17 -0
- package/src/client/stream/follow.ts +63 -0
- package/src/client/stream/index.ts +9 -0
- package/src/client/stream/pager.ts +158 -0
- package/src/client/stream/plan.ts +147 -0
- package/src/client/stream/position.ts +143 -0
- package/src/client/stream/run.ts +147 -0
- package/src/client/stream/session.ts +259 -0
- package/src/client/stream/status.ts +44 -0
- package/src/client/stream/token.ts +104 -0
- package/src/client/transaction-data.ts +587 -0
- package/src/client/transaction-resolver.ts +158 -69
- package/src/client/types.ts +530 -115
- package/src/client/utils.ts +147 -50
- package/src/cryptography/publickey.ts +12 -1
- package/src/cryptography/signature.ts +6 -3
- package/src/graphql/client.ts +204 -135
- package/src/graphql/core.ts +446 -139
- package/src/graphql/errors.ts +24 -0
- package/src/graphql/filters.ts +48 -0
- package/src/graphql/generated/queries.ts +1455 -277
- package/src/graphql/generated/schema.graphql +282 -9
- package/src/graphql/generated/tada-env.ts +933 -4
- package/src/graphql/queries/checkpoints.graphql +34 -0
- package/src/graphql/queries/getDynamicFields.graphql +1 -0
- package/src/graphql/queries/listEvents.graphql +16 -24
- package/src/graphql/queries/streams.graphql +212 -0
- package/src/graphql/queries/transactions.graphql +71 -28
- package/src/graphql/queries/verifySignature.graphql +17 -0
- package/src/graphql/sse-parser.ts +99 -0
- package/src/graphql/stream/families.ts +515 -0
- package/src/graphql/stream/index.ts +55 -0
- package/src/graphql/stream/live.ts +70 -0
- package/src/graphql/stream/page.ts +47 -0
- package/src/graphql/stream/query.ts +52 -0
- package/src/graphql/subscribe.ts +83 -0
- package/src/grpc/client.ts +81 -79
- package/src/grpc/core.ts +388 -274
- package/src/grpc/filters.ts +59 -60
- package/src/grpc/grpc-web-pull.ts +360 -0
- package/src/grpc/index.ts +5 -0
- package/src/grpc/network-error.ts +33 -0
- package/src/grpc/proto/sui/rpc/v2/error_reason.ts +175 -0
- package/src/grpc/proto/sui/rpc/v2/ledger_service.ts +145 -0
- package/src/grpc/proto/sui/rpc/v2/move_package_service.ts +43 -1
- package/src/grpc/proto/sui/rpc/v2/query_options.ts +132 -8
- package/src/grpc/proto/sui/rpc/v2/signature.ts +4 -4
- package/src/grpc/proto/sui/rpc/v2/signature_scheme.ts +4 -0
- package/src/grpc/proto/sui/rpc/v2/signature_verification_service.ts +30 -0
- package/src/grpc/proto/sui/rpc/v2/subscription_service.client.ts +16 -10
- package/src/grpc/proto/sui/rpc/v2/transaction.ts +6 -0
- package/src/grpc/proto/sui/rpc/v2/transaction_execution_service.ts +5 -1
- package/src/grpc/pull-call.ts +54 -0
- package/src/grpc/stream/call.ts +317 -0
- package/src/grpc/stream/families.ts +228 -0
- package/src/grpc/stream/index.ts +182 -0
- package/src/grpc/stream/live.ts +33 -0
- package/src/grpc/stream/page.ts +161 -0
- package/src/grpc/stream-types.ts +33 -0
- package/src/grpc/transport.ts +116 -59
- package/src/jsonRpc/index.ts +60 -17
- package/src/jsonRpc/types.ts +421 -0
- package/src/multisig/publickey.ts +19 -7
- package/src/transactions/ObjectCache.ts +6 -6
- package/src/transactions/Transaction.ts +30 -6
- package/src/transactions/data/internal.ts +2 -0
- package/src/transactions/executor/serial.ts +2 -2
- package/src/transactions/index.ts +8 -1
- package/src/transactions/resolve.ts +6 -0
- package/src/transactions/restricted-move-calls.ts +87 -0
- package/src/transactions/serializer.ts +0 -70
- package/src/transactions/utils.ts +0 -37
- package/src/utils/abort.ts +101 -0
- package/src/verify/index.ts +1 -0
- package/src/verify/verify.ts +190 -62
- package/src/version.ts +1 -1
- package/src/zklogin/publickey.ts +18 -34
- package/dist/client/core-resolver.d.mts +0 -9
- package/dist/client/core-resolver.d.mts.map +0 -1
- package/dist/jsonRpc/client.d.mts +0 -507
- package/dist/jsonRpc/client.d.mts.map +0 -1
- package/dist/jsonRpc/client.mjs +0 -868
- package/dist/jsonRpc/client.mjs.map +0 -1
- package/dist/jsonRpc/core.d.mts +0 -168
- package/dist/jsonRpc/core.d.mts.map +0 -1
- package/dist/jsonRpc/core.mjs +0 -1054
- package/dist/jsonRpc/core.mjs.map +0 -1
- package/dist/jsonRpc/errors.d.mts +0 -27
- package/dist/jsonRpc/errors.d.mts.map +0 -1
- package/dist/jsonRpc/errors.mjs +0 -50
- package/dist/jsonRpc/errors.mjs.map +0 -1
- package/dist/jsonRpc/http-transport.d.mts +0 -62
- package/dist/jsonRpc/http-transport.d.mts.map +0 -1
- package/dist/jsonRpc/http-transport.mjs +0 -60
- package/dist/jsonRpc/http-transport.mjs.map +0 -1
- package/dist/jsonRpc/network.d.mts +0 -9
- package/dist/jsonRpc/network.d.mts.map +0 -1
- package/dist/jsonRpc/network.mjs +0 -18
- package/dist/jsonRpc/network.mjs.map +0 -1
- package/dist/jsonRpc/types/chain.d.mts +0 -169
- package/dist/jsonRpc/types/chain.d.mts.map +0 -1
- package/dist/jsonRpc/types/changes.d.mts +0 -48
- package/dist/jsonRpc/types/changes.d.mts.map +0 -1
- package/dist/jsonRpc/types/coins.d.mts +0 -15
- package/dist/jsonRpc/types/coins.d.mts.map +0 -1
- package/dist/jsonRpc/types/common.d.mts +0 -9
- package/dist/jsonRpc/types/common.d.mts.map +0 -1
- package/dist/jsonRpc/types/generated.d.mts +0 -1976
- package/dist/jsonRpc/types/generated.d.mts.map +0 -1
- package/dist/jsonRpc/types/index.d.mts +0 -6
- package/dist/jsonRpc/types/params.d.mts +0 -898
- package/dist/jsonRpc/types/params.d.mts.map +0 -1
- package/src/graphql/generated/tsconfig.tada.json +0 -11
- package/src/graphql/queries/verifyZkLoginSignature.graphql +0 -15
- package/src/jsonRpc/client.ts +0 -1252
- package/src/jsonRpc/core.ts +0 -1557
- package/src/jsonRpc/errors.ts +0 -57
- package/src/jsonRpc/http-transport.ts +0 -118
- package/src/jsonRpc/network.ts +0 -21
- package/src/jsonRpc/types/chain.ts +0 -190
- package/src/jsonRpc/types/changes.ts +0 -35
- package/src/jsonRpc/types/coins.ts +0 -14
- package/src/jsonRpc/types/common.ts +0 -8
- package/src/jsonRpc/types/generated.ts +0 -2165
- package/src/jsonRpc/types/index.ts +0 -9
- package/src/jsonRpc/types/params.ts +0 -908
package/src/grpc/transport.ts
CHANGED
|
@@ -17,10 +17,11 @@ import {
|
|
|
17
17
|
CLIENT_PROTOCOL_VERSION_HEADER,
|
|
18
18
|
MAX_PROTOCOL_VERSION,
|
|
19
19
|
} from '../client/protocol-version.js';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
import { assertClientUrl } from '../client/utils.js';
|
|
21
|
+
import { GrpcWebPullCall } from './grpc-web-pull.js';
|
|
22
|
+
import { abortRpcError, plainMessageErrors, toNetworkRpcError } from './network-error.js';
|
|
23
|
+
import { PULL_SERVER_STREAMING } from './pull-call.js';
|
|
24
|
+
import type { PullServerStreamingTransport, ServerStreamingIterableCall } from './pull-call.js';
|
|
24
25
|
|
|
25
26
|
// `grpc-message` is percent-encoded on the wire and the upstream transport does not decode it:
|
|
26
27
|
// https://github.com/timostamm/protobuf-ts/pull/739
|
|
@@ -34,38 +35,20 @@ function decodeGrpcStatusMessage(message: string): string {
|
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
if (MESSAGE_DECODED in error) return false;
|
|
39
|
-
Object.defineProperty(error, MESSAGE_DECODED, { value: true, configurable: true });
|
|
40
|
-
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
|
|
38
|
+
// A failed call rejects four promises with the same error, so it is only decoded once.
|
|
44
39
|
function decodeStatusMessageOnce(error: RpcError): void {
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
/** Whether this package's transport decoded the error's status text. */
|
|
49
|
-
export function hasDecodedStatusMessage(error: object): boolean {
|
|
50
|
-
return MESSAGE_DECODED in error;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// An abort reason is arbitrary, and reading a property on it runs code the caller wrote. A read
|
|
54
|
-
// that throws counts as absent, so one bad accessor does not decide the status.
|
|
55
|
-
function readProperty(value: unknown, key: 'code' | 'name' | 'message'): unknown {
|
|
56
|
-
if (typeof value !== 'object' || value === null) return undefined;
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
return (value as Record<string, unknown>)[key];
|
|
60
|
-
} catch {
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
40
|
+
if (plainMessageErrors.has(error)) return;
|
|
41
|
+
plainMessageErrors.add(error);
|
|
42
|
+
error.message = decodeGrpcStatusMessage(error.message);
|
|
63
43
|
}
|
|
64
44
|
|
|
65
45
|
// The reason is read by shape, since another copy of runtime-rpc or another realm fails
|
|
66
46
|
// `instanceof`. `AbortSignal.timeout` aborts with a `TimeoutError`.
|
|
67
47
|
function abortStatus(reason: unknown): string {
|
|
68
|
-
const code =
|
|
48
|
+
const { code, name } = (typeof reason === 'object' && reason !== null ? reason : {}) as {
|
|
49
|
+
code?: unknown;
|
|
50
|
+
name?: unknown;
|
|
51
|
+
};
|
|
69
52
|
|
|
70
53
|
// A status name maps to a number; `in` would also match the enum's reverse mapping.
|
|
71
54
|
if (
|
|
@@ -75,22 +58,11 @@ function abortStatus(reason: unknown): string {
|
|
|
75
58
|
return code;
|
|
76
59
|
}
|
|
77
60
|
|
|
78
|
-
return
|
|
61
|
+
return name === 'TimeoutError'
|
|
79
62
|
? GrpcStatusCode[GrpcStatusCode.DEADLINE_EXCEEDED]
|
|
80
63
|
: GrpcStatusCode[GrpcStatusCode.CANCELLED];
|
|
81
64
|
}
|
|
82
65
|
|
|
83
|
-
// The transport reuses the abort reason's message, so matching it says the text is local. A fetch
|
|
84
|
-
// that substitutes its own error (node-fetch) gives text of its own, which holds nothing to decode.
|
|
85
|
-
// The reason is never coerced: a symbol or a throwing hook would throw here.
|
|
86
|
-
function isAbortReasonText(message: string, reason: unknown): boolean {
|
|
87
|
-
if (typeof reason === 'string') return message === reason;
|
|
88
|
-
|
|
89
|
-
const reasonMessage = readProperty(reason, 'message');
|
|
90
|
-
|
|
91
|
-
return typeof reasonMessage === 'string' && message === reasonMessage;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
66
|
// Rewritten in place, so every promise a call rejects surfaces the same error. Only the two codes
|
|
95
67
|
// upstream uses for an abort are re-coded; a failure that raced the abort is relabelled with it.
|
|
96
68
|
function normalizeGrpcError(error: unknown, signal: AbortSignal | undefined): void {
|
|
@@ -111,14 +83,6 @@ function normalize(error: unknown, signal: AbortSignal | undefined): void {
|
|
|
111
83
|
error.code === GrpcStatusCode[GrpcStatusCode.CANCELLED])
|
|
112
84
|
) {
|
|
113
85
|
error.code = abortStatus(signal.reason);
|
|
114
|
-
|
|
115
|
-
// Text the abort reason supplied is local and holds nothing to decode; anything else came off
|
|
116
|
-
// the wire, even though the abort is what the caller sees. Settled here for the other promises
|
|
117
|
-
// the call rejects, which no longer match the codes above.
|
|
118
|
-
if (isAbortReasonText(error.message, signal.reason)) markStatusMessageRead(error);
|
|
119
|
-
else decodeStatusMessageOnce(error);
|
|
120
|
-
|
|
121
|
-
return;
|
|
122
86
|
}
|
|
123
87
|
|
|
124
88
|
decodeStatusMessageOnce(error);
|
|
@@ -131,19 +95,79 @@ function normalizeRejections(promises: Promise<unknown>[], signal: AbortSignal |
|
|
|
131
95
|
}
|
|
132
96
|
}
|
|
133
97
|
|
|
98
|
+
// Upstream erases fetch and body-read failures into INTERNAL; code network failures as
|
|
99
|
+
// UNAVAILABLE instead, and keep an aborted call's reason.
|
|
100
|
+
function fetchFailure(error: unknown, signal: AbortSignal | null | undefined): unknown {
|
|
101
|
+
return signal?.aborted ? abortRpcError(error) : toNetworkRpcError(error, signal);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function networkFetch(fetch: typeof globalThis.fetch): typeof globalThis.fetch {
|
|
105
|
+
return async (input, init) => {
|
|
106
|
+
let response: Response;
|
|
107
|
+
try {
|
|
108
|
+
response = await fetch(input, init);
|
|
109
|
+
} catch (error) {
|
|
110
|
+
throw fetchFailure(error, init?.signal);
|
|
111
|
+
}
|
|
112
|
+
// Other bodies, such as node-fetch's Node.js streams, are left to upstream.
|
|
113
|
+
if (typeof response.body?.getReader !== 'function') return response;
|
|
114
|
+
const reader = response.body.getReader();
|
|
115
|
+
// Upstream reads only these fields and iterates the body. The getters stay lazy because
|
|
116
|
+
// Cloudflare Workers throw on `type`, which upstream catches.
|
|
117
|
+
return {
|
|
118
|
+
get status() {
|
|
119
|
+
return response.status;
|
|
120
|
+
},
|
|
121
|
+
get statusText() {
|
|
122
|
+
return response.statusText;
|
|
123
|
+
},
|
|
124
|
+
get headers() {
|
|
125
|
+
return response.headers;
|
|
126
|
+
},
|
|
127
|
+
get type() {
|
|
128
|
+
return response.type;
|
|
129
|
+
},
|
|
130
|
+
body: { [Symbol.asyncIterator]: () => readBody(reader, init?.signal) },
|
|
131
|
+
} as unknown as Response;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function* readBody(
|
|
136
|
+
reader: ReadableStreamDefaultReader<Uint8Array>,
|
|
137
|
+
signal: AbortSignal | null | undefined,
|
|
138
|
+
): AsyncGenerator<Uint8Array> {
|
|
139
|
+
while (true) {
|
|
140
|
+
let result: ReadableStreamReadResult<Uint8Array>;
|
|
141
|
+
try {
|
|
142
|
+
result = await reader.read();
|
|
143
|
+
} catch (error) {
|
|
144
|
+
throw fetchFailure(error, signal);
|
|
145
|
+
}
|
|
146
|
+
if (result.done) return;
|
|
147
|
+
yield result.value;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
134
151
|
/**
|
|
135
152
|
* `GrpcWebFetchTransport` from `@protobuf-ts/grpcweb-transport`, subclassed to decode status
|
|
136
|
-
* messages, to code an aborted call from its reason rather than as `INTERNAL`,
|
|
137
|
-
* `x-sui-client-protocol-version` header
|
|
153
|
+
* messages, to code an aborted call from its reason rather than as `INTERNAL`, to code network
|
|
154
|
+
* failures as `UNAVAILABLE`, to send the `x-sui-client-protocol-version` header, and to default to
|
|
155
|
+
* the binary wire format. It also reads server streams on demand, for the SDK's ledger streams.
|
|
156
|
+
* A custom `fetch` must honour the request's `signal`.
|
|
138
157
|
*
|
|
139
158
|
* `SuiGrpcClient` builds one by default. A transport imported from `@protobuf-ts/grpcweb-transport`
|
|
140
159
|
* keeps that package's behaviour.
|
|
141
160
|
*/
|
|
142
|
-
export class GrpcWebFetchTransport
|
|
161
|
+
export class GrpcWebFetchTransport
|
|
162
|
+
extends UpstreamGrpcWebFetchTransport
|
|
163
|
+
implements PullServerStreamingTransport
|
|
164
|
+
{
|
|
143
165
|
constructor(options: GrpcWebOptions) {
|
|
166
|
+
assertClientUrl(options.baseUrl, 'GrpcWebFetchTransport baseUrl');
|
|
144
167
|
// Lets the server avoid sending types this SDK cannot decode. Caller-supplied `meta` wins.
|
|
145
168
|
super({
|
|
146
169
|
...options,
|
|
170
|
+
format: options.format ?? 'binary',
|
|
147
171
|
meta: {
|
|
148
172
|
[CLIENT_PROTOCOL_VERSION_HEADER]: String(MAX_PROTOCOL_VERSION),
|
|
149
173
|
...options.meta,
|
|
@@ -151,12 +175,26 @@ export class GrpcWebFetchTransport extends UpstreamGrpcWebFetchTransport {
|
|
|
151
175
|
});
|
|
152
176
|
}
|
|
153
177
|
|
|
178
|
+
/** Internal: an on-demand server-streaming call. Interceptors are not applied. */
|
|
179
|
+
[PULL_SERVER_STREAMING]<I extends object, O extends object>(
|
|
180
|
+
method: MethodInfo<I, O>,
|
|
181
|
+
input: I,
|
|
182
|
+
options: RpcOptions = {},
|
|
183
|
+
): ServerStreamingIterableCall<O> {
|
|
184
|
+
const merged = this.mergeOptions(options) as GrpcWebOptions;
|
|
185
|
+
return new GrpcWebPullCall(method, input, {
|
|
186
|
+
options: merged,
|
|
187
|
+
url: this.makeUrl(method, merged),
|
|
188
|
+
normalizeError: normalizeGrpcError,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
154
192
|
override unary<I extends object, O extends object>(
|
|
155
193
|
method: MethodInfo<I, O>,
|
|
156
194
|
input: I,
|
|
157
195
|
options: RpcOptions,
|
|
158
196
|
): UnaryCall<I, O> {
|
|
159
|
-
const call = super.unary(method, input, options);
|
|
197
|
+
const call = super.unary(method, input, withNetworkFetch(options));
|
|
160
198
|
|
|
161
199
|
normalizeRejections([call.headers, call.response, call.status, call.trailers], options.abort);
|
|
162
200
|
|
|
@@ -168,7 +206,7 @@ export class GrpcWebFetchTransport extends UpstreamGrpcWebFetchTransport {
|
|
|
168
206
|
input: I,
|
|
169
207
|
options: RpcOptions,
|
|
170
208
|
): ServerStreamingCall<I, O> {
|
|
171
|
-
const call = super.serverStreaming(method, input, options);
|
|
209
|
+
const call = super.serverStreaming(method, input, withNetworkFetch(options));
|
|
172
210
|
|
|
173
211
|
// A finite stream is often read through `responses` without awaiting `status`.
|
|
174
212
|
call.responses.onError((error) => normalizeGrpcError(error, options.abort));
|
|
@@ -178,8 +216,18 @@ export class GrpcWebFetchTransport extends UpstreamGrpcWebFetchTransport {
|
|
|
178
216
|
}
|
|
179
217
|
}
|
|
180
218
|
|
|
181
|
-
|
|
182
|
-
|
|
219
|
+
function withNetworkFetch(options: RpcOptions): RpcOptions {
|
|
220
|
+
const fetch = (options as Partial<GrpcWebOptions>).fetch ?? globalThis.fetch;
|
|
221
|
+
return { ...options, fetch: networkFetch(fetch) } as RpcOptions;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Applies the client's defaults to every call: adds the protocol-version header and fills unset
|
|
226
|
+
* request oneofs. Requests are re-encoded with this SDK's schema, so unknown fields on a request
|
|
227
|
+
* decoded from newer bytes are dropped. Does not mutate the caller's transport or its default
|
|
228
|
+
* options. Wraps every transport `SuiGrpcClient` uses, including a caller-supplied one.
|
|
229
|
+
*/
|
|
230
|
+
export function withClientDefaults(transport: RpcTransport): RpcTransport {
|
|
183
231
|
return {
|
|
184
232
|
mergeOptions(options) {
|
|
185
233
|
const merged = transport.mergeOptions(options);
|
|
@@ -191,9 +239,18 @@ export function withClientProtocolVersion(transport: RpcTransport): RpcTransport
|
|
|
191
239
|
},
|
|
192
240
|
};
|
|
193
241
|
},
|
|
194
|
-
|
|
195
|
-
|
|
242
|
+
// protobuf-ts's encoder requires every oneof to be set; create() fills unset ones so requests
|
|
243
|
+
// built before a oneof was added still send.
|
|
244
|
+
unary: (method, input, options) => transport.unary(method, method.I.create(input), options),
|
|
245
|
+
serverStreaming: (method, input, options) =>
|
|
246
|
+
transport.serverStreaming(method, method.I.create(input), options),
|
|
196
247
|
clientStreaming: transport.clientStreaming.bind(transport),
|
|
197
248
|
duplex: transport.duplex.bind(transport),
|
|
249
|
+
// The inner transport's pull method merges its own options, which already carry the header.
|
|
250
|
+
...(PULL_SERVER_STREAMING in transport && {
|
|
251
|
+
[PULL_SERVER_STREAMING]: (transport as PullServerStreamingTransport)[
|
|
252
|
+
PULL_SERVER_STREAMING
|
|
253
|
+
].bind(transport),
|
|
254
|
+
}),
|
|
198
255
|
};
|
|
199
256
|
}
|
package/src/jsonRpc/index.ts
CHANGED
|
@@ -1,20 +1,63 @@
|
|
|
1
1
|
// Copyright (c) Mysten Labs, Inc.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
SuiJsonRpcClient
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
// This entry point only exists so packages that still import it keep loading; every API throws.
|
|
5
|
+
|
|
6
|
+
export type * from './types.js';
|
|
7
|
+
|
|
8
|
+
const MESSAGE =
|
|
9
|
+
'JSON-RPC is no longer supported by @mysten/sui. Use SuiGrpcClient or SuiGraphQLClient instead.';
|
|
10
|
+
|
|
11
|
+
function unsupported(): never {
|
|
12
|
+
throw new Error(MESSAGE);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** @deprecated JSON-RPC is no longer supported by @mysten/sui. Use SuiGrpcClient or SuiGraphQLClient instead. */
|
|
16
|
+
export class SuiJsonRpcClient {
|
|
17
|
+
// Lets published declarations that read 2.x members (`SuiJsonRpcClient['getObject']`) still compile.
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
// Keeps the class nominal so `isSuiJsonRpcClient` doesn't narrow other clients to `never`.
|
|
20
|
+
declare protected readonly __jsonRpcRemoved: never;
|
|
21
|
+
|
|
22
|
+
constructor(..._args: unknown[]) {
|
|
23
|
+
unsupported();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** @deprecated JSON-RPC is no longer supported by @mysten/sui. Use SuiGrpcClient or SuiGraphQLClient instead. */
|
|
28
|
+
export class JsonRpcHTTPTransport {
|
|
29
|
+
constructor(..._args: unknown[]) {
|
|
30
|
+
unsupported();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** @deprecated JSON-RPC is no longer supported by @mysten/sui. Use SuiGrpcClient or SuiGraphQLClient instead. */
|
|
35
|
+
export class SuiHTTPTransportError extends Error {
|
|
36
|
+
constructor(..._args: unknown[]) {
|
|
37
|
+
super(MESSAGE);
|
|
38
|
+
unsupported();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** @deprecated JSON-RPC is no longer supported by @mysten/sui. Use SuiGrpcClient or SuiGraphQLClient instead. */
|
|
43
|
+
export class JsonRpcError extends SuiHTTPTransportError {
|
|
44
|
+
declare code: number;
|
|
45
|
+
declare type: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** @deprecated JSON-RPC is no longer supported by @mysten/sui. Use SuiGrpcClient or SuiGraphQLClient instead. */
|
|
49
|
+
export class SuiHTTPStatusError extends SuiHTTPTransportError {
|
|
50
|
+
declare status: number;
|
|
51
|
+
declare statusText: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** @deprecated JSON-RPC is no longer supported by @mysten/sui. Use SuiGrpcClient or SuiGraphQLClient instead. */
|
|
55
|
+
export function getJsonRpcFullnodeUrl(..._args: unknown[]): never {
|
|
56
|
+
unsupported();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Returns false instead of throwing: callers use it to pick a code path, and no client can exist.
|
|
60
|
+
/** @deprecated JSON-RPC is no longer supported by @mysten/sui. Use SuiGrpcClient or SuiGraphQLClient instead. */
|
|
61
|
+
export function isSuiJsonRpcClient(_client: unknown): _client is SuiJsonRpcClient {
|
|
62
|
+
return false;
|
|
63
|
+
}
|