@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,280 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enoki-sponsored transactions on top of the core pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Enoki takes only the `TransactionKind` and fills in gas itself, so a
|
|
5
|
+
* sponsored transaction replaces the gas half of `Tx.resolve`
|
|
6
|
+
* (`gasPrice -> budget -> payment -> finish`) with one round trip:
|
|
7
|
+
*
|
|
8
|
+
* Ptb.build(recipe) -> Resolve.inputs -> transactionKind -> Enoki sponsor
|
|
9
|
+
* -> check the returned bytes -> Signer.signTransaction -> Enoki execute
|
|
10
|
+
*
|
|
11
|
+
* const { digest } = yield* Sponsor.run(recipe, { signer, network: "testnet" })
|
|
12
|
+
*
|
|
13
|
+
* Each step is exported for flows that stop in between: `transactionKind`,
|
|
14
|
+
* `sponsor` (create and check), then sign, then `execute`. A failed execute is
|
|
15
|
+
* `ExecutionUnconfirmed`, carrying the signed bytes, signature and digest:
|
|
16
|
+
* check the digest on chain, or `execute` the same signature again, rather
|
|
17
|
+
* than sponsoring a second transaction.
|
|
18
|
+
*/
|
|
19
|
+
import * as Address from "../Address.ts"
|
|
20
|
+
import type * as Coins from "../Coins.ts"
|
|
21
|
+
import * as Hash from "../Hash.ts"
|
|
22
|
+
import type * as Objects from "../Objects.ts"
|
|
23
|
+
import type * as Packages from "../Packages.ts"
|
|
24
|
+
import * as Ptb from "../Ptb.ts"
|
|
25
|
+
import * as Resolve from "../Resolve.ts"
|
|
26
|
+
import type * as RpcError from "../RpcError.ts"
|
|
27
|
+
import * as Signer from "../Signer.ts"
|
|
28
|
+
import * as T from "../TransactionData.ts"
|
|
29
|
+
import * as Bcs from "@unconfirmed/effect-bcs/Bcs"
|
|
30
|
+
import * as Effect from "effect/Effect"
|
|
31
|
+
import * as Result from "effect/Result"
|
|
32
|
+
import * as Schema from "effect/Schema"
|
|
33
|
+
import { EnokiClient, EnokiError, type EnokiNetwork } from "./EnokiClient.ts"
|
|
34
|
+
import * as Bytes from "@unconfirmed/effect-bcs/Bytes"
|
|
35
|
+
|
|
36
|
+
/** Enoki answered with transaction bytes that are not the transaction we asked it to sponsor. */
|
|
37
|
+
export class UnexpectedSponsoredTransaction extends Schema.TaggedError<UnexpectedSponsoredTransaction>()(
|
|
38
|
+
"UnexpectedSponsoredTransaction",
|
|
39
|
+
{ reason: Schema.String }
|
|
40
|
+
) {
|
|
41
|
+
override get message(): string {
|
|
42
|
+
return this.reason
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const encodeKind = Bcs.encodeSync(T.TransactionKind)
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The BCS `TransactionKind` of a draft whose object inputs and coin/balance
|
|
50
|
+
* intents are resolved (run `Resolve.inputs` and `Resolve.balances` first).
|
|
51
|
+
*/
|
|
52
|
+
export const transactionKind = (draft: Ptb.Draft): Effect.Effect<Uint8Array, Resolve.Incomplete> =>
|
|
53
|
+
Effect.suspend(() => {
|
|
54
|
+
const programmable = Ptb.toProgrammable(draft)
|
|
55
|
+
return programmable
|
|
56
|
+
? Effect.succeed(encodeKind({ _tag: "ProgrammableTransaction", ...programmable }))
|
|
57
|
+
: Effect.fail(new Resolve.Incomplete({ missing: "object inputs or coin/balance intents (run Resolve.inputs and Resolve.balances)" }))
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Executing a signed sponsored transaction through Enoki failed. Enoki may
|
|
62
|
+
* have executed it anyway (a gateway timeout, a lost response): check `digest`
|
|
63
|
+
* on chain, or post the same `signature` again with `execute`. Sponsoring
|
|
64
|
+
* again would make a second, different transaction (new gas, new digest).
|
|
65
|
+
* `cause` is Enoki's answer; `retryable` is its.
|
|
66
|
+
*/
|
|
67
|
+
export class ExecutionUnconfirmed extends Schema.TaggedError<ExecutionUnconfirmed>()("ExecutionUnconfirmed", {
|
|
68
|
+
digest: Schema.String,
|
|
69
|
+
/** The sponsored `TransactionData` bytes that were signed. */
|
|
70
|
+
bytes: Schema.Uint8Array,
|
|
71
|
+
signature: Schema.Uint8Array,
|
|
72
|
+
message: Schema.String,
|
|
73
|
+
cause: EnokiError
|
|
74
|
+
}) {
|
|
75
|
+
get retryable(): boolean {
|
|
76
|
+
return this.cause.retryable
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** What Enoki is asked to sponsor, and the checks the transaction it returns must pass. */
|
|
81
|
+
export interface SponsorRequest {
|
|
82
|
+
readonly network?: EnokiNetwork
|
|
83
|
+
readonly sender: Address.Address
|
|
84
|
+
/**
|
|
85
|
+
* Identify a zkLogin sender by JWT instead of address (public API keys).
|
|
86
|
+
* `allowedAddresses` / `allowedMoveCallTargets` apply only to sender-based sponsorship.
|
|
87
|
+
*/
|
|
88
|
+
readonly jwt?: string
|
|
89
|
+
readonly allowedAddresses?: ReadonlyArray<string>
|
|
90
|
+
readonly allowedMoveCallTargets?: ReadonlyArray<string>
|
|
91
|
+
/**
|
|
92
|
+
* The gas owner Enoki must use. Default: the app's sponsor address for
|
|
93
|
+
* `network` from `getApp` (mainnet/testnet; an omitted network is Enoki's
|
|
94
|
+
* default, mainnet), when it lists one. Either way the gas owner must not be
|
|
95
|
+
* the sender, so the user never pays.
|
|
96
|
+
*/
|
|
97
|
+
readonly sponsorAddress?: Address.Address
|
|
98
|
+
/** Refuse sponsored transactions with a larger gas budget (MIST). */
|
|
99
|
+
readonly maxBudget?: bigint
|
|
100
|
+
/** Refuse sponsored transactions with a higher gas price (MIST per unit). */
|
|
101
|
+
readonly maxGasPrice?: bigint
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface SponsorOptions extends Omit<SponsorRequest, "sender"> {
|
|
105
|
+
/** Signs the sponsored transaction; its address is the sender unless `sender` is given. */
|
|
106
|
+
readonly signer: Signer.Signer
|
|
107
|
+
readonly sender?: Address.Address
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** A sponsored transaction Enoki created and `sponsor` checked: sign `bytes`, then `execute`. */
|
|
111
|
+
export interface SponsoredTransaction {
|
|
112
|
+
readonly digest: string
|
|
113
|
+
readonly bytes: Uint8Array
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface Sponsored {
|
|
117
|
+
readonly digest: string
|
|
118
|
+
/** The sponsored `TransactionData` bytes that were signed and executed. */
|
|
119
|
+
readonly bytes: Uint8Array
|
|
120
|
+
readonly signature: Uint8Array
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const unexpected = (reason: string) => new UnexpectedSponsoredTransaction({ reason })
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
interface Expected {
|
|
127
|
+
readonly kind: Uint8Array
|
|
128
|
+
readonly sender: Address.Address
|
|
129
|
+
readonly digest: string
|
|
130
|
+
readonly sponsor: Address.Address | undefined
|
|
131
|
+
readonly maxBudget: bigint | undefined
|
|
132
|
+
readonly maxGasPrice: bigint | undefined
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Never sign what we didn't ask for: the digest Enoki reports, same sender,
|
|
137
|
+
* same kind, and gas paid by the sponsor (never by the sender) within the caps.
|
|
138
|
+
*/
|
|
139
|
+
const check = (bytes: Uint8Array, expected: Expected) =>
|
|
140
|
+
Result.match(T.decode(bytes), {
|
|
141
|
+
onFailure: (e) => Effect.fail(unexpected(`undecodable transaction: ${e.message}`)),
|
|
142
|
+
onSuccess: (data) => {
|
|
143
|
+
const { gasData } = data
|
|
144
|
+
const digest = Hash.transactionDigest(bytes)
|
|
145
|
+
if (digest !== expected.digest) return Effect.fail(unexpected(`digest is ${digest}, Enoki reported ${expected.digest}`))
|
|
146
|
+
if (data.sender !== expected.sender) {
|
|
147
|
+
return Effect.fail(unexpected(`sender is ${data.sender}, expected ${expected.sender}`))
|
|
148
|
+
}
|
|
149
|
+
if (!Bytes.equal(encodeKind(data.kind), expected.kind)) return Effect.fail(unexpected("transaction kind was changed"))
|
|
150
|
+
if (gasData.owner === expected.sender) return Effect.fail(unexpected("gas would be paid by the sender"))
|
|
151
|
+
if (expected.sponsor !== undefined && gasData.owner !== expected.sponsor) {
|
|
152
|
+
return Effect.fail(unexpected(`gas owner is ${gasData.owner}, not the sponsor ${expected.sponsor}`))
|
|
153
|
+
}
|
|
154
|
+
if (expected.maxBudget !== undefined && gasData.budget > expected.maxBudget) {
|
|
155
|
+
return Effect.fail(unexpected(`gas budget ${gasData.budget} exceeds ${expected.maxBudget}`))
|
|
156
|
+
}
|
|
157
|
+
if (expected.maxGasPrice !== undefined && gasData.price > expected.maxGasPrice) {
|
|
158
|
+
return Effect.fail(unexpected(`gas price ${gasData.price} exceeds ${expected.maxGasPrice}`))
|
|
159
|
+
}
|
|
160
|
+
return Effect.void
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
/** The network Enoki sponsors on when the request names none (as `@mysten/enoki` assumes too). */
|
|
165
|
+
const DEFAULT_NETWORK = "mainnet"
|
|
166
|
+
|
|
167
|
+
/** The sponsor address to require: given, or the app's for this network (if it lists one). */
|
|
168
|
+
const sponsorFor = (enoki: EnokiClient["Service"], request: SponsorRequest) => {
|
|
169
|
+
if (request.sponsorAddress !== undefined) return Effect.succeed<Address.Address | undefined>(request.sponsorAddress)
|
|
170
|
+
const network = request.network ?? DEFAULT_NETWORK
|
|
171
|
+
if (network !== "mainnet" && network !== "testnet") return Effect.succeed<Address.Address | undefined>(undefined)
|
|
172
|
+
return Effect.flatMap(enoki.getApp, (app) => {
|
|
173
|
+
const listed = app.sponsorAddresses?.[network]
|
|
174
|
+
if (listed === undefined) return Effect.succeed(undefined)
|
|
175
|
+
return Result.match(Schema.decodeUnknownResult(Address.Strict)(listed), {
|
|
176
|
+
onFailure: () => Effect.fail(unexpected(`Enoki listed an invalid sponsor address ${listed}`)),
|
|
177
|
+
onSuccess: (a) => Effect.succeed<Address.Address | undefined>(a)
|
|
178
|
+
})
|
|
179
|
+
})
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Ask Enoki to sponsor a `TransactionKind` and check what comes back: the
|
|
184
|
+
* digest it reports, the sender, the kind, and gas paid by the sponsor within
|
|
185
|
+
* the caps. Answers bytes that are safe to sign.
|
|
186
|
+
*/
|
|
187
|
+
export const sponsor = Effect.fn("Sponsor.sponsor")(function*(kind: Uint8Array, request: SponsorRequest) {
|
|
188
|
+
const enoki = yield* EnokiClient
|
|
189
|
+
const network = request.network !== undefined ? { network: request.network } : {}
|
|
190
|
+
const [gasOwner, sponsored] = yield* Effect.all([sponsorFor(enoki, request), enoki.createSponsoredTransaction(
|
|
191
|
+
request.jwt !== undefined
|
|
192
|
+
? { ...network, transactionKindBytes: kind, jwt: request.jwt }
|
|
193
|
+
: {
|
|
194
|
+
...network,
|
|
195
|
+
transactionKindBytes: kind,
|
|
196
|
+
sender: request.sender,
|
|
197
|
+
...(request.allowedAddresses && { allowedAddresses: request.allowedAddresses }),
|
|
198
|
+
...(request.allowedMoveCallTargets && { allowedMoveCallTargets: request.allowedMoveCallTargets })
|
|
199
|
+
}
|
|
200
|
+
)], { concurrency: "unbounded" })
|
|
201
|
+
yield* check(sponsored.bytes, {
|
|
202
|
+
kind,
|
|
203
|
+
sender: request.sender,
|
|
204
|
+
digest: sponsored.digest,
|
|
205
|
+
sponsor: gasOwner,
|
|
206
|
+
maxBudget: request.maxBudget,
|
|
207
|
+
maxGasPrice: request.maxGasPrice
|
|
208
|
+
})
|
|
209
|
+
return { digest: sponsored.digest, bytes: sponsored.bytes } satisfies SponsoredTransaction
|
|
210
|
+
}) as (
|
|
211
|
+
kind: Uint8Array,
|
|
212
|
+
request: SponsorRequest
|
|
213
|
+
) => Effect.Effect<SponsoredTransaction, EnokiError | UnexpectedSponsoredTransaction, EnokiClient>
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Execute a signed sponsored transaction through Enoki. Posting the same
|
|
217
|
+
* signature again is safe: it is the same transaction. A failure is
|
|
218
|
+
* `ExecutionUnconfirmed` with everything needed to check or retry.
|
|
219
|
+
*/
|
|
220
|
+
export const execute = (signed: Sponsored): Effect.Effect<Sponsored, ExecutionUnconfirmed, EnokiClient> =>
|
|
221
|
+
Effect.flatMap(Effect.service(EnokiClient), (enoki) =>
|
|
222
|
+
enoki.executeSponsoredTransaction({ digest: signed.digest, signature: signed.signature }).pipe(
|
|
223
|
+
Effect.map(({ digest }) => ({ digest, bytes: signed.bytes, signature: signed.signature }) satisfies Sponsored),
|
|
224
|
+
Effect.mapError((cause) =>
|
|
225
|
+
new ExecutionUnconfirmed({
|
|
226
|
+
digest: signed.digest,
|
|
227
|
+
bytes: signed.bytes,
|
|
228
|
+
signature: signed.signature,
|
|
229
|
+
message: `executing sponsored transaction ${signed.digest} failed, it may still have executed: ${cause.message}`,
|
|
230
|
+
cause
|
|
231
|
+
})
|
|
232
|
+
)
|
|
233
|
+
)).pipe(Effect.withSpan("Sponsor.execute"))
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Sponsor a `TransactionKind`, check what comes back, sign it with the
|
|
237
|
+
* user's `Signer`, and execute it through Enoki.
|
|
238
|
+
*/
|
|
239
|
+
export const sponsorAndExecute = Effect.fn("Sponsor.sponsorAndExecute")(function*(kind: Uint8Array, options: SponsorOptions) {
|
|
240
|
+
const sponsored = yield* sponsor(kind, { ...options, sender: options.sender ?? options.signer.address })
|
|
241
|
+
const { signature } = yield* Signer.signTransaction(options.signer, sponsored.bytes)
|
|
242
|
+
return yield* execute({ digest: sponsored.digest, bytes: sponsored.bytes, signature })
|
|
243
|
+
}) as (
|
|
244
|
+
kind: Uint8Array,
|
|
245
|
+
options: SponsorOptions
|
|
246
|
+
) => Effect.Effect<
|
|
247
|
+
Sponsored,
|
|
248
|
+
EnokiError | UnexpectedSponsoredTransaction | Signer.SigningError | ExecutionUnconfirmed,
|
|
249
|
+
EnokiClient
|
|
250
|
+
>
|
|
251
|
+
|
|
252
|
+
/** Build a recipe, resolve its object inputs, and have Enoki sponsor and execute it. */
|
|
253
|
+
export const run = <A, E, R>(
|
|
254
|
+
recipe: Effect.Effect<A, E, R>,
|
|
255
|
+
options: SponsorOptions
|
|
256
|
+
): Effect.Effect<
|
|
257
|
+
Sponsored,
|
|
258
|
+
| E
|
|
259
|
+
| Objects.ObjectNotFound
|
|
260
|
+
| RpcError.RpcError
|
|
261
|
+
| Resolve.Incomplete
|
|
262
|
+
| Resolve.InvalidTransaction
|
|
263
|
+
| Resolve.InsufficientBalance
|
|
264
|
+
| Resolve.InvalidBalanceIntent
|
|
265
|
+
| Resolve.AllowanceError
|
|
266
|
+
| EnokiError
|
|
267
|
+
| UnexpectedSponsoredTransaction
|
|
268
|
+
| Signer.SigningError
|
|
269
|
+
| ExecutionUnconfirmed,
|
|
270
|
+
Exclude<R, Ptb.PtbBuilder> | Objects.Objects | Packages.Packages | Coins.Coins | EnokiClient
|
|
271
|
+
> =>
|
|
272
|
+
Ptb.build(recipe).pipe(
|
|
273
|
+
Effect.flatMap(({ draft }) => Resolve.inputs({ sender: options.sender ?? options.signer.address, draft })),
|
|
274
|
+
// Coin/balance intents are sourced from the sender's address balance or coins.
|
|
275
|
+
// The gas coin is the sponsor's, so sponsored recipes should use `useGasCoin: false`.
|
|
276
|
+
Effect.flatMap(Resolve.balances),
|
|
277
|
+
Effect.flatMap((plan) => transactionKind(plan.draft)),
|
|
278
|
+
Effect.flatMap((kind) => sponsorAndExecute(kind, options)),
|
|
279
|
+
Effect.withSpan("Sponsor.run")
|
|
280
|
+
)
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signing in with zkLogin through Enoki, as two Effects around the OAuth
|
|
3
|
+
* redirect your app performs:
|
|
4
|
+
*
|
|
5
|
+
* const session = yield* ZkLoginFlow.start({ ephemeral, network: "testnet" })
|
|
6
|
+
* // redirect to ZkLoginFlow.authorizationUrl({ provider: "google", clientId, redirectUrl, nonce: session.nonce })
|
|
7
|
+
* // ... the provider redirects back with an id_token (JWT)
|
|
8
|
+
* const { signer } = yield* ZkLoginFlow.complete(session, jwt)
|
|
9
|
+
* yield* Tx.run(recipe, { signer }) // or Sponsor.run(recipe, { signer, jwt })
|
|
10
|
+
*
|
|
11
|
+
* Across the redirect, persist the session's data (`SessionData`, a Schema:
|
|
12
|
+
* encode it to JSON) and the ephemeral key, then pass both back:
|
|
13
|
+
* `complete({ ...yield* Schema.decodeUnknownEffect(SessionData)(saved), ephemeral }, jwt)`.
|
|
14
|
+
*/
|
|
15
|
+
import * as Address from "../Address.ts"
|
|
16
|
+
import * as Signer from "../Signer.ts"
|
|
17
|
+
import type { InvalidJwt } from "../zklogin/Errors.ts"
|
|
18
|
+
import * as Jwt from "../zklogin/Jwt.ts"
|
|
19
|
+
import * as Nonce from "../zklogin/Nonce.ts"
|
|
20
|
+
import * as PublicIdentifier from "../zklogin/PublicIdentifier.ts"
|
|
21
|
+
import * as ZkLogin from "../zklogin/ZkLogin.ts"
|
|
22
|
+
import * as Effect from "effect/Effect"
|
|
23
|
+
import * as Schema from "effect/Schema"
|
|
24
|
+
import { EnokiClient, type EnokiError, EnokiNetwork, Epoch, type ZkLoginZkp } from "./EnokiClient.ts"
|
|
25
|
+
|
|
26
|
+
/** What to persist across the OAuth redirect (with the ephemeral key, which is the app's to store). */
|
|
27
|
+
export const SessionData = Schema.Struct({
|
|
28
|
+
network: Schema.optionalKey(EnokiNetwork),
|
|
29
|
+
nonce: Schema.String,
|
|
30
|
+
randomness: Schema.String,
|
|
31
|
+
/** A u64; encoded as a decimal string. */
|
|
32
|
+
maxEpoch: Epoch,
|
|
33
|
+
/** Milliseconds since the epoch after which the proof stops working. */
|
|
34
|
+
estimatedExpiration: Schema.Number
|
|
35
|
+
})
|
|
36
|
+
export type SessionData = typeof SessionData.Type
|
|
37
|
+
|
|
38
|
+
/** A login in progress: its data and the ephemeral signer the nonce commits to. */
|
|
39
|
+
export interface Session extends SessionData {
|
|
40
|
+
readonly ephemeral: Signer.Signer
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The JWT's `nonce` claim is not this session's nonce (a stale token, or one from another login). */
|
|
44
|
+
export class JwtNonceMismatch extends Schema.TaggedError<JwtNonceMismatch>()("JwtNonceMismatch", {
|
|
45
|
+
expected: Schema.String,
|
|
46
|
+
received: Schema.optionalKey(Schema.String)
|
|
47
|
+
}) {
|
|
48
|
+
override get message() {
|
|
49
|
+
return this.received === undefined
|
|
50
|
+
? `the JWT has no nonce claim (expected ${this.expected})`
|
|
51
|
+
: `the JWT's nonce ${this.received} is not this session's nonce ${this.expected}`
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Enoki's nonce does not commit to our ephemeral key, `maxEpoch` and randomness. */
|
|
56
|
+
export class InvalidEnokiNonce extends Schema.TaggedError<InvalidEnokiNonce>()("InvalidEnokiNonce", {
|
|
57
|
+
reason: Schema.String
|
|
58
|
+
}) {
|
|
59
|
+
override get message(): string {
|
|
60
|
+
return `invalid Enoki nonce: ${this.reason}`
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Ask Enoki for a nonce committing to the ephemeral key. The nonce is
|
|
66
|
+
* recomputed locally from the returned `maxEpoch` and randomness; a nonce
|
|
67
|
+
* that doesn't match is refused (it would bind the login to someone else's key).
|
|
68
|
+
*/
|
|
69
|
+
export const start = (options: {
|
|
70
|
+
readonly ephemeral: Signer.Signer
|
|
71
|
+
readonly network?: EnokiNetwork
|
|
72
|
+
readonly additionalEpochs?: number
|
|
73
|
+
}): Effect.Effect<Session, EnokiError | InvalidEnokiNonce, EnokiClient> =>
|
|
74
|
+
Effect.gen(function*() {
|
|
75
|
+
const enoki = yield* EnokiClient
|
|
76
|
+
const n = yield* enoki.createZkLoginNonce({
|
|
77
|
+
ephemeralPublicKey: options.ephemeral.publicKey,
|
|
78
|
+
...(options.network !== undefined && { network: options.network }),
|
|
79
|
+
...(options.additionalEpochs !== undefined && { additionalEpochs: options.additionalEpochs })
|
|
80
|
+
})
|
|
81
|
+
const expected = yield* Nonce.generate(options.ephemeral.publicKey, n.maxEpoch, n.randomness).pipe(
|
|
82
|
+
Effect.mapError((e) => new InvalidEnokiNonce({ reason: e.reason }))
|
|
83
|
+
)
|
|
84
|
+
if (expected !== n.nonce) {
|
|
85
|
+
return yield* new InvalidEnokiNonce({ reason: `Enoki returned nonce ${n.nonce}, expected ${expected}` })
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
ephemeral: options.ephemeral,
|
|
89
|
+
...(options.network !== undefined && { network: options.network }),
|
|
90
|
+
nonce: n.nonce,
|
|
91
|
+
randomness: n.randomness,
|
|
92
|
+
maxEpoch: n.maxEpoch,
|
|
93
|
+
estimatedExpiration: n.estimatedExpiration
|
|
94
|
+
} satisfies Session
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
export interface Completed {
|
|
98
|
+
readonly signer: Signer.Signer
|
|
99
|
+
readonly address: Address.Address
|
|
100
|
+
readonly salt: string
|
|
101
|
+
readonly proof: ZkLoginZkp
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* With the JWT from the OAuth redirect: check that it carries this session's
|
|
106
|
+
* nonce (locally, before spending a prover call), look up the user's address
|
|
107
|
+
* and salt, get the ZK proof, and build the zkLogin `Signer`. Legacy accounts
|
|
108
|
+
* are detected by matching the proof against the address Enoki reports.
|
|
109
|
+
*/
|
|
110
|
+
export const complete = (
|
|
111
|
+
session: Session,
|
|
112
|
+
jwt: string
|
|
113
|
+
): Effect.Effect<Completed, EnokiError | Signer.InvalidKey | InvalidJwt | JwtNonceMismatch, EnokiClient> =>
|
|
114
|
+
Effect.gen(function*() {
|
|
115
|
+
const claims = yield* Jwt.decode(jwt)
|
|
116
|
+
if (claims.nonce !== session.nonce) {
|
|
117
|
+
return yield* new JwtNonceMismatch({ expected: session.nonce, ...(claims.nonce !== undefined && { received: claims.nonce }) })
|
|
118
|
+
}
|
|
119
|
+
const enoki = yield* EnokiClient
|
|
120
|
+
const [account, proof] = yield* Effect.all([
|
|
121
|
+
enoki.getZkLogin({ jwt }),
|
|
122
|
+
enoki.createZkLoginZkp({
|
|
123
|
+
jwt,
|
|
124
|
+
ephemeralPublicKey: session.ephemeral.publicKey,
|
|
125
|
+
randomness: session.randomness,
|
|
126
|
+
maxEpoch: session.maxEpoch,
|
|
127
|
+
...(session.network !== undefined && { network: session.network })
|
|
128
|
+
})
|
|
129
|
+
], { concurrency: "unbounded" })
|
|
130
|
+
// The signer derives the address from the proof; pick the derivation that matches Enoki's.
|
|
131
|
+
const current = yield* ZkLogin.signer({ ephemeral: session.ephemeral, inputs: proof, maxEpoch: session.maxEpoch })
|
|
132
|
+
const expected = yield* Effect.try({
|
|
133
|
+
try: () => Address.normalize(account.address),
|
|
134
|
+
catch: () => new Signer.InvalidKey({ scheme: "ZkLogin", reason: `Enoki returned an invalid address ${account.address}` })
|
|
135
|
+
})
|
|
136
|
+
const legacyAddress = current.address !== expected &&
|
|
137
|
+
PublicIdentifier.toAddress(current.publicKey.bytes, { legacyAddress: true }) === expected
|
|
138
|
+
const signer = yield* ZkLogin.signer({
|
|
139
|
+
ephemeral: session.ephemeral,
|
|
140
|
+
inputs: proof,
|
|
141
|
+
maxEpoch: session.maxEpoch,
|
|
142
|
+
legacyAddress,
|
|
143
|
+
address: expected
|
|
144
|
+
})
|
|
145
|
+
return { signer, address: signer.address, salt: account.salt, proof }
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
export type AuthProvider = "google" | "facebook" | "twitch"
|
|
149
|
+
|
|
150
|
+
/** The OAuth URL to send the user to (implicit flow, `id_token`), as `@mysten/enoki`'s `EnokiFlow` builds it. */
|
|
151
|
+
export const authorizationUrl = (options: {
|
|
152
|
+
readonly provider: AuthProvider
|
|
153
|
+
readonly clientId: string
|
|
154
|
+
readonly redirectUrl: string
|
|
155
|
+
readonly nonce: string
|
|
156
|
+
readonly extraParams?: Readonly<Record<string, string>>
|
|
157
|
+
}): string => {
|
|
158
|
+
const { scope, ...extra } = options.extraParams ?? {}
|
|
159
|
+
const params = new URLSearchParams({
|
|
160
|
+
...extra,
|
|
161
|
+
nonce: options.nonce,
|
|
162
|
+
client_id: options.clientId,
|
|
163
|
+
redirect_uri: options.redirectUrl,
|
|
164
|
+
response_type: "id_token",
|
|
165
|
+
scope: ["openid", ...(scope ? [scope] : [])].join(" ")
|
|
166
|
+
})
|
|
167
|
+
switch (options.provider) {
|
|
168
|
+
case "google":
|
|
169
|
+
return `https://accounts.google.com/o/oauth2/v2/auth?${params}`
|
|
170
|
+
case "facebook":
|
|
171
|
+
return `https://www.facebook.com/v17.0/dialog/oauth?${params}`
|
|
172
|
+
case "twitch":
|
|
173
|
+
params.set("force_verify", "true")
|
|
174
|
+
return `https://id.twitch.tv/oauth2/authorize?${params}`
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enoki for `@unconfirmed/effect-sui`. Prefer the subpath namespaces
|
|
3
|
+
* (`@unconfirmed/effect-sui/enoki/EnokiClient`, `.../Sponsor`, ...); this barrel is for convenience.
|
|
4
|
+
*/
|
|
5
|
+
export * from "./EnokiClient.ts"
|
|
6
|
+
export * as EnokiHttp from "./EnokiHttp.ts"
|
|
7
|
+
export * as Sponsor from "./Sponsor.ts"
|
|
8
|
+
export * as ZkLoginFlow from "./ZkLoginFlow.ts"
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect"
|
|
2
|
+
import * as Exit from "effect/Exit"
|
|
3
|
+
import * as GraphQL from "effect/graphql/GraphQL"
|
|
4
|
+
import * as GraphQLClient from "effect/graphql/GraphQLClient"
|
|
5
|
+
import * as GraphQLGroup from "effect/graphql/GraphQLGroup"
|
|
6
|
+
import type * as GraphQLProtocol from "effect/graphql/GraphQLProtocol"
|
|
7
|
+
import * as Layer from "effect/Layer"
|
|
8
|
+
import * as Schema from "effect/Schema"
|
|
9
|
+
import * as Chain from "../Chain.ts"
|
|
10
|
+
import { RpcError } from "../RpcError.ts"
|
|
11
|
+
import type { ObjectDigest } from "../TransactionData.ts"
|
|
12
|
+
import { call, U64 } from "./convert.ts"
|
|
13
|
+
|
|
14
|
+
/** Chain info and the reference gas price in one request (they read the same `epoch`). */
|
|
15
|
+
export const ChainInfo = GraphQL.query("ChainInfo", {
|
|
16
|
+
document: "query ChainInfo{chainIdentifier epoch{epochId referenceGasPrice} checkpoint{sequenceNumber}}",
|
|
17
|
+
result: Schema.Struct({
|
|
18
|
+
chainIdentifier: Schema.String,
|
|
19
|
+
epoch: Schema.NullOr(Schema.Struct({
|
|
20
|
+
epochId: U64,
|
|
21
|
+
referenceGasPrice: Schema.optionalKey(Schema.NullOr(U64))
|
|
22
|
+
})),
|
|
23
|
+
checkpoint: Schema.NullOr(Schema.Struct({ sequenceNumber: U64 }))
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
export const group = GraphQLGroup.make(ChainInfo)
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* GraphQL has no chain name, so it is read from the chain id like the gRPC
|
|
31
|
+
* service reports it: `mainnet`, `testnet`, otherwise `unknown` (devnet's
|
|
32
|
+
* genesis changes on every reset; gRPC also reports `unknown` there).
|
|
33
|
+
*/
|
|
34
|
+
const CHAINS: Record<string, string> = {
|
|
35
|
+
"4btiuiMPvEENsttpZC7CZ53DruC3MAgfznDbASZ7DR6S": "mainnet",
|
|
36
|
+
"69WiPg3DAQiwdxfncX6wYQ2siKwAe6L9BZthQea3JNMD": "testnet"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** A null the indexer answers where a value must exist is the service not ready, never a default. */
|
|
40
|
+
const unavailable = (what: string) =>
|
|
41
|
+
new RpcError({ method: "ChainInfo", code: "UNAVAILABLE", message: `the indexer reports no ${what}` })
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* `Chain` over GraphQL. One `ChainInfo` query feeds both members: chain info is
|
|
45
|
+
* cached for 30 seconds, the gas price for a minute; failures are not cached.
|
|
46
|
+
* An indexer that answers null for the current epoch, the latest checkpoint or
|
|
47
|
+
* the gas price fails with UNAVAILABLE instead of inventing a value.
|
|
48
|
+
*/
|
|
49
|
+
export const layer: Layer.Layer<Chain.Chain, never, GraphQLProtocol.GraphQLProtocol> = Layer.effect(
|
|
50
|
+
Chain.Chain,
|
|
51
|
+
Effect.gen(function*() {
|
|
52
|
+
const client = yield* GraphQLClient.make(group)
|
|
53
|
+
const fetch = yield* client.ChainInfo().pipe(
|
|
54
|
+
call,
|
|
55
|
+
Effect.cachedWithTTL((exit) => (Exit.isSuccess(exit) ? "30 seconds" : 0))
|
|
56
|
+
)
|
|
57
|
+
const info = Effect.flatMap(fetch, (r): Effect.Effect<Chain.ChainInfo, RpcError> => {
|
|
58
|
+
if (r.epoch === null) return Effect.fail(unavailable("current epoch"))
|
|
59
|
+
if (r.checkpoint === null) return Effect.fail(unavailable("latest checkpoint"))
|
|
60
|
+
return Effect.succeed({
|
|
61
|
+
chainId: r.chainIdentifier as ObjectDigest,
|
|
62
|
+
chain: CHAINS[r.chainIdentifier] ?? "unknown",
|
|
63
|
+
epoch: r.epoch.epochId,
|
|
64
|
+
checkpointHeight: r.checkpoint.sequenceNumber
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
const referenceGasPrice = yield* fetch.pipe(
|
|
68
|
+
Effect.flatMap((r) => {
|
|
69
|
+
const price = r.epoch?.referenceGasPrice
|
|
70
|
+
return price === undefined || price === null ? Effect.fail(unavailable("reference gas price")) : Effect.succeed(price)
|
|
71
|
+
}),
|
|
72
|
+
Effect.cachedWithTTL((exit) => (Exit.isSuccess(exit) ? "1 minute" : 0))
|
|
73
|
+
)
|
|
74
|
+
return Chain.Chain.of({ info, referenceGasPrice })
|
|
75
|
+
})
|
|
76
|
+
)
|