Skip to content

Commit

Permalink
Merge branch 'main' of github.com:icon-project/intent-contracts into …
Browse files Browse the repository at this point in the history
…deployment/sui-intent-testnet
  • Loading branch information
gcranju committed Nov 29, 2024
2 parents 19b6783 + b7ad2c8 commit 8efa4e6
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 2 deletions.
73 changes: 72 additions & 1 deletion contracts/sui/intent_v1/sources/main.move
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,11 @@ module intents_v1::main {
};

let order=swap_order::decode(&bytes);
let token_type=order.get_token();
let token_type=if(order.get_src_nid()==string::utf8(b"sui")){
order.get_token()
}else{
order.get_to_token()
};

let mut type_args:vector<String> = vector::empty();
type_args.push_back(token_type);
Expand All @@ -420,6 +424,9 @@ module intents_v1::main {


}
public fun get_type_args(self:&Params):vector<String>{
self.type_args
}

entry fun get_receipt(self:&Storage,nid:String,conn_sn:u128):bool {
self.connection.get_receipt(nid, conn_sn)
Expand Down Expand Up @@ -447,6 +454,10 @@ module intents_v1::main {
&self.funds
}

public fun get_finished_orders(self:&Storage):&Table<vector<u8>,bool> {
&self.finished_orders
}

public fun get_id(self:&Storage):ID {
self.id.to_inner()
}
Expand Down Expand Up @@ -489,6 +500,7 @@ module intents_v1::main_tests {
use intents_v1::utils::id_to_hex_string;
use intents_v1::main::{insert_order};
use sui::sui::{SUI as RSUI};
use sui::hash::keccak256;
use intents_v1::utils::{get_type_string,address_to_hex_string};

// Test coin type
Expand Down Expand Up @@ -1198,4 +1210,63 @@ module intents_v1::main_tests {
};
test_scenario::end(scenario);
}

#[test]
fun test_recv_message_cancel_decoding() {
let admin=@0x1;
let mut scenario = setup_test(admin);
test_scenario::next_tx(&mut scenario, @0x1);
{
let mut storage = test_scenario::take_shared<Storage>(&scenario);
let ctx = test_scenario::ctx(&mut scenario);



let msg = order_message::decode(&x"f9017702b90173f90170b9016df9016a5aaa3078353345303039354335373637336643313666413346413234313462414433323030383434456331378f3078613462312e617262697472756d83737569aa307864433444373261373046396435343841463933373946343245364146383137323862326331643931b842307863656563613764623033366430373962333139333838366662656662653738663734356432313538396437363132643766346638383031663537386639343463aa307830303030303030303030303030303030303030303030303030303030303030303030303030303030872386f26fc10000b84a303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030323a3a7375693a3a5355498500b1ff400db57b2271756f74655f75756964223a2266316230306563302d666634632d343135302d616530332d353639636434376263663565227d");
let cancel = order_cancel::decode(&msg.get_message());
let order= swap_order::decode(&cancel.get_order_bytes());
std::debug::print(&order);

main::receive_message<USDC>(
&mut storage,
string::utf8(b"0xa4b1.arbitrum"),
1,
order_message::encode(&msg),
ctx
);

assert!(*main::get_finished_orders(&storage).borrow<vector<u8>,bool>(keccak256(&order.encode())));

test_scenario::return_shared(storage);
};
test_scenario::end(scenario);
}

#[test]
fun test_get_relayer_params(){

let admin=@0x1;
let mut scenario = setup_test(admin);
test_scenario::next_tx(&mut scenario, @0x1);
{
let mut storage = test_scenario::take_shared<Storage>(&scenario);
let ctx = test_scenario::ctx(&mut scenario);
let msg = order_message::decode(&x"f9017702b90173f90170b9016df9016a5aaa3078353345303039354335373637336643313666413346413234313462414433323030383434456331378f3078613462312e617262697472756d83737569aa307864433444373261373046396435343841463933373946343245364146383137323862326331643931b842307863656563613764623033366430373962333139333838366662656662653738663734356432313538396437363132643766346638383031663537386639343463aa307830303030303030303030303030303030303030303030303030303030303030303030303030303030872386f26fc10000b84a303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030323a3a7375693a3a5355498500b1ff400db57b2271756f74655f75756964223a2266316230306563302d666634632d343135302d616530332d353639636434376263663565227d");
let cancel = order_cancel::decode(&msg.get_message());
let order= swap_order::decode(&cancel.get_order_bytes());
std::debug::print(&order);

let args= main::get_receive_msg_args(
&storage,
msg.encode()

);

std::debug::print(&args);
assert!((*args.get_type_args().borrow(0))==string::utf8(b"0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"));
test_scenario::return_shared(storage);
};
test_scenario::end(scenario);

}
}
2 changes: 1 addition & 1 deletion scripts/optimize-move.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e
# contracts
CONTRACTS=("contracts/sui/intent_v1" "contracts/sui/libs/sui_rlp" )
CONTRACTS=("contracts/sui/intent_v1")

#cargo install --locked --git https://github.com/MystenLabs/sui.git --branch testnet sui
start_dir=$(pwd)
Expand Down

0 comments on commit 8efa4e6

Please sign in to comment.