Solana.Swift
Solana.Swift copied to clipboard
Implement Anchor
https://github.com/project-serum/anchor
does this imply that Solana.swift won't currently work with an anchor app?
It will work but won't generate a client. This library has all the buildings blocks
@ajamaica Thanks for your work here everything is very helpful and easy to get up and running.
As far as sending a TransactionInstruction
to the hello world application from the Swift client, do you have any guidance? https://github.com/solana-labs/example-helloworld
EDIT
We want to specifically port this function to Swift, but we aren't sure how to construct the required arguments.
/**
* Say hello
*/
export async function sayHello(): Promise<void> {
console.log('Saying hello to', greetedPubkey.toBase58());
const instruction = new TransactionInstruction({
keys: [{pubkey: greetedPubkey, isSigner: false, isWritable: true}],
programId,
data: Buffer.alloc(0), // All instructions are hellos
});
await sendAndConfirmTransaction(
connection,
new Transaction().add(instruction),
[payer],
);
}
it will translate something like this.
let network = NetworkingRouter(endpoint: .devnetSolana)
let solana = Solana(router: network, accountStorage: self.accountStorage)
let instruction = TransactionInstruction(
keys: [
.init(publicKey: greetedPubkey, isSigner: false, isWritable: true),
],
programId: programId,
data: [0]
)
solana.action.serializeAndSendWithFee(instructions: [instruction], signers: [payer]) { // doSomethingWithResponse() }
I dont know the type of the 0 so I assume is a u8
Edited to match your edit
Does anyone know about how to genereate anchor client for swift?
is it possible to make anchor client from idl?
#150 doesn't fix this entire "implement Anchor" but it's a start. And probably enough tbh. If you want to send instructions to your anchor program it does the job...
Is there still any interest in supporting anchor contracts? There have been no comments on #150 (which I created as draft specifically to garner comments/feedback on the approach) so I'm not really sure how to progress it. I was hoping it could be the first step in an incremental approach to more complete support, but if there's no community interest then I'll just focus on what we need instead.
This is now done here https://github.com/metaplex-foundation/solita-swift