chore: update datatype for matching solidity api uint40

This commit is contained in:
darshankabariya 2025-04-02 23:45:59 +05:30
parent 1dd05088ef
commit b48a7bf796

View File

@ -47,7 +47,7 @@ contract(WakuRlnContract):
# this constant describes max message limit of rln contract # this constant describes max message limit of rln contract
proc MAX_MESSAGE_LIMIT(): UInt256 {.view.} proc MAX_MESSAGE_LIMIT(): UInt256 {.view.}
# this function returns the merkleProof for a given index # this function returns the merkleProof for a given index
proc merkleProofElements(index: UInt256): seq[UInt256] {.view.} proc merkleProofElements(index: UInt40): seq[UInt256] {.view.}
# this function returns the Merkle root # this function returns the Merkle root
proc root(): Uint256 {.view.} proc root(): Uint256 {.view.}
@ -93,13 +93,17 @@ proc setMetadata*(
proc fetchMerkleProofElements*( proc fetchMerkleProofElements*(
g: OnchainGroupManager g: OnchainGroupManager
): Future[Result[seq[Uint256], string]] {.async.} = ): Future[Result[seq[Uint256], string]] {.async.} =
let index = stuint(g.membershipIndex.get(), 256) let membershipIndex = g.membershipIndex.get()
debug "Fetching merkle proof", index = membershipIndex
try: try:
let index = stuint(membershipIndex, 40)
let merkleProofInvocation = g.wakuRlnContract.get().merkleProofElements(index) let merkleProofInvocation = g.wakuRlnContract.get().merkleProofElements(index)
let merkleProof = await merkleProofInvocation.call() let merkleProof = await merkleProofInvocation.call()
debug "Successfully fetched merkle proof", elementsCount = merkleProof.len
return ok(merkleProof) return ok(merkleProof)
except CatchableError: except CatchableError:
error "Failed to fetch merkle proof - 1", errMsg = getCurrentExceptionMsg() error "Failed to fetch merkle proof", errMsg = getCurrentExceptionMsg()
proc fetchMerkleRoot*( proc fetchMerkleRoot*(
g: OnchainGroupManager g: OnchainGroupManager
@ -325,12 +329,12 @@ method generateProof*(
try: try:
let proofResult = waitFor g.fetchMerkleProofElements() let proofResult = waitFor g.fetchMerkleProofElements()
if proofResult.isErr(): if proofResult.isErr():
return err("Failed to fetch Merkle proof - 2: " & $proofResult.error) return err("Failed to fetch Merkle proof" & $proofResult.error)
g.merkleProofCache = proofResult.get() g.merkleProofCache = proofResult.get()
debug "Merkle proof fetched", debug "Merkle proof fetched",
membershipIndex = g.membershipIndex.get(), elementCount = g.merkleProofCache.len membershipIndex = g.membershipIndex.get(), elementCount = g.merkleProofCache.len
except CatchableError: except CatchableError:
error "Failed to fetch merkle proof - 3", error = getCurrentExceptionMsg() error "Failed to fetch merkle proof", error = getCurrentExceptionMsg()
let witness = Witness( let witness = Witness(
identity_secret: g.idCredentials.get().idSecretHash.toArray32(), identity_secret: g.idCredentials.get().idSecretHash.toArray32(),