-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathswapEvent.circuit.ts
46 lines (39 loc) · 1.37 KB
/
swapEvent.circuit.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import {
addToCallback,
CircuitValue,
CircuitValue256,
constant,
witness,
getReceipt,
getTx,
} from "@axiom-crypto/client";
/// For type safety, define the input types to your circuit here.
/// These should be the _variable_ inputs to your circuit. Constants can be hard-coded into the circuit itself.
export interface CircuitInputs {
blockNumber: CircuitValue;
txIdx: CircuitValue;
logIdx: CircuitValue;
}
/// Inputs used for compiling the circuit
export const defaultInputs = {
"blockNumber": 5130226,
"txIdx": 40,
"logIdx": 2
};
// The function name `circuit` is searched for by default by our Axiom CLI; if you decide to
// change the function name, you'll also need to ensure that you also pass the Axiom CLI flag
// `-f <circuitFunctionName>` for it to work
export const circuit = async (inputs: CircuitInputs) => {
const eventSchema =
"0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67";
// specify and fetch the data you want Axiom to verify
const receipt = getReceipt(inputs.blockNumber, inputs.txIdx);
const receiptLog = receipt.log(inputs.logIdx);
// get the topic at index 2
const swapTo = await receiptLog.topic(2, eventSchema);
// get the `address` field of the receipt log
const receiptAddr = await receiptLog.address();
addToCallback(swapTo);
addToCallback(inputs.blockNumber);
addToCallback(receiptAddr);
};