scatter-js icon indicating copy to clipboard operation
scatter-js copied to clipboard

Defining "ScatterJS.scatter.eos" Cannot call related methods

Open zebei opened this issue 5 years ago • 0 comments

Defining variables const eos = scatter.eos(network, Api, { rpc, beta3: true }); when i try to use 'eos' related method:getCurrencyBalance or transfer will throw exception: "TypeError:Cannot read property 'apply' of undefined"


import ScatterJS, { Network } from 'scatterjs-core';
import ScatterEOS from 'scatterjs-plugin-eosjs2'
import { Api, JsonRpc, RpcError, JsSignatureProvider } from 'eosjs';

ScatterJS.plugins(new ScatterEOS());
const network = Network.fromJson({
    blockchain: 'eos',
    protocol: 'https',
    host: 'jungle2.cryptolions.io',
    port: 443,
    chainId: 'e70aaab8997e1dfce58fbfac80cbbb8fecec7b99cf982a9444273cbc64c41473'
})
const rpc = new JsonRpc(network.fullhost());
const requiredFields = { accounts: [network] };

ScatterJS.connect('fff', { network }).then(connected => {
    if (!connected) return alert('no scatter');
    ScatterJS.scatter.getIdentity(requiredFields).then(() => {
        const scatter =ScatterJS.scatter;
        
        const account = scatter.identity.accounts.find(x => x.blockchain === 'eos');
        console.log( account.name);
        
        const eos = scatter.eos(network, Api, { rpc, beta3: true });
        
        let config = {
            account: account.name,  
            code: "eosio.token", 
            symbol: "EOS" 
        };
        eos.getCurrencyBalance(config).then(e => {
            console.log(e)
        });
    }).catch(error => {
        console.log(error);
    });
});

 "dependencies": {
    "browserify": "^16.5.0",
    "eosjs": "^20.0.3",
    "jquery": "^3.4.1",
    "scatterjs-core": "^2.7.18",
    "scatterjs-plugin-eosjs2": "^1.5.0"
   },`

zebei avatar Feb 22 '20 08:02 zebei