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
8 changes: 7 additions & 1 deletion cli/src/cli/deposit.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use alloy::{primitives::B256, providers::Provider};
use common::env::EnvType;
use intmax2_client_sdk::{
client::client::Client,
external_api::{
Expand Down Expand Up @@ -225,6 +226,11 @@ pub async fn fetch_predicate_permission(
let value = convert_u256_to_alloy(value);
let amount = convert_u256_to_alloy(amount);
let token_id = convert_u256_to_alloy(token_id);
let chain_id = if env.env == EnvType::Prod {
1u32
} else {
11155111u32
};
let request = match token_type {
TokenType::NATIVE => PermissionRequest::Native {
recipient_salt_hash,
Expand All @@ -249,7 +255,7 @@ pub async fn fetch_predicate_permission(
};
let from = convert_address_to_alloy(from);
let permission = predicate_client
.get_deposit_permission(from, aml_permitter_address, value, request)
.get_deposit_permission(from, aml_permitter_address, value, chain_id, request)
.await?;
Ok(permission)
}
Expand Down
6 changes: 5 additions & 1 deletion client-sdk/src/external_api/predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,28 @@ impl PredicateClient {
from: Address,
to: Address,
value: U256,
chain_id: u32,
request: PermissionRequest,
) -> Result<Vec<u8>, ServerError> {
let encoded_data = request.to_encoded_data();
self.get_permission(from, to, value, &encoded_data).await
self.get_permission(from, to, value, chain_id, &encoded_data)
.await
}

async fn get_permission(
&self,
from: Address,
to: Address,
value: U256,
chain_id: u32,
encoded_data: &[u8],
) -> Result<Vec<u8>, ServerError> {
let body = serde_json::json!({
"from": format!("{:?}", from),
"to": format!("{:?}", to),
"data": "0x".to_string() + &hex::encode(encoded_data),
"msg_value":format!("{:?}", value),
"chain_id": chain_id,
});
let response: PredicateResponse = post_request(
&self.client,
Expand Down
Loading