@avvy/react-native-provider
v1.0.2
Published
Avvy Domains uses a Poseidon hash to generate IDs for domains.
Downloads
2
Readme
Overview
Avvy Domains uses a Poseidon hash to generate IDs for domains.
Circomlib's poseidon implementation requires WebAssembly which is not supported by React Native. This project runs poseidon hashing calculations required by the Avvy Domains within a React Native Webview.
Installation
- Install this package
npm i --save @avvy/react-native-provider
- Install
react-native-webview
Follow the Getting Started Guide for React Native Webview to complete the installation.
- Set up ethers in React Native
ethers requires some special installation in React Native. Follow the ethers.js React Native Cookbook for setup.
- Install the Avvy client
npm i --save @avvy/client
Usage
import "@ethersproject/shims"
import { ethers } from 'ethers'
import AvvyProvider from '@avvy/react-native-provider'
import AVVY from '@avvy/client'
class App extends React.Component {
initAvvy = async (poseidon) => {
const provider = new ethers.providers.JsonRpcProvider(CCHAIN_RPC_URL)
const avvy = new AVVY(provider, {
poseidon
})
// now you can perform actions with the Avvy client.
const evmAddress = await avvy.name('avvydomains.avax').resolve(avvy.RECORDS.EVM)
}
render() {
// the AvvyProvider must always be rendered in your application to keep the Webview live.
return (
<AvvyProvider poseidon={(poseidon) => this.initAvvy(poseidon)} />
);
}
}
Project Structure
The javascript that is injected into the Webview is generated in the webview/
directory. Please see webview/README.md
for more details.