crosslightning-solana
Advanced tools
Comparing version 3.0.20 to 3.0.21
@@ -120,3 +120,3 @@ "use strict"; | ||
setupWebsocket() { | ||
const eventCallback = (event, slotNumber, signature) => __awaiter(this, void 0, void 0, function* () { | ||
const eventCallback = (event, slotNumber, signature) => { | ||
if (this.signaturesProcessing[signature] != null) | ||
@@ -126,23 +126,30 @@ return; | ||
this.signaturesProcessing[signature] = (() => __awaiter(this, void 0, void 0, function* () { | ||
const transaction = yield this.signer.connection.getTransaction(signature, { | ||
commitment: "confirmed" | ||
}); | ||
if (transaction.meta.err == null) { | ||
//console.log("Process tx: ", transaction.transaction); | ||
//console.log("Decoded ix: ", decodeInstructions(transaction.transaction.message)); | ||
const instructions = this.decodeInstructions(transaction.transaction.message); | ||
const parsedEvents = this.solanaSwapProgram.eventParser.parseLogs(transaction.meta.logMessages); | ||
const events = []; | ||
for (let event of parsedEvents) { | ||
events.push(event); | ||
try { | ||
const transaction = yield this.signer.connection.getTransaction(signature, { | ||
commitment: "confirmed" | ||
}); | ||
if (transaction.meta.err == null) { | ||
//console.log("Process tx: ", transaction.transaction); | ||
//console.log("Decoded ix: ", decodeInstructions(transaction.transaction.message)); | ||
const instructions = this.decodeInstructions(transaction.transaction.message); | ||
const parsedEvents = this.solanaSwapProgram.eventParser.parseLogs(transaction.meta.logMessages); | ||
const events = []; | ||
for (let event of parsedEvents) { | ||
events.push(event); | ||
} | ||
console.log("Instructions: ", instructions); | ||
console.log("Events: ", events); | ||
yield this.processEvent({ | ||
events, | ||
instructions | ||
}); | ||
} | ||
console.log("Instructions: ", instructions); | ||
console.log("Events: ", events); | ||
yield this.processEvent({ | ||
events, | ||
instructions | ||
}); | ||
} | ||
catch (e) { | ||
console.error(e); | ||
return false; | ||
} | ||
return true; | ||
}))(); | ||
}); | ||
}; | ||
this.eventListeners.push(this.solanaSwapProgram.program.addEventListener("InitializeEvent", eventCallback)); | ||
@@ -193,8 +200,6 @@ this.eventListeners.push(this.solanaSwapProgram.program.addEventListener("ClaimEvent", eventCallback)); | ||
if (signatureHandlerPromise != null) { | ||
try { | ||
yield signatureHandlerPromise; | ||
if (yield signatureHandlerPromise) { | ||
lastSuccessfulSignature = txSignature; | ||
continue; | ||
} | ||
catch (e) { } | ||
delete this.signaturesProcessing[txSignature]; | ||
@@ -204,22 +209,29 @@ } | ||
const processPromise = (() => __awaiter(this, void 0, void 0, function* () { | ||
const transaction = yield this.signer.connection.getTransaction(signatures[i].signature, { | ||
commitment: "confirmed" | ||
}); | ||
if (transaction.meta.err == null) { | ||
//console.log("Process tx: ", transaction.transaction); | ||
//console.log("Decoded ix: ", decodeInstructions(transaction.transaction.message)); | ||
const instructions = this.decodeInstructions(transaction.transaction.message); | ||
const parsedEvents = this.solanaSwapProgram.eventParser.parseLogs(transaction.meta.logMessages); | ||
const events = []; | ||
for (let event of parsedEvents) { | ||
events.push(event); | ||
try { | ||
const transaction = yield this.signer.connection.getTransaction(signatures[i].signature, { | ||
commitment: "confirmed" | ||
}); | ||
if (transaction.meta.err == null) { | ||
//console.log("Process tx: ", transaction.transaction); | ||
//console.log("Decoded ix: ", decodeInstructions(transaction.transaction.message)); | ||
const instructions = this.decodeInstructions(transaction.transaction.message); | ||
const parsedEvents = this.solanaSwapProgram.eventParser.parseLogs(transaction.meta.logMessages); | ||
const events = []; | ||
for (let event of parsedEvents) { | ||
events.push(event); | ||
} | ||
console.log("Instructions: ", instructions); | ||
// console.log("Events: ", events); | ||
yield this.processEvent({ | ||
events, | ||
instructions | ||
}); | ||
} | ||
console.log("Instructions: ", instructions); | ||
// console.log("Events: ", events); | ||
yield this.processEvent({ | ||
events, | ||
instructions | ||
}); | ||
lastSuccessfulSignature = txSignature; | ||
} | ||
lastSuccessfulSignature = txSignature; | ||
catch (e) { | ||
console.error(e); | ||
return false; | ||
} | ||
return true; | ||
}))(); | ||
@@ -226,0 +238,0 @@ this.signaturesProcessing[txSignature] = processPromise; |
{ | ||
"name": "crosslightning-solana", | ||
"version": "3.0.20", | ||
"version": "3.0.21", | ||
"description": "Solana specific base implementation", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -161,7 +161,7 @@ import {SolanaSwapData} from "../swaps/SolanaSwapData"; | ||
private signaturesProcessing: { | ||
[signature: string]: Promise<void> | ||
[signature: string]: Promise<boolean> | ||
} = {}; | ||
private setupWebsocket() { | ||
const eventCallback = async (event, slotNumber, signature) => { | ||
const eventCallback = (event, slotNumber, signature) => { | ||
if(this.signaturesProcessing[signature]!=null) return; | ||
@@ -172,24 +172,30 @@ | ||
this.signaturesProcessing[signature] = (async () => { | ||
const transaction = await this.signer.connection.getTransaction(signature, { | ||
commitment: "confirmed" | ||
}); | ||
if(transaction.meta.err==null) { | ||
//console.log("Process tx: ", transaction.transaction); | ||
//console.log("Decoded ix: ", decodeInstructions(transaction.transaction.message)); | ||
const instructions = this.decodeInstructions(transaction.transaction.message); | ||
const parsedEvents = this.solanaSwapProgram.eventParser.parseLogs(transaction.meta.logMessages); | ||
try { | ||
const transaction = await this.signer.connection.getTransaction(signature, { | ||
commitment: "confirmed" | ||
}); | ||
if(transaction.meta.err==null) { | ||
//console.log("Process tx: ", transaction.transaction); | ||
//console.log("Decoded ix: ", decodeInstructions(transaction.transaction.message)); | ||
const instructions = this.decodeInstructions(transaction.transaction.message); | ||
const parsedEvents = this.solanaSwapProgram.eventParser.parseLogs(transaction.meta.logMessages); | ||
const events = []; | ||
for(let event of parsedEvents) { | ||
events.push(event); | ||
} | ||
const events = []; | ||
for(let event of parsedEvents) { | ||
events.push(event); | ||
} | ||
console.log("Instructions: ", instructions); | ||
console.log("Events: ", events); | ||
console.log("Instructions: ", instructions); | ||
console.log("Events: ", events); | ||
await this.processEvent({ | ||
events, | ||
instructions | ||
}); | ||
await this.processEvent({ | ||
events, | ||
instructions | ||
}); | ||
} | ||
} catch (e) { | ||
console.error(e); | ||
return false; | ||
} | ||
return true; | ||
})(); | ||
@@ -246,9 +252,8 @@ }; | ||
const signatureHandlerPromise: Promise<void> = this.signaturesProcessing[txSignature]; | ||
const signatureHandlerPromise: Promise<boolean> = this.signaturesProcessing[txSignature]; | ||
if(signatureHandlerPromise!=null) { | ||
try { | ||
await signatureHandlerPromise; | ||
if(await signatureHandlerPromise) { | ||
lastSuccessfulSignature = txSignature; | ||
continue; | ||
} catch (e) {} | ||
} | ||
delete this.signaturesProcessing[txSignature]; | ||
@@ -259,27 +264,33 @@ } | ||
const processPromise = (async () => { | ||
const transaction = await this.signer.connection.getTransaction(signatures[i].signature, { | ||
commitment: "confirmed" | ||
}); | ||
if(transaction.meta.err==null) { | ||
//console.log("Process tx: ", transaction.transaction); | ||
//console.log("Decoded ix: ", decodeInstructions(transaction.transaction.message)); | ||
const instructions = this.decodeInstructions(transaction.transaction.message); | ||
const parsedEvents = this.solanaSwapProgram.eventParser.parseLogs(transaction.meta.logMessages); | ||
const processPromise: Promise<boolean> = (async () => { | ||
try { | ||
const transaction = await this.signer.connection.getTransaction(signatures[i].signature, { | ||
commitment: "confirmed" | ||
}); | ||
if(transaction.meta.err==null) { | ||
//console.log("Process tx: ", transaction.transaction); | ||
//console.log("Decoded ix: ", decodeInstructions(transaction.transaction.message)); | ||
const instructions = this.decodeInstructions(transaction.transaction.message); | ||
const parsedEvents = this.solanaSwapProgram.eventParser.parseLogs(transaction.meta.logMessages); | ||
const events = []; | ||
for(let event of parsedEvents) { | ||
events.push(event); | ||
const events = []; | ||
for(let event of parsedEvents) { | ||
events.push(event); | ||
} | ||
console.log("Instructions: ", instructions); | ||
// console.log("Events: ", events); | ||
await this.processEvent({ | ||
events, | ||
instructions | ||
}); | ||
} | ||
console.log("Instructions: ", instructions); | ||
// console.log("Events: ", events); | ||
await this.processEvent({ | ||
events, | ||
instructions | ||
}); | ||
lastSuccessfulSignature = txSignature; | ||
} catch (e) { | ||
console.error(e); | ||
return false; | ||
} | ||
lastSuccessfulSignature = txSignature; | ||
return true; | ||
})(); | ||
@@ -286,0 +297,0 @@ this.signaturesProcessing[txSignature] = processPromise; |
349807
8243