Skip to content

Commit

Permalink
Add basic IdentityUpdates contract
Browse files Browse the repository at this point in the history
  • Loading branch information
neekolas committed Sep 11, 2024
1 parent b5409cf commit 2d3ba8f
Show file tree
Hide file tree
Showing 8 changed files with 408 additions and 12 deletions.
18 changes: 18 additions & 0 deletions contracts/src/IdentityUpdates.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

contract IdentityUpdates {
event IdentityUpdateCreated(
bytes32 inboxId,
bytes update,
uint64 sequenceId
);

uint64 sequenceId;

function addIdentityUpdate(bytes32 inboxId, bytes memory update) public {
sequenceId++;

emit IdentityUpdateCreated(inboxId, update, sequenceId);
}
}
25 changes: 25 additions & 0 deletions contracts/test/IdentityUpdates.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Test, console} from "forge-std/Test.sol";
import {IdentityUpdates} from "../src/IdentityUpdates.sol";

contract IdentityUpdatesTest is Test {
IdentityUpdates public identityUpdates;

function setUp() public {
identityUpdates = new IdentityUpdates();
}

function test_AddIdentityUpdate1k() public {
bytes32 inboxId = bytes32(
0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
);
bytes memory message = new bytes(1024);
for (uint256 i = 0; i < message.length; i++) {
message[i] = bytes1(uint8(i % 256)); // Set each byte to its index modulo 256
}

identityUpdates.addIdentityUpdate(inboxId, message);
}
}
4 changes: 3 additions & 1 deletion dev/abigen
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ cd contracts
mkdir -p ../build
forge inspect ./src/Nodes.sol:Nodes abi > ../build/Nodes.abi.json
forge inspect ./src/GroupMessages.sol:GroupMessages abi > ../build/GroupMessages.abi.json
forge inspect ./src/IdentityUpdates.sol:IdentityUpdates abi > ../build/IdentityUpdates.abi.json

cd ..
# Generate Go code out of the ABI files
abigen --abi ./build/Nodes.abi.json --pkg abis --type Nodes --out ./pkg/abis/nodes.go
abigen --abi ./build/GroupMessages.abi.json --pkg abis --type GroupMessages --out ./pkg/abis/groupMessages.go
abigen --abi ./build/GroupMessages.abi.json --pkg abis --type GroupMessages --out ./pkg/abis/groupMessages.go
abigen --abi ./build/IdentityUpdates.abi.json --pkg abis --type IdentityUpdates --out ./pkg/abis/identityUpdates.go
3 changes: 2 additions & 1 deletion dev/contracts/deploy-local
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ function deploy_contract() {
}

deploy_contract src/GroupMessages.sol GroupMessages
deploy_contract src/Nodes.sol Nodes
deploy_contract src/Nodes.sol Nodes
deploy_contract src/IdentityUpdates.sol IdentityUpdates
Loading

0 comments on commit 2d3ba8f

Please sign in to comment.