|
| 1 | +import { abis, deployment } from "@happy.tech/contracts/random/anvil" |
1 | 2 | import { http, type Block, type Hex, createPublicClient, encodeAbiParameters, encodePacked, keccak256 } from "viem" |
2 | 3 | import { anvil } from "viem/chains" |
3 | 4 | import { z } from "zod" |
4 | | -import { abis, deployment } from "@happy.tech/contracts/random/anvil" |
5 | 5 |
|
6 | 6 | const RANDOMNESS_CONTRACT_ABI = abis.Random |
7 | | -const RANDOMNESS_CONTRACT_ADDRESS = deployment.Random; |
| 7 | +const RANDOMNESS_CONTRACT_ADDRESS = deployment.Random |
8 | 8 | const DRAND_SERVICE_URL = "https://api.drand.sh/v2/beacons/evmnet" |
9 | 9 |
|
10 | 10 | const client = createPublicClient({ |
@@ -98,14 +98,16 @@ async function onNewBlock(block: Block<bigint, false, "latest">) { |
98 | 98 |
|
99 | 99 | const drandRandomness = await getDrandRandomnessForRound(expectedDrandRound) |
100 | 100 |
|
101 | | - const revealedValueForBlock = await client.readContract({ |
102 | | - address: RANDOMNESS_CONTRACT_ADDRESS, |
103 | | - abi: RANDOMNESS_CONTRACT_ABI, |
104 | | - functionName: "getRevealedValue", |
105 | | - args: [block.number], |
106 | | - }).catch((error) => { |
107 | | - console.error("Error reading revealed value", error) |
108 | | - }) |
| 101 | + const revealedValueForBlock = await client |
| 102 | + .readContract({ |
| 103 | + address: RANDOMNESS_CONTRACT_ADDRESS, |
| 104 | + abi: RANDOMNESS_CONTRACT_ABI, |
| 105 | + functionName: "getRevealedValue", |
| 106 | + args: [block.number], |
| 107 | + }) |
| 108 | + .catch((error) => { |
| 109 | + console.error("Error reading revealed value", error) |
| 110 | + }) |
109 | 111 |
|
110 | 112 | if (!revealedValueForBlock) { |
111 | 113 | return |
|
0 commit comments