-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow multiple axiom input structs (#4)
- Loading branch information
Showing
8 changed files
with
192 additions
and
92 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
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
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
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
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
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,40 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import "../src/AxiomTest.sol"; | ||
|
||
contract ArrayTest is AxiomTest { | ||
using Axiom for Query; | ||
|
||
struct AxiomInput { | ||
uint64[] blockNumbers; | ||
uint256[] slots; | ||
address _address; | ||
} | ||
|
||
AxiomInput public input; | ||
bytes32 public querySchema; | ||
|
||
function setUp() public { | ||
_createSelectForkAndSetupAxiom("sepolia", 5_103_100); | ||
|
||
uint64[] memory blockNumbers = new uint64[](3); | ||
uint256[] memory slots = new uint256[](3); | ||
for (uint256 i = 0; i < 3; i++) { | ||
blockNumbers[i] = 4_205_938; | ||
slots[i] = i; | ||
} | ||
input = AxiomInput({ blockNumbers: blockNumbers, slots: slots, _address: address(0x8018fe32fCFd3d166E8b4c4E37105318A84BA11b)}); | ||
|
||
querySchema = axiomVm.readCircuit("test/circuit/array.circuit.ts"); | ||
} | ||
|
||
/// @dev Simple demonstration of testing an Axiom client contract using Axiom cheatcodes | ||
function test_simple_example() public { | ||
// create a query into Axiom with default parameters | ||
Query memory q = query(querySchema, abi.encode(input), address(0x8018fe32fCFd3d166E8b4c4E37105318A84BA11b)); | ||
|
||
// send the query to Axiom | ||
q.send(); | ||
} | ||
} |
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,32 @@ | ||
import { | ||
add, | ||
sub, | ||
mul, | ||
div, | ||
checkLessThan, | ||
addToCallback, | ||
CircuitValue, | ||
CircuitValue256, | ||
constant, | ||
witness, | ||
getAccount, | ||
sum | ||
} from "@axiom-crypto/client"; | ||
|
||
export interface CircuitInputs { | ||
blockNumbers: CircuitValue[]; | ||
slots: CircuitValue256[]; | ||
address: CircuitValue; | ||
} | ||
|
||
/// Default inputs used for compilation. | ||
export const defaultInputs = { | ||
"blockNumbers": [4205938, 4205938, 4205938], | ||
"slots": [1, 2, 3], | ||
"address": "0x8018fe32fCFd3d166E8b4c4E37105318A84BA11c" | ||
} | ||
|
||
export const circuit = async (inputs: CircuitInputs) => { | ||
sum(inputs.blockNumbers); | ||
addToCallback(inputs.address); | ||
}; |
Oops, something went wrong.