@@ -6,10 +6,9 @@ import { hideBin } from "yargs/helpers";
6
6
import dayjs from "dayjs" ;
7
7
import utc from "dayjs/plugin/utc.js" ;
8
8
import { createSnapshotCreator } from "./src/create-snapshot-from-block-limits.js" ;
9
- import { formatEther } from "ethers/lib/utils.js" ;
10
9
import fs from "fs" ;
11
10
import { fileToIpfs } from "./src/fileToIpfs.js" ;
12
-
11
+ import { addTransactionToBatch , writeTransactionBatch } from "./src/helpers/tx-builder.js" ;
13
12
dotenv . config ( ) ;
14
13
15
14
dayjs . extend ( utc ) ;
@@ -18,24 +17,28 @@ const chains = [
18
17
// ONLY uncomment Arbitrum Sepolia if you are testing
19
18
// {
20
19
// chainId: 421614,
20
+ // chainShortName: "arb-sep", // https://chainid.network/shortNameMapping.json
21
21
// blocksPerSecond: 0.268,
22
22
// klerosCoreAddress: "0xA54e7A16d7460e38a8F324eF46782FB520d58CE8",
23
23
// token: "0x34B944D42cAcfC8266955D07A80181D2054aa225",
24
24
// pnkDropRatio: BigNumber.from("1000000000"),
25
25
// fromBlock: 3638878,
26
26
// provider: getDefaultProvider(process.env.INFURA_ARB_SEPOLIA_RPC),
27
27
// merkleDropAddress: "0x93024F2D53D180074F4575818dE3E8dcE8147CF2",
28
+ // safeAddress: "0x66e8DE9B42308c6Ca913D1EE041d6F6fD037A57e", // Safe not supported on Arbitrum Sepolia
28
29
// },
29
30
{
30
31
chainId : 42161 ,
32
+ chainShortName : "arb" , // https://chainid.network/shortNameMapping.json
31
33
blocksPerSecond : 0.26 ,
32
34
klerosCoreAddress : "0x991d2df165670b9cac3B022f4B68D65b664222ea" ,
33
35
token : "0x330bD769382cFc6d50175903434CCC8D206DCAE5" ,
34
36
pnkDropRatio : BigNumber . from ( "1000000000" ) ,
35
37
fromBlock : 272063254 ,
36
38
provider : getDefaultProvider ( process . env . INFURA_ARB_ONE_RPC ) ,
37
- merkleDropAddress : "0x2a23B84078b287753A91C522c3bB3b6B32f6F8f1"
38
- }
39
+ merkleDropAddress : "0x2a23B84078b287753A91C522c3bB3b6B32f6F8f1" ,
40
+ safeAddress : "0x66e8DE9B42308c6Ca913D1EE041d6F6fD037A57e" ,
41
+ } ,
39
42
] ;
40
43
41
44
const argv = yargs ( hideBin ( process . argv ) )
@@ -167,7 +170,9 @@ const main = async () => {
167
170
const snapshot = await createSnapshot ( { fromBlock : c . fromBlock , startDate, endDate } ) ;
168
171
snapshotInfos . push ( {
169
172
// edit when arbitrum inclusion
170
- filename : `${ c . chainId == "42161" ? "arbitrum-" : "arbitrumSepolia-" } snapshot-${ startDate . toISOString ( ) . slice ( 0 , 7 ) } .json` ,
173
+ filename : `${ c . chainId == "42161" ? "arbitrum-" : "arbitrumSepolia-" } snapshot-${ startDate
174
+ . toISOString ( )
175
+ . slice ( 0 , 7 ) } .json`,
171
176
chain : c ,
172
177
snapshot,
173
178
period : periods [ c . chainId ] ,
@@ -185,27 +190,29 @@ const main = async () => {
185
190
// txs to run sequentially, hardcoded section.
186
191
console . log ( "PNK should be already approved to MerkleRedeem contract for each chain" ) ;
187
192
188
- const merkleDropABI = [
189
- "function seedAllocations(uint _month, bytes32 _merkleRoot, uint _totalAllocation) external"
190
- ] ;
191
-
192
- // Helper function to generate transaction URLs
193
- const txToUrl = ( tx , chainId ) =>
194
- `https://greenlucid.github.io/lame-tx-prompt/site?to=${ tx . to } &data=${ tx . data } &value=0&chainId=${ chainId } ` ;
193
+ const merkleDropABI = [ "function seedAllocations(uint _month, bytes32 _merkleRoot, uint _totalAllocation) external" ] ;
195
194
196
195
// Loop through snapshotInfos to generate transactions for each chain
197
196
for ( const sinfo of snapshotInfos ) {
198
197
const merkleContract = new Contract ( sinfo . chain . merkleDropAddress , merkleDropABI ) ;
199
198
200
199
// Populate the seedAllocations transaction
201
200
const tx = await merkleContract . populateTransaction . seedAllocations (
202
- sinfo . period , // The period (month) for this snapshot
201
+ sinfo . period , // The period (month) for this snapshot
203
202
sinfo . snapshot . merkleTree . root , // The Merkle root from the snapshot
204
- sinfo . snapshot . droppedAmount // The total allocation to drop
203
+ sinfo . snapshot . droppedAmount // The total allocation to drop
205
204
) ;
206
205
207
- // Log the transaction URL for this chain
208
- console . log ( `Transaction for chain ${ sinfo . chain . chainId } :` , txToUrl ( tx , sinfo . chain . chainId ) ) ;
206
+ addTransactionToBatch ( tx ) ;
207
+
208
+ const { chainId, chainShortName, safeAddress } = sinfo . chain ;
209
+ writeTransactionBatch ( {
210
+ name : "Seed allocations" ,
211
+ chainId,
212
+ chainShortName,
213
+ safeAddress,
214
+ outputPath : `tx-batch-${ chainShortName } .json` ,
215
+ } ) ;
209
216
}
210
217
} ;
211
218
0 commit comments