From e6fd1eada6de7166697dce259ebe06ffba30183f Mon Sep 17 00:00:00 2001 From: stephenson080 Date: Sun, 29 Sep 2024 23:29:22 -0700 Subject: [PATCH] add coinbase and trustwallet --- backend-ausdce/src/services/blockchain.ts | 4 +- backend-usdc/src/services/blockchain.ts | 2 +- backend-usdt/src/services/blockchain.ts | 2 +- backend-wnt/src/services/blockchain.ts | 2 +- backend/src/services/blockchain.ts | 2 +- frontend/src/api/history.ts | 8 +++- .../src/components/popups/ConnectDialog.vue | 47 ++++++++++--------- .../src/gotbit-tools/vue/utils/stores/web3.ts | 3 +- .../vue/utils/wallets/trustwallet.ts | 2 +- frontend/src/gotbit.config.ts | 2 +- frontend/src/store/business/bridge.ts | 1 - frontend/src/store/contracts/bridge.ts | 44 ++--------------- 12 files changed, 43 insertions(+), 76 deletions(-) diff --git a/backend-ausdce/src/services/blockchain.ts b/backend-ausdce/src/services/blockchain.ts index 2431101..a7eda4a 100644 --- a/backend-ausdce/src/services/blockchain.ts +++ b/backend-ausdce/src/services/blockchain.ts @@ -74,7 +74,7 @@ export const signTransaction = async ( if (tx.toChain.startsWith('evm.')) { const chainId = tx.toChain.replace('evm.', '') // const { bridgeAssist } = useContracts(undefined, chainId as ChainId) - let signatures = [] + let signatures : any[] = [] const signer0 = await signHashedTransaction( extractFulfillTransaction(tx), chainId, @@ -82,7 +82,7 @@ export const signTransaction = async ( 0 ) signatures.push(signer0) - if (process.env.PROD){ + if (process.env.PRIVATE_KEY2){ const signer1 = await signHashedTransaction( extractFulfillTransaction(tx), chainId, diff --git a/backend-usdc/src/services/blockchain.ts b/backend-usdc/src/services/blockchain.ts index 0ef5217..1f0a8e9 100644 --- a/backend-usdc/src/services/blockchain.ts +++ b/backend-usdc/src/services/blockchain.ts @@ -246,7 +246,7 @@ export const signTransaction = async ( 0 ) signatures.push(signer0) - if (process.env.PROD){ + if (process.env.PRIVATE_KEY2){ const signer1 = await signHashedTransaction( extractFulfillTransaction(tx), chainId, diff --git a/backend-usdt/src/services/blockchain.ts b/backend-usdt/src/services/blockchain.ts index 0298cb1..5b950ed 100644 --- a/backend-usdt/src/services/blockchain.ts +++ b/backend-usdt/src/services/blockchain.ts @@ -248,7 +248,7 @@ export const signTransaction = async ( 0 ) signatures.push(signer0) - if (process.env.PROD){ + if (process.env.PRIVATE_KEY2){ const signer1 = await signHashedTransaction( extractFulfillTransaction(tx), chainId, diff --git a/backend-wnt/src/services/blockchain.ts b/backend-wnt/src/services/blockchain.ts index edd879c..8b58c1e 100644 --- a/backend-wnt/src/services/blockchain.ts +++ b/backend-wnt/src/services/blockchain.ts @@ -246,7 +246,7 @@ export const signTransaction = async ( 0 ) signatures.push(signer0) - if (process.env.PROD){ + if (process.env.PRIVATE_KEY2){ const signer1 = await signHashedTransaction( extractFulfillTransaction(tx), chainId, diff --git a/backend/src/services/blockchain.ts b/backend/src/services/blockchain.ts index d0ba71c..5bc8d15 100644 --- a/backend/src/services/blockchain.ts +++ b/backend/src/services/blockchain.ts @@ -250,7 +250,7 @@ export const signTransaction = async ( 0 ) signatures.push(signer0) - if (process.env.PROD){ + if (process.env.PRIVATE_KEY2){ const signer1 = await signHashedTransaction( extractFulfillTransaction(tx), chainId, diff --git a/frontend/src/api/history.ts b/frontend/src/api/history.ts index 5e45b64..dbc379d 100644 --- a/frontend/src/api/history.ts +++ b/frontend/src/api/history.ts @@ -30,8 +30,9 @@ const getUrl = (symbol: Symbol) => { } } -const axiosClientToken = (token: Symbol) => - axios.create({ +const axiosClientToken = (token: Symbol) =>{ + console.log(token, getUrl(token), 'saklsa') + return axios.create({ baseURL: getUrl(token), transformResponse: [ (data) => { @@ -39,6 +40,8 @@ const axiosClientToken = (token: Symbol) => }, ], }) +} + const axiosClient = axios.create({ baseURL, @@ -84,6 +87,7 @@ export async function getTokenSignature( fromUser: string, index: number ): Promise { + console.log(symbol, 'sdkd') const [response, error] = await safe( axiosClientToken(symbol).get<{ signature: string | string[] }>(SIGN, { params: { fromBridgeAddress, toBridgeAssistAddress, fromChain, fromUser, index }, diff --git a/frontend/src/components/popups/ConnectDialog.vue b/frontend/src/components/popups/ConnectDialog.vue index a5a24aa..4bb263b 100644 --- a/frontend/src/components/popups/ConnectDialog.vue +++ b/frontend/src/components/popups/ConnectDialog.vue @@ -44,25 +44,6 @@ WalletConnect - - -
-
-
{ @@ -98,8 +79,8 @@ Coinbase - --> - + + +
+
+
+ + diff --git a/frontend/src/gotbit-tools/vue/utils/stores/web3.ts b/frontend/src/gotbit-tools/vue/utils/stores/web3.ts index a8001e1..b4f0876 100644 --- a/frontend/src/gotbit-tools/vue/utils/stores/web3.ts +++ b/frontend/src/gotbit-tools/vue/utils/stores/web3.ts @@ -38,7 +38,7 @@ let storeSettings: StoreSettings = { let config = { DEBUG: true, chainIds: [] as any, - DEFAULT_CHAINID: '' as any, + DEFAULT_CHAINID: '42421' as any, rpc: () => '', } as GotBitConfig @@ -87,7 +87,6 @@ export const useWeb3 = defineStore('$web3', { }, testLogin(address: string, chainId?: ChainId) { console.gotbit.log(`Test login ${address} on ${chainId}`) - if (chainId === undefined) chainId = this.DEFAULT_CHAINID const signer = new VoidSigner(address, getProvider(chainId)) diff --git a/frontend/src/gotbit-tools/vue/utils/wallets/trustwallet.ts b/frontend/src/gotbit-tools/vue/utils/wallets/trustwallet.ts index 67b6135..8d7e5e9 100644 --- a/frontend/src/gotbit-tools/vue/utils/wallets/trustwallet.ts +++ b/frontend/src/gotbit-tools/vue/utils/wallets/trustwallet.ts @@ -88,7 +88,7 @@ export class TrustWallet extends WalletHandler { await this.updateProviderState() return true } catch (error) { - if (parseInt((error as any).code) == 4902) return await this.addChain(chainId) + if (parseInt((error as any).code) == 4200) return await this.addChain(chainId) } return false } diff --git a/frontend/src/gotbit.config.ts b/frontend/src/gotbit.config.ts index 83b3cd2..b45242e 100644 --- a/frontend/src/gotbit.config.ts +++ b/frontend/src/gotbit.config.ts @@ -13,7 +13,7 @@ export const XEND_CHAIN = '42421' export const config = defineConfig({ DEBUG: IS_DEBUG, chainIds: ['97', '421614', '42421', '11155111', '80002', '84532', '200810'], - DEFAULT_CHAINID: IS_DEBUG ? '97' : '97', + DEFAULT_CHAINID: IS_DEBUG ? '42421' : '42421', rpc: (chainTag) => { const uni = universalRpc() diff --git a/frontend/src/store/business/bridge.ts b/frontend/src/store/business/bridge.ts index ce140ae..e37fc42 100644 --- a/frontend/src/store/business/bridge.ts +++ b/frontend/src/store/business/bridge.ts @@ -105,7 +105,6 @@ const createAction = async ( return 'Warning! An error has occurred. Please try again.' } } - if (web3.realChainId !== uiBridge.network) { dialogs.openDialog( 'waitDialog', diff --git a/frontend/src/store/contracts/bridge.ts b/frontend/src/store/contracts/bridge.ts index 51c04b4..e508c48 100644 --- a/frontend/src/store/contracts/bridge.ts +++ b/frontend/src/store/contracts/bridge.ts @@ -265,8 +265,10 @@ export const useBridge = defineContractStore { + for (const chainId of supportedChains as ChainId[]) { + // const { bridgeAssist } = useContracts(undefined, chainId) let tokenAddr = token.tokenAddress // const tokenAddr = // token.symbol === 'RWA' && chainId === '42421' @@ -300,44 +302,7 @@ export const useBridge = defineContractStore t.label === token.symbol) - // if (_token) { - // tokenAddr = _token.value - // } - // } - // } - - // const bridgeAddress = assistAndTokenAddresses[chainId].find( - // (item) => item.token === tokenAddr - // )?.bridgeAssist - - // const contract = getContract(chainId) - // if (bridgeAddress) { - // transactions = transactions.concat( - // await safeRead( - // contract.anyBridgeAssist(bridgeAddress).getUserTransactions(web3.wallet), - // [] - // ) - // ) - // } - // } + } // console.log('dddddddddd', transactions) return transactions }, @@ -349,7 +314,6 @@ export const useBridge = defineContractStore = {} const claimInfo: Record = {} const transactions: TransactionContract[] = await this.getTransactions() - let symbol = '' await Promise.all(transactions.map(async transaction => {