Skip to content

Commit b2d733b

Browse files
authored
Merge pull request #39 from GetScatter/master
Fixes for FIO and EOSIO manual link accounts
2 parents 675f26a + 2beb1d2 commit b2d733b

12 files changed

Lines changed: 224 additions & 45 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bridge",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"private": true,
55
"scripts": {
66
"build": "npm run check && yarn && cross-env NODE_ENV=production BABEL_ENV=prod vue-cli-service build && npm run zip",

src/components/Popups.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<EnterSecurityCode class="popin" :popin="popIn" :closer="closer(popIn)" v-if="popIn.data.type === 'enterSecurityCode'" />
3131
<Stabilize class="popin" :popin="popIn" :closer="closer(popIn)" v-if="popIn.data.type === 'stabilize'" />
3232
<SelectList class="popin" :popin="popIn" :closer="closer(popIn)" v-if="popIn.data.type === 'selectList'" />
33+
<GetInput class="popin" :popin="popIn" :closer="closer(popIn)" v-if="popIn.data.type === 'getInput'" />
3334
<DiscardTokens class="popin" :popin="popIn" :closer="closer(popIn)" v-if="popIn.data.type === 'discardTokens'" />
3435
<GoPremium class="popin" :popin="popIn" :closer="closer(popIn)" v-if="popIn.data.type === 'goPremium'" />
3536
<EditNetworkAccount class="popin" :popin="popIn" :closer="closer(popIn)" v-if="popIn.data.type === 'editNetworkAccount'" />
@@ -117,6 +118,7 @@
117118
ResetScatter:() => import('../components/popups/ResetScatter'),
118119
Stabilize:() => import('../components/popups/Stabilize'),
119120
SelectList:() => import('../components/popups/SelectList'),
121+
GetInput:() => import('../components/popups/GetInput'),
120122
DeleteKeypair:() => import('../components/popups/DeleteKeypair'),
121123
DeleteHistory:() => import('../components/popups/DeleteHistory'),
122124
ShowTerms:() => import('../components/popups/ShowTerms'),

src/components/popups/EditNetworkAccount.vue

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232

3333
<figure class="action">
3434
<figure class="bubble" @click="toggleAddingKey" :class="{'active':addingNewKey}">
35-
<i class="fa fa-plus"></i>
35+
<span v-if="!addingNewKey">Add key</span>
36+
<span v-if="addingNewKey">Back</span>
3637
</figure>
3738
</figure>
3839
</section>
@@ -76,6 +77,7 @@
7677
<Button v-if="!key.external" v-tooltip="`Convert blockchains`" icon="fa fa-link" @click.native="convertKeypair(key)" />
7778
<Button v-if="!isAccountlessChain" v-tooltip="`Refresh accounts`" icon="fa fa-sync-alt" :loading="loadingAccounts[key.unique()]" @click.native="refreshAccounts(key)" />
7879
<Button v-if="detachedKey(key)" icon="fa fa-trash" v-tooltip="`Remove key`" @click.native="removeKey(key)" />
80+
<Button v-if="tappedCtrl" icon="fa fa-user" v-tooltip="`Manually Link Account`" @click.native="manuallyLinkAccount(key)" />
7981
</section>
8082

8183
<section class="accounts">
@@ -166,7 +168,14 @@
166168
loadingAccounts:{},
167169
168170
accounts:{},
171+
tappedCtrl:false,
169172
}},
173+
beforeMount(){
174+
window.addEventListener("keydown", this.tapCtrl);
175+
},
176+
beforeDestroy(){
177+
window.removeEventListener("keydown", this.tapCtrl);
178+
},
170179
created(){
171180
this.keys.map(keypair => this.loadAccounts(keypair));
172181
@@ -202,6 +211,26 @@
202211
}
203212
},
204213
methods:{
214+
async manuallyLinkAccount(keypair){
215+
PopupService.push(Popups.getInput('Manually Link Account', 'If you link an account that does not actually belong to this key, you will not be able to sign anything.', 'account name', 'What is the account name?', async name => {
216+
if(!name || !name.length) return;
217+
let [account_name, permission] = name.split('@');
218+
if(!permission || !permission.length) permission = 'active';
219+
220+
this.select(Account.fromJson({
221+
keypairUnique: keypair.unique(),
222+
networkUnique: this.network.unique(),
223+
name:account_name,
224+
permission,
225+
publicKey: keypair.publicKeys.find(x => x.blockchain === this.network.blockchain).key
226+
}));
227+
}))
228+
},
229+
tapCtrl(event){
230+
if (event.keyCode === 17) {
231+
this.tappedCtrl = !this.tappedCtrl;
232+
}
233+
},
205234
detachedKey(keypair){
206235
return !keypair.base;
207236
},
@@ -448,28 +477,22 @@
448477
right:20px;
449478
450479
.bubble {
451-
width:40px;
452-
height:40px;
480+
padding:6px 12px;
453481
background:$blue;
454482
color:white;
455-
font-size: 18px;
483+
font-size: $font-size-tiny;
456484
display:flex;
457485
justify-content: center;
458486
align-items: center;
459-
border-radius:50%;
487+
border-radius:4px;
460488
cursor: pointer;
461489
462-
transition: transform 0.2s ease;
463-
464-
&:hover { transform:scale(1.1); }
465-
&:active { transform:scale(0.9); }
490+
backface-visibility: hidden;
466491
467-
&.active {
468-
transform:rotateZ(45deg);
492+
transition: background 0.2s ease;
469493
470-
&:hover { transform:rotateZ(45deg) scale(1.1); }
471-
&:active { transform:rotateZ(45deg) scale(0.9); }
472-
}
494+
&:hover { background:$darkblue; }
495+
&:active { background:$blue; }
473496
}
474497
}
475498
}

