11<template >
22 <ModalWrapper label =" Add Proposal" icon =" plus" >
33 <div >
4- <Dropdown mode =" accounts" @selected =" handleAccountSelection" />
5- <Dropdown mode =" accounts" @selected =" handleBeneficiary" />
6- <BalanceInput v-model =" value" />
7- <b-field label =" password 🤫 magic spell" class =" password-wrapper" >
8- <b-input v-model =" password" type =" password" password-reveal > </b-input >
9- </b-field >
10-
4+ <AccountSelect label =" submit with account" v-model =" accountId" />
5+ <AccountSelect label =" beneficiary" v-model =" beneficiaryId" />
6+ <BalanceInput v-model =" amount" />
7+ <PasswordInput v-model =" password" />
118 <b-button
129 type =" is-primary"
1310 icon-left =" paper-plane"
@@ -30,53 +27,47 @@ import { KeyringPair } from '@polkadot/keyring/types';
3027import { notificationTypes , showNotification } from ' @/utils/notification' ;
3128import exec from ' @/utils/transactionExecutor' ;
3229import { urlBuilderTransaction } from ' @/utils/explorerGuide' ;
33- import C from ' @vue-polkadot/vue-api'
34- import BalanceInput from ' @/components/shared/BalanceInput.vue'
30+ import Connector from ' @vue-polkadot/vue-api' ;
31+ import BalanceInput from ' @/components/shared/BalanceInput.vue' ;
32+ import AccountSelect from ' @/components/shared/AccountSelect.vue'
33+ import PasswordInput from ' @/components/shared/PasswordInput.vue' ;
3534
3635@Component ({
3736 components: {
3837 ModalWrapper ,
39- Dropdown ,
38+ AccountSelect ,
4039 BalanceInput ,
40+ PasswordInput
4141 },
4242})
4343export default class ProposalModal extends Vue {
44- private account: any = {};
44+ private accountId: string = ' ' ;
45+ private beneficiaryId: string = ' ' ;
4546 private password: string = ' ' ;
4647 private beneficiary: any = {};
47- private value : number = 0 ;
48+ private amount : number = 0 ;
4849
49-
50-
51- public handleAccountSelection(account : KeyringPair ) {
52- this .account = account ;
53- }
54-
55- public handleBeneficiary(account : KeyringPair ) {
56- console .log (account .address )
57- this .beneficiary = account ;
58- }
59-
6050 public async shipIt() {
61- const { api } = C .getInstance ()
51+ const { api } = Connector .getInstance ();
6252
6353 if (! api ) {
6454 return ;
6555 }
6656
6757 try {
68- const { value, beneficiary } = this ;
69- showNotification (' Dispatched' );
70- const tx = await exec (this .account , this .password , api .tx .treasury .proposeSpend , [value , beneficiary .address ]);
71- // showNotification(`Second ${referendumId.toString()}`, { ...notificationTypes.success, onAction: this.onAction() });
58+ const { amount, beneficiaryId, accountId, password } = this ;
59+ showNotification (' Dispatched new proposal' );
60+ console .log ({ amount , beneficiaryId , accountId , password })
61+ const tx = await exec (accountId , password , api .tx .treasury .proposeSpend , [amount , beneficiaryId ]);
62+ showNotification (' Success' , notificationTypes .success );
7263 } catch (e ) {
7364 showNotification (e , notificationTypes .danger );
7465 }
7566
7667 }
7768
7869 get disabled() {
79- return ! this .account || ! this .password || ! this . beneficiary || ! this .value
70+ return ! this .accountId || ! this .beneficiary || ! this .amount
8071 }
8172
8273}
0 commit comments