-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelius.ts
65 lines (49 loc) · 2.01 KB
/
helius.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const runHeliusGeyser = async () => {
const ws: WebSocket = new WebSocket(HELIUS_GEYSER_URL);
const copyWallets: string[] = Object.keys(await readDataJson("copyWallets.json"));
ws.on('open', async () => {
console.log('WebSocket connection established.');
copyWallets = Object.keys(await readDataJson("copyWallets.json"));
sendRequest(ws, copyWallets);
});
ws.on('message', async function incoming(data: any) {
const messageStr = data.toString('utf8');
const messageObj = JSON.parse(messageStr);
if (!messageObj.params) return;
if (!messageObj.params.result) return;
const result = messageObj.params.result;
const logs = result.transaction.meta.logMessages;
const signer = result.transaction.transaction.message.accountKeys.filter((item: any) => item.signer === true).map((item: any) => item.pubkey).join('');
if (!result || !result.transaction || !result.transaction.meta) {
console.log("Incomplete transaction data.");
return;
}
let targetWallet: string = '';
for (let i = 0; i < copyWallets.length; i++) {
if (messageStr.includes(copyWallets[i])) {
targetWallet = copyWallets[i]
break;
}
}
if (targetWallet === '') return;
if (!result.transaction) {
console.error("Transaction not found");
return;
}
if (messageStr.includes(PUMP_FUN_PROGRAM_ID)) {
// console.log("messageStr", messageStr)
// const PumpFunProgram = new PublicKey("6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P");
await parsePumpFunHeliusTx(result)
} else if (messageStr.includes(RAYDIUM_AMM_PROGRAM_ID)) {
// console.log("messageStr", messageStr)
// await parseRaydiumAmmHeliusTx(result)
} else if (messageStr.includes(RAYDIUM_CPMM_PROGRAM_ID)) {
// await parseRaydiumCpmmHeliusTx(result)
}
// console.log("messageStr", messageStr)
// console.log("messageObj", messageObj)
// const res = await parsePumpFunInstruction(result)
// console.log("res", res)
});
}
runHeliusGeyser()