-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat(token-manager): add token manager for ITS #215
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #215 +/- ##
==========================================
- Coverage 95.17% 95.09% -0.09%
==========================================
Files 61 65 +4
Lines 3423 3548 +125
==========================================
+ Hits 3258 3374 +116
- Misses 165 174 +9 ☔ View full report in Codecov by Sentry. |
#[test] | ||
fn execute_fails_unauthorized() { | ||
let (env, client, target) = setup(); | ||
let unauthorized = Address::generate(&env); |
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.
let unauthorized = Address::generate(&env); | |
let unauthorized_user = Address::generate(&env); |
or not_owner
?
let unauthorized = Address::generate(&env); | ||
|
||
assert_auth_err!( | ||
unauthorized, |
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.
unauthorized, | |
unauthorized_user, |
@@ -35,6 +35,7 @@ const ITS_HUB_CHAIN_NAME: &str = "axelar"; | |||
const PREFIX_INTERCHAIN_TOKEN_ID: &str = "its-interchain-token-id"; | |||
const PREFIX_INTERCHAIN_TOKEN_SALT: &str = "interchain-token-salt"; |
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.
const PREFIX_INTERCHAIN_TOKEN_SALT: &str = "interchain-token-salt"; | |
const PREFIX_INTERCHAIN_TOKEN_SALT: &str = "its-interchain-token-salt"; |
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.
@@ -35,6 +35,7 @@ const ITS_HUB_CHAIN_NAME: &str = "axelar"; | |||
const PREFIX_INTERCHAIN_TOKEN_ID: &str = "its-interchain-token-id"; | |||
const PREFIX_INTERCHAIN_TOKEN_SALT: &str = "interchain-token-salt"; | |||
const PREFIX_CANONICAL_TOKEN_SALT: &str = "canonical-token-salt"; | |||
const PREFIX_TOKEN_MANAGER: &str = "token-manager-id"; |
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.
Just to double check, in EVM the contract id looks like token-manager
: https://github.com/axelarnetwork/interchain-token-service/blob/cc6ef7282e18c6b2842cbf1098b06161e38ea32e/contracts/token-manager/TokenManager.sol#L30
if we're going to use token-manager-id
, then variable name could be PREFIX_TOKEN_MANAGER_ID
for code readability
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.
Unlike token id, there's no token manager id. Still I'm going to revisit the prefixes in a follow up PR
@@ -35,6 +35,7 @@ const ITS_HUB_CHAIN_NAME: &str = "axelar"; | |||
const PREFIX_INTERCHAIN_TOKEN_ID: &str = "its-interchain-token-id"; | |||
const PREFIX_INTERCHAIN_TOKEN_SALT: &str = "interchain-token-salt"; | |||
const PREFIX_CANONICAL_TOKEN_SALT: &str = "canonical-token-salt"; | |||
const PREFIX_TOKEN_MANAGER: &str = "token-manager-id"; | |||
const EXECUTE_WITH_TOKEN: &str = "execute_with_interchain_token"; |
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.
EXECUTE_WITH_INTERCHAIN_TOKEN
?
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.
Sure
Self::set_token_id_config( | ||
env, | ||
token_id, | ||
TokenIdConfigValue { | ||
token_address: deployed_address, | ||
token_address, | ||
token_manager: token_manager_address, |
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.
token_manager: token_manager_address, | |
token_manager_address, |
pub token_manager_address: Address, | ||
pub token_address: Address, |
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.
pub token_manager_address: Address, | |
pub token_address: Address, | |
pub token_address: Address, | |
pub token_manager_address: Address, |
TokenManagerType::LockUnlock => { | ||
token.transfer(sender, &env.current_contract_address(), &amount) | ||
} | ||
TokenManagerType::LockUnlock => token.transfer(sender, &token_manager, &amount), | ||
} |
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.
Do we need to check unsupported token manager type? e.g.
_ => {
return Err(ContractError::UnsupportedTokenManagerType);
}
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.
the enum is only defined for these two variants, so another option isn't possible
pub enum TokenManagerType { |
&env.current_contract_address(), | ||
recipient, | ||
&amount, | ||
), | ||
} |
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.
same question as above
let res: Val = env.invoke_contract(&contract, &func, args); | ||
|
||
extend_instance_ttl(env); | ||
|
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.
Just to check, does event
need to be emitted for the contract call?
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.
Nah, unnecessary gas cost for normal operations
AXE-6085