-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use anvil for local rewards distribution script (#49)
- Loading branch information
1 parent
6396040
commit 83b361d
Showing
6 changed files
with
177 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.25; | ||
|
||
import "forge-std/Script.sol"; | ||
import {MockFOXToken} from "../test/utils/MockFOXToken.sol"; | ||
|
||
contract DeployMockFoxToken is Script { | ||
function run() public { | ||
vm.startBroadcast(); | ||
MockFOXToken mockFoxToken = new MockFOXToken(); | ||
vm.stopBroadcast(); | ||
|
||
console.log("Contract deployed at:", address(mockFoxToken)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
import { createPublicClient, createWalletClient, http } from "viem"; | ||
import { privateKeyToAccount } from "viem/accounts"; | ||
import { localhost } from "viem/chains"; | ||
|
||
const ANVIL_JSON_RPC_URL = "http://127.0.0.1:8545"; | ||
|
||
export const localChain = { | ||
...localhost, | ||
id: 31337, | ||
} as const; | ||
|
||
export const localWalletClient = createWalletClient({ | ||
export const localOwnerWalletClient = createWalletClient({ | ||
chain: localChain, | ||
account: privateKeyToAccount(process.env.OWNER_PRIVATE_KEY as `0x${string}`), | ||
transport: http(process.env.ANVIL_JSON_RPC_URL), | ||
}); | ||
|
||
export const localUserWalletClient = createWalletClient({ | ||
chain: localChain, | ||
transport: http(ANVIL_JSON_RPC_URL), | ||
account: privateKeyToAccount(process.env.USER_PRIVATE_KEY as `0x${string}`), | ||
transport: http(process.env.ANVIL_JSON_RPC_URL), | ||
}); | ||
|
||
export const localPublicClient = createPublicClient({ | ||
chain: localChain, | ||
transport: http(ANVIL_JSON_RPC_URL), | ||
transport: http(process.env.ANVIL_JSON_RPC_URL), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,52 @@ | ||
import { AbiEvent, Address, Log, parseEventLogs } from "viem"; | ||
import { Log, getAbiItem } from "viem"; | ||
import { stakingV1Abi } from "./generated/abi-types"; | ||
|
||
type StakingEventName = "Stake" | "Unstake"; | ||
export const stakeEvent = getAbiItem({ abi: stakingV1Abi, name: "Stake" }); | ||
export const unstakeEvent = getAbiItem({ abi: stakingV1Abi, name: "Unstake" }); | ||
export const updateCooldownPeriodEvent = getAbiItem({ | ||
abi: stakingV1Abi, | ||
name: "UpdateCooldownPeriod", | ||
}); | ||
export const withdrawEvent = getAbiItem({ | ||
abi: stakingV1Abi, | ||
name: "Withdraw", | ||
}); | ||
export const setRuneAddressEvent = getAbiItem({ | ||
abi: stakingV1Abi, | ||
name: "SetRuneAddress", | ||
}); | ||
|
||
type StakingAbiEvent<T extends StakingEventName> = { | ||
type: "event"; | ||
anonymous: false; | ||
inputs: [ | ||
{ | ||
name: "account"; | ||
type: "address"; | ||
indexed: true; | ||
}, | ||
{ | ||
name: "amount"; | ||
type: "uint256"; | ||
indexed: false; | ||
}, | ||
// TOOD(gomes): if runeAddress is part of the staking fn, then it should be part of the Stake event too and should be reflected here | ||
]; | ||
name: T; | ||
}; | ||
export const rFoxEvents = [ | ||
stakeEvent, | ||
unstakeEvent, | ||
updateCooldownPeriodEvent, | ||
withdrawEvent, | ||
setRuneAddressEvent, | ||
] as const; | ||
|
||
type GenericStakingEventLog<T extends StakingEventName> = Log< | ||
export type RFoxEvent = (typeof rFoxEvents)[number]; | ||
|
||
export type StakeLog = Log<bigint, number, false, typeof stakeEvent, true>; | ||
export type UnstakeLog = Log<bigint, number, false, typeof unstakeEvent, true>; | ||
export type UpdateCooldownPeriodLog = Log< | ||
bigint, | ||
number, | ||
false, | ||
AbiEvent, | ||
true, | ||
StakingAbiEvent<T>[], | ||
T | ||
typeof updateCooldownPeriodEvent, | ||
true | ||
>; | ||
|
||
// explicit union of all possible event logs to ensure event args are correctly parsed by ts (fixes defaulting to unknown) | ||
export type StakingEventLog = | ||
| GenericStakingEventLog<"Stake"> | ||
| GenericStakingEventLog<"Unstake">; | ||
|
||
const addressA: Address = "0xA"; | ||
const addressB: Address = "0xB"; | ||
const addressC: Address = "0xC"; | ||
const addressD: Address = "0xD"; | ||
const addressE: Address = "0xE"; | ||
|
||
export type StakingLog = Pick< | ||
StakingEventLog, | ||
"blockNumber" | "eventName" | "args" | ||
export type WithdrawLog = Log<bigint, number, false, typeof withdrawEvent>; | ||
export type SetRuneAddressLog = Log< | ||
bigint, | ||
number, | ||
false, | ||
typeof setRuneAddressEvent, | ||
true | ||
>; | ||
|
||
export const logs: StakingLog[] = [ | ||
{ | ||
blockNumber: 20n, | ||
eventName: "Stake", | ||
args: { account: addressA, amount: 100n }, | ||
}, | ||
{ | ||
blockNumber: 25n, | ||
eventName: "Stake", | ||
args: { account: addressB, amount: 150n }, | ||
}, | ||
{ | ||
blockNumber: 32n, | ||
eventName: "Stake", | ||
args: { account: addressC, amount: 10000n }, | ||
}, | ||
{ | ||
blockNumber: 33n, | ||
eventName: "Stake", | ||
args: { account: addressD, amount: 1200n }, | ||
}, | ||
{ | ||
blockNumber: 60n, | ||
eventName: "Unstake", | ||
args: { account: addressA, amount: 100n }, | ||
}, | ||
{ | ||
blockNumber: 65n, | ||
eventName: "Stake", | ||
args: { account: addressE, amount: 500n }, | ||
}, | ||
]; | ||
export type RFoxLog = | ||
| StakeLog | ||
| UnstakeLog | ||
| UpdateCooldownPeriodLog | ||
| WithdrawLog | ||
| SetRuneAddressLog; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.