-
Notifications
You must be signed in to change notification settings - Fork 104
add prepare create subnet and chain tx #2909
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
base: main
Are you sure you want to change the base?
Conversation
"github.com/ava-labs/avalanchego/wallet/subnet/primary/common" | ||
) | ||
|
||
func SendTransaction( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we just move sending transaction to wallet like https://github.com/ava-labs/avalanche-tooling-sdk-go/blob/fef92d1127dc37da50a9307a78663b81a04b971e/wallet/wallet.go#L99?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here about moving it to wallet object https://github.com/ava-labs/avalanche-tooling-sdk-go/blob/fef92d1127dc37da50a9307a78663b81a04b971e/wallet/wallet.go#L99
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we want this? Why don't we just reuse https://github.com/ava-labs/avalanche-tooling-sdk-go/blob/fef92d1127dc37da50a9307a78663b81a04b971e/wallet/p-chain/examples/convertSubnetToL1Tx.go#L51?
It handles ledger too
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
client wallet.Wallet, | ||
subnetIDStr string, | ||
vmIDStr string, | ||
chainName string, | ||
genesis []byte, | ||
subnetAuthKeysStr []string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO our functions should all be just one argument
e.g.
https://github.com/ava-labs/avalanche-tooling-sdk-go/blob/fef92d1127dc37da50a9307a78663b81a04b971e/wallet/p-chain/txs/convertSubnetToL1Tx.go#L17
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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" | ||
) | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not understanding the comment
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) | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok we agree here
Why this should be merged
How this works
How this was tested
How is this documented