-
Notifications
You must be signed in to change notification settings - Fork 66
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
Multi-network support in ERC20 driver #947
Conversation
b7aa372
to
71afa7d
Compare
76428c2
to
0f86504
Compare
9737ec6
to
eb63d2f
Compare
0f86504
to
1d8733e
Compare
Separated account funding from initialization. On rinkeby, fund command obtains ETH and GLM from fucet. On mainnet, it displays a message to get funds. Initialization in send mode requires non-zero balance of both GLM and ETH. Signed-off-by: Adam Wierzbicki <awierzbicki@golem.network>
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.
LGTM!
Just some nitty comments, still approving!
core/payment-driver/gnt/src/lib.rs
Outdated
&self, | ||
address: &str, | ||
) -> Pin<Box<dyn Future<Output = GNTDriverResult<String>> + 'a>> { | ||
let address = utils::str_to_addr(address).unwrap(); |
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.
.map_err()?
instead of unwrap?
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.
Unfortunately, that won't work. 😢 I could only do that within the async move block but I need the converted address before to create the futures.
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 will move the type conversion one level up to remove unwrap
.
address: &str, | ||
network: Network, | ||
) -> GNTDriverResult<BigDecimal> { | ||
match network { |
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 match network
block is repeated a lot, could be something lie self.get_network_driver(network).do_function().await
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'll give that a try.
_caller: String, | ||
msg: Fund, | ||
) -> Result<String, GenericError> { | ||
log::info!("fund: {:?}", msg); |
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.
msg should be logged on debug since its ugly, maybe a neat UX friendly message saying "Preparing to fund address {}..."
} | ||
|
||
fn parse_platform(platform: String) -> Result<Network, GenericError> { | ||
let parts: Vec<&str> = platform.split("-").collect(); |
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 stuff will not with with the metamask driver on your example, since {drivername}-{network}-{token} !== {platform}
Can leave it for now, maybe a note to our future selves would be nice
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 code is not meant to be re-used by other drivers. It will be scrapped once erc20 driver is refactored to use base crate.
Applied review comments. Signed-off-by: Adam Wierzbicki <awierzbicki@golem.network>
No description provided.