@@ -48,18 +48,16 @@ func (c Constr) String() string {
48
48
49
49
// NewConstr creates a new Constr variant.
50
50
func NewConstr (tag uint , fields ... PlutusData ) PlutusData {
51
- if fields == nil {
52
- fields = make ([]PlutusData , 0 )
53
- }
54
- return & Constr {Tag : tag , Fields : fields }
51
+ tmpFields := make ([]PlutusData , len (fields ))
52
+ copy (tmpFields , fields )
53
+ return & Constr {Tag : tag , Fields : tmpFields }
55
54
}
56
55
57
56
// NewConstrDefIndef creates a Constr with the ability to specify whether it should use definite- or indefinite-length encoding
58
57
func NewConstrDefIndef (useIndef bool , tag uint , fields ... PlutusData ) PlutusData {
59
- if fields == nil {
60
- fields = make ([]PlutusData , 0 )
61
- }
62
- return & Constr {Tag : tag , Fields : fields , useIndef : & useIndef }
58
+ tmpFields := make ([]PlutusData , len (fields ))
59
+ copy (tmpFields , fields )
60
+ return & Constr {Tag : tag , Fields : tmpFields , useIndef : & useIndef }
63
61
}
64
62
65
63
// Map
@@ -77,12 +75,16 @@ func (m Map) String() string {
77
75
78
76
// NewMap creates a new Map variant.
79
77
func NewMap (pairs [][2 ]PlutusData ) PlutusData {
80
- return & Map {Pairs : pairs }
78
+ tmpPairs := make ([][2 ]PlutusData , len (pairs ))
79
+ copy (tmpPairs , pairs )
80
+ return & Map {Pairs : tmpPairs }
81
81
}
82
82
83
83
// NewMapDefIndef creates a new Map with the ability to specify whether it should use definite- or indefinite-length encoding
84
84
func NewMapDefIndef (useIndef bool , pairs [][2 ]PlutusData ) PlutusData {
85
- return & Map {Pairs : pairs , useIndef : & useIndef }
85
+ tmpPairs := make ([][2 ]PlutusData , len (pairs ))
86
+ copy (tmpPairs , pairs )
87
+ return & Map {Pairs : tmpPairs , useIndef : & useIndef }
86
88
}
87
89
88
90
// Integer
@@ -99,7 +101,8 @@ func (i Integer) String() string {
99
101
100
102
// NewInteger creates a new Integer variant.
101
103
func NewInteger (value * big.Int ) PlutusData {
102
- return & Integer {value }
104
+ tmpVal := new (big.Int ).Set (value )
105
+ return & Integer {tmpVal }
103
106
}
104
107
105
108
// ByteString
@@ -136,16 +139,14 @@ func (l List) String() string {
136
139
137
140
// NewList creates a new List variant.
138
141
func NewList (items ... PlutusData ) PlutusData {
139
- if items == nil {
140
- items = make ([]PlutusData , 0 )
141
- }
142
- return & List {Items : items }
142
+ tmpItems := make ([]PlutusData , len (items ))
143
+ copy (tmpItems , items )
144
+ return & List {Items : tmpItems }
143
145
}
144
146
145
147
// NewListDefIndef creates a list with the ability to specify whether it should use definite- or indefinite-length encoding
146
148
func NewListDefIndef (useIndef bool , items ... PlutusData ) PlutusData {
147
- if items == nil {
148
- items = make ([]PlutusData , 0 )
149
- }
150
- return & List {Items : items , useIndef : & useIndef }
149
+ tmpItems := make ([]PlutusData , len (items ))
150
+ copy (tmpItems , items )
151
+ return & List {Items : tmpItems , useIndef : & useIndef }
151
152
}
0 commit comments