From d3d6c88607abbfb74acf016fba886540938b216d Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Thu, 29 Jun 2023 12:04:14 +0600 Subject: [PATCH] fix(tx-builder): `buildTx` produces the same type as `unpackTx` accepts --- src/tx/builder/index.ts | 15 ++++++--------- test/integration/Middleware.ts | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/tx/builder/index.ts b/src/tx/builder/index.ts index cd17f77486..20754cd461 100644 --- a/src/tx/builder/index.ts +++ b/src/tx/builder/index.ts @@ -23,6 +23,9 @@ export function getSchema(tag: Tag, version?: number): Array<[string, Field]> { return Object.entries(schema); } +type TxEncoding = Encoding.Transaction | Encoding.Poi | Encoding.StateTrees +| Encoding.CallStateTree; + /** * Build transaction hash * @category transaction builder @@ -31,15 +34,9 @@ export function getSchema(tag: Tag, version?: number): Array<[string, Field]> { * @param options.prefix - Prefix of transaction * @returns object Base64Check transaction hash with 'tx_' prefix */ -export function buildTx< - E extends Encoding = Encoding.Transaction, ->( +export function buildTx( params: TxParams, - { - prefix, - }: { - prefix?: E; - } = {}, + { prefix }: { prefix?: E } = {}, ): Encoded.Generic { const schema = getSchema(params.tag, params.version); @@ -92,7 +89,7 @@ export async function buildTxAsync(params: TxParamsAsync): Promise( - encodedTx: Encoded.Transaction | Encoded.Poi | Encoded.StateTrees | Encoded.CallStateTree, + encodedTx: Encoded.Generic, txType?: TxType, ): TxUnpacked & { tag: TxType } { const binary = rlpDecode(decode(encodedTx)); diff --git a/test/integration/Middleware.ts b/test/integration/Middleware.ts index 415ef9de8a..2e0a83c87b 100644 --- a/test/integration/Middleware.ts +++ b/test/integration/Middleware.ts @@ -17,7 +17,7 @@ describe('MiddlewareSubscriber', () => { }, mdwGensPerMinute: res.mdwGensPerMinute, mdwHeight: res.mdwHeight, - mdwLastMigration: 20230519120000, + mdwLastMigration: res.mdwLastMigration, mdwRevision: res.mdwRevision, mdwSynced: true, mdwSyncing: true,