diff --git a/bun.lockb b/bun.lockb index 064d89247c..60932c607b 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/contracts/Makefile b/contracts/Makefile index 6bc2e25129..8d899b8615 100755 --- a/contracts/Makefile +++ b/contracts/Makefile @@ -47,9 +47,11 @@ setup: ln $(LN_FLAGS) ../$(NODE_MODULES)/solady lib/solady ln $(LN_FLAGS) ../$(NODE_MODULES)/kernel lib/kernel ln $(LN_FLAGS) ../$(NODE_MODULES)/forge-std lib/forge-std + ln $(LN_FLAGS) ../$(NODE_MODULES)/@kevincharm/bls-bn254 lib/bls-bn254 ln $(LN_FLAGS) ../$(NODE_MODULES)/account-abstraction lib/account-abstraction ln $(LN_FLAGS) ../../$(NODE_MODULES)/@openzeppelin/contracts lib/openzeppelin/src ln $(LN_FLAGS) ../../$(NODE_MODULES)/@openzeppelin/contracts-upgradeable lib/oz-upgradeable/src + .PHONY: setup #################################################################################################### diff --git a/contracts/deployments/anvil/random/abis.json b/contracts/deployments/anvil/random/abis.json index 0420b5fbbf..98b6473587 100644 --- a/contracts/deployments/anvil/random/abis.json +++ b/contracts/deployments/anvil/random/abis.json @@ -2,12 +2,28 @@ "Random": [ { "type": "constructor", - "inputs": [], + "inputs": [ + { + "name": "_publicKey", + "type": "uint256[4]", + "internalType": "uint256[4]" + }, + { + "name": "_genesisTimestamp", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_period", + "type": "uint256", + "internalType": "uint256" + } + ], "stateMutability": "nonpayable" }, { "type": "function", - "name": "BLOCK_TIME", + "name": "DRAND_DELAY", "inputs": [], "outputs": [ { @@ -18,6 +34,19 @@ ], "stateMutability": "view" }, + { + "type": "function", + "name": "DST", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes", + "internalType": "bytes" + } + ], + "stateMutability": "view" + }, { "type": "function", "name": "PRECOMMIT_DELAY", @@ -31,9 +60,41 @@ ], "stateMutability": "view" }, + { + "type": "function", + "name": "genesisTimestamp", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, { "type": "function", "name": "getRevealedValue", + "inputs": [ + { + "name": "blockNumber", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "nextValidTimestamp", "inputs": [ { "name": "timestamp", @@ -63,12 +124,25 @@ ], "stateMutability": "view" }, + { + "type": "function", + "name": "period", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, { "type": "function", "name": "postCommitment", "inputs": [ { - "name": "timestamp", + "name": "blockNumber", "type": "uint256", "internalType": "uint256" }, @@ -81,6 +155,94 @@ "outputs": [], "stateMutability": "nonpayable" }, + { + "type": "function", + "name": "postDrand", + "inputs": [ + { + "name": "round", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "signature", + "type": "uint256[2]", + "internalType": "uint256[2]" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "publicKey", + "inputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "random", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "randomForTimestamp", + "inputs": [ + { + "name": "timestamp", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "randomness", + "inputs": [ + { + "name": "round", + "type": "uint64", + "internalType": "uint64" + } + ], + "outputs": [ + { + "name": "randomness", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, { "type": "function", "name": "renounceOwnership", @@ -93,7 +255,7 @@ "name": "revealValue", "inputs": [ { - "name": "timestamp", + "name": "blockNumber", "type": "uint256", "internalType": "uint256" }, @@ -124,7 +286,7 @@ "name": "unsafeGetRevealedValue", "inputs": [ { - "name": "timestamp", + "name": "blockNumber", "type": "uint256", "internalType": "uint256" } @@ -143,7 +305,7 @@ "name": "CommitmentPosted", "inputs": [ { - "name": "timestamp", + "name": "blockNumber", "type": "uint256", "indexed": true, "internalType": "uint256" @@ -181,7 +343,7 @@ "name": "ValueRevealed", "inputs": [ { - "name": "timestamp", + "name": "blockNumber", "type": "uint256", "indexed": true, "internalType": "uint256" @@ -195,6 +357,17 @@ ], "anonymous": false }, + { + "type": "error", + "name": "BNAddFailed", + "inputs": [ + { + "name": "input", + "type": "uint256[4]", + "internalType": "uint256[4]" + } + ] + }, { "type": "error", "name": "CommitmentAlreadyExists", @@ -205,11 +378,108 @@ "name": "CommitmentTooLate", "inputs": [] }, + { + "type": "error", + "name": "DrandNotAvailable", + "inputs": [ + { + "name": "round", + "type": "uint64", + "internalType": "uint64" + } + ] + }, + { + "type": "error", + "name": "InvalidDSTLength", + "inputs": [ + { + "name": "dst", + "type": "bytes", + "internalType": "bytes" + } + ] + }, + { + "type": "error", + "name": "InvalidFieldElement", + "inputs": [ + { + "name": "x", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InvalidPublicKey", + "inputs": [ + { + "name": "publicKey", + "type": "uint256[4]", + "internalType": "uint256[4]" + } + ] + }, { "type": "error", "name": "InvalidReveal", "inputs": [] }, + { + "type": "error", + "name": "InvalidSignature", + "inputs": [ + { + "name": "publicKey", + "type": "uint256[4]", + "internalType": "uint256[4]" + }, + { + "name": "message", + "type": "uint256[2]", + "internalType": "uint256[2]" + }, + { + "name": "signature", + "type": "uint256[2]", + "internalType": "uint256[2]" + } + ] + }, + { + "type": "error", + "name": "MapToPointFailed", + "inputs": [ + { + "name": "noSqrt", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "ModExpFailed", + "inputs": [ + { + "name": "base", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "exponent", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "modulus", + "type": "uint256", + "internalType": "uint256" + } + ] + }, { "type": "error", "name": "NoCommitmentFound", diff --git a/contracts/deployments/anvil/random/abis.ts b/contracts/deployments/anvil/random/abis.ts index 43869df739..48835e8f78 100644 --- a/contracts/deployments/anvil/random/abis.ts +++ b/contracts/deployments/anvil/random/abis.ts @@ -2,16 +2,33 @@ import type { MapTuple, ObjectFromTuples, UnionToTuple } from "@happy.tech/common" import type { Address } from "viem" + const contractToAbi = ({ "Random": [ { "type": "constructor", - "inputs": [], + "inputs": [ + { + "name": "_publicKey", + "type": "uint256[4]", + "internalType": "uint256[4]" + }, + { + "name": "_genesisTimestamp", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_period", + "type": "uint256", + "internalType": "uint256" + } + ], "stateMutability": "nonpayable" }, { "type": "function", - "name": "BLOCK_TIME", + "name": "DRAND_DELAY", "inputs": [], "outputs": [ { @@ -22,6 +39,19 @@ const contractToAbi = ({ ], "stateMutability": "view" }, + { + "type": "function", + "name": "DST", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes", + "internalType": "bytes" + } + ], + "stateMutability": "view" + }, { "type": "function", "name": "PRECOMMIT_DELAY", @@ -35,9 +65,41 @@ const contractToAbi = ({ ], "stateMutability": "view" }, + { + "type": "function", + "name": "genesisTimestamp", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, { "type": "function", "name": "getRevealedValue", + "inputs": [ + { + "name": "blockNumber", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "nextValidTimestamp", "inputs": [ { "name": "timestamp", @@ -67,12 +129,25 @@ const contractToAbi = ({ ], "stateMutability": "view" }, + { + "type": "function", + "name": "period", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, { "type": "function", "name": "postCommitment", "inputs": [ { - "name": "timestamp", + "name": "blockNumber", "type": "uint256", "internalType": "uint256" }, @@ -85,6 +160,94 @@ const contractToAbi = ({ "outputs": [], "stateMutability": "nonpayable" }, + { + "type": "function", + "name": "postDrand", + "inputs": [ + { + "name": "round", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "signature", + "type": "uint256[2]", + "internalType": "uint256[2]" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "publicKey", + "inputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "random", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "randomForTimestamp", + "inputs": [ + { + "name": "timestamp", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "randomness", + "inputs": [ + { + "name": "round", + "type": "uint64", + "internalType": "uint64" + } + ], + "outputs": [ + { + "name": "randomness", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, { "type": "function", "name": "renounceOwnership", @@ -97,7 +260,7 @@ const contractToAbi = ({ "name": "revealValue", "inputs": [ { - "name": "timestamp", + "name": "blockNumber", "type": "uint256", "internalType": "uint256" }, @@ -128,7 +291,7 @@ const contractToAbi = ({ "name": "unsafeGetRevealedValue", "inputs": [ { - "name": "timestamp", + "name": "blockNumber", "type": "uint256", "internalType": "uint256" } @@ -147,7 +310,7 @@ const contractToAbi = ({ "name": "CommitmentPosted", "inputs": [ { - "name": "timestamp", + "name": "blockNumber", "type": "uint256", "indexed": true, "internalType": "uint256" @@ -185,7 +348,7 @@ const contractToAbi = ({ "name": "ValueRevealed", "inputs": [ { - "name": "timestamp", + "name": "blockNumber", "type": "uint256", "indexed": true, "internalType": "uint256" @@ -199,6 +362,17 @@ const contractToAbi = ({ ], "anonymous": false }, + { + "type": "error", + "name": "BNAddFailed", + "inputs": [ + { + "name": "input", + "type": "uint256[4]", + "internalType": "uint256[4]" + } + ] + }, { "type": "error", "name": "CommitmentAlreadyExists", @@ -209,11 +383,108 @@ const contractToAbi = ({ "name": "CommitmentTooLate", "inputs": [] }, + { + "type": "error", + "name": "DrandNotAvailable", + "inputs": [ + { + "name": "round", + "type": "uint64", + "internalType": "uint64" + } + ] + }, + { + "type": "error", + "name": "InvalidDSTLength", + "inputs": [ + { + "name": "dst", + "type": "bytes", + "internalType": "bytes" + } + ] + }, + { + "type": "error", + "name": "InvalidFieldElement", + "inputs": [ + { + "name": "x", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InvalidPublicKey", + "inputs": [ + { + "name": "publicKey", + "type": "uint256[4]", + "internalType": "uint256[4]" + } + ] + }, { "type": "error", "name": "InvalidReveal", "inputs": [] }, + { + "type": "error", + "name": "InvalidSignature", + "inputs": [ + { + "name": "publicKey", + "type": "uint256[4]", + "internalType": "uint256[4]" + }, + { + "name": "message", + "type": "uint256[2]", + "internalType": "uint256[2]" + }, + { + "name": "signature", + "type": "uint256[2]", + "internalType": "uint256[2]" + } + ] + }, + { + "type": "error", + "name": "MapToPointFailed", + "inputs": [ + { + "name": "noSqrt", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "ModExpFailed", + "inputs": [ + { + "name": "base", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "exponent", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "modulus", + "type": "uint256", + "internalType": "uint256" + } + ] + }, { "type": "error", "name": "NoCommitmentFound", @@ -260,7 +531,7 @@ const aliasToContract = ({ }) as const export const deployment = ({ - "Random": "0x51745e910FaD45A6cA620bCc7a7fAB7683B142e5" + "Random": "0x9ACE2eE177EB91eEed9591ea50Cb903d551DD0f9" }) as const export type ContractToAbi = typeof contractToAbi @@ -281,3 +552,4 @@ for (const [alias, contractName] of Object.entries(aliasToContract)) { abis[alias as ContractAlias] = contractToAbi[contractName as ContractName] as any } + diff --git a/contracts/deployments/anvil/random/deployment.json b/contracts/deployments/anvil/random/deployment.json index 260d25ee58..6c2374d088 100644 --- a/contracts/deployments/anvil/random/deployment.json +++ b/contracts/deployments/anvil/random/deployment.json @@ -1,3 +1,3 @@ { - "Random": "0x51745e910FaD45A6cA620bCc7a7fAB7683B142e5" + "Random": "0x9ACE2eE177EB91eEed9591ea50Cb903d551DD0f9" } \ No newline at end of file diff --git a/contracts/deployments/happy-sepolia/random/abis.json b/contracts/deployments/happy-sepolia/random/abis.json index 0420b5fbbf..5bf845ec23 100644 --- a/contracts/deployments/happy-sepolia/random/abis.json +++ b/contracts/deployments/happy-sepolia/random/abis.json @@ -2,12 +2,38 @@ "Random": [ { "type": "constructor", - "inputs": [], + "inputs": [ + { + "name": "_publicKey", + "type": "uint256[4]", + "internalType": "uint256[4]" + }, + { + "name": "_genesisTimestamp", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_period", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_happyGenesisTimestamp", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_happyTimeBlock", + "type": "uint256", + "internalType": "uint256" + } + ], "stateMutability": "nonpayable" }, { "type": "function", - "name": "BLOCK_TIME", + "name": "DRAND_DELAY", "inputs": [], "outputs": [ { @@ -18,6 +44,19 @@ ], "stateMutability": "view" }, + { + "type": "function", + "name": "DST", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes", + "internalType": "bytes" + } + ], + "stateMutability": "view" + }, { "type": "function", "name": "PRECOMMIT_DELAY", @@ -31,9 +70,156 @@ ], "stateMutability": "view" }, + { + "type": "function", + "name": "drandGenesisTimestamp", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "drandPeriod", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "drandPublicKey", + "inputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "drandRandomness", + "inputs": [ + { + "name": "round", + "type": "uint64", + "internalType": "uint64" + } + ], + "outputs": [ + { + "name": "randomness", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getDrand", + "inputs": [ + { + "name": "round", + "type": "uint64", + "internalType": "uint64" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, { "type": "function", "name": "getRevealedValue", + "inputs": [ + { + "name": "blockNumber", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "happyGenesisTimestamp", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "happyTimeBlock", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "nextValidBlock", + "inputs": [ + { + "name": "blockNumber", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "nextValidTimestamp", "inputs": [ { "name": "timestamp", @@ -68,7 +254,7 @@ "name": "postCommitment", "inputs": [ { - "name": "timestamp", + "name": "blockNumber", "type": "uint256", "internalType": "uint256" }, @@ -81,6 +267,75 @@ "outputs": [], "stateMutability": "nonpayable" }, + { + "type": "function", + "name": "postDrand", + "inputs": [ + { + "name": "round", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "signature", + "type": "uint256[2]", + "internalType": "uint256[2]" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "random", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "randomForBlock", + "inputs": [ + { + "name": "blockNumber", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "randomForTimestamp", + "inputs": [ + { + "name": "timestamp", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, { "type": "function", "name": "renounceOwnership", @@ -93,7 +348,7 @@ "name": "revealValue", "inputs": [ { - "name": "timestamp", + "name": "blockNumber", "type": "uint256", "internalType": "uint256" }, @@ -119,12 +374,31 @@ "outputs": [], "stateMutability": "nonpayable" }, + { + "type": "function", + "name": "unsafeGetDrand", + "inputs": [ + { + "name": "round", + "type": "uint64", + "internalType": "uint64" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, { "type": "function", "name": "unsafeGetRevealedValue", "inputs": [ { - "name": "timestamp", + "name": "blockNumber", "type": "uint256", "internalType": "uint256" } @@ -143,7 +417,7 @@ "name": "CommitmentPosted", "inputs": [ { - "name": "timestamp", + "name": "blockNumber", "type": "uint256", "indexed": true, "internalType": "uint256" @@ -157,6 +431,25 @@ ], "anonymous": false }, + { + "type": "event", + "name": "DrandRandomnessPosted", + "inputs": [ + { + "name": "round", + "type": "uint64", + "indexed": true, + "internalType": "uint64" + }, + { + "name": "randomness", + "type": "bytes32", + "indexed": false, + "internalType": "bytes32" + } + ], + "anonymous": false + }, { "type": "event", "name": "OwnershipTransferred", @@ -181,7 +474,7 @@ "name": "ValueRevealed", "inputs": [ { - "name": "timestamp", + "name": "blockNumber", "type": "uint256", "indexed": true, "internalType": "uint256" @@ -195,6 +488,17 @@ ], "anonymous": false }, + { + "type": "error", + "name": "BNAddFailed", + "inputs": [ + { + "name": "input", + "type": "uint256[4]", + "internalType": "uint256[4]" + } + ] + }, { "type": "error", "name": "CommitmentAlreadyExists", @@ -205,11 +509,108 @@ "name": "CommitmentTooLate", "inputs": [] }, + { + "type": "error", + "name": "DrandNotAvailable", + "inputs": [ + { + "name": "round", + "type": "uint64", + "internalType": "uint64" + } + ] + }, + { + "type": "error", + "name": "InvalidDSTLength", + "inputs": [ + { + "name": "dst", + "type": "bytes", + "internalType": "bytes" + } + ] + }, + { + "type": "error", + "name": "InvalidFieldElement", + "inputs": [ + { + "name": "x", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InvalidPublicKey", + "inputs": [ + { + "name": "publicKey", + "type": "uint256[4]", + "internalType": "uint256[4]" + } + ] + }, { "type": "error", "name": "InvalidReveal", "inputs": [] }, + { + "type": "error", + "name": "InvalidSignature", + "inputs": [ + { + "name": "publicKey", + "type": "uint256[4]", + "internalType": "uint256[4]" + }, + { + "name": "message", + "type": "uint256[2]", + "internalType": "uint256[2]" + }, + { + "name": "signature", + "type": "uint256[2]", + "internalType": "uint256[2]" + } + ] + }, + { + "type": "error", + "name": "MapToPointFailed", + "inputs": [ + { + "name": "noSqrt", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "ModExpFailed", + "inputs": [ + { + "name": "base", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "exponent", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "modulus", + "type": "uint256", + "internalType": "uint256" + } + ] + }, { "type": "error", "name": "NoCommitmentFound", diff --git a/contracts/deployments/happy-sepolia/random/abis.ts b/contracts/deployments/happy-sepolia/random/abis.ts index 43869df739..36b404276d 100644 --- a/contracts/deployments/happy-sepolia/random/abis.ts +++ b/contracts/deployments/happy-sepolia/random/abis.ts @@ -2,266 +2,666 @@ import type { MapTuple, ObjectFromTuples, UnionToTuple } from "@happy.tech/common" import type { Address } from "viem" -const contractToAbi = ({ - "Random": [ - { - "type": "constructor", - "inputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "BLOCK_TIME", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "PRECOMMIT_DELAY", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getRevealedValue", - "inputs": [ - { - "name": "timestamp", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "owner", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "postCommitment", - "inputs": [ - { - "name": "timestamp", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "commitmentHash", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "renounceOwnership", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "revealValue", - "inputs": [ - { - "name": "timestamp", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "revealedValue", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "transferOwnership", - "inputs": [ - { - "name": "newOwner", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "unsafeGetRevealedValue", - "inputs": [ - { - "name": "timestamp", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "event", - "name": "CommitmentPosted", - "inputs": [ - { - "name": "timestamp", - "type": "uint256", - "indexed": true, - "internalType": "uint256" - }, - { - "name": "commitment", - "type": "bytes32", - "indexed": false, - "internalType": "bytes32" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "OwnershipTransferred", - "inputs": [ - { - "name": "previousOwner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "newOwner", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ValueRevealed", - "inputs": [ - { - "name": "timestamp", - "type": "uint256", - "indexed": true, - "internalType": "uint256" - }, - { - "name": "revealedValue", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "error", - "name": "CommitmentAlreadyExists", - "inputs": [] - }, - { - "type": "error", - "name": "CommitmentTooLate", - "inputs": [] - }, - { - "type": "error", - "name": "InvalidReveal", - "inputs": [] - }, - { - "type": "error", - "name": "NoCommitmentFound", - "inputs": [] - }, - { - "type": "error", - "name": "OwnableInvalidOwner", - "inputs": [ - { - "name": "owner", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "OwnableUnauthorizedAccount", - "inputs": [ - { - "name": "account", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "RevealMustBeOnExactBlock", - "inputs": [] - }, - { - "type": "error", - "name": "RevealedValueNotAvailable", - "inputs": [] - } - ] -} -) as const +const contractToAbi = { + Random: [ + { + type: "constructor", + inputs: [ + { + name: "_publicKey", + type: "uint256[4]", + internalType: "uint256[4]", + }, + { + name: "_genesisTimestamp", + type: "uint256", + internalType: "uint256", + }, + { + name: "_period", + type: "uint256", + internalType: "uint256", + }, + { + name: "_happyGenesisTimestamp", + type: "uint256", + internalType: "uint256", + }, + { + name: "_happyTimeBlock", + type: "uint256", + internalType: "uint256", + }, + ], + stateMutability: "nonpayable", + }, + { + type: "function", + name: "DRAND_DELAY", + inputs: [], + outputs: [ + { + name: "", + type: "uint256", + internalType: "uint256", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "DST", + inputs: [], + outputs: [ + { + name: "", + type: "bytes", + internalType: "bytes", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "PRECOMMIT_DELAY", + inputs: [], + outputs: [ + { + name: "", + type: "uint256", + internalType: "uint256", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "drandGenesisTimestamp", + inputs: [], + outputs: [ + { + name: "", + type: "uint256", + internalType: "uint256", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "drandPeriod", + inputs: [], + outputs: [ + { + name: "", + type: "uint256", + internalType: "uint256", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "drandPublicKey", + inputs: [ + { + name: "", + type: "uint256", + internalType: "uint256", + }, + ], + outputs: [ + { + name: "", + type: "uint256", + internalType: "uint256", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "drandRandomness", + inputs: [ + { + name: "round", + type: "uint64", + internalType: "uint64", + }, + ], + outputs: [ + { + name: "randomness", + type: "bytes32", + internalType: "bytes32", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "getDrand", + inputs: [ + { + name: "round", + type: "uint64", + internalType: "uint64", + }, + ], + outputs: [ + { + name: "", + type: "bytes32", + internalType: "bytes32", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "getRevealedValue", + inputs: [ + { + name: "blockNumber", + type: "uint256", + internalType: "uint256", + }, + ], + outputs: [ + { + name: "", + type: "uint256", + internalType: "uint256", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "happyGenesisTimestamp", + inputs: [], + outputs: [ + { + name: "", + type: "uint256", + internalType: "uint256", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "happyTimeBlock", + inputs: [], + outputs: [ + { + name: "", + type: "uint256", + internalType: "uint256", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "nextValidBlock", + inputs: [ + { + name: "blockNumber", + type: "uint256", + internalType: "uint256", + }, + ], + outputs: [ + { + name: "", + type: "uint256", + internalType: "uint256", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "nextValidTimestamp", + inputs: [ + { + name: "timestamp", + type: "uint256", + internalType: "uint256", + }, + ], + outputs: [ + { + name: "", + type: "uint256", + internalType: "uint256", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "owner", + inputs: [], + outputs: [ + { + name: "", + type: "address", + internalType: "address", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "postCommitment", + inputs: [ + { + name: "blockNumber", + type: "uint256", + internalType: "uint256", + }, + { + name: "commitmentHash", + type: "bytes32", + internalType: "bytes32", + }, + ], + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + name: "postDrand", + inputs: [ + { + name: "round", + type: "uint64", + internalType: "uint64", + }, + { + name: "signature", + type: "uint256[2]", + internalType: "uint256[2]", + }, + ], + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + name: "random", + inputs: [], + outputs: [ + { + name: "", + type: "bytes32", + internalType: "bytes32", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "randomForBlock", + inputs: [ + { + name: "blockNumber", + type: "uint256", + internalType: "uint256", + }, + ], + outputs: [ + { + name: "", + type: "bytes32", + internalType: "bytes32", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "randomForTimestamp", + inputs: [ + { + name: "timestamp", + type: "uint256", + internalType: "uint256", + }, + ], + outputs: [ + { + name: "", + type: "bytes32", + internalType: "bytes32", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "renounceOwnership", + inputs: [], + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + name: "revealValue", + inputs: [ + { + name: "blockNumber", + type: "uint256", + internalType: "uint256", + }, + { + name: "revealedValue", + type: "uint256", + internalType: "uint256", + }, + ], + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + name: "transferOwnership", + inputs: [ + { + name: "newOwner", + type: "address", + internalType: "address", + }, + ], + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + name: "unsafeGetDrand", + inputs: [ + { + name: "round", + type: "uint64", + internalType: "uint64", + }, + ], + outputs: [ + { + name: "", + type: "bytes32", + internalType: "bytes32", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "unsafeGetRevealedValue", + inputs: [ + { + name: "blockNumber", + type: "uint256", + internalType: "uint256", + }, + ], + outputs: [ + { + name: "", + type: "uint256", + internalType: "uint256", + }, + ], + stateMutability: "view", + }, + { + type: "event", + name: "CommitmentPosted", + inputs: [ + { + name: "blockNumber", + type: "uint256", + indexed: true, + internalType: "uint256", + }, + { + name: "commitment", + type: "bytes32", + indexed: false, + internalType: "bytes32", + }, + ], + anonymous: false, + }, + { + type: "event", + name: "DrandRandomnessPosted", + inputs: [ + { + name: "round", + type: "uint64", + indexed: true, + internalType: "uint64", + }, + { + name: "randomness", + type: "bytes32", + indexed: false, + internalType: "bytes32", + }, + ], + anonymous: false, + }, + { + type: "event", + name: "OwnershipTransferred", + inputs: [ + { + name: "previousOwner", + type: "address", + indexed: true, + internalType: "address", + }, + { + name: "newOwner", + type: "address", + indexed: true, + internalType: "address", + }, + ], + anonymous: false, + }, + { + type: "event", + name: "ValueRevealed", + inputs: [ + { + name: "blockNumber", + type: "uint256", + indexed: true, + internalType: "uint256", + }, + { + name: "revealedValue", + type: "uint256", + indexed: false, + internalType: "uint256", + }, + ], + anonymous: false, + }, + { + type: "error", + name: "BNAddFailed", + inputs: [ + { + name: "input", + type: "uint256[4]", + internalType: "uint256[4]", + }, + ], + }, + { + type: "error", + name: "CommitmentAlreadyExists", + inputs: [], + }, + { + type: "error", + name: "CommitmentTooLate", + inputs: [], + }, + { + type: "error", + name: "DrandNotAvailable", + inputs: [ + { + name: "round", + type: "uint64", + internalType: "uint64", + }, + ], + }, + { + type: "error", + name: "InvalidDSTLength", + inputs: [ + { + name: "dst", + type: "bytes", + internalType: "bytes", + }, + ], + }, + { + type: "error", + name: "InvalidFieldElement", + inputs: [ + { + name: "x", + type: "uint256", + internalType: "uint256", + }, + ], + }, + { + type: "error", + name: "InvalidPublicKey", + inputs: [ + { + name: "publicKey", + type: "uint256[4]", + internalType: "uint256[4]", + }, + ], + }, + { + type: "error", + name: "InvalidReveal", + inputs: [], + }, + { + type: "error", + name: "InvalidSignature", + inputs: [ + { + name: "publicKey", + type: "uint256[4]", + internalType: "uint256[4]", + }, + { + name: "message", + type: "uint256[2]", + internalType: "uint256[2]", + }, + { + name: "signature", + type: "uint256[2]", + internalType: "uint256[2]", + }, + ], + }, + { + type: "error", + name: "MapToPointFailed", + inputs: [ + { + name: "noSqrt", + type: "uint256", + internalType: "uint256", + }, + ], + }, + { + type: "error", + name: "ModExpFailed", + inputs: [ + { + name: "base", + type: "uint256", + internalType: "uint256", + }, + { + name: "exponent", + type: "uint256", + internalType: "uint256", + }, + { + name: "modulus", + type: "uint256", + internalType: "uint256", + }, + ], + }, + { + type: "error", + name: "NoCommitmentFound", + inputs: [], + }, + { + type: "error", + name: "OwnableInvalidOwner", + inputs: [ + { + name: "owner", + type: "address", + internalType: "address", + }, + ], + }, + { + type: "error", + name: "OwnableUnauthorizedAccount", + inputs: [ + { + name: "account", + type: "address", + internalType: "address", + }, + ], + }, + { + type: "error", + name: "RevealMustBeOnExactBlock", + inputs: [], + }, + { + type: "error", + name: "RevealedValueNotAvailable", + inputs: [], + }, + ], +} as const -const aliasToContract = ({ - "Random": "Random" -}) as const +const aliasToContract = { + Random: "Random", +} as const -export const deployment = ({ - "Random": "0x51745e910FaD45A6cA620bCc7a7fAB7683B142e5" -}) as const +export const deployment = { + Random: "0x5FbDB2315678afecb367f032d93F642f64180aa3", +} as const export type ContractToAbi = typeof contractToAbi export type AliasToContract = typeof aliasToContract diff --git a/contracts/deployments/happy-sepolia/random/transactions.json b/contracts/deployments/happy-sepolia/random/transactions.json index 52ae922b75..906dd62b2d 100644 --- a/contracts/deployments/happy-sepolia/random/transactions.json +++ b/contracts/deployments/happy-sepolia/random/transactions.json @@ -1,20 +1,25 @@ { "transactions": [ { - "hash": "0xbd88a005ee7688787396e35537769b0f4360c64d0fc1268d1e581a1a264a568c", - "transactionType": "CREATE2", + "hash": "0xf14e183e774da1688029fd42690e1db562182e2d9594c1482e8f2e6a164d33f7", + "transactionType": "CREATE", "contractName": "Random", "contractAddress": "0x51745e910fad45a6ca620bcc7a7fab7683b142e5", "function": null, - "arguments": null, + "arguments": [ + "[2416910118189096557713698606232949750075245832257361418817199221841198809231, 3565178688866727608783247307855519961161197286613423629330948765523825963906, 18766085122067595057703228467555884757373773082319035490740181099798629248523, 263980444642394177375858669180402387903005329333277938776544051059273779190]", + "1727521075", + "3", + "1734347812", + "1" + ], "transaction": { - "from": "0xee3ae13ed56e877874a6c5fbe7cda7fc8573a7be", - "to": "0x4e59b44847b379578588920ca78fbf26c0b4956c", - "gas": "0x88ac4", + "from": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", + "gas": "0x3678db", "value": "0x0", - "input": "0x00000000000000000000000000000000000000000000000000000000000000006080604052348015600e575f80fd5b503380603357604051631e4fbdf760e01b81525f600482015260240160405180910390fd5b603a81603f565b50608e565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6105f08061009b5f395ff3fe608060405234801561000f575f80fd5b506004361061009f575f3560e01c80638da5cb5b11610072578063f5fa417a11610058578063f5fa417a14610133578063f930191014610146578063fd0a5aaf1461014e575f80fd5b80638da5cb5b146100f9578063f2fde38b14610120575f80fd5b80631d539681146100a35780635f6f07dc146100b8578063715018a6146100cb5780637b308b6d146100d3575b5f80fd5b6100b66100b136600461050b565b610156565b005b6100b66100c636600461050b565b610237565b6100b6610375565b6100e66100e136600461052b565b610388565b6040519081526020015b60405180910390f35b5f5460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100f0565b6100b661012e366004610542565b6103a1565b6100e661014136600461052b565b610409565b6100e6600281565b6100e6600a81565b61015e610445565b610169600a8361057c565b4211156101a2576040517f4c8e490f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f82815260036020526040902054156101e7576040517f145718a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f82815260036020526040908190208290555182907f7a27537ccaa1ad9d9b038704d7cf6ec9b4e73e786ec619181e3eb1451de868d89061022b9084815260200190565b60405180910390a25050565b61023f610445565b5f8281526003602052604081205490819003610287576040517fc6c155d800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8242146102c0576040517f7fc88be700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408051602081018490520160405160208183030381529060405280519060200120811461031a576040517f9ea6d12700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600182905560028390555f83815260036020526040808220919091555183907f42629d9632d9a72fcd50885db3d64e9e40e4c13f06af15d9241ef817bdf265bc906103689085815260200190565b60405180910390a2505050565b61037d610445565b6103865f610497565b565b5f816002541461039957505f919050565b505060015490565b6103a9610445565b73ffffffffffffffffffffffffffffffffffffffff81166103fd576040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081525f60048201526024015b60405180910390fd5b61040681610497565b50565b5f8160025414610399576040517f481b130600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5473ffffffffffffffffffffffffffffffffffffffff163314610386576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016103f4565b5f805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f806040838503121561051c575f80fd5b50508035926020909101359150565b5f6020828403121561053b575f80fd5b5035919050565b5f60208284031215610552575f80fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610575575f80fd5b9392505050565b818103818111156105b4577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b9291505056fea2646970667358221220b9d206ef5d57f69370f92d0b959fff0ce2b1f5951c7c981e6fb314500210fa6e64736f6c634300081a0033", - "nonce": "0x14", - "chainId": "0xd8" + "input": "0x608060405234801561000f575f80fd5b5060405161310638038061310683398101604081905261002e91610342565b848484338061005757604051631e4fbdf760e01b81525f60048201526024015b60405180910390fd5b610060816100b2565b5061006a83610101565b610089578260405163c7728ee960e01b815260040161004e91906103da565b610095600484816102dc565b5060089190915560095550600b91909155600c555061040a915050565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80515f905f805160206130e6833981519152111580610131575060208201515f805160206130e683398151915211155b80610168575060408201515f805160206130e6833981519152111580610168575060608201515f805160206130e683398151915211155b1561017457505f919050565b61017d82610183565b92915050565b5f815160208301515f805160206130e68339815191528283095f805160206130e683398151915282830981828301015f805160206130e683398151915282838401085f805160206130e683398151915286825f805160206130e6833981519152038601099350505f805160206130e683398151915284835f805160206130e68339815191520383010991505f805160206130e68339815191527f2b149d40ceb8aaae81be18991be06ac3b5b4c5e559dbefa33267e6dc24a138e5840894505f805160206130e68339815191527e9713b03af0fed4cd2cafadeed8fdf4a74fa084e52d1852e4a2bd0685c315d28308935060408701519250606087015191505f805160206130e683398151915280835f805160206130e68339815191520385085f805160206130e68339815191528486080990505f805160206130e6833981519152828460011b0994149290931491909116949350505050565b826004810192821561030a579160200282015b8281111561030a5782518255916020019190600101906102ef565b5061031692915061031a565b5090565b5b80821115610316575f815560010161031b565b634e487b7160e01b5f52604160045260245ffd5b5f805f805f6101008688031215610357575f80fd5b86601f870112610365575f80fd5b604051608081016001600160401b03811182821017156103875761038761032e565b60405280608088018981111561039b575f80fd5b885b818110156103b557805183526020928301920161039d565b505160a089015160c08a015160e0909a0151939b919a50989750919550909350505050565b6080810181835f5b60048110156104015781518352602092830192909101906001016103e2565b50505092915050565b612ccf806104175f395ff3fe608060405234801561000f575f80fd5b506004361061018f575f3560e01c80637b308b6d116100dd578063f14ff4ef11610088578063f5fa417a11610063578063f5fa417a14610326578063f61ff62314610339578063fd0a5aaf1461034c575f80fd5b8063f14ff4ef146102ed578063f2fde38b14610300578063f398a6db14610313575f80fd5b80638da5cb5b116100b85780638da5cb5b146102aa5780639c8c9b4a146102d1578063dc0998aa146102da575f80fd5b80637b308b6d146102865780638285d8891461029957806386377e8b146102a1575f80fd5b80635f7c75221161013d5780636fe318c1116101185780636fe318c114610256578063715018a6146102755780637425518f1461027d575f80fd5b80635f7c75221461021b5780636037d218146102305780636d1ef32814610243575f80fd5b80634a8ae6311161016d5780634a8ae631146101ed5780635ec01e4d146102005780635f6f07dc14610208575f80fd5b8063110a85bf146101935780631d539681146101af5780633d55a583146101c4575b5f80fd5b61019c600b5481565b6040519081526020015b60405180910390f35b6101c26101bd3660046127c7565b610354565b005b61019c6101d23660046127fe565b67ffffffffffffffff165f908152600a602052604090205490565b61019c6101fb366004612817565b610435565b61019c61044f565b6101c26102163660046127c7565b61049f565b6102236105dd565b6040516101a6919061282e565b61019c61023e3660046127fe565b6105f9565b6101c26102513660046128ae565b610677565b61019c6102643660046127fe565b600a6020525f908152604090205481565b6101c2610832565b61019c60095481565b61019c610294366004612817565b610845565b61019c600281565b61019c600c5481565b5f5460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101a6565b61019c60085481565b61019c6102e8366004612817565b61085e565b61019c6102fb366004612817565b610874565b6101c261030e36600461293a565b610881565b61019c610321366004612817565b6108e4565b61019c610334366004612817565b6108f9565b61019c610347366004612817565b610935565b61019c600a81565b61035c61096d565b610367600a8361299a565b4311156103a0576040517f4c8e490f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f82815260036020526040902054156103e5576040517f145718a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f82815260036020526040908190208290555182907f7a27537ccaa1ad9d9b038704d7cf6ec9b4e73e786ec619181e3eb1451de868d8906104299084815260200190565b60405180910390a25050565b5f61044961044460028461299a565b6109bf565b92915050565b5f8061045f61044460024261299a565b90505f61046b436108f9565b6040805160208101859052908101829052909150606001604051602081830303815290604052805190602001209250505090565b6104a761096d565b5f82815260036020526040812054908190036104ef576040517fc6c155d800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b824314610528576040517f7fc88be700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604080516020810184905201604051602081830303815290604052805190602001208114610582576040517f9ea6d12700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600182905560028390555f83815260036020526040808220919091555183907f42629d9632d9a72fcd50885db3d64e9e40e4c13f06af15d9241ef817bdf265bc906105d09085815260200190565b60405180910390a2505050565b6040518060600160405280602b8152602001612c6f602b913981565b67ffffffffffffffff81165f908152600a6020526040812054810361065b576040517fc3f4d68a00000000000000000000000000000000000000000000000000000000815267ffffffffffffffff831660048201526024015b60405180910390fd5b5067ffffffffffffffff165f908152600a602052604090205490565b6040805160208082528183019092525f91602082018180368337019050509050825f526008601820808260200152505f6106c96040518060600160405280602b8152602001612c6f602b9139836109ee565b90505f6106d584610aa3565b90508061071557600482856040517fb8cf7d30000000000000000000000000000000000000000000000000000000008152600401610652939291906129d5565b6040805160808101918290525f91829161075291889190600490819081845b81548152602001906001019080831161073457505050505086610b13565b915091508161079457600484876040517fb8cf7d30000000000000000000000000000000000000000000000000000000008152600401610652939291906129d5565b5f866040516020016107a69190612a22565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0018152828252805160209182012067ffffffffffffffff8c165f818152600a845293909320819055808452935090917fb262efe8f3fb8d5cb448e8771d8d93fe981dfa54d2e292afe1b4970dc9237134910160405180910390a25050505050505050565b61083a61096d565b6108435f610cc5565b565b5f816002541461085657505f919050565b505060015490565b6004816004811061086d575f80fd5b0154905081565b5f61044961044483610d39565b61088961096d565b73ffffffffffffffffffffffffffffffffffffffff81166108d8576040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081525f6004820152602401610652565b6108e181610cc5565b50565b5f6104496108f461034784610d39565b610d60565b5f8160025414610856576040517f481b130600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f60095460026109459190612a30565b6002610959610954828661299a565b610d87565b6109639190612a47565b6104499190612a47565b5f5473ffffffffffffffffffffffffffffffffffffffff163314610843576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401610652565b5f80600954600854846109d2919061299a565b6109dc9190612a87565b90506109e7816105f9565b9392505050565b6109f661276d565b5f610a018484610dad565b90505f610a1482825b6020020151610ef8565b90505f610a22836001610a0a565b9050610a2c61278b565b825181526020808401518282015282516040808401919091529083015160608301525f908460808460066107d05a03fa905080610a9757816040517f128e3f080000000000000000000000000000000000000000000000000000000081526004016106529190612ac7565b50919695505050505050565b80515f907f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47111580610af9575060208201517f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4711155b15610b0557505f919050565b610449826113a0565b919050565b5f805f604051806101800160405280875f60028110610b3457610b34612a9a565b6020020151815260200187600160028110610b5157610b51612a9a565b602002015181526020017f198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c281526020017f1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed81526020017f275dc4a288d1afb3cbb1ac09187524c7db36395df7be3b99e673b13a075a65ec81526020017f1d9befcd05a5323e6da4d435f3b617cdb3af83285c2df711ef39c01571827f9d8152602001855f60028110610c0557610c05612a9a565b6020020151815260200185600160028110610c2257610c22612a9a565b6020020151815260200186600160048110610c3f57610c3f612a9a565b60200201518152602001865f60048110610c5b57610c5b612a9a565b6020020151815260200186600360048110610c7857610c78612a9a565b6020020151815260200186600260048110610c9557610c95612a9a565b602002015190529050610ca66127a9565b6020816101808460086107d05a03fa9051151597909650945050505050565b5f805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600c545f90610d4960018461299a565b610d539190612a30565b600b546104499190612a47565b5f600c54600b5483610d72919061299a565b610d7c9190612a87565b610449906001612a47565b5f60095482610d969190612af7565b600954610da3919061299a565b6104499083612a47565b610db561276d565b5f610dc08484611446565b90505f805f806018850177ffffffffffffffffffffffffffffffffffffffffffffffff815116935060308601905077ffffffffffffffffffffffffffffffffffffffffffffffff81511694507f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47857f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4778010000000000000000000000000000000000000000000000008709086048870151606088015177ffffffffffffffffffffffffffffffffffffffffffffffff908116975016945092507f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47905084817801000000000000000000000000000000000000000000000000860908604080518082019091529283526020830152509695505050505050565b610f0061276d565b7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd478210610f5c576040517fd53e941500000000000000000000000000000000000000000000000000000000815260048101839052602401610652565b5f7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4760047f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd478586090990505f7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd478260010890507f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4761101a837f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4761299a565b60010891505f61104c7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47838509611630565b90505f7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4778016789af3a83522eb353c98fc6b36d713d5d8d1cc5dffffffa7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47847f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47888b09090990505f7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47611120837f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4761299a565b7f183227397098d014dc2822db40c0ac2ecbc0b548b438e5469e10460b6c3e7ea30890505f7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47837f183227397098d014dc2822db40c0ac2ecbc0b548b438e5469e10460b6c3e7ea30890505f7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4786870990505f7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4786830990505f7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47807f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd478485097f10216f7ba065e00de81ac1e7808072c9dd2b2385cd7b438469602eb24829a9bd0960010890505f8061125a6112558861163a565b6116ac565b5f0b6001036112c357868c5261126f8761163a565b905061127a8161175c565b60208e01919091529150816112be576040517f396ec77100000000000000000000000000000000000000000000000000000000815260048101829052602401610652565b61133f565b6112cf6112558761163a565b5f0b6001036112e457858c5261126f8661163a565b828c526112f08361163a565b90506112fb8161175c565b60208e019190915291508161133f576040517f396ec77100000000000000000000000000000000000000000000000000000000815260048101829052602401610652565b60208c015161134d90611796565b6113568e611796565b146113905760208c015161138a907f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4761299a565b60208d01525b5050505050505050505050919050565b5f815160208301517f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd478283097f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4783820990507f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd476003820890507f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4782830914949350505050565b815160609060ff81111561148857836040517f26e4f9ba000000000000000000000000000000000000000000000000000000008152600401610652919061282e565b60408051608880825260c082019092525f916020820181803683370190505090505f81855f60605f8a886040516020016114c89796959493929190612b21565b60405160208183030381529060405290505f818051906020012090505f81600189876040516020016114fd9493929190612bfc565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001815282825280516020820120606080855260808501909352909350915f91602082018180368337019050509050600360015b818110156115f45785841861156e826001612a47565b8d8b6040516020016115839493929190612bfc565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001815291905260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff830181028501810195909552805194810194909420939450600101611558565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff016020908102820101919091529550505050505092915050565b5f610449826117a2565b5f7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4760037f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47847f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47868709090892915050565b5f806116b783611efa565b90506116e460017f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4761299a565b810361171257507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff92915050565b8015801590611722575080600114155b15610449576040517f396ec77100000000000000000000000000000000000000000000000000000000815260048101849052602401610652565b5f8061176783612027565b9150827f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47838409149050915091565b5f610449600283612af7565b5f7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd478083840991508083830981838209828283098385830984848309858484098684850997508684840987858409945087898a09985087898a09985087898a09985087898a09985087898a09985087878a09985087898a09985087898a09985087898a099850878a8a09985087898a09985087898a09985087898a09985087898a099850878a8a09985087898a09985087898a09985087898a09985087898a09985087898a09985087848a09985087898a09985087898a09985087898a09985087898a09985087898a09985087848a09985087898a09985087898a09985087898a099850878a8a09985087898a09985087898a09985087898a09985087898a09985087848a09985087898a09985087898a09985087898a09985087898a09985087898a099850878a8a09985087898a09985087898a09985087898a09985087898a09985087878a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087818a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087868a09985087898a09985087898a09985087898a09985087898a09985087878a09985087898a09985087898a09985087898a09985087898a09985087848a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087868a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a099850878a8a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087828a09985087898a09985087898a09985087898a09985087898a09985087898a09985087818a09985087898a09985087898a09985087898a09985087868a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087878a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087868a09985087898a09985087898a09985087898a09985087878a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087828a09985087898a09985087898a09985087898a09985087898a09985087828a09985087898a09985087898a09985087898a09985087898a09985087898a09985087868a09985087898a09985087898a09985087898a09985087848a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087828a09985087898a09985087898a09985087898a09985087898a09985087868a09985087898a09985087898a09985087898a09985087898a09985087898a09985087838a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087828a09985087898a09985087898a099850878a8a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087848a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087848a09985087898a09985087898a09985087898a09985087898a09985087898a09985087868a09985087898a09985087898a099850878a8a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087818a09985050868889099750868889099750868889099750868889099750868889099750868889099750868489099750868889099750868889099750868889099750868889099750868889099750868989099750868889099750868889099750868889099750868889099750868889099750868889099750868989099750868889099750868889099750868889099750868889099750868889099750868689099750868889099750868889099750868889099750868889099750868889099750868889099750868889099750868889099750868889099750868189099750508587880996508587880996508587880996508585880996508587880996508587880996508587880996508585880996508587880996508587880996508587880996508587880996508587880996508587880996508587880996508587880996508583880996508587880996508587880996508587880996508587880996508581880996505050838586099450838586099450838586099450838586099450838186099450508284850993508284850993508284850993508281850993508284850993508284850993508285850993508284850993508284850993508284850993508284850993508284850993508284850993508281850995945050505050565b6040805160c080825260e082019092525f918291906020820181803683370190505060208082018181526040830182905260608301829052608083018690527f183227397098d014dc2822db40c0ac2ecbc0b548b438e5469e10460b6c3e7ea360a08401527f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4760c0808501919091529293505f92839160055afa90505f51925080612020576040517fc6daf7ab000000000000000000000000000000000000000000000000000000008152600481018590527f183227397098d014dc2822db40c0ac2ecbc0b548b438e5469e10460b6c3e7ea360248201527f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd476044820152606401610652565b5050919050565b5f7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd478083840991508083830981838209828283098385830984848309858484098684850997508684840987858409945087898a09985087898a09985087898a09985087898a09985087898a09985087878a09985087898a09985087898a09985087898a099850878a8a09985087898a09985087898a09985087898a09985087898a099850878a8a09985087898a09985087898a09985087898a09985087898a09985087898a09985087848a09985087898a09985087898a09985087898a09985087898a09985087898a09985087848a09985087898a09985087898a09985087898a099850878a8a09985087898a09985087898a09985087898a09985087898a09985087848a09985087898a09985087898a09985087898a09985087898a09985087898a099850878a8a09985087898a09985087898a09985087898a09985087898a09985087878a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087818a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087868a09985087898a09985087898a09985087898a09985087898a09985087878a09985087898a09985087898a09985087898a09985087898a09985087848a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087868a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a099850878a8a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087828a09985087898a09985087898a09985087898a09985087898a09985087898a09985087818a09985087898a09985087898a09985087898a09985087868a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087878a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087868a09985087898a09985087898a09985087898a09985087878a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087828a09985087898a09985087898a09985087898a09985087898a09985087828a09985087898a09985087898a09985087898a09985087898a09985087898a09985087868a09985087898a09985087898a09985087898a09985087848a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087828a09985087898a09985087898a09985087898a09985087898a09985087868a09985087898a09985087898a09985087898a09985087898a09985087898a09985087838a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087828a09985087898a09985087898a099850878a8a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087848a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087848a09985087898a09985087898a09985087898a09985087898a09985087898a09985087868a09985087898a09985087898a099850878a8a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087898a09985087818a09985050868889099750868889099750868889099750868889099750868889099750868889099750868489099750868889099750868889099750868889099750868889099750868889099750868989099750868889099750868889099750868889099750868889099750868889099750868889099750868989099750868889099750868889099750868889099750868889099750868889099750868689099750868889099750868889099750868889099750868889099750868889099750868889099750868889099750868889099750868889099750868189099750508587880996508587880996508587880996508585880996508587880996508587880996508587880996508585880996508587880996508587880996508587880996508587880996508587880996508587880996508587880996508587880996508583880996508587880996508587880996508587880996508587880996508581880996508587880996508587880996508587880996508587880996508583880996508587880996508587880996508587880996508584880996508587880996508587880996508587880996508587880996508587880996508581880996505050505050808283099392505050565b60405180604001604052806002906020820280368337509192915050565b60405180608001604052806004906020820280368337509192915050565b60405180602001604052806001906020820280368337509192915050565b5f80604083850312156127d8575f80fd5b50508035926020909101359150565b803567ffffffffffffffff81168114610b0e575f80fd5b5f6020828403121561280e575f80fd5b6109e7826127e7565b5f60208284031215612827575f80fd5b5035919050565b602081525f82518060208401528060208501604085015e5f6040828501015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011684010191505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f80606083850312156128bf575f80fd5b6128c8836127e7565b915083603f8401126128d8575f80fd5b6040516040810181811067ffffffffffffffff821117156128fb576128fb612881565b60405280606085018681111561290f575f80fd5b602086015b8181101561292c578035835260209283019201612914565b505050809150509250929050565b5f6020828403121561294a575f80fd5b813573ffffffffffffffffffffffffffffffffffffffff811681146109e7575f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b818103818111156104495761044961296d565b805f5b60028110156129cf5781518452602093840193909101906001016129b0565b50505050565b610100810181855f5b60048110156129fd5781548352602090920191600191820191016129de565b505050612a0d60808301856129ad565b612a1a60c08301846129ad565b949350505050565b6040810161044982846129ad565b80820281158282048414176104495761044961296d565b808201808211156104495761044961296d565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f82612a9557612a95612a5a565b500490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b6080810181835f5b6004811015612aee578151835260209283019290910190600101612acf565b50505092915050565b5f82612b0557612b05612a5a565b500690565b5f81518060208401855e5f93019283525090919050565b5f612b35612b2f838b612b0a565b89612b0a565b7fff000000000000000000000000000000000000000000000000000000000000008860f81b1681527fff000000000000000000000000000000000000000000000000000000000000008760f81b1660018201527fff000000000000000000000000000000000000000000000000000000000000008660f81b166002820152612bc06003820186612b0a565b60f89490941b7fff0000000000000000000000000000000000000000000000000000000000000016845250506001909101979650505050505050565b8481527fff000000000000000000000000000000000000000000000000000000000000008460f81b1660208201525f612c386021830185612b0a565b60f89390931b7fff000000000000000000000000000000000000000000000000000000000000001683525050600101939250505056fe424c535f5349475f424e32353447315f584d443a4b454343414b2d3235365f535644575f524f5f4e554c5fa26469706673582212202fd9bb390e4afffd96a5eac36eeaa90e7558beccfde421e09e7c70674504abca64736f6c634300081a003330644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd470557ec32c2ad488e4d4f6008f89a346f18492092ccc0d594610de2732c8b808f07e1d1d335df83fa98462005690372c643340060d205306a9aa8106b6bd0b382297d3a4f9749b33eb2d904c9d9ebf17224150ddd7abd7567a9bec6c74480ee0b0095685ae3a85ba243747b1b2f426049010f6b73a0cf1d389351d5aaaa1047f60000000000000000000000000000000000000000000000000000000066f7e13300000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000067600c240000000000000000000000000000000000000000000000000000000000000001", + "nonce": "0x0", + "chainId": "0x7a69" }, "additionalContracts": [], "isFixedGasLimit": false @@ -23,7 +28,7 @@ "receipts": [ { "status": "0x1", - "cumulativeGasUsed": "0x6da71", + "cumulativeGasUsed": "0x29e6d0", "logs": [ { "address": "0x51745e910fad45a6ca620bcc7a7fab7683b142e5", @@ -33,37 +38,34 @@ "0x0000000000000000000000004e59b44847b379578588920ca78fbf26c0b4956c" ], "data": "0x", - "blockHash": "0x294394e9a85f230aa7742f76d0fe35298805d71df8b1995043f2f3db571e32e4", - "blockNumber": "0x712d8e", - "transactionHash": "0xbd88a005ee7688787396e35537769b0f4360c64d0fc1268d1e581a1a264a568c", - "transactionIndex": "0x1", + "blockHash": "0xb71a399092177ae884f9f133b0610abab56396c27f5fb93a10cae78cdcb4912c", + "blockNumber": "0x6", + "blockTimestamp": "0x67600d77", + "transactionHash": "0xf14e183e774da1688029fd42690e1db562182e2d9594c1482e8f2e6a164d33f7", + "transactionIndex": "0x0", "logIndex": "0x0", "removed": false } ], "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000200000000000000000000000001000000000000000000000000000000001000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000080000000000000000000000000000000", "type": "0x2", - "transactionHash": "0xbd88a005ee7688787396e35537769b0f4360c64d0fc1268d1e581a1a264a568c", - "transactionIndex": "0x1", - "blockHash": "0x294394e9a85f230aa7742f76d0fe35298805d71df8b1995043f2f3db571e32e4", - "blockNumber": "0x712d8e", - "gasUsed": "0x62f2f", - "effectiveGasPrice": "0xfd", - "from": "0xee3ae13ed56e877874a6c5fbe7cda7fc8573a7be", - "to": "0x4e59b44847b379578588920ca78fbf26c0b4956c", - "contractAddress": "0x51745e910fad45a6ca620bcc7a7fab7683b142e5", - "l1BaseFeeScalar": "0xa31c2", - "l1BlobBaseFee": "0x1", - "l1BlobBaseFeeScalar": "0x0", - "l1Fee": "0x19cb2abcef8ba", - "l1GasPrice": "0xa961baff7", - "l1GasUsed": "0x3a59" + "transactionHash": "0xf14e183e774da1688029fd42690e1db562182e2d9594c1482e8f2e6a164d33f7", + "transactionIndex": "0x0", + "blockHash": "0xb71a399092177ae884f9f133b0610abab56396c27f5fb93a10cae78cdcb4912c", + "blockNumber": "0x6", + "gasUsed": "0x29e6d0", + "effectiveGasPrice": "0x1e925e89", + "blobGasPrice": "0x1", + "from": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", + "to": null, + "contractAddress": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "root": "0xffcf090a4e06a43746a3cfc827f38a459922276c52e6bf8b924dda5221b7a345" } ], "libraries": [], "pending": [], "returns": {}, - "timestamp": 1737999999, - "chain": 216, - "commit": "91cb8c79" + "timestamp": 1734348151, + "chain": 31337, + "commit": "79f7e6eb" } \ No newline at end of file diff --git a/contracts/foundry.toml b/contracts/foundry.toml index 36490827f0..febade1e5e 100755 --- a/contracts/foundry.toml +++ b/contracts/foundry.toml @@ -6,7 +6,7 @@ solc_version = "0.8.26" optimizer = true optimizer_runs = 20000 -via_ir = false +via_ir = true ignored_warnings_from = ["node_modules", "lib"] diff --git a/contracts/package.json b/contracts/package.json index 1db262e707..2d8f45c406 100755 --- a/contracts/package.json +++ b/contracts/package.json @@ -12,6 +12,7 @@ "./random/anvil": "./deployments/anvil/random/abis.ts" }, "dependencies": { + "@kevincharm/bls-bn254": "^2.0.0", "@openzeppelin/contracts": "^5.0.2", "@openzeppelin/contracts-upgradeable": "^5.0.2", "ExcessivelySafeCall": "git@github.com:nomad-xyz/ExcessivelySafeCall#release/0.0.1", diff --git a/contracts/remappings.txt b/contracts/remappings.txt index bdeea23e87..4fae0a7315 100755 --- a/contracts/remappings.txt +++ b/contracts/remappings.txt @@ -6,4 +6,5 @@ account-abstraction/=lib/account-abstraction/ kernel/=lib/kernel/src/ solady/=lib/solady/src/ ExcessivelySafeCall/=lib/ExcessivelySafeCall/src/ -@openzeppelin/contracts=lib/openzeppelin/src \ No newline at end of file +@openzeppelin/contracts=lib/openzeppelin/src +bls-bn254/=lib/bls-bn254/contracts/ \ No newline at end of file diff --git a/contracts/src/Random.sol b/contracts/src/Random.sol deleted file mode 100644 index 0ce8bc6389..0000000000 --- a/contracts/src/Random.sol +++ /dev/null @@ -1,75 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause-Clear -pragma solidity ^0.8.20; - -import {Ownable} from "openzeppelin/access/Ownable.sol"; - -contract Random is Ownable { - uint256 public constant PRECOMMIT_DELAY = 10; - uint256 public constant BLOCK_TIME = 2; - - uint256 private currentRevealedValue; - uint256 private currentRevealTimestamp; - mapping(uint256 timestamp => bytes32) private commitments; - - event CommitmentPosted(uint256 indexed timestamp, bytes32 commitment); - event ValueRevealed(uint256 indexed timestamp, uint256 revealedValue); - - error CommitmentTooLate(); - error CommitmentAlreadyExists(); - error NoCommitmentFound(); - error RevealMustBeOnExactBlock(); - error InvalidReveal(); - error RevealedValueNotAvailable(); - - constructor() Ownable(msg.sender) {} - - function postCommitment(uint256 timestamp, bytes32 commitmentHash) external onlyOwner { - if (block.timestamp > timestamp - PRECOMMIT_DELAY) { - revert CommitmentTooLate(); - } - - if (commitments[timestamp] != 0) { - revert CommitmentAlreadyExists(); - } - - commitments[timestamp] = commitmentHash; - emit CommitmentPosted(timestamp, commitmentHash); - } - - function revealValue(uint256 timestamp, uint256 revealedValue) external onlyOwner { - bytes32 storedCommitment = commitments[timestamp]; - - if (storedCommitment == 0) { - revert NoCommitmentFound(); - } - - if (block.timestamp != timestamp) { - revert RevealMustBeOnExactBlock(); - } - - if (storedCommitment != keccak256(abi.encodePacked(revealedValue))) { - revert InvalidReveal(); - } - - currentRevealedValue = revealedValue; - currentRevealTimestamp = timestamp; - delete commitments[timestamp]; - emit ValueRevealed(timestamp, revealedValue); - } - - function unsafeGetRevealedValue(uint256 timestamp) external view returns (uint256) { - if (currentRevealTimestamp != timestamp) { - return 0; - } - - return currentRevealedValue; - } - - function getRevealedValue(uint256 timestamp) external view returns (uint256) { - if (currentRevealTimestamp != timestamp) { - revert RevealedValueNotAvailable(); - } - - return currentRevealedValue; - } -} diff --git a/contracts/src/Randomness/Drand.sol b/contracts/src/Randomness/Drand.sol new file mode 100644 index 0000000000..6f6969c5ab --- /dev/null +++ b/contracts/src/Randomness/Drand.sol @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: BSD-3-Clause-Clear +pragma solidity ^0.8.20; + +import {BLS} from "bls-bn254/BLS.sol"; + +contract Drand { + bytes public constant DST = bytes("BLS_SIG_BN254G1_XMD:KECCAK-256_SVDW_RO_NUL_"); + + uint256[4] public publicKey; + uint256 public genesisTimestamp; + uint256 public period; + mapping(uint64 round => bytes32 randomness) public randomness; + + error InvalidPublicKey(uint256[4] publicKey); + error InvalidSignature(uint256[4] publicKey, uint256[2] message, uint256[2] signature); + error DrandNotAvailable(uint64 round); + + constructor(uint256[4] memory _publicKey, uint256 _genesisTimestamp, uint256 _period) { + if (!BLS.isValidPublicKey(_publicKey)) { + revert InvalidPublicKey(_publicKey); + } + publicKey = _publicKey; + genesisTimestamp = _genesisTimestamp; + period = _period; + } + + function postDrand(uint64 round, uint256[2] memory signature) external { + // Encode round for hash-to-point + bytes memory hashedRoundBytes = new bytes(32); + assembly { + mstore(0x00, round) + let hashedRound := keccak256(0x18, 0x08) // hash the last 8 bytes (uint64) of `round` + mstore(add(0x20, hashedRoundBytes), hashedRound) + } + uint256[2] memory message = BLS.hashToPoint(DST, hashedRoundBytes); + + // NB: Always check that the signature is a valid signature (a valid G1 point on the curve)! + bool isValidSignature = BLS.isValidSignature(signature); + if (!isValidSignature) { + revert InvalidSignature(publicKey, message, signature); + } + + // Verify the signature over the message using the public key + (bool pairingSuccess, bool callSuccess) = BLS.verifySingle(signature, publicKey, message); + if (!pairingSuccess) { + revert InvalidSignature(publicKey, message, signature); + } + + bytes32 roundRandomness = keccak256(abi.encode(signature)); + + randomness[round] = roundRandomness; + } + + function _unsafeGetDrand(uint64 round) internal view returns (bytes32) { + return randomness[round]; + } + + function _getDrand(uint64 round) internal view returns (bytes32) { + if (randomness[round] == 0) { + revert DrandNotAvailable(round); + } + + return randomness[round]; + } + + function _getDrandAtTimestamp(uint256 timestamp) internal view returns (bytes32) { + uint64 round = uint64((timestamp - genesisTimestamp) / period); + return _getDrand(round); + } + + function _nextValidTimestamp(uint256 timestamp) internal view returns (uint256) { + return timestamp + (period - (timestamp % period)); + } +} diff --git a/contracts/src/Randomness/Random.sol b/contracts/src/Randomness/Random.sol new file mode 100644 index 0000000000..7ab23d5a13 --- /dev/null +++ b/contracts/src/Randomness/Random.sol @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: BSD-3-Clause-Clear +pragma solidity ^0.8.20; + +import {RandomCommitment} from "./RandomCommitment.sol"; +import {Drand} from "./Drand.sol"; + +contract Random is RandomCommitment, Drand { + uint256 public constant DRAND_DELAY = 6; + + constructor(uint256[4] memory _publicKey, uint256 _genesisTimestamp, uint256 _period) + RandomCommitment() + Drand(_publicKey, _genesisTimestamp, _period) + {} + + function random() external view returns (bytes32) { + bytes32 drand = _getDrandAtTimestamp(block.timestamp - DRAND_DELAY); + uint256 revealedValue = getRevealedValue(block.number); + return keccak256(abi.encodePacked(drand, revealedValue)); + } + + function randomForTimestamp(uint256 timestamp) external view returns (bytes32) { + return _getDrandAtTimestamp(timestamp); + } + + function nextValidTimestamp(uint256 timestamp) public view returns (uint256) { + return _nextValidTimestamp(timestamp); + } +} diff --git a/contracts/src/Randomness/RandomCommitment.sol b/contracts/src/Randomness/RandomCommitment.sol new file mode 100644 index 0000000000..9efeb90d2a --- /dev/null +++ b/contracts/src/Randomness/RandomCommitment.sol @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: BSD-3-Clause-Clear +pragma solidity ^0.8.20; + +import {Ownable} from "openzeppelin/access/Ownable.sol"; + +contract RandomCommitment is Ownable { + uint256 public constant PRECOMMIT_DELAY = 10; + + uint256 private currentRevealedValue; + uint256 private currentRevealBlockNumber; + mapping(uint256 blockNumber => bytes32) private commitments; + + event CommitmentPosted(uint256 indexed blockNumber, bytes32 commitment); + event ValueRevealed(uint256 indexed blockNumber, uint256 revealedValue); + + error CommitmentTooLate(); + error CommitmentAlreadyExists(); + error NoCommitmentFound(); + error RevealMustBeOnExactBlock(); + error InvalidReveal(); + error RevealedValueNotAvailable(); + + constructor() Ownable(msg.sender) {} + + function postCommitment(uint256 blockNumber, bytes32 commitmentHash) external onlyOwner { + if (block.number > blockNumber - PRECOMMIT_DELAY) { + revert CommitmentTooLate(); + } + + if (commitments[blockNumber] != 0) { + revert CommitmentAlreadyExists(); + } + + commitments[blockNumber] = commitmentHash; + emit CommitmentPosted(blockNumber, commitmentHash); + } + + function revealValue(uint256 blockNumber, uint256 revealedValue) external onlyOwner { + bytes32 storedCommitment = commitments[blockNumber]; + + if (storedCommitment == 0) { + revert NoCommitmentFound(); + } + + if (block.number != blockNumber) { + revert RevealMustBeOnExactBlock(); + } + + if (storedCommitment != keccak256(abi.encodePacked(revealedValue))) { + revert InvalidReveal(); + } + + currentRevealedValue = revealedValue; + currentRevealBlockNumber = blockNumber; + delete commitments[blockNumber]; + emit ValueRevealed(blockNumber, revealedValue); + } + + function unsafeGetRevealedValue(uint256 blockNumber) public view returns (uint256) { + if (currentRevealBlockNumber != blockNumber) { + return 0; + } + + return currentRevealedValue; + } + + function getRevealedValue(uint256 blockNumber) public view returns (uint256) { + if (currentRevealBlockNumber != blockNumber) { + revert RevealedValueNotAvailable(); + } + + return currentRevealedValue; + } +} diff --git a/contracts/src/deploy/DeployRandom.s.sol b/contracts/src/deploy/DeployRandom.s.sol index b63047a7e2..004ab84fa0 100644 --- a/contracts/src/deploy/DeployRandom.s.sol +++ b/contracts/src/deploy/DeployRandom.s.sol @@ -2,18 +2,43 @@ pragma solidity ^0.8.20; import {BaseDeployScript} from "./BaseDeployScript.sol"; -import {Random} from "../Random.sol"; +import {Random} from "../randomness/Random.sol"; /** * @dev Deploys the Randomness contract. */ -contract DeployL1 is BaseDeployScript { +contract DeployRandom is BaseDeployScript { bytes32 public constant DEPLOYMENT_SALT = bytes32(uint256(0)); - Random public random; + /* + * To understand these values. Please refer to the following link: + * https://docs.anyrand.com/diy/quickstart + */ + // Drand evmnet public key + uint256[4] public drandPublicKey; + // Drand evmnet genesis time (2024-01-29 00:11:15 UTC) + uint256 public constant DRAND_GENESIS_TIMESTAMP = 1727521075; + // Drand evmnet period (3 seconds) + uint256 public constant DRAND_PERIOD = 3; + + constructor() { + drandPublicKey = [ + 2416910118189096557713698606232949750075245832257361418817199221841198809231, + 3565178688866727608783247307855519961161197286613423629330948765523825963906, + 18766085122067595057703228467555884757373773082319035490740181099798629248523, + 263980444642394177375858669180402387903005329333277938776544051059273779190 + ]; + } + function deploy() internal override { - (address _random,) = deployDeterministic("Random", type(Random).creationCode, abi.encode(), DEPLOYMENT_SALT); + (address _random,) = deployDeterministic( + "Random", + type(Random).creationCode, + abi.encode(drandPublicKey, DRAND_GENESIS_TIMESTAMP, DRAND_PERIOD), + DEPLOYMENT_SALT + ); random = Random(_random); + deployed("Random", address(random)); } }