Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

feat: auto-add the recipient if loading the modal using a URI #1936

Merged
merged 4 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -986,16 +986,16 @@ describe('TransactionFormTransfer', () => {
it('should load in schema form data', () => {
wrapper.setProps({
schema: {
amount: (10 * 1e8).toString(),
address: 'address-5',
amount: 100,
vendorField: 'test vendorfield'
}
})

wrapper.vm.populateSchema()

expect(wrapper.vm.amount).toBe((10 * 1e8).toString())
expect(wrapper.vm.recipientId).toBe('address-5')
expect(wrapper.vm.form.recipients[0].address).toBe('address-5')
expect(wrapper.vm.form.recipients[0].amount).toEqual(new BigNumber(100 * 1e8))
expect(wrapper.vm.form.vendorField).toBe('test vendorfield')
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,26 @@ export default {
return
}

this.$set(this, 'amount', this.schema.amount || '')
this.$set(this, 'recipientId', this.schema.address || '')
this.$set(this.form, 'vendorField', this.schema.vendorField || '')
try {
if (this.schema.address && this.schema.amount) {
if (WalletService.validateAddress(this.schema.address, this.session_network.version)) {
this.$v.form.recipients.$model = []
this.$v.form.recipients.$model.push({
address: this.schema.address,
amount: this.currency_unitToSub(this.schema.amount),
sendAll: false
})
} else {
throw new Error(this.$t('VALIDATION.RECIPIENT_DIFFERENT_NETWORK', [
this.wallet_truncate(this.schema.address)
]))
}
}

this.$set(this.form, 'vendorField', this.schema.vendorField || '')
} catch (error) {
this.$error(`${this.$t('TRANSACTION.ERROR.LOAD_FROM_URI')}: ${error.message}`)
}

if (this.schema.wallet) {
const currentProfileId = this.$store.getters['session/profileId']
Expand Down
1 change: 1 addition & 0 deletions src/renderer/i18n/locales/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,7 @@ export default {
LEDGER_SIGN_FAILED: 'Could not sign transaction with Ledger',
LEDGER_USER_DECLINED: 'User declined',
LOAD_FROM_FILE: 'Load transaction from file',
LOAD_FROM_URI: 'Load transaction from URI',
MULTIPLE: 'Multiple',
NONCE: 'Nonce',
NO_RECIPIENTS: 'There are no recipient(s)',
Expand Down