Skip to content

Commit

Permalink
Fixed tenderly push error.
Browse files Browse the repository at this point in the history
  • Loading branch information
BogdanHabic committed Jul 4, 2019
1 parent 2cfdfd4 commit 621d97d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 53 deletions.
6 changes: 2 additions & 4 deletions commands/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func uploadContracts(rest *rest.Rest) error {
for networkId, network := range contract.Networks {
var found bool
for _, pushedContract := range response.Contracts {
if pushedContract.DeploymentInformation.Address == network.Address && pushedContract.DeploymentInformation.NetworkID == networkId {
if pushedContract.Address == strings.ToLower(network.Address) && pushedContract.NetworkID == strings.ToLower(networkId) {
found = true
break
}
Expand Down Expand Up @@ -245,9 +245,7 @@ func getTruffleContracts(buildDir string) ([]truffle.Contract, int, error) {
}

contracts = append(contracts, contract)
if len(contract.Networks) > 0 {
numberOfContractsWithANetwork++
}
numberOfContractsWithANetwork += len(contract.Networks)
}

return contracts, numberOfContractsWithANetwork, nil
Expand Down
17 changes: 8 additions & 9 deletions stacktrace/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,14 @@ type Contract struct {

AccountID *AccountID `json:"account_id"`

Name string `json:"contract_name"`
LowercaseName string `json:"lowercase_contract_name"`
Abi string `json:"abi"`
Bytecode string `json:"bytecode"`
SourceMap string `json:"source_map"`
Source string `json:"source"`
NumberOfExceptions int `json:"number_of_exceptions"`
LastEventOccurredAt *time.Time `json:"last_event_occurred_at"`
DeploymentInformation DeploymentInformation `json:"deployment_information"`
Name string `json:"contract_name"`
LowercaseName string `json:"lowercase_contract_name"`
Abi string `json:"abi"`
Bytecode string `json:"bytecode"`
SourceMap string `json:"source_map"`
Source string `json:"source"`
NumberOfExceptions int `json:"number_of_exceptions"`
LastEventOccurredAt *time.Time `json:"last_event_occurred_at"`

VerificationDate time.Time `json:"verification_date"`
CreatedAt time.Time `json:"created_at"`
Expand Down
44 changes: 4 additions & 40 deletions truffle/contract.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package truffle

import (
"encoding/json"
"fmt"
"time"

"github.com/tenderly/tenderly-cli/stacktrace"
)

type Contract struct {
Expand Down Expand Up @@ -59,11 +55,10 @@ type ApiContract struct {

Name string `json:"contract_name"`

Abi string `json:"abi"`
Bytecode string `json:"bytecode"`
Source string `json:"source"`
SourceMap string `json:"source_map"`
DeploymentInformation *ApiDeploymentInformation `json:"deployment_information"`
Abi string `json:"abi"`
Bytecode string `json:"bytecode"`
Source string `json:"source"`
SourceMap string `json:"source_map"`

CreatedAt time.Time `json:"created_at"`
}
Expand All @@ -72,34 +67,3 @@ type ApiDeploymentInformation struct {
NetworkID string `json:"network_id"`
Address string `json:"address"`
}

func NewContract(truffleContract Contract) (*stacktrace.Contract, error) {
abiString, err := json.Marshal(truffleContract.Abi)
if err != nil {
return nil, fmt.Errorf("marshal abi string: %s", err)
}

var deploymentInformation *stacktrace.DeploymentInformation

for networkID, network := range truffleContract.Networks {
//@TODO(bogdan): Add multiple deployments or something similar
deploymentInformation = stacktrace.NewContractDeployment(
stacktrace.NewNetworkID(networkID),
stacktrace.NewContractAddress(network.Address),
)
break
}

return &stacktrace.Contract{
ID: stacktrace.NewContractID(truffleContract.Name),

Name: truffleContract.Name,
Abi: string(abiString),
Bytecode: truffleContract.DeployedBytecode,
SourceMap: truffleContract.DeployedSourceMap,
Source: truffleContract.Source,
DeploymentInformation: *deploymentInformation,

CreatedAt: time.Now(),
}, nil
}

0 comments on commit 621d97d

Please sign in to comment.