Skip to content

Instantly share code, notes, and snippets.

@shogochiai
Last active February 7, 2024 02:27
Show Gist options
  • Save shogochiai/fc636df8c13be967f37884acf8e8f6f3 to your computer and use it in GitHub Desktop.
Save shogochiai/fc636df8c13be967f37884acf8e8f6f3 to your computer and use it in GitHub Desktop.
// Sample implementation of voting for forked options (RCV) is here
// https://github.com/shogochiai/erc7546ucs-tdd-example/blob/master/src/BordaVoteForForksOp.sol
// i.e., headers and cmds are forkable RCV voting target in this document.
■ headers and cmds for TallyVotesOp
# Relations
proposal initially has a header
proposal can have many headers
proposal can have many cmds
# Types
Header is Forkable {
uint id;
bytes32 metadataURI;
uint[] tagIds;
}
Tag {
uint id;
bytes32 metadataURI;
}
Command is Forkable
Command {
uint id;
Action[] actions;
}
Action {
address addr;
string func;
bytes abiParams;
}
■ TxtSavePassOp
# Amazingly simple contract
contract TxtSavePassOp {
function txtSave(uint pid, uint txtId, bytes32[] metadataURIs) public onlyPassed(pid) {
txts[txtId] = metadataURIs;
}
}
# Sample Tx Composition
// Must be JS, but written in Solidity...
Command memory cmd;
cmd.id = $.newCommandId();
Action memory act;
act.addr = TXT_SAVE_OP_ADDR;
/*
// calldata is like
bytes.concat(
bytes4(keccak256(act.actions[i].func)),
_abiParams.actions[i].abiParams
)
*/
act.func = "txtSave(uint256, uint256, bytes32[])";
act.abiParams = abi.encode(pid, $.newTxtId(), [cid1, cid2]);
act.actions[0] = act;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment