-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
59 additions
and
13 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
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,47 @@ | ||
import { Connection, Keypair, PublicKey } from '@solana/web3.js'; | ||
import { | ||
configs, | ||
DriftClient, | ||
Wallet, | ||
} from "@drift-labs/sdk"; | ||
|
||
|
||
async function main() { | ||
|
||
const driftConfig = configs['mainnet-beta']; | ||
const connection = new Connection('https://api.mainnet-beta.solana.com'); | ||
|
||
const driftClient = new DriftClient({ | ||
connection: connection, | ||
wallet: new Wallet(new Keypair()), | ||
programID: new PublicKey(driftConfig.DRIFT_PROGRAM_ID), | ||
userStats: true, | ||
env: 'mainnet-beta', | ||
}); | ||
console.log(`driftClientSubscribed: ${await driftClient.subscribe()}`); | ||
|
||
const txHash = "3gvGQufckXGHrFDv4dNWEXuXKRMy3NZkKHMyFrAhLoYScaXXTGCp9vq58kWkfyJ8oDYZrz4bTyGayjUy9PKigeLS"; | ||
|
||
const tx = await driftClient.connection.getParsedTransaction(txHash, { | ||
commitment: "confirmed", | ||
maxSupportedTransactionVersion: 0, | ||
}); | ||
|
||
let logIdx = 0; | ||
// @ts-ignore | ||
for (const event of driftClient.program._events._eventParser.parseLogs(tx!.meta!.logMessages)) { | ||
console.log("----------------------------------------"); | ||
console.log(`Log ${logIdx++}`); | ||
console.log("----------------------------------------"); | ||
console.log(`${JSON.stringify(event, null, 2)}`); | ||
} | ||
|
||
console.log("========================================"); | ||
console.log("Raw transaction logs"); | ||
console.log("========================================"); | ||
console.log(JSON.stringify(tx!.meta!.logMessages, null, 2)); | ||
|
||
process.exit(0); | ||
} | ||
|
||
main().catch(console.error); |
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,3 +1,4 @@ | ||
// | ||
import { expect } from 'chai'; | ||
import { PublicKey, Keypair } from '@solana/web3.js'; | ||
|
||
|
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