Closed avi69night closed 1 month ago
The Right Code is
. . .
contract MultiSigWallet {
entrypoint approve(tx: Tx, signers: List
. . .
Changes:
Replaced .length()
with.size()
to get the size of the list.
The final expression will implicitly return the comparison result (valid_signatures.size() >= required_signatures).
Multi-signature_Wallet_Contract.ak
Experimental code is ---
. . . contract MultiSigWallet { entrypoint approve(tx: Tx, signers: List, required_signatures: Int) -> Bool {
let valid_signatures = signers.filter(|sig| tx.is_signed_by(sig))
valid_signatures.length() >= required_signatures
}
}
. . .
Issues
The issue with the code you provided lies in the use ofv
.length()
and the implicit return type..length()
: The Aiken language might not have alength()
function for lists. Instead, It needs to use thesize
function to get the number of elements in a list.Implicit Return: In Aiken-lang, need to explicitly return the result of the final expression in the function.