wowok 1.8.2 → 2.1.9
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/README.md +4 -33
- package/dist/cjs/bcs/bcs.d.ts +1973 -0
- package/dist/cjs/bcs/bcs.js +327 -0
- package/dist/cjs/bcs/effects.d.ts +579 -0
- package/dist/cjs/bcs/effects.js +231 -0
- package/dist/cjs/bcs/index.d.ts +2589 -0
- package/dist/cjs/bcs/index.js +79 -0
- package/dist/cjs/bcs/pure.d.ts +22 -0
- package/dist/cjs/bcs/pure.js +62 -0
- package/dist/cjs/bcs/type-tag-serializer.d.ts +7 -0
- package/dist/cjs/bcs/type-tag-serializer.js +124 -0
- package/dist/cjs/bcs/types.d.ts +114 -0
- package/dist/cjs/bcs/types.js +26 -0
- package/dist/cjs/client/index.d.ts +5 -0
- package/dist/cjs/client/index.js +34 -0
- package/dist/cjs/client/network.d.ts +5 -0
- package/dist/cjs/client/network.js +43 -0
- package/dist/cjs/cryptography/index.d.ts +7 -0
- package/dist/cjs/cryptography/index.js +46 -0
- package/dist/cjs/cryptography/intent.d.ts +6 -0
- package/dist/cjs/cryptography/intent.js +34 -0
- package/dist/cjs/cryptography/keypair.d.ts +73 -0
- package/dist/cjs/cryptography/keypair.js +125 -0
- package/dist/cjs/cryptography/mnemonics.d.ts +27 -0
- package/dist/cjs/cryptography/mnemonics.js +50 -0
- package/dist/cjs/cryptography/publickey.d.ts +67 -0
- package/dist/cjs/cryptography/publickey.js +142 -0
- package/dist/cjs/cryptography/signature-scheme.d.ts +24 -0
- package/dist/cjs/cryptography/signature-scheme.js +47 -0
- package/dist/cjs/cryptography/signature.d.ts +62 -0
- package/dist/cjs/cryptography/signature.js +71 -0
- package/dist/cjs/experimental/cache.d.ts +12 -0
- package/dist/cjs/experimental/client.d.ts +12 -0
- package/dist/cjs/experimental/core.d.ts +33 -0
- package/dist/cjs/experimental/errors.d.ts +8 -0
- package/dist/cjs/experimental/index.d.ts +7 -0
- package/dist/cjs/experimental/persistent-storage.d.ts +134 -0
- package/dist/cjs/experimental/persistent-storage.test.d.ts +5 -0
- package/dist/cjs/experimental/transports/utils.d.ts +3 -0
- package/dist/cjs/experimental/types.d.ts +367 -0
- package/dist/cjs/faucet/faucet.d.ts +66 -0
- package/dist/cjs/faucet/faucet.js +138 -0
- package/dist/cjs/faucet/index.d.ts +1 -0
- package/dist/cjs/faucet/index.js +29 -0
- package/dist/cjs/graphql/client.js +98 -0
- package/dist/cjs/graphql/core.js +506 -0
- package/dist/cjs/graphql/generated/2024.1/tada-env.js +13141 -0
- package/dist/cjs/graphql/generated/2024.1/tsconfig.tada.js +11 -0
- package/dist/cjs/graphql/generated/2024.4/tada-env.js +13287 -0
- package/dist/cjs/graphql/generated/2024.4/tsconfig.tada.js +11 -0
- package/dist/cjs/graphql/generated/latest/tada-env.js +12925 -0
- package/dist/cjs/graphql/generated/latest/tsconfig.tada.js +11 -0
- package/dist/cjs/graphql/generated/queries.js +807 -0
- package/dist/cjs/graphql/index.js +25 -0
- package/dist/cjs/graphql/schemas/2024.1/index.js +28 -0
- package/dist/cjs/graphql/schemas/2024.4/index.js +28 -0
- package/dist/cjs/graphql/schemas/latest/index.js +28 -0
- package/dist/cjs/graphql/types.js +16 -0
- package/dist/cjs/grpc/client.d.ts +32 -0
- package/dist/cjs/grpc/client.js +64 -0
- package/dist/cjs/grpc/core.d.ts +28 -0
- package/dist/cjs/grpc/core.js +645 -0
- package/dist/cjs/grpc/index.d.ts +4 -0
- package/dist/cjs/grpc/index.js +26 -0
- package/dist/cjs/grpc/proto/google/protobuf/any.d.ts +173 -0
- package/dist/cjs/grpc/proto/google/protobuf/any.js +138 -0
- package/dist/cjs/grpc/proto/google/protobuf/duration.d.ts +104 -0
- package/dist/cjs/grpc/proto/google/protobuf/duration.js +94 -0
- package/dist/cjs/grpc/proto/google/protobuf/empty.d.ts +25 -0
- package/dist/cjs/grpc/proto/google/protobuf/empty.js +30 -0
- package/dist/cjs/grpc/proto/google/protobuf/field_mask.d.ts +231 -0
- package/dist/cjs/grpc/proto/google/protobuf/field_mask.js +77 -0
- package/dist/cjs/grpc/proto/google/protobuf/struct.d.ts +169 -0
- package/dist/cjs/grpc/proto/google/protobuf/struct.js +224 -0
- package/dist/cjs/grpc/proto/google/protobuf/timestamp.d.ts +145 -0
- package/dist/cjs/grpc/proto/google/protobuf/timestamp.js +134 -0
- package/dist/cjs/grpc/proto/google/rpc/error_details.d.ts +525 -0
- package/dist/cjs/grpc/proto/google/rpc/error_details.js +317 -0
- package/dist/cjs/grpc/proto/google/rpc/status.d.ts +46 -0
- package/dist/cjs/grpc/proto/google/rpc/status.js +52 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/argument.d.ts +66 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/argument.js +70 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/balance_change.d.ts +34 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/balance_change.js +52 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/bcs.d.ts +30 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/bcs.js +45 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint.d.ts +68 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint.js +77 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_contents.d.ts +74 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_contents.js +84 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_summary.d.ts +195 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_summary.js +170 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/effects.d.ts +338 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/effects.js +300 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/epoch.d.ts +62 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/epoch.js +87 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/error_reason.d.ts +17 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/error_reason.js +29 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/event.d.ts +88 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/event.js +86 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/executed_transaction.d.ts +80 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/executed_transaction.js +87 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/execution_status.d.ts +843 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/execution_status.js +519 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/gas_cost_summary.d.ts +41 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/gas_cost_summary.js +63 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/input.d.ts +98 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/input.js +85 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/jwk.d.ts +70 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/jwk.js +81 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.client.d.ts +95 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.client.js +122 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.d.ts +420 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.js +368 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package.d.ts +579 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package.js +485 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.client.d.ts +61 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.client.js +81 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.d.ts +229 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.js +241 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.client.d.ts +41 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.client.js +55 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.d.ts +144 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.js +141 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/object.d.ts +127 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/object.js +114 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/object_reference.d.ts +34 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/object_reference.js +53 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/owner.d.ts +61 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/owner.js +63 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/protocol_config.d.ts +30 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/protocol_config.js +61 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature.d.ts +630 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature.js +541 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_scheme.d.ts +40 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_scheme.js +33 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.ts +35 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.client.js +50 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.d.ts +79 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.js +90 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.client.d.ts +71 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.client.js +88 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.d.ts +690 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.js +546 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.client.d.ts +55 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.client.js +54 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.d.ts +57 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.js +65 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/system_state.d.ts +684 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/system_state.js +740 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction.d.ts +1321 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction.js +1005 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.ts +41 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.client.js +49 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.d.ts +184 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.js +177 -0
- package/dist/cjs/index.d.ts +25 -0
- package/dist/cjs/index.js +93 -0
- package/dist/cjs/jsonRpc/client.d.ts +261 -0
- package/dist/cjs/jsonRpc/client.js +747 -0
- package/dist/cjs/jsonRpc/core.d.ts +87 -0
- package/dist/cjs/jsonRpc/core.js +638 -0
- package/dist/cjs/jsonRpc/errors.d.ts +12 -0
- package/dist/cjs/jsonRpc/errors.js +65 -0
- package/dist/cjs/jsonRpc/http-transport.d.ts +42 -0
- package/dist/cjs/jsonRpc/http-transport.js +121 -0
- package/dist/cjs/jsonRpc/index.d.ts +4 -0
- package/dist/cjs/jsonRpc/index.js +31 -0
- package/dist/cjs/jsonRpc/json-rpc-resolver.d.ts +4 -0
- package/dist/cjs/jsonRpc/json-rpc-resolver.js +321 -0
- package/dist/cjs/jsonRpc/rpc-websocket-client.d.ts +43 -0
- package/dist/cjs/jsonRpc/rpc-websocket-client.js +220 -0
- package/dist/cjs/jsonRpc/types/chain.d.ts +99 -0
- package/dist/cjs/jsonRpc/types/chain.js +16 -0
- package/dist/cjs/jsonRpc/types/changes.d.ts +19 -0
- package/dist/cjs/jsonRpc/types/changes.js +16 -0
- package/dist/cjs/jsonRpc/types/coins.d.ts +6 -0
- package/dist/cjs/jsonRpc/types/coins.js +16 -0
- package/dist/cjs/jsonRpc/types/common.d.ts +2 -0
- package/dist/cjs/jsonRpc/types/common.js +16 -0
- package/dist/cjs/jsonRpc/types/generated.d.ts +1492 -0
- package/dist/cjs/jsonRpc/types/generated.js +16 -0
- package/dist/cjs/jsonRpc/types/index.d.ts +6 -0
- package/dist/cjs/jsonRpc/types/index.js +16 -0
- package/dist/cjs/jsonRpc/types/params.d.ts +656 -0
- package/dist/cjs/jsonRpc/types/params.js +16 -0
- package/dist/cjs/keypairs/ed25519/ed25519-hd-key.d.ts +8 -0
- package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js +82 -0
- package/dist/cjs/keypairs/ed25519/index.d.ts +2 -0
- package/dist/cjs/keypairs/ed25519/index.js +27 -0
- package/dist/cjs/keypairs/ed25519/keypair.d.ts +74 -0
- package/dist/cjs/keypairs/ed25519/keypair.js +169 -0
- package/dist/cjs/keypairs/ed25519/publickey.d.ts +30 -0
- package/dist/cjs/keypairs/ed25519/publickey.js +90 -0
- package/dist/cjs/keypairs/index.d.ts +4 -0
- package/dist/cjs/keypairs/index.js +21 -0
- package/dist/cjs/keypairs/passkey/index.d.ts +3 -0
- package/dist/cjs/keypairs/passkey/index.js +28 -0
- package/dist/cjs/keypairs/passkey/keypair.d.ts +113 -0
- package/dist/cjs/keypairs/passkey/keypair.js +268 -0
- package/dist/cjs/keypairs/passkey/publickey.d.ts +72 -0
- package/dist/cjs/keypairs/passkey/publickey.js +175 -0
- package/dist/cjs/keypairs/passkey/types.d.ts +12 -0
- package/dist/cjs/keypairs/passkey/types.js +16 -0
- package/dist/cjs/keypairs/secp256k1/index.d.ts +2 -0
- package/dist/cjs/keypairs/secp256k1/index.js +27 -0
- package/dist/cjs/keypairs/secp256k1/keypair.d.ts +73 -0
- package/dist/cjs/keypairs/secp256k1/keypair.js +159 -0
- package/dist/cjs/keypairs/secp256k1/publickey.d.ts +30 -0
- package/dist/cjs/keypairs/secp256k1/publickey.js +95 -0
- package/dist/cjs/keypairs/secp256r1/index.d.ts +2 -0
- package/dist/cjs/keypairs/secp256r1/index.js +27 -0
- package/dist/cjs/keypairs/secp256r1/keypair.d.ts +73 -0
- package/dist/cjs/keypairs/secp256r1/keypair.js +155 -0
- package/dist/cjs/keypairs/secp256r1/publickey.d.ts +30 -0
- package/dist/cjs/keypairs/secp256r1/publickey.js +96 -0
- package/dist/cjs/multisig/index.d.ts +2 -0
- package/dist/cjs/multisig/index.js +27 -0
- package/dist/cjs/multisig/publickey.d.ts +79 -0
- package/dist/cjs/multisig/publickey.js +296 -0
- package/dist/cjs/multisig/signer.d.ts +20 -0
- package/dist/cjs/multisig/signer.js +114 -0
- package/dist/cjs/package.json +5 -0
- package/dist/cjs/transactions/Arguments.d.ts +57 -0
- package/dist/cjs/transactions/Arguments.js +36 -0
- package/dist/cjs/transactions/Commands.d.ts +57 -0
- package/dist/cjs/transactions/Commands.js +143 -0
- package/dist/cjs/transactions/Inputs.d.ts +22 -0
- package/dist/cjs/transactions/Inputs.js +87 -0
- package/dist/cjs/transactions/ObjectCache.d.ts +83 -0
- package/dist/cjs/transactions/ObjectCache.js +251 -0
- package/dist/cjs/transactions/Transaction.d.ts +710 -0
- package/dist/cjs/transactions/Transaction.js +742 -0
- package/dist/cjs/transactions/TransactionData.d.ts +73 -0
- package/dist/cjs/transactions/TransactionData.js +472 -0
- package/dist/cjs/transactions/__tests__/Transaction.test.d.ts +1 -0
- package/dist/cjs/transactions/__tests__/bcs.test.d.ts +1 -0
- package/dist/cjs/transactions/data/internal.d.ts +1010 -0
- package/dist/cjs/transactions/data/internal.js +230 -0
- package/dist/cjs/transactions/data/v1.d.ts +312 -0
- package/dist/cjs/transactions/data/v1.js +538 -0
- package/dist/cjs/transactions/data/v2.d.ts +153 -0
- package/dist/cjs/transactions/data/v2.js +124 -0
- package/dist/cjs/transactions/executor/caching.d.ts +31 -0
- package/dist/cjs/transactions/executor/caching.js +118 -0
- package/dist/cjs/transactions/executor/parallel.d.ts +37 -0
- package/dist/cjs/transactions/executor/parallel.js +395 -0
- package/dist/cjs/transactions/executor/queue.d.ts +11 -0
- package/dist/cjs/transactions/executor/queue.js +87 -0
- package/dist/cjs/transactions/executor/serial.d.ts +31 -0
- package/dist/cjs/transactions/executor/serial.js +136 -0
- package/dist/cjs/transactions/hash.d.ts +7 -0
- package/dist/cjs/transactions/hash.js +31 -0
- package/dist/cjs/transactions/index.d.ts +21 -0
- package/dist/cjs/transactions/index.js +50 -0
- package/dist/cjs/transactions/intents/CoinWithBalance.d.ts +9 -0
- package/dist/cjs/transactions/intents/CoinWithBalance.js +206 -0
- package/dist/cjs/transactions/object.d.ts +24 -0
- package/dist/cjs/transactions/object.js +116 -0
- package/dist/cjs/transactions/plugins/NamedPackagesPlugin.d.ts +31 -0
- package/dist/cjs/transactions/plugins/NamedPackagesPlugin.js +37 -0
- package/dist/cjs/transactions/pure.d.ts +20 -0
- package/dist/cjs/transactions/pure.js +64 -0
- package/dist/cjs/transactions/resolve.d.ts +13 -0
- package/dist/cjs/transactions/resolve.js +103 -0
- package/dist/cjs/transactions/serializer.d.ts +7 -0
- package/dist/cjs/transactions/serializer.js +189 -0
- package/dist/cjs/transactions/utils.d.ts +10 -0
- package/dist/cjs/transactions/utils.js +143 -0
- package/dist/cjs/utils/constants.d.ts +17 -0
- package/dist/cjs/utils/constants.js +57 -0
- package/dist/cjs/utils/derived-objects.d.ts +5 -0
- package/dist/cjs/utils/derived-objects.js +33 -0
- package/dist/cjs/utils/dynamic-fields.d.ts +2 -0
- package/dist/cjs/utils/dynamic-fields.js +40 -0
- package/dist/cjs/utils/format.d.ts +2 -0
- package/dist/cjs/utils/format.js +35 -0
- package/dist/cjs/utils/index.d.ts +8 -0
- package/dist/cjs/utils/index.js +65 -0
- package/dist/cjs/utils/move-registry.d.ts +6 -0
- package/dist/cjs/utils/move-registry.js +44 -0
- package/dist/cjs/utils/sui-types.d.ts +26 -0
- package/dist/cjs/utils/sui-types.js +90 -0
- package/dist/cjs/utils/suins.d.ts +2 -0
- package/dist/cjs/utils/suins.js +56 -0
- package/dist/cjs/verify/index.d.ts +1 -0
- package/dist/cjs/verify/index.js +28 -0
- package/dist/cjs/verify/verify.d.ts +16 -0
- package/dist/cjs/verify/verify.js +125 -0
- package/dist/cjs/version.d.ts +2 -0
- package/dist/cjs/version.js +26 -0
- package/dist/cjs/w/call/allocation.d.ts +35 -0
- package/dist/cjs/w/call/allocation.js +439 -0
- package/dist/cjs/w/call/arb.d.ts +17 -0
- package/dist/cjs/w/call/arb.js +149 -0
- package/dist/cjs/w/call/arbitration.d.ts +106 -0
- package/dist/cjs/w/call/arbitration.js +1623 -0
- package/dist/cjs/w/call/base.d.ts +42 -0
- package/dist/cjs/w/call/base.js +363 -0
- package/dist/cjs/w/call/contact.d.ts +45 -0
- package/dist/cjs/w/call/contact.js +479 -0
- package/dist/cjs/w/call/demand.d.ts +79 -0
- package/dist/cjs/w/call/demand.js +872 -0
- package/dist/cjs/w/call/entity.d.ts +33 -0
- package/dist/cjs/w/call/entity.js +230 -0
- package/dist/cjs/w/call/guard-ins.d.ts +31 -0
- package/dist/cjs/w/call/guard-ins.js +4391 -0
- package/dist/cjs/w/call/guard.d.ts +254 -0
- package/dist/cjs/w/call/guard.js +1210 -0
- package/dist/cjs/w/call/index.d.ts +37 -0
- package/dist/cjs/w/call/index.js +71 -0
- package/dist/cjs/w/call/machine.d.ts +124 -0
- package/dist/cjs/w/call/machine.js +1486 -0
- package/dist/cjs/w/call/order.d.ts +73 -0
- package/dist/cjs/w/call/order.js +485 -0
- package/dist/cjs/w/call/passport.d.ts +24 -0
- package/dist/cjs/w/call/passport.js +281 -0
- package/dist/cjs/w/call/payment.d.ts +27 -0
- package/dist/cjs/w/call/payment.js +241 -0
- package/dist/cjs/w/call/permission.d.ts +222 -0
- package/dist/cjs/w/call/permission.js +1368 -0
- package/dist/cjs/w/call/personal.d.ts +51 -0
- package/dist/cjs/w/call/personal.js +184 -0
- package/dist/cjs/w/call/progress.d.ts +94 -0
- package/dist/cjs/w/call/progress.js +833 -0
- package/dist/cjs/w/call/proof.d.ts +27 -0
- package/dist/cjs/w/call/proof.js +124 -0
- package/dist/cjs/w/call/repository.d.ts +97 -0
- package/dist/cjs/w/call/repository.js +1324 -0
- package/dist/cjs/w/call/resource.d.ts +27 -0
- package/dist/cjs/w/call/resource.js +149 -0
- package/dist/cjs/w/call/reward.d.ts +52 -0
- package/dist/cjs/w/call/reward.js +879 -0
- package/dist/cjs/w/call/service.d.ts +184 -0
- package/dist/cjs/w/call/service.js +2468 -0
- package/dist/cjs/w/call/treasury.d.ts +77 -0
- package/dist/cjs/w/call/treasury.js +1192 -0
- package/dist/cjs/w/call/util.d.ts +12 -0
- package/dist/cjs/w/call/util.js +661 -0
- package/dist/cjs/w/common.d.ts +359 -0
- package/dist/cjs/w/common.js +625 -0
- package/dist/cjs/w/exception.d.ts +82 -0
- package/dist/cjs/w/exception.js +604 -0
- package/dist/cjs/w/index.d.ts +8 -0
- package/dist/cjs/w/index.js +25 -0
- package/dist/cjs/w/local/.eslintrc.js +15 -0
- package/dist/cjs/w/local/account.d.ts +134 -0
- package/dist/cjs/w/local/account.js +770 -0
- package/dist/cjs/w/local/cache.d.ts +35 -0
- package/dist/cjs/w/local/cache.js +181 -0
- package/dist/cjs/w/local/config.d.ts +15 -0
- package/dist/cjs/w/local/config.js +83 -0
- package/dist/cjs/w/local/index.d.ts +193 -0
- package/dist/cjs/w/local/index.js +322 -0
- package/dist/cjs/w/local/local.d.ts +93 -0
- package/dist/cjs/w/local/local.js +673 -0
- package/dist/cjs/w/local/storage.d.ts +61 -0
- package/dist/cjs/w/local/storage.js +219 -0
- package/dist/cjs/w/local/token.d.ts +22 -0
- package/dist/cjs/w/local/token.js +182 -0
- package/dist/cjs/w/local/util.d.ts +5 -0
- package/dist/cjs/w/local/util.js +57 -0
- package/dist/cjs/w/local/wip.d.ts +218 -0
- package/dist/cjs/w/local/wip.js +911 -0
- package/dist/cjs/w/messenger/.eslintrc.js +15 -0
- package/dist/cjs/w/messenger/crypto.d.ts +269 -0
- package/dist/cjs/w/messenger/crypto.js +448 -0
- package/dist/cjs/w/messenger/index.d.ts +23 -0
- package/dist/cjs/w/messenger/index.js +37 -0
- package/dist/cjs/w/messenger/messenger-api.d.ts +225 -0
- package/dist/cjs/w/messenger/messenger-api.js +1247 -0
- package/dist/cjs/w/messenger/messenger-manager.d.ts +80 -0
- package/dist/cjs/w/messenger/messenger-manager.js +1143 -0
- package/dist/cjs/w/messenger/messenger.d.ts +231 -0
- package/dist/cjs/w/messenger/messenger.js +1512 -0
- package/dist/cjs/w/messenger/server.d.ts +134 -0
- package/dist/cjs/w/messenger/server.js +535 -0
- package/dist/cjs/w/messenger/session.d.ts +78 -0
- package/dist/cjs/w/messenger/session.js +418 -0
- package/dist/cjs/w/messenger/storage.d.ts +192 -0
- package/dist/cjs/w/messenger/storage.js +964 -0
- package/dist/cjs/w/messenger/types.d.ts +705 -0
- package/dist/cjs/w/messenger/types.js +107 -0
- package/dist/cjs/w/messenger/utils.d.ts +15 -0
- package/dist/cjs/w/messenger/utils.js +37 -0
- package/dist/cjs/w/query/bult-in.d.ts +73 -0
- package/dist/cjs/w/query/bult-in.js +121 -0
- package/dist/cjs/w/query/event.d.ts +82 -0
- package/dist/cjs/w/query/event.js +157 -0
- package/dist/cjs/w/query/index.d.ts +5 -0
- package/dist/cjs/w/query/index.js +22 -0
- package/dist/cjs/w/query/object.d.ts +658 -0
- package/dist/cjs/w/query/object.js +1671 -0
- package/dist/cjs/w/query/received.d.ts +34 -0
- package/dist/cjs/w/query/received.js +93 -0
- package/dist/cjs/w/query/util.d.ts +5 -0
- package/dist/cjs/w/query/util.js +82 -0
- package/dist/cjs/w/util.d.ts +19 -0
- package/dist/cjs/w/util.js +715 -0
- package/dist/cjs/zklogin/address.js +93 -0
- package/dist/cjs/zklogin/bcs.js +41 -0
- package/dist/cjs/zklogin/index.js +45 -0
- package/dist/cjs/zklogin/jwt-decode.js +88 -0
- package/dist/cjs/zklogin/jwt-utils.js +128 -0
- package/dist/cjs/zklogin/nonce.js +60 -0
- package/dist/cjs/zklogin/poseidon.js +64 -0
- package/dist/cjs/zklogin/publickey.js +281 -0
- package/dist/cjs/zklogin/signature.js +57 -0
- package/dist/cjs/zklogin/utils.js +98 -0
- package/dist/esm/bcs/bcs.d.ts +1973 -0
- package/dist/esm/bcs/bcs.js +319 -0
- package/dist/esm/bcs/effects.d.ts +579 -0
- package/dist/esm/bcs/effects.js +211 -0
- package/dist/esm/bcs/index.d.ts +2589 -0
- package/dist/esm/bcs/index.js +98 -0
- package/dist/esm/bcs/pure.d.ts +22 -0
- package/dist/esm/bcs/pure.js +42 -0
- package/dist/esm/bcs/type-tag-serializer.d.ts +7 -0
- package/dist/esm/bcs/type-tag-serializer.js +104 -0
- package/dist/esm/bcs/types.d.ts +114 -0
- package/dist/esm/bcs/types.js +6 -0
- package/dist/esm/client/index.d.ts +5 -0
- package/dist/esm/client/index.js +23 -0
- package/dist/esm/client/network.d.ts +5 -0
- package/dist/esm/client/network.js +23 -0
- package/dist/esm/cryptography/index.d.ts +7 -0
- package/dist/esm/cryptography/index.js +46 -0
- package/dist/esm/cryptography/intent.d.ts +6 -0
- package/dist/esm/cryptography/intent.js +14 -0
- package/dist/esm/cryptography/keypair.d.ts +73 -0
- package/dist/esm/cryptography/keypair.js +108 -0
- package/dist/esm/cryptography/mnemonics.d.ts +27 -0
- package/dist/esm/cryptography/mnemonics.js +30 -0
- package/dist/esm/cryptography/publickey.d.ts +67 -0
- package/dist/esm/cryptography/publickey.js +125 -0
- package/dist/esm/cryptography/signature-scheme.d.ts +24 -0
- package/dist/esm/cryptography/signature-scheme.js +27 -0
- package/dist/esm/cryptography/signature.d.ts +62 -0
- package/dist/esm/cryptography/signature.js +54 -0
- package/dist/esm/experimental/cache.d.ts +12 -0
- package/dist/esm/experimental/client.d.ts +12 -0
- package/dist/esm/experimental/core.d.ts +33 -0
- package/dist/esm/experimental/errors.d.ts +8 -0
- package/dist/esm/experimental/index.d.ts +7 -0
- package/dist/esm/experimental/persistent-storage.d.ts +134 -0
- package/dist/esm/experimental/persistent-storage.test.d.ts +5 -0
- package/dist/esm/experimental/transports/utils.d.ts +3 -0
- package/dist/esm/experimental/types.d.ts +367 -0
- package/dist/esm/faucet/faucet.d.ts +66 -0
- package/dist/esm/faucet/faucet.js +118 -0
- package/dist/esm/faucet/index.d.ts +1 -0
- package/dist/esm/faucet/index.js +16 -0
- package/dist/esm/graphql/client.js +79 -0
- package/dist/esm/graphql/core.js +505 -0
- package/dist/esm/graphql/generated/2024.1/tada-env.js +13121 -0
- package/dist/esm/graphql/generated/2024.1/tsconfig.tada.js +16 -0
- package/dist/esm/graphql/generated/2024.4/tada-env.js +13267 -0
- package/dist/esm/graphql/generated/2024.4/tsconfig.tada.js +16 -0
- package/dist/esm/graphql/generated/latest/tada-env.js +12905 -0
- package/dist/esm/graphql/generated/latest/tsconfig.tada.js +16 -0
- package/dist/esm/graphql/generated/queries.js +788 -0
- package/dist/esm/graphql/index.js +8 -0
- package/dist/esm/graphql/schemas/2024.1/index.js +8 -0
- package/dist/esm/graphql/schemas/2024.4/index.js +8 -0
- package/dist/esm/graphql/schemas/latest/index.js +8 -0
- package/dist/esm/graphql/types.js +0 -0
- package/dist/esm/grpc/client.d.ts +32 -0
- package/dist/esm/grpc/client.js +45 -0
- package/dist/esm/grpc/core.d.ts +28 -0
- package/dist/esm/grpc/core.js +634 -0
- package/dist/esm/grpc/index.d.ts +4 -0
- package/dist/esm/grpc/index.js +6 -0
- package/dist/esm/grpc/proto/google/protobuf/any.d.ts +173 -0
- package/dist/esm/grpc/proto/google/protobuf/any.js +118 -0
- package/dist/esm/grpc/proto/google/protobuf/duration.d.ts +104 -0
- package/dist/esm/grpc/proto/google/protobuf/duration.js +74 -0
- package/dist/esm/grpc/proto/google/protobuf/empty.d.ts +25 -0
- package/dist/esm/grpc/proto/google/protobuf/empty.js +10 -0
- package/dist/esm/grpc/proto/google/protobuf/field_mask.d.ts +231 -0
- package/dist/esm/grpc/proto/google/protobuf/field_mask.js +57 -0
- package/dist/esm/grpc/proto/google/protobuf/struct.d.ts +169 -0
- package/dist/esm/grpc/proto/google/protobuf/struct.js +204 -0
- package/dist/esm/grpc/proto/google/protobuf/timestamp.d.ts +145 -0
- package/dist/esm/grpc/proto/google/protobuf/timestamp.js +114 -0
- package/dist/esm/grpc/proto/google/rpc/error_details.d.ts +525 -0
- package/dist/esm/grpc/proto/google/rpc/error_details.js +297 -0
- package/dist/esm/grpc/proto/google/rpc/status.d.ts +46 -0
- package/dist/esm/grpc/proto/google/rpc/status.js +32 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/argument.d.ts +66 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/argument.js +50 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/balance_change.d.ts +34 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/balance_change.js +32 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/bcs.d.ts +30 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/bcs.js +25 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint.d.ts +68 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint.js +57 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_contents.d.ts +74 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_contents.js +64 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_summary.d.ts +195 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_summary.js +150 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/effects.d.ts +338 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/effects.js +280 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/epoch.d.ts +62 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/epoch.js +67 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/error_reason.d.ts +17 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/error_reason.js +9 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/event.d.ts +88 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/event.js +66 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/executed_transaction.d.ts +80 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/executed_transaction.js +67 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/execution_status.d.ts +843 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/execution_status.js +499 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/gas_cost_summary.d.ts +41 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/gas_cost_summary.js +43 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/input.d.ts +98 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/input.js +65 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/jwk.d.ts +70 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/jwk.js +61 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.client.d.ts +95 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.client.js +103 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.d.ts +420 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.js +348 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package.d.ts +579 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package.js +465 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.client.d.ts +61 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.client.js +62 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.d.ts +229 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.js +221 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/name_service.client.d.ts +41 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/name_service.client.js +36 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/name_service.d.ts +144 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/name_service.js +121 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/object.d.ts +127 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/object.js +94 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/object_reference.d.ts +34 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/object_reference.js +33 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/owner.d.ts +61 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/owner.js +43 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/protocol_config.d.ts +30 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/protocol_config.js +41 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/signature.d.ts +630 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/signature.js +521 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_scheme.d.ts +40 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_scheme.js +13 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.ts +35 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.client.js +31 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.d.ts +79 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.js +70 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/state_service.client.d.ts +71 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/state_service.client.js +69 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/state_service.d.ts +690 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/state_service.js +526 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.client.d.ts +55 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.client.js +35 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.d.ts +57 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.js +45 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/system_state.d.ts +684 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/system_state.js +720 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction.d.ts +1321 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction.js +985 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.ts +41 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.client.js +30 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.d.ts +184 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.js +157 -0
- package/dist/esm/index.d.ts +25 -0
- package/dist/esm/index.js +119 -0
- package/dist/esm/jsonRpc/client.d.ts +261 -0
- package/dist/esm/jsonRpc/client.js +734 -0
- package/dist/esm/jsonRpc/core.d.ts +87 -0
- package/dist/esm/jsonRpc/core.js +621 -0
- package/dist/esm/jsonRpc/errors.d.ts +12 -0
- package/dist/esm/jsonRpc/errors.js +46 -0
- package/dist/esm/jsonRpc/http-transport.d.ts +42 -0
- package/dist/esm/jsonRpc/http-transport.js +101 -0
- package/dist/esm/jsonRpc/index.d.ts +4 -0
- package/dist/esm/jsonRpc/index.js +20 -0
- package/dist/esm/jsonRpc/json-rpc-resolver.d.ts +4 -0
- package/dist/esm/jsonRpc/json-rpc-resolver.js +309 -0
- package/dist/esm/jsonRpc/rpc-websocket-client.d.ts +43 -0
- package/dist/esm/jsonRpc/rpc-websocket-client.js +201 -0
- package/dist/esm/jsonRpc/types/chain.d.ts +99 -0
- package/dist/esm/jsonRpc/types/chain.js +0 -0
- package/dist/esm/jsonRpc/types/changes.d.ts +19 -0
- package/dist/esm/jsonRpc/types/changes.js +0 -0
- package/dist/esm/jsonRpc/types/coins.d.ts +6 -0
- package/dist/esm/jsonRpc/types/coins.js +0 -0
- package/dist/esm/jsonRpc/types/common.d.ts +2 -0
- package/dist/esm/jsonRpc/types/common.js +0 -0
- package/dist/esm/jsonRpc/types/generated.d.ts +1492 -0
- package/dist/esm/jsonRpc/types/generated.js +0 -0
- package/dist/esm/jsonRpc/types/index.d.ts +6 -0
- package/dist/esm/jsonRpc/types/index.js +0 -0
- package/dist/esm/jsonRpc/types/params.d.ts +656 -0
- package/dist/esm/jsonRpc/types/params.js +0 -0
- package/dist/esm/keypairs/ed25519/ed25519-hd-key.d.ts +8 -0
- package/dist/esm/keypairs/ed25519/ed25519-hd-key.js +62 -0
- package/dist/esm/keypairs/ed25519/index.d.ts +2 -0
- package/dist/esm/keypairs/ed25519/index.js +10 -0
- package/dist/esm/keypairs/ed25519/keypair.d.ts +74 -0
- package/dist/esm/keypairs/ed25519/keypair.js +158 -0
- package/dist/esm/keypairs/ed25519/publickey.d.ts +30 -0
- package/dist/esm/keypairs/ed25519/publickey.js +75 -0
- package/dist/esm/keypairs/index.d.ts +4 -0
- package/dist/esm/keypairs/index.js +4 -0
- package/dist/esm/keypairs/passkey/index.d.ts +3 -0
- package/dist/esm/keypairs/passkey/index.js +12 -0
- package/dist/esm/keypairs/passkey/keypair.d.ts +113 -0
- package/dist/esm/keypairs/passkey/keypair.js +258 -0
- package/dist/esm/keypairs/passkey/publickey.d.ts +72 -0
- package/dist/esm/keypairs/passkey/publickey.js +156 -0
- package/dist/esm/keypairs/passkey/types.d.ts +12 -0
- package/dist/esm/keypairs/passkey/types.js +0 -0
- package/dist/esm/keypairs/secp256k1/index.d.ts +2 -0
- package/dist/esm/keypairs/secp256k1/index.js +10 -0
- package/dist/esm/keypairs/secp256k1/keypair.d.ts +73 -0
- package/dist/esm/keypairs/secp256k1/keypair.js +147 -0
- package/dist/esm/keypairs/secp256k1/publickey.d.ts +30 -0
- package/dist/esm/keypairs/secp256k1/publickey.js +80 -0
- package/dist/esm/keypairs/secp256r1/index.d.ts +2 -0
- package/dist/esm/keypairs/secp256r1/index.js +10 -0
- package/dist/esm/keypairs/secp256r1/keypair.d.ts +73 -0
- package/dist/esm/keypairs/secp256r1/keypair.js +143 -0
- package/dist/esm/keypairs/secp256r1/publickey.d.ts +30 -0
- package/dist/esm/keypairs/secp256r1/publickey.js +77 -0
- package/dist/esm/multisig/index.d.ts +2 -0
- package/dist/esm/multisig/index.js +10 -0
- package/dist/esm/multisig/publickey.d.ts +79 -0
- package/dist/esm/multisig/publickey.js +280 -0
- package/dist/esm/multisig/signer.d.ts +20 -0
- package/dist/esm/multisig/signer.js +94 -0
- package/dist/esm/package.json +5 -0
- package/dist/esm/transactions/Arguments.d.ts +57 -0
- package/dist/esm/transactions/Arguments.js +16 -0
- package/dist/esm/transactions/Commands.d.ts +57 -0
- package/dist/esm/transactions/Commands.js +123 -0
- package/dist/esm/transactions/Inputs.d.ts +22 -0
- package/dist/esm/transactions/Inputs.js +67 -0
- package/dist/esm/transactions/ObjectCache.d.ts +83 -0
- package/dist/esm/transactions/ObjectCache.js +231 -0
- package/dist/esm/transactions/Transaction.d.ts +710 -0
- package/dist/esm/transactions/Transaction.js +731 -0
- package/dist/esm/transactions/TransactionData.d.ts +73 -0
- package/dist/esm/transactions/TransactionData.js +453 -0
- package/dist/esm/transactions/__tests__/Transaction.test.d.ts +1 -0
- package/dist/esm/transactions/__tests__/bcs.test.d.ts +1 -0
- package/dist/esm/transactions/data/internal.d.ts +1010 -0
- package/dist/esm/transactions/data/internal.js +232 -0
- package/dist/esm/transactions/data/v1.d.ts +312 -0
- package/dist/esm/transactions/data/v1.js +542 -0
- package/dist/esm/transactions/data/v2.d.ts +153 -0
- package/dist/esm/transactions/data/v2.js +126 -0
- package/dist/esm/transactions/executor/caching.d.ts +31 -0
- package/dist/esm/transactions/executor/caching.js +99 -0
- package/dist/esm/transactions/executor/parallel.d.ts +37 -0
- package/dist/esm/transactions/executor/parallel.js +375 -0
- package/dist/esm/transactions/executor/queue.d.ts +11 -0
- package/dist/esm/transactions/executor/queue.js +68 -0
- package/dist/esm/transactions/executor/serial.d.ts +31 -0
- package/dist/esm/transactions/executor/serial.js +116 -0
- package/dist/esm/transactions/hash.d.ts +7 -0
- package/dist/esm/transactions/hash.js +11 -0
- package/dist/esm/transactions/index.d.ts +21 -0
- package/dist/esm/transactions/index.js +41 -0
- package/dist/esm/transactions/intents/CoinWithBalance.d.ts +9 -0
- package/dist/esm/transactions/intents/CoinWithBalance.js +186 -0
- package/dist/esm/transactions/object.d.ts +24 -0
- package/dist/esm/transactions/object.js +96 -0
- package/dist/esm/transactions/plugins/NamedPackagesPlugin.d.ts +31 -0
- package/dist/esm/transactions/plugins/NamedPackagesPlugin.js +17 -0
- package/dist/esm/transactions/pure.d.ts +20 -0
- package/dist/esm/transactions/pure.js +44 -0
- package/dist/esm/transactions/resolve.d.ts +13 -0
- package/dist/esm/transactions/resolve.js +83 -0
- package/dist/esm/transactions/serializer.d.ts +7 -0
- package/dist/esm/transactions/serializer.js +169 -0
- package/dist/esm/transactions/utils.d.ts +10 -0
- package/dist/esm/transactions/utils.js +123 -0
- package/dist/esm/utils/constants.d.ts +17 -0
- package/dist/esm/utils/constants.js +37 -0
- package/dist/esm/utils/derived-objects.d.ts +5 -0
- package/dist/esm/utils/derived-objects.js +13 -0
- package/dist/esm/utils/dynamic-fields.d.ts +2 -0
- package/dist/esm/utils/dynamic-fields.js +20 -0
- package/dist/esm/utils/format.d.ts +2 -0
- package/dist/esm/utils/format.js +15 -0
- package/dist/esm/utils/index.d.ts +8 -0
- package/dist/esm/utils/index.js +76 -0
- package/dist/esm/utils/move-registry.d.ts +6 -0
- package/dist/esm/utils/move-registry.js +24 -0
- package/dist/esm/utils/sui-types.d.ts +26 -0
- package/dist/esm/utils/sui-types.js +70 -0
- package/dist/esm/utils/suins.d.ts +2 -0
- package/dist/esm/utils/suins.js +36 -0
- package/dist/esm/verify/index.d.ts +1 -0
- package/dist/esm/verify/index.js +14 -0
- package/dist/esm/verify/verify.d.ts +16 -0
- package/dist/esm/verify/verify.js +108 -0
- package/dist/esm/version.d.ts +2 -0
- package/dist/esm/version.js +6 -0
- package/dist/esm/w/call/allocation.d.ts +35 -0
- package/dist/esm/w/call/allocation.js +433 -0
- package/dist/esm/w/call/arb.d.ts +17 -0
- package/dist/esm/w/call/arb.js +138 -0
- package/dist/esm/w/call/arbitration.d.ts +106 -0
- package/dist/esm/w/call/arbitration.js +1620 -0
- package/dist/esm/w/call/base.d.ts +42 -0
- package/dist/esm/w/call/base.js +350 -0
- package/dist/esm/w/call/contact.d.ts +45 -0
- package/dist/esm/w/call/contact.js +474 -0
- package/dist/esm/w/call/demand.d.ts +79 -0
- package/dist/esm/w/call/demand.js +869 -0
- package/dist/esm/w/call/entity.d.ts +33 -0
- package/dist/esm/w/call/entity.js +220 -0
- package/dist/esm/w/call/guard-ins.d.ts +31 -0
- package/dist/esm/w/call/guard-ins.js +4371 -0
- package/dist/esm/w/call/guard.d.ts +254 -0
- package/dist/esm/w/call/guard.js +1202 -0
- package/dist/esm/w/call/index.d.ts +37 -0
- package/dist/esm/w/call/index.js +57 -0
- package/dist/esm/w/call/machine.d.ts +124 -0
- package/dist/esm/w/call/machine.js +1492 -0
- package/dist/esm/w/call/order.d.ts +73 -0
- package/dist/esm/w/call/order.js +481 -0
- package/dist/esm/w/call/passport.d.ts +24 -0
- package/dist/esm/w/call/passport.js +266 -0
- package/dist/esm/w/call/payment.d.ts +27 -0
- package/dist/esm/w/call/payment.js +233 -0
- package/dist/esm/w/call/permission.d.ts +222 -0
- package/dist/esm/w/call/permission.js +1375 -0
- package/dist/esm/w/call/personal.d.ts +51 -0
- package/dist/esm/w/call/personal.js +177 -0
- package/dist/esm/w/call/progress.d.ts +94 -0
- package/dist/esm/w/call/progress.js +827 -0
- package/dist/esm/w/call/proof.d.ts +27 -0
- package/dist/esm/w/call/proof.js +110 -0
- package/dist/esm/w/call/repository.d.ts +97 -0
- package/dist/esm/w/call/repository.js +1325 -0
- package/dist/esm/w/call/resource.d.ts +27 -0
- package/dist/esm/w/call/resource.js +135 -0
- package/dist/esm/w/call/reward.d.ts +52 -0
- package/dist/esm/w/call/reward.js +874 -0
- package/dist/esm/w/call/service.d.ts +184 -0
- package/dist/esm/w/call/service.js +2472 -0
- package/dist/esm/w/call/treasury.d.ts +77 -0
- package/dist/esm/w/call/treasury.js +1186 -0
- package/dist/esm/w/call/util.d.ts +12 -0
- package/dist/esm/w/call/util.js +646 -0
- package/dist/esm/w/common.d.ts +359 -0
- package/dist/esm/w/common.js +605 -0
- package/dist/esm/w/exception.d.ts +82 -0
- package/dist/esm/w/exception.js +585 -0
- package/dist/esm/w/index.d.ts +8 -0
- package/dist/esm/w/index.js +8 -0
- package/dist/esm/w/local/.eslintrc.js +23 -0
- package/dist/esm/w/local/account.d.ts +134 -0
- package/dist/esm/w/local/account.js +746 -0
- package/dist/esm/w/local/cache.d.ts +35 -0
- package/dist/esm/w/local/cache.js +162 -0
- package/dist/esm/w/local/config.d.ts +15 -0
- package/dist/esm/w/local/config.js +64 -0
- package/dist/esm/w/local/index.d.ts +193 -0
- package/dist/esm/w/local/index.js +301 -0
- package/dist/esm/w/local/local.d.ts +93 -0
- package/dist/esm/w/local/local.js +654 -0
- package/dist/esm/w/local/storage.d.ts +61 -0
- package/dist/esm/w/local/storage.js +190 -0
- package/dist/esm/w/local/token.d.ts +22 -0
- package/dist/esm/w/local/token.js +163 -0
- package/dist/esm/w/local/util.d.ts +5 -0
- package/dist/esm/w/local/util.js +27 -0
- package/dist/esm/w/local/wip.d.ts +218 -0
- package/dist/esm/w/local/wip.js +882 -0
- package/dist/esm/w/messenger/.eslintrc.js +23 -0
- package/dist/esm/w/messenger/crypto.d.ts +269 -0
- package/dist/esm/w/messenger/crypto.js +428 -0
- package/dist/esm/w/messenger/index.d.ts +23 -0
- package/dist/esm/w/messenger/index.js +25 -0
- package/dist/esm/w/messenger/messenger-api.d.ts +225 -0
- package/dist/esm/w/messenger/messenger-api.js +1228 -0
- package/dist/esm/w/messenger/messenger-manager.d.ts +80 -0
- package/dist/esm/w/messenger/messenger-manager.js +1118 -0
- package/dist/esm/w/messenger/messenger.d.ts +231 -0
- package/dist/esm/w/messenger/messenger.js +1492 -0
- package/dist/esm/w/messenger/server.d.ts +134 -0
- package/dist/esm/w/messenger/server.js +520 -0
- package/dist/esm/w/messenger/session.d.ts +78 -0
- package/dist/esm/w/messenger/session.js +415 -0
- package/dist/esm/w/messenger/storage.d.ts +192 -0
- package/dist/esm/w/messenger/storage.js +935 -0
- package/dist/esm/w/messenger/types.d.ts +705 -0
- package/dist/esm/w/messenger/types.js +88 -0
- package/dist/esm/w/messenger/utils.d.ts +15 -0
- package/dist/esm/w/messenger/utils.js +17 -0
- package/dist/esm/w/query/bult-in.d.ts +73 -0
- package/dist/esm/w/query/bult-in.js +112 -0
- package/dist/esm/w/query/event.d.ts +82 -0
- package/dist/esm/w/query/event.js +137 -0
- package/dist/esm/w/query/index.d.ts +5 -0
- package/dist/esm/w/query/index.js +5 -0
- package/dist/esm/w/query/object.d.ts +658 -0
- package/dist/esm/w/query/object.js +1648 -0
- package/dist/esm/w/query/received.d.ts +34 -0
- package/dist/esm/w/query/received.js +73 -0
- package/dist/esm/w/query/util.d.ts +5 -0
- package/dist/esm/w/query/util.js +62 -0
- package/dist/esm/w/util.d.ts +19 -0
- package/dist/esm/w/util.js +710 -0
- package/dist/esm/zklogin/address.js +78 -0
- package/dist/esm/zklogin/bcs.js +21 -0
- package/dist/esm/zklogin/index.js +38 -0
- package/dist/esm/zklogin/jwt-decode.js +68 -0
- package/dist/esm/zklogin/jwt-utils.js +108 -0
- package/dist/esm/zklogin/nonce.js +40 -0
- package/dist/esm/zklogin/poseidon.js +61 -0
- package/dist/esm/zklogin/publickey.js +265 -0
- package/dist/esm/zklogin/signature.js +37 -0
- package/dist/esm/zklogin/utils.js +78 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +295 -61
- package/dist/arbitration.d.ts +0 -65
- package/dist/arbitration.d.ts.map +0 -1
- package/dist/arbitration.js +0 -517
- package/dist/arbitration.js.map +0 -1
- package/dist/demand.d.ts +0 -27
- package/dist/demand.d.ts.map +0 -1
- package/dist/demand.js +0 -266
- package/dist/demand.js.map +0 -1
- package/dist/entity.d.ts +0 -46
- package/dist/entity.d.ts.map +0 -1
- package/dist/entity.js +0 -146
- package/dist/entity.js.map +0 -1
- package/dist/exception.d.ts +0 -37
- package/dist/exception.d.ts.map +0 -1
- package/dist/exception.js +0 -41
- package/dist/exception.js.map +0 -1
- package/dist/guard.d.ts +0 -110
- package/dist/guard.d.ts.map +0 -1
- package/dist/guard.js +0 -936
- package/dist/guard.js.map +0 -1
- package/dist/index.d.ts +0 -40
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -28
- package/dist/index.js.map +0 -1
- package/dist/machine.d.ts +0 -68
- package/dist/machine.d.ts.map +0 -1
- package/dist/machine.js +0 -520
- package/dist/machine.js.map +0 -1
- package/dist/passport.d.ts +0 -129
- package/dist/passport.d.ts.map +0 -1
- package/dist/passport.js +0 -1233
- package/dist/passport.js.map +0 -1
- package/dist/payment.d.ts +0 -28
- package/dist/payment.d.ts.map +0 -1
- package/dist/payment.js +0 -60
- package/dist/payment.js.map +0 -1
- package/dist/permission.d.ts +0 -155
- package/dist/permission.d.ts.map +0 -1
- package/dist/permission.js +0 -462
- package/dist/permission.js.map +0 -1
- package/dist/progress.d.ts +0 -66
- package/dist/progress.d.ts.map +0 -1
- package/dist/progress.js +0 -311
- package/dist/progress.js.map +0 -1
- package/dist/protocol.d.ts +0 -247
- package/dist/protocol.d.ts.map +0 -1
- package/dist/protocol.js +0 -726
- package/dist/protocol.js.map +0 -1
- package/dist/repository.d.ts +0 -94
- package/dist/repository.d.ts.map +0 -1
- package/dist/repository.js +0 -783
- package/dist/repository.js.map +0 -1
- package/dist/resource.d.ts +0 -36
- package/dist/resource.d.ts.map +0 -1
- package/dist/resource.js +0 -129
- package/dist/resource.js.map +0 -1
- package/dist/service.d.ts +0 -144
- package/dist/service.d.ts.map +0 -1
- package/dist/service.js +0 -1303
- package/dist/service.js.map +0 -1
- package/dist/treasury.d.ts +0 -55
- package/dist/treasury.d.ts.map +0 -1
- package/dist/treasury.js +0 -393
- package/dist/treasury.js.map +0 -1
- package/dist/utils.d.ts +0 -94
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -582
- package/dist/utils.js.map +0 -1
- package/dist/wowok.d.ts +0 -15
- package/dist/wowok.d.ts.map +0 -1
- package/dist/wowok.js +0 -66
- package/dist/wowok.js.map +0 -1
|
@@ -0,0 +1,1118 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import { Messenger } from "./messenger.js";
|
|
5
|
+
import { MessageStorage } from "./storage.js";
|
|
6
|
+
import { MessengerPersistStorage } from "./storage.js";
|
|
7
|
+
import { MessageType, MessageStatus, WTS_MAX_MESSAGE_COUNT } from "./types.js";
|
|
8
|
+
import {
|
|
9
|
+
MessengerError,
|
|
10
|
+
MessengerErrorCode,
|
|
11
|
+
DEFAULT_MESSENGER_CONFIG
|
|
12
|
+
} from "./types.js";
|
|
13
|
+
import { canonicalizeJson } from "./utils.js";
|
|
14
|
+
import { MAX_MESSENGER_ACCOUNTS } from "../local/account.js";
|
|
15
|
+
import { GetAccountOrMark_Address } from "../local/index.js";
|
|
16
|
+
const MAX_ACCOUNTS = MAX_MESSENGER_ACCOUNTS;
|
|
17
|
+
class MessengerManager {
|
|
18
|
+
constructor(options) {
|
|
19
|
+
__publicField(this, "accounts", /* @__PURE__ */ new Map());
|
|
20
|
+
__publicField(this, "config");
|
|
21
|
+
__publicField(this, "messageListeners", /* @__PURE__ */ new Set());
|
|
22
|
+
__publicField(this, "pollingTimers", /* @__PURE__ */ new Map());
|
|
23
|
+
__publicField(this, "isWatching", false);
|
|
24
|
+
__publicField(this, "persistStorage");
|
|
25
|
+
__publicField(this, "instanceId");
|
|
26
|
+
__publicField(this, "accountRefreshTimer", null);
|
|
27
|
+
__publicField(this, "sseHeartbeatTimer", null);
|
|
28
|
+
__publicField(this, "sseLockedAccounts", /* @__PURE__ */ new Set());
|
|
29
|
+
this.config = {
|
|
30
|
+
...DEFAULT_MESSENGER_CONFIG,
|
|
31
|
+
...options?.messengerConfig
|
|
32
|
+
};
|
|
33
|
+
this.instanceId = options?.instanceId || "default";
|
|
34
|
+
this.persistStorage = new MessengerPersistStorage();
|
|
35
|
+
}
|
|
36
|
+
findAccount(address) {
|
|
37
|
+
return this.accounts.get(address.toLowerCase());
|
|
38
|
+
}
|
|
39
|
+
getConfig() {
|
|
40
|
+
return this.config;
|
|
41
|
+
}
|
|
42
|
+
get_accounts() {
|
|
43
|
+
return Array.from(this.accounts.values()).map((acc) => acc.address);
|
|
44
|
+
}
|
|
45
|
+
async refresh_accounts() {
|
|
46
|
+
const { Account } = await import("../local/account.js");
|
|
47
|
+
const messengerAccounts = await Account.Instance().list_messenger_accounts();
|
|
48
|
+
const currentAddresses = new Set(this.accounts.keys());
|
|
49
|
+
const newAddresses = new Set(
|
|
50
|
+
messengerAccounts.map((a) => a.address.toLowerCase())
|
|
51
|
+
);
|
|
52
|
+
for (const address of currentAddresses) {
|
|
53
|
+
if (!newAddresses.has(address)) {
|
|
54
|
+
this.remove_account_internal(address);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
for (const account of messengerAccounts) {
|
|
58
|
+
const addressLower = account.address.toLowerCase();
|
|
59
|
+
if (!this.accounts.has(addressLower)) {
|
|
60
|
+
await this.add_account_internal(account.address);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (this.accounts.size > 0 && !this.isWatching) {
|
|
64
|
+
this.startPolling();
|
|
65
|
+
} else if (this.accounts.size === 0 && this.isWatching) {
|
|
66
|
+
this.stopPolling();
|
|
67
|
+
}
|
|
68
|
+
await this.syncAllContactLists();
|
|
69
|
+
}
|
|
70
|
+
async start() {
|
|
71
|
+
await this.refresh_accounts();
|
|
72
|
+
let hasSSEFailure = false;
|
|
73
|
+
for (const account of this.accounts.values()) {
|
|
74
|
+
if (!account.messenger.isEventSourceConnected()) {
|
|
75
|
+
try {
|
|
76
|
+
const hasLock = this.persistStorage.tryAcquireSSELock(
|
|
77
|
+
account.address,
|
|
78
|
+
this.instanceId
|
|
79
|
+
);
|
|
80
|
+
if (hasLock) {
|
|
81
|
+
this.sseLockedAccounts.add(
|
|
82
|
+
account.address.toLowerCase()
|
|
83
|
+
);
|
|
84
|
+
await account.messenger.connectEventSource(
|
|
85
|
+
(messages) => {
|
|
86
|
+
for (const listener of this.messageListeners) {
|
|
87
|
+
listener(messages);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
} else {
|
|
92
|
+
console.debug(
|
|
93
|
+
`Another process holds SSE lock for ${account.address}, using polling`
|
|
94
|
+
);
|
|
95
|
+
hasSSEFailure = true;
|
|
96
|
+
}
|
|
97
|
+
} catch (err) {
|
|
98
|
+
console.warn(
|
|
99
|
+
`Failed to connect SSE for ${account.address}, falling back to polling:`,
|
|
100
|
+
err
|
|
101
|
+
);
|
|
102
|
+
hasSSEFailure = true;
|
|
103
|
+
this.persistStorage.releaseSSELock(
|
|
104
|
+
account.address,
|
|
105
|
+
this.instanceId
|
|
106
|
+
);
|
|
107
|
+
this.sseLockedAccounts.delete(
|
|
108
|
+
account.address.toLowerCase()
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (hasSSEFailure && !this.isWatching) {
|
|
114
|
+
this.startPolling();
|
|
115
|
+
}
|
|
116
|
+
this.startSSEHeartbeat();
|
|
117
|
+
if (this.accountRefreshTimer) {
|
|
118
|
+
clearInterval(this.accountRefreshTimer);
|
|
119
|
+
}
|
|
120
|
+
this.accountRefreshTimer = setInterval(() => {
|
|
121
|
+
this.refresh_accounts().catch((err) => {
|
|
122
|
+
console.error("Failed to refresh accounts:", err);
|
|
123
|
+
});
|
|
124
|
+
}, this.config.watch_interval_ms);
|
|
125
|
+
}
|
|
126
|
+
stop() {
|
|
127
|
+
if (this.accountRefreshTimer) {
|
|
128
|
+
clearInterval(this.accountRefreshTimer);
|
|
129
|
+
this.accountRefreshTimer = null;
|
|
130
|
+
}
|
|
131
|
+
this.stopSSEHeartbeat();
|
|
132
|
+
for (const accountAddress of this.sseLockedAccounts) {
|
|
133
|
+
this.persistStorage.releaseSSELock(accountAddress, this.instanceId);
|
|
134
|
+
}
|
|
135
|
+
this.sseLockedAccounts.clear();
|
|
136
|
+
this.stopPolling();
|
|
137
|
+
this.clear_accounts();
|
|
138
|
+
}
|
|
139
|
+
startSSEHeartbeat() {
|
|
140
|
+
if (this.sseHeartbeatTimer) {
|
|
141
|
+
clearInterval(this.sseHeartbeatTimer);
|
|
142
|
+
}
|
|
143
|
+
this.sseHeartbeatTimer = setInterval(() => {
|
|
144
|
+
for (const accountAddress of this.sseLockedAccounts) {
|
|
145
|
+
this.persistStorage.updateSSELockHeartbeat(
|
|
146
|
+
accountAddress,
|
|
147
|
+
this.instanceId
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
}, 5e3);
|
|
151
|
+
}
|
|
152
|
+
stopSSEHeartbeat() {
|
|
153
|
+
if (this.sseHeartbeatTimer) {
|
|
154
|
+
clearInterval(this.sseHeartbeatTimer);
|
|
155
|
+
this.sseHeartbeatTimer = null;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
async add_account_internal(address) {
|
|
159
|
+
const addressLower = address.toLowerCase();
|
|
160
|
+
if (this.accounts.size >= MAX_ACCOUNTS) {
|
|
161
|
+
throw new MessengerError(
|
|
162
|
+
MessengerErrorCode.INVALID_INPUT,
|
|
163
|
+
`Maximum ${MAX_ACCOUNTS} accounts allowed`
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
const messenger = new Messenger(addressLower, this.config);
|
|
167
|
+
try {
|
|
168
|
+
await messenger.initialize();
|
|
169
|
+
} catch (error) {
|
|
170
|
+
throw new MessengerError(
|
|
171
|
+
MessengerErrorCode.SERVER_ERROR,
|
|
172
|
+
`Failed to initialize account ${addressLower}: ${error instanceof Error ? error.message : String(error)}`
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
const contactLists = {
|
|
176
|
+
friends: [],
|
|
177
|
+
guards: [],
|
|
178
|
+
lastUpdatedAt: 0
|
|
179
|
+
};
|
|
180
|
+
this.accounts.set(addressLower, {
|
|
181
|
+
address: addressLower,
|
|
182
|
+
messenger,
|
|
183
|
+
initialized: true,
|
|
184
|
+
contactLists
|
|
185
|
+
});
|
|
186
|
+
if (this.isWatching) {
|
|
187
|
+
this.startAccountPolling(addressLower);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
remove_account_internal(address) {
|
|
191
|
+
const addressLower = address.toLowerCase();
|
|
192
|
+
const account = this.accounts.get(addressLower);
|
|
193
|
+
if (!account) return false;
|
|
194
|
+
if (account.initialized && account.messenger) {
|
|
195
|
+
account.messenger.disconnectEventSource();
|
|
196
|
+
account.messenger.disconnect();
|
|
197
|
+
}
|
|
198
|
+
const timer = this.pollingTimers.get(account.address);
|
|
199
|
+
if (timer) {
|
|
200
|
+
clearInterval(timer);
|
|
201
|
+
this.pollingTimers.delete(account.address);
|
|
202
|
+
}
|
|
203
|
+
this.persistStorage.releaseSSELock(addressLower, this.instanceId);
|
|
204
|
+
this.sseLockedAccounts.delete(addressLower);
|
|
205
|
+
return this.accounts.delete(addressLower);
|
|
206
|
+
}
|
|
207
|
+
clear_accounts() {
|
|
208
|
+
this.stopPolling();
|
|
209
|
+
for (const info of this.accounts.values()) {
|
|
210
|
+
info.messenger.disconnectEventSource();
|
|
211
|
+
info.messenger.disconnect();
|
|
212
|
+
}
|
|
213
|
+
this.accounts.clear();
|
|
214
|
+
}
|
|
215
|
+
async send(from, to, content, options) {
|
|
216
|
+
const { Account } = await import("../local/account.js");
|
|
217
|
+
let accountInfo = this.findAccount(from);
|
|
218
|
+
if (!accountInfo) {
|
|
219
|
+
const account = await Account.Instance().get(from, false);
|
|
220
|
+
if (!account) {
|
|
221
|
+
throw new MessengerError(
|
|
222
|
+
MessengerErrorCode.IDENTITY_NOT_FOUND,
|
|
223
|
+
`Account ${from} not found`
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
if (account.m == null) {
|
|
227
|
+
if (options?.new_messenger_name == null) {
|
|
228
|
+
throw new MessengerError(
|
|
229
|
+
MessengerErrorCode.ACCOUNT_MESSENGER_NOT_ENABLED,
|
|
230
|
+
`Account messenger name not set. Use new_messenger_name parameter to set it automatically.`
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
await Account.Instance().set_messenger(
|
|
234
|
+
from,
|
|
235
|
+
options.new_messenger_name
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
await this.refresh_accounts();
|
|
239
|
+
accountInfo = this.findAccount(from);
|
|
240
|
+
if (!accountInfo) {
|
|
241
|
+
throw new MessengerError(
|
|
242
|
+
MessengerErrorCode.SERVER_ERROR,
|
|
243
|
+
`Failed to add account ${from} to messenger manager`
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (options?.new_messenger_name != null) {
|
|
248
|
+
const account = await Account.Instance().get(from, false);
|
|
249
|
+
if (account && account.m !== options.new_messenger_name) {
|
|
250
|
+
await Account.Instance().set_messenger(
|
|
251
|
+
from,
|
|
252
|
+
options.new_messenger_name
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return accountInfo.messenger.sendMessage(to, content, {
|
|
257
|
+
guardAddress: options?.guardAddress,
|
|
258
|
+
passportAddress: options?.passportAddress,
|
|
259
|
+
force: options?.force
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
async send_file(from, to, filePath, options) {
|
|
263
|
+
const { Account } = await import("../local/account.js");
|
|
264
|
+
let accountInfo = this.findAccount(from);
|
|
265
|
+
if (!accountInfo) {
|
|
266
|
+
const account = await Account.Instance().get(from, false);
|
|
267
|
+
if (!account) {
|
|
268
|
+
throw new MessengerError(
|
|
269
|
+
MessengerErrorCode.IDENTITY_NOT_FOUND,
|
|
270
|
+
`Account ${from} not found`
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
if (account.m == null) {
|
|
274
|
+
if (options?.new_messenger_name == null) {
|
|
275
|
+
throw new MessengerError(
|
|
276
|
+
MessengerErrorCode.ACCOUNT_MESSENGER_NOT_ENABLED,
|
|
277
|
+
`Account messenger name not set. Use new_messenger_name parameter to set it automatically.`
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
await Account.Instance().set_messenger(
|
|
281
|
+
from,
|
|
282
|
+
options.new_messenger_name
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
await this.refresh_accounts();
|
|
286
|
+
accountInfo = this.findAccount(from);
|
|
287
|
+
if (!accountInfo) {
|
|
288
|
+
throw new MessengerError(
|
|
289
|
+
MessengerErrorCode.SERVER_ERROR,
|
|
290
|
+
`Failed to add account ${from} to messenger manager`
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (options?.new_messenger_name != null) {
|
|
295
|
+
const account = await Account.Instance().get(from, false);
|
|
296
|
+
if (account && account.m !== options.new_messenger_name) {
|
|
297
|
+
await Account.Instance().set_messenger(
|
|
298
|
+
from,
|
|
299
|
+
options.new_messenger_name
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return accountInfo.messenger.sendZipFile(to, filePath, {
|
|
304
|
+
fileName: options?.fileName,
|
|
305
|
+
contentType: options?.contentType,
|
|
306
|
+
guardAddress: options?.guardAddress,
|
|
307
|
+
passportAddress: options?.passportAddress,
|
|
308
|
+
force: options?.force
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
async watch(filter) {
|
|
312
|
+
let messages = [];
|
|
313
|
+
if (filter?.account) {
|
|
314
|
+
const address = filter.account.toLowerCase();
|
|
315
|
+
const messageStorage = new MessageStorage(address);
|
|
316
|
+
messages = messageStorage.getAllMessages(address);
|
|
317
|
+
} else {
|
|
318
|
+
for (const account of this.accounts.values()) {
|
|
319
|
+
const messageStorage = new MessageStorage(account.address);
|
|
320
|
+
const accountMessages = messageStorage.getAllMessages(
|
|
321
|
+
account.address
|
|
322
|
+
);
|
|
323
|
+
messages.push(...accountMessages);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (filter) {
|
|
327
|
+
const peerAddress = filter.peerAddress ? await GetAccountOrMark_Address(filter.peerAddress) : void 0;
|
|
328
|
+
messages = messages.filter((msg) => {
|
|
329
|
+
if (filter.account) {
|
|
330
|
+
const accountLower = filter.account.toLowerCase();
|
|
331
|
+
const fromLower = msg.fromAddress.toLowerCase();
|
|
332
|
+
const toLower = msg.toAddress.toLowerCase();
|
|
333
|
+
if (fromLower !== accountLower && toLower !== accountLower) {
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (filter.direction && msg.direction !== filter.direction) {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
if (filter.status && msg.status !== filter.status) {
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
if (filter.msgType !== void 0 && msg.msgType !== filter.msgType) {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
if (filter.contentType) {
|
|
347
|
+
switch (filter.contentType) {
|
|
348
|
+
case "text":
|
|
349
|
+
if (msg.msgType !== MessageType.NORMAL_MESSAGE)
|
|
350
|
+
return false;
|
|
351
|
+
break;
|
|
352
|
+
case "zip":
|
|
353
|
+
if (!msg.zipMetadata) return false;
|
|
354
|
+
break;
|
|
355
|
+
case "wts":
|
|
356
|
+
if (!msg.zipMetadata || msg.zipMetadata?.contentType !== "wts") {
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
break;
|
|
360
|
+
case "wip":
|
|
361
|
+
if (!msg.zipMetadata || msg.zipMetadata?.contentType !== "wip") {
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (filter.peerAddress && peerAddress) {
|
|
368
|
+
const peer = peerAddress.toLowerCase();
|
|
369
|
+
const from = msg.fromAddress.toLowerCase();
|
|
370
|
+
const to = msg.toAddress.toLowerCase();
|
|
371
|
+
if (from !== peer && to !== peer) {
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
const timeField = filter.timeField || "createdAt";
|
|
376
|
+
if (filter.startTime !== void 0 || filter.endTime !== void 0) {
|
|
377
|
+
const msgTime = msg[timeField];
|
|
378
|
+
if (msgTime !== void 0) {
|
|
379
|
+
if (filter.startTime !== void 0 && msgTime < filter.startTime) {
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
if (filter.endTime !== void 0 && msgTime > filter.endTime) {
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
if (filter.createdAtStart !== void 0 && msg.createdAt < filter.createdAtStart) {
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
if (filter.createdAtEnd !== void 0 && msg.createdAt > filter.createdAtEnd) {
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
if (filter.receivedAtStart !== void 0) {
|
|
394
|
+
if (msg.receivedAt === void 0 || msg.receivedAt < filter.receivedAtStart) {
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (filter.receivedAtEnd !== void 0) {
|
|
399
|
+
if (msg.receivedAt === void 0 || msg.receivedAt > filter.receivedAtEnd) {
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
if (filter.serverTimestampStart !== void 0) {
|
|
404
|
+
if (msg.serverTimestamp === void 0 || msg.serverTimestamp < filter.serverTimestampStart) {
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (filter.serverTimestampEnd !== void 0) {
|
|
409
|
+
if (msg.serverTimestamp === void 0 || msg.serverTimestamp > filter.serverTimestampEnd) {
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
if (filter.decryptedOnly && !msg.plaintext) {
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
if (filter.arkConfirmedOnly) {
|
|
417
|
+
if (!msg.arkConfirmed) {
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
if (filter.proofedOnly) {
|
|
422
|
+
if (!msg.proof) {
|
|
423
|
+
return false;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
if (filter.arkTimestampStart !== void 0) {
|
|
427
|
+
if (msg.arkConfirmed === void 0 || msg.arkConfirmed.timestamp < filter.arkTimestampStart) {
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
if (filter.arkTimestampEnd !== void 0) {
|
|
432
|
+
if (msg.arkConfirmed === void 0 || msg.arkConfirmed.timestamp > filter.arkTimestampEnd) {
|
|
433
|
+
return false;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
if (filter.hasLastReceivedIndexOnly) {
|
|
437
|
+
if (msg.lastReceivedLeafIndex === void 0 || msg.lastReceivedLeafIndex === null) {
|
|
438
|
+
return false;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
if (filter.lastReceivedIndexMin !== void 0) {
|
|
442
|
+
if (msg.lastReceivedLeafIndex === void 0 || msg.lastReceivedLeafIndex < filter.lastReceivedIndexMin) {
|
|
443
|
+
return false;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
if (filter.lastReceivedIndexMax !== void 0) {
|
|
447
|
+
if (msg.lastReceivedLeafIndex === void 0 || msg.lastReceivedLeafIndex > filter.lastReceivedIndexMax) {
|
|
448
|
+
return false;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
if (filter.keyword && msg.plaintext) {
|
|
452
|
+
if (!msg.plaintext.toLowerCase().includes(filter.keyword.toLowerCase())) {
|
|
453
|
+
return false;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
if (filter.listFilterMode && filter.listFilterMode !== "any") {
|
|
457
|
+
const msgAccount = this.findAccount(msg.toAddress);
|
|
458
|
+
if (!msgAccount) return false;
|
|
459
|
+
const senderAddress = msg.fromAddress.toLowerCase();
|
|
460
|
+
const lists = msgAccount.contactLists;
|
|
461
|
+
const friends = new Set(
|
|
462
|
+
lists.friends.map((a) => a.toLowerCase())
|
|
463
|
+
);
|
|
464
|
+
const guards = new Set(
|
|
465
|
+
lists.guards.map((g) => g.guardAddress.toLowerCase())
|
|
466
|
+
);
|
|
467
|
+
const inFriends = friends.has(senderAddress);
|
|
468
|
+
const inGuards = guards.has(senderAddress);
|
|
469
|
+
const isStranger = !inFriends && !inGuards;
|
|
470
|
+
switch (filter.listFilterMode) {
|
|
471
|
+
case "friends":
|
|
472
|
+
if (!inFriends) return false;
|
|
473
|
+
break;
|
|
474
|
+
case "guard":
|
|
475
|
+
if (!inGuards) return false;
|
|
476
|
+
break;
|
|
477
|
+
case "stranger":
|
|
478
|
+
if (!isStranger) return false;
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
if (filter.customListFilter) {
|
|
482
|
+
const {
|
|
483
|
+
includeAddresses,
|
|
484
|
+
excludeAddresses,
|
|
485
|
+
relation = "union"
|
|
486
|
+
} = filter.customListFilter;
|
|
487
|
+
if (excludeAddresses) {
|
|
488
|
+
const excludeSet = new Set(
|
|
489
|
+
excludeAddresses.map((a) => a.toLowerCase())
|
|
490
|
+
);
|
|
491
|
+
if (excludeSet.has(senderAddress)) return false;
|
|
492
|
+
}
|
|
493
|
+
if (includeAddresses && includeAddresses.length > 0) {
|
|
494
|
+
const includeSet = new Set(
|
|
495
|
+
includeAddresses.map((a) => a.toLowerCase())
|
|
496
|
+
);
|
|
497
|
+
const inIncludeList = includeSet.has(senderAddress);
|
|
498
|
+
if (relation === "union") {
|
|
499
|
+
const modeMatch = filter.listFilterMode === "friends" && inFriends || filter.listFilterMode === "guard" && inGuards || filter.listFilterMode === "stranger" && isStranger;
|
|
500
|
+
if (!inIncludeList && !modeMatch) return false;
|
|
501
|
+
} else {
|
|
502
|
+
if (!inIncludeList) return false;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
return true;
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
const sortOrder = filter?.sortOrder ?? "desc";
|
|
511
|
+
const sortField = filter?.timeField || "createdAt";
|
|
512
|
+
messages.sort((a, b) => {
|
|
513
|
+
const aTime = a[sortField] || 0;
|
|
514
|
+
const bTime = b[sortField] || 0;
|
|
515
|
+
return sortOrder === "asc" ? aTime - bTime : bTime - aTime;
|
|
516
|
+
});
|
|
517
|
+
const { MAX_QUERY_LIMIT } = await import("./types.js");
|
|
518
|
+
const defaultLimit = this.config.defaultQueryLimit ?? 50;
|
|
519
|
+
const limit = Math.min(filter?.limit ?? defaultLimit, MAX_QUERY_LIMIT);
|
|
520
|
+
const offset = filter?.offset ?? 0;
|
|
521
|
+
messages = messages.slice(offset, offset + limit);
|
|
522
|
+
return messages;
|
|
523
|
+
}
|
|
524
|
+
startPolling() {
|
|
525
|
+
if (this.isWatching) return;
|
|
526
|
+
this.isWatching = true;
|
|
527
|
+
for (const info of this.accounts.values()) {
|
|
528
|
+
const timer = setInterval(async () => {
|
|
529
|
+
try {
|
|
530
|
+
const messages = await info.messenger.pullMessages();
|
|
531
|
+
if (messages.length > 0) {
|
|
532
|
+
for (const listener of this.messageListeners) {
|
|
533
|
+
listener(messages);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
} catch (error) {
|
|
537
|
+
console.error(
|
|
538
|
+
`Failed to poll messages for ${info.address}:`,
|
|
539
|
+
error
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
}, this.config.watch_interval_ms);
|
|
543
|
+
this.pollingTimers.set(info.address, timer);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
startAccountPolling(address) {
|
|
547
|
+
const info = this.accounts.get(address.toLowerCase());
|
|
548
|
+
if (!info || !info.initialized) return;
|
|
549
|
+
const existingTimer = this.pollingTimers.get(info.address);
|
|
550
|
+
if (existingTimer) {
|
|
551
|
+
clearInterval(existingTimer);
|
|
552
|
+
}
|
|
553
|
+
const timer = setInterval(async () => {
|
|
554
|
+
try {
|
|
555
|
+
const messages = await info.messenger.pullMessages();
|
|
556
|
+
if (messages.length > 0) {
|
|
557
|
+
for (const listener of this.messageListeners) {
|
|
558
|
+
listener(messages);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
} catch (error) {
|
|
562
|
+
console.error(
|
|
563
|
+
`Failed to poll messages for ${info.address}:`,
|
|
564
|
+
error
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
}, this.config.watch_interval_ms);
|
|
568
|
+
this.pollingTimers.set(info.address, timer);
|
|
569
|
+
}
|
|
570
|
+
stopPolling() {
|
|
571
|
+
for (const timer of this.pollingTimers.values()) {
|
|
572
|
+
clearInterval(timer);
|
|
573
|
+
}
|
|
574
|
+
this.pollingTimers.clear();
|
|
575
|
+
this.isWatching = false;
|
|
576
|
+
}
|
|
577
|
+
onMessage(listener) {
|
|
578
|
+
this.messageListeners.add(listener);
|
|
579
|
+
}
|
|
580
|
+
offMessage(listener) {
|
|
581
|
+
this.messageListeners.delete(listener);
|
|
582
|
+
}
|
|
583
|
+
destroy() {
|
|
584
|
+
this.stop();
|
|
585
|
+
this.messageListeners.clear();
|
|
586
|
+
}
|
|
587
|
+
async syncContactLists(account) {
|
|
588
|
+
const acc = this.findAccount(account);
|
|
589
|
+
if (!acc) {
|
|
590
|
+
return {
|
|
591
|
+
success: false,
|
|
592
|
+
friends: [],
|
|
593
|
+
guards: [],
|
|
594
|
+
error: `Account not found: ${account}`
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
try {
|
|
598
|
+
const { Account } = await import("../local/account.js");
|
|
599
|
+
const accountData = await Account.Instance().get(account, false);
|
|
600
|
+
if (!accountData?.address) {
|
|
601
|
+
return {
|
|
602
|
+
success: false,
|
|
603
|
+
friends: [],
|
|
604
|
+
guards: [],
|
|
605
|
+
error: `Account data not found: ${account}`
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
const address = accountData.address;
|
|
609
|
+
const [friends, guards] = await Promise.all([
|
|
610
|
+
this.fetchFriendsList(address),
|
|
611
|
+
this.fetchGuardList(address)
|
|
612
|
+
]);
|
|
613
|
+
acc.contactLists = {
|
|
614
|
+
friends,
|
|
615
|
+
guards,
|
|
616
|
+
lastUpdatedAt: Date.now()
|
|
617
|
+
};
|
|
618
|
+
return {
|
|
619
|
+
success: true,
|
|
620
|
+
friends,
|
|
621
|
+
guards
|
|
622
|
+
};
|
|
623
|
+
} catch (error) {
|
|
624
|
+
console.error(
|
|
625
|
+
`Failed to sync contact lists for ${account}:`,
|
|
626
|
+
error
|
|
627
|
+
);
|
|
628
|
+
return {
|
|
629
|
+
success: false,
|
|
630
|
+
friends: acc.contactLists.friends,
|
|
631
|
+
guards: acc.contactLists.guards,
|
|
632
|
+
error: error instanceof Error ? error.message : String(error)
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
async syncAllContactLists() {
|
|
637
|
+
const results = /* @__PURE__ */ new Map();
|
|
638
|
+
for (const acc of this.accounts.values()) {
|
|
639
|
+
const result = await this.syncContactLists(acc.address);
|
|
640
|
+
results.set(acc.address, result);
|
|
641
|
+
}
|
|
642
|
+
return results;
|
|
643
|
+
}
|
|
644
|
+
getContactLists(account) {
|
|
645
|
+
const acc = this.findAccount(account);
|
|
646
|
+
return acc?.contactLists;
|
|
647
|
+
}
|
|
648
|
+
setContactLists(account, lists) {
|
|
649
|
+
const acc = this.findAccount(account);
|
|
650
|
+
if (!acc) return false;
|
|
651
|
+
acc.contactLists = {
|
|
652
|
+
...acc.contactLists,
|
|
653
|
+
...lists,
|
|
654
|
+
lastUpdatedAt: Date.now()
|
|
655
|
+
};
|
|
656
|
+
return true;
|
|
657
|
+
}
|
|
658
|
+
isStranger(account, senderAddress) {
|
|
659
|
+
const acc = this.findAccount(account);
|
|
660
|
+
if (!acc) return true;
|
|
661
|
+
const sender = senderAddress.toLowerCase();
|
|
662
|
+
const lists = acc.contactLists;
|
|
663
|
+
const inFriends = lists.friends.some((a) => a.toLowerCase() === sender);
|
|
664
|
+
const inGuards = lists.guards.some(
|
|
665
|
+
(g) => g.guardAddress.toLowerCase() === sender
|
|
666
|
+
);
|
|
667
|
+
return !inFriends && !inGuards;
|
|
668
|
+
}
|
|
669
|
+
recordGuardSender(account, guardAddress) {
|
|
670
|
+
const acc = this.findAccount(account);
|
|
671
|
+
if (!acc) return false;
|
|
672
|
+
const guardAddr = guardAddress.toLowerCase();
|
|
673
|
+
const exists = acc.contactLists.guards.some(
|
|
674
|
+
(g) => g.guardAddress.toLowerCase() === guardAddr
|
|
675
|
+
);
|
|
676
|
+
if (!exists) {
|
|
677
|
+
acc.contactLists.guards.push({
|
|
678
|
+
guardAddress,
|
|
679
|
+
passportValiditySeconds: 86400
|
|
680
|
+
});
|
|
681
|
+
acc.contactLists.lastUpdatedAt = Date.now();
|
|
682
|
+
}
|
|
683
|
+
return true;
|
|
684
|
+
}
|
|
685
|
+
async fetchFriendsList(address) {
|
|
686
|
+
try {
|
|
687
|
+
const response = await fetch(
|
|
688
|
+
`${this.config.serverUrl}/v1/spam-protection/${address}/friends-list`,
|
|
689
|
+
{
|
|
690
|
+
method: "POST",
|
|
691
|
+
headers: { "Content-Type": "application/json" },
|
|
692
|
+
body: JSON.stringify({
|
|
693
|
+
userAddress: address,
|
|
694
|
+
signature: "",
|
|
695
|
+
timestamp: Date.now(),
|
|
696
|
+
nonce: this.generateNonce()
|
|
697
|
+
})
|
|
698
|
+
}
|
|
699
|
+
);
|
|
700
|
+
if (!response.ok) {
|
|
701
|
+
throw new Error(`HTTP ${response.status}`);
|
|
702
|
+
}
|
|
703
|
+
return await response.json();
|
|
704
|
+
} catch (error) {
|
|
705
|
+
return [];
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
async fetchGuardList(address) {
|
|
709
|
+
try {
|
|
710
|
+
const response = await fetch(
|
|
711
|
+
`${this.config.serverUrl}/v1/spam-protection/${address}/guard-list`,
|
|
712
|
+
{
|
|
713
|
+
method: "POST",
|
|
714
|
+
headers: { "Content-Type": "application/json" },
|
|
715
|
+
body: JSON.stringify({
|
|
716
|
+
userAddress: address,
|
|
717
|
+
signature: "",
|
|
718
|
+
timestamp: Date.now(),
|
|
719
|
+
nonce: this.generateNonce()
|
|
720
|
+
})
|
|
721
|
+
}
|
|
722
|
+
);
|
|
723
|
+
if (!response.ok) {
|
|
724
|
+
throw new Error(`HTTP ${response.status}`);
|
|
725
|
+
}
|
|
726
|
+
return await response.json();
|
|
727
|
+
} catch (error) {
|
|
728
|
+
return [];
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
generateNonce() {
|
|
732
|
+
return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
733
|
+
}
|
|
734
|
+
async watch_paginated(filter) {
|
|
735
|
+
const { MAX_QUERY_LIMIT } = await import("./types.js");
|
|
736
|
+
const allMessages = await this.watch(filter);
|
|
737
|
+
const total = allMessages.length;
|
|
738
|
+
const defaultLimit = this.config.defaultQueryLimit ?? 50;
|
|
739
|
+
const limit = Math.min(filter?.limit ?? defaultLimit, MAX_QUERY_LIMIT);
|
|
740
|
+
const offset = filter?.offset ?? 0;
|
|
741
|
+
const messages = allMessages.slice(offset, offset + limit);
|
|
742
|
+
return {
|
|
743
|
+
messages,
|
|
744
|
+
total,
|
|
745
|
+
offset,
|
|
746
|
+
limit
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
async get_conversations(account) {
|
|
750
|
+
const filter = account ? { account } : void 0;
|
|
751
|
+
const allMessages = await this.watch(filter);
|
|
752
|
+
const conversations = /* @__PURE__ */ new Map();
|
|
753
|
+
for (const msg of allMessages) {
|
|
754
|
+
const myAddress = account?.toLowerCase();
|
|
755
|
+
const peerAddress = msg.fromAddress.toLowerCase() === myAddress ? msg.toAddress : msg.fromAddress;
|
|
756
|
+
if (!conversations.has(peerAddress)) {
|
|
757
|
+
conversations.set(peerAddress, {
|
|
758
|
+
peerAddress,
|
|
759
|
+
lastMessageAt: msg.createdAt,
|
|
760
|
+
messageCount: 0,
|
|
761
|
+
unreadCount: 0,
|
|
762
|
+
lastMessagePreview: msg.plaintext
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
const conv = conversations.get(peerAddress);
|
|
766
|
+
conv.messageCount++;
|
|
767
|
+
if (msg.createdAt > conv.lastMessageAt) {
|
|
768
|
+
conv.lastMessageAt = msg.createdAt;
|
|
769
|
+
conv.lastMessagePreview = msg.plaintext;
|
|
770
|
+
}
|
|
771
|
+
if (msg.status !== MessageStatus.READ && msg.toAddress.toLowerCase() === myAddress) {
|
|
772
|
+
conv.unreadCount++;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
return Array.from(conversations.values()).sort(
|
|
776
|
+
(a, b) => b.lastMessageAt - a.lastMessageAt
|
|
777
|
+
);
|
|
778
|
+
}
|
|
779
|
+
async generate_wts(params) {
|
|
780
|
+
const fs = await import("fs");
|
|
781
|
+
const path = await import("path");
|
|
782
|
+
const myAddress = params.myAccount.toLowerCase();
|
|
783
|
+
const peerAddress = params.peerAccount.toLowerCase();
|
|
784
|
+
const messageStorage = new MessageStorage(myAddress);
|
|
785
|
+
const myMessages = messageStorage.getAllMessages(myAddress);
|
|
786
|
+
let messages = myMessages.filter((msg) => {
|
|
787
|
+
const fromLower = msg.fromAddress.toLowerCase();
|
|
788
|
+
const toLower = msg.toAddress.toLowerCase();
|
|
789
|
+
const isBetween = fromLower === myAddress && toLower === peerAddress || fromLower === peerAddress && toLower === myAddress;
|
|
790
|
+
return isBetween;
|
|
791
|
+
});
|
|
792
|
+
messages = messages.filter(
|
|
793
|
+
(m) => m.leafIndex !== void 0 && m.serverTimestamp !== void 0
|
|
794
|
+
).reduce((acc, msg) => {
|
|
795
|
+
const existing = acc.find((m) => m.messageId === msg.messageId);
|
|
796
|
+
if (!existing) {
|
|
797
|
+
acc.push(msg);
|
|
798
|
+
}
|
|
799
|
+
return acc;
|
|
800
|
+
}, []).sort((a, b) => {
|
|
801
|
+
return a.leafIndex - b.leafIndex;
|
|
802
|
+
});
|
|
803
|
+
const leafIndexMap = /* @__PURE__ */ new Map();
|
|
804
|
+
for (const msg of messages) {
|
|
805
|
+
const idx = msg.leafIndex;
|
|
806
|
+
if (!leafIndexMap.has(idx)) {
|
|
807
|
+
leafIndexMap.set(idx, []);
|
|
808
|
+
}
|
|
809
|
+
leafIndexMap.get(idx).push(msg);
|
|
810
|
+
}
|
|
811
|
+
const duplicates = Array.from(leafIndexMap.entries()).filter(
|
|
812
|
+
([, msgs]) => msgs.length > 1
|
|
813
|
+
);
|
|
814
|
+
if (duplicates.length > 0) {
|
|
815
|
+
messages.sort(
|
|
816
|
+
(a, b) => (b.serverTimestamp || 0) - (a.serverTimestamp || 0)
|
|
817
|
+
);
|
|
818
|
+
const seenLeafIndices = /* @__PURE__ */ new Set();
|
|
819
|
+
const uniqueMessages = [];
|
|
820
|
+
for (const msg of messages) {
|
|
821
|
+
const idx = msg.leafIndex;
|
|
822
|
+
if (!seenLeafIndices.has(idx)) {
|
|
823
|
+
seenLeafIndices.add(idx);
|
|
824
|
+
uniqueMessages.push(msg);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
messages = uniqueMessages.sort(
|
|
828
|
+
(a, b) => a.leafIndex - b.leafIndex
|
|
829
|
+
);
|
|
830
|
+
}
|
|
831
|
+
if (params.range) {
|
|
832
|
+
switch (params.range.type) {
|
|
833
|
+
case "time": {
|
|
834
|
+
const start = Math.min(
|
|
835
|
+
params.range.start,
|
|
836
|
+
params.range.end
|
|
837
|
+
);
|
|
838
|
+
const end = Math.max(params.range.start, params.range.end);
|
|
839
|
+
messages = messages.filter(
|
|
840
|
+
(m) => m.createdAt >= start && m.createdAt <= end
|
|
841
|
+
);
|
|
842
|
+
break;
|
|
843
|
+
}
|
|
844
|
+
case "messageId": {
|
|
845
|
+
const start = params.range.start;
|
|
846
|
+
const end = params.range.end;
|
|
847
|
+
messages = messages.filter(
|
|
848
|
+
(m) => m.messageId >= start && m.messageId <= end
|
|
849
|
+
);
|
|
850
|
+
break;
|
|
851
|
+
}
|
|
852
|
+
case "seqIndex": {
|
|
853
|
+
const start = Math.min(
|
|
854
|
+
params.range.start,
|
|
855
|
+
params.range.end
|
|
856
|
+
);
|
|
857
|
+
const end = Math.max(params.range.start, params.range.end);
|
|
858
|
+
messages = messages.filter(
|
|
859
|
+
(m) => m.leafIndex >= start && m.leafIndex <= end
|
|
860
|
+
);
|
|
861
|
+
break;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
if (messages.length === 0) {
|
|
866
|
+
throw new MessengerError(
|
|
867
|
+
MessengerErrorCode.INVALID_INPUT,
|
|
868
|
+
"No messages found for the given criteria"
|
|
869
|
+
);
|
|
870
|
+
}
|
|
871
|
+
if (messages.length > WTS_MAX_MESSAGE_COUNT) {
|
|
872
|
+
throw new MessengerError(
|
|
873
|
+
MessengerErrorCode.INVALID_INPUT,
|
|
874
|
+
`Message count (${messages.length}) exceeds maximum allowed (${WTS_MAX_MESSAGE_COUNT})`
|
|
875
|
+
);
|
|
876
|
+
}
|
|
877
|
+
if (!fs.existsSync(params.outputDir)) {
|
|
878
|
+
fs.mkdirSync(params.outputDir, { recursive: true });
|
|
879
|
+
}
|
|
880
|
+
const sessionId = `${myAddress.slice(0, 6)}_${peerAddress.slice(0, 6)}`;
|
|
881
|
+
const groups = [messages];
|
|
882
|
+
const generatedFiles = [];
|
|
883
|
+
const startTime = messages[0].createdAt;
|
|
884
|
+
const endTime = messages[messages.length - 1].createdAt;
|
|
885
|
+
for (const group of groups) {
|
|
886
|
+
const leafIndices = group.map((m) => m.leafIndex).filter((i) => i !== void 0);
|
|
887
|
+
const startLeafIndex = Math.min(...leafIndices);
|
|
888
|
+
const endLeafIndex = Math.max(...leafIndices);
|
|
889
|
+
for (const msg of group) {
|
|
890
|
+
if (msg.serverTimestamp === void 0) {
|
|
891
|
+
throw new MessengerError(
|
|
892
|
+
MessengerErrorCode.INVALID_INPUT,
|
|
893
|
+
`Message ${msg.messageId} missing serverTimestamp`
|
|
894
|
+
);
|
|
895
|
+
}
|
|
896
|
+
if (msg.leafIndex === void 0) {
|
|
897
|
+
throw new MessengerError(
|
|
898
|
+
MessengerErrorCode.INVALID_INPUT,
|
|
899
|
+
`Message ${msg.messageId} missing leafIndex`
|
|
900
|
+
);
|
|
901
|
+
}
|
|
902
|
+
if (!msg.prevRoot) {
|
|
903
|
+
throw new MessengerError(
|
|
904
|
+
MessengerErrorCode.INVALID_INPUT,
|
|
905
|
+
`Message ${msg.messageId} missing prevRoot`
|
|
906
|
+
);
|
|
907
|
+
}
|
|
908
|
+
if (!msg.newRoot) {
|
|
909
|
+
throw new MessengerError(
|
|
910
|
+
MessengerErrorCode.INVALID_INPUT,
|
|
911
|
+
`Message ${msg.messageId} missing newRoot`
|
|
912
|
+
);
|
|
913
|
+
}
|
|
914
|
+
if (!msg.serverSignature) {
|
|
915
|
+
throw new MessengerError(
|
|
916
|
+
MessengerErrorCode.INVALID_INPUT,
|
|
917
|
+
`Message ${msg.messageId} missing serverSignature`
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
const wtsMessages = group.map((msg) => ({
|
|
922
|
+
id: msg.messageId,
|
|
923
|
+
from: msg.fromAddress,
|
|
924
|
+
to: msg.toAddress,
|
|
925
|
+
plaintext: params.excludePlaintext ? void 0 : msg.plaintext,
|
|
926
|
+
plaintextHash: msg.plaintextHash,
|
|
927
|
+
clientTimestamp: msg.createdAt,
|
|
928
|
+
timestamp: msg.serverTimestamp,
|
|
929
|
+
leafIndex: msg.leafIndex,
|
|
930
|
+
prevRoot: msg.prevRoot,
|
|
931
|
+
merkleRoot: msg.newRoot,
|
|
932
|
+
serverSignature: msg.serverSignature,
|
|
933
|
+
serverPublicKey: msg.serverPublicKey || "",
|
|
934
|
+
guardAddress: msg.guardAddress,
|
|
935
|
+
passportAddress: msg.passportAddress,
|
|
936
|
+
lastReceivedLeafIndex: msg.lastReceivedLeafIndex,
|
|
937
|
+
arkConfirmed: msg.arkConfirmed ? {
|
|
938
|
+
recipient: msg.arkConfirmed.recipient,
|
|
939
|
+
recipientPublicKey: msg.arkConfirmed.recipientPublicKey,
|
|
940
|
+
signature: msg.arkConfirmed.signature,
|
|
941
|
+
timestamp: msg.arkConfirmed.timestamp
|
|
942
|
+
} : void 0,
|
|
943
|
+
msgType: msg.msgType,
|
|
944
|
+
zipMetadata: msg.zipMetadata
|
|
945
|
+
}));
|
|
946
|
+
const addresses = [myAddress, peerAddress].sort();
|
|
947
|
+
const wtsSession = {
|
|
948
|
+
id: `${addresses[0]}:${addresses[1]}`,
|
|
949
|
+
participants: addresses
|
|
950
|
+
};
|
|
951
|
+
const payload = {
|
|
952
|
+
session: wtsSession,
|
|
953
|
+
messages: wtsMessages
|
|
954
|
+
};
|
|
955
|
+
const wtsMeta = {
|
|
956
|
+
type: "wts",
|
|
957
|
+
version: "1.0",
|
|
958
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
959
|
+
hash: "",
|
|
960
|
+
algorithm: "sha256",
|
|
961
|
+
startTime,
|
|
962
|
+
endTime,
|
|
963
|
+
messageCount: wtsMessages.length,
|
|
964
|
+
merkleRoot: wtsMessages[wtsMessages.length - 1].merkleRoot
|
|
965
|
+
};
|
|
966
|
+
const wtsFile = {
|
|
967
|
+
wts: canonicalizeJson(wtsMeta),
|
|
968
|
+
payload,
|
|
969
|
+
meta: wtsMeta
|
|
970
|
+
};
|
|
971
|
+
const fileName = `${sessionId}_${startLeafIndex}-${endLeafIndex}.wts`;
|
|
972
|
+
const filePath = path.join(params.outputDir, fileName);
|
|
973
|
+
fs.writeFileSync(filePath, JSON.stringify(wtsFile, null, 2));
|
|
974
|
+
generatedFiles.push(filePath);
|
|
975
|
+
}
|
|
976
|
+
return {
|
|
977
|
+
files: generatedFiles,
|
|
978
|
+
totalMessageCount: messages.length,
|
|
979
|
+
timeRange: {
|
|
980
|
+
start: startTime,
|
|
981
|
+
end: endTime
|
|
982
|
+
}
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
async addToBlacklist(account, addresses) {
|
|
986
|
+
const acc = this.findAccount(account);
|
|
987
|
+
if (!acc) {
|
|
988
|
+
throw new MessengerError(
|
|
989
|
+
MessengerErrorCode.ACCOUNT_NOT_FOUND,
|
|
990
|
+
`Account ${account} not in managed accounts`
|
|
991
|
+
);
|
|
992
|
+
}
|
|
993
|
+
return acc.messenger.addToBlacklist(addresses);
|
|
994
|
+
}
|
|
995
|
+
async removeFromBlacklist(account, addresses) {
|
|
996
|
+
const acc = this.findAccount(account);
|
|
997
|
+
if (!acc) {
|
|
998
|
+
throw new MessengerError(
|
|
999
|
+
MessengerErrorCode.ACCOUNT_NOT_FOUND,
|
|
1000
|
+
`Account ${account} not in managed accounts`
|
|
1001
|
+
);
|
|
1002
|
+
}
|
|
1003
|
+
return acc.messenger.removeFromBlacklist(addresses);
|
|
1004
|
+
}
|
|
1005
|
+
async clearBlacklist(account) {
|
|
1006
|
+
const acc = this.findAccount(account);
|
|
1007
|
+
if (!acc) {
|
|
1008
|
+
throw new MessengerError(
|
|
1009
|
+
MessengerErrorCode.ACCOUNT_NOT_FOUND,
|
|
1010
|
+
`Account ${account} not in managed accounts`
|
|
1011
|
+
);
|
|
1012
|
+
}
|
|
1013
|
+
return acc.messenger.clearBlacklist();
|
|
1014
|
+
}
|
|
1015
|
+
async getBlacklist(account) {
|
|
1016
|
+
const acc = this.findAccount(account);
|
|
1017
|
+
if (!acc) {
|
|
1018
|
+
throw new MessengerError(
|
|
1019
|
+
MessengerErrorCode.ACCOUNT_NOT_FOUND,
|
|
1020
|
+
`Account ${account} not in managed accounts`
|
|
1021
|
+
);
|
|
1022
|
+
}
|
|
1023
|
+
return acc.messenger.getBlacklist();
|
|
1024
|
+
}
|
|
1025
|
+
async existInBlacklist(account, addresses) {
|
|
1026
|
+
const acc = this.findAccount(account);
|
|
1027
|
+
if (!acc) {
|
|
1028
|
+
throw new MessengerError(
|
|
1029
|
+
MessengerErrorCode.ACCOUNT_NOT_FOUND,
|
|
1030
|
+
`Account ${account} not in managed accounts`
|
|
1031
|
+
);
|
|
1032
|
+
}
|
|
1033
|
+
return acc.messenger.existInBlacklist(addresses);
|
|
1034
|
+
}
|
|
1035
|
+
async addToFriendsList(account, addresses) {
|
|
1036
|
+
const acc = this.findAccount(account);
|
|
1037
|
+
if (!acc) {
|
|
1038
|
+
throw new MessengerError(
|
|
1039
|
+
MessengerErrorCode.ACCOUNT_NOT_FOUND,
|
|
1040
|
+
`Account ${account} not in managed accounts`
|
|
1041
|
+
);
|
|
1042
|
+
}
|
|
1043
|
+
return acc.messenger.addToFriendsList(addresses);
|
|
1044
|
+
}
|
|
1045
|
+
async removeFromFriendsList(account, addresses) {
|
|
1046
|
+
const acc = this.findAccount(account);
|
|
1047
|
+
if (!acc) {
|
|
1048
|
+
throw new MessengerError(
|
|
1049
|
+
MessengerErrorCode.ACCOUNT_NOT_FOUND,
|
|
1050
|
+
`Account ${account} not in managed accounts`
|
|
1051
|
+
);
|
|
1052
|
+
}
|
|
1053
|
+
return acc.messenger.removeFromFriendsList(addresses);
|
|
1054
|
+
}
|
|
1055
|
+
async clearFriendsList(account) {
|
|
1056
|
+
const acc = this.findAccount(account);
|
|
1057
|
+
if (!acc) {
|
|
1058
|
+
throw new MessengerError(
|
|
1059
|
+
MessengerErrorCode.ACCOUNT_NOT_FOUND,
|
|
1060
|
+
`Account ${account} not in managed accounts`
|
|
1061
|
+
);
|
|
1062
|
+
}
|
|
1063
|
+
return acc.messenger.clearFriendsList();
|
|
1064
|
+
}
|
|
1065
|
+
async getFriendsList(account) {
|
|
1066
|
+
const acc = this.findAccount(account);
|
|
1067
|
+
if (!acc) {
|
|
1068
|
+
throw new MessengerError(
|
|
1069
|
+
MessengerErrorCode.ACCOUNT_NOT_FOUND,
|
|
1070
|
+
`Account ${account} not in managed accounts`
|
|
1071
|
+
);
|
|
1072
|
+
}
|
|
1073
|
+
return acc.messenger.getFriendsList();
|
|
1074
|
+
}
|
|
1075
|
+
async existInFriendsList(account, addresses) {
|
|
1076
|
+
const acc = this.findAccount(account);
|
|
1077
|
+
if (!acc) {
|
|
1078
|
+
throw new MessengerError(
|
|
1079
|
+
MessengerErrorCode.ACCOUNT_NOT_FOUND,
|
|
1080
|
+
`Account ${account} not in managed accounts`
|
|
1081
|
+
);
|
|
1082
|
+
}
|
|
1083
|
+
return acc.messenger.existInFriendsList(addresses);
|
|
1084
|
+
}
|
|
1085
|
+
async addToGuardList(account, guards) {
|
|
1086
|
+
const acc = this.findAccount(account);
|
|
1087
|
+
if (!acc) {
|
|
1088
|
+
throw new MessengerError(
|
|
1089
|
+
MessengerErrorCode.ACCOUNT_NOT_FOUND,
|
|
1090
|
+
`Account ${account} not in managed accounts`
|
|
1091
|
+
);
|
|
1092
|
+
}
|
|
1093
|
+
return acc.messenger.addToGuardList(guards);
|
|
1094
|
+
}
|
|
1095
|
+
async removeFromGuardList(account, addresses) {
|
|
1096
|
+
const acc = this.findAccount(account);
|
|
1097
|
+
if (!acc) {
|
|
1098
|
+
throw new MessengerError(
|
|
1099
|
+
MessengerErrorCode.ACCOUNT_NOT_FOUND,
|
|
1100
|
+
`Account ${account} not in managed accounts`
|
|
1101
|
+
);
|
|
1102
|
+
}
|
|
1103
|
+
return acc.messenger.removeFromGuardList(addresses);
|
|
1104
|
+
}
|
|
1105
|
+
async getGuardList(account) {
|
|
1106
|
+
const acc = this.findAccount(account);
|
|
1107
|
+
if (!acc) {
|
|
1108
|
+
throw new MessengerError(
|
|
1109
|
+
MessengerErrorCode.ACCOUNT_NOT_FOUND,
|
|
1110
|
+
`Account ${account} not in managed accounts`
|
|
1111
|
+
);
|
|
1112
|
+
}
|
|
1113
|
+
return acc.messenger.getGuardList();
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
export {
|
|
1117
|
+
MessengerManager
|
|
1118
|
+
};
|