From 08ce904bdfb42f0b6aba3af9403e44c7bac446ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Holm=20Gj=C3=B8rup?= Date: Mon, 30 Oct 2023 13:18:48 +0100 Subject: [PATCH] Move type BlockItem to types.ts --- packages/sdk/src/types.ts | 19 +++++++++++++++++++ packages/sdk/src/wasm/deserialization.ts | 23 +---------------------- packages/sdk/src/wasm/index.ts | 2 +- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index c751d5cfa..24ba60377 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -1845,3 +1845,22 @@ export type HealthCheckResponse = isHealthy: false; message?: string; }; + +/** + * Type representing an item which is included in a block, such as account transactions, chain updates or deployments of new credentials. + */ +export type BlockItem = + | { + kind: BlockItemKind.AccountTransactionKind; + transaction: { + accountTransaction: AccountTransaction; + signatures: AccountTransactionSignature; + }; + } + | { + kind: BlockItemKind.CredentialDeploymentKind; + transaction: { + credential: TypedCredentialDeployment; + expiry: number; + }; + }; diff --git a/packages/sdk/src/wasm/deserialization.ts b/packages/sdk/src/wasm/deserialization.ts index 20d9fc9dc..2ca3d65bd 100644 --- a/packages/sdk/src/wasm/deserialization.ts +++ b/packages/sdk/src/wasm/deserialization.ts @@ -4,12 +4,7 @@ import { deserializeUint8, } from '../deserialization.js'; import { Cursor } from '../deserializationHelpers.js'; -import { - AccountTransaction, - AccountTransactionSignature, - BlockItemKind, - TypedCredentialDeployment, -} from '../types.js'; +import { BlockItem, BlockItemKind } from '../types.js'; function deserializeCredentialDeployment(serializedDeployment: Cursor) { const raw = wasm.deserializeCredentialDeployment( @@ -27,22 +22,6 @@ function deserializeCredentialDeployment(serializedDeployment: Cursor) { } } -export type BlockItem = - | { - kind: BlockItemKind.AccountTransactionKind; - transaction: { - accountTransaction: AccountTransaction; - signatures: AccountTransactionSignature; - }; - } - | { - kind: BlockItemKind.CredentialDeploymentKind; - transaction: { - credential: TypedCredentialDeployment; - expiry: number; - }; - }; - /** * Deserializes a transaction, from the binary format used to send it to the node, back into an js object. * @param serializedTransaction A buffer containing the binary transaction. It is expected to start with the version and blockItemKind. diff --git a/packages/sdk/src/wasm/index.ts b/packages/sdk/src/wasm/index.ts index 4b2fe0ef2..16a688cb1 100644 --- a/packages/sdk/src/wasm/index.ts +++ b/packages/sdk/src/wasm/index.ts @@ -3,7 +3,7 @@ export { serializeCredentialDeploymentTransactionForSubmission, serializeCredentialDeploymentPayload, } from './serialization.js'; -export { deserializeTransaction, BlockItem } from './deserialization.js'; +export { deserializeTransaction } from './deserialization.js'; export { generateBakerKeys } from './accountHelpers.js'; export * from './HdWallet.js'; export * from './identity.js';