Skip to content

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

@btrdnch

Description

@btrdnch

Versions

  • scatter desktop @12.0.0,
  • scatterjs-core@2.7.18,
  • scatterjs-plugin-eosjs2@1.5.0,
  • eosjs@20.0.3

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions