Skip to content

Commit

Permalink
chore: update scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Rafael Belchior <[email protected]>
  • Loading branch information
rafaelbelchiorbd committed Aug 1, 2024
1 parent a15948b commit cd60a7c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/main/scripts/get-chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
Expand Down
15 changes: 9 additions & 6 deletions src/main/scripts/get-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/main/scripts/get-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ async function main() {
const api = new TokensApi(apiConfig);

// get all USDC token data

const tokensParameters: GetTokensRequest = {
tokenSymbol: "USDC",
};
Expand Down
2 changes: 1 addition & 1 deletion src/main/scripts/sign-and-broadcast-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/main/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cd60a7c

Please sign in to comment.