Skip to content

Commit

Permalink
Merge pull request #5456 from onflow/ramtin/flow-evm-dont-returne-add…
Browse files Browse the repository at this point in the history
…ress-zero-for-deployment

[Flow EVM] return empty string when deployed address is empty
  • Loading branch information
ramtinms authored Feb 26, 2024
2 parents 35d56ce + ba8588e commit c912767
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions fvm/evm/types/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ func (fa Address) Bytes() []byte {
return fa[:]
}

// String returns the hex encoding of the address
// it returns empty string if address is empty
func (fa Address) String() string {
if fa == EmptyAddress {
return ""
}
return fa.ToCommon().Hex()
}

// ToCommon returns the geth address
func (fa Address) ToCommon() gethCommon.Address {
return gethCommon.Address(fa)
Expand Down
2 changes: 1 addition & 1 deletion fvm/evm/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (p *TransactionExecutedPayload) CadenceEvent() (cadence.Event, error) {
cadence.String(p.Result.VMErrorString()),
cadence.NewUInt8(p.Result.TxType),
cadence.NewUInt64(p.Result.GasConsumed),
cadence.String(p.Result.DeployedContractAddress.ToCommon().Hex()),
cadence.String(p.Result.DeployedContractAddress.String()),
cadence.String(hex.EncodeToString(p.Result.ReturnedValue)),
cadence.String(hex.EncodeToString(encodedLogs)),
},
Expand Down

0 comments on commit c912767

Please sign in to comment.