permissionless 0.1.24 → 0.1.26
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 +12 -0
- package/_cjs/experimental/eip7677/actions/getPaymasterData.js +41 -0
- package/_cjs/experimental/eip7677/actions/getPaymasterData.js.map +1 -0
- package/_cjs/experimental/eip7677/actions/getPaymasterStubData.js +47 -0
- package/_cjs/experimental/eip7677/actions/getPaymasterStubData.js.map +1 -0
- package/_cjs/experimental/eip7677/clients/decorators/paymasterActionsEip7677.js +21 -0
- package/_cjs/experimental/eip7677/clients/decorators/paymasterActionsEip7677.js.map +1 -0
- package/_cjs/experimental/eip7677/index.js +10 -0
- package/_cjs/experimental/eip7677/index.js.map +1 -0
- package/_cjs/experimental/eip7677/types/paymaster.js +3 -0
- package/_cjs/experimental/eip7677/types/paymaster.js.map +1 -0
- package/_cjs/experimental/index.js +5 -0
- package/_cjs/experimental/index.js.map +1 -0
- package/_esm/actions/smartAccount/sendTransaction.js +0 -2
- package/_esm/actions/smartAccount/sendTransaction.js.map +1 -1
- package/_esm/actions/smartAccount/sendTransactions.js +0 -2
- package/_esm/actions/smartAccount/sendTransactions.js.map +1 -1
- package/_esm/actions/smartAccount/writeContract.js +0 -2
- package/_esm/actions/smartAccount/writeContract.js.map +1 -1
- package/_esm/errors/sendUserOperation.js +0 -1
- package/_esm/errors/sendUserOperation.js.map +1 -1
- package/_esm/experimental/eip7677/actions/getPaymasterData.js +37 -0
- package/_esm/experimental/eip7677/actions/getPaymasterData.js.map +1 -0
- package/_esm/experimental/eip7677/actions/getPaymasterStubData.js +43 -0
- package/_esm/experimental/eip7677/actions/getPaymasterStubData.js.map +1 -0
- package/_esm/experimental/eip7677/clients/decorators/paymasterActionsEip7677.js +18 -0
- package/_esm/experimental/eip7677/clients/decorators/paymasterActionsEip7677.js.map +1 -0
- package/_esm/experimental/eip7677/index.js +5 -0
- package/_esm/experimental/eip7677/index.js.map +1 -0
- package/_esm/experimental/eip7677/types/paymaster.js +2 -0
- package/_esm/experimental/eip7677/types/paymaster.js.map +1 -0
- package/_esm/experimental/index.js +2 -0
- package/_esm/experimental/index.js.map +1 -0
- package/_types/actions/smartAccount/sendTransaction.d.ts +2 -2
- package/_types/actions/smartAccount/sendTransaction.d.ts.map +1 -1
- package/_types/actions/smartAccount/sendTransactions.d.ts +2 -2
- package/_types/actions/smartAccount/sendTransactions.d.ts.map +1 -1
- package/_types/actions/smartAccount/writeContract.d.ts +2 -2
- package/_types/actions/smartAccount/writeContract.d.ts.map +1 -1
- package/_types/clients/decorators/smartAccount.d.ts +1 -2
- package/_types/clients/decorators/smartAccount.d.ts.map +1 -1
- package/_types/errors/sendUserOperation.d.ts +1 -1
- package/_types/errors/sendUserOperation.d.ts.map +1 -1
- package/_types/experimental/eip7677/actions/getPaymasterData.d.ts +18 -0
- package/_types/experimental/eip7677/actions/getPaymasterData.d.ts.map +1 -0
- package/_types/experimental/eip7677/actions/getPaymasterStubData.d.ts +20 -0
- package/_types/experimental/eip7677/actions/getPaymasterStubData.d.ts.map +1 -0
- package/_types/experimental/eip7677/clients/decorators/paymasterActionsEip7677.d.ts +14 -0
- package/_types/experimental/eip7677/clients/decorators/paymasterActionsEip7677.d.ts.map +1 -0
- package/_types/experimental/eip7677/index.d.ts +6 -0
- package/_types/experimental/eip7677/index.d.ts.map +1 -0
- package/_types/experimental/eip7677/types/paymaster.d.ts +42 -0
- package/_types/experimental/eip7677/types/paymaster.d.ts.map +1 -0
- package/_types/experimental/index.d.ts +2 -0
- package/_types/experimental/index.d.ts.map +1 -0
- package/actions/smartAccount/sendTransaction.ts +2 -2
- package/actions/smartAccount/sendTransactions.ts +2 -2
- package/actions/smartAccount/writeContract.ts +2 -2
- package/clients/decorators/smartAccount.ts +1 -1
- package/errors/sendUserOperation.ts +1 -1
- package/experimental/eip7677/actions/getPaymasterData.ts +128 -0
- package/experimental/eip7677/actions/getPaymasterStubData.ts +140 -0
- package/experimental/eip7677/clients/decorators/paymasterActionsEip7677.ts +86 -0
- package/experimental/eip7677/index.ts +27 -0
- package/experimental/eip7677/types/paymaster.ts +59 -0
- package/experimental/index.ts +1 -0
- package/package.json +6 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type GetPaymasterDataParameters, type GetPaymasterDataReturnType, getPaymasterData } from "./actions/getPaymasterData";
|
|
2
|
+
import { type GetPaymasterStubDataParameters, type GetPaymasterStubDataReturnType, getPaymasterStubData } from "./actions/getPaymasterStubData";
|
|
3
|
+
import { type PaymasterActionsEip7677, paymasterActionsEip7677 } from "./clients/decorators/paymasterActionsEip7677";
|
|
4
|
+
import type { Eip7677RpcSchema } from "./types/paymaster";
|
|
5
|
+
export { type GetPaymasterStubDataParameters, type GetPaymasterStubDataReturnType, getPaymasterStubData, type GetPaymasterDataReturnType, type GetPaymasterDataParameters, getPaymasterData, type PaymasterActionsEip7677, paymasterActionsEip7677, type Eip7677RpcSchema };
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../experimental/eip7677/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,gBAAgB,EACnB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EACH,KAAK,8BAA8B,EACnC,KAAK,8BAA8B,EACnC,oBAAoB,EACvB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACH,KAAK,uBAAuB,EAC5B,uBAAuB,EAC1B,MAAM,8CAA8C,CAAA;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAEzD,OAAO,EACH,KAAK,8BAA8B,EACnC,KAAK,8BAA8B,EACnC,oBAAoB,EACpB,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,uBAAuB,EACvB,KAAK,gBAAgB,EACxB,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Hex } from "viem";
|
|
2
|
+
import type { EntryPoint, GetEntryPointVersion } from "../../../types/entrypoint";
|
|
3
|
+
import type { UserOperationWithBigIntAsHex } from "../../../types/userOperation";
|
|
4
|
+
export type GetRpcPaymasterStubDataParameters<entryPoint extends EntryPoint> = [
|
|
5
|
+
userOperation: UserOperationWithBigIntAsHex<GetEntryPointVersion<entryPoint>>,
|
|
6
|
+
entryPoint: entryPoint,
|
|
7
|
+
chainId: Hex,
|
|
8
|
+
context?: Record<string, unknown>
|
|
9
|
+
];
|
|
10
|
+
export type GetRpcPaymasterStubDataReturnType<entryPoint extends EntryPoint> = GetEntryPointVersion<entryPoint> extends "v0.6" ? {
|
|
11
|
+
paymasterAndData: Hex;
|
|
12
|
+
} : {
|
|
13
|
+
paymaster: Hex;
|
|
14
|
+
paymasterData: Hex;
|
|
15
|
+
paymasterVerificationGasLimit?: Hex | null;
|
|
16
|
+
paymasterPostOpGasLimit?: Hex | null;
|
|
17
|
+
};
|
|
18
|
+
export type GetRpcPaymasterDataParameters<entryPoint extends EntryPoint> = [
|
|
19
|
+
userOperation: UserOperationWithBigIntAsHex<GetEntryPointVersion<entryPoint>>,
|
|
20
|
+
entryPoint: entryPoint,
|
|
21
|
+
chainId: Hex,
|
|
22
|
+
context?: Record<string, unknown>
|
|
23
|
+
];
|
|
24
|
+
export type GetRpcPaymasterDataReturnType<entryPoint extends EntryPoint> = GetEntryPointVersion<entryPoint> extends "v0.6" ? {
|
|
25
|
+
paymasterAndData: Hex;
|
|
26
|
+
} : {
|
|
27
|
+
paymaster: Hex;
|
|
28
|
+
paymasterData: Hex;
|
|
29
|
+
};
|
|
30
|
+
export type Eip7677RpcSchema<entryPoint extends EntryPoint> = [
|
|
31
|
+
{
|
|
32
|
+
Method: "pm_getPaymasterStubData";
|
|
33
|
+
Parameters: GetRpcPaymasterStubDataParameters<entryPoint>;
|
|
34
|
+
ReturnType: GetRpcPaymasterStubDataReturnType<entryPoint>;
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
Method: "pm_getPaymasterData";
|
|
38
|
+
Paremeters: GetRpcPaymasterDataParameters<entryPoint>;
|
|
39
|
+
ReturnType: GetRpcPaymasterDataReturnType<entryPoint>;
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
//# sourceMappingURL=paymaster.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paymaster.d.ts","sourceRoot":"","sources":["../../../../experimental/eip7677/types/paymaster.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,KAAK,EACR,UAAU,EACV,oBAAoB,EACvB,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAA;AAEhF,MAAM,MAAM,iCAAiC,CAAC,UAAU,SAAS,UAAU,IAAI;IAC3E,aAAa,EAAE,4BAA4B,CACvC,oBAAoB,CAAC,UAAU,CAAC,CACnC;IACD,UAAU,EAAE,UAAU;IACtB,OAAO,EAAE,GAAG;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CACpC,CAAA;AAED,MAAM,MAAM,iCAAiC,CAAC,UAAU,SAAS,UAAU,IACvE,oBAAoB,CAAC,UAAU,CAAC,SAAS,MAAM,GACzC;IACI,gBAAgB,EAAE,GAAG,CAAA;CACxB,GACD;IACI,SAAS,EAAE,GAAG,CAAA;IACd,aAAa,EAAE,GAAG,CAAA;IAClB,6BAA6B,CAAC,EAAE,GAAG,GAAG,IAAI,CAAA;IAC1C,uBAAuB,CAAC,EAAE,GAAG,GAAG,IAAI,CAAA;CACvC,CAAA;AAEX,MAAM,MAAM,6BAA6B,CAAC,UAAU,SAAS,UAAU,IAAI;IACvE,aAAa,EAAE,4BAA4B,CACvC,oBAAoB,CAAC,UAAU,CAAC,CACnC;IACD,UAAU,EAAE,UAAU;IACtB,OAAO,EAAE,GAAG;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CACpC,CAAA;AAED,MAAM,MAAM,6BAA6B,CAAC,UAAU,SAAS,UAAU,IACnE,oBAAoB,CAAC,UAAU,CAAC,SAAS,MAAM,GACzC;IACI,gBAAgB,EAAE,GAAG,CAAA;CACxB,GACD;IACI,SAAS,EAAE,GAAG,CAAA;IACd,aAAa,EAAE,GAAG,CAAA;CACrB,CAAA;AAEX,MAAM,MAAM,gBAAgB,CAAC,UAAU,SAAS,UAAU,IAAI;IAC1D;QACI,MAAM,EAAE,yBAAyB,CAAA;QACjC,UAAU,EAAE,iCAAiC,CAAC,UAAU,CAAC,CAAA;QACzD,UAAU,EAAE,iCAAiC,CAAC,UAAU,CAAC,CAAA;KAC5D;IACD;QACI,MAAM,EAAE,qBAAqB,CAAA;QAC7B,UAAU,EAAE,6BAA6B,CAAC,UAAU,CAAC,CAAA;QACrD,UAAU,EAAE,6BAA6B,CAAC,UAAU,CAAC,CAAA;KACxD;CACJ,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../experimental/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
|
|
@@ -6,12 +6,12 @@ import type {
|
|
|
6
6
|
Transport
|
|
7
7
|
} from "viem"
|
|
8
8
|
import { getAction } from "viem/utils"
|
|
9
|
-
import {
|
|
9
|
+
import type { SmartAccount } from "../../accounts/types"
|
|
10
10
|
import type { Prettify } from "../../types/"
|
|
11
11
|
import type { EntryPoint } from "../../types/entrypoint"
|
|
12
12
|
import { AccountOrClientNotFoundError, parseAccount } from "../../utils/"
|
|
13
13
|
import { waitForUserOperationReceipt } from "../bundler/waitForUserOperationReceipt"
|
|
14
|
-
import {
|
|
14
|
+
import type { Middleware } from "./prepareUserOperationRequest"
|
|
15
15
|
import { sendUserOperation } from "./sendUserOperation"
|
|
16
16
|
|
|
17
17
|
export type SendTransactionWithPaymasterParameters<
|
|
@@ -8,12 +8,12 @@ import type {
|
|
|
8
8
|
Transport
|
|
9
9
|
} from "viem"
|
|
10
10
|
import { getAction } from "viem/utils"
|
|
11
|
-
import {
|
|
11
|
+
import type { SmartAccount } from "../../accounts/types"
|
|
12
12
|
import type { GetAccountParameter, Prettify } from "../../types/"
|
|
13
13
|
import type { EntryPoint } from "../../types/entrypoint"
|
|
14
14
|
import { AccountOrClientNotFoundError, parseAccount } from "../../utils/"
|
|
15
15
|
import { waitForUserOperationReceipt } from "../bundler/waitForUserOperationReceipt"
|
|
16
|
-
import {
|
|
16
|
+
import type { Middleware } from "./prepareUserOperationRequest"
|
|
17
17
|
import { sendUserOperation } from "./sendUserOperation"
|
|
18
18
|
|
|
19
19
|
export type SendTransactionsWithPaymasterParameters<
|
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
encodeFunctionData
|
|
12
12
|
} from "viem"
|
|
13
13
|
import { getAction } from "viem/utils"
|
|
14
|
-
import {
|
|
14
|
+
import type { SmartAccount } from "../../accounts/types"
|
|
15
15
|
import type { EntryPoint } from "../../types/entrypoint"
|
|
16
|
-
import {
|
|
16
|
+
import type { Middleware } from "./prepareUserOperationRequest"
|
|
17
17
|
import {
|
|
18
18
|
type SendTransactionWithPaymasterParameters,
|
|
19
19
|
sendTransaction
|
|
@@ -300,7 +300,7 @@ export type SmartAccountActions<
|
|
|
300
300
|
TChainOverride
|
|
301
301
|
>
|
|
302
302
|
>
|
|
303
|
-
) =>
|
|
303
|
+
) => Promise<Hash>
|
|
304
304
|
/**
|
|
305
305
|
* Executes a write function on a contract.
|
|
306
306
|
* This function also allows you to sponsor this transaction if sender is a smartAccount
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseError } from "viem"
|
|
2
|
-
import {
|
|
2
|
+
import type { SendUserOperationParameters } from "../actions/bundler/sendUserOperation"
|
|
3
3
|
import type { EntryPoint } from "../types/entrypoint"
|
|
4
4
|
import { prettyPrint } from "./utils"
|
|
5
5
|
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Chain,
|
|
3
|
+
ChainNotFoundError,
|
|
4
|
+
type Client,
|
|
5
|
+
type GetChainParameter,
|
|
6
|
+
type Hex,
|
|
7
|
+
type Transport,
|
|
8
|
+
toHex
|
|
9
|
+
} from "viem"
|
|
10
|
+
import type { PartialBy } from "viem/types/utils"
|
|
11
|
+
import type {
|
|
12
|
+
ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
13
|
+
ENTRYPOINT_ADDRESS_V07_TYPE,
|
|
14
|
+
EntryPoint,
|
|
15
|
+
GetEntryPointVersion
|
|
16
|
+
} from "../../../types/entrypoint"
|
|
17
|
+
import type {
|
|
18
|
+
UserOperation,
|
|
19
|
+
UserOperationWithBigIntAsHex
|
|
20
|
+
} from "../../../types/userOperation"
|
|
21
|
+
import { deepHexlify, getEntryPointVersion } from "../../../utils"
|
|
22
|
+
import type {
|
|
23
|
+
Eip7677RpcSchema,
|
|
24
|
+
GetRpcPaymasterDataReturnType
|
|
25
|
+
} from "../types/paymaster"
|
|
26
|
+
|
|
27
|
+
export type GetPaymasterDataParameters<
|
|
28
|
+
TEntryPoint extends EntryPoint,
|
|
29
|
+
TChain extends Chain | undefined = Chain | undefined,
|
|
30
|
+
TChainOverride extends Chain | undefined = Chain | undefined
|
|
31
|
+
> = {
|
|
32
|
+
userOperation: GetEntryPointVersion<TEntryPoint> extends "v0.6"
|
|
33
|
+
? PartialBy<UserOperation<"v0.6">, "paymasterAndData" | "signature">
|
|
34
|
+
: PartialBy<
|
|
35
|
+
UserOperation<"v0.7">,
|
|
36
|
+
"signature" | "paymaster" | "paymasterData"
|
|
37
|
+
>
|
|
38
|
+
entryPoint: TEntryPoint
|
|
39
|
+
context?: Record<string, unknown>
|
|
40
|
+
} & GetChainParameter<TChain, TChainOverride>
|
|
41
|
+
|
|
42
|
+
export type GetPaymasterDataReturnType<TEntryPoint extends EntryPoint> =
|
|
43
|
+
GetEntryPointVersion<TEntryPoint> extends "v0.6"
|
|
44
|
+
? {
|
|
45
|
+
paymasterAndData: Hex
|
|
46
|
+
}
|
|
47
|
+
: {
|
|
48
|
+
paymaster: Hex
|
|
49
|
+
paymasterData: Hex
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function getPaymasterData<
|
|
53
|
+
TEntryPoint extends EntryPoint,
|
|
54
|
+
TChain extends Chain | undefined,
|
|
55
|
+
TTransport extends Transport = Transport,
|
|
56
|
+
TChainOverride extends Chain | undefined = Chain | undefined
|
|
57
|
+
>(
|
|
58
|
+
client: Client<
|
|
59
|
+
TTransport,
|
|
60
|
+
TChain,
|
|
61
|
+
undefined,
|
|
62
|
+
Eip7677RpcSchema<TEntryPoint>
|
|
63
|
+
>,
|
|
64
|
+
{
|
|
65
|
+
userOperation,
|
|
66
|
+
entryPoint,
|
|
67
|
+
context,
|
|
68
|
+
chain
|
|
69
|
+
}: GetPaymasterDataParameters<TEntryPoint, TChain, TChainOverride>
|
|
70
|
+
): Promise<GetPaymasterDataReturnType<TEntryPoint>> {
|
|
71
|
+
const chainId = chain?.id ?? client.chain?.id
|
|
72
|
+
|
|
73
|
+
if (!chainId) {
|
|
74
|
+
throw new ChainNotFoundError()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const params:
|
|
78
|
+
| [
|
|
79
|
+
UserOperationWithBigIntAsHex<GetEntryPointVersion<TEntryPoint>>,
|
|
80
|
+
TEntryPoint,
|
|
81
|
+
Hex,
|
|
82
|
+
Record<string, unknown>
|
|
83
|
+
]
|
|
84
|
+
| [
|
|
85
|
+
UserOperationWithBigIntAsHex<GetEntryPointVersion<TEntryPoint>>,
|
|
86
|
+
TEntryPoint,
|
|
87
|
+
Hex
|
|
88
|
+
] = context
|
|
89
|
+
? [
|
|
90
|
+
deepHexlify(userOperation) as UserOperationWithBigIntAsHex<
|
|
91
|
+
GetEntryPointVersion<TEntryPoint>
|
|
92
|
+
>,
|
|
93
|
+
entryPoint,
|
|
94
|
+
toHex(chainId),
|
|
95
|
+
context
|
|
96
|
+
]
|
|
97
|
+
: [
|
|
98
|
+
deepHexlify(userOperation) as UserOperationWithBigIntAsHex<
|
|
99
|
+
GetEntryPointVersion<TEntryPoint>
|
|
100
|
+
>,
|
|
101
|
+
entryPoint,
|
|
102
|
+
toHex(chainId)
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
const response = await client.request({
|
|
106
|
+
method: "pm_getPaymasterData",
|
|
107
|
+
params
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
const entryPointVersion = getEntryPointVersion(entryPoint)
|
|
111
|
+
|
|
112
|
+
if (entryPointVersion === "v0.6") {
|
|
113
|
+
const responseV06 =
|
|
114
|
+
response as GetRpcPaymasterDataReturnType<ENTRYPOINT_ADDRESS_V06_TYPE>
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
paymasterAndData: responseV06.paymasterAndData
|
|
118
|
+
} as GetPaymasterDataReturnType<TEntryPoint>
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const responseV07 =
|
|
122
|
+
response as GetRpcPaymasterDataReturnType<ENTRYPOINT_ADDRESS_V07_TYPE>
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
paymaster: responseV07.paymaster,
|
|
126
|
+
paymasterData: responseV07.paymasterData
|
|
127
|
+
} as GetPaymasterDataReturnType<TEntryPoint>
|
|
128
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Chain,
|
|
3
|
+
ChainNotFoundError,
|
|
4
|
+
type Client,
|
|
5
|
+
type GetChainParameter,
|
|
6
|
+
type Hex,
|
|
7
|
+
type Transport,
|
|
8
|
+
toHex
|
|
9
|
+
} from "viem"
|
|
10
|
+
import type { PartialBy } from "viem/types/utils"
|
|
11
|
+
import type {
|
|
12
|
+
ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
13
|
+
ENTRYPOINT_ADDRESS_V07_TYPE,
|
|
14
|
+
EntryPoint,
|
|
15
|
+
GetEntryPointVersion
|
|
16
|
+
} from "../../../types/entrypoint"
|
|
17
|
+
import type {
|
|
18
|
+
UserOperation,
|
|
19
|
+
UserOperationWithBigIntAsHex
|
|
20
|
+
} from "../../../types/userOperation"
|
|
21
|
+
import { deepHexlify, getEntryPointVersion } from "../../../utils"
|
|
22
|
+
import type {
|
|
23
|
+
Eip7677RpcSchema,
|
|
24
|
+
GetRpcPaymasterStubDataReturnType
|
|
25
|
+
} from "../types/paymaster"
|
|
26
|
+
|
|
27
|
+
export type GetPaymasterStubDataParameters<
|
|
28
|
+
TEntryPoint extends EntryPoint,
|
|
29
|
+
TChain extends Chain | undefined,
|
|
30
|
+
TChainOverride extends Chain | undefined = Chain | undefined
|
|
31
|
+
> = {
|
|
32
|
+
userOperation: GetEntryPointVersion<TEntryPoint> extends "v0.6"
|
|
33
|
+
? PartialBy<UserOperation<"v0.6">, "paymasterAndData" | "signature">
|
|
34
|
+
: PartialBy<
|
|
35
|
+
UserOperation<"v0.7">,
|
|
36
|
+
| "signature"
|
|
37
|
+
| "paymaster"
|
|
38
|
+
| "paymasterData"
|
|
39
|
+
| "paymasterVerificationGasLimit"
|
|
40
|
+
| "paymasterPostOpGasLimit"
|
|
41
|
+
>
|
|
42
|
+
entryPoint: TEntryPoint
|
|
43
|
+
context?: Record<string, unknown>
|
|
44
|
+
} & GetChainParameter<TChain, TChainOverride>
|
|
45
|
+
|
|
46
|
+
export type GetPaymasterStubDataReturnType<TEntryPoint extends EntryPoint> =
|
|
47
|
+
GetEntryPointVersion<TEntryPoint> extends "v0.6"
|
|
48
|
+
? {
|
|
49
|
+
paymasterAndData: Hex
|
|
50
|
+
}
|
|
51
|
+
: {
|
|
52
|
+
paymaster: Hex
|
|
53
|
+
paymasterData: Hex
|
|
54
|
+
paymasterVerificationGasLimit?: bigint
|
|
55
|
+
paymasterPostOpGasLimit?: bigint
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function getPaymasterStubData<
|
|
59
|
+
TEntryPoint extends EntryPoint,
|
|
60
|
+
TChain extends Chain | undefined,
|
|
61
|
+
TTransport extends Transport = Transport,
|
|
62
|
+
TChainOverride extends Chain | undefined = Chain | undefined
|
|
63
|
+
>(
|
|
64
|
+
client: Client<
|
|
65
|
+
TTransport,
|
|
66
|
+
TChain,
|
|
67
|
+
undefined,
|
|
68
|
+
Eip7677RpcSchema<TEntryPoint>
|
|
69
|
+
>,
|
|
70
|
+
{
|
|
71
|
+
userOperation,
|
|
72
|
+
entryPoint,
|
|
73
|
+
context,
|
|
74
|
+
chain
|
|
75
|
+
}: GetPaymasterStubDataParameters<TEntryPoint, TChain, TChainOverride>
|
|
76
|
+
): Promise<GetPaymasterStubDataReturnType<TEntryPoint>> {
|
|
77
|
+
const chainId = chain?.id ?? client.chain?.id
|
|
78
|
+
|
|
79
|
+
if (!chainId) {
|
|
80
|
+
throw new ChainNotFoundError()
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const params:
|
|
84
|
+
| [
|
|
85
|
+
UserOperationWithBigIntAsHex<GetEntryPointVersion<TEntryPoint>>,
|
|
86
|
+
TEntryPoint,
|
|
87
|
+
Hex,
|
|
88
|
+
Record<string, unknown>
|
|
89
|
+
]
|
|
90
|
+
| [
|
|
91
|
+
UserOperationWithBigIntAsHex<GetEntryPointVersion<TEntryPoint>>,
|
|
92
|
+
TEntryPoint,
|
|
93
|
+
Hex
|
|
94
|
+
] = context
|
|
95
|
+
? [
|
|
96
|
+
deepHexlify(userOperation) as UserOperationWithBigIntAsHex<
|
|
97
|
+
GetEntryPointVersion<TEntryPoint>
|
|
98
|
+
>,
|
|
99
|
+
entryPoint,
|
|
100
|
+
toHex(chainId),
|
|
101
|
+
context
|
|
102
|
+
]
|
|
103
|
+
: [
|
|
104
|
+
deepHexlify(userOperation) as UserOperationWithBigIntAsHex<
|
|
105
|
+
GetEntryPointVersion<TEntryPoint>
|
|
106
|
+
>,
|
|
107
|
+
entryPoint,
|
|
108
|
+
toHex(chainId)
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
const response = await client.request({
|
|
112
|
+
method: "pm_getPaymasterStubData",
|
|
113
|
+
params
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
const entryPointVersion = getEntryPointVersion(entryPoint)
|
|
117
|
+
|
|
118
|
+
if (entryPointVersion === "v0.6") {
|
|
119
|
+
const responseV06 =
|
|
120
|
+
response as GetRpcPaymasterStubDataReturnType<ENTRYPOINT_ADDRESS_V06_TYPE>
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
paymasterAndData: responseV06.paymasterAndData
|
|
124
|
+
} as GetPaymasterStubDataReturnType<TEntryPoint>
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const responseV07 =
|
|
128
|
+
response as GetRpcPaymasterStubDataReturnType<ENTRYPOINT_ADDRESS_V07_TYPE>
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
paymaster: responseV07.paymaster,
|
|
132
|
+
paymasterData: responseV07.paymasterData,
|
|
133
|
+
paymasterVerificationGasLimit: responseV07.paymasterVerificationGasLimit
|
|
134
|
+
? BigInt(responseV07.paymasterVerificationGasLimit)
|
|
135
|
+
: undefined,
|
|
136
|
+
paymasterPostOpGasLimit: responseV07.paymasterPostOpGasLimit
|
|
137
|
+
? BigInt(responseV07.paymasterPostOpGasLimit)
|
|
138
|
+
: undefined
|
|
139
|
+
} as GetPaymasterStubDataReturnType<TEntryPoint>
|
|
140
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Chain, Client, Transport } from "viem"
|
|
2
|
+
import type { Prettify } from "viem/types/utils"
|
|
3
|
+
import type { EntryPoint } from "../../../../types/entrypoint"
|
|
4
|
+
import {
|
|
5
|
+
type GetPaymasterDataParameters,
|
|
6
|
+
type GetPaymasterDataReturnType,
|
|
7
|
+
getPaymasterData
|
|
8
|
+
} from "../../actions/getPaymasterData"
|
|
9
|
+
import {
|
|
10
|
+
type GetPaymasterStubDataParameters,
|
|
11
|
+
type GetPaymasterStubDataReturnType,
|
|
12
|
+
getPaymasterStubData
|
|
13
|
+
} from "../../actions/getPaymasterStubData"
|
|
14
|
+
import type { Eip7677RpcSchema } from "../../types/paymaster"
|
|
15
|
+
|
|
16
|
+
export type PaymasterActionsEip7677<
|
|
17
|
+
TEntryPoint extends EntryPoint,
|
|
18
|
+
TChain extends Chain | undefined = Chain | undefined
|
|
19
|
+
> = {
|
|
20
|
+
getPaymasterData: <
|
|
21
|
+
TChainOverride extends Chain | undefined = Chain | undefined
|
|
22
|
+
>(
|
|
23
|
+
args: Omit<
|
|
24
|
+
GetPaymasterDataParameters<TEntryPoint, TChain, TChainOverride>,
|
|
25
|
+
"entryPoint"
|
|
26
|
+
>
|
|
27
|
+
) => Promise<GetPaymasterDataReturnType<TEntryPoint>>
|
|
28
|
+
getPaymasterStubData: <
|
|
29
|
+
TChainOverride extends Chain | undefined = Chain | undefined
|
|
30
|
+
>(
|
|
31
|
+
args: Prettify<
|
|
32
|
+
Omit<
|
|
33
|
+
GetPaymasterStubDataParameters<
|
|
34
|
+
TEntryPoint,
|
|
35
|
+
TChain,
|
|
36
|
+
TChainOverride
|
|
37
|
+
>,
|
|
38
|
+
"entryPoint"
|
|
39
|
+
>
|
|
40
|
+
>
|
|
41
|
+
) => Promise<GetPaymasterStubDataReturnType<TEntryPoint>>
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const paymasterActionsEip7677 =
|
|
45
|
+
<TEntryPoint extends EntryPoint>({
|
|
46
|
+
entryPoint
|
|
47
|
+
}: { entryPoint: TEntryPoint }) =>
|
|
48
|
+
<
|
|
49
|
+
TTransport extends Transport,
|
|
50
|
+
TChain extends Chain | undefined = Chain | undefined
|
|
51
|
+
>(
|
|
52
|
+
client: Client<TTransport, TChain>
|
|
53
|
+
): PaymasterActionsEip7677<TEntryPoint, TChain> => ({
|
|
54
|
+
getPaymasterData: (args) =>
|
|
55
|
+
getPaymasterData(
|
|
56
|
+
client as Client<
|
|
57
|
+
TTransport,
|
|
58
|
+
TChain,
|
|
59
|
+
undefined,
|
|
60
|
+
Eip7677RpcSchema<TEntryPoint>
|
|
61
|
+
>,
|
|
62
|
+
{
|
|
63
|
+
userOperation: args.userOperation,
|
|
64
|
+
context: args.context,
|
|
65
|
+
chain: args.chain,
|
|
66
|
+
entryPoint
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
getPaymasterStubData: async (args) =>
|
|
70
|
+
getPaymasterStubData(
|
|
71
|
+
client as Client<
|
|
72
|
+
TTransport,
|
|
73
|
+
TChain,
|
|
74
|
+
undefined,
|
|
75
|
+
Eip7677RpcSchema<TEntryPoint>
|
|
76
|
+
>,
|
|
77
|
+
{
|
|
78
|
+
userOperation: args.userOperation,
|
|
79
|
+
context: args.context,
|
|
80
|
+
chain: args.chain,
|
|
81
|
+
entryPoint
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
export { paymasterActionsEip7677 }
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type GetPaymasterDataParameters,
|
|
3
|
+
type GetPaymasterDataReturnType,
|
|
4
|
+
getPaymasterData
|
|
5
|
+
} from "./actions/getPaymasterData"
|
|
6
|
+
import {
|
|
7
|
+
type GetPaymasterStubDataParameters,
|
|
8
|
+
type GetPaymasterStubDataReturnType,
|
|
9
|
+
getPaymasterStubData
|
|
10
|
+
} from "./actions/getPaymasterStubData"
|
|
11
|
+
import {
|
|
12
|
+
type PaymasterActionsEip7677,
|
|
13
|
+
paymasterActionsEip7677
|
|
14
|
+
} from "./clients/decorators/paymasterActionsEip7677"
|
|
15
|
+
import type { Eip7677RpcSchema } from "./types/paymaster"
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
type GetPaymasterStubDataParameters,
|
|
19
|
+
type GetPaymasterStubDataReturnType,
|
|
20
|
+
getPaymasterStubData,
|
|
21
|
+
type GetPaymasterDataReturnType,
|
|
22
|
+
type GetPaymasterDataParameters,
|
|
23
|
+
getPaymasterData,
|
|
24
|
+
type PaymasterActionsEip7677,
|
|
25
|
+
paymasterActionsEip7677,
|
|
26
|
+
type Eip7677RpcSchema
|
|
27
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Hex } from "viem"
|
|
2
|
+
import type {
|
|
3
|
+
EntryPoint,
|
|
4
|
+
GetEntryPointVersion
|
|
5
|
+
} from "../../../types/entrypoint"
|
|
6
|
+
import type { UserOperationWithBigIntAsHex } from "../../../types/userOperation"
|
|
7
|
+
|
|
8
|
+
export type GetRpcPaymasterStubDataParameters<entryPoint extends EntryPoint> = [
|
|
9
|
+
userOperation: UserOperationWithBigIntAsHex<
|
|
10
|
+
GetEntryPointVersion<entryPoint>
|
|
11
|
+
>,
|
|
12
|
+
entryPoint: entryPoint,
|
|
13
|
+
chainId: Hex,
|
|
14
|
+
context?: Record<string, unknown>
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
export type GetRpcPaymasterStubDataReturnType<entryPoint extends EntryPoint> =
|
|
18
|
+
GetEntryPointVersion<entryPoint> extends "v0.6"
|
|
19
|
+
? {
|
|
20
|
+
paymasterAndData: Hex
|
|
21
|
+
}
|
|
22
|
+
: {
|
|
23
|
+
paymaster: Hex
|
|
24
|
+
paymasterData: Hex
|
|
25
|
+
paymasterVerificationGasLimit?: Hex | null
|
|
26
|
+
paymasterPostOpGasLimit?: Hex | null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type GetRpcPaymasterDataParameters<entryPoint extends EntryPoint> = [
|
|
30
|
+
userOperation: UserOperationWithBigIntAsHex<
|
|
31
|
+
GetEntryPointVersion<entryPoint>
|
|
32
|
+
>,
|
|
33
|
+
entryPoint: entryPoint,
|
|
34
|
+
chainId: Hex,
|
|
35
|
+
context?: Record<string, unknown>
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
export type GetRpcPaymasterDataReturnType<entryPoint extends EntryPoint> =
|
|
39
|
+
GetEntryPointVersion<entryPoint> extends "v0.6"
|
|
40
|
+
? {
|
|
41
|
+
paymasterAndData: Hex
|
|
42
|
+
}
|
|
43
|
+
: {
|
|
44
|
+
paymaster: Hex
|
|
45
|
+
paymasterData: Hex
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type Eip7677RpcSchema<entryPoint extends EntryPoint> = [
|
|
49
|
+
{
|
|
50
|
+
Method: "pm_getPaymasterStubData"
|
|
51
|
+
Parameters: GetRpcPaymasterStubDataParameters<entryPoint>
|
|
52
|
+
ReturnType: GetRpcPaymasterStubDataReturnType<entryPoint>
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
Method: "pm_getPaymasterData"
|
|
56
|
+
Paremeters: GetRpcPaymasterDataParameters<entryPoint>
|
|
57
|
+
ReturnType: GetRpcPaymasterDataReturnType<entryPoint>
|
|
58
|
+
}
|
|
59
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./eip7677"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "permissionless",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.26",
|
|
4
4
|
"author": "Pimlico",
|
|
5
5
|
"homepage": "https://docs.pimlico.io/permissionless",
|
|
6
6
|
"repository": "github:pimlicolabs/permissionless.js",
|
|
@@ -79,6 +79,11 @@
|
|
|
79
79
|
"types": "./_types/types/index.d.ts",
|
|
80
80
|
"import": "./_esm/types/index.js",
|
|
81
81
|
"default": "./_cjs/types/index.js"
|
|
82
|
+
},
|
|
83
|
+
"./experimental": {
|
|
84
|
+
"types": "./_types/experimental/index.d.ts",
|
|
85
|
+
"import": "./_esm/experimental/index.js",
|
|
86
|
+
"default": "./_cjs/experimental/index.js"
|
|
82
87
|
}
|
|
83
88
|
},
|
|
84
89
|
"peerDependencies": {
|