Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic IdentityUpdates contract #154

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
// Instructions from https://github.com/segmentio/golines
"emeraldwalk.runonsave": {
"shell": "bash",
"commands": [
{
"match": "\\.go$",
Expand Down
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
Loading