crosslightning-sdk-base
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -38,6 +38,14 @@ import { BTCLNtoSolSwap } from "./BTCLNtoSolSwap"; | ||
/** | ||
* Returns swaps that are in-progress and are claimable that were initiated with the current provider's public key | ||
*/ | ||
getClaimableSwapsSync(): BTCLNtoSolSwap<T>[]; | ||
/** | ||
* Returns all swaps that were initiated with the current provider's public key | ||
*/ | ||
getAllSwaps(): Promise<BTCLNtoSolSwap<T>[]>; | ||
/** | ||
* Returns all swaps that were initiated with the current provider's public key | ||
*/ | ||
getAllSwapsSync(): BTCLNtoSolSwap<T>[]; | ||
stop(): Promise<void>; | ||
} |
@@ -232,2 +232,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
/** | ||
* Returns swaps that are in-progress and are claimable that were initiated with the current provider's public key | ||
*/ | ||
getClaimableSwapsSync() { | ||
if (!this.isInitialized) | ||
throw new Error("Not initialized, call init() first!"); | ||
const returnArr = []; | ||
for (let paymentHash in this.swapData) { | ||
const swap = this.swapData[paymentHash]; | ||
console.log(swap); | ||
if (swap.data.getClaimer() !== this.contract.swapContract.getAddress()) { | ||
continue; | ||
} | ||
const castedSwap = swap; | ||
if (castedSwap.state === BTCxtoSolSwapState.PR_CREATED || castedSwap.state === BTCxtoSolSwapState.CLAIM_CLAIMED || castedSwap.state === BTCxtoSolSwapState.FAILED) { | ||
continue; | ||
} | ||
returnArr.push(castedSwap); | ||
} | ||
return returnArr; | ||
} | ||
/** | ||
* Returns all swaps that were initiated with the current provider's public key | ||
@@ -251,2 +272,19 @@ */ | ||
} | ||
/** | ||
* Returns all swaps that were initiated with the current provider's public key | ||
*/ | ||
getAllSwapsSync() { | ||
if (!this.isInitialized) | ||
throw new Error("Not initialized, call init() first!"); | ||
const returnArr = []; | ||
for (let paymentHash in this.swapData) { | ||
const swap = this.swapData[paymentHash]; | ||
console.log(swap); | ||
if (swap.data.getClaimer() !== this.contract.swapContract.getAddress()) { | ||
continue; | ||
} | ||
returnArr.push(swap); | ||
} | ||
return returnArr; | ||
} | ||
stop() { | ||
@@ -253,0 +291,0 @@ this.chainEvents.unregisterListener(this.listener); |
@@ -39,6 +39,14 @@ import { IBTCxtoSolWrapper } from "../IBTCxtoSolWrapper"; | ||
/** | ||
* Returns swaps that are in-progress and are claimable that were initiated with the current provider's public key | ||
*/ | ||
getClaimableSwapsSync(): BTCtoSolNewSwap<T>[]; | ||
/** | ||
* Returns all swaps that were initiated with the current provider's public key | ||
*/ | ||
getAllSwaps(): Promise<BTCtoSolNewSwap<T>[]>; | ||
/** | ||
* Returns all swaps that were initiated with the current provider's public key | ||
*/ | ||
getAllSwapsSync(): BTCtoSolNewSwap<T>[]; | ||
stop(): Promise<void>; | ||
} |
@@ -215,2 +215,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
/** | ||
* Returns swaps that are in-progress and are claimable that were initiated with the current provider's public key | ||
*/ | ||
getClaimableSwapsSync() { | ||
if (!this.isInitialized) | ||
throw new Error("Not initialized, call init() first!"); | ||
const returnArr = []; | ||
for (let paymentHash in this.swapData) { | ||
const swap = this.swapData[paymentHash]; | ||
console.log(swap); | ||
if (swap.data.getClaimer() !== this.contract.swapContract.getAddress()) { | ||
continue; | ||
} | ||
if (swap.state === BTCtoSolNewSwapState.PR_CREATED && swap.txId == null) { | ||
continue; | ||
} | ||
if (swap.state === BTCtoSolNewSwapState.CLAIM_CLAIMED || swap.state === BTCtoSolNewSwapState.FAILED) { | ||
continue; | ||
} | ||
returnArr.push(swap); | ||
} | ||
return returnArr; | ||
} | ||
/** | ||
* Returns all swaps that were initiated with the current provider's public key | ||
@@ -234,2 +257,19 @@ */ | ||
} | ||
/** | ||
* Returns all swaps that were initiated with the current provider's public key | ||
*/ | ||
getAllSwapsSync() { | ||
if (!this.isInitialized) | ||
throw new Error("Not initialized, call init() first!"); | ||
const returnArr = []; | ||
for (let paymentHash in this.swapData) { | ||
const swap = this.swapData[paymentHash]; | ||
console.log(swap); | ||
if (swap.data.getClaimer() !== this.contract.swapContract.getAddress()) { | ||
continue; | ||
} | ||
returnArr.push(swap); | ||
} | ||
return returnArr; | ||
} | ||
stop() { | ||
@@ -236,0 +276,0 @@ this.chainEvents.unregisterListener(this.listener); |
@@ -47,2 +47,6 @@ /// <reference types="node" /> | ||
/** | ||
* Returns swaps that are refundable and that were initiated with the current provider's public key | ||
*/ | ||
getRefundableSwapsSync(): ISolToBTCxSwap<T>[]; | ||
/** | ||
* Returns all swaps that were initiated with the current provider's public key | ||
@@ -52,2 +56,6 @@ */ | ||
/** | ||
* Returns all swaps that were initiated with the current provider's public key | ||
*/ | ||
getAllSwapsSync(): ISolToBTCxSwap<T>[]; | ||
/** | ||
* Un-subscribes from event listeners on Solana | ||
@@ -54,0 +62,0 @@ */ |
@@ -180,2 +180,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
/** | ||
* Returns swaps that are refundable and that were initiated with the current provider's public key | ||
*/ | ||
getRefundableSwapsSync() { | ||
if (!this.isInitialized) | ||
throw new Error("Not initialized, call init() first!"); | ||
const returnArr = []; | ||
for (let paymentHash in this.swapData) { | ||
const swap = this.swapData[paymentHash]; | ||
console.log(swap); | ||
if (swap.data.getOfferer() !== this.contract.swapContract.getAddress()) { | ||
continue; | ||
} | ||
if (swap.state === SolToBTCxSwapState.REFUNDABLE) { | ||
returnArr.push(swap); | ||
} | ||
} | ||
return returnArr; | ||
} | ||
/** | ||
* Returns all swaps that were initiated with the current provider's public key | ||
@@ -200,2 +219,19 @@ */ | ||
/** | ||
* Returns all swaps that were initiated with the current provider's public key | ||
*/ | ||
getAllSwapsSync() { | ||
if (!this.isInitialized) | ||
throw new Error("Not initialized, call init() first!"); | ||
const returnArr = []; | ||
for (let paymentHash in this.swapData) { | ||
const swap = this.swapData[paymentHash]; | ||
console.log(swap); | ||
if (swap.data.getOfferer() !== this.contract.swapContract.getAddress()) { | ||
continue; | ||
} | ||
returnArr.push(swap); | ||
} | ||
return returnArr; | ||
} | ||
/** | ||
* Un-subscribes from event listeners on Solana | ||
@@ -202,0 +238,0 @@ */ |
{ | ||
"name": "crosslightning-sdk-base", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "CrossLightning SDK chain-agnostic base", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -286,2 +286,33 @@ import {BTCLNtoSolSwap} from "./BTCLNtoSolSwap"; | ||
/** | ||
* Returns swaps that are in-progress and are claimable that were initiated with the current provider's public key | ||
*/ | ||
getClaimableSwapsSync(): BTCLNtoSolSwap<T>[] { | ||
if(!this.isInitialized) throw new Error("Not initialized, call init() first!"); | ||
const returnArr: BTCLNtoSolSwap<T>[] = []; | ||
for(let paymentHash in this.swapData) { | ||
const swap = this.swapData[paymentHash]; | ||
console.log(swap); | ||
if(swap.data.getClaimer()!==this.contract.swapContract.getAddress()) { | ||
continue; | ||
} | ||
const castedSwap = swap as BTCLNtoSolSwap<T>; | ||
if(castedSwap.state===BTCxtoSolSwapState.PR_CREATED || castedSwap.state===BTCxtoSolSwapState.CLAIM_CLAIMED || castedSwap.state===BTCxtoSolSwapState.FAILED) { | ||
continue; | ||
} | ||
returnArr.push(castedSwap); | ||
} | ||
return returnArr; | ||
} | ||
/** | ||
* Returns all swaps that were initiated with the current provider's public key | ||
@@ -311,2 +342,27 @@ */ | ||
/** | ||
* Returns all swaps that were initiated with the current provider's public key | ||
*/ | ||
getAllSwapsSync(): BTCLNtoSolSwap<T>[] { | ||
if(!this.isInitialized) throw new Error("Not initialized, call init() first!"); | ||
const returnArr: BTCLNtoSolSwap<T>[] = []; | ||
for(let paymentHash in this.swapData) { | ||
const swap = this.swapData[paymentHash]; | ||
console.log(swap); | ||
if(swap.data.getClaimer()!==this.contract.swapContract.getAddress()) { | ||
continue; | ||
} | ||
returnArr.push(swap as BTCLNtoSolSwap<T>); | ||
} | ||
return returnArr; | ||
} | ||
stop(): Promise<void> { | ||
@@ -313,0 +369,0 @@ this.chainEvents.unregisterListener(this.listener); |
@@ -251,2 +251,35 @@ import {IBTCxtoSolWrapper} from "../IBTCxtoSolWrapper"; | ||
/** | ||
* Returns swaps that are in-progress and are claimable that were initiated with the current provider's public key | ||
*/ | ||
getClaimableSwapsSync(): BTCtoSolNewSwap<T>[] { | ||
if(!this.isInitialized) throw new Error("Not initialized, call init() first!"); | ||
const returnArr = []; | ||
for(let paymentHash in this.swapData) { | ||
const swap: BTCtoSolNewSwap<T> = this.swapData[paymentHash] as BTCtoSolNewSwap<T>; | ||
console.log(swap); | ||
if(swap.data.getClaimer()!==this.contract.swapContract.getAddress()) { | ||
continue; | ||
} | ||
if(swap.state===BTCtoSolNewSwapState.PR_CREATED && swap.txId==null) { | ||
continue; | ||
} | ||
if(swap.state===BTCtoSolNewSwapState.CLAIM_CLAIMED || swap.state===BTCtoSolNewSwapState.FAILED) { | ||
continue; | ||
} | ||
returnArr.push(swap); | ||
} | ||
return returnArr; | ||
} | ||
/** | ||
* Returns all swaps that were initiated with the current provider's public key | ||
@@ -276,2 +309,27 @@ */ | ||
/** | ||
* Returns all swaps that were initiated with the current provider's public key | ||
*/ | ||
getAllSwapsSync(): BTCtoSolNewSwap<T>[] { | ||
if(!this.isInitialized) throw new Error("Not initialized, call init() first!"); | ||
const returnArr = []; | ||
for(let paymentHash in this.swapData) { | ||
const swap = this.swapData[paymentHash]; | ||
console.log(swap); | ||
if(swap.data.getClaimer()!==this.contract.swapContract.getAddress()) { | ||
continue; | ||
} | ||
returnArr.push(swap); | ||
} | ||
return returnArr; | ||
} | ||
stop(): Promise<void> { | ||
@@ -278,0 +336,0 @@ this.chainEvents.unregisterListener(this.listener); |
@@ -226,2 +226,29 @@ import {ISolToBTCxSwap, SolToBTCxSwapState} from "./ISolToBTCxSwap"; | ||
/** | ||
* Returns swaps that are refundable and that were initiated with the current provider's public key | ||
*/ | ||
getRefundableSwapsSync(): ISolToBTCxSwap<T>[] { | ||
if(!this.isInitialized) throw new Error("Not initialized, call init() first!"); | ||
const returnArr: ISolToBTCxSwap<T>[] = []; | ||
for(let paymentHash in this.swapData) { | ||
const swap = this.swapData[paymentHash]; | ||
console.log(swap); | ||
if(swap.data.getOfferer()!==this.contract.swapContract.getAddress()) { | ||
continue; | ||
} | ||
if(swap.state===SolToBTCxSwapState.REFUNDABLE) { | ||
returnArr.push(swap); | ||
} | ||
} | ||
return returnArr; | ||
} | ||
/** | ||
* Returns all swaps that were initiated with the current provider's public key | ||
@@ -252,2 +279,27 @@ */ | ||
/** | ||
* Returns all swaps that were initiated with the current provider's public key | ||
*/ | ||
getAllSwapsSync(): ISolToBTCxSwap<T>[] { | ||
if(!this.isInitialized) throw new Error("Not initialized, call init() first!"); | ||
const returnArr: ISolToBTCxSwap<T>[] = []; | ||
for(let paymentHash in this.swapData) { | ||
const swap = this.swapData[paymentHash]; | ||
console.log(swap); | ||
if(swap.data.getOfferer()!==this.contract.swapContract.getAddress()) { | ||
continue; | ||
} | ||
returnArr.push(swap); | ||
} | ||
return returnArr; | ||
} | ||
/** | ||
* Un-subscribes from event listeners on Solana | ||
@@ -254,0 +306,0 @@ */ |
431699
9743