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
package/dist/cjs/w/util.js
CHANGED
|
@@ -1,587 +1 @@
|
|
|
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";
|
|
9
|
-
export const isValidValueContainer = (container) => {
|
|
10
|
-
try {
|
|
11
|
-
valueToBcsBytes(container.valueType, container.value);
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const toU64Value = (value) => {
|
|
19
|
-
if (typeof value === "string") {
|
|
20
|
-
if (value.length > 15) {
|
|
21
|
-
return BigInt(value);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
const num = parseInt(value, 10);
|
|
25
|
-
return Number.isInteger(num) ? num : BigInt(value);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return value;
|
|
29
|
-
};
|
|
30
|
-
const toU128Value = (value) => {
|
|
31
|
-
if (typeof value === "bigint") {
|
|
32
|
-
return value;
|
|
33
|
-
}
|
|
34
|
-
if (typeof value === "string") {
|
|
35
|
-
return BigInt(value);
|
|
36
|
-
}
|
|
37
|
-
return BigInt(value);
|
|
38
|
-
};
|
|
39
|
-
const toU256Value = (value) => {
|
|
40
|
-
if (typeof value === "bigint") {
|
|
41
|
-
return value;
|
|
42
|
-
}
|
|
43
|
-
if (typeof value === "string") {
|
|
44
|
-
return BigInt(value);
|
|
45
|
-
}
|
|
46
|
-
return BigInt(value);
|
|
47
|
-
};
|
|
48
|
-
export const valueToBcsBytes = async (valueType, value) => {
|
|
49
|
-
if (!isValidValueType(valueType)) {
|
|
50
|
-
W_ERROR(WErrors.InvalidParam, `Invalid ValueType: ${valueType}`);
|
|
51
|
-
return new Uint8Array(0);
|
|
52
|
-
}
|
|
53
|
-
const result = new Uint8Array(1);
|
|
54
|
-
result[0] = valueType;
|
|
55
|
-
try {
|
|
56
|
-
let serializedValue;
|
|
57
|
-
switch (valueType) {
|
|
58
|
-
case ValueType.Bool:
|
|
59
|
-
serializedValue = bcs.Bool.serialize(value).toBytes();
|
|
60
|
-
break;
|
|
61
|
-
case ValueType.Address: {
|
|
62
|
-
let addressValue;
|
|
63
|
-
let errorDetails = "";
|
|
64
|
-
if (typeof value === "string") {
|
|
65
|
-
addressValue = await GetAccountOrMark_Address({
|
|
66
|
-
name_or_address: value,
|
|
67
|
-
});
|
|
68
|
-
errorDetails = `string: ${value}`;
|
|
69
|
-
}
|
|
70
|
-
else if (value &&
|
|
71
|
-
typeof value === "object" &&
|
|
72
|
-
"name_or_address" in value) {
|
|
73
|
-
const accountOrMarkAddr = value;
|
|
74
|
-
addressValue =
|
|
75
|
-
await GetAccountOrMark_Address(accountOrMarkAddr);
|
|
76
|
-
errorDetails = `AccountOrMark_Address: ${JSON.stringify(value)}`;
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
addressValue = undefined;
|
|
80
|
-
errorDetails = `type: ${typeof value}, value: ${JSON.stringify(value)}`;
|
|
81
|
-
}
|
|
82
|
-
if (addressValue === undefined) {
|
|
83
|
-
W_ERROR(WErrors.InvalidParam, `Expected valid Address for ValueType.Address, but failed to resolve ${errorDetails}. Address may not exist in local accounts or marks.`);
|
|
84
|
-
return new Uint8Array(0);
|
|
85
|
-
}
|
|
86
|
-
serializedValue = bcs.Address.serialize(addressValue).toBytes();
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
case ValueType.String:
|
|
90
|
-
serializedValue = bcs.String.serialize(value).toBytes();
|
|
91
|
-
break;
|
|
92
|
-
case ValueType.U8:
|
|
93
|
-
if (!isValidU8(value)) {
|
|
94
|
-
W_ERROR(WErrors.InvalidParam, `Expected valid U8 for ValueType.U8, got ${JSON.stringify(value)}`);
|
|
95
|
-
return new Uint8Array(0);
|
|
96
|
-
}
|
|
97
|
-
serializedValue = bcs.U8.serialize(value).toBytes();
|
|
98
|
-
break;
|
|
99
|
-
case ValueType.U16:
|
|
100
|
-
if (!isValidU16(value)) {
|
|
101
|
-
W_ERROR(WErrors.InvalidParam, `Expected valid U16 for ValueType.U16, got ${JSON.stringify(value)}`);
|
|
102
|
-
return new Uint8Array(0);
|
|
103
|
-
}
|
|
104
|
-
serializedValue = bcs.U16.serialize(value).toBytes();
|
|
105
|
-
break;
|
|
106
|
-
case ValueType.U32:
|
|
107
|
-
if (!isValidU32(value)) {
|
|
108
|
-
W_ERROR(WErrors.InvalidParam, `Expected valid U32 for ValueType.U32, got ${JSON.stringify(value)}`);
|
|
109
|
-
return new Uint8Array(0);
|
|
110
|
-
}
|
|
111
|
-
serializedValue = bcs.U32.serialize(value).toBytes();
|
|
112
|
-
break;
|
|
113
|
-
case ValueType.U64:
|
|
114
|
-
if (!isValidU64(value)) {
|
|
115
|
-
W_ERROR(WErrors.InvalidParam, `Expected valid U64 for ValueType.U64, got ${JSON.stringify(value)}`);
|
|
116
|
-
return new Uint8Array(0);
|
|
117
|
-
}
|
|
118
|
-
serializedValue = bcs.U64.serialize(toU64Value(value)).toBytes();
|
|
119
|
-
break;
|
|
120
|
-
case ValueType.U128:
|
|
121
|
-
if (!isValidU128(value)) {
|
|
122
|
-
W_ERROR(WErrors.InvalidParam, `Expected valid U128 for ValueType.U128, got ${JSON.stringify(value)}`);
|
|
123
|
-
return new Uint8Array(0);
|
|
124
|
-
}
|
|
125
|
-
serializedValue = bcs.U128.serialize(toU128Value(value)).toBytes();
|
|
126
|
-
break;
|
|
127
|
-
case ValueType.U256:
|
|
128
|
-
if (!isValidU256(value)) {
|
|
129
|
-
W_ERROR(WErrors.InvalidParam, `Expected valid U256 for ValueType.U256, got ${JSON.stringify(value)}`);
|
|
130
|
-
return new Uint8Array(0);
|
|
131
|
-
}
|
|
132
|
-
serializedValue = bcs.U256.serialize(toU256Value(value)).toBytes();
|
|
133
|
-
break;
|
|
134
|
-
case ValueType.VecBool:
|
|
135
|
-
if (!Array.isArray(value)) {
|
|
136
|
-
W_ERROR(WErrors.InvalidParam, `Expected array for ValueType.VecBool, got ${typeof value}`);
|
|
137
|
-
return new Uint8Array(0);
|
|
138
|
-
}
|
|
139
|
-
for (const item of value) {
|
|
140
|
-
if (typeof item !== "boolean") {
|
|
141
|
-
W_ERROR(WErrors.InvalidParam, `Expected boolean in VecBool, got ${typeof item}`);
|
|
142
|
-
return new Uint8Array(0);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
serializedValue = bcs
|
|
146
|
-
.vector(bcs.Bool)
|
|
147
|
-
.serialize(value)
|
|
148
|
-
.toBytes();
|
|
149
|
-
break;
|
|
150
|
-
case ValueType.VecAddress:
|
|
151
|
-
const r = await GetManyAccountOrMark_Address(value);
|
|
152
|
-
serializedValue = bcs
|
|
153
|
-
.vector(bcs.Address)
|
|
154
|
-
.serialize(r)
|
|
155
|
-
.toBytes();
|
|
156
|
-
break;
|
|
157
|
-
case ValueType.VecString:
|
|
158
|
-
if (!Array.isArray(value)) {
|
|
159
|
-
W_ERROR(WErrors.InvalidParam, `Expected array for ValueType.VecString, got ${typeof value}`);
|
|
160
|
-
return new Uint8Array(0);
|
|
161
|
-
}
|
|
162
|
-
for (const item of value) {
|
|
163
|
-
if (typeof item !== "string") {
|
|
164
|
-
W_ERROR(WErrors.InvalidParam, `Expected string in VecString, got ${typeof item}`);
|
|
165
|
-
return new Uint8Array(0);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
serializedValue = bcs
|
|
169
|
-
.vector(bcs.String)
|
|
170
|
-
.serialize(value)
|
|
171
|
-
.toBytes();
|
|
172
|
-
break;
|
|
173
|
-
case ValueType.VecU8:
|
|
174
|
-
if (value instanceof Uint8Array) {
|
|
175
|
-
serializedValue = bcs
|
|
176
|
-
.vector(bcs.U8)
|
|
177
|
-
.serialize(Array.from(value))
|
|
178
|
-
.toBytes();
|
|
179
|
-
}
|
|
180
|
-
else if (Array.isArray(value)) {
|
|
181
|
-
for (const item of value) {
|
|
182
|
-
if (!isValidU8(item)) {
|
|
183
|
-
W_ERROR(WErrors.InvalidParam, `Expected valid U8 in VecU8, got ${item}`);
|
|
184
|
-
return new Uint8Array(0);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
serializedValue = bcs
|
|
188
|
-
.vector(bcs.U8)
|
|
189
|
-
.serialize(value)
|
|
190
|
-
.toBytes();
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
W_ERROR(WErrors.InvalidParam, `Expected Uint8Array or array for ValueType.VecU8, got ${typeof value}`);
|
|
194
|
-
return new Uint8Array(0);
|
|
195
|
-
}
|
|
196
|
-
break;
|
|
197
|
-
case ValueType.VecU16:
|
|
198
|
-
if (!Array.isArray(value)) {
|
|
199
|
-
W_ERROR(WErrors.InvalidParam, `Expected array for ValueType.VecU16, got ${typeof value}`);
|
|
200
|
-
return new Uint8Array(0);
|
|
201
|
-
}
|
|
202
|
-
for (const item of value) {
|
|
203
|
-
if (!isValidU16(item)) {
|
|
204
|
-
W_ERROR(WErrors.InvalidParam, `Expected valid U16 in VecU16, got ${item}`);
|
|
205
|
-
return new Uint8Array(0);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
serializedValue = bcs
|
|
209
|
-
.vector(bcs.U16)
|
|
210
|
-
.serialize(value)
|
|
211
|
-
.toBytes();
|
|
212
|
-
break;
|
|
213
|
-
case ValueType.VecU32:
|
|
214
|
-
if (!Array.isArray(value)) {
|
|
215
|
-
W_ERROR(WErrors.InvalidParam, `Expected array for ValueType.VecU32, got ${typeof value}`);
|
|
216
|
-
return new Uint8Array(0);
|
|
217
|
-
}
|
|
218
|
-
for (const item of value) {
|
|
219
|
-
if (!isValidU32(item)) {
|
|
220
|
-
W_ERROR(WErrors.InvalidParam, `Expected valid U32 in VecU32, got ${item}`);
|
|
221
|
-
return new Uint8Array(0);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
serializedValue = bcs
|
|
225
|
-
.vector(bcs.U32)
|
|
226
|
-
.serialize(value)
|
|
227
|
-
.toBytes();
|
|
228
|
-
break;
|
|
229
|
-
case ValueType.VecU64:
|
|
230
|
-
if (!Array.isArray(value)) {
|
|
231
|
-
W_ERROR(WErrors.InvalidParam, `Expected array for ValueType.VecU64, got ${typeof value}`);
|
|
232
|
-
return new Uint8Array(0);
|
|
233
|
-
}
|
|
234
|
-
for (const item of value) {
|
|
235
|
-
if (!isValidU64(item)) {
|
|
236
|
-
W_ERROR(WErrors.InvalidParam, `Expected valid U64 in VecU64, got ${item}`);
|
|
237
|
-
return new Uint8Array(0);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
const vecU64Values = value.map(toU64Value);
|
|
241
|
-
serializedValue = bcs
|
|
242
|
-
.vector(bcs.U64)
|
|
243
|
-
.serialize(vecU64Values)
|
|
244
|
-
.toBytes();
|
|
245
|
-
break;
|
|
246
|
-
case ValueType.VecU128:
|
|
247
|
-
if (!Array.isArray(value)) {
|
|
248
|
-
W_ERROR(WErrors.InvalidParam, `Expected array for ValueType.VecU128, got ${typeof value}`);
|
|
249
|
-
return new Uint8Array(0);
|
|
250
|
-
}
|
|
251
|
-
for (const item of value) {
|
|
252
|
-
if (!isValidU128(item)) {
|
|
253
|
-
W_ERROR(WErrors.InvalidParam, `Expected valid U128 in VecU128, got ${item}`);
|
|
254
|
-
return new Uint8Array(0);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
const vecU128Values = value.map(toU128Value);
|
|
258
|
-
serializedValue = bcs
|
|
259
|
-
.vector(bcs.U128)
|
|
260
|
-
.serialize(vecU128Values)
|
|
261
|
-
.toBytes();
|
|
262
|
-
break;
|
|
263
|
-
case ValueType.VecU256:
|
|
264
|
-
if (!Array.isArray(value)) {
|
|
265
|
-
W_ERROR(WErrors.InvalidParam, `Expected array for ValueType.VecU256, got ${typeof value}`);
|
|
266
|
-
return new Uint8Array(0);
|
|
267
|
-
}
|
|
268
|
-
for (const item of value) {
|
|
269
|
-
if (!isValidU256(item)) {
|
|
270
|
-
W_ERROR(WErrors.InvalidParam, `Expected valid U256 in VecU256, got ${item}`);
|
|
271
|
-
return new Uint8Array(0);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
const vecU256Values = value.map(toU256Value);
|
|
275
|
-
serializedValue = bcs
|
|
276
|
-
.vector(bcs.U256)
|
|
277
|
-
.serialize(vecU256Values)
|
|
278
|
-
.toBytes();
|
|
279
|
-
break;
|
|
280
|
-
case ValueType.VecVecU8:
|
|
281
|
-
if (!Array.isArray(value)) {
|
|
282
|
-
W_ERROR(WErrors.InvalidParam, `Expected array for ValueType.VecVecU8, got ${typeof value}`);
|
|
283
|
-
return new Uint8Array(0);
|
|
284
|
-
}
|
|
285
|
-
for (const item of value) {
|
|
286
|
-
if (!(item instanceof Uint8Array || Array.isArray(item))) {
|
|
287
|
-
W_ERROR(WErrors.InvalidParam, `Expected Uint8Array or array in VecVecU8, got ${typeof item}`);
|
|
288
|
-
return new Uint8Array(0);
|
|
289
|
-
}
|
|
290
|
-
if (Array.isArray(item)) {
|
|
291
|
-
for (const subItem of item) {
|
|
292
|
-
if (!isValidU8(subItem)) {
|
|
293
|
-
W_ERROR(WErrors.InvalidParam, `Expected valid U8 in VecVecU8, got ${subItem}`);
|
|
294
|
-
return new Uint8Array(0);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
const vecVecU8 = value.map((item) => item instanceof Uint8Array ? Array.from(item) : item);
|
|
300
|
-
serializedValue = bcs
|
|
301
|
-
.vector(bcs.vector(bcs.U8))
|
|
302
|
-
.serialize(vecVecU8)
|
|
303
|
-
.toBytes();
|
|
304
|
-
break;
|
|
305
|
-
case ValueType.Value:
|
|
306
|
-
const container = value;
|
|
307
|
-
if (!container ||
|
|
308
|
-
typeof container !== "object" ||
|
|
309
|
-
!("valueType" in container) ||
|
|
310
|
-
!("value" in container)) {
|
|
311
|
-
W_ERROR(WErrors.InvalidParam, `Expected ValueContainer for ValueType.Value, got ${JSON.stringify(value)}`);
|
|
312
|
-
return new Uint8Array(0);
|
|
313
|
-
}
|
|
314
|
-
if (!isValidValueType(container.valueType)) {
|
|
315
|
-
W_ERROR(WErrors.InvalidParam, `Invalid inner ValueType in ValueContainer: ${container.valueType}`);
|
|
316
|
-
return new Uint8Array(0);
|
|
317
|
-
}
|
|
318
|
-
serializedValue = await valueToBcsBytes(container.valueType, container.value);
|
|
319
|
-
break;
|
|
320
|
-
default:
|
|
321
|
-
W_ERROR(WErrors.InvalidParam, `Unsupported ValueType: ${valueType}`);
|
|
322
|
-
return new Uint8Array(0);
|
|
323
|
-
}
|
|
324
|
-
const finalResult = new Uint8Array(result.length + serializedValue.length);
|
|
325
|
-
finalResult.set(result, 0);
|
|
326
|
-
finalResult.set(serializedValue, 1);
|
|
327
|
-
return finalResult;
|
|
328
|
-
}
|
|
329
|
-
catch (error) {
|
|
330
|
-
W_ERROR(WErrors.InvalidParam, `BCS serialization failed: ${error.message}`);
|
|
331
|
-
return new Uint8Array(0);
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
export const bcsBytesToValue = (bytes, valueType) => {
|
|
335
|
-
if (bytes.length === 0) {
|
|
336
|
-
W_ERROR(WErrors.InvalidParam, "Empty bytes array");
|
|
337
|
-
return undefined;
|
|
338
|
-
}
|
|
339
|
-
const actualValueType = valueType ?? bytes[0];
|
|
340
|
-
if (!isValidValueType(actualValueType)) {
|
|
341
|
-
W_ERROR(WErrors.InvalidParam, `Invalid ValueType in bytes: ${actualValueType}`);
|
|
342
|
-
return undefined;
|
|
343
|
-
}
|
|
344
|
-
if (bytes.length < 2) {
|
|
345
|
-
return undefined;
|
|
346
|
-
}
|
|
347
|
-
const dataBytes = bytes.slice(1);
|
|
348
|
-
try {
|
|
349
|
-
switch (actualValueType) {
|
|
350
|
-
case ValueType.Bool:
|
|
351
|
-
return bcs.Bool.parse(dataBytes);
|
|
352
|
-
case ValueType.Address:
|
|
353
|
-
return bcs.Address.parse(dataBytes);
|
|
354
|
-
case ValueType.String:
|
|
355
|
-
return bcs.String.parse(dataBytes);
|
|
356
|
-
case ValueType.U8:
|
|
357
|
-
return bcs.U8.parse(dataBytes);
|
|
358
|
-
case ValueType.U16:
|
|
359
|
-
return bcs.U16.parse(dataBytes);
|
|
360
|
-
case ValueType.U32:
|
|
361
|
-
return bcs.U32.parse(dataBytes);
|
|
362
|
-
case ValueType.U64:
|
|
363
|
-
return bcs.U64.parse(dataBytes);
|
|
364
|
-
case ValueType.U128:
|
|
365
|
-
return bcs.U128.parse(dataBytes);
|
|
366
|
-
case ValueType.U256:
|
|
367
|
-
return bcs.U256.parse(dataBytes);
|
|
368
|
-
case ValueType.VecBool:
|
|
369
|
-
return bcs.vector(bcs.Bool).parse(dataBytes);
|
|
370
|
-
case ValueType.VecAddress:
|
|
371
|
-
const addresses = bcs.vector(bcs.Address).parse(dataBytes);
|
|
372
|
-
return {
|
|
373
|
-
entities: addresses.map((addr) => ({
|
|
374
|
-
name_or_address: addr,
|
|
375
|
-
})),
|
|
376
|
-
};
|
|
377
|
-
case ValueType.VecString:
|
|
378
|
-
return bcs.vector(bcs.String).parse(dataBytes);
|
|
379
|
-
case ValueType.VecU8:
|
|
380
|
-
return bcs.vector(bcs.U8).parse(dataBytes);
|
|
381
|
-
case ValueType.VecU16:
|
|
382
|
-
return bcs.vector(bcs.U16).parse(dataBytes);
|
|
383
|
-
case ValueType.VecU32:
|
|
384
|
-
return bcs.vector(bcs.U32).parse(dataBytes);
|
|
385
|
-
case ValueType.VecU64:
|
|
386
|
-
return bcs.vector(bcs.U64).parse(dataBytes);
|
|
387
|
-
case ValueType.VecU128:
|
|
388
|
-
return bcs.vector(bcs.U128).parse(dataBytes);
|
|
389
|
-
case ValueType.VecU256:
|
|
390
|
-
return bcs.vector(bcs.U256).parse(dataBytes);
|
|
391
|
-
case ValueType.VecVecU8:
|
|
392
|
-
return bcs.vector(bcs.vector(bcs.U8)).parse(dataBytes);
|
|
393
|
-
default:
|
|
394
|
-
W_ERROR(WErrors.InvalidParam, `Unsupported ValueType for deserialization: ${actualValueType}`);
|
|
395
|
-
return undefined;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
catch (error) {
|
|
399
|
-
W_ERROR(WErrors.InvalidParam, `BCS deserialization failed: ${error.message}`);
|
|
400
|
-
return undefined;
|
|
401
|
-
}
|
|
402
|
-
};
|
|
403
|
-
export const parseObjectType = (chain_type, header = "payment::Payment") => {
|
|
404
|
-
header += "<";
|
|
405
|
-
if (chain_type && isThisPackage(chain_type)) {
|
|
406
|
-
const i = chain_type.indexOf(header);
|
|
407
|
-
if (i > 0) {
|
|
408
|
-
const r = chain_type.slice(i + header.length, chain_type.length - 1);
|
|
409
|
-
return r;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
return undefined;
|
|
413
|
-
};
|
|
414
|
-
export const parseTypeParameter = (type) => {
|
|
415
|
-
if (!type || !type.startsWith(PackageAddress)) {
|
|
416
|
-
return undefined;
|
|
417
|
-
}
|
|
418
|
-
const openIndex = type.indexOf("<");
|
|
419
|
-
const closeIndex = type.lastIndexOf(">");
|
|
420
|
-
if (openIndex === -1 || closeIndex === -1 || openIndex >= closeIndex) {
|
|
421
|
-
return undefined;
|
|
422
|
-
}
|
|
423
|
-
return type.slice(openIndex + 1, closeIndex);
|
|
424
|
-
};
|
|
425
|
-
export const extractCoinType = (type) => {
|
|
426
|
-
if (!type || !type.startsWith(PackageAddress)) {
|
|
427
|
-
return undefined;
|
|
428
|
-
}
|
|
429
|
-
const escapedPackageAddress = PackageAddress.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
430
|
-
const coinPattern = new RegExp(`${escapedPackageAddress}::[^:]+::[^<]+<${escapedPackageAddress}::coin::Coin<([^>]+)>>`);
|
|
431
|
-
const match = type.match(coinPattern);
|
|
432
|
-
if (match && match[1]) {
|
|
433
|
-
return match[1];
|
|
434
|
-
}
|
|
435
|
-
return undefined;
|
|
436
|
-
};
|
|
437
|
-
export async function owner_receive(tx, object, permission, param, caller_type, fnBuilder, passport) {
|
|
438
|
-
validObjects([object, permission, passport]);
|
|
439
|
-
if (caller_type && !IsValidArgType(caller_type)) {
|
|
440
|
-
W_ERROR(WErrors.IsValidArgType, `caller_type ${caller_type} is invalid`);
|
|
441
|
-
}
|
|
442
|
-
if (Array.isArray(param)) {
|
|
443
|
-
for (const item of param) {
|
|
444
|
-
if (!item.type || !IsValidArgType(item.type)) {
|
|
445
|
-
W_ERROR(WErrors.IsValidArgType, `type ${item.type} is invalid`);
|
|
446
|
-
}
|
|
447
|
-
if (passport) {
|
|
448
|
-
const r = await LocalMark.Instance().get_address(item.id);
|
|
449
|
-
if (!r) {
|
|
450
|
-
W_ERROR(WErrors.IsValidArgType, `Received ${item.id} is invalid`);
|
|
451
|
-
}
|
|
452
|
-
tx.moveCall({
|
|
453
|
-
target: fnBuilder("owner_receive_object_with_passport"),
|
|
454
|
-
arguments: [
|
|
455
|
-
toTxObject(tx, object),
|
|
456
|
-
toTxObject(tx, permission),
|
|
457
|
-
toTxObject(tx, passport),
|
|
458
|
-
toTxObject(tx, r),
|
|
459
|
-
],
|
|
460
|
-
typeArguments: caller_type
|
|
461
|
-
? [caller_type, item.type]
|
|
462
|
-
: [item.type],
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
else {
|
|
466
|
-
const r = await LocalMark.Instance().get_address(item.id);
|
|
467
|
-
if (!r) {
|
|
468
|
-
W_ERROR(WErrors.IsValidArgType, `Received ${item.id} is invalid`);
|
|
469
|
-
}
|
|
470
|
-
tx.moveCall({
|
|
471
|
-
target: fnBuilder("owner_receive_object"),
|
|
472
|
-
arguments: [
|
|
473
|
-
toTxObject(tx, object),
|
|
474
|
-
toTxObject(tx, permission),
|
|
475
|
-
toTxObject(tx, r),
|
|
476
|
-
],
|
|
477
|
-
typeArguments: caller_type
|
|
478
|
-
? [caller_type, item.type]
|
|
479
|
-
: [item.type],
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
else {
|
|
485
|
-
const match = param.token_type.match(/CoinWrapper<([^>]+)>/);
|
|
486
|
-
if (!match) {
|
|
487
|
-
W_ERROR(WErrors.IsValidArgType, `Invalid CoinWrapper type: ${param.token_type}`);
|
|
488
|
-
}
|
|
489
|
-
const t = match[1];
|
|
490
|
-
if (!IsValidArgType(t)) {
|
|
491
|
-
W_ERROR(WErrors.IsValidArgType, `Invalid CoinWrapper type: ${t}`);
|
|
492
|
-
}
|
|
493
|
-
for (const item of param.received) {
|
|
494
|
-
const [r, p] = await Promise.all([
|
|
495
|
-
LocalMark.Instance().get_address(item.id),
|
|
496
|
-
LocalMark.Instance().get_address(item.payment),
|
|
497
|
-
]);
|
|
498
|
-
if (!r || !p) {
|
|
499
|
-
W_ERROR(WErrors.IsValidArgType, `Received ${item.id} or Payment ${item.payment} is invalid`);
|
|
500
|
-
}
|
|
501
|
-
if (passport) {
|
|
502
|
-
tx.moveCall({
|
|
503
|
-
target: fnBuilder("owner_receive_with_passport"),
|
|
504
|
-
arguments: [
|
|
505
|
-
toTxObject(tx, object),
|
|
506
|
-
toTxObject(tx, permission),
|
|
507
|
-
toTxObject(tx, passport),
|
|
508
|
-
toTxObject(tx, r),
|
|
509
|
-
toTxObject(tx, p),
|
|
510
|
-
],
|
|
511
|
-
typeArguments: caller_type ? [caller_type, t] : [t],
|
|
512
|
-
});
|
|
513
|
-
}
|
|
514
|
-
else {
|
|
515
|
-
tx.moveCall({
|
|
516
|
-
target: fnBuilder("owner_receive"),
|
|
517
|
-
arguments: [
|
|
518
|
-
toTxObject(tx, object),
|
|
519
|
-
toTxObject(tx, permission),
|
|
520
|
-
toTxObject(tx, r),
|
|
521
|
-
toTxObject(tx, p),
|
|
522
|
-
],
|
|
523
|
-
typeArguments: caller_type ? [caller_type, t] : [t],
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
export function permission_set(tx, object, old_permission, new_permission, caller_type, fnBuilder) {
|
|
530
|
-
validObjects([object, old_permission, new_permission]);
|
|
531
|
-
if (caller_type && !IsValidArgType(caller_type)) {
|
|
532
|
-
W_ERROR(WErrors.IsValidArgType, `caller_type ${caller_type} is invalid`);
|
|
533
|
-
}
|
|
534
|
-
tx.moveCall({
|
|
535
|
-
target: fnBuilder("permission_set"),
|
|
536
|
-
arguments: [
|
|
537
|
-
toTxObject(tx, object),
|
|
538
|
-
toTxObject(tx, old_permission),
|
|
539
|
-
toTxObject(tx, new_permission),
|
|
540
|
-
tx.object.mutRegistrar(),
|
|
541
|
-
tx.object.clock(),
|
|
542
|
-
],
|
|
543
|
-
typeArguments: caller_type ? [caller_type] : [],
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
export const validObjects = (objects, allowNull = true) => {
|
|
547
|
-
objects.forEach((item, index) => {
|
|
548
|
-
if (typeof item === "string" && item != null) {
|
|
549
|
-
if (!isValidAddress(item)) {
|
|
550
|
-
W_ERROR(WErrors.IsValidAddress, `Address is invalid: ${item}`);
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
else {
|
|
554
|
-
if (!allowNull && !item) {
|
|
555
|
-
W_ERROR(WErrors.IsValidAddress, `Address is required at index ${index} in objects ${objects}`);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
});
|
|
559
|
-
};
|
|
560
|
-
export const uint2address = (value) => {
|
|
561
|
-
return normalizeWowAddress(value.toString(16));
|
|
562
|
-
};
|
|
563
|
-
export const parseRecipient = (whoData) => {
|
|
564
|
-
if (!whoData || !whoData.variant) {
|
|
565
|
-
W_ERROR(WErrors.ParseObjectContentFailed, `Invalid who data: ${JSON.stringify(whoData)}`);
|
|
566
|
-
}
|
|
567
|
-
if (whoData.variant === "GuardIdentifier" && whoData.fields) {
|
|
568
|
-
return {
|
|
569
|
-
GuardIdentifier: Number(whoData.fields.pos0),
|
|
570
|
-
};
|
|
571
|
-
}
|
|
572
|
-
else if (whoData.variant === "Entity" && whoData.fields) {
|
|
573
|
-
return {
|
|
574
|
-
Entity: {
|
|
575
|
-
name_or_address: whoData.fields.pos0,
|
|
576
|
-
},
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
else if (whoData.variant === "Signer") {
|
|
580
|
-
return {
|
|
581
|
-
Signer: null,
|
|
582
|
-
};
|
|
583
|
-
}
|
|
584
|
-
else {
|
|
585
|
-
W_ERROR(WErrors.ParseObjectContentFailed, `Invalid who variant: ${whoData.variant}`);
|
|
586
|
-
}
|
|
587
|
-
};
|
|
1
|
+
import{bcs}from'../bcs/index.js';import{isThisPackage,IsValidArgType,isValidU128,isValidU16,isValidU256,isValidU32,isValidU64,isValidU8,isValidValueType,PackageAddress,ValueType}from'./common.js';import{W_ERROR,WErrors}from'./exception.js';import{GetAccountOrMark_Address,GetManyAccountOrMark_Address}from'./local/index.js';import{toTxObject}from'./common.js';import{normalizeWowAddress}from'../utils/sui-types.js';import{LocalMark}from'./local/local.js';import{isValidAddress}from'./local/local.js';export const isValidValueContainer=a=>{try{return valueToBcsBytes(a['valueType'],a['value']),!![];}catch{return![];}};const toU64Value=a=>{if(typeof a==='string'){if(a['length']>0xf)return BigInt(a);else{const b=parseInt(a,0xa);return Number['isInteger'](b)?b:BigInt(a);}}return a;},toU128Value=a=>{if(typeof a==='bigint')return a;if(typeof a==='string')return BigInt(a);return BigInt(a);},toU256Value=a=>{if(typeof a==='bigint')return a;if(typeof a==='string')return BigInt(a);return BigInt(a);};export const valueToBcsBytes=async(a,b)=>{if(!isValidValueType(a))return W_ERROR(WErrors['InvalidParam'],'Invalid\x20ValueType:\x20'+a),new Uint8Array(0x0);const c=new Uint8Array(0x1);c[0x0]=a;try{let d;switch(a){case ValueType['Bool']:d=bcs['Bool']['serialize'](b)['toBytes']();break;case ValueType['Address']:{let l,m='';if(typeof b==='string')l=await GetAccountOrMark_Address({'name_or_address':b}),m='string:\x20'+b;else{if(b&&typeof b==='object'&&'name_or_address'in b){const n=b;l=await GetAccountOrMark_Address(n),m='AccountOrMark_Address:\x20'+JSON['stringify'](b);}else l=undefined,m='type:\x20'+typeof b+',\x20value:\x20'+JSON['stringify'](b);}if(l===undefined)return W_ERROR(WErrors['InvalidParam'],'Expected\x20valid\x20Address\x20for\x20ValueType.Address,\x20but\x20failed\x20to\x20resolve\x20'+m+'.\x20Address\x20may\x20not\x20exist\x20in\x20local\x20accounts\x20or\x20marks.'),new Uint8Array(0x0);d=bcs['Address']['serialize'](l)['toBytes']();break;}case ValueType['String']:d=bcs['String']['serialize'](b)['toBytes']();break;case ValueType['U8']:if(!isValidU8(b))return W_ERROR(WErrors['InvalidParam'],'Expected\x20valid\x20U8\x20for\x20ValueType.U8,\x20got\x20'+JSON['stringify'](b)),new Uint8Array(0x0);d=bcs['U8']['serialize'](b)['toBytes']();break;case ValueType['U16']:if(!isValidU16(b))return W_ERROR(WErrors['InvalidParam'],'Expected\x20valid\x20U16\x20for\x20ValueType.U16,\x20got\x20'+JSON['stringify'](b)),new Uint8Array(0x0);d=bcs['U16']['serialize'](b)['toBytes']();break;case ValueType['U32']:if(!isValidU32(b))return W_ERROR(WErrors['InvalidParam'],'Expected\x20valid\x20U32\x20for\x20ValueType.U32,\x20got\x20'+JSON['stringify'](b)),new Uint8Array(0x0);d=bcs['U32']['serialize'](b)['toBytes']();break;case ValueType['U64']:if(!isValidU64(b))return W_ERROR(WErrors['InvalidParam'],'Expected\x20valid\x20U64\x20for\x20ValueType.U64,\x20got\x20'+JSON['stringify'](b)),new Uint8Array(0x0);d=bcs['U64']['serialize'](toU64Value(b))['toBytes']();break;case ValueType['U128']:if(!isValidU128(b))return W_ERROR(WErrors['InvalidParam'],'Expected\x20valid\x20U128\x20for\x20ValueType.U128,\x20got\x20'+JSON['stringify'](b)),new Uint8Array(0x0);d=bcs['U128']['serialize'](toU128Value(b))['toBytes']();break;case ValueType['U256']:if(!isValidU256(b))return W_ERROR(WErrors['InvalidParam'],'Expected\x20valid\x20U256\x20for\x20ValueType.U256,\x20got\x20'+JSON['stringify'](b)),new Uint8Array(0x0);d=bcs['U256']['serialize'](toU256Value(b))['toBytes']();break;case ValueType['VecBool']:if(!Array['isArray'](b))return W_ERROR(WErrors['InvalidParam'],'Expected\x20array\x20for\x20ValueType.VecBool,\x20got\x20'+typeof b),new Uint8Array(0x0);for(const o of b){if(typeof o!=='boolean')return W_ERROR(WErrors['InvalidParam'],'Expected\x20boolean\x20in\x20VecBool,\x20got\x20'+typeof o),new Uint8Array(0x0);}d=bcs['vector'](bcs['Bool'])['serialize'](b)['toBytes']();break;case ValueType['VecAddress']:const f=await GetManyAccountOrMark_Address(b);d=bcs['vector'](bcs['Address'])['serialize'](f)['toBytes']();break;case ValueType['VecString']:if(!Array['isArray'](b))return W_ERROR(WErrors['InvalidParam'],'Expected\x20array\x20for\x20ValueType.VecString,\x20got\x20'+typeof b),new Uint8Array(0x0);for(const p of b){if(typeof p!=='string')return W_ERROR(WErrors['InvalidParam'],'Expected\x20string\x20in\x20VecString,\x20got\x20'+typeof p),new Uint8Array(0x0);}d=bcs['vector'](bcs['String'])['serialize'](b)['toBytes']();break;case ValueType['VecU8']:if(b instanceof Uint8Array)d=bcs['vector'](bcs['U8'])['serialize'](Array['from'](b))['toBytes']();else{if(Array['isArray'](b)){for(const q of b){if(!isValidU8(q))return W_ERROR(WErrors['InvalidParam'],'Expected\x20valid\x20U8\x20in\x20VecU8,\x20got\x20'+q),new Uint8Array(0x0);}d=bcs['vector'](bcs['U8'])['serialize'](b)['toBytes']();}else return W_ERROR(WErrors['InvalidParam'],'Expected\x20Uint8Array\x20or\x20array\x20for\x20ValueType.VecU8,\x20got\x20'+typeof b),new Uint8Array(0x0);}break;case ValueType['VecU16']:if(!Array['isArray'](b))return W_ERROR(WErrors['InvalidParam'],'Expected\x20array\x20for\x20ValueType.VecU16,\x20got\x20'+typeof b),new Uint8Array(0x0);for(const s of b){if(!isValidU16(s))return W_ERROR(WErrors['InvalidParam'],'Expected\x20valid\x20U16\x20in\x20VecU16,\x20got\x20'+s),new Uint8Array(0x0);}d=bcs['vector'](bcs['U16'])['serialize'](b)['toBytes']();break;case ValueType['VecU32']:if(!Array['isArray'](b))return W_ERROR(WErrors['InvalidParam'],'Expected\x20array\x20for\x20ValueType.VecU32,\x20got\x20'+typeof b),new Uint8Array(0x0);for(const t of b){if(!isValidU32(t))return W_ERROR(WErrors['InvalidParam'],'Expected\x20valid\x20U32\x20in\x20VecU32,\x20got\x20'+t),new Uint8Array(0x0);}d=bcs['vector'](bcs['U32'])['serialize'](b)['toBytes']();break;case ValueType['VecU64']:if(!Array['isArray'](b))return W_ERROR(WErrors['InvalidParam'],'Expected\x20array\x20for\x20ValueType.VecU64,\x20got\x20'+typeof b),new Uint8Array(0x0);for(const u of b){if(!isValidU64(u))return W_ERROR(WErrors['InvalidParam'],'Expected\x20valid\x20U64\x20in\x20VecU64,\x20got\x20'+u),new Uint8Array(0x0);}const g=b['map'](toU64Value);d=bcs['vector'](bcs['U64'])['serialize'](g)['toBytes']();break;case ValueType['VecU128']:if(!Array['isArray'](b))return W_ERROR(WErrors['InvalidParam'],'Expected\x20array\x20for\x20ValueType.VecU128,\x20got\x20'+typeof b),new Uint8Array(0x0);for(const v of b){if(!isValidU128(v))return W_ERROR(WErrors['InvalidParam'],'Expected\x20valid\x20U128\x20in\x20VecU128,\x20got\x20'+v),new Uint8Array(0x0);}const h=b['map'](toU128Value);d=bcs['vector'](bcs['U128'])['serialize'](h)['toBytes']();break;case ValueType['VecU256']:if(!Array['isArray'](b))return W_ERROR(WErrors['InvalidParam'],'Expected\x20array\x20for\x20ValueType.VecU256,\x20got\x20'+typeof b),new Uint8Array(0x0);for(const w of b){if(!isValidU256(w))return W_ERROR(WErrors['InvalidParam'],'Expected\x20valid\x20U256\x20in\x20VecU256,\x20got\x20'+w),new Uint8Array(0x0);}const i=b['map'](toU256Value);d=bcs['vector'](bcs['U256'])['serialize'](i)['toBytes']();break;case ValueType['VecVecU8']:if(!Array['isArray'](b))return W_ERROR(WErrors['InvalidParam'],'Expected\x20array\x20for\x20ValueType.VecVecU8,\x20got\x20'+typeof b),new Uint8Array(0x0);for(const x of b){if(!(x instanceof Uint8Array||Array['isArray'](x)))return W_ERROR(WErrors['InvalidParam'],'Expected\x20Uint8Array\x20or\x20array\x20in\x20VecVecU8,\x20got\x20'+typeof x),new Uint8Array(0x0);if(Array['isArray'](x))for(const y of x){if(!isValidU8(y))return W_ERROR(WErrors['InvalidParam'],'Expected\x20valid\x20U8\x20in\x20VecVecU8,\x20got\x20'+y),new Uint8Array(0x0);}}const j=b['map'](z=>z instanceof Uint8Array?Array['from'](z):z);d=bcs['vector'](bcs['vector'](bcs['U8']))['serialize'](j)['toBytes']();break;case ValueType['Value']:const k=b;if(!k||typeof k!=='object'||!('valueType'in k)||!('value'in k))return W_ERROR(WErrors['InvalidParam'],'Expected\x20ValueContainer\x20for\x20ValueType.Value,\x20got\x20'+JSON['stringify'](b)),new Uint8Array(0x0);if(!isValidValueType(k['valueType']))return W_ERROR(WErrors['InvalidParam'],'Invalid\x20inner\x20ValueType\x20in\x20ValueContainer:\x20'+k['valueType']),new Uint8Array(0x0);d=await valueToBcsBytes(k['valueType'],k['value']);break;default:W_ERROR(WErrors['InvalidParam'],'Unsupported\x20ValueType:\x20'+a);return new Uint8Array(0x0);}const e=new Uint8Array(c['length']+d['length']);return e['set'](c,0x0),e['set'](d,0x1),e;}catch(z){return W_ERROR(WErrors['InvalidParam'],'BCS\x20serialization\x20failed:\x20'+z['message']),new Uint8Array(0x0);}};export const bcsBytesToValue=(a,b)=>{if(a['length']===0x0)return W_ERROR(WErrors['InvalidParam'],'Empty\x20bytes\x20array'),undefined;const c=b??a[0x0];if(!isValidValueType(c))return W_ERROR(WErrors['InvalidParam'],'Invalid\x20ValueType\x20in\x20bytes:\x20'+c),undefined;if(a['length']<0x2)return undefined;const d=a['slice'](0x1);try{switch(c){case ValueType['Bool']:return bcs['Bool']['parse'](d);case ValueType['Address']:return bcs['Address']['parse'](d);case ValueType['String']:return bcs['String']['parse'](d);case ValueType['U8']:return bcs['U8']['parse'](d);case ValueType['U16']:return bcs['U16']['parse'](d);case ValueType['U32']:return bcs['U32']['parse'](d);case ValueType['U64']:return bcs['U64']['parse'](d);case ValueType['U128']:return bcs['U128']['parse'](d);case ValueType['U256']:return bcs['U256']['parse'](d);case ValueType['VecBool']:return bcs['vector'](bcs['Bool'])['parse'](d);case ValueType['VecAddress']:const e=bcs['vector'](bcs['Address'])['parse'](d);return{'entities':e['map'](f=>({'name_or_address':f}))};case ValueType['VecString']:return bcs['vector'](bcs['String'])['parse'](d);case ValueType['VecU8']:return bcs['vector'](bcs['U8'])['parse'](d);case ValueType['VecU16']:return bcs['vector'](bcs['U16'])['parse'](d);case ValueType['VecU32']:return bcs['vector'](bcs['U32'])['parse'](d);case ValueType['VecU64']:return bcs['vector'](bcs['U64'])['parse'](d);case ValueType['VecU128']:return bcs['vector'](bcs['U128'])['parse'](d);case ValueType['VecU256']:return bcs['vector'](bcs['U256'])['parse'](d);case ValueType['VecVecU8']:return bcs['vector'](bcs['vector'](bcs['U8']))['parse'](d);default:W_ERROR(WErrors['InvalidParam'],'Unsupported\x20ValueType\x20for\x20deserialization:\x20'+c);return undefined;}}catch(f){return W_ERROR(WErrors['InvalidParam'],'BCS\x20deserialization\x20failed:\x20'+f['message']),undefined;}};export const parseObjectType=(a,b='payment::Payment')=>{b+='<';if(a&&isThisPackage(a)){const c=a['indexOf'](b);if(c>0x0){const d=a['slice'](c+b['length'],a['length']-0x1);return d;}}return undefined;};export const parseTypeParameter=a=>{if(!a||!a['startsWith'](PackageAddress))return undefined;const b=a['indexOf']('<'),c=a['lastIndexOf']('>');if(b===-0x1||c===-0x1||b>=c)return undefined;return a['slice'](b+0x1,c);};export const extractCoinType=a=>{if(!a||!a['startsWith'](PackageAddress))return undefined;const b=PackageAddress['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&'),c=new RegExp(b+'::[^:]+::[^<]+<'+b+'::coin::Coin<([^>]+)>>'),d=a['match'](c);if(d&&d[0x1])return d[0x1];return undefined;};export async function owner_receive(a,b,c,d,e,f,g){validObjects([b,c,g]);e&&!IsValidArgType(e)&&W_ERROR(WErrors['IsValidArgType'],'caller_type\x20'+e+'\x20is\x20invalid');if(Array['isArray'](d))for(const h of d){(!h['type']||!IsValidArgType(h['type']))&&W_ERROR(WErrors['IsValidArgType'],'type\x20'+h['type']+'\x20is\x20invalid');if(g){const i=await LocalMark['Instance']()['get_address'](h['id']);!i&&W_ERROR(WErrors['IsValidArgType'],'Received\x20'+h['id']+'\x20is\x20invalid'),a['moveCall']({'target':f('owner_receive_object_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,g),toTxObject(a,i)],'typeArguments':e?[e,h['type']]:[h['type']]});}else{const j=await LocalMark['Instance']()['get_address'](h['id']);!j&&W_ERROR(WErrors['IsValidArgType'],'Received\x20'+h['id']+'\x20is\x20invalid'),a['moveCall']({'target':f('owner_receive_object'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,j)],'typeArguments':e?[e,h['type']]:[h['type']]});}}else{const k=d['token_type']['match'](/CoinWrapper<([^>]+)>/);!k&&W_ERROR(WErrors['IsValidArgType'],'Invalid\x20CoinWrapper\x20type:\x20'+d['token_type']);const l=k[0x1];!IsValidArgType(l)&&W_ERROR(WErrors['IsValidArgType'],'Invalid\x20CoinWrapper\x20type:\x20'+l);for(const m of d['received']){const [n,o]=await Promise['all']([LocalMark['Instance']()['get_address'](m['id']),LocalMark['Instance']()['get_address'](m['payment'])]);(!n||!o)&&W_ERROR(WErrors['IsValidArgType'],'Received\x20'+m['id']+'\x20or\x20Payment\x20'+m['payment']+'\x20is\x20invalid'),g?a['moveCall']({'target':f('owner_receive_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,g),toTxObject(a,n),toTxObject(a,o)],'typeArguments':e?[e,l]:[l]}):a['moveCall']({'target':f('owner_receive'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,n),toTxObject(a,o)],'typeArguments':e?[e,l]:[l]});}}}export function permission_set(a,b,c,d,e,f){validObjects([b,c,d]),e&&!IsValidArgType(e)&&W_ERROR(WErrors['IsValidArgType'],'caller_type\x20'+e+'\x20is\x20invalid'),a['moveCall']({'target':f('permission_set'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,d),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':e?[e]:[]});}export const validObjects=(a,b=!![])=>{a['forEach']((c,d)=>{typeof c==='string'&&c!=null?!isValidAddress(c)&&W_ERROR(WErrors['IsValidAddress'],'Address\x20is\x20invalid:\x20'+c):!b&&!c&&W_ERROR(WErrors['IsValidAddress'],'Address\x20is\x20required\x20at\x20index\x20'+d+'\x20in\x20objects\x20'+a);});};export const uint2address=a=>{return normalizeWowAddress(a['toString'](0x10));};export const parseRecipient=a=>{(!a||!a['variant'])&&W_ERROR(WErrors['ParseObjectContentFailed'],'Invalid\x20who\x20data:\x20'+JSON['stringify'](a));if(a['variant']==='GuardIdentifier'&&a['fields'])return{'GuardIdentifier':Number(a['fields']['pos0'])};else{if(a['variant']==='Entity'&&a['fields'])return{'Entity':{'name_or_address':a['fields']['pos0']}};else{if(a['variant']==='Signer')return{'Signer':null};else W_ERROR(WErrors['ParseObjectContentFailed'],'Invalid\x20who\x20variant:\x20'+a['variant']);}}};
|