mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
signer, clef/core: ui changes + display UA and Origin
This commit is contained in:
parent
e31efa3716
commit
28cbd61baa
2 changed files with 24 additions and 12 deletions
|
|
@ -94,11 +94,13 @@ type Metadata struct {
|
||||||
Remote string `json:"remote"`
|
Remote string `json:"remote"`
|
||||||
Local string `json:"local"`
|
Local string `json:"local"`
|
||||||
Scheme string `json:"scheme"`
|
Scheme string `json:"scheme"`
|
||||||
|
UserAgent string `json:"User-Agent"`
|
||||||
|
Origin string `json:"Origin"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MetadataFromContext extracts Metadata from a given context.Context
|
// MetadataFromContext extracts Metadata from a given context.Context
|
||||||
func MetadataFromContext(ctx context.Context) Metadata {
|
func MetadataFromContext(ctx context.Context) Metadata {
|
||||||
m := Metadata{"NA", "NA", "NA"} // batman
|
m := Metadata{"NA", "NA", "NA", "", ""} // batman
|
||||||
|
|
||||||
if v := ctx.Value("remote"); v != nil {
|
if v := ctx.Value("remote"); v != nil {
|
||||||
m.Remote = v.(string)
|
m.Remote = v.(string)
|
||||||
|
|
@ -109,6 +111,12 @@ func MetadataFromContext(ctx context.Context) Metadata {
|
||||||
if v := ctx.Value("local"); v != nil {
|
if v := ctx.Value("local"); v != nil {
|
||||||
m.Local = v.(string)
|
m.Local = v.(string)
|
||||||
}
|
}
|
||||||
|
if v := ctx.Value("Origin"); v != nil {
|
||||||
|
m.Origin = v.(string)
|
||||||
|
}
|
||||||
|
if v := ctx.Value("User-Agent"); v != nil {
|
||||||
|
m.UserAgent = v.(string)
|
||||||
|
}
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/internal/ethapi"
|
"github.com/ethereum/go-ethereum/internal/ethapi"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"golang.org/x/crypto/ssh/terminal"
|
"golang.org/x/crypto/ssh/terminal"
|
||||||
|
|
@ -95,6 +95,7 @@ func (ui *CommandlineUI) confirm() bool {
|
||||||
|
|
||||||
func showMetadata(metadata Metadata) {
|
func showMetadata(metadata Metadata) {
|
||||||
fmt.Printf("Request context:\n\t%v -> %v -> %v\n", metadata.Remote, metadata.Scheme, metadata.Local)
|
fmt.Printf("Request context:\n\t%v -> %v -> %v\n", metadata.Remote, metadata.Scheme, metadata.Local)
|
||||||
|
fmt.Printf("\n\tUser-Agent: %v\n\tOrigin: %v\n", metadata.UserAgent, metadata.Origin)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ApproveTx prompt the user for confirmation to request to sign Transaction
|
// ApproveTx prompt the user for confirmation to request to sign Transaction
|
||||||
|
|
@ -113,19 +114,20 @@ func (ui *CommandlineUI) ApproveTx(request *SignTxRequest) (SignTxResponse, erro
|
||||||
}
|
}
|
||||||
fmt.Printf("from: %v\n", request.Transaction.From.String())
|
fmt.Printf("from: %v\n", request.Transaction.From.String())
|
||||||
fmt.Printf("value: %v wei\n", weival)
|
fmt.Printf("value: %v wei\n", weival)
|
||||||
fmt.Printf("gas: %v\n", request.Transaction.Gas)
|
fmt.Printf("gas: %v (%v)\n", request.Transaction.Gas, uint64(request.Transaction.Gas))
|
||||||
fmt.Printf("gasprice: %v wei\n", request.Transaction.GasPrice.ToInt())
|
fmt.Printf("gasprice: %v wei\n", request.Transaction.GasPrice.ToInt())
|
||||||
fmt.Printf("nonce: %v\n", request.Transaction.Nonce)
|
fmt.Printf("nonce: %v (%v)\n", request.Transaction.Nonce, uint64(request.Transaction.Nonce))
|
||||||
if request.Transaction.Data != nil {
|
if request.Transaction.Data != nil {
|
||||||
d := *request.Transaction.Data
|
d := *request.Transaction.Data
|
||||||
if len(d) > 0 {
|
if len(d) > 0 {
|
||||||
fmt.Printf("data: %v\n", common.Bytes2Hex(d))
|
|
||||||
|
fmt.Printf("data: %v\n", hexutil.Encode(d))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if request.Callinfo != nil {
|
if request.Callinfo != nil {
|
||||||
fmt.Printf("\nTransaction validation:\n")
|
fmt.Printf("\nTransaction validation:\n")
|
||||||
for _, m := range request.Callinfo {
|
for _, m := range request.Callinfo {
|
||||||
fmt.Printf(" * %s : %s", m.Typ, m.Message)
|
fmt.Printf(" * %s : %s\n", m.Typ, m.Message)
|
||||||
}
|
}
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
|
|
@ -199,7 +201,9 @@ func (ui *CommandlineUI) ApproveListing(request *ListRequest) (ListResponse, err
|
||||||
fmt.Printf("A request has been made to list all accounts. \n")
|
fmt.Printf("A request has been made to list all accounts. \n")
|
||||||
fmt.Printf("You can select which accounts the caller can see\n")
|
fmt.Printf("You can select which accounts the caller can see\n")
|
||||||
for _, account := range request.Accounts {
|
for _, account := range request.Accounts {
|
||||||
fmt.Printf("\t[x] %v\n", account.Address.Hex())
|
fmt.Printf(" [x] %v\n", account.Address.Hex())
|
||||||
|
fmt.Printf(" URL: %v\n", account.URL)
|
||||||
|
fmt.Printf(" Type: %v\n", account.Typ)
|
||||||
}
|
}
|
||||||
fmt.Printf("-------------------------------------------\n")
|
fmt.Printf("-------------------------------------------\n")
|
||||||
showMetadata(request.Meta)
|
showMetadata(request.Meta)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue