Skip to content

Commit

Permalink
Merge pull request #100 from multiversx/rc/v1.4.0
Browse files Browse the repository at this point in the history
Rc/v1.4.0
  • Loading branch information
iulianpascalau authored Feb 14, 2023
2 parents c921500 + 17e1836 commit 9b2d95b
Show file tree
Hide file tree
Showing 174 changed files with 4,856 additions and 1,143 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# mx-chain-core-go

mx-chain-go common components and data that can be used in other repositories as well
4 changes: 2 additions & 2 deletions core/accumulator/timeAccumulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"sync"
"time"

"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/ElrondNetwork/elrond-go-core/core/check"
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/check"
)

var _ core.Accumulator = (*timeAccumulator)(nil)
Expand Down
8 changes: 4 additions & 4 deletions core/accumulator/timeAccumulator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"testing"
"time"

"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/ElrondNetwork/elrond-go-core/core/accumulator"
"github.com/ElrondNetwork/elrond-go-core/core/check"
"github.com/ElrondNetwork/elrond-go-core/core/mock"
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/accumulator"
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-core-go/core/mock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
4 changes: 2 additions & 2 deletions core/alarm/alarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"
"time"

"github.com/ElrondNetwork/elrond-go-core/core/alarm"
"github.com/ElrondNetwork/elrond-go-core/core/atomic"
"github.com/multiversx/mx-chain-core-go/core/alarm"
"github.com/multiversx/mx-chain-core-go/core/atomic"
"github.com/stretchr/testify/require"
)

Expand Down
4 changes: 2 additions & 2 deletions core/appStatusPolling/appStatusPolling.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"sync"
"time"

"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/ElrondNetwork/elrond-go-core/core/check"
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/check"
)

const minPollingDuration = time.Second
Expand Down
6 changes: 3 additions & 3 deletions core/appStatusPolling/appStatusPolling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"testing"
"time"

"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/ElrondNetwork/elrond-go-core/core/appStatusPolling"
"github.com/ElrondNetwork/elrond-go-core/core/mock"
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/appStatusPolling"
"github.com/multiversx/mx-chain-core-go/core/mock"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion core/check/ifNil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package check_test
import (
"testing"

"github.com/ElrondNetwork/elrond-go-core/core/check"
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion core/check/ifZero_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"testing"

"github.com/ElrondNetwork/elrond-go-core/core/check"
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion core/closing/safeChanCloser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
8 changes: 4 additions & 4 deletions core/closing/shuffleOutCloser.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"fmt"
"time"

"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/ElrondNetwork/elrond-go-core/core/check"
"github.com/ElrondNetwork/elrond-go-core/core/random"
"github.com/ElrondNetwork/elrond-go-core/data/endProcess"
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-core-go/core/random"
"github.com/multiversx/mx-chain-core-go/data/endProcess"
)

const minDuration = time.Second
Expand Down
8 changes: 4 additions & 4 deletions core/closing/shuffleOutCloser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"testing"
"time"

"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/ElrondNetwork/elrond-go-core/core/check"
"github.com/ElrondNetwork/elrond-go-core/core/mock"
"github.com/ElrondNetwork/elrond-go-core/data/endProcess"
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-core-go/core/mock"
"github.com/multiversx/mx-chain-core-go/data/endProcess"
"github.com/stretchr/testify/assert"
)

Expand Down
17 changes: 17 additions & 0 deletions core/computers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import (
"strconv"
"strings"
"time"

"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-core-go/data"
)

// MaxInt32 returns the maximum of two given numbers
Expand Down Expand Up @@ -182,3 +185,17 @@ func IsValidESDTRole(role string) bool {
return false
}
}

// GetHeaderType will return the type of the provided header
func GetHeaderType(header data.HeaderHandler) HeaderType {
switch {
case check.IfNil(header):
return ""
case header.GetShardID() == MetachainShardId:
return MetaHeader
case check.IfNil(header.GetAdditionalData()):
return ShardHeaderV1
default:
return ShardHeaderV2
}
}
17 changes: 16 additions & 1 deletion core/computers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"testing"
"time"

