permissionless 0.0.12 → 0.0.14
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 +18 -0
- package/_cjs/accounts/index.js +11 -2
- package/_cjs/accounts/index.js.map +1 -1
- package/_cjs/accounts/kernel/abi/KernelAccountAbi.js +84 -0
- package/_cjs/accounts/kernel/abi/KernelAccountAbi.js.map +1 -0
- package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js +211 -0
- package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -0
- package/_cjs/accounts/privateKeyToSafeSmartAccount.js +24 -0
- package/_cjs/accounts/privateKeyToSafeSmartAccount.js.map +1 -0
- package/_cjs/accounts/privateKeyToSimpleSmartAccount.js +8 -160
- package/_cjs/accounts/privateKeyToSimpleSmartAccount.js.map +1 -1
- 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 +20 -0
- package/_cjs/accounts/types.js.map +1 -1
- package/_cjs/actions/bundler/chainId.js.map +1 -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.map +1 -1
- package/_cjs/actions/bundler/supportedEntryPoints.js.map +1 -1
- package/_cjs/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
- package/_cjs/actions/pimlico/sponsorUserOperation.js +12 -4
- package/_cjs/actions/pimlico/sponsorUserOperation.js.map +1 -1
- package/_cjs/actions/smartAccount/prepareUserOperationRequest.js +3 -1
- package/_cjs/actions/smartAccount/prepareUserOperationRequest.js.map +1 -1
- package/_cjs/actions/smartAccount/sendTransaction.js +3 -2
- package/_cjs/actions/smartAccount/sendTransaction.js.map +1 -1
- package/_cjs/actions/smartAccount/sendTransactions.js +46 -0
- package/_cjs/actions/smartAccount/sendTransactions.js.map +1 -0
- package/_cjs/actions/smartAccount.js +3 -1
- package/_cjs/actions/smartAccount.js.map +1 -1
- package/_cjs/clients/createSmartAccountClient.js.map +1 -1
- package/_cjs/clients/decorators/pimlico.js.map +1 -1
- package/_cjs/clients/decorators/smartAccount.js +5 -0
- package/_cjs/clients/decorators/smartAccount.js.map +1 -1
- package/_esm/accounts/index.js +7 -3
- package/_esm/accounts/index.js.map +1 -1
- package/_esm/accounts/kernel/abi/KernelAccountAbi.js +87 -0
- package/_esm/accounts/kernel/abi/KernelAccountAbi.js.map +1 -0
- package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js +262 -0
- package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -0
- package/_esm/accounts/privateKeyToSafeSmartAccount.js +26 -0
- package/_esm/accounts/privateKeyToSafeSmartAccount.js.map +1 -0
- package/_esm/accounts/privateKeyToSimpleSmartAccount.js +9 -160
- package/_esm/accounts/privateKeyToSimpleSmartAccount.js.map +1 -1
- 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 +18 -0
- package/_esm/accounts/types.js.map +1 -1
- package/_esm/actions/bundler/chainId.js.map +1 -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.map +1 -1
- package/_esm/actions/bundler/supportedEntryPoints.js.map +1 -1
- package/_esm/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
- package/_esm/actions/pimlico/getUserOperationGasPrice.js +1 -1
- package/_esm/actions/pimlico/getUserOperationStatus.js +1 -1
- package/_esm/actions/pimlico/sponsorUserOperation.js +13 -5
- package/_esm/actions/pimlico/sponsorUserOperation.js.map +1 -1
- package/_esm/actions/smartAccount/prepareUserOperationRequest.js +3 -1
- package/_esm/actions/smartAccount/prepareUserOperationRequest.js.map +1 -1
- package/_esm/actions/smartAccount/sendTransaction.js +3 -2
- package/_esm/actions/smartAccount/sendTransaction.js.map +1 -1
- package/_esm/actions/smartAccount/sendTransactions.js +90 -0
- package/_esm/actions/smartAccount/sendTransactions.js.map +1 -0
- package/_esm/actions/smartAccount.js +2 -1
- package/_esm/actions/smartAccount.js.map +1 -1
- package/_esm/actions/stackup/accounts.js +1 -1
- package/_esm/actions/stackup/sponsorUserOperation.js +1 -1
- package/_esm/clients/createSmartAccountClient.js +1 -1
- package/_esm/clients/createSmartAccountClient.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 +5 -0
- package/_esm/clients/decorators/smartAccount.js.map +1 -1
- package/_esm/clients/pimlico.js +1 -1
- package/_esm/clients/stackup.js +1 -1
- package/_types/accounts/index.d.ts +7 -3
- package/_types/accounts/index.d.ts.map +1 -1
- package/_types/accounts/kernel/abi/KernelAccountAbi.d.ts +68 -0
- package/_types/accounts/kernel/abi/KernelAccountAbi.d.ts.map +1 -0
- package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.d.ts +25 -0
- package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.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 +5 -11
- package/_types/accounts/privateKeyToSimpleSmartAccount.d.ts.map +1 -1
- 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 +14 -3
- package/_types/accounts/types.d.ts.map +1 -1
- 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 -3
- 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/pimlico/getUserOperationGasPrice.d.ts +1 -1
- package/_types/actions/pimlico/getUserOperationStatus.d.ts +1 -1
- package/_types/actions/pimlico/sponsorUserOperation.d.ts +4 -3
- package/_types/actions/pimlico/sponsorUserOperation.d.ts.map +1 -1
- package/_types/actions/pimlico.d.ts +2 -2
- package/_types/actions/pimlico.d.ts.map +1 -1
- package/_types/actions/smartAccount/prepareUserOperationRequest.d.ts.map +1 -1
- package/_types/actions/smartAccount/sendTransaction.d.ts.map +1 -1
- package/_types/actions/smartAccount/sendTransactions.d.ts +63 -0
- package/_types/actions/smartAccount/sendTransactions.d.ts.map +1 -0
- package/_types/actions/smartAccount.d.ts +2 -1
- package/_types/actions/smartAccount.d.ts.map +1 -1
- package/_types/actions/stackup/accounts.d.ts +1 -1
- package/_types/actions/stackup/sponsorUserOperation.d.ts +1 -1
- package/_types/clients/createSmartAccountClient.d.ts +7 -1
- package/_types/clients/createSmartAccountClient.d.ts.map +1 -1
- package/_types/clients/decorators/bundler.d.ts +1 -1
- package/_types/clients/decorators/pimlico.d.ts +6 -6
- package/_types/clients/decorators/pimlico.d.ts.map +1 -1
- package/_types/clients/decorators/smartAccount.d.ts +51 -0
- package/_types/clients/decorators/smartAccount.d.ts.map +1 -1
- package/_types/clients/pimlico.d.ts +1 -1
- package/_types/clients/stackup.d.ts +1 -1
- package/_types/types/index.d.ts +1 -0
- package/_types/types/index.d.ts.map +1 -1
- package/_types/types/pimlico.d.ts +4 -1
- package/_types/types/pimlico.d.ts.map +1 -1
- package/accounts/index.ts +33 -7
- package/accounts/kernel/abi/KernelAccountAbi.ts +87 -0
- package/accounts/kernel/signerToEcdsaKernelSmartAccount.ts +363 -0
- package/accounts/privateKeyToSafeSmartAccount.ts +73 -0
- package/accounts/privateKeyToSimpleSmartAccount.ts +15 -191
- package/accounts/signerToSafeSmartAccount.ts +775 -0
- package/accounts/signerToSimpleSmartAccount.ts +267 -0
- package/accounts/types.ts +43 -12
- package/actions/bundler/chainId.ts +9 -1
- package/actions/bundler/estimateUserOperationGas.ts +8 -3
- package/actions/bundler/getUserOperationByHash.ts +8 -3
- package/actions/bundler/getUserOperationReceipt.ts +16 -3
- package/actions/bundler/sendUserOperation.ts +8 -3
- package/actions/bundler/supportedEntryPoints.ts +8 -3
- package/actions/bundler/waitForUserOperationReceipt.ts +15 -4
- package/actions/pimlico/getUserOperationGasPrice.ts +1 -1
- package/actions/pimlico/getUserOperationStatus.ts +1 -1
- package/actions/pimlico/sponsorUserOperation.ts +20 -7
- package/actions/pimlico.ts +2 -2
- package/actions/smartAccount/prepareUserOperationRequest.ts +3 -1
- package/actions/smartAccount/sendTransaction.ts +3 -1
- package/actions/smartAccount/sendTransactions.ts +141 -0
- package/actions/smartAccount.ts +8 -1
- package/actions/stackup/accounts.ts +1 -1
- package/actions/stackup/sponsorUserOperation.ts +1 -1
- package/clients/createSmartAccountClient.ts +6 -1
- package/clients/decorators/bundler.ts +1 -1
- package/clients/decorators/pimlico.ts +7 -7
- package/clients/decorators/smartAccount.ts +61 -0
- package/clients/pimlico.ts +1 -1
- package/clients/stackup.ts +1 -1
- package/package.json +2 -2
- package/types/index.ts +5 -0
- package/types/pimlico.ts +4 -1
- package/tsconfig.build.tsbuildinfo +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# permissionless
|
|
2
2
|
|
|
3
|
+
## 0.0.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4d6f01f: Add sponsorship policies option to pimlicoPaymasterClient
|
|
8
|
+
Update Safe 4337 module version to 0.2.0
|
|
9
|
+
- 5fe172d: Introduce a simpel version of Kernel SmartAccount (by ZeroDev), using their ECDSA Validator
|
|
10
|
+
|
|
11
|
+
## 0.0.13
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 69a7b4b: Added support to enable extra modules and transactions during setup for Safe account
|
|
16
|
+
- 639775d: Added support for passing in custom signers
|
|
17
|
+
- 0254c24: Enable batch calls for Safe account
|
|
18
|
+
- b95e9e5: Enable setting custom nonce for user operations
|
|
19
|
+
- 39164f7: Added support for Safe account management
|
|
20
|
+
|
|
3
21
|
## 0.0.12
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/_cjs/accounts/index.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.privateKeyToSimpleSmartAccount = exports.SignTransactionNotSupportedBySmartAccount = void 0;
|
|
3
|
+
exports.signerToEcdsaKernelSmartAccount = exports.privateKeyToSafeSmartAccount = exports.privateKeyToSimpleSmartAccount = exports.SignTransactionNotSupportedBySmartAccount = exports.signerToSimpleSmartAccount = exports.signerToSafeSmartAccount = void 0;
|
|
4
4
|
const privateKeyToSimpleSmartAccount_js_1 = require("./privateKeyToSimpleSmartAccount.js");
|
|
5
|
-
Object.defineProperty(exports, "SignTransactionNotSupportedBySmartAccount", { enumerable: true, get: function () { return privateKeyToSimpleSmartAccount_js_1.SignTransactionNotSupportedBySmartAccount; } });
|
|
6
5
|
Object.defineProperty(exports, "privateKeyToSimpleSmartAccount", { enumerable: true, get: function () { return privateKeyToSimpleSmartAccount_js_1.privateKeyToSimpleSmartAccount; } });
|
|
6
|
+
const signerToSimpleSmartAccount_js_1 = require("./signerToSimpleSmartAccount.js");
|
|
7
|
+
Object.defineProperty(exports, "signerToSimpleSmartAccount", { enumerable: true, get: function () { return signerToSimpleSmartAccount_js_1.signerToSimpleSmartAccount; } });
|
|
8
|
+
const privateKeyToSafeSmartAccount_js_1 = require("./privateKeyToSafeSmartAccount.js");
|
|
9
|
+
Object.defineProperty(exports, "privateKeyToSafeSmartAccount", { enumerable: true, get: function () { return privateKeyToSafeSmartAccount_js_1.privateKeyToSafeSmartAccount; } });
|
|
10
|
+
const signerToSafeSmartAccount_js_1 = require("./signerToSafeSmartAccount.js");
|
|
11
|
+
Object.defineProperty(exports, "signerToSafeSmartAccount", { enumerable: true, get: function () { return signerToSafeSmartAccount_js_1.signerToSafeSmartAccount; } });
|
|
12
|
+
const signerToEcdsaKernelSmartAccount_js_1 = require("./kernel/signerToEcdsaKernelSmartAccount.js");
|
|
13
|
+
Object.defineProperty(exports, "signerToEcdsaKernelSmartAccount", { enumerable: true, get: function () { return signerToEcdsaKernelSmartAccount_js_1.signerToEcdsaKernelSmartAccount; } });
|
|
14
|
+
const types_js_1 = require("./types.js");
|
|
15
|
+
Object.defineProperty(exports, "SignTransactionNotSupportedBySmartAccount", { enumerable: true, get: function () { return types_js_1.SignTransactionNotSupportedBySmartAccount; } });
|
|
7
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":";;;AAAA,2FAAoF;AAkChF,+GAlCK,kEAA8B,OAkCL;AAhClC,mFAGwC;AA2BpC,2GA5BA,0DAA0B,OA4BA;AAzB9B,uFAAgF;AA6B5E,6GA7BK,8DAA4B,OA6BL;AA3BhC,+EAIsC;AAiBlC,yGAlBA,sDAAwB,OAkBA;AAf5B,oGAGoD;AAoBhD,gHArBA,oEAA+B,OAqBA;AAlBnC,yCAImB;AASf,0HAZA,oDAAyC,OAYA"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KernelInitAbi = exports.KernelExecuteAbi = void 0;
|
|
4
|
+
exports.KernelExecuteAbi = [
|
|
5
|
+
{
|
|
6
|
+
inputs: [
|
|
7
|
+
{
|
|
8
|
+
internalType: "address",
|
|
9
|
+
name: "to",
|
|
10
|
+
type: "address"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
internalType: "uint256",
|
|
14
|
+
name: "value",
|
|
15
|
+
type: "uint256"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
internalType: "bytes",
|
|
19
|
+
name: "data",
|
|
20
|
+
type: "bytes"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
internalType: "enum Operation",
|
|
24
|
+
name: "",
|
|
25
|
+
type: "uint8"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
name: "execute",
|
|
29
|
+
outputs: [],
|
|
30
|
+
stateMutability: "payable",
|
|
31
|
+
type: "function"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
inputs: [
|
|
35
|
+
{
|
|
36
|
+
components: [
|
|
37
|
+
{
|
|
38
|
+
internalType: "address",
|
|
39
|
+
name: "to",
|
|
40
|
+
type: "address"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
internalType: "uint256",
|
|
44
|
+
name: "value",
|
|
45
|
+
type: "uint256"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
internalType: "bytes",
|
|
49
|
+
name: "data",
|
|
50
|
+
type: "bytes"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
internalType: "struct Call[]",
|
|
54
|
+
name: "calls",
|
|
55
|
+
type: "tuple[]"
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
name: "executeBatch",
|
|
59
|
+
outputs: [],
|
|
60
|
+
stateMutability: "payable",
|
|
61
|
+
type: "function"
|
|
62
|
+
}
|
|
63
|
+
];
|
|
64
|
+
exports.KernelInitAbi = [
|
|
65
|
+
{
|
|
66
|
+
inputs: [
|
|
67
|
+
{
|
|
68
|
+
internalType: "contract IKernelValidator",
|
|
69
|
+
name: "_defaultValidator",
|
|
70
|
+
type: "address"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
internalType: "bytes",
|
|
74
|
+
name: "_data",
|
|
75
|
+
type: "bytes"
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
name: "initialize",
|
|
79
|
+
outputs: [],
|
|
80
|
+
stateMutability: "payable",
|
|
81
|
+
type: "function"
|
|
82
|
+
}
|
|
83
|
+
];
|
|
84
|
+
//# sourceMappingURL=KernelAccountAbi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KernelAccountAbi.js","sourceRoot":"","sources":["../../../../accounts/kernel/abi/KernelAccountAbi.ts"],"names":[],"mappings":";;;AAGa,QAAA,gBAAgB,GAAG;IAC5B;QACI,MAAM,EAAE;YACJ;gBACI,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,SAAS;aAClB;YACD;gBACI,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,SAAS;aAClB;YACD;gBACI,YAAY,EAAE,OAAO;gBACrB,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,OAAO;aAChB;YACD;gBACI,YAAY,EAAE,gBAAgB;gBAC9B,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,OAAO;aAChB;SACJ;QACD,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,SAAS;QAC1B,IAAI,EAAE,UAAU;KACnB;IACD;QACI,MAAM,EAAE;YACJ;gBACI,UAAU,EAAE;oBACR;wBACI,YAAY,EAAE,SAAS;wBACvB,IAAI,EAAE,IAAI;wBACV,IAAI,EAAE,SAAS;qBAClB;oBACD;wBACI,YAAY,EAAE,SAAS;wBACvB,IAAI,EAAE,OAAO;wBACb,IAAI,EAAE,SAAS;qBAClB;oBACD;wBACI,YAAY,EAAE,OAAO;wBACrB,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,OAAO;qBAChB;iBACJ;gBACD,YAAY,EAAE,eAAe;gBAC7B,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,SAAS;aAClB;SACJ;QACD,IAAI,EAAE,cAAc;QACpB,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,SAAS;QAC1B,IAAI,EAAE,UAAU;KACnB;CACK,CAAA;AAKG,QAAA,aAAa,GAAG;IACzB;QACI,MAAM,EAAE;YACJ;gBACI,YAAY,EAAE,2BAA2B;gBACzC,IAAI,EAAE,mBAAmB;gBACzB,IAAI,EAAE,SAAS;aAClB;YACD;gBACI,YAAY,EAAE,OAAO;gBACrB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,OAAO;aAChB;SACJ;QACD,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,SAAS;QAC1B,IAAI,EAAE,UAAU;KACnB;CACK,CAAA"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signerToEcdsaKernelSmartAccount = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const accounts_1 = require("viem/accounts");
|
|
6
|
+
const actions_1 = require("viem/actions");
|
|
7
|
+
const getAccountNonce_js_1 = require("../../actions/public/getAccountNonce.js");
|
|
8
|
+
const getSenderAddress_js_1 = require("../../actions/public/getSenderAddress.js");
|
|
9
|
+
const getUserOperationHash_js_1 = require("../../utils/getUserOperationHash.js");
|
|
10
|
+
const types_js_1 = require("../types.js");
|
|
11
|
+
const KernelAccountAbi_js_1 = require("./abi/KernelAccountAbi.js");
|
|
12
|
+
const createAccountAbi = [
|
|
13
|
+
{
|
|
14
|
+
inputs: [
|
|
15
|
+
{
|
|
16
|
+
internalType: "address",
|
|
17
|
+
name: "_implementation",
|
|
18
|
+
type: "address"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
internalType: "bytes",
|
|
22
|
+
name: "_data",
|
|
23
|
+
type: "bytes"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
internalType: "uint256",
|
|
27
|
+
name: "_index",
|
|
28
|
+
type: "uint256"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
name: "createAccount",
|
|
32
|
+
outputs: [
|
|
33
|
+
{
|
|
34
|
+
internalType: "address",
|
|
35
|
+
name: "proxy",
|
|
36
|
+
type: "address"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
stateMutability: "payable",
|
|
40
|
+
type: "function"
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
const KERNEL_ADDRESSES = {
|
|
44
|
+
ECDSA_VALIDATOR: "0xd9AB5096a832b9ce79914329DAEE236f8Eea0390",
|
|
45
|
+
ACCOUNT_V2_2_LOGIC: "0x0DA6a956B9488eD4dd761E59f52FDc6c8068E6B5",
|
|
46
|
+
FACTORY_ADDRESS: "0x5de4839a76cf55d0c90e2061ef4386d962E15ae3"
|
|
47
|
+
};
|
|
48
|
+
const getAccountInitCode = async ({ owner, index, factoryAddress, accountLogicAddress, ecdsaValidatorAddress }) => {
|
|
49
|
+
if (!owner)
|
|
50
|
+
throw new Error("Owner account not found");
|
|
51
|
+
const initialisationData = (0, viem_1.encodeFunctionData)({
|
|
52
|
+
abi: KernelAccountAbi_js_1.KernelInitAbi,
|
|
53
|
+
functionName: "initialize",
|
|
54
|
+
args: [ecdsaValidatorAddress, owner]
|
|
55
|
+
});
|
|
56
|
+
return (0, viem_1.concatHex)([
|
|
57
|
+
factoryAddress,
|
|
58
|
+
(0, viem_1.encodeFunctionData)({
|
|
59
|
+
abi: createAccountAbi,
|
|
60
|
+
functionName: "createAccount",
|
|
61
|
+
args: [accountLogicAddress, initialisationData, index]
|
|
62
|
+
})
|
|
63
|
+
]);
|
|
64
|
+
};
|
|
65
|
+
const getAccountAddress = async ({ client, owner, entryPoint, initCodeProvider, ecdsaValidatorAddress, deployedAccountAddress }) => {
|
|
66
|
+
if (deployedAccountAddress !== undefined) {
|
|
67
|
+
const deployedAccountOwner = await (0, actions_1.readContract)(client, {
|
|
68
|
+
address: ecdsaValidatorAddress,
|
|
69
|
+
abi: [
|
|
70
|
+
{
|
|
71
|
+
inputs: [
|
|
72
|
+
{
|
|
73
|
+
internalType: "address",
|
|
74
|
+
name: "",
|
|
75
|
+
type: "address"
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
name: "ecdsaValidatorStorage",
|
|
79
|
+
outputs: [
|
|
80
|
+
{
|
|
81
|
+
internalType: "address",
|
|
82
|
+
name: "owner",
|
|
83
|
+
type: "address"
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
stateMutability: "view",
|
|
87
|
+
type: "function"
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
functionName: "ecdsaValidatorStorage",
|
|
91
|
+
args: [deployedAccountAddress]
|
|
92
|
+
});
|
|
93
|
+
if (!(0, viem_1.isAddressEqual)(deployedAccountOwner, owner)) {
|
|
94
|
+
throw new Error("Invalid owner for the already deployed account");
|
|
95
|
+
}
|
|
96
|
+
return deployedAccountAddress;
|
|
97
|
+
}
|
|
98
|
+
const initCode = await initCodeProvider();
|
|
99
|
+
return (0, getSenderAddress_js_1.getSenderAddress)(client, {
|
|
100
|
+
initCode,
|
|
101
|
+
entryPoint
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
async function signerToEcdsaKernelSmartAccount(client, { signer, entryPoint, index = 0n, factoryAddress = KERNEL_ADDRESSES.FACTORY_ADDRESS, accountLogicAddress = KERNEL_ADDRESSES.ACCOUNT_V2_2_LOGIC, ecdsaValidatorAddress = KERNEL_ADDRESSES.ECDSA_VALIDATOR, deployedAccountAddress }) {
|
|
105
|
+
const viemSigner = signer.type === "local"
|
|
106
|
+
? {
|
|
107
|
+
...signer,
|
|
108
|
+
signTransaction: (_, __) => {
|
|
109
|
+
throw new types_js_1.SignTransactionNotSupportedBySmartAccount();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
: signer;
|
|
113
|
+
const generateInitCode = () => getAccountInitCode({
|
|
114
|
+
owner: viemSigner.address,
|
|
115
|
+
index,
|
|
116
|
+
factoryAddress,
|
|
117
|
+
accountLogicAddress,
|
|
118
|
+
ecdsaValidatorAddress
|
|
119
|
+
});
|
|
120
|
+
const [accountAddress, chainId] = await Promise.all([
|
|
121
|
+
getAccountAddress({
|
|
122
|
+
client,
|
|
123
|
+
entryPoint,
|
|
124
|
+
owner: viemSigner.address,
|
|
125
|
+
ecdsaValidatorAddress,
|
|
126
|
+
initCodeProvider: generateInitCode,
|
|
127
|
+
deployedAccountAddress
|
|
128
|
+
}),
|
|
129
|
+
(0, actions_1.getChainId)(client)
|
|
130
|
+
]);
|
|
131
|
+
if (!accountAddress)
|
|
132
|
+
throw new Error("Account address not found");
|
|
133
|
+
const account = (0, accounts_1.toAccount)({
|
|
134
|
+
address: accountAddress,
|
|
135
|
+
async signMessage({ message }) {
|
|
136
|
+
return (0, actions_1.signMessage)(client, { account: viemSigner, message });
|
|
137
|
+
},
|
|
138
|
+
async signTransaction(_, __) {
|
|
139
|
+
throw new types_js_1.SignTransactionNotSupportedBySmartAccount();
|
|
140
|
+
},
|
|
141
|
+
async signTypedData(typedData) {
|
|
142
|
+
return (0, actions_1.signTypedData)(client, { account: viemSigner, ...typedData });
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return {
|
|
146
|
+
...account,
|
|
147
|
+
client: client,
|
|
148
|
+
publicKey: accountAddress,
|
|
149
|
+
entryPoint: entryPoint,
|
|
150
|
+
source: "kernelEcdsaSmartAccount",
|
|
151
|
+
async getNonce() {
|
|
152
|
+
return (0, getAccountNonce_js_1.getAccountNonce)(client, {
|
|
153
|
+
sender: accountAddress,
|
|
154
|
+
entryPoint: entryPoint
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
async signUserOperation(userOperation) {
|
|
158
|
+
const hash = (0, getUserOperationHash_js_1.getUserOperationHash)({
|
|
159
|
+
userOperation: {
|
|
160
|
+
...userOperation,
|
|
161
|
+
signature: "0x"
|
|
162
|
+
},
|
|
163
|
+
entryPoint: entryPoint,
|
|
164
|
+
chainId: chainId
|
|
165
|
+
});
|
|
166
|
+
const signature = await (0, actions_1.signMessage)(client, {
|
|
167
|
+
account: viemSigner,
|
|
168
|
+
message: { raw: hash }
|
|
169
|
+
});
|
|
170
|
+
return (0, viem_1.concatHex)(["0x00000000", signature]);
|
|
171
|
+
},
|
|
172
|
+
async getInitCode() {
|
|
173
|
+
const contractCode = await (0, actions_1.getBytecode)(client, {
|
|
174
|
+
address: accountAddress
|
|
175
|
+
});
|
|
176
|
+
if ((contractCode?.length ?? 0) > 2)
|
|
177
|
+
return "0x";
|
|
178
|
+
return generateInitCode();
|
|
179
|
+
},
|
|
180
|
+
async encodeDeployCallData(_) {
|
|
181
|
+
throw new Error("Simple account doesn't support account deployment");
|
|
182
|
+
},
|
|
183
|
+
async encodeCallData(_tx) {
|
|
184
|
+
if (Array.isArray(_tx)) {
|
|
185
|
+
return (0, viem_1.encodeFunctionData)({
|
|
186
|
+
abi: KernelAccountAbi_js_1.KernelExecuteAbi,
|
|
187
|
+
functionName: "executeBatch",
|
|
188
|
+
args: [
|
|
189
|
+
_tx.map((tx) => ({
|
|
190
|
+
to: tx.to,
|
|
191
|
+
value: tx.value,
|
|
192
|
+
data: tx.data
|
|
193
|
+
}))
|
|
194
|
+
]
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
return (0, viem_1.encodeFunctionData)({
|
|
199
|
+
abi: KernelAccountAbi_js_1.KernelExecuteAbi,
|
|
200
|
+
functionName: "execute",
|
|
201
|
+
args: [_tx.to, _tx.value, _tx.data, 0]
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
async getDummySignature() {
|
|
206
|
+
return "0x00000000fffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
exports.signerToEcdsaKernelSmartAccount = signerToEcdsaKernelSmartAccount;
|
|
211
|
+
//# sourceMappingURL=signerToEcdsaKernelSmartAccount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signerToEcdsaKernelSmartAccount.js","sourceRoot":"","sources":["../../../accounts/kernel/signerToEcdsaKernelSmartAccount.ts"],"names":[],"mappings":";;;AAAA,+BAUa;AACb,4CAAyC;AACzC,0CAMqB;AACrB,gFAAyE;AACzE,kFAA2E;AAC3E,iFAA0E;AAE1E,0CAGoB;AACpB,mEAA2E;AAU3E,MAAM,gBAAgB,GAAG;IACrB;QACI,MAAM,EAAE;YACJ;gBACI,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,iBAAiB;gBACvB,IAAI,EAAE,SAAS;aAClB;YACD;gBACI,YAAY,EAAE,OAAO;gBACrB,IAAI,EAAE,OAAO;g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AK,EAAE,EAAE,CAAC,KAAK;4BACf,IAAI,EAAE,EAAE,CAAC,IAAI;yBAChB,CAAC,CAAC;qBACN;iBACJ,CAAC,CAAA;aACL;iBAAM;gBAEH,OAAO,IAAA,yBAAkB,EAAC;oBACtB,GAAG,EAAE,sCAAgB;oBACrB,YAAY,EAAE,SAAS;oBACvB,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;iBACzC,CAAC,CAAA;aACL;QACL,CAAC;QAGD,KAAK,CAAC,iBAAiB;YACnB,OAAO,8IAA8I,CAAA;QACzJ,CAAC;KACJ,CAAA;AACL,CAAC;AAxJD,0EAwJC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.privateKeyToSafeSmartAccount = void 0;
|
|
4
|
+
const accounts_1 = require("viem/accounts");
|
|
5
|
+
const signerToSafeSmartAccount_js_1 = require("./signerToSafeSmartAccount.js");
|
|
6
|
+
async function privateKeyToSafeSmartAccount(client, { privateKey, safeVersion, entryPoint, addModuleLibAddress: _addModuleLibAddress, safe4337ModuleAddress: _safe4337ModuleAddress, safeProxyFactoryAddress: _safeProxyFactoryAddress, safeSingletonAddress: _safeSingletonAddress, multiSendAddress: _multiSendAddress, multiSendCallOnlyAddress: _multiSendCallOnlyAddress, saltNonce = 0n, safeModules = [], setupTransactions = [] }) {
|
|
7
|
+
const privateKeyAccount = (0, accounts_1.privateKeyToAccount)(privateKey);
|
|
8
|
+
return (0, signerToSafeSmartAccount_js_1.signerToSafeSmartAccount)(client, {
|
|
9
|
+
signer: privateKeyAccount,
|
|
10
|
+
safeVersion,
|
|
11
|
+
entryPoint,
|
|
12
|
+
addModuleLibAddress: _addModuleLibAddress,
|
|
13
|
+
safe4337ModuleAddress: _safe4337ModuleAddress,
|
|
14
|
+
safeProxyFactoryAddress: _safeProxyFactoryAddress,
|
|
15
|
+
safeSingletonAddress: _safeSingletonAddress,
|
|
16
|
+
multiSendAddress: _multiSendAddress,
|
|
17
|
+
multiSendCallOnlyAddress: _multiSendCallOnlyAddress,
|
|
18
|
+
saltNonce,
|
|
19
|
+
safeModules,
|
|
20
|
+
setupTransactions
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
exports.privateKeyToSafeSmartAccount = privateKeyToSafeSmartAccount;
|
|
24
|
+
//# sourceMappingURL=privateKeyToSafeSmartAccount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privateKeyToSafeSmartAccount.js","sourceRoot":"","sources":["../../accounts/privateKeyToSafeSmartAccount.ts"],"names":[],"mappings":";;;AAOA,4CAAmD;AACnD,+EAIsC;AAO/B,KAAK,UAAU,4BAA4B,CAI9C,MAAkC,EAClC,EACI,UAAU,EACV,WAAW,EACX,UAAU,EACV,mBAAmB,EAAE,oBAAoB,EACzC,qBAAqB,EAAE,sBAAsB,EAC7C,uBAAuB,EAAE,wBAAwB,EACjD,oBAAoB,EAAE,qBAAqB,EAC3C,gBAAgB,EAAE,iBAAiB,EACnC,wBAAwB,EAAE,yBAAyB,EACnD,SAAS,GAAG,EAAE,EACd,WAAW,GAAG,EAAE,EAChB,iBAAiB,GAAG,EAAE,EAkBzB;IAED,MAAM,iBAAiB,GAAG,IAAA,8BAAmB,EAAC,UAAU,CAAC,CAAA;IAEzD,OAAO,IAAA,sDAAwB,EAAC,MAAM,EAAE;QACpC,MAAM,EAAE,iBAAiB;QACzB,WAAW;QACX,UAAU;QACV,mBAAmB,EAAE,oBAAoB;QACzC,qBAAqB,EAAE,sBAAsB;QAC7C,uBAAuB,EAAE,wBAAwB;QACjD,oBAAoB,EAAE,qBAAqB;QAC3C,gBAAgB,EAAE,iBAAiB;QACnC,wBAAwB,EAAE,yBAAyB;QACnD,SAAS;QACT,WAAW;QACX,iBAAiB;KACpB,CAAC,CAAA;AACN,CAAC;AArDD,oEAqDC"}
|
|
@@ -1,168 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.privateKeyToSimpleSmartAccount =
|
|
4
|
-
const viem_1 = require("viem");
|
|
3
|
+
exports.privateKeyToSimpleSmartAccount = void 0;
|
|
5
4
|
const accounts_1 = require("viem/accounts");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const getSenderAddress_js_1 = require("../actions/public/getSenderAddress.js");
|
|
9
|
-
const getUserOperationHash_js_1 = require("../utils/getUserOperationHash.js");
|
|
10
|
-
class SignTransactionNotSupportedBySmartAccount extends viem_1.BaseError {
|
|
11
|
-
constructor({ docsPath } = {}) {
|
|
12
|
-
super([
|
|
13
|
-
"A smart account cannot sign or send transaction, it can only sign message or userOperation.",
|
|
14
|
-
"Please send user operation instead."
|
|
15
|
-
].join("\n"), {
|
|
16
|
-
docsPath,
|
|
17
|
-
docsSlug: "account"
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(this, "name", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
configurable: true,
|
|
22
|
-
writable: true,
|
|
23
|
-
value: "SignTransactionNotSupportedBySmartAccount"
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.SignTransactionNotSupportedBySmartAccount = SignTransactionNotSupportedBySmartAccount;
|
|
28
|
-
const getAccountInitCode = async (factoryAddress, owner, index = 0n) => {
|
|
29
|
-
if (!owner)
|
|
30
|
-
throw new Error("Owner account not found");
|
|
31
|
-
return (0, viem_1.concatHex)([
|
|
32
|
-
factoryAddress,
|
|
33
|
-
(0, viem_1.encodeFunctionData)({
|
|
34
|
-
abi: [
|
|
35
|
-
{
|
|
36
|
-
inputs: [
|
|
37
|
-
{
|
|
38
|
-
internalType: "address",
|
|
39
|
-
name: "owner",
|
|
40
|
-
type: "address"
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
internalType: "uint256",
|
|
44
|
-
name: "salt",
|
|
45
|
-
type: "uint256"
|
|
46
|
-
}
|
|
47
|
-
],
|
|
48
|
-
name: "createAccount",
|
|
49
|
-
outputs: [
|
|
50
|
-
{
|
|
51
|
-
internalType: "contract SimpleAccount",
|
|
52
|
-
name: "ret",
|
|
53
|
-
type: "address"
|
|
54
|
-
}
|
|
55
|
-
],
|
|
56
|
-
stateMutability: "nonpayable",
|
|
57
|
-
type: "function"
|
|
58
|
-
}
|
|
59
|
-
],
|
|
60
|
-
functionName: "createAccount",
|
|
61
|
-
args: [owner, index]
|
|
62
|
-
})
|
|
63
|
-
]);
|
|
64
|
-
};
|
|
65
|
-
const getAccountAddress = async ({ client, factoryAddress, entryPoint, owner }) => {
|
|
66
|
-
const initCode = await getAccountInitCode(factoryAddress, owner);
|
|
67
|
-
return (0, getSenderAddress_js_1.getSenderAddress)(client, {
|
|
68
|
-
initCode,
|
|
69
|
-
entryPoint
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
async function privateKeyToSimpleSmartAccount(client, { privateKey, factoryAddress, entryPoint }) {
|
|
5
|
+
const signerToSimpleSmartAccount_js_1 = require("./signerToSimpleSmartAccount.js");
|
|
6
|
+
async function privateKeyToSimpleSmartAccount(client, { privateKey, factoryAddress, entryPoint, index = 0n }) {
|
|
73
7
|
const privateKeyAccount = (0, accounts_1.privateKeyToAccount)(privateKey);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
owner: privateKeyAccount.address
|
|
80
|
-
}),
|
|
81
|
-
(0, actions_1.getChainId)(client)
|
|
82
|
-
]);
|
|
83
|
-
if (!accountAddress)
|
|
84
|
-
throw new Error("Account address not found");
|
|
85
|
-
const account = (0, accounts_1.toAccount)({
|
|
86
|
-
address: accountAddress,
|
|
87
|
-
async signMessage({ message }) {
|
|
88
|
-
return privateKeyAccount.signMessage({ message });
|
|
89
|
-
},
|
|
90
|
-
async signTransaction(_, __) {
|
|
91
|
-
throw new SignTransactionNotSupportedBySmartAccount();
|
|
92
|
-
},
|
|
93
|
-
async signTypedData(typedData) {
|
|
94
|
-
return privateKeyAccount.signTypedData({ ...typedData, privateKey });
|
|
95
|
-
}
|
|
8
|
+
return (0, signerToSimpleSmartAccount_js_1.signerToSimpleSmartAccount)(client, {
|
|
9
|
+
signer: privateKeyAccount,
|
|
10
|
+
factoryAddress,
|
|
11
|
+
entryPoint,
|
|
12
|
+
index
|
|
96
13
|
});
|
|
97
|
-
return {
|
|
98
|
-
...account,
|
|
99
|
-
client: client,
|
|
100
|
-
publicKey: accountAddress,
|
|
101
|
-
entryPoint: entryPoint,
|
|
102
|
-
source: "privateKeySimpleSmartAccount",
|
|
103
|
-
async getNonce() {
|
|
104
|
-
return (0, getAccountNonce_js_1.getAccountNonce)(client, {
|
|
105
|
-
sender: accountAddress,
|
|
106
|
-
entryPoint: entryPoint
|
|
107
|
-
});
|
|
108
|
-
},
|
|
109
|
-
async signUserOperation(userOperation) {
|
|
110
|
-
return account.signMessage({
|
|
111
|
-
message: {
|
|
112
|
-
raw: (0, getUserOperationHash_js_1.getUserOperationHash)({
|
|
113
|
-
userOperation,
|
|
114
|
-
entryPoint: entryPoint,
|
|
115
|
-
chainId: chainId
|
|
116
|
-
})
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
},
|
|
120
|
-
async getInitCode() {
|
|
121
|
-
const contractCode = await (0, actions_1.getBytecode)(client, {
|
|
122
|
-
address: accountAddress
|
|
123
|
-
});
|
|
124
|
-
if ((contractCode?.length ?? 0) > 2)
|
|
125
|
-
return "0x";
|
|
126
|
-
return getAccountInitCode(factoryAddress, privateKeyAccount.address);
|
|
127
|
-
},
|
|
128
|
-
async encodeDeployCallData(_) {
|
|
129
|
-
throw new Error("Simple account doesn't support account deployment");
|
|
130
|
-
},
|
|
131
|
-
async encodeCallData({ to, value, data }) {
|
|
132
|
-
return (0, viem_1.encodeFunctionData)({
|
|
133
|
-
abi: [
|
|
134
|
-
{
|
|
135
|
-
inputs: [
|
|
136
|
-
{
|
|
137
|
-
internalType: "address",
|
|
138
|
-
name: "dest",
|
|
139
|
-
type: "address"
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
internalType: "uint256",
|
|
143
|
-
name: "value",
|
|
144
|
-
type: "uint256"
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
internalType: "bytes",
|
|
148
|
-
name: "func",
|
|
149
|
-
type: "bytes"
|
|
150
|
-
}
|
|
151
|
-
],
|
|
152
|
-
name: "execute",
|
|
153
|
-
outputs: [],
|
|
154
|
-
stateMutability: "nonpayable",
|
|
155
|
-
type: "function"
|
|
156
|
-
}
|
|
157
|
-
],
|
|
158
|
-
functionName: "execute",
|
|
159
|
-
args: [to, value, data]
|
|
160
|
-
});
|
|
161
|
-
},
|
|
162
|
-
async getDummySignature() {
|
|
163
|
-
return "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
14
|
}
|
|
167
15
|
exports.privateKeyToSimpleSmartAccount = privateKeyToSimpleSmartAccount;
|
|
168
16
|
//# sourceMappingURL=privateKeyToSimpleSmartAccount.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"privateKeyToSimpleSmartAccount.js","sourceRoot":"","sources":["../../accounts/privateKeyToSimpleSmartAccount.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"privateKeyToSimpleSmartAccount.js","sourceRoot":"","sources":["../../accounts/privateKeyToSimpleSmartAccount.ts"],"names":[],"mappings":";;;AAOA,4CAAmD;AACnD,mFAGwC;AAOjC,KAAK,UAAU,8BAA8B,CAIhD,MAAkC,EAClC,EACI,UAAU,EACV,cAAc,EACd,UAAU,EACV,KAAK,GAAG,EAAE,EAMb;IAED,MAAM,iBAAiB,GAAG,IAAA,8BAAmB,EAAC,UAAU,CAAC,CAAA;IAEzD,OAAO,IAAA,0DAA0B,EAAC,MAAM,EAAE;QACtC,MAAM,EAAE,iBAAiB;QACzB,cAAc;QACd,UAAU;QACV,KAAK;KACR,CAAC,CAAA;AACN,CAAC;AAzBD,wEAyBC"}
|