New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@concordium/common-sdk

Package Overview
Dependencies
Maintainers
4
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@concordium/common-sdk - npm Package Compare versions

Comparing version

to
2.3.0

13

lib/accountTransactions.d.ts

@@ -0,5 +1,8 @@

/// <reference types="node" />
import { Buffer } from 'buffer/';
import { AccountTransactionType, InitContractPayload, SimpleTransferPayload, SimpleTransferWithMemoPayload, DeployModulePayload, UpdateContractPayload, AccountTransactionPayload, UpdateCredentialsPayload, RegisterDataPayload, ConfigureDelegationPayload } from './types';
import { Readable } from 'stream';
interface AccountTransactionHandler<PayloadType extends AccountTransactionPayload = AccountTransactionPayload> {
serialize: (payload: PayloadType) => Buffer;
deserialize: (serializedPayload: Readable) => PayloadType;
getBaseEnergyCost: (payload: PayloadType) => bigint;

@@ -10,5 +13,7 @@ }

serialize(transfer: SimpleTransferPayload): Buffer;
deserialize(serializedPayload: Readable): SimpleTransferPayload;
}
export declare class SimpleTransferWithMemoHandler extends SimpleTransferHandler implements AccountTransactionHandler<SimpleTransferWithMemoPayload> {
serialize(transfer: SimpleTransferWithMemoPayload): Buffer;
deserialize(serializedPayload: Readable): SimpleTransferWithMemoPayload;
}

@@ -18,2 +23,3 @@ export declare class DeployModuleHandler implements AccountTransactionHandler<DeployModulePayload> {

serialize(payload: DeployModulePayload): Buffer;
deserialize(): DeployModulePayload;
}

@@ -23,2 +29,3 @@ export declare class InitContractHandler implements AccountTransactionHandler<InitContractPayload> {

serialize(payload: InitContractPayload): Buffer;
deserialize(): InitContractPayload;
}

@@ -28,2 +35,3 @@ export declare class UpdateContractHandler implements AccountTransactionHandler<UpdateContractPayload> {

serialize(payload: UpdateContractPayload): Buffer;
deserialize(): UpdateContractPayload;
}

@@ -33,2 +41,3 @@ export declare class UpdateCredentialsHandler implements AccountTransactionHandler<UpdateCredentialsPayload> {

serialize(updateCredentials: UpdateCredentialsPayload): Buffer;
deserialize(): UpdateCredentialsPayload;
}

@@ -38,2 +47,3 @@ export declare class RegisterDataHandler implements AccountTransactionHandler<RegisterDataPayload> {

serialize(payload: RegisterDataPayload): Buffer;
deserialize(serializedPayload: Readable): RegisterDataPayload;
}

@@ -43,7 +53,8 @@ export declare class ConfigureDelegationHandler implements AccountTransactionHandler<ConfigureDelegationPayload> {

serialize(payload: ConfigureDelegationPayload): Buffer;
deserialize(): ConfigureDelegationPayload;
}
export declare function getAccountTransactionHandler(type: AccountTransactionType): AccountTransactionHandler;
export declare function getAccountTransactionHandler(type: AccountTransactionType.SimpleTransfer): SimpleTransferHandler;
export declare function getAccountTransactionHandler(type: AccountTransactionType.SimpleTransferWithMemo): SimpleTransferWithMemoHandler;
export declare function getAccountTransactionHandler(type: AccountTransactionType.UpdateCredentials): UpdateCredentialsHandler;
export declare function getAccountTransactionHandler(type: AccountTransactionType): AccountTransactionHandler;
export declare function getAccountTransactionHandler(type: AccountTransactionType.DeployModule): DeployModuleHandler;

@@ -50,0 +61,0 @@ export declare function getAccountTransactionHandler(type: AccountTransactionType.InitializeSmartContractInstance): InitContractHandler;

@@ -8,2 +8,5 @@ "use strict";

const types_1 = require("./types");
const accountAddress_1 = require("./types/accountAddress");
const DataBlob_1 = require("./types/DataBlob");
const gtuAmount_1 = require("./types/gtuAmount");
class SimpleTransferHandler {

@@ -18,2 +21,10 @@ getBaseEnergyCost() {

}
deserialize(serializedPayload) {
const toAddress = accountAddress_1.AccountAddress.fromBytes(buffer_1.Buffer.from(serializedPayload.read(32)));
const amount = new gtuAmount_1.GtuAmount(serializedPayload.read(8).readBigUInt64BE(0));
return {
toAddress,
amount,
};
}
}

