-
Notifications
You must be signed in to change notification settings - Fork 503
/
result.go
45 lines (36 loc) · 1.12 KB
/
result.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
package deploy
import (
"bytes"
"fmt"
"github.com/0xPolygon/polygon-edge/command/helper"
"github.com/0xPolygon/polygon-edge/types"
"github.com/umbracle/ethgo"
)
type deployContractResult struct {
Name string `json:"name"`
Address types.Address `json:"address"`
Hash types.Hash `json:"hash"`
GasUsed uint64 `json:"gasUsed"`
}
func newDeployContractsResult(name string,
address types.Address,
hash ethgo.Hash, gasUsed uint64) *deployContractResult {
return &deployContractResult{
Name: name,
Address: address,
Hash: types.BytesToHash(hash.Bytes()),
GasUsed: gasUsed,
}
}
func (r deployContractResult) GetOutput() string {
var buffer bytes.Buffer
buffer.WriteString("\n[ROOTCHAIN - DEPLOY CONTRACT]\n")
vals := make([]string, 0, 4)
vals = append(vals, fmt.Sprintf("Name|%s", r.Name))
vals = append(vals, fmt.Sprintf("Contract (address)|%s", r.Address))
vals = append(vals, fmt.Sprintf("Transaction (hash)|%s", r.Hash))
vals = append(vals, fmt.Sprintf("Transaction (gas used)|%d", r.GasUsed))
buffer.WriteString(helper.FormatKV(vals))
buffer.WriteString("\n")
return buffer.String()
}