@haneullabs/haneul 2.5.2 → 2.13.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 +129 -0
- package/README.md +36 -36
- package/dist/bcs/bcs.d.mts +6 -7
- package/dist/bcs/bcs.d.mts.map +1 -1
- package/dist/bcs/bcs.mjs.map +1 -1
- package/dist/bcs/effects.mjs.map +1 -1
- package/dist/bcs/index.d.mts +2 -2
- package/dist/bcs/index.d.mts.map +1 -1
- package/dist/bcs/index.mjs +2 -2
- package/dist/bcs/index.mjs.map +1 -1
- package/dist/bcs/pure.d.mts.map +1 -1
- package/dist/bcs/type-tag-serializer.d.mts.map +1 -1
- package/dist/bcs/types.d.mts +0 -1
- package/dist/bcs/types.d.mts.map +1 -1
- package/dist/client/cache.d.mts.map +1 -1
- package/dist/client/client.d.mts.map +1 -1
- package/dist/client/core-resolver.d.mts.map +1 -1
- package/dist/client/core-resolver.mjs +87 -68
- package/dist/client/core-resolver.mjs.map +1 -1
- package/dist/client/core.d.mts +9 -8
- package/dist/client/core.d.mts.map +1 -1
- package/dist/client/core.mjs +29 -10
- package/dist/client/core.mjs.map +1 -1
- package/dist/client/errors.d.mts.map +1 -1
- package/dist/client/mvr.d.mts +0 -1
- package/dist/client/mvr.d.mts.map +1 -1
- package/dist/client/types.d.mts +110 -24
- package/dist/client/types.d.mts.map +1 -1
- package/dist/client/utils.d.mts.map +1 -1
- package/dist/client/utils.mjs +7 -7
- package/dist/client/utils.mjs.map +1 -1
- package/dist/cryptography/index.d.mts +2 -2
- package/dist/cryptography/index.mjs +2 -2
- package/dist/cryptography/intent.d.mts +2 -2
- package/dist/cryptography/intent.d.mts.map +1 -1
- package/dist/cryptography/intent.mjs +2 -2
- package/dist/cryptography/intent.mjs.map +1 -1
- package/dist/cryptography/keypair.d.mts +3 -3
- package/dist/cryptography/keypair.d.mts.map +1 -1
- package/dist/cryptography/keypair.mjs +3 -3
- package/dist/cryptography/keypair.mjs.map +1 -1
- package/dist/cryptography/mnemonics.d.mts +5 -5
- package/dist/cryptography/mnemonics.d.mts.map +1 -1
- package/dist/cryptography/mnemonics.mjs +7 -7
- package/dist/cryptography/mnemonics.mjs.map +1 -1
- package/dist/cryptography/publickey.d.mts +1 -2
- package/dist/cryptography/publickey.d.mts.map +1 -1
- package/dist/cryptography/publickey.mjs +7 -7
- package/dist/cryptography/publickey.mjs.map +1 -1
- package/dist/cryptography/signature-scheme.d.mts.map +1 -1
- package/dist/cryptography/signature.d.mts +10 -13
- package/dist/cryptography/signature.d.mts.map +1 -1
- package/dist/cryptography/signature.mjs +2 -2
- package/dist/cryptography/signature.mjs.map +1 -1
- package/dist/faucet/faucet.d.mts +2 -2
- package/dist/faucet/faucet.d.mts.map +1 -1
- package/dist/faucet/faucet.mjs +2 -2
- package/dist/faucet/faucet.mjs.map +1 -1
- package/dist/faucet/index.d.mts +2 -2
- package/dist/faucet/index.mjs +2 -2
- package/dist/graphql/client.d.mts +20 -5
- package/dist/graphql/client.d.mts.map +1 -1
- package/dist/graphql/client.mjs +55 -7
- package/dist/graphql/client.mjs.map +1 -1
- package/dist/graphql/core.d.mts +6 -5
- package/dist/graphql/core.d.mts.map +1 -1
- package/dist/graphql/core.mjs +43 -47
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/generated/queries.d.mts +0 -1
- package/dist/graphql/generated/queries.d.mts.map +1 -1
- package/dist/graphql/generated/queries.mjs +46 -10
- package/dist/graphql/generated/queries.mjs.map +1 -1
- package/dist/graphql/generated/tada-env.d.mts +706 -98
- package/dist/graphql/generated/tada-env.d.mts.map +1 -1
- package/dist/graphql/index.d.mts +2 -2
- package/dist/graphql/index.mjs +2 -2
- package/dist/graphql/schema/index.d.mts +0 -1
- package/dist/graphql/schema/index.d.mts.map +1 -1
- package/dist/graphql/types.d.mts.map +1 -1
- package/dist/grpc/client.d.mts +20 -5
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs +47 -7
- package/dist/grpc/client.mjs.map +1 -1
- package/dist/grpc/core.d.mts +6 -5
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +35 -34
- package/dist/grpc/core.mjs.map +1 -1
- package/dist/grpc/index.d.mts +2 -2
- package/dist/grpc/index.mjs +2 -2
- package/dist/grpc/proto/google/protobuf/any.d.mts +0 -1
- package/dist/grpc/proto/google/protobuf/any.d.mts.map +1 -1
- package/dist/grpc/proto/google/protobuf/duration.d.mts +0 -1
- package/dist/grpc/proto/google/protobuf/duration.d.mts.map +1 -1
- package/dist/grpc/proto/google/protobuf/field_mask.d.mts +0 -1
- package/dist/grpc/proto/google/protobuf/field_mask.d.mts.map +1 -1
- package/dist/grpc/proto/google/protobuf/struct.d.mts +1 -2
- package/dist/grpc/proto/google/protobuf/struct.d.mts.map +1 -1
- package/dist/grpc/proto/google/protobuf/timestamp.d.mts +0 -1
- package/dist/grpc/proto/google/protobuf/timestamp.d.mts.map +1 -1
- package/dist/grpc/proto/google/rpc/status.d.mts +0 -1
- package/dist/grpc/proto/google/rpc/status.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/argument.d.mts +1 -2
- package/dist/grpc/proto/haneul/rpc/v2/argument.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/balance_change.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/balance_change.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/bcs.d.mts +1 -2
- package/dist/grpc/proto/haneul/rpc/v2/bcs.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/bcs.mjs.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/checkpoint.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/checkpoint.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/checkpoint_contents.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/checkpoint_contents.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/checkpoint_summary.d.mts +1 -2
- package/dist/grpc/proto/haneul/rpc/v2/checkpoint_summary.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/effects.d.mts +5 -6
- package/dist/grpc/proto/haneul/rpc/v2/effects.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/epoch.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/epoch.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/error_reason.d.mts +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/error_reason.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/event.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/event.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/executed_transaction.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/executed_transaction.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/execution_status.d.mts +8 -9
- package/dist/grpc/proto/haneul/rpc/v2/execution_status.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/execution_status.mjs +4 -4
- package/dist/grpc/proto/haneul/rpc/v2/execution_status.mjs.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/gas_cost_summary.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/gas_cost_summary.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/input.d.mts +3 -4
- package/dist/grpc/proto/haneul/rpc/v2/input.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/jwk.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/jwk.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/ledger_service.client.d.mts +4 -5
- package/dist/grpc/proto/haneul/rpc/v2/ledger_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/ledger_service.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/ledger_service.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/move_package.d.mts +5 -6
- package/dist/grpc/proto/haneul/rpc/v2/move_package.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/move_package_service.client.d.mts +4 -5
- package/dist/grpc/proto/haneul/rpc/v2/move_package_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/move_package_service.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/move_package_service.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/name_service.client.d.mts +4 -5
- package/dist/grpc/proto/haneul/rpc/v2/name_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/name_service.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/name_service.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/object.d.mts +38 -2
- package/dist/grpc/proto/haneul/rpc/v2/object.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/object.mjs +26 -1
- package/dist/grpc/proto/haneul/rpc/v2/object.mjs.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/object_reference.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/object_reference.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/owner.d.mts +1 -2
- package/dist/grpc/proto/haneul/rpc/v2/owner.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/protocol_config.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/protocol_config.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/signature.d.mts +1 -2
- package/dist/grpc/proto/haneul/rpc/v2/signature.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/signature.mjs.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/signature_scheme.d.mts +2 -2
- package/dist/grpc/proto/haneul/rpc/v2/signature_scheme.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/signature_scheme.mjs +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/signature_scheme.mjs.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/signature_verification_service.client.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/signature_verification_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/signature_verification_service.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/signature_verification_service.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/state_service.client.d.mts +4 -5
- package/dist/grpc/proto/haneul/rpc/v2/state_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/state_service.d.mts +4 -5
- package/dist/grpc/proto/haneul/rpc/v2/state_service.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/subscription_service.client.d.mts +4 -5
- package/dist/grpc/proto/haneul/rpc/v2/subscription_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/subscription_service.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/subscription_service.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/system_state.d.mts +3 -4
- package/dist/grpc/proto/haneul/rpc/v2/system_state.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/system_state.mjs +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/system_state.mjs.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/transaction.d.mts +4 -5
- package/dist/grpc/proto/haneul/rpc/v2/transaction.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.client.d.mts +0 -1
- package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.d.mts +9 -2
- package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.d.mts.map +1 -1
- package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.mjs +23 -12
- package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.mjs.map +1 -1
- package/dist/grpc/proto/types.d.mts +2 -2
- package/dist/grpc/proto/types.d.mts.map +1 -1
- package/dist/grpc/proto/types.mjs +2 -1
- package/dist/jsonRpc/client.d.mts +4 -7
- package/dist/jsonRpc/client.d.mts.map +1 -1
- package/dist/jsonRpc/client.mjs +4 -33
- package/dist/jsonRpc/client.mjs.map +1 -1
- package/dist/jsonRpc/core.d.mts +8 -15
- package/dist/jsonRpc/core.d.mts.map +1 -1
- package/dist/jsonRpc/core.mjs +81 -34
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/jsonRpc/errors.d.mts.map +1 -1
- package/dist/jsonRpc/http-transport.d.mts +1 -17
- package/dist/jsonRpc/http-transport.d.mts.map +1 -1
- package/dist/jsonRpc/http-transport.mjs +0 -23
- package/dist/jsonRpc/http-transport.mjs.map +1 -1
- package/dist/jsonRpc/index.d.mts +3 -3
- package/dist/jsonRpc/network.d.mts.map +1 -1
- package/dist/jsonRpc/types/chain.d.mts.map +1 -1
- package/dist/jsonRpc/types/changes.d.mts.map +1 -1
- package/dist/jsonRpc/types/coins.d.mts.map +1 -1
- package/dist/jsonRpc/types/common.d.mts +1 -2
- package/dist/jsonRpc/types/common.d.mts.map +1 -1
- package/dist/jsonRpc/types/generated.d.mts +101 -129
- package/dist/jsonRpc/types/generated.d.mts.map +1 -1
- package/dist/jsonRpc/types/index.d.mts +1 -1
- package/dist/jsonRpc/types/params.d.mts +9 -14
- package/dist/jsonRpc/types/params.d.mts.map +1 -1
- package/dist/keypairs/ed25519/keypair.d.mts +8 -6
- package/dist/keypairs/ed25519/keypair.d.mts.map +1 -1
- package/dist/keypairs/ed25519/keypair.mjs +13 -9
- package/dist/keypairs/ed25519/keypair.mjs.map +1 -1
- package/dist/keypairs/ed25519/publickey.d.mts +0 -1
- package/dist/keypairs/ed25519/publickey.d.mts.map +1 -1
- package/dist/keypairs/passkey/keypair.d.mts +12 -5
- package/dist/keypairs/passkey/keypair.d.mts.map +1 -1
- package/dist/keypairs/passkey/keypair.mjs +20 -7
- package/dist/keypairs/passkey/keypair.mjs.map +1 -1
- package/dist/keypairs/passkey/publickey.d.mts +0 -1
- package/dist/keypairs/passkey/publickey.d.mts.map +1 -1
- package/dist/keypairs/passkey/types.d.mts.map +1 -1
- package/dist/keypairs/secp256k1/keypair.d.mts +3 -3
- package/dist/keypairs/secp256k1/keypair.d.mts.map +1 -1
- package/dist/keypairs/secp256k1/keypair.mjs +6 -6
- package/dist/keypairs/secp256k1/keypair.mjs.map +1 -1
- package/dist/keypairs/secp256k1/publickey.d.mts +0 -1
- package/dist/keypairs/secp256k1/publickey.d.mts.map +1 -1
- package/dist/keypairs/secp256r1/keypair.d.mts +3 -3
- package/dist/keypairs/secp256r1/keypair.d.mts.map +1 -1
- package/dist/keypairs/secp256r1/keypair.mjs +6 -6
- package/dist/keypairs/secp256r1/keypair.mjs.map +1 -1
- package/dist/keypairs/secp256r1/publickey.d.mts +0 -1
- package/dist/keypairs/secp256r1/publickey.d.mts.map +1 -1
- package/dist/multisig/publickey.d.mts +1 -0
- package/dist/multisig/publickey.d.mts.map +1 -1
- package/dist/multisig/publickey.mjs +7 -7
- package/dist/multisig/publickey.mjs.map +1 -1
- package/dist/multisig/signer.d.mts.map +1 -1
- package/dist/transactions/Arguments.d.mts.map +1 -1
- package/dist/transactions/Commands.d.mts +1 -1
- package/dist/transactions/Commands.d.mts.map +1 -1
- package/dist/transactions/Commands.mjs.map +1 -1
- package/dist/transactions/Inputs.d.mts.map +1 -1
- package/dist/transactions/ObjectCache.d.mts +3 -3
- package/dist/transactions/ObjectCache.d.mts.map +1 -1
- package/dist/transactions/Transaction.d.mts +26 -0
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/transactions/Transaction.mjs +23 -1
- package/dist/transactions/Transaction.mjs.map +1 -1
- package/dist/transactions/TransactionData.d.mts.map +1 -1
- package/dist/transactions/TransactionData.mjs +8 -8
- package/dist/transactions/TransactionData.mjs.map +1 -1
- package/dist/transactions/data/internal.d.mts +109 -109
- package/dist/transactions/data/internal.d.mts.map +1 -1
- package/dist/transactions/data/internal.mjs.map +1 -1
- package/dist/transactions/data/v1.d.mts +220 -221
- package/dist/transactions/data/v1.d.mts.map +1 -1
- package/dist/transactions/data/v2.d.mts.map +1 -1
- package/dist/transactions/data/v2.mjs.map +1 -1
- package/dist/transactions/executor/caching.mjs +2 -2
- package/dist/transactions/executor/caching.mjs.map +1 -1
- package/dist/transactions/executor/parallel.d.mts +1 -1
- package/dist/transactions/executor/parallel.d.mts.map +1 -1
- package/dist/transactions/executor/parallel.mjs +1 -1
- package/dist/transactions/executor/parallel.mjs.map +1 -1
- package/dist/transactions/executor/serial.d.mts +3 -3
- package/dist/transactions/executor/serial.d.mts.map +1 -1
- package/dist/transactions/executor/serial.mjs.map +1 -1
- package/dist/transactions/intents/CoinWithBalance.d.mts.map +1 -1
- package/dist/transactions/intents/CoinWithBalance.mjs +174 -97
- package/dist/transactions/intents/CoinWithBalance.mjs.map +1 -1
- package/dist/transactions/object.d.mts.map +1 -1
- package/dist/transactions/pure.d.mts.map +1 -1
- package/dist/transactions/pure.mjs +12 -12
- package/dist/transactions/pure.mjs.map +1 -1
- package/dist/transactions/resolve.d.mts.map +1 -1
- package/dist/transactions/resolve.mjs +3 -3
- package/dist/transactions/resolve.mjs.map +1 -1
- package/dist/transactions/serializer.d.mts.map +1 -1
- package/dist/transactions/serializer.mjs +15 -15
- 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/utils/coin-reservation.mjs +67 -0
- package/dist/utils/coin-reservation.mjs.map +1 -0
- package/dist/utils/constants.d.mts +2 -1
- package/dist/utils/constants.d.mts.map +1 -1
- package/dist/utils/constants.mjs +2 -1
- package/dist/utils/constants.mjs.map +1 -1
- package/dist/utils/derived-objects.d.mts +0 -1
- package/dist/utils/derived-objects.d.mts.map +1 -1
- package/dist/utils/dynamic-fields.d.mts.map +1 -1
- package/dist/utils/dynamic-fields.mjs +4 -4
- package/dist/utils/dynamic-fields.mjs.map +1 -1
- package/dist/utils/format.d.mts.map +1 -1
- package/dist/utils/haneul-types.d.mts.map +1 -1
- package/dist/utils/haneul-types.mjs +8 -0
- package/dist/utils/haneul-types.mjs.map +1 -1
- package/dist/utils/haneulns.d.mts.map +1 -1
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.mjs +2 -2
- package/dist/utils/move-registry.d.mts.map +1 -1
- package/dist/verify/verify.d.mts.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/address.d.mts.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/dist/zklogin/bcs.d.mts.map +1 -1
- package/dist/zklogin/jwt-decode.d.mts +0 -1
- package/dist/zklogin/jwt-decode.d.mts.map +1 -1
- package/dist/zklogin/jwt-utils.d.mts +0 -1
- package/dist/zklogin/jwt-utils.d.mts.map +1 -1
- package/dist/zklogin/nonce.d.mts.map +1 -1
- package/dist/zklogin/poseidon.d.mts.map +1 -1
- package/dist/zklogin/publickey.d.mts +0 -1
- package/dist/zklogin/publickey.d.mts.map +1 -1
- package/dist/zklogin/signature.d.mts.map +1 -1
- package/dist/zklogin/utils.d.mts.map +1 -1
- package/dist/zklogin/utils.mjs +1 -1
- package/dist/zklogin/utils.mjs.map +1 -1
- package/docs/bcs.md +132 -0
- package/docs/clients/core.md +616 -0
- package/docs/clients/graphql.md +99 -0
- package/docs/clients/grpc.md +152 -0
- package/docs/clients/index.md +93 -0
- package/docs/clients/json-rpc.md +235 -0
- package/docs/cryptography/keypairs.md +259 -0
- package/docs/cryptography/multisig.md +192 -0
- package/docs/cryptography/passkey.md +111 -0
- package/docs/cryptography/webcrypto-signer.md +81 -0
- package/docs/executors.md +148 -0
- package/docs/faucet.md +26 -0
- package/docs/hello-haneul.md +115 -0
- package/docs/index.md +56 -0
- package/docs/install.md +61 -0
- package/docs/llm-docs.md +32 -0
- package/docs/llms-index.md +66 -0
- package/docs/migrations/0.38.md +57 -0
- package/docs/migrations/haneul-1.0.md +454 -0
- package/docs/migrations/haneul-2.0/agent-prompt.md +42 -0
- package/docs/migrations/haneul-2.0/dapp-kit.md +350 -0
- package/docs/migrations/haneul-2.0/deepbook-v3.md +33 -0
- package/docs/migrations/haneul-2.0/haneul.md +341 -0
- package/docs/migrations/haneul-2.0/haneulns.md +42 -0
- package/docs/migrations/haneul-2.0/index.md +161 -0
- package/docs/migrations/haneul-2.0/json-rpc-migration.md +399 -0
- package/docs/migrations/haneul-2.0/kiosk.md +120 -0
- package/docs/migrations/haneul-2.0/sdk-maintainers.md +91 -0
- package/docs/migrations/haneul-2.0/seal.md +14 -0
- package/docs/migrations/haneul-2.0/wallet-builders.md +66 -0
- package/docs/migrations/haneul-2.0/walrus.md +41 -0
- package/docs/migrations/haneul-2.0/zksend.md +94 -0
- package/docs/plugins.md +255 -0
- package/docs/sdk-building.md +341 -0
- package/docs/transaction-building/basics.md +297 -0
- package/docs/transaction-building/gas.md +62 -0
- package/docs/transaction-building/intents.md +61 -0
- package/docs/transaction-building/offline.md +71 -0
- package/docs/transaction-building/sponsored-transactions.md +22 -0
- package/docs/utils/derived_objects.md +80 -0
- package/docs/utils/index.md +53 -0
- package/docs/zklogin.md +78 -0
- package/package.json +199 -199
- package/src/bcs/bcs.ts +13 -13
- package/src/bcs/effects.ts +20 -20
- package/src/bcs/index.ts +2 -2
- package/src/client/core-resolver.ts +150 -100
- package/src/client/core.ts +62 -22
- package/src/client/types.ts +109 -24
- package/src/cryptography/index.ts +2 -2
- package/src/cryptography/keypair.ts +2 -2
- package/src/cryptography/mnemonics.ts +7 -7
- package/src/cryptography/publickey.ts +5 -5
- package/src/faucet/faucet.ts +1 -1
- package/src/faucet/index.ts +1 -1
- package/src/graphql/client.ts +100 -8
- package/src/graphql/core.ts +73 -80
- package/src/graphql/generated/queries.ts +301 -51
- package/src/graphql/generated/schema.graphql +407 -104
- package/src/graphql/generated/tada-env.ts +779 -58
- package/src/graphql/index.ts +1 -1
- package/src/graphql/queries/getAllBalances.graphql +1 -1
- package/src/graphql/queries/getBalance.graphql +1 -1
- package/src/graphql/queries/getCoins.graphql +2 -2
- package/src/graphql/queries/getDynamicFields.graphql +9 -1
- package/src/graphql/queries/getMoveFunction.graphql +1 -1
- package/src/graphql/queries/getProtocolConfig.graphql +18 -0
- package/src/graphql/queries/nameService.graphql +1 -1
- package/src/graphql/queries/objects.graphql +11 -1
- package/src/graphql/queries/transactions.graphql +1 -3
- package/src/graphql/queries/verifyZkLoginSignature.graphql +1 -2
- package/src/grpc/client.ts +66 -8
- package/src/grpc/core.ts +74 -35
- package/src/grpc/index.ts +1 -1
- package/src/grpc/proto/haneul/rpc/v2/bcs.ts +1 -1
- package/src/grpc/proto/haneul/rpc/v2/execution_status.ts +4 -4
- package/src/grpc/proto/haneul/rpc/v2/object.ts +44 -0
- package/src/grpc/proto/haneul/rpc/v2/signature.ts +1 -1
- package/src/grpc/proto/haneul/rpc/v2/signature_scheme.ts +1 -1
- package/src/grpc/proto/haneul/rpc/v2/system_state.ts +4 -4
- package/src/grpc/proto/haneul/rpc/v2/transaction_execution_service.ts +16 -0
- package/src/jsonRpc/client.ts +5 -23
- package/src/jsonRpc/core.ts +114 -41
- package/src/jsonRpc/http-transport.ts +0 -52
- package/src/jsonRpc/index.ts +0 -1
- package/src/jsonRpc/types/common.ts +0 -1
- package/src/jsonRpc/types/generated.ts +2 -2
- package/src/jsonRpc/types/params.ts +6 -6
- package/src/keypairs/ed25519/keypair.ts +14 -10
- package/src/keypairs/passkey/keypair.ts +22 -8
- package/src/keypairs/secp256k1/keypair.ts +6 -6
- package/src/keypairs/secp256r1/keypair.ts +6 -6
- package/src/transactions/Commands.ts +1 -1
- package/src/transactions/Transaction.ts +38 -1
- package/src/transactions/TransactionData.ts +3 -3
- package/src/transactions/__tests__/bcs.test.ts +3 -3
- package/src/transactions/data/internal.ts +12 -12
- package/src/transactions/data/v2.ts +6 -6
- package/src/transactions/executor/caching.ts +2 -2
- package/src/transactions/executor/parallel.ts +1 -2
- package/src/transactions/executor/serial.ts +1 -1
- package/src/transactions/intents/CoinWithBalance.ts +247 -121
- package/src/utils/coin-reservation.ts +84 -0
- package/src/utils/constants.ts +2 -0
- package/src/utils/haneul-types.ts +16 -1
- package/src/utils/index.ts +1 -0
- package/src/version.ts +1 -1
- package/src/zklogin/utils.ts +1 -1
- package/dist/jsonRpc/rpc-websocket-client.d.mts +0 -26
- package/dist/jsonRpc/rpc-websocket-client.d.mts.map +0 -1
- package/dist/jsonRpc/rpc-websocket-client.mjs +0 -135
- package/dist/jsonRpc/rpc-websocket-client.mjs.map +0 -1
- package/src/jsonRpc/rpc-websocket-client.ts +0 -241
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { JsonRpcError } from "./errors.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/jsonRpc/rpc-websocket-client.ts
|
|
4
|
-
function getWebsocketUrl(httpUrl) {
|
|
5
|
-
const url = new URL(httpUrl);
|
|
6
|
-
url.protocol = url.protocol.replace("http", "ws");
|
|
7
|
-
return url.toString();
|
|
8
|
-
}
|
|
9
|
-
const DEFAULT_CLIENT_OPTIONS = {
|
|
10
|
-
WebSocketConstructor: typeof WebSocket !== "undefined" ? WebSocket : void 0,
|
|
11
|
-
callTimeout: 3e4,
|
|
12
|
-
reconnectTimeout: 3e3,
|
|
13
|
-
maxReconnects: 5
|
|
14
|
-
};
|
|
15
|
-
var WebsocketClient = class {
|
|
16
|
-
#requestId = 0;
|
|
17
|
-
#disconnects = 0;
|
|
18
|
-
#webSocket = null;
|
|
19
|
-
#connectionPromise = null;
|
|
20
|
-
#subscriptions = /* @__PURE__ */ new Set();
|
|
21
|
-
#pendingRequests = /* @__PURE__ */ new Map();
|
|
22
|
-
constructor(endpoint, options = {}) {
|
|
23
|
-
this.endpoint = endpoint;
|
|
24
|
-
this.options = {
|
|
25
|
-
...DEFAULT_CLIENT_OPTIONS,
|
|
26
|
-
...options
|
|
27
|
-
};
|
|
28
|
-
if (!this.options.WebSocketConstructor) throw new Error("Missing WebSocket constructor");
|
|
29
|
-
if (this.endpoint.startsWith("http")) this.endpoint = getWebsocketUrl(this.endpoint);
|
|
30
|
-
}
|
|
31
|
-
async makeRequest(method, params, signal) {
|
|
32
|
-
const webSocket = await this.#setupWebSocket();
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
this.#requestId += 1;
|
|
35
|
-
this.#pendingRequests.set(this.#requestId, {
|
|
36
|
-
resolve,
|
|
37
|
-
reject,
|
|
38
|
-
timeout: setTimeout(() => {
|
|
39
|
-
this.#pendingRequests.delete(this.#requestId);
|
|
40
|
-
reject(/* @__PURE__ */ new Error(`Request timeout: ${method}`));
|
|
41
|
-
}, this.options.callTimeout)
|
|
42
|
-
});
|
|
43
|
-
signal?.addEventListener("abort", () => {
|
|
44
|
-
this.#pendingRequests.delete(this.#requestId);
|
|
45
|
-
reject(signal.reason);
|
|
46
|
-
});
|
|
47
|
-
webSocket.send(JSON.stringify({
|
|
48
|
-
jsonrpc: "2.0",
|
|
49
|
-
id: this.#requestId,
|
|
50
|
-
method,
|
|
51
|
-
params
|
|
52
|
-
}));
|
|
53
|
-
}).then(({ error, result }) => {
|
|
54
|
-
if (error) throw new JsonRpcError(error.message, error.code);
|
|
55
|
-
return result;
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
#setupWebSocket() {
|
|
59
|
-
if (this.#connectionPromise) return this.#connectionPromise;
|
|
60
|
-
this.#connectionPromise = new Promise((resolve) => {
|
|
61
|
-
this.#webSocket?.close();
|
|
62
|
-
this.#webSocket = new this.options.WebSocketConstructor(this.endpoint);
|
|
63
|
-
this.#webSocket.addEventListener("open", () => {
|
|
64
|
-
this.#disconnects = 0;
|
|
65
|
-
resolve(this.#webSocket);
|
|
66
|
-
});
|
|
67
|
-
this.#webSocket.addEventListener("close", () => {
|
|
68
|
-
this.#disconnects++;
|
|
69
|
-
if (this.#disconnects <= this.options.maxReconnects) setTimeout(() => {
|
|
70
|
-
this.#reconnect();
|
|
71
|
-
}, this.options.reconnectTimeout);
|
|
72
|
-
});
|
|
73
|
-
this.#webSocket.addEventListener("message", ({ data }) => {
|
|
74
|
-
let json;
|
|
75
|
-
try {
|
|
76
|
-
json = JSON.parse(data);
|
|
77
|
-
} catch (error) {
|
|
78
|
-
console.error(new Error(`Failed to parse RPC message: ${data}`, { cause: error }));
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
if ("id" in json && json.id != null && this.#pendingRequests.has(json.id)) {
|
|
82
|
-
const { resolve: resolve$1, timeout } = this.#pendingRequests.get(json.id);
|
|
83
|
-
clearTimeout(timeout);
|
|
84
|
-
resolve$1(json);
|
|
85
|
-
} else if ("params" in json) {
|
|
86
|
-
const { params } = json;
|
|
87
|
-
this.#subscriptions.forEach((subscription) => {
|
|
88
|
-
if (subscription.subscriptionId === params.subscription) {
|
|
89
|
-
if (params.subscription === subscription.subscriptionId) subscription.onMessage(params.result);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
return this.#connectionPromise;
|
|
96
|
-
}
|
|
97
|
-
async #reconnect() {
|
|
98
|
-
this.#webSocket?.close();
|
|
99
|
-
this.#connectionPromise = null;
|
|
100
|
-
return Promise.allSettled([...this.#subscriptions].map((subscription) => subscription.subscribe(this)));
|
|
101
|
-
}
|
|
102
|
-
async subscribe(input) {
|
|
103
|
-
const subscription = new RpcSubscription(input);
|
|
104
|
-
this.#subscriptions.add(subscription);
|
|
105
|
-
await subscription.subscribe(this);
|
|
106
|
-
return () => subscription.unsubscribe(this);
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
var RpcSubscription = class {
|
|
110
|
-
constructor(input) {
|
|
111
|
-
this.subscriptionId = null;
|
|
112
|
-
this.subscribed = false;
|
|
113
|
-
this.input = input;
|
|
114
|
-
}
|
|
115
|
-
onMessage(message) {
|
|
116
|
-
if (this.subscribed) this.input.onMessage(message);
|
|
117
|
-
}
|
|
118
|
-
async unsubscribe(client) {
|
|
119
|
-
const { subscriptionId } = this;
|
|
120
|
-
this.subscribed = false;
|
|
121
|
-
if (subscriptionId == null) return false;
|
|
122
|
-
this.subscriptionId = null;
|
|
123
|
-
return client.makeRequest(this.input.unsubscribe, [subscriptionId]);
|
|
124
|
-
}
|
|
125
|
-
async subscribe(client) {
|
|
126
|
-
this.subscriptionId = null;
|
|
127
|
-
this.subscribed = true;
|
|
128
|
-
const newSubscriptionId = await client.makeRequest(this.input.method, this.input.params, this.input.signal);
|
|
129
|
-
if (this.subscribed) this.subscriptionId = newSubscriptionId;
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
//#endregion
|
|
134
|
-
export { WebsocketClient };
|
|
135
|
-
//# sourceMappingURL=rpc-websocket-client.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-websocket-client.mjs","names":["#setupWebSocket","#requestId","#pendingRequests","#connectionPromise","#webSocket","#disconnects","#reconnect","#subscriptions"],"sources":["../../src/jsonRpc/rpc-websocket-client.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { JsonRpcError } from './errors.js';\n\nfunction getWebsocketUrl(httpUrl: string): string {\n\tconst url = new URL(httpUrl);\n\turl.protocol = url.protocol.replace('http', 'ws');\n\treturn url.toString();\n}\n\ntype JsonRpcMessage =\n\t| {\n\t\t\tid: number;\n\t\t\tresult: never;\n\t\t\terror: {\n\t\t\t\tcode: number;\n\t\t\t\tmessage: string;\n\t\t\t};\n\t }\n\t| {\n\t\t\tid: number;\n\t\t\tresult: unknown;\n\t\t\terror: never;\n\t }\n\t| {\n\t\t\tmethod: string;\n\t\t\tparams: NotificationMessageParams;\n\t };\n\ntype NotificationMessageParams = {\n\tsubscription?: number;\n\tresult: object;\n};\n\ntype SubscriptionRequest<T = any> = {\n\tmethod: string;\n\tunsubscribe: string;\n\tparams: any[];\n\tonMessage: (event: T) => void;\n\tsignal?: AbortSignal;\n};\n\n/**\n * Configuration options for the websocket connection\n */\nexport type WebsocketClientOptions = {\n\t/**\n\t * Custom WebSocket class to use. Defaults to the global WebSocket class, if available.\n\t */\n\tWebSocketConstructor?: typeof WebSocket;\n\t/**\n\t * Milliseconds before timing out while calling an RPC method\n\t */\n\tcallTimeout?: number;\n\t/**\n\t * Milliseconds between attempts to connect\n\t */\n\treconnectTimeout?: number;\n\t/**\n\t * Maximum number of times to try connecting before giving up\n\t */\n\tmaxReconnects?: number;\n};\n\nexport const DEFAULT_CLIENT_OPTIONS = {\n\t// We fudge the typing because we also check for undefined in the constructor:\n\tWebSocketConstructor: (typeof WebSocket !== 'undefined'\n\t\t? WebSocket\n\t\t: undefined) as typeof WebSocket,\n\tcallTimeout: 30000,\n\treconnectTimeout: 3000,\n\tmaxReconnects: 5,\n} satisfies WebsocketClientOptions;\n\nexport class WebsocketClient {\n\tendpoint: string;\n\toptions: Required<WebsocketClientOptions>;\n\t#requestId = 0;\n\t#disconnects = 0;\n\t#webSocket: WebSocket | null = null;\n\t#connectionPromise: Promise<WebSocket> | null = null;\n\t#subscriptions = new Set<RpcSubscription>();\n\t#pendingRequests = new Map<\n\t\tnumber,\n\t\t{\n\t\t\tresolve: (result: Extract<JsonRpcMessage, { id: number }>) => void;\n\t\t\treject: (reason: unknown) => void;\n\t\t\ttimeout: ReturnType<typeof setTimeout>;\n\t\t}\n\t>();\n\n\tconstructor(endpoint: string, options: WebsocketClientOptions = {}) {\n\t\tthis.endpoint = endpoint;\n\t\tthis.options = { ...DEFAULT_CLIENT_OPTIONS, ...options };\n\n\t\tif (!this.options.WebSocketConstructor) {\n\t\t\tthrow new Error('Missing WebSocket constructor');\n\t\t}\n\n\t\tif (this.endpoint.startsWith('http')) {\n\t\t\tthis.endpoint = getWebsocketUrl(this.endpoint);\n\t\t}\n\t}\n\n\tasync makeRequest<T>(method: string, params: any[], signal?: AbortSignal): Promise<T> {\n\t\tconst webSocket = await this.#setupWebSocket();\n\n\t\treturn new Promise<Extract<JsonRpcMessage, { id: number }>>((resolve, reject) => {\n\t\t\tthis.#requestId += 1;\n\t\t\tthis.#pendingRequests.set(this.#requestId, {\n\t\t\t\tresolve: resolve,\n\t\t\t\treject,\n\t\t\t\ttimeout: setTimeout(() => {\n\t\t\t\t\tthis.#pendingRequests.delete(this.#requestId);\n\t\t\t\t\treject(new Error(`Request timeout: ${method}`));\n\t\t\t\t}, this.options.callTimeout),\n\t\t\t});\n\n\t\t\tsignal?.addEventListener('abort', () => {\n\t\t\t\tthis.#pendingRequests.delete(this.#requestId);\n\t\t\t\treject(signal.reason);\n\t\t\t});\n\n\t\t\twebSocket.send(JSON.stringify({ jsonrpc: '2.0', id: this.#requestId, method, params }));\n\t\t}).then(({ error, result }) => {\n\t\t\tif (error) {\n\t\t\t\tthrow new JsonRpcError(error.message, error.code);\n\t\t\t}\n\n\t\t\treturn result as T;\n\t\t});\n\t}\n\n\t#setupWebSocket() {\n\t\tif (this.#connectionPromise) {\n\t\t\treturn this.#connectionPromise;\n\t\t}\n\n\t\tthis.#connectionPromise = new Promise<WebSocket>((resolve) => {\n\t\t\tthis.#webSocket?.close();\n\t\t\tthis.#webSocket = new this.options.WebSocketConstructor(this.endpoint);\n\n\t\t\tthis.#webSocket.addEventListener('open', () => {\n\t\t\t\tthis.#disconnects = 0;\n\t\t\t\tresolve(this.#webSocket!);\n\t\t\t});\n\n\t\t\tthis.#webSocket.addEventListener('close', () => {\n\t\t\t\tthis.#disconnects++;\n\t\t\t\tif (this.#disconnects <= this.options.maxReconnects) {\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthis.#reconnect();\n\t\t\t\t\t}, this.options.reconnectTimeout);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tthis.#webSocket.addEventListener('message', ({ data }: { data: string }) => {\n\t\t\t\tlet json: JsonRpcMessage;\n\t\t\t\ttry {\n\t\t\t\t\tjson = JSON.parse(data) as JsonRpcMessage;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error(new Error(`Failed to parse RPC message: ${data}`, { cause: error }));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ('id' in json && json.id != null && this.#pendingRequests.has(json.id)) {\n\t\t\t\t\tconst { resolve, timeout } = this.#pendingRequests.get(json.id)!;\n\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\tresolve(json);\n\t\t\t\t} else if ('params' in json) {\n\t\t\t\t\tconst { params } = json;\n\t\t\t\t\tthis.#subscriptions.forEach((subscription) => {\n\t\t\t\t\t\tif (subscription.subscriptionId === params.subscription)\n\t\t\t\t\t\t\tif (params.subscription === subscription.subscriptionId) {\n\t\t\t\t\t\t\t\tsubscription.onMessage(params.result);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\treturn this.#connectionPromise;\n\t}\n\n\tasync #reconnect() {\n\t\tthis.#webSocket?.close();\n\t\tthis.#connectionPromise = null;\n\n\t\treturn Promise.allSettled(\n\t\t\t[...this.#subscriptions].map((subscription) => subscription.subscribe(this)),\n\t\t);\n\t}\n\n\tasync subscribe<T>(input: SubscriptionRequest<T>) {\n\t\tconst subscription = new RpcSubscription(input);\n\t\tthis.#subscriptions.add(subscription);\n\t\tawait subscription.subscribe(this);\n\t\treturn () => subscription.unsubscribe(this);\n\t}\n}\n\nclass RpcSubscription {\n\tsubscriptionId: number | null = null;\n\tinput: SubscriptionRequest<any>;\n\tsubscribed = false;\n\n\tconstructor(input: SubscriptionRequest) {\n\t\tthis.input = input;\n\t}\n\n\tonMessage(message: unknown) {\n\t\tif (this.subscribed) {\n\t\t\tthis.input.onMessage(message);\n\t\t}\n\t}\n\n\tasync unsubscribe(client: WebsocketClient) {\n\t\tconst { subscriptionId } = this;\n\t\tthis.subscribed = false;\n\t\tif (subscriptionId == null) return false;\n\t\tthis.subscriptionId = null;\n\n\t\treturn client.makeRequest(this.input.unsubscribe, [subscriptionId]);\n\t}\n\n\tasync subscribe(client: WebsocketClient) {\n\t\tthis.subscriptionId = null;\n\t\tthis.subscribed = true;\n\t\tconst newSubscriptionId = await client.makeRequest<number>(\n\t\t\tthis.input.method,\n\t\t\tthis.input.params,\n\t\t\tthis.input.signal,\n\t\t);\n\n\t\tif (this.subscribed) {\n\t\t\tthis.subscriptionId = newSubscriptionId;\n\t\t}\n\t}\n}\n"],"mappings":"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"}
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import { JsonRpcError } from './errors.js';
|
|
5
|
-
|
|
6
|
-
function getWebsocketUrl(httpUrl: string): string {
|
|
7
|
-
const url = new URL(httpUrl);
|
|
8
|
-
url.protocol = url.protocol.replace('http', 'ws');
|
|
9
|
-
return url.toString();
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
type JsonRpcMessage =
|
|
13
|
-
| {
|
|
14
|
-
id: number;
|
|
15
|
-
result: never;
|
|
16
|
-
error: {
|
|
17
|
-
code: number;
|
|
18
|
-
message: string;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
| {
|
|
22
|
-
id: number;
|
|
23
|
-
result: unknown;
|
|
24
|
-
error: never;
|
|
25
|
-
}
|
|
26
|
-
| {
|
|
27
|
-
method: string;
|
|
28
|
-
params: NotificationMessageParams;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
type NotificationMessageParams = {
|
|
32
|
-
subscription?: number;
|
|
33
|
-
result: object;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
type SubscriptionRequest<T = any> = {
|
|
37
|
-
method: string;
|
|
38
|
-
unsubscribe: string;
|
|
39
|
-
params: any[];
|
|
40
|
-
onMessage: (event: T) => void;
|
|
41
|
-
signal?: AbortSignal;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Configuration options for the websocket connection
|
|
46
|
-
*/
|
|
47
|
-
export type WebsocketClientOptions = {
|
|
48
|
-
/**
|
|
49
|
-
* Custom WebSocket class to use. Defaults to the global WebSocket class, if available.
|
|
50
|
-
*/
|
|
51
|
-
WebSocketConstructor?: typeof WebSocket;
|
|
52
|
-
/**
|
|
53
|
-
* Milliseconds before timing out while calling an RPC method
|
|
54
|
-
*/
|
|
55
|
-
callTimeout?: number;
|
|
56
|
-
/**
|
|
57
|
-
* Milliseconds between attempts to connect
|
|
58
|
-
*/
|
|
59
|
-
reconnectTimeout?: number;
|
|
60
|
-
/**
|
|
61
|
-
* Maximum number of times to try connecting before giving up
|
|
62
|
-
*/
|
|
63
|
-
maxReconnects?: number;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export const DEFAULT_CLIENT_OPTIONS = {
|
|
67
|
-
// We fudge the typing because we also check for undefined in the constructor:
|
|
68
|
-
WebSocketConstructor: (typeof WebSocket !== 'undefined'
|
|
69
|
-
? WebSocket
|
|
70
|
-
: undefined) as typeof WebSocket,
|
|
71
|
-
callTimeout: 30000,
|
|
72
|
-
reconnectTimeout: 3000,
|
|
73
|
-
maxReconnects: 5,
|
|
74
|
-
} satisfies WebsocketClientOptions;
|
|
75
|
-
|
|
76
|
-
export class WebsocketClient {
|
|
77
|
-
endpoint: string;
|
|
78
|
-
options: Required<WebsocketClientOptions>;
|
|
79
|
-
#requestId = 0;
|
|
80
|
-
#disconnects = 0;
|
|
81
|
-
#webSocket: WebSocket | null = null;
|
|
82
|
-
#connectionPromise: Promise<WebSocket> | null = null;
|
|
83
|
-
#subscriptions = new Set<RpcSubscription>();
|
|
84
|
-
#pendingRequests = new Map<
|
|
85
|
-
number,
|
|
86
|
-
{
|
|
87
|
-
resolve: (result: Extract<JsonRpcMessage, { id: number }>) => void;
|
|
88
|
-
reject: (reason: unknown) => void;
|
|
89
|
-
timeout: ReturnType<typeof setTimeout>;
|
|
90
|
-
}
|
|
91
|
-
>();
|
|
92
|
-
|
|
93
|
-
constructor(endpoint: string, options: WebsocketClientOptions = {}) {
|
|
94
|
-
this.endpoint = endpoint;
|
|
95
|
-
this.options = { ...DEFAULT_CLIENT_OPTIONS, ...options };
|
|
96
|
-
|
|
97
|
-
if (!this.options.WebSocketConstructor) {
|
|
98
|
-
throw new Error('Missing WebSocket constructor');
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (this.endpoint.startsWith('http')) {
|
|
102
|
-
this.endpoint = getWebsocketUrl(this.endpoint);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
async makeRequest<T>(method: string, params: any[], signal?: AbortSignal): Promise<T> {
|
|
107
|
-
const webSocket = await this.#setupWebSocket();
|
|
108
|
-
|
|
109
|
-
return new Promise<Extract<JsonRpcMessage, { id: number }>>((resolve, reject) => {
|
|
110
|
-
this.#requestId += 1;
|
|
111
|
-
this.#pendingRequests.set(this.#requestId, {
|
|
112
|
-
resolve: resolve,
|
|
113
|
-
reject,
|
|
114
|
-
timeout: setTimeout(() => {
|
|
115
|
-
this.#pendingRequests.delete(this.#requestId);
|
|
116
|
-
reject(new Error(`Request timeout: ${method}`));
|
|
117
|
-
}, this.options.callTimeout),
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
signal?.addEventListener('abort', () => {
|
|
121
|
-
this.#pendingRequests.delete(this.#requestId);
|
|
122
|
-
reject(signal.reason);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
webSocket.send(JSON.stringify({ jsonrpc: '2.0', id: this.#requestId, method, params }));
|
|
126
|
-
}).then(({ error, result }) => {
|
|
127
|
-
if (error) {
|
|
128
|
-
throw new JsonRpcError(error.message, error.code);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return result as T;
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
#setupWebSocket() {
|
|
136
|
-
if (this.#connectionPromise) {
|
|
137
|
-
return this.#connectionPromise;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
this.#connectionPromise = new Promise<WebSocket>((resolve) => {
|
|
141
|
-
this.#webSocket?.close();
|
|
142
|
-
this.#webSocket = new this.options.WebSocketConstructor(this.endpoint);
|
|
143
|
-
|
|
144
|
-
this.#webSocket.addEventListener('open', () => {
|
|
145
|
-
this.#disconnects = 0;
|
|
146
|
-
resolve(this.#webSocket!);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
this.#webSocket.addEventListener('close', () => {
|
|
150
|
-
this.#disconnects++;
|
|
151
|
-
if (this.#disconnects <= this.options.maxReconnects) {
|
|
152
|
-
setTimeout(() => {
|
|
153
|
-
this.#reconnect();
|
|
154
|
-
}, this.options.reconnectTimeout);
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
this.#webSocket.addEventListener('message', ({ data }: { data: string }) => {
|
|
159
|
-
let json: JsonRpcMessage;
|
|
160
|
-
try {
|
|
161
|
-
json = JSON.parse(data) as JsonRpcMessage;
|
|
162
|
-
} catch (error) {
|
|
163
|
-
console.error(new Error(`Failed to parse RPC message: ${data}`, { cause: error }));
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if ('id' in json && json.id != null && this.#pendingRequests.has(json.id)) {
|
|
168
|
-
const { resolve, timeout } = this.#pendingRequests.get(json.id)!;
|
|
169
|
-
|
|
170
|
-
clearTimeout(timeout);
|
|
171
|
-
resolve(json);
|
|
172
|
-
} else if ('params' in json) {
|
|
173
|
-
const { params } = json;
|
|
174
|
-
this.#subscriptions.forEach((subscription) => {
|
|
175
|
-
if (subscription.subscriptionId === params.subscription)
|
|
176
|
-
if (params.subscription === subscription.subscriptionId) {
|
|
177
|
-
subscription.onMessage(params.result);
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
return this.#connectionPromise;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
async #reconnect() {
|
|
188
|
-
this.#webSocket?.close();
|
|
189
|
-
this.#connectionPromise = null;
|
|
190
|
-
|
|
191
|
-
return Promise.allSettled(
|
|
192
|
-
[...this.#subscriptions].map((subscription) => subscription.subscribe(this)),
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
async subscribe<T>(input: SubscriptionRequest<T>) {
|
|
197
|
-
const subscription = new RpcSubscription(input);
|
|
198
|
-
this.#subscriptions.add(subscription);
|
|
199
|
-
await subscription.subscribe(this);
|
|
200
|
-
return () => subscription.unsubscribe(this);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
class RpcSubscription {
|
|
205
|
-
subscriptionId: number | null = null;
|
|
206
|
-
input: SubscriptionRequest<any>;
|
|
207
|
-
subscribed = false;
|
|
208
|
-
|
|
209
|
-
constructor(input: SubscriptionRequest) {
|
|
210
|
-
this.input = input;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
onMessage(message: unknown) {
|
|
214
|
-
if (this.subscribed) {
|
|
215
|
-
this.input.onMessage(message);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
async unsubscribe(client: WebsocketClient) {
|
|
220
|
-
const { subscriptionId } = this;
|
|
221
|
-
this.subscribed = false;
|
|
222
|
-
if (subscriptionId == null) return false;
|
|
223
|
-
this.subscriptionId = null;
|
|
224
|
-
|
|
225
|
-
return client.makeRequest(this.input.unsubscribe, [subscriptionId]);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
async subscribe(client: WebsocketClient) {
|
|
229
|
-
this.subscriptionId = null;
|
|
230
|
-
this.subscribed = true;
|
|
231
|
-
const newSubscriptionId = await client.makeRequest<number>(
|
|
232
|
-
this.input.method,
|
|
233
|
-
this.input.params,
|
|
234
|
-
this.input.signal,
|
|
235
|
-
);
|
|
236
|
-
|
|
237
|
-
if (this.subscribed) {
|
|
238
|
-
this.subscriptionId = newSubscriptionId;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|