@unconfirmed/effect-sui 0.0.0-stage → 0.1.1
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/Connection.d.ts +119 -0
- package/dist/wallet/Connection.d.ts.map +1 -0
- package/dist/wallet/Connection.js +197 -0
- package/dist/wallet/Connection.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 +7 -0
- package/dist/wallet/index.d.ts.map +1 -0
- package/dist/wallet/index.js +7 -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/Connection.ts +323 -0
- package/src/wallet/Features.ts +114 -0
- package/src/wallet/Wallet.ts +550 -0
- package/src/wallet/index.ts +6 -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/src/TypeTag.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Move type tags: the BCS schema plus the `0x2::coin::Coin<0x2::sui::SUI>` string form.
|
|
3
|
+
*/
|
|
4
|
+
import * as Bcs from "@unconfirmed/effect-bcs/Bcs"
|
|
5
|
+
import { type Address, normalize } from "./Address.ts"
|
|
6
|
+
|
|
7
|
+
export interface StructTag {
|
|
8
|
+
readonly address: Address
|
|
9
|
+
readonly module: string
|
|
10
|
+
readonly name: string
|
|
11
|
+
readonly typeParams: ReadonlyArray<TypeTag>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type TypeTag =
|
|
15
|
+
| { readonly _tag: "bool" | "u8" | "u16" | "u32" | "u64" | "u128" | "u256" | "address" | "signer" }
|
|
16
|
+
| { readonly _tag: "vector"; readonly value: TypeTag }
|
|
17
|
+
| ({ readonly _tag: "struct" } & StructTag)
|
|
18
|
+
|
|
19
|
+
export const StructTag: Bcs.BcsSchema<StructTag, any> = /* @__PURE__ */ Bcs.struct({
|
|
20
|
+
address: Bcs.Address,
|
|
21
|
+
module: Bcs.string,
|
|
22
|
+
name: Bcs.string,
|
|
23
|
+
typeParams: Bcs.vector(Bcs.lazy((): Bcs.BcsSchema<TypeTag, any> => TypeTag))
|
|
24
|
+
}) as any
|
|
25
|
+
|
|
26
|
+
/** Variant order is Rust's `TypeTag` (u16/u32/u256 were appended later). */
|
|
27
|
+
export const TypeTag: Bcs.BcsSchema<TypeTag, any> = /* @__PURE__ */ Bcs.enum({
|
|
28
|
+
bool: null,
|
|
29
|
+
u8: null,
|
|
30
|
+
u64: null,
|
|
31
|
+
u128: null,
|
|
32
|
+
address: null,
|
|
33
|
+
signer: null,
|
|
34
|
+
vector: Bcs.lazy((): Bcs.BcsSchema<TypeTag, any> => TypeTag),
|
|
35
|
+
struct: StructTag as any,
|
|
36
|
+
u16: null,
|
|
37
|
+
u32: null,
|
|
38
|
+
u256: null
|
|
39
|
+
}) as any
|
|
40
|
+
|
|
41
|
+
const PRIMITIVES = /* @__PURE__ */ new Set(["bool", "u8", "u16", "u32", "u64", "u128", "u256", "address", "signer"])
|
|
42
|
+
|
|
43
|
+
/** Parse `vector<0x2::coin::Coin<0x2::sui::SUI>>`. Throws on malformed input. */
|
|
44
|
+
export const parse = (input: string): TypeTag => {
|
|
45
|
+
const s = input.replace(/\s+/g, "")
|
|
46
|
+
let i = 0
|
|
47
|
+
const expect = (c: string) => {
|
|
48
|
+
if (s.slice(i, i + c.length) !== c) throw new Error(`invalid type tag "${input}": expected "${c}" at ${i}`)
|
|
49
|
+
i += c.length
|
|
50
|
+
}
|
|
51
|
+
const ident = () => {
|
|
52
|
+
const m = /^[A-Za-z0-9_]+/.exec(s.slice(i))
|
|
53
|
+
if (!m) throw new Error(`invalid type tag "${input}" at ${i}`)
|
|
54
|
+
i += m[0].length
|
|
55
|
+
return m[0]
|
|
56
|
+
}
|
|
57
|
+
const tag = (): TypeTag => {
|
|
58
|
+
const head = ident()
|
|
59
|
+
if (PRIMITIVES.has(head)) return { _tag: head as "bool" }
|
|
60
|
+
if (head === "vector") {
|
|
61
|
+
expect("<")
|
|
62
|
+
const value = tag()
|
|
63
|
+
expect(">")
|
|
64
|
+
return { _tag: "vector", value }
|
|
65
|
+
}
|
|
66
|
+
expect("::")
|
|
67
|
+
const module = ident()
|
|
68
|
+
expect("::")
|
|
69
|
+
const name = ident()
|
|
70
|
+
const typeParams: Array<TypeTag> = []
|
|
71
|
+
if (s[i] === "<") {
|
|
72
|
+
i++
|
|
73
|
+
do typeParams.push(tag())
|
|
74
|
+
while (s[i] === "," && ++i)
|
|
75
|
+
expect(">")
|
|
76
|
+
}
|
|
77
|
+
return { _tag: "struct", address: normalize(head), module, name, typeParams }
|
|
78
|
+
}
|
|
79
|
+
const result = tag()
|
|
80
|
+
if (i !== s.length) throw new Error(`invalid type tag "${input}": trailing input at ${i}`)
|
|
81
|
+
return result
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const format = (t: TypeTag): string =>
|
|
85
|
+
t._tag === "vector"
|
|
86
|
+
? `vector<${format(t.value)}>`
|
|
87
|
+
: t._tag === "struct"
|
|
88
|
+
? `${t.address}::${t.module}::${t.name}${t.typeParams.length ? `<${t.typeParams.map(format).join(", ")}>` : ""}`
|
|
89
|
+
: t._tag
|
|
90
|
+
|
|
91
|
+
/** Canonical string form (fully padded addresses). */
|
|
92
|
+
export const normalizeString = (s: string) => format(parse(s))
|
|
93
|
+
|
|
94
|
+
/** `0x2::sui::SUI`, padded. */
|
|
95
|
+
export const SUI = /* @__PURE__ */ normalizeString("0x2::sui::SUI")
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Pad the addresses of a type or a type prefix used as a filter,
|
|
99
|
+
* `0xaddr[::module[::Name[<T>]]]` (nodes reject `0x2`). Input that doesn't
|
|
100
|
+
* parse is returned as is.
|
|
101
|
+
*/
|
|
102
|
+
export const normalizePath = (path: string): string => {
|
|
103
|
+
try {
|
|
104
|
+
if (path.includes("<") || path.split("::").length === 3) return normalizeString(path)
|
|
105
|
+
const [address, ...rest] = path.split("::")
|
|
106
|
+
return [normalize(address!), ...rest].join("::")
|
|
107
|
+
} catch {
|
|
108
|
+
return path
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Does `type` match a filter path at its level of specificity: `0xaddr`,
|
|
114
|
+
* `0xaddr::module`, `0xaddr::module::Name` (any instantiation), an exact
|
|
115
|
+
* instantiation, or an exact non-struct type.
|
|
116
|
+
*/
|
|
117
|
+
export const matchesPath = (path: string, type: string): boolean => {
|
|
118
|
+
const p = normalizePath(path)
|
|
119
|
+
const t = normalizePath(type)
|
|
120
|
+
if (p.includes("<") || !p.startsWith("0x")) return p === t
|
|
121
|
+
const segments = p.split("::").length
|
|
122
|
+
return segments === 3 ? t === p || t.startsWith(p + "<") : t.startsWith(p + "::")
|
|
123
|
+
}
|
package/src/Verify.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signature verification over whatever schemes are installed.
|
|
3
|
+
*
|
|
4
|
+
* Fails with `InvalidSignature` (wrong signature or signer),
|
|
5
|
+
* `UnsupportedScheme` (scheme not installed) or `VerificationUnavailable`
|
|
6
|
+
* (a service the scheme needs failed: no verdict, retry if `retryable`).
|
|
7
|
+
*/
|
|
8
|
+
import * as Effect from "effect/Effect"
|
|
9
|
+
import type { Address } from "./Address.ts"
|
|
10
|
+
import * as Hash from "./Hash.ts"
|
|
11
|
+
import { addressOf, InvalidSignature, type PublicKey, SignatureSchemes, type VerifyError } from "./SignatureScheme.ts"
|
|
12
|
+
|
|
13
|
+
export interface Verified {
|
|
14
|
+
readonly publicKey: PublicKey
|
|
15
|
+
readonly address: Address
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Verify a serialized signature over an intent message; answer who signed. */
|
|
19
|
+
export const signature = /* @__PURE__ */ Effect.fn("Verify.signature")(function*(serialized: Uint8Array, intentMessage: Uint8Array) {
|
|
20
|
+
const registry = yield* SignatureSchemes
|
|
21
|
+
if (serialized.length === 0) return yield* new InvalidSignature({ scheme: "unknown", reason: "empty signature" })
|
|
22
|
+
const scheme = yield* registry.get(serialized[0]!)
|
|
23
|
+
const publicKey = yield* scheme.verify(serialized.subarray(1), intentMessage, registry)
|
|
24
|
+
return { publicKey, address: yield* addressOf(publicKey) } satisfies Verified
|
|
25
|
+
}) as (serialized: Uint8Array, intentMessage: Uint8Array) => Effect.Effect<Verified, VerifyError, SignatureSchemes>
|
|
26
|
+
|
|
27
|
+
/** Accept `expected` when it is the key's address or, for schemes with several, any of its `addresses`. */
|
|
28
|
+
const expecting = (expected: Address | undefined) => (v: Verified) => {
|
|
29
|
+
if (expected === undefined || v.address === expected) return Effect.succeed(v)
|
|
30
|
+
const mismatch = new InvalidSignature({ scheme: "any", reason: `signed by ${v.address}, expected ${expected}` })
|
|
31
|
+
return Effect.flatMap(Effect.service(SignatureSchemes), (r) => r.get(v.publicKey.flag)).pipe(
|
|
32
|
+
Effect.flatMap((s) =>
|
|
33
|
+
s.addresses?.(v.publicKey.bytes).includes(expected) ? Effect.succeed({ ...v, address: expected }) : Effect.fail(mismatch)
|
|
34
|
+
)
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const personalMessage = (message: Uint8Array, serialized: Uint8Array, options?: { readonly address?: Address }) =>
|
|
39
|
+
Effect.flatMap(signature(serialized, Hash.personalMessageIntent(message)), expecting(options?.address))
|
|
40
|
+
|
|
41
|
+
export const transaction = (txBytes: Uint8Array, serialized: Uint8Array, options?: { readonly address?: Address }) =>
|
|
42
|
+
Effect.flatMap(signature(serialized, Hash.transactionIntent(txBytes)), expecting(options?.address))
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Enoki API as a service: zkLogin (salt/address lookup, nonces, ZK
|
|
3
|
+
* proofs), sponsored transactions and app metadata. Requests and responses
|
|
4
|
+
* are Schema-validated; every failure is a typed `EnokiError`.
|
|
5
|
+
*
|
|
6
|
+
* EnokiHttp.layer({ apiKey }).pipe(Layer.provide(FetchHttpClient.layer))
|
|
7
|
+
*/
|
|
8
|
+
import type * as SignatureScheme from "../SignatureScheme.ts"
|
|
9
|
+
import * as Signature from "../zklogin/Signature.ts"
|
|
10
|
+
import * as Context from "effect/Context"
|
|
11
|
+
import type * as Effect from "effect/Effect"
|
|
12
|
+
import * as Schema from "effect/Schema"
|
|
13
|
+
import * as SchemaGetter from "effect/SchemaGetter"
|
|
14
|
+
|
|
15
|
+
// -----------------------------------------------------------------------------
|
|
16
|
+
// Errors
|
|
17
|
+
// -----------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
/** One entry of Enoki's `errors`; fields are kept only when well-formed. */
|
|
20
|
+
export const EnokiErrorDetail = Schema.Struct({
|
|
21
|
+
code: Schema.optionalKey(Schema.String),
|
|
22
|
+
message: Schema.optionalKey(Schema.String),
|
|
23
|
+
data: Schema.optionalKey(Schema.Unknown)
|
|
24
|
+
})
|
|
25
|
+
export type EnokiErrorDetail = typeof EnokiErrorDetail.Type
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A failed Enoki call. `status` is the HTTP status (0 when no response
|
|
29
|
+
* arrived). `code` is Enoki's first error code, or one of ours:
|
|
30
|
+
* `request_failed` (transport), `invalid_response` (body didn't decode),
|
|
31
|
+
* `unknown_error` (an error body without codes). `cause` is the underlying
|
|
32
|
+
* transport or decode failure, when there is one.
|
|
33
|
+
*/
|
|
34
|
+
export class EnokiError extends Schema.TaggedError<EnokiError>()("EnokiError", {
|
|
35
|
+
status: Schema.Number,
|
|
36
|
+
code: Schema.String,
|
|
37
|
+
message: Schema.String,
|
|
38
|
+
errors: Schema.Array(EnokiErrorDetail),
|
|
39
|
+
cause: Schema.optionalKey(Schema.Defect())
|
|
40
|
+
}) {
|
|
41
|
+
/** Worth retrying as is: no response arrived (status 0), rate limited (429), or a server error (5xx). */
|
|
42
|
+
get retryable(): boolean {
|
|
43
|
+
return this.status === 0 || this.status === 429 || this.status >= 500
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The transaction must be rebuilt and signed again: Enoki's sponsor address
|
|
48
|
+
* or the reference gas price changed since it was built.
|
|
49
|
+
*/
|
|
50
|
+
get requiresRebuild(): boolean {
|
|
51
|
+
return this.code === "invalid_gas_owner" || this.code === "invalid_gas_price"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// -----------------------------------------------------------------------------
|
|
56
|
+
// Inputs
|
|
57
|
+
// -----------------------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
export const EnokiNetwork = Schema.Literals(["mainnet", "testnet", "devnet"])
|
|
60
|
+
export type EnokiNetwork = typeof EnokiNetwork.Type
|
|
61
|
+
export const EnokiDomainNetwork = Schema.Literals(["mainnet", "testnet"])
|
|
62
|
+
export type EnokiDomainNetwork = typeof EnokiDomainNetwork.Type
|
|
63
|
+
|
|
64
|
+
export interface CreateZkLoginNonceInput {
|
|
65
|
+
readonly network?: EnokiNetwork
|
|
66
|
+
readonly ephemeralPublicKey: SignatureScheme.PublicKey
|
|
67
|
+
readonly additionalEpochs?: number
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface CreateZkLoginZkpInput {
|
|
71
|
+
readonly network?: EnokiNetwork
|
|
72
|
+
readonly jwt: string
|
|
73
|
+
readonly ephemeralPublicKey: SignatureScheme.PublicKey
|
|
74
|
+
readonly randomness: string
|
|
75
|
+
/** A u64; sent to Enoki as a JSON number. */
|
|
76
|
+
readonly maxEpoch: bigint
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
interface SponsorBase {
|
|
80
|
+
readonly network?: EnokiNetwork
|
|
81
|
+
/** BCS `TransactionKind`. */
|
|
82
|
+
readonly transactionKindBytes: Uint8Array
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Sponsor for a zkLogin user identified by their JWT (public API key), or for an explicit sender (private key). */
|
|
86
|
+
export type CreateSponsoredTransactionInput =
|
|
87
|
+
| SponsorBase & { readonly jwt: string }
|
|
88
|
+
| SponsorBase & {
|
|
89
|
+
readonly sender: string
|
|
90
|
+
readonly allowedAddresses?: ReadonlyArray<string>
|
|
91
|
+
readonly allowedMoveCallTargets?: ReadonlyArray<string>
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface ExecuteSponsoredTransactionInput {
|
|
95
|
+
readonly digest: string
|
|
96
|
+
/** The sender's serialized signature over the sponsored bytes. */
|
|
97
|
+
readonly signature: Uint8Array
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface SponsorAndExecuteTransactionInput {
|
|
101
|
+
readonly network?: EnokiNetwork
|
|
102
|
+
/** BCS `TransactionData` built with Enoki's sponsor as gas owner and an empty gas payment. */
|
|
103
|
+
readonly transactionBytes: Uint8Array
|
|
104
|
+
readonly signature: Uint8Array
|
|
105
|
+
readonly allowedAddresses?: ReadonlyArray<string>
|
|
106
|
+
readonly allowedMoveCallTargets?: ReadonlyArray<string>
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// -----------------------------------------------------------------------------
|
|
110
|
+
// Responses (the `data` field of Enoki's `{ data }` envelope)
|
|
111
|
+
// -----------------------------------------------------------------------------
|
|
112
|
+
|
|
113
|
+
export const AuthProvider = Schema.String
|
|
114
|
+
export const App = Schema.Struct({
|
|
115
|
+
allowedOrigins: Schema.Array(Schema.String),
|
|
116
|
+
authenticationProviders: Schema.Array(Schema.Struct({ providerType: AuthProvider, clientId: Schema.String })),
|
|
117
|
+
domains: Schema.Array(Schema.Struct({ nftId: Schema.String, name: Schema.String, network: EnokiDomainNetwork })),
|
|
118
|
+
/** Enoki's sponsor address per network it sponsors on. */
|
|
119
|
+
sponsorAddresses: Schema.optionalKey(Schema.Struct({
|
|
120
|
+
mainnet: Schema.optionalKey(Schema.String),
|
|
121
|
+
testnet: Schema.optionalKey(Schema.String)
|
|
122
|
+
}))
|
|
123
|
+
})
|
|
124
|
+
export type App = typeof App.Type
|
|
125
|
+
|
|
126
|
+
export const ZkLoginAccount = Schema.Struct({
|
|
127
|
+
address: Schema.String,
|
|
128
|
+
publicKey: Schema.String,
|
|
129
|
+
salt: Schema.String
|
|
130
|
+
})
|
|
131
|
+
export type ZkLoginAccount = typeof ZkLoginAccount.Type
|
|
132
|
+
|
|
133
|
+
export const ZkLoginAddresses = Schema.Struct({
|
|
134
|
+
addresses: Schema.Array(Schema.Struct({
|
|
135
|
+
clientId: Schema.String,
|
|
136
|
+
salt: Schema.String,
|
|
137
|
+
address: Schema.String,
|
|
138
|
+
publicKey: Schema.String,
|
|
139
|
+
legacy: Schema.optionalKey(Schema.Boolean)
|
|
140
|
+
}))
|
|
141
|
+
})
|
|
142
|
+
export type ZkLoginAddresses = typeof ZkLoginAddresses.Type
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* An epoch (a u64 on chain) as a `bigint`. Decodes Enoki's JSON number or a decimal string; encodes to a
|
|
146
|
+
* decimal string, so a persisted `SessionData` survives `JSON.stringify`.
|
|
147
|
+
*/
|
|
148
|
+
export const Epoch = Schema.Union([
|
|
149
|
+
Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
150
|
+
Schema.String.check(Schema.isPattern(/^(0|[1-9][0-9]*)$/))
|
|
151
|
+
]).pipe(
|
|
152
|
+
Schema.decodeTo(Schema.BigInt, {
|
|
153
|
+
decode: SchemaGetter.BigInt(),
|
|
154
|
+
encode: SchemaGetter.transform((b: bigint) => b.toString())
|
|
155
|
+
})
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
export const ZkLoginNonce = Schema.Struct({
|
|
159
|
+
nonce: Schema.String,
|
|
160
|
+
randomness: Schema.String,
|
|
161
|
+
epoch: Epoch,
|
|
162
|
+
maxEpoch: Epoch,
|
|
163
|
+
/** Milliseconds since the epoch. */
|
|
164
|
+
estimatedExpiration: Schema.Number
|
|
165
|
+
})
|
|
166
|
+
export type ZkLoginNonce = typeof ZkLoginNonce.Type
|
|
167
|
+
|
|
168
|
+
/** The proof is exactly zkLogin's signature inputs. */
|
|
169
|
+
export const ZkLoginZkp = Signature.ZkLoginSignatureInputs
|
|
170
|
+
export type ZkLoginZkp = Signature.ZkLoginSignatureInputs
|
|
171
|
+
|
|
172
|
+
export const SponsoredTransaction = Schema.Struct({
|
|
173
|
+
/** BCS `TransactionData`, gas filled in by Enoki. */
|
|
174
|
+
bytes: Schema.Uint8ArrayFromBase64,
|
|
175
|
+
digest: Schema.String
|
|
176
|
+
})
|
|
177
|
+
export type SponsoredTransaction = typeof SponsoredTransaction.Type
|
|
178
|
+
|
|
179
|
+
export const ExecutedTransaction = Schema.Struct({ digest: Schema.String })
|
|
180
|
+
export type ExecutedTransaction = typeof ExecutedTransaction.Type
|
|
181
|
+
|
|
182
|
+
// -----------------------------------------------------------------------------
|
|
183
|
+
// Service
|
|
184
|
+
// -----------------------------------------------------------------------------
|
|
185
|
+
|
|
186
|
+
export class EnokiClient extends Context.Service<EnokiClient, {
|
|
187
|
+
readonly getApp: Effect.Effect<App, EnokiError>
|
|
188
|
+
/** The salt, address and public identifier of the JWT's user. */
|
|
189
|
+
readonly getZkLogin: (input: { readonly jwt: string }) => Effect.Effect<ZkLoginAccount, EnokiError>
|
|
190
|
+
/** Every address of the JWT's user across the app's client ids, flagging legacy ones. */
|
|
191
|
+
readonly getZkLoginAddresses: (input: { readonly jwt: string }) => Effect.Effect<ZkLoginAddresses, EnokiError>
|
|
192
|
+
readonly createZkLoginNonce: (input: CreateZkLoginNonceInput) => Effect.Effect<ZkLoginNonce, EnokiError>
|
|
193
|
+
readonly createZkLoginZkp: (input: CreateZkLoginZkpInput) => Effect.Effect<ZkLoginZkp, EnokiError>
|
|
194
|
+
readonly createSponsoredTransaction: (
|
|
195
|
+
input: CreateSponsoredTransactionInput
|
|
196
|
+
) => Effect.Effect<SponsoredTransaction, EnokiError>
|
|
197
|
+
readonly executeSponsoredTransaction: (
|
|
198
|
+
input: ExecuteSponsoredTransactionInput
|
|
199
|
+
) => Effect.Effect<ExecutedTransaction, EnokiError>
|
|
200
|
+
/** Sponsor and execute in one call (private API key). */
|
|
201
|
+
readonly sponsorAndExecuteTransaction: (
|
|
202
|
+
input: SponsorAndExecuteTransactionInput
|
|
203
|
+
) => Effect.Effect<ExecutedTransaction, EnokiError>
|
|
204
|
+
}>()("@unconfirmed/effect-sui/enoki/EnokiClient") {}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `EnokiClient` over Effect's `HttpClient`: the same endpoints, headers and
|
|
3
|
+
* JSON bodies as `@mysten/enoki`'s `EnokiClient`.
|
|
4
|
+
*
|
|
5
|
+
* EnokiHttp.layer({ apiKey }).pipe(Layer.provide(FetchHttpClient.layer))
|
|
6
|
+
*/
|
|
7
|
+
import * as SignatureScheme from "../SignatureScheme.ts"
|
|
8
|
+
import * as Duration from "effect/Duration"
|
|
9
|
+
import * as Effect from "effect/Effect"
|
|
10
|
+
import * as Exit from "effect/Exit"
|
|
11
|
+
import * as Layer from "effect/Layer"
|
|
12
|
+
import * as Option from "effect/Option"
|
|
13
|
+
import * as Predicate from "effect/Predicate"
|
|
14
|
+
import * as Schema from "effect/Schema"
|
|
15
|
+
import * as Headers from "effect/http/Headers"
|
|
16
|
+
import * as HttpClient from "effect/http/HttpClient"
|
|
17
|
+
import * as HttpClientRequest from "effect/http/HttpClientRequest"
|
|
18
|
+
import * as HttpClientResponse from "effect/http/HttpClientResponse"
|
|
19
|
+
import { EnokiClient, EnokiError, type EnokiErrorDetail } from "./EnokiClient.ts"
|
|
20
|
+
import * as E from "./EnokiClient.ts"
|
|
21
|
+
|
|
22
|
+
export const DEFAULT_URL = "https://api.enoki.mystenlabs.com"
|
|
23
|
+
/** How long a successful `getApp` (which names the sponsor addresses) is reused. Failures aren't cached. */
|
|
24
|
+
export const APP_CACHE_TTL = "5 minutes"
|
|
25
|
+
const VERSION = "v1"
|
|
26
|
+
const ZKLOGIN_HEADER = "zklogin-jwt"
|
|
27
|
+
/** Headers that carry credentials (`authorization` is redacted by Effect already). */
|
|
28
|
+
const REDACTED = [ZKLOGIN_HEADER, "authorization"]
|
|
29
|
+
|
|
30
|
+
export interface EnokiHttpOptions {
|
|
31
|
+
readonly apiKey: string
|
|
32
|
+
/**
|
|
33
|
+
* Base URL of the Enoki API; `/v1/…` paths are appended to it, trailing slashes stripped.
|
|
34
|
+
* Default {@link DEFAULT_URL} (`https://api.enoki.mystenlabs.com`).
|
|
35
|
+
*/
|
|
36
|
+
readonly url?: string
|
|
37
|
+
/**
|
|
38
|
+
* Extra headers on every request (routing, a proxy's credentials). The API key, content type,
|
|
39
|
+
* request id and the user's JWT are set by the layer and take precedence.
|
|
40
|
+
*/
|
|
41
|
+
readonly headers?: Readonly<Record<string, string>>
|
|
42
|
+
/** Default `additionalEpochs` for nonces. */
|
|
43
|
+
readonly additionalEpochs?: number
|
|
44
|
+
/**
|
|
45
|
+
* Send `traceparent` / `b3` headers. Off by default: browsers preflight
|
|
46
|
+
* them, and the Enoki API doesn't list them as allowed headers.
|
|
47
|
+
*/
|
|
48
|
+
readonly tracerPropagation?: boolean
|
|
49
|
+
/** Bound on each request; one without an answer in time is a retryable `EnokiError` (`status: 0`, `code: "timeout"`). Default 30 seconds. */
|
|
50
|
+
readonly requestTimeout?: Duration.Input
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const toBase64 = (bytes: Uint8Array): string => {
|
|
54
|
+
let binary = ""
|
|
55
|
+
for (const b of bytes) binary += String.fromCharCode(b)
|
|
56
|
+
return btoa(binary)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** `flag || bytes` in base64, as `PublicKey.toSuiPublicKey()`. */
|
|
60
|
+
const suiPublicKey = (pk: SignatureScheme.PublicKey) => toBase64(SignatureScheme.toSuiBytes(pk))
|
|
61
|
+
|
|
62
|
+
const ErrorBody = Schema.fromJsonString(Schema.Struct({ errors: Schema.Array(Schema.Unknown) }))
|
|
63
|
+
const decodeErrorBody = Schema.decodeUnknownOption(ErrorBody)
|
|
64
|
+
|
|
65
|
+
/** One entry, keeping whichever of `code` / `message` / `data` are well-formed (as `@mysten/enoki` reads them raw). */
|
|
66
|
+
const detail = (entry: unknown): EnokiErrorDetail | undefined => {
|
|
67
|
+
if (!Predicate.isObject(entry)) return undefined
|
|
68
|
+
const e = entry as Record<string, unknown>
|
|
69
|
+
return {
|
|
70
|
+
...(Predicate.isString(e.code) && { code: e.code }),
|
|
71
|
+
...(Predicate.isString(e.message) && { message: e.message }),
|
|
72
|
+
...("data" in e && { data: e.data })
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** @internal An error response, decoded like `@mysten/enoki`'s `EnokiClientError`: leniently, per entry. */
|
|
77
|
+
export const errorFromResponse = (status: number, text: string): EnokiError => {
|
|
78
|
+
const errors = Option.match(decodeErrorBody(text), {
|
|
79
|
+
onNone: () => [],
|
|
80
|
+
onSome: (b) => b.errors.flatMap((entry) => detail(entry) ?? [])
|
|
81
|
+
})
|
|
82
|
+
const first = errors[0]
|
|
83
|
+
return new EnokiError({
|
|
84
|
+
status,
|
|
85
|
+
code: first?.code ?? "unknown_error",
|
|
86
|
+
message: first?.message ?? `Request to Enoki API failed (status: ${status})`,
|
|
87
|
+
errors
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The failure to keep as an `EnokiError`'s `cause`. HTTP client errors hold
|
|
93
|
+
* the request, whose headers carry the API key and the user's JWT, so only
|
|
94
|
+
* their name and message are kept; a Schema error (about the response body)
|
|
95
|
+
* is kept as is.
|
|
96
|
+
*/
|
|
97
|
+
const withoutRequest = (e: unknown): unknown => {
|
|
98
|
+
if (Schema.isSchemaError(e)) return e
|
|
99
|
+
const tag = Predicate.hasProperty(e, "reason") && Predicate.hasProperty(e.reason, "_tag") ? String(e.reason._tag) : undefined
|
|
100
|
+
const error = new Error(Predicate.hasProperty(e, "message") ? String(e.message) : String(e))
|
|
101
|
+
error.name = tag ?? "HttpClientError"
|
|
102
|
+
return error
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export const layer = (options: EnokiHttpOptions): Layer.Layer<EnokiClient, never, HttpClient.HttpClient> =>
|
|
106
|
+
Layer.effect(
|
|
107
|
+
EnokiClient,
|
|
108
|
+
Effect.gen(function*() {
|
|
109
|
+
const http = yield* HttpClient.HttpClient
|
|
110
|
+
const base = `${(options.url ?? DEFAULT_URL).replace(/\/+$/, "")}/${VERSION}`
|
|
111
|
+
const timeout = Duration.fromInputUnsafe(options.requestTimeout ?? "30 seconds")
|
|
112
|
+
|
|
113
|
+
const call = <S extends Schema.Top & { readonly DecodingServices: never }>(
|
|
114
|
+
operation: string,
|
|
115
|
+
method: "GET" | "POST",
|
|
116
|
+
path: string,
|
|
117
|
+
data: S,
|
|
118
|
+
init: { readonly headers?: Record<string, string>; readonly body?: unknown } = {}
|
|
119
|
+
): Effect.Effect<S["Type"], EnokiError> => {
|
|
120
|
+
const envelope = Schema.Struct({ data })
|
|
121
|
+
return Effect.gen(function*() {
|
|
122
|
+
let request = HttpClientRequest.make(method)(`${base}/${path}`).pipe(
|
|
123
|
+
HttpClientRequest.setHeaders({
|
|
124
|
+
...options.headers,
|
|
125
|
+
...init.headers,
|
|
126
|
+
Authorization: `Bearer ${options.apiKey}`,
|
|
127
|
+
"Content-Type": "application/json",
|
|
128
|
+
"Request-Id": crypto.randomUUID()
|
|
129
|
+
})
|
|
130
|
+
)
|
|
131
|
+
if (init.body !== undefined) request = HttpClientRequest.bodyJsonUnsafe(request, init.body)
|
|
132
|
+
const redacted = yield* Headers.CurrentRedactedNames
|
|
133
|
+
const response = yield* http.execute(request).pipe(
|
|
134
|
+
Effect.provideService(HttpClient.TracerPropagationEnabled, options.tracerPropagation ?? false),
|
|
135
|
+
// The JWT is a bearer credential for the user; keep it out of spans and logs like `Authorization`.
|
|
136
|
+
Effect.provideService(Headers.CurrentRedactedNames, [...redacted, ...REDACTED]),
|
|
137
|
+
Effect.mapError((e) => new EnokiError({ status: 0, code: "request_failed", message: e.message, errors: [], cause: withoutRequest(e) }))
|
|
138
|
+
)
|
|
139
|
+
if (response.status < 200 || response.status >= 300) {
|
|
140
|
+
const text = yield* response.text.pipe(Effect.orElseSucceed(() => ""))
|
|
141
|
+
return yield* errorFromResponse(response.status, text)
|
|
142
|
+
}
|
|
143
|
+
const body = yield* HttpClientResponse.schemaBodyJson(envelope)(response).pipe(
|
|
144
|
+
Effect.mapError((e) =>
|
|
145
|
+
new EnokiError({ status: response.status, code: "invalid_response", message: e.message, errors: [], cause: withoutRequest(e) })
|
|
146
|
+
)
|
|
147
|
+
)
|
|
148
|
+
return (body as { readonly data: S["Type"] }).data
|
|
149
|
+
}).pipe(
|
|
150
|
+
Effect.timeoutOrElse({
|
|
151
|
+
duration: timeout,
|
|
152
|
+
orElse: () =>
|
|
153
|
+
Effect.fail(new EnokiError({ status: 0, code: "timeout", message: `${operation}: no answer within ${Duration.format(timeout)}`, errors: [] }))
|
|
154
|
+
}),
|
|
155
|
+
Effect.withSpan(`EnokiClient.${operation}`, { attributes: { "http.request.method": method, "enoki.path": path } })
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const jwtHeader = (jwt: string | undefined) => (jwt ? { [ZKLOGIN_HEADER]: jwt } : {})
|
|
160
|
+
|
|
161
|
+
// `Sponsor` asks for the app (its sponsor addresses) with every transaction: answer it from a cache,
|
|
162
|
+
// and drop the cache when Enoki says the sponsor or gas price changed, as `@mysten/enoki` does.
|
|
163
|
+
const [getApp, invalidateApp] = yield* Effect.cachedInvalidateWithTTL(
|
|
164
|
+
call("getApp", "GET", "app", E.App),
|
|
165
|
+
(exit) => (Exit.isSuccess(exit) ? APP_CACHE_TTL : 0)
|
|
166
|
+
)
|
|
167
|
+
const dropAppWhenStale = <A>(effect: Effect.Effect<A, EnokiError>) =>
|
|
168
|
+
Effect.tapError(effect, (e) => (e.requiresRebuild ? invalidateApp : Effect.void))
|
|
169
|
+
|
|
170
|
+
return EnokiClient.of({
|
|
171
|
+
getApp,
|
|
172
|
+
getZkLogin: ({ jwt }) => call("getZkLogin", "GET", "zklogin", E.ZkLoginAccount, { headers: jwtHeader(jwt) }),
|
|
173
|
+
getZkLoginAddresses: ({ jwt }) =>
|
|
174
|
+
call("getZkLoginAddresses", "GET", "zklogin/addresses", E.ZkLoginAddresses, { headers: jwtHeader(jwt) }),
|
|
175
|
+
createZkLoginNonce: (input) =>
|
|
176
|
+
call("createZkLoginNonce", "POST", "zklogin/nonce", E.ZkLoginNonce, {
|
|
177
|
+
body: {
|
|
178
|
+
network: input.network,
|
|
179
|
+
ephemeralPublicKey: suiPublicKey(input.ephemeralPublicKey),
|
|
180
|
+
additionalEpochs: input.additionalEpochs ?? options.additionalEpochs
|
|
181
|
+
}
|
|
182
|
+
}),
|
|
183
|
+
createZkLoginZkp: (input) =>
|
|
184
|
+
call("createZkLoginZkp", "POST", "zklogin/zkp", E.ZkLoginZkp, {
|
|
185
|
+
headers: jwtHeader(input.jwt),
|
|
186
|
+
body: {
|
|
187
|
+
network: input.network,
|
|
188
|
+
ephemeralPublicKey: suiPublicKey(input.ephemeralPublicKey),
|
|
189
|
+
maxEpoch: Number(input.maxEpoch),
|
|
190
|
+
randomness: input.randomness
|
|
191
|
+
}
|
|
192
|
+
}),
|
|
193
|
+
createSponsoredTransaction: (input) => {
|
|
194
|
+
const bySender = "sender" in input ? input : undefined
|
|
195
|
+
return dropAppWhenStale(call("createSponsoredTransaction", "POST", "transaction-blocks/sponsor", E.SponsoredTransaction, {
|
|
196
|
+
headers: jwtHeader("jwt" in input ? input.jwt : undefined),
|
|
197
|
+
body: {
|
|
198
|
+
sender: bySender?.sender,
|
|
199
|
+
network: input.network,
|
|
200
|
+
transactionBlockKindBytes: toBase64(input.transactionKindBytes),
|
|
201
|
+
allowedAddresses: bySender?.allowedAddresses,
|
|
202
|
+
allowedMoveCallTargets: bySender?.allowedMoveCallTargets
|
|
203
|
+
}
|
|
204
|
+
}))
|
|
205
|
+
},
|
|
206
|
+
executeSponsoredTransaction: (input) =>
|
|
207
|
+
dropAppWhenStale(call("executeSponsoredTransaction", "POST", `transaction-blocks/sponsor/${input.digest}`, E.ExecutedTransaction, {
|
|
208
|
+
body: { signature: toBase64(input.signature) }
|
|
209
|
+
})),
|
|
210
|
+
sponsorAndExecuteTransaction: (input) =>
|
|
211
|
+
call("sponsorAndExecuteTransaction", "POST", "transaction-blocks/sponsor/execute", E.ExecutedTransaction, {
|
|
212
|
+
body: {
|
|
213
|
+
network: input.network,
|
|
214
|
+
transactionBytes: toBase64(input.transactionBytes),
|
|
215
|
+
signature: toBase64(input.signature),
|
|
216
|
+
allowedAddresses: input.allowedAddresses,
|
|
217
|
+
allowedMoveCallTargets: input.allowedMoveCallTargets
|
|
218
|
+
}
|
|
219
|
+
})
|
|
220
|
+
})
|
|
221
|
+
})
|
|
222
|
+
)
|