Skip to content
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

Support parsing transitions with Option ByStr arguments. #23

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/simplified_representation/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ impl AstConverting for SrEmitter {
NodeTypeArgument::TemplateTypeArgument(_) => {
unimplemented!();
}
NodeTypeArgument::AddressTypeArgument(_) => {
unimplemented!();
NodeTypeArgument::AddressTypeArgument(n) => {
n.visit(self)?;
}
NodeTypeArgument::MapTypeArgument(_, _) => {
unimplemented!();
Expand Down
8 changes: 8 additions & 0 deletions tests/contracts/ByStr.scilla
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,11 @@ contract AllByStrVariants
transition ArbitrageFromXCAD
(token : ByStr20 with contract field balances : Map ByStr20 Uint128 end)
end

transition BuyNFTUsername(
username: String,
guardianship: Option ByStr20 with contract field verification_methods: Map String ByStr33 end,
id: String,
tyron: Option Uint128
)
end
46 changes: 33 additions & 13 deletions tests/full_contract_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,39 @@ fn test_bystr_contract_parse() {
)
]),
fields: FieldList::default(),
transitions: TransitionList(vec![Transition::new(
"ArbitrageFromXCAD",
FieldList(vec![Field::new(
"token",
Type::ByStr20With {
type_name: "contract".to_string(),
fields: FieldList(vec![Field::new(
"balances",
Type::Map(Box::new(Type::ByStr20), Box::new(Type::Uint128))
),],),
},
)]),
)])
transitions: TransitionList(vec![
Transition::new(
"ArbitrageFromXCAD",
FieldList(vec![Field::new(
"token",
Type::ByStr20With {
type_name: "contract".to_string(),
fields: FieldList(vec![Field::new(
"balances",
Type::Map(Box::new(Type::ByStr20), Box::new(Type::Uint128))
),],),
},
)]),
),
Transition::new(
"BuyNFTUsername",
FieldList(vec![
Field::new("username", Type::String),
Field::new(
"guardianship",
Type::Option(Box::new(Type::ByStr20With {
type_name: "contract".to_string(),
fields: FieldList(vec![Field::new(
"verification_methods",
Type::Map(Box::new(Type::String), Box::new(Type::ByStrX(33)))
)])
}))
),
Field::new("id", Type::String),
Field::new("tyron", Type::Option(Box::new(Type::Uint128))),
])
)
])
}
);
}
Expand Down