From 38c90847c7c4cce9e3149194bcdcba429f2d06d4 Mon Sep 17 00:00:00 2001 From: Chun Lam <31641877+sleepyOwl14@users.noreply.github.com> Date: Fri, 19 Apr 2024 21:01:20 +0800 Subject: [PATCH 1/3] Add symbol merge txns and fix account info (#171) * WIP:add new txn and fix txn consistency * fix test cases and minor issue * WIP: add remaining new txns * add new txn into txn builder factory * fix new account REST API structure * fix account info and test case * fix new txns * add export of supplementalPk * add lockMosaics into account info * fix account info test case * add node unlocked accounts and peers fetching --- e2e/conf/conf.spec.ts | 4 +- e2e/infrastructure/MetadataHttp.spec.ts | 2 +- ...Http.spec.ts => NetworkConfigHttp.spec.ts} | 8 +- e2e/infrastructure/TransactionHttp.spec.ts | 2 +- src/infrastructure/AccountHttp.ts | 63 ++- src/infrastructure/ChainUpgradeHttp.ts | 2 +- ...hainConfigHttp.ts => NetworkConfigHttp.ts} | 12 +- ...pository.ts => NetworkConfigRepository.ts} | 8 +- src/infrastructure/NodeHttp.ts | 58 ++- src/infrastructure/api/nodeRoutesApi.ts | 78 ++++ ...ountAddressRestrictionTransactionBuffer.ts | 301 +++++++++++++ ...countMosaicRestrictionTransactionBuffer.ts | 301 +++++++++++++ ...ntOperationRestrictionTransactionBuffer.ts | 328 ++++++++++++++ .../AccountV2UpgradeTransactionBuffer.ts | 246 ++++++++++ src/infrastructure/buffers/AddressBuffer.ts | 68 +++ .../LockFundCancelUnlockTransactionBuffer.ts | 241 ++++++++++ .../LockFundTransferTransactionBuffer.ts | 299 +++++++++++++ ...saicAddressRestrictionTransactionBuffer.ts | 384 ++++++++++++++++ src/infrastructure/buffers/MosaicBuffer.ts | 110 +++++ ...osaicGlobalRestrictionTransactionBuffer.ts | 419 ++++++++++++++++++ src/infrastructure/buffers/MosaicIdBuffer.ts | 73 +++ ...rkConfigAbsoluteHeightTransactionBuffer.ts | 325 ++++++++++++++ ...r.ts => NetworkConfigTransactionBuffer.ts} | 34 +- .../buffers/NodeLinkTransactionBuffer.ts | 256 +++++++++++ .../buffers/VrfLinkTransactionBuffer.ts | 256 +++++++++++ .../AccountAddressRestrictionTransaction.ts | 149 +++++++ .../AccountMosaicRestrictionTransaction.ts | 148 +++++++ .../AccountOperationRestrictionTransaction.ts | 129 ++++++ .../builders/AccountV2UpgradeTransaction.ts | 107 +++++ .../LockFundCancelUnlockTransaction.ts | 98 ++++ .../builders/LockFundTransferTransaction.ts | 124 ++++++ .../MosaicAddressRestrictionTransaction.ts | 142 ++++++ .../MosaicGlobalRestrictionTransaction.ts | 151 +++++++ .../builders/MosaicMetadataTransaction.ts | 1 - .../NetworkConfigAbsoluteHeightTransaction.ts | 116 +++++ ...saction.ts => NetworkConfigTransaction.ts} | 24 +- .../builders/NodeLinkTransaction.ts | 114 +++++ .../builders/VrfLinkTransaction.ts | 114 +++++ src/infrastructure/infrastructure.ts | 2 +- src/infrastructure/model/accountDTO.ts | 40 +- src/infrastructure/model/models.ts | 9 +- src/infrastructure/model/nodePeerInfoDTO.ts | 70 +++ .../model/nodeUnlockedAccountDTO.ts | 34 ++ .../model/supplementalPublicKeysDTO.ts | 48 ++ .../model/transactionStatusTypeEnum.ts | 4 +- ...ountAddressRestrictionTransactionSchema.ts | 34 ++ ...countMosaicRestrictionTransactionSchema.ts | 34 ++ ...ntOperationRestrictionTransactionSchema.ts | 30 ++ .../AccountV2UpgradeTransactionSchema.ts | 25 ++ .../LockFundCancelUnlockTransactionSchema.ts | 25 ++ .../LockFundTransferTransactionSchema.ts | 31 ++ ...saicAddressRestrictionTransactionSchema.ts | 29 ++ ...osaicGlobalRestrictionTransactionSchema.ts | 31 ++ ...rkConfigAbsoluteHeightTransactionSchema.ts | 39 ++ ...a.ts => NetworkConfigTransactionSchema.ts} | 2 +- .../schemas/NodeLinkTransactionSchema.ts | 26 ++ .../schemas/VrfLinkTransactionSchema.ts | 26 ++ .../transaction/CreateTransactionFromDTO.ts | 16 +- .../CreateTransactionFromPayload.ts | 4 +- src/model/account/Account.ts | 2 +- src/model/account/AccountInfo.ts | 16 +- src/model/account/AccountLink.ts | 4 + src/model/account/SupplementalPublicKeys.ts | 23 + .../{ChainConfig.ts => NetworkConfig.ts} | 4 +- src/model/model.ts | 32 +- src/model/mosaic/MosaicRestriction.ts | 14 + src/model/node/NodePeers.ts | 43 ++ src/model/node/NodeUnlockedAccount.ts | 29 ++ .../AccountAddressRestrictionTransaction.ts | 195 ++++++++ .../AccountMosaicRestrictionTransaction.ts | 195 ++++++++ .../AccountOperationRestrictionTransaction.ts | 191 ++++++++ .../AccountV2UpgradeTransaction.ts | 149 +++++++ src/model/transaction/AggregateTransaction.ts | 6 + src/model/transaction/LockFund.ts | 4 + .../LockFundCancelUnlockTransaction.ts | 123 +++++ .../LockFundTransferTransaction.ts | 156 +++++++ .../MosaicAddressRestrictionTransaction.ts | 197 ++++++++ .../MosaicGlobalRestrictionTransaction.ts | 208 +++++++++ .../NetworkConfigAbsoluteHeightTransaction.ts | 153 +++++++ ...saction.ts => NetworkConfigTransaction.ts} | 20 +- src/model/transaction/NodeLinkTransaction.ts | 165 +++++++ .../transaction/TransactionBuilderFactory.ts | 107 ++++- src/model/transaction/TransactionType.ts | 14 +- .../transaction/TransactionTypeVersion.ts | 21 + src/model/transaction/VrfLinkTransaction.ts | 165 +++++++ ...dressRestrictionModificationTransaction.ts | 30 +- ...osaicRestrictionModificationTransaction.ts | 32 +- ...ationRestrictionModificationTransaction.ts | 32 +- .../AccountRestrictionModification.ts | 8 +- .../AccountRestrictionTransaction.ts | 10 +- .../ModifyMetadataTransaction.ts | 33 +- test/core/utils/TransactionMapping.spec.ts | 18 +- ...nConfigHttp.spec.ts => ConfigHttp.spec.ts} | 10 +- .../SerializeTransactionToJSON.spec.ts | 12 +- test/model/account/AccountInfo.spec.ts | 24 +- .../AccountRestrictionTransaction.spec.ts | 4 +- ...ec.ts => NetworkConfigTransaction.spec.ts} | 12 +- 97 files changed, 8097 insertions(+), 218 deletions(-) rename e2e/infrastructure/{ChainConfigHttp.spec.ts => NetworkConfigHttp.spec.ts} (75%) rename src/infrastructure/{ChainConfigHttp.ts => NetworkConfigHttp.ts} (71%) rename src/infrastructure/{ChainConfigRepository.ts => NetworkConfigRepository.ts} (60%) create mode 100644 src/infrastructure/buffers/AccountAddressRestrictionTransactionBuffer.ts create mode 100644 src/infrastructure/buffers/AccountMosaicRestrictionTransactionBuffer.ts create mode 100644 src/infrastructure/buffers/AccountOperationRestrictionTransactionBuffer.ts create mode 100644 src/infrastructure/buffers/AccountV2UpgradeTransactionBuffer.ts create mode 100644 src/infrastructure/buffers/AddressBuffer.ts create mode 100644 src/infrastructure/buffers/LockFundCancelUnlockTransactionBuffer.ts create mode 100644 src/infrastructure/buffers/LockFundTransferTransactionBuffer.ts create mode 100644 src/infrastructure/buffers/MosaicAddressRestrictionTransactionBuffer.ts create mode 100644 src/infrastructure/buffers/MosaicBuffer.ts create mode 100644 src/infrastructure/buffers/MosaicGlobalRestrictionTransactionBuffer.ts create mode 100644 src/infrastructure/buffers/MosaicIdBuffer.ts create mode 100644 src/infrastructure/buffers/NetworkConfigAbsoluteHeightTransactionBuffer.ts rename src/infrastructure/buffers/{ChainConfigTransactionBuffer.ts => NetworkConfigTransactionBuffer.ts} (93%) create mode 100644 src/infrastructure/buffers/NodeLinkTransactionBuffer.ts create mode 100644 src/infrastructure/buffers/VrfLinkTransactionBuffer.ts create mode 100644 src/infrastructure/builders/AccountAddressRestrictionTransaction.ts create mode 100644 src/infrastructure/builders/AccountMosaicRestrictionTransaction.ts create mode 100644 src/infrastructure/builders/AccountOperationRestrictionTransaction.ts create mode 100644 src/infrastructure/builders/AccountV2UpgradeTransaction.ts create mode 100644 src/infrastructure/builders/LockFundCancelUnlockTransaction.ts create mode 100644 src/infrastructure/builders/LockFundTransferTransaction.ts create mode 100644 src/infrastructure/builders/MosaicAddressRestrictionTransaction.ts create mode 100644 src/infrastructure/builders/MosaicGlobalRestrictionTransaction.ts create mode 100644 src/infrastructure/builders/NetworkConfigAbsoluteHeightTransaction.ts rename src/infrastructure/builders/{ChainConfigTransaction.ts => NetworkConfigTransaction.ts} (80%) create mode 100644 src/infrastructure/builders/NodeLinkTransaction.ts create mode 100644 src/infrastructure/builders/VrfLinkTransaction.ts create mode 100644 src/infrastructure/model/nodePeerInfoDTO.ts create mode 100644 src/infrastructure/model/nodeUnlockedAccountDTO.ts create mode 100644 src/infrastructure/model/supplementalPublicKeysDTO.ts create mode 100644 src/infrastructure/schemas/AccountAddressRestrictionTransactionSchema.ts create mode 100644 src/infrastructure/schemas/AccountMosaicRestrictionTransactionSchema.ts create mode 100644 src/infrastructure/schemas/AccountOperationRestrictionTransactionSchema.ts create mode 100644 src/infrastructure/schemas/AccountV2UpgradeTransactionSchema.ts create mode 100644 src/infrastructure/schemas/LockFundCancelUnlockTransactionSchema.ts create mode 100644 src/infrastructure/schemas/LockFundTransferTransactionSchema.ts create mode 100644 src/infrastructure/schemas/MosaicAddressRestrictionTransactionSchema.ts create mode 100644 src/infrastructure/schemas/MosaicGlobalRestrictionTransactionSchema.ts create mode 100644 src/infrastructure/schemas/NetworkConfigAbsoluteHeightTransactionSchema.ts rename src/infrastructure/schemas/{ChainConfigTransactionSchema.ts => NetworkConfigTransactionSchema.ts} (94%) create mode 100644 src/infrastructure/schemas/NodeLinkTransactionSchema.ts create mode 100644 src/infrastructure/schemas/VrfLinkTransactionSchema.ts create mode 100644 src/model/account/AccountLink.ts create mode 100644 src/model/account/SupplementalPublicKeys.ts rename src/model/config/{ChainConfig.ts => NetworkConfig.ts} (92%) create mode 100644 src/model/mosaic/MosaicRestriction.ts create mode 100644 src/model/node/NodePeers.ts create mode 100644 src/model/node/NodeUnlockedAccount.ts create mode 100644 src/model/transaction/AccountAddressRestrictionTransaction.ts create mode 100644 src/model/transaction/AccountMosaicRestrictionTransaction.ts create mode 100644 src/model/transaction/AccountOperationRestrictionTransaction.ts create mode 100644 src/model/transaction/AccountV2UpgradeTransaction.ts create mode 100644 src/model/transaction/LockFund.ts create mode 100644 src/model/transaction/LockFundCancelUnlockTransaction.ts create mode 100644 src/model/transaction/LockFundTransferTransaction.ts create mode 100644 src/model/transaction/MosaicAddressRestrictionTransaction.ts create mode 100644 src/model/transaction/MosaicGlobalRestrictionTransaction.ts create mode 100644 src/model/transaction/NetworkConfigAbsoluteHeightTransaction.ts rename src/model/transaction/{ChainConfigTransaction.ts => NetworkConfigTransaction.ts} (86%) create mode 100644 src/model/transaction/NodeLinkTransaction.ts create mode 100644 src/model/transaction/VrfLinkTransaction.ts rename src/model/transaction/{ => deprecated}/AccountAddressRestrictionModificationTransaction.ts (88%) rename src/model/transaction/{ => deprecated}/AccountMosaicRestrictionModificationTransaction.ts (88%) rename src/model/transaction/{ => deprecated}/AccountOperationRestrictionModificationTransaction.ts (88%) rename src/model/transaction/{ => deprecated}/AccountRestrictionModification.ts (92%) rename src/model/transaction/{ => deprecated}/AccountRestrictionTransaction.ts (94%) rename src/model/transaction/{ => deprecated}/ModifyMetadataTransaction.ts (89%) rename test/infrastructure/{ChainConfigHttp.spec.ts => ConfigHttp.spec.ts} (78%) rename test/model/transaction/{ChainConfigTransaction.spec.ts => NetworkConfigTransaction.spec.ts} (73%) diff --git a/e2e/conf/conf.spec.ts b/e2e/conf/conf.spec.ts index 28e097ec..cfea8767 100644 --- a/e2e/conf/conf.spec.ts +++ b/e2e/conf/conf.spec.ts @@ -1,7 +1,7 @@ const conf = require("config"); import { MosaicId, NamespaceId, TransactionType, RegisterNamespaceTransaction, MosaicDefinitionTransaction, - TransferTransaction, TransactionInfo, MosaicNonce, MosaicProperties, UInt64, BlockInfo, ChainConfigTransaction, TransactionBuilderFactory, NetworkType, Account, Transaction } from '../../src/model/model'; + TransferTransaction, TransactionInfo, MosaicNonce, MosaicProperties, UInt64, BlockInfo, NetworkConfigTransaction, TransactionBuilderFactory, NetworkType, Account, Transaction } from '../../src/model/model'; import { ConfUtils } from './ConfUtils'; import { AccountHttp, TransactionHttp, NamespaceHttp, MosaicHttp, BlockHttp, TransactionQueryParams } from '../../src/infrastructure/infrastructure'; import { firstValueFrom } from "rxjs" @@ -226,7 +226,7 @@ const GetNemesisBlockDataPromise = () => { const testNamespace = currencyNamespace ? currencyNamespace : regNamespaceTxs[0]; const regMosaicTx = txs.find(tx => tx.type === TransactionType.MOSAIC_DEFINITION) as MosaicDefinitionTransaction; const transferTx = txs.find(tx => tx.type === TransactionType.TRANSFER) as TransferTransaction; - const config = txs.find(tx => tx.type === TransactionType.CHAIN_CONFIGURE) as ChainConfigTransaction; + const config = txs.find(tx => tx.type === TransactionType.CHAIN_CONFIGURE) as NetworkConfigTransaction; return { nemesisBlockInfo, diff --git a/e2e/infrastructure/MetadataHttp.spec.ts b/e2e/infrastructure/MetadataHttp.spec.ts index 9edd61f7..a2868e42 100644 --- a/e2e/infrastructure/MetadataHttp.spec.ts +++ b/e2e/infrastructure/MetadataHttp.spec.ts @@ -7,7 +7,7 @@ import { APIUrl, TestingAccount, ConfTestingNamespaceId, ConfTestingMosaicId, Co import { MetadataHttp } from '../../src/infrastructure/MetadataHttp'; import { Address, Transaction, TransactionBuilderFactory, UInt64, Mosaic, NamespaceId } from '../../src/model/model'; import { Convert as convert } from '../../src/core/format'; -import { MetadataModification, MetadataModificationType } from '../../src/model/transaction/ModifyMetadataTransaction'; +import { MetadataModification, MetadataModificationType } from '../../src/model/transaction/deprecated/ModifyMetadataTransaction'; import { TransactionHttp, Listener } from '../../src/infrastructure/infrastructure'; import { validateTransactionConfirmed, validatePartialTransactionNotPartialAnyMore, validatePartialTransactionAnnouncedCorrectly } from '../utils'; import { fail } from 'assert'; diff --git a/e2e/infrastructure/ChainConfigHttp.spec.ts b/e2e/infrastructure/NetworkConfigHttp.spec.ts similarity index 75% rename from e2e/infrastructure/ChainConfigHttp.spec.ts rename to e2e/infrastructure/NetworkConfigHttp.spec.ts index 1627cc49..454cb6e3 100644 --- a/e2e/infrastructure/ChainConfigHttp.spec.ts +++ b/e2e/infrastructure/NetworkConfigHttp.spec.ts @@ -4,13 +4,13 @@ import {expect} from 'chai'; import { APIUrl } from '../conf/conf.spec'; -import { ChainConfigHttp } from '../../src/infrastructure/ChainConfigHttp'; -describe('ChainConfigHttp', () => { - let chainConfigHttp = new ChainConfigHttp(APIUrl); +import { NetworkConfigHttp } from '../../src/infrastructure/NetworkConfigHttp'; +describe('NetworkConfigHttp', () => { + let chainConfigHttp = new NetworkConfigHttp(APIUrl); describe('getChainConfig', () => { it('should return blockchain config', (done) => { - chainConfigHttp.getChainConfig(1) + chainConfigHttp.getNetworkConfig(1) .subscribe((chainConfig) => { expect(chainConfig.height.compact()).to.be.equal(1); expect(chainConfig.networkConfig).not.to.be.undefined; diff --git a/e2e/infrastructure/TransactionHttp.spec.ts b/e2e/infrastructure/TransactionHttp.spec.ts index 3db04a6d..301289f5 100644 --- a/e2e/infrastructure/TransactionHttp.spec.ts +++ b/e2e/infrastructure/TransactionHttp.spec.ts @@ -1248,7 +1248,7 @@ describe('TransactionHttp', () => { describe('ChainConfigTransaction', () => { ((NemesisAccount.privateKey !== "0".repeat(64)) ? it : it.skip)('standalone', (done) => { GetNemesisBlockDataPromise().then(nemesisBlockInfo => { - const chainConfigTransaction = factory.chainConfig() + const chainConfigTransaction = factory.networkConfig() .applyHeightDelta(UInt64.fromUint(10)) .networkConfig(nemesisBlockInfo.config.networkConfig) .supportedEntityVersions(nemesisBlockInfo.config.supportedEntityVersions) diff --git a/src/infrastructure/AccountHttp.ts b/src/infrastructure/AccountHttp.ts index 5420b20c..aa427df3 100644 --- a/src/infrastructure/AccountHttp.ts +++ b/src/infrastructure/AccountHttp.ts @@ -18,7 +18,8 @@ import {from as observableFrom, Observable} from 'rxjs'; import {map, mergeMap} from 'rxjs/operators'; import { DtoMapping } from '../core/utils/DtoMapping'; -import {AccountInfo} from '../model/account/AccountInfo'; +import { AccountInfo } from '../model/account/AccountInfo'; +import { SupplementalPublicKeys } from '../model/account/SupplementalPublicKeys'; import { AccountNames } from '../model/account/AccountNames'; import { AccountRestrictionsInfo } from '../model/account/AccountRestrictionsInfo'; import {Address} from '../model/account/Address'; @@ -91,18 +92,44 @@ export class AccountHttp extends Http implements AccountRepository { return observableFrom(this.accountRoutesApi.getAccountInfo(address.plain(), requestOptions)).pipe( map((response: AccountInfoResponse) => { const accountInfoDTO = response.body; + const accVersion = accountInfoDTO.account.version ?? 1; + const address = Address.createFromEncoded(accountInfoDTO.account.address); return new AccountInfo( accountInfoDTO.meta, - Address.createFromEncoded(accountInfoDTO.account.address), + address, new UInt64(accountInfoDTO.account.addressHeight), accountInfoDTO.account.publicKey, new UInt64(accountInfoDTO.account.publicKeyHeight), accountInfoDTO.account.accountType.valueOf(), - accountInfoDTO.account.linkedAccountKey, accountInfoDTO.account.mosaics.map((mosaicDTO) => new Mosaic( new MosaicId(mosaicDTO.id), new UInt64(mosaicDTO.amount), )), + accountInfoDTO.account.lockedMosaics ? + accountInfoDTO.account.lockedMosaics.map((mosaicDTO) => new Mosaic( + new MosaicId(mosaicDTO.id), + new UInt64(mosaicDTO.amount), + )): [], + accountInfoDTO.account.linkedAccountKey, + accountInfoDTO.account.supplementalPublicKeys ? + new SupplementalPublicKeys( + accountInfoDTO.account.supplementalPublicKeys.linked ? + PublicAccount.createFromPublicKey( + accountInfoDTO.account.supplementalPublicKeys.linked, + address.networkType + ) : undefined, + accountInfoDTO.account.supplementalPublicKeys.node ? + PublicAccount.createFromPublicKey( + accountInfoDTO.account.supplementalPublicKeys.node, + address.networkType + ) : undefined, + accountInfoDTO.account.supplementalPublicKeys.vrf ? + PublicAccount.createFromPublicKey( + accountInfoDTO.account.supplementalPublicKeys.vrf, + address.networkType + ) : undefined, + ) : undefined, + accVersion ); }) ); @@ -151,16 +178,42 @@ export class AccountHttp extends Http implements AccountRepository { this.accountRoutesApi.getAccountsInfo(accountIdsBody, requestOptions)) .pipe(map((response: AccountsInfoResponse) => { return response.body.map((accountInfoDTO: AccountInfoDTO) => { + const accVersion = accountInfoDTO.account.version ?? 1; + const address = Address.createFromEncoded(accountInfoDTO.account.address); return new AccountInfo( accountInfoDTO.meta, - Address.createFromEncoded(accountInfoDTO.account.address), + address, new UInt64(accountInfoDTO.account.addressHeight), accountInfoDTO.account.publicKey, new UInt64(accountInfoDTO.account.publicKeyHeight), accountInfoDTO.account.accountType.valueOf(), - accountInfoDTO.account.linkedAccountKey, accountInfoDTO.account.mosaics.map((mosaicDTO: MosaicDTO) => new Mosaic(new MosaicId(mosaicDTO.id), new UInt64(mosaicDTO.amount))), + accountInfoDTO.account.lockedMosaics ? + accountInfoDTO.account.lockedMosaics.map((mosaicDTO) => new Mosaic( + new MosaicId(mosaicDTO.id), + new UInt64(mosaicDTO.amount), + )): [], + accountInfoDTO.account.linkedAccountKey, + accountInfoDTO.account.supplementalPublicKeys ? + new SupplementalPublicKeys( + accountInfoDTO.account.supplementalPublicKeys.linked ? + PublicAccount.createFromPublicKey( + accountInfoDTO.account.supplementalPublicKeys.linked, + address.networkType + ) : undefined, + accountInfoDTO.account.supplementalPublicKeys.node ? + PublicAccount.createFromPublicKey( + accountInfoDTO.account.supplementalPublicKeys.node, + address.networkType + ) : undefined, + accountInfoDTO.account.supplementalPublicKeys.vrf ? + PublicAccount.createFromPublicKey( + accountInfoDTO.account.supplementalPublicKeys.vrf, + address.networkType + ) : undefined, + ) : undefined, + accVersion ); }); })); diff --git a/src/infrastructure/ChainUpgradeHttp.ts b/src/infrastructure/ChainUpgradeHttp.ts index 26e57192..5f4913d4 100644 --- a/src/infrastructure/ChainUpgradeHttp.ts +++ b/src/infrastructure/ChainUpgradeHttp.ts @@ -34,7 +34,7 @@ export class ChainUpgradeHttp extends Http implements ChainUpgradeRepository { /** * Gets blockchain configuration at given height * @param height - * @returns Observable + * @returns Observable */ public getChainUpgrade(height: number, requestOptions?: RequestOptions): Observable { return observableFrom( diff --git a/src/infrastructure/ChainConfigHttp.ts b/src/infrastructure/NetworkConfigHttp.ts similarity index 71% rename from src/infrastructure/ChainConfigHttp.ts rename to src/infrastructure/NetworkConfigHttp.ts index 7e0e1cb7..83a5e27e 100644 --- a/src/infrastructure/ChainConfigHttp.ts +++ b/src/infrastructure/NetworkConfigHttp.ts @@ -5,9 +5,9 @@ import {from as observableFrom, Observable} from 'rxjs'; import {map} from 'rxjs/operators'; import { ConfigRoutesApi, NetworkConfigResponse } from './api'; -import { ChainConfigRepository } from './ChainConfigRepository'; +import { NetworkConfigRepository } from './NetworkConfigRepository'; import {Http} from './Http'; -import { ChainConfig } from '../model/model'; +import { NetworkConfig } from '../model/model'; import { RequestOptions } from './RequestOptions'; /** @@ -15,7 +15,7 @@ import { RequestOptions } from './RequestOptions'; * * @since 1.0 */ -export class ChainConfigHttp extends Http implements ChainConfigRepository { +export class NetworkConfigHttp extends Http implements NetworkConfigRepository { /** * @internal * xpx chain Library chain config routes api @@ -34,14 +34,14 @@ export class ChainConfigHttp extends Http implements ChainConfigRepository { /** * Gets blockchain configuration at given height * @param height - * @returns Observable + * @returns Observable */ - public getChainConfig(height: number, requestOptions?: RequestOptions): Observable { + public getNetworkConfig(height: number, requestOptions?: RequestOptions): Observable { return observableFrom( this.configRoutesApi.getConfig(height, requestOptions)) .pipe( map((response: NetworkConfigResponse) => { - return ChainConfig.createFromDTO(response.body.networkConfig); + return NetworkConfig.createFromDTO(response.body.networkConfig); }) ); } diff --git a/src/infrastructure/ChainConfigRepository.ts b/src/infrastructure/NetworkConfigRepository.ts similarity index 60% rename from src/infrastructure/ChainConfigRepository.ts rename to src/infrastructure/NetworkConfigRepository.ts index 6aae5e0c..db082cfe 100644 --- a/src/infrastructure/ChainConfigRepository.ts +++ b/src/infrastructure/NetworkConfigRepository.ts @@ -3,7 +3,7 @@ // license that can be found in the LICENSE file import {Observable} from 'rxjs'; -import { ChainConfig } from '../model/model'; +import { NetworkConfig } from '../model/model'; import { RequestOptions } from './RequestOptions'; /** @@ -11,11 +11,11 @@ import { RequestOptions } from './RequestOptions'; * * @since 1.0 */ -export interface ChainConfigRepository { +export interface NetworkConfigRepository { /** * Gets config at given height - * @returns Observable + * @returns Observable */ - getChainConfig(height: number, requestOptions?: RequestOptions): Observable; + getNetworkConfig(height: number, requestOptions?: RequestOptions): Observable; } diff --git a/src/infrastructure/NodeHttp.ts b/src/infrastructure/NodeHttp.ts index 0138e7c2..739e676e 100644 --- a/src/infrastructure/NodeHttp.ts +++ b/src/infrastructure/NodeHttp.ts @@ -1,5 +1,5 @@ /* - * Copyright 2023 ProximaX + * Copyright 2024 ProximaX * Copyright 2019 NEM * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,13 +16,18 @@ */ import {from as observableFrom, Observable} from 'rxjs'; -import {map} from 'rxjs/operators'; +import {map, mergeMap} from 'rxjs/operators'; import { NodeInfo } from '../model/node/NodeInfo'; import { NodeTime } from '../model/node/NodeTime'; -import { NodeInfoResponse, NodeRoutesApi, NodeTimeResponse } from './api'; +import { NodeUnlockedAccount } from '../model/node/NodeUnlockedAccount'; +import { NodePeers, PeerInfo } from '../model/node/NodePeers'; +import { NodeInfoResponse, NodePeersResponse, NodeRoutesApi, NodeTimeResponse, NodeUnlockedAccountResponse } from './api'; import {Http} from './Http'; import {NodeRepository} from './NodeRepository'; import { RequestOptions } from './RequestOptions'; +import { PublicAccount } from "../model/account/PublicAccount"; +import { NetworkType } from '../model/model'; +import {NetworkHttp} from './NetworkHttp'; /** * Node http repository. @@ -39,11 +44,12 @@ export class NodeHttp extends Http implements NodeRepository { /** * Constructor * @param url + * @param networkHttp */ - constructor(url: string) { - super(); + constructor(url: string, networkHttp?: NetworkHttp) { + networkHttp = networkHttp == null ? new NetworkHttp(url) : networkHttp; + super(networkHttp); this.nodeRoutesApi = new NodeRoutesApi(url); - } /** @@ -79,4 +85,44 @@ export class NodeHttp extends Http implements NodeRepository { }) ); } + + public getNodeUnlockedAccounts(requestOptions?: RequestOptions): Observable { + return this.getNetworkTypeObservable(requestOptions).pipe( + mergeMap((networkType: NetworkType) => + observableFrom(this.nodeRoutesApi.getNodeUnlockedAccounts(requestOptions)) + .pipe( + map((response: NodeUnlockedAccountResponse) => { + const nodeUnlockedAccountDTOs = response.body; + return new NodeUnlockedAccount( + nodeUnlockedAccountDTOs.map( + x => PublicAccount.createFromPublicKey(x.PublicKey, networkType) + ) + ); + }) + ) + ) + ); + } + + public getNodePeers(requestOptions?: RequestOptions): Observable { + return observableFrom(this.nodeRoutesApi.getNodePeers(requestOptions)) + .pipe( + map((response: NodePeersResponse) => { + const nodePeersDTOs = response.body; + return new NodePeers( + nodePeersDTOs.map( + x => new PeerInfo( + x.publicKey, + x.port, + x.networkIdentifier, + x.version, + x.roles, + x.host, + x.friendlyName + ) + ) + ); + }) + ) + } } diff --git a/src/infrastructure/api/nodeRoutesApi.ts b/src/infrastructure/api/nodeRoutesApi.ts index 1943a2ba..b27a6cca 100644 --- a/src/infrastructure/api/nodeRoutesApi.ts +++ b/src/infrastructure/api/nodeRoutesApi.ts @@ -9,6 +9,8 @@ import {AxiosRequestConfig, AxiosResponse, AxiosError} from 'axios'; /* tslint:disable:no-unused-locals */ import { NodeInfoDTO } from '../model/nodeInfoDTO'; import { NodeTimeDTO } from '../model/nodeTimeDTO'; +import { NodePeerInfoDTO } from '../model/nodePeerInfoDTO'; +import { NodeUnlockedAccountDTO } from '../model/nodeUnlockedAccountDTO'; import { RequestOptions } from '../RequestOptions'; import { ObjectSerializer } from '../model/models'; @@ -25,6 +27,16 @@ export interface NodeTimeResponse{ body: NodeTimeDTO; } +export interface NodePeersResponse{ + response: AxiosResponse; + body: Array; +} + +export interface NodeUnlockedAccountResponse{ + response: AxiosResponse; + body: Array; +} + let defaultBasePath = 'http://localhost:3000'; export enum NodeRoutesApiApiKeys { @@ -141,4 +153,70 @@ export class NodeRoutesApi { ); }); } + + /** + * Get the unlocked accouns from the node + * @summary Get unlocked accouns from the node + */ + public async getNodeUnlockedAccounts (reqOptions?:RequestOptions) : Promise { + const localVarPath = '/node/unlockedaccount'; + let requestHeaders = this.combineHeaders(reqOptions); + + let localVarRequestOptions: AxiosRequestConfig = { + method: 'GET', + headers: requestHeaders, + url: localVarPath, + baseURL: this.basePath, + responseType: 'json' + }; + + return new Promise((resolve, reject) => { + axios(localVarRequestOptions).then( + (response)=>{ + let body = ObjectSerializer.deserialize(response.data, "Array"); + if (response.status && response.status >= 200 && response.status <= 299) { + resolve({ response: response, body: body }); + } else { + reject(response); + } + }, + (error: AxiosError ) => { + reject(error); + } + ); + }); + } + + /** + * Get peer from the node + * @summary Get peer from the node + */ + public async getNodePeers (reqOptions?:RequestOptions) : Promise { + const localVarPath = '/node/peers'; + let requestHeaders = this.combineHeaders(reqOptions); + + let localVarRequestOptions: AxiosRequestConfig = { + method: 'GET', + headers: requestHeaders, + url: localVarPath, + baseURL: this.basePath, + responseType: 'json' + }; + + return new Promise((resolve, reject) => { + axios(localVarRequestOptions).then( + (response)=>{ + let body = ObjectSerializer.deserialize(response.data, "Array"); + if (response.status && response.status >= 200 && response.status <= 299) { + resolve({ response: response, body: body }); + } else { + reject(response); + } + }, + (error: AxiosError ) => { + reject(error); + } + ); + }); + } } diff --git a/src/infrastructure/buffers/AccountAddressRestrictionTransactionBuffer.ts b/src/infrastructure/buffers/AccountAddressRestrictionTransactionBuffer.ts new file mode 100644 index 00000000..ecb6b260 --- /dev/null +++ b/src/infrastructure/buffers/AccountAddressRestrictionTransactionBuffer.ts @@ -0,0 +1,301 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { AddressBuffer } from './AddressBuffer'; + + +export class AccountAddressRestrictionTransactionBuffer { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):AccountAddressRestrictionTransactionBuffer { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsAccountAddressRestrictionTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:AccountAddressRestrictionTransactionBuffer):AccountAddressRestrictionTransactionBuffer { + return (obj || new AccountAddressRestrictionTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsAccountAddressRestrictionTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:AccountAddressRestrictionTransactionBuffer):AccountAddressRestrictionTransactionBuffer { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new AccountAddressRestrictionTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +size():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +signature(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signatureLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signatureArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +signer(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signerLength():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signerArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +version():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +type():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +maxFee(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +maxFeeLength():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +maxFeeArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +deadline(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +deadlineLength():number { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +deadlineArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +restrictionFlags():number { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +restrictionAdditionsCount():number { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; +} + +restrictionDeletionsCount():number { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; +} + +accountRestrictionTransactionBodyReserved1():number { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +restrictionAdditions(index: number, obj?:AddressBuffer):AddressBuffer|null { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? (obj || new AddressBuffer()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +restrictionAdditionsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +restrictionDeletions(index: number, obj?:AddressBuffer):AddressBuffer|null { + const offset = this.bb!.__offset(this.bb_pos, 28); + return offset ? (obj || new AddressBuffer()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +restrictionDeletionsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 28); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +static startAccountAddressRestrictionTransactionBuffer(builder:flatbuffers.Builder) { + builder.startObject(13); +} + +static addSize(builder:flatbuffers.Builder, size:number) { + builder.addFieldInt32(0, size, 0); +} + +static addSignature(builder:flatbuffers.Builder, signatureOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, signatureOffset, 0); +} + +static createSignatureVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignatureVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addSigner(builder:flatbuffers.Builder, signerOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, signerOffset, 0); +} + +static createSignerVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignerVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addVersion(builder:flatbuffers.Builder, version:number) { + builder.addFieldInt32(3, version, 0); +} + +static addType(builder:flatbuffers.Builder, type:number) { + builder.addFieldInt16(4, type, 0); +} + +static addMaxFee(builder:flatbuffers.Builder, maxFeeOffset:flatbuffers.Offset) { + builder.addFieldOffset(5, maxFeeOffset, 0); +} + +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startMaxFeeVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDeadline(builder:flatbuffers.Builder, deadlineOffset:flatbuffers.Offset) { + builder.addFieldOffset(6, deadlineOffset, 0); +} + +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startDeadlineVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addRestrictionFlags(builder:flatbuffers.Builder, restrictionFlags:number) { + builder.addFieldInt16(7, restrictionFlags, 0); +} + +static addRestrictionAdditionsCount(builder:flatbuffers.Builder, restrictionAdditionsCount:number) { + builder.addFieldInt8(8, restrictionAdditionsCount, 0); +} + +static addRestrictionDeletionsCount(builder:flatbuffers.Builder, restrictionDeletionsCount:number) { + builder.addFieldInt8(9, restrictionDeletionsCount, 0); +} + +static addAccountRestrictionTransactionBodyReserved1(builder:flatbuffers.Builder, accountRestrictionTransactionBodyReserved1:number) { + builder.addFieldInt32(10, accountRestrictionTransactionBodyReserved1, 0); +} + +static addRestrictionAdditions(builder:flatbuffers.Builder, restrictionAdditionsOffset:flatbuffers.Offset) { + builder.addFieldOffset(11, restrictionAdditionsOffset, 0); +} + +static createRestrictionAdditionsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startRestrictionAdditionsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addRestrictionDeletions(builder:flatbuffers.Builder, restrictionDeletionsOffset:flatbuffers.Offset) { + builder.addFieldOffset(12, restrictionDeletionsOffset, 0); +} + +static createRestrictionDeletionsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startRestrictionDeletionsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static endAccountAddressRestrictionTransactionBuffer(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createAccountAddressRestrictionTransactionBuffer(builder:flatbuffers.Builder, size:number, signatureOffset:flatbuffers.Offset, signerOffset:flatbuffers.Offset, version:number, type:number, maxFeeOffset:flatbuffers.Offset, deadlineOffset:flatbuffers.Offset, restrictionFlags:number, restrictionAdditionsCount:number, restrictionDeletionsCount:number, accountRestrictionTransactionBodyReserved1:number, restrictionAdditionsOffset:flatbuffers.Offset, restrictionDeletionsOffset:flatbuffers.Offset):flatbuffers.Offset { + AccountAddressRestrictionTransactionBuffer.startAccountAddressRestrictionTransactionBuffer(builder); + AccountAddressRestrictionTransactionBuffer.addSize(builder, size); + AccountAddressRestrictionTransactionBuffer.addSignature(builder, signatureOffset); + AccountAddressRestrictionTransactionBuffer.addSigner(builder, signerOffset); + AccountAddressRestrictionTransactionBuffer.addVersion(builder, version); + AccountAddressRestrictionTransactionBuffer.addType(builder, type); + AccountAddressRestrictionTransactionBuffer.addMaxFee(builder, maxFeeOffset); + AccountAddressRestrictionTransactionBuffer.addDeadline(builder, deadlineOffset); + AccountAddressRestrictionTransactionBuffer.addRestrictionFlags(builder, restrictionFlags); + AccountAddressRestrictionTransactionBuffer.addRestrictionAdditionsCount(builder, restrictionAdditionsCount); + AccountAddressRestrictionTransactionBuffer.addRestrictionDeletionsCount(builder, restrictionDeletionsCount); + AccountAddressRestrictionTransactionBuffer.addAccountRestrictionTransactionBodyReserved1(builder, accountRestrictionTransactionBodyReserved1); + AccountAddressRestrictionTransactionBuffer.addRestrictionAdditions(builder, restrictionAdditionsOffset); + AccountAddressRestrictionTransactionBuffer.addRestrictionDeletions(builder, restrictionDeletionsOffset); + return AccountAddressRestrictionTransactionBuffer.endAccountAddressRestrictionTransactionBuffer(builder); +} +} diff --git a/src/infrastructure/buffers/AccountMosaicRestrictionTransactionBuffer.ts b/src/infrastructure/buffers/AccountMosaicRestrictionTransactionBuffer.ts new file mode 100644 index 00000000..b758a0e1 --- /dev/null +++ b/src/infrastructure/buffers/AccountMosaicRestrictionTransactionBuffer.ts @@ -0,0 +1,301 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { MosaicId } from './MosaicIdBuffer'; + + +export class AccountMosaicRestrictionTransactionBuffer { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):AccountMosaicRestrictionTransactionBuffer { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsAccountMosaicRestrictionTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:AccountMosaicRestrictionTransactionBuffer):AccountMosaicRestrictionTransactionBuffer { + return (obj || new AccountMosaicRestrictionTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsAccountMosaicRestrictionTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:AccountMosaicRestrictionTransactionBuffer):AccountMosaicRestrictionTransactionBuffer { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new AccountMosaicRestrictionTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +size():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +signature(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signatureLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signatureArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +signer(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signerLength():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signerArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +version():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +type():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +maxFee(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +maxFeeLength():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +maxFeeArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +deadline(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +deadlineLength():number { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +deadlineArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +restrictionFlags():number { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +restrictionAdditionsCount():number { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; +} + +restrictionDeletionsCount():number { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; +} + +accountRestrictionTransactionBodyReserved1():number { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +restrictionAdditions(index: number, obj?:MosaicId):MosaicId|null { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? (obj || new MosaicId()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +restrictionAdditionsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +restrictionDeletions(index: number, obj?:MosaicId):MosaicId|null { + const offset = this.bb!.__offset(this.bb_pos, 28); + return offset ? (obj || new MosaicId()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +restrictionDeletionsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 28); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +static startAccountMosaicRestrictionTransactionBuffer(builder:flatbuffers.Builder) { + builder.startObject(13); +} + +static addSize(builder:flatbuffers.Builder, size:number) { + builder.addFieldInt32(0, size, 0); +} + +static addSignature(builder:flatbuffers.Builder, signatureOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, signatureOffset, 0); +} + +static createSignatureVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignatureVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addSigner(builder:flatbuffers.Builder, signerOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, signerOffset, 0); +} + +static createSignerVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignerVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addVersion(builder:flatbuffers.Builder, version:number) { + builder.addFieldInt32(3, version, 0); +} + +static addType(builder:flatbuffers.Builder, type:number) { + builder.addFieldInt16(4, type, 0); +} + +static addMaxFee(builder:flatbuffers.Builder, maxFeeOffset:flatbuffers.Offset) { + builder.addFieldOffset(5, maxFeeOffset, 0); +} + +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startMaxFeeVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDeadline(builder:flatbuffers.Builder, deadlineOffset:flatbuffers.Offset) { + builder.addFieldOffset(6, deadlineOffset, 0); +} + +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startDeadlineVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addRestrictionFlags(builder:flatbuffers.Builder, restrictionFlags:number) { + builder.addFieldInt16(7, restrictionFlags, 0); +} + +static addRestrictionAdditionsCount(builder:flatbuffers.Builder, restrictionAdditionsCount:number) { + builder.addFieldInt8(8, restrictionAdditionsCount, 0); +} + +static addRestrictionDeletionsCount(builder:flatbuffers.Builder, restrictionDeletionsCount:number) { + builder.addFieldInt8(9, restrictionDeletionsCount, 0); +} + +static addAccountRestrictionTransactionBodyReserved1(builder:flatbuffers.Builder, accountRestrictionTransactionBodyReserved1:number) { + builder.addFieldInt32(10, accountRestrictionTransactionBodyReserved1, 0); +} + +static addRestrictionAdditions(builder:flatbuffers.Builder, restrictionAdditionsOffset:flatbuffers.Offset) { + builder.addFieldOffset(11, restrictionAdditionsOffset, 0); +} + +static createRestrictionAdditionsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startRestrictionAdditionsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addRestrictionDeletions(builder:flatbuffers.Builder, restrictionDeletionsOffset:flatbuffers.Offset) { + builder.addFieldOffset(12, restrictionDeletionsOffset, 0); +} + +static createRestrictionDeletionsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startRestrictionDeletionsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static endAccountMosaicRestrictionTransactionBuffer(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createAccountMosaicRestrictionTransactionBuffer(builder:flatbuffers.Builder, size:number, signatureOffset:flatbuffers.Offset, signerOffset:flatbuffers.Offset, version:number, type:number, maxFeeOffset:flatbuffers.Offset, deadlineOffset:flatbuffers.Offset, restrictionFlags:number, restrictionAdditionsCount:number, restrictionDeletionsCount:number, accountRestrictionTransactionBodyReserved1:number, restrictionAdditionsOffset:flatbuffers.Offset, restrictionDeletionsOffset:flatbuffers.Offset):flatbuffers.Offset { + AccountMosaicRestrictionTransactionBuffer.startAccountMosaicRestrictionTransactionBuffer(builder); + AccountMosaicRestrictionTransactionBuffer.addSize(builder, size); + AccountMosaicRestrictionTransactionBuffer.addSignature(builder, signatureOffset); + AccountMosaicRestrictionTransactionBuffer.addSigner(builder, signerOffset); + AccountMosaicRestrictionTransactionBuffer.addVersion(builder, version); + AccountMosaicRestrictionTransactionBuffer.addType(builder, type); + AccountMosaicRestrictionTransactionBuffer.addMaxFee(builder, maxFeeOffset); + AccountMosaicRestrictionTransactionBuffer.addDeadline(builder, deadlineOffset); + AccountMosaicRestrictionTransactionBuffer.addRestrictionFlags(builder, restrictionFlags); + AccountMosaicRestrictionTransactionBuffer.addRestrictionAdditionsCount(builder, restrictionAdditionsCount); + AccountMosaicRestrictionTransactionBuffer.addRestrictionDeletionsCount(builder, restrictionDeletionsCount); + AccountMosaicRestrictionTransactionBuffer.addAccountRestrictionTransactionBodyReserved1(builder, accountRestrictionTransactionBodyReserved1); + AccountMosaicRestrictionTransactionBuffer.addRestrictionAdditions(builder, restrictionAdditionsOffset); + AccountMosaicRestrictionTransactionBuffer.addRestrictionDeletions(builder, restrictionDeletionsOffset); + return AccountMosaicRestrictionTransactionBuffer.endAccountMosaicRestrictionTransactionBuffer(builder); +} +} diff --git a/src/infrastructure/buffers/AccountOperationRestrictionTransactionBuffer.ts b/src/infrastructure/buffers/AccountOperationRestrictionTransactionBuffer.ts new file mode 100644 index 00000000..3c9a6820 --- /dev/null +++ b/src/infrastructure/buffers/AccountOperationRestrictionTransactionBuffer.ts @@ -0,0 +1,328 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class AccountOperationRestrictionTransactionBuffer { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):AccountOperationRestrictionTransactionBuffer { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsAccountOperationRestrictionTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:AccountOperationRestrictionTransactionBuffer):AccountOperationRestrictionTransactionBuffer { + return (obj || new AccountOperationRestrictionTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsAccountOperationRestrictionTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:AccountOperationRestrictionTransactionBuffer):AccountOperationRestrictionTransactionBuffer { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new AccountOperationRestrictionTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +size():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +signature(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signatureLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signatureArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +signer(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signerLength():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signerArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +version():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +type():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +maxFee(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +maxFeeLength():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +maxFeeArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +deadline(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +deadlineLength():number { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +deadlineArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +restrictionFlags():number { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +restrictionAdditionsCount():number { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; +} + +restrictionDeletionsCount():number { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; +} + +accountRestrictionTransactionBodyReserved1():number { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +restrictionAdditions(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? this.bb!.readUint16(this.bb!.__vector(this.bb_pos + offset) + index * 2) : 0; +} + +restrictionAdditionsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +restrictionAdditionsArray():Uint16Array|null { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? new Uint16Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +restrictionDeletions(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 28); + return offset ? this.bb!.readUint16(this.bb!.__vector(this.bb_pos + offset) + index * 2) : 0; +} + +restrictionDeletionsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 28); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +restrictionDeletionsArray():Uint16Array|null { + const offset = this.bb!.__offset(this.bb_pos, 28); + return offset ? new Uint16Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +static startAccountOperationRestrictionTransactionBuffer(builder:flatbuffers.Builder) { + builder.startObject(13); +} + +static addSize(builder:flatbuffers.Builder, size:number) { + builder.addFieldInt32(0, size, 0); +} + +static addSignature(builder:flatbuffers.Builder, signatureOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, signatureOffset, 0); +} + +static createSignatureVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignatureVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addSigner(builder:flatbuffers.Builder, signerOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, signerOffset, 0); +} + +static createSignerVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignerVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addVersion(builder:flatbuffers.Builder, version:number) { + builder.addFieldInt32(3, version, 0); +} + +static addType(builder:flatbuffers.Builder, type:number) { + builder.addFieldInt16(4, type, 0); +} + +static addMaxFee(builder:flatbuffers.Builder, maxFeeOffset:flatbuffers.Offset) { + builder.addFieldOffset(5, maxFeeOffset, 0); +} + +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startMaxFeeVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDeadline(builder:flatbuffers.Builder, deadlineOffset:flatbuffers.Offset) { + builder.addFieldOffset(6, deadlineOffset, 0); +} + +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startDeadlineVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addRestrictionFlags(builder:flatbuffers.Builder, restrictionFlags:number) { + builder.addFieldInt16(7, restrictionFlags, 0); +} + +static addRestrictionAdditionsCount(builder:flatbuffers.Builder, restrictionAdditionsCount:number) { + builder.addFieldInt8(8, restrictionAdditionsCount, 0); +} + +static addRestrictionDeletionsCount(builder:flatbuffers.Builder, restrictionDeletionsCount:number) { + builder.addFieldInt8(9, restrictionDeletionsCount, 0); +} + +static addAccountRestrictionTransactionBodyReserved1(builder:flatbuffers.Builder, accountRestrictionTransactionBodyReserved1:number) { + builder.addFieldInt32(10, accountRestrictionTransactionBodyReserved1, 0); +} + +static addRestrictionAdditions(builder:flatbuffers.Builder, restrictionAdditionsOffset:flatbuffers.Offset) { + builder.addFieldOffset(11, restrictionAdditionsOffset, 0); +} + +static createRestrictionAdditionsVector(builder:flatbuffers.Builder, data:number[]|Uint16Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createRestrictionAdditionsVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createRestrictionAdditionsVector(builder:flatbuffers.Builder, data:number[]|Uint16Array|Uint8Array):flatbuffers.Offset { + builder.startVector(2, data.length, 2); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt16(data[i]!); + } + return builder.endVector(); +} + +static startRestrictionAdditionsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(2, numElems, 2); +} + +static addRestrictionDeletions(builder:flatbuffers.Builder, restrictionDeletionsOffset:flatbuffers.Offset) { + builder.addFieldOffset(12, restrictionDeletionsOffset, 0); +} + +static createRestrictionDeletionsVector(builder:flatbuffers.Builder, data:number[]|Uint16Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createRestrictionDeletionsVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createRestrictionDeletionsVector(builder:flatbuffers.Builder, data:number[]|Uint16Array|Uint8Array):flatbuffers.Offset { + builder.startVector(2, data.length, 2); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt16(data[i]!); + } + return builder.endVector(); +} + +static startRestrictionDeletionsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(2, numElems, 2); +} + +static endAccountOperationRestrictionTransactionBuffer(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishAccountOperationRestrictionTransactionBufferBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset); +} + +static finishSizePrefixedAccountOperationRestrictionTransactionBufferBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, undefined, true); +} + +static createAccountOperationRestrictionTransactionBuffer(builder:flatbuffers.Builder, size:number, signatureOffset:flatbuffers.Offset, signerOffset:flatbuffers.Offset, version:number, type:number, maxFeeOffset:flatbuffers.Offset, deadlineOffset:flatbuffers.Offset, restrictionFlags:number, restrictionAdditionsCount:number, restrictionDeletionsCount:number, accountRestrictionTransactionBodyReserved1:number, restrictionAdditionsOffset:flatbuffers.Offset, restrictionDeletionsOffset:flatbuffers.Offset):flatbuffers.Offset { + AccountOperationRestrictionTransactionBuffer.startAccountOperationRestrictionTransactionBuffer(builder); + AccountOperationRestrictionTransactionBuffer.addSize(builder, size); + AccountOperationRestrictionTransactionBuffer.addSignature(builder, signatureOffset); + AccountOperationRestrictionTransactionBuffer.addSigner(builder, signerOffset); + AccountOperationRestrictionTransactionBuffer.addVersion(builder, version); + AccountOperationRestrictionTransactionBuffer.addType(builder, type); + AccountOperationRestrictionTransactionBuffer.addMaxFee(builder, maxFeeOffset); + AccountOperationRestrictionTransactionBuffer.addDeadline(builder, deadlineOffset); + AccountOperationRestrictionTransactionBuffer.addRestrictionFlags(builder, restrictionFlags); + AccountOperationRestrictionTransactionBuffer.addRestrictionAdditionsCount(builder, restrictionAdditionsCount); + AccountOperationRestrictionTransactionBuffer.addRestrictionDeletionsCount(builder, restrictionDeletionsCount); + AccountOperationRestrictionTransactionBuffer.addAccountRestrictionTransactionBodyReserved1(builder, accountRestrictionTransactionBodyReserved1); + AccountOperationRestrictionTransactionBuffer.addRestrictionAdditions(builder, restrictionAdditionsOffset); + AccountOperationRestrictionTransactionBuffer.addRestrictionDeletions(builder, restrictionDeletionsOffset); + return AccountOperationRestrictionTransactionBuffer.endAccountOperationRestrictionTransactionBuffer(builder); +} +} diff --git a/src/infrastructure/buffers/AccountV2UpgradeTransactionBuffer.ts b/src/infrastructure/buffers/AccountV2UpgradeTransactionBuffer.ts new file mode 100644 index 00000000..582f7e8f --- /dev/null +++ b/src/infrastructure/buffers/AccountV2UpgradeTransactionBuffer.ts @@ -0,0 +1,246 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class AccountV2UpgradeTransactionBuffer { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):AccountV2UpgradeTransactionBuffer { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsAccountV2UpgradeTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:AccountV2UpgradeTransactionBuffer):AccountV2UpgradeTransactionBuffer { + return (obj || new AccountV2UpgradeTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsAccountV2UpgradeTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:AccountV2UpgradeTransactionBuffer):AccountV2UpgradeTransactionBuffer { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new AccountV2UpgradeTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +size():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +signature(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signatureLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signatureArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +signer(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signerLength():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signerArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +version():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +type():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +maxFee(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +maxFeeLength():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +maxFeeArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +deadline(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +deadlineLength():number { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +deadlineArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +newaccountpublickey(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +newaccountpublickeyLength():number { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +newaccountpublickeyArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +static startAccountV2UpgradeTransactionBuffer(builder:flatbuffers.Builder) { + builder.startObject(8); +} + +static addSize(builder:flatbuffers.Builder, size:number) { + builder.addFieldInt32(0, size, 0); +} + +static addSignature(builder:flatbuffers.Builder, signatureOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, signatureOffset, 0); +} + +static createSignatureVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignatureVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addSigner(builder:flatbuffers.Builder, signerOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, signerOffset, 0); +} + +static createSignerVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignerVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addVersion(builder:flatbuffers.Builder, version:number) { + builder.addFieldInt32(3, version, 0); +} + +static addType(builder:flatbuffers.Builder, type:number) { + builder.addFieldInt16(4, type, 0); +} + +static addMaxFee(builder:flatbuffers.Builder, maxFeeOffset:flatbuffers.Offset) { + builder.addFieldOffset(5, maxFeeOffset, 0); +} + +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startMaxFeeVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDeadline(builder:flatbuffers.Builder, deadlineOffset:flatbuffers.Offset) { + builder.addFieldOffset(6, deadlineOffset, 0); +} + +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startDeadlineVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addNewaccountpublickey(builder:flatbuffers.Builder, newaccountpublickeyOffset:flatbuffers.Offset) { + builder.addFieldOffset(7, newaccountpublickeyOffset, 0); +} + +static createNewaccountpublickeyVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startNewaccountpublickeyVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static endAccountV2UpgradeTransactionBuffer(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishAccountV2UpgradeTransactionBufferBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset); +} + +static finishSizePrefixedAccountV2UpgradeTransactionBufferBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, undefined, true); +} + +static createAccountV2UpgradeTransactionBuffer(builder:flatbuffers.Builder, size:number, signatureOffset:flatbuffers.Offset, signerOffset:flatbuffers.Offset, version:number, type:number, maxFeeOffset:flatbuffers.Offset, deadlineOffset:flatbuffers.Offset, newaccountpublickeyOffset:flatbuffers.Offset):flatbuffers.Offset { + AccountV2UpgradeTransactionBuffer.startAccountV2UpgradeTransactionBuffer(builder); + AccountV2UpgradeTransactionBuffer.addSize(builder, size); + AccountV2UpgradeTransactionBuffer.addSignature(builder, signatureOffset); + AccountV2UpgradeTransactionBuffer.addSigner(builder, signerOffset); + AccountV2UpgradeTransactionBuffer.addVersion(builder, version); + AccountV2UpgradeTransactionBuffer.addType(builder, type); + AccountV2UpgradeTransactionBuffer.addMaxFee(builder, maxFeeOffset); + AccountV2UpgradeTransactionBuffer.addDeadline(builder, deadlineOffset); + AccountV2UpgradeTransactionBuffer.addNewaccountpublickey(builder, newaccountpublickeyOffset); + return AccountV2UpgradeTransactionBuffer.endAccountV2UpgradeTransactionBuffer(builder); +} +} diff --git a/src/infrastructure/buffers/AddressBuffer.ts b/src/infrastructure/buffers/AddressBuffer.ts new file mode 100644 index 00000000..0862c186 --- /dev/null +++ b/src/infrastructure/buffers/AddressBuffer.ts @@ -0,0 +1,68 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +export class AddressBuffer { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):AddressBuffer { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsAddressBuffer(bb:flatbuffers.ByteBuffer, obj?:AddressBuffer):AddressBuffer { + return (obj || new AddressBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsAddressBuffer(bb:flatbuffers.ByteBuffer, obj?:AddressBuffer):AddressBuffer { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new AddressBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +address(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +addressLength():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +addressArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +static startAddressBuffer(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addAddress(builder:flatbuffers.Builder, addressOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, addressOffset, 0); +} + +static createAddressVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startAddressVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static endAddressBuffer(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createAddressBuffer(builder:flatbuffers.Builder, addressOffset:flatbuffers.Offset):flatbuffers.Offset { + AddressBuffer.startAddressBuffer(builder); + AddressBuffer.addAddress(builder, addressOffset); + return AddressBuffer.endAddressBuffer(builder); +} +} diff --git a/src/infrastructure/buffers/LockFundCancelUnlockTransactionBuffer.ts b/src/infrastructure/buffers/LockFundCancelUnlockTransactionBuffer.ts new file mode 100644 index 00000000..ff6b2bc6 --- /dev/null +++ b/src/infrastructure/buffers/LockFundCancelUnlockTransactionBuffer.ts @@ -0,0 +1,241 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +export class LockFundCancelUnlockTransactionBuffer { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):LockFundCancelUnlockTransactionBuffer { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsLockFundCancelUnlockTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:LockFundCancelUnlockTransactionBuffer):LockFundCancelUnlockTransactionBuffer { + return (obj || new LockFundCancelUnlockTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsLockFundCancelUnlockTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:LockFundCancelUnlockTransactionBuffer):LockFundCancelUnlockTransactionBuffer { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new LockFundCancelUnlockTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +size():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +signature(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signatureLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signatureArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +signer(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signerLength():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signerArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +version():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +type():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +maxFee(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +maxFeeLength():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +maxFeeArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +deadline(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +deadlineLength():number { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +deadlineArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +targetHeight(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +targetHeightLength():number { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +targetHeightArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +static startLockFundCancelUnlockTransactionBuffer(builder:flatbuffers.Builder) { + builder.startObject(8); +} + +static addSize(builder:flatbuffers.Builder, size:number) { + builder.addFieldInt32(0, size, 0); +} + +static addSignature(builder:flatbuffers.Builder, signatureOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, signatureOffset, 0); +} + +static createSignatureVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignatureVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addSigner(builder:flatbuffers.Builder, signerOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, signerOffset, 0); +} + +static createSignerVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignerVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addVersion(builder:flatbuffers.Builder, version:number) { + builder.addFieldInt32(3, version, 0); +} + +static addType(builder:flatbuffers.Builder, type:number) { + builder.addFieldInt16(4, type, 0); +} + +static addMaxFee(builder:flatbuffers.Builder, maxFeeOffset:flatbuffers.Offset) { + builder.addFieldOffset(5, maxFeeOffset, 0); +} + +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startMaxFeeVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDeadline(builder:flatbuffers.Builder, deadlineOffset:flatbuffers.Offset) { + builder.addFieldOffset(6, deadlineOffset, 0); +} + +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startDeadlineVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addTargetHeight(builder:flatbuffers.Builder, targetHeightOffset:flatbuffers.Offset) { + builder.addFieldOffset(7, targetHeightOffset, 0); +} + +static createTargetHeightVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createTargetHeightVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createTargetHeightVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startTargetHeightVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static endLockFundCancelUnlockTransactionBuffer(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createLockFundCancelUnlockTransactionBuffer(builder:flatbuffers.Builder, size:number, signatureOffset:flatbuffers.Offset, signerOffset:flatbuffers.Offset, version:number, type:number, maxFeeOffset:flatbuffers.Offset, deadlineOffset:flatbuffers.Offset, targetHeightOffset:flatbuffers.Offset):flatbuffers.Offset { + LockFundCancelUnlockTransactionBuffer.startLockFundCancelUnlockTransactionBuffer(builder); + LockFundCancelUnlockTransactionBuffer.addSize(builder, size); + LockFundCancelUnlockTransactionBuffer.addSignature(builder, signatureOffset); + LockFundCancelUnlockTransactionBuffer.addSigner(builder, signerOffset); + LockFundCancelUnlockTransactionBuffer.addVersion(builder, version); + LockFundCancelUnlockTransactionBuffer.addType(builder, type); + LockFundCancelUnlockTransactionBuffer.addMaxFee(builder, maxFeeOffset); + LockFundCancelUnlockTransactionBuffer.addDeadline(builder, deadlineOffset); + LockFundCancelUnlockTransactionBuffer.addTargetHeight(builder, targetHeightOffset); + return LockFundCancelUnlockTransactionBuffer.endLockFundCancelUnlockTransactionBuffer(builder); +} +} diff --git a/src/infrastructure/buffers/LockFundTransferTransactionBuffer.ts b/src/infrastructure/buffers/LockFundTransferTransactionBuffer.ts new file mode 100644 index 00000000..b36043a0 --- /dev/null +++ b/src/infrastructure/buffers/LockFundTransferTransactionBuffer.ts @@ -0,0 +1,299 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { MosaicBuffer } from './MosaicBuffer'; + + +export class LockFundTransferTransactionBuffer { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):LockFundTransferTransactionBuffer { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsLockFundTransferTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:LockFundTransferTransactionBuffer):LockFundTransferTransactionBuffer { + return (obj || new LockFundTransferTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsLockFundTransferTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:LockFundTransferTransactionBuffer):LockFundTransferTransactionBuffer { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new LockFundTransferTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +size():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +signature(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signatureLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signatureArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +signer(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signerLength():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signerArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +version():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +type():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +maxFee(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +maxFeeLength():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +maxFeeArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +deadline(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +deadlineLength():number { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +deadlineArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +duration(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +durationLength():number { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +durationArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +action():number { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; +} + +mosaicsCount():number { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; +} + +mosaics(index: number, obj?:MosaicBuffer):MosaicBuffer|null { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? (obj || new MosaicBuffer()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +mosaicsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +static startLockFundTransferTransactionBuffer(builder:flatbuffers.Builder) { + builder.startObject(11); +} + +static addSize(builder:flatbuffers.Builder, size:number) { + builder.addFieldInt32(0, size, 0); +} + +static addSignature(builder:flatbuffers.Builder, signatureOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, signatureOffset, 0); +} + +static createSignatureVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignatureVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addSigner(builder:flatbuffers.Builder, signerOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, signerOffset, 0); +} + +static createSignerVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignerVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addVersion(builder:flatbuffers.Builder, version:number) { + builder.addFieldInt32(3, version, 0); +} + +static addType(builder:flatbuffers.Builder, type:number) { + builder.addFieldInt16(4, type, 0); +} + +static addMaxFee(builder:flatbuffers.Builder, maxFeeOffset:flatbuffers.Offset) { + builder.addFieldOffset(5, maxFeeOffset, 0); +} + +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startMaxFeeVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDeadline(builder:flatbuffers.Builder, deadlineOffset:flatbuffers.Offset) { + builder.addFieldOffset(6, deadlineOffset, 0); +} + +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startDeadlineVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDuration(builder:flatbuffers.Builder, durationOffset:flatbuffers.Offset) { + builder.addFieldOffset(7, durationOffset, 0); +} + +static createDurationVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createDurationVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createDurationVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startDurationVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addAction(builder:flatbuffers.Builder, action:number) { + builder.addFieldInt8(8, action, 0); +} + +static addMosaicsCount(builder:flatbuffers.Builder, mosaicsCount:number) { + builder.addFieldInt8(9, mosaicsCount, 0); +} + +static addMosaics(builder:flatbuffers.Builder, mosaicsOffset:flatbuffers.Offset) { + builder.addFieldOffset(10, mosaicsOffset, 0); +} + +static createMosaicsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startMosaicsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static endLockFundTransferTransactionBuffer(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishLockFundTransferTransactionBufferBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset); +} + +static finishSizePrefixedLockFundTransferTransactionBufferBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, undefined, true); +} + +static createLockFundTransferTransactionBuffer(builder:flatbuffers.Builder, size:number, signatureOffset:flatbuffers.Offset, signerOffset:flatbuffers.Offset, version:number, type:number, maxFeeOffset:flatbuffers.Offset, deadlineOffset:flatbuffers.Offset, durationOffset:flatbuffers.Offset, action:number, mosaicsCount:number, mosaicsOffset:flatbuffers.Offset):flatbuffers.Offset { + LockFundTransferTransactionBuffer.startLockFundTransferTransactionBuffer(builder); + LockFundTransferTransactionBuffer.addSize(builder, size); + LockFundTransferTransactionBuffer.addSignature(builder, signatureOffset); + LockFundTransferTransactionBuffer.addSigner(builder, signerOffset); + LockFundTransferTransactionBuffer.addVersion(builder, version); + LockFundTransferTransactionBuffer.addType(builder, type); + LockFundTransferTransactionBuffer.addMaxFee(builder, maxFeeOffset); + LockFundTransferTransactionBuffer.addDeadline(builder, deadlineOffset); + LockFundTransferTransactionBuffer.addDuration(builder, durationOffset); + LockFundTransferTransactionBuffer.addAction(builder, action); + LockFundTransferTransactionBuffer.addMosaicsCount(builder, mosaicsCount); + LockFundTransferTransactionBuffer.addMosaics(builder, mosaicsOffset); + return LockFundTransferTransactionBuffer.endLockFundTransferTransactionBuffer(builder); +} +} diff --git a/src/infrastructure/buffers/MosaicAddressRestrictionTransactionBuffer.ts b/src/infrastructure/buffers/MosaicAddressRestrictionTransactionBuffer.ts new file mode 100644 index 00000000..11368506 --- /dev/null +++ b/src/infrastructure/buffers/MosaicAddressRestrictionTransactionBuffer.ts @@ -0,0 +1,384 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +export class MosaicAddressRestrictionTransactionBuffer { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):MosaicAddressRestrictionTransactionBuffer { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsMosaicAddressRestrictionTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:MosaicAddressRestrictionTransactionBuffer):MosaicAddressRestrictionTransactionBuffer { + return (obj || new MosaicAddressRestrictionTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsMosaicAddressRestrictionTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:MosaicAddressRestrictionTransactionBuffer):MosaicAddressRestrictionTransactionBuffer { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new MosaicAddressRestrictionTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +size():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +signature(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signatureLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signatureArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +signer(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signerLength():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signerArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +version():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +type():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +maxFee(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +maxFeeLength():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +maxFeeArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +deadline(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +deadlineLength():number { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +deadlineArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +mosaicId(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +mosaicIdLength():number { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +mosaicIdArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +restrictionKey(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +restrictionKeyLength():number { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +restrictionKeyArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +previousRestrictionValue(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +previousRestrictionValueLength():number { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +previousRestrictionValueArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +newRestrictionValue(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +newRestrictionValueLength():number { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +newRestrictionValueArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +targetAddress(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +targetAddressLength():number { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +targetAddressArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +static startMosaicAddressRestrictionTransactionBuffer(builder:flatbuffers.Builder) { + builder.startObject(12); +} + +static addSize(builder:flatbuffers.Builder, size:number) { + builder.addFieldInt32(0, size, 0); +} + +static addSignature(builder:flatbuffers.Builder, signatureOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, signatureOffset, 0); +} + +static createSignatureVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignatureVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addSigner(builder:flatbuffers.Builder, signerOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, signerOffset, 0); +} + +static createSignerVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignerVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addVersion(builder:flatbuffers.Builder, version:number) { + builder.addFieldInt32(3, version, 0); +} + +static addType(builder:flatbuffers.Builder, type:number) { + builder.addFieldInt16(4, type, 0); +} + +static addMaxFee(builder:flatbuffers.Builder, maxFeeOffset:flatbuffers.Offset) { + builder.addFieldOffset(5, maxFeeOffset, 0); +} + +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startMaxFeeVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDeadline(builder:flatbuffers.Builder, deadlineOffset:flatbuffers.Offset) { + builder.addFieldOffset(6, deadlineOffset, 0); +} + +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startDeadlineVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addMosaicId(builder:flatbuffers.Builder, mosaicIdOffset:flatbuffers.Offset) { + builder.addFieldOffset(7, mosaicIdOffset, 0); +} + +static createMosaicIdVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createMosaicIdVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createMosaicIdVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startMosaicIdVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addRestrictionKey(builder:flatbuffers.Builder, restrictionKeyOffset:flatbuffers.Offset) { + builder.addFieldOffset(8, restrictionKeyOffset, 0); +} + +static createRestrictionKeyVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createRestrictionKeyVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createRestrictionKeyVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startRestrictionKeyVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addPreviousRestrictionValue(builder:flatbuffers.Builder, previousRestrictionValueOffset:flatbuffers.Offset) { + builder.addFieldOffset(9, previousRestrictionValueOffset, 0); +} + +static createPreviousRestrictionValueVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createPreviousRestrictionValueVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createPreviousRestrictionValueVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startPreviousRestrictionValueVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addNewRestrictionValue(builder:flatbuffers.Builder, newRestrictionValueOffset:flatbuffers.Offset) { + builder.addFieldOffset(10, newRestrictionValueOffset, 0); +} + +static createNewRestrictionValueVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createNewRestrictionValueVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createNewRestrictionValueVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startNewRestrictionValueVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addTargetAddress(builder:flatbuffers.Builder, targetAddressOffset:flatbuffers.Offset) { + builder.addFieldOffset(11, targetAddressOffset, 0); +} + +static createTargetAddressVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startTargetAddressVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static endMosaicAddressRestrictionTransactionBuffer(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createMosaicAddressRestrictionTransactionBuffer(builder:flatbuffers.Builder, size:number, signatureOffset:flatbuffers.Offset, signerOffset:flatbuffers.Offset, version:number, type:number, maxFeeOffset:flatbuffers.Offset, deadlineOffset:flatbuffers.Offset, mosaicIdOffset:flatbuffers.Offset, restrictionKeyOffset:flatbuffers.Offset, previousRestrictionValueOffset:flatbuffers.Offset, newRestrictionValueOffset:flatbuffers.Offset, targetAddressOffset:flatbuffers.Offset):flatbuffers.Offset { + MosaicAddressRestrictionTransactionBuffer.startMosaicAddressRestrictionTransactionBuffer(builder); + MosaicAddressRestrictionTransactionBuffer.addSize(builder, size); + MosaicAddressRestrictionTransactionBuffer.addSignature(builder, signatureOffset); + MosaicAddressRestrictionTransactionBuffer.addSigner(builder, signerOffset); + MosaicAddressRestrictionTransactionBuffer.addVersion(builder, version); + MosaicAddressRestrictionTransactionBuffer.addType(builder, type); + MosaicAddressRestrictionTransactionBuffer.addMaxFee(builder, maxFeeOffset); + MosaicAddressRestrictionTransactionBuffer.addDeadline(builder, deadlineOffset); + MosaicAddressRestrictionTransactionBuffer.addMosaicId(builder, mosaicIdOffset); + MosaicAddressRestrictionTransactionBuffer.addRestrictionKey(builder, restrictionKeyOffset); + MosaicAddressRestrictionTransactionBuffer.addPreviousRestrictionValue(builder, previousRestrictionValueOffset); + MosaicAddressRestrictionTransactionBuffer.addNewRestrictionValue(builder, newRestrictionValueOffset); + MosaicAddressRestrictionTransactionBuffer.addTargetAddress(builder, targetAddressOffset); + return MosaicAddressRestrictionTransactionBuffer.endMosaicAddressRestrictionTransactionBuffer(builder); +} +} diff --git a/src/infrastructure/buffers/MosaicBuffer.ts b/src/infrastructure/buffers/MosaicBuffer.ts new file mode 100644 index 00000000..3bda58a3 --- /dev/null +++ b/src/infrastructure/buffers/MosaicBuffer.ts @@ -0,0 +1,110 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +export class MosaicBuffer { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):MosaicBuffer { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsMosaicBuffer(bb:flatbuffers.ByteBuffer, obj?:MosaicBuffer):MosaicBuffer { + return (obj || new MosaicBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsMosaicBuffer(bb:flatbuffers.ByteBuffer, obj?:MosaicBuffer):MosaicBuffer { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new MosaicBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +id(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +idLength():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +idArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +amount(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +amountLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +amountArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +static startMosaicBuffer(builder:flatbuffers.Builder) { + builder.startObject(2); +} + +static addId(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, idOffset, 0); +} + +static createIdVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createIdVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createIdVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startIdVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addAmount(builder:flatbuffers.Builder, amountOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, amountOffset, 0); +} + +static createAmountVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createAmountVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createAmountVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startAmountVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static endMosaicBuffer(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createMosaicBuffer(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset, amountOffset:flatbuffers.Offset):flatbuffers.Offset { + MosaicBuffer.startMosaicBuffer(builder); + MosaicBuffer.addId(builder, idOffset); + MosaicBuffer.addAmount(builder, amountOffset); + return MosaicBuffer.endMosaicBuffer(builder); +} +} diff --git a/src/infrastructure/buffers/MosaicGlobalRestrictionTransactionBuffer.ts b/src/infrastructure/buffers/MosaicGlobalRestrictionTransactionBuffer.ts new file mode 100644 index 00000000..14e122b2 --- /dev/null +++ b/src/infrastructure/buffers/MosaicGlobalRestrictionTransactionBuffer.ts @@ -0,0 +1,419 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class MosaicGlobalRestrictionTransactionBuffer { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):MosaicGlobalRestrictionTransactionBuffer { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsMosaicGlobalRestrictionTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:MosaicGlobalRestrictionTransactionBuffer):MosaicGlobalRestrictionTransactionBuffer { + return (obj || new MosaicGlobalRestrictionTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsMosaicGlobalRestrictionTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:MosaicGlobalRestrictionTransactionBuffer):MosaicGlobalRestrictionTransactionBuffer { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new MosaicGlobalRestrictionTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +size():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +signature(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signatureLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signatureArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +signer(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signerLength():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signerArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +version():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +type():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +maxFee(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +maxFeeLength():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +maxFeeArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +deadline(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +deadlineLength():number { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +deadlineArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +mosaicId(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +mosaicIdLength():number { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +mosaicIdArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +referenceMosaicId(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +referenceMosaicIdLength():number { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +referenceMosaicIdArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +restrictionKey(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +restrictionKeyLength():number { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +restrictionKeyArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +previousRestrictionValue(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +previousRestrictionValueLength():number { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +previousRestrictionValueArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +newRestrictionValue(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +newRestrictionValueLength():number { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +newRestrictionValueArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +previousRestrictionType():number { + const offset = this.bb!.__offset(this.bb_pos, 28); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; +} + +newRestrictionType():number { + const offset = this.bb!.__offset(this.bb_pos, 30); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; +} + +static startMosaicGlobalRestrictionTransactionBuffer(builder:flatbuffers.Builder) { + builder.startObject(14); +} + +static addSize(builder:flatbuffers.Builder, size:number) { + builder.addFieldInt32(0, size, 0); +} + +static addSignature(builder:flatbuffers.Builder, signatureOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, signatureOffset, 0); +} + +static createSignatureVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignatureVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addSigner(builder:flatbuffers.Builder, signerOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, signerOffset, 0); +} + +static createSignerVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignerVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addVersion(builder:flatbuffers.Builder, version:number) { + builder.addFieldInt32(3, version, 0); +} + +static addType(builder:flatbuffers.Builder, type:number) { + builder.addFieldInt16(4, type, 0); +} + +static addMaxFee(builder:flatbuffers.Builder, maxFeeOffset:flatbuffers.Offset) { + builder.addFieldOffset(5, maxFeeOffset, 0); +} + +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startMaxFeeVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDeadline(builder:flatbuffers.Builder, deadlineOffset:flatbuffers.Offset) { + builder.addFieldOffset(6, deadlineOffset, 0); +} + +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startDeadlineVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addMosaicId(builder:flatbuffers.Builder, mosaicIdOffset:flatbuffers.Offset) { + builder.addFieldOffset(7, mosaicIdOffset, 0); +} + +static createMosaicIdVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createMosaicIdVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createMosaicIdVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startMosaicIdVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addReferenceMosaicId(builder:flatbuffers.Builder, referenceMosaicIdOffset:flatbuffers.Offset) { + builder.addFieldOffset(8, referenceMosaicIdOffset, 0); +} + +static createReferenceMosaicIdVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createReferenceMosaicIdVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createReferenceMosaicIdVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startReferenceMosaicIdVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addRestrictionKey(builder:flatbuffers.Builder, restrictionKeyOffset:flatbuffers.Offset) { + builder.addFieldOffset(9, restrictionKeyOffset, 0); +} + +static createRestrictionKeyVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createRestrictionKeyVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createRestrictionKeyVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startRestrictionKeyVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addPreviousRestrictionValue(builder:flatbuffers.Builder, previousRestrictionValueOffset:flatbuffers.Offset) { + builder.addFieldOffset(10, previousRestrictionValueOffset, 0); +} + +static createPreviousRestrictionValueVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createPreviousRestrictionValueVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createPreviousRestrictionValueVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startPreviousRestrictionValueVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addNewRestrictionValue(builder:flatbuffers.Builder, newRestrictionValueOffset:flatbuffers.Offset) { + builder.addFieldOffset(11, newRestrictionValueOffset, 0); +} + +static createNewRestrictionValueVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createNewRestrictionValueVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createNewRestrictionValueVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startNewRestrictionValueVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addPreviousRestrictionType(builder:flatbuffers.Builder, previousRestrictionType:number) { + builder.addFieldInt8(12, previousRestrictionType, 0); +} + +static addNewRestrictionType(builder:flatbuffers.Builder, newRestrictionType:number) { + builder.addFieldInt8(13, newRestrictionType, 0); +} + +static endMosaicGlobalRestrictionTransactionBuffer(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishMosaicGlobalRestrictionTransactionBufferBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset); +} + +static finishSizePrefixedMosaicGlobalRestrictionTransactionBufferBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, undefined, true); +} + +static createMosaicGlobalRestrictionTransactionBuffer(builder:flatbuffers.Builder, size:number, signatureOffset:flatbuffers.Offset, signerOffset:flatbuffers.Offset, version:number, type:number, maxFeeOffset:flatbuffers.Offset, deadlineOffset:flatbuffers.Offset, mosaicIdOffset:flatbuffers.Offset, referenceMosaicIdOffset:flatbuffers.Offset, restrictionKeyOffset:flatbuffers.Offset, previousRestrictionValueOffset:flatbuffers.Offset, newRestrictionValueOffset:flatbuffers.Offset, previousRestrictionType:number, newRestrictionType:number):flatbuffers.Offset { + MosaicGlobalRestrictionTransactionBuffer.startMosaicGlobalRestrictionTransactionBuffer(builder); + MosaicGlobalRestrictionTransactionBuffer.addSize(builder, size); + MosaicGlobalRestrictionTransactionBuffer.addSignature(builder, signatureOffset); + MosaicGlobalRestrictionTransactionBuffer.addSigner(builder, signerOffset); + MosaicGlobalRestrictionTransactionBuffer.addVersion(builder, version); + MosaicGlobalRestrictionTransactionBuffer.addType(builder, type); + MosaicGlobalRestrictionTransactionBuffer.addMaxFee(builder, maxFeeOffset); + MosaicGlobalRestrictionTransactionBuffer.addDeadline(builder, deadlineOffset); + MosaicGlobalRestrictionTransactionBuffer.addMosaicId(builder, mosaicIdOffset); + MosaicGlobalRestrictionTransactionBuffer.addReferenceMosaicId(builder, referenceMosaicIdOffset); + MosaicGlobalRestrictionTransactionBuffer.addRestrictionKey(builder, restrictionKeyOffset); + MosaicGlobalRestrictionTransactionBuffer.addPreviousRestrictionValue(builder, previousRestrictionValueOffset); + MosaicGlobalRestrictionTransactionBuffer.addNewRestrictionValue(builder, newRestrictionValueOffset); + MosaicGlobalRestrictionTransactionBuffer.addPreviousRestrictionType(builder, previousRestrictionType); + MosaicGlobalRestrictionTransactionBuffer.addNewRestrictionType(builder, newRestrictionType); + return MosaicGlobalRestrictionTransactionBuffer.endMosaicGlobalRestrictionTransactionBuffer(builder); +} +} diff --git a/src/infrastructure/buffers/MosaicIdBuffer.ts b/src/infrastructure/buffers/MosaicIdBuffer.ts new file mode 100644 index 00000000..abdb40c3 --- /dev/null +++ b/src/infrastructure/buffers/MosaicIdBuffer.ts @@ -0,0 +1,73 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +export class MosaicId { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):MosaicId { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsMosaicId(bb:flatbuffers.ByteBuffer, obj?:MosaicId):MosaicId { + return (obj || new MosaicId()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsMosaicId(bb:flatbuffers.ByteBuffer, obj?:MosaicId):MosaicId { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new MosaicId()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +id(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +idLength():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +idArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +static startMosaicId(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addId(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, idOffset, 0); +} + +static createIdVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createIdVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createIdVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startIdVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static endMosaicId(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createMosaicId(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset):flatbuffers.Offset { + MosaicId.startMosaicId(builder); + MosaicId.addId(builder, idOffset); + return MosaicId.endMosaicId(builder); +} +} diff --git a/src/infrastructure/buffers/NetworkConfigAbsoluteHeightTransactionBuffer.ts b/src/infrastructure/buffers/NetworkConfigAbsoluteHeightTransactionBuffer.ts new file mode 100644 index 00000000..fd4994ec --- /dev/null +++ b/src/infrastructure/buffers/NetworkConfigAbsoluteHeightTransactionBuffer.ts @@ -0,0 +1,325 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +export class NetworkConfigAbsoluteHeightTransactionBuffer { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):NetworkConfigAbsoluteHeightTransactionBuffer { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsNetworkConfigAbsoluteHeightTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:NetworkConfigAbsoluteHeightTransactionBuffer):NetworkConfigAbsoluteHeightTransactionBuffer { + return (obj || new NetworkConfigAbsoluteHeightTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsNetworkConfigAbsoluteHeightTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:NetworkConfigAbsoluteHeightTransactionBuffer):NetworkConfigAbsoluteHeightTransactionBuffer { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new NetworkConfigAbsoluteHeightTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +size():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +signature(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signatureLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signatureArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +signer(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signerLength():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signerArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +version():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +type():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +maxFee(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +maxFeeLength():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +maxFeeArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +deadline(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +deadlineLength():number { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +deadlineArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +applyHeight(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +applyHeightLength():number { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +applyHeightArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +networkConfigSize():number { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +supportedEntityVersionsSize():number { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +networkConfig(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +networkConfigLength():number { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +networkConfigArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +supportedEntityVersions(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +supportedEntityVersionsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +supportedEntityVersionsArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +static startNetworkConfigAbsoluteHeightTransactionBuffer(builder:flatbuffers.Builder) { + builder.startObject(12); +} + +static addSize(builder:flatbuffers.Builder, size:number) { + builder.addFieldInt32(0, size, 0); +} + +static addSignature(builder:flatbuffers.Builder, signatureOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, signatureOffset, 0); +} + +static createSignatureVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignatureVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addSigner(builder:flatbuffers.Builder, signerOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, signerOffset, 0); +} + +static createSignerVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignerVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addVersion(builder:flatbuffers.Builder, version:number) { + builder.addFieldInt32(3, version, 0); +} + +static addType(builder:flatbuffers.Builder, type:number) { + builder.addFieldInt16(4, type, 0); +} + +static addMaxFee(builder:flatbuffers.Builder, maxFeeOffset:flatbuffers.Offset) { + builder.addFieldOffset(5, maxFeeOffset, 0); +} + +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startMaxFeeVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDeadline(builder:flatbuffers.Builder, deadlineOffset:flatbuffers.Offset) { + builder.addFieldOffset(6, deadlineOffset, 0); +} + +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startDeadlineVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addApplyHeight(builder:flatbuffers.Builder, applyHeightOffset:flatbuffers.Offset) { + builder.addFieldOffset(7, applyHeightOffset, 0); +} + +static createApplyHeightVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createApplyHeightVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createApplyHeightVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startApplyHeightVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addNetworkConfigSize(builder:flatbuffers.Builder, networkConfigSize:number) { + builder.addFieldInt16(8, networkConfigSize, 0); +} + +static addSupportedEntityVersionsSize(builder:flatbuffers.Builder, supportedEntityVersionsSize:number) { + builder.addFieldInt16(9, supportedEntityVersionsSize, 0); +} + +static addNetworkConfig(builder:flatbuffers.Builder, networkConfigOffset:flatbuffers.Offset) { + builder.addFieldOffset(10, networkConfigOffset, 0); +} + +static createNetworkConfigVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startNetworkConfigVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addSupportedEntityVersions(builder:flatbuffers.Builder, supportedEntityVersionsOffset:flatbuffers.Offset) { + builder.addFieldOffset(11, supportedEntityVersionsOffset, 0); +} + +static createSupportedEntityVersionsVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSupportedEntityVersionsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static endNetworkConfigAbsoluteHeightTransactionBuffer(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createNetworkConfigAbsoluteHeightTransactionBuffer(builder:flatbuffers.Builder, size:number, signatureOffset:flatbuffers.Offset, signerOffset:flatbuffers.Offset, version:number, type:number, maxFeeOffset:flatbuffers.Offset, deadlineOffset:flatbuffers.Offset, applyHeightOffset:flatbuffers.Offset, networkConfigSize:number, supportedEntityVersionsSize:number, networkConfigOffset:flatbuffers.Offset, supportedEntityVersionsOffset:flatbuffers.Offset):flatbuffers.Offset { + NetworkConfigAbsoluteHeightTransactionBuffer.startNetworkConfigAbsoluteHeightTransactionBuffer(builder); + NetworkConfigAbsoluteHeightTransactionBuffer.addSize(builder, size); + NetworkConfigAbsoluteHeightTransactionBuffer.addSignature(builder, signatureOffset); + NetworkConfigAbsoluteHeightTransactionBuffer.addSigner(builder, signerOffset); + NetworkConfigAbsoluteHeightTransactionBuffer.addVersion(builder, version); + NetworkConfigAbsoluteHeightTransactionBuffer.addType(builder, type); + NetworkConfigAbsoluteHeightTransactionBuffer.addMaxFee(builder, maxFeeOffset); + NetworkConfigAbsoluteHeightTransactionBuffer.addDeadline(builder, deadlineOffset); + NetworkConfigAbsoluteHeightTransactionBuffer.addApplyHeight(builder, applyHeightOffset); + NetworkConfigAbsoluteHeightTransactionBuffer.addNetworkConfigSize(builder, networkConfigSize); + NetworkConfigAbsoluteHeightTransactionBuffer.addSupportedEntityVersionsSize(builder, supportedEntityVersionsSize); + NetworkConfigAbsoluteHeightTransactionBuffer.addNetworkConfig(builder, networkConfigOffset); + NetworkConfigAbsoluteHeightTransactionBuffer.addSupportedEntityVersions(builder, supportedEntityVersionsOffset); + return NetworkConfigAbsoluteHeightTransactionBuffer.endNetworkConfigAbsoluteHeightTransactionBuffer(builder); +} +} diff --git a/src/infrastructure/buffers/ChainConfigTransactionBuffer.ts b/src/infrastructure/buffers/NetworkConfigTransactionBuffer.ts similarity index 93% rename from src/infrastructure/buffers/ChainConfigTransactionBuffer.ts rename to src/infrastructure/buffers/NetworkConfigTransactionBuffer.ts index 65f807bc..7c4e4bb9 100644 --- a/src/infrastructure/buffers/ChainConfigTransactionBuffer.ts +++ b/src/infrastructure/buffers/NetworkConfigTransactionBuffer.ts @@ -203,7 +203,7 @@ Catapult.Buffers.CatapultConfigTransactionBuffer.prototype.applyHeightDeltaArray /** * @returns {number} */ -Catapult.Buffers.CatapultConfigTransactionBuffer.prototype.blockChainConfigSize = function() { +Catapult.Buffers.CatapultConfigTransactionBuffer.prototype.blockNetworkConfigSize = function() { var offset = this.bb.__offset(this.bb_pos, 20); return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; }; @@ -220,7 +220,7 @@ Catapult.Buffers.CatapultConfigTransactionBuffer.prototype.supportedEntityVersio * @param {number} index * @returns {number} */ -Catapult.Buffers.CatapultConfigTransactionBuffer.prototype.blockChainConfig = function(index) { +Catapult.Buffers.CatapultConfigTransactionBuffer.prototype.blockNetworkConfig = function(index) { var offset = this.bb.__offset(this.bb_pos, 24); return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; }; @@ -228,7 +228,7 @@ Catapult.Buffers.CatapultConfigTransactionBuffer.prototype.blockChainConfig = fu /** * @returns {number} */ -Catapult.Buffers.CatapultConfigTransactionBuffer.prototype.blockChainConfigLength = function() { +Catapult.Buffers.CatapultConfigTransactionBuffer.prototype.blockNetworkConfigLength = function() { var offset = this.bb.__offset(this.bb_pos, 24); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; }; @@ -236,7 +236,7 @@ Catapult.Buffers.CatapultConfigTransactionBuffer.prototype.blockChainConfigLengt /** * @returns {Uint8Array} */ -Catapult.Buffers.CatapultConfigTransactionBuffer.prototype.blockChainConfigArray = function() { +Catapult.Buffers.CatapultConfigTransactionBuffer.prototype.blockNetworkConfigArray = function() { var offset = this.bb.__offset(this.bb_pos, 24); return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; }; @@ -444,10 +444,10 @@ Catapult.Buffers.CatapultConfigTransactionBuffer.startApplyHeightDeltaVector = f /** * @param {flatbuffers.Builder} builder - * @param {number} blockChainConfigSize + * @param {number} blockNetworkConfigSize */ -Catapult.Buffers.CatapultConfigTransactionBuffer.addBlockChainConfigSize = function(builder, blockChainConfigSize) { - builder.addFieldInt16(8, blockChainConfigSize, 0); +Catapult.Buffers.CatapultConfigTransactionBuffer.addBlockNetworkConfigSize = function(builder, blockNetworkConfigSize) { + builder.addFieldInt16(8, blockNetworkConfigSize, 0); }; /** @@ -460,10 +460,10 @@ Catapult.Buffers.CatapultConfigTransactionBuffer.addSupportedEntityVersionsSize /** * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} blockChainConfigOffset + * @param {flatbuffers.Offset} blockNetworkConfigOffset */ -Catapult.Buffers.CatapultConfigTransactionBuffer.addBlockChainConfig = function(builder, blockChainConfigOffset) { - builder.addFieldOffset(10, blockChainConfigOffset, 0); +Catapult.Buffers.CatapultConfigTransactionBuffer.addBlockNetworkConfig = function(builder, blockNetworkConfigOffset) { + builder.addFieldOffset(10, blockNetworkConfigOffset, 0); }; /** @@ -471,7 +471,7 @@ Catapult.Buffers.CatapultConfigTransactionBuffer.addBlockChainConfig = function( * @param {Array.} data * @returns {flatbuffers.Offset} */ -Catapult.Buffers.CatapultConfigTransactionBuffer.createBlockChainConfigVector = function(builder, data) { +Catapult.Buffers.CatapultConfigTransactionBuffer.createBlockNetworkConfigVector = function(builder, data) { builder.startVector(1, data.length, 1); for (var i = data.length - 1; i >= 0; i--) { builder.addInt8(data[i]); @@ -483,7 +483,7 @@ Catapult.Buffers.CatapultConfigTransactionBuffer.createBlockChainConfigVector = * @param {flatbuffers.Builder} builder * @param {number} numElems */ -Catapult.Buffers.CatapultConfigTransactionBuffer.startBlockChainConfigVector = function(builder, numElems) { +Catapult.Buffers.CatapultConfigTransactionBuffer.startBlockNetworkConfigVector = function(builder, numElems) { builder.startVector(1, numElems, 1); }; @@ -543,13 +543,13 @@ Catapult.Buffers.CatapultConfigTransactionBuffer.finishCatapultConfigTransaction * @param {flatbuffers.Offset} maxFeeOffset * @param {flatbuffers.Offset} deadlineOffset * @param {flatbuffers.Offset} applyHeightDeltaOffset - * @param {number} blockChainConfigSize + * @param {number} blockNetworkConfigSize * @param {number} supportedEntityVersionsSize - * @param {flatbuffers.Offset} blockChainConfigOffset + * @param {flatbuffers.Offset} blockNetworkConfigOffset * @param {flatbuffers.Offset} supportedEntityVersionsOffset * @returns {flatbuffers.Offset} */ -Catapult.Buffers.CatapultConfigTransactionBuffer.createCatapultConfigTransactionBuffer = function(builder, size, signatureOffset, signerOffset, version, type, maxFeeOffset, deadlineOffset, applyHeightDeltaOffset, blockChainConfigSize, supportedEntityVersionsSize, blockChainConfigOffset, supportedEntityVersionsOffset) { +Catapult.Buffers.CatapultConfigTransactionBuffer.createCatapultConfigTransactionBuffer = function(builder, size, signatureOffset, signerOffset, version, type, maxFeeOffset, deadlineOffset, applyHeightDeltaOffset, blockNetworkConfigSize, supportedEntityVersionsSize, blockNetworkConfigOffset, supportedEntityVersionsOffset) { Catapult.Buffers.CatapultConfigTransactionBuffer.startCatapultConfigTransactionBuffer(builder); Catapult.Buffers.CatapultConfigTransactionBuffer.addSize(builder, size); Catapult.Buffers.CatapultConfigTransactionBuffer.addSignature(builder, signatureOffset); @@ -559,9 +559,9 @@ Catapult.Buffers.CatapultConfigTransactionBuffer.createCatapultConfigTransaction Catapult.Buffers.CatapultConfigTransactionBuffer.addMaxFee(builder, maxFeeOffset); Catapult.Buffers.CatapultConfigTransactionBuffer.addDeadline(builder, deadlineOffset); Catapult.Buffers.CatapultConfigTransactionBuffer.addApplyHeightDelta(builder, applyHeightDeltaOffset); - Catapult.Buffers.CatapultConfigTransactionBuffer.addBlockChainConfigSize(builder, blockChainConfigSize); + Catapult.Buffers.CatapultConfigTransactionBuffer.addBlockNetworkConfigSize(builder, blockNetworkConfigSize); Catapult.Buffers.CatapultConfigTransactionBuffer.addSupportedEntityVersionsSize(builder, supportedEntityVersionsSize); - Catapult.Buffers.CatapultConfigTransactionBuffer.addBlockChainConfig(builder, blockChainConfigOffset); + Catapult.Buffers.CatapultConfigTransactionBuffer.addBlockNetworkConfig(builder, blockNetworkConfigOffset); Catapult.Buffers.CatapultConfigTransactionBuffer.addSupportedEntityVersions(builder, supportedEntityVersionsOffset); return Catapult.Buffers.CatapultConfigTransactionBuffer.endCatapultConfigTransactionBuffer(builder); } diff --git a/src/infrastructure/buffers/NodeLinkTransactionBuffer.ts b/src/infrastructure/buffers/NodeLinkTransactionBuffer.ts new file mode 100644 index 00000000..6ea7fbab --- /dev/null +++ b/src/infrastructure/buffers/NodeLinkTransactionBuffer.ts @@ -0,0 +1,256 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class NodeLinkTransactionBuffer { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):NodeLinkTransactionBuffer { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsNodeLinkTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:NodeLinkTransactionBuffer):NodeLinkTransactionBuffer { + return (obj || new NodeLinkTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsNodeLinkTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:NodeLinkTransactionBuffer):NodeLinkTransactionBuffer { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new NodeLinkTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +size():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +signature(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signatureLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signatureArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +signer(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signerLength():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signerArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +version():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +type():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +maxFee(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +maxFeeLength():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +maxFeeArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +deadline(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +deadlineLength():number { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +deadlineArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +remoteAccountKey(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +remoteAccountKeyLength():number { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +remoteAccountKeyArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +linkAction():number { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; +} + +static startNodeLinkTransactionBuffer(builder:flatbuffers.Builder) { + builder.startObject(9); +} + +static addSize(builder:flatbuffers.Builder, size:number) { + builder.addFieldInt32(0, size, 0); +} + +static addSignature(builder:flatbuffers.Builder, signatureOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, signatureOffset, 0); +} + +static createSignatureVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignatureVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addSigner(builder:flatbuffers.Builder, signerOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, signerOffset, 0); +} + +static createSignerVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignerVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addVersion(builder:flatbuffers.Builder, version:number) { + builder.addFieldInt32(3, version, 0); +} + +static addType(builder:flatbuffers.Builder, type:number) { + builder.addFieldInt16(4, type, 0); +} + +static addMaxFee(builder:flatbuffers.Builder, maxFeeOffset:flatbuffers.Offset) { + builder.addFieldOffset(5, maxFeeOffset, 0); +} + +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startMaxFeeVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDeadline(builder:flatbuffers.Builder, deadlineOffset:flatbuffers.Offset) { + builder.addFieldOffset(6, deadlineOffset, 0); +} + +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startDeadlineVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addRemoteAccountKey(builder:flatbuffers.Builder, remoteAccountKeyOffset:flatbuffers.Offset) { + builder.addFieldOffset(7, remoteAccountKeyOffset, 0); +} + +static createRemoteAccountKeyVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startRemoteAccountKeyVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addLinkAction(builder:flatbuffers.Builder, linkAction:number) { + builder.addFieldInt8(8, linkAction, 0); +} + +static endNodeLinkTransactionBuffer(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishNodeLinkTransactionBufferBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset); +} + +static finishSizePrefixedNodeLinkTransactionBufferBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, undefined, true); +} + +static createNodeLinkTransactionBuffer(builder:flatbuffers.Builder, size:number, signatureOffset:flatbuffers.Offset, signerOffset:flatbuffers.Offset, version:number, type:number, maxFeeOffset:flatbuffers.Offset, deadlineOffset:flatbuffers.Offset, remoteAccountKeyOffset:flatbuffers.Offset, linkAction:number):flatbuffers.Offset { + NodeLinkTransactionBuffer.startNodeLinkTransactionBuffer(builder); + NodeLinkTransactionBuffer.addSize(builder, size); + NodeLinkTransactionBuffer.addSignature(builder, signatureOffset); + NodeLinkTransactionBuffer.addSigner(builder, signerOffset); + NodeLinkTransactionBuffer.addVersion(builder, version); + NodeLinkTransactionBuffer.addType(builder, type); + NodeLinkTransactionBuffer.addMaxFee(builder, maxFeeOffset); + NodeLinkTransactionBuffer.addDeadline(builder, deadlineOffset); + NodeLinkTransactionBuffer.addRemoteAccountKey(builder, remoteAccountKeyOffset); + NodeLinkTransactionBuffer.addLinkAction(builder, linkAction); + return NodeLinkTransactionBuffer.endNodeLinkTransactionBuffer(builder); +} +} diff --git a/src/infrastructure/buffers/VrfLinkTransactionBuffer.ts b/src/infrastructure/buffers/VrfLinkTransactionBuffer.ts new file mode 100644 index 00000000..cfd6bef5 --- /dev/null +++ b/src/infrastructure/buffers/VrfLinkTransactionBuffer.ts @@ -0,0 +1,256 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class VrfLinkTransactionBuffer { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):VrfLinkTransactionBuffer { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsVrfLinkTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:VrfLinkTransactionBuffer):VrfLinkTransactionBuffer { + return (obj || new VrfLinkTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsVrfLinkTransactionBuffer(bb:flatbuffers.ByteBuffer, obj?:VrfLinkTransactionBuffer):VrfLinkTransactionBuffer { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new VrfLinkTransactionBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +size():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +signature(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signatureLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signatureArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +signer(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +signerLength():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +signerArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +version():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +type():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +maxFee(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +maxFeeLength():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +maxFeeArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +deadline(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; +} + +deadlineLength():number { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +deadlineArray():Uint32Array|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +remoteAccountKey(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +remoteAccountKeyLength():number { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +remoteAccountKeyArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +linkAction():number { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; +} + +static startVrfLinkTransactionBuffer(builder:flatbuffers.Builder) { + builder.startObject(9); +} + +static addSize(builder:flatbuffers.Builder, size:number) { + builder.addFieldInt32(0, size, 0); +} + +static addSignature(builder:flatbuffers.Builder, signatureOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, signatureOffset, 0); +} + +static createSignatureVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignatureVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addSigner(builder:flatbuffers.Builder, signerOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, signerOffset, 0); +} + +static createSignerVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startSignerVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addVersion(builder:flatbuffers.Builder, version:number) { + builder.addFieldInt32(3, version, 0); +} + +static addType(builder:flatbuffers.Builder, type:number) { + builder.addFieldInt16(4, type, 0); +} + +static addMaxFee(builder:flatbuffers.Builder, maxFeeOffset:flatbuffers.Offset) { + builder.addFieldOffset(5, maxFeeOffset, 0); +} + +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createMaxFeeVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startMaxFeeVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDeadline(builder:flatbuffers.Builder, deadlineOffset:flatbuffers.Offset) { + builder.addFieldOffset(6, deadlineOffset, 0); +} + +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createDeadlineVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]!); + } + return builder.endVector(); +} + +static startDeadlineVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addRemoteAccountKey(builder:flatbuffers.Builder, remoteAccountKeyOffset:flatbuffers.Offset) { + builder.addFieldOffset(7, remoteAccountKeyOffset, 0); +} + +static createRemoteAccountKeyVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startRemoteAccountKeyVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addLinkAction(builder:flatbuffers.Builder, linkAction:number) { + builder.addFieldInt8(8, linkAction, 0); +} + +static endVrfLinkTransactionBuffer(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishVrfLinkTransactionBufferBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset); +} + +static finishSizePrefixedVrfLinkTransactionBufferBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, undefined, true); +} + +static createVrfLinkTransactionBuffer(builder:flatbuffers.Builder, size:number, signatureOffset:flatbuffers.Offset, signerOffset:flatbuffers.Offset, version:number, type:number, maxFeeOffset:flatbuffers.Offset, deadlineOffset:flatbuffers.Offset, remoteAccountKeyOffset:flatbuffers.Offset, linkAction:number):flatbuffers.Offset { + VrfLinkTransactionBuffer.startVrfLinkTransactionBuffer(builder); + VrfLinkTransactionBuffer.addSize(builder, size); + VrfLinkTransactionBuffer.addSignature(builder, signatureOffset); + VrfLinkTransactionBuffer.addSigner(builder, signerOffset); + VrfLinkTransactionBuffer.addVersion(builder, version); + VrfLinkTransactionBuffer.addType(builder, type); + VrfLinkTransactionBuffer.addMaxFee(builder, maxFeeOffset); + VrfLinkTransactionBuffer.addDeadline(builder, deadlineOffset); + VrfLinkTransactionBuffer.addRemoteAccountKey(builder, remoteAccountKeyOffset); + VrfLinkTransactionBuffer.addLinkAction(builder, linkAction); + return VrfLinkTransactionBuffer.endVrfLinkTransactionBuffer(builder); +} +} diff --git a/src/infrastructure/builders/AccountAddressRestrictionTransaction.ts b/src/infrastructure/builders/AccountAddressRestrictionTransaction.ts new file mode 100644 index 00000000..d383c6b3 --- /dev/null +++ b/src/infrastructure/builders/AccountAddressRestrictionTransaction.ts @@ -0,0 +1,149 @@ +/* + * Copyright 2024 ProximaX + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @module transactions/AccountAddressRestrictionTransaction + */ +import { RawAddress as address } from '../../core/format'; +import { TransactionType } from '../../model/transaction/TransactionType'; +import { AccountAddressRestrictionTransactionBuffer } from '../buffers/AccountAddressRestrictionTransactionBuffer'; +import { AddressBuffer } from '../buffers/AddressBuffer'; +import AccountAddressRestrictionTransactionSchema from '../schemas/AccountAddressRestrictionTransactionSchema'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +import * as flatbuffers from 'flatbuffers'; + +export default class AccountAddressRestrictionTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, AccountAddressRestrictionTransactionSchema); + } +} + +export class Builder { + size: any; + maxFee: any; + version: any; + type: any; + deadline: any; + restrictionFlags: number; + restrictionAdditions: any[]; + restrictionDeletions: any[]; + + constructor() { + this.maxFee = [0, 0]; + this.type = TransactionType.Account_Address_Restriction; + } + + addSize(size) { + this.size = size; + return this; + } + + addMaxFee(maxFee) { + this.maxFee = maxFee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addRestrictionFlags(restrictionFlags: number){ + this.restrictionFlags = restrictionFlags; + return this; + } + + addRestrictionAdditions(restrictionAdditions) { + this.restrictionAdditions = restrictionAdditions; + return this; + } + + addRestrictionDeletions(restrictionDeletions) { + this.restrictionDeletions = restrictionDeletions; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + const restrictionAdditionsArray: any = []; + this.restrictionAdditions.forEach((addition) => { + const addressVector = AddressBuffer + .createAddressVector(builder, address.stringToAddress(addition)); + AddressBuffer.startAddressBuffer(builder); + AddressBuffer.addAddress(builder, addressVector); + restrictionAdditionsArray.push(AddressBuffer.endAddressBuffer(builder)); + }); + + const restrictionDeletionsArray: any = []; + this.restrictionDeletions.forEach((deletion) => { + const addressVector = AddressBuffer + .createAddressVector(builder, address.stringToAddress(deletion)); + AddressBuffer.startAddressBuffer(builder); + AddressBuffer.addAddress(builder, addressVector); + restrictionDeletionsArray.push(AddressBuffer.endAddressBuffer(builder)); + }); + + // Create vectors + const signatureVector = AccountAddressRestrictionTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = AccountAddressRestrictionTransactionBuffer + .createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = AccountAddressRestrictionTransactionBuffer + .createDeadlineVector(builder, this.deadline); + const feeVector = AccountAddressRestrictionTransactionBuffer + .createMaxFeeVector(builder, this.maxFee); + const restrictionAdditionsVector = AccountAddressRestrictionTransactionBuffer + .createRestrictionAdditionsVector(builder, restrictionAdditionsArray); + const restrictionDeletionsVector = AccountAddressRestrictionTransactionBuffer + .createRestrictionDeletionsVector(builder, restrictionDeletionsArray); + + AccountAddressRestrictionTransactionBuffer.startAccountAddressRestrictionTransactionBuffer(builder); + AccountAddressRestrictionTransactionBuffer.addSize(builder, this.size); + AccountAddressRestrictionTransactionBuffer.addSignature(builder, signatureVector); + AccountAddressRestrictionTransactionBuffer.addSigner(builder, signerVector); + AccountAddressRestrictionTransactionBuffer.addVersion(builder, this.version); + AccountAddressRestrictionTransactionBuffer.addType(builder, this.type); + AccountAddressRestrictionTransactionBuffer.addMaxFee(builder, feeVector); + AccountAddressRestrictionTransactionBuffer.addDeadline(builder, deadlineVector); + AccountAddressRestrictionTransactionBuffer.addRestrictionFlags(builder, this.restrictionFlags); + AccountAddressRestrictionTransactionBuffer.addRestrictionAdditionsCount(builder, this.restrictionAdditions.length); + AccountAddressRestrictionTransactionBuffer.addRestrictionDeletionsCount(builder, this.restrictionDeletions.length); + AccountAddressRestrictionTransactionBuffer.addAccountRestrictionTransactionBodyReserved1(builder, 0); + AccountAddressRestrictionTransactionBuffer.addRestrictionAdditions(builder, restrictionAdditionsVector); + AccountAddressRestrictionTransactionBuffer.addRestrictionDeletions(builder, restrictionDeletionsVector); + + // Calculate size + const codedAccountAddressRestriction = AccountAddressRestrictionTransactionBuffer + .endAccountAddressRestrictionTransactionBuffer(builder); + builder.finish(codedAccountAddressRestriction); + + const bytes = builder.asUint8Array(); + + return new AccountAddressRestrictionTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/AccountMosaicRestrictionTransaction.ts b/src/infrastructure/builders/AccountMosaicRestrictionTransaction.ts new file mode 100644 index 00000000..cdd7db84 --- /dev/null +++ b/src/infrastructure/builders/AccountMosaicRestrictionTransaction.ts @@ -0,0 +1,148 @@ +/* + * Copyright 2024 ProximaX + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @module transactions/AccountMosaicRestrictionTransaction + */ +import { TransactionType } from '../../model/transaction/TransactionType'; +import { AccountMosaicRestrictionTransactionBuffer } from '../buffers/AccountMosaicRestrictionTransactionBuffer'; +import { MosaicId } from '../buffers/MosaicIdBuffer'; +import AccountMosaicRestrictionTransactionSchema from '../schemas/AccountMosaicRestrictionTransactionSchema'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +import * as flatbuffers from 'flatbuffers'; + +export default class AccountMosaicRestrictionTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, AccountMosaicRestrictionTransactionSchema); + } +} + +export class Builder { + size: any; + maxFee: any; + version: any; + type: any; + deadline: any; + restrictionFlags: number; + restrictionAdditions: number[][]; + restrictionDeletions: number[][]; + + constructor() { + this.maxFee = [0, 0]; + this.type = TransactionType.Account_Mosaic_Restriction; + } + + addSize(size) { + this.size = size; + return this; + } + + addMaxFee(maxFee) { + this.maxFee = maxFee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addRestrictionFlags(restrictionFlags: number){ + this.restrictionFlags = restrictionFlags; + return this; + } + + addRestrictionAdditions(restrictionAdditions) { + this.restrictionAdditions = restrictionAdditions; + return this; + } + + addRestrictionDeletions(restrictionDeletions) { + this.restrictionDeletions = restrictionDeletions; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + const restrictionAdditionsArray: any = []; + this.restrictionAdditions.forEach((addition) => { + const idVector = MosaicId + .createIdVector(builder, addition); + MosaicId.startMosaicId(builder); + MosaicId.addId(builder, idVector); + restrictionAdditionsArray.push(MosaicId.endMosaicId(builder)); + }); + + const restrictionDeletionsArray: any = []; + this.restrictionDeletions.forEach((deletion) => { + const idVector = MosaicId + .createIdVector(builder, deletion); + MosaicId.startMosaicId(builder); + MosaicId.addId(builder, idVector); + restrictionDeletionsArray.push(MosaicId.endMosaicId(builder)); + }); + + // Create vectors + const signatureVector = AccountMosaicRestrictionTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = AccountMosaicRestrictionTransactionBuffer + .createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = AccountMosaicRestrictionTransactionBuffer + .createDeadlineVector(builder, this.deadline); + const feeVector = AccountMosaicRestrictionTransactionBuffer + .createMaxFeeVector(builder, this.maxFee); + const restrictionAdditionsVector = AccountMosaicRestrictionTransactionBuffer + .createRestrictionAdditionsVector(builder, restrictionAdditionsArray); + const restrictionDeletionsVector = AccountMosaicRestrictionTransactionBuffer + .createRestrictionDeletionsVector(builder, restrictionDeletionsArray); + + AccountMosaicRestrictionTransactionBuffer.startAccountMosaicRestrictionTransactionBuffer(builder); + AccountMosaicRestrictionTransactionBuffer.addSize(builder, this.size); + AccountMosaicRestrictionTransactionBuffer.addSignature(builder, signatureVector); + AccountMosaicRestrictionTransactionBuffer.addSigner(builder, signerVector); + AccountMosaicRestrictionTransactionBuffer.addVersion(builder, this.version); + AccountMosaicRestrictionTransactionBuffer.addType(builder, this.type); + AccountMosaicRestrictionTransactionBuffer.addMaxFee(builder, feeVector); + AccountMosaicRestrictionTransactionBuffer.addDeadline(builder, deadlineVector); + AccountMosaicRestrictionTransactionBuffer.addRestrictionFlags(builder, this.restrictionFlags); + AccountMosaicRestrictionTransactionBuffer.addRestrictionAdditionsCount(builder, this.restrictionAdditions.length); + AccountMosaicRestrictionTransactionBuffer.addRestrictionDeletionsCount(builder, this.restrictionDeletions.length); + AccountMosaicRestrictionTransactionBuffer.addAccountRestrictionTransactionBodyReserved1(builder, 0); + AccountMosaicRestrictionTransactionBuffer.addRestrictionAdditions(builder, restrictionAdditionsVector); + AccountMosaicRestrictionTransactionBuffer.addRestrictionDeletions(builder, restrictionDeletionsVector); + + // Calculate size + const codedAccountMosaicRestriction = AccountMosaicRestrictionTransactionBuffer + .endAccountMosaicRestrictionTransactionBuffer(builder); + builder.finish(codedAccountMosaicRestriction); + + const bytes = builder.asUint8Array(); + + return new AccountMosaicRestrictionTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/AccountOperationRestrictionTransaction.ts b/src/infrastructure/builders/AccountOperationRestrictionTransaction.ts new file mode 100644 index 00000000..397cd906 --- /dev/null +++ b/src/infrastructure/builders/AccountOperationRestrictionTransaction.ts @@ -0,0 +1,129 @@ +/* + * Copyright 2024 ProximaX + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @module transactions/AccountOperationRestrictionTransaction + */ +import { TransactionType } from '../../model/transaction/TransactionType'; +import { AccountOperationRestrictionTransactionBuffer } from '../buffers/AccountOperationRestrictionTransactionBuffer'; +import AccountOperationRestrictionTransactionSchema from '../schemas/AccountOperationRestrictionTransactionSchema'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +import * as flatbuffers from 'flatbuffers'; + +export default class AccountOperationRestrictionTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, AccountOperationRestrictionTransactionSchema); + } +} + +export class Builder { + size: any; + maxFee: any; + version: any; + type: any; + deadline: any; + restrictionFlags: number; + restrictionAdditions: number[]; + restrictionDeletions: number[]; + + constructor() { + this.maxFee = [0, 0]; + this.type = TransactionType.Account_Operation_Restriction; + } + + addSize(size) { + this.size = size; + return this; + } + + addMaxFee(maxFee) { + this.maxFee = maxFee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addRestrictionFlags(restrictionFlags: number){ + this.restrictionFlags = restrictionFlags; + return this; + } + + addRestrictionAdditions(restrictionAdditions) { + this.restrictionAdditions = restrictionAdditions; + return this; + } + + addRestrictionDeletions(restrictionDeletions) { + this.restrictionDeletions = restrictionDeletions; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + // Create vectors + const signatureVector = AccountOperationRestrictionTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = AccountOperationRestrictionTransactionBuffer + .createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = AccountOperationRestrictionTransactionBuffer + .createDeadlineVector(builder, this.deadline); + const feeVector = AccountOperationRestrictionTransactionBuffer + .createMaxFeeVector(builder, this.maxFee); + const restrictionAdditionsVector = AccountOperationRestrictionTransactionBuffer + .createRestrictionAdditionsVector(builder, this.restrictionAdditions); + const restrictionDeletionsVector = AccountOperationRestrictionTransactionBuffer + .createRestrictionDeletionsVector(builder, this.restrictionDeletions); + + AccountOperationRestrictionTransactionBuffer.startAccountOperationRestrictionTransactionBuffer(builder); + AccountOperationRestrictionTransactionBuffer.addSize(builder, this.size); + AccountOperationRestrictionTransactionBuffer.addSignature(builder, signatureVector); + AccountOperationRestrictionTransactionBuffer.addSigner(builder, signerVector); + AccountOperationRestrictionTransactionBuffer.addVersion(builder, this.version); + AccountOperationRestrictionTransactionBuffer.addType(builder, this.type); + AccountOperationRestrictionTransactionBuffer.addMaxFee(builder, feeVector); + AccountOperationRestrictionTransactionBuffer.addDeadline(builder, deadlineVector); + AccountOperationRestrictionTransactionBuffer.addRestrictionFlags(builder, this.restrictionFlags); + AccountOperationRestrictionTransactionBuffer.addRestrictionAdditionsCount(builder, this.restrictionAdditions.length); + AccountOperationRestrictionTransactionBuffer.addRestrictionDeletionsCount(builder, this.restrictionDeletions.length); + AccountOperationRestrictionTransactionBuffer.addAccountRestrictionTransactionBodyReserved1(builder, 0); + AccountOperationRestrictionTransactionBuffer.addRestrictionAdditions(builder, restrictionAdditionsVector); + AccountOperationRestrictionTransactionBuffer.addRestrictionDeletions(builder, restrictionDeletionsVector); + + // Calculate size + const codedAccountOperationRestriction = AccountOperationRestrictionTransactionBuffer + .endAccountOperationRestrictionTransactionBuffer(builder); + builder.finish(codedAccountOperationRestriction); + + const bytes = builder.asUint8Array(); + + return new AccountOperationRestrictionTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/AccountV2UpgradeTransaction.ts b/src/infrastructure/builders/AccountV2UpgradeTransaction.ts new file mode 100644 index 00000000..4719318d --- /dev/null +++ b/src/infrastructure/builders/AccountV2UpgradeTransaction.ts @@ -0,0 +1,107 @@ +/* + * Copyright 2024 ProximaX + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @module transactions/AccountV2UpgradeTransaction + */ +import { Convert as convert } from '../../core/format'; +import { TransactionType } from '../../model/transaction/TransactionType'; +import { AccountV2UpgradeTransactionBuffer} from '../buffers/AccountV2UpgradeTransactionBuffer'; +import AccountV2UpgradeTransactionSchema from '../schemas/AccountV2UpgradeTransactionSchema'; +import {VerifiableTransaction} from './VerifiableTransaction'; + +import * as flatbuffers from 'flatbuffers'; + +export class AccountV2UpgradeTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, AccountV2UpgradeTransactionSchema); + } +} + +// tslint:disable-next-line:max-classes-per-file +export class Builder { + size: number; + maxFee: number[]; + version: number; + type: number; + deadline: number[]; + newPublicAccountKey: string; + + constructor() { + this.maxFee = [0, 0]; + this.type = TransactionType.Account_V2_Upgrade; + } + + addSize(size) { + this.size = size; + return this; + } + + addMaxFee(maxFee) { + this.maxFee = maxFee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addNewPublicAccountKey(newPublicAccountKey) { + this.newPublicAccountKey = newPublicAccountKey; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + // Create vectors + const signatureVector = AccountV2UpgradeTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = AccountV2UpgradeTransactionBuffer.createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = AccountV2UpgradeTransactionBuffer.createDeadlineVector(builder, this.deadline); + const feeVector = AccountV2UpgradeTransactionBuffer.createMaxFeeVector(builder, this.maxFee); + const newPublicAccountKeyVector = AccountV2UpgradeTransactionBuffer.createNewaccountpublickeyVector(builder, convert.hexToUint8(this.newPublicAccountKey)); + + AccountV2UpgradeTransactionBuffer.startAccountV2UpgradeTransactionBuffer(builder); + AccountV2UpgradeTransactionBuffer.addSize(builder, this.size); + AccountV2UpgradeTransactionBuffer.addSignature(builder, signatureVector); + AccountV2UpgradeTransactionBuffer.addSigner(builder, signerVector); + AccountV2UpgradeTransactionBuffer.addVersion(builder, this.version); + AccountV2UpgradeTransactionBuffer.addType(builder, this.type); + AccountV2UpgradeTransactionBuffer.addMaxFee(builder, feeVector); + AccountV2UpgradeTransactionBuffer.addDeadline(builder, deadlineVector); + AccountV2UpgradeTransactionBuffer.addNewaccountpublickey(builder, newPublicAccountKeyVector); + + // Calculate size + + const codedTxn = AccountV2UpgradeTransactionBuffer.endAccountV2UpgradeTransactionBuffer(builder); + builder.finish(codedTxn); + + const bytes = builder.asUint8Array(); + return new AccountV2UpgradeTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/LockFundCancelUnlockTransaction.ts b/src/infrastructure/builders/LockFundCancelUnlockTransaction.ts new file mode 100644 index 00000000..6901b752 --- /dev/null +++ b/src/infrastructure/builders/LockFundCancelUnlockTransaction.ts @@ -0,0 +1,98 @@ +// Copyright 2019 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { TransactionType } from '../../model/transaction/TransactionType'; +import { LockFundCancelUnlockTransactionBuffer } from '../buffers/LockFundCancelUnlockTransactionBuffer'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +import * as flatbuffers from 'flatbuffers'; +import LockFundCancelUnlockTransactionSchema from '../schemas/LockFundCancelUnlockTransactionSchema'; + +/** + * @module transactions/LockFundCancelUnlockTransaction + */ +export default class LockFundCancelUnlockTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, LockFundCancelUnlockTransactionSchema); + } +} + +export class Builder { + size: any; + maxFee: any; + version: any; + type: any; + deadline: any; + targetHeight: any; + + constructor() { + this.maxFee = [0, 0]; + this.type = TransactionType.Lock_Fund_Cancel_Unlock; + } + + addSize(size) { + this.size = size; + return this; + } + + addMaxFee(maxFee) { + this.maxFee = maxFee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addTargetHeight(targetHeight) { + this.targetHeight = targetHeight; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + // Create vectors + const signatureVector = LockFundCancelUnlockTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = LockFundCancelUnlockTransactionBuffer + .createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = LockFundCancelUnlockTransactionBuffer + .createDeadlineVector(builder, this.deadline); + const feeVector = LockFundCancelUnlockTransactionBuffer + .createMaxFeeVector(builder, this.maxFee); + const targetHeightVector = LockFundCancelUnlockTransactionBuffer + .createTargetHeightVector(builder, this.targetHeight); + + LockFundCancelUnlockTransactionBuffer.startLockFundCancelUnlockTransactionBuffer(builder); + LockFundCancelUnlockTransactionBuffer.addSize(builder, this.size); + LockFundCancelUnlockTransactionBuffer.addSignature(builder, signatureVector); + LockFundCancelUnlockTransactionBuffer.addSigner(builder, signerVector); + LockFundCancelUnlockTransactionBuffer.addVersion(builder, this.version); + LockFundCancelUnlockTransactionBuffer.addType(builder, this.type); + LockFundCancelUnlockTransactionBuffer.addMaxFee(builder, feeVector); + LockFundCancelUnlockTransactionBuffer.addDeadline(builder, deadlineVector); + LockFundCancelUnlockTransactionBuffer.addTargetHeight(builder, targetHeightVector); + + + // Calculate size + const codedTxn= LockFundCancelUnlockTransactionBuffer.endLockFundCancelUnlockTransactionBuffer(builder); + builder.finish(codedTxn); + + const bytes = builder.asUint8Array(); + + return new LockFundCancelUnlockTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/LockFundTransferTransaction.ts b/src/infrastructure/builders/LockFundTransferTransaction.ts new file mode 100644 index 00000000..15495f35 --- /dev/null +++ b/src/infrastructure/builders/LockFundTransferTransaction.ts @@ -0,0 +1,124 @@ +// Copyright 2019 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { TransactionType } from '../../model/transaction/TransactionType'; +import { LockFundTransferTransactionBuffer } from '../buffers/LockFundTransferTransactionBuffer'; +import { MosaicBuffer } from '../buffers/MosaicBuffer'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +import * as flatbuffers from 'flatbuffers'; +import LockFundTransferTransactionSchema from '../schemas/LockFundTransferTransactionSchema'; + +/** + * @module transactions/LockFundTransferTransaction + */ +export default class LockFundTransferTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, LockFundTransferTransactionSchema); + } +} + +export class Builder { + size: any; + maxFee: any; + version: any; + type: any; + deadline: any; + duration: any; + action: any; + mosaics: any[]; + + constructor() { + this.maxFee = [0, 0]; + this.type = TransactionType.Lock_Fund_Transfer; + } + + addSize(size) { + this.size = size; + return this; + } + + addMaxFee(maxFee) { + this.maxFee = maxFee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addDuration(duration) { + this.duration = duration; + return this; + } + + addAction(action) { + this.action = action; + return this; + } + + addMosaics(mosaics) { + this.mosaics = mosaics; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + const mosaicsArray: any[] = []; + this.mosaics.forEach(mosaic => { + const id = MosaicBuffer.createIdVector(builder, mosaic.id); + const amount = MosaicBuffer.createAmountVector(builder, mosaic.amount); + MosaicBuffer.startMosaicBuffer(builder); + MosaicBuffer.addId(builder, id); + MosaicBuffer.addAmount(builder, amount); + mosaicsArray.push(MosaicBuffer.endMosaicBuffer(builder)); + }); + + // Create vectors + const signatureVector = LockFundTransferTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = LockFundTransferTransactionBuffer + .createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = LockFundTransferTransactionBuffer + .createDeadlineVector(builder, this.deadline); + const feeVector = LockFundTransferTransactionBuffer + .createMaxFeeVector(builder, this.maxFee); + const durationVector = LockFundTransferTransactionBuffer + .createDurationVector(builder, this.duration); + const mosaicsVector = LockFundTransferTransactionBuffer + .createMosaicsVector(builder, mosaicsArray); + LockFundTransferTransactionBuffer.startLockFundTransferTransactionBuffer(builder); + LockFundTransferTransactionBuffer.addSize(builder, this.size); + LockFundTransferTransactionBuffer.addSignature(builder, signatureVector); + LockFundTransferTransactionBuffer.addSigner(builder, signerVector); + LockFundTransferTransactionBuffer.addVersion(builder, this.version); + LockFundTransferTransactionBuffer.addType(builder, this.type); + LockFundTransferTransactionBuffer.addMaxFee(builder, feeVector); + LockFundTransferTransactionBuffer.addDeadline(builder, deadlineVector); + LockFundTransferTransactionBuffer.addDuration(builder, durationVector); + LockFundTransferTransactionBuffer.addAction(builder, this.action); + LockFundTransferTransactionBuffer.addMosaicsCount(builder, this.mosaics.length); + LockFundTransferTransactionBuffer.addMosaics(builder, mosaicsVector); + + // Calculate size + const codedTxn= LockFundTransferTransactionBuffer.endLockFundTransferTransactionBuffer(builder); + builder.finish(codedTxn); + + const bytes = builder.asUint8Array(); + + return new LockFundTransferTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/MosaicAddressRestrictionTransaction.ts b/src/infrastructure/builders/MosaicAddressRestrictionTransaction.ts new file mode 100644 index 00000000..2212eda0 --- /dev/null +++ b/src/infrastructure/builders/MosaicAddressRestrictionTransaction.ts @@ -0,0 +1,142 @@ +// Copyright 2024 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { Convert as convert, RawAddress as address} from '../../core/format'; +import { TransactionType } from '../../model/transaction/TransactionType'; +import { MosaicAddressRestrictionTransactionBuffer } from '../buffers/MosaicAddressRestrictionTransactionBuffer'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +import * as flatbuffers from 'flatbuffers'; +import MosaicAddressRestrictionTransactionSchema from '../schemas/MosaicAddressRestrictionTransactionSchema'; + +/** + * @module transactions/MosaicAddressRestrictionTransaction + */ +export default class MosaicAddressRestrictionTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, MosaicAddressRestrictionTransactionSchema); + } +} + +export class Builder { + size: number; + maxFee: number[]; + version: number; + type: number; + deadline: number[]; + mosaicId: number[]; + restrictionKey: number[]; + previousRestrictionValue: number[]; + newRestrictionValue: number[]; + targetAddress: Uint8Array; + + constructor() { + this.maxFee = [0, 0]; + this.type = TransactionType.Mosaic_Address_Restriction; + } + + addSize(size) { + this.size = size; + return this; + } + + addMaxFee(maxFee) { + this.maxFee = maxFee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addMosaicId(mosaicId) { + this.mosaicId = mosaicId; + return this; + } + + addRestrictionKey(restrictionKey) { + this.restrictionKey = restrictionKey; + return this; + } + + addPreviousRestrictionValue(previousRestrictionValue) { + this.previousRestrictionValue = previousRestrictionValue; + return this; + } + + + addNewRestrictionValue(newRestrictionValue) { + this.newRestrictionValue = newRestrictionValue; + return this; + } + + addTargetAddress(targetAddress) { + if (/^[0-9a-fA-F]{16}$/.test(targetAddress)) { + // received hexadecimal notation of namespaceId (alias) + this.targetAddress = address.aliasToRecipient(convert.hexToUint8(targetAddress)); + } else { + // received recipient address + this.targetAddress = address.stringToAddress(targetAddress); + } + return this; + } + + + build() { + const builder = new flatbuffers.Builder(1); + + // Create vectors + const signatureVector = MosaicAddressRestrictionTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = MosaicAddressRestrictionTransactionBuffer + .createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = MosaicAddressRestrictionTransactionBuffer + .createDeadlineVector(builder, this.deadline); + const feeVector = MosaicAddressRestrictionTransactionBuffer + .createMaxFeeVector(builder, this.maxFee); + const mosaicIdVector = MosaicAddressRestrictionTransactionBuffer + .createMosaicIdVector(builder, this.mosaicId); + const restrictionKeyVector = MosaicAddressRestrictionTransactionBuffer + .createRestrictionKeyVector(builder, this.restrictionKey); + const previousRestrictionValueVector = MosaicAddressRestrictionTransactionBuffer + .createPreviousRestrictionValueVector(builder, this.previousRestrictionValue); + const newRestrictionValueVector = MosaicAddressRestrictionTransactionBuffer + .createNewRestrictionValueVector(builder, this.newRestrictionValue); + const targetAddressVector = MosaicAddressRestrictionTransactionBuffer + .createTargetAddressVector(builder, this.targetAddress); + + MosaicAddressRestrictionTransactionBuffer.startMosaicAddressRestrictionTransactionBuffer(builder); + MosaicAddressRestrictionTransactionBuffer.addSize(builder, this.size); + MosaicAddressRestrictionTransactionBuffer.addSignature(builder, signatureVector); + MosaicAddressRestrictionTransactionBuffer.addSigner(builder, signerVector); + MosaicAddressRestrictionTransactionBuffer.addVersion(builder, this.version); + MosaicAddressRestrictionTransactionBuffer.addType(builder, this.type); + MosaicAddressRestrictionTransactionBuffer.addMaxFee(builder, feeVector); + MosaicAddressRestrictionTransactionBuffer.addDeadline(builder, deadlineVector); + MosaicAddressRestrictionTransactionBuffer.addMosaicId(builder, mosaicIdVector); + MosaicAddressRestrictionTransactionBuffer.addRestrictionKey(builder, restrictionKeyVector); + MosaicAddressRestrictionTransactionBuffer.addPreviousRestrictionValue(builder, previousRestrictionValueVector); + MosaicAddressRestrictionTransactionBuffer.addNewRestrictionValue(builder, newRestrictionValueVector); + MosaicAddressRestrictionTransactionBuffer.addTargetAddress(builder, targetAddressVector); + + // Calculate size + const codedTxn= MosaicAddressRestrictionTransactionBuffer.endMosaicAddressRestrictionTransactionBuffer(builder); + builder.finish(codedTxn); + + const bytes = builder.asUint8Array(); + + return new MosaicAddressRestrictionTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/MosaicGlobalRestrictionTransaction.ts b/src/infrastructure/builders/MosaicGlobalRestrictionTransaction.ts new file mode 100644 index 00000000..451c7fe4 --- /dev/null +++ b/src/infrastructure/builders/MosaicGlobalRestrictionTransaction.ts @@ -0,0 +1,151 @@ +// Copyright 2024 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { TransactionType } from '../../model/transaction/TransactionType'; +import { MosaicGlobalRestrictionTransactionBuffer } from '../buffers/MosaicGlobalRestrictionTransactionBuffer'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +import * as flatbuffers from 'flatbuffers'; +import MosaicGlobalRestrictionTransactionSchema from '../schemas/MosaicGlobalRestrictionTransactionSchema'; + +/** + * @module transactions/MosaicGlobalRestrictionTransaction + */ +export default class MosaicGlobalRestrictionTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, MosaicGlobalRestrictionTransactionSchema); + } +} + +export class Builder { + size: number; + maxFee: number[]; + version: number; + type: number; + deadline: number[]; + mosaicId: number[]; + referenceMosaicId: number[]; + restrictionKey: number[]; + previousRestrictionValue: number[]; + newRestrictionValue: number[]; + previousRestrictionType: number; + newRestrictionType: number; + + constructor() { + this.maxFee = [0, 0]; + this.type = TransactionType.Mosaic_Global_Restriction; + } + + addSize(size) { + this.size = size; + return this; + } + + addMaxFee(maxFee) { + this.maxFee = maxFee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addMosaicId(mosaicId) { + this.mosaicId = mosaicId; + return this; + } + + addReferenceMosaicId(referenceMosaicId) { + this.referenceMosaicId = referenceMosaicId; + return this; + } + + addRestrictionKey(restrictionKey) { + this.restrictionKey = restrictionKey; + return this; + } + + addPreviousRestrictionValue(previousRestrictionValue) { + this.previousRestrictionValue = previousRestrictionValue; + return this; + } + + + addNewRestrictionValue(newRestrictionValue) { + this.newRestrictionValue = newRestrictionValue; + return this; + } + + + addPreviousRestrictionType(previousRestrictionType) { + this.previousRestrictionType = previousRestrictionType; + return this; + } + + + addNewRestrictionType(newRestrictionType) { + this.newRestrictionType = newRestrictionType; + return this; + } + + + build() { + const builder = new flatbuffers.Builder(1); + + // Create vectors + const signatureVector = MosaicGlobalRestrictionTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = MosaicGlobalRestrictionTransactionBuffer + .createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = MosaicGlobalRestrictionTransactionBuffer + .createDeadlineVector(builder, this.deadline); + const feeVector = MosaicGlobalRestrictionTransactionBuffer + .createMaxFeeVector(builder, this.maxFee); + const mosaicIdVector = MosaicGlobalRestrictionTransactionBuffer + .createMosaicIdVector(builder, this.mosaicId); + const referenceMosaicIdVector = MosaicGlobalRestrictionTransactionBuffer + .createReferenceMosaicIdVector(builder, this.referenceMosaicId); + const restrictionKeyVector = MosaicGlobalRestrictionTransactionBuffer + .createRestrictionKeyVector(builder, this.restrictionKey); + const previousRestrictionValueVector = MosaicGlobalRestrictionTransactionBuffer + .createPreviousRestrictionValueVector(builder, this.previousRestrictionValue); + const newRestrictionValueVector = MosaicGlobalRestrictionTransactionBuffer + .createNewRestrictionValueVector(builder, this.newRestrictionValue); + + MosaicGlobalRestrictionTransactionBuffer.startMosaicGlobalRestrictionTransactionBuffer(builder); + MosaicGlobalRestrictionTransactionBuffer.addSize(builder, this.size); + MosaicGlobalRestrictionTransactionBuffer.addSignature(builder, signatureVector); + MosaicGlobalRestrictionTransactionBuffer.addSigner(builder, signerVector); + MosaicGlobalRestrictionTransactionBuffer.addVersion(builder, this.version); + MosaicGlobalRestrictionTransactionBuffer.addType(builder, this.type); + MosaicGlobalRestrictionTransactionBuffer.addMaxFee(builder, feeVector); + MosaicGlobalRestrictionTransactionBuffer.addDeadline(builder, deadlineVector); + MosaicGlobalRestrictionTransactionBuffer.addMosaicId(builder, mosaicIdVector); + MosaicGlobalRestrictionTransactionBuffer.addReferenceMosaicId(builder, referenceMosaicIdVector); + MosaicGlobalRestrictionTransactionBuffer.addRestrictionKey(builder, restrictionKeyVector); + MosaicGlobalRestrictionTransactionBuffer.addPreviousRestrictionValue(builder, previousRestrictionValueVector); + MosaicGlobalRestrictionTransactionBuffer.addNewRestrictionValue(builder, newRestrictionValueVector); + MosaicGlobalRestrictionTransactionBuffer.addPreviousRestrictionType(builder, this.previousRestrictionType); + MosaicGlobalRestrictionTransactionBuffer.addNewRestrictionType(builder, this.newRestrictionType); + + // Calculate size + const codedTxn= MosaicGlobalRestrictionTransactionBuffer.endMosaicGlobalRestrictionTransactionBuffer(builder); + builder.finish(codedTxn); + + const bytes = builder.asUint8Array(); + + return new MosaicGlobalRestrictionTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/MosaicMetadataTransaction.ts b/src/infrastructure/builders/MosaicMetadataTransaction.ts index 9763e8d0..bbf3994e 100644 --- a/src/infrastructure/builders/MosaicMetadataTransaction.ts +++ b/src/infrastructure/builders/MosaicMetadataTransaction.ts @@ -35,7 +35,6 @@ export class Builder { constructor() { this.fee = [0, 0]; - this.version = 1; } addSize(size: number) { diff --git a/src/infrastructure/builders/NetworkConfigAbsoluteHeightTransaction.ts b/src/infrastructure/builders/NetworkConfigAbsoluteHeightTransaction.ts new file mode 100644 index 00000000..4f07f02d --- /dev/null +++ b/src/infrastructure/builders/NetworkConfigAbsoluteHeightTransaction.ts @@ -0,0 +1,116 @@ +// Copyright 2019 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +/** + * @module transactions/NetworkConfigTransaction + */ +import { TransactionType } from '../../model/transaction/TransactionType'; +import { NetworkConfigAbsoluteHeightTransactionBuffer } from '../buffers/NetworkConfigAbsoluteHeightTransactionBuffer'; +import NetworkConfigTransactionSchema from '../schemas/NetworkConfigAbsoluteHeightTransactionSchema'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +import * as flatbuffers from 'flatbuffers'; +import { Convert } from '../../core/format'; + +export default class NetworkConfigTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, NetworkConfigTransactionSchema); + } +} + +export class Builder { + size: any; + maxFee: any; + version: any; + type: any; + deadline: any; + applyHeight: any; + networkConfig: any; + supportedEntityVersions: any; + + constructor() { + this.maxFee = [0, 0]; + this.type = TransactionType.NetworkConfig_Absolute_Height; + } + + addSize(size) { + this.size = size; + return this; + } + + addMaxFee(maxFee) { + this.maxFee = maxFee; + return this; + } + + addApplyHeight(applyHeight) { + this.applyHeight = applyHeight; + return this; + } + + addNetworkConfig(networkConfig) { + this.networkConfig = networkConfig.split('').map(n=>n.charCodeAt(0)); + return this; + } + + addSupportedEntityVersions(supportedEntityVersions) { + this.supportedEntityVersions = supportedEntityVersions.split('').map(n=>n.charCodeAt(0)); + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + const signatureVector = NetworkConfigAbsoluteHeightTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = NetworkConfigAbsoluteHeightTransactionBuffer + .createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = NetworkConfigAbsoluteHeightTransactionBuffer + .createDeadlineVector(builder, this.deadline); + const feeVector = NetworkConfigAbsoluteHeightTransactionBuffer + .createMaxFeeVector(builder, this.maxFee); + const applyHeightVector = NetworkConfigAbsoluteHeightTransactionBuffer + .createApplyHeightVector(builder, this.applyHeight); + const networkConfigVector = NetworkConfigAbsoluteHeightTransactionBuffer + .createNetworkConfigVector(builder, this.networkConfig); + const supportedEntityVersionsVector = NetworkConfigAbsoluteHeightTransactionBuffer + .createSupportedEntityVersionsVector(builder, this.supportedEntityVersions); + + NetworkConfigAbsoluteHeightTransactionBuffer.startNetworkConfigAbsoluteHeightTransactionBuffer(builder); + NetworkConfigAbsoluteHeightTransactionBuffer.addSize(builder, this.size); + NetworkConfigAbsoluteHeightTransactionBuffer.addSignature(builder, signatureVector); + NetworkConfigAbsoluteHeightTransactionBuffer.addSigner(builder, signerVector); + NetworkConfigAbsoluteHeightTransactionBuffer.addVersion(builder, this.version); + NetworkConfigAbsoluteHeightTransactionBuffer.addType(builder, this.type); + NetworkConfigAbsoluteHeightTransactionBuffer.addMaxFee(builder, feeVector); + NetworkConfigAbsoluteHeightTransactionBuffer.addDeadline(builder, deadlineVector); + NetworkConfigAbsoluteHeightTransactionBuffer.addApplyHeight(builder, applyHeightVector); + NetworkConfigAbsoluteHeightTransactionBuffer.addNetworkConfigSize(builder, this.networkConfig.length); + NetworkConfigAbsoluteHeightTransactionBuffer.addSupportedEntityVersionsSize(builder, this.supportedEntityVersions.length); + NetworkConfigAbsoluteHeightTransactionBuffer.addNetworkConfig(builder, networkConfigVector); + NetworkConfigAbsoluteHeightTransactionBuffer.addSupportedEntityVersions(builder, supportedEntityVersionsVector); + + // Calculate size + const codedNetworkConfig = NetworkConfigAbsoluteHeightTransactionBuffer.endNetworkConfigAbsoluteHeightTransactionBuffer(builder); + builder.finish(codedNetworkConfig); + + const bytes = builder.asUint8Array(); + return new NetworkConfigTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/ChainConfigTransaction.ts b/src/infrastructure/builders/NetworkConfigTransaction.ts similarity index 80% rename from src/infrastructure/builders/ChainConfigTransaction.ts rename to src/infrastructure/builders/NetworkConfigTransaction.ts index cce08466..73b8b15d 100644 --- a/src/infrastructure/builders/ChainConfigTransaction.ts +++ b/src/infrastructure/builders/NetworkConfigTransaction.ts @@ -3,23 +3,23 @@ // license that can be found in the LICENSE file /** - * @module transactions/ChainConfigTransaction + * @module transactions/NetworkConfigTransaction */ import { TransactionType } from '../../model/transaction/TransactionType'; -import ChainConfigTransactionBufferPackage from '../buffers/ChainConfigTransactionBuffer'; -import ChainConfigTransactionSchema from '../schemas/ChainConfigTransactionSchema'; +import NetworkConfigTransactionBufferPackage from '../buffers/NetworkConfigTransactionBuffer'; +import NetworkConfigTransactionSchema from '../schemas/NetworkConfigTransactionSchema'; import { VerifiableTransaction } from './VerifiableTransaction'; const { CatapultConfigTransactionBuffer, -} = ChainConfigTransactionBufferPackage.Buffers; +} = NetworkConfigTransactionBufferPackage.Buffers; import * as flatbuffers from 'flatbuffers'; import { Convert } from '../../core/format'; -export default class ChainConfigTransaction extends VerifiableTransaction { +export default class NetworkConfigTransaction extends VerifiableTransaction { constructor(bytes) { - super(bytes, ChainConfigTransactionSchema); + super(bytes, NetworkConfigTransactionSchema); } } @@ -92,7 +92,7 @@ export class Builder { const applyHeightDeltaVector = CatapultConfigTransactionBuffer .createApplyHeightDeltaVector(builder, this.applyHeightDelta); const networkConfigVector = CatapultConfigTransactionBuffer - .createBlockChainConfigVector(builder, this.networkConfig); + .createBlockNetworkConfigVector(builder, this.networkConfig); const supportedEntityVersionsVector = CatapultConfigTransactionBuffer .createSupportedEntityVersionsVector(builder, this.supportedEntityVersions); @@ -105,16 +105,16 @@ export class Builder { CatapultConfigTransactionBuffer.addMaxFee(builder, feeVector); CatapultConfigTransactionBuffer.addDeadline(builder, deadlineVector); CatapultConfigTransactionBuffer.addApplyHeightDelta(builder, applyHeightDeltaVector); - CatapultConfigTransactionBuffer.addBlockChainConfigSize(builder, this.networkConfig.length); + CatapultConfigTransactionBuffer.addBlockNetworkConfigSize(builder, this.networkConfig.length); CatapultConfigTransactionBuffer.addSupportedEntityVersionsSize(builder, this.supportedEntityVersions.length); - CatapultConfigTransactionBuffer.addBlockChainConfig(builder, networkConfigVector); + CatapultConfigTransactionBuffer.addBlockNetworkConfig(builder, networkConfigVector); CatapultConfigTransactionBuffer.addSupportedEntityVersions(builder, supportedEntityVersionsVector); // Calculate size - const codedChainConfig = CatapultConfigTransactionBuffer.endCatapultConfigTransactionBuffer(builder); - builder.finish(codedChainConfig); + const codedNetworkConfig = CatapultConfigTransactionBuffer.endCatapultConfigTransactionBuffer(builder); + builder.finish(codedNetworkConfig); const bytes = builder.asUint8Array(); - return new ChainConfigTransaction(bytes); + return new NetworkConfigTransaction(bytes); } } diff --git a/src/infrastructure/builders/NodeLinkTransaction.ts b/src/infrastructure/builders/NodeLinkTransaction.ts new file mode 100644 index 00000000..b5e78fae --- /dev/null +++ b/src/infrastructure/builders/NodeLinkTransaction.ts @@ -0,0 +1,114 @@ +/* + * Copyright 2024 ProximaX + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @module transactions/NodeLinkTransaction + */ +import { Convert as convert } from '../../core/format'; +import { TransactionType } from '../../model/transaction/TransactionType'; +import { NodeLinkTransactionBuffer} from '../buffers/NodeLinkTransactionBuffer'; +import NodeLinkTransactionSchema from '../schemas/NodeLinkTransactionSchema'; +import {VerifiableTransaction} from './VerifiableTransaction'; + +import * as flatbuffers from 'flatbuffers'; + +export class NodeLinkTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, NodeLinkTransactionSchema); + } +} + +// tslint:disable-next-line:max-classes-per-file +export class Builder { + size: number; + maxFee: number[]; + version: number; + type: number; + deadline: number[]; + remoteAccountKey: string; + linkAction: number; + + constructor() { + this.maxFee = [0, 0]; + this.type = TransactionType.Node_Key_Link; + } + + addSize(size) { + this.size = size; + return this; + } + + addMaxFee(maxFee) { + this.maxFee = maxFee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addRemoteAccountKey(remoteAccountKey) { + this.remoteAccountKey = remoteAccountKey; + return this; + } + + addLinkAction(linkAction){ + this.linkAction = linkAction; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + // Create vectors + const signatureVector = NodeLinkTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = NodeLinkTransactionBuffer.createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = NodeLinkTransactionBuffer.createDeadlineVector(builder, this.deadline); + const feeVector = NodeLinkTransactionBuffer.createMaxFeeVector(builder, this.maxFee); + const remoteAccountKeyVector = NodeLinkTransactionBuffer.createRemoteAccountKeyVector(builder, convert.hexToUint8(this.remoteAccountKey)); + + NodeLinkTransactionBuffer.startNodeLinkTransactionBuffer(builder); + NodeLinkTransactionBuffer.addSize(builder, this.size); + NodeLinkTransactionBuffer.addSignature(builder, signatureVector); + NodeLinkTransactionBuffer.addSigner(builder, signerVector); + NodeLinkTransactionBuffer.addVersion(builder, this.version); + NodeLinkTransactionBuffer.addType(builder, this.type); + NodeLinkTransactionBuffer.addMaxFee(builder, feeVector); + NodeLinkTransactionBuffer.addDeadline(builder, deadlineVector); + NodeLinkTransactionBuffer.addRemoteAccountKey(builder, remoteAccountKeyVector); + NodeLinkTransactionBuffer.addLinkAction(builder, this.linkAction); + + // Calculate size + + const codedTxn = NodeLinkTransactionBuffer.endNodeLinkTransactionBuffer(builder); + builder.finish(codedTxn); + + const bytes = builder.asUint8Array(); + return new NodeLinkTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/VrfLinkTransaction.ts b/src/infrastructure/builders/VrfLinkTransaction.ts new file mode 100644 index 00000000..38d714d0 --- /dev/null +++ b/src/infrastructure/builders/VrfLinkTransaction.ts @@ -0,0 +1,114 @@ +/* + * Copyright 2024 ProximaX + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @module transactions/VrfLinkTransaction + */ +import { Convert as convert } from '../../core/format'; +import { TransactionType } from '../../model/transaction/TransactionType'; +import { VrfLinkTransactionBuffer} from '../buffers/VrfLinkTransactionBuffer'; +import VrfLinkTransactionSchema from '../schemas/VrfLinkTransactionSchema'; +import {VerifiableTransaction} from './VerifiableTransaction'; + +import * as flatbuffers from 'flatbuffers'; + +export class VrfLinkTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, VrfLinkTransactionSchema); + } +} + +// tslint:disable-next-line:max-classes-per-file +export class Builder { + size: number; + maxFee: number[]; + version: number; + type: number; + deadline: number[]; + remoteAccountKey: string; + linkAction: number; + + constructor() { + this.maxFee = [0, 0]; + this.type = TransactionType.Vrf_Key_Link; + } + + addSize(size) { + this.size = size; + return this; + } + + addMaxFee(maxFee) { + this.maxFee = maxFee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addRemoteAccountKey(remoteAccountKey) { + this.remoteAccountKey = remoteAccountKey; + return this; + } + + addLinkAction(linkAction){ + this.linkAction = linkAction; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + // Create vectors + const signatureVector = VrfLinkTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = VrfLinkTransactionBuffer.createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = VrfLinkTransactionBuffer.createDeadlineVector(builder, this.deadline); + const feeVector = VrfLinkTransactionBuffer.createMaxFeeVector(builder, this.maxFee); + const remoteAccountKeyVector = VrfLinkTransactionBuffer.createRemoteAccountKeyVector(builder, convert.hexToUint8(this.remoteAccountKey)); + + VrfLinkTransactionBuffer.startVrfLinkTransactionBuffer(builder); + VrfLinkTransactionBuffer.addSize(builder, this.size); + VrfLinkTransactionBuffer.addSignature(builder, signatureVector); + VrfLinkTransactionBuffer.addSigner(builder, signerVector); + VrfLinkTransactionBuffer.addVersion(builder, this.version); + VrfLinkTransactionBuffer.addType(builder, this.type); + VrfLinkTransactionBuffer.addMaxFee(builder, feeVector); + VrfLinkTransactionBuffer.addDeadline(builder, deadlineVector); + VrfLinkTransactionBuffer.addRemoteAccountKey(builder, remoteAccountKeyVector); + VrfLinkTransactionBuffer.addLinkAction(builder, this.linkAction); + + // Calculate size + + const codedTxn = VrfLinkTransactionBuffer.endVrfLinkTransactionBuffer(builder); + builder.finish(codedTxn); + + const bytes = builder.asUint8Array(); + return new VrfLinkTransaction(bytes); + } +} diff --git a/src/infrastructure/infrastructure.ts b/src/infrastructure/infrastructure.ts index 22841612..1e31fbc3 100644 --- a/src/infrastructure/infrastructure.ts +++ b/src/infrastructure/infrastructure.ts @@ -17,7 +17,7 @@ export * from './AccountHttp'; export * from './BlockHttp'; -export * from './ChainConfigHttp'; +export * from './NetworkConfigHttp'; export * from './ChainHttp'; export * from './ChainUpgradeHttp'; export * from './DiagnosticHttp'; diff --git a/src/infrastructure/model/accountDTO.ts b/src/infrastructure/model/accountDTO.ts index 3689cdb8..6587d711 100644 --- a/src/infrastructure/model/accountDTO.ts +++ b/src/infrastructure/model/accountDTO.ts @@ -1,5 +1,5 @@ /* - * Copyright 2019 NEM + * Copyright 2024 ProximaX * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,23 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * Catapult REST API Reference - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 0.7.15 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ import { RequestFile } from '../api'; import { AccountLinkTypeEnum } from './accountLinkTypeEnum'; import { MosaicDTO } from './mosaicDTO'; +import { SupplementalPublicKeysDTO } from './supplementalPublicKeysDTO'; export class AccountDTO { + 'version'?: number; /** * The account unique address in hexadecimal. */ @@ -48,11 +39,21 @@ export class AccountDTO { /** * The public key of a linked account. The linked account can use|provide balance for delegated harvesting. */ - 'linkedAccountKey': string; + 'linkedAccountKey'?: string; + /** + * The public key of all linked accounts. The linked account can use|provide balance for remote delegated harvesting. + */ + 'supplementalPublicKeys'?: SupplementalPublicKeysDTO; + 'lockedMosaics'?:Array; static discriminator: string | undefined = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "version", + "baseName": "version", + "type": "number" + }, { "name": "address", "baseName": "address", @@ -87,7 +88,18 @@ export class AccountDTO { "name": "linkedAccountKey", "baseName": "linkedAccountKey", "type": "string" - } ]; + }, + { + "name": "supplementalPublicKeys", + "baseName": "supplementalPublicKeys", + "type": "SupplementalPublicKeysDTO" + }, + { + "name": "lockedMosaics", + "baseName": "lockedMosaics", + "type": "Array" + } + ]; static getAttributeTypeMap() { return AccountDTO.attributeTypeMap; diff --git a/src/infrastructure/model/models.ts b/src/infrastructure/model/models.ts index 9d6e6fc6..5ca07231 100644 --- a/src/infrastructure/model/models.ts +++ b/src/infrastructure/model/models.ts @@ -221,6 +221,8 @@ export * from './transferTransactionDTO'; export * from './upgradeDTO'; export * from './uploadInfoDTO'; export * from './verifiableEntityDTO'; +export * from './nodeUnlockedAccountDTO' +export * from './nodePeerInfoDTO' /* Storage DTO export @@ -472,6 +474,9 @@ import { ReplicatorDTO } from "./storage/replicatorDTO"; Storage DTO export end */ +import { NodeUnlockedAccountDTO } from './nodeUnlockedAccountDTO'; +import { NodePeerInfoDTO } from './nodePeerInfoDTO'; + /* tslint:disable:no-unused-variable */ let primitives = [ "string", @@ -713,7 +718,9 @@ let typeMap: {[index: string]: any} = { ReplicatorDTO, DownloadChannelInlineInfoMetaIdDTO, ReplicatorInlineMetaIdDTO, - DriveInfoInlineMetaIdDTO + DriveInfoInlineMetaIdDTO, + NodeUnlockedAccountDTO, + NodePeerInfoDTO } export class ObjectSerializer { diff --git a/src/infrastructure/model/nodePeerInfoDTO.ts b/src/infrastructure/model/nodePeerInfoDTO.ts new file mode 100644 index 00000000..1d30edef --- /dev/null +++ b/src/infrastructure/model/nodePeerInfoDTO.ts @@ -0,0 +1,70 @@ +/* + * Copyright 2024 ProximaX + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class NodePeerInfoDTO { + publicKey: string; + port: number; + networkIdentifier: number; + version: number; + roles: number; + host: string; + friendlyName: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "publicKey", + "baseName": "publicKey", + "type": "string" + }, + { + "name": "port", + "baseName": "port", + "type": "number" + }, + { + "name": "networkIdentifier", + "baseName": "networkIdentifier", + "type": "number" + }, + { + "name": "version", + "baseName": "version", + "type": "number" + }, + { + "name": "roles", + "baseName": "roles", + "type": "number" + }, + { + "name": "host", + "baseName": "host", + "type": "string" + }, + { + "name": "friendlyName", + "baseName": "friendlyName", + "type": "string" + } + ]; + + static getAttributeTypeMap() { + return NodePeerInfoDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/nodeUnlockedAccountDTO.ts b/src/infrastructure/model/nodeUnlockedAccountDTO.ts new file mode 100644 index 00000000..f5ffe0fc --- /dev/null +++ b/src/infrastructure/model/nodeUnlockedAccountDTO.ts @@ -0,0 +1,34 @@ +/* + * Copyright 2024 ProximaX + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { RequestFile } from '../api'; + +export class NodeUnlockedAccountDTO { + 'PublicKey': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "PublicKey", + "baseName": "PublicKey", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return NodeUnlockedAccountDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/supplementalPublicKeysDTO.ts b/src/infrastructure/model/supplementalPublicKeysDTO.ts new file mode 100644 index 00000000..d332974e --- /dev/null +++ b/src/infrastructure/model/supplementalPublicKeysDTO.ts @@ -0,0 +1,48 @@ +/* + * Copyright 2024 ProximaX + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { RequestFile } from '../api'; + +export class SupplementalPublicKeysDTO { + + 'linked'?: string; + 'node'?: string; + 'vrf'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "linked", + "baseName": "linked", + "type": "string" + }, + { + "name": "node", + "baseName": "node", + "type": "string" + }, + { + "name": "vrf", + "baseName": "vrf", + "type": "string" + }]; + + static getAttributeTypeMap() { + return SupplementalPublicKeysDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/transactionStatusTypeEnum.ts b/src/infrastructure/model/transactionStatusTypeEnum.ts index 259a0ca9..570af6b9 100644 --- a/src/infrastructure/model/transactionStatusTypeEnum.ts +++ b/src/infrastructure/model/transactionStatusTypeEnum.ts @@ -144,9 +144,9 @@ export enum TransactionStatusTypeEnum { FailureTransferTooManyMosaics = 'Failure_Transfer_Too_Many_Mosaics', FailureTransferZeroAmount = 'Failure_Transfer_Zero_Amount', FailureNetworkConfigInvalidSigner = 'Failure_NetworkConfig_Invalid_Signer', - FailureNetworkConfigBlockChainConfigTooLarge = 'Failure_NetworkConfig_BlockChain_Config_Too_Large', + FailureNetworkConfigBlockNetworkConfigTooLarge = 'Failure_NetworkConfig_BlockChain_Config_Too_Large', FailureNetworkConfigConfigRedundant = 'Failure_NetworkConfig_Config_Redundant', - FailureNetworkConfigBlockChainConfigMalformed = 'Failure_NetworkConfig_BlockChain_Config_Malformed', + FailureNetworkConfigBlockNetworkConfigMalformed = 'Failure_NetworkConfig_BlockChain_Config_Malformed', FailureNetworkConfigPluginConfigMalformed = 'Failure_NetworkConfig_Plugin_Config_Malformed', FailureNetworkConfigSupportedEntityVersionsConfigTooLarge = 'Failure_NetworkConfig_SupportedEntityVersions_Config_Too_Large', FailureNetworkConfigSupportedEntityVersionsConfigMalformed = 'Failure_NetworkConfig_SupportedEntityVersions_Config_Malformed', diff --git a/src/infrastructure/schemas/AccountAddressRestrictionTransactionSchema.ts b/src/infrastructure/schemas/AccountAddressRestrictionTransactionSchema.ts new file mode 100644 index 00000000..f6889bbf --- /dev/null +++ b/src/infrastructure/schemas/AccountAddressRestrictionTransactionSchema.ts @@ -0,0 +1,34 @@ +// Copyright 2024 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { array, Schema, table, tableArray, TypeSize, ubyte, uint, ushort, short } from './Schema'; + +/** + * @module schema/AccountAddressRestrictionTransactionSchema + */ + +/** + * Account Address Restriction transaction schema + * @const {module:schema/Schema} + */ +const schema = new Schema([ + uint('size'), + array('signature'), + array('signer'), + uint('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + ushort('restrictionFlags'), + ubyte('restrictionAdditionsCount'), + ubyte('restrictionDeletionsCount'), + uint('accountRestrictionTransactionBody_Reserved1'), + tableArray('restrictionAdditions', [ + array('address') + ]), + tableArray('restrictionDeletions', [ + array('address') + ]) +]); +export default schema; \ No newline at end of file diff --git a/src/infrastructure/schemas/AccountMosaicRestrictionTransactionSchema.ts b/src/infrastructure/schemas/AccountMosaicRestrictionTransactionSchema.ts new file mode 100644 index 00000000..c390874f --- /dev/null +++ b/src/infrastructure/schemas/AccountMosaicRestrictionTransactionSchema.ts @@ -0,0 +1,34 @@ +// Copyright 2024 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { array, Schema, table, tableArray, TypeSize, ubyte, uint, ushort, short } from './Schema'; + +/** + * @module schema/AccountMosaicRestrictionTransactionSchema + */ + +/** + * Account Mosaic Restriction transaction schema + * @const {module:schema/Schema} + */ +const schema = new Schema([ + uint('size'), + array('signature'), + array('signer'), + uint('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + ushort('restrictionFlags'), + ubyte('restrictionAdditionsCount'), + ubyte('restrictionDeletionsCount'), + uint('accountRestrictionTransactionBody_Reserved1'), + tableArray('restrictionAdditions', [ + array('id', TypeSize.INT) + ]), + tableArray('restrictionDeletions', [ + array('id', TypeSize.INT) + ]) +]); +export default schema; \ No newline at end of file diff --git a/src/infrastructure/schemas/AccountOperationRestrictionTransactionSchema.ts b/src/infrastructure/schemas/AccountOperationRestrictionTransactionSchema.ts new file mode 100644 index 00000000..0f5466ea --- /dev/null +++ b/src/infrastructure/schemas/AccountOperationRestrictionTransactionSchema.ts @@ -0,0 +1,30 @@ +// Copyright 2024 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { array, Schema, table, tableArray, TypeSize, ubyte, uint, ushort, short } from './Schema'; + +/** + * @module schema/AccountOperationRestrictionTransactionSchema + */ + +/** + * Account Operation Restriction transaction schema + * @const {module:schema/Schema} + */ +const schema = new Schema([ + uint('size'), + array('signature'), + array('signer'), + uint('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + ushort('restrictionFlags'), + ubyte('restrictionAdditionsCount'), + ubyte('restrictionDeletionsCount'), + uint('accountRestrictionTransactionBody_Reserved1'), + array('restrictionAdditions', TypeSize.SHORT), + array('restrictionDeletions', TypeSize.SHORT) +]); +export default schema; \ No newline at end of file diff --git a/src/infrastructure/schemas/AccountV2UpgradeTransactionSchema.ts b/src/infrastructure/schemas/AccountV2UpgradeTransactionSchema.ts new file mode 100644 index 00000000..3c59f495 --- /dev/null +++ b/src/infrastructure/schemas/AccountV2UpgradeTransactionSchema.ts @@ -0,0 +1,25 @@ +// Copyright 2024 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { array, Schema, table, tableArray, TypeSize, ubyte, uint, ushort, short } from './Schema'; + +/** + * @module schema/AccountV2UpgradeTransactionSchema + */ + +/** + * Account V2 upgrade transaction schema + * @const {module:schema/Schema} + */ +const schema = new Schema([ + uint('size'), + array('signature'), + array('signer'), + uint('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + array('newaccountpublickey') +]); +export default schema; diff --git a/src/infrastructure/schemas/LockFundCancelUnlockTransactionSchema.ts b/src/infrastructure/schemas/LockFundCancelUnlockTransactionSchema.ts new file mode 100644 index 00000000..7e15744e --- /dev/null +++ b/src/infrastructure/schemas/LockFundCancelUnlockTransactionSchema.ts @@ -0,0 +1,25 @@ +// Copyright 2024 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { array, Schema, table, tableArray, TypeSize, ubyte, uint, ushort, short } from './Schema'; + +/** + * @module schema/LockFundCancelUnlockTransactionSchema + */ + +/** + * Lock fund cancel unlock transaction schema + * @const {module:schema/Schema} + */ +const schema = new Schema([ + uint('size'), + array('signature'), + array('signer'), + uint('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + array('targetHeight', TypeSize.INT) +]); +export default schema; diff --git a/src/infrastructure/schemas/LockFundTransferTransactionSchema.ts b/src/infrastructure/schemas/LockFundTransferTransactionSchema.ts new file mode 100644 index 00000000..435173de --- /dev/null +++ b/src/infrastructure/schemas/LockFundTransferTransactionSchema.ts @@ -0,0 +1,31 @@ +// Copyright 2024 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { array, Schema, table, tableArray, TypeSize, ubyte, uint, ushort, short } from './Schema'; + +/** + * @module schema/LockFundTransferTransactionSchema + */ + +/** + * Lock fund transfer transaction schema + * @const {module:schema/Schema} + */ +const schema = new Schema([ + uint('size'), + array('signature'), + array('signer'), + uint('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + array('duration', TypeSize.INT), + ubyte('action'), + ubyte('mosaicsCount'), + tableArray('mosaics', [ + array('id', TypeSize.INT), + array('amount', TypeSize.INT) + ]) +]); +export default schema; diff --git a/src/infrastructure/schemas/MosaicAddressRestrictionTransactionSchema.ts b/src/infrastructure/schemas/MosaicAddressRestrictionTransactionSchema.ts new file mode 100644 index 00000000..e1a24b4d --- /dev/null +++ b/src/infrastructure/schemas/MosaicAddressRestrictionTransactionSchema.ts @@ -0,0 +1,29 @@ +// Copyright 2024 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { array, Schema, table, tableArray, TypeSize, ubyte, uint, ushort, short } from './Schema'; + +/** + * @module schema/MosaicAddressRestrictionTransactionSchema + */ + +/** + * Mosaic Address Restriction transaction schema + * @const {module:schema/Schema} + */ +const schema = new Schema([ + uint('size'), + array('signature'), + array('signer'), + uint('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + array('mosaicId', TypeSize.INT), + array('restrictionKey', TypeSize.INT), + array('previousRestrictionValue', TypeSize.INT), + array('newRestrictionValue', TypeSize.INT), + array('targetAddress'), +]); +export default schema; \ No newline at end of file diff --git a/src/infrastructure/schemas/MosaicGlobalRestrictionTransactionSchema.ts b/src/infrastructure/schemas/MosaicGlobalRestrictionTransactionSchema.ts new file mode 100644 index 00000000..da96063d --- /dev/null +++ b/src/infrastructure/schemas/MosaicGlobalRestrictionTransactionSchema.ts @@ -0,0 +1,31 @@ +// Copyright 2024 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { array, Schema, table, tableArray, TypeSize, ubyte, uint, ushort, short } from './Schema'; + +/** + * @module schema/MosaicGlobalRestrictionTransactionSchema + */ + +/** + * Mosaic Global Restriction transaction schema + * @const {module:schema/Schema} + */ +const schema = new Schema([ + uint('size'), + array('signature'), + array('signer'), + uint('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + array('mosaicId', TypeSize.INT), + array('referenceMosaicId', TypeSize.INT), + array('restrictionKey', TypeSize.INT), + array('previousRestrictionValue', TypeSize.INT), + array('newRestrictionValue', TypeSize.INT), + ubyte('previousRestrictionType'), + ubyte('newRestrictionType') +]); +export default schema; \ No newline at end of file diff --git a/src/infrastructure/schemas/NetworkConfigAbsoluteHeightTransactionSchema.ts b/src/infrastructure/schemas/NetworkConfigAbsoluteHeightTransactionSchema.ts new file mode 100644 index 00000000..ca43bc1e --- /dev/null +++ b/src/infrastructure/schemas/NetworkConfigAbsoluteHeightTransactionSchema.ts @@ -0,0 +1,39 @@ +// Copyright 2019 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { + array, + Schema, + table, + tableArray, + TypeSize, + ubyte, + uint, + ushort +} from './Schema'; + +/** + * @module schema/NetworkConfigAbsoluteHeightTransactionSchema + */ + +/** + * Chain config absolute height transaction schema + * @const {module:schema/Schema} + */ +const schema = new Schema([ + uint('size'), + array('signature'), + array('signer'), + uint('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + array('applyHeight', TypeSize.INT), + ushort('networkConfigSize'), + ushort('supportedEntityVersionsSize'), + array('networkConfig'), + array('supportedEntityVersions'), +]); + +export default schema; diff --git a/src/infrastructure/schemas/ChainConfigTransactionSchema.ts b/src/infrastructure/schemas/NetworkConfigTransactionSchema.ts similarity index 94% rename from src/infrastructure/schemas/ChainConfigTransactionSchema.ts rename to src/infrastructure/schemas/NetworkConfigTransactionSchema.ts index 09520d37..c6518ab5 100644 --- a/src/infrastructure/schemas/ChainConfigTransactionSchema.ts +++ b/src/infrastructure/schemas/NetworkConfigTransactionSchema.ts @@ -14,7 +14,7 @@ import { } from './Schema'; /** - * @module schema/ChainConfigTransactionSchema + * @module schema/NetworkConfigTransactionSchema */ /** diff --git a/src/infrastructure/schemas/NodeLinkTransactionSchema.ts b/src/infrastructure/schemas/NodeLinkTransactionSchema.ts new file mode 100644 index 00000000..727b4718 --- /dev/null +++ b/src/infrastructure/schemas/NodeLinkTransactionSchema.ts @@ -0,0 +1,26 @@ +// Copyright 2024 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { array, Schema, table, tableArray, TypeSize, ubyte, uint, ushort, short } from './Schema'; + +/** + * @module schema/NodeLinkTransactionSchema + */ + +/** + * Node Link transaction schema + * @const {module:schema/Schema} + */ +const schema = new Schema([ + uint('size'), + array('signature'), + array('signer'), + uint('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + array('remoteAccountKey'), + ubyte('linkAction') +]); +export default schema; diff --git a/src/infrastructure/schemas/VrfLinkTransactionSchema.ts b/src/infrastructure/schemas/VrfLinkTransactionSchema.ts new file mode 100644 index 00000000..b7e3e472 --- /dev/null +++ b/src/infrastructure/schemas/VrfLinkTransactionSchema.ts @@ -0,0 +1,26 @@ +// Copyright 2024 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { array, Schema, table, tableArray, TypeSize, ubyte, uint, ushort, short } from './Schema'; + +/** + * @module schema/VrfLinkTransactionSchema + */ + +/** + * Vrf Link transaction schema + * @const {module:schema/Schema} + */ +const schema = new Schema([ + uint('size'), + array('signature'), + array('signer'), + uint('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + array('remoteAccountKey'), + ubyte('linkAction') +]); +export default schema; diff --git a/src/infrastructure/transaction/CreateTransactionFromDTO.ts b/src/infrastructure/transaction/CreateTransactionFromDTO.ts index f8072491..3f741a60 100644 --- a/src/infrastructure/transaction/CreateTransactionFromDTO.ts +++ b/src/infrastructure/transaction/CreateTransactionFromDTO.ts @@ -26,21 +26,21 @@ import {MosaicProperties} from '../../model/mosaic/MosaicProperties'; import { MosaicPropertyType } from '../../model/mosaic/MosaicPropertyType'; import {NamespaceId} from '../../model/namespace/NamespaceId'; import { AccountLinkTransaction } from '../../model/transaction/AccountLinkTransaction'; -import {AccountRestrictionModification} from '../../model/transaction/AccountRestrictionModification'; +import {AccountRestrictionModification} from '../../model/transaction/deprecated/AccountRestrictionModification'; import {AddressAliasTransaction} from '../../model/transaction/AddressAliasTransaction'; import {AggregateTransaction} from '../../model/transaction/AggregateTransaction'; import {AggregateTransactionCosignature} from '../../model/transaction/AggregateTransactionCosignature'; import {AggregateTransactionInfo} from '../../model/transaction/AggregateTransactionInfo'; -import {ChainConfigTransaction} from '../../model/transaction/ChainConfigTransaction'; +import {NetworkConfigTransaction} from '../../model/transaction/NetworkConfigTransaction'; import {ChainUpgradeTransaction} from '../../model/transaction/ChainUpgradeTransaction'; import {Deadline} from '../../model/transaction/Deadline'; import { MessageType } from '../../model/transaction/MessageType'; import { EncryptedMessage } from '../../model/transaction/EncryptedMessage'; import { HexadecimalMessage } from '../../model/transaction/HexadecimalMessage'; import {HashLockTransaction} from '../../model/transaction/HashLockTransaction'; -import {AccountAddressRestrictionModificationTransaction} from '../../model/transaction/AccountAddressRestrictionModificationTransaction'; -import {AccountOperationRestrictionModificationTransaction} from '../../model/transaction/AccountOperationRestrictionModificationTransaction'; -import {AccountMosaicRestrictionModificationTransaction} from '../../model/transaction/AccountMosaicRestrictionModificationTransaction'; +import {AccountAddressRestrictionModificationTransaction} from '../../model/transaction/deprecated/AccountAddressRestrictionModificationTransaction'; +import {AccountOperationRestrictionModificationTransaction} from '../../model/transaction/deprecated/AccountOperationRestrictionModificationTransaction'; +import {AccountMosaicRestrictionModificationTransaction} from '../../model/transaction/deprecated/AccountMosaicRestrictionModificationTransaction'; import {ModifyMultisigAccountTransaction} from '../../model/transaction/ModifyMultisigAccountTransaction'; import {MosaicAliasTransaction} from '../../model/transaction/MosaicAliasTransaction'; import {MosaicDefinitionTransaction} from '../../model/transaction/MosaicDefinitionTransaction'; @@ -58,7 +58,7 @@ import {TransactionInfo} from '../../model/transaction/TransactionInfo'; import {TransactionType} from '../../model/transaction/TransactionType'; import {TransferTransaction} from '../../model/transaction/TransferTransaction'; import {UInt64} from '../../model/UInt64'; -import { ModifyMetadataTransaction, MetadataModification } from '../../model/transaction/ModifyMetadataTransaction'; +import { ModifyMetadataTransaction, MetadataModification } from '../../model/transaction/deprecated/ModifyMetadataTransaction'; import { MetadataType as oldMetadataType } from '../../model/metadata/oldMetadataType'; import { AddExchangeOfferTransaction } from '../../model/transaction/AddExchangeOfferTransaction'; import { AddExchangeOffer } from '../../model/transaction/AddExchangeOffer'; @@ -598,7 +598,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, isA ); txn = chainUpgradeTxn; } else if (transactionDTO.type === TransactionType.CHAIN_CONFIGURE) { - const chainConfigTxn = new ChainConfigTransaction( + const NetworkConfigTxn = new NetworkConfigTransaction( networkType, transactionTypeVersion, isAggregatedInfo.isEmbedded? Deadline.createEmpty() : Deadline.createFromDTO(transactionDTO.deadline), @@ -611,7 +611,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, isA networkType, signerVersion) : undefined, transactionInfo, ); - txn = chainConfigTxn; + txn = NetworkConfigTxn; } else if (transactionDTO.type === TransactionType.ADD_EXCHANGE_OFFER) { const addExchangeOfferTxn = new AddExchangeOfferTransaction( networkType, diff --git a/src/infrastructure/transaction/CreateTransactionFromPayload.ts b/src/infrastructure/transaction/CreateTransactionFromPayload.ts index f083751d..471ee4d8 100644 --- a/src/infrastructure/transaction/CreateTransactionFromPayload.ts +++ b/src/infrastructure/transaction/CreateTransactionFromPayload.ts @@ -27,7 +27,7 @@ import { MosaicNonce } from '../../model/mosaic/MosaicNonce'; import { MosaicProperties, PropertyBit } from '../../model/mosaic/MosaicProperties'; import { NamespaceId } from '../../model/namespace/NamespaceId'; import { NamespaceType } from '../../model/namespace/NamespaceType'; -import { AccountRestrictionModification } from '../../model/transaction/AccountRestrictionModification'; +import { AccountRestrictionModification } from '../../model/transaction/deprecated/AccountRestrictionModification'; import { AggregateTransactionCosignature } from '../../model/transaction/AggregateTransactionCosignature'; import { AggregateV2TransactionCosignature } from '../../model/transaction/AggregateV2TransactionCosignature'; import { Deadline } from '../../model/transaction/Deadline'; @@ -522,7 +522,7 @@ const CreateTransaction = (type: number, transactionData: string, txnVersion: Tr const supportedEntityVersionsLength = extractNumberFromHexReverse(transactionData.substring(20, 24)); const networkConfig = transactionData.substring(24, 24 + networkConfigLength*2); const supportedEntityVersions = transactionData.substring(24 + networkConfigLength*2, 24 + networkConfigLength*2 + supportedEntityVersionsLength*2); - return factory.chainConfig() + return factory.networkConfig() .applyHeightDelta(UInt64.fromHex(reverseHexString(applyHeightDelta))) .networkConfig(decodeHexUtf8(networkConfig)) .supportedEntityVersions(decodeHexUtf8(supportedEntityVersions)) diff --git a/src/model/account/Account.ts b/src/model/account/Account.ts index 85a3f780..3904d3d2 100644 --- a/src/model/account/Account.ts +++ b/src/model/account/Account.ts @@ -162,7 +162,7 @@ export class Account { * @param networkType - Network type * @param version - Account version */ - public static generateNewAccount(networkType: NetworkType, version: number = 1): Account { + public static generateNewAccount(networkType: NetworkType, version: number = 2): Account { // Create random bytes const randomBytesArray = Crypto.randomBytes(32); // Hash random bytes with entropy seed diff --git a/src/model/account/AccountInfo.ts b/src/model/account/AccountInfo.ts index 95a24be2..f913883d 100644 --- a/src/model/account/AccountInfo.ts +++ b/src/model/account/AccountInfo.ts @@ -20,6 +20,7 @@ import {UInt64} from '../UInt64'; import {AccountType} from './AccountType'; import {Address} from './Address'; import {PublicAccount} from './PublicAccount'; +import { SupplementalPublicKeys } from './SupplementalPublicKeys'; /** * The account info structure describes basic information for an account. @@ -54,14 +55,23 @@ export class AccountInfo { * Account type */ public readonly accountType: AccountType, + + /** + * Mosaics hold by the account. + */ + public readonly mosaics: Mosaic[], + + public readonly lockedMosaics: Mosaic[], /** * Linked account key */ - public readonly linkedAccountKey: string, + public readonly linkedAccountKey?: string, + /** - * Mosaics hold by the account. + * supplemental PublicKeys */ - public readonly mosaics: Mosaic[], + public readonly supplementalPublicKeys?: SupplementalPublicKeys, + /** * account version */ diff --git a/src/model/account/AccountLink.ts b/src/model/account/AccountLink.ts new file mode 100644 index 00000000..8de3f951 --- /dev/null +++ b/src/model/account/AccountLink.ts @@ -0,0 +1,4 @@ +export enum AccountLinkAction{ + Link, + Unlink +} \ No newline at end of file diff --git a/src/model/account/SupplementalPublicKeys.ts b/src/model/account/SupplementalPublicKeys.ts new file mode 100644 index 00000000..85482cd4 --- /dev/null +++ b/src/model/account/SupplementalPublicKeys.ts @@ -0,0 +1,23 @@ +import { NetworkType } from '../model'; +import {PublicAccount} from './PublicAccount'; + +export class SupplementalPublicKeys{ + + constructor( + public readonly linked?: PublicAccount, + public readonly node?: PublicAccount, + public readonly vrf?: PublicAccount){ + } + + public static create(params: { + linked: string, + node: string, + vrf: string + }, networkType: NetworkType) { + return new SupplementalPublicKeys( + params.linked ? PublicAccount.createFromPublicKey(params.linked, networkType): undefined, + params.node ? PublicAccount.createFromPublicKey(params.node, networkType): undefined, + params.vrf ? PublicAccount.createFromPublicKey(params.vrf, networkType): undefined, + ); + } +} \ No newline at end of file diff --git a/src/model/config/ChainConfig.ts b/src/model/config/NetworkConfig.ts similarity index 92% rename from src/model/config/ChainConfig.ts rename to src/model/config/NetworkConfig.ts index d4943ae8..0605d8df 100644 --- a/src/model/config/ChainConfig.ts +++ b/src/model/config/NetworkConfig.ts @@ -8,7 +8,7 @@ import { UInt64 } from "../UInt64"; /** * The config structure stores a chain configuration as returned from http configRoutesApi. */ -export class ChainConfig { +export class NetworkConfig { constructor( public readonly height: UInt64, public readonly networkConfig: string, @@ -18,7 +18,7 @@ export class ChainConfig { } public static createFromDTO(configDTO: ConfigDTO) { - return new ChainConfig( + return new NetworkConfig( new UInt64(configDTO.height), configDTO.networkConfig, configDTO.supportedEntityVersions diff --git a/src/model/model.ts b/src/model/model.ts index e6716225..7bf8f79a 100644 --- a/src/model/model.ts +++ b/src/model/model.ts @@ -44,7 +44,7 @@ export * from './blockchain/MerkleProofInfoPayload'; export * from './blockchain/NetworkType'; // Config -export * from './config/ChainConfig'; +export * from './config/NetworkConfig'; // Diagnostic export * from './diagnostic/ServerInfo'; @@ -134,13 +134,13 @@ export * from './receipt/TransactionStatement'; export * from './richlist/RichlistEntry'; // Transaction -export * from './transaction/AccountAddressRestrictionModificationTransaction'; export * from './transaction/AccountMetadataTransaction'; export * from './transaction/AccountLinkTransaction'; -export * from './transaction/AccountMosaicRestrictionModificationTransaction'; -export * from './transaction/AccountOperationRestrictionModificationTransaction'; -export * from './transaction/AccountRestrictionModification'; -export * from './transaction/AccountRestrictionTransaction'; +export * from './transaction/deprecated/AccountAddressRestrictionModificationTransaction'; +export * from './transaction/deprecated/AccountMosaicRestrictionModificationTransaction'; +export * from './transaction/deprecated/AccountOperationRestrictionModificationTransaction'; +export * from './transaction/deprecated/AccountRestrictionModification'; +export * from './transaction/deprecated/AccountRestrictionTransaction'; export * from './transaction/AddExchangeOffer'; export * from './transaction/AddExchangeOfferTransaction'; export * from './transaction/AddressAliasTransaction'; @@ -148,7 +148,7 @@ export * from './transaction/AggregateTransaction'; export * from './transaction/AggregateTransactionCosignature'; export * from './transaction/AggregateTransactionInfo'; export * from './transaction/AliasTransaction'; -export * from './transaction/ChainConfigTransaction'; +export * from './transaction/NetworkConfigTransaction'; export * from './transaction/ChainUpgradeTransaction'; export * from './transaction/CosignatureSignedTransaction'; export * from './transaction/CosignatureTransaction'; @@ -225,6 +225,24 @@ export * from './transaction/storage/NewStoragePaymentTransaction'; export * from './transaction/storage/NewVerificationPaymentTransaction'; export * from './transaction/storage/ReplicatorOffboardingTransaction'; +// symbol merge transaction +export * from './transaction/AccountAddressRestrictionTransaction'; +export * from './transaction/AccountMosaicRestrictionTransaction'; +export * from './transaction/AccountOperationRestrictionTransaction'; +export * from './transaction/AccountV2UpgradeTransaction'; +export * from './transaction/LockFundTransferTransaction'; +export * from './transaction/LockFundCancelUnlockTransaction'; +export * from './transaction/MosaicAddressRestrictionTransaction'; +export * from './transaction/MosaicGlobalRestrictionTransaction'; +export * from './transaction/NetworkConfigAbsoluteHeightTransaction'; +export * from './transaction/NodeLinkTransaction'; +export * from './transaction/VrfLinkTransaction'; + +export * from './mosaic/MosaicRestriction'; +export * from './transaction/LockFund'; +export * from './account/AccountLink'; +export * from './account/SupplementalPublicKeys'; + // Liquidity Provider export * from './liquidity/LiquidityProvider'; export * from './liquidity/LiquidityProviderSearch'; diff --git a/src/model/mosaic/MosaicRestriction.ts b/src/model/mosaic/MosaicRestriction.ts new file mode 100644 index 00000000..f7419f5b --- /dev/null +++ b/src/model/mosaic/MosaicRestriction.ts @@ -0,0 +1,14 @@ +export enum MosaicRestrictionType{ + NONE, + EQ, + NE, + LT, + LE, + GT, + GE +} + +export enum MosaicRestrictionEntryType{ + ADDRESS, + GLOBAL +} \ No newline at end of file diff --git a/src/model/node/NodePeers.ts b/src/model/node/NodePeers.ts new file mode 100644 index 00000000..deddc4f4 --- /dev/null +++ b/src/model/node/NodePeers.ts @@ -0,0 +1,43 @@ +/* + * Copyright 2024 ProximaX + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * The node peers of a node. + */ +export class NodePeers { + + /** + * @param peersInfo + */ + constructor(/** + * The peers info + */ + public readonly peersInfo: PeerInfo[]){} +} + +export class PeerInfo{ + + constructor( + public readonly publicKey: string, + public readonly port: number, + public readonly networkIdentifier: number, + public readonly version: number, + public readonly roles: number, + public readonly host: string, + public readonly friendlyName: string + ){ + + } +} \ No newline at end of file diff --git a/src/model/node/NodeUnlockedAccount.ts b/src/model/node/NodeUnlockedAccount.ts new file mode 100644 index 00000000..7a1dfd58 --- /dev/null +++ b/src/model/node/NodeUnlockedAccount.ts @@ -0,0 +1,29 @@ +/* + * Copyright 2024 ProximaX + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { PublicAccount } from '../account/PublicAccount'; +/** + * The unlocked accounts form the node + */ +export class NodeUnlockedAccount { + + /** + * @param unlockedAccounts + */ + constructor(/** + * The unlocked accounts + */ + public readonly unlockedAccounts: PublicAccount[]){} +} diff --git a/src/model/transaction/AccountAddressRestrictionTransaction.ts b/src/model/transaction/AccountAddressRestrictionTransaction.ts new file mode 100644 index 00000000..e393a244 --- /dev/null +++ b/src/model/transaction/AccountAddressRestrictionTransaction.ts @@ -0,0 +1,195 @@ +/* + * Copyright 2024 ProximaX + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Builder } from '../../infrastructure/builders/AccountAddressRestrictionTransaction'; +import {VerifiableTransaction} from '../../infrastructure/builders/VerifiableTransaction'; +import { PublicAccount } from '../account/PublicAccount'; +import { RestrictionType } from '../account/RestrictionType'; +import { NetworkType } from '../blockchain/NetworkType'; +import { UInt64 } from '../UInt64'; +import { Deadline } from './Deadline'; +import { Transaction, TransactionBuilder } from './Transaction'; +import { TransactionInfo } from './TransactionInfo'; +import { TransactionType } from './TransactionType'; +import { TransactionTypeVersion } from './TransactionTypeVersion'; +import { calculateFee } from './FeeCalculationStrategy'; +import { Address } from "../account/Address"; + +export class AccountAddressRestrictionTransaction extends Transaction { + + /** + * Create a modify account address restriction transaction object + * @param deadline - The deadline to include the transaction. + * @param restrictionFlags + * @param restrictionAdditions + * @param restrictionDeletions + * @param networkType - The network type. + * @param maxFee - (Optional) Max fee defined by the sender + * @returns {AccountAddressRestrictionTransaction} + */ + public static create(deadline: Deadline, + restrictionFlags: number, + restrictionAdditions: Address[], + restrictionDeletions: Address[], + networkType: NetworkType, + maxFee?: UInt64): AccountAddressRestrictionTransaction { + + if(restrictionFlags > 0xFFFF){ + throw new Error("restrictionFlags short be uint16 number"); + } + + return new AccountAddressRestrictionTransactionBuilder() + .networkType(networkType) + .deadline(deadline) + .restrictionFlags(restrictionFlags) + .restrictionAdditions(restrictionAdditions) + .restrictionDeletions(restrictionDeletions) + .maxFee(maxFee) + .build(); + } + + /** + * @param networkType + * @param version + * @param deadline + * @param maxFee + * @param restrictionFlags + * @param restrictionAdditions + * @param restrictionDeletions + * @param signature + * @param signer + * @param transactionInfo + */ + constructor(networkType: NetworkType, + version: number, + deadline: Deadline, + maxFee: UInt64, + public readonly restrictionFlags: number, + public readonly restrictionAdditions: Address[], + public readonly restrictionDeletions: Address[], + signature?: string, + signer?: PublicAccount, + transactionInfo?: TransactionInfo) { + super(TransactionType.Account_Address_Restriction, + networkType, version, deadline, maxFee, signature, signer, transactionInfo); + } + + /** + * @override Transaction.size() + * @description get the byte size of a AccountAddressRestrictionTransaction + * @returns {number} + * @memberof AccountAddressRestrictionTransaction + */ + public get size(): number { + return AccountAddressRestrictionTransaction.calculateSize(this.restrictionAdditions.length, this.restrictionDeletions.length); + } + + public static calculateSize(addCount: number, deleteCount: number): number { + const byteSize = Transaction.getHeaderSize(); + + const restrictionFlags = 2; + const byteAddCount = 1; + const byteDeleteCount = 1; + + const reservedBodyByte = 1; + + const additionBytes = 25 * addCount; + const deletionBytes = 25 * deleteCount; + + return byteSize + restrictionFlags + + byteAddCount + byteDeleteCount + + reservedBodyByte + + additionBytes + deletionBytes; + } + + /** + * @override Transaction.toJSON() + * @description Serialize a transaction object - add own fields to the result of Transaction.toJSON() + * @return {Object} + * @memberof AccountAddressRestrictionTransaction + */ + public toJSON() { + const parent = super.toJSON(); + return { + ...parent, + transaction: { + ...parent.transaction, + restrictionFlags: this.restrictionFlags, + restrictionAdditions: this.restrictionAdditions.map(add=>{ + return add.plain() + }), + restrictionDeletions: this.restrictionDeletions.map(del=>{ + return del.plain() + }) + } + } + } + + /** + * @internal + * @returns {VerifiableTransaction} + */ + protected buildTransaction(): VerifiableTransaction { + return new Builder() + .addSize(this.size) + .addDeadline(this.deadline.toDTO()) + .addMaxFee(this.maxFee.toDTO()) + .addVersion(this.versionToDTO()) + .addRestrictionFlags(this.restrictionFlags) + .addRestrictionAdditions(this.restrictionAdditions.map(x=> x.plain())) + .addRestrictionDeletions(this.restrictionDeletions.map(x=> x.plain())) + .build(); + } +} + +export class AccountAddressRestrictionTransactionBuilder extends TransactionBuilder { + private _restrictionFlags: number; + private _restrictionAdditions: Address[]; + private _restrictionDeletions: Address[]; + + public restrictionFlags(restrictionFlags: number) { + if (restrictionFlags > 0xFFFF) { + throw new Error('restrictionFlags must be a uint16 number'); + }; + this._restrictionFlags = restrictionFlags; + return this; + } + + public restrictionAdditions(restrictionAdditions: Address[]) { + this._restrictionAdditions = restrictionAdditions; + return this; + } + + public restrictionDeletions(restrictionDeletions: Address[]) { + this._restrictionDeletions = restrictionDeletions; + return this; + } + + public build(): AccountAddressRestrictionTransaction { + return new AccountAddressRestrictionTransaction( + this._networkType, + this._version || TransactionTypeVersion.Account_Address_Restriction, + this._deadline ? this._deadline : this._createNewDeadlineFn(), + this._maxFee ? this._maxFee : calculateFee(AccountAddressRestrictionTransaction.calculateSize(this._restrictionAdditions.length, this._restrictionDeletions.length), this._feeCalculationStrategy), + this._restrictionFlags, + this._restrictionAdditions, + this._restrictionDeletions, + this._signature, + this._signer, + this._transactionInfo + ); + } +} diff --git a/src/model/transaction/AccountMosaicRestrictionTransaction.ts b/src/model/transaction/AccountMosaicRestrictionTransaction.ts new file mode 100644 index 00000000..c2e99891 --- /dev/null +++ b/src/model/transaction/AccountMosaicRestrictionTransaction.ts @@ -0,0 +1,195 @@ +/* + * Copyright 2024 ProximaX + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Builder } from '../../infrastructure/builders/AccountMosaicRestrictionTransaction'; +import {VerifiableTransaction} from '../../infrastructure/builders/VerifiableTransaction'; +import { PublicAccount } from '../account/PublicAccount'; +import { RestrictionType } from '../account/RestrictionType'; +import { NetworkType } from '../blockchain/NetworkType'; +import { UInt64 } from '../UInt64'; +import { Deadline } from './Deadline'; +import { Transaction, TransactionBuilder } from './Transaction'; +import { TransactionInfo } from './TransactionInfo'; +import { TransactionType } from './TransactionType'; +import { TransactionTypeVersion } from './TransactionTypeVersion'; +import { calculateFee } from './FeeCalculationStrategy'; +import { MosaicId } from "../mosaic/MosaicId"; + +export class AccountMosaicRestrictionTransaction extends Transaction { + + /** + * Create a modify account address restriction transaction object + * @param deadline - The deadline to include the transaction. + * @param restrictionFlags + * @param restrictionAdditions + * @param restrictionDeletions + * @param networkType - The network type. + * @param maxFee - (Optional) Max fee defined by the sender + * @returns {AccountMosaicRestrictionTransaction} + */ + public static create(deadline: Deadline, + restrictionFlags: number, + restrictionAdditions: MosaicId[], + restrictionDeletions: MosaicId[], + networkType: NetworkType, + maxFee?: UInt64): AccountMosaicRestrictionTransaction { + + if(restrictionFlags > 0xFFFF){ + throw new Error("restrictionFlags short be uint16 number"); + } + + return new AccountMosaicRestrictionTransactionBuilder() + .networkType(networkType) + .deadline(deadline) + .restrictionFlags(restrictionFlags) + .restrictionAdditions(restrictionAdditions) + .restrictionDeletions(restrictionDeletions) + .maxFee(maxFee) + .build(); + } + + /** + * @param networkType + * @param version + * @param deadline + * @param maxFee + * @param restrictionFlags + * @param restrictionAdditions + * @param restrictionDeletions + * @param signature + * @param signer + * @param transactionInfo + */ + constructor(networkType: NetworkType, + version: number, + deadline: Deadline, + maxFee: UInt64, + public readonly restrictionFlags: number, + public readonly restrictionAdditions: MosaicId[], + public readonly restrictionDeletions: MosaicId[], + signature?: string, + signer?: PublicAccount, + transactionInfo?: TransactionInfo) { + super(TransactionType.Account_Mosaic_Restriction, + networkType, version, deadline, maxFee, signature, signer, transactionInfo); + } + + /** + * @override Transaction.size() + * @description get the byte size of a AccountMosaicRestrictionTransaction + * @returns {number} + * @memberof AccountMosaicRestrictionTransaction + */ + public get size(): number { + return AccountMosaicRestrictionTransaction.calculateSize(this.restrictionAdditions.length, this.restrictionDeletions.length); + } + + public static calculateSize(addCount: number, deleteCount: number): number { + const byteSize = Transaction.getHeaderSize(); + + const restrictionFlags = 2; + const byteAddCount = 1; + const byteDeleteCount = 1; + + const reservedBodyByte = 1; + + const additionBytes = 8 * addCount; + const deletionBytes = 8 * deleteCount; + + return byteSize + restrictionFlags + + byteAddCount + byteDeleteCount + + reservedBodyByte + + additionBytes + deletionBytes; + } + + /** + * @override Transaction.toJSON() + * @description Serialize a transaction object - add own fields to the result of Transaction.toJSON() + * @return {Object} + * @memberof AccountMosaicRestrictionTransaction + */ + public toJSON() { + const parent = super.toJSON(); + return { + ...parent, + transaction: { + ...parent.transaction, + restrictionFlags: this.restrictionFlags, + restrictionAdditions: this.restrictionAdditions.map(add=>{ + return add.toHex() + }), + restrictionDeletions: this.restrictionDeletions.map(del=>{ + return del.toHex() + }) + } + } + } + + /** + * @internal + * @returns {VerifiableTransaction} + */ + protected buildTransaction(): VerifiableTransaction { + return new Builder() + .addSize(this.size) + .addDeadline(this.deadline.toDTO()) + .addMaxFee(this.maxFee.toDTO()) + .addVersion(this.versionToDTO()) + .addRestrictionFlags(this.restrictionFlags) + .addRestrictionAdditions(this.restrictionAdditions.map(x=> x.toDTO().id)) + .addRestrictionDeletions(this.restrictionDeletions.map(x=> x.toDTO().id)) + .build(); + } +} + +export class AccountMosaicRestrictionTransactionBuilder extends TransactionBuilder { + private _restrictionFlags: number; + private _restrictionAdditions: MosaicId[]; + private _restrictionDeletions: MosaicId[]; + + public restrictionFlags(restrictionFlags: number) { + if (restrictionFlags > 0xFFFF) { + throw new Error('restrictionFlags must be a uint16 number'); + }; + this._restrictionFlags = restrictionFlags; + return this; + } + + public restrictionAdditions(restrictionAdditions: MosaicId[]) { + this._restrictionAdditions = restrictionAdditions; + return this; + } + + public restrictionDeletions(restrictionDeletions: MosaicId[]) { + this._restrictionDeletions = restrictionDeletions; + return this; + } + + public build(): AccountMosaicRestrictionTransaction { + return new AccountMosaicRestrictionTransaction( + this._networkType, + this._version || TransactionTypeVersion.Account_Mosaic_Restriction, + this._deadline ? this._deadline : this._createNewDeadlineFn(), + this._maxFee ? this._maxFee : calculateFee(AccountMosaicRestrictionTransaction.calculateSize(this._restrictionAdditions.length, this._restrictionDeletions.length), this._feeCalculationStrategy), + this._restrictionFlags, + this._restrictionAdditions, + this._restrictionDeletions, + this._signature, + this._signer, + this._transactionInfo + ); + } +} diff --git a/src/model/transaction/AccountOperationRestrictionTransaction.ts b/src/model/transaction/AccountOperationRestrictionTransaction.ts new file mode 100644 index 00000000..d9106fac --- /dev/null +++ b/src/model/transaction/AccountOperationRestrictionTransaction.ts @@ -0,0 +1,191 @@ +/* + * Copyright 2024 ProximaX + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Builder } from '../../infrastructure/builders/AccountOperationRestrictionTransaction'; +import {VerifiableTransaction} from '../../infrastructure/builders/VerifiableTransaction'; +import { PublicAccount } from '../account/PublicAccount'; +import { RestrictionType } from '../account/RestrictionType'; +import { NetworkType } from '../blockchain/NetworkType'; +import { UInt64 } from '../UInt64'; +import { Deadline } from './Deadline'; +import { Transaction, TransactionBuilder } from './Transaction'; +import { TransactionInfo } from './TransactionInfo'; +import { TransactionType } from './TransactionType'; +import { TransactionTypeVersion } from './TransactionTypeVersion'; +import { calculateFee } from './FeeCalculationStrategy'; +import { MosaicId } from "../mosaic/MosaicId"; + +export class AccountOperationRestrictionTransaction extends Transaction { + + /** + * Create a modify account address restriction transaction object + * @param deadline - The deadline to include the transaction. + * @param restrictionFlags + * @param restrictionAdditions + * @param restrictionDeletions + * @param networkType - The network type. + * @param maxFee - (Optional) Max fee defined by the sender + * @returns {AccountOperationRestrictionTransaction} + */ + public static create(deadline: Deadline, + restrictionFlags: number, + restrictionAdditions: TransactionType[], + restrictionDeletions: TransactionType[], + networkType: NetworkType, + maxFee?: UInt64): AccountOperationRestrictionTransaction { + + if(restrictionFlags > 0xFFFF){ + throw new Error("restrictionFlags short be uint16 number"); + } + + return new AccountOperationRestrictionTransactionBuilder() + .networkType(networkType) + .deadline(deadline) + .restrictionFlags(restrictionFlags) + .restrictionAdditions(restrictionAdditions) + .restrictionDeletions(restrictionDeletions) + .maxFee(maxFee) + .build(); + } + + /** + * @param networkType + * @param version + * @param deadline + * @param maxFee + * @param restrictionFlags + * @param restrictionAdditions + * @param restrictionDeletions + * @param signature + * @param signer + * @param transactionInfo + */ + constructor(networkType: NetworkType, + version: number, + deadline: Deadline, + maxFee: UInt64, + public readonly restrictionFlags: number, + public readonly restrictionAdditions: TransactionType[], + public readonly restrictionDeletions: TransactionType[], + signature?: string, + signer?: PublicAccount, + transactionInfo?: TransactionInfo) { + super(TransactionType.Account_Operation_Restriction, + networkType, version, deadline, maxFee, signature, signer, transactionInfo); + } + + /** + * @override Transaction.size() + * @description get the byte size of a AccountOperationRestrictionTransaction + * @returns {number} + * @memberof AccountOperationRestrictionTransaction + */ + public get size(): number { + return AccountOperationRestrictionTransaction.calculateSize(this.restrictionAdditions.length, this.restrictionDeletions.length); + } + + public static calculateSize(addCount: number, deleteCount: number): number { + const byteSize = Transaction.getHeaderSize(); + + const restrictionFlags = 2; + const byteAddCount = 1; + const byteDeleteCount = 1; + + const reservedBodyByte = 1; + + const additionBytes = 2 * addCount; + const deletionBytes = 2 * deleteCount; + + return byteSize + restrictionFlags + + byteAddCount + byteDeleteCount + + reservedBodyByte + + additionBytes + deletionBytes; + } + + /** + * @override Transaction.toJSON() + * @description Serialize a transaction object - add own fields to the result of Transaction.toJSON() + * @return {Object} + * @memberof AccountOperationRestrictionTransaction + */ + public toJSON() { + const parent = super.toJSON(); + return { + ...parent, + transaction: { + ...parent.transaction, + restrictionFlags: this.restrictionFlags, + restrictionAdditions: this.restrictionAdditions, + restrictionDeletions: this.restrictionDeletions + } + } + } + + /** + * @internal + * @returns {VerifiableTransaction} + */ + protected buildTransaction(): VerifiableTransaction { + return new Builder() + .addSize(this.size) + .addDeadline(this.deadline.toDTO()) + .addMaxFee(this.maxFee.toDTO()) + .addVersion(this.versionToDTO()) + .addRestrictionFlags(this.restrictionFlags) + .addRestrictionAdditions(this.restrictionAdditions) + .addRestrictionDeletions(this.restrictionDeletions) + .build(); + } +} + +export class AccountOperationRestrictionTransactionBuilder extends TransactionBuilder { + private _restrictionFlags: number; + private _restrictionAdditions: TransactionType[]; + private _restrictionDeletions: TransactionType[]; + + public restrictionFlags(restrictionFlags: number) { + if (restrictionFlags > 0xFFFF) { + throw new Error('restrictionFlags must be a uint16 number'); + }; + this._restrictionFlags = restrictionFlags; + return this; + } + + public restrictionAdditions(restrictionAdditions: TransactionType[]) { + this._restrictionAdditions = restrictionAdditions; + return this; + } + + public restrictionDeletions(restrictionDeletions: TransactionType[]) { + this._restrictionDeletions = restrictionDeletions; + return this; + } + + public build(): AccountOperationRestrictionTransaction { + return new AccountOperationRestrictionTransaction( + this._networkType, + this._version || TransactionTypeVersion.Account_Operation_Restriction, + this._deadline ? this._deadline : this._createNewDeadlineFn(), + this._maxFee ? this._maxFee : calculateFee(AccountOperationRestrictionTransaction.calculateSize(this._restrictionAdditions.length, this._restrictionDeletions.length), this._feeCalculationStrategy), + this._restrictionFlags, + this._restrictionAdditions, + this._restrictionDeletions, + this._signature, + this._signer, + this._transactionInfo + ); + } +} diff --git a/src/model/transaction/AccountV2UpgradeTransaction.ts b/src/model/transaction/AccountV2UpgradeTransaction.ts new file mode 100644 index 00000000..cedccbe7 --- /dev/null +++ b/src/model/transaction/AccountV2UpgradeTransaction.ts @@ -0,0 +1,149 @@ +/* + * Copyright 2024 ProximaX + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Builder } from '../../infrastructure/builders/AccountV2UpgradeTransaction'; +import { TransactionBuilder } from './Transaction'; +import { VerifiableTransaction } from '../../infrastructure/builders/VerifiableTransaction'; +import { PublicAccount } from '../account/PublicAccount'; +import { NetworkType } from '../blockchain/NetworkType'; +import { UInt64 } from '../UInt64'; +import { Deadline } from './Deadline'; +import { Transaction } from './Transaction'; +import { TransactionInfo } from './TransactionInfo'; +import { TransactionType } from './TransactionType'; +import { TransactionTypeVersion } from './TransactionTypeVersion'; +import { calculateFee } from './FeeCalculationStrategy'; + +/** + * Announce an AccountV2UpgradeTransaction to move from v1 account to v2 account. + */ +export class AccountV2UpgradeTransaction extends Transaction { + /** + * Create a account v2 upgrade transaction object + * @param deadline - The deadline to include the transaction. + * @param newPublicAccountKey - The public key of the v2 account. + * @param maxFee - (Optional) Max fee defined by the sender + * @returns {AccountV2UpgradeTransaction} + */ + public static create(deadline: Deadline, + newPublicAccountKey: string, + networkType: NetworkType, + maxFee?: UInt64): AccountV2UpgradeTransaction { + return new AccountV2UpgradeTransactionBuilder() + .networkType(networkType) + .deadline(deadline) + .maxFee(maxFee) + .newPublicAccountKey(newPublicAccountKey) + .build(); + } + + /** + * @param networkType + * @param version + * @param deadline + * @param maxFee + * @param newPublicAccountKey + * @param signature + * @param signer + * @param transactionInfo + */ + constructor(networkType: NetworkType, + version: number, + deadline: Deadline, + maxFee: UInt64, + /** + * The public key of the v2 account. + */ + public readonly newPublicAccountKey: string, + signature?: string, + signer?: PublicAccount, + transactionInfo?: TransactionInfo) { + super(TransactionType.Account_V2_Upgrade, networkType, version, deadline, maxFee, signature, signer, transactionInfo); + } + + /** + * @override Transaction.size() + * @description get the byte size of a AccountV2UpgradeTransaction + * @returns {number} + * @memberof AccountV2UpgradeTransaction + */ + public get size(): number { + return AccountV2UpgradeTransaction.calculateSize(); + } + + public static calculateSize(): number { + const byteSize = Transaction.getHeaderSize(); + + // set static byte size fields + const bytePublicKey = 32; + + return byteSize + bytePublicKey; + } + + /** + * @override Transaction.toJSON() + * @description Serialize a transaction object - add own fields to the result of Transaction.toJSON() + * @return {Object} + * @memberof AccountV2UpgradeTransaction + */ + public toJSON() { + const parent = super.toJSON(); + return { + ...parent, + transaction: { + ...parent.transaction, + newPublicAccountKey: this.newPublicAccountKey, + } + } + } + + /** + * @internal + * @returns {VerifiableTransaction} + */ + protected buildTransaction(): VerifiableTransaction { + return new Builder() + .addSize(this.size) + .addDeadline(this.deadline.toDTO()) + .addMaxFee(this.maxFee.toDTO()) + .addVersion(this.versionToDTO()) + .addNewPublicAccountKey(this.newPublicAccountKey) + .build(); + } + +} + +export class AccountV2UpgradeTransactionBuilder extends TransactionBuilder { + private _newPublicAccountKey: string; + + public newPublicAccountKey(newPublicAccountKey: string) { + this._newPublicAccountKey = newPublicAccountKey; + return this; + } + + public build(): AccountV2UpgradeTransaction { + return new AccountV2UpgradeTransaction( + this._networkType, + this._version || TransactionTypeVersion.Account_V2_Upgrade, + this._deadline ? this._deadline : this._createNewDeadlineFn(), + this._maxFee ? this._maxFee : calculateFee(AccountV2UpgradeTransaction.calculateSize(), this._feeCalculationStrategy), + this._newPublicAccountKey, + this._signature, + this._signer, + this._transactionInfo + ); + } +} diff --git a/src/model/transaction/AggregateTransaction.ts b/src/model/transaction/AggregateTransaction.ts index e4f100bd..cbc3c9a8 100644 --- a/src/model/transaction/AggregateTransaction.ts +++ b/src/model/transaction/AggregateTransaction.ts @@ -345,6 +345,9 @@ export class AggregateCompleteTransactionBuilder extends TransactionBuilder { } } +/** + * @deprecated + */ export class AggregateCompleteV1TransactionBuilder extends TransactionBuilder { private _cosignatures: AggregateTransactionCosignature[] = []; private _innerTransactions: InnerTransaction[] = []; @@ -405,6 +408,9 @@ export class AggregateBondedTransactionBuilder extends TransactionBuilder { } } +/** + * @deprecated + */ export class AggregateBondedV1TransactionBuilder extends TransactionBuilder { private _cosignatures: AggregateTransactionCosignature[] = []; private _innerTransactions: InnerTransaction[] = []; diff --git a/src/model/transaction/LockFund.ts b/src/model/transaction/LockFund.ts new file mode 100644 index 00000000..120a9e9a --- /dev/null +++ b/src/model/transaction/LockFund.ts @@ -0,0 +1,4 @@ +export enum LockFundAction{ + LOCK, + UNLOCK +} \ No newline at end of file diff --git a/src/model/transaction/LockFundCancelUnlockTransaction.ts b/src/model/transaction/LockFundCancelUnlockTransaction.ts new file mode 100644 index 00000000..5e3f63ab --- /dev/null +++ b/src/model/transaction/LockFundCancelUnlockTransaction.ts @@ -0,0 +1,123 @@ +// Copyright 2024 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { Transaction, TransactionBuilder } from './Transaction'; +import { TransactionType } from './TransactionType'; +import { NetworkType } from '../blockchain/NetworkType'; +import { Deadline } from './Deadline'; +import { UInt64 } from '../UInt64'; +import { PublicAccount } from '../account/PublicAccount'; +import { TransactionInfo } from './TransactionInfo'; +import { Builder } from '../../infrastructure/builders/LockFundCancelUnlockTransaction'; +import { VerifiableTransaction } from '../../infrastructure/builders/VerifiableTransaction'; +import { TransactionTypeVersion } from './TransactionTypeVersion'; +import { calculateFee, FeeCalculationStrategy } from './FeeCalculationStrategy'; + +export class LockFundCancelUnlockTransaction extends Transaction { + /** + * @param networkType + * @param version + * @param deadline + * @param maxFee + * @param targetHeight + * @param signature + * @param signer + * @param transactionInfo + */ + constructor(networkType: NetworkType, + version: number, + deadline: Deadline, + maxFee: UInt64, + public readonly targetHeight: UInt64, + signature?: string, + signer?: PublicAccount, + transactionInfo?: TransactionInfo) { + super(TransactionType.Lock_Fund_Cancel_Unlock, networkType, version, deadline, maxFee, signature, signer, transactionInfo); + } + + public static create(deadline: Deadline, + targetHeight: UInt64, + networkType: NetworkType, + maxFee?: UInt64): LockFundCancelUnlockTransaction { + return new LockFundCancelUnlockTransactionBuilder() + .networkType(networkType) + .deadline(deadline) + .maxFee(maxFee) + .targetHeight(targetHeight) + .build(); + } + + /** + * @override Transaction.size() + * @description get the byte size of a transaction + * @returns {number} + * @memberof Transaction + */ + public get size(): number { + return LockFundCancelUnlockTransaction.calculateSize(); + } + + public static calculateSize(): number { + const byteSize = Transaction.getHeaderSize() + + 8 // duration + return byteSize; + } + + /** + * @override Transaction.toJSON() + * @description Serialize a transaction object - add own fields to the result of Transaction.toJSON() + * @return {Object} + * @memberof LockFundCancelUnlockTransaction + */ + public toJSON() { + const parent = super.toJSON(); + return { + ...parent, + transaction: { + ...parent.transaction, + targetHeight: this.targetHeight.toDTO() + } + } + } + + /** + * @internal + * @returns {VerifiableTransaction} + */ + protected buildTransaction(): VerifiableTransaction { + return new Builder() + .addSize(this.size) + .addDeadline(this.deadline.toDTO()) + .addMaxFee(this.maxFee.toDTO()) + .addVersion(this.versionToDTO()) + .addTargetHeight(this.targetHeight.toDTO()) + .build(); + } +} + +export class LockFundCancelUnlockTransactionBuilder extends TransactionBuilder { + private _targetHeight: UInt64; + + constructor() { + super(); + } + + public targetHeight(targetHeight: UInt64) { + this._targetHeight = targetHeight; + return this; + } + + public build(): LockFundCancelUnlockTransaction { + return new LockFundCancelUnlockTransaction( + this._networkType, + this._version || TransactionTypeVersion.Lock_Fund_Cancel_Unlock, + this._deadline ? this._deadline : this._createNewDeadlineFn(), + this._maxFee ? this._maxFee : calculateFee(LockFundCancelUnlockTransaction.calculateSize(), this._feeCalculationStrategy), + this._targetHeight, + this._signature, + this._signer, + this._transactionInfo + ); + } +} diff --git a/src/model/transaction/LockFundTransferTransaction.ts b/src/model/transaction/LockFundTransferTransaction.ts new file mode 100644 index 00000000..901e554a --- /dev/null +++ b/src/model/transaction/LockFundTransferTransaction.ts @@ -0,0 +1,156 @@ +// Copyright 2024 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { Transaction, TransactionBuilder } from './Transaction'; +import { TransactionType } from './TransactionType'; +import { NetworkType } from '../blockchain/NetworkType'; +import { Deadline } from './Deadline'; +import { UInt64 } from '../UInt64'; +import { PublicAccount } from '../account/PublicAccount'; +import { TransactionInfo } from './TransactionInfo'; +import { Builder } from '../../infrastructure/builders/LockFundTransferTransaction'; +import { VerifiableTransaction } from '../../infrastructure/builders/VerifiableTransaction'; +import { TransactionTypeVersion } from './TransactionTypeVersion'; +import { calculateFee, FeeCalculationStrategy } from './FeeCalculationStrategy'; +import { LockFundAction } from './LockFund'; +import { Mosaic } from '../mosaic/Mosaic'; + +export class LockFundTransferTransaction extends Transaction { + /** + * @param networkType + * @param version + * @param deadline + * @param maxFee + * @param duration + * @param action + * @param mosaics + * @param signature + * @param signer + * @param transactionInfo + */ + constructor(networkType: NetworkType, + version: number, + deadline: Deadline, + maxFee: UInt64, + public readonly duration: UInt64, + public readonly action: LockFundAction, + public readonly mosaics: Mosaic[], + signature?: string, + signer?: PublicAccount, + transactionInfo?: TransactionInfo) { + super(TransactionType.Lock_Fund_Transfer, networkType, version, deadline, maxFee, signature, signer, transactionInfo); + } + + public static create(deadline: Deadline, + duration: UInt64, + action: LockFundAction, + mosaics: Mosaic[], + networkType: NetworkType, + maxFee?: UInt64): LockFundTransferTransaction { + return new LockFundTransferTransactionBuilder() + .networkType(networkType) + .deadline(deadline) + .maxFee(maxFee) + .duration(duration) + .action(action) + .mosaics(mosaics) + .build(); + } + + /** + * @override Transaction.size() + * @description get the byte size of a transaction + * @returns {number} + * @memberof Transaction + */ + public get size(): number { + return LockFundTransferTransaction.calculateSize(this.mosaics.length); + } + + public static calculateSize(mosaicsCount: number): number { + const byteSize = Transaction.getHeaderSize() + + 8 // duration + + 1 // action + + 1 // mosaicsCount + + (mosaicsCount * 16) // mosaicId + amount + return byteSize; + } + + /** + * @override Transaction.toJSON() + * @description Serialize a transaction object - add own fields to the result of Transaction.toJSON() + * @return {Object} + * @memberof LockFundTransferTransaction + */ + public toJSON() { + const parent = super.toJSON(); + return { + ...parent, + transaction: { + ...parent.transaction, + duration: this.duration.toDTO(), + action: this.action, + mosaics: this.mosaics.map((mosaic) => { + return mosaic.toDTO(); + }) + } + } + } + + /** + * @internal + * @returns {VerifiableTransaction} + */ + protected buildTransaction(): VerifiableTransaction { + return new Builder() + .addSize(this.size) + .addDeadline(this.deadline.toDTO()) + .addMaxFee(this.maxFee.toDTO()) + .addVersion(this.versionToDTO()) + .addDuration(this.duration.toDTO()) + .addAction(this.action) + .addMosaics(this.mosaics.map((mosaic) => mosaic.toDTO())) + .build(); + } +} + +export class LockFundTransferTransactionBuilder extends TransactionBuilder { + private _duration: UInt64; + private _action: LockFundAction; + private _mosaics: Mosaic[]; + + constructor() { + super(); + } + + public duration(duration: UInt64) { + this._duration = duration; + return this; + } + + public action(action: LockFundAction) { + this._action = action; + return this; + } + + public mosaics(mosaics: Mosaic[]) { + this._mosaics = mosaics; + return this; + } + + public build(): LockFundTransferTransaction { + return new LockFundTransferTransaction( + this._networkType, + this._version || TransactionTypeVersion.Lock_Fund_Transfer, + this._deadline ? this._deadline : this._createNewDeadlineFn(), + this._maxFee ? this._maxFee : calculateFee(LockFundTransferTransaction.calculateSize(this._mosaics.length), this._feeCalculationStrategy), + this._duration, + this._action, + this._mosaics, + this._signature, + this._signer, + this._transactionInfo + ); + } +} diff --git a/src/model/transaction/MosaicAddressRestrictionTransaction.ts b/src/model/transaction/MosaicAddressRestrictionTransaction.ts new file mode 100644 index 00000000..b9ccf1ad --- /dev/null +++ b/src/model/transaction/MosaicAddressRestrictionTransaction.ts @@ -0,0 +1,197 @@ +// Copyright 2024 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { Transaction, TransactionBuilder } from './Transaction'; +import { TransactionType } from './TransactionType'; +import { NetworkType } from '../blockchain/NetworkType'; +import { Deadline } from './Deadline'; +import { UInt64 } from '../UInt64'; +import { PublicAccount } from '../account/PublicAccount'; +import { TransactionInfo } from './TransactionInfo'; +import { Builder } from '../../infrastructure/builders/MosaicAddressRestrictionTransaction'; +import { VerifiableTransaction } from '../../infrastructure/builders/VerifiableTransaction'; +import { TransactionTypeVersion } from './TransactionTypeVersion'; +import { calculateFee, FeeCalculationStrategy } from './FeeCalculationStrategy'; +import { Address } from '../account/Address'; +import { MosaicId } from '../mosaic/MosaicId'; +import { NamespaceId } from '../namespace/NamespaceId'; + +export class MosaicAddressRestrictionTransaction extends Transaction { + /** + * @param networkType + * @param version + * @param deadline + * @param maxFee + * @param mosaicId + * @param restrictionKey + * @param previousRestrictionValue + * @param newRestrictionValue + * @param targetAddress + * @param signature + * @param signer + * @param transactionInfo + */ + constructor(networkType: NetworkType, + version: number, + deadline: Deadline, + maxFee: UInt64, + public readonly mosaicId: MosaicId, + public readonly restrictionKey: UInt64, + public readonly previousRestrictionValue: UInt64, + public readonly newRestrictionValue: UInt64, + public readonly targetAddress: Address | NamespaceId, + signature?: string, + signer?: PublicAccount, + transactionInfo?: TransactionInfo) { + super(TransactionType.Mosaic_Address_Restriction, networkType, version, deadline, maxFee, signature, signer, transactionInfo); + } + + public static create(deadline: Deadline, + mosaicId: MosaicId, + restrictionKey: UInt64, + previousRestrictionValue: UInt64, + newRestrictionValue: UInt64, + targetAddress: Address | NamespaceId, + networkType: NetworkType, + maxFee?: UInt64): MosaicAddressRestrictionTransaction { + return new MosaicAddressRestrictionTransactionBuilder() + .networkType(networkType) + .deadline(deadline) + .maxFee(maxFee) + .mosaicId(mosaicId) + .restrictionKey(restrictionKey) + .previousRestrictionValue(previousRestrictionValue) + .newRestrictionValue(newRestrictionValue) + .targetAddress(targetAddress) + .build(); + } + + /** + * Return the string notation for the set recipient + * @internal + * @returns {string} + */ + public targetAddressToString(): string { + + if (this.targetAddress instanceof NamespaceId) { + // namespaceId recipient, return hexadecimal notation + return (this.targetAddress as NamespaceId).toHex(); + } + + // address recipient + return (this.targetAddress as Address).plain(); + } + + /** + * @override Transaction.size() + * @description get the byte size of a transaction + * @returns {number} + * @memberof Transaction + */ + public get size(): number { + return MosaicAddressRestrictionTransaction.calculateSize(); + } + + public static calculateSize(): number { + const byteSize = Transaction.getHeaderSize() + + 8 // mosaicId + + 8 // restrictionKey + + 8 // previousRestrictionValue + + 8 // newRestrictionValue + + 25 // targetAddress + return byteSize; + } + + /** + * @override Transaction.toJSON() + * @description Serialize a transaction object - add own fields to the result of Transaction.toJSON() + * @return {Object} + * @memberof MosaicAddressRestrictionTransaction + */ + public toJSON() { + const parent = super.toJSON(); + return { + ...parent, + transaction: { + ...parent.transaction, + mosaicId: this.mosaicId.toHex(), + restrictionKey: this.restrictionKey.toDTO(), + previousRestrictionValue: this.previousRestrictionValue.toDTO(), + newRestrictionValue: this.newRestrictionValue.toDTO(), + targetAddress: this.targetAddress.toDTO(), + } + } + } + + /** + * @internal + * @returns {VerifiableTransaction} + */ + protected buildTransaction(): VerifiableTransaction { + return new Builder() + .addSize(this.size) + .addDeadline(this.deadline.toDTO()) + .addMaxFee(this.maxFee.toDTO()) + .addVersion(this.versionToDTO()) + .addMosaicId(this.mosaicId.toDTO().id) + .addRestrictionKey(this.restrictionKey.toDTO()) + .addPreviousRestrictionValue(this.previousRestrictionValue.toDTO()) + .addNewRestrictionValue(this.newRestrictionValue.toDTO()) + .addTargetAddress(this.targetAddressToString()) + .build(); + } +} + +export class MosaicAddressRestrictionTransactionBuilder extends TransactionBuilder { + private _mosaicId: MosaicId; + private _restrictionKey: UInt64; + private _previousRestrictionValue: UInt64; + private _newRestrictionValue: UInt64; + private _targetAddress: Address | NamespaceId; + constructor() { + super(); + } + + public mosaicId(mosaicId: MosaicId) { + this._mosaicId = mosaicId; + return this; + } + + public restrictionKey(restrictionKey: UInt64) { + this._restrictionKey = restrictionKey; + return this; + } + + public previousRestrictionValue(previousRestrictionValue: UInt64) { + this._previousRestrictionValue = previousRestrictionValue; + return this; + } + + public newRestrictionValue(newRestrictionValue: UInt64) { + this._newRestrictionValue = newRestrictionValue; + return this; + } + + public targetAddress(targetAddress: Address | NamespaceId) { + this._targetAddress = targetAddress; + return this; + } + + public build(): MosaicAddressRestrictionTransaction { + return new MosaicAddressRestrictionTransaction( + this._networkType, + this._version || TransactionTypeVersion.Mosaic_Address_Restriction, + this._deadline ? this._deadline : this._createNewDeadlineFn(), + this._maxFee ? this._maxFee : calculateFee(MosaicAddressRestrictionTransaction.calculateSize(), this._feeCalculationStrategy), + this._mosaicId, + this._restrictionKey, + this._previousRestrictionValue, + this._newRestrictionValue, + this._targetAddress, + this._signature, + this._signer, + this._transactionInfo + ); + } +} diff --git a/src/model/transaction/MosaicGlobalRestrictionTransaction.ts b/src/model/transaction/MosaicGlobalRestrictionTransaction.ts new file mode 100644 index 00000000..dc311ad9 --- /dev/null +++ b/src/model/transaction/MosaicGlobalRestrictionTransaction.ts @@ -0,0 +1,208 @@ +// Copyright 2024 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { Transaction, TransactionBuilder } from './Transaction'; +import { TransactionType } from './TransactionType'; +import { NetworkType } from '../blockchain/NetworkType'; +import { Deadline } from './Deadline'; +import { UInt64 } from '../UInt64'; +import { PublicAccount } from '../account/PublicAccount'; +import { TransactionInfo } from './TransactionInfo'; +import { Builder } from '../../infrastructure/builders/MosaicGlobalRestrictionTransaction'; +import { VerifiableTransaction } from '../../infrastructure/builders/VerifiableTransaction'; +import { TransactionTypeVersion } from './TransactionTypeVersion'; +import { calculateFee, FeeCalculationStrategy } from './FeeCalculationStrategy'; +import { MosaicRestrictionType } from '../mosaic/MosaicRestriction'; +import { MosaicId } from '../mosaic/MosaicId'; + +export class MosaicGlobalRestrictionTransaction extends Transaction { + /** + * @param networkType + * @param version + * @param deadline + * @param maxFee + * @param mosaicId + * @param referenceMosaicId + * @param restrictionKey + * @param previousRestrictionValue + * @param newRestrictionValue + * @param previousRestrictionType + * @param newRestrictionType + * @param signature + * @param signer + * @param transactionInfo + */ + constructor(networkType: NetworkType, + version: number, + deadline: Deadline, + maxFee: UInt64, + public readonly mosaicId: MosaicId, + public readonly referenceMosaicId: MosaicId, + public readonly restrictionKey: UInt64, + public readonly previousRestrictionValue: UInt64, + public readonly newRestrictionValue: UInt64, + public readonly previousRestrictionType: MosaicRestrictionType, + public readonly newRestrictionType: MosaicRestrictionType, + signature?: string, + signer?: PublicAccount, + transactionInfo?: TransactionInfo) { + super(TransactionType.Mosaic_Global_Restriction, networkType, version, deadline, maxFee, signature, signer, transactionInfo); + } + + public static create(deadline: Deadline, + mosaicId: MosaicId, + referenceMosaicId: MosaicId, + restrictionKey: UInt64, + previousRestrictionValue: UInt64, + newRestrictionValue: UInt64, + previousRestrictionType: MosaicRestrictionType, + newRestrictionType: MosaicRestrictionType, + networkType: NetworkType, + maxFee?: UInt64): MosaicGlobalRestrictionTransaction { + return new MosaicGlobalRestrictionTransactionBuilder() + .networkType(networkType) + .deadline(deadline) + .maxFee(maxFee) + .mosaicId(mosaicId) + .referenceMosaicId(referenceMosaicId) + .restrictionKey(restrictionKey) + .previousRestrictionValue(previousRestrictionValue) + .newRestrictionValue(newRestrictionValue) + .previousRestrictionType(previousRestrictionType) + .newRestrictionType(newRestrictionType) + .build(); + } + + /** + * @override Transaction.size() + * @description get the byte size of a transaction + * @returns {number} + * @memberof Transaction + */ + public get size(): number { + return MosaicGlobalRestrictionTransaction.calculateSize(); + } + + public static calculateSize(): number { + const byteSize = Transaction.getHeaderSize() + + 8 // mosaicId + + 8 // referenceMosaicId + + 8 // restrictionKey + + 8 // previousRestrictionValue + + 8 // newRestrictionValue + + 1 // previousRestrictionType + + 1 // newRestrictionType + return byteSize; + } + + /** + * @override Transaction.toJSON() + * @description Serialize a transaction object - add own fields to the result of Transaction.toJSON() + * @return {Object} + * @memberof MosaicGlobalRestrictionTransaction + */ + public toJSON() { + const parent = super.toJSON(); + return { + ...parent, + transaction: { + ...parent.transaction, + mosaicId: this.mosaicId.toHex(), + referenceMosaicId: this.referenceMosaicId.toHex(), + restrictionKey: this.restrictionKey.toDTO(), + previousRestrictionValue: this.previousRestrictionValue.toDTO(), + newRestrictionValue: this.newRestrictionValue.toDTO(), + previousRestrictionType: this.previousRestrictionType, + newRestrictionType: this.newRestrictionType, + } + } + } + + /** + * @internal + * @returns {VerifiableTransaction} + */ + protected buildTransaction(): VerifiableTransaction { + return new Builder() + .addSize(this.size) + .addDeadline(this.deadline.toDTO()) + .addMaxFee(this.maxFee.toDTO()) + .addVersion(this.versionToDTO()) + .addMosaicId(this.mosaicId.toDTO().id) + .addReferenceMosaicId(this.referenceMosaicId.toDTO().id) + .addRestrictionKey(this.restrictionKey.toDTO()) + .addPreviousRestrictionValue(this.previousRestrictionValue.toDTO()) + .addNewRestrictionValue(this.newRestrictionValue.toDTO()) + .addPreviousRestrictionType(this.previousRestrictionType) + .addNewRestrictionType(this.newRestrictionType) + .build(); + } +} + +export class MosaicGlobalRestrictionTransactionBuilder extends TransactionBuilder { + private _mosaicId: MosaicId; + private _referenceMosaicId: MosaicId; + private _restrictionKey: UInt64; + private _previousRestrictionValue: UInt64; + private _newRestrictionValue: UInt64; + private _previousRestrictionType: MosaicRestrictionType; + private _newRestrictionType: MosaicRestrictionType; + constructor() { + super(); + } + + public mosaicId(mosaicId: MosaicId) { + this._mosaicId = mosaicId; + return this; + } + + public referenceMosaicId(referenceMosaicId: MosaicId) { + this._referenceMosaicId = referenceMosaicId; + return this; + } + + public restrictionKey(restrictionKey: UInt64) { + this._restrictionKey = restrictionKey; + return this; + } + + public previousRestrictionValue(previousRestrictionValue: UInt64) { + this._previousRestrictionValue = previousRestrictionValue; + return this; + } + + public newRestrictionValue(newRestrictionValue: UInt64) { + this._newRestrictionValue = newRestrictionValue; + return this; + } + + public previousRestrictionType(previousRestrictionType: MosaicRestrictionType) { + this._previousRestrictionType = previousRestrictionType; + return this; + } + + public newRestrictionType(newRestrictionType: MosaicRestrictionType) { + this._newRestrictionType = newRestrictionType; + return this; + } + + public build(): MosaicGlobalRestrictionTransaction { + return new MosaicGlobalRestrictionTransaction( + this._networkType, + this._version || TransactionTypeVersion.Mosaic_Global_Restriction, + this._deadline ? this._deadline : this._createNewDeadlineFn(), + this._maxFee ? this._maxFee : calculateFee(MosaicGlobalRestrictionTransaction.calculateSize(), this._feeCalculationStrategy), + this._mosaicId, + this._referenceMosaicId, + this._restrictionKey, + this._previousRestrictionValue, + this._newRestrictionValue, + this._previousRestrictionType, + this._newRestrictionType, + this._signature, + this._signer, + this._transactionInfo + ); + } +} diff --git a/src/model/transaction/NetworkConfigAbsoluteHeightTransaction.ts b/src/model/transaction/NetworkConfigAbsoluteHeightTransaction.ts new file mode 100644 index 00000000..c9f030e8 --- /dev/null +++ b/src/model/transaction/NetworkConfigAbsoluteHeightTransaction.ts @@ -0,0 +1,153 @@ +// Copyright 2019 ProximaX Limited. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file + +import { Transaction, TransactionBuilder } from './Transaction'; +import { TransactionType } from './TransactionType'; +import { NetworkType } from '../blockchain/NetworkType'; +import { Deadline } from './Deadline'; +import { UInt64 } from '../UInt64'; +import { PublicAccount } from '../account/PublicAccount'; +import { TransactionInfo } from './TransactionInfo'; +import { Builder } from '../../infrastructure/builders/NetworkConfigAbsoluteHeightTransaction'; +import { VerifiableTransaction } from '../../infrastructure/builders/VerifiableTransaction'; +import { TransactionTypeVersion } from './TransactionTypeVersion'; +import { calculateFee, FeeCalculationStrategy } from './FeeCalculationStrategy'; + +export class NetworkConfigAbsoluteHeightTransaction extends Transaction { + /** + * @param networkType + * @param version + * @param deadline + * @param maxFee + * @param applyHeight + * @param networkConfig, + * @param supportedEntityVersions, + * @param signature + * @param signer + * @param transactionInfo + */ + constructor(networkType: NetworkType, + version: number, + deadline: Deadline, + maxFee: UInt64, + public readonly applyHeight: UInt64, + public readonly networkConfig: string, + public readonly supportedEntityVersions: string, + signature?: string, + signer?: PublicAccount, + transactionInfo?: TransactionInfo) { + super(TransactionType.NetworkConfig_Absolute_Height, networkType, version, deadline, maxFee, signature, signer, transactionInfo); + } + + public static create(deadline: Deadline, + applyHeight: UInt64, + networkConfig: string, + supportedEntityVersions: string, + networkType: NetworkType, + maxFee?: UInt64): NetworkConfigAbsoluteHeightTransaction { + return new NetworkConfigAbsoluteHeightTransactionBuilder() + .networkType(networkType) + .deadline(deadline) + .maxFee(maxFee) + .applyHeight(applyHeight) + .networkConfig(networkConfig) + .supportedEntityVersions(supportedEntityVersions) + .build(); + } + + /** + * @override Transaction.size() + * @description get the byte size of a transaction + * @returns {number} + * @memberof Transaction + */ + public get size(): number { + return NetworkConfigAbsoluteHeightTransaction.calculateSize(this.networkConfig.length, this.supportedEntityVersions.length); + } + + public static calculateSize(networkConfigLength: number, supportedEntityVersionsLength: number): number { + const byteSize = Transaction.getHeaderSize() + + 8 // applyHeight + + 2 // networkConfigSize + + 2 // supportedEntityVersionsSize + + networkConfigLength //networkConfig + + supportedEntityVersionsLength // supportedEntityVersions + return byteSize; + } + + /** + * @override Transaction.toJSON() + * @description Serialize a transaction object - add own fields to the result of Transaction.toJSON() + * @return {Object} + * @memberof NetworkConfigAbsoluteHeightTransaction + */ + public toJSON() { + const parent = super.toJSON(); + return { + ...parent, + transaction: { + ...parent.transaction, + applyHeight: this.applyHeight.toDTO(), + networkConfig: this.networkConfig, + supportedEntityVersions: this.supportedEntityVersions + } + } + } + + /** + * @internal + * @returns {VerifiableTransaction} + */ + protected buildTransaction(): VerifiableTransaction { + return new Builder() + .addSize(this.size) + .addDeadline(this.deadline.toDTO()) + .addMaxFee(this.maxFee.toDTO()) + .addVersion(this.versionToDTO()) + .addApplyHeight(this.applyHeight.toDTO()) + .addNetworkConfig(this.networkConfig) + .addSupportedEntityVersions(this.supportedEntityVersions) + .build(); + } +} + +export class NetworkConfigAbsoluteHeightTransactionBuilder extends TransactionBuilder { + private _applyHeight: UInt64; + private _networkConfig: string; + private _supportedEntityVersions: string; + + constructor() { + super(); + } + + public applyHeight(applyHeight: UInt64) { + this._applyHeight = applyHeight; + return this; + } + + public networkConfig(networkConfig: string) { + this._networkConfig = networkConfig; + return this; + } + + public supportedEntityVersions(supportedEntityVersions: string) { + this._supportedEntityVersions = supportedEntityVersions; + return this; + } + + public build(): NetworkConfigAbsoluteHeightTransaction { + return new NetworkConfigAbsoluteHeightTransaction( + this._networkType, + this._version || TransactionTypeVersion.NetworkConfig_Absolute_Height, + this._deadline ? this._deadline : this._createNewDeadlineFn(), + this._maxFee ? this._maxFee : calculateFee(NetworkConfigAbsoluteHeightTransaction.calculateSize(this._networkConfig.length, this._supportedEntityVersions.length), this._feeCalculationStrategy), + this._applyHeight, + this._networkConfig, + this._supportedEntityVersions, + this._signature, + this._signer, + this._transactionInfo + ); + } +} diff --git a/src/model/transaction/ChainConfigTransaction.ts b/src/model/transaction/NetworkConfigTransaction.ts similarity index 86% rename from src/model/transaction/ChainConfigTransaction.ts rename to src/model/transaction/NetworkConfigTransaction.ts index 04f151dd..3c59cf02 100644 --- a/src/model/transaction/ChainConfigTransaction.ts +++ b/src/model/transaction/NetworkConfigTransaction.ts @@ -9,12 +9,12 @@ import { Deadline } from './Deadline'; import { UInt64 } from '../UInt64'; import { PublicAccount } from '../account/PublicAccount'; import { TransactionInfo } from './TransactionInfo'; -import { Builder } from '../../infrastructure/builders/ChainConfigTransaction'; +import { Builder } from '../../infrastructure/builders/NetworkConfigTransaction'; import { VerifiableTransaction } from '../../infrastructure/builders/VerifiableTransaction'; import { TransactionTypeVersion } from './TransactionTypeVersion'; import { calculateFee, FeeCalculationStrategy } from './FeeCalculationStrategy'; -export class ChainConfigTransaction extends Transaction { +export class NetworkConfigTransaction extends Transaction { /** * @param networkType * @param version @@ -45,8 +45,8 @@ export class ChainConfigTransaction extends Transaction { networkConfig: string, supportedEntityVersions: string, networkType: NetworkType, - maxFee?: UInt64): ChainConfigTransaction { - return new ChainConfigTransactionBuilder() + maxFee?: UInt64): NetworkConfigTransaction { + return new NetworkConfigTransactionBuilder() .networkType(networkType) .deadline(deadline) .maxFee(maxFee) @@ -63,7 +63,7 @@ export class ChainConfigTransaction extends Transaction { * @memberof Transaction */ public get size(): number { - return ChainConfigTransaction.calculateSize(this.networkConfig.length, this.supportedEntityVersions.length); + return NetworkConfigTransaction.calculateSize(this.networkConfig.length, this.supportedEntityVersions.length); } public static calculateSize(networkConfigLength: number, supportedEntityVersionsLength: number): number { @@ -80,7 +80,7 @@ export class ChainConfigTransaction extends Transaction { * @override Transaction.toJSON() * @description Serialize a transaction object - add own fields to the result of Transaction.toJSON() * @return {Object} - * @memberof ChainConfigTransaction + * @memberof NetworkConfigTransaction */ public toJSON() { const parent = super.toJSON(); @@ -112,7 +112,7 @@ export class ChainConfigTransaction extends Transaction { } } -export class ChainConfigTransactionBuilder extends TransactionBuilder { +export class NetworkConfigTransactionBuilder extends TransactionBuilder { private _applyHeightDelta: UInt64; private _networkConfig: string; private _supportedEntityVersions: string; @@ -137,12 +137,12 @@ export class ChainConfigTransactionBuilder extends TransactionBuilder { return this; } - public build(): ChainConfigTransaction { - return new ChainConfigTransaction( + public build(): NetworkConfigTransaction { + return new NetworkConfigTransaction( this._networkType, this._version || TransactionTypeVersion.CHAIN_CONFIG, this._deadline ? this._deadline : this._createNewDeadlineFn(), - this._maxFee ? this._maxFee : calculateFee(ChainConfigTransaction.calculateSize(this._networkConfig.length, this._supportedEntityVersions.length), this._feeCalculationStrategy), + this._maxFee ? this._maxFee : calculateFee(NetworkConfigTransaction.calculateSize(this._networkConfig.length, this._supportedEntityVersions.length), this._feeCalculationStrategy), this._applyHeightDelta, this._networkConfig, this._supportedEntityVersions, diff --git a/src/model/transaction/NodeLinkTransaction.ts b/src/model/transaction/NodeLinkTransaction.ts new file mode 100644 index 00000000..802a8736 --- /dev/null +++ b/src/model/transaction/NodeLinkTransaction.ts @@ -0,0 +1,165 @@ +/* + * Copyright 2024 ProximaX + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Builder } from '../../infrastructure/builders/NodeLinkTransaction'; +import { TransactionBuilder } from './Transaction'; +import { VerifiableTransaction } from '../../infrastructure/builders/VerifiableTransaction'; +import { PublicAccount } from '../account/PublicAccount'; +import { NetworkType } from '../blockchain/NetworkType'; +import { UInt64 } from '../UInt64'; +import { Deadline } from './Deadline'; +import { Transaction } from './Transaction'; +import { TransactionInfo } from './TransactionInfo'; +import { TransactionType } from './TransactionType'; +import { AccountLinkAction } from "../account/AccountLink" +import { TransactionTypeVersion } from './TransactionTypeVersion'; +import { calculateFee } from './FeeCalculationStrategy'; + +/** + * Announce an NodeLinkTransaction, must use v2 account + * By doing so, you can enable delegated harvesting + */ +export class NodeLinkTransaction extends Transaction { + /** + * Create a node link transaction object + * @param deadline - The deadline to include the transaction. + * @param remoteAccountKey - The public key of the v2 account. + * @param linkAction - Link or unlink + * @param maxFee - (Optional) Max fee defined by the sender + * @returns {NodeLinkTransaction} + */ + public static create(deadline: Deadline, + remoteAccountKey: string, + linkAction: AccountLinkAction, + networkType: NetworkType, + maxFee?: UInt64): NodeLinkTransaction { + return new NodeLinkTransactionBuilder() + .networkType(networkType) + .deadline(deadline) + .maxFee(maxFee) + .remoteAccountKey(remoteAccountKey) + .linkAction(linkAction) + .build(); + } + + /** + * @param networkType + * @param version + * @param deadline + * @param maxFee + * @param remoteAccountKey + * @param linkAction + * @param signature + * @param signer + * @param transactionInfo + */ + constructor(networkType: NetworkType, + version: number, + deadline: Deadline, + maxFee: UInt64, + /** + * The public key of the node + */ + public readonly remoteAccountKey: string, + public readonly linkAction: AccountLinkAction, + signature?: string, + signer?: PublicAccount, + transactionInfo?: TransactionInfo) { + super(TransactionType.Node_Key_Link, networkType, version, deadline, maxFee, signature, signer, transactionInfo); + } + + /** + * @override Transaction.size() + * @description get the byte size of a NodeLinkTransaction + * @returns {number} + * @memberof NodeLinkTransaction + */ + public get size(): number { + return NodeLinkTransaction.calculateSize(); + } + + public static calculateSize(): number { + const byteSize = Transaction.getHeaderSize(); + + // set static byte size fields + const bytePublicKey = 32; + + return byteSize + bytePublicKey + 1; + } + + /** + * @override Transaction.toJSON() + * @description Serialize a transaction object - add own fields to the result of Transaction.toJSON() + * @return {Object} + * @memberof NodeLinkTransaction + */ + public toJSON() { + const parent = super.toJSON(); + return { + ...parent, + transaction: { + ...parent.transaction, + remoteAccountKey: this.remoteAccountKey, + linkAction: this.linkAction + } + } + } + + /** + * @internal + * @returns {VerifiableTransaction} + */ + protected buildTransaction(): VerifiableTransaction { + return new Builder() + .addSize(this.size) + .addDeadline(this.deadline.toDTO()) + .addMaxFee(this.maxFee.toDTO()) + .addVersion(this.versionToDTO()) + .addRemoteAccountKey(this.remoteAccountKey) + .addLinkAction(this.linkAction) + .build(); + } + +} + +export class NodeLinkTransactionBuilder extends TransactionBuilder { + private _remoteAccountKey: string; + private _linkAction: AccountLinkAction; + + public remoteAccountKey(remoteAccountKey: string) { + this._remoteAccountKey = remoteAccountKey; + return this; + } + + public linkAction(linkAction: AccountLinkAction) { + this._linkAction = linkAction; + return this; + } + + public build(): NodeLinkTransaction { + return new NodeLinkTransaction( + this._networkType, + this._version || TransactionTypeVersion.Node_Key_Link, + this._deadline ? this._deadline : this._createNewDeadlineFn(), + this._maxFee ? this._maxFee : calculateFee(NodeLinkTransaction.calculateSize(), this._feeCalculationStrategy), + this._remoteAccountKey, + this._linkAction, + this._signature, + this._signer, + this._transactionInfo + ); + } +} diff --git a/src/model/transaction/TransactionBuilderFactory.ts b/src/model/transaction/TransactionBuilderFactory.ts index 52fbac39..55f6cfc9 100644 --- a/src/model/transaction/TransactionBuilderFactory.ts +++ b/src/model/transaction/TransactionBuilderFactory.ts @@ -7,15 +7,15 @@ import { TransactionBuilder } from "./Transaction"; import { TransferTransactionBuilder } from './TransferTransaction'; import { AccountLinkTransactionBuilder } from './AccountLinkTransaction'; import { MosaicDefinitionTransactionBuilder } from './MosaicDefinitionTransaction'; -import { AccountAddressRestrictionModificationTransactionBuilder } from "./AccountAddressRestrictionModificationTransaction"; -import { AccountMosaicRestrictionModificationTransactionBuilder } from "./AccountMosaicRestrictionModificationTransaction"; -import { AccountOperationRestrictionModificationTransactionBuilder } from "./AccountOperationRestrictionModificationTransaction"; +import { AccountAddressRestrictionModificationTransactionBuilder } from "./deprecated/AccountAddressRestrictionModificationTransaction"; +import { AccountMosaicRestrictionModificationTransactionBuilder } from "./deprecated/AccountMosaicRestrictionModificationTransaction"; +import { AccountOperationRestrictionModificationTransactionBuilder } from "./deprecated/AccountOperationRestrictionModificationTransaction"; import { AddressAliasTransactionBuilder } from "./AddressAliasTransaction"; import { AggregateBondedTransactionBuilder, AggregateCompleteTransactionBuilder, AggregateBondedV1TransactionBuilder, AggregateCompleteV1TransactionBuilder } from "./AggregateTransaction"; -import { ChainConfigTransactionBuilder } from "./ChainConfigTransaction"; +import { NetworkConfigTransactionBuilder } from "./NetworkConfigTransaction"; import { ChainUpgradeTransactionBuilder } from "./ChainUpgradeTransaction"; import { HashLockTransactionBuilder } from "./HashLockTransaction"; import { AccountMetadataTransactionBuilder } from "./AccountMetadataTransaction"; @@ -39,7 +39,17 @@ import { PlaceSdaExchangeOfferTransactionBuilder } from "./PlaceSdaExchangeOffer import { RemoveSdaExchangeOfferTransactionBuilder } from "./RemoveSdaExchangeOfferTransaction"; import { CreateLiquidityProviderTransactionBuilder } from "./liquidityProvider/CreateLiquidityProviderTransaction"; import { ManualRateChangeTransactionBuilder } from "./liquidityProvider/ManualRateChangeTransaction"; - +import { NetworkConfigAbsoluteHeightTransactionBuilder } from "./NetworkConfigAbsoluteHeightTransaction"; +import { VrfLinkTransactionBuilder } from "./VrfLinkTransaction"; +import { NodeLinkTransactionBuilder } from "./NodeLinkTransaction"; +import { AccountV2UpgradeTransactionBuilder } from "./AccountV2UpgradeTransaction"; +import { AccountAddressRestrictionTransactionBuilder } from "./AccountAddressRestrictionTransaction"; +import { AccountMosaicRestrictionTransactionBuilder } from "./AccountMosaicRestrictionTransaction"; +import { AccountOperationRestrictionTransactionBuilder } from "./AccountOperationRestrictionTransaction"; +import { MosaicGlobalRestrictionTransactionBuilder } from "./MosaicGlobalRestrictionTransaction"; +import { MosaicAddressRestrictionTransactionBuilder } from "./MosaicAddressRestrictionTransaction"; +import { LockFundTransferTransactionBuilder } from "./LockFundTransferTransaction"; +import { LockFundCancelUnlockTransactionBuilder } from "./LockFundCancelUnlockTransaction"; export class TransactionBuilderFactory { private _networkType: NetworkType = NetworkType.MIJIN_TEST; @@ -99,6 +109,24 @@ export class TransactionBuilderFactory { return builder; } + public nodeLink(): VrfLinkTransactionBuilder { + const builder = new VrfLinkTransactionBuilder(); + this.configureBuilder(builder); + return builder; + } + + public vrfLink(): NodeLinkTransactionBuilder { + const builder = new NodeLinkTransactionBuilder(); + this.configureBuilder(builder); + return builder; + } + + public accountV2Upgrade(): AccountV2UpgradeTransactionBuilder { + const builder = new AccountV2UpgradeTransactionBuilder(); + this.configureBuilder(builder); + return builder; + } + public transfer(): TransferTransactionBuilder { const builder = new TransferTransactionBuilder(); this.configureBuilder(builder); @@ -111,18 +139,27 @@ export class TransactionBuilderFactory { return builder; } + /** + * @deprecated + */ public accountRestrictionAddress(): AccountAddressRestrictionModificationTransactionBuilder { const builder = new AccountAddressRestrictionModificationTransactionBuilder(); this.configureBuilder(builder); return builder; } + /** + * @deprecated + */ public accountRestrictionMosaic(): AccountMosaicRestrictionModificationTransactionBuilder { const builder = new AccountMosaicRestrictionModificationTransactionBuilder(); this.configureBuilder(builder); return builder; } + /** + * @deprecated + */ public accountRestrictionOperation(): AccountOperationRestrictionModificationTransactionBuilder { const builder = new AccountOperationRestrictionModificationTransactionBuilder(); this.configureBuilder(builder); @@ -147,20 +184,34 @@ export class TransactionBuilderFactory { return builder; } + /** + * @deprecated + */ public aggregateBondedV1(): AggregateBondedV1TransactionBuilder { const builder = new AggregateBondedV1TransactionBuilder(); this.configureBuilder(builder); return builder; } + /** + * @deprecated + */ public aggregateCompleteV1(): AggregateCompleteV1TransactionBuilder { const builder = new AggregateCompleteV1TransactionBuilder(); this.configureBuilder(builder); return builder; } - public chainConfig(): ChainConfigTransactionBuilder { - const builder = new ChainConfigTransactionBuilder(); + public networkConfig(): NetworkConfigTransactionBuilder { + const builder = new NetworkConfigTransactionBuilder(); + builder.networkType(this.networkType) + .generationHash(this.generationHash) + .createNewDeadlineFn(this.createNewDeadlineFn); + return builder; + } + + public networkConfigAbsoluteHeight(): NetworkConfigAbsoluteHeightTransactionBuilder { + const builder = new NetworkConfigAbsoluteHeightTransactionBuilder(); builder.networkType(this.networkType) .generationHash(this.generationHash) .createNewDeadlineFn(this.createNewDeadlineFn); @@ -306,6 +357,48 @@ export class TransactionBuilderFactory { this.configureBuilder(builder); return builder; } + + public accountAddressRestriction(): AccountAddressRestrictionTransactionBuilder{ + const builder = new AccountAddressRestrictionTransactionBuilder(); + this.configureBuilder(builder); + return builder; + } + + public accountMosaicRestriction(): AccountMosaicRestrictionTransactionBuilder{ + const builder = new AccountMosaicRestrictionTransactionBuilder(); + this.configureBuilder(builder); + return builder; + } + + public accountOperationRestriction(): AccountOperationRestrictionTransactionBuilder{ + const builder = new AccountOperationRestrictionTransactionBuilder(); + this.configureBuilder(builder); + return builder; + } + + public lockFundTransfer(): LockFundTransferTransactionBuilder{ + const builder = new LockFundTransferTransactionBuilder(); + this.configureBuilder(builder); + return builder; + } + + public lockFundCancelUnlock(): LockFundCancelUnlockTransactionBuilder{ + const builder = new LockFundCancelUnlockTransactionBuilder(); + this.configureBuilder(builder); + return builder; + } + + public mosaicAddressRestriction(): MosaicAddressRestrictionTransactionBuilder{ + const builder = new MosaicAddressRestrictionTransactionBuilder(); + this.configureBuilder(builder); + return builder; + } + + public mosaicGlobalRestriction(): MosaicGlobalRestrictionTransactionBuilder{ + const builder = new MosaicGlobalRestrictionTransactionBuilder(); + this.configureBuilder(builder); + return builder; + } } diff --git a/src/model/transaction/TransactionType.ts b/src/model/transaction/TransactionType.ts index f13e22a9..3712ad24 100644 --- a/src/model/transaction/TransactionType.ts +++ b/src/model/transaction/TransactionType.ts @@ -94,18 +94,21 @@ export enum TransactionType { /** * Account restriction address transaction type + * @deprecated * @type {number} */ MODIFY_ACCOUNT_RESTRICTION_ADDRESS = 0x4150, /** * Account restriction mosaic transaction type + * @deprecated * @type {number} */ MODIFY_ACCOUNT_RESTRICTION_MOSAIC = 0x4250, /** * Account restriction operation transaction type + * @deprecated * @type {number} */ MODIFY_ACCOUNT_RESTRICTION_OPERATION = 0x4350, @@ -213,12 +216,6 @@ export enum TransactionType { */ AGGREGATE_BONDED_V2 = 0x4441, - /** - * Account v2 upgrade transaction type - * @type {number} - */ - Account_V2_Upgrade = 0x4258, - /** * Place SDA exchange offer transaction type */ @@ -267,6 +264,11 @@ export enum TransactionType { //--------------------------------------------------------------------------------------- // ----------------------------symbol merge type----------------------------------------- + /** + * Account v2 upgrade transaction type + * @type {number} + */ + Account_V2_Upgrade = 0x4258, NetworkConfig_Absolute_Height = 0x4259, Node_Key_Link = 0x424c, Vrf_Key_Link = 0x434c, diff --git a/src/model/transaction/TransactionTypeVersion.ts b/src/model/transaction/TransactionTypeVersion.ts index d57b0186..7655d969 100644 --- a/src/model/transaction/TransactionTypeVersion.ts +++ b/src/model/transaction/TransactionTypeVersion.ts @@ -99,18 +99,21 @@ export enum TransactionTypeVersion { /** * Account Restriction address transaction version + * @deprecated * @type {number} */ MODIFY_ACCOUNT_RESTRICTION_ADDRESS = 1, /** * Account Restriction mosaic transaction version + * @deprecated * @type {number} */ MODIFY_ACCOUNT_RESTRICTION_MOSAIC = 1, /** * Account Restriction operation transaction version + * @deprecated * @type {number} */ MODIFY_ACCOUNT_RESTRICTION_ENTITY_TYPE = 1, @@ -247,4 +250,22 @@ export enum TransactionTypeVersion { Replicator_Offboarding = 1, // -------------------------------------------------------------------------------------- + + // ----------------------------symbol merge type----------------------------------------- + /** + * Account v2 upgrade transaction type + * @type {number} + */ + Account_V2_Upgrade = 1, + NetworkConfig_Absolute_Height = 1, + Node_Key_Link = 1, + Vrf_Key_Link = 1, + Lock_Fund_Transfer = 1, + Lock_Fund_Cancel_Unlock = 1, + Account_Address_Restriction = 1, + Account_Mosaic_Restriction = 1, + Account_Operation_Restriction = 1, + Mosaic_Global_Restriction = 1, + Mosaic_Address_Restriction = 1, + // -------------------------------------------------------------------------------------- } diff --git a/src/model/transaction/VrfLinkTransaction.ts b/src/model/transaction/VrfLinkTransaction.ts new file mode 100644 index 00000000..84ce1753 --- /dev/null +++ b/src/model/transaction/VrfLinkTransaction.ts @@ -0,0 +1,165 @@ +/* + * Copyright 2024 ProximaX + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Builder } from '../../infrastructure/builders/VrfLinkTransaction'; +import { TransactionBuilder } from './Transaction'; +import { VerifiableTransaction } from '../../infrastructure/builders/VerifiableTransaction'; +import { PublicAccount } from '../account/PublicAccount'; +import { NetworkType } from '../blockchain/NetworkType'; +import { UInt64 } from '../UInt64'; +import { Deadline } from './Deadline'; +import { Transaction } from './Transaction'; +import { TransactionInfo } from './TransactionInfo'; +import { TransactionType } from './TransactionType'; +import { AccountLinkAction } from "../account/AccountLink" +import { TransactionTypeVersion } from './TransactionTypeVersion'; +import { calculateFee } from './FeeCalculationStrategy'; + +/** + * Announce an VrfLinkTransaction, must use v2 account + * By doing so, you can enable delegated harvesting + */ +export class VrfLinkTransaction extends Transaction { + /** + * Create a Vrf link transaction object + * @param deadline - The deadline to include the transaction. + * @param remoteAccountKey - The public key of the v2 account. + * @param linkAction - Link or unlink + * @param maxFee - (Optional) Max fee defined by the sender + * @returns {VrfLinkTransaction} + */ + public static create(deadline: Deadline, + remoteAccountKey: string, + linkAction: AccountLinkAction, + networkType: NetworkType, + maxFee?: UInt64): VrfLinkTransaction { + return new VrfLinkTransactionBuilder() + .networkType(networkType) + .deadline(deadline) + .maxFee(maxFee) + .remoteAccountKey(remoteAccountKey) + .linkAction(linkAction) + .build(); + } + + /** + * @param networkType + * @param version + * @param deadline + * @param maxFee + * @param remoteAccountKey + * @param linkAction + * @param signature + * @param signer + * @param transactionInfo + */ + constructor(networkType: NetworkType, + version: number, + deadline: Deadline, + maxFee: UInt64, + /** + * The public key of the Vrf account + */ + public readonly remoteAccountKey: string, + public readonly linkAction: AccountLinkAction, + signature?: string, + signer?: PublicAccount, + transactionInfo?: TransactionInfo) { + super(TransactionType.Vrf_Key_Link, networkType, version, deadline, maxFee, signature, signer, transactionInfo); + } + + /** + * @override Transaction.size() + * @description get the byte size of a VrfLinkTransaction + * @returns {number} + * @memberof VrfLinkTransaction + */ + public get size(): number { + return VrfLinkTransaction.calculateSize(); + } + + public static calculateSize(): number { + const byteSize = Transaction.getHeaderSize(); + + // set static byte size fields + const bytePublicKey = 32; + + return byteSize + bytePublicKey + 1; + } + + /** + * @override Transaction.toJSON() + * @description Serialize a transaction object - add own fields to the result of Transaction.toJSON() + * @return {Object} + * @memberof VrfLinkTransaction + */ + public toJSON() { + const parent = super.toJSON(); + return { + ...parent, + transaction: { + ...parent.transaction, + remoteAccountKey: this.remoteAccountKey, + linkAction: this.linkAction + } + } + } + + /** + * @internal + * @returns {VerifiableTransaction} + */ + protected buildTransaction(): VerifiableTransaction { + return new Builder() + .addSize(this.size) + .addDeadline(this.deadline.toDTO()) + .addMaxFee(this.maxFee.toDTO()) + .addVersion(this.versionToDTO()) + .addRemoteAccountKey(this.remoteAccountKey) + .addLinkAction(this.linkAction) + .build(); + } + +} + +export class VrfLinkTransactionBuilder extends TransactionBuilder { + private _remoteAccountKey: string; + private _linkAction: AccountLinkAction; + + public remoteAccountKey(remoteAccountKey: string) { + this._remoteAccountKey = remoteAccountKey; + return this; + } + + public linkAction(linkAction: AccountLinkAction) { + this._linkAction = linkAction; + return this; + } + + public build(): VrfLinkTransaction { + return new VrfLinkTransaction( + this._networkType, + this._version || TransactionTypeVersion.Vrf_Key_Link, + this._deadline ? this._deadline : this._createNewDeadlineFn(), + this._maxFee ? this._maxFee : calculateFee(VrfLinkTransaction.calculateSize(), this._feeCalculationStrategy), + this._remoteAccountKey, + this._linkAction, + this._signature, + this._signer, + this._transactionInfo + ); + } +} diff --git a/src/model/transaction/AccountAddressRestrictionModificationTransaction.ts b/src/model/transaction/deprecated/AccountAddressRestrictionModificationTransaction.ts similarity index 88% rename from src/model/transaction/AccountAddressRestrictionModificationTransaction.ts rename to src/model/transaction/deprecated/AccountAddressRestrictionModificationTransaction.ts index a9f83b68..8ec67ed3 100644 --- a/src/model/transaction/AccountAddressRestrictionModificationTransaction.ts +++ b/src/model/transaction/deprecated/AccountAddressRestrictionModificationTransaction.ts @@ -14,20 +14,23 @@ * limitations under the License. */ -import { Builder } from '../../infrastructure/builders/AccountRestrictionsAddressTransaction'; -import {VerifiableTransaction} from '../../infrastructure/builders/VerifiableTransaction'; -import { PublicAccount } from '../account/PublicAccount'; -import { RestrictionType } from '../account/RestrictionType'; -import { NetworkType } from '../blockchain/NetworkType'; -import { UInt64 } from '../UInt64'; +import { Builder } from '../../../infrastructure/builders/AccountRestrictionsAddressTransaction'; +import {VerifiableTransaction} from '../../../infrastructure/builders/VerifiableTransaction'; +import { PublicAccount } from '../../account/PublicAccount'; +import { RestrictionType } from '../../account/RestrictionType'; +import { NetworkType } from '../../blockchain/NetworkType'; +import { UInt64 } from '../../UInt64'; import { AccountRestrictionModification } from './AccountRestrictionModification'; -import { Deadline } from './Deadline'; -import { Transaction, TransactionBuilder } from './Transaction'; -import { TransactionInfo } from './TransactionInfo'; -import { TransactionType } from './TransactionType'; -import { TransactionTypeVersion } from './TransactionTypeVersion'; -import { calculateFee } from './FeeCalculationStrategy'; +import { Deadline } from '../Deadline'; +import { Transaction, TransactionBuilder } from '../Transaction'; +import { TransactionInfo } from '../TransactionInfo'; +import { TransactionType } from '../TransactionType'; +import { TransactionTypeVersion } from '../TransactionTypeVersion'; +import { calculateFee } from '../FeeCalculationStrategy'; +/** + * @deprecated +*/ export class AccountAddressRestrictionModificationTransaction extends Transaction { /** @@ -138,6 +141,9 @@ export class AccountAddressRestrictionModificationTransaction extends Transactio } } +/** + * @deprecated +*/ export class AccountAddressRestrictionModificationTransactionBuilder extends TransactionBuilder { private _modifications: Array>; private _restrictionType: RestrictionType; diff --git a/src/model/transaction/AccountMosaicRestrictionModificationTransaction.ts b/src/model/transaction/deprecated/AccountMosaicRestrictionModificationTransaction.ts similarity index 88% rename from src/model/transaction/AccountMosaicRestrictionModificationTransaction.ts rename to src/model/transaction/deprecated/AccountMosaicRestrictionModificationTransaction.ts index ef8854bf..62d74bc3 100644 --- a/src/model/transaction/AccountMosaicRestrictionModificationTransaction.ts +++ b/src/model/transaction/deprecated/AccountMosaicRestrictionModificationTransaction.ts @@ -14,20 +14,23 @@ * limitations under the License. */ -import { Builder } from '../../infrastructure/builders/AccountRestrictionsMosaicTransaction'; -import {VerifiableTransaction} from '../../infrastructure/builders/VerifiableTransaction'; -import { PublicAccount } from '../account/PublicAccount'; -import { RestrictionType } from '../account/RestrictionType'; -import { NetworkType } from '../blockchain/NetworkType'; -import { UInt64 } from '../UInt64'; +import { Builder } from '../../../infrastructure/builders/AccountRestrictionsMosaicTransaction'; +import {VerifiableTransaction} from '../../../infrastructure/builders/VerifiableTransaction'; +import { PublicAccount } from '../../account/PublicAccount'; +import { RestrictionType } from '../../account/RestrictionType'; +import { NetworkType } from '../../blockchain/NetworkType'; +import { UInt64 } from '../../UInt64'; import { AccountRestrictionModification } from './AccountRestrictionModification'; -import { Deadline } from './Deadline'; -import { Transaction, TransactionBuilder } from './Transaction'; -import { TransactionInfo } from './TransactionInfo'; -import { TransactionType } from './TransactionType'; -import { TransactionTypeVersion } from './TransactionTypeVersion'; -import { calculateFee } from './FeeCalculationStrategy'; - +import { Deadline } from '../Deadline'; +import { Transaction, TransactionBuilder } from '../Transaction'; +import { TransactionInfo } from '../TransactionInfo'; +import { TransactionType } from '../TransactionType'; +import { TransactionTypeVersion } from '../TransactionTypeVersion'; +import { calculateFee } from '../FeeCalculationStrategy'; + +/** + * @deprecated +*/ export class AccountMosaicRestrictionModificationTransaction extends Transaction { /** @@ -139,6 +142,9 @@ export class AccountMosaicRestrictionModificationTransaction extends Transaction } +/** + * @deprecated +*/ export class AccountMosaicRestrictionModificationTransactionBuilder extends TransactionBuilder { private _modifications: Array>; private _restrictionType: RestrictionType; diff --git a/src/model/transaction/AccountOperationRestrictionModificationTransaction.ts b/src/model/transaction/deprecated/AccountOperationRestrictionModificationTransaction.ts similarity index 88% rename from src/model/transaction/AccountOperationRestrictionModificationTransaction.ts rename to src/model/transaction/deprecated/AccountOperationRestrictionModificationTransaction.ts index bd46cc0f..3b47e488 100644 --- a/src/model/transaction/AccountOperationRestrictionModificationTransaction.ts +++ b/src/model/transaction/deprecated/AccountOperationRestrictionModificationTransaction.ts @@ -14,20 +14,23 @@ * limitations under the License. */ -import { Builder } from '../../infrastructure/builders/AccountRestrictionsEntityTypeTransaction'; -import {VerifiableTransaction} from '../../infrastructure/builders/VerifiableTransaction'; -import { PublicAccount } from '../account/PublicAccount'; -import { RestrictionType } from '../account/RestrictionType'; -import { NetworkType } from '../blockchain/NetworkType'; -import { UInt64 } from '../UInt64'; +import { Builder } from '../../../infrastructure/builders/AccountRestrictionsEntityTypeTransaction'; +import {VerifiableTransaction} from '../../../infrastructure/builders/VerifiableTransaction'; +import { PublicAccount } from '../../account/PublicAccount'; +import { RestrictionType } from '../../account/RestrictionType'; +import { NetworkType } from '../../blockchain/NetworkType'; +import { UInt64 } from '../../UInt64'; import { AccountRestrictionModification } from './AccountRestrictionModification'; -import { Deadline } from './Deadline'; -import { Transaction, TransactionBuilder } from './Transaction'; -import { TransactionInfo } from './TransactionInfo'; -import { TransactionType } from './TransactionType'; -import { TransactionTypeVersion } from './TransactionTypeVersion'; -import { calculateFee } from './FeeCalculationStrategy'; - +import { Deadline } from '../Deadline'; +import { Transaction, TransactionBuilder } from '../Transaction'; +import { TransactionInfo } from '../TransactionInfo'; +import { TransactionType } from '../TransactionType'; +import { TransactionTypeVersion } from '../TransactionTypeVersion'; +import { calculateFee } from '../FeeCalculationStrategy'; + +/** + * @deprecated +*/ export class AccountOperationRestrictionModificationTransaction extends Transaction { /** @@ -138,6 +141,9 @@ export class AccountOperationRestrictionModificationTransaction extends Transact } } +/** + * @deprecated +*/ export class AccountOperationRestrictionModificationTransactionBuilder extends TransactionBuilder { private _modifications: Array>; private _restrictionType: RestrictionType; diff --git a/src/model/transaction/AccountRestrictionModification.ts b/src/model/transaction/deprecated/AccountRestrictionModification.ts similarity index 92% rename from src/model/transaction/AccountRestrictionModification.ts rename to src/model/transaction/deprecated/AccountRestrictionModification.ts index 599a61ae..3cf8b927 100644 --- a/src/model/transaction/AccountRestrictionModification.ts +++ b/src/model/transaction/deprecated/AccountRestrictionModification.ts @@ -14,10 +14,10 @@ * limitations under the License. */ -import { Address } from '../account/Address'; -import { RestrictionModificationType } from '../account/RestrictionModificationType'; -import { MosaicId } from '../mosaic/MosaicId'; -import { TransactionType } from './TransactionType'; +import { Address } from '../../account/Address'; +import { RestrictionModificationType } from '../../account/RestrictionModificationType'; +import { MosaicId } from '../../mosaic/MosaicId'; +import { TransactionType } from '../TransactionType'; export class AccountRestrictionModification { diff --git a/src/model/transaction/AccountRestrictionTransaction.ts b/src/model/transaction/deprecated/AccountRestrictionTransaction.ts similarity index 94% rename from src/model/transaction/AccountRestrictionTransaction.ts rename to src/model/transaction/deprecated/AccountRestrictionTransaction.ts index 4979730a..d4bee2fb 100644 --- a/src/model/transaction/AccountRestrictionTransaction.ts +++ b/src/model/transaction/deprecated/AccountRestrictionTransaction.ts @@ -14,15 +14,15 @@ * limitations under the License. */ -import { RestrictionType } from '../account/RestrictionType'; -import { NetworkType } from '../blockchain/NetworkType'; -import { UInt64 } from '../UInt64'; +import { RestrictionType } from '../../account/RestrictionType'; +import { NetworkType } from '../../blockchain/NetworkType'; +import { UInt64 } from '../../UInt64'; import { AccountAddressRestrictionModificationTransaction } from './AccountAddressRestrictionModificationTransaction'; import { AccountMosaicRestrictionModificationTransaction } from './AccountMosaicRestrictionModificationTransaction'; import { AccountOperationRestrictionModificationTransaction } from './AccountOperationRestrictionModificationTransaction'; import { AccountRestrictionModification } from './AccountRestrictionModification'; -import { Deadline } from './Deadline'; -import { TransactionType } from './TransactionType'; +import { Deadline } from '../Deadline'; +import { TransactionType } from '../TransactionType'; export class AccountRestrictionTransaction { /** diff --git a/src/model/transaction/ModifyMetadataTransaction.ts b/src/model/transaction/deprecated/ModifyMetadataTransaction.ts similarity index 89% rename from src/model/transaction/ModifyMetadataTransaction.ts rename to src/model/transaction/deprecated/ModifyMetadataTransaction.ts index 84045fd9..07ac58f7 100644 --- a/src/model/transaction/ModifyMetadataTransaction.ts +++ b/src/model/transaction/deprecated/ModifyMetadataTransaction.ts @@ -2,22 +2,22 @@ // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file -import { PublicAccount } from '../account/PublicAccount'; -import { NetworkType } from '../blockchain/NetworkType'; -import { UInt64 } from '../UInt64'; -import { Deadline } from './Deadline'; -import { Transaction, TransactionBuilder } from './Transaction'; -import { TransactionInfo } from './TransactionInfo'; -import { TransactionTypeVersion } from './TransactionTypeVersion'; -import { AggregateTransactionInfo } from './AggregateTransactionInfo'; -import { MetadataType } from '../metadata/oldMetadataType'; -import { VerifiableTransaction } from '../../infrastructure/builders/VerifiableTransaction'; -import { Builder } from '../../infrastructure/builders/ModifyMetadataTransaction'; -import { TransactionType } from './TransactionType'; -import { calculateFee } from './FeeCalculationStrategy'; -import { Address } from '../account/Address'; -import { MosaicId } from '../mosaic/MosaicId'; -import { NamespaceId } from '../namespace/NamespaceId'; +import { PublicAccount } from '../../account/PublicAccount'; +import { NetworkType } from '../../blockchain/NetworkType'; +import { UInt64 } from '../../UInt64'; +import { Deadline } from '../Deadline'; +import { Transaction, TransactionBuilder } from '../Transaction'; +import { TransactionInfo } from '../TransactionInfo'; +import { TransactionTypeVersion } from '../TransactionTypeVersion'; +import { AggregateTransactionInfo } from '../AggregateTransactionInfo'; +import { MetadataType } from '../../metadata/oldMetadataType'; +import { VerifiableTransaction } from '../../../infrastructure/builders/VerifiableTransaction'; +import { Builder } from '../../../infrastructure/builders/ModifyMetadataTransaction'; +import { TransactionType } from '../TransactionType'; +import { calculateFee } from '../FeeCalculationStrategy'; +import { Address } from '../../account/Address'; +import { MosaicId } from '../../mosaic/MosaicId'; +import { NamespaceId } from '../../namespace/NamespaceId'; export enum MetadataModificationType { ADD = 0, @@ -26,6 +26,7 @@ export enum MetadataModificationType { /** * Represents single metadata modification - add/remove of the key/value pair + * @deprecated * @param type * @param key * @param value diff --git a/test/core/utils/TransactionMapping.spec.ts b/test/core/utils/TransactionMapping.spec.ts index 7ed240a6..6e9afa4c 100644 --- a/test/core/utils/TransactionMapping.spec.ts +++ b/test/core/utils/TransactionMapping.spec.ts @@ -26,7 +26,7 @@ import { RestrictionModificationType } from '../../../src/model/account/Restrict import { RestrictionType } from '../../../src/model/account/RestrictionType'; import { NetworkType } from '../../../src/model/blockchain/NetworkType'; import { EncryptedMessage, MosaicMetadataTransaction, AccountMetadataTransaction, NamespaceMetadataTransaction, - ChainConfigTransaction, ChainUpgradeTransaction, MosaicModifyLevyTransaction, MosaicRemoveLevyTransaction } from '../../../src/model/model'; + NetworkConfigTransaction, ChainUpgradeTransaction, MosaicModifyLevyTransaction, MosaicRemoveLevyTransaction } from '../../../src/model/model'; import { KeyGenerator } from '../../../src/core/format/KeyGenerator'; import { MosaicId } from '../../../src/model/mosaic/MosaicId'; import { MosaicLevy } from '../../../src/model/mosaic/MosaicLevy'; @@ -38,11 +38,11 @@ import { NetworkCurrencyMosaic } from '../../../src/model/mosaic/NetworkCurrency import { AliasActionType } from '../../../src/model/namespace/AliasActionType'; import { NamespaceId } from '../../../src/model/namespace/NamespaceId'; import { NamespaceType } from '../../../src/model/namespace/NamespaceType'; -import { AccountAddressRestrictionModificationTransaction } from '../../../src/model/transaction/AccountAddressRestrictionModificationTransaction'; +import { AccountAddressRestrictionModificationTransaction } from '../../../src/model/transaction/deprecated/AccountAddressRestrictionModificationTransaction'; import { AccountLinkTransaction } from '../../../src/model/transaction/AccountLinkTransaction'; -import { AccountMosaicRestrictionModificationTransaction } from '../../../src/model/transaction/AccountMosaicRestrictionModificationTransaction'; -import { AccountRestrictionModification } from '../../../src/model/transaction/AccountRestrictionModification'; -import { AccountRestrictionTransaction } from '../../../src/model/transaction/AccountRestrictionTransaction'; +import { AccountMosaicRestrictionModificationTransaction } from '../../../src/model/transaction/deprecated/AccountMosaicRestrictionModificationTransaction'; +import { AccountRestrictionModification } from '../../../src/model/transaction/deprecated/AccountRestrictionModification'; +import { AccountRestrictionTransaction } from '../../../src/model/transaction/deprecated/AccountRestrictionTransaction'; import { AddressAliasTransaction } from '../../../src/model/transaction/AddressAliasTransaction'; import { AggregateTransaction } from '../../../src/model/transaction/AggregateTransaction'; import { Deadline } from '../../../src/model/transaction/Deadline'; @@ -678,8 +678,8 @@ describe('TransactionMapping - createFromPayload', () => { deepStrictEqual(transaction.valueDifferences, new Uint8Array([0, 0, 0, 0, 0, 49])); }) - it('should create ChainConfigTransaction transaction', () => { - const chainConfigureTransaction = ChainConfigTransaction.create( + it('should create NetworkConfigTransaction transaction', () => { + const NetworkConfigureTransaction = NetworkConfigTransaction.create( Deadline.create(), UInt64.fromHex('0123456789ABCDEF'), "some network config", @@ -687,9 +687,9 @@ describe('TransactionMapping - createFromPayload', () => { NetworkType.MIJIN_TEST ); - const signedTransaction = chainConfigureTransaction.preV2SignWith(account, generationHash); + const signedTransaction = NetworkConfigureTransaction.preV2SignWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as ChainConfigTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as NetworkConfigTransaction; expect(transaction.applyHeightDelta.toHex()).to.be.equal('0123456789ABCDEF'); expect(transaction.networkConfig).to.be.equal("some network config"); diff --git a/test/infrastructure/ChainConfigHttp.spec.ts b/test/infrastructure/ConfigHttp.spec.ts similarity index 78% rename from test/infrastructure/ChainConfigHttp.spec.ts rename to test/infrastructure/ConfigHttp.spec.ts index 9f504b62..582bf7a4 100644 --- a/test/infrastructure/ChainConfigHttp.spec.ts +++ b/test/infrastructure/ConfigHttp.spec.ts @@ -1,17 +1,17 @@ import * as chai from 'chai'; import * as spies from 'chai-spies'; -import { ChainConfigHttp } from '../../src/infrastructure/infrastructure'; +import { NetworkConfigHttp } from '../../src/infrastructure/infrastructure'; import { UInt64 } from '../../src/model/model'; chai.use(spies); const expect = chai.expect; -const client = new ChainConfigHttp('http://nonexistent:0'); +const client = new NetworkConfigHttp('http://nonexistent:0'); const sandbox = (chai as any).spy.sandbox(); -describe('ChainConfigHttp', () => { +describe('NetworkConfigHttp', () => { - describe('getChainConfig', () => { + describe('getNetworkConfig', () => { const dto = { networkConfig: { height: UInt64.fromUint(666).toDTO(), @@ -26,7 +26,7 @@ describe('ChainConfigHttp', () => { sandbox.restore(); }); it('should call api client', (done) => { - client.getChainConfig(666).subscribe(response => { + client.getNetworkConfig(666).subscribe(response => { expect(response.height.compact()).to.be.equal(666); expect(response.networkConfig).to.be.equal('some network config'); expect(response.supportedEntityVersions).to.be.equal('some supported entity versions'); diff --git a/test/infrastructure/SerializeTransactionToJSON.spec.ts b/test/infrastructure/SerializeTransactionToJSON.spec.ts index b7f7b744..b0d2e69b 100644 --- a/test/infrastructure/SerializeTransactionToJSON.spec.ts +++ b/test/infrastructure/SerializeTransactionToJSON.spec.ts @@ -31,8 +31,8 @@ import { NetworkCurrencyMosaic } from '../../src/model/mosaic/NetworkCurrencyMos import { AliasActionType } from '../../src/model/namespace/AliasActionType'; import { NamespaceId } from '../../src/model/namespace/NamespaceId'; import { AccountLinkTransaction } from '../../src/model/transaction/AccountLinkTransaction'; -import { AccountRestrictionModification } from '../../src/model/transaction/AccountRestrictionModification'; -import { AccountRestrictionTransaction } from '../../src/model/transaction/AccountRestrictionTransaction'; +import { AccountRestrictionModification } from '../../src/model/transaction/deprecated/AccountRestrictionModification'; +import { AccountRestrictionTransaction } from '../../src/model/transaction/deprecated/AccountRestrictionTransaction'; import { AddressAliasTransaction } from '../../src/model/transaction/AddressAliasTransaction'; import { AggregateTransaction } from '../../src/model/transaction/AggregateTransaction'; import { Deadline } from '../../src/model/transaction/Deadline'; @@ -56,7 +56,7 @@ import { TestingAccount } from '../conf/conf.spec'; import { deepStrictEqual } from 'assert'; import { KeyGenerator } from '../../src/core/format/KeyGenerator' import { NamespaceType, MosaicMetadataTransaction, NamespaceMetadataTransaction, AccountMetadataTransaction, - ChainUpgradeTransaction, ChainConfigTransaction, MosaicLevy, MosaicLevyType, MosaicModifyLevyTransaction } from '../../src/model/model'; + ChainUpgradeTransaction, NetworkConfigTransaction, MosaicLevy, MosaicLevyType, MosaicModifyLevyTransaction } from '../../src/model/model'; describe('SerializeTransactionToJSON', () => { let account: Account; @@ -566,8 +566,8 @@ describe('SerializeTransactionToJSON', () => { }); - it('should create ChainConfigTransaction', () => { - const chainConfigureTransaction = ChainConfigTransaction.create( + it('should create NetworkConfigTransaction', () => { + const NetworkConfigureTransaction = NetworkConfigTransaction.create( Deadline.create(), UInt64.fromUint(12345678901234567890), 'some-network-config', @@ -575,7 +575,7 @@ describe('SerializeTransactionToJSON', () => { NetworkType.MIJIN_TEST ); - const json = chainConfigureTransaction.toJSON(); + const json = NetworkConfigureTransaction.toJSON(); expect(json.transaction.type).to.be.equal(TransactionType.CHAIN_CONFIGURE); deepStrictEqual(json.transaction.applyHeightDelta, UInt64.fromUint(12345678901234567890).toDTO()); diff --git a/test/model/account/AccountInfo.spec.ts b/test/model/account/AccountInfo.spec.ts index 0678d40a..3b0b6d25 100644 --- a/test/model/account/AccountInfo.spec.ts +++ b/test/model/account/AccountInfo.spec.ts @@ -30,6 +30,7 @@ describe('AccountInfo', () => { it('should createComplete an AccountInfo object', () => { const accountInfoDTO = { account: { + version: 1, accountType: AccountLinkTypeEnum.NUMBER_1, linkedAccountKey: '0'.repeat(64), address: Address.createFromEncoded('9050B9837EFAB4BBE8A4B9BB32D812F9885C00D8FC1650E142'), @@ -40,8 +41,13 @@ describe('AccountInfo', () => { amount: new UInt64([1830592442, 94387]), id: new MosaicId([3646934825, 3576016193]), }], + lockedMosaics: [{ + amount: new UInt64([1830592442, 94387]), + id: new MosaicId([3646934825, 3576016193]), + }], publicKey: '846B4439154579A5903B1459C9CF69CB8153F6D0110A7A0ED61DE29AE4810BF2', publicKeyHeight: new UInt64([13, 0]), + supplementalPublicKeys: {} }, meta: {}, }; @@ -53,8 +59,11 @@ describe('AccountInfo', () => { accountInfoDTO.account.publicKey, accountInfoDTO.account.publicKeyHeight, accountInfoDTO.account.accountType.valueOf(), + accountInfoDTO.account.mosaics.map((mosaicDTO) => new Mosaic(mosaicDTO.id, mosaicDTO.amount)), + accountInfoDTO.account.lockedMosaics.map((mosaicDTO) => new Mosaic(mosaicDTO.id, mosaicDTO.amount)), accountInfoDTO.account.linkedAccountKey, - accountInfoDTO.account.mosaics.map((mosaicDTO) => new Mosaic(mosaicDTO.id, mosaicDTO.amount)) + accountInfoDTO.account.supplementalPublicKeys, + accountInfoDTO.account.version ); expect(accountInfo.meta).to.be.equal(accountInfoDTO.meta); @@ -81,8 +90,17 @@ describe('AccountInfo', () => { amount: new UInt64([1830592442, 94387]), id: new MosaicId([3646934825, 3576016193]), }], + lockedMosaics: [{ + amount: new UInt64([1830592442, 94387]), + id: new MosaicId([3646934825, 3576016193]), + }], publicKey: '846B4439154579A5903B1459C9CF69CB8153F6D0110A7A0ED61DE29AE4810BF2', publicKeyHeight: new UInt64([13, 0]), + supplementalPublicKeys: { + linked: PublicAccount.createFromPublicKey("AB".repeat(32), NetworkType.MIJIN_TEST), + node: PublicAccount.createFromPublicKey("AC".repeat(32), NetworkType.MIJIN_TEST), + vrf: PublicAccount.createFromPublicKey("AD".repeat(32), NetworkType.MIJIN_TEST), + } }, meta: {}, }; @@ -94,8 +112,10 @@ describe('AccountInfo', () => { accountInfoDTO.account.publicKey, accountInfoDTO.account.publicKeyHeight, accountInfoDTO.account.accountType.valueOf(), - accountInfoDTO.account.linkedAccountKey, accountInfoDTO.account.mosaics.map((mosaicDTO) => new Mosaic(mosaicDTO.id, mosaicDTO.amount)), + accountInfoDTO.account.lockedMosaics.map((mosaicDTO) => new Mosaic(mosaicDTO.id, mosaicDTO.amount)), + accountInfoDTO.account.linkedAccountKey, + accountInfoDTO.account.supplementalPublicKeys, accountInfoDTO.account.version ); diff --git a/test/model/transaction/AccountRestrictionTransaction.spec.ts b/test/model/transaction/AccountRestrictionTransaction.spec.ts index 293a8768..2c2614e8 100644 --- a/test/model/transaction/AccountRestrictionTransaction.spec.ts +++ b/test/model/transaction/AccountRestrictionTransaction.spec.ts @@ -21,8 +21,8 @@ import { RestrictionModificationType } from '../../../src/model/account/Restrict import { RestrictionType } from '../../../src/model/account/RestrictionType'; import {NetworkType} from '../../../src/model/blockchain/NetworkType'; import {MosaicId} from '../../../src/model/mosaic/MosaicId'; -import { AccountRestrictionModification } from '../../../src/model/transaction/AccountRestrictionModification'; -import {AccountRestrictionTransaction} from '../../../src/model/transaction/AccountRestrictionTransaction'; +import { AccountRestrictionModification } from '../../../src/model/transaction/deprecated/AccountRestrictionModification'; +import {AccountRestrictionTransaction} from '../../../src/model/transaction/deprecated/AccountRestrictionTransaction'; import {Deadline} from '../../../src/model/transaction/Deadline'; import { TransactionType } from '../../../src/model/transaction/TransactionType'; import {UInt64} from '../../../src/model/UInt64'; diff --git a/test/model/transaction/ChainConfigTransaction.spec.ts b/test/model/transaction/NetworkConfigTransaction.spec.ts similarity index 73% rename from test/model/transaction/ChainConfigTransaction.spec.ts rename to test/model/transaction/NetworkConfigTransaction.spec.ts index 7891abec..4167c5e4 100644 --- a/test/model/transaction/ChainConfigTransaction.spec.ts +++ b/test/model/transaction/NetworkConfigTransaction.spec.ts @@ -8,27 +8,27 @@ import {NetworkType} from '../../../src/model/blockchain/NetworkType'; import {Deadline} from '../../../src/model/transaction/Deadline'; import {UInt64} from '../../../src/model/UInt64'; import {TestingAccount} from '../../conf/conf.spec'; -import { ChainConfigTransaction } from '../../../src/model/model'; +import { NetworkConfigTransaction } from '../../../src/model/model'; -describe('ChainConfigTransaction', () => { +describe('NetworkConfigTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; before(() => { account = TestingAccount; }); describe('size', () => { - it('should return 186 for ChainConfigTransaction byte size with some config values', () => { + it('should return 186 for NetworkConfigTransaction byte size with some config values', () => { - const chainConfigTransaction = ChainConfigTransaction.create( + const networkConfigTransaction = NetworkConfigTransaction.create( Deadline.create(), UInt64.fromHex("1234567812345678"), "some blockchain config", "some supported entity versions", NetworkType.MIJIN_TEST ); - const signedTransaction = chainConfigTransaction.preV2SignWith(account, generationHash); + const signedTransaction = networkConfigTransaction.preV2SignWith(account, generationHash); - expect(chainConfigTransaction.size).to.be.equal(186); + expect(networkConfigTransaction.size).to.be.equal(186); expect(signedTransaction.payload.length).to.be.equal(186 * 2); expect(signedTransaction.payload.substring( 244, From b97d5fd1452b2ca70032dcf207e24c1f24ef81fe Mon Sep 17 00:00:00 2001 From: Chun Lam Date: Fri, 19 Apr 2024 21:02:26 +0800 Subject: [PATCH 2/3] bump version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index bb5ddd0a..ad5d0802 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tsjs-xpx-chain-sdk", - "version": "0.11.1", + "version": "0.11.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "tsjs-xpx-chain-sdk", - "version": "0.11.1", + "version": "0.11.2", "license": "Apache-2.0", "dependencies": { "@js-joda/core": "^4.0.0", diff --git a/package.json b/package.json index d3613a48..f66731d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tsjs-xpx-chain-sdk", - "version": "0.11.1", + "version": "0.11.2", "description": "Proximax Blockchain sdk for typescript and javascript", "scripts": { "pretest": "npm run build", From 32cb36453378a6240afffcf704e41e6faffed50e Mon Sep 17 00:00:00 2001 From: Chun Lam Date: Sat, 20 Apr 2024 13:21:10 +0800 Subject: [PATCH 3/3] remove account default version --- src/model/account/Account.ts | 6 +++--- test/model/account/Account.spec.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/model/account/Account.ts b/src/model/account/Account.ts index 3904d3d2..661cf6ee 100644 --- a/src/model/account/Account.ts +++ b/src/model/account/Account.ts @@ -1,5 +1,5 @@ /* - * Copyright 2023 ProximaX + * Copyright 2024 ProximaX * Copyright 2018 NEM * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -56,7 +56,7 @@ export class Account { /** * The account version. */ - public readonly version: number = 1){ + public readonly version: number){ } /** @@ -162,7 +162,7 @@ export class Account { * @param networkType - Network type * @param version - Account version */ - public static generateNewAccount(networkType: NetworkType, version: number = 2): Account { + public static generateNewAccount(networkType: NetworkType, version: number): Account { // Create random bytes const randomBytesArray = Crypto.randomBytes(32); // Hash random bytes with entropy seed diff --git a/test/model/account/Account.spec.ts b/test/model/account/Account.spec.ts index 6117aead..dad9bac5 100644 --- a/test/model/account/Account.spec.ts +++ b/test/model/account/Account.spec.ts @@ -42,7 +42,7 @@ describe('Account', () => { }); it('should generate a new account', () => { - const account = Account.generateNewAccount(NetworkType.MIJIN_TEST); + const account = Account.generateNewAccount(NetworkType.MIJIN_TEST, 1); expect(account.publicKey).to.not.be.equal(undefined); expect(account.privateKey).to.not.be.equal(undefined); expect(account.address).to.not.be.equal(undefined);