GetScatter / ScatterDesktop

Connect to applications on EOS, Ethereum, and Tron. Exchange tokens with ease. Manage your assets safely. All in a simple to use interface.
https://get-scatter.com/
GNU General Public License v3.0
501 stars 197 forks source link

signatureProvider.sign hangs while an error appears in scatter desktop console #491

Open batrudinych opened 4 years ago

batrudinych commented 4 years ago

Versions

In the scatter desktop I have a custom network configured and a single private key added. The key is linked to the network.

From the Node.js Scatter connection is established fine but whenever I do signatureProvider.sign, the app hangs and I'm getting an error in the scatter desktop console: TypeError: fetching abi for eosaccnt: Cannot read property 'getRawAbi' of undefined

The code snippet is below. Some of the values need to be set. await feapi.signatureProvider.sign(signArgsFe) never returns.

const { Api, JsonRpc } = require('eosjs')
const fetch = require('node-fetch')
const { TextDecoder, TextEncoder } = require('util')
const ScatterJS = require('scatterjs-core').default
const ScatterEOS = require('scatterjs-plugin-eosjs2').default
ScatterJS.plugins(new ScatterEOS())

async function main () {
  const opts = {
    blocksBehind: 3,
    expireSeconds: 60
  }
  const actions = [{
    account: 'eosaccnt',
    name: 'validate',
    authorization: [{
      actor: 'testuser1111',
      permission: 'active'
    }],
    data: {
      account: 'testuser1111'
    }
  }]
  const { scatter } = ScatterJS
  const connected = await scatter.connect('demo-app')
  if (!connected) throw new Error('no scatter connection')
  await scatter.forgetIdentity()

  const network = {
    blockchain: 'eos',
    protocol: 'https',
    host: 'node_address',
    port: 443,
    chainId: 'chain_id from v1/chain/get_info'
  }
  await scatter.suggestNetwork(network)

  const hasAccount = await scatter.hasAccountFor(network)
  if (!hasAccount) throw new Error('no account found')

  await scatter.getIdentity({ accounts: [network] })
  const feSignProvider = scatter.eosHook(network, null, true)

  const ferpc = new JsonRpc('https://node_address', { fetch })
  const feapi = new Api({
    rpc: ferpc,
    signatureProvider: feSignProvider,
    textDecoder: new TextDecoder(),
    textEncoder: new TextEncoder()
  })

  const { serializedTransaction } = await feapi.transact({ actions }, {
    ...opts,
    broadcast: false,
    sign: false
  })
  const feRequiredKeys = await feapi.signatureProvider.getAvailableKeys()
  const signArgsFe = {
    chainId: network.chainId,
    requiredKeys: feRequiredKeys,
    serializedTransaction,
    abis: []
  }
  const fePushTransactionArgs = await feapi.signatureProvider.sign(signArgsFe)
  console.log('done')
}

main().catch(console.error)
dev-sk-master commented 3 years ago

I get the same error

Versions

scatter desktop @12.1.1, scatterjs-core@2.7.47, scatterjs-plugin-eosjs2@1.5.29, eosjs@20.0.3

Scatter not responding to sign action fePushTransactionArgs = await feapi.signatureProvider.sign(signArgsFe)