Skip to content

Commit

Permalink
release-rewards: lazy initialize ledger
Browse files Browse the repository at this point in the history
Otherwise if you first need to wait until you sent funds to your account and then press
`yes`, the ledger connection won't work any more.
  • Loading branch information
juliangruber committed Nov 11, 2024
1 parent 19e1429 commit a16e6c3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions bin/release-rewards.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ import pRetry from 'p-retry'
process.title = 'release-rewards'
const { RPC_URL = 'https://api.node.glif.io/rpc/v1', WALLET_SEED } = process.env

const provider = new ethers.JsonRpcProvider(RPC_URL)
const signer = WALLET_SEED
? ethers.Wallet.fromPhrase(WALLET_SEED, provider)
: new LedgerSigner(HIDTransport, provider)
const ie = new ethers
.Contract(SparkImpactEvaluator.ADDRESS, SparkImpactEvaluator.ABI, provider)
.connect(signer)

const rawRewardsRes = await fetch('https://spark-rewards.fly.dev/scheduled-rewards')
const rawRewards = await rawRewardsRes.json()
const rewards = Object.entries(rawRewards)
Expand All @@ -44,6 +36,14 @@ if (!/^y(es)?$/.test(answer)) {
process.exit(1)
}

const provider = new ethers.JsonRpcProvider(RPC_URL)
const signer = WALLET_SEED
? ethers.Wallet.fromPhrase(WALLET_SEED, provider)
: new LedgerSigner(HIDTransport, provider)
const ie = new ethers
.Contract(SparkImpactEvaluator.ADDRESS, SparkImpactEvaluator.ABI, provider)
.connect(signer)

const addresses = rewards.map(({ address }) => address)
const amounts = rewards.map(({ amount }) => amount)
const batchSize = 1000
Expand Down

0 comments on commit a16e6c3

Please sign in to comment.