wowok 2.1.13 → 2.1.15
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.js +125 -174
- package/dist/cjs/w/messenger/messenger-api.js.map +1 -1
- package/dist/cjs/w/messenger/messenger-manager.js +49 -53
- 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.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/package.json +7 -4
- package/scripts/download-prebuilds.js +213 -195
- package/scripts/install-better-sqlite3.js +8 -8
|
@@ -1,46 +1,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright (c) Wowok.
|
|
3
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
exports.policy_clear = policy_clear;
|
|
17
|
-
exports.reward_add = reward_add;
|
|
18
|
-
exports.reward_remove = reward_remove;
|
|
19
|
-
exports.reward_clear = reward_clear;
|
|
20
|
-
exports.data_remove = data_remove;
|
|
21
|
-
const common_js_1 = require("../common.js");
|
|
22
|
-
const exception_js_1 = require("../exception.js");
|
|
23
|
-
const util_js_1 = require("../util.js");
|
|
24
|
-
const common_js_2 = require("../common.js");
|
|
25
|
-
const index_js_1 = require("../local/index.js");
|
|
26
|
-
const local_js_1 = require("../local/local.js");
|
|
27
|
-
const base_js_1 = require("./base.js");
|
|
28
|
-
const permission_js_1 = require("./permission.js");
|
|
29
|
-
const object_js_1 = require("../query/object.js");
|
|
30
|
-
const permission_js_2 = require("./permission.js");
|
|
31
|
-
const util_js_2 = require("../query/util.js");
|
|
32
|
-
const received_js_1 = require("../query/received.js");
|
|
3
|
+
import { toTxObject, toTxString, isValidDescription, MAX_DESCRIPTION_LENGTH, isValidName, PackageAddress, IsValidArgType, isValidU8, repositoryFn, parseValueType, } from "../common.js";
|
|
4
|
+
import { W_ERROR, WErrors } from "../exception.js";
|
|
5
|
+
import { owner_receive, validObjects, valueToBcsBytes, uint2address, } from "../util.js";
|
|
6
|
+
import { GetObjectExisted, GetObject, GetObjectDescription, } from "../common.js";
|
|
7
|
+
import { GetAccountOrMark_Address } from "../local/index.js";
|
|
8
|
+
import { LocalMark } from "../local/local.js";
|
|
9
|
+
import { CallBase } from "./base.js";
|
|
10
|
+
import { BuiltinPermissionIndex, newPermission } from "./permission.js";
|
|
11
|
+
import { IdFrom, ObjectType, parseIdFrom } from "../query/object.js";
|
|
12
|
+
import { create as permissionCreate } from "./permission.js";
|
|
13
|
+
import { queryObjectsWithType } from "../query/util.js";
|
|
14
|
+
import { query_received } from "../query/received.js";
|
|
33
15
|
// ================================================
|
|
34
16
|
// 常量定义
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
17
|
+
export const MAX_POLICY_DESCRIPTION_LEN = 500;
|
|
18
|
+
export const MAX_POLICY_COUNT = 50;
|
|
19
|
+
export const MAX_POLICY_GUARD_COUNT = 10;
|
|
20
|
+
export const MAX_DATA_SIZE = 40960; // 10KB
|
|
21
|
+
export const MAX_ID_COUNT_ONCE = 100;
|
|
22
|
+
export const MAX_REWARD_COUNT = 20;
|
|
41
23
|
// ================================================
|
|
42
24
|
// 数据操作类 TODO: submission无需提供id或data的情况,支持的不好,现在仍要填充并检查数据有效性
|
|
43
|
-
class CallRepository extends
|
|
25
|
+
export class CallRepository extends CallBase {
|
|
44
26
|
data;
|
|
45
27
|
object_address = undefined;
|
|
46
28
|
permission_address = undefined;
|
|
@@ -52,21 +34,21 @@ class CallRepository extends base_js_1.CallBase {
|
|
|
52
34
|
async prepare(env) {
|
|
53
35
|
await super.prepare(env);
|
|
54
36
|
if (!this.object_address) {
|
|
55
|
-
this.object_address = await
|
|
37
|
+
this.object_address = await GetObjectExisted(this.data?.object);
|
|
56
38
|
}
|
|
57
39
|
if (this.object_address) {
|
|
58
|
-
await this.update_content(env,
|
|
40
|
+
await this.update_content(env, ObjectType.Repository, this.object_address);
|
|
59
41
|
if (!this.content)
|
|
60
|
-
|
|
42
|
+
W_ERROR(WErrors.InvalidParam, "CallRepository_Data.data.object:" + this.object_address);
|
|
61
43
|
this.permission_address = this.content.permission;
|
|
62
44
|
if (!this.permission_address) {
|
|
63
|
-
|
|
45
|
+
W_ERROR(WErrors.InvalidParam, "CallRepository_Data.data.object.permission is empty");
|
|
64
46
|
}
|
|
65
47
|
}
|
|
66
48
|
else {
|
|
67
|
-
const n =
|
|
68
|
-
this.permission_address = await
|
|
69
|
-
this.new_permission_description =
|
|
49
|
+
const n = GetObject(this.data.object);
|
|
50
|
+
this.permission_address = await GetObjectExisted(n?.permission);
|
|
51
|
+
this.new_permission_description = GetObjectDescription(n?.permission);
|
|
70
52
|
}
|
|
71
53
|
}
|
|
72
54
|
async call(env) {
|
|
@@ -84,24 +66,24 @@ class CallRepository extends base_js_1.CallBase {
|
|
|
84
66
|
}
|
|
85
67
|
};
|
|
86
68
|
if (this.permission_address && !this.object_address) {
|
|
87
|
-
add_perm(
|
|
69
|
+
add_perm(BuiltinPermissionIndex.REPOSITORY_NEW);
|
|
88
70
|
}
|
|
89
71
|
if (this.permission_address &&
|
|
90
72
|
this.data?.description != null &&
|
|
91
73
|
this.object_address) {
|
|
92
|
-
add_perm(
|
|
74
|
+
add_perm(BuiltinPermissionIndex.REPOSITORY_DESCRIPTION);
|
|
93
75
|
}
|
|
94
76
|
if (this.permission_address && this.data?.policies != null) {
|
|
95
|
-
add_perm(
|
|
77
|
+
add_perm(BuiltinPermissionIndex.REPOSITORY_POLICY);
|
|
96
78
|
}
|
|
97
79
|
// 对id和guard做地址转换和检查
|
|
98
80
|
if (this.data?.data_add != null) {
|
|
99
81
|
if (!this.content) {
|
|
100
|
-
|
|
82
|
+
W_ERROR(WErrors.InvalidParam, "CallRepository_Data.data.data_add fail because the Repository content not ready");
|
|
101
83
|
}
|
|
102
84
|
const p = this.content.policies.find((p) => p.name === this.data.data_add.name);
|
|
103
85
|
if (!p) {
|
|
104
|
-
|
|
86
|
+
W_ERROR(WErrors.InvalidParam, `Invalid policy name: ${this.data.data_add.name}`);
|
|
105
87
|
}
|
|
106
88
|
// 处理 data_add 中的数据
|
|
107
89
|
if ("items" in this.data.data_add) {
|
|
@@ -114,12 +96,12 @@ class CallRepository extends base_js_1.CallBase {
|
|
|
114
96
|
if (typeof keyData.id === "number" ||
|
|
115
97
|
typeof keyData.id === "bigint" ||
|
|
116
98
|
typeof keyData.id === "string") {
|
|
117
|
-
idAddress =
|
|
99
|
+
idAddress = uint2address(keyData.id);
|
|
118
100
|
}
|
|
119
101
|
else {
|
|
120
|
-
const r = await
|
|
102
|
+
const r = await GetAccountOrMark_Address(keyData.id);
|
|
121
103
|
if (!r) {
|
|
122
|
-
|
|
104
|
+
W_ERROR(WErrors.InvalidParam, `Invalid id address: ${keyData.id}`);
|
|
123
105
|
}
|
|
124
106
|
idAddress = r;
|
|
125
107
|
}
|
|
@@ -128,39 +110,39 @@ class CallRepository extends base_js_1.CallBase {
|
|
|
128
110
|
// 处理 write_guard 字段
|
|
129
111
|
if (item.write_guard) {
|
|
130
112
|
// 将 write_guard 转换为地址
|
|
131
|
-
const guardAddress = await
|
|
113
|
+
const guardAddress = await LocalMark.Instance().get_address(item.write_guard);
|
|
132
114
|
if (guardAddress) {
|
|
133
115
|
if (!p.write_guard.find((g) => g.guard === guardAddress)) {
|
|
134
|
-
|
|
116
|
+
W_ERROR(WErrors.InvalidParam, `${item.write_guard} (${guardAddress}) is not match in policy ${p.name} with write_guards: ${p.write_guard.map((g) => g.guard).join(", ")}`);
|
|
135
117
|
}
|
|
136
118
|
item.write_guard = guardAddress;
|
|
137
119
|
add_guard(guardAddress);
|
|
138
120
|
}
|
|
139
121
|
else {
|
|
140
|
-
|
|
122
|
+
W_ERROR(WErrors.InvalidParam, `Invalid write_guard address: ${item.write_guard}`);
|
|
141
123
|
}
|
|
142
124
|
}
|
|
143
125
|
}
|
|
144
126
|
}
|
|
145
127
|
else if (this.data.data_add.write_guard) {
|
|
146
128
|
// 处理 SignerOrClock 类型的 write_guard
|
|
147
|
-
const guardAddress = await
|
|
129
|
+
const guardAddress = await LocalMark.Instance().get_address(this.data.data_add.write_guard);
|
|
148
130
|
if (guardAddress) {
|
|
149
131
|
if (!p.write_guard.find((g) => g.guard === guardAddress)) {
|
|
150
|
-
|
|
132
|
+
W_ERROR(WErrors.InvalidParam, `Invalid write_guard address: ${this.data.data_add.write_guard} in policy ${p.name}`);
|
|
151
133
|
}
|
|
152
134
|
this.data.data_add.write_guard = guardAddress;
|
|
153
135
|
add_guard(guardAddress);
|
|
154
136
|
}
|
|
155
137
|
else {
|
|
156
|
-
|
|
138
|
+
W_ERROR(WErrors.InvalidParam, `Invalid write_guard address: ${this.data.data_add.write_guard}`);
|
|
157
139
|
}
|
|
158
140
|
}
|
|
159
141
|
}
|
|
160
142
|
if (this.data?.data_remove != null) {
|
|
161
143
|
const p = this.content.policies.find((p) => p.name === this.data.data_remove.name);
|
|
162
144
|
if (!p) {
|
|
163
|
-
|
|
145
|
+
W_ERROR(WErrors.InvalidParam, `Invalid policy name: ${this.data.data_remove.name}`);
|
|
164
146
|
}
|
|
165
147
|
// 处理 data_remove 中的数据
|
|
166
148
|
if ("items" in this.data.data_remove) {
|
|
@@ -173,12 +155,12 @@ class CallRepository extends base_js_1.CallBase {
|
|
|
173
155
|
if (typeof id === "number" ||
|
|
174
156
|
typeof id === "bigint" ||
|
|
175
157
|
typeof id === "string") {
|
|
176
|
-
idAddress =
|
|
158
|
+
idAddress = uint2address(id);
|
|
177
159
|
}
|
|
178
160
|
else {
|
|
179
|
-
const r = await
|
|
161
|
+
const r = await GetAccountOrMark_Address(id);
|
|
180
162
|
if (!r) {
|
|
181
|
-
|
|
163
|
+
W_ERROR(WErrors.InvalidParam, `Invalid id address: ${id}`);
|
|
182
164
|
}
|
|
183
165
|
idAddress = r;
|
|
184
166
|
}
|
|
@@ -188,16 +170,16 @@ class CallRepository extends base_js_1.CallBase {
|
|
|
188
170
|
// 处理 write_guard 字段
|
|
189
171
|
if (item.write_guard) {
|
|
190
172
|
// 将 write_guard 转换为地址
|
|
191
|
-
const guardAddress = await
|
|
173
|
+
const guardAddress = await LocalMark.Instance().get_address(item.write_guard);
|
|
192
174
|
if (guardAddress) {
|
|
193
175
|
if (!p.write_guard.find((g) => g.guard === guardAddress)) {
|
|
194
|
-
|
|
176
|
+
W_ERROR(WErrors.InvalidParam, `Invalid write_guard address: ${item.write_guard} in policy ${p.name}`);
|
|
195
177
|
}
|
|
196
178
|
item.write_guard = guardAddress;
|
|
197
179
|
add_guard(guardAddress);
|
|
198
180
|
}
|
|
199
181
|
else {
|
|
200
|
-
|
|
182
|
+
W_ERROR(WErrors.InvalidParam, `Invalid write_guard address: ${item.write_guard}`);
|
|
201
183
|
}
|
|
202
184
|
}
|
|
203
185
|
}
|
|
@@ -205,28 +187,28 @@ class CallRepository extends base_js_1.CallBase {
|
|
|
205
187
|
else {
|
|
206
188
|
if (this.data.data_remove.write_guard) {
|
|
207
189
|
// 处理 SignerOrClockBase 类型的 write_guard
|
|
208
|
-
const guardAddress = await
|
|
190
|
+
const guardAddress = await LocalMark.Instance().get_address(this.data.data_remove.write_guard);
|
|
209
191
|
if (guardAddress) {
|
|
210
192
|
if (!p.write_guard.find((g) => g.guard === guardAddress)) {
|
|
211
|
-
|
|
193
|
+
W_ERROR(WErrors.InvalidParam, `Invalid write_guard address: ${this.data.data_remove.write_guard} in policy ${p.name}`);
|
|
212
194
|
}
|
|
213
195
|
this.data.data_remove.write_guard = guardAddress;
|
|
214
196
|
add_guard(guardAddress);
|
|
215
197
|
}
|
|
216
198
|
else {
|
|
217
|
-
|
|
199
|
+
W_ERROR(WErrors.InvalidParam, `Invalid write_guard address: ${this.data.data_remove.write_guard}`);
|
|
218
200
|
}
|
|
219
201
|
}
|
|
220
202
|
}
|
|
221
203
|
}
|
|
222
204
|
if (this.permission_address && this.data?.rewards != null) {
|
|
223
|
-
add_perm(
|
|
205
|
+
add_perm(BuiltinPermissionIndex.REPOSITORY_REWARD);
|
|
224
206
|
}
|
|
225
207
|
if (this.permission_address && this.data?.owner_receive != null) {
|
|
226
|
-
add_perm(
|
|
208
|
+
add_perm(BuiltinPermissionIndex.REPOSITORY_OWNER_RECEIVE);
|
|
227
209
|
}
|
|
228
210
|
if (this.permission_address && this.data?.um !== undefined) {
|
|
229
|
-
add_perm(
|
|
211
|
+
add_perm(BuiltinPermissionIndex.REPOSITORY_UM);
|
|
230
212
|
}
|
|
231
213
|
if (this.permission_address || guards.length > 0) {
|
|
232
214
|
return await this.check_permission_and_call(env, this.permission_address, perms, guards);
|
|
@@ -239,14 +221,14 @@ class CallRepository extends base_js_1.CallBase {
|
|
|
239
221
|
//console.dir(this.data, { depth: null });
|
|
240
222
|
if (!this.object_address) {
|
|
241
223
|
if (!permission) {
|
|
242
|
-
permission =
|
|
224
|
+
permission = newPermission(tx, this.new_permission_description ?? "");
|
|
243
225
|
}
|
|
244
226
|
if (permission) {
|
|
245
|
-
object = newRepository(tx,
|
|
227
|
+
object = newRepository(tx, toTxObject(tx, permission), this.data?.description ?? "", passport);
|
|
246
228
|
}
|
|
247
229
|
}
|
|
248
230
|
if (!object || !permission) {
|
|
249
|
-
|
|
231
|
+
W_ERROR(WErrors.InvalidParam, "CallRepository_Data.data.object:" + this.object_address);
|
|
250
232
|
}
|
|
251
233
|
if (this.data?.description != null && this.object_address) {
|
|
252
234
|
description_set(tx, object, permission, this.data.description, passport);
|
|
@@ -258,23 +240,23 @@ class CallRepository extends base_js_1.CallBase {
|
|
|
258
240
|
await Promise.all(this.data.policies.policy.map(async (p) => {
|
|
259
241
|
// 处理 write_guard 数组
|
|
260
242
|
await Promise.all(p.write_guard.map(async (g) => {
|
|
261
|
-
const r = await
|
|
243
|
+
const r = await LocalMark.Instance().get_address(g.guard);
|
|
262
244
|
if (r) {
|
|
263
245
|
g.guard = r;
|
|
264
246
|
}
|
|
265
247
|
else {
|
|
266
|
-
|
|
248
|
+
W_ERROR(WErrors.InvalidParam, `Invalid write_guard address: ${g.guard}`);
|
|
267
249
|
}
|
|
268
250
|
}));
|
|
269
251
|
// 处理 quote_guard 字段
|
|
270
252
|
if (p.quote_guard &&
|
|
271
253
|
typeof p.quote_guard === "string") {
|
|
272
|
-
const r = await
|
|
254
|
+
const r = await LocalMark.Instance().get_address(p.quote_guard);
|
|
273
255
|
if (r) {
|
|
274
256
|
p.quote_guard = r;
|
|
275
257
|
}
|
|
276
258
|
else {
|
|
277
|
-
|
|
259
|
+
W_ERROR(WErrors.InvalidParam, `Invalid quote_guard address: ${p.quote_guard}`);
|
|
278
260
|
}
|
|
279
261
|
}
|
|
280
262
|
}));
|
|
@@ -302,7 +284,7 @@ class CallRepository extends base_js_1.CallBase {
|
|
|
302
284
|
// 查找 policy 中的 write_guard
|
|
303
285
|
const policy = this.content.policies.find((p) => p.name === this.data.data_add.name);
|
|
304
286
|
if (!policy) {
|
|
305
|
-
|
|
287
|
+
W_ERROR(WErrors.InvalidParam, `policy ${this.data.data_add.name} not found in policies ${this.content.policies.map((p) => p.name)}`);
|
|
306
288
|
}
|
|
307
289
|
if ("items" in this.data.data_add) {
|
|
308
290
|
data(tx, object, policy, this.data.data_add.items, passport);
|
|
@@ -315,7 +297,7 @@ class CallRepository extends base_js_1.CallBase {
|
|
|
315
297
|
// 查找 policy 中的 write_guard
|
|
316
298
|
const policy = this.content.policies.find((p) => p.name === this.data.data_remove.name);
|
|
317
299
|
if (!policy) {
|
|
318
|
-
|
|
300
|
+
W_ERROR(WErrors.InvalidParam, `policy ${this.data.data_remove.name} not found in policies ${this.content.policies.map((p) => p.name)}`);
|
|
319
301
|
}
|
|
320
302
|
if ("items" in this.data.data_remove) {
|
|
321
303
|
data_remove(tx, object, policy, { items: this.data.data_remove.items }, passport);
|
|
@@ -328,24 +310,24 @@ class CallRepository extends base_js_1.CallBase {
|
|
|
328
310
|
switch (this.data.rewards.op) {
|
|
329
311
|
case "set":
|
|
330
312
|
case "add": {
|
|
331
|
-
if (this.data.rewards.objects.length >
|
|
332
|
-
|
|
313
|
+
if (this.data.rewards.objects.length > MAX_REWARD_COUNT) {
|
|
314
|
+
W_ERROR(WErrors.InvalidParam, `rewards count exceeds maximum limit ${MAX_REWARD_COUNT}`);
|
|
333
315
|
}
|
|
334
316
|
if (this.data.rewards.op === "set") {
|
|
335
317
|
reward_clear(tx, object, permission, passport);
|
|
336
318
|
}
|
|
337
319
|
// 无需localmark查询
|
|
338
|
-
const rewards = await
|
|
320
|
+
const rewards = await queryObjectsWithType(env, this.data.rewards.objects, ObjectType.Reward, "reward::Reward", false);
|
|
339
321
|
rewards.forEach((reward) => {
|
|
340
322
|
reward_add(tx, object, permission, reward.object, reward.type, passport);
|
|
341
323
|
});
|
|
342
324
|
break;
|
|
343
325
|
}
|
|
344
326
|
case "remove": {
|
|
345
|
-
if (this.data.rewards.objects.length >
|
|
346
|
-
|
|
327
|
+
if (this.data.rewards.objects.length > MAX_REWARD_COUNT) {
|
|
328
|
+
W_ERROR(WErrors.InvalidParam, `rewards count exceeds maximum limit ${MAX_REWARD_COUNT}`);
|
|
347
329
|
}
|
|
348
|
-
const rewardAddrs = await
|
|
330
|
+
const rewardAddrs = await LocalMark.Instance().get_many_address_availables(this.data.rewards.objects);
|
|
349
331
|
reward_remove(tx, object, permission, rewardAddrs, passport);
|
|
350
332
|
break;
|
|
351
333
|
}
|
|
@@ -357,80 +339,79 @@ class CallRepository extends base_js_1.CallBase {
|
|
|
357
339
|
}
|
|
358
340
|
if (this.data.owner_receive != null && this.object_address) {
|
|
359
341
|
if (this.data.owner_receive === "recently") {
|
|
360
|
-
this.data.owner_receive = await
|
|
342
|
+
this.data.owner_receive = await query_received({
|
|
361
343
|
object: this.object_address,
|
|
362
344
|
all_type: true,
|
|
363
345
|
});
|
|
364
346
|
}
|
|
365
|
-
await
|
|
347
|
+
await owner_receive(tx, object, permission, this.data.owner_receive, undefined, (name) => `${PackageAddress}::repository::${name}`, passport);
|
|
366
348
|
}
|
|
367
349
|
// 处理 um
|
|
368
350
|
if (this.data.um !== undefined) {
|
|
369
351
|
let um_address = null;
|
|
370
352
|
if (this.data.um) {
|
|
371
353
|
um_address =
|
|
372
|
-
(await
|
|
354
|
+
(await LocalMark.Instance().get_address(this.data.um)) ||
|
|
373
355
|
null;
|
|
374
356
|
if (!um_address) {
|
|
375
|
-
|
|
357
|
+
W_ERROR(WErrors.InvalidParam, "CallRepository_Data.data.um:" + this.data.um);
|
|
376
358
|
}
|
|
377
359
|
}
|
|
378
360
|
um_set(tx, object, permission, um_address, passport);
|
|
379
361
|
}
|
|
380
362
|
if (!this.permission_address) {
|
|
381
|
-
const p =
|
|
382
|
-
await this.new_with_mark(env, tx,
|
|
363
|
+
const p = GetObject(this.data?.object);
|
|
364
|
+
await this.new_with_mark(env, tx, ObjectType.Permission, permissionCreate(tx, permission), GetObject(p.permission));
|
|
383
365
|
}
|
|
384
366
|
if (!this.object_address) {
|
|
385
|
-
await this.new_with_mark(env, tx,
|
|
367
|
+
await this.new_with_mark(env, tx, ObjectType.Repository, create(tx, object), GetObject(this.data?.object));
|
|
386
368
|
}
|
|
387
369
|
}
|
|
388
370
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
(0, util_js_1.validObjects)([repository]);
|
|
371
|
+
export function create(tx, repository) {
|
|
372
|
+
validObjects([repository]);
|
|
392
373
|
return tx.moveCall({
|
|
393
|
-
target:
|
|
394
|
-
arguments: [
|
|
374
|
+
target: repositoryFn("create"),
|
|
375
|
+
arguments: [toTxObject(tx, repository)],
|
|
395
376
|
});
|
|
396
377
|
}
|
|
397
378
|
function policy_guard(tx, param) {
|
|
398
|
-
|
|
379
|
+
validObjects([param.guard]);
|
|
399
380
|
if (param.id_from_submission != null &&
|
|
400
|
-
!
|
|
401
|
-
|
|
381
|
+
!isValidU8(param.id_from_submission)) {
|
|
382
|
+
W_ERROR(WErrors.IsValidU8, `Id from submission ${param.id_from_submission} is not valid`);
|
|
402
383
|
}
|
|
403
384
|
if (param.data_from_submission != null &&
|
|
404
|
-
!
|
|
405
|
-
|
|
385
|
+
!isValidU8(param.data_from_submission)) {
|
|
386
|
+
W_ERROR(WErrors.IsValidU8, `Data from submission ${param.data_from_submission} is not valid`);
|
|
406
387
|
}
|
|
407
388
|
return tx.moveCall({
|
|
408
|
-
target:
|
|
389
|
+
target: repositoryFn("policy_guard"),
|
|
409
390
|
arguments: [
|
|
410
|
-
|
|
391
|
+
toTxObject(tx, param.guard),
|
|
411
392
|
tx.pure.option("u8", param.id_from_submission ?? null),
|
|
412
393
|
tx.pure.option("u8", param.data_from_submission ?? null),
|
|
413
394
|
],
|
|
414
395
|
});
|
|
415
396
|
}
|
|
416
|
-
function policy(tx, param) {
|
|
417
|
-
if (typeof param.name === "string" && !
|
|
418
|
-
|
|
397
|
+
export function policy(tx, param) {
|
|
398
|
+
if (typeof param.name === "string" && !isValidName(param.name)) {
|
|
399
|
+
W_ERROR(WErrors.InvalidParam, `Policy name ${param.name} is not valid`);
|
|
419
400
|
}
|
|
420
401
|
if (typeof param.description === "string" &&
|
|
421
|
-
!
|
|
422
|
-
|
|
402
|
+
!isValidDescription(param.description)) {
|
|
403
|
+
W_ERROR(WErrors.IsValidDescription, `Description exceeds maximum length ${MAX_DESCRIPTION_LENGTH}`);
|
|
423
404
|
}
|
|
424
|
-
|
|
405
|
+
validObjects([
|
|
425
406
|
param.quote_guard,
|
|
426
407
|
...param.write_guard.map((guard) => guard.guard),
|
|
427
408
|
]);
|
|
428
|
-
const idFrom =
|
|
409
|
+
const idFrom = parseIdFrom(param.id_from);
|
|
429
410
|
const obj = tx.moveCall({
|
|
430
|
-
target:
|
|
411
|
+
target: repositoryFn("policy"),
|
|
431
412
|
arguments: [
|
|
432
|
-
|
|
433
|
-
|
|
413
|
+
toTxString(tx, param.name),
|
|
414
|
+
toTxString(tx, param.description),
|
|
434
415
|
tx.pure.u8(idFrom),
|
|
435
416
|
tx.pure.u8(param.value_type),
|
|
436
417
|
],
|
|
@@ -438,88 +419,88 @@ function policy(tx, param) {
|
|
|
438
419
|
if (param.quote_guard) {
|
|
439
420
|
// some
|
|
440
421
|
tx.moveCall({
|
|
441
|
-
target:
|
|
442
|
-
arguments: [obj,
|
|
422
|
+
target: repositoryFn("policy_quote_guard_set"),
|
|
423
|
+
arguments: [obj, toTxObject(tx, param.quote_guard)],
|
|
443
424
|
});
|
|
444
425
|
}
|
|
445
426
|
else if (param.quote_guard === null) {
|
|
446
427
|
//@ null
|
|
447
428
|
tx.moveCall({
|
|
448
|
-
target:
|
|
429
|
+
target: repositoryFn("policy_quote_guard_none"),
|
|
449
430
|
arguments: [obj],
|
|
450
431
|
});
|
|
451
432
|
}
|
|
452
433
|
if (param.write_guard.length > 0) {
|
|
453
434
|
tx.moveCall({
|
|
454
|
-
target:
|
|
435
|
+
target: repositoryFn("policy_write_guard_set"),
|
|
455
436
|
arguments: [
|
|
456
437
|
obj,
|
|
457
438
|
tx.makeMoveVec({
|
|
458
439
|
elements: param.write_guard.map((guard) => policy_guard(tx, guard)),
|
|
459
|
-
type: `${
|
|
440
|
+
type: `${PackageAddress}::repository::PolicyGuard`,
|
|
460
441
|
}),
|
|
461
442
|
],
|
|
462
443
|
});
|
|
463
444
|
}
|
|
464
445
|
return obj;
|
|
465
446
|
}
|
|
466
|
-
async function data_id_from(tx, repository, policy, data, passport) {
|
|
447
|
+
export async function data_id_from(tx, repository, policy, data, passport) {
|
|
467
448
|
// RepIdData类型
|
|
468
|
-
const idFrom =
|
|
469
|
-
if (idFrom ===
|
|
470
|
-
|
|
449
|
+
const idFrom = parseIdFrom(policy.id_from);
|
|
450
|
+
if (idFrom === IdFrom.None) {
|
|
451
|
+
W_ERROR(WErrors.InvalidParam, `id_from must be set when id_from is IdFrom.None`);
|
|
471
452
|
}
|
|
472
453
|
if (data.write_guard) {
|
|
473
454
|
if (!passport) {
|
|
474
|
-
|
|
455
|
+
W_ERROR(WErrors.InvalidParam, `passport is required when write_guard is specified`);
|
|
475
456
|
}
|
|
476
457
|
if (policy.write_guard.find((guard) => guard.guard === data.write_guard)) {
|
|
477
|
-
const policyValueType1 =
|
|
458
|
+
const policyValueType1 = parseValueType(policy.value_type);
|
|
478
459
|
tx.moveCall({
|
|
479
|
-
target:
|
|
460
|
+
target: repositoryFn("data_when_id_from_set_with_passport"),
|
|
480
461
|
arguments: [
|
|
481
|
-
|
|
482
|
-
|
|
462
|
+
toTxObject(tx, repository),
|
|
463
|
+
toTxString(tx, policy.name),
|
|
483
464
|
tx.pure.address(data.write_guard),
|
|
484
|
-
tx.pure.vector("u8", await
|
|
465
|
+
tx.pure.vector("u8", await valueToBcsBytes(policyValueType1, data.data)),
|
|
485
466
|
tx.object.clock(),
|
|
486
467
|
passport,
|
|
487
468
|
],
|
|
488
469
|
});
|
|
489
470
|
}
|
|
490
471
|
else {
|
|
491
|
-
|
|
472
|
+
W_ERROR(WErrors.InvalidParam, `Write guard ${data.write_guard} is not in policy ${policy.name}`);
|
|
492
473
|
}
|
|
493
474
|
}
|
|
494
475
|
else {
|
|
495
476
|
if (policy.write_guard.length === 0) {
|
|
496
|
-
const policyValueType2 =
|
|
477
|
+
const policyValueType2 = parseValueType(policy.value_type);
|
|
497
478
|
tx.moveCall({
|
|
498
|
-
target:
|
|
479
|
+
target: repositoryFn("data_when_id_from_set"),
|
|
499
480
|
arguments: [
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
tx.pure.vector("u8", await
|
|
481
|
+
toTxObject(tx, repository),
|
|
482
|
+
toTxString(tx, policy.name),
|
|
483
|
+
tx.pure.vector("u8", await valueToBcsBytes(policyValueType2, data.data)),
|
|
503
484
|
tx.object.clock(),
|
|
504
485
|
],
|
|
505
486
|
});
|
|
506
487
|
}
|
|
507
488
|
else {
|
|
508
|
-
|
|
489
|
+
W_ERROR(WErrors.InvalidParam, `specify write guard in policy ${policy.write_guard.map((guard) => guard.guard)}`);
|
|
509
490
|
}
|
|
510
491
|
}
|
|
511
492
|
}
|
|
512
|
-
function um_set(tx, repository, permission, um, passport) {
|
|
513
|
-
|
|
493
|
+
export function um_set(tx, repository, permission, um, passport) {
|
|
494
|
+
validObjects([repository, permission]);
|
|
514
495
|
if (um) {
|
|
515
496
|
if (passport) {
|
|
516
497
|
tx.moveCall({
|
|
517
|
-
target:
|
|
498
|
+
target: repositoryFn(`um_set_with_passport`),
|
|
518
499
|
arguments: [
|
|
519
|
-
|
|
520
|
-
|
|
500
|
+
toTxObject(tx, repository),
|
|
501
|
+
toTxObject(tx, permission),
|
|
521
502
|
passport,
|
|
522
|
-
|
|
503
|
+
toTxObject(tx, um),
|
|
523
504
|
tx.object.mutRegistrar(),
|
|
524
505
|
tx.object.clock(),
|
|
525
506
|
],
|
|
@@ -527,11 +508,11 @@ function um_set(tx, repository, permission, um, passport) {
|
|
|
527
508
|
}
|
|
528
509
|
else {
|
|
529
510
|
tx.moveCall({
|
|
530
|
-
target:
|
|
511
|
+
target: repositoryFn(`um_set`),
|
|
531
512
|
arguments: [
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
513
|
+
toTxObject(tx, repository),
|
|
514
|
+
toTxObject(tx, permission),
|
|
515
|
+
toTxObject(tx, um),
|
|
535
516
|
tx.object.mutRegistrar(),
|
|
536
517
|
tx.object.clock(),
|
|
537
518
|
],
|
|
@@ -541,10 +522,10 @@ function um_set(tx, repository, permission, um, passport) {
|
|
|
541
522
|
else {
|
|
542
523
|
if (passport) {
|
|
543
524
|
tx.moveCall({
|
|
544
|
-
target:
|
|
525
|
+
target: repositoryFn(`um_none_with_passport`),
|
|
545
526
|
arguments: [
|
|
546
|
-
|
|
547
|
-
|
|
527
|
+
toTxObject(tx, repository),
|
|
528
|
+
toTxObject(tx, permission),
|
|
548
529
|
passport,
|
|
549
530
|
tx.object.mutRegistrar(),
|
|
550
531
|
],
|
|
@@ -552,20 +533,20 @@ function um_set(tx, repository, permission, um, passport) {
|
|
|
552
533
|
}
|
|
553
534
|
else {
|
|
554
535
|
tx.moveCall({
|
|
555
|
-
target:
|
|
536
|
+
target: repositoryFn(`um_none`),
|
|
556
537
|
arguments: [
|
|
557
|
-
|
|
558
|
-
|
|
538
|
+
toTxObject(tx, repository),
|
|
539
|
+
toTxObject(tx, permission),
|
|
559
540
|
tx.object.mutRegistrar(),
|
|
560
541
|
],
|
|
561
542
|
});
|
|
562
543
|
}
|
|
563
544
|
}
|
|
564
545
|
}
|
|
565
|
-
async function data(tx, repository, policy, data, passport) {
|
|
566
|
-
|
|
567
|
-
if (policy.id_from !==
|
|
568
|
-
|
|
546
|
+
export async function data(tx, repository, policy, data, passport) {
|
|
547
|
+
validObjects([repository]);
|
|
548
|
+
if (policy.id_from !== IdFrom.None) {
|
|
549
|
+
W_ERROR(WErrors.InvalidParam, `id_from must be IdFrom.None when items is provided`);
|
|
569
550
|
}
|
|
570
551
|
// 优化分组逻辑
|
|
571
552
|
const noGuardItems = [];
|
|
@@ -579,7 +560,7 @@ async function data(tx, repository, policy, data, passport) {
|
|
|
579
560
|
noGuardItems.push(item);
|
|
580
561
|
}
|
|
581
562
|
else {
|
|
582
|
-
|
|
563
|
+
W_ERROR(WErrors.InvalidParam, `specify write guard in policy ${policy.write_guard.map((guard) => guard.guard)}`);
|
|
583
564
|
}
|
|
584
565
|
}
|
|
585
566
|
else {
|
|
@@ -587,7 +568,7 @@ async function data(tx, repository, policy, data, passport) {
|
|
|
587
568
|
// 查找policy中对应的guard设置
|
|
588
569
|
const policyGuard = policy.write_guard.find((g) => g.guard === guard);
|
|
589
570
|
if (!policyGuard) {
|
|
590
|
-
|
|
571
|
+
W_ERROR(WErrors.InvalidParam, `Guard ${guard} not found in policy ${policy.write_guard.map((guard) => guard.guard)}`);
|
|
591
572
|
}
|
|
592
573
|
// 检查guard是否有设置id_from_submission
|
|
593
574
|
const hasSubmissionSettings = policyGuard.id_from_submission !== undefined;
|
|
@@ -635,20 +616,20 @@ async function data(tx, repository, policy, data, passport) {
|
|
|
635
616
|
}
|
|
636
617
|
// 处理无guard组
|
|
637
618
|
if (noGuardItems.length > 0) {
|
|
638
|
-
const policyValueType3 =
|
|
619
|
+
const policyValueType3 = parseValueType(policy.value_type);
|
|
639
620
|
const ids = noGuardItems.flatMap((item) => item.data.map((keyData) => keyData.id));
|
|
640
621
|
const dataBytes = await Promise.all(noGuardItems
|
|
641
622
|
.flatMap((item) => item.data)
|
|
642
|
-
.map(async (keyData) => await
|
|
623
|
+
.map(async (keyData) => await valueToBcsBytes(policyValueType3, keyData.data)));
|
|
643
624
|
if (ids.length !== dataBytes.length) {
|
|
644
|
-
|
|
625
|
+
W_ERROR(WErrors.InvalidParam, `Id and data arrays must have the same length`);
|
|
645
626
|
}
|
|
646
627
|
//@ notice: 前面已将地址转换为了string
|
|
647
628
|
tx.moveCall({
|
|
648
|
-
target:
|
|
629
|
+
target: repositoryFn("id_data"),
|
|
649
630
|
arguments: [
|
|
650
|
-
|
|
651
|
-
|
|
631
|
+
toTxObject(tx, repository),
|
|
632
|
+
toTxString(tx, policy.name),
|
|
652
633
|
tx.pure.vector("address", ids),
|
|
653
634
|
tx.makeMoveVec({
|
|
654
635
|
elements: dataBytes.map((arr) => tx.pure.vector("u8", arr)),
|
|
@@ -660,75 +641,75 @@ async function data(tx, repository, policy, data, passport) {
|
|
|
660
641
|
// 处理有submission设置的guard组(合并成一个调用)
|
|
661
642
|
if (mixedItems.length > 0) {
|
|
662
643
|
if (!passport) {
|
|
663
|
-
|
|
644
|
+
W_ERROR(WErrors.InvalidParam, "Guard specified but no passport provided");
|
|
664
645
|
}
|
|
665
646
|
// 提取所有ids、data和guards
|
|
666
|
-
const policyValueType4 =
|
|
647
|
+
const policyValueType4 = parseValueType(policy.value_type);
|
|
667
648
|
const ids = mixedItems.map((item) => item.id);
|
|
668
|
-
const dataBytes = await Promise.all(mixedItems.map(async (item) => await
|
|
649
|
+
const dataBytes = await Promise.all(mixedItems.map(async (item) => await valueToBcsBytes(policyValueType4, item.data)));
|
|
669
650
|
const guards = mixedItems.map((item) => item.guard);
|
|
670
651
|
if (ids.length !== dataBytes.length || ids.length !== guards.length) {
|
|
671
|
-
|
|
652
|
+
W_ERROR(WErrors.InvalidParam, `Id, data, and guard arrays must have the same length`);
|
|
672
653
|
}
|
|
673
654
|
// 调用id_data_mixed_with_passport
|
|
674
655
|
tx.moveCall({
|
|
675
|
-
target:
|
|
656
|
+
target: repositoryFn("id_data_mixed_with_passport"),
|
|
676
657
|
arguments: [
|
|
677
|
-
|
|
678
|
-
|
|
658
|
+
toTxObject(tx, repository),
|
|
659
|
+
toTxString(tx, policy.name),
|
|
679
660
|
tx.pure.vector("address", guards),
|
|
680
661
|
tx.pure.vector("address", ids),
|
|
681
662
|
tx.makeMoveVec({
|
|
682
663
|
elements: dataBytes.map((arr) => tx.pure.vector("u8", arr)),
|
|
683
664
|
type: "vector<u8>",
|
|
684
665
|
}),
|
|
685
|
-
|
|
666
|
+
toTxObject(tx, passport),
|
|
686
667
|
],
|
|
687
668
|
});
|
|
688
669
|
}
|
|
689
670
|
// 处理无submission设置的guard组(每个guard单独调用)
|
|
690
671
|
for (const { guard, items } of regularGuards) {
|
|
691
672
|
if (!passport) {
|
|
692
|
-
|
|
673
|
+
W_ERROR(WErrors.InvalidParam, "Guard specified but no passport provided");
|
|
693
674
|
}
|
|
694
|
-
const policyValueType5 =
|
|
675
|
+
const policyValueType5 = parseValueType(policy.value_type);
|
|
695
676
|
const keyDataItems = items.flatMap((item) => item.data);
|
|
696
677
|
const ids = keyDataItems.map((keyData) => keyData.id);
|
|
697
|
-
const dataBytes = await Promise.all(keyDataItems.map(async (keyData) => await
|
|
678
|
+
const dataBytes = await Promise.all(keyDataItems.map(async (keyData) => await valueToBcsBytes(policyValueType5, keyData.data)));
|
|
698
679
|
if (ids.length !== dataBytes.length) {
|
|
699
|
-
|
|
680
|
+
W_ERROR(WErrors.InvalidParam, `Id and data arrays must have the same length for guard ${guard}`);
|
|
700
681
|
}
|
|
701
682
|
// 调用id_data_with_passport
|
|
702
683
|
tx.moveCall({
|
|
703
|
-
target:
|
|
684
|
+
target: repositoryFn("id_data_with_passport"),
|
|
704
685
|
arguments: [
|
|
705
|
-
|
|
706
|
-
|
|
686
|
+
toTxObject(tx, repository),
|
|
687
|
+
toTxString(tx, policy.name),
|
|
707
688
|
tx.pure.address(guard),
|
|
708
689
|
tx.pure.vector("address", ids),
|
|
709
690
|
tx.makeMoveVec({
|
|
710
691
|
elements: dataBytes.map((arr) => tx.pure.vector("u8", arr)),
|
|
711
692
|
type: "vector<u8>",
|
|
712
693
|
}),
|
|
713
|
-
|
|
694
|
+
toTxObject(tx, passport),
|
|
714
695
|
],
|
|
715
696
|
});
|
|
716
697
|
}
|
|
717
698
|
}
|
|
718
699
|
// ================================================
|
|
719
700
|
// 构造函数和设置函数
|
|
720
|
-
function newRepository(tx, permission, description, passport) {
|
|
721
|
-
|
|
722
|
-
if (typeof description === "string" && !
|
|
723
|
-
|
|
701
|
+
export function newRepository(tx, permission, description, passport) {
|
|
702
|
+
validObjects([permission, passport]);
|
|
703
|
+
if (typeof description === "string" && !isValidDescription(description)) {
|
|
704
|
+
W_ERROR(WErrors.IsValidDescription, `Description exceeds maximum length ${MAX_DESCRIPTION_LENGTH}`);
|
|
724
705
|
}
|
|
725
706
|
if (passport) {
|
|
726
707
|
return tx.moveCall({
|
|
727
|
-
target:
|
|
708
|
+
target: repositoryFn("new_with_passport"),
|
|
728
709
|
arguments: [
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
710
|
+
toTxObject(tx, permission),
|
|
711
|
+
toTxObject(tx, passport),
|
|
712
|
+
toTxString(tx, description),
|
|
732
713
|
tx.object.mutRegistrar(),
|
|
733
714
|
tx.object.clock(),
|
|
734
715
|
],
|
|
@@ -736,58 +717,58 @@ function newRepository(tx, permission, description, passport) {
|
|
|
736
717
|
}
|
|
737
718
|
else {
|
|
738
719
|
return tx.moveCall({
|
|
739
|
-
target:
|
|
720
|
+
target: repositoryFn("new"),
|
|
740
721
|
arguments: [
|
|
741
|
-
|
|
742
|
-
|
|
722
|
+
toTxObject(tx, permission),
|
|
723
|
+
toTxString(tx, description),
|
|
743
724
|
tx.object.mutRegistrar(),
|
|
744
725
|
tx.object.clock(),
|
|
745
726
|
],
|
|
746
727
|
});
|
|
747
728
|
}
|
|
748
729
|
}
|
|
749
|
-
function description_set(tx, repository, permission, description, passport) {
|
|
750
|
-
|
|
751
|
-
if (typeof description === "string" && !
|
|
752
|
-
|
|
730
|
+
export function description_set(tx, repository, permission, description, passport) {
|
|
731
|
+
validObjects([repository, permission, passport]);
|
|
732
|
+
if (typeof description === "string" && !isValidDescription(description)) {
|
|
733
|
+
W_ERROR(WErrors.IsValidDescription, `Description exceeds maximum length ${MAX_DESCRIPTION_LENGTH}`);
|
|
753
734
|
}
|
|
754
735
|
if (passport) {
|
|
755
736
|
tx.moveCall({
|
|
756
|
-
target:
|
|
737
|
+
target: repositoryFn("description_set_with_passport"),
|
|
757
738
|
arguments: [
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
739
|
+
toTxObject(tx, repository),
|
|
740
|
+
toTxObject(tx, permission),
|
|
741
|
+
toTxObject(tx, passport),
|
|
742
|
+
toTxString(tx, description),
|
|
762
743
|
],
|
|
763
744
|
});
|
|
764
745
|
}
|
|
765
746
|
else {
|
|
766
747
|
tx.moveCall({
|
|
767
|
-
target:
|
|
748
|
+
target: repositoryFn("description_set"),
|
|
768
749
|
arguments: [
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
750
|
+
toTxObject(tx, repository),
|
|
751
|
+
toTxObject(tx, permission),
|
|
752
|
+
toTxString(tx, description),
|
|
772
753
|
],
|
|
773
754
|
});
|
|
774
755
|
}
|
|
775
756
|
}
|
|
776
|
-
function policy_add(tx, repository, permission, policies, passport) {
|
|
757
|
+
export function policy_add(tx, repository, permission, policies, passport) {
|
|
777
758
|
if (policies.length === 0) {
|
|
778
759
|
return;
|
|
779
760
|
}
|
|
780
|
-
|
|
761
|
+
validObjects([repository, permission, passport]);
|
|
781
762
|
if (passport) {
|
|
782
763
|
tx.moveCall({
|
|
783
|
-
target:
|
|
764
|
+
target: repositoryFn("policy_add_with_passport"),
|
|
784
765
|
arguments: [
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
766
|
+
toTxObject(tx, repository),
|
|
767
|
+
toTxObject(tx, permission),
|
|
768
|
+
toTxObject(tx, passport),
|
|
788
769
|
tx.makeMoveVec({
|
|
789
770
|
elements: policies.map((p) => policy(tx, p)),
|
|
790
|
-
type: `${
|
|
771
|
+
type: `${PackageAddress}::repository::PolicyRule`,
|
|
791
772
|
}),
|
|
792
773
|
tx.object.mutRegistrar(),
|
|
793
774
|
tx.object.clock(),
|
|
@@ -796,13 +777,13 @@ function policy_add(tx, repository, permission, policies, passport) {
|
|
|
796
777
|
}
|
|
797
778
|
else {
|
|
798
779
|
tx.moveCall({
|
|
799
|
-
target:
|
|
780
|
+
target: repositoryFn("policy_add"),
|
|
800
781
|
arguments: [
|
|
801
|
-
|
|
802
|
-
|
|
782
|
+
toTxObject(tx, repository),
|
|
783
|
+
toTxObject(tx, permission),
|
|
803
784
|
tx.makeMoveVec({
|
|
804
785
|
elements: policies.map((p) => policy(tx, p)),
|
|
805
|
-
type: `${
|
|
786
|
+
type: `${PackageAddress}::repository::PolicyRule`,
|
|
806
787
|
}),
|
|
807
788
|
tx.object.mutRegistrar(),
|
|
808
789
|
tx.object.clock(),
|
|
@@ -810,18 +791,18 @@ function policy_add(tx, repository, permission, policies, passport) {
|
|
|
810
791
|
});
|
|
811
792
|
}
|
|
812
793
|
}
|
|
813
|
-
function policy_set(tx, repository, permission, policies, passport) {
|
|
814
|
-
|
|
794
|
+
export function policy_set(tx, repository, permission, policies, passport) {
|
|
795
|
+
validObjects([repository, permission, passport]);
|
|
815
796
|
if (passport) {
|
|
816
797
|
tx.moveCall({
|
|
817
|
-
target:
|
|
798
|
+
target: repositoryFn("policy_set_with_passport"),
|
|
818
799
|
arguments: [
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
800
|
+
toTxObject(tx, repository),
|
|
801
|
+
toTxObject(tx, permission),
|
|
802
|
+
toTxObject(tx, passport),
|
|
822
803
|
tx.makeMoveVec({
|
|
823
804
|
elements: policies.map((p) => policy(tx, p)),
|
|
824
|
-
type: `${
|
|
805
|
+
type: `${PackageAddress}::repository::PolicyRule`,
|
|
825
806
|
}),
|
|
826
807
|
tx.object.mutRegistrar(),
|
|
827
808
|
tx.object.clock(),
|
|
@@ -830,13 +811,13 @@ function policy_set(tx, repository, permission, policies, passport) {
|
|
|
830
811
|
}
|
|
831
812
|
else {
|
|
832
813
|
tx.moveCall({
|
|
833
|
-
target:
|
|
814
|
+
target: repositoryFn("policy_set"),
|
|
834
815
|
arguments: [
|
|
835
|
-
|
|
836
|
-
|
|
816
|
+
toTxObject(tx, repository),
|
|
817
|
+
toTxObject(tx, permission),
|
|
837
818
|
tx.makeMoveVec({
|
|
838
819
|
elements: policies.map((p) => policy(tx, p)),
|
|
839
|
-
type: `${
|
|
820
|
+
type: `${PackageAddress}::repository::PolicyRule`,
|
|
840
821
|
}),
|
|
841
822
|
tx.object.mutRegistrar(),
|
|
842
823
|
tx.object.clock(),
|
|
@@ -844,18 +825,18 @@ function policy_set(tx, repository, permission, policies, passport) {
|
|
|
844
825
|
});
|
|
845
826
|
}
|
|
846
827
|
}
|
|
847
|
-
function policy_remove(tx, repository, permission, policies, passport) {
|
|
828
|
+
export function policy_remove(tx, repository, permission, policies, passport) {
|
|
848
829
|
if (policies.length === 0) {
|
|
849
830
|
return;
|
|
850
831
|
}
|
|
851
|
-
|
|
832
|
+
validObjects([repository, permission, passport]);
|
|
852
833
|
if (passport) {
|
|
853
834
|
tx.moveCall({
|
|
854
|
-
target:
|
|
835
|
+
target: repositoryFn("policy_remove_with_passport"),
|
|
855
836
|
arguments: [
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
837
|
+
toTxObject(tx, repository),
|
|
838
|
+
toTxObject(tx, permission),
|
|
839
|
+
toTxObject(tx, passport),
|
|
859
840
|
tx.pure.vector("string", policies),
|
|
860
841
|
tx.object.mutRegistrar(),
|
|
861
842
|
],
|
|
@@ -863,47 +844,47 @@ function policy_remove(tx, repository, permission, policies, passport) {
|
|
|
863
844
|
}
|
|
864
845
|
else {
|
|
865
846
|
tx.moveCall({
|
|
866
|
-
target:
|
|
847
|
+
target: repositoryFn("policy_remove"),
|
|
867
848
|
arguments: [
|
|
868
|
-
|
|
869
|
-
|
|
849
|
+
toTxObject(tx, repository),
|
|
850
|
+
toTxObject(tx, permission),
|
|
870
851
|
tx.pure.vector("string", policies),
|
|
871
852
|
tx.object.mutRegistrar(),
|
|
872
853
|
],
|
|
873
854
|
});
|
|
874
855
|
}
|
|
875
856
|
}
|
|
876
|
-
function policy_clear(tx, repository, permission, passport) {
|
|
877
|
-
|
|
857
|
+
export function policy_clear(tx, repository, permission, passport) {
|
|
858
|
+
validObjects([repository, permission, passport]);
|
|
878
859
|
if (passport) {
|
|
879
860
|
tx.moveCall({
|
|
880
|
-
target:
|
|
861
|
+
target: repositoryFn("policy_clear_with_passport"),
|
|
881
862
|
arguments: [
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
863
|
+
toTxObject(tx, repository),
|
|
864
|
+
toTxObject(tx, permission),
|
|
865
|
+
toTxObject(tx, passport),
|
|
885
866
|
],
|
|
886
867
|
});
|
|
887
868
|
}
|
|
888
869
|
else {
|
|
889
870
|
tx.moveCall({
|
|
890
|
-
target:
|
|
891
|
-
arguments: [
|
|
871
|
+
target: repositoryFn("policy_clear"),
|
|
872
|
+
arguments: [toTxObject(tx, repository), toTxObject(tx, permission)],
|
|
892
873
|
});
|
|
893
874
|
}
|
|
894
875
|
}
|
|
895
|
-
function reward_add(tx, repository, permission, reward, reward_type, passport) {
|
|
896
|
-
|
|
897
|
-
if (!
|
|
898
|
-
|
|
876
|
+
export function reward_add(tx, repository, permission, reward, reward_type, passport) {
|
|
877
|
+
validObjects([repository, permission, passport, reward]);
|
|
878
|
+
if (!IsValidArgType(reward_type)) {
|
|
879
|
+
W_ERROR(WErrors.IsValidArgType, `Reward type ${reward_type} is not valid`);
|
|
899
880
|
}
|
|
900
881
|
if (passport) {
|
|
901
882
|
tx.moveCall({
|
|
902
|
-
target:
|
|
883
|
+
target: repositoryFn("reward_add_with_passport"),
|
|
903
884
|
arguments: [
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
885
|
+
toTxObject(tx, repository),
|
|
886
|
+
toTxObject(tx, permission),
|
|
887
|
+
toTxObject(tx, passport),
|
|
907
888
|
tx.object(reward),
|
|
908
889
|
],
|
|
909
890
|
typeArguments: [reward_type],
|
|
@@ -911,68 +892,68 @@ function reward_add(tx, repository, permission, reward, reward_type, passport) {
|
|
|
911
892
|
}
|
|
912
893
|
else {
|
|
913
894
|
tx.moveCall({
|
|
914
|
-
target:
|
|
895
|
+
target: repositoryFn("reward_add"),
|
|
915
896
|
arguments: [
|
|
916
|
-
|
|
917
|
-
|
|
897
|
+
toTxObject(tx, repository),
|
|
898
|
+
toTxObject(tx, permission),
|
|
918
899
|
tx.object(reward),
|
|
919
900
|
],
|
|
920
901
|
typeArguments: [reward_type],
|
|
921
902
|
});
|
|
922
903
|
}
|
|
923
904
|
}
|
|
924
|
-
function reward_remove(tx, repository, permission, rewards, passport) {
|
|
905
|
+
export function reward_remove(tx, repository, permission, rewards, passport) {
|
|
925
906
|
if (rewards.length === 0) {
|
|
926
907
|
return;
|
|
927
908
|
}
|
|
928
|
-
|
|
909
|
+
validObjects([repository, permission, passport, ...rewards]);
|
|
929
910
|
if (passport) {
|
|
930
911
|
tx.moveCall({
|
|
931
|
-
target:
|
|
912
|
+
target: repositoryFn("reward_remove_with_passport"),
|
|
932
913
|
arguments: [
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
914
|
+
toTxObject(tx, repository),
|
|
915
|
+
toTxObject(tx, permission),
|
|
916
|
+
toTxObject(tx, passport),
|
|
936
917
|
tx.pure.vector("address", rewards),
|
|
937
918
|
],
|
|
938
919
|
});
|
|
939
920
|
}
|
|
940
921
|
else {
|
|
941
922
|
tx.moveCall({
|
|
942
|
-
target:
|
|
923
|
+
target: repositoryFn("reward_remove"),
|
|
943
924
|
arguments: [
|
|
944
|
-
|
|
945
|
-
|
|
925
|
+
toTxObject(tx, repository),
|
|
926
|
+
toTxObject(tx, permission),
|
|
946
927
|
tx.pure.vector("address", rewards),
|
|
947
928
|
],
|
|
948
929
|
});
|
|
949
930
|
}
|
|
950
931
|
}
|
|
951
|
-
function reward_clear(tx, repository, permission, passport) {
|
|
952
|
-
|
|
932
|
+
export function reward_clear(tx, repository, permission, passport) {
|
|
933
|
+
validObjects([repository, permission, passport]);
|
|
953
934
|
if (passport) {
|
|
954
935
|
tx.moveCall({
|
|
955
|
-
target:
|
|
936
|
+
target: repositoryFn("reward_clear_with_passport"),
|
|
956
937
|
arguments: [
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
938
|
+
toTxObject(tx, repository),
|
|
939
|
+
toTxObject(tx, permission),
|
|
940
|
+
toTxObject(tx, passport),
|
|
960
941
|
],
|
|
961
942
|
});
|
|
962
943
|
}
|
|
963
944
|
else {
|
|
964
945
|
tx.moveCall({
|
|
965
|
-
target:
|
|
966
|
-
arguments: [
|
|
946
|
+
target: repositoryFn("reward_clear"),
|
|
947
|
+
arguments: [toTxObject(tx, repository), toTxObject(tx, permission)],
|
|
967
948
|
});
|
|
968
949
|
}
|
|
969
950
|
}
|
|
970
|
-
async function data_remove(tx, repository, policy, param, passport) {
|
|
971
|
-
|
|
951
|
+
export async function data_remove(tx, repository, policy, param, passport) {
|
|
952
|
+
validObjects([repository]);
|
|
972
953
|
// 检查参数类型
|
|
973
954
|
if ("items" in param) {
|
|
974
|
-
if (policy.id_from !==
|
|
975
|
-
|
|
955
|
+
if (policy.id_from !== IdFrom.None) {
|
|
956
|
+
W_ERROR(WErrors.InvalidParam, `id_from must be IdFrom.None when items is provided`);
|
|
976
957
|
}
|
|
977
958
|
// 优化分组逻辑
|
|
978
959
|
const noGuardItems = [];
|
|
@@ -986,7 +967,7 @@ async function data_remove(tx, repository, policy, param, passport) {
|
|
|
986
967
|
noGuardItems.push(...item.id);
|
|
987
968
|
}
|
|
988
969
|
else {
|
|
989
|
-
|
|
970
|
+
W_ERROR(WErrors.InvalidParam, `specify write guard in policy ${policy.write_guard.map((guard) => guard.guard)}`);
|
|
990
971
|
}
|
|
991
972
|
}
|
|
992
973
|
else {
|
|
@@ -994,7 +975,7 @@ async function data_remove(tx, repository, policy, param, passport) {
|
|
|
994
975
|
// 查找policy中对应的guard设置
|
|
995
976
|
const policyGuard = policy.write_guard.find((g) => g.guard === guard);
|
|
996
977
|
if (!policyGuard) {
|
|
997
|
-
|
|
978
|
+
W_ERROR(WErrors.InvalidParam, `Guard ${guard} not found in policy ${policy.write_guard.map((guard) => guard.guard)}`);
|
|
998
979
|
}
|
|
999
980
|
// 检查guard是否有设置id_from_submission
|
|
1000
981
|
const hasSubmissionSettings = policyGuard.id_from_submission !== undefined;
|
|
@@ -1020,16 +1001,16 @@ async function data_remove(tx, repository, policy, param, passport) {
|
|
|
1020
1001
|
// 处理无guard组
|
|
1021
1002
|
if (noGuardItems.length > 0) {
|
|
1022
1003
|
if (policy.write_guard.length !== 0) {
|
|
1023
|
-
|
|
1004
|
+
W_ERROR(WErrors.InvalidParam, `specify write guard in policy ${policy.write_guard.map((guard) => guard.guard)}`);
|
|
1024
1005
|
}
|
|
1025
1006
|
// 去重处理
|
|
1026
1007
|
const uniqueIds = [...new Set(noGuardItems)];
|
|
1027
1008
|
// 调用id_data_remove
|
|
1028
1009
|
tx.moveCall({
|
|
1029
|
-
target:
|
|
1010
|
+
target: repositoryFn("id_data_remove"),
|
|
1030
1011
|
arguments: [
|
|
1031
|
-
|
|
1032
|
-
|
|
1012
|
+
toTxObject(tx, repository),
|
|
1013
|
+
toTxString(tx, policy.name),
|
|
1033
1014
|
tx.pure.vector("address", uniqueIds),
|
|
1034
1015
|
],
|
|
1035
1016
|
});
|
|
@@ -1037,17 +1018,17 @@ async function data_remove(tx, repository, policy, param, passport) {
|
|
|
1037
1018
|
// 处理有submission设置的guard组(合并成一个调用)
|
|
1038
1019
|
if (mixedItems.length > 0) {
|
|
1039
1020
|
if (!passport) {
|
|
1040
|
-
|
|
1021
|
+
W_ERROR(WErrors.InvalidParam, "Guard specified but no passport provided");
|
|
1041
1022
|
}
|
|
1042
1023
|
const uniqueIds = [...new Set(mixedItems)];
|
|
1043
1024
|
// 调用id_data_mixed_with_passport
|
|
1044
1025
|
tx.moveCall({
|
|
1045
|
-
target:
|
|
1026
|
+
target: repositoryFn("id_data_mixed_remove_with_passport"),
|
|
1046
1027
|
arguments: [
|
|
1047
|
-
|
|
1048
|
-
|
|
1028
|
+
toTxObject(tx, repository),
|
|
1029
|
+
toTxString(tx, policy.name),
|
|
1049
1030
|
tx.pure.vector("address", uniqueIds),
|
|
1050
|
-
|
|
1031
|
+
toTxObject(tx, passport),
|
|
1051
1032
|
],
|
|
1052
1033
|
});
|
|
1053
1034
|
}
|
|
@@ -1056,13 +1037,13 @@ async function data_remove(tx, repository, policy, param, passport) {
|
|
|
1056
1037
|
const uniqueIds = [...new Set(id)];
|
|
1057
1038
|
// 调用id_data_with_passport
|
|
1058
1039
|
tx.moveCall({
|
|
1059
|
-
target:
|
|
1040
|
+
target: repositoryFn("id_data_remove_with_passport"),
|
|
1060
1041
|
arguments: [
|
|
1061
|
-
|
|
1062
|
-
|
|
1042
|
+
toTxObject(tx, repository),
|
|
1043
|
+
toTxString(tx, policy.name),
|
|
1063
1044
|
tx.pure.address(guard),
|
|
1064
1045
|
tx.pure.vector("address", uniqueIds),
|
|
1065
|
-
|
|
1046
|
+
toTxObject(tx, passport),
|
|
1066
1047
|
],
|
|
1067
1048
|
});
|
|
1068
1049
|
}
|
|
@@ -1070,39 +1051,39 @@ async function data_remove(tx, repository, policy, param, passport) {
|
|
|
1070
1051
|
else {
|
|
1071
1052
|
const guard = param.write_guard;
|
|
1072
1053
|
// RepIdData类型
|
|
1073
|
-
if (policy.id_from ===
|
|
1074
|
-
|
|
1054
|
+
if (policy.id_from === IdFrom.None) {
|
|
1055
|
+
W_ERROR(WErrors.InvalidParam, `id_from must be set when id_from is IdFrom.None`);
|
|
1075
1056
|
}
|
|
1076
1057
|
if (guard) {
|
|
1077
1058
|
if (policy.write_guard.find((g) => g.guard === guard)) {
|
|
1078
1059
|
tx.moveCall({
|
|
1079
|
-
target:
|
|
1060
|
+
target: repositoryFn("data_remove_when_id_from_set_with_passport"),
|
|
1080
1061
|
arguments: [
|
|
1081
|
-
|
|
1082
|
-
|
|
1062
|
+
toTxObject(tx, repository),
|
|
1063
|
+
toTxString(tx, policy.name),
|
|
1083
1064
|
tx.pure.address(guard),
|
|
1084
1065
|
tx.object.clock(),
|
|
1085
|
-
|
|
1066
|
+
toTxObject(tx, passport),
|
|
1086
1067
|
],
|
|
1087
1068
|
});
|
|
1088
1069
|
}
|
|
1089
1070
|
else {
|
|
1090
|
-
|
|
1071
|
+
W_ERROR(WErrors.InvalidParam, `Write guard ${guard} is not in policy ${policy.write_guard.map((guard) => guard.guard)}`);
|
|
1091
1072
|
}
|
|
1092
1073
|
}
|
|
1093
1074
|
else {
|
|
1094
1075
|
if (policy.write_guard.length === 0) {
|
|
1095
1076
|
tx.moveCall({
|
|
1096
|
-
target:
|
|
1077
|
+
target: repositoryFn("data_remove_when_id_from_set"),
|
|
1097
1078
|
arguments: [
|
|
1098
|
-
|
|
1099
|
-
|
|
1079
|
+
toTxObject(tx, repository),
|
|
1080
|
+
toTxString(tx, policy.name),
|
|
1100
1081
|
tx.object.clock(),
|
|
1101
1082
|
],
|
|
1102
1083
|
});
|
|
1103
1084
|
}
|
|
1104
1085
|
else {
|
|
1105
|
-
|
|
1086
|
+
W_ERROR(WErrors.InvalidParam, `specify write guard in policy ${policy.write_guard.map((guard) => guard.guard)}`);
|
|
1106
1087
|
}
|
|
1107
1088
|
}
|
|
1108
1089
|
}
|