@lit-protocol/vincent-ability-erc20-transfer 0.0.10-mma
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/CONTRIBUTING.md +84 -0
- package/README.md +271 -0
- package/dist/CONTRIBUTING.md +84 -0
- package/dist/README.md +271 -0
- package/dist/package.json +31 -0
- package/dist/src/generated/lit-action.js +9 -0
- package/dist/src/generated/vincent-ability-metadata.json +3 -0
- package/dist/src/generated/vincent-bundled-ability.d.ts +1122 -0
- package/dist/src/generated/vincent-bundled-ability.d.ts.map +1 -0
- package/dist/src/generated/vincent-bundled-ability.js +15 -0
- package/dist/src/generated/vincent-bundled-ability.js.map +1 -0
- package/dist/src/generated/vincent-bundled-ability.ts +13 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib/helpers/commit-allowed-policies.d.ts +15 -0
- package/dist/src/lib/helpers/commit-allowed-policies.d.ts.map +1 -0
- package/dist/src/lib/helpers/commit-allowed-policies.js +37 -0
- package/dist/src/lib/helpers/commit-allowed-policies.js.map +1 -0
- package/dist/src/lib/helpers/execute-operation.d.ts +17 -0
- package/dist/src/lib/helpers/execute-operation.d.ts.map +1 -0
- package/dist/src/lib/helpers/execute-operation.js +54 -0
- package/dist/src/lib/helpers/execute-operation.js.map +1 -0
- package/dist/src/lib/helpers/index.d.ts +50 -0
- package/dist/src/lib/helpers/index.d.ts.map +1 -0
- package/dist/src/lib/helpers/index.js +116 -0
- package/dist/src/lib/helpers/index.js.map +1 -0
- package/dist/src/lib/lit-action.d.ts +2 -0
- package/dist/src/lib/lit-action.d.ts.map +1 -0
- package/dist/src/lib/lit-action.js +16 -0
- package/dist/src/lib/lit-action.js.map +1 -0
- package/dist/src/lib/schemas.d.ts +97 -0
- package/dist/src/lib/schemas.d.ts.map +1 -0
- package/dist/src/lib/schemas.js +73 -0
- package/dist/src/lib/schemas.js.map +1 -0
- package/dist/src/lib/vincent-ability.d.ts +1119 -0
- package/dist/src/lib/vincent-ability.d.ts.map +1 -0
- package/dist/src/lib/vincent-ability.js +190 -0
- package/dist/src/lib/vincent-ability.js.map +1 -0
- package/package.json +30 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vincent-bundled-ability.d.ts","sourceRoot":"","sources":["../../../src/generated/vincent-bundled-ability.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAA4D,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DO NOT EDIT THIS FILE. IT IS GENERATED ON BUILD.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.bundledVincentAbility = void 0;
|
|
7
|
+
const tslib_1 = require("tslib");
|
|
8
|
+
const vincent_ability_sdk_1 = require("@lit-protocol/vincent-ability-sdk");
|
|
9
|
+
const vincent_ability_1 = require("../lib/vincent-ability");
|
|
10
|
+
const vincent_ability_metadata_json_1 = tslib_1.__importDefault(require("./vincent-ability-metadata.json"));
|
|
11
|
+
if (!vincent_ability_metadata_json_1.default.ipfsCid) {
|
|
12
|
+
throw new Error('ipfsCid is not defined in metadata JSON file');
|
|
13
|
+
}
|
|
14
|
+
exports.bundledVincentAbility = (0, vincent_ability_sdk_1.asBundledVincentAbility)(vincent_ability_1.vincentAbility, vincent_ability_metadata_json_1.default.ipfsCid);
|
|
15
|
+
//# sourceMappingURL=vincent-bundled-ability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vincent-bundled-ability.js","sourceRoot":"","sources":["../../../src/generated/vincent-bundled-ability.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,2EAA4E;AAC5E,4DAAwD;AACxD,4GAAuD;AAEvD,IAAG,CAAC,uCAAQ,CAAC,OAAO,EAAE,CAAC;IACrB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;AAClE,CAAC;AAEY,QAAA,qBAAqB,GAAG,IAAA,6CAAuB,EAAC,gCAAc,EAAE,uCAAQ,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DO NOT EDIT THIS FILE. IT IS GENERATED ON BUILD.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { asBundledVincentAbility } from '@lit-protocol/vincent-ability-sdk';
|
|
6
|
+
import { vincentAbility } from '../lib/vincent-ability';
|
|
7
|
+
import metadata from './vincent-ability-metadata.json';
|
|
8
|
+
|
|
9
|
+
if(!metadata.ipfsCid) {
|
|
10
|
+
throw new Error('ipfsCid is not defined in metadata JSON file');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const bundledVincentAbility = asBundledVincentAbility(vincentAbility, metadata.ipfsCid);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bundledVincentAbility = void 0;
|
|
4
|
+
var vincent_bundled_ability_1 = require("./generated/vincent-bundled-ability");
|
|
5
|
+
Object.defineProperty(exports, "bundledVincentAbility", { enumerable: true, get: function () { return vincent_bundled_ability_1.bundledVincentAbility; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,+EAA4E;AAAnE,gIAAA,qBAAqB,OAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface PolicyContext {
|
|
2
|
+
commit?: (params: any) => Promise<any>;
|
|
3
|
+
result?: any;
|
|
4
|
+
}
|
|
5
|
+
interface PoliciesContext {
|
|
6
|
+
allowedPolicies: Record<string, PolicyContext>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Executes commit functions for all allowed policies that support it
|
|
10
|
+
* @param policiesContext - The policies context from the execute function
|
|
11
|
+
* @param abilityName - The ability name for logging purposes
|
|
12
|
+
*/
|
|
13
|
+
export declare function commitAllowedPolicies(policiesContext: PoliciesContext, abilityName?: string): Promise<Record<string, any>>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=commit-allowed-policies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit-allowed-policies.d.ts","sourceRoot":"","sources":["../../../../src/lib/helpers/commit-allowed-policies.ts"],"names":[],"mappings":"AAAA,UAAU,aAAa;IACrB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACvC,MAAM,CAAC,EAAE,GAAG,CAAC;CACd;AAED,UAAU,eAAe;IACvB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAChD;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,eAAe,EAAE,eAAe,EAChC,WAAW,SAAY,GACtB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAgC9B"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.commitAllowedPolicies = commitAllowedPolicies;
|
|
4
|
+
/**
|
|
5
|
+
* Executes commit functions for all allowed policies that support it
|
|
6
|
+
* @param policiesContext - The policies context from the execute function
|
|
7
|
+
* @param abilityName - The ability name for logging purposes
|
|
8
|
+
*/
|
|
9
|
+
async function commitAllowedPolicies(policiesContext, abilityName = 'ability') {
|
|
10
|
+
const commitResults = {};
|
|
11
|
+
if (!policiesContext?.allowedPolicies) {
|
|
12
|
+
console.log(`[${abilityName}] No allowed policies found`);
|
|
13
|
+
return commitResults;
|
|
14
|
+
}
|
|
15
|
+
console.log(`[${abilityName}] Processing policy commits...`);
|
|
16
|
+
for (const [policyName, policyContext] of Object.entries(policiesContext.allowedPolicies)) {
|
|
17
|
+
try {
|
|
18
|
+
if (policyContext?.commit && policyContext?.result) {
|
|
19
|
+
console.log(`[${abilityName}] ✅ Committing policy: ${policyName}`);
|
|
20
|
+
// Extract commit parameters from policy result
|
|
21
|
+
const commitParams = policyContext.result;
|
|
22
|
+
const commitResult = await policyContext.commit(commitParams);
|
|
23
|
+
commitResults[policyName] = commitResult;
|
|
24
|
+
console.log(`[${abilityName}] ✅ Policy ${policyName} commit successful:`, commitResult);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
console.log(`[${abilityName}] ⚠️ Policy ${policyName} missing commit function or result`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
console.error(`[${abilityName}] ❌ Error committing policy ${policyName}: ${error}`);
|
|
32
|
+
commitResults[policyName] = { error: error.message };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return commitResults;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=commit-allowed-policies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit-allowed-policies.js","sourceRoot":"","sources":["../../../../src/lib/helpers/commit-allowed-policies.ts"],"names":[],"mappings":";;AAcA,sDAmCC;AAxCD;;;;GAIG;AACI,KAAK,UAAU,qBAAqB,CACzC,eAAgC,EAChC,WAAW,GAAG,SAAS;IAEvB,MAAM,aAAa,GAAwB,EAAE,CAAC;IAE9C,IAA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|
3
|
+
*/
|
|
4
|
+
export declare function executeOperation({ provider, pkpPublicKey, callerAddress, contractAddress, functionName, args, chainId, abi, alchemyGasSponsor, alchemyGasSponsorApiKey, alchemyGasSponsorPolicyId, }: {
|
|
5
|
+
provider?: any;
|
|
6
|
+
pkpPublicKey: string;
|
|
7
|
+
callerAddress: string;
|
|
8
|
+
contractAddress: string;
|
|
9
|
+
functionName: string;
|
|
10
|
+
args: any[];
|
|
11
|
+
chainId: number;
|
|
12
|
+
abi: any;
|
|
13
|
+
alchemyGasSponsor?: boolean;
|
|
14
|
+
alchemyGasSponsorApiKey?: string;
|
|
15
|
+
alchemyGasSponsorPolicyId?: string;
|
|
16
|
+
}): Promise<string>;
|
|
17
|
+
//# sourceMappingURL=execute-operation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-operation.d.ts","sourceRoot":"","sources":["../../../../src/lib/helpers/execute-operation.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,eAAe,EACf,YAAY,EACZ,IAAI,EACJ,OAAO,EACP,GAAG,EACH,iBAAiB,EACjB,uBAAuB,EACvB,yBAAyB,GAC1B,EAAE;IACD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,GAAG,CAAC;IACT,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACpC,GAAG,OAAO,CAAC,MAAM,CAAC,CA4DlB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeOperation = executeOperation;
|
|
4
|
+
const vincent_scaffold_sdk_1 = require("@lit-protocol/vincent-scaffold-sdk");
|
|
5
|
+
/**
|
|
6
|
+
* Generic function to execute any ERC20 operation, with optional gas sponsorship
|
|
7
|
+
*/
|
|
8
|
+
async function executeOperation({ provider, pkpPublicKey, callerAddress, contractAddress, functionName, args, chainId, abi, alchemyGasSponsor, alchemyGasSponsorApiKey, alchemyGasSponsorPolicyId, }) {
|
|
9
|
+
console.log(`[@lit-protocol/vincent-ability-morpho/executeMorphoOperation] Starting ${functionName} operation`, { sponsored: !!alchemyGasSponsor });
|
|
10
|
+
// Use gas sponsorship if enabled and all required parameters are provided
|
|
11
|
+
if (alchemyGasSponsor && alchemyGasSponsorApiKey && alchemyGasSponsorPolicyId) {
|
|
12
|
+
console.log(`[@lit-protocol/vincent-ability-morpho/executeMorphoOperation] Using EIP-7702 gas sponsorship`, { callerAddress, contractAddress, functionName, args, policyId: alchemyGasSponsorPolicyId });
|
|
13
|
+
try {
|
|
14
|
+
return await vincent_scaffold_sdk_1.laUtils.transaction.handler.sponsoredGasContractCall({
|
|
15
|
+
pkpPublicKey,
|
|
16
|
+
abi,
|
|
17
|
+
contractAddress,
|
|
18
|
+
functionName,
|
|
19
|
+
args,
|
|
20
|
+
chainId,
|
|
21
|
+
eip7702AlchemyApiKey: alchemyGasSponsorApiKey,
|
|
22
|
+
eip7702AlchemyPolicyId: alchemyGasSponsorPolicyId,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
console.error(`[@lit-protocol/vincent-ability-morpho/executeMorphoOperation] EIP-7702 operation failed:`, error);
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// Use regular transaction without gas sponsorship
|
|
32
|
+
console.log(`[@lit-protocol/vincent-ability-morpho/executeMorphoOperation] Using regular transaction`);
|
|
33
|
+
if (!provider) {
|
|
34
|
+
throw new Error('Provider is required for non-sponsored transactions');
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
return await vincent_scaffold_sdk_1.laUtils.transaction.handler.contractCall({
|
|
38
|
+
provider,
|
|
39
|
+
pkpPublicKey,
|
|
40
|
+
callerAddress,
|
|
41
|
+
abi,
|
|
42
|
+
contractAddress,
|
|
43
|
+
functionName,
|
|
44
|
+
args,
|
|
45
|
+
chainId,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error(`[@lit-protocol/vincent-ability-morpho/executeMorphoOperation] Regular transaction failed:`, error);
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=execute-operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-operation.js","sourceRoot":"","sources":["../../../../src/lib/helpers/execute-operation.ts"],"names":[],"mappings":";;AAKA,4CAoFC;AAzFD,6EAA6D;AAE7D;;GAEG;AACI,KAAK,UAAU,gBAAgB,CAAC,EACrC,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,eAAe,EACf,YAAY,EACZ,IAAI,EACJ,OAAO,EACP,GAAG,EACH,iBAAiB,EACjB,uBAAuB,EACvB,yBAAyB,GAa1B;IACC,OAAO,CAAC,GAAG,CACT,0EAA0E,YAAY,YAAY,EAClG,EAAE,SAAS,EAAE,CAAC,CAAC,iBAAiB,EAAE,CACnC,CAAC;IAEF,0EAA0E;IAC1E,IAAI,iBAAiB,IAAI,uBAAuB,IAAI,yBAAyB,EAAE,CAAC;QAC9E,OAAO,CAAC,GAAG,CACT,8FAA8F,EAC9F,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,yBAAyB,EAAE,CAC5F,CAAC;QAEF,IAAI,CAAC;YACH,OAAO,MAAM,8BAAO,CAAC,WAAW,CAAC,OAAO,CAAC,wBAAwB,CAAC;gBAChE,YAAY;gBACZ,GAAG;gBACH,eAAe;gBACf,YAAY;gBACZ,IAAI;gBACJ,OAAO;gBACP,oBAAoB,EAAE,uBAAuB;gBAC7C,sBAAsB,EAAE,yBAAyB;aAClD,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CACX,0FAA0F,EAC1F,KAAK,CACN,CAAC;YACF,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;SAAM,CAAC;QACN,kDAAkD;QAClD,OAAO,CAAC,GAAG,CACT,yFAAyF,CAC1F,CAAC;QAEF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;QACzE,CAAC;QAED,IAAI,CAAC;YACH,OAAO,MAAM,8BAAO,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC;gBACpD,QAAQ;gBACR,YAAY;gBACZ,aAAa;gBACb,GAAG;gBACH,eAAe;gBACf,YAAY;gBACZ,IAAI;gBACJ,OAAO;aACR,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CACX,2FAA2F,EAC3F,KAAK,CACN,CAAC;YACF,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
/**
|
|
3
|
+
* ERC-20 helper functions and ABI definitions
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Standard partial ERC-20 ABI
|
|
7
|
+
*/
|
|
8
|
+
export declare const ERC20_ABI: {
|
|
9
|
+
constant: boolean;
|
|
10
|
+
inputs: {
|
|
11
|
+
name: string;
|
|
12
|
+
type: string;
|
|
13
|
+
}[];
|
|
14
|
+
name: string;
|
|
15
|
+
outputs: {
|
|
16
|
+
name: string;
|
|
17
|
+
type: string;
|
|
18
|
+
}[];
|
|
19
|
+
payable: boolean;
|
|
20
|
+
stateMutability: string;
|
|
21
|
+
type: string;
|
|
22
|
+
}[];
|
|
23
|
+
/**
|
|
24
|
+
* Creates and returns an instance of an ERC-20 contract connected to the given address and provider.
|
|
25
|
+
*
|
|
26
|
+
* @param provider - The JSON-RPC provider to connect to the blockchain.
|
|
27
|
+
* @param address - The address of the ERC-20 contract.
|
|
28
|
+
* @return An instance of the ethers.js Contract representing the ERC-20 token contract.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getErc20Contract(provider: ethers.providers.JsonRpcProvider, address: string): ethers.Contract;
|
|
31
|
+
/**
|
|
32
|
+
* Parse amount string to wei units for ERC-20 tokens
|
|
33
|
+
* @param amount - Amount as string (e.g., "1.5")
|
|
34
|
+
* @param decimals - Token decimals (default 18)
|
|
35
|
+
* @returns Amount in wei as string
|
|
36
|
+
*/
|
|
37
|
+
export declare function parseTokenAmount(amount: string, decimals?: number): string;
|
|
38
|
+
/**
|
|
39
|
+
* Validate Ethereum address format
|
|
40
|
+
* @param address - Address to validate
|
|
41
|
+
* @returns True if valid, false otherwise
|
|
42
|
+
*/
|
|
43
|
+
export declare function isValidAddress(address: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Validate amount format and ensure it's positive
|
|
46
|
+
* @param amount - Amount string to validate
|
|
47
|
+
* @returns True if valid, false otherwise
|
|
48
|
+
*/
|
|
49
|
+
export declare function isValidAmount(amount: string): boolean;
|
|
50
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;GAyDrB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC,eAAe,EAAE,OAAO,EAAE,MAAM,mBAE3F;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,SAAK,GAAG,MAAM,CAKtE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAKrD"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ERC20_ABI = void 0;
|
|
4
|
+
exports.getErc20Contract = getErc20Contract;
|
|
5
|
+
exports.parseTokenAmount = parseTokenAmount;
|
|
6
|
+
exports.isValidAddress = isValidAddress;
|
|
7
|
+
exports.isValidAmount = isValidAmount;
|
|
8
|
+
const ethers_1 = require("ethers");
|
|
9
|
+
/**
|
|
10
|
+
* ERC-20 helper functions and ABI definitions
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Standard partial ERC-20 ABI
|
|
14
|
+
*/
|
|
15
|
+
exports.ERC20_ABI = [
|
|
16
|
+
{
|
|
17
|
+
constant: false,
|
|
18
|
+
inputs: [
|
|
19
|
+
{
|
|
20
|
+
name: '_to',
|
|
21
|
+
type: 'address',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: '_value',
|
|
25
|
+
type: 'uint256',
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
name: 'transfer',
|
|
29
|
+
outputs: [
|
|
30
|
+
{
|
|
31
|
+
name: '',
|
|
32
|
+
type: 'bool',
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
payable: false,
|
|
36
|
+
stateMutability: 'nonpayable',
|
|
37
|
+
type: 'function',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
constant: true,
|
|
41
|
+
inputs: [
|
|
42
|
+
{
|
|
43
|
+
name: '_owner',
|
|
44
|
+
type: 'address',
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
name: 'balanceOf',
|
|
48
|
+
outputs: [
|
|
49
|
+
{
|
|
50
|
+
name: 'balance',
|
|
51
|
+
type: 'uint256',
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
payable: false,
|
|
55
|
+
stateMutability: 'view',
|
|
56
|
+
type: 'function',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
constant: true,
|
|
60
|
+
inputs: [],
|
|
61
|
+
name: 'decimals',
|
|
62
|
+
outputs: [
|
|
63
|
+
{
|
|
64
|
+
name: '',
|
|
65
|
+
type: 'uint8',
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
payable: false,
|
|
69
|
+
stateMutability: 'view',
|
|
70
|
+
type: 'function',
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
/**
|
|
74
|
+
* Creates and returns an instance of an ERC-20 contract connected to the given address and provider.
|
|
75
|
+
*
|
|
76
|
+
* @param provider - The JSON-RPC provider to connect to the blockchain.
|
|
77
|
+
* @param address - The address of the ERC-20 contract.
|
|
78
|
+
* @return An instance of the ethers.js Contract representing the ERC-20 token contract.
|
|
79
|
+
*/
|
|
80
|
+
function getErc20Contract(provider, address) {
|
|
81
|
+
return new ethers_1.ethers.Contract(address, exports.ERC20_ABI, provider);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Parse amount string to wei units for ERC-20 tokens
|
|
85
|
+
* @param amount - Amount as string (e.g., "1.5")
|
|
86
|
+
* @param decimals - Token decimals (default 18)
|
|
87
|
+
* @returns Amount in wei as string
|
|
88
|
+
*/
|
|
89
|
+
function parseTokenAmount(amount, decimals = 18) {
|
|
90
|
+
const amountFloat = parseFloat(amount);
|
|
91
|
+
const multiplier = Math.pow(10, decimals);
|
|
92
|
+
const weiAmount = Math.floor(amountFloat * multiplier);
|
|
93
|
+
return weiAmount.toString();
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Validate Ethereum address format
|
|
97
|
+
* @param address - Address to validate
|
|
98
|
+
* @returns True if valid, false otherwise
|
|
99
|
+
*/
|
|
100
|
+
function isValidAddress(address) {
|
|
101
|
+
return /^0x[a-fA-F0-9]{40}$/.test(address);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Validate amount format and ensure it's positive
|
|
105
|
+
* @param amount - Amount string to validate
|
|
106
|
+
* @returns True if valid, false otherwise
|
|
107
|
+
*/
|
|
108
|
+
function isValidAmount(amount) {
|
|
109
|
+
if (!amount || typeof amount !== 'string')
|
|
110
|
+
return false;
|
|
111
|
+
if (!/^\d*\.?\d+$/.test(amount))
|
|
112
|
+
return false;
|
|
113
|
+
const parsed = parseFloat(amount);
|
|
114
|
+
return !isNaN(parsed) && parsed > 0;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/helpers/index.ts"],"names":[],"mappings":";;;AA2EA,4CAEC;AAQD,4CAKC;AAOD,wCAEC;AAOD,sCAKC;AA/GD,mCAAgC;AAEhC;;GAEG;AAEH;;GAEG;AACU,QAAA,SAAS,GAAG;IACvB;QACE,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,KAAK;gBACX,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS;aAChB;SACF;QACD,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,MAAM;aACb;SACF;QACD,OAAO,EAAE,KAAK;QACd,eAAe,EAAE,YAAY;QAC7B,IAAI,EAAE,UAAU;KACjB;IACD;QACE,QAAQ,E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K,QAAQ;QAAE,OAAO,KAAK,CAAC;IACxD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAC9C,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lit-action.d.ts","sourceRoot":"","sources":["../../../src/lib/lit-action.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vincent_ability_sdk_1 = require("@lit-protocol/vincent-ability-sdk");
|
|
4
|
+
// FIXME: This should be generated code
|
|
5
|
+
const vincent_ability_1 = require("./vincent-ability");
|
|
6
|
+
(async () => {
|
|
7
|
+
const func = (0, vincent_ability_sdk_1.vincentAbilityHandler)({
|
|
8
|
+
vincentAbility: vincent_ability_1.vincentAbility,
|
|
9
|
+
context: {
|
|
10
|
+
delegatorPkpEthAddress: context.delegatorPkpEthAddress,
|
|
11
|
+
},
|
|
12
|
+
abilityParams,
|
|
13
|
+
});
|
|
14
|
+
await func();
|
|
15
|
+
})();
|
|
16
|
+
//# sourceMappingURL=lit-action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lit-action.js","sourceRoot":"","sources":["../../../src/lib/lit-action.ts"],"names":[],"mappings":";;AAAA,2EAA0E;AAG1E,uCAAuC;AAEvC,uDAAmD;AAQnD,CAAC,KAAK,IAAI,EAAE;IACV,MAAM,IAAI,GAAG,IAAA,2CAAqB,EAAC;QACjC,cAAc,EAAE,gCAAc;QAC9B,OAAO,EAAE;YACP,sBAAsB,EAAE,OAAO,CAAC,sBAAsB;SACvD;QACD,aAAa;KACd,CAAC,CAAC;IACH,MAAM,IAAI,EAAE,CAAC;AACf,CAAC,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Ability parameters schema - defines the input parameters for the ERC-20 transfer ability
|
|
4
|
+
*/
|
|
5
|
+
export declare const abilityParamsSchema: z.ZodObject<{
|
|
6
|
+
to: z.ZodString;
|
|
7
|
+
amount: z.ZodEffects<z.ZodString, string, string>;
|
|
8
|
+
tokenAddress: z.ZodString;
|
|
9
|
+
chain: z.ZodString;
|
|
10
|
+
rpcUrl: z.ZodString;
|
|
11
|
+
alchemyGasSponsor: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
12
|
+
alchemyGasSponsorApiKey: z.ZodOptional<z.ZodString>;
|
|
13
|
+
alchemyGasSponsorPolicyId: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
alchemyGasSponsor: boolean;
|
|
16
|
+
to: string;
|
|
17
|
+
amount: string;
|
|
18
|
+
tokenAddress: string;
|
|
19
|
+
chain: string;
|
|
20
|
+
rpcUrl: string;
|
|
21
|
+
alchemyGasSponsorApiKey?: string | undefined;
|
|
22
|
+
alchemyGasSponsorPolicyId?: string | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
to: string;
|
|
25
|
+
amount: string;
|
|
26
|
+
tokenAddress: string;
|
|
27
|
+
chain: string;
|
|
28
|
+
rpcUrl: string;
|
|
29
|
+
alchemyGasSponsor?: boolean | undefined;
|
|
30
|
+
alchemyGasSponsorApiKey?: string | undefined;
|
|
31
|
+
alchemyGasSponsorPolicyId?: string | undefined;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Precheck success result schema
|
|
35
|
+
*/
|
|
36
|
+
export declare const precheckSuccessSchema: z.ZodObject<{
|
|
37
|
+
addressValid: z.ZodBoolean;
|
|
38
|
+
amountValid: z.ZodBoolean;
|
|
39
|
+
tokenAddressValid: z.ZodBoolean;
|
|
40
|
+
estimatedGas: z.ZodString;
|
|
41
|
+
userBalance: z.ZodString;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
addressValid: boolean;
|
|
44
|
+
amountValid: boolean;
|
|
45
|
+
tokenAddressValid: boolean;
|
|
46
|
+
estimatedGas: string;
|
|
47
|
+
userBalance: string;
|
|
48
|
+
}, {
|
|
49
|
+
addressValid: boolean;
|
|
50
|
+
amountValid: boolean;
|
|
51
|
+
tokenAddressValid: boolean;
|
|
52
|
+
estimatedGas: string;
|
|
53
|
+
userBalance: string;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* Precheck failure result schema
|
|
57
|
+
*/
|
|
58
|
+
export declare const precheckFailSchema: z.ZodObject<{
|
|
59
|
+
error: z.ZodString;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
error: string;
|
|
62
|
+
}, {
|
|
63
|
+
error: string;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Execute success result schema
|
|
67
|
+
*/
|
|
68
|
+
export declare const executeSuccessSchema: z.ZodObject<{
|
|
69
|
+
txHash: z.ZodString;
|
|
70
|
+
to: z.ZodString;
|
|
71
|
+
amount: z.ZodString;
|
|
72
|
+
tokenAddress: z.ZodString;
|
|
73
|
+
timestamp: z.ZodNumber;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
to: string;
|
|
76
|
+
amount: string;
|
|
77
|
+
tokenAddress: string;
|
|
78
|
+
txHash: string;
|
|
79
|
+
timestamp: number;
|
|
80
|
+
}, {
|
|
81
|
+
to: string;
|
|
82
|
+
amount: string;
|
|
83
|
+
tokenAddress: string;
|
|
84
|
+
txHash: string;
|
|
85
|
+
timestamp: number;
|
|
86
|
+
}>;
|
|
87
|
+
/**
|
|
88
|
+
* Execute failure result schema
|
|
89
|
+
*/
|
|
90
|
+
export declare const executeFailSchema: z.ZodObject<{
|
|
91
|
+
error: z.ZodString;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
error: string;
|
|
94
|
+
}, {
|
|
95
|
+
error: string;
|
|
96
|
+
}>;
|
|
97
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/lib/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgC9B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;EAMhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;EAE7B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;EAM/B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;EAE5B,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeFailSchema = exports.executeSuccessSchema = exports.precheckFailSchema = exports.precheckSuccessSchema = exports.abilityParamsSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* Ability parameters schema - defines the input parameters for the ERC-20 transfer ability
|
|
7
|
+
*/
|
|
8
|
+
exports.abilityParamsSchema = zod_1.z.object({
|
|
9
|
+
to: zod_1.z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^0x[a-fA-F0-9]{40}$/, 'Invalid Ethereum address')
|
|
12
|
+
.describe("The recipient's Ethereum address. On 0x123... format"),
|
|
13
|
+
amount: zod_1.z
|
|
14
|
+
.string()
|
|
15
|
+
.regex(/^\d*\.?\d+$/, 'Invalid amount format')
|
|
16
|
+
.refine((val) => parseFloat(val) > 0, 'Amount must be greater than 0')
|
|
17
|
+
.describe('The amount of tokens to transfer, as a string (supports decimals. Example: 1.23)'),
|
|
18
|
+
tokenAddress: zod_1.z
|
|
19
|
+
.string()
|
|
20
|
+
.regex(/^0x[a-fA-F0-9]{40}$/, 'Invalid token contract address')
|
|
21
|
+
.describe('The ERC-20 token contract address to transfer'),
|
|
22
|
+
chain: zod_1.z
|
|
23
|
+
.string()
|
|
24
|
+
.describe('The blockchain network where the erc20 token is deployed and be transferred'),
|
|
25
|
+
rpcUrl: zod_1.z.string().describe('RPC URL used for precheck validations'),
|
|
26
|
+
// Gas sponsorship parameters for EIP-7702
|
|
27
|
+
alchemyGasSponsor: zod_1.z
|
|
28
|
+
.boolean()
|
|
29
|
+
.optional()
|
|
30
|
+
.default(false)
|
|
31
|
+
.describe("Whether to use Alchemy's gas sponsorship (EIP-7702)"),
|
|
32
|
+
alchemyGasSponsorApiKey: zod_1.z
|
|
33
|
+
.string()
|
|
34
|
+
.optional()
|
|
35
|
+
.describe('Alchemy API key for gas sponsorship (required if alchemyGasSponsor is true)'),
|
|
36
|
+
alchemyGasSponsorPolicyId: zod_1.z
|
|
37
|
+
.string()
|
|
38
|
+
.optional()
|
|
39
|
+
.describe('Alchemy gas policy ID for sponsorship (required if alchemyGasSponsor is true)'),
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Precheck success result schema
|
|
43
|
+
*/
|
|
44
|
+
exports.precheckSuccessSchema = zod_1.z.object({
|
|
45
|
+
addressValid: zod_1.z.boolean().describe('Whether the recipient address is valid'),
|
|
46
|
+
amountValid: zod_1.z.boolean().describe('Whether the specified amount is valid'),
|
|
47
|
+
tokenAddressValid: zod_1.z.boolean().describe('Whether the token contract address is valid'),
|
|
48
|
+
estimatedGas: zod_1.z.string().describe('Estimated gas cost for the token transfer'),
|
|
49
|
+
userBalance: zod_1.z.string().describe('The user balance of the token'),
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Precheck failure result schema
|
|
53
|
+
*/
|
|
54
|
+
exports.precheckFailSchema = zod_1.z.object({
|
|
55
|
+
error: zod_1.z.string().describe('A string containing the error message if the precheck failed.'),
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Execute success result schema
|
|
59
|
+
*/
|
|
60
|
+
exports.executeSuccessSchema = zod_1.z.object({
|
|
61
|
+
txHash: zod_1.z.string().describe('The transaction hash of the executed transfer'),
|
|
62
|
+
to: zod_1.z.string().describe('The recipient address of the transfer'),
|
|
63
|
+
amount: zod_1.z.string().describe('The amount of tokens transferred'),
|
|
64
|
+
tokenAddress: zod_1.z.string().describe('The ERC-20 token contract address used for the transfer'),
|
|
65
|
+
timestamp: zod_1.z.number().describe('The Unix timestamp when the transfer was executed'),
|
|
66
|
+
});
|
|
67
|
+
/**
|
|
68
|
+
* Execute failure result schema
|
|
69
|
+
*/
|
|
70
|
+
exports.executeFailSchema = zod_1.z.object({
|
|
71
|
+
error: zod_1.z.string().describe('A string containing the error message if the execution failed.'),
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/lib/schemas.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB;;GAEG;AACU,QAAA,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC1C,EAAE,EAAE,OAAC;SACF,MAAM,EAAE;SACR,KAAK,CAAC,qBAAqB,EAAE,0BAA0B,CAAC;SACxD,QAAQ,CAAC,sDAAsD,CAAC;IACnE,MAAM,EAAE,OAAC;SACN,MAAM,EAAE;SACR,KAAK,CAAC,aAAa,EAAE,uBAAuB,CAAC;SAC7C,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,+BAA+B,CAAC;SACrE,QAAQ,CAAC,kFAAkF,CAAC;IAC/F,YAAY,EAAE,OAAC;SACZ,MAAM,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