Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/refactor zboxcore #394

Merged
merged 33 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b1bfd37
Fix/refactor zboxcore
Jayashsatolia403 Aug 24, 2024
4328975
Repo snapshots
Jayashsatolia403 Aug 24, 2024
59ba911
Fixed according to new functions
Jayashsatolia403 Sep 10, 2024
7d596fe
Update
Jayashsatolia403 Sep 10, 2024
23d8239
Fix
Jayashsatolia403 Sep 10, 2024
52b763e
Fix
Jayashsatolia403 Sep 10, 2024
7a941e5
Fix
Jayashsatolia403 Sep 10, 2024
42be33e
Merge remote-tracking branch 'origin/sprint-1.18' into fix/refactor-z…
Jayashsatolia403 Sep 11, 2024
6154c81
Merge remote-tracking branch 'origin/fix/refactor-zboxcore' into fix/…
Jayashsatolia403 Sep 11, 2024
6a1f579
Fix
Jayashsatolia403 Sep 11, 2024
d59c12f
Updated gitactions version in build-zwallet.yaml
shahnawaz-creator Sep 11, 2024
3fdd8d3
Fix
Jayashsatolia403 Sep 11, 2024
6c85618
Merge remote-tracking branch 'origin/fix/refactor-zboxcore' into fix/…
Jayashsatolia403 Sep 11, 2024
1d24ded
Fix
Jayashsatolia403 Sep 11, 2024
687dda5
Update gosdk
Jayashsatolia403 Sep 12, 2024
47d9e6f
Fix
Jayashsatolia403 Sep 13, 2024
5c06714
Fix
Jayashsatolia403 Sep 14, 2024
7b0a60e
Fix
Jayashsatolia403 Sep 15, 2024
e8bd2f1
Fix
Jayashsatolia403 Sep 15, 2024
8ca3e72
Fix
Jayashsatolia403 Sep 15, 2024
7bcc868
Fix
Jayashsatolia403 Sep 15, 2024
c780bf3
Fix
Jayashsatolia403 Sep 15, 2024
905407c
go mod tidy.
yash10019coder Sep 17, 2024
fb0cc02
refactor: auth-register command to use new method ZCNSCAddAuthorizer.
yash10019coder Sep 18, 2024
acdca50
refactor: go mod to use latest gosdk from fix/refactor-zboxcore PR.
yash10019coder Sep 18, 2024
ec78e61
refactor: go mod to use latest gosdk from fix/refactor-zboxcore PR.
yash10019coder Sep 18, 2024
c8e4c5b
Merge pull request #401 from 0chain/fix/refactor-zboxcore-st
Jayashsatolia403 Sep 19, 2024
c5b5d43
Fix
Jayashsatolia403 Sep 21, 2024
d902ef2
Fix
Jayashsatolia403 Sep 21, 2024
83da25f
Fix
Jayashsatolia403 Sep 22, 2024
e61ad26
Merge remote-tracking branch 'origin/fix/refactor-zboxcore' into fix/…
Jayashsatolia403 Sep 22, 2024
aaee8bb
Fix
Jayashsatolia403 Sep 22, 2024
3f9537a
Merge branch 'sprint-1.18' into fix/refactor-zboxcore
dabasov Oct 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/build-zwallet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ jobs:
go-version: '1.21' # The Go version to download (if necessary) and use.

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install
run: make install

- name: 'Upload Artifact'
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: zwallet-linux
path: zwallet
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
go env -w "CC=/mingw64/bin/clang.exe"

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install
run: make install
Expand All @@ -94,7 +94,7 @@ jobs:
zip zwallet-windows.zip zwallet.exe libgcc_s_seh-1.dll libstdc++-6.dll libwinpthread-1.dll

- name: 'Upload Artifact'
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: zwallet-windows.zip
path: zwallet-windows.zip
Expand All @@ -115,13 +115,13 @@ jobs:
go-version: '1.21' # The Go version to download (if necessary) and use.

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install
run: make install

- name: 'Upload Artifact'
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: zwallet-macos
path: zwallet
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/system_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: 0chain/actions/.github/workflows/manual_system_tests.yml@master
with:
zwallet_cli_branch: ${{ github.ref_name }}
repo_snapshots_branch: ${{ github.event.inputs.repo_snapshots_branch }}
repo_snapshots_branch: fix/refactor-zboxcore
test_file_filter: ${{ github.event.inputs.test_file_filter }}
skip_tests: ${{ github.event.inputs.skip_tests }}
run_smoke_tests: ${{ github.event.inputs.run_smoke_tests }}
Expand Down
20 changes: 9 additions & 11 deletions cmd/auth-register.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package cmd

