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,60 +1,21 @@
|
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
exports.stock_reduce = stock_reduce;
|
|
21
|
-
exports.sale_suspension = sale_suspension;
|
|
22
|
-
exports.repository_add = repository_add;
|
|
23
|
-
exports.repository_remove = repository_remove;
|
|
24
|
-
exports.repository_clear = repository_clear;
|
|
25
|
-
exports.buy_guard_set = buy_guard_set;
|
|
26
|
-
exports.machine_set = machine_set;
|
|
27
|
-
exports.publish = publish;
|
|
28
|
-
exports.pause = pause;
|
|
29
|
-
exports.customer_required_set = customer_required_set;
|
|
30
|
-
exports.arbitrations_add = arbitrations_add;
|
|
31
|
-
exports.arbitrations_remove = arbitrations_remove;
|
|
32
|
-
exports.arbitration_clear = arbitration_clear;
|
|
33
|
-
exports.compensation_fund_add = compensation_fund_add;
|
|
34
|
-
exports.compensation_lock_duration_set = compensation_lock_duration_set;
|
|
35
|
-
exports.order_allocators_set = order_allocators_set;
|
|
36
|
-
exports.reward_add = reward_add;
|
|
37
|
-
exports.reward_remove = reward_remove;
|
|
38
|
-
exports.reward_clear = reward_clear;
|
|
39
|
-
exports.compensation_fund_receive = compensation_fund_receive;
|
|
40
|
-
exports.compensation_fund_withdraw = compensation_fund_withdraw;
|
|
41
|
-
exports.discount = discount;
|
|
42
|
-
const common_js_1 = require("../common.js");
|
|
43
|
-
const exception_js_1 = require("../exception.js");
|
|
44
|
-
const object_js_1 = require("../query/object.js");
|
|
45
|
-
const util_js_1 = require("../util.js");
|
|
46
|
-
const allocation_js_1 = require("./allocation.js");
|
|
47
|
-
const base_js_1 = require("./base.js");
|
|
48
|
-
const permission_js_1 = require("./permission.js");
|
|
49
|
-
const index_js_1 = require("../local/index.js");
|
|
50
|
-
const local_js_1 = require("../local/local.js");
|
|
51
|
-
const order_js_1 = require("./order.js");
|
|
52
|
-
const progress_js_1 = require("./progress.js");
|
|
53
|
-
const order_js_2 = require("./order.js");
|
|
54
|
-
const permission_js_2 = require("./permission.js");
|
|
55
|
-
const util_js_2 = require("../query/util.js");
|
|
56
|
-
const received_js_1 = require("../query/received.js");
|
|
57
|
-
class CallService extends base_js_1.CallBase {
|
|
3
|
+
import { toTxObject, toTxString, isValidDescription, MAX_DESCRIPTION_LENGTH, isValidName, isValidLongName, isValidU16, isValidU64, PackageAddress, MAX_LONG_NAME_LENGTH, isValidArray, IsValidArgType, GetObjectExisted, GetObject, GetObjectDescription, serviceFn, MAX_NAME_LENGTH, isValidHttpUrl, } 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 { allocators } from "./allocation.js";
|
|
8
|
+
import { CallBase, getCoinParam } from "./base.js";
|
|
9
|
+
import { BuiltinPermissionIndex, newPermission } from "./permission.js";
|
|
10
|
+
import { GetManyAccountOrMark_Address } from "../local/index.js";
|
|
11
|
+
import { LocalMark } from "../local/local.js";
|
|
12
|
+
import { agent_set, order_required_info_update, owner_change, } from "./order.js";
|
|
13
|
+
import { create as progressCreate } from "./progress.js";
|
|
14
|
+
import { create as orderCreate } from "./order.js";
|
|
15
|
+
import { create as permissionCreate } from "./permission.js";
|
|
16
|
+
import { queryObjectsWithType } from "../query/util.js";
|
|
17
|
+
import { query_received } from "../query/received.js";
|
|
18
|
+
export class CallService extends CallBase {
|
|
58
19
|
data;
|
|
59
20
|
object_address = undefined;
|
|
60
21
|
permission_address = undefined;
|
|
@@ -67,28 +28,28 @@ class CallService extends base_js_1.CallBase {
|
|
|
67
28
|
async prepare(env) {
|
|
68
29
|
await super.prepare(env);
|
|
69
30
|
if (!this.object_address) {
|
|
70
|
-
this.object_address = await
|
|
31
|
+
this.object_address = await GetObjectExisted(this.data?.object);
|
|
71
32
|
}
|
|
72
33
|
if (this.object_address) {
|
|
73
|
-
await this.update_content(env,
|
|
34
|
+
await this.update_content(env, ObjectType.Service, this.object_address);
|
|
74
35
|
if (!this.content)
|
|
75
|
-
|
|
36
|
+
W_ERROR(WErrors.InvalidParam, "CallService_Data.data.object:" + this.object_address);
|
|
76
37
|
this.permission_address = this.content.permission;
|
|
77
|
-
this.parameter_type =
|
|
38
|
+
this.parameter_type = parseObjectType(this.content.type_raw, "service::Service");
|
|
78
39
|
if (!this.permission_address) {
|
|
79
|
-
|
|
40
|
+
W_ERROR(WErrors.InvalidParam, "CallService_Data.data.object.permission is empty");
|
|
80
41
|
}
|
|
81
|
-
if (!
|
|
82
|
-
|
|
42
|
+
if (!IsValidArgType(this.parameter_type)) {
|
|
43
|
+
W_ERROR(WErrors.IsValidArgType, "CallService_Data.data.object.type_parameter is empty");
|
|
83
44
|
}
|
|
84
45
|
}
|
|
85
46
|
else {
|
|
86
|
-
const n =
|
|
87
|
-
this.permission_address = await
|
|
88
|
-
this.new_permission_description =
|
|
47
|
+
const n = GetObject(this.data.object);
|
|
48
|
+
this.permission_address = await GetObjectExisted(n?.permission);
|
|
49
|
+
this.new_permission_description = GetObjectDescription(n?.permission);
|
|
89
50
|
this.parameter_type = n?.type_parameter;
|
|
90
|
-
if (!
|
|
91
|
-
|
|
51
|
+
if (!IsValidArgType(this.parameter_type)) {
|
|
52
|
+
W_ERROR(WErrors.IsValidArgType, "CallService_Data.data.object.type_parameter invalid");
|
|
92
53
|
}
|
|
93
54
|
}
|
|
94
55
|
}
|
|
@@ -107,11 +68,11 @@ class CallService extends base_js_1.CallBase {
|
|
|
107
68
|
}
|
|
108
69
|
};
|
|
109
70
|
if (this.permission_address && !this.object_address) {
|
|
110
|
-
add_perm(
|
|
71
|
+
add_perm(BuiltinPermissionIndex.SERVICE_NEW);
|
|
111
72
|
}
|
|
112
73
|
if (this.data?.order_new) {
|
|
113
74
|
if (!this.content) {
|
|
114
|
-
|
|
75
|
+
W_ERROR(WErrors.InvalidParam, `CallService_Data.data.order_new fail because the Service ${JSON.stringify(this.data.object)} content not ready`);
|
|
115
76
|
}
|
|
116
77
|
this.order_allowed();
|
|
117
78
|
if (this.content.buy_guard != null) {
|
|
@@ -121,62 +82,62 @@ class CallService extends base_js_1.CallBase {
|
|
|
121
82
|
if (this.permission_address &&
|
|
122
83
|
this.data?.description != null &&
|
|
123
84
|
this.object_address) {
|
|
124
|
-
add_perm(
|
|
85
|
+
add_perm(BuiltinPermissionIndex.SERVICE_DESCRIPTION);
|
|
125
86
|
}
|
|
126
87
|
if (this.permission_address && this.data?.location != null) {
|
|
127
|
-
add_perm(
|
|
88
|
+
add_perm(BuiltinPermissionIndex.SERVICE_LOCATION);
|
|
128
89
|
}
|
|
129
90
|
if (this.permission_address && this.data?.repositories != null) {
|
|
130
|
-
add_perm(
|
|
91
|
+
add_perm(BuiltinPermissionIndex.SERVICE_REPOSITORY);
|
|
131
92
|
}
|
|
132
93
|
if (this.permission_address && this.data?.sales != null) {
|
|
133
|
-
add_perm(
|
|
94
|
+
add_perm(BuiltinPermissionIndex.SERVICE_SALES);
|
|
134
95
|
}
|
|
135
96
|
if (this.permission_address && this.data?.machine !== undefined) {
|
|
136
97
|
this.checkNotPublished("machine");
|
|
137
|
-
add_perm(
|
|
98
|
+
add_perm(BuiltinPermissionIndex.SERVICE_MACHINE);
|
|
138
99
|
}
|
|
139
100
|
if (this.permission_address && this.data?.discount != null) {
|
|
140
|
-
add_perm(
|
|
101
|
+
add_perm(BuiltinPermissionIndex.SERVICE_DISCOUNT);
|
|
141
102
|
}
|
|
142
103
|
if (this.permission_address && this.data?.arbitrations != null) {
|
|
143
104
|
this.checkNotPublished("arbitrations");
|
|
144
|
-
add_perm(
|
|
105
|
+
add_perm(BuiltinPermissionIndex.SERVICE_ARBITRATION);
|
|
145
106
|
}
|
|
146
107
|
if (this.permission_address && this.data?.customer_required != null) {
|
|
147
|
-
add_perm(
|
|
108
|
+
add_perm(BuiltinPermissionIndex.SERVICE_CUSTOMER_INFO_REQUIRED);
|
|
148
109
|
}
|
|
149
110
|
if (this.permission_address && this.data?.pause !== undefined) {
|
|
150
|
-
add_perm(
|
|
111
|
+
add_perm(BuiltinPermissionIndex.SERVICE_PAUSE);
|
|
151
112
|
}
|
|
152
113
|
if (this.permission_address && this.data?.publish) {
|
|
153
|
-
add_perm(
|
|
114
|
+
add_perm(BuiltinPermissionIndex.SERVICE_PUBLISH);
|
|
154
115
|
}
|
|
155
116
|
if (this.permission_address &&
|
|
156
117
|
this.data?.order_allocators !== undefined) {
|
|
157
118
|
this.checkNotPublished("order_allocators");
|
|
158
|
-
add_perm(
|
|
119
|
+
add_perm(BuiltinPermissionIndex.SERVICE_ORDER_ALLOCATOR);
|
|
159
120
|
}
|
|
160
121
|
if (this.permission_address &&
|
|
161
122
|
this.data?.compensation_fund_add != null) {
|
|
162
|
-
add_perm(
|
|
123
|
+
add_perm(BuiltinPermissionIndex.SERVICE_COMPENSATION_FUND_DEPOSIT);
|
|
163
124
|
}
|
|
164
125
|
if (this.permission_address &&
|
|
165
126
|
this.data?.compensation_locked_time_add !== undefined) {
|
|
166
|
-
add_perm(
|
|
127
|
+
add_perm(BuiltinPermissionIndex.SERVICE_COMPENSATION_LOCKED_TIME_ADD);
|
|
167
128
|
}
|
|
168
129
|
if (this.permission_address && this.data?.rewards != null) {
|
|
169
|
-
add_perm(
|
|
130
|
+
add_perm(BuiltinPermissionIndex.SERVICE_REWARD);
|
|
170
131
|
}
|
|
171
132
|
if (this.permission_address &&
|
|
172
133
|
this.data?.compensation_fund_receive != null) {
|
|
173
|
-
add_perm(
|
|
134
|
+
add_perm(BuiltinPermissionIndex.SERVICE_COMPENSATION_FUND_RECEIVE);
|
|
174
135
|
}
|
|
175
136
|
if (this.permission_address && this.data?.owner_receive != null) {
|
|
176
|
-
add_perm(
|
|
137
|
+
add_perm(BuiltinPermissionIndex.SERVICE_OWNER_RECEIVE);
|
|
177
138
|
}
|
|
178
139
|
if (this.permission_address && this.data?.um !== undefined) {
|
|
179
|
-
add_perm(
|
|
140
|
+
add_perm(BuiltinPermissionIndex.SERVICE_UM);
|
|
180
141
|
}
|
|
181
142
|
if (this.permission_address || guards.length > 0) {
|
|
182
143
|
return await this.check_permission_and_call(env, this.permission_address, perms, guards);
|
|
@@ -188,55 +149,55 @@ class CallService extends base_js_1.CallBase {
|
|
|
188
149
|
let object = this.object_address;
|
|
189
150
|
if (!this.object_address) {
|
|
190
151
|
if (!permission) {
|
|
191
|
-
permission =
|
|
152
|
+
permission = newPermission(tx, this.new_permission_description ?? "");
|
|
192
153
|
}
|
|
193
154
|
if (permission && this.parameter_type) {
|
|
194
155
|
object = newService(tx, this.parameter_type, permission, this.data?.description ?? "", passport);
|
|
195
156
|
}
|
|
196
157
|
}
|
|
197
158
|
if (!object || !permission) {
|
|
198
|
-
|
|
159
|
+
W_ERROR(WErrors.InvalidParam, "CallService_Data.data.object:" + this.object_address);
|
|
199
160
|
}
|
|
200
161
|
// 最后再给地址命名
|
|
201
162
|
let buyResult;
|
|
202
163
|
if (this.data?.order_new != null && this.content) {
|
|
203
164
|
this.order_allowed();
|
|
204
165
|
const n = this.data?.order_new;
|
|
205
|
-
n.buy.discount = await
|
|
206
|
-
buyResult = await
|
|
166
|
+
n.buy.discount = await LocalMark.Instance().get_address(this.data.order_new.buy.discount);
|
|
167
|
+
buyResult = await buy(env, tx, object, this.parameter_type, this.content.machine, n.buy, passport);
|
|
207
168
|
if (!buyResult) {
|
|
208
|
-
|
|
169
|
+
W_ERROR(WErrors.Fail, "Buy failed, no order created");
|
|
209
170
|
}
|
|
210
171
|
if (n?.agents != null) {
|
|
211
|
-
|
|
172
|
+
agent_set(tx, {
|
|
212
173
|
order: buyResult.order,
|
|
213
|
-
agents: await
|
|
174
|
+
agents: await GetManyAccountOrMark_Address(n.agents),
|
|
214
175
|
});
|
|
215
176
|
}
|
|
216
177
|
if (n?.order_required_info !== undefined) {
|
|
217
|
-
await
|
|
178
|
+
await order_required_info_update(tx, buyResult.order, n.order_required_info);
|
|
218
179
|
}
|
|
219
180
|
if (n?.transfer != null) {
|
|
220
|
-
await
|
|
181
|
+
await owner_change(tx, {
|
|
221
182
|
order: buyResult.order,
|
|
222
183
|
new_owner: n.transfer,
|
|
223
184
|
});
|
|
224
185
|
}
|
|
225
186
|
if (n?.namedNewAllocation != null && buyResult?.allocation) {
|
|
226
|
-
await this.new_with_mark(env, tx,
|
|
187
|
+
await this.new_with_mark(env, tx, ObjectType.Allocation, buyResult?.allocation, GetObject(n.namedNewAllocation));
|
|
227
188
|
}
|
|
228
189
|
if (buyResult?.progress) {
|
|
229
190
|
if (n?.namedNewProgress != null) {
|
|
230
|
-
await this.new_with_mark(env, tx,
|
|
191
|
+
await this.new_with_mark(env, tx, ObjectType.Progress, progressCreate(tx, buyResult?.progress), GetObject(n.namedNewProgress));
|
|
231
192
|
}
|
|
232
193
|
else {
|
|
233
|
-
(
|
|
194
|
+
progressCreate(tx, buyResult?.progress);
|
|
234
195
|
}
|
|
235
196
|
}
|
|
236
197
|
if (buyResult?.order) {
|
|
237
|
-
const addr = (
|
|
198
|
+
const addr = orderCreate(tx, buyResult?.order);
|
|
238
199
|
if (n?.namedNewOrder != null) {
|
|
239
|
-
await this.new_with_mark(env, tx,
|
|
200
|
+
await this.new_with_mark(env, tx, ObjectType.Order, addr, GetObject(n.namedNewOrder));
|
|
240
201
|
}
|
|
241
202
|
}
|
|
242
203
|
}
|
|
@@ -271,14 +232,14 @@ class CallService extends base_js_1.CallBase {
|
|
|
271
232
|
case "add":
|
|
272
233
|
case "set": {
|
|
273
234
|
if (this.data.repositories.objects.length >
|
|
274
|
-
|
|
275
|
-
|
|
235
|
+
MAX_REPOSITORY_COUNT) {
|
|
236
|
+
W_ERROR(WErrors.InvalidParam, "CallService_Data.data.repositories.objects:" +
|
|
276
237
|
this.data.repositories.objects);
|
|
277
238
|
}
|
|
278
239
|
if (this.data.repositories.op === "set") {
|
|
279
240
|
repository_clear(tx, object, this.parameter_type, permission, passport);
|
|
280
241
|
}
|
|
281
|
-
const r = await
|
|
242
|
+
const r = await LocalMark.Instance().get_many_address_availables(this.data.repositories.objects);
|
|
282
243
|
r.forEach((repo) => {
|
|
283
244
|
repository_add(tx, object, this.parameter_type, permission, repo, passport);
|
|
284
245
|
});
|
|
@@ -286,11 +247,11 @@ class CallService extends base_js_1.CallBase {
|
|
|
286
247
|
}
|
|
287
248
|
case "remove": {
|
|
288
249
|
if (this.data.repositories.objects.length >
|
|
289
|
-
|
|
290
|
-
|
|
250
|
+
MAX_REPOSITORY_COUNT) {
|
|
251
|
+
W_ERROR(WErrors.InvalidParam, "CallService_Data.data.repositories.objects:" +
|
|
291
252
|
this.data.repositories.objects);
|
|
292
253
|
}
|
|
293
|
-
const addrs = await
|
|
254
|
+
const addrs = await LocalMark.Instance().get_many_address_availables(this.data.repositories.objects);
|
|
294
255
|
repository_remove(tx, object, this.parameter_type, permission, addrs, passport);
|
|
295
256
|
break;
|
|
296
257
|
}
|
|
@@ -304,24 +265,24 @@ class CallService extends base_js_1.CallBase {
|
|
|
304
265
|
switch (this.data.rewards.op) {
|
|
305
266
|
case "add":
|
|
306
267
|
case "set": {
|
|
307
|
-
if (this.data.rewards.objects.length >
|
|
308
|
-
|
|
268
|
+
if (this.data.rewards.objects.length > MAX_REWARD_COUNT) {
|
|
269
|
+
W_ERROR(WErrors.InvalidParam, `rewards count exceeds maximum limit ${MAX_REWARD_COUNT}`);
|
|
309
270
|
}
|
|
310
271
|
if (this.data.rewards.op === "set") {
|
|
311
272
|
reward_clear(tx, object, this.parameter_type, permission, passport);
|
|
312
273
|
}
|
|
313
274
|
// 无需localmark查询
|
|
314
|
-
const rewards = await
|
|
275
|
+
const rewards = await queryObjectsWithType(env, this.data.rewards.objects, ObjectType.Reward, "reward::Reward", false);
|
|
315
276
|
rewards.forEach((reward) => {
|
|
316
277
|
reward_add(tx, object, this.parameter_type, permission, reward.object, reward.type, passport);
|
|
317
278
|
});
|
|
318
279
|
break;
|
|
319
280
|
}
|
|
320
281
|
case "remove": {
|
|
321
|
-
if (this.data.rewards.objects.length >
|
|
322
|
-
|
|
282
|
+
if (this.data.rewards.objects.length > MAX_REWARD_COUNT) {
|
|
283
|
+
W_ERROR(WErrors.InvalidParam, `rewards count exceeds maximum limit ${MAX_REWARD_COUNT}`);
|
|
323
284
|
}
|
|
324
|
-
const addrs = await
|
|
285
|
+
const addrs = await LocalMark.Instance().get_many_address_availables(this.data.rewards.objects);
|
|
325
286
|
reward_remove(tx, object, this.parameter_type, permission, addrs, passport);
|
|
326
287
|
break;
|
|
327
288
|
}
|
|
@@ -336,13 +297,13 @@ class CallService extends base_js_1.CallBase {
|
|
|
336
297
|
case "add":
|
|
337
298
|
case "set": {
|
|
338
299
|
if (this.data.arbitrations.objects.length >
|
|
339
|
-
|
|
340
|
-
|
|
300
|
+
MAX_ARBITRATION_COUNT) {
|
|
301
|
+
W_ERROR(WErrors.InvalidParam, `arbitrations count exceeds maximum limit ${MAX_ARBITRATION_COUNT}`);
|
|
341
302
|
}
|
|
342
303
|
if (this.data.arbitrations.op === "set") {
|
|
343
304
|
arbitration_clear(tx, object, this.parameter_type, permission, passport);
|
|
344
305
|
}
|
|
345
|
-
const arbitrations = await
|
|
306
|
+
const arbitrations = await queryObjectsWithType(env, this.data.arbitrations.objects, ObjectType.Arbitration, "arbitration::Arbitration", false);
|
|
346
307
|
arbitrations.forEach((arbitration) => {
|
|
347
308
|
arbitrations_add(tx, object, this.parameter_type, permission, arbitration.object, arbitration.type, passport);
|
|
348
309
|
});
|
|
@@ -350,10 +311,10 @@ class CallService extends base_js_1.CallBase {
|
|
|
350
311
|
}
|
|
351
312
|
case "remove": {
|
|
352
313
|
if (this.data.arbitrations.objects.length >
|
|
353
|
-
|
|
354
|
-
|
|
314
|
+
MAX_ARBITRATION_COUNT) {
|
|
315
|
+
W_ERROR(WErrors.InvalidParam, `arbitrations count exceeds maximum limit ${MAX_ARBITRATION_COUNT}`);
|
|
355
316
|
}
|
|
356
|
-
const addrs = await
|
|
317
|
+
const addrs = await LocalMark.Instance().get_many_address_availables(this.data.arbitrations.objects);
|
|
357
318
|
arbitrations_remove(tx, object, this.parameter_type, permission, addrs, passport);
|
|
358
319
|
break;
|
|
359
320
|
}
|
|
@@ -367,17 +328,17 @@ class CallService extends base_js_1.CallBase {
|
|
|
367
328
|
await discount(tx, object, this.parameter_type, permission, this.data.discount, passport);
|
|
368
329
|
}
|
|
369
330
|
if (this.data.discount_destroy != null) {
|
|
370
|
-
const r = await
|
|
331
|
+
const r = await LocalMark.Instance().get_many_address_availables(this.data.discount_destroy);
|
|
371
332
|
discount_destroy(tx, r);
|
|
372
333
|
}
|
|
373
334
|
if (this.data.machine !== undefined) {
|
|
374
335
|
if (this.data.machine) {
|
|
375
|
-
const m = await
|
|
336
|
+
const m = await LocalMark.Instance().get_address(this.data.machine);
|
|
376
337
|
if (m) {
|
|
377
338
|
this.data.machine = m;
|
|
378
339
|
}
|
|
379
340
|
else {
|
|
380
|
-
|
|
341
|
+
W_ERROR(WErrors.IsValidArgType, `Machine not found ${this.data.machine}`);
|
|
381
342
|
}
|
|
382
343
|
}
|
|
383
344
|
machine_set(tx, object, this.parameter_type, permission, this.data.machine, passport);
|
|
@@ -388,7 +349,7 @@ class CallService extends base_js_1.CallBase {
|
|
|
388
349
|
if (this.data.order_allocators !== undefined) {
|
|
389
350
|
// localMark 查询在allocators中完成
|
|
390
351
|
order_allocators_set(tx, object, this.parameter_type, permission, this.data.order_allocators
|
|
391
|
-
? await
|
|
352
|
+
? await allocators(tx, this.data.order_allocators)
|
|
392
353
|
: null, passport);
|
|
393
354
|
}
|
|
394
355
|
if (this.data.compensation_fund_add != null) {
|
|
@@ -401,14 +362,14 @@ class CallService extends base_js_1.CallBase {
|
|
|
401
362
|
if (this.data.compensation_fund_receive != null &&
|
|
402
363
|
this.object_address) {
|
|
403
364
|
if (this.data.compensation_fund_receive === "recently") {
|
|
404
|
-
const received = await
|
|
365
|
+
const received = await query_received({
|
|
405
366
|
object: this.object_address,
|
|
406
367
|
network: env.network,
|
|
407
368
|
no_cache: env.no_cache,
|
|
408
369
|
});
|
|
409
370
|
// 检查received的类型,如果是ReceivedNormal[],需要转换为ReceivedBalance
|
|
410
371
|
if (Array.isArray(received)) {
|
|
411
|
-
|
|
372
|
+
W_ERROR(WErrors.InvalidParam, "CallAllocation_Data.data.received_coins: received is ReceivedNormal[]");
|
|
412
373
|
}
|
|
413
374
|
else {
|
|
414
375
|
// 如果是ReceivedBalance类型,直接赋值
|
|
@@ -420,16 +381,16 @@ class CallService extends base_js_1.CallBase {
|
|
|
420
381
|
this.data.compensation_fund_receive.received?.length > 0) {
|
|
421
382
|
if (this.data.compensation_fund_receive.token_type !==
|
|
422
383
|
this.parameter_type) {
|
|
423
|
-
|
|
384
|
+
W_ERROR(WErrors.InvalidParam, `token_type ${this.data.compensation_fund_receive.token_type} is not equal to parameter_type ${this.parameter_type}`);
|
|
424
385
|
}
|
|
425
386
|
for (const item of this.data.compensation_fund_receive
|
|
426
387
|
.received) {
|
|
427
388
|
const [received_object, payment_object] = await Promise.all([
|
|
428
|
-
|
|
429
|
-
|
|
389
|
+
LocalMark.Instance().get_address(item.id),
|
|
390
|
+
LocalMark.Instance().get_address(item.payment),
|
|
430
391
|
]);
|
|
431
392
|
if (!received_object || !payment_object) {
|
|
432
|
-
|
|
393
|
+
W_ERROR(WErrors.IsValidArgType, `Compensation fund receive object ${item.id} or payment object ${item.payment} not found`);
|
|
433
394
|
}
|
|
434
395
|
compensation_fund_receive(tx, object, this.parameter_type, permission, item.id, item.payment, passport);
|
|
435
396
|
}
|
|
@@ -438,24 +399,24 @@ class CallService extends base_js_1.CallBase {
|
|
|
438
399
|
if (this.data.owner_receive != null && this.object_address) {
|
|
439
400
|
// owner_receive 中完成地址查询
|
|
440
401
|
if (this.data.owner_receive === "recently") {
|
|
441
|
-
this.data.owner_receive = await
|
|
402
|
+
this.data.owner_receive = await query_received({
|
|
442
403
|
object: this.object_address,
|
|
443
404
|
all_type: true,
|
|
444
405
|
network: env.network,
|
|
445
406
|
no_cache: env.no_cache,
|
|
446
407
|
});
|
|
447
408
|
}
|
|
448
|
-
await
|
|
409
|
+
await owner_receive(tx, object, permission, this.data.owner_receive, this.parameter_type, (name) => `${PackageAddress}::service::${name}`, passport);
|
|
449
410
|
}
|
|
450
411
|
// 处理 um
|
|
451
412
|
if (this.data.um !== undefined) {
|
|
452
413
|
let um_address = null;
|
|
453
414
|
if (this.data.um) {
|
|
454
415
|
um_address =
|
|
455
|
-
(await
|
|
416
|
+
(await LocalMark.Instance().get_address(this.data.um)) ||
|
|
456
417
|
null;
|
|
457
418
|
if (!um_address) {
|
|
458
|
-
|
|
419
|
+
W_ERROR(WErrors.InvalidParam, "CallService_Data.data.um:" + this.data.um);
|
|
459
420
|
}
|
|
460
421
|
}
|
|
461
422
|
um_set(tx, object, this.parameter_type, permission, um_address, passport);
|
|
@@ -467,116 +428,115 @@ class CallService extends base_js_1.CallBase {
|
|
|
467
428
|
publish(tx, object, this.parameter_type, permission, passport);
|
|
468
429
|
}
|
|
469
430
|
if (!this.permission_address) {
|
|
470
|
-
const p =
|
|
471
|
-
await this.new_with_mark(env, tx,
|
|
431
|
+
const p = GetObject(this.data?.object);
|
|
432
|
+
await this.new_with_mark(env, tx, ObjectType.Permission, permissionCreate(tx, permission), GetObject(p.permission));
|
|
472
433
|
}
|
|
473
434
|
if (!this.object_address) {
|
|
474
|
-
await this.new_with_mark(env, tx,
|
|
435
|
+
await this.new_with_mark(env, tx, ObjectType.Service, create(tx, object, this.parameter_type), GetObject(this.data?.object));
|
|
475
436
|
}
|
|
476
437
|
}
|
|
477
438
|
checkPublished = (op) => {
|
|
478
439
|
if (this.content && !this.content.bPublished) {
|
|
479
|
-
|
|
440
|
+
W_ERROR(WErrors.Fail, `Service object has not been published yet, so the operation (${op}) cannot proceed.`);
|
|
480
441
|
}
|
|
481
442
|
};
|
|
482
443
|
checkNotPublished = (op) => {
|
|
483
444
|
if (this.content && this.content.bPublished) {
|
|
484
|
-
|
|
445
|
+
W_ERROR(WErrors.Fail, `Service object has been published and operation (${op}) cannot proceed.
|
|
485
446
|
If further modifications are needed, you can 'clone' a new Service and then proceed with the operation.`);
|
|
486
447
|
}
|
|
487
448
|
};
|
|
488
449
|
checkNotPaused = (op) => {
|
|
489
450
|
if (this.content && this.content.bPaused) {
|
|
490
|
-
|
|
451
|
+
W_ERROR(WErrors.Fail, `Service object has been paused and operation (${op}) cannot proceed.`);
|
|
491
452
|
}
|
|
492
453
|
};
|
|
493
454
|
order_allowed() {
|
|
494
455
|
if (this.content?.bPaused) {
|
|
495
|
-
|
|
456
|
+
W_ERROR(WErrors.InvalidParam, "Service is paused");
|
|
496
457
|
return false;
|
|
497
458
|
}
|
|
498
459
|
if (this.content?.bPublished !== true) {
|
|
499
|
-
|
|
460
|
+
W_ERROR(WErrors.InvalidParam, "Service is not published");
|
|
500
461
|
return false;
|
|
501
462
|
}
|
|
502
463
|
return true;
|
|
503
464
|
}
|
|
504
465
|
}
|
|
505
|
-
exports.CallService = CallService;
|
|
506
466
|
// ================================================
|
|
507
467
|
// 常量定义
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
468
|
+
export const MAX_SALE_COUNT = 50;
|
|
469
|
+
export const MAX_REPOSITORY_COUNT = 100;
|
|
470
|
+
export const MAX_ARBITRATION_COUNT = 20;
|
|
471
|
+
export const MAX_REWARD_COUNT = 20;
|
|
472
|
+
export const MAX_CUSTOMER_REQUIRED_INFO_COUNT = 10;
|
|
473
|
+
export const MAX_PUBKEY_LENGTH = 1024;
|
|
474
|
+
export const MAX_DISCOUNT_COUNT_ONCE = 1000;
|
|
475
|
+
export const MAX_DISCOUNT_RECEIVER_ONCE = 1000;
|
|
476
|
+
export const MAX_DISCOUNT_TOTAL_COUNT = 20000;
|
|
477
|
+
export const MAX_REQUIRED_INFO_SIZE = 20;
|
|
478
|
+
export const DEFAULT_COMPENSATION_LOCK_DURATION = 2592000000; // 30 days
|
|
479
|
+
export const DISCOUNT_TYPE_RATES = 0;
|
|
480
|
+
export const DISCOUNT_TYPE_MINUS = 1;
|
|
521
481
|
const MAX_WIP_LENGTH = 1024;
|
|
522
482
|
const MAX_WIP_HASH_LENGTH = 64;
|
|
523
483
|
function sale(tx, sale) {
|
|
524
|
-
if (typeof sale.name === "string" && !
|
|
525
|
-
|
|
484
|
+
if (typeof sale.name === "string" && !isValidLongName(sale.name)) {
|
|
485
|
+
W_ERROR(WErrors.InvalidParam, `Name ${sale.name} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`);
|
|
526
486
|
}
|
|
527
487
|
if (sale.wip.length > MAX_WIP_LENGTH) {
|
|
528
|
-
|
|
488
|
+
W_ERROR(WErrors.InvalidParam, `WIP ${sale.wip} exceeds maximum length ${MAX_WIP_LENGTH}`);
|
|
529
489
|
}
|
|
530
|
-
if (!
|
|
531
|
-
|
|
490
|
+
if (!isValidHttpUrl(sale.wip)) {
|
|
491
|
+
W_ERROR(WErrors.IsValidHttpUrl, `WIP ${sale.wip} is not a valid HTTP/HTTPS URL`);
|
|
532
492
|
}
|
|
533
493
|
if (sale.wip_hash.length > MAX_WIP_HASH_LENGTH) {
|
|
534
|
-
|
|
494
|
+
W_ERROR(WErrors.InvalidParam, `WIP hash ${sale.wip_hash} exceeds maximum length ${MAX_WIP_HASH_LENGTH}`);
|
|
535
495
|
}
|
|
536
496
|
return tx.moveCall({
|
|
537
|
-
target:
|
|
497
|
+
target: serviceFn("sale"),
|
|
538
498
|
arguments: [
|
|
539
|
-
|
|
499
|
+
toTxString(tx, sale.name),
|
|
540
500
|
tx.pure.u64(sale.price),
|
|
541
501
|
tx.pure.u64(sale.stock),
|
|
542
502
|
tx.pure.bool(sale.suspension),
|
|
543
|
-
|
|
544
|
-
|
|
503
|
+
toTxString(tx, sale.wip),
|
|
504
|
+
toTxString(tx, sale.wip_hash),
|
|
545
505
|
],
|
|
546
506
|
});
|
|
547
507
|
}
|
|
548
508
|
function quote_item(tx, item) {
|
|
549
|
-
if (!
|
|
550
|
-
|
|
509
|
+
if (!isValidLongName(item.name)) {
|
|
510
|
+
W_ERROR(WErrors.InvalidParam, `Quote item name ${item.name} is not valid`);
|
|
551
511
|
}
|
|
552
|
-
if (!
|
|
553
|
-
|
|
512
|
+
if (!isValidU64(item.stock)) {
|
|
513
|
+
W_ERROR(WErrors.IsValidU64, `Quote item stock ${item.stock} is not valid`);
|
|
554
514
|
}
|
|
555
515
|
if (item.wip_hash.length > MAX_WIP_HASH_LENGTH) {
|
|
556
|
-
|
|
516
|
+
W_ERROR(WErrors.InvalidParam, `Quote item wip_hash ${item.wip_hash} exceeds maximum length ${MAX_WIP_HASH_LENGTH}`);
|
|
557
517
|
}
|
|
558
518
|
return tx.moveCall({
|
|
559
|
-
target:
|
|
519
|
+
target: serviceFn("quote_item"),
|
|
560
520
|
arguments: [
|
|
561
|
-
|
|
521
|
+
toTxString(tx, item.name),
|
|
562
522
|
tx.pure.u64(item.stock),
|
|
563
|
-
|
|
523
|
+
toTxString(tx, item.wip_hash),
|
|
564
524
|
],
|
|
565
525
|
});
|
|
566
526
|
}
|
|
567
|
-
function discount_send(tx, discount, recipient) {
|
|
527
|
+
export function discount_send(tx, discount, recipient) {
|
|
568
528
|
if (discount.length === 0) {
|
|
569
529
|
return;
|
|
570
530
|
}
|
|
571
|
-
|
|
572
|
-
if (discount.length >
|
|
573
|
-
|
|
531
|
+
validObjects([...discount, recipient]);
|
|
532
|
+
if (discount.length > MAX_DISCOUNT_COUNT_ONCE) {
|
|
533
|
+
W_ERROR(WErrors.InvalidParam, `Discount count ${discount.length} exceeds maximum limit ${MAX_DISCOUNT_COUNT_ONCE}`);
|
|
574
534
|
}
|
|
575
535
|
if (discount.length === 1) {
|
|
576
536
|
tx.moveCall({
|
|
577
|
-
target:
|
|
537
|
+
target: serviceFn("discount_send_singleton"),
|
|
578
538
|
arguments: [
|
|
579
|
-
|
|
539
|
+
toTxObject(tx, discount[0]),
|
|
580
540
|
tx.pure.address(recipient),
|
|
581
541
|
],
|
|
582
542
|
});
|
|
@@ -584,78 +544,78 @@ function discount_send(tx, discount, recipient) {
|
|
|
584
544
|
}
|
|
585
545
|
else {
|
|
586
546
|
tx.moveCall({
|
|
587
|
-
target:
|
|
547
|
+
target: serviceFn("discount_send"),
|
|
588
548
|
arguments: [
|
|
589
549
|
tx.makeMoveVec({
|
|
590
550
|
elements: discount,
|
|
591
|
-
type: `${
|
|
551
|
+
type: `${PackageAddress}::service::Discount`,
|
|
592
552
|
}),
|
|
593
553
|
tx.pure.address(recipient),
|
|
594
554
|
],
|
|
595
555
|
});
|
|
596
556
|
}
|
|
597
557
|
}
|
|
598
|
-
function discount_destroy(tx, discount) {
|
|
599
|
-
|
|
558
|
+
export function discount_destroy(tx, discount) {
|
|
559
|
+
validObjects([...discount]);
|
|
600
560
|
discount.forEach((item) => {
|
|
601
561
|
tx.moveCall({
|
|
602
|
-
target:
|
|
603
|
-
arguments: [
|
|
562
|
+
target: serviceFn("discount_destroy"),
|
|
563
|
+
arguments: [toTxObject(tx, item)],
|
|
604
564
|
});
|
|
605
565
|
});
|
|
606
566
|
}
|
|
607
|
-
const buy = async (env, tx, service, service_type, machine, buy, passport) => {
|
|
567
|
+
export const buy = async (env, tx, service, service_type, machine, buy, passport) => {
|
|
608
568
|
if (buy.items.length === 0) {
|
|
609
569
|
return undefined;
|
|
610
570
|
}
|
|
611
|
-
|
|
612
|
-
if (!
|
|
613
|
-
|
|
571
|
+
validObjects([service, buy.discount, machine, passport]);
|
|
572
|
+
if (!IsValidArgType(service_type)) {
|
|
573
|
+
W_ERROR(WErrors.InvalidParam, `Buy service type ${service_type} is not valid`);
|
|
614
574
|
}
|
|
615
|
-
if (!
|
|
616
|
-
if (!
|
|
617
|
-
|
|
575
|
+
if (!isValidArray(buy.items, (item) => {
|
|
576
|
+
if (!isValidLongName(item.name)) {
|
|
577
|
+
W_ERROR(WErrors.InvalidParam, `Buy item name ${item.name} is not valid`);
|
|
618
578
|
}
|
|
619
|
-
if (!
|
|
620
|
-
|
|
579
|
+
if (!isValidU64(item.stock)) {
|
|
580
|
+
W_ERROR(WErrors.IsValidU64, `Buy item stock ${item.stock} is not valid`);
|
|
621
581
|
}
|
|
622
582
|
return true;
|
|
623
583
|
})) {
|
|
624
|
-
|
|
584
|
+
W_ERROR(WErrors.InvalidParam, "Buy items is not valid");
|
|
625
585
|
}
|
|
626
586
|
if (typeof buy.payment_remark === "string" &&
|
|
627
|
-
!
|
|
628
|
-
|
|
587
|
+
!isValidName(buy.payment_remark)) {
|
|
588
|
+
W_ERROR(WErrors.InvalidParam, `Buy payment remark ${buy.payment_remark} is not valid`);
|
|
629
589
|
}
|
|
630
590
|
buy.payment_remark = buy.payment_remark || "";
|
|
631
|
-
if (buy.payment_index != null && !
|
|
632
|
-
|
|
591
|
+
if (buy.payment_index != null && !isValidU64(buy.payment_index)) {
|
|
592
|
+
W_ERROR(WErrors.IsValidU64, `Buy payment index ${buy.payment_index} is not valid`);
|
|
633
593
|
}
|
|
634
|
-
const coinParam = await
|
|
635
|
-
buy.discount = await
|
|
594
|
+
const coinParam = await getCoinParam(env, tx, buy.total_pay, service_type);
|
|
595
|
+
buy.discount = await LocalMark.Instance().get_address(buy.discount);
|
|
636
596
|
let quote = undefined;
|
|
637
597
|
if (buy.discount) {
|
|
638
598
|
quote = tx.moveCall({
|
|
639
|
-
target:
|
|
599
|
+
target: serviceFn("quote_with_discount"),
|
|
640
600
|
arguments: [
|
|
641
|
-
|
|
601
|
+
toTxObject(tx, service),
|
|
642
602
|
tx.makeMoveVec({
|
|
643
603
|
elements: buy.items.map((item) => quote_item(tx, item)),
|
|
644
|
-
type: `${
|
|
604
|
+
type: `${PackageAddress}::service::QuoteItem`,
|
|
645
605
|
}),
|
|
646
|
-
|
|
606
|
+
toTxObject(tx, buy.discount),
|
|
647
607
|
],
|
|
648
608
|
typeArguments: [service_type],
|
|
649
609
|
});
|
|
650
610
|
}
|
|
651
611
|
else {
|
|
652
612
|
quote = tx.moveCall({
|
|
653
|
-
target:
|
|
613
|
+
target: serviceFn("quote"),
|
|
654
614
|
arguments: [
|
|
655
|
-
|
|
615
|
+
toTxObject(tx, service),
|
|
656
616
|
tx.makeMoveVec({
|
|
657
617
|
elements: buy.items.map((item) => quote_item(tx, item)),
|
|
658
|
-
type: `${
|
|
618
|
+
type: `${PackageAddress}::service::QuoteItem`,
|
|
659
619
|
}),
|
|
660
620
|
],
|
|
661
621
|
typeArguments: [service_type],
|
|
@@ -664,10 +624,10 @@ const buy = async (env, tx, service, service_type, machine, buy, passport) => {
|
|
|
664
624
|
let order;
|
|
665
625
|
if (passport) {
|
|
666
626
|
order = tx.moveCall({
|
|
667
|
-
target:
|
|
627
|
+
target: serviceFn("buy_with_passport"),
|
|
668
628
|
arguments: [
|
|
669
|
-
|
|
670
|
-
|
|
629
|
+
toTxObject(tx, service),
|
|
630
|
+
toTxObject(tx, passport),
|
|
671
631
|
quote,
|
|
672
632
|
tx.object.mutRegistrar(),
|
|
673
633
|
tx.object.clock(),
|
|
@@ -677,9 +637,9 @@ const buy = async (env, tx, service, service_type, machine, buy, passport) => {
|
|
|
677
637
|
}
|
|
678
638
|
else {
|
|
679
639
|
order = tx.moveCall({
|
|
680
|
-
target:
|
|
640
|
+
target: serviceFn("buy"),
|
|
681
641
|
arguments: [
|
|
682
|
-
|
|
642
|
+
toTxObject(tx, service),
|
|
683
643
|
quote,
|
|
684
644
|
tx.object.mutRegistrar(),
|
|
685
645
|
tx.object.clock(),
|
|
@@ -691,10 +651,10 @@ const buy = async (env, tx, service, service_type, machine, buy, passport) => {
|
|
|
691
651
|
order: order,
|
|
692
652
|
};
|
|
693
653
|
result.allocation = tx.moveCall({
|
|
694
|
-
target:
|
|
654
|
+
target: serviceFn("order_allocation"),
|
|
695
655
|
arguments: [
|
|
696
|
-
|
|
697
|
-
|
|
656
|
+
toTxObject(tx, service),
|
|
657
|
+
toTxObject(tx, order),
|
|
698
658
|
coinParam,
|
|
699
659
|
tx.pure.string(buy.payment_remark ?? ""),
|
|
700
660
|
tx.pure.u64(buy.payment_index || 0),
|
|
@@ -705,11 +665,11 @@ const buy = async (env, tx, service, service_type, machine, buy, passport) => {
|
|
|
705
665
|
});
|
|
706
666
|
if (machine) {
|
|
707
667
|
result.progress = tx.moveCall({
|
|
708
|
-
target:
|
|
668
|
+
target: serviceFn("order_progress"),
|
|
709
669
|
arguments: [
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
670
|
+
toTxObject(tx, service),
|
|
671
|
+
toTxObject(tx, order),
|
|
672
|
+
toTxObject(tx, machine),
|
|
713
673
|
tx.object.mutRegistrar(),
|
|
714
674
|
tx.object.clock(),
|
|
715
675
|
],
|
|
@@ -718,24 +678,23 @@ const buy = async (env, tx, service, service_type, machine, buy, passport) => {
|
|
|
718
678
|
}
|
|
719
679
|
return result;
|
|
720
680
|
};
|
|
721
|
-
exports.buy = buy;
|
|
722
681
|
// ================================================
|
|
723
682
|
// 构造函数和设置函数
|
|
724
|
-
function newService(tx, service_type, permission, description, passport) {
|
|
725
|
-
|
|
726
|
-
if (typeof description === "string" && !
|
|
727
|
-
|
|
683
|
+
export function newService(tx, service_type, permission, description, passport) {
|
|
684
|
+
validObjects([permission, passport]);
|
|
685
|
+
if (typeof description === "string" && !isValidDescription(description)) {
|
|
686
|
+
W_ERROR(WErrors.IsValidDescription, `Description exceeds maximum length ${MAX_DESCRIPTION_LENGTH}`);
|
|
728
687
|
}
|
|
729
|
-
if (!
|
|
730
|
-
|
|
688
|
+
if (!IsValidArgType(service_type)) {
|
|
689
|
+
W_ERROR(WErrors.InvalidParam, `New service type ${service_type} is not valid`);
|
|
731
690
|
}
|
|
732
691
|
if (passport) {
|
|
733
692
|
return tx.moveCall({
|
|
734
|
-
target:
|
|
693
|
+
target: serviceFn("new_with_passport"),
|
|
735
694
|
arguments: [
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
695
|
+
toTxObject(tx, permission),
|
|
696
|
+
toTxObject(tx, passport),
|
|
697
|
+
toTxString(tx, description),
|
|
739
698
|
tx.object.mutRegistrar(),
|
|
740
699
|
tx.object.clock(),
|
|
741
700
|
],
|
|
@@ -744,10 +703,10 @@ function newService(tx, service_type, permission, description, passport) {
|
|
|
744
703
|
}
|
|
745
704
|
else {
|
|
746
705
|
return tx.moveCall({
|
|
747
|
-
target:
|
|
706
|
+
target: serviceFn("new"),
|
|
748
707
|
arguments: [
|
|
749
|
-
|
|
750
|
-
|
|
708
|
+
toTxObject(tx, permission),
|
|
709
|
+
toTxString(tx, description),
|
|
751
710
|
tx.object.mutRegistrar(),
|
|
752
711
|
tx.object.clock(),
|
|
753
712
|
],
|
|
@@ -755,52 +714,52 @@ function newService(tx, service_type, permission, description, passport) {
|
|
|
755
714
|
});
|
|
756
715
|
}
|
|
757
716
|
}
|
|
758
|
-
function description_set(tx, service, service_type, permission, description, passport) {
|
|
759
|
-
|
|
760
|
-
if (typeof description === "string" && !
|
|
761
|
-
|
|
717
|
+
export function description_set(tx, service, service_type, permission, description, passport) {
|
|
718
|
+
validObjects([service, permission, passport]);
|
|
719
|
+
if (typeof description === "string" && !isValidDescription(description)) {
|
|
720
|
+
W_ERROR(WErrors.IsValidDescription, `Description exceeds maximum length ${MAX_DESCRIPTION_LENGTH}`);
|
|
762
721
|
}
|
|
763
|
-
if (!
|
|
764
|
-
|
|
722
|
+
if (!IsValidArgType(service_type)) {
|
|
723
|
+
W_ERROR(WErrors.InvalidParam, `Description set service type ${service_type} is not valid`);
|
|
765
724
|
}
|
|
766
725
|
if (passport) {
|
|
767
726
|
tx.moveCall({
|
|
768
|
-
target:
|
|
727
|
+
target: serviceFn("description_set_with_passport"),
|
|
769
728
|
arguments: [
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
729
|
+
toTxObject(tx, service),
|
|
730
|
+
toTxObject(tx, permission),
|
|
731
|
+
toTxObject(tx, passport),
|
|
732
|
+
toTxString(tx, description),
|
|
774
733
|
],
|
|
775
734
|
typeArguments: [service_type],
|
|
776
735
|
});
|
|
777
736
|
}
|
|
778
737
|
else {
|
|
779
738
|
tx.moveCall({
|
|
780
|
-
target:
|
|
739
|
+
target: serviceFn("description_set"),
|
|
781
740
|
arguments: [
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
741
|
+
toTxObject(tx, service),
|
|
742
|
+
toTxObject(tx, permission),
|
|
743
|
+
toTxString(tx, description),
|
|
785
744
|
],
|
|
786
745
|
typeArguments: [service_type],
|
|
787
746
|
});
|
|
788
747
|
}
|
|
789
748
|
}
|
|
790
|
-
function um_set(tx, service, service_type, permission, um, passport) {
|
|
791
|
-
|
|
792
|
-
if (!
|
|
793
|
-
|
|
749
|
+
export function um_set(tx, service, service_type, permission, um, passport) {
|
|
750
|
+
validObjects([service, permission]);
|
|
751
|
+
if (!IsValidArgType(service_type)) {
|
|
752
|
+
W_ERROR(WErrors.InvalidParam, `Service type ${service_type} is not valid`);
|
|
794
753
|
}
|
|
795
754
|
if (um) {
|
|
796
755
|
if (passport) {
|
|
797
756
|
tx.moveCall({
|
|
798
|
-
target:
|
|
757
|
+
target: serviceFn(`um_set_with_passport`),
|
|
799
758
|
arguments: [
|
|
800
|
-
|
|
801
|
-
|
|
759
|
+
toTxObject(tx, service),
|
|
760
|
+
toTxObject(tx, permission),
|
|
802
761
|
passport,
|
|
803
|
-
|
|
762
|
+
toTxObject(tx, um),
|
|
804
763
|
tx.object.mutRegistrar(),
|
|
805
764
|
tx.object.clock(),
|
|
806
765
|
],
|
|
@@ -809,11 +768,11 @@ function um_set(tx, service, service_type, permission, um, passport) {
|
|
|
809
768
|
}
|
|
810
769
|
else {
|
|
811
770
|
tx.moveCall({
|
|
812
|
-
target:
|
|
771
|
+
target: serviceFn(`um_set`),
|
|
813
772
|
arguments: [
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
773
|
+
toTxObject(tx, service),
|
|
774
|
+
toTxObject(tx, permission),
|
|
775
|
+
toTxObject(tx, um),
|
|
817
776
|
tx.object.mutRegistrar(),
|
|
818
777
|
tx.object.clock(),
|
|
819
778
|
],
|
|
@@ -824,10 +783,10 @@ function um_set(tx, service, service_type, permission, um, passport) {
|
|
|
824
783
|
else {
|
|
825
784
|
if (passport) {
|
|
826
785
|
tx.moveCall({
|
|
827
|
-
target:
|
|
786
|
+
target: serviceFn(`um_none_with_passport`),
|
|
828
787
|
arguments: [
|
|
829
|
-
|
|
830
|
-
|
|
788
|
+
toTxObject(tx, service),
|
|
789
|
+
toTxObject(tx, permission),
|
|
831
790
|
passport,
|
|
832
791
|
tx.object.mutRegistrar(),
|
|
833
792
|
],
|
|
@@ -836,10 +795,10 @@ function um_set(tx, service, service_type, permission, um, passport) {
|
|
|
836
795
|
}
|
|
837
796
|
else {
|
|
838
797
|
tx.moveCall({
|
|
839
|
-
target:
|
|
798
|
+
target: serviceFn(`um_none`),
|
|
840
799
|
arguments: [
|
|
841
|
-
|
|
842
|
-
|
|
800
|
+
toTxObject(tx, service),
|
|
801
|
+
toTxObject(tx, permission),
|
|
843
802
|
tx.object.mutRegistrar(),
|
|
844
803
|
],
|
|
845
804
|
typeArguments: [service_type],
|
|
@@ -847,67 +806,67 @@ function um_set(tx, service, service_type, permission, um, passport) {
|
|
|
847
806
|
}
|
|
848
807
|
}
|
|
849
808
|
}
|
|
850
|
-
function location_set(tx, service, service_type, permission, location, passport) {
|
|
851
|
-
|
|
852
|
-
if (typeof location === "string" && !
|
|
853
|
-
|
|
809
|
+
export function location_set(tx, service, service_type, permission, location, passport) {
|
|
810
|
+
validObjects([service, permission, passport]);
|
|
811
|
+
if (typeof location === "string" && !isValidLongName(location)) {
|
|
812
|
+
W_ERROR(WErrors.InvalidParam, `Location ${location} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`);
|
|
854
813
|
}
|
|
855
|
-
if (!
|
|
856
|
-
|
|
814
|
+
if (!IsValidArgType(service_type)) {
|
|
815
|
+
W_ERROR(WErrors.InvalidParam, `Location set service type ${service_type} is not valid`);
|
|
857
816
|
}
|
|
858
817
|
if (passport) {
|
|
859
818
|
tx.moveCall({
|
|
860
|
-
target:
|
|
819
|
+
target: serviceFn("location_set_with_passport"),
|
|
861
820
|
arguments: [
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
821
|
+
toTxObject(tx, service),
|
|
822
|
+
toTxObject(tx, permission),
|
|
823
|
+
toTxObject(tx, passport),
|
|
824
|
+
toTxString(tx, location),
|
|
866
825
|
],
|
|
867
826
|
typeArguments: [service_type],
|
|
868
827
|
});
|
|
869
828
|
}
|
|
870
829
|
else {
|
|
871
830
|
tx.moveCall({
|
|
872
|
-
target:
|
|
831
|
+
target: serviceFn("location_set"),
|
|
873
832
|
arguments: [
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
833
|
+
toTxObject(tx, service),
|
|
834
|
+
toTxObject(tx, permission),
|
|
835
|
+
toTxString(tx, location),
|
|
877
836
|
],
|
|
878
837
|
typeArguments: [service_type],
|
|
879
838
|
});
|
|
880
839
|
}
|
|
881
840
|
}
|
|
882
|
-
function create(tx, service, service_type) {
|
|
883
|
-
|
|
884
|
-
if (!
|
|
885
|
-
|
|
841
|
+
export function create(tx, service, service_type) {
|
|
842
|
+
validObjects([service]);
|
|
843
|
+
if (!IsValidArgType(service_type)) {
|
|
844
|
+
W_ERROR(WErrors.InvalidParam, `Create service type ${service_type} is not valid`);
|
|
886
845
|
}
|
|
887
846
|
return tx.moveCall({
|
|
888
|
-
target:
|
|
889
|
-
arguments: [
|
|
847
|
+
target: serviceFn("create"),
|
|
848
|
+
arguments: [toTxObject(tx, service)],
|
|
890
849
|
typeArguments: [service_type],
|
|
891
850
|
});
|
|
892
851
|
}
|
|
893
|
-
function sales_add(tx, service, service_type, permission, sales, passport) {
|
|
852
|
+
export function sales_add(tx, service, service_type, permission, sales, passport) {
|
|
894
853
|
if (sales.length === 0) {
|
|
895
854
|
return;
|
|
896
855
|
}
|
|
897
|
-
|
|
898
|
-
if (!
|
|
899
|
-
|
|
856
|
+
validObjects([service, permission, passport]);
|
|
857
|
+
if (!IsValidArgType(service_type)) {
|
|
858
|
+
W_ERROR(WErrors.InvalidParam, `Sales add service type ${service_type} is not valid`);
|
|
900
859
|
}
|
|
901
860
|
if (passport) {
|
|
902
861
|
tx.moveCall({
|
|
903
|
-
target:
|
|
862
|
+
target: serviceFn("sales_add_with_passport"),
|
|
904
863
|
arguments: [
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
864
|
+
toTxObject(tx, service),
|
|
865
|
+
toTxObject(tx, permission),
|
|
866
|
+
toTxObject(tx, passport),
|
|
908
867
|
tx.makeMoveVec({
|
|
909
868
|
elements: sales.map((s) => sale(tx, s)),
|
|
910
|
-
type: `${
|
|
869
|
+
type: `${PackageAddress}::service::Sale`,
|
|
911
870
|
}),
|
|
912
871
|
],
|
|
913
872
|
typeArguments: [service_type],
|
|
@@ -915,34 +874,34 @@ function sales_add(tx, service, service_type, permission, sales, passport) {
|
|
|
915
874
|
}
|
|
916
875
|
else {
|
|
917
876
|
tx.moveCall({
|
|
918
|
-
target:
|
|
877
|
+
target: serviceFn("sales_add"),
|
|
919
878
|
arguments: [
|
|
920
|
-
|
|
921
|
-
|
|
879
|
+
toTxObject(tx, service),
|
|
880
|
+
toTxObject(tx, permission),
|
|
922
881
|
tx.makeMoveVec({
|
|
923
882
|
elements: sales.map((s) => sale(tx, s)),
|
|
924
|
-
type: `${
|
|
883
|
+
type: `${PackageAddress}::service::Sale`,
|
|
925
884
|
}),
|
|
926
885
|
],
|
|
927
886
|
typeArguments: [service_type],
|
|
928
887
|
});
|
|
929
888
|
}
|
|
930
889
|
}
|
|
931
|
-
function sales_remove(tx, service, service_type, permission, sales_name, passport) {
|
|
890
|
+
export function sales_remove(tx, service, service_type, permission, sales_name, passport) {
|
|
932
891
|
if (sales_name.length === 0) {
|
|
933
892
|
return;
|
|
934
893
|
}
|
|
935
|
-
|
|
936
|
-
if (!
|
|
937
|
-
|
|
894
|
+
validObjects([service, permission, passport]);
|
|
895
|
+
if (!IsValidArgType(service_type)) {
|
|
896
|
+
W_ERROR(WErrors.InvalidParam, `Sales remove service type ${service_type} is not valid`);
|
|
938
897
|
}
|
|
939
898
|
if (passport) {
|
|
940
899
|
tx.moveCall({
|
|
941
|
-
target:
|
|
900
|
+
target: serviceFn("sales_remove_with_passport"),
|
|
942
901
|
arguments: [
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
902
|
+
toTxObject(tx, service),
|
|
903
|
+
toTxObject(tx, permission),
|
|
904
|
+
toTxObject(tx, passport),
|
|
946
905
|
tx.pure.vector("string", sales_name),
|
|
947
906
|
],
|
|
948
907
|
typeArguments: [service_type],
|
|
@@ -950,58 +909,58 @@ function sales_remove(tx, service, service_type, permission, sales_name, passpor
|
|
|
950
909
|
}
|
|
951
910
|
else {
|
|
952
911
|
tx.moveCall({
|
|
953
|
-
target:
|
|
912
|
+
target: serviceFn("sales_remove"),
|
|
954
913
|
arguments: [
|
|
955
|
-
|
|
956
|
-
|
|
914
|
+
toTxObject(tx, service),
|
|
915
|
+
toTxObject(tx, permission),
|
|
957
916
|
tx.pure.vector("string", sales_name),
|
|
958
917
|
],
|
|
959
918
|
typeArguments: [service_type],
|
|
960
919
|
});
|
|
961
920
|
}
|
|
962
921
|
}
|
|
963
|
-
function sales_clear(tx, service, service_type, permission, passport) {
|
|
964
|
-
|
|
965
|
-
if (!
|
|
966
|
-
|
|
922
|
+
export function sales_clear(tx, service, service_type, permission, passport) {
|
|
923
|
+
validObjects([service, permission, passport]);
|
|
924
|
+
if (!IsValidArgType(service_type)) {
|
|
925
|
+
W_ERROR(WErrors.InvalidParam, `Sales clear service type ${service_type} is not valid`);
|
|
967
926
|
}
|
|
968
927
|
if (passport) {
|
|
969
928
|
tx.moveCall({
|
|
970
|
-
target:
|
|
929
|
+
target: serviceFn("sales_clear_with_passport"),
|
|
971
930
|
arguments: [
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
931
|
+
toTxObject(tx, service),
|
|
932
|
+
toTxObject(tx, permission),
|
|
933
|
+
toTxObject(tx, passport),
|
|
975
934
|
],
|
|
976
935
|
typeArguments: [service_type],
|
|
977
936
|
});
|
|
978
937
|
}
|
|
979
938
|
else {
|
|
980
939
|
tx.moveCall({
|
|
981
|
-
target:
|
|
982
|
-
arguments: [
|
|
940
|
+
target: serviceFn("sales_clear"),
|
|
941
|
+
arguments: [toTxObject(tx, service), toTxObject(tx, permission)],
|
|
983
942
|
typeArguments: [service_type],
|
|
984
943
|
});
|
|
985
944
|
}
|
|
986
945
|
}
|
|
987
|
-
function sales_set(tx, service, service_type, permission, sales, passport) {
|
|
946
|
+
export function sales_set(tx, service, service_type, permission, sales, passport) {
|
|
988
947
|
if (sales.length === 0) {
|
|
989
948
|
return;
|
|
990
949
|
}
|
|
991
|
-
|
|
992
|
-
if (!
|
|
993
|
-
|
|
950
|
+
validObjects([service, permission, passport]);
|
|
951
|
+
if (!IsValidArgType(service_type)) {
|
|
952
|
+
W_ERROR(WErrors.InvalidParam, `Sales set service type ${service_type} is not valid`);
|
|
994
953
|
}
|
|
995
954
|
if (passport) {
|
|
996
955
|
tx.moveCall({
|
|
997
|
-
target:
|
|
956
|
+
target: serviceFn("sales_set_with_passport"),
|
|
998
957
|
arguments: [
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
958
|
+
toTxObject(tx, service),
|
|
959
|
+
toTxObject(tx, permission),
|
|
960
|
+
toTxObject(tx, passport),
|
|
1002
961
|
tx.makeMoveVec({
|
|
1003
962
|
elements: sales.map((s) => sale(tx, s)),
|
|
1004
|
-
type: `${
|
|
963
|
+
type: `${PackageAddress}::service::Sale`,
|
|
1005
964
|
}),
|
|
1006
965
|
],
|
|
1007
966
|
typeArguments: [service_type],
|
|
@@ -1009,38 +968,38 @@ function sales_set(tx, service, service_type, permission, sales, passport) {
|
|
|
1009
968
|
}
|
|
1010
969
|
else {
|
|
1011
970
|
tx.moveCall({
|
|
1012
|
-
target:
|
|
971
|
+
target: serviceFn("sales_set"),
|
|
1013
972
|
arguments: [
|
|
1014
|
-
|
|
1015
|
-
|
|
973
|
+
toTxObject(tx, service),
|
|
974
|
+
toTxObject(tx, permission),
|
|
1016
975
|
tx.makeMoveVec({
|
|
1017
976
|
elements: sales.map((s) => sale(tx, s)),
|
|
1018
|
-
type: `${
|
|
977
|
+
type: `${PackageAddress}::service::Sale`,
|
|
1019
978
|
}),
|
|
1020
979
|
],
|
|
1021
980
|
typeArguments: [service_type],
|
|
1022
981
|
});
|
|
1023
982
|
}
|
|
1024
983
|
}
|
|
1025
|
-
function price_add(tx, service, service_type, permission, sale_name, price_add, passport) {
|
|
1026
|
-
|
|
1027
|
-
if (!
|
|
1028
|
-
|
|
984
|
+
export function price_add(tx, service, service_type, permission, sale_name, price_add, passport) {
|
|
985
|
+
validObjects([service, permission, passport]);
|
|
986
|
+
if (!IsValidArgType(service_type)) {
|
|
987
|
+
W_ERROR(WErrors.InvalidParam, `Price add service type ${service_type} is not valid`);
|
|
1029
988
|
}
|
|
1030
|
-
if (typeof sale_name === "string" && !
|
|
1031
|
-
|
|
989
|
+
if (typeof sale_name === "string" && !isValidLongName(sale_name)) {
|
|
990
|
+
W_ERROR(WErrors.InvalidParam, `Sale name ${sale_name} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`);
|
|
1032
991
|
}
|
|
1033
|
-
if (!
|
|
1034
|
-
|
|
992
|
+
if (!isValidU64(price_add)) {
|
|
993
|
+
W_ERROR(WErrors.IsValidU64, `Price add ${price_add} is not valid`);
|
|
1035
994
|
}
|
|
1036
995
|
if (passport) {
|
|
1037
996
|
tx.moveCall({
|
|
1038
|
-
target:
|
|
997
|
+
target: serviceFn("price_add_with_passport"),
|
|
1039
998
|
arguments: [
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
999
|
+
toTxObject(tx, service),
|
|
1000
|
+
toTxObject(tx, permission),
|
|
1001
|
+
toTxObject(tx, passport),
|
|
1002
|
+
toTxString(tx, sale_name),
|
|
1044
1003
|
tx.pure.u64(price_add),
|
|
1045
1004
|
],
|
|
1046
1005
|
typeArguments: [service_type],
|
|
@@ -1048,36 +1007,36 @@ function price_add(tx, service, service_type, permission, sale_name, price_add,
|
|
|
1048
1007
|
}
|
|
1049
1008
|
else {
|
|
1050
1009
|
tx.moveCall({
|
|
1051
|
-
target:
|
|
1010
|
+
target: serviceFn("price_add"),
|
|
1052
1011
|
arguments: [
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1012
|
+
toTxObject(tx, service),
|
|
1013
|
+
toTxObject(tx, permission),
|
|
1014
|
+
toTxString(tx, sale_name),
|
|
1056
1015
|
tx.pure.u64(price_add),
|
|
1057
1016
|
],
|
|
1058
1017
|
typeArguments: [service_type],
|
|
1059
1018
|
});
|
|
1060
1019
|
}
|
|
1061
1020
|
}
|
|
1062
|
-
function price_reduce(tx, service, service_type, permission, sale_name, price_reduce, passport) {
|
|
1063
|
-
|
|
1064
|
-
if (!
|
|
1065
|
-
|
|
1021
|
+
export function price_reduce(tx, service, service_type, permission, sale_name, price_reduce, passport) {
|
|
1022
|
+
validObjects([service, permission, passport]);
|
|
1023
|
+
if (!IsValidArgType(service_type)) {
|
|
1024
|
+
W_ERROR(WErrors.InvalidParam, `Price reduce service type ${service_type} is not valid`);
|
|
1066
1025
|
}
|
|
1067
|
-
if (typeof sale_name === "string" && !
|
|
1068
|
-
|
|
1026
|
+
if (typeof sale_name === "string" && !isValidLongName(sale_name)) {
|
|
1027
|
+
W_ERROR(WErrors.InvalidParam, `Sale name ${sale_name} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`);
|
|
1069
1028
|
}
|
|
1070
|
-
if (!
|
|
1071
|
-
|
|
1029
|
+
if (!isValidU64(price_reduce)) {
|
|
1030
|
+
W_ERROR(WErrors.IsValidU64, `Price reduce ${price_reduce} is not valid`);
|
|
1072
1031
|
}
|
|
1073
1032
|
if (passport) {
|
|
1074
1033
|
tx.moveCall({
|
|
1075
|
-
target:
|
|
1034
|
+
target: serviceFn("price_reduce_with_passport"),
|
|
1076
1035
|
arguments: [
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1036
|
+
toTxObject(tx, service),
|
|
1037
|
+
toTxObject(tx, permission),
|
|
1038
|
+
toTxObject(tx, passport),
|
|
1039
|
+
toTxString(tx, sale_name),
|
|
1081
1040
|
tx.pure.u64(price_reduce),
|
|
1082
1041
|
],
|
|
1083
1042
|
typeArguments: [service_type],
|
|
@@ -1085,36 +1044,36 @@ function price_reduce(tx, service, service_type, permission, sale_name, price_re
|
|
|
1085
1044
|
}
|
|
1086
1045
|
else {
|
|
1087
1046
|
tx.moveCall({
|
|
1088
|
-
target:
|
|
1047
|
+
target: serviceFn("price_reduce"),
|
|
1089
1048
|
arguments: [
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1049
|
+
toTxObject(tx, service),
|
|
1050
|
+
toTxObject(tx, permission),
|
|
1051
|
+
toTxString(tx, sale_name),
|
|
1093
1052
|
tx.pure.u64(price_reduce),
|
|
1094
1053
|
],
|
|
1095
1054
|
typeArguments: [service_type],
|
|
1096
1055
|
});
|
|
1097
1056
|
}
|
|
1098
1057
|
}
|
|
1099
|
-
function stock_add(tx, service, service_type, permission, sale_name, stock_add, passport) {
|
|
1100
|
-
|
|
1101
|
-
if (!
|
|
1102
|
-
|
|
1058
|
+
export function stock_add(tx, service, service_type, permission, sale_name, stock_add, passport) {
|
|
1059
|
+
validObjects([service, permission, passport]);
|
|
1060
|
+
if (!IsValidArgType(service_type)) {
|
|
1061
|
+
W_ERROR(WErrors.InvalidParam, `Stock add service type ${service_type} is not valid`);
|
|
1103
1062
|
}
|
|
1104
|
-
if (typeof sale_name === "string" && !
|
|
1105
|
-
|
|
1063
|
+
if (typeof sale_name === "string" && !isValidLongName(sale_name)) {
|
|
1064
|
+
W_ERROR(WErrors.InvalidParam, `Sale name ${sale_name} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`);
|
|
1106
1065
|
}
|
|
1107
|
-
if (!
|
|
1108
|
-
|
|
1066
|
+
if (!isValidU64(stock_add)) {
|
|
1067
|
+
W_ERROR(WErrors.IsValidU64, `Stock add ${stock_add} is not valid`);
|
|
1109
1068
|
}
|
|
1110
1069
|
if (passport) {
|
|
1111
1070
|
tx.moveCall({
|
|
1112
|
-
target:
|
|
1071
|
+
target: serviceFn("stock_add_with_passport"),
|
|
1113
1072
|
arguments: [
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1073
|
+
toTxObject(tx, service),
|
|
1074
|
+
toTxObject(tx, permission),
|
|
1075
|
+
toTxObject(tx, passport),
|
|
1076
|
+
toTxString(tx, sale_name),
|
|
1118
1077
|
tx.pure.u64(stock_add),
|
|
1119
1078
|
],
|
|
1120
1079
|
typeArguments: [service_type],
|
|
@@ -1122,36 +1081,36 @@ function stock_add(tx, service, service_type, permission, sale_name, stock_add,
|
|
|
1122
1081
|
}
|
|
1123
1082
|
else {
|
|
1124
1083
|
tx.moveCall({
|
|
1125
|
-
target:
|
|
1084
|
+
target: serviceFn("stock_add"),
|
|
1126
1085
|
arguments: [
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1086
|
+
toTxObject(tx, service),
|
|
1087
|
+
toTxObject(tx, permission),
|
|
1088
|
+
toTxString(tx, sale_name),
|
|
1130
1089
|
tx.pure.u64(stock_add),
|
|
1131
1090
|
],
|
|
1132
1091
|
typeArguments: [service_type],
|
|
1133
1092
|
});
|
|
1134
1093
|
}
|
|
1135
1094
|
}
|
|
1136
|
-
function stock_reduce(tx, service, service_type, permission, sale_name, stock_reduce, passport) {
|
|
1137
|
-
|
|
1138
|
-
if (!
|
|
1139
|
-
|
|
1095
|
+
export function stock_reduce(tx, service, service_type, permission, sale_name, stock_reduce, passport) {
|
|
1096
|
+
validObjects([service, permission, passport]);
|
|
1097
|
+
if (!IsValidArgType(service_type)) {
|
|
1098
|
+
W_ERROR(WErrors.InvalidParam, `Stock reduce service type ${service_type} is not valid`);
|
|
1140
1099
|
}
|
|
1141
|
-
if (typeof sale_name === "string" && !
|
|
1142
|
-
|
|
1100
|
+
if (typeof sale_name === "string" && !isValidLongName(sale_name)) {
|
|
1101
|
+
W_ERROR(WErrors.InvalidParam, `Sale name ${sale_name} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`);
|
|
1143
1102
|
}
|
|
1144
|
-
if (!
|
|
1145
|
-
|
|
1103
|
+
if (!isValidU64(stock_reduce)) {
|
|
1104
|
+
W_ERROR(WErrors.IsValidU64, `Stock reduce ${stock_reduce} is not valid`);
|
|
1146
1105
|
}
|
|
1147
1106
|
if (passport) {
|
|
1148
1107
|
tx.moveCall({
|
|
1149
|
-
target:
|
|
1108
|
+
target: serviceFn("stock_reduce_with_passport"),
|
|
1150
1109
|
arguments: [
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1110
|
+
toTxObject(tx, service),
|
|
1111
|
+
toTxObject(tx, permission),
|
|
1112
|
+
toTxObject(tx, passport),
|
|
1113
|
+
toTxString(tx, sale_name),
|
|
1155
1114
|
tx.pure.u64(stock_reduce),
|
|
1156
1115
|
],
|
|
1157
1116
|
typeArguments: [service_type],
|
|
@@ -1159,33 +1118,33 @@ function stock_reduce(tx, service, service_type, permission, sale_name, stock_re
|
|
|
1159
1118
|
}
|
|
1160
1119
|
else {
|
|
1161
1120
|
tx.moveCall({
|
|
1162
|
-
target:
|
|
1121
|
+
target: serviceFn("stock_reduce"),
|
|
1163
1122
|
arguments: [
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1123
|
+
toTxObject(tx, service),
|
|
1124
|
+
toTxObject(tx, permission),
|
|
1125
|
+
toTxString(tx, sale_name),
|
|
1167
1126
|
tx.pure.u64(stock_reduce),
|
|
1168
1127
|
],
|
|
1169
1128
|
typeArguments: [service_type],
|
|
1170
1129
|
});
|
|
1171
1130
|
}
|
|
1172
1131
|
}
|
|
1173
|
-
function sale_suspension(tx, service, service_type, permission, sale_name, suspension, passport) {
|
|
1174
|
-
|
|
1175
|
-
if (!
|
|
1176
|
-
|
|
1132
|
+
export function sale_suspension(tx, service, service_type, permission, sale_name, suspension, passport) {
|
|
1133
|
+
validObjects([service, permission, passport]);
|
|
1134
|
+
if (!IsValidArgType(service_type)) {
|
|
1135
|
+
W_ERROR(WErrors.InvalidParam, `Sale suspension service type ${service_type} is not valid`);
|
|
1177
1136
|
}
|
|
1178
|
-
if (typeof sale_name === "string" && !
|
|
1179
|
-
|
|
1137
|
+
if (typeof sale_name === "string" && !isValidLongName(sale_name)) {
|
|
1138
|
+
W_ERROR(WErrors.InvalidParam, `Sale name ${sale_name} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`);
|
|
1180
1139
|
}
|
|
1181
1140
|
if (passport) {
|
|
1182
1141
|
tx.moveCall({
|
|
1183
|
-
target:
|
|
1142
|
+
target: serviceFn("sale_suspension_with_passport"),
|
|
1184
1143
|
arguments: [
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1144
|
+
toTxObject(tx, service),
|
|
1145
|
+
toTxObject(tx, permission),
|
|
1146
|
+
toTxObject(tx, passport),
|
|
1147
|
+
toTxString(tx, sale_name),
|
|
1189
1148
|
tx.pure.bool(suspension),
|
|
1190
1149
|
],
|
|
1191
1150
|
typeArguments: [service_type],
|
|
@@ -1193,30 +1152,30 @@ function sale_suspension(tx, service, service_type, permission, sale_name, suspe
|
|
|
1193
1152
|
}
|
|
1194
1153
|
else {
|
|
1195
1154
|
tx.moveCall({
|
|
1196
|
-
target:
|
|
1155
|
+
target: serviceFn("sale_suspension"),
|
|
1197
1156
|
arguments: [
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1157
|
+
toTxObject(tx, service),
|
|
1158
|
+
toTxObject(tx, permission),
|
|
1159
|
+
toTxString(tx, sale_name),
|
|
1201
1160
|
tx.pure.bool(suspension),
|
|
1202
1161
|
],
|
|
1203
1162
|
typeArguments: [service_type],
|
|
1204
1163
|
});
|
|
1205
1164
|
}
|
|
1206
1165
|
}
|
|
1207
|
-
function repository_add(tx, service, service_type, permission, repository, passport) {
|
|
1208
|
-
|
|
1209
|
-
if (!
|
|
1210
|
-
|
|
1166
|
+
export function repository_add(tx, service, service_type, permission, repository, passport) {
|
|
1167
|
+
validObjects([service, permission, repository, passport]);
|
|
1168
|
+
if (!IsValidArgType(service_type)) {
|
|
1169
|
+
W_ERROR(WErrors.InvalidParam, `Repository add service type ${service_type} is not valid`);
|
|
1211
1170
|
}
|
|
1212
1171
|
if (passport) {
|
|
1213
1172
|
tx.moveCall({
|
|
1214
|
-
target:
|
|
1173
|
+
target: serviceFn("repository_add_with_passport"),
|
|
1215
1174
|
arguments: [
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1175
|
+
toTxObject(tx, service),
|
|
1176
|
+
toTxObject(tx, permission),
|
|
1177
|
+
toTxObject(tx, passport),
|
|
1178
|
+
toTxObject(tx, repository),
|
|
1220
1179
|
tx.object.mutRegistrar(),
|
|
1221
1180
|
tx.object.clock(),
|
|
1222
1181
|
],
|
|
@@ -1225,11 +1184,11 @@ function repository_add(tx, service, service_type, permission, repository, passp
|
|
|
1225
1184
|
}
|
|
1226
1185
|
else {
|
|
1227
1186
|
tx.moveCall({
|
|
1228
|
-
target:
|
|
1187
|
+
target: serviceFn("repository_add"),
|
|
1229
1188
|
arguments: [
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1189
|
+
toTxObject(tx, service),
|
|
1190
|
+
toTxObject(tx, permission),
|
|
1191
|
+
toTxObject(tx, repository),
|
|
1233
1192
|
tx.object.mutRegistrar(),
|
|
1234
1193
|
tx.object.clock(),
|
|
1235
1194
|
],
|
|
@@ -1237,21 +1196,21 @@ function repository_add(tx, service, service_type, permission, repository, passp
|
|
|
1237
1196
|
});
|
|
1238
1197
|
}
|
|
1239
1198
|
}
|
|
1240
|
-
function repository_remove(tx, service, service_type, permission, repositories, passport) {
|
|
1199
|
+
export function repository_remove(tx, service, service_type, permission, repositories, passport) {
|
|
1241
1200
|
if (repositories.length === 0) {
|
|
1242
1201
|
return;
|
|
1243
1202
|
}
|
|
1244
|
-
|
|
1245
|
-
if (!
|
|
1246
|
-
|
|
1203
|
+
validObjects([service, permission, passport, ...repositories]);
|
|
1204
|
+
if (!IsValidArgType(service_type)) {
|
|
1205
|
+
W_ERROR(WErrors.InvalidParam, `Repository remove service type ${service_type} is not valid`);
|
|
1247
1206
|
}
|
|
1248
1207
|
if (passport) {
|
|
1249
1208
|
tx.moveCall({
|
|
1250
|
-
target:
|
|
1209
|
+
target: serviceFn("repository_remove_with_passport"),
|
|
1251
1210
|
arguments: [
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1211
|
+
toTxObject(tx, service),
|
|
1212
|
+
toTxObject(tx, permission),
|
|
1213
|
+
toTxObject(tx, passport),
|
|
1255
1214
|
tx.pure.vector("address", repositories),
|
|
1256
1215
|
tx.object.mutRegistrar(),
|
|
1257
1216
|
],
|
|
@@ -1260,10 +1219,10 @@ function repository_remove(tx, service, service_type, permission, repositories,
|
|
|
1260
1219
|
}
|
|
1261
1220
|
else {
|
|
1262
1221
|
tx.moveCall({
|
|
1263
|
-
target:
|
|
1222
|
+
target: serviceFn("repository_remove"),
|
|
1264
1223
|
arguments: [
|
|
1265
|
-
|
|
1266
|
-
|
|
1224
|
+
toTxObject(tx, service),
|
|
1225
|
+
toTxObject(tx, permission),
|
|
1267
1226
|
tx.pure.vector("address", repositories),
|
|
1268
1227
|
tx.object.mutRegistrar(),
|
|
1269
1228
|
],
|
|
@@ -1271,18 +1230,18 @@ function repository_remove(tx, service, service_type, permission, repositories,
|
|
|
1271
1230
|
});
|
|
1272
1231
|
}
|
|
1273
1232
|
}
|
|
1274
|
-
function repository_clear(tx, service, service_type, permission, passport) {
|
|
1275
|
-
|
|
1276
|
-
if (!
|
|
1277
|
-
|
|
1233
|
+
export function repository_clear(tx, service, service_type, permission, passport) {
|
|
1234
|
+
validObjects([service, permission, passport]);
|
|
1235
|
+
if (!IsValidArgType(service_type)) {
|
|
1236
|
+
W_ERROR(WErrors.InvalidParam, `Repository clear service type ${service_type} is not valid`);
|
|
1278
1237
|
}
|
|
1279
1238
|
if (passport) {
|
|
1280
1239
|
tx.moveCall({
|
|
1281
|
-
target:
|
|
1240
|
+
target: serviceFn("repository_clear_with_passport"),
|
|
1282
1241
|
arguments: [
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1242
|
+
toTxObject(tx, service),
|
|
1243
|
+
toTxObject(tx, permission),
|
|
1244
|
+
toTxObject(tx, passport),
|
|
1286
1245
|
tx.object.mutRegistrar(),
|
|
1287
1246
|
],
|
|
1288
1247
|
typeArguments: [service_type],
|
|
@@ -1290,30 +1249,30 @@ function repository_clear(tx, service, service_type, permission, passport) {
|
|
|
1290
1249
|
}
|
|
1291
1250
|
else {
|
|
1292
1251
|
tx.moveCall({
|
|
1293
|
-
target:
|
|
1252
|
+
target: serviceFn("repository_clear"),
|
|
1294
1253
|
arguments: [
|
|
1295
|
-
|
|
1296
|
-
|
|
1254
|
+
toTxObject(tx, service),
|
|
1255
|
+
toTxObject(tx, permission),
|
|
1297
1256
|
tx.object.mutRegistrar(),
|
|
1298
1257
|
],
|
|
1299
1258
|
typeArguments: [service_type],
|
|
1300
1259
|
});
|
|
1301
1260
|
}
|
|
1302
1261
|
}
|
|
1303
|
-
function buy_guard_set(tx, service, service_type, permission, guard, passport) {
|
|
1304
|
-
|
|
1305
|
-
if (!
|
|
1306
|
-
|
|
1262
|
+
export function buy_guard_set(tx, service, service_type, permission, guard, passport) {
|
|
1263
|
+
validObjects([service, permission, guard, passport]);
|
|
1264
|
+
if (!IsValidArgType(service_type)) {
|
|
1265
|
+
W_ERROR(WErrors.InvalidParam, `Buy guard set service type ${service_type} is not valid`);
|
|
1307
1266
|
}
|
|
1308
1267
|
if (passport) {
|
|
1309
1268
|
if (guard) {
|
|
1310
1269
|
tx.moveCall({
|
|
1311
|
-
target:
|
|
1270
|
+
target: serviceFn("buy_guard_set_with_passport"),
|
|
1312
1271
|
arguments: [
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1272
|
+
toTxObject(tx, service),
|
|
1273
|
+
toTxObject(tx, permission),
|
|
1274
|
+
toTxObject(tx, passport),
|
|
1275
|
+
toTxObject(tx, guard),
|
|
1317
1276
|
tx.object.mutRegistrar(),
|
|
1318
1277
|
tx.object.clock(),
|
|
1319
1278
|
],
|
|
@@ -1322,11 +1281,11 @@ function buy_guard_set(tx, service, service_type, permission, guard, passport) {
|
|
|
1322
1281
|
}
|
|
1323
1282
|
else {
|
|
1324
1283
|
tx.moveCall({
|
|
1325
|
-
target:
|
|
1284
|
+
target: serviceFn("buy_guard_none_with_passport"),
|
|
1326
1285
|
arguments: [
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1286
|
+
toTxObject(tx, service),
|
|
1287
|
+
toTxObject(tx, permission),
|
|
1288
|
+
toTxObject(tx, passport),
|
|
1330
1289
|
tx.object.mutRegistrar(),
|
|
1331
1290
|
],
|
|
1332
1291
|
typeArguments: [service_type],
|
|
@@ -1336,11 +1295,11 @@ function buy_guard_set(tx, service, service_type, permission, guard, passport) {
|
|
|
1336
1295
|
else {
|
|
1337
1296
|
if (guard) {
|
|
1338
1297
|
tx.moveCall({
|
|
1339
|
-
target:
|
|
1298
|
+
target: serviceFn("buy_guard_set"),
|
|
1340
1299
|
arguments: [
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1300
|
+
toTxObject(tx, service),
|
|
1301
|
+
toTxObject(tx, permission),
|
|
1302
|
+
toTxObject(tx, guard),
|
|
1344
1303
|
tx.object.mutRegistrar(),
|
|
1345
1304
|
tx.object.clock(),
|
|
1346
1305
|
],
|
|
@@ -1349,10 +1308,10 @@ function buy_guard_set(tx, service, service_type, permission, guard, passport) {
|
|
|
1349
1308
|
}
|
|
1350
1309
|
else {
|
|
1351
1310
|
tx.moveCall({
|
|
1352
|
-
target:
|
|
1311
|
+
target: serviceFn("buy_guard_none"),
|
|
1353
1312
|
arguments: [
|
|
1354
|
-
|
|
1355
|
-
|
|
1313
|
+
toTxObject(tx, service),
|
|
1314
|
+
toTxObject(tx, permission),
|
|
1356
1315
|
tx.object.mutRegistrar(),
|
|
1357
1316
|
],
|
|
1358
1317
|
typeArguments: [service_type],
|
|
@@ -1360,20 +1319,20 @@ function buy_guard_set(tx, service, service_type, permission, guard, passport) {
|
|
|
1360
1319
|
}
|
|
1361
1320
|
}
|
|
1362
1321
|
}
|
|
1363
|
-
function machine_set(tx, service, service_type, permission, machine, passport) {
|
|
1364
|
-
|
|
1365
|
-
if (!
|
|
1366
|
-
|
|
1322
|
+
export function machine_set(tx, service, service_type, permission, machine, passport) {
|
|
1323
|
+
validObjects([service, permission, machine, passport]);
|
|
1324
|
+
if (!IsValidArgType(service_type)) {
|
|
1325
|
+
W_ERROR(WErrors.InvalidParam, `Machine set service type ${service_type} is not valid`);
|
|
1367
1326
|
}
|
|
1368
1327
|
if (passport) {
|
|
1369
1328
|
if (machine) {
|
|
1370
1329
|
tx.moveCall({
|
|
1371
|
-
target:
|
|
1330
|
+
target: serviceFn("machine_set_with_passport"),
|
|
1372
1331
|
arguments: [
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1332
|
+
toTxObject(tx, service),
|
|
1333
|
+
toTxObject(tx, permission),
|
|
1334
|
+
toTxObject(tx, passport),
|
|
1335
|
+
toTxObject(tx, machine),
|
|
1377
1336
|
tx.object.mutRegistrar(),
|
|
1378
1337
|
tx.object.clock(),
|
|
1379
1338
|
],
|
|
@@ -1382,11 +1341,11 @@ function machine_set(tx, service, service_type, permission, machine, passport) {
|
|
|
1382
1341
|
}
|
|
1383
1342
|
else {
|
|
1384
1343
|
tx.moveCall({
|
|
1385
|
-
target:
|
|
1344
|
+
target: serviceFn("machine_none_with_passport"),
|
|
1386
1345
|
arguments: [
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1346
|
+
toTxObject(tx, service),
|
|
1347
|
+
toTxObject(tx, permission),
|
|
1348
|
+
toTxObject(tx, passport),
|
|
1390
1349
|
tx.object.mutRegistrar(),
|
|
1391
1350
|
],
|
|
1392
1351
|
typeArguments: [service_type],
|
|
@@ -1396,11 +1355,11 @@ function machine_set(tx, service, service_type, permission, machine, passport) {
|
|
|
1396
1355
|
else {
|
|
1397
1356
|
if (machine) {
|
|
1398
1357
|
tx.moveCall({
|
|
1399
|
-
target:
|
|
1358
|
+
target: serviceFn("machine_set"),
|
|
1400
1359
|
arguments: [
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1360
|
+
toTxObject(tx, service),
|
|
1361
|
+
toTxObject(tx, permission),
|
|
1362
|
+
toTxObject(tx, machine),
|
|
1404
1363
|
tx.object.mutRegistrar(),
|
|
1405
1364
|
tx.object.clock(),
|
|
1406
1365
|
],
|
|
@@ -1409,10 +1368,10 @@ function machine_set(tx, service, service_type, permission, machine, passport) {
|
|
|
1409
1368
|
}
|
|
1410
1369
|
else {
|
|
1411
1370
|
tx.moveCall({
|
|
1412
|
-
target:
|
|
1371
|
+
target: serviceFn("machine_set_none"),
|
|
1413
1372
|
arguments: [
|
|
1414
|
-
|
|
1415
|
-
|
|
1373
|
+
toTxObject(tx, service),
|
|
1374
|
+
toTxObject(tx, permission),
|
|
1416
1375
|
tx.object.mutRegistrar(),
|
|
1417
1376
|
],
|
|
1418
1377
|
typeArguments: [service_type],
|
|
@@ -1420,42 +1379,42 @@ function machine_set(tx, service, service_type, permission, machine, passport) {
|
|
|
1420
1379
|
}
|
|
1421
1380
|
}
|
|
1422
1381
|
}
|
|
1423
|
-
function publish(tx, service, service_type, permission, passport) {
|
|
1424
|
-
|
|
1425
|
-
if (!
|
|
1426
|
-
|
|
1382
|
+
export function publish(tx, service, service_type, permission, passport) {
|
|
1383
|
+
validObjects([service, permission, passport]);
|
|
1384
|
+
if (!IsValidArgType(service_type)) {
|
|
1385
|
+
W_ERROR(WErrors.InvalidParam, `Publish service type ${service_type} is not valid`);
|
|
1427
1386
|
}
|
|
1428
1387
|
if (passport) {
|
|
1429
1388
|
tx.moveCall({
|
|
1430
|
-
target:
|
|
1389
|
+
target: serviceFn("publish_with_passport"),
|
|
1431
1390
|
arguments: [
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1391
|
+
toTxObject(tx, service),
|
|
1392
|
+
toTxObject(tx, permission),
|
|
1393
|
+
toTxObject(tx, passport),
|
|
1435
1394
|
],
|
|
1436
1395
|
typeArguments: [service_type],
|
|
1437
1396
|
});
|
|
1438
1397
|
}
|
|
1439
1398
|
else {
|
|
1440
1399
|
tx.moveCall({
|
|
1441
|
-
target:
|
|
1442
|
-
arguments: [
|
|
1400
|
+
target: serviceFn("publish"),
|
|
1401
|
+
arguments: [toTxObject(tx, service), toTxObject(tx, permission)],
|
|
1443
1402
|
typeArguments: [service_type],
|
|
1444
1403
|
});
|
|
1445
1404
|
}
|
|
1446
1405
|
}
|
|
1447
|
-
function pause(tx, service, service_type, permission, bPaused, passport) {
|
|
1448
|
-
|
|
1449
|
-
if (!
|
|
1450
|
-
|
|
1406
|
+
export function pause(tx, service, service_type, permission, bPaused, passport) {
|
|
1407
|
+
validObjects([service, permission, passport]);
|
|
1408
|
+
if (!IsValidArgType(service_type)) {
|
|
1409
|
+
W_ERROR(WErrors.InvalidParam, `Pause service type ${service_type} is not valid`);
|
|
1451
1410
|
}
|
|
1452
1411
|
if (passport) {
|
|
1453
1412
|
tx.moveCall({
|
|
1454
|
-
target:
|
|
1413
|
+
target: serviceFn("pause_with_passport"),
|
|
1455
1414
|
arguments: [
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1415
|
+
toTxObject(tx, service),
|
|
1416
|
+
toTxObject(tx, permission),
|
|
1417
|
+
toTxObject(tx, passport),
|
|
1459
1418
|
tx.pure.bool(bPaused),
|
|
1460
1419
|
tx.object.clock(),
|
|
1461
1420
|
],
|
|
@@ -1464,10 +1423,10 @@ function pause(tx, service, service_type, permission, bPaused, passport) {
|
|
|
1464
1423
|
}
|
|
1465
1424
|
else {
|
|
1466
1425
|
tx.moveCall({
|
|
1467
|
-
target:
|
|
1426
|
+
target: serviceFn("pause"),
|
|
1468
1427
|
arguments: [
|
|
1469
|
-
|
|
1470
|
-
|
|
1428
|
+
toTxObject(tx, service),
|
|
1429
|
+
toTxObject(tx, permission),
|
|
1471
1430
|
tx.pure.bool(bPaused),
|
|
1472
1431
|
tx.object.clock(),
|
|
1473
1432
|
],
|
|
@@ -1475,26 +1434,26 @@ function pause(tx, service, service_type, permission, bPaused, passport) {
|
|
|
1475
1434
|
});
|
|
1476
1435
|
}
|
|
1477
1436
|
}
|
|
1478
|
-
function customer_required_set(tx, service, service_type, permission, required_info, passport) {
|
|
1479
|
-
if (required_info.length >
|
|
1480
|
-
|
|
1437
|
+
export function customer_required_set(tx, service, service_type, permission, required_info, passport) {
|
|
1438
|
+
if (required_info.length > MAX_REQUIRED_INFO_SIZE) {
|
|
1439
|
+
W_ERROR(WErrors.InvalidParam, `Customer required set size ${required_info.length} is exceed maximum size ${MAX_REQUIRED_INFO_SIZE}`);
|
|
1481
1440
|
}
|
|
1482
|
-
|
|
1483
|
-
if (!
|
|
1484
|
-
|
|
1441
|
+
validObjects([service, permission, passport]);
|
|
1442
|
+
if (!IsValidArgType(service_type)) {
|
|
1443
|
+
W_ERROR(WErrors.InvalidParam, `Customer required set service type ${service_type} is not valid`);
|
|
1485
1444
|
}
|
|
1486
1445
|
required_info.forEach((item) => {
|
|
1487
|
-
if (!
|
|
1488
|
-
|
|
1446
|
+
if (!isValidName(item)) {
|
|
1447
|
+
W_ERROR(WErrors.InvalidParam, `Customer required info ${item} is exceed maximum length ${MAX_NAME_LENGTH} or start with "0x"`);
|
|
1489
1448
|
}
|
|
1490
1449
|
});
|
|
1491
1450
|
if (passport) {
|
|
1492
1451
|
tx.moveCall({
|
|
1493
|
-
target:
|
|
1452
|
+
target: serviceFn("custom_required_info_set_with_passport"),
|
|
1494
1453
|
arguments: [
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1454
|
+
toTxObject(tx, service),
|
|
1455
|
+
toTxObject(tx, permission),
|
|
1456
|
+
toTxObject(tx, passport),
|
|
1498
1457
|
tx.pure.vector("string", required_info),
|
|
1499
1458
|
],
|
|
1500
1459
|
typeArguments: [service_type],
|
|
@@ -1502,32 +1461,32 @@ function customer_required_set(tx, service, service_type, permission, required_i
|
|
|
1502
1461
|
}
|
|
1503
1462
|
else {
|
|
1504
1463
|
tx.moveCall({
|
|
1505
|
-
target:
|
|
1464
|
+
target: serviceFn("custom_required_info_set"),
|
|
1506
1465
|
arguments: [
|
|
1507
|
-
|
|
1508
|
-
|
|
1466
|
+
toTxObject(tx, service),
|
|
1467
|
+
toTxObject(tx, permission),
|
|
1509
1468
|
tx.pure.vector("string", required_info),
|
|
1510
1469
|
],
|
|
1511
1470
|
typeArguments: [service_type],
|
|
1512
1471
|
});
|
|
1513
1472
|
}
|
|
1514
1473
|
}
|
|
1515
|
-
function arbitrations_add(tx, service, service_type, permission, arbitration, arbitration_type, passport) {
|
|
1516
|
-
|
|
1517
|
-
if (!
|
|
1518
|
-
|
|
1474
|
+
export function arbitrations_add(tx, service, service_type, permission, arbitration, arbitration_type, passport) {
|
|
1475
|
+
validObjects([service, permission, arbitration, passport]);
|
|
1476
|
+
if (!IsValidArgType(service_type)) {
|
|
1477
|
+
W_ERROR(WErrors.InvalidParam, `Arbitrations add service type ${service_type} is not valid`);
|
|
1519
1478
|
}
|
|
1520
|
-
if (!
|
|
1521
|
-
|
|
1479
|
+
if (!IsValidArgType(arbitration_type)) {
|
|
1480
|
+
W_ERROR(WErrors.InvalidParam, `Arbitrations add arbitration type ${arbitration_type} is not valid`);
|
|
1522
1481
|
}
|
|
1523
1482
|
if (passport) {
|
|
1524
1483
|
tx.moveCall({
|
|
1525
|
-
target:
|
|
1484
|
+
target: serviceFn("arbitration_add_with_passport"),
|
|
1526
1485
|
arguments: [
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1486
|
+
toTxObject(tx, service),
|
|
1487
|
+
toTxObject(tx, permission),
|
|
1488
|
+
toTxObject(tx, passport),
|
|
1489
|
+
toTxObject(tx, arbitration),
|
|
1531
1490
|
tx.object.mutRegistrar(),
|
|
1532
1491
|
tx.object.clock(),
|
|
1533
1492
|
],
|
|
@@ -1536,11 +1495,11 @@ function arbitrations_add(tx, service, service_type, permission, arbitration, ar
|
|
|
1536
1495
|
}
|
|
1537
1496
|
else {
|
|
1538
1497
|
tx.moveCall({
|
|
1539
|
-
target:
|
|
1498
|
+
target: serviceFn("arbitrations_add"),
|
|
1540
1499
|
arguments: [
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1500
|
+
toTxObject(tx, service),
|
|
1501
|
+
toTxObject(tx, permission),
|
|
1502
|
+
toTxObject(tx, arbitration),
|
|
1544
1503
|
tx.object.mutRegistrar(),
|
|
1545
1504
|
tx.object.clock(),
|
|
1546
1505
|
],
|
|
@@ -1548,21 +1507,21 @@ function arbitrations_add(tx, service, service_type, permission, arbitration, ar
|
|
|
1548
1507
|
});
|
|
1549
1508
|
}
|
|
1550
1509
|
}
|
|
1551
|
-
function arbitrations_remove(tx, service, service_type, permission, arbitrations, passport) {
|
|
1510
|
+
export function arbitrations_remove(tx, service, service_type, permission, arbitrations, passport) {
|
|
1552
1511
|
if (arbitrations.length === 0) {
|
|
1553
1512
|
return;
|
|
1554
1513
|
}
|
|
1555
|
-
|
|
1556
|
-
if (!
|
|
1557
|
-
|
|
1514
|
+
validObjects([service, permission, passport]);
|
|
1515
|
+
if (!IsValidArgType(service_type)) {
|
|
1516
|
+
W_ERROR(WErrors.InvalidParam, `Arbitrations remove service type ${service_type} is not valid`);
|
|
1558
1517
|
}
|
|
1559
1518
|
if (passport) {
|
|
1560
1519
|
tx.moveCall({
|
|
1561
|
-
target:
|
|
1520
|
+
target: serviceFn("arbitration_remove_with_passport"),
|
|
1562
1521
|
arguments: [
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1522
|
+
toTxObject(tx, service),
|
|
1523
|
+
toTxObject(tx, permission),
|
|
1524
|
+
toTxObject(tx, passport),
|
|
1566
1525
|
tx.pure.vector("address", arbitrations),
|
|
1567
1526
|
tx.object.mutRegistrar(),
|
|
1568
1527
|
],
|
|
@@ -1571,10 +1530,10 @@ function arbitrations_remove(tx, service, service_type, permission, arbitrations
|
|
|
1571
1530
|
}
|
|
1572
1531
|
else {
|
|
1573
1532
|
tx.moveCall({
|
|
1574
|
-
target:
|
|
1533
|
+
target: serviceFn("arbitration_remove"),
|
|
1575
1534
|
arguments: [
|
|
1576
|
-
|
|
1577
|
-
|
|
1535
|
+
toTxObject(tx, service),
|
|
1536
|
+
toTxObject(tx, permission),
|
|
1578
1537
|
tx.pure.vector("address", arbitrations),
|
|
1579
1538
|
tx.object.mutRegistrar(),
|
|
1580
1539
|
],
|
|
@@ -1582,18 +1541,18 @@ function arbitrations_remove(tx, service, service_type, permission, arbitrations
|
|
|
1582
1541
|
});
|
|
1583
1542
|
}
|
|
1584
1543
|
}
|
|
1585
|
-
function arbitration_clear(tx, service, service_type, permission, passport) {
|
|
1586
|
-
|
|
1587
|
-
if (!
|
|
1588
|
-
|
|
1544
|
+
export function arbitration_clear(tx, service, service_type, permission, passport) {
|
|
1545
|
+
validObjects([service, permission, passport]);
|
|
1546
|
+
if (!IsValidArgType(service_type)) {
|
|
1547
|
+
W_ERROR(WErrors.InvalidParam, `Arbitrations clear service type ${service_type} is not valid`);
|
|
1589
1548
|
}
|
|
1590
1549
|
if (passport) {
|
|
1591
1550
|
tx.moveCall({
|
|
1592
|
-
target:
|
|
1551
|
+
target: serviceFn("arbitration_clear_with_passport"),
|
|
1593
1552
|
arguments: [
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1553
|
+
toTxObject(tx, service),
|
|
1554
|
+
toTxObject(tx, permission),
|
|
1555
|
+
toTxObject(tx, passport),
|
|
1597
1556
|
tx.object.mutRegistrar(),
|
|
1598
1557
|
],
|
|
1599
1558
|
typeArguments: [service_type],
|
|
@@ -1601,29 +1560,29 @@ function arbitration_clear(tx, service, service_type, permission, passport) {
|
|
|
1601
1560
|
}
|
|
1602
1561
|
else {
|
|
1603
1562
|
tx.moveCall({
|
|
1604
|
-
target:
|
|
1563
|
+
target: serviceFn("arbitration_clear"),
|
|
1605
1564
|
arguments: [
|
|
1606
|
-
|
|
1607
|
-
|
|
1565
|
+
toTxObject(tx, service),
|
|
1566
|
+
toTxObject(tx, permission),
|
|
1608
1567
|
tx.object.mutRegistrar(),
|
|
1609
1568
|
],
|
|
1610
1569
|
typeArguments: [service_type],
|
|
1611
1570
|
});
|
|
1612
1571
|
}
|
|
1613
1572
|
}
|
|
1614
|
-
async function compensation_fund_add(env, tx, service, service_type, permission, coin, passport) {
|
|
1615
|
-
|
|
1616
|
-
if (!
|
|
1617
|
-
|
|
1573
|
+
export async function compensation_fund_add(env, tx, service, service_type, permission, coin, passport) {
|
|
1574
|
+
validObjects([service, permission, passport]);
|
|
1575
|
+
if (!IsValidArgType(service_type)) {
|
|
1576
|
+
W_ERROR(WErrors.InvalidParam, `Compensation fund add service type ${service_type} is not valid`);
|
|
1618
1577
|
}
|
|
1619
|
-
const coinParam = await
|
|
1578
|
+
const coinParam = await getCoinParam(env, tx, coin, service_type);
|
|
1620
1579
|
if (passport) {
|
|
1621
1580
|
tx.moveCall({
|
|
1622
|
-
target:
|
|
1581
|
+
target: serviceFn("compensation_fund_add_with_passport"),
|
|
1623
1582
|
arguments: [
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1583
|
+
toTxObject(tx, service),
|
|
1584
|
+
toTxObject(tx, permission),
|
|
1585
|
+
toTxObject(tx, passport),
|
|
1627
1586
|
coinParam,
|
|
1628
1587
|
],
|
|
1629
1588
|
typeArguments: [service_type],
|
|
@@ -1631,31 +1590,31 @@ async function compensation_fund_add(env, tx, service, service_type, permission,
|
|
|
1631
1590
|
}
|
|
1632
1591
|
else {
|
|
1633
1592
|
tx.moveCall({
|
|
1634
|
-
target:
|
|
1593
|
+
target: serviceFn("compensation_fund_add"),
|
|
1635
1594
|
arguments: [
|
|
1636
|
-
|
|
1637
|
-
|
|
1595
|
+
toTxObject(tx, service),
|
|
1596
|
+
toTxObject(tx, permission),
|
|
1638
1597
|
coinParam,
|
|
1639
1598
|
],
|
|
1640
1599
|
typeArguments: [service_type],
|
|
1641
1600
|
});
|
|
1642
1601
|
}
|
|
1643
1602
|
}
|
|
1644
|
-
function compensation_lock_duration_set(tx, service, service_type, permission, duration_ms, passport) {
|
|
1645
|
-
if (!
|
|
1603
|
+
export function compensation_lock_duration_set(tx, service, service_type, permission, duration_ms, passport) {
|
|
1604
|
+
if (!isValidU64(duration_ms) || duration_ms === 0) {
|
|
1646
1605
|
return;
|
|
1647
1606
|
}
|
|
1648
|
-
|
|
1649
|
-
if (!
|
|
1650
|
-
|
|
1607
|
+
validObjects([service, permission, passport]);
|
|
1608
|
+
if (!IsValidArgType(service_type)) {
|
|
1609
|
+
W_ERROR(WErrors.InvalidParam, `Compensation lock duration set service type ${service_type} is not valid`);
|
|
1651
1610
|
}
|
|
1652
1611
|
if (passport) {
|
|
1653
1612
|
tx.moveCall({
|
|
1654
|
-
target:
|
|
1613
|
+
target: serviceFn("compensation_lock_duration_add_with_passport"),
|
|
1655
1614
|
arguments: [
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1615
|
+
toTxObject(tx, service),
|
|
1616
|
+
toTxObject(tx, permission),
|
|
1617
|
+
toTxObject(tx, passport),
|
|
1659
1618
|
tx.pure.u64(duration_ms),
|
|
1660
1619
|
],
|
|
1661
1620
|
typeArguments: [service_type],
|
|
@@ -1663,30 +1622,30 @@ function compensation_lock_duration_set(tx, service, service_type, permission, d
|
|
|
1663
1622
|
}
|
|
1664
1623
|
else {
|
|
1665
1624
|
tx.moveCall({
|
|
1666
|
-
target:
|
|
1625
|
+
target: serviceFn("compensation_lock_duration_add"),
|
|
1667
1626
|
arguments: [
|
|
1668
|
-
|
|
1669
|
-
|
|
1627
|
+
toTxObject(tx, service),
|
|
1628
|
+
toTxObject(tx, permission),
|
|
1670
1629
|
tx.pure.u64(duration_ms),
|
|
1671
1630
|
],
|
|
1672
1631
|
typeArguments: [service_type],
|
|
1673
1632
|
});
|
|
1674
1633
|
}
|
|
1675
1634
|
}
|
|
1676
|
-
function order_allocators_set(tx, service, service_type, permission, allocators, passport) {
|
|
1677
|
-
|
|
1678
|
-
if (!
|
|
1679
|
-
|
|
1635
|
+
export function order_allocators_set(tx, service, service_type, permission, allocators, passport) {
|
|
1636
|
+
validObjects([service, permission, allocators, passport]);
|
|
1637
|
+
if (!IsValidArgType(service_type)) {
|
|
1638
|
+
W_ERROR(WErrors.InvalidParam, `Order allocators set service type ${service_type} is not valid`);
|
|
1680
1639
|
}
|
|
1681
1640
|
if (passport) {
|
|
1682
1641
|
tx.moveCall({
|
|
1683
|
-
target:
|
|
1642
|
+
target: serviceFn("order_allocators_set_with_passport"),
|
|
1684
1643
|
arguments: [
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1644
|
+
toTxObject(tx, service),
|
|
1645
|
+
toTxObject(tx, permission),
|
|
1646
|
+
toTxObject(tx, passport),
|
|
1688
1647
|
tx.object.option({
|
|
1689
|
-
type: `${
|
|
1648
|
+
type: `${PackageAddress}::allocation::Allocators`,
|
|
1690
1649
|
value: allocators ?? null,
|
|
1691
1650
|
}),
|
|
1692
1651
|
],
|
|
@@ -1695,12 +1654,12 @@ function order_allocators_set(tx, service, service_type, permission, allocators,
|
|
|
1695
1654
|
}
|
|
1696
1655
|
else {
|
|
1697
1656
|
tx.moveCall({
|
|
1698
|
-
target:
|
|
1657
|
+
target: serviceFn("order_allocators_set"),
|
|
1699
1658
|
arguments: [
|
|
1700
|
-
|
|
1701
|
-
|
|
1659
|
+
toTxObject(tx, service),
|
|
1660
|
+
toTxObject(tx, permission),
|
|
1702
1661
|
tx.object.option({
|
|
1703
|
-
type: `${
|
|
1662
|
+
type: `${PackageAddress}::allocation::Allocators`,
|
|
1704
1663
|
value: allocators ?? null,
|
|
1705
1664
|
}),
|
|
1706
1665
|
],
|
|
@@ -1708,22 +1667,22 @@ function order_allocators_set(tx, service, service_type, permission, allocators,
|
|
|
1708
1667
|
});
|
|
1709
1668
|
}
|
|
1710
1669
|
}
|
|
1711
|
-
function reward_add(tx, service, service_type, permission, reward, reward_type, passport) {
|
|
1712
|
-
|
|
1713
|
-
if (!
|
|
1714
|
-
|
|
1670
|
+
export function reward_add(tx, service, service_type, permission, reward, reward_type, passport) {
|
|
1671
|
+
validObjects([service, permission, reward, passport]);
|
|
1672
|
+
if (!IsValidArgType(service_type)) {
|
|
1673
|
+
W_ERROR(WErrors.InvalidParam, `Rewards add service type ${service_type} is not valid`);
|
|
1715
1674
|
}
|
|
1716
|
-
if (!
|
|
1717
|
-
|
|
1675
|
+
if (!IsValidArgType(reward_type)) {
|
|
1676
|
+
W_ERROR(WErrors.InvalidParam, `Rewards add reward type ${reward_type} is not valid`);
|
|
1718
1677
|
}
|
|
1719
1678
|
if (passport) {
|
|
1720
1679
|
tx.moveCall({
|
|
1721
|
-
target:
|
|
1680
|
+
target: serviceFn("reward_add_with_passport"),
|
|
1722
1681
|
arguments: [
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1682
|
+
toTxObject(tx, service),
|
|
1683
|
+
toTxObject(tx, permission),
|
|
1684
|
+
toTxObject(tx, passport),
|
|
1685
|
+
toTxObject(tx, reward),
|
|
1727
1686
|
tx.object.mutRegistrar(),
|
|
1728
1687
|
tx.object.clock(),
|
|
1729
1688
|
],
|
|
@@ -1732,11 +1691,11 @@ function reward_add(tx, service, service_type, permission, reward, reward_type,
|
|
|
1732
1691
|
}
|
|
1733
1692
|
else {
|
|
1734
1693
|
tx.moveCall({
|
|
1735
|
-
target:
|
|
1694
|
+
target: serviceFn("reward_add"),
|
|
1736
1695
|
arguments: [
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1696
|
+
toTxObject(tx, service),
|
|
1697
|
+
toTxObject(tx, permission),
|
|
1698
|
+
toTxObject(tx, reward),
|
|
1740
1699
|
tx.object.mutRegistrar(),
|
|
1741
1700
|
tx.object.clock(),
|
|
1742
1701
|
],
|
|
@@ -1744,21 +1703,21 @@ function reward_add(tx, service, service_type, permission, reward, reward_type,
|
|
|
1744
1703
|
});
|
|
1745
1704
|
}
|
|
1746
1705
|
}
|
|
1747
|
-
function reward_remove(tx, service, service_type, permission, rewards, passport) {
|
|
1706
|
+
export function reward_remove(tx, service, service_type, permission, rewards, passport) {
|
|
1748
1707
|
if (rewards.length === 0) {
|
|
1749
1708
|
return;
|
|
1750
1709
|
}
|
|
1751
|
-
|
|
1752
|
-
if (!
|
|
1753
|
-
|
|
1710
|
+
validObjects([service, permission, passport]);
|
|
1711
|
+
if (!IsValidArgType(service_type)) {
|
|
1712
|
+
W_ERROR(WErrors.InvalidParam, `Rewards remove service type ${service_type} is not valid`);
|
|
1754
1713
|
}
|
|
1755
1714
|
if (passport) {
|
|
1756
1715
|
tx.moveCall({
|
|
1757
|
-
target:
|
|
1716
|
+
target: serviceFn("reward_remove_with_passport"),
|
|
1758
1717
|
arguments: [
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1718
|
+
toTxObject(tx, service),
|
|
1719
|
+
toTxObject(tx, permission),
|
|
1720
|
+
toTxObject(tx, passport),
|
|
1762
1721
|
tx.pure.vector("address", rewards),
|
|
1763
1722
|
tx.object.mutRegistrar(),
|
|
1764
1723
|
],
|
|
@@ -1767,10 +1726,10 @@ function reward_remove(tx, service, service_type, permission, rewards, passport)
|
|
|
1767
1726
|
}
|
|
1768
1727
|
else {
|
|
1769
1728
|
tx.moveCall({
|
|
1770
|
-
target:
|
|
1729
|
+
target: serviceFn("reward_remove"),
|
|
1771
1730
|
arguments: [
|
|
1772
|
-
|
|
1773
|
-
|
|
1731
|
+
toTxObject(tx, service),
|
|
1732
|
+
toTxObject(tx, permission),
|
|
1774
1733
|
tx.pure.vector("address", rewards),
|
|
1775
1734
|
tx.object.mutRegistrar(),
|
|
1776
1735
|
],
|
|
@@ -1778,18 +1737,18 @@ function reward_remove(tx, service, service_type, permission, rewards, passport)
|
|
|
1778
1737
|
});
|
|
1779
1738
|
}
|
|
1780
1739
|
}
|
|
1781
|
-
function reward_clear(tx, service, service_type, permission, passport) {
|
|
1782
|
-
|
|
1783
|
-
if (!
|
|
1784
|
-
|
|
1740
|
+
export function reward_clear(tx, service, service_type, permission, passport) {
|
|
1741
|
+
validObjects([service, permission, passport]);
|
|
1742
|
+
if (!IsValidArgType(service_type)) {
|
|
1743
|
+
W_ERROR(WErrors.InvalidParam, `Rewards clear service type ${service_type} is not valid`);
|
|
1785
1744
|
}
|
|
1786
1745
|
if (passport) {
|
|
1787
1746
|
tx.moveCall({
|
|
1788
|
-
target:
|
|
1747
|
+
target: serviceFn("reward_clear_with_passport"),
|
|
1789
1748
|
arguments: [
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1749
|
+
toTxObject(tx, service),
|
|
1750
|
+
toTxObject(tx, permission),
|
|
1751
|
+
toTxObject(tx, passport),
|
|
1793
1752
|
tx.object.mutRegistrar(),
|
|
1794
1753
|
],
|
|
1795
1754
|
typeArguments: [service_type],
|
|
@@ -1797,64 +1756,64 @@ function reward_clear(tx, service, service_type, permission, passport) {
|
|
|
1797
1756
|
}
|
|
1798
1757
|
else {
|
|
1799
1758
|
tx.moveCall({
|
|
1800
|
-
target:
|
|
1759
|
+
target: serviceFn("reward_clear"),
|
|
1801
1760
|
arguments: [
|
|
1802
|
-
|
|
1803
|
-
|
|
1761
|
+
toTxObject(tx, service),
|
|
1762
|
+
toTxObject(tx, permission),
|
|
1804
1763
|
tx.object.mutRegistrar(),
|
|
1805
1764
|
],
|
|
1806
1765
|
typeArguments: [service_type],
|
|
1807
1766
|
});
|
|
1808
1767
|
}
|
|
1809
1768
|
}
|
|
1810
|
-
function compensation_fund_receive(tx, service, service_type, permission, received_object, payment, passport) {
|
|
1769
|
+
export function compensation_fund_receive(tx, service, service_type, permission, received_object, payment, passport) {
|
|
1811
1770
|
if (!payment) {
|
|
1812
|
-
|
|
1771
|
+
W_ERROR(WErrors.InvalidParam, `Compensation fund receive payment is required`);
|
|
1813
1772
|
}
|
|
1814
|
-
|
|
1815
|
-
if (!
|
|
1816
|
-
|
|
1773
|
+
validObjects([service, permission, received_object, payment, passport]);
|
|
1774
|
+
if (!IsValidArgType(service_type)) {
|
|
1775
|
+
W_ERROR(WErrors.InvalidParam, `Compensation fund receive service type ${service_type} is not valid`);
|
|
1817
1776
|
}
|
|
1818
1777
|
if (passport) {
|
|
1819
1778
|
tx.moveCall({
|
|
1820
|
-
target:
|
|
1779
|
+
target: serviceFn("compensation_fund_receive_with_passport"),
|
|
1821
1780
|
arguments: [
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1781
|
+
toTxObject(tx, service),
|
|
1782
|
+
toTxObject(tx, permission),
|
|
1783
|
+
toTxObject(tx, passport),
|
|
1784
|
+
toTxObject(tx, received_object),
|
|
1785
|
+
toTxObject(tx, payment),
|
|
1827
1786
|
],
|
|
1828
1787
|
typeArguments: [service_type],
|
|
1829
1788
|
});
|
|
1830
1789
|
}
|
|
1831
1790
|
else {
|
|
1832
1791
|
tx.moveCall({
|
|
1833
|
-
target:
|
|
1792
|
+
target: serviceFn("compensation_fund_receive"),
|
|
1834
1793
|
arguments: [
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1794
|
+
toTxObject(tx, service),
|
|
1795
|
+
toTxObject(tx, permission),
|
|
1796
|
+
toTxObject(tx, received_object),
|
|
1797
|
+
toTxObject(tx, payment),
|
|
1839
1798
|
],
|
|
1840
1799
|
typeArguments: [service_type],
|
|
1841
1800
|
});
|
|
1842
1801
|
}
|
|
1843
1802
|
}
|
|
1844
|
-
function compensation_fund_withdraw(tx, service, service_type, payment_info, receipt, permission, passport) {
|
|
1845
|
-
|
|
1846
|
-
if (!
|
|
1847
|
-
|
|
1803
|
+
export function compensation_fund_withdraw(tx, service, service_type, payment_info, receipt, permission, passport) {
|
|
1804
|
+
validObjects([service, permission, receipt, payment_info, passport]);
|
|
1805
|
+
if (!IsValidArgType(service_type)) {
|
|
1806
|
+
W_ERROR(WErrors.InvalidParam, `Compensation fund withdraw service type ${service_type} is not valid`);
|
|
1848
1807
|
}
|
|
1849
1808
|
if (passport) {
|
|
1850
1809
|
tx.moveCall({
|
|
1851
|
-
target:
|
|
1810
|
+
target: serviceFn("compensation_fund_withdraw_with_passport"),
|
|
1852
1811
|
arguments: [
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1812
|
+
toTxObject(tx, service),
|
|
1813
|
+
toTxObject(tx, permission),
|
|
1814
|
+
toTxObject(tx, passport),
|
|
1856
1815
|
tx.pure.address(receipt),
|
|
1857
|
-
|
|
1816
|
+
toTxObject(tx, payment_info),
|
|
1858
1817
|
tx.object.mutRegistrar(),
|
|
1859
1818
|
tx.object.clock(),
|
|
1860
1819
|
],
|
|
@@ -1863,12 +1822,12 @@ function compensation_fund_withdraw(tx, service, service_type, payment_info, rec
|
|
|
1863
1822
|
}
|
|
1864
1823
|
else {
|
|
1865
1824
|
tx.moveCall({
|
|
1866
|
-
target:
|
|
1825
|
+
target: serviceFn("compensation_fund_withdraw"),
|
|
1867
1826
|
arguments: [
|
|
1868
|
-
|
|
1869
|
-
|
|
1827
|
+
toTxObject(tx, service),
|
|
1828
|
+
toTxObject(tx, permission),
|
|
1870
1829
|
tx.pure.address(receipt),
|
|
1871
|
-
|
|
1830
|
+
toTxObject(tx, payment_info),
|
|
1872
1831
|
tx.object.mutRegistrar(),
|
|
1873
1832
|
tx.object.clock(),
|
|
1874
1833
|
],
|
|
@@ -1876,7 +1835,7 @@ function compensation_fund_withdraw(tx, service, service_type, payment_info, rec
|
|
|
1876
1835
|
});
|
|
1877
1836
|
}
|
|
1878
1837
|
}
|
|
1879
|
-
async function discount(tx, service, service_type, permission, discount, passport) {
|
|
1838
|
+
export async function discount(tx, service, service_type, permission, discount, passport) {
|
|
1880
1839
|
let recipient = [];
|
|
1881
1840
|
if (Array.isArray(discount.recipient)) {
|
|
1882
1841
|
// 如果 recipient 是 string[] 类型,直接使用
|
|
@@ -1884,46 +1843,46 @@ async function discount(tx, service, service_type, permission, discount, passpor
|
|
|
1884
1843
|
}
|
|
1885
1844
|
else {
|
|
1886
1845
|
// 如果 recipient 是 ManyAccountOrMark_Address 类型,调用 GetManyAccountOrMark_Address
|
|
1887
|
-
recipient = await
|
|
1846
|
+
recipient = await GetManyAccountOrMark_Address(discount.recipient);
|
|
1888
1847
|
}
|
|
1889
1848
|
if (recipient.length === 0 || discount.count === 0) {
|
|
1890
1849
|
return;
|
|
1891
1850
|
}
|
|
1892
|
-
if (recipient.length >
|
|
1893
|
-
|
|
1851
|
+
if (recipient.length > MAX_DISCOUNT_RECEIVER_ONCE) {
|
|
1852
|
+
W_ERROR(WErrors.InvalidParam, `Discount recipient length ${recipient.length} is exceed max ${MAX_DISCOUNT_RECEIVER_ONCE}`);
|
|
1894
1853
|
}
|
|
1895
|
-
if (!
|
|
1896
|
-
|
|
1854
|
+
if (!isValidName(discount.name)) {
|
|
1855
|
+
W_ERROR(WErrors.InvalidParam, `Discount name ${discount.name} is not valid`);
|
|
1897
1856
|
}
|
|
1898
|
-
if (!
|
|
1899
|
-
discount.count >
|
|
1900
|
-
|
|
1857
|
+
if (!isValidU16(discount.count) ||
|
|
1858
|
+
discount.count > MAX_DISCOUNT_COUNT_ONCE) {
|
|
1859
|
+
W_ERROR(WErrors.InvalidParam, `Discount count ${discount.count} is exceed max ${MAX_DISCOUNT_COUNT_ONCE}`);
|
|
1901
1860
|
}
|
|
1902
|
-
if (recipient.length * discount.count >
|
|
1903
|
-
|
|
1861
|
+
if (recipient.length * discount.count > MAX_DISCOUNT_TOTAL_COUNT) {
|
|
1862
|
+
W_ERROR(WErrors.InvalidParam, `Discount total count ${recipient.length * discount.count} is exceed max ${MAX_DISCOUNT_TOTAL_COUNT}`);
|
|
1904
1863
|
}
|
|
1905
|
-
if (discount.benchmark != null && !
|
|
1906
|
-
|
|
1864
|
+
if (discount.benchmark != null && !isValidU64(discount.benchmark)) {
|
|
1865
|
+
W_ERROR(WErrors.InvalidParam, `Discount benchmark ${discount.benchmark} is not valid`);
|
|
1907
1866
|
}
|
|
1908
1867
|
const start = discount.time_ms_start ?? Date.now();
|
|
1909
1868
|
if (discount.time_ms_end < start) {
|
|
1910
|
-
|
|
1869
|
+
W_ERROR(WErrors.InvalidParam, `Discount time_ms_end ${discount.time_ms_end} is not valid`);
|
|
1911
1870
|
}
|
|
1912
1871
|
if (discount.discount_value != null &&
|
|
1913
|
-
!
|
|
1914
|
-
|
|
1872
|
+
!isValidU64(discount.discount_value)) {
|
|
1873
|
+
W_ERROR(WErrors.InvalidParam, `Discount discount_value ${discount.discount_value} is not valid`);
|
|
1915
1874
|
}
|
|
1916
|
-
|
|
1917
|
-
if (!
|
|
1918
|
-
|
|
1875
|
+
validObjects([service, permission, passport, ...recipient]);
|
|
1876
|
+
if (!IsValidArgType(service_type)) {
|
|
1877
|
+
W_ERROR(WErrors.InvalidParam, `Discount service type ${service_type} is not valid`);
|
|
1919
1878
|
}
|
|
1920
1879
|
if (passport) {
|
|
1921
1880
|
tx.moveCall({
|
|
1922
|
-
target:
|
|
1881
|
+
target: serviceFn("discount_with_passport"),
|
|
1923
1882
|
arguments: [
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1883
|
+
toTxObject(tx, service),
|
|
1884
|
+
toTxObject(tx, permission),
|
|
1885
|
+
toTxObject(tx, passport),
|
|
1927
1886
|
tx.pure.string(discount.name),
|
|
1928
1887
|
tx.pure.u8(discount.discount_type),
|
|
1929
1888
|
tx.pure.u64(discount.discount_value),
|
|
@@ -1940,10 +1899,10 @@ async function discount(tx, service, service_type, permission, discount, passpor
|
|
|
1940
1899
|
}
|
|
1941
1900
|
else {
|
|
1942
1901
|
tx.moveCall({
|
|
1943
|
-
target:
|
|
1902
|
+
target: serviceFn("discount"),
|
|
1944
1903
|
arguments: [
|
|
1945
|
-
|
|
1946
|
-
|
|
1904
|
+
toTxObject(tx, service),
|
|
1905
|
+
toTxObject(tx, permission),
|
|
1947
1906
|
tx.pure.string(discount.name),
|
|
1948
1907
|
tx.pure.u8(discount.discount_type),
|
|
1949
1908
|
tx.pure.u64(discount.discount_value),
|