Skip to content

Commit

Permalink
dapp onboarding helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
nsjames committed Aug 16, 2018
1 parent dfba0a5 commit 03cd7be
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 14 deletions.
16 changes: 16 additions & 0 deletions dist/scatter.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -27961,6 +27961,22 @@ class Scatter {
});
}

getPublicKey(blockchain) {
throwNoAuth();
return _SocketService2.default.sendApiRequest({
type: 'getPublicKey',
payload: { blockchain }
});
}

linkAccount(publicKey, account, network) {
throwNoAuth();
return _SocketService2.default.sendApiRequest({
type: 'linkAccount',
payload: { publicKey, account, network }
});
}

suggestNetwork(network) {
throwNoAuth();
return _SocketService2.default.sendApiRequest({
Expand Down
2 changes: 1 addition & 1 deletion dist/scatter.min.js.map

Large diffs are not rendered by default.

37 changes: 24 additions & 13 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,31 @@

function test(){
var network = {blockchain:'eos', protocol:'http', host:'192.168.1.6', port:8888, chainId:'cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f'};
var eos = scatter.eos(network, Eos);

console.log('id before', scatter.identity)
scatter.forgetIdentity().then(function(){
scatter.getIdentity({accounts:[network]}).then(function(id){
const account = id.accounts.find(function(x){ return x.blockchain === 'eos' });
console.log('acc', account);
eos.transfer(account.name, 'eosio', '1.0000 EOS', '').then(function(res){
console.log('res', res);
}).catch(function(err){
console.log('err', err);
})
})

scatter.getPublicKey('eos').then(function(publicKey){
scatter.linkAccount(publicKey, { name:'testaccount', authority:'active' }, network).then(function(link){
console.log('link', link);
});
console.log('publicKey', publicKey);
})
// scatter.getIdentity();



// var eos = scatter.eos(network, Eos);
//
// console.log('id before', scatter.identity)
// scatter.forgetIdentity().then(function(){
// scatter.getIdentity({accounts:[network]}).then(function(id){
// const account = id.accounts.find(function(x){ return x.blockchain === 'eos' });
// console.log('acc', account);
// eos.transfer(account.name, 'eosio', '1.0000 EOS', '').then(function(res){
// console.log('res', res);
// }).catch(function(err){
// console.log('err', err);
// })
// })
// })

}

Expand Down
16 changes: 16 additions & 0 deletions src/scatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,22 @@ class Scatter {
});
}

getPublicKey(blockchain){
throwNoAuth();
return SocketService.sendApiRequest({
type:'getPublicKey',
payload:{ blockchain }
});
}

linkAccount(publicKey, account, network){
throwNoAuth();
return SocketService.sendApiRequest({
type:'linkAccount',
payload:{ publicKey, account, network }
});
}

suggestNetwork(network){
throwNoAuth();
return SocketService.sendApiRequest({
Expand Down

0 comments on commit 03cd7be

Please sign in to comment.