@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,4 +1,36 @@
|
|
|
1
1
|
import { custom } from "viem";
|
|
2
|
+
/**
|
|
3
|
+
* The Split Transport allows you to split RPC traffic for specific methods across
|
|
4
|
+
* different RPC providers. This is done by specifying the methods you want handled
|
|
5
|
+
* specially as overrides and providing a fallback transport for all other methods.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createPublicClient, http } from "viem";
|
|
10
|
+
* import { split } from "@aa-sdk/core";
|
|
11
|
+
*
|
|
12
|
+
* const bundlerMethods = [
|
|
13
|
+
* "eth_sendUserOperation",
|
|
14
|
+
* "eth_estimateUserOperationGas",
|
|
15
|
+
* "eth_getUserOperationReceipt",
|
|
16
|
+
* "eth_getUserOperationByHash",
|
|
17
|
+
* "eth_supportedEntryPoints"
|
|
18
|
+
* ];
|
|
19
|
+
*
|
|
20
|
+
* const clientWithSplit = createPublicClient({
|
|
21
|
+
* transport: split({
|
|
22
|
+
* overrides: [{
|
|
23
|
+
* methods: bundlerMethods,
|
|
24
|
+
* transport: http(BUNDLER_RPC_URL)
|
|
25
|
+
* }],
|
|
26
|
+
* fallback: http(OTHER_RPC_URL)
|
|
27
|
+
* }),
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param {SplitTransportParams} params split transport configuration containing the methods overrides and fallback transport
|
|
32
|
+
* @returns {CustomTransport} a viem Transport that splits traffic
|
|
33
|
+
*/
|
|
2
34
|
export const split = (params) => {
|
|
3
35
|
const overrideMap = params.overrides.reduce((accum, curr) => {
|
|
4
36
|
curr.methods.forEach((method) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split.js","sourceRoot":"","sources":["../../../src/transport/split.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAwC,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"split.js","sourceRoot":"","sources":["../../../src/transport/split.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAwC,MAAM,MAAM,CAAC;AAUpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,MAA4B,EAAmB,EAAE;IACrE,MAAM,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QAC1D,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YAC9B,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC;gBAC9D,MAAM,IAAI,KAAK,CACb,uDAAuD,CACxD,CAAC;YACJ,CAAC;YAED,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACf,CAAC,EAAE,IAAI,GAAG,EAAqB,CAAC,CAAC;IAEjC,OAAO,CAAC,IAAI,EAAE,EAAE,CACd,MAAM,CAAC;QACL,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YACtB,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACvD,IAAI,iBAAiB,IAAI,IAAI,EAAE,CAAC;gBAC9B,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC/C,CAAC;YAED,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7C,CAAC;KACF,CAAC,CAAC,IAAI,CAAC,CAAC;AACb,CAAC,CAAC","sourcesContent":["import { custom, type CustomTransport, type Transport } from \"viem\";\n\nexport interface SplitTransportParams {\n overrides: {\n methods: string[];\n transport: Transport;\n }[];\n fallback: Transport;\n}\n\n/**\n * The Split Transport allows you to split RPC traffic for specific methods across\n * different RPC providers. This is done by specifying the methods you want handled\n * specially as overrides and providing a fallback transport for all other methods.\n *\n * @example\n * ```ts\n * import { createPublicClient, http } from \"viem\";\n * import { split } from \"@aa-sdk/core\";\n *\n * const bundlerMethods = [\n * \"eth_sendUserOperation\",\n * \"eth_estimateUserOperationGas\",\n * \"eth_getUserOperationReceipt\",\n * \"eth_getUserOperationByHash\",\n * \"eth_supportedEntryPoints\"\n * ];\n *\n * const clientWithSplit = createPublicClient({\n * transport: split({\n * overrides: [{\n * methods: bundlerMethods,\n * transport: http(BUNDLER_RPC_URL)\n * }],\n * fallback: http(OTHER_RPC_URL)\n * }),\n * });\n * ```\n *\n * @param {SplitTransportParams} params split transport configuration containing the methods overrides and fallback transport\n * @returns {CustomTransport} a viem Transport that splits traffic\n */\nexport const split = (params: SplitTransportParams): CustomTransport => {\n const overrideMap = params.overrides.reduce((accum, curr) => {\n curr.methods.forEach((method) => {\n if (accum.has(method) && accum.get(method) !== curr.transport) {\n throw new Error(\n \"A method cannot be handled by more than one transport\"\n );\n }\n\n accum.set(method, curr.transport);\n });\n\n return accum;\n }, new Map<string, Transport>());\n\n return (opts) =>\n custom({\n request: async (args) => {\n const transportOverride = overrideMap.get(args.method);\n if (transportOverride != null) {\n return transportOverride(opts).request(args);\n }\n\n return params.fallback(opts).request(args);\n },\n })(opts);\n};\n"]}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -37,7 +37,22 @@ export type UserOperationOverrides<TEntryPointVersion extends EntryPointVersion
|
|
|
37
37
|
maxPriorityFeePerGas: UserOperationStruct<TEntryPointVersion>["maxPriorityFeePerGas"] | Multiplier;
|
|
38
38
|
preVerificationGas: UserOperationStruct<TEntryPointVersion>["preVerificationGas"] | Multiplier;
|
|
39
39
|
verificationGasLimit: UserOperationStruct<TEntryPointVersion>["verificationGasLimit"] | Multiplier;
|
|
40
|
+
/**
|
|
41
|
+
* This can be used to override the key used when calling `entryPoint.getNonce`
|
|
42
|
+
* It is useful when you want to use parallel nonces for user operations
|
|
43
|
+
*
|
|
44
|
+
* NOTE: not all bundlers fully support this feature and it could be that your bundler will still only include
|
|
45
|
+
* one user operation for your account in a bundle
|
|
46
|
+
*/
|
|
40
47
|
nonceKey: bigint;
|
|
48
|
+
/**
|
|
49
|
+
* The same state overrides for
|
|
50
|
+
* [`eth_call`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-eth#eth-call) method.
|
|
51
|
+
* An address-to-state mapping, where each entry specifies some state to be ephemerally overridden
|
|
52
|
+
* prior to executing the call. State overrides allow you to customize the network state for
|
|
53
|
+
* the purpose of the simulation, so this feature is useful when you need to estimate gas
|
|
54
|
+
* for user operation scenarios under conditions that aren’t currently present on the live network.
|
|
55
|
+
*/
|
|
41
56
|
stateOverride: StateOverride;
|
|
42
57
|
} & UserOperationPaymasterOverrides<TEntryPointVersion>>;
|
|
43
58
|
export interface UserOperationRequest_v6 {
|
|
@@ -97,6 +112,7 @@ export interface UserOperationReceipt {
|
|
|
97
112
|
logs: string[];
|
|
98
113
|
receipt: TransactionReceipt;
|
|
99
114
|
}
|
|
115
|
+
/** @deprecated use viem type TransactionReceipt instead */
|
|
100
116
|
export interface UserOperationReceiptObject {
|
|
101
117
|
blockHash: Hash;
|
|
102
118
|
blockNumber: BigNumberish;
|
|
@@ -114,6 +130,7 @@ export interface UserOperationReceiptObject {
|
|
|
114
130
|
effectiveGasPrice: BigNumberish;
|
|
115
131
|
type: string;
|
|
116
132
|
}
|
|
133
|
+
/** @deprecated use viem type Log instead */
|
|
117
134
|
export interface UserOperationReceiptLog {
|
|
118
135
|
blockHash: Hash;
|
|
119
136
|
blockNumber: BigNumberish;
|
package/dist/esm/types.js
CHANGED
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAMN,MAAM,MAAM,CAAC","sourcesContent":["import {\n type Address,\n type Hash,\n type Hex,\n type StateOverride,\n type TransactionReceipt,\n} from \"viem\";\nimport type { z } from \"zod\";\nimport type {\n UserOperationFeeOptionsFieldSchema,\n UserOperationFeeOptionsSchema,\n UserOperationFeeOptionsSchema_v6,\n UserOperationFeeOptionsSchema_v7,\n} from \"./client/schema\";\nimport type { EntryPointVersion } from \"./entrypoint/types\";\nimport type {\n BigNumberishRangeSchema,\n BigNumberishSchema,\n MultiplierSchema,\n NoUndefined,\n} from \"./utils\";\n\nexport type EmptyHex = `0x`;\nexport type NullAddress = `0x0`;\n\n// based on @account-abstraction/common\nexport type PromiseOrValue<T> = T | Promise<T>;\nexport type BytesLike = Uint8Array | Hex;\nexport type Multiplier = z.input<typeof MultiplierSchema>;\n\nexport type BigNumberish = z.input<typeof BigNumberishSchema>;\nexport type BigNumberishRange = z.input<typeof BigNumberishRangeSchema>;\n\n// [!region UserOperationCallData]\nexport type UserOperationCallData =\n | {\n /* the target of the call */\n target: Address;\n /* the data passed to the target */\n data: Hex;\n /* the amount of native token to send to the target (default: 0) */\n value?: bigint;\n }\n | Hex;\n// [!endregion UserOperationCallData]\n\n// [!region BatchUserOperationCallData]\nexport type BatchUserOperationCallData = Exclude<UserOperationCallData, Hex>[];\n// [!endregion BatchUserOperationCallData]\n\nexport type UserOperationFeeOptionsField = z.input<\n typeof UserOperationFeeOptionsFieldSchema\n>;\n\nexport type UserOperationFeeOptions<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = TEntryPointVersion extends \"0.6.0\"\n ? z.input<typeof UserOperationFeeOptionsSchema_v6>\n : TEntryPointVersion extends \"0.7.0\"\n ? z.input<typeof UserOperationFeeOptionsSchema_v7>\n : z.input<typeof UserOperationFeeOptionsSchema>;\n\nexport type UserOperationOverridesParameter<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion,\n Required extends boolean = false\n> = Required extends true\n ? { overrides: UserOperationOverrides<TEntryPointVersion> }\n : { overrides?: UserOperationOverrides<TEntryPointVersion> };\n\n// [!region UserOperationPaymasterOverrides]\nexport type UserOperationPaymasterOverrides<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = TEntryPointVersion extends \"0.6.0\"\n ? {\n // paymasterData overrides to bypass paymaster middleware\n paymasterAndData: Hex;\n }\n : TEntryPointVersion extends \"0.7.0\"\n ? {\n // paymasterData overrides to bypass paymaster middleware\n // if set to '0x', all paymaster related fields are omitted from the user op request\n paymasterData: Hex;\n paymaster: Address;\n paymasterVerificationGasLimit:\n | NoUndefined<\n UserOperationStruct<\"0.7.0\">[\"paymasterVerificationGasLimit\"]\n >\n | Multiplier;\n paymasterPostOpGasLimit:\n | NoUndefined<UserOperationStruct<\"0.7.0\">[\"paymasterPostOpGasLimit\"]>\n | Multiplier;\n }\n : {};\n// [!endregion UserOperationOverridesParameter]\n\n// [!region UserOperationOverrides]\nexport type UserOperationOverrides<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = Partial<\n {\n callGasLimit:\n | UserOperationStruct<TEntryPointVersion>[\"callGasLimit\"]\n | Multiplier;\n maxFeePerGas:\n | UserOperationStruct<TEntryPointVersion>[\"maxFeePerGas\"]\n | Multiplier;\n maxPriorityFeePerGas:\n | UserOperationStruct<TEntryPointVersion>[\"maxPriorityFeePerGas\"]\n | Multiplier;\n preVerificationGas:\n | UserOperationStruct<TEntryPointVersion>[\"preVerificationGas\"]\n | Multiplier;\n verificationGasLimit:\n | UserOperationStruct<TEntryPointVersion>[\"verificationGasLimit\"]\n | Multiplier;\n /**\n * This can be used to override the key used when calling `entryPoint.getNonce`\n * It is useful when you want to use parallel nonces for user operations\n *\n * NOTE: not all bundlers fully support this feature and it could be that your bundler will still only include\n * one user operation for your account in a bundle\n */\n nonceKey: bigint;\n\n /**\n * The same state overrides for\n * [`eth_call`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-eth#eth-call) method.\n * An address-to-state mapping, where each entry specifies some state to be ephemerally overridden\n * prior to executing the call. State overrides allow you to customize the network state for\n * the purpose of the simulation, so this feature is useful when you need to estimate gas\n * for user operation scenarios under conditions that aren’t currently present on the live network.\n */\n stateOverride: StateOverride;\n } & UserOperationPaymasterOverrides<TEntryPointVersion>\n>;\n// [!endregion UserOperationOverrides]\n\n// [!region UserOperationRequest_v6]\n// represents the request as it needs to be formatted for v0.6 RPC requests\n// Reference: https://github.com/ethereum/ERCs/blob/8dd085d159cb123f545c272c0d871a5339550e79/ERCS/erc-4337.md#definitions\nexport interface UserOperationRequest_v6 {\n /* the origin of the request */\n sender: Address;\n /* nonce (as hex) of the transaction, returned from the entry point for this Address */\n nonce: Hex;\n /* the initCode for creating the sender if it does not exist yet, otherwise \"0x\" */\n initCode: Hex | EmptyHex;\n /* the callData passed to the target */\n callData: Hex;\n /* Gas value (as hex) used by inner account execution */\n callGasLimit: Hex;\n /* Actual gas (as hex) used by the validation of this UserOperation */\n verificationGasLimit: Hex;\n /* Gas overhead (as hex) of this UserOperation */\n preVerificationGas: Hex;\n /* Maximum fee per gas (similar to EIP-1559 max_fee_per_gas) (as hex)*/\n maxFeePerGas: Hex;\n /* Maximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas) (as hex)*/\n maxPriorityFeePerGas: Hex;\n /* Address of paymaster sponsoring the transaction, followed by extra data to send to the paymaster (\"0x\" for self-sponsored transaction) */\n paymasterAndData: Hex | EmptyHex;\n /* Data passed into the account along with the nonce during the verification step */\n signature: Hex;\n}\n// [!endregion UserOperationRequest_v6]\n\n// [!region UserOperationRequest_v7]\n// represents the request as it needs to be formatted for v0.7 RPC requests\n// Reference: https://eips.ethereum.org/EIPS/eip-4337#definitions\nexport interface UserOperationRequest_v7 {\n /* the account making the operation */\n sender: Address;\n /* anti-replay parameter. nonce of the transaction, returned from the entry point for this address */\n nonce: Hex;\n /* account factory, only for new accounts */\n factory?: Address;\n /* data for account factory (only if account factory exists) */\n factoryData?: Hex;\n /* the data to pass to the sender during the main execution call */\n callData: Hex;\n /* the amount of gas to allocate the main execution call */\n callGasLimit: Hex;\n /* the amount of gas to allocate for the verification step */\n verificationGasLimit: Hex;\n /* extra gas to pay the bunder */\n preVerificationGas: Hex;\n /* maximum fee per gas (similar to EIP-1559 max_fee_per_gas) */\n maxFeePerGas: Hex;\n /* maximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas) */\n maxPriorityFeePerGas: Hex;\n /* address of paymaster contract, (or empty, if account pays for itself) */\n paymaster?: Address;\n /* the amount of gas to allocate for the paymaster validation code */\n paymasterVerificationGasLimit?: Hex;\n /* the amount of gas to allocate for the paymaster post-operation code */\n paymasterPostOpGasLimit?: Hex;\n /* data for paymaster (only if paymaster exists) */\n paymasterData?: Hex;\n /* data passed into the account to verify authorization */\n signature: Hex;\n}\n// [!endregion UserOperationRequest_v7]\n\n// [!region UserOperationRequest]\n// Reference: https://eips.ethereum.org/EIPS/eip-4337#definitions\nexport type UserOperationRequest<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = TEntryPointVersion extends \"0.6.0\"\n ? UserOperationRequest_v6\n : TEntryPointVersion extends \"0.7.0\"\n ? UserOperationRequest_v7\n : never;\n\n// [!endregion UserOperationRequest]\n\n// [!region UserOperationEstimateGasResponse]\nexport interface UserOperationEstimateGasResponse<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> {\n /* Gas overhead of this UserOperation */\n preVerificationGas: BigNumberish;\n /* Actual gas used by the validation of this UserOperation */\n verificationGasLimit: BigNumberish;\n /* Value used by inner account execution */\n callGasLimit: BigNumberish;\n /*\n * EntryPoint v0.7.0 operations only.\n * The amount of gas to allocate for the paymaster validation code.\n * Note: `eth_estimateUserOperationGas` does not return paymasterPostOpGasLimit.\n */\n paymasterVerificationGasLimit: TEntryPointVersion extends \"0.7.0\"\n ? BigNumberish | undefined\n : never;\n}\n// [!endregion UserOperationEstimateGasResponse]\n\n// [!region UserOperationResponse]\nexport interface UserOperationResponse<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> {\n /* the User Operation */\n userOperation: UserOperationRequest<TEntryPointVersion>;\n /* the address of the entry point contract that executed the user operation */\n entryPoint: Address;\n /* the block number the user operation was included in */\n blockNumber: BigNumberish;\n /* the hash of the block the user operation was included in */\n blockHash: Hash;\n /* the hash of the transaction that included the user operation */\n transactionHash: Hash;\n}\n// [!endregion UserOperationResponse]\n\n// [!region UserOperationReceipt]\nexport interface UserOperationReceipt {\n /* The request hash of the UserOperation. */\n userOpHash: Hash;\n /* The entry point address used for the UserOperation. */\n entryPoint: Address;\n /* The account initiating the UserOperation. */\n sender: Address;\n /* The nonce used in the UserOperation. */\n nonce: BigNumberish;\n /* The paymaster used for this UserOperation (or empty). */\n paymaster?: Address;\n /* The actual amount paid (by account or paymaster) for this UserOperation. */\n actualGasCost: BigNumberish;\n /* The total gas used by this UserOperation (including preVerification, creation, validation, and execution). */\n actualGasUsed: BigNumberish;\n /* Indicates whether the execution completed without reverting. */\n success: boolean;\n /* In case of revert, this is the revert reason. */\n reason?: string;\n /* The logs generated by this UserOperation (not including logs of other UserOperations in the same bundle). */\n logs: string[];\n /* The TransactionReceipt object for the entire bundle, not only for this UserOperation. */\n receipt: TransactionReceipt;\n}\n// [!endregion UserOperationReceipt]\n\n/** @deprecated use viem type TransactionReceipt instead */\nexport interface UserOperationReceiptObject {\n /* 32 Bytes - hash of the block where this log was in. null when its pending. null when its pending log */\n blockHash: Hash;\n /* The block number where this log was in. null when its pending. null when its pending log. */\n blockNumber: BigNumberish;\n /* The index of the transaction within the block. */\n transactionIndex: BigNumberish;\n /* 32 Bytes - hash of the transaction. null when its pending. */\n transactionHash: Hash;\n /* 20 Bytes - address of the sender */\n from: Address;\n /* 20 Bytes - address of the receiver. null when its a contract creation transaction */\n to: Address;\n /* The total amount of gas used when this transaction was executed in the block. */\n cumulativeGasUsed: BigNumberish;\n /* The amount of gas used by this specific transaction alone */\n gasUsed: BigNumberish;\n /* 20 Bytes - The contract address created, if the transaction was a contract creation, otherwise null */\n contractAddress: Address;\n logs: UserOperationReceiptLog[];\n /* 256 Bytes - Bloom filter for light clients to quickly retrieve related logs */\n logsBloom: Hex;\n /* 32 bytes of post-transaction stateroot. (pre Byzantium hard fork at block 4,370,000) */\n root: Hex;\n /* Either 1 (success) or 0 (failure). (post Byzantium hard fork at block 4,370,000) */\n status: number;\n /* The cumulative gas used in the block containing this UserOperation. */\n effectiveGasPrice: BigNumberish;\n /* The type of the recipt object */\n type: string;\n}\n\n/** @deprecated use viem type Log instead */\n/* https://github.com/wevm/viem/blob/6ef4ac131a878bf1dc4b335f5dc127e62618dda0/src/types/log.ts#L15 */\nexport interface UserOperationReceiptLog {\n /* The hash of the block where the given transaction was included. */\n blockHash: Hash;\n /* The number of the block where the given transaction was included. */\n blockNumber: BigNumberish;\n /* The index of the transaction within the block. */\n transactionIndex: BigNumberish;\n /* 20 Bytes - address from which this log originated. */\n address: Address;\n /* Integer of the log index position in the block. null when its pending log. */\n logIndex: BigNumberish;\n /* Contains one or more 32 Bytes non-indexed arguments of the log. */\n data: Hex;\n /* true when the log was removed, due to a chain reorganization. false if its a valid log. */\n removed: boolean;\n /* Array of zero to four 32 Bytes DATA of indexed log arguments. */\n topics: string[];\n /* hash of the transaction */\n transactionHash: Hash;\n}\n\n// [!region UserOperationStruct_v6]\n// https://github.com/eth-infinitism/account-abstraction/blob/releases/v0.6/test/UserOperation.ts\n// this is used for building requests for v0.6 entry point contract\nexport interface UserOperationStruct_v6 {\n /* the origin of the request */\n sender: string;\n /* nonce of the transaction, returned from the entry point for this address */\n nonce: BigNumberish;\n /* the initCode for creating the sender if it does not exist yet, otherwise \"0x\" */\n initCode: BytesLike | \"0x\";\n /* the callData passed to the target */\n callData: BytesLike;\n /* Value used by inner account execution */\n callGasLimit?: BigNumberish;\n /* Actual gas used by the validation of this UserOperation */\n verificationGasLimit?: BigNumberish;\n /* Gas overhead of this UserOperation */\n preVerificationGas?: BigNumberish;\n /* Maximum fee per gas (similar to EIP-1559 max_fee_per_gas) */\n maxFeePerGas?: BigNumberish;\n /* Maximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas) */\n maxPriorityFeePerGas?: BigNumberish;\n /* Address of paymaster sponsoring the transaction, followed by extra data to send to the paymaster (\"0x\" for self-sponsored transaction) */\n paymasterAndData: BytesLike | \"0x\";\n /* Data passed into the account along with the nonce during the verification step */\n signature: BytesLike;\n}\n// [!endregion UserOperationStruct_v6]\n\n// [!region UserOperationStruct_v7]\n// based on https://github.com/eth-infinitism/account-abstraction/blob/releases/v0.7/test/UserOperation.ts\n// this is used for building requests for v0.7 entry point contract\nexport interface UserOperationStruct_v7 {\n /* the account making the operation */\n sender: string;\n /* anti-replay parameter. nonce of the transaction, returned from the entry point for this address */\n nonce: BigNumberish;\n /* account factory, only for new accounts */\n factory?: string;\n /* data for account factory (only if account factory exists) */\n factoryData?: BytesLike;\n /* the data to pass to the sender during the main execution call */\n callData: BytesLike;\n /* the amount of gas to allocate the main execution call */\n callGasLimit?: BigNumberish;\n /* the amount of gas to allocate for the verification step */\n verificationGasLimit?: BigNumberish;\n /* extra gas to pay the bunder */\n preVerificationGas?: BigNumberish;\n /* maximum fee per gas (similar to EIP-1559 max_fee_per_gas) */\n maxFeePerGas?: BigNumberish;\n /* maximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas) */\n maxPriorityFeePerGas?: BigNumberish;\n /* address of paymaster contract, (or empty, if account pays for itself) */\n paymaster?: string;\n /* the amount of gas to allocate for the paymaster validation code */\n paymasterVerificationGasLimit?: BigNumberish;\n /* the amount of gas to allocate for the paymaster post-operation code */\n paymasterPostOpGasLimit?: BigNumberish;\n /* data for paymaster (only if paymaster exists) */\n paymasterData?: BytesLike;\n /* data passed into the account to verify authorization */\n signature: BytesLike;\n}\n// [!endregion UserOperationStruct_v7]\n\n// [!region UserOperationStruct]\nexport type UserOperationStruct<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = TEntryPointVersion extends \"0.6.0\"\n ? UserOperationStruct_v6\n : TEntryPointVersion extends \"0.7.0\"\n ? UserOperationStruct_v7\n : never;\n// [!endregion UserOperationStruct]\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAMN,MAAM,MAAM,CAAC;AAoZd,mCAAmC","sourcesContent":["import {\n type Address,\n type Hash,\n type Hex,\n type StateOverride,\n type TransactionReceipt,\n} from \"viem\";\nimport type { z } from \"zod\";\nimport type {\n UserOperationFeeOptionsFieldSchema,\n UserOperationFeeOptionsSchema,\n UserOperationFeeOptionsSchema_v6,\n UserOperationFeeOptionsSchema_v7,\n} from \"./client/schema\";\nimport type { EntryPointVersion } from \"./entrypoint/types\";\nimport type {\n BigNumberishRangeSchema,\n BigNumberishSchema,\n MultiplierSchema,\n NoUndefined,\n} from \"./utils\";\n\nexport type EmptyHex = `0x`;\nexport type NullAddress = `0x0`;\n\n// based on @account-abstraction/common\nexport type PromiseOrValue<T> = T | Promise<T>;\nexport type BytesLike = Uint8Array | Hex;\nexport type Multiplier = z.input<typeof MultiplierSchema>;\n\nexport type BigNumberish = z.input<typeof BigNumberishSchema>;\nexport type BigNumberishRange = z.input<typeof BigNumberishRangeSchema>;\n\n// [!region UserOperationCallData]\nexport type UserOperationCallData =\n | {\n /* the target of the call */\n target: Address;\n /* the data passed to the target */\n data: Hex;\n /* the amount of native token to send to the target (default: 0) */\n value?: bigint;\n }\n | Hex;\n// [!endregion UserOperationCallData]\n\n// [!region BatchUserOperationCallData]\nexport type BatchUserOperationCallData = Exclude<UserOperationCallData, Hex>[];\n// [!endregion BatchUserOperationCallData]\n\nexport type UserOperationFeeOptionsField = z.input<\n typeof UserOperationFeeOptionsFieldSchema\n>;\n\nexport type UserOperationFeeOptions<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = TEntryPointVersion extends \"0.6.0\"\n ? z.input<typeof UserOperationFeeOptionsSchema_v6>\n : TEntryPointVersion extends \"0.7.0\"\n ? z.input<typeof UserOperationFeeOptionsSchema_v7>\n : z.input<typeof UserOperationFeeOptionsSchema>;\n\nexport type UserOperationOverridesParameter<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion,\n Required extends boolean = false\n> = Required extends true\n ? { overrides: UserOperationOverrides<TEntryPointVersion> }\n : { overrides?: UserOperationOverrides<TEntryPointVersion> };\n\n// [!region UserOperationPaymasterOverrides]\nexport type UserOperationPaymasterOverrides<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = TEntryPointVersion extends \"0.6.0\"\n ? {\n // paymasterData overrides to bypass paymaster middleware\n paymasterAndData: Hex;\n }\n : TEntryPointVersion extends \"0.7.0\"\n ? {\n // paymasterData overrides to bypass paymaster middleware\n // if set to '0x', all paymaster related fields are omitted from the user op request\n paymasterData: Hex;\n paymaster: Address;\n paymasterVerificationGasLimit:\n | NoUndefined<\n UserOperationStruct<\"0.7.0\">[\"paymasterVerificationGasLimit\"]\n >\n | Multiplier;\n paymasterPostOpGasLimit:\n | NoUndefined<UserOperationStruct<\"0.7.0\">[\"paymasterPostOpGasLimit\"]>\n | Multiplier;\n }\n : {};\n// [!endregion UserOperationOverridesParameter]\n\n// [!region UserOperationOverrides]\nexport type UserOperationOverrides<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = Partial<\n {\n callGasLimit:\n | UserOperationStruct<TEntryPointVersion>[\"callGasLimit\"]\n | Multiplier;\n maxFeePerGas:\n | UserOperationStruct<TEntryPointVersion>[\"maxFeePerGas\"]\n | Multiplier;\n maxPriorityFeePerGas:\n | UserOperationStruct<TEntryPointVersion>[\"maxPriorityFeePerGas\"]\n | Multiplier;\n preVerificationGas:\n | UserOperationStruct<TEntryPointVersion>[\"preVerificationGas\"]\n | Multiplier;\n verificationGasLimit:\n | UserOperationStruct<TEntryPointVersion>[\"verificationGasLimit\"]\n | Multiplier;\n /**\n * This can be used to override the key used when calling `entryPoint.getNonce`\n * It is useful when you want to use parallel nonces for user operations\n *\n * NOTE: not all bundlers fully support this feature and it could be that your bundler will still only include\n * one user operation for your account in a bundle\n */\n nonceKey: bigint;\n\n /**\n * The same state overrides for\n * [`eth_call`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-eth#eth-call) method.\n * An address-to-state mapping, where each entry specifies some state to be ephemerally overridden\n * prior to executing the call. State overrides allow you to customize the network state for\n * the purpose of the simulation, so this feature is useful when you need to estimate gas\n * for user operation scenarios under conditions that aren’t currently present on the live network.\n */\n stateOverride: StateOverride;\n } & UserOperationPaymasterOverrides<TEntryPointVersion>\n>;\n// [!endregion UserOperationOverrides]\n\n// [!region UserOperationRequest_v6]\n// represents the request as it needs to be formatted for v0.6 RPC requests\n// Reference: https://github.com/ethereum/ERCs/blob/8dd085d159cb123f545c272c0d871a5339550e79/ERCS/erc-4337.md#definitions\nexport interface UserOperationRequest_v6 {\n /* the origin of the request */\n sender: Address;\n /* nonce (as hex) of the transaction, returned from the entry point for this Address */\n nonce: Hex;\n /* the initCode for creating the sender if it does not exist yet, otherwise \"0x\" */\n initCode: Hex | EmptyHex;\n /* the callData passed to the target */\n callData: Hex;\n /* Gas value (as hex) used by inner account execution */\n callGasLimit: Hex;\n /* Actual gas (as hex) used by the validation of this UserOperation */\n verificationGasLimit: Hex;\n /* Gas overhead (as hex) of this UserOperation */\n preVerificationGas: Hex;\n /* Maximum fee per gas (similar to EIP-1559 max_fee_per_gas) (as hex)*/\n maxFeePerGas: Hex;\n /* Maximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas) (as hex)*/\n maxPriorityFeePerGas: Hex;\n /* Address of paymaster sponsoring the transaction, followed by extra data to send to the paymaster (\"0x\" for self-sponsored transaction) */\n paymasterAndData: Hex | EmptyHex;\n /* Data passed into the account along with the nonce during the verification step */\n signature: Hex;\n}\n// [!endregion UserOperationRequest_v6]\n\n// [!region UserOperationRequest_v7]\n// represents the request as it needs to be formatted for v0.7 RPC requests\n// Reference: https://eips.ethereum.org/EIPS/eip-4337#definitions\nexport interface UserOperationRequest_v7 {\n /* the account making the operation */\n sender: Address;\n /* anti-replay parameter. nonce of the transaction, returned from the entry point for this address */\n nonce: Hex;\n /* account factory, only for new accounts */\n factory?: Address;\n /* data for account factory (only if account factory exists) */\n factoryData?: Hex;\n /* the data to pass to the sender during the main execution call */\n callData: Hex;\n /* the amount of gas to allocate the main execution call */\n callGasLimit: Hex;\n /* the amount of gas to allocate for the verification step */\n verificationGasLimit: Hex;\n /* extra gas to pay the bunder */\n preVerificationGas: Hex;\n /* maximum fee per gas (similar to EIP-1559 max_fee_per_gas) */\n maxFeePerGas: Hex;\n /* maximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas) */\n maxPriorityFeePerGas: Hex;\n /* address of paymaster contract, (or empty, if account pays for itself) */\n paymaster?: Address;\n /* the amount of gas to allocate for the paymaster validation code */\n paymasterVerificationGasLimit?: Hex;\n /* the amount of gas to allocate for the paymaster post-operation code */\n paymasterPostOpGasLimit?: Hex;\n /* data for paymaster (only if paymaster exists) */\n paymasterData?: Hex;\n /* data passed into the account to verify authorization */\n signature: Hex;\n}\n// [!endregion UserOperationRequest_v7]\n\n// [!region UserOperationRequest]\n// Reference: https://eips.ethereum.org/EIPS/eip-4337#definitions\nexport type UserOperationRequest<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = TEntryPointVersion extends \"0.6.0\"\n ? UserOperationRequest_v6\n : TEntryPointVersion extends \"0.7.0\"\n ? UserOperationRequest_v7\n : never;\n\n// [!endregion UserOperationRequest]\n\n// [!region UserOperationEstimateGasResponse]\nexport interface UserOperationEstimateGasResponse<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> {\n /* Gas overhead of this UserOperation */\n preVerificationGas: BigNumberish;\n /* Actual gas used by the validation of this UserOperation */\n verificationGasLimit: BigNumberish;\n /* Value used by inner account execution */\n callGasLimit: BigNumberish;\n /*\n * EntryPoint v0.7.0 operations only.\n * The amount of gas to allocate for the paymaster validation code.\n * Note: `eth_estimateUserOperationGas` does not return paymasterPostOpGasLimit.\n */\n paymasterVerificationGasLimit: TEntryPointVersion extends \"0.7.0\"\n ? BigNumberish | undefined\n : never;\n}\n// [!endregion UserOperationEstimateGasResponse]\n\n// [!region UserOperationResponse]\nexport interface UserOperationResponse<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> {\n /* the User Operation */\n userOperation: UserOperationRequest<TEntryPointVersion>;\n /* the address of the entry point contract that executed the user operation */\n entryPoint: Address;\n /* the block number the user operation was included in */\n blockNumber: BigNumberish;\n /* the hash of the block the user operation was included in */\n blockHash: Hash;\n /* the hash of the transaction that included the user operation */\n transactionHash: Hash;\n}\n// [!endregion UserOperationResponse]\n\n// [!region UserOperationReceipt]\nexport interface UserOperationReceipt {\n /* The request hash of the UserOperation. */\n userOpHash: Hash;\n /* The entry point address used for the UserOperation. */\n entryPoint: Address;\n /* The account initiating the UserOperation. */\n sender: Address;\n /* The nonce used in the UserOperation. */\n nonce: BigNumberish;\n /* The paymaster used for this UserOperation (or empty). */\n paymaster?: Address;\n /* The actual amount paid (by account or paymaster) for this UserOperation. */\n actualGasCost: BigNumberish;\n /* The total gas used by this UserOperation (including preVerification, creation, validation, and execution). */\n actualGasUsed: BigNumberish;\n /* Indicates whether the execution completed without reverting. */\n success: boolean;\n /* In case of revert, this is the revert reason. */\n reason?: string;\n /* The logs generated by this UserOperation (not including logs of other UserOperations in the same bundle). */\n logs: string[];\n /* The TransactionReceipt object for the entire bundle, not only for this UserOperation. */\n receipt: TransactionReceipt;\n}\n// [!endregion UserOperationReceipt]\n\n/** @deprecated use viem type TransactionReceipt instead */\nexport interface UserOperationReceiptObject {\n /* 32 Bytes - hash of the block where this log was in. null when its pending. null when its pending log */\n blockHash: Hash;\n /* The block number where this log was in. null when its pending. null when its pending log. */\n blockNumber: BigNumberish;\n /* The index of the transaction within the block. */\n transactionIndex: BigNumberish;\n /* 32 Bytes - hash of the transaction. null when its pending. */\n transactionHash: Hash;\n /* 20 Bytes - address of the sender */\n from: Address;\n /* 20 Bytes - address of the receiver. null when its a contract creation transaction */\n to: Address;\n /* The total amount of gas used when this transaction was executed in the block. */\n cumulativeGasUsed: BigNumberish;\n /* The amount of gas used by this specific transaction alone */\n gasUsed: BigNumberish;\n /* 20 Bytes - The contract address created, if the transaction was a contract creation, otherwise null */\n contractAddress: Address;\n logs: UserOperationReceiptLog[];\n /* 256 Bytes - Bloom filter for light clients to quickly retrieve related logs */\n logsBloom: Hex;\n /* 32 bytes of post-transaction stateroot. (pre Byzantium hard fork at block 4,370,000) */\n root: Hex;\n /* Either 1 (success) or 0 (failure). (post Byzantium hard fork at block 4,370,000) */\n status: number;\n /* The cumulative gas used in the block containing this UserOperation. */\n effectiveGasPrice: BigNumberish;\n /* The type of the recipt object */\n type: string;\n}\n\n/** @deprecated use viem type Log instead */\n/* https://github.com/wevm/viem/blob/6ef4ac131a878bf1dc4b335f5dc127e62618dda0/src/types/log.ts#L15 */\nexport interface UserOperationReceiptLog {\n /* The hash of the block where the given transaction was included. */\n blockHash: Hash;\n /* The number of the block where the given transaction was included. */\n blockNumber: BigNumberish;\n /* The index of the transaction within the block. */\n transactionIndex: BigNumberish;\n /* 20 Bytes - address from which this log originated. */\n address: Address;\n /* Integer of the log index position in the block. null when its pending log. */\n logIndex: BigNumberish;\n /* Contains one or more 32 Bytes non-indexed arguments of the log. */\n data: Hex;\n /* true when the log was removed, due to a chain reorganization. false if its a valid log. */\n removed: boolean;\n /* Array of zero to four 32 Bytes DATA of indexed log arguments. */\n topics: string[];\n /* hash of the transaction */\n transactionHash: Hash;\n}\n\n// [!region UserOperationStruct_v6]\n// https://github.com/eth-infinitism/account-abstraction/blob/releases/v0.6/test/UserOperation.ts\n// this is used for building requests for v0.6 entry point contract\nexport interface UserOperationStruct_v6 {\n /* the origin of the request */\n sender: string;\n /* nonce of the transaction, returned from the entry point for this address */\n nonce: BigNumberish;\n /* the initCode for creating the sender if it does not exist yet, otherwise \"0x\" */\n initCode: BytesLike | \"0x\";\n /* the callData passed to the target */\n callData: BytesLike;\n /* Value used by inner account execution */\n callGasLimit?: BigNumberish;\n /* Actual gas used by the validation of this UserOperation */\n verificationGasLimit?: BigNumberish;\n /* Gas overhead of this UserOperation */\n preVerificationGas?: BigNumberish;\n /* Maximum fee per gas (similar to EIP-1559 max_fee_per_gas) */\n maxFeePerGas?: BigNumberish;\n /* Maximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas) */\n maxPriorityFeePerGas?: BigNumberish;\n /* Address of paymaster sponsoring the transaction, followed by extra data to send to the paymaster (\"0x\" for self-sponsored transaction) */\n paymasterAndData: BytesLike | \"0x\";\n /* Data passed into the account along with the nonce during the verification step */\n signature: BytesLike;\n}\n// [!endregion UserOperationStruct_v6]\n\n// [!region UserOperationStruct_v7]\n// based on https://github.com/eth-infinitism/account-abstraction/blob/releases/v0.7/test/UserOperation.ts\n// this is used for building requests for v0.7 entry point contract\nexport interface UserOperationStruct_v7 {\n /* the account making the operation */\n sender: string;\n /* anti-replay parameter. nonce of the transaction, returned from the entry point for this address */\n nonce: BigNumberish;\n /* account factory, only for new accounts */\n factory?: string;\n /* data for account factory (only if account factory exists) */\n factoryData?: BytesLike;\n /* the data to pass to the sender during the main execution call */\n callData: BytesLike;\n /* the amount of gas to allocate the main execution call */\n callGasLimit?: BigNumberish;\n /* the amount of gas to allocate for the verification step */\n verificationGasLimit?: BigNumberish;\n /* extra gas to pay the bunder */\n preVerificationGas?: BigNumberish;\n /* maximum fee per gas (similar to EIP-1559 max_fee_per_gas) */\n maxFeePerGas?: BigNumberish;\n /* maximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas) */\n maxPriorityFeePerGas?: BigNumberish;\n /* address of paymaster contract, (or empty, if account pays for itself) */\n paymaster?: string;\n /* the amount of gas to allocate for the paymaster validation code */\n paymasterVerificationGasLimit?: BigNumberish;\n /* the amount of gas to allocate for the paymaster post-operation code */\n paymasterPostOpGasLimit?: BigNumberish;\n /* data for paymaster (only if paymaster exists) */\n paymasterData?: BytesLike;\n /* data passed into the account to verify authorization */\n signature: BytesLike;\n}\n// [!endregion UserOperationStruct_v7]\n\n// [!region UserOperationStruct]\nexport type UserOperationStruct<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = TEntryPointVersion extends \"0.6.0\"\n ? UserOperationStruct_v6\n : TEntryPointVersion extends \"0.7.0\"\n ? UserOperationStruct_v7\n : never;\n// [!endregion UserOperationStruct]\n"]}
|
|
@@ -1,10 +1,55 @@
|
|
|
1
1
|
import type { BigNumberish, Multiplier } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Returns the max bigint in a list of bigints
|
|
4
|
+
*
|
|
5
|
+
* @param {bigint[]} args a list of bigints to get the max of
|
|
6
|
+
* @returns {bigint} the max bigint in the list
|
|
7
|
+
*/
|
|
2
8
|
export declare const bigIntMax: (...args: bigint[]) => bigint;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the min bigint in a list of bigints
|
|
11
|
+
*
|
|
12
|
+
* @param {bigint[]} args a list of bigints to get the max of
|
|
13
|
+
* @returns {bigint} the min bigint in the list
|
|
14
|
+
*/
|
|
3
15
|
export declare const bigIntMin: (...args: bigint[]) => bigint;
|
|
16
|
+
/**
|
|
17
|
+
* Given a bigint and a min-max range, returns the min-max clamped bigint value
|
|
18
|
+
*
|
|
19
|
+
* @param {BigNumberish} value a bigint value to clamp
|
|
20
|
+
* @param {BigNumberish | undefined} lower lower bound min max tuple value
|
|
21
|
+
* @param {BigNumberish | undefined} upper upper bound min max tuple value
|
|
22
|
+
* @returns {bigint} the clamped bigint value per given range
|
|
23
|
+
*/
|
|
4
24
|
export declare const bigIntClamp: (value: BigNumberish, lower: BigNumberish | null | undefined, upper: BigNumberish | null | undefined) => bigint;
|
|
5
25
|
export declare enum RoundingMode {
|
|
6
26
|
ROUND_DOWN = 0,
|
|
7
27
|
ROUND_UP = 1
|
|
8
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Given a bigint and a number (which can be a float), returns the bigint value.
|
|
31
|
+
* Note: this function has loss and will round down to the nearest integer.
|
|
32
|
+
*
|
|
33
|
+
* @param {BigNumberish} base - the number to be multiplied
|
|
34
|
+
* @param {number} multiplier - the amount to multiply by
|
|
35
|
+
* @param {RoundingMode} roundingMode - the rounding mode to use when calculating the percent. defaults to ROUND_UP
|
|
36
|
+
* @returns {bigint} the bigint value of the multiplication with the number rounded by the rounding mode
|
|
37
|
+
*/
|
|
9
38
|
export declare const bigIntMultiply: (base: BigNumberish, multiplier: Multiplier["multiplier"], roundingMode?: RoundingMode) => bigint;
|
|
39
|
+
/**
|
|
40
|
+
* Useful if you want to use a string, such as a user's email address, as salt to generate a unique SmartAccount per user.
|
|
41
|
+
*
|
|
42
|
+
* example:
|
|
43
|
+
* ```
|
|
44
|
+
* const salt = stringToIndex("alice@example.com");
|
|
45
|
+
*
|
|
46
|
+
* export const account = new SimpleSmartContractAccount({
|
|
47
|
+
* index: salt,
|
|
48
|
+
* // other args omitted...
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @param {string} phrase -- any string value.
|
|
53
|
+
* @returns {bigint} the bigint value of the hashed string
|
|
54
|
+
*/
|
|
10
55
|
export declare const stringToIndex: (phrase: string) => bigint;
|
package/dist/esm/utils/bigint.js
CHANGED
|
@@ -1,17 +1,37 @@
|
|
|
1
1
|
import { keccak256, toHex } from "viem";
|
|
2
2
|
import { isMultiplier } from "./schema.js";
|
|
3
|
+
/**
|
|
4
|
+
* Returns the max bigint in a list of bigints
|
|
5
|
+
*
|
|
6
|
+
* @param {bigint[]} args a list of bigints to get the max of
|
|
7
|
+
* @returns {bigint} the max bigint in the list
|
|
8
|
+
*/
|
|
3
9
|
export const bigIntMax = (...args) => {
|
|
4
10
|
if (!args.length) {
|
|
5
11
|
throw new Error("bigIntMax requires at least one argument");
|
|
6
12
|
}
|
|
7
13
|
return args.reduce((m, c) => (m > c ? m : c));
|
|
8
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Returns the min bigint in a list of bigints
|
|
17
|
+
*
|
|
18
|
+
* @param {bigint[]} args a list of bigints to get the max of
|
|
19
|
+
* @returns {bigint} the min bigint in the list
|
|
20
|
+
*/
|
|
9
21
|
export const bigIntMin = (...args) => {
|
|
10
22
|
if (!args.length) {
|
|
11
23
|
throw new Error("bigIntMin requires at least one argument");
|
|
12
24
|
}
|
|
13
25
|
return args.reduce((m, c) => (m < c ? m : c));
|
|
14
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Given a bigint and a min-max range, returns the min-max clamped bigint value
|
|
29
|
+
*
|
|
30
|
+
* @param {BigNumberish} value a bigint value to clamp
|
|
31
|
+
* @param {BigNumberish | undefined} lower lower bound min max tuple value
|
|
32
|
+
* @param {BigNumberish | undefined} upper upper bound min max tuple value
|
|
33
|
+
* @returns {bigint} the clamped bigint value per given range
|
|
34
|
+
*/
|
|
15
35
|
export const bigIntClamp = (value, lower, upper) => {
|
|
16
36
|
lower = lower != null ? BigInt(lower) : null;
|
|
17
37
|
upper = upper != null ? BigInt(upper) : null;
|
|
@@ -32,10 +52,20 @@ export var RoundingMode;
|
|
|
32
52
|
RoundingMode[RoundingMode["ROUND_DOWN"] = 0] = "ROUND_DOWN";
|
|
33
53
|
RoundingMode[RoundingMode["ROUND_UP"] = 1] = "ROUND_UP";
|
|
34
54
|
})(RoundingMode || (RoundingMode = {}));
|
|
55
|
+
/**
|
|
56
|
+
* Given a bigint and a number (which can be a float), returns the bigint value.
|
|
57
|
+
* Note: this function has loss and will round down to the nearest integer.
|
|
58
|
+
*
|
|
59
|
+
* @param {BigNumberish} base - the number to be multiplied
|
|
60
|
+
* @param {number} multiplier - the amount to multiply by
|
|
61
|
+
* @param {RoundingMode} roundingMode - the rounding mode to use when calculating the percent. defaults to ROUND_UP
|
|
62
|
+
* @returns {bigint} the bigint value of the multiplication with the number rounded by the rounding mode
|
|
63
|
+
*/
|
|
35
64
|
export const bigIntMultiply = (base, multiplier, roundingMode = RoundingMode.ROUND_UP) => {
|
|
36
65
|
if (!isMultiplier({ multiplier })) {
|
|
37
66
|
throw new Error("bigIntMultiply requires a multiplier validated number as the second argument");
|
|
38
67
|
}
|
|
68
|
+
// Get decimal places of b. Max decimal places is defined by the MultiplerSchema.
|
|
39
69
|
const decimalPlaces = multiplier.toString().split(".")[1]?.length ?? 0;
|
|
40
70
|
const val = roundingMode === RoundingMode.ROUND_UP
|
|
41
71
|
? BigInt(base) * BigInt(multiplier * 10 ** decimalPlaces) +
|
|
@@ -43,5 +73,21 @@ export const bigIntMultiply = (base, multiplier, roundingMode = RoundingMode.ROU
|
|
|
43
73
|
: BigInt(base) * BigInt(multiplier * 10 ** decimalPlaces);
|
|
44
74
|
return val / BigInt(10 ** decimalPlaces);
|
|
45
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* Useful if you want to use a string, such as a user's email address, as salt to generate a unique SmartAccount per user.
|
|
78
|
+
*
|
|
79
|
+
* example:
|
|
80
|
+
* ```
|
|
81
|
+
* const salt = stringToIndex("alice@example.com");
|
|
82
|
+
*
|
|
83
|
+
* export const account = new SimpleSmartContractAccount({
|
|
84
|
+
* index: salt,
|
|
85
|
+
* // other args omitted...
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @param {string} phrase -- any string value.
|
|
90
|
+
* @returns {bigint} the bigint value of the hashed string
|
|
91
|
+
*/
|
|
46
92
|
export const stringToIndex = (phrase) => BigInt(keccak256(toHex(phrase)));
|
|
47
93
|
//# sourceMappingURL=bigint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bigint.js","sourceRoot":"","sources":["../../../src/utils/bigint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"bigint.js","sourceRoot":"","sources":["../../../src/utils/bigint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAG,IAAc,EAAU,EAAE;IACrD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAG,IAAc,EAAU,EAAE;IACrD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,KAAmB,EACnB,KAAsC,EACtC,KAAsC,EAC9B,EAAE;IACV,KAAK,GAAG,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7C,KAAK,GAAG,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE7C,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,GAAG,KAAK,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CACb,8BAA8B,KAAK,6BAA6B,KAAK,EAAE,CACxE,CAAC;IACJ,CAAC;IAED,IAAI,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACxB,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,GAAG,GAAG,EAAE,CAAC;QACjC,GAAG,GAAG,KAAK,CAAC;IACd,CAAC;IACD,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,GAAG,GAAG,EAAE,CAAC;QACjC,GAAG,GAAG,KAAK,CAAC;IACd,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,2DAAc,CAAA;IACd,uDAAY,CAAA;AACd,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,IAAkB,EAClB,UAAoC,EACpC,eAA6B,YAAY,CAAC,QAAQ,EAClD,EAAE;IACF,IAAI,CAAC,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,8EAA8E,CAC/E,CAAC;IACJ,CAAC;IAED,iFAAiF;IACjF,MAAM,aAAa,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC;IACvE,MAAM,GAAG,GACP,YAAY,KAAK,YAAY,CAAC,QAAQ;QACpC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,UAAU,GAAG,EAAE,IAAI,aAAa,CAAC;YACvD,MAAM,CAAC,EAAE,IAAI,aAAa,GAAG,CAAC,CAAC;QACjC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,UAAU,GAAG,EAAE,IAAI,aAAa,CAAC,CAAC;IAE9D,OAAO,GAAG,GAAG,MAAM,CAAC,EAAE,IAAI,aAAa,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAc,EAAU,EAAE,CACtD,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC","sourcesContent":["import { keccak256, toHex } from \"viem\";\nimport type { BigNumberish, Multiplier } from \"../types\";\nimport { isMultiplier } from \"./schema.js\";\n\n/**\n * Returns the max bigint in a list of bigints\n *\n * @param {bigint[]} args a list of bigints to get the max of\n * @returns {bigint} the max bigint in the list\n */\nexport const bigIntMax = (...args: bigint[]): bigint => {\n if (!args.length) {\n throw new Error(\"bigIntMax requires at least one argument\");\n }\n\n return args.reduce((m, c) => (m > c ? m : c));\n};\n\n/**\n * Returns the min bigint in a list of bigints\n *\n * @param {bigint[]} args a list of bigints to get the max of\n * @returns {bigint} the min bigint in the list\n */\nexport const bigIntMin = (...args: bigint[]): bigint => {\n if (!args.length) {\n throw new Error(\"bigIntMin requires at least one argument\");\n }\n\n return args.reduce((m, c) => (m < c ? m : c));\n};\n\n/**\n * Given a bigint and a min-max range, returns the min-max clamped bigint value\n *\n * @param {BigNumberish} value a bigint value to clamp\n * @param {BigNumberish | undefined} lower lower bound min max tuple value\n * @param {BigNumberish | undefined} upper upper bound min max tuple value\n * @returns {bigint} the clamped bigint value per given range\n */\nexport const bigIntClamp = (\n value: BigNumberish,\n lower: BigNumberish | null | undefined,\n upper: BigNumberish | null | undefined\n): bigint => {\n lower = lower != null ? BigInt(lower) : null;\n upper = upper != null ? BigInt(upper) : null;\n\n if (upper != null && lower != null && upper < lower) {\n throw new Error(\n `invalid range: upper bound ${upper} is less than lower bound ${lower}`\n );\n }\n\n let ret = BigInt(value);\n if (lower != null && lower > ret) {\n ret = lower;\n }\n if (upper != null && upper < ret) {\n ret = upper;\n }\n return ret;\n};\n\nexport enum RoundingMode {\n ROUND_DOWN = 0,\n ROUND_UP = 1,\n}\n\n/**\n * Given a bigint and a number (which can be a float), returns the bigint value.\n * Note: this function has loss and will round down to the nearest integer.\n *\n * @param {BigNumberish} base - the number to be multiplied\n * @param {number} multiplier - the amount to multiply by\n * @param {RoundingMode} roundingMode - the rounding mode to use when calculating the percent. defaults to ROUND_UP\n * @returns {bigint} the bigint value of the multiplication with the number rounded by the rounding mode\n */\nexport const bigIntMultiply = (\n base: BigNumberish,\n multiplier: Multiplier[\"multiplier\"],\n roundingMode: RoundingMode = RoundingMode.ROUND_UP\n) => {\n if (!isMultiplier({ multiplier })) {\n throw new Error(\n \"bigIntMultiply requires a multiplier validated number as the second argument\"\n );\n }\n\n // Get decimal places of b. Max decimal places is defined by the MultiplerSchema.\n const decimalPlaces = multiplier.toString().split(\".\")[1]?.length ?? 0;\n const val =\n roundingMode === RoundingMode.ROUND_UP\n ? BigInt(base) * BigInt(multiplier * 10 ** decimalPlaces) +\n BigInt(10 ** decimalPlaces - 1)\n : BigInt(base) * BigInt(multiplier * 10 ** decimalPlaces);\n\n return val / BigInt(10 ** decimalPlaces);\n};\n\n/**\n * Useful if you want to use a string, such as a user's email address, as salt to generate a unique SmartAccount per user.\n *\n * example:\n * ```\n * const salt = stringToIndex(\"alice@example.com\");\n *\n * export const account = new SimpleSmartContractAccount({\n * index: salt,\n * // other args omitted...\n * });\n * ```\n *\n * @param {string} phrase -- any string value.\n * @returns {bigint} the bigint value of the hashed string\n */\nexport const stringToIndex = (phrase: string): bigint =>\n BigInt(keccak256(toHex(phrase)));\n"]}
|
|
@@ -3,5 +3,14 @@ type TakeBytesOpts = {
|
|
|
3
3
|
count?: number;
|
|
4
4
|
offset?: number;
|
|
5
5
|
};
|
|
6
|
+
/**
|
|
7
|
+
* Given a bytes string, returns a slice of the bytes
|
|
8
|
+
*
|
|
9
|
+
* @param {Hex} bytes - the hex string representing bytes
|
|
10
|
+
* @param {TakeBytesOpts} opts - optional parameters for slicing the bytes
|
|
11
|
+
* @param {number} opts.offset - the offset in bytes to start slicing from
|
|
12
|
+
* @param {number} opts.count - the number of bytes to slice
|
|
13
|
+
* @returns {Hex} the sliced bytes
|
|
14
|
+
*/
|
|
6
15
|
export declare const takeBytes: (bytes: Hex, opts?: TakeBytesOpts) => Hex;
|
|
7
16
|
export {};
|
package/dist/esm/utils/bytes.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given a bytes string, returns a slice of the bytes
|
|
3
|
+
*
|
|
4
|
+
* @param {Hex} bytes - the hex string representing bytes
|
|
5
|
+
* @param {TakeBytesOpts} opts - optional parameters for slicing the bytes
|
|
6
|
+
* @param {number} opts.offset - the offset in bytes to start slicing from
|
|
7
|
+
* @param {number} opts.count - the number of bytes to slice
|
|
8
|
+
* @returns {Hex} the sliced bytes
|
|
9
|
+
*/
|
|
1
10
|
export const takeBytes = (bytes, opts = {}) => {
|
|
2
11
|
const { offset, count } = opts;
|
|
3
|
-
const start = (offset ? offset * 2 : 0) + 2;
|
|
12
|
+
const start = (offset ? offset * 2 : 0) + 2; // add 2 to skip the 0x prefix
|
|
4
13
|
const end = count ? start + count * 2 : undefined;
|
|
5
14
|
return `0x${bytes.slice(start, end)}`;
|
|
6
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bytes.js","sourceRoot":"","sources":["../../../src/utils/bytes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bytes.js","sourceRoot":"","sources":["../../../src/utils/bytes.ts"],"names":[],"mappings":"AAOA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAU,EAAE,OAAsB,EAAE,EAAO,EAAE;IACrE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAC/B,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,8BAA8B;IAC3E,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAElD,OAAO,KAAK,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;AACxC,CAAC,CAAC","sourcesContent":["import type { Hex } from \"viem\";\n\ntype TakeBytesOpts = {\n count?: number;\n offset?: number;\n};\n\n/**\n * Given a bytes string, returns a slice of the bytes\n *\n * @param {Hex} bytes - the hex string representing bytes\n * @param {TakeBytesOpts} opts - optional parameters for slicing the bytes\n * @param {number} opts.offset - the offset in bytes to start slicing from\n * @param {number} opts.count - the number of bytes to slice\n * @returns {Hex} the sliced bytes\n */\nexport const takeBytes = (bytes: Hex, opts: TakeBytesOpts = {}): Hex => {\n const { offset, count } = opts;\n const start = (offset ? offset * 2 : 0) + 2; // add 2 to skip the 0x prefix\n const end = count ? start + count * 2 : undefined;\n\n return `0x${bytes.slice(start, end)}`;\n};\n"]}
|
|
@@ -1,15 +1,101 @@
|
|
|
1
1
|
import type { PromiseOrValue } from "../types.js";
|
|
2
2
|
import type { RecordableKeys } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Utility function that allows for piping a series of async functions together
|
|
5
|
+
*
|
|
6
|
+
* @param {((s: S, o?: O, f?: F) => Promise<S>)[]} fns - functions to pipe
|
|
7
|
+
* @returns {S} result of the pipe
|
|
8
|
+
*/
|
|
3
9
|
export declare const asyncPipe: <S, O, F>(...fns: ((s: S, o?: O | undefined, f?: F | undefined) => Promise<S>)[]) => (s: S, o?: O | undefined, f?: F | undefined) => Promise<S>;
|
|
4
10
|
export type Deferrable<T> = {
|
|
5
11
|
[K in keyof T]: PromiseOrValue<T[K]>;
|
|
6
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Await all of the properties of a Deferrable object
|
|
15
|
+
*
|
|
16
|
+
* @param {Deferrable<T>} object - a Deferrable object
|
|
17
|
+
* @returns {Promise<T>} the object with its properties resolved
|
|
18
|
+
*/
|
|
7
19
|
export declare function resolveProperties<T>(object: Deferrable<T>): Promise<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Recursively converts all values in an object to hex strings
|
|
22
|
+
*
|
|
23
|
+
* @param {any} obj - obj to deep hexlify
|
|
24
|
+
* @returns {any} object with all of its values hexlified
|
|
25
|
+
*/
|
|
8
26
|
export declare function deepHexlify(obj: any): any;
|
|
27
|
+
/**
|
|
28
|
+
* Filters out properties with undefined or null values from the provided object.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { filterUndefined } from "@aa-sdk/core";
|
|
33
|
+
*
|
|
34
|
+
* const result = filterUndefined({
|
|
35
|
+
* foo: undefined,
|
|
36
|
+
* bar: null,
|
|
37
|
+
* baz: "baz",
|
|
38
|
+
* }); // { baz: "baz" }
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @param {T} obj the object from which to remove properties with undefined or null values
|
|
42
|
+
* @returns {T} the object with undefined or null properties removed
|
|
43
|
+
*/
|
|
9
44
|
export declare function filterUndefined<T>(obj: T): T;
|
|
45
|
+
/**
|
|
46
|
+
* Picks the specified keys from an object and returns a new object containing only those key-value pairs.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { pick } from "@aa-sdk/core";
|
|
51
|
+
*
|
|
52
|
+
* const picked = pick({
|
|
53
|
+
* foo: "foo",
|
|
54
|
+
* bar: "bar",
|
|
55
|
+
* }, ["foo"]); // { foo: "foo" }
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @param {Record<string, unknown>} obj The object from which to pick keys
|
|
59
|
+
* @param {string|string[]} keys A single key or an array of keys to pick from the object
|
|
60
|
+
* @returns {Record<string, unknown>} A new object containing only the picked key-value pairs
|
|
61
|
+
*/
|
|
10
62
|
export declare function pick(obj: Record<string, unknown>, keys: string | string[]): {};
|
|
63
|
+
/**
|
|
64
|
+
* Utility method for checking if the passed in values are all equal (strictly)
|
|
65
|
+
*
|
|
66
|
+
* @param {...any[]} params - values to check
|
|
67
|
+
* @returns {boolean} a boolean indicating if all values are the same
|
|
68
|
+
* @throws if no values are passed in
|
|
69
|
+
*/
|
|
11
70
|
export declare const allEqual: (...params: any[]) => boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Utility method for checking the condition and return the value if condition holds true, undefined if not.
|
|
73
|
+
*
|
|
74
|
+
* @param {Promise<boolean>} condition - condition to check
|
|
75
|
+
* @param {() => Promise<T>} value - value to return when condition holds true
|
|
76
|
+
* @returns {Promise<T | undefined>} the value if condition holds true, undefined if not
|
|
77
|
+
*/
|
|
12
78
|
export declare const conditionalReturn: <T>(condition: Promise<boolean>, value: () => Promise<T>) => Promise<T | undefined>;
|
|
79
|
+
/**
|
|
80
|
+
* Converts an array of objects into a record (object) where each key is determined by the specified selector and the value is determined by the provided function.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { toRecord } from "@aa-sdk/core";
|
|
85
|
+
* import { sepolia, mainnet } from "viem/chains";
|
|
86
|
+
*
|
|
87
|
+
* const addressesByChain = toRecord(
|
|
88
|
+
* [sepolia, mainnet],
|
|
89
|
+
* "id",
|
|
90
|
+
* () => "0x..."
|
|
91
|
+
* ); // { [sepolia.id]: "0x...", [mainnet.id]: "0x..." }
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @param {T[]} array The array of objects to convert to a record
|
|
95
|
+
* @param {K} selector The key used to select the property that will become the record's key
|
|
96
|
+
* @param {(item: T) => V} fn The function that transforms each item in the array into the record's value
|
|
97
|
+
* @returns {Record<T[K], V>} The resulting record object
|
|
98
|
+
*/
|
|
13
99
|
export declare const toRecord: <T extends { [K in RecordableKeys<T>]: string | number | symbol; }, K_1 extends RecordableKeys<T>, V>(array: T[], selector: K_1, fn: (item: T) => V) => Record<T[K_1], V>;
|
|
14
100
|
export * from "./bigint.js";
|
|
15
101
|
export * from "./bytes.js";
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { toHex } from "viem";
|
|
2
|
+
/**
|
|
3
|
+
* Utility function that allows for piping a series of async functions together
|
|
4
|
+
*
|
|
5
|
+
* @param {((s: S, o?: O, f?: F) => Promise<S>)[]} fns - functions to pipe
|
|
6
|
+
* @returns {S} result of the pipe
|
|
7
|
+
*/
|
|
2
8
|
export const asyncPipe = (...fns) => async (s, o, f) => {
|
|
3
9
|
let result = s;
|
|
4
10
|
for (const fn of fns) {
|
|
@@ -6,6 +12,12 @@ export const asyncPipe = (...fns) => async (s, o, f) => {
|
|
|
6
12
|
}
|
|
7
13
|
return result;
|
|
8
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Await all of the properties of a Deferrable object
|
|
17
|
+
*
|
|
18
|
+
* @param {Deferrable<T>} object - a Deferrable object
|
|
19
|
+
* @returns {Promise<T>} the object with its properties resolved
|
|
20
|
+
*/
|
|
9
21
|
export async function resolveProperties(object) {
|
|
10
22
|
const promises = Object.keys(object).map((key) => {
|
|
11
23
|
const value = object[key];
|
|
@@ -17,6 +29,12 @@ export async function resolveProperties(object) {
|
|
|
17
29
|
return accum;
|
|
18
30
|
}, {}));
|
|
19
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Recursively converts all values in an object to hex strings
|
|
34
|
+
*
|
|
35
|
+
* @param {any} obj - obj to deep hexlify
|
|
36
|
+
* @returns {any} object with all of its values hexlified
|
|
37
|
+
*/
|
|
20
38
|
export function deepHexlify(obj) {
|
|
21
39
|
if (typeof obj === "function") {
|
|
22
40
|
return undefined;
|
|
@@ -38,6 +56,23 @@ export function deepHexlify(obj) {
|
|
|
38
56
|
[key]: deepHexlify(obj[key]),
|
|
39
57
|
}), {});
|
|
40
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Filters out properties with undefined or null values from the provided object.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { filterUndefined } from "@aa-sdk/core";
|
|
65
|
+
*
|
|
66
|
+
* const result = filterUndefined({
|
|
67
|
+
* foo: undefined,
|
|
68
|
+
* bar: null,
|
|
69
|
+
* baz: "baz",
|
|
70
|
+
* }); // { baz: "baz" }
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @param {T} obj the object from which to remove properties with undefined or null values
|
|
74
|
+
* @returns {T} the object with undefined or null properties removed
|
|
75
|
+
*/
|
|
41
76
|
export function filterUndefined(obj) {
|
|
42
77
|
for (const key in obj) {
|
|
43
78
|
if (obj[key] == null) {
|
|
@@ -46,18 +81,69 @@ export function filterUndefined(obj) {
|
|
|
46
81
|
}
|
|
47
82
|
return obj;
|
|
48
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Picks the specified keys from an object and returns a new object containing only those key-value pairs.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* import { pick } from "@aa-sdk/core";
|
|
90
|
+
*
|
|
91
|
+
* const picked = pick({
|
|
92
|
+
* foo: "foo",
|
|
93
|
+
* bar: "bar",
|
|
94
|
+
* }, ["foo"]); // { foo: "foo" }
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @param {Record<string, unknown>} obj The object from which to pick keys
|
|
98
|
+
* @param {string|string[]} keys A single key or an array of keys to pick from the object
|
|
99
|
+
* @returns {Record<string, unknown>} A new object containing only the picked key-value pairs
|
|
100
|
+
*/
|
|
49
101
|
export function pick(obj, keys) {
|
|
50
102
|
return Object.keys(obj)
|
|
51
103
|
.filter((k) => keys.includes(k))
|
|
52
104
|
.reduce((res, k) => Object.assign(res, { [k]: obj[k] }), {});
|
|
53
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Utility method for checking if the passed in values are all equal (strictly)
|
|
108
|
+
*
|
|
109
|
+
* @param {...any[]} params - values to check
|
|
110
|
+
* @returns {boolean} a boolean indicating if all values are the same
|
|
111
|
+
* @throws if no values are passed in
|
|
112
|
+
*/
|
|
54
113
|
export const allEqual = (...params) => {
|
|
55
114
|
if (params.length === 0) {
|
|
56
115
|
throw new Error("no values passed in");
|
|
57
116
|
}
|
|
58
117
|
return params.every((v) => v === params[0]);
|
|
59
118
|
};
|
|
119
|
+
/**
|
|
120
|
+
* Utility method for checking the condition and return the value if condition holds true, undefined if not.
|
|
121
|
+
*
|
|
122
|
+
* @param {Promise<boolean>} condition - condition to check
|
|
123
|
+
* @param {() => Promise<T>} value - value to return when condition holds true
|
|
124
|
+
* @returns {Promise<T | undefined>} the value if condition holds true, undefined if not
|
|
125
|
+
*/
|
|
60
126
|
export const conditionalReturn = (condition, value) => condition.then((t) => (t ? value() : undefined));
|
|
127
|
+
/**
|
|
128
|
+
* Converts an array of objects into a record (object) where each key is determined by the specified selector and the value is determined by the provided function.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* import { toRecord } from "@aa-sdk/core";
|
|
133
|
+
* import { sepolia, mainnet } from "viem/chains";
|
|
134
|
+
*
|
|
135
|
+
* const addressesByChain = toRecord(
|
|
136
|
+
* [sepolia, mainnet],
|
|
137
|
+
* "id",
|
|
138
|
+
* () => "0x..."
|
|
139
|
+
* ); // { [sepolia.id]: "0x...", [mainnet.id]: "0x..." }
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @param {T[]} array The array of objects to convert to a record
|
|
143
|
+
* @param {K} selector The key used to select the property that will become the record's key
|
|
144
|
+
* @param {(item: T) => V} fn The function that transforms each item in the array into the record's value
|
|
145
|
+
* @returns {Record<T[K], V>} The resulting record object
|
|
146
|
+
*/
|
|
61
147
|
export const toRecord = (array, selector, fn) => array.reduce((acc, item) => {
|
|
62
148
|
acc[item[selector]] = fn(item);
|
|
63
149
|
return acc;
|