Conversation
|
/cmd fmt |
|
/cmd prdoc --audience runtime_dev --bump minor |
…time_dev --bump minor'
|
/cmd fmt |
|
do we care semvar for test runtimes? they shouldn't be published anyway? |
Co-authored-by: Bastian Köcher <git@kchr.de>
| ) | ||
| })?; | ||
| Ok(amount_in) | ||
| Self::do_swap_tokens_for_exact_tokens( |
There was a problem hiding this comment.
Side note, I still think we should do something about functions that returns a dirty storage on error.
Maybe we should try to standardize a suffix: _mroe: must rollback on error.
And we use it every.
There was a problem hiding this comment.
I thought about this before and my conclusion is just we should require all non view only pallet public methods are protected with #[transactional].
And with pallet level fuzzing setup (which we don't have), it is easy to verify.
| Add `trait MutateLiquidity` for pallet-asset-conversion. | ||
| crates: | ||
| - name: pallet-asset-conversion | ||
| bump: minor |
There was a problem hiding this comment.
This is major change for the rust library, we change the functions signature.
There was a problem hiding this comment.
I guess there is nothing wrong to return a Result type for get_reserve in view function so I updated to avoid breaking change.
| #[pallet::weight(T::WeightInfo::swap_exact_tokens_for_tokens(path.len() as u32))] | ||
| pub fn swap_exact_tokens_for_tokens( | ||
| origin: OriginFor<T>, | ||
| path: Vec<Box<T::AssetKind>>, |
There was a problem hiding this comment.
For curiosity, why did we make it a Vec of Box in the past?
The only reason I know to use Box for arguments is to reduce the type size of the runtime call enum.
Is there another reason?
I also ask because just after we copy again the whole value into a Vec<AssetKind>.
| amount2_min_receive, | ||
| withdraw_to, | ||
| ) | ||
| } |
There was a problem hiding this comment.
We could have one test that calls into them, but also they are straightforward so it is good to me.
| asset2: T::AssetKind, | ||
| ) -> Result<(T::Balance, T::Balance), Error<T>> { | ||
| let pool_account = T::PoolLocator::pool_address(&asset1, &asset2) | ||
| .map_err(|_| Error::<T>::InvalidAssetPair)?; |
There was a problem hiding this comment.
we no longer make a distinction for this error and now always return PoolNoFound. But I think it is ok. As both error mean the pool doesn't exist.
| pub fn get_reserves( | ||
| asset1: T::AssetKind, | ||
| asset2: T::AssetKind, | ||
| ) -> Result<(T::Balance, T::Balance), Error<T>> { |
There was a problem hiding this comment.
We could keep this function and introduce get_reserves_ok to avoid a breaking change.
Co-authored-by: Guillaume Thiolliere <guillaume.thiolliere@parity.io>
| /// Swap the exact amount of `asset1` into `asset2`. | ||
| /// `amount_out_min` param allows you to specify the min amount of the `asset2` | ||
| /// you're happy to receive. | ||
| /// | ||
| /// [`AssetConversionApi::quote_price_exact_tokens_for_tokens`] runtime call can be called | ||
| /// for a quote. | ||
| #[pallet::call_index(3)] | ||
| #[pallet::weight(T::WeightInfo::swap_exact_tokens_for_tokens(path.len() as u32))] | ||
| pub fn swap_exact_tokens_for_tokens( |
There was a problem hiding this comment.
Why did you decide to change the ordering of these? Makes it hard to see the diff and what changed
There was a problem hiding this comment.
I think it is just that the function body as been moved outside of the call into a regular function, so the logic can be reused for the trait implementation.
There was a problem hiding this comment.
@gui1117 it was already in a helper function do_swap_exact_tokens_for_tokens, so it looks like this method was just moved up in the file.
There was a problem hiding this comment.
maybe I'm wrong, but I think it is just how git is showing the diff, the calls were ordered by call index and still is.
There was a problem hiding this comment.
yeah it is git diff got confused. the only "reordering" is the body moved from calls to helper methods and that's larger chunk of matching compare to just the call method declaration
be423a3
added view functions #7374 added trait `MutateLiquidity` to allow other pallets to manage liquidity #9765 --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Guillaume Thiolliere <guillaume.thiolliere@parity.io>
added view functions #7374 added trait `MutateLiquidity` to allow other pallets to manage liquidity #9765 --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Guillaume Thiolliere <guillaume.thiolliere@parity.io>
added view functions #7374
added trait
MutateLiquidityto allow other pallets to manage liquidity #9765