Skip to content
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

fix: change async_callback.id to number type #170

Merged
merged 2 commits into from
Dec 23, 2024
Merged
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
Binary file modified precompile/binaries/stdlib/minitswap.mv
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ module initia_std::ibctesting {
check_dispatch_type_compatibility_for_testing(
&dispatchable_ibc_timeout_function_info(), &function_info
);
dispatchable_ibc_timeout(async_callback.id, &function_info);
dispatchable_ibc_timeout((async_callback.id as u64), &function_info);
} else if (option::is_some(&result.async_callback)) {
let async_callback = option::destroy_some(result.async_callback);
let function_info =
Expand All @@ -218,7 +218,7 @@ module initia_std::ibctesting {
&dispatchable_ibc_ack_function_info(), &function_info
);
dispatchable_ibc_ack(
async_callback.id, result.success, &function_info
(async_callback.id as u64), result.success, &function_info
);
};
}
Expand Down Expand Up @@ -401,7 +401,7 @@ module initia_std::ibctesting {
}

struct MoveAsyncCallback has copy, drop, store {
id: u64,
id: u32,
module_address: address,
module_name: String
}
Expand Down
29 changes: 23 additions & 6 deletions precompile/modules/initia_stdlib/sources/minitswap.move
Original file line number Diff line number Diff line change
Expand Up @@ -2315,17 +2315,34 @@ module initia_std::minitswap {
evm: Option<MemoEvm>
}

struct IBCMemoV2 has copy, drop {
_move_: MemoMoveV2,
wasm: Option<MemoWasm>,
evm: Option<MemoEvm>
}

struct MemoMove has copy, drop {
message: Option<MemoMoveMessage>,
async_callback: MemoAsyncCallback
}

struct MemoMoveV2 has copy, drop {
message: Option<MemoMoveMessage>,
async_callback: MemoAsyncCallbackV2
}

struct MemoAsyncCallback has copy, drop {
id: u64,
module_address: address,
module_name: String
}

struct MemoAsyncCallbackV2 has copy, drop {
id: u32, // Use u32 instead of u64 to keep it as number type after json marshal.
module_address: address,
module_name: String
}