"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/multiversx/mx-chain-core-go/core"
dataCore "github.com/multiversx/mx-chain-core-go/data"
"github.com/multiversx/mx-chain-core-go/data/block"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -502,3 +504,16 @@ func TestIsValidESDTRole(t *testing.T) {
require.Equal(t, tt.output, core.IsValidESDTRole(tt.input))
}
}

func TestGetHeaderType(t *testing.T) {
t.Parallel()

require.Equal(t, core.HeaderType(""), core.GetHeaderType(nil))

var nilHeader dataCore.HeaderHandler
require.Equal(t, core.HeaderType(""), core.GetHeaderType(nilHeader))

require.Equal(t, core.MetaHeader, core.GetHeaderType(&block.MetaBlock{}))
require.Equal(t, core.ShardHeaderV1, core.GetHeaderType(&block.Header{}))
require.Equal(t, core.ShardHeaderV2, core.GetHeaderType(&block.HeaderV2{}))
}
74 changes: 49 additions & 25 deletions core/constants.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
package core

// HeaderType defines the type to be used for the header that is sent
type HeaderType string

const (
// MetaHeader defines the type of *block.MetaBlock
MetaHeader HeaderType = "MetaBlock"
// ShardHeaderV1 defines the type of *block.Header
ShardHeaderV1 HeaderType = "Header"
// ShardHeaderV2 defines the type of *block.HeaderV2
ShardHeaderV2 HeaderType = "HeaderV2"
)

// NodeType represents the node's role in the network
type NodeType string

Expand Down Expand Up @@ -40,69 +52,69 @@ const BuiltInFunctionSetUserName = "SetUserName"
// BuiltInFunctionSaveKeyValue is the key for the save key value built-in function
const BuiltInFunctionSaveKeyValue = "SaveKeyValue"

// BuiltInFunctionESDTTransfer is the key for the elrond standard digital token transfer built-in function
// BuiltInFunctionESDTTransfer is the key for the electronic standard digital token transfer built-in function
const BuiltInFunctionESDTTransfer = "ESDTTransfer"

// BuiltInFunctionESDTBurn is the key for the elrond standard digital token burn built-in function
// BuiltInFunctionESDTBurn is the key for the electronic standard digital token burn built-in function
const BuiltInFunctionESDTBurn = "ESDTBurn"

// BuiltInFunctionESDTFreeze is the key for the elrond standard digital token freeze built-in function
// BuiltInFunctionESDTFreeze is the key for the electronic standard digital token freeze built-in function
const BuiltInFunctionESDTFreeze = "ESDTFreeze"

// BuiltInFunctionESDTUnFreeze is the key for the elrond standard digital token unfreeze built-in function
// BuiltInFunctionESDTUnFreeze is the key for the electronic standard digital token unfreeze built-in function
const BuiltInFunctionESDTUnFreeze = "ESDTUnFreeze"

// BuiltInFunctionESDTWipe is the key for the elrond standard digital token wipe built-in function
// BuiltInFunctionESDTWipe is the key for the electronic standard digital token wipe built-in function
const BuiltInFunctionESDTWipe = "ESDTWipe"

// BuiltInFunctionESDTPause is the key for the elrond standard digital token pause built-in function
// BuiltInFunctionESDTPause is the key for the electronic standard digital token pause built-in function
const BuiltInFunctionESDTPause = "ESDTPause"

// BuiltInFunctionESDTUnPause is the key for the elrond standard digital token unpause built-in function
// BuiltInFunctionESDTUnPause is the key for the electronic standard digital token unpause built-in function
const BuiltInFunctionESDTUnPause = "ESDTUnPause"

// BuiltInFunctionSetESDTRole is the key for the elrond standard digital token set built-in function
// BuiltInFunctionSetESDTRole is the key for the electronic standard digital token set built-in function
const BuiltInFunctionSetESDTRole = "ESDTSetRole"

// BuiltInFunctionUnSetESDTRole is the key for the elrond standard digital token unset built-in function
// BuiltInFunctionUnSetESDTRole is the key for the electronic standard digital token unset built-in function
const BuiltInFunctionUnSetESDTRole = "ESDTUnSetRole"

