@lit-protocol/vincent-ability-uniswap-swap 2.0.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +94 -83
- package/dist/CHANGELOG.md +15 -0
- package/dist/README.md +94 -83
- package/dist/package.json +6 -4
- package/dist/src/generated/lit-action-prepare.js +9 -0
- package/dist/src/generated/lit-action.js +2 -2
- package/dist/src/generated/vincent-ability-metadata.json +1 -1
- package/dist/src/generated/vincent-bundled-ability.d.ts +132 -946
- package/dist/src/generated/vincent-bundled-ability.d.ts.map +1 -1
- package/dist/src/generated/vincent-prepare-metadata.json +6 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/ability-checks/check-token-in-balance.d.ts +1 -1
- package/dist/src/lib/ability-checks/check-token-in-balance.d.ts.map +1 -1
- package/dist/src/lib/ability-checks/check-token-in-balance.js.map +1 -1
- package/dist/src/lib/ability-checks/index.d.ts +0 -1
- package/dist/src/lib/ability-checks/index.d.ts.map +1 -1
- package/dist/src/lib/ability-checks/index.js +0 -1
- package/dist/src/lib/ability-checks/index.js.map +1 -1
- package/dist/src/lib/ability-helpers/get-gas-params.d.ts +1 -1
- package/dist/src/lib/ability-helpers/get-gas-params.d.ts.map +1 -1
- package/dist/src/lib/ability-helpers/get-gas-params.js +5 -3
- package/dist/src/lib/ability-helpers/get-gas-params.js.map +1 -1
- package/dist/src/lib/ability-helpers/get-uniswap-quote.d.ts +6 -11
- package/dist/src/lib/ability-helpers/get-uniswap-quote.d.ts.map +1 -1
- package/dist/src/lib/ability-helpers/get-uniswap-quote.js +59 -104
- package/dist/src/lib/ability-helpers/get-uniswap-quote.js.map +1 -1
- package/dist/src/lib/ability-helpers/index.d.ts +0 -4
- package/dist/src/lib/ability-helpers/index.d.ts.map +1 -1
- package/dist/src/lib/ability-helpers/index.js +0 -4
- package/dist/src/lib/ability-helpers/index.js.map +1 -1
- package/dist/src/lib/ability-helpers/send-uniswap-tx.d.ts +8 -8
- package/dist/src/lib/ability-helpers/send-uniswap-tx.d.ts.map +1 -1
- package/dist/src/lib/ability-helpers/send-uniswap-tx.js +25 -53
- package/dist/src/lib/ability-helpers/send-uniswap-tx.js.map +1 -1
- package/dist/src/lib/prepare/get-signed-uniswap-quote.d.ts +9 -0
- package/dist/src/lib/prepare/get-signed-uniswap-quote.d.ts.map +1 -0
- package/dist/src/lib/prepare/get-signed-uniswap-quote.js +56 -0
- package/dist/src/lib/prepare/get-signed-uniswap-quote.js.map +1 -0
- package/dist/src/lib/prepare/lit-action.d.ts +2 -0
- package/dist/src/lib/prepare/lit-action.d.ts.map +1 -0
- package/dist/src/lib/prepare/lit-action.js +87 -0
- package/dist/src/lib/prepare/lit-action.js.map +1 -0
- package/dist/src/lib/prepare/types.d.ts +48 -0
- package/dist/src/lib/prepare/types.d.ts.map +1 -0
- package/dist/src/lib/prepare/types.js +3 -0
- package/dist/src/lib/prepare/types.js.map +1 -0
- package/dist/src/lib/prepare/validate-signed-uniswap-quote.d.ts +6 -0
- package/dist/src/lib/prepare/validate-signed-uniswap-quote.d.ts.map +1 -0
- package/dist/src/lib/prepare/validate-signed-uniswap-quote.js +22 -0
- package/dist/src/lib/prepare/validate-signed-uniswap-quote.js.map +1 -0
- package/dist/src/lib/schemas.d.ts +133 -62
- package/dist/src/lib/schemas.d.ts.map +1 -1
- package/dist/src/lib/schemas.js +26 -41
- package/dist/src/lib/schemas.js.map +1 -1
- package/dist/src/lib/vincent-ability.d.ts +132 -946
- package/dist/src/lib/vincent-ability.d.ts.map +1 -1
- package/dist/src/lib/vincent-ability.js +52 -122
- package/dist/src/lib/vincent-ability.js.map +1 -1
- package/package.json +8 -6
- package/dist/src/lib/ability-checks/check-uniswap-pool-exists.d.ts +0 -10
- package/dist/src/lib/ability-checks/check-uniswap-pool-exists.d.ts.map +0 -1
- package/dist/src/lib/ability-checks/check-uniswap-pool-exists.js +0 -24
- package/dist/src/lib/ability-checks/check-uniswap-pool-exists.js.map +0 -1
- package/dist/src/lib/ability-helpers/calculate-usd-value.d.ts +0 -7
- package/dist/src/lib/ability-helpers/calculate-usd-value.d.ts.map +0 -1
- package/dist/src/lib/ability-helpers/calculate-usd-value.js +0 -22
- package/dist/src/lib/ability-helpers/calculate-usd-value.js.map +0 -1
- package/dist/src/lib/ability-helpers/estimate-gas-for-swap.d.ts +0 -7
- package/dist/src/lib/ability-helpers/estimate-gas-for-swap.d.ts.map +0 -1
- package/dist/src/lib/ability-helpers/estimate-gas-for-swap.js +0 -24
- package/dist/src/lib/ability-helpers/estimate-gas-for-swap.js.map +0 -1
- package/dist/src/lib/ability-helpers/get-eth-usd-price.d.ts +0 -6
- package/dist/src/lib/ability-helpers/get-eth-usd-price.d.ts.map +0 -1
- package/dist/src/lib/ability-helpers/get-eth-usd-price.js +0 -22
- package/dist/src/lib/ability-helpers/get-eth-usd-price.js.map +0 -1
- package/dist/src/lib/ability-helpers/get-token-amount-in-usd.d.ts +0 -10
- package/dist/src/lib/ability-helpers/get-token-amount-in-usd.d.ts.map +0 -1
- package/dist/src/lib/ability-helpers/get-token-amount-in-usd.js +0 -68
- package/dist/src/lib/ability-helpers/get-token-amount-in-usd.js.map +0 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSignedUniswapQuote = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const abilityClient_1 = require("@lit-protocol/vincent-app-sdk/abilityClient");
|
|
6
|
+
const vincent_prepare_metadata_json_1 = tslib_1.__importDefault(require("../../generated/vincent-prepare-metadata.json"));
|
|
7
|
+
const validate_signed_uniswap_quote_1 = require("./validate-signed-uniswap-quote");
|
|
8
|
+
const getSignedUniswapQuote = async ({ quoteParams, ethersSigner, litNodeClient, }) => {
|
|
9
|
+
const sessionSigs = await (0, abilityClient_1.generateVincentAbilitySessionSigs)({ ethersSigner, litNodeClient });
|
|
10
|
+
const { ipfsCid, pkpPublicKey, pkpEthAddress } = vincent_prepare_metadata_json_1.default;
|
|
11
|
+
if (!ipfsCid) {
|
|
12
|
+
throw new Error('Prepare Lit Action IPFS CID is not set');
|
|
13
|
+
}
|
|
14
|
+
if (!pkpPublicKey) {
|
|
15
|
+
throw new Error('Prepare Lit Action PKP Public Key is not set');
|
|
16
|
+
}
|
|
17
|
+
if (!pkpEthAddress) {
|
|
18
|
+
throw new Error('Prepare Lit Action PKP Eth Address is not set');
|
|
19
|
+
}
|
|
20
|
+
const result = await litNodeClient.executeJs({
|
|
21
|
+
ipfsId: ipfsCid,
|
|
22
|
+
sessionSigs,
|
|
23
|
+
jsParams: {
|
|
24
|
+
quoteParams,
|
|
25
|
+
pkpPublicKey: pkpPublicKey.replace(/^0x/, ''),
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
const signature = result.signatures['prepare-uniswap-route-signature'];
|
|
29
|
+
if (!signature) {
|
|
30
|
+
throw new Error('No signature of Uniswap Quote from Prepare Lit Action');
|
|
31
|
+
}
|
|
32
|
+
const prepareResponse = result.response;
|
|
33
|
+
if (!prepareResponse) {
|
|
34
|
+
throw new Error(`No response from Lit Action: ${JSON.stringify(result)}`);
|
|
35
|
+
}
|
|
36
|
+
if (!prepareResponse.success) {
|
|
37
|
+
throw new Error(prepareResponse.error);
|
|
38
|
+
}
|
|
39
|
+
const uniswapQuote = prepareResponse.quote;
|
|
40
|
+
const prepareSuccessResult = {
|
|
41
|
+
quote: uniswapQuote,
|
|
42
|
+
signature: signature.signature,
|
|
43
|
+
};
|
|
44
|
+
(0, validate_signed_uniswap_quote_1.validateSignedUniswapQuote)({
|
|
45
|
+
prepareSuccessResult,
|
|
46
|
+
expectedSignerEthAddress: pkpEthAddress,
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
...prepareSuccessResult,
|
|
50
|
+
dataSigned: signature.dataSigned,
|
|
51
|
+
signerPublicKey: signature.publicKey,
|
|
52
|
+
signerEthAddress: pkpEthAddress,
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
exports.getSignedUniswapQuote = getSignedUniswapQuote;
|
|
56
|
+
//# sourceMappingURL=get-signed-uniswap-quote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-signed-uniswap-quote.js","sourceRoot":"","sources":["../../../../src/lib/prepare/get-signed-uniswap-quote.ts"],"names":[],"mappings":";;;;AAEA,+EAAgG;AAQhG,0HAAmF;AACnF,mFAA6E;AAEtE,MAAM,qBAAqB,GAAG,KAAK,EAAE,EAC1C,WAAW,EACX,YAAY,EACZ,aAAa,GAKd,EAAsC,EAAE;IACvC,MAAM,WAAW,GAAG,MAAM,IAAA,iDAAiC,EAAC,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC,CAAC;IAE7F,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,uCAAsB,CAAC;IACxE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IACD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,SAAS,CAAC;QAC3C,MAAM,EAAE,OAAO;QACf,WAAW;QACX,QAAQ,EAAE;YACR,WAAW;YACX,YAAY,EAAE,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;SAC9C;KACF,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,iCAAiC,CAAC,CAAC;IACvE,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IAED,MAAM,eAAe,GAAG,MAAM,CAAC,QAA2B,CAAC;IAC3D,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,gCAAgC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,YAAY,GAAG,eAAe,CAAC,KAAK,CAAC;IAE3C,MAAM,oBAAoB,GAAyB;QACjD,KAAK,EAAE,YAAY;QACnB,SAAS,EAAE,SAAS,CAAC,SAAS;KAC/B,CAAC;IAEF,IAAA,0DAA0B,EAAC;QACzB,oBAAoB;QACpB,wBAAwB,EAAE,aAAa;KACxC,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,oBAAoB;QACvB,UAAU,EAAE,SAAS,CAAC,UAAU;QAChC,eAAe,EAAE,SAAS,CAAC,SAAS;QACpC,gBAAgB,EAAE,aAAa;KAChC,CAAC;AACJ,CAAC,CAAC;AA/DW,QAAA,qBAAqB,yBA+DhC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lit-action.d.ts","sourceRoot":"","sources":["../../../../src/lib/prepare/lit-action.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const json_stable_stringify_1 = tslib_1.__importDefault(require("json-stable-stringify"));
|
|
5
|
+
const get_uniswap_quote_1 = require("../ability-helpers/get-uniswap-quote");
|
|
6
|
+
(async () => {
|
|
7
|
+
try {
|
|
8
|
+
console.log('Quote parameters:', quoteParams);
|
|
9
|
+
const quoteResponse = await Lit.Actions.runOnce({ waitForResponse: true, name: 'Uniswap quote' }, async () => {
|
|
10
|
+
try {
|
|
11
|
+
const quoteResult = await (0, get_uniswap_quote_1.getUniswapQuote)(quoteParams);
|
|
12
|
+
if (!quoteResult.methodParameters) {
|
|
13
|
+
throw new Error('No method parameters returned from quote');
|
|
14
|
+
}
|
|
15
|
+
return JSON.stringify({
|
|
16
|
+
status: 'success',
|
|
17
|
+
quoteResult: {
|
|
18
|
+
chainId: quoteResult.trade.inputAmount.currency.isNative
|
|
19
|
+
? quoteResult.trade.inputAmount.currency.wrapped.chainId
|
|
20
|
+
: quoteResult.trade.inputAmount.currency.chainId,
|
|
21
|
+
to: quoteResult.methodParameters.to,
|
|
22
|
+
value: quoteResult.methodParameters.value,
|
|
23
|
+
calldata: quoteResult.methodParameters.calldata,
|
|
24
|
+
quote: quoteResult.quote.toExact(),
|
|
25
|
+
estimatedGasUsed: quoteResult.estimatedGasUsed.toString(),
|
|
26
|
+
estimatedGasUsedUSD: quoteResult.estimatedGasUsedUSD.toExact(),
|
|
27
|
+
blockNumber: quoteResult.blockNumber.toString(),
|
|
28
|
+
tokenIn: quoteResult.trade.inputAmount.currency.isNative
|
|
29
|
+
? quoteResult.trade.inputAmount.currency.wrapped.address
|
|
30
|
+
: quoteResult.trade.inputAmount.currency.address,
|
|
31
|
+
tokenInDecimals: quoteResult.trade.inputAmount.currency.isNative
|
|
32
|
+
? quoteResult.trade.inputAmount.currency.wrapped.decimals
|
|
33
|
+
: quoteResult.trade.inputAmount.currency.decimals,
|
|
34
|
+
amountIn: quoteResult.trade.inputAmount.toExact(),
|
|
35
|
+
tokenOut: quoteResult.trade.outputAmount.currency.isNative
|
|
36
|
+
? quoteResult.trade.outputAmount.currency.wrapped.address
|
|
37
|
+
: quoteResult.trade.outputAmount.currency.address,
|
|
38
|
+
amountOut: quoteResult.trade.outputAmount.toExact(),
|
|
39
|
+
tokenOutDecimals: quoteResult.trade.outputAmount.currency.isNative
|
|
40
|
+
? quoteResult.trade.outputAmount.currency.wrapped.decimals
|
|
41
|
+
: quoteResult.trade.outputAmount.currency.decimals,
|
|
42
|
+
timestamp: Date.now(),
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
return JSON.stringify({
|
|
48
|
+
status: 'error',
|
|
49
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const parsedQuoteResponse = JSON.parse(quoteResponse);
|
|
54
|
+
if (parsedQuoteResponse.status === 'error') {
|
|
55
|
+
throw new Error(`Error getting Uniswap quote: ${parsedQuoteResponse.error}`);
|
|
56
|
+
}
|
|
57
|
+
const { quoteResult } = parsedQuoteResponse;
|
|
58
|
+
const deterministicallyStringifiedQuoteResult = (0, json_stable_stringify_1.default)(quoteResult);
|
|
59
|
+
if (!deterministicallyStringifiedQuoteResult) {
|
|
60
|
+
throw new Error('Failed to stringify Uniswap quote');
|
|
61
|
+
}
|
|
62
|
+
const signatureSuccess = await Lit.Actions.ethPersonalSignMessageEcdsa({
|
|
63
|
+
message: deterministicallyStringifiedQuoteResult,
|
|
64
|
+
publicKey: pkpPublicKey,
|
|
65
|
+
sigName: 'prepare-uniswap-route-signature',
|
|
66
|
+
});
|
|
67
|
+
if (!signatureSuccess) {
|
|
68
|
+
throw new Error('Failed to sign Uniswap quote');
|
|
69
|
+
}
|
|
70
|
+
const successResponse = {
|
|
71
|
+
success: true,
|
|
72
|
+
quote: quoteResult,
|
|
73
|
+
};
|
|
74
|
+
Lit.Actions.setResponse({ response: JSON.stringify(successResponse) });
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
console.error('Error creating Uniswap quote:', error);
|
|
78
|
+
const errorResponse = {
|
|
79
|
+
success: false,
|
|
80
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
81
|
+
};
|
|
82
|
+
Lit.Actions.setResponse({
|
|
83
|
+
response: JSON.stringify(errorResponse),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
})();
|
|
87
|
+
//# sourceMappingURL=lit-action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lit-action.js","sourceRoot":"","sources":["../../../../src/lib/prepare/lit-action.ts"],"names":[],"mappings":";;;AAAA,0FAA+D;AAE/D,4EAAuE;AAyBvE,CAAC,KAAK,IAAI,EAAE;IACV,IAAI,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;QAE9C,MAAM,aAAa,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,OAAO,CAC7C,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,EAChD,KAAK,IAAI,EAAE;YACT,IAAI,CAAC;gBACH,MAAM,WAAW,GAAG,MAAM,IAAA,mCAAe,EAAC,WAAW,CAAC,CAAC;gBAEvD,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE,CAAC;oBAClC,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;gBAC9D,CAAC;gBAED,OAAO,IAAI,CAAC,SAAS,CAAC;oBACpB,MAAM,EAAE,SAAS;oBACjB,WAAW,EAAE;wBACX,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,QAAQ;4BACtD,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO;4BACxD,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO;wBAClD,EAAE,EAAE,WAAW,CAAC,gBAAgB,CAAC,EAAE;wBACnC,KAAK,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK;wBACzC,QAAQ,EAAE,WAAW,CAAC,gBAAgB,CAAC,QAAQ;wBAC/C,KAAK,EAAE,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AQ,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;IACzE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;QAEtD,MAAM,aAAa,GAAyB;YAC1C,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;SAChE,CAAC;QAEF,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC;YACtB,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;SACxC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface QuoteParams {
|
|
2
|
+
rpcUrl: string;
|
|
3
|
+
tokenInAddress: string;
|
|
4
|
+
tokenInAmount: string;
|
|
5
|
+
tokenOutAddress: string;
|
|
6
|
+
recipient: string;
|
|
7
|
+
slippageTolerance?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface PrepareUniswapRoute {
|
|
10
|
+
chainId: number;
|
|
11
|
+
to: string;
|
|
12
|
+
value: string;
|
|
13
|
+
calldata: string;
|
|
14
|
+
quote: string;
|
|
15
|
+
estimatedGasUsed: string;
|
|
16
|
+
estimatedGasUsedUSD: string;
|
|
17
|
+
blockNumber: string;
|
|
18
|
+
tokenIn: string;
|
|
19
|
+
tokenInDecimals: number;
|
|
20
|
+
amountIn: string;
|
|
21
|
+
tokenOut: string;
|
|
22
|
+
tokenOutDecimals: number;
|
|
23
|
+
amountOut: string;
|
|
24
|
+
timestamp: number;
|
|
25
|
+
}
|
|
26
|
+
export interface PrepareSuccessResult {
|
|
27
|
+
quote: PrepareUniswapRoute;
|
|
28
|
+
signature: string;
|
|
29
|
+
}
|
|
30
|
+
export interface PrepareErrorResponse {
|
|
31
|
+
success: false;
|
|
32
|
+
error: string;
|
|
33
|
+
}
|
|
34
|
+
export interface PrepareSuccessResponse {
|
|
35
|
+
success: true;
|
|
36
|
+
quote: PrepareUniswapRoute;
|
|
37
|
+
}
|
|
38
|
+
export interface PrepareErrorResponse {
|
|
39
|
+
success: false;
|
|
40
|
+
error: string;
|
|
41
|
+
}
|
|
42
|
+
export type PrepareResponse = PrepareSuccessResponse | PrepareErrorResponse;
|
|
43
|
+
export type PrepareSignedUniswapQuote = PrepareSuccessResult & {
|
|
44
|
+
dataSigned: string;
|
|
45
|
+
signerPublicKey: string;
|
|
46
|
+
signerEthAddress: string;
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/prepare/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,mBAAmB,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,IAAI,CAAC;IACd,KAAK,EAAE,mBAAmB,CAAC;CAC5B;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,eAAe,GAAG,sBAAsB,GAAG,oBAAoB,CAAC;AAE5E,MAAM,MAAM,yBAAyB,GAAG,oBAAoB,GAAG;IAC7D,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/prepare/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PrepareSuccessResult } from './types';
|
|
2
|
+
export declare const validateSignedUniswapQuote: ({ prepareSuccessResult, expectedSignerEthAddress, }: {
|
|
3
|
+
prepareSuccessResult: PrepareSuccessResult;
|
|
4
|
+
expectedSignerEthAddress: string;
|
|
5
|
+
}) => void;
|
|
6
|
+
//# sourceMappingURL=validate-signed-uniswap-quote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-signed-uniswap-quote.d.ts","sourceRoot":"","sources":["../../../../src/lib/prepare/validate-signed-uniswap-quote.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,0BAA0B,GAAI,qDAGxC;IACD,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,wBAAwB,EAAE,MAAM,CAAC;CAClC,SAkBA,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateSignedUniswapQuote = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const ethers_1 = require("ethers");
|
|
6
|
+
const json_stable_stringify_1 = tslib_1.__importDefault(require("json-stable-stringify"));
|
|
7
|
+
const validateSignedUniswapQuote = ({ prepareSuccessResult, expectedSignerEthAddress, }) => {
|
|
8
|
+
const deterministicallyStringifiedQuote = (0, json_stable_stringify_1.default)(prepareSuccessResult.quote);
|
|
9
|
+
if (!deterministicallyStringifiedQuote) {
|
|
10
|
+
throw new Error('Failed to stringify Uniswap quote');
|
|
11
|
+
}
|
|
12
|
+
const messageToSign = deterministicallyStringifiedQuote;
|
|
13
|
+
console.log('messageToSign', messageToSign);
|
|
14
|
+
const messageHash = ethers_1.ethers.utils.hashMessage(messageToSign);
|
|
15
|
+
console.log('messageHash', messageHash);
|
|
16
|
+
const recoveredAddress = ethers_1.ethers.utils.recoverAddress(messageHash, prepareSuccessResult.signature);
|
|
17
|
+
if (recoveredAddress !== expectedSignerEthAddress) {
|
|
18
|
+
throw new Error(`Signature validation failed: recovered address ${recoveredAddress} does not match expected signer address ${expectedSignerEthAddress}`);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.validateSignedUniswapQuote = validateSignedUniswapQuote;
|
|
22
|
+
//# sourceMappingURL=validate-signed-uniswap-quote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-signed-uniswap-quote.js","sourceRoot":"","sources":["../../../../src/lib/prepare/validate-signed-uniswap-quote.ts"],"names":[],"mappings":";;;;AAAA,mCAAgC;AAChC,0FAA+D;AAIxD,MAAM,0BAA0B,GAAG,CAAC,EACzC,oBAAoB,EACpB,wBAAwB,GAIzB,EAAE,EAAE;IACH,MAAM,iCAAiC,GAAG,IAAA,+BAA0B,EAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;IACjG,IAAI,CAAC,iCAAiC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,aAAa,GAAG,iCAAiC,CAAC;IACxD,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;IAE5C,MAAM,WAAW,GAAG,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAC5D,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IAExC,MAAM,gBAAgB,GAAG,eAAM,CAAC,KAAK,CAAC,cAAc,CAAC,WAAW,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAClG,IAAI,gBAAgB,KAAK,wBAAwB,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CACb,kDAAkD,gBAAgB,2CAA2C,wBAAwB,EAAE,CACxI,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAxBW,QAAA,0BAA0B,8BAwBrC"}
|
|
@@ -1,92 +1,163 @@
|
|
|
1
|
-
import { SchemaValidationError } from '@lit-protocol/vincent-ability-sdk';
|
|
2
1
|
import { z } from 'zod';
|
|
3
2
|
export declare const abilityParamsSchema: z.ZodObject<{
|
|
4
|
-
ethRpcUrl: z.ZodString;
|
|
5
3
|
rpcUrlForUniswap: z.ZodString;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
signedUniswapQuote: z.ZodObject<{
|
|
5
|
+
quote: z.ZodObject<{
|
|
6
|
+
chainId: z.ZodNumber;
|
|
7
|
+
to: z.ZodString;
|
|
8
|
+
value: z.ZodString;
|
|
9
|
+
calldata: z.ZodString;
|
|
10
|
+
quote: z.ZodString;
|
|
11
|
+
estimatedGasUsed: z.ZodString;
|
|
12
|
+
estimatedGasUsedUSD: z.ZodString;
|
|
13
|
+
blockNumber: z.ZodString;
|
|
14
|
+
tokenIn: z.ZodString;
|
|
15
|
+
amountIn: z.ZodString;
|
|
16
|
+
tokenInDecimals: z.ZodNumber;
|
|
17
|
+
tokenOut: z.ZodString;
|
|
18
|
+
amountOut: z.ZodString;
|
|
19
|
+
tokenOutDecimals: z.ZodNumber;
|
|
20
|
+
timestamp: z.ZodNumber;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
tokenInDecimals: number;
|
|
23
|
+
tokenOutDecimals: number;
|
|
24
|
+
to: string;
|
|
25
|
+
value: string;
|
|
26
|
+
chainId: number;
|
|
27
|
+
quote: string;
|
|
28
|
+
calldata: string;
|
|
29
|
+
estimatedGasUsed: string;
|
|
30
|
+
estimatedGasUsedUSD: string;
|
|
31
|
+
blockNumber: string;
|
|
32
|
+
tokenIn: string;
|
|
33
|
+
amountIn: string;
|
|
34
|
+
tokenOut: string;
|
|
35
|
+
amountOut: string;
|
|
36
|
+
timestamp: number;
|
|
37
|
+
}, {
|
|
38
|
+
tokenInDecimals: number;
|
|
39
|
+
tokenOutDecimals: number;
|
|
40
|
+
to: string;
|
|
41
|
+
value: string;
|
|
42
|
+
chainId: number;
|
|
43
|
+
quote: string;
|
|
44
|
+
calldata: string;
|
|
45
|
+
estimatedGasUsed: string;
|
|
46
|
+
estimatedGasUsedUSD: string;
|
|
47
|
+
blockNumber: string;
|
|
48
|
+
tokenIn: string;
|
|
49
|
+
amountIn: string;
|
|
50
|
+
tokenOut: string;
|
|
51
|
+
amountOut: string;
|
|
52
|
+
timestamp: number;
|
|
53
|
+
}>;
|
|
54
|
+
signature: z.ZodString;
|
|
55
|
+
}, "strip", z.ZodTypeAny, {
|
|
56
|
+
quote: {
|
|
57
|
+
tokenInDecimals: number;
|
|
58
|
+
tokenOutDecimals: number;
|
|
59
|
+
to: string;
|
|
60
|
+
value: string;
|
|
61
|
+
chainId: number;
|
|
62
|
+
quote: string;
|
|
63
|
+
calldata: string;
|
|
64
|
+
estimatedGasUsed: string;
|
|
65
|
+
estimatedGasUsedUSD: string;
|
|
66
|
+
blockNumber: string;
|
|
67
|
+
tokenIn: string;
|
|
68
|
+
amountIn: string;
|
|
69
|
+
tokenOut: string;
|
|
70
|
+
amountOut: string;
|
|
71
|
+
timestamp: number;
|
|
72
|
+
};
|
|
73
|
+
signature: string;
|
|
74
|
+
}, {
|
|
75
|
+
quote: {
|
|
76
|
+
tokenInDecimals: number;
|
|
77
|
+
tokenOutDecimals: number;
|
|
78
|
+
to: string;
|
|
79
|
+
value: string;
|
|
80
|
+
chainId: number;
|
|
81
|
+
quote: string;
|
|
82
|
+
calldata: string;
|
|
83
|
+
estimatedGasUsed: string;
|
|
84
|
+
estimatedGasUsedUSD: string;
|
|
85
|
+
blockNumber: string;
|
|
86
|
+
tokenIn: string;
|
|
87
|
+
amountIn: string;
|
|
88
|
+
tokenOut: string;
|
|
89
|
+
amountOut: string;
|
|
90
|
+
timestamp: number;
|
|
91
|
+
};
|
|
92
|
+
signature: string;
|
|
93
|
+
}>;
|
|
12
94
|
}, "strip", z.ZodTypeAny, {
|
|
13
|
-
tokenInAddress: string;
|
|
14
|
-
tokenInDecimals: number;
|
|
15
|
-
tokenInAmount: number;
|
|
16
|
-
tokenOutAddress: string;
|
|
17
|
-
tokenOutDecimals: number;
|
|
18
|
-
ethRpcUrl: string;
|
|
19
95
|
rpcUrlForUniswap: string;
|
|
20
|
-
|
|
96
|
+
signedUniswapQuote: {
|
|
97
|
+
quote: {
|
|
98
|
+
tokenInDecimals: number;
|
|
99
|
+
tokenOutDecimals: number;
|
|
100
|
+
to: string;
|
|
101
|
+
value: string;
|
|
102
|
+
chainId: number;
|
|
103
|
+
quote: string;
|
|
104
|
+
calldata: string;
|
|
105
|
+
estimatedGasUsed: string;
|
|
106
|
+
estimatedGasUsedUSD: string;
|
|
107
|
+
blockNumber: string;
|
|
108
|
+
tokenIn: string;
|
|
109
|
+
amountIn: string;
|
|
110
|
+
tokenOut: string;
|
|
111
|
+
amountOut: string;
|
|
112
|
+
timestamp: number;
|
|
113
|
+
};
|
|
114
|
+
signature: string;
|
|
115
|
+
};
|
|
21
116
|
}, {
|
|
22
|
-
tokenInAddress: string;
|
|
23
|
-
tokenInDecimals: number;
|
|
24
|
-
tokenInAmount: number;
|
|
25
|
-
tokenOutAddress: string;
|
|
26
|
-
tokenOutDecimals: number;
|
|
27
|
-
ethRpcUrl: string;
|
|
28
117
|
rpcUrlForUniswap: string;
|
|
29
|
-
|
|
118
|
+
signedUniswapQuote: {
|
|
119
|
+
quote: {
|
|
120
|
+
tokenInDecimals: number;
|
|
121
|
+
tokenOutDecimals: number;
|
|
122
|
+
to: string;
|
|
123
|
+
value: string;
|
|
124
|
+
chainId: number;
|
|
125
|
+
quote: string;
|
|
126
|
+
calldata: string;
|
|
127
|
+
estimatedGasUsed: string;
|
|
128
|
+
estimatedGasUsedUSD: string;
|
|
129
|
+
blockNumber: string;
|
|
130
|
+
tokenIn: string;
|
|
131
|
+
amountIn: string;
|
|
132
|
+
tokenOut: string;
|
|
133
|
+
amountOut: string;
|
|
134
|
+
timestamp: number;
|
|
135
|
+
};
|
|
136
|
+
signature: string;
|
|
137
|
+
};
|
|
30
138
|
}>;
|
|
31
139
|
export declare const precheckFailSchema: z.ZodObject<{
|
|
32
140
|
reason: z.ZodOptional<z.ZodString>;
|
|
141
|
+
erc20SpenderAddress: z.ZodOptional<z.ZodString>;
|
|
33
142
|
}, "strip", z.ZodTypeAny, {
|
|
34
143
|
reason?: string | undefined;
|
|
144
|
+
erc20SpenderAddress?: string | undefined;
|
|
35
145
|
}, {
|
|
36
146
|
reason?: string | undefined;
|
|
147
|
+
erc20SpenderAddress?: string | undefined;
|
|
37
148
|
}>;
|
|
38
149
|
export declare const executeFailSchema: z.ZodObject<{
|
|
39
150
|
reason: z.ZodOptional<z.ZodString>;
|
|
40
|
-
spendingLimitCommitFail: z.ZodOptional<z.ZodObject<{
|
|
41
|
-
runtimeError: z.ZodOptional<z.ZodString>;
|
|
42
|
-
schemaValidationError: z.ZodOptional<z.ZodType<SchemaValidationError, z.ZodTypeDef, SchemaValidationError>>;
|
|
43
|
-
structuredCommitFailureReason: z.ZodOptional<z.ZodObject<{
|
|
44
|
-
error: import("zod").ZodString;
|
|
45
|
-
}, "strip", z.ZodTypeAny, {
|
|
46
|
-
error: string;
|
|
47
|
-
}, {
|
|
48
|
-
error: string;
|
|
49
|
-
}>> | z.ZodOptional<z.ZodOptional<z.ZodUndefined>>;
|
|
50
|
-
}, "strip", z.ZodTypeAny, {
|
|
51
|
-
runtimeError?: string | undefined;
|
|
52
|
-
schemaValidationError?: SchemaValidationError | undefined;
|
|
53
|
-
structuredCommitFailureReason?: {
|
|
54
|
-
error: string;
|
|
55
|
-
} | undefined;
|
|
56
|
-
}, {
|
|
57
|
-
runtimeError?: string | undefined;
|
|
58
|
-
schemaValidationError?: SchemaValidationError | undefined;
|
|
59
|
-
structuredCommitFailureReason?: {
|
|
60
|
-
error: string;
|
|
61
|
-
} | undefined;
|
|
62
|
-
}>>;
|
|
63
151
|
}, "strip", z.ZodTypeAny, {
|
|
64
152
|
reason?: string | undefined;
|
|
65
|
-
spendingLimitCommitFail?: {
|
|
66
|
-
runtimeError?: string | undefined;
|
|
67
|
-
schemaValidationError?: SchemaValidationError | undefined;
|
|
68
|
-
structuredCommitFailureReason?: {
|
|
69
|
-
error: string;
|
|
70
|
-
} | undefined;
|
|
71
|
-
} | undefined;
|
|
72
153
|
}, {
|
|
73
154
|
reason?: string | undefined;
|
|
74
|
-
spendingLimitCommitFail?: {
|
|
75
|
-
runtimeError?: string | undefined;
|
|
76
|
-
schemaValidationError?: SchemaValidationError | undefined;
|
|
77
|
-
structuredCommitFailureReason?: {
|
|
78
|
-
error: string;
|
|
79
|
-
} | undefined;
|
|
80
|
-
} | undefined;
|
|
81
155
|
}>;
|
|
82
156
|
export declare const executeSuccessSchema: z.ZodObject<{
|
|
83
157
|
swapTxHash: z.ZodString;
|
|
84
|
-
spendTxHash: z.ZodOptional<z.ZodString>;
|
|
85
158
|
}, "strip", z.ZodTypeAny, {
|
|
86
159
|
swapTxHash: string;
|
|
87
|
-
spendTxHash?: string | undefined;
|
|
88
160
|
}, {
|
|
89
161
|
swapTxHash: string;
|
|
90
|
-
spendTxHash?: string | undefined;
|
|
91
162
|
}>;
|
|
92
163
|
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/lib/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4B9B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;EAS7B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;EAK5B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;EAE/B,CAAC"}
|
package/dist/src/lib/schemas.js
CHANGED
|
@@ -2,65 +2,50 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.executeSuccessSchema = exports.executeFailSchema = exports.precheckFailSchema = exports.abilityParamsSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const vincent_policy_spending_limit_1 = require("@lit-protocol/vincent-policy-spending-limit");
|
|
6
5
|
exports.abilityParamsSchema = zod_1.z.object({
|
|
7
|
-
ethRpcUrl: zod_1.z
|
|
8
|
-
.string()
|
|
9
|
-
.describe('An Ethereum Mainnet RPC Endpoint. This is used to check USD <> ETH prices via Chainlink.'),
|
|
10
6
|
rpcUrlForUniswap: zod_1.z
|
|
11
7
|
.string()
|
|
12
|
-
.describe('An RPC endpoint for any chain that is supported by the @uniswap/sdk-core package. Must work for the chain specified in
|
|
13
|
-
|
|
14
|
-
.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
8
|
+
.describe('An RPC endpoint for any chain that is supported by the @uniswap/sdk-core package. Must work for the chain specified in the signed Uniswap quote.'),
|
|
9
|
+
signedUniswapQuote: zod_1.z
|
|
10
|
+
.object({
|
|
11
|
+
quote: zod_1.z.object({
|
|
12
|
+
chainId: zod_1.z.number().describe('The chain ID the swap was generated for.'),
|
|
13
|
+
to: zod_1.z.string().describe('The router contract address'),
|
|
14
|
+
value: zod_1.z.string().describe('The value to send with the transaction'),
|
|
15
|
+
calldata: zod_1.z.string().describe('The encoded transaction data'),
|
|
16
|
+
quote: zod_1.z.string().describe('Expected output amount as decimal string'),
|
|
17
|
+
estimatedGasUsed: zod_1.z.string().describe('Estimated gas usage as integer string'),
|
|
18
|
+
estimatedGasUsedUSD: zod_1.z.string().describe('Estimated gas cost in USD as decimal string'),
|
|
19
|
+
blockNumber: zod_1.z.string().describe('Block number when quote was generated'),
|
|
20
|
+
tokenIn: zod_1.z.string().describe('Input token address'),
|
|
21
|
+
amountIn: zod_1.z.string().describe('Input amount as decimal string'),
|
|
22
|
+
tokenInDecimals: zod_1.z.number().describe('Input token decimals'),
|
|
23
|
+
tokenOut: zod_1.z.string().describe('Output token address'),
|
|
24
|
+
amountOut: zod_1.z.string().describe('Output amount as decimal string'),
|
|
25
|
+
tokenOutDecimals: zod_1.z.number().describe('Output token decimals'),
|
|
26
|
+
timestamp: zod_1.z.number().describe('Timestamp when quote was generated'),
|
|
27
|
+
}),
|
|
28
|
+
signature: zod_1.z.string().describe('The signature of the Uniswap quote'),
|
|
26
29
|
})
|
|
27
|
-
.describe('
|
|
28
|
-
tokenOutAddress: zod_1.z
|
|
29
|
-
.string()
|
|
30
|
-
.describe('ERC20 Token address to buy. For example 0x50dA645f148798F68EF2d7dB7C1CB22A6819bb2C for SPX600 on Base.'),
|
|
31
|
-
tokenOutDecimals: zod_1.z
|
|
32
|
-
.number()
|
|
33
|
-
.describe('ERC20 Token to buy decimals. For example 18 for WETH on Base.'),
|
|
30
|
+
.describe('Signed Uniswap quote from Prepare Lit Action'),
|
|
34
31
|
});
|
|
35
32
|
exports.precheckFailSchema = zod_1.z.object({
|
|
36
33
|
reason: zod_1.z
|
|
37
34
|
.string()
|
|
38
35
|
.optional()
|
|
39
36
|
.describe('The reason for failing the execution in cases where we identified the reason.'),
|
|
37
|
+
erc20SpenderAddress: zod_1.z
|
|
38
|
+
.string()
|
|
39
|
+
.optional()
|
|
40
|
+
.describe('The Uniswap router address that will be used to spend the ERC20 token'),
|
|
40
41
|
});
|
|
41
|
-
const spendingLimitCommitFailSchema = vincent_policy_spending_limit_1.bundledVincentPolicy.vincentPolicy
|
|
42
|
-
.commitDenyResultSchema
|
|
43
|
-
? vincent_policy_spending_limit_1.bundledVincentPolicy.vincentPolicy.commitDenyResultSchema
|
|
44
|
-
: zod_1.z.undefined().optional();
|
|
45
42
|
exports.executeFailSchema = zod_1.z.object({
|
|
46
43
|
reason: zod_1.z
|
|
47
44
|
.string()
|
|
48
45
|
.optional()
|
|
49
46
|
.describe('The reason for failing the execution in cases where we identified the reason.'),
|
|
50
|
-
spendingLimitCommitFail: zod_1.z
|
|
51
|
-
.object({
|
|
52
|
-
runtimeError: zod_1.z.string().optional(),
|
|
53
|
-
schemaValidationError: zod_1.z.custom().optional(),
|
|
54
|
-
structuredCommitFailureReason: spendingLimitCommitFailSchema.optional(),
|
|
55
|
-
})
|
|
56
|
-
.optional()
|
|
57
|
-
.describe('The commit failure result'),
|
|
58
47
|
});
|
|
59
48
|
exports.executeSuccessSchema = zod_1.z.object({
|
|
60
49
|
swapTxHash: zod_1.z.string().describe('The hash of the swapping transaction on uniswap'),
|
|
61
|
-
spendTxHash: zod_1.z
|
|
62
|
-
.string()
|
|
63
|
-
.optional()
|
|
64
|
-
.describe('The hash of the transaction recording the amount spent. Necessary for spending limit enforcement by @lit-protocol/vincent-policy-spending-limit policy'),
|
|
65
50
|
});
|
|
66
51
|
//# sourceMappingURL=schemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/lib/schemas.ts"],"names":[],"mappings":";;;
|
|
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,gBAAgB,EAAE,OAAC;SAChB,MAAM,EAAE;SACR,QAAQ,CACP,kJAAkJ,CACnJ;IACH,kBAAkB,EAAE,OAAC;SAClB,MAAM,CAAC;QACN,KAAK,EAAE,OAAC,CAAC,MAAM,CAAC;YACd,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;YACxE,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;YACtD,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wCAAwC,CAAC;YACpE,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;YAC7D,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;YACtE,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uCAAuC,CAAC;YAC9E,mBAAmB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAA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