Skip to content

Commit

Permalink
Make 'to' a required argument
Browse files Browse the repository at this point in the history
  • Loading branch information
zvolin committed Aug 18, 2023
1 parent e972011 commit 2f47735
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/ethereum-canister/candid.did
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ type setup_request = record {

type estimate_gas_request = record {
from: opt address;
to: opt address;
gas: opt u256;
to: address;
gas_limit: opt u256;
gas_price: opt u256;
value: opt u256;
// Hash of the method signature and encoded parameters. See the Ethereum contract ABI specification.
data: opt blob;
};

Expand Down
2 changes: 1 addition & 1 deletion src/ethereum-canister/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl IntoCallOpts for EstimateGasRequest {
fn into_call_opts(self) -> CallOpts {
CallOpts {
from: self.from.map(Into::into),
to: self.to.map(Into::into),
to: Some(self.to.into()),
gas: self.gas_limit.map(Into::into),
gas_price: self.gas_price.map(Into::into),
value: self.value.map(Into::into),
Expand Down
13 changes: 7 additions & 6 deletions src/ethereum-canister/tests/canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ fn estimate_gas() {
.unwrap(),
};
let request = EstimateGasRequest {
to: Some(
"0xdAC17F958D2ee523a2206206994597C13D831ec7" // usdt
.parse()
.unwrap(),
),
from: None,
to: "0xdAC17F958D2ee523a2206206994597C13D831ec7" // usdt
.parse()
.unwrap(),
gas_limit: None,
gas_price: None,
value: None,
data: Some(erc20_balance_of.encode()),
..Default::default()
};

let gas: (Nat,) = call!(canister, "estimate_gas", request).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions src/interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ pub struct Erc721OwnerOfRequest {
pub token_id: U256,
}

#[derive(Debug, Clone, PartialEq, Eq, CandidType, Deserialize, Default)]
#[derive(Debug, Clone, PartialEq, Eq, CandidType, Deserialize)]
pub struct EstimateGasRequest {
pub from: Option<Address>,
pub to: Option<Address>,
pub to: Address,
pub gas_limit: Option<U256>,
pub gas_price: Option<U256>,
pub value: Option<U256>,
Expand Down

0 comments on commit 2f47735

Please sign in to comment.