diff --git a/src/main/swap/Main.ts b/src/main/swap/Main.ts index 6f7ae5c..3324108 100644 --- a/src/main/swap/Main.ts +++ b/src/main/swap/Main.ts @@ -71,9 +71,26 @@ function address_to_url(address: BlockchainAddress): string { } function ui_show_route() { + if (CURRENT_ROUTE.from == null || CURRENT_ROUTE.to == null) { + return; + } + + const infoFrom = TOKENS[CURRENT_ROUTE.from.asString()]; + const infoTo = TOKENS[CURRENT_ROUTE.to.asString()]; + + const symbolFrom = infoFrom.latest_state == null ? "???" : infoFrom.latest_state.symbol; + const symbolTo = infoTo.latest_state == null ? "???" : infoTo.latest_state.symbol; + + for (const a of document.querySelectorAll("[data-input-token]")) { + (a).innerText = symbolFrom; + } + for (const a of document.querySelectorAll("[data-output-token]")) { + (a).innerText = symbolTo; + } } function reroute() { + console.log("Rerouting", CURRENT_ROUTE); // Do not route if from or to are not assigned yet. if (CURRENT_ROUTE.from == null || CURRENT_ROUTE.to == null) { @@ -82,6 +99,8 @@ function reroute() { // Perform routing. // TODO + + ui_show_route(); } function routeFrom(address: BlockchainAddress) { @@ -114,7 +133,7 @@ function ui_add_token(tokenState: TokenStateV1 | TokenStateV2, address: Blockcha value="To" /> `; - spanFrom.addEventListener("click", () => routeTo(address)); + spanTo.addEventListener("click", () => routeTo(address)); const spanSymbol= document.createElement("a"); spanSymbol.innerText = tokenState.symbol; spanSymbol.title = tokenState.name; diff --git a/tsconfig.json b/tsconfig.json index bfc631e..3674998 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,6 +12,6 @@ "strict": true, "sourceMap": true, "jsx": "react", - "lib": ["dom", "es2015", "es2016", "es2017", "esnext"] + "lib": ["dom", "es2015", "es2016", "es2017", "esnext", "dom.iterable"] } }