Changeset View
Changeset View
Standalone View
Standalone View
modules/chronik-client/src/ChronikClientNode.ts
Show First 20 Lines • Show All 218 Lines • ▼ Show 20 Lines | ): Promise<TxHistoryPage_InNode> { | ||||
return { | return { | ||||
txs: historyPage.txs.map(convertToTx), | txs: historyPage.txs.map(convertToTx), | ||||
numPages: historyPage.numPages, | numPages: historyPage.numPages, | ||||
numTxs: historyPage.numTxs, | numTxs: historyPage.numTxs, | ||||
}; | }; | ||||
} | } | ||||
/** | /** | ||||
* Fetches the confirmed tx history of this script, in the order they appear on the blockchain. | |||||
* @param page Page index of the tx history. | |||||
* @param pageSize Number of txs per page. | |||||
*/ | |||||
public async confirmedTxs( | |||||
page = 0, // Get the first page if unspecified | |||||
pageSize = 25, // Must be less than 200, let server handle error as server setting could change | |||||
): Promise<TxHistoryPage_InNode> { | |||||
const data = await this._proxyInterface.get( | |||||
`/script/${this._scriptType}/${this._scriptPayload}/confirmed-txs?page=${page}&page_size=${pageSize}`, | |||||
); | |||||
const historyPage = proto.TxHistoryPage.decode(data); | |||||
return { | |||||
txs: historyPage.txs.map(convertToTx), | |||||
numPages: historyPage.numPages, | |||||
numTxs: historyPage.numTxs, | |||||
}; | |||||
} | |||||
/** | |||||
* Fetches the unconfirmed tx history of this script, in chronological order. | |||||
* @param page Page index of the tx history. | |||||
* @param pageSize Number of txs per page. | |||||
*/ | |||||
public async unconfirmedTxs( | |||||
page = 0, // Get the first page if unspecified | |||||
pageSize = 25, // Must be less than 200, let server handle error as server setting could change | |||||
): Promise<TxHistoryPage_InNode> { | |||||
const data = await this._proxyInterface.get( | |||||
`/script/${this._scriptType}/${this._scriptPayload}/unconfirmed-txs?page=${page}&page_size=${pageSize}`, | |||||
); | |||||
const historyPage = proto.TxHistoryPage.decode(data); | |||||
return { | |||||
txs: historyPage.txs.map(convertToTx), | |||||
numPages: historyPage.numPages, | |||||
numTxs: historyPage.numTxs, | |||||
}; | |||||
} | |||||
/** | |||||
* Fetches the current UTXO set for this script. | * Fetches the current UTXO set for this script. | ||||
* It is grouped by output script, in case a script type can match multiple | * It is grouped by output script, in case a script type can match multiple | ||||
* different output scripts (e.g. Taproot on Lotus). | * different output scripts (e.g. Taproot on Lotus). | ||||
*/ | */ | ||||
public async utxos(): Promise<ScriptUtxos_InNode> { | public async utxos(): Promise<ScriptUtxos_InNode> { | ||||
const data = await this._proxyInterface.get( | const data = await this._proxyInterface.get( | ||||
`/script/${this._scriptType}/${this._scriptPayload}/utxos`, | `/script/${this._scriptType}/${this._scriptPayload}/utxos`, | ||||
); | ); | ||||
Show All 31 Lines | ): Promise<TxHistoryPage_InNode> { | ||||
return { | return { | ||||
txs: historyPage.txs.map(convertToTx), | txs: historyPage.txs.map(convertToTx), | ||||
numPages: historyPage.numPages, | numPages: historyPage.numPages, | ||||
numTxs: historyPage.numTxs, | numTxs: historyPage.numTxs, | ||||
}; | }; | ||||
} | } | ||||
/** | /** | ||||
* Fetches the confirmed tx history of this tokenId, in anti-chronological order. | * Fetches the confirmed tx history of this tokenId, in the order they appear on the blockchain. | ||||
* @param page Page index of the tx history. | * @param page Page index of the tx history. | ||||
* @param pageSize Number of txs per page. | * @param pageSize Number of txs per page. | ||||
*/ | */ | ||||
public async confirmedTxs( | public async confirmedTxs( | ||||
page = 0, // Get the first page if unspecified | page = 0, // Get the first page if unspecified | ||||
pageSize = 25, // Must be less than 200, let server handle error as server setting could change | pageSize = 25, // Must be less than 200, let server handle error as server setting could change | ||||
): Promise<TxHistoryPage_InNode> { | ): Promise<TxHistoryPage_InNode> { | ||||
const data = await this._proxyInterface.get( | const data = await this._proxyInterface.get( | ||||
`/token-id/${this._tokenId}/confirmed-txs?page=${page}&page_size=${pageSize}`, | `/token-id/${this._tokenId}/confirmed-txs?page=${page}&page_size=${pageSize}`, | ||||
); | ); | ||||
const historyPage = proto.TxHistoryPage.decode(data); | const historyPage = proto.TxHistoryPage.decode(data); | ||||
return { | return { | ||||
txs: historyPage.txs.map(convertToTx), | txs: historyPage.txs.map(convertToTx), | ||||
numPages: historyPage.numPages, | numPages: historyPage.numPages, | ||||
numTxs: historyPage.numTxs, | numTxs: historyPage.numTxs, | ||||
}; | }; | ||||
} | } | ||||
/** | /** | ||||
* Fetches the unconfirmed tx history of this tokenId, in anti-chronological order. | * Fetches the unconfirmed tx history of this tokenId, in chronological order. | ||||
* @param page Page index of the tx history. | * @param page Page index of the tx history. | ||||
* @param pageSize Number of txs per page. | * @param pageSize Number of txs per page. | ||||
*/ | */ | ||||
public async unconfirmedTxs( | public async unconfirmedTxs( | ||||
page = 0, // Get the first page if unspecified | page = 0, // Get the first page if unspecified | ||||
pageSize = 25, // Must be less than 200, let server handle error as server setting could change | pageSize = 25, // Must be less than 200, let server handle error as server setting could change | ||||
): Promise<TxHistoryPage_InNode> { | ): Promise<TxHistoryPage_InNode> { | ||||
const data = await this._proxyInterface.get( | const data = await this._proxyInterface.get( | ||||
▲ Show 20 Lines • Show All 1,167 Lines • Show Last 20 Lines |