src/components/popups/GetInput.vue

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<template>
2+
<section class="get-input">
3+
4+
<section class="popup-content">
5+
<figure class="title" v-html="title"></figure>
6+
<figure class="sub-title" style="margin-top:-20px;">{{subTitle}}</figure>
7+
8+
<section class="input-container">
9+
<Input style="margin-bottom:0;" :placeholder="placeholder" :label="label" :text="text" v-on:changed="x => text = x" />
10+
</section>
11+
</section>
12+
13+
<section class="popup-buttons">
14+
<Button @click.native="closer(null)" text="Cancel" />
15+
<Button primary="1" @click.native="closer(text)" text="Done" />
16+
</section>
17+
18+
</section>
19+
</template>
20+
21+
<script>
22+
import Popups from "../../util/Popups";
23+
import PopupService from "../../services/utility/PopupService";
24+
25+
export default {
26+
props:['popin', 'closer'],
27+
data(){return {
28+
text:'',
29+
}},
30+
computed:{
31+
title(){
32+
return this.popin.data.props.title;
33+
},
34+
subTitle(){
35+
return this.popin.data.props.subTitle;
36+
},
37+
placeholder(){
38+
return this.popin.data.props.placeholder || '';
39+
},
40+
label(){
41+
return this.popin.data.props.label || '';
42+
},
43+
},
44+
methods:{
45+
46+
},
47+
}
48+
</script>
49+
50+
<style scoped lang="scss">
51+
@import "../../styles/variables";
52+
53+
.get-input {
54+
max-width:380px;
55+
width:calc(100% - 80px);
56+
margin:0 auto;
57+
58+
.sub-title {
59+
font-size: $font-size-small;
60+
}
61+
62+
.input-container {
63+
margin-top:40px;
64+
}
65+
}
66+
67+
68+
</style>

src/components/popups/Transfer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
168168
const fioRecipient = (await getFioRecipient(this.token.symbol) || await getFioRecipient(this.token.network().systemToken().symbol));
169169
170-
if (!fioRecipient) return PopupService.push(Popups.snackbar(`The identity you entered does not exist, or does not accept these tokens.`));
170+
if (!fioRecipient || fioRecipient.toString() === "0") return PopupService.push(Popups.snackbar(`The identity or FIO address you entered does not exist, or does not accept these tokens.`));
171171
recipient = fioRecipient;
172172
173173
} else {

src/components/popups/fio/ManageFioAddresses.vue

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<figure class="name">{{network.name}}</figure>
1111
<figure class="action">
1212
<Button v-if="!fioData[network.unique()]" text="Attach" @click.native="linkNetwork(network)" />
13-
<Button v-if="fioData[network.unique()]" primary="1" disabled="1" text="Linked" />
13+
<Button v-if="fioData[network.unique()]" primary="1" text="Detach" @click.native="unlinkNetwork(network)" />
1414
</figure>
1515
</section>
1616
</section>
@@ -68,7 +68,7 @@
6868
address:await plugin.recipientToSendable(this.account.network(), this.account.fio_address, network.blockchain, network.systemToken().symbol).catch(() => null)
6969
};
7070
})).then(x => x.reduce((acc, y) => {
71-
acc[y.network.unique()] = y.address;
71+
acc[y.network.unique()] = y.address === null ? false : y.address.toString() === '0' ? false : y.address;
7272
return acc;
7373
}, {}));
7474
},
@@ -84,7 +84,19 @@
8484
}).then(x => {
8585
this.syncData();
8686
});
87-
87+
},
88+
async unlinkNetwork(network){
89+
const plugin = PluginRepository.plugin(Blockchains.FIO);
90+
await plugin.linkAddress(this.account, [{
91+
"chain_code": network.blockchain.toUpperCase(),
92+
"token_code": network.systemToken().symbol.toUpperCase(),
93+
"public_address": "0"
94+
}]).catch(err => {
95+
PopupService.push(Popups.snackbar(err.error));
96+
return false
97+
}).then(x => {
98+
this.syncData();
99+
});
88100
},
89101
},
90102
}

src/components/popups/fio/RequestFioTokens.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
const sharedSecret = await window.wallet.createSharedSecret('fio', this.account.publicKey, recipientPublicKey);
9494
const encrypted = await plugin.encrypt('new_funds_content', content, sharedSecret);
9595
96-
// this.getCipherContent('new_funds_content', this.content, this.privateKey, this.payerFioPublicKey);
9796
const requested = await plugin.requestFunds(this.account, this.recipient, encrypted).catch(() => null);
9897
if(requested && requested.hasOwnProperty('transaction_id')){
9998
PopupService.push(Popups.transactionSuccess(this.account.blockchain(), requested.transaction_id));

0 commit comments

Comments
 (0)