diff --git a/go.mod b/go.mod index b4d4bde..93dc4d4 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,16 @@ module github.com/joeqian10/neo-gogogo -go 1.12 +go 1.18 require ( - github.com/stretchr/testify v1.4.0 - golang.org/x/crypto v0.23.0 - golang.org/x/text v0.15.0 + github.com/stretchr/testify v1.9.0 + golang.org/x/crypto v0.27.0 + golang.org/x/text v0.18.0 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 07c1afa..b764e34 100644 --- a/go.sum +++ b/go.sum @@ -1,60 +1,16 @@ -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= -golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= -golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/nep5/nep5Helper.go b/nep5/nep5Helper.go index 2d42f3a..2726a44 100644 --- a/nep5/nep5Helper.go +++ b/nep5/nep5Helper.go @@ -10,7 +10,7 @@ import ( "github.com/joeqian10/neo-gogogo/sc" ) -// nep5 wrapper class, api reference: https://github.com/neo-project/proposals/blob/master/nep-5.mediawiki#name +// Nep5Helper wrapper class, api reference: https://github.com/neo-project/proposals/blob/master/nep-5.mediawiki#name type Nep5Helper struct { scriptHash helper.UInt160 // the script hash of the nep5 token EndPoint string diff --git a/tx/claimTransaction.go b/tx/claimTransaction.go index e15a838..bde06d4 100644 --- a/tx/claimTransaction.go +++ b/tx/claimTransaction.go @@ -2,6 +2,7 @@ package tx import ( "encoding/hex" + "github.com/joeqian10/neo-gogogo/crypto" "github.com/joeqian10/neo-gogogo/helper" "github.com/joeqian10/neo-gogogo/helper/io" diff --git a/tx/claimTransaction_test.go b/tx/claimTransaction_test.go index d8bafa7..bd2fe4a 100644 --- a/tx/claimTransaction_test.go +++ b/tx/claimTransaction_test.go @@ -2,10 +2,12 @@ package tx import ( "encoding/hex" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/joeqian10/neo-gogogo/helper" "github.com/joeqian10/neo-gogogo/helper/io" - "github.com/stretchr/testify/assert" - "testing" ) func TestClaimTransaction(t *testing.T) { diff --git a/tx/contractTransaction.go b/tx/contractTransaction.go index 9756838..f4d7f57 100644 --- a/tx/contractTransaction.go +++ b/tx/contractTransaction.go @@ -2,6 +2,7 @@ package tx import ( "encoding/hex" + "github.com/joeqian10/neo-gogogo/crypto" "github.com/joeqian10/neo-gogogo/helper" "github.com/joeqian10/neo-gogogo/helper/io" @@ -94,7 +95,7 @@ func (tx *ContractTransaction) Serialize(bw *io.BinaryWriter) { tx.SerializeWitnesses(bw) } -func (tx *ContractTransaction) SerializeUnsigned(bw *io.BinaryWriter) { +func (tx *ContractTransaction) SerializeUnsigned(bw *io.BinaryWriter) { tx.SerializeUnsigned1(bw) tx.SerializeExclusiveData(bw) tx.SerializeUnsigned2(bw) diff --git a/tx/contractTransaction_test.go b/tx/contractTransaction_test.go index 11da3b5..831f043 100644 --- a/tx/contractTransaction_test.go +++ b/tx/contractTransaction_test.go @@ -2,9 +2,11 @@ package tx import ( "encoding/hex" - "github.com/joeqian10/neo-gogogo/helper/io" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" + + "github.com/joeqian10/neo-gogogo/helper/io" ) func TestContractTransaction(t *testing.T) { diff --git a/tx/invocationTransaction.go b/tx/invocationTransaction.go index 966be21..b8844e7 100644 --- a/tx/invocationTransaction.go +++ b/tx/invocationTransaction.go @@ -3,6 +3,7 @@ package tx import ( "crypto/rand" "encoding/hex" + "github.com/joeqian10/neo-gogogo/crypto" "github.com/joeqian10/neo-gogogo/helper" "github.com/joeqian10/neo-gogogo/helper/io" diff --git a/tx/invocationTransaction_test.go b/tx/invocationTransaction_test.go index 10b46b0..8b5fbd0 100644 --- a/tx/invocationTransaction_test.go +++ b/tx/invocationTransaction_test.go @@ -2,10 +2,12 @@ package tx import ( "encoding/hex" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/joeqian10/neo-gogogo/helper" "github.com/joeqian10/neo-gogogo/helper/io" - "github.com/stretchr/testify/assert" - "testing" ) func TestInvocationTransaction(t *testing.T) { diff --git a/tx/issueTransaction.go b/tx/issueTransaction.go index aa18177..7481eca 100644 --- a/tx/issueTransaction.go +++ b/tx/issueTransaction.go @@ -2,6 +2,7 @@ package tx import ( "encoding/hex" + "github.com/joeqian10/neo-gogogo/crypto" "github.com/joeqian10/neo-gogogo/helper" "github.com/joeqian10/neo-gogogo/helper/io" @@ -15,7 +16,7 @@ type IssueTransaction struct { // NewIssueTransaction creates an IssueTransaction func NewIssueTransaction(script []byte) *IssueTransaction { tx := &IssueTransaction{ - Transaction:NewTransaction(), + Transaction: NewTransaction(), } tx.Type = Issue_Transaction return tx @@ -85,12 +86,11 @@ func (tx *IssueTransaction) Serialize(bw *io.BinaryWriter) { tx.SerializeWitnesses(bw) } -func (tx *IssueTransaction) SerializeUnsigned(bw *io.BinaryWriter) { +func (tx *IssueTransaction) SerializeUnsigned(bw *io.BinaryWriter) { tx.Transaction.SerializeUnsigned1(bw) tx.SerializeExclusiveData(bw) tx.SerializeUnsigned2(bw) } -func (tx *IssueTransaction) SerializeExclusiveData(bw *io.BinaryWriter) { +func (tx *IssueTransaction) SerializeExclusiveData(bw *io.BinaryWriter) { } - diff --git a/tx/minerTransaction.go b/tx/minerTransaction.go index acaee26..e6e77bc 100644 --- a/tx/minerTransaction.go +++ b/tx/minerTransaction.go @@ -2,6 +2,7 @@ package tx import ( "encoding/hex" + "github.com/joeqian10/neo-gogogo/crypto" "github.com/joeqian10/neo-gogogo/helper" "github.com/joeqian10/neo-gogogo/helper/io" @@ -88,13 +89,12 @@ func (mtx *MinerTransaction) Serialize(bw *io.BinaryWriter) { mtx.SerializeWitnesses(bw) } -func (mtx *MinerTransaction) SerializeUnsigned(bw *io.BinaryWriter) { +func (mtx *MinerTransaction) SerializeUnsigned(bw *io.BinaryWriter) { mtx.Transaction.SerializeUnsigned1(bw) mtx.SerializeExclusiveData(bw) mtx.SerializeUnsigned2(bw) } -func (mtx *MinerTransaction) SerializeExclusiveData(bw *io.BinaryWriter) { +func (mtx *MinerTransaction) SerializeExclusiveData(bw *io.BinaryWriter) { bw.WriteLE(mtx.Nonce) } - diff --git a/tx/minerTransaction_test.go b/tx/minerTransaction_test.go index 2c8898b..0f64766 100644 --- a/tx/minerTransaction_test.go +++ b/tx/minerTransaction_test.go @@ -2,15 +2,17 @@ package tx import ( "encoding/hex" - "github.com/joeqian10/neo-gogogo/helper/io" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" + + "github.com/joeqian10/neo-gogogo/helper/io" ) func TestMinerTransaction(t *testing.T) { rawTx := "0000fcd30e22000001e72d286979ee6cb1b7e65dfddfb2e384100b8d148e7758de42e4168b71792c60c8000000000000001f72e68b4e39602912106d53b229378a082784b200" mtx := &MinerTransaction{ - Transaction:NewTransaction(), + Transaction: NewTransaction(), } // Deserialize mtx, err := mtx.FromHexString(rawTx) diff --git a/tx/stateTransaction.go b/tx/stateTransaction.go index ada8ea8..fa2ebdf 100644 --- a/tx/stateTransaction.go +++ b/tx/stateTransaction.go @@ -2,6 +2,7 @@ package tx import ( "encoding/hex" + "github.com/joeqian10/neo-gogogo/crypto" "github.com/joeqian10/neo-gogogo/helper" "github.com/joeqian10/neo-gogogo/helper/io" @@ -16,7 +17,7 @@ type StateTransaction struct { // NewStateTransaction creates a StateTransaction func NewStateTransaction(script []byte) *StateTransaction { tx := &StateTransaction{ - Transaction:NewTransaction(), + Transaction: NewTransaction(), } tx.Type = State_Transaction return tx @@ -92,16 +93,15 @@ func (tx *StateTransaction) Serialize(bw *io.BinaryWriter) { tx.SerializeWitnesses(bw) } -func (tx *StateTransaction) SerializeUnsigned(bw *io.BinaryWriter) { +func (tx *StateTransaction) SerializeUnsigned(bw *io.BinaryWriter) { tx.Transaction.SerializeUnsigned1(bw) tx.SerializeExclusiveData(bw) tx.SerializeUnsigned2(bw) } -func (tx *StateTransaction) SerializeExclusiveData(bw *io.BinaryWriter) { +func (tx *StateTransaction) SerializeExclusiveData(bw *io.BinaryWriter) { bw.WriteVarUint(uint64(len(tx.Descriptors))) for _, desc := range tx.Descriptors { desc.Serialize(bw) } } - diff --git a/tx/stateTransaction_test.go b/tx/stateTransaction_test.go index 6b0813c..354d3cd 100644 --- a/tx/stateTransaction_test.go +++ b/tx/stateTransaction_test.go @@ -2,9 +2,11 @@ package tx import ( "encoding/hex" - "github.com/joeqian10/neo-gogogo/helper/io" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" + + "github.com/joeqian10/neo-gogogo/helper/io" ) func TestStateTransaction(t *testing.T) { diff --git a/tx/transaction.go b/tx/transaction.go index c223bd3..648497b 100644 --- a/tx/transaction.go +++ b/tx/transaction.go @@ -2,10 +2,11 @@ package tx import ( "bytes" + "sort" + "github.com/joeqian10/neo-gogogo/helper" "github.com/joeqian10/neo-gogogo/helper/io" "github.com/joeqian10/neo-gogogo/wallet/keys" - "sort" ) const ( @@ -35,7 +36,7 @@ func NewTransaction() *Transaction { } } -func NewTransactionFromRPC() { +func NewTransactionFromRPC() { } diff --git a/tx/transactionAttribute.go b/tx/transactionAttribute.go index d17a024..1bc0753 100644 --- a/tx/transactionAttribute.go +++ b/tx/transactionAttribute.go @@ -4,10 +4,11 @@ import ( "encoding/hex" "encoding/json" "fmt" + "unsafe" + "github.com/joeqian10/neo-gogogo/helper" "github.com/joeqian10/neo-gogogo/helper/io" "github.com/joeqian10/neo-gogogo/rpc/models" - "unsafe" ) type TransactionAttribute struct { @@ -90,4 +91,4 @@ func (attr *TransactionAttribute) MarshalJSON() ([]byte, error) { "usage": attr.Usage.String(), "data": hex.EncodeToString(attr.Data), }) -} \ No newline at end of file +} diff --git a/tx/transactionBuilder.go b/tx/transactionBuilder.go index e9f4d54..94505af 100644 --- a/tx/transactionBuilder.go +++ b/tx/transactionBuilder.go @@ -2,12 +2,13 @@ package tx import ( "fmt" + "math/big" + "sort" + "github.com/joeqian10/neo-gogogo/helper" "github.com/joeqian10/neo-gogogo/rpc" "github.com/joeqian10/neo-gogogo/rpc/models" "github.com/joeqian10/neo-gogogo/sc" - "math/big" - "sort" ) const NeoTokenId = "c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b" @@ -164,7 +165,7 @@ func (tb *TransactionBuilder) MakeInvocationTransaction(script []byte, from help itx.Attributes = attributes } itx.Gas = gasConsumed.Add(sysFee) // add sys fee - fee := itx.Gas.Add(netFee) // add net fee + fee := itx.Gas.Add(netFee) // add net fee if itx.Size() > 1024 { fee = fee.Add(helper.Fixed8FromFloat64(0.001)) fee = fee.Add(helper.Fixed8FromFloat64(float64(itx.Size()) * 0.00001)) diff --git a/tx/transactionBuilder_integration_test.go b/tx/transactionBuilder_integration_test.go index ef295ad..a671d7c 100644 --- a/tx/transactionBuilder_integration_test.go +++ b/tx/transactionBuilder_integration_test.go @@ -1,12 +1,15 @@ +//go:build integration // +build integration package tx_integration import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/joeqian10/neo-gogogo/helper" "github.com/joeqian10/neo-gogogo/sc" - "github.com/stretchr/testify/assert" - "testing" ) var LocalEndPoint = "http://localhost:50003" // change to yours when using this SDK diff --git a/tx/transactionBuilder_test.go b/tx/transactionBuilder_test.go index ba8356c..9e3583d 100644 --- a/tx/transactionBuilder_test.go +++ b/tx/transactionBuilder_test.go @@ -1,12 +1,14 @@ package tx import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "github.com/joeqian10/neo-gogogo/helper" "github.com/joeqian10/neo-gogogo/rpc" "github.com/joeqian10/neo-gogogo/rpc/models" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" - "testing" ) func TestNewTransactionBuilder(t *testing.T) { @@ -26,7 +28,7 @@ func TestTransactionBuilder_GetBalance(t *testing.T) { clientMock.On("GetUnspents", mock.Anything).Return(rpc.GetUnspentsResponse{ RpcResponse: rpc.RpcResponse{ JsonRpc: "2.0", - ID: 1, + ID: 1, }, ErrorResponse: rpc.ErrorResponse{ Error: rpc.RpcError{ @@ -37,7 +39,7 @@ func TestTransactionBuilder_GetBalance(t *testing.T) { Result: models.RpcUnspent{ Balances: []models.UnspentBalance{ { - Unspents: []models.Unspent{ + Unspents: []models.Unspent{ { Txid: "4ee4af75d5aa60598fbae40ce86fb9a23ffec5a75dfa8b59d259d15f9e304319", N: 0, @@ -50,7 +52,7 @@ func TestTransactionBuilder_GetBalance(t *testing.T) { Amount: 27844.821, }, { - Unspents: []models.Unspent{ + Unspents: []models.Unspent{ { Txid: "c3182952855314b3f4b1ecf01a03b891d4627d19426ce841275f6d4c186e729a", N: 0, @@ -80,9 +82,9 @@ func TestTransactionBuilder_GetGasConsumed(t *testing.T) { Client: clientMock, } clientMock.On("InvokeScript", mock.Anything, mock.Anything).Return(rpc.InvokeScriptResponse{ - RpcResponse: rpc.RpcResponse{ + RpcResponse: rpc.RpcResponse{ JsonRpc: "2.0", - ID: 1, + ID: 1, }, ErrorResponse: rpc.ErrorResponse{ Error: rpc.RpcError{ @@ -90,10 +92,10 @@ func TestTransactionBuilder_GetGasConsumed(t *testing.T) { Message: "", }, }, - Result: models.InvokeResult{ - Script:"00c1046e616d656763d26113bac4208254d98a3eebaee66230ead7b9", - State:"HALT", - GasConsumed:"0.126", + Result: models.InvokeResult{ + Script: "00c1046e616d656763d26113bac4208254d98a3eebaee66230ead7b9", + State: "HALT", + GasConsumed: "0.126", Stack: []models.InvokeStack{ { Type: "ByteArray", @@ -115,9 +117,9 @@ func TestTransactionBuilder_GetClaimables(t *testing.T) { Client: clientMock, } clientMock.On("GetClaimable", mock.Anything).Return(rpc.GetClaimableResponse{ - RpcResponse: rpc.RpcResponse{ + RpcResponse: rpc.RpcResponse{ JsonRpc: "2.0", - ID: 1, + ID: 1, }, ErrorResponse: rpc.ErrorResponse{ Error: rpc.RpcError{ @@ -125,7 +127,7 @@ func TestTransactionBuilder_GetClaimables(t *testing.T) { Message: "", }, }, - Result: models.RpcClaimable{ + Result: models.RpcClaimable{ Claimables: []models.Claimable{ { TxId: "52ba70ef18e879785572c917795cd81422c3820b8cf44c24846a30ee7376fd77", @@ -138,8 +140,8 @@ func TestTransactionBuilder_GetClaimables(t *testing.T) { Unclaimed: 750.032, }, }, - Address:"AGofsxAUDwt52KjaB664GYsqVAkULYvKNt", - Unclaimed:750.032, + Address: "AGofsxAUDwt52KjaB664GYsqVAkULYvKNt", + Unclaimed: 750.032, }, }) @@ -225,7 +227,7 @@ func TestTransactionBuilder_LoadScriptTransaction(t *testing.T) { Client: clientMock, } - script := []byte{ 0x01, 0x02, 0x03, 0x04 } + script := []byte{0x01, 0x02, 0x03, 0x04} paramList := "0710" returnType := "05" hasStorage := true diff --git a/tx/transaction_test.go b/tx/transaction_test.go index 469fc9f..dbbfd1f 100644 --- a/tx/transaction_test.go +++ b/tx/transaction_test.go @@ -1,10 +1,12 @@ package tx import ( - "github.com/joeqian10/neo-gogogo/wallet/keys" - "github.com/stretchr/testify/assert" "sort" "testing" + + "github.com/stretchr/testify/assert" + + "github.com/joeqian10/neo-gogogo/wallet/keys" ) func TestAddSignature(t *testing.T) { diff --git a/tx/witness.go b/tx/witness.go index 1183d35..51b342e 100644 --- a/tx/witness.go +++ b/tx/witness.go @@ -4,11 +4,12 @@ import ( "encoding/hex" "encoding/json" "fmt" + "sort" + "github.com/joeqian10/neo-gogogo/helper" "github.com/joeqian10/neo-gogogo/helper/io" "github.com/joeqian10/neo-gogogo/sc" "github.com/joeqian10/neo-gogogo/wallet/keys" - "sort" ) // Witness @@ -105,7 +106,6 @@ func CreateMultiSignatureWitness(msg []byte, pairs []*keys.KeyPair, least int, p return CreateWitness(invocationScript, verificationScript) } - func VerifySignatureWitness(msg []byte, witness *Witness) bool { invocationScript := witness.InvocationScript length := invocationScript[0] @@ -122,7 +122,6 @@ func VerifySignatureWitness(msg []byte, witness *Witness) bool { return keys.VerifySignature(msg, signature, publicKey) } - func VerifyMultiSignatureWitness(msg []byte, witness *Witness) bool { invocationScript := witness.InvocationScript lenInvoScript := len(invocationScript) diff --git a/tx/witness_test.go b/tx/witness_test.go index b0f129a..6eca666 100644 --- a/tx/witness_test.go +++ b/tx/witness_test.go @@ -4,10 +4,11 @@ import ( "log" "testing" + "github.com/stretchr/testify/assert" + "github.com/joeqian10/neo-gogogo/helper" "github.com/joeqian10/neo-gogogo/helper/io" "github.com/joeqian10/neo-gogogo/wallet/keys" - "github.com/stretchr/testify/assert" ) func TestWitness_Deserialize(t *testing.T) {