Skip to content

Commit

Permalink
Merge pull request #53 from VerusCoin/gateway
Browse files Browse the repository at this point in the history
Gateway
  • Loading branch information
Asherda authored Oct 22, 2020
2 parents ad2ea39 + a8ec20c commit e300731
Show file tree
Hide file tree
Showing 29 changed files with 524 additions and 58 deletions.
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ stages:
- build

variables:
VERSION: 0.2.0-beta
VERSION: 0.2.0-beta-1
POST_MESSAGE: "Pipeline Trigger: ${CI_PIPELINE_SOURCE}\n
Branch: ${CI_COMMIT_REF_NAME}\n
Commit: ${CI_COMMIT_SHA}\n
Expand Down Expand Up @@ -40,7 +40,7 @@ Android:release:
- yarn install
- cd android
- echo ${KEYSTORE} | xxd -r -p - > app/${MYAPP_RELEASE_STORE_FILE}
- ./gradlew assembleRelease;
- ./gradlew assembleRelease
- rm app/${MYAPP_RELEASE_STORE_FILE}
after_script:
- curl -F file=@"android/app/build/outputs/apk/release/VerusMobile-${VERSION}.apk"
Expand Down
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.android.build.OutputFile
def versionMajor = 0
def versionMinor = 2
def versionRevision = 0
def versionBuild = 0
def versionBuild = 1

def keystorePropertiesFile = rootProject.file("keystore.properties");

Expand Down
4 changes: 2 additions & 2 deletions ios/verusMobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0.05;
CURRENT_PROJECT_VERSION = 0.06;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = J8Y97B5NMQ;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -981,7 +981,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0.05;
CURRENT_PROJECT_VERSION = 0.06;
DEVELOPMENT_TEAM = J8Y97B5NMQ;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = verusmobile/Info.plist;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"dependencies": {
"@babel/core": "^7.6.2",
"@babel/runtime": "^7.6.2",
"@ethersproject/signing-key": "^5.0.5",
"@react-native-community/art": "^1.2.0",
"@react-native-community/async-storage": "^1.5.1",
"@react-native-community/cameraroll": "^4.0.1",
Expand Down
134 changes: 134 additions & 0 deletions src/components/RFoxClaim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
This component creates a modal to claim RFox
migrated funds
*/

import { ethers } from "ethers";
import React, { Component } from "react"
import {
View,
Modal,
Text,
ScrollView,
Alert,
} from "react-native"
import AlertAsync from "react-native-alert-async";
import StandardButton from "../components/StandardButton"
import Colors from '../globals/colors';
import Styles from '../styles/index'
import { claimRFoxAccountBalances, estimateGasClaimRFoxAccountBalances } from "../utils/api/channels/erc20/requests/specific/rfox/claimAccountBalance";
import { ETHERS } from "../utils/constants/web3Constants";

class RFoxClaim extends Component {
constructor(props) {
super(props)
this.state = {
loading: false,
rewards: ethers.utils.formatUnits(props.rewards)
}
}

cancelHandler = () => {
if (this.props.cancel) {
this.props.cancel()
}
}

canClaim = (feeString) => {
return AlertAsync(
'Claim RFOX?',
`Would you like to claim ${this.state.rewards} RFOX? This action will cost you an estimated ${feeString} ETH in fees.`,
[
{
text: 'No',
onPress: () => Promise.resolve(false),
style: 'cancel',
},
{text: 'Yes', onPress: () => Promise.resolve(true)},
],
{
cancelable: false,
},
)
}

claim = () => {
this.setState({ loading: true }, async () => {
try {
const gasFee = ethers.utils.formatUnits(
await estimateGasClaimRFoxAccountBalances(
this.props.pubKey,
this.props.fromAddress
),
ETHERS
);

if (await this.canClaim(gasFee.toString())) {
try {
await claimRFoxAccountBalances(this.props.privKey, this.props.pubKey)

this.props.onSuccess()
} catch(e) {
console.error(e)
Alert.alert("Error", "Error claiming RFOX funds, try adding ETH to your wallet to cover fees, and claim again.")
this.setState({
loading: false
})
}
}
} catch(e) {
console.error(e)
Alert.alert("Error", "Error estimating gas for claim tx.")
}

this.setState({ loading: false })
})
}

render() {
return (
<Modal
animationType={this.props.animationType}
transparent={false}
visible={this.props.visible}
onRequestClose={this.cancelHandler}>
<ScrollView
style={Styles.flexBackground}
contentContainerStyle={Styles.centerContainer}>
<View style={Styles.headerContainer}>
<Text style={Styles.centralHeader}>
{"Claim RFox Funds"}
</Text>
</View>
<View style={Styles.standardWidthFlexGrowCenterBlock}>
<Text style={Styles.centralInfoTextPadded}>
{'You have the following funds available to claim.'}
</Text>
<Text style={Styles.seedWord}>{this.state.rewards + " RFOX"}</Text>
<Text style={Styles.centralLightTextPadded}>
{"Press the claim button to add them to your wallet!"}
</Text>
</View>
<View style={Styles.footerContainer}>
<View style={Styles.standardWidthSpaceBetweenBlock}>
<StandardButton
color={Colors.warningButtonColor}
disabled={this.state.loading}
title="CLOSE"
onPress={this.cancelHandler}
/>
<StandardButton
color={Colors.successButtonColor}
disabled={this.state.loading}
title="CLAIM"
onPress={this.claim}
/>
</View>
</View>
</ScrollView>
</Modal>
);
}
}

export default RFoxClaim;
30 changes: 19 additions & 11 deletions src/components/TxDetailsModal/TxDetailsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@ class TxDetailsModal extends Component {
<View style={Styles.infoTable}>
<View style={Styles.infoTableRow}>
<Text style={Styles.infoTableHeaderCell}>Type:</Text>
<Text style={{...Styles.infoTableCell, ...Styles.capitalizeFirstLetter}}>
<Text
style={{
...Styles.infoTableCell,
...Styles.capitalizeFirstLetter,
}}
>
{txData.type || "??"}
</Text>
</View>
Expand All @@ -142,16 +147,19 @@ class TxDetailsModal extends Component {
</Text>
</View>
)}
<View style={Styles.infoTableRow}>
<Text style={Styles.infoTableHeaderCell}>
Confirmations:
</Text>
<Text style={Styles.infoTableCell}>
{txData.confirmations != null
? txData.confirmations
: "??"}
</Text>
</View>
{explorers[activeCoinID] &&
explorers[activeCoinID].includes("etherscan") ? (
<View style={Styles.infoTableRow}>
<Text style={Styles.infoTableHeaderCell}>
{"Confirmations:"}
</Text>
<Text style={Styles.infoTableCell}>
{txData.confirmations != null
? txData.confirmations
: "??"}
</Text>
</View>
) : null}
<View style={Styles.infoTableRow}>
<Text style={Styles.infoTableHeaderCell}>Address:</Text>
<Text
Expand Down
Loading

0 comments on commit e300731

Please sign in to comment.