Skip to content

Commit de0600d

Browse files
committed
Unexport some fields from the state since it should not be serialized
1 parent 1451263 commit de0600d

7 files changed

Lines changed: 29 additions & 29 deletions

File tree

evm-events-calls/convo.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (c *Convo) NextStep() (out loop.Cmd) {
8181
return cmd(AskContractAddress{})
8282
}
8383

84-
if contract.Abi == nil || contract.Abi.abi == nil {
84+
if contract.abi == nil || contract.abi.abi == nil {
8585
// if the user pasted an empty ABI, we would restart the process or choosing a contract address
8686
if contract.emptyABI {
8787
contract.Address = "" // reset the address
@@ -133,7 +133,7 @@ func (c *Convo) NextStep() (out loop.Cmd) {
133133
if !dynContract.TrackEvents && !dynContract.TrackCalls {
134134
return notifyContext(cmd(AskDynamicContractTrackWhat{}))
135135
}
136-
if dynContract.Abi == nil {
136+
if dynContract.abi == nil {
137137
// if the user pasted an empty ABI, we would restart the process or choosing a contract address
138138
if dynContract.emptyABI {
139139
dynContract.ReferenceContractAddress = "" // reset the reference address
@@ -293,9 +293,9 @@ func (c *Convo) Update(msg loop.Msg) loop.Cmd {
293293
return QuitInvalidContext
294294
}
295295

296-
if contract.AbiType == "string" {
296+
if contract.abiType == "string" {
297297
return loop.Seq(cmd(AskContractABIString{}))
298-
} else if contract.AbiType == "file" {
298+
} else if contract.abiType == "file" {
299299
return loop.Seq(cmd(AskContractABIFile{}))
300300
}
301301

@@ -312,7 +312,7 @@ func (c *Convo) Update(msg loop.Msg) loop.Cmd {
312312
return QuitInvalidContext
313313
}
314314

315-
contract.AbiType = msg.Value
315+
contract.abiType = msg.Value
316316

317317
return c.NextStep()
318318

@@ -508,7 +508,7 @@ func (c *Convo) Update(msg loop.Msg) loop.Cmd {
508508
if msg.Err != nil {
509509
return loop.Quit(fmt.Errorf("decoding ABI for contract %q: %w", contract.Name, msg.Err))
510510
}
511-
contract.Abi = msg.Abi
511+
contract.abi = msg.Abi
512512
evt := contract.EventModels()
513513
calls := contract.CallModels()
514514

@@ -577,7 +577,7 @@ message {{.Proto.MessageName}} {{.Proto.OutputModuleFieldName}} {
577577
return loop.Quit(fmt.Errorf("decoding ABI for dynamic contract of %q: %w", factory.Name, msg.err))
578578
}
579579
contract := c.State.dynamicContractOf(factory.Name)
580-
contract.Abi = msg.abi
580+
contract.abi = msg.abi
581581
evt := contract.EventModels()
582582
calls := contract.CallModels()
583583

@@ -819,7 +819,7 @@ message {{.Proto.MessageName}} {{.Proto.OutputModuleFieldName}} {
819819
return QuitInvalidContext
820820
}
821821

822-
events := contract.Abi.EventIDsToSig()
822+
events := contract.abi.EventIDsToSig()
823823

824824
values := make([]string, 0)
825825

evm-events-calls/generate.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ func (p *Project) Generate() codegen.ReturnGenerate {
3131
}
3232

3333
for _, contract := range p.Contracts {
34-
res.ProjectFiles[fmt.Sprintf("abi/%s_contract.abi.json", contract.Name)] = codegen.PrettifyJSON([]byte(contract.Abi.raw))
34+
res.ProjectFiles[fmt.Sprintf("abi/%s_contract.abi.json", contract.Name)] = codegen.PrettifyJSON([]byte(contract.abi.raw))
3535
}
3636

3737
for _, dds := range p.DynamicContracts {
38-
res.ProjectFiles[fmt.Sprintf("abi/%s_contract.abi.json", dds.Name)] = codegen.PrettifyJSON([]byte(dds.Abi.raw))
38+
res.ProjectFiles[fmt.Sprintf("abi/%s_contract.abi.json", dds.Name)] = codegen.PrettifyJSON([]byte(dds.abi.raw))
3939
}
4040

4141
return res
@@ -318,7 +318,7 @@ func generateFieldTransformCodeWithIndexed(fieldType eth.SolidityType, fieldAcce
318318
// For indexed dynamic arrays, we need to access the hash field
319319
return fmt.Sprintf("%s.hash", fieldAccess)
320320
}
321-
321+
322322
inner := generateFieldTransformCodeWithIndexed(v.ElementType, "x", byRef, false)
323323
if inner == SKIP_FIELD {
324324
return SKIP_FIELD

evm-events-calls/generate_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ func Test_Generate(t *testing.T) {
8383
for _, contract := range p.Contracts {
8484
res := CmdDecodeABI(contract)().(ReturnRunDecodeContractABI)
8585
require.NoError(t, res.Err)
86-
contract.Abi = res.Abi
86+
contract.abi = res.Abi
8787
}
8888

8989
for _, dynamicContract := range p.DynamicContracts {
9090
res := cmdDecodeDynamicABI(dynamicContract)().(ReturnRunDecodeDynamicContractABI)
9191
require.NoError(t, res.err)
92-
dynamicContract.Abi = res.abi
92+
dynamicContract.abi = res.abi
9393

9494
for _, contract := range p.Contracts {
9595
if contract.Name == dynamicContract.ParentContractName {
@@ -174,7 +174,7 @@ func TestUniFactory(t *testing.T) {
174174
for _, contract := range p.Contracts {
175175
res := CmdDecodeABI(contract)().(ReturnRunDecodeContractABI)
176176
require.NoError(t, res.Err)
177-
contract.Abi = res.Abi
177+
contract.abi = res.Abi
178178
}
179179

180180
res := p.Generate()
@@ -198,7 +198,7 @@ func TestBaycSQL(t *testing.T) {
198198
for _, contract := range p.Contracts {
199199
res := CmdDecodeABI(contract)().(ReturnRunDecodeContractABI)
200200
require.NoError(t, res.Err)
201-
contract.Abi = res.Abi
201+
contract.abi = res.Abi
202202
}
203203

204204
res := p.Generate()
@@ -216,13 +216,13 @@ func Test_Uniswapv3riggersDynamicDatasources(t *testing.T) {
216216
for _, contract := range p.Contracts {
217217
res := CmdDecodeABI(contract)().(ReturnRunDecodeContractABI)
218218
require.NoError(t, res.Err)
219-
contract.Abi = res.Abi
219+
contract.abi = res.Abi
220220
}
221221

222222
for _, contract := range p.DynamicContracts {
223223
res := cmdDecodeDynamicABI(contract)().(ReturnRunDecodeDynamicContractABI)
224224
require.NoError(t, res.err)
225-
contract.Abi = res.abi
225+
contract.abi = res.abi
226226
contract.parentContract = p.Contracts[0]
227227
}
228228

@@ -244,7 +244,7 @@ func Test_BaycTriggers(t *testing.T) {
244244
for _, contract := range p.Contracts {
245245
res := CmdDecodeABI(contract)().(ReturnRunDecodeContractABI)
246246
require.NoError(t, res.Err)
247-
contract.Abi = res.Abi
247+
contract.abi = res.Abi
248248
}
249249

250250
res := p.Generate()

evm-events-calls/state.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ type BaseContract struct {
241241
RawABI json.RawMessage `json:"rawAbi,omitempty"`
242242

243243
abiFetchedInThisSession bool
244-
Abi *ABI
244+
abi *ABI
245245
emptyABI bool
246-
AbiType string
246+
abiType string
247247
}
248248

249249
func (c *BaseContract) Identifier() string { return c.Name }
@@ -259,23 +259,23 @@ func (c *BaseContract) EventFields(event string) ([]*eth.LogParameter, error) {
259259
if err != nil {
260260
return nil, fmt.Errorf("invalid event ID %q: %w", event, err)
261261
}
262-
eventDef := c.Abi.abi.FindLogByTopic(hash)
262+
eventDef := c.abi.abi.FindLogByTopic(hash)
263263
if eventDef == nil {
264264
return nil, fmt.Errorf("cannot find event definition for %q", event)
265265
}
266266
return eventDef.Parameters, nil
267267
}
268268

269269
func (c *BaseContract) CallModels() []codegenCall {
270-
calls, err := c.Abi.BuildCallModels()
270+
calls, err := c.abi.BuildCallModels()
271271
if err != nil {
272272
panic(err)
273273
}
274274
return calls
275275
}
276276

277277
func (c *BaseContract) EventModels() []codegenEvent {
278-
evts, err := c.Abi.BuildEventModels()
278+
evts, err := c.abi.BuildEventModels()
279279
if err != nil {
280280
panic(err)
281281
}

starknet-events/contract.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type Contract struct {
3333
Aliases []*Alias `json:"aliases"`
3434
RawABI json.RawMessage `json:"rawAbi,omitempty"`
3535

36-
Abi *ABI
36+
abi *ABI
3737
emptyABI bool
3838
abiFetchedInThisSession bool
3939
}
@@ -57,7 +57,7 @@ func (c *Contract) SetAliases() {
5757

5858
// This is a bit hacky, but it works for now!
5959
func (c *Contract) setAliasesForOtherItems() {
60-
otherItems := c.Abi.otherItems
60+
otherItems := c.abi.otherItems
6161

6262
seen := make(map[string]int)
6363
for _, item := range otherItems {
@@ -77,7 +77,7 @@ func (c *Contract) setAliasesForOtherItems() {
7777
}
7878
}
7979
func (c *Contract) setAliasesForEvents() {
80-
events := c.Abi.decodedEvents
80+
events := c.abi.decodedEvents
8181

8282
aliases := make([]*Alias, 0)
8383
seen := make(map[string]struct{})

starknet-events/convo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (c *Convo) NextStep() loop.Cmd {
7777
return cmd(AskContractAddress{})
7878
}
7979

80-
if contract.Abi == nil || contract.Abi.decodedEvents == nil {
80+
if contract.abi == nil || contract.abi.decodedEvents == nil {
8181
// if the user pasted an empty ABI, we would restart the process or choosing a contract address
8282
if contract.emptyABI {
8383
contract.Address = "" // reset the address
@@ -291,7 +291,7 @@ func (c *Convo) Update(msg loop.Msg) loop.Cmd {
291291
if msg.Err != nil {
292292
return loop.Quit(fmt.Errorf("decoding ABI for contract %q: %w", contract.Name, msg.Err))
293293
}
294-
contract.Abi = msg.Abi
294+
contract.abi = msg.Abi
295295

296296
contract.SetAliases()
297297

starknet-events/state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (p *Project) Generate() codegen.ReturnGenerate {
3838
}
3939

4040
for _, contract := range p.Contracts {
41-
res.ProjectFiles[fmt.Sprintf("abi/%s_contract.abi.json", contract.Name)] = codegen.PrettifyJSON([]byte(contract.Abi.raw))
41+
res.ProjectFiles[fmt.Sprintf("abi/%s_contract.abi.json", contract.Name)] = codegen.PrettifyJSON([]byte(contract.abi.raw))
4242
}
4343

4444
return res

0 commit comments

Comments
 (0)