Skip to content

Commit

Permalink
*: use nativehashes package where possible
Browse files Browse the repository at this point in the history
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
  • Loading branch information
AnnaShaleva committed Apr 18, 2024
1 parent cfb5a29 commit b7e247b
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 23 deletions.
4 changes: 2 additions & 2 deletions pkg/compiler/interop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/dao"
"github.com/nspcc-dev/neo-go/pkg/core/interop"
"github.com/nspcc-dev/neo-go/pkg/core/native"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativehashes"
"github.com/nspcc-dev/neo-go/pkg/core/state"
"github.com/nspcc-dev/neo-go/pkg/core/storage"
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
Expand Down Expand Up @@ -610,7 +610,7 @@ func TestCallWithVersion(t *testing.T) {
e.DeployContract(t, ctr, nil)
c := e.CommitteeInvoker(ctr.Hash)

policyH := state.CreateNativeContractHash(nativenames.Policy)
policyH := nativehashes.Policy
t.Run("good", func(t *testing.T) {
c.Invoke(t, e.Chain.GetBaseExecFee(), "callWithVersion", policyH.BytesBE(), 0, "getExecFeeFactor")
})
Expand Down
3 changes: 2 additions & 1 deletion pkg/core/blockchain_neotest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/interop/interopnames"
"github.com/nspcc-dev/neo-go/pkg/core/mempool"
"github.com/nspcc-dev/neo-go/pkg/core/native"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativehashes"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativeprices"
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
Expand Down Expand Up @@ -2460,7 +2461,7 @@ func TestBlockchain_GenesisTransactionExtension(t *testing.T) {
emit.Syscall(script.BinWriter, interopnames.SystemRuntimeCheckWitness)
emit.Bytes(script.BinWriter, to.BytesBE())
emit.Syscall(script.BinWriter, interopnames.SystemRuntimeCheckWitness)
emit.AppCall(script.BinWriter, state.CreateNativeContractHash(nativenames.Neo), "transfer", callflag.All, from, to, amount, nil)
emit.AppCall(script.BinWriter, nativehashes.Neo, "transfer", callflag.All, from, to, amount, nil)
emit.Opcodes(script.BinWriter, opcode.ASSERT)

var sysFee int64 = 1_0000_0000
Expand Down
5 changes: 2 additions & 3 deletions pkg/rpcclient/gas/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ package for more details on NEP-17 interface.
package gas

import (
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
"github.com/nspcc-dev/neo-go/pkg/core/state"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativehashes"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/nep17"
)

// Hash stores the hash of the native GAS contract.
var Hash = state.CreateNativeContractHash(nativenames.Gas)
var Hash = nativehashes.Gas

// NewReader creates a NEP-17 reader for the GAS contract.
func NewReader(invoker nep17.Invoker) *nep17.TokenReader {
Expand Down
4 changes: 2 additions & 2 deletions pkg/rpcclient/management/management.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"math/big"

"github.com/google/uuid"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativehashes"
"github.com/nspcc-dev/neo-go/pkg/core/state"
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
Expand Down Expand Up @@ -75,7 +75,7 @@ type HashesIterator struct {
}

// Hash stores the hash of the native ContractManagement contract.
var Hash = state.CreateNativeContractHash(nativenames.Management)
var Hash = nativehashes.Management

// Event is the event emitted on contract deployment/update/destroy.
// Even though these events are different they all have the same field inside.
Expand Down
4 changes: 2 additions & 2 deletions pkg/rpcclient/neo/neo.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"math/big"

"github.com/google/uuid"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativehashes"
"github.com/nspcc-dev/neo-go/pkg/core/state"
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
Expand Down Expand Up @@ -97,7 +97,7 @@ type ValidatorIterator struct {
}

// Hash stores the hash of the native NEOToken contract.
var Hash = state.CreateNativeContractHash(nativenames.Neo)
var Hash = nativehashes.Neo

// NewReader creates an instance of ContractReader to get data from the NEO
// contract.
Expand Down
5 changes: 2 additions & 3 deletions pkg/rpcclient/notary/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import (
"math"
"math/big"

"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
"github.com/nspcc-dev/neo-go/pkg/core/state"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativehashes"
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
Expand Down Expand Up @@ -76,7 +75,7 @@ type OnNEP17PaymentData struct {
var _ = stackitem.Convertible(&OnNEP17PaymentData{})

// Hash stores the hash of the native Notary contract.
var Hash = state.CreateNativeContractHash(nativenames.Notary)
var Hash = nativehashes.Notary

// NewReader creates an instance of ContractReader to get data from the Notary
// contract.
Expand Down
5 changes: 2 additions & 3 deletions pkg/rpcclient/oracle/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ package oracle
import (
"math/big"

"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
"github.com/nspcc-dev/neo-go/pkg/core/state"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativehashes"
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
Expand All @@ -32,7 +31,7 @@ type Actor interface {
}

// Hash stores the hash of the native OracleContract contract.
var Hash = state.CreateNativeContractHash(nativenames.Oracle)
var Hash = nativehashes.Oracle

const priceSetter = "setPrice"

Expand Down
5 changes: 2 additions & 3 deletions pkg/rpcclient/policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ various methods to perform PolicyContract state-changing calls.
package policy

import (
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
"github.com/nspcc-dev/neo-go/pkg/core/state"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativehashes"
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
Expand All @@ -34,7 +33,7 @@ type Actor interface {
}

// Hash stores the hash of the native PolicyContract contract.
var Hash = state.CreateNativeContractHash(nativenames.Policy)
var Hash = nativehashes.Policy

const (
execFeeSetter = "setExecFeeFactor"
Expand Down
5 changes: 2 additions & 3 deletions pkg/rpcclient/rolemgmt/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ various methods to perform the only RoleManagement state-changing call.
package rolemgmt

import (
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativehashes"
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
"github.com/nspcc-dev/neo-go/pkg/core/state"
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
Expand All @@ -32,7 +31,7 @@ type Actor interface {
}

// Hash stores the hash of the native RoleManagement contract.
var Hash = state.CreateNativeContractHash(nativenames.Designation)
var Hash = nativehashes.Designation

const designateMethod = "designateAsRole"

Expand Down
3 changes: 2 additions & 1 deletion pkg/services/rpcsrv/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/block"
"github.com/nspcc-dev/neo-go/pkg/core/fee"
"github.com/nspcc-dev/neo-go/pkg/core/native"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativehashes"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
"github.com/nspcc-dev/neo-go/pkg/core/state"
Expand Down Expand Up @@ -825,7 +826,7 @@ func TestCalculateNetworkFee(t *testing.T) {
require.NoError(t, err)

// Set fee per Conflicts attribute.
script, err := smartcontract.CreateCallScript(state.CreateNativeContractHash(nativenames.Policy), "setAttributeFee", byte(transaction.ConflictsT), conflictsFee)
script, err := smartcontract.CreateCallScript(nativehashes.Policy, "setAttributeFee", byte(transaction.ConflictsT), conflictsFee)
require.NoError(t, err)
txSetFee := transaction.New(script, 1_0000_0000)
txSetFee.ValidUntilBlock = chain.BlockHeight() + 1
Expand Down

0 comments on commit b7e247b

Please sign in to comment.