import (
"context"
"log"
"strings"

"github.com/0chain/gosdk/core/transaction"
"github.com/0chain/gosdk/zcnbridge"
"github.com/0chain/gosdk/zcnbridge/transaction"
"github.com/0chain/gosdk/zcncore"
"github.com/pkg/errors"
"log"
"strings"
)

//goland:noinspection ALL
Expand Down Expand Up @@ -91,20 +89,20 @@ func registerAuthorizerInChain(bc *zcnbridge.BridgeClient, args ...*Arg) {
},
}

trx, err := transaction.AddAuthorizer(context.Background(), input)
hash, _, _, txn, err := zcncore.ZCNSCAddAuthorizer(input)
if err != nil {
log.Fatal(err, "failed to add authorizer with transaction: '%s'", trx.GetHash())
log.Fatal(err, "failed to add authorizer with transaction: '%s'", hash)
}

log.Printf("Authorizer submitted OK... " + trx.GetHash())
log.Printf("Starting verification: " + trx.GetHash())
log.Printf("Authorizer submitted OK... " + hash)
log.Printf("Starting verification: " + hash)

err = trx.Verify(context.Background())
txn, err = transaction.VerifyTransaction(hash)
if err != nil {
if strings.Contains(err.Error(), "already exists") {
ExitWithError("Authorizer has already been added to 0Chain... Continue")
} else {
ExitWithError(errors.Wrapf(err, "failed to verify transaction: '%s'", trx.GetHash()))
ExitWithError(errors.Wrapf(err, "failed to verify transaction: '%s'", txn.Hash))
}
}
}
56 changes: 9 additions & 47 deletions cmd/bridge-auth-config-update.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@ package cmd

import (
"fmt"
"log"
"strconv"
"strings"
"sync"

"github.com/0chain/gosdk/core/common"
"github.com/0chain/gosdk/zcncore"
"github.com/spf13/cobra"
"log"
"strconv"
)

