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,1210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
31
|
+
var guard_exports = {};
|
|
32
|
+
__export(guard_exports, {
|
|
33
|
+
CallGuard: () => CallGuard,
|
|
34
|
+
create: () => create,
|
|
35
|
+
formatGuardParseErrors: () => formatGuardParseErrors,
|
|
36
|
+
gen_passport: () => gen_passport,
|
|
37
|
+
guard2file: () => guard2file,
|
|
38
|
+
guardFn: () => guardFn,
|
|
39
|
+
newGuard: () => newGuard,
|
|
40
|
+
parseGuardFile: () => parseGuardFile,
|
|
41
|
+
parseGuardFromMarkdown: () => parseGuardFromMarkdown,
|
|
42
|
+
reliesAdd: () => reliesAdd,
|
|
43
|
+
reliesClear: () => reliesClear,
|
|
44
|
+
reliesLogic: () => reliesLogic,
|
|
45
|
+
reliesRemove: () => reliesRemove,
|
|
46
|
+
validateGuardNode: () => validateGuardNode
|
|
47
|
+
});
|
|
48
|
+
module.exports = __toCommonJS(guard_exports);
|
|
49
|
+
var import_common = require("../common.js");
|
|
50
|
+
var import_lodash = __toESM(require("lodash"));
|
|
51
|
+
var import_exception = require("../exception.js");
|
|
52
|
+
var import_base = require("./base.js");
|
|
53
|
+
var import_local = require("../local/local.js");
|
|
54
|
+
var import_object = require("../query/object.js");
|
|
55
|
+
var import_bcs = require("../../bcs/index.js");
|
|
56
|
+
var import_util = require("../util.js");
|
|
57
|
+
var import_guard_ins = require("./guard-ins.js");
|
|
58
|
+
var import_util2 = require("./util.js");
|
|
59
|
+
var import_sui_types = require("../../utils/sui-types.js");
|
|
60
|
+
var import_passport = require("./passport.js");
|
|
61
|
+
var import_fs = require("fs");
|
|
62
|
+
var import_path = require("path");
|
|
63
|
+
function guardFn(name) {
|
|
64
|
+
return `${import_common.PackageAddress}::guard::${name}`;
|
|
65
|
+
}
|
|
66
|
+
class CallGuard extends import_base.CallBase {
|
|
67
|
+
constructor(data) {
|
|
68
|
+
super();
|
|
69
|
+
__publicField(this, "data");
|
|
70
|
+
this.data = data;
|
|
71
|
+
}
|
|
72
|
+
async call(env) {
|
|
73
|
+
await this.prepare(env);
|
|
74
|
+
return await this.exec(env);
|
|
75
|
+
}
|
|
76
|
+
async operate(env, tx, _passport, _submission) {
|
|
77
|
+
if (!this.data.table || this.data.table.length === 0) {
|
|
78
|
+
(0, import_exception.W_ERROR)(import_exception.WErrors.InvalidParam, "table is empty");
|
|
79
|
+
}
|
|
80
|
+
if (!this.data.root) {
|
|
81
|
+
(0, import_exception.W_ERROR)(import_exception.WErrors.InvalidParam, "root is empty");
|
|
82
|
+
}
|
|
83
|
+
const guard = await newGuard(
|
|
84
|
+
tx,
|
|
85
|
+
this.data?.description || "",
|
|
86
|
+
this.data?.table,
|
|
87
|
+
this.data?.root
|
|
88
|
+
);
|
|
89
|
+
if (this.data?.rely != null) {
|
|
90
|
+
const relyGuards = await import_local.LocalMark.Instance().get_many_address(
|
|
91
|
+
this.data.rely.guards
|
|
92
|
+
);
|
|
93
|
+
const undefinedIndex = relyGuards.findIndex((v) => v === void 0);
|
|
94
|
+
if (undefinedIndex !== -1) {
|
|
95
|
+
(0, import_exception.W_ERROR)(
|
|
96
|
+
import_exception.WErrors.InvalidParam,
|
|
97
|
+
`rely.guards invalid: guard at index ${undefinedIndex} not found`
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
reliesAdd(
|
|
101
|
+
tx,
|
|
102
|
+
guard,
|
|
103
|
+
relyGuards.filter((v) => v !== void 0)
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
await this.new_with_mark(
|
|
107
|
+
env,
|
|
108
|
+
tx,
|
|
109
|
+
import_common.ObjectType.Guard,
|
|
110
|
+
create(tx, guard),
|
|
111
|
+
this.data?.namedNew
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const newGuard = async (tx, description, table, root) => {
|
|
116
|
+
if (!(0, import_common.isValidDescription)(description)) {
|
|
117
|
+
(0, import_exception.W_ERROR)(
|
|
118
|
+
import_exception.WErrors.IsValidDescription,
|
|
119
|
+
`Description exceeds maximum length ${import_common.MAX_DESCRIPTION_LENGTH}`
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
for (let i = 0; i < table.length; i++) {
|
|
123
|
+
const v = table[i];
|
|
124
|
+
if (!(0, import_common.isValidU8)(v.identifier))
|
|
125
|
+
(0, import_exception.W_ERROR)(
|
|
126
|
+
import_exception.WErrors.InvalidParam,
|
|
127
|
+
`table.identifier ${v.identifier} invalid`
|
|
128
|
+
);
|
|
129
|
+
if (!v.b_submission && (v.value === void 0 || v.value === null))
|
|
130
|
+
(0, import_exception.W_ERROR)(
|
|
131
|
+
import_exception.WErrors.InvalidParam,
|
|
132
|
+
`table.value ${v.value} with identifier ${v.identifier} invalid`
|
|
133
|
+
);
|
|
134
|
+
if (!(0, import_common.isValidName)(v.name)) (0, import_exception.W_ERROR)(import_exception.WErrors.InvalidParam, "table.name");
|
|
135
|
+
}
|
|
136
|
+
const grouped = import_lodash.default.groupBy(table, "identifier");
|
|
137
|
+
const duplicates = Object.keys(grouped).filter(
|
|
138
|
+
(key) => grouped[key].length > 1
|
|
139
|
+
);
|
|
140
|
+
if (duplicates.length > 0) {
|
|
141
|
+
(0, import_exception.W_ERROR)(
|
|
142
|
+
import_exception.WErrors.InvalidParam,
|
|
143
|
+
`table.identifier duplicates: ${duplicates.join(", ")}`
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
var output = [];
|
|
147
|
+
await buildNode(root, import_common.ValueType.Bool, table, output);
|
|
148
|
+
const totalLength = output.reduce((acc, arr) => acc + arr.length, 0);
|
|
149
|
+
const input = new Uint8Array(totalLength);
|
|
150
|
+
let offset = 0;
|
|
151
|
+
for (const arr of output) {
|
|
152
|
+
input.set(arr, offset);
|
|
153
|
+
offset += arr.length;
|
|
154
|
+
}
|
|
155
|
+
if (input.length > import_common.MAX_INPUT_SIZE) {
|
|
156
|
+
(0, import_exception.W_ERROR)(
|
|
157
|
+
import_exception.WErrors.NewGuardCheckFailed,
|
|
158
|
+
`Input size exceeds maximum limit ${import_common.MAX_INPUT_SIZE}`
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
if (input.length === 0) {
|
|
162
|
+
(0, import_exception.W_ERROR)(import_exception.WErrors.NewGuardCheckFailed, `Input cannot be empty`);
|
|
163
|
+
}
|
|
164
|
+
const tableItems = [];
|
|
165
|
+
for (let i = 0; i < table.length; i++) {
|
|
166
|
+
const item = table[i];
|
|
167
|
+
const valueType = (0, import_common.parseValueType)(item.value_type);
|
|
168
|
+
let bcsValue;
|
|
169
|
+
if (item.b_submission) {
|
|
170
|
+
bcsValue = new Uint8Array(1);
|
|
171
|
+
bcsValue[0] = valueType;
|
|
172
|
+
} else {
|
|
173
|
+
if (item.value === void 0 || item.value === null) {
|
|
174
|
+
(0, import_exception.W_ERROR)(
|
|
175
|
+
import_exception.WErrors.NewGuardCheckFailed,
|
|
176
|
+
`Table item value is required when b_submission is false`
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
bcsValue = await (0, import_util.valueToBcsBytes)(valueType, item.value);
|
|
180
|
+
}
|
|
181
|
+
tableItems.push(
|
|
182
|
+
tx.moveCall({
|
|
183
|
+
target: guardFn("table_item"),
|
|
184
|
+
arguments: [
|
|
185
|
+
tx.pure.u8(item.identifier),
|
|
186
|
+
tx.pure.bool(item.b_submission),
|
|
187
|
+
tx.pure.vector("u8", Array.from(bcsValue)),
|
|
188
|
+
(0, import_common.toTxString)(tx, item.name)
|
|
189
|
+
]
|
|
190
|
+
})
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
return tx.moveCall({
|
|
194
|
+
target: guardFn("new"),
|
|
195
|
+
arguments: [
|
|
196
|
+
(0, import_common.toTxString)(tx, description),
|
|
197
|
+
tx.makeMoveVec({
|
|
198
|
+
elements: tableItems,
|
|
199
|
+
type: `${import_common.PackageAddress}::guard::TableItem`
|
|
200
|
+
}),
|
|
201
|
+
tx.pure.vector("u8", Array.from(input))
|
|
202
|
+
]
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
function create(tx, guard) {
|
|
206
|
+
return tx.moveCall({
|
|
207
|
+
target: guardFn("create"),
|
|
208
|
+
arguments: [
|
|
209
|
+
(0, import_common.toTxObject)(tx, guard),
|
|
210
|
+
tx.object.mutRegistrar(),
|
|
211
|
+
tx.object.clock()
|
|
212
|
+
]
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
function reliesAdd(tx, guard, rely_guards) {
|
|
216
|
+
const guards = import_lodash.default.uniq(rely_guards);
|
|
217
|
+
if (guards.length > import_common.MAX_DEPENDED_COUNT) {
|
|
218
|
+
(0, import_exception.W_ERROR)(
|
|
219
|
+
import_exception.WErrors.NewGuardCheckFailed,
|
|
220
|
+
`Relies count exceeds maximum limit ${import_common.MAX_DEPENDED_COUNT}`
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
guards.forEach((g) => {
|
|
224
|
+
if (g === guard) {
|
|
225
|
+
(0, import_exception.W_ERROR)(import_exception.WErrors.NewGuardCheckFailed, `Guard cannot rely on itself`);
|
|
226
|
+
}
|
|
227
|
+
tx.moveCall({
|
|
228
|
+
target: guardFn("relies_add"),
|
|
229
|
+
arguments: [
|
|
230
|
+
(0, import_common.toTxObject)(tx, guard),
|
|
231
|
+
(0, import_common.toTxObject)(tx, g),
|
|
232
|
+
tx.object.mutRegistrar(),
|
|
233
|
+
tx.object.clock()
|
|
234
|
+
]
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function reliesRemove(tx, guard, rely_guards) {
|
|
239
|
+
const guards = import_lodash.default.uniq(rely_guards);
|
|
240
|
+
if (guards.length > import_common.MAX_DEPENDED_COUNT) {
|
|
241
|
+
(0, import_exception.W_ERROR)(
|
|
242
|
+
import_exception.WErrors.NewGuardCheckFailed,
|
|
243
|
+
`Relies count exceeds maximum limit ${import_common.MAX_DEPENDED_COUNT}`
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
guards.forEach((g) => {
|
|
247
|
+
tx.moveCall({
|
|
248
|
+
target: guardFn("relies_remove"),
|
|
249
|
+
arguments: [
|
|
250
|
+
(0, import_common.toTxObject)(tx, guard),
|
|
251
|
+
(0, import_common.toTxObject)(tx, g),
|
|
252
|
+
tx.object.mutRegistrar()
|
|
253
|
+
]
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function reliesClear(tx, guard) {
|
|
258
|
+
tx.moveCall({
|
|
259
|
+
target: guardFn("relies_clear"),
|
|
260
|
+
arguments: [(0, import_common.toTxObject)(tx, guard), tx.object.mutRegistrar()]
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
function reliesLogic(tx, guard, logic_and) {
|
|
264
|
+
tx.moveCall({
|
|
265
|
+
target: guardFn("relies_logic_and"),
|
|
266
|
+
arguments: [(0, import_common.toTxObject)(tx, guard), tx.pure.bool(logic_and)]
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
const buildNode = async (guard_node, type_required, table, output) => {
|
|
270
|
+
const node = guard_node;
|
|
271
|
+
switch (node.type) {
|
|
272
|
+
case "identifier": {
|
|
273
|
+
const f = table.find((v) => v.identifier === node.identifier);
|
|
274
|
+
if (f) {
|
|
275
|
+
const fValueType = (0, import_common.parseValueType)(f.value_type);
|
|
276
|
+
(0, import_util2.checkType)(fValueType, type_required, node);
|
|
277
|
+
output.push(
|
|
278
|
+
import_bcs.bcs.U8.serialize(import_common.ContextType.TypeConstant).toBytes()
|
|
279
|
+
);
|
|
280
|
+
output.push(import_bcs.bcs.U8.serialize(node.identifier).toBytes());
|
|
281
|
+
} else {
|
|
282
|
+
(0, import_exception.W_ERROR)(
|
|
283
|
+
import_exception.WErrors.InvalidParam,
|
|
284
|
+
"node identifier - " + JSON.stringify(node)
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
case "query": {
|
|
290
|
+
const q = (0, import_guard_ins.getGuardQueryInfo)(node.query);
|
|
291
|
+
if (!q) {
|
|
292
|
+
(0, import_exception.W_ERROR)(import_exception.WErrors.InvalidParam, `query not found: ${node.query}`);
|
|
293
|
+
}
|
|
294
|
+
(0, import_util2.checkType)(q.return, type_required, node);
|
|
295
|
+
if (q.parameters.length === node.parameters.length) {
|
|
296
|
+
for (let i = node.parameters.length - 1; i >= 0; --i) {
|
|
297
|
+
await buildNode(
|
|
298
|
+
node.parameters[i],
|
|
299
|
+
q.parameters[i],
|
|
300
|
+
table,
|
|
301
|
+
output
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
} else {
|
|
305
|
+
(0, import_exception.W_ERROR)(
|
|
306
|
+
import_exception.WErrors.InvalidParam,
|
|
307
|
+
"node query parameters length not match - " + JSON.stringify(node)
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
const tableItem = table.find(
|
|
311
|
+
(v) => v.identifier === node.object.identifier
|
|
312
|
+
);
|
|
313
|
+
if (!tableItem) {
|
|
314
|
+
(0, import_exception.W_ERROR)(
|
|
315
|
+
import_exception.WErrors.InvalidParam,
|
|
316
|
+
"node object from identifier - " + JSON.stringify(node)
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
const tableItemValueType = (0, import_common.parseValueType)(tableItem.value_type);
|
|
320
|
+
if (tableItemValueType !== import_common.ValueType.Address) {
|
|
321
|
+
(0, import_exception.W_ERROR)(
|
|
322
|
+
import_exception.WErrors.InvalidParam,
|
|
323
|
+
`object to query must be address in table ${tableItem}. ${node.object}`
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
output.push(import_bcs.bcs.U8.serialize(import_common.OperatorType.TypeQuery).toBytes());
|
|
327
|
+
if ((0, import_common.isWitnessType)(node.object.convert_witness)) {
|
|
328
|
+
const target = (0, import_object.WitnessTargetType)(node.object.convert_witness);
|
|
329
|
+
if (target !== q.objectType) {
|
|
330
|
+
(0, import_exception.W_ERROR)(
|
|
331
|
+
import_exception.WErrors.InvalidParam,
|
|
332
|
+
`witness object type(${target}) not consistent with query object type(${q.objectType})`
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
const source = (0, import_object.WitnessSourceType)(node.object.convert_witness);
|
|
336
|
+
if (tableItem.object_type) {
|
|
337
|
+
if (tableItem.object_type !== source) {
|
|
338
|
+
(0, import_exception.W_ERROR)(
|
|
339
|
+
import_exception.WErrors.InvalidParam,
|
|
340
|
+
`witness object type(${source}) not consistent with query object type(${tableItem.object_type})`
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
} else {
|
|
344
|
+
tableItem.object_type = source;
|
|
345
|
+
}
|
|
346
|
+
output.push(
|
|
347
|
+
import_bcs.bcs.U8.serialize(node.object.convert_witness).toBytes()
|
|
348
|
+
);
|
|
349
|
+
} else {
|
|
350
|
+
if (tableItem?.object_type) {
|
|
351
|
+
if (tableItem.object_type !== q.objectType) {
|
|
352
|
+
(0, import_exception.W_ERROR)(
|
|
353
|
+
import_exception.WErrors.InvalidParam,
|
|
354
|
+
`witness object type(${q.objectType}) not consistent with query object type(${tableItem.object_type})`
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
} else {
|
|
358
|
+
tableItem.object_type = q.objectType;
|
|
359
|
+
}
|
|
360
|
+
output.push(
|
|
361
|
+
import_bcs.bcs.U8.serialize(import_common.ContextType.TypeConstant).toBytes()
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
output.push(import_bcs.bcs.U8.serialize(node.object.identifier).toBytes());
|
|
365
|
+
output.push(import_bcs.bcs.U16.serialize(q.id).toBytes());
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
case "logic_as_u256_greater_or_equal":
|
|
369
|
+
case "logic_as_u256_lesser_or_equal":
|
|
370
|
+
case "logic_as_u256_equal":
|
|
371
|
+
case "logic_as_u256_greater":
|
|
372
|
+
case "logic_as_u256_lesser":
|
|
373
|
+
case "logic_equal":
|
|
374
|
+
case "logic_and":
|
|
375
|
+
case "logic_or":
|
|
376
|
+
case "logic_string_contains":
|
|
377
|
+
case "logic_string_nocase_contains":
|
|
378
|
+
case "logic_string_nocase_equal":
|
|
379
|
+
case "calc_number_add":
|
|
380
|
+
case "calc_number_subtract":
|
|
381
|
+
case "calc_number_multiply":
|
|
382
|
+
case "calc_number_divide":
|
|
383
|
+
case "calc_number_mod":
|
|
384
|
+
case "calc_string_nocase_contains":
|
|
385
|
+
case "calc_string_nocase_equal":
|
|
386
|
+
case "calc_string_contains": {
|
|
387
|
+
const opCodeMap = {
|
|
388
|
+
logic_as_u256_greater_or_equal: import_common.OperatorType.TypeLogicAsU256GreaterEqual,
|
|
389
|
+
logic_as_u256_lesser_or_equal: import_common.OperatorType.TypeLogicAsU256LesserEqual,
|
|
390
|
+
logic_as_u256_equal: import_common.OperatorType.TypeLogicAsU256Equal,
|
|
391
|
+
logic_as_u256_greater: import_common.OperatorType.TypeLogicAsU256Greater,
|
|
392
|
+
logic_as_u256_lesser: import_common.OperatorType.TypeLogicAsU256Lesser,
|
|
393
|
+
logic_equal: import_common.OperatorType.TypeLogicEqual,
|
|
394
|
+
logic_and: import_common.OperatorType.TypeLogicAnd,
|
|
395
|
+
logic_or: import_common.OperatorType.TypeLogicOr,
|
|
396
|
+
logic_string_contains: import_common.OperatorType.TypeStringContains,
|
|
397
|
+
logic_string_nocase_contains: import_common.OperatorType.TypeStringNocaseContains,
|
|
398
|
+
logic_string_nocase_equal: import_common.OperatorType.TypeStringNocaseEqual,
|
|
399
|
+
calc_number_add: import_common.OperatorType.TypeNumberAdd,
|
|
400
|
+
calc_number_subtract: import_common.OperatorType.TypeNumberSubtract,
|
|
401
|
+
calc_number_multiply: import_common.OperatorType.TypeNumberMultiply,
|
|
402
|
+
calc_number_divide: import_common.OperatorType.TypeNumberDivide,
|
|
403
|
+
calc_number_mod: import_common.OperatorType.TypeNumberMod,
|
|
404
|
+
calc_string_nocase_contains: import_common.OperatorType.TypeStringNocaseContains,
|
|
405
|
+
calc_string_nocase_equal: import_common.OperatorType.TypeStringNocaseEqual,
|
|
406
|
+
calc_string_contains: import_common.OperatorType.TypeStringContains
|
|
407
|
+
};
|
|
408
|
+
const requiredTypeMap = {
|
|
409
|
+
logic_as_u256_greater_or_equal: "number",
|
|
410
|
+
logic_as_u256_lesser_or_equal: "number",
|
|
411
|
+
logic_as_u256_equal: "number",
|
|
412
|
+
logic_as_u256_greater: "number",
|
|
413
|
+
logic_as_u256_lesser: "number",
|
|
414
|
+
logic_equal: "variable",
|
|
415
|
+
logic_and: import_common.ValueType.Bool,
|
|
416
|
+
logic_or: import_common.ValueType.Bool,
|
|
417
|
+
logic_string_contains: import_common.ValueType.String,
|
|
418
|
+
logic_string_nocase_contains: import_common.ValueType.String,
|
|
419
|
+
logic_string_nocase_equal: import_common.ValueType.String,
|
|
420
|
+
calc_number_add: "number",
|
|
421
|
+
calc_number_subtract: "number",
|
|
422
|
+
calc_number_multiply: "number",
|
|
423
|
+
calc_number_divide: "number",
|
|
424
|
+
calc_number_mod: "number",
|
|
425
|
+
calc_string_nocase_contains: import_common.ValueType.String,
|
|
426
|
+
calc_string_nocase_equal: import_common.ValueType.String,
|
|
427
|
+
calc_string_contains: import_common.ValueType.String
|
|
428
|
+
};
|
|
429
|
+
const returnTypeMap = {
|
|
430
|
+
logic_as_u256_greater_or_equal: import_common.ValueType.Bool,
|
|
431
|
+
logic_as_u256_lesser_or_equal: import_common.ValueType.Bool,
|
|
432
|
+
logic_as_u256_equal: import_common.ValueType.Bool,
|
|
433
|
+
logic_as_u256_greater: import_common.ValueType.Bool,
|
|
434
|
+
logic_as_u256_lesser: import_common.ValueType.Bool,
|
|
435
|
+
logic_equal: import_common.ValueType.Bool,
|
|
436
|
+
logic_and: import_common.ValueType.Bool,
|
|
437
|
+
logic_or: import_common.ValueType.Bool,
|
|
438
|
+
logic_string_contains: import_common.ValueType.Bool,
|
|
439
|
+
logic_string_nocase_contains: import_common.ValueType.Bool,
|
|
440
|
+
logic_string_nocase_equal: import_common.ValueType.Bool,
|
|
441
|
+
calc_number_add: import_common.ValueType.U256,
|
|
442
|
+
calc_number_subtract: import_common.ValueType.U256,
|
|
443
|
+
calc_number_multiply: import_common.ValueType.U256,
|
|
444
|
+
calc_number_divide: import_common.ValueType.U256,
|
|
445
|
+
calc_number_mod: import_common.ValueType.U256,
|
|
446
|
+
calc_string_nocase_contains: import_common.ValueType.Bool,
|
|
447
|
+
calc_string_nocase_equal: import_common.ValueType.Bool,
|
|
448
|
+
calc_string_contains: import_common.ValueType.Bool
|
|
449
|
+
};
|
|
450
|
+
(0, import_util2.checkType)(returnTypeMap[node.type], type_required, node);
|
|
451
|
+
await multi_operand_op(
|
|
452
|
+
opCodeMap[node.type],
|
|
453
|
+
node.nodes,
|
|
454
|
+
requiredTypeMap[node.type],
|
|
455
|
+
table,
|
|
456
|
+
output
|
|
457
|
+
);
|
|
458
|
+
break;
|
|
459
|
+
}
|
|
460
|
+
case "vec_contains_bool":
|
|
461
|
+
case "vec_contains_address":
|
|
462
|
+
case "vec_contains_string":
|
|
463
|
+
case "vec_contains_string_nocase":
|
|
464
|
+
case "vec_contains_number": {
|
|
465
|
+
const opCodeMap = {
|
|
466
|
+
vec_contains_bool: import_common.OperatorType.TypedValueVecContains_Bool,
|
|
467
|
+
vec_contains_address: import_common.OperatorType.TypedValueVecContains_Address,
|
|
468
|
+
vec_contains_string: import_common.OperatorType.TypedValueVecContains_String,
|
|
469
|
+
vec_contains_string_nocase: import_common.OperatorType.TypedValueVecContains_StringNoCase,
|
|
470
|
+
vec_contains_number: import_common.OperatorType.TypedValueVecContains_Number
|
|
471
|
+
};
|
|
472
|
+
const vecTypeMap = {
|
|
473
|
+
vec_contains_bool: import_common.ValueType.VecBool,
|
|
474
|
+
vec_contains_address: import_common.ValueType.VecAddress,
|
|
475
|
+
vec_contains_string: import_common.ValueType.VecString,
|
|
476
|
+
vec_contains_string_nocase: import_common.ValueType.VecString,
|
|
477
|
+
vec_contains_number: "vec_number"
|
|
478
|
+
};
|
|
479
|
+
const elemTypeMap = {
|
|
480
|
+
vec_contains_bool: import_common.ValueType.Bool,
|
|
481
|
+
vec_contains_address: import_common.ValueType.Address,
|
|
482
|
+
vec_contains_string: import_common.ValueType.String,
|
|
483
|
+
vec_contains_string_nocase: import_common.ValueType.String,
|
|
484
|
+
vec_contains_number: "number"
|
|
485
|
+
};
|
|
486
|
+
(0, import_util2.checkType)(import_common.ValueType.Bool, type_required, node);
|
|
487
|
+
for (let i = node.nodes.length - 1; i >= 0; --i) {
|
|
488
|
+
const nodeType = i === 0 ? vecTypeMap[node.type] : elemTypeMap[node.type];
|
|
489
|
+
await buildNode(node.nodes[i], nodeType, table, output);
|
|
490
|
+
}
|
|
491
|
+
output.push(import_bcs.bcs.U8.serialize(opCodeMap[node.type]).toBytes());
|
|
492
|
+
output.push(import_bcs.bcs.U8.serialize(node.nodes.length).toBytes());
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
case "logic_not":
|
|
496
|
+
case "calc_string_length":
|
|
497
|
+
case "convert_number_address":
|
|
498
|
+
case "convert_address_number":
|
|
499
|
+
case "convert_number_string":
|
|
500
|
+
case "convert_string_number":
|
|
501
|
+
case "convert_safe_u8":
|
|
502
|
+
case "convert_safe_u16":
|
|
503
|
+
case "convert_safe_u32":
|
|
504
|
+
case "convert_safe_u64":
|
|
505
|
+
case "convert_safe_u128":
|
|
506
|
+
case "convert_safe_u256":
|
|
507
|
+
case "value_type":
|
|
508
|
+
case "vec_length": {
|
|
509
|
+
const opCodeMap = {
|
|
510
|
+
logic_not: import_common.OperatorType.TypeLogicNot,
|
|
511
|
+
calc_string_length: import_common.OperatorType.TypeStringLength,
|
|
512
|
+
convert_number_address: import_common.OperatorType.TypeNumberAddress,
|
|
513
|
+
convert_address_number: import_common.OperatorType.TypeAddressNumber,
|
|
514
|
+
convert_number_string: import_common.OperatorType.TypeNumberString,
|
|
515
|
+
convert_string_number: import_common.OperatorType.TypeStringNumber,
|
|
516
|
+
//convert_string_lowercase: OperatorType.TypeStringLowercase,
|
|
517
|
+
convert_safe_u8: import_common.OperatorType.TypeSafeU8,
|
|
518
|
+
convert_safe_u16: import_common.OperatorType.TypeSafeU16,
|
|
519
|
+
convert_safe_u32: import_common.OperatorType.TypeSafeU32,
|
|
520
|
+
convert_safe_u64: import_common.OperatorType.TypeSafeU64,
|
|
521
|
+
convert_safe_u128: import_common.OperatorType.TypeSafeU128,
|
|
522
|
+
convert_safe_u256: import_common.OperatorType.TypeSafeU256,
|
|
523
|
+
value_type: import_common.OperatorType.TypedValueType,
|
|
524
|
+
vec_length: import_common.OperatorType.TypedValueVecLength
|
|
525
|
+
};
|
|
526
|
+
const requiredTypeMap = {
|
|
527
|
+
logic_not: import_common.ValueType.Bool,
|
|
528
|
+
calc_string_length: import_common.ValueType.String,
|
|
529
|
+
convert_number_address: "number",
|
|
530
|
+
convert_address_number: import_common.ValueType.Address,
|
|
531
|
+
convert_number_string: "number",
|
|
532
|
+
convert_string_number: import_common.ValueType.String,
|
|
533
|
+
convert_safe_u8: "number",
|
|
534
|
+
convert_safe_u16: "number",
|
|
535
|
+
convert_safe_u32: "number",
|
|
536
|
+
convert_safe_u64: "number",
|
|
537
|
+
convert_safe_u128: "number",
|
|
538
|
+
convert_safe_u256: "number",
|
|
539
|
+
value_type: "variable",
|
|
540
|
+
vec_length: "vec"
|
|
541
|
+
};
|
|
542
|
+
const returnTypeMap = {
|
|
543
|
+
logic_not: import_common.ValueType.Bool,
|
|
544
|
+
calc_string_length: import_common.ValueType.U64,
|
|
545
|
+
convert_number_address: import_common.ValueType.Address,
|
|
546
|
+
convert_address_number: import_common.ValueType.U256,
|
|
547
|
+
convert_number_string: import_common.ValueType.String,
|
|
548
|
+
convert_string_number: import_common.ValueType.U256,
|
|
549
|
+
convert_safe_u8: import_common.ValueType.U8,
|
|
550
|
+
convert_safe_u16: import_common.ValueType.U16,
|
|
551
|
+
convert_safe_u32: import_common.ValueType.U32,
|
|
552
|
+
convert_safe_u64: import_common.ValueType.U64,
|
|
553
|
+
convert_safe_u128: import_common.ValueType.U128,
|
|
554
|
+
convert_safe_u256: import_common.ValueType.U256,
|
|
555
|
+
value_type: import_common.ValueType.U8,
|
|
556
|
+
vec_length: import_common.ValueType.U64
|
|
557
|
+
};
|
|
558
|
+
(0, import_util2.checkType)(returnTypeMap[node.type], type_required, node);
|
|
559
|
+
await single_operand_op(
|
|
560
|
+
opCodeMap[node.type],
|
|
561
|
+
node.node,
|
|
562
|
+
requiredTypeMap[node.type],
|
|
563
|
+
table,
|
|
564
|
+
output
|
|
565
|
+
);
|
|
566
|
+
break;
|
|
567
|
+
}
|
|
568
|
+
case "calc_string_indexof":
|
|
569
|
+
case "calc_string_nocase_indexof": {
|
|
570
|
+
const opCodeMap = {
|
|
571
|
+
calc_string_indexof: import_common.OperatorType.TypeStringIndexof,
|
|
572
|
+
calc_string_nocase_indexof: import_common.OperatorType.TypeStringNocaseIndexof
|
|
573
|
+
};
|
|
574
|
+
(0, import_util2.checkType)(import_common.ValueType.U64, type_required, node);
|
|
575
|
+
await buildNode(node.nodeRight, import_common.ValueType.String, table, output);
|
|
576
|
+
await buildNode(node.nodeLeft, import_common.ValueType.String, table, output);
|
|
577
|
+
output.push(import_bcs.bcs.U8.serialize(opCodeMap[node.type]).toBytes());
|
|
578
|
+
output.push(
|
|
579
|
+
import_bcs.bcs.U8.serialize(node.order === "forward" ? 0 : 1).toBytes()
|
|
580
|
+
);
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
case "vec_indexof_bool":
|
|
584
|
+
case "vec_indexof_address":
|
|
585
|
+
case "vec_indexof_string":
|
|
586
|
+
case "vec_indexof_string_nocase":
|
|
587
|
+
case "vec_indexof_number": {
|
|
588
|
+
const opCodeMap = {
|
|
589
|
+
vec_indexof_bool: import_common.OperatorType.TypedValueVecIndexOf_Bool,
|
|
590
|
+
vec_indexof_address: import_common.OperatorType.TypedValueVecIndexOf_Address,
|
|
591
|
+
vec_indexof_string: import_common.OperatorType.TypedValueVecIndexOf_String,
|
|
592
|
+
vec_indexof_string_nocase: import_common.OperatorType.TypedValueVecIndexOf_StringNoCase,
|
|
593
|
+
vec_indexof_number: import_common.OperatorType.TypedValueVecIndexOf_Number
|
|
594
|
+
};
|
|
595
|
+
const rightTypeMap = {
|
|
596
|
+
vec_indexof_bool: import_common.ValueType.Bool,
|
|
597
|
+
vec_indexof_address: import_common.ValueType.Address,
|
|
598
|
+
vec_indexof_string: import_common.ValueType.String,
|
|
599
|
+
vec_indexof_string_nocase: import_common.ValueType.String,
|
|
600
|
+
vec_indexof_number: "number"
|
|
601
|
+
};
|
|
602
|
+
const leftTypeMap = {
|
|
603
|
+
vec_indexof_bool: import_common.ValueType.VecBool,
|
|
604
|
+
vec_indexof_address: import_common.ValueType.VecAddress,
|
|
605
|
+
vec_indexof_string: import_common.ValueType.VecString,
|
|
606
|
+
vec_indexof_string_nocase: import_common.ValueType.VecString,
|
|
607
|
+
vec_indexof_number: "vec_number"
|
|
608
|
+
};
|
|
609
|
+
(0, import_util2.checkType)(import_common.ValueType.U64, type_required, node);
|
|
610
|
+
await buildNode(
|
|
611
|
+
node.nodeRight,
|
|
612
|
+
rightTypeMap[node.type],
|
|
613
|
+
table,
|
|
614
|
+
output
|
|
615
|
+
);
|
|
616
|
+
await buildNode(
|
|
617
|
+
node.nodeLeft,
|
|
618
|
+
leftTypeMap[node.type],
|
|
619
|
+
table,
|
|
620
|
+
output
|
|
621
|
+
);
|
|
622
|
+
output.push(import_bcs.bcs.U8.serialize(opCodeMap[node.type]).toBytes());
|
|
623
|
+
output.push(
|
|
624
|
+
import_bcs.bcs.U8.serialize(node.order === "forward" ? 0 : 1).toBytes()
|
|
625
|
+
);
|
|
626
|
+
break;
|
|
627
|
+
}
|
|
628
|
+
case "context": {
|
|
629
|
+
let contextValue;
|
|
630
|
+
switch (node.context) {
|
|
631
|
+
case "Signer":
|
|
632
|
+
contextValue = import_common.ContextType.TypeSigner;
|
|
633
|
+
break;
|
|
634
|
+
case "Clock":
|
|
635
|
+
contextValue = import_common.ContextType.TypeClock;
|
|
636
|
+
break;
|
|
637
|
+
case "Guard":
|
|
638
|
+
contextValue = import_common.ContextType.TypeGuard;
|
|
639
|
+
break;
|
|
640
|
+
default:
|
|
641
|
+
(0, import_exception.W_ERROR)(
|
|
642
|
+
import_exception.WErrors.InvalidParam,
|
|
643
|
+
"Invalid context type: " + node.context
|
|
644
|
+
);
|
|
645
|
+
}
|
|
646
|
+
output.push(import_bcs.bcs.U8.serialize(contextValue).toBytes());
|
|
647
|
+
(0, import_util2.checkType)(import_common.ValueType.Address, type_required, node);
|
|
648
|
+
break;
|
|
649
|
+
}
|
|
650
|
+
default:
|
|
651
|
+
(0, import_exception.W_ERROR)(import_exception.WErrors.InvalidParam, "node:" + JSON.stringify(node));
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
const multi_operand_op = async (op_code, parameters, required_type, table, output) => {
|
|
655
|
+
if (parameters.length < 2 || parameters.length > import_common.MAX_MULTI_OPERANDS) {
|
|
656
|
+
(0, import_exception.W_ERROR)(
|
|
657
|
+
import_exception.WErrors.InvalidParam,
|
|
658
|
+
`op ${op_code} parameters length must >= 2 and <=
|
|
659
|
+
${import_common.MAX_MULTI_OPERANDS}. parameters:
|
|
660
|
+
${JSON.stringify(parameters)}`
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
for (let i = parameters.length - 1; i >= 0; --i) {
|
|
664
|
+
await buildNode(parameters[i], required_type, table, output);
|
|
665
|
+
}
|
|
666
|
+
output.push(import_bcs.bcs.U8.serialize(op_code).toBytes());
|
|
667
|
+
output.push(import_bcs.bcs.U8.serialize(parameters.length).toBytes());
|
|
668
|
+
};
|
|
669
|
+
const single_operand_op = async (op_code, parameter, required_type, table, output) => {
|
|
670
|
+
await buildNode(parameter, required_type, table, output);
|
|
671
|
+
output.push(import_bcs.bcs.U8.serialize(op_code).toBytes());
|
|
672
|
+
};
|
|
673
|
+
const guard2file = async (guard, file_path, format = "json", network) => {
|
|
674
|
+
const queryResult = await (0, import_object.query_objects)({
|
|
675
|
+
objects: [guard],
|
|
676
|
+
network
|
|
677
|
+
});
|
|
678
|
+
const objects = queryResult.objects;
|
|
679
|
+
if (!objects || objects.length === 0 || objects[0].type !== "Guard") {
|
|
680
|
+
(0, import_exception.W_ERROR)(
|
|
681
|
+
import_exception.WErrors.InvalidParam,
|
|
682
|
+
`guard2file: Guard object not found: ${guard}`
|
|
683
|
+
);
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
const guardObj = objects[0];
|
|
687
|
+
if (!guardObj) {
|
|
688
|
+
(0, import_exception.W_ERROR)(
|
|
689
|
+
import_exception.WErrors.InvalidParam,
|
|
690
|
+
`guard2file: Failed to get Guard object data: ${guard}`
|
|
691
|
+
);
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
let content;
|
|
695
|
+
if (format === "json") {
|
|
696
|
+
content = generateGuardJson(guardObj);
|
|
697
|
+
} else {
|
|
698
|
+
content = generateGuardMarkdown(guardObj);
|
|
699
|
+
}
|
|
700
|
+
try {
|
|
701
|
+
const resolvedPath = (0, import_path.resolve)(file_path);
|
|
702
|
+
(0, import_fs.writeFileSync)(resolvedPath, content, "utf-8");
|
|
703
|
+
} catch (e) {
|
|
704
|
+
(0, import_exception.W_ERROR)(
|
|
705
|
+
import_exception.WErrors.InvalidParam,
|
|
706
|
+
`guard2file: Failed to write file '${file_path}': ${e.message}`
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
const generateGuardJson = (guardObj) => {
|
|
711
|
+
const output = {};
|
|
712
|
+
if (guardObj.description) {
|
|
713
|
+
output.description = guardObj.description;
|
|
714
|
+
}
|
|
715
|
+
if (guardObj.table && guardObj.table.length > 0) {
|
|
716
|
+
output.table = guardObj.table.map((item) => ({
|
|
717
|
+
identifier: item.identifier,
|
|
718
|
+
b_submission: item.b_submission,
|
|
719
|
+
value_type: item.value_type,
|
|
720
|
+
value: item.value,
|
|
721
|
+
name: item.name
|
|
722
|
+
}));
|
|
723
|
+
}
|
|
724
|
+
if (guardObj.root) {
|
|
725
|
+
output.root = guardObj.root;
|
|
726
|
+
}
|
|
727
|
+
if (guardObj.relies && guardObj.relies.length > 0) {
|
|
728
|
+
output.rely = {
|
|
729
|
+
guards: guardObj.relies,
|
|
730
|
+
logic_or: !guardObj.relies_logic_and
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
return JSON.stringify(output, null, 2);
|
|
734
|
+
};
|
|
735
|
+
const generateGuardMarkdown = (guardObj) => {
|
|
736
|
+
const lines = [];
|
|
737
|
+
lines.push(`# Guard Definition`);
|
|
738
|
+
lines.push("");
|
|
739
|
+
lines.push(`**Object ID:** ${guardObj.object}`);
|
|
740
|
+
lines.push("");
|
|
741
|
+
lines.push("## Description");
|
|
742
|
+
lines.push("");
|
|
743
|
+
lines.push(guardObj.description || "");
|
|
744
|
+
lines.push("");
|
|
745
|
+
lines.push("## Table (Data Definitions)");
|
|
746
|
+
lines.push("");
|
|
747
|
+
lines.push("| Identifier | b_submission | value_type | value | name |");
|
|
748
|
+
lines.push("|------------|--------------|------------|-------|------|");
|
|
749
|
+
if (guardObj.table && guardObj.table.length > 0) {
|
|
750
|
+
for (const item of guardObj.table) {
|
|
751
|
+
const itemValueType = (0, import_common.parseValueType)(item.value_type);
|
|
752
|
+
const valueTypeStr = valueTypeToString(itemValueType);
|
|
753
|
+
const valueStr = formatValueForMarkdown(item.value);
|
|
754
|
+
lines.push(
|
|
755
|
+
`| ${item.identifier} | ${item.b_submission} | ${valueTypeStr} (${item.value_type}) | ${valueStr} | ${item.name} |`
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
} else {
|
|
759
|
+
lines.push("| - | - | - | - | - |");
|
|
760
|
+
}
|
|
761
|
+
lines.push("");
|
|
762
|
+
lines.push("## Root (Computational Tree)");
|
|
763
|
+
lines.push("");
|
|
764
|
+
lines.push("The root node MUST return a Bool value (pass/fail).");
|
|
765
|
+
lines.push("");
|
|
766
|
+
if (guardObj.root) {
|
|
767
|
+
lines.push("```json");
|
|
768
|
+
lines.push(JSON.stringify(guardObj.root, null, 2));
|
|
769
|
+
lines.push("```");
|
|
770
|
+
lines.push("");
|
|
771
|
+
const nodeComments = generateNodeComments(guardObj.root);
|
|
772
|
+
if (nodeComments.length > 0) {
|
|
773
|
+
lines.push("### Node Comments");
|
|
774
|
+
lines.push("");
|
|
775
|
+
for (const comment of nodeComments) {
|
|
776
|
+
lines.push(`- **${comment.type}**: ${comment.description}`);
|
|
777
|
+
}
|
|
778
|
+
lines.push("");
|
|
779
|
+
}
|
|
780
|
+
} else {
|
|
781
|
+
lines.push("*No root node data available*");
|
|
782
|
+
lines.push("");
|
|
783
|
+
}
|
|
784
|
+
if (guardObj.relies && guardObj.relies.length > 0) {
|
|
785
|
+
lines.push("## Rely (Dependencies)");
|
|
786
|
+
lines.push("");
|
|
787
|
+
lines.push(`**Logic:** ${guardObj.relies_logic_and ? "AND" : "OR"}`);
|
|
788
|
+
lines.push("");
|
|
789
|
+
lines.push("**Dependent Guards:**");
|
|
790
|
+
for (const rely of guardObj.relies) {
|
|
791
|
+
lines.push(`- ${rely}`);
|
|
792
|
+
}
|
|
793
|
+
lines.push("");
|
|
794
|
+
}
|
|
795
|
+
lines.push("## Guard Instructions Reference");
|
|
796
|
+
lines.push("");
|
|
797
|
+
lines.push("Use these instructions in query nodes:");
|
|
798
|
+
lines.push("");
|
|
799
|
+
lines.push("| ID | Name | Object Type | Return Type | Description |");
|
|
800
|
+
lines.push("|----|------|-------------|-------------|-------------|");
|
|
801
|
+
for (const query of import_guard_ins.GUARDQUERY.slice(0, 20)) {
|
|
802
|
+
lines.push(
|
|
803
|
+
`| ${query.id} | ${query.name} | ${query.objectType} | ${valueTypeToString(query.return)} | ${query.description} |`
|
|
804
|
+
);
|
|
805
|
+
}
|
|
806
|
+
lines.push("");
|
|
807
|
+
lines.push(
|
|
808
|
+
"*For complete list, use `wowok_buildin_info` with query='guard instructions'*"
|
|
809
|
+
);
|
|
810
|
+
lines.push("");
|
|
811
|
+
return lines.join("\n");
|
|
812
|
+
};
|
|
813
|
+
const formatValueForMarkdown = (value) => {
|
|
814
|
+
if (value === void 0 || value === null) {
|
|
815
|
+
return "-";
|
|
816
|
+
}
|
|
817
|
+
if (typeof value === "boolean") {
|
|
818
|
+
return value ? "true" : "false";
|
|
819
|
+
}
|
|
820
|
+
if (typeof value === "string") {
|
|
821
|
+
if (value.length > 30) {
|
|
822
|
+
return value.substring(0, 27) + "...";
|
|
823
|
+
}
|
|
824
|
+
return value;
|
|
825
|
+
}
|
|
826
|
+
if (typeof value === "number") {
|
|
827
|
+
return value.toString();
|
|
828
|
+
}
|
|
829
|
+
if (Array.isArray(value)) {
|
|
830
|
+
if (value.length === 0) return "[]";
|
|
831
|
+
if (value.length > 3) {
|
|
832
|
+
return `[${value.slice(0, 3).join(", ")}, ... (${value.length} items)]`;
|
|
833
|
+
}
|
|
834
|
+
return `[${value.join(", ")}]`;
|
|
835
|
+
}
|
|
836
|
+
if (typeof value === "object") {
|
|
837
|
+
return "{...}";
|
|
838
|
+
}
|
|
839
|
+
return String(value);
|
|
840
|
+
};
|
|
841
|
+
const generateNodeComments = (node, comments = []) => {
|
|
842
|
+
if (!node) return comments;
|
|
843
|
+
if (node.type === "query") {
|
|
844
|
+
const queryId = typeof node.query === "number" ? node.query : void 0;
|
|
845
|
+
if (queryId !== void 0) {
|
|
846
|
+
const queryInfo = import_guard_ins.GUARDQUERY.find((q) => q.id === queryId);
|
|
847
|
+
if (queryInfo) {
|
|
848
|
+
comments.push({
|
|
849
|
+
type: `query(${node.query})`,
|
|
850
|
+
description: `${queryInfo.name}: ${queryInfo.description}`
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
} else if (node.type.startsWith("logic_")) {
|
|
855
|
+
comments.push({
|
|
856
|
+
type: node.type,
|
|
857
|
+
description: `Logic operation: ${node.type.replace(/_/g, " ")}`
|
|
858
|
+
});
|
|
859
|
+
} else if (node.type.startsWith("calc_")) {
|
|
860
|
+
comments.push({
|
|
861
|
+
type: node.type,
|
|
862
|
+
description: `Calculation: ${node.type.replace(/_/g, " ")}`
|
|
863
|
+
});
|
|
864
|
+
} else if (node.type.startsWith("convert_")) {
|
|
865
|
+
comments.push({
|
|
866
|
+
type: node.type,
|
|
867
|
+
description: `Type conversion: ${node.type.replace(/_/g, " ")}`
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
if ("nodes" in node && Array.isArray(node.nodes)) {
|
|
871
|
+
for (const childNode of node.nodes) {
|
|
872
|
+
generateNodeComments(childNode, comments);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
if ("node" in node && node.node) {
|
|
876
|
+
generateNodeComments(node.node, comments);
|
|
877
|
+
}
|
|
878
|
+
if ("parameters" in node && Array.isArray(node.parameters)) {
|
|
879
|
+
for (const param of node.parameters) {
|
|
880
|
+
generateNodeComments(param, comments);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
if ("nodeLeft" in node && node.nodeLeft) {
|
|
884
|
+
generateNodeComments(node.nodeLeft, comments);
|
|
885
|
+
}
|
|
886
|
+
if ("nodeRight" in node && node.nodeRight) {
|
|
887
|
+
generateNodeComments(node.nodeRight, comments);
|
|
888
|
+
}
|
|
889
|
+
return comments;
|
|
890
|
+
};
|
|
891
|
+
const valueTypeToString = (valueType) => {
|
|
892
|
+
const typeMap = {
|
|
893
|
+
[import_common.ValueType.Bool]: "Bool",
|
|
894
|
+
[import_common.ValueType.Address]: "Address",
|
|
895
|
+
[import_common.ValueType.String]: "String",
|
|
896
|
+
[import_common.ValueType.U8]: "U8",
|
|
897
|
+
[import_common.ValueType.U16]: "U16",
|
|
898
|
+
[import_common.ValueType.U32]: "U32",
|
|
899
|
+
[import_common.ValueType.U64]: "U64",
|
|
900
|
+
[import_common.ValueType.U128]: "U128",
|
|
901
|
+
[import_common.ValueType.U256]: "U256",
|
|
902
|
+
[import_common.ValueType.VecBool]: "VecBool",
|
|
903
|
+
[import_common.ValueType.VecAddress]: "VecAddress",
|
|
904
|
+
[import_common.ValueType.VecString]: "VecString",
|
|
905
|
+
[import_common.ValueType.VecU8]: "VecU8",
|
|
906
|
+
[import_common.ValueType.VecU16]: "VecU16",
|
|
907
|
+
[import_common.ValueType.VecU32]: "VecU32",
|
|
908
|
+
[import_common.ValueType.VecU64]: "VecU64",
|
|
909
|
+
[import_common.ValueType.VecU128]: "VecU128",
|
|
910
|
+
[import_common.ValueType.VecU256]: "VecU256",
|
|
911
|
+
[import_common.ValueType.VecVecU8]: "VecVecU8",
|
|
912
|
+
[import_common.ValueType.Value]: "Value"
|
|
913
|
+
};
|
|
914
|
+
return typeMap[valueType] || `Unknown(${valueType})`;
|
|
915
|
+
};
|
|
916
|
+
const gen_passport = async (env, guard, info) => {
|
|
917
|
+
if (!(0, import_sui_types.isValidWowAddress)(guard)) {
|
|
918
|
+
(0, import_exception.W_ERROR)(import_exception.WErrors.InvalidParam, "guard invalid: guard empty");
|
|
919
|
+
}
|
|
920
|
+
await (0, import_util2.resolveCallEnv)(env);
|
|
921
|
+
const s = await (0, import_passport.get_guardSubmissions)(env, [guard]);
|
|
922
|
+
if (s.submission.length > 0) {
|
|
923
|
+
if (!info) {
|
|
924
|
+
return {
|
|
925
|
+
type: "submission",
|
|
926
|
+
guard: s.guard,
|
|
927
|
+
submission: s.submission
|
|
928
|
+
};
|
|
929
|
+
} else {
|
|
930
|
+
return await (0, import_passport.verify_guard)(env, info);
|
|
931
|
+
}
|
|
932
|
+
} else {
|
|
933
|
+
return await (0, import_passport.verify_guard)(env, {
|
|
934
|
+
type: "submission",
|
|
935
|
+
guard: [{ object: guard, impack: true }],
|
|
936
|
+
submission: []
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
function detectFileFormatFromContent(text) {
|
|
941
|
+
const trimmed = text.trim();
|
|
942
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
943
|
+
return "json";
|
|
944
|
+
}
|
|
945
|
+
return "markdown";
|
|
946
|
+
}
|
|
947
|
+
function extractJsonFromMarkdown(markdown) {
|
|
948
|
+
const codeBlockRegex = /```(?:json)?\s*\n([\s\S]*?)```/g;
|
|
949
|
+
let match;
|
|
950
|
+
let lastMatch = null;
|
|
951
|
+
while ((match = codeBlockRegex.exec(markdown)) !== null) {
|
|
952
|
+
const jsonContent = match[1].trim();
|
|
953
|
+
if (jsonContent.startsWith("{") || jsonContent.startsWith("[")) {
|
|
954
|
+
const beforeMatch = markdown.substring(0, match.index);
|
|
955
|
+
const lineOffset = (beforeMatch.match(/\n/g) || []).length + 1;
|
|
956
|
+
lastMatch = { json: jsonContent, lineOffset };
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
return lastMatch;
|
|
960
|
+
}
|
|
961
|
+
function parseTableFromMarkdown(section) {
|
|
962
|
+
const jsonMatch = section.match(/```(?:json)?\s*\n([\s\S]*?)```/);
|
|
963
|
+
if (jsonMatch) {
|
|
964
|
+
try {
|
|
965
|
+
const parsed = JSON.parse(jsonMatch[1]);
|
|
966
|
+
if (Array.isArray(parsed)) {
|
|
967
|
+
return parsed;
|
|
968
|
+
}
|
|
969
|
+
} catch {
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
const tableRows = section.match(/\|[^\n]+\|/g);
|
|
973
|
+
if (tableRows && tableRows.length > 2) {
|
|
974
|
+
return tableRows.slice(2).map((row) => {
|
|
975
|
+
const cells = row.split("|").filter((c) => c.trim()).map((c) => c.trim());
|
|
976
|
+
const valueTypeCell = cells[2];
|
|
977
|
+
let value_type;
|
|
978
|
+
const numericMatch = valueTypeCell.match(/\d+/);
|
|
979
|
+
if (numericMatch) {
|
|
980
|
+
value_type = parseInt(numericMatch[0], 10);
|
|
981
|
+
} else {
|
|
982
|
+
const typeNameMatch = valueTypeCell.match(/^([A-Za-z]+)/);
|
|
983
|
+
if (typeNameMatch) {
|
|
984
|
+
value_type = typeNameMatch[1];
|
|
985
|
+
} else {
|
|
986
|
+
throw new Error(
|
|
987
|
+
`Invalid value_type in table row: "${valueTypeCell}". Expected a number (0-19) or type name (e.g., "U64", "Address")`
|
|
988
|
+
);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
return {
|
|
992
|
+
identifier: parseInt(cells[0], 10),
|
|
993
|
+
b_submission: cells[1].toLowerCase() === "true",
|
|
994
|
+
value_type,
|
|
995
|
+
value: cells[3] === "-" ? void 0 : cells[3],
|
|
996
|
+
name: cells[4] === "-" ? void 0 : cells[4]
|
|
997
|
+
};
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
return void 0;
|
|
1001
|
+
}
|
|
1002
|
+
function parseRelyFromMarkdown(section) {
|
|
1003
|
+
const logicMatch = section.match(/\*\*Logic:\*\*\s*(AND|OR)/i);
|
|
1004
|
+
const guardListMatches = section.match(/^\s*[-*]\s*(\S+)$/gm);
|
|
1005
|
+
if (logicMatch || guardListMatches) {
|
|
1006
|
+
return {
|
|
1007
|
+
logic_or: logicMatch ? logicMatch[1].toUpperCase() === "OR" : false,
|
|
1008
|
+
guards: guardListMatches ? guardListMatches.map(
|
|
1009
|
+
(g) => g.replace(/^\s*[-*]\s*/, "").trim()
|
|
1010
|
+
) : []
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
return void 0;
|
|
1014
|
+
}
|
|
1015
|
+
function parseGuardFromMarkdown(content) {
|
|
1016
|
+
const errors = [];
|
|
1017
|
+
const result = {};
|
|
1018
|
+
const jsonMatch = extractJsonFromMarkdown(content);
|
|
1019
|
+
if (jsonMatch) {
|
|
1020
|
+
try {
|
|
1021
|
+
const parsed = JSON.parse(
|
|
1022
|
+
jsonMatch.json
|
|
1023
|
+
);
|
|
1024
|
+
Object.assign(result, parsed);
|
|
1025
|
+
} catch (e) {
|
|
1026
|
+
errors.push({
|
|
1027
|
+
message: `Failed to parse JSON from code block: ${e.message}`,
|
|
1028
|
+
path: "/",
|
|
1029
|
+
line: jsonMatch.lineOffset
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
if (!result.description) {
|
|
1034
|
+
const descMatch = content.match(
|
|
1035
|
+
/(?:^|\n)#+\s*(?:Description|Description|Description)[^\n]*\n+([^\n#]+)/i
|
|
1036
|
+
);
|
|
1037
|
+
if (descMatch) {
|
|
1038
|
+
result.description = descMatch[1].trim();
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
if (!result.table) {
|
|
1042
|
+
const tableMatch = content.match(
|
|
1043
|
+
/(?:^|\n)#+\s*(?:Table|Data Table|数据表)[^\n]*\n+([\s\S]*?)(?=(?:\n#+|$))/i
|
|
1044
|
+
);
|
|
1045
|
+
if (tableMatch) {
|
|
1046
|
+
const table = parseTableFromMarkdown(tableMatch[1]);
|
|
1047
|
+
if (table) {
|
|
1048
|
+
result.table = table;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
if (!result.root) {
|
|
1053
|
+
const rootMatch = content.match(
|
|
1054
|
+
/(?:^|\n)#+\s*(?:Root|根节点)[^\n]*\n+([\s\S]*?)(?=(?:\n#+|$))/i
|
|
1055
|
+
);
|
|
1056
|
+
if (rootMatch) {
|
|
1057
|
+
const rootSection = rootMatch[1];
|
|
1058
|
+
const rootJsonMatch = rootSection.match(
|
|
1059
|
+
/```(?:json)?\s*\n([\s\S]*?)```/
|
|
1060
|
+
);
|
|
1061
|
+
if (rootJsonMatch) {
|
|
1062
|
+
try {
|
|
1063
|
+
result.root = JSON.parse(rootJsonMatch[1]);
|
|
1064
|
+
} catch (e) {
|
|
1065
|
+
errors.push({
|
|
1066
|
+
message: `Failed to parse root JSON: ${e.message}`,
|
|
1067
|
+
path: "/root"
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
if (!result.rely) {
|
|
1074
|
+
const relyMatch = content.match(
|
|
1075
|
+
/(?:^|\n)#+\s*(?:Rely|Dependencies|依赖)[^\n]*\n+([\s\S]*?)(?=(?:\n#+|$))/i
|
|
1076
|
+
);
|
|
1077
|
+
if (relyMatch) {
|
|
1078
|
+
const rely = parseRelyFromMarkdown(relyMatch[1]);
|
|
1079
|
+
if (rely) {
|
|
1080
|
+
result.rely = rely;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
if (!result.root) {
|
|
1085
|
+
errors.push({
|
|
1086
|
+
message: "Guard root node not found in markdown file",
|
|
1087
|
+
path: "/root"
|
|
1088
|
+
});
|
|
1089
|
+
return { success: false, errors };
|
|
1090
|
+
}
|
|
1091
|
+
return {
|
|
1092
|
+
success: true,
|
|
1093
|
+
data: result,
|
|
1094
|
+
errors
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1097
|
+
function parseGuardFile(content, format) {
|
|
1098
|
+
const detectedFormat = format ?? detectFileFormatFromContent(content);
|
|
1099
|
+
if (detectedFormat === "json") {
|
|
1100
|
+
try {
|
|
1101
|
+
const parsed = JSON.parse(content);
|
|
1102
|
+
if (!parsed.root) {
|
|
1103
|
+
return {
|
|
1104
|
+
success: false,
|
|
1105
|
+
errors: [
|
|
1106
|
+
{
|
|
1107
|
+
message: "Missing required field: root",
|
|
1108
|
+
path: "/root"
|
|
1109
|
+
}
|
|
1110
|
+
]
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
return { success: true, data: parsed, errors: [] };
|
|
1114
|
+
} catch (e) {
|
|
1115
|
+
return {
|
|
1116
|
+
success: false,
|
|
1117
|
+
errors: [
|
|
1118
|
+
{
|
|
1119
|
+
message: `JSON parse error: ${e.message}`,
|
|
1120
|
+
path: "/"
|
|
1121
|
+
}
|
|
1122
|
+
]
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
return parseGuardFromMarkdown(content);
|
|
1127
|
+
}
|
|
1128
|
+
function validateGuardNode(node) {
|
|
1129
|
+
const errors = [];
|
|
1130
|
+
if (!node || typeof node !== "object") {
|
|
1131
|
+
errors.push({ message: "GuardNode must be an object", path: "/" });
|
|
1132
|
+
return { success: false, errors };
|
|
1133
|
+
}
|
|
1134
|
+
const n = node;
|
|
1135
|
+
if (!n.type || typeof n.type !== "string") {
|
|
1136
|
+
errors.push({
|
|
1137
|
+
message: "GuardNode must have a 'type' property",
|
|
1138
|
+
path: "/type"
|
|
1139
|
+
});
|
|
1140
|
+
return { success: false, errors };
|
|
1141
|
+
}
|
|
1142
|
+
const validTypes = [
|
|
1143
|
+
"identifier",
|
|
1144
|
+
"query",
|
|
1145
|
+
"context",
|
|
1146
|
+
"logic_not",
|
|
1147
|
+
"logic_and",
|
|
1148
|
+
"logic_or",
|
|
1149
|
+
"logic_equal",
|
|
1150
|
+
"logic_as_u256_greater_or_equal",
|
|
1151
|
+
"logic_as_u256_lesser_or_equal",
|
|
1152
|
+
"logic_as_u256_greater",
|
|
1153
|
+
"logic_as_u256_lesser",
|
|
1154
|
+
"logic_as_u256_equal",
|
|
1155
|
+
"logic_string_contains",
|
|
1156
|
+
"logic_string_nocase_contains",
|
|
1157
|
+
"logic_string_nocase_equal",
|
|
1158
|
+
"calc_number_add",
|
|
1159
|
+
"calc_number_subtract",
|
|
1160
|
+
"calc_number_multiply",
|
|
1161
|
+
"calc_number_divide",
|
|
1162
|
+
"calc_number_mod",
|
|
1163
|
+
"calc_string_length",
|
|
1164
|
+
"calc_string_nocase_contains",
|
|
1165
|
+
"calc_string_nocase_equal",
|
|
1166
|
+
"calc_string_contains",
|
|
1167
|
+
"calc_string_indexof",
|
|
1168
|
+
"calc_string_nocase_indexof",
|
|
1169
|
+
"convert_number_address",
|
|
1170
|
+
"convert_address_number",
|
|
1171
|
+
"convert_number_string",
|
|
1172
|
+
"convert_string_number",
|
|
1173
|
+
"convert_safe_u8",
|
|
1174
|
+
"convert_safe_u16",
|
|
1175
|
+
"convert_safe_u32",
|
|
1176
|
+
"convert_safe_u64",
|
|
1177
|
+
"convert_safe_u128",
|
|
1178
|
+
"convert_safe_u256",
|
|
1179
|
+
"value_type",
|
|
1180
|
+
"vec_length",
|
|
1181
|
+
"vec_contains_bool",
|
|
1182
|
+
"vec_contains_address",
|
|
1183
|
+
"vec_contains_string",
|
|
1184
|
+
"vec_contains_string_nocase",
|
|
1185
|
+
"vec_contains_number",
|
|
1186
|
+
"vec_indexof_bool",
|
|
1187
|
+
"vec_indexof_address",
|
|
1188
|
+
"vec_indexof_string",
|
|
1189
|
+
"vec_indexof_string_nocase",
|
|
1190
|
+
"vec_indexof_number"
|
|
1191
|
+
];
|
|
1192
|
+
if (!validTypes.includes(n.type)) {
|
|
1193
|
+
errors.push({
|
|
1194
|
+
message: `Invalid GuardNode type: ${n.type}`,
|
|
1195
|
+
path: "/type"
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1198
|
+
return { success: errors.length === 0, errors };
|
|
1199
|
+
}
|
|
1200
|
+
function formatGuardParseErrors(errors) {
|
|
1201
|
+
return errors.map((e) => {
|
|
1202
|
+
let msg = `Path: ${e.path}`;
|
|
1203
|
+
if (e.line !== void 0 && e.column !== void 0) {
|
|
1204
|
+
msg += ` (line ${e.line}, column ${e.column})`;
|
|
1205
|
+
}
|
|
1206
|
+
msg += `
|
|
1207
|
+
Error: ${e.message}`;
|
|
1208
|
+
return msg;
|
|
1209
|
+
}).join("\n\n");
|
|
1210
|
+
}
|