@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
package/package.json
CHANGED
|
@@ -1,6 +1,71 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unconfirmed/effect-sui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A ground-up Effect SDK for Sui: transactions, signers and signature schemes (Ed25519, Secp256k1/r1, ML-DSA-65, multisig, passkeys, zkLogin), mnemonics, gRPC and GraphQL clients, crash-safe submission, wallets and Enoki.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/unconfirmedlabs/effect-packages.git",
|
|
9
|
+
"directory": "packages/effect-sui"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/unconfirmedlabs/effect-packages/tree/main/packages/effect-sui#readme",
|
|
12
|
+
"bugs": "https://github.com/unconfirmedlabs/effect-packages/issues",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./grpc": {
|
|
21
|
+
"types": "./dist/grpc/index.d.ts",
|
|
22
|
+
"default": "./dist/grpc/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./graphql": {
|
|
25
|
+
"types": "./dist/graphql/index.d.ts",
|
|
26
|
+
"default": "./dist/graphql/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./lifecycle": {
|
|
29
|
+
"types": "./dist/lifecycle/index.d.ts",
|
|
30
|
+
"default": "./dist/lifecycle/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./zklogin": {
|
|
33
|
+
"types": "./dist/zklogin/index.d.ts",
|
|
34
|
+
"default": "./dist/zklogin/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./enoki": {
|
|
37
|
+
"types": "./dist/enoki/index.d.ts",
|
|
38
|
+
"default": "./dist/enoki/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./wallet": {
|
|
41
|
+
"types": "./dist/wallet/index.d.ts",
|
|
42
|
+
"default": "./dist/wallet/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./*": {
|
|
45
|
+
"types": "./dist/*.d.ts",
|
|
46
|
+
"default": "./dist/*.js"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"dist",
|
|
51
|
+
"src"
|
|
52
|
+
],
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@noble/curves": "^2.3.0",
|
|
55
|
+
"@noble/hashes": "^2.3.0",
|
|
56
|
+
"@noble/post-quantum": "^0.7.1",
|
|
57
|
+
"@scure/base": "^2.3.0",
|
|
58
|
+
"@scure/bip32": "^2.3.0",
|
|
59
|
+
"@scure/bip39": "^2.3.0",
|
|
60
|
+
"@wallet-standard/app": "^1.1.1",
|
|
61
|
+
"@wallet-standard/base": "^1.1.1",
|
|
62
|
+
"poseidon-lite": "0.3.0"
|
|
63
|
+
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"@unconfirmed/effect-bcs": "^0.1.0",
|
|
66
|
+
"effect": "^4.1.6"
|
|
67
|
+
},
|
|
68
|
+
"publishConfig": {
|
|
69
|
+
"access": "public"
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/Address.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sui addresses and object ids: 32 bytes, shown as `0x` + 64 lowercase hex.
|
|
3
|
+
*/
|
|
4
|
+
import { blake2b } from "@noble/hashes/blake2.js"
|
|
5
|
+
import * as Bcs from "@unconfirmed/effect-bcs/Bcs"
|
|
6
|
+
import * as Schema from "effect/Schema"
|
|
7
|
+
import * as SchemaTransformation from "effect/SchemaTransformation"
|
|
8
|
+
import * as Bytes from "@unconfirmed/effect-bcs/Bytes"
|
|
9
|
+
|
|
10
|
+
/** The branded, normalized address. Also its BCS layout (32 raw bytes). */
|
|
11
|
+
export const Address = Bcs.Address
|
|
12
|
+
export type Address = Bcs.Address
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/** Normalize `0x2`, `0X02` or unprefixed hex. Throws on anything else: use for literals you control. */
|
|
16
|
+
export const normalize = (s: string): Address => {
|
|
17
|
+
const h = s.toLowerCase().replace(/^0x/, "")
|
|
18
|
+
if (!/^[0-9a-f]{1,64}$/.test(h)) throw new Error(`invalid Sui address: ${s}`)
|
|
19
|
+
return ("0x" + h.padStart(64, "0")) as Address
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Decode a value someone typed: exactly 64 hex digits, `0x` optional. A truncated paste is an error, not a padded address. */
|
|
23
|
+
export const Strict: Schema.Codec<Address, string> = /* @__PURE__ */ Schema.String.pipe(
|
|
24
|
+
Schema.check(Schema.isPattern(/^(0x)?[0-9a-fA-F]{64}$/)),
|
|
25
|
+
Schema.decodeTo(
|
|
26
|
+
Address,
|
|
27
|
+
SchemaTransformation.transform<string, string>({ decode: (s) => normalize(s), encode: (a) => a }) as any
|
|
28
|
+
)
|
|
29
|
+
) as any
|
|
30
|
+
|
|
31
|
+
export const fromBytes = (bytes: Uint8Array): Address => ("0x" + Bytes.toHex(bytes)) as Address
|
|
32
|
+
|
|
33
|
+
/** `blake2b256(flag || publicKey)`, the address of a single-key scheme. */
|
|
34
|
+
export const fromPublicKey = (flag: number, publicKey: Uint8Array): Address => {
|
|
35
|
+
const input = new Uint8Array(1 + publicKey.length)
|
|
36
|
+
input[0] = flag
|
|
37
|
+
input.set(publicKey, 1)
|
|
38
|
+
return fromBytes(blake2b(input, { dkLen: 32 }))
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const ZERO = /* @__PURE__ */ normalize("0x0")
|
|
42
|
+
export const SUI_FRAMEWORK = /* @__PURE__ */ normalize("0x2")
|
|
43
|
+
export const SUI_SYSTEM = /* @__PURE__ */ normalize("0x3")
|
|
44
|
+
export const CLOCK = /* @__PURE__ */ normalize("0x6")
|
|
45
|
+
export const RANDOM = /* @__PURE__ */ normalize("0x8")
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Address aliases (`0x2::address_alias`). An address `A` that has enabled
|
|
3
|
+
* aliases owns an `AddressAliases` object, derived from the shared
|
|
4
|
+
* `AddressAliasState` (`0xa`), holding up to eight addresses. From then on the
|
|
5
|
+
* chain accepts a transaction from `A` signed by any address in that set
|
|
6
|
+
* instead of by `A`'s own key (and `A`'s own key only while `A` is in it).
|
|
7
|
+
*
|
|
8
|
+
* const aliases = yield* AddressAlias.get(A) // { enabled, aliases, objectId }
|
|
9
|
+
* yield* Tx.run(AddressAlias.add(A, B), { signer: a }) // a recipe step, signed by A
|
|
10
|
+
* const asA = yield* AddressAlias.checkedSigner(A, b) // B's key, signing for A
|
|
11
|
+
* yield* Tx.run(recipe, { signer: asA }) // sender A, signature by B
|
|
12
|
+
*
|
|
13
|
+
* Adding an alias gives that key full control of the address, so treat these
|
|
14
|
+
* steps like exporting a key. (`@mysten/sui` refuses `0x2::address_alias`
|
|
15
|
+
* calls by default, so a dapp can't slip one into a wallet's transaction.)
|
|
16
|
+
*/
|
|
17
|
+
import * as Effect from "effect/Effect"
|
|
18
|
+
import * as Schema from "effect/Schema"
|
|
19
|
+
import * as Bcs from "@unconfirmed/effect-bcs/Bcs"
|
|
20
|
+
import { type Address, normalize } from "./Address.ts"
|
|
21
|
+
import { deriveObjectId } from "./DynamicFields.ts"
|
|
22
|
+
import { decode, type ObjectDecodeError, Objects } from "./Objects.ts"
|
|
23
|
+
import * as Ptb from "./Ptb.ts"
|
|
24
|
+
import type { RpcError } from "./RpcError.ts"
|
|
25
|
+
import type { Signer } from "./Signer.ts"
|
|
26
|
+
import type * as T from "./TransactionData.ts"
|
|
27
|
+
|
|
28
|
+
/** The shared `0x2::address_alias::AddressAliasState`, parent of every alias set. */
|
|
29
|
+
export const STATE_ID: Address = /* @__PURE__ */ normalize("0xa")
|
|
30
|
+
|
|
31
|
+
/** The most addresses an alias set holds (`add` and `replaceAll` abort beyond it). */
|
|
32
|
+
export const MAX_ALIASES = 8
|
|
33
|
+
|
|
34
|
+
const KEY_TYPE = "0x2::address_alias::AliasKey"
|
|
35
|
+
|
|
36
|
+
/** `0x2::address_alias::AddressAliases`: its id and a `VecSet<address>`. */
|
|
37
|
+
export const AddressAliases = /* @__PURE__ */ Bcs.struct({
|
|
38
|
+
id: Bcs.Address,
|
|
39
|
+
aliases: /* @__PURE__ */ Bcs.struct({ contents: /* @__PURE__ */ Bcs.vector(Bcs.Address) })
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
const encodeAddress = /* @__PURE__ */ Bcs.encodeSync(Bcs.Address)
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The id of `address`'s `AddressAliases` object, whether or not it exists yet:
|
|
46
|
+
* `derived_object` of `AliasKey(address)` under `0xa`. Throws on an invalid
|
|
47
|
+
* address, like `Address.normalize`.
|
|
48
|
+
*/
|
|
49
|
+
export const aliasesId = (address: string): Address => deriveObjectId(STATE_ID, KEY_TYPE, encodeAddress(normalize(address)))
|
|
50
|
+
|
|
51
|
+
export interface Aliases {
|
|
52
|
+
readonly address: Address
|
|
53
|
+
/** Whether `address` has enabled aliases (its `AddressAliases` object exists). */
|
|
54
|
+
readonly enabled: boolean
|
|
55
|
+
/** The addresses whose signatures the chain accepts for `address`: its alias set, or only itself when not enabled. */
|
|
56
|
+
readonly aliases: ReadonlyArray<Address>
|
|
57
|
+
readonly objectId: Address
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const decodeAliases = /* @__PURE__ */ decode(AddressAliases)
|
|
61
|
+
|
|
62
|
+
/** Read `address`'s alias set. An address that never enabled aliases is its own only alias, as on chain. */
|
|
63
|
+
export const get = (address: Address): Effect.Effect<Aliases, ObjectDecodeError | RpcError, Objects> =>
|
|
64
|
+
Effect.suspend(() => {
|
|
65
|
+
const objectId = aliasesId(address)
|
|
66
|
+
return Effect.flatMap(Effect.service(Objects), (o) => o.get(objectId)).pipe(
|
|
67
|
+
Effect.flatMap(decodeAliases),
|
|
68
|
+
Effect.map((a): Aliases => ({ address, enabled: true, aliases: a.aliases.contents, objectId })),
|
|
69
|
+
Effect.catchTag("ObjectNotFound", () => Effect.succeed<Aliases>({ address, enabled: false, aliases: [address], objectId }))
|
|
70
|
+
)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
/** Whether the chain accepts `signer`'s signature for transactions from `address`. */
|
|
74
|
+
export const allows = (address: Address, signer: Address): Effect.Effect<boolean, ObjectDecodeError | RpcError, Objects> =>
|
|
75
|
+
Effect.map(get(address), (a) => a.aliases.includes(signer))
|
|
76
|
+
|
|
77
|
+
// -----------------------------------------------------------------------------
|
|
78
|
+
// Recipe steps
|
|
79
|
+
// -----------------------------------------------------------------------------
|
|
80
|
+
|
|
81
|
+
const attempt = <A>(f: () => A) =>
|
|
82
|
+
Effect.try({ try: f, catch: (e) => new Ptb.InvalidPureValue({ issue: e instanceof Error ? e.message : String(e) }) })
|
|
83
|
+
|
|
84
|
+
const call = (fn: string, args: ReadonlyArray<T.Argument>) =>
|
|
85
|
+
Ptb.moveCall({ target: `0x2::address_alias::${fn}`, arguments: args })
|
|
86
|
+
|
|
87
|
+
/** `owner`'s `AddressAliases` (consensus-owned by `owner`), looked up by the resolver. */
|
|
88
|
+
const aliasesOf = (owner: string) => Effect.flatMap(attempt(() => aliasesId(owner)), (id) => Ptb.object(id))
|
|
89
|
+
|
|
90
|
+
/** `enable`: create the sender's alias set, holding only the sender. Aborts if the sender already has one. */
|
|
91
|
+
export const enable = /* @__PURE__ */ Effect.flatMap(/* @__PURE__ */ Ptb.object(STATE_ID), (state) => call("enable", [state]))
|
|
92
|
+
|
|
93
|
+
/** `add`: add `alias` to `owner`'s set (signed by `owner` or an alias). Aborts if present or past `MAX_ALIASES`. */
|
|
94
|
+
export const add = (owner: string, alias: string) =>
|
|
95
|
+
Effect.gen(function*() {
|
|
96
|
+
const aliases = yield* aliasesOf(owner)
|
|
97
|
+
return yield* call("add", [aliases, yield* Ptb.address(alias)])
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
/** `remove`: remove `alias` from `owner`'s set. Aborts if absent or the last one. */
|
|
101
|
+
export const remove = (owner: string, alias: string) =>
|
|
102
|
+
Effect.gen(function*() {
|
|
103
|
+
const aliases = yield* aliasesOf(owner)
|
|
104
|
+
return yield* call("remove", [aliases, yield* Ptb.address(alias)])
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* `replace_all`: make `owner`'s set exactly `aliases`. One to `MAX_ALIASES`
|
|
109
|
+
* distinct addresses, checked here (`InvalidPureValue`) as the chain would.
|
|
110
|
+
*/
|
|
111
|
+
export const replaceAll = (owner: string, aliases: ReadonlyArray<string>) =>
|
|
112
|
+
Effect.gen(function*() {
|
|
113
|
+
const set = yield* attempt(() => aliases.map(normalize))
|
|
114
|
+
if (set.length === 0 || set.length > MAX_ALIASES || new Set(set).size !== set.length) {
|
|
115
|
+
return yield* new Ptb.InvalidPureValue({ issue: `an alias set holds 1 to ${MAX_ALIASES} distinct addresses, got ${aliases.length}` })
|
|
116
|
+
}
|
|
117
|
+
const target = yield* aliasesOf(owner)
|
|
118
|
+
return yield* call("replace_all", [target, yield* Ptb.pure(Bcs.vector(Bcs.Address), set)])
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
// -----------------------------------------------------------------------------
|
|
122
|
+
// Signing as an alias
|
|
123
|
+
// -----------------------------------------------------------------------------
|
|
124
|
+
|
|
125
|
+
/** A key signing for another address: `address` is the address it signs for, `keyAddress` the key's own. */
|
|
126
|
+
export interface AliasSigner extends Signer {
|
|
127
|
+
readonly keyAddress: Address
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* `key` signing for `address` through `address`'s alias set: transactions it
|
|
132
|
+
* runs have sender `address` and carry `key`'s signature. Unchecked: the node
|
|
133
|
+
* refuses the signature if `key` isn't in the set (see `checkedSigner`).
|
|
134
|
+
*/
|
|
135
|
+
export const signer = (address: string, key: Signer): AliasSigner => ({
|
|
136
|
+
...key,
|
|
137
|
+
address: normalize(address),
|
|
138
|
+
keyAddress: key.address
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
/** `key` is not in `address`'s alias set. */
|
|
142
|
+
export class AliasNotAllowed extends /* @__PURE__ */ Schema.TaggedError<AliasNotAllowed>()("AliasNotAllowed", {
|
|
143
|
+
address: Schema.String,
|
|
144
|
+
signer: Schema.String,
|
|
145
|
+
aliases: Schema.Array(Schema.String)
|
|
146
|
+
}) {
|
|
147
|
+
override get message(): string {
|
|
148
|
+
return `${this.signer} is not in the alias set of ${this.address} (${this.aliases.join(", ")})`
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** `signer`, after reading `address`'s alias set: `AliasNotAllowed` if `key` isn't in it. */
|
|
153
|
+
export const checkedSigner = (
|
|
154
|
+
address: Address,
|
|
155
|
+
key: Signer
|
|
156
|
+
): Effect.Effect<AliasSigner, AliasNotAllowed | ObjectDecodeError | RpcError, Objects> =>
|
|
157
|
+
Effect.flatMap(get(address), (a) =>
|
|
158
|
+
a.aliases.includes(key.address)
|
|
159
|
+
? Effect.succeed(signer(address, key))
|
|
160
|
+
: Effect.fail(new AliasNotAllowed({ address, signer: key.address, aliases: a.aliases })))
|
package/src/Bip32.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secp256k1 and Secp256r1 keys from a mnemonic (BIP32). A module of its own so
|
|
3
|
+
* `@scure/bip32` loads only for these: Ed25519 and ML-DSA-65 (SLIP-0010) are in
|
|
4
|
+
* `Mnemonic`.
|
|
5
|
+
*
|
|
6
|
+
* const k1 = yield* Secp256k1.fromSecretKey(yield* Bip32.secp256k1SecretKey(m, { account: 1 }))
|
|
7
|
+
*
|
|
8
|
+
* Secp256r1 follows `@mysten/sui` and the Sui CLI: it derives with BIP32's
|
|
9
|
+
* secp256k1 arithmetic and uses the resulting scalar as a P-256 key.
|
|
10
|
+
*/
|
|
11
|
+
import { HDKey } from "@scure/bip32"
|
|
12
|
+
import * as Effect from "effect/Effect"
|
|
13
|
+
import { type Derived, type Path, resolve, type Rule, SECP256K1, SECP256R1, seedOf, type Source } from "./internal/mnemonic.ts"
|
|
14
|
+
|
|
15
|
+
const deriveBip32 = (rule: Rule, source: Source, path: Path | undefined): Derived =>
|
|
16
|
+
Effect.flatMap(resolve(rule, path), ({ path }) =>
|
|
17
|
+
Effect.flatMap(seedOf(source), (seed) =>
|
|
18
|
+
Effect.sync(() => {
|
|
19
|
+
// A child that is not a valid key has probability ~2^-127; a defect, as in @scure/bip32.
|
|
20
|
+
const master = HDKey.fromMasterSeed(seed)
|
|
21
|
+
const child = master.derive(path)
|
|
22
|
+
try {
|
|
23
|
+
if (!child.privateKey) throw new Error(`no private key at ${path}`)
|
|
24
|
+
return child.privateKey.slice()
|
|
25
|
+
} finally {
|
|
26
|
+
// Zero the nodes' keys and chain codes, as the SLIP-0010 path zeroes its intermediates.
|
|
27
|
+
// (`derive` makes the nodes in between internally; they are out of reach.)
|
|
28
|
+
child.wipePrivateData()
|
|
29
|
+
master.wipePrivateData()
|
|
30
|
+
}
|
|
31
|
+
})))
|
|
32
|
+
|
|
33
|
+
/** The Secp256k1 secret key at a path (default `m/54'/784'/0'/0/0`). Use with `Secp256k1.fromSecretKey`. */
|
|
34
|
+
export const secp256k1SecretKey = (source: Source, path?: Path): Derived => deriveBip32(SECP256K1, source, path)
|
|
35
|
+
|
|
36
|
+
/** The Secp256r1 secret key at a path (default `m/74'/784'/0'/0/0`). Use with `Secp256r1.fromSecretKey`. */
|
|
37
|
+
export const secp256r1SecretKey = (source: Source, path?: Path): Derived => deriveBip32(SECP256R1, source, path)
|
package/src/Chain.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chain identity and the current epoch's gas price.
|
|
3
|
+
*/
|
|
4
|
+
import * as Context from "effect/Context"
|
|
5
|
+
import type * as Effect from "effect/Effect"
|
|
6
|
+
import type { RpcError } from "./RpcError.ts"
|
|
7
|
+
import type { ObjectDigest } from "./TransactionData.ts"
|
|
8
|
+
|
|
9
|
+
export interface ChainInfo {
|
|
10
|
+
/** The genesis checkpoint digest; what `ValidDuring.chain` names. */
|
|
11
|
+
readonly chainId: ObjectDigest
|
|
12
|
+
/** `mainnet`, `testnet`, ... as the node reports it. */
|
|
13
|
+
readonly chain: string
|
|
14
|
+
readonly epoch: bigint
|
|
15
|
+
readonly checkpointHeight: bigint
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class Chain extends /* @__PURE__ */ Context.Service<Chain, {
|
|
19
|
+
readonly info: Effect.Effect<ChainInfo, RpcError>
|
|
20
|
+
readonly referenceGasPrice: Effect.Effect<bigint, RpcError>
|
|
21
|
+
}>()("@unconfirmed/effect-sui/Chain") {}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkpoint contents for indexers: each checkpoint with its transactions,
|
|
3
|
+
* their effects and events. `follow` reads history from a start checkpoint and
|
|
4
|
+
* continues live, gap-free and without duplicates.
|
|
5
|
+
*/
|
|
6
|
+
import * as Context from "effect/Context"
|
|
7
|
+
import type * as Duration from "effect/Duration"
|
|
8
|
+
import * as Effect from "effect/Effect"
|
|
9
|
+
import * as Schedule from "effect/Schedule"
|
|
10
|
+
import * as Schema from "effect/Schema"
|
|
11
|
+
import * as Stream from "effect/Stream"
|
|
12
|
+
import type { Event } from "./Events.ts"
|
|
13
|
+
import type { RpcError } from "./RpcError.ts"
|
|
14
|
+
import type { ChangedObject, GasUsed, Status } from "./Transactions.ts"
|
|
15
|
+
|
|
16
|
+
export interface CheckpointTransaction {
|
|
17
|
+
readonly digest: string
|
|
18
|
+
/** Position within the checkpoint. */
|
|
19
|
+
readonly index: bigint
|
|
20
|
+
readonly status: Status
|
|
21
|
+
readonly gasUsed: GasUsed
|
|
22
|
+
readonly changedObjects: ReadonlyArray<ChangedObject>
|
|
23
|
+
readonly events: ReadonlyArray<Event>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface Checkpoint {
|
|
27
|
+
readonly sequenceNumber: bigint
|
|
28
|
+
readonly digest: string
|
|
29
|
+
readonly epoch: bigint
|
|
30
|
+
readonly timestampMs: bigint
|
|
31
|
+
readonly transactions: ReadonlyArray<CheckpointTransaction>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class CheckpointNotFound extends /* @__PURE__ */ Schema.TaggedError<CheckpointNotFound>()("CheckpointNotFound", {
|
|
35
|
+
sequenceNumber: Schema.BigInt
|
|
36
|
+
}) {
|
|
37
|
+
override get message(): string {
|
|
38
|
+
return `checkpoint ${this.sequenceNumber} not found`
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** `follow` could not list a gap between history and the live subscription in time. */
|
|
43
|
+
export class CheckpointGap extends /* @__PURE__ */ Schema.TaggedError<CheckpointGap>()("CheckpointGap", {
|
|
44
|
+
from: Schema.BigInt,
|
|
45
|
+
to: Schema.BigInt
|
|
46
|
+
}) {
|
|
47
|
+
override get message(): string {
|
|
48
|
+
return `could not fill checkpoints ${this.from} to ${this.to}`
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export class CheckpointData extends /* @__PURE__ */ Context.Service<CheckpointData, {
|
|
53
|
+
readonly get: (sequenceNumber: bigint) => Effect.Effect<Checkpoint, CheckpointNotFound | RpcError>
|
|
54
|
+
/** History in order, `start` inclusive to `end` exclusive (default: the tip at the time of the call, pinned for the whole scan). */
|
|
55
|
+
readonly list: (options?: { readonly start?: bigint; readonly end?: bigint }) => Stream.Stream<Checkpoint, RpcError>
|
|
56
|
+
/** New checkpoints as they are executed. Ends cleanly if the server closes the stream (use `follow` to reconnect and fill gaps); a cut-off stream fails. */
|
|
57
|
+
readonly subscribe: Stream.Stream<Checkpoint, RpcError>
|
|
58
|
+
}>()("@unconfirmed/effect-sui/CheckpointData") {}
|
|
59
|
+
|
|
60
|
+
export interface FollowOptions {
|
|
61
|
+
/**
|
|
62
|
+
* When to re-list a gap the list index hasn't reached yet; once the schedule ends, the gap is a
|
|
63
|
+
* `CheckpointGap`. It restarts whenever a re-list makes progress. Default every 250 ms, 120 times (30 s).
|
|
64
|
+
*/
|
|
65
|
+
readonly gapRetry?: Schedule.Schedule<unknown>
|
|
66
|
+
/** Wait before reopening a subscription the server closed. Default 1 second. */
|
|
67
|
+
readonly reconnectDelay?: Duration.Input
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const defaultGapRetry: Schedule.Schedule<unknown> = /* @__PURE__ */ Schedule.spaced("250 millis").pipe(
|
|
71
|
+
/* @__PURE__ */ Schedule.upTo({ times: 120 })
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Every checkpoint from `start`, in order, forever: `list` until the tip, then
|
|
76
|
+
* `subscribe`, re-listing any gap between the two and dropping overlap. A
|
|
77
|
+
* subscription the server closes is reopened (its gap re-listed); it only ends
|
|
78
|
+
* with a failure.
|
|
79
|
+
*/
|
|
80
|
+
export const follow = (start: bigint, options?: FollowOptions): Stream.Stream<Checkpoint, RpcError | CheckpointGap, CheckpointData> =>
|
|
81
|
+
Stream.unwrap(Effect.map(Effect.service(CheckpointData), (data) =>
|
|
82
|
+
Stream.suspend(() => {
|
|
83
|
+
const gapRetry = options?.gapRetry ?? defaultGapRetry
|
|
84
|
+
const reconnect = options?.reconnectDelay ?? "1 second"
|
|
85
|
+
let next = start
|
|
86
|
+
const emit = <E>(s: Stream.Stream<Checkpoint, E>) =>
|
|
87
|
+
s.pipe(
|
|
88
|
+
Stream.filter((c) => c.sequenceNumber >= next),
|
|
89
|
+
Stream.tap((c) => Effect.sync(() => (next = c.sequenceNumber + 1n)))
|
|
90
|
+
)
|
|
91
|
+
// The list index may trail the subscription: re-list from `next`, boundedly, until the gap is closed.
|
|
92
|
+
// Only `CheckpointGap` is retried; an `RpcError` from `list` ends the stream at once.
|
|
93
|
+
const fill = (end: bigint): Stream.Stream<Checkpoint, RpcError | CheckpointGap> =>
|
|
94
|
+
Stream.suspend(() =>
|
|
95
|
+
next >= end ? Stream.empty : Stream.concat(
|
|
96
|
+
emit(data.list({ start: next, end })),
|
|
97
|
+
Stream.suspend(() => (next >= end ? Stream.empty : Stream.fail(new CheckpointGap({ from: next, to: end }))))
|
|
98
|
+
)
|
|
99
|
+
).pipe(Stream.retry(Schedule.while(gapRetry, ({ input }) => input instanceof CheckpointGap)))
|
|
100
|
+
const live = (): Stream.Stream<Checkpoint, RpcError | CheckpointGap> =>
|
|
101
|
+
Stream.concat(
|
|
102
|
+
data.subscribe.pipe(Stream.flatMap((c) => Stream.concat(fill(c.sequenceNumber), emit(Stream.make(c))))),
|
|
103
|
+
Stream.suspend(() => Stream.concat(Stream.fromEffectDrain(Effect.sleep(reconnect)), live()))
|
|
104
|
+
)
|
|
105
|
+
return Stream.concat(emit(data.list({ start })), live())
|
|
106
|
+
})))
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkpoints as streams.
|
|
3
|
+
*/
|
|
4
|
+
import * as Context from "effect/Context"
|
|
5
|
+
import type * as Stream from "effect/Stream"
|
|
6
|
+
import type { RpcError } from "./RpcError.ts"
|
|
7
|
+
|
|
8
|
+
export interface CheckpointSummary {
|
|
9
|
+
readonly sequenceNumber: bigint
|
|
10
|
+
readonly digest: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class Checkpoints extends /* @__PURE__ */ Context.Service<Checkpoints, {
|
|
14
|
+
/** History from `start` (default: the oldest the node keeps), in order. */
|
|
15
|
+
readonly list: (options?: { readonly start?: bigint; readonly end?: bigint }) => Stream.Stream<CheckpointSummary, RpcError>
|
|
16
|
+
/** New checkpoints as they are certified. */
|
|
17
|
+
readonly subscribe: Stream.Stream<CheckpointSummary, RpcError>
|
|
18
|
+
}>()("@unconfirmed/effect-sui/Checkpoints") {}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coin reservation refs: a gas-payment entry that funds the gas coin from the
|
|
3
|
+
* gas owner's SUI address balance.
|
|
4
|
+
*
|
|
5
|
+
* When a transaction uses the gas coin (`Ptb.gas`) its payment can't be empty,
|
|
6
|
+
* but the owner may hold SUI in their address balance rather than (or as well
|
|
7
|
+
* as) coin objects. A reservation ref is a synthetic `ObjectRef` that tells
|
|
8
|
+
* validators to draw up to `reserved` MIST from that balance into the gas
|
|
9
|
+
* coin for this epoch:
|
|
10
|
+
*
|
|
11
|
+
* - `objectId`: the owner's SUI accumulator field id (under `0xacc`) XOR the chain id;
|
|
12
|
+
* - `version`: 0;
|
|
13
|
+
* - `digest`: `reserved` (u64 LE) ‖ `epoch` (u32 LE) ‖ twenty `0xac` bytes.
|
|
14
|
+
*/
|
|
15
|
+
import { base58 } from "@scure/base"
|
|
16
|
+
import * as Bcs from "@unconfirmed/effect-bcs/Bcs"
|
|
17
|
+
import * as Bytes from "@unconfirmed/effect-bcs/Bytes"
|
|
18
|
+
import { type Address, fromBytes, normalize } from "./Address.ts"
|
|
19
|
+
import { deriveId } from "./DynamicFields.ts"
|
|
20
|
+
import type { ObjectDigest, ObjectRef } from "./TransactionData.ts"
|
|
21
|
+
|
|
22
|
+
const ACCUMULATOR_ROOT = /* @__PURE__ */ normalize("0xacc")
|
|
23
|
+
const SUI_ACCUMULATOR_KEY = "0x2::accumulator::Key<0x2::balance::Balance<0x2::sui::SUI>>"
|
|
24
|
+
const MAGIC = new Uint8Array(20).fill(0xac)
|
|
25
|
+
|
|
26
|
+
/** Is this gas-payment entry a reservation rather than a coin object? */
|
|
27
|
+
export const isReservation = (ref: ObjectRef): boolean => {
|
|
28
|
+
try {
|
|
29
|
+
const d = base58.decode(ref.digest)
|
|
30
|
+
return d.length === 32 && d.subarray(12).every((b, i) => b === MAGIC[i])
|
|
31
|
+
} catch {
|
|
32
|
+
return false
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The MIST a reservation ref reserves. */
|
|
37
|
+
export const reservedOf = (ref: ObjectRef): bigint => {
|
|
38
|
+
const d = base58.decode(ref.digest)
|
|
39
|
+
return new DataView(d.buffer, d.byteOffset, d.byteLength).getBigUint64(0, true)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A reservation of `reserved` MIST from `owner`'s SUI address balance, valid
|
|
44
|
+
* in `epoch` on the chain `chainId` (the genesis checkpoint digest).
|
|
45
|
+
* Fails (as a defect) only on an epoch beyond u32, which no chain has reached.
|
|
46
|
+
*/
|
|
47
|
+
export const make = (options: {
|
|
48
|
+
readonly reserved: bigint
|
|
49
|
+
readonly owner: Address
|
|
50
|
+
readonly chainId: string
|
|
51
|
+
readonly epoch: bigint
|
|
52
|
+
}): ObjectRef => {
|
|
53
|
+
if (options.epoch < 0n || options.epoch > 0xffffffffn) throw new Error(`epoch ${options.epoch} exceeds u32`)
|
|
54
|
+
const field = Bytes.fromHex(deriveId(ACCUMULATOR_ROOT, SUI_ACCUMULATOR_KEY, Bcs.encodeSync(Bcs.Address)(options.owner)).slice(2))
|
|
55
|
+
const chain = base58.decode(options.chainId)
|
|
56
|
+
if (chain.length !== 32) throw new Error(`chain id must be 32 bytes, got ${chain.length}`)
|
|
57
|
+
const id = field.map((b, i) => b ^ chain[i]!)
|
|
58
|
+
|
|
59
|
+
const digest = new Uint8Array(32)
|
|
60
|
+
const view = new DataView(digest.buffer)
|
|
61
|
+
view.setBigUint64(0, options.reserved, true)
|
|
62
|
+
view.setUint32(8, Number(options.epoch), true)
|
|
63
|
+
digest.set(MAGIC, 12)
|
|
64
|
+
return { objectId: fromBytes(id), version: 0n, digest: base58.encode(digest) as ObjectDigest }
|
|
65
|
+
}
|
package/src/Coins.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Balances and coin objects.
|
|
3
|
+
*/
|
|
4
|
+
import * as Context from "effect/Context"
|
|
5
|
+
import * as Effect from "effect/Effect"
|
|
6
|
+
import * as Result from "effect/Result"
|
|
7
|
+
import * as Stream from "effect/Stream"
|
|
8
|
+
import * as Bcs from "@unconfirmed/effect-bcs/Bcs"
|
|
9
|
+
import { type Address, normalize } from "./Address.ts"
|
|
10
|
+
import type { SuiObject } from "./Objects.ts"
|
|
11
|
+
import { RpcError } from "./RpcError.ts"
|
|
12
|
+
import type { ObjectRef } from "./TransactionData.ts"
|
|
13
|
+
import * as TypeTag from "./TypeTag.ts"
|
|
14
|
+
|
|
15
|
+
export interface Balance {
|
|
16
|
+
readonly coinType: string
|
|
17
|
+
/** Address balance plus coin objects. */
|
|
18
|
+
readonly total: bigint
|
|
19
|
+
readonly addressBalance: bigint
|
|
20
|
+
readonly coinBalance: bigint
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface Coin {
|
|
24
|
+
readonly ref: ObjectRef
|
|
25
|
+
readonly coinType: string
|
|
26
|
+
readonly balance: bigint
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class Coins extends /* @__PURE__ */ Context.Service<Coins, {
|
|
30
|
+
/** Default coin type: SUI. */
|
|
31
|
+
readonly getBalance: (owner: Address, coinType?: string) => Effect.Effect<Balance, RpcError>
|
|
32
|
+
/** Every coin type the owner holds, in coins or only in its address balance. */
|
|
33
|
+
readonly listBalances: (owner: Address) => Stream.Stream<Balance, RpcError>
|
|
34
|
+
/** The owner's coin objects of `coinType`, or of every type when it is omitted. */
|
|
35
|
+
readonly list: (owner: Address, coinType?: string) => Stream.Stream<Coin, RpcError>
|
|
36
|
+
}>()("@unconfirmed/effect-sui/Coins") {}
|
|
37
|
+
|
|
38
|
+
const decodeCoin = /* @__PURE__ */ Bcs.decode(/* @__PURE__ */ Bcs.struct({ id: Bcs.Address, balance: Bcs.u64 }))
|
|
39
|
+
|
|
40
|
+
const COIN = "0x2::coin::Coin"
|
|
41
|
+
const FRAMEWORK = /* @__PURE__ */ normalize("0x2")
|
|
42
|
+
|
|
43
|
+
/** `T` of a `0x2::coin::Coin<T>` object type, normalized; `undefined` for anything else. */
|
|
44
|
+
const coinTypeOf = (objectType: string): string | undefined => {
|
|
45
|
+
try {
|
|
46
|
+
const t = TypeTag.parse(objectType)
|
|
47
|
+
return t._tag === "struct" && t.address === FRAMEWORK && t.module === "coin" && t.name === "Coin" && t.typeParams.length === 1
|
|
48
|
+
? TypeTag.format(t.typeParams[0]!)
|
|
49
|
+
: undefined
|
|
50
|
+
} catch {
|
|
51
|
+
return undefined
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Coins from an owned-object listing, for transports that list coins as
|
|
57
|
+
* objects: `list(objectType)` gets the `0x2::coin::Coin<T>` filter, or the
|
|
58
|
+
* uninstantiated `0x2::coin::Coin` (every coin) when `coinType` is omitted.
|
|
59
|
+
* A coin type that doesn't parse is `INVALID_ARGUMENT` (before any request);
|
|
60
|
+
* an object that isn't a coin is `DATA_LOSS`.
|
|
61
|
+
*/
|
|
62
|
+
export const fromObjects = (
|
|
63
|
+
method: string,
|
|
64
|
+
coinType: string | undefined,
|
|
65
|
+
list: (objectType: string) => Stream.Stream<SuiObject, RpcError>
|
|
66
|
+
): Stream.Stream<Coin, RpcError> =>
|
|
67
|
+
Stream.unwrap(Effect.map(
|
|
68
|
+
Effect.try({
|
|
69
|
+
try: () => (coinType === undefined ? undefined : TypeTag.normalizeString(coinType)),
|
|
70
|
+
catch: (e) => new RpcError({ method, code: "INVALID_ARGUMENT", message: `invalid coin type ${coinType}: ${e instanceof Error ? e.message : String(e)}` })
|
|
71
|
+
}),
|
|
72
|
+
(type) =>
|
|
73
|
+
list(type === undefined ? COIN : `${COIN}<${type}>`).pipe(
|
|
74
|
+
Stream.mapEffect((o) => {
|
|
75
|
+
const malformed = (issue: string) =>
|
|
76
|
+
Effect.fail(new RpcError({ method, code: "DATA_LOSS", message: `malformed coin ${o.objectId}: ${issue}` }))
|
|
77
|
+
const ofType = type ?? coinTypeOf(o.type)
|
|
78
|
+
if (ofType === undefined) return malformed(`${o.type} is not a coin type`)
|
|
79
|
+
return Result.match(decodeCoin(o.contents), {
|
|
80
|
+
onFailure: (e) => malformed(e.message),
|
|
81
|
+
onSuccess: (c): Effect.Effect<Coin> =>
|
|
82
|
+
Effect.succeed({ ref: { objectId: o.objectId, version: o.version, digest: o.digest }, coinType: ofType, balance: c.balance })
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
)
|
|
86
|
+
))
|