Closed Zaniyar closed 6 months ago
I have similar problem:
json-rpc-provider.js:366 Uncaught (in promise) Error: [-32700] Parse error: Failed parsing args: missing field account_id
at l.
What I found so far the near-wallet.js module has undefined "contractId" when calling
async viewMethod({ contractId, method, args = {} }) { const { network } = this.walletSelector.options; const provider = new providers.JsonRpcProvider({ url: network.nodeUrl });
console.log(contractId)
let res = await provider.query({
request_type: 'call_function',
account_id: contractId,
method_name: method,
args_base64: Buffer.from(JSON.stringify(args)).toString('base64'),
finality: 'optimistic',
});
return JSON.parse(Buffer.from(res.result).toString());
}
Hardcoding the contractId has solved the problem temporarily.
Source code: https://github.com/romanzac/sticky-habits/blob/main/frontend/near-wallet.js
Problem solved for myself. Parcel was not passing environment variables so my code could read process.env.CONTRACT_NAME. What helped was to remove "process" "devDependencies": {}, delete "node_modules" directory and let parcel to install for Node builtin module "process" during "npm run build".
parcel build index.html --public-url ./
Installing process...
@parcel/resolver-default: Auto installing polyfill for Node builtin module "process"...
/Users/roman/sources/sticky-habits/frontend/node_modules/js-sha256/src/sha256.js:20:54 19 | var WEB_WORKER = !WINDOW && typeof self === 'object';
20 | var NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; | ^^^^^^^ used here 21 | if (NODE_JS) { 22 | root = global;
https://en.parceljs.org/env.html https://parceljs.org/features/node-emulation/#environment-variables https://parceljs.org/features/node-emulation/#polyfilling-%26-excluding-builtin-node-modules
this problem is unrelated to near-cli
, please open it back if necessary in the right repositories, or reach out dev support through telegram or discord
I get this error (not on the near CLI - the login works there) in the frontend when I try to call a method on the contract, "Failed parsing args: missing field account_id" but the account_id is there when I log it:
User is logged in; wallet.accountId is existing;
Output:
I saw similar errors related to the CLI login function, but on my side that works, but not the frontend.