struct MemoMoveMessage has copy, drop {
module_address: String,
module_name: String,
Expand Down Expand Up @@ -2381,11 +2398,11 @@ module initia_std::minitswap {
op_denom: String,
amount: u64
): (String, String) {
let memo = IBCMemo {
_move_: MemoMove {
let memo = IBCMemoV2 {
_move_: MemoMoveV2 {
message: option::none(),
async_callback: MemoAsyncCallback {
id: batch_index,
async_callback: MemoAsyncCallbackV2 {
id: (batch_index as u32),
module_address: @initia_std,
module_name: string::utf8(b"minitswap")
}
Expand Down Expand Up @@ -3419,7 +3436,7 @@ module initia_std::minitswap {
assert!(
memo
== string::utf8(
b"{\"evm\":null,\"move\":{\"async_callback\":{\"id\":\"1\",\"module_address\":\"0x1\",\"module_name\":\"minitswap\"},\"message\":{\"args\":[\"CG9wX2Rlbm9t\",\"QEIPAAAAAAA=\",\"CHJlY2VpdmVy\"],\"function_name\":\"minitswap_hook\",\"module_address\":\"0x1\",\"module_name\":\"minitswap_hook\",\"type_args\":[]}},\"wasm\":null}"
b"{\"evm\":null,\"move\":{\"async_callback\":{\"id\":1,\"module_address\":\"0x1\",\"module_name\":\"minitswap\"},\"message\":{\"args\":[\"CG9wX2Rlbm9t\",\"QEIPAAAAAAA=\",\"CHJlY2VpdmVy\"],\"function_name\":\"minitswap_hook\",\"module_address\":\"0x1\",\"module_name\":\"minitswap_hook\",\"type_args\":[]}},\"wasm\":null}"
),
1
);
Expand All @@ -3438,7 +3455,7 @@ module initia_std::minitswap {
assert!(
memo
== string::utf8(
b"{\"evm\":null,\"move\":{\"async_callback\":{\"id\":\"1\",\"module_address\":\"0x1\",\"module_name\":\"minitswap\"},\"message\":null},\"wasm\":{\"message\":{\"contracts\":\"cosmwasm_contract_addr\",\"funds\":[{\"amount\":\"1000000\",\"denom\":\"op_denom\"}],\"msg\":{\"minitswap_hook\":{\"receiver\":\"receiver\"}}}}}"
b"{\"evm\":null,\"move\":{\"async_callback\":{\"id\":1,\"module_address\":\"0x1\",\"module_name\":\"minitswap\"},\"message\":null},\"wasm\":{\"message\":{\"contracts\":\"cosmwasm_contract_addr\",\"funds\":[{\"amount\":\"1000000\",\"denom\":\"op_denom\"}],\"msg\":{\"minitswap_hook\":{\"receiver\":\"receiver\"}}}}}"
),
3
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ module cafe::ibc_transfer_tests {
},
timeout_timestamp: 0u64, // timeout timestamp is not used in this test
memo: string::utf8(
b"{\"move\":{\"async_callback\":{\"id\": \"103\", \"module_address\": \"0xcafe\", \"module_name\": \"ibc_transfer_tests_helpers\"}}}"
b"{\"move\":{\"async_callback\":{\"id\": 103, \"module_address\": \"0xcafe\", \"module_name\": \"ibc_transfer_tests_helpers\"}}}"
)
};

Expand Down Expand Up @@ -362,7 +362,7 @@ module cafe::ibc_transfer_tests {
},
timeout_timestamp: 0u64, // timeout timestamp is not used in this test
memo: string::utf8(
b"{\"move\":{\"async_callback\":{\"id\": \"103\", \"module_address\": \"0xcafe\", \"module_name\": \"ibc_transfer_tests_helpers\"}}}"
b"{\"move\":{\"async_callback\":{\"id\": 103, \"module_address\": \"0xcafe\", \"module_name\": \"ibc_transfer_tests_helpers\"}}}"
)
};

Expand Down Expand Up @@ -441,7 +441,7 @@ module cafe::ibc_transfer_tests {
},
timeout_timestamp: 0u64, // timeout timestamp is not used in this test
memo: string::utf8(
b"{\"move\":{\"async_callback\":{\"id\": \"103\", \"module_address\": \"0xcafe\", \"module_name\": \"ibc_transfer_tests_helpers\"}}}"
b"{\"move\":{\"async_callback\":{\"id\": 103, \"module_address\": \"0xcafe\", \"module_name\": \"ibc_transfer_tests_helpers\"}}}"
)
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ module minitia_std::ibctesting {
check_dispatch_type_compatibility_for_testing(
&dispatchable_ibc_timeout_function_info(), &function_info
);
dispatchable_ibc_timeout(async_callback.id, &function_info);
dispatchable_ibc_timeout((async_callback.id as u64), &function_info);
} else if (option::is_some(&result.async_callback)) {
let async_callback = option::destroy_some(result.async_callback);
let function_info =
Expand All @@ -218,7 +218,7 @@ module minitia_std::ibctesting {
&dispatchable_ibc_ack_function_info(), &function_info
);
dispatchable_ibc_ack(
async_callback.id, result.success, &function_info
(async_callback.id as u64), result.success, &function_info
);
};
}
Expand Down Expand Up @@ -401,7 +401,7 @@ module minitia_std::ibctesting {
}

struct MoveAsyncCallback has copy, drop, store {
id: u64,
id: u32,
module_address: address,
module_name: String
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ module cafe::ibc_transfer_tests {
},
timeout_timestamp: 0u64, // timeout timestamp is not used in this test
memo: string::utf8(
b"{\"move\":{\"async_callback\":{\"id\": \"103\", \"module_address\": \"0xcafe\", \"module_name\": \"ibc_transfer_tests_helpers\"}}}"
b"{\"move\":{\"async_callback\":{\"id\": 103, \"module_address\": \"0xcafe\", \"module_name\": \"ibc_transfer_tests_helpers\"}}}"
)
};

Expand Down Expand Up @@ -362,7 +362,7 @@ module cafe::ibc_transfer_tests {
},
timeout_timestamp: 0u64, // timeout timestamp is not used in this test
memo: string::utf8(
b"{\"move\":{\"async_callback\":{\"id\": \"103\", \"module_address\": \"0xcafe\", \"module_name\": \"ibc_transfer_tests_helpers\"}}}"
b"{\"move\":{\"async_callback\":{\"id\": 103, \"module_address\": \"0xcafe\", \"module_name\": \"ibc_transfer_tests_helpers\"}}}"
)
};

Expand Down Expand Up @@ -441,7 +441,7 @@ module cafe::ibc_transfer_tests {
},
timeout_timestamp: 0u64, // timeout timestamp is not used in this test
memo: string::utf8(
b"{\"move\":{\"async_callback\":{\"id\": \"103\", \"module_address\": \"0xcafe\", \"module_name\": \"ibc_transfer_tests_helpers\"}}}"
b"{\"move\":{\"async_callback\":{\"id\": 103, \"module_address\": \"0xcafe\", \"module_name\": \"ibc_transfer_tests_helpers\"}}}"
)
};

Expand Down
Loading