-
Notifications
You must be signed in to change notification settings - Fork 670
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved wallet builder backend to pchain
- Loading branch information
Showing
21 changed files
with
284 additions
and
218 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package backends | ||
|
||
import ( | ||
"github.com/ava-labs/avalanchego/ids" | ||
"github.com/ava-labs/avalanchego/vms/components/avax" | ||
"github.com/ava-labs/avalanchego/vms/platformvm/fx" | ||
|
||
stdcontext "context" | ||
) | ||
|
||
var ( | ||
_ BuilderBackend = WalletBackend(nil) | ||
_ SignerBackend = WalletBackend(nil) | ||
) | ||
|
||
type WalletBackend interface { | ||
Context | ||
UTXOs(ctx stdcontext.Context, sourceChainID ids.ID) ([]*avax.UTXO, error) | ||
GetSubnetOwner(ctx stdcontext.Context, subnetID ids.ID) (fx.Owner, error) | ||
GetUTXO(ctx stdcontext.Context, chainID, utxoID ids.ID) (*avax.UTXO, error) | ||
} | ||
|
||
type SignerBackend interface { | ||
GetUTXO(ctx stdcontext.Context, chainID, utxoID ids.ID) (*avax.UTXO, error) | ||
GetSubnetOwner(ctx stdcontext.Context, subnetID ids.ID) (fx.Owner, error) | ||
} | ||
|
||
type BuilderBackend interface { | ||
Context | ||
UTXOs(ctx stdcontext.Context, sourceChainID ids.ID) ([]*avax.UTXO, error) | ||
GetSubnetOwner(ctx stdcontext.Context, subnetID ids.ID) (fx.Owner, error) | ||
} |
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,100 @@ | ||
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package backends | ||
|
||
import "github.com/ava-labs/avalanchego/ids" | ||
|
||
var _ Context = (*builderCtx)(nil) | ||
|
||
type Context interface { | ||
NetworkID() uint32 | ||
AVAXAssetID() ids.ID | ||
BaseTxFee() uint64 | ||
CreateSubnetTxFee() uint64 | ||
TransformSubnetTxFee() uint64 | ||
CreateBlockchainTxFee() uint64 | ||
AddPrimaryNetworkValidatorFee() uint64 | ||
AddPrimaryNetworkDelegatorFee() uint64 | ||
AddSubnetValidatorFee() uint64 | ||
AddSubnetDelegatorFee() uint64 | ||
} | ||
|
||
type builderCtx struct { | ||
networkID uint32 | ||
avaxAssetID ids.ID | ||
baseTxFee uint64 | ||
createSubnetTxFee uint64 | ||
transformSubnetTxFee uint64 | ||
createBlockchainTxFee uint64 | ||
addPrimaryNetworkValidatorFee uint64 | ||
addPrimaryNetworkDelegatorFee uint64 | ||
addSubnetValidatorFee uint64 | ||
addSubnetDelegatorFee uint64 | ||
} | ||
|
||
func NewContext( | ||
networkID uint32, | ||
avaxAssetID ids.ID, | ||
baseTxFee uint64, | ||
createSubnetTxFee uint64, | ||
transformSubnetTxFee uint64, | ||
createBlockchainTxFee uint64, | ||
addPrimaryNetworkValidatorFee uint64, | ||
addPrimaryNetworkDelegatorFee uint64, | ||
addSubnetValidatorFee uint64, | ||
addSubnetDelegatorFee uint64, | ||
) Context { | ||
return &builderCtx{ | ||
networkID: networkID, | ||
avaxAssetID: avaxAssetID, | ||
baseTxFee: baseTxFee, | ||
createSubnetTxFee: createSubnetTxFee, | ||
transformSubnetTxFee: transformSubnetTxFee, | ||
createBlockchainTxFee: createBlockchainTxFee, | ||
addPrimaryNetworkValidatorFee: addPrimaryNetworkValidatorFee, | ||
addPrimaryNetworkDelegatorFee: addPrimaryNetworkDelegatorFee, | ||
addSubnetValidatorFee: addSubnetValidatorFee, | ||
addSubnetDelegatorFee: addSubnetDelegatorFee, | ||
} | ||
} | ||
|
||
func (c *builderCtx) NetworkID() uint32 { | ||
return c.networkID | ||
} | ||
|
||
func (c *builderCtx) AVAXAssetID() ids.ID { | ||
return c.avaxAssetID | ||
} | ||
|
||
func (c *builderCtx) BaseTxFee() uint64 { | ||
return c.baseTxFee | ||
} | ||
|
||
func (c *builderCtx) CreateSubnetTxFee() uint64 { | ||
return c.createSubnetTxFee | ||
} | ||
|
||
func (c *builderCtx) TransformSubnetTxFee() uint64 { | ||
return c.transformSubnetTxFee | ||
} | ||
|
||
func (c *builderCtx) CreateBlockchainTxFee() uint64 { | ||
return c.createBlockchainTxFee | ||
} | ||
|
||
func (c *builderCtx) AddPrimaryNetworkValidatorFee() uint64 { | ||
return c.addPrimaryNetworkValidatorFee | ||
} | ||
|
||
func (c *builderCtx) AddPrimaryNetworkDelegatorFee() uint64 { | ||
return c.addPrimaryNetworkDelegatorFee | ||
} | ||
|
||
func (c *builderCtx) AddSubnetValidatorFee() uint64 { | ||
return c.addSubnetValidatorFee | ||
} | ||
|
||
func (c *builderCtx) AddSubnetDelegatorFee() uint64 { | ||
return c.addSubnetDelegatorFee | ||
} |
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
Oops, something went wrong.