Skip to content

Commit

Permalink
more detailed errs, fix fee precision error
Browse files Browse the repository at this point in the history
  • Loading branch information
blockpane committed Oct 13, 2021
1 parent 2234e74 commit a4daffc
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 21 deletions.
2 changes: 1 addition & 1 deletion abi-form.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func GetAbiViewer(w int, h int, api *fio.API) (tab *widget.Box, ok bool) {
errs.ErrChan <- "getting abi for " + s
abiOut, err := api.GetABI(eos.AccountName(s))
if err != nil {
errs.ErrChan <- err.Error()
errs.ErrChan <- errs.Detailed(err)
return
}

Expand Down
4 changes: 2 additions & 2 deletions account-form.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ func NewAccountSearchTab(box chan fyne.Container, account *fio.Account) {
)
info, err := AccountSearch(accountSelect.Selected, accountInput.Text)
if err != nil {
errs.ErrChan <- err.Error()
errs.ErrChan <- errs.Detailed(err)
return
}
ao, err := info.report()
if err != nil {
errs.ErrChan <- err.Error()
errs.ErrChan <- errs.Detailed(err)
return
}
deRef := *ao
Expand Down
2 changes: 1 addition & 1 deletion action-form.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func GetAbiForm(action string, account *fio.Account, api *fio.API, opts *fio.TxO
}
abi, err := api.GetABI(eos.AccountName(accountAction[0]))
if err != nil {
errs.ErrChan <- err.Error()
errs.ErrChan <- errs.Detailed(err)
return nil, err
}
abiStruct := abi.ABI.StructForName(accountAction[1])
Expand Down
2 changes: 1 addition & 1 deletion action-vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func defaultValues(contract string, action string, fieldName string, fieldType s
// as expensive as it gets ... pretty safe to return
fee = fio.GetMaxFee("register_fio_domain")
}
returnValue = p.Sprintf("%.9f", fee)
returnValue = p.Sprintf("%.10f", fee)
case fieldName == "can_vote":
returnValue = "1"
case fieldName == "is_public":
Expand Down
2 changes: 1 addition & 1 deletion api-form.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewApiRequestTab(container chan fyne.Container) {
apiList := SupportedApis{Apis: []string{"/v1/chain/get_info"}}
err := apiList.Update(Uri, false)
if err != nil {
errs.ErrChan <- "Error updating list of available APIs: " + err.Error()
errs.ErrChan <- "Error updating list of available APIs: " + errs.Detailed(err)
}
inputEntry := widget.NewMultiLineEntry()
outputEntry := widget.NewMultiLineEntry()
Expand Down
11 changes: 11 additions & 0 deletions errLog/init.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package errs

import (
"fmt"
"fyne.io/fyne/widget"
"github.com/fioprotocol/fio-go/eos"
"log"
"strings"
"time"
Expand Down Expand Up @@ -43,3 +45,12 @@ func init() {
}
}(ErrChan, DisconnectChan)
}

func Detailed(e error) string {
switch e.(type) {
case eos.APIError:
return fmt.Sprintf("%s - %+v", e.Error(), e.(eos.APIError).ErrorStruct)
default:
return e.Error()
}
}
6 changes: 3 additions & 3 deletions msig-form.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func fundRandMsig(msig *fio.Account, funder *fio.Account, count int, api *fio.AP
), opts.ChainID, fio.CompressionNone,
)
if err != nil {
errs.ErrChan <- err.Error()
errs.ErrChan <- errs.Detailed(err)
errs.ErrChan <- "Could not fund new msig account:"
return false, err
}
Expand Down Expand Up @@ -364,7 +364,7 @@ func updateAuthResult(account *fio.Account, signers []signer, threshold int) (ok
}
a, o, e := fio.NewConnection(account.KeyBag, Uri)
if e != nil {
errs.ErrChan <- e.Error()
errs.ErrChan <- errs.Detailed(err)
errs.ErrChan <- "Could not update auth, new connection failed:"
return false, nil, errors.New("update auth Failed, could not connect to server")
}
Expand Down Expand Up @@ -409,7 +409,7 @@ func updateAuthResult(account *fio.Account, signers []signer, threshold int) (ok
}
out, e := a.PushTransactionRaw(tx)
if e != nil {
errs.ErrChan <- e.Error()
errs.ErrChan <- errs.Detailed(e)
errs.ErrChan <- account.KeyBag.Keys[0].String()
errs.ErrChan <- "use this private key to recover funds."
errs.ErrChan <- "Could not update auth for owner, push transaction failed:"
Expand Down
12 changes: 6 additions & 6 deletions msig-requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func requestBox(proposer string, requests []*fio.MsigApprovalsInfo, index int, p
refresh := func() {
_, ai, err := api.GetApprovals(fio.Name(proposer), 10)
if err != nil {
errs.ErrChan <- err.Error()
errs.ErrChan <- errs.Detailed(err)
return
}
requests = ai
Expand All @@ -59,13 +59,13 @@ func requestBox(proposer string, requests []*fio.MsigApprovalsInfo, index int, p
opts.ChainID, fio.CompressionNone,
)
if err != nil {
errs.ErrChan <- err.Error()
errs.ErrChan <- errs.Detailed(err)
resultPopup(err.Error(), proposalWindow)
return
}
res, err := api.PushTransactionRaw(tx)
if err != nil {
errs.ErrChan <- err.Error()
errs.ErrChan <-errs.Detailed(err)
resultPopup(err.Error(), proposalWindow)
return
}
Expand All @@ -88,13 +88,13 @@ func requestBox(proposer string, requests []*fio.MsigApprovalsInfo, index int, p
opts.ChainID, fio.CompressionNone,
)
if err != nil {
errs.ErrChan <- err.Error()
errs.ErrChan <- errs.Detailed(err)
resultPopup(err.Error(), proposalWindow)
return
}
res, err := api.PushTransactionRaw(tx)
if err != nil {
errs.ErrChan <- err.Error()
errs.ErrChan <- errs.Detailed(err)
resultPopup(err.Error(), proposalWindow)
return
}
Expand Down Expand Up @@ -123,7 +123,7 @@ func requestBox(proposer string, requests []*fio.MsigApprovalsInfo, index int, p
}
res, err := api.PushTransactionRaw(tx)
if err != nil {
errs.ErrChan <- err.Error()
errs.ErrChan <- errs.Detailed(err)
resultPopup(err.Error(), proposalWindow)
return
}
Expand Down
8 changes: 4 additions & 4 deletions requests-form.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func RequestContent(reqContent chan fyne.CanvasObject, refresh chan bool) {
case <-refresh:
content, err := GetPending(refresh, Account, Api)
if err != nil {
errs.ErrChan <- err.Error()
errs.ErrChan <- errs.Detailed(err)
continue
}
reqContent <- content
Expand Down Expand Up @@ -130,7 +130,7 @@ func GetPending(refreshChan chan bool, account *fio.Account, api *fio.API) (form
rejectBtn := widget.NewButtonWithIcon("", theme.DeleteIcon(), func() {
_, err := api.SignPushActions(fio.NewRejectFndReq(account.Actor, strconv.FormatUint(req.FioRequestId, 10)))
if err != nil {
errs.ErrChan <- err.Error()
errs.ErrChan <- errs.Detailed(err)
return
}
errs.ErrChan <- "rejected request id: " + strconv.FormatUint(req.FioRequestId, 10)
Expand All @@ -146,7 +146,7 @@ func GetPending(refreshChan chan bool, account *fio.Account, api *fio.API) (form
if err != nil {
view.Hide()
summary = "invalid content"
errs.ErrChan <- err.Error()
errs.ErrChan <- errs.Detailed(err)
} else {
summary = obt.Request.ChainCode
if obt.Request.ChainCode != obt.Request.TokenCode {
Expand Down Expand Up @@ -486,7 +486,7 @@ func NewRequest(account *fio.Account, api *fio.API) fyne.CanvasObject {
resp, err := api.SignPushActions(fio.NewFundsReq(account.Actor, payerFio, payeeFio, content))
if err != nil {
errLabel.SetText(err.Error())
errs.ErrChan <- err.Error()
errs.ErrChan <- errs.Detailed(err)
return
}
errLabel.SetText("Success, txid: " + resp.TransactionID)
Expand Down
2 changes: 1 addition & 1 deletion table.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func GetAccountSummary(api *fio.API) (*FioActions, error) {
for _, name := range result {
bi, err := api.GetABI(eos.AccountName(name.Owner))
if err != nil {
errs.ErrChan <- "problem while loading abi: " + err.Error()
errs.ErrChan <- "problem while loading abi: " + errs.Detailed(err)
continue
}
actionList := make(map[string]bool, 0)
Expand Down
2 changes: 1 addition & 1 deletion vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func VoteContent(content chan fyne.CanvasObject, refresh chan bool) {
)
if err != nil {
result = err.Error()
errs.ErrChan <- err.Error()
errs.ErrChan <- errs.Detailed(err)
} else {
j, err := json.MarshalIndent(resp, "", " ")
if err != nil {
Expand Down

0 comments on commit a4daffc

Please sign in to comment.