From cbabc6632ed34c163eb254e40ffb258abd13421a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Thu, 29 Dec 2022 13:59:09 +0200 Subject: [PATCH 01/21] Add "libbls" (compiled as a library). --- .github/workflows/build_libraries.yml | 81 +++++++++++++++++++ libraries/libbls/README.md | 17 ++++ libraries/libbls/libbls.go | 110 ++++++++++++++++++++++++++ libraries/libbls/libbls.h | 78 ++++++++++++++++++ libraries/libbls/libbls_test.go | 89 +++++++++++++++++++++ libraries/libbls/main.go | 42 ++++++++++ 6 files changed, 417 insertions(+) create mode 100644 .github/workflows/build_libraries.yml create mode 100644 libraries/libbls/README.md create mode 100644 libraries/libbls/libbls.go create mode 100644 libraries/libbls/libbls.h create mode 100644 libraries/libbls/libbls_test.go create mode 100644 libraries/libbls/main.go diff --git a/.github/workflows/build_libraries.yml b/.github/workflows/build_libraries.yml new file mode 100644 index 00000000..07ea8859 --- /dev/null +++ b/.github/workflows/build_libraries.yml @@ -0,0 +1,81 @@ +name: Build libraries + +on: + workflow_dispatch: + inputs: + attach: + type: boolean + description: Attach artifacts on release, if one exists + +permissions: + contents: write + +jobs: + build: + strategy: + matrix: + runs-on: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.runs-on }} + name: Build + steps: + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.17.6 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v3 + with: + fetch-depth: "0" + + - name: Get dependencies + run: | + go get -v -t -d ./... + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure + fi + + - name: Build libbls (Linux) + if: runner.os == 'Linux' + run: | + cd ./libraries/libbls + go build -buildmode=c-shared -o $GITHUB_WORKSPACE/libbls.so . + + - name: Build libbls (MacOS) + if: runner.os == 'macOS' + run: | + cd ./libraries/libbls + go build -buildmode=c-shared -o $GITHUB_WORKSPACE/libbls.dylib . + + - name: Save artifacts + uses: actions/upload-artifact@v2 + with: + name: libraries + path: | + ${{ github.workspace }}/libbls.so + ${{ github.workspace }}/libbls.dylib + if-no-files-found: error + + attach-on-release: + if: ${{ github.event.inputs.attach == 'true' }} + needs: [build] + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + with: + fetch-depth: "0" + + - name: Download all workflow artifacts + uses: actions/download-artifact@v2 + with: + path: libraries + + - name: Upload artifacts + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload ${{ github.ref_name }} $(find ./libraries -type f) diff --git a/libraries/libbls/README.md b/libraries/libbls/README.md new file mode 100644 index 00000000..fd4d6163 --- /dev/null +++ b/libraries/libbls/README.md @@ -0,0 +1,17 @@ +# libbls + +BLS signature utilities, compiled as a library (shared object). + +## Build + +On Linux: + +``` +go build -buildmode=c-shared -o libbls.so . +``` + +On MacOS: + +``` +go build -buildmode=c-shared -o libbls.dylib . +``` diff --git a/libraries/libbls/libbls.go b/libraries/libbls/libbls.go new file mode 100644 index 00000000..e05a483d --- /dev/null +++ b/libraries/libbls/libbls.go @@ -0,0 +1,110 @@ +package main + +import ( + "encoding/hex" + "log" + + "github.com/ElrondNetwork/elrond-go-crypto/signing" + "github.com/ElrondNetwork/elrond-go-crypto/signing/mcl" + "github.com/ElrondNetwork/elrond-go-crypto/signing/mcl/singlesig" +) + +var ( + keyGenerator = signing.NewKeyGenerator(mcl.NewSuiteBLS12()) + blsSigner = singlesig.BlsSingleSigner{} +) + +func doGeneratePrivateKey() string { + privateKey, _ := keyGenerator.GeneratePair() + privateKeyBytes, err := privateKey.ToByteArray() + if err != nil { + log.Println("doGeneratePrivateKey(): error when decoding the private key", err) + return "" + } + + return hex.EncodeToString(privateKeyBytes) +} + +func doGeneratePublicKey(privateKeyHex string) string { + privateKeyBytes, ok := decodeInputParameter("private key", privateKeyHex) + if !ok { + return "" + } + + privateKey, err := keyGenerator.PrivateKeyFromByteArray(privateKeyBytes) + if err != nil { + log.Println("doGeneratePublicKey(): error when creating the private key", err) + return "" + } + + publicKey := privateKey.GeneratePublic() + publicKeyBytes, err := publicKey.ToByteArray() + if err != nil { + log.Println("doGeneratePublicKey(): error when decoding the public key", err) + return "" + } + + return hex.EncodeToString(publicKeyBytes) +} + +func doSignMessage(messageHex string, privateKeyHex string) string { + message, ok := decodeInputParameter("message", messageHex) + if !ok { + return "" + } + + privateKeyBytes, ok := decodeInputParameter("private key", privateKeyHex) + if !ok { + return "" + } + + privateKey, err := keyGenerator.PrivateKeyFromByteArray(privateKeyBytes) + if err != nil { + log.Println("doSignMessage(): error when creating the private key", err) + return "" + } + + signature, err := blsSigner.Sign(privateKey, message) + if err != nil { + log.Println("doSignMessage(): error when signing the message", err) + return "" + } + + return hex.EncodeToString(signature) +} + +func doVerifyMessage(publicKeyHex string, messageHex string, signatureHex string) bool { + publicKeyBytes, ok := decodeInputParameter("public key", publicKeyHex) + if !ok { + return false + } + + message, ok := decodeInputParameter("message", messageHex) + if !ok { + return false + } + + signature, ok := decodeInputParameter("signature", signatureHex) + if !ok { + return false + } + + publicKey, err := keyGenerator.PublicKeyFromByteArray(publicKeyBytes) + if err != nil { + log.Println("doVerifyMessage(): error when creating the public key", err) + return false + } + + err = blsSigner.Verify(publicKey, message, signature) + return err == nil +} + +func decodeInputParameter(parameterName string, parameterValueHex string) ([]byte, bool) { + data, err := hex.DecodeString(parameterValueHex) + if err != nil { + log.Println("cannot decode input parameter", parameterName, err) + return nil, false + } + + return data, true +} diff --git a/libraries/libbls/libbls.h b/libraries/libbls/libbls.h new file mode 100644 index 00000000..46fa5075 --- /dev/null +++ b/libraries/libbls/libbls.h @@ -0,0 +1,78 @@ +/* Code generated by cmd/cgo; DO NOT EDIT. */ + +/* package github.com/ElrondNetwork/elrond-sdk-erdgo/libraries/libbls */ + + +#line 1 "cgo-builtin-export-prolog" + +#include /* for ptrdiff_t below */ + +#ifndef GO_CGO_EXPORT_PROLOGUE_H +#define GO_CGO_EXPORT_PROLOGUE_H + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef struct { const char *p; ptrdiff_t n; } _GoString_; +#endif + +#endif + +/* Start of preamble from import "C" comments. */ + + + + +/* End of preamble from import "C" comments. */ + + +/* Start of boilerplate cgo prologue. */ +#line 1 "cgo-gcc-export-header-prolog" + +#ifndef GO_CGO_PROLOGUE_H +#define GO_CGO_PROLOGUE_H + +typedef signed char GoInt8; +typedef unsigned char GoUint8; +typedef short GoInt16; +typedef unsigned short GoUint16; +typedef int GoInt32; +typedef unsigned int GoUint32; +typedef long long GoInt64; +typedef unsigned long long GoUint64; +typedef GoInt64 GoInt; +typedef GoUint64 GoUint; +typedef __SIZE_TYPE__ GoUintptr; +typedef float GoFloat32; +typedef double GoFloat64; +typedef float _Complex GoComplex64; +typedef double _Complex GoComplex128; + +/* + static assertion to make sure the file is being used on architecture + at least with matching size of GoInt. +*/ +typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef _GoString_ GoString; +#endif +typedef void *GoMap; +typedef void *GoChan; +typedef struct { void *t; void *v; } GoInterface; +typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; + +#endif + +/* End of boilerplate cgo prologue. */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern char* generatePublicKey(char* privateKey); +extern char* signMessage(char* message, char* privateKey); +extern GoInt verifyMessage(char* publicKey, char* message, char* signature); +extern char* generatePrivateKey(); + +#ifdef __cplusplus +} +#endif diff --git a/libraries/libbls/libbls_test.go b/libraries/libbls/libbls_test.go new file mode 100644 index 00000000..c5ab150c --- /dev/null +++ b/libraries/libbls/libbls_test.go @@ -0,0 +1,89 @@ +package main + +import ( + "encoding/hex" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestDoGeneratePrivateKey(t *testing.T) { + privateKeyHex := doGeneratePrivateKey() + privateKey, err := hex.DecodeString(privateKeyHex) + + require.Nil(t, err) + require.Len(t, privateKey, 32) +} + +func TestDoGeneratePublicKey(t *testing.T) { + t.Run("with good input", func(t *testing.T) { + publicKeyHex := doGeneratePublicKey("7cff99bd671502db7d15bc8abc0c9a804fb925406fbdd50f1e4c17a4cd774247") + require.Equal(t, "e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208", publicKeyHex) + }) + + t.Run("with bad input", func(t *testing.T) { + publicKeyHex := doGeneratePublicKey("7cff99bd671502db7d15bc8abc0c9a804fb925406fbdd50f1e4c17a4cd7742") + require.Equal(t, "", publicKeyHex) + }) +} + +func TestDoSignMessage(t *testing.T) { + t.Run("with good input", func(t *testing.T) { + messageHex := hex.EncodeToString([]byte("hello")) + privateKeyHex := "7cff99bd671502db7d15bc8abc0c9a804fb925406fbdd50f1e4c17a4cd774247" + signatureHex := doSignMessage(messageHex, privateKeyHex) + require.Equal(t, "84fd0a3a9d4f1ea2d4b40c6da67f9b786284a1c3895b7253fec7311597cda3f757862bb0690a92a13ce612c33889fd86", signatureHex) + }) + + t.Run("with bad input (not hex)", func(t *testing.T) { + signatureHex := doSignMessage("not hex", "7cff99bd671502db7d15bc8abc0c9a804fb925406fbdd50f1e4c17a4cd774247") + require.Equal(t, "", signatureHex) + }) + + t.Run("with bad input (bad key)", func(t *testing.T) { + messageHex := hex.EncodeToString([]byte("hello")) + signatureHex := doSignMessage(messageHex, "7cff99bd671502db7d15bc8abc0c9a804fb925406fbdd50f1e4c17a4cd7742") + require.Equal(t, "", signatureHex) + }) +} + +func TestDoVerifyMessage(t *testing.T) { + t.Run("with good input", func(t *testing.T) { + publicKeyHex := "e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" + messageHex := hex.EncodeToString([]byte("hello")) + signatureHex := "84fd0a3a9d4f1ea2d4b40c6da67f9b786284a1c3895b7253fec7311597cda3f757862bb0690a92a13ce612c33889fd86" + require.True(t, doVerifyMessage(publicKeyHex, messageHex, signatureHex)) + }) + + t.Run("with altered signature", func(t *testing.T) { + publicKeyHex := "e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" + messageHex := hex.EncodeToString([]byte("hello")) + signatureHex := "94fd0a3a9d4f1ea2d4b40c6da67f9b786284a1c3895b7253fec7311597cda3f757862bb0690a92a13ce612c33889fd86" + require.False(t, doVerifyMessage(publicKeyHex, messageHex, signatureHex)) + }) + + t.Run("with altered message", func(t *testing.T) { + publicKeyHex := "e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" + messageHex := hex.EncodeToString([]byte("helloWorld")) + signatureHex := "84fd0a3a9d4f1ea2d4b40c6da67f9b786284a1c3895b7253fec7311597cda3f757862bb0690a92a13ce612c33889fd86" + require.False(t, doVerifyMessage(publicKeyHex, messageHex, signatureHex)) + }) + + t.Run("with bad public key", func(t *testing.T) { + publicKeyHex := "badbad95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" + messageHex := hex.EncodeToString([]byte("hello")) + signatureHex := "84fd0a3a9d4f1ea2d4b40c6da67f9b786284a1c3895b7253fec7311597cda3f757862bb0690a92a13ce612c33889fd86" + require.False(t, doVerifyMessage(publicKeyHex, messageHex, signatureHex)) + }) +} + +func TestGenerateSignAndVerify(t *testing.T) { + messageHex := hex.EncodeToString([]byte("hello")) + + privateKeyHex := doGeneratePrivateKey() + publicKeyHex := doGeneratePublicKey(privateKeyHex) + signatureHex := doSignMessage(messageHex, privateKeyHex) + isOk := doVerifyMessage(publicKeyHex, messageHex, signatureHex) + + require.True(t, isOk) +} diff --git a/libraries/libbls/main.go b/libraries/libbls/main.go new file mode 100644 index 00000000..e2a63235 --- /dev/null +++ b/libraries/libbls/main.go @@ -0,0 +1,42 @@ +package main + +import ( + "C" +) + +func main() { +} + +//export generatePublicKey +func generatePublicKey(privateKey *C.char) *C.char { + privateKeyHex := C.GoString(privateKey) + publicKeyHex := doGeneratePublicKey(privateKeyHex) + return C.CString(publicKeyHex) +} + +//export signMessage +func signMessage(message *C.char, privateKey *C.char) *C.char { + messageHex := C.GoString(message) + privateKeyHex := C.GoString(privateKey) + signatureHex := doSignMessage(messageHex, privateKeyHex) + return C.CString(signatureHex) +} + +//export verifyMessage +func verifyMessage(publicKey *C.char, message *C.char, signature *C.char) int { + publicKeyHex := C.GoString(publicKey) + messageHex := C.GoString(message) + signatureHex := C.GoString(signature) + ok := doVerifyMessage(publicKeyHex, messageHex, signatureHex) + if ok { + return 1 + } + + return 0 +} + +//export generatePrivateKey +func generatePrivateKey() *C.char { + privateKeyHex := doGeneratePrivateKey() + return C.CString(privateKeyHex) +} From 3c154b89e61acd78dc412d8330f45fc25d45ae82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Thu, 29 Dec 2022 14:33:00 +0200 Subject: [PATCH 02/21] Fix after review. --- libraries/libbls/libbls.go | 18 ++++++++--------- libraries/libbls/libbls.h | 4 ++-- libraries/libbls/libbls_test.go | 36 ++++++++++++++++----------------- libraries/libbls/main.go | 16 +++++++-------- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/libraries/libbls/libbls.go b/libraries/libbls/libbls.go index e05a483d..cc376346 100644 --- a/libraries/libbls/libbls.go +++ b/libraries/libbls/libbls.go @@ -14,7 +14,7 @@ var ( blsSigner = singlesig.BlsSingleSigner{} ) -func doGeneratePrivateKey() string { +func doGeneratePrivateKeyAsHex() string { privateKey, _ := keyGenerator.GeneratePair() privateKeyBytes, err := privateKey.ToByteArray() if err != nil { @@ -25,7 +25,7 @@ func doGeneratePrivateKey() string { return hex.EncodeToString(privateKeyBytes) } -func doGeneratePublicKey(privateKeyHex string) string { +func doGeneratePublicKeyAsHex(privateKeyHex string) string { privateKeyBytes, ok := decodeInputParameter("private key", privateKeyHex) if !ok { return "" @@ -33,21 +33,21 @@ func doGeneratePublicKey(privateKeyHex string) string { privateKey, err := keyGenerator.PrivateKeyFromByteArray(privateKeyBytes) if err != nil { - log.Println("doGeneratePublicKey(): error when creating the private key", err) + log.Println("doGeneratePublicKeyAsHex(): error when creating the private key", err) return "" } publicKey := privateKey.GeneratePublic() publicKeyBytes, err := publicKey.ToByteArray() if err != nil { - log.Println("doGeneratePublicKey(): error when decoding the public key", err) + log.Println("doGeneratePublicKeyAsHex(): error when decoding the public key", err) return "" } return hex.EncodeToString(publicKeyBytes) } -func doSignMessage(messageHex string, privateKeyHex string) string { +func doComputeMessageSignatureAsHex(messageHex string, privateKeyHex string) string { message, ok := decodeInputParameter("message", messageHex) if !ok { return "" @@ -60,20 +60,20 @@ func doSignMessage(messageHex string, privateKeyHex string) string { privateKey, err := keyGenerator.PrivateKeyFromByteArray(privateKeyBytes) if err != nil { - log.Println("doSignMessage(): error when creating the private key", err) + log.Println("doComputeMessageSignatureAsHex(): error when creating the private key", err) return "" } signature, err := blsSigner.Sign(privateKey, message) if err != nil { - log.Println("doSignMessage(): error when signing the message", err) + log.Println("doComputeMessageSignatureAsHex(): error when signing the message", err) return "" } return hex.EncodeToString(signature) } -func doVerifyMessage(publicKeyHex string, messageHex string, signatureHex string) bool { +func doVerifyMessageSignature(publicKeyHex string, messageHex string, signatureHex string) bool { publicKeyBytes, ok := decodeInputParameter("public key", publicKeyHex) if !ok { return false @@ -91,7 +91,7 @@ func doVerifyMessage(publicKeyHex string, messageHex string, signatureHex string publicKey, err := keyGenerator.PublicKeyFromByteArray(publicKeyBytes) if err != nil { - log.Println("doVerifyMessage(): error when creating the public key", err) + log.Println("doVerifyMessageSignature(): error when creating the public key", err) return false } diff --git a/libraries/libbls/libbls.h b/libraries/libbls/libbls.h index 46fa5075..ee1f1b37 100644 --- a/libraries/libbls/libbls.h +++ b/libraries/libbls/libbls.h @@ -69,8 +69,8 @@ extern "C" { #endif extern char* generatePublicKey(char* privateKey); -extern char* signMessage(char* message, char* privateKey); -extern GoInt verifyMessage(char* publicKey, char* message, char* signature); +extern char* computeMessageSignature(char* message, char* privateKey); +extern GoInt verifyMessageSignature(char* publicKey, char* message, char* signature); extern char* generatePrivateKey(); #ifdef __cplusplus diff --git a/libraries/libbls/libbls_test.go b/libraries/libbls/libbls_test.go index c5ab150c..376f2ec0 100644 --- a/libraries/libbls/libbls_test.go +++ b/libraries/libbls/libbls_test.go @@ -7,83 +7,83 @@ import ( "github.com/stretchr/testify/require" ) -func TestDoGeneratePrivateKey(t *testing.T) { - privateKeyHex := doGeneratePrivateKey() +func TestDoGeneratePrivateKeyAsHex(t *testing.T) { + privateKeyHex := doGeneratePrivateKeyAsHex() privateKey, err := hex.DecodeString(privateKeyHex) require.Nil(t, err) require.Len(t, privateKey, 32) } -func TestDoGeneratePublicKey(t *testing.T) { +func TestDoGeneratePublicKeyAsHex(t *testing.T) { t.Run("with good input", func(t *testing.T) { - publicKeyHex := doGeneratePublicKey("7cff99bd671502db7d15bc8abc0c9a804fb925406fbdd50f1e4c17a4cd774247") + publicKeyHex := doGeneratePublicKeyAsHex("7cff99bd671502db7d15bc8abc0c9a804fb925406fbdd50f1e4c17a4cd774247") require.Equal(t, "e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208", publicKeyHex) }) t.Run("with bad input", func(t *testing.T) { - publicKeyHex := doGeneratePublicKey("7cff99bd671502db7d15bc8abc0c9a804fb925406fbdd50f1e4c17a4cd7742") + publicKeyHex := doGeneratePublicKeyAsHex("7cff99bd671502db7d15bc8abc0c9a804fb925406fbdd50f1e4c17a4cd7742") require.Equal(t, "", publicKeyHex) }) } -func TestDoSignMessage(t *testing.T) { +func TestDoComputeMessageSignatureAsHex(t *testing.T) { t.Run("with good input", func(t *testing.T) { messageHex := hex.EncodeToString([]byte("hello")) privateKeyHex := "7cff99bd671502db7d15bc8abc0c9a804fb925406fbdd50f1e4c17a4cd774247" - signatureHex := doSignMessage(messageHex, privateKeyHex) + signatureHex := doComputeMessageSignatureAsHex(messageHex, privateKeyHex) require.Equal(t, "84fd0a3a9d4f1ea2d4b40c6da67f9b786284a1c3895b7253fec7311597cda3f757862bb0690a92a13ce612c33889fd86", signatureHex) }) t.Run("with bad input (not hex)", func(t *testing.T) { - signatureHex := doSignMessage("not hex", "7cff99bd671502db7d15bc8abc0c9a804fb925406fbdd50f1e4c17a4cd774247") + signatureHex := doComputeMessageSignatureAsHex("not hex", "7cff99bd671502db7d15bc8abc0c9a804fb925406fbdd50f1e4c17a4cd774247") require.Equal(t, "", signatureHex) }) t.Run("with bad input (bad key)", func(t *testing.T) { messageHex := hex.EncodeToString([]byte("hello")) - signatureHex := doSignMessage(messageHex, "7cff99bd671502db7d15bc8abc0c9a804fb925406fbdd50f1e4c17a4cd7742") + signatureHex := doComputeMessageSignatureAsHex(messageHex, "7cff99bd671502db7d15bc8abc0c9a804fb925406fbdd50f1e4c17a4cd7742") require.Equal(t, "", signatureHex) }) } -func TestDoVerifyMessage(t *testing.T) { +func TestDoVerifyMessageSignature(t *testing.T) { t.Run("with good input", func(t *testing.T) { publicKeyHex := "e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" messageHex := hex.EncodeToString([]byte("hello")) signatureHex := "84fd0a3a9d4f1ea2d4b40c6da67f9b786284a1c3895b7253fec7311597cda3f757862bb0690a92a13ce612c33889fd86" - require.True(t, doVerifyMessage(publicKeyHex, messageHex, signatureHex)) + require.True(t, doVerifyMessageSignature(publicKeyHex, messageHex, signatureHex)) }) t.Run("with altered signature", func(t *testing.T) { publicKeyHex := "e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" messageHex := hex.EncodeToString([]byte("hello")) signatureHex := "94fd0a3a9d4f1ea2d4b40c6da67f9b786284a1c3895b7253fec7311597cda3f757862bb0690a92a13ce612c33889fd86" - require.False(t, doVerifyMessage(publicKeyHex, messageHex, signatureHex)) + require.False(t, doVerifyMessageSignature(publicKeyHex, messageHex, signatureHex)) }) t.Run("with altered message", func(t *testing.T) { publicKeyHex := "e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" messageHex := hex.EncodeToString([]byte("helloWorld")) signatureHex := "84fd0a3a9d4f1ea2d4b40c6da67f9b786284a1c3895b7253fec7311597cda3f757862bb0690a92a13ce612c33889fd86" - require.False(t, doVerifyMessage(publicKeyHex, messageHex, signatureHex)) + require.False(t, doVerifyMessageSignature(publicKeyHex, messageHex, signatureHex)) }) t.Run("with bad public key", func(t *testing.T) { publicKeyHex := "badbad95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" messageHex := hex.EncodeToString([]byte("hello")) signatureHex := "84fd0a3a9d4f1ea2d4b40c6da67f9b786284a1c3895b7253fec7311597cda3f757862bb0690a92a13ce612c33889fd86" - require.False(t, doVerifyMessage(publicKeyHex, messageHex, signatureHex)) + require.False(t, doVerifyMessageSignature(publicKeyHex, messageHex, signatureHex)) }) } func TestGenerateSignAndVerify(t *testing.T) { messageHex := hex.EncodeToString([]byte("hello")) - privateKeyHex := doGeneratePrivateKey() - publicKeyHex := doGeneratePublicKey(privateKeyHex) - signatureHex := doSignMessage(messageHex, privateKeyHex) - isOk := doVerifyMessage(publicKeyHex, messageHex, signatureHex) + privateKeyHex := doGeneratePrivateKeyAsHex() + publicKeyHex := doGeneratePublicKeyAsHex(privateKeyHex) + signatureHex := doComputeMessageSignatureAsHex(messageHex, privateKeyHex) + isOk := doVerifyMessageSignature(publicKeyHex, messageHex, signatureHex) require.True(t, isOk) } diff --git a/libraries/libbls/main.go b/libraries/libbls/main.go index e2a63235..84938bc7 100644 --- a/libraries/libbls/main.go +++ b/libraries/libbls/main.go @@ -10,24 +10,24 @@ func main() { //export generatePublicKey func generatePublicKey(privateKey *C.char) *C.char { privateKeyHex := C.GoString(privateKey) - publicKeyHex := doGeneratePublicKey(privateKeyHex) + publicKeyHex := doGeneratePublicKeyAsHex(privateKeyHex) return C.CString(publicKeyHex) } -//export signMessage -func signMessage(message *C.char, privateKey *C.char) *C.char { +//export computeMessageSignature +func computeMessageSignature(message *C.char, privateKey *C.char) *C.char { messageHex := C.GoString(message) privateKeyHex := C.GoString(privateKey) - signatureHex := doSignMessage(messageHex, privateKeyHex) + signatureHex := doComputeMessageSignatureAsHex(messageHex, privateKeyHex) return C.CString(signatureHex) } -//export verifyMessage -func verifyMessage(publicKey *C.char, message *C.char, signature *C.char) int { +//export verifyMessageSignature +func verifyMessageSignature(publicKey *C.char, message *C.char, signature *C.char) int { publicKeyHex := C.GoString(publicKey) messageHex := C.GoString(message) signatureHex := C.GoString(signature) - ok := doVerifyMessage(publicKeyHex, messageHex, signatureHex) + ok := doVerifyMessageSignature(publicKeyHex, messageHex, signatureHex) if ok { return 1 } @@ -37,6 +37,6 @@ func verifyMessage(publicKey *C.char, message *C.char, signature *C.char) int { //export generatePrivateKey func generatePrivateKey() *C.char { - privateKeyHex := doGeneratePrivateKey() + privateKeyHex := doGeneratePrivateKeyAsHex() return C.CString(privateKeyHex) } From 3b6a4f5e39cdec814b280ae5a47515ac348231e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 4 Jan 2023 10:42:50 +0200 Subject: [PATCH 03/21] Adjust github workflows. --- .github/workflows/build_libraries.yml | 8 +++++--- .github/workflows/create_release.yml | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_libraries.yml b/.github/workflows/build_libraries.yml index 07ea8859..c0132ebd 100644 --- a/.github/workflows/build_libraries.yml +++ b/.github/workflows/build_libraries.yml @@ -6,6 +6,8 @@ on: attach: type: boolean description: Attach artifacts on release, if one exists + release: + types: [published] permissions: contents: write @@ -53,7 +55,7 @@ jobs: - name: Save artifacts uses: actions/upload-artifact@v2 with: - name: libraries + name: artifacts path: | ${{ github.workspace }}/libbls.so ${{ github.workspace }}/libbls.dylib @@ -72,10 +74,10 @@ jobs: - name: Download all workflow artifacts uses: actions/download-artifact@v2 with: - path: libraries + path: artifacts - name: Upload artifacts env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh release upload ${{ github.ref_name }} $(find ./libraries -type f) + gh release upload ${{ github.ref_name }} $(find ./artifacts -type f) diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index 7c546f11..67c429b5 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -22,4 +22,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - hub release create --draft --message="Release draft from Github Actions" vNext + hub release create --draft --title="vNext" --generate-notes vNext From f6ee9cc30e817b4482c069da673a578695bd3469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 4 Jan 2023 10:48:50 +0200 Subject: [PATCH 04/21] Adjust title. --- .github/workflows/create_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index 67c429b5..b8fa929d 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -22,4 +22,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - hub release create --draft --title="vNext" --generate-notes vNext + hub release create --draft --message="vNext" --generate-notes vNext From c5a1107989a0bc810ae12eb5337c565d706b2af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 4 Jan 2023 10:52:41 +0200 Subject: [PATCH 05/21] Use gh instead of hub. --- .github/workflows/create_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index b8fa929d..39472d6a 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -22,4 +22,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - hub release create --draft --message="vNext" --generate-notes vNext + gh release create --draft --title="vNext" --generate-notes vNext From 7eb0e60dd97b622221b0e823075de005efb043dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 4 Jan 2023 10:57:25 +0200 Subject: [PATCH 06/21] Improve flow. --- .github/workflows/build_libraries.yml | 5 ----- .github/workflows/create_release.yml | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/build_libraries.yml b/.github/workflows/build_libraries.yml index c0132ebd..9998b688 100644 --- a/.github/workflows/build_libraries.yml +++ b/.github/workflows/build_libraries.yml @@ -2,10 +2,6 @@ name: Build libraries on: workflow_dispatch: - inputs: - attach: - type: boolean - description: Attach artifacts on release, if one exists release: types: [published] @@ -62,7 +58,6 @@ jobs: if-no-files-found: error attach-on-release: - if: ${{ github.event.inputs.attach == 'true' }} needs: [build] runs-on: ubuntu-latest steps: diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index 39472d6a..e4ced447 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -22,4 +22,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh release create --draft --title="vNext" --generate-notes vNext + gh release create vNext --target=$GITHUB_SHA --title="vNext" --generate-notes --draft From c40d75531c2de77493bbe73b141c8d810f48f7a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 4 Jan 2023 12:57:22 +0200 Subject: [PATCH 07/21] Build libbls for older OS (glibc, libc compatibility reasons). --- .github/workflows/build_libraries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_libraries.yml b/.github/workflows/build_libraries.yml index 9998b688..80b18376 100644 --- a/.github/workflows/build_libraries.yml +++ b/.github/workflows/build_libraries.yml @@ -12,7 +12,7 @@ jobs: build: strategy: matrix: - runs-on: [ubuntu-latest, macos-latest] + runs-on: [ubuntu-20.04, macos-11] runs-on: ${{ matrix.runs-on }} name: Build steps: From e6858d0a148ff809e96e86ead2092cae288d1d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 4 Jan 2023 15:00:16 +0200 Subject: [PATCH 08/21] Build for windows, as well. --- .github/workflows/build_libraries.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_libraries.yml b/.github/workflows/build_libraries.yml index 80b18376..d01a64b2 100644 --- a/.github/workflows/build_libraries.yml +++ b/.github/workflows/build_libraries.yml @@ -12,7 +12,7 @@ jobs: build: strategy: matrix: - runs-on: [ubuntu-20.04, macos-11] + runs-on: [ubuntu-20.04, macos-11, windows-2019] runs-on: ${{ matrix.runs-on }} name: Build steps: @@ -48,6 +48,12 @@ jobs: cd ./libraries/libbls go build -buildmode=c-shared -o $GITHUB_WORKSPACE/libbls.dylib . + - name: Build libbls (Windows) + if: runner.os == 'Windows' + run: | + cd ./libraries/libbls + go build -buildmode=c-shared -o $GITHUB_WORKSPACE/libbls.dll . + - name: Save artifacts uses: actions/upload-artifact@v2 with: @@ -55,6 +61,7 @@ jobs: path: | ${{ github.workspace }}/libbls.so ${{ github.workspace }}/libbls.dylib + ${{ github.workspace }}/libbls.dll if-no-files-found: error attach-on-release: From 86c0e9e4772b9aef055b9b1057d081d4570199cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 4 Jan 2023 15:06:33 +0200 Subject: [PATCH 09/21] Set shell type. --- .github/workflows/build_libraries.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_libraries.yml b/.github/workflows/build_libraries.yml index d01a64b2..ddc0bdd6 100644 --- a/.github/workflows/build_libraries.yml +++ b/.github/workflows/build_libraries.yml @@ -29,6 +29,7 @@ jobs: fetch-depth: "0" - name: Get dependencies + shell: bash run: | go get -v -t -d ./... if [ -f Gopkg.toml ]; then From 090a68206d8020360aa514b4449189fea976bd00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 4 Jan 2023 15:31:00 +0200 Subject: [PATCH 10/21] Trial and error. --- .github/workflows/build_libraries.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_libraries.yml b/.github/workflows/build_libraries.yml index ddc0bdd6..41d6cadf 100644 --- a/.github/workflows/build_libraries.yml +++ b/.github/workflows/build_libraries.yml @@ -53,16 +53,16 @@ jobs: if: runner.os == 'Windows' run: | cd ./libraries/libbls - go build -buildmode=c-shared -o $GITHUB_WORKSPACE/libbls.dll . + go build -buildmode=c-shared -o $GITHUB_WORKSPACE\libbls.dll . - name: Save artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: artifacts path: | - ${{ github.workspace }}/libbls.so - ${{ github.workspace }}/libbls.dylib - ${{ github.workspace }}/libbls.dll + libbls.so + libbls.dylib + libbls.dll if-no-files-found: error attach-on-release: @@ -75,7 +75,7 @@ jobs: fetch-depth: "0" - name: Download all workflow artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: path: artifacts From 724b502a3f0b6d5a437f63e91c34ebbd99407dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 4 Jan 2023 15:38:17 +0200 Subject: [PATCH 11/21] Trial and error. --- .github/workflows/build_libraries.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_libraries.yml b/.github/workflows/build_libraries.yml index 41d6cadf..acd62b8e 100644 --- a/.github/workflows/build_libraries.yml +++ b/.github/workflows/build_libraries.yml @@ -50,10 +50,11 @@ jobs: go build -buildmode=c-shared -o $GITHUB_WORKSPACE/libbls.dylib . - name: Build libbls (Windows) + shell: bash if: runner.os == 'Windows' run: | cd ./libraries/libbls - go build -buildmode=c-shared -o $GITHUB_WORKSPACE\libbls.dll . + go build -buildmode=c-shared -o $GITHUB_WORKSPACE/libbls.dll . - name: Save artifacts uses: actions/upload-artifact@v3 From 44471bae28d8915ff69a338dd15146b9d4bd84c7 Mon Sep 17 00:00:00 2001 From: Bogdan Rosianu Date: Thu, 5 Jan 2023 12:20:07 +0200 Subject: [PATCH 12/21] relayed tx builder --- blockchain/proxy.go | 2 +- builders/errors.go | 12 +++ builders/relayedTxBuilder.go | 135 ++++++++++++++++++++++++++++++ builders/relayedTxBuilder_test.go | 101 ++++++++++++++++++++++ 4 files changed, 249 insertions(+), 1 deletion(-) create mode 100644 builders/relayedTxBuilder.go create mode 100644 builders/relayedTxBuilder_test.go diff --git a/blockchain/proxy.go b/blockchain/proxy.go index 89393a30..205c7e3c 100644 --- a/blockchain/proxy.go +++ b/blockchain/proxy.go @@ -234,7 +234,7 @@ func (ep *elrondProxy) SendTransaction(ctx context.Context, tx *data.Transaction return "", err } buff, code, err := ep.PostHTTP(ctx, ep.endpointProvider.GetSendTransaction(), jsonTx) - if err != nil || code != http.StatusOK { + if err != nil { return "", createHTTPStatusError(code, err) } diff --git a/builders/errors.go b/builders/errors.go index b1b508d5..e168a302 100644 --- a/builders/errors.go +++ b/builders/errors.go @@ -22,3 +22,15 @@ var ErrNilCryptoComponentsHolder = errors.New("nil crypto components holder") // ErrMissingSignature signals that a transaction's signature is empty when trying to compute it's hash var ErrMissingSignature = errors.New("missing signature when computing the transaction's hash") + +// ErrNilInnerTransaction signals that a nil inner transaction was provided +var ErrNilInnerTransaction = errors.New("nil inner transaction") + +// ErrNilRelayerAccount signals that a nil relayer account was provided +var ErrNilRelayerAccount = errors.New("nil relayer account") + +// ErrNilNetworkConfig signals that a nil network config was provided +var ErrNilNetworkConfig = errors.New("nil network config") + +// ErrNilInnerTransactionSignature signals that a nil inner transaction signature was provided +var ErrNilInnerTransactionSignature = errors.New("nil inner transaction signature") diff --git a/builders/relayedTxBuilder.go b/builders/relayedTxBuilder.go new file mode 100644 index 00000000..2d1e9a48 --- /dev/null +++ b/builders/relayedTxBuilder.go @@ -0,0 +1,135 @@ +package builders + +import ( + "encoding/hex" + "encoding/json" + "math/big" + + "github.com/ElrondNetwork/elrond-go-core/data/transaction" + "github.com/ElrondNetwork/elrond-sdk-erdgo/core" + "github.com/ElrondNetwork/elrond-sdk-erdgo/data" +) + +type relayedTxV1Builder struct { + innerTransaction *data.Transaction + relayerAccount *data.Account + networkConfig *data.NetworkConfig +} + +// NewRelayedTxV1Builder creates a new relayed transaction v1 builder +func NewRelayedTxV1Builder() *relayedTxV1Builder { + return &relayedTxV1Builder{ + innerTransaction: nil, + relayerAccount: nil, + networkConfig: nil, + } +} + +// SetInnerTransaction sets the inner transaction to be relayed +func (rtb *relayedTxV1Builder) SetInnerTransaction(tx *data.Transaction) *relayedTxV1Builder { + rtb.innerTransaction = tx + + return rtb +} + +// SetRelayerAccount sets the relayer account +func (rtb *relayedTxV1Builder) SetRelayerAccount(account *data.Account) *relayedTxV1Builder { + rtb.relayerAccount = account + + return rtb +} + +// SetNetworkConfig sets the network config +func (rtb *relayedTxV1Builder) SetNetworkConfig(config *data.NetworkConfig) *relayedTxV1Builder { + rtb.networkConfig = config + + return rtb +} + +// Build builds the relayed transaction v1 +// The returned transaction will not be signed +func (rtb *relayedTxV1Builder) Build() (*data.Transaction, error) { + if rtb.innerTransaction == nil { + return nil, ErrNilInnerTransaction + } + if len(rtb.innerTransaction.Signature) == 0 { + return nil, ErrNilInnerTransactionSignature + } + if rtb.relayerAccount == nil { + return nil, ErrNilRelayerAccount + } + if rtb.networkConfig == nil { + return nil, ErrNilNetworkConfig + } + + innerTxHex, err := prepareInnerTxForRelay(rtb.innerTransaction) + if err != nil { + return nil, err + } + + payload := []byte("relayedTx@" + innerTxHex) + gasLimit := rtb.networkConfig.MinGasLimit + rtb.networkConfig.GasPerDataByte*uint64(len(payload)) + rtb.innerTransaction.GasLimit + + innerTxValue, ok := big.NewInt(0).SetString(rtb.innerTransaction.Value, 10) + if !ok { + return nil, ErrInvalidValue + } + + relayedTx := &data.Transaction{ + Nonce: rtb.relayerAccount.Nonce, + Value: innerTxValue.String(), + RcvAddr: rtb.innerTransaction.SndAddr, + SndAddr: rtb.relayerAccount.Address, + GasPrice: rtb.innerTransaction.GasPrice, + GasLimit: gasLimit, + Data: payload, + ChainID: rtb.networkConfig.ChainID, + Version: rtb.networkConfig.MinTransactionVersion, + } + + return relayedTx, nil +} + +func prepareInnerTxForRelay(tx *data.Transaction) (string, error) { + txValue, ok := big.NewInt(0).SetString(tx.Value, 10) + if !ok { + return "", ErrInvalidValue + } + + addressConverter := core.AddressPublicKeyConverter + receiverAddress, err := addressConverter.Decode(tx.RcvAddr) + if err != nil { + return "", err + } + + senderAddress, err := addressConverter.Decode(tx.SndAddr) + if err != nil { + return "", err + } + + signatureBytes, err := hex.DecodeString(tx.Signature) + if err != nil { + + } + + coreTx := &transaction.Transaction{ + Nonce: tx.Nonce, + Value: txValue, + RcvAddr: receiverAddress, + SndAddr: senderAddress, + GasPrice: tx.GasPrice, + GasLimit: tx.GasLimit, + Data: tx.Data, + ChainID: []byte(tx.ChainID), + Version: tx.Version, + Signature: signatureBytes, + Options: tx.Options, + } + + serializedTx, err := json.Marshal(coreTx) + if err != nil { + return "", err + } + + return hex.EncodeToString(serializedTx), nil +} diff --git a/builders/relayedTxBuilder_test.go b/builders/relayedTxBuilder_test.go new file mode 100644 index 00000000..8c6a59e6 --- /dev/null +++ b/builders/relayedTxBuilder_test.go @@ -0,0 +1,101 @@ +package builders + +import ( + "context" + "encoding/hex" + "fmt" + "testing" + "time" + + "github.com/ElrondNetwork/elrond-go-crypto/signing" + "github.com/ElrondNetwork/elrond-go-crypto/signing/ed25519" + "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain" + "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain/cryptoProvider" + "github.com/ElrondNetwork/elrond-sdk-erdgo/core" + "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" + "github.com/stretchr/testify/require" +) + +const ( + testRelayerMnemonic = "bid involve twenty cave offer life hello three walnut travel rare bike edit canyon ice brave theme furnace cotton swing wear bread fine latin" + testInnerSenderMnemonic = "acid twice post genre topic observe valid viable gesture fortune funny dawn around blood enemy page update reduce decline van bundle zebra rookie real" +) + +func TestRelayedTxBuilder(t *testing.T) { + proxyProvider, err := blockchain.NewElrondProxy(blockchain.ArgsElrondProxy{ + ProxyURL: "https://testnet-gateway.elrond.com", + CacheExpirationTime: time.Minute, + EntityType: core.Proxy, + }) + require.NoError(t, err) + + netConfig, err := proxyProvider.GetNetworkConfig(context.Background()) + require.NoError(t, err) + + relayerAcc, relayerPrivKey := getAccount(t, proxyProvider, testRelayerMnemonic) + innerSenderAcc, innerSenderPrivKey := getAccount(t, proxyProvider, testInnerSenderMnemonic) + + innerTx := &data.Transaction{ + Nonce: innerSenderAcc.Nonce, + Value: "100000000", + RcvAddr: "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th", + SndAddr: innerSenderAcc.Address, + GasPrice: netConfig.MinGasPrice, + GasLimit: netConfig.MinGasLimit, + Data: nil, + ChainID: netConfig.ChainID, + Version: netConfig.MinTransactionVersion, + Options: 0, + } + + innerTxSig := signTx(t, innerSenderPrivKey, innerTx) + innerTx.Signature = hex.EncodeToString(innerTxSig) + + relayedTxV1Builder := NewRelayedTxV1Builder() + relayedTxV1Builder.SetInnerTransaction(innerTx) + relayedTxV1Builder.SetRelayerAccount(relayerAcc) + relayedTxV1Builder.SetNetworkConfig(netConfig) + + relayedTx, err := relayedTxV1Builder.Build() + require.NoError(t, err) + + relayedTxSig := signTx(t, relayerPrivKey, relayedTx) + relayedTx.Signature = hex.EncodeToString(relayedTxSig) + + printTx(relayedTx) + + hash, err := proxyProvider.SendTransaction(context.Background(), relayedTx) + require.NoError(t, err) + fmt.Printf("The hash of the transaction is: %s\n", hash) +} + +func getAccount(t *testing.T, proxy interactors.Proxy, mnemonic string) (*data.Account, []byte) { + wallet := interactors.NewWallet() + + privKey := wallet.GetPrivateKeyFromMnemonic(data.Mnemonic(mnemonic), 0, 0) + address, err := wallet.GetAddressFromPrivateKey(privKey) + require.NoError(t, err) + + account, err := proxy.GetAccount(context.Background(), address) + require.NoError(t, err) + + return account, privKey +} + +func signTx(t *testing.T, privKeyBytes []byte, tx *data.Transaction) []byte { + keyGen := signing.NewKeyGenerator(ed25519.NewEd25519()) + privKey, err := keyGen.PrivateKeyFromByteArray(privKeyBytes) + require.NoError(t, err) + signer := cryptoProvider.NewSigner() + + signature, err := signer.SignTransaction(tx, privKey) + require.NoError(t, err) + + return signature +} + +func printTx(tx *data.Transaction) { + fmt.Printf("Transaction: [\n\tNonce: %d\n\tSender: %s\n\tReceiver: %s\n\tValue: %s\n\tGasPrice: %d\n\tGasLimit: %d\n\tData: %s\n\tSignature: %s\n]\n", + tx.Nonce, tx.SndAddr, tx.RcvAddr, tx.Value, tx.GasPrice, tx.GasLimit, tx.Data, tx.Signature) +} From 0dc4726114ea87ca5589b6ce527aa153a9058218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Mon, 9 Jan 2023 19:43:13 +0200 Subject: [PATCH 13/21] Rename Elrond to MultiversX. --- CHANGELOG.md | 9 --------- README.md | 10 +++------- 2 files changed, 3 insertions(+), 16 deletions(-) delete mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 5f749c84..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,9 +0,0 @@ -# Change Log - -All notable changes will be documented in this file. - -Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. - -## [1.0.0] - -- Initial release. diff --git a/README.md b/README.md index 2c059dd2..f57a0674 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,10 @@ -# Elrond SDK for GO +# MultiversX SDK for GO -Elrond SDK for GO - useful for developing GO applications that interact with the Elrond Network. +MultiversX SDK for GO - useful for developing GO applications that interact with the blockchain. ## Documentation -[pkg.go.dev](https://pkg.go.dev/github.com/ElrondNetwork/elrond-sdk/erdgo) - -## CHANGELOG - -[CHANGELOG](CHANGELOG.md) +[pkg.go.dev](https://pkg.go.dev/github.com/multiversx/mx-sdk-erdgo) ## Dependencies From 1c67686e7da33b5d6fc8d5bbed20270e0e07d087 Mon Sep 17 00:00:00 2001 From: Bogdan Rosianu Date: Tue, 10 Jan 2023 14:50:03 +0200 Subject: [PATCH 14/21] added relayedv2 builder + fixes + unit tests --- builders/errors.go | 6 + ...ayedTxBuilder.go => relayedTxV1Builder.go} | 4 +- ...der_test.go => relayedTxV1Builder_test.go} | 47 +++---- builders/relayedTxV2Builder.go | 115 ++++++++++++++++++ builders/relayedTxV2Builder_test.go | 65 ++++++++++ data/transaction.go | 4 +- 6 files changed, 215 insertions(+), 26 deletions(-) rename builders/{relayedTxBuilder.go => relayedTxV1Builder.go} (95%) rename builders/{relayedTxBuilder_test.go => relayedTxV1Builder_test.go} (50%) create mode 100644 builders/relayedTxV2Builder.go create mode 100644 builders/relayedTxV2Builder_test.go diff --git a/builders/errors.go b/builders/errors.go index e168a302..7330945e 100644 --- a/builders/errors.go +++ b/builders/errors.go @@ -34,3 +34,9 @@ var ErrNilNetworkConfig = errors.New("nil network config") // ErrNilInnerTransactionSignature signals that a nil inner transaction signature was provided var ErrNilInnerTransactionSignature = errors.New("nil inner transaction signature") + +// ErrInvalidGasLimitNeededForInnerTransaction signals that an invalid gas limit needed for the inner transaction was provided +var ErrInvalidGasLimitNeededForInnerTransaction = errors.New("invalid gas limit needed for inner transaction") + +// ErrGasLimitForInnerTransactionV2ShouldBeZero signals that the gas limit for the inner transaction should be zero +var ErrGasLimitForInnerTransactionV2ShouldBeZero = errors.New("gas limit of the inner transaction should be 0") diff --git a/builders/relayedTxBuilder.go b/builders/relayedTxV1Builder.go similarity index 95% rename from builders/relayedTxBuilder.go rename to builders/relayedTxV1Builder.go index 2d1e9a48..19647f95 100644 --- a/builders/relayedTxBuilder.go +++ b/builders/relayedTxV1Builder.go @@ -62,7 +62,7 @@ func (rtb *relayedTxV1Builder) Build() (*data.Transaction, error) { return nil, ErrNilNetworkConfig } - innerTxHex, err := prepareInnerTxForRelay(rtb.innerTransaction) + innerTxHex, err := prepareInnerTxForRelayV1(rtb.innerTransaction) if err != nil { return nil, err } @@ -90,7 +90,7 @@ func (rtb *relayedTxV1Builder) Build() (*data.Transaction, error) { return relayedTx, nil } -func prepareInnerTxForRelay(tx *data.Transaction) (string, error) { +func prepareInnerTxForRelayV1(tx *data.Transaction) (string, error) { txValue, ok := big.NewInt(0).SetString(tx.Value, 10) if !ok { return "", ErrInvalidValue diff --git a/builders/relayedTxBuilder_test.go b/builders/relayedTxV1Builder_test.go similarity index 50% rename from builders/relayedTxBuilder_test.go rename to builders/relayedTxV1Builder_test.go index 8c6a59e6..38286731 100644 --- a/builders/relayedTxBuilder_test.go +++ b/builders/relayedTxV1Builder_test.go @@ -3,7 +3,7 @@ package builders import ( "context" "encoding/hex" - "fmt" + "encoding/json" "testing" "time" @@ -22,7 +22,7 @@ const ( testInnerSenderMnemonic = "acid twice post genre topic observe valid viable gesture fortune funny dawn around blood enemy page update reduce decline van bundle zebra rookie real" ) -func TestRelayedTxBuilder(t *testing.T) { +func TestRelayedTxV1Builder(t *testing.T) { proxyProvider, err := blockchain.NewElrondProxy(blockchain.ArgsElrondProxy{ ProxyURL: "https://testnet-gateway.elrond.com", CacheExpirationTime: time.Minute, @@ -33,8 +33,8 @@ func TestRelayedTxBuilder(t *testing.T) { netConfig, err := proxyProvider.GetNetworkConfig(context.Background()) require.NoError(t, err) - relayerAcc, relayerPrivKey := getAccount(t, proxyProvider, testRelayerMnemonic) - innerSenderAcc, innerSenderPrivKey := getAccount(t, proxyProvider, testInnerSenderMnemonic) + relayerAcc, relayerPrivKey := getAccount(t, testRelayerMnemonic) + innerSenderAcc, innerSenderPrivKey := getAccount(t, testInnerSenderMnemonic) innerTx := &data.Transaction{ Nonce: innerSenderAcc.Nonce, @@ -52,33 +52,41 @@ func TestRelayedTxBuilder(t *testing.T) { innerTxSig := signTx(t, innerSenderPrivKey, innerTx) innerTx.Signature = hex.EncodeToString(innerTxSig) - relayedTxV1Builder := NewRelayedTxV1Builder() - relayedTxV1Builder.SetInnerTransaction(innerTx) - relayedTxV1Builder.SetRelayerAccount(relayerAcc) - relayedTxV1Builder.SetNetworkConfig(netConfig) + txJson, _ := json.Marshal(innerTx) + require.Equal(t, + `{"nonce":37,"value":"100000000","receiver":"erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th","sender":"erd1mlh7q3fcgrjeq0et65vaaxcw6m5ky8jhu296pdxpk9g32zga6uhsemxx2a","gasPrice":1000000000,"gasLimit":50000,"signature":"c315bc927bac80996e77b5c2f4b76506ce98b12bb0511583e8e20ef9e2bbbf58a07687e341023cf2a69bab5d116b116e32cb67bf697ce451bc5bed55b24c410a","chainID":"T","version":1}`, + string(txJson), + ) - relayedTx, err := relayedTxV1Builder.Build() + relayedV1Builder := NewRelayedTxV1Builder() + relayedV1Builder.SetInnerTransaction(innerTx) + relayedV1Builder.SetRelayerAccount(relayerAcc) + relayedV1Builder.SetNetworkConfig(netConfig) + + relayedTx, err := relayedV1Builder.Build() require.NoError(t, err) relayedTxSig := signTx(t, relayerPrivKey, relayedTx) relayedTx.Signature = hex.EncodeToString(relayedTxSig) - printTx(relayedTx) - - hash, err := proxyProvider.SendTransaction(context.Background(), relayedTx) - require.NoError(t, err) - fmt.Printf("The hash of the transaction is: %s\n", hash) + txJson, _ = json.Marshal(relayedTx) + require.Equal(t, + `{"nonce":37,"value":"100000000","receiver":"erd1mlh7q3fcgrjeq0et65vaaxcw6m5ky8jhu296pdxpk9g32zga6uhsemxx2a","sender":"erd1h692scsz3um6e5qwzts4yjrewxqxwcwxzavl5n9q8sprussx8fqsu70jf5","gasPrice":1000000000,"gasLimit":1060000,"data":"cmVsYXllZFR4QDdiMjI2ZTZmNmU2MzY1MjIzYTMzMzcyYzIyNzY2MTZjNzU2NTIyM2EzMTMwMzAzMDMwMzAzMDMwMzAyYzIyNzI2NTYzNjU2OTc2NjU3MjIyM2EyMjQxNTQ2YzQ4NGM3NjM5NmY2ODZlNjM2MTZkNDMzODc3NjczOTcwNjQ1MTY4Mzg2Yjc3NzA0NzQyMzU2YTY5NDk0OTZmMzM0OTQ4NGI1OTRlNjE2NTQ1M2QyMjJjMjI3MzY1NmU2NDY1NzIyMjNhMjIzMzJiMmY2NzUyNTQ2ODQxMzU1YTQxMmY0YjM5NTU1YTMzNzA3MzRmMzE3NTZjNjk0ODZjNjY2OTY5MzY0MzMwNzc2MjQ2NTI0NjUxNmI2NDMxNzkzODNkMjIyYzIyNjc2MTczNTA3MjY5NjM2NTIyM2EzMTMwMzAzMDMwMzAzMDMwMzAzMDJjMjI2NzYxNzM0YzY5NmQ2OTc0MjIzYTM1MzAzMDMwMzAyYzIyNjM2ODYxNjk2ZTQ5NDQyMjNhMjI1NjQxM2QzZDIyMmMyMjc2NjU3MjczNjk2ZjZlMjIzYTMxMmMyMjczNjk2NzZlNjE3NDc1NzI2NTIyM2EyMjc3Nzg1NzM4NmI2ZTc1NzM2NzRhNmM3NTY0Mzc1ODQzMzk0YzY0NmM0MjczMzY1OTczNTM3NTc3NTU1MjU3NDQzNjRmNDk0ZjJiNjU0YjM3NzYzMTY5Njc2NDZmNjY2YTUxNTE0OTM4Mzg3MTYxNjI3MTMxMzA1MjYxNzg0Njc1NGQ3Mzc0NmU3NjMyNmMzODM1NDY0NzM4NTcyYjMxNTY3MzZiNzg0MjQzNjczZDNkMjI3ZA==","signature":"49ff32dcfef469d14887a9940c2943a80e1d50cecf1e611a2175e4cbc1de1b900e5e41d54d9beb5760af80a87720c9099100d5b1d5ff2b73a7e37e6a364fc401","chainID":"T","version":1}`, + string(txJson), + ) } -func getAccount(t *testing.T, proxy interactors.Proxy, mnemonic string) (*data.Account, []byte) { +func getAccount(t *testing.T, mnemonic string) (*data.Account, []byte) { wallet := interactors.NewWallet() privKey := wallet.GetPrivateKeyFromMnemonic(data.Mnemonic(mnemonic), 0, 0) address, err := wallet.GetAddressFromPrivateKey(privKey) require.NoError(t, err) - account, err := proxy.GetAccount(context.Background(), address) - require.NoError(t, err) + account := &data.Account{ + Nonce: 37, + Address: address.AddressAsBech32String(), + } return account, privKey } @@ -94,8 +102,3 @@ func signTx(t *testing.T, privKeyBytes []byte, tx *data.Transaction) []byte { return signature } - -func printTx(tx *data.Transaction) { - fmt.Printf("Transaction: [\n\tNonce: %d\n\tSender: %s\n\tReceiver: %s\n\tValue: %s\n\tGasPrice: %d\n\tGasLimit: %d\n\tData: %s\n\tSignature: %s\n]\n", - tx.Nonce, tx.SndAddr, tx.RcvAddr, tx.Value, tx.GasPrice, tx.GasLimit, tx.Data, tx.Signature) -} diff --git a/builders/relayedTxV2Builder.go b/builders/relayedTxV2Builder.go new file mode 100644 index 00000000..ad99f2cb --- /dev/null +++ b/builders/relayedTxV2Builder.go @@ -0,0 +1,115 @@ +package builders + +import ( + "encoding/hex" + "fmt" + "math/big" + + "github.com/ElrondNetwork/elrond-sdk-erdgo/core" + "github.com/ElrondNetwork/elrond-sdk-erdgo/data" +) + +type relayedTxV2Builder struct { + innerTransaction *data.Transaction + gasLimitNeededForInnerTransaction uint64 + relayerAccount *data.Account + networkConfig *data.NetworkConfig +} + +// NewRelayedTxV2Builder creates a new relayed transaction v2 builder +func NewRelayedTxV2Builder() *relayedTxV2Builder { + return &relayedTxV2Builder{ + innerTransaction: nil, + relayerAccount: nil, + networkConfig: nil, + } +} + +// SetInnerTransaction sets the inner transaction to be relayed +func (rtb *relayedTxV2Builder) SetInnerTransaction(tx *data.Transaction) *relayedTxV2Builder { + rtb.innerTransaction = tx + + return rtb +} + +func (rtb *relayedTxV2Builder) SetRelayerAccount(account *data.Account) *relayedTxV2Builder { + rtb.relayerAccount = account + + return rtb +} + +// SetGasLimitNeededForInnerTransaction sets the gas limit needed for the inner transaction +func (rtb *relayedTxV2Builder) SetGasLimitNeededForInnerTransaction(gasLimit uint64) *relayedTxV2Builder { + rtb.gasLimitNeededForInnerTransaction = gasLimit + + return rtb +} + +// SetNetworkConfig sets the network config +func (rtb *relayedTxV2Builder) SetNetworkConfig(config *data.NetworkConfig) *relayedTxV2Builder { + rtb.networkConfig = config + + return rtb +} + +// Build builds the relayed transaction v1 +// The returned transaction will not be signed +func (rtb *relayedTxV2Builder) Build() (*data.Transaction, error) { + if rtb.innerTransaction == nil { + return nil, ErrNilInnerTransaction + } + if len(rtb.innerTransaction.Signature) == 0 { + return nil, ErrNilInnerTransactionSignature + } + if rtb.relayerAccount == nil { + return nil, ErrNilRelayerAccount + } + if rtb.networkConfig == nil { + return nil, ErrNilNetworkConfig + } + if rtb.gasLimitNeededForInnerTransaction == 0 { + return nil, ErrInvalidGasLimitNeededForInnerTransaction + } + if rtb.innerTransaction.GasLimit != 0 { + return nil, ErrGasLimitForInnerTransactionV2ShouldBeZero + } + + innerTxHex, err := prepareInnerTxForRelayV2(rtb.innerTransaction) + if err != nil { + return nil, err + } + + payload := []byte("relayedTxV2@" + innerTxHex) + gasLimit := rtb.networkConfig.MinGasLimit + rtb.networkConfig.GasPerDataByte*uint64(len(payload)) + rtb.gasLimitNeededForInnerTransaction + + relayedTx := &data.Transaction{ + Nonce: rtb.relayerAccount.Nonce, + Value: "0", + RcvAddr: rtb.innerTransaction.SndAddr, + SndAddr: rtb.relayerAccount.Address, + GasPrice: rtb.innerTransaction.GasPrice, + GasLimit: gasLimit, + Data: payload, + ChainID: rtb.networkConfig.ChainID, + Version: rtb.networkConfig.MinTransactionVersion, + } + + return relayedTx, nil +} + +func prepareInnerTxForRelayV2(tx *data.Transaction) (string, error) { + nonceBytes := big.NewInt(0).SetUint64(tx.Nonce).Bytes() + decodedReceiver, err := core.AddressPublicKeyConverter.Decode(tx.RcvAddr) + if err != nil { + return "", err + } + + payload := fmt.Sprintf("%s@%s@%s@%s", + hex.EncodeToString(decodedReceiver), + hex.EncodeToString(nonceBytes), + hex.EncodeToString(tx.Data), + tx.Signature, + ) + + return payload, nil +} diff --git a/builders/relayedTxV2Builder_test.go b/builders/relayedTxV2Builder_test.go new file mode 100644 index 00000000..7ac9c5b4 --- /dev/null +++ b/builders/relayedTxV2Builder_test.go @@ -0,0 +1,65 @@ +package builders + +import ( + "encoding/hex" + "encoding/json" + "testing" + + "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/stretchr/testify/require" +) + +func TestRelayedTxV2Builder(t *testing.T) { + t.Parallel() + + netConfig := &data.NetworkConfig{ + ChainID: "T", + MinTransactionVersion: 1, + GasPerDataByte: 1500, + } + + relayerAcc, relayerPrivKey := getAccount(t, testRelayerMnemonic) + innerSenderAcc, innerSenderPrivKey := getAccount(t, testInnerSenderMnemonic) + + innerTx := &data.Transaction{ + Nonce: innerSenderAcc.Nonce, + Value: "0", + RcvAddr: "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u", + SndAddr: innerSenderAcc.Address, + GasPrice: netConfig.MinGasPrice, + GasLimit: 0, + Data: []byte("getContractConfig"), + ChainID: netConfig.ChainID, + Version: netConfig.MinTransactionVersion, + Options: 0, + } + + innerTxSig := signTx(t, innerSenderPrivKey, innerTx) + innerTx.Signature = hex.EncodeToString(innerTxSig) + + txJson, _ := json.Marshal(innerTx) + require.Equal(t, + `{"nonce":37,"value":"0","receiver":"erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u","sender":"erd1mlh7q3fcgrjeq0et65vaaxcw6m5ky8jhu296pdxpk9g32zga6uhsemxx2a","gasPrice":0,"gasLimit":0,"data":"Z2V0Q29udHJhY3RDb25maWc=","signature":"e578eb15076d9bf42f7610c17125ef88d38422a927e80075d11790b618ec106d4dec7da0d312801e0df28f5c8885d648844f54e7dc83c3e7fd71f60998867103","chainID":"T","version":1}`, + string(txJson), + ) + + relayedV2Builder := NewRelayedTxV2Builder() + relayedV2Builder.SetInnerTransaction(innerTx) + relayedV2Builder.SetRelayerAccount(relayerAcc) + relayedV2Builder.SetNetworkConfig(netConfig) + relayedV2Builder.SetGasLimitNeededForInnerTransaction(60_000_000) + + relayedTx, err := relayedV2Builder.Build() + require.NoError(t, err) + + relayedTx.GasPrice = netConfig.MinGasPrice + + relayedTxSig := signTx(t, relayerPrivKey, relayedTx) + relayedTx.Signature = hex.EncodeToString(relayedTxSig) + + txJson, _ = json.Marshal(relayedTx) + require.Equal(t, + `{"nonce":37,"value":"0","receiver":"erd1mlh7q3fcgrjeq0et65vaaxcw6m5ky8jhu296pdxpk9g32zga6uhsemxx2a","sender":"erd1h692scsz3um6e5qwzts4yjrewxqxwcwxzavl5n9q8sprussx8fqsu70jf5","gasPrice":0,"gasLimit":60364500,"data":"cmVsYXllZFR4VjJAMDAwMDAwMDAwMDAwMDAwMDAwMDEwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAyZmZmZkAyNUA2NzY1NzQ0MzZmNmU3NDcyNjE2Mzc0NDM2ZjZlNjY2OTY3QGU1NzhlYjE1MDc2ZDliZjQyZjc2MTBjMTcxMjVlZjg4ZDM4NDIyYTkyN2U4MDA3NWQxMTc5MGI2MThlYzEwNmQ0ZGVjN2RhMGQzMTI4MDFlMGRmMjhmNWM4ODg1ZDY0ODg0NGY1NGU3ZGM4M2MzZTdmZDcxZjYwOTk4ODY3MTAz","signature":"6c4f404274d499857be292c59bfca9c29f1ea5ead9544346fadf9ab2944310775aa5c0954cc289d916c6c8cadec128614903f73b2bcd6c0266f6d651383d7207","chainID":"T","version":1}`, + string(txJson), + ) +} diff --git a/data/transaction.go b/data/transaction.go index b57252b4..456341b7 100644 --- a/data/transaction.go +++ b/data/transaction.go @@ -27,8 +27,8 @@ type Transaction struct { Value string `json:"value"` RcvAddr string `json:"receiver"` SndAddr string `json:"sender"` - GasPrice uint64 `json:"gasPrice,omitempty"` - GasLimit uint64 `json:"gasLimit,omitempty"` + GasPrice uint64 `json:"gasPrice"` + GasLimit uint64 `json:"gasLimit"` Data []byte `json:"data,omitempty"` Signature string `json:"signature,omitempty"` ChainID string `json:"chainID"` From 6d877c61df602e95ac61e2d0abd7e6ae25f99d94 Mon Sep 17 00:00:00 2001 From: Bogdan Rosianu Date: Tue, 10 Jan 2023 14:53:02 +0200 Subject: [PATCH 15/21] fix linter issue --- builders/relayedTxV1Builder.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builders/relayedTxV1Builder.go b/builders/relayedTxV1Builder.go index 19647f95..e8107342 100644 --- a/builders/relayedTxV1Builder.go +++ b/builders/relayedTxV1Builder.go @@ -109,7 +109,7 @@ func prepareInnerTxForRelayV1(tx *data.Transaction) (string, error) { signatureBytes, err := hex.DecodeString(tx.Signature) if err != nil { - + return "", err } coreTx := &transaction.Transaction{ From 2a90bc923d42337846c445506b4f7d134151ebea Mon Sep 17 00:00:00 2001 From: Bogdan Rosianu Date: Tue, 10 Jan 2023 16:03:40 +0200 Subject: [PATCH 16/21] fixes after review --- builders/relayedTxV1Builder_test.go | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/builders/relayedTxV1Builder_test.go b/builders/relayedTxV1Builder_test.go index 38286731..7d12e8bf 100644 --- a/builders/relayedTxV1Builder_test.go +++ b/builders/relayedTxV1Builder_test.go @@ -1,17 +1,13 @@ package builders import ( - "context" "encoding/hex" "encoding/json" "testing" - "time" "github.com/ElrondNetwork/elrond-go-crypto/signing" "github.com/ElrondNetwork/elrond-go-crypto/signing/ed25519" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain" "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain/cryptoProvider" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" "github.com/ElrondNetwork/elrond-sdk-erdgo/data" "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" "github.com/stretchr/testify/require" @@ -23,15 +19,15 @@ const ( ) func TestRelayedTxV1Builder(t *testing.T) { - proxyProvider, err := blockchain.NewElrondProxy(blockchain.ArgsElrondProxy{ - ProxyURL: "https://testnet-gateway.elrond.com", - CacheExpirationTime: time.Minute, - EntityType: core.Proxy, - }) - require.NoError(t, err) - - netConfig, err := proxyProvider.GetNetworkConfig(context.Background()) - require.NoError(t, err) + t.Parallel() + + netConfig := &data.NetworkConfig{ + ChainID: "T", + MinTransactionVersion: 1, + GasPerDataByte: 1500, + MinGasLimit: 50000, + MinGasPrice: 1000000000, + } relayerAcc, relayerPrivKey := getAccount(t, testRelayerMnemonic) innerSenderAcc, innerSenderPrivKey := getAccount(t, testInnerSenderMnemonic) From d26287dc6e340bcf36884e6041df240e0732c6ff Mon Sep 17 00:00:00 2001 From: Radu Chis Date: Thu, 26 Jan 2023 14:53:55 +0200 Subject: [PATCH 17/21] Rebranding (#120) * rebranding + usage of mx-chain-go v1.4.4 * removed gogoproto replace * replaced elrond to multiversX also in code * removed MultiversX from Proxy, Notifee, ShardCoordinator * removed MultiversX from Proxy, Notifee, ShardCoordinator 2 * proxy test renamed --- aggregator/api/gin/httpServer.go | 2 +- aggregator/api/gin/httpServer_test.go | 6 +- aggregator/api/gin/webServer.go | 12 +- aggregator/api/gin/webServer_test.go | 2 +- aggregator/api/gin/writers.go | 4 +- aggregator/computers_test.go | 2 +- aggregator/fetchers/binance.go | 2 +- aggregator/fetchers/bitfinex.go | 2 +- aggregator/fetchers/cryptocom.go | 2 +- aggregator/fetchers/factory.go | 2 +- aggregator/fetchers/factory_test.go | 2 +- aggregator/fetchers/fetchers_test.go | 6 +- aggregator/fetchers/gemini.go | 2 +- aggregator/fetchers/hitbtc.go | 2 +- aggregator/fetchers/huobi.go | 2 +- aggregator/fetchers/kraken.go | 2 +- aggregator/fetchers/maiar.go | 2 +- aggregator/fetchers/okex.go | 2 +- aggregator/graphqlResponseGetter.go | 4 +- aggregator/graphqlResponseGetter_test.go | 2 +- aggregator/httpResponseGetter_test.go | 2 +- aggregator/mock/priceNotifeeStub.go | 2 +- aggregator/notifees/interface.go | 6 +- .../{elrondNotifee.go => mxNotifee.go} | 38 +++--- ...lrondNotifee_test.go => mxNotifee_test.go} | 90 ++++++------- aggregator/pair_test.go | 2 +- aggregator/priceAggregator.go | 6 +- aggregator/priceAggregator_test.go | 6 +- aggregator/priceNotifier.go | 2 +- aggregator/priceNotifier_test.go | 6 +- authentication/native.go | 10 +- authentication/native_test.go | 6 +- blockchain/addressGenerator.go | 36 ++--- blockchain/addressGenerator_test.go | 2 +- .../{elrondBaseProxy.go => baseProxy.go} | 44 +++--- ...ondBaseProxy_test.go => baseProxy_test.go} | 114 ++++++++-------- .../cryptoProvider/cryptoComponentsHolder.go | 6 +- .../cryptoComponentsHolder_test.go | 8 +- blockchain/cryptoProvider/signer.go | 12 +- blockchain/cryptoProvider/signer_test.go | 12 +- .../endpointProviders/nodeEndpointProvider.go | 4 +- .../nodeEndpointProvider_test.go | 4 +- .../proxyEndpointProvider.go | 4 +- .../proxyEndpointProvider_test.go | 6 +- blockchain/factory/factory.go | 6 +- blockchain/factory/factory_test.go | 6 +- blockchain/factory/interface.go | 4 +- .../disabledFinalityProvider_test.go | 2 +- blockchain/finalityProvider/interface.go | 2 +- .../finalityProvider/nodeFinalityProvider.go | 4 +- .../nodeFinalityProvider_test.go | 6 +- .../finalityProvider/proxyFinalityProvider.go | 14 +- .../proxyFinalityProvider_test.go | 10 +- blockchain/interface.go | 6 +- blockchain/proxy.go | 96 ++++++------- blockchain/proxy_test.go | 126 +++++++++--------- blockchain/shardCoordinator.go | 6 +- builders/baseBuilder.go | 4 +- builders/interface.go | 6 +- builders/relayedTxV1Builder.go | 6 +- builders/relayedTxV1Builder_test.go | 10 +- builders/relayedTxV2Builder.go | 4 +- builders/relayedTxV2Builder_test.go | 2 +- builders/txBuilder.go | 12 +- builders/txBuilder_test.go | 14 +- builders/txDataBuilder.go | 2 +- builders/txDataBuilder_test.go | 4 +- builders/vmQueryBuilder.go | 4 +- builders/vmQueryBuilder_test.go | 4 +- core/http/clientWrapper.go | 4 +- core/http/clientWrapper_test.go | 2 +- core/interface.go | 2 +- core/polling/pollingHandler.go | 4 +- core/polling/pollingHandler_test.go | 6 +- core/variables.go | 6 +- data/address.go | 2 +- data/enableEpochsConfig.go | 2 +- data/nodeConfig.go | 2 +- data/transaction.go | 2 +- data/vmValues.go | 2 +- disabled/accounts.go | 6 +- disabled/blockchain.go | 2 +- disabled/blockchainHookCounter.go | 7 +- disabled/builtInFunctionContainer.go | 2 +- disabled/datapool.go | 4 +- disabled/elrondShardCoordinator.go | 35 ----- disabled/enableEpochsHandler.go | 10 ++ disabled/epochNotifier.go | 4 +- disabled/epochStartNotifier.go | 2 +- disabled/fallbackHeaderValidator.go | 2 +- disabled/gasScheduleNotifier.go | 2 +- disabled/nodeTypeProvider.go | 2 +- disabled/shardCoordinator.go | 35 +++++ disabled/simpleESDTNFTStorageHandler.go | 6 +- disabled/storageService.go | 4 +- disabled/storer.go | 2 +- examples/examplesAccount/main.go | 16 +-- examples/examplesBlock/main.go | 14 +- examples/examplesFlowWalletTracker/main.go | 26 ++-- examples/examplesHeaderCheck/main.go | 18 +-- examples/examplesPriceAggregator/main.go | 34 ++--- examples/examplesTransaction/main.go | 24 ++-- examples/examplesVMQuery/main.go | 16 +-- examples/examplesWallet/main.go | 6 +- examples/networks.go | 4 +- go.mod | 26 ++-- go.sum | 63 ++++----- headerCheck/export_test.go | 2 +- headerCheck/factory/coreComponents.go | 26 ++-- headerCheck/factory/cryptoComponents.go | 14 +- headerCheck/factory/nodesCoordinator.go | 18 +-- headerCheck/headerCheck.go | 12 +- headerCheck/headerCheckFactory.go | 12 +- headerCheck/headerCheck_test.go | 12 +- headerCheck/interface.go | 6 +- headerCheck/rawHeaderHandler.go | 14 +- headerCheck/rawHeaderHandler_test.go | 10 +- interactors/interface.go | 6 +- .../nonceHandlerV1/addressNonceHandler.go | 8 +- .../nonceTransactionsHandler.go | 12 +- .../nonceTransactionsHandler_test.go | 8 +- .../nonceHandlerV2/addressNonceHandler.go | 10 +- .../addressNonceHandlerCreator.go | 4 +- .../addressNonceHandlerCreator_test.go | 4 +- .../addressNonceHandler_test.go | 8 +- interactors/nonceHandlerV2/export_test.go | 8 +- .../nonceTransactionsHandler.go | 12 +- .../nonceTransactionsHandler_test.go | 10 +- .../singleTransactionAddressNonceHandler.go | 10 +- ...leTransactionAddressNonceHandlerCreator.go | 4 +- ...nsactionAddressNonceHandlerCreator_test.go | 4 +- ...ngleTransactionAddressNonceHandler_test.go | 8 +- interactors/transaction.go | 8 +- interactors/transaction_test.go | 6 +- interactors/wallet.go | 8 +- interactors/wallet_test.go | 2 +- libraries/libbls/libbls.go | 6 +- libraries/libbls/libbls.h | 2 +- serde/deserializer_test.go | 2 +- storage/mapCacher.go | 4 +- testsCommon/cryptoComponentsHolderStub.go | 4 +- testsCommon/headerSigVerifierStub.go | 2 +- .../addressNonceHandlerCreatorStub.go | 4 +- testsCommon/nodesCoordinatorStub.go | 4 +- testsCommon/privateKeyStub.go | 2 +- testsCommon/proxyStub.go | 8 +- testsCommon/publicKeyStub.go | 2 +- testsCommon/rawHeaderHandlerStub.go | 4 +- testsCommon/signerStub.go | 4 +- testsCommon/txBuilderStub.go | 4 +- testsCommon/txNonceHandlerV1Stub.go | 4 +- testsCommon/txNonceHandlerV2Stub.go | 4 +- workflows/interface.go | 4 +- workflows/moveBalanceHandler.go | 10 +- workflows/walletsTracker.go | 8 +- 155 files changed, 807 insertions(+), 797 deletions(-) rename aggregator/notifees/{elrondNotifee.go => mxNotifee.go} (73%) rename aggregator/notifees/{elrondNotifee_test.go => mxNotifee_test.go} (81%) rename blockchain/{elrondBaseProxy.go => baseProxy.go} (75%) rename blockchain/{elrondBaseProxy_test.go => baseProxy_test.go} (86%) delete mode 100644 disabled/elrondShardCoordinator.go create mode 100644 disabled/shardCoordinator.go diff --git a/aggregator/api/gin/httpServer.go b/aggregator/api/gin/httpServer.go index de095ae4..3b0afea3 100644 --- a/aggregator/api/gin/httpServer.go +++ b/aggregator/api/gin/httpServer.go @@ -5,7 +5,7 @@ import ( "net/http" "time" - apiErrors "github.com/ElrondNetwork/elrond-go/api/errors" + apiErrors "github.com/multiversx/mx-chain-go/api/errors" ) type httpServer struct { diff --git a/aggregator/api/gin/httpServer_test.go b/aggregator/api/gin/httpServer_test.go index d2083c1d..58c0c61f 100644 --- a/aggregator/api/gin/httpServer_test.go +++ b/aggregator/api/gin/httpServer_test.go @@ -6,9 +6,9 @@ import ( "net/http" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" - apiErrors "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator/api/errors" - testsServer "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon/server" + "github.com/multiversx/mx-chain-core-go/core/check" + apiErrors "github.com/multiversx/mx-sdk-go/aggregator/api/errors" + testsServer "github.com/multiversx/mx-sdk-go/testsCommon/server" "github.com/stretchr/testify/assert" ) diff --git a/aggregator/api/gin/webServer.go b/aggregator/api/gin/webServer.go index f628da61..71e1c955 100644 --- a/aggregator/api/gin/webServer.go +++ b/aggregator/api/gin/webServer.go @@ -5,21 +5,21 @@ import ( "net/http" "sync" - "github.com/ElrondNetwork/elrond-go-core/marshal" - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-go/api/logs" - elrondShared "github.com/ElrondNetwork/elrond-go/api/shared" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" "github.com/gorilla/websocket" + "github.com/multiversx/mx-chain-core-go/marshal" + "github.com/multiversx/mx-chain-go/api/logs" + mxChainShared "github.com/multiversx/mx-chain-go/api/shared" + logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/core" ) var log = logger.GetOrCreate("api") type webServer struct { sync.RWMutex - httpServer elrondShared.HttpServerCloser + httpServer mxChainShared.HttpServerCloser apiInterface string cancelFunc func() } diff --git a/aggregator/api/gin/webServer_test.go b/aggregator/api/gin/webServer_test.go index f2b1fcd3..071c4c64 100644 --- a/aggregator/api/gin/webServer_test.go +++ b/aggregator/api/gin/webServer_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/core/check" + "github.com/multiversx/mx-chain-core-go/core/check" "github.com/stretchr/testify/assert" ) diff --git a/aggregator/api/gin/writers.go b/aggregator/api/gin/writers.go index 8cc4a4c6..0e7f3dbb 100644 --- a/aggregator/api/gin/writers.go +++ b/aggregator/api/gin/writers.go @@ -5,7 +5,7 @@ import "bytes" type ginWriter struct { } -// Write will output the message using elrond-go-logger's logger +// Write will output the message using mx-chain-logger-go's logger func (gv *ginWriter) Write(p []byte) (n int, err error) { trimmed := bytes.TrimSpace(p) log.Trace("gin server", "message", string(trimmed)) @@ -16,7 +16,7 @@ func (gv *ginWriter) Write(p []byte) (n int, err error) { type ginErrorWriter struct { } -// Write will output the error using elrond-go-logger's logger +// Write will output the error using mx-chain-logger-go's logger func (gev *ginErrorWriter) Write(p []byte) (n int, err error) { trimmed := bytes.TrimSpace(p) log.Trace("gin server", "error", string(trimmed)) diff --git a/aggregator/computers_test.go b/aggregator/computers_test.go index 35a8b43b..3f3a1173 100644 --- a/aggregator/computers_test.go +++ b/aggregator/computers_test.go @@ -3,7 +3,7 @@ package aggregator_test import ( "testing" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator" + "github.com/multiversx/mx-sdk-go/aggregator" "github.com/stretchr/testify/assert" ) diff --git a/aggregator/fetchers/binance.go b/aggregator/fetchers/binance.go index 98f60468..930c16b6 100644 --- a/aggregator/fetchers/binance.go +++ b/aggregator/fetchers/binance.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator" + "github.com/multiversx/mx-sdk-go/aggregator" ) const ( diff --git a/aggregator/fetchers/bitfinex.go b/aggregator/fetchers/bitfinex.go index 13b6446d..aef55d97 100644 --- a/aggregator/fetchers/bitfinex.go +++ b/aggregator/fetchers/bitfinex.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator" + "github.com/multiversx/mx-sdk-go/aggregator" ) const ( diff --git a/aggregator/fetchers/cryptocom.go b/aggregator/fetchers/cryptocom.go index 96e5a551..1b0051e9 100644 --- a/aggregator/fetchers/cryptocom.go +++ b/aggregator/fetchers/cryptocom.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator" + "github.com/multiversx/mx-sdk-go/aggregator" ) const ( diff --git a/aggregator/fetchers/factory.go b/aggregator/fetchers/factory.go index 3091cf0f..4fd8adcc 100644 --- a/aggregator/fetchers/factory.go +++ b/aggregator/fetchers/factory.go @@ -3,7 +3,7 @@ package fetchers import ( "fmt" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator" + "github.com/multiversx/mx-sdk-go/aggregator" ) // MaiarTokensPair defines a base-quote pair of ids used by maiar exchange diff --git a/aggregator/fetchers/factory_test.go b/aggregator/fetchers/factory_test.go index 1e08ec0f..14a58b61 100644 --- a/aggregator/fetchers/factory_test.go +++ b/aggregator/fetchers/factory_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator/mock" + "github.com/multiversx/mx-sdk-go/aggregator/mock" "github.com/stretchr/testify/assert" ) diff --git a/aggregator/fetchers/fetchers_test.go b/aggregator/fetchers/fetchers_test.go index 5211ccbe..e6ee2f1c 100644 --- a/aggregator/fetchers/fetchers_test.go +++ b/aggregator/fetchers/fetchers_test.go @@ -9,9 +9,9 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator/mock" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-sdk-go/aggregator" + "github.com/multiversx/mx-sdk-go/aggregator/mock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/aggregator/fetchers/gemini.go b/aggregator/fetchers/gemini.go index 17614fb2..e45872c0 100644 --- a/aggregator/fetchers/gemini.go +++ b/aggregator/fetchers/gemini.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator" + "github.com/multiversx/mx-sdk-go/aggregator" ) const ( diff --git a/aggregator/fetchers/hitbtc.go b/aggregator/fetchers/hitbtc.go index 871f5ae3..69b821db 100644 --- a/aggregator/fetchers/hitbtc.go +++ b/aggregator/fetchers/hitbtc.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator" + "github.com/multiversx/mx-sdk-go/aggregator" ) const ( diff --git a/aggregator/fetchers/huobi.go b/aggregator/fetchers/huobi.go index 5708a144..ee1a25f0 100644 --- a/aggregator/fetchers/huobi.go +++ b/aggregator/fetchers/huobi.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator" + "github.com/multiversx/mx-sdk-go/aggregator" ) const ( diff --git a/aggregator/fetchers/kraken.go b/aggregator/fetchers/kraken.go index edeeff28..54616576 100644 --- a/aggregator/fetchers/kraken.go +++ b/aggregator/fetchers/kraken.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator" + "github.com/multiversx/mx-sdk-go/aggregator" ) const ( diff --git a/aggregator/fetchers/maiar.go b/aggregator/fetchers/maiar.go index 31391acc..a8e92c27 100644 --- a/aggregator/fetchers/maiar.go +++ b/aggregator/fetchers/maiar.go @@ -6,7 +6,7 @@ import ( "fmt" "time" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator" + "github.com/multiversx/mx-sdk-go/aggregator" ) const ( diff --git a/aggregator/fetchers/okex.go b/aggregator/fetchers/okex.go index e3e76bd0..b95d4c39 100644 --- a/aggregator/fetchers/okex.go +++ b/aggregator/fetchers/okex.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator" + "github.com/multiversx/mx-sdk-go/aggregator" ) const ( diff --git a/aggregator/graphqlResponseGetter.go b/aggregator/graphqlResponseGetter.go index 25bfa3e4..e9e87994 100644 --- a/aggregator/graphqlResponseGetter.go +++ b/aggregator/graphqlResponseGetter.go @@ -6,8 +6,8 @@ import ( "io" "strings" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-sdk-erdgo/authentication" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-sdk-go/authentication" "golang.org/x/oauth2" ) diff --git a/aggregator/graphqlResponseGetter_test.go b/aggregator/graphqlResponseGetter_test.go index d4d83f93..5952e535 100644 --- a/aggregator/graphqlResponseGetter_test.go +++ b/aggregator/graphqlResponseGetter_test.go @@ -6,7 +6,7 @@ import ( "net/url" "testing" - "github.com/ElrondNetwork/elrond-sdk-erdgo/authentication/mock" + "github.com/multiversx/mx-sdk-go/authentication/mock" "github.com/stretchr/testify/require" ) diff --git a/aggregator/httpResponseGetter_test.go b/aggregator/httpResponseGetter_test.go index 45165795..40a3eb7f 100644 --- a/aggregator/httpResponseGetter_test.go +++ b/aggregator/httpResponseGetter_test.go @@ -8,7 +8,7 @@ import ( "net/url" "testing" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator" + "github.com/multiversx/mx-sdk-go/aggregator" "github.com/stretchr/testify/require" ) diff --git a/aggregator/mock/priceNotifeeStub.go b/aggregator/mock/priceNotifeeStub.go index a25467eb..b2527f82 100644 --- a/aggregator/mock/priceNotifeeStub.go +++ b/aggregator/mock/priceNotifeeStub.go @@ -3,7 +3,7 @@ package mock import ( "context" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator" + "github.com/multiversx/mx-sdk-go/aggregator" ) // PriceNotifeeStub - diff --git a/aggregator/notifees/interface.go b/aggregator/notifees/interface.go index 7da8c745..81d45c2e 100644 --- a/aggregator/notifees/interface.go +++ b/aggregator/notifees/interface.go @@ -3,8 +3,8 @@ package notifees import ( "context" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" ) // TxBuilder defines the component able to build & sign a transaction @@ -13,7 +13,7 @@ type TxBuilder interface { IsInterfaceNil() bool } -// Proxy holds the primitive functions that the elrond proxy engine supports & implements +// Proxy holds the primitive functions that the multiversx proxy engine supports & implements // dependency inversion: blockchain package is considered inner business logic, this package is considered "plugin" type Proxy interface { GetNetworkConfig(ctx context.Context) (*data.NetworkConfig, error) diff --git a/aggregator/notifees/elrondNotifee.go b/aggregator/notifees/mxNotifee.go similarity index 73% rename from aggregator/notifees/elrondNotifee.go rename to aggregator/notifees/mxNotifee.go index 24fa35e8..339c492c 100644 --- a/aggregator/notifees/elrondNotifee.go +++ b/aggregator/notifees/mxNotifee.go @@ -3,12 +3,12 @@ package notifees import ( "context" - "github.com/ElrondNetwork/elrond-go-core/core/check" - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator" - "github.com/ElrondNetwork/elrond-sdk-erdgo/builders" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-chain-core-go/core/check" + logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/aggregator" + "github.com/multiversx/mx-sdk-go/builders" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" ) const zeroString = "0" @@ -16,10 +16,10 @@ const txVersion = uint32(1) const function = "submitBatch" const minGasLimit = uint64(1) -var log = logger.GetOrCreate("elrond-sdk-erdgo/aggregator/notifees") +var log = logger.GetOrCreate("mx-sdk-go/aggregator/notifees") -// ArgsElrondNotifee is the argument DTO for the NewElrondNotifee function -type ArgsElrondNotifee struct { +// ArgsMxNotifee is the argument DTO for the NewMxNotifee function +type ArgsMxNotifee struct { Proxy Proxy TxBuilder TxBuilder TxNonceHandler TransactionNonceHandler @@ -29,7 +29,7 @@ type ArgsElrondNotifee struct { GasLimitForEach uint64 } -type elrondNotifee struct { +type mxNotifee struct { proxy Proxy txBuilder TxBuilder txNonceHandler TransactionNonceHandler @@ -39,14 +39,14 @@ type elrondNotifee struct { cryptoHolder core.CryptoComponentsHolder } -// NewElrondNotifee will create a new instance of elrondNotifee -func NewElrondNotifee(args ArgsElrondNotifee) (*elrondNotifee, error) { - err := checkArgsElrondNotifee(args) +// NewMxNotifee will create a new instance of mxNotifee +func NewMxNotifee(args ArgsMxNotifee) (*mxNotifee, error) { + err := checkArgsMxNotifee(args) if err != nil { return nil, err } - notifee := &elrondNotifee{ + notifee := &mxNotifee{ proxy: args.Proxy, txBuilder: args.TxBuilder, txNonceHandler: args.TxNonceHandler, @@ -59,7 +59,7 @@ func NewElrondNotifee(args ArgsElrondNotifee) (*elrondNotifee, error) { return notifee, nil } -func checkArgsElrondNotifee(args ArgsElrondNotifee) error { +func checkArgsMxNotifee(args ArgsMxNotifee) error { if check.IfNil(args.Proxy) { return errNilProxy } @@ -88,9 +88,9 @@ func checkArgsElrondNotifee(args ArgsElrondNotifee) error { return nil } -// PriceChanged is the function that gets called by a price notifier. This function will assemble an Elrond +// PriceChanged is the function that gets called by a price notifier. This function will assemble a MultiversX // transaction, having the transaction's data field containing all the price changes information -func (en *elrondNotifee) PriceChanged(ctx context.Context, priceChanges []*aggregator.ArgsPriceChanged) error { +func (en *mxNotifee) PriceChanged(ctx context.Context, priceChanges []*aggregator.ArgsPriceChanged) error { txData, err := en.prepareTxData(priceChanges) if err != nil { return err @@ -132,7 +132,7 @@ func (en *elrondNotifee) PriceChanged(ctx context.Context, priceChanges []*aggre return nil } -func (en *elrondNotifee) prepareTxData(priceChanges []*aggregator.ArgsPriceChanged) ([]byte, error) { +func (en *mxNotifee) prepareTxData(priceChanges []*aggregator.ArgsPriceChanged) ([]byte, error) { txDataBuilder := builders.NewTxDataBuilder() txDataBuilder.Function(function) @@ -148,6 +148,6 @@ func (en *elrondNotifee) prepareTxData(priceChanges []*aggregator.ArgsPriceChang } // IsInterfaceNil returns true if there is no value under the interface -func (en *elrondNotifee) IsInterfaceNil() bool { +func (en *mxNotifee) IsInterfaceNil() bool { return en == nil } diff --git a/aggregator/notifees/elrondNotifee_test.go b/aggregator/notifees/mxNotifee_test.go similarity index 81% rename from aggregator/notifees/elrondNotifee_test.go rename to aggregator/notifees/mxNotifee_test.go index e07d3bc0..eebb452d 100644 --- a/aggregator/notifees/elrondNotifee_test.go +++ b/aggregator/notifees/mxNotifee_test.go @@ -9,15 +9,15 @@ import ( "strings" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-crypto/signing" - "github.com/ElrondNetwork/elrond-go-crypto/signing/ed25519" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain/cryptoProvider" - "github.com/ElrondNetwork/elrond-sdk-erdgo/builders" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-crypto-go/signing" + "github.com/multiversx/mx-chain-crypto-go/signing/ed25519" + "github.com/multiversx/mx-sdk-go/aggregator" + "github.com/multiversx/mx-sdk-go/blockchain/cryptoProvider" + "github.com/multiversx/mx-sdk-go/builders" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/testsCommon" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -27,8 +27,8 @@ var ( keyGen = signing.NewKeyGenerator(suite) ) -func createMockArgsElrondNotifee() ArgsElrondNotifee { - return ArgsElrondNotifee{ +func createMockArgsMxNotifee() ArgsMxNotifee { + return ArgsMxNotifee{ Proxy: &testsCommon.ProxyStub{}, TxBuilder: &testsCommon.TxBuilderStub{}, TxNonceHandler: &testsCommon.TxNonceHandlerV2Stub{}, @@ -39,7 +39,7 @@ func createMockArgsElrondNotifee() ArgsElrondNotifee { } } -func createMockArgsElrondNotifeeWithSomeRealComponents() ArgsElrondNotifee { +func createMockArgsMxNotifeeWithSomeRealComponents() ArgsMxNotifee { proxy := &testsCommon.ProxyStub{ GetNetworkConfigCalled: func() (*data.NetworkConfig, error) { return &data.NetworkConfig{ @@ -54,7 +54,7 @@ func createMockArgsElrondNotifeeWithSomeRealComponents() ArgsElrondNotifee { holder, _ := cryptoProvider.NewCryptoComponentsHolder(keyGen, skBytes) txBuilder, _ := builders.NewTxBuilder(cryptoProvider.NewSigner()) - return ArgsElrondNotifee{ + return ArgsMxNotifee{ Proxy: proxy, TxBuilder: txBuilder, TxNonceHandler: &testsCommon.TxNonceHandlerV2Stub{}, @@ -84,15 +84,15 @@ func createMockPriceChanges() []*aggregator.ArgsPriceChanged { } } -func TestNewElrondNotifee(t *testing.T) { +func TestNewMxNotifee(t *testing.T) { t.Parallel() t.Run("nil proxy should error", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondNotifee() + args := createMockArgsMxNotifee() args.Proxy = nil - en, err := NewElrondNotifee(args) + en, err := NewMxNotifee(args) assert.True(t, check.IfNil(en)) assert.Equal(t, errNilProxy, err) @@ -100,9 +100,9 @@ func TestNewElrondNotifee(t *testing.T) { t.Run("nil tx builder should error", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondNotifee() + args := createMockArgsMxNotifee() args.TxBuilder = nil - en, err := NewElrondNotifee(args) + en, err := NewMxNotifee(args) assert.True(t, check.IfNil(en)) assert.Equal(t, errNilTxBuilder, err) @@ -110,9 +110,9 @@ func TestNewElrondNotifee(t *testing.T) { t.Run("nil tx nonce handler should error", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondNotifee() + args := createMockArgsMxNotifee() args.TxNonceHandler = nil - en, err := NewElrondNotifee(args) + en, err := NewMxNotifee(args) assert.True(t, check.IfNil(en)) assert.Equal(t, errNilTxNonceHandler, err) @@ -120,9 +120,9 @@ func TestNewElrondNotifee(t *testing.T) { t.Run("nil contract address should error", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondNotifee() + args := createMockArgsMxNotifee() args.ContractAddress = nil - en, err := NewElrondNotifee(args) + en, err := NewMxNotifee(args) assert.True(t, check.IfNil(en)) assert.Equal(t, errNilContractAddressHandler, err) @@ -130,9 +130,9 @@ func TestNewElrondNotifee(t *testing.T) { t.Run("invalid contract address should error", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondNotifee() + args := createMockArgsMxNotifee() args.ContractAddress = data.NewAddressFromBytes([]byte("invalid")) - en, err := NewElrondNotifee(args) + en, err := NewMxNotifee(args) assert.True(t, check.IfNil(en)) assert.Equal(t, errInvalidContractAddress, err) @@ -140,9 +140,9 @@ func TestNewElrondNotifee(t *testing.T) { t.Run("nil cryptoHlder should error", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondNotifee() + args := createMockArgsMxNotifee() args.CryptoHolder = nil - en, err := NewElrondNotifee(args) + en, err := NewMxNotifee(args) assert.True(t, check.IfNil(en)) assert.Equal(t, builders.ErrNilCryptoComponentsHolder, err) @@ -150,9 +150,9 @@ func TestNewElrondNotifee(t *testing.T) { t.Run("invalid base gas limit should error", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondNotifee() + args := createMockArgsMxNotifee() args.BaseGasLimit = minGasLimit - 1 - en, err := NewElrondNotifee(args) + en, err := NewMxNotifee(args) assert.True(t, check.IfNil(en)) assert.Equal(t, errInvalidBaseGasLimit, err) @@ -160,9 +160,9 @@ func TestNewElrondNotifee(t *testing.T) { t.Run("invalid gas limit for each should error", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondNotifee() + args := createMockArgsMxNotifee() args.GasLimitForEach = minGasLimit - 1 - en, err := NewElrondNotifee(args) + en, err := NewMxNotifee(args) assert.True(t, check.IfNil(en)) assert.Equal(t, errInvalidGasLimitForEach, err) @@ -170,22 +170,22 @@ func TestNewElrondNotifee(t *testing.T) { t.Run("should work", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondNotifee() - en, err := NewElrondNotifee(args) + args := createMockArgsMxNotifee() + en, err := NewMxNotifee(args) assert.False(t, check.IfNil(en)) assert.Nil(t, err) }) } -func TestElrondNotifee_PriceChanged(t *testing.T) { +func TestMxNotifee_PriceChanged(t *testing.T) { t.Parallel() t.Run("get nonce errors", func(t *testing.T) { t.Parallel() expectedErr := errors.New("expected error") - args := createMockArgsElrondNotifeeWithSomeRealComponents() + args := createMockArgsMxNotifeeWithSomeRealComponents() args.TxNonceHandler = &testsCommon.TxNonceHandlerV2Stub{ ApplyNonceAndGasPriceCalled: func(ctx context.Context, address core.AddressHandler, txArgs *data.ArgCreateTransaction) error { return expectedErr @@ -196,7 +196,7 @@ func TestElrondNotifee_PriceChanged(t *testing.T) { }, } - en, err := NewElrondNotifee(args) + en, err := NewMxNotifee(args) require.Nil(t, err) priceChanges := createMockPriceChanges() @@ -206,7 +206,7 @@ func TestElrondNotifee_PriceChanged(t *testing.T) { t.Run("invalid price arguments", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondNotifeeWithSomeRealComponents() + args := createMockArgsMxNotifeeWithSomeRealComponents() args.TxNonceHandler = &testsCommon.TxNonceHandlerV2Stub{ ApplyNonceAndGasPriceCalled: func(ctx context.Context, address core.AddressHandler, txArgs *data.ArgCreateTransaction) error { txArgs.Nonce = 43 @@ -218,7 +218,7 @@ func TestElrondNotifee_PriceChanged(t *testing.T) { }, } - en, err := NewElrondNotifee(args) + en, err := NewMxNotifee(args) require.Nil(t, err) priceChanges := createMockPriceChanges() @@ -230,7 +230,7 @@ func TestElrondNotifee_PriceChanged(t *testing.T) { t.Parallel() expectedErr := errors.New("expected error") - args := createMockArgsElrondNotifeeWithSomeRealComponents() + args := createMockArgsMxNotifeeWithSomeRealComponents() args.Proxy = &testsCommon.ProxyStub{ GetNetworkConfigCalled: func() (*data.NetworkConfig, error) { return nil, expectedErr @@ -247,7 +247,7 @@ func TestElrondNotifee_PriceChanged(t *testing.T) { }, } - en, err := NewElrondNotifee(args) + en, err := NewMxNotifee(args) require.Nil(t, err) priceChanges := createMockPriceChanges() @@ -258,7 +258,7 @@ func TestElrondNotifee_PriceChanged(t *testing.T) { t.Parallel() expectedErr := errors.New("expected error") - args := createMockArgsElrondNotifeeWithSomeRealComponents() + args := createMockArgsMxNotifeeWithSomeRealComponents() args.TxNonceHandler = &testsCommon.TxNonceHandlerV2Stub{ ApplyNonceAndGasPriceCalled: func(ctx context.Context, address core.AddressHandler, txArgs *data.ArgCreateTransaction) error { txArgs.Nonce = 43 @@ -275,7 +275,7 @@ func TestElrondNotifee_PriceChanged(t *testing.T) { }, } - en, err := NewElrondNotifee(args) + en, err := NewMxNotifee(args) require.Nil(t, err) priceChanges := createMockPriceChanges() @@ -286,7 +286,7 @@ func TestElrondNotifee_PriceChanged(t *testing.T) { t.Parallel() expectedErr := errors.New("expected error") - args := createMockArgsElrondNotifeeWithSomeRealComponents() + args := createMockArgsMxNotifeeWithSomeRealComponents() args.TxNonceHandler = &testsCommon.TxNonceHandlerV2Stub{ ApplyNonceAndGasPriceCalled: func(ctx context.Context, address core.AddressHandler, txArgs *data.ArgCreateTransaction) error { txArgs.Nonce = 43 @@ -297,7 +297,7 @@ func TestElrondNotifee_PriceChanged(t *testing.T) { }, } - en, err := NewElrondNotifee(args) + en, err := NewMxNotifee(args) require.Nil(t, err) priceChanges := createMockPriceChanges() @@ -309,7 +309,7 @@ func TestElrondNotifee_PriceChanged(t *testing.T) { priceChanges := createMockPriceChanges() sentWasCalled := false - args := createMockArgsElrondNotifeeWithSomeRealComponents() + args := createMockArgsMxNotifeeWithSomeRealComponents() args.TxNonceHandler = &testsCommon.TxNonceHandlerV2Stub{ ApplyNonceAndGasPriceCalled: func(ctx context.Context, address core.AddressHandler, txArgs *data.ArgCreateTransaction) error { txArgs.Nonce = 43 @@ -348,7 +348,7 @@ func TestElrondNotifee_PriceChanged(t *testing.T) { }, } - en, err := NewElrondNotifee(args) + en, err := NewMxNotifee(args) require.Nil(t, err) err = en.PriceChanged(context.Background(), priceChanges) diff --git a/aggregator/pair_test.go b/aggregator/pair_test.go index 7d63377e..3f2102a1 100644 --- a/aggregator/pair_test.go +++ b/aggregator/pair_test.go @@ -4,7 +4,7 @@ import ( "errors" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" + "github.com/multiversx/mx-chain-core-go/core/check" "github.com/stretchr/testify/assert" ) diff --git a/aggregator/priceAggregator.go b/aggregator/priceAggregator.go index 32804a53..b05a610a 100644 --- a/aggregator/priceAggregator.go +++ b/aggregator/priceAggregator.go @@ -6,13 +6,13 @@ import ( "strings" "sync" - "github.com/ElrondNetwork/elrond-go-core/core/check" - logger "github.com/ElrondNetwork/elrond-go-logger" + "github.com/multiversx/mx-chain-core-go/core/check" + logger "github.com/multiversx/mx-chain-logger-go" ) const minResultsNum = 1 -var log = logger.GetOrCreate("elrond-sdk-erdgo/aggregator") +var log = logger.GetOrCreate("mx-sdk-go/aggregator") // ArgsPriceAggregator is the DTO used in the NewPriceAggregator function type ArgsPriceAggregator struct { diff --git a/aggregator/priceAggregator_test.go b/aggregator/priceAggregator_test.go index 6f38e857..4554d522 100644 --- a/aggregator/priceAggregator_test.go +++ b/aggregator/priceAggregator_test.go @@ -5,9 +5,9 @@ import ( "errors" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator/mock" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-sdk-go/aggregator" + "github.com/multiversx/mx-sdk-go/aggregator/mock" "github.com/stretchr/testify/assert" ) diff --git a/aggregator/priceNotifier.go b/aggregator/priceNotifier.go index ef78a02a..d2f14107 100644 --- a/aggregator/priceNotifier.go +++ b/aggregator/priceNotifier.go @@ -7,7 +7,7 @@ import ( "sync" "time" - "github.com/ElrondNetwork/elrond-go-core/core/check" + "github.com/multiversx/mx-chain-core-go/core/check" ) const epsilon = 0.0001 diff --git a/aggregator/priceNotifier_test.go b/aggregator/priceNotifier_test.go index 8362f5aa..b5edeaaf 100644 --- a/aggregator/priceNotifier_test.go +++ b/aggregator/priceNotifier_test.go @@ -8,9 +8,9 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator/mock" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-sdk-go/aggregator" + "github.com/multiversx/mx-sdk-go/aggregator/mock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/authentication/native.go b/authentication/native.go index ac1b8832..55879ad0 100644 --- a/authentication/native.go +++ b/authentication/native.go @@ -7,10 +7,10 @@ import ( "fmt" "time" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-sdk-erdgo/builders" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/workflows" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-sdk-go/builders" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/workflows" ) // ArgsNativeAuthClient is the DTO used in the native auth client constructor @@ -68,7 +68,7 @@ func NewNativeAuthClient(args ArgsNativeAuthClient) (*nativeAuthClient, error) { }, nil } -// GetAccessToken returns an access token used for authentication into different elrond services +// GetAccessToken returns an access token used for authentication into different MultiversX services func (nac *nativeAuthClient) GetAccessToken() (string, error) { now := nac.getTimeHandler() noToken := nac.tokenExpire.IsZero() diff --git a/authentication/native_test.go b/authentication/native_test.go index 2b16b84c..227f7052 100644 --- a/authentication/native_test.go +++ b/authentication/native_test.go @@ -8,9 +8,9 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-crypto" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" + "github.com/multiversx/mx-chain-crypto-go" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/testsCommon" "github.com/stretchr/testify/require" ) diff --git a/blockchain/addressGenerator.go b/blockchain/addressGenerator.go index 5ef42287..9f0ecb63 100644 --- a/blockchain/addressGenerator.go +++ b/blockchain/addressGenerator.go @@ -3,26 +3,26 @@ package blockchain import ( "bytes" - elrondCore "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/data/typeConverters/uint64ByteSlice" - "github.com/ElrondNetwork/elrond-go-core/hashing" - "github.com/ElrondNetwork/elrond-go-core/hashing/keccak" - "github.com/ElrondNetwork/elrond-go-core/marshal" - "github.com/ElrondNetwork/elrond-go/process" - "github.com/ElrondNetwork/elrond-go/process/factory" - "github.com/ElrondNetwork/elrond-go/process/smartContract/hooks" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/disabled" - "github.com/ElrondNetwork/elrond-sdk-erdgo/storage" + mxChainCore "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/data/typeConverters/uint64ByteSlice" + "github.com/multiversx/mx-chain-core-go/hashing" + "github.com/multiversx/mx-chain-core-go/hashing/keccak" + "github.com/multiversx/mx-chain-core-go/marshal" + "github.com/multiversx/mx-chain-go/process" + "github.com/multiversx/mx-chain-go/process/factory" + "github.com/multiversx/mx-chain-go/process/smartContract/hooks" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/disabled" + "github.com/multiversx/mx-sdk-go/storage" ) const accountStartNonce = uint64(0) var initialDNSAddress = bytes.Repeat([]byte{1}, 32) -// addressGenerator is used to generate some addresses based on elrond-go logic +// addressGenerator is used to generate some addresses based on mx-chain-go logic type addressGenerator struct { coordinator *shardCoordinator blockChainHook process.BlockChainHookHandler @@ -42,7 +42,7 @@ func NewAddressGenerator(coordinator *shardCoordinator) (*addressGenerator, erro PubkeyConv: core.AddressPublicKeyConverter, StorageService: &disabled.StorageService{}, BlockChain: &disabled.Blockchain{}, - ShardCoordinator: &disabled.ElrondShardCoordinator{}, + ShardCoordinator: &disabled.ShardCoordinator{}, Marshalizer: &marshal.JsonMarshalizer{}, Uint64Converter: uint64ByteSlice.NewBigEndianConverter(), BuiltInFunctions: builtInFuncs, @@ -73,8 +73,8 @@ func (ag *addressGenerator) CompatibleDNSAddress(shardId byte) (core.AddressHand addressLen := len(initialDNSAddress) shardInBytes := []byte{0, shardId} - newDNSPk := string(initialDNSAddress[:(addressLen-elrondCore.ShardIdentiferLen)]) + string(shardInBytes) - newDNSAddress, err := ag.blockChainHook.NewAddress([]byte(newDNSPk), accountStartNonce, factory.ArwenVirtualMachine) + newDNSPk := string(initialDNSAddress[:(addressLen-mxChainCore.ShardIdentiferLen)]) + string(shardInBytes) + newDNSAddress, err := ag.blockChainHook.NewAddress([]byte(newDNSPk), accountStartNonce, factory.WasmVirtualMachine) if err != nil { return nil, err } @@ -96,7 +96,7 @@ func (ag *addressGenerator) ComputeArwenScAddress(address core.AddressHandler, n return nil, ErrNilAddress } - scAddressBytes, err := ag.blockChainHook.NewAddress(address.AddressBytes(), nonce, factory.ArwenVirtualMachine) + scAddressBytes, err := ag.blockChainHook.NewAddress(address.AddressBytes(), nonce, factory.WasmVirtualMachine) if err != nil { return nil, err } diff --git a/blockchain/addressGenerator_test.go b/blockchain/addressGenerator_test.go index 1e58c3ba..0abb6c96 100644 --- a/blockchain/addressGenerator_test.go +++ b/blockchain/addressGenerator_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-sdk-go/data" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/blockchain/elrondBaseProxy.go b/blockchain/baseProxy.go similarity index 75% rename from blockchain/elrondBaseProxy.go rename to blockchain/baseProxy.go index b84fc795..bffc2d73 100644 --- a/blockchain/elrondBaseProxy.go +++ b/blockchain/baseProxy.go @@ -9,25 +9,25 @@ import ( "sync" "time" - "github.com/ElrondNetwork/elrond-go-core/core/check" - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-chain-core-go/core/check" + logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" ) -var log = logger.GetOrCreate("elrond-sdk-erdgo/blockchain") +var log = logger.GetOrCreate("mx-sdk-go/blockchain") const ( minimumCachingInterval = time.Second ) -type argsElrondBaseProxy struct { +type argsBaseProxy struct { expirationTime time.Duration httpClientWrapper httpClientWrapper endpointProvider EndpointProvider } -type elrondBaseProxy struct { +type baseProxy struct { httpClientWrapper mut sync.RWMutex fetchedConfigs *data.NetworkConfig @@ -37,14 +37,14 @@ type elrondBaseProxy struct { endpointProvider EndpointProvider } -// newElrondBaseProxy will create a base elrond proxy with cache instance -func newElrondBaseProxy(args argsElrondBaseProxy) (*elrondBaseProxy, error) { +// newBaseProxy will create a base multiversx proxy with cache instance +func newBaseProxy(args argsBaseProxy) (*baseProxy, error) { err := checkArgsBaseProxy(args) if err != nil { return nil, err } - return &elrondBaseProxy{ + return &baseProxy{ httpClientWrapper: args.httpClientWrapper, cacheExpiryDuration: args.expirationTime, endpointProvider: args.endpointProvider, @@ -52,7 +52,7 @@ func newElrondBaseProxy(args argsElrondBaseProxy) (*elrondBaseProxy, error) { }, nil } -func checkArgsBaseProxy(args argsElrondBaseProxy) error { +func checkArgsBaseProxy(args argsBaseProxy) error { if args.expirationTime < minimumCachingInterval { return fmt.Errorf("%w, provided: %v, minimum: %v", ErrInvalidCacherDuration, args.expirationTime, minimumCachingInterval) } @@ -71,7 +71,7 @@ func since(t time.Time) time.Duration { } // GetNetworkConfig will return the cached network configs fetching new values and saving them if necessary -func (proxy *elrondBaseProxy) GetNetworkConfig(ctx context.Context) (*data.NetworkConfig, error) { +func (proxy *baseProxy) GetNetworkConfig(ctx context.Context) (*data.NetworkConfig, error) { proxy.mut.RLock() cachedConfigs := proxy.getCachedConfigs() proxy.mut.RUnlock() @@ -83,7 +83,7 @@ func (proxy *elrondBaseProxy) GetNetworkConfig(ctx context.Context) (*data.Netwo return proxy.cacheConfigs(ctx) } -func (proxy *elrondBaseProxy) getCachedConfigs() *data.NetworkConfig { +func (proxy *baseProxy) getCachedConfigs() *data.NetworkConfig { if proxy.sinceTimeHandler(proxy.lastFetchedTime) > proxy.cacheExpiryDuration { return nil } @@ -91,7 +91,7 @@ func (proxy *elrondBaseProxy) getCachedConfigs() *data.NetworkConfig { return proxy.fetchedConfigs } -func (proxy *elrondBaseProxy) cacheConfigs(ctx context.Context) (*data.NetworkConfig, error) { +func (proxy *baseProxy) cacheConfigs(ctx context.Context) (*data.NetworkConfig, error) { proxy.mut.Lock() defer proxy.mut.Unlock() @@ -114,7 +114,7 @@ func (proxy *elrondBaseProxy) cacheConfigs(ctx context.Context) (*data.NetworkCo } // getNetworkConfigFromSource retrieves the network configuration from the proxy -func (proxy *elrondBaseProxy) getNetworkConfigFromSource(ctx context.Context) (*data.NetworkConfig, error) { +func (proxy *baseProxy) getNetworkConfigFromSource(ctx context.Context) (*data.NetworkConfig, error) { buff, code, err := proxy.GetHTTP(ctx, proxy.endpointProvider.GetNetworkConfig()) if err != nil || code != http.StatusOK { return nil, createHTTPStatusError(code, err) @@ -134,7 +134,7 @@ func (proxy *elrondBaseProxy) getNetworkConfigFromSource(ctx context.Context) (* // GetShardOfAddress returns the shard ID of a provided address by using a shardCoordinator object and querying the // network config route -func (proxy *elrondBaseProxy) GetShardOfAddress(ctx context.Context, bech32Address string) (uint32, error) { +func (proxy *baseProxy) GetShardOfAddress(ctx context.Context, bech32Address string) (uint32, error) { addr, err := data.NewAddressFromBech32String(bech32Address) if err != nil { return 0, err @@ -154,7 +154,7 @@ func (proxy *elrondBaseProxy) GetShardOfAddress(ctx context.Context, bech32Addre } // GetNetworkStatus will return the network status of a provided shard -func (proxy *elrondBaseProxy) GetNetworkStatus(ctx context.Context, shardID uint32) (*data.NetworkStatus, error) { +func (proxy *baseProxy) GetNetworkStatus(ctx context.Context, shardID uint32) (*data.NetworkStatus, error) { endpoint := proxy.endpointProvider.GetNodeStatus(shardID) buff, code, err := proxy.GetHTTP(ctx, endpoint) if err != nil || code != http.StatusOK { @@ -172,7 +172,7 @@ func (proxy *elrondBaseProxy) GetNetworkStatus(ctx context.Context, shardID uint return &data.NetworkStatus{}, ErrInvalidEndpointProvider } -func (proxy *elrondBaseProxy) getNetworkStatus(buff []byte, shardID uint32) (*data.NetworkStatus, error) { +func (proxy *baseProxy) getNetworkStatus(buff []byte, shardID uint32) (*data.NetworkStatus, error) { response := &data.NetworkStatusResponse{} err := json.Unmarshal(buff, response) if err != nil { @@ -190,7 +190,7 @@ func (proxy *elrondBaseProxy) getNetworkStatus(buff []byte, shardID uint32) (*da return response.Data.Status, nil } -func (proxy *elrondBaseProxy) getNodeStatus(buff []byte, shardID uint32) (*data.NetworkStatus, error) { +func (proxy *baseProxy) getNodeStatus(buff []byte, shardID uint32) (*data.NetworkStatus, error) { response := &data.NodeStatusResponse{} err := json.Unmarshal(buff, response) if err != nil { @@ -208,7 +208,7 @@ func (proxy *elrondBaseProxy) getNodeStatus(buff []byte, shardID uint32) (*data. return response.Data.Status, nil } -func (proxy *elrondBaseProxy) checkReceivedNodeStatus(networkStatus *data.NetworkStatus, shardID uint32) error { +func (proxy *baseProxy) checkReceivedNodeStatus(networkStatus *data.NetworkStatus, shardID uint32) error { if networkStatus == nil { return fmt.Errorf("%w, requested from %d", ErrNilNetworkStatus, shardID) } @@ -223,11 +223,11 @@ func (proxy *elrondBaseProxy) checkReceivedNodeStatus(networkStatus *data.Networ } // GetRestAPIEntityType returns the REST API entity type that this implementation works with -func (proxy *elrondBaseProxy) GetRestAPIEntityType() core.RestAPIEntityType { +func (proxy *baseProxy) GetRestAPIEntityType() core.RestAPIEntityType { return proxy.endpointProvider.GetRestAPIEntityType() } // IsInterfaceNil returns true if there is no value under the interface -func (proxy *elrondBaseProxy) IsInterfaceNil() bool { +func (proxy *baseProxy) IsInterfaceNil() bool { return proxy == nil } diff --git a/blockchain/elrondBaseProxy_test.go b/blockchain/baseProxy_test.go similarity index 86% rename from blockchain/elrondBaseProxy_test.go rename to blockchain/baseProxy_test.go index b3045bfd..5351fe0e 100644 --- a/blockchain/elrondBaseProxy_test.go +++ b/blockchain/baseProxy_test.go @@ -9,32 +9,32 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain/endpointProviders" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-sdk-go/blockchain/endpointProviders" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/testsCommon" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -func createMockArgsElrondBaseProxy() argsElrondBaseProxy { - return argsElrondBaseProxy{ +func createMockArgsBaseProxy() argsBaseProxy { + return argsBaseProxy{ httpClientWrapper: &testsCommon.HTTPClientWrapperStub{}, expirationTime: time.Second, endpointProvider: endpointProviders.NewNodeEndpointProvider(), } } -func TestNewElrondBaseProxy(t *testing.T) { +func TestNewBaseProxy(t *testing.T) { t.Parallel() t.Run("nil http client wrapper", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.httpClientWrapper = nil - baseProxy, err := newElrondBaseProxy(args) + baseProxy, err := newBaseProxy(args) assert.True(t, check.IfNil(baseProxy)) assert.True(t, errors.Is(err, ErrNilHTTPClientWrapper)) @@ -42,9 +42,9 @@ func TestNewElrondBaseProxy(t *testing.T) { t.Run("invalid caching duration", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.expirationTime = time.Second - time.Nanosecond - baseProxy, err := newElrondBaseProxy(args) + baseProxy, err := newBaseProxy(args) assert.True(t, check.IfNil(baseProxy)) assert.True(t, errors.Is(err, ErrInvalidCacherDuration)) @@ -52,9 +52,9 @@ func TestNewElrondBaseProxy(t *testing.T) { t.Run("nil endpoint provider", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.endpointProvider = nil - baseProxy, err := newElrondBaseProxy(args) + baseProxy, err := newBaseProxy(args) assert.True(t, check.IfNil(baseProxy)) assert.True(t, errors.Is(err, ErrNilEndpointProvider)) @@ -62,15 +62,15 @@ func TestNewElrondBaseProxy(t *testing.T) { t.Run("should work", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondBaseProxy() - baseProxy, err := newElrondBaseProxy(args) + args := createMockArgsBaseProxy() + baseProxy, err := newBaseProxy(args) assert.False(t, check.IfNil(baseProxy)) assert.Nil(t, err) }) } -func TestElrondBaseProxy_GetNetworkConfig(t *testing.T) { +func TestBaseProxy_GetNetworkConfig(t *testing.T) { t.Parallel() expectedReturnedNetworkConfig := &data.NetworkConfig{ @@ -110,10 +110,10 @@ func TestElrondBaseProxy_GetNetworkConfig(t *testing.T) { return networkConfigBytes, http.StatusOK, nil } - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.httpClientWrapper = mockWrapper args.expirationTime = minimumCachingInterval * 2 - baseProxy, _ := newElrondBaseProxy(args) + baseProxy, _ := newBaseProxy(args) baseProxy.sinceTimeHandler = func(t time.Time) time.Duration { return minimumCachingInterval } @@ -134,10 +134,10 @@ func TestElrondBaseProxy_GetNetworkConfig(t *testing.T) { return networkConfigBytes, http.StatusOK, nil } - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.httpClientWrapper = mockWrapper args.expirationTime = minimumCachingInterval * 2 - baseProxy, _ := newElrondBaseProxy(args) + baseProxy, _ := newBaseProxy(args) baseProxy.sinceTimeHandler = func(t time.Time) time.Duration { return minimumCachingInterval*2 + time.Millisecond } @@ -159,9 +159,9 @@ func TestElrondBaseProxy_GetNetworkConfig(t *testing.T) { return nil, http.StatusBadRequest, expectedErr } - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.httpClientWrapper = mockWrapper - baseProxy, _ := newElrondBaseProxy(args) + baseProxy, _ := newBaseProxy(args) configs, err := baseProxy.GetNetworkConfig(context.Background()) @@ -180,9 +180,9 @@ func TestElrondBaseProxy_GetNetworkConfig(t *testing.T) { return []byte("malformed data"), http.StatusOK, nil } - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.httpClientWrapper = mockWrapper - baseProxy, _ := newElrondBaseProxy(args) + baseProxy, _ := newBaseProxy(args) configs, err := baseProxy.GetNetworkConfig(context.Background()) @@ -211,9 +211,9 @@ func TestElrondBaseProxy_GetNetworkConfig(t *testing.T) { return erroredNetworkConfigBytes, http.StatusOK, nil } - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.httpClientWrapper = mockWrapper - baseProxy, _ := newElrondBaseProxy(args) + baseProxy, _ := newBaseProxy(args) configs, err := baseProxy.GetNetworkConfig(context.Background()) @@ -232,10 +232,10 @@ func TestElrondBaseProxy_GetNetworkConfig(t *testing.T) { return nil, http.StatusOK, nil } - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.httpClientWrapper = mockWrapper args.expirationTime = minimumCachingInterval * 2 - baseProxy, _ := newElrondBaseProxy(args) + baseProxy, _ := newBaseProxy(args) baseProxy.fetchedConfigs = expectedReturnedNetworkConfig baseProxy.sinceTimeHandler = func(t time.Time) time.Duration { return minimumCachingInterval @@ -249,20 +249,20 @@ func TestElrondBaseProxy_GetNetworkConfig(t *testing.T) { }) } -func TestElrondBaseProxy_GetNetworkStatus(t *testing.T) { +func TestBaseProxy_GetNetworkStatus(t *testing.T) { t.Parallel() expectedErr := errors.New("expected error") t.Run("get errors", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{ GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) { return nil, http.StatusBadRequest, expectedErr }, } - baseProxy, _ := newElrondBaseProxy(args) + baseProxy, _ := newBaseProxy(args) result, err := baseProxy.GetNetworkStatus(context.Background(), 0) assert.Nil(t, result) @@ -272,13 +272,13 @@ func TestElrondBaseProxy_GetNetworkStatus(t *testing.T) { t.Run("malformed response - node endpoint provider", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{ GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) { return []byte("malformed response"), http.StatusOK, nil }, } - baseProxy, _ := newElrondBaseProxy(args) + baseProxy, _ := newBaseProxy(args) result, err := baseProxy.GetNetworkStatus(context.Background(), 0) assert.Nil(t, result) @@ -288,14 +288,14 @@ func TestElrondBaseProxy_GetNetworkStatus(t *testing.T) { t.Run("malformed response - proxy endpoint provider", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.endpointProvider = endpointProviders.NewProxyEndpointProvider() args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{ GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) { return []byte("malformed response"), http.StatusOK, nil }, } - baseProxy, _ := newElrondBaseProxy(args) + baseProxy, _ := newBaseProxy(args) result, err := baseProxy.GetNetworkStatus(context.Background(), 0) assert.Nil(t, result) @@ -314,13 +314,13 @@ func TestElrondBaseProxy_GetNetworkStatus(t *testing.T) { } respBytes, _ := json.Marshal(resp) - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{ GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) { return respBytes, http.StatusOK, nil }, } - baseProxy, _ := newElrondBaseProxy(args) + baseProxy, _ := newBaseProxy(args) result, err := baseProxy.GetNetworkStatus(context.Background(), 0) assert.Nil(t, result) @@ -339,14 +339,14 @@ func TestElrondBaseProxy_GetNetworkStatus(t *testing.T) { } respBytes, _ := json.Marshal(resp) - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.endpointProvider = endpointProviders.NewProxyEndpointProvider() args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{ GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) { return respBytes, http.StatusOK, nil }, } - baseProxy, _ := newElrondBaseProxy(args) + baseProxy, _ := newBaseProxy(args) result, err := baseProxy.GetNetworkStatus(context.Background(), 0) assert.Nil(t, result) @@ -356,13 +356,13 @@ func TestElrondBaseProxy_GetNetworkStatus(t *testing.T) { t.Run("GetNodeStatus returns nil network status - node endpoint provider", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{ GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) { return getNetworkStatusBytes(nil), http.StatusOK, nil }, } - baseProxy, _ := newElrondBaseProxy(args) + baseProxy, _ := newBaseProxy(args) result, err := baseProxy.GetNetworkStatus(context.Background(), 0) assert.Nil(t, result) @@ -372,14 +372,14 @@ func TestElrondBaseProxy_GetNetworkStatus(t *testing.T) { t.Run("GetNodeStatus returns nil network status - proxy endpoint provider", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.endpointProvider = endpointProviders.NewProxyEndpointProvider() args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{ GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) { return getNetworkStatusBytes(nil), http.StatusOK, nil }, } - baseProxy, _ := newElrondBaseProxy(args) + baseProxy, _ := newBaseProxy(args) result, err := baseProxy.GetNetworkStatus(context.Background(), 0) assert.Nil(t, result) @@ -402,13 +402,13 @@ func TestElrondBaseProxy_GetNetworkStatus(t *testing.T) { ShardID: core.MetachainShardId, } - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{ GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) { return getNodeStatusBytes(providedNetworkStatus), http.StatusOK, nil }, } - baseProxy, _ := newElrondBaseProxy(args) + baseProxy, _ := newBaseProxy(args) result, err := baseProxy.GetNetworkStatus(context.Background(), 0) assert.Nil(t, result) @@ -430,13 +430,13 @@ func TestElrondBaseProxy_GetNetworkStatus(t *testing.T) { CrossCheckBlockHeight: "aaa", } - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{ GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) { return getNodeStatusBytes(providedNetworkStatus), http.StatusOK, nil }, } - baseProxy, _ := newElrondBaseProxy(args) + baseProxy, _ := newBaseProxy(args) result, err := baseProxy.GetNetworkStatus(context.Background(), 0) assert.Nil(t, err) @@ -458,14 +458,14 @@ func TestElrondBaseProxy_GetNetworkStatus(t *testing.T) { ShardID: core.MetachainShardId, // this won't be tested in this test } - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.endpointProvider = endpointProviders.NewProxyEndpointProvider() args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{ GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) { return getNetworkStatusBytes(providedNetworkStatus), http.StatusOK, nil }, } - baseProxy, _ := newElrondBaseProxy(args) + baseProxy, _ := newBaseProxy(args) result, err := baseProxy.GetNetworkStatus(context.Background(), 0) assert.Nil(t, err) @@ -495,7 +495,7 @@ func getNodeStatusBytes(status *data.NetworkStatus) []byte { return respBytes } -func TestElrondBaseProxy_GetShardOfAddress(t *testing.T) { +func TestBaseProxy_GetShardOfAddress(t *testing.T) { t.Parallel() t.Run("invalid address", func(t *testing.T) { @@ -554,7 +554,7 @@ func TestElrondBaseProxy_GetShardOfAddress(t *testing.T) { }) } -func createBaseProxyForGetShardOfAddress(numShards uint32, errGet error) *elrondBaseProxy { +func createBaseProxyForGetShardOfAddress(numShards uint32, errGet error) *baseProxy { expectedReturnedNetworkConfig := &data.NetworkConfig{ NumShardsWithoutMeta: numShards, } @@ -576,18 +576,18 @@ func createBaseProxyForGetShardOfAddress(numShards uint32, errGet error) *elrond return networkConfigBytes, http.StatusOK, nil } - args := createMockArgsElrondBaseProxy() + args := createMockArgsBaseProxy() args.httpClientWrapper = mockWrapper - baseProxy, _ := newElrondBaseProxy(args) + baseProxy, _ := newBaseProxy(args) return baseProxy } -func TestElrondBaseProxy_GetRestAPIEntityType(t *testing.T) { +func TestBaseProxy_GetRestAPIEntityType(t *testing.T) { t.Parallel() - args := createMockArgsElrondBaseProxy() - baseProxy, _ := newElrondBaseProxy(args) + args := createMockArgsBaseProxy() + baseProxy, _ := newBaseProxy(args) assert.Equal(t, args.endpointProvider.GetRestAPIEntityType(), baseProxy.GetRestAPIEntityType()) } diff --git a/blockchain/cryptoProvider/cryptoComponentsHolder.go b/blockchain/cryptoProvider/cryptoComponentsHolder.go index 9776db88..db1fc123 100644 --- a/blockchain/cryptoProvider/cryptoComponentsHolder.go +++ b/blockchain/cryptoProvider/cryptoComponentsHolder.go @@ -1,9 +1,9 @@ package cryptoProvider import ( - crypto "github.com/ElrondNetwork/elrond-go-crypto" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + crypto "github.com/multiversx/mx-chain-crypto-go" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" ) type cryptoComponentsHolder struct { diff --git a/blockchain/cryptoProvider/cryptoComponentsHolder_test.go b/blockchain/cryptoProvider/cryptoComponentsHolder_test.go index be6a81cf..af2d3032 100644 --- a/blockchain/cryptoProvider/cryptoComponentsHolder_test.go +++ b/blockchain/cryptoProvider/cryptoComponentsHolder_test.go @@ -4,10 +4,10 @@ import ( "encoding/hex" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" - crypto "github.com/ElrondNetwork/elrond-go-crypto" - "github.com/ElrondNetwork/elrond-go/testscommon/cryptoMocks" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" + "github.com/multiversx/mx-chain-core-go/core/check" + crypto "github.com/multiversx/mx-chain-crypto-go" + "github.com/multiversx/mx-chain-go/testscommon/cryptoMocks" + "github.com/multiversx/mx-sdk-go/testsCommon" "github.com/stretchr/testify/require" ) diff --git a/blockchain/cryptoProvider/signer.go b/blockchain/cryptoProvider/signer.go index 311d22d9..02e93d40 100644 --- a/blockchain/cryptoProvider/signer.go +++ b/blockchain/cryptoProvider/signer.go @@ -4,15 +4,15 @@ import ( "encoding/json" "strconv" - "github.com/ElrondNetwork/elrond-go-core/hashing/keccak" - "github.com/ElrondNetwork/elrond-go-crypto" - "github.com/ElrondNetwork/elrond-go-crypto/signing/ed25519/singlesig" - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-chain-core-go/hashing/keccak" + "github.com/multiversx/mx-chain-crypto-go" + "github.com/multiversx/mx-chain-crypto-go/signing/ed25519/singlesig" + logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/data" ) var ( - signerLog = logger.GetOrCreate("elrond-sdk-erdgo/signer") + signerLog = logger.GetOrCreate("mx-sdk-go/signer") hasher = keccak.NewKeccak() singleSigner = &singlesig.Ed25519Signer{} messagePrefix = []byte("\x17Elrond Signed Message:\n") diff --git a/blockchain/cryptoProvider/signer_test.go b/blockchain/cryptoProvider/signer_test.go index 38d97f64..97a008f0 100644 --- a/blockchain/cryptoProvider/signer_test.go +++ b/blockchain/cryptoProvider/signer_test.go @@ -5,12 +5,12 @@ import ( "errors" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-crypto/signing" - "github.com/ElrondNetwork/elrond-go-crypto/signing/ed25519" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/examples" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-crypto-go/signing" + "github.com/multiversx/mx-chain-crypto-go/signing/ed25519" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/examples" + "github.com/multiversx/mx-sdk-go/interactors" "github.com/stretchr/testify/require" ) diff --git a/blockchain/endpointProviders/nodeEndpointProvider.go b/blockchain/endpointProviders/nodeEndpointProvider.go index a0c89de3..c4e7fd1b 100644 --- a/blockchain/endpointProviders/nodeEndpointProvider.go +++ b/blockchain/endpointProviders/nodeEndpointProvider.go @@ -3,7 +3,7 @@ package endpointProviders import ( "fmt" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" + "github.com/multiversx/mx-sdk-go/core" ) const ( @@ -13,7 +13,7 @@ const ( nodeRawMiniBlockByHashEndpoint = "internal/raw/miniblock/by-hash/%s/epoch/%d" ) -// nodeEndpointProvider is suitable to work with an Elrond node (observer) +// nodeEndpointProvider is suitable to work with a MultiversX node (observer) type nodeEndpointProvider struct { *baseEndpointProvider } diff --git a/blockchain/endpointProviders/nodeEndpointProvider_test.go b/blockchain/endpointProviders/nodeEndpointProvider_test.go index 6f5cbd7f..8ec1a4a7 100644 --- a/blockchain/endpointProviders/nodeEndpointProvider_test.go +++ b/blockchain/endpointProviders/nodeEndpointProvider_test.go @@ -3,8 +3,8 @@ package endpointProviders import ( "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-sdk-go/core" "github.com/stretchr/testify/assert" ) diff --git a/blockchain/endpointProviders/proxyEndpointProvider.go b/blockchain/endpointProviders/proxyEndpointProvider.go index cd861dd6..0a3df4f6 100644 --- a/blockchain/endpointProviders/proxyEndpointProvider.go +++ b/blockchain/endpointProviders/proxyEndpointProvider.go @@ -3,7 +3,7 @@ package endpointProviders import ( "fmt" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" + "github.com/multiversx/mx-sdk-go/core" ) const ( @@ -13,7 +13,7 @@ const ( proxyRawMiniBlockByHash = "internal/%d/raw/miniblock/by-hash/%s/epoch/%d" ) -// proxyEndpointProvider is suitable to work with an Elrond Proxy +// proxyEndpointProvider is suitable to work with a MultiversX Proxy type proxyEndpointProvider struct { *baseEndpointProvider } diff --git a/blockchain/endpointProviders/proxyEndpointProvider_test.go b/blockchain/endpointProviders/proxyEndpointProvider_test.go index 5816524b..adb169ac 100644 --- a/blockchain/endpointProviders/proxyEndpointProvider_test.go +++ b/blockchain/endpointProviders/proxyEndpointProvider_test.go @@ -3,9 +3,9 @@ package endpointProviders import ( "testing" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" - erdgoCore "github.com/ElrondNetwork/elrond-sdk-erdgo/core" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + erdgoCore "github.com/multiversx/mx-sdk-go/core" "github.com/stretchr/testify/assert" ) diff --git a/blockchain/factory/factory.go b/blockchain/factory/factory.go index ea1b13eb..38de40bd 100644 --- a/blockchain/factory/factory.go +++ b/blockchain/factory/factory.go @@ -3,9 +3,9 @@ package factory import ( "fmt" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain/endpointProviders" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain/finalityProvider" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" + "github.com/multiversx/mx-sdk-go/blockchain/endpointProviders" + "github.com/multiversx/mx-sdk-go/blockchain/finalityProvider" + "github.com/multiversx/mx-sdk-go/core" ) // CreateEndpointProvider creates a new instance of EndpointProvider diff --git a/blockchain/factory/factory_test.go b/blockchain/factory/factory_test.go index c3e4e12b..22a7e9c3 100644 --- a/blockchain/factory/factory_test.go +++ b/blockchain/factory/factory_test.go @@ -5,9 +5,9 @@ import ( "fmt" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/testsCommon" "github.com/stretchr/testify/assert" ) diff --git a/blockchain/factory/interface.go b/blockchain/factory/interface.go index 716544a1..927d4129 100644 --- a/blockchain/factory/interface.go +++ b/blockchain/factory/interface.go @@ -3,8 +3,8 @@ package factory import ( "context" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" ) type proxy interface { diff --git a/blockchain/finalityProvider/disabledFinalityProvider_test.go b/blockchain/finalityProvider/disabledFinalityProvider_test.go index 31bbe08f..303d1289 100644 --- a/blockchain/finalityProvider/disabledFinalityProvider_test.go +++ b/blockchain/finalityProvider/disabledFinalityProvider_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" + "github.com/multiversx/mx-chain-core-go/core/check" "github.com/stretchr/testify/assert" ) diff --git a/blockchain/finalityProvider/interface.go b/blockchain/finalityProvider/interface.go index 5f36c139..b7a4800f 100644 --- a/blockchain/finalityProvider/interface.go +++ b/blockchain/finalityProvider/interface.go @@ -3,7 +3,7 @@ package finalityProvider import ( "context" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-sdk-go/data" ) type proxy interface { diff --git a/blockchain/finalityProvider/nodeFinalityProvider.go b/blockchain/finalityProvider/nodeFinalityProvider.go index 13865326..7f593728 100644 --- a/blockchain/finalityProvider/nodeFinalityProvider.go +++ b/blockchain/finalityProvider/nodeFinalityProvider.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-sdk-go/core" ) type nonces struct { diff --git a/blockchain/finalityProvider/nodeFinalityProvider_test.go b/blockchain/finalityProvider/nodeFinalityProvider_test.go index 111a9019..2bb93515 100644 --- a/blockchain/finalityProvider/nodeFinalityProvider_test.go +++ b/blockchain/finalityProvider/nodeFinalityProvider_test.go @@ -6,9 +6,9 @@ import ( "strings" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/testsCommon" "github.com/stretchr/testify/assert" ) diff --git a/blockchain/finalityProvider/proxyFinalityProvider.go b/blockchain/finalityProvider/proxyFinalityProvider.go index 89da6091..4cd04d59 100644 --- a/blockchain/finalityProvider/proxyFinalityProvider.go +++ b/blockchain/finalityProvider/proxyFinalityProvider.go @@ -6,13 +6,13 @@ import ( "math/big" "strings" - elrondCore "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" + mxChainCore "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/core" ) -var log = logger.GetOrCreate("elrond-sdk-erdgo/blockchain/finalityprovider") +var log = logger.GetOrCreate("mx-sdk-go/blockchain/finalityprovider") type proxyFinalityProvider struct { proxy proxy @@ -36,7 +36,7 @@ func (provider *proxyFinalityProvider) CheckShardFinalization(ctx context.Contex if maxNoncesDelta < core.MinAllowedDeltaToFinal { return fmt.Errorf("%w, provided: %d, minimum: %d", ErrInvalidAllowedDeltaToFinal, maxNoncesDelta, core.MinAllowedDeltaToFinal) } - if targetShardID == elrondCore.MetachainShardId { + if targetShardID == mxChainCore.MetachainShardId { // we consider this final since the minAllowedDeltaToFinal is 1 return nil } @@ -62,7 +62,7 @@ func (provider *proxyFinalityProvider) CheckShardFinalization(ctx context.Contex } func (provider *proxyFinalityProvider) getNoncesFromMetaAndShard(ctx context.Context, targetShardID uint32) (uint64, uint64, error) { - networkStatusMeta, err := provider.proxy.GetNetworkStatus(ctx, elrondCore.MetachainShardId) + networkStatusMeta, err := provider.proxy.GetNetworkStatus(ctx, mxChainCore.MetachainShardId) if err != nil { return 0, 0, err } diff --git a/blockchain/finalityProvider/proxyFinalityProvider_test.go b/blockchain/finalityProvider/proxyFinalityProvider_test.go index 24e7dd72..9ca4d01c 100644 --- a/blockchain/finalityProvider/proxyFinalityProvider_test.go +++ b/blockchain/finalityProvider/proxyFinalityProvider_test.go @@ -6,10 +6,10 @@ import ( "strings" "testing" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/testsCommon" "github.com/stretchr/testify/assert" ) @@ -85,7 +85,7 @@ func TestExtractNonceOfShardID(t *testing.T) { }) } -func TestElrondBaseProxy_CheckShardFinalization(t *testing.T) { +func TestBaseProxy_CheckShardFinalization(t *testing.T) { t.Parallel() t.Run("invalid maxNoncesDelta", func(t *testing.T) { diff --git a/blockchain/interface.go b/blockchain/interface.go index 069be61e..ee8ac971 100644 --- a/blockchain/interface.go +++ b/blockchain/interface.go @@ -3,11 +3,11 @@ package blockchain import ( "context" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" ) -// Proxy holds the primitive functions that the elrond proxy engine supports & implements +// Proxy holds the primitive functions that the multiversx proxy engine supports & implements type Proxy interface { GetNetworkConfig(ctx context.Context) (*data.NetworkConfig, error) GetAccount(ctx context.Context, address core.AddressHandler) (*data.Account, error) diff --git a/blockchain/proxy.go b/blockchain/proxy.go index 205c7e3c..3ba2fd85 100644 --- a/blockchain/proxy.go +++ b/blockchain/proxy.go @@ -9,21 +9,21 @@ import ( "sort" "time" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go/state" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain/factory" - erdgoCore "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - erdgoHttp "github.com/ElrondNetwork/elrond-sdk-erdgo/core/http" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-go/state" + "github.com/multiversx/mx-sdk-go/blockchain/factory" + erdgoCore "github.com/multiversx/mx-sdk-go/core" + erdgoHttp "github.com/multiversx/mx-sdk-go/core/http" + "github.com/multiversx/mx-sdk-go/data" ) const ( withResultsQueryParam = "?withResults=true" ) -// ArgsElrondProxy is the DTO used in the elrond proxy constructor -type ArgsElrondProxy struct { +// ArgsProxy is the DTO used in the multiversx proxy constructor +type ArgsProxy struct { ProxyURL string Client erdgoHttp.Client SameScState bool @@ -34,9 +34,9 @@ type ArgsElrondProxy struct { EntityType erdgoCore.RestAPIEntityType } -// elrondProxy implements basic functions for interacting with an Elrond Proxy -type elrondProxy struct { - *elrondBaseProxy +// proxy implements basic functions for interacting with a multiversx Proxy +type proxy struct { + *baseProxy sameScState bool shouldBeSynced bool finalityCheck bool @@ -44,8 +44,8 @@ type elrondProxy struct { finalityProvider FinalityProvider } -// NewElrondProxy initializes and returns an ElrondProxy object -func NewElrondProxy(args ArgsElrondProxy) (*elrondProxy, error) { +// NewProxy initializes and returns a proxy object +func NewProxy(args ArgsProxy) (*proxy, error) { err := checkArgsProxy(args) if err != nil { return nil, err @@ -57,12 +57,12 @@ func NewElrondProxy(args ArgsElrondProxy) (*elrondProxy, error) { } clientWrapper := erdgoHttp.NewHttpClientWrapper(args.Client, args.ProxyURL) - baseArgs := argsElrondBaseProxy{ + baseArgs := argsBaseProxy{ httpClientWrapper: clientWrapper, expirationTime: args.CacheExpirationTime, endpointProvider: endpointProvider, } - baseProxy, err := newElrondBaseProxy(baseArgs) + baseProxy, err := newBaseProxy(baseArgs) if err != nil { return nil, err } @@ -72,8 +72,8 @@ func NewElrondProxy(args ArgsElrondProxy) (*elrondProxy, error) { return nil, err } - ep := &elrondProxy{ - elrondBaseProxy: baseProxy, + ep := &proxy{ + baseProxy: baseProxy, sameScState: args.SameScState, shouldBeSynced: args.ShouldBeSynced, finalityCheck: args.FinalityCheck, @@ -84,7 +84,7 @@ func NewElrondProxy(args ArgsElrondProxy) (*elrondProxy, error) { return ep, nil } -func checkArgsProxy(args ArgsElrondProxy) error { +func checkArgsProxy(args ArgsProxy) error { if args.FinalityCheck { if args.AllowedDeltaToFinal < erdgoCore.MinAllowedDeltaToFinal { return fmt.Errorf("%w, provided: %d, minimum: %d", @@ -96,7 +96,7 @@ func checkArgsProxy(args ArgsElrondProxy) error { } // ExecuteVMQuery retrieves data from existing SC trie through the use of a VM -func (ep *elrondProxy) ExecuteVMQuery(ctx context.Context, vmRequest *data.VmValueRequest) (*data.VmValuesResponseData, error) { +func (ep *proxy) ExecuteVMQuery(ctx context.Context, vmRequest *data.VmValueRequest) (*data.VmValuesResponseData, error) { err := ep.checkFinalState(ctx, vmRequest.Address) if err != nil { return nil, err @@ -129,7 +129,7 @@ func (ep *elrondProxy) ExecuteVMQuery(ctx context.Context, vmRequest *data.VmVal return &response.Data, nil } -func (ep *elrondProxy) checkFinalState(ctx context.Context, address string) error { +func (ep *proxy) checkFinalState(ctx context.Context, address string) error { if !ep.finalityCheck { return nil } @@ -143,7 +143,7 @@ func (ep *elrondProxy) checkFinalState(ctx context.Context, address string) erro } // GetNetworkEconomics retrieves the network economics from the proxy -func (ep *elrondProxy) GetNetworkEconomics(ctx context.Context) (*data.NetworkEconomics, error) { +func (ep *proxy) GetNetworkEconomics(ctx context.Context) (*data.NetworkEconomics, error) { buff, code, err := ep.GetHTTP(ctx, ep.endpointProvider.GetNetworkEconomics()) if err != nil || code != http.StatusOK { return nil, createHTTPStatusError(code, err) @@ -162,7 +162,7 @@ func (ep *elrondProxy) GetNetworkEconomics(ctx context.Context) (*data.NetworkEc } // GetDefaultTransactionArguments will prepare the transaction creation argument by querying the account's info -func (ep *elrondProxy) GetDefaultTransactionArguments( +func (ep *proxy) GetDefaultTransactionArguments( ctx context.Context, address erdgoCore.AddressHandler, networkConfigs *data.NetworkConfig, @@ -196,7 +196,7 @@ func (ep *elrondProxy) GetDefaultTransactionArguments( } // GetAccount retrieves an account info from the network (nonce, balance) -func (ep *elrondProxy) GetAccount(ctx context.Context, address erdgoCore.AddressHandler) (*data.Account, error) { +func (ep *proxy) GetAccount(ctx context.Context, address erdgoCore.AddressHandler) (*data.Account, error) { err := ep.checkFinalState(ctx, address.AddressAsBech32String()) if err != nil { return nil, err @@ -228,7 +228,7 @@ func (ep *elrondProxy) GetAccount(ctx context.Context, address erdgoCore.Address } // SendTransaction broadcasts a transaction to the network and returns the txhash if successful -func (ep *elrondProxy) SendTransaction(ctx context.Context, tx *data.Transaction) (string, error) { +func (ep *proxy) SendTransaction(ctx context.Context, tx *data.Transaction) (string, error) { jsonTx, err := json.Marshal(tx) if err != nil { return "", err @@ -251,7 +251,7 @@ func (ep *elrondProxy) SendTransaction(ctx context.Context, tx *data.Transaction } // SendTransactions broadcasts the provided transactions to the network and returns the txhashes if successful -func (ep *elrondProxy) SendTransactions(ctx context.Context, txs []*data.Transaction) ([]string, error) { +func (ep *proxy) SendTransactions(ctx context.Context, txs []*data.Transaction) ([]string, error) { jsonTx, err := json.Marshal(txs) if err != nil { return nil, err @@ -273,7 +273,7 @@ func (ep *elrondProxy) SendTransactions(ctx context.Context, txs []*data.Transac return ep.postProcessSendMultipleTxsResult(response) } -func (ep *elrondProxy) postProcessSendMultipleTxsResult(response *data.SendTransactionsResponse) ([]string, error) { +func (ep *proxy) postProcessSendMultipleTxsResult(response *data.SendTransactionsResponse) ([]string, error) { txHashes := make([]string, 0, len(response.Data.TxsHashes)) indexes := make([]int, 0, len(response.Data.TxsHashes)) for index := range response.Data.TxsHashes { @@ -292,7 +292,7 @@ func (ep *elrondProxy) postProcessSendMultipleTxsResult(response *data.SendTrans } // GetTransactionStatus retrieves a transaction's status from the network -func (ep *elrondProxy) GetTransactionStatus(ctx context.Context, hash string) (string, error) { +func (ep *proxy) GetTransactionStatus(ctx context.Context, hash string) (string, error) { endpoint := ep.endpointProvider.GetTransactionStatus(hash) buff, code, err := ep.GetHTTP(ctx, endpoint) if err != nil || code != http.StatusOK { @@ -312,16 +312,16 @@ func (ep *elrondProxy) GetTransactionStatus(ctx context.Context, hash string) (s } // GetTransactionInfo retrieves a transaction's details from the network -func (ep *elrondProxy) GetTransactionInfo(ctx context.Context, hash string) (*data.TransactionInfo, error) { +func (ep *proxy) GetTransactionInfo(ctx context.Context, hash string) (*data.TransactionInfo, error) { return ep.getTransactionInfo(ctx, hash, false) } // GetTransactionInfoWithResults retrieves a transaction's details from the network with events -func (ep *elrondProxy) GetTransactionInfoWithResults(ctx context.Context, hash string) (*data.TransactionInfo, error) { +func (ep *proxy) GetTransactionInfoWithResults(ctx context.Context, hash string) (*data.TransactionInfo, error) { return ep.getTransactionInfo(ctx, hash, true) } -func (ep *elrondProxy) getTransactionInfo(ctx context.Context, hash string, withResults bool) (*data.TransactionInfo, error) { +func (ep *proxy) getTransactionInfo(ctx context.Context, hash string, withResults bool) (*data.TransactionInfo, error) { endpoint := ep.endpointProvider.GetTransactionInfo(hash) if withResults { endpoint += withResultsQueryParam @@ -345,7 +345,7 @@ func (ep *elrondProxy) getTransactionInfo(ctx context.Context, hash string, with } // RequestTransactionCost retrieves how many gas a transaction will consume -func (ep *elrondProxy) RequestTransactionCost(ctx context.Context, tx *data.Transaction) (*data.TxCostResponseData, error) { +func (ep *proxy) RequestTransactionCost(ctx context.Context, tx *data.Transaction) (*data.TxCostResponseData, error) { jsonTx, err := json.Marshal(tx) if err != nil { return nil, err @@ -368,7 +368,7 @@ func (ep *elrondProxy) RequestTransactionCost(ctx context.Context, tx *data.Tran } // GetLatestHyperBlockNonce retrieves the latest hyper block (metachain) nonce from the network -func (ep *elrondProxy) GetLatestHyperBlockNonce(ctx context.Context) (uint64, error) { +func (ep *proxy) GetLatestHyperBlockNonce(ctx context.Context) (uint64, error) { response, err := ep.GetNetworkStatus(ctx, core.MetachainShardId) if err != nil { return 0, err @@ -378,20 +378,20 @@ func (ep *elrondProxy) GetLatestHyperBlockNonce(ctx context.Context) (uint64, er } // GetHyperBlockByNonce retrieves a hyper block's info by nonce from the network -func (ep *elrondProxy) GetHyperBlockByNonce(ctx context.Context, nonce uint64) (*data.HyperBlock, error) { +func (ep *proxy) GetHyperBlockByNonce(ctx context.Context, nonce uint64) (*data.HyperBlock, error) { endpoint := ep.endpointProvider.GetHyperBlockByNonce(nonce) return ep.getHyperBlock(ctx, endpoint) } // GetHyperBlockByHash retrieves a hyper block's info by hash from the network -func (ep *elrondProxy) GetHyperBlockByHash(ctx context.Context, hash string) (*data.HyperBlock, error) { +func (ep *proxy) GetHyperBlockByHash(ctx context.Context, hash string) (*data.HyperBlock, error) { endpoint := ep.endpointProvider.GetHyperBlockByHash(hash) return ep.getHyperBlock(ctx, endpoint) } -func (ep *elrondProxy) getHyperBlock(ctx context.Context, endpoint string) (*data.HyperBlock, error) { +func (ep *proxy) getHyperBlock(ctx context.Context, endpoint string) (*data.HyperBlock, error) { buff, code, err := ep.GetHTTP(ctx, endpoint) if err != nil || code != http.StatusOK { return nil, createHTTPStatusError(code, err) @@ -410,27 +410,27 @@ func (ep *elrondProxy) getHyperBlock(ctx context.Context, endpoint string) (*dat } // GetRawBlockByHash retrieves a raw block by hash from the network -func (ep *elrondProxy) GetRawBlockByHash(ctx context.Context, shardId uint32, hash string) ([]byte, error) { +func (ep *proxy) GetRawBlockByHash(ctx context.Context, shardId uint32, hash string) ([]byte, error) { endpoint := ep.endpointProvider.GetRawBlockByHash(shardId, hash) return ep.getRawBlock(ctx, endpoint) } // GetRawBlockByNonce retrieves a raw block by hash from the network -func (ep *elrondProxy) GetRawBlockByNonce(ctx context.Context, shardId uint32, nonce uint64) ([]byte, error) { +func (ep *proxy) GetRawBlockByNonce(ctx context.Context, shardId uint32, nonce uint64) ([]byte, error) { endpoint := ep.endpointProvider.GetRawBlockByNonce(shardId, nonce) return ep.getRawBlock(ctx, endpoint) } // GetRawStartOfEpochMetaBlock retrieves a raw block by hash from the network -func (ep *elrondProxy) GetRawStartOfEpochMetaBlock(ctx context.Context, epoch uint32) ([]byte, error) { +func (ep *proxy) GetRawStartOfEpochMetaBlock(ctx context.Context, epoch uint32) ([]byte, error) { endpoint := ep.endpointProvider.GetRawStartOfEpochMetaBlock(epoch) return ep.getRawBlock(ctx, endpoint) } -func (ep *elrondProxy) getRawBlock(ctx context.Context, endpoint string) ([]byte, error) { +func (ep *proxy) getRawBlock(ctx context.Context, endpoint string) ([]byte, error) { buff, code, err := ep.GetHTTP(ctx, endpoint) if err != nil || code != http.StatusOK { return nil, createHTTPStatusError(code, err) @@ -449,13 +449,13 @@ func (ep *elrondProxy) getRawBlock(ctx context.Context, endpoint string) ([]byte } // GetRawMiniBlockByHash retrieves a raw block by hash from the network -func (ep *elrondProxy) GetRawMiniBlockByHash(ctx context.Context, shardId uint32, hash string, epoch uint32) ([]byte, error) { +func (ep *proxy) GetRawMiniBlockByHash(ctx context.Context, shardId uint32, hash string, epoch uint32) ([]byte, error) { endpoint := ep.endpointProvider.GetRawMiniBlockByHash(shardId, hash, epoch) return ep.getRawMiniBlock(ctx, endpoint) } -func (ep *elrondProxy) getRawMiniBlock(ctx context.Context, endpoint string) ([]byte, error) { +func (ep *proxy) getRawMiniBlock(ctx context.Context, endpoint string) ([]byte, error) { buff, code, err := ep.GetHTTP(ctx, endpoint) if err != nil || code != http.StatusOK { return nil, createHTTPStatusError(code, err) @@ -474,7 +474,7 @@ func (ep *elrondProxy) getRawMiniBlock(ctx context.Context, endpoint string) ([] } // GetNonceAtEpochStart retrieves the start of epoch nonce from hyper block (metachain) -func (ep *elrondProxy) GetNonceAtEpochStart(ctx context.Context, shardId uint32) (uint64, error) { +func (ep *proxy) GetNonceAtEpochStart(ctx context.Context, shardId uint32) (uint64, error) { response, err := ep.GetNetworkStatus(ctx, shardId) if err != nil { return 0, err @@ -484,7 +484,7 @@ func (ep *elrondProxy) GetNonceAtEpochStart(ctx context.Context, shardId uint32) } // GetRatingsConfig retrieves the ratings configuration from the proxy -func (ep *elrondProxy) GetRatingsConfig(ctx context.Context) (*data.RatingsConfig, error) { +func (ep *proxy) GetRatingsConfig(ctx context.Context) (*data.RatingsConfig, error) { buff, code, err := ep.GetHTTP(ctx, ep.endpointProvider.GetRatingsConfig()) if err != nil || code != http.StatusOK { return nil, createHTTPStatusError(code, err) @@ -503,7 +503,7 @@ func (ep *elrondProxy) GetRatingsConfig(ctx context.Context) (*data.RatingsConfi } // GetEnableEpochsConfig retrieves the ratings configuration from the proxy -func (ep *elrondProxy) GetEnableEpochsConfig(ctx context.Context) (*data.EnableEpochsConfig, error) { +func (ep *proxy) GetEnableEpochsConfig(ctx context.Context) (*data.EnableEpochsConfig, error) { buff, code, err := ep.GetHTTP(ctx, ep.endpointProvider.GetEnableEpochsConfig()) if err != nil || code != http.StatusOK { return nil, createHTTPStatusError(code, err) @@ -522,7 +522,7 @@ func (ep *elrondProxy) GetEnableEpochsConfig(ctx context.Context) (*data.EnableE } // GetGenesisNodesPubKeys retrieves genesis nodes configuration from proxy -func (ep *elrondProxy) GetGenesisNodesPubKeys(ctx context.Context) (*data.GenesisNodes, error) { +func (ep *proxy) GetGenesisNodesPubKeys(ctx context.Context) (*data.GenesisNodes, error) { buff, code, err := ep.GetHTTP(ctx, ep.endpointProvider.GetGenesisNodesConfig()) if err != nil || code != http.StatusOK { return nil, createHTTPStatusError(code, err) @@ -541,7 +541,7 @@ func (ep *elrondProxy) GetGenesisNodesPubKeys(ctx context.Context) (*data.Genesi } // GetValidatorsInfoByEpoch retrieves the validators info by epoch -func (ep *elrondProxy) GetValidatorsInfoByEpoch(ctx context.Context, epoch uint32) ([]*state.ShardValidatorInfo, error) { +func (ep *proxy) GetValidatorsInfoByEpoch(ctx context.Context, epoch uint32) ([]*state.ShardValidatorInfo, error) { buff, code, err := ep.GetHTTP(ctx, ep.endpointProvider.GetValidatorsInfo(epoch)) if err != nil || code != http.StatusOK { return nil, createHTTPStatusError(code, err) @@ -560,6 +560,6 @@ func (ep *elrondProxy) GetValidatorsInfoByEpoch(ctx context.Context, epoch uint3 } // IsInterfaceNil returns true if there is no value under the interface -func (ep *elrondProxy) IsInterfaceNil() bool { +func (ep *proxy) IsInterfaceNil() bool { return ep == nil } diff --git a/blockchain/proxy_test.go b/blockchain/proxy_test.go index 44056669..40b65ca7 100644 --- a/blockchain/proxy_test.go +++ b/blockchain/proxy_test.go @@ -13,14 +13,14 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go/config" - "github.com/ElrondNetwork/elrond-go/state" - erdgoCore "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - erdgoHttp "github.com/ElrondNetwork/elrond-sdk-erdgo/core/http" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-go/config" + "github.com/multiversx/mx-chain-go/state" + erdgoCore "github.com/multiversx/mx-sdk-go/core" + erdgoHttp "github.com/multiversx/mx-sdk-go/core/http" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/testsCommon" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -58,8 +58,8 @@ func createMockClientRespondingBytes(responseBytes []byte) *mockHTTPClient { } } -func createMockArgsElrondProxy(httpClient erdgoHttp.Client) ArgsElrondProxy { - return ArgsElrondProxy{ +func createMockArgsProxy(httpClient erdgoHttp.Client) ArgsProxy { + return ArgsProxy{ ProxyURL: testHttpURL, Client: httpClient, SameScState: false, @@ -139,15 +139,15 @@ func handleRequestNetworkConfigAndStatus( }, handled, nil } -func TestNewElrondProxy(t *testing.T) { +func TestNewProxy(t *testing.T) { t.Parallel() t.Run("invalid time cache should error", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondProxy(nil) + args := createMockArgsProxy(nil) args.CacheExpirationTime = time.Second - time.Nanosecond - proxy, err := NewElrondProxy(args) + proxy, err := NewProxy(args) assert.True(t, check.IfNil(proxy)) assert.True(t, errors.Is(err, ErrInvalidCacherDuration)) @@ -155,10 +155,10 @@ func TestNewElrondProxy(t *testing.T) { t.Run("invalid nonce delta should error", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondProxy(nil) + args := createMockArgsProxy(nil) args.FinalityCheck = true args.AllowedDeltaToFinal = 0 - proxy, err := NewElrondProxy(args) + proxy, err := NewProxy(args) assert.True(t, check.IfNil(proxy)) assert.True(t, errors.Is(err, ErrInvalidAllowedDeltaToFinal)) @@ -166,9 +166,9 @@ func TestNewElrondProxy(t *testing.T) { t.Run("should work with finality check", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondProxy(nil) + args := createMockArgsProxy(nil) args.FinalityCheck = true - proxy, err := NewElrondProxy(args) + proxy, err := NewProxy(args) assert.False(t, check.IfNil(proxy)) assert.Nil(t, err) @@ -176,8 +176,8 @@ func TestNewElrondProxy(t *testing.T) { t.Run("should work without finality check", func(t *testing.T) { t.Parallel() - args := createMockArgsElrondProxy(nil) - proxy, err := NewElrondProxy(args) + args := createMockArgsProxy(nil) + proxy, err := NewProxy(args) assert.False(t, check.IfNil(proxy)) assert.Nil(t, err) @@ -213,9 +213,9 @@ func TestGetAccount(t *testing.T) { }, nil }, } - args := createMockArgsElrondProxy(httpClient) + args := createMockArgsProxy(httpClient) args.FinalityCheck = true - proxy, _ := NewElrondProxy(args) + proxy, _ := NewProxy(args) address, err := data.NewAddressFromBech32String("erd1qqqqqqqqqqqqqpgqfzydqmdw7m2vazsp6u5p95yxz76t2p9rd8ss0zp9ts") if err != nil { @@ -253,13 +253,13 @@ func TestGetAccount(t *testing.T) { }) } -func TestElrondProxy_GetNetworkEconomics(t *testing.T) { +func TestProxy_GetNetworkEconomics(t *testing.T) { t.Parallel() responseBytes := []byte(`{"data":{"metrics":{"erd_dev_rewards":"0","erd_epoch_for_economics_data":263,"erd_inflation":"5869888769785838708144","erd_total_fees":"51189055176110000000","erd_total_staked_value":"9963775651405816710680128","erd_total_supply":"21556417261819025351089574","erd_total_top_up_value":"1146275808171377418645274"}},"code":"successful"}`) httpClient := createMockClientRespondingBytes(responseBytes) - args := createMockArgsElrondProxy(httpClient) - ep, _ := NewElrondProxy(args) + args := createMockArgsProxy(httpClient) + ep, _ := NewProxy(args) networkEconomics, err := ep.GetNetworkEconomics(context.Background()) require.Nil(t, err) @@ -274,13 +274,13 @@ func TestElrondProxy_GetNetworkEconomics(t *testing.T) { }, networkEconomics) } -func TestElrondProxy_RequestTransactionCost(t *testing.T) { +func TestProxy_RequestTransactionCost(t *testing.T) { t.Parallel() responseBytes := []byte(`{"data":{"txGasUnits":24273810,"returnMessage":""},"error":"","code":"successful"}`) httpClient := createMockClientRespondingBytes(responseBytes) - args := createMockArgsElrondProxy(httpClient) - ep, _ := NewElrondProxy(args) + args := createMockArgsProxy(httpClient) + ep, _ := NewProxy(args) tx := &data.Transaction{ Nonce: 1, @@ -300,13 +300,13 @@ func TestElrondProxy_RequestTransactionCost(t *testing.T) { }, txCost) } -func TestElrondProxy_GetTransactionInfoWithResults(t *testing.T) { +func TestProxy_GetTransactionInfoWithResults(t *testing.T) { t.Parallel() responseBytes := []byte(`{"data":{"transaction":{"type":"normal","nonce":22100,"round":53057,"epoch":263,"value":"0","receiver":"erd1e6c9vcga5lyhwdu9nr9lya4ujz2r5w2egsfjp0lslrgv5dsccpdsmre6va","sender":"erd1e6c9vcga5lyhwdu9nr9lya4ujz2r5w2egsfjp0lslrgv5dsccpdsmre6va","gasPrice":1000000001,"gasLimit":19210000,"data":"RVNEVE5GVFRyYW5zZmVyQDU5NTk1OTQ1MzY0MzM5MkQzMDM5MzQzOTMwMzBAMDFAMDFAMDAwMDAwMDAwMDAwMDAwMDA1MDA1QzgzRTBDNDJFRENFMzk0RjQwQjI0RDI5RDI5OEIwMjQ5QzQxRjAyODk3NEA2Njc1NkU2NEA1N0M1MDZBMTlEOEVBRTE4Mjk0MDNBOEYzRjU0RTFGMDM3OUYzODE1N0ZDRjUzRDVCQ0E2RjIzN0U0QTRDRjYxQDFjMjA=","signature":"37922ccb13d46857d819cd618f1fd8e76777e14f1c16a54eeedd55c67d5883db0e3a91cd0ff0f541e2c3d7347488b4020c0ba4765c9bc02ea0ae1c3f6db1ec05","sourceShard":1,"destinationShard":1,"blockNonce":53052,"blockHash":"4a63312d1bfe48aa516185d12abff5daf6343fce1f298db51291168cf97a790c","notarizedAtSourceInMetaNonce":53053,"NotarizedAtSourceInMetaHash":"342d189e36ef5cbf9f8b3f2cb5bf2cb8e2260062c6acdf89ce5faacd99f4dbcc","notarizedAtDestinationInMetaNonce":53053,"notarizedAtDestinationInMetaHash":"342d189e36ef5cbf9f8b3f2cb5bf2cb8e2260062c6acdf89ce5faacd99f4dbcc","miniblockType":"TxBlock","miniblockHash":"0c659cce5e2653522cc0e3cf35571264522035a7aef4ffa5244d1ed3d8bc01a8","status":"success","hyperblockNonce":53053,"hyperblockHash":"342d189e36ef5cbf9f8b3f2cb5bf2cb8e2260062c6acdf89ce5faacd99f4dbcc","smartContractResults":[{"hash":"5ab14959aaeb3a20d95ec6bbefc03f251732d9368711c55c63d3811e70903f4e","nonce":0,"value":0,"receiver":"erd1qqqqqqqqqqqqqpgqtjp7p3pwmn3efaqtynff62vtqfyug8cz396qs5vnsy","sender":"erd1e6c9vcga5lyhwdu9nr9lya4ujz2r5w2egsfjp0lslrgv5dsccpdsmre6va","data":"ESDTNFTTransfer@595959453643392d303934393030@01@01@080112020001226f08011204746573741a20ceb056611da7c977378598cbf276bc90943a3959441320bff0f8d0ca3618c05b20e8072a206161616161616161616161616161616161616161616161616161616161616161320461626261321268747470733a2f2f656c726f6e642e636f6d3a0474657374@66756e64@57c506a19d8eae1829403a8f3f54e1f0379f38157fcf53d5bca6f237e4a4cf61@1c20","prevTxHash":"c7fadeaccce0673bd6ce3a1f472f7cc1beef20c0b3131cfa9866cd5075816639","originalTxHash":"c7fadeaccce0673bd6ce3a1f472f7cc1beef20c0b3131cfa9866cd5075816639","gasLimit":18250000,"gasPrice":1000000001,"callType":0},{"hash":"f337d2705d2b644f9d8f75cf270e879b6ada51c4c54009e94305adf368d1adbc","nonce":1,"value":102793170000000,"receiver":"erd1e6c9vcga5lyhwdu9nr9lya4ujz2r5w2egsfjp0lslrgv5dsccpdsmre6va","sender":"erd1qqqqqqqqqqqqqpgqtjp7p3pwmn3efaqtynff62vtqfyug8cz396qs5vnsy","data":"@6f6b","prevTxHash":"5ab14959aaeb3a20d95ec6bbefc03f251732d9368711c55c63d3811e70903f4e","originalTxHash":"c7fadeaccce0673bd6ce3a1f472f7cc1beef20c0b3131cfa9866cd5075816639","gasLimit":0,"gasPrice":1000000001,"callType":0}]}},"error":"","code":"successful"}`) httpClient := createMockClientRespondingBytes(responseBytes) - args := createMockArgsElrondProxy(httpClient) - ep, _ := NewElrondProxy(args) + args := createMockArgsProxy(httpClient) + ep, _ := NewProxy(args) tx, err := ep.GetTransactionInfoWithResults(context.Background(), "a40e5a6af4efe221608297a73459211756ab88b96896e6e331842807a138f343") require.Nil(t, err) @@ -315,14 +315,14 @@ func TestElrondProxy_GetTransactionInfoWithResults(t *testing.T) { fmt.Println(string(txBytes)) } -func TestElrondProxy_ExecuteVmQuery(t *testing.T) { +func TestProxy_ExecuteVmQuery(t *testing.T) { t.Parallel() responseBytes := []byte(`{"data":{"data":{"returnData":["MC41LjU="],"returnCode":"ok","returnMessage":"","gasRemaining":18446744073685949187,"gasRefund":0,"outputAccounts":{"0000000000000000050033bb65a91ee17ab84c6f8a01846ef8644e15fb76696a":{"address":"erd1qqqqqqqqqqqqqpgqxwakt2g7u9atsnr03gqcgmhcv38pt7mkd94q6shuwt","nonce":0,"balance":null,"balanceDelta":0,"storageUpdates":{},"code":null,"codeMetaData":null,"outputTransfers":[],"callType":0}},"deletedAccounts":[],"touchedAccounts":[],"logs":[]}},"error":"","code":"successful"}`) t.Run("no finality check", func(t *testing.T) { httpClient := createMockClientRespondingBytes(responseBytes) - args := createMockArgsElrondProxy(httpClient) - ep, _ := NewElrondProxy(args) + args := createMockArgsProxy(httpClient) + ep, _ := NewProxy(args) response, err := ep.ExecuteVMQuery(context.Background(), &data.VmValueRequest{ Address: "erd1qqqqqqqqqqqqqpgqxwakt2g7u9atsnr03gqcgmhcv38pt7mkd94q6shuwt", @@ -344,9 +344,9 @@ func TestElrondProxy_ExecuteVmQuery(t *testing.T) { return nil, nil }, } - args := createMockArgsElrondProxy(httpClient) + args := createMockArgsProxy(httpClient) args.FinalityCheck = true - ep, _ := NewElrondProxy(args) + ep, _ := NewProxy(args) response, err := ep.ExecuteVMQuery(context.Background(), &data.VmValueRequest{ Address: "erd1qqqqqqqqqqqqqpgqxwakt2g7u9atsnr03gqcgmhcv38pt7mkd94q6shuwt", @@ -370,9 +370,9 @@ func TestElrondProxy_ExecuteVmQuery(t *testing.T) { return nil, nil }, } - args := createMockArgsElrondProxy(httpClient) + args := createMockArgsProxy(httpClient) args.FinalityCheck = true - ep, _ := NewElrondProxy(args) + ep, _ := NewProxy(args) response, err := ep.ExecuteVMQuery(context.Background(), &data.VmValueRequest{ Address: "invalid", @@ -400,9 +400,9 @@ func TestElrondProxy_ExecuteVmQuery(t *testing.T) { }, nil }, } - args := createMockArgsElrondProxy(httpClient) + args := createMockArgsProxy(httpClient) args.FinalityCheck = true - ep, _ := NewElrondProxy(args) + ep, _ := NewProxy(args) response, err := ep.ExecuteVMQuery(context.Background(), &data.VmValueRequest{ Address: "erd1qqqqqqqqqqqqqpgqxwakt2g7u9atsnr03gqcgmhcv38pt7mkd94q6shuwt", @@ -416,7 +416,7 @@ func TestElrondProxy_ExecuteVmQuery(t *testing.T) { }) } -func TestElrondProxy_GetRawBlockByHash(t *testing.T) { +func TestProxy_GetRawBlockByHash(t *testing.T) { t.Parallel() expectedTs := &testStruct{ @@ -436,8 +436,8 @@ func TestElrondProxy_GetRawBlockByHash(t *testing.T) { rawBlockDataBytes, _ := json.Marshal(rawBlockData) httpClient := createMockClientRespondingBytes(rawBlockDataBytes) - args := createMockArgsElrondProxy(httpClient) - ep, _ := NewElrondProxy(args) + args := createMockArgsProxy(httpClient) + ep, _ := NewProxy(args) response, err := ep.GetRawBlockByHash(context.Background(), 0, "aaaa") require.Nil(t, err) @@ -448,7 +448,7 @@ func TestElrondProxy_GetRawBlockByHash(t *testing.T) { require.Equal(t, expectedTs, ts) } -func TestElrondProxy_GetRawBlockByNonce(t *testing.T) { +func TestProxy_GetRawBlockByNonce(t *testing.T) { t.Parallel() expectedTs := &testStruct{ @@ -466,8 +466,8 @@ func TestElrondProxy_GetRawBlockByNonce(t *testing.T) { rawBlockDataBytes, _ := json.Marshal(rawBlockData) httpClient := createMockClientRespondingBytes(rawBlockDataBytes) - args := createMockArgsElrondProxy(httpClient) - ep, _ := NewElrondProxy(args) + args := createMockArgsProxy(httpClient) + ep, _ := NewProxy(args) response, err := ep.GetRawBlockByNonce(context.Background(), 0, 10) require.Nil(t, err) @@ -478,7 +478,7 @@ func TestElrondProxy_GetRawBlockByNonce(t *testing.T) { require.Equal(t, expectedTs, ts) } -func TestElrondProxy_GetRawMiniBlockByHash(t *testing.T) { +func TestProxy_GetRawMiniBlockByHash(t *testing.T) { t.Parallel() expectedTs := &testStruct{ @@ -496,8 +496,8 @@ func TestElrondProxy_GetRawMiniBlockByHash(t *testing.T) { rawBlockDataBytes, _ := json.Marshal(rawBlockData) httpClient := createMockClientRespondingBytes(rawBlockDataBytes) - args := createMockArgsElrondProxy(httpClient) - ep, _ := NewElrondProxy(args) + args := createMockArgsProxy(httpClient) + ep, _ := NewProxy(args) response, err := ep.GetRawMiniBlockByHash(context.Background(), 0, "aaaa", 1) require.Nil(t, err) @@ -508,7 +508,7 @@ func TestElrondProxy_GetRawMiniBlockByHash(t *testing.T) { require.Equal(t, expectedTs, ts) } -func TestElrondProxy_GetNonceAtEpochStart(t *testing.T) { +func TestProxy_GetNonceAtEpochStart(t *testing.T) { t.Parallel() expectedNonce := uint64(2) @@ -526,8 +526,8 @@ func TestElrondProxy_GetNonceAtEpochStart(t *testing.T) { statusResponseBytes, _ := json.Marshal(statusResponse) httpClient := createMockClientRespondingBytes(statusResponseBytes) - args := createMockArgsElrondProxy(httpClient) - ep, _ := NewElrondProxy(args) + args := createMockArgsProxy(httpClient) + ep, _ := NewProxy(args) response, err := ep.GetNonceAtEpochStart(context.Background(), core.MetachainShardId) require.Nil(t, err) @@ -535,7 +535,7 @@ func TestElrondProxy_GetNonceAtEpochStart(t *testing.T) { require.Equal(t, expectedNonce, response) } -func TestElrondProxy_GetRatingsConfig(t *testing.T) { +func TestProxy_GetRatingsConfig(t *testing.T) { t.Parallel() expectedRatingsConfig := &data.RatingsConfig{ @@ -552,8 +552,8 @@ func TestElrondProxy_GetRatingsConfig(t *testing.T) { ratingsResponseBytes, _ := json.Marshal(ratingsResponse) httpClient := createMockClientRespondingBytes(ratingsResponseBytes) - args := createMockArgsElrondProxy(httpClient) - ep, _ := NewElrondProxy(args) + args := createMockArgsProxy(httpClient) + ep, _ := NewProxy(args) response, err := ep.GetRatingsConfig(context.Background()) require.Nil(t, err) @@ -561,7 +561,7 @@ func TestElrondProxy_GetRatingsConfig(t *testing.T) { require.Equal(t, expectedRatingsConfig, response) } -func TestElrondProxy_GetEnableEpochsConfig(t *testing.T) { +func TestProxy_GetEnableEpochsConfig(t *testing.T) { t.Parallel() enableEpochs := config.EnableEpochs{ @@ -581,8 +581,8 @@ func TestElrondProxy_GetEnableEpochsConfig(t *testing.T) { enableEpochsResponseBytes, _ := json.Marshal(enableEpochsResponse) httpClient := createMockClientRespondingBytes(enableEpochsResponseBytes) - args := createMockArgsElrondProxy(httpClient) - ep, _ := NewElrondProxy(args) + args := createMockArgsProxy(httpClient) + ep, _ := NewProxy(args) response, err := ep.GetEnableEpochsConfig(context.Background()) require.Nil(t, err) @@ -590,7 +590,7 @@ func TestElrondProxy_GetEnableEpochsConfig(t *testing.T) { require.Equal(t, expectedEnableEpochsConfig, response) } -func TestElrondProxy_GetGenesisNodesPubKeys(t *testing.T) { +func TestProxy_GetGenesisNodesPubKeys(t *testing.T) { t.Parallel() expectedGenesisNodes := &data.GenesisNodes{ @@ -607,8 +607,8 @@ func TestElrondProxy_GetGenesisNodesPubKeys(t *testing.T) { genesisNodesResponseBytes, _ := json.Marshal(genesisNodesResponse) httpClient := createMockClientRespondingBytes(genesisNodesResponseBytes) - args := createMockArgsElrondProxy(httpClient) - ep, _ := NewElrondProxy(args) + args := createMockArgsProxy(httpClient) + ep, _ := NewProxy(args) response, err := ep.GetGenesisNodesPubKeys(context.Background()) require.Nil(t, err) @@ -616,7 +616,7 @@ func TestElrondProxy_GetGenesisNodesPubKeys(t *testing.T) { require.Equal(t, expectedGenesisNodes, response) } -func TestElrondProxy_GetValidatorsInfoByEpoch(t *testing.T) { +func TestProxy_GetValidatorsInfoByEpoch(t *testing.T) { t.Parallel() expectedValidatorsInfo := []*state.ShardValidatorInfo{ @@ -635,8 +635,8 @@ func TestElrondProxy_GetValidatorsInfoByEpoch(t *testing.T) { validatorsInfoResponseBytes, _ := json.Marshal(validatorsInfoResponse) httpClient := createMockClientRespondingBytes(validatorsInfoResponseBytes) - args := createMockArgsElrondProxy(httpClient) - ep, _ := NewElrondProxy(args) + args := createMockArgsProxy(httpClient) + ep, _ := NewProxy(args) response, err := ep.GetValidatorsInfoByEpoch(context.Background(), 1) require.Nil(t, err) diff --git a/blockchain/shardCoordinator.go b/blockchain/shardCoordinator.go index d3398fc4..3b00cc45 100644 --- a/blockchain/shardCoordinator.go +++ b/blockchain/shardCoordinator.go @@ -1,9 +1,9 @@ package blockchain import ( - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go/sharding" - erdgoCore "github.com/ElrondNetwork/elrond-sdk-erdgo/core" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-go/sharding" + erdgoCore "github.com/multiversx/mx-sdk-go/core" ) type shardCoordinator struct { diff --git a/builders/baseBuilder.go b/builders/baseBuilder.go index 01489741..ce6764be 100644 --- a/builders/baseBuilder.go +++ b/builders/baseBuilder.go @@ -5,8 +5,8 @@ import ( "fmt" "math/big" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-sdk-go/core" ) type baseBuilder struct { diff --git a/builders/interface.go b/builders/interface.go index a40de388..a56a3640 100644 --- a/builders/interface.go +++ b/builders/interface.go @@ -3,9 +3,9 @@ package builders import ( "math/big" - crypto "github.com/ElrondNetwork/elrond-go-crypto" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + crypto "github.com/multiversx/mx-chain-crypto-go" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" ) // TxDataBuilder defines the behavior of a transaction data builder diff --git a/builders/relayedTxV1Builder.go b/builders/relayedTxV1Builder.go index e8107342..ec669b70 100644 --- a/builders/relayedTxV1Builder.go +++ b/builders/relayedTxV1Builder.go @@ -5,9 +5,9 @@ import ( "encoding/json" "math/big" - "github.com/ElrondNetwork/elrond-go-core/data/transaction" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-chain-core-go/data/transaction" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" ) type relayedTxV1Builder struct { diff --git a/builders/relayedTxV1Builder_test.go b/builders/relayedTxV1Builder_test.go index 7d12e8bf..09e8c063 100644 --- a/builders/relayedTxV1Builder_test.go +++ b/builders/relayedTxV1Builder_test.go @@ -5,11 +5,11 @@ import ( "encoding/json" "testing" - "github.com/ElrondNetwork/elrond-go-crypto/signing" - "github.com/ElrondNetwork/elrond-go-crypto/signing/ed25519" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain/cryptoProvider" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" + "github.com/multiversx/mx-chain-crypto-go/signing" + "github.com/multiversx/mx-chain-crypto-go/signing/ed25519" + "github.com/multiversx/mx-sdk-go/blockchain/cryptoProvider" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/interactors" "github.com/stretchr/testify/require" ) diff --git a/builders/relayedTxV2Builder.go b/builders/relayedTxV2Builder.go index ad99f2cb..e8d13f18 100644 --- a/builders/relayedTxV2Builder.go +++ b/builders/relayedTxV2Builder.go @@ -5,8 +5,8 @@ import ( "fmt" "math/big" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" ) type relayedTxV2Builder struct { diff --git a/builders/relayedTxV2Builder_test.go b/builders/relayedTxV2Builder_test.go index 7ac9c5b4..8b007fbe 100644 --- a/builders/relayedTxV2Builder_test.go +++ b/builders/relayedTxV2Builder_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" "testing" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-sdk-go/data" "github.com/stretchr/testify/require" ) diff --git a/builders/txBuilder.go b/builders/txBuilder.go index 127a5b3e..e01a0f9c 100644 --- a/builders/txBuilder.go +++ b/builders/txBuilder.go @@ -4,12 +4,12 @@ import ( "encoding/hex" "math/big" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/data/transaction" - "github.com/ElrondNetwork/elrond-go-core/hashing/blake2b" - "github.com/ElrondNetwork/elrond-go-core/marshal" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/data/transaction" + "github.com/multiversx/mx-chain-core-go/hashing/blake2b" + "github.com/multiversx/mx-chain-core-go/marshal" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" ) var ( diff --git a/builders/txBuilder_test.go b/builders/txBuilder_test.go index f15b30ee..5505a3f5 100644 --- a/builders/txBuilder_test.go +++ b/builders/txBuilder_test.go @@ -6,13 +6,13 @@ import ( "math/big" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" - crypto "github.com/ElrondNetwork/elrond-go-crypto" - "github.com/ElrondNetwork/elrond-go-crypto/signing" - "github.com/ElrondNetwork/elrond-go-crypto/signing/ed25519" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain/cryptoProvider" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" + "github.com/multiversx/mx-chain-core-go/core/check" + crypto "github.com/multiversx/mx-chain-crypto-go" + "github.com/multiversx/mx-chain-crypto-go/signing" + "github.com/multiversx/mx-chain-crypto-go/signing/ed25519" + "github.com/multiversx/mx-sdk-go/blockchain/cryptoProvider" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/testsCommon" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/builders/txDataBuilder.go b/builders/txDataBuilder.go index d21b0bc5..c4f51bc0 100644 --- a/builders/txDataBuilder.go +++ b/builders/txDataBuilder.go @@ -4,7 +4,7 @@ import ( "math/big" "strings" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" + "github.com/multiversx/mx-sdk-go/core" ) const dataSeparator = "@" diff --git a/builders/txDataBuilder_test.go b/builders/txDataBuilder_test.go index b6ad3643..35ee03c2 100644 --- a/builders/txDataBuilder_test.go +++ b/builders/txDataBuilder_test.go @@ -7,8 +7,8 @@ import ( "strings" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-sdk-go/data" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/builders/vmQueryBuilder.go b/builders/vmQueryBuilder.go index a7d5fbe5..eed853d0 100644 --- a/builders/vmQueryBuilder.go +++ b/builders/vmQueryBuilder.go @@ -3,8 +3,8 @@ package builders import ( "math/big" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" ) type vmQueryBuilder struct { diff --git a/builders/vmQueryBuilder_test.go b/builders/vmQueryBuilder_test.go index 2ee1cb64..bb1dd9ad 100644 --- a/builders/vmQueryBuilder_test.go +++ b/builders/vmQueryBuilder_test.go @@ -6,8 +6,8 @@ import ( "math/big" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-sdk-go/data" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/core/http/clientWrapper.go b/core/http/clientWrapper.go index e63debe8..8a8f24a3 100644 --- a/core/http/clientWrapper.go +++ b/core/http/clientWrapper.go @@ -7,12 +7,12 @@ import ( "io/ioutil" "net/http" - "github.com/ElrondNetwork/elrond-go-core/core/check" + "github.com/multiversx/mx-chain-core-go/core/check" ) const ( httpUserAgentKey = "User-Agent" - httpUserAgent = "Elrond go SDK / 1.0.0 " + httpUserAgent = "MultiversX go SDK / 1.0.0 " httpAcceptTypeKey = "Accept" httpAcceptType = "application/json" diff --git a/core/http/clientWrapper_test.go b/core/http/clientWrapper_test.go index 049f1f1a..152ffb92 100644 --- a/core/http/clientWrapper_test.go +++ b/core/http/clientWrapper_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/core/check" + "github.com/multiversx/mx-chain-core-go/core/check" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/core/interface.go b/core/interface.go index 641b364d..76394db8 100644 --- a/core/interface.go +++ b/core/interface.go @@ -1,6 +1,6 @@ package core -import crypto "github.com/ElrondNetwork/elrond-go-crypto" +import crypto "github.com/multiversx/mx-chain-crypto-go" // AddressHandler will handle different implementations of an address type AddressHandler interface { diff --git a/core/polling/pollingHandler.go b/core/polling/pollingHandler.go index 87e97d36..13f204a1 100644 --- a/core/polling/pollingHandler.go +++ b/core/polling/pollingHandler.go @@ -6,8 +6,8 @@ import ( "sync" "time" - "github.com/ElrondNetwork/elrond-go-core/core/check" - logger "github.com/ElrondNetwork/elrond-go-logger" + "github.com/multiversx/mx-chain-core-go/core/check" + logger "github.com/multiversx/mx-chain-logger-go" ) const minimumPollingInterval = time.Millisecond diff --git a/core/polling/pollingHandler_test.go b/core/polling/pollingHandler_test.go index e2d2d53a..a40bf1a0 100644 --- a/core/polling/pollingHandler_test.go +++ b/core/polling/pollingHandler_test.go @@ -8,9 +8,9 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/core/check" - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core/polling/mock" + "github.com/multiversx/mx-chain-core-go/core/check" + logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/core/polling/mock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/core/variables.go b/core/variables.go index 7a3f2f59..6758ddaf 100644 --- a/core/variables.go +++ b/core/variables.go @@ -1,11 +1,11 @@ package core import ( - "github.com/ElrondNetwork/elrond-go-core/core/pubkeyConverter" - logger "github.com/ElrondNetwork/elrond-go-logger" + "github.com/multiversx/mx-chain-core-go/core/pubkeyConverter" + logger "github.com/multiversx/mx-chain-logger-go" ) -var log = logger.GetOrCreate("elrond-sdk-erdgo/core") +var log = logger.GetOrCreate("mx-sdk-go/core") // AddressPublicKeyConverter represents the default address public key converter var AddressPublicKeyConverter, _ = pubkeyConverter.NewBech32PubkeyConverter(AddressBytesLen, log) diff --git a/data/address.go b/data/address.go index 8ea4a60f..a33a97ef 100644 --- a/data/address.go +++ b/data/address.go @@ -1,6 +1,6 @@ package data -import "github.com/ElrondNetwork/elrond-sdk-erdgo/core" +import "github.com/multiversx/mx-sdk-go/core" type address struct { bytes []byte diff --git a/data/enableEpochsConfig.go b/data/enableEpochsConfig.go index 0d2fa5de..cb9f5a51 100644 --- a/data/enableEpochsConfig.go +++ b/data/enableEpochsConfig.go @@ -1,6 +1,6 @@ package data -import "github.com/ElrondNetwork/elrond-go/config" +import "github.com/multiversx/mx-chain-go/config" // EnableEpochsConfigResponse holds the enable epochs config endpoint response type EnableEpochsConfigResponse struct { diff --git a/data/nodeConfig.go b/data/nodeConfig.go index e3463fe4..7e29c6b8 100644 --- a/data/nodeConfig.go +++ b/data/nodeConfig.go @@ -1,6 +1,6 @@ package data -import "github.com/ElrondNetwork/elrond-go/state" +import "github.com/multiversx/mx-chain-go/state" // GenesisNodesResponse holds the network genesis nodes endpoint reponse type GenesisNodesResponse struct { diff --git a/data/transaction.go b/data/transaction.go index 456341b7..c221a8b4 100644 --- a/data/transaction.go +++ b/data/transaction.go @@ -1,6 +1,6 @@ package data -import "github.com/ElrondNetwork/elrond-go-core/data/transaction" +import "github.com/multiversx/mx-chain-core-go/data/transaction" // SendTransactionResponse holds the response received from the network when broadcasting a transaction type SendTransactionResponse struct { diff --git a/data/vmValues.go b/data/vmValues.go index 3c480729..f966c2d1 100644 --- a/data/vmValues.go +++ b/data/vmValues.go @@ -1,7 +1,7 @@ package data import ( - "github.com/ElrondNetwork/elrond-go-core/data/vm" + "github.com/multiversx/mx-chain-core-go/data/vm" ) // VmValuesResponseData follows the format of the data field in an API response for a VM values query diff --git a/disabled/accounts.go b/disabled/accounts.go index 9ba03da0..9c3566d0 100644 --- a/disabled/accounts.go +++ b/disabled/accounts.go @@ -3,9 +3,9 @@ package disabled import ( "context" - "github.com/ElrondNetwork/elrond-go/common" - "github.com/ElrondNetwork/elrond-go/state" - vmcommon "github.com/ElrondNetwork/elrond-vm-common" + "github.com/multiversx/mx-chain-go/common" + "github.com/multiversx/mx-chain-go/state" + vmcommon "github.com/multiversx/mx-chain-vm-common-go" ) // Accounts is a disabled implementation of the AccountAdapter interface diff --git a/disabled/blockchain.go b/disabled/blockchain.go index 137f1c2d..57b8e6f1 100644 --- a/disabled/blockchain.go +++ b/disabled/blockchain.go @@ -1,7 +1,7 @@ package disabled import ( - "github.com/ElrondNetwork/elrond-go-core/data" + "github.com/multiversx/mx-chain-core-go/data" ) // Blockchain is a disabled implementation of the ChainHandler interface diff --git a/disabled/blockchainHookCounter.go b/disabled/blockchainHookCounter.go index f082cf9c..49e9596b 100644 --- a/disabled/blockchainHookCounter.go +++ b/disabled/blockchainHookCounter.go @@ -1,6 +1,6 @@ package disabled -import vmcommon "github.com/ElrondNetwork/elrond-vm-common" +import vmcommon "github.com/multiversx/mx-chain-vm-common-go" // BlockChainHookCounter is a disabled implementation of BlockChainHookCounter interface type BlockChainHookCounter struct { @@ -24,6 +24,11 @@ func (bhc *BlockChainHookCounter) ResetCounters() { func (bhc *BlockChainHookCounter) SetMaximumValues(_ map[string]uint64) { } +// GetCounterValues - +func (bhc *BlockChainHookCounter) GetCounterValues() map[string]uint64 { + return make(map[string]uint64) +} + // IsInterfaceNil returns true if there is no value under the interface func (bhc *BlockChainHookCounter) IsInterfaceNil() bool { return bhc == nil diff --git a/disabled/builtInFunctionContainer.go b/disabled/builtInFunctionContainer.go index 47f1e1d7..707aabe8 100644 --- a/disabled/builtInFunctionContainer.go +++ b/disabled/builtInFunctionContainer.go @@ -3,7 +3,7 @@ package disabled import ( "errors" - vmcommon "github.com/ElrondNetwork/elrond-vm-common" + vmcommon "github.com/multiversx/mx-chain-vm-common-go" ) var errNotImplemented = errors.New("not implemented") diff --git a/disabled/datapool.go b/disabled/datapool.go index 4d9ace68..249f72ce 100644 --- a/disabled/datapool.go +++ b/disabled/datapool.go @@ -1,8 +1,8 @@ package disabled import ( - "github.com/ElrondNetwork/elrond-go/dataRetriever" - "github.com/ElrondNetwork/elrond-go/storage" + "github.com/multiversx/mx-chain-go/dataRetriever" + "github.com/multiversx/mx-chain-go/storage" ) // DataPool is the disabled implementation of a PoolsHolder interface diff --git a/disabled/elrondShardCoordinator.go b/disabled/elrondShardCoordinator.go deleted file mode 100644 index 1e6a6939..00000000 --- a/disabled/elrondShardCoordinator.go +++ /dev/null @@ -1,35 +0,0 @@ -package disabled - -// ElrondShardCoordinator is the disabled shard coordinator instance that satisfies the elrond.sharding.Coordinator interface -type ElrondShardCoordinator struct { -} - -// NumberOfShards returns 0 -func (esc *ElrondShardCoordinator) NumberOfShards() uint32 { - return 0 -} - -// ComputeId returns 0 -func (esc *ElrondShardCoordinator) ComputeId(_ []byte) uint32 { - return 0 -} - -// SelfId returns 0 -func (esc *ElrondShardCoordinator) SelfId() uint32 { - return 0 -} - -// SameShard returns false -func (esc *ElrondShardCoordinator) SameShard(_, _ []byte) bool { - return false -} - -// CommunicationIdentifier returns empty string -func (esc *ElrondShardCoordinator) CommunicationIdentifier(_ uint32) string { - return "" -} - -// IsInterfaceNil returns true if there is no value under the interface -func (esc *ElrondShardCoordinator) IsInterfaceNil() bool { - return esc == nil -} diff --git a/disabled/enableEpochsHandler.go b/disabled/enableEpochsHandler.go index b4fc3d5d..db449389 100644 --- a/disabled/enableEpochsHandler.go +++ b/disabled/enableEpochsHandler.go @@ -548,6 +548,16 @@ func (eeh *EnableEpochsHandler) IsRuntimeMemStoreLimitEnabled() bool { return false } +// IsWipeSingleNFTLiquidityDecreaseEnabled - +func (eeh *EnableEpochsHandler) IsWipeSingleNFTLiquidityDecreaseEnabled() bool { + return false +} + +// IsAlwaysSaveTokenMetaDataEnabled - +func (eeh *EnableEpochsHandler) IsAlwaysSaveTokenMetaDataEnabled() bool { + return false +} + // IsInterfaceNil returns true if there is no value under the interface func (eeh *EnableEpochsHandler) IsInterfaceNil() bool { return eeh == nil diff --git a/disabled/epochNotifier.go b/disabled/epochNotifier.go index af4ba104..3dc0d655 100644 --- a/disabled/epochNotifier.go +++ b/disabled/epochNotifier.go @@ -1,8 +1,8 @@ package disabled import ( - "github.com/ElrondNetwork/elrond-go-core/data" - vmcommon "github.com/ElrondNetwork/elrond-vm-common" + "github.com/multiversx/mx-chain-core-go/data" + vmcommon "github.com/multiversx/mx-chain-vm-common-go" ) // EpochNotifier is a disabled implementation of EpochNotifier interface diff --git a/disabled/epochStartNotifier.go b/disabled/epochStartNotifier.go index 6780697c..7701845a 100644 --- a/disabled/epochStartNotifier.go +++ b/disabled/epochStartNotifier.go @@ -1,7 +1,7 @@ package disabled import ( - "github.com/ElrondNetwork/elrond-go/epochStart" + "github.com/multiversx/mx-chain-go/epochStart" ) // EpochStartNotifier is a disabled implementation of EpochStartEventNotifier interface diff --git a/disabled/fallbackHeaderValidator.go b/disabled/fallbackHeaderValidator.go index e3bb1131..56e2dcc1 100644 --- a/disabled/fallbackHeaderValidator.go +++ b/disabled/fallbackHeaderValidator.go @@ -1,7 +1,7 @@ package disabled import ( - "github.com/ElrondNetwork/elrond-go-core/data" + "github.com/multiversx/mx-chain-core-go/data" ) // FallBackHeaderValidator is a disabled implementation of FallBackHeaderValidator interface diff --git a/disabled/gasScheduleNotifier.go b/disabled/gasScheduleNotifier.go index d5d72357..52545faa 100644 --- a/disabled/gasScheduleNotifier.go +++ b/disabled/gasScheduleNotifier.go @@ -1,6 +1,6 @@ package disabled -import "github.com/ElrondNetwork/elrond-go-core/core" +import "github.com/multiversx/mx-chain-core-go/core" // GasScheduleNotifier - type GasScheduleNotifier struct { diff --git a/disabled/nodeTypeProvider.go b/disabled/nodeTypeProvider.go index 8416ee52..189aa18d 100644 --- a/disabled/nodeTypeProvider.go +++ b/disabled/nodeTypeProvider.go @@ -1,7 +1,7 @@ package disabled import ( - "github.com/ElrondNetwork/elrond-go-core/core" + "github.com/multiversx/mx-chain-core-go/core" ) // NodeTypeProvider is a disabled implementation of NodeTypeProviderHandler interface diff --git a/disabled/shardCoordinator.go b/disabled/shardCoordinator.go new file mode 100644 index 00000000..8d850af2 --- /dev/null +++ b/disabled/shardCoordinator.go @@ -0,0 +1,35 @@ +package disabled + +// ShardCoordinator is the disabled shard coordinator instance that satisfies the mx-chain-go.sharding.Coordinator interface +type ShardCoordinator struct { +} + +// NumberOfShards returns 0 +func (sc *ShardCoordinator) NumberOfShards() uint32 { + return 0 +} + +// ComputeId returns 0 +func (sc *ShardCoordinator) ComputeId(_ []byte) uint32 { + return 0 +} + +// SelfId returns 0 +func (sc *ShardCoordinator) SelfId() uint32 { + return 0 +} + +// SameShard returns false +func (sc *ShardCoordinator) SameShard(_, _ []byte) bool { + return false +} + +// CommunicationIdentifier returns empty string +func (sc *ShardCoordinator) CommunicationIdentifier(_ uint32) string { + return "" +} + +// IsInterfaceNil returns true if there is no value under the interface +func (sc *ShardCoordinator) IsInterfaceNil() bool { + return sc == nil +} diff --git a/disabled/simpleESDTNFTStorageHandler.go b/disabled/simpleESDTNFTStorageHandler.go index af2bbe39..fa80fc5c 100644 --- a/disabled/simpleESDTNFTStorageHandler.go +++ b/disabled/simpleESDTNFTStorageHandler.go @@ -1,9 +1,9 @@ package disabled import ( - "github.com/ElrondNetwork/elrond-go-core/data" - "github.com/ElrondNetwork/elrond-go-core/data/esdt" - vmcommon "github.com/ElrondNetwork/elrond-vm-common" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/esdt" + vmcommon "github.com/multiversx/mx-chain-vm-common-go" ) // SimpleESDTNFTStorageHandler is a disabled implementation of SimpleESDTNFTStorageHandler interface diff --git a/disabled/storageService.go b/disabled/storageService.go index 136be702..feff79c0 100644 --- a/disabled/storageService.go +++ b/disabled/storageService.go @@ -1,8 +1,8 @@ package disabled import ( - "github.com/ElrondNetwork/elrond-go/dataRetriever" - "github.com/ElrondNetwork/elrond-go/storage" + "github.com/multiversx/mx-chain-go/dataRetriever" + "github.com/multiversx/mx-chain-go/storage" ) // StorageService is a disabled implementation of the StorageService interface diff --git a/disabled/storer.go b/disabled/storer.go index 15fc218d..1dde1c0d 100644 --- a/disabled/storer.go +++ b/disabled/storer.go @@ -1,6 +1,6 @@ package disabled -import "github.com/ElrondNetwork/elrond-go-core/storage" +import "github.com/multiversx/mx-chain-core-go/storage" // Storer is a disabled implementation of Storer interface type Storer struct { diff --git a/examples/examplesAccount/main.go b/examples/examplesAccount/main.go index 0134ecf2..f96620e8 100644 --- a/examples/examplesAccount/main.go +++ b/examples/examplesAccount/main.go @@ -5,17 +5,17 @@ import ( "fmt" "time" - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/examples" + logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/blockchain" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/examples" ) -var log = logger.GetOrCreate("elrond-sdk-erdgo/examples/examplesAccount") +var log = logger.GetOrCreate("mx-sdk-go/examples/examplesAccount") func main() { - args := blockchain.ArgsElrondProxy{ + args := blockchain.ArgsProxy{ ProxyURL: examples.TestnetGateway, Client: nil, SameScState: false, @@ -24,7 +24,7 @@ func main() { CacheExpirationTime: time.Minute, EntityType: core.Proxy, } - ep, err := blockchain.NewElrondProxy(args) + ep, err := blockchain.NewProxy(args) if err != nil { log.Error("error creating proxy", "error", err) return diff --git a/examples/examplesBlock/main.go b/examples/examplesBlock/main.go index ef6f27d2..62894aa9 100644 --- a/examples/examplesBlock/main.go +++ b/examples/examplesBlock/main.go @@ -5,16 +5,16 @@ import ( "encoding/json" "time" - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/examples" + logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/blockchain" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/examples" ) -var log = logger.GetOrCreate("elrond-sdk-erdgo/examples/examplesBlock") +var log = logger.GetOrCreate("mx-sdk-go/examples/examplesBlock") func main() { - args := blockchain.ArgsElrondProxy{ + args := blockchain.ArgsProxy{ ProxyURL: examples.TestnetGateway, Client: nil, SameScState: false, @@ -23,7 +23,7 @@ func main() { CacheExpirationTime: time.Minute, EntityType: core.Proxy, } - ep, err := blockchain.NewElrondProxy(args) + ep, err := blockchain.NewProxy(args) if err != nil { log.Error("error creating proxy", "error", err) return diff --git a/examples/examplesFlowWalletTracker/main.go b/examples/examplesFlowWalletTracker/main.go index a67af9eb..209aa2d8 100644 --- a/examples/examplesFlowWalletTracker/main.go +++ b/examples/examplesFlowWalletTracker/main.go @@ -9,20 +9,20 @@ import ( "strings" "time" - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain/cryptoProvider" - "github.com/ElrondNetwork/elrond-sdk-erdgo/builders" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/examples" - "github.com/ElrondNetwork/elrond-sdk-erdgo/examples/examplesFlowWalletTracker/mock" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" - "github.com/ElrondNetwork/elrond-sdk-erdgo/workflows" + logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/blockchain" + "github.com/multiversx/mx-sdk-go/blockchain/cryptoProvider" + "github.com/multiversx/mx-sdk-go/builders" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/examples" + "github.com/multiversx/mx-sdk-go/examples/examplesFlowWalletTracker/mock" + "github.com/multiversx/mx-sdk-go/interactors" + "github.com/multiversx/mx-sdk-go/workflows" ) const timeToExecuteRequest = time.Second -var log = logger.GetOrCreate("elrond-sdk-erdgo/examples/examplesFlowWalletTracker") +var log = logger.GetOrCreate("mx-sdk-go/examples/examplesFlowWalletTracker") type moveBalanceHandler interface { GenerateMoveBalanceTransactions(ctx context.Context, addresses []string) @@ -51,7 +51,7 @@ func main() { } func runApp() error { - args := blockchain.ArgsElrondProxy{ + args := blockchain.ArgsProxy{ ProxyURL: examples.TestnetGateway, Client: nil, SameScState: false, @@ -60,7 +60,7 @@ func runApp() error { CacheExpirationTime: time.Minute, EntityType: core.Proxy, } - ep, err := blockchain.NewElrondProxy(args) + ep, err := blockchain.NewProxy(args) if err != nil { return err } @@ -91,7 +91,7 @@ func runApp() error { return err } - receiverAddress := "erd1zptg3eu7uw0qvzhnu009lwxupcn6ntjxptj5gaxt8curhxjqr9tsqpsnht" // /elrond-sdk-erdgo/interactors/testdata/test.pem + receiverAddress := "erd1zptg3eu7uw0qvzhnu009lwxupcn6ntjxptj5gaxt8curhxjqr9tsqpsnht" // /mx-sdk-go/interactors/testdata/test.pem txInteractor, err := interactors.NewTransactionInteractor(ep, txBuilder) if err != nil { return err diff --git a/examples/examplesHeaderCheck/main.go b/examples/examplesHeaderCheck/main.go index 87a8c0a4..502ba105 100644 --- a/examples/examplesHeaderCheck/main.go +++ b/examples/examplesHeaderCheck/main.go @@ -4,18 +4,18 @@ import ( "context" "time" - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-go/config" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/examples" - "github.com/ElrondNetwork/elrond-sdk-erdgo/headerCheck" + "github.com/multiversx/mx-chain-go/config" + logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/blockchain" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/examples" + "github.com/multiversx/mx-sdk-go/headerCheck" ) -var log = logger.GetOrCreate("elrond-sdk-erdgo/examples/examplesHeaderCheck") +var log = logger.GetOrCreate("mx-sdk-go/examples/examplesHeaderCheck") func main() { - args := blockchain.ArgsElrondProxy{ + args := blockchain.ArgsProxy{ ProxyURL: examples.TestnetGateway, Client: nil, SameScState: false, @@ -24,7 +24,7 @@ func main() { CacheExpirationTime: time.Minute, EntityType: core.Proxy, } - ep, err := blockchain.NewElrondProxy(args) + ep, err := blockchain.NewProxy(args) if err != nil { log.Error("error creating proxy", "error", err) return diff --git a/examples/examplesPriceAggregator/main.go b/examples/examplesPriceAggregator/main.go index f29fa911..dec18cff 100644 --- a/examples/examplesPriceAggregator/main.go +++ b/examples/examplesPriceAggregator/main.go @@ -7,22 +7,22 @@ import ( "os/signal" "time" - "github.com/ElrondNetwork/elrond-go-crypto/signing" - "github.com/ElrondNetwork/elrond-go-crypto/signing/ed25519" - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator/fetchers" - "github.com/ElrondNetwork/elrond-sdk-erdgo/aggregator/mock" - "github.com/ElrondNetwork/elrond-sdk-erdgo/authentication" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain/cryptoProvider" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core/polling" - "github.com/ElrondNetwork/elrond-sdk-erdgo/examples" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" + "github.com/multiversx/mx-chain-crypto-go/signing" + "github.com/multiversx/mx-chain-crypto-go/signing/ed25519" + logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/aggregator" + "github.com/multiversx/mx-sdk-go/aggregator/fetchers" + "github.com/multiversx/mx-sdk-go/aggregator/mock" + "github.com/multiversx/mx-sdk-go/authentication" + "github.com/multiversx/mx-sdk-go/blockchain" + "github.com/multiversx/mx-sdk-go/blockchain/cryptoProvider" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/core/polling" + "github.com/multiversx/mx-sdk-go/examples" + "github.com/multiversx/mx-sdk-go/interactors" ) -var log = logger.GetOrCreate("elrond-sdk-erdgo/examples/examplesPriceAggregator") +var log = logger.GetOrCreate("mx-sdk-go/examples/examplesPriceAggregator") const base = "ETH" const quote = "USD" @@ -33,7 +33,7 @@ const minResultsNum = 3 const pollInterval = time.Second * 2 const autoSendInterval = time.Second * 10 -const networkAddress = "https://testnet-gateway.elrond.com" +const networkAddress = "https://testnet-gateway.multiversx.com" var ( suite = ed25519.NewEd25519() @@ -211,7 +211,7 @@ func createAuthClient() (authentication.AuthClient, error) { return nil, err } - argsProxy := blockchain.ArgsElrondProxy{ + argsProxy := blockchain.ArgsProxy{ ProxyURL: networkAddress, SameScState: false, ShouldBeSynced: false, @@ -221,7 +221,7 @@ func createAuthClient() (authentication.AuthClient, error) { EntityType: core.RestAPIEntityType("Proxy"), } - proxy, err := blockchain.NewElrondProxy(argsProxy) + proxy, err := blockchain.NewProxy(argsProxy) if err != nil { return nil, err } diff --git a/examples/examplesTransaction/main.go b/examples/examplesTransaction/main.go index 72475768..1d09ad98 100644 --- a/examples/examplesTransaction/main.go +++ b/examples/examplesTransaction/main.go @@ -4,27 +4,27 @@ import ( "context" "time" - "github.com/ElrondNetwork/elrond-go-crypto/signing" - "github.com/ElrondNetwork/elrond-go-crypto/signing/ed25519" - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain/cryptoProvider" - "github.com/ElrondNetwork/elrond-sdk-erdgo/builders" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/examples" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" + "github.com/multiversx/mx-chain-crypto-go/signing" + "github.com/multiversx/mx-chain-crypto-go/signing/ed25519" + logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/blockchain" + "github.com/multiversx/mx-sdk-go/blockchain/cryptoProvider" + "github.com/multiversx/mx-sdk-go/builders" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/examples" + "github.com/multiversx/mx-sdk-go/interactors" ) var ( suite = ed25519.NewEd25519() keyGen = signing.NewKeyGenerator(suite) - log = logger.GetOrCreate("elrond-sdk-erdgo/examples/examplesTransaction") + log = logger.GetOrCreate("mx-sdk-go/examples/examplesTransaction") ) func main() { _ = logger.SetLogLevel("*:DEBUG") - args := blockchain.ArgsElrondProxy{ + args := blockchain.ArgsProxy{ ProxyURL: examples.TestnetGateway, Client: nil, SameScState: false, @@ -33,7 +33,7 @@ func main() { CacheExpirationTime: time.Minute, EntityType: core.Proxy, } - ep, err := blockchain.NewElrondProxy(args) + ep, err := blockchain.NewProxy(args) if err != nil { log.Error("error creating proxy", "error", err) return diff --git a/examples/examplesVMQuery/main.go b/examples/examplesVMQuery/main.go index e3ea09a1..741dfbc4 100644 --- a/examples/examplesVMQuery/main.go +++ b/examples/examplesVMQuery/main.go @@ -4,17 +4,17 @@ import ( "context" "time" - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/examples" + logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/blockchain" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/examples" ) -var log = logger.GetOrCreate("elrond-sdk-erdgo/examples/examplesVMQuery") +var log = logger.GetOrCreate("mx-sdk-go/examples/examplesVMQuery") func main() { - args := blockchain.ArgsElrondProxy{ + args := blockchain.ArgsProxy{ ProxyURL: examples.TestnetGateway, Client: nil, SameScState: false, @@ -23,7 +23,7 @@ func main() { CacheExpirationTime: time.Minute, EntityType: core.Proxy, } - ep, err := blockchain.NewElrondProxy(args) + ep, err := blockchain.NewProxy(args) if err != nil { log.Error("error creating proxy", "error", err) return diff --git a/examples/examplesWallet/main.go b/examples/examplesWallet/main.go index 54849936..d6d87a9b 100644 --- a/examples/examplesWallet/main.go +++ b/examples/examplesWallet/main.go @@ -1,11 +1,11 @@ package main import ( - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" + logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/interactors" ) -var log = logger.GetOrCreate("elrond-sdk-erdgo/examples/examplesWallet") +var log = logger.GetOrCreate("mx-sdk-go/examples/examplesWallet") func main() { w := interactors.NewWallet() diff --git a/examples/networks.go b/examples/networks.go index 4d955221..05cc5d97 100644 --- a/examples/networks.go +++ b/examples/networks.go @@ -1,7 +1,7 @@ package examples // MainnetGateway represents the mainnet gateway address -const MainnetGateway = "https://gateway.elrond.com" +const MainnetGateway = "https://gateway.multiversx.com" // TestnetGateway represents the testnet gateway address -const TestnetGateway = "https://testnet-gateway.elrond.com" +const TestnetGateway = "https://testnet-gateway.multiversx.com" diff --git a/go.mod b/go.mod index b362cd75..2a51a6d4 100644 --- a/go.mod +++ b/go.mod @@ -1,27 +1,24 @@ -module github.com/ElrondNetwork/elrond-sdk-erdgo +module github.com/multiversx/mx-sdk-go go 1.17 require ( - github.com/ElrondNetwork/elrond-go v1.4.1-0.20221209102744-b2d7dbb950b4 - github.com/ElrondNetwork/elrond-go-core v1.1.26 - github.com/ElrondNetwork/elrond-go-crypto v1.2.2 - github.com/ElrondNetwork/elrond-go-logger v1.0.10 - github.com/ElrondNetwork/elrond-vm-common v1.3.30 github.com/gin-contrib/cors v1.4.0 github.com/gin-gonic/gin v1.8.1 github.com/gorilla/websocket v1.5.0 + github.com/multiversx/mx-chain-core-go v1.1.30 + github.com/multiversx/mx-chain-crypto-go v1.2.5 + github.com/multiversx/mx-chain-go v1.4.4 + github.com/multiversx/mx-chain-logger-go v1.0.11 + github.com/multiversx/mx-chain-vm-common-go v1.3.36 github.com/pborman/uuid v1.2.1 - github.com/stretchr/testify v1.8.0 + github.com/stretchr/testify v1.8.1 github.com/tyler-smith/go-bip39 v1.1.0 golang.org/x/crypto v0.3.0 golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b ) require ( - github.com/ElrondNetwork/concurrent-map v0.1.3 // indirect - github.com/ElrondNetwork/elrond-go-p2p v1.0.5 // indirect - github.com/ElrondNetwork/elrond-go-storage v1.0.4 // indirect github.com/beevik/ntp v0.3.0 // indirect github.com/benbjohnson/clock v1.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -114,6 +111,9 @@ require ( 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-p2p-go v1.0.10 // indirect + github.com/multiversx/mx-chain-storage-go v1.0.7 // 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 @@ -156,9 +156,3 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect lukechampine.com/blake3 v1.1.7 // indirect ) - -replace github.com/ElrondNetwork/arwen-wasm-vm/v1_2 v1.2.41 => github.com/ElrondNetwork/arwen-wasm-vm v1.2.41 - -replace github.com/ElrondNetwork/arwen-wasm-vm/v1_3 v1.3.41 => github.com/ElrondNetwork/arwen-wasm-vm v1.3.41 - -replace github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.58 => github.com/ElrondNetwork/arwen-wasm-vm v1.4.58 diff --git a/go.sum b/go.sum index abfd1367..d99bd128 100644 --- a/go.sum +++ b/go.sum @@ -42,35 +42,6 @@ github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOv github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/ElrondNetwork/big-int-util v0.1.0 h1:vTMoJ5azhVmr7jhpSD3JUjQdkdyXoEPVkOvhdw1RjV4= -github.com/ElrondNetwork/big-int-util v0.1.0/go.mod h1:96viBvoTXLjZOhEvE0D+QnAwg1IJLPAK6GVHMbC7Aw4= -github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04gd61sNYo04Zf0= -github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= -github.com/ElrondNetwork/elastic-indexer-go v1.3.3 h1:RgJ043yt92PUWMbSAQHRrC+GiyNnFdwdM/kseHlpLoo= -github.com/ElrondNetwork/elastic-indexer-go v1.3.3/go.mod h1:E3VO5712GkGSGYnOTJ+0wxW74JXgjV6XCRPlcHiTTK0= -github.com/ElrondNetwork/elrond-go v1.4.1-0.20221209102744-b2d7dbb950b4 h1:Z2WIuaC5Y2i1NiOAu9/BcTmeFJhq5aWJRj0nBYUwI6w= -github.com/ElrondNetwork/elrond-go v1.4.1-0.20221209102744-b2d7dbb950b4/go.mod h1:Wu2Zfw1UjbFT4E47SlF2rfYnn9UTB9CWosa4oar7NQY= -github.com/ElrondNetwork/elrond-go-core v1.1.26 h1:5syiJMlkWlH7HHnuiOafJJzeI+oUfYqL8mXREqrFerY= -github.com/ElrondNetwork/elrond-go-core v1.1.26/go.mod h1:N/RI++YU2M6OlnD1GSZepc1wPhI84ykRDQ1IyD3B0wk= -github.com/ElrondNetwork/elrond-go-crypto v1.2.2 h1:Q59dZUeyibuskq5vjgk3ng/87ifOcd9YZMTnlYJAuIU= -github.com/ElrondNetwork/elrond-go-crypto v1.2.2/go.mod h1:MyQPKUKti7Axnx/eihhL0F2jLTalvSV/Ytv1mIxvYyM= -github.com/ElrondNetwork/elrond-go-logger v1.0.10 h1:2xQOWZErcHW5sl9qSRO+7mGNw+QhFhqiUlLLtOgvuuk= -github.com/ElrondNetwork/elrond-go-logger v1.0.10/go.mod h1:+rMODFw4yQptTi5WuLUBzvl/AE26V+2YJtc52wX30Eg= -github.com/ElrondNetwork/elrond-go-p2p v1.0.5 h1:XzuieXEKrVSQ9gKKO3sq60RRZC29IRYgmn7RsPmgUOA= -github.com/ElrondNetwork/elrond-go-p2p v1.0.5/go.mod h1:yCdKTQWNHNKrrQAK5xx1uQT02BEiumjz88I/fk5m1f8= -github.com/ElrondNetwork/elrond-go-storage v1.0.2/go.mod h1:SRsv4hUtL1BCiQe0eADth3C0EZH9baijzIJDCUitR34= -github.com/ElrondNetwork/elrond-go-storage v1.0.4 h1:esyXbHQvlR6m4HGeC86Nq0xAJ74+QG9EnUgfG+wQDYQ= -github.com/ElrondNetwork/elrond-go-storage v1.0.4/go.mod h1:SRsv4hUtL1BCiQe0eADth3C0EZH9baijzIJDCUitR34= -github.com/ElrondNetwork/elrond-vm-common v1.3.27/go.mod h1:3GKLv9hUFYEVxoBgtaCmaZo9HMNfKN9mM/O/xX83Rbw= -github.com/ElrondNetwork/elrond-vm-common v1.3.28/go.mod h1:3GKLv9hUFYEVxoBgtaCmaZo9HMNfKN9mM/O/xX83Rbw= -github.com/ElrondNetwork/elrond-vm-common v1.3.30 h1:nLMORp46GcvK9qwx/Iiz+8h/MB5qlPppaX+VJikOz8I= -github.com/ElrondNetwork/elrond-vm-common v1.3.30/go.mod h1:3GKLv9hUFYEVxoBgtaCmaZo9HMNfKN9mM/O/xX83Rbw= -github.com/ElrondNetwork/wasm-vm-v1_2 v1.2.48 h1:il52OCaEpYDQFRkUtlsBwBqnbpkoN9S2FAnjF4z3VHk= -github.com/ElrondNetwork/wasm-vm-v1_2 v1.2.48/go.mod h1:xcs02SDXqF//9zFUcgzBY3jpGQKJ4AiO2pTa8ZgS6zs= -github.com/ElrondNetwork/wasm-vm-v1_3 v1.3.48 h1:jgR6oWmbXGFDdAoPSny1ibRsm9/JRQIc/hbtl8JcYsA= -github.com/ElrondNetwork/wasm-vm-v1_3 v1.3.48/go.mod h1:ZyuArzcU3qq34mrW06QPTU2w1xcla6tj+BcTQtcanP4= -github.com/ElrondNetwork/wasm-vm-v1_4 v1.4.68 h1:fVasWb4cE1DbmE1Eq0yit3yu0zq6V4G5M9anEgLAZ3s= -github.com/ElrondNetwork/wasm-vm-v1_4 v1.4.68/go.mod h1:LM/5+DfBaI36NL77Xp1XyH+8ozuGOEPJlOAaDtiKW8g= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= @@ -99,8 +70,9 @@ github.com/btcsuite/btcd v0.23.0 h1:V2/ZgjfDFIygAX3ZapeigkVBoVUtOJKSwrhZdlpSvaA= github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= -github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k= github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU= +github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= +github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= @@ -623,6 +595,33 @@ github.com/multiformats/go-varint v0.0.2/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXS github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/multiformats/go-varint v0.0.6 h1:gk85QWKxh3TazbLxED/NlDVv8+q+ReFJk7Y2W/KhfNY= github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= +github.com/multiversx/concurrent-map v0.1.4 h1:hdnbM8VE4b0KYJaGY5yJS2aNIW9TFFsUYwbO0993uPI= +github.com/multiversx/concurrent-map v0.1.4/go.mod h1:8cWFRJDOrWHOTNSqgYCUvwT7c7eFQ4U2vKMOp4A/9+o= +github.com/multiversx/mx-chain-core-go v1.1.30 h1:BtURR4I6HU1OnSbxcPMTQSQXNqtOuH3RW6bg5N7FSM0= +github.com/multiversx/mx-chain-core-go v1.1.30/go.mod h1:8gGEQv6BWuuJwhd25qqhCOZbBSv9mk+hLeKvinSaSMk= +github.com/multiversx/mx-chain-crypto-go v1.2.5 h1:tuq3BUNMhKud5DQbZi9DiVAAHUXypizy8zPH0NpTGZk= +github.com/multiversx/mx-chain-crypto-go v1.2.5/go.mod h1:teqhNyWEqfMPgNn8sgWXlgtJ1a36jGCnhs/tRpXW6r4= +github.com/multiversx/mx-chain-es-indexer-go v1.3.8 h1:OvdOoBUQKkTaZsFPiBp1WCvDRN9ReQJUfy9Ac06rguM= +github.com/multiversx/mx-chain-es-indexer-go v1.3.8/go.mod h1:IV42GfhkqQ5vVO0OzGaF/ejp8TQrLkNo4LSB3TPnVhg= +github.com/multiversx/mx-chain-go v1.4.4 h1:sM0UlXj+JWpr9l9BMsFpwck+nSAF/8BThpR0mhiWeOw= +github.com/multiversx/mx-chain-go v1.4.4/go.mod h1:PREgsJ97g7a9yd5BUqfp8FpM2VSIFpYIt3VTVXBMUks= +github.com/multiversx/mx-chain-logger-go v1.0.11 h1:DFsHa+sc5fKwhDR50I8uBM99RTDTEW68ESyr5ALRDwE= +github.com/multiversx/mx-chain-logger-go v1.0.11/go.mod h1:1srDkP0DQucWQ+rYfaq0BX2qLnULsUdRPADpYUTM6dA= +github.com/multiversx/mx-chain-p2p-go v1.0.10 h1:CYCuI0SP8Pt9K0TcJjUyxK7ByvWi2FXNUihy0iCEVIA= +github.com/multiversx/mx-chain-p2p-go v1.0.10/go.mod h1:j9Ueo2ptCnL7TQvQg6KS/KWAoJEJpjkPgE5ZTaqEAn4= +github.com/multiversx/mx-chain-storage-go v1.0.7 h1:UqLo/OLTD3IHiE/TB/SEdNRV1GG2f1R6vIP5ehHwCNw= +github.com/multiversx/mx-chain-storage-go v1.0.7/go.mod h1:gtKoV32Cg2Uy8deHzF8Ud0qAl0zv92FvWgPSYIP0Zmg= +github.com/multiversx/mx-chain-vm-common-go v1.3.34/go.mod h1:sZ2COLCxvf2GxAAJHGmGqWybObLtFuk2tZUyGqnMXE8= +github.com/multiversx/mx-chain-vm-common-go v1.3.36 h1:9TViMK+vqTHss9cnGKtzOWzsxI/LWIetAYzrgf4H/w0= +github.com/multiversx/mx-chain-vm-common-go v1.3.36/go.mod h1:sZ2COLCxvf2GxAAJHGmGqWybObLtFuk2tZUyGqnMXE8= +github.com/multiversx/mx-chain-vm-v1_2-go v1.2.49 h1:Qbe+QvpUzodoOJEu+j6uK/erhnLfQBwNGiAEyP1XlQI= +github.com/multiversx/mx-chain-vm-v1_2-go v1.2.49/go.mod h1:+2IkboTtZ75oZ2Lzx7gNWbLP6BQ5GYa1MJQXPcfzu60= +github.com/multiversx/mx-chain-vm-v1_3-go v1.3.50 h1:+JlYeStjpPqyRGzfLCwnR4Zya3nA34SJjj/1DP1HtXk= +github.com/multiversx/mx-chain-vm-v1_3-go v1.3.50/go.mod h1:+rdIrpLS4NOAA3DNwXQHxXKO6cPnU3DF8+l0AbjV27E= +github.com/multiversx/mx-chain-vm-v1_4-go v1.4.74 h1:qr86QIn+u9zjRNa6/aDJ0nNgKk6Cb2FGB0RvltCcJhE= +github.com/multiversx/mx-chain-vm-v1_4-go v1.4.74/go.mod h1:EInFuruY4smF2XZczFcOM8W607x3T6KanTJ5mjYHY4Y= +github.com/multiversx/mx-components-big-int v0.1.1 h1:695mYPKYOrmGEGgRH4/pZruDoe3CPP1LHrBxKfvj5l4= +github.com/multiversx/mx-components-big-int v0.1.1/go.mod h1:0QrcFdfeLgJ/am10HGBeH0G0DNF+0Qx1E4DS/iozQls= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= @@ -759,6 +758,7 @@ github.com/src-d/envconfig v1.0.0/go.mod h1:Q9YQZ7BKITldTBnoxsE5gOeB5y66RyPXeue/ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -766,8 +766,9 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= diff --git a/headerCheck/export_test.go b/headerCheck/export_test.go index a56e1cb3..eb1cd263 100644 --- a/headerCheck/export_test.go +++ b/headerCheck/export_test.go @@ -3,7 +3,7 @@ package headerCheck import ( "context" - coreData "github.com/ElrondNetwork/elrond-go-core/data" + coreData "github.com/multiversx/mx-chain-core-go/data" ) func (hch *headerVerifier) FetchHeaderByHashAndShard(ctx context.Context, shardId uint32, hash string) (coreData.HeaderHandler, error) { diff --git a/headerCheck/factory/coreComponents.go b/headerCheck/factory/coreComponents.go index 02df0785..d1477528 100644 --- a/headerCheck/factory/coreComponents.go +++ b/headerCheck/factory/coreComponents.go @@ -1,19 +1,19 @@ package factory import ( - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/pubkeyConverter" - "github.com/ElrondNetwork/elrond-go-core/hashing" - hasherFactory "github.com/ElrondNetwork/elrond-go-core/hashing/factory" - "github.com/ElrondNetwork/elrond-go-core/marshal" - marshalizerFactory "github.com/ElrondNetwork/elrond-go-core/marshal/factory" - "github.com/ElrondNetwork/elrond-go/common" - "github.com/ElrondNetwork/elrond-go/common/enablers" - "github.com/ElrondNetwork/elrond-go/config" - "github.com/ElrondNetwork/elrond-go/process/rating" - "github.com/ElrondNetwork/elrond-go/sharding/nodesCoordinator" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/disabled" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/pubkeyConverter" + "github.com/multiversx/mx-chain-core-go/hashing" + hasherFactory "github.com/multiversx/mx-chain-core-go/hashing/factory" + "github.com/multiversx/mx-chain-core-go/marshal" + marshalizerFactory "github.com/multiversx/mx-chain-core-go/marshal/factory" + "github.com/multiversx/mx-chain-go/common" + "github.com/multiversx/mx-chain-go/common/enablers" + "github.com/multiversx/mx-chain-go/config" + "github.com/multiversx/mx-chain-go/process/rating" + "github.com/multiversx/mx-chain-go/sharding/nodesCoordinator" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/disabled" ) const ( diff --git a/headerCheck/factory/cryptoComponents.go b/headerCheck/factory/cryptoComponents.go index e90921ae..5821a457 100644 --- a/headerCheck/factory/cryptoComponents.go +++ b/headerCheck/factory/cryptoComponents.go @@ -1,13 +1,13 @@ package factory import ( - "github.com/ElrondNetwork/elrond-go-core/hashing/blake2b" - crypto "github.com/ElrondNetwork/elrond-go-crypto" - "github.com/ElrondNetwork/elrond-go-crypto/signing" - disabledSig "github.com/ElrondNetwork/elrond-go-crypto/signing/disabled/singlesig" - "github.com/ElrondNetwork/elrond-go-crypto/signing/mcl" - mclMultiSig "github.com/ElrondNetwork/elrond-go-crypto/signing/mcl/multisig" - "github.com/ElrondNetwork/elrond-go-crypto/signing/multisig" + "github.com/multiversx/mx-chain-core-go/hashing/blake2b" + crypto "github.com/multiversx/mx-chain-crypto-go" + "github.com/multiversx/mx-chain-crypto-go/signing" + disabledSig "github.com/multiversx/mx-chain-crypto-go/signing/disabled/singlesig" + "github.com/multiversx/mx-chain-crypto-go/signing/mcl" + mclMultiSig "github.com/multiversx/mx-chain-crypto-go/signing/mcl/multisig" + "github.com/multiversx/mx-chain-crypto-go/signing/multisig" ) type cryptoComponents struct { diff --git a/headerCheck/factory/nodesCoordinator.go b/headerCheck/factory/nodesCoordinator.go index ef8775c7..c068865e 100644 --- a/headerCheck/factory/nodesCoordinator.go +++ b/headerCheck/factory/nodesCoordinator.go @@ -1,15 +1,15 @@ package factory import ( - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/data/endProcess" - crypto "github.com/ElrondNetwork/elrond-go-crypto" - "github.com/ElrondNetwork/elrond-go/common" - "github.com/ElrondNetwork/elrond-go/config" - "github.com/ElrondNetwork/elrond-go/dataRetriever/dataPool" - "github.com/ElrondNetwork/elrond-go/sharding/nodesCoordinator" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/disabled" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/data/endProcess" + crypto "github.com/multiversx/mx-chain-crypto-go" + "github.com/multiversx/mx-chain-go/common" + "github.com/multiversx/mx-chain-go/config" + "github.com/multiversx/mx-chain-go/dataRetriever/dataPool" + "github.com/multiversx/mx-chain-go/sharding/nodesCoordinator" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/disabled" ) const ( diff --git a/headerCheck/headerCheck.go b/headerCheck/headerCheck.go index c08e8868..9ec57b6a 100644 --- a/headerCheck/headerCheck.go +++ b/headerCheck/headerCheck.go @@ -3,14 +3,14 @@ package headerCheck import ( "context" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" - coreData "github.com/ElrondNetwork/elrond-go-core/data" - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-go/sharding/nodesCoordinator" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + coreData "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-go/sharding/nodesCoordinator" + logger "github.com/multiversx/mx-chain-logger-go" ) -var log = logger.GetOrCreate("elrond-sdk-erdgo/headerCheck") +var log = logger.GetOrCreate("mx-sdk-go/headerCheck") // ArgsHeaderVerifier holds all dependencies required by headerVerifier in // order to create a new instance diff --git a/headerCheck/headerCheckFactory.go b/headerCheck/headerCheckFactory.go index 6c5674ca..ac626812 100644 --- a/headerCheck/headerCheckFactory.go +++ b/headerCheck/headerCheckFactory.go @@ -3,12 +3,12 @@ package headerCheck import ( "context" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go/factory/crypto" - "github.com/ElrondNetwork/elrond-go/process/headerCheck" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/disabled" - "github.com/ElrondNetwork/elrond-sdk-erdgo/headerCheck/factory" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-go/factory/crypto" + "github.com/multiversx/mx-chain-go/process/headerCheck" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/disabled" + "github.com/multiversx/mx-sdk-go/headerCheck/factory" ) // NewHeaderCheckHandler will create all components needed for header diff --git a/headerCheck/headerCheck_test.go b/headerCheck/headerCheck_test.go index c1200e3a..e1f68da3 100644 --- a/headerCheck/headerCheck_test.go +++ b/headerCheck/headerCheck_test.go @@ -5,12 +5,12 @@ import ( "errors" "testing" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/data" - "github.com/ElrondNetwork/elrond-go-core/data/block" - "github.com/ElrondNetwork/elrond-sdk-erdgo/headerCheck" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/block" + "github.com/multiversx/mx-sdk-go/headerCheck" + "github.com/multiversx/mx-sdk-go/testsCommon" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/headerCheck/interface.go b/headerCheck/interface.go index 3c38ee35..a82c2b09 100644 --- a/headerCheck/interface.go +++ b/headerCheck/interface.go @@ -3,9 +3,9 @@ package headerCheck import ( "context" - coreData "github.com/ElrondNetwork/elrond-go-core/data" - "github.com/ElrondNetwork/elrond-go/state" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + coreData "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-go/state" + "github.com/multiversx/mx-sdk-go/data" ) // Proxy holds the behaviour needed for header verifier in order to interact with proxy diff --git a/headerCheck/rawHeaderHandler.go b/headerCheck/rawHeaderHandler.go index fce33d24..13638b39 100644 --- a/headerCheck/rawHeaderHandler.go +++ b/headerCheck/rawHeaderHandler.go @@ -3,13 +3,13 @@ package headerCheck import ( "context" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/data" - "github.com/ElrondNetwork/elrond-go-core/data/block" - "github.com/ElrondNetwork/elrond-go-core/marshal" - "github.com/ElrondNetwork/elrond-go/process" - "github.com/ElrondNetwork/elrond-go/state" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/block" + "github.com/multiversx/mx-chain-core-go/marshal" + "github.com/multiversx/mx-chain-go/process" + "github.com/multiversx/mx-chain-go/state" ) type rawHeaderHandler struct { diff --git a/headerCheck/rawHeaderHandler_test.go b/headerCheck/rawHeaderHandler_test.go index 1d7fce84..67e82727 100644 --- a/headerCheck/rawHeaderHandler_test.go +++ b/headerCheck/rawHeaderHandler_test.go @@ -6,11 +6,11 @@ import ( "errors" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/data/block" - "github.com/ElrondNetwork/elrond-go/state" - "github.com/ElrondNetwork/elrond-sdk-erdgo/headerCheck" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/data/block" + "github.com/multiversx/mx-chain-go/state" + "github.com/multiversx/mx-sdk-go/headerCheck" + "github.com/multiversx/mx-sdk-go/testsCommon" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/interactors/interface.go b/interactors/interface.go index e4061968..6c7e4507 100644 --- a/interactors/interface.go +++ b/interactors/interface.go @@ -3,11 +3,11 @@ package interactors import ( "context" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" ) -// Proxy holds the primitive functions that the elrond proxy engine supports & implements +// Proxy holds the primitive functions that the multiversx proxy engine supports & implements // dependency inversion: blockchain package is considered inner business logic, this package is considered "plugin" type Proxy interface { GetNetworkConfig(ctx context.Context) (*data.NetworkConfig, error) diff --git a/interactors/nonceHandlerV1/addressNonceHandler.go b/interactors/nonceHandlerV1/addressNonceHandler.go index 514ca97b..9618594e 100644 --- a/interactors/nonceHandlerV1/addressNonceHandler.go +++ b/interactors/nonceHandlerV1/addressNonceHandler.go @@ -5,10 +5,10 @@ import ( "context" "sync" - "github.com/ElrondNetwork/elrond-go-core/core" - erdgoCore "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" + "github.com/multiversx/mx-chain-core-go/core" + erdgoCore "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/interactors" ) // addressNonceHandler is the handler used for one address. It is able to handle the current diff --git a/interactors/nonceHandlerV1/nonceTransactionsHandler.go b/interactors/nonceHandlerV1/nonceTransactionsHandler.go index 30cda069..84d5c9c8 100644 --- a/interactors/nonceHandlerV1/nonceTransactionsHandler.go +++ b/interactors/nonceHandlerV1/nonceTransactionsHandler.go @@ -6,16 +6,16 @@ import ( "sync" "time" - "github.com/ElrondNetwork/elrond-go-core/core/check" - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" + "github.com/multiversx/mx-chain-core-go/core/check" + logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/interactors" ) const minimumIntervalToResend = time.Second -var log = logger.GetOrCreate("elrond-sdk-erdgo/interactors/nonceHandlerV1") +var log = logger.GetOrCreate("mx-sdk-go/interactors/nonceHandlerV1") // nonceTransactionsHandlerV1 is the handler used for an unlimited number of addresses. // It basically contains a map of addressNonceHandler, creating new entries on the first diff --git a/interactors/nonceHandlerV1/nonceTransactionsHandler_test.go b/interactors/nonceHandlerV1/nonceTransactionsHandler_test.go index b3cebe4c..e9debdb5 100644 --- a/interactors/nonceHandlerV1/nonceTransactionsHandler_test.go +++ b/interactors/nonceHandlerV1/nonceTransactionsHandler_test.go @@ -9,10 +9,10 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/interactors" + "github.com/multiversx/mx-sdk-go/testsCommon" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/interactors/nonceHandlerV2/addressNonceHandler.go b/interactors/nonceHandlerV2/addressNonceHandler.go index 704f6bf1..8f7dd9ca 100644 --- a/interactors/nonceHandlerV2/addressNonceHandler.go +++ b/interactors/nonceHandlerV2/addressNonceHandler.go @@ -5,11 +5,11 @@ import ( "context" "sync" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" - erdgoCore "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + erdgoCore "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/interactors" ) //TODO EN-13182: create a baseAddressNonceHandler component that can remove the duplicate code as much as possible from the diff --git a/interactors/nonceHandlerV2/addressNonceHandlerCreator.go b/interactors/nonceHandlerV2/addressNonceHandlerCreator.go index 91438b87..a6f81b2d 100644 --- a/interactors/nonceHandlerV2/addressNonceHandlerCreator.go +++ b/interactors/nonceHandlerV2/addressNonceHandlerCreator.go @@ -1,8 +1,8 @@ package nonceHandlerV2 import ( - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/interactors" ) // AddressNonceHandlerCreator is used to create addressNonceHandler instances diff --git a/interactors/nonceHandlerV2/addressNonceHandlerCreator_test.go b/interactors/nonceHandlerV2/addressNonceHandlerCreator_test.go index 8228610b..8583a9ad 100644 --- a/interactors/nonceHandlerV2/addressNonceHandlerCreator_test.go +++ b/interactors/nonceHandlerV2/addressNonceHandlerCreator_test.go @@ -5,8 +5,8 @@ import ( "fmt" "testing" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/testsCommon" "github.com/stretchr/testify/require" ) diff --git a/interactors/nonceHandlerV2/addressNonceHandler_test.go b/interactors/nonceHandlerV2/addressNonceHandler_test.go index 75ce71cd..9dd3d82e 100644 --- a/interactors/nonceHandlerV2/addressNonceHandler_test.go +++ b/interactors/nonceHandlerV2/addressNonceHandler_test.go @@ -6,10 +6,10 @@ import ( "errors" "testing" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/interactors" + "github.com/multiversx/mx-sdk-go/testsCommon" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/interactors/nonceHandlerV2/export_test.go b/interactors/nonceHandlerV2/export_test.go index 120cd4ea..5291c776 100644 --- a/interactors/nonceHandlerV2/export_test.go +++ b/interactors/nonceHandlerV2/export_test.go @@ -1,10 +1,10 @@ package nonceHandlerV2 import ( - "github.com/ElrondNetwork/elrond-go-core/core/check" - erdgoCore "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" + "github.com/multiversx/mx-chain-core-go/core/check" + erdgoCore "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/interactors" ) // NewAddressNonceHandlerWithPrivateAccess - diff --git a/interactors/nonceHandlerV2/nonceTransactionsHandler.go b/interactors/nonceHandlerV2/nonceTransactionsHandler.go index e640ad2f..a725864a 100644 --- a/interactors/nonceHandlerV2/nonceTransactionsHandler.go +++ b/interactors/nonceHandlerV2/nonceTransactionsHandler.go @@ -6,16 +6,16 @@ import ( "sync" "time" - "github.com/ElrondNetwork/elrond-go-core/core/check" - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" + "github.com/multiversx/mx-chain-core-go/core/check" + logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/interactors" ) const minimumIntervalToResend = time.Second -var log = logger.GetOrCreate("elrond-sdk-erdgo/interactors/nonceHandlerV2") +var log = logger.GetOrCreate("mx-sdk-go/interactors/nonceHandlerV2") // ArgsNonceTransactionsHandlerV2 is the argument DTO for a nonce transactions handler component type ArgsNonceTransactionsHandlerV2 struct { diff --git a/interactors/nonceHandlerV2/nonceTransactionsHandler_test.go b/interactors/nonceHandlerV2/nonceTransactionsHandler_test.go index f36e4190..6d7b080a 100644 --- a/interactors/nonceHandlerV2/nonceTransactionsHandler_test.go +++ b/interactors/nonceHandlerV2/nonceTransactionsHandler_test.go @@ -8,11 +8,11 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" - testsInteractors "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon/interactors" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/interactors" + "github.com/multiversx/mx-sdk-go/testsCommon" + testsInteractors "github.com/multiversx/mx-sdk-go/testsCommon/interactors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/interactors/nonceHandlerV2/singleTransactionAddressNonceHandler.go b/interactors/nonceHandlerV2/singleTransactionAddressNonceHandler.go index 06513b14..1a34c292 100644 --- a/interactors/nonceHandlerV2/singleTransactionAddressNonceHandler.go +++ b/interactors/nonceHandlerV2/singleTransactionAddressNonceHandler.go @@ -4,11 +4,11 @@ import ( "context" "sync" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" - erdgoCore "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + erdgoCore "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/interactors" ) type singleTransactionAddressNonceHandler struct { diff --git a/interactors/nonceHandlerV2/singleTransactionAddressNonceHandlerCreator.go b/interactors/nonceHandlerV2/singleTransactionAddressNonceHandlerCreator.go index b5f038fb..5f9b7b56 100644 --- a/interactors/nonceHandlerV2/singleTransactionAddressNonceHandlerCreator.go +++ b/interactors/nonceHandlerV2/singleTransactionAddressNonceHandlerCreator.go @@ -1,8 +1,8 @@ package nonceHandlerV2 import ( - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/interactors" ) // SingleTransactionAddressNonceHandlerCreator is used to create singleTransactionAddressNonceHandler instances diff --git a/interactors/nonceHandlerV2/singleTransactionAddressNonceHandlerCreator_test.go b/interactors/nonceHandlerV2/singleTransactionAddressNonceHandlerCreator_test.go index e62a7b4f..36e2f6e6 100644 --- a/interactors/nonceHandlerV2/singleTransactionAddressNonceHandlerCreator_test.go +++ b/interactors/nonceHandlerV2/singleTransactionAddressNonceHandlerCreator_test.go @@ -5,8 +5,8 @@ import ( "fmt" "testing" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/testsCommon" "github.com/stretchr/testify/require" ) diff --git a/interactors/nonceHandlerV2/singleTransactionAddressNonceHandler_test.go b/interactors/nonceHandlerV2/singleTransactionAddressNonceHandler_test.go index 0ca80eec..25fc0510 100644 --- a/interactors/nonceHandlerV2/singleTransactionAddressNonceHandler_test.go +++ b/interactors/nonceHandlerV2/singleTransactionAddressNonceHandler_test.go @@ -5,10 +5,10 @@ import ( "crypto/rand" "testing" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/interactors" + "github.com/multiversx/mx-sdk-go/testsCommon" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/interactors/transaction.go b/interactors/transaction.go index adaebde3..2357227c 100644 --- a/interactors/transaction.go +++ b/interactors/transaction.go @@ -5,12 +5,12 @@ import ( "sync" "time" - "github.com/ElrondNetwork/elrond-go-core/core/check" - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-chain-core-go/core/check" + logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/data" ) -var log = logger.GetOrCreate("elrond-sdk-erdgo/interactors") +var log = logger.GetOrCreate("mx-sdk-go/interactors") const defaultTimeBetweenBunches = time.Second diff --git a/interactors/transaction_test.go b/interactors/transaction_test.go index 48d8c87e..01df7dc8 100644 --- a/interactors/transaction_test.go +++ b/interactors/transaction_test.go @@ -6,9 +6,9 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-sdk-erdgo/builders" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" + "github.com/multiversx/mx-sdk-go/builders" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/testsCommon" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/interactors/wallet.go b/interactors/wallet.go index e0054dde..d559e84a 100644 --- a/interactors/wallet.go +++ b/interactors/wallet.go @@ -16,10 +16,10 @@ import ( "io/ioutil" "os" - "github.com/ElrondNetwork/elrond-go-crypto/signing" - "github.com/ElrondNetwork/elrond-go-crypto/signing/ed25519" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-chain-crypto-go/signing" + "github.com/multiversx/mx-chain-crypto-go/signing/ed25519" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" "github.com/pborman/uuid" "github.com/tyler-smith/go-bip39" "golang.org/x/crypto/scrypt" diff --git a/interactors/wallet_test.go b/interactors/wallet_test.go index 9f01f399..280dee46 100644 --- a/interactors/wallet_test.go +++ b/interactors/wallet_test.go @@ -7,7 +7,7 @@ import ( "os" "testing" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-sdk-go/data" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/libraries/libbls/libbls.go b/libraries/libbls/libbls.go index cc376346..be1323c7 100644 --- a/libraries/libbls/libbls.go +++ b/libraries/libbls/libbls.go @@ -4,9 +4,9 @@ import ( "encoding/hex" "log" - "github.com/ElrondNetwork/elrond-go-crypto/signing" - "github.com/ElrondNetwork/elrond-go-crypto/signing/mcl" - "github.com/ElrondNetwork/elrond-go-crypto/signing/mcl/singlesig" + "github.com/multiversx/mx-chain-crypto-go/signing" + "github.com/multiversx/mx-chain-crypto-go/signing/mcl" + "github.com/multiversx/mx-chain-crypto-go/signing/mcl/singlesig" ) var ( diff --git a/libraries/libbls/libbls.h b/libraries/libbls/libbls.h index ee1f1b37..2ae4d8a9 100644 --- a/libraries/libbls/libbls.h +++ b/libraries/libbls/libbls.h @@ -1,6 +1,6 @@ /* Code generated by cmd/cgo; DO NOT EDIT. */ -/* package github.com/ElrondNetwork/elrond-sdk-erdgo/libraries/libbls */ +/* package github.com/multiversx/mx-sdk-go/libraries/libbls */ #line 1 "cgo-builtin-export-prolog" diff --git a/serde/deserializer_test.go b/serde/deserializer_test.go index e227e56a..df8ebc66 100644 --- a/serde/deserializer_test.go +++ b/serde/deserializer_test.go @@ -5,7 +5,7 @@ import ( "math/big" "testing" - "github.com/ElrondNetwork/elrond-sdk-erdgo/serde/testingMocks" + "github.com/multiversx/mx-sdk-go/serde/testingMocks" "github.com/stretchr/testify/assert" ) diff --git a/storage/mapCacher.go b/storage/mapCacher.go index f56da1d2..d915b0ff 100644 --- a/storage/mapCacher.go +++ b/storage/mapCacher.go @@ -5,10 +5,10 @@ import ( "encoding/gob" "sync" - logger "github.com/ElrondNetwork/elrond-go-logger" + logger "github.com/multiversx/mx-chain-logger-go" ) -var log = logger.GetOrCreate("elrond-sdk-erdgo/storage") +var log = logger.GetOrCreate("mx-sdk-go/storage") // mapCacher is the cacher implementation based on a map type mapCacher struct { diff --git a/testsCommon/cryptoComponentsHolderStub.go b/testsCommon/cryptoComponentsHolderStub.go index f24a7bee..af584ea9 100644 --- a/testsCommon/cryptoComponentsHolderStub.go +++ b/testsCommon/cryptoComponentsHolderStub.go @@ -1,8 +1,8 @@ package testsCommon import ( - crypto "github.com/ElrondNetwork/elrond-go-crypto" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" + crypto "github.com/multiversx/mx-chain-crypto-go" + "github.com/multiversx/mx-sdk-go/core" ) // CryptoComponentsHolderStub - diff --git a/testsCommon/headerSigVerifierStub.go b/testsCommon/headerSigVerifierStub.go index 07c3d8b4..befbb1f0 100644 --- a/testsCommon/headerSigVerifierStub.go +++ b/testsCommon/headerSigVerifierStub.go @@ -1,6 +1,6 @@ package testsCommon -import "github.com/ElrondNetwork/elrond-go-core/data" +import "github.com/multiversx/mx-chain-core-go/data" // HeaderSigVerifierStub - type HeaderSigVerifierStub struct { diff --git a/testsCommon/interactors/addressNonceHandlerCreatorStub.go b/testsCommon/interactors/addressNonceHandlerCreatorStub.go index 0b6edf4c..87a7dc9e 100644 --- a/testsCommon/interactors/addressNonceHandlerCreatorStub.go +++ b/testsCommon/interactors/addressNonceHandlerCreatorStub.go @@ -1,8 +1,8 @@ package interactors import ( - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/interactors" ) // AddressNonceHandlerCreatorStub - diff --git a/testsCommon/nodesCoordinatorStub.go b/testsCommon/nodesCoordinatorStub.go index 732bf447..5e8f6228 100644 --- a/testsCommon/nodesCoordinatorStub.go +++ b/testsCommon/nodesCoordinatorStub.go @@ -1,8 +1,8 @@ package testsCommon import ( - "github.com/ElrondNetwork/elrond-go/sharding/nodesCoordinator" - "github.com/ElrondNetwork/elrond-go/state" + "github.com/multiversx/mx-chain-go/sharding/nodesCoordinator" + "github.com/multiversx/mx-chain-go/state" ) // NodesCoordinatorStub - diff --git a/testsCommon/privateKeyStub.go b/testsCommon/privateKeyStub.go index c5d1aeac..e06aa4f5 100644 --- a/testsCommon/privateKeyStub.go +++ b/testsCommon/privateKeyStub.go @@ -1,6 +1,6 @@ package testsCommon -import "github.com/ElrondNetwork/elrond-go-crypto" +import "github.com/multiversx/mx-chain-crypto-go" // PrivateKeyStub - type PrivateKeyStub struct { diff --git a/testsCommon/proxyStub.go b/testsCommon/proxyStub.go index 3f748cd2..653349a7 100644 --- a/testsCommon/proxyStub.go +++ b/testsCommon/proxyStub.go @@ -3,10 +3,10 @@ package testsCommon import ( "context" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go/state" - erdgoCore "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-go/state" + erdgoCore "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" ) // ProxyStub - diff --git a/testsCommon/publicKeyStub.go b/testsCommon/publicKeyStub.go index f113e8cd..f57e21d8 100644 --- a/testsCommon/publicKeyStub.go +++ b/testsCommon/publicKeyStub.go @@ -1,6 +1,6 @@ package testsCommon -import "github.com/ElrondNetwork/elrond-go-crypto" +import "github.com/multiversx/mx-chain-crypto-go" // PublicKeyStub - type PublicKeyStub struct { diff --git a/testsCommon/rawHeaderHandlerStub.go b/testsCommon/rawHeaderHandlerStub.go index a06eeaf0..98e224bc 100644 --- a/testsCommon/rawHeaderHandlerStub.go +++ b/testsCommon/rawHeaderHandlerStub.go @@ -3,8 +3,8 @@ package testsCommon import ( "context" - "github.com/ElrondNetwork/elrond-go-core/data" - "github.com/ElrondNetwork/elrond-go/state" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-go/state" ) // RawHeaderHandlerStub - diff --git a/testsCommon/signerStub.go b/testsCommon/signerStub.go index 6181a76c..82411238 100644 --- a/testsCommon/signerStub.go +++ b/testsCommon/signerStub.go @@ -1,8 +1,8 @@ package testsCommon import ( - crypto "github.com/ElrondNetwork/elrond-go-crypto" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + crypto "github.com/multiversx/mx-chain-crypto-go" + "github.com/multiversx/mx-sdk-go/data" ) // SignerStub - diff --git a/testsCommon/txBuilderStub.go b/testsCommon/txBuilderStub.go index 1ffeba58..b3400d86 100644 --- a/testsCommon/txBuilderStub.go +++ b/testsCommon/txBuilderStub.go @@ -1,8 +1,8 @@ package testsCommon import ( - erdgoCore "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + erdgoCore "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" ) // TxBuilderStub - diff --git a/testsCommon/txNonceHandlerV1Stub.go b/testsCommon/txNonceHandlerV1Stub.go index 88cc3702..058cbb6b 100644 --- a/testsCommon/txNonceHandlerV1Stub.go +++ b/testsCommon/txNonceHandlerV1Stub.go @@ -3,8 +3,8 @@ package testsCommon import ( "context" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" ) // TxNonceHandlerV1Stub - diff --git a/testsCommon/txNonceHandlerV2Stub.go b/testsCommon/txNonceHandlerV2Stub.go index d6ffbdfa..1b7005ba 100644 --- a/testsCommon/txNonceHandlerV2Stub.go +++ b/testsCommon/txNonceHandlerV2Stub.go @@ -3,8 +3,8 @@ package testsCommon import ( "context" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" ) // TxNonceHandlerV2Stub - diff --git a/workflows/interface.go b/workflows/interface.go index 9b836151..7c9cb749 100644 --- a/workflows/interface.go +++ b/workflows/interface.go @@ -3,8 +3,8 @@ package workflows import ( "context" - erdgoCore "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + erdgoCore "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" ) // TrackableAddressesProvider defines the behavior for a component that can determine if one address is tracked or not diff --git a/workflows/moveBalanceHandler.go b/workflows/moveBalanceHandler.go index 13ecda36..db035da0 100644 --- a/workflows/moveBalanceHandler.go +++ b/workflows/moveBalanceHandler.go @@ -7,11 +7,11 @@ import ( "math/big" "sync" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-crypto/signing" - "github.com/ElrondNetwork/elrond-go-crypto/signing/ed25519" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain/cryptoProvider" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-crypto-go/signing" + "github.com/multiversx/mx-chain-crypto-go/signing/ed25519" + "github.com/multiversx/mx-sdk-go/blockchain/cryptoProvider" + "github.com/multiversx/mx-sdk-go/data" ) var ( diff --git a/workflows/walletsTracker.go b/workflows/walletsTracker.go index ff4006a4..7595d5ff 100644 --- a/workflows/walletsTracker.go +++ b/workflows/walletsTracker.go @@ -7,12 +7,12 @@ import ( "sync" "time" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/data" ) -var log = logger.GetOrCreate("elrond-sdk-erdgo/workflows") +var log = logger.GetOrCreate("mx-sdk-go/workflows") // WalletTrackerArgs is the argument DTO for the NewWalletTracker constructor function type WalletTrackerArgs struct { From 191728a66f2e63039cdbbbe19f83eae7d4e6b877 Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Thu, 26 Jan 2023 17:11:09 +0200 Subject: [PATCH 18/21] fix cryptocom fetcher and tests --- aggregator/fetchers/cryptocom.go | 11 ++-- aggregator/fetchers/fetchers_test.go | 74 +++++++++++++++++++++--- aggregator/fetchers/maiar.go | 2 +- examples/examplesPriceAggregator/main.go | 2 +- 4 files changed, 76 insertions(+), 13 deletions(-) diff --git a/aggregator/fetchers/cryptocom.go b/aggregator/fetchers/cryptocom.go index 1b0051e9..9742800f 100644 --- a/aggregator/fetchers/cryptocom.go +++ b/aggregator/fetchers/cryptocom.go @@ -16,11 +16,11 @@ type cryptocomPriceRequest struct { } type cryptocomData struct { - Data cryptocomPair `json:"data"` + Data []cryptocomPair `json:"data"` } type cryptocomPair struct { - Price float64 `json:"a"` + Price string `json:"a"` } type cryptocom struct { @@ -41,10 +41,13 @@ func (c *cryptocom) FetchPrice(ctx context.Context, base, quote string) (float64 if err != nil { return 0, err } - if cpr.Result.Data.Price <= 0 { + if len(cpr.Result.Data) == 0 { return 0, errInvalidResponseData } - return cpr.Result.Data.Price, nil + if cpr.Result.Data[0].Price == "" { + return 0, errInvalidResponseData + } + return StrToPositiveFloat64(cpr.Result.Data[0].Price) } // Name returns the name diff --git a/aggregator/fetchers/fetchers_test.go b/aggregator/fetchers/fetchers_test.go index e6ee2f1c..ab5d3eae 100644 --- a/aggregator/fetchers/fetchers_test.go +++ b/aggregator/fetchers/fetchers_test.go @@ -10,14 +10,24 @@ import ( "time" "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-crypto-go/signing" + "github.com/multiversx/mx-chain-crypto-go/signing/ed25519" "github.com/multiversx/mx-sdk-go/aggregator" "github.com/multiversx/mx-sdk-go/aggregator/mock" + "github.com/multiversx/mx-sdk-go/authentication" + "github.com/multiversx/mx-sdk-go/blockchain" + "github.com/multiversx/mx-sdk-go/blockchain/cryptoProvider" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/examples" + "github.com/multiversx/mx-sdk-go/interactors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) var errShouldSkipTest = errors.New("should skip test") +const networkAddress = "https://testnet-gateway.multiversx.com" + func createMockMap() map[string]MaiarTokensPair { return map[string]MaiarTokensPair{ "ETH-USD": { @@ -35,20 +45,70 @@ func createMockMap() map[string]MaiarTokensPair { } } +func createAuthClient() (authentication.AuthClient, error) { + w := interactors.NewWallet() + privateKeyBytes, err := w.LoadPrivateKeyFromPemData([]byte(examples.AlicePemContents)) + if err != nil { + return nil, err + } + + argsProxy := blockchain.ArgsProxy{ + ProxyURL: networkAddress, + SameScState: false, + ShouldBeSynced: false, + FinalityCheck: false, + AllowedDeltaToFinal: 1, + CacheExpirationTime: time.Second, + EntityType: core.Proxy, + } + + proxy, err := blockchain.NewProxy(argsProxy) + if err != nil { + return nil, err + } + + keyGen := signing.NewKeyGenerator(ed25519.NewEd25519()) + holder, _ := cryptoProvider.NewCryptoComponentsHolder(keyGen, privateKeyBytes) + args := authentication.ArgsNativeAuthClient{ + Signer: cryptoProvider.NewSigner(), + ExtraInfo: nil, + Proxy: proxy, + CryptoComponentsHolder: holder, + TokenExpiryInSeconds: 60 * 60 * 24, + Host: "oracle", + } + + authClient, err := authentication.NewNativeAuthClient(args) + if err != nil { + return nil, err + } + + return authClient, nil +} + func Test_FunctionalTesting(t *testing.T) { t.Parallel() + responseGetter, err := aggregator.NewHttpResponseGetter() + require.Nil(t, err) + + authClient, err := createAuthClient() + require.Nil(t, err) + + graphqlGetter, err := aggregator.NewGraphqlResponseGetter(authClient) + require.Nil(t, err) + for f := range ImplementedFetchers { fetcherName := f t.Run("Test_FunctionalTesting_"+fetcherName, func(t *testing.T) { t.Skip("this test should be run only when doing debugging work on the component") t.Parallel() - fetcher, _ := NewPriceFetcher(fetcherName, &mock.HttpResponseGetterStub{}, &mock.GraphqlResponseGetterStub{}, createMockMap()) + fetcher, _ := NewPriceFetcher(fetcherName, responseGetter, graphqlGetter, createMockMap()) ethTicker := "ETH" fetcher.AddPair(ethTicker, quoteUSDFiat) - price, err := fetcher.FetchPrice(context.Background(), ethTicker, quoteUSDFiat) - require.Nil(t, err) + price, fetchErr := fetcher.FetchPrice(context.Background(), ethTicker, quoteUSDFiat) + require.Nil(t, fetchErr) fmt.Printf("price between %s and %s is: %v from %s\n", ethTicker, quoteUSDFiat, price, fetcherName) require.True(t, price > 0) }) @@ -319,10 +379,10 @@ func getFuncGetCalled(name, returnPrice, pair string, returnErr error) func(ctx case CryptocomName: return func(ctx context.Context, url string, response interface{}) error { cast, _ := response.(*cryptocomPriceRequest) - var err error - cast.Result.Data.Price, err = strconv.ParseFloat(returnPrice, 64) - if err != nil { - return errShouldSkipTest + cast.Result.Data = []cryptocomPair{ + { + Price: returnPrice, + }, } return returnErr } diff --git a/aggregator/fetchers/maiar.go b/aggregator/fetchers/maiar.go index a8e92c27..ecdef8e2 100644 --- a/aggregator/fetchers/maiar.go +++ b/aggregator/fetchers/maiar.go @@ -11,7 +11,7 @@ import ( const ( // TODO EN-13146: extract this urls constants in a file - dataApiUrl = "https://tools.elrond.com/data-api/graphql" + dataApiUrl = "https://tools.multiversx.com/data-api/graphql" query = "query MaiarPriceUrl($base: String!, $quote: String!) { trading { pair(first_token: $base, second_token: $quote) { price { last time } } } }" ) diff --git a/examples/examplesPriceAggregator/main.go b/examples/examplesPriceAggregator/main.go index dec18cff..0bfee2ce 100644 --- a/examples/examplesPriceAggregator/main.go +++ b/examples/examplesPriceAggregator/main.go @@ -218,7 +218,7 @@ func createAuthClient() (authentication.AuthClient, error) { FinalityCheck: false, AllowedDeltaToFinal: 1, CacheExpirationTime: time.Second, - EntityType: core.RestAPIEntityType("Proxy"), + EntityType: core.Proxy, } proxy, err := blockchain.NewProxy(argsProxy) From cb41e31c71c3dd716232e64dd87d4d6580005b5d Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Fri, 27 Jan 2023 12:16:23 +0200 Subject: [PATCH 19/21] maiar fetcher to xExchange --- aggregator/fetchers/constants.go | 22 +++++++------- aggregator/fetchers/errors.go | 4 +-- aggregator/fetchers/factory.go | 24 +++++++-------- aggregator/fetchers/factory_test.go | 12 ++++---- aggregator/fetchers/fetchers_test.go | 14 ++++----- .../fetchers/{maiar.go => xexchange.go} | 30 +++++++++---------- examples/examplesPriceAggregator/main.go | 6 ++-- 7 files changed, 56 insertions(+), 56 deletions(-) rename aggregator/fetchers/{maiar.go => xexchange.go} (67%) diff --git a/aggregator/fetchers/constants.go b/aggregator/fetchers/constants.go index 39801978..b64c4f5c 100644 --- a/aggregator/fetchers/constants.go +++ b/aggregator/fetchers/constants.go @@ -4,24 +4,24 @@ const ( quoteUSDFiat = "USD" quoteUSDT = "USDT" - // BinanceName defines the Binance exchange + // BinanceName defines the Binance exchange name BinanceName = "Binance" - // BitfinexName defines the Bitfinex exchange + // BitfinexName defines the Bitfinex exchange name BitfinexName = "Bitfinex" - // CryptocomName defines the crypto.com exchange + // CryptocomName defines the crypto.com exchange name CryptocomName = "Crypto.com" - // GeminiName defines the Gemini exchange + // GeminiName defines the Gemini exchange name GeminiName = "Gemini" - // HitbtcName defines the HitBTC exchange + // HitbtcName defines the HitBTC exchange name HitbtcName = "HitBTC" - // HuobiName defines the Huobi exchange + // HuobiName defines the Huobi exchange name HuobiName = "Huobi" - // KrakenName defines the Kraken exchange + // KrakenName defines the Kraken exchange name KrakenName = "Kraken" - // OkexName defines the Okex exchange + // OkexName defines the Okex exchange name OkexName = "Okex" - // MaiarName defines the Maiar exchange - MaiarName = "Maiar" + // XExchangeName defines the XExchange name + XExchangeName = "XExchange" ) // ImplementedFetchers is the map of all implemented exchange fetchers @@ -34,5 +34,5 @@ var ImplementedFetchers = map[string]struct{}{ HuobiName: {}, KrakenName: {}, OkexName: {}, - MaiarName: {}, + XExchangeName: {}, } diff --git a/aggregator/fetchers/errors.go b/aggregator/fetchers/errors.go index 04d0ad01..27fc3322 100644 --- a/aggregator/fetchers/errors.go +++ b/aggregator/fetchers/errors.go @@ -7,7 +7,7 @@ var ( errInvalidFetcherName = errors.New("invalid fetcher name") errNilResponseGetter = errors.New("nil response getter") errNilGraphqlGetter = errors.New("nil graphql getter") - errNilMaiarTokensMap = errors.New("nil maiar tokens map") + errNilXExchangeTokensMap = errors.New("nil xexchange tokens map") errInvalidPair = errors.New("invalid pair") - errInvalidGraphqlResponse = errors.New("invalid graphql reponse") + errInvalidGraphqlResponse = errors.New("invalid graphql response") ) diff --git a/aggregator/fetchers/factory.go b/aggregator/fetchers/factory.go index 4fd8adcc..29d1bdc5 100644 --- a/aggregator/fetchers/factory.go +++ b/aggregator/fetchers/factory.go @@ -6,28 +6,28 @@ import ( "github.com/multiversx/mx-sdk-go/aggregator" ) -// MaiarTokensPair defines a base-quote pair of ids used by maiar exchange -type MaiarTokensPair struct { +// XExchangeTokensPair defines a base-quote pair of ids used by XExchange +type XExchangeTokensPair struct { Base string Quote string } // NewPriceFetcher returns a new price fetcher of the type provided -func NewPriceFetcher(fetcherName string, responseGetter aggregator.ResponseGetter, graphqlGetter aggregator.GraphqlGetter, maiarTokensMap map[string]MaiarTokensPair) (aggregator.PriceFetcher, error) { +func NewPriceFetcher(fetcherName string, responseGetter aggregator.ResponseGetter, graphqlGetter aggregator.GraphqlGetter, xExchangeTokensMap map[string]XExchangeTokensPair) (aggregator.PriceFetcher, error) { if responseGetter == nil { return nil, errNilResponseGetter } if graphqlGetter == nil { return nil, errNilGraphqlGetter } - if maiarTokensMap == nil && fetcherName == MaiarName { - return nil, errNilMaiarTokensMap + if xExchangeTokensMap == nil && fetcherName == XExchangeName { + return nil, errNilXExchangeTokensMap } - return createFetcher(fetcherName, responseGetter, graphqlGetter, maiarTokensMap) + return createFetcher(fetcherName, responseGetter, graphqlGetter, xExchangeTokensMap) } -func createFetcher(fetcherName string, responseGetter aggregator.ResponseGetter, graphqlGetter aggregator.GraphqlGetter, maiarTokensMap map[string]MaiarTokensPair) (aggregator.PriceFetcher, error) { +func createFetcher(fetcherName string, responseGetter aggregator.ResponseGetter, graphqlGetter aggregator.GraphqlGetter, xExchangeTokensMap map[string]XExchangeTokensPair) (aggregator.PriceFetcher, error) { switch fetcherName { case BinanceName: return &binance{ @@ -69,11 +69,11 @@ func createFetcher(fetcherName string, responseGetter aggregator.ResponseGetter, ResponseGetter: responseGetter, baseFetcher: newBaseFetcher(), }, nil - case MaiarName: - return &maiar{ - GraphqlGetter: graphqlGetter, - baseFetcher: newBaseFetcher(), - maiarTokensMap: maiarTokensMap, + case XExchangeName: + return &xExchange{ + GraphqlGetter: graphqlGetter, + baseFetcher: newBaseFetcher(), + xExchangeTokensMap: xExchangeTokensMap, }, nil } return nil, fmt.Errorf("%w, fetcherName %s", errInvalidFetcherName, fetcherName) diff --git a/aggregator/fetchers/factory_test.go b/aggregator/fetchers/factory_test.go index 14a58b61..59b98393 100644 --- a/aggregator/fetchers/factory_test.go +++ b/aggregator/fetchers/factory_test.go @@ -32,16 +32,16 @@ func TestNewPriceFetcher(t *testing.T) { t.Run("nil graphqlGetter should error", func(t *testing.T) { t.Parallel() - pf, err := NewPriceFetcher(MaiarName, &mock.HttpResponseGetterStub{}, nil, nil) + pf, err := NewPriceFetcher(XExchangeName, &mock.HttpResponseGetterStub{}, nil, nil) assert.Nil(t, pf) assert.True(t, errors.Is(err, errNilGraphqlGetter)) }) - t.Run("nil map for maiar should error", func(t *testing.T) { + t.Run("nil map for xExchange should error", func(t *testing.T) { t.Parallel() - pf, err := NewPriceFetcher(MaiarName, &mock.HttpResponseGetterStub{}, &mock.GraphqlResponseGetterStub{}, nil) + pf, err := NewPriceFetcher(XExchangeName, &mock.HttpResponseGetterStub{}, &mock.GraphqlResponseGetterStub{}, nil) assert.Nil(t, pf) - assert.True(t, errors.Is(err, errNilMaiarTokensMap)) + assert.True(t, errors.Is(err, errNilXExchangeTokensMap)) }) t.Run("should work", func(t *testing.T) { t.Parallel() @@ -70,8 +70,8 @@ func TestNewPriceFetcher(t *testing.T) { pf, err = NewPriceFetcher(OkexName, &mock.HttpResponseGetterStub{}, &mock.GraphqlResponseGetterStub{}, createMockMap()) assert.Equal(t, "*fetchers.okex", fmt.Sprintf("%T", pf)) assert.Nil(t, err) - pf, err = NewPriceFetcher(MaiarName, &mock.HttpResponseGetterStub{}, &mock.GraphqlResponseGetterStub{}, createMockMap()) - assert.Equal(t, "*fetchers.maiar", fmt.Sprintf("%T", pf)) + pf, err = NewPriceFetcher(XExchangeName, &mock.HttpResponseGetterStub{}, &mock.GraphqlResponseGetterStub{}, createMockMap()) + assert.Equal(t, "*fetchers.xExchange", fmt.Sprintf("%T", pf)) assert.Nil(t, err) }) } diff --git a/aggregator/fetchers/fetchers_test.go b/aggregator/fetchers/fetchers_test.go index ab5d3eae..abc7e5f5 100644 --- a/aggregator/fetchers/fetchers_test.go +++ b/aggregator/fetchers/fetchers_test.go @@ -28,8 +28,8 @@ var errShouldSkipTest = errors.New("should skip test") const networkAddress = "https://testnet-gateway.multiversx.com" -func createMockMap() map[string]MaiarTokensPair { - return map[string]MaiarTokensPair{ +func createMockMap() map[string]XExchangeTokensPair { + return map[string]XExchangeTokensPair{ "ETH-USD": { Base: "WEGLD-bd4d79", // for tests only until we have an ETH id Quote: "USDC-c76f1f", @@ -214,10 +214,10 @@ func Test_FetchPriceErrors(t *testing.T) { require.Equal(t, float64(0), price) require.IsType(t, err, &strconv.NumError{}) }) - t.Run("maiar: missing key from map should error "+fetcherName, func(t *testing.T) { + t.Run("xExchange: missing key from map should error "+fetcherName, func(t *testing.T) { t.Parallel() - if fetcherName != MaiarName { + if fetcherName != XExchangeName { return } @@ -239,10 +239,10 @@ func Test_FetchPriceErrors(t *testing.T) { assert.Equal(t, errInvalidPair, err) require.Equal(t, float64(0), price) }) - t.Run("maiar: invalid graphql response should error "+fetcherName, func(t *testing.T) { + t.Run("xExchange: invalid graphql response should error "+fetcherName, func(t *testing.T) { t.Parallel() - if fetcherName != MaiarName { + if fetcherName != XExchangeName { return } @@ -338,7 +338,7 @@ func Test_FetchPriceErrors(t *testing.T) { func getFuncQueryCalled(name, returnPrice string, returnErr error) func(ctx context.Context, url string, query string, variables string) ([]byte, error) { switch name { - case MaiarName: + case XExchangeName: return func(ctx context.Context, url string, query string, variables string) ([]byte, error) { priceArray := make([]priceResponse, 0) var p priceResponse diff --git a/aggregator/fetchers/maiar.go b/aggregator/fetchers/xexchange.go similarity index 67% rename from aggregator/fetchers/maiar.go rename to aggregator/fetchers/xexchange.go index ecdef8e2..15b02e69 100644 --- a/aggregator/fetchers/maiar.go +++ b/aggregator/fetchers/xexchange.go @@ -35,32 +35,32 @@ type graphqlResponse struct { } `json:"data"` } -type maiar struct { +type xExchange struct { aggregator.GraphqlGetter baseFetcher - maiarTokensMap map[string]MaiarTokensPair + xExchangeTokensMap map[string]XExchangeTokensPair } // FetchPrice will fetch the price using the http client -func (m *maiar) FetchPrice(ctx context.Context, base string, quote string) (float64, error) { - if !m.hasPair(base, quote) { +func (x *xExchange) FetchPrice(ctx context.Context, base string, quote string) (float64, error) { + if !x.hasPair(base, quote) { return 0, aggregator.ErrPairNotSupported } - maiarTokensPair, ok := m.fetchMaiarTokensPair(base, quote) + xExchangeTokensPair, ok := x.fetchXExchangeTokensPair(base, quote) if !ok { return 0, errInvalidPair } - variables, err := json.Marshal(variables{ - BasePrice: maiarTokensPair.Base, - QuotePrice: maiarTokensPair.Quote, + vars, err := json.Marshal(variables{ + BasePrice: xExchangeTokensPair.Base, + QuotePrice: xExchangeTokensPair.Quote, }) if err != nil { return 0, err } - resp, err := m.GraphqlGetter.Query(ctx, dataApiUrl, query, string(variables)) + resp, err := x.GraphqlGetter.Query(ctx, dataApiUrl, query, string(vars)) if err != nil { return 0, err } @@ -79,18 +79,18 @@ func (m *maiar) FetchPrice(ctx context.Context, base string, quote string) (floa return price, nil } -func (m *maiar) fetchMaiarTokensPair(base, quote string) (MaiarTokensPair, bool) { +func (x *xExchange) fetchXExchangeTokensPair(base, quote string) (XExchangeTokensPair, bool) { pair := fmt.Sprintf("%s-%s", base, quote) - mtp, ok := m.maiarTokensMap[pair] + mtp, ok := x.xExchangeTokensMap[pair] return mtp, ok } // Name returns the name -func (m *maiar) Name() string { - return MaiarName +func (x *xExchange) Name() string { + return XExchangeName } // IsInterfaceNil returns true if there is no value under the interface -func (m *maiar) IsInterfaceNil() bool { - return m == nil +func (x *xExchange) IsInterfaceNil() bool { + return x == nil } diff --git a/examples/examplesPriceAggregator/main.go b/examples/examplesPriceAggregator/main.go index 0bfee2ce..60ce2b79 100644 --- a/examples/examplesPriceAggregator/main.go +++ b/examples/examplesPriceAggregator/main.go @@ -157,8 +157,8 @@ func addPairToFetchers(pair *aggregator.ArgsPair, priceFetchers []aggregator.Pri } } -func createMaiarMap() map[string]fetchers.MaiarTokensPair { - return map[string]fetchers.MaiarTokensPair{ +func createXExchangeMap() map[string]fetchers.XExchangeTokensPair { + return map[string]fetchers.XExchangeTokensPair{ "ETH-USD": { // for tests only until we have an ETH id // the price will be dropped as it is extreme compared to real price @@ -183,7 +183,7 @@ func createPriceFetchers() ([]aggregator.PriceFetcher, error) { } for exchangeName := range exchanges { - priceFetcher, err := fetchers.NewPriceFetcher(exchangeName, httpResponseGetter, graphqlResponseGetter, createMaiarMap()) + priceFetcher, err := fetchers.NewPriceFetcher(exchangeName, httpResponseGetter, graphqlResponseGetter, createXExchangeMap()) if err != nil { return nil, err } From bb2fc4ebf6e8823a642a684c58270113931734c4 Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Fri, 27 Jan 2023 12:28:17 +0200 Subject: [PATCH 20/21] added query todo --- aggregator/fetchers/xexchange.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aggregator/fetchers/xexchange.go b/aggregator/fetchers/xexchange.go index 15b02e69..89818d81 100644 --- a/aggregator/fetchers/xexchange.go +++ b/aggregator/fetchers/xexchange.go @@ -12,7 +12,8 @@ import ( const ( // TODO EN-13146: extract this urls constants in a file dataApiUrl = "https://tools.multiversx.com/data-api/graphql" - query = "query MaiarPriceUrl($base: String!, $quote: String!) { trading { pair(first_token: $base, second_token: $quote) { price { last time } } } }" + // TODO: update the query after data-api rebranding + query = "query MaiarPriceUrl($base: String!, $quote: String!) { trading { pair(first_token: $base, second_token: $quote) { price { last time } } } }" ) type variables struct { From 915169bf68dd116451eb4c2bf710c7c609b702b2 Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Fri, 3 Feb 2023 13:14:31 +0200 Subject: [PATCH 21/21] fixes after merge --- aggregator/fetchers/fetchers_test.go | 8 ++-- aggregator/graphqlResponseGetter_test.go | 2 +- authentication/native/client_test.go | 2 +- authentication/native/mock/authServerStub.go | 2 +- .../native/mock/authTokenHandlerStub.go | 2 +- authentication/native/semiIntegrated_test.go | 24 +++++------ authentication/native/server.go | 18 ++++---- authentication/native/server_test.go | 16 +++---- authentication/native/tokenHandler.go | 2 +- authentication/native/tokenHandler_test.go | 4 +- blockchain/cryptoProvider/signer.go | 2 +- blockchain/interface.go | 1 + blockchain/proxy.go | 1 + blockchain/proxy_test.go | 1 + builders/txBuilder.go | 3 +- cmd/cli/main.go | 36 ++++++++-------- data/guardian.go | 2 +- disabled/enableEpochsHandler.go | 5 --- examples/examplesPriceAggregator/main.go | 2 +- go.mod | 16 ++++--- go.sum | 43 +++++++++++-------- headerCheck/interface.go | 4 +- libraries/libbls/main.go | 4 +- testsCommon/privateKeyStub.go | 2 +- testsCommon/publicKeyStub.go | 2 +- txcheck/sigcheck.go | 12 +++--- txcheck/sigcheck_test.go | 24 +++++------ 27 files changed, 127 insertions(+), 113 deletions(-) diff --git a/aggregator/fetchers/fetchers_test.go b/aggregator/fetchers/fetchers_test.go index abc7e5f5..b7a508e3 100644 --- a/aggregator/fetchers/fetchers_test.go +++ b/aggregator/fetchers/fetchers_test.go @@ -15,6 +15,7 @@ import ( "github.com/multiversx/mx-sdk-go/aggregator" "github.com/multiversx/mx-sdk-go/aggregator/mock" "github.com/multiversx/mx-sdk-go/authentication" + "github.com/multiversx/mx-sdk-go/authentication/native" "github.com/multiversx/mx-sdk-go/blockchain" "github.com/multiversx/mx-sdk-go/blockchain/cryptoProvider" "github.com/multiversx/mx-sdk-go/core" @@ -69,16 +70,17 @@ func createAuthClient() (authentication.AuthClient, error) { keyGen := signing.NewKeyGenerator(ed25519.NewEd25519()) holder, _ := cryptoProvider.NewCryptoComponentsHolder(keyGen, privateKeyBytes) - args := authentication.ArgsNativeAuthClient{ + args := native.ArgsNativeAuthClient{ Signer: cryptoProvider.NewSigner(), - ExtraInfo: nil, + ExtraInfo: struct{}{}, Proxy: proxy, CryptoComponentsHolder: holder, TokenExpiryInSeconds: 60 * 60 * 24, Host: "oracle", + TokenHandler: native.NewAuthTokenHandler(), } - authClient, err := authentication.NewNativeAuthClient(args) + authClient, err := native.NewNativeAuthClient(args) if err != nil { return nil, err } diff --git a/aggregator/graphqlResponseGetter_test.go b/aggregator/graphqlResponseGetter_test.go index 5952e535..96ea8428 100644 --- a/aggregator/graphqlResponseGetter_test.go +++ b/aggregator/graphqlResponseGetter_test.go @@ -6,7 +6,7 @@ import ( "net/url" "testing" - "github.com/multiversx/mx-sdk-go/authentication/mock" + "github.com/multiversx/mx-sdk-go/authentication/native/mock" "github.com/stretchr/testify/require" ) diff --git a/authentication/native/client_test.go b/authentication/native/client_test.go index 97118a9f..24dd6cbd 100644 --- a/authentication/native/client_test.go +++ b/authentication/native/client_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/multiversx/mx-chain-crypto-go" + crypto "github.com/multiversx/mx-chain-crypto-go" "github.com/multiversx/mx-sdk-go/authentication" "github.com/multiversx/mx-sdk-go/authentication/native/mock" "github.com/multiversx/mx-sdk-go/data" diff --git a/authentication/native/mock/authServerStub.go b/authentication/native/mock/authServerStub.go index ac0cee22..75409157 100644 --- a/authentication/native/mock/authServerStub.go +++ b/authentication/native/mock/authServerStub.go @@ -1,6 +1,6 @@ package mock -import "github.com/ElrondNetwork/elrond-sdk-erdgo/authentication" +import "github.com/multiversx/mx-sdk-go/authentication" // AuthServerStub - type AuthServerStub struct { diff --git a/authentication/native/mock/authTokenHandlerStub.go b/authentication/native/mock/authTokenHandlerStub.go index 06f10545..4c7ec9be 100644 --- a/authentication/native/mock/authTokenHandlerStub.go +++ b/authentication/native/mock/authTokenHandlerStub.go @@ -1,6 +1,6 @@ package mock -import "github.com/ElrondNetwork/elrond-sdk-erdgo/authentication" +import "github.com/multiversx/mx-sdk-go/authentication" // AuthTokenHandlerStub - type AuthTokenHandlerStub struct { diff --git a/authentication/native/semiIntegrated_test.go b/authentication/native/semiIntegrated_test.go index cb8861da..5a9587e9 100644 --- a/authentication/native/semiIntegrated_test.go +++ b/authentication/native/semiIntegrated_test.go @@ -5,21 +5,21 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/core/pubkeyConverter" - crypto "github.com/ElrondNetwork/elrond-go-crypto" - "github.com/ElrondNetwork/elrond-go-crypto/signing/ed25519" - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-sdk-erdgo/authentication" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain/cryptoProvider" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/examples" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" - "github.com/ElrondNetwork/elrond-sdk-erdgo/workflows" + "github.com/multiversx/mx-chain-core-go/core/pubkeyConverter" + "github.com/multiversx/mx-chain-crypto-go/signing" + "github.com/multiversx/mx-chain-crypto-go/signing/ed25519" + logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/authentication" + "github.com/multiversx/mx-sdk-go/blockchain/cryptoProvider" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/examples" + "github.com/multiversx/mx-sdk-go/interactors" + "github.com/multiversx/mx-sdk-go/testsCommon" + "github.com/multiversx/mx-sdk-go/workflows" "github.com/stretchr/testify/require" ) -var keyGen = crypto.NewKeyGenerator(ed25519.NewEd25519()) +var keyGen = signing.NewKeyGenerator(ed25519.NewEd25519()) func TestNativeserver_ClientServer(t *testing.T) { diff --git a/authentication/native/server.go b/authentication/native/server.go index 889073d8..576b6594 100644 --- a/authentication/native/server.go +++ b/authentication/native/server.go @@ -4,12 +4,12 @@ import ( "context" "time" - goCore "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" - crypto "github.com/ElrondNetwork/elrond-go-crypto" - "github.com/ElrondNetwork/elrond-sdk-erdgo/authentication" - "github.com/ElrondNetwork/elrond-sdk-erdgo/builders" - "github.com/ElrondNetwork/elrond-sdk-erdgo/workflows" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + crypto "github.com/multiversx/mx-chain-crypto-go" + "github.com/multiversx/mx-sdk-go/authentication" + "github.com/multiversx/mx-sdk-go/builders" + "github.com/multiversx/mx-sdk-go/workflows" ) // ArgsNativeAuthServer is the DTO used in the native auth server constructor @@ -17,7 +17,7 @@ type ArgsNativeAuthServer struct { Proxy workflows.ProxyHandler TokenHandler authentication.AuthTokenHandler Signer builders.Signer - PubKeyConverter goCore.PubkeyConverter + PubKeyConverter core.PubkeyConverter KeyGenerator crypto.KeyGenerator } @@ -26,7 +26,7 @@ type authServer struct { tokenHandler authentication.AuthTokenHandler signer builders.Signer keyGenerator crypto.KeyGenerator - pubKeyConverter goCore.PubkeyConverter + pubKeyConverter core.PubkeyConverter getTimeHandler func() time.Time } @@ -48,7 +48,7 @@ func NewNativeAuthServer(args ArgsNativeAuthServer) (*authServer, error) { } if check.IfNil(args.PubKeyConverter) { - return nil, goCore.ErrNilPubkeyConverter + return nil, core.ErrNilPubkeyConverter } if check.IfNil(args.TokenHandler) { diff --git a/authentication/native/server_test.go b/authentication/native/server_test.go index 21cef0bf..a885ed77 100644 --- a/authentication/native/server_test.go +++ b/authentication/native/server_test.go @@ -6,14 +6,14 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/core" - crypto "github.com/ElrondNetwork/elrond-go-crypto" - genesisMock "github.com/ElrondNetwork/elrond-go/genesis/mock" - "github.com/ElrondNetwork/elrond-sdk-erdgo/authentication" - "github.com/ElrondNetwork/elrond-sdk-erdgo/authentication/native/mock" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/testsCommon" - "github.com/ElrondNetwork/elrond-sdk-erdgo/workflows" + "github.com/multiversx/mx-chain-core-go/core" + crypto "github.com/multiversx/mx-chain-crypto-go" + genesisMock "github.com/multiversx/mx-chain-go/genesis/mock" + "github.com/multiversx/mx-sdk-go/authentication" + "github.com/multiversx/mx-sdk-go/authentication/native/mock" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/testsCommon" + "github.com/multiversx/mx-sdk-go/workflows" "github.com/stretchr/testify/require" ) diff --git a/authentication/native/tokenHandler.go b/authentication/native/tokenHandler.go index 0d9790dc..fa7f7600 100644 --- a/authentication/native/tokenHandler.go +++ b/authentication/native/tokenHandler.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/ElrondNetwork/elrond-sdk-erdgo/authentication" + "github.com/multiversx/mx-sdk-go/authentication" ) // authTokenHandler will handle encoding and decoding native authentication tokens diff --git a/authentication/native/tokenHandler_test.go b/authentication/native/tokenHandler_test.go index c7524fa6..6370f91a 100644 --- a/authentication/native/tokenHandler_test.go +++ b/authentication/native/tokenHandler_test.go @@ -3,8 +3,8 @@ package native import ( "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-sdk-erdgo/authentication" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-sdk-go/authentication" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/blockchain/cryptoProvider/signer.go b/blockchain/cryptoProvider/signer.go index 02e93d40..3692c3dc 100644 --- a/blockchain/cryptoProvider/signer.go +++ b/blockchain/cryptoProvider/signer.go @@ -5,7 +5,7 @@ import ( "strconv" "github.com/multiversx/mx-chain-core-go/hashing/keccak" - "github.com/multiversx/mx-chain-crypto-go" + crypto "github.com/multiversx/mx-chain-crypto-go" "github.com/multiversx/mx-chain-crypto-go/signing/ed25519/singlesig" logger "github.com/multiversx/mx-chain-logger-go" "github.com/multiversx/mx-sdk-go/data" diff --git a/blockchain/interface.go b/blockchain/interface.go index 107ba4bd..c8fb4c05 100644 --- a/blockchain/interface.go +++ b/blockchain/interface.go @@ -3,6 +3,7 @@ package blockchain import ( "context" + "github.com/multiversx/mx-chain-core-go/data/api" "github.com/multiversx/mx-sdk-go/core" "github.com/multiversx/mx-sdk-go/data" ) diff --git a/blockchain/proxy.go b/blockchain/proxy.go index 2d1520c9..95399d14 100644 --- a/blockchain/proxy.go +++ b/blockchain/proxy.go @@ -11,6 +11,7 @@ import ( "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/data/api" "github.com/multiversx/mx-chain-go/state" "github.com/multiversx/mx-sdk-go/blockchain/factory" erdgoCore "github.com/multiversx/mx-sdk-go/core" diff --git a/blockchain/proxy_test.go b/blockchain/proxy_test.go index 8829b655..4e8ae7d0 100644 --- a/blockchain/proxy_test.go +++ b/blockchain/proxy_test.go @@ -15,6 +15,7 @@ import ( "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/data/api" "github.com/multiversx/mx-chain-go/config" "github.com/multiversx/mx-chain-go/state" erdgoCore "github.com/multiversx/mx-sdk-go/core" diff --git a/builders/txBuilder.go b/builders/txBuilder.go index a814676c..500ac1e8 100644 --- a/builders/txBuilder.go +++ b/builders/txBuilder.go @@ -9,8 +9,9 @@ import ( "github.com/multiversx/mx-chain-core-go/core/check" "github.com/multiversx/mx-chain-core-go/data/transaction" "github.com/multiversx/mx-chain-core-go/hashing/blake2b" - "github.com/multiversx/mx-chain-core-go/marshal" "github.com/multiversx/mx-chain-core-go/hashing/keccak" + "github.com/multiversx/mx-chain-core-go/marshal" + logger "github.com/multiversx/mx-chain-logger-go" "github.com/multiversx/mx-sdk-go/core" "github.com/multiversx/mx-sdk-go/data" ) diff --git a/cmd/cli/main.go b/cmd/cli/main.go index 95c0f983..772f0c8a 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -7,17 +7,17 @@ import ( "os" "time" - crypto "github.com/ElrondNetwork/elrond-go-crypto" - "github.com/ElrondNetwork/elrond-go-crypto/signing/ed25519" - logger "github.com/ElrondNetwork/elrond-go-logger" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain/cryptoProvider" - "github.com/ElrondNetwork/elrond-sdk-erdgo/builders" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/examples" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" - "github.com/ElrondNetwork/elrond-sdk-erdgo/workflows" + "github.com/multiversx/mx-chain-crypto-go/signing" + "github.com/multiversx/mx-chain-crypto-go/signing/ed25519" + logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-sdk-go/blockchain" + "github.com/multiversx/mx-sdk-go/blockchain/cryptoProvider" + "github.com/multiversx/mx-sdk-go/builders" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/examples" + "github.com/multiversx/mx-sdk-go/interactors" + "github.com/multiversx/mx-sdk-go/workflows" "github.com/urfave/cli" ) @@ -106,13 +106,13 @@ VERSION: } argsConfig = &cfg{} - log = logger.GetOrCreate("elrond-sdk-erdgo/cmd/cli") + log = logger.GetOrCreate("mx-sdk-go/cmd/cli") ) var HOME = os.Getenv("HOME") -var pathGeneratedWallets = HOME + "/Elrond/testnet/filegen/output/walletKey.pem" +var pathGeneratedWallets = HOME + "/MultiversX/testnet/filegen/output/walletKey.pem" var suite = ed25519.NewEd25519() -var keyGen = crypto.NewKeyGenerator(suite) +var keyGen = signing.NewKeyGenerator(suite) const ( alice = "alice" @@ -169,7 +169,7 @@ func main() { app.Name = "cli" app.Version = "v1.0.0" - app.Usage = "This binary provides commands to interact with the elrond blockchain" + app.Usage = "This binary provides commands to interact with the MultiversX blockchain" app.Flags = []cli.Flag{ setGuardian, @@ -198,7 +198,7 @@ func process() error { return err } - ep, err := blockchain.NewElrondProxy(createElrondProxyArgs()) + ep, err := blockchain.NewProxy(createProxyArgs()) if err != nil { log.Error("error creating proxy", "error", err) return err @@ -599,7 +599,7 @@ func loadPemFiles() (*testData, error) { return td, nil } -func createElrondProxyArgs() blockchain.ArgsElrondProxy { +func createProxyArgs() blockchain.ArgsProxy { proxyURL := examples.TestnetGateway switch argsConfig.proxy { case mainnet: @@ -614,7 +614,7 @@ func createElrondProxyArgs() blockchain.ArgsElrondProxy { } } - return blockchain.ArgsElrondProxy{ + return blockchain.ArgsProxy{ ProxyURL: proxyURL, Client: nil, SameScState: false, diff --git a/data/guardian.go b/data/guardian.go index b88db52f..63ffcace 100644 --- a/data/guardian.go +++ b/data/guardian.go @@ -1,6 +1,6 @@ package data -import "github.com/ElrondNetwork/elrond-go-core/data/api" +import "github.com/multiversx/mx-chain-core-go/data/api" // GuardianDataResponse holds the guardian data endpoint response type GuardianDataResponse struct { diff --git a/disabled/enableEpochsHandler.go b/disabled/enableEpochsHandler.go index 4a840dcf..72d5c368 100644 --- a/disabled/enableEpochsHandler.go +++ b/disabled/enableEpochsHandler.go @@ -563,11 +563,6 @@ func (eeh *EnableEpochsHandler) IsRuntimeMemStoreLimitEnabled() bool { return false } -// IsWipeSingleNFTLiquidityDecreaseEnabled - -func (eeh *EnableEpochsHandler) IsWipeSingleNFTLiquidityDecreaseEnabled() bool { - return false -} - // IsAlwaysSaveTokenMetaDataEnabled - func (eeh *EnableEpochsHandler) IsAlwaysSaveTokenMetaDataEnabled() bool { return false diff --git a/examples/examplesPriceAggregator/main.go b/examples/examplesPriceAggregator/main.go index 002e8d7b..d92fd817 100644 --- a/examples/examplesPriceAggregator/main.go +++ b/examples/examplesPriceAggregator/main.go @@ -14,7 +14,7 @@ import ( "github.com/multiversx/mx-sdk-go/aggregator/fetchers" "github.com/multiversx/mx-sdk-go/aggregator/mock" "github.com/multiversx/mx-sdk-go/authentication" - "github.com/multiversx/mx-sdk-go/authentication" + "github.com/multiversx/mx-sdk-go/authentication/native" "github.com/multiversx/mx-sdk-go/blockchain" "github.com/multiversx/mx-sdk-go/blockchain/cryptoProvider" "github.com/multiversx/mx-sdk-go/core" diff --git a/go.mod b/go.mod index 5d36f140..33fb0933 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/ElrondNetwork/elrond-sdk-erdgo +module github.com/multiversx/mx-sdk-go go 1.17 @@ -6,14 +6,15 @@ require ( github.com/gin-contrib/cors v1.4.0 github.com/gin-gonic/gin v1.8.1 github.com/gorilla/websocket v1.5.0 - github.com/multiversx/mx-chain-core-go v1.1.30 - github.com/multiversx/mx-chain-crypto-go v1.2.5 - github.com/multiversx/mx-chain-go v1.4.4 + github.com/multiversx/mx-chain-core-go v1.1.33-0.20230202120347-d6f693e74417 + github.com/multiversx/mx-chain-crypto-go v1.2.6-0.20230202152403-757f8ca0be13 + github.com/multiversx/mx-chain-go v1.4.6-0.20230203094850-65bcc7f5b156 github.com/multiversx/mx-chain-logger-go v1.0.11 - github.com/multiversx/mx-chain-vm-common-go v1.3.36 + github.com/multiversx/mx-chain-vm-common-go v1.3.37-0.20230202165947-64f070d656e3 github.com/pborman/uuid v1.2.1 github.com/stretchr/testify v1.8.1 github.com/tyler-smith/go-bip39 v1.1.0 + github.com/urfave/cli v1.22.10 golang.org/x/crypto v0.3.0 golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b ) @@ -27,6 +28,7 @@ require ( github.com/cheekybits/genny v1.0.0 // indirect github.com/containerd/cgroups v1.0.4 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect @@ -112,7 +114,7 @@ require ( 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-p2p-go v1.0.10 // indirect + github.com/multiversx/mx-chain-p2p-go v1.0.11-0.20230202152730-438885fb703d // indirect github.com/multiversx/mx-chain-storage-go v1.0.7 // indirect github.com/nxadm/tail v1.4.8 // indirect github.com/onsi/ginkgo v1.16.5 // indirect @@ -129,7 +131,9 @@ require ( github.com/prometheus/common v0.37.0 // indirect github.com/prometheus/procfs v0.8.0 // indirect github.com/raulk/go-watchdog v1.3.0 // indirect + github.com/russross/blackfriday/v2 v2.0.1 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect + github.com/shurcooL/sanitized_anchor_name v1.0.0 // 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 diff --git a/go.sum b/go.sum index d99bd128..1fcef4f2 100644 --- a/go.sum +++ b/go.sum @@ -37,6 +37,7 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBrvjyP0v+ecvNYvCpyZgu5/xkfAUhi6wJj28eUfSU= dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4= dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= +filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= @@ -118,8 +119,10 @@ github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7 github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -597,29 +600,31 @@ github.com/multiformats/go-varint v0.0.6 h1:gk85QWKxh3TazbLxED/NlDVv8+q+ReFJk7Y2 github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/multiversx/concurrent-map v0.1.4 h1:hdnbM8VE4b0KYJaGY5yJS2aNIW9TFFsUYwbO0993uPI= github.com/multiversx/concurrent-map v0.1.4/go.mod h1:8cWFRJDOrWHOTNSqgYCUvwT7c7eFQ4U2vKMOp4A/9+o= -github.com/multiversx/mx-chain-core-go v1.1.30 h1:BtURR4I6HU1OnSbxcPMTQSQXNqtOuH3RW6bg5N7FSM0= github.com/multiversx/mx-chain-core-go v1.1.30/go.mod h1:8gGEQv6BWuuJwhd25qqhCOZbBSv9mk+hLeKvinSaSMk= -github.com/multiversx/mx-chain-crypto-go v1.2.5 h1:tuq3BUNMhKud5DQbZi9DiVAAHUXypizy8zPH0NpTGZk= -github.com/multiversx/mx-chain-crypto-go v1.2.5/go.mod h1:teqhNyWEqfMPgNn8sgWXlgtJ1a36jGCnhs/tRpXW6r4= -github.com/multiversx/mx-chain-es-indexer-go v1.3.8 h1:OvdOoBUQKkTaZsFPiBp1WCvDRN9ReQJUfy9Ac06rguM= -github.com/multiversx/mx-chain-es-indexer-go v1.3.8/go.mod h1:IV42GfhkqQ5vVO0OzGaF/ejp8TQrLkNo4LSB3TPnVhg= -github.com/multiversx/mx-chain-go v1.4.4 h1:sM0UlXj+JWpr9l9BMsFpwck+nSAF/8BThpR0mhiWeOw= -github.com/multiversx/mx-chain-go v1.4.4/go.mod h1:PREgsJ97g7a9yd5BUqfp8FpM2VSIFpYIt3VTVXBMUks= +github.com/multiversx/mx-chain-core-go v1.1.33-0.20230202120347-d6f693e74417 h1:wY/dhfwJC0mpeGwpvBRWWh/IL4aJLyQoqS+s3Bz17fw= +github.com/multiversx/mx-chain-core-go v1.1.33-0.20230202120347-d6f693e74417/go.mod h1:8gGEQv6BWuuJwhd25qqhCOZbBSv9mk+hLeKvinSaSMk= +github.com/multiversx/mx-chain-crypto-go v1.2.6-0.20230202113457-3066d2598c7a/go.mod h1:rOj0Rr19HTOYt9YTeym7RKxlHt91NXln3LVKjHKVmA0= +github.com/multiversx/mx-chain-crypto-go v1.2.6-0.20230202152403-757f8ca0be13 h1:rVjlCtEVNdt39s9H76RONNI/cNCsI0i0o8/t2u0L86I= +github.com/multiversx/mx-chain-crypto-go v1.2.6-0.20230202152403-757f8ca0be13/go.mod h1:rOj0Rr19HTOYt9YTeym7RKxlHt91NXln3LVKjHKVmA0= +github.com/multiversx/mx-chain-es-indexer-go v1.3.9 h1:6AS3f158aJ1E6Pzs6jvyBUiCaq/5yof4lbkGdSTzJng= +github.com/multiversx/mx-chain-es-indexer-go v1.3.9/go.mod h1:IV42GfhkqQ5vVO0OzGaF/ejp8TQrLkNo4LSB3TPnVhg= +github.com/multiversx/mx-chain-go v1.4.6-0.20230203094850-65bcc7f5b156 h1:XrD12WTtW0CO1weFKCaBv4NFxv6yERAsmBm8f6TjKiU= +github.com/multiversx/mx-chain-go v1.4.6-0.20230203094850-65bcc7f5b156/go.mod h1:iTXJ1vZ73AJMK7ewnX1XZtAUtOwgmMPV+cKExR9JPy0= github.com/multiversx/mx-chain-logger-go v1.0.11 h1:DFsHa+sc5fKwhDR50I8uBM99RTDTEW68ESyr5ALRDwE= github.com/multiversx/mx-chain-logger-go v1.0.11/go.mod h1:1srDkP0DQucWQ+rYfaq0BX2qLnULsUdRPADpYUTM6dA= -github.com/multiversx/mx-chain-p2p-go v1.0.10 h1:CYCuI0SP8Pt9K0TcJjUyxK7ByvWi2FXNUihy0iCEVIA= -github.com/multiversx/mx-chain-p2p-go v1.0.10/go.mod h1:j9Ueo2ptCnL7TQvQg6KS/KWAoJEJpjkPgE5ZTaqEAn4= +github.com/multiversx/mx-chain-p2p-go v1.0.11-0.20230202152730-438885fb703d h1:bXGh+i8XWP5JvUuGy3bM4eUIZsaDGGF35dfxJQTgoiM= +github.com/multiversx/mx-chain-p2p-go v1.0.11-0.20230202152730-438885fb703d/go.mod h1:oM8OV80AJku6lkocWcbQuk62dyXTwSOlQr6X1vdIJv8= github.com/multiversx/mx-chain-storage-go v1.0.7 h1:UqLo/OLTD3IHiE/TB/SEdNRV1GG2f1R6vIP5ehHwCNw= github.com/multiversx/mx-chain-storage-go v1.0.7/go.mod h1:gtKoV32Cg2Uy8deHzF8Ud0qAl0zv92FvWgPSYIP0Zmg= github.com/multiversx/mx-chain-vm-common-go v1.3.34/go.mod h1:sZ2COLCxvf2GxAAJHGmGqWybObLtFuk2tZUyGqnMXE8= -github.com/multiversx/mx-chain-vm-common-go v1.3.36 h1:9TViMK+vqTHss9cnGKtzOWzsxI/LWIetAYzrgf4H/w0= -github.com/multiversx/mx-chain-vm-common-go v1.3.36/go.mod h1:sZ2COLCxvf2GxAAJHGmGqWybObLtFuk2tZUyGqnMXE8= -github.com/multiversx/mx-chain-vm-v1_2-go v1.2.49 h1:Qbe+QvpUzodoOJEu+j6uK/erhnLfQBwNGiAEyP1XlQI= -github.com/multiversx/mx-chain-vm-v1_2-go v1.2.49/go.mod h1:+2IkboTtZ75oZ2Lzx7gNWbLP6BQ5GYa1MJQXPcfzu60= -github.com/multiversx/mx-chain-vm-v1_3-go v1.3.50 h1:+JlYeStjpPqyRGzfLCwnR4Zya3nA34SJjj/1DP1HtXk= -github.com/multiversx/mx-chain-vm-v1_3-go v1.3.50/go.mod h1:+rdIrpLS4NOAA3DNwXQHxXKO6cPnU3DF8+l0AbjV27E= -github.com/multiversx/mx-chain-vm-v1_4-go v1.4.74 h1:qr86QIn+u9zjRNa6/aDJ0nNgKk6Cb2FGB0RvltCcJhE= -github.com/multiversx/mx-chain-vm-v1_4-go v1.4.74/go.mod h1:EInFuruY4smF2XZczFcOM8W607x3T6KanTJ5mjYHY4Y= +github.com/multiversx/mx-chain-vm-common-go v1.3.37-0.20230202165947-64f070d656e3 h1:SYQTxS2KyYt5vgveDxetP7LVW0q/N6i0RVw6Jn2kDDk= +github.com/multiversx/mx-chain-vm-common-go v1.3.37-0.20230202165947-64f070d656e3/go.mod h1:7DV6Bu5GYyFW1T7swv44W/Eo2RDSJbhyeh5DJuz6GnY= +github.com/multiversx/mx-chain-vm-v1_2-go v1.2.51-0.20230202172648-8fbdbe9c384c h1:rqYl1maYfXsk/NdUwJic2OuOSdHWRNMQPa0DsNzM9yE= +github.com/multiversx/mx-chain-vm-v1_2-go v1.2.51-0.20230202172648-8fbdbe9c384c/go.mod h1:ZhYZiqymuvO0tuWnl3/ZAdp5oxBn6QfWUi865T49iQw= +github.com/multiversx/mx-chain-vm-v1_3-go v1.3.52-0.20230202172716-54839202baaf h1:ejv0o0pLPkE+1dcjRlVQx5NP/DDjUMhj810DhT6spr0= +github.com/multiversx/mx-chain-vm-v1_3-go v1.3.52-0.20230202172716-54839202baaf/go.mod h1:1lAeuSWICo/zjIzfBSMi02Jfei2WUrJg3YVhpPWMsik= +github.com/multiversx/mx-chain-vm-v1_4-go v1.4.77-0.20230202172735-b1076cf4e8e7 h1:Vv06Vyy3BzmC6Bq6vcuXlnxf5mW68Y4J4Tmg0I0geEA= +github.com/multiversx/mx-chain-vm-v1_4-go v1.4.77-0.20230202172735-b1076cf4e8e7/go.mod h1:Z8JpJcZLSk/XCy6XnuRQF5Y5PI6EntYR0S4MhaKi4hU= github.com/multiversx/mx-components-big-int v0.1.1 h1:695mYPKYOrmGEGgRH4/pZruDoe3CPP1LHrBxKfvj5l4= github.com/multiversx/mx-components-big-int v0.1.1/go.mod h1:0QrcFdfeLgJ/am10HGBeH0G0DNF+0Qx1E4DS/iozQls= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= @@ -702,7 +707,9 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= +github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= @@ -728,6 +735,7 @@ github.com/shurcooL/notifications v0.0.0-20181007000457-627ab5aea122/go.mod h1:b github.com/shurcooL/octicon v0.0.0-20181028054416-fa4f57f9efb2/go.mod h1:eWdoE5JD4R5UVWDucdOPg1g2fqQRq78IQa9zlOV1vpQ= github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1lToEk4d2s07G3XGfz2QrgHXg4RJBvjrOozvoWfk= github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4= github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw= @@ -793,6 +801,7 @@ github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95 github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.9/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli v1.22.10 h1:p8Fspmz3iTctJstry1PYS3HVdllxnEzTEsgIgtxTrCk= github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= diff --git a/headerCheck/interface.go b/headerCheck/interface.go index b21e1fd8..4266f93c 100644 --- a/headerCheck/interface.go +++ b/headerCheck/interface.go @@ -4,7 +4,9 @@ import ( "context" coreData "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/api" "github.com/multiversx/mx-chain-go/state" + "github.com/multiversx/mx-sdk-go/core" "github.com/multiversx/mx-sdk-go/data" ) @@ -20,7 +22,7 @@ type Proxy interface { GetRawStartOfEpochMetaBlock(ctx context.Context, epoch uint32) ([]byte, error) GetGenesisNodesPubKeys(ctx context.Context) (*data.GenesisNodes, error) GetValidatorsInfoByEpoch(ctx context.Context, epoch uint32) ([]*state.ShardValidatorInfo, error) - GetGuardianData(ctx context.Context, address erdgoCore.AddressHandler) (*api.GuardianData, error) + GetGuardianData(ctx context.Context, address core.AddressHandler) (*api.GuardianData, error) IsInterfaceNil() bool } diff --git a/libraries/libbls/main.go b/libraries/libbls/main.go index 84938bc7..97d88761 100644 --- a/libraries/libbls/main.go +++ b/libraries/libbls/main.go @@ -1,8 +1,6 @@ package main -import ( - "C" -) +import "C" func main() { } diff --git a/testsCommon/privateKeyStub.go b/testsCommon/privateKeyStub.go index e06aa4f5..fa596fc5 100644 --- a/testsCommon/privateKeyStub.go +++ b/testsCommon/privateKeyStub.go @@ -1,6 +1,6 @@ package testsCommon -import "github.com/multiversx/mx-chain-crypto-go" +import crypto "github.com/multiversx/mx-chain-crypto-go" // PrivateKeyStub - type PrivateKeyStub struct { diff --git a/testsCommon/publicKeyStub.go b/testsCommon/publicKeyStub.go index f57e21d8..a0250eb2 100644 --- a/testsCommon/publicKeyStub.go +++ b/testsCommon/publicKeyStub.go @@ -1,6 +1,6 @@ package testsCommon -import "github.com/multiversx/mx-chain-crypto-go" +import crypto "github.com/multiversx/mx-chain-crypto-go" // PublicKeyStub - type PublicKeyStub struct { diff --git a/txcheck/sigcheck.go b/txcheck/sigcheck.go index 68362fd5..44434c1b 100644 --- a/txcheck/sigcheck.go +++ b/txcheck/sigcheck.go @@ -1,12 +1,12 @@ package txcheck import ( - "github.com/ElrondNetwork/elrond-go-core/core/check" - coreData "github.com/ElrondNetwork/elrond-go-core/data" - "github.com/ElrondNetwork/elrond-go-core/data/transaction" - crypto "github.com/ElrondNetwork/elrond-go-crypto" - "github.com/ElrondNetwork/elrond-sdk-erdgo/builders" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" + "github.com/multiversx/mx-chain-core-go/core/check" + coreData "github.com/multiversx/mx-chain-core-go/data" + "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/data" ) // VerifyTransactionSignature handles the signature verification for a given transaction diff --git a/txcheck/sigcheck_test.go b/txcheck/sigcheck_test.go index ed4adb3f..66af2711 100644 --- a/txcheck/sigcheck_test.go +++ b/txcheck/sigcheck_test.go @@ -5,17 +5,17 @@ import ( "math/big" "testing" - "github.com/ElrondNetwork/elrond-go-core/data/transaction" - "github.com/ElrondNetwork/elrond-go-core/hashing/keccak" - marshallerFactory "github.com/ElrondNetwork/elrond-go-core/marshal/factory" - crypto "github.com/ElrondNetwork/elrond-go-crypto" - "github.com/ElrondNetwork/elrond-go-crypto/signing/ed25519" - "github.com/ElrondNetwork/elrond-sdk-erdgo/blockchain/cryptoProvider" - "github.com/ElrondNetwork/elrond-sdk-erdgo/builders" - "github.com/ElrondNetwork/elrond-sdk-erdgo/core" - "github.com/ElrondNetwork/elrond-sdk-erdgo/data" - "github.com/ElrondNetwork/elrond-sdk-erdgo/interactors" - "github.com/ElrondNetwork/elrond-sdk-erdgo/txcheck" + "github.com/multiversx/mx-chain-core-go/data/transaction" + "github.com/multiversx/mx-chain-core-go/hashing/keccak" + marshallerFactory "github.com/multiversx/mx-chain-core-go/marshal/factory" + "github.com/multiversx/mx-chain-crypto-go/signing" + "github.com/multiversx/mx-chain-crypto-go/signing/ed25519" + "github.com/multiversx/mx-sdk-go/blockchain/cryptoProvider" + "github.com/multiversx/mx-sdk-go/builders" + "github.com/multiversx/mx-sdk-go/core" + "github.com/multiversx/mx-sdk-go/data" + "github.com/multiversx/mx-sdk-go/interactors" + "github.com/multiversx/mx-sdk-go/txcheck" "github.com/stretchr/testify/require" ) @@ -88,7 +88,7 @@ func Test_VerifyTransactionSignature(t *testing.T) { func createUserAndGuardianKeys(t *testing.T) (cryptoHolderUser core.CryptoComponentsHolder, cryptoHolderGuardian core.CryptoComponentsHolder) { suite := ed25519.NewEd25519() - keyGen := crypto.NewKeyGenerator(suite) + keyGen := signing.NewKeyGenerator(suite) skUser, err := hex.DecodeString("6ae10fed53a84029e53e35afdbe083688eea0917a09a9431951dd42fd4da14c4") require.Nil(t, err)