Skip to content

Commit

Permalink
Merge pull request #265 from multiversx/new-sdk-version-2023.05.31
Browse files Browse the repository at this point in the history
New go SDK version
  • Loading branch information
dragos-rebegea authored Jul 3, 2023
2 parents c053115 + c313c93 commit af4ba09
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 75 deletions.
7 changes: 4 additions & 3 deletions clients/multiversx/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package multiversx
import (
"context"

"github.com/multiversx/mx-chain-core-go/data/transaction"
"github.com/multiversx/mx-sdk-go/builders"
"github.com/multiversx/mx-sdk-go/core"
"github.com/multiversx/mx-sdk-go/data"
Expand All @@ -11,8 +12,8 @@ import (
// Proxy defines the behavior of a proxy able to serve MultiversX blockchain requests
type Proxy interface {
GetNetworkConfig(ctx context.Context) (*data.NetworkConfig, error)
SendTransaction(ctx context.Context, tx *data.Transaction) (string, error)
SendTransactions(ctx context.Context, txs []*data.Transaction) ([]string, error)
SendTransaction(ctx context.Context, tx *transaction.FrontendTransaction) (string, error)
SendTransactions(ctx context.Context, txs []*transaction.FrontendTransaction) ([]string, error)
ExecuteVMQuery(ctx context.Context, vmRequest *data.VmValueRequest) (*data.VmValuesResponseData, error)
GetAccount(ctx context.Context, address core.AddressHandler) (*data.Account, error)
GetNetworkStatus(ctx context.Context, shardID uint32) (*data.NetworkStatus, error)
Expand All @@ -23,7 +24,7 @@ type Proxy interface {
// NonceTransactionsHandler represents the interface able to handle the current nonce and the transactions resend mechanism
type NonceTransactionsHandler interface {
GetNonce(ctx context.Context, address core.AddressHandler) (uint64, error)
SendTransaction(ctx context.Context, tx *data.Transaction) (string, error)
SendTransaction(ctx context.Context, tx *transaction.FrontendTransaction) (string, error)
Close() error
}

Expand Down
12 changes: 6 additions & 6 deletions clients/multiversx/transactionHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"encoding/hex"
"encoding/json"

"github.com/multiversx/mx-chain-core-go/data/transaction"
crypto "github.com/multiversx/mx-chain-crypto-go"
"github.com/multiversx/mx-sdk-go/builders"
"github.com/multiversx/mx-sdk-go/core"
"github.com/multiversx/mx-sdk-go/data"
)

type transactionHandler struct {
Expand All @@ -34,7 +34,7 @@ func (txHandler *transactionHandler) SendTransactionReturnHash(ctx context.Conte
return txHandler.nonceTxHandler.SendTransaction(context.Background(), tx)
}

func (txHandler *transactionHandler) signTransaction(ctx context.Context, builder builders.TxDataBuilder, gasLimit uint64) (*data.Transaction, error) {
func (txHandler *transactionHandler) signTransaction(ctx context.Context, builder builders.TxDataBuilder, gasLimit uint64) (*transaction.FrontendTransaction, error) {
networkConfig, err := txHandler.proxy.GetNetworkConfig(ctx)
if err != nil {
return nil, err
Expand All @@ -50,15 +50,15 @@ func (txHandler *transactionHandler) signTransaction(ctx context.Context, builde
return nil, err
}

tx := &data.Transaction{
tx := &transaction.FrontendTransaction{
ChainID: networkConfig.ChainID,
Version: networkConfig.MinTransactionVersion,
GasLimit: gasLimit,
GasPrice: networkConfig.MinGasPrice,
Nonce: nonce,
Data: dataBytes,
SndAddr: txHandler.relayerAddress.AddressAsBech32String(),
RcvAddr: txHandler.multisigAddressAsBech32,
Sender: txHandler.relayerAddress.AddressAsBech32String(),
Receiver: txHandler.multisigAddressAsBech32,
Value: "0",
}

Expand All @@ -71,7 +71,7 @@ func (txHandler *transactionHandler) signTransaction(ctx context.Context, builde
}

// signTransactionWithPrivateKey signs a transaction with the client's private key
func (txHandler *transactionHandler) signTransactionWithPrivateKey(tx *data.Transaction) error {
func (txHandler *transactionHandler) signTransactionWithPrivateKey(tx *transaction.FrontendTransaction) error {
tx.Signature = ""
bytes, err := json.Marshal(&tx)
if err != nil {
Expand Down
9 changes: 5 additions & 4 deletions clients/multiversx/transactionHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
cryptoMock "github.com/multiversx/mx-bridge-eth-go/testsCommon/crypto"
"github.com/multiversx/mx-bridge-eth-go/testsCommon/interactors"
"github.com/multiversx/mx-bridge-eth-go/testsCommon/roleProviders"
"github.com/multiversx/mx-chain-core-go/data/transaction"
"github.com/multiversx/mx-chain-crypto-go"
"github.com/multiversx/mx-chain-crypto-go/signing/ed25519/singlesig"
"github.com/multiversx/mx-sdk-go/builders"
Expand Down Expand Up @@ -106,7 +107,7 @@ func TestTransactionHandler_SendTransactionReturnHash(t *testing.T) {
},
}
txHandlerInstance.nonceTxHandler = &bridgeTests.NonceTransactionsHandlerStub{
SendTransactionCalled: func(ctx context.Context, tx *data.Transaction) (string, error) {
SendTransactionCalled: func(ctx context.Context, tx *transaction.FrontendTransaction) (string, error) {
wasSendTransactionCalled = true
return "", nil
},
Expand Down Expand Up @@ -146,10 +147,10 @@ func TestTransactionHandler_SendTransactionReturnHash(t *testing.T) {

return 0, errors.New("unexpected address to fetch the nonce")
},
SendTransactionCalled: func(ctx context.Context, tx *data.Transaction) (string, error) {
SendTransactionCalled: func(ctx context.Context, tx *transaction.FrontendTransaction) (string, error) {
sendWasCalled = true
assert.Equal(t, relayerAddress, tx.SndAddr)
assert.Equal(t, testMultisigAddress, tx.RcvAddr)
assert.Equal(t, relayerAddress, tx.Sender)
assert.Equal(t, testMultisigAddress, tx.Receiver)
assert.Equal(t, nonce, tx.Nonce)
assert.Equal(t, "0", tx.Value)
assert.Equal(t, "function@62756666@16", string(tx.Data))
Expand Down
25 changes: 13 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ require (
github.com/gin-contrib/cors v1.4.0
github.com/gin-contrib/pprof v1.4.0
github.com/gin-gonic/gin v1.8.1
github.com/multiversx/mx-chain-core-go v1.1.30
github.com/multiversx/mx-chain-core-go v1.1.33
github.com/multiversx/mx-chain-crypto-go v1.2.5
github.com/multiversx/mx-chain-go v1.4.4
github.com/multiversx/mx-chain-go v1.4.15
github.com/multiversx/mx-chain-logger-go v1.0.11
github.com/multiversx/mx-chain-p2p-go v1.0.10
github.com/multiversx/mx-sdk-go v1.2.5
github.com/multiversx/mx-sdk-go v1.3.2
github.com/stretchr/testify v1.8.1
github.com/urfave/cli v1.22.10
)
Expand Down Expand Up @@ -57,19 +57,19 @@ require (
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/herumi/bls-go-binary v1.0.0 // indirect
github.com/huin/goupnp v1.0.3 // indirect
github.com/ipfs/go-cid v0.2.0 // indirect
github.com/ipfs/go-cid v0.3.2 // indirect
github.com/ipfs/go-datastore v0.5.1 // indirect
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
github.com/ipfs/go-ipns v0.2.0 // indirect
github.com/ipfs/go-log v1.0.5 // indirect
github.com/ipfs/go-log/v2 v2.5.1 // indirect
github.com/ipld/go-ipld-prime v0.9.0 // indirect
github.com/ipld/go-ipld-prime v0.19.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/jbenet/goprocess v0.1.4 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/klauspost/compress v1.15.1 // indirect
github.com/klauspost/cpuid/v2 v2.1.0 // indirect
github.com/koron/go-ssdp v0.0.3 // indirect
Expand Down Expand Up @@ -112,13 +112,13 @@ require (
github.com/multiformats/go-multiaddr-dns v0.3.1 // indirect
github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect
github.com/multiformats/go-multibase v0.1.1 // indirect
github.com/multiformats/go-multicodec v0.5.0 // indirect
github.com/multiformats/go-multicodec v0.6.0 // indirect
github.com/multiformats/go-multihash v0.2.1 // indirect
github.com/multiformats/go-multistream v0.3.3 // indirect
github.com/multiformats/go-varint v0.0.6 // indirect
github.com/multiversx/concurrent-map v0.1.4 // indirect
github.com/multiversx/mx-chain-storage-go v1.0.7 // indirect
github.com/multiversx/mx-chain-vm-common-go v1.3.36 // indirect
github.com/multiversx/mx-chain-vm-common-go v1.3.37 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/opencontainers/runtime-spec v1.0.2 // indirect
Expand All @@ -129,7 +129,7 @@ require (
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polydawn/refmt v0.0.0-20190807091052-3d65705ee9f1 // indirect
github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
Expand All @@ -138,6 +138,7 @@ require (
github.com/rjeczalik/notify v0.9.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/smartystreets/assertions v1.13.1 // indirect
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
Expand All @@ -154,10 +155,10 @@ require (
go.uber.org/zap v1.22.0 // indirect
golang.org/x/crypto v0.3.0 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.2.0 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
golang.org/x/tools v0.1.12 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
Expand Down
Loading

0 comments on commit af4ba09

Please sign in to comment.