js-moi-sdk
js-moi-sdk copied to clipboard
Bug: Receiving an error stating "ERROR_INVALID_ARGUMENT" even after providing all necessary valid arguments.
Description
- When attempting to invoke an endpoint through the js-moi-sdk, an error stating "One or more required arguments are missing" is encountered despite all required arguments being provided.
Contract
endpoint invoke persistent addProof(
moiID Address,
IDtype []String,
country String,
status String,
time U256,
cid String,
verifier []Bytes
):
mutate verificationProofs <- verfieye.verificationProofs:
if verificationProofs[moiID]?:
throw "Given moiID already has a proof exist"
memory proof = (proofDetails) <- createProof(moiID: moiID, IDtype: IDtype, country: country, status: status, time: time, cid: cid, verifier: verifier)
memory local_proof Map[Address]Proof
local_proof[moiID] = proof
disperse verificationProofs <- local_proof
TS code
private async initWallet(): Promise<moi.Wallet> {
const wallet = await moi.Wallet.fromMnemonic(mnemonic, keyPath);
wallet.connect(provider);
return wallet;
}
private async getLogicDriver(): Promise<moi.LogicDriver<any>> {
const wallet = await this.initWallet();
return await moi.getLogicDriver(logicID, wallet);
}
async recordVerification(moiID: string, details: VerificationDetails): Promise<void> {
try {
const logic = await this.getLogicDriver();
const { docTypes: IDtype, country, status, proofDetails } = details;
const { id: cid, meta: verifier } = proofDetails;
const time = Date.now();
const ix = await logic.routines.addProof(moiID, IDtype, country, status, time, cid, verifier);
console.log(ix.hash);
const receipt = await ix.wait();
console.log(receipt);
} catch (err) {
console.error(err);
throw new Error("Failed to record verification");
}
}
Manifest
Expected Output: Should get the result and hash.
Actual Output:
code: 'ERROR_INVALID_ARGUMENT',
reason: 'One or more required arguments are missing.',
params: {}