Closed feekayo closed 6 years ago
Hello feekayo,
We have made a few breaking changes moving from beta1->beta2, which have been outlined in the PR here along with appropriate updates to the README. Included in those changes is a refactor of the JsonRpc and JsSignatureProvider classes and how they're imported, so please update your code according to the new documentation and let us know if you have any further issues. We will also be doing some release notes outlining these changes today in order to minimize any confusion on the changes from beta1->beta2.
no Rpc., just jsonRpc. or use import * as Eos from 'eosjs'
no Rpc., just jsonRpc. or use import * as Eos from 'eosjs'
@iKest actually, you won't have to use JsonRpc. syntax anymore either. The interfaces have been pulled out of the eosjs_jsonrpc file now, so the syntax is now simply const rpc = new JsonRpc(httpEndpoint)
. The second issue for @feekayo is he must import the signature provider as JsSignatureProvider
, but this is also outlined in our README and PR notes.
Thanks for your assistance. You guys are doing an exceptional job...
I've refactored my code.. Now I'm getting an error: fetching the abi (internal service error) for my smart contract. Its progress I guess...
On Mon, Oct 22, 2018, 16:29 Cody Douglass notifications@github.com wrote:
@iKest https://github.com/iKest actually, you won't have to use JsonRpc. syntax anymore either. The interfaces have been pulled out of the eosjs_jsonrpc file now, so the syntax is now simply const rpc = new JsonRpc(httpEndpoint). The second issue for @feekayo https://github.com/feekayo is he must import the signature provider as JsSignatureProvider, but this is also outlined in our README and PR notes.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EOSIO/eosjs/issues/405#issuecomment-431869140, or mute the thread https://github.com/notifications/unsubscribe-auth/APh8BrLngg2H1pxO-AkNj3fA4ua9JNnVks5uneRLgaJpZM4Xyz2Y .
Thanks, happy to help eager developers out! Many of the errors from the chain are obfuscated to "Internal Service Errors" for security purposes as of right now, but since you are running a local node you should be able to see the specifics of that error message in the terminal running your local node. Without seeing the updated code, I can't say for sure what the error might be, but there's two things that come to mind right off the bat:
account: "eosio.token", name: "transfer"
) here's a reference for these contracts. I have no access to the github interface for updating this issue. Let me see if you can help me out from here..
Attached are screenshots of me successfully publishing the contract on the blockchain and the error I get, and below is my code
const eosjs = require('eosjs');
// Main action call to blockchain
async function takeAction(action, dataValue) { // node
only; not needed in browsers
const { TextDecoder, TextEncoder } = require('text-encoding'); // node,
IE11 and IE Edge Browsers
const defaultPrivateKey = localStorage.getItem("KEY");
const signatureProvider = new
eosjs.JsSignatureProvider([defaultPrivateKey]);
const rpc = new eosjs.JsonRpc('http://127.0.0.1:8888', {});
const api = new eosjs.Api({ rpc, signatureProvider, textDecoder: new
TextDecoder, textEncoder: new TextEncoder });
// Main call to blockchain after setting action, account_name and data
try {
const resultWithConfig = await api.transact({
actions: [{
account: "cx",
name: action,
authorization: [{
actor: localStorage.getItem("USERNAME"),
permission: 'active',
}],
data: dataValue,
}]
}, {
blocksBehind: 3,
expireSeconds: 30,
});
return resultWithConfig;
console.log(resultWithConfig);
} catch (err) {
console.log(err);
throw(err)
}
}
Thanks in anticipation of your assistance in resolving this issue
On Mon, Oct 22, 2018 at 6:34 PM Cody Douglass notifications@github.com wrote:
Thanks, happy to help eager developers out! Many of the errors from the chain are obfuscated to "Internal Service Errors" for security purposes as of right now, but since you are running a local node you should be able to see the specifics of that error message in the terminal running your local node. Without seeing the updated code, I can't say for sure what the error might be, but there's two things that come to mind right off the bat:
- Ensure you are using the correct httpEndpoint when intializing JsonRpc because this endpoint will be called upon to retrieve the abis
- Ensure your transaction is not malformed and the contract actually exists on your local chain, the contractName and action need to reference a contract you've created when initializing your chain (i.e. account: "eosio.token", name: "transfer") here's https://github.com/EOSIO/eosio.contracts a reference for these contracts.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EOSIO/eosjs/issues/405#issuecomment-431908033, or mute the thread https://github.com/notifications/unsubscribe-auth/APh8BlhCK17850JCPQGm_QO8LnqF1I0nks5ungHAgaJpZM4Xyz2Y .
@feekayo I'm not sure if this is your issue, but the second parameter for the JsonRpc constructor should simply be omitted in the browser (or set to null) or if you are calling this from node you need to import fetch (const fetch = require('node-fetch');
). You're also missing the () on the constructor for the TextEncoder and decoder (also only necessary if you're calling from a node context). I can't see the screenshots you're talking about but you should also ensure that the cx::action exists under the cx account after fixing those other two things.
This is me pushing the contract to my local node
this is the error log on my client browswer
This is the network trace on mozilla..
Here's ther error on the blockchain everytime I initiate a query on the frontend
I know I am definitely doing something wrong... I have made the updates you asked for in my code.. Still getting the same error.
Thanks for your assistance
catch the error with: catch (e) { console.log('\nCaught exception: ' + e); if (e instanceof RpcError) console.log(JSON.stringify(e.json, null, 2); }
for more error information
Here's what I got
hmmm. simple rpc.get_abi('cx') work?
The error on my local node from the get_abi function
The error on my log from get_abi function
I unlocked my wallets before carrying out the actions
Version of EOSJS ^20.0.0-beta2
Describe the bug I keep getting this error on react everytime I try to initiate a transaction witth EOSJS
To Reproduce
Expected behavior I'm really new to eosjs and would really love to get past this asap