Skip to content

Commit

Permalink
Merge pull request #542 from PeggyJV/collin/go-package-v4
Browse files Browse the repository at this point in the history
Gravity v4
  • Loading branch information
zmanian committed Sep 12, 2023
2 parents 143c0cb + c505b4d commit c22987f
Show file tree
Hide file tree
Showing 114 changed files with 1,850 additions and 4,412 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/automated-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: setup-go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.19
# Setup Rust Environment
- name: setup-rust
uses: actions-rs/toolchain@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.19
- name: Checkout Branch
uses: actions/checkout@v2
- name: Create Go cache
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ jobs:
packages: write
runs-on: ubuntu-20.04
steps:
- name: Set up Go 1.18
- name: Set up Go 1.19
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.19
- name: checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
Expand Down Expand Up @@ -228,10 +228,10 @@ jobs:
]

steps:
- name: Set up Go 1.18
- name: Set up Go 1.19
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.19
- name: checkout
uses: actions/checkout@v2
- name: go-cache
Expand Down
31 changes: 12 additions & 19 deletions integration_tests/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package integration_tests

import (
"fmt"
"io/ioutil"
"os"

"github.com/cosmos/cosmos-sdk/client"
Expand All @@ -21,9 +20,9 @@ import (
sdkTx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/peggyjv/gravity-bridge/module/v3/app"
"github.com/peggyjv/gravity-bridge/module/v3/app/params"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v3/x/gravity/types"
"github.com/peggyjv/gravity-bridge/module/v4/app"
"github.com/peggyjv/gravity-bridge/module/v4/app/params"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
tmrand "github.com/tendermint/tendermint/libs/rand"
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
)
Expand Down Expand Up @@ -73,7 +72,7 @@ func newChain() (*chain, error) {
}
}

tmpDir, err := ioutil.TempDir(dir, "gravity-bridge-e2e-testnet")
tmpDir, err := os.MkdirTemp(dir, "gravity-bridge-e2e-testnet")
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -167,7 +166,7 @@ func (c *chain) createAndInitOrchestratorsWithMnemonics(mnemonics []string) erro
return err
}

orchestrator.keyInfo = *info
orchestrator.keyRecord = *info
orchestrator.mnemonic = mnemonics[i]
orchestrator.keyring = kb

Expand Down Expand Up @@ -249,7 +248,6 @@ func (c *chain) sendMsgs(clientCtx client.Context, msgs ...sdk.Msg) (*sdk.TxResp
WithSignMode(signing.SignMode_SIGN_MODE_DIRECT)

fromAddr := clientCtx.GetFromAddress()
fromName := clientCtx.GetFromName()

if err := txf.AccountRetriever().EnsureExists(clientCtx, fromAddr); err != nil {
return nil, err
Expand All @@ -271,29 +269,24 @@ func (c *chain) sendMsgs(clientCtx client.Context, msgs ...sdk.Msg) (*sdk.TxResp
}
}

txf.WithFees("246913560testgb")
txf = txf.WithFees("246913560testgb")

txb, err := tx.BuildUnsignedTx(txf, msgs...)
err := tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msgs...)
if err != nil {
return nil, err
}

txb.SetFeeAmount(sdk.Coins{{Denom: "testgb", Amount: sdk.NewInt(246913560)}})

err = tx.Sign(txf, fromName, txb, false)
if err != nil {
return nil, err
}

txBytes, err := clientCtx.TxConfig.TxEncoder()(txb.GetTx())
resBytes := []byte{}
_, err = clientCtx.Input.Read(resBytes)
if err != nil {
return nil, err
}

res, err := clientCtx.BroadcastTx(txBytes)
var res sdk.TxResponse
err = cdc.Unmarshal(resBytes, &res)
if err != nil {
return nil, err
}

return res, nil
return &res, nil
}
13 changes: 7 additions & 6 deletions integration_tests/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (
"math/big"
"strings"

"cosmossdk.io/errors"
sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v3/x/gravity/types"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
)

type EthereumConfig struct {
Expand Down Expand Up @@ -137,11 +138,11 @@ const stateLastValsetNonceABIJSON = `[
func packCall(abiString, method string, args []interface{}) []byte {
encodedCall, err := abi.JSON(strings.NewReader(abiString))
if err != nil {
panic(sdkerrors.Wrap(err, "bad ABI definition in code"))
panic(errors.Wrap(err, "bad ABI definition in code"))
}
abiEncodedCall, err := encodedCall.Pack(method, args...)
if err != nil {
panic(sdkerrors.Wrap(err, "error packing calling"))
panic(errors.Wrap(err, "error packing calling"))
}
return abiEncodedCall
}
Expand All @@ -155,7 +156,7 @@ func PackDeployERC20(denom string, name string, symbol string, decimals uint8) [
})
}

func PackSendToCosmos(tokenContract common.Address, destination sdk.AccAddress, amount sdk.Int) []byte {
func PackSendToCosmos(tokenContract common.Address, destination sdk.AccAddress, amount sdkmath.Int) []byte {
destinationBytes, _ := byteArrayToFixByteArray(destination.Bytes())
return packCall(gravitytypes.SendToCosmosABIJSON, "sendToCosmos", []interface{}{
tokenContract,
Expand Down Expand Up @@ -192,7 +193,7 @@ func PackLastValsetNonce() []byte {
return packCall(stateLastValsetNonceABIJSON, "state_lastValsetNonce", []interface{}{})
}

func UnpackEthUInt(bz []byte) sdk.Int {
func UnpackEthUInt(bz []byte) sdkmath.Int {
output := big.NewInt(0)
output.SetBytes(bz)

Expand Down
Loading

0 comments on commit c22987f

Please sign in to comment.