@lit-protocol/vincent-ability-erc20-approval 0.0.7-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.
Files changed (59) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/CONTRIBUTING.md +89 -0
  3. package/README.md +76 -0
  4. package/dist/CHANGELOG.md +14 -0
  5. package/dist/CONTRIBUTING.md +89 -0
  6. package/dist/README.md +76 -0
  7. package/dist/package.json +29 -0
  8. package/dist/src/generated/lit-action.js +9 -0
  9. package/dist/src/generated/vincent-ability-metadata.json +3 -0
  10. package/dist/src/generated/vincent-bundled-ability.d.ts +65 -0
  11. package/dist/src/generated/vincent-bundled-ability.d.ts.map +1 -0
  12. package/dist/src/generated/vincent-bundled-ability.js +15 -0
  13. package/dist/src/generated/vincent-bundled-ability.js.map +1 -0
  14. package/dist/src/generated/vincent-bundled-ability.ts +13 -0
  15. package/dist/src/index.d.ts +3 -0
  16. package/dist/src/index.d.ts.map +1 -0
  17. package/dist/src/index.js +9 -0
  18. package/dist/src/index.js.map +1 -0
  19. package/dist/src/lib/helpers/check-native-token-balance.d.ts +6 -0
  20. package/dist/src/lib/helpers/check-native-token-balance.d.ts.map +1 -0
  21. package/dist/src/lib/helpers/check-native-token-balance.js +9 -0
  22. package/dist/src/lib/helpers/check-native-token-balance.js.map +1 -0
  23. package/dist/src/lib/helpers/get-current-allowance.d.ts +8 -0
  24. package/dist/src/lib/helpers/get-current-allowance.d.ts.map +1 -0
  25. package/dist/src/lib/helpers/get-current-allowance.js +11 -0
  26. package/dist/src/lib/helpers/get-current-allowance.js.map +1 -0
  27. package/dist/src/lib/helpers/getErc20Contract.d.ts +4 -0
  28. package/dist/src/lib/helpers/getErc20Contract.d.ts.map +1 -0
  29. package/dist/src/lib/helpers/getErc20Contract.js +20 -0
  30. package/dist/src/lib/helpers/getErc20Contract.js.map +1 -0
  31. package/dist/src/lib/helpers/index.d.ts +4 -0
  32. package/dist/src/lib/helpers/index.d.ts.map +1 -0
  33. package/dist/src/lib/helpers/index.js +10 -0
  34. package/dist/src/lib/helpers/index.js.map +1 -0
  35. package/dist/src/lib/lit-action-helpers/index.d.ts +3 -0
  36. package/dist/src/lib/lit-action-helpers/index.d.ts.map +1 -0
  37. package/dist/src/lib/lit-action-helpers/index.js +8 -0
  38. package/dist/src/lib/lit-action-helpers/index.js.map +1 -0
  39. package/dist/src/lib/lit-action-helpers/send-erc20-approval-tx.d.ts +10 -0
  40. package/dist/src/lib/lit-action-helpers/send-erc20-approval-tx.d.ts.map +1 -0
  41. package/dist/src/lib/lit-action-helpers/send-erc20-approval-tx.js +94 -0
  42. package/dist/src/lib/lit-action-helpers/send-erc20-approval-tx.js.map +1 -0
  43. package/dist/src/lib/lit-action-helpers/sign-tx.d.ts +3 -0
  44. package/dist/src/lib/lit-action-helpers/sign-tx.d.ts.map +1 -0
  45. package/dist/src/lib/lit-action-helpers/sign-tx.js +28 -0
  46. package/dist/src/lib/lit-action-helpers/sign-tx.js.map +1 -0
  47. package/dist/src/lib/lit-action.d.ts +2 -0
  48. package/dist/src/lib/lit-action.d.ts.map +1 -0
  49. package/dist/src/lib/lit-action.js +16 -0
  50. package/dist/src/lib/lit-action.js.map +1 -0
  51. package/dist/src/lib/schemas.d.ts +67 -0
  52. package/dist/src/lib/schemas.d.ts.map +1 -0
  53. package/dist/src/lib/schemas.js +59 -0
  54. package/dist/src/lib/schemas.js.map +1 -0
  55. package/dist/src/lib/vincent-ability.d.ts +62 -0
  56. package/dist/src/lib/vincent-ability.d.ts.map +1 -0
  57. package/dist/src/lib/vincent-ability.js +99 -0
  58. package/dist/src/lib/vincent-ability.js.map +1 -0
  59. package/package.json +28 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ "ipfsCid": "QmdsUNSuz4T2RLoyJP16QmJAtSvDZbGFHafh14MAePSY7r"
