ordinalsbot
Advanced tools
Comparing version 0.0.6 to 0.1.0
@@ -1,18 +0,20 @@ | ||
import { OrdinalsBotEnv } from "./types"; | ||
import { OrdinalsBotPriceRequest, OrdinalsBotPriceResponse, OrdinalsBotOrderRequest, OrdinalsBotOrder, OrdinalsBotCollectionCreateRequest, OrdinalsBotCollectionCreateResponse, OrdinalsBotCollectionOrderRequest, OrdinalsBotTextOrderRequest, OrdinalsBotInventoryResponse, OrdinalsBotReferralRequest, OrdinalsBotReferralSetResponse, OrdinalsBotReferralStatusResponse } from "./types/v1"; | ||
export declare class OrdinalsBotClient { | ||
env: OrdinalsBotEnv; | ||
import { AxiosInstance } from "axios"; | ||
import { InscriptionEnv } from "./types"; | ||
import { InscriptionPriceRequest, InscriptionPriceResponse, InscriptionOrderRequest, InscriptionOrder, InscriptionCollectionCreateRequest, InscriptionCollectionCreateResponse, InscriptionCollectionOrderRequest, InscriptionTextOrderRequest, InscriptionInventoryResponse, InscriptionReferralRequest, InscriptionReferralSetResponse, InscriptionReferralStatusResponse } from "./types/v1"; | ||
export declare class InscriptionClient { | ||
env: InscriptionEnv; | ||
private api_key; | ||
private instanceV1; | ||
constructor(key?: string, environment?: OrdinalsBotEnv); | ||
getPrice(priceRequest: OrdinalsBotPriceRequest): Promise<OrdinalsBotPriceResponse>; | ||
createOrder(order: OrdinalsBotOrderRequest): Promise<OrdinalsBotOrder>; | ||
getOrder(id: string): Promise<OrdinalsBotOrder>; | ||
createCollection(collection: OrdinalsBotCollectionCreateRequest): Promise<OrdinalsBotCollectionCreateResponse>; | ||
createCollectionOrder(collectionOrder: OrdinalsBotCollectionOrderRequest): Promise<OrdinalsBotOrder>; | ||
createTextOrder(order: OrdinalsBotTextOrderRequest): Promise<OrdinalsBotOrder>; | ||
getInventory(): Promise<OrdinalsBotInventoryResponse[]>; | ||
setReferralCode(referral: OrdinalsBotReferralRequest): Promise<OrdinalsBotReferralSetResponse>; | ||
getReferralStatus(referral: OrdinalsBotReferralRequest): Promise<OrdinalsBotReferralStatusResponse>; | ||
constructor(key?: string, environment?: InscriptionEnv); | ||
get axiosInstance(): AxiosInstance; | ||
getPrice(priceRequest: InscriptionPriceRequest): Promise<InscriptionPriceResponse>; | ||
createOrder(order: InscriptionOrderRequest): Promise<InscriptionOrder>; | ||
getOrder(id: string): Promise<InscriptionOrder>; | ||
createCollection(collection: InscriptionCollectionCreateRequest): Promise<InscriptionCollectionCreateResponse>; | ||
createCollectionOrder(collectionOrder: InscriptionCollectionOrderRequest): Promise<InscriptionOrder>; | ||
createTextOrder(order: InscriptionTextOrderRequest): Promise<InscriptionOrder>; | ||
getInventory(): Promise<InscriptionInventoryResponse[]>; | ||
setReferralCode(referral: InscriptionReferralRequest): Promise<InscriptionReferralSetResponse>; | ||
getReferralStatus(referral: InscriptionReferralRequest): Promise<InscriptionReferralStatusResponse>; | ||
} | ||
//# sourceMappingURL=client.d.ts.map |
@@ -6,8 +6,9 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OrdinalsBotClient = void 0; | ||
exports.InscriptionClient = void 0; | ||
const axios_1 = __importDefault(require("axios")); | ||
const OrdinalsBotError_1 = require("./OrdinalsBotError"); | ||
const InscriptionError_1 = require("./InscriptionError"); | ||
const qs = require("qs"); | ||
const version = require("../package.json")?.version || "local"; | ||
const packageVersion = `npm-ordinalsbot-v${version}`; | ||
class OrdinalsBotClient { | ||
const packageVersion = `npm-inscription-v${version}`; | ||
class InscriptionClient { | ||
constructor(key = "", environment = "live") { | ||
@@ -23,3 +24,3 @@ this.api_key = key; | ||
headers: { | ||
'x-api-key': this.api_key, | ||
"x-api-key": this.api_key, | ||
Connection: "Keep-Alive", | ||
@@ -33,3 +34,3 @@ "Content-Type": "application/json", | ||
if (axios_1.default.isAxiosError(err)) { | ||
throw new OrdinalsBotError_1.OrdinalsBotError(err.message, err.response?.statusText, err.response?.status); | ||
throw new InscriptionError_1.InscriptionError(err.message, err.response?.statusText, err.response?.status); | ||
} | ||
@@ -44,4 +45,7 @@ if (err instanceof Error) | ||
} | ||
get axiosInstance() { | ||
return this.instanceV1; | ||
} | ||
async getPrice(priceRequest) { | ||
return this.instanceV1.get(`/order`, { | ||
return this.instanceV1.get(`/price`, { | ||
params: priceRequest, | ||
@@ -59,9 +63,30 @@ }); | ||
async createCollection(collection) { | ||
return this.instanceV1.post(`/collection-create`, collection); | ||
let plainObject = Object.assign({ ...collection }); | ||
let files = collection?.files; | ||
for (let index in files) { | ||
let file = files[index]; | ||
let keys = Object.keys(file); | ||
for (let key in keys) { | ||
let propName = keys[key]; | ||
plainObject[`files[${index}][${propName}]`] = file[propName]; | ||
} | ||
} | ||
delete plainObject.files; | ||
let data = qs.stringify(plainObject); | ||
let config = { | ||
method: "post", | ||
maxBodyLength: Infinity, | ||
url: this.instanceV1.getUri() + "/collectioncreate", | ||
headers: { | ||
"Content-Type": "application/x-www-form-urlencoded", | ||
}, | ||
data: data, | ||
}; | ||
return axios_1.default.request(config); | ||
} | ||
async createCollectionOrder(collectionOrder) { | ||
return this.instanceV1.post(`/collection-order`, collectionOrder); | ||
return this.instanceV1.post(`/collectionorder`, collectionOrder); | ||
} | ||
async createTextOrder(order) { | ||
return this.instanceV1.post(`/text-order`, order); | ||
return this.instanceV1.post(`/textorder`, order); | ||
} | ||
@@ -80,3 +105,3 @@ async getInventory() { | ||
} | ||
exports.OrdinalsBotClient = OrdinalsBotClient; | ||
exports.InscriptionClient = InscriptionClient; | ||
//# sourceMappingURL=client.js.map |
@@ -1,15 +0,6 @@ | ||
import { OrdinalsBotEnv, v1 } from "./types"; | ||
export { OrdinalsBotClient } from "./client"; | ||
export { OrdinalsBotError } from "./OrdinalsBotError"; | ||
export { InscriptionClient } from "./client"; | ||
export { InscriptionError } from "./InscriptionError"; | ||
export * from "./types"; | ||
export declare function setCredentials(key?: string, environment?: OrdinalsBotEnv): void; | ||
export declare function getPrice(priceRequest: v1.OrdinalsBotPriceRequest): Promise<v1.OrdinalsBotPriceResponse>; | ||
export declare function createOrder(order: v1.OrdinalsBotOrderRequest): Promise<v1.OrdinalsBotOrder>; | ||
export declare function getOrder(id: string): Promise<v1.OrdinalsBotOrder>; | ||
export declare function createCollection(collection: v1.OrdinalsBotCollectionCreateRequest): Promise<v1.OrdinalsBotCollectionCreateResponse>; | ||
export declare function createCollectionOrder(collectionOrder: v1.OrdinalsBotCollectionOrderRequest): Promise<v1.OrdinalsBotOrder>; | ||
export declare function createTextOrder(order: v1.OrdinalsBotTextOrderRequest): Promise<v1.OrdinalsBotOrder>; | ||
export declare function getInventory(): Promise<v1.OrdinalsBotInventoryResponse[]>; | ||
export declare function setReferralCode(referral: v1.OrdinalsBotReferralRequest): Promise<v1.OrdinalsBotReferralSetResponse>; | ||
export declare function getReferralStatus(referral: v1.OrdinalsBotReferralRequest): Promise<v1.OrdinalsBotReferralStatusResponse>; | ||
export { MarketPlace } from "./marketplace"; | ||
export { Inscription } from "./inscription"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -17,54 +17,12 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getReferralStatus = exports.setReferralCode = exports.getInventory = exports.createTextOrder = exports.createCollectionOrder = exports.createCollection = exports.getOrder = exports.createOrder = exports.getPrice = exports.setCredentials = exports.OrdinalsBotError = exports.OrdinalsBotClient = void 0; | ||
const client_1 = require("./client"); | ||
var client_2 = require("./client"); | ||
Object.defineProperty(exports, "OrdinalsBotClient", { enumerable: true, get: function () { return client_2.OrdinalsBotClient; } }); | ||
var OrdinalsBotError_1 = require("./OrdinalsBotError"); | ||
Object.defineProperty(exports, "OrdinalsBotError", { enumerable: true, get: function () { return OrdinalsBotError_1.OrdinalsBotError; } }); | ||
exports.Inscription = exports.MarketPlace = exports.InscriptionError = exports.InscriptionClient = void 0; | ||
var client_1 = require("./client"); | ||
Object.defineProperty(exports, "InscriptionClient", { enumerable: true, get: function () { return client_1.InscriptionClient; } }); | ||
var InscriptionError_1 = require("./InscriptionError"); | ||
Object.defineProperty(exports, "InscriptionError", { enumerable: true, get: function () { return InscriptionError_1.InscriptionError; } }); | ||
__exportStar(require("./types"), exports); | ||
let instance; | ||
function setCredentials(key = "", environment = "live") { | ||
if (instance !== undefined) { | ||
console.error("ordinalsbot.setCredentials was called multiple times"); | ||
return; | ||
} | ||
instance = new client_1.OrdinalsBotClient(key, environment); | ||
} | ||
exports.setCredentials = setCredentials; | ||
function getPrice(priceRequest) { | ||
return instance.getPrice(priceRequest); | ||
} | ||
exports.getPrice = getPrice; | ||
function createOrder(order) { | ||
return instance.createOrder(order); | ||
} | ||
exports.createOrder = createOrder; | ||
function getOrder(id) { | ||
return instance.getOrder(id); | ||
} | ||
exports.getOrder = getOrder; | ||
function createCollection(collection) { | ||
return instance.createCollection(collection); | ||
} | ||
exports.createCollection = createCollection; | ||
function createCollectionOrder(collectionOrder) { | ||
return instance.createCollectionOrder(collectionOrder); | ||
} | ||
exports.createCollectionOrder = createCollectionOrder; | ||
function createTextOrder(order) { | ||
return instance.createTextOrder(order); | ||
} | ||
exports.createTextOrder = createTextOrder; | ||
function getInventory() { | ||
return instance.getInventory(); | ||
} | ||
exports.getInventory = getInventory; | ||
function setReferralCode(referral) { | ||
return instance.setReferralCode(referral); | ||
} | ||
exports.setReferralCode = setReferralCode; | ||
function getReferralStatus(referral) { | ||
return instance.getReferralStatus(referral); | ||
} | ||
exports.getReferralStatus = getReferralStatus; | ||
var marketplace_1 = require("./marketplace"); | ||
Object.defineProperty(exports, "MarketPlace", { enumerable: true, get: function () { return marketplace_1.MarketPlace; } }); | ||
var inscription_1 = require("./inscription"); | ||
Object.defineProperty(exports, "Inscription", { enumerable: true, get: function () { return inscription_1.Inscription; } }); | ||
//# sourceMappingURL=index.js.map |
export * as v1 from "./v1"; | ||
export type OrdinalsBotEnv = "live" | "dev"; | ||
export type InscriptionEnv = "live" | "dev"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -9,3 +9,3 @@ export interface InscriptionTransaction { | ||
} | ||
export interface OrdinalsBotFile { | ||
export interface InscriptionFile { | ||
size: number; | ||
@@ -18,4 +18,4 @@ type: string; | ||
} | ||
export interface OrdinalsBotOrderRequest { | ||
files: OrdinalsBotFile[]; | ||
export interface InscriptionOrderRequest { | ||
files: InscriptionFile[]; | ||
fee: number; | ||
@@ -30,3 +30,3 @@ lowPostage?: boolean; | ||
} | ||
export interface OrdinalsBotCharge { | ||
export interface InscriptionCharge { | ||
id: string; | ||
@@ -43,11 +43,11 @@ description: string; | ||
address: string; | ||
metadata?: OrdinalsBotChargeMetadata; | ||
metadata?: InscriptionChargeMetadata; | ||
expires_at?: string; | ||
auto_settle?: boolean; | ||
chain_invoice?: OrdinalsBotOnchainInvoice; | ||
transactions?: OrdinalsBotChargeTransaction[]; | ||
chain_invoice?: InscriptionOnchainInvoice; | ||
transactions?: InscriptionChargeTransaction[]; | ||
} | ||
export interface OrdinalsBotOrder extends OrdinalsBotOrderRequest { | ||
export interface InscriptionOrder extends InscriptionOrderRequest { | ||
status: string; | ||
charge: OrdinalsBotCharge; | ||
charge: InscriptionCharge; | ||
chainFee: number; | ||
@@ -58,3 +58,3 @@ serviceFee: number; | ||
} | ||
export interface OrdinalsBotOnchainInvoice { | ||
export interface InscriptionOnchainInvoice { | ||
address: string; | ||
@@ -64,3 +64,3 @@ settled_at: number; | ||
} | ||
export interface OrdinalsBotChargeTransaction { | ||
export interface InscriptionChargeTransaction { | ||
address: string; | ||
@@ -73,7 +73,7 @@ created_at: number; | ||
} | ||
export interface OrdinalsBotChargeMetadata { | ||
export interface InscriptionChargeMetadata { | ||
email: string; | ||
invoice_id: string; | ||
} | ||
export interface OrdinalsBotPriceRequest { | ||
export interface InscriptionPriceRequest { | ||
size: number; | ||
@@ -84,12 +84,12 @@ fee: number; | ||
} | ||
export interface OrdinalsBotPriceResponse { | ||
"status": string; | ||
"chainFee": number; | ||
"baseFee": number; | ||
"serviceFee": number; | ||
"totalFee": number; | ||
export interface InscriptionPriceResponse { | ||
status: string; | ||
chainFee: number; | ||
baseFee: number; | ||
serviceFee: number; | ||
totalFee: number; | ||
} | ||
export interface OrdinalsBotCollectionCreateRequest { | ||
export interface InscriptionCollectionCreateRequest { | ||
id: string; | ||
files: OrdinalsBotFile[]; | ||
files: InscriptionFile[]; | ||
price: number; | ||
@@ -109,12 +109,12 @@ totalCount: number; | ||
} | ||
export interface OrdinalsBotCollectionCreateResponse extends OrdinalsBotCollectionCreateRequest { | ||
export interface InscriptionCollectionCreateResponse extends InscriptionCollectionCreateRequest { | ||
status: string; | ||
createdAt: number; | ||
} | ||
export interface OrdinalsBotCollection { | ||
export interface InscriptionCollection { | ||
id: string; | ||
count: number; | ||
} | ||
export interface OrdinalsBotCollectionOrderRequest { | ||
collection: OrdinalsBotCollection; | ||
export interface InscriptionCollectionOrderRequest { | ||
collection: InscriptionCollection; | ||
token?: string; | ||
@@ -124,3 +124,3 @@ receiveAddress?: string; | ||
} | ||
export interface OrdinalsBotTextOrderRequest { | ||
export interface InscriptionTextOrderRequest { | ||
texts: string[]; | ||
@@ -132,3 +132,3 @@ fee: number; | ||
} | ||
type OrdinalsBotInventoryData = { | ||
type InscriptionInventoryData = { | ||
amount: number; | ||
@@ -140,13 +140,13 @@ baseFee: number; | ||
}; | ||
type OrdinalsBotInventoryItem = { | ||
[specialSatType: string]: OrdinalsBotInventoryData; | ||
type InscriptionInventoryItem = { | ||
[specialSatType: string]: InscriptionInventoryData; | ||
}; | ||
export interface OrdinalsBotInventoryResponse { | ||
[specialSatType: string]: OrdinalsBotInventoryItem; | ||
export interface InscriptionInventoryResponse { | ||
[specialSatType: string]: InscriptionInventoryItem; | ||
} | ||
export interface OrdinalsBotReferralRequest { | ||
export interface InscriptionReferralRequest { | ||
referral: string; | ||
address: string; | ||
} | ||
export interface OrdinalsBotPayout { | ||
export interface InscriptionPayout { | ||
id: string; | ||
@@ -166,7 +166,7 @@ count: number; | ||
} | ||
export interface OrdinalsBotReferralStatusResponse { | ||
export interface InscriptionReferralStatusResponse { | ||
address: string; | ||
orderCound: number; | ||
paidCount: number; | ||
payments?: OrdinalsBotPayout[]; | ||
payments?: InscriptionPayout[]; | ||
orders?: { | ||
@@ -176,3 +176,3 @@ [orderId: string]: true; | ||
} | ||
export interface OrdinalsBotReferralSetResponse { | ||
export interface InscriptionReferralSetResponse { | ||
status: string; | ||
@@ -179,0 +179,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
; | ||
//# sourceMappingURL=v1.js.map |
{ | ||
"name": "ordinalsbot", | ||
"version": "0.0.6", | ||
"version": "0.1.0", | ||
"description": "Node.js library for OrdinalsBot API", | ||
@@ -22,3 +22,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"axios": "^1.3.4" | ||
"axios": "0.27.2", | ||
"uuid": "^9.0.1" | ||
}, | ||
@@ -31,2 +32,4 @@ "devDependencies": { | ||
"pnpm": "^8.6.12", | ||
"qs": "^6.11.2", | ||
"sinon": "^17.0.1", | ||
"typescript": "^4.9.5" | ||
@@ -39,4 +42,7 @@ }, | ||
"api", | ||
"ordinalsbot" | ||
"ordinalsbot", | ||
"inscriptions", | ||
"buy", | ||
"sell" | ||
] | ||
} |
@@ -22,30 +22,44 @@ # OrdinalsBot Node.js Library | ||
## Usage | ||
## Import and intialization | ||
The package needs to be configured with your account's API key which you can get by opening a ticket in our Discord for now. Our developer dashboard is coming soon... | ||
``` js | ||
const ordinalsbot = require('ordinalsbot'); | ||
```js | ||
import { MarketPlace, Inscription } from "ordinalsbot"; | ||
// if no parameter given, default environment is 'live' | ||
// API_KEY only required for creating collection orders | ||
ordinalsbot.setCredentials('MY_API_KEY', 'dev'); | ||
let inscription = new Inscription("API_KEY", "dev"); | ||
let marketplace = new MarketPlace("API_KEY", "dev"); | ||
``` | ||
## Usage | ||
```js | ||
try { | ||
const order = await ordinalsbot.createOrder({ | ||
// create new order | ||
const order = await inscription.createOrder({ | ||
files: [ | ||
{ | ||
size: 10, | ||
type: "plain/text", | ||
name: "my-text-inscription-file.txt", | ||
dataURL: "data:plain/text;base64,dGVzdCBvcmRlcg==", | ||
} | ||
{ | ||
size: 10, | ||
type: "plain/text", | ||
name: "my-text-inscription-file.txt", | ||
dataURL: "data:plain/text;base64,dGVzdCBvcmRlcg==", | ||
}, | ||
], | ||
lowPostage: true, | ||
receiveAddress: "", | ||
fee: 11 | ||
fee: 11, | ||
}); | ||
console.log("Order: ", order); | ||
} catch (error) { | ||
console.error(`${error.status} | ${error.message}`); | ||
console.log("Exception: ", error); | ||
} | ||
try { | ||
// get marketplace listings | ||
const listing = await marketplace.getListing(); | ||
console.log("Marketplaces: ", listing); | ||
} catch (e) { | ||
console.log("Exception: ", e); | ||
} | ||
``` | ||
@@ -59,24 +73,33 @@ | ||
```js | ||
// You can also use import | ||
import ordinalsbot from 'ordinalsbot' | ||
ordinalsbot.setCredentials('', 'dev'); | ||
// Create a new order | ||
ordinalsbot.createOrder({ | ||
// create new order | ||
inscription | ||
.createOrder({ | ||
files: [ | ||
{ | ||
size: 10, | ||
type: "plain/text", | ||
name: "my-text-inscription-file.txt", | ||
dataURL: "data:plain/text;base64,dGVzdCBvcmRlcg==", | ||
} | ||
{ | ||
size: 10, | ||
type: "plain/text", | ||
name: "my-text-inscription-file.txt", | ||
dataURL: "data:plain/text;base64,dGVzdCBvcmRlcg==", | ||
}, | ||
], | ||
lowPostage: true, | ||
receiveAddress: "", | ||
fee: 11 | ||
}).then(order => { | ||
console.log(order); | ||
}).catch(error => { | ||
console.error(`${error.status} | ${error.message}`); | ||
}); | ||
fee: 11, | ||
}) | ||
.then((order) => { | ||
console.log("Order: ", order); | ||
}) | ||
.catch((error) => { | ||
console.log("Exception: ", error); | ||
}); | ||
// get marketplace listings | ||
marketplace | ||
.getListing() | ||
.then((listings) => { | ||
console.log("Order: ", listings); | ||
}) | ||
.catch((error) => { | ||
console.log("Exception: ", error); | ||
}); | ||
``` |
import axios, { AxiosInstance } from "axios"; | ||
import { OrdinalsBotError } from "./OrdinalsBotError"; | ||
import { OrdinalsBotEnv } from "./types"; | ||
import { InscriptionError } from "./InscriptionError"; | ||
import { InscriptionEnv } from "./types"; | ||
import { | ||
OrdinalsBotPriceRequest, | ||
OrdinalsBotPriceResponse, | ||
OrdinalsBotOrderRequest, | ||
OrdinalsBotOrder, | ||
OrdinalsBotCollectionCreateRequest, | ||
OrdinalsBotCollectionCreateResponse, | ||
OrdinalsBotCollectionOrderRequest, | ||
OrdinalsBotTextOrderRequest, | ||
OrdinalsBotInventoryResponse, | ||
OrdinalsBotReferralRequest, | ||
OrdinalsBotReferralSetResponse, | ||
OrdinalsBotReferralStatusResponse, | ||
InscriptionPriceRequest, | ||
InscriptionPriceResponse, | ||
InscriptionOrderRequest, | ||
InscriptionOrder, | ||
InscriptionCollectionCreateRequest, | ||
InscriptionCollectionCreateResponse, | ||
InscriptionCollectionOrderRequest, | ||
InscriptionTextOrderRequest, | ||
InscriptionInventoryResponse, | ||
InscriptionReferralRequest, | ||
InscriptionReferralSetResponse, | ||
InscriptionReferralStatusResponse, | ||
} from "./types/v1"; | ||
const qs = require("qs"); | ||
const version = require("../package.json")?.version || "local"; | ||
const packageVersion = `npm-ordinalsbot-v${version}`; | ||
const packageVersion = `npm-inscription-v${version}`; | ||
export class OrdinalsBotClient { | ||
public env: OrdinalsBotEnv; | ||
export class InscriptionClient { | ||
public env: InscriptionEnv; | ||
@@ -28,3 +29,3 @@ private api_key: string; | ||
constructor(key: string = "", environment: OrdinalsBotEnv = "live") { | ||
constructor(key: string = "", environment: InscriptionEnv = "live") { | ||
this.api_key = key; | ||
@@ -36,8 +37,8 @@ this.env = environment; | ||
baseURL: | ||
environment === "live" | ||
? `https://api.ordinalsbot.com` | ||
: `https://testnet-api.ordinalsbot.com`, | ||
timeout: 30000, | ||
environment === "live" | ||
? `https://api.ordinalsbot.com` | ||
: `https://testnet-api.ordinalsbot.com`, | ||
timeout: 30000, | ||
headers: { | ||
'x-api-key': this.api_key, | ||
"x-api-key": this.api_key, | ||
Connection: "Keep-Alive", | ||
@@ -56,3 +57,3 @@ "Content-Type": "application/json", | ||
// added to keep compatibility with previous versions | ||
throw new OrdinalsBotError( | ||
throw new InscriptionError( | ||
err.message, | ||
@@ -76,4 +77,12 @@ err.response?.statusText, | ||
async getPrice(priceRequest: OrdinalsBotPriceRequest): Promise<OrdinalsBotPriceResponse> { | ||
return this.instanceV1.get(`/order`, { | ||
// exposing the axios instance in case the user wants to use it directly | ||
// This is also useful for testing | ||
get axiosInstance() { | ||
return this.instanceV1; | ||
} | ||
async getPrice( | ||
priceRequest: InscriptionPriceRequest | ||
): Promise<InscriptionPriceResponse> { | ||
return this.instanceV1.get(`/price`, { | ||
params: priceRequest, | ||
@@ -83,7 +92,7 @@ }); | ||
async createOrder(order: OrdinalsBotOrderRequest): Promise<OrdinalsBotOrder> { | ||
async createOrder(order: InscriptionOrderRequest): Promise<InscriptionOrder> { | ||
return this.instanceV1.post(`/order`, order); | ||
} | ||
async getOrder(id: string): Promise<OrdinalsBotOrder> { | ||
async getOrder(id: string): Promise<InscriptionOrder> { | ||
return this.instanceV1.get(`/order`, { | ||
@@ -94,23 +103,57 @@ params: { id }, | ||
async createCollection(collection: OrdinalsBotCollectionCreateRequest): Promise<OrdinalsBotCollectionCreateResponse> { | ||
return this.instanceV1.post(`/collection-create`, collection); | ||
async createCollection( | ||
collection: InscriptionCollectionCreateRequest | ||
): Promise<InscriptionCollectionCreateResponse> { | ||
// modify normal json to valid form data for files | ||
let plainObject = Object.assign({ ...collection }); | ||
let files = collection?.files; | ||
for (let index in files) { | ||
let file: any = files[index]; | ||
let keys = Object.keys(file); | ||
for (let key in keys) { | ||
let propName = keys[key]; | ||
plainObject[`files[${index}][${propName}]`] = file[propName]; | ||
} | ||
} | ||
delete plainObject.files; | ||
let data = qs.stringify(plainObject); | ||
// modify normal json to valid form data for files | ||
let config = { | ||
method: "post", | ||
maxBodyLength: Infinity, | ||
url: this.instanceV1.getUri() + "/collectioncreate", | ||
headers: { | ||
"Content-Type": "application/x-www-form-urlencoded", | ||
}, | ||
data: data, | ||
}; | ||
return axios.request(config); | ||
} | ||
async createCollectionOrder(collectionOrder: OrdinalsBotCollectionOrderRequest): Promise<OrdinalsBotOrder> { | ||
return this.instanceV1.post(`/collection-order`, collectionOrder); | ||
async createCollectionOrder( | ||
collectionOrder: InscriptionCollectionOrderRequest | ||
): Promise<InscriptionOrder> { | ||
return this.instanceV1.post(`/collectionorder`, collectionOrder); | ||
} | ||
async createTextOrder(order: OrdinalsBotTextOrderRequest): Promise<OrdinalsBotOrder> { | ||
return this.instanceV1.post(`/text-order`, order); | ||
async createTextOrder( | ||
order: InscriptionTextOrderRequest | ||
): Promise<InscriptionOrder> { | ||
return this.instanceV1.post(`/textorder`, order); | ||
} | ||
async getInventory(): Promise<OrdinalsBotInventoryResponse[]> { | ||
async getInventory(): Promise<InscriptionInventoryResponse[]> { | ||
return this.instanceV1.get(`/inventory`); | ||
} | ||
async setReferralCode(referral: OrdinalsBotReferralRequest): Promise<OrdinalsBotReferralSetResponse> { | ||
async setReferralCode( | ||
referral: InscriptionReferralRequest | ||
): Promise<InscriptionReferralSetResponse> { | ||
return this.instanceV1.post(`/referrals`, referral); | ||
} | ||
async getReferralStatus(referral: OrdinalsBotReferralRequest): Promise<OrdinalsBotReferralStatusResponse> { | ||
async getReferralStatus( | ||
referral: InscriptionReferralRequest | ||
): Promise<InscriptionReferralStatusResponse> { | ||
return this.instanceV1.get(`/referrals`, { | ||
@@ -120,3 +163,2 @@ params: referral, | ||
} | ||
} | ||
} |
@@ -1,71 +0,5 @@ | ||
import { OrdinalsBotClient } from "./client"; | ||
import { OrdinalsBotEnv, v1 } from "./types"; | ||
export { OrdinalsBotClient } from "./client"; | ||
export { OrdinalsBotError } from "./OrdinalsBotError"; | ||
export { InscriptionClient } from "./client"; | ||
export { InscriptionError } from "./InscriptionError"; | ||
export * from "./types"; | ||
let instance!: OrdinalsBotClient; | ||
export function setCredentials( | ||
key: string = "", | ||
environment: OrdinalsBotEnv = "live" | ||
): void { | ||
if (instance !== undefined) { | ||
console.error( | ||
"ordinalsbot.setCredentials was called multiple times", | ||
); | ||
return; | ||
} | ||
instance = new OrdinalsBotClient(key, environment); | ||
} | ||
export function getPrice( | ||
priceRequest: v1.OrdinalsBotPriceRequest | ||
): Promise<v1.OrdinalsBotPriceResponse> { | ||
return instance.getPrice(priceRequest); | ||
} | ||
export function createOrder( | ||
order: v1.OrdinalsBotOrderRequest | ||
): Promise<v1.OrdinalsBotOrder> { | ||
return instance.createOrder(order); | ||
} | ||
export function getOrder(id: string): Promise<v1.OrdinalsBotOrder> { | ||
return instance.getOrder(id); | ||
} | ||
export function createCollection( | ||
collection: v1.OrdinalsBotCollectionCreateRequest | ||
): Promise<v1.OrdinalsBotCollectionCreateResponse> { | ||
return instance.createCollection(collection); | ||
} | ||
export function createCollectionOrder( | ||
collectionOrder: v1.OrdinalsBotCollectionOrderRequest | ||
): Promise<v1.OrdinalsBotOrder> { | ||
return instance.createCollectionOrder(collectionOrder); | ||
} | ||
export function createTextOrder( | ||
order: v1.OrdinalsBotTextOrderRequest | ||
): Promise<v1.OrdinalsBotOrder> { | ||
return instance.createTextOrder(order); | ||
} | ||
export function getInventory(): Promise<v1.OrdinalsBotInventoryResponse[]> { | ||
return instance.getInventory(); | ||
} | ||
export function setReferralCode( | ||
referral: v1.OrdinalsBotReferralRequest | ||
): Promise<v1.OrdinalsBotReferralSetResponse> { | ||
return instance.setReferralCode(referral); | ||
} | ||
export function getReferralStatus( | ||
referral: v1.OrdinalsBotReferralRequest | ||
): Promise<v1.OrdinalsBotReferralStatusResponse> { | ||
return instance.getReferralStatus(referral); | ||
} | ||
export { MarketPlace } from "./marketplace"; | ||
export { Inscription } from "./inscription"; |
export * as v1 from "./v1"; | ||
export type OrdinalsBotEnv = "live" | "dev"; | ||
export type InscriptionEnv = "live" | "dev"; |
@@ -21,3 +21,3 @@ export interface InscriptionTransaction { | ||
export interface OrdinalsBotFile { | ||
export interface InscriptionFile { | ||
/** Size of the file to be inscribed in bytes */ | ||
@@ -40,6 +40,6 @@ size: number; | ||
tx?: InscriptionTransaction; | ||
}; | ||
} | ||
export interface OrdinalsBotOrderRequest { | ||
files: OrdinalsBotFile[], | ||
export interface InscriptionOrderRequest { | ||
files: InscriptionFile[]; | ||
fee: number; | ||
@@ -50,4 +50,4 @@ | ||
*/ | ||
lowPostage?: boolean, | ||
receiveAddress?: string, | ||
lowPostage?: boolean; | ||
receiveAddress?: string; | ||
@@ -58,6 +58,6 @@ /** Inscribe on a rare, exotic, early sat. | ||
*/ | ||
rareSats?: string, | ||
rareSats?: string; | ||
/** referral code to earn up to %15 of the order service fee. */ | ||
referral?: string, | ||
referral?: string; | ||
@@ -67,3 +67,3 @@ /** Amount of satoshis to charge extra for this order that will be added to "referral" account. | ||
*/ | ||
additionalFee?: number, | ||
additionalFee?: number; | ||
@@ -74,9 +74,9 @@ /* Order timeout in minutes. | ||
*/ | ||
timeout?: number, | ||
timeout?: number; | ||
/** URL to receive a POST request when each file in the order is inscribed */ | ||
webhookUrl?: string, | ||
webhookUrl?: string; | ||
} | ||
export interface OrdinalsBotCharge { | ||
export interface InscriptionCharge { | ||
id: string; | ||
@@ -93,13 +93,13 @@ description: string; | ||
address: string; | ||
metadata?: OrdinalsBotChargeMetadata; | ||
metadata?: InscriptionChargeMetadata; | ||
expires_at?: string; | ||
auto_settle?: boolean; | ||
chain_invoice?: OrdinalsBotOnchainInvoice; | ||
transactions?: OrdinalsBotChargeTransaction[]; | ||
chain_invoice?: InscriptionOnchainInvoice; | ||
transactions?: InscriptionChargeTransaction[]; | ||
} | ||
export interface OrdinalsBotOrder extends OrdinalsBotOrderRequest { | ||
export interface InscriptionOrder extends InscriptionOrderRequest { | ||
status: string; | ||
// ... input parameters from OrdinalsBotOrderRequest | ||
charge: OrdinalsBotCharge; | ||
// ... input parameters from InscriptionOrderRequest | ||
charge: InscriptionCharge; | ||
chainFee: number; // in satoshis | ||
@@ -111,3 +111,3 @@ serviceFee: number; // in satoshis | ||
export interface OrdinalsBotOnchainInvoice { | ||
export interface InscriptionOnchainInvoice { | ||
address: string; | ||
@@ -118,3 +118,3 @@ settled_at: number; | ||
export interface OrdinalsBotChargeTransaction { | ||
export interface InscriptionChargeTransaction { | ||
address: string; | ||
@@ -128,3 +128,3 @@ created_at: number; | ||
export interface OrdinalsBotChargeMetadata { | ||
export interface InscriptionChargeMetadata { | ||
email: string; | ||
@@ -134,3 +134,3 @@ invoice_id: string; | ||
export interface OrdinalsBotPriceRequest { | ||
export interface InscriptionPriceRequest { | ||
/** Total size of all files to be inscribed in bytes */ | ||
@@ -152,14 +152,14 @@ size: number; | ||
export interface OrdinalsBotPriceResponse { | ||
"status": string, | ||
"chainFee": number, // chain fee that will be paid to miners | ||
"baseFee": number, // base service fee taken by ordinalsbot.com | ||
"serviceFee": number, // total service fee taken by ordinalsbot.com | ||
"totalFee": number // total amount to be paid by the user | ||
export interface InscriptionPriceResponse { | ||
status: string; | ||
chainFee: number; // chain fee that will be paid to miners | ||
baseFee: number; // base service fee taken by inscription.com | ||
serviceFee: number; // total service fee taken by inscription.com | ||
totalFee: number; // total amount to be paid by the user | ||
} | ||
export interface OrdinalsBotCollectionCreateRequest { | ||
export interface InscriptionCollectionCreateRequest { | ||
/** URL safe unique collection slug. This will be used as part of mint URL. */ | ||
id: string; | ||
files: OrdinalsBotFile[], | ||
files: InscriptionFile[]; | ||
@@ -174,6 +174,6 @@ // Inscription price per file (for collection creator) set to 0 for free mints | ||
// Inscription service fee per file taken by ordinalsbot.com, min: 27000 (sats) | ||
// Inscription service fee per file taken by inscription.com, min: 27000 (sats) | ||
serviceFee?: number; | ||
// Bitcoin address to receive payouts from inscriptions | ||
"creator-address": string, | ||
"creator-address": string; | ||
@@ -194,9 +194,10 @@ // collection metadata | ||
export interface OrdinalsBotCollectionCreateResponse extends OrdinalsBotCollectionCreateRequest { | ||
export interface InscriptionCollectionCreateResponse | ||
extends InscriptionCollectionCreateRequest { | ||
status: string; | ||
// ... input parameters from OrdinalsBotCollectionCreateRequest | ||
// ... input parameters from InscriptionCollectionCreateRequest | ||
createdAt: number; | ||
} | ||
export interface OrdinalsBotCollection { | ||
export interface InscriptionCollection { | ||
/** unique ID of the collection being requested */ | ||
@@ -209,9 +210,9 @@ id: string; | ||
export interface OrdinalsBotCollectionOrderRequest { | ||
collection: OrdinalsBotCollection, | ||
export interface InscriptionCollectionOrderRequest { | ||
collection: InscriptionCollection; | ||
// cloudflare turnstile token | ||
token?: string, | ||
token?: string; | ||
receiveAddress?: string, | ||
receiveAddress?: string; | ||
@@ -222,7 +223,7 @@ /** Inscribe on a rare, exotic, early sat. | ||
*/ | ||
rareSats?: string, | ||
rareSats?: string; | ||
} | ||
export interface OrdinalsBotTextOrderRequest { | ||
texts: string[], | ||
export interface InscriptionTextOrderRequest { | ||
texts: string[]; | ||
fee: number; | ||
@@ -233,10 +234,10 @@ | ||
*/ | ||
lowPostage?: boolean, | ||
receiveAddress?: string, | ||
lowPostage?: boolean; | ||
receiveAddress?: string; | ||
/** referral code to earn up to %15 of the order service fee. */ | ||
referral?: string, | ||
referral?: string; | ||
} | ||
type OrdinalsBotInventoryData = { | ||
type InscriptionInventoryData = { | ||
// amount of sats available in this inventory | ||
@@ -255,13 +256,13 @@ amount: number; | ||
minSize: number; | ||
} | ||
}; | ||
type OrdinalsBotInventoryItem = { | ||
[specialSatType: string]: OrdinalsBotInventoryData; | ||
} | ||
type InscriptionInventoryItem = { | ||
[specialSatType: string]: InscriptionInventoryData; | ||
}; | ||
export interface OrdinalsBotInventoryResponse { | ||
[specialSatType: string]: OrdinalsBotInventoryItem; | ||
export interface InscriptionInventoryResponse { | ||
[specialSatType: string]: InscriptionInventoryItem; | ||
} | ||
export interface OrdinalsBotReferralRequest { | ||
export interface InscriptionReferralRequest { | ||
referral: string; | ||
@@ -271,3 +272,3 @@ address: string; | ||
export interface OrdinalsBotPayout { | ||
export interface InscriptionPayout { | ||
id: string; | ||
@@ -288,12 +289,12 @@ count: number; | ||
export interface OrdinalsBotReferralStatusResponse { | ||
export interface InscriptionReferralStatusResponse { | ||
address: string; | ||
orderCound: number; | ||
paidCount: number; | ||
payments?: OrdinalsBotPayout[]; | ||
orders?: {[orderId: string]: true}[]; | ||
payments?: InscriptionPayout[]; | ||
orders?: { [orderId: string]: true }[]; | ||
} | ||
export interface OrdinalsBotReferralSetResponse { | ||
export interface InscriptionReferralSetResponse { | ||
status: string; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76992
50
1407
104
2
8
1
+ Addeduuid@^9.0.1
+ Addedaxios@0.27.2(transitive)
+ Addeduuid@9.0.1(transitive)
- Removedaxios@1.7.9(transitive)
- Removedproxy-from-env@1.1.0(transitive)
Updatedaxios@0.27.2