Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function* makePayment({ monetaryAmount, recipient, walletOverride }) {
let signer;
let confOnDevice;
let confOnDeviceDone;
try {
const wallet = walletOverride || (yield (select(makeSelectCurrentWalletWithInfo()))).toJS();
if (wallet.encrypted && !wallet.decrypted) {
yield put(showDecryptWalletModal(actions.makeNahmiiPayment(monetaryAmount, recipient, walletOverride)));
yield put(actions.nahmiiPaymentError(new Error(getIntl().formatMessage({ id: 'wallet_encrypted_error' }))));
return;
}
const network = yield select(makeSelectCurrentNetwork());
const nahmiiProvider = network.nahmiiProvider;
[signer, confOnDevice, confOnDeviceDone] = yield call(getSdkWalletSigner, wallet);
const nahmiiWallet = new nahmii.Wallet(signer, nahmiiProvider);
const payment = new nahmii.Payment(monetaryAmount, wallet.address, recipient, nahmiiWallet);
if (confOnDevice) yield put(confOnDevice);
yield call([payment, 'sign']);
if (confOnDeviceDone) yield put(confOnDeviceDone);
yield call([payment, 'register']);
yield put(actions.nahmiiPaymentSuccess());
yield put(notify('success', getIntl().formatMessage({ id: 'sent_transaction_success' })));
} catch (e) {
if (confOnDeviceDone) yield put(confOnDeviceDone);
yield put(actions.nahmiiPaymentError(e));
yield put(notify('error', getIntl().formatMessage({ id: 'send_transaction_failed_message_error' }, { message: e.message })));
}
}