var updateAuthorizerConfigCmd = &cobra.Command{
Use: "bridge-auth-config-update",
Short: "Update ZCNSC authorizer settings by ID",
Long: `Update ZCNSC authorizer settings by ID.`,
Args: cobra.MinimumNArgs(0),
Use: "bridge-auth-config-update",
Short: "Update ZCNSC authorizer settings by ID",
Long: `Update ZCNSC authorizer settings by ID.`,
Args: cobra.MinimumNArgs(0),
Hidden: true,
Run: func(cmd *cobra.Command, args []string) {
const (
Expand All @@ -31,6 +28,7 @@ var updateAuthorizerConfigCmd = &cobra.Command{
Fee string
FeeBalance int64
URL string
hash string
err error
)

Expand Down Expand Up @@ -65,46 +63,10 @@ var updateAuthorizerConfigCmd = &cobra.Command{
},
}

var wg sync.WaitGroup
statusBar := &ZCNStatus{wg: &wg}
txn, err := zcncore.NewTransaction(statusBar, getTxnFee(), nonce)
if err != nil {
log.Fatal(err)
}

wg.Add(1)
if err = txn.ZCNSCUpdateAuthorizerConfig(node); err != nil {
if hash, _, _, _, err = zcncore.ZCNSCUpdateAuthorizerConfig(node); err != nil {
log.Fatal(err)
}
wg.Wait()

if !statusBar.success {
log.Fatal("fatal:", statusBar.errMsg)
}

statusBar.success = false
wg.Add(1)
if err = txn.Verify(); err != nil {
log.Fatal(err)
}
wg.Wait()

if statusBar.success {
//fmt.Printf("Nonce:%v\n", txn.GetTransactionNonce())
switch txn.GetVerifyConfirmationStatus() {
case zcncore.ChargeableError:
ExitWithError("\n", strings.Trim(txn.GetVerifyOutput(), "\""))
case zcncore.Success:
fmt.Printf("global settings updated\nHash: %v\n", txn.GetTransactionHash())
default:
ExitWithError("\nExecute global settings update smart contract failed. Unknown status code: " +
strconv.Itoa(int(txn.GetVerifyConfirmationStatus())))
}
return
} else {
log.Fatal("fatal:", statusBar.errMsg)
}

fmt.Printf("global settings updated\nHash: %v\n", hash)
},
}

Expand Down
17 changes: 10 additions & 7 deletions cmd/bridge-auth-config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"encoding/json"
"log"

"github.com/0chain/gosdk/zcnbridge"
Expand All @@ -9,10 +10,10 @@ import (
)

var getAuthorizerConfigCmd = &cobra.Command{
Use: "bridge-auth-config",
Short: "Show authorizer configurations.",
Long: `Show authorizer configurations.`,
Args: cobra.MinimumNArgs(0),
Use: "bridge-auth-config",
Short: "Show authorizer configurations.",
Long: `Show authorizer configurations.`,
Args: cobra.MinimumNArgs(0),
Hidden: true,
Run: func(cmd *cobra.Command, args []string) {
var (
Expand All @@ -31,12 +32,14 @@ var getAuthorizerConfigCmd = &cobra.Command{

var (
response = new(zcnbridge.AuthorizerResponse)
cb = NewJSONInfoCB(response)
res []byte
)
if err = zcnbridge.GetAuthorizer(ID, cb); err != nil {
if res, err = zcnbridge.GetAuthorizer(ID); err != nil {
log.Fatal(err)
}
if err = cb.Waiting(); err != nil {

err = json.Unmarshal(res, response)
if err != nil {
log.Fatal(err)
}

Expand Down
54 changes: 8 additions & 46 deletions cmd/bridge-auth-delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@ package cmd

import (
"fmt"
"log"
"strconv"
"strings"
"sync"

"github.com/0chain/gosdk/zcncore"
"github.com/spf13/cobra"
"log"
)

var deleteAuthorizerConfigCmd = &cobra.Command{
Use: "bridge-auth-delete",
Short: "Delete ZCNSC authorizer by ID",
Long: `Delete ZCNSC authorizer by ID`,
Args: cobra.MinimumNArgs(0),
Use: "bridge-auth-delete",
Short: "Delete ZCNSC authorizer by ID",
Long: `Delete ZCNSC authorizer by ID`,
Args: cobra.MinimumNArgs(0),
Hidden: true,
Run: func(cmd *cobra.Command, args []string) {
const (
Expand All @@ -25,6 +21,7 @@ var deleteAuthorizerConfigCmd = &cobra.Command{
flags = cmd.Flags()
err error
ID string
hash string
)

if flags.Changed(IDFlag) {
Expand All @@ -38,45 +35,10 @@ var deleteAuthorizerConfigCmd = &cobra.Command{
payload := &zcncore.DeleteAuthorizerPayload{
ID: ID,
}
var wg sync.WaitGroup
statusBar := &ZCNStatus{wg: &wg}
txn, err := zcncore.NewTransaction(statusBar, getTxnFee(), nonce)
if err != nil {
log.Fatal(err)
}

wg.Add(1)
if err = txn.ZCNSCDeleteAuthorizer(payload); err != nil {
log.Fatal(err)
}
wg.Wait()

if !statusBar.success {
log.Fatal("fatal:", statusBar.errMsg)
}

statusBar.success = false
wg.Add(1)
if err = txn.Verify(); err != nil {
if hash, _, _, _, err = zcncore.ZCNSCDeleteAuthorizer(payload); err != nil {
log.Fatal(err)
}
wg.Wait()

if statusBar.success {
switch txn.GetVerifyConfirmationStatus() {
case zcncore.ChargeableError:
ExitWithError("\n", strings.Trim(txn.GetVerifyOutput(), "\""))
case zcncore.Success:
fmt.Printf("global settings updated\nHash: %v\n", txn.GetTransactionHash())
default:
ExitWithError("\nExecute global settings update smart contract failed. Unknown status code: " +
strconv.Itoa(int(txn.GetVerifyConfirmationStatus())))
}
return
} else {
log.Fatal("fatal:", statusBar.errMsg)
}

fmt.Printf("global settings updated\nHash: %v\n", hash)
},
}

Expand Down
13 changes: 3 additions & 10 deletions cmd/bridge-burn-zcn.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cmd

import (
"context"
"fmt"

"github.com/0chain/gosdk/zcncore"
Expand All @@ -25,18 +24,12 @@ func commandBurnZCN(b *zcnbridge.BridgeClient, args ...*Arg) {
amount := GetToken(args)

fmt.Println("Starting burn transaction")
transaction, err := b.BurnZCN(context.Background(), zcncore.ConvertToValue(amount), 0)
hash, _, err := b.BurnZCN(zcncore.ConvertToValue(amount))
if err == nil {
fmt.Printf("Submitted burn transaction %s\n", transaction.GetHash())
fmt.Printf("Submitted burn transaction %s\n", hash)
} else {
ExitWithError(err)
}

fmt.Printf("Starting transaction verification %s\n", transaction.GetHash())
err = transaction.Verify(context.Background())
if err != nil {
ExitWithError(err)
}

fmt.Printf("Transaction completed successfully: %s\n", transaction.GetHash())
fmt.Printf("Transaction completed successfully: %s\n", hash)
}
Loading
Loading