/
hinters.go
154 lines (135 loc) · 8.08 KB
/
hinters.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package cmds
import (
"github.com/ProtoconNet/mitum-currency/v3/common"
"github.com/ProtoconNet/mitum-currency/v3/digest"
digestisaac "github.com/ProtoconNet/mitum-currency/v3/digest/isaac"
"github.com/ProtoconNet/mitum-currency/v3/operation/currency"
"github.com/ProtoconNet/mitum-currency/v3/operation/extension"
isaacoperation "github.com/ProtoconNet/mitum-currency/v3/operation/isaac"
statecurrency "github.com/ProtoconNet/mitum-currency/v3/state/currency"
stateextension "github.com/ProtoconNet/mitum-currency/v3/state/extension"
"github.com/ProtoconNet/mitum-currency/v3/types"
"github.com/ProtoconNet/mitum2/launch"
"github.com/ProtoconNet/mitum2/util/encoder"
"github.com/pkg/errors"
)
var Hinters []encoder.DecodeDetail
var SupportedProposalOperationFactHinters []encoder.DecodeDetail
var AddedHinters = []encoder.DecodeDetail{
// revive:disable-next-line:line-length-limit
{Hint: common.BaseStateHint, Instance: common.BaseState{}},
{Hint: common.NodeHint, Instance: common.BaseNode{}},
{Hint: types.AccountHint, Instance: types.Account{}},
{Hint: types.AccountKeyHint, Instance: types.BaseAccountKey{}},
{Hint: types.AccountKeysHint, Instance: types.BaseAccountKeys{}},
{Hint: types.EthAccountKeysHint, Instance: types.EthAccountKeys{}},
{Hint: types.NilAccountKeysHint, Instance: types.NilAccountKeys{}},
{Hint: types.AddressHint, Instance: types.Address{}},
{Hint: types.AmountHint, Instance: types.Amount{}},
{Hint: types.ContractAccountKeysHint, Instance: types.ContractAccountKeys{}},
{Hint: types.ContractAccountStatusHint, Instance: types.ContractAccountStatus{}},
{Hint: types.CurrencyDesignHint, Instance: types.CurrencyDesign{}},
{Hint: types.CurrencyPolicyHint, Instance: types.CurrencyPolicy{}},
{Hint: types.EthAddressHint, Instance: types.EthAddress{}},
{Hint: types.FixedFeeerHint, Instance: types.FixedFeeer{}},
{Hint: types.MEPrivatekeyHint, Instance: types.MEPrivatekey{}},
{Hint: types.MEPublickeyHint, Instance: types.MEPublickey{}},
{Hint: types.NilFeeerHint, Instance: types.NilFeeer{}},
{Hint: types.RatioFeeerHint, Instance: types.RatioFeeer{}},
{Hint: currency.CreateAccountHint, Instance: currency.CreateAccount{}},
{Hint: currency.CreateAccountItemMultiAmountsHint, Instance: currency.CreateAccountItemMultiAmounts{}},
{Hint: currency.CreateAccountItemSingleAmountHint, Instance: currency.CreateAccountItemSingleAmount{}},
{Hint: currency.UpdateCurrencyHint, Instance: currency.UpdateCurrency{}},
{Hint: currency.RegisterCurrencyHint, Instance: currency.RegisterCurrency{}},
//{Hint: currency.FeeOperationFactHint, Instance: currency.FeeOperationFact{}},
//{Hint: currency.FeeOperationHint, Instance: currency.FeeOperation{}},
{Hint: currency.RegisterGenesisCurrencyHint, Instance: currency.RegisterGenesisCurrency{}},
{Hint: currency.RegisterGenesisCurrencyFactHint, Instance: currency.RegisterGenesisCurrencyFact{}},
{Hint: currency.UpdateKeyHint, Instance: currency.UpdateKey{}},
{Hint: currency.MintHint, Instance: currency.Mint{}},
{Hint: currency.TransferHint, Instance: currency.Transfer{}},
{Hint: currency.TransferItemMultiAmountsHint, Instance: currency.TransferItemMultiAmounts{}},
{Hint: currency.TransferItemSingleAmountHint, Instance: currency.TransferItemSingleAmount{}},
{Hint: extension.CreateContractAccountHint, Instance: extension.CreateContractAccount{}},
{Hint: extension.CreateContractAccountItemMultiAmountsHint, Instance: extension.CreateContractAccountItemMultiAmounts{}},
{Hint: extension.CreateContractAccountItemSingleAmountHint, Instance: extension.CreateContractAccountItemSingleAmount{}},
{Hint: extension.UpdateOperatorHint, Instance: extension.UpdateOperator{}},
{Hint: extension.WithdrawHint, Instance: extension.Withdraw{}},
{Hint: extension.WithdrawItemMultiAmountsHint, Instance: extension.WithdrawItemMultiAmounts{}},
{Hint: extension.WithdrawItemSingleAmountHint, Instance: extension.WithdrawItemSingleAmount{}},
{Hint: isaacoperation.GenesisNetworkPolicyHint, Instance: isaacoperation.GenesisNetworkPolicy{}},
{Hint: isaacoperation.FixedSuffrageCandidateLimiterRuleHint, Instance: isaacoperation.FixedSuffrageCandidateLimiterRule{}},
{Hint: isaacoperation.MajoritySuffrageCandidateLimiterRuleHint, Instance: isaacoperation.MajoritySuffrageCandidateLimiterRule{}},
{Hint: types.NetworkPolicyHint, Instance: types.NetworkPolicy{}},
{Hint: types.NetworkPolicyStateValueHint, Instance: types.NetworkPolicyStateValue{}},
{Hint: isaacoperation.SuffrageCandidateHint, Instance: isaacoperation.SuffrageCandidate{}},
{Hint: isaacoperation.SuffrageDisjoinHint, Instance: isaacoperation.SuffrageDisjoin{}},
{Hint: isaacoperation.SuffrageGenesisJoinHint, Instance: isaacoperation.SuffrageGenesisJoin{}},
{Hint: isaacoperation.SuffrageJoinHint, Instance: isaacoperation.SuffrageJoin{}},
{Hint: isaacoperation.NetworkPolicyHint, Instance: isaacoperation.NetworkPolicy{}},
{Hint: isaacoperation.NetworkPolicyFactHint, Instance: isaacoperation.NetworkPolicyFact{}},
{Hint: statecurrency.AccountStateValueHint, Instance: statecurrency.AccountStateValue{}},
{Hint: statecurrency.BalanceStateValueHint, Instance: statecurrency.BalanceStateValue{}},
{Hint: statecurrency.CurrencyDesignStateValueHint, Instance: statecurrency.CurrencyDesignStateValue{}},
{Hint: stateextension.ContractAccountStateValueHint, Instance: stateextension.ContractAccountStateValue{}},
{Hint: digest.AccountValueHint, Instance: digest.AccountValue{}},
{Hint: digest.OperationValueHint, Instance: digest.OperationValue{}},
{Hint: digestisaac.ManifestHint, Instance: digestisaac.Manifest{}},
}
var AddedSupportedHinters = []encoder.DecodeDetail{
{Hint: currency.CreateAccountFactHint, Instance: currency.CreateAccountFact{}},
{Hint: currency.UpdateCurrencyFactHint, Instance: currency.UpdateCurrencyFact{}},
{Hint: currency.RegisterCurrencyFactHint, Instance: currency.RegisterCurrencyFact{}},
{Hint: currency.UpdateKeyFactHint, Instance: currency.UpdateKeyFact{}},
{Hint: currency.MintFactHint, Instance: currency.MintFact{}},
{Hint: currency.TransferFactHint, Instance: currency.TransferFact{}},
{Hint: extension.CreateContractAccountFactHint, Instance: extension.CreateContractAccountFact{}},
{Hint: extension.UpdateOperatorFactHint, Instance: extension.UpdateOperatorFact{}},
{Hint: extension.WithdrawFactHint, Instance: extension.WithdrawFact{}},
{Hint: isaacoperation.GenesisNetworkPolicyFactHint, Instance: isaacoperation.GenesisNetworkPolicyFact{}},
{Hint: isaacoperation.SuffrageCandidateFactHint, Instance: isaacoperation.SuffrageCandidateFact{}},
{Hint: isaacoperation.SuffrageDisjoinFactHint, Instance: isaacoperation.SuffrageDisjoinFact{}},
{Hint: isaacoperation.SuffrageGenesisJoinFactHint, Instance: isaacoperation.SuffrageGenesisJoinFact{}},
{Hint: isaacoperation.SuffrageJoinFactHint, Instance: isaacoperation.SuffrageJoinFact{}},
}
func init() {
Hinters = make([]encoder.DecodeDetail, len(launch.Hinters)+len(AddedHinters))
copy(Hinters, launch.Hinters)
copy(Hinters[len(launch.Hinters):], AddedHinters)
SupportedProposalOperationFactHinters = make(
[]encoder.DecodeDetail,
len(launch.SupportedProposalOperationFactHinters)+len(AddedSupportedHinters),
)
copy(SupportedProposalOperationFactHinters, launch.SupportedProposalOperationFactHinters)
copy(SupportedProposalOperationFactHinters[len(launch.SupportedProposalOperationFactHinters):],
AddedSupportedHinters,
)
}
func LoadHinters(encs *encoder.Encoders) error {
for i := range Hinters {
if err := encs.AddDetail(Hinters[i]); err != nil {
return errors.Wrap(err, "add hinter to encoder")
}
}
for i := range SupportedProposalOperationFactHinters {
if err := encs.AddDetail(SupportedProposalOperationFactHinters[i]); err != nil {
return errors.Wrap(err, "add supported proposal operation fact hinter to encoder")
}
}
return nil
}
//func LoadHinters(enc encoder.Encoder) error {
// for i := range Hinters {
// if err := enc.Add(Hinters[i]); err != nil {
// return errors.Wrap(err, "add to encoder")
// }
// }
//
// for i := range SupportedProposalOperationFactHinters {
// if err := enc.Add(SupportedProposalOperationFactHinters[i]); err != nil {
// return errors.Wrap(err, "add to encoder")
// }
// }
//
// return nil
//}