-
Notifications
You must be signed in to change notification settings - Fork 4
/
unsigned_validator.go
38 lines (31 loc) 路 1.21 KB
/
unsigned_validator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package extrinsic
import (
sc "github.com/LimeChain/goscale"
primitives "github.com/LimeChain/gosemble/primitives/types"
)
type UnsignedValidatorForChecked struct {
runtimeExtrinsic RuntimeExtrinsic
}
func NewUnsignedValidatorForChecked(extrinsic RuntimeExtrinsic) primitives.UnsignedValidator {
return UnsignedValidatorForChecked{
runtimeExtrinsic: extrinsic,
}
}
// PreDispatch validates the dispatch call before execution.
// Inherent call is accepted for being dispatched
func (v UnsignedValidatorForChecked) PreDispatch(call primitives.Call) (sc.Empty, error) {
module, ok := v.runtimeExtrinsic.Module(call.ModuleIndex())
if !ok {
return sc.Empty{}, nil
}
return module.PreDispatch(call)
}
// ValidateUnsigned returns the validity of the dispatch call.
// Inherent call is not validated as unsigned
func (v UnsignedValidatorForChecked) ValidateUnsigned(txSource primitives.TransactionSource, call primitives.Call) (primitives.ValidTransaction, error) {
module, ok := v.runtimeExtrinsic.Module(call.ModuleIndex())
if !ok {
return primitives.ValidTransaction{}, primitives.NewTransactionValidityError(primitives.NewUnknownTransactionNoUnsignedValidator())
}
return module.ValidateUnsigned(txSource, call)
}