permissionless 0.0.1 → 0.0.3
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 +17 -0
- package/_cjs/actions/bundler.js +118 -0
- package/_cjs/actions/bundler.js.map +1 -0
- package/_cjs/actions/index.js +12 -0
- package/_cjs/actions/index.js.map +1 -0
- package/_cjs/actions/pimlico.js +55 -0
- package/_cjs/actions/pimlico.js.map +1 -0
- package/_cjs/actions/utils.js +31 -0
- package/_cjs/actions/utils.js.map +1 -0
- package/_cjs/clients/bundler.js +17 -0
- package/_cjs/clients/bundler.js.map +1 -0
- package/_cjs/clients/index.js +6 -0
- package/_cjs/clients/index.js.map +1 -0
- package/_cjs/clients/pimlico.js +29 -0
- package/_cjs/clients/pimlico.js.map +1 -0
- package/_cjs/index.js +7 -0
- package/_cjs/index.js.map +1 -0
- package/_cjs/package.json +1 -0
- package/_cjs/types/bundler.js +3 -0
- package/_cjs/types/bundler.js.map +1 -0
- package/_cjs/types/index.js +3 -0
- package/_cjs/types/index.js.map +1 -0
- package/_cjs/types/pimlico.js +3 -0
- package/_cjs/types/pimlico.js.map +1 -0
- package/_cjs/types/userOperation.js +3 -0
- package/_cjs/types/userOperation.js.map +1 -0
- package/_esm/actions/bundler.js +251 -0
- package/_esm/actions/bundler.js.map +1 -0
- package/_esm/actions/index.js +3 -0
- package/_esm/actions/index.js.map +1 -0
- package/_esm/actions/pimlico.js +127 -0
- package/_esm/actions/pimlico.js.map +1 -0
- package/_esm/actions/utils.js +28 -0
- package/_esm/actions/utils.js.map +1 -0
- package/_esm/clients/bundler.js +33 -0
- package/_esm/clients/bundler.js.map +1 -0
- package/_esm/clients/index.js +3 -0
- package/_esm/clients/index.js.map +1 -0
- package/_esm/clients/pimlico.js +64 -0
- package/_esm/clients/pimlico.js.map +1 -0
- package/_esm/index.js +4 -0
- package/_esm/index.js.map +1 -0
- package/_esm/package.json +1 -0
- package/_esm/types/bundler.js +2 -0
- package/_esm/types/bundler.js.map +1 -0
- package/_esm/types/index.js +2 -0
- package/_esm/types/index.js.map +1 -0
- package/_esm/types/pimlico.js +2 -0
- package/_esm/types/pimlico.js.map +1 -0
- package/_esm/types/userOperation.js +2 -0
- package/_esm/types/userOperation.js.map +1 -0
- package/_types/actions/bundler.d.ts +393 -0
- package/_types/actions/bundler.d.ts.map +1 -0
- package/_types/actions/index.d.ts +5 -0
- package/_types/actions/index.d.ts.map +1 -0
- package/_types/actions/pimlico.d.ts +184 -0
- package/_types/actions/pimlico.d.ts.map +1 -0
- package/_types/actions/utils.d.ts +6 -0
- package/_types/actions/utils.d.ts.map +1 -0
- package/_types/clients/bundler.d.ts +39 -0
- package/_types/clients/bundler.d.ts.map +1 -0
- package/_types/clients/index.d.ts +3 -0
- package/_types/clients/index.d.ts.map +1 -0
- package/_types/clients/pimlico.d.ts +75 -0
- package/_types/clients/pimlico.d.ts.map +1 -0
- package/_types/index.d.ts +4 -0
- package/_types/index.d.ts.map +1 -0
- package/_types/types/bundler.d.ts +82 -0
- package/_types/types/bundler.d.ts.map +1 -0
- package/_types/types/index.d.ts +3 -0
- package/_types/types/index.d.ts.map +1 -0
- package/_types/types/pimlico.d.ts +50 -0
- package/_types/types/pimlico.d.ts.map +1 -0
- package/_types/types/userOperation.d.ts +30 -0
- package/_types/types/userOperation.d.ts.map +1 -0
- package/actions/bundler.ts +498 -0
- package/actions/index.ts +38 -0
- package/actions/package.json +6 -0
- package/actions/pimlico.ts +258 -0
- package/actions/utils.ts +30 -0
- package/clients/bundler.ts +39 -0
- package/clients/index.ts +3 -0
- package/clients/pimlico.ts +93 -0
- package/index.ts +3 -0
- package/package.json +49 -11
- package/tsconfig.build.tsbuildinfo +1 -0
- package/types/bundler.ts +85 -0
- package/types/index.ts +3 -0
- package/types/package.json +6 -0
- package/types/pimlico.ts +55 -0
- package/types/userOperation.ts +32 -0
- package/LICENSE +0 -21
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# permissionless
|
|
2
|
+
|
|
3
|
+
## 0.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 80e7fad: Added Pimlico Bundler Actions (pimlico_getUserOperationStatus, pimlico_getUserOperationGasPrice)
|
|
8
|
+
Added Pimlico Paymaster Actions (pm_sponsorUserOperation)
|
|
9
|
+
Added types for BundlerClient, GetUserOperationByHashParameters, GetUserOperationByHashReturnType, GetUserOperationReceiptParameters, GetUserOperationReceiptReturnType
|
|
10
|
+
Added createBundlerClient, createPimlicoBundlerClient, createPimlicoPaymasterClient
|
|
11
|
+
- 3bbc6d3: Fix JSDoc for Bundler Actions, move viem to peerDependencies, and export getUserOperationReceipt
|
|
12
|
+
|
|
13
|
+
## 0.0.2
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 05a12f9: Added Bundler Actions and standard bundler methods support
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUserOperationReceipt = exports.getUserOperationByHash = exports.chainId = exports.supportedEntryPoints = exports.estimateUserOperationGas = exports.sendUserOperation = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
const sendUserOperation = async (client, args) => {
|
|
6
|
+
const { userOperation, entryPoint } = args;
|
|
7
|
+
return client.request({
|
|
8
|
+
method: "eth_sendUserOperation",
|
|
9
|
+
params: [(0, utils_1.deepHexlify)(userOperation), entryPoint]
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
exports.sendUserOperation = sendUserOperation;
|
|
13
|
+
const estimateUserOperationGas = async (client, args) => {
|
|
14
|
+
const { userOperation, entryPoint } = args;
|
|
15
|
+
const response = await client.request({
|
|
16
|
+
method: "eth_estimateUserOperationGas",
|
|
17
|
+
params: [(0, utils_1.deepHexlify)(userOperation), entryPoint]
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
preVerificationGas: BigInt(response.preVerificationGas || 0n),
|
|
21
|
+
verificationGasLimit: BigInt(response.verificationGasLimit || 0n),
|
|
22
|
+
callGasLimit: BigInt(response.callGasLimit || 0n)
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.estimateUserOperationGas = estimateUserOperationGas;
|
|
26
|
+
const supportedEntryPoints = async (client) => {
|
|
27
|
+
return client.request({
|
|
28
|
+
method: "eth_supportedEntryPoints",
|
|
29
|
+
params: []
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
exports.supportedEntryPoints = supportedEntryPoints;
|
|
33
|
+
const chainId = async (client) => {
|
|
34
|
+
return BigInt(await client.request({
|
|
35
|
+
method: "eth_chainId",
|
|
36
|
+
params: []
|
|
37
|
+
}));
|
|
38
|
+
};
|
|
39
|
+
exports.chainId = chainId;
|
|
40
|
+
const getUserOperationByHash = async (client, { hash }) => {
|
|
41
|
+
const params = [hash];
|
|
42
|
+
const response = await client.request({
|
|
43
|
+
method: "eth_getUserOperationByHash",
|
|
44
|
+
params
|
|
45
|
+
});
|
|
46
|
+
if (!response)
|
|
47
|
+
return null;
|
|
48
|
+
const { userOperation, entryPoint, transactionHash, blockHash, blockNumber } = response;
|
|
49
|
+
return {
|
|
50
|
+
userOperation: {
|
|
51
|
+
...userOperation,
|
|
52
|
+
nonce: BigInt(userOperation.nonce),
|
|
53
|
+
callGasLimit: BigInt(userOperation.callGasLimit),
|
|
54
|
+
verificationGasLimit: BigInt(userOperation.verificationGasLimit),
|
|
55
|
+
preVerificationGas: BigInt(userOperation.preVerificationGas),
|
|
56
|
+
maxFeePerGas: BigInt(userOperation.maxFeePerGas),
|
|
57
|
+
maxPriorityFeePerGas: BigInt(userOperation.maxPriorityFeePerGas)
|
|
58
|
+
},
|
|
59
|
+
entryPoint: entryPoint,
|
|
60
|
+
transactionHash: transactionHash,
|
|
61
|
+
blockHash: blockHash,
|
|
62
|
+
blockNumber: BigInt(blockNumber)
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
exports.getUserOperationByHash = getUserOperationByHash;
|
|
66
|
+
const getUserOperationReceipt = async (client, { hash }) => {
|
|
67
|
+
const params = [hash];
|
|
68
|
+
const response = await client.request({
|
|
69
|
+
method: "eth_getUserOperationReceipt",
|
|
70
|
+
params
|
|
71
|
+
});
|
|
72
|
+
if (!response)
|
|
73
|
+
return null;
|
|
74
|
+
const userOperationReceipt = {
|
|
75
|
+
userOpHash: response.userOpHash,
|
|
76
|
+
sender: response.sender,
|
|
77
|
+
nonce: BigInt(response.nonce),
|
|
78
|
+
actualGasUsed: BigInt(response.actualGasUsed),
|
|
79
|
+
actualGasCost: BigInt(response.actualGasCost),
|
|
80
|
+
success: response.success,
|
|
81
|
+
receipt: {
|
|
82
|
+
transactionHash: response.receipt.transactionHash,
|
|
83
|
+
transactionIndex: BigInt(response.receipt.transactionIndex),
|
|
84
|
+
blockHash: response.receipt.blockHash,
|
|
85
|
+
blockNumber: BigInt(response.receipt.blockNumber),
|
|
86
|
+
from: response.receipt.from,
|
|
87
|
+
to: response.receipt.to,
|
|
88
|
+
cumulativeGasUsed: BigInt(response.receipt.cumulativeGasUsed),
|
|
89
|
+
status: utils_1.transactionReceiptStatus[response.receipt.status],
|
|
90
|
+
gasUsed: BigInt(response.receipt.gasUsed),
|
|
91
|
+
contractAddress: response.receipt.contractAddress,
|
|
92
|
+
logsBloom: response.receipt.logsBloom,
|
|
93
|
+
effectiveGasPrice: BigInt(response.receipt.effectiveGasPrice)
|
|
94
|
+
},
|
|
95
|
+
logs: response.logs.map((log) => ({
|
|
96
|
+
data: log.data,
|
|
97
|
+
blockNumber: BigInt(log.blockNumber),
|
|
98
|
+
blockHash: log.blockHash,
|
|
99
|
+
transactionHash: log.transactionHash,
|
|
100
|
+
logIndex: BigInt(log.logIndex),
|
|
101
|
+
transactionIndex: BigInt(log.transactionIndex),
|
|
102
|
+
address: log.address,
|
|
103
|
+
topics: log.topics
|
|
104
|
+
}))
|
|
105
|
+
};
|
|
106
|
+
return userOperationReceipt;
|
|
107
|
+
};
|
|
108
|
+
exports.getUserOperationReceipt = getUserOperationReceipt;
|
|
109
|
+
const bundlerActions = (client) => ({
|
|
110
|
+
sendUserOperation: async (args) => (0, exports.sendUserOperation)(client, args),
|
|
111
|
+
estimateUserOperationGas: (args) => (0, exports.estimateUserOperationGas)(client, args),
|
|
112
|
+
supportedEntryPoints: () => (0, exports.supportedEntryPoints)(client),
|
|
113
|
+
chainId: () => (0, exports.chainId)(client),
|
|
114
|
+
getUserOperationByHash: (args) => (0, exports.getUserOperationByHash)(client, args),
|
|
115
|
+
getUserOperationReceipt: (args) => (0, exports.getUserOperationReceipt)(client, args)
|
|
116
|
+
});
|
|
117
|
+
exports.default = bundlerActions;
|
|
118
|
+
//# sourceMappingURL=bundler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundler.js","sourceRoot":"","sources":["../../actions/bundler.ts"],"names":[],"mappings":";;;AAMA,mCAA+D;AA8FxD,MAAM,iBAAiB,GAAG,KAAK,EAAE,MAAqB,EAAE,IAAiC,EAAiB,EAAE;IAC/G,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,IAAI,CAAA;IAE1C,OAAO,MAAM,CAAC,OAAO,CAAC;QAClB,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,IAAA,mBAAW,EAAC,aAAa,CAAiC,EAAE,UAAqB,CAAC;KAC9F,CAAC,CAAA;AACN,CAAC,CAAA;AAPY,QAAA,iBAAiB,qBAO7B;AA6BM,MAAM,wBAAwB,GAAG,KAAK,EACzC,MAAqB,EACrB,IAAwC,EACG,EAAE;IAC7C,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,IAAI,CAAA;IAE1C,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClC,MAAM,EAAE,8BAA8B;QACtC,MAAM,EAAE,CAAC,IAAA,mBAAW,EAAC,aAAa,CAA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AK,EAAE,IAAiC,EAAiB,EAAE,CAC1E,IAAA,yBAAiB,EAAC,MAAuB,EAAE,IAAI,CAAC;IACpD,wBAAwB,EAAE,CAAC,IAAwC,EAAE,EAAE,CACnE,IAAA,gCAAwB,EAAC,MAAuB,EAAE,IAAI,CAAC;IAC3D,oBAAoB,EAAE,GAAuB,EAAE,CAAC,IAAA,4BAAoB,EAAC,MAAuB,CAAC;IAC7F,OAAO,EAAE,GAAG,EAAE,CAAC,IAAA,eAAO,EAAC,MAAuB,CAAC;IAC/C,sBAAsB,EAAE,CAAC,IAAsC,EAAE,EAAE,CAC/D,IAAA,8BAAsB,EAAC,MAAuB,EAAE,IAAI,CAAC;IACzD,uBAAuB,EAAE,CAAC,IAAuC,EAAE,EAAE,CACjE,IAAA,+BAAuB,EAAC,MAAuB,EAAE,IAAI,CAAC;CAC7D,CAAC,CAAA;AAEF,kBAAe,cAAc,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUserOperationReceipt = exports.getUserOperationByHash = exports.chainId = exports.supportedEntryPoints = exports.estimateUserOperationGas = exports.sendUserOperation = exports.bundlerActions = void 0;
|
|
4
|
+
const bundler_1 = require("./bundler");
|
|
5
|
+
exports.bundlerActions = bundler_1.default;
|
|
6
|
+
Object.defineProperty(exports, "chainId", { enumerable: true, get: function () { return bundler_1.chainId; } });
|
|
7
|
+
Object.defineProperty(exports, "estimateUserOperationGas", { enumerable: true, get: function () { return bundler_1.estimateUserOperationGas; } });
|
|
8
|
+
Object.defineProperty(exports, "getUserOperationByHash", { enumerable: true, get: function () { return bundler_1.getUserOperationByHash; } });
|
|
9
|
+
Object.defineProperty(exports, "getUserOperationReceipt", { enumerable: true, get: function () { return bundler_1.getUserOperationReceipt; } });
|
|
10
|
+
Object.defineProperty(exports, "sendUserOperation", { enumerable: true, get: function () { return bundler_1.sendUserOperation; } });
|
|
11
|
+
Object.defineProperty(exports, "supportedEntryPoints", { enumerable: true, get: function () { return bundler_1.supportedEntryPoints; } });
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../actions/index.ts"],"names":[],"mappings":";;;AAUA,uCAOkB;AAad,yBApBG,iBAAc,CAoBH;AAId,wFAvBA,iBAAO,OAuBA;AAFP,yGApBA,kCAAwB,OAoBA;AAGxB,uGAtBA,gCAAsB,OAsBA;AACtB,wGAtBA,iCAAuB,OAsBA;AALvB,kGAhBA,2BAAiB,OAgBA;AAEjB,qGAjBA,8BAAoB,OAiBA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pimlicoPaymasterActions = exports.sponsorUserOperation = exports.pimlicoBundlerActions = exports.getUserOperationStatus = exports.getUserOperationGasPrice = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
const getUserOperationGasPrice = async (client) => {
|
|
6
|
+
const gasPrices = await client.request({
|
|
7
|
+
method: "pimlico_getUserOperationGasPrice",
|
|
8
|
+
params: []
|
|
9
|
+
});
|
|
10
|
+
return {
|
|
11
|
+
slow: {
|
|
12
|
+
maxFeePerGas: BigInt(gasPrices.slow.maxFeePerGas),
|
|
13
|
+
maxPriorityFeePerGas: BigInt(gasPrices.slow.maxPriorityFeePerGas)
|
|
14
|
+
},
|
|
15
|
+
standard: {
|
|
16
|
+
maxFeePerGas: BigInt(gasPrices.standard.maxFeePerGas),
|
|
17
|
+
maxPriorityFeePerGas: BigInt(gasPrices.standard.maxPriorityFeePerGas)
|
|
18
|
+
},
|
|
19
|
+
fast: {
|
|
20
|
+
maxFeePerGas: BigInt(gasPrices.fast.maxFeePerGas),
|
|
21
|
+
maxPriorityFeePerGas: BigInt(gasPrices.fast.maxPriorityFeePerGas)
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.getUserOperationGasPrice = getUserOperationGasPrice;
|
|
26
|
+
const getUserOperationStatus = async (client, { hash }) => {
|
|
27
|
+
return client.request({
|
|
28
|
+
method: "pimlico_getUserOperationStatus",
|
|
29
|
+
params: [hash]
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
exports.getUserOperationStatus = getUserOperationStatus;
|
|
33
|
+
const pimlicoBundlerActions = (client) => ({
|
|
34
|
+
getUserOperationGasPrice: async () => (0, exports.getUserOperationGasPrice)(client),
|
|
35
|
+
getUserOperationStatus: async (args) => (0, exports.getUserOperationStatus)(client, args)
|
|
36
|
+
});
|
|
37
|
+
exports.pimlicoBundlerActions = pimlicoBundlerActions;
|
|
38
|
+
const sponsorUserOperation = async (client, args) => {
|
|
39
|
+
const response = await client.request({
|
|
40
|
+
method: "pm_sponsorUserOperation",
|
|
41
|
+
params: [(0, utils_1.deepHexlify)(args.userOperation), args.entryPoint]
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
paymasterAndData: response.paymasterAndData,
|
|
45
|
+
preVerificationGas: BigInt(response.preVerificationGas),
|
|
46
|
+
verificationGasLimit: BigInt(response.verificationGasLimit),
|
|
47
|
+
callGasLimit: BigInt(response.callGasLimit)
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
exports.sponsorUserOperation = sponsorUserOperation;
|
|
51
|
+
const pimlicoPaymasterActions = (client) => ({
|
|
52
|
+
sponsorUserOperation: async (args) => (0, exports.sponsorUserOperation)(client, args)
|
|
53
|
+
});
|
|
54
|
+
exports.pimlicoPaymasterActions = pimlicoPaymasterActions;
|
|
55
|
+
//# sourceMappingURL=pimlico.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pimlico.js","sourceRoot":"","sources":["../../actions/pimlico.ts"],"names":[],"mappings":";;;AAKA,mCAAqC;AA4D9B,MAAM,wBAAwB,GAAG,KAAK,EACzC,MAA4B,EACe,EAA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M,oBAAoB,GAAG,KAAK,EACrC,MAA8B,EAC9B,IAAoC,EACG,EAAE;IACzC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClC,MAAM,EAAE,yBAAyB;QACjC,MAAM,EAAE,CAAC,IAAA,mBAAW,EAAC,IAAI,CAAC,aAAa,CAAiC,EAAE,IAAI,CAAC,UAAU,CAAC;KAC7F,CAAC,CAAA;IAEF,OAAO;QACH,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB;QAC3C,kBAAkB,EAAE,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QACvD,oBAAoB,EAAE,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAC;QAC3D,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC;KAC9C,CAAA;AACL,CAAC,CAAA;AAfY,QAAA,oBAAoB,wBAehC;AA8BM,MAAM,uBAAuB,GAAG,CAAC,MAAc,EAAiC,EAAE,CAAC,CAAC;IACvF,oBAAoB,EAAE,KAAK,EAAE,IAAoC,EAAE,EAAE,CACjE,IAAA,4BAAoB,EAAC,MAAgC,EAAE,IAAI,CAAC;CACnE,CAAC,CAAA;AAHW,QAAA,uBAAuB,2BAGlC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deepHexlify = exports.transactionReceiptStatus = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
exports.transactionReceiptStatus = {
|
|
6
|
+
"0x0": "reverted",
|
|
7
|
+
"0x1": "success"
|
|
8
|
+
};
|
|
9
|
+
function deepHexlify(obj) {
|
|
10
|
+
if (typeof obj === "function") {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
if (obj == null || typeof obj === "string" || typeof obj === "boolean") {
|
|
14
|
+
return obj;
|
|
15
|
+
}
|
|
16
|
+
else if (typeof obj === "bigint") {
|
|
17
|
+
return (0, viem_1.toHex)(obj);
|
|
18
|
+
}
|
|
19
|
+
else if (obj._isBigNumber != null || typeof obj !== "object") {
|
|
20
|
+
return (0, viem_1.toHex)(obj).replace(/^0x0/, "0x");
|
|
21
|
+
}
|
|
22
|
+
if (Array.isArray(obj)) {
|
|
23
|
+
return obj.map((member) => deepHexlify(member));
|
|
24
|
+
}
|
|
25
|
+
return Object.keys(obj).reduce((set, key) => ({
|
|
26
|
+
...set,
|
|
27
|
+
[key]: deepHexlify(obj[key])
|
|
28
|
+
}), {});
|
|
29
|
+
}
|
|
30
|
+
exports.deepHexlify = deepHexlify;
|
|
31
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../actions/utils.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAEf,QAAA,wBAAwB,GAAG;IACpC,KAAK,EAAE,UAAU;IACjB,KAAK,EAAE,SAAS;CACV,CAAA;AAGV,SAAgB,WAAW,CAAC,GAAQ;IAChC,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;QAC3B,OAAO,SAAS,CAAA;KACnB;IACD,IAAI,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,SAAS,EAAE;QACpE,OAAO,GAAG,CAAA;KACb;SAAM,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAChC,OAAO,IAAA,YAAK,EAAC,GAAG,CAAC,CAAA;KACpB;SAAM,IAAI,GAAG,CAAC,YAAY,IAAI,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC5D,OAAO,IAAA,YAAK,EAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;KAC1C;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACpB,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAA;KAClD;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAC1B,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QACX,GAAG,GAAG;QACN,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;KAC/B,CAAC,EACF,EAAE,CACL,CAAA;AACL,CAAC;AArBD,kCAqBC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBundlerClient = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const actions_1 = require("../actions");
|
|
6
|
+
const createBundlerClient = (parameters) => {
|
|
7
|
+
const { key = "public", name = "Bundler Client" } = parameters;
|
|
8
|
+
const client = (0, viem_1.createClient)({
|
|
9
|
+
...parameters,
|
|
10
|
+
key,
|
|
11
|
+
name,
|
|
12
|
+
type: "bundlerClient"
|
|
13
|
+
});
|
|
14
|
+
return client.extend(actions_1.bundlerActions);
|
|
15
|
+
};
|
|
16
|
+
exports.createBundlerClient = createBundlerClient;
|
|
17
|
+
//# sourceMappingURL=bundler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundler.js","sourceRoot":"","sources":["../../clients/bundler.ts"],"names":[],"mappings":";;;AACA,+BAAmC;AACnC,wCAA2C;AAyBpC,MAAM,mBAAmB,GAAG,CAC/B,UAAgD,EACnC,EAAE;IACf,MAAM,EAAE,GAAG,GAAG,QAAQ,EAAE,IAAI,GAAG,gBAAgB,EAAE,GAAG,UAAU,CAAA;IAC9D,MAAM,MAAM,GAAG,IAAA,mBAAY,EAAC;QACxB,GAAG,UAAU;QACb,GAAG;QACH,IAAI;QACJ,IAAI,EAAE,eAAe;KACxB,CAAC,CAAA;IACF,OAAO,MAAM,CAAC,MAAM,CAAC,wBAAc,CAAC,CAAA;AACxC,CAAC,CAAA;AAXY,QAAA,mBAAmB,uBAW/B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBundlerClient = void 0;
|
|
4
|
+
const bundler_1 = require("./bundler");
|
|
5
|
+
Object.defineProperty(exports, "createBundlerClient", { enumerable: true, get: function () { return bundler_1.createBundlerClient; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../clients/index.ts"],"names":[],"mappings":";;;AAAA,uCAAmE;AAE1D,oGAFoB,6BAAmB,OAEpB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPimlicoPaymasterClient = exports.createPimlicoBundlerClient = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const actions_1 = require("../actions");
|
|
6
|
+
const pimlico_1 = require("../actions/pimlico");
|
|
7
|
+
const createPimlicoBundlerClient = (parameters) => {
|
|
8
|
+
const { key = "public", name = "Pimlico Bundler Client" } = parameters;
|
|
9
|
+
const client = (0, viem_1.createClient)({
|
|
10
|
+
...parameters,
|
|
11
|
+
key,
|
|
12
|
+
name,
|
|
13
|
+
type: "pimlicoBundlerClient"
|
|
14
|
+
});
|
|
15
|
+
return client.extend(actions_1.bundlerActions).extend(pimlico_1.pimlicoBundlerActions);
|
|
16
|
+
};
|
|
17
|
+
exports.createPimlicoBundlerClient = createPimlicoBundlerClient;
|
|
18
|
+
const createPimlicoPaymasterClient = (parameters) => {
|
|
19
|
+
const { key = "public", name = "Pimlico Paymaster Client" } = parameters;
|
|
20
|
+
const client = (0, viem_1.createClient)({
|
|
21
|
+
...parameters,
|
|
22
|
+
key,
|
|
23
|
+
name,
|
|
24
|
+
type: "pimlicoPaymasterClient"
|
|
25
|
+
});
|
|
26
|
+
return client.extend(pimlico_1.pimlicoPaymasterActions);
|
|
27
|
+
};
|
|
28
|
+
exports.createPimlicoPaymasterClient = createPimlicoPaymasterClient;
|
|
29
|
+
//# sourceMappingURL=pimlico.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pimlico.js","sourceRoot":"","sources":["../../clients/pimlico.ts"],"names":[],"mappings":";;;AACA,+BAAmC;AACnC,wCAA2C;AAE3C,gDAK2B;AAuCpB,MAAM,0BAA0B,GAAG,CACtC,UAAgD,EAC5B,EAAE;IACtB,MAAM,EAAE,GAAG,GAAG,QAAQ,EAAE,IAAI,GAAG,wBAAwB,EAAE,GAAG,UAAU,CAAA;IACtE,MAAM,MAAM,GAAG,IAAA,mBAAY,EAAC;QACxB,GAAG,UAAU;QACb,GAAG;QACH,IAAI;QACJ,IAAI,EAAE,sBAAsB;KAC/B,CAAC,CAAA;IACF,OAAO,MAAM,CAAC,MAAM,CAAC,wBAAc,CAAC,CAAC,MAAM,CAAC,+BAAqB,CAAC,CAAA;AACtE,CAAC,CAAA;AAXY,QAAA,0BAA0B,8BAWtC;AAsBM,MAAM,4BAA4B,GAAG,CACxC,UAAgD,EAC1B,EAAE;IACxB,MAAM,EAAE,GAAG,GAAG,QAAQ,EAAE,IAAI,GAAG,0BAA0B,EAAE,GAAG,UAAU,CAAA;IACxE,MAAM,MAAM,GAAG,IAAA,mBAAY,EAAC;QACxB,GAAG,UAAU;QACb,GAAG;QACH,IAAI;QACJ,IAAI,EAAE,wBAAwB;KACjC,CAAC,CAAA;IACF,OAAO,MAAM,CAAC,MAAM,CAAC,iCAAuB,CAAC,CAAA;AACjD,CAAC,CAAA;AAXY,QAAA,4BAA4B,gCAWxC"}
|
package/_cjs/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./actions"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./clients"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB;AACzB,oDAAyB;AACzB,kDAAuB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundler.js","sourceRoot":"","sources":["../../types/bundler.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../types/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pimlico.js","sourceRoot":"","sources":["../../types/pimlico.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userOperation.js","sourceRoot":"","sources":["../../types/userOperation.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { deepHexlify, transactionReceiptStatus } from "./utils";
|
|
2
|
+
/**
|
|
3
|
+
* Sends user operation to the bundler
|
|
4
|
+
*
|
|
5
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/sendUserOperation
|
|
6
|
+
*
|
|
7
|
+
* @param client {@link BundlerClient} that you created using viem's createClient and extended it with bundlerActions.
|
|
8
|
+
* @param args {@link SendUserOperationParameters}.
|
|
9
|
+
* @returns UserOpHash that you can use to track user operation as {@link Hash}.
|
|
10
|
+
*
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { createClient } from "viem"
|
|
14
|
+
* import { sendUserOperation } from "permissionless/actions"
|
|
15
|
+
*
|
|
16
|
+
* const bundlerClient = createClient({
|
|
17
|
+
* chain: goerli,
|
|
18
|
+
* transport: http(BUNDLER_URL)
|
|
19
|
+
* })
|
|
20
|
+
*
|
|
21
|
+
* const userOpHash = sendUserOperation(bundlerClient, {
|
|
22
|
+
* userOperation: signedUserOperation,
|
|
23
|
+
* entryPoint: entryPoint
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* // Return '0xe9fad2cd67f9ca1d0b7a6513b2a42066784c8df938518da2b51bb8cc9a89ea34'
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
export const sendUserOperation = async (client, args) => {
|
|
30
|
+
const { userOperation, entryPoint } = args;
|
|
31
|
+
return client.request({
|
|
32
|
+
method: "eth_sendUserOperation",
|
|
33
|
+
params: [deepHexlify(userOperation), entryPoint]
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Estimates preVerificationGas, verificationGasLimit and callGasLimit for user operation
|
|
38
|
+
*
|
|
39
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/estimateUserOperationGas
|
|
40
|
+
*
|
|
41
|
+
* @param client {@link BundlerClient} that you created using viem's createClient and extended it with bundlerActions.
|
|
42
|
+
* @param args {@link EstimateUserOperationGasParameters}
|
|
43
|
+
* @returns preVerificationGas, verificationGasLimit and callGasLimit as {@link EstimateUserOperationGasReturnType}
|
|
44
|
+
*
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* import { createClient } from "viem"
|
|
48
|
+
* import { estimateUserOperationGas } from "permissionless/actions"
|
|
49
|
+
*
|
|
50
|
+
* const bundlerClient = createClient({
|
|
51
|
+
* chain: goerli,
|
|
52
|
+
* transport: http(BUNDLER_URL)
|
|
53
|
+
* })
|
|
54
|
+
*
|
|
55
|
+
* const gasParameters = estimateUserOperationGas(bundlerClient, {
|
|
56
|
+
* serOperation: signedUserOperation,
|
|
57
|
+
* entryPoint: entryPoint
|
|
58
|
+
* })
|
|
59
|
+
*
|
|
60
|
+
* // Return {preVerificationGas: 43492n, verificationGasLimit: 59436n, callGasLimit: 9000n}
|
|
61
|
+
*
|
|
62
|
+
*/
|
|
63
|
+
export const estimateUserOperationGas = async (client, args) => {
|
|
64
|
+
const { userOperation, entryPoint } = args;
|
|
65
|
+
const response = await client.request({
|
|
66
|
+
method: "eth_estimateUserOperationGas",
|
|
67
|
+
params: [deepHexlify(userOperation), entryPoint]
|
|
68
|
+
});
|
|
69
|
+
return {
|
|
70
|
+
preVerificationGas: BigInt(response.preVerificationGas || 0n),
|
|
71
|
+
verificationGasLimit: BigInt(response.verificationGasLimit || 0n),
|
|
72
|
+
callGasLimit: BigInt(response.callGasLimit || 0n)
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Returns the supported entrypoints by the bundler service
|
|
77
|
+
*
|
|
78
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/supportedEntryPoints
|
|
79
|
+
*
|
|
80
|
+
* @param client {@link BundlerClient} that you created using viem's createClient and extended it with bundlerActions.
|
|
81
|
+
* @returns Supported entryPoints
|
|
82
|
+
*
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* import { createClient } from "viem"
|
|
86
|
+
* import { supportedEntryPoints } from "permissionless/actions"
|
|
87
|
+
*
|
|
88
|
+
* const bundlerClient = createClient({
|
|
89
|
+
* chain: goerli,
|
|
90
|
+
* transport: http(BUNDLER_URL)
|
|
91
|
+
* })
|
|
92
|
+
*
|
|
93
|
+
* const entryPointsSupported = supportedEntryPoints(bundlerClient)
|
|
94
|
+
* // Return ['0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789']
|
|
95
|
+
*
|
|
96
|
+
*/
|
|
97
|
+
export const supportedEntryPoints = async (client) => {
|
|
98
|
+
return client.request({
|
|
99
|
+
method: "eth_supportedEntryPoints",
|
|
100
|
+
params: []
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Returns the supported chain id by the bundler service
|
|
105
|
+
*
|
|
106
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/chainId
|
|
107
|
+
*
|
|
108
|
+
* @param client {@link BundlerClient} that you created using viem's createClient and extended it with bundlerActions.
|
|
109
|
+
* @returns Supported chain id
|
|
110
|
+
*
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* import { createClient } from "viem"
|
|
114
|
+
* import { chainId } from "permissionless/actions"
|
|
115
|
+
*
|
|
116
|
+
* const bundlerClient = createClient({
|
|
117
|
+
* chain: goerli,
|
|
118
|
+
* transport: http(BUNDLER_URL)
|
|
119
|
+
* })
|
|
120
|
+
*
|
|
121
|
+
* const bundlerChainId = chainId(bundlerClient)
|
|
122
|
+
* // Return 5n for Goerli
|
|
123
|
+
*
|
|
124
|
+
*/
|
|
125
|
+
export const chainId = async (client) => {
|
|
126
|
+
return BigInt(await client.request({
|
|
127
|
+
method: "eth_chainId",
|
|
128
|
+
params: []
|
|
129
|
+
}));
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Returns the user operation from userOpHash
|
|
133
|
+
*
|
|
134
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/getUserOperationByHash
|
|
135
|
+
*
|
|
136
|
+
* @param client {@link BundlerClient} that you created using viem's createClient and extended it with bundlerActions.
|
|
137
|
+
* @param args {@link GetUserOperationByHashParameters} UserOpHash that was returned by {@link sendUserOperation}
|
|
138
|
+
* @returns userOperation along with entryPoint, transactionHash, blockHash, blockNumber if found or null
|
|
139
|
+
*
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* import { createClient } from "viem"
|
|
143
|
+
* import { getUserOperationByHash } from "permissionless/actions"
|
|
144
|
+
*
|
|
145
|
+
* const bundlerClient = createClient({
|
|
146
|
+
* chain: goerli,
|
|
147
|
+
* transport: http(BUNDLER_URL)
|
|
148
|
+
* })
|
|
149
|
+
*
|
|
150
|
+
* getUserOperationByHash(bundlerClient, {hash: userOpHash})
|
|
151
|
+
*
|
|
152
|
+
*/
|
|
153
|
+
export const getUserOperationByHash = async (client, { hash }) => {
|
|
154
|
+
const params = [hash];
|
|
155
|
+
const response = await client.request({
|
|
156
|
+
method: "eth_getUserOperationByHash",
|
|
157
|
+
params
|
|
158
|
+
});
|
|
159
|
+
if (!response)
|
|
160
|
+
return null;
|
|
161
|
+
const { userOperation, entryPoint, transactionHash, blockHash, blockNumber } = response;
|
|
162
|
+
return {
|
|
163
|
+
userOperation: {
|
|
164
|
+
...userOperation,
|
|
165
|
+
nonce: BigInt(userOperation.nonce),
|
|
166
|
+
callGasLimit: BigInt(userOperation.callGasLimit),
|
|
167
|
+
verificationGasLimit: BigInt(userOperation.verificationGasLimit),
|
|
168
|
+
preVerificationGas: BigInt(userOperation.preVerificationGas),
|
|
169
|
+
maxFeePerGas: BigInt(userOperation.maxFeePerGas),
|
|
170
|
+
maxPriorityFeePerGas: BigInt(userOperation.maxPriorityFeePerGas)
|
|
171
|
+
},
|
|
172
|
+
entryPoint: entryPoint,
|
|
173
|
+
transactionHash: transactionHash,
|
|
174
|
+
blockHash: blockHash,
|
|
175
|
+
blockNumber: BigInt(blockNumber)
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Returns the user operation receipt from userOpHash
|
|
180
|
+
*
|
|
181
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/getUserOperationReceipt
|
|
182
|
+
*
|
|
183
|
+
* @param client {@link BundlerClient} that you created using viem's createClient and extended it with bundlerActions.
|
|
184
|
+
* @param args {@link GetUserOperationReceiptParameters} UserOpHash that was returned by {@link sendUserOperation}
|
|
185
|
+
* @returns user operation receipt {@link GetUserOperationReceiptReturnType} if found or null
|
|
186
|
+
*
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* import { createClient } from "viem"
|
|
190
|
+
* import { getUserOperationReceipt } from "permissionless/actions"
|
|
191
|
+
*
|
|
192
|
+
* const bundlerClient = createClient({
|
|
193
|
+
* chain: goerli,
|
|
194
|
+
* transport: http(BUNDLER_URL)
|
|
195
|
+
* })
|
|
196
|
+
*
|
|
197
|
+
* getUserOperationReceipt(bundlerClient, {hash: userOpHash})
|
|
198
|
+
*
|
|
199
|
+
*/
|
|
200
|
+
export const getUserOperationReceipt = async (client, { hash }) => {
|
|
201
|
+
const params = [hash];
|
|
202
|
+
const response = await client.request({
|
|
203
|
+
method: "eth_getUserOperationReceipt",
|
|
204
|
+
params
|
|
205
|
+
});
|
|
206
|
+
if (!response)
|
|
207
|
+
return null;
|
|
208
|
+
const userOperationReceipt = {
|
|
209
|
+
userOpHash: response.userOpHash,
|
|
210
|
+
sender: response.sender,
|
|
211
|
+
nonce: BigInt(response.nonce),
|
|
212
|
+
actualGasUsed: BigInt(response.actualGasUsed),
|
|
213
|
+
actualGasCost: BigInt(response.actualGasCost),
|
|
214
|
+
success: response.success,
|
|
215
|
+
receipt: {
|
|
216
|
+
transactionHash: response.receipt.transactionHash,
|
|
217
|
+
transactionIndex: BigInt(response.receipt.transactionIndex),
|
|
218
|
+
blockHash: response.receipt.blockHash,
|
|
219
|
+
blockNumber: BigInt(response.receipt.blockNumber),
|
|
220
|
+
from: response.receipt.from,
|
|
221
|
+
to: response.receipt.to,
|
|
222
|
+
cumulativeGasUsed: BigInt(response.receipt.cumulativeGasUsed),
|
|
223
|
+
status: transactionReceiptStatus[response.receipt.status],
|
|
224
|
+
gasUsed: BigInt(response.receipt.gasUsed),
|
|
225
|
+
contractAddress: response.receipt.contractAddress,
|
|
226
|
+
logsBloom: response.receipt.logsBloom,
|
|
227
|
+
effectiveGasPrice: BigInt(response.receipt.effectiveGasPrice)
|
|
228
|
+
},
|
|
229
|
+
logs: response.logs.map((log) => ({
|
|
230
|
+
data: log.data,
|
|
231
|
+
blockNumber: BigInt(log.blockNumber),
|
|
232
|
+
blockHash: log.blockHash,
|
|
233
|
+
transactionHash: log.transactionHash,
|
|
234
|
+
logIndex: BigInt(log.logIndex),
|
|
235
|
+
transactionIndex: BigInt(log.transactionIndex),
|
|
236
|
+
address: log.address,
|
|
237
|
+
topics: log.topics
|
|
238
|
+
}))
|
|
239
|
+
};
|
|
240
|
+
return userOperationReceipt;
|
|
241
|
+
};
|
|
242
|
+
const bundlerActions = (client) => ({
|
|
243
|
+
sendUserOperation: async (args) => sendUserOperation(client, args),
|
|
244
|
+
estimateUserOperationGas: (args) => estimateUserOperationGas(client, args),
|
|
245
|
+
supportedEntryPoints: () => supportedEntryPoints(client),
|
|
246
|
+
chainId: () => chainId(client),
|
|
247
|
+
getUserOperationByHash: (args) => getUserOperationByHash(client, args),
|
|
248
|
+
getUserOperationReceipt: (args) => getUserOperationReceipt(client, args)
|
|
249
|
+
});
|
|
250
|
+
export default bundlerActions;
|
|
251
|
+
//# sourceMappingURL=bundler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundler.js","sourceRoot":"","sources":["../../actions/bundler.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAmE/D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,MAAqB,EAAE,IAAiC,EAAiB,EAAE;IAC/G,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,IAAI,CAAA;IAE1C,OAAO,MAAM,CAAC,OAAO,CAAC;QAClB,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,WAAW,CAAC,aAAa,CAAiC,EAAE,UAAqB,CAAC;KAC9F,CAAC,CAAA;AACN,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,EACzC,MAAqB,EACrB,IAAwC,EACG,EAAE;IAC7C,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,IAAI,CAA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AAC,MAAM;SACrB,CAAC,CAAC;KACN,CAAA;IAED,OAAO,oBAAoB,CAAA;AAC/B,CAAC,CAAA;AAgJD,MAAM,cAAc,GAAG,CAAC,MAAc,EAAkB,EAAE,CAAC,CAAC;IACxD,iBAAiB,EAAE,KAAK,EAAE,IAAiC,EAAiB,EAAE,CAC1E,iBAAiB,CAAC,MAAuB,EAAE,IAAI,CAAC;IACpD,wBAAwB,EAAE,CAAC,IAAwC,EAAE,EAAE,CACnE,wBAAwB,CAAC,MAAuB,EAAE,IAAI,CAAC;IAC3D,oBAAoB,EAAE,GAAuB,EAAE,CAAC,oBAAoB,CAAC,MAAuB,CAAC;IAC7F,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAuB,CAAC;IAC/C,sBAAsB,EAAE,CAAC,IAAsC,EAAE,EAAE,CAC/D,sBAAsB,CAAC,MAAuB,EAAE,IAAI,CAAC;IACzD,uBAAuB,EAAE,CAAC,IAAuC,EAAE,EAAE,CACjE,uBAAuB,CAAC,MAAuB,EAAE,IAAI,CAAC;CAC7D,CAAC,CAAA;AAEF,eAAe,cAAc,CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import bundlerActions, { chainId, estimateUserOperationGas, getUserOperationByHash, getUserOperationReceipt, sendUserOperation, supportedEntryPoints } from "./bundler";
|
|
2
|
+
export { bundlerActions, sendUserOperation, estimateUserOperationGas, supportedEntryPoints, chainId, getUserOperationByHash, getUserOperationReceipt };
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../actions/index.ts"],"names":[],"mappings":"AAUA,OAAO,cAAc,EAAE,EACnB,OAAO,EACP,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,oBAAoB,EACvB,MAAM,WAAW,CAAA;AAYlB,OAAO,EACH,cAAc,EACd,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,OAAO,EACP,sBAAsB,EACtB,uBAAuB,EAC1B,CAAA"}
|