Skip to content

Commit

Permalink
Support parsing transitions with Option ByStr arguments (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
saeed-zil authored Dec 3, 2024
1 parent 6a3368b commit e263680
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 15 deletions.
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

0 comments on commit e263680

Please sign in to comment.