Skip to content

Commit a9f1f00

Browse files
authored
Merge pull request #57 from GetScatter/master
manually link accounts
2 parents 16c177e + bf909e1 commit a9f1f00

4 files changed

Lines changed: 82 additions & 8 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.14",
3+
"version": "1.0.15",
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/ManageAccounts.vue

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@
3030
{{account.sendable()}}<span class="authority" v-if="account.authority">@{{account.authority}}</span>
3131
</figure>
3232

33-
<figure class="select-account" :class="{'selected':enabledAccounts.find(x => x.unique() === account.unique())}" @click="select(account, network)">
34-
<i class="fa fa-check"></i>
35-
</figure>
33+
<section style="display:flex;">
34+
<figure class="select-account remove" @click="removeAccount(account, network)">
35+
<i class="fa fa-times"></i>
36+
</figure>
37+
<figure class="select-account" :class="{'selected':enabledAccounts.find(x => x.unique() === account.unique())}" @click="select(account, network)">
38+
<i class="fa fa-check"></i>
39+
</figure>
40+
</section>
3641
</section>
3742
</section>
3843
</section>
@@ -45,6 +50,7 @@
4550
<script>
4651
import { mapState, mapActions } from 'vuex'
4752
import * as UIActions from "../store/ui_actions";
53+
import * as Actions from "@walletpack/core/store/constants";
4854
import SearchBar from "../components/reusable/SearchBar";
4955
import Switcher from "../components/reusable/Switcher";
5056
import SingularAccounts from "../services/utility/SingularAccounts";
@@ -156,9 +162,23 @@
156162
SingularAccounts.setPredefinedAccount(network, account);
157163
}
158164
},
165+
async removeAccount(account, network){
166+
if(this.enabledAccounts.find(x => x.unique() === account.unique())){
167+
SingularAccounts.setPredefinedAccount(network, null);
168+
}
169+
170+
const cache = this.accountCache;
171+
Object.keys(cache).map(network => {
172+
this[UIActions.SET_ACCOUNT_CACHE]({key:network, value:cache[network].filter(x => x.unique() !== account.unique())});
173+
});
174+
175+
this.setNetworkAccounts();
176+
this.refreshAccounts();
177+
},
159178
...mapActions([
160179
UIActions.SET_COLLAPSED_SIDEBAR,
161180
UIActions.SET_ACCOUNT_CACHE,
181+
Actions.SET_SCATTER,
162182
])
163183
},
164184
watch:{
@@ -333,6 +353,27 @@
333353
display:block;
334354
}
335355
}
356+
357+
&.remove {
358+
border:2px solid transparent;
359+
color:$red;
360+
margin-right:2px;
361+
362+
i {
363+
display:block;
364+
font-size: 13px;
365+
}
366+
367+
&.selected, &:hover {
368+
background:$red;
369+
color:white;
370+
border:2px solid transparent;
371+
372+
i {
373+
display:block;
374+
}
375+
}
376+
}
336377
}
337378
338379
.toggle {

src/components/popups/ManageKeys.vue

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<Button v-tooltip="`Copy public key`" icon="fal fa-copy" @click.native="copyPublicKey(key)" />
6969
<Button v-if="!key.external" v-tooltip="`Convert blockchains`" icon="fal fa-link" @click.native="convertKeypair(key)" />
7070
<Button v-if="detachedKey(key)" icon="fal fa-ban" v-tooltip="`Remove key`" @click.native="removeKey(key)" />
71+
<Button v-if="canManuallyLink(key)" icon="fal fa-user" v-tooltip="`Manually link account`" @click.native="manuallyLinkAccount(key)" />
7172
<Button primary="1" v-if="!key.external" text="Export" icon="fal fa-key" @click.native="exportKey(key)" />
7273
</section>
7374

@@ -264,6 +265,38 @@
264265
if(converted) PopupService.push(Popups.snackbar("Conversion successful. Check the network for the corresponding blockchain."))
265266
}));
266267
},
268+
canManuallyLink(keypair){
269+
return keypair.blockchains[0] === 'eos';
270+
},
271+
async manuallyLinkAccount(keypair){
272+
const blockchain = keypair.blockchains[0];
273+
const networks = this.scatter.settings.networks.filter(x => x.blockchain === blockchain);
274+
PopupService.push(Popups.selectList('Select a <span>Network</span>', 'Select the type of blockchain you want to either create or import a key for.', networks, x => {
275+
return x.name;
276+
}, async network => {
277+
if(!network) return;
278+
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 => {
279+
if(!name || !name.length) return;
280+
let [account_name, permission] = name.split('@');
281+
if(!permission || !permission.length) permission = 'active';
282+
283+
const account = Account.fromJson({
284+
keypairUnique: keypair.unique(),
285+
networkUnique: network.unique(),
286+
name:account_name,
287+
authority:permission,
288+
publicKey: keypair.publicKeys.find(x => x.blockchain === blockchain).key
289+
});
290+
291+
await AccountService.addAccount(account);
292+
SingularAccounts.setPredefinedAccount(network, account);
293+
BalanceService.loadBalancesFor(account);
294+
await SingularAccounts.refreshAccounts([network], [keypair]);
295+
this.closer(true);
296+
}))
297+
}));
298+
299+
},
267300
...mapActions([
268301
Actions.SET_BALANCES,
269302
Actions.REMOVE_BALANCES,

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,10 +1298,10 @@
12981298
eosjs "^20.0.0"
12991299
eosjs-ecc "^4.0.7"
13001300

1301-
"@walletpack/ethereum@^0.0.59":
1302-
version "0.0.59"
1303-
resolved "https://registry.yarnpkg.com/@walletpack/ethereum/-/ethereum-0.0.59.tgz#f41bd920b41c7a462c67aa386062d7dd9a504fe2"
1304-
integrity sha512-2H8VlpyFG1VFbUzqcd5FF4r82vHTiROwXU048awcIqIie5ud2ps3lI/pp+Bc5nq/ZDkszdUsNUKp3+ookgJBBw==
1301+
"@walletpack/ethereum@^0.0.60":
1302+
version "0.0.60"
1303+
resolved "https://registry.yarnpkg.com/@walletpack/ethereum/-/ethereum-0.0.60.tgz#e81a69a8bae08666270af6c4be195dfac69f50e1"
1304+
integrity sha512-Tr7xd5Eh5BOrok/w8mTf91B6ii1sIC9w74mI/YLQzpKRz2aQGMkTuu9BU8M1X/eAxZHLs1RSSg0mLnMIrozlIA==
13051305
dependencies:
13061306
"@walletpack/core" "^1.0.50"
13071307
ethereumjs-tx "^2.1.0"

0 commit comments

Comments
 (0)