Skip to content
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

feat: add solana send endpoint #1049

Merged
merged 4 commits into from
Sep 27, 2024
Merged

feat: add solana send endpoint #1049

merged 4 commits into from
Sep 27, 2024

Conversation

NeOMakinG
Copy link
Contributor

@NeOMakinG NeOMakinG commented Sep 26, 2024

closes #1031

Description

Added the send endpoint logic:

  • I decided to use the helius SDK because I feel like their custom endpoints will be typed this way, it will be easier for us to respect their types
  • Like other chains, I assumed the TX is signed on client side

Testing

  • You need to sign a TX
import { Transaction, SystemProgram, Connection, PublicKey } from '@solana/web3.js';

 ;(async () => const transaction = new Transaction().add(
    SystemProgram.transfer({
      fromPubkey: publicKey,
      toPubkey: publicKey,
      lamports: 100,
    })
  );
  transaction.feePayer = publicKey;

  const anyTransaction: any = transaction;
  anyTransaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
  
   try {
    const signedTransaction = await provider.signTransaction(transaction);
    console.log(Buffer.from(signedTransaction.serialize()).toString('base64'))
  } catch (error) {
    console.warn(error);
    throw new Error(error.message);
  }
)()

Then use this with the send endpoint (http://api.solana.localhost/api/v1/send)

Screenshots

image

Here is the TX:
https://solscan.io/tx/2yG59F1eughDiEg6R8FkcDe5MVSd2YYqiBeaH1AMX958nMXrLEpVPvgKpCDFwY2Doh6oM7NeHNdSbrcfSbckv8Ps

@NeOMakinG NeOMakinG requested a review from a team as a code owner September 26, 2024 15:46
feat: revert unwanted ignore

fix: remove solana web3js

fix: remove unwanted spaces

fix: lint

fix: moove dependence to solana coinstack
@NeOMakinG NeOMakinG marked this pull request as ready for review September 26, 2024 16:57
@kaladinlight
Copy link
Collaborator

A couple comments:

  • Just to give context for the Service paradigm. The tsoa route registration does not support constructor ags. The service was a way to abstract shared logic between evm/utxo chains and pass args to the class for the specific endpoints/api keys. Seeing as this isn't really the case with solana and we could probably reduce the extra boilerplate and just implement the functions in controller.ts directly.
  • We can use the helius sdk for now and agree it is necessary for typed responses from their api. Note that the connection is just an instance of @solana/web3.js connection and we could use web3 directly for rpc/subscription related things. May not be worth is the heluis sdk is more ergonomic to use though.

@NeOMakinG
Copy link
Contributor Author

A couple comments:

  • Just to give context for the Service paradigm. The tsoa route registration does not support constructor ags. The service was a way to abstract shared logic between evm/utxo chains and pass args to the class for the specific endpoints/api keys. Seeing as this isn't really the case with solana and we could probably reduce the extra boilerplate and just implement the functions in controller.ts directly.
  • We can use the helius sdk for now and agree it is necessary for typed responses from their api. Note that the connection is just an instance of @solana/web3.js connection and we could use web3 directly for rpc/subscription related things. May not be worth is the heluis sdk is more ergonomic to use though.

The helius sdk will be more ergonomic to use because of the in houses endpoints that are not usable with web3js

@kaladinlight kaladinlight merged commit 5fb70d4 into develop Sep 27, 2024
2 checks passed
@kaladinlight kaladinlight deleted the solana-send branch September 27, 2024 16:16
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.

solana send endpoint
2 participants