context: define a constant for transaction context type

This commit is contained in:
Roman Khimov 2022-09-08 13:07:49 +03:00
parent 6be9367f03
commit 541d4b49e1
4 changed files with 10 additions and 4 deletions

View file

@ -21,6 +21,12 @@ import (
"github.com/nspcc-dev/neo-go/pkg/wallet"
)
// TransactionType is the ParameterContext Type used for transactions.
const TransactionType = "Neo.Network.P2P.Payloads.Transaction"
// compatTransactionType is the old, 2.x type used for transactions.
const compatTransactionType = "Neo.Core.ContractTransaction"
// ParameterContext represents smartcontract parameter's context.
type ParameterContext struct {
// Type is a type of a verifiable item.
@ -213,7 +219,7 @@ func (c *ParameterContext) UnmarshalJSON(data []byte) error {
var verif crypto.VerifiableDecodable
switch pc.Type {
case "Neo.Core.ContractTransaction", "Neo.Network.P2P.Payloads.Transaction":
case compatTransactionType, TransactionType:
tx := new(transaction.Transaction)
verif = tx
default:

View file

@ -102,7 +102,7 @@ func TestParameterContext_AddSignatureMultisig(t *testing.T) {
},
}
tx := getContractTx(ctr.ScriptHash())
c := NewParameterContext("Neo.Network.P2P.Payloads.Transaction", netmode.UnitTestNet, tx)
c := NewParameterContext(TransactionType, netmode.UnitTestNet, tx)
priv, err := keys.NewPrivateKey()
require.NoError(t, err)
sig := priv.SignHashable(uint32(c.Network), tx)