Skip to content

Commit b8cdc99

Browse files
Fixed some logic and typing (elizaOS#2868)
Co-authored-by: Shakker Nerd <165377636+shakkernerd@users.noreply.github.com>
1 parent 1f0bbde commit b8cdc99

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

packages/plugin-squid-router/src/actions/xChainSwap.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ export const xChainSwapAction = {
4646
): Promise<boolean> => {
4747
elizaLogger.log("Starting X_CHAIN_SWAP handler...");
4848

49-
// Initialize or update state
50-
if (!state) {
51-
state = (await runtime.composeState(message)) as State;
49+
let currentState = state; // Create new variable
50+
if (!currentState) {
51+
currentState = (await runtime.composeState(message)) as State;
5252
} else {
53-
state = await runtime.updateRecentMessageState(state);
53+
currentState = await runtime.updateRecentMessageState(currentState);
5454
}
5555

5656
// Compose X chain swap context
5757
const xChainSwapContext = composeContext({
58-
state,
58+
state: currentState, // Use the new variable
5959
template: xChainSwapTemplate,
6060
});
6161

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

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

170170
if (callback) {
171171
callback({
172-
text:
173-
"Swap completed successfully! Check Axelarscan for details:\n " + axelarScanLink,
172+
text: `Swap completed successfully! Check Axelarscan for details:\n${axelarScanLink}`, // Fix: Use template literal
174173
content: {},
175174
});
176175
}

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

+15-3
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,25 @@ export class SquidRouterProvider {
8484
if(chain.chainType === ChainType.EVM) {
8585
const provider = new ethers.JsonRpcProvider(chain.rpc);
8686
return new ethers.Wallet(runtime.getSetting("SQUID_EVM_PRIVATE_KEY"), provider);
87-
} else {
88-
throw Error("Cannot instantiate EVM signer for non-EVM chain");
8987
}
88+
throw new Error('Cannot instantiate EVM signer for non-EVM chain'); // Fix: Use template literal and remove else
9089
} catch (error) {
91-
throw Error("Cannot instantiate EVM signer: "+error);
90+
throw new Error(`Cannot instantiate EVM signer: ${error}`); // Fix: Use template literal
9291
}
9392
}
93+
94+
// async getEVMSignerForChain(chain: ChainData, runtime): Promise<ethers.Signer> {
95+
// try {
96+
// if(chain.chainType === ChainType.EVM) {
97+
// const provider = new ethers.JsonRpcProvider(chain.rpc);
98+
// return new ethers.Wallet(runtime.getSetting("SQUID_EVM_PRIVATE_KEY"), provider);
99+
// } else {
100+
// throw Error("Cannot instantiate EVM signer for non-EVM chain");
101+
// }
102+
// } catch (error) {
103+
// throw Error("Cannot instantiate EVM signer: "+error);
104+
// }
105+
// }
94106
}
95107

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

0 commit comments

Comments
 (0)