Open adsick opened 2 years ago
Thank you for the clear ticket, will look into this
Hey @adsick I think you're on the right track. I think you ran into an issue where we're trying to load keyStores
from different places, and the way we build some of our libraries has trouble with that.
This is not the final solution, but I think you can get past this hurdle by adding this to the bottom of calculate-gas.js
:
exports.calculateGas = calculateGas;
exports.keyStores = keyStores;
and changing a line in the calculate-gas-.ava.ts
to be:
- const { calculateGas } = module
+ const { calculateGas, keyStores } = module
and removing the import of keyStores
at the top of that test file. That will get you farther and onto the next problem 👿
Hi, I've been trying to test
near-api-js/examples/cookbook/*
scripts for quite a while and now I'm stuck on a problem that looks like a bug to me.Here is the recipe script I am testing, it is slightly modified because we want to test it: https://github.com/adsick/near-api-js/blob/36afea8c3bcc44066c711dfeb44e76fbb12aa64f/examples/cookbook/utils/calculate-gas.js
And here is the test code: https://github.com/adsick/near-api-js/blob/36afea8c3bcc44066c711dfeb44e76fbb12aa64f/examples/cookbook/tests/calculate-gas.ava.ts
The Important thing is that we create a new InMemoryKeyStore on the [line 22](https://github.com/adsick/near-api-js/blob/36afea8c3bcc44066c711dfeb44e76fbb12aa64f/examples/cookbook/tests/calculate-gas.ava.ts#L22) and add alice's key to that keystore we've just created. Then we pass the keystore to the config, setup a few things and finally calling the exported
calculateGas
function, logging the result.But the problem is that
this code can't sign transactions for some reason, the error is:
To reproduce this on your system you can clone my fork,
cd examples/cookbook
, comment the line 27 ofutils/calculate-gas.js
and then runyarn test -m "calculate gas"