@aa-sdk/core 4.0.0-alpha.9 → 4.0.0-beta.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/dist/esm/abis/EntryPointAbi_v7.js +1 -0
- package/dist/esm/abis/EntryPointAbi_v7.js.map +1 -1
- package/dist/esm/account/smartContractAccount.d.ts +50 -1
- package/dist/esm/account/smartContractAccount.js +111 -2
- package/dist/esm/account/smartContractAccount.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperation.d.ts +23 -0
- package/dist/esm/actions/smartAccount/buildUserOperation.js +23 -0
- package/dist/esm/actions/smartAccount/buildUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperationFromTx.d.ts +39 -0
- package/dist/esm/actions/smartAccount/buildUserOperationFromTx.js +39 -0
- package/dist/esm/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.d.ts +54 -0
- package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.js +55 -0
- package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
- package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.d.ts +28 -0
- package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js +28 -0
- package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
- package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.d.ts +22 -0
- package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.js +27 -6
- package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/estimateUserOperationGas.d.ts +13 -0
- package/dist/esm/actions/smartAccount/estimateUserOperationGas.js +13 -0
- package/dist/esm/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/initUserOperation.d.ts +13 -0
- package/dist/esm/actions/smartAccount/internal/initUserOperation.js +14 -1
- package/dist/esm/actions/smartAccount/internal/initUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/runMiddlewareStack.js +2 -1
- package/dist/esm/actions/smartAccount/internal/runMiddlewareStack.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendTransaction.d.ts +24 -0
- package/dist/esm/actions/smartAccount/sendTransaction.js +24 -0
- package/dist/esm/actions/smartAccount/sendTransaction.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendTransactions.d.ts +23 -0
- package/dist/esm/actions/smartAccount/sendTransactions.js +23 -0
- package/dist/esm/actions/smartAccount/sendTransactions.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendUserOperation.d.ts +21 -0
- package/dist/esm/actions/smartAccount/sendUserOperation.js +21 -0
- package/dist/esm/actions/smartAccount/sendUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/types.d.ts +14 -0
- package/dist/esm/actions/smartAccount/types.js +1 -0
- package/dist/esm/actions/smartAccount/types.js.map +1 -1
- package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.d.ts +24 -0
- package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.js +24 -0
- package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.js.map +1 -1
- package/dist/esm/client/bundlerClient.d.ts +21 -0
- package/dist/esm/client/bundlerClient.js +32 -0
- package/dist/esm/client/bundlerClient.js.map +1 -1
- package/dist/esm/client/decorators/bundlerClient.d.ts +41 -0
- package/dist/esm/client/decorators/bundlerClient.js +10 -0
- package/dist/esm/client/decorators/bundlerClient.js.map +1 -1
- package/dist/esm/client/decorators/smartAccountClient.d.ts +8 -0
- package/dist/esm/client/decorators/smartAccountClient.js +12 -1
- package/dist/esm/client/decorators/smartAccountClient.js.map +1 -1
- package/dist/esm/client/isSmartAccountClient.d.ts +16 -0
- package/dist/esm/client/isSmartAccountClient.js +16 -0
- package/dist/esm/client/isSmartAccountClient.js.map +1 -1
- package/dist/esm/client/schema.d.ts +12 -0
- package/dist/esm/client/schema.js +14 -0
- package/dist/esm/client/schema.js.map +1 -1
- package/dist/esm/client/smartAccountClient.js +53 -0
- package/dist/esm/client/smartAccountClient.js.map +1 -1
- package/dist/esm/client/types.js +1 -0
- package/dist/esm/client/types.js.map +1 -1
- package/dist/esm/ens/utils.d.ts +45 -0
- package/dist/esm/ens/utils.js +49 -0
- package/dist/esm/ens/utils.js.map +1 -1
- package/dist/esm/entrypoint/index.d.ts +14 -0
- package/dist/esm/entrypoint/index.js +30 -0
- package/dist/esm/entrypoint/index.js.map +1 -1
- package/dist/esm/entrypoint/types.d.ts +17 -0
- package/dist/esm/errors/account.d.ts +87 -4
- package/dist/esm/errors/account.js +88 -4
- package/dist/esm/errors/account.js.map +1 -1
- package/dist/esm/errors/base.d.ts +5 -0
- package/dist/esm/errors/base.js +5 -0
- package/dist/esm/errors/base.js.map +1 -1
- package/dist/esm/errors/client.d.ts +24 -0
- package/dist/esm/errors/client.js +24 -0
- package/dist/esm/errors/client.js.map +1 -1
- package/dist/esm/errors/entrypoint.d.ts +18 -0
- package/dist/esm/errors/entrypoint.js +18 -0
- package/dist/esm/errors/entrypoint.js.map +1 -1
- package/dist/esm/errors/signer.d.ts +8 -0
- package/dist/esm/errors/signer.js +8 -0
- package/dist/esm/errors/signer.js.map +1 -1
- package/dist/esm/errors/transaction.d.ts +14 -1
- package/dist/esm/errors/transaction.js +14 -1
- package/dist/esm/errors/transaction.js.map +1 -1
- package/dist/esm/errors/useroperation.d.ts +25 -0
- package/dist/esm/errors/useroperation.js +26 -0
- package/dist/esm/errors/useroperation.js.map +1 -1
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/logger.d.ts +91 -0
- package/dist/esm/logger.js +91 -0
- package/dist/esm/logger.js.map +1 -1
- package/dist/esm/middleware/actions.d.ts +14 -0
- package/dist/esm/middleware/actions.js +7 -0
- package/dist/esm/middleware/actions.js.map +1 -1
- package/dist/esm/middleware/defaults/feeEstimator.d.ts +20 -0
- package/dist/esm/middleware/defaults/feeEstimator.js +28 -0
- package/dist/esm/middleware/defaults/feeEstimator.js.map +1 -1
- package/dist/esm/middleware/defaults/gasEstimator.d.ts +8 -0
- package/dist/esm/middleware/defaults/gasEstimator.js +8 -0
- package/dist/esm/middleware/defaults/gasEstimator.js.map +1 -1
- package/dist/esm/middleware/defaults/paymasterAndData.d.ts +8 -0
- package/dist/esm/middleware/defaults/paymasterAndData.js +8 -0
- package/dist/esm/middleware/defaults/paymasterAndData.js.map +1 -1
- package/dist/esm/middleware/defaults/userOpSigner.d.ts +10 -0
- package/dist/esm/middleware/defaults/userOpSigner.js +10 -0
- package/dist/esm/middleware/defaults/userOpSigner.js.map +1 -1
- package/dist/esm/middleware/erc7677middleware.d.ts +21 -0
- package/dist/esm/middleware/erc7677middleware.js +23 -0
- package/dist/esm/middleware/erc7677middleware.js.map +1 -1
- package/dist/esm/middleware/noopMiddleware.d.ts +6 -0
- package/dist/esm/middleware/noopMiddleware.js +6 -0
- package/dist/esm/middleware/noopMiddleware.js.map +1 -1
- package/dist/esm/middleware/types.js +1 -0
- package/dist/esm/middleware/types.js.map +1 -1
- package/dist/esm/signer/local-account.d.ts +98 -5
- package/dist/esm/signer/local-account.js +97 -2
- package/dist/esm/signer/local-account.js.map +1 -1
- package/dist/esm/signer/schema.d.ts +14 -0
- package/dist/esm/signer/schema.js +14 -0
- package/dist/esm/signer/schema.js.map +1 -1
- package/dist/esm/signer/types.d.ts +13 -3
- package/dist/esm/signer/types.js +1 -0
- package/dist/esm/signer/types.js.map +1 -1
- package/dist/esm/signer/utils.d.ts +20 -0
- package/dist/esm/signer/utils.js +27 -0
- package/dist/esm/signer/utils.js.map +1 -1
- package/dist/esm/signer/wallet-client.d.ts +94 -4
- package/dist/esm/signer/wallet-client.js +95 -2
- package/dist/esm/signer/wallet-client.js.map +1 -1
- package/dist/esm/transport/split.d.ts +32 -0
- package/dist/esm/transport/split.js +32 -0
- package/dist/esm/transport/split.js.map +1 -1
- package/dist/esm/types.d.ts +17 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/bigint.d.ts +45 -0
- package/dist/esm/utils/bigint.js +46 -0
- package/dist/esm/utils/bigint.js.map +1 -1
- package/dist/esm/utils/bytes.d.ts +9 -0
- package/dist/esm/utils/bytes.js +10 -1
- package/dist/esm/utils/bytes.js.map +1 -1
- package/dist/esm/utils/index.d.ts +86 -0
- package/dist/esm/utils/index.js +86 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/schema.d.ts +3 -0
- package/dist/esm/utils/schema.js +9 -0
- package/dist/esm/utils/schema.js.map +1 -1
- package/dist/esm/utils/stateOverride.js +2 -0
- package/dist/esm/utils/stateOverride.js.map +1 -1
- package/dist/esm/utils/types.d.ts +22 -0
- package/dist/esm/utils/types.js +1 -0
- package/dist/esm/utils/types.js.map +1 -1
- package/dist/esm/utils/userop.d.ts +79 -0
- package/dist/esm/utils/userop.js +83 -0
- package/dist/esm/utils/userop.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +3 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/account/smartContractAccount.d.ts +1 -1
- package/dist/types/account/smartContractAccount.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/dropAndReplaceUserOperation.d.ts.map +1 -1
- package/dist/types/client/smartAccountClient.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/signer/local-account.d.ts +2 -4
- package/dist/types/signer/local-account.d.ts.map +1 -1
- package/dist/types/signer/types.d.ts +1 -3
- package/dist/types/signer/types.d.ts.map +1 -1
- package/dist/types/signer/wallet-client.d.ts +2 -4
- package/dist/types/signer/wallet-client.d.ts.map +1 -1
- package/dist/types/transport/split.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +9 -11
- package/src/account/smartContractAccount.ts +3 -3
- package/src/actions/smartAccount/dropAndReplaceUserOperation.ts +10 -10
- package/src/actions/smartAccount/internal/initUserOperation.ts +1 -1
- package/src/client/smartAccountClient.ts +7 -0
- package/src/index.ts +0 -1
- package/src/signer/local-account.ts +2 -2
- package/src/signer/types.ts +2 -2
- package/src/signer/wallet-client.ts +8 -4
- package/src/transport/split.ts +1 -1
- package/src/version.ts +1 -1
- package/dist/cjs/abis/EntryPointAbi_v6.d.ts +0 -1018
- package/dist/cjs/abis/EntryPointAbi_v6.js +0 -1313
- package/dist/cjs/abis/EntryPointAbi_v6.js.map +0 -1
- package/dist/cjs/abis/EntryPointAbi_v7.d.ts +0 -775
- package/dist/cjs/abis/EntryPointAbi_v7.js +0 -661
- package/dist/cjs/abis/EntryPointAbi_v7.js.map +0 -1
- package/dist/cjs/abis/SimpleAccountAbi_v6.d.ts +0 -405
- package/dist/cjs/abis/SimpleAccountAbi_v6.js +0 -528
- package/dist/cjs/abis/SimpleAccountAbi_v6.js.map +0 -1
- package/dist/cjs/abis/SimpleAccountAbi_v7.d.ts +0 -410
- package/dist/cjs/abis/SimpleAccountAbi_v7.js +0 -538
- package/dist/cjs/abis/SimpleAccountAbi_v7.js.map +0 -1
- package/dist/cjs/abis/SimpleAccountFactoryAbi.d.ts +0 -55
- package/dist/cjs/abis/SimpleAccountFactoryAbi.js +0 -78
- package/dist/cjs/abis/SimpleAccountFactoryAbi.js.map +0 -1
- package/dist/cjs/account/smartContractAccount.d.ts +0 -74
- package/dist/cjs/account/smartContractAccount.js +0 -180
- package/dist/cjs/account/smartContractAccount.js.map +0 -1
- package/dist/cjs/actions/bundler/estimateUserOperationGas.d.ts +0 -8
- package/dist/cjs/actions/bundler/estimateUserOperationGas.js +0 -18
- package/dist/cjs/actions/bundler/estimateUserOperationGas.js.map +0 -1
- package/dist/cjs/actions/bundler/getSupportedEntryPoints.d.ts +0 -3
- package/dist/cjs/actions/bundler/getSupportedEntryPoints.js +0 -11
- package/dist/cjs/actions/bundler/getSupportedEntryPoints.js.map +0 -1
- package/dist/cjs/actions/bundler/getUserOperationByHash.d.ts +0 -6
- package/dist/cjs/actions/bundler/getUserOperationByHash.js +0 -11
- package/dist/cjs/actions/bundler/getUserOperationByHash.js.map +0 -1
- package/dist/cjs/actions/bundler/getUserOperationReceipt.d.ts +0 -6
- package/dist/cjs/actions/bundler/getUserOperationReceipt.js +0 -11
- package/dist/cjs/actions/bundler/getUserOperationReceipt.js.map +0 -1
- package/dist/cjs/actions/bundler/sendRawUserOperation.d.ts +0 -7
- package/dist/cjs/actions/bundler/sendRawUserOperation.js +0 -11
- package/dist/cjs/actions/bundler/sendRawUserOperation.js.map +0 -1
- package/dist/cjs/actions/smartAccount/buildUserOperation.d.ts +0 -5
- package/dist/cjs/actions/smartAccount/buildUserOperation.js +0 -25
- package/dist/cjs/actions/smartAccount/buildUserOperation.js.map +0 -1
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTx.d.ts +0 -5
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTx.js +0 -39
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTx.js.map +0 -1
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTxs.d.ts +0 -4
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTxs.js +0 -62
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTxs.js.map +0 -1
- package/dist/cjs/actions/smartAccount/checkGasSponsorshipEligibility.d.ts +0 -4
- package/dist/cjs/actions/smartAccount/checkGasSponsorshipEligibility.js +0 -34
- package/dist/cjs/actions/smartAccount/checkGasSponsorshipEligibility.js.map +0 -1
- package/dist/cjs/actions/smartAccount/dropAndReplaceUserOperation.d.ts +0 -5
- package/dist/cjs/actions/smartAccount/dropAndReplaceUserOperation.js +0 -64
- package/dist/cjs/actions/smartAccount/dropAndReplaceUserOperation.js.map +0 -1
- package/dist/cjs/actions/smartAccount/estimateUserOperationGas.d.ts +0 -5
- package/dist/cjs/actions/smartAccount/estimateUserOperationGas.js +0 -23
- package/dist/cjs/actions/smartAccount/estimateUserOperationGas.js.map +0 -1
- package/dist/cjs/actions/smartAccount/getAddress.d.ts +0 -4
- package/dist/cjs/actions/smartAccount/getAddress.js +0 -13
- package/dist/cjs/actions/smartAccount/getAddress.js.map +0 -1
- package/dist/cjs/actions/smartAccount/internal/initUserOperation.d.ts +0 -7
- package/dist/cjs/actions/smartAccount/internal/initUserOperation.js +0 -42
- package/dist/cjs/actions/smartAccount/internal/initUserOperation.js.map +0 -1
- package/dist/cjs/actions/smartAccount/internal/runMiddlewareStack.d.ts +0 -10
- package/dist/cjs/actions/smartAccount/internal/runMiddlewareStack.js +0 -47
- package/dist/cjs/actions/smartAccount/internal/runMiddlewareStack.js.map +0 -1
- package/dist/cjs/actions/smartAccount/internal/sendUserOperation.d.ts +0 -10
- package/dist/cjs/actions/smartAccount/internal/sendUserOperation.js +0 -28
- package/dist/cjs/actions/smartAccount/internal/sendUserOperation.js.map +0 -1
- package/dist/cjs/actions/smartAccount/sendTransaction.d.ts +0 -5
- package/dist/cjs/actions/smartAccount/sendTransaction.js +0 -35
- package/dist/cjs/actions/smartAccount/sendTransaction.js.map +0 -1
- package/dist/cjs/actions/smartAccount/sendTransactions.d.ts +0 -4
- package/dist/cjs/actions/smartAccount/sendTransactions.js +0 -36
- package/dist/cjs/actions/smartAccount/sendTransactions.js.map +0 -1
- package/dist/cjs/actions/smartAccount/sendUserOperation.d.ts +0 -5
- package/dist/cjs/actions/smartAccount/sendUserOperation.js +0 -31
- package/dist/cjs/actions/smartAccount/sendUserOperation.js.map +0 -1
- package/dist/cjs/actions/smartAccount/signMessage.d.ts +0 -6
- package/dist/cjs/actions/smartAccount/signMessage.js +0 -12
- package/dist/cjs/actions/smartAccount/signMessage.js.map +0 -1
- package/dist/cjs/actions/smartAccount/signMessageWith6492.d.ts +0 -4
- package/dist/cjs/actions/smartAccount/signMessageWith6492.js +0 -12
- package/dist/cjs/actions/smartAccount/signMessageWith6492.js.map +0 -1
- package/dist/cjs/actions/smartAccount/signTypedData.d.ts +0 -10
- package/dist/cjs/actions/smartAccount/signTypedData.js +0 -12
- package/dist/cjs/actions/smartAccount/signTypedData.js.map +0 -1
- package/dist/cjs/actions/smartAccount/signTypedDataWith6492.d.ts +0 -6
- package/dist/cjs/actions/smartAccount/signTypedDataWith6492.js +0 -12
- package/dist/cjs/actions/smartAccount/signTypedDataWith6492.js.map +0 -1
- package/dist/cjs/actions/smartAccount/signUserOperation.d.ts +0 -5
- package/dist/cjs/actions/smartAccount/signUserOperation.js +0 -30
- package/dist/cjs/actions/smartAccount/signUserOperation.js.map +0 -1
- package/dist/cjs/actions/smartAccount/types.d.ts +0 -42
- package/dist/cjs/actions/smartAccount/types.js +0 -3
- package/dist/cjs/actions/smartAccount/types.js.map +0 -1
- package/dist/cjs/actions/smartAccount/upgradeAccount.d.ts +0 -4
- package/dist/cjs/actions/smartAccount/upgradeAccount.js +0 -38
- package/dist/cjs/actions/smartAccount/upgradeAccount.js.map +0 -1
- package/dist/cjs/actions/smartAccount/waitForUserOperationTransacation.d.ts +0 -3
- package/dist/cjs/actions/smartAccount/waitForUserOperationTransacation.js +0 -36
- package/dist/cjs/actions/smartAccount/waitForUserOperationTransacation.js.map +0 -1
- package/dist/cjs/client/bundlerClient.d.ts +0 -10
- package/dist/cjs/client/bundlerClient.js +0 -51
- package/dist/cjs/client/bundlerClient.js.map +0 -1
- package/dist/cjs/client/decorators/bundlerClient.d.ts +0 -41
- package/dist/cjs/client/decorators/bundlerClient.js +0 -17
- package/dist/cjs/client/decorators/bundlerClient.js.map +0 -1
- package/dist/cjs/client/decorators/smartAccountClient.d.ts +0 -35
- package/dist/cjs/client/decorators/smartAccountClient.js +0 -43
- package/dist/cjs/client/decorators/smartAccountClient.js.map +0 -1
- package/dist/cjs/client/isSmartAccountClient.d.ts +0 -5
- package/dist/cjs/client/isSmartAccountClient.js +0 -18
- package/dist/cjs/client/isSmartAccountClient.js.map +0 -1
- package/dist/cjs/client/schema.d.ts +0 -767
- package/dist/cjs/client/schema.js +0 -63
- package/dist/cjs/client/schema.js.map +0 -1
- package/dist/cjs/client/smartAccountClient.d.ts +0 -33
- package/dist/cjs/client/smartAccountClient.js +0 -93
- package/dist/cjs/client/smartAccountClient.js.map +0 -1
- package/dist/cjs/client/types.d.ts +0 -21
- package/dist/cjs/client/types.js +0 -3
- package/dist/cjs/client/types.js.map +0 -1
- package/dist/cjs/ens/utils.d.ts +0 -6
- package/dist/cjs/ens/utils.js +0 -53
- package/dist/cjs/ens/utils.js.map +0 -1
- package/dist/cjs/entrypoint/0.6.d.ts +0 -1029
- package/dist/cjs/entrypoint/0.6.js +0 -49
- package/dist/cjs/entrypoint/0.6.js.map +0 -1
- package/dist/cjs/entrypoint/0.7.d.ts +0 -792
- package/dist/cjs/entrypoint/0.7.js +0 -88
- package/dist/cjs/entrypoint/0.7.js.map +0 -1
- package/dist/cjs/entrypoint/index.d.ts +0 -8
- package/dist/cjs/entrypoint/index.js +0 -53
- package/dist/cjs/entrypoint/index.js.map +0 -1
- package/dist/cjs/entrypoint/types.d.ts +0 -46
- package/dist/cjs/entrypoint/types.js +0 -3
- package/dist/cjs/entrypoint/types.js.map +0 -1
- package/dist/cjs/errors/account.d.ts +0 -47
- package/dist/cjs/errors/account.js +0 -140
- package/dist/cjs/errors/account.js.map +0 -1
- package/dist/cjs/errors/base.d.ts +0 -18
- package/dist/cjs/errors/base.js +0 -39
- package/dist/cjs/errors/base.js.map +0 -1
- package/dist/cjs/errors/client.d.ts +0 -14
- package/dist/cjs/errors/client.js +0 -44
- package/dist/cjs/errors/client.js.map +0 -1
- package/dist/cjs/errors/entrypoint.d.ts +0 -10
- package/dist/cjs/errors/entrypoint.js +0 -32
- package/dist/cjs/errors/entrypoint.js.map +0 -1
- package/dist/cjs/errors/signer.d.ts +0 -5
- package/dist/cjs/errors/signer.js +0 -20
- package/dist/cjs/errors/signer.js.map +0 -1
- package/dist/cjs/errors/transaction.d.ts +0 -10
- package/dist/cjs/errors/transaction.js +0 -29
- package/dist/cjs/errors/transaction.js.map +0 -1
- package/dist/cjs/errors/useroperation.d.ts +0 -10
- package/dist/cjs/errors/useroperation.js +0 -34
- package/dist/cjs/errors/useroperation.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -60
- package/dist/cjs/index.js +0 -170
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/logger.d.ts +0 -20
- package/dist/cjs/logger.js +0 -60
- package/dist/cjs/logger.js.map +0 -1
- package/dist/cjs/middleware/actions.d.ts +0 -12
- package/dist/cjs/middleware/actions.js +0 -21
- package/dist/cjs/middleware/actions.js.map +0 -1
- package/dist/cjs/middleware/defaults/feeEstimator.d.ts +0 -3
- package/dist/cjs/middleware/defaults/feeEstimator.js +0 -23
- package/dist/cjs/middleware/defaults/feeEstimator.js.map +0 -1
- package/dist/cjs/middleware/defaults/gasEstimator.d.ts +0 -3
- package/dist/cjs/middleware/defaults/gasEstimator.js +0 -28
- package/dist/cjs/middleware/defaults/gasEstimator.js.map +0 -1
- package/dist/cjs/middleware/defaults/paymasterAndData.d.ts +0 -2
- package/dist/cjs/middleware/defaults/paymasterAndData.js +0 -12
- package/dist/cjs/middleware/defaults/paymasterAndData.js.map +0 -1
- package/dist/cjs/middleware/defaults/userOpSigner.d.ts +0 -2
- package/dist/cjs/middleware/defaults/userOpSigner.js +0 -26
- package/dist/cjs/middleware/defaults/userOpSigner.js.map +0 -1
- package/dist/cjs/middleware/erc7677middleware.d.ts +0 -40
- package/dist/cjs/middleware/erc7677middleware.js +0 -77
- package/dist/cjs/middleware/erc7677middleware.js.map +0 -1
- package/dist/cjs/middleware/noopMiddleware.d.ts +0 -3
- package/dist/cjs/middleware/noopMiddleware.js +0 -8
- package/dist/cjs/middleware/noopMiddleware.js.map +0 -1
- package/dist/cjs/middleware/types.d.ts +0 -22
- package/dist/cjs/middleware/types.js +0 -3
- package/dist/cjs/middleware/types.js.map +0 -1
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/signer/local-account.d.ts +0 -219
- package/dist/cjs/signer/local-account.js +0 -56
- package/dist/cjs/signer/local-account.js.map +0 -1
- package/dist/cjs/signer/schema.d.ts +0 -4
- package/dist/cjs/signer/schema.js +0 -16
- package/dist/cjs/signer/schema.js.map +0 -1
- package/dist/cjs/signer/types.d.ts +0 -15
- package/dist/cjs/signer/types.js +0 -3
- package/dist/cjs/signer/types.js.map +0 -1
- package/dist/cjs/signer/utils.d.ts +0 -7
- package/dist/cjs/signer/utils.js +0 -16
- package/dist/cjs/signer/utils.js.map +0 -1
- package/dist/cjs/signer/wallet-client.d.ts +0 -217
- package/dist/cjs/signer/wallet-client.js +0 -58
- package/dist/cjs/signer/wallet-client.js.map +0 -1
- package/dist/cjs/transport/split.d.ts +0 -9
- package/dist/cjs/transport/split.js +0 -26
- package/dist/cjs/transport/split.js.map +0 -1
- package/dist/cjs/types.d.ts +0 -158
- package/dist/cjs/types.js +0 -3
- package/dist/cjs/types.js.map +0 -1
- package/dist/cjs/utils/bigint.d.ts +0 -10
- package/dist/cjs/utils/bigint.js +0 -55
- package/dist/cjs/utils/bigint.js.map +0 -1
- package/dist/cjs/utils/bytes.d.ts +0 -7
- package/dist/cjs/utils/bytes.js +0 -11
- package/dist/cjs/utils/bytes.js.map +0 -1
- package/dist/cjs/utils/defaults.d.ts +0 -4
- package/dist/cjs/utils/defaults.js +0 -19
- package/dist/cjs/utils/defaults.js.map +0 -1
- package/dist/cjs/utils/index.d.ts +0 -19
- package/dist/cjs/utils/index.js +0 -95
- package/dist/cjs/utils/index.js.map +0 -1
- package/dist/cjs/utils/schema.d.ts +0 -25
- package/dist/cjs/utils/schema.js +0 -35
- package/dist/cjs/utils/schema.js.map +0 -1
- package/dist/cjs/utils/stateOverride.d.ts +0 -4
- package/dist/cjs/utils/stateOverride.js +0 -52
- package/dist/cjs/utils/stateOverride.js.map +0 -1
- package/dist/cjs/utils/testUtils.d.ts +0 -6
- package/dist/cjs/utils/testUtils.js +0 -33
- package/dist/cjs/utils/testUtils.js.map +0 -1
- package/dist/cjs/utils/types.d.ts +0 -16
- package/dist/cjs/utils/types.js +0 -3
- package/dist/cjs/utils/types.js.map +0 -1
- package/dist/cjs/utils/userop.d.ts +0 -49
- package/dist/cjs/utils/userop.js +0 -75
- package/dist/cjs/utils/userop.js.map +0 -1
- package/dist/cjs/version.d.ts +0 -1
- package/dist/cjs/version.js +0 -5
- package/dist/cjs/version.js.map +0 -1
- package/dist/esm/package.json +0 -1
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import {} from "viem";
|
|
2
2
|
import { mnemonicToAccount, privateKeyToAccount } from "viem/accounts";
|
|
3
|
+
/**
|
|
4
|
+
* Represents a local account signer and provides methods to sign messages and transactions, as well as static methods to create the signer from mnemonic or private key.
|
|
5
|
+
*/
|
|
3
6
|
export class LocalAccountSigner {
|
|
7
|
+
/**
|
|
8
|
+
* A function to initialize an object with an inner parameter and derive a signerType from it.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
13
|
+
* import { privateKeyToAccount, generatePrivateKey } from "viem";
|
|
14
|
+
*
|
|
15
|
+
* const signer = new LocalAccountSigner(
|
|
16
|
+
* privateKeyToAccount(generatePrivateKey()),
|
|
17
|
+
* );
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @param {T} inner The inner parameter containing the necessary data
|
|
21
|
+
*/
|
|
4
22
|
constructor(inner) {
|
|
5
23
|
Object.defineProperty(this, "inner", {
|
|
6
24
|
enumerable: true,
|
|
@@ -14,6 +32,21 @@ export class LocalAccountSigner {
|
|
|
14
32
|
writable: true,
|
|
15
33
|
value: void 0
|
|
16
34
|
});
|
|
35
|
+
/**
|
|
36
|
+
* Signs the provided message using the inner signMessage function.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
41
|
+
* import { generatePrivateKey } from "viem";
|
|
42
|
+
*
|
|
43
|
+
* const signer = LocalAccountSigner.mnemonicToAccountSigner(generatePrivateKey());
|
|
44
|
+
* const signature = await signer.signMessage("Hello, world!");
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @param {string} message The message to be signed
|
|
48
|
+
* @returns {Promise<any>} A promise that resolves to the signed message
|
|
49
|
+
*/
|
|
17
50
|
Object.defineProperty(this, "signMessage", {
|
|
18
51
|
enumerable: true,
|
|
19
52
|
configurable: true,
|
|
@@ -22,6 +55,26 @@ export class LocalAccountSigner {
|
|
|
22
55
|
return this.inner.signMessage({ message });
|
|
23
56
|
}
|
|
24
57
|
});
|
|
58
|
+
/**
|
|
59
|
+
* Signs typed data using the given parameters.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
64
|
+
* import { generatePrivateKey } from "viem";
|
|
65
|
+
*
|
|
66
|
+
* const signer = LocalAccountSigner.mnemonicToAccountSigner(generatePrivateKey());
|
|
67
|
+
* const signature = await signer.signTypedData({
|
|
68
|
+
* domain: {},
|
|
69
|
+
* types: {},
|
|
70
|
+
* primaryType: "",
|
|
71
|
+
* message: {},
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @param {TypedDataDefinition<TTypedData, TPrimaryType>} params The parameters defining the typed data and primary type
|
|
76
|
+
* @returns {Promise<Hex>} A promise that resolves to the signed data in hexadecimal format
|
|
77
|
+
*/
|
|
25
78
|
Object.defineProperty(this, "signTypedData", {
|
|
26
79
|
enumerable: true,
|
|
27
80
|
configurable: true,
|
|
@@ -30,6 +83,20 @@ export class LocalAccountSigner {
|
|
|
30
83
|
return this.inner.signTypedData(params);
|
|
31
84
|
}
|
|
32
85
|
});
|
|
86
|
+
/**
|
|
87
|
+
* Returns the address of the inner object in a specific hexadecimal format.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
92
|
+
* import { generatePrivateKey } from "viem";
|
|
93
|
+
*
|
|
94
|
+
* const signer = LocalAccountSigner.mnemonicToAccountSigner(generatePrivateKey());
|
|
95
|
+
* const address = await signer.getAddress();
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @returns {Promise<Hex>} A promise that resolves to the address in the format `0x{string}`
|
|
99
|
+
*/
|
|
33
100
|
Object.defineProperty(this, "getAddress", {
|
|
34
101
|
enumerable: true,
|
|
35
102
|
configurable: true,
|
|
@@ -39,13 +106,41 @@ export class LocalAccountSigner {
|
|
|
39
106
|
}
|
|
40
107
|
});
|
|
41
108
|
this.inner = inner;
|
|
42
|
-
this.signerType = inner.type;
|
|
109
|
+
this.signerType = inner.type; // type: "local"
|
|
43
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Creates a LocalAccountSigner using the provided mnemonic key and optional HD options.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
117
|
+
* import { generateMnemonic } from "viem";
|
|
118
|
+
*
|
|
119
|
+
* const signer = LocalAccountSigner.mnemonicToAccountSigner(generateMnemonic());
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* @param {string} key The mnemonic key to derive the account from.
|
|
123
|
+
* @param {HDOptions} [opts] Optional HD options for deriving the account.
|
|
124
|
+
* @returns {LocalAccountSigner<HDAccount>} A LocalAccountSigner object for the derived account.
|
|
125
|
+
*/
|
|
44
126
|
static mnemonicToAccountSigner(key, opts) {
|
|
45
127
|
const signer = mnemonicToAccount(key, opts);
|
|
46
128
|
return new LocalAccountSigner(signer);
|
|
47
129
|
}
|
|
48
|
-
|
|
130
|
+
/**
|
|
131
|
+
* Creates a `LocalAccountSigner` instance using the provided private key.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
136
|
+
* import { generatePrivateKey } from "viem";
|
|
137
|
+
*
|
|
138
|
+
* const signer = LocalAccountSigner.mnemonicToAccountSigner(generatePrivateKey());
|
|
139
|
+
* ```
|
|
140
|
+
*
|
|
141
|
+
* @param {Hex} key The private key in hexadecimal format
|
|
142
|
+
* @returns {LocalAccountSigner<PrivateKeyAccount>} An instance of `LocalAccountSigner` initialized with the provided private key
|
|
143
|
+
*/ static privateKeyToAccountSigner(key) {
|
|
49
144
|
const signer = privateKeyToAccount(key);
|
|
50
145
|
return new LocalAccountSigner(signer);
|
|
51
146
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-account.js","sourceRoot":"","sources":["../../../src/signer/local-account.ts"],"names":[],"mappings":"AAAA,OAAO,EASN,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"local-account.js","sourceRoot":"","sources":["../../../src/signer/local-account.ts"],"names":[],"mappings":"AAAA,OAAO,EASN,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGvE;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAO7B;;;;;;;;;;;;;;OAcG;IACH,YAAY,KAAQ;QAlBpB;;;;;WAAS;QACT;;;;;WAAmB;QAsBnB;;;;;;;;;;;;;;WAcG;QACM;;;;mBAAoE,CAC3E,OAAO,EACP,EAAE;gBACF,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;YAC7C,CAAC;WAAC;QAEF;;;;;;;;;;;;;;;;;;;WAmBG;QACM;;;;mBAAgB,KAAK,EAI5B,MAAqD,EACvC,EAAE;gBAChB,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YAC1C,CAAC;WAAC;QAEF;;;;;;;;;;;;;WAaG;QACM;;;;mBAAa,KAAK,IAA4B,EAAE;gBACvD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;YAC5B,CAAC;WAAC;QAtEA,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,iBAAiB;IACjD,CAAC;IAsED;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,uBAAuB,CAC5B,GAAW,EACX,IAAgB;QAEhB,MAAM,MAAM,GAAG,iBAAiB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC5C,OAAO,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;;;;;;;;OAaG,CAAC,MAAM,CAAC,yBAAyB,CAClC,GAAQ;QAER,MAAM,MAAM,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACxC,OAAO,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["import {\n type HDAccount,\n type HDOptions,\n type Hex,\n type LocalAccount,\n type PrivateKeyAccount,\n type SignableMessage,\n type TypedData,\n type TypedDataDefinition,\n} from \"viem\";\nimport { mnemonicToAccount, privateKeyToAccount } from \"viem/accounts\";\nimport type { SmartAccountSigner } from \"./types.js\";\n\n/**\n * Represents a local account signer and provides methods to sign messages and transactions, as well as static methods to create the signer from mnemonic or private key.\n */\nexport class LocalAccountSigner<\n T extends HDAccount | PrivateKeyAccount | LocalAccount\n> implements SmartAccountSigner<T>\n{\n inner: T;\n signerType: string;\n\n /**\n * A function to initialize an object with an inner parameter and derive a signerType from it.\n *\n * @example\n * ```ts\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { privateKeyToAccount, generatePrivateKey } from \"viem\";\n *\n * const signer = new LocalAccountSigner(\n * privateKeyToAccount(generatePrivateKey()),\n * );\n * ```\n *\n * @param {T} inner The inner parameter containing the necessary data\n */\n constructor(inner: T) {\n this.inner = inner;\n this.signerType = inner.type; // type: \"local\"\n }\n\n /**\n * Signs the provided message using the inner signMessage function.\n *\n * @example\n * ```ts\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\";\n *\n * const signer = LocalAccountSigner.mnemonicToAccountSigner(generatePrivateKey());\n * const signature = await signer.signMessage(\"Hello, world!\");\n * ```\n *\n * @param {string} message The message to be signed\n * @returns {Promise<any>} A promise that resolves to the signed message\n */\n readonly signMessage: (message: SignableMessage) => Promise<`0x${string}`> = (\n message\n ) => {\n return this.inner.signMessage({ message });\n };\n\n /**\n * Signs typed data using the given parameters.\n *\n * @example\n * ```ts\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\";\n *\n * const signer = LocalAccountSigner.mnemonicToAccountSigner(generatePrivateKey());\n * const signature = await signer.signTypedData({\n * domain: {},\n * types: {},\n * primaryType: \"\",\n * message: {},\n * });\n * ```\n *\n * @param {TypedDataDefinition<TTypedData, TPrimaryType>} params The parameters defining the typed data and primary type\n * @returns {Promise<Hex>} A promise that resolves to the signed data in hexadecimal format\n */\n readonly signTypedData = async <\n const TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | \"EIP712Domain\" = keyof TTypedData\n >(\n params: TypedDataDefinition<TTypedData, TPrimaryType>\n ): Promise<Hex> => {\n return this.inner.signTypedData(params);\n };\n\n /**\n * Returns the address of the inner object in a specific hexadecimal format.\n *\n * @example\n * ```ts\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\";\n *\n * const signer = LocalAccountSigner.mnemonicToAccountSigner(generatePrivateKey());\n * const address = await signer.getAddress();\n * ```\n *\n * @returns {Promise<Hex>} A promise that resolves to the address in the format `0x{string}`\n */\n readonly getAddress = async (): Promise<`0x${string}`> => {\n return this.inner.address;\n };\n\n /**\n * Creates a LocalAccountSigner using the provided mnemonic key and optional HD options.\n *\n * @example\n * ```ts\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generateMnemonic } from \"viem\";\n *\n * const signer = LocalAccountSigner.mnemonicToAccountSigner(generateMnemonic());\n * ```\n *\n * @param {string} key The mnemonic key to derive the account from.\n * @param {HDOptions} [opts] Optional HD options for deriving the account.\n * @returns {LocalAccountSigner<HDAccount>} A LocalAccountSigner object for the derived account.\n */\n static mnemonicToAccountSigner(\n key: string,\n opts?: HDOptions\n ): LocalAccountSigner<HDAccount> {\n const signer = mnemonicToAccount(key, opts);\n return new LocalAccountSigner(signer);\n }\n\n /**\n * Creates a `LocalAccountSigner` instance using the provided private key.\n *\n * @example\n * ```ts\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\";\n *\n * const signer = LocalAccountSigner.mnemonicToAccountSigner(generatePrivateKey());\n * ```\n *\n * @param {Hex} key The private key in hexadecimal format\n * @returns {LocalAccountSigner<PrivateKeyAccount>} An instance of `LocalAccountSigner` initialized with the provided private key\n */ static privateKeyToAccountSigner(\n key: Hex\n ): LocalAccountSigner<PrivateKeyAccount> {\n const signer = privateKeyToAccount(key);\n return new LocalAccountSigner(signer);\n }\n}\n"]}
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { SmartAccountSigner } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the provided object is a `SmartAccountSigner`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { isSigner, LocalAccountSigner } from "@aa-sdk/core";
|
|
9
|
+
*
|
|
10
|
+
* const signer = new LocalAccountSigner(...);
|
|
11
|
+
* console.log(isSigner(signer)); // true
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @param {any} signer the object to check
|
|
15
|
+
* @returns {boolean} A boolean indicating whether the object is a `SmartAccountSigner`
|
|
16
|
+
*/
|
|
3
17
|
export declare const isSigner: (signer: any) => signer is SmartAccountSigner<any>;
|
|
4
18
|
export declare const SignerSchema: z.ZodType<SmartAccountSigner<any>, z.ZodTypeDef, SmartAccountSigner<any>>;
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the provided object is a `SmartAccountSigner`.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { isSigner, LocalAccountSigner } from "@aa-sdk/core";
|
|
8
|
+
*
|
|
9
|
+
* const signer = new LocalAccountSigner(...);
|
|
10
|
+
* console.log(isSigner(signer)); // true
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param {any} signer the object to check
|
|
14
|
+
* @returns {boolean} A boolean indicating whether the object is a `SmartAccountSigner`
|
|
15
|
+
*/
|
|
2
16
|
export const isSigner = (signer) => {
|
|
3
17
|
return (signer != null &&
|
|
4
18
|
typeof signer === "object" &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/signer/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/signer/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAW,EAAgC,EAAE;IACpE,OAAO,CACL,MAAM,IAAI,IAAI;QACd,OAAO,MAAM,KAAK,QAAQ;QAC1B,YAAY,IAAI,MAAM;QACtB,aAAa,IAAI,MAAM;QACvB,eAAe,IAAI,MAAM;QACzB,YAAY,IAAI,MAAM;QACtB,OAAO,IAAI,MAAM,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAqB,QAAQ,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type { SmartAccountSigner } from \"./types\";\n\n/**\n * Checks if the provided object is a `SmartAccountSigner`.\n *\n * @example\n * ```ts\n * import { isSigner, LocalAccountSigner } from \"@aa-sdk/core\";\n *\n * const signer = new LocalAccountSigner(...);\n * console.log(isSigner(signer)); // true\n * ```\n *\n * @param {any} signer the object to check\n * @returns {boolean} A boolean indicating whether the object is a `SmartAccountSigner`\n */\nexport const isSigner = (signer: any): signer is SmartAccountSigner => {\n return (\n signer != null &&\n typeof signer === \"object\" &&\n \"signerType\" in signer &&\n \"signMessage\" in signer &&\n \"signTypedData\" in signer &&\n \"getAddress\" in signer &&\n \"inner\" in signer\n );\n};\n\nexport const SignerSchema = z.custom<SmartAccountSigner>(isSigner);\n"]}
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import type { Address } from "abitype";
|
|
2
2
|
import type { Hex, SignableMessage, TypedData, TypedDataDefinition } from "viem";
|
|
3
|
+
/**
|
|
4
|
+
* Extends the @interface SmartAccountSigner interface with authentication.
|
|
5
|
+
*
|
|
6
|
+
* @template AuthParams - the generic type of the authentication parameters
|
|
7
|
+
* @template AuthDetails - the generic type of the authentication details
|
|
8
|
+
* @template Inner - the generic type of the inner client that the signer wraps to provide functionality such as signing, etc.
|
|
9
|
+
*/
|
|
3
10
|
export interface SmartAccountAuthenticator<AuthParams, AuthDetails, Inner = any> extends SmartAccountSigner<Inner> {
|
|
4
11
|
authenticate: (params: AuthParams) => Promise<AuthDetails>;
|
|
5
12
|
getAuthDetails: () => Promise<AuthDetails>;
|
|
6
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* A signer that can sign messages and typed data.
|
|
16
|
+
*
|
|
17
|
+
* @template Inner - the generic type of the inner client that the signer wraps to provide functionality such as signing, etc.
|
|
18
|
+
*/
|
|
7
19
|
export interface SmartAccountSigner<Inner = any> {
|
|
8
20
|
signerType: string;
|
|
9
21
|
inner: Inner;
|
|
10
22
|
getAddress: () => Promise<Address>;
|
|
11
23
|
signMessage: (message: SignableMessage) => Promise<Hex>;
|
|
12
|
-
signTypedData: <const TTypedData extends TypedData |
|
|
13
|
-
[key: string]: unknown;
|
|
14
|
-
}, TPrimaryType extends string = string>(params: TypedDataDefinition<TTypedData, TPrimaryType>) => Promise<Hex>;
|
|
24
|
+
signTypedData: <const TTypedData extends TypedData | Record<string, unknown>, TPrimaryType extends keyof TTypedData | "EIP712Domain" = keyof TTypedData>(params: TypedDataDefinition<TTypedData, TPrimaryType>) => Promise<Hex>;
|
|
15
25
|
}
|
package/dist/esm/signer/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/signer/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Address } from \"abitype\";\nimport type {\n Hex,\n SignableMessage,\n TypedData,\n TypedDataDefinition,\n} from \"viem\";\n\n// [!region SmartAccountAuthenticator]\n/**\n * Extends the @interface SmartAccountSigner interface with authentication.\n *\n * @template AuthParams - the generic type of the authentication parameters\n * @template AuthDetails - the generic type of the authentication details\n * @template Inner - the generic type of the inner client that the signer wraps to provide functionality such as signing, etc.\n */\nexport interface SmartAccountAuthenticator<AuthParams, AuthDetails, Inner = any>\n extends SmartAccountSigner<Inner> {\n authenticate: (params: AuthParams) => Promise<AuthDetails>;\n\n getAuthDetails: () => Promise<AuthDetails>;\n}\n// [!endregion SmartAccountAuthenticator]\n\n// [!region SmartAccountSigner]\n/**\n * A signer that can sign messages and typed data.\n *\n * @template Inner - the generic type of the inner client that the signer wraps to provide functionality such as signing, etc.\n */\nexport interface SmartAccountSigner<Inner = any> {\n signerType: string;\n inner: Inner;\n\n getAddress: () => Promise<Address>;\n\n signMessage: (message: SignableMessage) => Promise<Hex>;\n\n signTypedData: <\n const TTypedData extends TypedData |
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/signer/types.ts"],"names":[],"mappings":";AA6CA,kCAAkC","sourcesContent":["import type { Address } from \"abitype\";\nimport type {\n Hex,\n SignableMessage,\n TypedData,\n TypedDataDefinition,\n} from \"viem\";\n\n// [!region SmartAccountAuthenticator]\n/**\n * Extends the @interface SmartAccountSigner interface with authentication.\n *\n * @template AuthParams - the generic type of the authentication parameters\n * @template AuthDetails - the generic type of the authentication details\n * @template Inner - the generic type of the inner client that the signer wraps to provide functionality such as signing, etc.\n */\nexport interface SmartAccountAuthenticator<AuthParams, AuthDetails, Inner = any>\n extends SmartAccountSigner<Inner> {\n authenticate: (params: AuthParams) => Promise<AuthDetails>;\n\n getAuthDetails: () => Promise<AuthDetails>;\n}\n// [!endregion SmartAccountAuthenticator]\n\n// [!region SmartAccountSigner]\n/**\n * A signer that can sign messages and typed data.\n *\n * @template Inner - the generic type of the inner client that the signer wraps to provide functionality such as signing, etc.\n */\nexport interface SmartAccountSigner<Inner = any> {\n signerType: string;\n inner: Inner;\n\n getAddress: () => Promise<Address>;\n\n signMessage: (message: SignableMessage) => Promise<Hex>;\n\n signTypedData: <\n const TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | \"EIP712Domain\" = keyof TTypedData\n >(\n params: TypedDataDefinition<TTypedData, TPrimaryType>\n ) => Promise<Hex>;\n}\n// [!endregion SmartAccountSigner]\n"]}
|
|
@@ -4,4 +4,24 @@ export type SignWith6492Params = {
|
|
|
4
4
|
factoryCalldata: Hex;
|
|
5
5
|
signature: Hash;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Wraps a given signature with additional data following the EIP-6492 standard.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { wrapSignatureWith6492 } from "@aa-sdk/core";
|
|
13
|
+
*
|
|
14
|
+
* const signature = wrapSignatureWith6492({
|
|
15
|
+
* factoryAddress: "0x...",
|
|
16
|
+
* factoryCalldata: "0x...",
|
|
17
|
+
* signature: "0x...",
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @param {SignWith6492Params} params The parameters to wrap the signature
|
|
22
|
+
* @param {Hex} params.factoryAddress The address of the factory
|
|
23
|
+
* @param {Hex} params.factoryCalldata The calldata for the factory
|
|
24
|
+
* @param {Hex} params.signature The original signature that needs to be wrapped
|
|
25
|
+
* @returns {Hash} The wrapped signature
|
|
26
|
+
*/
|
|
7
27
|
export declare const wrapSignatureWith6492: ({ factoryAddress, factoryCalldata, signature, }: SignWith6492Params) => Hash;
|
package/dist/esm/signer/utils.js
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
import { concat, encodeAbiParameters, parseAbiParameters, } from "viem";
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a given signature with additional data following the EIP-6492 standard.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { wrapSignatureWith6492 } from "@aa-sdk/core";
|
|
8
|
+
*
|
|
9
|
+
* const signature = wrapSignatureWith6492({
|
|
10
|
+
* factoryAddress: "0x...",
|
|
11
|
+
* factoryCalldata: "0x...",
|
|
12
|
+
* signature: "0x...",
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param {SignWith6492Params} params The parameters to wrap the signature
|
|
17
|
+
* @param {Hex} params.factoryAddress The address of the factory
|
|
18
|
+
* @param {Hex} params.factoryCalldata The calldata for the factory
|
|
19
|
+
* @param {Hex} params.signature The original signature that needs to be wrapped
|
|
20
|
+
* @returns {Hash} The wrapped signature
|
|
21
|
+
*/
|
|
2
22
|
export const wrapSignatureWith6492 = ({ factoryAddress, factoryCalldata, signature, }) => {
|
|
23
|
+
// wrap the signature as follows: https://eips.ethereum.org/EIPS/eip-6492
|
|
24
|
+
// concat(
|
|
25
|
+
// abi.encode(
|
|
26
|
+
// (create2Factory, factoryCalldata, originalERC1271Signature),
|
|
27
|
+
// (address, bytes, bytes)),
|
|
28
|
+
// magicBytes
|
|
29
|
+
// )
|
|
3
30
|
return concat([
|
|
4
31
|
encodeAbiParameters(parseAbiParameters("address, bytes, bytes"), [
|
|
5
32
|
factoryAddress,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/signer/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,mBAAmB,EACnB,kBAAkB,GAInB,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/signer/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,mBAAmB,EACnB,kBAAkB,GAInB,MAAM,MAAM,CAAC;AAQd;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EACpC,cAAc,EACd,eAAe,EACf,SAAS,GACU,EAAQ,EAAE;IAC7B,yEAAyE;IACzE,UAAU;IACV,eAAe;IACf,kEAAkE;IAClE,+BAA+B;IAC/B,gBAAgB;IAChB,IAAI;IACJ,OAAO,MAAM,CAAC;QACZ,mBAAmB,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,EAAE;YAC/D,cAAc;YACd,eAAe;YACf,SAAS;SACV,CAAC;QACF,oEAAoE;KACrE,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import {\n concat,\n encodeAbiParameters,\n parseAbiParameters,\n type Address,\n type Hash,\n type Hex,\n} from \"viem\";\n\nexport type SignWith6492Params = {\n factoryAddress: Address;\n factoryCalldata: Hex;\n signature: Hash;\n};\n\n/**\n * Wraps a given signature with additional data following the EIP-6492 standard.\n *\n * @example\n * ```ts\n * import { wrapSignatureWith6492 } from \"@aa-sdk/core\";\n *\n * const signature = wrapSignatureWith6492({\n * factoryAddress: \"0x...\",\n * factoryCalldata: \"0x...\",\n * signature: \"0x...\",\n * });\n * ```\n *\n * @param {SignWith6492Params} params The parameters to wrap the signature\n * @param {Hex} params.factoryAddress The address of the factory\n * @param {Hex} params.factoryCalldata The calldata for the factory\n * @param {Hex} params.signature The original signature that needs to be wrapped\n * @returns {Hash} The wrapped signature\n */\nexport const wrapSignatureWith6492 = ({\n factoryAddress,\n factoryCalldata,\n signature,\n}: SignWith6492Params): Hash => {\n // wrap the signature as follows: https://eips.ethereum.org/EIPS/eip-6492\n // concat(\n // abi.encode(\n // (create2Factory, factoryCalldata, originalERC1271Signature),\n // (address, bytes, bytes)),\n // magicBytes\n // )\n return concat([\n encodeAbiParameters(parseAbiParameters(\"address, bytes, bytes\"), [\n factoryAddress,\n factoryCalldata,\n signature,\n ]),\n \"0x6492649264926492649264926492649264926492649264926492649264926492\",\n ]);\n};\n"]}
|
|
@@ -1,12 +1,104 @@
|
|
|
1
1
|
import { type Hex, type SignableMessage, type TypedDataDefinition, type WalletClient } from "viem";
|
|
2
2
|
import type { SmartAccountSigner } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, and sign typed data.
|
|
5
|
+
*/
|
|
3
6
|
export declare class WalletClientSigner implements SmartAccountSigner<WalletClient> {
|
|
4
7
|
signerType: string;
|
|
5
8
|
inner: WalletClient;
|
|
9
|
+
/**
|
|
10
|
+
* Initializes a signer with a given wallet client and signer type.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { WalletClientSigner } from "@aa-sdk/core";
|
|
15
|
+
* import { createWalletClient, custom } from 'viem'
|
|
16
|
+
* import { mainnet } from 'viem/chains'
|
|
17
|
+
*
|
|
18
|
+
* const client = createWalletClient({
|
|
19
|
+
* chain: mainnet,
|
|
20
|
+
* transport: custom(window.ethereum!)
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* const signer = new WalletClientSigner(client, 'wallet');
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @param {WalletClient} client The wallet client to interact with
|
|
27
|
+
* @param {string} signerType The type of signer; must be a valid signer type, otherwise an error will be thrown
|
|
28
|
+
* @throws {InvalidSignerTypeError} If the signer type is invalid
|
|
29
|
+
*/
|
|
6
30
|
constructor(client: WalletClient, signerType: string);
|
|
31
|
+
/**
|
|
32
|
+
* Asynchronously retrieves addresses from the inner object and returns the first address after applying the `getAddress` function.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { WalletClientSigner } from "@aa-sdk/core";
|
|
37
|
+
* import { createWalletClient, custom } from 'viem'
|
|
38
|
+
* import { mainnet } from 'viem/chains'
|
|
39
|
+
*
|
|
40
|
+
* const client = createWalletClient({
|
|
41
|
+
* chain: mainnet,
|
|
42
|
+
* transport: custom(window.ethereum!)
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* const signer = new WalletClientSigner(client, 'wallet');
|
|
46
|
+
* console.log(await signer.getAddress());
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @returns {Promise<string>} A promise that resolves to the first address after being processed by the `getAddress` function.
|
|
50
|
+
*/
|
|
7
51
|
getAddress: () => Promise<`0x${string}`>;
|
|
52
|
+
/**
|
|
53
|
+
* Signs a message using the account's signing method.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { WalletClientSigner } from "@aa-sdk/core";
|
|
58
|
+
* import { createWalletClient, custom } from 'viem'
|
|
59
|
+
* import { mainnet } from 'viem/chains'
|
|
60
|
+
*
|
|
61
|
+
* const client = createWalletClient({
|
|
62
|
+
* chain: mainnet,
|
|
63
|
+
* transport: custom(window.ethereum!)
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* const signer = new WalletClientSigner(client, 'wallet');
|
|
67
|
+
* console.log(await signer.signMessage("hello"));
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @param {string} message the message string that needs to be signed
|
|
71
|
+
* @returns {Promise<string>} a promise that resolves to the signed message
|
|
72
|
+
*/
|
|
8
73
|
readonly signMessage: (message: SignableMessage) => Promise<`0x${string}`>;
|
|
9
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Signs the provided typed data using the account's private key.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* import { WalletClientSigner } from "@aa-sdk/core";
|
|
80
|
+
* import { createWalletClient, custom } from 'viem'
|
|
81
|
+
* import { mainnet } from 'viem/chains'
|
|
82
|
+
*
|
|
83
|
+
* const client = createWalletClient({
|
|
84
|
+
* chain: mainnet,
|
|
85
|
+
* transport: custom(window.ethereum!)
|
|
86
|
+
* });
|
|
87
|
+
*
|
|
88
|
+
* const signer = new WalletClientSigner(client, 'wallet');
|
|
89
|
+
* console.log(await signer.signTypedData({
|
|
90
|
+
* types: {
|
|
91
|
+
* "Message": [{ name: "content", type: "string" }]
|
|
92
|
+
* },
|
|
93
|
+
* primaryType: "Message",
|
|
94
|
+
* message: { content: "Hello" },
|
|
95
|
+
* }));
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @param {TypedDataDefinition<TTypedData, TPrimaryType>} typedData The typed data to be signed
|
|
99
|
+
* @returns {Promise<Hex>} A promise that resolves to a hex string representing the signed data
|
|
100
|
+
*/
|
|
101
|
+
signTypedData: <const TTypedData extends Record<string, unknown> | {
|
|
10
102
|
[x: string]: readonly import("viem").TypedDataParameter[];
|
|
11
103
|
[x: `string[${string}]`]: undefined;
|
|
12
104
|
[x: `function[${string}]`]: undefined;
|
|
@@ -211,7 +303,5 @@ export declare class WalletClientSigner implements SmartAccountSigner<WalletClie
|
|
|
211
303
|
uint232?: undefined;
|
|
212
304
|
uint240?: undefined;
|
|
213
305
|
uint248?: undefined;
|
|
214
|
-
} |
|
|
215
|
-
[key: string]: unknown;
|
|
216
|
-
}, TPrimaryType extends string = string>(typedData: TypedDataDefinition<TTypedData, TPrimaryType>) => Promise<Hex>;
|
|
306
|
+
}, TPrimaryType extends string | keyof TTypedData = string>(typedData: TypedDataDefinition<TTypedData, TPrimaryType>) => Promise<Hex>;
|
|
217
307
|
}
|
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
import { getAddress, } from "viem";
|
|
2
2
|
import { InvalidSignerTypeError } from "../errors/signer.js";
|
|
3
|
+
/**
|
|
4
|
+
* Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, and sign typed data.
|
|
5
|
+
*/
|
|
3
6
|
export class WalletClientSigner {
|
|
7
|
+
/**
|
|
8
|
+
* Initializes a signer with a given wallet client and signer type.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { WalletClientSigner } from "@aa-sdk/core";
|
|
13
|
+
* import { createWalletClient, custom } from 'viem'
|
|
14
|
+
* import { mainnet } from 'viem/chains'
|
|
15
|
+
*
|
|
16
|
+
* const client = createWalletClient({
|
|
17
|
+
* chain: mainnet,
|
|
18
|
+
* transport: custom(window.ethereum!)
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* const signer = new WalletClientSigner(client, 'wallet');
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @param {WalletClient} client The wallet client to interact with
|
|
25
|
+
* @param {string} signerType The type of signer; must be a valid signer type, otherwise an error will be thrown
|
|
26
|
+
* @throws {InvalidSignerTypeError} If the signer type is invalid
|
|
27
|
+
*/
|
|
4
28
|
constructor(client, signerType) {
|
|
5
29
|
Object.defineProperty(this, "signerType", {
|
|
6
30
|
enumerable: true,
|
|
@@ -14,6 +38,26 @@ export class WalletClientSigner {
|
|
|
14
38
|
writable: true,
|
|
15
39
|
value: void 0
|
|
16
40
|
});
|
|
41
|
+
/**
|
|
42
|
+
* Asynchronously retrieves addresses from the inner object and returns the first address after applying the `getAddress` function.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* import { WalletClientSigner } from "@aa-sdk/core";
|
|
47
|
+
* import { createWalletClient, custom } from 'viem'
|
|
48
|
+
* import { mainnet } from 'viem/chains'
|
|
49
|
+
*
|
|
50
|
+
* const client = createWalletClient({
|
|
51
|
+
* chain: mainnet,
|
|
52
|
+
* transport: custom(window.ethereum!)
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* const signer = new WalletClientSigner(client, 'wallet');
|
|
56
|
+
* console.log(await signer.getAddress());
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @returns {Promise<string>} A promise that resolves to the first address after being processed by the `getAddress` function.
|
|
60
|
+
*/
|
|
17
61
|
Object.defineProperty(this, "getAddress", {
|
|
18
62
|
enumerable: true,
|
|
19
63
|
configurable: true,
|
|
@@ -23,6 +67,27 @@ export class WalletClientSigner {
|
|
|
23
67
|
return getAddress(addresses[0]);
|
|
24
68
|
}
|
|
25
69
|
});
|
|
70
|
+
/**
|
|
71
|
+
* Signs a message using the account's signing method.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* import { WalletClientSigner } from "@aa-sdk/core";
|
|
76
|
+
* import { createWalletClient, custom } from 'viem'
|
|
77
|
+
* import { mainnet } from 'viem/chains'
|
|
78
|
+
*
|
|
79
|
+
* const client = createWalletClient({
|
|
80
|
+
* chain: mainnet,
|
|
81
|
+
* transport: custom(window.ethereum!)
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* const signer = new WalletClientSigner(client, 'wallet');
|
|
85
|
+
* console.log(await signer.signMessage("hello"));
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @param {string} message the message string that needs to be signed
|
|
89
|
+
* @returns {Promise<string>} a promise that resolves to the signed message
|
|
90
|
+
*/
|
|
26
91
|
Object.defineProperty(this, "signMessage", {
|
|
27
92
|
enumerable: true,
|
|
28
93
|
configurable: true,
|
|
@@ -32,16 +97,44 @@ export class WalletClientSigner {
|
|
|
32
97
|
return this.inner.signMessage({ message, account });
|
|
33
98
|
}
|
|
34
99
|
});
|
|
100
|
+
/**
|
|
101
|
+
* Signs the provided typed data using the account's private key.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* import { WalletClientSigner } from "@aa-sdk/core";
|
|
106
|
+
* import { createWalletClient, custom } from 'viem'
|
|
107
|
+
* import { mainnet } from 'viem/chains'
|
|
108
|
+
*
|
|
109
|
+
* const client = createWalletClient({
|
|
110
|
+
* chain: mainnet,
|
|
111
|
+
* transport: custom(window.ethereum!)
|
|
112
|
+
* });
|
|
113
|
+
*
|
|
114
|
+
* const signer = new WalletClientSigner(client, 'wallet');
|
|
115
|
+
* console.log(await signer.signTypedData({
|
|
116
|
+
* types: {
|
|
117
|
+
* "Message": [{ name: "content", type: "string" }]
|
|
118
|
+
* },
|
|
119
|
+
* primaryType: "Message",
|
|
120
|
+
* message: { content: "Hello" },
|
|
121
|
+
* }));
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* @param {TypedDataDefinition<TTypedData, TPrimaryType>} typedData The typed data to be signed
|
|
125
|
+
* @returns {Promise<Hex>} A promise that resolves to a hex string representing the signed data
|
|
126
|
+
*/
|
|
35
127
|
Object.defineProperty(this, "signTypedData", {
|
|
36
128
|
enumerable: true,
|
|
37
129
|
configurable: true,
|
|
38
130
|
writable: true,
|
|
39
131
|
value: async (typedData) => {
|
|
40
132
|
const account = this.inner.account ?? (await this.getAddress());
|
|
41
|
-
|
|
133
|
+
const params = {
|
|
42
134
|
account,
|
|
43
135
|
...typedData,
|
|
44
|
-
}
|
|
136
|
+
};
|
|
137
|
+
return this.inner.signTypedData(params);
|
|
45
138
|
}
|
|
46
139
|
});
|
|
47
140
|
this.inner = client;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-client.js","sourceRoot":"","sources":["../../../src/signer/wallet-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,GAMX,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"wallet-client.js","sourceRoot":"","sources":["../../../src/signer/wallet-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,GAMX,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAG7D;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAI7B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAAY,MAAoB,EAAE,UAAkB;QAxBpD;;;;;WAAmB;QACnB;;;;;WAAoB;QA+BpB;;;;;;;;;;;;;;;;;;;WAmBG;QACH;;;;mBAA2C,KAAK,IAAI,EAAE;gBACpD,IAAI,SAAS,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;gBAChD,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YAClC,CAAC;WAAC;QAEF;;;;;;;;;;;;;;;;;;;;WAoBG;QACM;;;;mBACP,KAAK,EAAE,OAAO,EAAE,EAAE;gBAChB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;gBAEhE,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;YACtD,CAAC;WAAC;QAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;WA0BG;QACH;;;;mBAAgB,KAAK,EAInB,SAAwD,EAC1C,EAAE;gBAChB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;gBAEhE,MAAM,MAAM,GAAG;oBACb,OAAO;oBACP,GAAG,SAAS;iBACuD,CAAC;gBAEtE,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAqB,MAAM,CAAC,CAAC;YAC9D,CAAC;WAAC;QArGA,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC;QACpB,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,sBAAsB,CAAC,UAAU,CAAC,CAAC;QAC/C,CAAC;QACD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CAiGF","sourcesContent":["import {\n getAddress,\n type Hex,\n type SignableMessage,\n type TypedData,\n type TypedDataDefinition,\n type WalletClient,\n} from \"viem\";\nimport type { Account } from \"viem/accounts\";\nimport type { SignTypedDataParameters } from \"viem/actions\";\nimport { InvalidSignerTypeError } from \"../errors/signer.js\";\nimport type { SmartAccountSigner } from \"./types\";\n\n/**\n * Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, and sign typed data.\n */\nexport class WalletClientSigner implements SmartAccountSigner<WalletClient> {\n signerType: string;\n inner: WalletClient;\n\n /**\n * Initializes a signer with a given wallet client and signer type.\n *\n * @example\n * ```ts\n * import { WalletClientSigner } from \"@aa-sdk/core\";\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum!)\n * });\n *\n * const signer = new WalletClientSigner(client, 'wallet');\n * ```\n *\n * @param {WalletClient} client The wallet client to interact with\n * @param {string} signerType The type of signer; must be a valid signer type, otherwise an error will be thrown\n * @throws {InvalidSignerTypeError} If the signer type is invalid\n */\n constructor(client: WalletClient, signerType: string) {\n this.inner = client;\n if (!signerType) {\n throw new InvalidSignerTypeError(signerType);\n }\n this.signerType = signerType;\n }\n\n /**\n * Asynchronously retrieves addresses from the inner object and returns the first address after applying the `getAddress` function.\n *\n * @example\n * ```ts\n * import { WalletClientSigner } from \"@aa-sdk/core\";\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum!)\n * });\n *\n * const signer = new WalletClientSigner(client, 'wallet');\n * console.log(await signer.getAddress());\n * ```\n *\n * @returns {Promise<string>} A promise that resolves to the first address after being processed by the `getAddress` function.\n */\n getAddress: () => Promise<`0x${string}`> = async () => {\n let addresses = await this.inner.getAddresses();\n return getAddress(addresses[0]);\n };\n\n /**\n * Signs a message using the account's signing method.\n *\n * @example\n * ```ts\n * import { WalletClientSigner } from \"@aa-sdk/core\";\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum!)\n * });\n *\n * const signer = new WalletClientSigner(client, 'wallet');\n * console.log(await signer.signMessage(\"hello\"));\n * ```\n *\n * @param {string} message the message string that needs to be signed\n * @returns {Promise<string>} a promise that resolves to the signed message\n */\n readonly signMessage: (message: SignableMessage) => Promise<`0x${string}`> =\n async (message) => {\n const account = this.inner.account ?? (await this.getAddress());\n\n return this.inner.signMessage({ message, account });\n };\n\n /**\n * Signs the provided typed data using the account's private key.\n *\n * @example\n * ```ts\n * import { WalletClientSigner } from \"@aa-sdk/core\";\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum!)\n * });\n *\n * const signer = new WalletClientSigner(client, 'wallet');\n * console.log(await signer.signTypedData({\n * types: {\n * \"Message\": [{ name: \"content\", type: \"string\" }]\n * },\n * primaryType: \"Message\",\n * message: { content: \"Hello\" },\n * }));\n * ```\n *\n * @param {TypedDataDefinition<TTypedData, TPrimaryType>} typedData The typed data to be signed\n * @returns {Promise<Hex>} A promise that resolves to a hex string representing the signed data\n */\n signTypedData = async <\n const TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | \"EIP712Domain\" | string = string\n >(\n typedData: TypedDataDefinition<TTypedData, TPrimaryType>\n ): Promise<Hex> => {\n const account = this.inner.account ?? (await this.getAddress());\n\n const params = {\n account,\n ...typedData,\n } as SignTypedDataParameters<TTypedData, string, Account | undefined>;\n\n return this.inner.signTypedData<TTypedData, string>(params);\n };\n}\n"]}
|
|
@@ -6,4 +6,36 @@ export interface SplitTransportParams {
|
|
|
6
6
|
}[];
|
|
7
7
|
fallback: Transport;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* The Split Transport allows you to split RPC traffic for specific methods across
|
|
11
|
+
* different RPC providers. This is done by specifying the methods you want handled
|
|
12
|
+
* specially as overrides and providing a fallback transport for all other methods.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { createPublicClient, http } from "viem";
|
|
17
|
+
* import { split } from "@aa-sdk/core";
|
|
18
|
+
*
|
|
19
|
+
* const bundlerMethods = [
|
|
20
|
+
* "eth_sendUserOperation",
|
|
21
|
+
* "eth_estimateUserOperationGas",
|
|
22
|
+
* "eth_getUserOperationReceipt",
|
|
23
|
+
* "eth_getUserOperationByHash",
|
|
24
|
+
* "eth_supportedEntryPoints"
|
|
25
|
+
* ];
|
|
26
|
+
*
|
|
27
|
+
* const clientWithSplit = createPublicClient({
|
|
28
|
+
* transport: split({
|
|
29
|
+
* overrides: [{
|
|
30
|
+
* methods: bundlerMethods,
|
|
31
|
+
* transport: http(BUNDLER_RPC_URL)
|
|
32
|
+
* }],
|
|
33
|
+
* fallback: http(OTHER_RPC_URL)
|
|
34
|
+
* }),
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @param {SplitTransportParams} params split transport configuration containing the methods overrides and fallback transport
|
|
39
|
+
* @returns {CustomTransport} a viem Transport that splits traffic
|
|
40
|
+
*/
|
|
9
41
|
export declare const split: (params: SplitTransportParams) => CustomTransport;
|