From de1270957000208bf1bb9f93b1738992b291a742 Mon Sep 17 00:00:00 2001 From: Michele Balistreri Date: Fri, 2 Oct 2020 12:08:08 +0200 Subject: [PATCH] start POS adaptation to new contract --- status-pay/dapps/pos/js/actions/index.js | 34 +++++++++-------------- status-pay/dapps/pos/js/components/App.js | 6 ---- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/status-pay/dapps/pos/js/actions/index.js b/status-pay/dapps/pos/js/actions/index.js index 6126258..82a9a47 100644 --- a/status-pay/dapps/pos/js/actions/index.js +++ b/status-pay/dapps/pos/js/actions/index.js @@ -1,9 +1,10 @@ -const StatusPay = artifacts.require('StatusPay'); +const StatusPay = artifacts.require('StatusPay'); // TODO: load JSON import { recoverTypedSignature } from 'eth-sig-util'; const addressZero = "0x0000000000000000000000000000000000000000"; -const tokenAddress = "0xc55cF4B03948D7EBc8b9E8BAD92643703811d162"; + +const statusPay; //TODO: initialize with web3/JSON export const NEW_WALLET = 'NEW_WALLET'; export const newWallet = () => ({ @@ -209,11 +210,11 @@ export const paymentRequested = () => ({ type: PAYMENT_REQUESTED, }); -export const sendPaymentRequest = (walletContract, message, sig) => { +export const sendPaymentRequest = (message, sig) => { return async (dispatch) => { try { dispatch(requestingPayment()) - const requestPayment = await walletContract.methods.requestPayment(message, sig); + const requestPayment = await statusPay.requestPayment(message, sig); const gas = await requestPayment.estimateGas(); const receipt = await requestPayment.send({ gas: gas @@ -230,24 +231,12 @@ export const loadWallet = (walletAddress, message, sig) => { return async (dispatch) => { dispatch(loadingWallet()) - const jsonInterface = KeycardWallet.options.jsonInterface; - const walletContract = new EmbarkJS.Blockchain.Contract({ - abi: jsonInterface, - address: walletAddress, - }); - walletContract.address = walletAddress; - - const erc20Contract = new EmbarkJS.Blockchain.Contract({ - abi: IERC20.options.jsonInterface, - address: tokenAddress, - }); - erc20Contract.address = tokenAddress; - - const balance = await erc20Contract.methods.balanceOf(walletAddress).call(); - const maxTxValue = await walletContract.methods.tokenMaxTxAmount(tokenAddress).call(); + const account = await statusPay.accounts(walletAddress).call(); + const balance = account.balance.toNumber(); + const maxTxValue = account.maxTxAmount.toNumber(); dispatch(walletLoaded(balance, maxTxValue)) - dispatch(sendPaymentRequest(walletContract, message, sig)) + dispatch(sendPaymentRequest(message, sig)) }; } @@ -277,7 +266,10 @@ export const paymentAmountValueChange = (value) => ({ export const findWallet = (keycardAddress, message, sig) => { return async (dispatch) => { dispatch(findingWallet()); - KeycardWalletFactory.methods.keycardsWallets(keycardAddress).call() + assert.equal((await token.balanceOf.call(owner)).toNumber(), 0); + assert.equal((await statusPay.accounts.call(account)).balance.toNumber(), 100); + + statusPay.keycards.call(keycardAddress) .then((address) => { //FIXME: if 0x00, display error if (address === addressZero) { diff --git a/status-pay/dapps/pos/js/components/App.js b/status-pay/dapps/pos/js/components/App.js index 33d3674..aa4023f 100644 --- a/status-pay/dapps/pos/js/components/App.js +++ b/status-pay/dapps/pos/js/components/App.js @@ -1,7 +1,6 @@ import React from 'react'; import Pos from "../containers/Pos" -import KeycardWalletFactory from 'Embark/contracts/KeycardWalletFactory'; import { withStyles } from '@material-ui/core/styles'; import AppBar from '@material-ui/core/AppBar'; @@ -9,8 +8,6 @@ import Toolbar from '@material-ui/core/Toolbar'; import Typography from '@material-ui/core/Typography'; import CircularProgress from '@material-ui/core/CircularProgress'; -import { compressedAddress } from '../utils'; - const styles = theme => ({ loading: { textAlign: "center", @@ -36,9 +33,6 @@ const App = (props) => { Keycard POS - - {compressedAddress(KeycardWalletFactory.address)} {networkText} -