From cd60a7c38f263a8d08c5cee26f54fc35d890814b Mon Sep 17 00:00:00 2001 From: rafaelbelchiorbd Date: Thu, 1 Aug 2024 08:09:40 +0200 Subject: [PATCH] chore: update scripts Signed-off-by: Rafael Belchior --- src/main/scripts/get-chains.ts | 3 +-- src/main/scripts/get-routes.ts | 15 +++++++++------ src/main/scripts/get-tokens.ts | 1 - .../scripts/sign-and-broadcast-transaction.ts | 2 +- src/main/utils/common.ts | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/scripts/get-chains.ts b/src/main/scripts/get-chains.ts index 4b1c33f..728e37c 100644 --- a/src/main/scripts/get-chains.ts +++ b/src/main/scripts/get-chains.ts @@ -8,8 +8,7 @@ const logger = log.getLogger("get-chains"); async function main() { const api = new ChainsApi(apiConfig); - // get only polygon chains - + // get polygon; no parameters to get all chains const chainsParameters: GetChainsRequest = { chainName: "polygon", }; diff --git a/src/main/scripts/get-routes.ts b/src/main/scripts/get-routes.ts index 91b662d..4d48a78 100644 --- a/src/main/scripts/get-routes.ts +++ b/src/main/scripts/get-routes.ts @@ -22,14 +22,17 @@ async function main() { }; try { - const routes = await api.getRoutes(routeParameters); + const routes: RoutesResponse = await api.getRoutes(routeParameters); logger.info("Got routes"); - const chosenRoute = routes.routes[0]; - logger.info(chosenRoute); - const approvalAddress = chosenRoute.steps[0].estimate.approvalAddress; - const transactionPayload = chosenRoute.transactionRequest.data; + if (routes.routes.length > 0) { + logger.info("Printing first route:") + logger.info(JSON.stringify(routes.routes[0], null, 2)); + } else { + logger.warn("Routes returned but empty object") + } + } catch (error) { - logger.error("Failed to execute swap"); + logger.error("Failed to get routes"); logger.debug(error); } } diff --git a/src/main/scripts/get-tokens.ts b/src/main/scripts/get-tokens.ts index 2e42574..7d204f1 100644 --- a/src/main/scripts/get-tokens.ts +++ b/src/main/scripts/get-tokens.ts @@ -9,7 +9,6 @@ async function main() { const api = new TokensApi(apiConfig); // get all USDC token data - const tokensParameters: GetTokensRequest = { tokenSymbol: "USDC", }; diff --git a/src/main/scripts/sign-and-broadcast-transaction.ts b/src/main/scripts/sign-and-broadcast-transaction.ts index 6208dbb..897913c 100644 --- a/src/main/scripts/sign-and-broadcast-transaction.ts +++ b/src/main/scripts/sign-and-broadcast-transaction.ts @@ -6,7 +6,7 @@ const logger = log.getLogger("sign and broadcast"); async function main() { try { const dataToSign = - "0x733214a333631d44387fd3fb260c6e9118d26439ba18c0240023778ac9f59d680b41d13d00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000f271aafc62634e6dc9a276ac0f6145c4fdbe2ced00000000000000000000000000000000000000000000000000659cd351b5ce03000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000086c6966692d617069000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a30783030303030303030303030303030303030303030303030303030303030303030303030303030303000000000000000000000000000000000000000000000000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee57000000000000000000000000216b4b4ba9f3e719726886d34a177484278bfcae000000000000000000000000420000000000000000000000000000000000004200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034461e1d689cf400000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000264a6886da900000000000000000000000000000000000000000000000000000000000000200000000000000000000000004200000000000000000000000000000000000042000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000e592427a0aece92de3edee1f18e0157c058615640000000000000000000000000000000000000000000000034461e1d689cf400000000000000000000000000000000000000000000000000000659cd351b5ce030000000000000000000000000000000000000000000000000070e723b01f56ae0100000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000006695baaf000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae00000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000022078354cd147374d379a48ecc0ecbbf61d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b42000000000000000000000000000000000000420001f44200000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + "hello world"; // data to sign, this can be a transaction payload or any data you want to sign const signedMessage = await signMessage(logger, dataToSign); diff --git a/src/main/utils/common.ts b/src/main/utils/common.ts index 84bf9f6..f54086b 100644 --- a/src/main/utils/common.ts +++ b/src/main/utils/common.ts @@ -87,7 +87,7 @@ export async function broadcastSignedMessage( const tx = { to: RECEIVER_ADDRESS, data: signedMessage, - value: ethers.parseEther("0"), + value: "0", }; const transactionResponse = await optimismWallet.sendTransaction(tx);