async function upgradeUsersToCreators (executeAll, executeOne) {
  await logOps('Upgrade to creator', async () => {
    try {
      await executeAll(async (libs, i) => {
        // Check if existing users are already creators. If so, don't upgrade
        const existingUser = await getUser({ executeOne, walletIndex: i })
        if (!existingUser) throw new Error(`Cannot upgrade nonexistant user with wallet=${libs.walletAddress}`)
        if (existingUser.tracks > 0) {
          logger.info(`User ${existingUser.user_id} is already a creator. Skipping upgrade...`)
          return
        }
        // Upgrade to creator with replica set (empty string as users will be assigned an rset on signup)
        await executeOne(i, l => upgradeToCreator(l, existingUser.creator_node_endpoint))
        logger.info(`Finished upgrading creator for user=${existingUser.user_id}`)

        // Wait until upgrade txn has been indexed
        await executeOne(i, libs => libs.waitForLatestBlock())
      })
    } catch (e) {
      logger.error('GOT ERR UPGRADING USER TO CREATOR')
      console.error(e)
      throw e
    }
  })
}
/**
 * Helper function to upgrade a user at a wallet index to a creator if not already.
 * @param {*} executeAll
 * @param {*} executeOne
 * @param {int} numCreatorNodes
 */
Helper function to upgrade a user at a wallet index to a creator if not already.
Helper function to upgrade a user at a wallet index to a creator if not already .
async function upgradeUsersToCreators (executeAll, executeOne) {
  await logOps('Upgrade to creator', async () => {
    try {
      await executeAll(async (libs, i) => {
        const existingUser = await getUser({ executeOne, walletIndex: i })
        if (!existingUser) throw new Error(`Cannot upgrade nonexistant user with wallet=${libs.walletAddress}`)
        if (existingUser.tracks > 0) {
          logger.info(`User ${existingUser.user_id} is already a creator. Skipping upgrade...`)
          return
        }
        await executeOne(i, l => upgradeToCreator(l, existingUser.creator_node_endpoint))
        logger.info(`Finished upgrading creator for user=${existingUser.user_id}`)
        await executeOne(i, libs => libs.waitForLatestBlock())
      })
    } catch (e) {
      logger.error('GOT ERR UPGRADING USER TO CREATOR')
      console.error(e)
      throw e
    }
  })
}
async function upgradeUsersToCreators ( executeAll , executeOne ) { await logOps ( 'Upgrade to creator' , async ( ) => { try { await executeAll ( async ( libs , i ) => { const existingUser = await getUser ( { executeOne , walletIndex : i } ) if ( ! existingUser ) throw new Error ( ` ${ libs . walletAddress } ` ) if ( existingUser . tracks > 0 ) { logger . info ( ` ${ existingUser . user_id } ` ) return } await executeOne ( i , l => upgradeToCreator ( l , existingUser . creator_node_endpoint ) ) logger . info ( ` ${ existingUser . user_id } ` ) await executeOne ( i , libs => libs . waitForLatestBlock ( ) ) } ) } catch ( e ) { logger . error ( 'GOT ERR UPGRADING USER TO CREATOR' ) console . error ( e ) throw e } } ) }
Helper function to upgrade a user at a wallet index to a creator if not already.
Helper function to upgrade a user at a wallet index to a creator if not already .
// Check if existing users are already creators. If so, don't upgrade // Upgrade to creator with replica set (empty string as users will be assigned an rset on signup) // Wait until upgrade txn has been indexed