Skip to content

Commit

Permalink
fix: fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikRevich committed Oct 11, 2023
1 parent 7001812 commit 2fa4bef
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
24 changes: 20 additions & 4 deletions cmd/bridge-burn-eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,28 @@ func commandBurnEth(b *zcnbridge.BridgeClient, args ...*Arg) {
ExitWithError(err, "failed to convert current token balance to ZCN")
}

var transaction *types.Transaction
var (
transaction *types.Transaction
hash string
status int
)

if tokenBalanceZCN < float64(amount) {
transaction, err = b.Swap(context.Background(), amount, time.Now().Add(time.Minute*3))
if err != nil {
ExitWithError(err, "failed to execute IncreaseBurnerAllowance")
ExitWithError(err, "failed to execute Swap")
}

hash = transaction.Hash().Hex()
status, err = zcnbridge.ConfirmEthereumTransaction(hash, retries, time.Second)
if err != nil {
ExitWithError(fmt.Sprintf("Failed to confirm Swap: hash = %s, error = %v", hash, err))
}

if status == 1 {
fmt.Printf("Verification: Swap [OK]: %s\n", hash)
} else {
ExitWithError(fmt.Sprintf("Verification: Swap [FAILED]: %s\n", hash))
}
}

Expand All @@ -51,8 +67,8 @@ func commandBurnEth(b *zcnbridge.BridgeClient, args ...*Arg) {
ExitWithError(err, "failed to execute IncreaseBurnerAllowance")
}

hash := transaction.Hash().Hex()
status, err := zcnbridge.ConfirmEthereumTransaction(hash, retries, time.Second)
hash = transaction.Hash().Hex()
status, err = zcnbridge.ConfirmEthereumTransaction(hash, retries, time.Second)
if err != nil {
ExitWithError(fmt.Sprintf("Failed to confirm IncreaseBurnerAllowance: hash = %s, error = %v", hash, err))
}
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/0chain/zwalletcli

require (
github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565
github.com/0chain/gosdk v1.10.1-0.20231010110531-9c7afa90cc6b
github.com/0chain/gosdk v1.8.18-0.20230902144943-ec223996673c
github.com/ethereum/go-ethereum v1.10.26
github.com/icza/bitio v1.1.0
github.com/olekukonko/tablewriter v0.0.5
Expand Down Expand Up @@ -44,6 +44,7 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/philhofer/fwd v1.1.2-0.20210722190033-5c56ac6d0bb9 // indirect
github.com/remeh/sizedwaitgroup v1.0.0 // indirect
github.com/rivo/uniseg v0.4.3 // indirect
github.com/rjeczalik/notify v0.9.3 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
Expand Down Expand Up @@ -75,4 +76,4 @@ require (
go 1.20

// temporary, for development
//replace github.com/0chain/gosdk => ../gosdk
replace github.com/0chain/gosdk => ../gosdk
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 h1:z+DtCR8mBsjPnEs
github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565/go.mod h1:UyDC8Qyl5z9lGkCnf9RHJPMektnFX8XtCJZHXCCVj8E=
github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM=
github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc=
github.com/0chain/gosdk v1.8.18-0.20230902144943-ec223996673c h1:EkFJlu3vui3myAjvWyXcgpqgbU5vrRdamuTgKWPd1e4=
github.com/0chain/gosdk v1.8.18-0.20230902144943-ec223996673c/go.mod h1:/AYFyM6A7rBWk/AoAy/oClmNnpdznvA9d7ND2rhSGJI=
github.com/0chain/gosdk v1.10.1-0.20231010110531-9c7afa90cc6b h1:5oRiAHtsyoZyrnKoFTGW2xlQRHCtFErF2vV0a0Pfs8M=
github.com/0chain/gosdk v1.10.1-0.20231010110531-9c7afa90cc6b/go.mod h1:d3YLgnSKvEtZ6I9taIQotb6xcMvUKvd01JnkXS+O1jk=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw=
Expand Down Expand Up @@ -279,6 +275,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/tsdb v0.7.1 h1:YZcsG11NqnK4czYLrWd9mpEuAJIHVQLwdrleYfszMAA=
github.com/remeh/sizedwaitgroup v1.0.0 h1:VNGGFwNo/R5+MJBf6yrsr110p0m4/OX4S3DCy7Kyl5E=
github.com/remeh/sizedwaitgroup v1.0.0/go.mod h1:3j2R4OIe/SeS6YDhICBy22RWjJC5eNCJ1V+9+NVNYlo=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw=
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
Expand Down

0 comments on commit 2fa4bef

Please sign in to comment.