@unconfirmed/effect-sui 0.0.0-stage → 0.1.0
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/LICENSE +202 -0
- package/README.md +10 -2
- package/dist/Address.d.ts +18 -0
- package/dist/Address.d.ts.map +1 -0
- package/dist/Address.js +33 -0
- package/dist/Address.js.map +1 -0
- package/dist/AddressAlias.d.ts +107 -0
- package/dist/AddressAlias.d.ts.map +1 -0
- package/dist/AddressAlias.js +104 -0
- package/dist/AddressAlias.js.map +1 -0
- package/dist/Bip32.d.ts +6 -0
- package/dist/Bip32.d.ts.map +1 -0
- package/dist/Bip32.js +34 -0
- package/dist/Bip32.js.map +1 -0
- package/dist/Chain.d.ts +23 -0
- package/dist/Chain.d.ts.map +1 -0
- package/dist/Chain.js +7 -0
- package/dist/Chain.js.map +1 -0
- package/dist/CheckpointData.d.ts +74 -0
- package/dist/CheckpointData.d.ts.map +1 -0
- package/dist/CheckpointData.js +48 -0
- package/dist/CheckpointData.js.map +1 -0
- package/dist/Checkpoints.d.ts +23 -0
- package/dist/Checkpoints.d.ts.map +1 -0
- package/dist/Checkpoints.js +7 -0
- package/dist/Checkpoints.js.map +1 -0
- package/dist/CoinReservation.d.ts +18 -0
- package/dist/CoinReservation.d.ts.map +1 -0
- package/dist/CoinReservation.js +58 -0
- package/dist/CoinReservation.js.map +1 -0
- package/dist/Coins.d.ts +42 -0
- package/dist/Coins.d.ts.map +1 -0
- package/dist/Coins.js +49 -0
- package/dist/Coins.js.map +1 -0
- package/dist/DynamicFields.d.ts +115 -0
- package/dist/DynamicFields.d.ts.map +1 -0
- package/dist/DynamicFields.js +101 -0
- package/dist/DynamicFields.js.map +1 -0
- package/dist/Ecdsa.d.ts +39 -0
- package/dist/Ecdsa.d.ts.map +1 -0
- package/dist/Ecdsa.js +76 -0
- package/dist/Ecdsa.js.map +1 -0
- package/dist/Ed25519.d.ts +22 -0
- package/dist/Ed25519.d.ts.map +1 -0
- package/dist/Ed25519.js +77 -0
- package/dist/Ed25519.js.map +1 -0
- package/dist/Events.d.ts +105 -0
- package/dist/Events.d.ts.map +1 -0
- package/dist/Events.js +51 -0
- package/dist/Events.js.map +1 -0
- package/dist/Hash.d.ts +16 -0
- package/dist/Hash.d.ts.map +1 -0
- package/dist/Hash.js +32 -0
- package/dist/Hash.js.map +1 -0
- package/dist/MlDsa65.d.ts +17 -0
- package/dist/MlDsa65.d.ts.map +1 -0
- package/dist/MlDsa65.js +84 -0
- package/dist/MlDsa65.js.map +1 -0
- package/dist/Mnemonic.d.ts +20 -0
- package/dist/Mnemonic.d.ts.map +1 -0
- package/dist/Mnemonic.js +71 -0
- package/dist/Mnemonic.js.map +1 -0
- package/dist/Move.d.ts +261 -0
- package/dist/Move.d.ts.map +1 -0
- package/dist/Move.js +232 -0
- package/dist/Move.js.map +1 -0
- package/dist/MultiSig.d.ts +106 -0
- package/dist/MultiSig.d.ts.map +1 -0
- package/dist/MultiSig.js +254 -0
- package/dist/MultiSig.js.map +1 -0
- package/dist/Objects.d.ts +95 -0
- package/dist/Objects.d.ts.map +1 -0
- package/dist/Objects.js +57 -0
- package/dist/Objects.js.map +1 -0
- package/dist/Packages.d.ts +49 -0
- package/dist/Packages.d.ts.map +1 -0
- package/dist/Packages.js +16 -0
- package/dist/Packages.js.map +1 -0
- package/dist/Passkey.d.ts +11 -0
- package/dist/Passkey.d.ts.map +1 -0
- package/dist/Passkey.js +11 -0
- package/dist/Passkey.js.map +1 -0
- package/dist/PrivateKey.d.ts +39 -0
- package/dist/PrivateKey.d.ts.map +1 -0
- package/dist/PrivateKey.js +118 -0
- package/dist/PrivateKey.js.map +1 -0
- package/dist/Ptb.d.ts +413 -0
- package/dist/Ptb.d.ts.map +1 -0
- package/dist/Ptb.js +338 -0
- package/dist/Ptb.js.map +1 -0
- package/dist/Resolve.d.ts +502 -0
- package/dist/Resolve.d.ts.map +1 -0
- package/dist/Resolve.js +1188 -0
- package/dist/Resolve.js.map +1 -0
- package/dist/RpcError.d.ts +19 -0
- package/dist/RpcError.d.ts.map +1 -0
- package/dist/RpcError.js +37 -0
- package/dist/RpcError.js.map +1 -0
- package/dist/Secp256k1.d.ts +11 -0
- package/dist/Secp256k1.d.ts.map +1 -0
- package/dist/Secp256k1.js +23 -0
- package/dist/Secp256k1.js.map +1 -0
- package/dist/Secp256r1.d.ts +11 -0
- package/dist/Secp256r1.d.ts.map +1 -0
- package/dist/Secp256r1.js +23 -0
- package/dist/Secp256r1.js.map +1 -0
- package/dist/SignatureScheme.d.ts +103 -0
- package/dist/SignatureScheme.d.ts.map +1 -0
- package/dist/SignatureScheme.js +93 -0
- package/dist/SignatureScheme.js.map +1 -0
- package/dist/Signer.d.ts +54 -0
- package/dist/Signer.d.ts.map +1 -0
- package/dist/Signer.js +31 -0
- package/dist/Signer.js.map +1 -0
- package/dist/Testing.d.ts +171 -0
- package/dist/Testing.d.ts.map +1 -0
- package/dist/Testing.js +531 -0
- package/dist/Testing.js.map +1 -0
- package/dist/TransactionData.d.ts +3218 -0
- package/dist/TransactionData.d.ts.map +1 -0
- package/dist/TransactionData.js +105 -0
- package/dist/TransactionData.js.map +1 -0
- package/dist/TransactionJson.d.ts +1544 -0
- package/dist/TransactionJson.d.ts.map +1 -0
- package/dist/TransactionJson.js +926 -0
- package/dist/TransactionJson.js.map +1 -0
- package/dist/Transactions.d.ts +181 -0
- package/dist/Transactions.d.ts.map +1 -0
- package/dist/Transactions.js +49 -0
- package/dist/Transactions.js.map +1 -0
- package/dist/Tx.d.ts +1419 -0
- package/dist/Tx.d.ts.map +1 -0
- package/dist/Tx.js +266 -0
- package/dist/Tx.js.map +1 -0
- package/dist/TypeTag.d.ts +42 -0
- package/dist/TypeTag.d.ts.map +1 -0
- package/dist/TypeTag.js +110 -0
- package/dist/TypeTag.js.map +1 -0
- package/dist/Verify.d.ts +23 -0
- package/dist/Verify.d.ts.map +1 -0
- package/dist/Verify.js +29 -0
- package/dist/Verify.js.map +1 -0
- package/dist/enoki/EnokiClient.d.ts +184 -0
- package/dist/enoki/EnokiClient.d.ts.map +1 -0
- package/dist/enoki/EnokiClient.js +105 -0
- package/dist/enoki/EnokiClient.js.map +1 -0
- package/dist/enoki/EnokiHttp.d.ts +33 -0
- package/dist/enoki/EnokiHttp.d.ts.map +1 -0
- package/dist/enoki/EnokiHttp.js +160 -0
- package/dist/enoki/EnokiHttp.js.map +1 -0
- package/dist/enoki/Sponsor.d.ts +119 -0
- package/dist/enoki/Sponsor.d.ts.map +1 -0
- package/dist/enoki/Sponsor.js +170 -0
- package/dist/enoki/Sponsor.js.map +1 -0
- package/dist/enoki/ZkLoginFlow.d.ts +84 -0
- package/dist/enoki/ZkLoginFlow.d.ts.map +1 -0
- package/dist/enoki/ZkLoginFlow.js +138 -0
- package/dist/enoki/ZkLoginFlow.js.map +1 -0
- package/dist/enoki/index.d.ts +9 -0
- package/dist/enoki/index.d.ts.map +1 -0
- package/dist/enoki/index.js +9 -0
- package/dist/enoki/index.js.map +1 -0
- package/dist/graphql/ChainGraphQL.d.ts +35 -0
- package/dist/graphql/ChainGraphQL.d.ts.map +1 -0
- package/dist/graphql/ChainGraphQL.js +62 -0
- package/dist/graphql/ChainGraphQL.js.map +1 -0
- package/dist/graphql/CheckpointDataGraphQL.d.ts +785 -0
- package/dist/graphql/CheckpointDataGraphQL.d.ts.map +1 -0
- package/dist/graphql/CheckpointDataGraphQL.js +157 -0
- package/dist/graphql/CheckpointDataGraphQL.js.map +1 -0
- package/dist/graphql/CheckpointsGraphQL.d.ts +91 -0
- package/dist/graphql/CheckpointsGraphQL.d.ts.map +1 -0
- package/dist/graphql/CheckpointsGraphQL.js +80 -0
- package/dist/graphql/CheckpointsGraphQL.js.map +1 -0
- package/dist/graphql/CoinsGraphQL.d.ts +81 -0
- package/dist/graphql/CoinsGraphQL.d.ts.map +1 -0
- package/dist/graphql/CoinsGraphQL.js +63 -0
- package/dist/graphql/CoinsGraphQL.js.map +1 -0
- package/dist/graphql/DynamicFieldsGraphQL.d.ts +94 -0
- package/dist/graphql/DynamicFieldsGraphQL.d.ts.map +1 -0
- package/dist/graphql/DynamicFieldsGraphQL.js +126 -0
- package/dist/graphql/DynamicFieldsGraphQL.js.map +1 -0
- package/dist/graphql/EventsGraphQL.d.ts +266 -0
- package/dist/graphql/EventsGraphQL.d.ts.map +1 -0
- package/dist/graphql/EventsGraphQL.js +249 -0
- package/dist/graphql/EventsGraphQL.js.map +1 -0
- package/dist/graphql/ObjectsGraphQL.d.ts +130 -0
- package/dist/graphql/ObjectsGraphQL.d.ts.map +1 -0
- package/dist/graphql/ObjectsGraphQL.js +79 -0
- package/dist/graphql/ObjectsGraphQL.js.map +1 -0
- package/dist/graphql/PackagesGraphQL.d.ts +82 -0
- package/dist/graphql/PackagesGraphQL.d.ts.map +1 -0
- package/dist/graphql/PackagesGraphQL.js +145 -0
- package/dist/graphql/PackagesGraphQL.js.map +1 -0
- package/dist/graphql/SuiGraphQL.d.ts +37 -0
- package/dist/graphql/SuiGraphQL.d.ts.map +1 -0
- package/dist/graphql/SuiGraphQL.js +47 -0
- package/dist/graphql/SuiGraphQL.js.map +1 -0
- package/dist/graphql/TransactionsGraphQL.d.ts +1309 -0
- package/dist/graphql/TransactionsGraphQL.d.ts.map +1 -0
- package/dist/graphql/TransactionsGraphQL.js +206 -0
- package/dist/graphql/TransactionsGraphQL.js.map +1 -0
- package/dist/graphql/convert.d.ts +505 -0
- package/dist/graphql/convert.d.ts.map +1 -0
- package/dist/graphql/convert.js +384 -0
- package/dist/graphql/convert.js.map +1 -0
- package/dist/graphql/index.d.ts +41 -0
- package/dist/graphql/index.d.ts.map +1 -0
- package/dist/graphql/index.js +20 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/graphql/merge.d.ts +8 -0
- package/dist/graphql/merge.d.ts.map +1 -0
- package/dist/graphql/merge.js +55 -0
- package/dist/graphql/merge.js.map +1 -0
- package/dist/graphql/paging.d.ts +219 -0
- package/dist/graphql/paging.d.ts.map +1 -0
- package/dist/graphql/paging.js +74 -0
- package/dist/graphql/paging.js.map +1 -0
- package/dist/graphql/subscription.d.ts +27 -0
- package/dist/graphql/subscription.d.ts.map +1 -0
- package/dist/graphql/subscription.js +47 -0
- package/dist/graphql/subscription.js.map +1 -0
- package/dist/graphql/tip.d.ts +31 -0
- package/dist/graphql/tip.d.ts.map +1 -0
- package/dist/graphql/tip.js +29 -0
- package/dist/graphql/tip.js.map +1 -0
- package/dist/grpc/ChainGrpc.d.ts +11 -0
- package/dist/grpc/ChainGrpc.d.ts.map +1 -0
- package/dist/grpc/ChainGrpc.js +40 -0
- package/dist/grpc/ChainGrpc.js.map +1 -0
- package/dist/grpc/CheckpointDataGrpc.d.ts +6 -0
- package/dist/grpc/CheckpointDataGrpc.d.ts.map +1 -0
- package/dist/grpc/CheckpointDataGrpc.js +27 -0
- package/dist/grpc/CheckpointDataGrpc.js.map +1 -0
- package/dist/grpc/CheckpointsGrpc.d.ts +6 -0
- package/dist/grpc/CheckpointsGrpc.d.ts.map +1 -0
- package/dist/grpc/CheckpointsGrpc.js +25 -0
- package/dist/grpc/CheckpointsGrpc.js.map +1 -0
- package/dist/grpc/CoinsGrpc.d.ts +7 -0
- package/dist/grpc/CoinsGrpc.d.ts.map +1 -0
- package/dist/grpc/CoinsGrpc.js +34 -0
- package/dist/grpc/CoinsGrpc.js.map +1 -0
- package/dist/grpc/DynamicFieldsGrpc.d.ts +11 -0
- package/dist/grpc/DynamicFieldsGrpc.d.ts.map +1 -0
- package/dist/grpc/DynamicFieldsGrpc.js +91 -0
- package/dist/grpc/DynamicFieldsGrpc.js.map +1 -0
- package/dist/grpc/EventsGrpc.d.ts +13 -0
- package/dist/grpc/EventsGrpc.d.ts.map +1 -0
- package/dist/grpc/EventsGrpc.js +88 -0
- package/dist/grpc/EventsGrpc.js.map +1 -0
- package/dist/grpc/GrpcWeb.d.ts +71 -0
- package/dist/grpc/GrpcWeb.d.ts.map +1 -0
- package/dist/grpc/GrpcWeb.js +243 -0
- package/dist/grpc/GrpcWeb.js.map +1 -0
- package/dist/grpc/ObjectsGrpc.d.ts +10 -0
- package/dist/grpc/ObjectsGrpc.d.ts.map +1 -0
- package/dist/grpc/ObjectsGrpc.js +72 -0
- package/dist/grpc/ObjectsGrpc.js.map +1 -0
- package/dist/grpc/PackagesGrpc.d.ts +9 -0
- package/dist/grpc/PackagesGrpc.d.ts.map +1 -0
- package/dist/grpc/PackagesGrpc.js +78 -0
- package/dist/grpc/PackagesGrpc.js.map +1 -0
- package/dist/grpc/Rpc.d.ts +46 -0
- package/dist/grpc/Rpc.d.ts.map +1 -0
- package/dist/grpc/Rpc.js +111 -0
- package/dist/grpc/Rpc.js.map +1 -0
- package/dist/grpc/TransactionsGrpc.d.ts +6 -0
- package/dist/grpc/TransactionsGrpc.d.ts.map +1 -0
- package/dist/grpc/TransactionsGrpc.js +56 -0
- package/dist/grpc/TransactionsGrpc.js.map +1 -0
- package/dist/grpc/cache.d.ts +7 -0
- package/dist/grpc/cache.d.ts.map +1 -0
- package/dist/grpc/cache.js +55 -0
- package/dist/grpc/cache.js.map +1 -0
- package/dist/grpc/convert.d.ts +43 -0
- package/dist/grpc/convert.d.ts.map +1 -0
- package/dist/grpc/convert.js +198 -0
- package/dist/grpc/convert.js.map +1 -0
- package/dist/grpc/generated/lean.d.ts +36 -0
- package/dist/grpc/generated/lean.d.ts.map +1 -0
- package/dist/grpc/generated/lean.js +205 -0
- package/dist/grpc/generated/lean.js.map +1 -0
- package/dist/grpc/generated/proto.d.ts +2000 -0
- package/dist/grpc/generated/proto.d.ts.map +1 -0
- package/dist/grpc/generated/proto.js +356 -0
- package/dist/grpc/generated/proto.js.map +1 -0
- package/dist/grpc/generated/rpc.d.ts +62 -0
- package/dist/grpc/generated/rpc.d.ts.map +1 -0
- package/dist/grpc/generated/rpc.js +324 -0
- package/dist/grpc/generated/rpc.js.map +1 -0
- package/dist/grpc/index.d.ts +58 -0
- package/dist/grpc/index.d.ts.map +1 -0
- package/dist/grpc/index.js +43 -0
- package/dist/grpc/index.js.map +1 -0
- package/dist/grpc/scan.d.ts +79 -0
- package/dist/grpc/scan.d.ts.map +1 -0
- package/dist/grpc/scan.js +126 -0
- package/dist/grpc/scan.js.map +1 -0
- package/dist/grpc/transaction.d.ts +9 -0
- package/dist/grpc/transaction.d.ts.map +1 -0
- package/dist/grpc/transaction.js +168 -0
- package/dist/grpc/transaction.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/allowances.d.ts +18 -0
- package/dist/internal/allowances.d.ts.map +1 -0
- package/dist/internal/allowances.js +194 -0
- package/dist/internal/allowances.js.map +1 -0
- package/dist/internal/mnemonic.d.ts +53 -0
- package/dist/internal/mnemonic.d.ts.map +1 -0
- package/dist/internal/mnemonic.js +66 -0
- package/dist/internal/mnemonic.js.map +1 -0
- package/dist/internal/passkey/BrowserProvider.d.ts +10 -0
- package/dist/internal/passkey/BrowserProvider.d.ts.map +1 -0
- package/dist/internal/passkey/BrowserProvider.js +101 -0
- package/dist/internal/passkey/BrowserProvider.js.map +1 -0
- package/dist/internal/passkey/Passkey.d.ts +104 -0
- package/dist/internal/passkey/Passkey.d.ts.map +1 -0
- package/dist/internal/passkey/Passkey.js +333 -0
- package/dist/internal/passkey/Passkey.js.map +1 -0
- package/dist/internal/passkey/SoftwareProvider.d.ts +23 -0
- package/dist/internal/passkey/SoftwareProvider.d.ts.map +1 -0
- package/dist/internal/passkey/SoftwareProvider.js +61 -0
- package/dist/internal/passkey/SoftwareProvider.js.map +1 -0
- package/dist/lifecycle/Evidence.d.ts +62 -0
- package/dist/lifecycle/Evidence.d.ts.map +1 -0
- package/dist/lifecycle/Evidence.js +30 -0
- package/dist/lifecycle/Evidence.js.map +1 -0
- package/dist/lifecycle/EvidenceGraphQL.d.ts +59 -0
- package/dist/lifecycle/EvidenceGraphQL.d.ts.map +1 -0
- package/dist/lifecycle/EvidenceGraphQL.js +53 -0
- package/dist/lifecycle/EvidenceGraphQL.js.map +1 -0
- package/dist/lifecycle/EvidenceGrpc.d.ts +4 -0
- package/dist/lifecycle/EvidenceGrpc.d.ts.map +1 -0
- package/dist/lifecycle/EvidenceGrpc.js +37 -0
- package/dist/lifecycle/EvidenceGrpc.js.map +1 -0
- package/dist/lifecycle/Journal.d.ts +69 -0
- package/dist/lifecycle/Journal.d.ts.map +1 -0
- package/dist/lifecycle/Journal.js +70 -0
- package/dist/lifecycle/Journal.js.map +1 -0
- package/dist/lifecycle/JournalEntry.d.ts +67 -0
- package/dist/lifecycle/JournalEntry.d.ts.map +1 -0
- package/dist/lifecycle/JournalEntry.js +45 -0
- package/dist/lifecycle/JournalEntry.js.map +1 -0
- package/dist/lifecycle/JournalKeyValueStore.d.ts +30 -0
- package/dist/lifecycle/JournalKeyValueStore.d.ts.map +1 -0
- package/dist/lifecycle/JournalKeyValueStore.js +217 -0
- package/dist/lifecycle/JournalKeyValueStore.js.map +1 -0
- package/dist/lifecycle/KeyValueStoreIndexedDb.d.ts +54 -0
- package/dist/lifecycle/KeyValueStoreIndexedDb.d.ts.map +1 -0
- package/dist/lifecycle/KeyValueStoreIndexedDb.js +321 -0
- package/dist/lifecycle/KeyValueStoreIndexedDb.js.map +1 -0
- package/dist/lifecycle/KeyValueStoreOpfs.d.ts +65 -0
- package/dist/lifecycle/KeyValueStoreOpfs.d.ts.map +1 -0
- package/dist/lifecycle/KeyValueStoreOpfs.js +207 -0
- package/dist/lifecycle/KeyValueStoreOpfs.js.map +1 -0
- package/dist/lifecycle/Lifecycle.d.ts +416 -0
- package/dist/lifecycle/Lifecycle.d.ts.map +1 -0
- package/dist/lifecycle/Lifecycle.js +666 -0
- package/dist/lifecycle/Lifecycle.js.map +1 -0
- package/dist/lifecycle/Outcome.d.ts +132 -0
- package/dist/lifecycle/Outcome.d.ts.map +1 -0
- package/dist/lifecycle/Outcome.js +106 -0
- package/dist/lifecycle/Outcome.js.map +1 -0
- package/dist/lifecycle/SenderLock.d.ts +37 -0
- package/dist/lifecycle/SenderLock.d.ts.map +1 -0
- package/dist/lifecycle/SenderLock.js +57 -0
- package/dist/lifecycle/SenderLock.js.map +1 -0
- package/dist/lifecycle/SenderLockWebLocks.d.ts +37 -0
- package/dist/lifecycle/SenderLockWebLocks.d.ts.map +1 -0
- package/dist/lifecycle/SenderLockWebLocks.js +100 -0
- package/dist/lifecycle/SenderLockWebLocks.js.map +1 -0
- package/dist/lifecycle/SignedTransaction.d.ts +55 -0
- package/dist/lifecycle/SignedTransaction.d.ts.map +1 -0
- package/dist/lifecycle/SignedTransaction.js +109 -0
- package/dist/lifecycle/SignedTransaction.js.map +1 -0
- package/dist/lifecycle/SubmitConfig.d.ts +44 -0
- package/dist/lifecycle/SubmitConfig.d.ts.map +1 -0
- package/dist/lifecycle/SubmitConfig.js +39 -0
- package/dist/lifecycle/SubmitConfig.js.map +1 -0
- package/dist/lifecycle/index.d.ts +13 -0
- package/dist/lifecycle/index.d.ts.map +1 -0
- package/dist/lifecycle/index.js +13 -0
- package/dist/lifecycle/index.js.map +1 -0
- package/dist/wallet/Features.d.ts +91 -0
- package/dist/wallet/Features.d.ts.map +1 -0
- package/dist/wallet/Features.js +14 -0
- package/dist/wallet/Features.js.map +1 -0
- package/dist/wallet/Wallet.d.ts +151 -0
- package/dist/wallet/Wallet.d.ts.map +1 -0
- package/dist/wallet/Wallet.js +399 -0
- package/dist/wallet/Wallet.js.map +1 -0
- package/dist/wallet/index.d.ts +6 -0
- package/dist/wallet/index.d.ts.map +1 -0
- package/dist/wallet/index.js +6 -0
- package/dist/wallet/index.js.map +1 -0
- package/dist/zklogin/AddressSeed.d.ts +40 -0
- package/dist/zklogin/AddressSeed.d.ts.map +1 -0
- package/dist/zklogin/AddressSeed.js +91 -0
- package/dist/zklogin/AddressSeed.js.map +1 -0
- package/dist/zklogin/Errors.d.ts +24 -0
- package/dist/zklogin/Errors.d.ts.map +1 -0
- package/dist/zklogin/Errors.js +25 -0
- package/dist/zklogin/Errors.js.map +1 -0
- package/dist/zklogin/Jwt.d.ts +51 -0
- package/dist/zklogin/Jwt.d.ts.map +1 -0
- package/dist/zklogin/Jwt.js +159 -0
- package/dist/zklogin/Jwt.js.map +1 -0
- package/dist/zklogin/Nonce.d.ts +9 -0
- package/dist/zklogin/Nonce.d.ts.map +1 -0
- package/dist/zklogin/Nonce.js +34 -0
- package/dist/zklogin/Nonce.js.map +1 -0
- package/dist/zklogin/Poseidon.d.ts +24 -0
- package/dist/zklogin/Poseidon.d.ts.map +1 -0
- package/dist/zklogin/Poseidon.js +54 -0
- package/dist/zklogin/Poseidon.js.map +1 -0
- package/dist/zklogin/PublicIdentifier.d.ts +49 -0
- package/dist/zklogin/PublicIdentifier.d.ts.map +1 -0
- package/dist/zklogin/PublicIdentifier.js +90 -0
- package/dist/zklogin/PublicIdentifier.js.map +1 -0
- package/dist/zklogin/Signature.d.ts +55 -0
- package/dist/zklogin/Signature.d.ts.map +1 -0
- package/dist/zklogin/Signature.js +70 -0
- package/dist/zklogin/Signature.js.map +1 -0
- package/dist/zklogin/ZkLogin.d.ts +41 -0
- package/dist/zklogin/ZkLogin.d.ts.map +1 -0
- package/dist/zklogin/ZkLogin.js +87 -0
- package/dist/zklogin/ZkLogin.js.map +1 -0
- package/dist/zklogin/ZkLoginAddress.d.ts +30 -0
- package/dist/zklogin/ZkLoginAddress.d.ts.map +1 -0
- package/dist/zklogin/ZkLoginAddress.js +31 -0
- package/dist/zklogin/ZkLoginAddress.js.map +1 -0
- package/dist/zklogin/ZkLoginVerifier.d.ts +37 -0
- package/dist/zklogin/ZkLoginVerifier.d.ts.map +1 -0
- package/dist/zklogin/ZkLoginVerifier.js +4 -0
- package/dist/zklogin/ZkLoginVerifier.js.map +1 -0
- package/dist/zklogin/ZkLoginVerifierGrpc.d.ts +12 -0
- package/dist/zklogin/ZkLoginVerifierGrpc.d.ts.map +1 -0
- package/dist/zklogin/ZkLoginVerifierGrpc.js +53 -0
- package/dist/zklogin/ZkLoginVerifierGrpc.js.map +1 -0
- package/dist/zklogin/index.d.ts +17 -0
- package/dist/zklogin/index.d.ts.map +1 -0
- package/dist/zklogin/index.js +17 -0
- package/dist/zklogin/index.js.map +1 -0
- package/dist/zklogin/internal/parse.d.ts +9 -0
- package/dist/zklogin/internal/parse.d.ts.map +1 -0
- package/dist/zklogin/internal/parse.js +33 -0
- package/dist/zklogin/internal/parse.js.map +1 -0
- package/dist/zklogin/internal/poseidon.d.ts +21 -0
- package/dist/zklogin/internal/poseidon.d.ts.map +1 -0
- package/dist/zklogin/internal/poseidon.js +40 -0
- package/dist/zklogin/internal/poseidon.js.map +1 -0
- package/package.json +69 -4
- package/src/Address.ts +45 -0
- package/src/AddressAlias.ts +160 -0
- package/src/Bip32.ts +37 -0
- package/src/Chain.ts +21 -0
- package/src/CheckpointData.ts +106 -0
- package/src/Checkpoints.ts +18 -0
- package/src/CoinReservation.ts +65 -0
- package/src/Coins.ts +86 -0
- package/src/DynamicFields.ts +179 -0
- package/src/Ecdsa.ts +103 -0
- package/src/Ed25519.ts +84 -0
- package/src/Events.ts +133 -0
- package/src/Hash.ts +39 -0
- package/src/MlDsa65.ts +92 -0
- package/src/Mnemonic.ts +109 -0
- package/src/Move.ts +440 -0
- package/src/MultiSig.ts +320 -0
- package/src/Objects.ts +112 -0
- package/src/Packages.ts +52 -0
- package/src/Passkey.ts +10 -0
- package/src/PrivateKey.ts +138 -0
- package/src/Ptb.ts +579 -0
- package/src/Resolve.ts +1367 -0
- package/src/RpcError.ts +41 -0
- package/src/Secp256k1.ts +29 -0
- package/src/Secp256r1.ts +29 -0
- package/src/SignatureScheme.ts +166 -0
- package/src/Signer.ts +62 -0
- package/src/Testing.ts +830 -0
- package/src/TransactionData.ts +134 -0
- package/src/TransactionJson.ts +1002 -0
- package/src/Transactions.ts +211 -0
- package/src/Tx.ts +367 -0
- package/src/TypeTag.ts +123 -0
- package/src/Verify.ts +42 -0
- package/src/enoki/EnokiClient.ts +204 -0
- package/src/enoki/EnokiHttp.ts +222 -0
- package/src/enoki/Sponsor.ts +280 -0
- package/src/enoki/ZkLoginFlow.ts +176 -0
- package/src/enoki/index.ts +8 -0
- package/src/graphql/ChainGraphQL.ts +76 -0
- package/src/graphql/CheckpointDataGraphQL.ts +191 -0
- package/src/graphql/CheckpointsGraphQL.ts +96 -0
- package/src/graphql/CoinsGraphQL.ts +85 -0
- package/src/graphql/DynamicFieldsGraphQL.ts +167 -0
- package/src/graphql/EventsGraphQL.ts +301 -0
- package/src/graphql/ObjectsGraphQL.ts +112 -0
- package/src/graphql/PackagesGraphQL.ts +173 -0
- package/src/graphql/SuiGraphQL.ts +77 -0
- package/src/graphql/TransactionsGraphQL.ts +292 -0
- package/src/graphql/convert.ts +450 -0
- package/src/graphql/index.ts +74 -0
- package/src/graphql/merge.ts +62 -0
- package/src/graphql/paging.ts +110 -0
- package/src/graphql/subscription.ts +58 -0
- package/src/graphql/tip.ts +38 -0
- package/src/grpc/ChainGrpc.ts +51 -0
- package/src/grpc/CheckpointDataGrpc.ts +47 -0
- package/src/grpc/CheckpointsGrpc.ts +37 -0
- package/src/grpc/CoinsGrpc.ts +50 -0
- package/src/grpc/DynamicFieldsGrpc.ts +128 -0
- package/src/grpc/EventsGrpc.ts +101 -0
- package/src/grpc/GrpcWeb.ts +343 -0
- package/src/grpc/ObjectsGrpc.ts +95 -0
- package/src/grpc/PackagesGrpc.ts +98 -0
- package/src/grpc/Rpc.ts +156 -0
- package/src/grpc/TransactionsGrpc.ts +88 -0
- package/src/grpc/cache.ts +68 -0
- package/src/grpc/convert.ts +227 -0
- package/src/grpc/generated/lean.ts +276 -0
- package/src/grpc/generated/proto.ts +2130 -0
- package/src/grpc/generated/rpc.ts +417 -0
- package/src/grpc/index.ts +97 -0
- package/src/grpc/scan.ts +183 -0
- package/src/grpc/transaction.ts +182 -0
- package/src/index.ts +35 -0
- package/src/internal/allowances.ts +238 -0
- package/src/internal/mnemonic.ts +99 -0
- package/src/internal/passkey/BrowserProvider.ts +131 -0
- package/src/internal/passkey/Passkey.ts +408 -0
- package/src/internal/passkey/SoftwareProvider.ts +90 -0
- package/src/lifecycle/Evidence.ts +85 -0
- package/src/lifecycle/EvidenceGraphQL.ts +67 -0
- package/src/lifecycle/EvidenceGrpc.ts +47 -0
- package/src/lifecycle/Journal.ts +117 -0
- package/src/lifecycle/JournalEntry.ts +68 -0
- package/src/lifecycle/JournalKeyValueStore.ts +276 -0
- package/src/lifecycle/KeyValueStoreIndexedDb.ts +361 -0
- package/src/lifecycle/KeyValueStoreOpfs.ts +230 -0
- package/src/lifecycle/Lifecycle.ts +990 -0
- package/src/lifecycle/Outcome.ts +130 -0
- package/src/lifecycle/SenderLock.ts +73 -0
- package/src/lifecycle/SenderLockWebLocks.ts +136 -0
- package/src/lifecycle/SignedTransaction.ts +133 -0
- package/src/lifecycle/SubmitConfig.ts +77 -0
- package/src/lifecycle/index.ts +12 -0
- package/src/wallet/Features.ts +114 -0
- package/src/wallet/Wallet.ts +550 -0
- package/src/wallet/index.ts +5 -0
- package/src/zklogin/AddressSeed.ts +130 -0
- package/src/zklogin/Errors.ts +27 -0
- package/src/zklogin/Jwt.ts +186 -0
- package/src/zklogin/Nonce.ts +46 -0
- package/src/zklogin/Poseidon.ts +62 -0
- package/src/zklogin/PublicIdentifier.ts +111 -0
- package/src/zklogin/Signature.ts +88 -0
- package/src/zklogin/ZkLogin.ts +145 -0
- package/src/zklogin/ZkLoginAddress.ts +72 -0
- package/src/zklogin/ZkLoginVerifier.ts +37 -0
- package/src/zklogin/ZkLoginVerifierGrpc.ts +66 -0
- package/src/zklogin/index.ts +16 -0
- package/src/zklogin/internal/parse.ts +30 -0
- package/src/zklogin/internal/poseidon.ts +47 -0
|
@@ -0,0 +1,926 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interop with `@mysten/sui`'s transaction JSON: the v2 serialized
|
|
3
|
+
* `TransactionData` that `Transaction.toJSON()` writes and
|
|
4
|
+
* `Transaction.from(json)` reads (what wallets receive through
|
|
5
|
+
* `sui:signTransaction`).
|
|
6
|
+
*
|
|
7
|
+
* const json = yield* TransactionJson.encode(data) // resolved TransactionData
|
|
8
|
+
* const json = yield* TransactionJson.encode({ sender, draft }) // a Draft, intents included
|
|
9
|
+
* const tx = yield* TransactionJson.decode(json) // -> Unresolved (a Draft + gas fields)
|
|
10
|
+
* const data = yield* TransactionJson.resolve(tx) // the default Resolve pipeline
|
|
11
|
+
*
|
|
12
|
+
* Mapping:
|
|
13
|
+
* - `Ptb.BalanceIntent` <-> the `CoinWithBalance` `$Intent` (`tx.coin` / `tx.balance`):
|
|
14
|
+
* `type: "gas"` is SUI that may use the gas coin.
|
|
15
|
+
* - `Ptb.AllowanceIntent` <-> the `AllowanceBalance` `$Intent` (`tx.coin({ allowance })`),
|
|
16
|
+
* with its `allowance`, `clock` and optional `permit` inputs.
|
|
17
|
+
* - `Ptb.UnresolvedObject` <-> `UnresolvedObject`. Mysten treats `mutable` as
|
|
18
|
+
* "at least mutable"; so does the decoder (`mutable: true` forces it,
|
|
19
|
+
* anything else is inferred from usage).
|
|
20
|
+
* - `UnresolvedPure` decodes only where Mysten itself knows the type without a
|
|
21
|
+
* Move signature (`SplitCoins` amounts: u64, `TransferObjects` address).
|
|
22
|
+
*
|
|
23
|
+
* Anything else that can't be represented faithfully (another intent, an
|
|
24
|
+
* `UnresolvedPure` elsewhere, a pinned `UnresolvedObject` passed to a Move
|
|
25
|
+
* call, a command kind this module doesn't know) is `UnsupportedTransactionJson`,
|
|
26
|
+
* never a silent drop. JSON that doesn't match the schema is `InvalidTransactionJson`.
|
|
27
|
+
*/
|
|
28
|
+
import { base58, base64 } from "@scure/base";
|
|
29
|
+
import * as Effect from "effect/Effect";
|
|
30
|
+
import * as Option from "effect/Option";
|
|
31
|
+
import * as Result from "effect/Result";
|
|
32
|
+
import * as Schema from "effect/Schema";
|
|
33
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
34
|
+
import * as Bcs from "@unconfirmed/effect-bcs/Bcs";
|
|
35
|
+
import * as Address from "./Address.js";
|
|
36
|
+
import * as Hash from "./Hash.js";
|
|
37
|
+
import * as Allowances from "./internal/allowances.js";
|
|
38
|
+
import * as Resolve from "./Resolve.js";
|
|
39
|
+
import * as T from "./TransactionData.js";
|
|
40
|
+
import * as Tx from "./Tx.js";
|
|
41
|
+
import * as TypeTag from "./TypeTag.js";
|
|
42
|
+
// -----------------------------------------------------------------------------
|
|
43
|
+
// Errors
|
|
44
|
+
// -----------------------------------------------------------------------------
|
|
45
|
+
/** Not v2 transaction JSON: wrong shape, a bad u64, address, digest, type tag or base64. */
|
|
46
|
+
export class InvalidTransactionJson extends /* @__PURE__ */ Schema.TaggedError()("InvalidTransactionJson", {
|
|
47
|
+
issue: Schema.String
|
|
48
|
+
}) {
|
|
49
|
+
get message() {
|
|
50
|
+
return this.issue;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Well-formed, but uses something this SDK can't represent faithfully. */
|
|
54
|
+
export class UnsupportedTransactionJson extends /* @__PURE__ */ Schema.TaggedError()("UnsupportedTransactionJson", { construct: Schema.String, reason: Schema.String }) {
|
|
55
|
+
get message() {
|
|
56
|
+
return `unsupported ${this.construct}: ${this.reason}`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// -----------------------------------------------------------------------------
|
|
60
|
+
// The JSON shape (mirrors `SerializedTransactionDataV2Schema`)
|
|
61
|
+
// -----------------------------------------------------------------------------
|
|
62
|
+
const U64_MAX = (1n << 64n) - 1n;
|
|
63
|
+
/** A u64 as Mysten writes it: a decimal string or a safe integer. */
|
|
64
|
+
export const JsonU64 = /* @__PURE__ */ Schema.Union([
|
|
65
|
+
Schema.Int.check(Schema.makeFilter((n) => (n >= 0 && Number.isSafeInteger(n)) || "expected a non-negative safe integer")),
|
|
66
|
+
Schema.String.check(Schema.makeFilter((s) => (/^\d+$/.test(s) && BigInt(s) <= U64_MAX) || "expected a u64 decimal string"))
|
|
67
|
+
]);
|
|
68
|
+
/** Any hex address; normalized on decode, like Mysten's `SuiAddress`. */
|
|
69
|
+
export const JsonAddress = /* @__PURE__ */ Schema.String.check(Schema.isPattern(/^(0x)?[0-9a-fA-F]{1,64}$/));
|
|
70
|
+
const U32 = /* @__PURE__ */ Schema.Int.check(Schema.makeFilter((n) => (n >= 0 && n < 2 ** 32) || "expected a u32"));
|
|
71
|
+
const Index = /* @__PURE__ */ Schema.Int.check(Schema.makeFilter((n) => (n >= 0 && n < 65536) || "expected a u16 index"));
|
|
72
|
+
const Base64 = Schema.String;
|
|
73
|
+
/** `{ [key]: value, $kind?: key }`, Mysten's enum encoding. */
|
|
74
|
+
const variant = (key, value) => Schema.Struct({ [key]: value, $kind: Schema.optionalKey(Schema.Literal(key)) });
|
|
75
|
+
export const Argument = /* @__PURE__ */ Schema.Union([
|
|
76
|
+
variant("GasCoin", Schema.Literal(true)),
|
|
77
|
+
Schema.Struct({
|
|
78
|
+
Input: Index,
|
|
79
|
+
type: Schema.optionalKey(Schema.Literals(["pure", "object", "withdrawal"])),
|
|
80
|
+
$kind: Schema.optionalKey(Schema.Literal("Input"))
|
|
81
|
+
}),
|
|
82
|
+
variant("Result", Index),
|
|
83
|
+
variant("NestedResult", Schema.Tuple([Index, Index]))
|
|
84
|
+
]);
|
|
85
|
+
export const ObjectRef = /* @__PURE__ */ Schema.Struct({ objectId: JsonAddress, version: JsonU64, digest: Bcs.Digest });
|
|
86
|
+
export const ObjectArg = /* @__PURE__ */ Schema.Union([
|
|
87
|
+
variant("ImmOrOwnedObject", ObjectRef),
|
|
88
|
+
variant("SharedObject", Schema.Struct({
|
|
89
|
+
objectId: JsonAddress,
|
|
90
|
+
initialSharedVersion: JsonU64,
|
|
91
|
+
mutable: Schema.Boolean,
|
|
92
|
+
mutability: Schema.optionalKey(Schema.Literal("NonExclusiveWrite"))
|
|
93
|
+
})),
|
|
94
|
+
variant("Receiving", ObjectRef)
|
|
95
|
+
]);
|
|
96
|
+
export const FundsWithdrawal = /* @__PURE__ */ Schema.Struct({
|
|
97
|
+
reservation: variant("MaxAmountU64", JsonU64),
|
|
98
|
+
typeArg: variant("Balance", Schema.String),
|
|
99
|
+
withdrawFrom: Schema.Union([
|
|
100
|
+
variant("Sender", Schema.Literal(true)),
|
|
101
|
+
variant("Sponsor", Schema.Literal(true)),
|
|
102
|
+
variant("SenderAllowance", Schema.Struct({ funder: JsonAddress, allowance: JsonAddress }))
|
|
103
|
+
])
|
|
104
|
+
});
|
|
105
|
+
export const CallArg = /* @__PURE__ */ Schema.Union([
|
|
106
|
+
variant("Object", ObjectArg),
|
|
107
|
+
variant("Pure", Schema.Struct({ bytes: Base64 })),
|
|
108
|
+
variant("UnresolvedPure", Schema.Struct({ value: Schema.Unknown })),
|
|
109
|
+
variant("UnresolvedObject", Schema.Struct({
|
|
110
|
+
objectId: JsonAddress,
|
|
111
|
+
version: Schema.optionalKey(Schema.NullOr(JsonU64)),
|
|
112
|
+
digest: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
113
|
+
initialSharedVersion: Schema.optionalKey(Schema.NullOr(JsonU64)),
|
|
114
|
+
mutable: Schema.optionalKey(Schema.NullOr(Schema.Boolean))
|
|
115
|
+
})),
|
|
116
|
+
variant("FundsWithdrawal", FundsWithdrawal)
|
|
117
|
+
]);
|
|
118
|
+
export const Intent = /* @__PURE__ */ Schema.Struct({
|
|
119
|
+
name: Schema.String,
|
|
120
|
+
inputs: Schema.Record(Schema.String, Schema.Union([Argument, Schema.Array(Argument)])),
|
|
121
|
+
data: Schema.Record(Schema.String, Schema.Unknown)
|
|
122
|
+
});
|
|
123
|
+
export const Command = /* @__PURE__ */ Schema.Union([
|
|
124
|
+
variant("MoveCall", Schema.Struct({
|
|
125
|
+
package: JsonAddress,
|
|
126
|
+
module: Schema.String,
|
|
127
|
+
function: Schema.String,
|
|
128
|
+
typeArguments: Schema.Array(Schema.String),
|
|
129
|
+
arguments: Schema.Array(Argument)
|
|
130
|
+
})),
|
|
131
|
+
variant("TransferObjects", Schema.Struct({ objects: Schema.Array(Argument), address: Argument })),
|
|
132
|
+
variant("SplitCoins", Schema.Struct({ coin: Argument, amounts: Schema.Array(Argument) })),
|
|
133
|
+
variant("MergeCoins", Schema.Struct({ destination: Argument, sources: Schema.Array(Argument) })),
|
|
134
|
+
variant("Publish", Schema.Struct({ modules: Schema.Array(Base64), dependencies: Schema.Array(JsonAddress) })),
|
|
135
|
+
variant("MakeMoveVec", Schema.Struct({ type: Schema.NullOr(Schema.String), elements: Schema.Array(Argument) })),
|
|
136
|
+
variant("Upgrade", Schema.Struct({
|
|
137
|
+
modules: Schema.Array(Base64),
|
|
138
|
+
dependencies: Schema.Array(JsonAddress),
|
|
139
|
+
package: JsonAddress,
|
|
140
|
+
ticket: Argument
|
|
141
|
+
})),
|
|
142
|
+
variant("$Intent", Intent)
|
|
143
|
+
]);
|
|
144
|
+
const ValidDuringFields = {
|
|
145
|
+
minEpoch: Schema.NullOr(JsonU64),
|
|
146
|
+
maxEpoch: Schema.NullOr(JsonU64),
|
|
147
|
+
minTimestamp: Schema.NullOr(JsonU64),
|
|
148
|
+
maxTimestamp: Schema.NullOr(JsonU64),
|
|
149
|
+
chain: Bcs.Digest,
|
|
150
|
+
nonce: U32
|
|
151
|
+
};
|
|
152
|
+
export const Expiration = /* @__PURE__ */ Schema.Union([
|
|
153
|
+
variant("None", Schema.Literal(true)),
|
|
154
|
+
variant("Epoch", JsonU64),
|
|
155
|
+
variant("ValidDuring", Schema.Struct(ValidDuringFields)),
|
|
156
|
+
variant("Validity", Schema.Struct({
|
|
157
|
+
...ValidDuringFields,
|
|
158
|
+
allowedProposers: Schema.NullOr(Schema.Struct({ epoch: JsonU64, proposers: Schema.Array(U32) }))
|
|
159
|
+
}))
|
|
160
|
+
]);
|
|
161
|
+
export const GasData = /* @__PURE__ */ Schema.Struct({
|
|
162
|
+
budget: Schema.NullOr(JsonU64),
|
|
163
|
+
price: Schema.NullOr(JsonU64),
|
|
164
|
+
owner: Schema.NullOr(JsonAddress),
|
|
165
|
+
payment: Schema.NullOr(Schema.Array(ObjectRef))
|
|
166
|
+
});
|
|
167
|
+
/** `SerializedTransactionDataV2`: what `Transaction.toJSON()` produces. */
|
|
168
|
+
export const TransactionJson = /* @__PURE__ */ Schema.Struct({
|
|
169
|
+
version: Schema.Literal(2),
|
|
170
|
+
sender: Schema.optionalKey(Schema.NullOr(JsonAddress)),
|
|
171
|
+
expiration: Schema.optionalKey(Schema.NullOr(Expiration)),
|
|
172
|
+
gasData: GasData,
|
|
173
|
+
inputs: Schema.Array(CallArg),
|
|
174
|
+
commands: Schema.Array(Command),
|
|
175
|
+
digest: Schema.optionalKey(Schema.NullOr(Schema.String))
|
|
176
|
+
});
|
|
177
|
+
/** The same, as a JSON string. */
|
|
178
|
+
export const TransactionJsonString = /* @__PURE__ */ Schema.fromJsonString(TransactionJson);
|
|
179
|
+
/** `CoinWithBalance` intent data. */
|
|
180
|
+
const CoinWithBalanceData = /* @__PURE__ */ Schema.Struct({
|
|
181
|
+
type: Schema.String,
|
|
182
|
+
balance: JsonU64,
|
|
183
|
+
outputKind: Schema.optionalKey(Schema.Literals(["coin", "balance"]))
|
|
184
|
+
});
|
|
185
|
+
export const COIN_WITH_BALANCE = "CoinWithBalance";
|
|
186
|
+
/** `AllowanceBalance` intent data. */
|
|
187
|
+
const AllowanceBalanceData = /* @__PURE__ */ Schema.Struct({
|
|
188
|
+
objectId: Schema.String,
|
|
189
|
+
funder: Schema.optionalKey(Schema.String),
|
|
190
|
+
appType: Schema.optionalKey(Schema.String),
|
|
191
|
+
type: Schema.String,
|
|
192
|
+
amount: JsonU64,
|
|
193
|
+
outputKind: Schema.Literals(["coin", "balance"])
|
|
194
|
+
});
|
|
195
|
+
export const ALLOWANCE_BALANCE = "AllowanceBalance";
|
|
196
|
+
// -----------------------------------------------------------------------------
|
|
197
|
+
// Encoding (ours -> JSON)
|
|
198
|
+
// -----------------------------------------------------------------------------
|
|
199
|
+
const u64 = (v) => v.toString();
|
|
200
|
+
const b64 = (bytes) => base64.encode(bytes);
|
|
201
|
+
const argumentJson = (a) => {
|
|
202
|
+
switch (a._tag) {
|
|
203
|
+
case "GasCoin":
|
|
204
|
+
return { GasCoin: true, $kind: "GasCoin" };
|
|
205
|
+
case "Input":
|
|
206
|
+
return { Input: a.value, $kind: "Input" };
|
|
207
|
+
case "Result":
|
|
208
|
+
return { Result: a.value, $kind: "Result" };
|
|
209
|
+
case "NestedResult":
|
|
210
|
+
return { NestedResult: [a.value[0], a.value[1]], $kind: "NestedResult" };
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
const refJson = (r) => ({ objectId: r.objectId, version: u64(r.version), digest: r.digest });
|
|
214
|
+
const objectArgJson = (o) => {
|
|
215
|
+
switch (o._tag) {
|
|
216
|
+
case "ImmOrOwnedObject":
|
|
217
|
+
return { ImmOrOwnedObject: refJson(o), $kind: "ImmOrOwnedObject" };
|
|
218
|
+
case "Receiving":
|
|
219
|
+
return { Receiving: refJson(o), $kind: "Receiving" };
|
|
220
|
+
case "SharedObject":
|
|
221
|
+
return {
|
|
222
|
+
SharedObject: {
|
|
223
|
+
objectId: o.objectId,
|
|
224
|
+
initialSharedVersion: u64(o.initialSharedVersion),
|
|
225
|
+
mutable: o.mutability._tag === "Mutable",
|
|
226
|
+
...(o.mutability._tag === "NonExclusiveWrite" && { mutability: "NonExclusiveWrite" })
|
|
227
|
+
},
|
|
228
|
+
$kind: "SharedObject"
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
const withdrawalJson = (w) => ({
|
|
233
|
+
reservation: { MaxAmountU64: u64(w.reservation.value), $kind: "MaxAmountU64" },
|
|
234
|
+
typeArg: { Balance: TypeTag.format(w.typeArg.value), $kind: "Balance" },
|
|
235
|
+
withdrawFrom: w.withdrawFrom._tag === "SenderAllowance"
|
|
236
|
+
? {
|
|
237
|
+
SenderAllowance: { funder: w.withdrawFrom.funder, allowance: w.withdrawFrom.allowance },
|
|
238
|
+
$kind: "SenderAllowance"
|
|
239
|
+
}
|
|
240
|
+
: w.withdrawFrom._tag === "Sponsor"
|
|
241
|
+
? { Sponsor: true, $kind: "Sponsor" }
|
|
242
|
+
: { Sender: true, $kind: "Sender" }
|
|
243
|
+
});
|
|
244
|
+
const inputJson = (i) => {
|
|
245
|
+
switch (i._tag) {
|
|
246
|
+
case "Pure":
|
|
247
|
+
return { Pure: { bytes: b64(i.bytes) }, $kind: "Pure" };
|
|
248
|
+
case "Object":
|
|
249
|
+
return { Object: objectArgJson(i.value), $kind: "Object" };
|
|
250
|
+
case "FundsWithdrawal":
|
|
251
|
+
return { FundsWithdrawal: withdrawalJson(i), $kind: "FundsWithdrawal" };
|
|
252
|
+
case "UnresolvedObject":
|
|
253
|
+
return {
|
|
254
|
+
UnresolvedObject: { objectId: i.objectId, ...(i.mutable !== undefined && { mutable: i.mutable }) },
|
|
255
|
+
$kind: "UnresolvedObject"
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
const commandJson = (c) => {
|
|
260
|
+
const args = (as) => as.map(argumentJson);
|
|
261
|
+
switch (c._tag) {
|
|
262
|
+
case "MoveCall":
|
|
263
|
+
return Result.succeed({
|
|
264
|
+
MoveCall: {
|
|
265
|
+
package: c.package,
|
|
266
|
+
module: c.module,
|
|
267
|
+
function: c.function,
|
|
268
|
+
typeArguments: c.typeArguments.map(TypeTag.format),
|
|
269
|
+
arguments: args(c.arguments)
|
|
270
|
+
},
|
|
271
|
+
$kind: "MoveCall"
|
|
272
|
+
});
|
|
273
|
+
case "TransferObjects":
|
|
274
|
+
return Result.succeed({
|
|
275
|
+
TransferObjects: { objects: args(c.objects), address: argumentJson(c.address) },
|
|
276
|
+
$kind: "TransferObjects"
|
|
277
|
+
});
|
|
278
|
+
case "SplitCoins":
|
|
279
|
+
return Result.succeed({ SplitCoins: { coin: argumentJson(c.coin), amounts: args(c.amounts) }, $kind: "SplitCoins" });
|
|
280
|
+
case "MergeCoins":
|
|
281
|
+
return Result.succeed({
|
|
282
|
+
MergeCoins: { destination: argumentJson(c.destination), sources: args(c.sources) },
|
|
283
|
+
$kind: "MergeCoins"
|
|
284
|
+
});
|
|
285
|
+
case "Publish":
|
|
286
|
+
return Result.succeed({ Publish: { modules: c.modules.map(b64), dependencies: [...c.dependencies] }, $kind: "Publish" });
|
|
287
|
+
case "MakeMoveVec":
|
|
288
|
+
return Result.succeed({
|
|
289
|
+
MakeMoveVec: { type: Option.match(c.type, { onNone: () => null, onSome: TypeTag.format }), elements: args(c.elements) },
|
|
290
|
+
$kind: "MakeMoveVec"
|
|
291
|
+
});
|
|
292
|
+
case "Upgrade":
|
|
293
|
+
return Result.succeed({
|
|
294
|
+
Upgrade: {
|
|
295
|
+
modules: c.modules.map(b64),
|
|
296
|
+
dependencies: [...c.dependencies],
|
|
297
|
+
package: c.package,
|
|
298
|
+
ticket: argumentJson(c.ticket)
|
|
299
|
+
},
|
|
300
|
+
$kind: "Upgrade"
|
|
301
|
+
});
|
|
302
|
+
case "BalanceIntent":
|
|
303
|
+
return Result.succeed({
|
|
304
|
+
$Intent: {
|
|
305
|
+
name: COIN_WITH_BALANCE,
|
|
306
|
+
inputs: {},
|
|
307
|
+
data: {
|
|
308
|
+
type: c.coinType === TypeTag.SUI && c.useGasCoin ? "gas" : c.coinType,
|
|
309
|
+
balance: u64(c.amount),
|
|
310
|
+
outputKind: c.output
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
$kind: "$Intent"
|
|
314
|
+
});
|
|
315
|
+
case "AllowanceIntent":
|
|
316
|
+
return Result.succeed({
|
|
317
|
+
$Intent: {
|
|
318
|
+
name: ALLOWANCE_BALANCE,
|
|
319
|
+
inputs: {
|
|
320
|
+
allowance: argumentJson(c.allowance),
|
|
321
|
+
clock: argumentJson(c.clock),
|
|
322
|
+
...(c.permit !== undefined && { permit: argumentJson(c.permit) })
|
|
323
|
+
},
|
|
324
|
+
data: {
|
|
325
|
+
objectId: c.allowanceId,
|
|
326
|
+
...(c.funder !== undefined && { funder: c.funder }),
|
|
327
|
+
...(c.appType !== undefined && { appType: c.appType }),
|
|
328
|
+
type: c.coinType,
|
|
329
|
+
amount: u64(c.amount),
|
|
330
|
+
outputKind: c.output
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
$kind: "$Intent"
|
|
334
|
+
});
|
|
335
|
+
default:
|
|
336
|
+
return Result.fail(new UnsupportedTransactionJson({
|
|
337
|
+
construct: `command ${c._tag}`,
|
|
338
|
+
reason: "no transaction JSON mapping for this command"
|
|
339
|
+
}));
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
const optionU64 = (o) => Option.match(o, { onNone: () => null, onSome: u64 });
|
|
343
|
+
const expirationJson = (e) => {
|
|
344
|
+
switch (e._tag) {
|
|
345
|
+
case "None":
|
|
346
|
+
return { None: true, $kind: "None" };
|
|
347
|
+
case "Epoch":
|
|
348
|
+
return { Epoch: u64(e.value), $kind: "Epoch" };
|
|
349
|
+
case "ValidDuring":
|
|
350
|
+
case "Validity": {
|
|
351
|
+
const fields = {
|
|
352
|
+
minEpoch: optionU64(e.minEpoch),
|
|
353
|
+
maxEpoch: optionU64(e.maxEpoch),
|
|
354
|
+
minTimestamp: optionU64(e.minTimestamp),
|
|
355
|
+
maxTimestamp: optionU64(e.maxTimestamp),
|
|
356
|
+
chain: e.chain,
|
|
357
|
+
nonce: e.nonce
|
|
358
|
+
};
|
|
359
|
+
return e._tag === "ValidDuring"
|
|
360
|
+
? { ValidDuring: fields, $kind: "ValidDuring" }
|
|
361
|
+
: {
|
|
362
|
+
Validity: {
|
|
363
|
+
...fields,
|
|
364
|
+
allowedProposers: Option.match(e.allowedProposers, {
|
|
365
|
+
onNone: () => null,
|
|
366
|
+
onSome: (p) => ({ epoch: u64(p.epoch), proposers: [...p.proposers] })
|
|
367
|
+
})
|
|
368
|
+
},
|
|
369
|
+
$kind: "Validity"
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
/** Resolved `TransactionData` as transaction JSON (with its digest, as Mysten writes fully resolved transactions). */
|
|
375
|
+
export const fromTransactionData = (data) => ({
|
|
376
|
+
version: 2,
|
|
377
|
+
sender: data.sender,
|
|
378
|
+
expiration: expirationJson(data.expiration),
|
|
379
|
+
gasData: {
|
|
380
|
+
budget: u64(data.gasData.budget),
|
|
381
|
+
price: u64(data.gasData.price),
|
|
382
|
+
owner: data.gasData.owner,
|
|
383
|
+
payment: data.gasData.payment.map(refJson)
|
|
384
|
+
},
|
|
385
|
+
inputs: data.kind.inputs.map(inputJson),
|
|
386
|
+
// The resolved command set has no intents, so this can't fail.
|
|
387
|
+
commands: data.kind.commands.map((c) => Result.getOrThrow(commandJson(c))),
|
|
388
|
+
digest: Hash.transactionDigest(T.encode(data))
|
|
389
|
+
});
|
|
390
|
+
/** An unresolved transaction (a `Draft`, intents included) as transaction JSON. */
|
|
391
|
+
export const fromUnresolved = (tx) => Effect.suspend(() => {
|
|
392
|
+
const commands = [];
|
|
393
|
+
for (const c of tx.draft.commands) {
|
|
394
|
+
const r = commandJson(c);
|
|
395
|
+
if (Result.isFailure(r))
|
|
396
|
+
return Effect.fail(r.failure);
|
|
397
|
+
commands.push(r.success);
|
|
398
|
+
}
|
|
399
|
+
return Effect.succeed({
|
|
400
|
+
version: 2,
|
|
401
|
+
sender: tx.sender ?? null,
|
|
402
|
+
expiration: tx.expiration ? expirationJson(tx.expiration) : null,
|
|
403
|
+
gasData: {
|
|
404
|
+
budget: tx.gasBudget === undefined ? null : u64(tx.gasBudget),
|
|
405
|
+
price: tx.gasPrice === undefined ? null : u64(tx.gasPrice),
|
|
406
|
+
owner: tx.gasOwner ?? null,
|
|
407
|
+
payment: tx.gasPayment ? tx.gasPayment.map(refJson) : null
|
|
408
|
+
},
|
|
409
|
+
inputs: tx.draft.inputs.map(inputJson),
|
|
410
|
+
commands
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
const isTransactionData = (tx) => tx._tag === "V1";
|
|
414
|
+
/** Either form as transaction JSON. */
|
|
415
|
+
export const toJson = (tx) => isTransactionData(tx) ? Effect.succeed(fromTransactionData(tx)) : fromUnresolved(tx);
|
|
416
|
+
/** Either form as a JSON string that `Transaction.from` accepts. */
|
|
417
|
+
export const encode = (tx) => Effect.map(toJson(tx), (json) => JSON.stringify(json, null, 2));
|
|
418
|
+
// -----------------------------------------------------------------------------
|
|
419
|
+
// Decoding (JSON -> ours)
|
|
420
|
+
// -----------------------------------------------------------------------------
|
|
421
|
+
const KNOWN_INPUTS = new Set(["Object", "Pure", "UnresolvedPure", "UnresolvedObject", "FundsWithdrawal"]);
|
|
422
|
+
const KNOWN_COMMANDS = new Set([
|
|
423
|
+
"MoveCall",
|
|
424
|
+
"TransferObjects",
|
|
425
|
+
"SplitCoins",
|
|
426
|
+
"MergeCoins",
|
|
427
|
+
"Publish",
|
|
428
|
+
"MakeMoveVec",
|
|
429
|
+
"Upgrade",
|
|
430
|
+
"$Intent"
|
|
431
|
+
]);
|
|
432
|
+
/**
|
|
433
|
+
* Every enum variant key in the v2 schema, derived from the schema itself (a
|
|
434
|
+
* variant is a struct with an optional `$kind`), so a new variant can't be
|
|
435
|
+
* missed by the ambiguity guard. Computed on first use.
|
|
436
|
+
*/
|
|
437
|
+
let variantKeys;
|
|
438
|
+
const VARIANT_KEYS = () => {
|
|
439
|
+
if (variantKeys)
|
|
440
|
+
return variantKeys;
|
|
441
|
+
const keys = new Set();
|
|
442
|
+
const seen = new Set();
|
|
443
|
+
const visit = (n) => {
|
|
444
|
+
if (seen.has(n))
|
|
445
|
+
return;
|
|
446
|
+
seen.add(n);
|
|
447
|
+
if (SchemaAST.isObjects(n)) {
|
|
448
|
+
const names = n.propertySignatures.map((p) => String(p.name));
|
|
449
|
+
if (names.includes("$kind"))
|
|
450
|
+
names.filter((k) => k !== "$kind" && /^[$A-Z]/.test(k)).forEach((k) => keys.add(k));
|
|
451
|
+
n.propertySignatures.forEach((p) => visit(p.type));
|
|
452
|
+
n.indexSignatures.forEach((i) => visit(i.type));
|
|
453
|
+
}
|
|
454
|
+
else if (SchemaAST.isUnion(n))
|
|
455
|
+
n.types.forEach(visit);
|
|
456
|
+
else if (SchemaAST.isArrays(n)) {
|
|
457
|
+
n.elements.forEach(visit);
|
|
458
|
+
n.rest.forEach(visit);
|
|
459
|
+
}
|
|
460
|
+
else if (SchemaAST.isSuspend(n))
|
|
461
|
+
visit(n.thunk());
|
|
462
|
+
n.encoding?.forEach((link) => visit(link.to));
|
|
463
|
+
};
|
|
464
|
+
visit(TransactionJson.ast);
|
|
465
|
+
return variantKeys = keys;
|
|
466
|
+
};
|
|
467
|
+
/**
|
|
468
|
+
* An object carrying two enum variants (`{ "Pure": …, "Object": … }`) reads as
|
|
469
|
+
* different transactions depending on the parser (Mysten takes `$kind` or the
|
|
470
|
+
* first key; a schema union takes its first matching member), so it is refused.
|
|
471
|
+
*/
|
|
472
|
+
const ambiguousVariant = (v, path) => {
|
|
473
|
+
if (typeof v !== "object" || v === null)
|
|
474
|
+
return undefined;
|
|
475
|
+
if (Array.isArray(v)) {
|
|
476
|
+
for (const [i, x] of v.entries()) {
|
|
477
|
+
const e = ambiguousVariant(x, `${path}[${i}]`);
|
|
478
|
+
if (e)
|
|
479
|
+
return e;
|
|
480
|
+
}
|
|
481
|
+
return undefined;
|
|
482
|
+
}
|
|
483
|
+
const variants = Object.keys(v).filter((k) => VARIANT_KEYS().has(k));
|
|
484
|
+
if (variants.length > 1) {
|
|
485
|
+
return new InvalidTransactionJson({ issue: `${path || "transaction"} has more than one enum variant: ${variants.join(", ")}` });
|
|
486
|
+
}
|
|
487
|
+
for (const [k, x] of Object.entries(v)) {
|
|
488
|
+
const e = ambiguousVariant(x, path ? `${path}.${k}` : k);
|
|
489
|
+
if (e)
|
|
490
|
+
return e;
|
|
491
|
+
}
|
|
492
|
+
return undefined;
|
|
493
|
+
};
|
|
494
|
+
const kindOf = (v) => {
|
|
495
|
+
if (typeof v !== "object" || v === null)
|
|
496
|
+
return undefined;
|
|
497
|
+
const k = v.$kind;
|
|
498
|
+
return typeof k === "string" ? k : Object.keys(v).find((key) => key !== "$kind");
|
|
499
|
+
};
|
|
500
|
+
/** Name an enum variant this module doesn't know, so it's reported as unsupported rather than malformed. */
|
|
501
|
+
const unknownVariant = (input) => {
|
|
502
|
+
if (typeof input !== "object" || input === null)
|
|
503
|
+
return undefined;
|
|
504
|
+
const { inputs, commands } = input;
|
|
505
|
+
if (Array.isArray(inputs)) {
|
|
506
|
+
for (const i of inputs) {
|
|
507
|
+
const k = kindOf(i);
|
|
508
|
+
if (k !== undefined && !KNOWN_INPUTS.has(k)) {
|
|
509
|
+
return new UnsupportedTransactionJson({ construct: `input ${k}`, reason: "unknown input kind" });
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
if (Array.isArray(commands)) {
|
|
514
|
+
for (const c of commands) {
|
|
515
|
+
const k = kindOf(c);
|
|
516
|
+
if (k !== undefined && !KNOWN_COMMANDS.has(k)) {
|
|
517
|
+
return new UnsupportedTransactionJson({ construct: `command ${k}`, reason: "unknown command kind" });
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return undefined;
|
|
522
|
+
};
|
|
523
|
+
const decodeJsonObject = /* @__PURE__ */ Schema.decodeUnknownResult(TransactionJson);
|
|
524
|
+
const decodeCoinWithBalance = /* @__PURE__ */ Schema.decodeUnknownResult(CoinWithBalanceData);
|
|
525
|
+
const decodeAllowanceBalance = /* @__PURE__ */ Schema.decodeUnknownResult(AllowanceBalanceData);
|
|
526
|
+
/** Validate a parsed JSON value (or a JSON string) against the v2 schema. */
|
|
527
|
+
export const parse = (input) => Effect.suspend(() => {
|
|
528
|
+
let value = input;
|
|
529
|
+
if (typeof input === "string") {
|
|
530
|
+
try {
|
|
531
|
+
value = JSON.parse(input);
|
|
532
|
+
}
|
|
533
|
+
catch (e) {
|
|
534
|
+
return Effect.fail(new InvalidTransactionJson({ issue: `not JSON: ${e.message}` }));
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
const ambiguous = ambiguousVariant(value, "");
|
|
538
|
+
if (ambiguous)
|
|
539
|
+
return Effect.fail(ambiguous);
|
|
540
|
+
const r = decodeJsonObject(value);
|
|
541
|
+
if (Result.isSuccess(r))
|
|
542
|
+
return Effect.succeed(r.success);
|
|
543
|
+
return Effect.fail(unknownVariant(value) ?? new InvalidTransactionJson({ issue: r.failure.message }));
|
|
544
|
+
});
|
|
545
|
+
class Fail {
|
|
546
|
+
error;
|
|
547
|
+
constructor(error) {
|
|
548
|
+
this.error = error;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
const invalid = (issue) => {
|
|
552
|
+
throw new Fail(new InvalidTransactionJson({ issue }));
|
|
553
|
+
};
|
|
554
|
+
const unsupported = (construct, reason) => {
|
|
555
|
+
throw new Fail(new UnsupportedTransactionJson({ construct, reason }));
|
|
556
|
+
};
|
|
557
|
+
const toU64 = (v) => BigInt(v);
|
|
558
|
+
const toAddress = (s) => {
|
|
559
|
+
try {
|
|
560
|
+
return Address.normalize(s);
|
|
561
|
+
}
|
|
562
|
+
catch {
|
|
563
|
+
return invalid(`${JSON.stringify(s)} is not an address`);
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
const toTypeTag = (s) => {
|
|
567
|
+
try {
|
|
568
|
+
return TypeTag.parse(s);
|
|
569
|
+
}
|
|
570
|
+
catch (e) {
|
|
571
|
+
return s.includes("@") || s.includes("/")
|
|
572
|
+
? unsupported(`type ${s}`, "named (MVR) types must be resolved before they reach this SDK")
|
|
573
|
+
: invalid(e.message);
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
const toBytes = (s) => {
|
|
577
|
+
try {
|
|
578
|
+
return base64.decode(s);
|
|
579
|
+
}
|
|
580
|
+
catch {
|
|
581
|
+
return invalid(`invalid base64: ${s.slice(0, 32)}`);
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
const toDigest = (s) => {
|
|
585
|
+
try {
|
|
586
|
+
if (base58.decode(s).length === 32)
|
|
587
|
+
return s;
|
|
588
|
+
}
|
|
589
|
+
catch {
|
|
590
|
+
// fall through
|
|
591
|
+
}
|
|
592
|
+
return invalid(`invalid object digest: ${s}`);
|
|
593
|
+
};
|
|
594
|
+
const toRef = (r) => ({
|
|
595
|
+
objectId: toAddress(r.objectId),
|
|
596
|
+
version: toU64(r.version),
|
|
597
|
+
digest: r.digest
|
|
598
|
+
});
|
|
599
|
+
const toOptionU64 = (v) => (v === null ? Option.none() : Option.some(toU64(v)));
|
|
600
|
+
const toObjectArg = (o) => {
|
|
601
|
+
if ("ImmOrOwnedObject" in o)
|
|
602
|
+
return { _tag: "ImmOrOwnedObject", ...toRef(o.ImmOrOwnedObject) };
|
|
603
|
+
if ("Receiving" in o)
|
|
604
|
+
return { _tag: "Receiving", ...toRef(o.Receiving) };
|
|
605
|
+
const s = o.SharedObject;
|
|
606
|
+
return {
|
|
607
|
+
_tag: "SharedObject",
|
|
608
|
+
objectId: toAddress(s.objectId),
|
|
609
|
+
initialSharedVersion: toU64(s.initialSharedVersion),
|
|
610
|
+
mutability: { _tag: s.mutability === "NonExclusiveWrite" ? "NonExclusiveWrite" : s.mutable ? "Mutable" : "Immutable" }
|
|
611
|
+
};
|
|
612
|
+
};
|
|
613
|
+
const toWithdrawal = (w) => {
|
|
614
|
+
const from = w.withdrawFrom;
|
|
615
|
+
return {
|
|
616
|
+
_tag: "FundsWithdrawal",
|
|
617
|
+
reservation: { _tag: "MaxAmountU64", value: toU64(w.reservation.MaxAmountU64) },
|
|
618
|
+
typeArg: { _tag: "Balance", value: toTypeTag(w.typeArg.Balance) },
|
|
619
|
+
withdrawFrom: "SenderAllowance" in from
|
|
620
|
+
? {
|
|
621
|
+
_tag: "SenderAllowance",
|
|
622
|
+
funder: toAddress(from.SenderAllowance.funder),
|
|
623
|
+
allowance: toAddress(from.SenderAllowance.allowance)
|
|
624
|
+
}
|
|
625
|
+
: "Sponsor" in from
|
|
626
|
+
? { _tag: "Sponsor" }
|
|
627
|
+
: { _tag: "Sender" }
|
|
628
|
+
};
|
|
629
|
+
};
|
|
630
|
+
const toExpiration = (e) => {
|
|
631
|
+
if ("None" in e)
|
|
632
|
+
return { _tag: "None" };
|
|
633
|
+
if ("Epoch" in e)
|
|
634
|
+
return { _tag: "Epoch", value: toU64(e.Epoch) };
|
|
635
|
+
const v = "ValidDuring" in e ? e.ValidDuring : e.Validity;
|
|
636
|
+
const fields = {
|
|
637
|
+
minEpoch: toOptionU64(v.minEpoch),
|
|
638
|
+
maxEpoch: toOptionU64(v.maxEpoch),
|
|
639
|
+
minTimestamp: toOptionU64(v.minTimestamp),
|
|
640
|
+
maxTimestamp: toOptionU64(v.maxTimestamp),
|
|
641
|
+
chain: toDigest(v.chain),
|
|
642
|
+
nonce: v.nonce
|
|
643
|
+
};
|
|
644
|
+
if ("ValidDuring" in e)
|
|
645
|
+
return { _tag: "ValidDuring", ...fields };
|
|
646
|
+
const p = e.Validity.allowedProposers;
|
|
647
|
+
if (p !== null && p.proposers.length === 0)
|
|
648
|
+
invalid("allowedProposers must not be empty");
|
|
649
|
+
return {
|
|
650
|
+
_tag: "Validity",
|
|
651
|
+
...fields,
|
|
652
|
+
allowedProposers: p === null ? Option.none() : Option.some({ epoch: toU64(p.epoch), proposers: [...p.proposers] })
|
|
653
|
+
};
|
|
654
|
+
};
|
|
655
|
+
const encodeU64 = /* @__PURE__ */ Bcs.encodeSync(Bcs.u64);
|
|
656
|
+
const encodeAddress = /* @__PURE__ */ Bcs.encodeSync(Bcs.Address);
|
|
657
|
+
const toUnresolvedSync = (json) => {
|
|
658
|
+
const nInputs = json.inputs.length;
|
|
659
|
+
// Where each input is used, to type `UnresolvedPure` values and to tell
|
|
660
|
+
// whether a pinned `UnresolvedObject` could be a `Receiving`.
|
|
661
|
+
const pureUses = new Map();
|
|
662
|
+
const inMoveCall = new Set();
|
|
663
|
+
const use = (a, kind) => {
|
|
664
|
+
if (!("Input" in a))
|
|
665
|
+
return;
|
|
666
|
+
const s = pureUses.get(a.Input) ?? new Set();
|
|
667
|
+
s.add(kind);
|
|
668
|
+
pureUses.set(a.Input, s);
|
|
669
|
+
};
|
|
670
|
+
const toArgument = (a, at) => {
|
|
671
|
+
if ("GasCoin" in a)
|
|
672
|
+
return { _tag: "GasCoin" };
|
|
673
|
+
if ("Input" in a) {
|
|
674
|
+
if (a.Input >= nInputs)
|
|
675
|
+
invalid(`command ${at} refers to input ${a.Input}; there are ${nInputs}`);
|
|
676
|
+
return { _tag: "Input", value: a.Input };
|
|
677
|
+
}
|
|
678
|
+
if ("Result" in a) {
|
|
679
|
+
if (a.Result >= at)
|
|
680
|
+
invalid(`command ${at} refers to the result of command ${a.Result}`);
|
|
681
|
+
return { _tag: "Result", value: a.Result };
|
|
682
|
+
}
|
|
683
|
+
if (a.NestedResult[0] >= at)
|
|
684
|
+
invalid(`command ${at} refers to the result of command ${a.NestedResult[0]}`);
|
|
685
|
+
// An intent yields one value: only its first nested result exists.
|
|
686
|
+
if (a.NestedResult[1] > 0 && "$Intent" in json.commands[a.NestedResult[0]]) {
|
|
687
|
+
invalid(`command ${at} refers to result ${a.NestedResult[1]} of intent command ${a.NestedResult[0]}, which has one`);
|
|
688
|
+
}
|
|
689
|
+
return { _tag: "NestedResult", value: [a.NestedResult[0], a.NestedResult[1]] };
|
|
690
|
+
};
|
|
691
|
+
const commands = json.commands.map((c, at) => {
|
|
692
|
+
const args = (as, kind = "other") => as.map((a) => {
|
|
693
|
+
use(a, kind);
|
|
694
|
+
return toArgument(a, at);
|
|
695
|
+
});
|
|
696
|
+
const arg = (a, kind = "other") => args([a], kind)[0];
|
|
697
|
+
if ("MoveCall" in c) {
|
|
698
|
+
const m = c.MoveCall;
|
|
699
|
+
for (const a of m.arguments)
|
|
700
|
+
if ("Input" in a)
|
|
701
|
+
inMoveCall.add(a.Input);
|
|
702
|
+
return {
|
|
703
|
+
_tag: "MoveCall",
|
|
704
|
+
package: toAddress(m.package),
|
|
705
|
+
module: m.module,
|
|
706
|
+
function: m.function,
|
|
707
|
+
typeArguments: m.typeArguments.map(toTypeTag),
|
|
708
|
+
arguments: args(m.arguments)
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
if ("TransferObjects" in c) {
|
|
712
|
+
return {
|
|
713
|
+
_tag: "TransferObjects",
|
|
714
|
+
objects: args(c.TransferObjects.objects),
|
|
715
|
+
address: arg(c.TransferObjects.address, "address")
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
if ("SplitCoins" in c) {
|
|
719
|
+
return { _tag: "SplitCoins", coin: arg(c.SplitCoins.coin), amounts: args(c.SplitCoins.amounts, "u64") };
|
|
720
|
+
}
|
|
721
|
+
if ("MergeCoins" in c) {
|
|
722
|
+
return { _tag: "MergeCoins", destination: arg(c.MergeCoins.destination), sources: args(c.MergeCoins.sources) };
|
|
723
|
+
}
|
|
724
|
+
if ("Publish" in c) {
|
|
725
|
+
return {
|
|
726
|
+
_tag: "Publish",
|
|
727
|
+
modules: c.Publish.modules.map(toBytes),
|
|
728
|
+
dependencies: c.Publish.dependencies.map(toAddress)
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
if ("MakeMoveVec" in c) {
|
|
732
|
+
return {
|
|
733
|
+
_tag: "MakeMoveVec",
|
|
734
|
+
type: c.MakeMoveVec.type === null ? Option.none() : Option.some(toTypeTag(c.MakeMoveVec.type)),
|
|
735
|
+
elements: args(c.MakeMoveVec.elements)
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
if ("Upgrade" in c) {
|
|
739
|
+
const u = c.Upgrade;
|
|
740
|
+
return {
|
|
741
|
+
_tag: "Upgrade",
|
|
742
|
+
modules: u.modules.map(toBytes),
|
|
743
|
+
dependencies: u.dependencies.map(toAddress),
|
|
744
|
+
package: toAddress(u.package),
|
|
745
|
+
ticket: arg(u.ticket)
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
const intent = c.$Intent;
|
|
749
|
+
if (intent.name === ALLOWANCE_BALANCE) {
|
|
750
|
+
const input = (name) => {
|
|
751
|
+
const a = intent.inputs[name];
|
|
752
|
+
if (a === undefined)
|
|
753
|
+
return undefined;
|
|
754
|
+
if (Array.isArray(a))
|
|
755
|
+
return invalid(`AllowanceBalance input ${name} must be a single argument`);
|
|
756
|
+
return arg(a);
|
|
757
|
+
};
|
|
758
|
+
const extra = Object.keys(intent.inputs).filter((k) => k !== "allowance" && k !== "clock" && k !== "permit");
|
|
759
|
+
if (extra.length > 0)
|
|
760
|
+
invalid(`unexpected AllowanceBalance inputs: ${extra.join(", ")}`);
|
|
761
|
+
const allowance = input("allowance") ?? invalid("an AllowanceBalance intent needs an allowance input");
|
|
762
|
+
const clock = input("clock") ?? invalid("an AllowanceBalance intent needs a clock input");
|
|
763
|
+
const permit = input("permit");
|
|
764
|
+
const d = decodeAllowanceBalance(intent.data);
|
|
765
|
+
if (Result.isFailure(d))
|
|
766
|
+
return invalid(`AllowanceBalance data: ${d.failure.message}`);
|
|
767
|
+
const { objectId, funder, appType, type, amount, outputKind } = d.success;
|
|
768
|
+
if ((appType === undefined) !== (permit === undefined)) {
|
|
769
|
+
invalid("an AllowanceBalance intent has an app type exactly when it has a permit input");
|
|
770
|
+
}
|
|
771
|
+
return {
|
|
772
|
+
_tag: "AllowanceIntent",
|
|
773
|
+
coinType: TypeTag.format(toTypeTag(type)),
|
|
774
|
+
amount: toU64(amount),
|
|
775
|
+
output: outputKind,
|
|
776
|
+
allowanceId: toAddress(objectId),
|
|
777
|
+
...(funder !== undefined && { funder: toAddress(funder) }),
|
|
778
|
+
...(appType !== undefined && { appType: TypeTag.format(toTypeTag(appType)) }),
|
|
779
|
+
allowance,
|
|
780
|
+
clock,
|
|
781
|
+
...(permit !== undefined && { permit }),
|
|
782
|
+
resolve: Allowances.resolve
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
if (intent.name !== COIN_WITH_BALANCE) {
|
|
786
|
+
return unsupported(`intent ${intent.name}`, "only CoinWithBalance (tx.coin / tx.balance) and AllowanceBalance intents are supported");
|
|
787
|
+
}
|
|
788
|
+
if (Object.keys(intent.inputs).length > 0)
|
|
789
|
+
invalid("a CoinWithBalance intent takes no inputs");
|
|
790
|
+
const d = decodeCoinWithBalance(intent.data);
|
|
791
|
+
if (Result.isFailure(d))
|
|
792
|
+
return invalid(`CoinWithBalance data: ${d.failure.message}`);
|
|
793
|
+
const { type, balance, outputKind } = d.success;
|
|
794
|
+
const coinType = type === "gas" ? TypeTag.SUI : TypeTag.format(toTypeTag(type));
|
|
795
|
+
return {
|
|
796
|
+
_tag: "BalanceIntent",
|
|
797
|
+
coinType,
|
|
798
|
+
amount: toU64(balance),
|
|
799
|
+
output: outputKind ?? "coin",
|
|
800
|
+
// An explicit SUI type means "not from the gas coin"; for other types the flag is moot (`Ptb.coin`'s default).
|
|
801
|
+
useGasCoin: type === "gas" || coinType !== TypeTag.SUI
|
|
802
|
+
};
|
|
803
|
+
});
|
|
804
|
+
const inputs = json.inputs.map((i, index) => {
|
|
805
|
+
if ("Pure" in i)
|
|
806
|
+
return { _tag: "Pure", bytes: toBytes(i.Pure.bytes) };
|
|
807
|
+
if ("Object" in i)
|
|
808
|
+
return { _tag: "Object", value: toObjectArg(i.Object) };
|
|
809
|
+
if ("FundsWithdrawal" in i)
|
|
810
|
+
return toWithdrawal(i.FundsWithdrawal);
|
|
811
|
+
if ("UnresolvedObject" in i) {
|
|
812
|
+
const o = i.UnresolvedObject;
|
|
813
|
+
const objectId = toAddress(o.objectId);
|
|
814
|
+
const pinned = o.version != null || o.digest != null;
|
|
815
|
+
if (pinned && o.initialSharedVersion == null) {
|
|
816
|
+
if (o.version == null || o.digest == null)
|
|
817
|
+
invalid(`UnresolvedObject ${objectId}: version and digest go together`);
|
|
818
|
+
// Mysten uses a pinned ref as given: owned, or Receiving when a Move
|
|
819
|
+
// call takes it as `Receiving<T>` (which needs the signature to tell).
|
|
820
|
+
if (inMoveCall.has(index)) {
|
|
821
|
+
unsupported(`UnresolvedObject ${objectId}`, "a version-pinned object passed to a Move call may be a Receiving; resolve it to an Object input first");
|
|
822
|
+
}
|
|
823
|
+
return {
|
|
824
|
+
_tag: "Object",
|
|
825
|
+
value: { _tag: "ImmOrOwnedObject", objectId, version: toU64(o.version), digest: toDigest(o.digest) }
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
// A shared object's initial version is a property of the object, so the resolver finds the same value.
|
|
829
|
+
return { _tag: "UnresolvedObject", objectId, ...(o.mutable === true && { mutable: true }) };
|
|
830
|
+
}
|
|
831
|
+
// UnresolvedPure
|
|
832
|
+
const uses = pureUses.get(index);
|
|
833
|
+
const kind = uses?.size === 1 ? [...uses][0] : "other";
|
|
834
|
+
const value = i.UnresolvedPure.value;
|
|
835
|
+
if (kind === "u64") {
|
|
836
|
+
if (!(typeof value === "bigint" || (typeof value === "number" && Number.isSafeInteger(value)) ||
|
|
837
|
+
(typeof value === "string" && /^\d+$/.test(value)))) {
|
|
838
|
+
invalid(`UnresolvedPure ${index}: not a u64: ${JSON.stringify(value)}`);
|
|
839
|
+
}
|
|
840
|
+
const n = BigInt(value);
|
|
841
|
+
if (n < 0n || n > U64_MAX)
|
|
842
|
+
invalid(`UnresolvedPure ${index}: not a u64: ${n}`);
|
|
843
|
+
return { _tag: "Pure", bytes: encodeU64(n) };
|
|
844
|
+
}
|
|
845
|
+
if (kind === "address") {
|
|
846
|
+
if (typeof value !== "string" || !/^(0x)?[0-9a-fA-F]{1,64}$/.test(value)) {
|
|
847
|
+
invalid(`UnresolvedPure ${index}: not an address: ${JSON.stringify(value)}`);
|
|
848
|
+
}
|
|
849
|
+
return { _tag: "Pure", bytes: encodeAddress(toAddress(value)) };
|
|
850
|
+
}
|
|
851
|
+
return unsupported(`UnresolvedPure input ${index}`, "an untyped pure value needs its Move parameter type; serialize it (tx.pure.u64(...), ...) before encoding");
|
|
852
|
+
});
|
|
853
|
+
const g = json.gasData;
|
|
854
|
+
return {
|
|
855
|
+
draft: { inputs, commands },
|
|
856
|
+
...(json.sender != null && { sender: toAddress(json.sender) }),
|
|
857
|
+
...(json.expiration != null && { expiration: toExpiration(json.expiration) }),
|
|
858
|
+
...(g.owner !== null && { gasOwner: toAddress(g.owner) }),
|
|
859
|
+
...(g.price !== null && { gasPrice: toU64(g.price) }),
|
|
860
|
+
...(g.budget !== null && { gasBudget: toU64(g.budget) }),
|
|
861
|
+
...(g.payment !== null && { gasPayment: g.payment.map(toRef) })
|
|
862
|
+
};
|
|
863
|
+
};
|
|
864
|
+
/** Schema-valid transaction JSON -> an `Unresolved` transaction. */
|
|
865
|
+
export const toUnresolved = (json) => Effect.suspend(() => {
|
|
866
|
+
let tx;
|
|
867
|
+
try {
|
|
868
|
+
tx = toUnresolvedSync(json);
|
|
869
|
+
}
|
|
870
|
+
catch (e) {
|
|
871
|
+
if (e instanceof Fail)
|
|
872
|
+
return Effect.fail(e.error);
|
|
873
|
+
throw e;
|
|
874
|
+
}
|
|
875
|
+
// A fully resolved transaction's digest must be its own. A digest beside
|
|
876
|
+
// unresolved inputs or intents describes some other resolution: not checked.
|
|
877
|
+
const claimed = json.digest;
|
|
878
|
+
const resolved = json.inputs.every((i) => !("UnresolvedPure" in i) && !("UnresolvedObject" in i)) &&
|
|
879
|
+
json.commands.every((c) => !("$Intent" in c));
|
|
880
|
+
if (typeof claimed !== "string" || !resolved)
|
|
881
|
+
return Effect.succeed(tx);
|
|
882
|
+
return Effect.matchEffect(toTransactionData(tx), {
|
|
883
|
+
onFailure: () => Effect.succeed(tx),
|
|
884
|
+
onSuccess: (data) => {
|
|
885
|
+
const actual = Hash.transactionDigest(T.encode(data));
|
|
886
|
+
return actual === claimed
|
|
887
|
+
? Effect.succeed(tx)
|
|
888
|
+
: Effect.fail(new InvalidTransactionJson({ issue: `digest ${claimed} is not this transaction's (${actual})` }));
|
|
889
|
+
}
|
|
890
|
+
});
|
|
891
|
+
});
|
|
892
|
+
/** A JSON string (or parsed value) from `Transaction.toJSON()` -> an `Unresolved` transaction. */
|
|
893
|
+
export const decode = (input) => Effect.flatMap(parse(input), toUnresolved);
|
|
894
|
+
// -----------------------------------------------------------------------------
|
|
895
|
+
// Finishing
|
|
896
|
+
// -----------------------------------------------------------------------------
|
|
897
|
+
/** As a `Resolve.Plan`, for running `Resolve` steps by hand. Needs a sender (from the JSON or `sender`). */
|
|
898
|
+
export const toPlan = (tx, sender) => {
|
|
899
|
+
const s = sender ?? tx.sender;
|
|
900
|
+
return s === undefined
|
|
901
|
+
? Effect.fail(new Resolve.Incomplete({ missing: "sender" }))
|
|
902
|
+
: Effect.succeed({ ...tx, sender: s });
|
|
903
|
+
};
|
|
904
|
+
/** The `TransactionData` of a transaction that is already fully resolved (no network). */
|
|
905
|
+
export const toTransactionData = (tx) => Effect.flatMap(toPlan(tx), Resolve.finish);
|
|
906
|
+
/**
|
|
907
|
+
* Finish with the default pipeline (`Tx.resolve`), keeping whatever the JSON
|
|
908
|
+
* already fixed: sender, gas owner, price, budget, expiration, and its gas
|
|
909
|
+
* payment (as `Resolve.fixed`). `options` override the JSON.
|
|
910
|
+
*/
|
|
911
|
+
export const resolve = (tx, options = {}) => Effect.flatMap(toPlan(tx, options.sender), (plan) => {
|
|
912
|
+
const payment = options.payment ?? (plan.gasPayment ? Resolve.fixed(plan.gasPayment) : undefined);
|
|
913
|
+
const gasOwner = options.gasOwner ?? plan.gasOwner;
|
|
914
|
+
const gasPrice = options.gasPrice ?? plan.gasPrice;
|
|
915
|
+
const gasBudget = options.gasBudget ?? plan.gasBudget;
|
|
916
|
+
const expiration = options.expiration ?? plan.expiration;
|
|
917
|
+
return Tx.resolve(plan.draft, {
|
|
918
|
+
sender: plan.sender,
|
|
919
|
+
...(gasOwner !== undefined && { gasOwner }),
|
|
920
|
+
...(gasPrice !== undefined && { gasPrice }),
|
|
921
|
+
...(gasBudget !== undefined && { gasBudget }),
|
|
922
|
+
...(expiration !== undefined && { expiration }),
|
|
923
|
+
...(payment !== undefined && { payment })
|
|
924
|
+
});
|
|
925
|
+
});
|
|
926
|
+
//# sourceMappingURL=TransactionJson.js.map
|