@xterio-sdk/rn-wallet
v0.1.3
Published
xterio wallet service in react native
Readme
@xterio-sdk/rn-wallet
xterio wallet service in react native
Installation
npm install @xterio-sdk/rn-wallet @xterio-sdk/rn-auth
# only ios
npx pod-install
# 或
cd ios && pod install && cd ..Usage
import {
SendTransactionMode,
useXterioTransaction,
useXterioWalletContext,
XterioWalletProvider,
IXterioWalletContextProps
} from '@xterio-sdk/rn-wallet';
// ...
//provider setup
const options:IXterioWalletContextProps = {
env: Env.Dev,
transactionMode:SendTransactionMode.Gasless,
}
<XterioWalletProvider {...options}>
<AppView />
</XterioWalletProvider>
//useXterioWalletContext(), useXterioTransaction()
const {
connectWallet,
disconnectWallet,
obtainWallet,
switchChain,
openWallet,
signMessage,
isConnect,
aaAddress
} = useXterioWalletContext();
const { sendTransaction, sendUserOperation, state } = useXterioTransaction(erc20,'transfer');
Configuration
There are two methods for automatic linking of the
ParticlenNetworkseries modules.One is to find the project
react-native.config.jsfile and add thedependenciesconfiguration item as follows;the other is to directly install the corresponding module.
npm install @particle-network/[email protected] @particle-network/[email protected] @particle-network/[email protected].
//...
dependencies: {
//...
'@particle-network/rn-base': {},
'@particle-network/rn-auth-core': {},
'@particle-network/rn-aa': {},
//...
},iOS
At the root of your Xcode project, create a new file, ParticleNetwork-Info.plist. Ensure this is marked under “Target Membership.”
From here, with a fresh ParticleNetwork-Info.plist file, go ahead and fill it in with the following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PROJECT_UUID</key>
<string>YOUR_PROJECT_UUID</string>
<key>PROJECT_CLIENT_KEY</key>
<string>YOUR_PROJECT_CLIENT_KEY</string>
<key>PROJECT_APP_UUID</key>
<string>YOUR_PROJECT_APP_UUID</string>
</dict>
</plist>
Finally, you’ll need to edit your Podfile to align with the snippet below; this is required for all iOS projects that leverage Particle Auth Core.

Android
If you’re planning on using Android for your React Native application, ensure you meet the following prerequisites (otherwise, expect issues or non-functionality):

API Reference
XterioWalletProvider
the wallet context
<XterioWalletProvider transactionMode={} PN_CHAIN_ID={} PN_PROJECT_ID={} PN_CLIENT_KEY={} PN_APP_ID={}>
<AppView />
</XterioWalletProvider>useXterioWalletContext()
aaAddress
xterio user aa wallet address
isConnect
aa wallet connection status
connectWallet(chainId?:number): Promise<void>
disconnectWallet(): Promise<void>
obtainWallet(): Promise<void>
switchChain(chainId:number): Promise<void>
signMessage(message: string, uniq?: boolean) :Promise<string>
useXterioTransaction(contract?, funcName?)
state
transaction status
sendTransaction(...args:any[], tx?:TransactionParam)
send a transaction
await sendTransaction?.(toAddr, amount, {value:'', gasLimit:''})sendUserOperation(tx: TransactionParam|TransactionParam[])
send a transaction
await sendUserOperation?.({to:'', data:''})Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Made with create-react-native-library
