-
Notifications
You must be signed in to change notification settings - Fork 0
Xdefi Wallet Context Provider #1
base: develop
Are you sure you want to change the base?
Conversation
- if xdefi wallet is connected exposes a bitcoin and litecoin provider - creates a context provider to pass wrapped wallet provider
export interface IXfiBitcoinProvider { | ||
accounts: string[] | ||
chainId: string | ||
network: string | ||
request: (e: { method: string; params: any[] }, cb: AnyFunction) => Promise<any> | ||
signTransaction: (e: any) => Promise<void> | ||
transfer: (e: any) => Promise<void> | ||
} | ||
|
||
export interface IXfiLitecoinProvider { | ||
accounts: string[] | ||
chainId: string | ||
network: string | ||
request: (e: { method: string; params: any[] }, cb: AnyFunction) => void | ||
transfer: (e: any) => void | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is set up so that when a XDEFI wallet is connected then it will grab the accounts of the needed wallets, in this case litecoin
and bitcoin
and gather some general information about the connection in a 'provider' object.
For bitcoin it exposes the request
, signTransaction
, and transfer
methods.
https://sdk.xdefi.io/docs/HEAD/bitcoin.html
For litecoin it exposes the request
and transfer
methods.
https://sdk.xdefi.io/docs/HEAD/litecoin.html
These will allow you to interact with these chains
export interface InitialState { | ||
ethereumWallet: HDWallet | null | ||
xfiBitcoinProvider: IXfiBitcoinProvider | null | ||
xfiLitecoinProvider: IXfiLitecoinProvider | null | ||
isWalletLoading: boolean | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The state interface that is provided by the useXDEFIProvider
hook.
The etereumWallet is the Wallet created when connecting via Shapeshift's interface. this is for easy access to the other wallets when connected to any other ethereum wallet.
Overview
Creates a context wrapper that exposes xdefi bitcoin and litecoin providers when xdefi wallet is connected.
Notes
There are three states that this provider will be in
XDEFI_CONNECTED
Xdefi wallet is propoerly connected.
returned state
XDEFI_NOT_CONNECTED
A different wallet is connected. in this case the ethereum wallet is set leaving
bitcoin
andlitecoin
providersnull
NOT_CONNECTED
No Wallet is connected (default state)
USUAGE
import the Provider component and wrap
and easily use the custom hook in children