-
Notifications
You must be signed in to change notification settings - Fork 2
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
chore: dynamic weights strategy table #47
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
web/app/r/[id]/page.tsx
Outdated
}; | ||
}); | ||
|
||
const amount = run.data.funding_entries.reduce((previous, current) => { |
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.
Super nit: run.data.funding_entries.reduce((acc, x) => acc + Number(x.amount), 0);
acc
is for accumulator, relatively standard
You could also do (s, x) or even (a, b) instead of (acc, x), I think most people reading it would know what it does
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.
yah agreed - i added it cause its easier for me to read hehe will update it accordingly
web/components/FundingReview.tsx
Outdated
const networkIndex = Object.values(SUPPORTED_NETWORKS).indexOf(11155111) | ||
const networkName = Object.keys(SUPPORTED_NETWORKS)[networkIndex] as NetworkName | ||
const token = getTokensForNetwork(networkName).find(t => t.name == "WETH") | ||
const networkIndex = Object.values(SUPPORTED_NETWORKS).indexOf(11155111); |
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.
Can we use the user's current address? We can just make sure that we switch to Sepolia when testing.)
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.
yup yup
const networkName = Object.keys(SUPPORTED_NETWORKS)[ | ||
networkIndex | ||
] as NetworkName; | ||
const token = getTokensForNetwork(networkName).find( |
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.
Could we use the first token in the list as the default one?
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.
yasss
web/components/Strategy.tsx
Outdated
strategy: StrategyWithProjects, | ||
amount: string | ||
) => { | ||
const selectedStrategies = strategy.filter(({ selected }) => selected); |
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.
NIT: strategy.filter(x => x.selected);
web/components/Strategy.tsx
Outdated
const weights = selectedStrategies.map((s) => s.weight) as number[]; | ||
const amounts = distributeWeights(weights, +amount, 2); | ||
let amountIndex = 0; | ||
return strategy.map(s => { |
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.
Might be simpler to do
return strategy.map(s => ({
...s,
amount: s.selected ? amounts[amountIndex++].toFixed(2) : undefined
}));
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.
smart
I was able to make it show incorrect % values by:
If you select the "toggle all" button in the top right to turn the off/on again it will reset back to the original correct values. |
…ywrap/fund-public-goods-ai into chore/dynamic-weights-strategy-table
@dOrgJelli nice catch, I didn't handle that case - added a commit to fix that |
Found one more, otherwise it's working great! |
@dOrgJelli what is the expected behavior here? my thought was that if a strategy is unselected, and then you select it again; it will have the default weight (which is the one given by the agent). if the user would like to set any weight in particular he could just edit the weight input manually |
No description provided.