-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from elsoul/feature
add getSolTransferDetails
- Loading branch information
Showing
7 changed files
with
66 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,4 +46,5 @@ firebase-debug.log | |
/apps/ | ||
keyfile.json | ||
|
||
/functions/ | ||
/functions/ | ||
/data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
20.3.1 | ||
20.10.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Connection, TransactionSignature } from '@solana/web3.js' | ||
import { | ||
SPLTransferHistoryResponse, | ||
SolTransferDetailsResponse, | ||
SolanaTransaction, | ||
TokenExchange, | ||
} from '..' | ||
|
||
/** | ||
* Fetches the details of a transaction, specifically the token transfer details. | ||
* | ||
* @param rpcUrl - The URL of the Solana RPC endpoint. | ||
* @param signature - The transaction signature. | ||
* @returns {Promise<SolTransferDetailsResponse>} - A promise that resolves with the token transfer details. | ||
* | ||
* @example | ||
* ```typescript | ||
* const rpcUrl = 'https://api.mainnet-beta.solana.com'; | ||
* const signature = '5verv...'; // Example transaction signature | ||
* | ||
* const transferDetails = await getTokenTransferDetails(rpcUrl, signature); | ||
* console.log(transferDetails); | ||
* ``` | ||
*/ | ||
export const getSolTransferDetails = async ( | ||
rpcUrl: string, | ||
signature: TransactionSignature, | ||
) => { | ||
try { | ||
const connection = new Connection(rpcUrl) | ||
|
||
const transactionDetails = (await connection.getParsedTransaction( | ||
signature, | ||
)) as unknown as SolanaTransaction | ||
|
||
const tokenTransferDetails = | ||
transactionDetails.transaction.message.instructions.find( | ||
(instruction) => instruction?.parsed?.type === 'transfer', | ||
)?.parsed?.info | ||
|
||
return tokenTransferDetails as SolTransferDetailsResponse | ||
} catch (error) { | ||
throw new Error(`getSolTransferDetails: ${error}`) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters