-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: parse allocation csvs #194
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
frontend/utils/db.ts
Outdated
@@ -74,6 +75,9 @@ export async function addClaimInfosToDatabase( | |||
}) | |||
) | |||
|
|||
console.log(`\n\nbuilt merkle tree\n\n`) |
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.
TODO: clean up comments.
right now this insert is taking a long time so will look into optimizing
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.
Yeah makes sense, I am sure you can batch the queries
usage | ||
exit | ||
else | ||
test=1 | ||
fi | ||
shift | ||
;; | ||
-c|--csv) | ||
if [ "$dev" -eq 1 ] || [ "$test" -eq 1 ]; then |
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.
Would something like if $dev + $test + $csv != 1
be simpler?
fs.readFileSync(path.resolve(CSV_DIR, defi_csv), 'utf-8'), | ||
{ | ||
header: true, | ||
skipEmptyLines: true, |
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.
Is this needed? we might want to code to crash if there are empty lines
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 originally added this for handling any empty lines at the end but open to removing this and throwing errors/crashing
) | ||
assert( | ||
defiCsvClaims.meta.fields?.includes('alloc'), | ||
"CSV file does not have required 'alloc' column" |
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.
should it check that there's a chain column
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.
Also might be useful to refactor this into a hasColumns
function
assert( | ||
!curChainsForAddr.includes(chainAndAlloc[0]), | ||
`CurChainsForAddr: ${curChainsForAddr}. Address ${key} has duplicate chain ${chainAndAlloc[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 it would be good to have logic here that ignores dev addresses if they are already in the defi claims csv
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 was planning on just removing them from the defi_dev.csv address but can change to this instead
async function main() { | ||
await clearDatabase(pool) | ||
const { claimInfos, evmBreakdownAddresses, solanaBreakdownData } = parseCsvs() | ||
if (DEBUG) { | ||
const [maxUser, maxAmount] = getMaxUserAndAmount(claimInfos) |
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.
Good sanity checks
assert( | ||
discordClaimsAddrSet.size === | ||
discordDevClaims.length + discordClaims.length, | ||
'Discord claims and discord dev claims have duplicate addresses' |
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.
Same comment as for defi_dev, maybe it's fine just skipping the dev claims that are already in the main table instead of crashing
evmBreakDowns.push({ | ||
chain, | ||
identity, | ||
amount: truncateAllocation(alloc), |
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.
Maybe this conversion should happen inside parseCsv and parseCsv should return a EvmBreakdownRow[] and a SolanaBreakdownRow[]
@guibescos i left some console logging statements since this is just a script that will only be used internally but if you want me to remove them lmk and i can clean those up |
frontend/utils/db.ts
Outdated
@@ -10,6 +10,8 @@ import { getMaxAmount } from '../claim_sdk/claim' | |||
import * as anchor from '@coral-xyz/anchor' | |||
import { MerkleTree } from '../claim_sdk/merkleTree' | |||
import { BN } from 'bn.js' | |||
const sql = require('sql') as any | |||
// import { SQL, define } from 'sql'; |
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.
Commented out code
@@ -30,3 +30,4 @@ DISPENSER_GUARD=[128,47,82,29,168,187,15,46,104,227,206,117,172,71,34,235,23,50, | |||
FUNDER_KEYPAIR=[145,197,43,77,224,103,196,174,132,195,48,31,177,97,237,163,15,196,217,142,181,204,104,107,98,82,213,0,155,140,218,180,30,119,201,38,51,176,207,221,193,222,235,244,163,250,125,66,68,196,45,208,212,201,232,178,100,163,24,21,106,83,66,174] | |||
|
|||
PROGRAM_ID=Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS |
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.
Let's add DEPLOYER_WALLET here
@@ -17,7 +19,12 @@ import BN from 'bn.js' | |||
import NodeWallet from '@coral-xyz/anchor/dist/cjs/nodewallet' | |||
import { EvmBreakdownRow } from '../utils/db' | |||
import assert from 'assert' | |||
import path from 'path' | |||
import { SolanaBreakdown } from 'utils/api' |
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.
Unused
@@ -31,19 +38,43 @@ const FUNDER_KEYPAIR = Keypair.fromSecretKey( | |||
) | |||
const CLUSTER = envOrErr('CLUSTER') |
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.
Unused
|
||
const NFT_CLAIMS = 'nft.csv' | ||
|
||
const ECOSYSTEM_LIST = [ |
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 Ecosystems
from ../claim_sdk/claim
}) | ||
|
||
// need solana breakdown between nft & defi | ||
const nftCsvClaims = Papa.parse( |
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.
Perhaps refactor into parseNftClaims
frontend/utils/db.ts
Outdated
) | ||
let claimInfoChunks = [] | ||
let chunkSize = 100 | ||
let chunkCounts = [...Array(Math.ceil(claimInfos.length / chunkSize))] |
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.
You don't need this variable, only the index is important
frontend/utils/db.ts
Outdated
] | ||
) | ||
let claimInfoChunks = [] | ||
let chunkSize = 100 |
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.
Feels like this should be const
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 like it! Dropped many minor comments.
* Add change * Optimize csvs
No description provided.