0.0.4 • Published 9 months ago
@frictionless-money/faas v0.0.4
Fees-as-a-Service
Install
npm i @frictionless-money/faas
Example
// main.ts
import { Faas } from "@frictionless-money/faas";
const URL = "https://graphql.frictionless.money/";
const KEY = "???"; // TODO: Fill with your own API key.
async function run() {
const faas: Faas = new Faas(URL, KEY);
const myCredit: Number = await faas.readCredit();
console.log("Available Credit:", myCredit);
}
run().then(() => console.log("Done.")).catch(e => console.log(e));
# Execute
ts-node main.ts
Visit this complete example for more details.
API
export type PSBT = {
owner: string;
asset: string;
id: string;
psbt: string;
state: string;
fee: string[];
timeout: number;
txid?: string;
};
export type PSBTNI = {
owner: string;
asset: string;
id: string;
psbt: string;
state: string;
fee: string[];
timeout: number;
txid: string;
};
export declare const ASSET_BTC: string;
export declare const PAIR_BTC_USD: string;
export declare const STATE_PARTIAL: string;
export declare const STATE_ABORTED: string;
export declare const STATE_FINAL: string;
export declare const STATE_BROADCAST: string;
export declare const STATE_SETTLED: string;
export declare class Faas {
private readonly URL;
private readonly KEY;
private readonly CLIENT;
constructor(url: string, key: string);
url(): string;
key(): string;
readApiKey(): Promise<string>;
readCredit(): Promise<number>;
readFee(asset: string): Promise<number>;
createPSBT(asset: string, psbt: string): Promise<PSBT>;
readPSBT(asset: string, id: string): Promise<PSBT>;
readPSBTs(): Promise<PSBT[]>;
updatePSBT(asset: string, id: string, psbt: string): Promise<PSBT>;
createPSBTNI(asset: string, psbt: string): Promise<PSBTNI>;
readPSBTNI(asset: string, id: string): Promise<PSBTNI>;
readPSBTNIs(): Promise<PSBTNI[]>;
readRate(pair: string): Promise<number>;
}