-
Notifications
You must be signed in to change notification settings - Fork 270
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
Add svm keypair wallet provider #246
base: master
Are you sure you want to change the base?
Conversation
🟡 Heimdall Review Status
|
0798c31
to
9cb2b3e
Compare
9cb2b3e
to
8e81267
Compare
// Assumes `to` is a hex encoded address that we'll convert to a Solana PublicKey | ||
async nativeTransfer(to: `0x${string}`, value: string): Promise<`0x${string}`> { | ||
const toPubkey = new PublicKey(Buffer.from(to.slice(2), "hex")); |
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 will weaken the WalletProvider#nativeTransfer
abstract method signature to support string
instead of 0x${string}
. It doesn't break anything explicitly yet to weaken the type and I would prefer to have solana feel native from day 0
return { | ||
protocolFamily: SOLANA_PROTOCOL_FAMILY, | ||
chainId: String(SOLANA_MAINNET_CHAIN_ID), | ||
networkId: SOLANA_MAINNET_NETWORK_ID, | ||
}; |
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.
nit: can we make Network
typed objects for each of these and a map from genesisHash
to network object
export const SOLANA_MAINNET_CHAIN_ID = 101; | ||
export const SOLANA_TESTNET_CHAIN_ID = 102; | ||
export const SOLANA_DEVNET_CHAIN_ID = 103; | ||
|
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.
are these standard? Is there a more canonical chain identifier that we can use for solana?
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.
These are not standard - I stole this from ankr, but looks like it differs provider to provider.
Technically the most canonical chain identifier is the result of the getGenesisHash rpc call: solana genesis-hash
.
* @param transaction - The transaction to sign. | ||
* @returns The signed transaction. | ||
*/ | ||
abstract signTransaction(transaction: VersionedTransaction): VersionedTransaction; |
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.
abstract signTransaction(transaction: VersionedTransaction): VersionedTransaction; | |
abstract signTransaction(transaction: VersionedTransaction): Promise<VersionedTransaction>; |
Signing will be async with some wallet provider implementations
typescript/agentkit/src/wallet-providers/solanaKeypairWalletProvider.ts
Outdated
Show resolved
Hide resolved
…ovider.ts Co-authored-by: John Peterson <[email protected]>
What changed? Why?
Add Solana wallet provider abstract class called
svmWalletProvider
in order to pave the way for Solana integration with Coinbase's AgentKit. There is a concrete implementation calledSvmKeypairWalletProvider
that performs the basic functions to implement Solana actions.This PR updates the
WalletProvider
instance fromabstract getNetwork() -> Network
toabstract getNetwork() -> Promise<Network>
in order to support Solana network retrieval, which requires a network request to check genesis hash.Qualified Impact
WalletProvider
interface