wowok 2.1.13 → 2.1.16
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 +160 -164
- package/dist/cjs/bcs/bcs.js.map +1 -1
- package/dist/cjs/bcs/effects.js +109 -112
- package/dist/cjs/bcs/effects.js.map +1 -1
- package/dist/cjs/bcs/index.js +49 -58
- package/dist/cjs/bcs/index.js.map +1 -1
- package/dist/cjs/bcs/pure.js +14 -17
- package/dist/cjs/bcs/pure.js.map +1 -1
- package/dist/cjs/bcs/type-tag-serializer.js +6 -11
- package/dist/cjs/bcs/type-tag-serializer.js.map +1 -1
- package/dist/cjs/bcs/types.js +1 -4
- package/dist/cjs/bcs/types.js.map +1 -1
- package/dist/cjs/client/index.js +4 -15
- package/dist/cjs/client/index.js.map +1 -1
- package/dist/cjs/client/network.js +3 -7
- package/dist/cjs/client/network.js.map +1 -1
- package/dist/cjs/cryptography/index.js +6 -27
- package/dist/cjs/cryptography/index.js.map +1 -1
- package/dist/cjs/cryptography/intent.js +4 -7
- package/dist/cjs/cryptography/intent.js.map +1 -1
- package/dist/cjs/cryptography/keypair.js +26 -33
- package/dist/cjs/cryptography/keypair.js.map +1 -1
- package/dist/cjs/cryptography/mnemonics.js +8 -14
- package/dist/cjs/cryptography/mnemonics.js.map +1 -1
- package/dist/cjs/cryptography/publickey.js +19 -25
- package/dist/cjs/cryptography/publickey.js.map +1 -1
- package/dist/cjs/cryptography/signature-scheme.js +3 -6
- package/dist/cjs/cryptography/signature-scheme.js.map +1 -1
- package/dist/cjs/cryptography/signature.js +14 -18
- package/dist/cjs/cryptography/signature.js.map +1 -1
- package/dist/cjs/experimental/cache.js +1 -5
- package/dist/cjs/experimental/cache.js.map +1 -1
- package/dist/cjs/experimental/client.js +3 -7
- package/dist/cjs/experimental/client.js.map +1 -1
- package/dist/cjs/experimental/core.js +11 -15
- package/dist/cjs/experimental/core.js.map +1 -1
- package/dist/cjs/experimental/errors.js +2 -7
- package/dist/cjs/experimental/errors.js.map +1 -1
- package/dist/cjs/experimental/index.js +5 -12
- package/dist/cjs/experimental/index.js.map +1 -1
- package/dist/cjs/experimental/persistent-storage.js +30 -36
- package/dist/cjs/experimental/persistent-storage.js.map +1 -1
- package/dist/cjs/experimental/persistent-storage.test.js +18 -20
- package/dist/cjs/experimental/persistent-storage.test.js.map +1 -1
- package/dist/cjs/experimental/transports/utils.js +6 -10
- package/dist/cjs/experimental/transports/utils.js.map +1 -1
- package/dist/cjs/experimental/types.js +1 -2
- package/dist/cjs/experimental/types.js.map +1 -1
- package/dist/cjs/faucet/faucet.js +6 -15
- package/dist/cjs/faucet/faucet.js.map +1 -1
- package/dist/cjs/faucet/index.js +1 -10
- package/dist/cjs/faucet/index.js.map +1 -1
- package/dist/cjs/grpc/client.js +20 -24
- package/dist/cjs/grpc/client.js.map +1 -1
- package/dist/cjs/grpc/core.js +65 -70
- package/dist/cjs/grpc/core.js.map +1 -1
- package/dist/cjs/grpc/index.js +2 -7
- package/dist/cjs/grpc/index.js.map +1 -1
- package/dist/cjs/grpc/proto/google/protobuf/any.js +10 -13
- package/dist/cjs/grpc/proto/google/protobuf/any.js.map +1 -1
- package/dist/cjs/grpc/proto/google/protobuf/duration.js +8 -11
- package/dist/cjs/grpc/proto/google/protobuf/duration.js.map +1 -1
- package/dist/cjs/grpc/proto/google/protobuf/empty.js +3 -6
- package/dist/cjs/grpc/proto/google/protobuf/empty.js.map +1 -1
- package/dist/cjs/grpc/proto/google/protobuf/field_mask.js +7 -10
- package/dist/cjs/grpc/proto/google/protobuf/field_mask.js.map +1 -1
- package/dist/cjs/grpc/proto/google/protobuf/struct.js +25 -28
- package/dist/cjs/grpc/proto/google/protobuf/struct.js.map +1 -1
- package/dist/cjs/grpc/proto/google/protobuf/timestamp.js +11 -14
- package/dist/cjs/grpc/proto/google/protobuf/timestamp.js.map +1 -1
- package/dist/cjs/grpc/proto/google/rpc/error_details.js +36 -39
- package/dist/cjs/grpc/proto/google/rpc/error_details.js.map +1 -1
- package/dist/cjs/grpc/proto/google/rpc/status.js +5 -8
- package/dist/cjs/grpc/proto/google/rpc/status.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/argument.js +5 -8
- package/dist/cjs/grpc/proto/sui/rpc/v2/argument.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/balance_change.js +3 -6
- package/dist/cjs/grpc/proto/sui/rpc/v2/balance_change.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/bcs.js +3 -6
- package/dist/cjs/grpc/proto/sui/rpc/v2/bcs.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint.js +13 -16
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_contents.js +10 -13
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_contents.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_summary.js +20 -23
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_summary.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/effects.js +29 -32
- package/dist/cjs/grpc/proto/sui/rpc/v2/effects.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/epoch.js +12 -15
- package/dist/cjs/grpc/proto/sui/rpc/v2/epoch.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/error_reason.js +2 -5
- package/dist/cjs/grpc/proto/sui/rpc/v2/error_reason.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/event.js +11 -14
- package/dist/cjs/grpc/proto/sui/rpc/v2/event.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/executed_transaction.js +17 -20
- package/dist/cjs/grpc/proto/sui/rpc/v2/executed_transaction.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/execution_status.js +45 -48
- package/dist/cjs/grpc/proto/sui/rpc/v2/execution_status.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/gas_cost_summary.js +3 -6
- package/dist/cjs/grpc/proto/sui/rpc/v2/gas_cost_summary.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/input.js +7 -10
- package/dist/cjs/grpc/proto/sui/rpc/v2/input.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/jwk.js +5 -8
- package/dist/cjs/grpc/proto/sui/rpc/v2/jwk.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.client.js +13 -17
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.client.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.js +73 -76
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package.js +48 -51
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.client.js +10 -14
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.client.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.js +36 -39
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.client.js +8 -12
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.client.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.js +21 -24
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/object.js +15 -18
- package/dist/cjs/grpc/proto/sui/rpc/v2/object.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/object_reference.js +3 -6
- package/dist/cjs/grpc/proto/sui/rpc/v2/object_reference.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/owner.js +5 -8
- package/dist/cjs/grpc/proto/sui/rpc/v2/owner.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/protocol_config.js +3 -6
- package/dist/cjs/grpc/proto/sui/rpc/v2/protocol_config.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature.js +67 -70
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_scheme.js +2 -5
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_scheme.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.client.js +7 -11
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.client.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.js +15 -18
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.client.js +11 -15
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.client.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.js +67 -70
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.client.js +7 -11
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.client.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.js +13 -16
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/system_state.js +38 -41
- package/dist/cjs/grpc/proto/sui/rpc/v2/system_state.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction.js +124 -127
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.client.js +8 -12
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.client.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.js +41 -44
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.js.map +1 -1
- package/dist/cjs/index.js +22 -87
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/jsonRpc/client.js +29 -34
- package/dist/cjs/jsonRpc/client.js.map +1 -1
- package/dist/cjs/jsonRpc/core.js +29 -33
- package/dist/cjs/jsonRpc/core.js.map +1 -1
- package/dist/cjs/jsonRpc/errors.js +3 -9
- package/dist/cjs/jsonRpc/errors.js.map +1 -1
- package/dist/cjs/jsonRpc/http-transport.js +9 -13
- package/dist/cjs/jsonRpc/http-transport.js.map +1 -1
- package/dist/cjs/jsonRpc/index.js +3 -12
- package/dist/cjs/jsonRpc/index.js.map +1 -1
- package/dist/cjs/jsonRpc/json-rpc-resolver.js +19 -22
- package/dist/cjs/jsonRpc/json-rpc-resolver.js.map +1 -1
- package/dist/cjs/jsonRpc/rpc-websocket-client.js +5 -9
- package/dist/cjs/jsonRpc/rpc-websocket-client.js.map +1 -1
- package/dist/cjs/jsonRpc/types/chain.js +1 -2
- package/dist/cjs/jsonRpc/types/chain.js.map +1 -1
- package/dist/cjs/jsonRpc/types/changes.js +1 -2
- package/dist/cjs/jsonRpc/types/changes.js.map +1 -1
- package/dist/cjs/jsonRpc/types/coins.js +1 -2
- package/dist/cjs/jsonRpc/types/coins.js.map +1 -1
- package/dist/cjs/jsonRpc/types/common.js +1 -2
- package/dist/cjs/jsonRpc/types/common.js.map +1 -1
- package/dist/cjs/jsonRpc/types/generated.js +1 -2
- package/dist/cjs/jsonRpc/types/generated.js.map +1 -1
- package/dist/cjs/jsonRpc/types/index.js +1 -2
- package/dist/cjs/jsonRpc/types/index.js.map +1 -1
- package/dist/cjs/jsonRpc/types/params.js +1 -2
- package/dist/cjs/jsonRpc/types/params.js.map +1 -1
- package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js +7 -11
- package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js.map +1 -1
- package/dist/cjs/keypairs/ed25519/index.js +2 -8
- package/dist/cjs/keypairs/ed25519/index.js.map +1 -1
- package/dist/cjs/keypairs/ed25519/keypair.js +26 -30
- package/dist/cjs/keypairs/ed25519/keypair.js.map +1 -1
- package/dist/cjs/keypairs/ed25519/publickey.js +10 -14
- package/dist/cjs/keypairs/ed25519/publickey.js.map +1 -1
- package/dist/cjs/keypairs/index.js +4 -20
- package/dist/cjs/keypairs/index.js.map +1 -1
- package/dist/cjs/keypairs/passkey/index.js +2 -9
- package/dist/cjs/keypairs/passkey/index.js.map +1 -1
- package/dist/cjs/keypairs/passkey/keypair.js +29 -35
- package/dist/cjs/keypairs/passkey/keypair.js.map +1 -1
- package/dist/cjs/keypairs/passkey/publickey.js +35 -41
- package/dist/cjs/keypairs/passkey/publickey.js.map +1 -1
- package/dist/cjs/keypairs/passkey/types.js +1 -2
- package/dist/cjs/keypairs/passkey/types.js.map +1 -1
- package/dist/cjs/keypairs/secp256k1/index.js +2 -8
- package/dist/cjs/keypairs/secp256k1/index.js.map +1 -1
- package/dist/cjs/keypairs/secp256k1/keypair.js +25 -29
- package/dist/cjs/keypairs/secp256k1/keypair.js.map +1 -1
- package/dist/cjs/keypairs/secp256k1/publickey.js +11 -15
- package/dist/cjs/keypairs/secp256k1/publickey.js.map +1 -1
- package/dist/cjs/keypairs/secp256r1/index.js +2 -8
- package/dist/cjs/keypairs/secp256r1/index.js.map +1 -1
- package/dist/cjs/keypairs/secp256r1/keypair.js +25 -29
- package/dist/cjs/keypairs/secp256r1/keypair.js.map +1 -1
- package/dist/cjs/keypairs/secp256r1/publickey.js +12 -16
- package/dist/cjs/keypairs/secp256r1/publickey.js.map +1 -1
- package/dist/cjs/multisig/index.js +2 -8
- package/dist/cjs/multisig/index.js.map +1 -1
- package/dist/cjs/multisig/publickey.js +40 -45
- package/dist/cjs/multisig/publickey.js.map +1 -1
- package/dist/cjs/multisig/signer.js +5 -9
- package/dist/cjs/multisig/signer.js.map +1 -1
- package/dist/cjs/transactions/Arguments.js +5 -8
- package/dist/cjs/transactions/Arguments.js.map +1 -1
- package/dist/cjs/transactions/Commands.js +21 -24
- package/dist/cjs/transactions/Commands.js.map +1 -1
- package/dist/cjs/transactions/Inputs.js +7 -10
- package/dist/cjs/transactions/Inputs.js.map +1 -1
- package/dist/cjs/transactions/ObjectCache.js +7 -13
- package/dist/cjs/transactions/ObjectCache.js.map +1 -1
- package/dist/cjs/transactions/Transaction.js +54 -59
- package/dist/cjs/transactions/Transaction.js.map +1 -1
- package/dist/cjs/transactions/TransactionData.js +27 -31
- package/dist/cjs/transactions/TransactionData.js.map +1 -1
- package/dist/cjs/transactions/__tests__/Transaction.test.js +71 -73
- package/dist/cjs/transactions/__tests__/Transaction.test.js.map +1 -1
- package/dist/cjs/transactions/__tests__/bcs.test.js +26 -28
- package/dist/cjs/transactions/__tests__/bcs.test.js.map +1 -1
- package/dist/cjs/transactions/data/internal.js +122 -126
- package/dist/cjs/transactions/data/internal.js.map +1 -1
- package/dist/cjs/transactions/data/v1.js +114 -119
- package/dist/cjs/transactions/data/v1.js.map +1 -1
- package/dist/cjs/transactions/data/v2.js +63 -66
- package/dist/cjs/transactions/data/v2.js.map +1 -1
- package/dist/cjs/transactions/executor/caching.js +7 -11
- package/dist/cjs/transactions/executor/caching.js.map +1 -1
- package/dist/cjs/transactions/executor/parallel.js +20 -24
- package/dist/cjs/transactions/executor/parallel.js.map +1 -1
- package/dist/cjs/transactions/executor/queue.js +2 -7
- package/dist/cjs/transactions/executor/queue.js.map +1 -1
- package/dist/cjs/transactions/executor/serial.js +11 -16
- package/dist/cjs/transactions/executor/serial.js.map +1 -1
- package/dist/cjs/transactions/hash.js +3 -6
- package/dist/cjs/transactions/hash.js.map +1 -1
- package/dist/cjs/transactions/index.js +12 -31
- package/dist/cjs/transactions/index.js.map +1 -1
- package/dist/cjs/transactions/intents/CoinWithBalance.js +21 -25
- package/dist/cjs/transactions/intents/CoinWithBalance.js.map +1 -1
- package/dist/cjs/transactions/object.js +4 -7
- package/dist/cjs/transactions/object.js.map +1 -1
- package/dist/cjs/transactions/plugins/NamedPackagesPlugin.js +2 -7
- package/dist/cjs/transactions/plugins/NamedPackagesPlugin.js.map +1 -1
- package/dist/cjs/transactions/pure.js +19 -22
- package/dist/cjs/transactions/pure.js.map +1 -1
- package/dist/cjs/transactions/resolve.js +10 -15
- package/dist/cjs/transactions/resolve.js.map +1 -1
- package/dist/cjs/transactions/serializer.js +34 -40
- package/dist/cjs/transactions/serializer.js.map +1 -1
- package/dist/cjs/transactions/utils.js +15 -23
- package/dist/cjs/transactions/utils.js.map +1 -1
- package/dist/cjs/utils/constants.js +18 -21
- package/dist/cjs/utils/constants.js.map +1 -1
- package/dist/cjs/utils/derived-objects.js +5 -8
- package/dist/cjs/utils/derived-objects.js.map +1 -1
- package/dist/cjs/utils/dynamic-fields.js +9 -12
- package/dist/cjs/utils/dynamic-fields.js.map +1 -1
- package/dist/cjs/utils/format.js +2 -6
- package/dist/cjs/utils/format.js.map +1 -1
- package/dist/cjs/utils/index.js +10 -46
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/move-registry.js +5 -10
- package/dist/cjs/utils/move-registry.js.map +1 -1
- package/dist/cjs/utils/sui-types.js +15 -25
- package/dist/cjs/utils/sui-types.js.map +1 -1
- package/dist/cjs/utils/suins.js +2 -6
- package/dist/cjs/utils/suins.js.map +1 -1
- package/dist/cjs/verify/index.js +1 -9
- package/dist/cjs/verify/index.js.map +1 -1
- package/dist/cjs/verify/verify.js +21 -28
- package/dist/cjs/verify/verify.js.map +1 -1
- package/dist/cjs/version.js +2 -5
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/w/call/allocation.js +88 -99
- package/dist/cjs/w/call/allocation.js.map +1 -1
- package/dist/cjs/w/call/arb.js +49 -58
- package/dist/cjs/w/call/arb.js.map +1 -1
- package/dist/cjs/w/call/arbitration.js +380 -406
- package/dist/cjs/w/call/arbitration.js.map +1 -1
- package/dist/cjs/w/call/base.js +63 -73
- package/dist/cjs/w/call/base.js.map +1 -1
- package/dist/cjs/w/call/contact.js +111 -123
- package/dist/cjs/w/call/contact.js.map +1 -1
- package/dist/cjs/w/call/demand.js +221 -238
- package/dist/cjs/w/call/demand.js.map +1 -1
- package/dist/cjs/w/call/entity.js +58 -75
- package/dist/cjs/w/call/entity.js.map +1 -1
- package/dist/cjs/w/call/guard-ins.js +1191 -1196
- package/dist/cjs/w/call/guard-ins.js.map +1 -1
- package/dist/cjs/w/call/guard.js +265 -286
- package/dist/cjs/w/call/guard.js.map +1 -1
- package/dist/cjs/w/call/index.js +22 -66
- package/dist/cjs/w/call/index.js.map +1 -1
- package/dist/cjs/w/call/machine.js +351 -378
- package/dist/cjs/w/call/machine.js.map +1 -1
- package/dist/cjs/w/call/order.js +102 -113
- package/dist/cjs/w/call/order.js.map +1 -1
- package/dist/cjs/w/call/passport.js +53 -65
- package/dist/cjs/w/call/passport.js.map +1 -1
- package/dist/cjs/w/call/payment.js +41 -50
- package/dist/cjs/w/call/payment.js.map +1 -1
- package/dist/cjs/w/call/permission.js +233 -263
- package/dist/cjs/w/call/permission.js.map +1 -1
- package/dist/cjs/w/call/personal.js +38 -42
- package/dist/cjs/w/call/personal.js.map +1 -1
- package/dist/cjs/w/call/progress.js +222 -240
- package/dist/cjs/w/call/progress.js.map +1 -1
- package/dist/cjs/w/call/proof.js +23 -30
- package/dist/cjs/w/call/proof.js.map +1 -1
- package/dist/cjs/w/call/repository.js +283 -302
- package/dist/cjs/w/call/repository.js.map +1 -1
- package/dist/cjs/w/call/resource.js +27 -37
- package/dist/cjs/w/call/resource.js.map +1 -1
- package/dist/cjs/w/call/reward.js +227 -241
- package/dist/cjs/w/call/reward.js.map +1 -1
- package/dist/cjs/w/call/service.js +653 -694
- package/dist/cjs/w/call/service.js.map +1 -1
- package/dist/cjs/w/call/treasury.js +270 -289
- package/dist/cjs/w/call/treasury.js.map +1 -1
- package/dist/cjs/w/call/util.js +201 -208
- package/dist/cjs/w/call/util.js.map +1 -1
- package/dist/cjs/w/common.js +117 -168
- package/dist/cjs/w/common.js.map +1 -1
- package/dist/cjs/w/exception.js +18 -30
- package/dist/cjs/w/exception.js.map +1 -1
- package/dist/cjs/w/index.js +8 -24
- package/dist/cjs/w/index.js.map +1 -1
- package/dist/cjs/w/local/account.js +73 -77
- package/dist/cjs/w/local/account.js.map +1 -1
- package/dist/cjs/w/local/cache.js +5 -9
- package/dist/cjs/w/local/cache.js.map +1 -1
- package/dist/cjs/w/local/config.js +10 -14
- package/dist/cjs/w/local/config.js.map +1 -1
- package/dist/cjs/w/local/index.js +65 -98
- package/dist/cjs/w/local/index.js.map +1 -1
- package/dist/cjs/w/local/local.js +59 -65
- package/dist/cjs/w/local/local.js.map +1 -1
- package/dist/cjs/w/local/storage.js +13 -56
- package/dist/cjs/w/local/storage.js.map +1 -1
- package/dist/cjs/w/local/token.js +20 -24
- package/dist/cjs/w/local/token.js.map +1 -1
- package/dist/cjs/w/local/util.js +3 -39
- package/dist/cjs/w/local/util.js.map +1 -1
- package/dist/cjs/w/local/wip.js +22 -70
- package/dist/cjs/w/local/wip.js.map +1 -1
- package/dist/cjs/w/messenger/crypto.js +34 -57
- package/dist/cjs/w/messenger/crypto.js.map +1 -1
- package/dist/cjs/w/messenger/index.js +4 -31
- package/dist/cjs/w/messenger/index.js.map +1 -1
- package/dist/cjs/w/messenger/messenger-api.d.ts +1 -3
- package/dist/cjs/w/messenger/messenger-api.js +128 -178
- package/dist/cjs/w/messenger/messenger-api.js.map +1 -1
- package/dist/cjs/w/messenger/messenger-manager.d.ts +3 -5
- package/dist/cjs/w/messenger/messenger-manager.js +65 -69
- package/dist/cjs/w/messenger/messenger-manager.js.map +1 -1
- package/dist/cjs/w/messenger/messenger.js +100 -137
- package/dist/cjs/w/messenger/messenger.js.map +1 -1
- package/dist/cjs/w/messenger/server.js +40 -44
- package/dist/cjs/w/messenger/server.js.map +1 -1
- package/dist/cjs/w/messenger/session.js +52 -56
- package/dist/cjs/w/messenger/session.js.map +1 -1
- package/dist/cjs/w/messenger/storage.js +13 -57
- package/dist/cjs/w/messenger/storage.js.map +1 -1
- package/dist/cjs/w/messenger/types.d.ts +3 -1
- package/dist/cjs/w/messenger/types.js +23 -27
- package/dist/cjs/w/messenger/types.js.map +1 -1
- package/dist/cjs/w/messenger/utils.js +1 -4
- package/dist/cjs/w/messenger/utils.js.map +1 -1
- package/dist/cjs/w/query/bult-in.js +22 -27
- package/dist/cjs/w/query/bult-in.js.map +1 -1
- package/dist/cjs/w/query/event.js +13 -18
- package/dist/cjs/w/query/event.js.map +1 -1
- package/dist/cjs/w/query/index.js +5 -21
- package/dist/cjs/w/query/index.js.map +1 -1
- package/dist/cjs/w/query/object.js +229 -266
- package/dist/cjs/w/query/object.js.map +1 -1
- package/dist/cjs/w/query/received.js +17 -21
- package/dist/cjs/w/query/received.js.map +1 -1
- package/dist/cjs/w/query/util.js +13 -17
- package/dist/cjs/w/query/util.js.map +1 -1
- package/dist/cjs/w/util.js +211 -225
- package/dist/cjs/w/util.js.map +1 -1
- package/dist/esm/experimental/persistent-storage.test.js +1 -1
- package/dist/esm/experimental/persistent-storage.test.js.map +1 -1
- package/dist/esm/w/messenger/messenger-api.d.ts +1 -3
- package/dist/esm/w/messenger/messenger-api.js +7 -8
- package/dist/esm/w/messenger/messenger-api.js.map +1 -1
- package/dist/esm/w/messenger/messenger-manager.d.ts +3 -5
- package/dist/esm/w/messenger/messenger-manager.js +16 -16
- package/dist/esm/w/messenger/messenger-manager.js.map +1 -1
- package/dist/esm/w/messenger/types.d.ts +3 -1
- package/dist/esm/w/messenger/types.js.map +1 -1
- package/package.json +7 -4
- package/scripts/download-prebuilds.js +213 -195
- package/scripts/install-better-sqlite3.js +8 -8
package/dist/cjs/w/util.js
CHANGED
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const index_js_2 = require("./local/index.js");
|
|
10
|
-
const common_js_2 = require("./common.js");
|
|
11
|
-
const sui_types_js_1 = require("../utils/sui-types.js");
|
|
12
|
-
const local_js_1 = require("./local/local.js");
|
|
13
|
-
const local_js_2 = require("./local/local.js");
|
|
1
|
+
import { bcs } from "../bcs/index.js";
|
|
2
|
+
import { isThisPackage, IsValidArgType, isValidU128, isValidU16, isValidU256, isValidU32, isValidU64, isValidU8, isValidValueType, PackageAddress, ValueType, } from "./common.js";
|
|
3
|
+
import { W_ERROR, WErrors } from "./exception.js";
|
|
4
|
+
import { GetAccountOrMark_Address, GetManyAccountOrMark_Address, } from "./local/index.js";
|
|
5
|
+
import { toTxObject } from "./common.js";
|
|
6
|
+
import { normalizeWowAddress } from "../utils/sui-types.js";
|
|
7
|
+
import { LocalMark } from "./local/local.js";
|
|
8
|
+
import { isValidAddress } from "./local/local.js";
|
|
14
9
|
// 验证 ValueContainer 的函数
|
|
15
|
-
const isValidValueContainer = (container) => {
|
|
10
|
+
export const isValidValueContainer = (container) => {
|
|
16
11
|
try {
|
|
17
12
|
// 通过尝试序列化来验证容器的有效性
|
|
18
|
-
|
|
13
|
+
valueToBcsBytes(container.valueType, container.value);
|
|
19
14
|
return true;
|
|
20
15
|
}
|
|
21
16
|
catch {
|
|
22
17
|
return false;
|
|
23
18
|
}
|
|
24
19
|
};
|
|
25
|
-
exports.isValidValueContainer = isValidValueContainer;
|
|
26
20
|
const toU64Value = (value) => {
|
|
27
21
|
if (typeof value === "string") {
|
|
28
22
|
if (value.length > 15) {
|
|
@@ -53,10 +47,10 @@ const toU256Value = (value) => {
|
|
|
53
47
|
}
|
|
54
48
|
return BigInt(value);
|
|
55
49
|
};
|
|
56
|
-
const valueToBcsBytes = async (valueType, value) => {
|
|
50
|
+
export const valueToBcsBytes = async (valueType, value) => {
|
|
57
51
|
// 验证 ValueType
|
|
58
|
-
if (!
|
|
59
|
-
|
|
52
|
+
if (!isValidValueType(valueType)) {
|
|
53
|
+
W_ERROR(WErrors.InvalidParam, `Invalid ValueType: ${valueType}`);
|
|
60
54
|
return new Uint8Array(0);
|
|
61
55
|
}
|
|
62
56
|
// 创建结果数组,第一个字节为 ValueType
|
|
@@ -65,16 +59,16 @@ const valueToBcsBytes = async (valueType, value) => {
|
|
|
65
59
|
try {
|
|
66
60
|
let serializedValue;
|
|
67
61
|
switch (valueType) {
|
|
68
|
-
case
|
|
69
|
-
serializedValue =
|
|
62
|
+
case ValueType.Bool:
|
|
63
|
+
serializedValue = bcs.Bool.serialize(value).toBytes();
|
|
70
64
|
break;
|
|
71
|
-
case
|
|
65
|
+
case ValueType.Address: {
|
|
72
66
|
let addressValue;
|
|
73
67
|
let errorDetails = "";
|
|
74
68
|
// 尝试不同的方式获取地址
|
|
75
69
|
if (typeof value === "string") {
|
|
76
70
|
// 如果是字符串,直接尝试解析
|
|
77
|
-
addressValue = await
|
|
71
|
+
addressValue = await GetAccountOrMark_Address({
|
|
78
72
|
name_or_address: value,
|
|
79
73
|
});
|
|
80
74
|
errorDetails = `string: ${value}`;
|
|
@@ -85,7 +79,7 @@ const valueToBcsBytes = async (valueType, value) => {
|
|
|
85
79
|
// 如果是包含name_or_address属性的对象
|
|
86
80
|
const accountOrMarkAddr = value;
|
|
87
81
|
addressValue =
|
|
88
|
-
await
|
|
82
|
+
await GetAccountOrMark_Address(accountOrMarkAddr);
|
|
89
83
|
errorDetails = `AccountOrMark_Address: ${JSON.stringify(value)}`;
|
|
90
84
|
}
|
|
91
85
|
else {
|
|
@@ -94,217 +88,217 @@ const valueToBcsBytes = async (valueType, value) => {
|
|
|
94
88
|
errorDetails = `type: ${typeof value}, value: ${JSON.stringify(value)}`;
|
|
95
89
|
}
|
|
96
90
|
if (addressValue === undefined) {
|
|
97
|
-
|
|
91
|
+
W_ERROR(WErrors.InvalidParam, `Expected valid Address for ValueType.Address, but failed to resolve ${errorDetails}. Address may not exist in local accounts or marks.`);
|
|
98
92
|
return new Uint8Array(0);
|
|
99
93
|
}
|
|
100
|
-
serializedValue =
|
|
94
|
+
serializedValue = bcs.Address.serialize(addressValue).toBytes();
|
|
101
95
|
break;
|
|
102
96
|
}
|
|
103
|
-
case
|
|
104
|
-
serializedValue =
|
|
97
|
+
case ValueType.String:
|
|
98
|
+
serializedValue = bcs.String.serialize(value).toBytes();
|
|
105
99
|
break;
|
|
106
|
-
case
|
|
107
|
-
if (!
|
|
108
|
-
|
|
100
|
+
case ValueType.U8:
|
|
101
|
+
if (!isValidU8(value)) {
|
|
102
|
+
W_ERROR(WErrors.InvalidParam, `Expected valid U8 for ValueType.U8, got ${JSON.stringify(value)}`);
|
|
109
103
|
return new Uint8Array(0);
|
|
110
104
|
}
|
|
111
|
-
serializedValue =
|
|
105
|
+
serializedValue = bcs.U8.serialize(value).toBytes();
|
|
112
106
|
break;
|
|
113
|
-
case
|
|
114
|
-
if (!
|
|
115
|
-
|
|
107
|
+
case ValueType.U16:
|
|
108
|
+
if (!isValidU16(value)) {
|
|
109
|
+
W_ERROR(WErrors.InvalidParam, `Expected valid U16 for ValueType.U16, got ${JSON.stringify(value)}`);
|
|
116
110
|
return new Uint8Array(0);
|
|
117
111
|
}
|
|
118
|
-
serializedValue =
|
|
112
|
+
serializedValue = bcs.U16.serialize(value).toBytes();
|
|
119
113
|
break;
|
|
120
|
-
case
|
|
121
|
-
if (!
|
|
122
|
-
|
|
114
|
+
case ValueType.U32:
|
|
115
|
+
if (!isValidU32(value)) {
|
|
116
|
+
W_ERROR(WErrors.InvalidParam, `Expected valid U32 for ValueType.U32, got ${JSON.stringify(value)}`);
|
|
123
117
|
return new Uint8Array(0);
|
|
124
118
|
}
|
|
125
|
-
serializedValue =
|
|
119
|
+
serializedValue = bcs.U32.serialize(value).toBytes();
|
|
126
120
|
break;
|
|
127
|
-
case
|
|
128
|
-
if (!
|
|
129
|
-
|
|
121
|
+
case ValueType.U64:
|
|
122
|
+
if (!isValidU64(value)) {
|
|
123
|
+
W_ERROR(WErrors.InvalidParam, `Expected valid U64 for ValueType.U64, got ${JSON.stringify(value)}`);
|
|
130
124
|
return new Uint8Array(0);
|
|
131
125
|
}
|
|
132
|
-
serializedValue =
|
|
126
|
+
serializedValue = bcs.U64.serialize(toU64Value(value)).toBytes();
|
|
133
127
|
break;
|
|
134
|
-
case
|
|
135
|
-
if (!
|
|
136
|
-
|
|
128
|
+
case ValueType.U128:
|
|
129
|
+
if (!isValidU128(value)) {
|
|
130
|
+
W_ERROR(WErrors.InvalidParam, `Expected valid U128 for ValueType.U128, got ${JSON.stringify(value)}`);
|
|
137
131
|
return new Uint8Array(0);
|
|
138
132
|
}
|
|
139
|
-
serializedValue =
|
|
133
|
+
serializedValue = bcs.U128.serialize(toU128Value(value)).toBytes();
|
|
140
134
|
break;
|
|
141
|
-
case
|
|
142
|
-
if (!
|
|
143
|
-
|
|
135
|
+
case ValueType.U256:
|
|
136
|
+
if (!isValidU256(value)) {
|
|
137
|
+
W_ERROR(WErrors.InvalidParam, `Expected valid U256 for ValueType.U256, got ${JSON.stringify(value)}`);
|
|
144
138
|
return new Uint8Array(0);
|
|
145
139
|
}
|
|
146
|
-
serializedValue =
|
|
140
|
+
serializedValue = bcs.U256.serialize(toU256Value(value)).toBytes();
|
|
147
141
|
break;
|
|
148
|
-
case
|
|
142
|
+
case ValueType.VecBool:
|
|
149
143
|
if (!Array.isArray(value)) {
|
|
150
|
-
|
|
144
|
+
W_ERROR(WErrors.InvalidParam, `Expected array for ValueType.VecBool, got ${typeof value}`);
|
|
151
145
|
return new Uint8Array(0);
|
|
152
146
|
}
|
|
153
147
|
for (const item of value) {
|
|
154
148
|
if (typeof item !== "boolean") {
|
|
155
|
-
|
|
149
|
+
W_ERROR(WErrors.InvalidParam, `Expected boolean in VecBool, got ${typeof item}`);
|
|
156
150
|
return new Uint8Array(0);
|
|
157
151
|
}
|
|
158
152
|
}
|
|
159
|
-
serializedValue =
|
|
160
|
-
.vector(
|
|
153
|
+
serializedValue = bcs
|
|
154
|
+
.vector(bcs.Bool)
|
|
161
155
|
.serialize(value)
|
|
162
156
|
.toBytes();
|
|
163
157
|
break;
|
|
164
|
-
case
|
|
165
|
-
const r = await
|
|
166
|
-
serializedValue =
|
|
167
|
-
.vector(
|
|
158
|
+
case ValueType.VecAddress:
|
|
159
|
+
const r = await GetManyAccountOrMark_Address(value);
|
|
160
|
+
serializedValue = bcs
|
|
161
|
+
.vector(bcs.Address)
|
|
168
162
|
.serialize(r)
|
|
169
163
|
.toBytes();
|
|
170
164
|
break;
|
|
171
|
-
case
|
|
165
|
+
case ValueType.VecString:
|
|
172
166
|
if (!Array.isArray(value)) {
|
|
173
|
-
|
|
167
|
+
W_ERROR(WErrors.InvalidParam, `Expected array for ValueType.VecString, got ${typeof value}`);
|
|
174
168
|
return new Uint8Array(0);
|
|
175
169
|
}
|
|
176
170
|
for (const item of value) {
|
|
177
171
|
if (typeof item !== "string") {
|
|
178
|
-
|
|
172
|
+
W_ERROR(WErrors.InvalidParam, `Expected string in VecString, got ${typeof item}`);
|
|
179
173
|
return new Uint8Array(0);
|
|
180
174
|
}
|
|
181
175
|
}
|
|
182
|
-
serializedValue =
|
|
183
|
-
.vector(
|
|
176
|
+
serializedValue = bcs
|
|
177
|
+
.vector(bcs.String)
|
|
184
178
|
.serialize(value)
|
|
185
179
|
.toBytes();
|
|
186
180
|
break;
|
|
187
|
-
case
|
|
181
|
+
case ValueType.VecU8:
|
|
188
182
|
if (value instanceof Uint8Array) {
|
|
189
|
-
serializedValue =
|
|
190
|
-
.vector(
|
|
183
|
+
serializedValue = bcs
|
|
184
|
+
.vector(bcs.U8)
|
|
191
185
|
.serialize(Array.from(value))
|
|
192
186
|
.toBytes();
|
|
193
187
|
}
|
|
194
188
|
else if (Array.isArray(value)) {
|
|
195
189
|
for (const item of value) {
|
|
196
|
-
if (!
|
|
197
|
-
|
|
190
|
+
if (!isValidU8(item)) {
|
|
191
|
+
W_ERROR(WErrors.InvalidParam, `Expected valid U8 in VecU8, got ${item}`);
|
|
198
192
|
return new Uint8Array(0);
|
|
199
193
|
}
|
|
200
194
|
}
|
|
201
|
-
serializedValue =
|
|
202
|
-
.vector(
|
|
195
|
+
serializedValue = bcs
|
|
196
|
+
.vector(bcs.U8)
|
|
203
197
|
.serialize(value)
|
|
204
198
|
.toBytes();
|
|
205
199
|
}
|
|
206
200
|
else {
|
|
207
|
-
|
|
201
|
+
W_ERROR(WErrors.InvalidParam, `Expected Uint8Array or array for ValueType.VecU8, got ${typeof value}`);
|
|
208
202
|
return new Uint8Array(0);
|
|
209
203
|
}
|
|
210
204
|
break;
|
|
211
|
-
case
|
|
205
|
+
case ValueType.VecU16:
|
|
212
206
|
if (!Array.isArray(value)) {
|
|
213
|
-
|
|
207
|
+
W_ERROR(WErrors.InvalidParam, `Expected array for ValueType.VecU16, got ${typeof value}`);
|
|
214
208
|
return new Uint8Array(0);
|
|
215
209
|
}
|
|
216
210
|
for (const item of value) {
|
|
217
|
-
if (!
|
|
218
|
-
|
|
211
|
+
if (!isValidU16(item)) {
|
|
212
|
+
W_ERROR(WErrors.InvalidParam, `Expected valid U16 in VecU16, got ${item}`);
|
|
219
213
|
return new Uint8Array(0);
|
|
220
214
|
}
|
|
221
215
|
}
|
|
222
|
-
serializedValue =
|
|
223
|
-
.vector(
|
|
216
|
+
serializedValue = bcs
|
|
217
|
+
.vector(bcs.U16)
|
|
224
218
|
.serialize(value)
|
|
225
219
|
.toBytes();
|
|
226
220
|
break;
|
|
227
|
-
case
|
|
221
|
+
case ValueType.VecU32:
|
|
228
222
|
if (!Array.isArray(value)) {
|
|
229
|
-
|
|
223
|
+
W_ERROR(WErrors.InvalidParam, `Expected array for ValueType.VecU32, got ${typeof value}`);
|
|
230
224
|
return new Uint8Array(0);
|
|
231
225
|
}
|
|
232
226
|
for (const item of value) {
|
|
233
|
-
if (!
|
|
234
|
-
|
|
227
|
+
if (!isValidU32(item)) {
|
|
228
|
+
W_ERROR(WErrors.InvalidParam, `Expected valid U32 in VecU32, got ${item}`);
|
|
235
229
|
return new Uint8Array(0);
|
|
236
230
|
}
|
|
237
231
|
}
|
|
238
|
-
serializedValue =
|
|
239
|
-
.vector(
|
|
232
|
+
serializedValue = bcs
|
|
233
|
+
.vector(bcs.U32)
|
|
240
234
|
.serialize(value)
|
|
241
235
|
.toBytes();
|
|
242
236
|
break;
|
|
243
|
-
case
|
|
237
|
+
case ValueType.VecU64:
|
|
244
238
|
if (!Array.isArray(value)) {
|
|
245
|
-
|
|
239
|
+
W_ERROR(WErrors.InvalidParam, `Expected array for ValueType.VecU64, got ${typeof value}`);
|
|
246
240
|
return new Uint8Array(0);
|
|
247
241
|
}
|
|
248
242
|
for (const item of value) {
|
|
249
|
-
if (!
|
|
250
|
-
|
|
243
|
+
if (!isValidU64(item)) {
|
|
244
|
+
W_ERROR(WErrors.InvalidParam, `Expected valid U64 in VecU64, got ${item}`);
|
|
251
245
|
return new Uint8Array(0);
|
|
252
246
|
}
|
|
253
247
|
}
|
|
254
248
|
const vecU64Values = value.map(toU64Value);
|
|
255
|
-
serializedValue =
|
|
256
|
-
.vector(
|
|
249
|
+
serializedValue = bcs
|
|
250
|
+
.vector(bcs.U64)
|
|
257
251
|
.serialize(vecU64Values)
|
|
258
252
|
.toBytes();
|
|
259
253
|
break;
|
|
260
|
-
case
|
|
254
|
+
case ValueType.VecU128:
|
|
261
255
|
if (!Array.isArray(value)) {
|
|
262
|
-
|
|
256
|
+
W_ERROR(WErrors.InvalidParam, `Expected array for ValueType.VecU128, got ${typeof value}`);
|
|
263
257
|
return new Uint8Array(0);
|
|
264
258
|
}
|
|
265
259
|
for (const item of value) {
|
|
266
|
-
if (!
|
|
267
|
-
|
|
260
|
+
if (!isValidU128(item)) {
|
|
261
|
+
W_ERROR(WErrors.InvalidParam, `Expected valid U128 in VecU128, got ${item}`);
|
|
268
262
|
return new Uint8Array(0);
|
|
269
263
|
}
|
|
270
264
|
}
|
|
271
265
|
const vecU128Values = value.map(toU128Value);
|
|
272
|
-
serializedValue =
|
|
273
|
-
.vector(
|
|
266
|
+
serializedValue = bcs
|
|
267
|
+
.vector(bcs.U128)
|
|
274
268
|
.serialize(vecU128Values)
|
|
275
269
|
.toBytes();
|
|
276
270
|
break;
|
|
277
|
-
case
|
|
271
|
+
case ValueType.VecU256:
|
|
278
272
|
if (!Array.isArray(value)) {
|
|
279
|
-
|
|
273
|
+
W_ERROR(WErrors.InvalidParam, `Expected array for ValueType.VecU256, got ${typeof value}`);
|
|
280
274
|
return new Uint8Array(0);
|
|
281
275
|
}
|
|
282
276
|
for (const item of value) {
|
|
283
|
-
if (!
|
|
284
|
-
|
|
277
|
+
if (!isValidU256(item)) {
|
|
278
|
+
W_ERROR(WErrors.InvalidParam, `Expected valid U256 in VecU256, got ${item}`);
|
|
285
279
|
return new Uint8Array(0);
|
|
286
280
|
}
|
|
287
281
|
}
|
|
288
282
|
const vecU256Values = value.map(toU256Value);
|
|
289
|
-
serializedValue =
|
|
290
|
-
.vector(
|
|
283
|
+
serializedValue = bcs
|
|
284
|
+
.vector(bcs.U256)
|
|
291
285
|
.serialize(vecU256Values)
|
|
292
286
|
.toBytes();
|
|
293
287
|
break;
|
|
294
|
-
case
|
|
288
|
+
case ValueType.VecVecU8:
|
|
295
289
|
if (!Array.isArray(value)) {
|
|
296
|
-
|
|
290
|
+
W_ERROR(WErrors.InvalidParam, `Expected array for ValueType.VecVecU8, got ${typeof value}`);
|
|
297
291
|
return new Uint8Array(0);
|
|
298
292
|
}
|
|
299
293
|
for (const item of value) {
|
|
300
294
|
if (!(item instanceof Uint8Array || Array.isArray(item))) {
|
|
301
|
-
|
|
295
|
+
W_ERROR(WErrors.InvalidParam, `Expected Uint8Array or array in VecVecU8, got ${typeof item}`);
|
|
302
296
|
return new Uint8Array(0);
|
|
303
297
|
}
|
|
304
298
|
if (Array.isArray(item)) {
|
|
305
299
|
for (const subItem of item) {
|
|
306
|
-
if (!
|
|
307
|
-
|
|
300
|
+
if (!isValidU8(subItem)) {
|
|
301
|
+
W_ERROR(WErrors.InvalidParam, `Expected valid U8 in VecVecU8, got ${subItem}`);
|
|
308
302
|
return new Uint8Array(0);
|
|
309
303
|
}
|
|
310
304
|
}
|
|
@@ -312,12 +306,12 @@ const valueToBcsBytes = async (valueType, value) => {
|
|
|
312
306
|
}
|
|
313
307
|
// 将 Uint8Array 转换为数组
|
|
314
308
|
const vecVecU8 = value.map((item) => item instanceof Uint8Array ? Array.from(item) : item);
|
|
315
|
-
serializedValue =
|
|
316
|
-
.vector(
|
|
309
|
+
serializedValue = bcs
|
|
310
|
+
.vector(bcs.vector(bcs.U8))
|
|
317
311
|
.serialize(vecVecU8)
|
|
318
312
|
.toBytes();
|
|
319
313
|
break;
|
|
320
|
-
case
|
|
314
|
+
case ValueType.Value:
|
|
321
315
|
// Value 类型是递归的,包含一个 ValueContainer
|
|
322
316
|
// 第一个字节是内部的 ValueType,后续字节是 BCS 序列化的值
|
|
323
317
|
const container = value;
|
|
@@ -325,19 +319,19 @@ const valueToBcsBytes = async (valueType, value) => {
|
|
|
325
319
|
typeof container !== "object" ||
|
|
326
320
|
!("valueType" in container) ||
|
|
327
321
|
!("value" in container)) {
|
|
328
|
-
|
|
322
|
+
W_ERROR(WErrors.InvalidParam, `Expected ValueContainer for ValueType.Value, got ${JSON.stringify(value)}`);
|
|
329
323
|
return new Uint8Array(0);
|
|
330
324
|
}
|
|
331
325
|
// 验证内部的 valueType 是否有效
|
|
332
|
-
if (!
|
|
333
|
-
|
|
326
|
+
if (!isValidValueType(container.valueType)) {
|
|
327
|
+
W_ERROR(WErrors.InvalidParam, `Invalid inner ValueType in ValueContainer: ${container.valueType}`);
|
|
334
328
|
return new Uint8Array(0);
|
|
335
329
|
}
|
|
336
330
|
// 递归序列化内部值
|
|
337
|
-
serializedValue = await
|
|
331
|
+
serializedValue = await valueToBcsBytes(container.valueType, container.value);
|
|
338
332
|
break;
|
|
339
333
|
default:
|
|
340
|
-
|
|
334
|
+
W_ERROR(WErrors.InvalidParam, `Unsupported ValueType: ${valueType}`);
|
|
341
335
|
return new Uint8Array(0);
|
|
342
336
|
}
|
|
343
337
|
// 合并结果
|
|
@@ -347,22 +341,21 @@ const valueToBcsBytes = async (valueType, value) => {
|
|
|
347
341
|
return finalResult;
|
|
348
342
|
}
|
|
349
343
|
catch (error) {
|
|
350
|
-
|
|
344
|
+
W_ERROR(WErrors.InvalidParam, `BCS serialization failed: ${error.message}`);
|
|
351
345
|
return new Uint8Array(0);
|
|
352
346
|
}
|
|
353
347
|
};
|
|
354
|
-
exports.valueToBcsBytes = valueToBcsBytes;
|
|
355
348
|
// 类型安全的反序列化函数
|
|
356
|
-
const bcsBytesToValue = (bytes, valueType) => {
|
|
349
|
+
export const bcsBytesToValue = (bytes, valueType) => {
|
|
357
350
|
if (bytes.length === 0) {
|
|
358
|
-
|
|
351
|
+
W_ERROR(WErrors.InvalidParam, "Empty bytes array");
|
|
359
352
|
return undefined;
|
|
360
353
|
}
|
|
361
354
|
// 获取 ValueType
|
|
362
355
|
const actualValueType = valueType ?? bytes[0];
|
|
363
356
|
// 验证 ValueType
|
|
364
|
-
if (!
|
|
365
|
-
|
|
357
|
+
if (!isValidValueType(actualValueType)) {
|
|
358
|
+
W_ERROR(WErrors.InvalidParam, `Invalid ValueType in bytes: ${actualValueType}`);
|
|
366
359
|
return undefined;
|
|
367
360
|
}
|
|
368
361
|
if (bytes.length < 2) {
|
|
@@ -372,63 +365,62 @@ const bcsBytesToValue = (bytes, valueType) => {
|
|
|
372
365
|
const dataBytes = bytes.slice(1);
|
|
373
366
|
try {
|
|
374
367
|
switch (actualValueType) {
|
|
375
|
-
case
|
|
376
|
-
return
|
|
377
|
-
case
|
|
378
|
-
return
|
|
379
|
-
case
|
|
380
|
-
return
|
|
381
|
-
case
|
|
382
|
-
return
|
|
383
|
-
case
|
|
384
|
-
return
|
|
385
|
-
case
|
|
386
|
-
return
|
|
387
|
-
case
|
|
388
|
-
return
|
|
389
|
-
case
|
|
390
|
-
return
|
|
391
|
-
case
|
|
392
|
-
return
|
|
393
|
-
case
|
|
394
|
-
return
|
|
395
|
-
case
|
|
396
|
-
const addresses =
|
|
368
|
+
case ValueType.Bool:
|
|
369
|
+
return bcs.Bool.parse(dataBytes);
|
|
370
|
+
case ValueType.Address:
|
|
371
|
+
return bcs.Address.parse(dataBytes);
|
|
372
|
+
case ValueType.String:
|
|
373
|
+
return bcs.String.parse(dataBytes);
|
|
374
|
+
case ValueType.U8:
|
|
375
|
+
return bcs.U8.parse(dataBytes);
|
|
376
|
+
case ValueType.U16:
|
|
377
|
+
return bcs.U16.parse(dataBytes);
|
|
378
|
+
case ValueType.U32:
|
|
379
|
+
return bcs.U32.parse(dataBytes);
|
|
380
|
+
case ValueType.U64:
|
|
381
|
+
return bcs.U64.parse(dataBytes);
|
|
382
|
+
case ValueType.U128:
|
|
383
|
+
return bcs.U128.parse(dataBytes);
|
|
384
|
+
case ValueType.U256:
|
|
385
|
+
return bcs.U256.parse(dataBytes);
|
|
386
|
+
case ValueType.VecBool:
|
|
387
|
+
return bcs.vector(bcs.Bool).parse(dataBytes);
|
|
388
|
+
case ValueType.VecAddress:
|
|
389
|
+
const addresses = bcs.vector(bcs.Address).parse(dataBytes);
|
|
397
390
|
return {
|
|
398
391
|
entities: addresses.map((addr) => ({
|
|
399
392
|
name_or_address: addr,
|
|
400
393
|
})),
|
|
401
394
|
};
|
|
402
|
-
case
|
|
403
|
-
return
|
|
404
|
-
case
|
|
405
|
-
return
|
|
406
|
-
case
|
|
407
|
-
return
|
|
408
|
-
case
|
|
409
|
-
return
|
|
410
|
-
case
|
|
411
|
-
return
|
|
412
|
-
case
|
|
413
|
-
return
|
|
414
|
-
case
|
|
415
|
-
return
|
|
416
|
-
case
|
|
417
|
-
return
|
|
395
|
+
case ValueType.VecString:
|
|
396
|
+
return bcs.vector(bcs.String).parse(dataBytes);
|
|
397
|
+
case ValueType.VecU8:
|
|
398
|
+
return bcs.vector(bcs.U8).parse(dataBytes);
|
|
399
|
+
case ValueType.VecU16:
|
|
400
|
+
return bcs.vector(bcs.U16).parse(dataBytes);
|
|
401
|
+
case ValueType.VecU32:
|
|
402
|
+
return bcs.vector(bcs.U32).parse(dataBytes);
|
|
403
|
+
case ValueType.VecU64:
|
|
404
|
+
return bcs.vector(bcs.U64).parse(dataBytes);
|
|
405
|
+
case ValueType.VecU128:
|
|
406
|
+
return bcs.vector(bcs.U128).parse(dataBytes);
|
|
407
|
+
case ValueType.VecU256:
|
|
408
|
+
return bcs.vector(bcs.U256).parse(dataBytes);
|
|
409
|
+
case ValueType.VecVecU8:
|
|
410
|
+
return bcs.vector(bcs.vector(bcs.U8)).parse(dataBytes);
|
|
418
411
|
default:
|
|
419
|
-
|
|
412
|
+
W_ERROR(WErrors.InvalidParam, `Unsupported ValueType for deserialization: ${actualValueType}`);
|
|
420
413
|
return undefined;
|
|
421
414
|
}
|
|
422
415
|
}
|
|
423
416
|
catch (error) {
|
|
424
|
-
|
|
417
|
+
W_ERROR(WErrors.InvalidParam, `BCS deserialization failed: ${error.message}`);
|
|
425
418
|
return undefined;
|
|
426
419
|
}
|
|
427
420
|
};
|
|
428
|
-
|
|
429
|
-
const parseObjectType = (chain_type, header = "payment::Payment") => {
|
|
421
|
+
export const parseObjectType = (chain_type, header = "payment::Payment") => {
|
|
430
422
|
header += "<";
|
|
431
|
-
if (chain_type &&
|
|
423
|
+
if (chain_type && isThisPackage(chain_type)) {
|
|
432
424
|
const i = chain_type.indexOf(header);
|
|
433
425
|
if (i > 0) {
|
|
434
426
|
const r = chain_type.slice(i + header.length, chain_type.length - 1);
|
|
@@ -437,9 +429,8 @@ const parseObjectType = (chain_type, header = "payment::Payment") => {
|
|
|
437
429
|
}
|
|
438
430
|
return undefined;
|
|
439
431
|
};
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
if (!type || !type.startsWith(common_js_1.PackageAddress)) {
|
|
432
|
+
export const parseTypeParameter = (type) => {
|
|
433
|
+
if (!type || !type.startsWith(PackageAddress)) {
|
|
443
434
|
return undefined;
|
|
444
435
|
}
|
|
445
436
|
const openIndex = type.indexOf("<");
|
|
@@ -449,13 +440,12 @@ const parseTypeParameter = (type) => {
|
|
|
449
440
|
}
|
|
450
441
|
return type.slice(openIndex + 1, closeIndex);
|
|
451
442
|
};
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
if (!type || !type.startsWith(common_js_1.PackageAddress)) {
|
|
443
|
+
export const extractCoinType = (type) => {
|
|
444
|
+
if (!type || !type.startsWith(PackageAddress)) {
|
|
455
445
|
return undefined;
|
|
456
446
|
}
|
|
457
447
|
// Match the pattern: PackageAddress::{}::{}<PackageAddress::coin::Coin<{}>>
|
|
458
|
-
const escapedPackageAddress =
|
|
448
|
+
const escapedPackageAddress = PackageAddress.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
459
449
|
const coinPattern = new RegExp(`${escapedPackageAddress}::[^:]+::[^<]+<${escapedPackageAddress}::coin::Coin<([^>]+)>>`);
|
|
460
450
|
const match = type.match(coinPattern);
|
|
461
451
|
if (match && match[1]) {
|
|
@@ -463,32 +453,31 @@ const extractCoinType = (type) => {
|
|
|
463
453
|
}
|
|
464
454
|
return undefined;
|
|
465
455
|
};
|
|
466
|
-
|
|
467
|
-
async function owner_receive(tx, object, // MachineObject | DemandObject | ServiceObject ...
|
|
456
|
+
export async function owner_receive(tx, object, // MachineObject | DemandObject | ServiceObject ...
|
|
468
457
|
permission, param, caller_type, fnBuilder, // machineFn | demandFn
|
|
469
458
|
passport) {
|
|
470
|
-
|
|
471
|
-
if (caller_type && !
|
|
472
|
-
|
|
459
|
+
validObjects([object, permission, passport]);
|
|
460
|
+
if (caller_type && !IsValidArgType(caller_type)) {
|
|
461
|
+
W_ERROR(WErrors.IsValidArgType, `caller_type ${caller_type} is invalid`);
|
|
473
462
|
}
|
|
474
463
|
// 处理ReceivedNormal[]类型
|
|
475
464
|
if (Array.isArray(param)) {
|
|
476
465
|
for (const item of param) {
|
|
477
|
-
if (!item.type || !
|
|
478
|
-
|
|
466
|
+
if (!item.type || !IsValidArgType(item.type)) {
|
|
467
|
+
W_ERROR(WErrors.IsValidArgType, `type ${item.type} is invalid`);
|
|
479
468
|
}
|
|
480
469
|
if (passport) {
|
|
481
|
-
const r = await
|
|
470
|
+
const r = await LocalMark.Instance().get_address(item.id);
|
|
482
471
|
if (!r) {
|
|
483
|
-
|
|
472
|
+
W_ERROR(WErrors.IsValidArgType, `Received ${item.id} is invalid`);
|
|
484
473
|
}
|
|
485
474
|
tx.moveCall({
|
|
486
475
|
target: fnBuilder("owner_receive_object_with_passport"),
|
|
487
476
|
arguments: [
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
477
|
+
toTxObject(tx, object),
|
|
478
|
+
toTxObject(tx, permission),
|
|
479
|
+
toTxObject(tx, passport),
|
|
480
|
+
toTxObject(tx, r),
|
|
492
481
|
],
|
|
493
482
|
typeArguments: caller_type
|
|
494
483
|
? [caller_type, item.type]
|
|
@@ -496,16 +485,16 @@ passport) {
|
|
|
496
485
|
});
|
|
497
486
|
}
|
|
498
487
|
else {
|
|
499
|
-
const r = await
|
|
488
|
+
const r = await LocalMark.Instance().get_address(item.id);
|
|
500
489
|
if (!r) {
|
|
501
|
-
|
|
490
|
+
W_ERROR(WErrors.IsValidArgType, `Received ${item.id} is invalid`);
|
|
502
491
|
}
|
|
503
492
|
tx.moveCall({
|
|
504
493
|
target: fnBuilder("owner_receive_object"),
|
|
505
494
|
arguments: [
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
495
|
+
toTxObject(tx, object),
|
|
496
|
+
toTxObject(tx, permission),
|
|
497
|
+
toTxObject(tx, r),
|
|
509
498
|
],
|
|
510
499
|
typeArguments: caller_type
|
|
511
500
|
? [caller_type, item.type]
|
|
@@ -518,31 +507,31 @@ passport) {
|
|
|
518
507
|
else {
|
|
519
508
|
const match = param.token_type.match(/CoinWrapper<([^>]+)>/);
|
|
520
509
|
if (!match) {
|
|
521
|
-
|
|
510
|
+
W_ERROR(WErrors.IsValidArgType, `Invalid CoinWrapper type: ${param.token_type}`);
|
|
522
511
|
}
|
|
523
512
|
const t = match[1];
|
|
524
|
-
if (!
|
|
525
|
-
|
|
513
|
+
if (!IsValidArgType(t)) {
|
|
514
|
+
W_ERROR(WErrors.IsValidArgType, `Invalid CoinWrapper type: ${t}`);
|
|
526
515
|
}
|
|
527
516
|
for (const item of param.received) {
|
|
528
517
|
// 这里假设item.type是CoinWrapper类型
|
|
529
518
|
// 从item.id和item.payment中获取地址
|
|
530
519
|
const [r, p] = await Promise.all([
|
|
531
|
-
|
|
532
|
-
|
|
520
|
+
LocalMark.Instance().get_address(item.id),
|
|
521
|
+
LocalMark.Instance().get_address(item.payment),
|
|
533
522
|
]);
|
|
534
523
|
if (!r || !p) {
|
|
535
|
-
|
|
524
|
+
W_ERROR(WErrors.IsValidArgType, `Received ${item.id} or Payment ${item.payment} is invalid`);
|
|
536
525
|
}
|
|
537
526
|
if (passport) {
|
|
538
527
|
tx.moveCall({
|
|
539
528
|
target: fnBuilder("owner_receive_with_passport"),
|
|
540
529
|
arguments: [
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
530
|
+
toTxObject(tx, object),
|
|
531
|
+
toTxObject(tx, permission),
|
|
532
|
+
toTxObject(tx, passport),
|
|
533
|
+
toTxObject(tx, r),
|
|
534
|
+
toTxObject(tx, p),
|
|
546
535
|
],
|
|
547
536
|
typeArguments: caller_type ? [caller_type, t] : [t],
|
|
548
537
|
});
|
|
@@ -551,10 +540,10 @@ passport) {
|
|
|
551
540
|
tx.moveCall({
|
|
552
541
|
target: fnBuilder("owner_receive"),
|
|
553
542
|
arguments: [
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
543
|
+
toTxObject(tx, object),
|
|
544
|
+
toTxObject(tx, permission),
|
|
545
|
+
toTxObject(tx, r),
|
|
546
|
+
toTxObject(tx, p),
|
|
558
547
|
],
|
|
559
548
|
typeArguments: caller_type ? [caller_type, t] : [t],
|
|
560
549
|
});
|
|
@@ -562,47 +551,45 @@ passport) {
|
|
|
562
551
|
}
|
|
563
552
|
}
|
|
564
553
|
}
|
|
565
|
-
function permission_set(tx, object, // MachineObject | DemandObject
|
|
554
|
+
export function permission_set(tx, object, // MachineObject | DemandObject
|
|
566
555
|
old_permission, new_permission, caller_type, fnBuilder) {
|
|
567
|
-
|
|
568
|
-
if (caller_type && !
|
|
569
|
-
|
|
556
|
+
validObjects([object, old_permission, new_permission]);
|
|
557
|
+
if (caller_type && !IsValidArgType(caller_type)) {
|
|
558
|
+
W_ERROR(WErrors.IsValidArgType, `caller_type ${caller_type} is invalid`);
|
|
570
559
|
}
|
|
571
560
|
tx.moveCall({
|
|
572
561
|
target: fnBuilder("permission_set"),
|
|
573
562
|
arguments: [
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
563
|
+
toTxObject(tx, object),
|
|
564
|
+
toTxObject(tx, old_permission),
|
|
565
|
+
toTxObject(tx, new_permission),
|
|
577
566
|
tx.object.mutRegistrar(),
|
|
578
567
|
tx.object.clock(),
|
|
579
568
|
],
|
|
580
569
|
typeArguments: caller_type ? [caller_type] : [],
|
|
581
570
|
});
|
|
582
571
|
}
|
|
583
|
-
const validObjects = (objects, allowNull = true) => {
|
|
572
|
+
export const validObjects = (objects, allowNull = true) => {
|
|
584
573
|
objects.forEach((item, index) => {
|
|
585
574
|
if (typeof item === "string" && item != null) {
|
|
586
|
-
if (!
|
|
587
|
-
|
|
575
|
+
if (!isValidAddress(item)) {
|
|
576
|
+
W_ERROR(WErrors.IsValidAddress, `Address is invalid: ${item}`);
|
|
588
577
|
}
|
|
589
578
|
}
|
|
590
579
|
else {
|
|
591
580
|
if (!allowNull && !item) {
|
|
592
|
-
|
|
581
|
+
W_ERROR(WErrors.IsValidAddress, `Address is required at index ${index} in objects ${objects}`);
|
|
593
582
|
}
|
|
594
583
|
}
|
|
595
584
|
});
|
|
596
585
|
};
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
return (0, sui_types_js_1.normalizeWowAddress)(value.toString(16));
|
|
586
|
+
export const uint2address = (value) => {
|
|
587
|
+
return normalizeWowAddress(value.toString(16));
|
|
600
588
|
};
|
|
601
|
-
exports.uint2address = uint2address;
|
|
602
589
|
// 将 whoData 转换为 Recipient 类型
|
|
603
|
-
const parseRecipient = (whoData) => {
|
|
590
|
+
export const parseRecipient = (whoData) => {
|
|
604
591
|
if (!whoData || !whoData.variant) {
|
|
605
|
-
|
|
592
|
+
W_ERROR(WErrors.ParseObjectContentFailed, `Invalid who data: ${JSON.stringify(whoData)}`);
|
|
606
593
|
}
|
|
607
594
|
if (whoData.variant === "GuardIdentifier" && whoData.fields) {
|
|
608
595
|
return {
|
|
@@ -622,8 +609,7 @@ const parseRecipient = (whoData) => {
|
|
|
622
609
|
};
|
|
623
610
|
}
|
|
624
611
|
else {
|
|
625
|
-
|
|
612
|
+
W_ERROR(WErrors.ParseObjectContentFailed, `Invalid who variant: ${whoData.variant}`);
|
|
626
613
|
}
|
|
627
614
|
};
|
|
628
|
-
exports.parseRecipient = parseRecipient;
|
|
629
615
|
//# sourceMappingURL=util.js.map
|