@lit-protocol/vincent-e2e-test-utils 1.2.0 → 2.0.0
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 +20 -2
- package/dist/CHANGELOG.md +35 -0
- package/dist/CONTRIBUTING.md +0 -0
- package/dist/README.md +59 -0
- package/dist/package.json +18 -1
- package/dist/src/index.d.ts +2 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/chain.d.ts +1 -2
- package/dist/src/lib/chain.d.ts.map +1 -1
- package/dist/src/lib/chain.js +2 -4
- package/dist/src/lib/chain.js.map +1 -1
- package/dist/src/lib/create-random-vincent-wallets.d.ts +1 -1
- package/dist/src/lib/create-random-vincent-wallets.js +1 -1
- package/dist/src/lib/create-random-vincent-wallets.js.map +1 -1
- package/dist/src/lib/delegator/add-permission-for-abilities.d.ts +2 -1
- package/dist/src/lib/delegator/add-permission-for-abilities.d.ts.map +1 -1
- package/dist/src/lib/delegator/add-permission-for-abilities.js +4 -3
- package/dist/src/lib/delegator/add-permission-for-abilities.js.map +1 -1
- package/dist/src/lib/delegator/agent-pkp.d.ts +18 -3
- package/dist/src/lib/delegator/agent-pkp.d.ts.map +1 -1
- package/dist/src/lib/delegator/agent-pkp.js +77 -26
- package/dist/src/lib/delegator/agent-pkp.js.map +1 -1
- package/dist/src/lib/delegator/get-platform-user-pkp-wallet.d.ts +8 -0
- package/dist/src/lib/delegator/get-platform-user-pkp-wallet.d.ts.map +1 -0
- package/dist/src/lib/delegator/get-platform-user-pkp-wallet.js +77 -0
- package/dist/src/lib/delegator/get-platform-user-pkp-wallet.js.map +1 -0
- package/dist/src/lib/delegator/index.d.ts +2 -0
- package/dist/src/lib/delegator/index.d.ts.map +1 -1
- package/dist/src/lib/delegator/index.js +7 -1
- package/dist/src/lib/delegator/index.js.map +1 -1
- package/dist/src/lib/delegator/permit-vincent-app-version.d.ts +4 -2
- package/dist/src/lib/delegator/permit-vincent-app-version.d.ts.map +1 -1
- package/dist/src/lib/delegator/permit-vincent-app-version.js +5 -7
- package/dist/src/lib/delegator/permit-vincent-app-version.js.map +1 -1
- package/dist/src/lib/delegator/platform-user-pkp.d.ts +10 -0
- package/dist/src/lib/delegator/platform-user-pkp.d.ts.map +1 -0
- package/dist/src/lib/delegator/platform-user-pkp.js +48 -0
- package/dist/src/lib/delegator/platform-user-pkp.js.map +1 -0
- package/dist/src/lib/ensure-capacity-credit.d.ts +2 -1
- package/dist/src/lib/ensure-capacity-credit.d.ts.map +1 -1
- package/dist/src/lib/ensure-capacity-credit.js +7 -4
- package/dist/src/lib/ensure-capacity-credit.js.map +1 -1
- package/dist/src/lib/env.d.ts +12 -2
- package/dist/src/lib/env.d.ts.map +1 -1
- package/dist/src/lib/env.js +10 -1
- package/dist/src/lib/env.js.map +1 -1
- package/dist/src/lib/environment/crossmint.d.ts +3 -0
- package/dist/src/lib/environment/crossmint.d.ts.map +1 -0
- package/dist/src/lib/environment/crossmint.js +23 -0
- package/dist/src/lib/environment/crossmint.js.map +1 -0
- package/dist/src/lib/environment/safe.d.ts +567 -0
- package/dist/src/lib/environment/safe.d.ts.map +1 -0
- package/dist/src/lib/environment/safe.js +41 -0
- package/dist/src/lib/environment/safe.js.map +1 -0
- package/dist/src/lib/environment/zerodev.d.ts +49 -0
- package/dist/src/lib/environment/zerodev.d.ts.map +1 -0
- package/dist/src/lib/environment/zerodev.js +32 -0
- package/dist/src/lib/environment/zerodev.js.map +1 -0
- package/dist/src/lib/funder/ensure-wallet-has-test-tokens.d.ts +2 -1
- package/dist/src/lib/funder/ensure-wallet-has-test-tokens.d.ts.map +1 -1
- package/dist/src/lib/funder/ensure-wallet-has-test-tokens.js +9 -7
- package/dist/src/lib/funder/ensure-wallet-has-test-tokens.js.map +1 -1
- package/dist/src/lib/index.d.ts +2 -1
- package/dist/src/lib/index.d.ts.map +1 -1
- package/dist/src/lib/index.js +5 -1
- package/dist/src/lib/index.js.map +1 -1
- package/dist/src/lib/litContractsClient/LitContractsInstance.d.ts +2 -1
- package/dist/src/lib/litContractsClient/LitContractsInstance.d.ts.map +1 -1
- package/dist/src/lib/litContractsClient/LitContractsInstance.js.map +1 -1
- package/dist/src/lib/litContractsClient/get-lit-contract-client.d.ts +2 -1
- package/dist/src/lib/litContractsClient/get-lit-contract-client.d.ts.map +1 -1
- package/dist/src/lib/litContractsClient/get-lit-contract-client.js.map +1 -1
- package/dist/src/lib/mint-new-pkp.d.ts +5 -3
- package/dist/src/lib/mint-new-pkp.d.ts.map +1 -1
- package/dist/src/lib/mint-new-pkp.js +10 -4
- package/dist/src/lib/mint-new-pkp.js.map +1 -1
- package/dist/src/lib/setup-vincent-development-environment.d.ts +36 -6
- package/dist/src/lib/setup-vincent-development-environment.d.ts.map +1 -1
- package/dist/src/lib/setup-vincent-development-environment.js +97 -8
- package/dist/src/lib/setup-vincent-development-environment.js.map +1 -1
- package/dist/src/lib/smartAccount/crossmint/setup-crossmint-account.d.ts +3 -0
- package/dist/src/lib/smartAccount/crossmint/setup-crossmint-account.d.ts.map +1 -0
- package/dist/src/lib/smartAccount/crossmint/setup-crossmint-account.js +96 -0
- package/dist/src/lib/smartAccount/crossmint/setup-crossmint-account.js.map +1 -0
- package/dist/src/lib/smartAccount/index.d.ts +5 -0
- package/dist/src/lib/smartAccount/index.d.ts.map +1 -0
- package/dist/src/lib/smartAccount/index.js +10 -0
- package/dist/src/lib/smartAccount/index.js.map +1 -0
- package/dist/src/lib/smartAccount/safe/setup-safe-account.d.ts +15 -0
- package/dist/src/lib/smartAccount/safe/setup-safe-account.d.ts.map +1 -0
- package/dist/src/lib/smartAccount/safe/setup-safe-account.js +92 -0
- package/dist/src/lib/smartAccount/safe/setup-safe-account.js.map +1 -0
- package/dist/src/lib/smartAccount/types.d.ts +27 -0
- package/dist/src/lib/smartAccount/types.d.ts.map +1 -0
- package/dist/src/lib/smartAccount/types.js +3 -0
- package/dist/src/lib/smartAccount/types.js.map +1 -0
- package/dist/src/lib/smartAccount/zerodev/get-permission-empty-validator.d.ts +3 -0
- package/dist/src/lib/smartAccount/zerodev/get-permission-empty-validator.d.ts.map +1 -0
- package/dist/src/lib/smartAccount/zerodev/get-permission-empty-validator.js +24 -0
- package/dist/src/lib/smartAccount/zerodev/get-permission-empty-validator.js.map +1 -0
- package/dist/src/lib/smartAccount/zerodev/setup-zerodev-account.d.ts +15 -0
- package/dist/src/lib/smartAccount/zerodev/setup-zerodev-account.d.ts.map +1 -0
- package/dist/src/lib/smartAccount/zerodev/setup-zerodev-account.js +107 -0
- package/dist/src/lib/smartAccount/zerodev/setup-zerodev-account.js.map +1 -0
- package/package.json +20 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-vincent-development-environment.js","sourceRoot":"","sources":["../../../src/lib/setup-vincent-development-environment.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"setup-vincent-development-environment.js","sourceRoot":"","sources":["../../../src/lib/setup-vincent-development-environment.ts"],"names":[],"mappings":";;;;AAEA,+BAAoC;AACpC,4CAAoD;AACpD,gEAA0C;AAQ1C,iEAA2C;AAC3C,mCAA0C;AAC1C,+DAAyC;AACzC,+DAAyC;AACzC,qEAAwE;AACxE,+BAA+B;AAC/B,yDAAmC;AACnC,iDAA8F;AAiB9F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACI,MAAM,kCAAkC,GAAG,KAAK,EAAE,EACvD,cAAc,EACd,gBAAgB,GAIjB,EAAkC,EAAE;IACnC,uCAAuC;IACvC,MAAM,MAAM,CAAC,kBAAkB,EAAE,CAAC;IAClC,MAAM,SAAS,CAAC,wBAAwB,EAAE,CAAC;IAC3C,MAAM,UAAU,CAAC,sBAAsB,EAAE,CAAC;IAE1C,MAAM,YAAY,GAAG,MAAM,IAAA,uBAAe,GAAE,CAAC;IAC7C,MAAM,OAAO,GAAG,YAAY,CAAC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AAC;QACL,CAAC;aAAM,IAAI,gBAAgB,KAAK,WAAW,EAAE,CAAC;YAC5C,YAAY,GAAG,MAAM,IAAA,oCAAqB,EAAC;gBACzC,YAAY;gBACZ,gBAAgB,EAAE,YAAY,CAAC,UAA2B;gBAC1D,KAAK;aACN,CAAC,CAAC;QACL,CAAC;aAAM,IAAI,gBAAgB,KAAK,MAAM,EAAE,CAAC;YACvC,YAAY,GAAG,MAAM,IAAA,+BAAgB,EAAC;gBACpC,YAAY;gBACZ,gBAAgB,EAAE,YAAY,CAAC,UAA2B;gBAC1D,KAAK;aACN,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO;QACL,YAAY;QACZ,mBAAmB;QACnB,OAAO,EAAE;YACP,GAAG,OAAO;YACV,qBAAqB;SACtB;QACD,KAAK;QACL,UAAU;QACV,YAAY;KACb,CAAC;AACJ,CAAC,CAAC;AAtIW,QAAA,kCAAkC,sCAsI7C"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CrossmintSmartAccountInfo, SetupSmartAccountParams } from '../types';
|
|
2
|
+
export declare function setupCrossmintAccount({ ownerAccount, permittedAddress, chain, }: SetupSmartAccountParams): Promise<CrossmintSmartAccountInfo>;
|
|
3
|
+
//# sourceMappingURL=setup-crossmint-account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-crossmint-account.d.ts","sourceRoot":"","sources":["../../../../../src/lib/smartAccount/crossmint/setup-crossmint-account.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAInF,wBAAsB,qBAAqB,CAAC,EAC1C,YAAY,EACZ,gBAAgB,EAChB,KAAK,GACN,EAAE,uBAAuB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CA+G9D"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupCrossmintAccount = setupCrossmintAccount;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const crossmint_1 = require("../../environment/crossmint");
|
|
6
|
+
async function setupCrossmintAccount({ ownerAccount, permittedAddress, chain, }) {
|
|
7
|
+
const crossmintWalletApiClient = (0, crossmint_1.getCrossmintWalletApiClient)();
|
|
8
|
+
// Use email-based owner for idempotency
|
|
9
|
+
// This ensures we don't create duplicate wallets for the same owner
|
|
10
|
+
const userEmail = `${ownerAccount.address.toLowerCase()}@wallet.local`;
|
|
11
|
+
const walletLocator = `email:${userEmail}:evm:smart`;
|
|
12
|
+
// Check if wallet already exists
|
|
13
|
+
let crossmintAccount = await crossmintWalletApiClient.getWallet(walletLocator).catch(() => null);
|
|
14
|
+
let accountAlreadyExisted = false;
|
|
15
|
+
if (crossmintAccount && !('error' in crossmintAccount)) {
|
|
16
|
+
accountAlreadyExisted = true;
|
|
17
|
+
console.log(`[setupCrossmintAccount] ✅ Crossmint Smart Account already exists at: ${crossmintAccount.address}`);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
console.log(`[setupCrossmintAccount] Creating new Crossmint Smart Account...`);
|
|
21
|
+
crossmintAccount = await crossmintWalletApiClient.createWallet({
|
|
22
|
+
chainType: 'evm',
|
|
23
|
+
type: 'smart',
|
|
24
|
+
owner: `email:${userEmail}`,
|
|
25
|
+
config: {
|
|
26
|
+
adminSigner: {
|
|
27
|
+
type: 'external-wallet',
|
|
28
|
+
address: ownerAccount.address,
|
|
29
|
+
},
|
|
30
|
+
delegatedSigners: [
|
|
31
|
+
{
|
|
32
|
+
signer: {
|
|
33
|
+
type: 'external-wallet',
|
|
34
|
+
address: permittedAddress,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
if ('error' in crossmintAccount) {
|
|
41
|
+
throw new Error(`Failed to create Crossmint wallet: ${JSON.stringify(crossmintAccount.error)}`);
|
|
42
|
+
}
|
|
43
|
+
console.log(`[setupCrossmintAccount] Crossmint Smart Account address: ${crossmintAccount.address}`);
|
|
44
|
+
}
|
|
45
|
+
// Try to deploy the smart account with an empty user op
|
|
46
|
+
const deployUserOp = await crossmintWalletApiClient.createTransaction(crossmintAccount.address, {
|
|
47
|
+
params: {
|
|
48
|
+
calls: [
|
|
49
|
+
{
|
|
50
|
+
data: '0x',
|
|
51
|
+
to: viem_1.zeroAddress,
|
|
52
|
+
value: '0',
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
// @ts-expect-error - Crossmint expects specific chain literal union, viem Chain.name is generic string. Runtime validates.
|
|
56
|
+
chain: chain.name,
|
|
57
|
+
signer: ownerAccount.address,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
if ('error' in deployUserOp) {
|
|
61
|
+
// Error creating deploy transaction - account is likely already deployed
|
|
62
|
+
if (accountAlreadyExisted) {
|
|
63
|
+
console.log(`[setupCrossmintAccount] ✅ Smart Account already deployed`);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
console.log(`[setupCrossmintAccount] Skipping deployment (unable to create transaction)`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
// Account needs deployment - sign and approve the transaction
|
|
71
|
+
console.log(`[setupCrossmintAccount] Deploying Smart Account with empty UserOp...`);
|
|
72
|
+
if (!('userOperationHash' in deployUserOp.onChain)) {
|
|
73
|
+
throw new Error('Unexpected transaction response format: missing userOperationHash');
|
|
74
|
+
}
|
|
75
|
+
const deployUserOpSignature = await ownerAccount.signMessage({
|
|
76
|
+
message: { raw: deployUserOp.onChain.userOperationHash },
|
|
77
|
+
});
|
|
78
|
+
const deployUserOpApproval = await crossmintWalletApiClient.approveTransaction(crossmintAccount.address, deployUserOp.id, {
|
|
79
|
+
approvals: [
|
|
80
|
+
{
|
|
81
|
+
signer: `external-wallet:${ownerAccount.address}`,
|
|
82
|
+
signature: deployUserOpSignature,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
});
|
|
86
|
+
if ('error' in deployUserOpApproval) {
|
|
87
|
+
throw new Error(`Could not sign crossmint deploy user operation. Error: ${JSON.stringify(deployUserOpApproval.error)}`);
|
|
88
|
+
}
|
|
89
|
+
console.log(`[setupCrossmintAccount] ✅ Smart Account deployed`);
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
account: crossmintAccount,
|
|
93
|
+
client: crossmintWalletApiClient,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=setup-crossmint-account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-crossmint-account.js","sourceRoot":"","sources":["../../../../../src/lib/smartAccount/crossmint/setup-crossmint-account.ts"],"names":[],"mappings":";;AAMA,sDAmHC;AAzHD,+BAAmC;AAInC,2DAA0E;AAEnE,KAAK,UAAU,qBAAqB,CAAC,EAC1C,YAAY,EACZ,gBAAgB,EAChB,KAAK,GACmB;IACxB,MAAM,wBAAwB,GAAG,IAAA,uCAA2B,GAAE,CAAC;IAE/D,wCAAwC;IACxC,oEAAoE;IACpE,MAAM,SAAS,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,WAAW,EAAE,eAAe,CAAC;IACvE,MAAM,aAAa,GAAG,SAAS,SAAS,YAAY,CAAC;IAErD,iCAAiC;IACjC,IAAI,gBAAgB,GAAG,MAAM,wBAAwB,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACjG,IAAI,qBAAqB,GAAG,KAAK,CAAC;IAElC,IAAI,gBAAgB,IAAI,CAAC,CAAC,OAAO,IAAI,gBAAgB,CAAC,EAAE,CAAC;QACvD,qBAAqB,GAAG,IAAI,CAAC;QAC7B,OAAO,CAAC,GAAG,CACT,wEAAwE,gBAAgB,CAAC,OAAO,EAAE,CACnG,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OA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C;QAC5F,CAAC;IACH,CAAC;SAAM,CAAC;QACN,8DAA8D;QAC9D,OAAO,CAAC,GAAG,CAAC,sEAAsE,CAAC,CAAC;QAEpF,IAAI,CAAC,CAAC,mBAAmB,IAAI,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;YACnD,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;QACvF,CAAC;QAED,MAAM,qBAAqB,GAAG,MAAM,YAAY,CAAC,WAAW,CAAC;YAC3D,OAAO,EAAE,EAAE,GAAG,EAAE,YAAY,CAAC,OAAO,CAAC,iBAAkC,EAAE;SAC1E,CAAC,CAAC;QAEH,MAAM,oBAAoB,GAAG,MAAM,wBAAwB,CAAC,kBAAkB,CAC5E,gBAAgB,CAAC,OAAO,EACxB,YAAY,CAAC,EAAE,EACf;YACE,SAAS,EAAE;gBACT;oBACE,MAAM,EAAE,mBAAmB,YAAY,CAAC,OAAO,EAAE;oBACjD,SAAS,EAAE,qBAAqB;iBACjC;aACF;SACF,CACF,CAAC;QACF,IAAI,OAAO,IAAI,oBAAoB,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CACb,0DAA0D,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE,CACvG,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;IAClE,CAAC;IAED,OAAO;QACL,OAAO,EAAE,gBAAgB;QACzB,MAAM,EAAE,wBAAwB;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { setupZerodevAccount } from './zerodev/setup-zerodev-account';
|
|
2
|
+
export { setupCrossmintAccount } from './crossmint/setup-crossmint-account';
|
|
3
|
+
export { setupSafeAccount } from './safe/setup-safe-account';
|
|
4
|
+
export type { SmartAccountInfo, ZerodevSmartAccountInfo, CrossmintSmartAccountInfo, SafeSmartAccountInfo, SetupSmartAccountParams, } from './types';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/smartAccount/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,yBAAyB,EACzB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupSafeAccount = exports.setupCrossmintAccount = exports.setupZerodevAccount = void 0;
|
|
4
|
+
var setup_zerodev_account_1 = require("./zerodev/setup-zerodev-account");
|
|
5
|
+
Object.defineProperty(exports, "setupZerodevAccount", { enumerable: true, get: function () { return setup_zerodev_account_1.setupZerodevAccount; } });
|
|
6
|
+
var setup_crossmint_account_1 = require("./crossmint/setup-crossmint-account");
|
|
7
|
+
Object.defineProperty(exports, "setupCrossmintAccount", { enumerable: true, get: function () { return setup_crossmint_account_1.setupCrossmintAccount; } });
|
|
8
|
+
var setup_safe_account_1 = require("./safe/setup-safe-account");
|
|
9
|
+
Object.defineProperty(exports, "setupSafeAccount", { enumerable: true, get: function () { return setup_safe_account_1.setupSafeAccount; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/smartAccount/index.ts"],"names":[],"mappings":";;;AAAA,yEAAsE;AAA7D,4HAAA,mBAAmB,OAAA;AAC5B,+EAA4E;AAAnE,gIAAA,qBAAqB,OAAA;AAC9B,gEAA6D;AAApD,sHAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SafeSmartAccountInfo, SetupSmartAccountParams } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Set up a Safe smart account for testing with Vincent abilities.
|
|
4
|
+
*
|
|
5
|
+
* This function:
|
|
6
|
+
* 1. Creates a Safe (v1.4.1) smart account with the owner account
|
|
7
|
+
* 2. Deploys the Safe on-chain
|
|
8
|
+
* 3. Adds the PKP address as an additional owner with threshold 1
|
|
9
|
+
* 4. This allows either the owner EOA or the Vincent PKP to sign UserOps
|
|
10
|
+
*
|
|
11
|
+
* @param params - Configuration parameters
|
|
12
|
+
* @returns Safe smart account and client
|
|
13
|
+
*/
|
|
14
|
+
export declare function setupSafeAccount({ ownerAccount, permittedAddress, chain, }: SetupSmartAccountParams): Promise<SafeSmartAccountInfo>;
|
|
15
|
+
//# sourceMappingURL=setup-safe-account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-safe-account.d.ts","sourceRoot":"","sources":["../../../../../src/lib/smartAccount/safe/setup-safe-account.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAU9E;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,YAAY,EACZ,gBAAgB,EAChB,KAAK,GACN,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAwFzD"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupSafeAccount = setupSafeAccount;
|
|
4
|
+
const permissionless_1 = require("permissionless");
|
|
5
|
+
const accounts_1 = require("permissionless/accounts");
|
|
6
|
+
const viem_1 = require("viem");
|
|
7
|
+
const safe_1 = require("../../environment/safe");
|
|
8
|
+
/**
|
|
9
|
+
* Set up a Safe smart account for testing with Vincent abilities.
|
|
10
|
+
*
|
|
11
|
+
* This function:
|
|
12
|
+
* 1. Creates a Safe (v1.4.1) smart account with the owner account
|
|
13
|
+
* 2. Deploys the Safe on-chain
|
|
14
|
+
* 3. Adds the PKP address as an additional owner with threshold 1
|
|
15
|
+
* 4. This allows either the owner EOA or the Vincent PKP to sign UserOps
|
|
16
|
+
*
|
|
17
|
+
* @param params - Configuration parameters
|
|
18
|
+
* @returns Safe smart account and client
|
|
19
|
+
*/
|
|
20
|
+
async function setupSafeAccount({ ownerAccount, permittedAddress, chain, }) {
|
|
21
|
+
// Create transports - separate RPC for chain operations vs bundler operations
|
|
22
|
+
const safeTransport = (0, safe_1.getSafeTransport)(); // Regular RPC for eth_call, getCode, etc.
|
|
23
|
+
const pimlicoTransport = (0, safe_1.getPimlicoTransport)(); // Bundler RPC for UserOps
|
|
24
|
+
// Create public client for the chain using regular RPC
|
|
25
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
26
|
+
chain,
|
|
27
|
+
transport: safeTransport,
|
|
28
|
+
});
|
|
29
|
+
// Create Pimlico paymaster client
|
|
30
|
+
const pimlicoClient = (0, safe_1.createPimlicoPaymaster)();
|
|
31
|
+
console.log('[setupSafeAccount] Creating Safe account...');
|
|
32
|
+
// Create the Safe account with the owner
|
|
33
|
+
const safeAccount = await (0, accounts_1.toSafeSmartAccount)({
|
|
34
|
+
entryPoint: safe_1.entryPoint,
|
|
35
|
+
client: publicClient,
|
|
36
|
+
owners: [ownerAccount],
|
|
37
|
+
version: safe_1.safeVersion,
|
|
38
|
+
});
|
|
39
|
+
console.log(`[setupSafeAccount] Safe Smart Account address: ${safeAccount.address}`);
|
|
40
|
+
// Check if account is already deployed
|
|
41
|
+
const accountCode = await publicClient.getCode({
|
|
42
|
+
address: safeAccount.address,
|
|
43
|
+
});
|
|
44
|
+
const isDeployed = accountCode && accountCode !== '0x';
|
|
45
|
+
// Create Safe client
|
|
46
|
+
const safeClient = (0, permissionless_1.createSmartAccountClient)({
|
|
47
|
+
account: safeAccount,
|
|
48
|
+
chain,
|
|
49
|
+
bundlerTransport: pimlicoTransport,
|
|
50
|
+
paymaster: pimlicoClient,
|
|
51
|
+
userOperation: {
|
|
52
|
+
estimateFeesPerGas: async () => {
|
|
53
|
+
return (await pimlicoClient.getUserOperationGasPrice()).fast;
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
if (isDeployed) {
|
|
58
|
+
console.log('[setupSafeAccount] ✅ Safe account already deployed');
|
|
59
|
+
// Check if PKP is already an owner
|
|
60
|
+
// For now, we'll assume if deployed, it's already configured
|
|
61
|
+
// In production, you might want to read the Safe owners and verify
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
console.log('[setupSafeAccount] Deploying Safe and adding PKP as owner...');
|
|
65
|
+
// Encode the call to add the PKP as an owner with threshold 1
|
|
66
|
+
const addOwnerCallData = (0, viem_1.encodeFunctionData)({
|
|
67
|
+
abi: (0, viem_1.parseAbi)(['function addOwnerWithThreshold(address owner, uint256 _threshold) public']),
|
|
68
|
+
functionName: 'addOwnerWithThreshold',
|
|
69
|
+
args: [permittedAddress, 1n],
|
|
70
|
+
});
|
|
71
|
+
// Deploy and configure Safe in a single transaction
|
|
72
|
+
const txHash = await safeClient.sendTransaction({
|
|
73
|
+
to: safeAccount.address,
|
|
74
|
+
value: 0n,
|
|
75
|
+
data: addOwnerCallData,
|
|
76
|
+
chain,
|
|
77
|
+
});
|
|
78
|
+
console.log(`[setupSafeAccount] Setup transaction hash: ${txHash}`);
|
|
79
|
+
// Wait for receipt
|
|
80
|
+
const receipt = await publicClient.waitForTransactionReceipt({
|
|
81
|
+
confirmations: 2,
|
|
82
|
+
hash: txHash,
|
|
83
|
+
});
|
|
84
|
+
console.log(`[setupSafeAccount] ✅ Safe deployed and PKP added as owner at block: ${receipt.blockNumber}`);
|
|
85
|
+
}
|
|
86
|
+
console.log(`[setupSafeAccount] ✅ Safe account setup complete: ${safeAccount.address}\n`);
|
|
87
|
+
return {
|
|
88
|
+
account: safeAccount,
|
|
89
|
+
client: safeClient,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=setup-safe-account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-safe-account.js","sourceRoot":"","sources":["../../../../../src/lib/smartAccount/safe/setup-safe-account.ts"],"names":[],"mappings":";;AA0BA,4CA4FC;AAtHD,mDAA0D;AAC1D,sDAA6D;AAC7D,+BAAwE;AAIxE,iDAMgC;AAEhC;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,gBAAgB,CAAC,EACrC,YAAY,EACZ,gBAAgB,EAChB,KAAK,GACmB;IACxB,8EAA8E;IAC9E,MAAM,aAAa,GAAG,IAAA,uBAAgB,GAAE,CAAC,CAAC,0CAA0C;IACpF,MAAM,gBAAgB,GAAG,IAAA,0BAAmB,GAAE,CAAC,CAAC,0BAA0B;IAE1E,uDAAuD;IACvD,MAAM,YAAY,GAAG,IAAA,yBAAkB,EAAC;QACtC,KAAK;QACL,SAAS,EAAE,aAAa;KACzB,CAAC,CAAC;IAEH,kCAAkC;IAClC,MAAM,aAAa,GAAG,IAAA,6BAAsB,GAAE,CAAC;IAE/C,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;IAE3D,yCAAyC;IACzC,MAAM,WAAW,GAAG,MAAM,IAAA,6BAAkB,EAAC;QAC3C,UAAU,EAAV,iBAAU;QACV,MAAM,EAAE,YAAY;QACpB,MAAM,EAAE,CAAC,YAAY,CAAC;QACtB,OAAO,EAAE,kBAAW;KACrB,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,kDAAkD,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC;IAErF,uCAAuC;IACvC,MAAM,WAAW,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC;QAC7C,OAAO,EAAE,WAAW,CAAC,OAAO;KAC7B,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,WAAW,IAAI,WAAW,KAAK,IAA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AAC,GAAG,CAAC,qDAAqD,WAAW,CAAC,OAAO,IAAI,CAAC,CAAC;IAE1F,OAAO;QACL,OAAO,EAAE,WAAW;QACpB,MAAM,EAAE,UAAU;KACnB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { WalletsApiClient } from '@crossmint/wallets-sdk';
|
|
2
|
+
import type { CreateKernelAccountReturnType } from '@zerodev/sdk';
|
|
3
|
+
import type { SmartAccountClient } from 'permissionless';
|
|
4
|
+
import type { toSafeSmartAccount } from 'permissionless/accounts';
|
|
5
|
+
import type { Address, Chain } from 'viem';
|
|
6
|
+
import type { PrivateKeyAccount } from 'viem/accounts';
|
|
7
|
+
export interface SetupSmartAccountParams {
|
|
8
|
+
ownerAccount: PrivateKeyAccount;
|
|
9
|
+
permittedAddress: Address;
|
|
10
|
+
chain: Chain;
|
|
11
|
+
}
|
|
12
|
+
export interface ZerodevSmartAccountInfo {
|
|
13
|
+
account: CreateKernelAccountReturnType;
|
|
14
|
+
serializedPermissionAccount: string;
|
|
15
|
+
}
|
|
16
|
+
export interface CrossmintSmartAccountInfo {
|
|
17
|
+
account: Exclude<Awaited<ReturnType<WalletsApiClient['createWallet']>>, {
|
|
18
|
+
error: unknown;
|
|
19
|
+
}>;
|
|
20
|
+
client: WalletsApiClient;
|
|
21
|
+
}
|
|
22
|
+
export interface SafeSmartAccountInfo {
|
|
23
|
+
account: Awaited<ReturnType<typeof toSafeSmartAccount>>;
|
|
24
|
+
client: SmartAccountClient;
|
|
25
|
+
}
|
|
26
|
+
export type SmartAccountInfo = ZerodevSmartAccountInfo | CrossmintSmartAccountInfo | SafeSmartAccountInfo;
|
|
27
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/smartAccount/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,iBAAiB,CAAC;IAChC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,6BAA6B,CAAC;IACvC,2BAA2B,EAAE,MAAM,CAAC;CACrC;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC5F,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC;IACxD,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAED,MAAM,MAAM,gBAAgB,GACxB,uBAAuB,GACvB,yBAAyB,GACzB,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/smartAccount/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Address, PublicClient } from 'viem';
|
|
2
|
+
export declare function getPermissionEmptyValidator(publicClient: PublicClient, permittedAddress: Address): Promise<import("@zerodev/permissions").PermissionPlugin>;
|
|
3
|
+
//# sourceMappingURL=get-permission-empty-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-permission-empty-validator.d.ts","sourceRoot":"","sources":["../../../../../src/lib/smartAccount/zerodev/get-permission-empty-validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AASlD,wBAAsB,2BAA2B,CAC/C,YAAY,EAAE,YAAY,EAC1B,gBAAgB,EAAE,OAAO,4DAe1B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPermissionEmptyValidator = getPermissionEmptyValidator;
|
|
4
|
+
const permissions_1 = require("@zerodev/permissions");
|
|
5
|
+
const policies_1 = require("@zerodev/permissions/policies");
|
|
6
|
+
const signers_1 = require("@zerodev/permissions/signers");
|
|
7
|
+
const sdk_1 = require("@zerodev/sdk");
|
|
8
|
+
const zerodev_1 = require("../../environment/zerodev");
|
|
9
|
+
async function getPermissionEmptyValidator(publicClient, permittedAddress) {
|
|
10
|
+
const permittedEmptyAccount = (0, sdk_1.addressToEmptyAccount)(permittedAddress);
|
|
11
|
+
const permittedEmptySigner = await (0, signers_1.toECDSASigner)({
|
|
12
|
+
signer: permittedEmptyAccount,
|
|
13
|
+
});
|
|
14
|
+
return await (0, permissions_1.toPermissionValidator)(publicClient, {
|
|
15
|
+
entryPoint: zerodev_1.entryPoint,
|
|
16
|
+
kernelVersion: zerodev_1.kernelVersion,
|
|
17
|
+
signer: permittedEmptySigner,
|
|
18
|
+
policies: [
|
|
19
|
+
// This is kept simple since this is a simple development environment file.
|
|
20
|
+
(0, policies_1.toSudoPolicy)({}),
|
|
21
|
+
],
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=get-permission-empty-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-permission-empty-validator.js","sourceRoot":"","sources":["../../../../../src/lib/smartAccount/zerodev/get-permission-empty-validator.ts"],"names":[],"mappings":";;AASA,kEAiBC;AAxBD,sDAA6D;AAC7D,4DAA6D;AAC7D,0DAA6D;AAC7D,sCAAqD;AAErD,uDAAsE;AAE/D,KAAK,UAAU,2BAA2B,CAC/C,YAA0B,EAC1B,gBAAyB;IAEzB,MAAM,qBAAqB,GAAG,IAAA,2BAAqB,EAAC,gBAAgB,CAAC,CAAC;IACtE,MAAM,oBAAoB,GAAG,MAAM,IAAA,uBAAa,EAAC;QAC/C,MAAM,EAAE,qBAAqB;KAC9B,CAAC,CAAC;IACH,OAAO,MAAM,IAAA,mCAAqB,EAAC,YAAY,EAAE;QAC/C,UAAU,EAAV,oBAAU;QACV,aAAa,EAAb,uBAAa;QACb,MAAM,EAAE,oBAAoB;QAC5B,QAAQ,EAAE;YACR,2EAA2E;YAC3E,IAAA,uBAAY,EAAC,EAAE,CAAC;SACjB;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SetupSmartAccountParams, ZerodevSmartAccountInfo } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Set up a ZeroDev Kernel smart account for testing with Vincent abilities.
|
|
4
|
+
*
|
|
5
|
+
* This function:
|
|
6
|
+
* 1. Creates an owner validator using the owner's private key
|
|
7
|
+
* 2. Creates a permission validator for the PKP address (empty validator)
|
|
8
|
+
* 3. Deploys the Kernel smart account on-chain
|
|
9
|
+
* 4. Generates a serialized permission account for signing UserOps
|
|
10
|
+
*
|
|
11
|
+
* @param params - Configuration parameters
|
|
12
|
+
* @returns Smart account address and serialized permission account
|
|
13
|
+
*/
|
|
14
|
+
export declare function setupZerodevAccount({ ownerAccount, permittedAddress, chain, }: SetupSmartAccountParams): Promise<ZerodevSmartAccountInfo>;
|
|
15
|
+
//# sourceMappingURL=setup-zerodev-account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-zerodev-account.d.ts","sourceRoot":"","sources":["../../../../../src/lib/smartAccount/zerodev/setup-zerodev-account.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAUjF;;;;;;;;;;;GAWG;AACH,wBAAsB,mBAAmB,CAAC,EACxC,YAAY,EACZ,gBAAgB,EAChB,KAAK,GACN,EAAE,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA2G5D"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupZerodevAccount = setupZerodevAccount;
|
|
4
|
+
const ecdsa_validator_1 = require("@zerodev/ecdsa-validator");
|
|
5
|
+
const permissions_1 = require("@zerodev/permissions");
|
|
6
|
+
const sdk_1 = require("@zerodev/sdk");
|
|
7
|
+
const viem_1 = require("viem");
|
|
8
|
+
const zerodev_1 = require("../../environment/zerodev");
|
|
9
|
+
const get_permission_empty_validator_1 = require("./get-permission-empty-validator");
|
|
10
|
+
/**
|
|
11
|
+
* Set up a ZeroDev Kernel smart account for testing with Vincent abilities.
|
|
12
|
+
*
|
|
13
|
+
* This function:
|
|
14
|
+
* 1. Creates an owner validator using the owner's private key
|
|
15
|
+
* 2. Creates a permission validator for the PKP address (empty validator)
|
|
16
|
+
* 3. Deploys the Kernel smart account on-chain
|
|
17
|
+
* 4. Generates a serialized permission account for signing UserOps
|
|
18
|
+
*
|
|
19
|
+
* @param params - Configuration parameters
|
|
20
|
+
* @returns Smart account address and serialized permission account
|
|
21
|
+
*/
|
|
22
|
+
async function setupZerodevAccount({ ownerAccount, permittedAddress, chain, }) {
|
|
23
|
+
// Create public client for the chain using ZeroDev RPC
|
|
24
|
+
// This ensures validator configuration is consistent with the bundler
|
|
25
|
+
const zerodevTransport = (0, zerodev_1.getZerodevTransport)();
|
|
26
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
27
|
+
chain,
|
|
28
|
+
transport: zerodevTransport,
|
|
29
|
+
});
|
|
30
|
+
// Create ZeroDev paymaster using centralized factory
|
|
31
|
+
const zerodevPaymaster = (0, zerodev_1.createZeroDevPaymaster)(chain);
|
|
32
|
+
console.log('[setupZerodevAccount] Creating validators...');
|
|
33
|
+
// Owner validator (actual signer)
|
|
34
|
+
const ownerValidator = await (0, ecdsa_validator_1.signerToEcdsaValidator)(publicClient, {
|
|
35
|
+
entryPoint: zerodev_1.entryPoint,
|
|
36
|
+
kernelVersion: zerodev_1.kernelVersion,
|
|
37
|
+
signer: ownerAccount,
|
|
38
|
+
});
|
|
39
|
+
// Permission validator (empty validator for PKP address)
|
|
40
|
+
const permissionValidator = await (0, get_permission_empty_validator_1.getPermissionEmptyValidator)(publicClient, permittedAddress);
|
|
41
|
+
console.log('[setupZerodevAccount] Creating Kernel account...');
|
|
42
|
+
// Create smart account with both validators (matching reference implementation)
|
|
43
|
+
const ownerKernelAccount = await (0, sdk_1.createKernelAccount)(publicClient, {
|
|
44
|
+
entryPoint: zerodev_1.entryPoint,
|
|
45
|
+
kernelVersion: zerodev_1.kernelVersion,
|
|
46
|
+
plugins: {
|
|
47
|
+
sudo: ownerValidator,
|
|
48
|
+
},
|
|
49
|
+
initConfig: await (0, permissions_1.toInitConfig)(permissionValidator),
|
|
50
|
+
});
|
|
51
|
+
console.log(`[setupZerodevAccount] Smart account address: ${ownerKernelAccount.address}`);
|
|
52
|
+
// Check if account is already deployed
|
|
53
|
+
const accountCode = await publicClient.getCode({
|
|
54
|
+
address: ownerKernelAccount.address,
|
|
55
|
+
});
|
|
56
|
+
const isDeployed = accountCode && accountCode !== '0x';
|
|
57
|
+
// Create kernel client with paymaster
|
|
58
|
+
const ownerKernelClient = (0, sdk_1.createKernelAccountClient)({
|
|
59
|
+
chain,
|
|
60
|
+
account: ownerKernelAccount,
|
|
61
|
+
bundlerTransport: zerodevTransport,
|
|
62
|
+
client: publicClient,
|
|
63
|
+
paymaster: {
|
|
64
|
+
getPaymasterData(userOperation) {
|
|
65
|
+
return zerodevPaymaster.sponsorUserOperation({ userOperation });
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
if (isDeployed) {
|
|
70
|
+
console.log('[setupZerodevAccount] ✅ Smart account already deployed');
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
console.log('[setupZerodevAccount] Deploying Smart Account with empty UserOp...');
|
|
74
|
+
// Deploy smart account with an empty user operation
|
|
75
|
+
const deployUserOpHash = await ownerKernelClient.sendUserOperation({
|
|
76
|
+
callData: await ownerKernelAccount.encodeCalls([
|
|
77
|
+
{
|
|
78
|
+
to: viem_1.zeroAddress,
|
|
79
|
+
value: BigInt(0),
|
|
80
|
+
data: '0x',
|
|
81
|
+
},
|
|
82
|
+
]),
|
|
83
|
+
});
|
|
84
|
+
console.log(`[setupZerodevAccount] Deployment UserOp hash: ${deployUserOpHash}`);
|
|
85
|
+
// Wait for deployment
|
|
86
|
+
const deployUserOpReceipt = await ownerKernelClient.waitForUserOperationReceipt({
|
|
87
|
+
hash: deployUserOpHash,
|
|
88
|
+
});
|
|
89
|
+
console.log(`[setupZerodevAccount] ✅ Smart Account deployed at tx: ${deployUserOpReceipt.receipt.transactionHash}`);
|
|
90
|
+
}
|
|
91
|
+
const permissionKernelAccountToSerialize = await (0, sdk_1.createKernelAccount)(publicClient, {
|
|
92
|
+
entryPoint: zerodev_1.entryPoint,
|
|
93
|
+
kernelVersion: zerodev_1.kernelVersion,
|
|
94
|
+
address: ownerKernelAccount.address,
|
|
95
|
+
plugins: {
|
|
96
|
+
sudo: ownerValidator,
|
|
97
|
+
regular: permissionValidator,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
const serializedPermissionAccount = await (0, permissions_1.serializePermissionAccount)(permissionKernelAccountToSerialize);
|
|
101
|
+
console.log(`[setupZerodevAccount] ✅ Smart account setup complete: ${ownerKernelAccount.address}\n`);
|
|
102
|
+
return {
|
|
103
|
+
account: ownerKernelAccount,
|
|
104
|
+
serializedPermissionAccount,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=setup-zerodev-account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-zerodev-account.js","sourceRoot":"","sources":["../../../../../src/lib/smartAccount/zerodev/setup-zerodev-account.ts"],"names":[],"mappings":";;AA2BA,kDA+GC;AA1ID,8DAAkE;AAClE,sDAAgF;AAChF,sCAA8E;AAC9E,+BAAuD;AAIvD,uDAKmC;AACnC,qFAA+E;AAE/E;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,mBAAmB,CAAC,EACxC,YAAY,EACZ,gBAAgB,EAChB,KAAK,GACmB;IACxB,uDAAuD;IACvD,sEAAsE;IACtE,MAAM,gBAAgB,GAAG,IAAA,6BAAmB,GAAE,CAAC;IAC/C,MAAM,YAAY,GAAG,IAAA,yBAAkB,EAAC;QACtC,KAAK;QACL,SAAS,EAAE,gBAAgB;KAC5B,CAAC,CAAC;IAEH,qDAAqD;IACrD,MAAM,gBAAgB,GAAG,IAAA,gCAAsB,EAAC,KAAK,CAAC,CAAC;IAEvD,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;IAE5D,kCAAkC;IAClC,MAAM,cAAc,GAAG,MAAM,IAAA,wCAAsB,EAAC,YAAY,EAAE;QAChE,UAAU,EAAV,oBAAU;QACV,aAAa,EAAb,uBAAa;QACb,MAAM,EAAE,YAAY;KACrB,CAAC,CAAC;IAEH,yDAAyD;IACzD,MAAM,mBAAmB,GAAG,MAAM,IAAA,4DAA2B,EAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IAE9F,OAAO,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;IAEhE,gFAAgF;IAChF,MAAM,kBAAkB,GAAG,MAAM,IAAA,yBAAmB,EAAC,YAAY,EAAE;QACjE,UAAU,EAAV,oBAAU;QACV,aA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,iBAAiB,CAAC,2BAA2B,CAAC;YAC9E,IAAI,EAAE,gBAAgB;SACvB,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CACT,yDAAyD,mBAAmB,CAAC,OAAO,CAAC,eAAe,EAAE,CACvG,CAAC;IACJ,CAAC;IAED,MAAM,kCAAkC,GAAG,MAAM,IAAA,yBAAmB,EAAC,YAAY,EAAE;QACjF,UAAU,EAAV,oBAAU;QACV,aAAa,EAAb,uBAAa;QACb,OAAO,EAAE,kBAAkB,CAAC,OAAO;QACnC,OAAO,EAAE;YACP,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,mBAAmB;SAC7B;KACF,CAAC,CAAC;IAEH,MAAM,2BAA2B,GAAG,MAAM,IAAA,wCAA0B,EAClE,kCAAkC,CACnC,CAAC;IAEF,OAAO,CAAC,GAAG,CACT,yDAAyD,kBAAkB,CAAC,OAAO,IAAI,CACxF,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,kBAAkB;QAC3B,2BAA2B;KAC5B,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lit-protocol/vincent-e2e-test-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@lit-protocol/
|
|
8
|
+
"@lit-protocol/auth-helpers": "^7",
|
|
9
|
+
"@lit-protocol/constants": "^7",
|
|
10
|
+
"@crossmint/wallets-sdk": "^0.18.7",
|
|
9
11
|
"@lit-protocol/contracts-sdk": "^7.2.3",
|
|
12
|
+
"@lit-protocol/lit-node-client": "^7",
|
|
13
|
+
"@lit-protocol/pkp-ethers": "^7.3.1",
|
|
14
|
+
"@lit-protocol/types": "^7",
|
|
10
15
|
"@t3-oss/env-core": "^0.13.8",
|
|
16
|
+
"@zerodev/ecdsa-validator": "^5.4.9",
|
|
17
|
+
"@zerodev/permissions": "^5.6.2",
|
|
18
|
+
"@zerodev/sdk": "^5.5.3",
|
|
11
19
|
"ethers": "^5.7.2",
|
|
20
|
+
"permissionless": "^0.2.57",
|
|
12
21
|
"tslib": "^2.8.1",
|
|
22
|
+
"viem": "^2.38.3",
|
|
13
23
|
"zod": "^3.25.64",
|
|
14
|
-
"@lit-protocol/vincent-contracts-sdk": "
|
|
24
|
+
"@lit-protocol/vincent-contracts-sdk": "6.0.0"
|
|
15
25
|
},
|
|
16
26
|
"main": "./dist/src/index.js",
|
|
17
27
|
"types": "./dist/src/index.d.ts",
|
|
@@ -28,11 +38,18 @@
|
|
|
28
38
|
"devDependencies": {
|
|
29
39
|
"@types/semver": "^7.7.0",
|
|
30
40
|
"chokidar-cli": "^3.0.0",
|
|
41
|
+
"dotenv-cli": "^7.4.2",
|
|
31
42
|
"ipfs-only-hash": "^4.0.0",
|
|
32
43
|
"jsonc-eslint-parser": "^2.4.0",
|
|
33
44
|
"typedoc": "0.27.9",
|
|
34
45
|
"typedoc-material-theme": "1.3.0",
|
|
35
46
|
"typedoc-plugin-extras": "^4.0.0",
|
|
36
47
|
"typedoc-plugin-zod": "^1.4.1"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"test:smartAccount": "NODE_OPTIONS=--experimental-vm-modules dotenv -e .env jest test/smartAccount/all.spec.ts",
|
|
51
|
+
"test:crossmint": "NODE_OPTIONS=--experimental-vm-modules dotenv -e .env jest test/smartAccount/crossmint.spec.ts",
|
|
52
|
+
"test:zerodev": "NODE_OPTIONS=--experimental-vm-modules dotenv -e .env jest test/smartAccount/zerodev.spec.ts",
|
|
53
|
+
"test:safe": "NODE_OPTIONS=--experimental-vm-modules dotenv -e .env jest test/smartAccount/safe.spec.ts"
|
|
37
54
|
}
|
|
38
55
|
}
|