Skip to content

Commit

Permalink
Move type BlockItem to types.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
limemloh committed Oct 30, 2023
1 parent 0cc9a4e commit 08ce904
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
19 changes: 19 additions & 0 deletions packages/sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
23 changes: 1 addition & 22 deletions packages/sdk/src/wasm/deserialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/wasm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 08ce904

Please sign in to comment.