// BuiltInFunctionESDTSetLimitedTransfer is the key for the elrond standard digital token built-in function which sets the property
// BuiltInFunctionESDTSetLimitedTransfer is the key for the electronic standard digital token built-in function which sets the property
// for the token to be transferable only through accounts with transfer roles
const BuiltInFunctionESDTSetLimitedTransfer = "ESDTSetLimitedTransfer"

// BuiltInFunctionESDTUnSetLimitedTransfer is the key for the elrond standard digital token built-in function which unsets the property
// BuiltInFunctionESDTUnSetLimitedTransfer is the key for the electronic standard digital token built-in function which unsets the property
// for the token to be transferable only through accounts with transfer roles
const BuiltInFunctionESDTUnSetLimitedTransfer = "ESDTUnSetLimitedTransfer"

// BuiltInFunctionESDTLocalMint is the key for the elrond standard digital token local mint built-in function
// BuiltInFunctionESDTLocalMint is the key for the electronic standard digital token local mint built-in function
const BuiltInFunctionESDTLocalMint = "ESDTLocalMint"

// BuiltInFunctionESDTLocalBurn is the key for the elrond standard digital token local burn built-in function
// BuiltInFunctionESDTLocalBurn is the key for the electronic standard digital token local burn built-in function
const BuiltInFunctionESDTLocalBurn = "ESDTLocalBurn"

// BuiltInFunctionESDTNFTTransfer is the key for the elrond standard digital token NFT transfer built-in function
// BuiltInFunctionESDTNFTTransfer is the key for the electronic standard digital token NFT transfer built-in function
const BuiltInFunctionESDTNFTTransfer = "ESDTNFTTransfer"

// BuiltInFunctionESDTNFTCreate is the key for the elrond standard digital token NFT create built-in function
// BuiltInFunctionESDTNFTCreate is the key for the electronic standard digital token NFT create built-in function
const BuiltInFunctionESDTNFTCreate = "ESDTNFTCreate"

// BuiltInFunctionESDTNFTAddQuantity is the key for the elrond standard digital token NFT add quantity built-in function
// BuiltInFunctionESDTNFTAddQuantity is the key for the electronic standard digital token NFT add quantity built-in function
const BuiltInFunctionESDTNFTAddQuantity = "ESDTNFTAddQuantity"

// BuiltInFunctionESDTNFTCreateRoleTransfer is the key for the elrond standard digital token create role transfer function
// BuiltInFunctionESDTNFTCreateRoleTransfer is the key for the electronic standard digital token create role transfer function
const BuiltInFunctionESDTNFTCreateRoleTransfer = "ESDTNFTCreateRoleTransfer"

// BuiltInFunctionESDTNFTBurn is the key for the elrond standard digital token NFT burn built-in function
// BuiltInFunctionESDTNFTBurn is the key for the electronic standard digital token NFT burn built-in function
const BuiltInFunctionESDTNFTBurn = "ESDTNFTBurn"

// BuiltInFunctionESDTNFTAddURI is the key for the elrond standard digital token NFT add URI built-in function
// BuiltInFunctionESDTNFTAddURI is the key for the electronic standard digital token NFT add URI built-in function
const BuiltInFunctionESDTNFTAddURI = "ESDTNFTAddURI"

// BuiltInFunctionESDTNFTUpdateAttributes is the key for the elrond standard digital token NFT update attributes built-in function
// BuiltInFunctionESDTNFTUpdateAttributes is the key for the electronic standard digital token NFT update attributes built-in function
const BuiltInFunctionESDTNFTUpdateAttributes = "ESDTNFTUpdateAttributes"

// BuiltInFunctionMultiESDTNFTTransfer is the key for the elrond standard digital token multi transfer built-in function
// BuiltInFunctionMultiESDTNFTTransfer is the key for the electronic standard digital token multi transfer built-in function
const BuiltInFunctionMultiESDTNFTTransfer = "MultiESDTNFTTransfer"

// BuiltInFunctionSetGuardian is the key for setting a guardian built-in function
Expand Down Expand Up @@ -163,17 +175,17 @@ const SemiFungibleESDT = "SemiFungibleESDT"
// MaxRoyalty defines 100% as uint32
const MaxRoyalty = uint32(10000)

// RelayedTransaction is the key for the elrond meta/gassless/relayed transaction standard
// RelayedTransaction is the key for the electronic meta/gassless/relayed transaction standard
const RelayedTransaction = "relayedTx"

// RelayedTransactionV2 is the key for the optimized elrond meta/gassless/relayed transaction standard
// RelayedTransactionV2 is the key for the optimized electronic meta/gassless/relayed transaction standard
const RelayedTransactionV2 = "relayedTxV2"

// SCDeployInitFunctionName is the key for the function which is called at smart contract deploy time
const SCDeployInitFunctionName = "_init"

// ElrondProtectedKeyPrefix is the key prefix which is protected from writing in the trie - only for special builtin functions
const ElrondProtectedKeyPrefix = "ELROND"
// ProtectedKeyPrefix is the key prefix which is protected from writing in the trie - only for special builtin functions
const ProtectedKeyPrefix = "E" + "L" + "R" + "O" + "N" + "D"

// DelegationSystemSCKey is the key under which there is data in case of system delegation smart contracts
const DelegationSystemSCKey = "delegation"
Expand Down Expand Up @@ -230,3 +242,15 @@ const SCDeployIdentifier = "SCDeploy"

// SCUpgradeIdentifier is the identifier for a smart contract upgrade
const SCUpgradeIdentifier = "SCUpgrade"

// WriteLogIdentifier is the identifier for the information log that is generated by a smart contract call/esdt transfer
const WriteLogIdentifier = "writeLog"

// SignalErrorOperation is the identifier for the log that is generated when a smart contract is executed but return an error
const SignalErrorOperation = "signalError"

// CompletedTxEventIdentifier is the identifier for the log that is generated when the execution of a smart contract call is done
const CompletedTxEventIdentifier = "completedTxEvent"

// GasRefundForRelayerMessage is the return message for to the smart contract result with refund for the relayer
const GasRefundForRelayerMessage = "gas refund for relayer"
6 changes: 3 additions & 3 deletions core/converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"strconv"
"strings"

"github.com/ElrondNetwork/elrond-go-core/core/check"
"github.com/ElrondNetwork/elrond-go-core/hashing"
"github.com/ElrondNetwork/elrond-go-core/marshal"
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-core-go/hashing"
"github.com/multiversx/mx-chain-core-go/marshal"
)

// ConvertBytes converts the input bytes in a readable string using multipliers (k, M, G)
Expand Down
6 changes: 3 additions & 3 deletions core/converters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"strings"
"testing"

"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/ElrondNetwork/elrond-go-core/core/mock"
"github.com/ElrondNetwork/elrond-go-core/data/batch"
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/mock"
"github.com/multiversx/mx-chain-core-go/data/batch"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion core/counting/concurrentShardedCountsWithSize.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"sync"

"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/multiversx/mx-chain-core-go/core"
)

var _ CountsWithSize = (*ConcurrentShardedCountsWithSize)(nil)
Expand Down
2 changes: 1 addition & 1 deletion core/counting/concurrentShardedCountsWithSize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"sync"
"testing"

"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/multiversx/mx-chain-core-go/core"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
2 changes: 1 addition & 1 deletion core/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"testing"

"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/multiversx/mx-chain-core-go/core"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion core/keyValStorage/keyValStorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package keyValStorage
import (
"bytes"

"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/multiversx/mx-chain-core-go/core"
)

// KeyValStorage holds a key and an associated value
Expand Down
4 changes: 2 additions & 2 deletions core/keyValStorage/keyValStorage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package keyValStorage_test
import (
"testing"

"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/ElrondNetwork/elrond-go-core/core/keyValStorage"
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/keyValStorage"
"github.com/stretchr/testify/assert"
)

Expand Down
Loading

0 comments on commit 9b2d95b

Please sign in to comment.