@nimiq/fastspot-api
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -1,2 +0,2 @@ | ||
import { RequestAsset, SwapAsset, Estimate, PreSwap, ContractWithEstimate, Swap, Limits, AssetList } from './types'; | ||
import { RequestAsset, SwapAsset, Estimate, PreSwap, ContractWithEstimate, Swap, Limits, UserLimits, AssetList } from './types'; | ||
export declare function init(url: string, key: string): void; | ||
@@ -21,3 +21,3 @@ export declare function getEstimate(from: RequestAsset<SwapAsset>, to: SwapAsset): Promise<Estimate>; | ||
asset: SwapAsset.EUR; | ||
}): Promise<Swap>; | ||
}, uid?: string): Promise<Swap>; | ||
export declare function getSwap(id: string): Promise<PreSwap | Swap>; | ||
@@ -27,2 +27,3 @@ export declare function cancelSwap(swap: PreSwap): Promise<PreSwap>; | ||
export declare function getLimits<T extends SwapAsset>(asset: T, address: string): Promise<Limits<T>>; | ||
export declare function getUserLimits(uid: string): Promise<UserLimits>; | ||
export declare function getAssets(): Promise<AssetList>; |
import { SwapAsset, } from './types'; | ||
import { validateRequestPairs, convertFromData, convertToData, convertContract, convertSwap, convertLimits, coinsToUnits, } from './helpers'; | ||
import { validateRequestPairs, convertFromData, convertToData, convertContract, convertSwap, convertLimits, convertUserLimits, coinsToUnits, } from './helpers'; | ||
let API_URL; | ||
@@ -55,3 +55,3 @@ let API_KEY; | ||
} | ||
export async function confirmSwap(swap, redeem, refund) { | ||
export async function confirmSwap(swap, redeem, refund, uid) { | ||
const result = await api(`/swaps/${swap.id}`, 'POST', { | ||
@@ -68,2 +68,3 @@ confirm: true, | ||
refund: { [refund.asset]: 'address' in refund ? refund.address : '' }, | ||
...(uid ? { uid } : {}), | ||
}); | ||
@@ -93,2 +94,6 @@ return convertSwap(result); | ||
} | ||
export async function getUserLimits(uid) { | ||
const result = await api(`/limits/${uid}`, 'GET'); | ||
return convertUserLimits(result); | ||
} | ||
export async function getAssets() { | ||
@@ -95,0 +100,0 @@ const result = await api('/assets', 'GET'); |
@@ -1,2 +0,2 @@ | ||
import { RequestAsset, SwapAsset, ReferenceAsset, PriceData, FastspotPrice, FastspotContract, FastspotPreSwap, FastspotSwap, FastspotLimits, Contract, PreSwap, Swap, Limits } from './types'; | ||
import { RequestAsset, SwapAsset, ReferenceAsset, PriceData, FastspotPrice, FastspotContract, FastspotPreSwap, FastspotSwap, FastspotLimits, FastspotUserLimits, Contract, PreSwap, Swap, Limits, UserLimits } from './types'; | ||
export declare function coinsToUnits(asset: SwapAsset | ReferenceAsset, value: string | number, roundUp?: boolean): number; | ||
@@ -9,2 +9,3 @@ export declare function convertFromData(from: FastspotPrice): PriceData; | ||
export declare function convertLimits<T extends SwapAsset>(limits: FastspotLimits<T>): Limits<T>; | ||
export declare function convertUserLimits(limits: FastspotUserLimits): UserLimits; | ||
export declare function validateRequestPairs(from: SwapAsset | RequestAsset<SwapAsset>, to: SwapAsset | RequestAsset<SwapAsset>): boolean; |
@@ -127,2 +127,10 @@ import { SwapAsset, ReferenceAsset, } from './types'; | ||
} | ||
export function convertUserLimits(limits) { | ||
return { | ||
asset: limits.asset, | ||
current: coinsToUnits(limits.asset, limits.current), | ||
daily: coinsToUnits(limits.asset, limits.daily), | ||
monthly: coinsToUnits(limits.asset, limits.monthly), | ||
}; | ||
} | ||
export function validateRequestPairs(from, to) { | ||
@@ -129,0 +137,0 @@ let fromAsset; |
@@ -103,3 +103,9 @@ export declare enum SwapAsset { | ||
}; | ||
export declare type FastspotResult = FastspotAsset[] | FastspotEstimate[] | FastspotSwap | FastspotContractWithEstimate<SwapAsset> | FastspotLimits<SwapAsset>; | ||
export declare type FastspotUserLimits = { | ||
asset: ReferenceAsset; | ||
current: string; | ||
daily: string; | ||
monthly: string; | ||
}; | ||
export declare type FastspotResult = FastspotAsset[] | FastspotEstimate[] | FastspotSwap | FastspotContractWithEstimate<SwapAsset> | FastspotLimits<SwapAsset> | FastspotUserLimits; | ||
export declare type FastspotError = { | ||
@@ -187,1 +193,7 @@ status: number; | ||
}; | ||
export declare type UserLimits = { | ||
asset: ReferenceAsset; | ||
current: number; | ||
daily: number; | ||
monthly: number; | ||
}; |
{ | ||
"name": "@nimiq/fastspot-api", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Typescript library to interact with the Fastspot API", | ||
@@ -5,0 +5,0 @@ "repository": "git@github.com:nimiq/fastspot-api.git", |
30307
540