Skip to content

feat: example code to sign & send Orders #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: anna/filler-ex
Choose a base branch
from

Conversation

anna-carroll
Copy link
Contributor

@anna-carroll anna-carroll commented May 1, 2025

  • construct a simple example Order
  • sign the Order
  • send the Order

@anna-carroll anna-carroll requested a review from a team as a code owner May 1, 2025 10:09
@anna-carroll anna-carroll changed the title feat feat: example code to sign & send Orders May 1, 2025
@anna-carroll anna-carroll self-assigned this May 1, 2025
Comment on lines +16 to +17
/// Empty main to silence clippy.
fn main() {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's put the main fn at the bottom

Comment on lines +12 to +14
fn token_amount(amount: u64, decimals: u32) -> U256 {
U256::from(amount * 10u64.pow(decimals))
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ParseUnits from alloy::primitives to perform this conversion—no need to implement yourself

Comment on lines +92 to +101
// input is 1 USDC on the rollup
let input = Input { token: self.ru_usdc_address, amount: one_usdc };

// output is 1 USDC on the host chain
let output = Output {
token: self.host_usdc_address,
amount: one_usdc,
chainId: self.host_chain_id as u32,
recipient: self.signer.address(),
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated to this pr, but i still think we should have builder types for these so we don't have to declare them like this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, I started working on that code already but was prioritizing this first


/// Get an example Order which swaps 1 USDC on the rollup for 1 USDC on the host.
fn example_order(&self) -> Order {
let usdc_decimals: u32 = 6;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make this a const at the top

/// Get an example Order which swaps 1 USDC on the rollup for 1 USDC on the host.
fn example_order(&self) -> Order {
let usdc_decimals: u32 = 6;
let one_usdc = token_amount(1, usdc_decimals);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we calculating this at all? it could be a file-level const const ONE_USDC = uint!(1_000_000_U256);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants