Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error calling getArbitrarySignature (TypeError: t(...)[u] is not a function) #172

Open
jurosh opened this issue Oct 24, 2018 · 6 comments
Open

Comments

@jurosh
Copy link

jurosh commented Oct 24, 2018

As per docs here https://get-scatter.com/docs/api-request-arbitrary-signature

Scatter should be able to get signature like:

// getScatterEosInstance is getting eos instance based on network...
const scatterInstance = getScatterEosInstance([
    { actor: makerAccount, permission: 'active' }
  ]);
const scattertSignature = await scatterInstance.getArbitrarySignature(
    makerPublicKey,
    'test', // orderBuffer.toString(),
    'Order signing',
    false
  );

Instead promise is rejected with reason:

"TypeError: t(...)[u] is not a function
    at Promise (chrome-extension://ammjpmhgckkpcamddpolhchgomcojkle/inject.js:40:270202)
    at new Promise (<anonymous>)
    at Proxy.n (chrome-extension://ammjpmhgckkpcamddpolhchgomcojkle/inject.js:40:270118)
    at _callee$ (webpack-internal:///./src/client/eos/trading.js:100:49)
    at tryCatch (webpack-internal:///./node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:65:40)
    at Generator.invoke [as _invoke] (webpack-internal:///./node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:303:22)
    at Generator.prototype.(anonymous function) [as next] (webpack-internal:///./node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:117:21)
    at step (webpack-internal:///./src/client/eos/trading.js:217:191)
    at eval (webpack-internal:///./src/client/eos/trading.js:217:437)
    at new Promise (<anonymous>)
    at eval (webpack-internal:///./src/client/eos/trading.js:217:99)
    at signOrderWithScatter (webpack-internal:///./src/client/eos/trading.js:137:18)
    at <anonymous>:1:1"

Using scatter extension 6.1.10 on Chrome (Linux)

@nsjames
Copy link
Contributor

nsjames commented Oct 26, 2018

Need more code here to see what's going on ( like what getScatterEosInstance is doing ). Also, I see you're using extension, have to tried to check if this works from desktop? Lots of functionality is missing from the extension.

@jurosh
Copy link
Author

jurosh commented Oct 26, 2018

Wanted to build and try desktop version but ran into GetScatter/ScatterDesktop#156

Here are some details about getScatterEosInstance

// Tried also with latest scatter-js and same result...
import ScatterJS from 'scatter-js/dist/scatter.esm';
import Eos from 'eosjs';

...

export const getScatterEosInstance = (
  actors: Array<{ actor: string, permission: string }>,
  moreOptions: any = {}
) => {
  const options = {
    broadcast: true,
    chainId,
    authorization: actors,
    ...moreOptions
  };
  const scatterEos = ScatterJS.scatter.eos(eosNetwork, Eos, options, 'http');
  if (scatterEos === undefined || scatterEos === null) {
    // 'failed to obtain the Scatter eosjs instance.'
    // throw error....
  }
  return scatterEos;
};

@nsjames
Copy link
Contributor

nsjames commented Oct 27, 2018

Looks like you aren't pulling in the ScatterEOS plugin: https://get-scatter.com/docs/examples-interaction-flow

@jurosh
Copy link
Author

jurosh commented Nov 7, 2018

Forgot to paste it here, but I am doing eos initialization ScatterJS.plugins(new ScatterEOS()); in another file..

Cannot make this code to be functional:

scatterInstance.getArbitrarySignature(
    userPublicKey,
    'testToSign',
    'Order signing',
    false
);

@nsjames can you confirm it's working for you ? Already tried Scatter Desktop too and looks like it's same issue - so maybe error in scatter eos plugin or am I calling it wrong way ?

@nsjames
Copy link
Contributor

nsjames commented Nov 8, 2018

Those imports, and the ScatterJS.plugins(new ScatterEOS()); instantiation should be done as early as possible in your app, and only in a single location and then fetched from a global store/state-handler.

By doing:

import ScatterJS from 'scatter-js/dist/scatter.esm';
import Eos from 'eosjs';

That instance of ScatterJS has no knowledge of any plugins in any other files as the scopes are different.

@jurosh
Copy link
Author

jurosh commented Nov 8, 2018

So I am getting into the core of issue. Looks like I have to use ScatterJS.scatter for getting signatures but I was using ScatterJS.scatter.eos instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants