diff --git a/app/actions/ada/daedalus-transfer-actions.js b/app/actions/ada/daedalus-transfer-actions.js index 22cc3e5521..0c1eb8738e 100644 --- a/app/actions/ada/daedalus-transfer-actions.js +++ b/app/actions/ada/daedalus-transfer-actions.js @@ -4,7 +4,9 @@ import Action from '../lib/Action'; export default class DaedalusTranferActions { startTransferFunds: Action = new Action(); startTransferPaperFunds: Action = new Action(); - setupTransferFunds: Action = new Action(); + startTransferMasterKey: Action = new Action(); + setupTransferFundsWithMnemonic: Action = new Action(); + setupTransferFundsWithMasterKey: Action = new Action(); backToUninitialized: Action = new Action(); transferFunds: Action = new Action(); cancelTransferFunds: Action = new Action(); diff --git a/app/api/ada/daedalusTransfer.js b/app/api/ada/daedalusTransfer.js index 615d361e1b..7222871961 100644 --- a/app/api/ada/daedalusTransfer.js +++ b/app/api/ada/daedalusTransfer.js @@ -20,9 +20,6 @@ import { NoInputsError, GenerateTransferTxError } from './errors'; -import { - getCryptoDaedalusWalletFromMnemonics -} from './lib/cardanoCrypto/cryptoWallet'; import { getAllUTXOsForAddresses } from './adaTransactions/adaNewTransactions'; @@ -38,14 +35,11 @@ import { getReceiverAddress } from './adaAddress'; * @param fullUtxo the full utxo of the Cardano blockchain */ export function getAddressesWithFunds(payload: { - secretWords: string, + checker: CryptoAddressChecker, fullUtxo: Array }): Array { try { - const { secretWords, fullUtxo } = payload; - const checker: CryptoAddressChecker = getResultOrFail( - RandomAddressChecker.newCheckerFromMnemonics(secretWords) - ); + const { checker, fullUtxo } = payload; const addressesWithFunds: Array = getResultOrFail( RandomAddressChecker.checkAddresses(checker, fullUtxo) ); @@ -58,12 +52,12 @@ export function getAddressesWithFunds(payload: { /** Generate transaction including all addresses with no change */ export async function generateTransferTx(payload: { - secretWords: string, + wallet: CryptoDaedalusWallet, addressesWithFunds: Array }): Promise { try { - const { secretWords, addressesWithFunds } = payload; + const { wallet, addressesWithFunds } = payload; // fetch data to make transaction const senders = addressesWithFunds.map(a => a.address); @@ -78,8 +72,7 @@ export async function generateTransferTx(payload: { // pick which address to send transfer to const output = await getReceiverAddress(); - // get wallet and make transaction - const wallet = getCryptoDaedalusWalletFromMnemonics(secretWords); + // make transaction const tx: MoveResponse = getResultOrFail(Wallet.move(wallet, inputs, output)); // return summary of transaction diff --git a/app/api/ada/lib/cardanoCrypto/cryptoWallet.js b/app/api/ada/lib/cardanoCrypto/cryptoWallet.js index 337a899ba9..dac251643d 100644 --- a/app/api/ada/lib/cardanoCrypto/cryptoWallet.js +++ b/app/api/ada/lib/cardanoCrypto/cryptoWallet.js @@ -110,3 +110,16 @@ export function getCryptoDaedalusWalletFromMnemonics( wallet.config.protocol_magic = protocolMagic; return wallet; } + +/** Generate a Daedalus /wallet/ to create transactions. Do not save this. Regenerate every time. + * Note: key encoded as hex-string + */ +export function getCryptoDaedalusWalletFromMasterKey( + masterKey: string, +): CryptoDaedalusWallet { + const encodedKey = Buffer.from(masterKey, 'hex'); + + const wallet: CryptoDaedalusWallet = getResultOrFail(Wallet.fromDaedalusMasterKey(encodedKey)); + wallet.config.protocol_magic = protocolMagic; + return wallet; +} diff --git a/app/components/transfer/TransferInstructionsPage.js b/app/components/transfer/TransferInstructionsPage.js index dcfa1023d7..d2ab6baca5 100644 --- a/app/components/transfer/TransferInstructionsPage.js +++ b/app/components/transfer/TransferInstructionsPage.js @@ -10,11 +10,6 @@ import globalMessages from '../../i18n/global-messages'; import styles from './TransferInstructionsPage.scss'; const messages = defineMessages({ - instructionTitle: { - id: 'transfer.instructions.instructions.title.label', - defaultMessage: '!!!Instructions', - description: 'Label "Instructions" on the transfer instructions page.' - }, instructionsText: { id: 'transfer.instructions.instructions.text', defaultMessage: '!!!Before you can transfer funds, you must create a Yoroi wallet and back it up. Upon completion, you will receive a 15-word recovery phrase which can be used to restore your Yoroi wallet at any time.', @@ -33,15 +28,18 @@ const messages = defineMessages({ }); messages.fieldIsRequired = globalMessages.fieldIsRequired; +messages.instructionTitle = globalMessages.instructionTitle; type Props = { onFollowInstructionsPrerequisites: Function, onConfirm: Function, onPaperConfirm: Function, + onMasterKeyConfirm: Function, disableTransferFunds: boolean, attentionText: string, confirmationText: string, confirmationPaperText: string, + confirmationMasterKeyText: string, }; @observer @@ -57,10 +55,12 @@ export default class TransferInstructionsPage extends Component { onFollowInstructionsPrerequisites, onConfirm, onPaperConfirm, + onMasterKeyConfirm, disableTransferFunds, attentionText, confirmationText, confirmationPaperText, + confirmationMasterKeyText, } = this.props; const instructionsButtonClasses = classnames([ @@ -138,6 +138,14 @@ export default class TransferInstructionsPage extends Component { skin={ButtonSkin} /> +