ordinalsbot
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -1,2 +0,2 @@ | ||
import { MarketplaceConfirmPaddingOutputsRequest, MarketplaceConfirmPaddingOutputsResponse, MarketplaceCreateListingRequest, MarketplaceCreateListingResponse, MarketplaceCreateOfferRequest, MarketplaceCreateOfferResponse, MarketplaceSetupPaddingOutputsRequest, MarketplaceSetupPaddingOutputsResponse, MarketplaceCreateRequest, MarketplaceCreateResponse, MarketplaceGetListingResponse, MarketplaceSubmitOfferRequest, MarketplaceSubmitOfferResponse, MarketplaceGetListingRequest, MarketplaceSaveListingRequest, MarketplaceSaveListingResponse, MarketplaceTransferRequest, MarketplaceTransferResponse } from "./types/marketplace_types"; | ||
import { MarketplaceConfirmPaddingOutputsRequest, MarketplaceConfirmPaddingOutputsResponse, MarketplaceCreateListingRequest, MarketplaceCreateListingResponse, MarketplaceCreateOfferRequest, MarketplaceCreateOfferResponse, MarketplaceSetupPaddingOutputsRequest, MarketplaceSetupPaddingOutputsResponse, MarketplaceCreateRequest, MarketplaceCreateResponse, MarketplaceGetListingResponse, MarketplaceSubmitOfferRequest, MarketplaceSubmitOfferResponse, MarketplaceGetListingRequest, MarketplaceSaveListingRequest, MarketplaceSaveListingResponse, MarketplaceTransferRequest, MarketplaceTransferAPIResponse, MarketplaceConfirmListingRequest, MarketplaceConfirmListingResponse, MarketplaceReListingRequest, MarketplaceReListingResponse, MarketplaceConfirmReListRequest, MarketplaceConfirmReListResponse, MarketplaceDeListRequest, MarketplaceDeListAPIResponse } from "./types/marketplace_types"; | ||
import { InscriptionEnv } from "./types"; | ||
@@ -16,4 +16,8 @@ export declare class MarketPlaceClient { | ||
saveListing(saveListingRequest: MarketplaceSaveListingRequest): Promise<MarketplaceSaveListingResponse>; | ||
transfer(transferRequest: MarketplaceTransferRequest): Promise<MarketplaceTransferResponse>; | ||
confirmListing(confirmListingRequest: MarketplaceConfirmListingRequest): Promise<MarketplaceConfirmListingResponse>; | ||
reListing(reListingRequest: MarketplaceReListingRequest): Promise<MarketplaceReListingResponse>; | ||
confirmReListing(confirmReListRequest: MarketplaceConfirmReListRequest): Promise<MarketplaceConfirmReListResponse>; | ||
deList(deListRequest: MarketplaceDeListRequest): Promise<MarketplaceDeListAPIResponse>; | ||
transfer(transferRequest: MarketplaceTransferRequest): Promise<MarketplaceTransferAPIResponse>; | ||
} | ||
//# sourceMappingURL=marketplace_client.d.ts.map |
@@ -77,2 +77,22 @@ "use strict"; | ||
} | ||
async confirmListing(confirmListingRequest) { | ||
return this.instanceV1.post(`/confirm-listing`, { | ||
...confirmListingRequest, | ||
}); | ||
} | ||
async reListing(reListingRequest) { | ||
return this.instanceV1.post(`/relist`, { | ||
...reListingRequest, | ||
}); | ||
} | ||
async confirmReListing(confirmReListRequest) { | ||
return this.instanceV1.post(`/confirm-relist`, { | ||
...confirmReListRequest, | ||
}); | ||
} | ||
async deList(deListRequest) { | ||
return this.instanceV1.post(`/delist`, { | ||
...deListRequest, | ||
}); | ||
} | ||
async transfer(transferRequest) { | ||
@@ -79,0 +99,0 @@ return this.instanceV1.post(`/transfer-ordinal`, { |
import { InscriptionEnv } from "./types"; | ||
import { MarketplaceConfirmPaddingOutputsRequest, MarketplaceConfirmPaddingOutputsResponse, MarketplaceCreateListingRequest, MarketplaceCreateListingResponse, MarketplaceCreateOfferRequest, MarketplaceCreateOfferResponse, MarketplaceSetupPaddingOutputsRequest, MarketplaceSetupPaddingOutputsResponse, MarketplaceCreateRequest, MarketplaceCreateResponse, MarketplaceGetListingResponse, MarketplaceSubmitOfferRequest, MarketplaceSubmitOfferResponse, MarketplaceGetListingRequest, MarketplaceSaveListingRequest, MarketplaceSaveListingResponse, MarketplaceTransferRequest, MarketplaceTransferResponse } from "./types/marketplace_types"; | ||
import { MarketplaceConfirmPaddingOutputsRequest, MarketplaceConfirmPaddingOutputsResponse, MarketplaceCreateListingRequest, MarketplaceCreateListingResponse, MarketplaceCreateOfferRequest, MarketplaceCreateOfferResponse, MarketplaceSetupPaddingOutputsRequest, MarketplaceSetupPaddingOutputsResponse, MarketplaceCreateRequest, MarketplaceCreateResponse, MarketplaceGetListingResponse, MarketplaceSubmitOfferRequest, MarketplaceSubmitOfferResponse, MarketplaceGetListingRequest, MarketplaceSaveListingRequest, MarketplaceSaveListingResponse, MarketplaceTransferRequest, MarketplaceTransferAPIResponse, MarketplaceConfirmListingRequest, MarketplaceConfirmListingResponse, MarketplaceReListingRequest, MarketplaceReListingResponse, MarketplaceConfirmReListResponse, MarketplaceConfirmReListRequest, MarketplaceDeListRequest, MarketplaceDeListAPIResponse } from "./types/marketplace_types"; | ||
import { SignTransactionResponse } from 'sats-connect'; | ||
export declare class MarketPlace { | ||
@@ -8,3 +9,4 @@ private network; | ||
createMarketplace(createMarketplaceRequest: MarketplaceCreateRequest): Promise<MarketplaceCreateResponse>; | ||
createListing(createListingRequest: MarketplaceCreateListingRequest): Promise<MarketplaceCreateListingResponse | MarketplaceSaveListingResponse>; | ||
createListing(createListingRequest: MarketplaceCreateListingRequest): Promise<MarketplaceCreateListingResponse | MarketplaceConfirmListingResponse>; | ||
reListing(reListingRequest: MarketplaceReListingRequest): Promise<MarketplaceReListingResponse | MarketplaceConfirmReListResponse>; | ||
createOffer(createOfferRequest: MarketplaceCreateOfferRequest): Promise<MarketplaceCreateOfferResponse | string>; | ||
@@ -16,4 +18,7 @@ submitOffer(submitOfferRequest: MarketplaceSubmitOfferRequest): Promise<MarketplaceSubmitOfferResponse>; | ||
saveListing(saveListingRequest: MarketplaceSaveListingRequest): Promise<MarketplaceSaveListingResponse>; | ||
transfer(transferRequest: MarketplaceTransferRequest): Promise<MarketplaceTransferResponse>; | ||
confirmListing(confirmListingRequest: MarketplaceConfirmListingRequest): Promise<MarketplaceConfirmListingResponse>; | ||
confirmReListing(confirmReListingRequest: MarketplaceConfirmReListRequest): Promise<MarketplaceConfirmReListResponse>; | ||
transfer(transferRequest: MarketplaceTransferRequest): Promise<SignTransactionResponse | MarketplaceTransferAPIResponse>; | ||
deList(deListingRequest: MarketplaceDeListRequest): Promise<MarketplaceDeListAPIResponse | SignTransactionResponse>; | ||
} | ||
//# sourceMappingURL=marketplace.d.ts.map |
@@ -53,5 +53,6 @@ "use strict"; | ||
} | ||
const inputIndices = createListingRequest.sellerOrdinals.map((item, index) => index); | ||
const sellerInput = { | ||
address: createListingRequest.sellerOrdinalAddress, | ||
signingIndexes: [0], | ||
signingIndexes: inputIndices, | ||
sigHash: bitcoin.Transaction.SIGHASH_SINGLE | | ||
@@ -72,15 +73,11 @@ bitcoin.Transaction.SIGHASH_ANYONECANPAY, | ||
try { | ||
console.log('Transaction signed'); | ||
console.log('Response:', response); | ||
const listingId = createListingRequest.sellerOrdinals[0].id; | ||
if (!listingId) { | ||
throw new Error('No listing ID provided'); | ||
} | ||
const updateListingData = { | ||
const sellerOrdinalIds = createListingRequest.sellerOrdinals.map((item, index) => item.id); | ||
const confirmListingPayload = { | ||
sellerOrdinals: sellerOrdinalIds, | ||
signedListingPSBT: response.psbtBase64, | ||
}; | ||
resolve(this.saveListing({ ordinalId: listingId, updateListingData })); | ||
resolve(this.confirmListing(confirmListingPayload)); | ||
} | ||
catch (error) { | ||
console.error('Error saving listing:', error); | ||
console.error('Error confirm listing:', error); | ||
reject(error); | ||
@@ -104,2 +101,56 @@ } | ||
} | ||
async reListing(reListingRequest) { | ||
try { | ||
if (!reListingRequest.walletProvider) { | ||
return await this.marketplaceInstance.reListing(reListingRequest); | ||
} | ||
else if (reListingRequest.walletProvider === marketplace_types_1.WALLET_PROVIDER.xverse) { | ||
const { psbt } = await this.marketplaceInstance.reListing(reListingRequest); | ||
if (!reListingRequest.sellerOrdinalAddress) { | ||
throw new Error('No seller address provided'); | ||
} | ||
const sellerInput = { | ||
address: reListingRequest.sellerOrdinalAddress, | ||
signingIndexes: [0], | ||
sigHash: bitcoin.Transaction.SIGHASH_SINGLE | | ||
bitcoin.Transaction.SIGHASH_ANYONECANPAY, | ||
}; | ||
const payload = { | ||
network: { type: this.network }, | ||
message: 'Sign Seller Transaction', | ||
psbtBase64: psbt, | ||
broadcast: false, | ||
inputsToSign: [sellerInput], | ||
}; | ||
return new Promise((resolve, reject) => { | ||
(0, sats_connect_1.signTransaction)({ | ||
payload, | ||
onFinish: async (response) => { | ||
try { | ||
const confirmReListingPayload = { | ||
ordinalId: reListingRequest.ordinalId, | ||
signedListingPSBT: response.psbtBase64, | ||
}; | ||
resolve(this.confirmReListing(confirmReListingPayload)); | ||
} | ||
catch (error) { | ||
console.error('Error confirm relisting:', error); | ||
reject(error); | ||
} | ||
}, | ||
onCancel: () => { | ||
console.log('Transaction canceled'); | ||
} | ||
}); | ||
}); | ||
} | ||
else { | ||
throw new Error("Wallet not supported"); | ||
} | ||
} | ||
catch (error) { | ||
console.error('Error in reListing:', error); | ||
throw error; | ||
} | ||
} | ||
async createOffer(createOfferRequest) { | ||
@@ -185,2 +236,8 @@ if (!createOfferRequest.walletProvider) { | ||
} | ||
confirmListing(confirmListingRequest) { | ||
return this.marketplaceInstance.confirmListing(confirmListingRequest); | ||
} | ||
confirmReListing(confirmReListingRequest) { | ||
return this.marketplaceInstance.confirmReListing(confirmReListingRequest); | ||
} | ||
async transfer(transferRequest) { | ||
@@ -213,3 +270,5 @@ if (!transferRequest.walletProvider) { | ||
payload, | ||
onFinish: async (response) => response, | ||
onFinish: async (response) => { | ||
return resolve(response); | ||
}, | ||
onCancel: () => { | ||
@@ -221,4 +280,40 @@ console.log('Transaction canceled'); | ||
} | ||
async deList(deListingRequest) { | ||
if (!deListingRequest.walletProvider) { | ||
return this.marketplaceInstance.deList(deListingRequest); | ||
} | ||
const transferResponse = await this.marketplaceInstance.deList(deListingRequest); | ||
const inputsToSign = [ | ||
{ | ||
address: deListingRequest.senderOrdinalAddress, | ||
signingIndexes: transferResponse.senderOrdinalInputs, | ||
sigHash: bitcoin.Transaction.SIGHASH_ALL, | ||
}, | ||
{ | ||
address: deListingRequest.senderPaymentAddress, | ||
signingIndexes: transferResponse.senderPaymentInputs, | ||
sigHash: bitcoin.Transaction.SIGHASH_ALL, | ||
}, | ||
]; | ||
const payload = { | ||
network: { type: this.network }, | ||
message: 'Sign Transfer Transaction', | ||
psbtBase64: transferResponse.psbtBase64, | ||
broadcast: true, | ||
inputsToSign, | ||
}; | ||
return new Promise((resolve, reject) => { | ||
(0, sats_connect_1.signTransaction)({ | ||
payload, | ||
onFinish: async (response) => { | ||
return resolve(response); | ||
}, | ||
onCancel: () => { | ||
console.log('Transaction canceled'); | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
exports.MarketPlace = MarketPlace; | ||
//# sourceMappingURL=marketplace.js.map |
@@ -96,4 +96,15 @@ export declare enum LISTING_STATUS { | ||
} | ||
export interface MarketplaceConfirmListingRequest { | ||
sellerOrdinals: Array<string>; | ||
signedListingPSBT: string; | ||
} | ||
export interface MarketplaceConfirmListingResponse { | ||
message: string; | ||
} | ||
export interface TransferOrdinal { | ||
ordinalId?: string; | ||
receiverOrdinalAddress: number | string; | ||
} | ||
export interface MarketplaceTransferRequest { | ||
ordinals: Array<string>; | ||
transfer: Array<string>; | ||
senderPaymentAddress: string; | ||
@@ -103,6 +114,5 @@ senderPaymentPublicKey: string; | ||
senderOrdinalAddress: string; | ||
receiverOrdinalAddress: string; | ||
walletProvider?: string; | ||
} | ||
export interface MarketplaceTransferResponse { | ||
export interface MarketplaceTransferAPIResponse { | ||
psbtBase64: string; | ||
@@ -112,2 +122,36 @@ senderOrdinalInputs: Array<number>; | ||
} | ||
export interface SignTransactionResponse { | ||
psbtBase64: string; | ||
txId: string; | ||
} | ||
export interface MarketplaceReListingRequest { | ||
ordinalId: string; | ||
price: number; | ||
sellerPaymentAddress?: string; | ||
sellerOrdinalPublicKey?: string; | ||
sellerOrdinalAddress?: string; | ||
walletProvider?: string; | ||
} | ||
export interface MarketplaceReListingResponse { | ||
psbt: string; | ||
} | ||
export interface MarketplaceConfirmReListRequest { | ||
ordinalId: string; | ||
signedListingPSBT: string; | ||
} | ||
export interface MarketplaceConfirmReListResponse { | ||
message: string; | ||
} | ||
export interface MarketplaceDeListRequest { | ||
ordinalId: string; | ||
senderPaymentAddress: string; | ||
senderPaymentPublicKey: string; | ||
senderOrdinalAddress: string; | ||
walletProvider?: string; | ||
} | ||
export interface MarketplaceDeListAPIResponse { | ||
psbtBase64: string; | ||
senderOrdinalInputs: Array<number>; | ||
senderPaymentInputs: Array<number>; | ||
} | ||
//# sourceMappingURL=marketplace_types.d.ts.map |
{ | ||
"name": "ordinalsbot", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Node.js library for OrdinalsBot API", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"test": "pnpm build && nyc mocha", | ||
"test": "pnpm build && nyc mocha 'test/**/*.js'", | ||
"build": "rm -rf dist/ && tsc", | ||
@@ -9,0 +9,0 @@ "prepack": "pnpm build" |
@@ -21,3 +21,11 @@ import axios, { AxiosInstance } from "axios"; | ||
MarketplaceTransferRequest, | ||
MarketplaceTransferResponse, | ||
MarketplaceTransferAPIResponse, | ||
MarketplaceConfirmListingRequest, | ||
MarketplaceConfirmListingResponse, | ||
MarketplaceReListingRequest, | ||
MarketplaceReListingResponse, | ||
MarketplaceConfirmReListRequest, | ||
MarketplaceConfirmReListResponse, | ||
MarketplaceDeListRequest, | ||
MarketplaceDeListAPIResponse, | ||
} from "./types/marketplace_types"; | ||
@@ -139,5 +147,62 @@ import { InscriptionEnv } from "./types"; | ||
/** | ||
* Confirms a listing in the marketplace. | ||
* @param {MarketplaceConfirmListingRequest} confirmListingRequest - The request object for confirming the listing. | ||
* @returns {Promise<MarketplaceSaveListingResponse>} A promise that resolves with the response from confirming the listing. | ||
*/ | ||
async confirmListing( | ||
confirmListingRequest: MarketplaceConfirmListingRequest | ||
): Promise<MarketplaceConfirmListingResponse> { | ||
return this.instanceV1.post(`/confirm-listing`, { | ||
...confirmListingRequest, | ||
}) | ||
} | ||
/** | ||
* Relisting an existing listing ordinal in the marketplace. | ||
* @param {MarketplaceReListingRequest} reListingRequest - The request object for reListing. | ||
* @returns {Promise<MarketplaceReListingResponse>} A promise that resolves with the response from relisting. | ||
*/ | ||
async reListing( | ||
reListingRequest: MarketplaceReListingRequest | ||
): Promise<MarketplaceReListingResponse> { | ||
return this.instanceV1.post(`/relist`, { | ||
...reListingRequest, | ||
}); | ||
} | ||
/** | ||
* Confirms relisting in the marketplace. | ||
* @param {MarketplaceConfirmReListRequest} confirmReListRequest - The request object for confirming the listing. | ||
* @returns {Promise<MarketplaceConfirmReListResponse>} A promise that resolves with the response from confirming the listing. | ||
*/ | ||
async confirmReListing( | ||
confirmReListRequest: MarketplaceConfirmReListRequest | ||
): Promise<MarketplaceConfirmReListResponse> { | ||
return this.instanceV1.post(`/confirm-relist`, { | ||
...confirmReListRequest, | ||
}) | ||
} | ||
/** | ||
* deListing the ordinal from marketplace and transfer back to the seller ordinal address. | ||
* @param {MarketplaceDeListRequest} deListRequest - The request object for deListing. | ||
* @returns {Promise<MarketplaceDeListAPIResponse>} A promise that resolves with the response from deListing. | ||
*/ | ||
async deList( | ||
deListRequest: MarketplaceDeListRequest | ||
): Promise<MarketplaceDeListAPIResponse> { | ||
return this.instanceV1.post(`/delist`, { | ||
...deListRequest, | ||
}); | ||
} | ||
/** | ||
* transfer the ordinal to another ordinal address. | ||
* @param {MarketplaceTransferRequest} transferRequest - The request object for transfer. | ||
* @returns {Promise<MarketplaceTransferAPIResponse>} A promise that resolves with the response from transfer. | ||
*/ | ||
async transfer( | ||
transferRequest: MarketplaceTransferRequest | ||
): Promise<MarketplaceTransferResponse> { | ||
): Promise<MarketplaceTransferAPIResponse> { | ||
return this.instanceV1.post(`/transfer-ordinal`, { | ||
@@ -144,0 +209,0 @@ ...transferRequest, |
@@ -21,9 +21,16 @@ import { MarketPlaceClient } from "./marketplace_client"; | ||
MarketplaceTransferRequest, | ||
MarketplaceTransferResponse, | ||
MarketplaceTransferAPIResponse, | ||
WALLET_PROVIDER, | ||
MarketplaceConfirmListingRequest, | ||
MarketplaceConfirmListingResponse, | ||
MarketplaceReListingRequest, | ||
MarketplaceReListingResponse, | ||
MarketplaceConfirmReListResponse, | ||
MarketplaceConfirmReListRequest, | ||
MarketplaceDeListRequest, | ||
MarketplaceDeListAPIResponse | ||
} from "./types/marketplace_types"; | ||
import * as bitcoin from 'bitcoinjs-lib'; | ||
import * as ecc from '@bitcoin-js/tiny-secp256k1-asmjs'; | ||
import { BitcoinNetworkType, getAddress, signTransaction } from 'sats-connect'; | ||
import { BitcoinNetworkType, SignTransactionResponse, signTransaction } from 'sats-connect'; | ||
@@ -48,5 +55,10 @@ export class MarketPlace { | ||
/** | ||
* Create a new listing on the marketplace. | ||
* @param {MarketplaceCreateListingRequest} createListingRequest The request object containing information about the listing. | ||
* @returns {Promise<MarketplaceCreateListingResponse | MarketplaceConfirmListingResponse>} A promise that resolves to either a create listing response or a confirm listing response. | ||
*/ | ||
async createListing( | ||
createListingRequest: MarketplaceCreateListingRequest | ||
): Promise<MarketplaceCreateListingResponse | MarketplaceSaveListingResponse> { | ||
): Promise<MarketplaceCreateListingResponse | MarketplaceConfirmListingResponse> { | ||
try { | ||
@@ -61,5 +73,7 @@ if (!createListingRequest.walletProvider) { | ||
} | ||
const inputIndices = createListingRequest.sellerOrdinals.map((item, index) => index); | ||
const sellerInput = { | ||
address: createListingRequest.sellerOrdinalAddress, | ||
signingIndexes: [0], | ||
signingIndexes: inputIndices, | ||
sigHash: | ||
@@ -83,14 +97,13 @@ bitcoin.Transaction.SIGHASH_SINGLE | | ||
try { | ||
console.log('Transaction signed'); | ||
console.log('Response:', response); | ||
const listingId = createListingRequest.sellerOrdinals[0].id; | ||
if (!listingId) { | ||
throw new Error('No listing ID provided'); | ||
// ordinal ids to confirm the listing | ||
const sellerOrdinalIds = createListingRequest.sellerOrdinals.map((item, index) => item.id) | ||
const confirmListingPayload: MarketplaceConfirmListingRequest = { | ||
sellerOrdinals: sellerOrdinalIds as string[], | ||
signedListingPSBT: response.psbtBase64, | ||
} | ||
const updateListingData = { | ||
signedListingPSBT: response.psbtBase64, | ||
}; | ||
resolve(this.saveListing({ ordinalId: listingId, updateListingData })); | ||
resolve(this.confirmListing(confirmListingPayload)); | ||
} catch (error) { | ||
console.error('Error saving listing:', error); | ||
console.error('Error confirm listing:', error); | ||
reject(error); | ||
@@ -113,2 +126,63 @@ } | ||
/** | ||
* Updated price for a exisiting listing on the marketplace. | ||
* @param {MarketplaceReListingRequest} reListingRequest The request object containing information about the listing. | ||
* @returns {Promise<MarketplaceReListingResponse | MarketplaceConfirmReListResponse>} A promise that resolves to either a create listing response or a confirm listing response. | ||
*/ | ||
async reListing( | ||
reListingRequest: MarketplaceReListingRequest | ||
): Promise<MarketplaceReListingResponse | MarketplaceConfirmReListResponse> { | ||
try { | ||
if (!reListingRequest.walletProvider) { | ||
return await this.marketplaceInstance.reListing(reListingRequest); | ||
} else if (reListingRequest.walletProvider === WALLET_PROVIDER.xverse) { | ||
const { psbt } = await this.marketplaceInstance.reListing(reListingRequest); | ||
// Create the payload for signing the seller transaction | ||
if (!reListingRequest.sellerOrdinalAddress) { | ||
throw new Error('No seller address provided'); | ||
} | ||
const sellerInput = { | ||
address: reListingRequest.sellerOrdinalAddress, | ||
signingIndexes: [0], | ||
sigHash: | ||
bitcoin.Transaction.SIGHASH_SINGLE | | ||
bitcoin.Transaction.SIGHASH_ANYONECANPAY, | ||
}; | ||
const payload = { | ||
network: { type: this.network }, | ||
message: 'Sign Seller Transaction', | ||
psbtBase64: psbt, | ||
broadcast: false, | ||
inputsToSign: [sellerInput], | ||
}; | ||
return new Promise((resolve, reject) => { | ||
signTransaction({ | ||
payload, | ||
onFinish: async (response) => { | ||
try { | ||
const confirmReListingPayload = { | ||
ordinalId: reListingRequest.ordinalId, | ||
signedListingPSBT: response.psbtBase64, | ||
} | ||
resolve(this.confirmReListing(confirmReListingPayload)); | ||
} catch (error) { | ||
console.error('Error confirm relisting:', error); | ||
reject(error); | ||
} | ||
}, | ||
onCancel: () => { | ||
console.log('Transaction canceled'); | ||
} | ||
}); | ||
}); | ||
} else { | ||
throw new Error("Wallet not supported"); | ||
} | ||
} catch (error) { | ||
console.error('Error in reListing:', error); | ||
throw error; | ||
} | ||
} | ||
@@ -215,5 +289,27 @@ async createOffer( | ||
/** | ||
* Confirms a listing in the marketplace. | ||
* @param {MarketplaceConfirmListingRequest} confirmListingRequest - The request object for confirming the listing. | ||
* @returns {Promise<MarketplaceConfirmListingResponse>} A promise that resolves with the response from confirming the listing. | ||
*/ | ||
confirmListing( | ||
confirmListingRequest: MarketplaceConfirmListingRequest | ||
): Promise<MarketplaceConfirmListingResponse> { | ||
return this.marketplaceInstance.confirmListing(confirmListingRequest) | ||
} | ||
/** | ||
* Confirms relisting in the marketplace. | ||
* @param {MarketplaceConfirmReListRequest} confirmReListingRequest - The request object for confirming the listing. | ||
* @returns {Promise<MarketplaceConfirmReListResponse>} A promise that resolves with the response from confirming the listing. | ||
*/ | ||
confirmReListing( | ||
confirmReListingRequest: MarketplaceConfirmReListRequest | ||
): Promise<MarketplaceConfirmReListResponse> { | ||
return this.marketplaceInstance.confirmReListing(confirmReListingRequest) | ||
} | ||
async transfer( | ||
transferRequest: MarketplaceTransferRequest | ||
): Promise<MarketplaceTransferResponse> { | ||
): Promise<SignTransactionResponse | MarketplaceTransferAPIResponse> { | ||
if (!transferRequest.walletProvider) { | ||
@@ -224,3 +320,3 @@ return this.marketplaceInstance.transfer( | ||
} | ||
const transferResponse: MarketplaceTransferResponse = await this.marketplaceInstance.transfer(transferRequest); | ||
const transferResponse: MarketplaceTransferAPIResponse = await this.marketplaceInstance.transfer(transferRequest); | ||
const inputsToSign = [ | ||
@@ -251,3 +347,5 @@ { | ||
payload, | ||
onFinish: async (response) => response, | ||
onFinish: async (response: any) => { | ||
return resolve(response) | ||
}, | ||
onCancel: () => { | ||
@@ -259,2 +357,51 @@ console.log('Transaction canceled'); | ||
} | ||
/** | ||
* DeLists the listed ordinal from marketplace | ||
* @param {MarketplaceDeListRequest} deListingRequest - The request object for confirming the listing. | ||
* @returns {Promise<MarketplaceDeListAPIResponse>} A promise that resolves with the response from confirming the listing. | ||
*/ | ||
async deList( | ||
deListingRequest: MarketplaceDeListRequest | ||
): Promise<MarketplaceDeListAPIResponse | SignTransactionResponse> { | ||
if (!deListingRequest.walletProvider) { | ||
return this.marketplaceInstance.deList( | ||
deListingRequest | ||
); | ||
} | ||
const transferResponse: MarketplaceDeListAPIResponse = await this.marketplaceInstance.deList(deListingRequest); | ||
const inputsToSign = [ | ||
{ | ||
address: deListingRequest.senderOrdinalAddress, | ||
signingIndexes: transferResponse.senderOrdinalInputs, | ||
sigHash: bitcoin.Transaction.SIGHASH_ALL, | ||
}, | ||
{ | ||
address: deListingRequest.senderPaymentAddress, | ||
signingIndexes: transferResponse.senderPaymentInputs, | ||
sigHash: bitcoin.Transaction.SIGHASH_ALL, | ||
}, | ||
]; | ||
// Create the payload for signing the seller transaction | ||
const payload = { | ||
network: { type: this.network }, | ||
message: 'Sign Transfer Transaction', | ||
psbtBase64: transferResponse.psbtBase64, | ||
broadcast: true, | ||
inputsToSign, | ||
}; | ||
return new Promise((resolve, reject) => { | ||
signTransaction({ | ||
payload, | ||
onFinish: async (response: any) => { | ||
return resolve(response) | ||
}, | ||
onCancel: () => { | ||
console.log('Transaction canceled'); | ||
} | ||
}); | ||
}); | ||
} | ||
} |
@@ -172,5 +172,42 @@ export enum LISTING_STATUS { | ||
/** | ||
* Request object for confirming a listing in the marketplace. | ||
*/ | ||
export interface MarketplaceConfirmListingRequest { | ||
/** | ||
* An array of ordinals for the listings to be confirmed. | ||
*/ | ||
sellerOrdinals: Array<string>; | ||
/** | ||
* The PSBT (Partially Signed Bitcoin Transaction) for the confirmed listing. | ||
*/ | ||
signedListingPSBT: string; | ||
} | ||
/** | ||
* Response object for confirming a listing in the marketplace. | ||
*/ | ||
export interface MarketplaceConfirmListingResponse { | ||
/** | ||
* A message indicating the result of the confirmation operation. | ||
*/ | ||
message: string; | ||
} | ||
/** | ||
* transfer object. | ||
*/ | ||
export interface TransferOrdinal { | ||
/** Ordinal id for the ordinal to be transfer. */ | ||
ordinalId?: string; | ||
/** The receiver ordinal address to whom the ordinal will be send. */ | ||
receiverOrdinalAddress: number | string; | ||
} | ||
/** | ||
* Request object for transfer ordinals. | ||
*/ | ||
export interface MarketplaceTransferRequest { | ||
/** An array with a single ordinal object */ | ||
ordinals: Array<string>; | ||
transfer: Array<string>; | ||
@@ -188,6 +225,3 @@ /** The sender's payment address */ | ||
senderOrdinalAddress: string; | ||
/** The receiver's ordinal address */ | ||
receiverOrdinalAddress: string; | ||
/** Wallet Provider name */ | ||
@@ -197,3 +231,6 @@ walletProvider?: string; | ||
export interface MarketplaceTransferResponse { | ||
/** | ||
* Response object for transfer API. | ||
*/ | ||
export interface MarketplaceTransferAPIResponse { | ||
/** base64 transaction to be signed */ | ||
@@ -208,1 +245,102 @@ psbtBase64: string; | ||
} | ||
/** | ||
* Response object for sign transaction. | ||
*/ | ||
export interface SignTransactionResponse { | ||
/** base64 transaction to be signed */ | ||
psbtBase64: string; | ||
/** transaction id of the transfer */ | ||
txId: string; | ||
} | ||
/** | ||
* Request object for relist ordinal. | ||
*/ | ||
export interface MarketplaceReListingRequest { | ||
/** existing listing ordinal id for relist */ | ||
ordinalId: string; | ||
/** updated price for ordinal */ | ||
price:number | ||
/** The address to receive the sale proceeds when the ordinal is sold. This will be part of the sale transaction that the buyer will sign */ | ||
sellerPaymentAddress?: string; | ||
/** The public key for the wallet address that owns the ordinal being listed for sale */ | ||
sellerOrdinalPublicKey?: string; | ||
/** The Oridnal Address that owns the ordinal being listed for sale */ | ||
sellerOrdinalAddress?: string; | ||
/** Wallet Provider name */ | ||
walletProvider?: string; | ||
} | ||
/** | ||
* Response object for relist ordinal. | ||
*/ | ||
export interface MarketplaceReListingResponse { | ||
/** base64 transaction to be signed */ | ||
psbt: string; | ||
} | ||
/** | ||
* Request object for confirming a relisting in the marketplace. | ||
*/ | ||
export interface MarketplaceConfirmReListRequest { | ||
/** | ||
* The ordinal id for relist | ||
*/ | ||
ordinalId: string; | ||
/** | ||
* The PSBT (Partially Signed Bitcoin Transaction) for the confirmed relist. | ||
*/ | ||
signedListingPSBT: string; | ||
} | ||
/** | ||
* Response object for confirming a listing in the marketplace. | ||
*/ | ||
export interface MarketplaceConfirmReListResponse { | ||
/** | ||
* A message indicating the result of the confirmation operation. | ||
*/ | ||
message: string; | ||
} | ||
/** | ||
* Request object for deList ordinal. | ||
*/ | ||
export interface MarketplaceDeListRequest { | ||
/** ordinal Id to deList */ | ||
ordinalId: string; | ||
/** The seller's payment address */ | ||
senderPaymentAddress: string; | ||
/** The seller's payment public key */ | ||
senderPaymentPublicKey: string; | ||
/** The seller's ordinal address */ | ||
senderOrdinalAddress: string; | ||
/** Wallet Provider name */ | ||
walletProvider?: string; | ||
} | ||
/** | ||
* Response object for deList ordinal. | ||
*/ | ||
export interface MarketplaceDeListAPIResponse { | ||
/** base64 transaction to be signed */ | ||
psbtBase64: string; | ||
/** Array of Ordinal indices that need to be signed by the Seller */ | ||
senderOrdinalInputs: Array<number>; | ||
/** Array of Payment indices that need to be signed by the Seller */ | ||
senderPaymentInputs: Array<number>; | ||
} |
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
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
126522
2322