From fe26e266ea15bcddc9c645c58f3b82fbbefd86ec Mon Sep 17 00:00:00 2001 From: hoangdv2429 Date: Fri, 19 Jan 2024 18:05:21 +0700 Subject: [PATCH 1/3] add 0x convert back --- hooks/fetchUserStatus.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hooks/fetchUserStatus.ts b/hooks/fetchUserStatus.ts index fb7c07e..6180911 100644 --- a/hooks/fetchUserStatus.ts +++ b/hooks/fetchUserStatus.ts @@ -1,4 +1,5 @@ import { ChainType, CheckResponse } from "../pages/api/check"; +import { getInjectiveAddress } from "@injectivelabs/sdk-ts"; // Not a hook but seems like a good place to put this export const fetchUserStatus = async ({ @@ -10,6 +11,11 @@ export const fetchUserStatus = async ({ }) => { console.log(`Fetching for ${chain}`); + // check if input address start with 0x + if (walletAddr.startsWith("0x")) { + walletAddr = getInjectiveAddress(walletAddr); + } + try { const validateChain = ChainType.safeParse(chain); if (!validateChain.success) { From c2c590357f89a2597d410fd6bef47e06f0aeefc1 Mon Sep 17 00:00:00 2001 From: hoangdv2429 Date: Fri, 19 Jan 2024 20:31:49 +0700 Subject: [PATCH 2/3] testing --- components/chainCards.tsx | 2 ++ services/ledgerHelpers.ts | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/components/chainCards.tsx b/components/chainCards.tsx index fe5fd8b..bca6449 100644 --- a/components/chainCards.tsx +++ b/components/chainCards.tsx @@ -358,6 +358,7 @@ export const ClaimInfo = ({ return; } + console.log("chainCards: ", client.walletType); // If walletType is ledger && chain is injective, use helper if (client.walletType === "metamask" && client.chain === "injective") { toast.loading("Processing your request..."); @@ -382,6 +383,7 @@ export const ClaimInfo = ({ toast.error(`Visit our Discord for assistance`); }); } else if (client.walletType === "ledger" && client.chain === "injective") { + console.log("right case"); toast.loading("Processing your request..."); ethLedgerTxHelper({ client, diff --git a/services/ledgerHelpers.ts b/services/ledgerHelpers.ts index f896be9..18d7261 100644 --- a/services/ledgerHelpers.ts +++ b/services/ledgerHelpers.ts @@ -20,6 +20,7 @@ import { import { EthereumChainId } from "@injectivelabs/ts-types"; import { ChainSigningClient } from "../contexts/userClients"; import { bufferToHex } from 'ethereumjs-util'; +import { getInjectiveAddress } from "@injectivelabs/sdk-ts"; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Ethereum Ledger helpers for Injective @@ -57,6 +58,11 @@ export const ethLedgerTxHelper = async ({ // Get account sequence of user const {accountNumber, sequence} = await queryClient.getSequence(client.walletAddress); + console.log('walletAddress: ', client.walletAddress); + // check if input address start with 0x + if (client.walletAddress.startsWith("0x")) { + client.walletAddress = getInjectiveAddress(client.walletAddress); + } // Get latest block info const latestBlock = await queryClient.getBlock(); From 74c42e8ebb4038417de553601fc8eb583812d80c Mon Sep 17 00:00:00 2001 From: hoangdv2429 Date: Fri, 19 Jan 2024 20:54:40 +0700 Subject: [PATCH 3/3] again --- services/ledgerHelpers.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/services/ledgerHelpers.ts b/services/ledgerHelpers.ts index 18d7261..6e409c7 100644 --- a/services/ledgerHelpers.ts +++ b/services/ledgerHelpers.ts @@ -56,13 +56,14 @@ export const ethLedgerTxHelper = async ({ // Get query client, don't really need batch here since creating batch requires 2 trips anyway const queryClient = await CosmWasmClient.connect(chainConfig.rpc); + // check if input address start with 0x + if (client.walletAddress.startsWith("0x")) { + client.walletAddress = getInjectiveAddress(client.walletAddress); + } + // Get account sequence of user const {accountNumber, sequence} = await queryClient.getSequence(client.walletAddress); console.log('walletAddress: ', client.walletAddress); - // check if input address start with 0x - if (client.walletAddress.startsWith("0x")) { - client.walletAddress = getInjectiveAddress(client.walletAddress); - } // Get latest block info const latestBlock = await queryClient.getBlock();