wowok 2.1.40 → 2.1.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/bcs/bcs.js +1 -253
- package/dist/cjs/bcs/effects.js +1 -199
- package/dist/cjs/bcs/index.js +1 -51
- package/dist/cjs/bcs/pure.js +1 -36
- package/dist/cjs/bcs/type-tag-serializer.js +1 -104
- package/dist/cjs/bcs/types.js +1 -3
- package/dist/cjs/client/index.js +1 -4
- package/dist/cjs/client/network.js +1 -15
- package/dist/cjs/cryptography/index.js +1 -6
- package/dist/cjs/cryptography/intent.js +1 -14
- package/dist/cjs/cryptography/keypair.js +1 -74
- package/dist/cjs/cryptography/mnemonics.js +1 -20
- package/dist/cjs/cryptography/publickey.js +1 -80
- package/dist/cjs/cryptography/signature-scheme.js +1 -22
- package/dist/cjs/cryptography/signature.js +1 -41
- package/dist/cjs/experimental/cache.js +1 -58
- package/dist/cjs/experimental/client.js +1 -19
- package/dist/cjs/experimental/core.js +1 -80
- package/dist/cjs/experimental/errors.js +1 -24
- package/dist/cjs/experimental/index.js +1 -5
- package/dist/cjs/experimental/persistent-storage.js +1 -220
- package/dist/cjs/experimental/persistent-storage.test.js +1 -144
- package/dist/cjs/experimental/transports/utils.js +1 -96
- package/dist/cjs/experimental/types.js +1 -1
- package/dist/cjs/faucet/faucet.js +1 -99
- package/dist/cjs/faucet/index.js +1 -1
- package/dist/cjs/grpc/client.js +1 -42
- package/dist/cjs/grpc/core.js +1 -587
- package/dist/cjs/grpc/index.js +1 -2
- package/dist/cjs/grpc/proto/google/protobuf/any.js +1 -106
- package/dist/cjs/grpc/proto/google/protobuf/duration.js +1 -58
- package/dist/cjs/grpc/proto/google/protobuf/empty.js +1 -7
- package/dist/cjs/grpc/proto/google/protobuf/field_mask.js +1 -47
- package/dist/cjs/grpc/proto/google/protobuf/struct.js +1 -191
- package/dist/cjs/grpc/proto/google/protobuf/timestamp.js +1 -91
- package/dist/cjs/grpc/proto/google/rpc/error_details.js +1 -265
- package/dist/cjs/grpc/proto/google/rpc/status.js +1 -23
- package/dist/cjs/grpc/proto/sui/rpc/v2/argument.js +1 -46
- package/dist/cjs/grpc/proto/sui/rpc/v2/balance_change.js +1 -29
- package/dist/cjs/grpc/proto/sui/rpc/v2/bcs.js +1 -22
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint.js +1 -54
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_contents.js +1 -60
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_summary.js +1 -144
- package/dist/cjs/grpc/proto/sui/rpc/v2/effects.js +1 -271
- package/dist/cjs/grpc/proto/sui/rpc/v2/epoch.js +1 -64
- package/dist/cjs/grpc/proto/sui/rpc/v2/error_reason.js +1 -6
- package/dist/cjs/grpc/proto/sui/rpc/v2/event.js +1 -62
- package/dist/cjs/grpc/proto/sui/rpc/v2/executed_transaction.js +1 -64
- package/dist/cjs/grpc/proto/sui/rpc/v2/execution_status.js +1 -481
- package/dist/cjs/grpc/proto/sui/rpc/v2/gas_cost_summary.js +1 -40
- package/dist/cjs/grpc/proto/sui/rpc/v2/input.js +1 -61
- package/dist/cjs/grpc/proto/sui/rpc/v2/jwk.js +1 -57
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.client.js +1 -39
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.js +1 -329
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package.js +1 -447
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.client.js +1 -27
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.js +1 -206
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.client.js +1 -19
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.js +1 -109
- package/dist/cjs/grpc/proto/sui/rpc/v2/object.js +1 -90
- package/dist/cjs/grpc/proto/sui/rpc/v2/object_reference.js +1 -30
- package/dist/cjs/grpc/proto/sui/rpc/v2/owner.js +1 -39
- package/dist/cjs/grpc/proto/sui/rpc/v2/protocol_config.js +1 -30
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature.js +1 -501
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_scheme.js +1 -10
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.client.js +1 -15
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.js +1 -62
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.client.js +1 -31
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.js +1 -504
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.client.js +1 -15
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.js +1 -37
- package/dist/cjs/grpc/proto/sui/rpc/v2/system_state.js +1 -709
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction.js +1 -950
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.client.js +1 -19
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.js +1 -144
- package/dist/cjs/index.js +1 -22
- package/dist/cjs/jsonRpc/client.js +1 -516
- package/dist/cjs/jsonRpc/core.js +1 -587
- package/dist/cjs/jsonRpc/errors.js +1 -38
- package/dist/cjs/jsonRpc/http-transport.js +1 -70
- package/dist/cjs/jsonRpc/index.js +1 -3
- package/dist/cjs/jsonRpc/json-rpc-resolver.js +1 -296
- package/dist/cjs/jsonRpc/rpc-websocket-client.js +1 -155
- package/dist/cjs/jsonRpc/types/chain.js +1 -1
- package/dist/cjs/jsonRpc/types/changes.js +1 -1
- package/dist/cjs/jsonRpc/types/coins.js +1 -1
- package/dist/cjs/jsonRpc/types/common.js +1 -1
- package/dist/cjs/jsonRpc/types/generated.js +1 -1
- package/dist/cjs/jsonRpc/types/index.js +1 -1
- package/dist/cjs/jsonRpc/types/params.js +1 -1
- package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js +1 -58
- package/dist/cjs/keypairs/ed25519/index.js +1 -2
- package/dist/cjs/keypairs/ed25519/keypair.js +1 -90
- package/dist/cjs/keypairs/ed25519/publickey.js +1 -50
- package/dist/cjs/keypairs/index.js +1 -4
- package/dist/cjs/keypairs/passkey/index.js +1 -2
- package/dist/cjs/keypairs/passkey/keypair.js +1 -155
- package/dist/cjs/keypairs/passkey/publickey.js +1 -117
- package/dist/cjs/keypairs/passkey/types.js +1 -1
- package/dist/cjs/keypairs/secp256k1/index.js +1 -2
- package/dist/cjs/keypairs/secp256k1/keypair.js +1 -82
- package/dist/cjs/keypairs/secp256k1/publickey.js +1 -51
- package/dist/cjs/keypairs/secp256r1/index.js +1 -2
- package/dist/cjs/keypairs/secp256r1/keypair.js +1 -78
- package/dist/cjs/keypairs/secp256r1/publickey.js +1 -52
- package/dist/cjs/multisig/index.js +1 -2
- package/dist/cjs/multisig/publickey.js +1 -201
- package/dist/cjs/multisig/signer.js +1 -58
- package/dist/cjs/transactions/Arguments.js +1 -9
- package/dist/cjs/transactions/Commands.js +1 -102
- package/dist/cjs/transactions/Inputs.js +1 -52
- package/dist/cjs/transactions/ObjectCache.js +1 -205
- package/dist/cjs/transactions/Transaction.js +1 -574
- package/dist/cjs/transactions/TransactionData.js +1 -409
- package/dist/cjs/transactions/__tests__/Transaction.test.js +1 -160
- package/dist/cjs/transactions/__tests__/bcs.test.js +1 -182
- package/dist/cjs/transactions/data/internal.js +1 -169
- package/dist/cjs/transactions/data/v1.js +1 -469
- package/dist/cjs/transactions/data/v2.js +1 -97
- package/dist/cjs/transactions/executor/caching.js +1 -65
- package/dist/cjs/transactions/executor/parallel.js +1 -347
- package/dist/cjs/transactions/executor/queue.js +1 -59
- package/dist/cjs/transactions/executor/serial.js +1 -99
- package/dist/cjs/transactions/hash.js +1 -8
- package/dist/cjs/transactions/index.js +1 -12
- package/dist/cjs/transactions/intents/CoinWithBalance.js +1 -145
- package/dist/cjs/transactions/object.js +1 -87
- package/dist/cjs/transactions/plugins/NamedPackagesPlugin.js +1 -11
- package/dist/cjs/transactions/pure.js +1 -36
- package/dist/cjs/transactions/resolve.js +1 -69
- package/dist/cjs/transactions/serializer.js +1 -167
- package/dist/cjs/transactions/utils.js +1 -121
- package/dist/cjs/utils/constants.js +1 -18
- package/dist/cjs/utils/derived-objects.js +1 -8
- package/dist/cjs/utils/dynamic-fields.js +1 -17
- package/dist/cjs/utils/format.js +1 -11
- package/dist/cjs/utils/index.js +1 -8
- package/dist/cjs/utils/move-registry.js +1 -24
- package/dist/cjs/utils/sui-types.js +1 -66
- package/dist/cjs/utils/suins.js +1 -33
- package/dist/cjs/verify/index.js +1 -1
- package/dist/cjs/verify/verify.js +1 -87
- package/dist/cjs/version.js +1 -2
- package/dist/cjs/w/call/allocation.js +1 -345
- package/dist/cjs/w/call/arb.js +1 -103
- package/dist/cjs/w/call/arbitration.js +1 -1192
- package/dist/cjs/w/call/base.js +1 -293
- package/dist/cjs/w/call/contact.js +1 -345
- package/dist/cjs/w/call/demand.js +1 -681
- package/dist/cjs/w/call/entity.js +1 -173
- package/dist/cjs/w/call/guard-ins.js +1 -4449
- package/dist/cjs/w/call/guard.d.ts +111 -0
- package/dist/cjs/w/call/guard.js +1 -1048
- package/dist/cjs/w/call/index.js +1 -22
- package/dist/cjs/w/call/machine.js +1 -1127
- package/dist/cjs/w/call/order.js +1 -337
- package/dist/cjs/w/call/passport.js +1 -220
- package/dist/cjs/w/call/payment.js +1 -178
- package/dist/cjs/w/call/permission.js +1 -1162
- package/dist/cjs/w/call/personal.js +1 -139
- package/dist/cjs/w/call/progress.js +1 -678
- package/dist/cjs/w/call/proof.js +1 -66
- package/dist/cjs/w/call/repository.js +1 -1024
- package/dist/cjs/w/call/resource.js +1 -108
- package/dist/cjs/w/call/reward.js +1 -675
- package/dist/cjs/w/call/service.js +1 -1960
- package/dist/cjs/w/call/treasury.js +1 -873
- package/dist/cjs/w/call/util.d.ts +1 -0
- package/dist/cjs/w/call/util.js +1 -566
- package/dist/cjs/w/common.js +1 -571
- package/dist/cjs/w/exception.js +1 -618
- package/dist/cjs/w/index.js +1 -8
- package/dist/cjs/w/local/account.js +1 -656
- package/dist/cjs/w/local/cache.js +1 -161
- package/dist/cjs/w/local/config.js +1 -43
- package/dist/cjs/w/local/index.js +1 -228
- package/dist/cjs/w/local/local.js +1 -574
- package/dist/cjs/w/local/storage.js +1 -185
- package/dist/cjs/w/local/token.js +1 -131
- package/dist/cjs/w/local/util.js +1 -26
- package/dist/cjs/w/local/wip.js +1 -864
- package/dist/cjs/w/messenger/crypto.js +1 -380
- package/dist/cjs/w/messenger/index.js +1 -4
- package/dist/cjs/w/messenger/messenger-api.js +1 -1154
- package/dist/cjs/w/messenger/messenger-manager.js +1 -1003
- package/dist/cjs/w/messenger/messenger.js +1 -1093
- package/dist/cjs/w/messenger/server.js +1 -343
- package/dist/cjs/w/messenger/session.js +1 -628
- package/dist/cjs/w/messenger/storage.js +1 -1023
- package/dist/cjs/w/messenger/templates/wts-html-template.js +1 -371
- package/dist/cjs/w/messenger/types.js +1 -76
- package/dist/cjs/w/messenger/utils.js +1 -12
- package/dist/cjs/w/query/bult-in.js +1 -95
- package/dist/cjs/w/query/event.js +1 -137
- package/dist/cjs/w/query/index.js +1 -5
- package/dist/cjs/w/query/object.js +1 -1550
- package/dist/cjs/w/query/received.js +1 -62
- package/dist/cjs/w/query/util.js +1 -49
- package/dist/cjs/w/util.js +1 -587
- package/dist/esm/bcs/bcs.js +1 -253
- package/dist/esm/bcs/effects.js +1 -199
- package/dist/esm/bcs/index.js +1 -51
- package/dist/esm/bcs/pure.js +1 -36
- package/dist/esm/bcs/type-tag-serializer.js +1 -104
- package/dist/esm/bcs/types.js +1 -3
- package/dist/esm/client/index.js +1 -4
- package/dist/esm/client/network.js +1 -15
- package/dist/esm/cryptography/index.js +1 -6
- package/dist/esm/cryptography/intent.js +1 -14
- package/dist/esm/cryptography/keypair.js +1 -74
- package/dist/esm/cryptography/mnemonics.js +1 -20
- package/dist/esm/cryptography/publickey.js +1 -80
- package/dist/esm/cryptography/signature-scheme.js +1 -22
- package/dist/esm/cryptography/signature.js +1 -41
- package/dist/esm/experimental/cache.js +1 -58
- package/dist/esm/experimental/client.js +1 -19
- package/dist/esm/experimental/core.js +1 -80
- package/dist/esm/experimental/errors.js +1 -24
- package/dist/esm/experimental/index.js +1 -5
- package/dist/esm/experimental/persistent-storage.js +1 -220
- package/dist/esm/experimental/persistent-storage.test.js +1 -144
- package/dist/esm/experimental/transports/utils.js +1 -96
- package/dist/esm/experimental/types.js +1 -1
- package/dist/esm/faucet/faucet.js +1 -99
- package/dist/esm/faucet/index.js +1 -1
- package/dist/esm/grpc/client.js +1 -42
- package/dist/esm/grpc/core.js +1 -587
- package/dist/esm/grpc/index.js +1 -2
- package/dist/esm/grpc/proto/google/protobuf/any.js +1 -106
- package/dist/esm/grpc/proto/google/protobuf/duration.js +1 -58
- package/dist/esm/grpc/proto/google/protobuf/empty.js +1 -7
- package/dist/esm/grpc/proto/google/protobuf/field_mask.js +1 -47
- package/dist/esm/grpc/proto/google/protobuf/struct.js +1 -191
- package/dist/esm/grpc/proto/google/protobuf/timestamp.js +1 -91
- package/dist/esm/grpc/proto/google/rpc/error_details.js +1 -265
- package/dist/esm/grpc/proto/google/rpc/status.js +1 -23
- package/dist/esm/grpc/proto/sui/rpc/v2/argument.js +1 -46
- package/dist/esm/grpc/proto/sui/rpc/v2/balance_change.js +1 -29
- package/dist/esm/grpc/proto/sui/rpc/v2/bcs.js +1 -22
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint.js +1 -54
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_contents.js +1 -60
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_summary.js +1 -144
- package/dist/esm/grpc/proto/sui/rpc/v2/effects.js +1 -271
- package/dist/esm/grpc/proto/sui/rpc/v2/epoch.js +1 -64
- package/dist/esm/grpc/proto/sui/rpc/v2/error_reason.js +1 -6
- package/dist/esm/grpc/proto/sui/rpc/v2/event.js +1 -62
- package/dist/esm/grpc/proto/sui/rpc/v2/executed_transaction.js +1 -64
- package/dist/esm/grpc/proto/sui/rpc/v2/execution_status.js +1 -481
- package/dist/esm/grpc/proto/sui/rpc/v2/gas_cost_summary.js +1 -40
- package/dist/esm/grpc/proto/sui/rpc/v2/input.js +1 -61
- package/dist/esm/grpc/proto/sui/rpc/v2/jwk.js +1 -57
- package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.client.js +1 -39
- package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.js +1 -329
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package.js +1 -447
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.client.js +1 -27
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.js +1 -206
- package/dist/esm/grpc/proto/sui/rpc/v2/name_service.client.js +1 -19
- package/dist/esm/grpc/proto/sui/rpc/v2/name_service.js +1 -109
- package/dist/esm/grpc/proto/sui/rpc/v2/object.js +1 -90
- package/dist/esm/grpc/proto/sui/rpc/v2/object_reference.js +1 -30
- package/dist/esm/grpc/proto/sui/rpc/v2/owner.js +1 -39
- package/dist/esm/grpc/proto/sui/rpc/v2/protocol_config.js +1 -30
- package/dist/esm/grpc/proto/sui/rpc/v2/signature.js +1 -501
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_scheme.js +1 -10
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.client.js +1 -15
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.js +1 -62
- package/dist/esm/grpc/proto/sui/rpc/v2/state_service.client.js +1 -31
- package/dist/esm/grpc/proto/sui/rpc/v2/state_service.js +1 -504
- package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.client.js +1 -15
- package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.js +1 -37
- package/dist/esm/grpc/proto/sui/rpc/v2/system_state.js +1 -709
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction.js +1 -950
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.client.js +1 -19
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.js +1 -144
- package/dist/esm/index.js +1 -22
- package/dist/esm/jsonRpc/client.js +1 -516
- package/dist/esm/jsonRpc/core.js +1 -587
- package/dist/esm/jsonRpc/errors.js +1 -38
- package/dist/esm/jsonRpc/http-transport.js +1 -70
- package/dist/esm/jsonRpc/index.js +1 -3
- package/dist/esm/jsonRpc/json-rpc-resolver.js +1 -296
- package/dist/esm/jsonRpc/rpc-websocket-client.js +1 -155
- package/dist/esm/jsonRpc/types/chain.js +1 -1
- package/dist/esm/jsonRpc/types/changes.js +1 -1
- package/dist/esm/jsonRpc/types/coins.js +1 -1
- package/dist/esm/jsonRpc/types/common.js +1 -1
- package/dist/esm/jsonRpc/types/generated.js +1 -1
- package/dist/esm/jsonRpc/types/index.js +1 -1
- package/dist/esm/jsonRpc/types/params.js +1 -1
- package/dist/esm/keypairs/ed25519/ed25519-hd-key.js +1 -58
- package/dist/esm/keypairs/ed25519/index.js +1 -2
- package/dist/esm/keypairs/ed25519/keypair.js +1 -90
- package/dist/esm/keypairs/ed25519/publickey.js +1 -50
- package/dist/esm/keypairs/index.js +1 -4
- package/dist/esm/keypairs/passkey/index.js +1 -2
- package/dist/esm/keypairs/passkey/keypair.js +1 -155
- package/dist/esm/keypairs/passkey/publickey.js +1 -117
- package/dist/esm/keypairs/passkey/types.js +1 -1
- package/dist/esm/keypairs/secp256k1/index.js +1 -2
- package/dist/esm/keypairs/secp256k1/keypair.js +1 -82
- package/dist/esm/keypairs/secp256k1/publickey.js +1 -51
- package/dist/esm/keypairs/secp256r1/index.js +1 -2
- package/dist/esm/keypairs/secp256r1/keypair.js +1 -78
- package/dist/esm/keypairs/secp256r1/publickey.js +1 -52
- package/dist/esm/multisig/index.js +1 -2
- package/dist/esm/multisig/publickey.js +1 -201
- package/dist/esm/multisig/signer.js +1 -58
- package/dist/esm/transactions/Arguments.js +1 -9
- package/dist/esm/transactions/Commands.js +1 -102
- package/dist/esm/transactions/Inputs.js +1 -52
- package/dist/esm/transactions/ObjectCache.js +1 -205
- package/dist/esm/transactions/Transaction.js +1 -574
- package/dist/esm/transactions/TransactionData.js +1 -409
- package/dist/esm/transactions/__tests__/Transaction.test.js +1 -160
- package/dist/esm/transactions/__tests__/bcs.test.js +1 -182
- package/dist/esm/transactions/data/internal.js +1 -169
- package/dist/esm/transactions/data/v1.js +1 -469
- package/dist/esm/transactions/data/v2.js +1 -97
- package/dist/esm/transactions/executor/caching.js +1 -65
- package/dist/esm/transactions/executor/parallel.js +1 -347
- package/dist/esm/transactions/executor/queue.js +1 -59
- package/dist/esm/transactions/executor/serial.js +1 -99
- package/dist/esm/transactions/hash.js +1 -8
- package/dist/esm/transactions/index.js +1 -12
- package/dist/esm/transactions/intents/CoinWithBalance.js +1 -145
- package/dist/esm/transactions/object.js +1 -87
- package/dist/esm/transactions/plugins/NamedPackagesPlugin.js +1 -11
- package/dist/esm/transactions/pure.js +1 -36
- package/dist/esm/transactions/resolve.js +1 -69
- package/dist/esm/transactions/serializer.js +1 -167
- package/dist/esm/transactions/utils.js +1 -121
- package/dist/esm/utils/constants.js +1 -18
- package/dist/esm/utils/derived-objects.js +1 -8
- package/dist/esm/utils/dynamic-fields.js +1 -17
- package/dist/esm/utils/format.js +1 -11
- package/dist/esm/utils/index.js +1 -8
- package/dist/esm/utils/move-registry.js +1 -24
- package/dist/esm/utils/sui-types.js +1 -66
- package/dist/esm/utils/suins.js +1 -33
- package/dist/esm/verify/index.js +1 -1
- package/dist/esm/verify/verify.js +1 -87
- package/dist/esm/version.js +1 -2
- package/dist/esm/w/call/allocation.js +1 -345
- package/dist/esm/w/call/arb.js +1 -103
- package/dist/esm/w/call/arbitration.js +1 -1192
- package/dist/esm/w/call/base.js +1 -293
- package/dist/esm/w/call/contact.js +1 -345
- package/dist/esm/w/call/demand.js +1 -681
- package/dist/esm/w/call/entity.js +1 -173
- package/dist/esm/w/call/guard-ins.js +1 -4449
- package/dist/esm/w/call/guard.d.ts +111 -0
- package/dist/esm/w/call/guard.js +1 -1048
- package/dist/esm/w/call/index.js +1 -22
- package/dist/esm/w/call/machine.js +1 -1127
- package/dist/esm/w/call/order.js +1 -337
- package/dist/esm/w/call/passport.js +1 -220
- package/dist/esm/w/call/payment.js +1 -178
- package/dist/esm/w/call/permission.js +1 -1162
- package/dist/esm/w/call/personal.js +1 -139
- package/dist/esm/w/call/progress.js +1 -678
- package/dist/esm/w/call/proof.js +1 -66
- package/dist/esm/w/call/repository.js +1 -1024
- package/dist/esm/w/call/resource.js +1 -108
- package/dist/esm/w/call/reward.js +1 -675
- package/dist/esm/w/call/service.js +1 -1960
- package/dist/esm/w/call/treasury.js +1 -873
- package/dist/esm/w/call/util.d.ts +1 -0
- package/dist/esm/w/call/util.js +1 -566
- package/dist/esm/w/common.js +1 -571
- package/dist/esm/w/exception.js +1 -618
- package/dist/esm/w/index.js +1 -8
- package/dist/esm/w/local/account.js +1 -656
- package/dist/esm/w/local/cache.js +1 -161
- package/dist/esm/w/local/config.js +1 -43
- package/dist/esm/w/local/index.js +1 -228
- package/dist/esm/w/local/local.js +1 -574
- package/dist/esm/w/local/storage.js +1 -185
- package/dist/esm/w/local/token.js +1 -131
- package/dist/esm/w/local/util.js +1 -26
- package/dist/esm/w/local/wip.js +1 -864
- package/dist/esm/w/messenger/crypto.js +1 -380
- package/dist/esm/w/messenger/index.js +1 -4
- package/dist/esm/w/messenger/messenger-api.js +1 -1154
- package/dist/esm/w/messenger/messenger-manager.js +1 -1003
- package/dist/esm/w/messenger/messenger.js +1 -1093
- package/dist/esm/w/messenger/server.js +1 -343
- package/dist/esm/w/messenger/session.js +1 -628
- package/dist/esm/w/messenger/storage.js +1 -1023
- package/dist/esm/w/messenger/templates/wts-html-template.js +1 -371
- package/dist/esm/w/messenger/types.js +1 -76
- package/dist/esm/w/messenger/utils.js +1 -12
- package/dist/esm/w/query/bult-in.js +1 -95
- package/dist/esm/w/query/event.js +1 -137
- package/dist/esm/w/query/index.js +1 -5
- package/dist/esm/w/query/object.js +1 -1550
- package/dist/esm/w/query/received.js +1 -62
- package/dist/esm/w/query/util.js +1 -49
- package/dist/esm/w/util.js +1 -587
- package/package.json +5 -2
|
@@ -1,574 +1 @@
|
|
|
1
|
-
import { isValidWowAddress } from "../../utils/sui-types.js";
|
|
2
|
-
import { W_ERROR, WErrors } from "../exception.js";
|
|
3
|
-
import { Cache, CachePrefix } from "./cache.js";
|
|
4
|
-
export const BUITIN_IDS = [
|
|
5
|
-
"0x5",
|
|
6
|
-
"0x6",
|
|
7
|
-
"0x7",
|
|
8
|
-
"0x8",
|
|
9
|
-
"0x9",
|
|
10
|
-
"@0xaaa",
|
|
11
|
-
"@0xaab",
|
|
12
|
-
"@0x403",
|
|
13
|
-
"@0xacc",
|
|
14
|
-
"@0xc",
|
|
15
|
-
];
|
|
16
|
-
export const isValidAddress = (address) => {
|
|
17
|
-
return (address && (isValidWowAddress(address) || BUITIN_IDS.includes(address)));
|
|
18
|
-
};
|
|
19
|
-
export const LocalMarkNameMaxLength = 64;
|
|
20
|
-
export const LocalMarkTagMaxLength = 64;
|
|
21
|
-
export const LocalMarkTagMaxCount = 50;
|
|
22
|
-
export const LocalInfoNameMaxLength = 64;
|
|
23
|
-
export const LocalInfoContentMaxLength = 300;
|
|
24
|
-
export const LocalInfoContentMaxCount = 50;
|
|
25
|
-
export const LocalInfoNameDefault = "Address of delivery";
|
|
26
|
-
export class LocalMark {
|
|
27
|
-
static _instance;
|
|
28
|
-
cacheKey = [CachePrefix.local_mark];
|
|
29
|
-
static Instance() {
|
|
30
|
-
if (!LocalMark._instance) {
|
|
31
|
-
LocalMark._instance = new LocalMark();
|
|
32
|
-
}
|
|
33
|
-
return LocalMark._instance;
|
|
34
|
-
}
|
|
35
|
-
resolve_tags(tags) {
|
|
36
|
-
tags = tags?.slice(0, LocalMarkTagMaxCount);
|
|
37
|
-
tags = tags
|
|
38
|
-
?.filter((tag) => tag !== "" && tag)
|
|
39
|
-
?.map((tag) => {
|
|
40
|
-
return tag.slice(0, LocalMarkTagMaxLength);
|
|
41
|
-
});
|
|
42
|
-
return tags;
|
|
43
|
-
}
|
|
44
|
-
resolve_name(name) {
|
|
45
|
-
return name.slice(0, LocalMarkNameMaxLength);
|
|
46
|
-
}
|
|
47
|
-
async put(marks) {
|
|
48
|
-
const allMarksData = await Cache.read(this.cacheKey, async () => {
|
|
49
|
-
return {
|
|
50
|
-
expire: "INFINITE",
|
|
51
|
-
data: [],
|
|
52
|
-
};
|
|
53
|
-
});
|
|
54
|
-
const allMarks = allMarksData?.data || [];
|
|
55
|
-
const addedMarks = [];
|
|
56
|
-
for (const mark of marks) {
|
|
57
|
-
const addressLower = mark.address.toLowerCase();
|
|
58
|
-
mark.address = addressLower;
|
|
59
|
-
if (!isValidAddress(mark.address)) {
|
|
60
|
-
W_ERROR(WErrors.IsValidAddress, `LocalMark.put.mark.address: ${mark.address}`);
|
|
61
|
-
}
|
|
62
|
-
if (mark?.name?.value) {
|
|
63
|
-
mark.name.value = this.resolve_name(mark?.name?.value);
|
|
64
|
-
}
|
|
65
|
-
mark.tags = this.resolve_tags(mark?.tags);
|
|
66
|
-
allMarks.forEach((m) => {
|
|
67
|
-
if (mark?.name?.value != null && m.name === mark?.name?.value) {
|
|
68
|
-
if (mark?.name?.replaceExistName) {
|
|
69
|
-
m.name = undefined;
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
W_ERROR(WErrors.LocalMarkNameExist, `LocalMark.put.mark.name: ${mark.name.value}`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
const now = Date.now();
|
|
77
|
-
const newMark = {
|
|
78
|
-
name: mark?.name?.value,
|
|
79
|
-
address: mark.address,
|
|
80
|
-
tags: mark.tags,
|
|
81
|
-
createdAt: now,
|
|
82
|
-
updatedAt: now,
|
|
83
|
-
};
|
|
84
|
-
allMarks.push(newMark);
|
|
85
|
-
addedMarks.push(newMark);
|
|
86
|
-
}
|
|
87
|
-
await Cache.read(this.cacheKey, async () => ({
|
|
88
|
-
expire: "INFINITE",
|
|
89
|
-
data: allMarks,
|
|
90
|
-
}), true);
|
|
91
|
-
return addedMarks;
|
|
92
|
-
}
|
|
93
|
-
async get(name_or_address) {
|
|
94
|
-
if (name_or_address === undefined || name_or_address === null) {
|
|
95
|
-
return undefined;
|
|
96
|
-
}
|
|
97
|
-
const cachedData = await Cache.read(this.cacheKey, async (_) => {
|
|
98
|
-
return {
|
|
99
|
-
expire: "INFINITE",
|
|
100
|
-
data: [],
|
|
101
|
-
};
|
|
102
|
-
});
|
|
103
|
-
return cachedData?.data?.find((d) => d.name === name_or_address ||
|
|
104
|
-
d.address.toLowerCase() === name_or_address.toLowerCase());
|
|
105
|
-
}
|
|
106
|
-
async get_address(name_or_address) {
|
|
107
|
-
if (name_or_address && isValidAddress(name_or_address)) {
|
|
108
|
-
return name_or_address.toLowerCase();
|
|
109
|
-
}
|
|
110
|
-
return (await this.get(name_or_address))?.address;
|
|
111
|
-
}
|
|
112
|
-
async get_many(name_or_address) {
|
|
113
|
-
if (!Array.isArray(name_or_address) || name_or_address.length === 0) {
|
|
114
|
-
return [];
|
|
115
|
-
}
|
|
116
|
-
const cachedData = await Cache.read(this.cacheKey, async (_) => {
|
|
117
|
-
return {
|
|
118
|
-
expire: "INFINITE",
|
|
119
|
-
data: [],
|
|
120
|
-
};
|
|
121
|
-
});
|
|
122
|
-
const allMarks = cachedData?.data || [];
|
|
123
|
-
return name_or_address.map((input) => {
|
|
124
|
-
return allMarks.find((mark) => mark.name === input ||
|
|
125
|
-
mark.address.toLowerCase() === input?.toLowerCase());
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
async get_many_address(name_or_address) {
|
|
129
|
-
const results = new Array(name_or_address.length).fill(undefined);
|
|
130
|
-
const nonAddressMap = new Map();
|
|
131
|
-
name_or_address.forEach((input, index) => {
|
|
132
|
-
if (input === null || input === undefined) {
|
|
133
|
-
results[index] = undefined;
|
|
134
|
-
}
|
|
135
|
-
else if (isValidAddress(input)) {
|
|
136
|
-
results[index] = input.toLowerCase();
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
nonAddressMap.set(index, input);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
const nonAddressInputs = Array.from(nonAddressMap.values());
|
|
143
|
-
if (nonAddressInputs.length === 0) {
|
|
144
|
-
return results;
|
|
145
|
-
}
|
|
146
|
-
const nonAddressResults = await this.get_many(nonAddressInputs);
|
|
147
|
-
let resultIndex = 0;
|
|
148
|
-
nonAddressMap.forEach((input, originalIndex) => {
|
|
149
|
-
const result = nonAddressResults[resultIndex];
|
|
150
|
-
results[originalIndex] = result?.address;
|
|
151
|
-
resultIndex++;
|
|
152
|
-
});
|
|
153
|
-
return results;
|
|
154
|
-
}
|
|
155
|
-
async get_many_address_availables(name_or_addresses) {
|
|
156
|
-
return (await this.get_many_address(name_or_addresses)).filter((v) => v != null);
|
|
157
|
-
}
|
|
158
|
-
async del(name_or_address, delNotNamed = false) {
|
|
159
|
-
const allMarksCacheKey = [
|
|
160
|
-
CachePrefix.local_mark,
|
|
161
|
-
];
|
|
162
|
-
const allMarksData = await Cache.read(allMarksCacheKey, async () => ({
|
|
163
|
-
expire: "INFINITE",
|
|
164
|
-
data: [],
|
|
165
|
-
}));
|
|
166
|
-
const allMarks = allMarksData?.data || [];
|
|
167
|
-
const filteredMarks = allMarks.filter((mark) => {
|
|
168
|
-
const matchesName = mark.name !== undefined &&
|
|
169
|
-
mark.name !== null &&
|
|
170
|
-
name_or_address.includes(mark.name);
|
|
171
|
-
const matchesAddress = name_or_address.includes(mark.address);
|
|
172
|
-
const matchesInput = matchesName || matchesAddress;
|
|
173
|
-
const isNameInvalid = mark.name === undefined || mark.name === null;
|
|
174
|
-
if (delNotNamed) {
|
|
175
|
-
return !matchesInput && !isNameInvalid;
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
return !matchesInput;
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
const deletedMarks = allMarks.filter((mark) => !filteredMarks.includes(mark));
|
|
182
|
-
if (filteredMarks.length !== allMarks.length) {
|
|
183
|
-
await Cache.read(allMarksCacheKey, async () => ({
|
|
184
|
-
expire: "INFINITE",
|
|
185
|
-
data: filteredMarks,
|
|
186
|
-
}), true);
|
|
187
|
-
}
|
|
188
|
-
return deletedMarks;
|
|
189
|
-
}
|
|
190
|
-
async clear() {
|
|
191
|
-
const allMarksCacheKey = [
|
|
192
|
-
CachePrefix.local_mark,
|
|
193
|
-
];
|
|
194
|
-
await Cache.read(allMarksCacheKey, async () => ({
|
|
195
|
-
expire: "INFINITE",
|
|
196
|
-
data: [],
|
|
197
|
-
}), true);
|
|
198
|
-
return true;
|
|
199
|
-
}
|
|
200
|
-
async rename(name, new_name) {
|
|
201
|
-
new_name = this.resolve_name(new_name);
|
|
202
|
-
if (name === new_name) {
|
|
203
|
-
return true;
|
|
204
|
-
}
|
|
205
|
-
const allMarksData = await Cache.read(this.cacheKey, async () => ({
|
|
206
|
-
expire: "INFINITE",
|
|
207
|
-
data: [],
|
|
208
|
-
}));
|
|
209
|
-
const allMarks = allMarksData?.data || [];
|
|
210
|
-
const old = allMarks.find((d) => d.name === name);
|
|
211
|
-
if (old && allMarks.findIndex((d) => d.name === new_name) === -1) {
|
|
212
|
-
const now = Date.now();
|
|
213
|
-
old.name = new_name;
|
|
214
|
-
old.updatedAt = now;
|
|
215
|
-
await Cache.read(this.cacheKey, async () => ({
|
|
216
|
-
expire: "INFINITE",
|
|
217
|
-
data: allMarks,
|
|
218
|
-
}), true);
|
|
219
|
-
return true;
|
|
220
|
-
}
|
|
221
|
-
return false;
|
|
222
|
-
}
|
|
223
|
-
async swap_name(name1, name2) {
|
|
224
|
-
if (name1 === name2) {
|
|
225
|
-
return true;
|
|
226
|
-
}
|
|
227
|
-
const allMarksData = await Cache.read(this.cacheKey, async () => ({
|
|
228
|
-
expire: "INFINITE",
|
|
229
|
-
data: [],
|
|
230
|
-
}));
|
|
231
|
-
const allMarks = allMarksData?.data || [];
|
|
232
|
-
const n1 = allMarks.find((d) => d.name === name1);
|
|
233
|
-
const n2 = allMarks.find((d) => d.name === name2);
|
|
234
|
-
if (n1 && n2) {
|
|
235
|
-
const now = Date.now();
|
|
236
|
-
n1.name = name2;
|
|
237
|
-
n1.updatedAt = now;
|
|
238
|
-
n2.name = name1;
|
|
239
|
-
n2.updatedAt = now;
|
|
240
|
-
await Cache.read(this.cacheKey, async () => ({
|
|
241
|
-
expire: "INFINITE",
|
|
242
|
-
data: allMarks,
|
|
243
|
-
}), true);
|
|
244
|
-
return true;
|
|
245
|
-
}
|
|
246
|
-
return false;
|
|
247
|
-
}
|
|
248
|
-
async set_tags(name, tags) {
|
|
249
|
-
tags = this.resolve_tags(tags);
|
|
250
|
-
const allMarksData = await Cache.read(this.cacheKey, async () => ({
|
|
251
|
-
expire: "INFINITE",
|
|
252
|
-
data: [],
|
|
253
|
-
}));
|
|
254
|
-
const allMarks = allMarksData?.data || [];
|
|
255
|
-
const mark = allMarks.find((d) => d.name === name);
|
|
256
|
-
if (mark) {
|
|
257
|
-
const now = Date.now();
|
|
258
|
-
mark.tags = tags;
|
|
259
|
-
mark.updatedAt = now;
|
|
260
|
-
await Cache.read(this.cacheKey, async () => ({
|
|
261
|
-
expire: "INFINITE",
|
|
262
|
-
data: allMarks,
|
|
263
|
-
}), true);
|
|
264
|
-
return true;
|
|
265
|
-
}
|
|
266
|
-
return false;
|
|
267
|
-
}
|
|
268
|
-
async list(filter) {
|
|
269
|
-
if (filter && filter.tags)
|
|
270
|
-
filter.tags = filter.tags.filter((v) => v !== "" && v);
|
|
271
|
-
const allMarksData = await Cache.read(this.cacheKey, async () => ({
|
|
272
|
-
expire: "INFINITE",
|
|
273
|
-
data: [],
|
|
274
|
-
}));
|
|
275
|
-
const allMarks = allMarksData?.data || [];
|
|
276
|
-
return (allMarks
|
|
277
|
-
.filter((mark) => {
|
|
278
|
-
if (filter?.address && mark.address !== filter.address)
|
|
279
|
-
return false;
|
|
280
|
-
if (filter?.createdAt) {
|
|
281
|
-
if (filter.createdAt.gte !== undefined &&
|
|
282
|
-
(!mark.createdAt ||
|
|
283
|
-
mark.createdAt < filter.createdAt.gte))
|
|
284
|
-
return false;
|
|
285
|
-
if (filter.createdAt.lte !== undefined &&
|
|
286
|
-
(!mark.createdAt ||
|
|
287
|
-
mark.createdAt > filter.createdAt.lte))
|
|
288
|
-
return false;
|
|
289
|
-
}
|
|
290
|
-
if (filter?.updatedAt) {
|
|
291
|
-
if (filter.updatedAt.gte !== undefined &&
|
|
292
|
-
(!mark.updatedAt ||
|
|
293
|
-
mark.updatedAt < filter.updatedAt.gte))
|
|
294
|
-
return false;
|
|
295
|
-
if (filter.updatedAt.lte !== undefined &&
|
|
296
|
-
(!mark.updatedAt ||
|
|
297
|
-
mark.updatedAt > filter.updatedAt.lte))
|
|
298
|
-
return false;
|
|
299
|
-
}
|
|
300
|
-
return true;
|
|
301
|
-
})
|
|
302
|
-
.map((mark) => {
|
|
303
|
-
let score = 0;
|
|
304
|
-
const lowerName = mark.name?.toLowerCase() || "";
|
|
305
|
-
const lowerFilterName = filter?.name?.toLowerCase() || "";
|
|
306
|
-
if (filter?.name) {
|
|
307
|
-
if (lowerName === lowerFilterName) {
|
|
308
|
-
score += 100;
|
|
309
|
-
}
|
|
310
|
-
else if (lowerName.startsWith(lowerFilterName)) {
|
|
311
|
-
score += 50;
|
|
312
|
-
}
|
|
313
|
-
else if (lowerName.includes(lowerFilterName)) {
|
|
314
|
-
score += 25;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
if (filter?.tags && filter.tags.length > 0) {
|
|
318
|
-
filter.tags.forEach((filterTag) => {
|
|
319
|
-
const lowerFilterTag = filterTag.toLowerCase();
|
|
320
|
-
if (mark.tags) {
|
|
321
|
-
mark.tags.forEach((tag) => {
|
|
322
|
-
const lowerTag = tag.toLowerCase();
|
|
323
|
-
if (lowerTag === lowerFilterTag) {
|
|
324
|
-
score += 20;
|
|
325
|
-
}
|
|
326
|
-
else if (lowerTag.startsWith(lowerFilterTag)) {
|
|
327
|
-
score += 15;
|
|
328
|
-
}
|
|
329
|
-
else if (lowerTag.includes(lowerFilterTag)) {
|
|
330
|
-
score += 10;
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
if ((filter?.name || filter?.tags) && score === 0) {
|
|
337
|
-
score = -1;
|
|
338
|
-
}
|
|
339
|
-
return { mark, score };
|
|
340
|
-
})
|
|
341
|
-
.filter(({ score }) => score >= 0)
|
|
342
|
-
.sort((a, b) => {
|
|
343
|
-
if (b.score !== a.score) {
|
|
344
|
-
return b.score - a.score;
|
|
345
|
-
}
|
|
346
|
-
const aNameLength = (a.mark.name || "").length;
|
|
347
|
-
const bNameLength = (b.mark.name || "").length;
|
|
348
|
-
if (aNameLength !== bNameLength) {
|
|
349
|
-
return aNameLength - bNameLength;
|
|
350
|
-
}
|
|
351
|
-
return (a.mark.name || "").localeCompare(b.mark.name || "");
|
|
352
|
-
})
|
|
353
|
-
.map(({ mark }) => mark));
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
export class LocalInfo {
|
|
357
|
-
static _instance;
|
|
358
|
-
cacheKey = [CachePrefix.local_info];
|
|
359
|
-
static Instance() {
|
|
360
|
-
if (!LocalInfo._instance) {
|
|
361
|
-
LocalInfo._instance = new LocalInfo();
|
|
362
|
-
}
|
|
363
|
-
return LocalInfo._instance;
|
|
364
|
-
}
|
|
365
|
-
resolve_contents(contents) {
|
|
366
|
-
contents = contents.slice(0, LocalInfoContentMaxCount);
|
|
367
|
-
return contents.map((v) => v.slice(0, LocalInfoContentMaxLength));
|
|
368
|
-
}
|
|
369
|
-
resolve_name(name) {
|
|
370
|
-
return name.slice(0, LocalInfoNameMaxLength);
|
|
371
|
-
}
|
|
372
|
-
async add(data) {
|
|
373
|
-
const allInfoData = await Cache.read(this.cacheKey, async () => ({
|
|
374
|
-
expire: "INFINITE",
|
|
375
|
-
data: {},
|
|
376
|
-
}));
|
|
377
|
-
const allInfo = allInfoData?.data || {};
|
|
378
|
-
for (const item of data) {
|
|
379
|
-
const resolvedName = this.resolve_name(item.name);
|
|
380
|
-
const resolvedDefault = item.default.slice(0, LocalInfoContentMaxLength);
|
|
381
|
-
if (allInfo[resolvedName]) {
|
|
382
|
-
const now = Date.now();
|
|
383
|
-
const obj = allInfo[resolvedName];
|
|
384
|
-
obj.default = resolvedDefault;
|
|
385
|
-
if (item.contents !== undefined) {
|
|
386
|
-
obj.contents = this.resolve_contents(item.contents);
|
|
387
|
-
}
|
|
388
|
-
obj.updatedAt = now;
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
391
|
-
const now = Date.now();
|
|
392
|
-
const obj = {
|
|
393
|
-
default: resolvedDefault,
|
|
394
|
-
contents: item.contents
|
|
395
|
-
? this.resolve_contents(item.contents)
|
|
396
|
-
: [],
|
|
397
|
-
createdAt: now,
|
|
398
|
-
updatedAt: now,
|
|
399
|
-
};
|
|
400
|
-
allInfo[resolvedName] = obj;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
await Cache.read(this.cacheKey, async () => ({
|
|
404
|
-
expire: "INFINITE",
|
|
405
|
-
data: allInfo,
|
|
406
|
-
}), true);
|
|
407
|
-
return true;
|
|
408
|
-
}
|
|
409
|
-
async get(name = LocalInfoNameDefault) {
|
|
410
|
-
const allInfoData = await Cache.read(this.cacheKey, async () => ({
|
|
411
|
-
expire: "INFINITE",
|
|
412
|
-
data: {},
|
|
413
|
-
}));
|
|
414
|
-
const allInfo = allInfoData?.data || {};
|
|
415
|
-
const inner = allInfo[name];
|
|
416
|
-
return inner ? { name, ...inner } : undefined;
|
|
417
|
-
}
|
|
418
|
-
async get_default(name = LocalInfoNameDefault) {
|
|
419
|
-
const info = await this.get(name);
|
|
420
|
-
return info?.default;
|
|
421
|
-
}
|
|
422
|
-
async get_many(names) {
|
|
423
|
-
if (!Array.isArray(names) || names.length === 0) {
|
|
424
|
-
return [];
|
|
425
|
-
}
|
|
426
|
-
const allInfoData = await Cache.read(this.cacheKey, async () => ({
|
|
427
|
-
expire: "INFINITE",
|
|
428
|
-
data: {},
|
|
429
|
-
}));
|
|
430
|
-
const allInfo = allInfoData?.data || {};
|
|
431
|
-
return names.map((name) => {
|
|
432
|
-
const inner = allInfo[name];
|
|
433
|
-
return inner ? { name, ...inner } : undefined;
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
async del(name = LocalInfoNameDefault) {
|
|
437
|
-
const allInfoData = await Cache.read(this.cacheKey, async () => ({
|
|
438
|
-
expire: "INFINITE",
|
|
439
|
-
data: {},
|
|
440
|
-
}));
|
|
441
|
-
const allInfo = allInfoData?.data || {};
|
|
442
|
-
delete allInfo[name];
|
|
443
|
-
await Cache.read(this.cacheKey, async () => ({
|
|
444
|
-
expire: "INFINITE",
|
|
445
|
-
data: allInfo,
|
|
446
|
-
}), true);
|
|
447
|
-
}
|
|
448
|
-
async reset_contents(name = LocalInfoNameDefault, contents) {
|
|
449
|
-
const allInfoData = await Cache.read(this.cacheKey, async () => ({
|
|
450
|
-
expire: "INFINITE",
|
|
451
|
-
data: {},
|
|
452
|
-
}));
|
|
453
|
-
const allInfo = allInfoData?.data || {};
|
|
454
|
-
const info = allInfo[name];
|
|
455
|
-
if (info) {
|
|
456
|
-
if (info.contents && info.contents.length > 0) {
|
|
457
|
-
const now = Date.now();
|
|
458
|
-
info.contents = this.resolve_contents(contents);
|
|
459
|
-
info.updatedAt = now;
|
|
460
|
-
await Cache.read(this.cacheKey, async () => ({
|
|
461
|
-
expire: "INFINITE",
|
|
462
|
-
data: allInfo,
|
|
463
|
-
}), true);
|
|
464
|
-
return true;
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
return false;
|
|
468
|
-
}
|
|
469
|
-
async clear() {
|
|
470
|
-
await Cache.read(this.cacheKey, async () => ({
|
|
471
|
-
expire: "INFINITE",
|
|
472
|
-
data: {},
|
|
473
|
-
}), true);
|
|
474
|
-
}
|
|
475
|
-
async list(filter) {
|
|
476
|
-
const allInfoData = await Cache.read(this.cacheKey, async () => ({
|
|
477
|
-
expire: "INFINITE",
|
|
478
|
-
data: {},
|
|
479
|
-
}));
|
|
480
|
-
const allInfo = allInfoData?.data || {};
|
|
481
|
-
return (Object.entries(allInfo)
|
|
482
|
-
.map(([name, info]) => {
|
|
483
|
-
let score = 0;
|
|
484
|
-
const infoWithName = { name, ...info };
|
|
485
|
-
if (filter?.name) {
|
|
486
|
-
const lowerName = name.toLowerCase();
|
|
487
|
-
const lowerFilterName = filter.name.toLowerCase();
|
|
488
|
-
if (lowerName === lowerFilterName) {
|
|
489
|
-
score += 100;
|
|
490
|
-
}
|
|
491
|
-
else if (lowerName.startsWith(lowerFilterName)) {
|
|
492
|
-
score += 50;
|
|
493
|
-
}
|
|
494
|
-
else if (lowerName.includes(lowerFilterName)) {
|
|
495
|
-
score += 25;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
if (filter?.default) {
|
|
499
|
-
const lowerDefault = info.default.toLowerCase();
|
|
500
|
-
const lowerFilterDefault = filter.default.toLowerCase();
|
|
501
|
-
if (lowerDefault === lowerFilterDefault) {
|
|
502
|
-
score += 90;
|
|
503
|
-
}
|
|
504
|
-
else if (lowerDefault.startsWith(lowerFilterDefault)) {
|
|
505
|
-
score += 45;
|
|
506
|
-
}
|
|
507
|
-
else if (lowerDefault.includes(lowerFilterDefault)) {
|
|
508
|
-
score += 22;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
if (filter?.contents && filter.contents.length > 0) {
|
|
512
|
-
filter.contents.forEach((filterContent) => {
|
|
513
|
-
const lowerFilterContent = filterContent.toLowerCase();
|
|
514
|
-
if (info.contents) {
|
|
515
|
-
info.contents.forEach((content) => {
|
|
516
|
-
const lowerContent = content.toLowerCase();
|
|
517
|
-
if (lowerContent === lowerFilterContent) {
|
|
518
|
-
score += 20;
|
|
519
|
-
}
|
|
520
|
-
else if (lowerContent.startsWith(lowerFilterContent)) {
|
|
521
|
-
score += 15;
|
|
522
|
-
}
|
|
523
|
-
else if (lowerContent.includes(lowerFilterContent)) {
|
|
524
|
-
score += 10;
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
if ((filter?.name || filter?.default || filter?.contents) &&
|
|
531
|
-
score === 0) {
|
|
532
|
-
score = -1;
|
|
533
|
-
}
|
|
534
|
-
return { info: infoWithName, score };
|
|
535
|
-
})
|
|
536
|
-
.filter(({ score, info }) => {
|
|
537
|
-
if (score < 0)
|
|
538
|
-
return false;
|
|
539
|
-
if (filter?.createdAt) {
|
|
540
|
-
if (filter.createdAt.gte !== undefined &&
|
|
541
|
-
(!info.createdAt ||
|
|
542
|
-
info.createdAt < filter.createdAt.gte))
|
|
543
|
-
return false;
|
|
544
|
-
if (filter.createdAt.lte !== undefined &&
|
|
545
|
-
(!info.createdAt ||
|
|
546
|
-
info.createdAt > filter.createdAt.lte))
|
|
547
|
-
return false;
|
|
548
|
-
}
|
|
549
|
-
if (filter?.updatedAt) {
|
|
550
|
-
if (filter.updatedAt.gte !== undefined &&
|
|
551
|
-
(!info.updatedAt ||
|
|
552
|
-
info.updatedAt < filter.updatedAt.gte))
|
|
553
|
-
return false;
|
|
554
|
-
if (filter.updatedAt.lte !== undefined &&
|
|
555
|
-
(!info.updatedAt ||
|
|
556
|
-
info.updatedAt > filter.updatedAt.lte))
|
|
557
|
-
return false;
|
|
558
|
-
}
|
|
559
|
-
return true;
|
|
560
|
-
})
|
|
561
|
-
.sort((a, b) => {
|
|
562
|
-
if (b.score !== a.score) {
|
|
563
|
-
return b.score - a.score;
|
|
564
|
-
}
|
|
565
|
-
const aNameLength = a.info.name.length;
|
|
566
|
-
const bNameLength = b.info.name.length;
|
|
567
|
-
if (aNameLength !== bNameLength) {
|
|
568
|
-
return aNameLength - bNameLength;
|
|
569
|
-
}
|
|
570
|
-
return a.info.name.localeCompare(b.info.name);
|
|
571
|
-
})
|
|
572
|
-
.map(({ info }) => info));
|
|
573
|
-
}
|
|
574
|
-
}
|
|
1
|
+
import{isValidWowAddress}from'../../utils/sui-types.js';import{W_ERROR,WErrors}from'../exception.js';import{Cache,CachePrefix}from'./cache.js';export const BUITIN_IDS=['0x5','0x6','0x7','0x8','0x9','@0xaaa','@0xaab','@0x403','@0xacc','@0xc'];export const isValidAddress=a=>{return a&&(isValidWowAddress(a)||BUITIN_IDS['includes'](a));};export const LocalMarkNameMaxLength=0x40;export const LocalMarkTagMaxLength=0x40;export const LocalMarkTagMaxCount=0x32;export const LocalInfoNameMaxLength=0x40;export const LocalInfoContentMaxLength=0x12c;export const LocalInfoContentMaxCount=0x32;export const LocalInfoNameDefault='Address\x20of\x20delivery';export class LocalMark{static ['_instance'];['cacheKey']=[CachePrefix['local_mark']];static['Instance'](){return!LocalMark['_instance']&&(LocalMark['_instance']=new LocalMark()),LocalMark['_instance'];}['resolve_tags'](a){return a=a?.['slice'](0x0,LocalMarkTagMaxCount),a=a?.['filter'](b=>b!==''&&b)?.['map'](b=>{return b['slice'](0x0,LocalMarkTagMaxLength);}),a;}['resolve_name'](a){return a['slice'](0x0,LocalMarkNameMaxLength);}async['put'](a){const b=await Cache['read'](this['cacheKey'],async()=>{return{'expire':'INFINITE','data':[]};}),c=b?.['data']||[],d=[];for(const e of a){const f=e['address']['toLowerCase']();e['address']=f;!isValidAddress(e['address'])&&W_ERROR(WErrors['IsValidAddress'],'LocalMark.put.mark.address:\x20'+e['address']);e?.['name']?.['value']&&(e['name']['value']=this['resolve_name'](e?.['name']?.['value']));e['tags']=this['resolve_tags'](e?.['tags']),c['forEach'](i=>{e?.['name']?.['value']!=null&&i['name']===e?.['name']?.['value']&&(e?.['name']?.['replaceExistName']?i['name']=undefined:W_ERROR(WErrors['LocalMarkNameExist'],'LocalMark.put.mark.name:\x20'+e['name']['value']));});const g=Date['now'](),h={'name':e?.['name']?.['value'],'address':e['address'],'tags':e['tags'],'createdAt':g,'updatedAt':g};c['push'](h),d['push'](h);}return await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':c}),!![]),d;}async['get'](a){if(a===undefined||a===null)return undefined;const b=await Cache['read'](this['cacheKey'],async c=>{return{'expire':'INFINITE','data':[]};});return b?.['data']?.['find'](c=>c['name']===a||c['address']['toLowerCase']()===a['toLowerCase']());}async['get_address'](a){if(a&&isValidAddress(a))return a['toLowerCase']();return(await this['get'](a))?.['address'];}async['get_many'](a){if(!Array['isArray'](a)||a['length']===0x0)return[];const b=await Cache['read'](this['cacheKey'],async d=>{return{'expire':'INFINITE','data':[]};}),c=b?.['data']||[];return a['map'](d=>{return c['find'](e=>e['name']===d||e['address']['toLowerCase']()===d?.['toLowerCase']());});}async['get_many_address'](a){const b=new Array(a['length'])['fill'](undefined),c=new Map();a['forEach']((g,h)=>{if(g===null||g===undefined)b[h]=undefined;else isValidAddress(g)?b[h]=g['toLowerCase']():c['set'](h,g);});const d=Array['from'](c['values']());if(d['length']===0x0)return b;const e=await this['get_many'](d);let f=0x0;return c['forEach']((g,h)=>{const i=e[f];b[h]=i?.['address'],f++;}),b;}async['get_many_address_availables'](a){return(await this['get_many_address'](a))['filter'](b=>b!=null);}async['del'](a,b=![]){const c=[CachePrefix['local_mark']],d=await Cache['read'](c,async()=>({'expire':'INFINITE','data':[]})),e=d?.['data']||[],f=e['filter'](h=>{const i=h['name']!==undefined&&h['name']!==null&&a['includes'](h['name']),j=a['includes'](h['address']),k=i||j,l=h['name']===undefined||h['name']===null;return b?!k&&!l:!k;}),g=e['filter'](h=>!f['includes'](h));return f['length']!==e['length']&&await Cache['read'](c,async()=>({'expire':'INFINITE','data':f}),!![]),g;}async['clear'](){const a=[CachePrefix['local_mark']];return await Cache['read'](a,async()=>({'expire':'INFINITE','data':[]}),!![]),!![];}async['rename'](a,b){b=this['resolve_name'](b);if(a===b)return!![];const c=await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':[]})),d=c?.['data']||[],e=d['find'](f=>f['name']===a);if(e&&d['findIndex'](f=>f['name']===b)===-0x1){const f=Date['now']();return e['name']=b,e['updatedAt']=f,await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':d}),!![]),!![];}return![];}async['swap_name'](a,b){if(a===b)return!![];const c=await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':[]})),d=c?.['data']||[],e=d['find'](g=>g['name']===a),f=d['find'](g=>g['name']===b);if(e&&f){const g=Date['now']();return e['name']=b,e['updatedAt']=g,f['name']=a,f['updatedAt']=g,await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':d}),!![]),!![];}return![];}async['set_tags'](a,b){b=this['resolve_tags'](b);const c=await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':[]})),d=c?.['data']||[],e=d['find'](f=>f['name']===a);if(e){const f=Date['now']();return e['tags']=b,e['updatedAt']=f,await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':d}),!![]),!![];}return![];}async['list'](a){if(a&&a['tags'])a['tags']=a['tags']['filter'](d=>d!==''&&d);const b=await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':[]})),c=b?.['data']||[];return c['filter'](d=>{if(a?.['address']&&d['address']!==a['address'])return![];if(a?.['createdAt']){if(a['createdAt']['gte']!==undefined&&(!d['createdAt']||d['createdAt']<a['createdAt']['gte']))return![];if(a['createdAt']['lte']!==undefined&&(!d['createdAt']||d['createdAt']>a['createdAt']['lte']))return![];}if(a?.['updatedAt']){if(a['updatedAt']['gte']!==undefined&&(!d['updatedAt']||d['updatedAt']<a['updatedAt']['gte']))return![];if(a['updatedAt']['lte']!==undefined&&(!d['updatedAt']||d['updatedAt']>a['updatedAt']['lte']))return![];}return!![];})['map'](d=>{let e=0x0;const f=d['name']?.['toLowerCase']()||'',g=a?.['name']?.['toLowerCase']()||'';if(a?.['name']){if(f===g)e+=0x64;else{if(f['startsWith'](g))e+=0x32;else f['includes'](g)&&(e+=0x19);}}return a?.['tags']&&a['tags']['length']>0x0&&a['tags']['forEach'](h=>{const i=h['toLowerCase']();d['tags']&&d['tags']['forEach'](j=>{const k=j['toLowerCase']();if(k===i)e+=0x14;else{if(k['startsWith'](i))e+=0xf;else k['includes'](i)&&(e+=0xa);}});}),(a?.['name']||a?.['tags'])&&e===0x0&&(e=-0x1),{'mark':d,'score':e};})['filter'](({score:d})=>d>=0x0)['sort']((d,e)=>{if(e['score']!==d['score'])return e['score']-d['score'];const f=(d['mark']['name']||'')['length'],g=(e['mark']['name']||'')['length'];if(f!==g)return f-g;return(d['mark']['name']||'')['localeCompare'](e['mark']['name']||'');})['map'](({mark:d})=>d);}}export class LocalInfo{static ['_instance'];['cacheKey']=[CachePrefix['local_info']];static['Instance'](){return!LocalInfo['_instance']&&(LocalInfo['_instance']=new LocalInfo()),LocalInfo['_instance'];}['resolve_contents'](a){return a=a['slice'](0x0,LocalInfoContentMaxCount),a['map'](b=>b['slice'](0x0,LocalInfoContentMaxLength));}['resolve_name'](a){return a['slice'](0x0,LocalInfoNameMaxLength);}async['add'](a){const b=await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':{}})),c=b?.['data']||{};for(const d of a){const e=this['resolve_name'](d['name']),f=d['default']['slice'](0x0,LocalInfoContentMaxLength);if(c[e]){const g=Date['now'](),h=c[e];h['default']=f,d['contents']!==undefined&&(h['contents']=this['resolve_contents'](d['contents'])),h['updatedAt']=g;}else{const i=Date['now'](),j={'default':f,'contents':d['contents']?this['resolve_contents'](d['contents']):[],'createdAt':i,'updatedAt':i};c[e]=j;}}return await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':c}),!![]),!![];}async['get'](a=LocalInfoNameDefault){const b=await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':{}})),c=b?.['data']||{},d=c[a];return d?{'name':a,...d}:undefined;}async['get_default'](a=LocalInfoNameDefault){const b=await this['get'](a);return b?.['default'];}async['get_many'](a){if(!Array['isArray'](a)||a['length']===0x0)return[];const b=await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':{}})),c=b?.['data']||{};return a['map'](d=>{const e=c[d];return e?{'name':d,...e}:undefined;});}async['del'](a=LocalInfoNameDefault){const b=await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':{}})),c=b?.['data']||{};delete c[a],await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':c}),!![]);}async['reset_contents'](a=LocalInfoNameDefault,b){const c=await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':{}})),d=c?.['data']||{},e=d[a];if(e){if(e['contents']&&e['contents']['length']>0x0){const f=Date['now']();return e['contents']=this['resolve_contents'](b),e['updatedAt']=f,await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':d}),!![]),!![];}}return![];}async['clear'](){await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':{}}),!![]);}async['list'](a){const b=await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':{}})),c=b?.['data']||{};return Object['entries'](c)['map'](([d,e])=>{let f=0x0;const g={'name':d,...e};if(a?.['name']){const h=d['toLowerCase'](),i=a['name']['toLowerCase']();if(h===i)f+=0x64;else{if(h['startsWith'](i))f+=0x32;else h['includes'](i)&&(f+=0x19);}}if(a?.['default']){const j=e['default']['toLowerCase'](),k=a['default']['toLowerCase']();if(j===k)f+=0x5a;else{if(j['startsWith'](k))f+=0x2d;else j['includes'](k)&&(f+=0x16);}}return a?.['contents']&&a['contents']['length']>0x0&&a['contents']['forEach'](l=>{const m=l['toLowerCase']();e['contents']&&e['contents']['forEach'](n=>{const o=n['toLowerCase']();if(o===m)f+=0x14;else{if(o['startsWith'](m))f+=0xf;else o['includes'](m)&&(f+=0xa);}});}),(a?.['name']||a?.['default']||a?.['contents'])&&f===0x0&&(f=-0x1),{'info':g,'score':f};})['filter'](({score:d,info:e})=>{if(d<0x0)return![];if(a?.['createdAt']){if(a['createdAt']['gte']!==undefined&&(!e['createdAt']||e['createdAt']<a['createdAt']['gte']))return![];if(a['createdAt']['lte']!==undefined&&(!e['createdAt']||e['createdAt']>a['createdAt']['lte']))return![];}if(a?.['updatedAt']){if(a['updatedAt']['gte']!==undefined&&(!e['updatedAt']||e['updatedAt']<a['updatedAt']['gte']))return![];if(a['updatedAt']['lte']!==undefined&&(!e['updatedAt']||e['updatedAt']>a['updatedAt']['lte']))return![];}return!![];})['sort']((d,e)=>{if(e['score']!==d['score'])return e['score']-d['score'];const f=d['info']['name']['length'],g=e['info']['name']['length'];if(f!==g)return f-g;return d['info']['name']['localeCompare'](e['info']['name']);})['map'](({info:d})=>d);}}
|