Skip to content

Commit

Permalink
add base54 encoding and decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Apr 15, 2024
1 parent ce24f6f commit b1678ec
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
e2etests.TestERC20DepositRestrictedName,
}
zetaTests := []string{
e2etests.TestMessagePassingZEVMName,
e2etests.TestZetaWithdrawName,
e2etests.TestMessagePassingName,
e2etests.TestMessagePassingZEVMName,
e2etests.TestMessagePassingRevertFailName,
e2etests.TestMessagePassingRevertSuccessName,
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ require (
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15
github.com/zeta-chain/go-tss v0.1.1-0.20240208222330-f3be0d4a0d98
github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240409202853-ee53ce11c29f
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240415192848-ad076a028d30
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f
gopkg.in/yaml.v2 v2.4.0
)
Expand Down
10 changes: 8 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1855,6 +1855,7 @@ github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8
github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk=
github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps=
github.com/ipfs/go-ipfs-util v0.0.2 h1:59Sswnk1MFaiq+VcaknX7aYEyGyGDAA73ilhEK2POp8=
github.com/ipfs/go-ipfs-util v0.0.2/go.mod h1:CbPtkWJzjLdEcezDns2XYaehFVNXG9zrdrtMecczcsQ=
github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8=
github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo=
github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g=
Expand Down Expand Up @@ -2771,6 +2772,7 @@ github.com/sourcegraph/go-diff v0.5.1/go.mod h1:j2dHj3m8aZgQO8lMTcTnBcXkRRRqi34c
github.com/sourcegraph/go-diff v0.5.3/go.mod h1:v9JDtjCE4HHHCZGId75rg8gkKKa98RVjBcBGsVmMmak=
github.com/sourcegraph/go-diff v0.6.1/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs=
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572/go.mod h1:w0SWMsp6j9O/dk4/ZpIhL+3CkG8ofA2vuv7k+ltqUMc=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
Expand Down Expand Up @@ -3054,8 +3056,12 @@ github.com/zeta-chain/go-tss v0.1.1-0.20240208222330-f3be0d4a0d98 h1:GCSRgszQbAR
github.com/zeta-chain/go-tss v0.1.1-0.20240208222330-f3be0d4a0d98/go.mod h1:+lJfk/qqt+oxXeVuJV+PzpUoxftUfoTRf2eF3qlbyFI=
github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2 h1:gd2uE0X+ZbdFJ8DubxNqLbOVlCB12EgWdzSNRAR82tM=
github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2/go.mod h1:x7Bkwbzt2W2lQfjOirnff0Dj+tykdbTG1FMJPVPZsvE=
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240409202853-ee53ce11c29f h1:CybkB7TrE025xTzapribnshq4PEA/EAGH6AxIRAqBFI=
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240409202853-ee53ce11c29f/go.mod h1:v79f+eY6PMpmLv188FAubst4XV2Mm8mUmx1OgmdFG3c=
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240415173111-d7407762b0d6 h1:5MPsY8ktDn5LMrJ19PaTCnbAHfnAgQ/3Ea/p5vV6Gd8=
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240415173111-d7407762b0d6/go.mod h1:v79f+eY6PMpmLv188FAubst4XV2Mm8mUmx1OgmdFG3c=
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240415174839-9598d475188f h1:DZv7FnSR2WllH5QyDRWlmTUCdqG90eYGE1KlCxFaFYc=
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240415174839-9598d475188f/go.mod h1:v79f+eY6PMpmLv188FAubst4XV2Mm8mUmx1OgmdFG3c=
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240415192848-ad076a028d30 h1:V1Kl0xLsdL2l9ThMEx/NLqRvr8zTAAyq2IoM+nhPMhE=
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240415192848-ad076a028d30/go.mod h1:v79f+eY6PMpmLv188FAubst4XV2Mm8mUmx1OgmdFG3c=
github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM=
github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U=
github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM=
Expand Down
6 changes: 5 additions & 1 deletion x/crosschain/keeper/evm_deposit.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keeper

import (
"encoding/base64"
"encoding/hex"
"fmt"

Expand All @@ -27,7 +28,10 @@ func (k Keeper) HandleEVMDeposit(ctx sdk.Context, cctx *types.CrossChainTx) (boo
inboundSender := cctx.GetInboundTxParams().Sender
inboundSenderChainID := cctx.GetInboundTxParams().SenderChainId
inboundCoinType := cctx.InboundTxParams.CoinType
data := []byte(cctx.RelayedMessage)
data, err := base64.StdEncoding.DecodeString(cctx.RelayedMessage)
if err != nil {
return false, errors.Wrap(types.ErrUnableToDecodeMessageString, err.Error())
}
if len(ctx.TxBytes()) > 0 {
// add event for tendermint transaction hash format
hash := tmbytes.HexBytes(tmtypes.Tx(ctx.TxBytes()).Hash())
Expand Down
4 changes: 2 additions & 2 deletions x/crosschain/keeper/evm_hooks.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keeper

import (
"encoding/base64"
"encoding/hex"
"fmt"
"math/big"
Expand Down Expand Up @@ -224,8 +225,7 @@ func (k Keeper) ProcessZetaSentEvent(ctx sdk.Context, event *connectorzevm.ZetaC
return fmt.Errorf("ProcessZetaSentEvent: failed to convert chainID: %s", err.Error())
}
amount := math.NewUintFromBigInt(event.ZetaValueAndGas)
// TODO : check encoding and decoding of message
messageString := string(event.Message[:])
messageString := base64.StdEncoding.EncodeToString(event.Message)
// Bump gasLimit by event index (which is very unlikely to be larger than 1000) to always have different ZetaSent events msgs.
msg := types.NewMsgVoteOnObservedInboundTx(
"",
Expand Down
1 change: 1 addition & 0 deletions x/crosschain/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ var (
ErrUnableProcessRefund = errorsmod.Register(ModuleName, 1148, "unable to process refund")
ErrUnableToFindZetaAccounting = errorsmod.Register(ModuleName, 1149, "unable to find zeta accounting")
ErrInsufficientZetaAmount = errorsmod.Register(ModuleName, 1150, "insufficient zeta amount")
ErrUnableToDecodeMessageString = errorsmod.Register(ModuleName, 1151, "unable to decode message bytes")
)

0 comments on commit b1678ec

Please sign in to comment.