sarvalabs / js-moi-sdk

JavaScript library to interact with MOI Protocol via RPC API
https://js-moi-sdk.docs.moi.technology/
Apache License 2.0
24 stars 2 forks source link

Bug: Receiving an error stating "ERROR_INVALID_ARGUMENT" even after providing all necessary valid arguments. #74

Closed sarvalabs-pawankalyan closed 1 month ago

sarvalabs-pawankalyan commented 4 months ago

Description

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

verifeye.json


Expected Output: Should get the result and hash.

Actual Output:

 code: 'ERROR_INVALID_ARGUMENT',
  reason: 'One or more required arguments are missing.',
  params: {}
sarvalabs-harshrastogi commented 1 month ago

closed in #75