Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use RIF Wallet v2 core - Complete #26

Merged
merged 21 commits into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b651a4b
Replace lib/core with new SmartWallet.
jessgusclark Oct 19, 2021
c5950af
Fix lint issues and install a missing package.
jessgusclark Oct 19, 2021
c854520
Update context to accept the new structure.
jessgusclark Oct 19, 2021
31fbf39
Expose mnemonic from the kms via context.
jessgusclark Oct 19, 2021
0d63c1f
Update core from rif-wallet.
jessgusclark Oct 20, 2021
5618f4c
Implement new core changes into the HomeScreen (src/App.tsx)
jessgusclark Oct 20, 2021
8167ac8
Update SmartWallet to use the new RIFWallet instance.
jessgusclark Oct 20, 2021
c1eca83
Update receive screen to use new RIFWallet.
jessgusclark Oct 20, 2021
56df04b
Fix test, smartWalletAddress is no longer a promise.
jessgusclark Oct 20, 2021
5875827
Fix lint issues.
jessgusclark Oct 20, 2021
e2b41b9
Update SmartWallet screen to get RIF and send transaction.
jessgusclark Oct 20, 2021
42fced9
Fix test.
jessgusclark Oct 20, 2021
b440f3d
Fix lint.
jessgusclark Oct 20, 2021
545d499
Update core with October 20th updates
jessgusclark Oct 21, 2021
3e786dc
Query RIF and transfer balance using the library.
jessgusclark Oct 21, 2021
f2ab663
Merge branch 'main' into new-core
jessgusclark Oct 21, 2021
b6ef8c5
Rename files.
jessgusclark Oct 21, 2021
408e0df
Remove check if getSmartAddress has been called. It is no longer a pr…
jessgusclark Oct 21, 2021
8e282ac
fix failing test with act().
jessgusclark Oct 21, 2021
a77c4f3
Fix type path.
jessgusclark Oct 21, 2021
1639e32
Update core + changes in review tx
ilanolkies Oct 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/lib/core
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"@react-navigation/native": "^6.0.4",
"@react-navigation/stack": "^6.0.9",
"@rsksmart/rif-id-ethr-did": "^0.1.0",
"@rsksmart/rif-id-mnemonic": "^0.1.0",
"@rsksmart/rif-id-mnemonic": "^0.1.1",
"@rsksmart/rlogin-dpath": "^1.0.1",
"@rsksmart/rsk-contract-metadata": "^1.0.15",
"@rsksmart/rsk-testnet-contract-metadata": "^1.0.11",
"buffer": "^4.9.2",
Expand Down
37 changes: 22 additions & 15 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { NavigationProp, ParamListBase } from '@react-navigation/native'

import Button from './components/button'
import { Header1, Header2, Paragraph } from './components/typography'
import { Account, Wallet } from './lib/core'
import { RIFWallet } from './lib/core/RIFWallet'

import { WalletProviderContext } from './state/AppContext'
import { removeStorage, StorageKeys } from './storage'
Expand All @@ -19,42 +19,50 @@ const WalletApp: React.FC<Interface> = ({ navigation }) => {
// Temporary component state:
interface componentStateI {
confirmResponse?: string
wallet?: Wallet
wallet?: RIFWallet
}

const [wallet, setWallet] = useState<Wallet | undefined>(undefined)
const [accounts, setAccounts] = useState<Account[]>([])
const [wallet, setWallet] = useState<RIFWallet[]>([])
const [mnemonic, setMnemonic] = useState<string>('')

const context = useContext(WalletProviderContext)
useEffect(() => {
setWallet(context.wallet)
}, [context.wallet, wallet])
context.wallets && setWallet(context.wallets)
}, [context.wallets])

useEffect(() => {
console.log('setting Mnemonic', context.getMnemonic())
setMnemonic(context.getMnemonic())
}, [context.wallets])

/*
const addAccount = () => {
if (wallet) {
wallet
?.getAccount(accounts.length)
.then(account => setAccounts(accounts.concat(account)))
}
}
*/

const seeSmartWallet = (account: Account) =>
const seeSmartWallet = (account: RIFWallet) =>
navigation.navigate('SmartWallet', { account })

return (
<ScrollView>
<Header1>sWallet</Header1>
<View style={styles.section}>
<Header2>Wallet:</Header2>
{wallet && <CopyComponent value={wallet.getMnemonic} />}
<Header2>KMS:</Header2>
<CopyComponent value={mnemonic} />
</View>

<View style={styles.section}>
<Header2>Accounts:</Header2>
{accounts.map((account: Account, index: number) => {
<Header2>RIF Wallets:</Header2>
{wallet.map((account: RIFWallet, index: number) => {
return (
<View key={index}>
<CopyComponent value={account.address} />
<Paragraph>EOA Address</Paragraph>
<CopyComponent value={account.smartWallet.wallet.address} />
<Button
title="See smart wallet"
onPress={() => seeSmartWallet(account)}
Expand All @@ -65,21 +73,20 @@ const WalletApp: React.FC<Interface> = ({ navigation }) => {
/>
<Button
onPress={() => {
// @ts-ignore
navigation.navigate('SendTransaction', { account })
}}
title="Send Transaction"
/>
</View>
)
})}
<Button onPress={addAccount} title="Add account" />
{/*<Button onPress={addAccount} title="Add account" />*/}
</View>

<View style={styles.section}>
<Header2>Settings</Header2>
<Button
onPress={() => removeStorage(StorageKeys.MNEMONIC)}
onPress={() => removeStorage(StorageKeys.KMS)}
title="Clear RN Storage"
/>
<Paragraph>
Expand Down
4 changes: 2 additions & 2 deletions src/RootNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ const RootNavigation: React.FC<Interface> = () => {
</NavigationContainer>

{/* Modals: */}
{context.userInteractionQue.length !== 0 && (
{context.walletRequests[0] && (
<ReviewTransactionModal
closeModal={closeReviewTransactionModal}
queuedTransactionRequest={context.userInteractionQue[0]}
queuedTransactionRequest={context.walletRequests[0]}
/>
)}
</View>
Expand Down
152 changes: 0 additions & 152 deletions src/lib/core/Account.ts

This file was deleted.

Loading