Skip to content

Conversation

felipemadero
Copy link
Collaborator

Why this should be merged

How this works

How this was tested

How is this documented

"github.com/ava-labs/avalanchego/wallet/subnet/primary/common"
)

func SendTransaction(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I try to be more aligned with TS SDK. Also I believe SendTransaction is somewhat better than Commit.

Copy link
Collaborator Author

@felipemadero felipemadero Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not issues in moving this into wallet, but I have a slight preference for non OOP style, which is also the TS SDK style for this matter

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anyway, we can have both options (if we find out the TS SDK provides both options)

"github.com/ava-labs/avalanche-cli/sdk/wallet"
)

func SignTransaction(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

@felipemadero felipemadero Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move towards TS SDK alignment

@@ -49,6 +50,20 @@ type Ledger struct {
LedgerIndices []uint32
}

func PrivateKeyToAvalancheAccount(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that i think about it, we should create wallet object directly from private key / private key path, no need for intermediary keychain / we can abstract it out

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to align to SDK. they have this account abstraction, very similar to the keychain. Also the function
is there. I believe it is handy. Anyway, not opposite to also having it in wallet. But I would have separate function
for the options:

  • ledger
  • path
  • string

if err != nil {
return err
}
return kc.AddLedgerIndices(indices)
}
return fmt.Errorf("keychain is not ledger enabled")
}

func (kc *Keychain) P(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get address directly from avalanche go Wallet.P() object instead?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that it will be something like

key := wallet.Keychain.Keychain // This gives you access to the underlying key
pAddress, err := key.P(network.HRP) // network.HRP would be "fuji" for testnet, "avax" for mainnet

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Point of consideration: Should this be in wallet object instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the account can have it. Not opposed to also have it on wallet.

@@ -283,12 +283,12 @@ func (m *SoftKey) Save(p string) error {
return os.WriteFile(p, []byte(m.PrivKeyHex()), constants.UserOnlyWriteReadPerms)
}

func (m *SoftKey) P(networkHRP string) (string, error) {
return address.Format("P", networkHRP, m.privKey.PublicKey().Address().Bytes())
func (m *SoftKey) P(network network.Network) (string, error) {
Copy link
Collaborator

@sukantoraymond sukantoraymond Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have this P object, do we need another keychain P chain function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for the key object, it ideally should be used by the keychain in the implementation

Comment on lines 18 to 23
client wallet.Wallet,
subnetIDStr string,
vmIDStr string,
chainName string,
genesis []byte,
subnetAuthKeysStr []string,
Copy link
Collaborator

@sukantoraymond sukantoraymond Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Two arguments as we talked. the wallet and the params


// PrepareCreateChainTx creates uncommitted CreateChainTx
// keychain in wallet will be used to build the transaction
func PrepareCreateChainTx(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also dont think we need to use the same name as typescript SDK. NewCreateChain that we have works better IMO

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok agree

"github.com/ava-labs/avalanchego/utils/formatting/address"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking this should be on wallet

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not understanding the comment

Comment on lines 30 to 37
subnetID, err := ids.FromString(subnetIDStr)
if err != nil {
return nil, fmt.Errorf("error parsing subnet ID: %w", err)
}
vmID, err := ids.FromString(vmIDStr)
if err != nil {
return nil, fmt.Errorf("error parsing vm ID: %w", err)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess in here we are deciding to let user use string instead of ids.ID. Im not opposed to it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok we agree here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants