@@ -271,17 +271,17 @@ async function main() {
271
271
272
272
const messageBufferKeys = priceIds . map ( ( priceId ) => {
273
273
return {
274
- messageBufferKey : getMessageBufferPubkey (
274
+ messageBuffer : getMessageBufferPubkey (
275
275
pythOracleCpiAuth ,
276
276
priceId ,
277
277
messageBufferPid
278
278
) ,
279
- priceAccountKey : priceId ,
279
+ priceAccount : priceId ,
280
280
} ;
281
281
} ) ;
282
282
283
283
let accounts = await messageBufferProgram . account . messageBuffer . fetchMultiple (
284
- messageBufferKeys . map ( ( k ) => k . messageBufferKey )
284
+ messageBufferKeys . map ( ( k ) => k . messageBuffer )
285
285
) ;
286
286
287
287
const msgBufferKeysAndData = messageBufferKeys . map ( ( k , i ) => {
@@ -291,31 +291,35 @@ async function main() {
291
291
} ;
292
292
} ) ;
293
293
294
- alreadyInitializedAccounts = msgBufferKeysAndData . filter ( ( idAndAccount ) => {
295
- return idAndAccount . messageBufferData !== null ;
296
- } ) ;
294
+ alreadyInitializedAccounts = msgBufferKeysAndData
295
+ . filter ( ( idAndAccount ) => {
296
+ return idAndAccount . messageBufferData !== null ;
297
+ } )
298
+ . map ( ( v ) => {
299
+ return {
300
+ priceAccount : v . priceAccount . toString ( ) ,
301
+ messageBuffer : v . messageBuffer . toString ( ) ,
302
+ } ;
303
+ } ) ;
297
304
298
305
console . log ( `
299
- ${
300
- alreadyInitializedAccounts . length
301
- } message buffer accounts already initialized.
302
- alreadyInitializedAccounts: ${ JSON . stringify ( alreadyInitializedAccounts ) } ` ) ;
306
+ ${ alreadyInitializedAccounts . length } message buffer accounts already initialized` ) ;
307
+ console . table ( alreadyInitializedAccounts ) ;
303
308
304
309
const priceAccountPubkeysForNewlyInitializedMessageBuffers =
305
310
msgBufferKeysAndData . filter ( ( idAndAccount ) => {
306
311
return idAndAccount . messageBufferData === null ;
307
312
} ) ;
308
313
309
314
if ( priceAccountPubkeysForNewlyInitializedMessageBuffers . length === 0 ) {
310
- console . info ( `no new message buffers to initialize. exiting...` ) ;
311
- process . exit ( 1 ) ;
315
+ console . info ( `no new message buffers to initialize` ) ;
312
316
}
313
317
// TODO: optimize with batching
314
318
await Promise . all (
315
319
priceAccountPubkeysForNewlyInitializedMessageBuffers . map (
316
320
async ( idAndAccount ) => {
317
- const priceId = idAndAccount . priceAccountKey ;
318
- const messageBufferPda = idAndAccount . messageBufferKey ;
321
+ const priceId = idAndAccount . priceAccount ;
322
+ const messageBufferPda = idAndAccount . messageBuffer ;
319
323
const msgBufferPdaMetas = [
320
324
{
321
325
pubkey : messageBufferPda ,
@@ -360,6 +364,7 @@ async function main() {
360
364
console . info ( `Accounts with errors: ${ JSON . stringify ( errorAccounts ) } ` ) ;
361
365
}
362
366
console . log ( `Initialized ${ newlyInitializedAccounts . length } accounts` ) ;
367
+ console . table ( newlyInitializedAccounts ) ;
363
368
364
369
// Update whitelist admin at the end otherwise all the message buffer PDAs
365
370
// will have to be initialized by the whitelist admin (which could be the multisig)
0 commit comments