Skip to content

Commit

Permalink
Fixed some logic and typing (#2868)
Browse files Browse the repository at this point in the history
Co-authored-by: Shakker Nerd <[email protected]>
  • Loading branch information
AIFlowML and shakkernerd authored Jan 28, 2025
1 parent 1f0bbde commit b8cdc99
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
15 changes: 7 additions & 8 deletions packages/plugin-squid-router/src/actions/xChainSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ export const xChainSwapAction = {
): Promise<boolean> => {
elizaLogger.log("Starting X_CHAIN_SWAP handler...");

// Initialize or update state
if (!state) {
state = (await runtime.composeState(message)) as State;
let currentState = state; // Create new variable
if (!currentState) {
currentState = (await runtime.composeState(message)) as State;
} else {
state = await runtime.updateRecentMessageState(state);
currentState = await runtime.updateRecentMessageState(currentState);
}

// Compose X chain swap context
const xChainSwapContext = composeContext({
state,
state: currentState, // Use the new variable
template: xChainSwapTemplate,
});

Expand Down Expand Up @@ -164,13 +164,12 @@ export const xChainSwapAction = {
const txReceipt = await tx.wait();

// Show the transaction receipt with Axelarscan link
const axelarScanLink = "https://axelarscan.io/gmp/" + txReceipt.hash;
const axelarScanLink = `https://axelarscan.io/gmp/${txReceipt.hash}`; // Fix: Use template literal
elizaLogger.log(`Finished! Check Axelarscan for details: ${axelarScanLink}`);

if (callback) {
callback({
text:
"Swap completed successfully! Check Axelarscan for details:\n " + axelarScanLink,
text: `Swap completed successfully! Check Axelarscan for details:\n${axelarScanLink}`, // Fix: Use template literal
content: {},
});
}
Expand Down
18 changes: 15 additions & 3 deletions packages/plugin-squid-router/src/providers/squidRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,25 @@ export class SquidRouterProvider {
if(chain.chainType === ChainType.EVM) {
const provider = new ethers.JsonRpcProvider(chain.rpc);
return new ethers.Wallet(runtime.getSetting("SQUID_EVM_PRIVATE_KEY"), provider);
} else {
throw Error("Cannot instantiate EVM signer for non-EVM chain");
}
throw new Error('Cannot instantiate EVM signer for non-EVM chain'); // Fix: Use template literal and remove else
} catch (error) {
throw Error("Cannot instantiate EVM signer: "+error);
throw new Error(`Cannot instantiate EVM signer: ${error}`); // Fix: Use template literal
}
}

// async getEVMSignerForChain(chain: ChainData, runtime): Promise<ethers.Signer> {
// try {
// if(chain.chainType === ChainType.EVM) {
// const provider = new ethers.JsonRpcProvider(chain.rpc);
// return new ethers.Wallet(runtime.getSetting("SQUID_EVM_PRIVATE_KEY"), provider);
// } else {
// throw Error("Cannot instantiate EVM signer for non-EVM chain");
// }
// } catch (error) {
// throw Error("Cannot instantiate EVM signer: "+error);
// }
// }
}

export const initSquidRouterProvider = (runtime: IAgentRuntime) => {

Check notice on line 108 in packages/plugin-squid-router/src/providers/squidRouter.ts

View check run for this annotation

codefactor.io / CodeFactor

packages/plugin-squid-router/src/providers/squidRouter.ts#L108

'_message' is defined but never used. (@typescript-eslint/no-unused-vars)
Expand Down

0 comments on commit b8cdc99

Please sign in to comment.