-
Notifications
You must be signed in to change notification settings - Fork 702
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow P-chain wallet to be used by the platformvm (#3314)
- Loading branch information
1 parent
76f1918
commit bfe9fbb
Showing
8 changed files
with
116 additions
and
90 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
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 p | ||
|
||
import ( | ||
"github.com/ava-labs/avalanchego/vms/platformvm" | ||
"github.com/ava-labs/avalanchego/vms/platformvm/txs" | ||
"github.com/ava-labs/avalanchego/wallet/chain/p/wallet" | ||
"github.com/ava-labs/avalanchego/wallet/subnet/primary/common" | ||
) | ||
|
||
var _ wallet.Client = (*Client)(nil) | ||
|
||
func NewClient( | ||
c platformvm.Client, | ||
b wallet.Backend, | ||
) *Client { | ||
return &Client{ | ||
client: c, | ||
backend: b, | ||
} | ||
} | ||
|
||
type Client struct { | ||
client platformvm.Client | ||
backend wallet.Backend | ||
} | ||
|
||
func (c *Client) IssueTx( | ||
tx *txs.Tx, | ||
options ...common.Option, | ||
) error { | ||
ops := common.NewOptions(options) | ||
ctx := ops.Context() | ||
txID, err := c.client.IssueTx(ctx, tx.Bytes()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if f := ops.PostIssuanceFunc(); f != nil { | ||
f(txID) | ||
} | ||
|
||
if ops.AssumeDecided() { | ||
return c.backend.AcceptTx(ctx, tx) | ||
} | ||
|
||
if err := platformvm.AwaitTxAccepted(c.client, ctx, txID, ops.PollFrequency()); err != nil { | ||
return err | ||
} | ||
|
||
return c.backend.AcceptTx(ctx, tx) | ||
} |
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
2 changes: 1 addition & 1 deletion
2
wallet/chain/p/backend_visitor.go → wallet/chain/p/wallet/backend_visitor.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
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.