Skip to content

Commit

Permalink
finalize
Browse files Browse the repository at this point in the history
  • Loading branch information
kaladinlight committed Jul 15, 2024
1 parent 9817100 commit ae883c8
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 2,005 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,3 @@ jobs:
with:
node-version-file: .nvmrc
cache: yarn

- name: Install Dependencies
id: install
run: |
yarn
cd scripts/rewards-distribution
yarn
- name: Run Typescript tests
id: test
run: |
cd scripts/rewards-distribution
yarn test
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@ Please check out the [wiki](https://github.com/shapeshift/rFOX/wiki/rFOX) for mo
### CLI dev

- Run foundry's anvil with `anvil`
- Rewards distribution can be tested locally with `ts-node scripts/rewards-distribution/index.ts`
- Rewards distribution script can be debugged locally with `cd scripts/rewards-distribution` and `NODE_OPTIONS="-r ts-node/register" node --inspect-brk index.ts` then going to `chrome://inspect` in Chrome to open the Node.JS debugging tools
- Ensure you CTRL + C anvil and restart it between run to clear your local blockchain state
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"typescript": "^5.4.5"
},
"scripts": {
"build": "forge build --root foundry && cd scripts/rewards-distribution && yarn && yarn wagmi generate",
"build": "forge build --root foundry && cd scripts/hotWalletCli && yarn && yarn generate",
"lint:sol": "npx prettier --write --plugin=prettier-plugin-solidity foundry/src/**/*.sol foundry/test/**/*.t.sol"
},
"simple-git-hooks": {
Expand Down
12 changes: 3 additions & 9 deletions scripts/hotWalletCli/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import BigNumber from 'bignumber.js'
import ora, { Ora } from 'ora'
import { Address, PublicClient, createPublicClient, getAddress, getContract, http } from 'viem'
import { arbitrum } from 'viem/chains'
import { stakingV1Abi } from './abi'
import { RFOX_REWARD_RATE, RFOX_WAD } from './constants'
import { stakingV1Abi } from './generated/abi'
import { error, info, warn } from './logging'
import { RewardDistribution } from './types'
import { RFOX_REWARD_RATE, RFOX_WAD } from './constants'

const INFURA_API_KEY = process.env['INFURA_API_KEY']

Expand All @@ -34,15 +34,9 @@ type ClosingStateByStakingAddress = Record<string, ClosingState>

export class Client {
private rpc: PublicClient
private archiveRpc: PublicClient

constructor() {
this.rpc = createPublicClient({
chain: arbitrum,
transport: http('https://api.arbitrum.shapeshift.com/api/v1/jsonrpc'),
})

this.archiveRpc = createPublicClient({
chain: arbitrum,
transport: http(`https://arbitrum-mainnet.infura.io/v3/${INFURA_API_KEY}`),
})
Expand Down Expand Up @@ -147,7 +141,7 @@ export class Client {
const contract = getContract({
address: ARBITRUM_RFOX_PROXY_CONTRACT_ADDRESS,
abi: stakingV1Abi,
client: { public: this.archiveRpc },
client: { public: this.rpc },
})

const prevEpochEndBlock = startBlock - 1n
Expand Down
5 changes: 1 addition & 4 deletions scripts/hotWalletCli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"clean": "rm -rf node_modules",
"generate": "yarn wagmi generate",
"start": "yarn generate && tsx index.ts"
"start": "tsx index.ts"
},
"dependencies": {
"@inquirer/core": "^8.2.2",
Expand All @@ -29,11 +29,8 @@
"viem": "^2.17.3"
},
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/node": "^20.12.4",
"@wagmi/cli": "^2.1.15",
"jest": "^29.7.0",
"ts-jest": "^29.2.2",
"tsx": "^4.15.6",
"typescript": "^5.4.4"
}
Expand Down
1 change: 1 addition & 0 deletions scripts/hotWalletCli/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ export class Wallet {
txsByStakingAddress[stakingAddress].txId = data.result.hash
epoch.distributionsByStakingAddress[stakingAddress].txId = data.result.hash

// wait for transaction to confirm before broadcasting next transaction (this ensures sequence is incremented before subsequent broadcast)
await new Promise(resolve => setTimeout(resolve, 1_000))
}
} catch (err) {
Expand Down
Loading

0 comments on commit ae883c8

Please sign in to comment.