From 07b2297627f9cdb2c9c92c6d1d5c132ecef7923c Mon Sep 17 00:00:00 2001 From: "markin.io" Date: Wed, 7 Jun 2023 12:01:04 +0100 Subject: [PATCH 1/2] fix: Transaction types --- typings/transaction/Transaction.d.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/typings/transaction/Transaction.d.ts b/typings/transaction/Transaction.d.ts index 234d2ba72..5475b4a1f 100644 --- a/typings/transaction/Transaction.d.ts +++ b/typings/transaction/Transaction.d.ts @@ -8,6 +8,7 @@ import { Signature } from '../crypto/Signature'; import { AbstractPayload } from './payload/AbstractPayload'; import { bitcore } from '../bitcore'; import { TransactionSignature } from './TransactionSignature'; +import { UnspentOutput } from './UnspentOutput'; export namespace Transaction { /** @@ -177,10 +178,10 @@ export class Transaction { * @param {number=} threshold */ from( - utxo: Transaction.fromObjectParams[] | Transaction.fromObjectParams, + utxo: Transaction.fromObjectParams[] | Transaction.fromObjectParams | UnspentOutput | UnspentOutput[], pubkeys?: any[], threshold?: number - ): void; + ): Transaction; /** * Add an input to this transaction. The input must be an instance of the `Input` class. @@ -239,7 +240,7 @@ export class Transaction { * @param {Address} address An address for change to be sent to. * @return {Transaction} this, for chaining */ - change(address: Address): Transaction; + change(address: Address | string): Transaction; /** * @return {Output} change output, if it exists @@ -476,6 +477,12 @@ export class Transaction { */ toJSON(): any; + /** + * @function + * @returns {Buffer} Buffer with the transaction bytes + */ + toBuffer(): Buffer; + /** * @param {Number} fundingAmount * @return {Transaction} From b8ad3c31dbcac969c27159bcd91a09db0a7a8a98 Mon Sep 17 00:00:00 2001 From: "markin.io" Date: Wed, 7 Jun 2023 14:29:58 +0100 Subject: [PATCH 2/2] feat: expose child types for Block, Transaction and GovObject --- typings/block/Block.d.ts | 10 +++++++--- typings/govobject/GovObject.d.ts | 8 ++++++++ typings/transaction/Transaction.d.ts | 9 +++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/typings/block/Block.d.ts b/typings/block/Block.d.ts index eda046272..03004aa48 100644 --- a/typings/block/Block.d.ts +++ b/typings/block/Block.d.ts @@ -1,6 +1,7 @@ import { BufferReader } from '../buffer/BufferReader'; import { BufferWriter } from '../buffer/BufferWriter'; import { BlockHeader } from './BlockHeader'; +import { MerkleBlock } from './MerkleBlock'; import { Transaction } from '../transaction/Transaction'; export namespace Block { @@ -9,7 +10,7 @@ export namespace Block { * @property {Transaction.toObjectParams[]} transactions * @property {BlockHeader.toObjectParams} header */ - type fromObjectParams = { + export type fromObjectParams = { transactions: Transaction[]; header: BlockHeader.toObjectParams; }; @@ -23,7 +24,7 @@ export namespace Block { * @property {number} bits * @property {number} nonce */ - type toObjectParams = { + export type toObjectParams = { hash: string; version: number; prevHash: string; @@ -33,10 +34,13 @@ export namespace Block { nonce: number; }; - type Values = { + export type Values = { START_OF_BLOCK: number; NULL_HASH: Buffer; }; + + export { BlockHeader }; + export { MerkleBlock }; } /** diff --git a/typings/govobject/GovObject.d.ts b/typings/govobject/GovObject.d.ts index d5e9edd62..a6a704a14 100644 --- a/typings/govobject/GovObject.d.ts +++ b/typings/govobject/GovObject.d.ts @@ -1,3 +1,11 @@ +import { Proposal } from './Proposal'; +import { Trigger } from './Trigger'; + +export namespace GovObject { + export { Proposal }; + export { Trigger }; +} + /** * Represents a generic Governance Object * diff --git a/typings/transaction/Transaction.d.ts b/typings/transaction/Transaction.d.ts index 5475b4a1f..e2a28589a 100644 --- a/typings/transaction/Transaction.d.ts +++ b/typings/transaction/Transaction.d.ts @@ -18,7 +18,7 @@ export namespace Transaction { * @property {(Buffer|string|Script)} script * @property {number} satoshis */ - type fromObjectParams = { + export type fromObjectParams = { prevTxId: string; outputIndex: number; script: Buffer | string | Script; @@ -29,10 +29,15 @@ export namespace Transaction { * @property {(string|Address)} address * @property {number} satoshis */ - type toObjectParams = { + export type toObjectParams = { address: string | Address; satoshis: number; }; + + export { Input }; + export { Output }; + export { UnspentOutput }; + export { TransactionSignature as Signature }; } /** * Represents a transaction, a set of inputs and outputs to change ownership of tokens