Skip to content

Commit

Permalink
add parameters for wrap near and ft contract
Browse files Browse the repository at this point in the history
  • Loading branch information
telezhnaya committed May 27, 2024
1 parent 0a380b9 commit f78fd6b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ pub struct Opts {
/// Receiver account id
#[clap(long, env)]
pub receiver_id: AccountId,
/// wrap.near account id (different for testnet)
#[clap(long, env)]
pub wrap_near_id: AccountId,
/// FT account id
#[clap(long, env)]
pub ft_account_id: AccountId,
/// Transaction kind
#[clap(long, env, value_enum, default_value = "token-transfer-default")]
pub transaction_kind: TransactionKind,
Expand Down
2 changes: 1 addition & 1 deletion src/transaction/fungible_token_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl TransactionSample for FungibleTokenTransfer {
signer_id: signer.account_id.clone(),
public_key: signer.public_key.clone(),
nonce: nonce + 1,
receiver_id: "usdt.tether-token.near".parse().unwrap(),
receiver_id: opts.ft_account_id,
block_hash,
actions: vec![Action::FunctionCall(Box::new(FunctionCallAction {
method_name: "ft_transfer".to_string(),
Expand Down
8 changes: 5 additions & 3 deletions src/transaction/swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ impl TransactionSample for Swap {
fn get_transaction_request(
&self,
signer: &InMemorySigner,
_opts: Opts,
opts: Opts,
nonce: Nonce,
block_hash: CryptoHash,
) -> RpcSendTransactionRequest {
let msg = format!("{{\"actions\":[{{\"pool_id\":3879,\"token_in\":\"{}\",\"token_out\":\"{}\",\"amount_in\":\"1000000000000000000000\",\"min_amount_out\":\"1\"}}]}}", opts.wrap_near_id, opts.ft_account_id);
let transaction = Transaction {
signer_id: signer.account_id.clone(),
public_key: signer.public_key.clone(),
nonce: nonce + 1,
receiver_id: "wrap.near".parse().unwrap(),
receiver_id: opts.wrap_near_id,
block_hash,
actions: vec![
Action::FunctionCall(Box::new(FunctionCallAction {
Expand All @@ -44,7 +45,8 @@ impl TransactionSample for Swap {
})),
Action::FunctionCall(Box::new(FunctionCallAction {
method_name: "ft_transfer_call".to_string(),
args: serde_json::json!({"msg": "{\"actions\":[{\"pool_id\":3879,\"token_in\":\"wrap.near\",\"token_out\":\"usdt.tether-token.near\",\"amount_in\":\"1000000000000000000000\",\"min_amount_out\":\"1\"}]}","amount": "1000000000000000000000","receiver_id": "v2.ref-finance.near"}).to_string().into_bytes(),
args: serde_json::json!(
{"msg": msg,"amount": "1000000000000000000000","receiver_id": "v2.ref-finance.near"}).to_string().into_bytes(),
gas: 100_000_000_000_000, // 100 TeraGas
deposit: 1,
})),
Expand Down

0 comments on commit f78fd6b

Please sign in to comment.