diff --git a/x/feeabs/types/build_memo.go b/x/feeabs/types/build_memo.go index 681cc75..8d34031 100644 --- a/x/feeabs/types/build_memo.go +++ b/x/feeabs/types/build_memo.go @@ -62,16 +62,14 @@ func NewOsmosisSwapMsg(inputCoin sdk.Coin, outputDenom string, slippagePercentag } // ParseMsgToMemo build a memo from msg, contractAddr, compatible with ValidateAndParseMemo in https://github.com/osmosis-labs/osmosis/blob/nicolas/crosschain-swaps-new/x/ibc-hooks/wasm_hook.go -func ParseMsgToMemo(msg OsmosisSwapMsg, contractAddr string, receiverAddress string, chainName string) (string, error) { +func ParseMsgToMemo(msg OsmosisSwapMsg, contractAddr string) (string, error) { // TODO: need to validate the msg && contract address - receiver := fmt.Sprintf("%s/%s", chainName, receiverAddress) memo := OsmosisSpecialMemo{ Wasm: make(map[string]interface{}), } memo.Wasm["contract"] = contractAddr memo.Wasm["msg"] = msg - memo.Wasm["receiver"] = receiver memo_marshalled, err := json.Marshal(&memo) if err != nil { @@ -82,7 +80,8 @@ func ParseMsgToMemo(msg OsmosisSwapMsg, contractAddr string, receiverAddress str // TODO: write test for this // BuildNextMemo create memo for IBC hook, this execute `CrossChainSwap contract` -func BuildCrossChainSwapMemo(outputDenom string, contractAddress, receiver string, chainName string) (string, error) { +func BuildCrossChainSwapMemo(outputDenom string, contractAddress string, receiverAddress string, chainName string) (string, error) { + receiver := fmt.Sprintf("%s/%s", chainName, receiverAddress) swap := Swap{ OutPutDenom: outputDenom, Slippage: Twap{ @@ -98,7 +97,7 @@ func BuildCrossChainSwapMemo(outputDenom string, contractAddress, receiver strin msgSwap := OsmosisSwapMsg{ OsmosisSwap: swap, } - nextMemo, err := ParseMsgToMemo(msgSwap, contractAddress, receiver, chainName) + nextMemo, err := ParseMsgToMemo(msgSwap, contractAddress) if err != nil { return "", err } diff --git a/x/feeabs/types/build_memo_test.go b/x/feeabs/types/build_memo_test.go index 0df9115..48f0cb5 100644 --- a/x/feeabs/types/build_memo_test.go +++ b/x/feeabs/types/build_memo_test.go @@ -26,11 +26,9 @@ func TestParseMsgToMemo(t *testing.T) { } mockAddress := "cosmos123456789" - mockReceiver := "cosmos123456789" - chainName := "feeappd-t1" //TODO: need to check assert msg - _, err := types.ParseMsgToMemo(msgSwap, mockAddress, mockReceiver, chainName) + _, err := types.ParseMsgToMemo(msgSwap, mockAddress) require.NoError(t, err) } @@ -38,10 +36,10 @@ func TestParseMsgToMemo(t *testing.T) { func TestParseCrossChainSwapMsgToMemo(t *testing.T) { outPutDenom := "uosmo" contractAddress := "osmo1c3ljch9dfw5kf52nfwpxd2zmj2ese7agnx0p9tenkrryasrle5sqf3ftpg" - mockReceiver := "osmo1cd4nn8yzdrrsfqsmmvaafq8r03xn38qgqt8fzh" - chainName := "feeappd-t1" + mockReceiver := "feeabs1efd63aw40lxf3n4mhf7dzhjkr453axurwrhrrw" + chainName := "feeabs" - execepted_memo_str := `{"wasm":{"contract":"osmo1c3ljch9dfw5kf52nfwpxd2zmj2ese7agnx0p9tenkrryasrle5sqf3ftpg","msg":{"osmosis_swap":{"output_denom":"uosmo","slippage":{"twap":{"slippage_percentage":"20","window_seconds":10}},"receiver":"osmo1cd4nn8yzdrrsfqsmmvaafq8r03xn38qgqt8fzh","on_failed_delivery":"do_nothing"}},"receiver":"feeappd-t1/osmo1cd4nn8yzdrrsfqsmmvaafq8r03xn38qgqt8fzh"}}` + execepted_memo_str := `{"wasm":{"contract":"osmo1c3ljch9dfw5kf52nfwpxd2zmj2ese7agnx0p9tenkrryasrle5sqf3ftpg","msg":{"osmosis_swap":{"output_denom":"uosmo","slippage":{"twap":{"slippage_percentage":"20","window_seconds":10}},"receiver":"feeabs/feeabs1efd63aw40lxf3n4mhf7dzhjkr453axurwrhrrw","on_failed_delivery":"do_nothing"}}}}` //TODO: need to check assert msg memo_str, err := types.BuildCrossChainSwapMemo(outPutDenom, contractAddress, mockReceiver, chainName)