@@ -32,2 +43,13 @@ exports.SimpleTransferHandler = SimpleTransferHandler;

}
deserialize(serializedPayload) {
const toAddress = accountAddress_1.AccountAddress.fromBytes(buffer_1.Buffer.from(serializedPayload.read(32)));
const memoLength = serializedPayload.read(2).readUInt16BE(0);
const memo = new DataBlob_1.DataBlob(buffer_1.Buffer.from(serializedPayload.read(memoLength)));
const amount = new gtuAmount_1.GtuAmount(serializedPayload.read(8).readBigUInt64BE(0));
return {
toAddress,
memo,
amount,
};
}
}

@@ -52,2 +74,5 @@ exports.SimpleTransferWithMemoHandler = SimpleTransferWithMemoHandler;

}
deserialize() {
throw new Error('deserialize not supported');
}
}

@@ -73,2 +98,5 @@ exports.DeployModuleHandler = DeployModuleHandler;

}
deserialize() {
throw new Error('deserialize not supported');
}
}

@@ -99,2 +127,5 @@ exports.InitContractHandler = InitContractHandler;

}
deserialize() {
throw new Error('deserialize not supported');
}
}

@@ -126,2 +157,5 @@ exports.UpdateContractHandler = UpdateContractHandler;

}
deserialize() {
throw new Error('deserialize not supported');
}
}

@@ -136,2 +170,8 @@ exports.UpdateCredentialsHandler = UpdateCredentialsHandler;

}
deserialize(serializedPayload) {
const memoLength = serializedPayload.read(2).readUInt16BE(0);
return {
data: new DataBlob_1.DataBlob(buffer_1.Buffer.from(serializedPayload.read(memoLength))),
};
}
}

