permissionless 0.0.11 → 0.0.13
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/CHANGELOG.md +16 -0
- package/_cjs/accounts/index.js +14 -0
- package/_cjs/accounts/index.js.map +1 -0
- package/_cjs/accounts/privateKeyToSafeSmartAccount.js +24 -0
- package/_cjs/accounts/privateKeyToSafeSmartAccount.js.map +1 -0
- package/_cjs/accounts/privateKeyToSimpleSmartAccount.js +16 -0
- package/_cjs/accounts/privateKeyToSimpleSmartAccount.js.map +1 -0
- package/_cjs/accounts/signerToSafeSmartAccount.js +492 -0
- package/_cjs/accounts/signerToSafeSmartAccount.js.map +1 -0
- package/_cjs/accounts/signerToSimpleSmartAccount.js +190 -0
- package/_cjs/accounts/signerToSimpleSmartAccount.js.map +1 -0
- package/_cjs/accounts/types.js +23 -0
- package/_cjs/accounts/types.js.map +1 -0
- package/_cjs/actions/bundler/chainId.js.map +1 -1
- package/_cjs/actions/bundler/estimateUserOperationGas.js +4 -1
- package/_cjs/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/_cjs/actions/bundler/getUserOperationByHash.js.map +1 -1
- package/_cjs/actions/bundler/getUserOperationReceipt.js.map +1 -1
- package/_cjs/actions/bundler/sendUserOperation.js +4 -1
- package/_cjs/actions/bundler/sendUserOperation.js.map +1 -1
- package/_cjs/actions/bundler/supportedEntryPoints.js.map +1 -1
- package/_cjs/actions/bundler/waitForUserOperationReceipt.js +7 -2
- package/_cjs/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/pimlico/getUserOperationGasPrice.js.map +1 -1
- package/_cjs/actions/pimlico/getUserOperationStatus.js.map +1 -1
- package/_cjs/actions/pimlico/sponsorUserOperation.js +4 -1
- package/_cjs/actions/pimlico/sponsorUserOperation.js.map +1 -1
- package/_cjs/actions/pimlico.js.map +1 -1
- package/_cjs/actions/public/getAccountNonce.js +4 -2
- package/_cjs/actions/public/getAccountNonce.js.map +1 -1
- package/_cjs/actions/public/getSenderAddress.js +7 -3
- package/_cjs/actions/public/getSenderAddress.js.map +1 -1
- package/_cjs/actions/smartAccount/deployContract.js +38 -0
- package/_cjs/actions/smartAccount/deployContract.js.map +1 -0
- package/_cjs/actions/smartAccount/prepareUserOperationRequest.js +73 -0
- package/_cjs/actions/smartAccount/prepareUserOperationRequest.js.map +1 -0
- package/_cjs/actions/smartAccount/sendTransaction.js +44 -0
- package/_cjs/actions/smartAccount/sendTransaction.js.map +1 -0
- package/_cjs/actions/smartAccount/sendTransactions.js +46 -0
- package/_cjs/actions/smartAccount/sendTransactions.js.map +1 -0
- package/_cjs/actions/smartAccount/sendUserOperation.js +22 -0
- package/_cjs/actions/smartAccount/sendUserOperation.js.map +1 -0
- package/_cjs/actions/smartAccount/signMessage.js +16 -0
- package/_cjs/actions/smartAccount/signMessage.js.map +1 -0
- package/_cjs/actions/smartAccount/signTypedData.js +34 -0
- package/_cjs/actions/smartAccount/signTypedData.js.map +1 -0
- package/_cjs/actions/smartAccount/writeContract.js +21 -0
- package/_cjs/actions/smartAccount/writeContract.js.map +1 -0
- package/_cjs/actions/smartAccount.js +18 -0
- package/_cjs/actions/smartAccount.js.map +1 -0
- package/_cjs/actions/stackup/sponsorUserOperation.js +5 -1
- package/_cjs/actions/stackup/sponsorUserOperation.js.map +1 -1
- package/_cjs/clients/{bundler.js → createBundlerClient.js} +1 -1
- package/_cjs/clients/createBundlerClient.js.map +1 -0
- package/_cjs/clients/createSmartAccountClient.js +20 -0
- package/_cjs/clients/createSmartAccountClient.js.map +1 -0
- package/_cjs/clients/decorators/bundler.js.map +1 -1
- package/_cjs/clients/decorators/pimlico.js.map +1 -1
- package/_cjs/clients/decorators/smartAccount.js +33 -0
- package/_cjs/clients/decorators/smartAccount.js.map +1 -0
- package/_cjs/clients/decorators/stackup.js.map +1 -1
- package/_cjs/clients/pimlico.js.map +1 -1
- package/_cjs/clients/stackup.js.map +1 -1
- package/_cjs/index.js +9 -5
- package/_cjs/index.js.map +1 -1
- package/_cjs/utils/deepHexlify.js +4 -4
- package/_cjs/utils/deepHexlify.js.map +1 -1
- package/_cjs/utils/getAction.js +8 -0
- package/_cjs/utils/getAction.js.map +1 -0
- package/_cjs/utils/getUserOperationHash.js.map +1 -1
- package/_cjs/utils/index.js +7 -1
- package/_cjs/utils/index.js.map +1 -1
- package/_cjs/utils/observe.js +7 -2
- package/_cjs/utils/observe.js.map +1 -1
- package/_cjs/utils/signUserOperationHashWithECDSA.js +7 -7
- package/_cjs/utils/signUserOperationHashWithECDSA.js.map +1 -1
- package/_esm/accounts/index.js +7 -0
- package/_esm/accounts/index.js.map +1 -0
- package/_esm/accounts/privateKeyToSafeSmartAccount.js +26 -0
- package/_esm/accounts/privateKeyToSafeSmartAccount.js.map +1 -0
- package/_esm/accounts/privateKeyToSimpleSmartAccount.js +18 -0
- package/_esm/accounts/privateKeyToSimpleSmartAccount.js.map +1 -0
- package/_esm/accounts/signerToSafeSmartAccount.js +499 -0
- package/_esm/accounts/signerToSafeSmartAccount.js.map +1 -0
- package/_esm/accounts/signerToSimpleSmartAccount.js +191 -0
- package/_esm/accounts/signerToSimpleSmartAccount.js.map +1 -0
- package/_esm/accounts/types.js +20 -0
- package/_esm/accounts/types.js.map +1 -0
- package/_esm/actions/bundler/chainId.js.map +1 -1
- package/_esm/actions/bundler/estimateUserOperationGas.js +4 -1
- package/_esm/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/_esm/actions/bundler/getUserOperationByHash.js.map +1 -1
- package/_esm/actions/bundler/getUserOperationReceipt.js.map +1 -1
- package/_esm/actions/bundler/sendUserOperation.js +4 -3
- package/_esm/actions/bundler/sendUserOperation.js.map +1 -1
- package/_esm/actions/bundler/supportedEntryPoints.js.map +1 -1
- package/_esm/actions/bundler/waitForUserOperationReceipt.js +7 -2
- package/_esm/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/pimlico/getUserOperationGasPrice.js +2 -2
- package/_esm/actions/pimlico/getUserOperationGasPrice.js.map +1 -1
- package/_esm/actions/pimlico/getUserOperationStatus.js +1 -1
- package/_esm/actions/pimlico/getUserOperationStatus.js.map +1 -1
- package/_esm/actions/pimlico/sponsorUserOperation.js +4 -1
- package/_esm/actions/pimlico/sponsorUserOperation.js.map +1 -1
- package/_esm/actions/pimlico.js.map +1 -1
- package/_esm/actions/public/getAccountNonce.js +7 -5
- package/_esm/actions/public/getAccountNonce.js.map +1 -1
- package/_esm/actions/public/getSenderAddress.js +8 -5
- package/_esm/actions/public/getSenderAddress.js.map +1 -1
- package/_esm/actions/smartAccount/deployContract.js +64 -0
- package/_esm/actions/smartAccount/deployContract.js.map +1 -0
- package/_esm/actions/smartAccount/prepareUserOperationRequest.js +69 -0
- package/_esm/actions/smartAccount/prepareUserOperationRequest.js.map +1 -0
- package/_esm/actions/smartAccount/sendTransaction.js +88 -0
- package/_esm/actions/smartAccount/sendTransaction.js.map +1 -0
- package/_esm/actions/smartAccount/sendTransactions.js +90 -0
- package/_esm/actions/smartAccount/sendTransactions.js.map +1 -0
- package/_esm/actions/smartAccount/sendUserOperation.js +18 -0
- package/_esm/actions/smartAccount/sendUserOperation.js.map +1 -0
- package/_esm/actions/smartAccount/signMessage.js +59 -0
- package/_esm/actions/smartAccount/signMessage.js.map +1 -0
- package/_esm/actions/smartAccount/signTypedData.js +129 -0
- package/_esm/actions/smartAccount/signTypedData.js.map +1 -0
- package/_esm/actions/smartAccount/writeContract.js +19 -0
- package/_esm/actions/smartAccount/writeContract.js.map +1 -0
- package/_esm/actions/smartAccount.js +9 -0
- package/_esm/actions/smartAccount.js.map +1 -0
- package/_esm/actions/stackup/accounts.js +1 -1
- package/_esm/actions/stackup/sponsorUserOperation.js +6 -2
- package/_esm/actions/stackup/sponsorUserOperation.js.map +1 -1
- package/_esm/clients/{bundler.js → createBundlerClient.js} +1 -1
- package/_esm/clients/createBundlerClient.js.map +1 -0
- package/_esm/clients/createSmartAccountClient.js +38 -0
- package/_esm/clients/createSmartAccountClient.js.map +1 -0
- package/_esm/clients/decorators/bundler.js.map +1 -1
- package/_esm/clients/decorators/pimlico.js +1 -1
- package/_esm/clients/decorators/pimlico.js.map +1 -1
- package/_esm/clients/decorators/smartAccount.js +29 -0
- package/_esm/clients/decorators/smartAccount.js.map +1 -0
- package/_esm/clients/decorators/stackup.js.map +1 -1
- package/_esm/clients/pimlico.js +1 -1
- package/_esm/clients/pimlico.js.map +1 -1
- package/_esm/clients/stackup.js +1 -1
- package/_esm/clients/stackup.js.map +1 -1
- package/_esm/index.js +5 -2
- package/_esm/index.js.map +1 -1
- package/_esm/utils/deepHexlify.js +6 -4
- package/_esm/utils/deepHexlify.js.map +1 -1
- package/_esm/utils/getAction.js +6 -0
- package/_esm/utils/getAction.js.map +1 -0
- package/_esm/utils/getUserOperationHash.js.map +1 -1
- package/_esm/utils/index.js +5 -0
- package/_esm/utils/index.js.map +1 -1
- package/_esm/utils/observe.js +7 -2
- package/_esm/utils/observe.js.map +1 -1
- package/_esm/utils/signUserOperationHashWithECDSA.js +7 -6
- package/_esm/utils/signUserOperationHashWithECDSA.js.map +1 -1
- package/_types/accounts/index.d.ts +7 -0
- package/_types/accounts/index.d.ts.map +1 -0
- package/_types/accounts/privateKeyToSafeSmartAccount.d.ts +26 -0
- package/_types/accounts/privateKeyToSafeSmartAccount.d.ts.map +1 -0
- package/_types/accounts/privateKeyToSimpleSmartAccount.d.ts +14 -0
- package/_types/accounts/privateKeyToSimpleSmartAccount.d.ts.map +1 -0
- package/_types/accounts/signerToSafeSmartAccount.d.ts +28 -0
- package/_types/accounts/signerToSafeSmartAccount.d.ts.map +1 -0
- package/_types/accounts/signerToSimpleSmartAccount.d.ts +15 -0
- package/_types/accounts/signerToSimpleSmartAccount.d.ts.map +1 -0
- package/_types/accounts/types.d.ts +32 -0
- package/_types/accounts/types.d.ts.map +1 -0
- package/_types/actions/bundler/chainId.d.ts +3 -2
- package/_types/actions/bundler/chainId.d.ts.map +1 -1
- package/_types/actions/bundler/estimateUserOperationGas.d.ts +3 -3
- package/_types/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
- package/_types/actions/bundler/getUserOperationByHash.d.ts +3 -3
- package/_types/actions/bundler/getUserOperationByHash.d.ts.map +1 -1
- package/_types/actions/bundler/getUserOperationReceipt.d.ts +3 -3
- package/_types/actions/bundler/getUserOperationReceipt.d.ts.map +1 -1
- package/_types/actions/bundler/sendUserOperation.d.ts +3 -5
- package/_types/actions/bundler/sendUserOperation.d.ts.map +1 -1
- package/_types/actions/bundler/supportedEntryPoints.d.ts +3 -3
- package/_types/actions/bundler/supportedEntryPoints.d.ts.map +1 -1
- package/_types/actions/bundler/waitForUserOperationReceipt.d.ts +2 -3
- package/_types/actions/bundler/waitForUserOperationReceipt.d.ts.map +1 -1
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/pimlico/getUserOperationGasPrice.d.ts +5 -4
- package/_types/actions/pimlico/getUserOperationGasPrice.d.ts.map +1 -1
- package/_types/actions/pimlico/getUserOperationStatus.d.ts +4 -5
- package/_types/actions/pimlico/getUserOperationStatus.d.ts.map +1 -1
- package/_types/actions/pimlico/sponsorUserOperation.d.ts +3 -3
- package/_types/actions/pimlico/sponsorUserOperation.d.ts.map +1 -1
- package/_types/actions/pimlico.d.ts.map +1 -1
- package/_types/actions/public/getAccountNonce.d.ts +5 -5
- package/_types/actions/public/getAccountNonce.d.ts.map +1 -1
- package/_types/actions/public/getSenderAddress.d.ts +3 -4
- package/_types/actions/public/getSenderAddress.d.ts.map +1 -1
- package/_types/actions/smartAccount/deployContract.d.ts +34 -0
- package/_types/actions/smartAccount/deployContract.d.ts.map +1 -0
- package/_types/actions/smartAccount/prepareUserOperationRequest.d.ts +20 -0
- package/_types/actions/smartAccount/prepareUserOperationRequest.d.ts.map +1 -0
- package/_types/actions/smartAccount/sendTransaction.d.ts +52 -0
- package/_types/actions/smartAccount/sendTransaction.d.ts.map +1 -0
- package/_types/actions/smartAccount/sendTransactions.d.ts +63 -0
- package/_types/actions/smartAccount/sendTransactions.d.ts.map +1 -0
- package/_types/actions/smartAccount/sendUserOperation.d.ts +10 -0
- package/_types/actions/smartAccount/sendUserOperation.d.ts.map +1 -0
- package/_types/actions/smartAccount/signMessage.d.ts +50 -0
- package/_types/actions/smartAccount/signMessage.d.ts.map +1 -0
- package/_types/actions/smartAccount/signTypedData.d.ts +104 -0
- package/_types/actions/smartAccount/signTypedData.d.ts.map +1 -0
- package/_types/actions/smartAccount/writeContract.d.ts +57 -0
- package/_types/actions/smartAccount/writeContract.d.ts.map +1 -0
- package/_types/actions/smartAccount.d.ts +9 -0
- package/_types/actions/smartAccount.d.ts.map +1 -0
- package/_types/actions/stackup/accounts.d.ts +1 -1
- package/_types/actions/stackup/sponsorUserOperation.d.ts +1 -1
- package/_types/actions/stackup/sponsorUserOperation.d.ts.map +1 -1
- package/_types/clients/{bundler.d.ts → createBundlerClient.d.ts} +1 -1
- package/_types/clients/createBundlerClient.d.ts.map +1 -0
- package/_types/clients/createSmartAccountClient.d.ts +282 -0
- package/_types/clients/createSmartAccountClient.d.ts.map +1 -0
- package/_types/clients/decorators/bundler.d.ts +1 -1
- package/_types/clients/decorators/bundler.d.ts.map +1 -1
- package/_types/clients/decorators/pimlico.d.ts +3 -3
- package/_types/clients/decorators/pimlico.d.ts.map +1 -1
- package/_types/clients/decorators/smartAccount.d.ts +327 -0
- package/_types/clients/decorators/smartAccount.d.ts.map +1 -0
- package/_types/clients/decorators/stackup.d.ts.map +1 -1
- package/_types/clients/pimlico.d.ts +1 -1
- package/_types/clients/pimlico.d.ts.map +1 -1
- package/_types/clients/stackup.d.ts +1 -1
- package/_types/clients/stackup.d.ts.map +1 -1
- package/_types/index.d.ts +6 -3
- package/_types/index.d.ts.map +1 -1
- package/_types/types/bundler.d.ts +4 -1
- package/_types/types/bundler.d.ts.map +1 -1
- package/_types/types/index.d.ts +20 -0
- package/_types/types/index.d.ts.map +1 -1
- package/_types/types/pimlico.d.ts.map +1 -1
- package/_types/types/stackup.d.ts.map +1 -1
- package/_types/utils/deepHexlify.d.ts.map +1 -1
- package/_types/utils/getAction.d.ts +3 -0
- package/_types/utils/getAction.d.ts.map +1 -0
- package/_types/utils/getUserOperationHash.d.ts.map +1 -1
- package/_types/utils/index.d.ts +2 -0
- package/_types/utils/index.d.ts.map +1 -1
- package/_types/utils/observe.d.ts.map +1 -1
- package/_types/utils/signUserOperationHashWithECDSA.d.ts +3 -11
- package/_types/utils/signUserOperationHashWithECDSA.d.ts.map +1 -1
- package/accounts/index.ts +33 -0
- package/accounts/privateKeyToSafeSmartAccount.ts +73 -0
- package/accounts/privateKeyToSimpleSmartAccount.ts +44 -0
- package/accounts/signerToSafeSmartAccount.ts +775 -0
- package/accounts/signerToSimpleSmartAccount.ts +267 -0
- package/accounts/types.ts +64 -0
- package/actions/bundler/chainId.ts +10 -2
- package/actions/bundler/estimateUserOperationGas.ts +17 -6
- package/actions/bundler/getUserOperationByHash.ts +16 -5
- package/actions/bundler/getUserOperationReceipt.ts +17 -4
- package/actions/bundler/sendUserOperation.ts +19 -7
- package/actions/bundler/supportedEntryPoints.ts +10 -3
- package/actions/bundler/waitForUserOperationReceipt.ts +64 -26
- package/actions/index.ts +4 -1
- package/actions/pimlico/getUserOperationGasPrice.ts +13 -6
- package/actions/pimlico/getUserOperationStatus.ts +12 -5
- package/actions/pimlico/sponsorUserOperation.ts +20 -7
- package/actions/pimlico.ts +8 -2
- package/actions/public/getAccountNonce.ts +20 -8
- package/actions/public/getSenderAddress.ts +25 -8
- package/actions/smartAccount/deployContract.ts +110 -0
- package/actions/smartAccount/prepareUserOperationRequest.ts +140 -0
- package/actions/smartAccount/sendTransaction.ts +138 -0
- package/actions/smartAccount/sendTransactions.ts +141 -0
- package/actions/smartAccount/sendUserOperation.ts +70 -0
- package/actions/smartAccount/signMessage.ts +79 -0
- package/actions/smartAccount/signTypedData.ts +161 -0
- package/actions/smartAccount/writeContract.ts +126 -0
- package/actions/smartAccount.ts +49 -0
- package/actions/stackup/accounts.ts +1 -1
- package/actions/stackup/sponsorUserOperation.ts +14 -4
- package/clients/{bundler.ts → createBundlerClient.ts} +14 -3
- package/clients/createSmartAccountClient.ts +95 -0
- package/clients/decorators/bundler.ts +20 -10
- package/clients/decorators/pimlico.ts +21 -9
- package/clients/decorators/smartAccount.ts +451 -0
- package/clients/decorators/stackup.ts +12 -4
- package/clients/pimlico.ts +20 -5
- package/clients/stackup.ts +17 -4
- package/index.ts +20 -3
- package/package.json +12 -2
- package/types/bundler.ts +4 -1
- package/types/index.ts +29 -0
- package/types/pimlico.ts +12 -2
- package/types/stackup.ts +4 -1
- package/utils/deepHexlify.test.ts +13 -7
- package/utils/deepHexlify.ts +5 -4
- package/utils/getAction.ts +15 -0
- package/utils/getUserOperationHash.ts +10 -2
- package/utils/index.ts +15 -2
- package/utils/observe.ts +18 -5
- package/utils/signUserOperationHashWithECDSA.ts +17 -20
- package/_cjs/clients/bundler.js.map +0 -1
- package/_esm/clients/bundler.js.map +0 -1
- package/_types/clients/bundler.d.ts.map +0 -1
- package/tsconfig.build.tsbuildinfo +0 -1
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Abi,
|
|
3
|
+
Chain,
|
|
4
|
+
Client,
|
|
5
|
+
DeployContractParameters,
|
|
6
|
+
SendTransactionParameters,
|
|
7
|
+
Transport,
|
|
8
|
+
TypedData,
|
|
9
|
+
WriteContractParameters
|
|
10
|
+
} from "viem"
|
|
11
|
+
import type { SmartAccount } from "../../accounts/types.js"
|
|
12
|
+
import {
|
|
13
|
+
type SendTransactionsWithPaymasterParameters,
|
|
14
|
+
sendTransactions
|
|
15
|
+
} from "../../actions/smartAccount.js"
|
|
16
|
+
import {
|
|
17
|
+
type DeployContractParametersWithPaymaster,
|
|
18
|
+
deployContract
|
|
19
|
+
} from "../../actions/smartAccount/deployContract.js"
|
|
20
|
+
import {
|
|
21
|
+
type PrepareUserOperationRequestReturnType,
|
|
22
|
+
type SponsorUserOperationMiddleware,
|
|
23
|
+
prepareUserOperationRequest
|
|
24
|
+
} from "../../actions/smartAccount/prepareUserOperationRequest.js"
|
|
25
|
+
import {
|
|
26
|
+
type SendTransactionWithPaymasterParameters,
|
|
27
|
+
sendTransaction
|
|
28
|
+
} from "../../actions/smartAccount/sendTransaction.js"
|
|
29
|
+
import { signMessage } from "../../actions/smartAccount/signMessage.js"
|
|
30
|
+
import { signTypedData } from "../../actions/smartAccount/signTypedData.js"
|
|
31
|
+
import {
|
|
32
|
+
type WriteContractWithPaymasterParameters,
|
|
33
|
+
writeContract
|
|
34
|
+
} from "../../actions/smartAccount/writeContract.js"
|
|
35
|
+
|
|
36
|
+
export type SmartAccountActions<
|
|
37
|
+
TChain extends Chain | undefined = Chain | undefined,
|
|
38
|
+
TSmartAccount extends SmartAccount | undefined = SmartAccount | undefined
|
|
39
|
+
> = {
|
|
40
|
+
/**
|
|
41
|
+
* Creates, signs, and sends a new transaction to the network.
|
|
42
|
+
* This function also allows you to sponsor this transaction if sender is a smartAccount
|
|
43
|
+
*
|
|
44
|
+
* - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html
|
|
45
|
+
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions
|
|
46
|
+
* - JSON-RPC Methods:
|
|
47
|
+
* - JSON-RPC Accounts: [`eth_sendTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendtransaction)
|
|
48
|
+
* - Local Accounts: [`eth_sendRawTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction)
|
|
49
|
+
*
|
|
50
|
+
* @param args - {@link SendTransactionParameters}
|
|
51
|
+
* @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash. {@link SendTransactionReturnType}
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* import { createWalletClient, custom } from 'viem'
|
|
55
|
+
* import { mainnet } from 'viem/chains'
|
|
56
|
+
*
|
|
57
|
+
* const client = createWalletClient({
|
|
58
|
+
* chain: mainnet,
|
|
59
|
+
* transport: custom(window.ethereum),
|
|
60
|
+
* })
|
|
61
|
+
* const hash = await client.sendTransaction({
|
|
62
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
63
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
64
|
+
* value: 1000000000000000000n,
|
|
65
|
+
* })
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* // Account Hoisting
|
|
69
|
+
* import { createWalletClient, http } from 'viem'
|
|
70
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
71
|
+
* import { mainnet } from 'viem/chains'
|
|
72
|
+
*
|
|
73
|
+
* const client = createWalletClient({
|
|
74
|
+
* account: privateKeyToAccount('0x…'),
|
|
75
|
+
* chain: mainnet,
|
|
76
|
+
* transport: http(),
|
|
77
|
+
* })
|
|
78
|
+
* const hash = await client.sendTransaction({
|
|
79
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
80
|
+
* value: 1000000000000000000n,
|
|
81
|
+
* })
|
|
82
|
+
*/
|
|
83
|
+
sendTransaction: <TChainOverride extends Chain | undefined>(
|
|
84
|
+
args: SendTransactionParameters<TChain, TSmartAccount, TChainOverride>
|
|
85
|
+
) => ReturnType<
|
|
86
|
+
typeof sendTransaction<TChain, TSmartAccount, TChainOverride>
|
|
87
|
+
>
|
|
88
|
+
/**
|
|
89
|
+
* Calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191): `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`.
|
|
90
|
+
*
|
|
91
|
+
* - Docs: https://viem.sh/docs/actions/wallet/signMessage.html
|
|
92
|
+
* - JSON-RPC Methods:
|
|
93
|
+
* - JSON-RPC Accounts: [`personal_sign`](https://docs.metamask.io/guide/signing-data.html#personal-sign)
|
|
94
|
+
* - Local Accounts: Signs locally. No JSON-RPC request.
|
|
95
|
+
*
|
|
96
|
+
* With the calculated signature, you can:
|
|
97
|
+
* - use [`verifyMessage`](https://viem.sh/docs/utilities/verifyMessage.html) to verify the signature,
|
|
98
|
+
* - use [`recoverMessageAddress`](https://viem.sh/docs/utilities/recoverMessageAddress.html) to recover the signing address from a signature.
|
|
99
|
+
*
|
|
100
|
+
* @param args - {@link SignMessageParameters}
|
|
101
|
+
* @returns The signed message. {@link SignMessageReturnType}
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* import { createWalletClient, custom } from 'viem'
|
|
105
|
+
* import { mainnet } from 'viem/chains'
|
|
106
|
+
*
|
|
107
|
+
* const client = createWalletClient({
|
|
108
|
+
* chain: mainnet,
|
|
109
|
+
* transport: custom(window.ethereum),
|
|
110
|
+
* })
|
|
111
|
+
* const signature = await client.signMessage({
|
|
112
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
113
|
+
* message: 'hello world',
|
|
114
|
+
* })
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* // Account Hoisting
|
|
118
|
+
* import { createWalletClient, http } from 'viem'
|
|
119
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
120
|
+
* import { mainnet } from 'viem/chains'
|
|
121
|
+
*
|
|
122
|
+
* const client = createWalletClient({
|
|
123
|
+
* account: privateKeyToAccount('0x…'),
|
|
124
|
+
* chain: mainnet,
|
|
125
|
+
* transport: http(),
|
|
126
|
+
* })
|
|
127
|
+
* const signature = await client.signMessage({
|
|
128
|
+
* message: 'hello world',
|
|
129
|
+
* })
|
|
130
|
+
*/
|
|
131
|
+
signMessage: (
|
|
132
|
+
args: Parameters<typeof signMessage<TChain, TSmartAccount>>[1]
|
|
133
|
+
) => ReturnType<typeof signMessage<TChain, TSmartAccount>>
|
|
134
|
+
/**
|
|
135
|
+
* Signs typed data and calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191): `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`.
|
|
136
|
+
*
|
|
137
|
+
* - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html
|
|
138
|
+
* - JSON-RPC Methods:
|
|
139
|
+
* - JSON-RPC Accounts: [`eth_signTypedData_v4`](https://docs.metamask.io/guide/signing-data.html#signtypeddata-v4)
|
|
140
|
+
* - Local Accounts: Signs locally. No JSON-RPC request.
|
|
141
|
+
*
|
|
142
|
+
* @param client - Client to use
|
|
143
|
+
* @param args - {@link SignTypedDataParameters}
|
|
144
|
+
* @returns The signed data. {@link SignTypedDataReturnType}
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* import { createWalletClient, custom } from 'viem'
|
|
148
|
+
* import { mainnet } from 'viem/chains'
|
|
149
|
+
*
|
|
150
|
+
* const client = createWalletClient({
|
|
151
|
+
* chain: mainnet,
|
|
152
|
+
* transport: custom(window.ethereum),
|
|
153
|
+
* })
|
|
154
|
+
* const signature = await client.signTypedData({
|
|
155
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
156
|
+
* domain: {
|
|
157
|
+
* name: 'Ether Mail',
|
|
158
|
+
* version: '1',
|
|
159
|
+
* chainId: 1,
|
|
160
|
+
* verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
|
|
161
|
+
* },
|
|
162
|
+
* types: {
|
|
163
|
+
* Person: [
|
|
164
|
+
* { name: 'name', type: 'string' },
|
|
165
|
+
* { name: 'wallet', type: 'address' },
|
|
166
|
+
* ],
|
|
167
|
+
* Mail: [
|
|
168
|
+
* { name: 'from', type: 'Person' },
|
|
169
|
+
* { name: 'to', type: 'Person' },
|
|
170
|
+
* { name: 'contents', type: 'string' },
|
|
171
|
+
* ],
|
|
172
|
+
* },
|
|
173
|
+
* primaryType: 'Mail',
|
|
174
|
+
* message: {
|
|
175
|
+
* from: {
|
|
176
|
+
* name: 'Cow',
|
|
177
|
+
* wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
|
|
178
|
+
* },
|
|
179
|
+
* to: {
|
|
180
|
+
* name: 'Bob',
|
|
181
|
+
* wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
|
|
182
|
+
* },
|
|
183
|
+
* contents: 'Hello, Bob!',
|
|
184
|
+
* },
|
|
185
|
+
* })
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* // Account Hoisting
|
|
189
|
+
* import { createWalletClient, http } from 'viem'
|
|
190
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
191
|
+
* import { mainnet } from 'viem/chains'
|
|
192
|
+
*
|
|
193
|
+
* const client = createWalletClient({
|
|
194
|
+
* account: privateKeyToAccount('0x…'),
|
|
195
|
+
* chain: mainnet,
|
|
196
|
+
* transport: http(),
|
|
197
|
+
* })
|
|
198
|
+
* const signature = await client.signTypedData({
|
|
199
|
+
* domain: {
|
|
200
|
+
* name: 'Ether Mail',
|
|
201
|
+
* version: '1',
|
|
202
|
+
* chainId: 1,
|
|
203
|
+
* verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
|
|
204
|
+
* },
|
|
205
|
+
* types: {
|
|
206
|
+
* Person: [
|
|
207
|
+
* { name: 'name', type: 'string' },
|
|
208
|
+
* { name: 'wallet', type: 'address' },
|
|
209
|
+
* ],
|
|
210
|
+
* Mail: [
|
|
211
|
+
* { name: 'from', type: 'Person' },
|
|
212
|
+
* { name: 'to', type: 'Person' },
|
|
213
|
+
* { name: 'contents', type: 'string' },
|
|
214
|
+
* ],
|
|
215
|
+
* },
|
|
216
|
+
* primaryType: 'Mail',
|
|
217
|
+
* message: {
|
|
218
|
+
* from: {
|
|
219
|
+
* name: 'Cow',
|
|
220
|
+
* wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
|
|
221
|
+
* },
|
|
222
|
+
* to: {
|
|
223
|
+
* name: 'Bob',
|
|
224
|
+
* wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
|
|
225
|
+
* },
|
|
226
|
+
* contents: 'Hello, Bob!',
|
|
227
|
+
* },
|
|
228
|
+
* })
|
|
229
|
+
*/
|
|
230
|
+
signTypedData: <
|
|
231
|
+
const TTypedData extends TypedData | { [key: string]: unknown },
|
|
232
|
+
TPrimaryType extends string
|
|
233
|
+
>(
|
|
234
|
+
args: Parameters<
|
|
235
|
+
typeof signTypedData<
|
|
236
|
+
TTypedData,
|
|
237
|
+
TPrimaryType,
|
|
238
|
+
TChain,
|
|
239
|
+
TSmartAccount
|
|
240
|
+
>
|
|
241
|
+
>[1]
|
|
242
|
+
) => ReturnType<
|
|
243
|
+
typeof signTypedData<TTypedData, TPrimaryType, TChain, TSmartAccount>
|
|
244
|
+
>
|
|
245
|
+
/**
|
|
246
|
+
* Deploys a contract to the network, given bytecode and constructor arguments.
|
|
247
|
+
* This function also allows you to sponsor this transaction if sender is a smartAccount
|
|
248
|
+
*
|
|
249
|
+
* - Docs: https://viem.sh/docs/contract/deployContract.html
|
|
250
|
+
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts
|
|
251
|
+
*
|
|
252
|
+
* @param args - {@link DeployContractParameters}
|
|
253
|
+
* @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash. {@link DeployContractReturnType}
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* import { createWalletClient, http } from 'viem'
|
|
257
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
258
|
+
* import { mainnet } from 'viem/chains'
|
|
259
|
+
*
|
|
260
|
+
* const client = createWalletClient({
|
|
261
|
+
* account: privateKeyToAccount('0x…'),
|
|
262
|
+
* chain: mainnet,
|
|
263
|
+
* transport: http(),
|
|
264
|
+
* })
|
|
265
|
+
* const hash = await client.deployContract({
|
|
266
|
+
* abi: [],
|
|
267
|
+
* account: '0x…,
|
|
268
|
+
* bytecode: '0x608060405260405161083e38038061083e833981016040819052610...',
|
|
269
|
+
* })
|
|
270
|
+
*/
|
|
271
|
+
deployContract: <
|
|
272
|
+
const TAbi extends Abi | readonly unknown[],
|
|
273
|
+
TChainOverride extends Chain | undefined = undefined
|
|
274
|
+
>(
|
|
275
|
+
args: DeployContractParameters<
|
|
276
|
+
TAbi,
|
|
277
|
+
TChain,
|
|
278
|
+
TSmartAccount,
|
|
279
|
+
TChainOverride
|
|
280
|
+
>
|
|
281
|
+
) => ReturnType<
|
|
282
|
+
typeof deployContract<TAbi, TChain, TSmartAccount, TChainOverride>
|
|
283
|
+
>
|
|
284
|
+
/**
|
|
285
|
+
* Executes a write function on a contract.
|
|
286
|
+
* This function also allows you to sponsor this transaction if sender is a smartAccount
|
|
287
|
+
*
|
|
288
|
+
* - Docs: https://viem.sh/docs/contract/writeContract.html
|
|
289
|
+
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts
|
|
290
|
+
*
|
|
291
|
+
* A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a [Transaction](https://viem.sh/docs/glossary/terms.html) is needed to be broadcast in order to change the state.
|
|
292
|
+
*
|
|
293
|
+
* Internally, uses a [Wallet Client](https://viem.sh/docs/clients/wallet.html) to call the [`sendTransaction` action](https://viem.sh/docs/actions/wallet/sendTransaction.html) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData.html).
|
|
294
|
+
*
|
|
295
|
+
* __Warning: The `write` internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to [simulate the contract write with `contract.simulate`](https://viem.sh/docs/contract/writeContract.html#usage) before you execute it.__
|
|
296
|
+
*
|
|
297
|
+
* @param args - {@link WriteContractParameters}
|
|
298
|
+
* @returns A [Transaction Hash](https://viem.sh/docs/glossary/terms.html#hash). {@link WriteContractReturnType}
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* import { createWalletClient, custom, parseAbi } from 'viem'
|
|
302
|
+
* import { mainnet } from 'viem/chains'
|
|
303
|
+
*
|
|
304
|
+
* const client = createWalletClient({
|
|
305
|
+
* chain: mainnet,
|
|
306
|
+
* transport: custom(window.ethereum),
|
|
307
|
+
* })
|
|
308
|
+
* const hash = await client.writeContract({
|
|
309
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
310
|
+
* abi: parseAbi(['function mint(uint32 tokenId) nonpayable']),
|
|
311
|
+
* functionName: 'mint',
|
|
312
|
+
* args: [69420],
|
|
313
|
+
* })
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* // With Validation
|
|
317
|
+
* import { createWalletClient, custom, parseAbi } from 'viem'
|
|
318
|
+
* import { mainnet } from 'viem/chains'
|
|
319
|
+
*
|
|
320
|
+
* const client = createWalletClient({
|
|
321
|
+
* chain: mainnet,
|
|
322
|
+
* transport: custom(window.ethereum),
|
|
323
|
+
* })
|
|
324
|
+
* const { request } = await client.simulateContract({
|
|
325
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
326
|
+
* abi: parseAbi(['function mint(uint32 tokenId) nonpayable']),
|
|
327
|
+
* functionName: 'mint',
|
|
328
|
+
* args: [69420],
|
|
329
|
+
* }
|
|
330
|
+
* const hash = await client.writeContract(request)
|
|
331
|
+
*/
|
|
332
|
+
writeContract: <
|
|
333
|
+
const TAbi extends Abi | readonly unknown[],
|
|
334
|
+
TFunctionName extends string,
|
|
335
|
+
TChainOverride extends Chain | undefined = undefined
|
|
336
|
+
>(
|
|
337
|
+
args: WriteContractParameters<
|
|
338
|
+
TAbi,
|
|
339
|
+
TFunctionName,
|
|
340
|
+
TChain,
|
|
341
|
+
TSmartAccount,
|
|
342
|
+
TChainOverride
|
|
343
|
+
>
|
|
344
|
+
) => ReturnType<
|
|
345
|
+
typeof writeContract<
|
|
346
|
+
TChain,
|
|
347
|
+
TSmartAccount,
|
|
348
|
+
TAbi,
|
|
349
|
+
TFunctionName,
|
|
350
|
+
TChainOverride
|
|
351
|
+
>
|
|
352
|
+
>
|
|
353
|
+
prepareUserOperationRequest: <TTransport extends Transport>(
|
|
354
|
+
args: Parameters<
|
|
355
|
+
typeof prepareUserOperationRequest<
|
|
356
|
+
TTransport,
|
|
357
|
+
TChain,
|
|
358
|
+
TSmartAccount
|
|
359
|
+
>
|
|
360
|
+
>[1]
|
|
361
|
+
) => Promise<PrepareUserOperationRequestReturnType>
|
|
362
|
+
/**
|
|
363
|
+
* Creates, signs, and sends a new transaction to the network.
|
|
364
|
+
* This function also allows you to sponsor this transaction if sender is a smartAccount
|
|
365
|
+
*
|
|
366
|
+
* - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html
|
|
367
|
+
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions
|
|
368
|
+
* - JSON-RPC Methods:
|
|
369
|
+
* - JSON-RPC Accounts: [`eth_sendTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendtransaction)
|
|
370
|
+
* - Local Accounts: [`eth_sendRawTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction)
|
|
371
|
+
*
|
|
372
|
+
* @param args - {@link SendTransactionParameters}
|
|
373
|
+
* @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash. {@link SendTransactionReturnType}
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* import { createWalletClient, custom } from 'viem'
|
|
377
|
+
* import { mainnet } from 'viem/chains'
|
|
378
|
+
*
|
|
379
|
+
* const client = createWalletClient({
|
|
380
|
+
* chain: mainnet,
|
|
381
|
+
* transport: custom(window.ethereum),
|
|
382
|
+
* })
|
|
383
|
+
* const hash = await client.sendTransaction([{
|
|
384
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
385
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
386
|
+
* value: 1000000000000000000n
|
|
387
|
+
* }, {
|
|
388
|
+
* to: '0x61897970c51812dc3a010c7d01b50e0d17dc1234',
|
|
389
|
+
* value: 10000000000000000n
|
|
390
|
+
* })
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* // Account Hoisting
|
|
394
|
+
* import { createWalletClient, http } from 'viem'
|
|
395
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
396
|
+
* import { mainnet } from 'viem/chains'
|
|
397
|
+
*
|
|
398
|
+
* const client = createWalletClient({
|
|
399
|
+
* account: privateKeyToAccount('0x…'),
|
|
400
|
+
* chain: mainnet,
|
|
401
|
+
* transport: http(),
|
|
402
|
+
* })
|
|
403
|
+
* const hash = await client.sendTransaction([{
|
|
404
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
405
|
+
* value: 1000000000000000000n
|
|
406
|
+
* }, {
|
|
407
|
+
* to: '0x61897970c51812dc3a010c7d01b50e0d17dc1234',
|
|
408
|
+
* value: 10000000000000000n
|
|
409
|
+
* }])
|
|
410
|
+
*/
|
|
411
|
+
sendTransactions: (
|
|
412
|
+
args: SendTransactionsWithPaymasterParameters<TSmartAccount>
|
|
413
|
+
) => ReturnType<typeof sendTransactions<TChain, TSmartAccount>>
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
export const smartAccountActions =
|
|
417
|
+
({ sponsorUserOperation }: SponsorUserOperationMiddleware) =>
|
|
418
|
+
<
|
|
419
|
+
TTransport extends Transport,
|
|
420
|
+
TChain extends Chain | undefined = Chain | undefined,
|
|
421
|
+
TSmartAccount extends SmartAccount | undefined =
|
|
422
|
+
| SmartAccount
|
|
423
|
+
| undefined
|
|
424
|
+
>(
|
|
425
|
+
client: Client<TTransport, TChain, TSmartAccount>
|
|
426
|
+
): SmartAccountActions<TChain, TSmartAccount> => ({
|
|
427
|
+
prepareUserOperationRequest: (args) =>
|
|
428
|
+
prepareUserOperationRequest(client, args),
|
|
429
|
+
deployContract: (args) =>
|
|
430
|
+
deployContract(client, {
|
|
431
|
+
...args,
|
|
432
|
+
sponsorUserOperation
|
|
433
|
+
} as DeployContractParametersWithPaymaster),
|
|
434
|
+
sendTransaction: (args) =>
|
|
435
|
+
sendTransaction(client, {
|
|
436
|
+
...args,
|
|
437
|
+
sponsorUserOperation
|
|
438
|
+
} as SendTransactionWithPaymasterParameters),
|
|
439
|
+
sendTransactions: (args) =>
|
|
440
|
+
sendTransactions(client, {
|
|
441
|
+
...args,
|
|
442
|
+
sponsorUserOperation
|
|
443
|
+
} as SendTransactionsWithPaymasterParameters),
|
|
444
|
+
signMessage: (args) => signMessage(client, args),
|
|
445
|
+
signTypedData: (args) => signTypedData(client, args),
|
|
446
|
+
writeContract: (args) =>
|
|
447
|
+
writeContract(client, {
|
|
448
|
+
...args,
|
|
449
|
+
sponsorUserOperation
|
|
450
|
+
} as WriteContractWithPaymasterParameters)
|
|
451
|
+
})
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { Address, Client } from "viem"
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type AccountsParameters,
|
|
4
|
+
accounts
|
|
5
|
+
} from "../../actions/stackup/accounts.js"
|
|
3
6
|
import {
|
|
4
7
|
type SponsorUserOperationParameters,
|
|
5
8
|
type SponsorUserOperationReturnType,
|
|
@@ -31,7 +34,9 @@ export type StackupPaymasterClientActions = {
|
|
|
31
34
|
* }})
|
|
32
35
|
*
|
|
33
36
|
*/
|
|
34
|
-
sponsorUserOperation: (
|
|
37
|
+
sponsorUserOperation: (
|
|
38
|
+
args: SponsorUserOperationParameters
|
|
39
|
+
) => Promise<SponsorUserOperationReturnType>
|
|
35
40
|
|
|
36
41
|
/**
|
|
37
42
|
* Returns all the Paymaster addresses associated with an EntryPoint that’s owned by this service.
|
|
@@ -58,8 +63,11 @@ export type StackupPaymasterClientActions = {
|
|
|
58
63
|
accounts: (args: AccountsParameters) => Promise<Address[]>
|
|
59
64
|
}
|
|
60
65
|
|
|
61
|
-
export const stackupPaymasterActions = (
|
|
66
|
+
export const stackupPaymasterActions = (
|
|
67
|
+
client: Client
|
|
68
|
+
): StackupPaymasterClientActions => ({
|
|
62
69
|
sponsorUserOperation: async (args: SponsorUserOperationParameters) =>
|
|
63
70
|
sponsorUserOperation(client as StackupPaymasterClient, args),
|
|
64
|
-
accounts: async (args: AccountsParameters) =>
|
|
71
|
+
accounts: async (args: AccountsParameters) =>
|
|
72
|
+
accounts(client as StackupPaymasterClient, args)
|
|
65
73
|
})
|
package/clients/pimlico.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
Account,
|
|
3
|
+
Chain,
|
|
4
|
+
Client,
|
|
5
|
+
PublicClientConfig,
|
|
6
|
+
Transport
|
|
7
|
+
} from "viem"
|
|
2
8
|
import { createClient } from "viem"
|
|
3
|
-
import type {
|
|
9
|
+
import type {
|
|
10
|
+
PimlicoBundlerRpcSchema,
|
|
11
|
+
PimlicoPaymasterRpcSchema
|
|
12
|
+
} from "../types/pimlico.js"
|
|
4
13
|
import { type BundlerActions, bundlerActions } from "./decorators/bundler.js"
|
|
5
14
|
import {
|
|
6
15
|
type PimlicoBundlerActions,
|
|
@@ -41,10 +50,13 @@ export type PimlicoPaymasterClient = Client<
|
|
|
41
50
|
*
|
|
42
51
|
* const pimlicoBundlerClient = createPimlicoBundlerClient({
|
|
43
52
|
* chain: mainnet,
|
|
44
|
-
* transport: http("https://api.pimlico.io/
|
|
53
|
+
* transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE"),
|
|
45
54
|
* })
|
|
46
55
|
*/
|
|
47
|
-
export const createPimlicoBundlerClient = <
|
|
56
|
+
export const createPimlicoBundlerClient = <
|
|
57
|
+
transport extends Transport,
|
|
58
|
+
chain extends Chain | undefined = undefined
|
|
59
|
+
>(
|
|
48
60
|
parameters: PublicClientConfig<transport, chain>
|
|
49
61
|
): PimlicoBundlerClient => {
|
|
50
62
|
const { key = "public", name = "Pimlico Bundler Client" } = parameters
|
|
@@ -76,7 +88,10 @@ export const createPimlicoBundlerClient = <transport extends Transport, chain ex
|
|
|
76
88
|
* transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE"),
|
|
77
89
|
* })
|
|
78
90
|
*/
|
|
79
|
-
export const createPimlicoPaymasterClient = <
|
|
91
|
+
export const createPimlicoPaymasterClient = <
|
|
92
|
+
transport extends Transport,
|
|
93
|
+
chain extends Chain | undefined = undefined
|
|
94
|
+
>(
|
|
80
95
|
parameters: PublicClientConfig<transport, chain>
|
|
81
96
|
): PimlicoPaymasterClient => {
|
|
82
97
|
const { key = "public", name = "Pimlico Paymaster Client" } = parameters
|
package/clients/stackup.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type Account,
|
|
3
|
+
type Chain,
|
|
4
|
+
type Client,
|
|
5
|
+
type PublicClientConfig,
|
|
6
|
+
type Transport,
|
|
7
|
+
createClient
|
|
8
|
+
} from "viem"
|
|
2
9
|
import type { StackupPaymasterRpcSchema } from "../types/stackup.js"
|
|
3
10
|
import { type BundlerActions, bundlerActions } from "./decorators/bundler.js"
|
|
4
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
type StackupPaymasterClientActions,
|
|
13
|
+
stackupPaymasterActions
|
|
14
|
+
} from "./decorators/stackup.js"
|
|
5
15
|
|
|
6
16
|
export type StackupPaymasterClient = Client<
|
|
7
17
|
Transport,
|
|
@@ -27,10 +37,13 @@ export type StackupPaymasterClient = Client<
|
|
|
27
37
|
*
|
|
28
38
|
* const stackupPaymasterClient = createStackupPaymasterClient({
|
|
29
39
|
* chain: mainnet,
|
|
30
|
-
* transport: http("https://api.stackup.sh/
|
|
40
|
+
* transport: http("https://api.stackup.sh/v2/paymaster/YOUR_API_KEY_HERE"),
|
|
31
41
|
* })
|
|
32
42
|
*/
|
|
33
|
-
export const createStackupPaymasterClient = <
|
|
43
|
+
export const createStackupPaymasterClient = <
|
|
44
|
+
transport extends Transport,
|
|
45
|
+
chain extends Chain | undefined = undefined
|
|
46
|
+
>(
|
|
34
47
|
parameters: PublicClientConfig<transport, chain>
|
|
35
48
|
): StackupPaymasterClient => {
|
|
36
49
|
const { key = "public", name = "Stackup Paymaster Client" } = parameters
|
package/index.ts
CHANGED
|
@@ -26,9 +26,21 @@ import {
|
|
|
26
26
|
} from "./actions/bundler/waitForUserOperationReceipt.js"
|
|
27
27
|
import type { GetAccountNonceParams } from "./actions/public/getAccountNonce.js"
|
|
28
28
|
import { getAccountNonce } from "./actions/public/getAccountNonce.js"
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
type BundlerClient,
|
|
31
|
+
createBundlerClient
|
|
32
|
+
} from "./clients/createBundlerClient.js"
|
|
33
|
+
import { createSmartAccountClient } from "./clients/createSmartAccountClient.js"
|
|
34
|
+
import {
|
|
35
|
+
type SmartAccountClient,
|
|
36
|
+
type SmartAccountClientConfig
|
|
37
|
+
} from "./clients/createSmartAccountClient.js"
|
|
30
38
|
import type { BundlerActions } from "./clients/decorators/bundler.js"
|
|
31
39
|
import { bundlerActions } from "./clients/decorators/bundler.js"
|
|
40
|
+
import {
|
|
41
|
+
type SmartAccountActions,
|
|
42
|
+
smartAccountActions
|
|
43
|
+
} from "./clients/decorators/smartAccount.js"
|
|
32
44
|
|
|
33
45
|
export type {
|
|
34
46
|
SendUserOperationParameters,
|
|
@@ -42,7 +54,10 @@ export type {
|
|
|
42
54
|
GetAccountNonceParams,
|
|
43
55
|
BundlerClient,
|
|
44
56
|
BundlerActions,
|
|
45
|
-
WaitForUserOperationReceiptParameters
|
|
57
|
+
WaitForUserOperationReceiptParameters,
|
|
58
|
+
SmartAccountClient,
|
|
59
|
+
SmartAccountClientConfig,
|
|
60
|
+
SmartAccountActions
|
|
46
61
|
}
|
|
47
62
|
|
|
48
63
|
export {
|
|
@@ -57,7 +72,9 @@ export {
|
|
|
57
72
|
waitForUserOperationReceipt,
|
|
58
73
|
createBundlerClient,
|
|
59
74
|
bundlerActions,
|
|
60
|
-
WaitForUserOperationReceiptTimeoutError
|
|
75
|
+
WaitForUserOperationReceiptTimeoutError,
|
|
76
|
+
createSmartAccountClient,
|
|
77
|
+
smartAccountActions
|
|
61
78
|
}
|
|
62
79
|
import type { UserOperation } from "./types/userOperation.js"
|
|
63
80
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "permissionless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"author": "Pimlico",
|
|
5
5
|
"main": "./_cjs/index.js",
|
|
6
6
|
"module": "./_esm/index.js",
|
|
@@ -23,6 +23,11 @@
|
|
|
23
23
|
"import": "./_esm/index.js",
|
|
24
24
|
"default": "./_cjs/index.js"
|
|
25
25
|
},
|
|
26
|
+
"./accounts": {
|
|
27
|
+
"types": "./_types/accounts/index.d.ts",
|
|
28
|
+
"import": "./_esm/accounts/index.js",
|
|
29
|
+
"default": "./_cjs/accounts/index.js"
|
|
30
|
+
},
|
|
26
31
|
"./actions": {
|
|
27
32
|
"types": "./_types/actions/index.d.ts",
|
|
28
33
|
"import": "./_esm/actions/index.js",
|
|
@@ -38,6 +43,11 @@
|
|
|
38
43
|
"import": "./_esm/actions/stackup.js",
|
|
39
44
|
"default": "./_cjs/actions/stackup.js"
|
|
40
45
|
},
|
|
46
|
+
"./actions/smartAccount": {
|
|
47
|
+
"types": "./_types/actions/smartAccount.d.ts",
|
|
48
|
+
"import": "./_esm/actions/smartAccount.js",
|
|
49
|
+
"default": "./_cjs/actions/smartAccount.js"
|
|
50
|
+
},
|
|
41
51
|
"./clients": {
|
|
42
52
|
"types": "./_types/clients/index.d.ts",
|
|
43
53
|
"import": "./_esm/clients/index.js",
|
|
@@ -60,6 +70,6 @@
|
|
|
60
70
|
}
|
|
61
71
|
},
|
|
62
72
|
"peerDependencies": {
|
|
63
|
-
"viem": "^1.
|
|
73
|
+
"viem": "^1.19.4"
|
|
64
74
|
}
|
|
65
75
|
}
|
package/types/bundler.ts
CHANGED
|
@@ -5,7 +5,10 @@ import type { UserOperationWithBigIntAsHex } from "./userOperation.js"
|
|
|
5
5
|
export type BundlerRpcSchema = [
|
|
6
6
|
{
|
|
7
7
|
Method: "eth_sendUserOperation"
|
|
8
|
-
Parameters: [
|
|
8
|
+
Parameters: [
|
|
9
|
+
userOperation: UserOperationWithBigIntAsHex,
|
|
10
|
+
entryPoint: Address
|
|
11
|
+
]
|
|
9
12
|
ReturnType: Hash
|
|
10
13
|
},
|
|
11
14
|
{
|