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
|
@@ -1,35 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright (c) Wowok.
|
|
3
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
exports.create = create;
|
|
17
|
-
exports.external_deposit = external_deposit;
|
|
18
|
-
exports.external_withdraw = external_withdraw;
|
|
19
|
-
exports.receive = receive;
|
|
20
|
-
exports.um_set = um_set;
|
|
21
|
-
const common_js_1 = require("../common.js");
|
|
22
|
-
const exception_js_1 = require("../exception.js");
|
|
23
|
-
const object_js_1 = require("../query/object.js");
|
|
24
|
-
const util_js_1 = require("../util.js");
|
|
25
|
-
const base_js_1 = require("./base.js");
|
|
26
|
-
const permission_js_1 = require("./permission.js");
|
|
27
|
-
const index_js_1 = require("../local/index.js");
|
|
28
|
-
const local_js_1 = require("../local/local.js");
|
|
29
|
-
const permission_js_2 = require("./permission.js");
|
|
30
|
-
const payment_js_1 = require("./payment.js");
|
|
31
|
-
const received_js_1 = require("../query/received.js");
|
|
32
|
-
class CallTreasury extends base_js_1.CallBase {
|
|
3
|
+
import { toTxObject, toTxString, isValidDescription, MAX_DESCRIPTION_LENGTH, isValidU64, PackageAddress, IsValidArgType, GetObjectExisted, GetObject, GetObjectDescription, isValidU8, treasuryFn, } from "../common.js";
|
|
4
|
+
import { W_ERROR, WErrors } from "../exception.js";
|
|
5
|
+
import { ObjectType } from "../query/object.js";
|
|
6
|
+
import { owner_receive, parseObjectType, validObjects } from "../util.js";
|
|
7
|
+
import { CallBase, getCoinParam } from "./base.js";
|
|
8
|
+
import { BuiltinPermissionIndex, newPermission } from "./permission.js";
|
|
9
|
+
import { GetAccountOrMark_Address } from "../local/index.js";
|
|
10
|
+
import { LocalMark } from "../local/local.js";
|
|
11
|
+
import { create as permissionCreate } from "./permission.js";
|
|
12
|
+
import { paymentInfo } from "./payment.js";
|
|
13
|
+
import { query_received } from "../query/received.js";
|
|
14
|
+
export class CallTreasury extends CallBase {
|
|
33
15
|
data;
|
|
34
16
|
object_address = undefined;
|
|
35
17
|
permission_address = undefined;
|
|
@@ -42,28 +24,28 @@ class CallTreasury extends base_js_1.CallBase {
|
|
|
42
24
|
async prepare(env) {
|
|
43
25
|
await super.prepare(env);
|
|
44
26
|
if (!this.object_address) {
|
|
45
|
-
this.object_address = await
|
|
27
|
+
this.object_address = await GetObjectExisted(this.data?.object);
|
|
46
28
|
}
|
|
47
29
|
if (this.object_address) {
|
|
48
|
-
await this.update_content(env,
|
|
30
|
+
await this.update_content(env, ObjectType.Treasury, this.object_address);
|
|
49
31
|
if (!this.content)
|
|
50
|
-
|
|
32
|
+
W_ERROR(WErrors.InvalidParam, "CallTreasury_Data.data.object:" + this.object_address);
|
|
51
33
|
this.permission_address = this.content.permission;
|
|
52
|
-
this.parameter_type =
|
|
34
|
+
this.parameter_type = parseObjectType(this.content.type_raw, "treasury::Treasury");
|
|
53
35
|
if (!this.permission_address) {
|
|
54
|
-
|
|
36
|
+
W_ERROR(WErrors.InvalidParam, "CallTreasury_Data.data.object.permission is empty");
|
|
55
37
|
}
|
|
56
|
-
if (!
|
|
57
|
-
|
|
38
|
+
if (!IsValidArgType(this.parameter_type)) {
|
|
39
|
+
W_ERROR(WErrors.IsValidArgType, "CallTreasury_Data.data.object.type_parameter is empty");
|
|
58
40
|
}
|
|
59
41
|
}
|
|
60
42
|
else {
|
|
61
|
-
const n =
|
|
62
|
-
this.permission_address = await
|
|
63
|
-
this.new_permission_description =
|
|
43
|
+
const n = GetObject(this.data.object);
|
|
44
|
+
this.permission_address = await GetObjectExisted(n?.permission);
|
|
45
|
+
this.new_permission_description = GetObjectDescription(n?.permission);
|
|
64
46
|
this.parameter_type = n?.type_parameter;
|
|
65
|
-
if (!
|
|
66
|
-
|
|
47
|
+
if (!IsValidArgType(this.parameter_type)) {
|
|
48
|
+
W_ERROR(WErrors.IsValidArgType, "CallTreasury_Data.data.object.type_parameter invalid");
|
|
67
49
|
}
|
|
68
50
|
}
|
|
69
51
|
}
|
|
@@ -82,30 +64,30 @@ class CallTreasury extends base_js_1.CallBase {
|
|
|
82
64
|
}
|
|
83
65
|
};
|
|
84
66
|
if (this.permission_address && !this.object_address) {
|
|
85
|
-
add_perm(
|
|
67
|
+
add_perm(BuiltinPermissionIndex.TREASURY_NEW);
|
|
86
68
|
}
|
|
87
69
|
if (this.permission_address &&
|
|
88
70
|
this.data?.description != null &&
|
|
89
71
|
this.object_address) {
|
|
90
|
-
add_perm(
|
|
72
|
+
add_perm(BuiltinPermissionIndex.TREASURY_DESCRIPTION);
|
|
91
73
|
}
|
|
92
74
|
if (this.permission_address && this.data?.receive != null) {
|
|
93
|
-
add_perm(
|
|
75
|
+
add_perm(BuiltinPermissionIndex.TREASURY_RECEIVE);
|
|
94
76
|
}
|
|
95
77
|
if (this.data?.deposit != null) {
|
|
96
78
|
if (this.data.deposit.by_external_deposit_guard) {
|
|
97
|
-
const guard = await
|
|
79
|
+
const guard = await LocalMark.Instance().get_address(this.data.deposit.by_external_deposit_guard);
|
|
98
80
|
if (guard) {
|
|
99
81
|
add_guard(guard);
|
|
100
82
|
this.data.deposit.by_external_deposit_guard = guard;
|
|
101
83
|
}
|
|
102
84
|
else {
|
|
103
|
-
|
|
85
|
+
W_ERROR(WErrors.InvalidParam, `external_deposit_guard ${this.data.deposit.by_external_deposit_guard} not found`);
|
|
104
86
|
}
|
|
105
87
|
}
|
|
106
88
|
else {
|
|
107
89
|
if (this.permission_address) {
|
|
108
|
-
add_perm(
|
|
90
|
+
add_perm(BuiltinPermissionIndex.TREASURY_DEPOSIT);
|
|
109
91
|
}
|
|
110
92
|
}
|
|
111
93
|
}
|
|
@@ -114,34 +96,34 @@ class CallTreasury extends base_js_1.CallBase {
|
|
|
114
96
|
if (withdraw && withdraw.amount) {
|
|
115
97
|
if ("fixed" in withdraw.amount) {
|
|
116
98
|
if (this.permission_address) {
|
|
117
|
-
add_perm(
|
|
99
|
+
add_perm(BuiltinPermissionIndex.TREASURY_WITHDRAW);
|
|
118
100
|
}
|
|
119
101
|
}
|
|
120
102
|
else if ("by_external_withdraw_guard" in withdraw.amount) {
|
|
121
|
-
const guard = await
|
|
103
|
+
const guard = await LocalMark.Instance().get_address(withdraw.amount.by_external_withdraw_guard);
|
|
122
104
|
if (guard) {
|
|
123
105
|
withdraw.amount.by_external_withdraw_guard = guard;
|
|
124
106
|
add_guard(guard);
|
|
125
107
|
}
|
|
126
108
|
else {
|
|
127
|
-
|
|
109
|
+
W_ERROR(WErrors.InvalidParam, `by_external_withdraw_guard ${withdraw.amount.by_external_withdraw_guard} not found`);
|
|
128
110
|
}
|
|
129
111
|
}
|
|
130
112
|
}
|
|
131
113
|
}
|
|
132
114
|
if (this.permission_address &&
|
|
133
115
|
this.data?.external_deposit_guard != null) {
|
|
134
|
-
add_perm(
|
|
116
|
+
add_perm(BuiltinPermissionIndex.TREASURY_EXTERNAL_DEPOSIT_GUARD);
|
|
135
117
|
}
|
|
136
118
|
if (this.permission_address &&
|
|
137
119
|
this.data?.external_withdraw_guard != null) {
|
|
138
|
-
add_perm(
|
|
120
|
+
add_perm(BuiltinPermissionIndex.TREASURY_EXTERNAL_WITHDRAW_GUARD);
|
|
139
121
|
}
|
|
140
122
|
if (this.permission_address && this.data?.owner_receive != null) {
|
|
141
|
-
add_perm(
|
|
123
|
+
add_perm(BuiltinPermissionIndex.TREASURY_OWNER_RECEIVE);
|
|
142
124
|
}
|
|
143
125
|
if (this.permission_address && this.data?.um !== undefined) {
|
|
144
|
-
add_perm(
|
|
126
|
+
add_perm(BuiltinPermissionIndex.TREASURY_UM);
|
|
145
127
|
}
|
|
146
128
|
if (this.permission_address || guards.length > 0) {
|
|
147
129
|
return await this.check_permission_and_call(env, this.permission_address, perms, guards);
|
|
@@ -154,28 +136,28 @@ class CallTreasury extends base_js_1.CallBase {
|
|
|
154
136
|
const content = this.content;
|
|
155
137
|
if (!this.object_address) {
|
|
156
138
|
if (!permission) {
|
|
157
|
-
permission =
|
|
139
|
+
permission = newPermission(tx, this.new_permission_description ?? "");
|
|
158
140
|
}
|
|
159
141
|
if (permission && this.parameter_type) {
|
|
160
142
|
object = newTreasury(tx, this.parameter_type, permission, this.data?.description ?? "", passport);
|
|
161
143
|
}
|
|
162
144
|
}
|
|
163
145
|
if (!object || !permission) {
|
|
164
|
-
|
|
146
|
+
W_ERROR(WErrors.InvalidParam, "CallTreasury_Data.data.object:" + this.object_address);
|
|
165
147
|
}
|
|
166
148
|
if (this.data.description != null && !this.object_address) {
|
|
167
149
|
description_set(tx, object, this.parameter_type, permission, this.data.description, passport);
|
|
168
150
|
}
|
|
169
151
|
if (this.data.receive != null && this.object_address) {
|
|
170
152
|
if (this.data.receive === "recently") {
|
|
171
|
-
const received = await
|
|
153
|
+
const received = await query_received({
|
|
172
154
|
object: this.object_address,
|
|
173
155
|
network: env.network,
|
|
174
156
|
no_cache: env.no_cache,
|
|
175
157
|
});
|
|
176
158
|
// 检查received的类型,如果是ReceivedNormal[],需要转换为ReceivedBalance
|
|
177
159
|
if (Array.isArray(received)) {
|
|
178
|
-
|
|
160
|
+
W_ERROR(WErrors.InvalidParam, "CallAllocation_Data.data.received_coins: received is ReceivedNormal[]");
|
|
179
161
|
}
|
|
180
162
|
else {
|
|
181
163
|
// 如果是ReceivedBalance类型,直接赋值
|
|
@@ -186,18 +168,18 @@ class CallTreasury extends base_js_1.CallBase {
|
|
|
186
168
|
"received" in this.data.receive &&
|
|
187
169
|
this.data.receive.received?.length > 0) {
|
|
188
170
|
if (this.data.receive.token_type !== this.parameter_type) {
|
|
189
|
-
|
|
171
|
+
W_ERROR(WErrors.InvalidParam, `token_type ${this.data.receive.token_type} is not equal to parameter_type ${this.parameter_type}`);
|
|
190
172
|
}
|
|
191
173
|
for (const item of this.data.receive.received) {
|
|
192
174
|
const [received_object, payment_object] = await Promise.all([
|
|
193
|
-
|
|
194
|
-
|
|
175
|
+
LocalMark.Instance().get_address(item.id),
|
|
176
|
+
LocalMark.Instance().get_address(item.payment),
|
|
195
177
|
]);
|
|
196
178
|
if (received_object && payment_object) {
|
|
197
179
|
receive(tx, object, this.parameter_type, permission, received_object, payment_object, passport);
|
|
198
180
|
}
|
|
199
181
|
else {
|
|
200
|
-
|
|
182
|
+
W_ERROR(WErrors.IsValidArgType, `Receive object ${item.id} or payment object ${item.payment} not found`);
|
|
201
183
|
}
|
|
202
184
|
}
|
|
203
185
|
}
|
|
@@ -205,23 +187,23 @@ class CallTreasury extends base_js_1.CallBase {
|
|
|
205
187
|
if (this.data.deposit != null) {
|
|
206
188
|
if (this.data.deposit.by_external_deposit_guard) {
|
|
207
189
|
if (!passport) {
|
|
208
|
-
|
|
190
|
+
W_ERROR(WErrors.InvalidParam, "Passport is required for external deposit");
|
|
209
191
|
}
|
|
210
|
-
await this.new_with_mark(env, tx,
|
|
192
|
+
await this.new_with_mark(env, tx, ObjectType.Payment, await external_deposit(env, tx, object, this.parameter_type, passport, this.data.deposit.by_external_deposit_guard, this.data.deposit.coin, this.data.deposit.payment_info), this.data.deposit.namedNewPayment);
|
|
211
193
|
}
|
|
212
194
|
else {
|
|
213
|
-
await this.new_with_mark(env, tx,
|
|
195
|
+
await this.new_with_mark(env, tx, ObjectType.Payment, await deposit(env, tx, object, this.parameter_type, permission, this.data.deposit.coin, this.data.deposit.payment_info, passport), this.data.deposit.namedNewPayment);
|
|
214
196
|
}
|
|
215
197
|
}
|
|
216
198
|
if (this.data.withdraw != null && this.data.withdraw.amount) {
|
|
217
199
|
if ("fixed" in this.data.withdraw.amount) {
|
|
218
|
-
await this.new_with_mark(env, tx,
|
|
200
|
+
await this.new_with_mark(env, tx, ObjectType.Payment, await withdraw(env, tx, object, this.parameter_type, permission, this.data.withdraw.amount.fixed, this.data.withdraw.recipient, this.data.withdraw.payment_info, passport), this.data.withdraw.namedNewPayment);
|
|
219
201
|
}
|
|
220
202
|
else if ("by_external_withdraw_guard" in this.data.withdraw.amount) {
|
|
221
203
|
if (!passport) {
|
|
222
|
-
|
|
204
|
+
W_ERROR(WErrors.InvalidParam, "Passport is required for external withdraw");
|
|
223
205
|
}
|
|
224
|
-
await this.new_with_mark(env, tx,
|
|
206
|
+
await this.new_with_mark(env, tx, ObjectType.Payment, await external_withdraw(env, tx, object, this.parameter_type, passport, this.data.withdraw.amount.by_external_withdraw_guard, this.data.withdraw.recipient, this.data.withdraw.payment_info), this.data.withdraw.namedNewPayment);
|
|
225
207
|
}
|
|
226
208
|
}
|
|
227
209
|
if (this.data.external_deposit_guard != null) {
|
|
@@ -231,7 +213,7 @@ class CallTreasury extends base_js_1.CallBase {
|
|
|
231
213
|
if (this.data.external_deposit_guard.op === "set") {
|
|
232
214
|
external_deposit_guard_clear(tx, object, this.parameter_type, permission, passport);
|
|
233
215
|
}
|
|
234
|
-
await external_deposit_guard_add(tx, object, this.parameter_type, permission, this.data.external_deposit_guard.guards,
|
|
216
|
+
await external_deposit_guard_add(tx, object, this.parameter_type, permission, this.data.external_deposit_guard.guards, MAX_EXTERNAL_DEPOSIT_GUARD_COUNT -
|
|
235
217
|
(content?.external_deposit_guard?.length ?? 0), passport);
|
|
236
218
|
break;
|
|
237
219
|
}
|
|
@@ -252,7 +234,7 @@ class CallTreasury extends base_js_1.CallBase {
|
|
|
252
234
|
if (this.data.external_withdraw_guard.op === "set") {
|
|
253
235
|
external_withdraw_guard_clear(tx, object, this.parameter_type, permission, passport);
|
|
254
236
|
}
|
|
255
|
-
await external_withdraw_guard_add(tx, object, this.parameter_type, permission, this.data.external_withdraw_guard.guards,
|
|
237
|
+
await external_withdraw_guard_add(tx, object, this.parameter_type, permission, this.data.external_withdraw_guard.guards, MAX_EXTERNAL_WITHDRAW_GUARD_COUNT -
|
|
256
238
|
(content?.external_withdraw_guard?.length ?? 0), passport);
|
|
257
239
|
break;
|
|
258
240
|
}
|
|
@@ -268,7 +250,7 @@ class CallTreasury extends base_js_1.CallBase {
|
|
|
268
250
|
}
|
|
269
251
|
if (this.data.owner_receive != null && this.object_address) {
|
|
270
252
|
if (this.data.owner_receive === "recently") {
|
|
271
|
-
this.data.owner_receive = await
|
|
253
|
+
this.data.owner_receive = await query_received({
|
|
272
254
|
object: this.object_address,
|
|
273
255
|
all_type: true,
|
|
274
256
|
network: env.network,
|
|
@@ -276,52 +258,51 @@ class CallTreasury extends base_js_1.CallBase {
|
|
|
276
258
|
});
|
|
277
259
|
}
|
|
278
260
|
// owner_receive 中完成地址查询
|
|
279
|
-
await
|
|
261
|
+
await owner_receive(tx, object, permission, this.data.owner_receive, this.parameter_type, (name) => `${PackageAddress}::treasury::${name}`, passport);
|
|
280
262
|
}
|
|
281
263
|
// 处理 um
|
|
282
264
|
if (this.data.um !== undefined) {
|
|
283
265
|
let um_address = null;
|
|
284
266
|
if (this.data.um) {
|
|
285
267
|
um_address =
|
|
286
|
-
(await
|
|
268
|
+
(await LocalMark.Instance().get_address(this.data.um)) ||
|
|
287
269
|
null;
|
|
288
270
|
if (!um_address) {
|
|
289
|
-
|
|
271
|
+
W_ERROR(WErrors.InvalidParam, "CallTreasury_Data.data.um:" + this.data.um);
|
|
290
272
|
}
|
|
291
273
|
}
|
|
292
274
|
um_set(tx, object, this.parameter_type, permission, um_address, passport);
|
|
293
275
|
}
|
|
294
276
|
if (!this.permission_address) {
|
|
295
|
-
const p =
|
|
296
|
-
await this.new_with_mark(env, tx,
|
|
277
|
+
const p = GetObject(this.data?.object);
|
|
278
|
+
await this.new_with_mark(env, tx, ObjectType.Permission, permissionCreate(tx, permission), GetObject(p.permission));
|
|
297
279
|
}
|
|
298
280
|
if (!this.object_address) {
|
|
299
|
-
await this.new_with_mark(env, tx,
|
|
281
|
+
await this.new_with_mark(env, tx, ObjectType.Treasury, create(tx, object, this.parameter_type), GetObject(this.data?.object));
|
|
300
282
|
}
|
|
301
283
|
}
|
|
302
284
|
}
|
|
303
|
-
exports.CallTreasury = CallTreasury;
|
|
304
285
|
// ================================================
|
|
305
286
|
// 常量定义
|
|
306
|
-
|
|
307
|
-
|
|
287
|
+
export const MAX_EXTERNAL_DEPOSIT_GUARD_COUNT = 100;
|
|
288
|
+
export const MAX_EXTERNAL_WITHDRAW_GUARD_COUNT = 200;
|
|
308
289
|
// ================================================
|
|
309
290
|
// 构造函数和设置函数
|
|
310
|
-
function newTreasury(tx, treasury_type, permission, description, passport) {
|
|
311
|
-
|
|
312
|
-
if (typeof description === "string" && !
|
|
313
|
-
|
|
291
|
+
export function newTreasury(tx, treasury_type, permission, description, passport) {
|
|
292
|
+
validObjects([permission, passport]);
|
|
293
|
+
if (typeof description === "string" && !isValidDescription(description)) {
|
|
294
|
+
W_ERROR(WErrors.IsValidDescription, `Description exceeds maximum length ${MAX_DESCRIPTION_LENGTH}`);
|
|
314
295
|
}
|
|
315
|
-
if (!
|
|
316
|
-
|
|
296
|
+
if (!IsValidArgType(treasury_type)) {
|
|
297
|
+
W_ERROR(WErrors.InvalidParam, `New treasury type ${treasury_type} is not valid`);
|
|
317
298
|
}
|
|
318
299
|
if (passport) {
|
|
319
300
|
return tx.moveCall({
|
|
320
|
-
target:
|
|
301
|
+
target: treasuryFn("new_with_passport"),
|
|
321
302
|
arguments: [
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
303
|
+
toTxObject(tx, permission),
|
|
304
|
+
toTxObject(tx, passport),
|
|
305
|
+
toTxString(tx, description),
|
|
325
306
|
tx.object.mutRegistrar(),
|
|
326
307
|
tx.object.clock(),
|
|
327
308
|
],
|
|
@@ -330,10 +311,10 @@ function newTreasury(tx, treasury_type, permission, description, passport) {
|
|
|
330
311
|
}
|
|
331
312
|
else {
|
|
332
313
|
return tx.moveCall({
|
|
333
|
-
target:
|
|
314
|
+
target: treasuryFn("new"),
|
|
334
315
|
arguments: [
|
|
335
|
-
|
|
336
|
-
|
|
316
|
+
toTxObject(tx, permission),
|
|
317
|
+
toTxString(tx, description),
|
|
337
318
|
tx.object.mutRegistrar(),
|
|
338
319
|
tx.object.clock(),
|
|
339
320
|
],
|
|
@@ -341,52 +322,52 @@ function newTreasury(tx, treasury_type, permission, description, passport) {
|
|
|
341
322
|
});
|
|
342
323
|
}
|
|
343
324
|
}
|
|
344
|
-
function description_set(tx, treasury, treasury_type, permission, description, passport) {
|
|
345
|
-
|
|
346
|
-
if (typeof description === "string" && !
|
|
347
|
-
|
|
325
|
+
export function description_set(tx, treasury, treasury_type, permission, description, passport) {
|
|
326
|
+
validObjects([treasury, permission, passport]);
|
|
327
|
+
if (typeof description === "string" && !isValidDescription(description)) {
|
|
328
|
+
W_ERROR(WErrors.IsValidDescription, `Description exceeds maximum length ${MAX_DESCRIPTION_LENGTH}`);
|
|
348
329
|
}
|
|
349
|
-
if (!
|
|
350
|
-
|
|
330
|
+
if (!IsValidArgType(treasury_type)) {
|
|
331
|
+
W_ERROR(WErrors.InvalidParam, `Description set treasury type ${treasury_type} is not valid`);
|
|
351
332
|
}
|
|
352
333
|
if (passport) {
|
|
353
334
|
tx.moveCall({
|
|
354
|
-
target:
|
|
335
|
+
target: treasuryFn("description_set_with_passport"),
|
|
355
336
|
arguments: [
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
337
|
+
toTxObject(tx, treasury),
|
|
338
|
+
toTxObject(tx, permission),
|
|
339
|
+
toTxObject(tx, passport),
|
|
340
|
+
toTxString(tx, description),
|
|
360
341
|
],
|
|
361
342
|
typeArguments: [treasury_type],
|
|
362
343
|
});
|
|
363
344
|
}
|
|
364
345
|
else {
|
|
365
346
|
tx.moveCall({
|
|
366
|
-
target:
|
|
347
|
+
target: treasuryFn("description_set"),
|
|
367
348
|
arguments: [
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
349
|
+
toTxObject(tx, treasury),
|
|
350
|
+
toTxObject(tx, permission),
|
|
351
|
+
toTxString(tx, description),
|
|
371
352
|
],
|
|
372
353
|
typeArguments: [treasury_type],
|
|
373
354
|
});
|
|
374
355
|
}
|
|
375
356
|
}
|
|
376
|
-
async function deposit(env, tx, treasury, treasury_type, permission, coin, payment_info, passport) {
|
|
377
|
-
|
|
378
|
-
if (!
|
|
379
|
-
|
|
357
|
+
export async function deposit(env, tx, treasury, treasury_type, permission, coin, payment_info, passport) {
|
|
358
|
+
validObjects([treasury, permission, passport]);
|
|
359
|
+
if (!IsValidArgType(treasury_type)) {
|
|
360
|
+
W_ERROR(WErrors.InvalidParam, `Deposit treasury type ${treasury_type} is not valid`);
|
|
380
361
|
}
|
|
381
|
-
const c = await
|
|
382
|
-
const p = await
|
|
362
|
+
const c = await getCoinParam(env, tx, coin, treasury_type);
|
|
363
|
+
const p = await paymentInfo(env, tx, payment_info);
|
|
383
364
|
if (passport) {
|
|
384
365
|
return tx.moveCall({
|
|
385
|
-
target:
|
|
366
|
+
target: treasuryFn("deposit_with_passport"),
|
|
386
367
|
arguments: [
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
368
|
+
toTxObject(tx, treasury),
|
|
369
|
+
toTxObject(tx, permission),
|
|
370
|
+
toTxObject(tx, passport),
|
|
390
371
|
c,
|
|
391
372
|
p,
|
|
392
373
|
tx.object.mutRegistrar(),
|
|
@@ -397,10 +378,10 @@ async function deposit(env, tx, treasury, treasury_type, permission, coin, payme
|
|
|
397
378
|
}
|
|
398
379
|
else {
|
|
399
380
|
return tx.moveCall({
|
|
400
|
-
target:
|
|
381
|
+
target: treasuryFn("deposit"),
|
|
401
382
|
arguments: [
|
|
402
|
-
|
|
403
|
-
|
|
383
|
+
toTxObject(tx, treasury),
|
|
384
|
+
toTxObject(tx, permission),
|
|
404
385
|
c,
|
|
405
386
|
p,
|
|
406
387
|
tx.object.mutRegistrar(),
|
|
@@ -410,26 +391,26 @@ async function deposit(env, tx, treasury, treasury_type, permission, coin, payme
|
|
|
410
391
|
});
|
|
411
392
|
}
|
|
412
393
|
}
|
|
413
|
-
async function withdraw(env, tx, treasury, treasury_type, permission, amount, recipient, payment_info, passport) {
|
|
414
|
-
|
|
415
|
-
if (!
|
|
416
|
-
|
|
394
|
+
export async function withdraw(env, tx, treasury, treasury_type, permission, amount, recipient, payment_info, passport) {
|
|
395
|
+
validObjects([treasury, permission, passport]);
|
|
396
|
+
if (!IsValidArgType(treasury_type)) {
|
|
397
|
+
W_ERROR(WErrors.InvalidParam, `Withdraw treasury type ${treasury_type} is not valid`);
|
|
417
398
|
}
|
|
418
|
-
if (!
|
|
419
|
-
|
|
399
|
+
if (!isValidU64(amount)) {
|
|
400
|
+
W_ERROR(WErrors.IsValidU64, `Amount ${amount} is not valid`);
|
|
420
401
|
}
|
|
421
|
-
const r = await
|
|
402
|
+
const r = await GetAccountOrMark_Address(recipient);
|
|
422
403
|
if (!r) {
|
|
423
|
-
|
|
404
|
+
W_ERROR(WErrors.InvalidParam, `Recipient ${recipient} is not valid`);
|
|
424
405
|
}
|
|
425
|
-
const p = await
|
|
406
|
+
const p = await paymentInfo(env, tx, payment_info);
|
|
426
407
|
if (passport) {
|
|
427
408
|
return tx.moveCall({
|
|
428
|
-
target:
|
|
409
|
+
target: treasuryFn("withdraw_with_passport"),
|
|
429
410
|
arguments: [
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
411
|
+
toTxObject(tx, treasury),
|
|
412
|
+
toTxObject(tx, permission),
|
|
413
|
+
toTxObject(tx, passport),
|
|
433
414
|
tx.pure.u64(amount),
|
|
434
415
|
tx.pure.address(r),
|
|
435
416
|
p,
|
|
@@ -441,10 +422,10 @@ async function withdraw(env, tx, treasury, treasury_type, permission, amount, re
|
|
|
441
422
|
}
|
|
442
423
|
else {
|
|
443
424
|
return tx.moveCall({
|
|
444
|
-
target:
|
|
425
|
+
target: treasuryFn("withdraw"),
|
|
445
426
|
arguments: [
|
|
446
|
-
|
|
447
|
-
|
|
427
|
+
toTxObject(tx, treasury),
|
|
428
|
+
toTxObject(tx, permission),
|
|
448
429
|
tx.pure.u64(amount),
|
|
449
430
|
tx.pure.address(r),
|
|
450
431
|
p,
|
|
@@ -455,24 +436,24 @@ async function withdraw(env, tx, treasury, treasury_type, permission, amount, re
|
|
|
455
436
|
});
|
|
456
437
|
}
|
|
457
438
|
}
|
|
458
|
-
async function external_deposit_guard_add(tx, treasury, treasury_type, permission, guards, counts =
|
|
439
|
+
export async function external_deposit_guard_add(tx, treasury, treasury_type, permission, guards, counts = MAX_EXTERNAL_DEPOSIT_GUARD_COUNT, passport) {
|
|
459
440
|
if (guards.length === 0) {
|
|
460
441
|
return;
|
|
461
442
|
}
|
|
462
443
|
if (guards.length > counts) {
|
|
463
|
-
|
|
444
|
+
W_ERROR(WErrors.InvalidParam, `External deposit guard add guards count ${guards.length} exceeds maximum ${counts}`);
|
|
464
445
|
}
|
|
465
|
-
|
|
466
|
-
if (!
|
|
467
|
-
|
|
446
|
+
validObjects([treasury, permission, passport]);
|
|
447
|
+
if (!IsValidArgType(treasury_type)) {
|
|
448
|
+
W_ERROR(WErrors.InvalidParam, `External deposit guard add treasury type ${treasury_type} is not valid`);
|
|
468
449
|
}
|
|
469
450
|
const g = await Promise.all(guards.map(async (item) => {
|
|
470
|
-
const guard = await
|
|
451
|
+
const guard = await LocalMark.Instance().get_address(item.guard);
|
|
471
452
|
if (!guard) {
|
|
472
|
-
|
|
453
|
+
W_ERROR(WErrors.InvalidParam, `External deposit guard add guard ${item.guard} is not valid`);
|
|
473
454
|
}
|
|
474
|
-
if (item.identifier && !
|
|
475
|
-
|
|
455
|
+
if (item.identifier && !isValidU8(item.identifier)) {
|
|
456
|
+
W_ERROR(WErrors.IsValidU8, `External deposit guard add identifier ${item.identifier} is not optional u8`);
|
|
476
457
|
}
|
|
477
458
|
return {
|
|
478
459
|
guard: item.guard,
|
|
@@ -483,7 +464,7 @@ async function external_deposit_guard_add(tx, treasury, treasury_type, permissio
|
|
|
483
464
|
// Check if any guard_addr is empty
|
|
484
465
|
const invalidGuards = g.filter((item) => !item.guard_addr);
|
|
485
466
|
if (invalidGuards.length > 0) {
|
|
486
|
-
|
|
467
|
+
W_ERROR(WErrors.InvalidParam, `External deposit guard add has invalid guards with empty guard_addr: ${JSON.stringify(invalidGuards)}`);
|
|
487
468
|
}
|
|
488
469
|
// Convert to AmountFromDepositGuard if all guard_addr are valid
|
|
489
470
|
g.filter((item) => item.guard_addr !== undefined)
|
|
@@ -494,12 +475,12 @@ async function external_deposit_guard_add(tx, treasury, treasury_type, permissio
|
|
|
494
475
|
.forEach((item) => {
|
|
495
476
|
if (passport) {
|
|
496
477
|
tx.moveCall({
|
|
497
|
-
target:
|
|
478
|
+
target: treasuryFn("external_deposit_guard_add_with_passport"),
|
|
498
479
|
arguments: [
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
480
|
+
toTxObject(tx, treasury),
|
|
481
|
+
toTxObject(tx, permission),
|
|
482
|
+
toTxObject(tx, passport),
|
|
483
|
+
toTxObject(tx, item.guard),
|
|
503
484
|
tx.pure.option("u8", item.identifier),
|
|
504
485
|
tx.object.mutRegistrar(),
|
|
505
486
|
tx.object.clock(),
|
|
@@ -509,11 +490,11 @@ async function external_deposit_guard_add(tx, treasury, treasury_type, permissio
|
|
|
509
490
|
}
|
|
510
491
|
else {
|
|
511
492
|
tx.moveCall({
|
|
512
|
-
target:
|
|
493
|
+
target: treasuryFn("external_deposit_guard_add"),
|
|
513
494
|
arguments: [
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
495
|
+
toTxObject(tx, treasury),
|
|
496
|
+
toTxObject(tx, permission),
|
|
497
|
+
toTxObject(tx, item.guard),
|
|
517
498
|
tx.pure.option("u8", item.identifier),
|
|
518
499
|
tx.object.mutRegistrar(),
|
|
519
500
|
tx.object.clock(),
|
|
@@ -523,25 +504,25 @@ async function external_deposit_guard_add(tx, treasury, treasury_type, permissio
|
|
|
523
504
|
}
|
|
524
505
|
});
|
|
525
506
|
}
|
|
526
|
-
async function external_deposit_guard_remove(tx, treasury, treasury_type, permission, guards, counts =
|
|
527
|
-
guards = await
|
|
507
|
+
export async function external_deposit_guard_remove(tx, treasury, treasury_type, permission, guards, counts = MAX_EXTERNAL_DEPOSIT_GUARD_COUNT, passport) {
|
|
508
|
+
guards = await LocalMark.Instance().get_many_address_availables(guards);
|
|
528
509
|
if (guards.length === 0) {
|
|
529
510
|
return;
|
|
530
511
|
}
|
|
531
512
|
if (guards.length > counts) {
|
|
532
|
-
|
|
513
|
+
W_ERROR(WErrors.InvalidParam, `External deposit guard remove guards count ${guards.length} exceeds maximum ${counts}`);
|
|
533
514
|
}
|
|
534
|
-
|
|
535
|
-
if (!
|
|
536
|
-
|
|
515
|
+
validObjects([treasury, permission, passport, ...guards]);
|
|
516
|
+
if (!IsValidArgType(treasury_type)) {
|
|
517
|
+
W_ERROR(WErrors.InvalidParam, `External deposit guard remove treasury type ${treasury_type} is not valid`);
|
|
537
518
|
}
|
|
538
519
|
if (passport) {
|
|
539
520
|
tx.moveCall({
|
|
540
|
-
target:
|
|
521
|
+
target: treasuryFn("external_deposit_guard_remove_with_passport"),
|
|
541
522
|
arguments: [
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
523
|
+
toTxObject(tx, treasury),
|
|
524
|
+
toTxObject(tx, permission),
|
|
525
|
+
toTxObject(tx, passport),
|
|
545
526
|
tx.pure.vector("address", guards),
|
|
546
527
|
tx.object.mutRegistrar(),
|
|
547
528
|
],
|
|
@@ -550,10 +531,10 @@ async function external_deposit_guard_remove(tx, treasury, treasury_type, permis
|
|
|
550
531
|
}
|
|
551
532
|
else {
|
|
552
533
|
tx.moveCall({
|
|
553
|
-
target:
|
|
534
|
+
target: treasuryFn("external_deposit_guard_remove"),
|
|
554
535
|
arguments: [
|
|
555
|
-
|
|
556
|
-
|
|
536
|
+
toTxObject(tx, treasury),
|
|
537
|
+
toTxObject(tx, permission),
|
|
557
538
|
tx.pure.vector("address", guards),
|
|
558
539
|
tx.object.mutRegistrar(),
|
|
559
540
|
],
|
|
@@ -561,18 +542,18 @@ async function external_deposit_guard_remove(tx, treasury, treasury_type, permis
|
|
|
561
542
|
});
|
|
562
543
|
}
|
|
563
544
|
}
|
|
564
|
-
function external_deposit_guard_clear(tx, treasury, treasury_type, permission, passport) {
|
|
565
|
-
|
|
566
|
-
if (!
|
|
567
|
-
|
|
545
|
+
export function external_deposit_guard_clear(tx, treasury, treasury_type, permission, passport) {
|
|
546
|
+
validObjects([treasury, permission, passport]);
|
|
547
|
+
if (!IsValidArgType(treasury_type)) {
|
|
548
|
+
W_ERROR(WErrors.InvalidParam, `External deposit guard clear treasury type ${treasury_type} is not valid`);
|
|
568
549
|
}
|
|
569
550
|
if (passport) {
|
|
570
551
|
tx.moveCall({
|
|
571
|
-
target:
|
|
552
|
+
target: treasuryFn("external_deposit_guard_clear_with_passport"),
|
|
572
553
|
arguments: [
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
554
|
+
toTxObject(tx, treasury),
|
|
555
|
+
toTxObject(tx, permission),
|
|
556
|
+
toTxObject(tx, passport),
|
|
576
557
|
tx.object.mutRegistrar(),
|
|
577
558
|
],
|
|
578
559
|
typeArguments: [treasury_type],
|
|
@@ -580,34 +561,34 @@ function external_deposit_guard_clear(tx, treasury, treasury_type, permission, p
|
|
|
580
561
|
}
|
|
581
562
|
else {
|
|
582
563
|
tx.moveCall({
|
|
583
|
-
target:
|
|
564
|
+
target: treasuryFn("external_deposit_guard_clear"),
|
|
584
565
|
arguments: [
|
|
585
|
-
|
|
586
|
-
|
|
566
|
+
toTxObject(tx, treasury),
|
|
567
|
+
toTxObject(tx, permission),
|
|
587
568
|
tx.object.mutRegistrar(),
|
|
588
569
|
],
|
|
589
570
|
typeArguments: [treasury_type],
|
|
590
571
|
});
|
|
591
572
|
}
|
|
592
573
|
}
|
|
593
|
-
async function external_withdraw_guard_add(tx, treasury, treasury_type, permission, guards, counts =
|
|
574
|
+
export async function external_withdraw_guard_add(tx, treasury, treasury_type, permission, guards, counts = MAX_EXTERNAL_DEPOSIT_GUARD_COUNT, passport) {
|
|
594
575
|
if (guards.length === 0) {
|
|
595
576
|
return;
|
|
596
577
|
}
|
|
597
578
|
if (guards.length > counts) {
|
|
598
|
-
|
|
579
|
+
W_ERROR(WErrors.InvalidParam, `External withdraw guard add guards count ${guards.length} exceeds maximum ${counts}`);
|
|
599
580
|
}
|
|
600
|
-
|
|
601
|
-
if (!
|
|
602
|
-
|
|
581
|
+
validObjects([treasury, permission, passport]);
|
|
582
|
+
if (!IsValidArgType(treasury_type)) {
|
|
583
|
+
W_ERROR(WErrors.InvalidParam, `External withdraw guard add treasury type ${treasury_type} is not valid`);
|
|
603
584
|
}
|
|
604
585
|
const g = await Promise.all(guards.map(async (item) => {
|
|
605
|
-
const guard = await
|
|
586
|
+
const guard = await LocalMark.Instance().get_address(item.guard);
|
|
606
587
|
if (!guard) {
|
|
607
|
-
|
|
588
|
+
W_ERROR(WErrors.InvalidParam, `External withdraw guard add guard ${item.guard} is not valid`);
|
|
608
589
|
}
|
|
609
|
-
if (!
|
|
610
|
-
|
|
590
|
+
if (!isValidU8(item.identifier)) {
|
|
591
|
+
W_ERROR(WErrors.IsValidU8, `External withdraw guard add identifier ${item.identifier} is not optional u8`);
|
|
611
592
|
}
|
|
612
593
|
return {
|
|
613
594
|
guard: item.guard,
|
|
@@ -618,7 +599,7 @@ async function external_withdraw_guard_add(tx, treasury, treasury_type, permissi
|
|
|
618
599
|
// Check if any guard_addr is empty
|
|
619
600
|
const invalidGuards = g.filter((item) => !item.guard_addr);
|
|
620
601
|
if (invalidGuards.length > 0) {
|
|
621
|
-
|
|
602
|
+
W_ERROR(WErrors.InvalidParam, `External withdraw guard add has invalid guards with empty guard_addr: ${JSON.stringify(invalidGuards)}`);
|
|
622
603
|
}
|
|
623
604
|
// Convert to AmountFromWithdrawGuard if all guard_addr are valid
|
|
624
605
|
g.filter((item) => item.guard_addr !== undefined)
|
|
@@ -629,12 +610,12 @@ async function external_withdraw_guard_add(tx, treasury, treasury_type, permissi
|
|
|
629
610
|
.forEach((item) => {
|
|
630
611
|
if (passport) {
|
|
631
612
|
tx.moveCall({
|
|
632
|
-
target:
|
|
613
|
+
target: treasuryFn("external_withdraw_guard_add_with_passport"),
|
|
633
614
|
arguments: [
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
615
|
+
toTxObject(tx, treasury),
|
|
616
|
+
toTxObject(tx, permission),
|
|
617
|
+
toTxObject(tx, passport),
|
|
618
|
+
toTxObject(tx, item.guard),
|
|
638
619
|
tx.pure.u8(item.identifier),
|
|
639
620
|
tx.object.mutRegistrar(),
|
|
640
621
|
tx.object.clock(),
|
|
@@ -647,11 +628,11 @@ async function external_withdraw_guard_add(tx, treasury, treasury_type, permissi
|
|
|
647
628
|
`External withdraw guard add guard ${item.guard} identifier ${item.identifier}`,
|
|
648
629
|
);*/
|
|
649
630
|
tx.moveCall({
|
|
650
|
-
target:
|
|
631
|
+
target: treasuryFn("external_withdraw_guard_add"),
|
|
651
632
|
arguments: [
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
633
|
+
toTxObject(tx, treasury),
|
|
634
|
+
toTxObject(tx, permission),
|
|
635
|
+
toTxObject(tx, item.guard),
|
|
655
636
|
tx.pure.u8(item.identifier),
|
|
656
637
|
tx.object.mutRegistrar(),
|
|
657
638
|
tx.object.clock(),
|
|
@@ -661,25 +642,25 @@ async function external_withdraw_guard_add(tx, treasury, treasury_type, permissi
|
|
|
661
642
|
}
|
|
662
643
|
});
|
|
663
644
|
}
|
|
664
|
-
async function external_withdraw_guard_remove(tx, treasury, treasury_type, permission, guards, counts =
|
|
665
|
-
guards = await
|
|
645
|
+
export async function external_withdraw_guard_remove(tx, treasury, treasury_type, permission, guards, counts = MAX_EXTERNAL_DEPOSIT_GUARD_COUNT, passport) {
|
|
646
|
+
guards = await LocalMark.Instance().get_many_address_availables(guards);
|
|
666
647
|
if (guards.length === 0) {
|
|
667
648
|
return;
|
|
668
649
|
}
|
|
669
650
|
if (guards.length > counts) {
|
|
670
|
-
|
|
651
|
+
W_ERROR(WErrors.InvalidParam, `External withdraw guard remove guards count ${guards.length} exceeds maximum ${counts}`);
|
|
671
652
|
}
|
|
672
|
-
|
|
673
|
-
if (!
|
|
674
|
-
|
|
653
|
+
validObjects([treasury, permission, passport]);
|
|
654
|
+
if (!IsValidArgType(treasury_type)) {
|
|
655
|
+
W_ERROR(WErrors.InvalidParam, `External withdraw guard remove treasury type ${treasury_type} is not valid`);
|
|
675
656
|
}
|
|
676
657
|
if (passport) {
|
|
677
658
|
tx.moveCall({
|
|
678
|
-
target:
|
|
659
|
+
target: treasuryFn("external_withdraw_guard_remove_with_passport"),
|
|
679
660
|
arguments: [
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
661
|
+
toTxObject(tx, treasury),
|
|
662
|
+
toTxObject(tx, permission),
|
|
663
|
+
toTxObject(tx, passport),
|
|
683
664
|
tx.pure.vector("address", guards),
|
|
684
665
|
tx.object.mutRegistrar(),
|
|
685
666
|
],
|
|
@@ -688,10 +669,10 @@ async function external_withdraw_guard_remove(tx, treasury, treasury_type, permi
|
|
|
688
669
|
}
|
|
689
670
|
else {
|
|
690
671
|
tx.moveCall({
|
|
691
|
-
target:
|
|
672
|
+
target: treasuryFn("external_withdraw_guard_remove"),
|
|
692
673
|
arguments: [
|
|
693
|
-
|
|
694
|
-
|
|
674
|
+
toTxObject(tx, treasury),
|
|
675
|
+
toTxObject(tx, permission),
|
|
695
676
|
tx.pure.vector("address", guards),
|
|
696
677
|
tx.object.mutRegistrar(),
|
|
697
678
|
],
|
|
@@ -699,18 +680,18 @@ async function external_withdraw_guard_remove(tx, treasury, treasury_type, permi
|
|
|
699
680
|
});
|
|
700
681
|
}
|
|
701
682
|
}
|
|
702
|
-
function external_withdraw_guard_clear(tx, treasury, treasury_type, permission, passport) {
|
|
703
|
-
|
|
704
|
-
if (!
|
|
705
|
-
|
|
683
|
+
export function external_withdraw_guard_clear(tx, treasury, treasury_type, permission, passport) {
|
|
684
|
+
validObjects([treasury, permission, passport]);
|
|
685
|
+
if (!IsValidArgType(treasury_type)) {
|
|
686
|
+
W_ERROR(WErrors.InvalidParam, `External withdraw guard clear treasury type ${treasury_type} is not valid`);
|
|
706
687
|
}
|
|
707
688
|
if (passport) {
|
|
708
689
|
tx.moveCall({
|
|
709
|
-
target:
|
|
690
|
+
target: treasuryFn("external_withdraw_guard_clear_with_passport"),
|
|
710
691
|
arguments: [
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
692
|
+
toTxObject(tx, treasury),
|
|
693
|
+
toTxObject(tx, permission),
|
|
694
|
+
toTxObject(tx, passport),
|
|
714
695
|
tx.object.mutRegistrar(),
|
|
715
696
|
],
|
|
716
697
|
typeArguments: [treasury_type],
|
|
@@ -718,46 +699,46 @@ function external_withdraw_guard_clear(tx, treasury, treasury_type, permission,
|
|
|
718
699
|
}
|
|
719
700
|
else {
|
|
720
701
|
tx.moveCall({
|
|
721
|
-
target:
|
|
702
|
+
target: treasuryFn("external_withdraw_guard_clear"),
|
|
722
703
|
arguments: [
|
|
723
|
-
|
|
724
|
-
|
|
704
|
+
toTxObject(tx, treasury),
|
|
705
|
+
toTxObject(tx, permission),
|
|
725
706
|
tx.object.mutRegistrar(),
|
|
726
707
|
],
|
|
727
708
|
typeArguments: [treasury_type],
|
|
728
709
|
});
|
|
729
710
|
}
|
|
730
711
|
}
|
|
731
|
-
function create(tx, treasury, treasury_type) {
|
|
732
|
-
|
|
733
|
-
if (!
|
|
734
|
-
|
|
712
|
+
export function create(tx, treasury, treasury_type) {
|
|
713
|
+
validObjects([treasury]);
|
|
714
|
+
if (!IsValidArgType(treasury_type)) {
|
|
715
|
+
W_ERROR(WErrors.InvalidParam, `Create treasury type ${treasury_type} is not valid`);
|
|
735
716
|
}
|
|
736
717
|
return tx.moveCall({
|
|
737
|
-
target:
|
|
738
|
-
arguments: [
|
|
718
|
+
target: treasuryFn("create"),
|
|
719
|
+
arguments: [toTxObject(tx, treasury)],
|
|
739
720
|
typeArguments: [treasury_type],
|
|
740
721
|
});
|
|
741
722
|
}
|
|
742
|
-
async function external_deposit(env, tx, treasury, treasury_type, passport, external_deposit_guard, coin, payment_info) {
|
|
743
|
-
|
|
744
|
-
if (!
|
|
745
|
-
|
|
723
|
+
export async function external_deposit(env, tx, treasury, treasury_type, passport, external_deposit_guard, coin, payment_info) {
|
|
724
|
+
validObjects([treasury, passport]);
|
|
725
|
+
if (!IsValidArgType(treasury_type)) {
|
|
726
|
+
W_ERROR(WErrors.InvalidParam, `External deposit treasury type ${treasury_type} is not valid`);
|
|
746
727
|
}
|
|
747
728
|
const [c, p, guard] = await Promise.all([
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
729
|
+
getCoinParam(env, tx, coin, treasury_type),
|
|
730
|
+
paymentInfo(env, tx, payment_info),
|
|
731
|
+
LocalMark.Instance().get_address(external_deposit_guard),
|
|
751
732
|
]);
|
|
752
733
|
if (!guard) {
|
|
753
|
-
|
|
734
|
+
W_ERROR(WErrors.InvalidParam, `External deposit guard ${external_deposit_guard} is not valid`);
|
|
754
735
|
}
|
|
755
736
|
return tx.moveCall({
|
|
756
|
-
target:
|
|
737
|
+
target: treasuryFn("external_deposit"),
|
|
757
738
|
arguments: [
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
739
|
+
toTxObject(tx, treasury),
|
|
740
|
+
toTxObject(tx, passport),
|
|
741
|
+
toTxObject(tx, guard),
|
|
761
742
|
c,
|
|
762
743
|
p,
|
|
763
744
|
tx.object.mutRegistrar(),
|
|
@@ -766,28 +747,28 @@ async function external_deposit(env, tx, treasury, treasury_type, passport, exte
|
|
|
766
747
|
typeArguments: [treasury_type],
|
|
767
748
|
});
|
|
768
749
|
}
|
|
769
|
-
async function external_withdraw(env, tx, treasury, treasury_type, passport, external_withdraw_guard, recipient, payment_info) {
|
|
770
|
-
|
|
771
|
-
if (!
|
|
772
|
-
|
|
750
|
+
export async function external_withdraw(env, tx, treasury, treasury_type, passport, external_withdraw_guard, recipient, payment_info) {
|
|
751
|
+
validObjects([treasury, passport]);
|
|
752
|
+
if (!IsValidArgType(treasury_type)) {
|
|
753
|
+
W_ERROR(WErrors.InvalidParam, `External withdraw treasury type ${treasury_type} is not valid`);
|
|
773
754
|
}
|
|
774
755
|
const [p, guard, recipient_addr] = await Promise.all([
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
756
|
+
paymentInfo(env, tx, payment_info),
|
|
757
|
+
LocalMark.Instance().get_address(external_withdraw_guard),
|
|
758
|
+
GetAccountOrMark_Address(recipient),
|
|
778
759
|
]);
|
|
779
760
|
if (!guard) {
|
|
780
|
-
|
|
761
|
+
W_ERROR(WErrors.InvalidParam, `External withdraw guard ${external_withdraw_guard} is not valid`);
|
|
781
762
|
}
|
|
782
763
|
if (!recipient_addr) {
|
|
783
|
-
|
|
764
|
+
W_ERROR(WErrors.InvalidParam, `External withdraw recipient ${recipient} is not valid`);
|
|
784
765
|
}
|
|
785
766
|
return tx.moveCall({
|
|
786
|
-
target:
|
|
767
|
+
target: treasuryFn("external_withdraw"),
|
|
787
768
|
arguments: [
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
769
|
+
toTxObject(tx, treasury),
|
|
770
|
+
toTxObject(tx, passport),
|
|
771
|
+
toTxObject(tx, guard),
|
|
791
772
|
tx.pure.address(recipient_addr),
|
|
792
773
|
p,
|
|
793
774
|
tx.object.mutRegistrar(),
|
|
@@ -796,23 +777,23 @@ async function external_withdraw(env, tx, treasury, treasury_type, passport, ext
|
|
|
796
777
|
typeArguments: [treasury_type],
|
|
797
778
|
});
|
|
798
779
|
}
|
|
799
|
-
function receive(tx, treasury, treasury_type, permission, received, payment, passport) {
|
|
780
|
+
export function receive(tx, treasury, treasury_type, permission, received, payment, passport) {
|
|
800
781
|
if (!payment) {
|
|
801
|
-
|
|
782
|
+
W_ERROR(WErrors.InvalidParam, `Treasury receive payment is required`);
|
|
802
783
|
}
|
|
803
|
-
|
|
804
|
-
if (!
|
|
805
|
-
|
|
784
|
+
validObjects([treasury, permission, received, payment, passport]);
|
|
785
|
+
if (!IsValidArgType(treasury_type)) {
|
|
786
|
+
W_ERROR(WErrors.InvalidParam, `Treasury receive treasury type ${treasury_type} is not valid`);
|
|
806
787
|
}
|
|
807
788
|
if (passport) {
|
|
808
789
|
tx.moveCall({
|
|
809
|
-
target:
|
|
790
|
+
target: treasuryFn("receive_with_passport"),
|
|
810
791
|
arguments: [
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
792
|
+
toTxObject(tx, treasury),
|
|
793
|
+
toTxObject(tx, permission),
|
|
794
|
+
toTxObject(tx, passport),
|
|
795
|
+
toTxObject(tx, received),
|
|
796
|
+
toTxObject(tx, payment),
|
|
816
797
|
tx.object.clock(),
|
|
817
798
|
],
|
|
818
799
|
typeArguments: [treasury_type],
|
|
@@ -820,32 +801,32 @@ function receive(tx, treasury, treasury_type, permission, received, payment, pas
|
|
|
820
801
|
}
|
|
821
802
|
else {
|
|
822
803
|
tx.moveCall({
|
|
823
|
-
target:
|
|
804
|
+
target: treasuryFn("receive"),
|
|
824
805
|
arguments: [
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
806
|
+
toTxObject(tx, treasury),
|
|
807
|
+
toTxObject(tx, permission),
|
|
808
|
+
toTxObject(tx, received),
|
|
809
|
+
toTxObject(tx, payment),
|
|
829
810
|
tx.object.clock(),
|
|
830
811
|
],
|
|
831
812
|
typeArguments: [treasury_type],
|
|
832
813
|
});
|
|
833
814
|
}
|
|
834
815
|
}
|
|
835
|
-
function um_set(tx, treasury, treasury_type, permission, um, passport) {
|
|
836
|
-
|
|
837
|
-
if (!
|
|
838
|
-
|
|
816
|
+
export function um_set(tx, treasury, treasury_type, permission, um, passport) {
|
|
817
|
+
validObjects([treasury, permission]);
|
|
818
|
+
if (!IsValidArgType(treasury_type)) {
|
|
819
|
+
W_ERROR(WErrors.InvalidParam, `Treasury type ${treasury_type} is not valid`);
|
|
839
820
|
}
|
|
840
821
|
if (um) {
|
|
841
822
|
if (passport) {
|
|
842
823
|
tx.moveCall({
|
|
843
|
-
target:
|
|
824
|
+
target: treasuryFn(`um_set_with_passport`),
|
|
844
825
|
arguments: [
|
|
845
|
-
|
|
846
|
-
|
|
826
|
+
toTxObject(tx, treasury),
|
|
827
|
+
toTxObject(tx, permission),
|
|
847
828
|
passport,
|
|
848
|
-
|
|
829
|
+
toTxObject(tx, um),
|
|
849
830
|
tx.object.mutRegistrar(),
|
|
850
831
|
tx.object.clock(),
|
|
851
832
|
],
|
|
@@ -854,11 +835,11 @@ function um_set(tx, treasury, treasury_type, permission, um, passport) {
|
|
|
854
835
|
}
|
|
855
836
|
else {
|
|
856
837
|
tx.moveCall({
|
|
857
|
-
target:
|
|
838
|
+
target: treasuryFn(`um_set`),
|
|
858
839
|
arguments: [
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
840
|
+
toTxObject(tx, treasury),
|
|
841
|
+
toTxObject(tx, permission),
|
|
842
|
+
toTxObject(tx, um),
|
|
862
843
|
tx.object.mutRegistrar(),
|
|
863
844
|
tx.object.clock(),
|
|
864
845
|
],
|
|
@@ -869,10 +850,10 @@ function um_set(tx, treasury, treasury_type, permission, um, passport) {
|
|
|
869
850
|
else {
|
|
870
851
|
if (passport) {
|
|
871
852
|
tx.moveCall({
|
|
872
|
-
target:
|
|
853
|
+
target: treasuryFn(`um_none_with_passport`),
|
|
873
854
|
arguments: [
|
|
874
|
-
|
|
875
|
-
|
|
855
|
+
toTxObject(tx, treasury),
|
|
856
|
+
toTxObject(tx, permission),
|
|
876
857
|
passport,
|
|
877
858
|
tx.object.mutRegistrar(),
|
|
878
859
|
],
|
|
@@ -881,10 +862,10 @@ function um_set(tx, treasury, treasury_type, permission, um, passport) {
|
|
|
881
862
|
}
|
|
882
863
|
else {
|
|
883
864
|
tx.moveCall({
|
|
884
|
-
target:
|
|
865
|
+
target: treasuryFn(`um_none`),
|
|
885
866
|
arguments: [
|
|
886
|
-
|
|
887
|
-
|
|
867
|
+
toTxObject(tx, treasury),
|
|
868
|
+
toTxObject(tx, permission),
|
|
888
869
|
tx.object.mutRegistrar(),
|
|
889
870
|
],
|
|
890
871
|
typeArguments: [treasury_type],
|