@lit-protocol/vincent-e2e-test-utils 1.1.0 → 1.2.1
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/README.md +51 -9
- package/dist/package.json +15 -2
- 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/env.d.ts +4 -0
- package/dist/src/lib/env.d.ts.map +1 -1
- package/dist/src/lib/env.js +3 -0
- 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/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/setup-vincent-development-environment.d.ts +26 -2
- package/dist/src/lib/setup-vincent-development-environment.d.ts.map +1 -1
- package/dist/src/lib/setup-vincent-development-environment.js +70 -2
- 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 +95 -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 +26 -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 +16 -3
- package/dist/CHANGELOG.md +0 -29
- package/dist/CONTRIBUTING.md +0 -0
- package/dist/README.md +0 -17
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPimlicoTransport = exports.getPimlicoRpc = exports.getSafeTransport = exports.getSafeRpc = exports.entryPoint = exports.safeVersion = void 0;
|
|
4
|
+
exports.createPimlicoPaymaster = createPimlicoPaymaster;
|
|
5
|
+
const pimlico_1 = require("permissionless/clients/pimlico");
|
|
6
|
+
const viem_1 = require("viem");
|
|
7
|
+
const account_abstraction_1 = require("viem/account-abstraction");
|
|
8
|
+
function getSafeRpcUrl() {
|
|
9
|
+
const SAFE_RPC_URL = process.env.SAFE_RPC_URL;
|
|
10
|
+
if (!SAFE_RPC_URL) {
|
|
11
|
+
throw new Error('Missing SAFE_RPC_URL env variable for chain operations');
|
|
12
|
+
}
|
|
13
|
+
return SAFE_RPC_URL;
|
|
14
|
+
}
|
|
15
|
+
function getPimlicoRpcUrl() {
|
|
16
|
+
const PIMLICO_RPC_URL = process.env.PIMLICO_RPC_URL;
|
|
17
|
+
if (!PIMLICO_RPC_URL) {
|
|
18
|
+
throw new Error('Missing PIMLICO_RPC_URL env variable for bundler operations');
|
|
19
|
+
}
|
|
20
|
+
return PIMLICO_RPC_URL;
|
|
21
|
+
}
|
|
22
|
+
exports.safeVersion = '1.4.1';
|
|
23
|
+
exports.entryPoint = {
|
|
24
|
+
address: account_abstraction_1.entryPoint07Address,
|
|
25
|
+
version: '0.7',
|
|
26
|
+
};
|
|
27
|
+
const getSafeRpc = () => getSafeRpcUrl();
|
|
28
|
+
exports.getSafeRpc = getSafeRpc;
|
|
29
|
+
const getSafeTransport = () => (0, viem_1.http)(getSafeRpcUrl());
|
|
30
|
+
exports.getSafeTransport = getSafeTransport;
|
|
31
|
+
const getPimlicoRpc = () => getPimlicoRpcUrl();
|
|
32
|
+
exports.getPimlicoRpc = getPimlicoRpc;
|
|
33
|
+
const getPimlicoTransport = () => (0, viem_1.http)(getPimlicoRpcUrl());
|
|
34
|
+
exports.getPimlicoTransport = getPimlicoTransport;
|
|
35
|
+
function createPimlicoPaymaster() {
|
|
36
|
+
return (0, pimlico_1.createPimlicoClient)({
|
|
37
|
+
entryPoint: exports.entryPoint,
|
|
38
|
+
transport: (0, exports.getPimlicoTransport)(),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=safe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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ACL,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Chain } from 'viem';
|
|
2
|
+
export declare const kernelVersion: import("@zerodev/sdk/types").KERNEL_V3_VERSION_TYPE;
|
|
3
|
+
export declare const entryPoint: import("@zerodev/sdk/types").EntryPointType<"0.7">;
|
|
4
|
+
export declare const getZerodevRpc: () => string;
|
|
5
|
+
export declare const getZerodevTransport: () => import("viem").HttpTransport<undefined, false>;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a ZeroDev paymaster client for the specified chain.
|
|
8
|
+
* This should be called at runtime with the actual chain object.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createZeroDevPaymaster(chain: Chain): {
|
|
11
|
+
account: import("viem/account-abstraction").SmartAccount | undefined;
|
|
12
|
+
batch?: {
|
|
13
|
+
multicall?: boolean | import("viem").Prettify<import("viem").MulticallBatchOptions> | undefined;
|
|
14
|
+
} | undefined;
|
|
15
|
+
cacheTime: number;
|
|
16
|
+
ccipRead?: false | {
|
|
17
|
+
request?: (parameters: import("viem").CcipRequestParameters) => Promise<import("node_modules/viem/_types/utils/ccip").CcipRequestReturnType>;
|
|
18
|
+
} | undefined;
|
|
19
|
+
chain: Chain | undefined;
|
|
20
|
+
experimental_blockTag?: import("viem").BlockTag | undefined;
|
|
21
|
+
key: string;
|
|
22
|
+
name: string;
|
|
23
|
+
pollingInterval: number;
|
|
24
|
+
request: import("viem").EIP1193RequestFn<import("@zerodev/sdk").ZeroDevPaymasterRpcSchema<"0.7">>;
|
|
25
|
+
transport: import("viem").TransportConfig<string, import("viem").EIP1193RequestFn> & Record<string, any>;
|
|
26
|
+
type: string;
|
|
27
|
+
uid: string;
|
|
28
|
+
getPaymasterData: (parameters: import("viem/account-abstraction").GetPaymasterDataParameters) => Promise<import("viem/account-abstraction").GetPaymasterDataReturnType>;
|
|
29
|
+
getPaymasterStubData: (parameters: import("viem/account-abstraction").GetPaymasterStubDataParameters) => Promise<import("viem/account-abstraction").GetPaymasterStubDataReturnType>;
|
|
30
|
+
sponsorUserOperation: (args: import("@zerodev/sdk").SponsorUserOperationParameters) => Promise<import("@zerodev/sdk").SponsorUserOperationReturnType>;
|
|
31
|
+
estimateGasInERC20: (args: import("@zerodev/sdk/actions").EstimateGasInERC20Parameters) => Promise<import("@zerodev/sdk/actions").EstimateGasInERC20ReturnType>;
|
|
32
|
+
extend: <const client extends {
|
|
33
|
+
[x: string]: unknown;
|
|
34
|
+
account?: undefined;
|
|
35
|
+
batch?: undefined;
|
|
36
|
+
cacheTime?: undefined;
|
|
37
|
+
ccipRead?: undefined;
|
|
38
|
+
chain?: undefined;
|
|
39
|
+
experimental_blockTag?: undefined;
|
|
40
|
+
key?: undefined;
|
|
41
|
+
name?: undefined;
|
|
42
|
+
pollingInterval?: undefined;
|
|
43
|
+
request?: undefined;
|
|
44
|
+
transport?: undefined;
|
|
45
|
+
type?: undefined;
|
|
46
|
+
uid?: undefined;
|
|
47
|
+
} & import("viem").ExactPartial<Pick<import("viem").PublicActions<import("viem").Transport, Chain | undefined, import("viem/account-abstraction").SmartAccount | undefined>, "call" | "getChainId" | "prepareTransactionRequest" | "sendRawTransaction" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "getContractEvents" | "getEnsText" | "getFilterChanges" | "getGasPrice" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "readContract" | "simulateContract" | "uninstallFilter" | "watchBlockNumber" | "watchContractEvent"> & Pick<import("viem").WalletActions<Chain | undefined, import("viem/account-abstraction").SmartAccount | undefined>, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<import("viem").Transport, Chain | undefined, import("viem/account-abstraction").SmartAccount | undefined, import("@zerodev/sdk").ZeroDevPaymasterRpcSchema<"0.7">, import("viem/account-abstraction").PaymasterActions & import("@zerodev/sdk").ZeroDevPaymasterClientActions>) => client) => import("viem").Client<import("viem").Transport, Chain | undefined, import("viem/account-abstraction").SmartAccount | undefined, import("@zerodev/sdk").ZeroDevPaymasterRpcSchema<"0.7">, { [K in keyof client]: client[K]; } & import("viem/account-abstraction").PaymasterActions & import("@zerodev/sdk").ZeroDevPaymasterClientActions>;
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=zerodev.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zerodev.d.ts","sourceRoot":"","sources":["../../../../src/lib/environment/zerodev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAclC,eAAO,MAAM,aAAa,qDAAc,CAAC;AACzC,eAAO,MAAM,UAAU,oDAAuB,CAAC;AAG/C,eAAO,MAAM,aAAa,cAA2B,CAAC;AACtD,eAAO,MAAM,mBAAmB,sDAAiC,CAAC;AAElE;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKlD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getZerodevTransport = exports.getZerodevRpc = exports.entryPoint = exports.kernelVersion = void 0;
|
|
4
|
+
exports.createZeroDevPaymaster = createZeroDevPaymaster;
|
|
5
|
+
const sdk_1 = require("@zerodev/sdk");
|
|
6
|
+
const constants_1 = require("@zerodev/sdk/constants");
|
|
7
|
+
const viem_1 = require("viem");
|
|
8
|
+
function getZerodevRpcUrl() {
|
|
9
|
+
const ZERODEV_RPC_URL = process.env.ZERODEV_RPC_URL;
|
|
10
|
+
if (!ZERODEV_RPC_URL) {
|
|
11
|
+
throw new Error('Missing ZERODEV_RPC_URL env variable');
|
|
12
|
+
}
|
|
13
|
+
return ZERODEV_RPC_URL;
|
|
14
|
+
}
|
|
15
|
+
exports.kernelVersion = constants_1.KERNEL_V3_3;
|
|
16
|
+
exports.entryPoint = (0, constants_1.getEntryPoint)('0.7');
|
|
17
|
+
// Lazy getters that only validate when accessed
|
|
18
|
+
const getZerodevRpc = () => getZerodevRpcUrl();
|
|
19
|
+
exports.getZerodevRpc = getZerodevRpc;
|
|
20
|
+
const getZerodevTransport = () => (0, viem_1.http)(getZerodevRpcUrl());
|
|
21
|
+
exports.getZerodevTransport = getZerodevTransport;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a ZeroDev paymaster client for the specified chain.
|
|
24
|
+
* This should be called at runtime with the actual chain object.
|
|
25
|
+
*/
|
|
26
|
+
function createZeroDevPaymaster(chain) {
|
|
27
|
+
return (0, sdk_1.createZeroDevPaymasterClient)({
|
|
28
|
+
chain,
|
|
29
|
+
transport: (0, exports.getZerodevTransport)(),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=zerodev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zerodev.js","sourceRoot":"","sources":["../../../../src/lib/environment/zerodev.ts"],"names":[],"mappings":";;;AAyBA,wDAKC;AA5BD,sCAA4D;AAC5D,sDAAoE;AACpE,+BAA4B;AAE5B,SAAS,gBAAgB;IACvB,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,eAAqC,CAAC;IAC1E,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAEY,QAAA,aAAa,GAAG,uBAAW,CAAC;AAC5B,QAAA,UAAU,GAAG,IAAA,yBAAa,EAAC,KAAK,CAAC,CAAC;AAE/C,gDAAgD;AACzC,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,gBAAgB,EAAE,CAAC;AAAzC,QAAA,aAAa,iBAA4B;AAC/C,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,IAAA,WAAI,EAAC,gBAAgB,EAAE,CAAC,CAAC;AAArD,QAAA,mBAAmB,uBAAkC;AAElE;;;GAGG;AACH,SAAgB,sBAAsB,CAAC,KAAY;IACjD,OAAO,IAAA,kCAA4B,EAAC;QAClC,KAAK;QACL,SAAS,EAAE,IAAA,2BAAmB,GAAE;KACjC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/src/lib/index.d.ts
CHANGED
|
@@ -8,10 +8,11 @@ import * as chain from './chain';
|
|
|
8
8
|
export { chain };
|
|
9
9
|
import * as appManager from './appManager';
|
|
10
10
|
export { appManager };
|
|
11
|
-
export { mintNewPkp } from './mint-new-pkp';
|
|
11
|
+
export { mintNewPkp, type PkpInfo } from './mint-new-pkp';
|
|
12
12
|
export { ensureUnexpiredCapacityToken } from './ensure-capacity-credit';
|
|
13
13
|
export { getEnv } from './env';
|
|
14
14
|
export { getChainHelpers } from './chain';
|
|
15
15
|
export { createRandomVincentWallets } from './create-random-vincent-wallets';
|
|
16
16
|
export { setupVincentDevelopmentEnvironment, type VincentDevEnvironment, } from './setup-vincent-development-environment';
|
|
17
|
+
export { setupZerodevAccount, setupCrossmintAccount, setupSafeAccount, type SmartAccountInfo } from './smartAccount';
|
|
17
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,CAAC;AAEjB,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,CAAC;AAEjB,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EACL,kCAAkC,EAClC,KAAK,qBAAqB,GAC3B,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/src/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setupVincentDevelopmentEnvironment = exports.createRandomVincentWallets = exports.getChainHelpers = exports.getEnv = exports.ensureUnexpiredCapacityToken = exports.mintNewPkp = exports.appManager = exports.chain = exports.funder = exports.delegatee = exports.delegator = void 0;
|
|
3
|
+
exports.setupSafeAccount = exports.setupCrossmintAccount = exports.setupZerodevAccount = exports.setupVincentDevelopmentEnvironment = exports.createRandomVincentWallets = exports.getChainHelpers = exports.getEnv = exports.ensureUnexpiredCapacityToken = exports.mintNewPkp = exports.appManager = exports.chain = exports.funder = exports.delegatee = exports.delegator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const delegator = tslib_1.__importStar(require("./delegator"));
|
|
6
6
|
exports.delegator = delegator;
|
|
@@ -24,4 +24,8 @@ var create_random_vincent_wallets_1 = require("./create-random-vincent-wallets")
|
|
|
24
24
|
Object.defineProperty(exports, "createRandomVincentWallets", { enumerable: true, get: function () { return create_random_vincent_wallets_1.createRandomVincentWallets; } });
|
|
25
25
|
var setup_vincent_development_environment_1 = require("./setup-vincent-development-environment");
|
|
26
26
|
Object.defineProperty(exports, "setupVincentDevelopmentEnvironment", { enumerable: true, get: function () { return setup_vincent_development_environment_1.setupVincentDevelopmentEnvironment; } });
|
|
27
|
+
var smartAccount_1 = require("./smartAccount");
|
|
28
|
+
Object.defineProperty(exports, "setupZerodevAccount", { enumerable: true, get: function () { return smartAccount_1.setupZerodevAccount; } });
|
|
29
|
+
Object.defineProperty(exports, "setupCrossmintAccount", { enumerable: true, get: function () { return smartAccount_1.setupCrossmintAccount; } });
|
|
30
|
+
Object.defineProperty(exports, "setupSafeAccount", { enumerable: true, get: function () { return smartAccount_1.setupSafeAccount; } });
|
|
27
31
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAyC;AAChC,8BAAS;AAElB,+DAAyC;AAChC,8BAAS;AAElB,yDAAmC;AAC1B,wBAAM;AAEf,uDAAiC;AACxB,sBAAK;AAEd,iEAA2C;AAClC,gCAAU;AAEnB,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAyC;AAChC,8BAAS;AAElB,+DAAyC;AAChC,8BAAS;AAElB,yDAAmC;AAC1B,wBAAM;AAEf,uDAAiC;AACxB,sBAAK;AAEd,iEAA2C;AAClC,gCAAU;AAEnB,+CAA0D;AAAjD,0GAAA,UAAU,OAAA;AACnB,mEAAwE;AAA/D,sIAAA,4BAA4B,OAAA;AACrC,6BAA+B;AAAtB,6FAAA,MAAM,OAAA;AACf,iCAA0C;AAAjC,wGAAA,eAAe,OAAA;AACxB,iFAA6E;AAApE,2IAAA,0BAA0B,OAAA;AACnC,iGAGiD;AAF/C,2JAAA,kCAAkC,OAAA;AAIpC,+CAAqH;AAA5G,mHAAA,mBAAmB,OAAA;AAAE,qHAAA,qBAAqB,OAAA;AAAE,gHAAA,gBAAgB,OAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Wallet } from 'ethers';
|
|
2
2
|
import type { PermissionData } from '@lit-protocol/vincent-contracts-sdk';
|
|
3
3
|
import type { PkpInfo } from './mint-new-pkp';
|
|
4
|
+
import type { SmartAccountInfo } from './smartAccount';
|
|
4
5
|
export interface VincentDevEnvironment {
|
|
5
6
|
agentPkpInfo: PkpInfo;
|
|
6
7
|
wallets: {
|
|
@@ -11,6 +12,7 @@ export interface VincentDevEnvironment {
|
|
|
11
12
|
};
|
|
12
13
|
appId: number;
|
|
13
14
|
appVersion: number;
|
|
15
|
+
smartAccount?: SmartAccountInfo;
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
18
|
* Helper function to set up a Vincent development environment.
|
|
@@ -20,9 +22,11 @@ export interface VincentDevEnvironment {
|
|
|
20
22
|
* - Creating or using an existing agent PKP
|
|
21
23
|
* - Setting up permissions for the agent PKP
|
|
22
24
|
* - Ensuring a valid capacity token exists
|
|
25
|
+
* - Optionally creating a smart account owned by agentWalletOwner with the PKP as a permitted signer
|
|
23
26
|
*
|
|
24
27
|
* @param permissionData permission data containing abilities and their policies
|
|
25
|
-
* @
|
|
28
|
+
* @param smartAccountType type of smart account to create: 'zerodev', 'crossmint', 'safe', or false to disable
|
|
29
|
+
* @returns the setup result including agent PKP info, wallets, app ID, app version, and optional smart account info
|
|
26
30
|
* @example
|
|
27
31
|
* ```typescript
|
|
28
32
|
* // Example with no policies
|
|
@@ -40,10 +44,30 @@ export interface VincentDevEnvironment {
|
|
|
40
44
|
* },
|
|
41
45
|
* };
|
|
42
46
|
*
|
|
47
|
+
* // EOA mode
|
|
43
48
|
* const result = await setupVincentDevelopmentEnvironment({ permissionData });
|
|
49
|
+
*
|
|
50
|
+
* // ZeroDev smart account mode (requires SMART_ACCOUNT_CHAIN_ID and ZERODEV_RPC_URL env vars)
|
|
51
|
+
* const result = await setupVincentDevelopmentEnvironment({
|
|
52
|
+
* permissionData,
|
|
53
|
+
* smartAccountType: 'zerodev',
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* // Crossmint smart account mode (requires SMART_ACCOUNT_CHAIN_ID and CROSSMINT_API_KEY env vars)
|
|
57
|
+
* const result = await setupVincentDevelopmentEnvironment({
|
|
58
|
+
* permissionData,
|
|
59
|
+
* smartAccountType: 'crossmint',
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* // Safe smart account mode (requires SMART_ACCOUNT_CHAIN_ID, SAFE_RPC_URL, and PIMLICO_RPC_URL env vars)
|
|
63
|
+
* const result = await setupVincentDevelopmentEnvironment({
|
|
64
|
+
* permissionData,
|
|
65
|
+
* smartAccountType: 'safe',
|
|
66
|
+
* });
|
|
44
67
|
* ```
|
|
45
68
|
*/
|
|
46
|
-
export declare const setupVincentDevelopmentEnvironment: ({ permissionData, }: {
|
|
69
|
+
export declare const setupVincentDevelopmentEnvironment: ({ permissionData, smartAccountType, }: {
|
|
47
70
|
permissionData: PermissionData;
|
|
71
|
+
smartAccountType?: "zerodev" | "crossmint" | "safe";
|
|
48
72
|
}) => Promise<VincentDevEnvironment>;
|
|
49
73
|
//# sourceMappingURL=setup-vincent-development-environment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-vincent-development-environment.d.ts","sourceRoot":"","sources":["../../../src/lib/setup-vincent-development-environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"setup-vincent-development-environment.d.ts","sourceRoot":"","sources":["../../../src/lib/setup-vincent-development-environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAE1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAWvD,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE;QACP,YAAY,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,gBAAgB,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,eAAO,MAAM,kCAAkC,GAAU,uCAGtD;IACD,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,MAAM,CAAC;CACrD,KAAG,OAAO,CAAC,qBAAqB,CAuGhC,CAAC"}
|
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setupVincentDevelopmentEnvironment = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const accounts_1 = require("viem/accounts");
|
|
7
|
+
const viemChains = tslib_1.__importStar(require("viem/chains"));
|
|
5
8
|
const appManager = tslib_1.__importStar(require("./appManager"));
|
|
6
9
|
const chain_1 = require("./chain");
|
|
7
10
|
const delegatee = tslib_1.__importStar(require("./delegatee"));
|
|
8
11
|
const delegator = tslib_1.__importStar(require("./delegator"));
|
|
9
12
|
const ensure_capacity_credit_1 = require("./ensure-capacity-credit");
|
|
13
|
+
const env_1 = require("./env");
|
|
10
14
|
const funder = tslib_1.__importStar(require("./funder"));
|
|
15
|
+
const smartAccount_1 = require("./smartAccount");
|
|
11
16
|
/**
|
|
12
17
|
* Helper function to set up a Vincent development environment.
|
|
13
18
|
* This function handles all the necessary setup steps including:
|
|
@@ -16,9 +21,11 @@ const funder = tslib_1.__importStar(require("./funder"));
|
|
|
16
21
|
* - Creating or using an existing agent PKP
|
|
17
22
|
* - Setting up permissions for the agent PKP
|
|
18
23
|
* - Ensuring a valid capacity token exists
|
|
24
|
+
* - Optionally creating a smart account owned by agentWalletOwner with the PKP as a permitted signer
|
|
19
25
|
*
|
|
20
26
|
* @param permissionData permission data containing abilities and their policies
|
|
21
|
-
* @
|
|
27
|
+
* @param smartAccountType type of smart account to create: 'zerodev', 'crossmint', 'safe', or false to disable
|
|
28
|
+
* @returns the setup result including agent PKP info, wallets, app ID, app version, and optional smart account info
|
|
22
29
|
* @example
|
|
23
30
|
* ```typescript
|
|
24
31
|
* // Example with no policies
|
|
@@ -36,10 +43,29 @@ const funder = tslib_1.__importStar(require("./funder"));
|
|
|
36
43
|
* },
|
|
37
44
|
* };
|
|
38
45
|
*
|
|
46
|
+
* // EOA mode
|
|
39
47
|
* const result = await setupVincentDevelopmentEnvironment({ permissionData });
|
|
48
|
+
*
|
|
49
|
+
* // ZeroDev smart account mode (requires SMART_ACCOUNT_CHAIN_ID and ZERODEV_RPC_URL env vars)
|
|
50
|
+
* const result = await setupVincentDevelopmentEnvironment({
|
|
51
|
+
* permissionData,
|
|
52
|
+
* smartAccountType: 'zerodev',
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* // Crossmint smart account mode (requires SMART_ACCOUNT_CHAIN_ID and CROSSMINT_API_KEY env vars)
|
|
56
|
+
* const result = await setupVincentDevelopmentEnvironment({
|
|
57
|
+
* permissionData,
|
|
58
|
+
* smartAccountType: 'crossmint',
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* // Safe smart account mode (requires SMART_ACCOUNT_CHAIN_ID, SAFE_RPC_URL, and PIMLICO_RPC_URL env vars)
|
|
62
|
+
* const result = await setupVincentDevelopmentEnvironment({
|
|
63
|
+
* permissionData,
|
|
64
|
+
* smartAccountType: 'safe',
|
|
65
|
+
* });
|
|
40
66
|
* ```
|
|
41
67
|
*/
|
|
42
|
-
const setupVincentDevelopmentEnvironment = async ({ permissionData, }) => {
|
|
68
|
+
const setupVincentDevelopmentEnvironment = async ({ permissionData, smartAccountType, }) => {
|
|
43
69
|
// Check and fund all required accounts
|
|
44
70
|
await funder.checkFunderBalance();
|
|
45
71
|
await delegatee.ensureAppDelegateeFunded();
|
|
@@ -78,11 +104,53 @@ const setupVincentDevelopmentEnvironment = async ({ permissionData, }) => {
|
|
|
78
104
|
await delegator.addPermissionForAbilities(wallets.agentWalletOwner, agentPkpInfo.tokenId, abilityIpfsCids);
|
|
79
105
|
// Ensure capacity token is valid and unexpired
|
|
80
106
|
await (0, ensure_capacity_credit_1.ensureUnexpiredCapacityToken)(wallets.appDelegatee);
|
|
107
|
+
// Optionally set up smart account
|
|
108
|
+
let smartAccount;
|
|
109
|
+
if (smartAccountType) {
|
|
110
|
+
console.log(`\n🔧 Setting up ${smartAccountType} smart account...\n`);
|
|
111
|
+
const env = (0, env_1.getEnv)();
|
|
112
|
+
const { SMART_ACCOUNT_CHAIN_ID } = env;
|
|
113
|
+
if (!SMART_ACCOUNT_CHAIN_ID) {
|
|
114
|
+
throw new Error('SMART_ACCOUNT_CHAIN_ID env var is required when smartAccountType is set');
|
|
115
|
+
}
|
|
116
|
+
const chainId = parseInt(SMART_ACCOUNT_CHAIN_ID);
|
|
117
|
+
// Extract chain from viem's exported chains using chainId
|
|
118
|
+
const chains = Object.values(viemChains);
|
|
119
|
+
// Type assertion needed: extractChain expects literal union type but we have runtime value from env
|
|
120
|
+
const chain = (0, viem_1.extractChain)({
|
|
121
|
+
chains,
|
|
122
|
+
id: chainId,
|
|
123
|
+
});
|
|
124
|
+
// Convert ethers wallet to viem account
|
|
125
|
+
const ownerAccount = (0, accounts_1.privateKeyToAccount)(wallets.agentWalletOwner.privateKey);
|
|
126
|
+
if (smartAccountType === 'zerodev') {
|
|
127
|
+
smartAccount = await (0, smartAccount_1.setupZerodevAccount)({
|
|
128
|
+
ownerAccount,
|
|
129
|
+
permittedAddress: agentPkpInfo.ethAddress,
|
|
130
|
+
chain,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
else if (smartAccountType === 'crossmint') {
|
|
134
|
+
smartAccount = await (0, smartAccount_1.setupCrossmintAccount)({
|
|
135
|
+
ownerAccount,
|
|
136
|
+
permittedAddress: agentPkpInfo.ethAddress,
|
|
137
|
+
chain,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
else if (smartAccountType === 'safe') {
|
|
141
|
+
smartAccount = await (0, smartAccount_1.setupSafeAccount)({
|
|
142
|
+
ownerAccount,
|
|
143
|
+
permittedAddress: agentPkpInfo.ethAddress,
|
|
144
|
+
chain,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
81
148
|
return {
|
|
82
149
|
agentPkpInfo,
|
|
83
150
|
wallets,
|
|
84
151
|
appId,
|
|
85
152
|
appVersion,
|
|
153
|
+
smartAccount,
|
|
86
154
|
};
|
|
87
155
|
};
|
|
88
156
|
exports.setupVincentDevelopmentEnvironment = setupVincentDevelopmentEnvironment;
|
|
@@ -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;AAO1C,iEAA2C;AAC3C,mCAA0C;AAC1C,+DAAyC;AACzC,+DAAyC;AACzC,qEAAwE;AACxE,+BAA+B;AAC/B,yDAAmC;AACnC,iDAA8F;AAe9F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;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,OAAO,CAAC;IAErC,MAAM,eAAe,GAAa,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC9D,MAAM,eAAe,GAAe,eAAe,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE;QACzE,OAAO,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,8FAA8F;IAC9F,kFAAkF;IAClF,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,UAAU,EAAE,CAAC;IACjD,IAAI,KAAa,CAAC;IAClB,IAAI,UAAkB,CAAC;IACvB,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,cAAc,CAAC,EAAE,eA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,MAAM;YACN,EAAE,EAAE,OAAwC;SAC7C,CAAC,CAAC;QAEH,wCAAwC;QACxC,MAAM,YAAY,GAAG,IAAA,8BAAmB,EAAC,OAAO,CAAC,gBAAgB,CAAC,UAA2B,CAAC,CAAC;QAE/F,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACnC,YAAY,GAAG,MAAM,IAAA,kCAAmB,EAAC;gBACvC,YAAY;gBACZ,gBAAgB,EAAE,YAAY,CAAC,UAA2B;gBAC1D,KAAK;aACN,CAAC,CAAC;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,OAAO;QACP,KAAK;QACL,UAAU;QACV,YAAY;KACb,CAAC;AACJ,CAAC,CAAC;AA7GW,QAAA,kCAAkC,sCA6G7C"}
|
|
@@ -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,CA8G9D"}
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//# 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,sDAkHC;AAxHD,+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,qBAA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
|
|
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
|