-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add total sold vs available widget #2898
Add total sold vs available widget #2898
Conversation
9e79a65
to
9cc7853
Compare
6d1c360
to
b5d4612
Compare
444e848
to
c1a32c3
Compare
85fa442
to
dec86a0
Compare
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.
Looks like the perfectFit property was dropped - See reference: https://github.com/malte-wessel/react-textfit/blob/fc7aa18e61a2397fcef838dc8b16c8dc027dce26/CHANGELOG.md#v100 |
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.
@ArmandoGraterol, it's a leftover prop I forgot to remove - thank you for spotting it! It should be all good now - without any warning. |
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.
Working well, without the error now for me!
7f453ac
to
ec2406e
Compare
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.
Yep, from what I've tested it's working as expected and without warnings! Good job
@ArmandoGraterol , @arrenv , can you please review my latest commit and test again? I have added the dynamic switching to 2 lines when the font-size reaches 10px. |
f089125
to
9ba1bbf
Compare
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.
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.
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.
Congrats on putting this PR together. Very nice work! 💯
There still is a issue in here. (but which was inherited from the previous iteration)
If the coin machine has less tokens that the batch available, it will still show the batch as having available the "max" allowed, even though the coin machine doesn't have them anymore.
I'll show you some pictures since it's easier to explain.
In here, there are only 10 tokens available in the coin machine (which the "Total sold v. available correctly shows -- 70/80), the buy widget correctly only allows you to buy 10 (notice the error), but the "Batch sold v. available" widget still shows 0 / 40 which is incorrect in this case as there are only 10 tokens left. It should show 0 / 10.
Notice, that if I pass the period, the previous batches table shows the period, correctly, as having just 0 / 10
src/data/resolvers/coinMachine.ts
Outdated
tokenClient.filters.Transfer(null, coinMachineClient.address, null), | ||
); |
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 is very expensive, but I guess it's what we have to do in order to fetch the token transfers into the coin machine.
However, you can filter it even more, by only fetching blocks from the time the current instance of the coin machine was installed.
See this for an example:
colonyDapp/src/data/resolvers/coinMachine.ts
Lines 329 to 356 in 9ba1bbf
const subgraphData = await apolloClient.query< | |
SubgraphCoinMachinePeriodsQuery, | |
SubgraphCoinMachinePeriodsQueryVariables | |
>({ | |
query: SubgraphCoinMachinePeriodsDocument, | |
variables: { | |
colonyAddress: colonyAddress.toLowerCase(), | |
extensionAddress: coinMachineClient.address.toLowerCase(), | |
limit, | |
}, | |
fetchPolicy: 'network-only', | |
}); | |
const [extensionInitialised] = ( | |
subgraphData?.data?.extensionInitialisedEvents || [] | |
).map(parseSubgraphEvent); | |
/* | |
* We use the `FromChain` suffix to make these events more easily | |
* recognizable when reading the code | |
*/ | |
const transferLogsFromChain = await getLogs( | |
tokenClient, | |
tokenClient.filters.Transfer(null, coinMachineClient.address, null), | |
{ | |
fromBlock: extensionInitialised?.blockNumber, | |
}, | |
); |
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.
Fair enough - done now.
@@ -201,7 +201,7 @@ const BuyTokens = ({ | |||
const getFormattedCost = useCallback( | |||
(amount) => { | |||
const decimalCost = new Decimal(amount) | |||
.times(salePriceData.coinMachineCurrentPeriodPrice) | |||
.times(salePriceData?.coinMachineCurrentPeriodPrice || '0') |
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.
Shouldn't this actually be OR 1
, because if you multiply by 0
, you'll always get 0
, but if you multiply by 1
you'll just get the amount.
Depends on what you want the fallback to be.
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 think the default value should be 0
. If it's 0
it will give an indication that something is off more that if it defaults to 1
.... But I am happy to hear a counter-argument
@@ -311,6 +346,7 @@ const CoinMachine = ({ | |||
}} | |||
sellableToken={sellableToken} | |||
purchaseToken={purchaseToken} | |||
periodTokens={periodTokens} |
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 really that you put the period tokens back in here, as I worked really hard to refactor this so that it expressly doesn't use this specific value as it's not quite optimized.
However, I do understand why it's here, because you had to move the "Price next batch" display into the table.
I really don't like this, but this is a side-effect of just refactoring design willy nilly, you end up with content you need to move around, and you just slap it somewhere....
(sorry for the rant :) )
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 am not sure I understand why it's so bad as I just moved the Price next batch
logic from one component to another and added one prop to TokenSalesTable
...
I am happy to discuss this & refactor once I understand the ideal state you would like to see.
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.
@rdig updated the PR. Not sure about your comment regarding the periodTokens
prop passing, other than that it's ready for re-review.
@@ -311,6 +346,7 @@ const CoinMachine = ({ | |||
}} | |||
sellableToken={sellableToken} | |||
purchaseToken={purchaseToken} | |||
periodTokens={periodTokens} |
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 am not sure I understand why it's so bad as I just moved the Price next batch
logic from one component to another and added one prop to TokenSalesTable
...
I am happy to discuss this & refactor once I understand the ideal state you would like to see.
src/data/resolvers/coinMachine.ts
Outdated
tokenClient.filters.Transfer(null, coinMachineClient.address, null), | ||
); |
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.
Fair enough - done now.
@@ -201,7 +201,7 @@ const BuyTokens = ({ | |||
const getFormattedCost = useCallback( | |||
(amount) => { | |||
const decimalCost = new Decimal(amount) | |||
.times(salePriceData.coinMachineCurrentPeriodPrice) | |||
.times(salePriceData?.coinMachineCurrentPeriodPrice || '0') |
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 think the default value should be 0
. If it's 0
it will give an indication that something is off more that if it defaults to 1
.... But I am happy to hear a counter-argument
b807101
to
272a49e
Compare
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.
Description
This PR adds total sold vs. available widget and adds some updates to tokens display in the remaining widget.
New stuff ✨
TODO
Resolves #2868