-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sometimes Switches require parens when it seems like they shouldn't #10
Comments
I'm not able to reproduce. This works for me: module
public func getNFTOwner(metadata: CandyTypes.CandyValue) : Result.Result<Types.Account, Types.OrigynError>
let val = take Properties.getClassProperty(metadata, Types.metadata.owner), return #err(Types.errors(#owner_not_found, "getNFTOwner - cannot find owner id in metadata", null))
return #ok(
switch val.value {
case(#Principal(val)){#principal(val)}
case(#Text(val)){#account_id(val)}
case(#Class(val)){#extensible(#Class(val))}
case(#Array(ary))
switch ary {
case(#frozen(items))
if(items.size() > 0)
#account(
{
owner = switch items[0] {
case(#Principal(val)){val }
case(_)
return #err(Types.errors(#improper_interface, "getNFTOwner - improper interface, not a principal at 0 ", null))
}
sub_account = if(items.size() > 1)
switch items[1] {
case(#Blob(val)){?val }
case(_)
return #err(Types.errors(#improper_interface, "getNFTOwner - improper interface, blob at 1 ", null))
}
else
null
})
else
return #err(Types.errors(#improper_interface, "ledger_interface - improper interface, not enough items " # debug_show(ary), null))
case(_){return #err(Types.errors(#improper_interface, "ledger_interface - send payment - improper interface, not frozen " # debug_show(ary), null)) }
}
case(_){return #err(Types.errors(#improper_interface, "ledger_interface - send payment - improper interface, not an array " , null)) }
}
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example:
The switches need parens or the compile fails
The text was updated successfully, but these errors were encountered: