UNPKG

ordinalsbot

Version:
142 lines 5.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Inscription = void 0; const client_1 = require("../client"); const types_1 = require("../types"); const sats_connect_1 = require("sats-connect"); class Inscription { constructor(key = "", environment = types_1.InscriptionEnvNetwork.mainnet, options) { if (this.instance !== undefined) { console.error("inscription.setCredentials was called multiple times"); return; } environment = types_1.InscriptionEnvNetwork[environment] ?? types_1.InscriptionEnvNetwork.mainnet; switch (environment) { case types_1.InscriptionEnvNetwork.mainnet: this.network = sats_connect_1.BitcoinNetworkType.Mainnet; break; case types_1.InscriptionEnvNetwork.testnet: this.network = sats_connect_1.BitcoinNetworkType.Testnet; break; case types_1.InscriptionEnvNetwork.signet: this.network = sats_connect_1.BitcoinNetworkType.Signet; break; default: this.network = sats_connect_1.BitcoinNetworkType.Mainnet; break; } this.instance = new client_1.InscriptionClient(key, environment, options); } getPrice(priceRequest) { return this.instance.getPrice(priceRequest); } createOrder(order) { return this.instance.createOrder(order); } getOrder(id) { return this.instance.getOrder(id); } createDirectOrder(order) { return this.instance.createDirectOrder(order); } createCollection(collection) { return this.instance.createCollection(collection); } updateCollectionPhases(collection) { return this.instance.updateCollectionPhases(collection); } getAllocation(allocation) { return this.instance.getAllocation(allocation); } createCollectionOrder(collectionOrder) { return this.instance.createCollectionOrder(collectionOrder); } createTextOrder(order) { return this.instance.createTextOrder(order); } createRunesEtchOrder(order) { return this.instance.createRunesEtchOrder(order); } createRunesMintOrder(order) { return this.instance.createRunesMintOrder(order); } getInventory() { return this.instance.getInventory(); } setReferralCode(referral) { return this.instance.setReferralCode(referral); } getReferralStatus(referral) { return this.instance.getReferralStatus(referral); } async createSpecialSatsPSBT(createSpecialSatsRequest) { if (!createSpecialSatsRequest.walletProvider) { return this.instance.createSpecialSatsPSBT(createSpecialSatsRequest); } const result = await this.instance.createSpecialSatsPSBT(createSpecialSatsRequest); const inputsToSign = [ { address: createSpecialSatsRequest.ordinalAddress, signingIndexes: result.ordinalInputIndices }, { address: createSpecialSatsRequest.paymentAddress, signingIndexes: result.paymentInputIndices }, ]; const payload = { network: { type: this.network }, message: 'Sign Payment Transaction', psbtBase64: result.psbtBase64, broadcast: true, inputsToSign, }; return new Promise((resolve, reject) => { (0, sats_connect_1.signTransaction)({ payload, onFinish: async (response) => { return resolve(response); }, onCancel: () => { console.log('Payment canceled'); } }); }); } async createParentChildPsbt(createParentChildPsbt) { if (!createParentChildPsbt.walletProvider) { return this.instance.createParentChildPsbt(createParentChildPsbt); } const result = await this.instance.createParentChildPsbt(createParentChildPsbt); const inputsToSign = [ { address: createParentChildPsbt.ordinalsAddress, signingIndexes: result.ordinalInputIndices }, { address: createParentChildPsbt.paymentAddress, signingIndexes: result.paymentInputIndices }, ]; const payload = { network: { type: this.network }, message: 'Sign Payment Transaction', psbtBase64: result.psbtBase64, broadcast: true, inputsToSign, }; return new Promise((resolve, reject) => { (0, sats_connect_1.signTransaction)({ payload, onFinish: async (response) => { return resolve(response); }, onCancel: () => { console.log('Payment canceled'); } }); }); } } exports.Inscription = Inscription; //# sourceMappingURL=index.js.map