3
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * DO NOT EDIT THIS FILE. IT IS GENERATED ON BUILD.
3
+ */
4
+ export declare const bundledVincentAbility: import("@lit-protocol/vincent-ability-sdk").BundledVincentAbility<import("@lit-protocol/vincent-ability-sdk").VincentAbility<import("zod").ZodObject<{
5
+ rpcUrl: import("zod").ZodString;
6
+ chainId: import("zod").ZodNumber;
7
+ spenderAddress: import("zod").ZodString;
8
+ tokenAddress: import("zod").ZodString;
9
+ tokenDecimals: import("zod").ZodNumber;
10
+ tokenAmount: import("zod").ZodNumber;
11
+ }, "strip", import("zod").ZodTypeAny, {
12
+ tokenAddress: string;
13
+ rpcUrl: string;
14
+ chainId: number;
15
+ spenderAddress: string;
16
+ tokenAmount: number;
17
+ tokenDecimals: number;
18
+ }, {
19
+ tokenAddress: string;
20
+ rpcUrl: string;
21
+ chainId: number;
22
+ spenderAddress: string;
23
+ tokenAmount: number;
24
+ tokenDecimals: number;
25
+ }>, string, import("node_modules/@lit-protocol/vincent-ability-sdk/dist/src/lib/abilityCore/helpers").AbilityPolicyMap<readonly [], never>, {}, import("zod").ZodObject<{
26
+ approvalTxHash: import("zod").ZodOptional<import("zod").ZodString>;
27
+ approvedAmount: import("zod").ZodString;
28
+ tokenAddress: import("zod").ZodString;
29
+ tokenDecimals: import("zod").ZodNumber;
30
+ spenderAddress: import("zod").ZodString;
31
+ }, "strip", import("zod").ZodTypeAny, {
32
+ tokenAddress: string;
33
+ spenderAddress: string;
34
+ tokenDecimals: number;
35
+ approvedAmount: string;
36
+ approvalTxHash?: string | undefined;
37
+ }, {
38
+ tokenAddress: string;
39
+ spenderAddress: string;
40
+ tokenDecimals: number;
41
+ approvedAmount: string;
42
+ approvalTxHash?: string | undefined;
43
+ }>, import("zod").ZodObject<{
44
+ error: import("zod").ZodString;
45
+ }, "strip", import("zod").ZodTypeAny, {
46
+ error: string;
47
+ }, {
48
+ error: string;
49
+ }>, import("zod").ZodObject<{
50
+ alreadyApproved: import("zod").ZodBoolean;
51
+ currentAllowance: import("zod").ZodString;
52
+ }, "strip", import("zod").ZodTypeAny, {
53
+ alreadyApproved: boolean;
54
+ currentAllowance: string;
55
+ }, {
56
+ alreadyApproved: boolean;
57
+ currentAllowance: string;
58
+ }>, import("zod").ZodObject<{
59
+ noNativeTokenBalance: import("zod").ZodBoolean;
60
+ }, "strip", import("zod").ZodTypeAny, {
61
+ noNativeTokenBalance: boolean;
62
+ }, {
63
+ noNativeTokenBalance: boolean;
64
+ }>>, string>;
65
+ //# sourceMappingURL=vincent-bundled-ability.d.ts.map
@@ -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,3 @@
1
+ export { bundledVincentAbility } from './generated/vincent-bundled-ability';
2
+ export { getCurrentAllowance, checkNativeTokenBalance } from './lib/helpers';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -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;AAC5E,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkNativeTokenBalance = exports.getCurrentAllowance = 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
+ var helpers_1 = require("./lib/helpers");
7
+ Object.defineProperty(exports, "getCurrentAllowance", { enumerable: true, get: function () { return helpers_1.getCurrentAllowance; } });
8
+ Object.defineProperty(exports, "checkNativeTokenBalance", { enumerable: true, get: function () { return helpers_1.checkNativeTokenBalance; } });
9
+ //# 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;AAC9B,yCAA6E;AAApE,8GAAA,mBAAmB,OAAA;AAAE,kHAAA,uBAAuB,OAAA"}
@@ -0,0 +1,6 @@
1
+ import { ethers } from 'ethers';
2
+ export declare const checkNativeTokenBalance: ({ provider, pkpEthAddress, }: {
3
+ provider: ethers.providers.Provider;
4
+ pkpEthAddress: string;
5
+ }) => Promise<boolean>;
6
+ //# sourceMappingURL=check-native-token-balance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-native-token-balance.d.ts","sourceRoot":"","sources":["../../../../src/lib/helpers/check-native-token-balance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,eAAO,MAAM,uBAAuB,GAAU,8BAG3C;IACD,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC;CACvB,KAAG,OAAO,CAAC,OAAO,CAIlB,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkNativeTokenBalance = void 0;
4
+ const checkNativeTokenBalance = async ({ provider, pkpEthAddress, }) => {
5
+ const ethBalance = await provider.getBalance(pkpEthAddress);
6
+ return ethBalance.gt(0n);
7
+ };
8
+ exports.checkNativeTokenBalance = checkNativeTokenBalance;
9
+ //# sourceMappingURL=check-native-token-balance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-native-token-balance.js","sourceRoot":"","sources":["../../../../src/lib/helpers/check-native-token-balance.ts"],"names":[],"mappings":";;;AAEO,MAAM,uBAAuB,GAAG,KAAK,EAAE,EAC5C,QAAQ,EACR,aAAa,GAId,EAAoB,EAAE;IACrB,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAE5D,OAAO,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAC3B,CAAC,CAAC;AAVW,QAAA,uBAAuB,2BAUlC"}
@@ -0,0 +1,8 @@
1
+ import { ethers } from 'ethers';
2
+ export declare const getCurrentAllowance: ({ provider, tokenAddress, owner, spender, }: {
3
+ provider: ethers.providers.JsonRpcProvider;
4
+ tokenAddress: string;
5
+ owner: string;
6
+ spender: string;
7
+ }) => Promise<bigint>;
8
+ //# sourceMappingURL=get-current-allowance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-current-allowance.d.ts","sourceRoot":"","sources":["../../../../src/lib/helpers/get-current-allowance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,eAAO,MAAM,mBAAmB,GAAU,6CAKvC;IACD,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC;IAC3C,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,KAAG,OAAO,CAAC,MAAM,CAIjB,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCurrentAllowance = void 0;
4
+ const getErc20Contract_1 = require("../helpers/getErc20Contract");
5
+ const getCurrentAllowance = async ({ provider, tokenAddress, owner, spender, }) => {
6
+ const contract = (0, getErc20Contract_1.getErc20Contract)(tokenAddress, provider);
7
+ const allowance = await contract.allowance(owner, spender);
8
+ return allowance.toBigInt();
9
+ };
10
+ exports.getCurrentAllowance = getCurrentAllowance;
11
+ //# sourceMappingURL=get-current-allowance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-current-allowance.js","sourceRoot":"","sources":["../../../../src/lib/helpers/get-current-allowance.ts"],"names":[],"mappings":";;;AACA,kEAA+D;AAExD,MAAM,mBAAmB,GAAG,KAAK,EAAE,EACxC,QAAQ,EACR,YAAY,EACZ,KAAK,EACL,OAAO,GAMR,EAAmB,EAAE;IACpB,MAAM,QAAQ,GAAG,IAAA,mCAAgB,EAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAC1D,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC3D,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC9B,CAAC,CAAC;AAdW,QAAA,mBAAmB,uBAc9B"}
@@ -0,0 +1,4 @@
1
+ import { ethers } from 'ethers';
2
+ export declare const ERC20_ABI: string[];
3
+ export declare function getErc20Contract(tokenAddress: string, provider: ethers.providers.JsonRpcProvider): ethers.Contract;
4
+ //# sourceMappingURL=getErc20Contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getErc20Contract.d.ts","sourceRoot":"","sources":["../../../../src/lib/helpers/getErc20Contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,eAAO,MAAM,SAAS,UAUrB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC,eAAe,mBAEhG"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ERC20_ABI = void 0;
4
+ exports.getErc20Contract = getErc20Contract;
5
+ const ethers_1 = require("ethers");
6
+ exports.ERC20_ABI = [
7
+ 'function balanceOf(address owner) external view returns (uint256)',
8
+ 'function approve(address spender, uint256 amount) external returns (bool)',
9
+ 'function allowance(address owner, address spender) external view returns (uint256)',
10
+ 'function decimals() view returns (uint8)',
11
+ 'function totalSupply() external view returns (uint256)',
12
+ 'function transfer(address to, uint256 amount) external returns (bool)',
13
+ 'function transferFrom(address from, address to, uint256 amount) external returns (bool)',
14
+ 'function name() external view returns (string)',
15
+ 'function symbol() external view returns (string)',
16
+ ];
17
+ function getErc20Contract(tokenAddress, provider) {
18
+ return new ethers_1.ethers.Contract(tokenAddress, exports.ERC20_ABI, provider);
19
+ }
20
+ //# sourceMappingURL=getErc20Contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getErc20Contract.js","sourceRoot":"","sources":["../../../../src/lib/helpers/getErc20Contract.ts"],"names":[],"mappings":";;;AAcA,4CAEC;AAhBD,mCAAgC;AAEnB,QAAA,SAAS,GAAG;IACvB,mEAAmE;IACnE,2EAA2E;IAC3E,oFAAoF;IACpF,0CAA0C;IAC1C,wDAAwD;IACxD,uEAAuE;IACvE,yFAAyF;IACzF,gDAAgD;IAChD,kDAAkD;CACnD,CAAC;AAEF,SAAgB,gBAAgB,CAAC,YAAoB,EAAE,QAA0C;IAC/F,OAAO,IAAI,eAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,iBAAS,EAAE,QAAQ,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { checkNativeTokenBalance } from './check-native-token-balance';
2
+ export { getErc20Contract } from './getErc20Contract';
3
+ export { getCurrentAllowance } from './get-current-allowance';
4
+ //# 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,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCurrentAllowance = exports.getErc20Contract = exports.checkNativeTokenBalance = void 0;
4
+ var check_native_token_balance_1 = require("./check-native-token-balance");
5
+ Object.defineProperty(exports, "checkNativeTokenBalance", { enumerable: true, get: function () { return check_native_token_balance_1.checkNativeTokenBalance; } });
6
+ var getErc20Contract_1 = require("./getErc20Contract");
7
+ Object.defineProperty(exports, "getErc20Contract", { enumerable: true, get: function () { return getErc20Contract_1.getErc20Contract; } });
8
+ var get_current_allowance_1 = require("./get-current-allowance");
9
+ Object.defineProperty(exports, "getCurrentAllowance", { enumerable: true, get: function () { return get_current_allowance_1.getCurrentAllowance; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/helpers/index.ts"],"names":[],"mappings":";;;AAAA,2EAAuE;AAA9D,qIAAA,uBAAuB,OAAA;AAChC,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,iEAA8D;AAArD,4HAAA,mBAAmB,OAAA"}
@@ -0,0 +1,3 @@
1
+ export { sendErc20ApprovalTx } from './send-erc20-approval-tx';
2
+ export { signTx } from './sign-tx';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/lit-action-helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.signTx = exports.sendErc20ApprovalTx = void 0;
4
+ var send_erc20_approval_tx_1 = require("./send-erc20-approval-tx");
5
+ Object.defineProperty(exports, "sendErc20ApprovalTx", { enumerable: true, get: function () { return send_erc20_approval_tx_1.sendErc20ApprovalTx; } });
6
+ var sign_tx_1 = require("./sign-tx");
7
+ Object.defineProperty(exports, "signTx", { enumerable: true, get: function () { return sign_tx_1.signTx; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/lit-action-helpers/index.ts"],"names":[],"mappings":";;;AAAA,mEAA+D;AAAtD,6HAAA,mBAAmB,OAAA;AAC5B,qCAAmC;AAA1B,iGAAA,MAAM,OAAA"}
@@ -0,0 +1,10 @@
1
+ export declare const sendErc20ApprovalTx: ({ rpcUrl, chainId, pkpEthAddress, pkpPublicKey, spenderAddress, tokenAmount, tokenAddress, }: {
2
+ rpcUrl: string;
3
+ chainId: number;
4
+ pkpEthAddress: string;
5
+ pkpPublicKey: string;
6
+ spenderAddress: string;
7
+ tokenAmount: bigint;
8
+ tokenAddress: string;
9
+ }) => Promise<any>;
10
+ //# sourceMappingURL=send-erc20-approval-tx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-erc20-approval-tx.d.ts","sourceRoot":"","sources":["../../../../src/lib/lit-action-helpers/send-erc20-approval-tx.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,mBAAmB,GAAU,8FAQvC;IACD,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB,iBA2GA,CAAC"}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendErc20ApprovalTx = void 0;
4
+ const ethers_1 = require("ethers");
5
+ const helpers_1 = require("../helpers");
6
+ const sign_tx_1 = require("./sign-tx");
7
+ const sendErc20ApprovalTx = async ({ rpcUrl, chainId, pkpEthAddress, pkpPublicKey, spenderAddress, tokenAmount, tokenAddress, }) => {
8
+ console.log('sendErc20ApprovalTx', {
9
+ rpcUrl,
10
+ chainId,
11
+ pkpEthAddress,
12
+ pkpPublicKey,
13
+ spenderAddress,
14
+ tokenAmount: tokenAmount.toString(),
15
+ tokenAddress,
16
+ });
17
+ const provider = new ethers_1.ethers.providers.JsonRpcProvider(rpcUrl);
18
+ const contract = (0, helpers_1.getErc20Contract)(tokenAddress, provider);
19
+ // Convert bigint to ethers.BigNumber for proper encoding
20
+ const tokenAmountBN = ethers_1.ethers.BigNumber.from(tokenAmount.toString());
21
+ // Encode the approve function call
22
+ const approveTxData = contract.interface.encodeFunctionData('approve', [
23
+ spenderAddress,
24
+ tokenAmountBN,
25
+ ]);
26
+ const txMetadataResponse = await Lit.Actions.runOnce({ waitForResponse: true, name: 'estimateGas' }, async () => {
27
+ try {
28
+ const [feeData, gasLimit, nonce] = await Promise.all([
29
+ provider.getFeeData(),
30
+ provider.estimateGas({
31
+ from: pkpEthAddress,
32
+ to: tokenAddress,
33
+ data: approveTxData,
34
+ }),
35
+ provider.getTransactionCount(pkpEthAddress),
36
+ ]);
37
+ return JSON.stringify({
38
+ status: 'success',
39
+ maxFeePerGas: feeData.maxFeePerGas?.toString() || '0',
40
+ maxPriorityFeePerGas: feeData.maxPriorityFeePerGas?.toString() || '0',
41
+ gas: gasLimit.toString(),
42
+ nonce,
43
+ });
44
+ }
45
+ catch (error) {
46
+ return JSON.stringify({
47
+ status: 'error',
48
+ error: error instanceof Error ? error.message : String(error),
49
+ });
50
+ }
51
+ });
52
+ const parsedTxMetadataResponse = JSON.parse(txMetadataResponse);
53
+ if (parsedTxMetadataResponse.status === 'error') {
54
+ throw new Error(`Error estimating gas: ${parsedTxMetadataResponse.error}`);
55
+ }
56
+ console.log('parsedTxMetadataResponse (sendErc20ApprovalTx)', JSON.stringify(parsedTxMetadataResponse));
57
+ const { maxFeePerGas, maxPriorityFeePerGas, gas, nonce } = parsedTxMetadataResponse;
58
+ const unsignedApproveTx = {
59
+ to: tokenAddress,
60
+ data: approveTxData,
61
+ value: ethers_1.ethers.BigNumber.from(0),
62
+ gasLimit: ethers_1.ethers.BigNumber.from(gas),
63
+ maxFeePerGas: ethers_1.ethers.BigNumber.from(maxFeePerGas),
64
+ maxPriorityFeePerGas: ethers_1.ethers.BigNumber.from(maxPriorityFeePerGas),
65
+ nonce,
66
+ chainId,
67
+ type: 2, // EIP-1559 transaction type
68
+ };
69
+ const signedApproveTx = await (0, sign_tx_1.signTx)(pkpPublicKey, unsignedApproveTx, 'approveErc20Sig');
70
+ console.log('signedApproveTx (sendErc20ApprovalTx)', signedApproveTx);
71
+ const erc20ApproveTxResponse = await Lit.Actions.runOnce({ waitForResponse: true, name: 'spendTxSender' }, async () => {
72
+ try {
73
+ const txResponse = await provider.sendTransaction(signedApproveTx);
74
+ return JSON.stringify({
75
+ status: 'success',
76
+ txHash: txResponse.hash,
77
+ });
78
+ }
79
+ catch (error) {
80
+ return JSON.stringify({
81
+ status: 'error',
82
+ error: error instanceof Error ? error.message : String(error),
83
+ });
84
+ }
85
+ });
86
+ console.log('erc20ApproveTxResponse (sendErc20ApprovalTx)', erc20ApproveTxResponse);
87
+ const parsedErc20ApproveTxResponse = JSON.parse(erc20ApproveTxResponse);
88
+ if (parsedErc20ApproveTxResponse.status === 'error') {
89
+ throw new Error(`Error sending approval transaction: ${parsedErc20ApproveTxResponse.error}`);
90
+ }
91
+ return parsedErc20ApproveTxResponse.txHash;
92
+ };
93
+ exports.sendErc20ApprovalTx = sendErc20ApprovalTx;
94
+ //# sourceMappingURL=send-erc20-approval-tx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-erc20-approval-tx.js","sourceRoot":"","sources":["../../../../src/lib/lit-action-helpers/send-erc20-approval-tx.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAChC,wCAA8C;AAC9C,uCAAmC;AAc5B,MAAM,mBAAmB,GAAG,KAAK,EAAE,EACxC,MAAM,EACN,OAAO,EACP,aAAa,EACb,YAAY,EACZ,cAAc,EACd,WAAW,EACX,YAAY,GASb,EAAE,EAAE;IACH,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE;QACjC,MAA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;IAEzF,OAAO,CAAC,GAAG,CAAC,uCAAuC,EAAE,eAAe,CAAC,CAAC;IAEtE,MAAM,sBAAsB,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,OAAO,CACtD,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,EAChD,KAAK,IAAI,EAAE;QACT,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;YACnE,OAAO,IAAI,CAAC,SAAS,CAAC;gBACpB,MAAM,EAAE,SAAS;gBACjB,MAAM,EAAE,UAAU,CAAC,IAAI;aACxB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,SAAS,CAAC;gBACpB,MAAM,EAAE,OAAO;gBACf,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CACF,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,8CAA8C,EAAE,sBAAsB,CAAC,CAAC;IAEpF,MAAM,4BAA4B,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAgC,CAAC,CAAC;IAClF,IAAI,4BAA4B,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,uCAAuC,4BAA4B,CAAC,KAAK,EAAE,CAAC,CAAC;IAC/F,CAAC;IAED,OAAO,4BAA4B,CAAC,MAAM,CAAC;AAC7C,CAAC,CAAC;AA3HW,QAAA,mBAAmB,uBA2H9B"}
@@ -0,0 +1,3 @@
1
+ import { ethers } from 'ethers';
2
+ export declare const signTx: (pkpPublicKey: string, tx: ethers.Transaction, sigName: string) => Promise<string>;
3
+ //# sourceMappingURL=sign-tx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sign-tx.d.ts","sourceRoot":"","sources":["../../../../src/lib/lit-action-helpers/sign-tx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAYhC,eAAO,MAAM,MAAM,GAAU,cAAc,MAAM,EAAE,IAAI,MAAM,CAAC,WAAW,EAAE,SAAS,MAAM,oBA2BzF,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.signTx = void 0;
4
+ const ethers_1 = require("ethers");
5
+ const signTx = async (pkpPublicKey, tx, sigName) => {
6
+ // Remove 0x prefix if it exists, Lit expects a hex string without 0x prefix
7
+ const publicKeyForLit = pkpPublicKey.replace(/^0x/, '');
8
+ console.log(`Signing using PKP Public Key: ${publicKeyForLit} (signTx)`);
9
+ const unsignedSerializedTx = ethers_1.ethers.utils.serializeTransaction(tx);
10
+ const txHash = ethers_1.ethers.utils.keccak256(unsignedSerializedTx);
11
+ console.log('Tx hash (signTx)', txHash);
12
+ const signatureResponse = await Lit.Actions.signAndCombineEcdsa({
13
+ toSign: ethers_1.ethers.utils.arrayify(txHash),
14
+ publicKey: publicKeyForLit,
15
+ sigName,
16
+ });
17
+ const { r, s, v } = JSON.parse(signatureResponse);
18
+ const ethersJoinedSignature = ethers_1.ethers.utils.joinSignature({
19
+ r: '0x' + r.substring(2),
20
+ s: '0x' + s,
21
+ v: v,
22
+ });
23
+ const signedSerializedTx = ethers_1.ethers.utils.serializeTransaction(tx, ethersJoinedSignature);
24
+ console.log('Signed serialized tx (signTx)', signedSerializedTx);
25
+ return signedSerializedTx;
26
+ };
27
+ exports.signTx = signTx;
28
+ //# sourceMappingURL=sign-tx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sign-tx.js","sourceRoot":"","sources":["../../../../src/lib/lit-action-helpers/sign-tx.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAYzB,MAAM,MAAM,GAAG,KAAK,EAAE,YAAoB,EA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,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,67 @@
1
+ import { z } from 'zod';
2
+ export declare const abilityParamsSchema: z.ZodObject<{
3
+ rpcUrl: z.ZodString;
4
+ chainId: z.ZodNumber;
5
+ spenderAddress: z.ZodString;
6
+ tokenAddress: z.ZodString;
7
+ tokenDecimals: z.ZodNumber;
8
+ tokenAmount: z.ZodNumber;
9
+ }, "strip", z.ZodTypeAny, {
10
+ tokenAddress: string;
11
+ rpcUrl: string;
12
+ chainId: number;
13
+ spenderAddress: string;
14
+ tokenAmount: number;
15
+ tokenDecimals: number;
16
+ }, {
17
+ tokenAddress: string;
18
+ rpcUrl: string;
19
+ chainId: number;
20
+ spenderAddress: string;
21
+ tokenAmount: number;
22
+ tokenDecimals: number;
23
+ }>;
24
+ export declare const precheckSuccessSchema: z.ZodObject<{
25
+ alreadyApproved: z.ZodBoolean;
26
+ currentAllowance: z.ZodString;
27
+ }, "strip", z.ZodTypeAny, {
28
+ alreadyApproved: boolean;
29
+ currentAllowance: string;
30
+ }, {
31
+ alreadyApproved: boolean;
32
+ currentAllowance: string;
33
+ }>;
34
+ export declare const precheckFailSchema: z.ZodObject<{
35
+ noNativeTokenBalance: z.ZodBoolean;
36
+ }, "strip", z.ZodTypeAny, {
37
+ noNativeTokenBalance: boolean;
38
+ }, {
39
+ noNativeTokenBalance: boolean;
40
+ }>;
41
+ export declare const executeSuccessSchema: z.ZodObject<{
42
+ approvalTxHash: z.ZodOptional<z.ZodString>;
43
+ approvedAmount: z.ZodString;
44
+ tokenAddress: z.ZodString;
45
+ tokenDecimals: z.ZodNumber;
46
+ spenderAddress: z.ZodString;
47
+ }, "strip", z.ZodTypeAny, {
48
+ tokenAddress: string;
49
+ spenderAddress: string;
50
+ tokenDecimals: number;
51
+ approvedAmount: string;
52
+ approvalTxHash?: string | undefined;
53
+ }, {
54
+ tokenAddress: string;
55
+ spenderAddress: string;
56
+ tokenDecimals: number;
57
+ approvedAmount: string;
58
+ approvalTxHash?: string | undefined;
59
+ }>;
60
+ export declare const executeFailSchema: z.ZodObject<{
61
+ error: z.ZodString;
62
+ }, "strip", z.ZodTypeAny, {
63
+ error: string;
64
+ }, {
65
+ error: string;
66
+ }>;
67
+ //# 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,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;EAyB9B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;EAShC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;EAI7B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;EAkB/B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;EAE5B,CAAC"}
@@ -0,0 +1,59 @@
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
+ exports.abilityParamsSchema = zod_1.z.object({
6
+ rpcUrl: zod_1.z
7
+ .string()
8
+ .describe('The RPC URL to use for the transaction. Must support the chainId specified.'), // FIXME: This should not be an ability-provided argument
9
+ chainId: zod_1.z
10
+ .number()
11
+ .describe('The chain ID to execute the transaction on. For example: 8453 for Base.'),
12
+ spenderAddress: zod_1.z
13
+ .string()
14
+ .describe('The spender address to approve. For example 0x2626664c2603336E57B271c5C0b26F421741e481 for the Uniswap v3 Swap Router contract on Base.'),
15
+ tokenAddress: zod_1.z
16
+ .string()
17
+ .describe('ERC20 Token address to approve. For example 0x4200000000000000000000000000000000000006 for WETH on Base.'),
18
+ tokenDecimals: zod_1.z
19
+ .number()
20
+ .describe('ERC20 Token to approve decimals. For example 18 for WETH on Base.'),
21
+ tokenAmount: zod_1.z
22
+ .number()
23
+ .gte(0, 'tokenAmount cannot be a negative number')
24
+ .describe('Amount of tokenIn to approve. For example 0.00001 for 0.00001 WETH.'),
25
+ });
26
+ exports.precheckSuccessSchema = zod_1.z.object({
27
+ alreadyApproved: zod_1.z
28
+ .boolean()
29
+ .describe('Boolean indicating if the spender already has sufficient allowance.'),
30
+ currentAllowance: zod_1.z
31
+ .string()
32
+ .describe('The current allowance the spender has for the token, as a string representation of a number.'),
33
+ });
34
+ exports.precheckFailSchema = zod_1.z.object({
35
+ noNativeTokenBalance: zod_1.z
36
+ .boolean()
37
+ .describe('Boolean indicating if the user has enough native token to pay for gas fees.'),
38
+ });
39
+ exports.executeSuccessSchema = zod_1.z.object({
40
+ // Transaction hash if a new approval was created, undefined if existing approval was used
41
+ approvalTxHash: zod_1.z
42
+ .string()
43
+ .optional()
44
+ .describe('Transaction hash if a new approval was created, undefined if existing approval was used'),
45
+ // The approved amount that is now active (either from existing or new approval)
46
+ approvedAmount: zod_1.z
47
+ .string()
48
+ .describe('The approved amount that is now active (either from existing or new approval)'),
49
+ // The token address that was approved
50
+ tokenAddress: zod_1.z.string().describe('The token address that was approved'),
51
+ // The token decimals that was approved
52
+ tokenDecimals: zod_1.z.number().describe('The token decimals that was approved'),
53
+ // The spender address that was approved
54
+ spenderAddress: zod_1.z.string().describe('The spender address that was approved'),
55
+ });
56
+ exports.executeFailSchema = zod_1.z.object({
57
+ error: zod_1.z.string().describe('A string containing the error message if the execution failed.'),
58
+ });
59
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/lib/schemas.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAEX,QAAA,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC1C,MAAM,EAAE,OAAC;SACN,MAAM,EAAE;SACR,QAAQ,CAAC,6EAA6E,CAAC,EAAE,yDAAyD;IACrJ,OAAO,EAAE,OAAC;SACP,MAAM,EAAE;SACR,QAAQ,CAAC,yEAAyE,CAAC;IACtF,cAAc,EAAE,OAAC;SACd,MAAM,EAAE;SACR,QAAQ,CACP,yIAAyI,CAC1I;IAEH,YAAY,EAAE,OAAC;SACZ,MAAM,EAAE;SACR,QAAQ,CACP,0GAA0G,CAC3G;IACH,aAAa,EAAE,OAAC;SACb,MAAM,EAAE;SACR,QAAQ,CAAC,mEAAmE,CAAC;IAChF,WAAW,EAAE,OAAC;SACX,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,yCAAyC,CAAC;SACjD,QAAQ,CAAC,qEAAqE,CAAC;CACnF,CA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