@@ -146,6 +186,10 @@ exports.RegisterDataHandler = RegisterDataHandler;

}
deserialize() {
throw new Error('deserialize not supported');
}
}
exports.ConfigureDelegationHandler = ConfigureDelegationHandler;
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
function getAccountTransactionHandler(type) {
function getAccountTransactionHandler(type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
) {
switch (type) {

@@ -152,0 +196,0 @@ case types_1.AccountTransactionType.SimpleTransfer:

2

lib/credentialDeploymentTransactions.d.ts

@@ -14,3 +14,3 @@ import { AttributeKey, CredentialDeploymentTransaction, CredentialDeploymentInfo, CryptographicParameters, IdentityInput, UnsignedCdiWithRandomness, UnsignedCredentialDeploymentInformation, VerifyKey } from './types';

* @param expiry the expiry of the transaction
* @returns a credential deployment transaction
* @returns the details used in a credential deployment transaction
*/

@@ -17,0 +17,0 @@ export declare function createCredentialDeploymentTransaction(identity: IdentityInput, cryptographicParameters: CryptographicParameters, threshold: number, publicKeys: VerifyKey[], credentialIndex: number, revealedAttributes: AttributeKey[], expiry: TransactionExpiry): CredentialDeploymentTransaction;

@@ -84,3 +84,3 @@ "use strict";

* @param expiry the expiry of the transaction
* @returns a credential deployment transaction
* @returns the details used in a credential deployment transaction
*/

@@ -87,0 +87,0 @@ function createCredentialDeploymentTransaction(identity, cryptographicParameters, threshold, publicKeys, credentialIndex, revealedAttributes, expiry) {

import { Buffer } from 'buffer/';
import { AccountTransaction, AccountTransactionSignature, BlockItemKind, TypedCredentialDeployment } from './types';
/**

@@ -7,1 +8,20 @@ * Given a contract's raw state, its name and its schema, return the state as a JSON object.

export declare function deserializeContractState(contractName: string, schema: Buffer, state: Buffer): any;
export declare 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.
* @returns An object specifiying the blockItemKind that the transaction has. The object also contains the actual transaction under the transaction field.
**/
export declare function deserializeTransaction(serializedTransaction: Buffer): BlockItem;

@@ -26,4 +26,11 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.deserializeContractState = void 0;
exports.deserializeTransaction = exports.deserializeContractState = void 0;
const wasm = __importStar(require("@concordium/rust-bindings"));
const buffer_1 = require("buffer/");
const accountTransactions_1 = require("./accountTransactions");
const types_1 = require("./types");
const accountAddress_1 = require("./types/accountAddress");
const transactionExpiry_1 = require("./types/transactionExpiry");
const stream_1 = require("stream");
const deserializeSchema_1 = require("./deserializeSchema");
/**

@@ -45,1 +52,99 @@ * Given a contract's raw state, its name and its schema, return the state as a JSON object.

exports.deserializeContractState = deserializeContractState;
function deserializeMap(serialized, decodeSize, decodeKey, decodeValue) {
const size = decodeSize(serialized);
const result = {};
for (let i = 0; i < size; i += 1) {
const key = decodeKey(serialized);
const value = decodeValue(serialized);
result[key] = value;
}
return result;
}
function deserializeAccountTransactionSignature(signatures) {
const decodeSignature = (serialized) => {
const length = serialized.read(2).readUInt16BE(0);
return serialized.read(length).toString('hex');
};
const decodeCredentialSignatures = (serialized) => deserializeMap(serialized, deserializeSchema_1.deserialUint8, deserializeSchema_1.deserialUint8, decodeSignature);
return deserializeMap(signatures, deserializeSchema_1.deserialUint8, deserializeSchema_1.deserialUint8, decodeCredentialSignatures);
}
function deserializeTransactionHeader(serializedHeader) {
const sender = accountAddress_1.AccountAddress.fromBytes(buffer_1.Buffer.from(serializedHeader.read(32)));
const nonce = serializedHeader.read(8).readBigUInt64BE(0);
// TODO: extract payloadSize and energyAmount?
// energyAmount
serializedHeader.read(8).readBigUInt64BE(0);
// payloadSize
serializedHeader.read(4).readUInt32BE(0);
const expiry = transactionExpiry_1.TransactionExpiry.fromEpochSeconds(serializedHeader.read(8).readBigUInt64BE(0));
return {
sender,
nonce,
expiry,
};
}
function deserializeAccountTransaction(serializedTransaction) {
const signatures = deserializeAccountTransactionSignature(serializedTransaction);
const header = deserializeTransactionHeader(serializedTransaction);
const transactionType = (0, deserializeSchema_1.deserialUint8)(serializedTransaction);
if (!(0, types_1.isAccountTransactionType)(transactionType)) {
throw new Error('TransactionType is not a valid value: ' + transactionType);
}
const accountTransactionHandler = (0, accountTransactions_1.getAccountTransactionHandler)(transactionType);
const payload = accountTransactionHandler.deserialize(serializedTransaction);
return {
accountTransaction: {
type: transactionType,
payload,
header,
},
signatures,
};
}
function deserializeCredentialDeployment(serializedDeployment) {
const raw = wasm.deserializeCredentialDeployment(serializedDeployment.read().toString('hex'));
try {
const parsed = JSON.parse(raw);
return {
credential: parsed.credential,
expiry: parsed.messageExpiry,
};
}
catch {
// If the return value is not a proper JSON, it should be an error message.
throw new Error(raw);
}
}
/**
* 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.
* @returns An object specifiying the blockItemKind that the transaction has. The object also contains the actual transaction under the transaction field.
**/
function deserializeTransaction(serializedTransaction) {
const bufferStream = new stream_1.PassThrough();
bufferStream.end(serializedTransaction);
const version = (0, deserializeSchema_1.deserialUint8)(bufferStream);
if (version !== 0) {
throw new Error('Supplied version ' +
version +
' is not valid. Only transactions with version 0 format are supported');
}
const blockItemKind = (0, deserializeSchema_1.deserialUint8)(bufferStream);
switch (blockItemKind) {
case types_1.BlockItemKind.AccountTransactionKind:
return {
kind: types_1.BlockItemKind.AccountTransactionKind,
transaction: deserializeAccountTransaction(bufferStream),
};
case types_1.BlockItemKind.CredentialDeploymentKind:
return {
kind: types_1.BlockItemKind.CredentialDeploymentKind,
transaction: deserializeCredentialDeployment(bufferStream),
};
case types_1.BlockItemKind.UpdateInstructionKind:
throw new Error('deserialization of UpdateInstructions is not supported');
default:
throw new Error('Invalid blockItemKind');
}
}
exports.deserializeTransaction = deserializeTransaction;

@@ -331,16 +331,2 @@ /// <reference types="node" />

/**
* Reads an unsigned 32-bit integer from the given {@link Readable}.
*
* @param source input stream
* @returns number from 0 to 4294967295
*/
export declare function deserialUint32(source: Readable): number;
/**
* Reads an unsigned 16-bit integer from the given {@link Readable}.
*
* @param source input stream
* @returns number from 0 to 65535
*/
export declare function deserialUint16(source: Readable): number;
/**
* @param buffer Schema buffer

@@ -347,0 +333,0 @@ * @param moduleVersion the version of the module (only needed for older versions of the schema).

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getParameterType = exports.deserialModuleFromBuffer = exports.deserialUint16 = exports.deserialUint32 = exports.deserialUint8 = exports.deserialTupleFn = exports.deserialOptionFn = exports.OptionTag = exports.deserialMapFn = exports.deserialArrayFn = exports.deserialString = exports.deserialFields = exports.FieldsTag = exports.deserialType = exports.deserialFunction = exports.SizeLength = exports.deserialContractV2 = exports.deserialContractV1 = exports.deserialVersionedModule = exports.VERSIONED_SCHEMA_PREFIX = exports.deserialModuleV2 = exports.deserialModuleV1 = void 0;
exports.getParameterType = exports.deserialModuleFromBuffer = exports.deserialUint8 = exports.deserialTupleFn = exports.deserialOptionFn = exports.OptionTag = exports.deserialMapFn = exports.deserialArrayFn = exports.deserialString = exports.deserialFields = exports.FieldsTag = exports.deserialType = exports.deserialFunction = exports.SizeLength = exports.deserialContractV2 = exports.deserialContractV1 = exports.deserialVersionedModule = exports.VERSIONED_SCHEMA_PREFIX = exports.deserialModuleV2 = exports.deserialModuleV1 = void 0;
const stream_1 = require("stream");

@@ -411,3 +411,2 @@ const types_1 = require("./types");

}
exports.deserialUint32 = deserialUint32;
/**

@@ -422,3 +421,2 @@ * Reads an unsigned 16-bit integer from the given {@link Readable}.

}
exports.deserialUint16 = deserialUint16;
/**

@@ -425,0 +423,0 @@ * @param buffer Schema buffer

import { Buffer } from 'buffer/';
import { AccountTransaction, AccountTransactionSignature, CredentialDeploymentTransaction, UnsignedCredentialDeploymentInformation, CredentialDeploymentInfo, SchemaVersion } from './types';
import { AccountTransaction, AccountTransactionSignature, UnsignedCredentialDeploymentInformation, CredentialDeploymentInfo, SchemaVersion, CredentialDeploymentDetails } from './types';
import { AccountAddress } from './types/accountAddress';

@@ -60,3 +60,3 @@ /**

*/
export declare function getCredentialDeploymentSignDigest(credentialDeploymentTransaction: CredentialDeploymentTransaction): Buffer;
export declare function getCredentialDeploymentSignDigest(credentialDeployment: CredentialDeploymentDetails): Buffer;
/**

@@ -69,3 +69,3 @@ * Gets the transaction hash that is used to look up the status of a credential

*/
export declare function getCredentialDeploymentTransactionHash(credentialDeploymentTransaction: CredentialDeploymentTransaction, signatures: string[]): string;
export declare function getCredentialDeploymentTransactionHash(credentialDeployment: CredentialDeploymentDetails, signatures: string[]): string;
/**

@@ -78,3 +78,3 @@ * Serializes a credential deployment transaction of a new account, so that it is ready for being

*/
export declare function serializeCredentialDeploymentTransactionForSubmission(credentialDeploymentTransaction: CredentialDeploymentTransaction, signatures: string[]): Buffer;
export declare function serializeCredentialDeploymentTransactionForSubmission(credentialDeployment: CredentialDeploymentDetails, signatures: string[]): Buffer;
/**

@@ -81,0 +81,0 @@ * @param contractName name of the contract that the init contract transaction will initialize

@@ -249,5 +249,5 @@ "use strict";

*/
function getCredentialDeploymentSignDigest(credentialDeploymentTransaction) {
const serializedCredentialValues = serializeCredentialDeploymentValues(credentialDeploymentTransaction.unsignedCdi);
const serializedIdOwnershipProofs = serializeIdOwnershipProofs(credentialDeploymentTransaction.unsignedCdi.proofs);
function getCredentialDeploymentSignDigest(credentialDeployment) {
const serializedCredentialValues = serializeCredentialDeploymentValues(credentialDeployment.unsignedCdi);
const serializedIdOwnershipProofs = serializeIdOwnershipProofs(credentialDeployment.unsignedCdi.proofs);
const newAccountByte = (0, serializationHelpers_1.encodeWord8)(0);

@@ -258,3 +258,3 @@ return (0, hash_1.sha256)([

newAccountByte,
(0, serializationHelpers_1.encodeWord64)(credentialDeploymentTransaction.expiry.expiryEpochSeconds),
(0, serializationHelpers_1.encodeWord64)(credentialDeployment.expiry.expiryEpochSeconds),
]);

@@ -270,4 +270,4 @@ }

*/
function getCredentialDeploymentTransactionHash(credentialDeploymentTransaction, signatures) {
const credentialDeploymentInfo = JSON.parse(wasm.getDeploymentDetails(signatures, JSON.stringify(credentialDeploymentTransaction.unsignedCdi), credentialDeploymentTransaction.expiry.expiryEpochSeconds));
function getCredentialDeploymentTransactionHash(credentialDeployment, signatures) {
const credentialDeploymentInfo = JSON.parse(wasm.getDeploymentDetails(signatures, JSON.stringify(credentialDeployment.unsignedCdi), credentialDeployment.expiry.expiryEpochSeconds));
return credentialDeploymentInfo.transactionHash;

@@ -283,4 +283,4 @@ }

*/
function serializeCredentialDeploymentTransactionForSubmission(credentialDeploymentTransaction, signatures) {
const credentialDeploymentInfo = JSON.parse(wasm.getDeploymentDetails(signatures, JSON.stringify(credentialDeploymentTransaction.unsignedCdi), credentialDeploymentTransaction.expiry.expiryEpochSeconds));
function serializeCredentialDeploymentTransactionForSubmission(credentialDeployment, signatures) {
const credentialDeploymentInfo = JSON.parse(wasm.getDeploymentDetails(signatures, JSON.stringify(credentialDeployment.unsignedCdi), credentialDeployment.expiry.expiryEpochSeconds));
return buffer_1.Buffer.from(credentialDeploymentInfo.serializedTransaction, 'hex');

@@ -287,0 +287,0 @@ }

@@ -820,2 +820,3 @@ import { AccountAddress } from './types/accountAddress';

}
export declare function isAccountTransactionType(candidate: number): candidate is AccountTransactionType;
export interface DeployModulePayload {

@@ -1046,6 +1047,5 @@ /** Version of the wasm module. This should only be supplied if wasm module is not already versioned. */

export declare type InvokeContractResult = InvokeContractSuccessResult | InvokeContractFailedResult;
export interface CredentialDeploymentTransaction {
export interface CredentialDeploymentDetails {
expiry: TransactionExpiry;
unsignedCdi: UnsignedCredentialDeploymentInformation;
randomness: CommitmentsRandomness;
}

@@ -1072,9 +1072,22 @@ export interface IdOwnershipProofs {

}
export interface UnsignedCdiWithRandomness {
unsignedCdi: UnsignedCredentialDeploymentInformation;
interface CdiRandomness {
randomness: CommitmentsRandomness;
}
export declare type CredentialDeploymentTransaction = CredentialDeploymentDetails & CdiRandomness;
/** Internal type used when building credentials */
export declare type UnsignedCdiWithRandomness = {
unsignedCdi: UnsignedCredentialDeploymentInformation;
} & CdiRandomness;
export interface CredentialDeploymentInfo extends CredentialDeploymentValues {
proofs: string;
}
export declare type TypedCredentialDeployment = {
type: 'normal';
contents: CredentialDeploymentInfo;
} | {
type: 'initial';
contents: InitialCredentialDeploymentValues & {
sig: string;
};
};
export interface IdentityProvider {

@@ -1081,0 +1094,0 @@ arsInfos: Record<number, ArInfo>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SchemaVersion = exports.buildInvoker = exports.isInstanceInfoV0 = exports.isInstanceInfoV1 = exports.ParameterType = exports.AccountTransactionType = exports.BlockItemKind = exports.DelegationTargetType = exports.PoolStatusType = exports.BakerPoolPendingChangeType = exports.OpenStatusText = exports.OpenStatus = exports.StakePendingChangeType = exports.instanceOfTransferWithMemoTransactionSummary = exports.RejectReasonTag = exports.TransactionStatusEnum = exports.AttributesKeys = void 0;
exports.SchemaVersion = exports.buildInvoker = exports.isInstanceInfoV0 = exports.isInstanceInfoV1 = exports.ParameterType = exports.isAccountTransactionType = exports.AccountTransactionType = exports.BlockItemKind = exports.DelegationTargetType = exports.PoolStatusType = exports.BakerPoolPendingChangeType = exports.OpenStatusText = exports.OpenStatus = exports.StakePendingChangeType = exports.instanceOfTransferWithMemoTransactionSummary = exports.RejectReasonTag = exports.TransactionStatusEnum = exports.AttributesKeys = void 0;
var AttributesKeys;

@@ -166,2 +166,6 @@ (function (AttributesKeys) {

})(AccountTransactionType = exports.AccountTransactionType || (exports.AccountTransactionType = {}));
function isAccountTransactionType(candidate) {
return candidate in AccountTransactionType;
}
exports.isAccountTransactionType = isAccountTransactionType;
var ParameterType;

@@ -168,0 +172,0 @@ (function (ParameterType) {

@@ -11,2 +11,3 @@ import { Buffer } from 'buffer/';

constructor(address: string);
static fromBytes(bytes: Buffer): AccountAddress;
}

@@ -49,3 +49,6 @@ "use strict";

}
static fromBytes(bytes) {
return new AccountAddress(bs58check.encode(buffer_1.Buffer.concat([buffer_1.Buffer.of(1), bytes])));
}
}
exports.AccountAddress = AccountAddress;

@@ -12,2 +12,3 @@ /**

constructor(expiry: Date);
static fromEpochSeconds(seconds: bigint): TransactionExpiry;
}

@@ -20,3 +20,6 @@ "use strict";

}
static fromEpochSeconds(seconds) {
return new TransactionExpiry(new Date(Number(seconds) * 1000));
}
}
exports.TransactionExpiry = TransactionExpiry;
{
"name": "@concordium/common-sdk",
"version": "2.2.0",
"version": "2.3.0",
"license": "Apache-2.0",

@@ -42,3 +42,3 @@ "engines": {

"dependencies": {
"@concordium/rust-bindings": "0.1.1",
"@concordium/rust-bindings": "0.2.0",
"@noble/ed25519": "^1.6.0",

@@ -45,0 +45,0 @@ "bs58check": "^2.1.2",

@@ -471,2 +471,24 @@ # Common

## Deserialize a transaction
The following example demonstrates how to deserialize a transaction:
```js
const serializedTransaction: Buffer = ...
const deserialized = deserializeTransaction(serializedTransaction);
if (deserialized.kind === BlockItemKind.AccountTransactionKind) {
// transaction is an account transaction
const accountTransaction: AccountTransaction = deserialized.transaction.accountTransaction;
const signatures: AccountTransactionSignature = deserialized.transaction.signatures;
...
if (accountTransaction.type === AccountTransactionType.SimpleTransfer) {
// transaction is a simple transfer
}
} else if (deserialized.kind === BlockItemKind.CredentialDeploymentKind) {
// transaction is a credentialDeployment
const credentialDeployment = deserialized.transaction.credential;
}
```
Note that currently the only supported account transaction kinds are `SimpleTransfer`, `SimpleTransferWithMemo` and `RegisterData`. If attempting to deserialize other transaction kinds, the function will throw an error;
## Sign an account transaction

@@ -473,0 +495,0 @@ The following example demonstrates how to use the `signTransaction` helper function to sign a account transaction: