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

Use client as primary token source #1967

Merged
merged 15 commits into from
Jan 23, 2020
Merged

Use client as primary token source #1967

merged 15 commits into from
Jan 23, 2020

Conversation

chmanie
Copy link
Member

@chmanie chmanie commented Jan 17, 2020

Description

This PR adds local resolvers for token data which query the token contracts directly instead of relying on the server. The colony and user tokens are still stored on the server but just as addresses. Furthermore we changed the way the tokens are added to colonies and users (via entering a token address in the edit tokens dialog).

New stuff

  • Token resolvers for users, colonies and payouts

Changes 🏗

  • Refined token edit modals

Resolves #1959
Resolves #1971
Resolves #1978

@todo
Copy link

todo bot commented Jan 20, 2020

validate against entering a duplicate address

https://github.com/JoinColony/colonyDapp/blob/bb5a5aa39c73f628447843586ba7c31b11ed8162/src/modules/core/components/TokenEditDialog/TokenEditDialog.tsx#L66-L71


This comment was generated by todo based on a todo comment in bb5a5aa39c73f628447843586ba7c31b11ed8162 in #1967. cc @JoinColony.

@ceolson01 ceolson01 added this to the Sprint 42 milestone Jan 20, 2020
@chmanie chmanie marked this pull request as ready for review January 20, 2020 17:05
@chmanie chmanie force-pushed the refactor/token-info branch from 74b5fcd to 2f02621 Compare January 20, 2020 17:09
Copy link
Member

@rdig rdig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of what I was able to test was blocked by the TokenInfoDocument query failing

Just from reading the code it all seems sensible.

So I'll do another pass once you fix that issue with the query

console.warn(`Token with address ${tokenAddress} not found on server`);
}

const serverData: TokenInfo = serverDataResult
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serverDataResult here returns:

{
  tokenInfo: { ... }
}

So this logic condition will always fail

Screenshot from 2020-01-22 16-47-32

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed! Thanks!

return (
<div className={styles.main}>
<div className={styles.tokenChoice}>
<TokenIcon token={token} name={token.name || undefined} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an error with the HookedTokenIcon.

I think it passes down some props to the underlying svg, that it can't handle

Screenshot from 2020-01-22 16-53-41

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I honestly have no idea what causes this. $$typeof comes from react so it should be OK

@@ -190,17 +183,6 @@ const StepCreateToken = ({
help={MSG.helpTokenSymbol}
/>
</div>
<div className={styles.inputFieldWrapper}>
<ActionFileUpload
name="tokenIcon"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we removed the Token info from the native token creation screen, shouldn't we also remove it from the external token "creation" page?:

https://github.com/JoinColony/colonyDapp/blob/2f02621bbb7fda94b9d452b49647609660abc64e/src/modules/dashboard/components/CreateColonyWizard/StepSelectToken.tsx#L187-L197

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think we need to make @JoinColony/product aware of this change

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should remove that, good catch!


let serverDataResult;
try {
const { data } = await client.query({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This query always fails on my machine claiming it can't the iconHash prop on some undefined object:

Screenshot from 2020-01-22 17-09-53

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is a good find!

@chmanie chmanie force-pushed the refactor/token-info branch 2 times, most recently from 26694d0 to 3758e62 Compare January 22, 2020 21:15
@chmanie chmanie requested a review from rdig January 22, 2020 22:47
Copy link
Member

@rdig rdig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After adding those two fixes everything seems to be working fine, so congrats Chris!

This was a lot of work, both on the dapp and the server side, and you've done an amazing job.

Screenshot from 2020-01-23 10-00-26

Screenshot from 2020-01-23 10-03-43

I've tested every interaction I could think of: native tokens, external tokens, send in, claiming, minting, etc.

Everything works well, but again, I do worry about the Ethplorer API key limitation.

I did find a UX issue we can improve on in the future:

  • You send in an external token
  • You claim it for your colony
  • It won't show up in your colony's tokens, until you manually add it via it's address

This all works as expected now, but an improvement here would be to automatically add that token to the user's colony when claiming the funds, as we already have all the data we need for that.

But again, this is a minor improvement, and it's nowhere near a priority right now.

@chmanie chmanie force-pushed the refactor/token-info branch from 3758e62 to 2003676 Compare January 23, 2020 10:10
@chmanie chmanie merged commit 102e9c7 into master Jan 23, 2020
@chmanie chmanie deleted the refactor/token-info branch January 23, 2020 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants