diff --git a/abi/codecForBigInt.go b/abi/bigIntValue.go similarity index 52% rename from abi/codecForBigInt.go rename to abi/bigIntValue.go index 2266dae..11e4dea 100644 --- a/abi/codecForBigInt.go +++ b/abi/bigIntValue.go @@ -7,61 +7,6 @@ import ( twos "github.com/multiversx/mx-components-big-int/twos-complement" ) -// BigUIntValue is a wrapper for a big integer (unsigned) -type BigUIntValue struct { - Value *big.Int -} - -func (value *BigUIntValue) encodeNested(writer io.Writer) error { - data := value.Value.Bytes() - dataLength := len(data) - - // Write the length of the payload - err := encodeLength(writer, uint32(dataLength)) - if err != nil { - return err - } - - // Write the payload - _, err = writer.Write(data) - if err != nil { - return err - } - - return nil -} - -func (value *BigUIntValue) encodeTopLevel(writer io.Writer) error { - data := value.Value.Bytes() - _, err := writer.Write(data) - if err != nil { - return err - } - - return nil -} - -func (value *BigUIntValue) decodeNested(reader io.Reader) error { - // Read the length of the payload - length, err := decodeLength(reader) - if err != nil { - return err - } - - // Read the payload - data, err := readBytesExactly(reader, int(length)) - if err != nil { - return err - } - - value.Value = big.NewInt(0).SetBytes(data) - return nil -} - -func (value *BigUIntValue) decodeTopLevel(data []byte) { - value.Value = big.NewInt(0).SetBytes(data) -} - // BigIntValue is a wrapper for a big integer (signed) type BigIntValue struct { Value *big.Int diff --git a/abi/codecForBigInt_test.go b/abi/bigIntValues_test.go similarity index 100% rename from abi/codecForBigInt_test.go rename to abi/bigIntValues_test.go diff --git a/abi/bigUIntValue.go b/abi/bigUIntValue.go new file mode 100644 index 0000000..70c3f98 --- /dev/null +++ b/abi/bigUIntValue.go @@ -0,0 +1,61 @@ +package abi + +import ( + "io" + "math/big" +) + +// BigUIntValue is a wrapper for a big integer (unsigned) +type BigUIntValue struct { + Value *big.Int +} + +func (value *BigUIntValue) encodeNested(writer io.Writer) error { + data := value.Value.Bytes() + dataLength := len(data) + + // Write the length of the payload + err := encodeLength(writer, uint32(dataLength)) + if err != nil { + return err + } + + // Write the payload + _, err = writer.Write(data) + if err != nil { + return err + } + + return nil +} + +func (value *BigUIntValue) encodeTopLevel(writer io.Writer) error { + data := value.Value.Bytes() + _, err := writer.Write(data) + if err != nil { + return err + } + + return nil +} + +func (value *BigUIntValue) decodeNested(reader io.Reader) error { + // Read the length of the payload + length, err := decodeLength(reader) + if err != nil { + return err + } + + // Read the payload + data, err := readBytesExactly(reader, int(length)) + if err != nil { + return err + } + + value.Value = big.NewInt(0).SetBytes(data) + return nil +} + +func (value *BigUIntValue) decodeTopLevel(data []byte) { + value.Value = big.NewInt(0).SetBytes(data) +} diff --git a/abi/addressValue.go b/abi/codecForAddress.go similarity index 100% rename from abi/addressValue.go rename to abi/codecForAddress.go