-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: add reset nonce command (#329)
* feature: add reset nonce command * fix: remove debug gosdk version * feature: update gosdk version
- Loading branch information
1 parent
7c0d897
commit c2b4876
Showing
3 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters