0.2.14 • Published 2 years ago
react-native-v99-sdk v0.2.14
react-native-v99-sdk
v99 SDK
Installation
yarn add react-native-v99-sdk
Then install all dependencies
yarn add buffer metro-react-native-babel-preset react-native-quick-crypto readable-stream constants assert @craftzdog/react-native-buffer react-native-device-info react-native-keychain react-native-mmkv babel-plugin-module-resolver
Install pod
cd ios && pod install
Usage
import { ActionType } from 'app-v99-common';
import * as React from 'react';
import { useEffect } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import V99SDK from 'react-native-v99-sdk';
const secretKey =
'-----BEGIN PUBLIC KEY-----' +
'MIGeMA0GCSqGSIb3DQEBAQUAA4GMADCBiAKBgH8pomuNWl6EU/ImgspO1dbilxfZ' +
'uXYwt4GILQQcj+iIL9IK4ZVRGRleuumPw21B2d7C2RsoK44w+kEa7Mo8C5cpM/mE' +
'UEreowgvjGEyqVcDagECMErsXFO9i+8KxZ9WRu4zGHgx7cqUOIy8rT/z+mr4ktar' +
'9LYzbJzYeflDCytTAgMBAAE=' +
'-----END PUBLIC KEY-----';
export function App() {
const [result, setResult] = React.useState<string | undefined>();
useEffect(async () => {
const sdk = new V99SDK();
const isInitialized = await sdk.init('miniapp1', secretKey);
if (!isInitialized) {
setResult('SDK is not initialized');
return;
}
const mnemonic = await sdk.wallet.generateMnemonic();
setResult(mnemonic);
sdk.app.onSessionExpired(() => {
console.log('on onSessionExpired');
});
sdk.app.onAccountChanged((account) => {
console.log('on onAccountChanged', account);
});
}, []);
return (
<View style={styles.container}>
<Text>Result: {result}</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
});
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