-
Notifications
You must be signed in to change notification settings - Fork 202
/
argumentParser.go
53 lines (43 loc) · 1.67 KB
/
argumentParser.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package smartContract
import (
"github.com/ElrondNetwork/elrond-go/process"
vmcommon "github.com/ElrondNetwork/elrond-vm-common"
"github.com/ElrondNetwork/elrond-vm-common/parsers"
)
type argumentParser struct {
callParser process.CallArgumentsParser
deployParser process.DeployArgumentsParser
storageParser process.StorageArgumentsParser
}
// NewArgumentParser creates a full argument parser component
func NewArgumentParser() *argumentParser {
callArgsParser := parsers.NewCallArgsParser()
deployArgsParser := parsers.NewDeployArgsParser()
storageArgsParser := parsers.NewStorageUpdatesParser()
a := &argumentParser{
callParser: callArgsParser,
deployParser: deployArgsParser,
storageParser: storageArgsParser,
}
return a
}
// ParseCallData returns parsed data for contract calls
func (a *argumentParser) ParseCallData(data string) (string, [][]byte, error) {
return a.callParser.ParseData(data)
}
// ParseDeployData returns parsed data for deploy data
func (a *argumentParser) ParseDeployData(data string) (*parsers.DeployArgs, error) {
return a.deployParser.ParseData(data)
}
// CreateDataFromStorageUpdate creates contract call data from storage update
func (a *argumentParser) CreateDataFromStorageUpdate(storageUpdates []*vmcommon.StorageUpdate) string {
return a.storageParser.CreateDataFromStorageUpdate(storageUpdates)
}
// GetStorageUpdates returns storage updates from contract call data
func (a *argumentParser) GetStorageUpdates(data string) ([]*vmcommon.StorageUpdate, error) {
return a.storageParser.GetStorageUpdates(data)
}
// IsInterfaceNil return true if underlying object is nil
func (a *argumentParser) IsInterfaceNil() bool {
return a == nil
}