-
Notifications
You must be signed in to change notification settings - Fork 675
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b378cf
commit 2b624ab
Showing
20 changed files
with
680 additions
and
82 deletions.
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
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
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
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
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
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
54 changes: 54 additions & 0 deletions
54
wallet/subnet/primary/examples/disable-subnet-validator/main.go
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,54 @@ | ||
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"time" | ||
|
||
"github.com/ava-labs/avalanchego/genesis" | ||
"github.com/ava-labs/avalanchego/ids" | ||
"github.com/ava-labs/avalanchego/vms/secp256k1fx" | ||
"github.com/ava-labs/avalanchego/wallet/subnet/primary" | ||
) | ||
|
||
func main() { | ||
key := genesis.EWOQKey | ||
uri := primary.LocalAPIURI | ||
kc := secp256k1fx.NewKeychain(key) | ||
validationID := ids.FromStringOrPanic("9FAftNgNBrzHUMMApsSyV6RcFiL9UmCbvsCu28xdLV2mQ7CMo") | ||
|
||
ctx := context.Background() | ||
|
||
// MakeWallet fetches the available UTXOs owned by [kc] on the network that | ||
// [uri] is hosting and registers [subnetID]. | ||
walletSyncStartTime := time.Now() | ||
wallet, err := primary.MakeWallet(ctx, &primary.WalletConfig{ | ||
URI: uri, | ||
AVAXKeychain: kc, | ||
EthKeychain: kc, | ||
ValidationIDs: []ids.ID{validationID}, | ||
}) | ||
if err != nil { | ||
log.Fatalf("failed to initialize wallet: %s\n", err) | ||
} | ||
log.Printf("synced wallet in %s\n", time.Since(walletSyncStartTime)) | ||
|
||
// Get the P-chain wallet | ||
pWallet := wallet.P() | ||
|
||
disableSubnetValidatorStartTime := time.Now() | ||
disableSubnetValidatorTx, err := pWallet.IssueDisableSubnetValidatorTx( | ||
validationID, | ||
) | ||
if err != nil { | ||
log.Fatalf("failed to issue disable subnet validator transaction: %s\n", err) | ||
} | ||
log.Printf("disabled %s with %s in %s\n", | ||
validationID, | ||
disableSubnetValidatorTx.ID(), | ||
time.Since(disableSubnetValidatorStartTime), | ||
) | ||
} |
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,56 @@ | ||
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"time" | ||
|
||
"github.com/ava-labs/avalanchego/genesis" | ||
"github.com/ava-labs/avalanchego/ids" | ||
"github.com/ava-labs/avalanchego/vms/secp256k1fx" | ||
"github.com/ava-labs/avalanchego/wallet/subnet/primary" | ||
) | ||
|
||
func main() { | ||
key := genesis.EWOQKey | ||
uri := primary.LocalAPIURI | ||
kc := secp256k1fx.NewKeychain(key) | ||
validationID := ids.FromStringOrPanic("9FAftNgNBrzHUMMApsSyV6RcFiL9UmCbvsCu28xdLV2mQ7CMo") | ||
balance := uint64(2) | ||
|
||
ctx := context.Background() | ||
|
||
// MakeWallet fetches the available UTXOs owned by [kc] on the network that | ||
// [uri] is hosting and registers [subnetID]. | ||
walletSyncStartTime := time.Now() | ||
wallet, err := primary.MakeWallet(ctx, &primary.WalletConfig{ | ||
URI: uri, | ||
AVAXKeychain: kc, | ||
EthKeychain: kc, | ||
}) | ||
if err != nil { | ||
log.Fatalf("failed to initialize wallet: %s\n", err) | ||
} | ||
log.Printf("synced wallet in %s\n", time.Since(walletSyncStartTime)) | ||
|
||
// Get the P-chain wallet | ||
pWallet := wallet.P() | ||
|
||
increaseBalanceStartTime := time.Now() | ||
increaseBalanceTx, err := pWallet.IssueIncreaseBalanceTx( | ||
validationID, | ||
balance, | ||
) | ||
if err != nil { | ||
log.Fatalf("failed to issue increase balance transaction: %s\n", err) | ||
} | ||
log.Printf("increased balance of validationID %s by %d with %s in %s\n", | ||
validationID, | ||
balance, | ||
increaseBalanceTx.ID(), | ||
time.Since(increaseBalanceStartTime), | ||
) | ||
} |
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
Oops, something went wrong.