Skip to content

Commit

Permalink
Fix a mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
Thunnini committed Jan 9, 2024
1 parent a6f89b7 commit dca37fc
Showing 1 changed file with 50 additions and 7 deletions.
57 changes: 50 additions & 7 deletions packages/extension/src/hooks/ibc-swap/amount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,11 @@ export class IBCSwapAmountConfig extends AmountConfig {
queryMsgsDirect.response.data
);

console.log({
swapRouterKey,
key,
});
if (swapRouterKey !== key) {
console.log({
swapRouterKey,
key,
});
throw new Error(
"Route and msgs_direct are not matched. Please try again."
);
Expand Down Expand Up @@ -374,9 +374,52 @@ export class IBCSwapAmountConfig extends AmountConfig {
const memo = JSON.parse(msg.msg).memo;
if (memo) {
const obj = JSON.parse(memo);
for (const operation of obj.wasm.msg.swap_and_action.user_swap
.swap_exact_asset_in.operations) {
key += `/${operation.pool}/${operation.denom_in}/${operation.denom_out}`;
const wasms: any = [];

if (obj.wasm) {
wasms.push(obj.wasm);
}

let forward = obj.forward;
if (forward) {
while (true) {
if (forward) {
if (forward.memo) {
const obj = JSON.parse(forward.memo);
if (obj.wasm) {
wasms.push(obj.wasm);
}
}

if (forward.wasm) {
wasms.push(forward.wasm);
}

if (forward.next) {
const obj =
typeof forward.next === "string"
? JSON.parse(forward.next)
: forward.next;

if (obj.forward) {
forward = obj.forward;
} else {
forward = obj;
}
} else {
break;
}
} else {
break;
}
}
}

for (const wasm of wasms) {
for (const operation of wasm.msg.swap_and_action.user_swap
.swap_exact_asset_in.operations) {
key += `/${operation.pool}/${operation.denom_in}/${operation.denom_out}`;
}
}
}
}
Expand Down

0 comments on commit dca37fc

Please sign in to comment.