-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ALL-4863: avoid copying, inherit common rpc methods
- Loading branch information
1 parent
0c825a8
commit 0f957f0
Showing
8 changed files
with
19 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,5 @@ | |
coverage | ||
*.log | ||
.env | ||
|
||
jest-junit.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,130 +1,11 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { JsonRpcResponse, UtxoBasedRpcInterface } from '../../../dto' | ||
import { AbstractCommonUtxoRpc } from './AbstractCommonUtxoRpc' | ||
|
||
export abstract class AbstractUtxoRpc implements UtxoBasedRpcInterface { | ||
export abstract class AbstractUtxoRpc extends AbstractCommonUtxoRpc implements UtxoBasedRpcInterface { | ||
protected abstract rpcCall<T>(method: string, params?: unknown[]): Promise<T> | ||
|
||
async createRawTransaction( | ||
inputs: any[], | ||
outputs: any, | ||
locktime: number, | ||
replaceable: boolean, | ||
): Promise<JsonRpcResponse<string>> { | ||
const params: unknown[] = [inputs, outputs] | ||
if (locktime) { | ||
params.push(locktime) | ||
} | ||
if (replaceable) { | ||
params.push(replaceable) | ||
} | ||
return this.rpcCall<JsonRpcResponse<string>>('createrawtransaction', params) | ||
} | ||
|
||
async decodeRawTransaction(hexstring: string): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('decoderawtransaction', [hexstring]) | ||
} | ||
|
||
async decodeScript(hexstring: string): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('decodescript', [hexstring]) | ||
} | ||
|
||
async estimateSmartFee(blocks: number, estimateMode?: string): Promise<JsonRpcResponse<any>> { | ||
const params: unknown[] = [blocks] | ||
if (estimateMode) { | ||
params.push(estimateMode) | ||
} | ||
return this.rpcCall<JsonRpcResponse<any>>('estimatesmartfee', params) | ||
} | ||
|
||
async getBestBlockHash(): Promise<JsonRpcResponse<string>> { | ||
return this.rpcCall<JsonRpcResponse<string>>('getbestblockhash') | ||
} | ||
|
||
async getBlock(hashOrHeight: string, verbose: 0 | 1 | 2 = 1): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getblock', [hashOrHeight, verbose]) | ||
} | ||
|
||
async getBlockChainInfo(): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getblockchaininfo') | ||
} | ||
|
||
async getBlockCount(): Promise<JsonRpcResponse<number>> { | ||
return this.rpcCall<JsonRpcResponse<number>>('getblockcount') | ||
} | ||
|
||
async getBlockHash(height: number): Promise<JsonRpcResponse<string>> { | ||
return this.rpcCall<JsonRpcResponse<string>>('getblockhash', [height]) | ||
} | ||
|
||
async getBlockHeader(hash: string, verbose = true): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getblockheader', [hash, verbose]) | ||
} | ||
|
||
async getBlockStats(hash: string): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getblockstats', [hash]) | ||
} | ||
|
||
async getChainTips(): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getchaintips') | ||
} | ||
|
||
async getDifficulty(): Promise<JsonRpcResponse<number>> { | ||
return this.rpcCall<JsonRpcResponse<number>>('getdifficulty') | ||
} | ||
|
||
async getMempoolAncestors(txId: string, verbose = false): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getmempoolancestors', [txId, verbose]) | ||
} | ||
|
||
async getMempoolDescendants(txId: string, verbose = false): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getmempooldescendants', [txId, verbose]) | ||
} | ||
|
||
async getMempoolEntry(txId: string): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getmempoolentry', [txId]) | ||
} | ||
|
||
async getMempoolInfo(): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getmempoolinfo') | ||
} | ||
|
||
async getRawMemPool(verbose = false): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getrawmempool', [verbose]) | ||
} | ||
|
||
async getRawTransaction(txId: string, verbose = false): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getrawtransaction', [txId, verbose]) | ||
} | ||
|
||
async getTxOut(txId: string, index: number, includeMempool = true): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('gettxout', [txId, index, includeMempool]) | ||
} | ||
|
||
async getTxOutProof(txIds: string[], blockhash?: string): Promise<JsonRpcResponse<any>> { | ||
const params: unknown[] = [txIds] | ||
if (blockhash) { | ||
params.push(blockhash) | ||
} | ||
return this.rpcCall<JsonRpcResponse<any>>('gettxoutproof', params) | ||
} | ||
|
||
async sendRawTransaction(hexstring: string): Promise<JsonRpcResponse<string>> { | ||
return this.rpcCall<JsonRpcResponse<string>>('sendrawtransaction', [hexstring]) | ||
} | ||
|
||
async validateAddress(address: string): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('validateaddress', [address]) | ||
} | ||
|
||
async verifyMessage( | ||
address: string, | ||
signature: string, | ||
message: string, | ||
): Promise<JsonRpcResponse<boolean>> { | ||
return this.rpcCall<JsonRpcResponse<boolean>>('verifymessage', [address, signature, message]) | ||
} | ||
|
||
async verifyTxOutProof(proof: string): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('verifytxoutproof', [proof]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export * from './AbstractUtxoRpc' | ||
export * from './UtxoRpc' | ||
export * from './DogeRpc' |