Skip to content

Commit

Permalink
feature(resolver): preprod support (#3264)
Browse files Browse the repository at this point in the history
  • Loading branch information
stackchain authored May 20, 2024
2 parents d1b20f3 + a6ceba1 commit fb225e2
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 60 deletions.
10 changes: 5 additions & 5 deletions apps/wallet-mobile/src/TxHistory/TxHistoryNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ import {
} from '../navigation'
import {COLORS} from '../theme'
import {useFrontendFees, useStakingKey, useWalletName} from '../yoroi-wallets/hooks'
import {isMainnetNetworkId} from '../yoroi-wallets/utils'
import {ModalInfo} from './ModalInfo'
import {TxDetails} from './TxDetails'
import {TxHistory} from './TxHistory'
Expand All @@ -86,17 +85,17 @@ export const TxHistoryNavigator = () => {
const {frontendFees} = useFrontendFees(wallet)
const stakingKey = useStakingKey(wallet)
const swapManager = React.useMemo(() => {
const aggregatorTokenId = isMainnetNetworkId(wallet.networkId) ? milkTokenId.mainnet : milkTokenId.preprod
const aggregatorTokenId = wallet.isMainnet ? milkTokenId.mainnet : milkTokenId.preprod
const swapStorage = swapStorageMaker()
const swapApi = swapApiMaker({
isMainnet: isMainnetNetworkId(wallet.networkId),
isMainnet: wallet.isMainnet,
stakingKey,
primaryTokenId: wallet.primaryTokenInfo.id,
supportedProviders,
})
const frontendFeeTiers = frontendFees?.[aggregator] ?? ([] as const)
return swapManagerMaker({swapStorage, swapApi, frontendFeeTiers, aggregator, aggregatorTokenId})
}, [wallet.networkId, wallet.primaryTokenInfo.id, stakingKey, frontendFees])
}, [wallet.isMainnet, wallet.primaryTokenInfo.id, stakingKey, frontendFees])

// resolver
const resolverManager = React.useMemo(() => {
Expand All @@ -107,11 +106,12 @@ export const TxHistoryNavigator = () => {
},
},
cslFactory: init,
isMainnet: wallet.isMainnet,
})
const walletStorage = storage.join(`wallet/${wallet.id}/`)
const resolverStorage = resolverStorageMaker({storage: walletStorage})
return resolverManagerMaker(resolverStorage, resolverApi)
}, [storage, wallet.id])
}, [storage, wallet.id, wallet.isMainnet])

