Giter Club home page Giter Club logo

Comments (6)

mintzhao avatar mintzhao commented on August 19, 2024 1

I have changed to the scatterjs-plugin-eosjs,and works fine. Great job, thank you

from scatter-js.

nsjames avatar nsjames commented on August 19, 2024

Are you using the scatterjs-plugin-eosjs2 ?
Can you show me full code in a gist maybe?

from scatter-js.

mintzhao avatar mintzhao commented on August 19, 2024

Yes, I'm sure.
code is here:

const scatter = await getScatterEOS();
  if (scatter != null) {
    if (scatter.identity) {
      // Always use the accounts you got back from Scatter. Never hardcode them even
      // if you are prompting the user for their account name beforehand. They could
      // still give you a different account.
      const account = scatter
        .identity
        .accounts
        .find(x => x.blockchain === 'eos');

      // Get a proxy reference to eosjs which you can use to sign transactions with a
      // user's Scatter. eosjs2
      const network = {
        blockchain: 'eos',
        protocol: process.env.EOS.PROTOCOL,
        host: process.env.EOS.host,
        port: process.env.EOS.PORT,
        chainId: process.env.EOS.CHAINID
      };

       const api = new Api({
        rpc,
        signatureProvider: scatter.eosHook(network),
        textDecoder: new TextDecoder(),
        textEncoder: new TextEncoder()
      });
      const api = scatter.eos(network, Api, {rpc});

      try {
        const result = await api.transact({
          actions: [
            {
              account: 'xxxx',
              name: 'xxx',
              authorization: [
                {
                  actor: `${account.name}`,
                  permission: `${account.authority}`
                }
              ],
              data: {
                xxxxxx:xxxxx
              }
            }
          ]
        }, {
          blocksBehind: 3,
          expireSeconds: 10
        });
        console.dir(result);
        return result;
      } catch (e) {
        console.log('\nCaught exception: ' + e);
        if (e instanceof RpcError) 
          console.log(JSON.stringify(e.json, null, 2));
        }
      }
  } 

If I use hook provider。Console says eosHook is not a function.
If I use proxy provider. Console says TypeError: Cannot read property 'length' of undefined

but if I use eosjs

const defaultPrivateKey = 'dddddddd'; // privkey
const signatureProvider = new JsSignatureProvider([defaultPrivateKey]);
const rpc = new JsonRpc(process.env.EOS.JSONRPC, {fetch});
const api = new Api({rpc, signatureProvider, textDecoder: new TextDecoder(), textEncoder: new TextEncoder()});

everything is fine!

env

mac chrome.
scatter desktop and chrome has the same result.

from scatter-js.

nsjames avatar nsjames commented on August 19, 2024

Need more of this code as it's not showing imports for scatterjs, or what getScatterEOS() does.

from scatter-js.

mintzhao avatar mintzhao commented on August 19, 2024

getScatterEOS() follow the document:https://get-scatter.com/docs/examples-interaction-flow
I think you should must already know what getScatterEOS() does, no need to post more code of it.
And if I didn't imports scatterjs, does the code can go through to the ````const api = xxxxx```, not a chance.

And I think hook provider show eosHook() not a function, I checked the code of packages/plugin-eosjs2, not a function named eosHook, maybe use hookProvider instead, params of it can fit the document. I will try tonight.

from scatter-js.

nsjames avatar nsjames commented on August 19, 2024

Using hookProvider will not work as they are renamed.

Please post the code inside the getScatterEOS() so I can see the full thing. I can't help with only pieces of the code.

Also please post an image of the error that you are getting with desktop open and the extension disabled ( extension does not support eosjs2 )

from scatter-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.