Skip to content

Commit

Permalink
Wallet Provider Update
Browse files Browse the repository at this point in the history
  • Loading branch information
arietrouw committed Nov 22, 2023
1 parent a3195ab commit 0c1c4f4
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 4 deletions.
75 changes: 75 additions & 0 deletions .yarn/versions/d57f37c0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
releases:
"@xyo-network/react-address": patch
"@xyo-network/react-address-history": patch
"@xyo-network/react-address-plugin": patch
"@xyo-network/react-address-render": patch
"@xyo-network/react-aggregate-price-plugin": patch
"@xyo-network/react-app-settings": patch
"@xyo-network/react-appbar": patch
"@xyo-network/react-archivist": patch
"@xyo-network/react-block": patch
"@xyo-network/react-boundwitness-plugin": patch
"@xyo-network/react-card": patch
"@xyo-network/react-coin-gecko-prices-plugin": patch
"@xyo-network/react-crypto-market-uniswap-plugin": patch
"@xyo-network/react-crypto-prices-plugin": patch
"@xyo-network/react-default-plugin": patch
"@xyo-network/react-details-plugin": patch
"@xyo-network/react-diviner": patch
"@xyo-network/react-elevation-map-quadkey-plugin": patch
"@xyo-network/react-embed": patch
"@xyo-network/react-error": patch
"@xyo-network/react-ethereum-gas-price-blocknative-plugin": patch
"@xyo-network/react-ethereum-gas-price-etherchain-plugins": patch
"@xyo-network/react-ethereum-gas-price-etherchain-v2-plugin": patch
"@xyo-network/react-ethereum-gas-price-ethers-plugin": patch
"@xyo-network/react-ethereum-gas-price-etherscan-plugin": patch
"@xyo-network/react-ethereum-gas-price-ethgasstation-plugin": patch
"@xyo-network/react-ethereum-gas-price-payload-plugins": patch
"@xyo-network/react-ethereum-gas-price-plugin": patch
"@xyo-network/react-event": patch
"@xyo-network/react-footer": patch
"@xyo-network/react-gas-price": patch
"@xyo-network/react-location-heatmap-quadkey-plugin": patch
"@xyo-network/react-location-point-map-plugin": patch
"@xyo-network/react-location-points-map-plugin": patch
"@xyo-network/react-map": patch
"@xyo-network/react-module": patch
"@xyo-network/react-modules": patch
"@xyo-network/react-network": patch
"@xyo-network/react-nft-score-plugin": patch
"@xyo-network/react-node": patch
"@xyo-network/react-node-context": patch
"@xyo-network/react-node-provider": patch
"@xyo-network/react-node-renderer": patch
"@xyo-network/react-payload": patch
"@xyo-network/react-payload-context": patch
"@xyo-network/react-payload-details": patch
"@xyo-network/react-payload-diviner": patch
"@xyo-network/react-payload-huri": patch
"@xyo-network/react-payload-plugin": patch
"@xyo-network/react-payload-plugin-resolver": patch
"@xyo-network/react-payload-table": patch
"@xyo-network/react-pixel": patch
"@xyo-network/react-plugins": patch
"@xyo-network/react-pointer-plugin": patch
"@xyo-network/react-powered-by-xyo": patch
"@xyo-network/react-price-forecast-plugin": patch
"@xyo-network/react-property": patch
"@xyo-network/react-sample-node": patch
"@xyo-network/react-schema": patch
"@xyo-network/react-schema-plugin": patch
"@xyo-network/react-sdk": patch
"@xyo-network/react-sentinel": patch
"@xyo-network/react-share": patch
"@xyo-network/react-shared": patch
"@xyo-network/react-standard-node": patch
"@xyo-network/react-storybook": patch
"@xyo-network/react-table": patch
"@xyo-network/react-theme": patch
"@xyo-network/react-typedoc": patch
"@xyo-network/react-wallet": patch
"@xyo-network/react-wallet-service": patch
"@xyo-network/react-webapp": patch
"@xyo-network/react-witness": patch
"@xyo-network/sdk-xyo-react": patch
11 changes: 7 additions & 4 deletions packages/sdk/packages/wallet/src/contexts/Wallet/Provider.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { usePromise } from '@xylabs/react-promise'
import { WithChildren } from '@xylabs/react-shared'
import { WalletInstance } from '@xyo-network/wallet-model'
import { useEffect, useState } from 'react'

import { WalletContext } from './Context'
import { WalletRootPath } from './lib'
import { usePromise } from './usePromise'

export interface WalletProviderProps {
basePath?: string
Expand All @@ -30,18 +30,21 @@ export const WalletProvider: React.FC<WithChildren<WalletProviderProps>> = ({
const [coinTypeWallet = null] = usePromise(async () => {
// ensure the wallet has the proper base
if (rootWallet) {
if (!rootWallet?.path?.includes(basePath)) {
if (rootWallet?.path !== basePath) {
try {
return await rootWallet?.derivePath(basePath)
const result = await rootWallet?.derivePath(basePath)
return result
} catch (e) {
console.error('Error setting proper wallet base path', e)
}
}
} else {
return undefined
return rootWallet
}
}, [basePath, rootWallet])

console.log(`coinTypeWallet: ${coinTypeWallet}`)

const [activeAccount = null] = usePromise(
async () => await coinTypeWallet?.derivePath(activeAccountIndex.toString()),
[coinTypeWallet, activeAccountIndex],
Expand Down

0 comments on commit 0c1c4f4

Please sign in to comment.