|
| 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 |
|
9 | 9 | const DRAND_SERVICE_URL = "https://api.drand.sh/v2/beacons/evmnet" |
10 | 10 |
|
@@ -99,14 +99,16 @@ async function onNewBlock(block: Block<bigint, false, "latest">) { |
99 | 99 |
|
100 | 100 | const drandRandomness = await getDrandRandomnessForRound(expectedDrandRound) |
101 | 101 |
|
102 | | - const revealedValueForBlock = await client.readContract({ |
103 | | - address: RANDOMNESS_CONTRACT_ADDRESS, |
104 | | - abi: RANDOMNESS_CONTRACT_ABI, |
105 | | - functionName: "getRevealedValue", |
106 | | - args: [block.number], |
107 | | - }).catch((error) => { |
108 | | - console.error("Error reading revealed value", error) |
109 | | - }) |
| 102 | + const revealedValueForBlock = await client |
| 103 | + .readContract({ |
| 104 | + address: RANDOMNESS_CONTRACT_ADDRESS, |
| 105 | + abi: RANDOMNESS_CONTRACT_ABI, |
| 106 | + functionName: "getRevealedValue", |
| 107 | + args: [block.number], |
| 108 | + }) |
| 109 | + .catch((error) => { |
| 110 | + console.error("Error reading revealed value", error) |
| 111 | + }) |
110 | 112 |
|
111 | 113 | if (!revealedValueForBlock) { |
112 | 114 | return |
|
0 commit comments