Skip to content
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

Finance: fix token fallbacks and error handling #813

Merged
merged 4 commits into from Apr 18, 2019

Conversation

Projects
None yet
3 participants
@sohkai
Copy link
Member

commented Apr 17, 2019

Fixes aragon/aragon#734.

With aragon/aragon.js#277 we now get the actual errors back from the RPC when a call goes wrong (e.g. naive token.symbol() on DAI) and we need to handle these explicitly.

This PR converts a lot of the token fallback-related bits into simpler Promise-based code and adds explicit handlers for their error cases.

@coveralls

This comment has been minimized.

Copy link

commented Apr 18, 2019

Coverage Status

Coverage remained the same at 97.015% when pulling e8ccf6c on finance-fix-dai into 0bf6ff4 on master.

@@ -167,16 +168,20 @@ class Deposit extends React.Component {
}

const [tokenSymbol, tokenDecimals] = await Promise.all([
getTokenSymbol(api, address),
token.decimals().toPromise(),
getTokenSymbol(api, address).catch(() => {}),

This comment has been minimized.

Copy link
@bpierre

bpierre Apr 18, 2019

Member

Super nitpicky but should we return explicit values (null) rather than implicit undefined in these cases?

This comment has been minimized.

Copy link
@sohkai

sohkai Apr 18, 2019

Author Member

Yeah... we should probably settle on a convention for handling errors and their "safe" default values.

In the case of the balance check above, I opted for "0" since it'll show "no balances" but we could probably use "-1" as "couldn't find balance".

This comment has been minimized.

Copy link
@sohkai

sohkai Apr 18, 2019

Author Member

I've now changed it to use -1 for the balance if the balance call failed and default the symbol and name values to '' (since they're optional strings for the token to implement) in a067c7c.

@sohkai sohkai force-pushed the finance-fix-dai branch from 8d74dc9 to a067c7c Apr 18, 2019

return ''
}

return userBalance === -1

This comment has been minimized.

Copy link
@bpierre

bpierre Apr 18, 2019

Member

I think this should be '-1'?

This comment has been minimized.

Copy link
@sohkai

sohkai Apr 18, 2019

Author Member

😅 this is why I need a second pair of eyes 😄

@sohkai sohkai merged commit f207a7e into master Apr 18, 2019

1 of 4 checks passed

Travis CI - Pull Request Build Errored
Details
Travis CI - Branch Build Failed
Details
License Compliance FOSSA is analyzing this commit
Details
license/cla Contributor License Agreement is signed.
Details
@bpierre
Copy link
Member

left a comment

💯 💯 💯

@sohkai sohkai deleted the finance-fix-dai branch Apr 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.