Skip to content

Commit

Permalink
minor test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzious committed Sep 11, 2023
1 parent 33aaa46 commit a1057e2
Showing 1 changed file with 69 additions and 58 deletions.
127 changes: 69 additions & 58 deletions relayer/tst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
const TEST_CHAIN = IncentivizedTestnet(2);

const entrypointContract: string =
"nibi1436kxs0w2es6xlqpp9rd35e3d0cjnw4sv8j3a7483sgks29jqwgsn6ytm8";
"nibi1wn625s4jcmvk0szpl85rj5azkfc6suyvf75q6vrddscjdphtve8strzuwm";
const mnemonic =
"";
"";

const callFinal = async () => {
const signer = await newSignerFromMnemonic(mnemonic!);
Expand All @@ -23,71 +23,82 @@ import {
// fe signing
// const { executeContract } = cosmwasm.wasm.v1.MessageComposer.withTypeUrl;
const { executeContract } = cosmwasm.wasm.v1.MessageComposer.withTypeUrl;
let callX = JSON.stringify({
store_swap_order: {
to: "nibi1uwy6yypgyn089ls42hg8mzlrmtj575ughne06e",
order_requester: "nibi1uwy6yypgyn089ls42hg8mzlrmtj575ughne06e",
token_sell: "unibi",
token_bought: "unusd",
quantity_order: "10",
swap_upper_usd: "10",
swap_lower_usd: "10",
minimum_result_accepted_usd: "10",
max_in_sell_usd: "10",
is_token_out_order: true,
},
})
const userOp = {
Sender: fromAddr,
Pubkey: "SGVsbG9Xb3JsZA==",
To: "nibi1mf6ptkssddfmxvhdx0ech0k03ktp6kf9yk59renau2gvht3nq2gqfdzd2w",
Nonce: "0",
Calldata: Buffer.from(callX).toString("base64"), // buffer msg from fe
Signature: "SGVsbG9Xb3JsZA==", // buffer sig from fe
funds: []
};
const handleUserOp = {
"handle_user_ops": {"UserOps":[userOp]}
}

const msg1 = executeContract({
sender: fromAddr,
contract: "nibi1ec5wenydt8pe2ntjfxv6ny97jtc7t4fqnuyl8as3xepjc4udfyfs699j7a",
msg: Buffer.from(
JSON.stringify({
store_swap_order: {
to: "nibi1uwy6yypgyn089ls42hg8mzlrmtj575ughne06e",
order_requester: "nibi1uwy6yypgyn089ls42hg8mzlrmtj575ughne06e",
token_sell: "unibi",
token_bought: "unibi",
quantity_order: "1",
swap_upper_usd: "1",
swap_lower_usd: "1",
minimum_result_accepted_usd: "1",
max_in_sell_usd: "1",
is_token_out_order: true,
},
})
),
contract: entrypointContract,
msg: Buffer.from(JSON.stringify(handleUserOp)),
funds: [
{
denom: "unibi",
amount: "1",
},
// {
// denom: "unibi",
// amount: "1",
// },
],
});
console.log(msg1)
console.log('asfasf')
const sig = await signingClient.wasmClient.sign(
fromAddr,
[msg1],
{
gas: "5000000",
amount: [
{
amount: "1",
denom: "uosmo",
},
],
},
""
);
console.log('asfasf')
// console.log(sig)
// console.log(msg1.value.msg);
// const sig = await signingClient.wasmClient.sign(
// fromAddr,
// [msg1],
// {
// gas: "5000000",
// amount: [
// {
// amount: "1",
// denom: "uosmo",
// },
// ],
// },
// ""
// );
// console.log('asfasf')
// // console.log(sig)
// // console.log(msg1.value.msg);

const userOp = {
Sender: fromAddr,
To: "",
Nonce: 0,
Calldata: msg1.value.msg, // buffer msg from fe
Signature: sig.signatures[0], // buffer sig from fe
};
const msg2 = {
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
value: {
sender: fromAddr,
contract: entrypointContract,
msg: msg1.value.msg, // buffer msg from fe
sent_funds: [],
},
};
// // const userOp = {
// // Sender: fromAddr,
// // To: "",
// // Nonce: 0,
// // Calldata: callX, // buffer msg from fe
// // Signature: sig.signatures[0], // buffer sig from fe
// // };
// const msg2 = {
// typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
// value: {
// sender: fromAddr,
// contract: entrypointContract,
// msg: msg1.value.msg, // buffer msg from fe
// sent_funds: [],
// },
// };

const result = await signingClient.wasmClient.signAndBroadcast(fromAddr, [msg2], "auto");
console.log(result)
const result = await signingClient.wasmClient.signAndBroadcast(fromAddr, [msg1], "auto");
console.log(JSON.stringify(result))
};
callFinal();

0 comments on commit a1057e2

Please sign in to comment.