Skip to content
Open
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
30 changes: 28 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contracts/lib/forge-std
Submodule forge-std updated 52 files
+0 −1 .gitattributes
+12 −48 .github/workflows/ci.yml
+0 −31 .github/workflows/sync.yml
+3 −0 .gitmodules
+0 −193 CONTRIBUTING.md
+4 −20 README.md
+3 −5 foundry.toml
+1 −0 lib/ds-test
+1 −1 package.json
+0 −646 scripts/vm.py
+10 −19 src/Base.sol
+3 −5 src/Script.sol
+225 −518 src/StdAssertions.sol
+16 −71 src/StdChains.sol
+21 −211 src/StdCheats.sol
+0 −30 src/StdConstants.sol
+4 −34 src/StdInvariant.sol
+25 −129 src/StdJson.sol
+99 −245 src/StdStorage.sol
+2 −2 src/StdStyle.sol
+0 −283 src/StdToml.sol
+33 −50 src/StdUtils.sol
+6 −8 src/Test.sol
+347 −2,307 src/Vm.sol
+608 −635 src/console.sol
+1,543 −1 src/console2.sol
+1 −1 src/interfaces/IERC1155.sol
+3 −3 src/interfaces/IERC4626.sol
+0 −72 src/interfaces/IERC6909.sol
+1 −1 src/interfaces/IERC721.sol
+0 −150 src/interfaces/IERC7540.sol
+0 −241 src/interfaces/IERC7575.sol
+0 −13,937 src/safeconsole.sol
+0 −44 test/CommonBase.t.sol
+898 −40 test/StdAssertions.t.sol
+67 −134 test/StdChains.t.sol
+50 −271 test/StdCheats.t.sol
+0 −38 test/StdConstants.t.sol
+13 −15 test/StdError.t.sol
+0 −49 test/StdJson.t.sol
+26 −31 test/StdMath.t.sol
+46 −251 test/StdStorage.t.sol
+5 −5 test/StdStyle.t.sol
+0 −49 test/StdToml.t.sol
+36 −81 test/StdUtils.t.sol
+0 −18 test/Vm.t.sol
+1 −1 test/compilation/CompilationScript.sol
+1 −1 test/compilation/CompilationScriptBase.sol
+1 −1 test/compilation/CompilationTest.sol
+1 −1 test/compilation/CompilationTestBase.sol
+0 −8 test/fixtures/test.json
+0 −6 test/fixtures/test.toml
6 changes: 6 additions & 0 deletions crates/toolkit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ world-chain-pbh.workspace = true
alloy-consensus.workspace = true
alloy-network.workspace = true
alloy-primitives.workspace = true
alloy-provider = { workspace = true, features = ["reqwest", "reqwest-default-tls"] }
alloy-rpc-client.workspace = true
alloy-rpc-types-eth.workspace = true
alloy-rlp.workspace = true
alloy-sol-types.workspace = true

# 3rd party
bytes.workspace = true
Expand All @@ -25,3 +29,5 @@ tokio.workspace = true
dotenvy.workspace = true
chrono.workspace = true
rand.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
24 changes: 24 additions & 0 deletions crates/toolkit/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use alloy_primitives::Address;
use bytes::Bytes;
use chrono::NaiveDate;
use clap::Parser;
Expand Down Expand Up @@ -29,6 +30,8 @@ pub enum Cmd {
/// For the inclusion proof you can fetch it dynamically from the (staging) sequencer API via `--inclusion-proof-url https://signup-orb-ethereum.stage-crypto.worldcoin.dev/inclusionProof`
/// or `export INCLUSION_PROOF_URL=https://signup-orb-ethereum.stage-crypto.worldcoin.dev/inclusionProof` env var
Prove(ProveArgs),
/// Queries the PBH entrypoint contract directly to find currently available PBH nonces.
CheckNonces(CheckNoncesArgs),
}

#[derive(Debug, Clone, Parser)]
Expand Down Expand Up @@ -68,3 +71,24 @@ pub struct ProveArgs {

#[derive(Debug, Clone, Parser)]
pub struct SendArgs {}

#[derive(Debug, Clone, Parser)]
pub struct CheckNoncesArgs {
/// PBH-enabled node RPC URL.
#[clap(long, env = "RPC_URL")]
pub rpc_url: String,

/// PBH entrypoint contract address.
#[clap(long, env = "PBH_ENTRYPOINT")]
pub pbh_entrypoint: Address,

/// Overrides the current date for PBH external nullifier generation.
/// Format: "YYYY-MM-DD"
///
/// Dates are always assumed to be in UTC.
#[clap(short = 'D', long)]
pub custom_date: Option<NaiveDate>,

#[command(flatten)]
pub identity_source: IdentitySource,
}
26 changes: 26 additions & 0 deletions crates/toolkit/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use world_chain_pbh::{
};

mod cli;
mod pbh_contract_client;

use pbh_contract_client::PbhContractClient;

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InclusionProof {
Expand All @@ -21,6 +24,7 @@ pub struct InclusionProof {
#[tokio::main]
async fn main() -> eyre::Result<()> {
dotenvy::dotenv().ok();
init_tracing();

let args = Opt::parse();

Expand Down Expand Up @@ -79,11 +83,33 @@ async fn main() -> eyre::Result<()> {

println!("{encoded_hex}");
}
Cmd::CheckNonces(check_args) => {
let date = check_args
.custom_date
.unwrap_or_else(|| chrono::Utc::now().naive_utc().date());
let identity = check_args.identity_source.load();
let client = PbhContractClient::new(check_args.rpc_url);
let available_nonces = client
.find_available_pbh_nonces(check_args.pbh_entrypoint, &identity, date)
.await?;

println!("{}", serde_json::to_string(&available_nonces)?);
}
}

Ok(())
}

fn init_tracing() {
let env_filter = tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("toolkit=info"));

let _ = tracing_subscriber::fmt()
.with_env_filter(env_filter)
.with_target(false)
.try_init();
}

fn load_inclusion_proof_file(path: impl AsRef<std::path::Path>) -> eyre::Result<InclusionProof> {
let file = std::fs::File::open(path)?;
let proof = serde_json::from_reader(file)?;
Expand Down
Loading
Loading