Skip to content

Commit

Permalink
fix: ci
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso committed Feb 9, 2024
1 parent c2c1bfb commit 7b04ae4
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 15 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ethers-contract = { version = "2", default-features = false, features = [
ethers-core = "2"
ethers-signers = "2"
ethnum = "1"
getrandom = { version = "0.2", features = ["custom"] }
hex = "0.4"
ic-cdk = "0.11"
ic-cdk-macros = "0.8"
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ impl TestEnv {
Self::install_icrc2(&pic, cketh_ledger_id, "ckETH", "ckETH", 18);
// TODO: install ckETH minter
Self::install_deferred(&pic, deferred_id, ekoke_id, marketplace_id);
Self::install_deferred(&pic, deferred_id, ekoke_id, marketplace_id);
Self::install_ekoke(
&pic,
ekoke_id,
Expand Down Expand Up @@ -247,7 +246,6 @@ impl TestEnv {

fn load_wasm(canister: Canister) -> Vec<u8> {
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("../.dfx/local/canisters");
path.push(canister.as_path());

let mut file = std::fs::File::open(path).unwrap();
Expand Down
12 changes: 7 additions & 5 deletions integration-tests/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ pub enum Canister {
impl Canister {
pub fn as_path(&self) -> &'static Path {
match self {
Canister::Deferred => Path::new("deferred/deferred.wasm"),
Canister::Ekoke => Path::new("ekoke/ekoke.wasm"),
Canister::Marketplace => Path::new("marketplace/marketplace.wasm"),
Canister::Xrc => Path::new("test/xrc.wasm"),
Canister::Icrc2 => Path::new("test/icrc2-template-canister.wasm"),
Canister::Deferred => Path::new("../.dfx/local/canisters/deferred/deferred.wasm"),
Canister::Ekoke => Path::new("../.dfx/local/canisters/ekoke/ekoke.wasm"),
Canister::Marketplace => {
Path::new("../.dfx/local/canisters/marketplace/marketplace.wasm")
}
Canister::Xrc => Path::new("../assets/wasm/xrc.wasm"),
Canister::Icrc2 => Path::new("../assets/wasm/icrc2-template-canister.wasm"),
}
}
}
1 change: 1 addition & 0 deletions src/deferred/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ async-trait = { workspace = true }
candid = { workspace = true }
did = { path = "../did" }
dip721 = { path = "../dip721" }
getrandom = { workspace = true, features = ["custom"] }
ic-cdk = { workspace = true }
ic-cdk-macros = { workspace = true }
ic-stable-structures = { workspace = true }
Expand Down
12 changes: 12 additions & 0 deletions src/deferred/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,15 @@ fn main() {
candid::export_service!();
std::print!("{}", __export_service());
}

/// GetRandom fixup to allow getrandom compilation.
/// A getrandom implementation that always fails
///
/// This is a workaround for the fact that the `getrandom` crate does not compile
/// for the `wasm32-unknown-ic` target. This is a dummy implementation that always
/// fails with `Error::UNSUPPORTED`.
pub fn getrandom_always_fail(_buf: &mut [u8]) -> Result<(), getrandom::Error> {
Err(getrandom::Error::UNSUPPORTED)
}

getrandom::register_custom_getrandom!(getrandom_always_fail);
1 change: 1 addition & 0 deletions src/ekoke/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ ethers-contract = { workspace = true }
ethers-core = { workspace = true }
ethers-signers = { workspace = true }
ethnum = { workspace = true }
getrandom = { workspace = true, features = ["custom"] }
ic-cdk = { workspace = true }
ic-cdk-macros = { workspace = true }
ic-cdk-timers = { workspace = true }
Expand Down
2 changes: 0 additions & 2 deletions src/ekoke/src/app/erc20_bridge/eth_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ const MAINNET_ANKR_URL: &str = "https://rpc.ankr.com/eth";
#[cfg(target_family = "wasm")]
const HEADER_SIZE_LIMIT: u64 = 2 * 1024;
#[cfg(target_family = "wasm")]
const HTTP_MAX_SIZE: u64 = 2_000_000;
#[cfg(target_family = "wasm")]
const HTTP_RESPONSE_SIZE_LIMIT: u64 = 2048;
#[cfg(target_family = "wasm")]
const BASE_SUBNET_SIZE: u128 = 13;
Expand Down
4 changes: 2 additions & 2 deletions src/ekoke/src/app/erc20_bridge/eth_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ impl EthWallet {
pub async fn sign_transaction(tx: TransactionRequest) -> EkokeResult<Bytes> {
#[cfg(target_family = "wasm")]
{
use ethers_signer::Signature;
use ethers_core::types::Signature;
use ic_cdk::api::management_canister::ecdsa::{
self, EcdsaCurve, EcdsaKeyId, SignWithEcdsaArgument,
};

let sighash = tx.sighash();
use crate::constants::ETH_PUBKEY_NAME;
let (SignWithEcdsaResponse { signature },) =
let (ic_cdk::api::management_canister::ecdsa::SignWithEcdsaResponse { signature },) =
ecdsa::sign_with_ecdsa(SignWithEcdsaArgument {
message_hash: sighash.0.to_vec(),
derivation_path: vec![vec![]],
Expand Down
5 changes: 2 additions & 3 deletions src/ekoke/src/app/erc20_bridge/gas_station.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ const ETHERSCAN_API_URL: &str = "https://api.etherscan.io/api?module=proxy&actio
#[cfg(target_family = "wasm")]
const HEADER_SIZE_LIMIT: u64 = 2 * 1024;
#[cfg(target_family = "wasm")]
const HTTP_MAX_SIZE: u64 = 2_000_000;
#[cfg(target_family = "wasm")]
const HTTP_RESPONSE_SIZE_LIMIT: u64 = 2048;
#[cfg(target_family = "wasm")]
const BASE_SUBNET_SIZE: u128 = 13;
Expand All @@ -17,6 +15,7 @@ pub struct GasStation;

impl GasStation {
/// Returns the gas price in wei.
#[cfg(not(target_family = "wasm"))]
pub async fn fetch_gas_price() -> EkokeResult<u64> {
Ok(32_000_000_000_u64)
}
Expand Down Expand Up @@ -84,7 +83,7 @@ impl GasStation {

// convert result (hex repr) to u64
u64::from_str_radix(ethrpc_response.result.trim_start_matches("0x"), 16)
.map_err(|e| did::ekoke::EkokeError::EthRpcError(0, ethrpc_response.result))
.map_err(|_| did::ekoke::EkokeError::EthRpcError(0, ethrpc_response.result))
}

#[cfg(target_family = "wasm")]
Expand Down
3 changes: 2 additions & 1 deletion src/ekoke/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ pub const ETH_MIN_WITHDRAWAL_AMOUNT: u64 = 30_000_000_000_000_000;
pub const TRANSCRIBE_SWAP_TX_GAS: u64 = 71306;

#[cfg(target_family = "wasm")]
pub const SPEND_ALLOWANCE_EXPIRED_ALLOWANCE_TIMER_INTERVAL: Duration = ONE_WEEK;
pub const SPEND_ALLOWANCE_EXPIRED_ALLOWANCE_TIMER_INTERVAL: Duration =
Duration::from_secs(60 * 60 * 24 * 7); // 7 days;

#[cfg(target_family = "wasm")]
pub const LIQUIDITY_POOL_SWAP_INTERVAL: Duration = Duration::from_secs(60 * 60 * 24); // 1 day
Expand Down
12 changes: 12 additions & 0 deletions src/ekoke/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,15 @@ fn main() {
candid::export_service!();
std::print!("{}", __export_service());
}

/// GetRandom fixup to allow getrandom compilation.
/// A getrandom implementation that always fails
///
/// This is a workaround for the fact that the `getrandom` crate does not compile
/// for the `wasm32-unknown-ic` target. This is a dummy implementation that always
/// fails with `Error::UNSUPPORTED`.
pub fn getrandom_always_fail(_buf: &mut [u8]) -> Result<(), getrandom::Error> {
Err(getrandom::Error::UNSUPPORTED)
}

getrandom::register_custom_getrandom!(getrandom_always_fail);
1 change: 1 addition & 0 deletions src/marketplace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ did = []
candid = { workspace = true }
did = { path = "../did" }
dip721 = { path = "../dip721" }
getrandom = { workspace = true, features = ["custom"] }
ic-cdk = { workspace = true }
ic-cdk-macros = { workspace = true }
ic-cdk-timers = { workspace = true }
Expand Down
12 changes: 12 additions & 0 deletions src/marketplace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,15 @@ fn main() {
candid::export_service!();
std::print!("{}", __export_service());
}

/// GetRandom fixup to allow getrandom compilation.
/// A getrandom implementation that always fails
///
/// This is a workaround for the fact that the `getrandom` crate does not compile
/// for the `wasm32-unknown-ic` target. This is a dummy implementation that always
/// fails with `Error::UNSUPPORTED`.
pub fn getrandom_always_fail(_buf: &mut [u8]) -> Result<(), getrandom::Error> {
Err(getrandom::Error::UNSUPPORTED)
}

getrandom::register_custom_getrandom!(getrandom_always_fail);

0 comments on commit 7b04ae4

Please sign in to comment.