@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
|
@@ -51,6 +51,21 @@ export interface VerifySignatureRequest {
|
|
|
51
51
|
* @generated from protobuf field: repeated sui.rpc.v2.ActiveJwk jwks = 4;
|
|
52
52
|
*/
|
|
53
53
|
jwks: ActiveJwk[];
|
|
54
|
+
// The epoch to use
|
|
55
|
+
// optional uint64 epoch = 5;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Optional. If true, `address` is required and the signature must be from a
|
|
59
|
+
* member of `address`'s current `AddressAliases` set rather than from
|
|
60
|
+
* `address` itself. An address with no `AddressAliases` set is its own only
|
|
61
|
+
* alias.
|
|
62
|
+
*
|
|
63
|
+
* Servers that predate this field ignore it, so clients must check
|
|
64
|
+
* `address_aliases_checked` in the response.
|
|
65
|
+
*
|
|
66
|
+
* @generated from protobuf field: optional bool check_address_aliases = 6;
|
|
67
|
+
*/
|
|
68
|
+
checkAddressAliases?: boolean;
|
|
54
69
|
}
|
|
55
70
|
/**
|
|
56
71
|
* @generated from protobuf message sui.rpc.v2.VerifySignatureResponse
|
|
@@ -68,6 +83,13 @@ export interface VerifySignatureResponse {
|
|
|
68
83
|
* @generated from protobuf field: optional string reason = 2;
|
|
69
84
|
*/
|
|
70
85
|
reason?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Set to true when the server applied `check_address_aliases`, whether or
|
|
88
|
+
* not the signature is valid. Unset by servers that predate it.
|
|
89
|
+
*
|
|
90
|
+
* @generated from protobuf field: optional bool address_aliases_checked = 3;
|
|
91
|
+
*/
|
|
92
|
+
addressAliasesChecked?: boolean;
|
|
71
93
|
}
|
|
72
94
|
// @generated message type with reflection information, may provide speed optimized methods
|
|
73
95
|
class VerifySignatureRequest$Type extends MessageType<VerifySignatureRequest> {
|
|
@@ -83,6 +105,7 @@ class VerifySignatureRequest$Type extends MessageType<VerifySignatureRequest> {
|
|
|
83
105
|
repeat: 2 /*RepeatType.UNPACKED*/,
|
|
84
106
|
T: () => ActiveJwk,
|
|
85
107
|
},
|
|
108
|
+
{ no: 6, name: 'check_address_aliases', kind: 'scalar', opt: true, T: 8 /*ScalarType.BOOL*/ },
|
|
86
109
|
]);
|
|
87
110
|
}
|
|
88
111
|
}
|
|
@@ -96,6 +119,13 @@ class VerifySignatureResponse$Type extends MessageType<VerifySignatureResponse>
|
|
|
96
119
|
super('sui.rpc.v2.VerifySignatureResponse', [
|
|
97
120
|
{ no: 1, name: 'is_valid', kind: 'scalar', opt: true, T: 8 /*ScalarType.BOOL*/ },
|
|
98
121
|
{ no: 2, name: 'reason', kind: 'scalar', opt: true, T: 9 /*ScalarType.STRING*/ },
|
|
122
|
+
{
|
|
123
|
+
no: 3,
|
|
124
|
+
name: 'address_aliases_checked',
|
|
125
|
+
kind: 'scalar',
|
|
126
|
+
opt: true,
|
|
127
|
+
T: 8 /*ScalarType.BOOL*/,
|
|
128
|
+
},
|
|
99
129
|
]);
|
|
100
130
|
}
|
|
101
131
|
}
|
|
@@ -33,11 +33,14 @@ import type { RpcOptions } from '@protobuf-ts/runtime-rpc';
|
|
|
33
33
|
* at the current tip of the chain as seen by the server (the latest executed
|
|
34
34
|
* checkpoint). To recover data missed between subscriptions, replay the gap
|
|
35
35
|
* with the paired List API: pass the last received `Watermark.cursor` as
|
|
36
|
-
* `options.after
|
|
37
|
-
* received `cursor + 1` as `start_checkpoint`). The
|
|
38
|
-
* indexed tip, which may trail the subscription's
|
|
39
|
-
* List call as the index advances until the replay
|
|
40
|
-
* established by the subscription's first frame
|
|
36
|
+
* `options.after`, with the request's start at its `cursor_position` (for
|
|
37
|
+
* checkpoints, pass the last received `cursor + 1` as `start_checkpoint`). The
|
|
38
|
+
* List scan reads from the indexed tip, which may trail the subscription's
|
|
39
|
+
* start position; repeat the List call as the index advances until the replay
|
|
40
|
+
* reaches the position established by the subscription's first frame: for
|
|
41
|
+
* transactions and events, that frame's item key if it carries an item, and
|
|
42
|
+
* its `cursor_position` otherwise. Compare positions and item keys, never
|
|
43
|
+
* cursor bytes.
|
|
41
44
|
*
|
|
42
45
|
* A subscription behaves like an unbounded ascending scan: every frame
|
|
43
46
|
* carries the subscriber's resume point, and progress advances as
|
|
@@ -104,11 +107,14 @@ export interface ISubscriptionServiceClient {
|
|
|
104
107
|
* at the current tip of the chain as seen by the server (the latest executed
|
|
105
108
|
* checkpoint). To recover data missed between subscriptions, replay the gap
|
|
106
109
|
* with the paired List API: pass the last received `Watermark.cursor` as
|
|
107
|
-
* `options.after
|
|
108
|
-
* received `cursor + 1` as `start_checkpoint`). The
|
|
109
|
-
* indexed tip, which may trail the subscription's
|
|
110
|
-
* List call as the index advances until the replay
|
|
111
|
-
* established by the subscription's first frame
|
|
110
|
+
* `options.after`, with the request's start at its `cursor_position` (for
|
|
111
|
+
* checkpoints, pass the last received `cursor + 1` as `start_checkpoint`). The
|
|
112
|
+
* List scan reads from the indexed tip, which may trail the subscription's
|
|
113
|
+
* start position; repeat the List call as the index advances until the replay
|
|
114
|
+
* reaches the position established by the subscription's first frame: for
|
|
115
|
+
* transactions and events, that frame's item key if it carries an item, and
|
|
116
|
+
* its `cursor_position` otherwise. Compare positions and item keys, never
|
|
117
|
+
* cursor bytes.
|
|
112
118
|
*
|
|
113
119
|
* A subscription behaves like an unbounded ascending scan: every frame
|
|
114
120
|
* carries the subscriber's resume point, and progress advances as
|
|
@@ -1162,6 +1162,12 @@ export enum EndOfEpochTransactionKind_Kind {
|
|
|
1162
1162
|
* @generated from protobuf enum value: WRITE_ACCUMULATOR_STORAGE_COST = 13;
|
|
1163
1163
|
*/
|
|
1164
1164
|
WRITE_ACCUMULATOR_STORAGE_COST = 13,
|
|
1165
|
+
/**
|
|
1166
|
+
* Create and initialize the Forwarding Address Registry object.
|
|
1167
|
+
*
|
|
1168
|
+
* @generated from protobuf enum value: FORWARDING_ADDRESS_REGISTRY_CREATE = 14;
|
|
1169
|
+
*/
|
|
1170
|
+
FORWARDING_ADDRESS_REGISTRY_CREATE = 14,
|
|
1165
1171
|
}
|
|
1166
1172
|
/**
|
|
1167
1173
|
* Expire old JWKs.
|
|
@@ -76,7 +76,11 @@ export interface SimulateTransactionRequest {
|
|
|
76
76
|
checks?: SimulateTransactionRequest_TransactionChecks;
|
|
77
77
|
/**
|
|
78
78
|
* Perform gas selection based on a budget estimation and include the
|
|
79
|
-
* selected gas payment and budget in the response.
|
|
79
|
+
* selected gas payment and budget in the response. If selection fails
|
|
80
|
+
* because the gas owner lacks enough SUI to cover the budget, the returned
|
|
81
|
+
* error carries a `google.rpc.ErrorInfo` with reason
|
|
82
|
+
* `INSUFFICIENT_GAS_BALANCE`, or `TRANSACTION_EXECUTION_FAILED` if the
|
|
83
|
+
* transaction also fails while estimating the budget (see `ErrorReason`).
|
|
80
84
|
*
|
|
81
85
|
* This option will be ignored if `checks` is `DISABLED`.
|
|
82
86
|
*
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// Internal: none of this is exported from `@mysten/sui/grpc`.
|
|
5
|
+
|
|
6
|
+
import type { GrpcWebOptions } from '@protobuf-ts/grpcweb-transport';
|
|
7
|
+
import type { MethodInfo, RpcOptions, RpcTransport } from '@protobuf-ts/runtime-rpc';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A server-streaming call whose messages are read from the network only as `responses` is pulled.
|
|
11
|
+
* `responses` has a single consumer, and `return()` cancels the call.
|
|
12
|
+
*/
|
|
13
|
+
export interface ServerStreamingIterableCall<O extends object = object> {
|
|
14
|
+
readonly responses: AsyncIterableIterator<O>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Starts an on-demand server-streaming call. Interceptors are not applied. */
|
|
18
|
+
export type PullServerStreaming = <I extends object, O extends object>(
|
|
19
|
+
method: MethodInfo<I, O>,
|
|
20
|
+
input: I,
|
|
21
|
+
options?: RpcOptions,
|
|
22
|
+
) => ServerStreamingIterableCall<O>;
|
|
23
|
+
|
|
24
|
+
/** The key of the on-demand server-streaming method on transports that have one. */
|
|
25
|
+
export const PULL_SERVER_STREAMING = Symbol('PullServerStreaming');
|
|
26
|
+
|
|
27
|
+
export interface PullServerStreamingTransport extends RpcTransport {
|
|
28
|
+
[PULL_SERVER_STREAMING]: PullServerStreaming;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The transport's on-demand server-streaming method, or `undefined` when it has none, uses the
|
|
33
|
+
* text format, or has interceptors, which only run through `serverStreaming`.
|
|
34
|
+
*/
|
|
35
|
+
export function pullServerStreaming(transport: RpcTransport): PullServerStreaming | undefined {
|
|
36
|
+
const method = (transport as Partial<PullServerStreamingTransport>)[PULL_SERVER_STREAMING];
|
|
37
|
+
if (typeof method !== 'function') return undefined;
|
|
38
|
+
const options: Partial<GrpcWebOptions> = transport.mergeOptions({});
|
|
39
|
+
if (options.interceptors?.length || options.format === 'text') return undefined;
|
|
40
|
+
return method.bind(transport) as PullServerStreaming;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const nonRetryable = new WeakSet<object>();
|
|
44
|
+
|
|
45
|
+
/** Marks `error` as failing the same way on every attempt, so a retrying caller surfaces it. */
|
|
46
|
+
export function markNonRetryable<E extends object>(error: E): E {
|
|
47
|
+
nonRetryable.add(error);
|
|
48
|
+
return error;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Whether `error` was marked with `markNonRetryable`. */
|
|
52
|
+
export function isNonRetryable(error: unknown): boolean {
|
|
53
|
+
return typeof error === 'object' && error !== null && nonRetryable.has(error);
|
|
54
|
+
}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Server-streaming calls for ledger streams, read through a bounded queue.
|
|
6
|
+
*
|
|
7
|
+
* - pull: `GrpcWebFetchTransport` without interceptors reads a response only when asked, unless
|
|
8
|
+
* `readAhead(true)`.
|
|
9
|
+
* - push: any other transport, called through `stackIntercept` so interceptors run. Responses
|
|
10
|
+
* arrive unasked; the bounded queue caps what is held.
|
|
11
|
+
*
|
|
12
|
+
* Once the stream signal aborts, queued responses are dropped and `next()` rejects with the abort
|
|
13
|
+
* reason. An overflow is not a cancellation: responses queued before it are delivered first.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { RpcError, stackIntercept } from '@protobuf-ts/runtime-rpc';
|
|
17
|
+
import type { MethodInfo, RpcTransport, ServerStreamingCall } from '@protobuf-ts/runtime-rpc';
|
|
18
|
+
|
|
19
|
+
import { linkedAbortController } from '../../utils/abort.js';
|
|
20
|
+
import { pullServerStreaming } from '../pull-call.js';
|
|
21
|
+
|
|
22
|
+
/** Responses a call may hold before it overflows and the stream reconnects. */
|
|
23
|
+
const MAX_QUEUED_RESPONSES = 1024;
|
|
24
|
+
|
|
25
|
+
export interface LedgerCall<T> extends AsyncIterableIterator<T> {
|
|
26
|
+
/**
|
|
27
|
+
* While enabled, responses are read ahead of the consumer into the bounded queue; past its
|
|
28
|
+
* limit the call fails with a buffer overflow. Push transports always read ahead.
|
|
29
|
+
*/
|
|
30
|
+
readAhead(enabled: boolean): void;
|
|
31
|
+
/** Cancels the call. */
|
|
32
|
+
return(): Promise<IteratorReturnResult<undefined>>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface LedgerCallOptions<T> {
|
|
36
|
+
signal: AbortSignal;
|
|
37
|
+
/** Whether a response carries a ledger item. */
|
|
38
|
+
isItem(response: T): boolean;
|
|
39
|
+
/** Keep only the newest of consecutive queued progress responses. */
|
|
40
|
+
coalesceProgress?: boolean;
|
|
41
|
+
/** Throws for a malformed response, which then fails the call in its place. */
|
|
42
|
+
validate?(response: T): void;
|
|
43
|
+
/** Defaults to `MAX_QUEUED_RESPONSES`. */
|
|
44
|
+
maxResponses?: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function openLedgerCall<I extends object, O extends object>(
|
|
48
|
+
transport: RpcTransport,
|
|
49
|
+
method: MethodInfo<I, O>,
|
|
50
|
+
request: I,
|
|
51
|
+
options: LedgerCallOptions<O>,
|
|
52
|
+
): LedgerCall<O> {
|
|
53
|
+
const linked = { ...linkedAbortController(options.signal), stream: options.signal };
|
|
54
|
+
const queue = new BoundedQueue(options);
|
|
55
|
+
const pull = pullServerStreaming(transport);
|
|
56
|
+
if (pull) {
|
|
57
|
+
const call = pull(method, request, { abort: linked.controller.signal });
|
|
58
|
+
return new PullLedgerCall(call.responses, queue, linked);
|
|
59
|
+
}
|
|
60
|
+
const call = stackIntercept(
|
|
61
|
+
'serverStreaming',
|
|
62
|
+
transport,
|
|
63
|
+
method,
|
|
64
|
+
transport.mergeOptions({ abort: linked.controller.signal }),
|
|
65
|
+
request,
|
|
66
|
+
);
|
|
67
|
+
ignoreRejections([call.headers, call.status, call.trailers]);
|
|
68
|
+
return new PushLedgerCall(call, queue, linked);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Holds at most `maxResponses` responses. */
|
|
72
|
+
class BoundedQueue<T> {
|
|
73
|
+
readonly #isItem: (response: T) => boolean;
|
|
74
|
+
readonly #maxResponses: number;
|
|
75
|
+
readonly #coalesceProgress: boolean;
|
|
76
|
+
readonly #validate: ((response: T) => void) | undefined;
|
|
77
|
+
#responses: T[] = [];
|
|
78
|
+
#head = 0;
|
|
79
|
+
|
|
80
|
+
constructor(options: LedgerCallOptions<T>) {
|
|
81
|
+
this.#isItem = options.isItem;
|
|
82
|
+
this.#maxResponses = options.maxResponses ?? MAX_QUEUED_RESPONSES;
|
|
83
|
+
this.#coalesceProgress = options.coalesceProgress ?? false;
|
|
84
|
+
this.#validate = options.validate;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
get length() {
|
|
88
|
+
return this.#responses.length - this.#head;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Returns false when the queue is full. */
|
|
92
|
+
push(response: T): boolean {
|
|
93
|
+
// Before coalescing, which would drop it unchecked.
|
|
94
|
+
this.#validate?.(response);
|
|
95
|
+
const last = this.#responses.length - 1;
|
|
96
|
+
if (
|
|
97
|
+
this.#coalesceProgress &&
|
|
98
|
+
this.length > 0 &&
|
|
99
|
+
!this.#isItem(response) &&
|
|
100
|
+
!this.#isItem(this.#responses[last])
|
|
101
|
+
) {
|
|
102
|
+
this.#responses[last] = response;
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
if (this.length >= this.#maxResponses) return false;
|
|
106
|
+
this.#responses.push(response);
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
shift(): T | undefined {
|
|
111
|
+
if (this.length === 0) return undefined;
|
|
112
|
+
const response = this.#responses[this.#head];
|
|
113
|
+
this.#responses[this.#head++] = undefined!;
|
|
114
|
+
// Compact once the consumed prefix is half the array, so shifting stays O(1) amortized.
|
|
115
|
+
if (this.#head >= 1024 && this.#head * 2 >= this.#responses.length) {
|
|
116
|
+
this.#responses = this.#responses.slice(this.#head);
|
|
117
|
+
this.#head = 0;
|
|
118
|
+
}
|
|
119
|
+
return response;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
clear() {
|
|
123
|
+
this.#responses = [];
|
|
124
|
+
this.#head = 0;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** The shared half: a queue, a sticky end state, and cancellation. */
|
|
129
|
+
abstract class QueuedLedgerCall<T> implements LedgerCall<T> {
|
|
130
|
+
protected readonly queue: BoundedQueue<T>;
|
|
131
|
+
readonly #linked: CallAbort;
|
|
132
|
+
readonly #onStreamAbort = () => this.#cancel(this.#linked.stream.reason);
|
|
133
|
+
#ended = false;
|
|
134
|
+
#returned = false;
|
|
135
|
+
#failure: unknown;
|
|
136
|
+
#wake: (() => void) | undefined;
|
|
137
|
+
|
|
138
|
+
constructor(queue: BoundedQueue<T>, linked: CallAbort) {
|
|
139
|
+
this.queue = queue;
|
|
140
|
+
this.#linked = linked;
|
|
141
|
+
// Listen to the stream signal itself: an overflow has already aborted the call's own
|
|
142
|
+
// controller, and a later stream abort must still cancel the call.
|
|
143
|
+
const { stream } = linked;
|
|
144
|
+
if (stream.aborted) this.#cancel(stream.reason);
|
|
145
|
+
else stream.addEventListener('abort', this.#onStreamAbort, { once: true });
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
[Symbol.asyncIterator]() {
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
abstract readAhead(enabled: boolean): void;
|
|
153
|
+
/** Resolves once a response is queued or the call has ended. */
|
|
154
|
+
protected abstract fill(): Promise<void>;
|
|
155
|
+
/** Releases the transport's response stream after cancellation. */
|
|
156
|
+
protected abstract release(): Promise<void>;
|
|
157
|
+
|
|
158
|
+
protected get ended() {
|
|
159
|
+
return this.#ended;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** The first end wins. Once aborted, the abort reason replaces the transport's cancel error. */
|
|
163
|
+
protected end(error?: unknown) {
|
|
164
|
+
if (this.#ended) return;
|
|
165
|
+
this.#ended = true;
|
|
166
|
+
const signal = this.#linked.controller.signal;
|
|
167
|
+
this.#failure = signal.aborted ? signal.reason : error;
|
|
168
|
+
this.wake();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Drops queued responses and fails later `next()` calls, even after the call has ended. */
|
|
172
|
+
#cancel(reason: unknown) {
|
|
173
|
+
if (this.#returned) return;
|
|
174
|
+
this.#ended = true;
|
|
175
|
+
this.#failure = reason;
|
|
176
|
+
this.queue.clear();
|
|
177
|
+
this.wake();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
protected wake() {
|
|
181
|
+
this.#wake?.();
|
|
182
|
+
this.#wake = undefined;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
protected waitForWake(): Promise<void> {
|
|
186
|
+
return new Promise((resolve) => (this.#wake = resolve));
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
protected enqueue(response: T) {
|
|
190
|
+
let queued: boolean;
|
|
191
|
+
try {
|
|
192
|
+
queued = this.queue.push(response);
|
|
193
|
+
} catch (error) {
|
|
194
|
+
return this.#fail(error);
|
|
195
|
+
}
|
|
196
|
+
// The consumer fell behind; the stream reconnects and resumes from its last frame.
|
|
197
|
+
if (!queued) this.#fail(new RpcError('Ledger stream buffer limit reached', 'ABORTED'));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** Responses queued before the failure are delivered first. */
|
|
201
|
+
#fail(error: unknown) {
|
|
202
|
+
this.end(error);
|
|
203
|
+
this.#linked.controller.abort(error);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
async next(): Promise<IteratorResult<T, undefined>> {
|
|
207
|
+
while (!this.queue.length && !this.#ended) await this.fill();
|
|
208
|
+
const value = this.queue.shift();
|
|
209
|
+
if (value !== undefined) return { done: false, value };
|
|
210
|
+
if (this.#failure !== undefined) throw this.#failure;
|
|
211
|
+
return { done: true, value: undefined };
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async return(): Promise<IteratorReturnResult<undefined>> {
|
|
215
|
+
this.end();
|
|
216
|
+
this.#returned = true;
|
|
217
|
+
this.queue.clear();
|
|
218
|
+
this.#linked.controller.abort();
|
|
219
|
+
this.#linked.dispose();
|
|
220
|
+
this.#linked.stream.removeEventListener('abort', this.#onStreamAbort);
|
|
221
|
+
await this.release();
|
|
222
|
+
return { done: true, value: undefined };
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** Reads on demand; while `readAhead` is on, a pump reads into the queue in the background. */
|
|
227
|
+
class PullLedgerCall<T> extends QueuedLedgerCall<T> {
|
|
228
|
+
readonly #responses: AsyncIterator<T>;
|
|
229
|
+
#readingAhead = false;
|
|
230
|
+
#pumping = false;
|
|
231
|
+
#inflight: Promise<void> | undefined;
|
|
232
|
+
|
|
233
|
+
constructor(responses: AsyncIterator<T>, queue: BoundedQueue<T>, linked: CallAbort) {
|
|
234
|
+
super(queue, linked);
|
|
235
|
+
this.#responses = responses;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
readAhead(enabled: boolean) {
|
|
239
|
+
this.#readingAhead = enabled;
|
|
240
|
+
if (enabled) void this.#pump();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
protected fill() {
|
|
244
|
+
return this.#readOne();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
protected async release() {
|
|
248
|
+
this.#readingAhead = false;
|
|
249
|
+
await this.#responses.return?.();
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// The reader takes one read at a time, so the consumer and the pump share one in-flight read.
|
|
253
|
+
#readOne(): Promise<void> {
|
|
254
|
+
this.#inflight ??= this.#responses.next().then(
|
|
255
|
+
(result) => {
|
|
256
|
+
this.#inflight = undefined;
|
|
257
|
+
if (this.ended) return;
|
|
258
|
+
if (result.done) this.end();
|
|
259
|
+
else this.enqueue(result.value);
|
|
260
|
+
},
|
|
261
|
+
(error: unknown) => {
|
|
262
|
+
this.#inflight = undefined;
|
|
263
|
+
this.end(error);
|
|
264
|
+
},
|
|
265
|
+
);
|
|
266
|
+
return this.#inflight;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
async #pump() {
|
|
270
|
+
if (this.#pumping) return;
|
|
271
|
+
this.#pumping = true;
|
|
272
|
+
try {
|
|
273
|
+
while (this.#readingAhead && !this.ended) await this.#readOne();
|
|
274
|
+
} finally {
|
|
275
|
+
this.#pumping = false;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** The transport pushes responses as they arrive; they go straight into the bounded queue. */
|
|
281
|
+
class PushLedgerCall<T extends object> extends QueuedLedgerCall<T> {
|
|
282
|
+
constructor(call: ServerStreamingCall<object, T>, queue: BoundedQueue<T>, linked: CallAbort) {
|
|
283
|
+
super(queue, linked);
|
|
284
|
+
// protobuf-ts's iterator, unlike `onNext`, replays responses delivered before the call was
|
|
285
|
+
// returned (for example by a caching interceptor).
|
|
286
|
+
void this.#drain(call.responses[Symbol.asyncIterator]());
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
readAhead() {}
|
|
290
|
+
|
|
291
|
+
protected fill() {
|
|
292
|
+
return this.waitForWake();
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
protected async release() {}
|
|
296
|
+
|
|
297
|
+
async #drain(responses: AsyncIterator<T>) {
|
|
298
|
+
try {
|
|
299
|
+
while (!this.ended) {
|
|
300
|
+
const result = await responses.next();
|
|
301
|
+
if (this.ended) return;
|
|
302
|
+
if (result.done) return this.end();
|
|
303
|
+
this.enqueue(result.value);
|
|
304
|
+
this.wake();
|
|
305
|
+
}
|
|
306
|
+
} catch (error) {
|
|
307
|
+
this.end(error);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** The call's own controller, plus the stream signal it is linked to. */
|
|
313
|
+
type CallAbort = ReturnType<typeof linkedAbortController> & { stream: AbortSignal };
|
|
314
|
+
|
|
315
|
+
function ignoreRejections(promises: Promise<unknown>[]) {
|
|
316
|
+
for (const promise of promises) void promise.catch(() => {});
|
|
317
|
+
}
|