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

Numeric Traits | Broken Filtering #54

Open
skiinginjeans opened this issue Jan 22, 2022 · 1 comment
Open

Numeric Traits | Broken Filtering #54

skiinginjeans opened this issue Jan 22, 2022 · 1 comment

Comments

@skiinginjeans
Copy link

Cool project thanks for sharing with us.

Using numeric trait values causes the build-rarities script to miss actual tokens at this line:
https://github.com/cryptoDevAmigos/rarity-analyzer/blob/main/packages/common-node/src/build-rarities.ts#L133

It ends up showing as [Missing] in the filtering functionality on the left nav which is undesirable given that the value is not actually missing;

I solved this on my fork by coercing the value to a string for equality matching:

.filter(t=>t.attributeRarities.some(a=>a.trait_type === x.trait_type && String(a.value) === String(x.value)))

There may be a better solution but this worked for me.

@skiinginjeans
Copy link
Author

Worth noting that due to the rarity calculator 0 is still not a valid trait value:

This line filters out 0

const allAttributesRaw = metadata.flatMap(x => x.attributes).filter(x => !!x.value);

Nice chart here

 value     │  !value  │  !!value
━━━━━━━━━━━┿━━━━━━━━━━┿━━━━━━━━━━━
 false     │ ✔ true   │   false
 true      │   false  │ ✔ true
 null      │ ✔ true   │   false
 undefined │ ✔ true   │   false
 0         │ ✔ true   │   false
 -0        │ ✔ true   │   false
 1         │   false  │ ✔ true
 -5        │   false  │ ✔ true
 NaN       │ ✔ true   │   false
 ''        │ ✔ true   │   false
 'hello'   │   false  │ ✔ true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant