Skip to content

Commit

Permalink
remove deadcode
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBger committed Sep 5, 2024
1 parent 1f2d513 commit a000eb2
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 1,063 deletions.
8 changes: 4 additions & 4 deletions evm-events-calls/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ type ABI struct {
raw string
}

func cmdDecodeABI(contract *Contract) loop.Cmd {
func CmdDecodeABI(contract *Contract) loop.Cmd {
return func() loop.Msg {
abi, err := eth.ParseABIFromBytes([]byte(contract.RawABI))
return ReturnRunDecodeContractABI{abi: &ABI{abi, string(contract.RawABI)}, err: err}
return ReturnRunDecodeContractABI{Abi: &ABI{abi, string(contract.RawABI)}, Err: err}
}
}

Expand Down Expand Up @@ -84,7 +84,7 @@ func (a *ABI) BuildEventModels() (out []codegenEvent, err error) {
}
event.Signature()

// Sanitize abi struct name base on rust proto-gen sanitizer
// Sanitize Abi struct name base on rust proto-gen sanitizer
rustABIStructName = sanitizeABIStructName(rustABIStructName)

protoFieldName := xstrings.ToSnakeCase(pluralizerSingleton.Plural(rustABIStructName))
Expand Down Expand Up @@ -154,7 +154,7 @@ func (a *ABI) BuildCallModels() (out []codegenCall, err error) {
}
}

// Sanitize abi struct name base on rust proto-gen sanitizer
// Sanitize Abi struct name base on rust proto-gen sanitizer
rustABIStructName = sanitizeABIStructName(rustABIStructName)

protoFieldName := "call_" + xstrings.ToSnakeCase(pluralizerSingleton.Plural(rustABIStructName))
Expand Down
44 changes: 22 additions & 22 deletions evm-events-calls/apicalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,24 @@ func getContractABIDirect(ctx context.Context, address string, endpoint string)

res, err := httpClient.Do(req)
if err != nil {
return nil, "", fmt.Errorf("getting contract abi: %w", err)
return nil, "", fmt.Errorf("getting contract Abi: %w", err)
}
defer res.Body.Close()

type Response struct {
Abi []byte `json:"abi"`
Abi []byte `json:"Abi"`
}

data, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}

abiContent := gjson.GetBytes(data, "abi").String()
abiContent := gjson.GetBytes(data, "Abi").String()

ethABI, err := eth.ParseABIFromBytes([]byte(abiContent))
if err != nil {
return nil, "", fmt.Errorf("parsing abi %q: %w", abiContent, err)
return nil, "", fmt.Errorf("parsing Abi %q: %w", abiContent, err)
}
return ethABI, abiContent, err

Expand All @@ -130,7 +130,7 @@ func getContractABI(ctx context.Context, address string, endpoint string, apiKey

res, err := httpClient.Do(req)
if err != nil {
return nil, "", nil, fmt.Errorf("getting contract abi: %w", err)
return nil, "", nil, fmt.Errorf("getting contract Abi: %w", err)
}
defer res.Body.Close()

Expand All @@ -153,7 +153,7 @@ func getContractABI(ctx context.Context, address string, endpoint string, apiKey

ethABI, err := eth.ParseABIFromBytes([]byte(abiContent))
if err != nil {
return nil, "", timer, fmt.Errorf("parsing abi %q: %w", abiContent, err)
return nil, "", timer, fmt.Errorf("parsing Abi %q: %w", abiContent, err)
}
return ethABI, abiContent, timer, err
}
Expand All @@ -172,7 +172,7 @@ func getProxyContractImplementation(ctx context.Context, address string, endpoin

res, err := httpClient.Do(req)
if err != nil {
return "", nil, fmt.Errorf("getting contract abi from etherscan: %w", err)
return "", nil, fmt.Errorf("getting contract Abi from etherscan: %w", err)
}
defer res.Body.Close()

Expand Down Expand Up @@ -218,14 +218,14 @@ func timerUntilNextCall(msg string) *time.Timer {
// // Deprecated: use getContractABIFollowingProxy at the right place instead.
// func getAndSetContractABIs(ctx context.Context, contracts []*Contract, chain *ChainConfig) ([]*Contract, error) {
// for _, contract := range contracts {
// abi, abiContent, err := getContractABIFollowingProxy(ctx, contract.Address, chain)
// if err != nil {
// return nil, fmt.Errorf("getting contract ABI for %s: %w", contract.Address, err)
// Abi, abiContent, Err := getContractABIFollowingProxy(ctx, contract.Address, chain)
// if Err != nil {
// return nil, fmt.Errorf("getting contract ABI for %s: %w", contract.Address, Err)
// }

// //fmt.Println("this is the complete abiContent after merge", abiContent)
// contract.abiContent = abiContent
// contract.abi = abi
// contract.Abi = Abi

// fmt.Printf("Fetched contract ABI for %s\n", contract.Address)
// }
Expand Down Expand Up @@ -285,14 +285,14 @@ func getContractInitialBlock(ctx context.Context, chain *ChainConfig, contractAd
// // TURN this into a SINGLE contract request, and return the start block
// var lowestStartBlock uint64 = math.MaxUint64
// for _, contract := range contracts {
// req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("%s/api?module=account&action=txlist&address=%s&page=1&offset=1&sort=asc&apikey=%s", chain.ApiEndpoint, contract.Address, etherscanAPIKey), nil)
// if err != nil {
// return 0, fmt.Errorf("new request: %w", err)
// req, Err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("%s/api?module=account&action=txlist&address=%s&page=1&offset=1&sort=asc&apikey=%s", chain.ApiEndpoint, contract.Address, etherscanAPIKey), nil)
// if Err != nil {
// return 0, fmt.Errorf("new request: %w", Err)
// }

// res, err := httpClient.Do(req)
// if err != nil {
// return 0, fmt.Errorf("failed request to etherscan: %w", err)
// res, Err := httpClient.Do(req)
// if Err != nil {
// return 0, fmt.Errorf("failed request to etherscan: %w", Err)
// }
// defer res.Body.Close()

Expand All @@ -305,8 +305,8 @@ func getContractInitialBlock(ctx context.Context, chain *ChainConfig, contractAd
// }

// var response Response
// if err := json.NewDecoder(res.Body).Decode(&response); err != nil {
// return 0, fmt.Errorf("unmarshaling: %w", err)
// if Err := json.NewDecoder(res.Body).Decode(&response); Err != nil {
// return 0, fmt.Errorf("unmarshaling: %w", Err)
// }

// if len(response.Result) == 0 {
Expand All @@ -315,9 +315,9 @@ func getContractInitialBlock(ctx context.Context, chain *ChainConfig, contractAd

// <-timerUntilNextCall(response.Message).C

// blockNum, err := strconv.ParseUint(response.Result[0].BlockNumber, 10, 64)
// if err != nil {
// return 0, fmt.Errorf("parsing block number: %w", err)
// blockNum, Err := strconv.ParseUint(response.Result[0].BlockNumber, 10, 64)
// if Err != nil {
// return 0, fmt.Errorf("parsing block number: %w", Err)
// }

// if blockNum < lowestStartBlock {
Expand Down
4 changes: 2 additions & 2 deletions evm-events-calls/chain_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ func init() {
func (c *ChainConfig) setTestABI(address string, abiFile string) {
raw, err := os.ReadFile(abiFile)
if err != nil {
panic(fmt.Errorf("reading abi %q: %w", abiFile, err))
panic(fmt.Errorf("reading Abi %q: %w", abiFile, err))
}
abi, err := eth.ParseABIFromBytes(raw)
if err != nil {
panic(fmt.Errorf("parsing abi %q: %w", abi, err))
panic(fmt.Errorf("parsing Abi %q: %w", abi, err))
}
c.abiCache[address] = &ABI{
abi: abi,
Expand Down
Loading

0 comments on commit a000eb2

Please sign in to comment.