Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nimiq/fastspot-api

Package Overview
Dependencies
Maintainers
8
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nimiq/fastspot-api - npm Package Compare versions

Comparing version 1.5.6 to 1.6.0

5

dist/api.d.ts
import { RequestAsset, SwapAsset, Estimate, PreSwap, ContractWithEstimate, Swap, Limits, UserLimits, AssetList } from './types';
export declare function init(url: string, key: string): void;
export declare function init(url: string, key: string, referral?: {
partnerCode: string;
refCode: string;
}): void;
export declare function getEstimate(from: RequestAsset<SwapAsset>, to: SwapAsset): Promise<Estimate>;

@@ -4,0 +7,0 @@ export declare function getEstimate(from: SwapAsset, to: RequestAsset<SwapAsset>): Promise<Estimate>;

16

dist/api.js

@@ -14,3 +14,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

let API_KEY;
export function init(url, key) {
let REFERRAL;
export function init(url, key, referral) {
if (!url || !key)

@@ -20,11 +21,9 @@ throw new Error('url and key must be provided');

API_KEY = key;
REFERRAL = referral;
}
function api(path, method, body) {
function api(path, method, body, headers) {
return __awaiter(this, void 0, void 0, function* () {
if (!API_URL || !API_KEY)
throw new Error('API URL and key not set, call init() first');
const response = yield fetch(`${API_URL}${path}`, Object.assign({ method, headers: {
'Content-Type': 'application/json',
'X-FAST-ApiKey': API_KEY,
} }, (body ? { body: JSON.stringify(body) } : {})));
const response = yield fetch(`${API_URL}${path}`, Object.assign({ method, headers: Object.assign({ 'Content-Type': 'application/json', 'X-FAST-ApiKey': API_KEY }, headers) }, (body ? { body: JSON.stringify(body) } : {})));
if (!response.ok) {

@@ -65,3 +64,6 @@ const error = yield response.json();

includedFees: 'required',
});
}, REFERRAL ? {
'X-S3-Partner-Code': REFERRAL.partnerCode,
'X-S3-Ref-Code': REFERRAL.refCode,
} : undefined);
return convertSwap(result);

@@ -68,0 +70,0 @@ });

@@ -15,3 +15,3 @@ import { SwapAsset, Precision, } from './types';

export function convertFromData(from) {
const asset = SwapAsset[from.symbol];
const asset = from.symbol;
return Object.assign(Object.assign({ asset, amount: coinsToUnits(asset, from.amount), fee: coinsToUnits(asset, from.fundingNetworkFee.total, true) }, (from.fundingNetworkFee.perUnit ? {

@@ -22,3 +22,3 @@ feePerUnit: coinsToUnits(asset, from.fundingNetworkFee.perUnit, true),

export function convertToData(to) {
const asset = SwapAsset[to.symbol];
const asset = to.symbol;
return Object.assign(Object.assign({ asset, amount: coinsToUnits(asset, to.amount), fee: coinsToUnits(asset, to.finalizeNetworkFee.total, true) }, (to.finalizeNetworkFee.perUnit ? {

@@ -25,0 +25,0 @@ feePerUnit: coinsToUnits(asset, to.finalizeNetworkFee.perUnit, true),

@@ -60,3 +60,3 @@ export declare enum SwapAsset {

export declare type FastspotPrice = {
symbol: 'NIM' | 'BTC';
symbol: SwapAsset;
name: string;

@@ -63,0 +63,0 @@ amount: string;

{
"name": "@nimiq/fastspot-api",
"version": "1.5.6",
"version": "1.6.0",
"description": "Typescript library to interact with the Fastspot API",

@@ -5,0 +5,0 @@ "repository": "git@github.com:nimiq/fastspot-api.git",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc