Merge branch 'make_electrum_from_inheritable' into 'development'
Make Blockchain from methods inheritable See merge request GeneralProtocols/xo/stack!80
This commit is contained in:
@@ -109,17 +109,18 @@ export class BlockchainElectrum extends BaseBlockchain<
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new BlockchainElectrum instance.
|
* Creates a new BlockchainElectrum instance.
|
||||||
* @param {BlockchainElectrumParams} params - The parameters for the BlockchainElectrum instance.
|
* @param params - The parameters for the BlockchainElectrum instance.
|
||||||
* @returns {BlockchainElectrum} A new BlockchainElectrum instance.
|
* @returns A new BlockchainElectrum instance.
|
||||||
*/
|
*/
|
||||||
static async from(
|
static async from<T extends typeof BlockchainElectrum>(
|
||||||
|
this: T,
|
||||||
params: BlockchainElectrumParams = {},
|
params: BlockchainElectrumParams = {},
|
||||||
): Promise<BlockchainElectrum> {
|
) {
|
||||||
const blockchain = new BlockchainElectrum(params);
|
const blockchain = new this(params);
|
||||||
|
|
||||||
await blockchain.start();
|
await blockchain.start();
|
||||||
|
|
||||||
return blockchain;
|
return blockchain as InstanceType<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
|
|||||||
@@ -24,8 +24,10 @@ import {
|
|||||||
// Local Blockchain Adapter.
|
// Local Blockchain Adapter.
|
||||||
// This simulates the BCH Blockchain.
|
// This simulates the BCH Blockchain.
|
||||||
export class BlockchainInMemory extends BaseBlockchain {
|
export class BlockchainInMemory extends BaseBlockchain {
|
||||||
static from() {
|
static async from<T extends typeof BlockchainInMemory>(this: T) {
|
||||||
return new BlockchainInMemory();
|
const blockchain = new this();
|
||||||
|
await blockchain.start();
|
||||||
|
return blockchain as InstanceType<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
private transactions: BlockchainTransactions;
|
private transactions: BlockchainTransactions;
|
||||||
|
|||||||
Reference in New Issue
Block a user