Skip to content
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

PROTO-1775: rm tcr env #8119

Merged
merged 5 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,57 +12,36 @@ export type SharedData = {
libs: AudiusLibs
localEndpoint: string
dryRun: boolean
dateToRun: string
}

let sharedData: SharedData | undefined = undefined

export const initSharedData = async (): Promise<SharedData> => {
if (sharedData !== undefined) return sharedData

dotenv.config({ path: './tcr.env' })

const libs = await initAudiusLibs()

// default to true if undefined, otherwise explicitly state false to not do dry run
const dryRun = !(
(process.env.dryRun || 'true').toLocaleLowerCase() === 'false'
(process.env.tcrDryRun || 'true').toLocaleLowerCase() === 'false'
)

const oracleEthAddress = process.env.oracleEthAddress
const AAOEndpoint = process.env.AAOEndpoint
const feePayerOverride = process.env.feePayerOverride
const localEndpoint = process.env.localEndpoint

const dateToRun = process.env.dateToRun
const feePayerOverride = process.env.audius_fee_payer_override
const AAOEndpoint = process.env.audius_aao_endpoint || "https://antiabuseoracle.audius.co"
const oracleEthAddress = process.env.audius_aao_address || "0x9811BA3eAB1F2Cd9A2dFeDB19e8c2a69729DC8b6"
const localEndpoint = process.env.audius_discprov_url || "http://server:5000"

if (oracleEthAddress === undefined)
throw new Error('oracleEthAddress undefined')
if (AAOEndpoint === undefined) throw new Error('AAOEndpoint undefined')
if (feePayerOverride === undefined)
throw new Error('feePayerOverride undefined')
if (localEndpoint === undefined) throw new Error('localEndpoint undefined')
if (dateToRun === undefined) throw new Error('dateToRun undefined')

sharedData = {
oracleEthAddress,
AAOEndpoint,
feePayerOverride,
libs,
localEndpoint,
dryRun,
dateToRun
dryRun
}
// @ts-ignore
return sharedData
}

export const condition = (app: App<SharedData>): boolean => {
// "Fri 09:43:00 GMT-0600"
const { dateToRun } = app.viewAppData()
const date = Date.parse(dateToRun)
const timeToDisburse = moment(date)
const now = moment()
if (now.isSame(timeToDisburse, 'seconds')) return true
return false
}
Comment on lines -59 to -68
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this is just unused cruft

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this used to rely on the date env var i removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use cron now

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const main = async () => {
}

// Friday at 12:01 pm PST, extra five minutes for trending to calculate
cron.schedule('1 12 * * 5', () => {
cron.schedule('5 12 * * 5', () => {
initSharedData().then((data) => {
// make new appdata instance to satisfy types
const appData = new App<SharedData>({ appData: data })
Expand Down