wowok 2.1.40 → 2.1.41
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/dist/cjs/bcs/bcs.js +1 -253
- package/dist/cjs/bcs/effects.js +1 -199
- package/dist/cjs/bcs/index.js +1 -51
- package/dist/cjs/bcs/pure.js +1 -36
- package/dist/cjs/bcs/type-tag-serializer.js +1 -104
- package/dist/cjs/bcs/types.js +1 -3
- package/dist/cjs/client/index.js +1 -4
- package/dist/cjs/client/network.js +1 -15
- package/dist/cjs/cryptography/index.js +1 -6
- package/dist/cjs/cryptography/intent.js +1 -14
- package/dist/cjs/cryptography/keypair.js +1 -74
- package/dist/cjs/cryptography/mnemonics.js +1 -20
- package/dist/cjs/cryptography/publickey.js +1 -80
- package/dist/cjs/cryptography/signature-scheme.js +1 -22
- package/dist/cjs/cryptography/signature.js +1 -41
- package/dist/cjs/experimental/cache.js +1 -58
- package/dist/cjs/experimental/client.js +1 -19
- package/dist/cjs/experimental/core.js +1 -80
- package/dist/cjs/experimental/errors.js +1 -24
- package/dist/cjs/experimental/index.js +1 -5
- package/dist/cjs/experimental/persistent-storage.js +1 -220
- package/dist/cjs/experimental/persistent-storage.test.js +1 -144
- package/dist/cjs/experimental/transports/utils.js +1 -96
- package/dist/cjs/experimental/types.js +1 -1
- package/dist/cjs/faucet/faucet.js +1 -99
- package/dist/cjs/faucet/index.js +1 -1
- package/dist/cjs/grpc/client.js +1 -42
- package/dist/cjs/grpc/core.js +1 -587
- package/dist/cjs/grpc/index.js +1 -2
- package/dist/cjs/grpc/proto/google/protobuf/any.js +1 -106
- package/dist/cjs/grpc/proto/google/protobuf/duration.js +1 -58
- package/dist/cjs/grpc/proto/google/protobuf/empty.js +1 -7
- package/dist/cjs/grpc/proto/google/protobuf/field_mask.js +1 -47
- package/dist/cjs/grpc/proto/google/protobuf/struct.js +1 -191
- package/dist/cjs/grpc/proto/google/protobuf/timestamp.js +1 -91
- package/dist/cjs/grpc/proto/google/rpc/error_details.js +1 -265
- package/dist/cjs/grpc/proto/google/rpc/status.js +1 -23
- package/dist/cjs/grpc/proto/sui/rpc/v2/argument.js +1 -46
- package/dist/cjs/grpc/proto/sui/rpc/v2/balance_change.js +1 -29
- package/dist/cjs/grpc/proto/sui/rpc/v2/bcs.js +1 -22
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint.js +1 -54
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_contents.js +1 -60
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_summary.js +1 -144
- package/dist/cjs/grpc/proto/sui/rpc/v2/effects.js +1 -271
- package/dist/cjs/grpc/proto/sui/rpc/v2/epoch.js +1 -64
- package/dist/cjs/grpc/proto/sui/rpc/v2/error_reason.js +1 -6
- package/dist/cjs/grpc/proto/sui/rpc/v2/event.js +1 -62
- package/dist/cjs/grpc/proto/sui/rpc/v2/executed_transaction.js +1 -64
- package/dist/cjs/grpc/proto/sui/rpc/v2/execution_status.js +1 -481
- package/dist/cjs/grpc/proto/sui/rpc/v2/gas_cost_summary.js +1 -40
- package/dist/cjs/grpc/proto/sui/rpc/v2/input.js +1 -61
- package/dist/cjs/grpc/proto/sui/rpc/v2/jwk.js +1 -57
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.client.js +1 -39
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.js +1 -329
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package.js +1 -447
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.client.js +1 -27
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.js +1 -206
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.client.js +1 -19
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.js +1 -109
- package/dist/cjs/grpc/proto/sui/rpc/v2/object.js +1 -90
- package/dist/cjs/grpc/proto/sui/rpc/v2/object_reference.js +1 -30
- package/dist/cjs/grpc/proto/sui/rpc/v2/owner.js +1 -39
- package/dist/cjs/grpc/proto/sui/rpc/v2/protocol_config.js +1 -30
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature.js +1 -501
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_scheme.js +1 -10
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.client.js +1 -15
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.js +1 -62
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.client.js +1 -31
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.js +1 -504
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.client.js +1 -15
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.js +1 -37
- package/dist/cjs/grpc/proto/sui/rpc/v2/system_state.js +1 -709
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction.js +1 -950
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.client.js +1 -19
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.js +1 -144
- package/dist/cjs/index.js +1 -22
- package/dist/cjs/jsonRpc/client.js +1 -516
- package/dist/cjs/jsonRpc/core.js +1 -587
- package/dist/cjs/jsonRpc/errors.js +1 -38
- package/dist/cjs/jsonRpc/http-transport.js +1 -70
- package/dist/cjs/jsonRpc/index.js +1 -3
- package/dist/cjs/jsonRpc/json-rpc-resolver.js +1 -296
- package/dist/cjs/jsonRpc/rpc-websocket-client.js +1 -155
- package/dist/cjs/jsonRpc/types/chain.js +1 -1
- package/dist/cjs/jsonRpc/types/changes.js +1 -1
- package/dist/cjs/jsonRpc/types/coins.js +1 -1
- package/dist/cjs/jsonRpc/types/common.js +1 -1
- package/dist/cjs/jsonRpc/types/generated.js +1 -1
- package/dist/cjs/jsonRpc/types/index.js +1 -1
- package/dist/cjs/jsonRpc/types/params.js +1 -1
- package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js +1 -58
- package/dist/cjs/keypairs/ed25519/index.js +1 -2
- package/dist/cjs/keypairs/ed25519/keypair.js +1 -90
- package/dist/cjs/keypairs/ed25519/publickey.js +1 -50
- package/dist/cjs/keypairs/index.js +1 -4
- package/dist/cjs/keypairs/passkey/index.js +1 -2
- package/dist/cjs/keypairs/passkey/keypair.js +1 -155
- package/dist/cjs/keypairs/passkey/publickey.js +1 -117
- package/dist/cjs/keypairs/passkey/types.js +1 -1
- package/dist/cjs/keypairs/secp256k1/index.js +1 -2
- package/dist/cjs/keypairs/secp256k1/keypair.js +1 -82
- package/dist/cjs/keypairs/secp256k1/publickey.js +1 -51
- package/dist/cjs/keypairs/secp256r1/index.js +1 -2
- package/dist/cjs/keypairs/secp256r1/keypair.js +1 -78
- package/dist/cjs/keypairs/secp256r1/publickey.js +1 -52
- package/dist/cjs/multisig/index.js +1 -2
- package/dist/cjs/multisig/publickey.js +1 -201
- package/dist/cjs/multisig/signer.js +1 -58
- package/dist/cjs/transactions/Arguments.js +1 -9
- package/dist/cjs/transactions/Commands.js +1 -102
- package/dist/cjs/transactions/Inputs.js +1 -52
- package/dist/cjs/transactions/ObjectCache.js +1 -205
- package/dist/cjs/transactions/Transaction.js +1 -574
- package/dist/cjs/transactions/TransactionData.js +1 -409
- package/dist/cjs/transactions/__tests__/Transaction.test.js +1 -160
- package/dist/cjs/transactions/__tests__/bcs.test.js +1 -182
- package/dist/cjs/transactions/data/internal.js +1 -169
- package/dist/cjs/transactions/data/v1.js +1 -469
- package/dist/cjs/transactions/data/v2.js +1 -97
- package/dist/cjs/transactions/executor/caching.js +1 -65
- package/dist/cjs/transactions/executor/parallel.js +1 -347
- package/dist/cjs/transactions/executor/queue.js +1 -59
- package/dist/cjs/transactions/executor/serial.js +1 -99
- package/dist/cjs/transactions/hash.js +1 -8
- package/dist/cjs/transactions/index.js +1 -12
- package/dist/cjs/transactions/intents/CoinWithBalance.js +1 -145
- package/dist/cjs/transactions/object.js +1 -87
- package/dist/cjs/transactions/plugins/NamedPackagesPlugin.js +1 -11
- package/dist/cjs/transactions/pure.js +1 -36
- package/dist/cjs/transactions/resolve.js +1 -69
- package/dist/cjs/transactions/serializer.js +1 -167
- package/dist/cjs/transactions/utils.js +1 -121
- package/dist/cjs/utils/constants.js +1 -18
- package/dist/cjs/utils/derived-objects.js +1 -8
- package/dist/cjs/utils/dynamic-fields.js +1 -17
- package/dist/cjs/utils/format.js +1 -11
- package/dist/cjs/utils/index.js +1 -8
- package/dist/cjs/utils/move-registry.js +1 -24
- package/dist/cjs/utils/sui-types.js +1 -66
- package/dist/cjs/utils/suins.js +1 -33
- package/dist/cjs/verify/index.js +1 -1
- package/dist/cjs/verify/verify.js +1 -87
- package/dist/cjs/version.js +1 -2
- package/dist/cjs/w/call/allocation.js +1 -345
- package/dist/cjs/w/call/arb.js +1 -103
- package/dist/cjs/w/call/arbitration.js +1 -1192
- package/dist/cjs/w/call/base.js +1 -293
- package/dist/cjs/w/call/contact.js +1 -345
- package/dist/cjs/w/call/demand.js +1 -681
- package/dist/cjs/w/call/entity.js +1 -173
- package/dist/cjs/w/call/guard-ins.js +1 -4449
- package/dist/cjs/w/call/guard.d.ts +111 -0
- package/dist/cjs/w/call/guard.js +1 -1048
- package/dist/cjs/w/call/index.js +1 -22
- package/dist/cjs/w/call/machine.js +1 -1127
- package/dist/cjs/w/call/order.js +1 -337
- package/dist/cjs/w/call/passport.js +1 -220
- package/dist/cjs/w/call/payment.js +1 -178
- package/dist/cjs/w/call/permission.js +1 -1162
- package/dist/cjs/w/call/personal.js +1 -139
- package/dist/cjs/w/call/progress.js +1 -678
- package/dist/cjs/w/call/proof.js +1 -66
- package/dist/cjs/w/call/repository.js +1 -1024
- package/dist/cjs/w/call/resource.js +1 -108
- package/dist/cjs/w/call/reward.js +1 -675
- package/dist/cjs/w/call/service.js +1 -1960
- package/dist/cjs/w/call/treasury.js +1 -873
- package/dist/cjs/w/call/util.d.ts +1 -0
- package/dist/cjs/w/call/util.js +1 -566
- package/dist/cjs/w/common.js +1 -571
- package/dist/cjs/w/exception.js +1 -618
- package/dist/cjs/w/index.js +1 -8
- package/dist/cjs/w/local/account.js +1 -656
- package/dist/cjs/w/local/cache.js +1 -161
- package/dist/cjs/w/local/config.js +1 -43
- package/dist/cjs/w/local/index.js +1 -228
- package/dist/cjs/w/local/local.js +1 -574
- package/dist/cjs/w/local/storage.js +1 -185
- package/dist/cjs/w/local/token.js +1 -131
- package/dist/cjs/w/local/util.js +1 -26
- package/dist/cjs/w/local/wip.js +1 -864
- package/dist/cjs/w/messenger/crypto.js +1 -380
- package/dist/cjs/w/messenger/index.js +1 -4
- package/dist/cjs/w/messenger/messenger-api.js +1 -1154
- package/dist/cjs/w/messenger/messenger-manager.js +1 -1003
- package/dist/cjs/w/messenger/messenger.js +1 -1093
- package/dist/cjs/w/messenger/server.js +1 -343
- package/dist/cjs/w/messenger/session.js +1 -628
- package/dist/cjs/w/messenger/storage.js +1 -1023
- package/dist/cjs/w/messenger/templates/wts-html-template.js +1 -371
- package/dist/cjs/w/messenger/types.js +1 -76
- package/dist/cjs/w/messenger/utils.js +1 -12
- package/dist/cjs/w/query/bult-in.js +1 -95
- package/dist/cjs/w/query/event.js +1 -137
- package/dist/cjs/w/query/index.js +1 -5
- package/dist/cjs/w/query/object.js +1 -1550
- package/dist/cjs/w/query/received.js +1 -62
- package/dist/cjs/w/query/util.js +1 -49
- package/dist/cjs/w/util.js +1 -587
- package/dist/esm/bcs/bcs.js +1 -253
- package/dist/esm/bcs/effects.js +1 -199
- package/dist/esm/bcs/index.js +1 -51
- package/dist/esm/bcs/pure.js +1 -36
- package/dist/esm/bcs/type-tag-serializer.js +1 -104
- package/dist/esm/bcs/types.js +1 -3
- package/dist/esm/client/index.js +1 -4
- package/dist/esm/client/network.js +1 -15
- package/dist/esm/cryptography/index.js +1 -6
- package/dist/esm/cryptography/intent.js +1 -14
- package/dist/esm/cryptography/keypair.js +1 -74
- package/dist/esm/cryptography/mnemonics.js +1 -20
- package/dist/esm/cryptography/publickey.js +1 -80
- package/dist/esm/cryptography/signature-scheme.js +1 -22
- package/dist/esm/cryptography/signature.js +1 -41
- package/dist/esm/experimental/cache.js +1 -58
- package/dist/esm/experimental/client.js +1 -19
- package/dist/esm/experimental/core.js +1 -80
- package/dist/esm/experimental/errors.js +1 -24
- package/dist/esm/experimental/index.js +1 -5
- package/dist/esm/experimental/persistent-storage.js +1 -220
- package/dist/esm/experimental/persistent-storage.test.js +1 -144
- package/dist/esm/experimental/transports/utils.js +1 -96
- package/dist/esm/experimental/types.js +1 -1
- package/dist/esm/faucet/faucet.js +1 -99
- package/dist/esm/faucet/index.js +1 -1
- package/dist/esm/grpc/client.js +1 -42
- package/dist/esm/grpc/core.js +1 -587
- package/dist/esm/grpc/index.js +1 -2
- package/dist/esm/grpc/proto/google/protobuf/any.js +1 -106
- package/dist/esm/grpc/proto/google/protobuf/duration.js +1 -58
- package/dist/esm/grpc/proto/google/protobuf/empty.js +1 -7
- package/dist/esm/grpc/proto/google/protobuf/field_mask.js +1 -47
- package/dist/esm/grpc/proto/google/protobuf/struct.js +1 -191
- package/dist/esm/grpc/proto/google/protobuf/timestamp.js +1 -91
- package/dist/esm/grpc/proto/google/rpc/error_details.js +1 -265
- package/dist/esm/grpc/proto/google/rpc/status.js +1 -23
- package/dist/esm/grpc/proto/sui/rpc/v2/argument.js +1 -46
- package/dist/esm/grpc/proto/sui/rpc/v2/balance_change.js +1 -29
- package/dist/esm/grpc/proto/sui/rpc/v2/bcs.js +1 -22
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint.js +1 -54
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_contents.js +1 -60
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_summary.js +1 -144
- package/dist/esm/grpc/proto/sui/rpc/v2/effects.js +1 -271
- package/dist/esm/grpc/proto/sui/rpc/v2/epoch.js +1 -64
- package/dist/esm/grpc/proto/sui/rpc/v2/error_reason.js +1 -6
- package/dist/esm/grpc/proto/sui/rpc/v2/event.js +1 -62
- package/dist/esm/grpc/proto/sui/rpc/v2/executed_transaction.js +1 -64
- package/dist/esm/grpc/proto/sui/rpc/v2/execution_status.js +1 -481
- package/dist/esm/grpc/proto/sui/rpc/v2/gas_cost_summary.js +1 -40
- package/dist/esm/grpc/proto/sui/rpc/v2/input.js +1 -61
- package/dist/esm/grpc/proto/sui/rpc/v2/jwk.js +1 -57
- package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.client.js +1 -39
- package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.js +1 -329
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package.js +1 -447
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.client.js +1 -27
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.js +1 -206
- package/dist/esm/grpc/proto/sui/rpc/v2/name_service.client.js +1 -19
- package/dist/esm/grpc/proto/sui/rpc/v2/name_service.js +1 -109
- package/dist/esm/grpc/proto/sui/rpc/v2/object.js +1 -90
- package/dist/esm/grpc/proto/sui/rpc/v2/object_reference.js +1 -30
- package/dist/esm/grpc/proto/sui/rpc/v2/owner.js +1 -39
- package/dist/esm/grpc/proto/sui/rpc/v2/protocol_config.js +1 -30
- package/dist/esm/grpc/proto/sui/rpc/v2/signature.js +1 -501
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_scheme.js +1 -10
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.client.js +1 -15
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.js +1 -62
- package/dist/esm/grpc/proto/sui/rpc/v2/state_service.client.js +1 -31
- package/dist/esm/grpc/proto/sui/rpc/v2/state_service.js +1 -504
- package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.client.js +1 -15
- package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.js +1 -37
- package/dist/esm/grpc/proto/sui/rpc/v2/system_state.js +1 -709
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction.js +1 -950
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.client.js +1 -19
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.js +1 -144
- package/dist/esm/index.js +1 -22
- package/dist/esm/jsonRpc/client.js +1 -516
- package/dist/esm/jsonRpc/core.js +1 -587
- package/dist/esm/jsonRpc/errors.js +1 -38
- package/dist/esm/jsonRpc/http-transport.js +1 -70
- package/dist/esm/jsonRpc/index.js +1 -3
- package/dist/esm/jsonRpc/json-rpc-resolver.js +1 -296
- package/dist/esm/jsonRpc/rpc-websocket-client.js +1 -155
- package/dist/esm/jsonRpc/types/chain.js +1 -1
- package/dist/esm/jsonRpc/types/changes.js +1 -1
- package/dist/esm/jsonRpc/types/coins.js +1 -1
- package/dist/esm/jsonRpc/types/common.js +1 -1
- package/dist/esm/jsonRpc/types/generated.js +1 -1
- package/dist/esm/jsonRpc/types/index.js +1 -1
- package/dist/esm/jsonRpc/types/params.js +1 -1
- package/dist/esm/keypairs/ed25519/ed25519-hd-key.js +1 -58
- package/dist/esm/keypairs/ed25519/index.js +1 -2
- package/dist/esm/keypairs/ed25519/keypair.js +1 -90
- package/dist/esm/keypairs/ed25519/publickey.js +1 -50
- package/dist/esm/keypairs/index.js +1 -4
- package/dist/esm/keypairs/passkey/index.js +1 -2
- package/dist/esm/keypairs/passkey/keypair.js +1 -155
- package/dist/esm/keypairs/passkey/publickey.js +1 -117
- package/dist/esm/keypairs/passkey/types.js +1 -1
- package/dist/esm/keypairs/secp256k1/index.js +1 -2
- package/dist/esm/keypairs/secp256k1/keypair.js +1 -82
- package/dist/esm/keypairs/secp256k1/publickey.js +1 -51
- package/dist/esm/keypairs/secp256r1/index.js +1 -2
- package/dist/esm/keypairs/secp256r1/keypair.js +1 -78
- package/dist/esm/keypairs/secp256r1/publickey.js +1 -52
- package/dist/esm/multisig/index.js +1 -2
- package/dist/esm/multisig/publickey.js +1 -201
- package/dist/esm/multisig/signer.js +1 -58
- package/dist/esm/transactions/Arguments.js +1 -9
- package/dist/esm/transactions/Commands.js +1 -102
- package/dist/esm/transactions/Inputs.js +1 -52
- package/dist/esm/transactions/ObjectCache.js +1 -205
- package/dist/esm/transactions/Transaction.js +1 -574
- package/dist/esm/transactions/TransactionData.js +1 -409
- package/dist/esm/transactions/__tests__/Transaction.test.js +1 -160
- package/dist/esm/transactions/__tests__/bcs.test.js +1 -182
- package/dist/esm/transactions/data/internal.js +1 -169
- package/dist/esm/transactions/data/v1.js +1 -469
- package/dist/esm/transactions/data/v2.js +1 -97
- package/dist/esm/transactions/executor/caching.js +1 -65
- package/dist/esm/transactions/executor/parallel.js +1 -347
- package/dist/esm/transactions/executor/queue.js +1 -59
- package/dist/esm/transactions/executor/serial.js +1 -99
- package/dist/esm/transactions/hash.js +1 -8
- package/dist/esm/transactions/index.js +1 -12
- package/dist/esm/transactions/intents/CoinWithBalance.js +1 -145
- package/dist/esm/transactions/object.js +1 -87
- package/dist/esm/transactions/plugins/NamedPackagesPlugin.js +1 -11
- package/dist/esm/transactions/pure.js +1 -36
- package/dist/esm/transactions/resolve.js +1 -69
- package/dist/esm/transactions/serializer.js +1 -167
- package/dist/esm/transactions/utils.js +1 -121
- package/dist/esm/utils/constants.js +1 -18
- package/dist/esm/utils/derived-objects.js +1 -8
- package/dist/esm/utils/dynamic-fields.js +1 -17
- package/dist/esm/utils/format.js +1 -11
- package/dist/esm/utils/index.js +1 -8
- package/dist/esm/utils/move-registry.js +1 -24
- package/dist/esm/utils/sui-types.js +1 -66
- package/dist/esm/utils/suins.js +1 -33
- package/dist/esm/verify/index.js +1 -1
- package/dist/esm/verify/verify.js +1 -87
- package/dist/esm/version.js +1 -2
- package/dist/esm/w/call/allocation.js +1 -345
- package/dist/esm/w/call/arb.js +1 -103
- package/dist/esm/w/call/arbitration.js +1 -1192
- package/dist/esm/w/call/base.js +1 -293
- package/dist/esm/w/call/contact.js +1 -345
- package/dist/esm/w/call/demand.js +1 -681
- package/dist/esm/w/call/entity.js +1 -173
- package/dist/esm/w/call/guard-ins.js +1 -4449
- package/dist/esm/w/call/guard.d.ts +111 -0
- package/dist/esm/w/call/guard.js +1 -1048
- package/dist/esm/w/call/index.js +1 -22
- package/dist/esm/w/call/machine.js +1 -1127
- package/dist/esm/w/call/order.js +1 -337
- package/dist/esm/w/call/passport.js +1 -220
- package/dist/esm/w/call/payment.js +1 -178
- package/dist/esm/w/call/permission.js +1 -1162
- package/dist/esm/w/call/personal.js +1 -139
- package/dist/esm/w/call/progress.js +1 -678
- package/dist/esm/w/call/proof.js +1 -66
- package/dist/esm/w/call/repository.js +1 -1024
- package/dist/esm/w/call/resource.js +1 -108
- package/dist/esm/w/call/reward.js +1 -675
- package/dist/esm/w/call/service.js +1 -1960
- package/dist/esm/w/call/treasury.js +1 -873
- package/dist/esm/w/call/util.d.ts +1 -0
- package/dist/esm/w/call/util.js +1 -566
- package/dist/esm/w/common.js +1 -571
- package/dist/esm/w/exception.js +1 -618
- package/dist/esm/w/index.js +1 -8
- package/dist/esm/w/local/account.js +1 -656
- package/dist/esm/w/local/cache.js +1 -161
- package/dist/esm/w/local/config.js +1 -43
- package/dist/esm/w/local/index.js +1 -228
- package/dist/esm/w/local/local.js +1 -574
- package/dist/esm/w/local/storage.js +1 -185
- package/dist/esm/w/local/token.js +1 -131
- package/dist/esm/w/local/util.js +1 -26
- package/dist/esm/w/local/wip.js +1 -864
- package/dist/esm/w/messenger/crypto.js +1 -380
- package/dist/esm/w/messenger/index.js +1 -4
- package/dist/esm/w/messenger/messenger-api.js +1 -1154
- package/dist/esm/w/messenger/messenger-manager.js +1 -1003
- package/dist/esm/w/messenger/messenger.js +1 -1093
- package/dist/esm/w/messenger/server.js +1 -343
- package/dist/esm/w/messenger/session.js +1 -628
- package/dist/esm/w/messenger/storage.js +1 -1023
- package/dist/esm/w/messenger/templates/wts-html-template.js +1 -371
- package/dist/esm/w/messenger/types.js +1 -76
- package/dist/esm/w/messenger/utils.js +1 -12
- package/dist/esm/w/query/bult-in.js +1 -95
- package/dist/esm/w/query/event.js +1 -137
- package/dist/esm/w/query/index.js +1 -5
- package/dist/esm/w/query/object.js +1 -1550
- package/dist/esm/w/query/received.js +1 -62
- package/dist/esm/w/query/util.js +1 -49
- package/dist/esm/w/util.js +1 -587
- package/package.json +5 -2
|
@@ -1,70 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { JsonRpcError, SuiHTTPStatusError } from "./errors.js";
|
|
3
|
-
import { WebsocketClient } from "./rpc-websocket-client.js";
|
|
4
|
-
export class JsonRpcHTTPTransport {
|
|
5
|
-
#requestId = 0;
|
|
6
|
-
#options;
|
|
7
|
-
#websocketClient;
|
|
8
|
-
constructor(options) {
|
|
9
|
-
this.#options = options;
|
|
10
|
-
}
|
|
11
|
-
fetch(input, init) {
|
|
12
|
-
const fetchFn = this.#options.fetch ?? fetch;
|
|
13
|
-
if (!fetchFn) {
|
|
14
|
-
throw new Error("The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.");
|
|
15
|
-
}
|
|
16
|
-
return fetchFn(input, init);
|
|
17
|
-
}
|
|
18
|
-
#getWebsocketClient() {
|
|
19
|
-
if (!this.#websocketClient) {
|
|
20
|
-
const WebSocketConstructor = this.#options.WebSocketConstructor ?? WebSocket;
|
|
21
|
-
if (!WebSocketConstructor) {
|
|
22
|
-
throw new Error("The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.");
|
|
23
|
-
}
|
|
24
|
-
this.#websocketClient = new WebsocketClient(this.#options.websocket?.url ?? this.#options.url, {
|
|
25
|
-
WebSocketConstructor,
|
|
26
|
-
...this.#options.websocket,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
return this.#websocketClient;
|
|
30
|
-
}
|
|
31
|
-
async request(input) {
|
|
32
|
-
this.#requestId += 1;
|
|
33
|
-
const res = await this.fetch(this.#options.rpc?.url ?? this.#options.url, {
|
|
34
|
-
method: "POST",
|
|
35
|
-
signal: input.signal,
|
|
36
|
-
headers: {
|
|
37
|
-
"Content-Type": "application/json",
|
|
38
|
-
"Client-Sdk-Type": "typescript",
|
|
39
|
-
"Client-Sdk-Version": PACKAGE_VERSION,
|
|
40
|
-
"Client-Target-Api-Version": TARGETED_RPC_VERSION,
|
|
41
|
-
"Client-Request-Method": input.method,
|
|
42
|
-
...this.#options.rpc?.headers,
|
|
43
|
-
},
|
|
44
|
-
body: JSON.stringify({
|
|
45
|
-
jsonrpc: "2.0",
|
|
46
|
-
id: this.#requestId,
|
|
47
|
-
method: input.method,
|
|
48
|
-
params: input.params,
|
|
49
|
-
}),
|
|
50
|
-
});
|
|
51
|
-
if (!res.ok) {
|
|
52
|
-
throw new SuiHTTPStatusError(`Unexpected status code: ${res.status}`, res.status, res.statusText);
|
|
53
|
-
}
|
|
54
|
-
const data = (await res.json());
|
|
55
|
-
if ("error" in data && data.error != null) {
|
|
56
|
-
throw new JsonRpcError(data.error.message, data.error.code);
|
|
57
|
-
}
|
|
58
|
-
return data.result;
|
|
59
|
-
}
|
|
60
|
-
async subscribe(input) {
|
|
61
|
-
const unsubscribe = await this.#getWebsocketClient().subscribe(input);
|
|
62
|
-
if (input.signal) {
|
|
63
|
-
input.signal.throwIfAborted();
|
|
64
|
-
input.signal.addEventListener("abort", () => {
|
|
65
|
-
unsubscribe();
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
return async () => !!(await unsubscribe());
|
|
69
|
-
}
|
|
70
|
-
}
|
|
1
|
+
import{PACKAGE_VERSION,TARGETED_RPC_VERSION}from'../version.js';import{JsonRpcError,SuiHTTPStatusError}from'./errors.js';import{WebsocketClient}from'./rpc-websocket-client.js';export class JsonRpcHTTPTransport{#requestId=0x0;#options;#websocketClient;constructor(a){this.#options=a;}['fetch'](a,b){const c=this.#options['fetch']??fetch;if(!c)throw new Error('The\x20current\x20environment\x20does\x20not\x20support\x20fetch,\x20you\x20can\x20provide\x20a\x20fetch\x20implementation\x20in\x20the\x20options\x20for\x20SuiHTTPTransport.');return c(a,b);}#getWebsocketClient(){if(!this.#websocketClient){const a=this.#options['WebSocketConstructor']??WebSocket;if(!a)throw new Error('The\x20current\x20environment\x20does\x20not\x20support\x20WebSocket,\x20you\x20can\x20provide\x20a\x20WebSocketConstructor\x20in\x20the\x20options\x20for\x20SuiHTTPTransport.');this.#websocketClient=new WebsocketClient(this.#options['websocket']?.['url']??this.#options['url'],{'WebSocketConstructor':a,...this.#options['websocket']});}return this.#websocketClient;}async['request'](a){this.#requestId+=0x1;const b=await this['fetch'](this.#options['rpc']?.['url']??this.#options['url'],{'method':'POST','signal':a['signal'],'headers':{'Content-Type':'application/json','Client-Sdk-Type':'typescript','Client-Sdk-Version':PACKAGE_VERSION,'Client-Target-Api-Version':TARGETED_RPC_VERSION,'Client-Request-Method':a['method'],...this.#options['rpc']?.['headers']},'body':JSON['stringify']({'jsonrpc':'2.0','id':this.#requestId,'method':a['method'],'params':a['params']})});if(!b['ok'])throw new SuiHTTPStatusError('Unexpected\x20status\x20code:\x20'+b['status'],b['status'],b['statusText']);const c=await b['json']();if('error'in c&&c['error']!=null)throw new JsonRpcError(c['error']['message'],c['error']['code']);return c['result'];}async['subscribe'](a){const b=await this.#getWebsocketClient()['subscribe'](a);return a['signal']&&(a['signal']['throwIfAborted'](),a['signal']['addEventListener']('abort',()=>{b();})),async()=>!!await b();}}
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { isSuiJsonRpcClient, SuiJsonRpcClient, } from "./client.js";
|
|
3
|
-
export { SuiHTTPStatusError, SuiHTTPTransportError, JsonRpcError, } from "./errors.js";
|
|
1
|
+
export{JsonRpcHTTPTransport}from'./http-transport.js';export{isSuiJsonRpcClient,SuiJsonRpcClient}from'./client.js';export{SuiHTTPStatusError,SuiHTTPTransportError,JsonRpcError}from'./errors.js';
|
|
@@ -1,296 +1 @@
|
|
|
1
|
-
import { parse } from
|
|
2
|
-
import { normalizeWowAddress, normalizeWowObjectId, WOW_TYPE_ARG, } from "../utils/index.js";
|
|
3
|
-
import { ObjectRefSchema } from "../transactions/data/internal.js";
|
|
4
|
-
import { Inputs } from "../transactions/Inputs.js";
|
|
5
|
-
import { getPureBcsSchema, isTxContext, normalizedTypeToMoveTypeSignature, } from "../transactions/serializer.js";
|
|
6
|
-
import { chunk } from "@mysten/utils";
|
|
7
|
-
const MAX_OBJECTS_PER_FETCH = 50;
|
|
8
|
-
const GAS_SAFE_OVERHEAD = 1000n;
|
|
9
|
-
const MAX_GAS = 50_000_000_000;
|
|
10
|
-
export function jsonRpcClientResolveTransactionPlugin(client) {
|
|
11
|
-
return async function resolveTransactionData(transactionData, options, next) {
|
|
12
|
-
await normalizeInputs(transactionData, client);
|
|
13
|
-
await resolveObjectReferences(transactionData, client);
|
|
14
|
-
if (!options.onlyTransactionKind) {
|
|
15
|
-
await setGasPrice(transactionData, client);
|
|
16
|
-
await setGasBudget(transactionData, client);
|
|
17
|
-
await setGasPayment(transactionData, client);
|
|
18
|
-
}
|
|
19
|
-
return await next();
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
async function setGasPrice(transactionData, client) {
|
|
23
|
-
if (!transactionData.gasConfig.price) {
|
|
24
|
-
transactionData.gasConfig.price = String(await client.getReferenceGasPrice());
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
async function setGasBudget(transactionData, client) {
|
|
28
|
-
if (transactionData.gasConfig.budget) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
const dryRunResult = await client.dryRunTransactionBlock({
|
|
32
|
-
transactionBlock: transactionData.build({
|
|
33
|
-
overrides: {
|
|
34
|
-
gasData: {
|
|
35
|
-
budget: String(MAX_GAS),
|
|
36
|
-
payment: [],
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
}),
|
|
40
|
-
});
|
|
41
|
-
if (dryRunResult.effects.status.status !== "success") {
|
|
42
|
-
const error = new Error(`Dry run failed, could not automatically determine a budget: ${dryRunResult.effects.status.error}`);
|
|
43
|
-
error.cause = dryRunResult;
|
|
44
|
-
throw error;
|
|
45
|
-
}
|
|
46
|
-
const safeOverhead = GAS_SAFE_OVERHEAD * BigInt(transactionData.gasConfig.price || 1n);
|
|
47
|
-
const baseComputationCostWithOverhead = BigInt(dryRunResult.effects.gasUsed.computationCost) + safeOverhead;
|
|
48
|
-
const gasBudget = baseComputationCostWithOverhead +
|
|
49
|
-
BigInt(dryRunResult.effects.gasUsed.storageCost) -
|
|
50
|
-
BigInt(dryRunResult.effects.gasUsed.storageRebate);
|
|
51
|
-
transactionData.gasConfig.budget = String(gasBudget > baseComputationCostWithOverhead
|
|
52
|
-
? gasBudget
|
|
53
|
-
: baseComputationCostWithOverhead);
|
|
54
|
-
}
|
|
55
|
-
async function setGasPayment(transactionData, client) {
|
|
56
|
-
if (!transactionData.gasConfig.payment) {
|
|
57
|
-
const coins = await client.getCoins({
|
|
58
|
-
owner: transactionData.gasConfig.owner || transactionData.sender,
|
|
59
|
-
coinType: WOW_TYPE_ARG,
|
|
60
|
-
});
|
|
61
|
-
const paymentCoins = coins.data
|
|
62
|
-
.filter((coin) => {
|
|
63
|
-
const matchingInput = transactionData.inputs.find((input) => {
|
|
64
|
-
if (input.Object?.ImmOrOwnedObject) {
|
|
65
|
-
return (coin.coinObjectId ===
|
|
66
|
-
input.Object.ImmOrOwnedObject.objectId);
|
|
67
|
-
}
|
|
68
|
-
return false;
|
|
69
|
-
});
|
|
70
|
-
return !matchingInput;
|
|
71
|
-
})
|
|
72
|
-
.map((coin) => ({
|
|
73
|
-
objectId: coin.coinObjectId,
|
|
74
|
-
digest: coin.digest,
|
|
75
|
-
version: coin.version,
|
|
76
|
-
}));
|
|
77
|
-
if (!paymentCoins.length) {
|
|
78
|
-
throw new Error("No valid gas coins found for the transaction.");
|
|
79
|
-
}
|
|
80
|
-
transactionData.gasConfig.payment = paymentCoins.map((payment) => parse(ObjectRefSchema, payment));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
async function resolveObjectReferences(transactionData, client) {
|
|
84
|
-
const objectsToResolve = transactionData.inputs.filter((input) => {
|
|
85
|
-
return (input.UnresolvedObject &&
|
|
86
|
-
!(input.UnresolvedObject.version ||
|
|
87
|
-
input.UnresolvedObject?.initialSharedVersion));
|
|
88
|
-
});
|
|
89
|
-
const dedupedIds = [
|
|
90
|
-
...new Set(objectsToResolve.map((input) => normalizeWowObjectId(input.UnresolvedObject.objectId))),
|
|
91
|
-
];
|
|
92
|
-
const objectChunks = dedupedIds.length
|
|
93
|
-
? chunk(dedupedIds, MAX_OBJECTS_PER_FETCH)
|
|
94
|
-
: [];
|
|
95
|
-
const resolved = (await Promise.all(objectChunks.map((chunk) => client.multiGetObjects({
|
|
96
|
-
ids: chunk,
|
|
97
|
-
options: { showOwner: true },
|
|
98
|
-
})))).flat();
|
|
99
|
-
const responsesById = new Map(dedupedIds.map((id, index) => {
|
|
100
|
-
return [id, resolved[index]];
|
|
101
|
-
}));
|
|
102
|
-
const invalidObjects = Array.from(responsesById)
|
|
103
|
-
.filter(([_, obj]) => obj.error)
|
|
104
|
-
.map(([_, obj]) => JSON.stringify(obj.error));
|
|
105
|
-
if (invalidObjects.length) {
|
|
106
|
-
throw new Error(`The following input objects are invalid: ${invalidObjects.join(", ")}`);
|
|
107
|
-
}
|
|
108
|
-
const objects = resolved.map((object) => {
|
|
109
|
-
if (object.error || !object.data) {
|
|
110
|
-
throw new Error(`Failed to fetch object: ${object.error}`);
|
|
111
|
-
}
|
|
112
|
-
const owner = object.data.owner;
|
|
113
|
-
const initialSharedVersion = owner && typeof owner === "object"
|
|
114
|
-
? "Shared" in owner
|
|
115
|
-
? owner.Shared.initial_shared_version
|
|
116
|
-
: "ConsensusAddressOwner" in owner
|
|
117
|
-
? owner.ConsensusAddressOwner.start_version
|
|
118
|
-
: null
|
|
119
|
-
: null;
|
|
120
|
-
return {
|
|
121
|
-
objectId: object.data.objectId,
|
|
122
|
-
digest: object.data.digest,
|
|
123
|
-
version: object.data.version,
|
|
124
|
-
initialSharedVersion,
|
|
125
|
-
};
|
|
126
|
-
});
|
|
127
|
-
const objectsById = new Map(dedupedIds.map((id, index) => {
|
|
128
|
-
return [id, objects[index]];
|
|
129
|
-
}));
|
|
130
|
-
for (const [index, input] of transactionData.inputs.entries()) {
|
|
131
|
-
if (!input.UnresolvedObject) {
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
let updated;
|
|
135
|
-
const id = normalizeWowAddress(input.UnresolvedObject.objectId);
|
|
136
|
-
const object = objectsById.get(id);
|
|
137
|
-
if (input.UnresolvedObject.initialSharedVersion ??
|
|
138
|
-
object?.initialSharedVersion) {
|
|
139
|
-
updated = Inputs.SharedObjectRef({
|
|
140
|
-
objectId: id,
|
|
141
|
-
initialSharedVersion: input.UnresolvedObject.initialSharedVersion ||
|
|
142
|
-
object?.initialSharedVersion,
|
|
143
|
-
mutable: input.UnresolvedObject.mutable ||
|
|
144
|
-
isUsedAsMutable(transactionData, index),
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
else if (isUsedAsReceiving(transactionData, index)) {
|
|
148
|
-
updated = Inputs.ReceivingRef({
|
|
149
|
-
objectId: id,
|
|
150
|
-
digest: input.UnresolvedObject.digest ?? object?.digest,
|
|
151
|
-
version: input.UnresolvedObject.version ?? object?.version,
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
transactionData.inputs[transactionData.inputs.indexOf(input)] =
|
|
155
|
-
updated ??
|
|
156
|
-
Inputs.ObjectRef({
|
|
157
|
-
objectId: id,
|
|
158
|
-
digest: input.UnresolvedObject.digest ?? object?.digest,
|
|
159
|
-
version: input.UnresolvedObject.version ?? object?.version,
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
async function normalizeInputs(transactionData, client) {
|
|
164
|
-
const { inputs, commands } = transactionData;
|
|
165
|
-
const moveCallsToResolve = [];
|
|
166
|
-
const moveFunctionsToResolve = new Set();
|
|
167
|
-
commands.forEach((command) => {
|
|
168
|
-
if (command.MoveCall) {
|
|
169
|
-
if (command.MoveCall._argumentTypes) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
const inputs = command.MoveCall.arguments.map((arg) => {
|
|
173
|
-
if (arg.$kind === "Input") {
|
|
174
|
-
return transactionData.inputs[arg.Input];
|
|
175
|
-
}
|
|
176
|
-
return null;
|
|
177
|
-
});
|
|
178
|
-
const needsResolution = inputs.some((input) => input?.UnresolvedPure ||
|
|
179
|
-
(input?.UnresolvedObject &&
|
|
180
|
-
typeof input?.UnresolvedObject.mutable !== "boolean"));
|
|
181
|
-
if (needsResolution) {
|
|
182
|
-
const functionName = `${command.MoveCall.package}::${command.MoveCall.module}::${command.MoveCall.function}`;
|
|
183
|
-
moveFunctionsToResolve.add(functionName);
|
|
184
|
-
moveCallsToResolve.push(command.MoveCall);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
const moveFunctionParameters = new Map();
|
|
189
|
-
if (moveFunctionsToResolve.size > 0) {
|
|
190
|
-
await Promise.all([...moveFunctionsToResolve].map(async (functionName) => {
|
|
191
|
-
const [packageId, moduleId, functionId] = functionName.split("::");
|
|
192
|
-
const def = await client.getNormalizedMoveFunction({
|
|
193
|
-
package: packageId,
|
|
194
|
-
module: moduleId,
|
|
195
|
-
function: functionId,
|
|
196
|
-
});
|
|
197
|
-
moveFunctionParameters.set(functionName, def.parameters.map((param) => normalizedTypeToMoveTypeSignature(param)));
|
|
198
|
-
}));
|
|
199
|
-
}
|
|
200
|
-
if (moveCallsToResolve.length) {
|
|
201
|
-
await Promise.all(moveCallsToResolve.map(async (moveCall) => {
|
|
202
|
-
const parameters = moveFunctionParameters.get(`${moveCall.package}::${moveCall.module}::${moveCall.function}`);
|
|
203
|
-
if (!parameters) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
const hasTxContext = parameters.length > 0 &&
|
|
207
|
-
isTxContext(parameters[parameters.length - 1]);
|
|
208
|
-
const params = hasTxContext
|
|
209
|
-
? parameters.slice(0, parameters.length - 1)
|
|
210
|
-
: parameters;
|
|
211
|
-
moveCall._argumentTypes = params;
|
|
212
|
-
}));
|
|
213
|
-
}
|
|
214
|
-
commands.forEach((command) => {
|
|
215
|
-
if (!command.MoveCall) {
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
const moveCall = command.MoveCall;
|
|
219
|
-
const fnName = `${moveCall.package}::${moveCall.module}::${moveCall.function}`;
|
|
220
|
-
const params = moveCall._argumentTypes;
|
|
221
|
-
if (!params) {
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
if (params.length !== command.MoveCall.arguments.length) {
|
|
225
|
-
throw new Error(`Incorrect number of arguments for ${fnName}`);
|
|
226
|
-
}
|
|
227
|
-
params.forEach((param, i) => {
|
|
228
|
-
const arg = moveCall.arguments[i];
|
|
229
|
-
if (arg.$kind !== "Input")
|
|
230
|
-
return;
|
|
231
|
-
const input = inputs[arg.Input];
|
|
232
|
-
if (!input.UnresolvedPure && !input.UnresolvedObject) {
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
const inputValue = input.UnresolvedPure?.value ??
|
|
236
|
-
input.UnresolvedObject?.objectId;
|
|
237
|
-
const schema = getPureBcsSchema(param.body);
|
|
238
|
-
if (schema) {
|
|
239
|
-
arg.type = "pure";
|
|
240
|
-
inputs[inputs.indexOf(input)] = Inputs.Pure(schema.serialize(inputValue));
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
if (typeof inputValue !== "string") {
|
|
244
|
-
throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(inputValue, null, 2)}`);
|
|
245
|
-
}
|
|
246
|
-
arg.type = "object";
|
|
247
|
-
const unresolvedObject = input.UnresolvedPure
|
|
248
|
-
? {
|
|
249
|
-
$kind: "UnresolvedObject",
|
|
250
|
-
UnresolvedObject: {
|
|
251
|
-
objectId: inputValue,
|
|
252
|
-
},
|
|
253
|
-
}
|
|
254
|
-
: input;
|
|
255
|
-
inputs[arg.Input] = unresolvedObject;
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
function isUsedAsMutable(transactionData, index) {
|
|
260
|
-
let usedAsMutable = false;
|
|
261
|
-
transactionData.getInputUses(index, (arg, tx) => {
|
|
262
|
-
if (tx.MoveCall && tx.MoveCall._argumentTypes) {
|
|
263
|
-
const argIndex = tx.MoveCall.arguments.indexOf(arg);
|
|
264
|
-
usedAsMutable =
|
|
265
|
-
tx.MoveCall._argumentTypes[argIndex].ref !== "&" ||
|
|
266
|
-
usedAsMutable;
|
|
267
|
-
}
|
|
268
|
-
if (tx.$kind === "MakeMoveVec" ||
|
|
269
|
-
tx.$kind === "MergeCoins" ||
|
|
270
|
-
tx.$kind === "SplitCoins" ||
|
|
271
|
-
tx.$kind === "TransferObjects") {
|
|
272
|
-
usedAsMutable = true;
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
return usedAsMutable;
|
|
276
|
-
}
|
|
277
|
-
function isUsedAsReceiving(transactionData, index) {
|
|
278
|
-
let usedAsReceiving = false;
|
|
279
|
-
transactionData.getInputUses(index, (arg, tx) => {
|
|
280
|
-
if (tx.MoveCall && tx.MoveCall._argumentTypes) {
|
|
281
|
-
const argIndex = tx.MoveCall.arguments.indexOf(arg);
|
|
282
|
-
usedAsReceiving =
|
|
283
|
-
isReceivingType(tx.MoveCall._argumentTypes[argIndex]) ||
|
|
284
|
-
usedAsReceiving;
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
return usedAsReceiving;
|
|
288
|
-
}
|
|
289
|
-
function isReceivingType(type) {
|
|
290
|
-
if (typeof type.body !== "object" || !("datatype" in type.body)) {
|
|
291
|
-
return false;
|
|
292
|
-
}
|
|
293
|
-
return (type.body.datatype.package === "0x2" &&
|
|
294
|
-
type.body.datatype.module === "transfer" &&
|
|
295
|
-
type.body.datatype.type === "Receiving");
|
|
296
|
-
}
|
|
1
|
+
import{parse}from'valibot';import{normalizeWowAddress,normalizeWowObjectId,WOW_TYPE_ARG}from'../utils/index.js';import{ObjectRefSchema}from'../transactions/data/internal.js';import{Inputs}from'../transactions/Inputs.js';import{getPureBcsSchema,isTxContext,normalizedTypeToMoveTypeSignature}from'../transactions/serializer.js';import{chunk}from'@mysten/utils';const MAX_OBJECTS_PER_FETCH=0x32,GAS_SAFE_OVERHEAD=0x3e8n,MAX_GAS=0xba43b7400;export function jsonRpcClientResolveTransactionPlugin(a){return async function b(c,d,e){return await normalizeInputs(c,a),await resolveObjectReferences(c,a),!d['onlyTransactionKind']&&(await setGasPrice(c,a),await setGasBudget(c,a),await setGasPayment(c,a)),await e();};}async function setGasPrice(a,b){!a['gasConfig']['price']&&(a['gasConfig']['price']=String(await b['getReferenceGasPrice']()));}async function setGasBudget(a,b){if(a['gasConfig']['budget'])return;const c=await b['dryRunTransactionBlock']({'transactionBlock':a['build']({'overrides':{'gasData':{'budget':String(MAX_GAS),'payment':[]}}})});if(c['effects']['status']['status']!=='success'){const g=new Error('Dry\x20run\x20failed,\x20could\x20not\x20automatically\x20determine\x20a\x20budget:\x20'+c['effects']['status']['error']);g['cause']=c;throw g;}const d=GAS_SAFE_OVERHEAD*BigInt(a['gasConfig']['price']||0x1n),e=BigInt(c['effects']['gasUsed']['computationCost'])+d,f=e+BigInt(c['effects']['gasUsed']['storageCost'])-BigInt(c['effects']['gasUsed']['storageRebate']);a['gasConfig']['budget']=String(f>e?f:e);}async function setGasPayment(a,b){if(!a['gasConfig']['payment']){const c=await b['getCoins']({'owner':a['gasConfig']['owner']||a['sender'],'coinType':WOW_TYPE_ARG}),d=c['data']['filter'](e=>{const f=a['inputs']['find'](g=>{if(g['Object']?.['ImmOrOwnedObject'])return e['coinObjectId']===g['Object']['ImmOrOwnedObject']['objectId'];return![];});return!f;})['map'](e=>({'objectId':e['coinObjectId'],'digest':e['digest'],'version':e['version']}));if(!d['length'])throw new Error('No\x20valid\x20gas\x20coins\x20found\x20for\x20the\x20transaction.');a['gasConfig']['payment']=d['map'](e=>parse(ObjectRefSchema,e));}}async function resolveObjectReferences(a,b){const c=a['inputs']['filter'](k=>{return k['UnresolvedObject']&&!(k['UnresolvedObject']['version']||k['UnresolvedObject']?.['initialSharedVersion']);}),d=[...new Set(c['map'](k=>normalizeWowObjectId(k['UnresolvedObject']['objectId'])))],e=d['length']?chunk(d,MAX_OBJECTS_PER_FETCH):[],f=(await Promise['all'](e['map'](k=>b['multiGetObjects']({'ids':k,'options':{'showOwner':!![]}}))))['flat'](),g=new Map(d['map']((k,l)=>{return[k,f[l]];})),h=Array['from'](g)['filter'](([k,l])=>l['error'])['map'](([k,l])=>JSON['stringify'](l['error']));if(h['length'])throw new Error('The\x20following\x20input\x20objects\x20are\x20invalid:\x20'+h['join'](',\x20'));const i=f['map'](k=>{if(k['error']||!k['data'])throw new Error('Failed\x20to\x20fetch\x20object:\x20'+k['error']);const l=k['data']['owner'],m=l&&typeof l==='object'?'Shared'in l?l['Shared']['initial_shared_version']:'ConsensusAddressOwner'in l?l['ConsensusAddressOwner']['start_version']:null:null;return{'objectId':k['data']['objectId'],'digest':k['data']['digest'],'version':k['data']['version'],'initialSharedVersion':m};}),j=new Map(d['map']((k,l)=>{return[k,i[l]];}));for(const [k,l]of a['inputs']['entries']()){if(!l['UnresolvedObject'])continue;let m;const n=normalizeWowAddress(l['UnresolvedObject']['objectId']),o=j['get'](n);if(l['UnresolvedObject']['initialSharedVersion']??o?.['initialSharedVersion'])m=Inputs['SharedObjectRef']({'objectId':n,'initialSharedVersion':l['UnresolvedObject']['initialSharedVersion']||o?.['initialSharedVersion'],'mutable':l['UnresolvedObject']['mutable']||isUsedAsMutable(a,k)});else isUsedAsReceiving(a,k)&&(m=Inputs['ReceivingRef']({'objectId':n,'digest':l['UnresolvedObject']['digest']??o?.['digest'],'version':l['UnresolvedObject']['version']??o?.['version']}));a['inputs'][a['inputs']['indexOf'](l)]=m??Inputs['ObjectRef']({'objectId':n,'digest':l['UnresolvedObject']['digest']??o?.['digest'],'version':l['UnresolvedObject']['version']??o?.['version']});}}async function normalizeInputs(a,b){const {inputs:c,commands:d}=a,e=[],f=new Set();d['forEach'](h=>{if(h['MoveCall']){if(h['MoveCall']['_argumentTypes'])return;const i=h['MoveCall']['arguments']['map'](k=>{if(k['$kind']==='Input')return a['inputs'][k['Input']];return null;}),j=i['some'](k=>k?.['UnresolvedPure']||k?.['UnresolvedObject']&&typeof k?.['UnresolvedObject']['mutable']!=='boolean');if(j){const k=h['MoveCall']['package']+'::'+h['MoveCall']['module']+'::'+h['MoveCall']['function'];f['add'](k),e['push'](h['MoveCall']);}}});const g=new Map();f['size']>0x0&&await Promise['all']([...f]['map'](async h=>{const [i,j,k]=h['split']('::'),l=await b['getNormalizedMoveFunction']({'package':i,'module':j,'function':k});g['set'](h,l['parameters']['map'](m=>normalizedTypeToMoveTypeSignature(m)));})),e['length']&&await Promise['all'](e['map'](async h=>{const i=g['get'](h['package']+'::'+h['module']+'::'+h['function']);if(!i)return;const j=i['length']>0x0&&isTxContext(i[i['length']-0x1]),k=j?i['slice'](0x0,i['length']-0x1):i;h['_argumentTypes']=k;})),d['forEach'](h=>{if(!h['MoveCall'])return;const i=h['MoveCall'],j=i['package']+'::'+i['module']+'::'+i['function'],k=i['_argumentTypes'];if(!k)return;if(k['length']!==h['MoveCall']['arguments']['length'])throw new Error('Incorrect\x20number\x20of\x20arguments\x20for\x20'+j);k['forEach']((l,m)=>{const n=i['arguments'][m];if(n['$kind']!=='Input')return;const o=c[n['Input']];if(!o['UnresolvedPure']&&!o['UnresolvedObject'])return;const p=o['UnresolvedPure']?.['value']??o['UnresolvedObject']?.['objectId'],q=getPureBcsSchema(l['body']);if(q){n['type']='pure',c[c['indexOf'](o)]=Inputs['Pure'](q['serialize'](p));return;}if(typeof p!=='string')throw new Error('Expect\x20the\x20argument\x20to\x20be\x20an\x20object\x20id\x20string,\x20got\x20'+JSON['stringify'](p,null,0x2));n['type']='object';const r=o['UnresolvedPure']?{'$kind':'UnresolvedObject','UnresolvedObject':{'objectId':p}}:o;c[n['Input']]=r;});});}function isUsedAsMutable(a,b){let c=![];return a['getInputUses'](b,(d,e)=>{if(e['MoveCall']&&e['MoveCall']['_argumentTypes']){const f=e['MoveCall']['arguments']['indexOf'](d);c=e['MoveCall']['_argumentTypes'][f]['ref']!=='&'||c;}(e['$kind']==='MakeMoveVec'||e['$kind']==='MergeCoins'||e['$kind']==='SplitCoins'||e['$kind']==='TransferObjects')&&(c=!![]);}),c;}function isUsedAsReceiving(a,b){let c=![];return a['getInputUses'](b,(d,e)=>{if(e['MoveCall']&&e['MoveCall']['_argumentTypes']){const f=e['MoveCall']['arguments']['indexOf'](d);c=isReceivingType(e['MoveCall']['_argumentTypes'][f])||c;}}),c;}function isReceivingType(a){if(typeof a['body']!=='object'||!('datatype'in a['body']))return![];return a['body']['datatype']['package']==='0x2'&&a['body']['datatype']['module']==='transfer'&&a['body']['datatype']['type']==='Receiving';}
|
|
@@ -1,155 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
function getWebsocketUrl(httpUrl) {
|
|
3
|
-
const url = new URL(httpUrl);
|
|
4
|
-
url.protocol = url.protocol.replace("http", "ws");
|
|
5
|
-
return url.toString();
|
|
6
|
-
}
|
|
7
|
-
export const DEFAULT_CLIENT_OPTIONS = {
|
|
8
|
-
WebSocketConstructor: (typeof WebSocket !== "undefined"
|
|
9
|
-
? WebSocket
|
|
10
|
-
: undefined),
|
|
11
|
-
callTimeout: 30000,
|
|
12
|
-
reconnectTimeout: 3000,
|
|
13
|
-
maxReconnects: 5,
|
|
14
|
-
};
|
|
15
|
-
export class WebsocketClient {
|
|
16
|
-
endpoint;
|
|
17
|
-
options;
|
|
18
|
-
#requestId = 0;
|
|
19
|
-
#disconnects = 0;
|
|
20
|
-
#webSocket = null;
|
|
21
|
-
#connectionPromise = null;
|
|
22
|
-
#subscriptions = new Set();
|
|
23
|
-
#pendingRequests = new Map();
|
|
24
|
-
constructor(endpoint, options = {}) {
|
|
25
|
-
this.endpoint = endpoint;
|
|
26
|
-
this.options = { ...DEFAULT_CLIENT_OPTIONS, ...options };
|
|
27
|
-
if (!this.options.WebSocketConstructor) {
|
|
28
|
-
throw new Error("Missing WebSocket constructor");
|
|
29
|
-
}
|
|
30
|
-
if (this.endpoint.startsWith("http")) {
|
|
31
|
-
this.endpoint = getWebsocketUrl(this.endpoint);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
async makeRequest(method, params, signal) {
|
|
35
|
-
const webSocket = await this.#setupWebSocket();
|
|
36
|
-
return new Promise((resolve, reject) => {
|
|
37
|
-
this.#requestId += 1;
|
|
38
|
-
this.#pendingRequests.set(this.#requestId, {
|
|
39
|
-
resolve: resolve,
|
|
40
|
-
reject,
|
|
41
|
-
timeout: setTimeout(() => {
|
|
42
|
-
this.#pendingRequests.delete(this.#requestId);
|
|
43
|
-
reject(new Error(`Request timeout: ${method}`));
|
|
44
|
-
}, this.options.callTimeout),
|
|
45
|
-
});
|
|
46
|
-
signal?.addEventListener("abort", () => {
|
|
47
|
-
this.#pendingRequests.delete(this.#requestId);
|
|
48
|
-
reject(signal.reason);
|
|
49
|
-
});
|
|
50
|
-
webSocket.send(JSON.stringify({
|
|
51
|
-
jsonrpc: "2.0",
|
|
52
|
-
id: this.#requestId,
|
|
53
|
-
method,
|
|
54
|
-
params,
|
|
55
|
-
}));
|
|
56
|
-
}).then(({ error, result }) => {
|
|
57
|
-
if (error) {
|
|
58
|
-
throw new JsonRpcError(error.message, error.code);
|
|
59
|
-
}
|
|
60
|
-
return result;
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
#setupWebSocket() {
|
|
64
|
-
if (this.#connectionPromise) {
|
|
65
|
-
return this.#connectionPromise;
|
|
66
|
-
}
|
|
67
|
-
this.#connectionPromise = new Promise((resolve) => {
|
|
68
|
-
this.#webSocket?.close();
|
|
69
|
-
this.#webSocket = new this.options.WebSocketConstructor(this.endpoint);
|
|
70
|
-
this.#webSocket.addEventListener("open", () => {
|
|
71
|
-
this.#disconnects = 0;
|
|
72
|
-
resolve(this.#webSocket);
|
|
73
|
-
});
|
|
74
|
-
this.#webSocket.addEventListener("close", () => {
|
|
75
|
-
this.#disconnects++;
|
|
76
|
-
if (this.#disconnects <= this.options.maxReconnects) {
|
|
77
|
-
setTimeout(() => {
|
|
78
|
-
this.#reconnect();
|
|
79
|
-
}, this.options.reconnectTimeout);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
this.#webSocket.addEventListener("message", ({ data }) => {
|
|
83
|
-
let json;
|
|
84
|
-
try {
|
|
85
|
-
json = JSON.parse(data);
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
const err = new Error(`Failed to parse RPC message: ${data}`);
|
|
89
|
-
err.cause = error;
|
|
90
|
-
console.error(err);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if ("id" in json &&
|
|
94
|
-
json.id != null &&
|
|
95
|
-
this.#pendingRequests.has(json.id)) {
|
|
96
|
-
const { resolve, timeout } = this.#pendingRequests.get(json.id);
|
|
97
|
-
clearTimeout(timeout);
|
|
98
|
-
resolve(json);
|
|
99
|
-
}
|
|
100
|
-
else if ("params" in json) {
|
|
101
|
-
const { params } = json;
|
|
102
|
-
this.#subscriptions.forEach((subscription) => {
|
|
103
|
-
if (subscription.subscriptionId ===
|
|
104
|
-
params.subscription)
|
|
105
|
-
if (params.subscription ===
|
|
106
|
-
subscription.subscriptionId) {
|
|
107
|
-
subscription.onMessage(params.result);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
return this.#connectionPromise;
|
|
114
|
-
}
|
|
115
|
-
async #reconnect() {
|
|
116
|
-
this.#webSocket?.close();
|
|
117
|
-
this.#connectionPromise = null;
|
|
118
|
-
return Promise.allSettled([...this.#subscriptions].map((subscription) => subscription.subscribe(this)));
|
|
119
|
-
}
|
|
120
|
-
async subscribe(input) {
|
|
121
|
-
const subscription = new RpcSubscription(input);
|
|
122
|
-
this.#subscriptions.add(subscription);
|
|
123
|
-
await subscription.subscribe(this);
|
|
124
|
-
return () => subscription.unsubscribe(this);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
class RpcSubscription {
|
|
128
|
-
subscriptionId = null;
|
|
129
|
-
input;
|
|
130
|
-
subscribed = false;
|
|
131
|
-
constructor(input) {
|
|
132
|
-
this.input = input;
|
|
133
|
-
}
|
|
134
|
-
onMessage(message) {
|
|
135
|
-
if (this.subscribed) {
|
|
136
|
-
this.input.onMessage(message);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
async unsubscribe(client) {
|
|
140
|
-
const { subscriptionId } = this;
|
|
141
|
-
this.subscribed = false;
|
|
142
|
-
if (subscriptionId == null)
|
|
143
|
-
return false;
|
|
144
|
-
this.subscriptionId = null;
|
|
145
|
-
return client.makeRequest(this.input.unsubscribe, [subscriptionId]);
|
|
146
|
-
}
|
|
147
|
-
async subscribe(client) {
|
|
148
|
-
this.subscriptionId = null;
|
|
149
|
-
this.subscribed = true;
|
|
150
|
-
const newSubscriptionId = await client.makeRequest(this.input.method, this.input.params, this.input.signal);
|
|
151
|
-
if (this.subscribed) {
|
|
152
|
-
this.subscriptionId = newSubscriptionId;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
1
|
+
import{JsonRpcError}from'./errors.js';function getWebsocketUrl(a){const b=new URL(a);return b['protocol']=b['protocol']['replace']('http','ws'),b['toString']();}export const DEFAULT_CLIENT_OPTIONS={'WebSocketConstructor':typeof WebSocket!=='undefined'?WebSocket:undefined,'callTimeout':0x7530,'reconnectTimeout':0xbb8,'maxReconnects':0x5};export class WebsocketClient{['endpoint'];['options'];#requestId=0x0;#disconnects=0x0;#webSocket=null;#connectionPromise=null;#subscriptions=new Set();#pendingRequests=new Map();constructor(a,b={}){this['endpoint']=a,this['options']={...DEFAULT_CLIENT_OPTIONS,...b};if(!this['options']['WebSocketConstructor'])throw new Error('Missing\x20WebSocket\x20constructor');this['endpoint']['startsWith']('http')&&(this['endpoint']=getWebsocketUrl(this['endpoint']));}async['makeRequest'](a,b,c){const d=await this.#setupWebSocket();return new Promise((e,f)=>{this.#requestId+=0x1,this.#pendingRequests['set'](this.#requestId,{'resolve':e,'reject':f,'timeout':setTimeout(()=>{this.#pendingRequests['delete'](this.#requestId),f(new Error('Request\x20timeout:\x20'+a));},this['options']['callTimeout'])}),c?.['addEventListener']('abort',()=>{this.#pendingRequests['delete'](this.#requestId),f(c['reason']);}),d['send'](JSON['stringify']({'jsonrpc':'2.0','id':this.#requestId,'method':a,'params':b}));})['then'](({error:e,result:f})=>{if(e)throw new JsonRpcError(e['message'],e['code']);return f;});}#setupWebSocket(){if(this.#connectionPromise)return this.#connectionPromise;return this.#connectionPromise=new Promise(a=>{this.#webSocket?.['close'](),this.#webSocket=new this['options']['WebSocketConstructor'](this['endpoint']),this.#webSocket['addEventListener']('open',()=>{this.#disconnects=0x0,a(this.#webSocket);}),this.#webSocket['addEventListener']('close',()=>{this.#disconnects++,this.#disconnects<=this['options']['maxReconnects']&&setTimeout(()=>{this.#reconnect();},this['options']['reconnectTimeout']);}),this.#webSocket['addEventListener']('message',({data:b})=>{let c;try{c=JSON['parse'](b);}catch(d){const e=new Error('Failed\x20to\x20parse\x20RPC\x20message:\x20'+b);e['cause']=d,console['error'](e);return;}if('id'in c&&c['id']!=null&&this.#pendingRequests['has'](c['id'])){const {resolve:f,timeout:g}=this.#pendingRequests['get'](c['id']);clearTimeout(g),f(c);}else{if('params'in c){const {params:h}=c;this.#subscriptions['forEach'](i=>{if(i['subscriptionId']===h['subscription'])h['subscription']===i['subscriptionId']&&i['onMessage'](h['result']);});}}});}),this.#connectionPromise;}async #reconnect(){return this.#webSocket?.['close'](),this.#connectionPromise=null,Promise['allSettled']([...this.#subscriptions]['map'](a=>a['subscribe'](this)));}async['subscribe'](a){const b=new RpcSubscription(a);return this.#subscriptions['add'](b),await b['subscribe'](this),()=>b['unsubscribe'](this);}}class RpcSubscription{['subscriptionId']=null;['input'];['subscribed']=![];constructor(a){this['input']=a;}['onMessage'](a){this['subscribed']&&this['input']['onMessage'](a);}async['unsubscribe'](a){const {subscriptionId:b}=this;this['subscribed']=![];if(b==null)return![];return this['subscriptionId']=null,a['makeRequest'](this['input']['unsubscribe'],[b]);}async['subscribe'](a){this['subscriptionId']=null,this['subscribed']=!![];const b=await a['makeRequest'](this['input']['method'],this['input']['params'],this['input']['signal']);this['subscribed']&&(this['subscriptionId']=b);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
|
@@ -1,58 +1 @@
|
|
|
1
|
-
import { fromHex }
|
|
2
|
-
import { hmac } from "@noble/hashes/hmac";
|
|
3
|
-
import { sha512 } from "@noble/hashes/sha512";
|
|
4
|
-
const ED25519_CURVE = "ed25519 seed";
|
|
5
|
-
const HARDENED_OFFSET = 0x80000000;
|
|
6
|
-
const pathRegex = new RegExp("^m(\\/[0-9]+')+$");
|
|
7
|
-
const replaceDerive = (val) => val.replace("'", "");
|
|
8
|
-
const getMasterKeyFromSeed = (seed) => {
|
|
9
|
-
const h = hmac.create(sha512, ED25519_CURVE);
|
|
10
|
-
const I = h.update(fromHex(seed)).digest();
|
|
11
|
-
const IL = I.slice(0, 32);
|
|
12
|
-
const IR = I.slice(32);
|
|
13
|
-
return {
|
|
14
|
-
key: IL,
|
|
15
|
-
chainCode: IR,
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
const CKDPriv = ({ key, chainCode }, index) => {
|
|
19
|
-
const indexBuffer = new ArrayBuffer(4);
|
|
20
|
-
const cv = new DataView(indexBuffer);
|
|
21
|
-
cv.setUint32(0, index);
|
|
22
|
-
const data = new Uint8Array(1 + key.length + indexBuffer.byteLength);
|
|
23
|
-
data.set(new Uint8Array(1).fill(0));
|
|
24
|
-
data.set(key, 1);
|
|
25
|
-
data.set(new Uint8Array(indexBuffer, 0, indexBuffer.byteLength), key.length + 1);
|
|
26
|
-
const I = hmac.create(sha512, chainCode).update(data).digest();
|
|
27
|
-
const IL = I.slice(0, 32);
|
|
28
|
-
const IR = I.slice(32);
|
|
29
|
-
return {
|
|
30
|
-
key: IL,
|
|
31
|
-
chainCode: IR,
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
const isValidPath = (path) => {
|
|
35
|
-
if (!pathRegex.test(path)) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
return !path
|
|
39
|
-
.split("/")
|
|
40
|
-
.slice(1)
|
|
41
|
-
.map(replaceDerive)
|
|
42
|
-
.some(isNaN);
|
|
43
|
-
};
|
|
44
|
-
export const derivePath = (path, seed, offset = HARDENED_OFFSET) => {
|
|
45
|
-
if (!isValidPath(path)) {
|
|
46
|
-
throw new Error("Invalid derivation path");
|
|
47
|
-
}
|
|
48
|
-
const { key, chainCode } = getMasterKeyFromSeed(seed);
|
|
49
|
-
const segments = path
|
|
50
|
-
.split("/")
|
|
51
|
-
.slice(1)
|
|
52
|
-
.map(replaceDerive)
|
|
53
|
-
.map((el) => parseInt(el, 10));
|
|
54
|
-
return segments.reduce((parentKeys, segment) => CKDPriv(parentKeys, segment + offset), {
|
|
55
|
-
key,
|
|
56
|
-
chainCode,
|
|
57
|
-
});
|
|
58
|
-
};
|
|
1
|
+
import{fromHex}from'@mysten/bcs';import{hmac}from'@noble/hashes/hmac';import{sha512}from'@noble/hashes/sha512';const ED25519_CURVE='ed25519\x20seed',HARDENED_OFFSET=0x80000000,pathRegex=new RegExp('^m(\x5c/[0-9]+\x27)+$'),replaceDerive=a=>a['replace']('\x27',''),getMasterKeyFromSeed=a=>{const b=hmac['create'](sha512,ED25519_CURVE),c=b['update'](fromHex(a))['digest'](),d=c['slice'](0x0,0x20),e=c['slice'](0x20);return{'key':d,'chainCode':e};},CKDPriv=({key:a,chainCode:b},c)=>{const d=new ArrayBuffer(0x4),e=new DataView(d);e['setUint32'](0x0,c);const f=new Uint8Array(0x1+a['length']+d['byteLength']);f['set'](new Uint8Array(0x1)['fill'](0x0)),f['set'](a,0x1),f['set'](new Uint8Array(d,0x0,d['byteLength']),a['length']+0x1);const g=hmac['create'](sha512,b)['update'](f)['digest'](),h=g['slice'](0x0,0x20),i=g['slice'](0x20);return{'key':h,'chainCode':i};},isValidPath=a=>{if(!pathRegex['test'](a))return![];return!a['split']('/')['slice'](0x1)['map'](replaceDerive)['some'](isNaN);};export const derivePath=(a,b,c=HARDENED_OFFSET)=>{if(!isValidPath(a))throw new Error('Invalid\x20derivation\x20path');const {key:d,chainCode:e}=getMasterKeyFromSeed(b),f=a['split']('/')['slice'](0x1)['map'](replaceDerive)['map'](g=>parseInt(g,0xa));return f['reduce']((g,h)=>CKDPriv(g,h+c),{'key':d,'chainCode':e});};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { Ed25519PublicKey } from "./publickey.js";
|
|
1
|
+
export{DEFAULT_ED25519_DERIVATION_PATH,Ed25519Keypair}from'./keypair.js';export{Ed25519PublicKey}from'./publickey.js';
|