Skip to content

Commit

Permalink
fix: invalid feedback modal on pin screen
Browse files Browse the repository at this point in the history
  • Loading branch information
andreabadesso committed Jul 11, 2024
1 parent 9aebf83 commit 3a16155
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 144 deletions.
2 changes: 2 additions & 0 deletions src/sagas/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ export function* startWallet(action) {
pin,
} = action.payload;

console.log('PIN: ', pin);

const uniqueDeviceId = getUniqueId();
const useWalletService = false; // yield call(isWalletServiceEnabled);
const usePushNotification = yield call(isPushNotificationEnabled);
Expand Down
10 changes: 6 additions & 4 deletions src/screens/CreateTokenConfirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class CreateTokenConfirm extends React.Component {
},
});
}, (err) => {
console.log('Err: ', err);
this.onError(err.message);
});
}
Expand All @@ -112,7 +113,7 @@ class CreateTokenConfirm extends React.Component {
*/
onSendPress = () => {
const params = {
cb: this.executeCreate,
cb: this.executeCreate.bind(this),
screenText: t`Enter your 6-digit pin to create your token`,
biometryText: t`Authorize token creation`,
canCancel: true,
Expand All @@ -138,6 +139,7 @@ class CreateTokenConfirm extends React.Component {
* @param {String} message Error message
*/
onError = (message) => {
console.log('Message on error: ', message);
this.setState({
modalType: 'FeedbackModal',
modal: {
Expand Down Expand Up @@ -169,9 +171,9 @@ class CreateTokenConfirm extends React.Component {
this.state.modalType === 'FeedbackModal' ? (
// eslint-disable-next-line react/jsx-indent
<FeedbackModal
icon={this.modal.icon}
text={this.modal.message}
onDismiss={this.modal.onDismiss}
icon={this.state.modal.icon}
text={this.state.modal.text}
onDismiss={this.state.modal.onDismiss}
/>
) : (
// eslint-disable-next-line react/jsx-indent
Expand Down
140 changes: 0 additions & 140 deletions src/screens/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,122 +25,6 @@ import { COLORS } from '../styles/themes';
import { TOKEN_DOWNLOAD_STATUS } from '../sagas/tokens';
import { NanoContractsList } from '../components/NanoContract/NanoContractsList';
import { getNanoContractFeatureToggle } from '../utils';
import { Address } from '@hathor/wallet-lib';

const MOCK_DEPOSIT = (wallet) => ({
type: 'WC_SESSION_REQUEST',
payload: {
id: 3,
topic: '6514868878fe1dadd648a495692d5ab9d458c7d45876f2c63e1e7274640a53d4',
jsonrpc: '2.0',
params: {
request: {
method: 'htr_sendNanoContractTx',
params: {
push_tx: true,
network: 'testnet',
method: 'bet',
blueprint_id: '3cb032600bdf7db784800e4ea911b10676fa2f67591f82bb62628c234e771595',
nc_id: '00002a71944472852754ed2f53dbd366b90b090bb319715e82f7fe0e786f0553',
actions: [{
type: 'deposit',
token: '00',
amount: 1
}],
args: [
(new Address('WdXfZ6zKa1mQpBAhGQVj9pCuWDqCrG5ZR6', {
network: wallet.getNetwork()
})).decode().toString('hex'),
'true'
],
},
},
},
},
});

const MOCK_INITIALIZE = (wallet) => ({
type: 'WC_SESSION_REQUEST',
payload: {
id: 3,
topic: '6514868878fe1dadd648a495692d5ab9d458c7d45876f2c63e1e7274640a53d4',
jsonrpc: '2.0',
params: {
request: {
method: 'htr_sendNanoContractTx',
params: {
push_tx: true,
network: 'testnet',
method: 'initialize',
blueprint_id: '3cb032600bdf7db784800e4ea911b10676fa2f67591f82bb62628c234e771595',
args: [
'76a914969647cffd30891b1444944ff228f3bd7582fa4588ac',
'00',
1720281665,
],
},
},
},
},
});

const MOCK_WITHDRAWL = (wallet) => ({
type: 'WC_SESSION_REQUEST',
payload: {
id: 3,
topic: '6514868878fe1dadd648a495692d5ab9d458c7d45876f2c63e1e7274640a53d4',
jsonrpc: '2.0',
params: {
request: {
method: 'htr_sendNanoContractTx',
params: {
push_tx: true,
network: 'testnet',
method: 'withdrawl',
blueprint_id: '3cb032600bdf7db784800e4ea911b10676fa2f67591f82bb62628c234e771595',
nc_id: '00002a71944472852754ed2f53dbd366b90b090bb319715e82f7fe0e786f0553',
actions: [{
type: 'withdrawal',
token: '00',
amount: 1
}],
},
},
},
},
});

const MOCK_SET_RESULT = (wallet) => ({
type: 'WC_SESSION_REQUEST',
payload: {
id: 3,
topic: '6514868878fe1dadd648a495692d5ab9d458c7d45876f2c63e1e7274640a53d4',
jsonrpc: '2.0',
params: {
request: {
method: 'htr_sendNanoContractTx',
params: {
push_tx: true,
network: 'testnet',
method: 'set_result',
blueprint_id: '3cb032600bdf7db784800e4ea911b10676fa2f67591f82bb62628c234e771595',
nc_id: '00002a71944472852754ed2f53dbd366b90b090bb319715e82f7fe0e786f0553',
actions: [{
type: 'deposit',
token: '00',
amount: 1
}],
args: [
(new Address('WdXfZ6zKa1mQpBAhGQVj9pCuWDqCrG5ZR6', {
network: wallet.getNetwork()
})).decode().toString('hex'),
'true'
],
},
},
},
},
});

/**
* State filter to retrieve token-related data from root state.
Expand Down Expand Up @@ -233,32 +117,8 @@ export const Dashboard = () => {
navigation.navigate('MainScreen');
}

const onInitializeNanoTx = () => {
dispatch(MOCK_INITIALIZE(wallet));
console.log('initialize call on nano contract');
};

const onSendNanoTx = () => {
dispatch(MOCK_DEPOSIT(wallet));
console.log('deposit call on nano contract');
};

const onWithdrawalNanoTx = () => {
dispatch(MOCK_WITHDRAWL(wallet));
console.log('withdrawal call on nano contract');
};

const onSetResultNanoTx = () => {
dispatch(MOCK_SET_RESULT(wallet));
console.log('set_result call on nano contract');
};

return (
<Wrapper>
<Button title='Deposit Nano Tx' onPress={onSendNanoTx} />
<Button title='Initialize Nano Tx' onPress={onInitializeNanoTx} />
<Button title='Withdrawal Nano Tx' onPress={onWithdrawalNanoTx} />
<Button title='Set Result Nano Tx' onPress={onSetResultNanoTx} />
<ShowPushNotificationTxDetails navigation={navigation} />
<AskForPushNotification navigation={navigation} />
<AskForPushNotificationRefresh />
Expand Down
6 changes: 6 additions & 0 deletions src/screens/PinScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ export default function PinScreen({ isLockScreen }) {
if (route.params.dispatchResponse) {
dispatch(pinScreenResult(pin));
}

// TODO: We need to refactor CreateTokenConfirm and SendConfirmScreen
// to stop passing a method as callback so we can remove this:
if (route.params.cb) {
route.params.cb(pin);
}
}
};

Expand Down
2 changes: 2 additions & 0 deletions src/screens/WalletConnect/SignMessageRequestScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { COLORS } from '../../styles/themes';
export function SignMessageRequestScreen({ route }) {
const { signMessageRequest } = route.params;

console.log('Sign Message Request: ', signMessageRequest);

return (
<Wrapper>
<HathorHeader
Expand Down

0 comments on commit 3a16155

Please sign in to comment.