Skip to content

Commit

Permalink
Feature: add reset nonce command (#329)
Browse files Browse the repository at this point in the history
* feature: add reset nonce command

* fix: remove debug gosdk version

* feature: update gosdk version
  • Loading branch information
YarikRevich authored Nov 11, 2023
1 parent 7c0d897 commit c2b4876
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
42 changes: 42 additions & 0 deletions cmd/reset-user-nonce.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package cmd

import (
"context"
"fmt"
"time"

"github.com/0chain/gosdk/zcnbridge"
)

//goland:noinspection ALL
func init() {
rootCmd.AddCommand(
createCommandWithBridge(
"reset-user-nonce",
"Reset user minted nonce",
"Resets user minted nonce in bridge SC",
resetUserNonce,
))
}

// resetUserNonce resets user nonce in bridge SC
func resetUserNonce(bc *zcnbridge.BridgeClient, args ...*Arg) {
tx, err := bc.ResetUserNonceMinted(context.Background())
if err != nil {
ExitWithError(err)
}

hash := tx.Hash().String()
fmt.Printf("Confirming Reset of user nonce transaction: %s\n", hash)

status, err := zcnbridge.ConfirmEthereumTransaction(hash, 100, time.Second*5)
if err != nil {
ExitWithError(err)
}

if status == 1 {
fmt.Printf("\nTransaction verification success: %s\n", hash)
} else {
ExitWithError(fmt.Sprintf("\nVerification failed: %s\n", hash))
}
}
2 changes: 1 addition & 1 deletion 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.20231026205111-b15f9736c813
github.com/0chain/gosdk v1.10.1-0.20231110212012-f3a75f7991a2
github.com/ethereum/go-ethereum v1.13.2
github.com/icza/bitio v1.1.0
github.com/olekukonko/tablewriter v0.0.5
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ github.com/0chain/gosdk v1.10.1-0.20231016103614-0f61a49368d5 h1:NfSSkZBcjI/QOi9
github.com/0chain/gosdk v1.10.1-0.20231016103614-0f61a49368d5/go.mod h1:6Co9xV9/jeS9Bdi0L3fISOnKbrm0qPTzRtBhIdB/yqY=
github.com/0chain/gosdk v1.10.1-0.20231026205111-b15f9736c813 h1:9++AowN5ps066UpVT4CCZgDLweaNi8Q/Yqs4Jxt2XS0=
github.com/0chain/gosdk v1.10.1-0.20231026205111-b15f9736c813/go.mod h1:d3YLgnSKvEtZ6I9taIQotb6xcMvUKvd01JnkXS+O1jk=
github.com/0chain/gosdk v1.10.1-0.20231110212012-f3a75f7991a2 h1:xeWeKRbKl+cX+Z2Xq43Dc7OwBDyT5l61FkogRsbe9tw=
github.com/0chain/gosdk v1.10.1-0.20231110212012-f3a75f7991a2/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/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
Expand Down

0 comments on commit c2b4876

Please sign in to comment.