Skip to content

Commit

Permalink
Merge pull request #31 from xendfinance/fix
Browse files Browse the repository at this point in the history
add coinbase and trustwallet
  • Loading branch information
theiceeman authored Sep 30, 2024
2 parents 6b97b2a + e6fd1ea commit 4e79224
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 76 deletions.
4 changes: 2 additions & 2 deletions backend-ausdce/src/services/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ 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,
toBridgeAddress,
0
)
signatures.push(signer0)
if (process.env.PROD){
if (process.env.PRIVATE_KEY2){
const signer1 = await signHashedTransaction(
extractFulfillTransaction(tx),
chainId,
Expand Down
2 changes: 1 addition & 1 deletion backend-usdc/src/services/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion backend-usdt/src/services/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion backend-wnt/src/services/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/services/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/api/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@ 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) => {
return JSON.parse(data)
},
],
})
}


const axiosClient = axios.create({
baseURL,
Expand Down Expand Up @@ -84,6 +87,7 @@ export async function getTokenSignature(
fromUser: string,
index: number
): Promise<string | string[]> {
console.log(symbol, 'sdkd')
const [response, error] = await safe(
axiosClientToken(symbol).get<{ signature: string | string[] }>(SIGN, {
params: { fromBridgeAddress, toBridgeAssistAddress, fromChain, fromUser, index },
Expand Down
47 changes: 24 additions & 23 deletions frontend/src/components/popups/ConnectDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,6 @@
WalletConnect
</div>
</GButton>

<GButton
secondary
@click="
() => {
connectOKXWallet()
dialogs.closeCurrentDialog()
}
"
class="w-full h-[50px]"
>
<div
class="flex items-center justify-center font-medium gap-2 w-full text-[16px] h-full z-30 button-text"
>
<OKXWalletIcon class="hidden md:block w-[24px] h-[24px]" />
<OKXWalletIcon class="md:hidden block w-[24px] h-[24px]" size="24px" />
OKX Wallet
</div>
</GButton>
<GButton
secondary
@click="
Expand All @@ -81,7 +62,7 @@
MAD Wallet
</div>
</GButton>
<!-- <GButton
<GButton
secondary
@click="
() => {
Expand All @@ -98,8 +79,8 @@
<CoinbaseIcon class="md:hidden block" size="24px" />
Coinbase
</div>
</GButton> -->
<!-- <div class="w-full hidden md:block">
</GButton>
<div class="w-full hidden md:block">
<GButton
secondary
@click="
Expand All @@ -118,7 +99,27 @@
Trust wallet
</div>
</GButton>
</div> -->
</div>
<GButton
secondary
@click="
() => {
connectOKXWallet()
dialogs.closeCurrentDialog()
}
"
class="w-full h-[50px]"
>
<div
class="flex items-center justify-center font-medium gap-2 w-full text-[16px] h-full z-30 button-text"
>
<OKXWalletIcon class="hidden md:block w-[24px] h-[24px]" />
<OKXWalletIcon class="md:hidden block w-[24px] h-[24px]" size="24px" />
OKX Wallet
</div>
</GButton>



</div>
</div>
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/gotbit-tools/vue/utils/stores/web3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>

Expand Down Expand Up @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/gotbit-tools/vue/utils/wallets/trustwallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/gotbit.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
1 change: 0 additions & 1 deletion frontend/src/store/business/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ const createAction = async (
return 'Warning! An error has occurred. Please try again.'
}
}

if (web3.realChainId !== uiBridge.network) {
dialogs.openDialog(
'waitDialog',
Expand Down
44 changes: 4 additions & 40 deletions frontend/src/store/contracts/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,10 @@ export const useBridge = defineContractStore<IBridgeAssistState, IBridgeAssistAc
const { supportedChains, assistAndTokenAddresses } = useFactory()

const token = useToken()


await Promise.all((supportedChains as ChainId[]).map(async chainId => {
for (const chainId of supportedChains as ChainId[]) {
// const { bridgeAssist } = useContracts(undefined, chainId)
let tokenAddr = token.tokenAddress
// const tokenAddr =
// token.symbol === 'RWA' && chainId === '42421'
Expand Down Expand Up @@ -300,44 +302,7 @@ export const useBridge = defineContractStore<IBridgeAssistState, IBridgeAssistAc
)
)
}
}))

// for (const chainId of supportedChains as ChainId[]) {
// // const { bridgeAssist } = useContracts(undefined, chainId)
// let tokenAddr = token.tokenAddress
// // const tokenAddr =
// // token.symbol === 'RWA' && chainId === '42421'
// // ? DEFAULT_NATIVE_TOKEN_CONTRACT_2
// // : token.tokenAddress
// if (
// (token.symbol === 'RWA' && chainId === '42421') ||
// (token.symbol === 'BTC' && chainId === '200810')
// ) {
// tokenAddr = DEFAULT_NATIVE_TOKEN_CONTRACT_2
// } else {
// const tokens = token.tokens[chainId]
// if (tokens) {
// const _token = tokens.find((t) => 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
},
Expand All @@ -349,7 +314,6 @@ export const useBridge = defineContractStore<IBridgeAssistState, IBridgeAssistAc
const fulfilled: Record<string, boolean> = {}
const claimInfo: Record<string, FulfillInfo> = {}
const transactions: TransactionContract[] = await this.getTransactions()

let symbol = ''

await Promise.all(transactions.map(async transaction => {
Expand Down

0 comments on commit 4e79224

Please sign in to comment.