-
Notifications
You must be signed in to change notification settings - Fork 26
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
♻️ Abstract SwapVenue Validation to a Method on the Type #62
base: main
Are you sure you want to change the base?
Conversation
eca2c57
to
22ca57b
Compare
@@ -102,6 +103,25 @@ pub struct SwapVenue { | |||
pub adapter_contract_address: String, | |||
} | |||
|
|||
impl SwapVenue { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be UncheckedSwapVenue
&self, | ||
deps: &DepsMut, | ||
swap_venue_map: Map<&str, Addr>, | ||
) -> Result<Addr, SkipError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should return a SwapVenue
return Err(ContractError::DuplicateSwapVenueName); | ||
} | ||
// Validate the swap venue (checks for valid address and non-duplicate name) | ||
let checked_swap_contract_address = swap_venue.validate(&deps, SWAP_VENUE_MAP)?; | ||
|
||
// Store the swap venue name and contract address inside the swap venue map | ||
SWAP_VENUE_MAP.save( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of an address, it should store a SwapVenue
45aae8c
to
e27cdff
Compare
This PR moves the SwapVenue validation logic out of the entry point contract's instantiate function and into a method implemented on the SwapVenue object itself.