From 177405656db1a8f643191f3f4919c09c088a2901 Mon Sep 17 00:00:00 2001 From: Wen Sun Date: Mon, 31 Jul 2023 22:33:05 +0900 Subject: [PATCH] Updating the example of invoking actions with Go * Add checksum data to memot --- docs/guide/invoke-actions.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/guide/invoke-actions.md b/docs/guide/invoke-actions.md index db38a0a..118febd 100644 --- a/docs/guide/invoke-actions.md +++ b/docs/guide/invoke-actions.md @@ -69,13 +69,14 @@ import ( "github.com/google/uuid" "github.com/pandodao/mtg/mtgpack" "github.com/pandodao/mtg/protocol" + "github.com/pandodao/mtg/protocol/checksum" "github.com/shopspring/decimal" ) func generateSwapMemo() string { // protocol header header := protocol.Header{ - Version: 1, + Version: 2, ProtocolID: protocol.ProtocolFswap, FollowID: uuid.New(), Action: 3, @@ -105,7 +106,10 @@ func generateSwapMemo() string { if err := enc.EncodeValues(header, receiver, uuid.MustParse(assetID), route, min); err != nil { panic(err) } - return base64.StdEncoding.EncodeToString(enc.Bytes()) + + data := enc.Bytes() + data = append(data, checksum.Sha256(data)...) + return base64.StdEncoding.EncodeToString(data) } ```