Skip to content

Commit

Permalink
Fix zilpay connection issue
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenkhong committed Aug 9, 2023
1 parent 3067d41 commit 4b2bc84
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 25 deletions.
18 changes: 12 additions & 6 deletions src/app/saga/app/blockchainSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,18 @@ function* initialize(

const { network, wallet } = action.payload
const sdkState = (yield select((state: RootState) => state.carbonSDK.sdkCache)) as SimpleMap<CarbonSDK>
if (!sdkState[network]) {
const carbonNetwork = netZilToCarbon(network)
const carbonSDK: CarbonSDK = yield call(CarbonSDK.instance, {
network: carbonNetwork,
})
yield put(actions.CarbonSDK.updateCarbonSDK({ sdk: carbonSDK, network: network }))
try {
if (!sdkState[network]) {
const carbonNetwork = netZilToCarbon(network)
const carbonSDK: CarbonSDK = yield call(CarbonSDK.instance, {
network: carbonNetwork,
skipInit: true, // skip initialization while carbon chain undergoes upgrade.
})
yield put(actions.CarbonSDK.updateCarbonSDK({ sdk: carbonSDK, network: network }))
}
} catch (error) {
console.warn("failed to initialize Carbon SDK");
console.error(error);
}
const providerOrKey = getProviderOrKeyFromWallet(wallet)
const { observingTxs } = getTransactions(yield select())
Expand Down
20 changes: 1 addition & 19 deletions src/app/utils/bridge.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Blockchain, CarbonSDK, ConnectedCarbonSDK } from 'carbon-js-sdk'
import { Token } from 'carbon-js-sdk/lib/codec'
import { SimpleMap } from 'carbon-js-sdk/lib/util/type'
import { Network } from "zilswap-sdk/lib/constants"
import { BridgeableChains, BridgeableEvmChains } from 'app/store/types'
Expand Down Expand Up @@ -54,23 +53,6 @@ export const getTokenDenoms = (network: CarbonSDK.Network, chain: Blockchain) =>
return getTokenDenomList(network)[chain]
}

/**
* Returns a mapping of chains to their respective SWTH token info
* @param {CarbonSDK.Network} network
* @returns {SimpleMap<Token>}
*/
export const getSwthBridgeTokens = async (network: CarbonSDK.Network) => {
var ret: SimpleMap<Token> = {}
const carbonSdk: CarbonSDK = await CarbonSDK.instance({ network })
const carbonTokens: Token[] = Object.values(carbonSdk.token.tokens)
const swthBridgeDenoms = getTokenDenomList(network)
Object.entries(swthBridgeDenoms).forEach(([chain, denom]) => {
const swthToken = carbonTokens.find(d => d.denom === denom)!
ret[chain] = swthToken
})
return ret
}

/**
* Returns a readonly map of EVM Blockchains to their respective chain IDs
* @param {Network} network The selected Zilliqa network based on wallet (mainnet/ testnet)
Expand Down Expand Up @@ -288,4 +270,4 @@ export const getChainParams = (network: Network) => {
},
}
}
}
}

0 comments on commit 4b2bc84

Please sign in to comment.