// claim
const claimApi = React.useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"start": {
"line": 435,
"column": 16,
"index": 17003
"index": 16958
},
"end": {
"line": 438,
"column": 3,
"index": 17092
"index": 17047
}
},
{
Expand All @@ -21,12 +21,12 @@
"start": {
"line": 439,
"column": 32,
"index": 17126
"index": 17081
},
"end": {
"line": 442,
"column": 3,
"index": 17239
"index": 17194
}
},
{
Expand All @@ -36,12 +36,12 @@
"start": {
"line": 443,
"column": 13,
"index": 17254
"index": 17209
},
"end": {
"line": 446,
"column": 3,
"index": 17327
"index": 17282
}
},
{
Expand All @@ -51,12 +51,12 @@
"start": {
"line": 447,
"column": 17,
"index": 17346
"index": 17301
},
"end": {
"line": 450,
"column": 3,
"index": 17423
"index": 17378
}
},
{
Expand All @@ -66,12 +66,12 @@
"start": {
"line": 451,
"column": 15,
"index": 17440
"index": 17395
},
"end": {
"line": 454,
"column": 3,
"index": 17513
"index": 17468
}
},
{
Expand All @@ -81,12 +81,12 @@
"start": {
"line": 455,
"column": 21,
"index": 17536
"index": 17491
},
"end": {
"line": 458,
"column": 3,
"index": 17631
"index": 17586
}
},
{
Expand All @@ -96,12 +96,12 @@
"start": {
"line": 459,
"column": 14,
"index": 17647
"index": 17602
},
"end": {
"line": 462,
"column": 3,
"index": 17728
"index": 17683
}
},
{
Expand All @@ -111,12 +111,12 @@
"start": {
"line": 463,
"column": 13,
"index": 17743
"index": 17698
},
"end": {
"line": 466,
"column": 3,
"index": 17823
"index": 17778
}
},
{
Expand All @@ -126,12 +126,12 @@
"start": {
"line": 467,
"column": 18,
"index": 17843
"index": 17798
},
"end": {
"line": 470,
"column": 3,
"index": 17944
"index": 17899
}
},
{
Expand All @@ -141,12 +141,12 @@
"start": {
"line": 471,
"column": 20,
"index": 17966
"index": 17921
},
"end": {
"line": 474,
"column": 3,
"index": 18055
"index": 18010
}
},
{
Expand All @@ -156,12 +156,12 @@
"start": {
"line": 475,
"column": 26,
"index": 18083
"index": 18038
},
"end": {
"line": 478,
"column": 3,
"index": 18187
"index": 18142
}
},
{
Expand All @@ -171,12 +171,12 @@
"start": {
"line": 479,
"column": 19,
"index": 18208
"index": 18163
},
"end": {
"line": 482,
"column": 3,
"index": 18301
"index": 18256
}
},
{
Expand All @@ -186,12 +186,12 @@
"start": {
"line": 483,
"column": 16,
"index": 18319
"index": 18274
},
"end": {
"line": 486,
"column": 3,
"index": 18405
"index": 18360
}
},
{
Expand All @@ -201,12 +201,12 @@
"start": {
"line": 487,
"column": 19,
"index": 18426
"index": 18381
},
"end": {
"line": 493,
"column": 3,
"index": 18664
"index": 18619
}
},
{
Expand All @@ -216,12 +216,12 @@
"start": {
"line": 494,
"column": 27,
"index": 18693
"index": 18648
},
"end": {
"line": 497,
"column": 3,
"index": 18786
"index": 18741
}
},
{
Expand All @@ -231,12 +231,12 @@
"start": {
"line": 498,
"column": 13,
"index": 18801
"index": 18756
},
"end": {
"line": 501,
"column": 3,
"index": 18876
"index": 18831
}
},
{
Expand All @@ -246,12 +246,12 @@
"start": {
"line": 502,
"column": 25,
"index": 18903
"index": 18858
},
"end": {
"line": 505,
"column": 3,
"index": 18977
"index": 18932
}
},
{
Expand All @@ -261,12 +261,12 @@
"start": {
"line": 506,
"column": 18,
"index": 18997
"index": 18952
},
"end": {
"line": 509,
"column": 3,
"index": 19111
"index": 19066
}
},
{
Expand All @@ -276,12 +276,12 @@
"start": {
"line": 510,
"column": 28,
"index": 19141
"index": 19096
},
"end": {
"line": 513,
"column": 3,
"index": 19237
"index": 19192
}
},
{
Expand All @@ -291,12 +291,12 @@
"start": {
"line": 514,
"column": 29,
"index": 19268
"index": 19223
},
"end": {
"line": 517,
"column": 3,
"index": 19376
"index": 19331
}
},
{
Expand All @@ -306,12 +306,12 @@
"start": {
"line": 518,
"column": 30,
"index": 19408
"index": 19363
},
"end": {
"line": 521,
"column": 3,
"index": 19518
"index": 19473
}
}
]
10 changes: 8 additions & 2 deletions packages/resolver/src/adapters/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {handleApiGetCryptoAddress} from './handle/api'
import {unstoppableApiGetCryptoAddress} from './unstoppable/api'
import {cnsCryptoAddress} from './cns/api'
import {WasmModuleProxy} from '@emurgo/cross-csl-core'
import {fetchData} from '@yoroi/common'

type ApiConfig = {
[Resolver.NameServer.Unstoppable]: {
Expand All @@ -28,9 +29,11 @@ export const resolverApiMaker = (
{
apiConfig,
cslFactory,
isMainnet = true,
}: {
apiConfig: Readonly<ApiConfig>
cslFactory: (scope: string) => WasmModuleProxy
isMainnet?: boolean
},
{
unstoppableApi,
Expand All @@ -48,11 +51,14 @@ export const resolverApiMaker = (
}
} = initialDeps,
): Resolver.Api => {
const getHandleCryptoAddress = handleApi.getCryptoAddress()
const getHandleCryptoAddress = handleApi.getCryptoAddress({
request: fetchData,
isMainnet,
})
const getUnstoppableCryptoAddress = unstoppableApi.getCryptoAddress(
apiConfig[Resolver.NameServer.Unstoppable],
)
const getCnsCryptoAddress = cnsApi.getCryptoAddress(cslFactory)
const getCnsCryptoAddress = cnsApi.getCryptoAddress(cslFactory, isMainnet)
const operationsGetCryptoAddress: GetCryptoAddressOperations = [
[Resolver.NameServer.Handle, getHandleCryptoAddress],
[Resolver.NameServer.Unstoppable, getUnstoppableCryptoAddress],
Expand Down
Loading

0 comments on commit fb225e2

Please sign in to comment.