diff --git a/README.md b/README.md index 51fe7a18d7..177e5fd8a0 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,101 @@ Important versions listed below. Refer to the [Changelog](CHANGELOG.md) for a fu - [0.10.1-beta](CHANGELOG.md#v0101-beta) - **Alpaca compatible** 07.2018 - [0.9.5](CHANGELOG.md#095-27-Jun-2018) - **Alpaca compatible** 07.2018 +## Notes on generation of catapult-rest DTO and API client + +Following command can be used to generate DTOs and Api clients for the [nem2-sdk-typescript-javascript](https://github.com/nemtech/nem2-sdk-typescript-javascript) : + +1. Download latest NEM2 swagger definition + ```bash + $ git clone git@github.com:nemtech/nem2-docs + $ cd nem2-docs && mkdir sdks && cd sdks + $ cp ../source/resources/collections/swagger.yaml . + ``` + 2. Copy OpenAPI generator template + + Copy the `templates` folder from {nem2-sdk-typescript-javascript}/infrastructure/ into `sdk` folder + +3. Download OpenAPI generator and generate codes + ```bash + $ brew install openapi-generator + $ openapi-generator generate -i ./swagger2.yaml -g typescript-node -t templates/ -o ./nem2-ts-sdk/ && rm -R nem2-ts-sdk/test + ``` + ** Note openapi-generator is also available on docker. (`https://hub.docker.com/r/openapitools/openapi-generator`) +4. Fix enum type definitions + + As the generator doesn't recognize `enum` type alias, we need to manually move enum classes in to the `enumsMap` list. + - Open generated file `./nem2-ts-sdk/model/models.ts` in editor + - Search for line contains `let enumsMap: {[index: string]: any}`. + - Move all `xxxTypeEnum` entries from below `typeMap` into `enumsMap`. + + example below: + ```js + let enumsMap: {[index: string]: any} = { + "AccountPropertyTypeEnum": AccountPropertyTypeEnum, + "AliasTypeEnum": AliasTypeEnum, + "ResolutionStatementDTO": ResolutionStatementDTO, + "MosaicPropertyIdEnum": MosaicPropertyIdEnum, + "MultisigModificationTypeEnum": MultisigModificationTypeEnum, + "NamespaceTypeEnum": NamespaceTypeEnum, + "ReceiptTypeEnum": ReceiptTypeEnum, + "RolesTypeEnum": RolesTypeEnum, + } + + let typeMap: {[index: string]: any} = { + "AccountDTO": AccountDTO, + "AccountIds": AccountIds, + "AccountInfoDTO": AccountInfoDTO, + "AccountMetaDTO": AccountMetaDTO, + "AccountNamesDTO": AccountNamesDTO, + "AccountPropertiesDTO": AccountPropertiesDTO, + "AccountPropertiesInfoDTO": AccountPropertiesInfoDTO, + "AccountPropertyDTO": AccountPropertyDTO, + "AliasDTO": AliasDTO, + "AnnounceTransactionInfoDTO": AnnounceTransactionInfoDTO, + "BlockDTO": BlockDTO, + "BlockInfoDTO": BlockInfoDTO, + "BlockMetaDTO": BlockMetaDTO, + "BlockchainScoreDTO": BlockchainScoreDTO, + "CommunicationTimestamps": CommunicationTimestamps, + "Cosignature": Cosignature, + "HeightInfoDTO": HeightInfoDTO, + "MerklePathItem": MerklePathItem, + "MerkleProofInfo": MerkleProofInfo, + "MerkleProofInfoDTO": MerkleProofInfoDTO, + "MosaicDTO": MosaicDTO, + "MosaicDefinitionDTO": MosaicDefinitionDTO, + "MosaicIds": MosaicIds, + "MosaicInfoDTO": MosaicInfoDTO, + "MosaicMetaDTO": MosaicMetaDTO, + "MosaicNamesDTO": MosaicNamesDTO, + "MosaicPropertyDTO": MosaicPropertyDTO, + "MultisigAccountGraphInfoDTO": MultisigAccountGraphInfoDTO, + "MultisigAccountInfoDTO": MultisigAccountInfoDTO, + "MultisigDTO": MultisigDTO, + "NamespaceDTO": NamespaceDTO, + "NamespaceIds": NamespaceIds, + "NamespaceInfoDTO": NamespaceInfoDTO, + "NamespaceMetaDTO": NamespaceMetaDTO, + "NamespaceNameDTO": NamespaceNameDTO, + "NetworkTypeDTO": NetworkTypeDTO, + "NodeInfoDTO": NodeInfoDTO, + "NodeTimeDTO": NodeTimeDTO, + "ResolutionEntryDTO": ResolutionEntryDTO, + "ServerDTO": ServerDTO, + "ServerInfoDTO": ServerInfoDTO, + "SourceDTO": SourceDTO, + "StatementsDTO": StatementsDTO, + "StorageInfoDTO": StorageInfoDTO, + "TransactionHashes": TransactionHashes, + "TransactionIds": TransactionIds, + "TransactionInfoDTO": TransactionInfoDTO, + "TransactionMetaDTO": TransactionMetaDTO, + "TransactionPayload": TransactionPayload, + "TransactionStatementDTO": TransactionStatementDTO, + "TransactionStatusDTO": TransactionStatusDTO, + } + ``` + ## License Copyright (c) 2018-2019 NEM diff --git a/e2e/infrastructure/AccountHttp.spec.ts b/e2e/infrastructure/AccountHttp.spec.ts index 80eae45c09..5dcf195e29 100644 --- a/e2e/infrastructure/AccountHttp.spec.ts +++ b/e2e/infrastructure/AccountHttp.spec.ts @@ -444,37 +444,6 @@ describe('AccountHttp', () => { }); }); - describe('Remove test AddressAlias', () => { - let listener: Listener; - before (() => { - listener = new Listener(config.apiUrl); - return listener.open(); - }); - after(() => { - return listener.close(); - }); - - it('Announce addressAliasTransaction', (done) => { - const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), - AliasActionType.Unlink, - namespaceId, - account.address, - NetworkType.MIJIN_TEST, - ); - const signedTransaction = addressAliasTransaction.signWith(account, generationHash); - - listener.confirmed(account.address).subscribe(() => { - done(); - }); - listener.status(account.address).subscribe((error) => { - console.log('Error:', error); - assert(false); - done(); - }); - transactionHttp.announce(signedTransaction); - }); - }); describe('Restore test multisig Accounts', () => { let listener: Listener; before (() => { diff --git a/e2e/infrastructure/MosaicHttp.spec.ts b/e2e/infrastructure/MosaicHttp.spec.ts index 183a09cc97..8277aae662 100644 --- a/e2e/infrastructure/MosaicHttp.spec.ts +++ b/e2e/infrastructure/MosaicHttp.spec.ts @@ -70,7 +70,6 @@ describe('MosaicHttp', () => { it('Announce MosaicDefinitionTransaction', (done) => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, account.publicAccount); - console.log(mosaicId.toHex()); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( Deadline.create(), nonce, diff --git a/e2e/infrastructure/TransactionHttp.spec.ts b/e2e/infrastructure/TransactionHttp.spec.ts index c94cca7fdc..dfd5019b00 100644 --- a/e2e/infrastructure/TransactionHttp.spec.ts +++ b/e2e/infrastructure/TransactionHttp.spec.ts @@ -17,7 +17,8 @@ import {assert, expect} from 'chai'; import * as CryptoJS from 'crypto-js'; import {ChronoUnit} from 'js-joda'; import {keccak_256, sha3_256} from 'js-sha3'; -import {convert, nacl_catapult} from 'nem2-library'; +import {Crypto} from '../../src/core/crypto'; +import { Convert as convert } from '../../src/core/format'; import {AccountHttp} from '../../src/infrastructure/AccountHttp'; import { NamespaceHttp } from '../../src/infrastructure/infrastructure'; import {Listener} from '../../src/infrastructure/Listener'; @@ -66,7 +67,6 @@ import {Transaction} from '../../src/model/transaction/Transaction'; import {TransactionType} from '../../src/model/transaction/TransactionType'; import {TransferTransaction} from '../../src/model/transaction/TransferTransaction'; import {UInt64} from '../../src/model/UInt64'; - describe('TransactionHttp', () => { let transactionHash; let transactionId; @@ -992,7 +992,7 @@ describe('TransactionHttp', () => { NetworkCurrencyMosaic.createAbsolute(10), UInt64.fromUint(100), HashType.Op_Sha3_256, - sha3_256.create().update(nacl_catapult.randomBytes(20)).hex(), + sha3_256.create().update(Crypto.randomBytes(20)).hex(), account2.address, NetworkType.MIJIN_TEST, ); @@ -1028,7 +1028,7 @@ describe('TransactionHttp', () => { NetworkCurrencyMosaic.createAbsolute(10), UInt64.fromUint(100), HashType.Op_Sha3_256, - sha3_256.create().update(nacl_catapult.randomBytes(20)).hex(), + sha3_256.create().update(Crypto.randomBytes(20)).hex(), account2.address, NetworkType.MIJIN_TEST, ); @@ -1062,7 +1062,7 @@ describe('TransactionHttp', () => { NetworkCurrencyMosaic.createAbsolute(10), UInt64.fromUint(100), HashType.Op_Keccak_256, - sha3_256.create().update(nacl_catapult.randomBytes(20)).hex(), + sha3_256.create().update(Crypto.randomBytes(20)).hex(), account2.address, NetworkType.MIJIN_TEST, ); @@ -1092,7 +1092,7 @@ describe('TransactionHttp', () => { NetworkCurrencyMosaic.createAbsolute(10), UInt64.fromUint(100), HashType.Op_Keccak_256, - sha3_256.create().update(nacl_catapult.randomBytes(20)).hex(), + sha3_256.create().update(Crypto.randomBytes(20)).hex(), account2.address, NetworkType.MIJIN_TEST, ); @@ -1121,7 +1121,7 @@ describe('TransactionHttp', () => { return listener.close(); }); it('standalone', (done) => { - const secretSeed = String.fromCharCode.apply(null, nacl_catapult.randomBytes(20)); + const secretSeed = String.fromCharCode.apply(null, Crypto.randomBytes(20)); const secret = CryptoJS.RIPEMD160(CryptoJS.SHA256(secretSeed).toString(CryptoJS.enc.Hex)).toString(CryptoJS.enc.Hex); const secretLockTransaction = SecretLockTransaction.create( Deadline.create(), @@ -1153,7 +1153,7 @@ describe('TransactionHttp', () => { return listener.close(); }); it('aggregate', (done) => { - const secretSeed = String.fromCharCode.apply(null, nacl_catapult.randomBytes(20)); + const secretSeed = String.fromCharCode.apply(null, Crypto.randomBytes(20)); const secret = CryptoJS.RIPEMD160(CryptoJS.SHA256(secretSeed).toString(CryptoJS.enc.Hex)).toString(CryptoJS.enc.Hex); const secretLockTransaction = SecretLockTransaction.create( Deadline.create(), @@ -1194,7 +1194,7 @@ describe('TransactionHttp', () => { NetworkCurrencyMosaic.createAbsolute(10), UInt64.fromUint(100), HashType.Op_Hash_256, - sha3_256.create().update(nacl_catapult.randomBytes(20)).hex(), + sha3_256.create().update(Crypto.randomBytes(20)).hex(), account2.address, NetworkType.MIJIN_TEST, ); @@ -1224,7 +1224,7 @@ describe('TransactionHttp', () => { NetworkCurrencyMosaic.createAbsolute(10), UInt64.fromUint(100), HashType.Op_Hash_256, - sha3_256.create().update(nacl_catapult.randomBytes(20)).hex(), + sha3_256.create().update(Crypto.randomBytes(20)).hex(), account2.address, NetworkType.MIJIN_TEST, ); @@ -1253,7 +1253,7 @@ describe('TransactionHttp', () => { return listener.close(); }); it('standalone', (done) => { - const secretSeed = nacl_catapult.randomBytes(20); + const secretSeed = Crypto.randomBytes(20); const secret = sha3_256.create().update(secretSeed).hex(); const proof = convert.uint8ToHex(secretSeed); @@ -1304,7 +1304,7 @@ describe('TransactionHttp', () => { return listener.close(); }); it('aggregate', (done) => { - const secretSeed = nacl_catapult.randomBytes(20); + const secretSeed = Crypto.randomBytes(20); const secret = sha3_256.create().update(secretSeed).hex(); const proof = convert.uint8ToHex(secretSeed); const secretLockTransaction = SecretLockTransaction.create( @@ -1352,7 +1352,7 @@ describe('TransactionHttp', () => { return listener.close(); }); it('standalone', (done) => { - const secretSeed = nacl_catapult.randomBytes(20); + const secretSeed = Crypto.randomBytes(20); const secret = keccak_256.create().update(secretSeed).hex(); const proof = convert.uint8ToHex(secretSeed); const secretLockTransaction = SecretLockTransaction.create( @@ -1396,7 +1396,7 @@ describe('TransactionHttp', () => { return listener.close(); }); it('aggregate', (done) => { - const secretSeed = nacl_catapult.randomBytes(20); + const secretSeed = Crypto.randomBytes(20); const secret = keccak_256.create().update(secretSeed).hex(); const proof = convert.uint8ToHex(secretSeed); const secretLockTransaction = SecretLockTransaction.create( @@ -1704,8 +1704,8 @@ describe('TransactionHttp', () => { transactionHttp.getTransactionStatus(transactionHash) .subscribe((transactionStatus) => { expect(transactionStatus.group).to.be.equal('confirmed'); - expect(transactionStatus.height.lower).to.be.greaterThan(0); - expect(transactionStatus.height.higher).to.be.equal(0); + expect(transactionStatus.height!.lower).to.be.greaterThan(0); + expect(transactionStatus.height!.higher).to.be.equal(0); done(); }); }); @@ -1716,8 +1716,8 @@ describe('TransactionHttp', () => { transactionHttp.getTransactionsStatuses([transactionHash]) .subscribe((transactionStatuses) => { expect(transactionStatuses[0].group).to.be.equal('confirmed'); - expect(transactionStatuses[0].height.lower).to.be.greaterThan(0); - expect(transactionStatuses[0].height.higher).to.be.equal(0); + expect(transactionStatuses[0].height!.lower).to.be.greaterThan(0); + expect(transactionStatuses[0].height!.higher).to.be.equal(0); done(); }); }); diff --git a/index.ts b/index.ts index 7c61994968..1239bbb0f5 100644 --- a/index.ts +++ b/index.ts @@ -18,3 +18,5 @@ export * from './src/infrastructure/infrastructure'; export * from './src/model/model'; export * from './src/service/service'; export * from './src/core/utils/utility'; +export * from './src/core/format'; +export * from './src/core/crypto'; diff --git a/package-lock.json b/package-lock.json index 853db9cb88..4c2ec1ce45 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,8 @@ "@types/crypto-js": { "version": "3.1.43", "resolved": "https://registry.npmjs.org/@types/crypto-js/-/crypto-js-3.1.43.tgz", - "integrity": "sha512-EHe/YKctU3IYNBsDmSOPX/7jLHPRlx8WaiDKSY9JCTnJ8XJeM4c0ZJvx+9Gxmr2s2ihI92R+3U/gNL1sq5oRuQ==" + "integrity": "sha512-EHe/YKctU3IYNBsDmSOPX/7jLHPRlx8WaiDKSY9JCTnJ8XJeM4c0ZJvx+9Gxmr2s2ihI92R+3U/gNL1sq5oRuQ==", + "dev": true }, "@types/form-data": { "version": "2.2.1", @@ -122,7 +123,8 @@ "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true }, "ansi-styles": { "version": "2.2.1", @@ -155,26 +157,12 @@ "buffer-equal": "^1.0.0" } }, - "aproba": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", - "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==" - }, "archy": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", "dev": true }, - "are-we-there-yet": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", - "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", - "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" - } - }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -303,17 +291,6 @@ "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=" }, - "asn1.js": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", - "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", - "optional": true, - "requires": { - "bn.js": "^4.0.0", - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0" - } - }, "assert": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz", @@ -505,25 +482,10 @@ "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", "dev": true }, - "bindings": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.1.tgz", - "integrity": "sha512-i47mqjF9UbjxJhxGf+pZ6kSxrnI3wBLlnGI2ArWJ4r0VrvDS7ZYXkprq/pLaBWYq4GM0r4zdHY+NNRqEMU7uew==" - }, - "bl": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", - "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", - "requires": { - "readable-stream": "^2.3.5", - "safe-buffer": "^5.1.1" - } - }, - "bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "optional": true + "bluebird": { + "version": "3.5.5", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz", + "integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==" }, "boom": { "version": "4.3.1", @@ -572,135 +534,24 @@ } } }, - "brorand": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", - "optional": true - }, "browser-stdout": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", "dev": true }, - "browserify-aes": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", - "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", - "optional": true, - "requires": { - "buffer-xor": "^1.0.3", - "cipher-base": "^1.0.0", - "create-hash": "^1.1.0", - "evp_bytestokey": "^1.0.3", - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } - }, - "browserify-cipher": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", - "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", - "optional": true, - "requires": { - "browserify-aes": "^1.0.4", - "browserify-des": "^1.0.0", - "evp_bytestokey": "^1.0.0" - } - }, - "browserify-des": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", - "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", - "optional": true, - "requires": { - "cipher-base": "^1.0.1", - "des.js": "^1.0.0", - "inherits": "^2.0.1", - "safe-buffer": "^5.1.2" - }, - "dependencies": { - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "optional": true - } - } - }, - "browserify-rsa": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", - "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", - "optional": true, - "requires": { - "bn.js": "^4.1.0", - "randombytes": "^2.0.1" - } - }, - "browserify-sign": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz", - "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", - "optional": true, - "requires": { - "bn.js": "^4.1.1", - "browserify-rsa": "^4.0.0", - "create-hash": "^1.1.0", - "create-hmac": "^1.1.2", - "elliptic": "^6.0.0", - "inherits": "^2.0.1", - "parse-asn1": "^5.0.0" - } - }, - "buffer-alloc": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", - "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==", - "requires": { - "buffer-alloc-unsafe": "^1.1.0", - "buffer-fill": "^1.0.0" - } - }, - "buffer-alloc-unsafe": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz", - "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==" - }, "buffer-equal": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.0.tgz", "integrity": "sha1-WWFrSYME1Var1GaWayLu2j7KX74=", "dev": true }, - "buffer-fill": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", - "integrity": "sha1-+PeLdniYiO858gXNY39o5wISKyw=" - }, "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, - "buffer-xor": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", - "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", - "optional": true - }, - "bufferutil": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-3.0.5.tgz", - "integrity": "sha512-0fUEthLqfCkYspEuP0vmiAe+PsXslE+AlILb2rmS9I4tAdm3SmpCI69M66zQL20GQEszdbXyVN6q+cpG/yhYlg==", - "requires": { - "bindings": "~1.3.0", - "nan": "~2.10.0", - "prebuild-install": "~4.0.0" - } - }, "builtin-modules": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", @@ -796,21 +647,6 @@ } } }, - "chownr": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", - "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==" - }, - "cipher-base": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", - "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", - "optional": true, - "requires": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } - }, "class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", @@ -882,7 +718,8 @@ "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "dev": true }, "collection-map": { "version": "1.0.0", @@ -943,7 +780,8 @@ "component-emitter": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", - "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=" + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "dev": true }, "concat-map": { "version": "0.0.1", @@ -963,11 +801,6 @@ "typedarray": "^0.0.6" } }, - "console-control-strings": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" - }, "convert-source-map": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz", @@ -977,11 +810,6 @@ "safe-buffer": "~5.1.1" } }, - "cookiejar": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.2.tgz", - "integrity": "sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA==" - }, "copy-descriptor": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", @@ -1016,43 +844,6 @@ "request": "^2.79.0" } }, - "create-ecdh": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", - "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", - "optional": true, - "requires": { - "bn.js": "^4.1.0", - "elliptic": "^6.0.0" - } - }, - "create-hash": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", - "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", - "optional": true, - "requires": { - "cipher-base": "^1.0.1", - "inherits": "^2.0.1", - "md5.js": "^1.3.4", - "ripemd160": "^2.0.1", - "sha.js": "^2.4.0" - } - }, - "create-hmac": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", - "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", - "optional": true, - "requires": { - "cipher-base": "^1.0.3", - "create-hash": "^1.1.0", - "inherits": "^2.0.1", - "ripemd160": "^2.0.0", - "safe-buffer": "^5.0.1", - "sha.js": "^2.4.8" - } - }, "cryptiles": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", @@ -1071,25 +862,6 @@ } } }, - "crypto-browserify": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", - "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", - "optional": true, - "requires": { - "browserify-cipher": "^1.0.0", - "browserify-sign": "^4.0.0", - "create-ecdh": "^4.0.0", - "create-hash": "^1.1.0", - "create-hmac": "^1.1.0", - "diffie-hellman": "^5.0.0", - "inherits": "^2.0.1", - "pbkdf2": "^3.0.3", - "public-encrypt": "^4.0.0", - "randombytes": "^2.0.0", - "randomfill": "^1.0.3" - } - }, "crypto-js": { "version": "3.1.9-1", "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-3.1.9-1.tgz", @@ -1112,21 +884,6 @@ "assert-plus": "^1.0.0" } }, - "debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", - "requires": { - "ms": "^2.1.1" - }, - "dependencies": { - "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" - } - } - }, "decamelize": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", @@ -1139,14 +896,6 @@ "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", "dev": true }, - "decompress-response": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz", - "integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=", - "requires": { - "mimic-response": "^1.0.0" - } - }, "deep-eql": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", @@ -1156,11 +905,6 @@ "type-detect": "^4.0.0" } }, - "deep-extend": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", - "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==" - }, "default-compare": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/default-compare/-/default-compare-1.0.0.tgz", @@ -1239,49 +983,18 @@ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, - "delegates": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" - }, - "des.js": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.0.tgz", - "integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=", - "optional": true, - "requires": { - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0" - } - }, "detect-file": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", "dev": true }, - "detect-libc": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", - "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=" - }, "diff": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/diff/-/diff-3.3.1.tgz", "integrity": "sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww==", "dev": true }, - "diffie-hellman": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", - "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", - "optional": true, - "requires": { - "bn.js": "^4.1.0", - "miller-rabin": "^4.0.0", - "randombytes": "^2.0.0" - } - }, "duplexify": { "version": "3.7.1", "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz", @@ -1313,25 +1026,11 @@ "jsbn": "~0.1.0" } }, - "elliptic": { - "version": "6.4.1", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz", - "integrity": "sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==", - "optional": true, - "requires": { - "bn.js": "^4.4.0", - "brorand": "^1.0.1", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.0", - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0", - "minimalistic-crypto-utils": "^1.0.0" - } - }, "end-of-stream": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "dev": true, "requires": { "once": "^1.4.0" } @@ -1407,16 +1106,6 @@ "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", "dev": true }, - "evp_bytestokey": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", - "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", - "optional": true, - "requires": { - "md5.js": "^1.3.4", - "safe-buffer": "^5.1.1" - } - }, "expand-brackets": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", @@ -1461,11 +1150,6 @@ } } }, - "expand-template": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-1.1.1.tgz", - "integrity": "sha512-cebqLtV8KOZfw0UI8TEFWxtczxxC1jvyUvx6H4fyp1K1FN7A4Q+uggVUlOsI1K8AGU0rwOGqP8nCapdrw8CYQg==" - }, "expand-tilde": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", @@ -1702,11 +1386,6 @@ "mime-types": "^2.1.12" } }, - "formidable": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.1.tgz", - "integrity": "sha512-Fs9VRguL0gqGHkXS5GQiMCr1VhZBxz0JnJs4JmMp/2jL18Fmbzvv7vOFRU+U8TBkHEE/CX1qDXzJplVULgsLeg==" - }, "fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", @@ -1716,11 +1395,6 @@ "map-cache": "^0.2.2" } }, - "fs-constants": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", - "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" - }, "fs-mkdirp-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz", @@ -2298,21 +1972,6 @@ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, - "gauge": { - "version": "2.7.4", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", - "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", - "requires": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - } - }, "get-caller-file": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", @@ -2339,11 +1998,6 @@ "assert-plus": "^1.0.0" } }, - "github-from-package": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", - "integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=" - }, "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", @@ -2577,11 +2231,6 @@ "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", "dev": true }, - "has-unicode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", - "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" - }, "has-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", @@ -2618,21 +2267,12 @@ "version": "3.0.4", "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", + "dev": true, "requires": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" } }, - "hash.js": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", - "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", - "optional": true, - "requires": { - "inherits": "^2.0.3", - "minimalistic-assert": "^1.0.1" - } - }, "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", @@ -2650,17 +2290,6 @@ "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", "dev": true }, - "hmac-drbg": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", - "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", - "optional": true, - "requires": { - "hash.js": "^1.0.3", - "minimalistic-assert": "^1.0.0", - "minimalistic-crypto-utils": "^1.0.1" - } - }, "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", @@ -2704,12 +2333,14 @@ "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true }, "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", + "dev": true }, "interpret": { "version": "1.2.0", @@ -2829,6 +2460,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2921,7 +2553,8 @@ "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true }, "isexe": { "version": "2.0.0", @@ -2952,9 +2585,9 @@ "dev": true }, "js-sha3": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.6.1.tgz", - "integrity": "sha1-W4n3enR3Z5h39YxKB1JAk0sflcA=" + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", + "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" }, "js-tokens": { "version": "3.0.2", @@ -3170,30 +2803,6 @@ } } }, - "md5.js": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", - "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", - "optional": true, - "requires": { - "hash-base": "^3.0.0", - "inherits": "^2.0.1", - "safe-buffer": "^5.1.2" - }, - "dependencies": { - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "optional": true - } - } - }, - "methods": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" - }, "micromatch": { "version": "3.1.10", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", @@ -3215,21 +2824,6 @@ "to-regex": "^3.0.2" } }, - "miller-rabin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", - "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", - "optional": true, - "requires": { - "bn.js": "^4.0.0", - "brorand": "^1.0.1" - } - }, - "mime": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" - }, "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", @@ -3243,23 +2837,6 @@ "mime-db": "~1.33.0" } }, - "mimic-response": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", - "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==" - }, - "minimalistic-assert": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", - "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", - "optional": true - }, - "minimalistic-crypto-utils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", - "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", - "optional": true - }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -3272,7 +2849,8 @@ "minimist": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true }, "mixin-deep": { "version": "1.3.1", @@ -3299,6 +2877,7 @@ "version": "0.5.1", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, "requires": { "minimist": "0.0.8" }, @@ -3306,7 +2885,8 @@ "minimist": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true } } }, @@ -3366,11 +2946,6 @@ "integrity": "sha512-kDcwXR4PS7caBpuRYYBUz9iVixUk3anO3f5OYFiIPwK/20vCzKCHyKoulbiDY1S53zD2bxUpxN/IJ+TnXjfvxg==", "dev": true }, - "nan": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", - "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==" - }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", @@ -3390,49 +2965,12 @@ "to-regex": "^3.0.1" } }, - "nem2-library": { - "version": "0.10.2", - "resolved": "https://registry.npmjs.org/nem2-library/-/nem2-library-0.10.2.tgz", - "integrity": "sha512-QdHmA3tMhcesDYzOVbhWE2Maxuq8d/umTpe2f3Sh99LGkf44PJIBG5sw/jiBRvZ9BjsgMVNqfD3VybcvOiXc/Q==", - "requires": { - "bufferutil": "^3.0.5", - "crypto-browserify": "3.12.0", - "crypto-js": "^3.1.9-1", - "flatbuffers": "^1.7.0", - "js-sha3": "^0.6.1", - "lodash": "^4.17.10", - "ripemd160": "^2.0.1", - "superagent": "^3.8.3", - "utf-8-validate": "^4.0.2", - "ws": "^5.2.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" - } - } - }, "next-tick": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", "dev": true }, - "node-abi": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.8.0.tgz", - "integrity": "sha512-1/aa2clS0pue0HjckL62CsbhWWU35HARvBDXcJtYKbYR7LnIutmpxmXbuDMV9kEviD2lP/wACOgWmmwljghHyQ==", - "requires": { - "semver": "^5.4.1" - } - }, - "noop-logger": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/noop-logger/-/noop-logger-0.1.1.tgz", - "integrity": "sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI=" - }, "normalize-package-data": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", @@ -3480,21 +3018,11 @@ "once": "^1.3.2" } }, - "npmlog": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", - "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", - "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" - } - }, "number-is-nan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true }, "nyc": { "version": "11.6.0", @@ -6274,11 +5802,6 @@ "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=" }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" - }, "object-copy": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", @@ -6382,6 +5905,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, "requires": { "wrappy": "1" } @@ -6395,11 +5919,6 @@ "readable-stream": "^2.0.1" } }, - "os-homedir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" - }, "os-locale": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", @@ -6409,20 +5928,6 @@ "lcid": "^1.0.0" } }, - "parse-asn1": { - "version": "5.1.4", - "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.4.tgz", - "integrity": "sha512-Qs5duJcuvNExRfFZ99HDD3z4mAi3r9Wl/FOjEOijlxwCZs7E7mW2vjTpgQ4J8LpTF8x5v+1Vn5UQFejmWT11aw==", - "optional": true, - "requires": { - "asn1.js": "^4.0.0", - "browserify-aes": "^1.0.0", - "create-hash": "^1.1.0", - "evp_bytestokey": "^1.0.0", - "pbkdf2": "^3.0.3", - "safe-buffer": "^5.1.1" - } - }, "parse-filepath": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz", @@ -6520,19 +6025,6 @@ "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", "dev": true }, - "pbkdf2": { - "version": "3.0.17", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", - "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", - "optional": true, - "requires": { - "create-hash": "^1.1.2", - "create-hmac": "^1.1.4", - "ripemd160": "^2.0.1", - "safe-buffer": "^5.0.1", - "sha.js": "^2.4.8" - } - }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -6577,28 +6069,6 @@ "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", "dev": true }, - "prebuild-install": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-4.0.0.tgz", - "integrity": "sha512-7tayxeYboJX0RbVzdnKyGl2vhQRWr6qfClEXDhOkXjuaOKCw2q8aiuFhONRYVsG/czia7KhpykIlI2S2VaPunA==", - "requires": { - "detect-libc": "^1.0.3", - "expand-template": "^1.0.2", - "github-from-package": "0.0.0", - "minimist": "^1.2.0", - "mkdirp": "^0.5.1", - "node-abi": "^2.2.0", - "noop-logger": "^0.1.1", - "npmlog": "^4.0.1", - "os-homedir": "^1.0.1", - "pump": "^2.0.1", - "rc": "^1.1.6", - "simple-get": "^2.7.0", - "tar-fs": "^1.13.0", - "tunnel-agent": "^0.6.0", - "which-pm-runs": "^1.0.0" - } - }, "pretty-hrtime": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", @@ -6608,34 +6078,14 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" - }, - "public-encrypt": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", - "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", - "optional": true, - "requires": { - "bn.js": "^4.1.0", - "browserify-rsa": "^4.0.0", - "create-hash": "^1.1.0", - "parse-asn1": "^5.0.0", - "randombytes": "^2.0.1", - "safe-buffer": "^5.1.2" - }, - "dependencies": { - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "optional": true - } - } + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "dev": true }, "pump": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", + "dev": true, "requires": { "end-of-stream": "^1.1.0", "once": "^1.3.1" @@ -6662,36 +6112,6 @@ "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" }, - "randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "optional": true, - "requires": { - "safe-buffer": "^5.1.0" - } - }, - "randomfill": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", - "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", - "optional": true, - "requires": { - "randombytes": "^2.0.5", - "safe-buffer": "^5.1.0" - } - }, - "rc": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", - "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", - "requires": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - } - }, "read-pkg": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", @@ -6717,6 +6137,7 @@ "version": "2.3.6", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -6916,6 +6337,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", + "dev": true, "requires": { "hash-base": "^3.0.0", "inherits": "^2.0.1" @@ -6957,7 +6379,8 @@ "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==" + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "dev": true }, "semver-greatest-satisfied-range": { "version": "1.1.0", @@ -6971,7 +6394,8 @@ "set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true }, "set-value": { "version": "2.0.0", @@ -6996,36 +6420,6 @@ } } }, - "sha.js": { - "version": "2.4.11", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", - "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", - "optional": true, - "requires": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } - }, - "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" - }, - "simple-concat": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", - "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=" - }, - "simple-get": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-2.8.1.tgz", - "integrity": "sha512-lSSHRSw3mQNUGPAYRqo7xy9dhKmxFXIjLjp4KHpf99GEH2VH7C3AM+Qfx6du6jhfUi6Vm7XnbEVEf7Wb6N8jRw==", - "requires": { - "decompress-response": "^3.3.0", - "once": "^1.3.1", - "simple-concat": "^1.0.0" - } - }, "snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", @@ -7291,6 +6685,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -7301,6 +6696,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, "requires": { "safe-buffer": "~5.1.0" } @@ -7314,6 +6710,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, "requires": { "ansi-regex": "^2.0.0" } @@ -7327,28 +6724,6 @@ "is-utf8": "^0.2.0" } }, - "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" - }, - "superagent": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/superagent/-/superagent-3.8.3.tgz", - "integrity": "sha512-GLQtLMCoEIK4eDv6OGtkOoSMt3D+oq0y3dsxMuYuDvaNUvuT8eFBuLmfR0iYYzHC1e8hpzC6ZsxbuP6DIalMFA==", - "requires": { - "component-emitter": "^1.2.0", - "cookiejar": "^2.1.0", - "debug": "^3.1.0", - "extend": "^3.0.0", - "form-data": "^2.3.1", - "formidable": "^1.2.0", - "methods": "^1.1.1", - "mime": "^1.4.1", - "qs": "^6.5.1", - "readable-stream": "^2.3.5" - } - }, "supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", @@ -7365,42 +6740,6 @@ "es6-symbol": "^3.1.1" } }, - "tar-fs": { - "version": "1.16.3", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-1.16.3.tgz", - "integrity": "sha512-NvCeXpYx7OsmOh8zIOP/ebG55zZmxLE0etfWRbWok+q2Qo8x/vOR/IJT1taADXPe+jsiu9axDb3X4B+iIgNlKw==", - "requires": { - "chownr": "^1.0.1", - "mkdirp": "^0.5.1", - "pump": "^1.0.0", - "tar-stream": "^1.1.2" - }, - "dependencies": { - "pump": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz", - "integrity": "sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==", - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - } - } - }, - "tar-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.2.tgz", - "integrity": "sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==", - "requires": { - "bl": "^1.0.0", - "buffer-alloc": "^1.2.0", - "end-of-stream": "^1.0.0", - "fs-constants": "^1.0.0", - "readable-stream": "^2.3.0", - "to-buffer": "^1.1.1", - "xtend": "^4.0.0" - } - }, "through2": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", @@ -7437,11 +6776,6 @@ "is-negated-glob": "^1.0.0" } }, - "to-buffer": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz", - "integrity": "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==" - }, "to-object-path": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", @@ -7822,16 +7156,6 @@ "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", "dev": true }, - "utf-8-validate": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-4.0.2.tgz", - "integrity": "sha512-CS63Ssp6zynBQ4IxVzgjP5Abdo6LuJ87HFIcgIiVUeY96+MTHkqKtrUhphbwQ6jX8aSGZv8zX6l1DCPpfcAnxA==", - "requires": { - "bindings": "~1.3.0", - "nan": "~2.10.0", - "prebuild-install": "~4.0.0" - } - }, "utf8": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/utf8/-/utf8-2.1.2.tgz", @@ -7857,7 +7181,8 @@ "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true }, "uuid": { "version": "3.2.1", @@ -7968,19 +7293,6 @@ "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=", "dev": true }, - "which-pm-runs": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/which-pm-runs/-/which-pm-runs-1.0.0.tgz", - "integrity": "sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs=" - }, - "wide-align": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", - "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", - "requires": { - "string-width": "^1.0.2 || 2" - } - }, "wrap-ansi": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", @@ -7994,7 +7306,8 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true }, "ws": { "version": "5.2.0", @@ -8007,7 +7320,8 @@ "xtend": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true }, "y18n": { "version": "3.2.1", diff --git a/package.json b/package.json index 9abe3f1cab..89b295f6a2 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "typings": "dist/index.d.ts", "devDependencies": { "@types/chai": "^4.0.4", + "@types/crypto-js": "^3.1.43", "@types/lodash": "^4.14.85", "@types/mocha": "^2.2.44", "@types/request": "^2.47.0", @@ -56,10 +57,11 @@ "typescript-require": "^0.2.9-1" }, "dependencies": { - "@types/crypto-js": "^3.1.43", + "bluebird": "^3.5.5", "crypto-js": "^3.1.9-1", + "flatbuffers": "^1.11.0", "js-joda": "^1.6.2", - "nem2-library": "0.10.2", + "js-sha3": "^0.8.0", "request": "^2.83.0", "request-promise-native": "^1.0.5", "rxjs": "^6.2.1", diff --git a/src/core/crypto/Crypto.ts b/src/core/crypto/Crypto.ts new file mode 100644 index 0000000000..0deef4f151 --- /dev/null +++ b/src/core/crypto/Crypto.ts @@ -0,0 +1,318 @@ +/* + * Copyright 2019 NEM + * + * 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 { WalletAlgorithm } from '../../model/wallet/WalletAlgorithm'; +import { Convert as convert } from '../format/Convert'; +import { KeyPair } from './KeyPair'; +import * as utility from './Utilities'; +const CryptoJS = require('crypto-js'); +export class Crypto { + /** + * Encrypt a private key for mobile apps (AES_PBKF2) + * + * @param {string} password - A wallet password + * @param {string} privateKey - An account private key + * + * @return {object} - The encrypted data + */ + public static toMobileKey = (password, privateKey) => { + // Errors + if (!password || !privateKey) { throw new Error('Missing argument !'); } + // Processing + const salt = CryptoJS.lib.WordArray.random(256 / 8); + const key = CryptoJS.PBKDF2(password, salt, { + keySize: 256 / 32, + iterations: 2000, + }); + const iv = Crypto.randomBytes(16); + const encIv = { + iv: utility.ua2words(iv, 16), + }; + const encrypted = CryptoJS.AES.encrypt(CryptoJS.enc.Hex.parse(privateKey), key, encIv); + // Result + return { + encrypted: convert.uint8ToHex(iv) + encrypted.ciphertext, + salt: salt.toString(), + }; + } + + /** + * Derive a private key from a password using count iterations of SHA3-256 + * + * @param {string} password - A wallet password + * @param {number} count - A number of iterations above 0 + * + * @return {object} - The derived private key + */ + public static derivePassSha = (password, count) => { + // Errors + if (!password) { throw new Error('Missing argument !'); } + if (!count || count <= 0) { throw new Error('Please provide a count number above 0'); } + // Processing + let data = password; + for (let i = 0; i < count; ++i) { + data = CryptoJS.SHA3(data, { + outputLength: 256, + }); + } + // Result + return { + priv: CryptoJS.enc.Hex.stringify(data), + }; + } + + /** + * Encrypt hex data using a key + * + * @param {string} data - An hex string + * @param {Uint8Array} key - An Uint8Array key + * + * @return {object} - The encrypted data + */ + public static encrypt = (data, key) => { + // Errors + if (!data || !key) { throw new Error('Missing argument !'); } + // Processing + const iv = Crypto.randomBytes(16); + const encKey = utility.ua2words(key, 32); + const encIv = { + iv: utility.ua2words(iv, 16), + }; + const encrypted = CryptoJS.AES.encrypt(CryptoJS.enc.Hex.parse(data), encKey, encIv); + // Result + return { + ciphertext: encrypted.ciphertext, + iv, + key, + }; + } + + /** + * Decrypt data + * + * @param {object} data - An encrypted data object + * + * @return {string} - The decrypted hex string + */ + public static decrypt = (data) => { + // Errors + if (!data) { throw new Error('Missing argument !'); } + // Processing + const encKey = utility.ua2words(data.key, 32); + const encIv = { + iv: utility.ua2words(data.iv, 16), + }; + // Result + return CryptoJS.enc.Hex.stringify(CryptoJS.AES.decrypt(data, encKey, encIv)); + } + + /** + * Reveal the private key of an account or derive it from the wallet password + * + * @param {object} common- An object containing password and privateKey field + * @param {object} walletAccount - A wallet account object + * @param {WalletAlgorithm} algo - A wallet algorithm + * + * @return {object|boolean} - The account private key in and object or false + */ + public static passwordToPrivateKey = (common, walletAccount, algo) => { + // Errors + if (!common || !common.password || !walletAccount || !algo) { throw new Error('Missing argument !'); } + // Processing + let r; + if (algo === WalletAlgorithm.Pass_6k) { // Brain wallets + if (!walletAccount.encrypted && !walletAccount.iv) { + // Account private key is generated simply using a passphrase so it has no encrypted and iv + r = Crypto.derivePassSha(common.password, 6000); + } else if (!walletAccount.encrypted || !walletAccount.iv) { + // Else if one is missing there is a problem + return false; + } else { + // Else child accounts have encrypted and iv so we decrypt + const pass = Crypto.derivePassSha(common.password, 20); + const obj = { + ciphertext: CryptoJS.enc.Hex.parse(walletAccount.encrypted), + iv: convert.hexToUint8(walletAccount.iv), + key: convert.hexToUint8(pass.priv), + }; + const d = Crypto.decrypt(obj); + r = { priv: d }; + } + } else if (algo === WalletAlgorithm.Pass_bip32) { // Wallets from PRNG + const pass = Crypto.derivePassSha(common.password, 20); + const obj = { + ciphertext: CryptoJS.enc.Hex.parse(walletAccount.encrypted), + iv: convert.hexToUint8(walletAccount.iv), + key: convert.hexToUint8(pass.priv), + }; + const d = Crypto.decrypt(obj); + r = { priv: d }; + } else if (algo === WalletAlgorithm.Pass_enc) { // Private Key wallets + const pass = Crypto.derivePassSha(common.password, 20); + const obj = { + ciphertext: CryptoJS.enc.Hex.parse(walletAccount.encrypted), + iv: convert.hexToUint8(walletAccount.iv), + key: convert.hexToUint8(pass.priv), + }; + const d = Crypto.decrypt(obj); + r = { priv: d }; + } else if (algo === WalletAlgorithm.Trezor) { // HW wallet + r = { priv: '' }; + common.isHW = true; + } else { + return false; + } + // Result + common.privateKey = r.priv; + return true; + } + + /** + * Generate a random key + * + * @return {Uint8Array} - A random key + */ + public static randomKey = () => { + return Crypto.randomBytes(32); + } + + /** + * Encode a private key using a password + * + * @param {string} privateKey - An hex private key + * @param {string} password - A password + * + * @return {object} - The encoded data + */ + public static encodePrivateKey = (privateKey, password) => { + // Errors + if (!privateKey || !password) { throw new Error('Missing argument !'); } + // Processing + const pass = Crypto.derivePassSha(password, 20); + const r = Crypto.encrypt(privateKey, convert.hexToUint8(pass.priv)); + // Result + return { + ciphertext: CryptoJS.enc.Hex.stringify(r.ciphertext), + iv: convert.uint8ToHex(r.iv), + }; + } + + /*** + * Encode a message, separated from encode() to help testing + * + * @param {string} senderPriv - A sender private key + * @param {string} recipientPub - A recipient public key + * @param {string} msg - A text message + * @param {Uint8Array} iv - An initialization vector + * @param {Uint8Array} salt - A salt + * + * @return {string} - The encoded message + */ + public static _encode = function(senderPriv, recipientPub, msg, iv, salt) { + // Errors + if (!senderPriv || !recipientPub || !msg || !iv || !salt) { throw new Error('Missing argument !'); } + // Processing + const keyPair = KeyPair.createKeyPairFromPrivateKeyString(senderPriv); + const pk = convert.hexToUint8(recipientPub); + const encKey = utility.ua2words(KeyPair.deriveSharedKey(keyPair, pk, salt), 32); + const encIv = { + iv: utility.ua2words(iv, 16), + }; + const encrypted = CryptoJS.AES.encrypt(CryptoJS.enc.Hex.parse(convert.utf8ToHex(msg)), encKey, encIv); + // Result + const result = convert.uint8ToHex(salt) + convert.uint8ToHex(iv) + CryptoJS.enc.Hex.stringify(encrypted.ciphertext); + return result; + } + + /** + * Encode a message + * + * @param {string} senderPriv - A sender private key + * @param {string} recipientPub - A recipient public key + * @param {string} msg - A text message + * + * @return {string} - The encoded message + */ + public static encode = (senderPriv, recipientPub, msg) => { + // Errors + if (!senderPriv || !recipientPub || !msg) { throw new Error('Missing argument !'); } + // Processing + const iv = Crypto.randomBytes(16); + const salt = Crypto.randomBytes(32); + const encoded = Crypto._encode(senderPriv, recipientPub, msg, iv, salt); + // Result + return encoded; + } + + /** + * Decode an encrypted message payload + * + * @param {string} recipientPrivate - A recipient private key + * @param {string} senderPublic - A sender public key + * @param {Uint8Array} _payload - An encrypted message payload in bytes + * + * @return {string} - The decoded payload as hex + */ + public static _decode = (recipientPrivate, senderPublic, payload, iv, salt) => { + // Error + if (!recipientPrivate || !senderPublic || !payload) { throw new Error('Missing argument !'); } + // Processing + const keyPair = KeyPair.createKeyPairFromPrivateKeyString(recipientPrivate); + const pk = convert.hexToUint8(senderPublic); + const encKey = utility.ua2words(KeyPair.deriveSharedKey(keyPair, pk, salt), 32); + const encIv = { + iv: utility.ua2words(iv, 16), + }; + const encrypted = { + ciphertext: utility.ua2words(payload, payload.length), + }; + const plain = CryptoJS.AES.decrypt(encrypted, encKey, encIv); + // Result + return CryptoJS.enc.Hex.stringify(plain); + } + + /** + * Decode an encrypted message payload + * + * @param {string} recipientPrivate - A recipient private key + * @param {string} senderPublic - A sender public key + * @param {string} _payload - An encrypted message payload + * + * @return {string} - The decoded payload as hex + */ + public static decode = (recipientPrivate, senderPublic, _payload) => { + // Error + if (!recipientPrivate || !senderPublic || !_payload) { throw new Error('Missing argument !'); } + // Processing + const binPayload = convert.hexToUint8(_payload); + const payload = new Uint8Array(binPayload.buffer, 48); + const salt = new Uint8Array(binPayload.buffer, 0, 32); + const iv = new Uint8Array(binPayload.buffer, 32, 16); + const decoded = Crypto._decode(recipientPrivate, senderPublic, payload, iv, salt); + return decoded; + } + + /** + * Generate random bytes by length + * @param {number} length - The length of the random bytes + * + * @return {Uint8Array} + */ + public static randomBytes = (length) => { + const crypto = require('crypto'); + return crypto.randomBytes(length); + } +} diff --git a/src/core/crypto/KeyPair.ts b/src/core/crypto/KeyPair.ts new file mode 100644 index 0000000000..b2b5a1bd1b --- /dev/null +++ b/src/core/crypto/KeyPair.ts @@ -0,0 +1,74 @@ +/* + * Copyright 2018 NEM + * + * 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 { Convert as convert } from '../format'; +import * as Utility from './Utilities'; + +export class KeyPair { + /** + * Creates a key pair from a private key string. + * @param {string} privateKeyString A hex encoded private key string. + * @returns {module:crypto/keyPair~KeyPair} The key pair. + */ + public static createKeyPairFromPrivateKeyString = (privateKeyString) => { + const privateKey = convert.hexToUint8(privateKeyString); + if (Utility.Key_Size !== privateKey.length) { + throw Error(`private key has unexpected size: ${privateKey.length}`); + } + + const publicKey = Utility.catapult_crypto.extractPublicKey(privateKey, Utility.catapult_hash.func); + return { + privateKey, + publicKey, + }; + } + + /** + * Signs a data buffer with a key pair. + * @param {module:crypto/keyPair~KeyPair} keyPair The key pair to use for signing. + * @param {Uint8Array} data The data to sign. + * @returns {Uint8Array} The signature. + */ + public static sign = (keyPair, data) => { + return Utility.catapult_crypto.sign(data, keyPair.publicKey, keyPair.privateKey, Utility.catapult_hash.createHasher()); + } + + /** + * Verifies a signature. + * @param {module:crypto/keyPair~PublicKey} publicKey The public key to use for verification. + * @param {Uint8Array} data The data to verify. + * @param {Uint8Array} signature The signature to verify. + * @returns {boolean} true if the signature is verifiable, false otherwise. + */ + public static verify = (publicKey, data, signature) => { + return Utility.catapult_crypto.verify(publicKey, data, signature, Utility.catapult_hash.createHasher()); + } + + /** + * Creates a shared key given a key pair and an arbitrary public key. + * The shared key can be used for encrypted message passing between the two. + * @param {module:crypto/keyPair~KeyPair} keyPair The key pair for which to create the shared key. + * @param {module:crypto/keyPair~PublicKey} publicKey The public key for which to create the shared key. + * @param {Uint8Array} salt A salt that should be applied to the shared key. + * @returns {Uint8Array} The shared key. + */ + public static deriveSharedKey = (keyPair, publicKey, salt) => { + if (Utility.Key_Size !== salt.length) { + throw Error(`salt has unexpected size: ${salt.length}`); + } + + return Utility.catapult_crypto.deriveSharedKey(salt, keyPair.privateKey, publicKey, Utility.catapult_hash.func); + } +} diff --git a/src/core/crypto/SHA3Hasher.ts b/src/core/crypto/SHA3Hasher.ts new file mode 100644 index 0000000000..28ecc06847 --- /dev/null +++ b/src/core/crypto/SHA3Hasher.ts @@ -0,0 +1,70 @@ +/* + * Copyright 2019 NEM + * + * 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 { sha3_256, sha3_512 } from 'js-sha3'; +import { Convert as convert, RawArray as array } from '../format'; + +export class SHA3Hasher { + /** + * Calculates the hash of data. + * @param {Uint8Array} dest The computed hash destination. + * @param {Uint8Array} data The data to hash. + * @param {numeric} length The hash length in bytes. + */ + public static func = (dest, data, length) => { + const hasher = SHA3Hasher.getHasher(length); + const hash = hasher.arrayBuffer(data); + array.copy(dest, array.uint8View(hash)); + } + + /** + * Creates a hasher object. + * @param {numeric} length The hash length in bytes. + * @returns {object} The hasher. + */ + public static createHasher = (length = 64) => { + let hash; + return { + reset: () => { + hash = SHA3Hasher.getHasher(length).create(); + }, + update: (data: any) => { + if (data instanceof Uint8Array) { + hash.update(data); + } else if ('string' === typeof data) { + hash.update(convert.hexToUint8(data)); + } else { + throw Error('unsupported data type'); + } + }, + finalize: (result: any) => { + array.copy(result, array.uint8View(hash.arrayBuffer())); + }, + }; + } + + /** + * Get a hasher instance. + * @param {numeric} length The hash length in bytes. + * @returns {object} The hasher. + */ + public static getHasher = (length = 64) => { + return { + 32: sha3_256, + 64: sha3_512, + } [length]; + } +} diff --git a/src/core/crypto/Utilities.ts b/src/core/crypto/Utilities.ts new file mode 100644 index 0000000000..487df065f7 --- /dev/null +++ b/src/core/crypto/Utilities.ts @@ -0,0 +1,227 @@ +/* + * Copyright 2019 NEM + * + * 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 { RawArray as array } from '../format'; +import * as nacl from './nacl_catapult'; +import { SHA3Hasher as sha3Hasher } from './SHA3Hasher'; + +export const CryptoJS = require('crypto-js'); +export const Key_Size = 32; +export const Signature_Size = 64; +export const Half_Signature_Size = Signature_Size / 2; +export const Hash_Size = 64; +export const Half_Hash_Size = Hash_Size / 2; + +/** + * Convert an Uint8Array to WordArray + * + * @param {Uint8Array} ua - An Uint8Array + * @param {number} uaLength - The Uint8Array length + * + * @return {WordArray} + */ +export const ua2words = (ua, uaLength) => { + const temp: number[] = []; + for (let i = 0; i < uaLength; i += 4) { + const x = ua[i] * 0x1000000 + (ua[i + 1] || 0) * 0x10000 + (ua[i + 2] || 0) * 0x100 + (ua[i + 3] || 0); + temp.push((x > 0x7fffffff) ? x - 0x100000000 : x); + } + return CryptoJS.lib.WordArray.create(temp, uaLength); +}; + +/** + * Convert a wordArray to Uint8Array + * + * @param {Uint8Array} destUa - A destination Uint8Array + * @param {WordArray} cryptoWords - A wordArray + * + * @return {Uint8Array} + */ +export const words2ua = (destUa, cryptoWords) => { + for (let i = 0; i < destUa.length; i += 4) { + let v = cryptoWords.words[i / 4]; + if (v < 0) { v += 0x100000000; } + destUa[i] = (v >>> 24); + destUa[i + 1] = (v >>> 16) & 0xff; + destUa[i + 2] = (v >>> 8) & 0xff; + destUa[i + 3] = v & 0xff; + } + return destUa; +}; + +export const catapult_hash = { + func: sha3Hasher.func, + createHasher: sha3Hasher.createHasher, +}; + +// custom catapult crypto functions +export const catapult_crypto = (function() { + function clamp(d) { + d[0] &= 248; + d[31] &= 127; + d[31] |= 64; + } + + function prepareForScalarMult(sk, hashfunc) { + const d = new Uint8Array(Hash_Size); + hashfunc(d, sk); + clamp(d); + return d; + } + + const encodedSChecker = (function() { + const Is_Reduced = 1; + const Is_Zero = 2; + + function validateEncodedSPart(s) { + if (array.isZeroFilled(s)) { + return Is_Zero | Is_Reduced; + } + const copy = new Uint8Array(Signature_Size); + array.copy(copy, s, Half_Signature_Size); + + nacl.reduce(copy); + return array.deepEqual(s, copy, Half_Signature_Size) ? Is_Reduced : 0; + } + + return { + isCanonical: (s) => Is_Reduced === validateEncodedSPart(s), + + requireValid: (s) => { + if (0 === (validateEncodedSPart(s) & Is_Reduced)) { + throw Error('S part of signature invalid'); + } + }, + }; + })(); + + return { + extractPublicKey: (sk, hashfunc) => { + const c = nacl; + const d = prepareForScalarMult(sk, hashfunc); + + const p = [c.gf(), c.gf(), c.gf(), c.gf()]; + const pk = new Uint8Array(Key_Size); + c.scalarbase(p, d); + c.pack(pk, p); + return pk; + }, + + sign: (m, pk, sk, hasher) => { + const c = nacl; + + const d = new Uint8Array(Hash_Size); + hasher.reset(); + hasher.update(sk); + hasher.finalize(d); + clamp(d); + + const r = new Uint8Array(Hash_Size); + hasher.reset(); + hasher.update(d.subarray(Half_Hash_Size)); + hasher.update(m); + hasher.finalize(r); + + const p = [c.gf(), c.gf(), c.gf(), c.gf()]; + const signature = new Uint8Array(Signature_Size); + c.reduce(r); + c.scalarbase(p, r); + c.pack(signature, p); + + const h = new Uint8Array(Hash_Size); + hasher.reset(); + hasher.update(signature.subarray(0, Half_Signature_Size)); + hasher.update(pk); + hasher.update(m); + hasher.finalize(h); + + c.reduce(h); + + // muladd + const x = new Float64Array(Hash_Size); + array.copy(x, r, Half_Hash_Size); + + for (let i = 0; i < Half_Hash_Size; ++i) { + for (let j = 0; j < Half_Hash_Size; ++j) { + x[i + j] += h[i] * d[j]; + } + } + + c.modL(signature.subarray(Half_Signature_Size), x); + encodedSChecker.requireValid(signature.subarray(Half_Signature_Size)); + return signature; + }, + + verify: (pk, m, signature, hasher) => { + // reject non canonical signature + if (!encodedSChecker.isCanonical(signature.subarray(Half_Signature_Size))) { + return false; + } + + // reject weak (zero) public key + if (array.isZeroFilled(pk)) { + return false; + } + + const c = nacl; + const p = [c.gf(), c.gf(), c.gf(), c.gf()]; + const q = [c.gf(), c.gf(), c.gf(), c.gf()]; + + if (c.unpackneg(q, pk)) { + return false; + } + + const h = new Uint8Array(Hash_Size); + hasher.reset(); + hasher.update(signature.subarray(0, Half_Signature_Size)); + hasher.update(pk); + hasher.update(m); + hasher.finalize(h); + + c.reduce(h); + c.scalarmult(p, q, h); + + const t = new Uint8Array(Signature_Size); + c.scalarbase(q, signature.subarray(Half_Signature_Size)); + c.add(p, q); + c.pack(t, p); + + return 0 === c.crypto_verify_32(signature, 0, t, 0); + }, + + deriveSharedKey: (salt, sk, pk, hashfunc) => { + const c = nacl; + const d = prepareForScalarMult(sk, hashfunc); + + // sharedKey = pack(p = d (derived from sk) * q (derived from pk)) + const q = [c.gf(), c.gf(), c.gf(), c.gf()]; + const p = [c.gf(), c.gf(), c.gf(), c.gf()]; + const sharedKey = new Uint8Array(Key_Size); + c.unpackneg(q, pk); + c.scalarmult(p, q, d); + c.pack(sharedKey, p); + + // salt the shared key + for (let i = 0; i < Key_Size; ++i) { + sharedKey[i] ^= salt[i]; + } + + // return the hash of the result + const sharedKeyHash = new Uint8Array(Key_Size); + hashfunc(sharedKeyHash, sharedKey, Key_Size); + return sharedKeyHash; + }, + }; +})(); diff --git a/src/core/crypto/index.ts b/src/core/crypto/index.ts new file mode 100644 index 0000000000..1a168b4094 --- /dev/null +++ b/src/core/crypto/index.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2019 NEM + * + * 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 * from './Crypto'; +export * from './KeyPair'; diff --git a/src/core/crypto/nacl_catapult.ts b/src/core/crypto/nacl_catapult.ts new file mode 100644 index 0000000000..1d47ac02fe --- /dev/null +++ b/src/core/crypto/nacl_catapult.ts @@ -0,0 +1,852 @@ +/* + * Copyright 2018 NEM + * + * 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. + */ + +// README: This is copied from tweeetnacl/nacl.fast.js and is updated to export custom hash functions. + +// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri. +// Public domain. +// +// Implementation derived from TweetNaCl version 20140427. +// See for details: http://tweetnacl.cr.yp.to/ +const _0 = new Uint8Array(16); +const _9 = new Uint8Array(32); +_9[0] = 9; + +export const gf = (init ? ) => { + // tslint:disable-next-line:one-variable-per-declaration + let i; + const r = new Float64Array(16); + if (init) { + for (i = 0; i < init.length; i++) { + r[i] = init[i]; + } + } + return r; +}; + +// tslint:disable-next-line:one-variable-per-declaration +const gf0 = gf(), + gf1 = gf([1]), + _121665 = gf([0xdb41, 1]), + D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, + 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203 + ]), + D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, + 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406 + ]), + X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, + 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169 + ]), + Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, + 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666 + ]), + I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, + 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83 + ]); +const L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, + 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10 +]); + +const A = (o, a, b) => { + for (let i = 0; i < 16; i++) { + o[i] = a[i] + b[i]; + } +}; + +const Z = (o, a, b) => { + for (let i = 0; i < 16; i++) { + o[i] = a[i] - b[i]; + } +}; + +const M = (o, a, b) => { + // tslint:disable-next-line:one-variable-per-declaration + let v, c, + t0 = 0, + t1 = 0, + t2 = 0, + t3 = 0, + t4 = 0, + t5 = 0, + t6 = 0, + t7 = 0, + t8 = 0, + t9 = 0, + t10 = 0, + t11 = 0, + t12 = 0, + t13 = 0, + t14 = 0, + t15 = 0, + t16 = 0, + t17 = 0, + t18 = 0, + t19 = 0, + t20 = 0, + t21 = 0, + t22 = 0, + t23 = 0, + t24 = 0, + t25 = 0, + t26 = 0, + t27 = 0, + t28 = 0, + t29 = 0, + t30 = 0, + b0 = b[0], + b1 = b[1], + b2 = b[2], + b3 = b[3], + b4 = b[4], + b5 = b[5], + b6 = b[6], + b7 = b[7], + b8 = b[8], + b9 = b[9], + b10 = b[10], + b11 = b[11], + b12 = b[12], + b13 = b[13], + b14 = b[14], + b15 = b[15]; + + v = a[0]; + t0 += v * b0; + t1 += v * b1; + t2 += v * b2; + t3 += v * b3; + t4 += v * b4; + t5 += v * b5; + t6 += v * b6; + t7 += v * b7; + t8 += v * b8; + t9 += v * b9; + t10 += v * b10; + t11 += v * b11; + t12 += v * b12; + t13 += v * b13; + t14 += v * b14; + t15 += v * b15; + v = a[1]; + t1 += v * b0; + t2 += v * b1; + t3 += v * b2; + t4 += v * b3; + t5 += v * b4; + t6 += v * b5; + t7 += v * b6; + t8 += v * b7; + t9 += v * b8; + t10 += v * b9; + t11 += v * b10; + t12 += v * b11; + t13 += v * b12; + t14 += v * b13; + t15 += v * b14; + t16 += v * b15; + v = a[2]; + t2 += v * b0; + t3 += v * b1; + t4 += v * b2; + t5 += v * b3; + t6 += v * b4; + t7 += v * b5; + t8 += v * b6; + t9 += v * b7; + t10 += v * b8; + t11 += v * b9; + t12 += v * b10; + t13 += v * b11; + t14 += v * b12; + t15 += v * b13; + t16 += v * b14; + t17 += v * b15; + v = a[3]; + t3 += v * b0; + t4 += v * b1; + t5 += v * b2; + t6 += v * b3; + t7 += v * b4; + t8 += v * b5; + t9 += v * b6; + t10 += v * b7; + t11 += v * b8; + t12 += v * b9; + t13 += v * b10; + t14 += v * b11; + t15 += v * b12; + t16 += v * b13; + t17 += v * b14; + t18 += v * b15; + v = a[4]; + t4 += v * b0; + t5 += v * b1; + t6 += v * b2; + t7 += v * b3; + t8 += v * b4; + t9 += v * b5; + t10 += v * b6; + t11 += v * b7; + t12 += v * b8; + t13 += v * b9; + t14 += v * b10; + t15 += v * b11; + t16 += v * b12; + t17 += v * b13; + t18 += v * b14; + t19 += v * b15; + v = a[5]; + t5 += v * b0; + t6 += v * b1; + t7 += v * b2; + t8 += v * b3; + t9 += v * b4; + t10 += v * b5; + t11 += v * b6; + t12 += v * b7; + t13 += v * b8; + t14 += v * b9; + t15 += v * b10; + t16 += v * b11; + t17 += v * b12; + t18 += v * b13; + t19 += v * b14; + t20 += v * b15; + v = a[6]; + t6 += v * b0; + t7 += v * b1; + t8 += v * b2; + t9 += v * b3; + t10 += v * b4; + t11 += v * b5; + t12 += v * b6; + t13 += v * b7; + t14 += v * b8; + t15 += v * b9; + t16 += v * b10; + t17 += v * b11; + t18 += v * b12; + t19 += v * b13; + t20 += v * b14; + t21 += v * b15; + v = a[7]; + t7 += v * b0; + t8 += v * b1; + t9 += v * b2; + t10 += v * b3; + t11 += v * b4; + t12 += v * b5; + t13 += v * b6; + t14 += v * b7; + t15 += v * b8; + t16 += v * b9; + t17 += v * b10; + t18 += v * b11; + t19 += v * b12; + t20 += v * b13; + t21 += v * b14; + t22 += v * b15; + v = a[8]; + t8 += v * b0; + t9 += v * b1; + t10 += v * b2; + t11 += v * b3; + t12 += v * b4; + t13 += v * b5; + t14 += v * b6; + t15 += v * b7; + t16 += v * b8; + t17 += v * b9; + t18 += v * b10; + t19 += v * b11; + t20 += v * b12; + t21 += v * b13; + t22 += v * b14; + t23 += v * b15; + v = a[9]; + t9 += v * b0; + t10 += v * b1; + t11 += v * b2; + t12 += v * b3; + t13 += v * b4; + t14 += v * b5; + t15 += v * b6; + t16 += v * b7; + t17 += v * b8; + t18 += v * b9; + t19 += v * b10; + t20 += v * b11; + t21 += v * b12; + t22 += v * b13; + t23 += v * b14; + t24 += v * b15; + v = a[10]; + t10 += v * b0; + t11 += v * b1; + t12 += v * b2; + t13 += v * b3; + t14 += v * b4; + t15 += v * b5; + t16 += v * b6; + t17 += v * b7; + t18 += v * b8; + t19 += v * b9; + t20 += v * b10; + t21 += v * b11; + t22 += v * b12; + t23 += v * b13; + t24 += v * b14; + t25 += v * b15; + v = a[11]; + t11 += v * b0; + t12 += v * b1; + t13 += v * b2; + t14 += v * b3; + t15 += v * b4; + t16 += v * b5; + t17 += v * b6; + t18 += v * b7; + t19 += v * b8; + t20 += v * b9; + t21 += v * b10; + t22 += v * b11; + t23 += v * b12; + t24 += v * b13; + t25 += v * b14; + t26 += v * b15; + v = a[12]; + t12 += v * b0; + t13 += v * b1; + t14 += v * b2; + t15 += v * b3; + t16 += v * b4; + t17 += v * b5; + t18 += v * b6; + t19 += v * b7; + t20 += v * b8; + t21 += v * b9; + t22 += v * b10; + t23 += v * b11; + t24 += v * b12; + t25 += v * b13; + t26 += v * b14; + t27 += v * b15; + v = a[13]; + t13 += v * b0; + t14 += v * b1; + t15 += v * b2; + t16 += v * b3; + t17 += v * b4; + t18 += v * b5; + t19 += v * b6; + t20 += v * b7; + t21 += v * b8; + t22 += v * b9; + t23 += v * b10; + t24 += v * b11; + t25 += v * b12; + t26 += v * b13; + t27 += v * b14; + t28 += v * b15; + v = a[14]; + t14 += v * b0; + t15 += v * b1; + t16 += v * b2; + t17 += v * b3; + t18 += v * b4; + t19 += v * b5; + t20 += v * b6; + t21 += v * b7; + t22 += v * b8; + t23 += v * b9; + t24 += v * b10; + t25 += v * b11; + t26 += v * b12; + t27 += v * b13; + t28 += v * b14; + t29 += v * b15; + v = a[15]; + t15 += v * b0; + t16 += v * b1; + t17 += v * b2; + t18 += v * b3; + t19 += v * b4; + t20 += v * b5; + t21 += v * b6; + t22 += v * b7; + t23 += v * b8; + t24 += v * b9; + t25 += v * b10; + t26 += v * b11; + t27 += v * b12; + t28 += v * b13; + t29 += v * b14; + t30 += v * b15; + + t0 += 38 * t16; + t1 += 38 * t17; + t2 += 38 * t18; + t3 += 38 * t19; + t4 += 38 * t20; + t5 += 38 * t21; + t6 += 38 * t22; + t7 += 38 * t23; + t8 += 38 * t24; + t9 += 38 * t25; + t10 += 38 * t26; + t11 += 38 * t27; + t12 += 38 * t28; + t13 += 38 * t29; + t14 += 38 * t30; + // t15 left as is + + // first car + c = 1; + v = t0 + c + 65535; + c = Math.floor(v / 65536); + t0 = v - c * 65536; + v = t1 + c + 65535; + c = Math.floor(v / 65536); + t1 = v - c * 65536; + v = t2 + c + 65535; + c = Math.floor(v / 65536); + t2 = v - c * 65536; + v = t3 + c + 65535; + c = Math.floor(v / 65536); + t3 = v - c * 65536; + v = t4 + c + 65535; + c = Math.floor(v / 65536); + t4 = v - c * 65536; + v = t5 + c + 65535; + c = Math.floor(v / 65536); + t5 = v - c * 65536; + v = t6 + c + 65535; + c = Math.floor(v / 65536); + t6 = v - c * 65536; + v = t7 + c + 65535; + c = Math.floor(v / 65536); + t7 = v - c * 65536; + v = t8 + c + 65535; + c = Math.floor(v / 65536); + t8 = v - c * 65536; + v = t9 + c + 65535; + c = Math.floor(v / 65536); + t9 = v - c * 65536; + v = t10 + c + 65535; + c = Math.floor(v / 65536); + t10 = v - c * 65536; + v = t11 + c + 65535; + c = Math.floor(v / 65536); + t11 = v - c * 65536; + v = t12 + c + 65535; + c = Math.floor(v / 65536); + t12 = v - c * 65536; + v = t13 + c + 65535; + c = Math.floor(v / 65536); + t13 = v - c * 65536; + v = t14 + c + 65535; + c = Math.floor(v / 65536); + t14 = v - c * 65536; + v = t15 + c + 65535; + c = Math.floor(v / 65536); + t15 = v - c * 65536; + t0 += c - 1 + 37 * (c - 1); + + // second car + c = 1; + v = t0 + c + 65535; + c = Math.floor(v / 65536); + t0 = v - c * 65536; + v = t1 + c + 65535; + c = Math.floor(v / 65536); + t1 = v - c * 65536; + v = t2 + c + 65535; + c = Math.floor(v / 65536); + t2 = v - c * 65536; + v = t3 + c + 65535; + c = Math.floor(v / 65536); + t3 = v - c * 65536; + v = t4 + c + 65535; + c = Math.floor(v / 65536); + t4 = v - c * 65536; + v = t5 + c + 65535; + c = Math.floor(v / 65536); + t5 = v - c * 65536; + v = t6 + c + 65535; + c = Math.floor(v / 65536); + t6 = v - c * 65536; + v = t7 + c + 65535; + c = Math.floor(v / 65536); + t7 = v - c * 65536; + v = t8 + c + 65535; + c = Math.floor(v / 65536); + t8 = v - c * 65536; + v = t9 + c + 65535; + c = Math.floor(v / 65536); + t9 = v - c * 65536; + v = t10 + c + 65535; + c = Math.floor(v / 65536); + t10 = v - c * 65536; + v = t11 + c + 65535; + c = Math.floor(v / 65536); + t11 = v - c * 65536; + v = t12 + c + 65535; + c = Math.floor(v / 65536); + t12 = v - c * 65536; + v = t13 + c + 65535; + c = Math.floor(v / 65536); + t13 = v - c * 65536; + v = t14 + c + 65535; + c = Math.floor(v / 65536); + t14 = v - c * 65536; + v = t15 + c + 65535; + c = Math.floor(v / 65536); + t15 = v - c * 65536; + t0 += c - 1 + 37 * (c - 1); + + o[0] = t0; + o[1] = t1; + o[2] = t2; + o[3] = t3; + o[4] = t4; + o[5] = t5; + o[6] = t6; + o[7] = t7; + o[8] = t8; + o[9] = t9; + o[10] = t10; + o[11] = t11; + o[12] = t12; + o[13] = t13; + o[14] = t14; + o[15] = t15; +}; + +const S = (o, a) => { + M(o, a, a); +}; +const vn = (x, xi, y, yi, n) => { + // tslint:disable-next-line:one-variable-per-declaration + let i, d = 0; + for (i = 0; i < n; i++) { + d |= x[xi + i] ^ y[yi + i]; + } + return (1 & ((d - 1) >>> 8)) - 1; +}; + +const pow2523 = (o, i) => { + const c = gf(); + let a; + for (a = 0; a < 16; a++) { + c[a] = i[a]; + } + for (a = 250; a >= 0; a--) { + S(c, c); + if (a !== 1) { + M(c, c, i); + } + } + for (a = 0; a < 16; a++) { + o[a] = c[a]; + } +}; +const inv25519 = (o, i) => { + const c = gf(); + let a; + for (a = 0; a < 16; a++) { + c[a] = i[a]; + } + for (a = 253; a >= 0; a--) { + S(c, c); + if (a !== 2 && a !== 4) { + M(c, c, i); + } + } + for (a = 0; a < 16; a++) { + o[a] = c[a]; + } +}; +const set25519 = (r, a) => { + let i; + for (i = 0; i < 16; i++) { + r[i] = a[i] | 0; + } +}; + +const car25519 = (o) => { + // tslint:disable-next-line:one-variable-per-declaration + let i, v, c = 1; + for (i = 0; i < 16; i++) { + v = o[i] + c + 65535; + c = Math.floor(v / 65536); + o[i] = v - c * 65536; + } + o[0] += c - 1 + 37 * (c - 1); +}; + +const sel25519 = (p, q, b) => { + // tslint:disable-next-line:one-variable-per-declaration + let t, c = ~(b - 1); + for (let i = 0; i < 16; i++) { + t = c & (p[i] ^ q[i]); + p[i] ^= t; + q[i] ^= t; + } +}; + +const pack25519 = (o, n) => { + // tslint:disable-next-line:one-variable-per-declaration + let i, j, b; + // tslint:disable-next-line:one-variable-per-declaration + const m = gf(), + t = gf(); + for (i = 0; i < 16; i++) { + t[i] = n[i]; + } + car25519(t); + car25519(t); + car25519(t); + for (j = 0; j < 2; j++) { + m[0] = t[0] - 0xffed; + for (i = 1; i < 15; i++) { + m[i] = t[i] - 0xffff - ((m[i - 1] >> 16) & 1); + m[i - 1] &= 0xffff; + } + m[15] = t[15] - 0x7fff - ((m[14] >> 16) & 1); + b = (m[15] >> 16) & 1; + m[14] &= 0xffff; + sel25519(t, m, 1 - b); + } + for (i = 0; i < 16; i++) { + o[2 * i] = t[i] & 0xff; + o[2 * i + 1] = t[i] >> 8; + } +}; + +const cswap = (p, q, b) => { + let i; + for (i = 0; i < 4; i++) { + sel25519(p[i], q[i], b); + } +}; + +const neq25519 = (a, b) => { + // tslint:disable-next-line:one-variable-per-declaration + const c = new Uint8Array(32), + d = new Uint8Array(32); + pack25519(c, a); + pack25519(d, b); + return crypto_verify_32(c, 0, d, 0); +}; + +const par25519 = (a) => { + const d = new Uint8Array(32); + pack25519(d, a); + return d[0] & 1; +}; + +const unpack25519 = (o, n) => { + let i; + for (i = 0; i < 16; i++) { + o[i] = n[2 * i] + (n[2 * i + 1] << 8); + } + o[15] &= 0x7fff; +}; + +export const cleanup = (arr) => { + for (var i = 0; i < arr.length; i++) { + arr[i] = 0; + } +}; + +export const crypto_shared_key_hash = (shared, pk, sk, hashfunc) => { + const d = new Uint8Array(64); + const p = [gf(), gf(), gf(), gf()]; + + hashfunc(d, sk, 32); + d[0] &= 248; + d[31] &= 127; + d[31] |= 64; + + let q = [gf(), gf(), gf(), gf()]; + unpackneg(q, pk); + scalarmult(p, q, d); + pack(shared, p); +}; + +export const crypto_verify_32 = (x, xi, y, yi) => { + return vn(x, xi, y, yi, 32); +}; + +export const add = (p, q) => { + // tslint:disable-next-line:one-variable-per-declaration + const a = gf(), + b = gf(), + c = gf(), + d = gf(), + e = gf(), + f = gf(), + g = gf(), + h = gf(), + t = gf(); + + Z(a, p[1], p[0]); + Z(t, q[1], q[0]); + M(a, a, t); + A(b, p[0], p[1]); + A(t, q[0], q[1]); + M(b, b, t); + M(c, p[3], q[3]); + M(c, c, D2); + M(d, p[2], q[2]); + A(d, d, d); + Z(e, b, a); + Z(f, d, c); + A(g, d, c); + A(h, b, a); + + M(p[0], e, f); + M(p[1], h, g); + M(p[2], g, f); + M(p[3], e, h); +}; + +export const modL = (r, x) => { + // tslint:disable-next-line:one-variable-per-declaration + let carry, i, j, k; + for (i = 63; i >= 32; --i) { + carry = 0; + for (j = i - 32, k = i - 12; j < k; ++j) { + x[j] += carry - 16 * x[i] * L[j - (i - 32)]; + carry = (x[j] + 128) >> 8; + x[j] -= carry * 256; + } + x[j] += carry; + x[i] = 0; + } + carry = 0; + for (j = 0; j < 32; j++) { + x[j] += carry - (x[31] >> 4) * L[j]; + carry = x[j] >> 8; + x[j] &= 255; + } + for (j = 0; j < 32; j++) { + x[j] -= carry * L[j]; + } + for (i = 0; i < 32; i++) { + x[i + 1] += x[i] >> 8; + r[i] = x[i] & 255; + } +}; + +export const reduce = (r) => { + // tslint:disable-next-line:one-variable-per-declaration + let x = new Float64Array(64), + i; + for (i = 0; i < 64; i++) { + x[i] = r[i]; + } + for (i = 0; i < 64; i++) { + r[i] = 0; + } + modL(r, x); +}; + +export const pack = (r, p) => { + // tslint:disable-next-line:one-variable-per-declaration + const tx = gf(), + ty = gf(), + zi = gf(); + inv25519(zi, p[2]); + M(tx, p[0], zi); + M(ty, p[1], zi); + pack25519(r, ty); + r[31] ^= par25519(tx) << 7; +}; + +export const scalarmult = (p, q, s) => { + // tslint:disable-next-line:one-variable-per-declaration + let b, i; + set25519(p[0], gf0); + set25519(p[1], gf1); + set25519(p[2], gf1); + set25519(p[3], gf0); + for (i = 255; i >= 0; --i) { + b = (s[(i / 8) | 0] >> (i & 7)) & 1; + cswap(p, q, b); + add(q, p); + add(p, p); + cswap(p, q, b); + } +}; + +export const scalarbase = (p, s) => { + const q = [gf(), gf(), gf(), gf()]; + set25519(q[0], X); + set25519(q[1], Y); + set25519(q[2], gf1); + M(q[3], X, Y); + scalarmult(p, q, s); +}; + +export const unpackneg = (r, p) => { + // tslint:disable-next-line:one-variable-per-declaration + const t = gf(), + chk = gf(), + num = gf(), + den = gf(), + den2 = gf(), + den4 = gf(), + den6 = gf(); + + set25519(r[2], gf1); + unpack25519(r[1], p); + S(num, r[1]); + M(den, num, D); + Z(num, num, r[2]); + A(den, r[2], den); + + S(den2, den); + S(den4, den2); + M(den6, den4, den2); + M(t, den6, num); + M(t, t, den); + + pow2523(t, t); + M(t, t, num); + M(t, t, den); + M(t, t, den); + M(r[0], t, den); + + S(chk, r[0]); + M(chk, chk, den); + if (neq25519(chk, num)) { + M(r[0], r[0], I); + } + + S(chk, r[0]); + M(chk, chk, den); + if (neq25519(chk, num)) { + return -1; + } + + if (par25519(r[0]) === (p[31] >> 7)) { + Z(r[0], gf0, r[0]); + } + + M(r[3], r[0], r[1]); + return 0; +}; diff --git a/src/core/format/Base32.ts b/src/core/format/Base32.ts new file mode 100644 index 0000000000..ac5314f457 --- /dev/null +++ b/src/core/format/Base32.ts @@ -0,0 +1,52 @@ +/* + * Copyright 2019 NEM + * + * 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 * as utilities from './Utilities'; + +export class Base32 { + /** + * Base32 encodes a binary buffer. + * @param {Uint8Array} data The binary data to encode. + * @returns {string} The base32 encoded string corresponding to the input data. + */ + public static Base32Encode = (data: Uint8Array): string => { + if (0 !== data.length % utilities.Decoded_Block_Size) { + throw Error(`decoded size must be multiple of ${utilities.Decoded_Block_Size}`); + } + const output = new Array(data.length / utilities.Decoded_Block_Size * utilities.Encoded_Block_Size); + for (let i = 0; i < data.length / utilities.Decoded_Block_Size; ++i) { + utilities.encodeBlock(data, i * utilities.Decoded_Block_Size, output, i * utilities.Encoded_Block_Size); + } + return output.join(''); + } + + /** + * Base32 decodes a base32 encoded string. + * @param {string} encoded The base32 encoded string to decode. + * @returns {Uint8Array} The binary data corresponding to the input string. + */ + public static Base32Decode = (encoded: string): Uint8Array => { + if (0 !== encoded.length % utilities.Encoded_Block_Size) { + throw Error(`encoded size must be multiple of ${utilities.Encoded_Block_Size}`); + } + + const output = new Uint8Array(encoded.length / utilities.Encoded_Block_Size * utilities.Decoded_Block_Size); + for (let i = 0; i < encoded.length / utilities.Encoded_Block_Size; ++i) { + utilities.decodeBlock(encoded, i * utilities.Encoded_Block_Size, output, i * utilities.Decoded_Block_Size); + } + return output; + } +} diff --git a/src/core/format/Convert.ts b/src/core/format/Convert.ts new file mode 100644 index 0000000000..f6d12097b2 --- /dev/null +++ b/src/core/format/Convert.ts @@ -0,0 +1,175 @@ +/* + * Copyright 2019 NEM + * + * 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 * as utilities from './Utilities'; + +export class Convert { + + /** + * Decodes two hex characters into a byte. + * @param {string} char1 The first hex digit. + * @param {string} char2 The second hex digit. + * @returns {number} The decoded byte. + */ + public static toByte = (char1: string, char2: string): number => { + const byte = utilities.tryParseByte(char1, char2); + if (undefined === byte) { + throw Error(`unrecognized hex char`); + } + return byte; + } + + /** + * Determines whether or not a string is a hex string. + * @param {string} input The string to test. + * @returns {boolean} true if the input is a hex string, false otherwise. + */ + public static isHexString = (input: string): boolean => { + if (0 !== input.length % 2) { + return false; + } + for (let i = 0; i < input.length; i += 2) { + if (undefined === utilities.tryParseByte(input[i], input[i + 1])) { + return false; + } + } + return true; + } + + /** + * Converts a hex string to a uint8 array. + * @param {string} input A hex encoded string. + * @returns {Uint8Array} A uint8 array corresponding to the input. + */ + public static hexToUint8 = (input: string): Uint8Array => { + if (0 !== input.length % 2) { + throw Error(`hex string has unexpected size '${input.length}'`); + } + const output = new Uint8Array(input.length / 2); + for (let i = 0; i < input.length; i += 2) { + output[i / 2] = Convert.toByte(input[i], input[i + 1]); + } + return output; + } + + /** + * Reversed convertion hex string to a uint8 array. + * @param {string} input A hex encoded string. + * @returns {Uint8Array} A uint8 array corresponding to the input. + */ + public static hexToUint8Reverse = (input: string): Uint8Array => { + if (0 !== input.length % 2) { + throw Error(`hex string has unexpected size '${input.length}'`); + } + const output = new Uint8Array(input.length / 2); + for (let i = 0; i < input.length; i += 2) { + output[output.length - 1 - (i / 2)] = Convert.toByte(input[i], input[i + 1]); + } + return output; + } + + /** + * Converts a uint8 array to a hex string. + * @param {Uint8Array} input A uint8 array. + * @returns {string} A hex encoded string corresponding to the input. + */ + public static uint8ToHex = (input) => { + let s = ''; + for (const byte of input) { + s += utilities.Nibble_To_Char_Map[byte >> 4]; + s += utilities.Nibble_To_Char_Map[byte & 0x0F]; + } + + return s; + } + + /** + * Converts a uint8 array to a uint32 array. + * @param {Uint8Array} input A uint8 array. + * @returns {Uint32Array} A uint32 array created from the input. + */ + public static uint8ToUint32 = (input) => new Uint32Array(input.buffer); + + /** + * Converts a uint32 array to a uint8 array. + * @param {Uint32Array} input A uint32 array. + * @returns {Uint8Array} A uint8 array created from the input. + */ + public static uint32ToUint8 = (input: Uint32Array): Uint8Array => new Uint8Array(input.buffer); + + /** Converts an unsigned byte to a signed byte with the same binary representation. + * @param {number} input An unsigned byte. + * @returns {number} A signed byte with the same binary representation as the input. + * + */ + public static uint8ToInt8 = (input: number): number => { + if (0xFF < input) { + throw Error(`input '${input}' is out of range`); + } + return input << 24 >> 24; + } + + /** Converts a signed byte to an unsigned byte with the same binary representation. + * @param {number} input A signed byte. + * @returns {number} An unsigned byte with the same binary representation as the input. + */ + public static int8ToUint8 = (input: number): number => { + if (127 < input || -128 > input) { + throw Error(`input '${input}' is out of range`); + } + return input & 0xFF; + } + + /** + * Converts a raw javascript string into a string of single byte characters using utf8 encoding. + * This makes it easier to perform other encoding operations on the string. + * @param {string} input - A raw string + * @return {string} - UTF-8 string + */ + public static rstr2utf8 = (input: string): string => { + let output = ''; + + for (let n = 0; n < input.length; n++) { + const c = input.charCodeAt(n); + + if (128 > c) { + output += String.fromCharCode(c); + } else if ((127 < c) && (2048 > c)) { + output += String.fromCharCode((c >> 6) | 192); + output += String.fromCharCode((c & 63) | 128); + } else { + output += String.fromCharCode((c >> 12) | 224); + output += String.fromCharCode(((c >> 6) & 63) | 128); + output += String.fromCharCode((c & 63) | 128); + } + } + + return output; + } + + /** + * Convert UTF-8 to hex + * @param {string} input - An UTF-8 string + * @return {string} + */ + public static utf8ToHex = (input: string): string => { + const rawString = Convert.rstr2utf8(input); + let result = ''; + for (let i = 0; i < rawString.length; i++) { + result += rawString.charCodeAt(i).toString(16); + } + return result; + } +} diff --git a/src/core/format/IdGenerator.ts b/src/core/format/IdGenerator.ts new file mode 100644 index 0000000000..e0ab0967b3 --- /dev/null +++ b/src/core/format/IdGenerator.ts @@ -0,0 +1,53 @@ +/* + * Copyright 2019 NEM + * + * 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 {sha3_256} from 'js-sha3'; +import * as utilities from './Utilities'; + +export class IdGenerator { + /** + * Generates a mosaic id given a nonce and a public id. + * @param {object} nonce The mosaic nonce. + * @param {object} ownerPublicId The public id. + * @returns {module:coders/uint64~uint64} The mosaic id. + */ + public static generateMosaicId = (nonce, ownerPublicId) => { + const hash = sha3_256.create(); + hash.update(nonce); + hash.update(ownerPublicId); + const result = new Uint32Array(hash.arrayBuffer()); + return [result[0], result[1] & 0x7FFFFFFF]; + } + + /** + * Parses a unified namespace name into a path. + * @param {string} name The unified namespace name. + * @returns {array} The namespace path. + */ + public static generateNamespacePath = (name: string) => { + if (0 >= name.length) { + utilities.throwInvalidFqn('having zero length', name); + } + let namespaceId = utilities.idGeneratorConst.namespace_base_id; + const path = []; + const start = utilities.split(name, (substringStart, size) => { + namespaceId = utilities.generateNamespaceId(namespaceId, utilities.extractPartName(name, substringStart, size)); + utilities.append(path, namespaceId, name); + }); + namespaceId = utilities.generateNamespaceId(namespaceId, utilities.extractPartName(name, start, name.length - start)); + utilities.append(path, namespaceId, name); + return path; + } +} diff --git a/src/core/format/RawAddress.ts b/src/core/format/RawAddress.ts new file mode 100644 index 0000000000..c512e3a4f4 --- /dev/null +++ b/src/core/format/RawAddress.ts @@ -0,0 +1,130 @@ +/* + * Copyright 2019 NEM + * + * 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 { sha3_256 } from 'js-sha3'; +import RIPEMD160 = require('ripemd160'); +import { Base32 } from './Base32'; +import { Convert } from './Convert'; +import { RawArray } from './RawArray'; + +export class RawAddress { + static readonly constants = { + sizes: { + ripemd160: 20, + addressDecoded: 25, + addressEncoded: 40, + key: 32, + checksum: 4, + }, + }; + /** + * Converts an encoded address string to a decoded address. + * @param {string} encoded The encoded address string. + * @returns {Uint8Array} The decoded address corresponding to the input. + */ + public static stringToAddress = (encoded: string): Uint8Array => { + if (RawAddress.constants.sizes.addressEncoded !== encoded.length) { + throw Error(`${encoded} does not represent a valid encoded address`); + } + + return Base32.Base32Decode(encoded); + } + + /** + * Format a namespaceId *alias* into a valid recipient field value. + * @param {Uint8Array} namespaceId The namespaceId + * @returns {Uint8Array} The padded notation of the alias + */ + public static aliasToRecipient = (namespaceId: Uint8Array): Uint8Array => { + // 0x91 | namespaceId on 8 bytes | 16 bytes 0-pad = 25 bytes + const padded = new Uint8Array(1 + 8 + 16); + padded.set([0x91], 0); + padded.set(namespaceId.reverse(), 1); + padded.set(Convert.hexToUint8('00'.repeat(16)), 9); + return padded; + } + + /** + * Converts a decoded address to an encoded address string. + * @param {Uint8Array} decoded The decoded address. + * @returns {string} The encoded address string corresponding to the input. + */ + public static addressToString = (decoded: Uint8Array): string => { + if (RawAddress.constants.sizes.addressDecoded !== decoded.length) { + throw Error(`${Convert.uint8ToHex(decoded)} does not represent a valid decoded address`); + } + + return Base32.Base32Encode(decoded); + } + + /** + * Converts a public key to a decoded address for a specific network. + * @param {Uint8Array} publicKey The public key. + * @param {number} networkIdentifier The network identifier. + * @returns {Uint8Array} The decoded address corresponding to the inputs. + */ + public static publicKeyToAddress = (publicKey: Uint8Array, networkIdentifier: number): Uint8Array => { + // step 1: sha3 hash of the public key + const publicKeyHash = (sha3_256 as any).arrayBuffer(publicKey); + + // step 2: ripemd160 hash of (1) + const ripemdHash = new RIPEMD160().update(new Buffer(publicKeyHash)).digest(); + + // step 3: add network identifier byte in front of (2) + const decodedAddress = new Uint8Array(RawAddress.constants.sizes.addressDecoded); + decodedAddress[0] = networkIdentifier; + RawArray.copy(decodedAddress, ripemdHash, RawAddress.constants.sizes.ripemd160, 1); + + // step 4: concatenate (3) and the checksum of (3) + const hash = (sha3_256 as any).arrayBuffer(decodedAddress.subarray(0, RawAddress.constants.sizes.ripemd160 + 1)); + RawArray.copy(decodedAddress, RawArray.uint8View(hash), + RawAddress.constants.sizes.checksum, RawAddress.constants.sizes.ripemd160 + 1); + + return decodedAddress; + } + + /** + * Determines the validity of a decoded address. + * @param {Uint8Array} decoded The decoded address. + * @returns {boolean} true if the decoded address is valid, false otherwise. + */ + public static isValidAddress = (decoded: Uint8Array): boolean => { + const hash = sha3_256.create(); + const checksumBegin = RawAddress.constants.sizes.addressDecoded - RawAddress.constants.sizes.checksum; + hash.update(decoded.subarray(0, checksumBegin)); + const checksum = new Uint8Array(RawAddress.constants.sizes.checksum); + RawArray.copy(checksum, RawArray.uint8View(hash.arrayBuffer()), RawAddress.constants.sizes.checksum); + return RawArray.deepEqual(checksum, decoded.subarray(checksumBegin)); + } + + /** + * Determines the validity of an encoded address string. + * @param {string} encoded The encoded address string. + * @returns {boolean} true if the encoded address string is valid, false otherwise. + */ + public static isValidEncodedAddress = (encoded: string): boolean => { + if (RawAddress.constants.sizes.addressEncoded !== encoded.length) { + return false; + } + + try { + const decoded = RawAddress.stringToAddress(encoded); + return RawAddress.isValidAddress(decoded); + } catch (err) { + return false; + } + } +} diff --git a/src/core/format/RawArray.ts b/src/core/format/RawArray.ts new file mode 100644 index 0000000000..d1c0bdad81 --- /dev/null +++ b/src/core/format/RawArray.ts @@ -0,0 +1,84 @@ +/* + * Copyright 2019 NEM + * + * 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 RawArray { + /** + * Creates a Uint8Array view on top of input. + * @param {ArrayBuffer|Uint8Array} input The input array. + * @returns {Uint8Array} A Uint8Array view on top of input. + */ + public static uint8View = (input) => { + if (ArrayBuffer === input.constructor) { + return new Uint8Array(input); + } else if (Uint8Array === input.constructor) { + return input; + } + + throw Error('unsupported type passed to uint8View'); + } + + /** + * Copies elements from a source array to a destination array. + * @param {Array} dest The destination array. + * @param {Array} src The source array. + * @param {number} [numElementsToCopy=undefined] The number of elements to copy. + * @param {number} [destOffset=0] The first index of the destination to write. + * @param {number} [srcOffset=0] The first index of the source to read. + */ + public static copy = (dest, src, numElementsToCopy?, destOffset = 0, srcOffset = 0) => { + const length = undefined === numElementsToCopy ? dest.length : numElementsToCopy; + for (let i = 0; i < length; ++i) { + dest[destOffset + i] = src[srcOffset + i]; + } + } + + /** + * Determines whether or not an array is zero-filled. + * @param {Array} array The array to check. + * @returns {boolean} true if the array is zero-filled, false otherwise. + */ + public static isZeroFilled = (array) => array.every(value => 0 === value); + + /** + * Deeply checks the equality of two arrays. + * @param {Array} lhs First array to compare. + * @param {Array} rhs Second array to compare. + * @param {number} [numElementsToCompare=undefined] The number of elements to compare. + * @returns {boolean} true if all compared elements are equal, false otherwise. + */ + public static deepEqual = (lhs, rhs, numElementsToCompare?) => { + let length = numElementsToCompare; + if (undefined === length) { + if (lhs.length !== rhs.length) { + return false; + } + + length = lhs.length; + } + + if (length > lhs.length || length > rhs.length) { + return false; + } + + for (let i = 0; i < length; ++i) { + if (lhs[i] !== rhs[i]) { + return false; + } + } + + return true; + } +} diff --git a/src/core/format/RawUInt64.ts b/src/core/format/RawUInt64.ts new file mode 100644 index 0000000000..81eaf3bf1e --- /dev/null +++ b/src/core/format/RawUInt64.ts @@ -0,0 +1,116 @@ +/* + * Copyright 2019 NEM + * + * 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 { Convert } from './Convert'; + +export class RawUInt64 { + static readonly readUint32At = (bytes, i) => (bytes[i] + (bytes[i + 1] << 8) + (bytes[i + 2] << 16) + (bytes[i + 3] << 24)) >>> 0; + + /** + * An exact uint64 representation composed of two 32bit values. + * @typedef {Array} uint64 + * @property {number} 0 The low 32bit value. + * @property {number} 1 The high 32bit value. + */ + /** + * Tries to compact a uint64 into a simple numeric. + * @param {module:coders/uint64~uint64} uint64 A uint64 value. + * @returns {number|module:coders/uint64~uint64} + * A numeric if the uint64 is no greater than Number.MAX_SAFE_INTEGER or the original uint64 value otherwise. + */ + public static compact = (uint64) => { + const low = uint64[0]; + const high = uint64[1]; + + // don't compact if the value is >= 2^53 + if (0x00200000 <= high) { + return uint64; + } + + // multiply because javascript bit operations operate on 32bit values + return (high * 0x100000000) + low; + } + + /** + * Converts a numeric unsigned integer into a uint64. + * @param {number} number The unsigned integer. + * @returns {module:coders/uint64~uint64} The uint64 representation of the input. + */ + public static fromUint = (number) => { + const value = [(number & 0xFFFFFFFF) >>> 0, (number / 0x100000000) >>> 0]; + return value; + } + + /** + * Converts a (64bit) uint8 array into a uint64. + * @param {Uint8Array} uint8Array A uint8 array. + * @returns {module:coders/uint64~uint64} The uint64 representation of the input. + */ + public static fromBytes = (uint8Array) => { + if (8 !== uint8Array.length) { + throw Error(`byte array has unexpected size '${uint8Array.length}'`); + } + return [RawUInt64.readUint32At(uint8Array, 0), RawUInt64.readUint32At(uint8Array, 4)]; + } + + /** + * Converts a (32bit) uint8 array into a uint64. + * @param {Uint8Array} uint8Array A uint8 array. + * @returns {module:coders/uint64~uint64} The uint64 representation of the input. + */ + public static fromBytes32 = (uint8Array) => { + if (4 !== uint8Array.length) { + throw Error(`byte array has unexpected size '${uint8Array.length}'`); + } + return [RawUInt64.readUint32At(uint8Array, 0), 0]; + } + + /** + * Parses a hex string into a uint64. + * @param {string} input A hex encoded string. + * @returns {module:coders/uint64~uint64} The uint64 representation of the input. + */ + public static fromHex = (input) => { + if (16 !== input.length) { + throw Error(`hex string has unexpected size '${input.length}'`); + } + let hexString = input; + if (16 > hexString.length) { + hexString = '0'.repeat(16 - hexString.length) + hexString; + } + const uint8Array = Convert.hexToUint8(hexString); + const view = new DataView(uint8Array.buffer); + return [view.getUint32(4), view.getUint32(0)]; + } + + /** + * Converts a uint64 into a hex string. + * @param {module:coders/uint64~uint64} uint64 A uint64 value. + * @returns {string} A hex encoded string representing the uint64. + */ + public static toHex = (uint64) => { + const uint32Array = new Uint32Array(uint64); + const uint8Array = Convert.uint32ToUint8(uint32Array).reverse(); + return Convert.uint8ToHex(uint8Array); + } + + /** + * Returns true if a uint64 is zero. + * @param {module:coders/uint64~uint64} uint64 A uint64 value. + * @returns {boolean} true if the value is zero. + */ + public static isZero = (uint64) => 0 === uint64[0] && 0 === uint64[1]; +} diff --git a/src/core/format/Utilities.ts b/src/core/format/Utilities.ts new file mode 100644 index 0000000000..fe0fc1b401 --- /dev/null +++ b/src/core/format/Utilities.ts @@ -0,0 +1,181 @@ +/* + * Copyright 2019 NEM + * + * 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 {sha3_256} from 'js-sha3'; + +export const createBuilder = () => { + const map = {}; + return { + map, + /** + * Adds a range mapping to the map. + * @param {string} start The start character. + * @param {string} end The end character. + * @param {number} base The value corresponding to the start character. + * @memberof module:utils/charMapping~CharacterMapBuilder + * @instance + */ + addRange: (start, end, base) => { + const startCode = start.charCodeAt(0); + const endCode = end.charCodeAt(0); + + for (let code = startCode; code <= endCode; ++code) { + map[String.fromCharCode(code)] = code - startCode + base; + } + }, + }; +}; + +const Char_To_Nibble_Map = () => { + const builder = createBuilder(); + builder.addRange('0', '9', 0); + builder.addRange('a', 'f', 10); + builder.addRange('A', 'F', 10); + return builder.map; +}; + +const Char_To_Digit_Map = () => { + const builder = createBuilder(); + builder.addRange('0', '9', 0); + return builder.map; +}; + +export const Nibble_To_Char_Map = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']; +export const Alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; +export const Decoded_Block_Size = 5; +export const Encoded_Block_Size = 8; +export const tryParseByte = (char1, char2) => { + const charMap = Char_To_Nibble_Map(); + const nibble1 = charMap[char1]; + const nibble2 = charMap[char2]; + return undefined === nibble1 || undefined === nibble2 ? + undefined : + (nibble1 << 4) | nibble2; +}; + +/** + * Tries to parse a string representing an unsigned integer. + * @param {string} str The string to parse. + * @returns {number} The number represented by the input or undefined. + */ +export const tryParseUint = (str) => { + if ('0' === str) { + return 0; + } + let value = 0; + for (const char of str) { + const charMap = Char_To_Digit_Map(); + const digit = charMap[char]; + if (undefined === digit || (0 === value && 0 === digit)) { + return undefined; + } + + value *= 10; + value += digit; + + if (value > Number.MAX_SAFE_INTEGER) { + return undefined; + } + } + return value; +}; + +export const idGeneratorConst = { + namespace_base_id: [0, 0], + namespace_max_depth: 3, + name_pattern: /^[a-z0-9][a-z0-9-_]*$/, +}; + +export const throwInvalidFqn = (reason, name) => { + throw Error(`fully qualified id is invalid due to ${reason} (${name})`); +}; + +export const extractPartName = (name, start, size) => { + if (0 === size) { + this.throwInvalidFqn('empty part', name); + } + const partName = name.substr(start, size); + if (!idGeneratorConst.name_pattern.test(partName)) { + this.throwInvalidFqn(`invalid part name [${partName}]`, name); + } + return partName; +}; + +export const append = (path, id, name) => { + if (idGeneratorConst.namespace_max_depth === path.length) { + this.throwInvalidFqn('too many parts', name); + } + path.push(id); +}; + +export const split = (name, processor) => { + let start = 0; + for (let index = 0; index < name.length; ++index) { + if ('.' === name[index]) { + processor(start, index - start); + start = index + 1; + } + } + return start; +}; + +export const generateNamespaceId = (parentId, name) => { + const hash = sha3_256.create(); + hash.update(Uint32Array.from(parentId).buffer); + hash.update(name); + const result = new Uint32Array(hash.arrayBuffer()); + // right zero-filling required to keep unsigned number representation + return [result[0], (result[1] | 0x80000000) >>> 0]; +}; + +export const encodeBlock = (input, inputOffset, output, outputOffset) => { + output[outputOffset + 0] = Alphabet[input[inputOffset + 0] >> 3]; + output[outputOffset + 1] = Alphabet[((input[inputOffset + 0] & 0x07) << 2) | (input[inputOffset + 1] >> 6)]; + output[outputOffset + 2] = Alphabet[(input[inputOffset + 1] & 0x3E) >> 1]; + output[outputOffset + 3] = Alphabet[((input[inputOffset + 1] & 0x01) << 4) | (input[inputOffset + 2] >> 4)]; + output[outputOffset + 4] = Alphabet[((input[inputOffset + 2] & 0x0F) << 1) | (input[inputOffset + 3] >> 7)]; + output[outputOffset + 5] = Alphabet[(input[inputOffset + 3] & 0x7F) >> 2]; + output[outputOffset + 6] = Alphabet[((input[inputOffset + 3] & 0x03) << 3) | (input[inputOffset + 4] >> 5)]; + output[outputOffset + 7] = Alphabet[input[inputOffset + 4] & 0x1F]; +}; + +export const Char_To_Decoded_Char_Map = () => { + const builder = this.createBuilder(); + builder.addRange('A', 'Z', 0); + builder.addRange('2', '7', 26); + return builder.map; +}; + +export const decodeChar = (c) => { + const charMap = Char_To_Decoded_Char_Map(); + const decodedChar = charMap[c]; + if (undefined !== decodedChar) { + return decodedChar; + } + throw Error(`illegal base32 character ${c}`); +}; + +export const decodeBlock = (input, inputOffset, output, outputOffset) => { + const bytes = new Uint8Array(this.Encoded_Block_Size); + for (let i = 0; i < this.Encoded_Block_Size; ++i) { + bytes[i] = decodeChar(input[inputOffset + i]); + } + + output[outputOffset + 0] = (bytes[0] << 3) | (bytes[1] >> 2); + output[outputOffset + 1] = ((bytes[1] & 0x03) << 6) | (bytes[2] << 1) | (bytes[3] >> 4); + output[outputOffset + 2] = ((bytes[3] & 0x0F) << 4) | (bytes[4] >> 1); + output[outputOffset + 3] = ((bytes[4] & 0x01) << 7) | (bytes[5] << 2) | (bytes[6] >> 3); + output[outputOffset + 4] = ((bytes[6] & 0x07) << 5) | bytes[7]; +}; diff --git a/src/core/format/index.ts b/src/core/format/index.ts new file mode 100644 index 0000000000..27fc8ea316 --- /dev/null +++ b/src/core/format/index.ts @@ -0,0 +1,21 @@ +/* + * Copyright 2019 NEM + * + * 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 * from './RawAddress'; +export * from './RawArray'; +export * from './Convert'; +export * from './IdGenerator'; +export * from './RawUInt64'; diff --git a/src/infrastructure/AccountHttp.ts b/src/infrastructure/AccountHttp.ts index 1efce1417e..7c53b58c7d 100644 --- a/src/infrastructure/AccountHttp.ts +++ b/src/infrastructure/AccountHttp.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import {AccountRoutesApi} from 'nem2-library'; import {from as observableFrom, Observable} from 'rxjs'; import {map, mergeMap} from 'rxjs/operators'; import { DtoMapping } from '../core/utils/DtoMapping'; @@ -33,6 +32,15 @@ import {AggregateTransaction} from '../model/transaction/AggregateTransaction'; import {Transaction} from '../model/transaction/Transaction'; import {UInt64} from '../model/UInt64'; import {AccountRepository} from './AccountRepository'; +import { AccountInfoDTO, + AccountNamesDTO, + AccountPropertiesDTO, + AccountPropertiesInfoDTO, + AccountRoutesApi, + MosaicDTO, + MultisigAccountGraphInfoDTO, + MultisigAccountInfoDTO, + TransactionInfoDTO } from './api'; import {Http} from './Http'; import {NetworkHttp} from './NetworkHttp'; import {QueryParams} from './QueryParams'; @@ -57,8 +65,8 @@ export class AccountHttp extends Http implements AccountRepository { */ constructor(url: string, networkHttp?: NetworkHttp) { networkHttp = networkHttp == null ? new NetworkHttp(url) : networkHttp; - super(url, networkHttp); - this.accountRoutesApi = new AccountRoutesApi(this.apiClient); + super(networkHttp); + this.accountRoutesApi = new AccountRoutesApi(url); } /** @@ -67,7 +75,7 @@ export class AccountHttp extends Http implements AccountRepository { * @returns Observable */ public getAccountInfo(address: Address): Observable { - return observableFrom(this.accountRoutesApi.getAccountInfo(address.plain())).pipe(map((accountInfoDTO) => { + return observableFrom(this.accountRoutesApi.getAccountInfo(address.plain())).pipe(map((accountInfoDTO: AccountInfoDTO) => { return new AccountInfo( accountInfoDTO.meta, Address.createFromEncoded(accountInfoDTO.account.address), @@ -90,7 +98,8 @@ export class AccountHttp extends Http implements AccountRepository { * @returns Observable */ public getAccountProperties(address: Address): Observable { - return observableFrom(this.accountRoutesApi.getAccountProperties(address.plain())).pipe(map((accountProperties) => { + return observableFrom(this.accountRoutesApi.getAccountProperties(address.plain())) + .pipe(map((accountProperties: AccountPropertiesInfoDTO) => { return DtoMapping.extractAccountPropertyFromDto(accountProperties); })); } @@ -105,7 +114,8 @@ export class AccountHttp extends Http implements AccountRepository { addresses: addresses.map((address) => address.plain()), }; return observableFrom( - this.accountRoutesApi.getAccountPropertiesFromAccounts(accountIds)).pipe(map((accountProperties) => { + this.accountRoutesApi.getAccountPropertiesFromAccounts(accountIds)) + .pipe(map((accountProperties: AccountPropertiesDTO[]) => { return accountProperties.map((property) => { return DtoMapping.extractAccountPropertyFromDto(property); }); @@ -122,15 +132,16 @@ export class AccountHttp extends Http implements AccountRepository { addresses: addresses.map((address) => address.plain()), }; return observableFrom( - this.accountRoutesApi.getAccountsInfo(accountIdsBody)).pipe(map((accountsInfoMetaDataDTO) => { - return accountsInfoMetaDataDTO.map((accountInfoDTO) => { + this.accountRoutesApi.getAccountsInfo(accountIdsBody)).pipe(map((accountsInfoMetaDataDTO: AccountInfoDTO[]) => { + return accountsInfoMetaDataDTO.map((accountInfoDTO: AccountInfoDTO) => { return new AccountInfo( accountInfoDTO.meta, Address.createFromEncoded(accountInfoDTO.account.address), new UInt64(accountInfoDTO.account.addressHeight), accountInfoDTO.account.publicKey, new UInt64(accountInfoDTO.account.publicKeyHeight), - accountInfoDTO.account.mosaics.map((mosaicDTO) => new Mosaic(mosaicDTO.id, mosaicDTO.amount)), + accountInfoDTO.account.mosaics.map((mosaicDTO: MosaicDTO) => + new Mosaic(new MosaicId(mosaicDTO.id), new UInt64(mosaicDTO.amount))), new UInt64(accountInfoDTO.account.importance), new UInt64(accountInfoDTO.account.importanceHeight), ); @@ -143,12 +154,12 @@ export class AccountHttp extends Http implements AccountRepository { addresses: addresses.map((address) => address.plain()), }; return observableFrom( - this.accountRoutesApi.getAccountsNames(accountIdsBody)).pipe(map((accountNames) => { + this.accountRoutesApi.getAccountsNames(accountIdsBody)).pipe(map((accountNames: AccountNamesDTO[]) => { return accountNames.map((accountName) => { return new AccountNames( Address.createFromEncoded(accountName.address), accountName.names.map((name) => { - new NamespaceName(new NamespaceId(name), name); + return new NamespaceName(new NamespaceId(name), name); }), ); }); @@ -162,7 +173,8 @@ export class AccountHttp extends Http implements AccountRepository { public getMultisigAccountInfo(address: Address): Observable { return this.getNetworkTypeObservable().pipe( mergeMap((networkType) => observableFrom( - this.accountRoutesApi.getAccountMultisig(address.plain())).pipe(map((multisigAccountInfoDTO) => { + this.accountRoutesApi.getAccountMultisig(address.plain())) + .pipe(map((multisigAccountInfoDTO: MultisigAccountInfoDTO) => { return new MultisigAccountInfo( PublicAccount.createFromPublicKey(multisigAccountInfoDTO.multisig.account, networkType), multisigAccountInfoDTO.multisig.minApproval, @@ -183,7 +195,8 @@ export class AccountHttp extends Http implements AccountRepository { public getMultisigAccountGraphInfo(address: Address): Observable { return this.getNetworkTypeObservable().pipe( mergeMap((networkType) => observableFrom( - this.accountRoutesApi.getAccountMultisigGraph(address.plain())).pipe(map((multisigAccountGraphInfosDTO) => { + this.accountRoutesApi.getAccountMultisigGraph(address.plain())) + .pipe(map((multisigAccountGraphInfosDTO: MultisigAccountGraphInfoDTO[]) => { const multisigAccounts = new Map(); multisigAccountGraphInfosDTO.map((multisigAccountGraphInfoDTO) => { multisigAccounts.set(multisigAccountGraphInfoDTO.level, @@ -211,8 +224,11 @@ export class AccountHttp extends Http implements AccountRepository { */ public transactions(publicAccount: PublicAccount, queryParams?: QueryParams): Observable { return observableFrom( - this.accountRoutesApi.transactions(publicAccount.publicKey, queryParams != null ? queryParams : {})).pipe( - map((transactionsDTO) => { + this.accountRoutesApi.transactions(publicAccount.publicKey, + this.queryParams(queryParams).pageSize, + this.queryParams(queryParams).id, + this.queryParams(queryParams).order)).pipe( + map((transactionsDTO: TransactionInfoDTO[]) => { return transactionsDTO.map((transactionDTO) => { return CreateTransactionFromDTO(transactionDTO); }); @@ -228,8 +244,11 @@ export class AccountHttp extends Http implements AccountRepository { */ public incomingTransactions(publicAccount: PublicAccount, queryParams?: QueryParams): Observable { return observableFrom( - this.accountRoutesApi.incomingTransactions(publicAccount.publicKey, queryParams != null ? queryParams : {})).pipe( - map((transactionsDTO) => { + this.accountRoutesApi.incomingTransactions(publicAccount.publicKey, + this.queryParams(queryParams).pageSize, + this.queryParams(queryParams).id, + this.queryParams(queryParams).order)).pipe( + map((transactionsDTO: TransactionInfoDTO[]) => { return transactionsDTO.map((transactionDTO) => { return CreateTransactionFromDTO(transactionDTO); }); @@ -245,8 +264,11 @@ export class AccountHttp extends Http implements AccountRepository { */ public outgoingTransactions(publicAccount: PublicAccount, queryParams?: QueryParams): Observable { return observableFrom( - this.accountRoutesApi.outgoingTransactions(publicAccount.publicKey, queryParams != null ? queryParams : {})).pipe( - map((transactionsDTO) => { + this.accountRoutesApi.outgoingTransactions(publicAccount.publicKey, + this.queryParams(queryParams).pageSize, + this.queryParams(queryParams).id, + this.queryParams(queryParams).order)).pipe( + map((transactionsDTO: TransactionInfoDTO[]) => { return transactionsDTO.map((transactionDTO) => { return CreateTransactionFromDTO(transactionDTO); }); @@ -263,8 +285,11 @@ export class AccountHttp extends Http implements AccountRepository { */ public unconfirmedTransactions(publicAccount: PublicAccount, queryParams?: QueryParams): Observable { return observableFrom( - this.accountRoutesApi.unconfirmedTransactions(publicAccount.publicKey, queryParams != null ? queryParams : {})).pipe( - map((transactionsDTO) => { + this.accountRoutesApi.unconfirmedTransactions(publicAccount.publicKey, + this.queryParams(queryParams).pageSize, + this.queryParams(queryParams).id, + this.queryParams(queryParams).order)).pipe( + map((transactionsDTO: TransactionInfoDTO[]) => { return transactionsDTO.map((transactionDTO) => { return CreateTransactionFromDTO(transactionDTO); }); @@ -280,8 +305,11 @@ export class AccountHttp extends Http implements AccountRepository { */ public aggregateBondedTransactions(publicAccount: PublicAccount, queryParams?: QueryParams): Observable { return observableFrom( - this.accountRoutesApi.partialTransactions(publicAccount.publicKey, queryParams != null ? queryParams : {})).pipe( - map((transactionsDTO) => { + this.accountRoutesApi.partialTransactions(publicAccount.publicKey, + this.queryParams(queryParams).pageSize, + this.queryParams(queryParams).id, + this.queryParams(queryParams).order)).pipe( + map((transactionsDTO: TransactionInfoDTO[]) => { return transactionsDTO.map((transactionDTO) => { return CreateTransactionFromDTO(transactionDTO) as AggregateTransaction; }); diff --git a/src/infrastructure/BlockHttp.ts b/src/infrastructure/BlockHttp.ts index 0f9ba1eead..f04089fb52 100644 --- a/src/infrastructure/BlockHttp.ts +++ b/src/infrastructure/BlockHttp.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import {BlockRoutesApi} from 'nem2-library'; import {from as observableFrom, Observable} from 'rxjs'; import {map, mergeMap} from 'rxjs/operators'; import {PublicAccount} from '../model/account/PublicAccount'; @@ -25,13 +24,32 @@ import { MerkleProofInfoPayload } from '../model/blockchain/MerkleProofInfoPaylo import { Statement } from '../model/receipt/Statement'; import {Transaction} from '../model/transaction/Transaction'; import {UInt64} from '../model/UInt64'; +import { BlockInfoDTO, + BlockRoutesApi, + MerkleProofInfoDTO, + StatementsDTO, + TransactionInfoDTO } from './api'; import {BlockRepository} from './BlockRepository'; import {Http} from './Http'; +import { NetworkHttp } from './NetworkHttp'; import {QueryParams} from './QueryParams'; import { CreateStatementFromDTO } from './receipt/CreateReceiptFromDTO'; import {CreateTransactionFromDTO, extractBeneficiary} from './transaction/CreateTransactionFromDTO'; -import { NetworkHttp } from './NetworkHttp'; +/** + * Blocks returned limits: + * N_25: 25 blocks. + * N_50: 50 blocks. + * N_75: 75 blocks. + * N_100: 100 blocks. + */ +export enum LimitType { + N_25 = 25, + N_50 = 50, + N_75 = 75, + N_100 = 100, + +} /** * Blockchain http repository. * @@ -47,11 +65,12 @@ export class BlockHttp extends Http implements BlockRepository { /** * Constructor * @param url + * @param networkHttp */ constructor(url: string, networkHttp?: NetworkHttp) { networkHttp = networkHttp == null ? new NetworkHttp(url) : networkHttp; - super(url, networkHttp); - this.blockRoutesApi = new BlockRoutesApi(this.apiClient); + super(networkHttp); + this.blockRoutesApi = new BlockRoutesApi(url); } /** @@ -60,8 +79,8 @@ export class BlockHttp extends Http implements BlockRepository { * @returns Observable */ public getBlockByHeight(height: number): Observable { - return observableFrom(this.blockRoutesApi.getBlockByHeight(height)).pipe(map((blockDTO) => { - const networkType = parseInt(blockDTO.block.version.toString(16).substr(0, 2), 16); + return observableFrom(this.blockRoutesApi.getBlockByHeight(height)).pipe(map((blockDTO: BlockInfoDTO) => { + const networkType = parseInt((blockDTO.block.version as number).toString(16).substr(0, 2), 16); return new BlockInfo( blockDTO.meta.hash, blockDTO.meta.generationHash, @@ -70,7 +89,7 @@ export class BlockHttp extends Http implements BlockRepository { blockDTO.block.signature, PublicAccount.createFromPublicKey(blockDTO.block.signer, networkType), networkType, - parseInt(blockDTO.block.version.toString(16).substr(2, 2), 16), // Tx version + parseInt((blockDTO.block.version as number).toString(16).substr(2, 2), 16), // Tx version blockDTO.block.type, new UInt64(blockDTO.block.height), new UInt64(blockDTO.block.timestamp), @@ -94,24 +113,28 @@ export class BlockHttp extends Http implements BlockRepository { public getBlockTransactions(height: number, queryParams?: QueryParams): Observable { return observableFrom( - this.blockRoutesApi.getBlockTransactions(height, queryParams != null ? queryParams : {})).pipe(map((transactionsDTO) => { - return transactionsDTO.map((transactionDTO) => { - return CreateTransactionFromDTO(transactionDTO); - }); + this.blockRoutesApi.getBlockTransactions(height, + this.queryParams(queryParams).pageSize, + this.queryParams(queryParams).id, + this.queryParams(queryParams).order)) + .pipe(map((transactionsDTO: TransactionInfoDTO[]) => { + return transactionsDTO.map((transactionDTO) => { + return CreateTransactionFromDTO(transactionDTO); + }); })); } /** * Gets array of BlockInfo for a block height with limit * @param height - Block height from which will be the first block in the array - * @param limit - Number of blocks returned + * @param limit - Number of blocks returned. Limit value only available in 25, 50. 75 and 100. (default 25) * @returns Observable */ - public getBlocksByHeightWithLimit(height: number, limit: number = 1): Observable { + public getBlocksByHeightWithLimit(height: number, limit: LimitType = LimitType.N_25): Observable { return observableFrom( - this.blockRoutesApi.getBlocksByHeightWithLimit(height, limit)).pipe(map((blocksDTO) => { + this.blockRoutesApi.getBlocksByHeightWithLimit(height, limit)).pipe(map((blocksDTO: BlockInfoDTO[]) => { return blocksDTO.map((blockDTO) => { - const networkType = parseInt(blockDTO.block.version.toString(16).substr(0, 2), 16); + const networkType = parseInt((blockDTO.block.version as number).toString(16).substr(0, 2), 16); return new BlockInfo( blockDTO.meta.hash, blockDTO.meta.generationHash, @@ -120,7 +143,7 @@ export class BlockHttp extends Http implements BlockRepository { blockDTO.block.signature, PublicAccount.createFromPublicKey(blockDTO.block.signer, networkType), networkType, - parseInt(blockDTO.block.version.toString(16).substr(2, 2), 16), // Tx version + parseInt((blockDTO.block.version as number).toString(16).substr(2, 2), 16), // Tx version blockDTO.block.type, new UInt64(blockDTO.block.height), new UInt64(blockDTO.block.timestamp), @@ -148,10 +171,11 @@ export class BlockHttp extends Http implements BlockRepository { */ public getMerkleReceipts(height: number, hash: string): Observable { return observableFrom( - this.blockRoutesApi.getMerkleReceipts(height, hash)).pipe(map((merkleProofReceipt) => { + this.blockRoutesApi.getMerkleReceipts(height, hash)).pipe(map((merkleProofReceipt: MerkleProofInfoDTO) => { return new MerkleProofInfo( new MerkleProofInfoPayload( - merkleProofReceipt.payload.merklePath.map((payload) => new MerklePathItem(payload.position, payload.hash))), + merkleProofReceipt.payload.merklePath!.map( + (payload) => new MerklePathItem(payload.position, payload.hash))), merkleProofReceipt.type, ); })); @@ -169,11 +193,11 @@ export class BlockHttp extends Http implements BlockRepository { */ public getMerkleTransaction(height: number, hash: string): Observable { return observableFrom( - this.blockRoutesApi.getMerkleReceipts(height, hash)).pipe(map((merkleProofReceipt) => { + this.blockRoutesApi.getMerkleReceipts(height, hash)).pipe(map((merkleProofTransaction: MerkleProofInfoDTO) => { return new MerkleProofInfo( new MerkleProofInfoPayload( - merkleProofReceipt.payload.merklePath.map((payload) => new MerklePathItem(payload.position, payload.hash))), - merkleProofReceipt.type, + merkleProofTransaction.payload.merklePath!.map((payload) => new MerklePathItem(payload.position, payload.hash))), + merkleProofTransaction.type, ); })); } @@ -188,7 +212,7 @@ export class BlockHttp extends Http implements BlockRepository { return this.getNetworkTypeObservable().pipe( mergeMap((networkType) => observableFrom( this.blockRoutesApi.getBlockReceipts(height)).pipe( - map((receiptDTO) => { + map((receiptDTO: StatementsDTO) => { return CreateStatementFromDTO(receiptDTO, networkType); }), ), diff --git a/src/infrastructure/ChainHttp.ts b/src/infrastructure/ChainHttp.ts index 6444eef34b..c791b69297 100644 --- a/src/infrastructure/ChainHttp.ts +++ b/src/infrastructure/ChainHttp.ts @@ -14,11 +14,13 @@ * limitations under the License. */ -import {ChainRoutesApi} from 'nem2-library'; import {from as observableFrom, Observable} from 'rxjs'; import {map} from 'rxjs/operators'; import {BlockchainScore} from '../model/blockchain/BlockchainScore'; import {UInt64} from '../model/UInt64'; +import { BlockchainScoreDTO, + ChainRoutesApi, + HeightInfoDTO } from './api'; import { ChainRepository } from './ChainRepository'; import {Http} from './Http'; @@ -39,8 +41,8 @@ export class ChainHttp extends Http implements ChainRepository { * @param url */ constructor(url: string) { - super(url); - this.chainRoutesApi = new ChainRoutesApi(this.apiClient); + super(); + this.chainRoutesApi = new ChainRoutesApi(url); } /** @@ -48,7 +50,7 @@ export class ChainHttp extends Http implements ChainRepository { * @returns Observable */ public getBlockchainHeight(): Observable { - return observableFrom(this.chainRoutesApi.getBlockchainHeight()).pipe(map((heightDTO) => { + return observableFrom(this.chainRoutesApi.getBlockchainHeight()).pipe(map((heightDTO: HeightInfoDTO) => { return new UInt64(heightDTO.height); })); } @@ -58,7 +60,7 @@ export class ChainHttp extends Http implements ChainRepository { * @returns Observable */ public getBlockchainScore(): Observable { - return observableFrom(this.chainRoutesApi.getBlockchainScore()).pipe(map((blockchainScoreDTO) => { + return observableFrom(this.chainRoutesApi.getBlockchainScore()).pipe(map((blockchainScoreDTO: BlockchainScoreDTO) => { return new BlockchainScore( new UInt64(blockchainScoreDTO.scoreLow), new UInt64(blockchainScoreDTO.scoreHigh), diff --git a/src/infrastructure/DiagnosticHttp.ts b/src/infrastructure/DiagnosticHttp.ts index acf911c033..be17dbcf5e 100644 --- a/src/infrastructure/DiagnosticHttp.ts +++ b/src/infrastructure/DiagnosticHttp.ts @@ -14,11 +14,11 @@ * limitations under the License. */ -import {DiagnosticRoutesApi} from 'nem2-library'; import {from as observableFrom, Observable} from 'rxjs'; import {map} from 'rxjs/operators'; import {BlockchainStorageInfo} from '../model/blockchain/BlockchainStorageInfo'; import { ServerInfo } from '../model/diagnostic/ServerInfo'; +import { DiagnosticRoutesApi, ServerDTO, StorageInfoDTO } from './api'; import {DiagnosticRepository} from './DiagnosticRepository'; import {Http} from './Http'; @@ -39,8 +39,8 @@ export class DiagnosticHttp extends Http implements DiagnosticRepository { * @param url */ constructor(url: string) { - super(url); - this.diagnosticRoutesApi = new DiagnosticRoutesApi(this.apiClient); + super(); + this.diagnosticRoutesApi = new DiagnosticRoutesApi(url); } /** @@ -49,7 +49,7 @@ export class DiagnosticHttp extends Http implements DiagnosticRepository { */ public getDiagnosticStorage(): Observable { return observableFrom( - this.diagnosticRoutesApi.getDiagnosticStorage()).pipe(map((blockchainStorageInfoDTO) => { + this.diagnosticRoutesApi.getDiagnosticStorage()).pipe(map((blockchainStorageInfoDTO: StorageInfoDTO) => { return new BlockchainStorageInfo( blockchainStorageInfoDTO.numBlocks, blockchainStorageInfoDTO.numTransactions, @@ -64,7 +64,7 @@ export class DiagnosticHttp extends Http implements DiagnosticRepository { */ public getServerInfo(): Observable { return observableFrom( - this.diagnosticRoutesApi.getServerInfo()).pipe(map((serverDTO) => { + this.diagnosticRoutesApi.getServerInfo()).pipe(map((serverDTO: ServerDTO) => { return new ServerInfo(serverDTO.serverInfo.restVersion, serverDTO.serverInfo.sdkVersion); })); diff --git a/src/infrastructure/Http.ts b/src/infrastructure/Http.ts index 2a4120d93b..7185797d17 100644 --- a/src/infrastructure/Http.ts +++ b/src/infrastructure/Http.ts @@ -14,21 +14,15 @@ * limitations under the License. */ -import {ApiClient} from 'nem2-library'; import {Observable, of as observableOf} from 'rxjs'; import {map} from 'rxjs/operators'; import {NetworkType} from '../model/blockchain/NetworkType'; import {NetworkHttp} from './NetworkHttp'; - +import { QueryParams } from './QueryParams'; /** * Http extended by all http services */ export abstract class Http { - /** - * @internal - */ - protected readonly apiClient; - private networkHttp: NetworkHttp; private networkType: NetworkType; @@ -37,11 +31,7 @@ export abstract class Http { * @param url * @param networkHttp */ - constructor(url: string, networkHttp?: NetworkHttp) { - this.apiClient = new ApiClient(); - if (url) { - this.apiClient.basePath = url; - } + constructor(networkHttp?: NetworkHttp) { if (networkHttp) { this.networkHttp = networkHttp; } @@ -59,4 +49,12 @@ export abstract class Http { } return networkTypeResolve; } + + queryParams(queryParams?: QueryParams): any { + return { + pageSize: queryParams ? queryParams.pageSize : undefined, + id: queryParams ? queryParams.id : undefined, + order: queryParams ? queryParams.order : undefined, + }; + } } diff --git a/src/infrastructure/MosaicHttp.ts b/src/infrastructure/MosaicHttp.ts index 588868ff3b..95782d33bf 100644 --- a/src/infrastructure/MosaicHttp.ts +++ b/src/infrastructure/MosaicHttp.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import {MosaicRoutesApi} from 'nem2-library'; import {from as observableFrom, Observable} from 'rxjs'; import {map, mergeMap} from 'rxjs/operators'; import {PublicAccount} from '../model/account/PublicAccount'; @@ -26,6 +25,7 @@ import { MosaicPropertyType } from '../model/mosaic/MosaicPropertyType'; import {NamespaceId} from '../model/namespace/NamespaceId'; import { NamespaceName } from '../model/namespace/NamespaceName'; import {UInt64} from '../model/UInt64'; +import { MosaicInfoDTO, MosaicNamesDTO, MosaicRoutesApi } from './api'; import {Http} from './Http'; import {MosaicRepository} from './MosaicRepository'; import {NetworkHttp} from './NetworkHttp'; @@ -49,8 +49,8 @@ export class MosaicHttp extends Http implements MosaicRepository { */ constructor(url: string, networkHttp?: NetworkHttp) { networkHttp = networkHttp == null ? new NetworkHttp(url) : networkHttp; - super(url, networkHttp); - this.mosaicRoutesApi = new MosaicRoutesApi(this.apiClient); + super(networkHttp); + this.mosaicRoutesApi = new MosaicRoutesApi(url); } /** @@ -61,19 +61,31 @@ export class MosaicHttp extends Http implements MosaicRepository { public getMosaic(mosaicId: MosaicId): Observable { return this.getNetworkTypeObservable().pipe( mergeMap((networkType) => observableFrom( - this.mosaicRoutesApi.getMosaic(mosaicId.toHex())).pipe(map((mosaicInfoDTO) => { - return new MosaicInfo( - mosaicInfoDTO.meta.id, - new MosaicId(mosaicInfoDTO.mosaic.mosaicId), - new UInt64(mosaicInfoDTO.mosaic.supply), - new UInt64(mosaicInfoDTO.mosaic.height), - PublicAccount.createFromPublicKey(mosaicInfoDTO.mosaic.owner, networkType), - mosaicInfoDTO.mosaic.revision, - new MosaicProperties( - new UInt64(mosaicInfoDTO.mosaic.properties[MosaicPropertyType.MosaicFlags].value), - (new UInt64(mosaicInfoDTO.mosaic.properties[MosaicPropertyType.Divisibility].value)).compact(), - new UInt64(mosaicInfoDTO.mosaic.properties[MosaicPropertyType.Duration].value), - ), + this.mosaicRoutesApi.getMosaic(mosaicId.toHex())).pipe(map((mosaicInfoDTO: MosaicInfoDTO) => { + let mosaicFlag; + let divisibility; + let duration; + if (mosaicInfoDTO.mosaic.properties[MosaicPropertyType.MosaicFlags].value) { + mosaicFlag = mosaicInfoDTO.mosaic.properties[MosaicPropertyType.MosaicFlags].value; + } + if (mosaicInfoDTO.mosaic.properties[MosaicPropertyType.Divisibility].value) { + divisibility = mosaicInfoDTO.mosaic.properties[MosaicPropertyType.Divisibility].value; + } + if (mosaicInfoDTO.mosaic.properties[MosaicPropertyType.Duration].value) { + duration = mosaicInfoDTO.mosaic.properties[MosaicPropertyType.Divisibility].value; + } + return new MosaicInfo( + mosaicInfoDTO.meta.id, + new MosaicId(mosaicInfoDTO.mosaic.mosaicId), + new UInt64(mosaicInfoDTO.mosaic.supply), + new UInt64(mosaicInfoDTO.mosaic.height), + PublicAccount.createFromPublicKey(mosaicInfoDTO.mosaic.owner, networkType), + mosaicInfoDTO.mosaic.revision, + new MosaicProperties( + new UInt64(mosaicFlag), + (new UInt64(divisibility)).compact(), + duration ? new UInt64(duration) : undefined, + ), ); })))); } @@ -89,8 +101,20 @@ export class MosaicHttp extends Http implements MosaicRepository { }; return this.getNetworkTypeObservable().pipe( mergeMap((networkType) => observableFrom( - this.mosaicRoutesApi.getMosaics(mosaicIdsBody)).pipe(map((mosaicInfosDTO) => { + this.mosaicRoutesApi.getMosaics(mosaicIdsBody)).pipe(map((mosaicInfosDTO: MosaicInfoDTO[]) => { return mosaicInfosDTO.map((mosaicInfoDTO) => { + let mosaicFlag; + let divisibility; + let duration; + if (mosaicInfoDTO.mosaic.properties[MosaicPropertyType.MosaicFlags].value) { + mosaicFlag = mosaicInfoDTO.mosaic.properties[MosaicPropertyType.MosaicFlags].value; + } + if (mosaicInfoDTO.mosaic.properties[MosaicPropertyType.Divisibility].value) { + divisibility = mosaicInfoDTO.mosaic.properties[MosaicPropertyType.Divisibility].value; + } + if (mosaicInfoDTO.mosaic.properties[MosaicPropertyType.Duration].value) { + duration = mosaicInfoDTO.mosaic.properties[MosaicPropertyType.Divisibility].value; + } return new MosaicInfo( mosaicInfoDTO.meta.id, new MosaicId(mosaicInfoDTO.mosaic.mosaicId), @@ -99,9 +123,9 @@ export class MosaicHttp extends Http implements MosaicRepository { PublicAccount.createFromPublicKey(mosaicInfoDTO.mosaic.owner, networkType), mosaicInfoDTO.mosaic.revision, new MosaicProperties( - new UInt64(mosaicInfoDTO.mosaic.properties[MosaicPropertyType.MosaicFlags].value), - (new UInt64(mosaicInfoDTO.mosaic.properties[MosaicPropertyType.Divisibility].value)).compact(), - new UInt64(mosaicInfoDTO.mosaic.properties[MosaicPropertyType.Duration].value), + new UInt64(mosaicFlag), + (new UInt64(divisibility)).compact(), + duration ? new UInt64(duration) : undefined, ), ); }); @@ -119,12 +143,12 @@ export class MosaicHttp extends Http implements MosaicRepository { mosaicIds: mosaicIds.map((id) => id.toHex()), }; return observableFrom( - this.mosaicRoutesApi.getMosaicsNames(mosaicIdsBody)).pipe(map((mosaics) => { + this.mosaicRoutesApi.getMosaicsNames(mosaicIdsBody)).pipe(map((mosaics: MosaicNamesDTO[]) => { return mosaics.map((mosaic) => { return new MosaicNames( new MosaicId(mosaic.mosaicId), mosaic.names.map((name) => { - new NamespaceName(new NamespaceId(name), name); + return new NamespaceName(new NamespaceId(name), name); }), ); }); diff --git a/src/infrastructure/NamespaceHttp.ts b/src/infrastructure/NamespaceHttp.ts index 72db046c81..64ad0e94af 100644 --- a/src/infrastructure/NamespaceHttp.ts +++ b/src/infrastructure/NamespaceHttp.ts @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {address as AddressLibrary, convert, NamespaceRoutesApi} from 'nem2-library'; import {from as observableFrom, Observable} from 'rxjs'; import {map, mergeMap} from 'rxjs/operators'; +import {Convert as convert, RawAddress as AddressLibrary} from '../core/format'; import {Address} from '../model/account/Address'; import {PublicAccount} from '../model/account/PublicAccount'; import {MosaicId} from '../model/mosaic/MosaicId'; @@ -28,6 +28,7 @@ import {NamespaceId} from '../model/namespace/NamespaceId'; import {NamespaceInfo} from '../model/namespace/NamespaceInfo'; import {NamespaceName} from '../model/namespace/NamespaceName'; import {UInt64} from '../model/UInt64'; +import { NamespaceInfoDTO, NamespaceNameDTO, NamespaceRoutesApi } from './api'; import {Http} from './Http'; import {NamespaceRepository} from './NamespaceRepository'; import {NetworkHttp} from './NetworkHttp'; @@ -52,8 +53,8 @@ export class NamespaceHttp extends Http implements NamespaceRepository { */ constructor(url: string, networkHttp?: NetworkHttp) { networkHttp = networkHttp == null ? new NetworkHttp(url) : networkHttp; - super(url, networkHttp); - this.namespaceRoutesApi = new NamespaceRoutesApi(this.apiClient); + super(networkHttp); + this.namespaceRoutesApi = new NamespaceRoutesApi(url); } /** @@ -64,12 +65,12 @@ export class NamespaceHttp extends Http implements NamespaceRepository { public getNamespace(namespaceId: NamespaceId): Observable { return this.getNetworkTypeObservable().pipe( mergeMap((networkType) => observableFrom( - this.namespaceRoutesApi.getNamespace(namespaceId.toHex())).pipe(map((namespaceInfoDTO) => { + this.namespaceRoutesApi.getNamespace(namespaceId.toHex())).pipe(map((namespaceInfoDTO: NamespaceInfoDTO) => { return new NamespaceInfo( namespaceInfoDTO.meta.active, namespaceInfoDTO.meta.index, namespaceInfoDTO.meta.id, - namespaceInfoDTO.namespace.type, + namespaceInfoDTO.namespace.type as number, namespaceInfoDTO.namespace.depth, this.extractLevels(namespaceInfoDTO.namespace), new NamespaceId(namespaceInfoDTO.namespace.parentId), @@ -91,14 +92,17 @@ export class NamespaceHttp extends Http implements NamespaceRepository { queryParams?: QueryParams): Observable { return this.getNetworkTypeObservable().pipe( mergeMap((networkType) => observableFrom( - this.namespaceRoutesApi.getNamespacesFromAccount(address.plain(), queryParams != null ? queryParams : {})).pipe( - map((namespaceInfosDTO) => { + this.namespaceRoutesApi.getNamespacesFromAccount(address.plain(), + this.queryParams(queryParams).pageSize, + this.queryParams(queryParams).id, + this.queryParams(queryParams).order)).pipe( + map((namespaceInfosDTO: NamespaceInfoDTO[]) => { return namespaceInfosDTO.map((namespaceInfoDTO) => { return new NamespaceInfo( namespaceInfoDTO.meta.active, namespaceInfoDTO.meta.index, namespaceInfoDTO.meta.id, - namespaceInfoDTO.namespace.type, + namespaceInfoDTO.namespace.type as number, namespaceInfoDTO.namespace.depth, this.extractLevels(namespaceInfoDTO.namespace), new NamespaceId(namespaceInfoDTO.namespace.parentId), @@ -124,14 +128,17 @@ export class NamespaceHttp extends Http implements NamespaceRepository { }; return this.getNetworkTypeObservable().pipe( mergeMap((networkType) => observableFrom( - this.namespaceRoutesApi.getNamespacesFromAccounts(publicKeysBody, queryParams != null ? queryParams : {})).pipe( - map((namespaceInfosDTO) => { + this.namespaceRoutesApi.getNamespacesFromAccounts(publicKeysBody, + this.queryParams(queryParams).pageSize, + this.queryParams(queryParams).id, + this.queryParams(queryParams).order)).pipe( + map((namespaceInfosDTO: NamespaceInfoDTO[]) => { return namespaceInfosDTO.map((namespaceInfoDTO) => { return new NamespaceInfo( namespaceInfoDTO.meta.active, namespaceInfoDTO.meta.index, namespaceInfoDTO.meta.id, - namespaceInfoDTO.namespace.type, + namespaceInfoDTO.namespace.type as number, namespaceInfoDTO.namespace.depth, this.extractLevels(namespaceInfoDTO.namespace), new NamespaceId(namespaceInfoDTO.namespace.parentId), @@ -154,7 +161,7 @@ export class NamespaceHttp extends Http implements NamespaceRepository { namespaceIds: namespaceIds.map((id) => id.toHex()), }; return observableFrom( - this.namespaceRoutesApi.getNamespacesNames(namespaceIdsBody)).pipe(map((namespaceNamesDTO) => { + this.namespaceRoutesApi.getNamespacesNames(namespaceIdsBody)).pipe(map((namespaceNamesDTO: NamespaceNameDTO[]) => { return namespaceNamesDTO.map((namespaceNameDTO) => { return new NamespaceName( new NamespaceId(namespaceNameDTO.namespaceId), @@ -174,7 +181,7 @@ export class NamespaceHttp extends Http implements NamespaceRepository { return this.getNetworkTypeObservable().pipe( mergeMap((networkType) => observableFrom( this.namespaceRoutesApi.getNamespace(namespaceId.toHex())).pipe( - map((namespaceInfoDTO) => { + map((namespaceInfoDTO: NamespaceInfoDTO) => { if (namespaceInfoDTO.namespace === undefined) { // forward catapult-rest error @@ -182,10 +189,10 @@ export class NamespaceHttp extends Http implements NamespaceRepository { } if (namespaceInfoDTO.namespace.alias.type === AliasType.None - || namespaceInfoDTO.namespace.alias.type !== AliasType.Mosaic) { - throw new Error('No mosaicId is linked to namespace \'' + namespaceInfoDTO.namespace.name + '\''); + || namespaceInfoDTO.namespace.alias.type !== AliasType.Mosaic + || !namespaceInfoDTO.namespace.alias.mosaicId) { + throw new Error('No mosaicId is linked to namespace \'' + namespaceInfoDTO.namespace.level0 + '\''); } - return new MosaicId(namespaceInfoDTO.namespace.alias.mosaicId); })))); } @@ -199,7 +206,7 @@ export class NamespaceHttp extends Http implements NamespaceRepository { return this.getNetworkTypeObservable().pipe( mergeMap((networkType) => observableFrom( this.namespaceRoutesApi.getNamespace(namespaceId.toHex())).pipe( - map((namespaceInfoDTO) => { + map((namespaceInfoDTO: NamespaceInfoDTO) => { if (namespaceInfoDTO.namespace === undefined) { // forward catapult-rest error @@ -207,8 +214,9 @@ export class NamespaceHttp extends Http implements NamespaceRepository { } if (namespaceInfoDTO.namespace.alias.type === AliasType.None - || namespaceInfoDTO.namespace.alias.type !== AliasType.Address) { - throw new Error('No address is linked to namespace \'' + namespaceInfoDTO.namespace.name + '\''); + || namespaceInfoDTO.namespace.alias.type !== AliasType.Address + || !namespaceInfoDTO.namespace.alias.address) { + throw new Error('No address is linked to namespace \'' + namespaceInfoDTO.namespace.level0 + '\''); } const addressDecoded = namespaceInfoDTO.namespace.alias.address; diff --git a/src/infrastructure/NetworkHttp.ts b/src/infrastructure/NetworkHttp.ts index 599aca888b..cbdc53ee9a 100644 --- a/src/infrastructure/NetworkHttp.ts +++ b/src/infrastructure/NetworkHttp.ts @@ -14,10 +14,10 @@ * limitations under the License. */ -import {NetworkRoutesApi} from 'nem2-library'; import {from as observableFrom, Observable} from 'rxjs'; import {map} from 'rxjs/operators'; import {NetworkType} from '../model/blockchain/NetworkType'; +import { NetworkRoutesApi, NetworkTypeDTO } from './api'; import {Http} from './Http'; import {NetworkRepository} from './NetworkRepository'; @@ -38,8 +38,8 @@ export class NetworkHttp extends Http implements NetworkRepository { * @param url */ constructor(url: string) { - super(url); - this.networkRoutesApi = new NetworkRoutesApi(this.apiClient); + super(); + this.networkRoutesApi = new NetworkRoutesApi(url); } @@ -49,7 +49,7 @@ export class NetworkHttp extends Http implements NetworkRepository { * @return network type enum. */ public getNetworkType(): Observable { - return observableFrom(this.networkRoutesApi.getNetworkType()).pipe(map((networkTypeDTO) => { + return observableFrom(this.networkRoutesApi.getNetworkType()).pipe(map((networkTypeDTO: NetworkTypeDTO) => { if (networkTypeDTO.name === 'mijinTest') { return NetworkType.MIJIN_TEST; } else { diff --git a/src/infrastructure/TransactionHttp.ts b/src/infrastructure/TransactionHttp.ts index 72975d2fa7..332ada1e85 100644 --- a/src/infrastructure/TransactionHttp.ts +++ b/src/infrastructure/TransactionHttp.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import {BlockRoutesApi, TransactionRoutesApi} from 'nem2-library'; import * as requestPromise from 'request-promise-native'; import {from as observableFrom, Observable, throwError as observableThrowError} from 'rxjs'; import {catchError, map, mergeMap} from 'rxjs/operators'; @@ -29,6 +28,11 @@ import {TransactionInfo} from '../model/transaction/TransactionInfo'; import {TransactionStatus} from '../model/transaction/TransactionStatus'; import {TransactionType} from '../model/transaction/TransactionType'; import {UInt64} from '../model/UInt64'; +import { AnnounceTransactionInfoDTO, + BlockInfoDTO, BlockRoutesApi, + TransactionInfoDTO, + TransactionRoutesApi, + TransactionStatusDTO } from './api'; import {Http} from './Http'; import {CreateTransactionFromDTO} from './transaction/CreateTransactionFromDTO'; import {TransactionRepository} from './TransactionRepository'; @@ -56,9 +60,9 @@ export class TransactionHttp extends Http implements TransactionRepository { * @param url */ constructor(private readonly url: string) { - super(url); - this.transactionRoutesApi = new TransactionRoutesApi(this.apiClient); - this.blockRoutesApi = new BlockRoutesApi(this.apiClient); + super(); + this.transactionRoutesApi = new TransactionRoutesApi(url); + this.blockRoutesApi = new BlockRoutesApi(url); } /** @@ -82,7 +86,7 @@ export class TransactionHttp extends Http implements TransactionRepository { transactionIds, }; return observableFrom( - this.transactionRoutesApi.getTransactions(transactionIdsBody)).pipe(map((transactionsDTO) => { + this.transactionRoutesApi.getTransactions(transactionIdsBody)).pipe(map((transactionsDTO: TransactionInfoDTO[]) => { return transactionsDTO.map((transactionDTO) => { return CreateTransactionFromDTO(transactionDTO); }); @@ -96,13 +100,13 @@ export class TransactionHttp extends Http implements TransactionRepository { */ public getTransactionStatus(transactionHash: string): Observable { return observableFrom(this.transactionRoutesApi.getTransactionStatus(transactionHash)).pipe( - map((transactionStatusDTO) => { + map((transactionStatusDTO: TransactionStatusDTO) => { return new TransactionStatus( - transactionStatusDTO.group, transactionStatusDTO.status, + transactionStatusDTO.group, transactionStatusDTO.hash, - Deadline.createFromDTO(transactionStatusDTO.deadline), - transactionStatusDTO.height ? new UInt64(transactionStatusDTO.height) : UInt64.fromUint(0)); + transactionStatusDTO.deadline ? Deadline.createFromDTO(transactionStatusDTO.deadline) : undefined, + transactionStatusDTO.height ? new UInt64(transactionStatusDTO.height) : undefined); })); } @@ -117,14 +121,14 @@ export class TransactionHttp extends Http implements TransactionRepository { }; return observableFrom( this.transactionRoutesApi.getTransactionsStatuses(transactionHashesBody)).pipe( - map((transactionStatusesDTO) => { + map((transactionStatusesDTO: TransactionStatusDTO[]) => { return transactionStatusesDTO.map((transactionStatusDTO) => { return new TransactionStatus( - transactionStatusDTO.group, transactionStatusDTO.status, + transactionStatusDTO.group, transactionStatusDTO.hash, - Deadline.createFromDTO(transactionStatusDTO.deadline), - transactionStatusDTO.height ? new UInt64(transactionStatusDTO.height) : UInt64.fromUint(0)); + transactionStatusDTO.deadline ? Deadline.createFromDTO(transactionStatusDTO.deadline) : undefined, + transactionStatusDTO.height ? new UInt64(transactionStatusDTO.height) : undefined); }); })); } @@ -136,7 +140,7 @@ export class TransactionHttp extends Http implements TransactionRepository { */ public announce(signedTransaction: SignedTransaction): Observable { return observableFrom(this.transactionRoutesApi.announceTransaction(signedTransaction)).pipe( - map((transactionAnnounceResponseDTO) => { + map((transactionAnnounceResponseDTO: AnnounceTransactionInfoDTO) => { return new TransactionAnnounceResponse(transactionAnnounceResponseDTO.message); })); } @@ -153,7 +157,7 @@ export class TransactionHttp extends Http implements TransactionRepository { })); } return observableFrom(this.transactionRoutesApi.announcePartialTransaction(signedTransaction)).pipe( - map((transactionAnnounceResponseDTO) => { + map((transactionAnnounceResponseDTO: AnnounceTransactionInfoDTO) => { return new TransactionAnnounceResponse(transactionAnnounceResponseDTO.message); })); } @@ -166,7 +170,7 @@ export class TransactionHttp extends Http implements TransactionRepository { public announceAggregateBondedCosignature( cosignatureSignedTransaction: CosignatureSignedTransaction): Observable { return observableFrom(this.transactionRoutesApi.announceCosignatureTransaction(cosignatureSignedTransaction)).pipe( - map((transactionAnnounceResponseDTO) => { + map((transactionAnnounceResponseDTO: AnnounceTransactionInfoDTO) => { return new TransactionAnnounceResponse(transactionAnnounceResponseDTO.message); })); } @@ -214,7 +218,7 @@ export class TransactionHttp extends Http implements TransactionRepository { // now read block details return observableFrom(this.blockRoutesApi.getBlockByHeight(uintHeight.compact())).pipe( - map((blockDTO) => { + map((blockDTO: BlockInfoDTO) => { // @see https://nemtech.github.io/concepts/transaction.html#fees // effective_fee = feeMultiplier x transaction::size diff --git a/src/infrastructure/api.ts b/src/infrastructure/api.ts new file mode 100644 index 0000000000..6d1bd548c9 --- /dev/null +++ b/src/infrastructure/api.ts @@ -0,0 +1,29 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ +// This is the entrypoint for the package +export * from './api/apis'; +export * from './model/models'; \ No newline at end of file diff --git a/src/infrastructure/api/accountRoutesApi.ts b/src/infrastructure/api/accountRoutesApi.ts new file mode 100644 index 0000000000..cdf01391d3 --- /dev/null +++ b/src/infrastructure/api/accountRoutesApi.ts @@ -0,0 +1,852 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 localVarRequest = require('request'); +import http = require('http'); + +/* tslint:disable:no-unused-locals */ +import { AccountIds } from '../model/accountIds'; +import { AccountInfoDTO } from '../model/accountInfoDTO'; +import { AccountNamesDTO } from '../model/accountNamesDTO'; +import { AccountPropertiesInfoDTO } from '../model/accountPropertiesInfoDTO'; +import { MultisigAccountGraphInfoDTO } from '../model/multisigAccountGraphInfoDTO'; +import { MultisigAccountInfoDTO } from '../model/multisigAccountInfoDTO'; +import { TransactionInfoDTO } from '../model/transactionInfoDTO'; + +import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; + +let defaultBasePath = 'http://localhost:3000'; + +// =============================================== +// This file is autogenerated - Please do not edit +// =============================================== + +export enum AccountRoutesApiApiKeys { +} + +export class AccountRoutesApi { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: AccountRoutesApiApiKeys, value: string) { + (this.authentications as any)[AccountRoutesApiApiKeys[key]].apiKey = value; + } + + /** + * Returns the account information. + * @summary Get account information + * @param accountId The public key or address of the account. + */ + public async getAccountInfo (accountId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: AccountInfoDTO; }> { + const localVarPath = this.basePath + '/account/{accountId}' + .replace('{' + 'accountId' + '}', encodeURIComponent(String(accountId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'accountId' is not null or undefined + if (accountId === null || accountId === undefined) { + throw new Error('Required parameter accountId was null or undefined when calling getAccountInfo.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: AccountInfoDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "AccountInfoDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Returns the multisig account information. + * @summary Get multisig account information + * @param accountId The public key or address of the account. + */ + public async getAccountMultisig (accountId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: MultisigAccountInfoDTO; }> { + const localVarPath = this.basePath + '/account/{accountId}/multisig' + .replace('{' + 'accountId' + '}', encodeURIComponent(String(accountId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'accountId' is not null or undefined + if (accountId === null || accountId === undefined) { + throw new Error('Required parameter accountId was null or undefined when calling getAccountMultisig.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: MultisigAccountInfoDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "MultisigAccountInfoDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Returns the multisig account graph. + * @summary Get multisig account graph information + * @param accountId The public key or address of the account. + */ + public async getAccountMultisigGraph (accountId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/account/{accountId}/multisig/graph' + .replace('{' + 'accountId' + '}', encodeURIComponent(String(accountId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'accountId' is not null or undefined + if (accountId === null || accountId === undefined) { + throw new Error('Required parameter accountId was null or undefined when calling getAccountMultisigGraph.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Returns the configurable properties for a given account. + * @summary Get account configurable properties information + * @param accountId The public key or address of the account. + */ + public async getAccountProperties (accountId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: AccountPropertiesInfoDTO; }> { + const localVarPath = this.basePath + '/account/{accountId}/properties/' + .replace('{' + 'accountId' + '}', encodeURIComponent(String(accountId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'accountId' is not null or undefined + if (accountId === null || accountId === undefined) { + throw new Error('Required parameter accountId was null or undefined when calling getAccountProperties.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: AccountPropertiesInfoDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "AccountPropertiesInfoDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Returns the configurable properties for a given array of addresses. + * @summary Get account properties for given array of addresses + * @param accountIds + */ + public async getAccountPropertiesFromAccounts (accountIds: AccountIds, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/account/properties'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'accountIds' is not null or undefined + if (accountIds === null || accountIds === undefined) { + throw new Error('Required parameter accountIds was null or undefined when calling getAccountPropertiesFromAccounts.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(accountIds, "AccountIds") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Returns the account information for an array of accounts. + * @summary Get accounts information + * @param accountIds + */ + public async getAccountsInfo (accountIds: AccountIds, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/account'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'accountIds' is not null or undefined + if (accountIds === null || accountIds === undefined) { + throw new Error('Required parameter accountIds was null or undefined when calling getAccountsInfo.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(accountIds, "AccountIds") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Returns friendly names for accounts. + * @summary Get readable names for a set of accountIds. + * @param accountIds + */ + public async getAccountsNames (accountIds: AccountIds, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/account/names'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'accountIds' is not null or undefined + if (accountIds === null || accountIds === undefined) { + throw new Error('Required parameter accountIds was null or undefined when calling getAccountsNames.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(accountIds, "AccountIds") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Gets an array of incoming transactions. A transaction is said to be incoming with respect to an account if the account is the recipient of the transaction. + * @summary Get incoming transactions + * @param publicKey The public key of the account. + * @param pageSize The number of transactions to return for each request. + * @param id The transaction id up to which transactions are returned. + * @param ordering The ordering criteria: * -id - Descending order by id. * id - Ascending order by id. + */ + public async incomingTransactions (publicKey: string, pageSize?: number, id?: string, ordering?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/account/{publicKey}/transactions/incoming' + .replace('{' + 'publicKey' + '}', encodeURIComponent(String(publicKey))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'publicKey' is not null or undefined + if (publicKey === null || publicKey === undefined) { + throw new Error('Required parameter publicKey was null or undefined when calling incomingTransactions.'); + } + + if (pageSize !== undefined) { + localVarQueryParameters['pageSize'] = ObjectSerializer.serialize(pageSize, "number"); + } + + if (id !== undefined) { + localVarQueryParameters['id'] = ObjectSerializer.serialize(id, "string"); + } + + if (ordering !== undefined) { + localVarQueryParameters['ordering'] = ObjectSerializer.serialize(ordering, "string"); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Gets an array of outgoing transactions. A transaction is said to be outgoing with respect to an account if the account is the sender of the transaction. + * @summary Get outgoing transactions + * @param publicKey The public key of the account. + * @param pageSize The number of transactions to return for each request. + * @param id The transaction id up to which transactions are returned. + * @param ordering The ordering criteria: * -id - Descending order by id. * id - Ascending order by id. + */ + public async outgoingTransactions (publicKey: string, pageSize?: number, id?: string, ordering?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/account/{publicKey}/transactions/outgoing' + .replace('{' + 'publicKey' + '}', encodeURIComponent(String(publicKey))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'publicKey' is not null or undefined + if (publicKey === null || publicKey === undefined) { + throw new Error('Required parameter publicKey was null or undefined when calling outgoingTransactions.'); + } + + if (pageSize !== undefined) { + localVarQueryParameters['pageSize'] = ObjectSerializer.serialize(pageSize, "number"); + } + + if (id !== undefined) { + localVarQueryParameters['id'] = ObjectSerializer.serialize(id, "string"); + } + + if (ordering !== undefined) { + localVarQueryParameters['ordering'] = ObjectSerializer.serialize(ordering, "string"); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Gets an array of aggregate bonded transactions where the account is the sender or requires to cosign the transaction. + * @summary Get aggregate bonded transactions information + * @param publicKey The public key of the account. + * @param pageSize The number of transactions to return for each request. + * @param id The transaction id up to which transactions are returned. + * @param ordering The ordering criteria. * -id - Descending order by id. * id - Ascending order by id. + */ + public async partialTransactions (publicKey: string, pageSize?: number, id?: string, ordering?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/account/{publicKey}/transactions/partial' + .replace('{' + 'publicKey' + '}', encodeURIComponent(String(publicKey))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'publicKey' is not null or undefined + if (publicKey === null || publicKey === undefined) { + throw new Error('Required parameter publicKey was null or undefined when calling partialTransactions.'); + } + + if (pageSize !== undefined) { + localVarQueryParameters['pageSize'] = ObjectSerializer.serialize(pageSize, "number"); + } + + if (id !== undefined) { + localVarQueryParameters['id'] = ObjectSerializer.serialize(id, "string"); + } + + if (ordering !== undefined) { + localVarQueryParameters['ordering'] = ObjectSerializer.serialize(ordering, "string"); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Gets an array of transactions for which an account is the sender or receiver. + * @summary Get confirmed transactions + * @param publicKey The public key of the account. + * @param pageSize The number of transactions to return for each request. + * @param id The transaction id up to which transactions are returned. + * @param ordering The ordering criteria: * -id - Descending order by id. * id - Ascending order by id. + */ + public async transactions (publicKey: string, pageSize?: number, id?: string, ordering?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/account/{publicKey}/transactions' + .replace('{' + 'publicKey' + '}', encodeURIComponent(String(publicKey))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'publicKey' is not null or undefined + if (publicKey === null || publicKey === undefined) { + throw new Error('Required parameter publicKey was null or undefined when calling transactions.'); + } + + if (pageSize !== undefined) { + localVarQueryParameters['pageSize'] = ObjectSerializer.serialize(pageSize, "number"); + } + + if (id !== undefined) { + localVarQueryParameters['id'] = ObjectSerializer.serialize(id, "string"); + } + + if (ordering !== undefined) { + localVarQueryParameters['ordering'] = ObjectSerializer.serialize(ordering, "string"); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Gets the array of transactions not included in a block where an account is the sender or receiver. + * @summary Get unconfirmed transactions + * @param publicKey The public key of the account. + * @param pageSize The number of transactions to return for each request. + * @param id The transaction id up to which transactions are returned. + * @param ordering The ordering criteria. * -id - Descending order by id. * id - Ascending order by id. + */ + public async unconfirmedTransactions (publicKey: string, pageSize?: number, id?: string, ordering?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/account/{publicKey}/transactions/unconfirmed' + .replace('{' + 'publicKey' + '}', encodeURIComponent(String(publicKey))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'publicKey' is not null or undefined + if (publicKey === null || publicKey === undefined) { + throw new Error('Required parameter publicKey was null or undefined when calling unconfirmedTransactions.'); + } + + if (pageSize !== undefined) { + localVarQueryParameters['pageSize'] = ObjectSerializer.serialize(pageSize, "number"); + } + + if (id !== undefined) { + localVarQueryParameters['id'] = ObjectSerializer.serialize(id, "string"); + } + + if (ordering !== undefined) { + localVarQueryParameters['ordering'] = ObjectSerializer.serialize(ordering, "string"); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } +} diff --git a/src/infrastructure/api/apis.ts b/src/infrastructure/api/apis.ts new file mode 100644 index 0000000000..b32f7659da --- /dev/null +++ b/src/infrastructure/api/apis.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + +export * from './accountRoutesApi'; +import { AccountRoutesApi } from './accountRoutesApi'; +export * from './blockRoutesApi'; +import { BlockRoutesApi } from './blockRoutesApi'; +export * from './chainRoutesApi'; +import { ChainRoutesApi } from './chainRoutesApi'; +export * from './diagnosticRoutesApi'; +import { DiagnosticRoutesApi } from './diagnosticRoutesApi'; +export * from './mosaicRoutesApi'; +import { MosaicRoutesApi } from './mosaicRoutesApi'; +export * from './namespaceRoutesApi'; +import { NamespaceRoutesApi } from './namespaceRoutesApi'; +export * from './networkRoutesApi'; +import { NetworkRoutesApi } from './networkRoutesApi'; +export * from './nodeRoutesApi'; +import { NodeRoutesApi } from './nodeRoutesApi'; +export * from './transactionRoutesApi'; +import { TransactionRoutesApi } from './transactionRoutesApi'; +export const APIS = [AccountRoutesApi, BlockRoutesApi, ChainRoutesApi, DiagnosticRoutesApi, MosaicRoutesApi, NamespaceRoutesApi, NetworkRoutesApi, NodeRoutesApi, TransactionRoutesApi]; diff --git a/src/infrastructure/api/blockRoutesApi.ts b/src/infrastructure/api/blockRoutesApi.ts new file mode 100644 index 0000000000..81abddbdc6 --- /dev/null +++ b/src/infrastructure/api/blockRoutesApi.ts @@ -0,0 +1,463 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 localVarRequest = require('request'); +import http = require('http'); + +/* tslint:disable:no-unused-locals */ +import { BlockInfoDTO } from '../model/blockInfoDTO'; +import { MerkleProofInfoDTO } from '../model/merkleProofInfoDTO'; +import { StatementsDTO } from '../model/statementsDTO'; +import { TransactionInfoDTO } from '../model/transactionInfoDTO'; + +import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; + +let defaultBasePath = 'http://localhost:3000'; + +// =============================================== +// This file is autogenerated - Please do not edit +// =============================================== + +export enum BlockRoutesApiApiKeys { +} + +export class BlockRoutesApi { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: BlockRoutesApiApiKeys, value: string) { + (this.authentications as any)[BlockRoutesApiApiKeys[key]].apiKey = value; + } + + /** + * Gets a block from the chain that has the given height. + * @summary Get block information + * @param height The height of the block. + */ + public async getBlockByHeight (height: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: BlockInfoDTO; }> { + const localVarPath = this.basePath + '/block/{height}' + .replace('{' + 'height' + '}', encodeURIComponent(String(height))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'height' is not null or undefined + if (height === null || height === undefined) { + throw new Error('Required parameter height was null or undefined when calling getBlockByHeight.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: BlockInfoDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "BlockInfoDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Returns the receipts linked to a block. + * @summary Get receipts from a block + * @param height The height of the block. + */ + public async getBlockReceipts (height: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: StatementsDTO; }> { + const localVarPath = this.basePath + '/block/{height}/receipts' + .replace('{' + 'height' + '}', encodeURIComponent(String(height))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'height' is not null or undefined + if (height === null || height === undefined) { + throw new Error('Required parameter height was null or undefined when calling getBlockReceipts.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: StatementsDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "StatementsDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Returns an array of transactions included in a block for a given block height. + * @summary Get transactions from a block + * @param height The height of the block. + * @param pageSize The number of transactions to return for each request. + * @param id The transaction id up to which transactions are returned. + */ + public async getBlockTransactions (height: number, pageSize?: number, id?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/block/{height}/transactions' + .replace('{' + 'height' + '}', encodeURIComponent(String(height))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'height' is not null or undefined + if (height === null || height === undefined) { + throw new Error('Required parameter height was null or undefined when calling getBlockTransactions.'); + } + + if (pageSize !== undefined) { + localVarQueryParameters['pageSize'] = ObjectSerializer.serialize(pageSize, "number"); + } + + if (id !== undefined) { + localVarQueryParameters['id'] = ObjectSerializer.serialize(id, "string"); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Gets up to limit number of blocks after given block height. + * @summary Get blocks information + * @param height The height of the block. If height -1 is not a multiple of the limit provided, the inferior closest multiple + 1 is used instead. + * @param limit The number of blocks to be returned. + */ + public async getBlocksByHeightWithLimit (height: number, limit: 25 | 50 | 75 | 100, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/blocks/{height}/limit/{limit}' + .replace('{' + 'height' + '}', encodeURIComponent(String(height))) + .replace('{' + 'limit' + '}', encodeURIComponent(String(limit))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'height' is not null or undefined + if (height === null || height === undefined) { + throw new Error('Required parameter height was null or undefined when calling getBlocksByHeightWithLimit.'); + } + + // verify required parameter 'limit' is not null or undefined + if (limit === null || limit === undefined) { + throw new Error('Required parameter limit was null or undefined when calling getBlocksByHeightWithLimit.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Returns the merkle path for a receipt statement or resolution linked to a block. The path is the complementary data needed to calculate the merkle root. A client can compare if the calculated root equals the one recorded in the block header, verifying that the receipt was linked with the block. + * @summary Get the merkle path for a given a receipt statement hash and block + * @param height The height of the block. + * @param hash The hash of the receipt statement or resolution. + */ + public async getMerkleReceipts (height: number, hash: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: MerkleProofInfoDTO; }> { + const localVarPath = this.basePath + '/block/{height}/receipt/{hash}/merkle' + .replace('{' + 'height' + '}', encodeURIComponent(String(height))) + .replace('{' + 'hash' + '}', encodeURIComponent(String(hash))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'height' is not null or undefined + if (height === null || height === undefined) { + throw new Error('Required parameter height was null or undefined when calling getMerkleReceipts.'); + } + + // verify required parameter 'hash' is not null or undefined + if (hash === null || hash === undefined) { + throw new Error('Required parameter hash was null or undefined when calling getMerkleReceipts.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: MerkleProofInfoDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "MerkleProofInfoDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Returns the merkle path for a transaction included in a block. The path is the complementary data needed to calculate the merkle root. A client can compare if the calculated root equals the one recorded in the block header, verifying that the transaction was included in the block. + * @summary Get the merkle path for a given a transaction and block + * @param height The height of the block. + * @param hash The hash of the transaction. + */ + public async getMerkleTransaction (height: number, hash: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: MerkleProofInfoDTO; }> { + const localVarPath = this.basePath + '/block/{height}/transaction/{hash}/merkle' + .replace('{' + 'height' + '}', encodeURIComponent(String(height))) + .replace('{' + 'hash' + '}', encodeURIComponent(String(hash))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'height' is not null or undefined + if (height === null || height === undefined) { + throw new Error('Required parameter height was null or undefined when calling getMerkleTransaction.'); + } + + // verify required parameter 'hash' is not null or undefined + if (hash === null || hash === undefined) { + throw new Error('Required parameter hash was null or undefined when calling getMerkleTransaction.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: MerkleProofInfoDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "MerkleProofInfoDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } +} diff --git a/src/infrastructure/api/chainRoutesApi.ts b/src/infrastructure/api/chainRoutesApi.ts new file mode 100644 index 0000000000..b5f3e17326 --- /dev/null +++ b/src/infrastructure/api/chainRoutesApi.ts @@ -0,0 +1,188 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 localVarRequest = require('request'); +import http = require('http'); + +/* tslint:disable:no-unused-locals */ +import { BlockchainScoreDTO } from '../model/blockchainScoreDTO'; +import { HeightInfoDTO } from '../model/heightInfoDTO'; + +import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; + +let defaultBasePath = 'http://localhost:3000'; + +// =============================================== +// This file is autogenerated - Please do not edit +// =============================================== + +export enum ChainRoutesApiApiKeys { +} + +export class ChainRoutesApi { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: ChainRoutesApiApiKeys, value: string) { + (this.authentications as any)[ChainRoutesApiApiKeys[key]].apiKey = value; + } + + /** + * Returns the current height of the blockchain. + * @summary Get the current height of the chain + */ + public async getBlockchainHeight (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: HeightInfoDTO; }> { + const localVarPath = this.basePath + '/chain/height'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: HeightInfoDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "HeightInfoDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Gets the current score of the blockchain. The higher the score, the better the chain. During synchronization, nodes try to get the best blockchain in the network. The score for a block is derived from its difficulty and the time (in seconds) that has elapsed since the last block: block score = difficulty − time elapsed since last block + * @summary Get the current score of the chain + */ + public async getBlockchainScore (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: BlockchainScoreDTO; }> { + const localVarPath = this.basePath + '/chain/score'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: BlockchainScoreDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "BlockchainScoreDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } +} diff --git a/src/infrastructure/api/diagnosticRoutesApi.ts b/src/infrastructure/api/diagnosticRoutesApi.ts new file mode 100644 index 0000000000..d05fc09bfe --- /dev/null +++ b/src/infrastructure/api/diagnosticRoutesApi.ts @@ -0,0 +1,188 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 localVarRequest = require('request'); +import http = require('http'); + +/* tslint:disable:no-unused-locals */ +import { ServerDTO } from '../model/serverDTO'; +import { StorageInfoDTO } from '../model/storageInfoDTO'; + +import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; + +let defaultBasePath = 'http://localhost:3000'; + +// =============================================== +// This file is autogenerated - Please do not edit +// =============================================== + +export enum DiagnosticRoutesApiApiKeys { +} + +export class DiagnosticRoutesApi { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: DiagnosticRoutesApiApiKeys, value: string) { + (this.authentications as any)[DiagnosticRoutesApiApiKeys[key]].apiKey = value; + } + + /** + * Returns diagnostic information about the node storage. + * @summary Get the storage information of the node + */ + public async getDiagnosticStorage (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: StorageInfoDTO; }> { + const localVarPath = this.basePath + '/diagnostic/storage'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: StorageInfoDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "StorageInfoDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Returns the version of the running rest component. + * @summary Get the version of the running rest component + */ + public async getServerInfo (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: ServerDTO; }> { + const localVarPath = this.basePath + '/diagnostic/server'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: ServerDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "ServerDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } +} diff --git a/src/infrastructure/api/mosaicRoutesApi.ts b/src/infrastructure/api/mosaicRoutesApi.ts new file mode 100644 index 0000000000..7470668f53 --- /dev/null +++ b/src/infrastructure/api/mosaicRoutesApi.ts @@ -0,0 +1,260 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 localVarRequest = require('request'); +import http = require('http'); + +/* tslint:disable:no-unused-locals */ +import { MosaicIds } from '../model/mosaicIds'; +import { MosaicInfoDTO } from '../model/mosaicInfoDTO'; +import { MosaicNamesDTO } from '../model/mosaicNamesDTO'; + +import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; + +let defaultBasePath = 'http://localhost:3000'; + +// =============================================== +// This file is autogenerated - Please do not edit +// =============================================== + +export enum MosaicRoutesApiApiKeys { +} + +export class MosaicRoutesApi { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: MosaicRoutesApiApiKeys, value: string) { + (this.authentications as any)[MosaicRoutesApiApiKeys[key]].apiKey = value; + } + + /** + * Gets the mosaic definition for a given mosaicId. + * @summary Get mosaic information + * @param mosaicId The mosaic identifier. + */ + public async getMosaic (mosaicId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: MosaicInfoDTO; }> { + const localVarPath = this.basePath + '/mosaic/{mosaicId}' + .replace('{' + 'mosaicId' + '}', encodeURIComponent(String(mosaicId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'mosaicId' is not null or undefined + if (mosaicId === null || mosaicId === undefined) { + throw new Error('Required parameter mosaicId was null or undefined when calling getMosaic.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: MosaicInfoDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "MosaicInfoDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Gets an array of mosaic definition. + * @summary Get mosaics information for an array of mosaics + * @param mosaicIds + */ + public async getMosaics (mosaicIds: MosaicIds, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/mosaic'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'mosaicIds' is not null or undefined + if (mosaicIds === null || mosaicIds === undefined) { + throw new Error('Required parameter mosaicIds was null or undefined when calling getMosaics.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(mosaicIds, "MosaicIds") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Returns friendly names for mosaics. + * @summary Get readable names for a set of mosaics + * @param mosaicIds + */ + public async getMosaicsNames (mosaicIds: MosaicIds, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/mosaic/names'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'mosaicIds' is not null or undefined + if (mosaicIds === null || mosaicIds === undefined) { + throw new Error('Required parameter mosaicIds was null or undefined when calling getMosaicsNames.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(mosaicIds, "MosaicIds") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } +} diff --git a/src/infrastructure/api/namespaceRoutesApi.ts b/src/infrastructure/api/namespaceRoutesApi.ts new file mode 100644 index 0000000000..ed7857bdf3 --- /dev/null +++ b/src/infrastructure/api/namespaceRoutesApi.ts @@ -0,0 +1,338 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 localVarRequest = require('request'); +import http = require('http'); + +/* tslint:disable:no-unused-locals */ +import { AccountIds } from '../model/accountIds'; +import { NamespaceIds } from '../model/namespaceIds'; +import { NamespaceInfoDTO } from '../model/namespaceInfoDTO'; +import { NamespaceNameDTO } from '../model/namespaceNameDTO'; + +import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; + +let defaultBasePath = 'http://localhost:3000'; + +// =============================================== +// This file is autogenerated - Please do not edit +// =============================================== + +export enum NamespaceRoutesApiApiKeys { +} + +export class NamespaceRoutesApi { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: NamespaceRoutesApiApiKeys, value: string) { + (this.authentications as any)[NamespaceRoutesApiApiKeys[key]].apiKey = value; + } + + /** + * Gets the namespace for a given namespaceId. + * @summary Get namespace information + * @param namespaceId The namespace identifier. + */ + public async getNamespace (namespaceId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: NamespaceInfoDTO; }> { + const localVarPath = this.basePath + '/namespace/{namespaceId}' + .replace('{' + 'namespaceId' + '}', encodeURIComponent(String(namespaceId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'namespaceId' is not null or undefined + if (namespaceId === null || namespaceId === undefined) { + throw new Error('Required parameter namespaceId was null or undefined when calling getNamespace.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: NamespaceInfoDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "NamespaceInfoDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Gets an array of namespaces for a given account address. + * @summary Get namespaces owned by an account + * @param accountId The address or public key of the account. + * @param pageSize The number of namespaces to return. + * @param id The namespace id up to which namespace objects are returned. + */ + public async getNamespacesFromAccount (accountId: string, pageSize?: number, id?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/account/{accountId}/namespaces' + .replace('{' + 'accountId' + '}', encodeURIComponent(String(accountId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'accountId' is not null or undefined + if (accountId === null || accountId === undefined) { + throw new Error('Required parameter accountId was null or undefined when calling getNamespacesFromAccount.'); + } + + if (pageSize !== undefined) { + localVarQueryParameters['pageSize'] = ObjectSerializer.serialize(pageSize, "number"); + } + + if (id !== undefined) { + localVarQueryParameters['id'] = ObjectSerializer.serialize(id, "string"); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Gets namespaces for a given array of addresses. + * @summary Get namespaces for given array of addresses + * @param accountIds + * @param pageSize The number of namespaces to return. + * @param id The namespace id up to which namespace objects are returned. + */ + public async getNamespacesFromAccounts (accountIds: AccountIds, pageSize?: number, id?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/account/namespaces'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'accountIds' is not null or undefined + if (accountIds === null || accountIds === undefined) { + throw new Error('Required parameter accountIds was null or undefined when calling getNamespacesFromAccounts.'); + } + + if (pageSize !== undefined) { + localVarQueryParameters['pageSize'] = ObjectSerializer.serialize(pageSize, "number"); + } + + if (id !== undefined) { + localVarQueryParameters['id'] = ObjectSerializer.serialize(id, "string"); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(accountIds, "AccountIds") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Returns friendly names for namespaces. + * @summary Get readable names for a set of namespaces + * @param namespaceIds + */ + public async getNamespacesNames (namespaceIds: NamespaceIds, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/namespace/names'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'namespaceIds' is not null or undefined + if (namespaceIds === null || namespaceIds === undefined) { + throw new Error('Required parameter namespaceIds was null or undefined when calling getNamespacesNames.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(namespaceIds, "NamespaceIds") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } +} diff --git a/src/infrastructure/api/networkRoutesApi.ts b/src/infrastructure/api/networkRoutesApi.ts new file mode 100644 index 0000000000..368aa05c7d --- /dev/null +++ b/src/infrastructure/api/networkRoutesApi.ts @@ -0,0 +1,137 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 localVarRequest = require('request'); +import http = require('http'); + +/* tslint:disable:no-unused-locals */ +import { NetworkTypeDTO } from '../model/networkTypeDTO'; + +import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; + +let defaultBasePath = 'http://localhost:3000'; + +// =============================================== +// This file is autogenerated - Please do not edit +// =============================================== + +export enum NetworkRoutesApiApiKeys { +} + +export class NetworkRoutesApi { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: NetworkRoutesApiApiKeys, value: string) { + (this.authentications as any)[NetworkRoutesApiApiKeys[key]].apiKey = value; + } + + /** + * Returns the current network type. + * @summary Get the current network type of the chain + */ + public async getNetworkType (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: NetworkTypeDTO; }> { + const localVarPath = this.basePath + '/network'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: NetworkTypeDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "NetworkTypeDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } +} diff --git a/src/infrastructure/api/nodeRoutesApi.ts b/src/infrastructure/api/nodeRoutesApi.ts new file mode 100644 index 0000000000..bd2b829091 --- /dev/null +++ b/src/infrastructure/api/nodeRoutesApi.ts @@ -0,0 +1,188 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 localVarRequest = require('request'); +import http = require('http'); + +/* tslint:disable:no-unused-locals */ +import { NodeInfoDTO } from '../model/nodeInfoDTO'; +import { NodeTimeDTO } from '../model/nodeTimeDTO'; + +import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; + +let defaultBasePath = 'http://localhost:3000'; + +// =============================================== +// This file is autogenerated - Please do not edit +// =============================================== + +export enum NodeRoutesApiApiKeys { +} + +export class NodeRoutesApi { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: NodeRoutesApiApiKeys, value: string) { + (this.authentications as any)[NodeRoutesApiApiKeys[key]].apiKey = value; + } + + /** + * Supplies additional information about the application running on a node. + * @summary Get the node information + */ + public async getNodeInfo (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: NodeInfoDTO; }> { + const localVarPath = this.basePath + '/node/info'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: NodeInfoDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "NodeInfoDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Gets the node time at the moment the reply was sent and received. + * @summary Get the node time + */ + public async getNodeTime (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: NodeTimeDTO; }> { + const localVarPath = this.basePath + '/node/time'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: NodeTimeDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "NodeTimeDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } +} diff --git a/src/infrastructure/api/transactionRoutesApi.ts b/src/infrastructure/api/transactionRoutesApi.ts new file mode 100644 index 0000000000..e06468ad30 --- /dev/null +++ b/src/infrastructure/api/transactionRoutesApi.ts @@ -0,0 +1,492 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 localVarRequest = require('request'); +import http = require('http'); + +/* tslint:disable:no-unused-locals */ +import { AnnounceTransactionInfoDTO } from '../model/announceTransactionInfoDTO'; +import { Cosignature } from '../model/cosignature'; +import { TransactionHashes } from '../model/transactionHashes'; +import { TransactionIds } from '../model/transactionIds'; +import { TransactionInfoDTO } from '../model/transactionInfoDTO'; +import { TransactionPayload } from '../model/transactionPayload'; +import { TransactionStatusDTO } from '../model/transactionStatusDTO'; + +import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; + +let defaultBasePath = 'http://localhost:3000'; + +// =============================================== +// This file is autogenerated - Please do not edit +// =============================================== + +export enum TransactionRoutesApiApiKeys { +} + +export class TransactionRoutesApi { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: TransactionRoutesApiApiKeys, value: string) { + (this.authentications as any)[TransactionRoutesApiApiKeys[key]].apiKey = value; + } + + /** + * Announces a cosignature transaction to the network. + * @summary Announce a cosignature transaction + * @param cosignature + */ + public async announceCosignatureTransaction (cosignature: Cosignature, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: AnnounceTransactionInfoDTO; }> { + const localVarPath = this.basePath + '/transaction/cosignature'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cosignature' is not null or undefined + if (cosignature === null || cosignature === undefined) { + throw new Error('Required parameter cosignature was null or undefined when calling announceCosignatureTransaction.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'PUT', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(cosignature, "Cosignature") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: AnnounceTransactionInfoDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "AnnounceTransactionInfoDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Announces an aggregate bonded transaction to the network. + * @summary Announce an aggregate bonded transaction + * @param transactionPayload + */ + public async announcePartialTransaction (transactionPayload: TransactionPayload, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: AnnounceTransactionInfoDTO; }> { + const localVarPath = this.basePath + '/transaction/partial'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'transactionPayload' is not null or undefined + if (transactionPayload === null || transactionPayload === undefined) { + throw new Error('Required parameter transactionPayload was null or undefined when calling announcePartialTransaction.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'PUT', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(transactionPayload, "TransactionPayload") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: AnnounceTransactionInfoDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "AnnounceTransactionInfoDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Announces a transaction to the network. It is recommended to use the NEM2-SDK to announce transactions as they should be serialized. + * @summary Announce a new transaction + * @param transactionPayload + */ + public async announceTransaction (transactionPayload: TransactionPayload, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: AnnounceTransactionInfoDTO; }> { + const localVarPath = this.basePath + '/transaction'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'transactionPayload' is not null or undefined + if (transactionPayload === null || transactionPayload === undefined) { + throw new Error('Required parameter transactionPayload was null or undefined when calling announceTransaction.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'PUT', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(transactionPayload, "TransactionPayload") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: AnnounceTransactionInfoDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "AnnounceTransactionInfoDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Returns transaction information given a transactionId or hash. + * @summary Get transaction information + * @param transactionId The transaction id or hash. + */ + public async getTransaction (transactionId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: TransactionInfoDTO; }> { + const localVarPath = this.basePath + '/transaction/{transactionId}' + .replace('{' + 'transactionId' + '}', encodeURIComponent(String(transactionId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'transactionId' is not null or undefined + if (transactionId === null || transactionId === undefined) { + throw new Error('Required parameter transactionId was null or undefined when calling getTransaction.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: TransactionInfoDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "TransactionInfoDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Returns the transaction status for a given hash. + * @summary Get transaction status + * @param hash The transaction hash. + */ + public async getTransactionStatus (hash: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: TransactionStatusDTO; }> { + const localVarPath = this.basePath + '/transaction/{hash}/status' + .replace('{' + 'hash' + '}', encodeURIComponent(String(hash))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'hash' is not null or undefined + if (hash === null || hash === undefined) { + throw new Error('Required parameter hash was null or undefined when calling getTransactionStatus.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: TransactionStatusDTO; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "TransactionStatusDTO"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Returns transactions information for a given array of transactionIds. + * @summary Get transactions information + * @param transactionIds + */ + public async getTransactions (transactionIds: TransactionIds, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/transaction'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'transactionIds' is not null or undefined + if (transactionIds === null || transactionIds === undefined) { + throw new Error('Required parameter transactionIds was null or undefined when calling getTransactions.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(transactionIds, "TransactionIds") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } + /** + * Returns an array of transaction statuses for a given array of transaction hashes. + * @summary Get transactions status. + * @param transactionHashes + */ + public async getTransactionsStatuses (transactionHashes: TransactionHashes, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/transaction/statuses'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'transactionHashes' is not null or undefined + if (transactionHashes === null || transactionHashes === undefined) { + throw new Error('Required parameter transactionHashes was null or undefined when calling getTransactionsStatuses.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(transactionHashes, "TransactionHashes") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } +} diff --git a/src/infrastructure/buffers/AccountLinkTransactionBuffer.ts b/src/infrastructure/buffers/AccountLinkTransactionBuffer.ts new file mode 100644 index 0000000000..30dde827ce --- /dev/null +++ b/src/infrastructure/buffers/AccountLinkTransactionBuffer.ts @@ -0,0 +1,425 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ + +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * @const + * @namespace + */ +var Catapult = Catapult || {}; + +/** + * @const + * @namespace + */ +Catapult.Buffers = Catapult.Buffers || {}; + +/** + * @constructor + */ +Catapult.Buffers.AccountLinkTransactionBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.AccountLinkTransactionBuffer} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.AccountLinkTransactionBuffer=} obj + * @returns {Catapult.Buffers.AccountLinkTransactionBuffer} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.getRootAsAccountLinkTransactionBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.AccountLinkTransactionBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.size = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.signature = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.signatureLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.signatureArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.signer = function(index) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.signerLength = function() { + let offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.signerArray = function() { + let 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.version = function() { + let offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.type = function() { + let offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.fee = function(index) { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.feeLength = function() { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.feeArray = function() { + 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.deadline = function(index) { + const offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.deadlineLength = function() { + const offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.deadlineArray = function() { + 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.remoteAccountKey = function(index) { + const offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.remoteAccountKeyLength = function() { + const offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.remoteAccountKeyArray = function() { + 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.prototype.linkAction = function() { + const offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.AccountLinkTransactionBuffer.startAccountLinkTransactionBuffer = function(builder) { + builder.startObject(12); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} size + */ +Catapult.Buffers.AccountLinkTransactionBuffer.addSize = function(builder, size) { + builder.addFieldInt32(0, size, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signatureOffset + */ +Catapult.Buffers.AccountLinkTransactionBuffer.addSignature = function(builder, signatureOffset) { + builder.addFieldOffset(1, signatureOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.createSignatureVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountLinkTransactionBuffer.startSignatureVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signerOffset + */ +Catapult.Buffers.AccountLinkTransactionBuffer.addSigner = function(builder, signerOffset) { + builder.addFieldOffset(2, signerOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.createSignerVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountLinkTransactionBuffer.startSignerVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} version + */ +Catapult.Buffers.AccountLinkTransactionBuffer.addVersion = function(builder, version) { + builder.addFieldInt16(3, version, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.AccountLinkTransactionBuffer.addType = function(builder, type) { + builder.addFieldInt16(4, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} feeOffset + */ +Catapult.Buffers.AccountLinkTransactionBuffer.addFee = function(builder, feeOffset) { + builder.addFieldOffset(5, feeOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.createFeeVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountLinkTransactionBuffer.startFeeVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} deadlineOffset + */ +Catapult.Buffers.AccountLinkTransactionBuffer.addDeadline = function(builder, deadlineOffset) { + builder.addFieldOffset(6, deadlineOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.createDeadlineVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountLinkTransactionBuffer.startDeadlineVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} remoteAccountKey + */ +Catapult.Buffers.AccountLinkTransactionBuffer.addRemoteAccountKey = function(builder, remoteAccountKeyOffset) { + builder.addFieldOffset(7, remoteAccountKeyOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.createRemoteAccountKeyVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountLinkTransactionBuffer.startRemoteAccountKeyVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} linkAction + */ +Catapult.Buffers.AccountLinkTransactionBuffer.addLinkAction = function(builder, linkAction) { + builder.addFieldInt8(8, linkAction, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountLinkTransactionBuffer.endAccountLinkTransactionBuffer = function(builder) { + const offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} offset + */ +Catapult.Buffers.AccountLinkTransactionBuffer.finishAccountLinkTransactionBufferBuffer = function(builder, offset) { + builder.finish(offset); +}; + +// Exports for Node.js and RequireJS +export default Catapult; diff --git a/src/infrastructure/buffers/AccountPropertiesAddressTransactionBuffer.ts b/src/infrastructure/buffers/AccountPropertiesAddressTransactionBuffer.ts new file mode 100644 index 0000000000..128442e660 --- /dev/null +++ b/src/infrastructure/buffers/AccountPropertiesAddressTransactionBuffer.ts @@ -0,0 +1,557 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ + +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * @const + * @namespace + */ +var Catapult = Catapult || {}; + +/** + * @const + * @namespace + */ +Catapult.Buffers = Catapult.Buffers || {}; + +/** + * @constructor + */ +Catapult.Buffers.PropertyAddressModificationBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.PropertyAddressModificationBuffer} + */ +Catapult.Buffers.PropertyAddressModificationBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.PropertyAddressModificationBuffer=} obj + * @returns {Catapult.Buffers.PropertyAddressModificationBuffer} + */ +Catapult.Buffers.PropertyAddressModificationBuffer.getRootAsPropertyAddressModificationBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.PropertyAddressModificationBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.PropertyAddressModificationBuffer.prototype.modificationType = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.PropertyAddressModificationBuffer.prototype.value = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.PropertyAddressModificationBuffer.prototype.valueLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.PropertyAddressModificationBuffer.prototype.valueArray = function() { + var 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; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.PropertyAddressModificationBuffer.startPropertyAddressModificationBuffer = function(builder) { + builder.startObject(2); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.PropertyAddressModificationBuffer.addModificationType = function(builder, type) { + builder.addFieldInt8(0, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} valueOffset + */ +Catapult.Buffers.PropertyAddressModificationBuffer.addValue = function(builder, valueOffset) { + builder.addFieldOffset(1, valueOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.PropertyAddressModificationBuffer.createValueVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.PropertyAddressModificationBuffer.startValueVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.PropertyAddressModificationBuffer.endPropertyAddressModificationBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @constructor + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.AccountPropertiesAddressTransactionBuffer} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.AccountPropertiesAddressTransactionBuffer=} obj + * @returns {Catapult.Buffers.AccountPropertiesAddressTransactionBuffer} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.getRootAsAccountPropertiesAddressTransactionBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.AccountPropertiesAddressTransactionBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.size = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.signature = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.signatureLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.signatureArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.signer = function(index) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.signerLength = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.signerArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.version = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.type = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.fee = function(index) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.feeLength = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.feeArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.deadline = function(index) { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.deadlineLength = function() { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.deadlineArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.propertyType = function() { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.modificationCount = function() { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @param {Catapult.Buffers.PropertyAddressModificationBuffer=} obj + * @returns {Catapult.Buffers.PropertyAddressModificationBuffer} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.modifications = function(index, obj) { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? (obj || new Catapult.Buffers.PropertyAddressModificationBuffer).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.prototype.modificationsLength = function() { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.startAccountPropertiesAddressTransactionBuffer = function(builder) { + builder.startObject(11); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} size + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.addSize = function(builder, size) { + builder.addFieldInt32(0, size, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signatureOffset + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.addSignature = function(builder, signatureOffset) { + builder.addFieldOffset(1, signatureOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.createSignatureVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.startSignatureVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signerOffset + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.addSigner = function(builder, signerOffset) { + builder.addFieldOffset(2, signerOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.createSignerVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.startSignerVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} version + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.addVersion = function(builder, version) { + builder.addFieldInt16(3, version, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.addType = function(builder, type) { + builder.addFieldInt16(4, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} feeOffset + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.addFee = function(builder, feeOffset) { + builder.addFieldOffset(5, feeOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.createFeeVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.startFeeVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} deadlineOffset + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.addDeadline = function(builder, deadlineOffset) { + builder.addFieldOffset(6, deadlineOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.createDeadlineVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.startDeadlineVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} propertyType + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.addPropertyType = function(builder, propertyType) { + builder.addFieldInt8(7, propertyType, 0); +}; + + +/** + * @param {flatbuffers.Builder} builder + * @param {number} modificationCount + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.addModificationCount = function(builder, modificationCount) { + builder.addFieldInt8(8, modificationCount, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} modificationsOffset + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.addModifications = function(builder, modificationsOffset) { + builder.addFieldOffset(9, modificationsOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.createModificationsVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.startModificationsVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.endAccountPropertiesAddressTransactionBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} offset + */ +Catapult.Buffers.AccountPropertiesAddressTransactionBuffer.finishAccountPropertiesAddressTransactionBufferBuffer = function(builder, offset) { + builder.finish(offset); +}; + +// Exports for Node.js and RequireJS +export default Catapult; diff --git a/src/infrastructure/buffers/AccountPropertiesEntityTypeTransactionBuffer.ts b/src/infrastructure/buffers/AccountPropertiesEntityTypeTransactionBuffer.ts new file mode 100644 index 0000000000..0994479bf7 --- /dev/null +++ b/src/infrastructure/buffers/AccountPropertiesEntityTypeTransactionBuffer.ts @@ -0,0 +1,520 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ + +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * @const + * @namespace + */ +var Catapult = Catapult || {}; + +/** + * @const + * @namespace + */ +Catapult.Buffers = Catapult.Buffers || {}; + +/** + * @constructor + */ +Catapult.Buffers.PropertyEntityTypeModificationBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.PropertyEntityTypeModificationBuffer} + */ +Catapult.Buffers.PropertyEntityTypeModificationBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.PropertyEntityTypeModificationBuffer=} obj + * @returns {Catapult.Buffers.PropertyEntityTypeModificationBuffer} + */ +Catapult.Buffers.PropertyEntityTypeModificationBuffer.getRootAsPropertyEntityTypeModificationBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.PropertyEntityTypeModificationBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.PropertyEntityTypeModificationBuffer.prototype.modificationType = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.PropertyEntityTypeModificationBuffer.prototype.value = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.PropertyEntityTypeModificationBuffer.startPropertyEntityTypeModificationBuffer = function(builder) { + builder.startObject(2); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.PropertyEntityTypeModificationBuffer.addModificationType = function(builder, type) { + builder.addFieldInt8(0, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} valueOffset + */ +Catapult.Buffers.PropertyEntityTypeModificationBuffer.addValue = function(builder, valueOffset) { + builder.addFieldInt16(1, valueOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.PropertyEntityTypeModificationBuffer.endPropertyEntityTypeModificationBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @constructor + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer=} obj + * @returns {Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.getRootAsAccountPropertiesEntityTypeTransactionBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.size = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.signature = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.signatureLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.signatureArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.signer = function(index) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.signerLength = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.signerArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.version = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.type = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.fee = function(index) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.feeLength = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.feeArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.deadline = function(index) { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.deadlineLength = function() { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.deadlineArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.propertyType = function() { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.modificationCount = function() { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @param {Catapult.Buffers.PropertyEntityTypeModificationBuffer=} obj + * @returns {Catapult.Buffers.PropertyEntityTypeModificationBuffer} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.modifications = function(index, obj) { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? (obj || new Catapult.Buffers.PropertyEntityTypeModificationBuffer).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.prototype.modificationsLength = function() { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.startAccountPropertiesEntityTypeTransactionBuffer = function(builder) { + builder.startObject(11); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} size + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.addSize = function(builder, size) { + builder.addFieldInt32(0, size, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signatureOffset + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.addSignature = function(builder, signatureOffset) { + builder.addFieldOffset(1, signatureOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.createSignatureVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.startSignatureVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signerOffset + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.addSigner = function(builder, signerOffset) { + builder.addFieldOffset(2, signerOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.createSignerVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.startSignerVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} version + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.addVersion = function(builder, version) { + builder.addFieldInt16(3, version, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.addType = function(builder, type) { + builder.addFieldInt16(4, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} feeOffset + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.addFee = function(builder, feeOffset) { + builder.addFieldOffset(5, feeOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.createFeeVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.startFeeVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} deadlineOffset + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.addDeadline = function(builder, deadlineOffset) { + builder.addFieldOffset(6, deadlineOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.createDeadlineVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.startDeadlineVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} propertyType + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.addPropertyType = function(builder, propertyType) { + builder.addFieldInt8(7, propertyType, 0); +}; + + +/** + * @param {flatbuffers.Builder} builder + * @param {number} modificationCount + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.addModificationCount = function(builder, modificationCount) { + builder.addFieldInt8(8, modificationCount, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} modificationsOffset + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.addModifications = function(builder, modificationsOffset) { + builder.addFieldOffset(9, modificationsOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.createModificationsVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.startModificationsVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.endAccountPropertiesEntityTypeTransactionBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} offset + */ +Catapult.Buffers.AccountPropertiesEntityTypeTransactionBuffer.finishAccountPropertiesEntityTypeTransactionBufferBuffer = function(builder, offset) { + builder.finish(offset); +}; + +// Exports for Node.js and RequireJS +export default Catapult; diff --git a/src/infrastructure/buffers/AccountPropertiesMosaicTransactionBuffer.ts b/src/infrastructure/buffers/AccountPropertiesMosaicTransactionBuffer.ts new file mode 100644 index 0000000000..59241cc50e --- /dev/null +++ b/src/infrastructure/buffers/AccountPropertiesMosaicTransactionBuffer.ts @@ -0,0 +1,557 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ + +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * @const + * @namespace + */ +var Catapult = Catapult || {}; + +/** + * @const + * @namespace + */ +Catapult.Buffers = Catapult.Buffers || {}; + +/** + * @constructor + */ +Catapult.Buffers.PropertyMosaicModificationBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.PropertyMosaicModificationBuffer} + */ +Catapult.Buffers.PropertyMosaicModificationBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.PropertyMosaicModificationBuffer=} obj + * @returns {Catapult.Buffers.PropertyMosaicModificationBuffer} + */ +Catapult.Buffers.PropertyMosaicModificationBuffer.getRootAsPropertyMosaicModificationBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.PropertyMosaicModificationBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.PropertyMosaicModificationBuffer.prototype.modificationType = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.PropertyMosaicModificationBuffer.prototype.value = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.PropertyMosaicModificationBuffer.prototype.valueLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.PropertyMosaicModificationBuffer.prototype.valueArray = function() { + var 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; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.PropertyMosaicModificationBuffer.startPropertyMosaicModificationBuffer = function(builder) { + builder.startObject(2); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.PropertyMosaicModificationBuffer.addModificationType = function(builder, type) { + builder.addFieldInt8(0, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} valueOffset + */ +Catapult.Buffers.PropertyMosaicModificationBuffer.addValue = function(builder, valueOffset) { + builder.addFieldOffset(1, valueOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.PropertyMosaicModificationBuffer.createValueVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.PropertyMosaicModificationBuffer.startValueVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.PropertyMosaicModificationBuffer.endPropertyMosaicModificationBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @constructor + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer=} obj + * @returns {Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.getRootAsAccountPropertiesMosaicTransactionBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.size = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.signature = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.signatureLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.signatureArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.signer = function(index) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.signerLength = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.signerArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.version = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.type = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.fee = function(index) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.feeLength = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.feeArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.deadline = function(index) { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.deadlineLength = function() { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.deadlineArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.propertyType = function() { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.modificationCount = function() { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @param {Catapult.Buffers.PropertyMosaicModificationBuffer=} obj + * @returns {Catapult.Buffers.PropertyMosaicModificationBuffer} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.modifications = function(index, obj) { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? (obj || new Catapult.Buffers.PropertyMosaicModificationBuffer).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.prototype.modificationsLength = function() { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.startAccountPropertiesMosaicTransactionBuffer = function(builder) { + builder.startObject(11); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} size + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.addSize = function(builder, size) { + builder.addFieldInt32(0, size, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signatureOffset + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.addSignature = function(builder, signatureOffset) { + builder.addFieldOffset(1, signatureOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.createSignatureVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.startSignatureVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signerOffset + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.addSigner = function(builder, signerOffset) { + builder.addFieldOffset(2, signerOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.createSignerVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.startSignerVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} version + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.addVersion = function(builder, version) { + builder.addFieldInt16(3, version, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.addType = function(builder, type) { + builder.addFieldInt16(4, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} feeOffset + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.addFee = function(builder, feeOffset) { + builder.addFieldOffset(5, feeOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.createFeeVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.startFeeVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} deadlineOffset + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.addDeadline = function(builder, deadlineOffset) { + builder.addFieldOffset(6, deadlineOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.createDeadlineVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.startDeadlineVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} propertyType + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.addPropertyType = function(builder, propertyType) { + builder.addFieldInt8(7, propertyType, 0); +}; + + +/** + * @param {flatbuffers.Builder} builder + * @param {number} modificationCount + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.addModificationCount = function(builder, modificationCount) { + builder.addFieldInt8(8, modificationCount, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} modificationsOffset + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.addModifications = function(builder, modificationsOffset) { + builder.addFieldOffset(9, modificationsOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.createModificationsVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.startModificationsVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.endAccountPropertiesMosaicTransactionBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} offset + */ +Catapult.Buffers.AccountPropertiesMosaicTransactionBuffer.finishAccountPropertiesMosaicTransactionBufferBuffer = function(builder, offset) { + builder.finish(offset); +}; + +// Exports for Node.js and RequireJS +export default Catapult; diff --git a/src/infrastructure/buffers/AddressAliasTransactionBuffer.ts b/src/infrastructure/buffers/AddressAliasTransactionBuffer.ts new file mode 100644 index 0000000000..48dd845503 --- /dev/null +++ b/src/infrastructure/buffers/AddressAliasTransactionBuffer.ts @@ -0,0 +1,479 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ + +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * @const + * @namespace + */ +var Catapult = Catapult || {}; + +/** + * @const + * @namespace + */ +Catapult.Buffers = Catapult.Buffers || {}; + +/** + * @constructor + */ +Catapult.Buffers.AddressAliasTransactionBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.AddressAliasTransactionBuffer} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.AddressAliasTransactionBuffer=} obj + * @returns {Catapult.Buffers.AddressAliasTransactionBuffer} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.getRootAsAddressAliasTransactionBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.AddressAliasTransactionBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.size = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.signature = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.signatureLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.signatureArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.signer = function(index) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.signerLength = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.signerArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.version = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.type = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.fee = function(index) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.feeLength = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.feeArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.deadline = function(index) { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.deadlineLength = function() { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.deadlineArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.actionType = function() { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.namespaceId = function(index) { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.namespaceIdLength = function() { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.namespaceIdArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.address = function(index) { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.addressLength = function() { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.prototype.addressArray = function() { + var offset = this.bb.__offset(this.bb_pos, 22); + 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; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.AddressAliasTransactionBuffer.startAddressAliasTransactionBuffer = function(builder) { + builder.startObject(10); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} size + */ +Catapult.Buffers.AddressAliasTransactionBuffer.addSize = function(builder, size) { + builder.addFieldInt32(0, size, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signatureOffset + */ +Catapult.Buffers.AddressAliasTransactionBuffer.addSignature = function(builder, signatureOffset) { + builder.addFieldOffset(1, signatureOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.createSignatureVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AddressAliasTransactionBuffer.startSignatureVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signerOffset + */ +Catapult.Buffers.AddressAliasTransactionBuffer.addSigner = function(builder, signerOffset) { + builder.addFieldOffset(2, signerOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.createSignerVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AddressAliasTransactionBuffer.startSignerVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} version + */ +Catapult.Buffers.AddressAliasTransactionBuffer.addVersion = function(builder, version) { + builder.addFieldInt16(3, version, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.AddressAliasTransactionBuffer.addType = function(builder, type) { + builder.addFieldInt16(4, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} feeOffset + */ +Catapult.Buffers.AddressAliasTransactionBuffer.addFee = function(builder, feeOffset) { + builder.addFieldOffset(5, feeOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.createFeeVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AddressAliasTransactionBuffer.startFeeVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} deadlineOffset + */ +Catapult.Buffers.AddressAliasTransactionBuffer.addDeadline = function(builder, deadlineOffset) { + builder.addFieldOffset(6, deadlineOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.createDeadlineVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AddressAliasTransactionBuffer.startDeadlineVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} actionType + */ +Catapult.Buffers.AddressAliasTransactionBuffer.addActionType = function(builder, actionType) { + builder.addFieldInt8(7, actionType, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} deltaOffset + */ +Catapult.Buffers.AddressAliasTransactionBuffer.addNamespaceId = function(builder, namespaceIdOffset) { + builder.addFieldOffset(8, namespaceIdOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.createNamespaceIdVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AddressAliasTransactionBuffer.startNamespaceIdVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} mosaicIdOffset + */ +Catapult.Buffers.AddressAliasTransactionBuffer.addAddress = function(builder, addressOffset) { + builder.addFieldOffset(9, addressOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.createAddressVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AddressAliasTransactionBuffer.startAddressVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AddressAliasTransactionBuffer.endAddressAliasTransactionBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} offset + */ +Catapult.Buffers.AddressAliasTransactionBuffer.finishAddressAliasTransactionBufferBuffer = function(builder, offset) { + builder.finish(offset); +}; + +// Exports for Node.js and RequireJS +export default Catapult; diff --git a/src/infrastructure/buffers/AggregateTransactionBuffer.ts b/src/infrastructure/buffers/AggregateTransactionBuffer.ts new file mode 100644 index 0000000000..e2f9f68e83 --- /dev/null +++ b/src/infrastructure/buffers/AggregateTransactionBuffer.ts @@ -0,0 +1,425 @@ +/* + * Copyright 2018 NEM + * + * 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. + */ + +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * @const + * @namespace + */ +var Catapult = Catapult || {}; + +/** + * @const + * @namespace + */ +Catapult.Buffers = Catapult.Buffers || {}; + +/** + * @constructor + */ +Catapult.Buffers.AggregateTransactionBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.AggregateTransactionBuffer} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.AggregateTransactionBuffer=} obj + * @returns {Catapult.Buffers.AggregateTransactionBuffer} + */ +Catapult.Buffers.AggregateTransactionBuffer.getRootAsAggregateTransactionBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.AggregateTransactionBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.size = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.signature = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.signatureLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.signatureArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.signer = function(index) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.signerLength = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.signerArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.version = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.type = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.fee = function(index) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.feeLength = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.feeArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.deadline = function(index) { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.deadlineLength = function() { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.deadlineArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.transactionsSize = function() { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.transactions = function(index) { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.transactionsLength = function() { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.AggregateTransactionBuffer.prototype.transactionsArray = function() { + var offset = this.bb.__offset(this.bb_pos, 20); + 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; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.AggregateTransactionBuffer.startAggregateTransactionBuffer = function(builder) { + builder.startObject(9); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} size + */ +Catapult.Buffers.AggregateTransactionBuffer.addSize = function(builder, size) { + builder.addFieldInt32(0, size, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signatureOffset + */ +Catapult.Buffers.AggregateTransactionBuffer.addSignature = function(builder, signatureOffset) { + builder.addFieldOffset(1, signatureOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AggregateTransactionBuffer.createSignatureVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AggregateTransactionBuffer.startSignatureVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signerOffset + */ +Catapult.Buffers.AggregateTransactionBuffer.addSigner = function(builder, signerOffset) { + builder.addFieldOffset(2, signerOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AggregateTransactionBuffer.createSignerVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AggregateTransactionBuffer.startSignerVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} version + */ +Catapult.Buffers.AggregateTransactionBuffer.addVersion = function(builder, version) { + builder.addFieldInt16(3, version, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.AggregateTransactionBuffer.addType = function(builder, type) { + builder.addFieldInt16(4, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} feeOffset + */ +Catapult.Buffers.AggregateTransactionBuffer.addFee = function(builder, feeOffset) { + builder.addFieldOffset(5, feeOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AggregateTransactionBuffer.createFeeVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AggregateTransactionBuffer.startFeeVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} deadlineOffset + */ +Catapult.Buffers.AggregateTransactionBuffer.addDeadline = function(builder, deadlineOffset) { + builder.addFieldOffset(6, deadlineOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AggregateTransactionBuffer.createDeadlineVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AggregateTransactionBuffer.startDeadlineVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} transactionsSize + */ +Catapult.Buffers.AggregateTransactionBuffer.addTransactionsSize = function(builder, transactionsSize) { + builder.addFieldInt32(7, transactionsSize, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} transactionsOffset + */ +Catapult.Buffers.AggregateTransactionBuffer.addTransactions = function(builder, transactionsOffset) { + builder.addFieldOffset(8, transactionsOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AggregateTransactionBuffer.createTransactionsVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.AggregateTransactionBuffer.startTransactionsVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.AggregateTransactionBuffer.endAggregateTransactionBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} offset + */ +Catapult.Buffers.AggregateTransactionBuffer.finishAggregateTransactionBufferBuffer = function(builder, offset) { + builder.finish(offset); +}; + +// Exports for Node.js and RequireJS +export default Catapult; diff --git a/src/infrastructure/buffers/HashLockTransactionBuffer.ts b/src/infrastructure/buffers/HashLockTransactionBuffer.ts new file mode 100644 index 0000000000..ed4f0d4d8d --- /dev/null +++ b/src/infrastructure/buffers/HashLockTransactionBuffer.ts @@ -0,0 +1,571 @@ +/* + * Copyright 2018 NEM + * + * 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. + */ + +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * @const + * @namespace + */ +var Catapult = Catapult || {}; + +/** + * @const + * @namespace + */ +Catapult.Buffers = Catapult.Buffers || {}; + +/** + * @constructor + */ +Catapult.Buffers.HashLockTransactionBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.HashLockTransactionBuffer} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.HashLockTransactionBuffer=} obj + * @returns {Catapult.Buffers.HashLockTransactionBuffer} + */ +Catapult.Buffers.HashLockTransactionBuffer.getRootAsHashLockTransactionBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.HashLockTransactionBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.size = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.signature = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.signatureLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.signatureArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.signer = function(index) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.signerLength = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.signerArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.version = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.type = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.fee = function(index) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.feeLength = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.feeArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.deadline = function(index) { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.deadlineLength = function() { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.deadlineArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.mosaicId = function(index) { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.mosaicIdLength = function() { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.mosaicIdArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.mosaicAmount = function(index) { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.mosaicAmountLength = function() { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.mosaicAmountArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.duration = function(index) { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.durationLength = function() { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.durationArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.hash = 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.hashLength = function() { + var offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.HashLockTransactionBuffer.prototype.hashArray = 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; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.HashLockTransactionBuffer.startHashLockTransactionBuffer = function(builder) { + builder.startObject(11); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} size + */ +Catapult.Buffers.HashLockTransactionBuffer.addSize = function(builder, size) { + builder.addFieldInt32(0, size, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signatureOffset + */ +Catapult.Buffers.HashLockTransactionBuffer.addSignature = function(builder, signatureOffset) { + builder.addFieldOffset(1, signatureOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.HashLockTransactionBuffer.createSignatureVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.HashLockTransactionBuffer.startSignatureVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signerOffset + */ +Catapult.Buffers.HashLockTransactionBuffer.addSigner = function(builder, signerOffset) { + builder.addFieldOffset(2, signerOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.HashLockTransactionBuffer.createSignerVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.HashLockTransactionBuffer.startSignerVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} version + */ +Catapult.Buffers.HashLockTransactionBuffer.addVersion = function(builder, version) { + builder.addFieldInt16(3, version, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.HashLockTransactionBuffer.addType = function(builder, type) { + builder.addFieldInt16(4, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} feeOffset + */ +Catapult.Buffers.HashLockTransactionBuffer.addFee = function(builder, feeOffset) { + builder.addFieldOffset(5, feeOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.HashLockTransactionBuffer.createFeeVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.HashLockTransactionBuffer.startFeeVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} deadlineOffset + */ +Catapult.Buffers.HashLockTransactionBuffer.addDeadline = function(builder, deadlineOffset) { + builder.addFieldOffset(6, deadlineOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.HashLockTransactionBuffer.createDeadlineVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.HashLockTransactionBuffer.startDeadlineVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} mosaicIdOffset + */ +Catapult.Buffers.HashLockTransactionBuffer.addMosaicId = function(builder, mosaicIdOffset) { + builder.addFieldOffset(7, mosaicIdOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.HashLockTransactionBuffer.createMosaicIdVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.HashLockTransactionBuffer.startMosaicIdVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} mosaicAmountOffset + */ +Catapult.Buffers.HashLockTransactionBuffer.addMosaicAmount = function(builder, mosaicAmountOffset) { + builder.addFieldOffset(8, mosaicAmountOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.HashLockTransactionBuffer.createMosaicAmountVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.HashLockTransactionBuffer.startMosaicAmountVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} durationOffset + */ +Catapult.Buffers.HashLockTransactionBuffer.addDuration = function(builder, durationOffset) { + builder.addFieldOffset(9, durationOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.HashLockTransactionBuffer.createDurationVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.HashLockTransactionBuffer.startDurationVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} hashOffset + */ +Catapult.Buffers.HashLockTransactionBuffer.addHash = function(builder, hashOffset) { + builder.addFieldOffset(10, hashOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.HashLockTransactionBuffer.createHashVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.HashLockTransactionBuffer.startHashVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.HashLockTransactionBuffer.endHashLockTransactionBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} offset + */ +Catapult.Buffers.HashLockTransactionBuffer.finishHashLockTransactionBufferBuffer = function(builder, offset) { + builder.finish(offset); +}; + +// Exports for Node.js and RequireJS +export default Catapult; diff --git a/src/infrastructure/buffers/MosaicAliasTransactionBuffer.ts b/src/infrastructure/buffers/MosaicAliasTransactionBuffer.ts new file mode 100644 index 0000000000..ee4d523f8d --- /dev/null +++ b/src/infrastructure/buffers/MosaicAliasTransactionBuffer.ts @@ -0,0 +1,479 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ + +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * @const + * @namespace + */ +var Catapult = Catapult || {}; + +/** + * @const + * @namespace + */ +Catapult.Buffers = Catapult.Buffers || {}; + +/** + * @constructor + */ +Catapult.Buffers.MosaicAliasTransactionBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.MosaicAliasTransactionBuffer} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.MosaicAliasTransactionBuffer=} obj + * @returns {Catapult.Buffers.MosaicAliasTransactionBuffer} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.getRootAsMosaicAliasTransactionBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.MosaicAliasTransactionBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.size = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.signature = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.signatureLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.signatureArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.signer = function(index) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.signerLength = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.signerArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.version = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.type = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.fee = function(index) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.feeLength = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.feeArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.deadline = function(index) { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.deadlineLength = function() { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.deadlineArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.actionType = function() { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.namespaceId = function(index) { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.namespaceIdLength = function() { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.namespaceIdArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.mosaicId = function(index) { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.mosaicIdLength = function() { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.prototype.mosaicIdArray = function() { + var 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; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.startMosaicAliasTransactionBuffer = function(builder) { + builder.startObject(10); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} size + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.addSize = function(builder, size) { + builder.addFieldInt32(0, size, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signatureOffset + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.addSignature = function(builder, signatureOffset) { + builder.addFieldOffset(1, signatureOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.createSignatureVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.startSignatureVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signerOffset + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.addSigner = function(builder, signerOffset) { + builder.addFieldOffset(2, signerOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.createSignerVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.startSignerVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} version + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.addVersion = function(builder, version) { + builder.addFieldInt16(3, version, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.addType = function(builder, type) { + builder.addFieldInt16(4, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} feeOffset + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.addFee = function(builder, feeOffset) { + builder.addFieldOffset(5, feeOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.createFeeVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.startFeeVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} deadlineOffset + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.addDeadline = function(builder, deadlineOffset) { + builder.addFieldOffset(6, deadlineOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.createDeadlineVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.startDeadlineVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} actionType + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.addActionType = function(builder, actionType) { + builder.addFieldInt8(7, actionType, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} deltaOffset + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.addNamespaceId = function(builder, namespaceIdOffset) { + builder.addFieldOffset(8, namespaceIdOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.createNamespaceIdVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.startNamespaceIdVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} mosaicIdOffset + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.addMosaicId = function(builder, mosaicIdOffset) { + builder.addFieldOffset(9, mosaicIdOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.createMosaicIdVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.startMosaicIdVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.endMosaicAliasTransactionBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} offset + */ +Catapult.Buffers.MosaicAliasTransactionBuffer.finishMosaicAliasTransactionBufferBuffer = function(builder, offset) { + builder.finish(offset); +}; + +// Exports for Node.js and RequireJS +export default Catapult; diff --git a/src/infrastructure/buffers/MosaicCreationTransactionBuffer.ts b/src/infrastructure/buffers/MosaicCreationTransactionBuffer.ts new file mode 100644 index 0000000000..eef8821885 --- /dev/null +++ b/src/infrastructure/buffers/MosaicCreationTransactionBuffer.ts @@ -0,0 +1,582 @@ +/* + * Copyright 2018 NEM + * + * 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. + */ + +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * @const + * @namespace + */ +var Catapult = Catapult || {}; + +/** + * @const + * @namespace + */ +Catapult.Buffers = Catapult.Buffers || {}; + +/** + * @constructor + */ +Catapult.Buffers.MosaicCreationTransactionBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.MosaicCreationTransactionBuffer} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.MosaicCreationTransactionBuffer=} obj + * @returns {Catapult.Buffers.MosaicCreationTransactionBuffer} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.getRootAsMosaicCreationTransactionBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.MosaicCreationTransactionBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.size = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.signature = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.signatureLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.signatureArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.signer = function(index) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.signerLength = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.signerArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.version = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.type = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.fee = function(index) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.feeLength = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.feeArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.deadline = function(index) { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.deadlineLength = function() { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.deadlineArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.nonce = function(index) { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.nonceLength = function() { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.nonceArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.mosaicId = function(index) { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.mosaicIdLength = function() { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.mosaicIdArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.numOptionalProperties = function() { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.flags = function() { + var offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.divisibility = function() { + var offset = this.bb.__offset(this.bb_pos, 26); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.indicateDuration = function() { + var offset = this.bb.__offset(this.bb_pos, 28); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.duration = function(index) { + var offset = this.bb.__offset(this.bb_pos, 30); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.durationLength = function() { + var offset = this.bb.__offset(this.bb_pos, 30); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.prototype.durationArray = function() { + var offset = this.bb.__offset(this.bb_pos, 30); + 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; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.startMosaicCreationTransactionBuffer = function(builder) { + builder.startObject(14); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} size + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.addSize = function(builder, size) { + builder.addFieldInt32(0, size, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signatureOffset + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.addSignature = function(builder, signatureOffset) { + builder.addFieldOffset(1, signatureOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.createSignatureVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.startSignatureVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signerOffset + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.addSigner = function(builder, signerOffset) { + builder.addFieldOffset(2, signerOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.createSignerVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.startSignerVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} version + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.addVersion = function(builder, version) { + builder.addFieldInt16(3, version, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.addType = function(builder, type) { + builder.addFieldInt16(4, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} feeOffset + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.addFee = function(builder, feeOffset) { + builder.addFieldOffset(5, feeOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.createFeeVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.startFeeVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} deadlineOffset + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.addDeadline = function(builder, deadlineOffset) { + builder.addFieldOffset(6, deadlineOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.createDeadlineVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.startDeadlineVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} nonce + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.addNonce = function(builder, nonceOffset) { + + builder.addFieldOffset(7, nonceOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.createNonceVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.startNonceVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} mosaicIdOffset + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.addMosaicId = function(builder, mosaicIdOffset) { + builder.addFieldOffset(8, mosaicIdOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.createMosaicIdVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.startMosaicIdVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numOptionalProperties + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.addNumOptionalProperties = function(builder, numOptionalProperties) { + builder.addFieldInt8(9, numOptionalProperties, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} flags + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.addFlags = function(builder, flags) { + builder.addFieldInt8(10, flags, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} divisibility + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.addDivisibility = function(builder, divisibility) { + builder.addFieldInt8(11, divisibility, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} indicateDuration + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.addIndicateDuration = function(builder, indicateDuration) { + builder.addFieldInt8(12, indicateDuration, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} durationOffset + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.addDuration = function(builder, durationOffset) { + builder.addFieldOffset(13, durationOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.createDurationVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.startDurationVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.endMosaicCreationTransactionBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} offset + */ +Catapult.Buffers.MosaicCreationTransactionBuffer.finishMosaicCreationTransactionBufferBuffer = function(builder, offset) { + builder.finish(offset); +}; + +// Exports for Node.js and RequireJS +export default Catapult; diff --git a/src/infrastructure/buffers/MosaicSupplyChangeTransactionBuffer.ts b/src/infrastructure/buffers/MosaicSupplyChangeTransactionBuffer.ts new file mode 100644 index 0000000000..0297f46688 --- /dev/null +++ b/src/infrastructure/buffers/MosaicSupplyChangeTransactionBuffer.ts @@ -0,0 +1,479 @@ +/* + * Copyright 2018 NEM + * + * 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. + */ + +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * @const + * @namespace + */ +var Catapult = Catapult || {}; + +/** + * @const + * @namespace + */ +Catapult.Buffers = Catapult.Buffers || {}; + +/** + * @constructor + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.MosaicSupplyChangeTransactionBuffer} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.MosaicSupplyChangeTransactionBuffer=} obj + * @returns {Catapult.Buffers.MosaicSupplyChangeTransactionBuffer} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.getRootAsMosaicSupplyChangeTransactionBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.MosaicSupplyChangeTransactionBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.size = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.signature = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.signatureLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.signatureArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.signer = function(index) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.signerLength = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.signerArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.version = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.type = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.fee = function(index) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.feeLength = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.feeArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.deadline = function(index) { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.deadlineLength = function() { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.deadlineArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.mosaicId = function(index) { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.mosaicIdLength = function() { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.mosaicIdArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.direction = function() { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.delta = function(index) { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.deltaLength = function() { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.prototype.deltaArray = function() { + var 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; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.startMosaicSupplyChangeTransactionBuffer = function(builder) { + builder.startObject(10); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} size + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.addSize = function(builder, size) { + builder.addFieldInt32(0, size, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signatureOffset + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.addSignature = function(builder, signatureOffset) { + builder.addFieldOffset(1, signatureOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.createSignatureVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.startSignatureVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signerOffset + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.addSigner = function(builder, signerOffset) { + builder.addFieldOffset(2, signerOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.createSignerVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.startSignerVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} version + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.addVersion = function(builder, version) { + builder.addFieldInt16(3, version, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.addType = function(builder, type) { + builder.addFieldInt16(4, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} feeOffset + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.addFee = function(builder, feeOffset) { + builder.addFieldOffset(5, feeOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.createFeeVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.startFeeVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} deadlineOffset + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.addDeadline = function(builder, deadlineOffset) { + builder.addFieldOffset(6, deadlineOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.createDeadlineVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.startDeadlineVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} mosaicIdOffset + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.addMosaicId = function(builder, mosaicIdOffset) { + builder.addFieldOffset(7, mosaicIdOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.createMosaicIdVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.startMosaicIdVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} direction + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.addDirection = function(builder, direction) { + builder.addFieldInt8(8, direction, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} deltaOffset + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.addDelta = function(builder, deltaOffset) { + builder.addFieldOffset(9, deltaOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.createDeltaVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.startDeltaVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.endMosaicSupplyChangeTransactionBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} offset + */ +Catapult.Buffers.MosaicSupplyChangeTransactionBuffer.finishMosaicSupplyChangeTransactionBufferBuffer = function(builder, offset) { + builder.finish(offset); +}; + +// Exports for Node.js and RequireJS +export default Catapult; diff --git a/src/infrastructure/buffers/MultisigModificationTransactionBuffer.ts b/src/infrastructure/buffers/MultisigModificationTransactionBuffer.ts new file mode 100644 index 0000000000..14376de447 --- /dev/null +++ b/src/infrastructure/buffers/MultisigModificationTransactionBuffer.ts @@ -0,0 +1,571 @@ +/* + * Copyright 2018 NEM + * + * 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. + */ + +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * @const + * @namespace + */ +var Catapult = Catapult || {}; + +/** + * @const + * @namespace + */ +Catapult.Buffers = Catapult.Buffers || {}; + +/** + * @constructor + */ +Catapult.Buffers.CosignatoryModificationBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.CosignatoryModificationBuffer} + */ +Catapult.Buffers.CosignatoryModificationBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.CosignatoryModificationBuffer=} obj + * @returns {Catapult.Buffers.CosignatoryModificationBuffer} + */ +Catapult.Buffers.CosignatoryModificationBuffer.getRootAsCosignatoryModificationBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.CosignatoryModificationBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.CosignatoryModificationBuffer.prototype.type = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.CosignatoryModificationBuffer.prototype.cosignatoryPublicKey = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.CosignatoryModificationBuffer.prototype.cosignatoryPublicKeyLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.CosignatoryModificationBuffer.prototype.cosignatoryPublicKeyArray = function() { + var 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; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.CosignatoryModificationBuffer.startCosignatoryModificationBuffer = function(builder) { + builder.startObject(2); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.CosignatoryModificationBuffer.addType = function(builder, type) { + builder.addFieldInt8(0, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} cosignatoryPublicKeyOffset + */ +Catapult.Buffers.CosignatoryModificationBuffer.addCosignatoryPublicKey = function(builder, cosignatoryPublicKeyOffset) { + builder.addFieldOffset(1, cosignatoryPublicKeyOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.CosignatoryModificationBuffer.createCosignatoryPublicKeyVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.CosignatoryModificationBuffer.startCosignatoryPublicKeyVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.CosignatoryModificationBuffer.endCosignatoryModificationBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @constructor + */ +Catapult.Buffers.MultisigModificationTransactionBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.MultisigModificationTransactionBuffer} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.MultisigModificationTransactionBuffer=} obj + * @returns {Catapult.Buffers.MultisigModificationTransactionBuffer} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.getRootAsMultisigModificationTransactionBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.MultisigModificationTransactionBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.size = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.signature = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.signatureLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.signatureArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.signer = function(index) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.signerLength = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.signerArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.version = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.type = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.fee = function(index) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.feeLength = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.feeArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.deadline = function(index) { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.deadlineLength = function() { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.deadlineArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.minRemovalDelta = function() { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.minApprovalDelta = function() { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.numModifications = function() { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @param {Catapult.Buffers.CosignatoryModificationBuffer=} obj + * @returns {Catapult.Buffers.CosignatoryModificationBuffer} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.modifications = function(index, obj) { + var offset = this.bb.__offset(this.bb_pos, 24); + return offset ? (obj || new Catapult.Buffers.CosignatoryModificationBuffer).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.prototype.modificationsLength = function() { + var offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.startMultisigModificationTransactionBuffer = function(builder) { + builder.startObject(11); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} size + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.addSize = function(builder, size) { + builder.addFieldInt32(0, size, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signatureOffset + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.addSignature = function(builder, signatureOffset) { + builder.addFieldOffset(1, signatureOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.createSignatureVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.startSignatureVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signerOffset + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.addSigner = function(builder, signerOffset) { + builder.addFieldOffset(2, signerOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.createSignerVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.startSignerVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} version + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.addVersion = function(builder, version) { + builder.addFieldInt16(3, version, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.addType = function(builder, type) { + builder.addFieldInt16(4, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} feeOffset + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.addFee = function(builder, feeOffset) { + builder.addFieldOffset(5, feeOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.createFeeVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.startFeeVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} deadlineOffset + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.addDeadline = function(builder, deadlineOffset) { + builder.addFieldOffset(6, deadlineOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.createDeadlineVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.startDeadlineVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} minRemovalDelta + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.addMinRemovalDelta = function(builder, minRemovalDelta) { + builder.addFieldInt8(7, minRemovalDelta, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} minApprovalDelta + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.addMinApprovalDelta = function(builder, minApprovalDelta) { + builder.addFieldInt8(8, minApprovalDelta, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numModifications + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.addNumModifications = function(builder, numModifications) { + builder.addFieldInt8(9, numModifications, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} modificationsOffset + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.addModifications = function(builder, modificationsOffset) { + builder.addFieldOffset(10, modificationsOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.createModificationsVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.startModificationsVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.endMultisigModificationTransactionBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} offset + */ +Catapult.Buffers.MultisigModificationTransactionBuffer.finishMultisigModificationTransactionBufferBuffer = function(builder, offset) { + builder.finish(offset); +}; + +// Exports for Node.js and RequireJS +export default Catapult; diff --git a/src/infrastructure/buffers/NamespaceCreationTransactionBuffer.ts b/src/infrastructure/buffers/NamespaceCreationTransactionBuffer.ts new file mode 100644 index 0000000000..47e9657a44 --- /dev/null +++ b/src/infrastructure/buffers/NamespaceCreationTransactionBuffer.ts @@ -0,0 +1,512 @@ +/* + * Copyright 2018 NEM + * + * 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. + */ + +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * @const + * @namespace + */ +var Catapult = Catapult || {}; + +/** + * @const + * @namespace + */ +Catapult.Buffers = Catapult.Buffers || {}; + +/** + * @constructor + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.NamespaceCreationTransactionBuffer} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.NamespaceCreationTransactionBuffer=} obj + * @returns {Catapult.Buffers.NamespaceCreationTransactionBuffer} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.getRootAsNamespaceCreationTransactionBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.NamespaceCreationTransactionBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.size = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.signature = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.signatureLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.signatureArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.signer = function(index) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.signerLength = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.signerArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.version = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.type = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.fee = function(index) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.feeLength = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.feeArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.deadline = function(index) { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.deadlineLength = function() { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.deadlineArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.namespaceType = function() { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.durationParentId = function(index) { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.durationParentIdLength = function() { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.durationParentIdArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.namespaceId = function(index) { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.namespaceIdLength = function() { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.namespaceIdArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.namespaceNameSize = function() { + var offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array|null} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.prototype.namespaceName = function(optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 26); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.startNamespaceCreationTransactionBuffer = function(builder) { + builder.startObject(12); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} size + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.addSize = function(builder, size) { + builder.addFieldInt32(0, size, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signatureOffset + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.addSignature = function(builder, signatureOffset) { + builder.addFieldOffset(1, signatureOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.createSignatureVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.startSignatureVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signerOffset + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.addSigner = function(builder, signerOffset) { + builder.addFieldOffset(2, signerOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.createSignerVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.startSignerVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} version + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.addVersion = function(builder, version) { + builder.addFieldInt16(3, version, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.addType = function(builder, type) { + builder.addFieldInt16(4, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} feeOffset + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.addFee = function(builder, feeOffset) { + builder.addFieldOffset(5, feeOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.createFeeVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.startFeeVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} deadlineOffset + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.addDeadline = function(builder, deadlineOffset) { + builder.addFieldOffset(6, deadlineOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.createDeadlineVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.startDeadlineVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} namespaceType + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.addNamespaceType = function(builder, namespaceType) { + builder.addFieldInt8(7, namespaceType, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} durationParentIdOffset + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.addDurationParentId = function(builder, durationParentIdOffset) { + builder.addFieldOffset(8, durationParentIdOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.createDurationParentIdVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.startDurationParentIdVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} namespaceIdOffset + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.addNamespaceId = function(builder, namespaceIdOffset) { + builder.addFieldOffset(9, namespaceIdOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.createNamespaceIdVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.startNamespaceIdVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} namespaceNameSize + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.addNamespaceNameSize = function(builder, namespaceNameSize) { + builder.addFieldInt8(10, namespaceNameSize, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} namespaceNameOffset + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.addNamespaceName = function(builder, namespaceNameOffset) { + builder.addFieldOffset(11, namespaceNameOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.endNamespaceCreationTransactionBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} offset + */ +Catapult.Buffers.NamespaceCreationTransactionBuffer.finishNamespaceCreationTransactionBufferBuffer = function(builder, offset) { + builder.finish(offset); +}; + +// Exports for Node.js and RequireJS +export default Catapult; diff --git a/src/infrastructure/buffers/SecretLockTransactionBuffer.ts b/src/infrastructure/buffers/SecretLockTransactionBuffer.ts new file mode 100644 index 0000000000..4036cdd4c2 --- /dev/null +++ b/src/infrastructure/buffers/SecretLockTransactionBuffer.ts @@ -0,0 +1,641 @@ +/* + * Copyright 2018 NEM + * + * 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. + */ + +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * @const + * @namespace + */ +var Catapult = Catapult || {}; + +/** + * @const + * @namespace + */ +Catapult.Buffers = Catapult.Buffers || {}; + +/** + * @constructor + */ +Catapult.Buffers.SecretLockTransactionBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.SecretLockTransactionBuffer} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.SecretLockTransactionBuffer=} obj + * @returns {Catapult.Buffers.SecretLockTransactionBuffer} + */ +Catapult.Buffers.SecretLockTransactionBuffer.getRootAsSecretLockTransactionBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.SecretLockTransactionBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.size = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.signature = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.signatureLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.signatureArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.signer = function(index) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.signerLength = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.signerArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.version = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.type = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.fee = function(index) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.feeLength = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.feeArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.deadline = function(index) { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.deadlineLength = function() { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.deadlineArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.mosaicId = function(index) { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.mosaicIdLength = function() { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.mosaicIdArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.mosaicAmount = function(index) { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.mosaicAmountLength = function() { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.mosaicAmountArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.duration = function(index) { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.durationLength = function() { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.durationArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.hashAlgorithm = function() { + var offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.secret = function(index) { + var offset = this.bb.__offset(this.bb_pos, 26); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.secretLength = function() { + var offset = this.bb.__offset(this.bb_pos, 26); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.secretArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.recipient = function(index) { + var offset = this.bb.__offset(this.bb_pos, 28); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.recipientLength = function() { + var offset = this.bb.__offset(this.bb_pos, 28); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.SecretLockTransactionBuffer.prototype.recipientArray = function() { + var offset = this.bb.__offset(this.bb_pos, 28); + 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; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.SecretLockTransactionBuffer.startSecretLockTransactionBuffer = function(builder) { + builder.startObject(13); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} size + */ +Catapult.Buffers.SecretLockTransactionBuffer.addSize = function(builder, size) { + builder.addFieldInt32(0, size, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signatureOffset + */ +Catapult.Buffers.SecretLockTransactionBuffer.addSignature = function(builder, signatureOffset) { + builder.addFieldOffset(1, signatureOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.SecretLockTransactionBuffer.createSignatureVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.SecretLockTransactionBuffer.startSignatureVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signerOffset + */ +Catapult.Buffers.SecretLockTransactionBuffer.addSigner = function(builder, signerOffset) { + builder.addFieldOffset(2, signerOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.SecretLockTransactionBuffer.createSignerVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.SecretLockTransactionBuffer.startSignerVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} version + */ +Catapult.Buffers.SecretLockTransactionBuffer.addVersion = function(builder, version) { + builder.addFieldInt16(3, version, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.SecretLockTransactionBuffer.addType = function(builder, type) { + builder.addFieldInt16(4, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} feeOffset + */ +Catapult.Buffers.SecretLockTransactionBuffer.addFee = function(builder, feeOffset) { + builder.addFieldOffset(5, feeOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.SecretLockTransactionBuffer.createFeeVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.SecretLockTransactionBuffer.startFeeVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} deadlineOffset + */ +Catapult.Buffers.SecretLockTransactionBuffer.addDeadline = function(builder, deadlineOffset) { + builder.addFieldOffset(6, deadlineOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.SecretLockTransactionBuffer.createDeadlineVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.SecretLockTransactionBuffer.startDeadlineVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} mosaicIdOffset + */ +Catapult.Buffers.SecretLockTransactionBuffer.addMosaicId = function(builder, mosaicIdOffset) { + builder.addFieldOffset(7, mosaicIdOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.SecretLockTransactionBuffer.createMosaicIdVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.SecretLockTransactionBuffer.startMosaicIdVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} mosaicAmountOffset + */ +Catapult.Buffers.SecretLockTransactionBuffer.addMosaicAmount = function(builder, mosaicAmountOffset) { + builder.addFieldOffset(8, mosaicAmountOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.SecretLockTransactionBuffer.createMosaicAmountVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.SecretLockTransactionBuffer.startMosaicAmountVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} durationOffset + */ +Catapult.Buffers.SecretLockTransactionBuffer.addDuration = function(builder, durationOffset) { + builder.addFieldOffset(9, durationOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.SecretLockTransactionBuffer.createDurationVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.SecretLockTransactionBuffer.startDurationVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} hashAlgorithm + */ +Catapult.Buffers.SecretLockTransactionBuffer.addHashAlgorithm = function(builder, hashAlgorithm) { + builder.addFieldInt8(10, hashAlgorithm, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} secretOffset + */ +Catapult.Buffers.SecretLockTransactionBuffer.addSecret = function(builder, secretOffset) { + builder.addFieldOffset(11, secretOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.SecretLockTransactionBuffer.createSecretVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.SecretLockTransactionBuffer.startSecretVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} recipientOffset + */ +Catapult.Buffers.SecretLockTransactionBuffer.addRecipient = function(builder, recipientOffset) { + builder.addFieldOffset(12, recipientOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.SecretLockTransactionBuffer.createRecipientVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.SecretLockTransactionBuffer.startRecipientVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.SecretLockTransactionBuffer.endSecretLockTransactionBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} offset + */ +Catapult.Buffers.SecretLockTransactionBuffer.finishSecretLockTransactionBufferBuffer = function(builder, offset) { + builder.finish(offset); +}; + +// Exports for Node.js and RequireJS +export default Catapult; diff --git a/src/infrastructure/buffers/SecretProofTransactionBuffer.ts b/src/infrastructure/buffers/SecretProofTransactionBuffer.ts new file mode 100644 index 0000000000..570f57a886 --- /dev/null +++ b/src/infrastructure/buffers/SecretProofTransactionBuffer.ts @@ -0,0 +1,549 @@ +/* + * Copyright 2018 NEM + * + * 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. + */ + +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * @const + * @namespace + */ +var Catapult = Catapult || {}; + +/** + * @const + * @namespace + */ +Catapult.Buffers = Catapult.Buffers || {}; + +/** + * @constructor + */ +Catapult.Buffers.SecretProofTransactionBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.SecretProofTransactionBuffer} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.SecretProofTransactionBuffer=} obj + * @returns {Catapult.Buffers.SecretProofTransactionBuffer} + */ +Catapult.Buffers.SecretProofTransactionBuffer.getRootAsSecretProofTransactionBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.SecretProofTransactionBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.size = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.signature = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.signatureLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.signatureArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.signer = function(index) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.signerLength = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.signerArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.version = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.type = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.fee = function(index) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.feeLength = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.feeArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.deadline = function(index) { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.deadlineLength = function() { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.deadlineArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.hashAlgorithm = function() { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.secret = function(index) { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.secretLength = function() { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.secretArray = function() { + var offset = this.bb.__offset(this.bb_pos, 20); + 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.recipient = function(index) { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.recipientLength = function() { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.recipientArray = function() { + var offset = this.bb.__offset(this.bb_pos, 22); + 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.proofSize = function() { + var offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.proof = function(index) { + var offset = this.bb.__offset(this.bb_pos, 26); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.proofLength = function() { + var offset = this.bb.__offset(this.bb_pos, 26); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.SecretProofTransactionBuffer.prototype.proofArray = function() { + var 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; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.SecretProofTransactionBuffer.startSecretProofTransactionBuffer = function(builder) { + builder.startObject(12); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} size + */ +Catapult.Buffers.SecretProofTransactionBuffer.addSize = function(builder, size) { + builder.addFieldInt32(0, size, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signatureOffset + */ +Catapult.Buffers.SecretProofTransactionBuffer.addSignature = function(builder, signatureOffset) { + builder.addFieldOffset(1, signatureOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.SecretProofTransactionBuffer.createSignatureVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.SecretProofTransactionBuffer.startSignatureVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signerOffset + */ +Catapult.Buffers.SecretProofTransactionBuffer.addSigner = function(builder, signerOffset) { + builder.addFieldOffset(2, signerOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.SecretProofTransactionBuffer.createSignerVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.SecretProofTransactionBuffer.startSignerVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} version + */ +Catapult.Buffers.SecretProofTransactionBuffer.addVersion = function(builder, version) { + builder.addFieldInt16(3, version, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.SecretProofTransactionBuffer.addType = function(builder, type) { + builder.addFieldInt16(4, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} feeOffset + */ +Catapult.Buffers.SecretProofTransactionBuffer.addFee = function(builder, feeOffset) { + builder.addFieldOffset(5, feeOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.SecretProofTransactionBuffer.createFeeVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.SecretProofTransactionBuffer.startFeeVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} deadlineOffset + */ +Catapult.Buffers.SecretProofTransactionBuffer.addDeadline = function(builder, deadlineOffset) { + builder.addFieldOffset(6, deadlineOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.SecretProofTransactionBuffer.createDeadlineVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.SecretProofTransactionBuffer.startDeadlineVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} hashAlgorithm + */ +Catapult.Buffers.SecretProofTransactionBuffer.addHashAlgorithm = function(builder, hashAlgorithm) { + builder.addFieldInt8(7, hashAlgorithm, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} secretOffset + */ +Catapult.Buffers.SecretProofTransactionBuffer.addSecret = function(builder, secretOffset) { + builder.addFieldOffset(8, secretOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.SecretProofTransactionBuffer.createSecretVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.SecretProofTransactionBuffer.startSecretVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} recipientOffset + */ +Catapult.Buffers.SecretProofTransactionBuffer.addRecipient = function(builder, recipientOffset) { + builder.addFieldOffset(9, recipientOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.SecretProofTransactionBuffer.createRecipientVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.SecretProofTransactionBuffer.startRecipientVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} proofSize + */ +Catapult.Buffers.SecretProofTransactionBuffer.addProofSize = function(builder, proofSize) { + builder.addFieldInt16(10, proofSize, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} proofOffset + */ +Catapult.Buffers.SecretProofTransactionBuffer.addProof = function(builder, proofOffset) { + builder.addFieldOffset(11, proofOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.SecretProofTransactionBuffer.createProofVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.SecretProofTransactionBuffer.startProofVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.SecretProofTransactionBuffer.endSecretProofTransactionBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} offset + */ +Catapult.Buffers.SecretProofTransactionBuffer.finishSecretProofTransactionBufferBuffer = function(builder, offset) { + builder.finish(offset); +}; + +// Exports for Node.js and RequireJS +export default Catapult; diff --git a/src/infrastructure/buffers/TransferTransactionBuffer.ts b/src/infrastructure/buffers/TransferTransactionBuffer.ts new file mode 100644 index 0000000000..05be19edfb --- /dev/null +++ b/src/infrastructure/buffers/TransferTransactionBuffer.ts @@ -0,0 +1,785 @@ +/* + * Copyright 2018 NEM + * + * 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. + */ + +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * @const + * @namespace + */ +var Catapult = Catapult || {}; + +/** + * @const + * @namespace + */ +Catapult.Buffers = Catapult.Buffers || {}; + +/** + * @constructor + */ +Catapult.Buffers.MessageBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.MessageBuffer} + */ +Catapult.Buffers.MessageBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.MessageBuffer=} obj + * @returns {Catapult.Buffers.MessageBuffer} + */ +Catapult.Buffers.MessageBuffer.getRootAsMessageBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.MessageBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MessageBuffer.prototype.type = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MessageBuffer.prototype.payload = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MessageBuffer.prototype.payloadLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.MessageBuffer.prototype.payloadArray = function() { + var 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; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.MessageBuffer.startMessageBuffer = function(builder) { + builder.startObject(2); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.MessageBuffer.addType = function(builder, type) { + builder.addFieldInt8(0, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} payloadOffset + */ +Catapult.Buffers.MessageBuffer.addPayload = function(builder, payloadOffset) { + builder.addFieldOffset(1, payloadOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MessageBuffer.createPayloadVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MessageBuffer.startPayloadVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MessageBuffer.endMessageBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @constructor + */ +Catapult.Buffers.MosaicBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.MosaicBuffer} + */ +Catapult.Buffers.MosaicBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.MosaicBuffer=} obj + * @returns {Catapult.Buffers.MosaicBuffer} + */ +Catapult.Buffers.MosaicBuffer.getRootAsMosaicBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.MosaicBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicBuffer.prototype.id = function(index) { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicBuffer.prototype.idLength = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.MosaicBuffer.prototype.idArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.MosaicBuffer.prototype.amount = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.MosaicBuffer.prototype.amountLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.MosaicBuffer.prototype.amountArray = function() { + var 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; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.MosaicBuffer.startMosaicBuffer = function(builder) { + builder.startObject(2); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} idOffset + */ +Catapult.Buffers.MosaicBuffer.addId = function(builder, idOffset) { + builder.addFieldOffset(0, idOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicBuffer.createIdVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicBuffer.startIdVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} amountOffset + */ +Catapult.Buffers.MosaicBuffer.addAmount = function(builder, amountOffset) { + builder.addFieldOffset(1, amountOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicBuffer.createAmountVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.MosaicBuffer.startAmountVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.MosaicBuffer.endMosaicBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @constructor + */ +Catapult.Buffers.TransferTransactionBuffer = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Catapult.Buffers.TransferTransactionBuffer} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Catapult.Buffers.TransferTransactionBuffer=} obj + * @returns {Catapult.Buffers.TransferTransactionBuffer} + */ +Catapult.Buffers.TransferTransactionBuffer.getRootAsTransferTransactionBuffer = function(bb, obj) { + return (obj || new Catapult.Buffers.TransferTransactionBuffer).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.size = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.signature = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.signatureLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.signatureArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.signer = function(index) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.signerLength = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.signerArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.version = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.type = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.fee = function(index) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.feeLength = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.feeArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.deadline = function(index) { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.deadlineLength = function() { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.deadlineArray = function() { + var 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; +}; + +/** + * @param {number} index + * @returns {number} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.recipient = function(index) { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.recipientLength = function() { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint8Array} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.recipientArray = function() { + var 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; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.messageSize = function() { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.numMosaics = function() { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {Catapult.Buffers.MessageBuffer=} obj + * @returns {Catapult.Buffers.MessageBuffer|null} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.message = function(obj) { + var offset = this.bb.__offset(this.bb_pos, 24); + return offset ? (obj || new Catapult.Buffers.MessageBuffer).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; +}; + +/** + * @param {number} index + * @param {Catapult.Buffers.MosaicBuffer=} obj + * @returns {Catapult.Buffers.MosaicBuffer} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.mosaics = function(index, obj) { + var offset = this.bb.__offset(this.bb_pos, 26); + return offset ? (obj || new Catapult.Buffers.MosaicBuffer).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; +}; + +/** + * @returns {number} + */ +Catapult.Buffers.TransferTransactionBuffer.prototype.mosaicsLength = function() { + var offset = this.bb.__offset(this.bb_pos, 26); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +Catapult.Buffers.TransferTransactionBuffer.startTransferTransactionBuffer = function(builder) { + builder.startObject(12); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} size + */ +Catapult.Buffers.TransferTransactionBuffer.addSize = function(builder, size) { + builder.addFieldInt32(0, size, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signatureOffset + */ +Catapult.Buffers.TransferTransactionBuffer.addSignature = function(builder, signatureOffset) { + builder.addFieldOffset(1, signatureOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.TransferTransactionBuffer.createSignatureVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.TransferTransactionBuffer.startSignatureVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} signerOffset + */ +Catapult.Buffers.TransferTransactionBuffer.addSigner = function(builder, signerOffset) { + builder.addFieldOffset(2, signerOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.TransferTransactionBuffer.createSignerVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.TransferTransactionBuffer.startSignerVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} version + */ +Catapult.Buffers.TransferTransactionBuffer.addVersion = function(builder, version) { + builder.addFieldInt16(3, version, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} type + */ +Catapult.Buffers.TransferTransactionBuffer.addType = function(builder, type) { + builder.addFieldInt16(4, type, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} feeOffset + */ +Catapult.Buffers.TransferTransactionBuffer.addFee = function(builder, feeOffset) { + builder.addFieldOffset(5, feeOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.TransferTransactionBuffer.createFeeVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.TransferTransactionBuffer.startFeeVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} deadlineOffset + */ +Catapult.Buffers.TransferTransactionBuffer.addDeadline = function(builder, deadlineOffset) { + builder.addFieldOffset(6, deadlineOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.TransferTransactionBuffer.createDeadlineVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.TransferTransactionBuffer.startDeadlineVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} recipientOffset + */ +Catapult.Buffers.TransferTransactionBuffer.addRecipient = function(builder, recipientOffset) { + builder.addFieldOffset(7, recipientOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.TransferTransactionBuffer.createRecipientVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.TransferTransactionBuffer.startRecipientVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} messageSize + */ +Catapult.Buffers.TransferTransactionBuffer.addMessageSize = function(builder, messageSize) { + builder.addFieldInt16(8, messageSize, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numMosaics + */ +Catapult.Buffers.TransferTransactionBuffer.addNumMosaics = function(builder, numMosaics) { + builder.addFieldInt8(9, numMosaics, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} messageOffset + */ +Catapult.Buffers.TransferTransactionBuffer.addMessage = function(builder, messageOffset) { + builder.addFieldOffset(10, messageOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} mosaicsOffset + */ +Catapult.Buffers.TransferTransactionBuffer.addMosaics = function(builder, mosaicsOffset) { + builder.addFieldOffset(11, mosaicsOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.TransferTransactionBuffer.createMosaicsVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +Catapult.Buffers.TransferTransactionBuffer.startMosaicsVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +Catapult.Buffers.TransferTransactionBuffer.endTransferTransactionBuffer = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} offset + */ +Catapult.Buffers.TransferTransactionBuffer.finishTransferTransactionBufferBuffer = function(builder, offset) { + builder.finish(offset); +}; + +// Exports for Node.js and RequireJS +export default Catapult; diff --git a/src/infrastructure/builders/AccountLinkTransaction.ts b/src/infrastructure/builders/AccountLinkTransaction.ts new file mode 100644 index 0000000000..4a4c390f66 --- /dev/null +++ b/src/infrastructure/builders/AccountLinkTransaction.ts @@ -0,0 +1,114 @@ +/* + * Copyright 2019 NEM + * + * 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/AccountLinkTransaction + */ +import { Convert as convert } from '../../core/format'; +import AccountLinkTransactionBufferPackage from '../buffers/AccountLinkTransactionBuffer'; +import AccountLinkTransactionSchema from '../schemas/AccountLinkTransactionSchema'; +import { + VerifiableTransaction, +} from './VerifiableTransaction'; + +const { + flatbuffers, +} = require('flatbuffers'); + +const { + AccountLinkTransactionBuffer, +} = AccountLinkTransactionBufferPackage.Buffers; + +export class AccountLinkTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, AccountLinkTransactionSchema); + } +} + +// tslint:disable-next-line:max-classes-per-file +export class Builder { + fee: any; + version: any; + type: any; + deadline: any; + remoteAccountKey: any; + linkAction: any; + constructor() { + this.fee = [0, 0]; + this.version = 36867; + this.type = 0x414C; + } + + addFee(fee) { + this.fee = fee; + 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 = convert.hexToUint8(remoteAccountKey); + return this; + } + + addLinkAction(linkAction) { + this.linkAction = linkAction; + return this; + } + build() { + const builder = new flatbuffers.Builder(1); + + // Create vectors + const signatureVector = AccountLinkTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = AccountLinkTransactionBuffer.createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = AccountLinkTransactionBuffer.createDeadlineVector(builder, this.deadline); + const feeVector = AccountLinkTransactionBuffer.createFeeVector(builder, this.fee); + const remoteAccountKeyVector = AccountLinkTransactionBuffer.createRemoteAccountKeyVector(builder, this.remoteAccountKey); + + AccountLinkTransactionBuffer.startAccountLinkTransactionBuffer(builder); + AccountLinkTransactionBuffer.addSize(builder, 153); + AccountLinkTransactionBuffer.addSignature(builder, signatureVector); + AccountLinkTransactionBuffer.addSigner(builder, signerVector); + AccountLinkTransactionBuffer.addVersion(builder, this.version); + AccountLinkTransactionBuffer.addType(builder, this.type); + AccountLinkTransactionBuffer.addFee(builder, feeVector); + AccountLinkTransactionBuffer.addDeadline(builder, deadlineVector); + AccountLinkTransactionBuffer.addRemoteAccountKey(builder, remoteAccountKeyVector); + AccountLinkTransactionBuffer.addLinkAction(builder, this.linkAction); + + // Calculate size + + const codedTransfer = AccountLinkTransactionBuffer.endAccountLinkTransactionBuffer(builder); + builder.finish(codedTransfer); + + const bytes = builder.asUint8Array(); + return new AccountLinkTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/AccountPropertiesAddressTransaction.ts b/src/infrastructure/builders/AccountPropertiesAddressTransaction.ts new file mode 100644 index 0000000000..6db85fd506 --- /dev/null +++ b/src/infrastructure/builders/AccountPropertiesAddressTransaction.ts @@ -0,0 +1,130 @@ +/* + * Copyright 2019 NEM + * + * 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/AccountPropertiesAddressTransaction + */ +import { RawAddress as address } from '../../core/format'; +import AccountPropertiesAddressTransactionBufferPackage from '../buffers/AccountPropertiesAddressTransactionBuffer'; +import AccountPropertiesAddressModificationTransactionSchema from '../schemas/AccountPropertiesAddressModificationTransactionSchema'; +import { VerifiableTransaction } from './VerifiableTransaction'; +const { + AccountPropertiesAddressTransactionBuffer, + PropertyAddressModificationBuffer, +} = AccountPropertiesAddressTransactionBufferPackage.Buffers; + +const { + flatbuffers +} = require('flatbuffers'); + +export default class AccountPropertiesAddressTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, AccountPropertiesAddressModificationTransactionSchema); + } +} + +// tslint:disable-next-line:max-classes-per-file +export class Builder { + fee: any; + version: any; + type: any; + deadline: any; + propertyType: any; + modifications: any; + constructor() { + this.fee = [0, 0]; + this.version = 36865; + this.type = 0x4150; + } + + addFee(fee) { + this.fee = fee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addPropertyType(propertyType) { + this.propertyType = propertyType; + return this; + } + + addModifications(modifications) { + this.modifications = modifications; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + // Create modifications + const modificationsArray: any = []; + this.modifications.forEach(modification => { + const addressModificationVector = PropertyAddressModificationBuffer + .createValueVector(builder, address.stringToAddress(modification.value)); + PropertyAddressModificationBuffer.startPropertyAddressModificationBuffer(builder); + PropertyAddressModificationBuffer.addModificationType(builder, modification.type); + PropertyAddressModificationBuffer.addValue(builder, addressModificationVector); + modificationsArray.push(PropertyAddressModificationBuffer.endPropertyAddressModificationBuffer(builder)); + }); + + // Create vectors + const signatureVector = AccountPropertiesAddressTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = AccountPropertiesAddressTransactionBuffer + .createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = AccountPropertiesAddressTransactionBuffer + .createDeadlineVector(builder, this.deadline); + const feeVector = AccountPropertiesAddressTransactionBuffer + .createFeeVector(builder, this.fee); + const modificationVector = AccountPropertiesAddressTransactionBuffer + .createModificationsVector(builder, modificationsArray); + + AccountPropertiesAddressTransactionBuffer.startAccountPropertiesAddressTransactionBuffer(builder); + AccountPropertiesAddressTransactionBuffer.addSize(builder, 122 + (26 * this.modifications.length)); + AccountPropertiesAddressTransactionBuffer.addSignature(builder, signatureVector); + AccountPropertiesAddressTransactionBuffer.addSigner(builder, signerVector); + AccountPropertiesAddressTransactionBuffer.addVersion(builder, this.version); + AccountPropertiesAddressTransactionBuffer.addType(builder, this.type); + AccountPropertiesAddressTransactionBuffer.addFee(builder, feeVector); + AccountPropertiesAddressTransactionBuffer.addDeadline(builder, deadlineVector); + AccountPropertiesAddressTransactionBuffer.addPropertyType(builder, this.propertyType); + AccountPropertiesAddressTransactionBuffer.addModificationCount(builder, this.modifications.length); + AccountPropertiesAddressTransactionBuffer.addModifications(builder, modificationVector); + + // Calculate size + const codedAccountPropertiesAddress = + AccountPropertiesAddressTransactionBuffer.endAccountPropertiesAddressTransactionBuffer(builder); + builder.finish(codedAccountPropertiesAddress); + + const bytes = builder.asUint8Array(); + + return new AccountPropertiesAddressTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/AccountPropertiesEntityTypeTransaction.ts b/src/infrastructure/builders/AccountPropertiesEntityTypeTransaction.ts new file mode 100644 index 0000000000..d868596e3a --- /dev/null +++ b/src/infrastructure/builders/AccountPropertiesEntityTypeTransaction.ts @@ -0,0 +1,128 @@ +/* + * Copyright 2019 NEM + * + * 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/AccountPropertiesEntityTypeTransaction + */ +import AccountPropertiesEntityTypeTransactionBufferPackage from '../buffers/AccountPropertiesEntityTypeTransactionBuffer'; +import AccountPropertiesEntityTypeModificationTransactionSchema from '../schemas/AccountPropertiesEntityTypeModificationTransactionSchema'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +const { + AccountPropertiesEntityTypeTransactionBuffer, + PropertyEntityTypeModificationBuffer, +} = AccountPropertiesEntityTypeTransactionBufferPackage.Buffers; + +const { + flatbuffers +} = require('flatbuffers'); + +export default class AccountPropertiesEntityTypeTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, AccountPropertiesEntityTypeModificationTransactionSchema); + } +} + +// tslint:disable-next-line:max-classes-per-file +export class Builder { + fee: any; + version: any; + type: any; + deadline: any; + propertyType: any; + modifications: any; + constructor() { + this.fee = [0, 0]; + this.version = 36865; + this.type = 0x4350; + } + + addFee(fee) { + this.fee = fee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addPropertyType(propertyType) { + this.propertyType = propertyType; + return this; + } + + addModifications(modifications) { + this.modifications = modifications; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + // Create modifications + const modificationsArray: any = []; + this.modifications.forEach(modification => { + PropertyEntityTypeModificationBuffer.startPropertyEntityTypeModificationBuffer(builder); + PropertyEntityTypeModificationBuffer.addModificationType(builder, modification.type); + PropertyEntityTypeModificationBuffer.addValue(builder, modification.value); + modificationsArray.push(PropertyEntityTypeModificationBuffer.endPropertyEntityTypeModificationBuffer(builder)); + }); + + // Create vectors + const signatureVector = AccountPropertiesEntityTypeTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = AccountPropertiesEntityTypeTransactionBuffer + .createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = AccountPropertiesEntityTypeTransactionBuffer + .createDeadlineVector(builder, this.deadline); + const feeVector = AccountPropertiesEntityTypeTransactionBuffer + .createFeeVector(builder, this.fee); + const modificationVector = AccountPropertiesEntityTypeTransactionBuffer + .createModificationsVector(builder, modificationsArray); + + AccountPropertiesEntityTypeTransactionBuffer.startAccountPropertiesEntityTypeTransactionBuffer(builder); + AccountPropertiesEntityTypeTransactionBuffer.addSize(builder, 122 + (3 * this.modifications.length)); + AccountPropertiesEntityTypeTransactionBuffer.addSignature(builder, signatureVector); + AccountPropertiesEntityTypeTransactionBuffer.addSigner(builder, signerVector); + AccountPropertiesEntityTypeTransactionBuffer.addVersion(builder, this.version); + AccountPropertiesEntityTypeTransactionBuffer.addType(builder, this.type); + AccountPropertiesEntityTypeTransactionBuffer.addFee(builder, feeVector); + AccountPropertiesEntityTypeTransactionBuffer.addDeadline(builder, deadlineVector); + AccountPropertiesEntityTypeTransactionBuffer.addPropertyType(builder, this.propertyType); + AccountPropertiesEntityTypeTransactionBuffer.addModificationCount(builder, this.modifications.length); + AccountPropertiesEntityTypeTransactionBuffer.addModifications(builder, modificationVector); + + // Calculate size + const codedAccountPropertiesAddress = AccountPropertiesEntityTypeTransactionBuffer + .endAccountPropertiesEntityTypeTransactionBuffer(builder); + builder.finish(codedAccountPropertiesAddress); + + const bytes = builder.asUint8Array(); + + return new AccountPropertiesEntityTypeTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/AccountPropertiesMosaicTransaction.ts b/src/infrastructure/builders/AccountPropertiesMosaicTransaction.ts new file mode 100644 index 0000000000..d50535b37f --- /dev/null +++ b/src/infrastructure/builders/AccountPropertiesMosaicTransaction.ts @@ -0,0 +1,129 @@ +/* + * Copyright 2019 NEM + * + * 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/AccountPropertiesMosaicTransaction + */ +import AccountPropertiesMosaicTransactionBufferPackage from '../buffers/AccountPropertiesMosaicTransactionBuffer'; +import AccountPropertiesMosaicModificationTransactionSchema from '../schemas/AccountPropertiesMosaicModificationTransactionSchema'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +const { + AccountPropertiesMosaicTransactionBuffer, + PropertyMosaicModificationBuffer, +} = AccountPropertiesMosaicTransactionBufferPackage.Buffers; + +const { + flatbuffers, +} = require('flatbuffers'); + +export default class AccountPropertiesMosaicTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, AccountPropertiesMosaicModificationTransactionSchema); + } +} + +// tslint:disable-next-line:max-classes-per-file +export class Builder { + fee: any; + version: any; + type: any; + deadline: any; + propertyType: any; + modifications: any; + constructor() { + this.fee = [0, 0]; + this.version = 36865; + this.type = 0x4250; + } + + addFee(fee) { + this.fee = fee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addPropertyType(propertyType) { + this.propertyType = propertyType; + return this; + } + + addModifications(modifications) { + this.modifications = modifications; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + // Create modifications + const modificationsArray: any = []; + this.modifications.forEach(modification => { + const addressModificationVector = PropertyMosaicModificationBuffer + .createValueVector(builder, modification.value); + PropertyMosaicModificationBuffer.startPropertyMosaicModificationBuffer(builder); + PropertyMosaicModificationBuffer.addModificationType(builder, modification.type); + PropertyMosaicModificationBuffer.addValue(builder, addressModificationVector); + modificationsArray.push(PropertyMosaicModificationBuffer.endPropertyMosaicModificationBuffer(builder)); + }); + + // Create vectors + const signatureVector = AccountPropertiesMosaicTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = AccountPropertiesMosaicTransactionBuffer + .createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = AccountPropertiesMosaicTransactionBuffer + .createDeadlineVector(builder, this.deadline); + const feeVector = AccountPropertiesMosaicTransactionBuffer + .createFeeVector(builder, this.fee); + const modificationVector = AccountPropertiesMosaicTransactionBuffer + .createModificationsVector(builder, modificationsArray); + + AccountPropertiesMosaicTransactionBuffer.startAccountPropertiesMosaicTransactionBuffer(builder); + AccountPropertiesMosaicTransactionBuffer.addSize(builder, 122 + (9 * this.modifications.length)); + AccountPropertiesMosaicTransactionBuffer.addSignature(builder, signatureVector); + AccountPropertiesMosaicTransactionBuffer.addSigner(builder, signerVector); + AccountPropertiesMosaicTransactionBuffer.addVersion(builder, this.version); + AccountPropertiesMosaicTransactionBuffer.addType(builder, this.type); + AccountPropertiesMosaicTransactionBuffer.addFee(builder, feeVector); + AccountPropertiesMosaicTransactionBuffer.addDeadline(builder, deadlineVector); + AccountPropertiesMosaicTransactionBuffer.addPropertyType(builder, this.propertyType); + AccountPropertiesMosaicTransactionBuffer.addModificationCount(builder, this.modifications.length); + AccountPropertiesMosaicTransactionBuffer.addModifications(builder, modificationVector); + + // Calculate size + const codedAccountPropertiesMosaic = AccountPropertiesMosaicTransactionBuffer.endAccountPropertiesMosaicTransactionBuffer(builder); + builder.finish(codedAccountPropertiesMosaic); + + const bytes = builder.asUint8Array(); + + return new AccountPropertiesMosaicTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/AddressAliasTransaction.ts b/src/infrastructure/builders/AddressAliasTransaction.ts new file mode 100644 index 0000000000..6e5ab8d169 --- /dev/null +++ b/src/infrastructure/builders/AddressAliasTransaction.ts @@ -0,0 +1,124 @@ +/* + * Copyright 2019 NEM + * + * 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 { RawAddress as addressLibrary } from '../../core/format'; +import AddressAliasTransactionBufferPackage from '../buffers/AddressAliasTransactionBuffer'; +import AddressAliasTransactionSchema from '../schemas/AddressAliasTransactionSchema'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +const { + AddressAliasTransactionBuffer, +} = AddressAliasTransactionBufferPackage.Buffers; + +const { + flatbuffers, +} = require('flatbuffers'); + +/** + * @module transactions/AddressAliasTransaction + */ +export class AddressAliasTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, AddressAliasTransactionSchema); + } +} +// tslint:disable-next-line:max-classes-per-file +export class Builder { + fee: any; + version: any; + type: any; + deadline: any; + address: any; + namespaceId: any; + actionType: any; + constructor() { + this.fee = [0, 0]; + this.version = 36865; + this.type = 0x424E; + } + + addFee(fee) { + this.fee = fee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addActionType(actionType) { + this.actionType = actionType; + return this; + } + + addNamespaceId(namespaceId) { + this.namespaceId = namespaceId; + return this; + } + + addAddress(address) { + this.address = addressLibrary.stringToAddress(address); + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + // Create vectors + const signatureVector = AddressAliasTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = AddressAliasTransactionBuffer + .createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = AddressAliasTransactionBuffer + .createDeadlineVector(builder, this.deadline); + const feeVector = AddressAliasTransactionBuffer + .createFeeVector(builder, this.fee); + const namespaceIdVector = AddressAliasTransactionBuffer + .createNamespaceIdVector(builder, this.namespaceId); + const addressVector = AddressAliasTransactionBuffer + .createAddressVector(builder, this.address); + + AddressAliasTransactionBuffer.startAddressAliasTransactionBuffer(builder); + AddressAliasTransactionBuffer.addSize(builder, 154); + AddressAliasTransactionBuffer.addSignature(builder, signatureVector); + AddressAliasTransactionBuffer.addSigner(builder, signerVector); + AddressAliasTransactionBuffer.addVersion(builder, this.version); + AddressAliasTransactionBuffer.addType(builder, this.type); + AddressAliasTransactionBuffer.addFee(builder, feeVector); + AddressAliasTransactionBuffer.addDeadline(builder, deadlineVector); + AddressAliasTransactionBuffer.addActionType(builder, this.actionType); + AddressAliasTransactionBuffer.addNamespaceId(builder, namespaceIdVector); + AddressAliasTransactionBuffer.addAddress(builder, addressVector); + + // Calculate size + const codedMosaicChangeSupply = AddressAliasTransactionBuffer.endAddressAliasTransactionBuffer(builder); + builder.finish(codedMosaicChangeSupply); + + const bytes = builder.asUint8Array(); + + return new AddressAliasTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/AggregateTransaction.ts b/src/infrastructure/builders/AggregateTransaction.ts new file mode 100644 index 0000000000..02eb1192cb --- /dev/null +++ b/src/infrastructure/builders/AggregateTransaction.ts @@ -0,0 +1,152 @@ +/* + * Copyright 2019 NEM + * + * 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/AggregateTransaction + */ +import AggregateTransactionBufferPackage from '../buffers/AggregateTransactionBuffer'; +import AggregateTransactionSchema from '../schemas/AggregateTransactionSchema'; +import { CosignatureTransaction} from './CosignatureTransaction'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +const { + flatbuffers, +} = require('flatbuffers'); + +const { + AggregateTransactionBuffer, +} = AggregateTransactionBufferPackage.Buffers; + +export class AggregateTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, AggregateTransactionSchema); + } + + signTransactionWithCosigners(initializer, cosigners, generationHash) { + const signedTransaction = this.signTransaction(initializer, generationHash); + cosigners.forEach((cosigner) => { + const signatureTransaction = new CosignatureTransaction(signedTransaction.hash); + const signatureCosignTransaction = signatureTransaction.signCosignatoriesTransaction(cosigner); + signedTransaction.payload = signedTransaction.payload + + signatureCosignTransaction.signer + signatureCosignTransaction.signature; + }); + + // Calculate new size + const size = `00000000${(signedTransaction.payload.length / 2).toString(16)}`; + const formatedSize = size.substr(size.length - 8, size.length); + const littleEndianSize = formatedSize.substr(6, 2) + formatedSize.substr(4, 2) + + formatedSize.substr(2, 2) + formatedSize.substr(0, 2); + + signedTransaction.payload = littleEndianSize + + signedTransaction.payload.substr(8, signedTransaction.payload.length - 8); + + return signedTransaction; + } + + signTransactionGivenSignatures(initializer, cosignedSignedTransactions, generationHash) { + const signedTransaction = this.signTransaction(initializer, generationHash); + cosignedSignedTransactions.forEach((cosignedTransaction) => { + signedTransaction.payload = signedTransaction.payload + cosignedTransaction.signer + cosignedTransaction.signature; + }); + + // Calculate new size + const size = `00000000${(signedTransaction.payload.length / 2).toString(16)}`; + const formatedSize = size.substr(size.length - 8, size.length); + const littleEndianSize = formatedSize.substr(6, 2) + formatedSize.substr(4, 2) + + formatedSize.substr(2, 2) + formatedSize.substr(0, 2); + + signedTransaction.payload = littleEndianSize + + signedTransaction.payload.substr(8, signedTransaction.payload.length - 8); + + return signedTransaction; + } +} +// tslint:disable-next-line:max-classes-per-file +export class Builder { + fee: any; + version: any; + type: any; + deadline: any; + transactions: any; + constructor() { + this.fee = [0, 0]; + this.version = 36867; + this.type = 0x4141; + } + + addFee(fee) { + this.fee = fee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addTransactions(transactions) { + let tmp = []; + for (let i = 0; i < transactions.length; ++i) { + tmp = tmp.concat(transactions[i]); + } + + this.transactions = tmp; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + // Create vectors + const signatureVector = AggregateTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)) + .map(Number.prototype.valueOf, 0)); + const signerVector = AggregateTransactionBuffer + .createSignerVector(builder, Array(...Array(32)) + .map(Number.prototype.valueOf, 0)); + const deadlineVector = AggregateTransactionBuffer.createDeadlineVector(builder, this.deadline); + const feeVector = AggregateTransactionBuffer.createFeeVector(builder, this.fee); + const modificationsVector = AggregateTransactionBuffer.createTransactionsVector(builder, this.transactions); + + AggregateTransactionBuffer.startAggregateTransactionBuffer(builder); + AggregateTransactionBuffer.addSize(builder, 120 + 4 + this.transactions.length); + AggregateTransactionBuffer.addSignature(builder, signatureVector); + AggregateTransactionBuffer.addSigner(builder, signerVector); + AggregateTransactionBuffer.addVersion(builder, this.version); + AggregateTransactionBuffer.addType(builder, this.type); + AggregateTransactionBuffer.addFee(builder, feeVector); + AggregateTransactionBuffer.addDeadline(builder, deadlineVector); + AggregateTransactionBuffer.addTransactionsSize(builder, 0 !== this.transactions.length ? this.transactions.length : 4294967296); + AggregateTransactionBuffer.addTransactions(builder, modificationsVector); + + // Calculate size + const codedAggregate = AggregateTransactionBuffer.endAggregateTransactionBuffer(builder); + builder.finish(codedAggregate); + + const bytes = builder.asUint8Array(); + return new AggregateTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/CosignatureTransaction.ts b/src/infrastructure/builders/CosignatureTransaction.ts new file mode 100644 index 0000000000..717041f910 --- /dev/null +++ b/src/infrastructure/builders/CosignatureTransaction.ts @@ -0,0 +1,27 @@ +/* + * Copyright 2019 NEM + * + * 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 { Convert as convert } from '../../core/format/Convert'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +/** + * @module transactions/AggregateSignatureTransaction + * @version 1.0.0 + */ +export class CosignatureTransaction extends VerifiableTransaction { + constructor(hash) { + super(convert.hexToUint8(hash), undefined); + } +} diff --git a/src/infrastructure/builders/Deadline.ts b/src/infrastructure/builders/Deadline.ts new file mode 100644 index 0000000000..3b37923c5a --- /dev/null +++ b/src/infrastructure/builders/Deadline.ts @@ -0,0 +1,22 @@ +/* + * Copyright 2019 NEM + * + * 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 { RawUInt64 as uint64 } from '../../core/format'; + +export default function deadline(deadlineParam) { + const NetworkTime = (new Date()).getTime() - 1459468800000; + const deadlineValue = deadlineParam || 60 * 60 * 1000; + return uint64.fromUint(deadlineValue + NetworkTime); +} \ No newline at end of file diff --git a/src/infrastructure/builders/HashLockTransaction.ts b/src/infrastructure/builders/HashLockTransaction.ts new file mode 100644 index 0000000000..a21bae30ca --- /dev/null +++ b/src/infrastructure/builders/HashLockTransaction.ts @@ -0,0 +1,129 @@ +/* + * Copyright 2019 NEM + * + * 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/HashLockTransaction + */ +import { Convert as convert } from '../../core/format'; +import * as HashLockTransactionBufferPackage from '../buffers/HashLockTransactionBuffer'; +import HashLockTransactionSchema from '../schemas/HashLockTransactionSchema'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +const { + flatbuffers, +} = require('flatbuffers'); + +const { + HashLockTransactionBuffer, +} = HashLockTransactionBufferPackage.default.Buffers; + +export default class HashLockTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, HashLockTransactionSchema); + } +} + +// tslint:disable-next-line:max-classes-per-file +export class Builder { + fee: any; + version: any; + type: any; + deadline: any; + mosaicId: any; + mosaicAmount: any; + duration: any; + hash: any; + constructor() { + this.fee = [0, 0]; + this.version = 36867; + this.type = 0x414C; + } + + addFee(fee) { + this.fee = fee; + 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; + } + + addMosaicAmount(mosaicAmount) { + this.mosaicAmount = mosaicAmount; + return this; + } + + addDuration(duration) { + this.duration = duration; + return this; + } + + addHash(hash) { + this.hash = hash; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + // Create vectors + const signatureVector = HashLockTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = HashLockTransactionBuffer.createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = HashLockTransactionBuffer.createDeadlineVector(builder, this.deadline); + const feeVector = HashLockTransactionBuffer.createFeeVector(builder, this.fee); + const mosaicIdVector = HashLockTransactionBuffer.createMosaicIdVector(builder, this.mosaicId); + const mosaicAmountVector = HashLockTransactionBuffer.createMosaicAmountVector(builder, this.mosaicAmount); + const durationVector = HashLockTransactionBuffer.createDurationVector(builder, this.duration); + const byteHash = convert.hexToUint8(this.hash); + const hashVector = HashLockTransactionBuffer.createHashVector(builder, byteHash); + + HashLockTransactionBuffer.startHashLockTransactionBuffer(builder); + HashLockTransactionBuffer.addSize(builder, 176); + HashLockTransactionBuffer.addSignature(builder, signatureVector); + HashLockTransactionBuffer.addSigner(builder, signerVector); + HashLockTransactionBuffer.addVersion(builder, this.version); + HashLockTransactionBuffer.addType(builder, this.type); + HashLockTransactionBuffer.addFee(builder, feeVector); + HashLockTransactionBuffer.addDeadline(builder, deadlineVector); + HashLockTransactionBuffer.addMosaicId(builder, mosaicIdVector); + HashLockTransactionBuffer.addMosaicAmount(builder, mosaicAmountVector); + HashLockTransactionBuffer.addDuration(builder, durationVector); + HashLockTransactionBuffer.addHash(builder, hashVector); + + const codedHashLock = HashLockTransactionBuffer.endHashLockTransactionBuffer(builder); + builder.finish(codedHashLock); + + const bytes = builder.asUint8Array(); + return new HashLockTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/MosaicAliasTransaction.ts b/src/infrastructure/builders/MosaicAliasTransaction.ts new file mode 100644 index 0000000000..1372d6cacb --- /dev/null +++ b/src/infrastructure/builders/MosaicAliasTransaction.ts @@ -0,0 +1,124 @@ +/* + * Copyright 2019 NEM + * + * 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 MosaicAliasTransactionBufferPackage from '../buffers/MosaicAliasTransactionBuffer'; +import MosaicAliasTransactionSchema from '../schemas/MosaicAliasTransactionSchema'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +const { + MosaicAliasTransactionBuffer, +} = MosaicAliasTransactionBufferPackage.Buffers; + +const { + flatbuffers, +} = require('flatbuffers'); + +/** + * @module transactions/MosaicAliasTransaction + */ +export default class MosaicAliasTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, MosaicAliasTransactionSchema); + } +} + +// tslint:disable-next-line:max-classes-per-file +export class Builder { + fee: any; + version: any; + type: any; + deadline: any; + mosaicId: any; + actionType: any; + namespaceId: any; + constructor() { + this.fee = [0, 0]; + this.version = 36865; + this.type = 0x434E; + } + + addFee(fee) { + this.fee = fee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addActionType(actionType) { + this.actionType = actionType; + return this; + } + + addNamespaceId(namespaceId) { + this.namespaceId = namespaceId; + return this; + } + + addMosaicId(mosaicId) { + this.mosaicId = mosaicId; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + // Create vectors + const signatureVector = MosaicAliasTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = MosaicAliasTransactionBuffer + .createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = MosaicAliasTransactionBuffer + .createDeadlineVector(builder, this.deadline); + const feeVector = MosaicAliasTransactionBuffer + .createFeeVector(builder, this.fee); + const namespaceIdVector = MosaicAliasTransactionBuffer + .createNamespaceIdVector(builder, this.namespaceId); + const mosaicIdVector = MosaicAliasTransactionBuffer + .createMosaicIdVector(builder, this.mosaicId); + + MosaicAliasTransactionBuffer.startMosaicAliasTransactionBuffer(builder); + MosaicAliasTransactionBuffer.addSize(builder, 137); + MosaicAliasTransactionBuffer.addSignature(builder, signatureVector); + MosaicAliasTransactionBuffer.addSigner(builder, signerVector); + MosaicAliasTransactionBuffer.addVersion(builder, this.version); + MosaicAliasTransactionBuffer.addType(builder, this.type); + MosaicAliasTransactionBuffer.addFee(builder, feeVector); + MosaicAliasTransactionBuffer.addDeadline(builder, deadlineVector); + MosaicAliasTransactionBuffer.addActionType(builder, this.actionType); + MosaicAliasTransactionBuffer.addNamespaceId(builder, namespaceIdVector); + MosaicAliasTransactionBuffer.addMosaicId(builder, mosaicIdVector); + + // Calculate size + const codedMosaicChangeSupply = MosaicAliasTransactionBuffer.endMosaicAliasTransactionBuffer(builder); + builder.finish(codedMosaicChangeSupply); + + const bytes = builder.asUint8Array(); + + return new MosaicAliasTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/MosaicCreationTransaction.ts b/src/infrastructure/builders/MosaicCreationTransaction.ts new file mode 100644 index 0000000000..e4909f5955 --- /dev/null +++ b/src/infrastructure/builders/MosaicCreationTransaction.ts @@ -0,0 +1,166 @@ +/* + * Copyright 2019 NEM + * + * 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/MosaicCreationTransaction + */ +import MosaicCreationTransactionBufferPackage from '../buffers/MosaicCreationTransactionBuffer'; +import { + schema as MosaicCreationTransactionSchema, + schemaNoDuration as MosaicCreationTransactionSchemaNoDuration +} from '../schemas/MosaicCreationTransactionSchema'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +const { + flatbuffers, +} = require('flatbuffers'); + +const { + MosaicCreationTransactionBuffer, +} = MosaicCreationTransactionBufferPackage.Buffers; + +export default class MosaicCreationTransaction extends VerifiableTransaction { + constructor(bytes, schema) { + super(bytes, schema); + } +} +// tslint:disable-next-line: max-classes-per-file +export class Builder { + fee: any; + version: any; + type: any; + deadline: any; + mosaicId: any; + flags: any; + nonce: any; + divisibility: any; + duration: any; + constructor() { + this.flags = 0; + this.fee = [0, 0]; + this.version = 36867; + this.type = 0x414d; + this.nonce = 0; + } + + addFee(fee) { + this.fee = fee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addNonce(nonce) { + this.nonce = nonce; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addDuration(duration) { + this.duration = duration; + return this; + } + + addDivisibility(divisibility) { + this.divisibility = divisibility; + return this; + } + + addSupplyMutable() { + this.flags += 1; + return this; + } + + addTransferability() { + this.flags += 2; + return this; + } + + addLevyMutable() { + this.flags += 4; + return this; + } + + addMosaicId(mosaicId) { + this.mosaicId = mosaicId; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + // Create vectors + const signatureVector = MosaicCreationTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = MosaicCreationTransactionBuffer + .createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = MosaicCreationTransactionBuffer + .createDeadlineVector(builder, this.deadline); + const feeVector = MosaicCreationTransactionBuffer + .createFeeVector(builder, this.fee); + const nonceVector = MosaicCreationTransactionBuffer + .createNonceVector(builder, this.nonce); + const mosaicIdVector = MosaicCreationTransactionBuffer + .createMosaicIdVector(builder, this.mosaicId); + + const durationVector = MosaicCreationTransactionBuffer + .createDurationVector(builder, this.duration); + + const durationProvided = 0 < this.duration.length; + + MosaicCreationTransactionBuffer.startMosaicCreationTransactionBuffer(builder); + MosaicCreationTransactionBuffer.addSize(builder, durationProvided ? 144 : 135); + MosaicCreationTransactionBuffer.addSignature(builder, signatureVector); + MosaicCreationTransactionBuffer.addSigner(builder, signerVector); + MosaicCreationTransactionBuffer.addVersion(builder, this.version); + MosaicCreationTransactionBuffer.addType(builder, this.type); + MosaicCreationTransactionBuffer.addFee(builder, feeVector); + MosaicCreationTransactionBuffer.addDeadline(builder, deadlineVector); + MosaicCreationTransactionBuffer.addNonce(builder, nonceVector); + MosaicCreationTransactionBuffer.addMosaicId(builder, mosaicIdVector); + MosaicCreationTransactionBuffer.addNumOptionalProperties(builder, durationProvided ? 1 : 0); + MosaicCreationTransactionBuffer.addFlags(builder, this.flags); + + MosaicCreationTransactionBuffer.addDivisibility(builder, this.divisibility); + + if (durationProvided) { + MosaicCreationTransactionBuffer.addIndicateDuration(builder, 2); + MosaicCreationTransactionBuffer.addDuration(builder, durationVector); + } + + // Calculate size + + const codedMosaicCreation = MosaicCreationTransactionBuffer.endMosaicCreationTransactionBuffer(builder); + builder.finish(codedMosaicCreation); + + const bytes = builder.asUint8Array(); + + const schema = durationProvided ? MosaicCreationTransactionSchema : MosaicCreationTransactionSchemaNoDuration; + return new MosaicCreationTransaction(bytes, schema); + } +} diff --git a/src/infrastructure/builders/MosaicSupplyChangeTransaction.ts b/src/infrastructure/builders/MosaicSupplyChangeTransaction.ts new file mode 100644 index 0000000000..4c9e77a1bd --- /dev/null +++ b/src/infrastructure/builders/MosaicSupplyChangeTransaction.ts @@ -0,0 +1,122 @@ +/* + * Copyright 2019 NEM + * + * 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 MosaicSupplyChangeTransactionBufferPackage from '../buffers/MosaicSupplyChangeTransactionBuffer'; +import MosaicSupplyChangeTransactionSchema from '../schemas/MosaicSupplyChangeTransactionSchema'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +const { + MosaicSupplyChangeTransactionBuffer, +} = MosaicSupplyChangeTransactionBufferPackage.Buffers; + +const { + flatbuffers, +} = require('flatbuffers'); + +/** + * @module transactions/MosaicSupplyChangeTransaction + */ +export default class MosaicSupplyChangeTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, MosaicSupplyChangeTransactionSchema); + } +} +// tslint:disable-next-line:max-classes-per-file +export class Builder { + fee: any; + version: any; + type: any; + deadline: any; + mosaicId: any; + direction: any; + delta: any; + constructor() { + this.fee = [0, 0]; + this.version = 36867; + this.type = 0x424d; + } + + addFee(fee) { + this.fee = fee; + 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; + } + + addDirection(direction) { + this.direction = direction; + return this; + } + + addDelta(delta) { + this.delta = delta; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + // Create vectors + const signatureVector = MosaicSupplyChangeTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = MosaicSupplyChangeTransactionBuffer + .createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = MosaicSupplyChangeTransactionBuffer + .createDeadlineVector(builder, this.deadline); + const feeVector = MosaicSupplyChangeTransactionBuffer + .createFeeVector(builder, this.fee); + const mosaicIdVector = MosaicSupplyChangeTransactionBuffer + .createFeeVector(builder, this.mosaicId); + const deltaVector = MosaicSupplyChangeTransactionBuffer + .createFeeVector(builder, this.delta); + + MosaicSupplyChangeTransactionBuffer.startMosaicSupplyChangeTransactionBuffer(builder); + MosaicSupplyChangeTransactionBuffer.addSize(builder, 137); + MosaicSupplyChangeTransactionBuffer.addSignature(builder, signatureVector); + MosaicSupplyChangeTransactionBuffer.addSigner(builder, signerVector); + MosaicSupplyChangeTransactionBuffer.addVersion(builder, this.version); + MosaicSupplyChangeTransactionBuffer.addType(builder, this.type); + MosaicSupplyChangeTransactionBuffer.addFee(builder, feeVector); + MosaicSupplyChangeTransactionBuffer.addDeadline(builder, deadlineVector); + MosaicSupplyChangeTransactionBuffer.addMosaicId(builder, mosaicIdVector); + MosaicSupplyChangeTransactionBuffer.addDirection(builder, this.direction); + MosaicSupplyChangeTransactionBuffer.addDelta(builder, deltaVector); + + // Calculate size + const codedMosaicChangeSupply = MosaicSupplyChangeTransactionBuffer.endMosaicSupplyChangeTransactionBuffer(builder); + builder.finish(codedMosaicChangeSupply); + + const bytes = builder.asUint8Array(); + return new MosaicSupplyChangeTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/MultisigModificationTransaction.ts b/src/infrastructure/builders/MultisigModificationTransaction.ts new file mode 100644 index 0000000000..65a4787f27 --- /dev/null +++ b/src/infrastructure/builders/MultisigModificationTransaction.ts @@ -0,0 +1,136 @@ +/* + * Copyright 2019 NEM + * + * 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 { Convert as convert } from '../../core/format'; +import MultisigModificationTransactionBufferPackage from '../buffers/MultisigModificationTransactionBuffer'; +import MultisigModificationTransactionSchema from '../schemas/MultisigModificationTransactionSchema'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +const { + flatbuffers +} = require('flatbuffers'); + +const { + MultisigModificationTransactionBuffer, + CosignatoryModificationBuffer, +} = MultisigModificationTransactionBufferPackage.Buffers; + +/** + * @module transactions/MultisigModificationTransaction + */ +export default class MultisigModificationTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, MultisigModificationTransactionSchema); + } +} + +// tslint:disable-next-line:max-classes-per-file +export class Builder { + fee: any; + version: any; + type: any; + deadline: any; + minRemovalDelta: any; + minApprovalDelta: any; + modifications: any; + constructor() { + this.fee = [0, 0]; + this.version = 36867; + this.type = 0x4155; + } + + addFee(fee) { + this.fee = fee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addMinRemovalDelta(minRemovalDelta) { + this.minRemovalDelta = minRemovalDelta; + return this; + } + + addMinApprovalDelta(minApprovalDelta) { + this.minApprovalDelta = minApprovalDelta; + return this; + } + + addModifications(modifications) { + this.modifications = modifications; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + // Create modifications + const modificationsArray: any = []; + this.modifications.forEach(modification => { + const cosignatoryPublicKeyVector = CosignatoryModificationBuffer + .createCosignatoryPublicKeyVector(builder, convert.hexToUint8(modification.cosignatoryPublicKey)); + CosignatoryModificationBuffer.startCosignatoryModificationBuffer(builder); + CosignatoryModificationBuffer.addType(builder, modification.type); + CosignatoryModificationBuffer.addCosignatoryPublicKey(builder, cosignatoryPublicKeyVector); + modificationsArray.push(CosignatoryModificationBuffer.endCosignatoryModificationBuffer(builder)); + }); + + // Create vectors + const signatureVector = MultisigModificationTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = MultisigModificationTransactionBuffer + .createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = MultisigModificationTransactionBuffer + .createDeadlineVector(builder, this.deadline); + const feeVector = MultisigModificationTransactionBuffer + .createFeeVector(builder, this.fee); + const modificationsVector = MultisigModificationTransactionBuffer + .createModificationsVector(builder, modificationsArray); + + MultisigModificationTransactionBuffer.startMultisigModificationTransactionBuffer(builder); + MultisigModificationTransactionBuffer.addSize(builder, 123 + (33 * this.modifications.length)); + MultisigModificationTransactionBuffer.addSignature(builder, signatureVector); + MultisigModificationTransactionBuffer.addSigner(builder, signerVector); + MultisigModificationTransactionBuffer.addVersion(builder, this.version); + MultisigModificationTransactionBuffer.addType(builder, this.type); + MultisigModificationTransactionBuffer.addFee(builder, feeVector); + MultisigModificationTransactionBuffer.addDeadline(builder, deadlineVector); + MultisigModificationTransactionBuffer.addMinRemovalDelta(builder, this.minRemovalDelta); + MultisigModificationTransactionBuffer.addMinApprovalDelta(builder, this.minApprovalDelta); + MultisigModificationTransactionBuffer.addNumModifications(builder, this.modifications.length); + MultisigModificationTransactionBuffer.addModifications(builder, modificationsVector); + + // Calculate size + const codedMultisigAggregate = MultisigModificationTransactionBuffer + .endMultisigModificationTransactionBuffer(builder); + builder.finish(codedMultisigAggregate); + + const bytes = builder.asUint8Array(); + return new MultisigModificationTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/NamespaceCreationTransaction.ts b/src/infrastructure/builders/NamespaceCreationTransaction.ts new file mode 100644 index 0000000000..88f420b15a --- /dev/null +++ b/src/infrastructure/builders/NamespaceCreationTransaction.ts @@ -0,0 +1,144 @@ +/* + * Copyright 2019 NEM + * + * 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/NamespaceCreationTransaction + */ +import { Convert as convert } from '../../core/format'; +import * as NamespaceCreationTransactionBufferPackage from '../buffers/NamespaceCreationTransactionBuffer'; +import NamespaceCreationTransactionSchema from '../schemas/NamespaceCreationTransactionSchema'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +const { + NamespaceCreationTransactionBuffer, +} = NamespaceCreationTransactionBufferPackage.default.Buffers; + +const { + flatbuffers, +} = require('flatbuffers'); + +export default class NamespaceCreationTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, NamespaceCreationTransactionSchema); + } +} + +// tslint:disable-next-line:max-classes-per-file +export class Builder { + fee: any; + version: any; + type: any; + deadline: any; + namespaceType: any; + duration: any; + parentId: any; + namespaceId: any; + namespaceName: any; + constructor() { + this.fee = [0, 0]; + this.version = 36867; + this.type = 0x414e; + } + + addFee(fee) { + this.fee = fee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addNamespaceType(namespaceType) { + this.namespaceType = namespaceType; + return this; + } + + addDuration(duration) { + this.duration = duration; + return this; + } + + addParentId(parentId) { + this.parentId = parentId; + return this; + } + + addNamespaceId(namespaceId) { + this.namespaceId = namespaceId; + return this; + } + + addNamespaceName(namespaceName) { + this.namespaceName = namespaceName; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + const namespaceNameLength = convert.utf8ToHex(this.namespaceName).length / 2; + + // create vectors + const signatureVector = NamespaceCreationTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = NamespaceCreationTransactionBuffer + .createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = NamespaceCreationTransactionBuffer + .createDeadlineVector(builder, this.deadline); + const feeVector = NamespaceCreationTransactionBuffer + .createFeeVector(builder, this.fee); + const parentIdVector = 1 === this.namespaceType ? this.parentId : this.duration; + const durationParentIdVector = NamespaceCreationTransactionBuffer + .createDurationParentIdVector(builder, parentIdVector); + const namespaceIdVector = NamespaceCreationTransactionBuffer + .createNamespaceIdVector(builder, this.namespaceId); + + const name = builder.createString(this.namespaceName); + + NamespaceCreationTransactionBuffer.startNamespaceCreationTransactionBuffer(builder); + NamespaceCreationTransactionBuffer.addSize(builder, 138 + namespaceNameLength); + NamespaceCreationTransactionBuffer.addSignature(builder, signatureVector); + NamespaceCreationTransactionBuffer.addSigner(builder, signerVector); + NamespaceCreationTransactionBuffer.addVersion(builder, this.version); + NamespaceCreationTransactionBuffer.addType(builder, this.type); + NamespaceCreationTransactionBuffer.addFee(builder, feeVector); + NamespaceCreationTransactionBuffer.addDeadline(builder, deadlineVector); + NamespaceCreationTransactionBuffer.addNamespaceType(builder, this.namespaceType); + NamespaceCreationTransactionBuffer.addDurationParentId(builder, durationParentIdVector); + NamespaceCreationTransactionBuffer.addNamespaceId(builder, namespaceIdVector); + NamespaceCreationTransactionBuffer.addNamespaceNameSize(builder, namespaceNameLength); + NamespaceCreationTransactionBuffer.addNamespaceName(builder, name); + + // Calculate size + const codedNamespace = NamespaceCreationTransactionBuffer.endNamespaceCreationTransactionBuffer(builder); + builder.finish(codedNamespace); + + const bytes = builder.asUint8Array(); + return new NamespaceCreationTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/SecretLockTransaction.ts b/src/infrastructure/builders/SecretLockTransaction.ts new file mode 100644 index 0000000000..d2d4e94bbc --- /dev/null +++ b/src/infrastructure/builders/SecretLockTransaction.ts @@ -0,0 +1,144 @@ +/* + * Copyright 2019 NEM + * + * 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/SecretLockTransaction + */ +import { Convert as convert, RawAddress as address } from '../../core/format'; +import * as SecretLockTransactionBufferPackage from '../../infrastructure/buffers/SecretLockTransactionBuffer'; +import { VerifiableTransaction } from '../../infrastructure/builders/VerifiableTransaction'; +import SecretLockTransactionSchema from '../../infrastructure/schemas/SecretLockTransactionSchema'; + +const { + flatbuffers, +} = require('flatbuffers'); + +const { + SecretLockTransactionBuffer, +} = SecretLockTransactionBufferPackage.default.Buffers; + +export default class SecretLockTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, SecretLockTransactionSchema); + } +} + +// tslint:disable-next-line:max-classes-per-file +export class Builder { + fee: any; + version: any; + type: any; + deadline: any; + mosaicId: any; + mosaicAmount: any; + duration: any; + hashAlgorithm: any; + secret: any; + recipient: any; + constructor() { + this.fee = [0, 0]; + this.version = 36865; + this.type = 0x424C; + } + + addFee(fee) { + this.fee = fee; + 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; + } + + addMosaicAmount(mosaicAmount) { + this.mosaicAmount = mosaicAmount; + return this; + } + + addDuration(duration) { + this.duration = duration; + return this; + } + + addHashAlgorithm(hashAlgorithm) { + this.hashAlgorithm = hashAlgorithm; + return this; + } + + addSecret(secret) { + this.secret = secret; + return this; + } + + addRecipient(recipient) { + this.recipient = address.stringToAddress(recipient); + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + // Create vectors + const signatureVector = SecretLockTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = SecretLockTransactionBuffer.createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = SecretLockTransactionBuffer.createDeadlineVector(builder, this.deadline); + const feeVector = SecretLockTransactionBuffer.createFeeVector(builder, this.fee); + const mosaicIdVector = SecretLockTransactionBuffer.createMosaicIdVector(builder, this.mosaicId); + const mosaicAmountVector = SecretLockTransactionBuffer.createMosaicAmountVector(builder, this.mosaicAmount); + const durationVector = SecretLockTransactionBuffer.createDurationVector(builder, this.duration); + const byteSecret = convert.hexToUint8(64 > this.secret.length ? this.secret + '0'.repeat(64 - this.secret.length) : this.secret); + const secretVector = SecretLockTransactionBuffer.createSecretVector(builder, byteSecret); + const recipientVector = SecretLockTransactionBuffer.createRecipientVector(builder, this.recipient); + + SecretLockTransactionBuffer.startSecretLockTransactionBuffer(builder); + SecretLockTransactionBuffer.addSize(builder, 202); + SecretLockTransactionBuffer.addSignature(builder, signatureVector); + SecretLockTransactionBuffer.addSigner(builder, signerVector); + SecretLockTransactionBuffer.addVersion(builder, this.version); + SecretLockTransactionBuffer.addType(builder, this.type); + SecretLockTransactionBuffer.addFee(builder, feeVector); + SecretLockTransactionBuffer.addDeadline(builder, deadlineVector); + SecretLockTransactionBuffer.addMosaicId(builder, mosaicIdVector); + SecretLockTransactionBuffer.addMosaicAmount(builder, mosaicAmountVector); + SecretLockTransactionBuffer.addDuration(builder, durationVector); + SecretLockTransactionBuffer.addHashAlgorithm(builder, this.hashAlgorithm); + SecretLockTransactionBuffer.addSecret(builder, secretVector); + SecretLockTransactionBuffer.addRecipient(builder, recipientVector); + + const codedSecretLock = SecretLockTransactionBuffer.endSecretLockTransactionBuffer(builder); + builder.finish(codedSecretLock); + + const bytes = builder.asUint8Array(); + return new SecretLockTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/SecretProofTransaction.ts b/src/infrastructure/builders/SecretProofTransaction.ts new file mode 100644 index 0000000000..78869e7863 --- /dev/null +++ b/src/infrastructure/builders/SecretProofTransaction.ts @@ -0,0 +1,129 @@ +/* + * Copyright 2019 NEM + * + * 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/SecretProofTransaction + */ +import { Convert as convert, RawAddress as address } from '../../core/format'; +import * as SecretProofTransactionBufferPackage from '../buffers/SecretProofTransactionBuffer'; +import SecretProofTransactionSchema from '../schemas/SecretProofTransactionSchema'; +import { VerifiableTransaction } from './VerifiableTransaction'; + +const { + flatbuffers, +} = require('flatbuffers'); + +const { + SecretProofTransactionBuffer, +} = SecretProofTransactionBufferPackage.default.Buffers; + +export default class SecretProofTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, SecretProofTransactionSchema); + } +} + +// tslint:disable-next-line:max-classes-per-file +export class Builder { + fee: any; + version: any; + type: any; + deadline: any; + hashAlgorithm: any; + secret: any; + recipient: any; + proof: any; + constructor() { + this.fee = [0, 0]; + this.version = 36865; + this.type = 0x434C; + } + + addFee(fee) { + this.fee = fee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addHashAlgorithm(hashAlgorithm) { + this.hashAlgorithm = hashAlgorithm; + return this; + } + + addSecret(secret) { + this.secret = secret; + return this; + } + addRecipient(recipient) { + this.recipient = address.stringToAddress(recipient); + return this; + } + + addProof(proof) { + this.proof = proof; + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + + // Create vectors + const signatureVector = SecretProofTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = SecretProofTransactionBuffer.createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = SecretProofTransactionBuffer.createDeadlineVector(builder, this.deadline); + const feeVector = SecretProofTransactionBuffer.createFeeVector(builder, this.fee); + const byteSecret = convert.hexToUint8(64 > this.secret.length ? this.secret + '0'.repeat(64 - this.secret.length) : this.secret); + const secretVector = SecretProofTransactionBuffer.createSecretVector(builder, byteSecret); + const recipientVector = SecretProofTransactionBuffer.createRecipientVector(builder, this.recipient); + const byteProof = convert.hexToUint8(this.proof); + const proofVector = SecretProofTransactionBuffer.createProofVector(builder, byteProof); + + SecretProofTransactionBuffer.startSecretProofTransactionBuffer(builder); + SecretProofTransactionBuffer.addSize(builder, 180 + byteProof.length); + SecretProofTransactionBuffer.addSignature(builder, signatureVector); + SecretProofTransactionBuffer.addSigner(builder, signerVector); + SecretProofTransactionBuffer.addVersion(builder, this.version); + SecretProofTransactionBuffer.addType(builder, this.type); + SecretProofTransactionBuffer.addFee(builder, feeVector); + SecretProofTransactionBuffer.addDeadline(builder, deadlineVector); + SecretProofTransactionBuffer.addHashAlgorithm(builder, this.hashAlgorithm); + SecretProofTransactionBuffer.addSecret(builder, secretVector); + SecretProofTransactionBuffer.addRecipient(builder, recipientVector); + SecretProofTransactionBuffer.addProofSize(builder, byteProof.length); + SecretProofTransactionBuffer.addProof(builder, proofVector); + + const codedSecretProof = SecretProofTransactionBuffer.endSecretProofTransactionBuffer(builder); + builder.finish(codedSecretProof); + + const bytes = builder.asUint8Array(); + return new SecretProofTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/TransferTransaction.ts b/src/infrastructure/builders/TransferTransaction.ts new file mode 100644 index 0000000000..6fbf445f85 --- /dev/null +++ b/src/infrastructure/builders/TransferTransaction.ts @@ -0,0 +1,154 @@ +/* + * Copyright 2019 NEM + * + * 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/TransferTransaction + */ +import { Convert as convert, RawAddress as address} from '../../core/format'; +import * as TransferTransactionBufferPackage from '../../infrastructure/buffers/TransferTransactionBuffer'; +import { VerifiableTransaction } from '../../infrastructure/builders/VerifiableTransaction'; +import TransferTransactionSchema from '../../infrastructure/schemas/TransferTransactionSchema'; + +const { + flatbuffers, +} = require('flatbuffers'); + +const { + TransferTransactionBuffer, + MessageBuffer, + MosaicBuffer, +} = TransferTransactionBufferPackage.default.Buffers; + +export default class TransferTransaction extends VerifiableTransaction { + constructor(bytes) { + super(bytes, TransferTransactionSchema); + } +} + +// tslint:disable-next-line:max-classes-per-file +export class Builder { + fee: any; + version: any; + type: any; + deadline: any; + recipient: any; + message: any; + mosaics: any; + constructor() { + this.fee = [0, 0]; + this.version = 36867; + this.type = 0x4154; + } + + addFee(fee) { + this.fee = fee; + return this; + } + + addVersion(version) { + this.version = version; + return this; + } + + addType(type) { + this.type = type; + return this; + } + + addDeadline(deadline) { + this.deadline = deadline; + return this; + } + + addRecipient(recipient) { + if (/^[0-9a-fA-F]{16}$/.test(recipient)) { + // received hexadecimal notation of namespaceId (alias) + this.recipient = address.aliasToRecipient(convert.hexToUint8(recipient)); + } else { + // received recipient address + this.recipient = address.stringToAddress(recipient); + } + return this; + } + + addMessage(message) { + this.message = message; + return this; + } + + addMosaics(mosaics) { + this.mosaics = mosaics.sort((a, b) => { + if (Number(a.id[1]) > b.id[1]) { return 1; } else if (a.id[1] < b.id[1]) { return -1; } + return 0; + }); + return this; + } + + build() { + const builder = new flatbuffers.Builder(1); + // Constants + + // Create message + const bytePayload = convert.hexToUint8(convert.utf8ToHex(this.message.payload)); + const payload = MessageBuffer.createPayloadVector(builder, bytePayload); + MessageBuffer.startMessageBuffer(builder); + MessageBuffer.addType(builder, this.message.type); + MessageBuffer.addPayload(builder, payload); + const message = MessageBuffer.endMessageBuffer(builder); + + // Create mosaics + const mosaics: 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); + mosaics.push(MosaicBuffer.endMosaicBuffer(builder)); + }); + + // Create vectors + const signatureVector = TransferTransactionBuffer + .createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0)); + const signerVector = TransferTransactionBuffer.createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0)); + const deadlineVector = TransferTransactionBuffer.createDeadlineVector(builder, this.deadline); + const feeVector = TransferTransactionBuffer.createFeeVector(builder, this.fee); + const recipientVector = TransferTransactionBuffer.createRecipientVector(builder, this.recipient); + const mosaicsVector = TransferTransactionBuffer.createMosaicsVector(builder, mosaics); + + TransferTransactionBuffer.startTransferTransactionBuffer(builder); + TransferTransactionBuffer.addSize(builder, 149 + (16 * this.mosaics.length) + bytePayload.length); + TransferTransactionBuffer.addSignature(builder, signatureVector); + TransferTransactionBuffer.addSigner(builder, signerVector); + TransferTransactionBuffer.addVersion(builder, this.version); + TransferTransactionBuffer.addType(builder, this.type); + TransferTransactionBuffer.addFee(builder, feeVector); + TransferTransactionBuffer.addDeadline(builder, deadlineVector); + TransferTransactionBuffer.addRecipient(builder, recipientVector); + TransferTransactionBuffer.addNumMosaics(builder, this.mosaics.length); + TransferTransactionBuffer.addMessageSize(builder, bytePayload.length + 1); + TransferTransactionBuffer.addMessage(builder, message); + TransferTransactionBuffer.addMosaics(builder, mosaicsVector); + + // Calculate size + + const codedTransfer = TransferTransactionBuffer.endTransferTransactionBuffer(builder); + builder.finish(codedTransfer); + + const bytes = builder.asUint8Array(); + return new TransferTransaction(bytes); + } +} diff --git a/src/infrastructure/builders/VerifiableTransaction.ts b/src/infrastructure/builders/VerifiableTransaction.ts new file mode 100644 index 0000000000..f27eb162bf --- /dev/null +++ b/src/infrastructure/builders/VerifiableTransaction.ts @@ -0,0 +1,126 @@ +/* + * Copyright 2019 NEM + * + * 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 { KeyPair } from '../../core/crypto'; +import { SHA3Hasher as sha3Hasher } from '../../core/crypto/SHA3Hasher'; +import { Convert as convert } from '../../core/format'; + +/** + * VerifiableTransaction + * @module transactions/VerifiableTransaction + * @version 1.0.0 + */ +export class VerifiableTransaction { + bytes: any; + schema: any; + /** + * @constructor + * @param {Uint8Array} bytes Uint8Array after flatbuffers.build.asUint8Array() + * @param {module:schema/Schema} schema Schema definition corresponding to flatbuffer Schema + */ + constructor(bytes, schema) { + this.bytes = bytes; + this.schema = schema; + } + + /** + * @param {string} transactionPayload HexString Payload + * @param {string} generationHash Network generation hash byte + * @returns {*|string} Returns Transaction Payload hash + */ + static createTransactionHash(transactionPayload, generationHash) { + const byteBuffer = Array.from(convert.hexToUint8(transactionPayload)); + const signingBytes = byteBuffer + .slice(4, 36) + .concat(byteBuffer + .slice(4 + 64, 4 + 64 + 32)) + .concat(generationHash) + .concat(byteBuffer + .splice(4 + 64 + 32, byteBuffer.length)); + + const hash = new Uint8Array(32); + + sha3Hasher.func(hash, signingBytes, 32); + + return convert.uint8ToHex(hash); + } + + /** + * @param {KeyPair } keyPair KeyPair instance + * @param {string} generationHash Network generation hash hex + * @returns {module:model/TransactionPayload} - Signed Transaction Payload + */ + signTransaction(keyPair, generationHash) { + const generationHashBytes = Array.from(convert.hexToUint8(generationHash)); + const byteBuffer = this.serialize(); + const signingBytes = generationHashBytes.concat(byteBuffer.slice(4 + 64 + 32)); + const keyPairEncoded = KeyPair.createKeyPairFromPrivateKeyString(keyPair.privateKey); + const signature = Array.from(KeyPair.sign(keyPair, new Uint8Array(signingBytes))); + const signedTransactionBuffer = byteBuffer + .splice(0, 4) + .concat(signature) + .concat(Array.from(keyPairEncoded.publicKey)) + .concat(byteBuffer + .splice(64 + 32, byteBuffer.length)); + const payload = convert.uint8ToHex(signedTransactionBuffer); + return { + payload, + hash: VerifiableTransaction.createTransactionHash(payload, generationHashBytes), + }; + } + + serialize() { + return this.schema.serialize(Array.from(this.bytes)); + } + + /** + * @returns {string} - Serialized Transaction Payload + */ + serializeUnsignedTransaction() { + return convert.uint8ToHex(this.serialize()); + } + + /** + * @param {KeyPair} keyPair KeyPair instance + * @returns {module:model/TransactionPayload} Returns TransactionPayload instance + */ + signCosignatoriesTransaction(keyPair) { + const signature = KeyPair.sign(keyPair, new Uint8Array(this.bytes)); + return { + parentHash: convert.uint8ToHex(this.bytes), + signature: convert.uint8ToHex(signature), + signer: keyPair.publicKey, + }; + } + + /** + * Converts the transaction into AggregateTransaction compatible + * @param {string} [_signer] Signer public key + * @returns {Array.<*>} AggregateTransaction bytes + */ + toAggregateTransaction(_signer) { + const signer = convert.hexToUint8(_signer); + let resultBytes = this.schema.serialize(Array.from(this.bytes)); + resultBytes.splice(0, 4 + 64 + 32); + resultBytes = Array.from(signer).concat(resultBytes); + resultBytes.splice(32 + 2 + 2, 16); + return Array.from((new Uint8Array([ + (resultBytes.length + 4 & 0x000000ff), + (resultBytes.length + 4 & 0x0000ff00) >> 8, + (resultBytes.length + 4 & 0x00ff0000) >> 16, + (resultBytes.length + 4 & 0xff000000) >> 24, + ]))).concat(resultBytes); + } +} diff --git a/src/infrastructure/builders/VerificableTransactionBuilder.ts b/src/infrastructure/builders/VerificableTransactionBuilder.ts new file mode 100644 index 0000000000..a63c9cb9ab --- /dev/null +++ b/src/infrastructure/builders/VerificableTransactionBuilder.ts @@ -0,0 +1,65 @@ +/* + * Copyright 2019 NEM + * + * 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 { + VerifiableTransaction +} from './VerifiableTransaction'; + +const { + flatbuffers +} = require('flatbuffers'); + +/** + * @module transactions/VerifiableTransactionBuilder + */ + +/** + * @callback LambdaBuilder + * @param {flatbuffers.Builder} builder + * @return {void} + */ + +export default class VerifiableTransactionBuilder { + bytes: any; + schema: any + /** + * @param {LambdaBuilder} lambda Callback + * @returns {VerifiableTransactionBuilder} Returns self instance + */ + addTransaction(lambda) { + const builder = new flatbuffers.Builder(1); + + lambda(builder); + + this.bytes = builder.asUint8Array(); + return this; + } + + /** + * @param {module:schema/Schema} schema Schema corresponding with flatbuffers Schema used on addTransaction + * @returns {VerifiableTransactionBuilder} Returns self instance + */ + addSchema(schema) { + this.schema = schema; + return this; + } + + /** + * @returns {VerifiableTransaction} Returns VerifiableTransaction instance + */ + build() { + return new VerifiableTransaction(this.bytes, this.schema); + } +} diff --git a/src/infrastructure/infrastructure.ts b/src/infrastructure/infrastructure.ts index 8bf145af0b..93351a18b4 100644 --- a/src/infrastructure/infrastructure.ts +++ b/src/infrastructure/infrastructure.ts @@ -25,3 +25,4 @@ export * from './TransactionHttp'; export * from './Listener'; export * from './QueryParams'; export * from './NetworkHttp'; +export * from './transaction/NamespaceMosaicIdGenerator'; diff --git a/src/infrastructure/model/accountDTO.ts b/src/infrastructure/model/accountDTO.ts new file mode 100644 index 0000000000..a312272c82 --- /dev/null +++ b/src/infrastructure/model/accountDTO.ts @@ -0,0 +1,91 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { MosaicDTO } from './mosaicDTO'; + +export class AccountDTO { + /** + * The account unique address in hexadecimal. + */ + 'address': string; + 'addressHeight': Array; + /** + * The public key of an account can be used to verify signatures of the account. Only accounts that have already published a transaction have a public key assigned to the account. Otherwise, the field is null. + */ + 'publicKey': string; + 'publicKeyHeight': Array; + /** + * The list of mosaics the account owns. The amount is represented in absolute amount. Thus a balance of 123456789 for a mosaic with divisibility 6 (absolute) means the account owns 123.456789 instead. + */ + 'mosaics': Array; + 'importance': Array; + 'importanceHeight': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "address", + "baseName": "address", + "type": "string" + }, + { + "name": "addressHeight", + "baseName": "addressHeight", + "type": "Array" + }, + { + "name": "publicKey", + "baseName": "publicKey", + "type": "string" + }, + { + "name": "publicKeyHeight", + "baseName": "publicKeyHeight", + "type": "Array" + }, + { + "name": "mosaics", + "baseName": "mosaics", + "type": "Array" + }, + { + "name": "importance", + "baseName": "importance", + "type": "Array" + }, + { + "name": "importanceHeight", + "baseName": "importanceHeight", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return AccountDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/accountIds.ts b/src/infrastructure/model/accountIds.ts new file mode 100644 index 0000000000..2152a05918 --- /dev/null +++ b/src/infrastructure/model/accountIds.ts @@ -0,0 +1,57 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class AccountIds { + /** + * The array of public keys. + */ + 'publicKeys'?: Array; + /** + * The array of addresses. + */ + 'addresses'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "publicKeys", + "baseName": "publicKeys", + "type": "Array" + }, + { + "name": "addresses", + "baseName": "addresses", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return AccountIds.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/accountInfoDTO.ts b/src/infrastructure/model/accountInfoDTO.ts new file mode 100644 index 0000000000..b29f9fffa6 --- /dev/null +++ b/src/infrastructure/model/accountInfoDTO.ts @@ -0,0 +1,53 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { AccountDTO } from './accountDTO'; +import { AccountMetaDTO } from './accountMetaDTO'; + +export class AccountInfoDTO { + 'meta': AccountMetaDTO; + 'account': AccountDTO; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "meta", + "baseName": "meta", + "type": "AccountMetaDTO" + }, + { + "name": "account", + "baseName": "account", + "type": "AccountDTO" + } ]; + + static getAttributeTypeMap() { + return AccountInfoDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/accountMetaDTO.ts b/src/infrastructure/model/accountMetaDTO.ts new file mode 100644 index 0000000000..fd30c7da9a --- /dev/null +++ b/src/infrastructure/model/accountMetaDTO.ts @@ -0,0 +1,69 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class AccountMetaDTO { + 'height': Array; + 'hash': string; + 'merkleComponentHash': string; + 'index': number; + 'id': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "height", + "baseName": "height", + "type": "Array" + }, + { + "name": "hash", + "baseName": "hash", + "type": "string" + }, + { + "name": "merkleComponentHash", + "baseName": "merkleComponentHash", + "type": "string" + }, + { + "name": "index", + "baseName": "index", + "type": "number" + }, + { + "name": "id", + "baseName": "id", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return AccountMetaDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/accountNamesDTO.ts b/src/infrastructure/model/accountNamesDTO.ts new file mode 100644 index 0000000000..5a4bbf42a3 --- /dev/null +++ b/src/infrastructure/model/accountNamesDTO.ts @@ -0,0 +1,57 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class AccountNamesDTO { + /** + * The address of the account in base 32. + */ + 'address': string; + /** + * The mosaic linked namespace names. + */ + 'names': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "address", + "baseName": "address", + "type": "string" + }, + { + "name": "names", + "baseName": "names", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return AccountNamesDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/accountPropertiesDTO.ts b/src/infrastructure/model/accountPropertiesDTO.ts new file mode 100644 index 0000000000..27cd8a4dba --- /dev/null +++ b/src/infrastructure/model/accountPropertiesDTO.ts @@ -0,0 +1,55 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { AccountPropertyDTO } from './accountPropertyDTO'; + +export class AccountPropertiesDTO { + /** + * The address of the account in hexadecimal. + */ + 'address': string; + 'properties': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "address", + "baseName": "address", + "type": "string" + }, + { + "name": "properties", + "baseName": "properties", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return AccountPropertiesDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/accountPropertiesInfoDTO.ts b/src/infrastructure/model/accountPropertiesInfoDTO.ts new file mode 100644 index 0000000000..097a9c9649 --- /dev/null +++ b/src/infrastructure/model/accountPropertiesInfoDTO.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { AccountPropertiesDTO } from './accountPropertiesDTO'; + +export class AccountPropertiesInfoDTO { + 'accountProperties': AccountPropertiesDTO; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "accountProperties", + "baseName": "accountProperties", + "type": "AccountPropertiesDTO" + } ]; + + static getAttributeTypeMap() { + return AccountPropertiesInfoDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/accountPropertyDTO.ts b/src/infrastructure/model/accountPropertyDTO.ts new file mode 100644 index 0000000000..8b1cdef1a3 --- /dev/null +++ b/src/infrastructure/model/accountPropertyDTO.ts @@ -0,0 +1,55 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { AccountPropertyTypeEnum } from './accountPropertyTypeEnum'; + +export class AccountPropertyDTO { + 'propertyType': AccountPropertyTypeEnum; + /** + * The address, transaction type or mosaic id to filter. + */ + 'values': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "propertyType", + "baseName": "propertyType", + "type": "AccountPropertyTypeEnum" + }, + { + "name": "values", + "baseName": "values", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return AccountPropertyDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/accountPropertyTypeEnum.ts b/src/infrastructure/model/accountPropertyTypeEnum.ts new file mode 100644 index 0000000000..6195456edd --- /dev/null +++ b/src/infrastructure/model/accountPropertyTypeEnum.ts @@ -0,0 +1,43 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +/** +* The account properties type: * 0x01 (1 decimal) - The property type only allows receiving transactions from an address. * 0x02 (2 decimal) - The property type only allows receiving transactions containing a mosaic id. * 0x04 (4 decimal) - The property type only allows sending transactions with a given transaction type. * 0x05 (5 decimal) - Property type sentinel. * 0x81 (129 decimal) - The property type blocks receiving transactions from an address. * 0x82 (130 decimal) - The property type blocks receiving transactions containing a mosaic id. * 0x84 (132 decimal) - The property type blocks sending transactions with a given transaction type. +*/ +export class AccountPropertyTypeEnum { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return AccountPropertyTypeEnum.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/aliasDTO.ts b/src/infrastructure/model/aliasDTO.ts new file mode 100644 index 0000000000..c1d05bdeb7 --- /dev/null +++ b/src/infrastructure/model/aliasDTO.ts @@ -0,0 +1,61 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { AliasTypeEnum } from './aliasTypeEnum'; + +export class AliasDTO { + 'type': AliasTypeEnum; + 'mosaicId'?: Array; + /** + * The aliased address in hexadecimal. + */ + 'address'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "type", + "baseName": "type", + "type": "AliasTypeEnum" + }, + { + "name": "mosaicId", + "baseName": "mosaicId", + "type": "Array" + }, + { + "name": "address", + "baseName": "address", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return AliasDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/aliasTypeEnum.ts b/src/infrastructure/model/aliasTypeEnum.ts new file mode 100644 index 0000000000..c3eb306311 --- /dev/null +++ b/src/infrastructure/model/aliasTypeEnum.ts @@ -0,0 +1,43 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +/** +* The alias type: * 0 - No alias. * 1 - Mosaic id alias. * 2 - Addres alias. +*/ +export class AliasTypeEnum { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return AliasTypeEnum.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/announceTransactionInfoDTO.ts b/src/infrastructure/model/announceTransactionInfoDTO.ts new file mode 100644 index 0000000000..9a0bd590cc --- /dev/null +++ b/src/infrastructure/model/announceTransactionInfoDTO.ts @@ -0,0 +1,45 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class AnnounceTransactionInfoDTO { + 'message': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "message", + "baseName": "message", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return AnnounceTransactionInfoDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/blockDTO.ts b/src/infrastructure/model/blockDTO.ts new file mode 100644 index 0000000000..178c52f7a0 --- /dev/null +++ b/src/infrastructure/model/blockDTO.ts @@ -0,0 +1,147 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class BlockDTO { + /** + * The signature of the block. The signature was generated by the signer and can be used to validate tha the entity data was not modified by a node. + */ + 'signature': string; + /** + * The public key of the block harvester formatted as hexadecimal. + */ + 'signer': string; + /** + * The entity version. The higher byte represents the network identifier: * 0x68 (MAIN_NET) - Public main network. * 0x98 (TEST_NET) - Public test network. * 0x60 (MIJIN) - Private network. * 0x90 (MIJIN_TEST) - Private test network. + */ + 'version': number; + /** + * The block type: * 0x8043 (32835 decimal) - Nemesis block. * 0x8143 (33091 decimal) - Regular block. + */ + 'type': number; + 'height': Array; + 'timestamp': Array; + 'difficulty': Array; + /** + * The fee multiplier applied to transactions contained in block. + */ + 'feeMultiplier': number; + /** + * The hash of the previous block. + */ + 'previousBlockHash': string; + /** + * The transactions included in a block are hashed forming a merkle tree. The root of the tree summarizes them. + */ + 'blockTransactionsHash': string; + /** + * The collection of receipts are hashed into a merkle tree and linked to a block. The block header stores the root hash. + */ + 'blockReceiptsHash': string; + /** + * For each block, the state of the blockchain is stored in RocksDB, forming a patricia tree. The root of the tree summarizes the state of the blockchain for the given block. + */ + 'stateHash': string; + /** + * The public key of the optional beneficiary designated by harvester. + */ + 'beneficiary': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "signature", + "baseName": "signature", + "type": "string" + }, + { + "name": "signer", + "baseName": "signer", + "type": "string" + }, + { + "name": "version", + "baseName": "version", + "type": "number" + }, + { + "name": "type", + "baseName": "type", + "type": "number" + }, + { + "name": "height", + "baseName": "height", + "type": "Array" + }, + { + "name": "timestamp", + "baseName": "timestamp", + "type": "Array" + }, + { + "name": "difficulty", + "baseName": "difficulty", + "type": "Array" + }, + { + "name": "feeMultiplier", + "baseName": "feeMultiplier", + "type": "number" + }, + { + "name": "previousBlockHash", + "baseName": "previousBlockHash", + "type": "string" + }, + { + "name": "blockTransactionsHash", + "baseName": "blockTransactionsHash", + "type": "string" + }, + { + "name": "blockReceiptsHash", + "baseName": "blockReceiptsHash", + "type": "string" + }, + { + "name": "stateHash", + "baseName": "stateHash", + "type": "string" + }, + { + "name": "beneficiary", + "baseName": "beneficiary", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return BlockDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/blockInfoDTO.ts b/src/infrastructure/model/blockInfoDTO.ts new file mode 100644 index 0000000000..8472c92e20 --- /dev/null +++ b/src/infrastructure/model/blockInfoDTO.ts @@ -0,0 +1,53 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { BlockDTO } from './blockDTO'; +import { BlockMetaDTO } from './blockMetaDTO'; + +export class BlockInfoDTO { + 'meta': BlockMetaDTO; + 'block': BlockDTO; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "meta", + "baseName": "meta", + "type": "BlockMetaDTO" + }, + { + "name": "block", + "baseName": "block", + "type": "BlockDTO" + } ]; + + static getAttributeTypeMap() { + return BlockInfoDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/blockMetaDTO.ts b/src/infrastructure/model/blockMetaDTO.ts new file mode 100644 index 0000000000..42cf4d7f93 --- /dev/null +++ b/src/infrastructure/model/blockMetaDTO.ts @@ -0,0 +1,75 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class BlockMetaDTO { + 'hash': string; + 'generationHash': string; + 'subCacheMerkleRoots': Array; + 'totalFee': Array; + 'numTransactions': number; + 'numStatements'?: number; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "hash", + "baseName": "hash", + "type": "string" + }, + { + "name": "generationHash", + "baseName": "generationHash", + "type": "string" + }, + { + "name": "subCacheMerkleRoots", + "baseName": "subCacheMerkleRoots", + "type": "Array" + }, + { + "name": "totalFee", + "baseName": "totalFee", + "type": "Array" + }, + { + "name": "numTransactions", + "baseName": "numTransactions", + "type": "number" + }, + { + "name": "numStatements", + "baseName": "numStatements", + "type": "number" + } ]; + + static getAttributeTypeMap() { + return BlockMetaDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/blockchainScoreDTO.ts b/src/infrastructure/model/blockchainScoreDTO.ts new file mode 100644 index 0000000000..e878826403 --- /dev/null +++ b/src/infrastructure/model/blockchainScoreDTO.ts @@ -0,0 +1,51 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class BlockchainScoreDTO { + 'scoreHigh': Array; + 'scoreLow': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "scoreHigh", + "baseName": "scoreHigh", + "type": "Array" + }, + { + "name": "scoreLow", + "baseName": "scoreLow", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return BlockchainScoreDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/communicationTimestamps.ts b/src/infrastructure/model/communicationTimestamps.ts new file mode 100644 index 0000000000..aac9258c6e --- /dev/null +++ b/src/infrastructure/model/communicationTimestamps.ts @@ -0,0 +1,51 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class CommunicationTimestamps { + 'sendTimestamp'?: Array; + 'receiveTimestamp'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "sendTimestamp", + "baseName": "sendTimestamp", + "type": "Array" + }, + { + "name": "receiveTimestamp", + "baseName": "receiveTimestamp", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return CommunicationTimestamps.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/cosignature.ts b/src/infrastructure/model/cosignature.ts new file mode 100644 index 0000000000..c3f5fea38f --- /dev/null +++ b/src/infrastructure/model/cosignature.ts @@ -0,0 +1,66 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class Cosignature { + /** + * The hash of parent aggregate transaction that has been signed by a cosignatory of the transaction. + */ + 'parentHash'?: string; + /** + * The signatures generated by signing the parent aggregate transaction hash. + */ + 'signature'?: string; + /** + * The signer of the transaction. + */ + 'signer'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "parentHash", + "baseName": "parentHash", + "type": "string" + }, + { + "name": "signature", + "baseName": "signature", + "type": "string" + }, + { + "name": "signer", + "baseName": "signer", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return Cosignature.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/heightInfoDTO.ts b/src/infrastructure/model/heightInfoDTO.ts new file mode 100644 index 0000000000..14276bc9a3 --- /dev/null +++ b/src/infrastructure/model/heightInfoDTO.ts @@ -0,0 +1,45 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class HeightInfoDTO { + 'height': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "height", + "baseName": "height", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return HeightInfoDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/merklePathItem.ts b/src/infrastructure/model/merklePathItem.ts new file mode 100644 index 0000000000..475550c6f5 --- /dev/null +++ b/src/infrastructure/model/merklePathItem.ts @@ -0,0 +1,51 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class MerklePathItem { + 'position'?: number; + 'hash'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "position", + "baseName": "position", + "type": "number" + }, + { + "name": "hash", + "baseName": "hash", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return MerklePathItem.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/merkleProofInfo.ts b/src/infrastructure/model/merkleProofInfo.ts new file mode 100644 index 0000000000..1b43545088 --- /dev/null +++ b/src/infrastructure/model/merkleProofInfo.ts @@ -0,0 +1,49 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { MerklePathItem } from './merklePathItem'; + +export class MerkleProofInfo { + /** + * The complementary data needed to calculate the merkle root. + */ + 'merklePath'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "merklePath", + "baseName": "merklePath", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return MerkleProofInfo.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/merkleProofInfoDTO.ts b/src/infrastructure/model/merkleProofInfoDTO.ts new file mode 100644 index 0000000000..d11326ff87 --- /dev/null +++ b/src/infrastructure/model/merkleProofInfoDTO.ts @@ -0,0 +1,52 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { MerkleProofInfo } from './merkleProofInfo'; + +export class MerkleProofInfoDTO { + 'payload': MerkleProofInfo; + 'type': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "payload", + "baseName": "payload", + "type": "MerkleProofInfo" + }, + { + "name": "type", + "baseName": "type", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return MerkleProofInfoDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/models.ts b/src/infrastructure/model/models.ts new file mode 100644 index 0000000000..d375ffac0b --- /dev/null +++ b/src/infrastructure/model/models.ts @@ -0,0 +1,387 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ +export * from './accountDTO'; +export * from './accountIds'; +export * from './accountInfoDTO'; +export * from './accountMetaDTO'; +export * from './accountNamesDTO'; +export * from './accountPropertiesDTO'; +export * from './accountPropertiesInfoDTO'; +export * from './accountPropertyDTO'; +export * from './accountPropertyTypeEnum'; +export * from './aliasDTO'; +export * from './aliasTypeEnum'; +export * from './announceTransactionInfoDTO'; +export * from './blockDTO'; +export * from './blockInfoDTO'; +export * from './blockMetaDTO'; +export * from './blockchainScoreDTO'; +export * from './communicationTimestamps'; +export * from './cosignature'; +export * from './heightInfoDTO'; +export * from './merklePathItem'; +export * from './merkleProofInfo'; +export * from './merkleProofInfoDTO'; +export * from './mosaicDTO'; +export * from './mosaicDefinitionDTO'; +export * from './mosaicIds'; +export * from './mosaicInfoDTO'; +export * from './mosaicMetaDTO'; +export * from './mosaicNamesDTO'; +export * from './mosaicPropertyDTO'; +export * from './mosaicPropertyIdEnum'; +export * from './multisigAccountGraphInfoDTO'; +export * from './multisigAccountInfoDTO'; +export * from './multisigDTO'; +export * from './multisigModificationTypeEnum'; +export * from './namespaceDTO'; +export * from './namespaceIds'; +export * from './namespaceInfoDTO'; +export * from './namespaceMetaDTO'; +export * from './namespaceNameDTO'; +export * from './namespaceTypeEnum'; +export * from './networkTypeDTO'; +export * from './nodeInfoDTO'; +export * from './nodeTimeDTO'; +export * from './receiptTypeEnum'; +export * from './resolutionEntryDTO'; +export * from './resolutionStatementDTO'; +export * from './rolesTypeEnum'; +export * from './serverDTO'; +export * from './serverInfoDTO'; +export * from './sourceDTO'; +export * from './statementsDTO'; +export * from './storageInfoDTO'; +export * from './transactionHashes'; +export * from './transactionIds'; +export * from './transactionInfoDTO'; +export * from './transactionMetaDTO'; +export * from './transactionPayload'; +export * from './transactionStatementDTO'; +export * from './transactionStatusDTO'; + +import localVarRequest = require('request'); + +import { AccountDTO } from './accountDTO'; +import { AccountIds } from './accountIds'; +import { AccountInfoDTO } from './accountInfoDTO'; +import { AccountMetaDTO } from './accountMetaDTO'; +import { AccountNamesDTO } from './accountNamesDTO'; +import { AccountPropertiesDTO } from './accountPropertiesDTO'; +import { AccountPropertiesInfoDTO } from './accountPropertiesInfoDTO'; +import { AccountPropertyDTO } from './accountPropertyDTO'; +import { AccountPropertyTypeEnum } from './accountPropertyTypeEnum'; +import { AliasDTO } from './aliasDTO'; +import { AliasTypeEnum } from './aliasTypeEnum'; +import { AnnounceTransactionInfoDTO } from './announceTransactionInfoDTO'; +import { BlockDTO } from './blockDTO'; +import { BlockInfoDTO } from './blockInfoDTO'; +import { BlockMetaDTO } from './blockMetaDTO'; +import { BlockchainScoreDTO } from './blockchainScoreDTO'; +import { CommunicationTimestamps } from './communicationTimestamps'; +import { Cosignature } from './cosignature'; +import { HeightInfoDTO } from './heightInfoDTO'; +import { MerklePathItem } from './merklePathItem'; +import { MerkleProofInfo } from './merkleProofInfo'; +import { MerkleProofInfoDTO } from './merkleProofInfoDTO'; +import { MosaicDTO } from './mosaicDTO'; +import { MosaicDefinitionDTO } from './mosaicDefinitionDTO'; +import { MosaicIds } from './mosaicIds'; +import { MosaicInfoDTO } from './mosaicInfoDTO'; +import { MosaicMetaDTO } from './mosaicMetaDTO'; +import { MosaicNamesDTO } from './mosaicNamesDTO'; +import { MosaicPropertyDTO } from './mosaicPropertyDTO'; +import { MosaicPropertyIdEnum } from './mosaicPropertyIdEnum'; +import { MultisigAccountGraphInfoDTO } from './multisigAccountGraphInfoDTO'; +import { MultisigAccountInfoDTO } from './multisigAccountInfoDTO'; +import { MultisigDTO } from './multisigDTO'; +import { MultisigModificationTypeEnum } from './multisigModificationTypeEnum'; +import { NamespaceDTO } from './namespaceDTO'; +import { NamespaceIds } from './namespaceIds'; +import { NamespaceInfoDTO } from './namespaceInfoDTO'; +import { NamespaceMetaDTO } from './namespaceMetaDTO'; +import { NamespaceNameDTO } from './namespaceNameDTO'; +import { NamespaceTypeEnum } from './namespaceTypeEnum'; +import { NetworkTypeDTO } from './networkTypeDTO'; +import { NodeInfoDTO } from './nodeInfoDTO'; +import { NodeTimeDTO } from './nodeTimeDTO'; +import { ReceiptTypeEnum } from './receiptTypeEnum'; +import { ResolutionEntryDTO } from './resolutionEntryDTO'; +import { ResolutionStatementDTO } from './resolutionStatementDTO'; +import { RolesTypeEnum } from './rolesTypeEnum'; +import { ServerDTO } from './serverDTO'; +import { ServerInfoDTO } from './serverInfoDTO'; +import { SourceDTO } from './sourceDTO'; +import { StatementsDTO } from './statementsDTO'; +import { StorageInfoDTO } from './storageInfoDTO'; +import { TransactionHashes } from './transactionHashes'; +import { TransactionIds } from './transactionIds'; +import { TransactionInfoDTO } from './transactionInfoDTO'; +import { TransactionMetaDTO } from './transactionMetaDTO'; +import { TransactionPayload } from './transactionPayload'; +import { TransactionStatementDTO } from './transactionStatementDTO'; +import { TransactionStatusDTO } from './transactionStatusDTO'; + +/* tslint:disable:no-unused-variable */ +let primitives = [ + "string", + "boolean", + "double", + "integer", + "long", + "float", + "number", + "any" + ]; + +let enumsMap: {[index: string]: any} = { + "AccountPropertyTypeEnum": AccountPropertyTypeEnum, + "AliasTypeEnum": AliasTypeEnum, + "ResolutionStatementDTO": ResolutionStatementDTO, + "MosaicPropertyIdEnum": MosaicPropertyIdEnum, + "MultisigModificationTypeEnum": MultisigModificationTypeEnum, + "NamespaceTypeEnum": NamespaceTypeEnum, + "ReceiptTypeEnum": ReceiptTypeEnum, + "RolesTypeEnum": RolesTypeEnum, +} + +let typeMap: {[index: string]: any} = { + "AccountDTO": AccountDTO, + "AccountIds": AccountIds, + "AccountInfoDTO": AccountInfoDTO, + "AccountMetaDTO": AccountMetaDTO, + "AccountNamesDTO": AccountNamesDTO, + "AccountPropertiesDTO": AccountPropertiesDTO, + "AccountPropertiesInfoDTO": AccountPropertiesInfoDTO, + "AccountPropertyDTO": AccountPropertyDTO, + "AliasDTO": AliasDTO, + "AnnounceTransactionInfoDTO": AnnounceTransactionInfoDTO, + "BlockDTO": BlockDTO, + "BlockInfoDTO": BlockInfoDTO, + "BlockMetaDTO": BlockMetaDTO, + "BlockchainScoreDTO": BlockchainScoreDTO, + "CommunicationTimestamps": CommunicationTimestamps, + "Cosignature": Cosignature, + "HeightInfoDTO": HeightInfoDTO, + "MerklePathItem": MerklePathItem, + "MerkleProofInfo": MerkleProofInfo, + "MerkleProofInfoDTO": MerkleProofInfoDTO, + "MosaicDTO": MosaicDTO, + "MosaicDefinitionDTO": MosaicDefinitionDTO, + "MosaicIds": MosaicIds, + "MosaicInfoDTO": MosaicInfoDTO, + "MosaicMetaDTO": MosaicMetaDTO, + "MosaicNamesDTO": MosaicNamesDTO, + "MosaicPropertyDTO": MosaicPropertyDTO, + "MultisigAccountGraphInfoDTO": MultisigAccountGraphInfoDTO, + "MultisigAccountInfoDTO": MultisigAccountInfoDTO, + "MultisigDTO": MultisigDTO, + "NamespaceDTO": NamespaceDTO, + "NamespaceIds": NamespaceIds, + "NamespaceInfoDTO": NamespaceInfoDTO, + "NamespaceMetaDTO": NamespaceMetaDTO, + "NamespaceNameDTO": NamespaceNameDTO, + "NetworkTypeDTO": NetworkTypeDTO, + "NodeInfoDTO": NodeInfoDTO, + "NodeTimeDTO": NodeTimeDTO, + "ResolutionEntryDTO": ResolutionEntryDTO, + "ServerDTO": ServerDTO, + "ServerInfoDTO": ServerInfoDTO, + "SourceDTO": SourceDTO, + "StatementsDTO": StatementsDTO, + "StorageInfoDTO": StorageInfoDTO, + "TransactionHashes": TransactionHashes, + "TransactionIds": TransactionIds, + "TransactionInfoDTO": TransactionInfoDTO, + "TransactionMetaDTO": TransactionMetaDTO, + "TransactionPayload": TransactionPayload, + "TransactionStatementDTO": TransactionStatementDTO, + "TransactionStatusDTO": TransactionStatusDTO, +} + +export class ObjectSerializer { + public static findCorrectType(data: any, expectedType: string) { + if (data == undefined) { + return expectedType; + } else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) { + return expectedType; + } else if (expectedType === "Date") { + return expectedType; + } else { + if (enumsMap[expectedType]) { + return expectedType; + } + + if (!typeMap[expectedType]) { + return expectedType; // w/e we don't know the type + } + + // Check the discriminator + let discriminatorProperty = typeMap[expectedType].discriminator; + if (discriminatorProperty == null) { + return expectedType; // the type does not have a discriminator. use it. + } else { + if (data[discriminatorProperty]) { + var discriminatorType = data[discriminatorProperty]; + if(typeMap[discriminatorType]){ + return discriminatorType; // use the type given in the discriminator + } else { + return expectedType; // discriminator did not map to a type + } + } else { + return expectedType; // discriminator was not present (or an empty string) + } + } + } + } + + public static serialize(data: any, type: string) { + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.serialize(date, subType)); + } + return transformedData; + } else if (type === "Date") { + return data.toISOString(); + } else { + if (enumsMap[type]) { + return data; + } + if (!typeMap[type]) { // in case we dont know the type + return data; + } + + // Get the actual type of this object + type = this.findCorrectType(data, type); + + // get the map for the correct type. + let attributeTypes = typeMap[type].getAttributeTypeMap(); + let instance: {[index: string]: any} = {}; + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type); + } + return instance; + } + } + + public static deserialize(data: any, type: string) { + // polymorphism may change the actual type. + type = ObjectSerializer.findCorrectType(data, type); + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.deserialize(date, subType)); + } + return transformedData; + } else if (type === "Date") { + return new Date(data); + } else { + if (enumsMap[type]) {// is Enum + return data; + } + + if (!typeMap[type]) { // dont know the type + return data; + } + let instance = new typeMap[type](); + let attributeTypes = typeMap[type].getAttributeTypeMap(); + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type); + } + return instance; + } + } +} + +export interface Authentication { + /** + * Apply authentication settings to header and query params. + */ + applyToRequest(requestOptions: localVarRequest.Options): void; +} + +export class HttpBasicAuth implements Authentication { + public username: string = ''; + public password: string = ''; + + applyToRequest(requestOptions: localVarRequest.Options): void { + requestOptions.auth = { + username: this.username, password: this.password + } + } +} + +export class ApiKeyAuth implements Authentication { + public apiKey: string = ''; + + constructor(private location: string, private paramName: string) { + } + + applyToRequest(requestOptions: localVarRequest.Options): void { + if (this.location == "query") { + (requestOptions.qs)[this.paramName] = this.apiKey; + } else if (this.location == "header" && requestOptions && requestOptions.headers) { + requestOptions.headers[this.paramName] = this.apiKey; + } + } +} + +export class OAuth implements Authentication { + public accessToken: string = ''; + + applyToRequest(requestOptions: localVarRequest.Options): void { + if (requestOptions && requestOptions.headers) { + requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; + } + } +} + +export class VoidAuth implements Authentication { + public username: string = ''; + public password: string = ''; + + applyToRequest(_: localVarRequest.Options): void { + // Do nothing + } +} \ No newline at end of file diff --git a/src/infrastructure/model/mosaicDTO.ts b/src/infrastructure/model/mosaicDTO.ts new file mode 100644 index 0000000000..6d378dd0e7 --- /dev/null +++ b/src/infrastructure/model/mosaicDTO.ts @@ -0,0 +1,51 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class MosaicDTO { + 'id': Array; + 'amount': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "Array" + }, + { + "name": "amount", + "baseName": "amount", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return MosaicDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/mosaicDefinitionDTO.ts b/src/infrastructure/model/mosaicDefinitionDTO.ts new file mode 100644 index 0000000000..852beca482 --- /dev/null +++ b/src/infrastructure/model/mosaicDefinitionDTO.ts @@ -0,0 +1,82 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { MosaicPropertyDTO } from './mosaicPropertyDTO'; + +export class MosaicDefinitionDTO { + 'mosaicId': Array; + 'supply': Array; + 'height': Array; + /** + * The public key of the mosaic owner. + */ + 'owner': string; + /** + * The number of definitions for the same mosaic. + */ + 'revision': number; + 'properties': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "mosaicId", + "baseName": "mosaicId", + "type": "Array" + }, + { + "name": "supply", + "baseName": "supply", + "type": "Array" + }, + { + "name": "height", + "baseName": "height", + "type": "Array" + }, + { + "name": "owner", + "baseName": "owner", + "type": "string" + }, + { + "name": "revision", + "baseName": "revision", + "type": "number" + }, + { + "name": "properties", + "baseName": "properties", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return MosaicDefinitionDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/mosaicIds.ts b/src/infrastructure/model/mosaicIds.ts new file mode 100644 index 0000000000..1835e0f87c --- /dev/null +++ b/src/infrastructure/model/mosaicIds.ts @@ -0,0 +1,48 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class MosaicIds { + /** + * The array of mosaic identifiers. + */ + 'mosaicIds'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "mosaicIds", + "baseName": "mosaicIds", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return MosaicIds.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/mosaicInfoDTO.ts b/src/infrastructure/model/mosaicInfoDTO.ts new file mode 100644 index 0000000000..3c47234a50 --- /dev/null +++ b/src/infrastructure/model/mosaicInfoDTO.ts @@ -0,0 +1,53 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { MosaicDefinitionDTO } from './mosaicDefinitionDTO'; +import { MosaicMetaDTO } from './mosaicMetaDTO'; + +export class MosaicInfoDTO { + 'meta': MosaicMetaDTO; + 'mosaic': MosaicDefinitionDTO; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "meta", + "baseName": "meta", + "type": "MosaicMetaDTO" + }, + { + "name": "mosaic", + "baseName": "mosaic", + "type": "MosaicDefinitionDTO" + } ]; + + static getAttributeTypeMap() { + return MosaicInfoDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/mosaicMetaDTO.ts b/src/infrastructure/model/mosaicMetaDTO.ts new file mode 100644 index 0000000000..25725c93aa --- /dev/null +++ b/src/infrastructure/model/mosaicMetaDTO.ts @@ -0,0 +1,45 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class MosaicMetaDTO { + 'id': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return MosaicMetaDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/mosaicNamesDTO.ts b/src/infrastructure/model/mosaicNamesDTO.ts new file mode 100644 index 0000000000..b45f1934f9 --- /dev/null +++ b/src/infrastructure/model/mosaicNamesDTO.ts @@ -0,0 +1,54 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class MosaicNamesDTO { + 'mosaicId': Array; + /** + * The mosaic linked namespace names. + */ + 'names': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "mosaicId", + "baseName": "mosaicId", + "type": "Array" + }, + { + "name": "names", + "baseName": "names", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return MosaicNamesDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/mosaicPropertyDTO.ts b/src/infrastructure/model/mosaicPropertyDTO.ts new file mode 100644 index 0000000000..9f480d6fa0 --- /dev/null +++ b/src/infrastructure/model/mosaicPropertyDTO.ts @@ -0,0 +1,52 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { MosaicPropertyIdEnum } from './mosaicPropertyIdEnum'; + +export class MosaicPropertyDTO { + 'id'?: MosaicPropertyIdEnum; + 'value'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "MosaicPropertyIdEnum" + }, + { + "name": "value", + "baseName": "value", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return MosaicPropertyDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/mosaicPropertyIdEnum.ts b/src/infrastructure/model/mosaicPropertyIdEnum.ts new file mode 100644 index 0000000000..02542b4b78 --- /dev/null +++ b/src/infrastructure/model/mosaicPropertyIdEnum.ts @@ -0,0 +1,43 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +/** +* The mosaic propery id means: * 0 - MosaicFlags * 1 - Divisibility * 2 - Duration +*/ +export class MosaicPropertyIdEnum { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return MosaicPropertyIdEnum.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/multisigAccountGraphInfoDTO.ts b/src/infrastructure/model/multisigAccountGraphInfoDTO.ts new file mode 100644 index 0000000000..20a3e027ae --- /dev/null +++ b/src/infrastructure/model/multisigAccountGraphInfoDTO.ts @@ -0,0 +1,58 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { MultisigAccountInfoDTO } from './multisigAccountInfoDTO'; + +export class MultisigAccountGraphInfoDTO { + /** + * The level of the multisig account. + */ + 'level': number; + /** + * The array of multisig accounts for this level. + */ + 'multisigEntries': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "level", + "baseName": "level", + "type": "number" + }, + { + "name": "multisigEntries", + "baseName": "multisigEntries", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return MultisigAccountGraphInfoDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/multisigAccountInfoDTO.ts b/src/infrastructure/model/multisigAccountInfoDTO.ts new file mode 100644 index 0000000000..5cc02e4c4d --- /dev/null +++ b/src/infrastructure/model/multisigAccountInfoDTO.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { MultisigDTO } from './multisigDTO'; + +export class MultisigAccountInfoDTO { + 'multisig': MultisigDTO; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "multisig", + "baseName": "multisig", + "type": "MultisigDTO" + } ]; + + static getAttributeTypeMap() { + return MultisigAccountInfoDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/multisigDTO.ts b/src/infrastructure/model/multisigDTO.ts new file mode 100644 index 0000000000..3ad10b6d94 --- /dev/null +++ b/src/infrastructure/model/multisigDTO.ts @@ -0,0 +1,93 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class MultisigDTO { + /** + * The account public key. + */ + 'account': string; + /** + * The account address in hexadecimal. + */ + 'accountAddress'?: string; + /** + * The number of signatures needed to approve a transaction. + */ + 'minApproval': number; + /** + * The number of signatures needed to remove a cosignatory. + */ + 'minRemoval': number; + /** + * The array of public keys of the cosignatory accounts. + */ + 'cosignatories': Array; + /** + * The array of multisig accounts where the account is cosignatory. + */ + 'multisigAccounts': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "account", + "baseName": "account", + "type": "string" + }, + { + "name": "accountAddress", + "baseName": "accountAddress", + "type": "string" + }, + { + "name": "minApproval", + "baseName": "minApproval", + "type": "number" + }, + { + "name": "minRemoval", + "baseName": "minRemoval", + "type": "number" + }, + { + "name": "cosignatories", + "baseName": "cosignatories", + "type": "Array" + }, + { + "name": "multisigAccounts", + "baseName": "multisigAccounts", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return MultisigDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/multisigModificationTypeEnum.ts b/src/infrastructure/model/multisigModificationTypeEnum.ts new file mode 100644 index 0000000000..248b06a1ba --- /dev/null +++ b/src/infrastructure/model/multisigModificationTypeEnum.ts @@ -0,0 +1,43 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +/** +* The type of the modification: * 0 - Add cosignatory. * 1 - Remove cosignatory. +*/ +export class MultisigModificationTypeEnum { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return MultisigModificationTypeEnum.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/namespaceDTO.ts b/src/infrastructure/model/namespaceDTO.ts new file mode 100644 index 0000000000..6836a3564c --- /dev/null +++ b/src/infrastructure/model/namespaceDTO.ts @@ -0,0 +1,116 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { AliasDTO } from './aliasDTO'; +import { NamespaceTypeEnum } from './namespaceTypeEnum'; + +export class NamespaceDTO { + /** + * The public key of the owner of the namespace. + */ + 'owner': string; + /** + * The address of the owner of the namespace in hexadecimal. + */ + 'ownerAddress': string; + 'startHeight': Array; + 'endHeight': Array; + /** + * The level of the namespace. + */ + 'depth': number; + 'level0': Array; + 'level1'?: Array; + 'level2'?: Array; + 'type': NamespaceTypeEnum; + 'alias': AliasDTO; + 'parentId': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "owner", + "baseName": "owner", + "type": "string" + }, + { + "name": "ownerAddress", + "baseName": "ownerAddress", + "type": "string" + }, + { + "name": "startHeight", + "baseName": "startHeight", + "type": "Array" + }, + { + "name": "endHeight", + "baseName": "endHeight", + "type": "Array" + }, + { + "name": "depth", + "baseName": "depth", + "type": "number" + }, + { + "name": "level0", + "baseName": "level0", + "type": "Array" + }, + { + "name": "level1", + "baseName": "level1", + "type": "Array" + }, + { + "name": "level2", + "baseName": "level2", + "type": "Array" + }, + { + "name": "type", + "baseName": "type", + "type": "NamespaceTypeEnum" + }, + { + "name": "alias", + "baseName": "alias", + "type": "AliasDTO" + }, + { + "name": "parentId", + "baseName": "parentId", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return NamespaceDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/namespaceIds.ts b/src/infrastructure/model/namespaceIds.ts new file mode 100644 index 0000000000..684e8c89a9 --- /dev/null +++ b/src/infrastructure/model/namespaceIds.ts @@ -0,0 +1,48 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class NamespaceIds { + /** + * The array of namespace identifiers. + */ + 'namespaceIds'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "namespaceIds", + "baseName": "namespaceIds", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return NamespaceIds.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/namespaceInfoDTO.ts b/src/infrastructure/model/namespaceInfoDTO.ts new file mode 100644 index 0000000000..084ba6da75 --- /dev/null +++ b/src/infrastructure/model/namespaceInfoDTO.ts @@ -0,0 +1,53 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { NamespaceDTO } from './namespaceDTO'; +import { NamespaceMetaDTO } from './namespaceMetaDTO'; + +export class NamespaceInfoDTO { + 'meta': NamespaceMetaDTO; + 'namespace': NamespaceDTO; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "meta", + "baseName": "meta", + "type": "NamespaceMetaDTO" + }, + { + "name": "namespace", + "baseName": "namespace", + "type": "NamespaceDTO" + } ]; + + static getAttributeTypeMap() { + return NamespaceInfoDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/namespaceMetaDTO.ts b/src/infrastructure/model/namespaceMetaDTO.ts new file mode 100644 index 0000000000..13f3557d7f --- /dev/null +++ b/src/infrastructure/model/namespaceMetaDTO.ts @@ -0,0 +1,57 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class NamespaceMetaDTO { + 'id': string; + 'active': boolean; + 'index': number; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "string" + }, + { + "name": "active", + "baseName": "active", + "type": "boolean" + }, + { + "name": "index", + "baseName": "index", + "type": "number" + } ]; + + static getAttributeTypeMap() { + return NamespaceMetaDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/namespaceNameDTO.ts b/src/infrastructure/model/namespaceNameDTO.ts new file mode 100644 index 0000000000..9a8eef6567 --- /dev/null +++ b/src/infrastructure/model/namespaceNameDTO.ts @@ -0,0 +1,60 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class NamespaceNameDTO { + 'parentId'?: Array; + 'namespaceId': Array; + /** + * The name of the namespace. + */ + 'name': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "parentId", + "baseName": "parentId", + "type": "Array" + }, + { + "name": "namespaceId", + "baseName": "namespaceId", + "type": "Array" + }, + { + "name": "name", + "baseName": "name", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return NamespaceNameDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/namespaceTypeEnum.ts b/src/infrastructure/model/namespaceTypeEnum.ts new file mode 100644 index 0000000000..81ae70d2af --- /dev/null +++ b/src/infrastructure/model/namespaceTypeEnum.ts @@ -0,0 +1,43 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +/** +* The namespace type: * 0 - Root namespace. * 1 - Subnamespace. +*/ +export class NamespaceTypeEnum { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return NamespaceTypeEnum.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/networkTypeDTO.ts b/src/infrastructure/model/networkTypeDTO.ts new file mode 100644 index 0000000000..8994ce3c30 --- /dev/null +++ b/src/infrastructure/model/networkTypeDTO.ts @@ -0,0 +1,57 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class NetworkTypeDTO { + /** + * The name of the network. + */ + 'name': string; + /** + * A short text describing the network. + */ + 'description': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "name", + "baseName": "name", + "type": "string" + }, + { + "name": "description", + "baseName": "description", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return NetworkTypeDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/nodeInfoDTO.ts b/src/infrastructure/model/nodeInfoDTO.ts new file mode 100644 index 0000000000..c4786b709d --- /dev/null +++ b/src/infrastructure/model/nodeInfoDTO.ts @@ -0,0 +1,97 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { RolesTypeEnum } from './rolesTypeEnum'; + +export class NodeInfoDTO { + /** + * The public key used to identify the node. + */ + 'publicKey': string; + /** + * The port used for the communication. + */ + 'port': number; + 'networkIdentifier': number; + /** + * The version of the application. + */ + 'version': number; + 'roles': RolesTypeEnum; + /** + * The IP address of the endpoint. + */ + 'host': string; + /** + * The name of the node. + */ + '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": "RolesTypeEnum" + }, + { + "name": "host", + "baseName": "host", + "type": "string" + }, + { + "name": "friendlyName", + "baseName": "friendlyName", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return NodeInfoDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/nodeTimeDTO.ts b/src/infrastructure/model/nodeTimeDTO.ts new file mode 100644 index 0000000000..d1a61ad09d --- /dev/null +++ b/src/infrastructure/model/nodeTimeDTO.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { CommunicationTimestamps } from './communicationTimestamps'; + +export class NodeTimeDTO { + 'communicationTimestamps': CommunicationTimestamps; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "communicationTimestamps", + "baseName": "communicationTimestamps", + "type": "CommunicationTimestamps" + } ]; + + static getAttributeTypeMap() { + return NodeTimeDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/receiptTypeEnum.ts b/src/infrastructure/model/receiptTypeEnum.ts new file mode 100644 index 0000000000..3083c95477 --- /dev/null +++ b/src/infrastructure/model/receiptTypeEnum.ts @@ -0,0 +1,43 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +/** +* The type of the receipt: * 0x134D (4941 decimal) - Mosaic_Rental_Fee. * 0x124E (4686 decimal) - Namespace_Rental_Fee. * 0x2143 (8515 decimal) - Harvest_Fee. * 0x2248 (8776 decimal) - LockHash_Completed. * 0x2348 (9032 decimal) - LockHash_Expired. * 0x2252 (8786 decimal) - LockSecret_Completed. * 0x2352 (9042 decimal) - LockSecret_Expired. * 0x3148 (12616 decimal) - LockHash_Created. * 0x3152 (12626 decimal) - LockSecret_Created. * 0x414D (16717 decimal) - Mosaic_Expired. * 0x414E (16718 decimal) - Namespace_Expired. * 0x5143 (20803 decimal) - Inflation. * 0xE134 (57652 decimal) - Transaction_Group. * 0xF143 (61763 decimal) - Address_Alias_Resolution. * 0xF243 (62019 decimal) - Mosaic_Alias_Resolution. +*/ +export class ReceiptTypeEnum { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return ReceiptTypeEnum.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/resolutionEntryDTO.ts b/src/infrastructure/model/resolutionEntryDTO.ts new file mode 100644 index 0000000000..32569b9855 --- /dev/null +++ b/src/infrastructure/model/resolutionEntryDTO.ts @@ -0,0 +1,52 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { SourceDTO } from './sourceDTO'; + +export class ResolutionEntryDTO { + 'source': SourceDTO; + 'resolved': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "source", + "baseName": "source", + "type": "SourceDTO" + }, + { + "name": "resolved", + "baseName": "resolved", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return ResolutionEntryDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/resolutionStatementDTO.ts b/src/infrastructure/model/resolutionStatementDTO.ts new file mode 100644 index 0000000000..d7de883078 --- /dev/null +++ b/src/infrastructure/model/resolutionStatementDTO.ts @@ -0,0 +1,64 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { ResolutionEntryDTO } from './resolutionEntryDTO'; + +/** +* A resolution statement keeps the relation between a namespace alias used in a transaction and the real address or mosaicId. +*/ +export class ResolutionStatementDTO { + 'height': Array; + 'unresolved': Array; + /** + * The array of resolution entries linked to the unresolved namespaceId. It is an array instead of a single UInt64 field since within one block the resolution might change for different sources due to alias related transactions. + */ + 'resolutionEntries': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "height", + "baseName": "height", + "type": "Array" + }, + { + "name": "unresolved", + "baseName": "unresolved", + "type": "Array" + }, + { + "name": "resolutionEntries", + "baseName": "resolutionEntries", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return ResolutionStatementDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/rolesTypeEnum.ts b/src/infrastructure/model/rolesTypeEnum.ts new file mode 100644 index 0000000000..a0b91d7a13 --- /dev/null +++ b/src/infrastructure/model/rolesTypeEnum.ts @@ -0,0 +1,43 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +/** +* The role of the node: * 1 - A peer node. * 2 - An api node. +*/ +export class RolesTypeEnum { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return RolesTypeEnum.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/serverDTO.ts b/src/infrastructure/model/serverDTO.ts new file mode 100644 index 0000000000..0cb1e94b98 --- /dev/null +++ b/src/infrastructure/model/serverDTO.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { ServerInfoDTO } from './serverInfoDTO'; + +export class ServerDTO { + 'serverInfo': ServerInfoDTO; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "serverInfo", + "baseName": "serverInfo", + "type": "ServerInfoDTO" + } ]; + + static getAttributeTypeMap() { + return ServerDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/serverInfoDTO.ts b/src/infrastructure/model/serverInfoDTO.ts new file mode 100644 index 0000000000..9a1ce8b75f --- /dev/null +++ b/src/infrastructure/model/serverInfoDTO.ts @@ -0,0 +1,57 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class ServerInfoDTO { + /** + * The catapult-rest component version. + */ + 'restVersion': string; + /** + * The catapult-sdk component version. + */ + 'sdkVersion': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "restVersion", + "baseName": "restVersion", + "type": "string" + }, + { + "name": "sdkVersion", + "baseName": "sdkVersion", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return ServerInfoDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/sourceDTO.ts b/src/infrastructure/model/sourceDTO.ts new file mode 100644 index 0000000000..b88167f350 --- /dev/null +++ b/src/infrastructure/model/sourceDTO.ts @@ -0,0 +1,60 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +/** +* The transaction that triggered the receipt. +*/ +export class SourceDTO { + /** + * The transaction index within the block. + */ + 'primaryId': number; + /** + * The transaction index inside within the aggregate transaction. If the transaction is not an inner transaction, then the secondary id is set to 0. + */ + 'secondaryId': number; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "primaryId", + "baseName": "primaryId", + "type": "number" + }, + { + "name": "secondaryId", + "baseName": "secondaryId", + "type": "number" + } ]; + + static getAttributeTypeMap() { + return SourceDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/statementsDTO.ts b/src/infrastructure/model/statementsDTO.ts new file mode 100644 index 0000000000..a7f5016e89 --- /dev/null +++ b/src/infrastructure/model/statementsDTO.ts @@ -0,0 +1,71 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { ResolutionStatementDTO } from './resolutionStatementDTO'; +import { TransactionStatementDTO } from './transactionStatementDTO'; + +/** +* The collection of transaction statements and resolutions triggered for the block requested. +*/ +export class StatementsDTO { + /** + * The array of transaction statements for the block requested. + */ + 'transactionStatements': Array; + /** + * The array of address resolutions for the block requested. + */ + 'addressResolutionStatements': Array; + /** + * The array of mosaic resolutions for the block requested. + */ + 'mosaicResolutionStatements': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "transactionStatements", + "baseName": "transactionStatements", + "type": "Array" + }, + { + "name": "addressResolutionStatements", + "baseName": "addressResolutionStatements", + "type": "Array" + }, + { + "name": "mosaicResolutionStatements", + "baseName": "mosaicResolutionStatements", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return StatementsDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/storageInfoDTO.ts b/src/infrastructure/model/storageInfoDTO.ts new file mode 100644 index 0000000000..78c7bacd71 --- /dev/null +++ b/src/infrastructure/model/storageInfoDTO.ts @@ -0,0 +1,66 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class StorageInfoDTO { + /** + * The number of blocks stored. + */ + 'numBlocks': number; + /** + * The number of transactions stored. + */ + 'numTransactions': number; + /** + * The number of accounts created. + */ + 'numAccounts': number; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "numBlocks", + "baseName": "numBlocks", + "type": "number" + }, + { + "name": "numTransactions", + "baseName": "numTransactions", + "type": "number" + }, + { + "name": "numAccounts", + "baseName": "numAccounts", + "type": "number" + } ]; + + static getAttributeTypeMap() { + return StorageInfoDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/transactionHashes.ts b/src/infrastructure/model/transactionHashes.ts new file mode 100644 index 0000000000..00a2aaf043 --- /dev/null +++ b/src/infrastructure/model/transactionHashes.ts @@ -0,0 +1,48 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class TransactionHashes { + /** + * The array of transaction hashes. + */ + 'hashes'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "hashes", + "baseName": "hashes", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return TransactionHashes.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/transactionIds.ts b/src/infrastructure/model/transactionIds.ts new file mode 100644 index 0000000000..9f9c4c8ed0 --- /dev/null +++ b/src/infrastructure/model/transactionIds.ts @@ -0,0 +1,48 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class TransactionIds { + /** + * The array of transaction ids. + */ + 'transactionIds'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "transactionIds", + "baseName": "transactionIds", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return TransactionIds.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/transactionInfoDTO.ts b/src/infrastructure/model/transactionInfoDTO.ts new file mode 100644 index 0000000000..935036c58a --- /dev/null +++ b/src/infrastructure/model/transactionInfoDTO.ts @@ -0,0 +1,52 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { TransactionMetaDTO } from './transactionMetaDTO'; + +export class TransactionInfoDTO { + 'meta': TransactionMetaDTO; + 'transaction': object; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "meta", + "baseName": "meta", + "type": "TransactionMetaDTO" + }, + { + "name": "transaction", + "baseName": "transaction", + "type": "object" + } ]; + + static getAttributeTypeMap() { + return TransactionInfoDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/transactionMetaDTO.ts b/src/infrastructure/model/transactionMetaDTO.ts new file mode 100644 index 0000000000..d264c1c74c --- /dev/null +++ b/src/infrastructure/model/transactionMetaDTO.ts @@ -0,0 +1,69 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class TransactionMetaDTO { + 'height': Array; + 'hash': string; + 'merkleComponentHash': string; + 'index': number; + 'id': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "height", + "baseName": "height", + "type": "Array" + }, + { + "name": "hash", + "baseName": "hash", + "type": "string" + }, + { + "name": "merkleComponentHash", + "baseName": "merkleComponentHash", + "type": "string" + }, + { + "name": "index", + "baseName": "index", + "type": "number" + }, + { + "name": "id", + "baseName": "id", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return TransactionMetaDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/transactionPayload.ts b/src/infrastructure/model/transactionPayload.ts new file mode 100644 index 0000000000..dcd42913a6 --- /dev/null +++ b/src/infrastructure/model/transactionPayload.ts @@ -0,0 +1,48 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class TransactionPayload { + /** + * The transaction payload. + */ + 'payload'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "payload", + "baseName": "payload", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return TransactionPayload.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/transactionStatementDTO.ts b/src/infrastructure/model/transactionStatementDTO.ts new file mode 100644 index 0000000000..999e49a2e2 --- /dev/null +++ b/src/infrastructure/model/transactionStatementDTO.ts @@ -0,0 +1,64 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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 { SourceDTO } from './sourceDTO'; + +/** +* The collection of receipts related to a transaction. +*/ +export class TransactionStatementDTO { + 'height': Array; + 'source': SourceDTO; + /** + * The array of receipts. + */ + 'receipts': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "height", + "baseName": "height", + "type": "Array" + }, + { + "name": "source", + "baseName": "source", + "type": "SourceDTO" + }, + { + "name": "receipts", + "baseName": "receipts", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return TransactionStatementDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/model/transactionStatusDTO.ts b/src/infrastructure/model/transactionStatusDTO.ts new file mode 100644 index 0000000000..69d24befd9 --- /dev/null +++ b/src/infrastructure/model/transactionStatusDTO.ts @@ -0,0 +1,69 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * 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. + */ + + +export class TransactionStatusDTO { + 'group'?: string; + 'status': string; + 'hash'?: string; + 'deadline'?: Array; + 'height'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "group", + "baseName": "group", + "type": "string" + }, + { + "name": "status", + "baseName": "status", + "type": "string" + }, + { + "name": "hash", + "baseName": "hash", + "type": "string" + }, + { + "name": "deadline", + "baseName": "deadline", + "type": "Array" + }, + { + "name": "height", + "baseName": "height", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return TransactionStatusDTO.attributeTypeMap; + } +} + diff --git a/src/infrastructure/schemas/AccountLinkTransactionSchema.ts b/src/infrastructure/schemas/AccountLinkTransactionSchema.ts new file mode 100644 index 0000000000..5a0e3be1ba --- /dev/null +++ b/src/infrastructure/schemas/AccountLinkTransactionSchema.ts @@ -0,0 +1,44 @@ +/* + * Copyright 2019 NEM + * + * 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 { + array, + Schema, + TypeSize, + ubyte, + uint, + ushort +} from './Schema'; + +/** + * @module schema/AccountLinkTransaction + */ + +/** + * Account Link schema + * @const {module:schema/Schema} + */ +const schema = new Schema([ + uint('size'), + array('signature'), + array('signer'), + ushort('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + array('remoteAccountKey'), + ubyte('linkAction') +]); +export default schema; diff --git a/src/infrastructure/schemas/AccountPropertiesAddressModificationTransactionSchema.ts b/src/infrastructure/schemas/AccountPropertiesAddressModificationTransactionSchema.ts new file mode 100644 index 0000000000..288fb34f23 --- /dev/null +++ b/src/infrastructure/schemas/AccountPropertiesAddressModificationTransactionSchema.ts @@ -0,0 +1,48 @@ +/* + * Copyright 2019 NEM + * + * 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 { + array, + Schema, + TypeSize, + ubyte, + ushort, + tableArray, + uint +} from './Schema'; + +/** + * @module schema/AccountPropertiesAddressModificationTransactionSchema + */ + +/** + * Account properties address transaction schema + * @const {module:schema/Schema} + */ +export default new Schema([ + uint('size'), + array('signature'), + array('signer'), + ushort('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + ubyte('propertyType'), + ubyte('modificationCount'), + tableArray('modifications', [ + ubyte('modificationType'), + array('value', TypeSize.BYTE) + ]) +]); diff --git a/src/infrastructure/schemas/AccountPropertiesEntityTypeModificationTransactionSchema.ts b/src/infrastructure/schemas/AccountPropertiesEntityTypeModificationTransactionSchema.ts new file mode 100644 index 0000000000..5c2373b1cc --- /dev/null +++ b/src/infrastructure/schemas/AccountPropertiesEntityTypeModificationTransactionSchema.ts @@ -0,0 +1,48 @@ +/* + * Copyright 2019 NEM + * + * 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 { + array, + Schema, + TypeSize, + ubyte, + ushort, + tableArray, + uint +} from './Schema'; + +/** + * @module schema/AccountPropertiesEntityTypeModificationTransactionSchema + */ + +/** + * Account properties address transaction schema + * @const {module:schema/Schema} + */ +export default new Schema([ + uint('size'), + array('signature'), + array('signer'), + ushort('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + ubyte('propertyType'), + ubyte('modificationCount'), + tableArray('modifications', [ + ubyte('modificationType'), + ushort('value') + ]) +]); diff --git a/src/infrastructure/schemas/AccountPropertiesMosaicModificationTransactionSchema.ts b/src/infrastructure/schemas/AccountPropertiesMosaicModificationTransactionSchema.ts new file mode 100644 index 0000000000..ce323b9e8c --- /dev/null +++ b/src/infrastructure/schemas/AccountPropertiesMosaicModificationTransactionSchema.ts @@ -0,0 +1,48 @@ +/* + * Copyright 2019 NEM + * + * 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 { + array, + Schema, + TypeSize, + ubyte, + ushort, + tableArray, + uint +} from './Schema'; + +/** + * @module schema/AccountPropertiesMosaicModificationTransactionSchema + */ + +/** + * Account properties address transaction schema + * @const {module:schema/Schema} + */ +export default new Schema([ + uint('size'), + array('signature'), + array('signer'), + ushort('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + ubyte('propertyType'), + ubyte('modificationCount'), + tableArray('modifications', [ + ubyte('modificationType'), + array('value', TypeSize.INT) + ]) +]); diff --git a/src/infrastructure/schemas/AddressAliasTransactionSchema.ts b/src/infrastructure/schemas/AddressAliasTransactionSchema.ts new file mode 100644 index 0000000000..4a9ceb4d25 --- /dev/null +++ b/src/infrastructure/schemas/AddressAliasTransactionSchema.ts @@ -0,0 +1,44 @@ +/* + * Copyright 2019 NEM + * + * 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 { + array, + Schema, + TypeSize, + ubyte, + uint, + ushort +} from './Schema'; + +/** + * @module schema/AddressAliasTransactionSchema + */ + +/** + * Address alias transaction schema + * @const {module:schema/Schema} + */ +export default new Schema([ + uint('size'), + array('signature'), + array('signer'), + ushort('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + ubyte('actionType'), + array('namespaceId', TypeSize.INT), + array('address', TypeSize.BYTE) +]); diff --git a/src/infrastructure/schemas/AggregateTransactionSchema.ts b/src/infrastructure/schemas/AggregateTransactionSchema.ts new file mode 100644 index 0000000000..f27bc0e142 --- /dev/null +++ b/src/infrastructure/schemas/AggregateTransactionSchema.ts @@ -0,0 +1,44 @@ +/* + * Copyright 2019 NEM + * + * 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 { + array, + Schema, + TypeSize, + uint, + ushort +} from './Schema'; + +/** + * @module schema/AggregateTransactionSchema + */ + +/** + * Aggregate transaction schema + * @const {module:schema/Schema} + */ +const schema = new Schema([ + uint('size'), + array('signature'), + array('signer'), + ushort('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + uint('transactionsSize'), + array('transactions') +]); + +export default schema; diff --git a/src/infrastructure/schemas/HashLockTransactionSchema.ts b/src/infrastructure/schemas/HashLockTransactionSchema.ts new file mode 100644 index 0000000000..2efbf4ffaa --- /dev/null +++ b/src/infrastructure/schemas/HashLockTransactionSchema.ts @@ -0,0 +1,45 @@ +/* + * Copyright 2019 NEM + * + * 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 { + array, + Schema, + TypeSize, + uint, + ushort +} from './Schema'; + +/** + * @module schema/HashLockTransactionSchema + */ + +/** + * Hash lock transaction schema + * @const {module:schema/Schema} + */ +const schema = new Schema([ + uint('size'), + array('signature'), + array('signer'), + ushort('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + array('mosaicId', TypeSize.INT), + array('mosaicAmount', TypeSize.INT), + array('duration', TypeSize.INT), + array('hash') +]); +export default schema; diff --git a/src/infrastructure/schemas/MosaicAliasTransactionSchema.ts b/src/infrastructure/schemas/MosaicAliasTransactionSchema.ts new file mode 100644 index 0000000000..b8a69b4c3e --- /dev/null +++ b/src/infrastructure/schemas/MosaicAliasTransactionSchema.ts @@ -0,0 +1,44 @@ +/* + * Copyright 2019 NEM + * + * 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 { + array, + Schema, + TypeSize, + ubyte, + uint, + ushort +} from './Schema'; + +/** + * @module schema/MosaicAliasTransactionSchema + */ + +/** + * Mosaic alias transaction schema + * @const {module:schema/Schema} + */ +export default new Schema([ + uint('size'), + array('signature'), + array('signer'), + ushort('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + ubyte('actionType'), + array('namespaceId', TypeSize.INT), + array('mosaicId', TypeSize.INT) +]); diff --git a/src/infrastructure/schemas/MosaicCreationTransactionSchema.ts b/src/infrastructure/schemas/MosaicCreationTransactionSchema.ts new file mode 100644 index 0000000000..e9d947652a --- /dev/null +++ b/src/infrastructure/schemas/MosaicCreationTransactionSchema.ts @@ -0,0 +1,63 @@ +/* + * Copyright 2019 NEM + * + * 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 { + array, + Schema, + TypeSize, + ubyte, + uint, + ushort +} from './Schema'; + +/** + * @module schema/MosaicCreationTransactionSchema + */ + +/** + * Mosaic definition creation transaction schema + * @const {module:schema/Schema} + */ +export const schema = new Schema([ + uint('size'), + array('signature'), + array('signer'), + ushort('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + array('nonce', TypeSize.BYTE), + array('mosaicId', TypeSize.INT), + ubyte('numOptionalProperties'), + ubyte('flags'), + ubyte('divisibility'), + ubyte('indicateDuration'), + array('duration', TypeSize.INT) +]); + +export const schemaNoDuration = new Schema([ + uint('size'), + array('signature'), + array('signer'), + ushort('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + array('nonce', TypeSize.BYTE), + array('mosaicId', TypeSize.INT), + ubyte('numOptionalProperties'), + ubyte('flags'), + ubyte('divisibility') +]); diff --git a/src/infrastructure/schemas/MosaicSupplyChangeTransactionSchema.ts b/src/infrastructure/schemas/MosaicSupplyChangeTransactionSchema.ts new file mode 100644 index 0000000000..19df7503b8 --- /dev/null +++ b/src/infrastructure/schemas/MosaicSupplyChangeTransactionSchema.ts @@ -0,0 +1,44 @@ +/* + * Copyright 2019 NEM + * + * 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 { + array, + Schema, + TypeSize, + ubyte, + uint, + ushort +} from './Schema'; + +/** + * @module schema/MosaicSupplyChangeTransactionSchema + */ + +/** + * Mosaic supply change transaction schema + * @const {module:schema/Schema} + */ +export default new Schema([ + uint('size'), + array('signature'), + array('signer'), + ushort('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + array('mosaicId', TypeSize.INT), + ubyte('direction'), + array('delta', TypeSize.INT) +]); diff --git a/src/infrastructure/schemas/MultisigModificationTransactionSchema.ts b/src/infrastructure/schemas/MultisigModificationTransactionSchema.ts new file mode 100644 index 0000000000..91beb8efc6 --- /dev/null +++ b/src/infrastructure/schemas/MultisigModificationTransactionSchema.ts @@ -0,0 +1,49 @@ +/* + * Copyright 2019 NEM + * + * 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 { + array, + Schema, + tableArray, + TypeSize, + ubyte, + uint, + ushort +} from './Schema'; + +/** + * @module schema/MultigAggregateModificationTransactionSchema + */ + +/** + * Multisig aggregate modification transaction schema + * @const {module:schema/Schema} + */ +export default new Schema([ + uint('size'), + array('signature'), + array('signer'), + ushort('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + ubyte('minRemovalDelta'), + ubyte('minApprovalDelta'), + ubyte('numModifications'), + tableArray('modifications', [ + ubyte('type'), + array('cosignatoryPublicKey') + ]) +]); diff --git a/src/infrastructure/schemas/NamespaceCreationTransactionSchema.ts b/src/infrastructure/schemas/NamespaceCreationTransactionSchema.ts new file mode 100644 index 0000000000..7694dddc5e --- /dev/null +++ b/src/infrastructure/schemas/NamespaceCreationTransactionSchema.ts @@ -0,0 +1,47 @@ +/* + * Copyright 2019 NEM + * + * 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 { + array, + Schema, + string, + TypeSize, + ubyte, + uint, + ushort +} from './Schema'; + +/** + * @module schema/NamespaceCreationTransactionSchema + */ + +/** + * Provision namespace transaction schema + * @const {module:schema/Schema} + */ +export default new Schema([ + uint('size'), + array('signature'), + array('signer'), + ushort('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + ubyte('namespaceType'), + array('durationParentId', TypeSize.INT), + array('namespaceId', TypeSize.INT), + ubyte('namespaceNameSize'), + string('name') +]); diff --git a/src/infrastructure/schemas/Schema.ts b/src/infrastructure/schemas/Schema.ts new file mode 100644 index 0000000000..212378e39e --- /dev/null +++ b/src/infrastructure/schemas/Schema.ts @@ -0,0 +1,374 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ + +/* eslint-disable no-use-before-define */ + +/** + * In bytes + * @type {{BYTE: number, SHORT: number, INT: number}} + */ +export const TypeSize = { + BYTE: 1, + SHORT: 2, + INT: 4, +}; + +/** + * @param {string} name Attribute name + * @returns {ScalarAttribute} return ScalarAttribute Instance + */ +export const ubyte = (name) => { + return new ScalarAttribute(name, TypeSize.BYTE); +}; + +/** + * + * @param {string} name Attribute Name + * @returns {ScalarAttribute} ScalarAttribute Instance + */ +export const byte = (name) => { + return new ScalarAttribute(name, TypeSize.BYTE); +}; + +/** + * + * @param {string} name Attribute Name + * @returns {ScalarAttribute} ScalarAttribute Instance + */ +export const ushort = (name) => { + return new ScalarAttribute(name, TypeSize.SHORT); +}; + +/** + * + * @param {string} name Attribute Name + * @returns {ScalarAttribute} ScalarAttribute Instance + */ +export const short = (name) => { + return new ScalarAttribute(name, TypeSize.SHORT); +}; + +/** + * + * @param {string} name Attribute Name + * @returns {ScalarAttribute} ScalarAttribute Instance + */ +export const uint = (name) => { + return new ScalarAttribute(name, TypeSize.INT); +}; + +/** + * + * @param {string} name Attribute Name + * @returns {ScalarAttribute} ScalarAttribute Instance + */ +export const int = (name) => { + return new ScalarAttribute(name, TypeSize.INT); +}; + +/** + * + * @param {string} name Attribute Name + * @param {number} typeSize Attribute Byte Size + * @returns {ArrayAttribute} ArrayAttribute Instance + */ +export const array = (name, typeSize = TypeSize.BYTE) => { + return new ArrayAttribute(name, typeSize); +}; + +/** + * + * @param {string} name Attribute Name + * @returns {ArrayAttribute} ArrayAttribute Instance + */ +export const string = (name) => { + return array(name); +}; + +/** + * + * @param {string} name Attribute Name + * @param {module:schema/Schema} schema Table Specific Schema definition + * @returns {TableAttribute} TableAttribute Instance + */ +export const table = (name, schema) => { + return new TableAttribute(name, schema); +}; + +/** + * + * @param {string} name Attribute Name + * @param {module:schema/Schema} schema Schema Definition + * @returns {TableArrayAttribute} TableAttribute Instance + */ +export const tableArray = (name, schema) => { + return new TableArrayAttribute(name, schema); +}; + +/* eslint-disable */ +const readInt32 = (offset, bytes) => { + return bytes[offset] | bytes[offset + 1] << 8 | bytes[offset + 2] << 16 | bytes[offset + 3] << 24; +}; + +const readInt16 = (offset, bytes) => { + return bytes[offset] | bytes[offset + 1] << 8; +}; + +const __offset = (val0, fieldPos, bytes) => { + const vtable = val0 - readInt32(val0, bytes); + return fieldPos < readInt16(vtable, bytes) ? readInt16(vtable + fieldPos, bytes) : 0; +}; + +const __vector_length = (offset, bytes) => { + return readInt32(offset + readInt32(offset, bytes), bytes); +}; + +const __indirect = (offset, bytes) => { + return offset + readInt32(offset, bytes); +}; + +const __vector = (offset, bytes) => { + return offset + readInt32(offset, bytes) + 4; +}; + +const findVector = (val0, fieldPos, bytes, size) => { + const offset = __offset(val0, fieldPos, bytes); + const offsetLong = offset + val0; + const vecStart = __vector(offsetLong, bytes); + const vecLength = __vector_length(offsetLong, bytes) * (size ? size : 1); + return offset ? bytes.slice(vecStart, vecStart + vecLength) : 0; +}; + +const findParam = (val0, fieldPos, bytes, numBytes) => { + const offset = __offset(val0, fieldPos, bytes); + return offset ? bytes.slice(offset + val0, offset + val0 + numBytes) : 0; +}; + +const findObjectStartPosition = (val0, fieldPos, bytes) => { + const offset = __offset(val0, fieldPos, bytes); + return __indirect(offset + val0, bytes); +}; + +const findArrayLength = (val0, fieldPos, bytes) => { + const offset = __offset(val0, fieldPos, bytes); + return offset ? __vector_length(val0 + offset, bytes) : 0; +}; + +const findObjectArrayElementStartPosition = (val0, fieldPos, bytes, index) => { + const offset = __offset(val0, fieldPos, bytes); + const vector = __vector(val0 + offset, bytes); + return __indirect(vector + index * 4, bytes); +}; + +/** + * Schema + * @module schema/Schema + */ +export class Schema { + schemaDefinition; + /** + * @constructor + * @param {Array.} schemaDefinition Schema Definition + */ + constructor(schemaDefinition) { + this.schemaDefinition = schemaDefinition; + } + + /** + * + * @param {Uint8Array} bytes flatbuffers bytes + * @returns {Uint8Array} catapult buffer + */ + serialize(bytes) { + let i = 0; + let resultBytes = []; + while (i < this.schemaDefinition.length) { + resultBytes = resultBytes.concat(this.schemaDefinition[i].serialize(bytes, 4 + (i * 2))); + i++; + } + return resultBytes; + } + + /** + * @param {Uint8Array} bytes flatbuffer bytes + * @returns {Array} Array with field name + payload + */ + debugSerialize(bytes) { + let i = 0; + let result: any = []; + while (i < this.schemaDefinition.length) { + result = result.concat({ + name: this.schemaDefinition[i].name, + bytes: this.schemaDefinition[i].debugSerialize(bytes, 4 + i * 2), + }); + i++; + } + return result; + } +} + +// tslint:disable-next-line:max-classes-per-file +export class Attribute { + name: any; + /** + * @constructor + * @param {string} name schema attribute name + */ + constructor(name) { + this.name = name; + } + + /** + * + * @param {Uint8Array} buffer flatbuffer bytes + * @param {number} position attribute possition in flatbuffer bytes + * @param {number} val0 position in case that it is an inner object + */ + serialize(buffer, position, val0 = undefined) { + throw new Error('Unimplemented method'); + } + + /** + * @suppress warnings + * @param {Uint8Array} buffer buffer flatbuffer bytes + * @param {number} position attribute possition in flatbuffer bytes + * @param {number} val0 position in case that it is an inner object + */ + debugSerialize(buffer, position, val0 = undefined) { + throw new Error('Unimplemented method'); + } +} + +// tslint:disable-next-line:max-classes-per-file +export class ScalarAttribute extends Attribute { + typeSize: any; + name: any; + /** + * @constructor + * @param {string} name schema attribute name + * @param {number} typeSize + */ + constructor(name, typeSize) { + super(name); + this.typeSize = typeSize; + } + + serialize(buffer, position, val0 = undefined) { + return findParam(val0 ? val0 : buffer[0], position, buffer, this.typeSize); + } + + debugSerialize(buffer, position, val0 = undefined) { + return { + name: this.name, + bytes: this.serialize(buffer, position, val0), + }; + } +} + +// tslint:disable-next-line:max-classes-per-file +export class ArrayAttribute extends Attribute { + typeSize: any; + name: any; + /** + * @constructor + * @param name - {string} + * @param typeSize - {TypeSize} + */ + constructor(name, typeSize) { + super(name); + this.typeSize = typeSize; + } + + serialize(buffer, position, val0 = undefined) { + return findVector(val0 ? val0 : buffer[0], position, buffer, this.typeSize); + } + + debugSerialize(buffer, position, val0 = undefined) { + return { + name: this.name, + bytes: this.serialize(buffer, position, val0), + }; + } +} + +// tslint:disable-next-line:max-classes-per-file +export class TableAttribute extends Attribute { + schema: any; + name: any; + /** + * + * @param {string} name + * @param {module:schema/Schema} schema + */ + constructor(name, schema) { + super(name); + this.schema = schema; + } + + serialize(bytes, position, val0 = undefined) { + let result = []; + const messageStartPosition = findObjectStartPosition(val0 ? val0 : bytes[0], position, bytes); + let i = 0; + while (i < this.schema.length) { + result = result.concat(this.schema[i].serialize(bytes, 4 + i * 2, messageStartPosition)); + i++; + } + return result; + } + + debugSerialize(buffer, position, val0 = undefined) { + return { + name: this.name, + bytes: this.serialize(buffer, position, val0), + }; + } +} + +// tslint:disable-next-line:max-classes-per-file +export class TableArrayAttribute extends Attribute { + schema: any; + name: any; + /** + * @constructor + * @param {string} name + * @param {module:schema/Schema} schema + */ + constructor(name, schema) { + super(name); + this.schema = schema; + } + + serialize(bytes, position, val0 = undefined) { + let result = []; + const arrayLength = findArrayLength(val0 ? val0 : bytes[0], position, bytes); + let i = 0; + while (i < arrayLength) { + const startArrayPosition = findObjectArrayElementStartPosition(val0 ? val0 : bytes[0], position, bytes, i); + for (let j = 0; j < this.schema.length; ++j) { + result = result.concat(this.schema[j].serialize(bytes, 4 + j * 2, startArrayPosition)); + } + i++; + } + return result; + } + + debugSerialize(buffer, position, val0 = undefined) { + return { + name: this.name, + bytes: this.serialize(buffer, position, val0), + }; + } +} diff --git a/src/infrastructure/schemas/SecretLockTransactionSchema.ts b/src/infrastructure/schemas/SecretLockTransactionSchema.ts new file mode 100644 index 0000000000..046f02c178 --- /dev/null +++ b/src/infrastructure/schemas/SecretLockTransactionSchema.ts @@ -0,0 +1,48 @@ +/* + * Copyright 2019 NEM + * + * 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 { + array, + Schema, + TypeSize, + ubyte, + uint, + ushort +} from './Schema'; + +/** + * @module schema/SecretLockTransactionSchema + */ + +/** + * Secret lock transaction schema + * @const {module:schema/Schema} + */ +const schema = new Schema([ + uint('size'), + array('signature'), + array('signer'), + ushort('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + array('mosaicId', TypeSize.INT), + array('mosaicAmount', TypeSize.INT), + array('duration', TypeSize.INT), + ubyte('hashAlgorithm'), + array('secret'), + array('recipient') +]); +export default schema; diff --git a/src/infrastructure/schemas/SecretProofTransactionSchema.ts b/src/infrastructure/schemas/SecretProofTransactionSchema.ts new file mode 100644 index 0000000000..db03f6eaf4 --- /dev/null +++ b/src/infrastructure/schemas/SecretProofTransactionSchema.ts @@ -0,0 +1,47 @@ +/* + * Copyright 2019 NEM + * + * 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 { + array, + Schema, + TypeSize, + ubyte, + uint, + ushort +} from './Schema'; + +/** + * @module schema/SecretProofTransactionSchema + */ + +/** + * Secret proof transaction schema + * @const {module:schema/Schema} + */ +const schema = new Schema([ + uint('size'), + array('signature'), + array('signer'), + ushort('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + ubyte('hashAlgorithm'), + array('secret'), + array('recipient'), + ushort('proofSize'), + array('proof') +]); +export default schema; diff --git a/src/infrastructure/schemas/TransferTransactionSchema.ts b/src/infrastructure/schemas/TransferTransactionSchema.ts new file mode 100644 index 0000000000..eb8efdfd4e --- /dev/null +++ b/src/infrastructure/schemas/TransferTransactionSchema.ts @@ -0,0 +1,55 @@ +/* + * Copyright 2019 NEM + * + * 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 { + array, + Schema, + table, + tableArray, + TypeSize, + ubyte, + uint, + ushort +} from './Schema'; + +/** + * @module schema/TransferTransactionSchema + */ + +/** + * Transfer transaction schema + * @const {module:schema/Schema} + */ +const schema = new Schema([ + uint('size'), + array('signature'), + array('signer'), + ushort('version'), + ushort('type'), + array('fee', TypeSize.INT), + array('deadline', TypeSize.INT), + array('recipient'), + ushort('messageSize'), + ubyte('numMosaics'), + table('message', [ + ubyte('type'), + array('payload') + ]), + tableArray('mosaics', [ + array('id', TypeSize.INT), + array('amount', TypeSize.INT) + ]) +]); +export default schema; diff --git a/src/infrastructure/templates/api-all.mustache b/src/infrastructure/templates/api-all.mustache new file mode 100755 index 0000000000..bf79c0fe05 --- /dev/null +++ b/src/infrastructure/templates/api-all.mustache @@ -0,0 +1,13 @@ +{{>licenseInfo}} +{{#apiInfo}} +{{#apis}} +{{#operations}} +export * from './{{ classFilename }}'; +import { {{ classname }} } from './{{ classFilename }}'; +{{/operations}} +{{#withInterfaces}} +export * from './{{ classFilename }}Interface' +{{/withInterfaces}} +{{/apis}} +export const APIS = [{{#apis}}{{#operations}}{{ classname }}{{/operations}}{{^-last}}, {{/-last}}{{/apis}}]; +{{/apiInfo}} diff --git a/src/infrastructure/templates/api-single.mustache b/src/infrastructure/templates/api-single.mustache new file mode 100755 index 0000000000..c90274237c --- /dev/null +++ b/src/infrastructure/templates/api-single.mustache @@ -0,0 +1,235 @@ +{{>licenseInfo}} +import localVarRequest = require('request'); +import http = require('http'); + +/* tslint:disable:no-unused-locals */ +{{#imports}} +import { {{classname}} } from '../{{filename}}'; +{{/imports}} + +import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; +{{#hasAuthMethods}} +{{#authMethods}} +{{#isBasic}} +import { HttpBasicAuth } from '../model/models'; +{{/isBasic}} +{{#isApiKey}} +import { ApiKeyAuth } from '../model/models'; +{{/isApiKey}} +{{#isOAuth}} +import { OAuth } from '../model/models'; +{{/isOAuth}} +{{/authMethods}} +{{/hasAuthMethods}} + +let defaultBasePath = '{{{basePath}}}'; + +// =============================================== +// This file is autogenerated - Please do not edit +// =============================================== + +{{#operations}} +{{#description}} +/** +* {{&description}} +*/ +{{/description}} +export enum {{classname}}ApiKeys { +{{#authMethods}} +{{#isApiKey}} + {{name}}, +{{/isApiKey}} +{{/authMethods}} +} + +export class {{classname}} { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), +{{#hasAuthMethods}} +{{#authMethods}} +{{#isBasic}} + '{{name}}': new HttpBasicAuth(), +{{/isBasic}} +{{#isApiKey}} + '{{name}}': new ApiKeyAuth({{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{^isKeyInHeader}}'query'{{/isKeyInHeader}}, '{{keyParamName}}'), +{{/isApiKey}} +{{#isOAuth}} + '{{name}}': new OAuth(), +{{/isOAuth}} +{{/authMethods}} +{{/hasAuthMethods}} + } + + constructor(basePath?: string); +{{#authMethods}} +{{#isBasic}} + constructor(username: string, password: string, basePath?: string); +{{/isBasic}} +{{/authMethods}} + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { +{{#authMethods}} +{{#isBasic}} + this.username = basePathOrUsername; + this.password = password +{{/isBasic}} +{{/authMethods}} + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: {{classname}}ApiKeys, value: string) { + (this.authentications as any)[{{classname}}ApiKeys[key]].apiKey = value; + } +{{#hasAuthMethods}} +{{#authMethods}} +{{#isBasic}} + set username(username: string) { + this.authentications.{{name}}.username = username; + } + + set password(password: string) { + this.authentications.{{name}}.password = password; + } +{{/isBasic}} +{{#isOAuth}} + + set accessToken(token: string) { + this.authentications.{{name}}.accessToken = token; + } +{{/isOAuth}} +{{/authMethods}} +{{/hasAuthMethods}} + +{{#operation}} + /** + * {{¬es}} + {{#summary}} + * @summary {{&summary}} + {{/summary}} + {{#allParams}} + * @param {{paramName}} {{description}} + {{/allParams}} + */ + public async {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.{{#supportsES6}}IncomingMessage{{/supportsES6}}{{^supportsES6}}ClientResponse{{/supportsES6}}; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }> { + const localVarPath = this.basePath + '{{{path}}}'{{#pathParams}} + .replace('{' + '{{baseName}}' + '}', encodeURIComponent(String({{paramName}}))){{/pathParams}}; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + +{{#allParams}} +{{#required}} + // verify required parameter '{{paramName}}' is not null or undefined + if ({{paramName}} === null || {{paramName}} === undefined) { + throw new Error('Required parameter {{paramName}} was null or undefined when calling {{nickname}}.'); + } + +{{/required}} +{{/allParams}} +{{#queryParams}} + if ({{paramName}} !== undefined) { + localVarQueryParameters['{{baseName}}'] = ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}"); + } + +{{/queryParams}} +{{#headerParams}} + localVarHeaderParams['{{baseName}}'] = ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}"); +{{/headerParams}} + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + +{{#formParams}} + if ({{paramName}} !== undefined) { + {{#isFile}} + localVarFormParams['{{baseName}}'] = {{paramName}}; + {{/isFile}} + {{^isFile}} + localVarFormParams['{{baseName}}'] = ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}"); + {{/isFile}} + } +{{#isFile}} + localVarUseFormData = true; +{{/isFile}} + +{{/formParams}} + let localVarRequestOptions: localVarRequest.Options = { + method: '{{httpMethod}}', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, +{{^isResponseFile}} + json: true, +{{/isResponseFile}} +{{#isResponseFile}} + encoding: null, +{{/isResponseFile}} +{{#bodyParam}} + body: ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}") +{{/bodyParam}} + }; + +{{#authMethods}} + this.authentications.{{name}}.applyToRequest(localVarRequestOptions); + +{{/authMethods}} + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.{{#supportsES6}}IncomingMessage{{/supportsES6}}{{^supportsES6}}ClientResponse{{/supportsES6}}; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + {{#returnType}} + body = ObjectSerializer.deserialize(body, "{{{returnType}}}"); + {{/returnType}} + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve(body); + } else { + reject({ + statusCode: response.statusCode, + statusMessage: response.statusMessage + }); + } + } + }); + }); + } +{{/operation}} +} +{{/operations}} diff --git a/src/infrastructure/templates/api.mustache b/src/infrastructure/templates/api.mustache new file mode 100755 index 0000000000..07d1fde760 --- /dev/null +++ b/src/infrastructure/templates/api.mustache @@ -0,0 +1,4 @@ +{{>licenseInfo}} +// This is the entrypoint for the package +export * from './api/apis'; +export * from './model/models'; \ No newline at end of file diff --git a/src/infrastructure/templates/git_push.sh.mustache b/src/infrastructure/templates/git_push.sh.mustache new file mode 100755 index 0000000000..8a32e53995 --- /dev/null +++ b/src/infrastructure/templates/git_push.sh.mustache @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/src/infrastructure/templates/gitignore b/src/infrastructure/templates/gitignore new file mode 100755 index 0000000000..149b576547 --- /dev/null +++ b/src/infrastructure/templates/gitignore @@ -0,0 +1,4 @@ +wwwroot/*.js +node_modules +typings +dist diff --git a/src/infrastructure/templates/licenseInfo.mustache b/src/infrastructure/templates/licenseInfo.mustache new file mode 100755 index 0000000000..d81df515fd --- /dev/null +++ b/src/infrastructure/templates/licenseInfo.mustache @@ -0,0 +1,26 @@ +/* + * Copyright 2019 NEM + * + * 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. + */ +/** + * {{{appName}}} + * {{{appDescription}}} + * + * {{#version}}The version of the OpenAPI document: {{{version}}}{{/version}} + * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ diff --git a/src/infrastructure/templates/model.mustache b/src/infrastructure/templates/model.mustache new file mode 100755 index 0000000000..0b3ca75891 --- /dev/null +++ b/src/infrastructure/templates/model.mustache @@ -0,0 +1,69 @@ +{{>licenseInfo}} +{{#models}} +{{#model}} +{{#tsImports}} +import { {{classname}} } from './{{filename}}'; +{{/tsImports}} + +{{#description}} +/** +* {{{description}}} +*/ +{{/description}} +export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ +{{#vars}} +{{#description}} + /** + * {{{description}}} + */ +{{/description}} + '{{name}}'{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}; +{{/vars}} + + {{#discriminator}} + static discriminator: string | undefined = "{{discriminatorName}}"; + {{/discriminator}} + {{^discriminator}} + static discriminator: string | undefined = undefined; + {{/discriminator}} + + {{^isArrayModel}} + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + {{#vars}} + { + "name": "{{name}}", + "baseName": "{{baseName}}", + "type": "{{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}" + }{{#hasMore}}, + {{/hasMore}} + {{/vars}} + ]; + + static getAttributeTypeMap() { + {{#parent}} + return super.getAttributeTypeMap().concat({{classname}}.attributeTypeMap); + {{/parent}} + {{^parent}} + return {{classname}}.attributeTypeMap; + {{/parent}} + } + {{/isArrayModel}} +} + +{{#hasEnums}} +export namespace {{classname}} { +{{#vars}} +{{#isEnum}} + export enum {{enumName}} { + {{#allowableValues}} + {{#enumVars}} + {{name}} = {{{value}}}{{^-last}},{{/-last}} + {{/enumVars}} + {{/allowableValues}} + } +{{/isEnum}} +{{/vars}} +} +{{/hasEnums}} +{{/model}} +{{/models}} \ No newline at end of file diff --git a/src/infrastructure/templates/models.mustache b/src/infrastructure/templates/models.mustache new file mode 100755 index 0000000000..f7f1d2e0a8 --- /dev/null +++ b/src/infrastructure/templates/models.mustache @@ -0,0 +1,210 @@ +{{#models}} +{{#model}} +export * from './{{{ classFilename }}}'; +{{/model}} +{{/models}} + +import localVarRequest = require('request'); + +{{#models}} +{{#model}} +import { {{classname}} } from './{{{ classFilename }}}'; +{{/model}} +{{/models}} + +/* tslint:disable:no-unused-variable */ +let primitives = [ + "string", + "boolean", + "double", + "integer", + "long", + "float", + "number", + "any" + ]; + +let enumsMap: {[index: string]: any} = { + {{#models}} + {{#model}} + {{#hasEnums}} + {{#vars}} + {{#isEnum}} + {{#isContainer}}"{{classname}}.{{enumName}}": {{classname}}.{{enumName}}{{/isContainer}}{{^isContainer}}"{{datatypeWithEnum}}": {{datatypeWithEnum}}{{/isContainer}}, + {{/isEnum}} + {{/vars}} + {{/hasEnums}} + {{/model}} + {{/models}} +} + +let typeMap: {[index: string]: any} = { + {{#models}} + {{#model}} + "{{classname}}": {{classname}}, + {{/model}} + {{/models}} +} + +export class ObjectSerializer { + public static findCorrectType(data: any, expectedType: string) { + if (data == undefined) { + return expectedType; + } else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) { + return expectedType; + } else if (expectedType === "Date") { + return expectedType; + } else { + if (enumsMap[expectedType]) { + return expectedType; + } + + if (!typeMap[expectedType]) { + return expectedType; // w/e we don't know the type + } + + // Check the discriminator + let discriminatorProperty = typeMap[expectedType].discriminator; + if (discriminatorProperty == null) { + return expectedType; // the type does not have a discriminator. use it. + } else { + if (data[discriminatorProperty]) { + var discriminatorType = data[discriminatorProperty]; + if(typeMap[discriminatorType]){ + return discriminatorType; // use the type given in the discriminator + } else { + return expectedType; // discriminator did not map to a type + } + } else { + return expectedType; // discriminator was not present (or an empty string) + } + } + } + } + + public static serialize(data: any, type: string) { + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.serialize(date, subType)); + } + return transformedData; + } else if (type === "Date") { + return data.toISOString(); + } else { + if (enumsMap[type]) { + return data; + } + if (!typeMap[type]) { // in case we dont know the type + return data; + } + + // Get the actual type of this object + type = this.findCorrectType(data, type); + + // get the map for the correct type. + let attributeTypes = typeMap[type].getAttributeTypeMap(); + let instance: {[index: string]: any} = {}; + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type); + } + return instance; + } + } + + public static deserialize(data: any, type: string) { + // polymorphism may change the actual type. + type = ObjectSerializer.findCorrectType(data, type); + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.deserialize(date, subType)); + } + return transformedData; + } else if (type === "Date") { + return new Date(data); + } else { + if (enumsMap[type]) {// is Enum + return data; + } + + if (!typeMap[type]) { // dont know the type + return data; + } + let instance = new typeMap[type](); + let attributeTypes = typeMap[type].getAttributeTypeMap(); + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type); + } + return instance; + } + } +} + +export interface Authentication { + /** + * Apply authentication settings to header and query params. + */ + applyToRequest(requestOptions: localVarRequest.Options): void; +} + +export class HttpBasicAuth implements Authentication { + public username: string = ''; + public password: string = ''; + + applyToRequest(requestOptions: localVarRequest.Options): void { + requestOptions.auth = { + username: this.username, password: this.password + } + } +} + +export class ApiKeyAuth implements Authentication { + public apiKey: string = ''; + + constructor(private location: string, private paramName: string) { + } + + applyToRequest(requestOptions: localVarRequest.Options): void { + if (this.location == "query") { + (requestOptions.qs)[this.paramName] = this.apiKey; + } else if (this.location == "header" && requestOptions && requestOptions.headers) { + requestOptions.headers[this.paramName] = this.apiKey; + } + } +} + +export class OAuth implements Authentication { + public accessToken: string = ''; + + applyToRequest(requestOptions: localVarRequest.Options): void { + if (requestOptions && requestOptions.headers) { + requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; + } + } +} + +export class VoidAuth implements Authentication { + public username: string = ''; + public password: string = ''; + + applyToRequest(_: localVarRequest.Options): void { + // Do nothing + } +} \ No newline at end of file diff --git a/src/infrastructure/templates/package.mustache b/src/infrastructure/templates/package.mustache new file mode 100755 index 0000000000..ff1c5c4451 --- /dev/null +++ b/src/infrastructure/templates/package.mustache @@ -0,0 +1,29 @@ +{ + "name": "{{npmName}}", + "version": "{{npmVersion}}", + "description": "NodeJS client for {{npmName}}", + "repository": "{{gitUserId}}/{{gitRepoId}}", + "main": "dist/api.js", + "types": "dist/api.d.ts", + "scripts": { + "clean": "rm -Rf node_modules/ *.js", + "build": "tsc", + "test": "npm run build && node dist/client.js" + }, + "author": "OpenAPI-Generator Contributors", + "license": "Unlicense", + "dependencies": { + "bluebird": "^3.5.0", + "request": "^2.81.0", + "@types/bluebird": "*", + "@types/request": "*", + "rewire": "^3.0.2" + }, + "devDependencies": { + "typescript": "^2.4.2", + "@types/node": "8.10.34" + }{{#npmRepository}}, + "publishConfig": { + "registry": "{{npmRepository}}" + }{{/npmRepository}} +} diff --git a/src/infrastructure/templates/tsconfig.mustache b/src/infrastructure/templates/tsconfig.mustache new file mode 100755 index 0000000000..160a99593a --- /dev/null +++ b/src/infrastructure/templates/tsconfig.mustache @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "noImplicitAny": false, + "suppressImplicitAnyIndexErrors": true, + "target": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}ES5{{/supportsES6}}", + "strict": true, + "moduleResolution": "node", + "removeComments": true, + "sourceMap": true, + "noLib": false, + "declaration": true, + "lib": ["dom", "es6", "es5", "dom.iterable", "scripthost"], + "outDir": "dist", + "typeRoots": [ + "node_modules/@types" + ] + }, + "exclude": [ + "dist", + "node_modules" + ] +} diff --git a/src/infrastructure/transaction/CreateTransactionFromDTO.ts b/src/infrastructure/transaction/CreateTransactionFromDTO.ts index df00cf8223..eb6c258a62 100644 --- a/src/infrastructure/transaction/CreateTransactionFromDTO.ts +++ b/src/infrastructure/transaction/CreateTransactionFromDTO.ts @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {convert} from 'nem2-library'; -import {uint64 as UInt64Library} from 'nem2-library'; +import {Convert as convert} from '../../core/format'; +import {RawUInt64 as UInt64Library} from '../../core/format'; import {Address} from '../../model/account/Address'; import {PublicAccount} from '../../model/account/PublicAccount'; import {NetworkType} from '../../model/blockchain/NetworkType'; diff --git a/src/infrastructure/transaction/CreateTransactionFromPayload.ts b/src/infrastructure/transaction/CreateTransactionFromPayload.ts index 52acb8144d..c042e778e7 100644 --- a/src/infrastructure/transaction/CreateTransactionFromPayload.ts +++ b/src/infrastructure/transaction/CreateTransactionFromPayload.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { convert } from 'nem2-library'; +import { Convert as convert } from '../../core/format'; import {decode} from 'utf8'; import { Address } from '../../model/account/Address'; import { PublicAccount } from '../../model/account/PublicAccount'; diff --git a/src/infrastructure/transaction/NamespaceMosaicIdGenerator.ts b/src/infrastructure/transaction/NamespaceMosaicIdGenerator.ts new file mode 100644 index 0000000000..5f7a57aea1 --- /dev/null +++ b/src/infrastructure/transaction/NamespaceMosaicIdGenerator.ts @@ -0,0 +1,63 @@ +/* + * Copyright 2019 NEM + * + * 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 {Crypto} from '../../core/crypto'; +import { IdGenerator } from '../../core/format'; + +export class NamespaceMosaicIdGenerator { + /** + * @returns mosaic Id + */ + public static mosaicId = (nonce, ownerPublicId) => { + return IdGenerator.generateMosaicId(nonce, ownerPublicId); + } + + /** + * @returns random mosaic nonce + */ + public static generateRandomMosaicNonce = () => { + return Crypto.randomBytes(4); + } + + /** + * @param {string} namespaceName - The namespace name + * @returns sub namespace id + */ + public static namespaceId = (namespaceName) => { + const path = IdGenerator.generateNamespacePath(namespaceName); + return path.length ? IdGenerator.generateNamespacePath(namespaceName)[path.length - 1] : []; + } + /** + * @param {string} parentNamespaceName - The parent namespace name + * @param {string} namespaceName - The namespace name + * @returns sub namespace parent id + */ + public static subnamespaceParentId = (parentNamespaceName: string, namespaceName: string) => { + const path = IdGenerator.generateNamespacePath(`${parentNamespaceName}.${namespaceName}`); + return IdGenerator.generateNamespacePath(parentNamespaceName)[path.length - 2]; + } + + /** + * @param {string} parentNamespaceName - The parent namespace name + * @param {string} namespaceName - The namespace name + * @returns sub namespace id + */ + public static subnamespaceNamespaceId = (parentNamespaceName, namespaceName) => { + const path = IdGenerator.generateNamespacePath(`${parentNamespaceName}.${namespaceName}`); + return path[path.length - 1]; + } + +} diff --git a/src/model/UInt64.ts b/src/model/UInt64.ts index 978eec992e..61048f0170 100644 --- a/src/model/UInt64.ts +++ b/src/model/UInt64.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {uint64} from 'nem2-library'; +import { RawUInt64 as uint64 } from '../core/format'; /** * UInt64 data model diff --git a/src/model/account/Account.ts b/src/model/account/Account.ts index 728dfc12a7..2d31512471 100644 --- a/src/model/account/Account.ts +++ b/src/model/account/Account.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import {address as AddressLibrary, convert, KeyPair, nacl_catapult} from 'nem2-library'; +import {Crypto, KeyPair} from '../../core/crypto'; +import {Convert as convert, RawAddress as AddressLibrary} from '../../core/format'; import {NetworkType} from '../blockchain/NetworkType'; import {AggregateTransaction} from '../transaction/AggregateTransaction'; import {CosignatureSignedTransaction} from '../transaction/CosignatureSignedTransaction'; @@ -70,7 +71,7 @@ export class Account { public static generateNewAccount(networkType: NetworkType): Account { // Create random bytes - const randomBytesArray = nacl_catapult.randomBytes(32); + const randomBytesArray = Crypto.randomBytes(32); // Hash random bytes with entropy seed // Finalize and keep only 32 bytes const hashKey = convert.uint8ToHex(randomBytesArray); // TODO: derive private key correctly @@ -83,8 +84,8 @@ export class Account { } /** * Create a new encrypted Message - * @param message - * @param recipientPublicAccount + * @param message - Plain message to be encrypted + * @param recipientPublicAccount - Recipient public account * @returns {EncryptedMessage} */ public encryptMessage(message: string, recipientPublicAccount: PublicAccount): EncryptedMessage { @@ -93,12 +94,12 @@ export class Account { /** * Decrypts an encrypted message - * @param encryptedMessage - * @param recipientPublicAccount + * @param encryptedMessage - Encrypted message + * @param publicAccount - The public account originally encrypted the message * @returns {PlainMessage} */ - public decryptMessage(encryptedMessage: EncryptedMessage, recipientPublicAccount: PublicAccount): PlainMessage { - return EncryptedMessage.decrypt(encryptedMessage, this.privateKey, recipientPublicAccount); + public decryptMessage(encryptedMessage: EncryptedMessage, publicAccount: PublicAccount): PlainMessage { + return EncryptedMessage.decrypt(encryptedMessage, this.privateKey, publicAccount); } /** * Account public key. diff --git a/src/model/account/Address.ts b/src/model/account/Address.ts index db5ebeeac2..b3d7dbbc40 100644 --- a/src/model/account/Address.ts +++ b/src/model/account/Address.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {address as AddressLibrary, convert} from 'nem2-library'; +import { Convert as convert, RawAddress as AddressLibrary} from '../../core/format'; import {NetworkType} from '../blockchain/NetworkType'; /** diff --git a/src/model/account/PublicAccount.ts b/src/model/account/PublicAccount.ts index 8bc2967bcd..84c2b2ea3c 100644 --- a/src/model/account/PublicAccount.ts +++ b/src/model/account/PublicAccount.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import { convert, KeyPair } from 'nem2-library'; +import { KeyPair } from '../../core/crypto'; +import { Convert as convert} from '../../core/format'; import { NetworkType } from '../blockchain/NetworkType'; import { Address } from './Address'; diff --git a/src/model/blockchain/MerklePathItem.ts b/src/model/blockchain/MerklePathItem.ts index 196ccd2335..a004229c18 100644 --- a/src/model/blockchain/MerklePathItem.ts +++ b/src/model/blockchain/MerklePathItem.ts @@ -26,11 +26,11 @@ export class MerklePathItem { constructor(/** * The position */ - public readonly position: number, + public readonly position?: number, /** * The hash */ - public readonly hash: string) { + public readonly hash?: string) { } } diff --git a/src/model/model.ts b/src/model/model.ts index c4d31efe5b..383305be0d 100644 --- a/src/model/model.ts +++ b/src/model/model.ts @@ -131,3 +131,4 @@ export * from './wallet/EncryptedPrivateKey'; export * from './wallet/Password'; export * from './wallet/SimpleWallet'; export * from './wallet/Wallet'; +export * from './wallet/WalletAlgorithm'; diff --git a/src/model/mosaic/MosaicId.ts b/src/model/mosaic/MosaicId.ts index 42c0de97ee..a1ab4e8110 100644 --- a/src/model/mosaic/MosaicId.ts +++ b/src/model/mosaic/MosaicId.ts @@ -13,13 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { - convert, - mosaicId as MosaicIdentifierGenerator, - nacl_catapult, - uint64 as uint64_t, -} from 'nem2-library'; - +import { Convert as convert, RawUInt64 as uint64_t } from '../../core/format'; +import {NamespaceMosaicIdGenerator} from '../../infrastructure/transaction/NamespaceMosaicIdGenerator'; import {PublicAccount} from '../account/PublicAccount'; import {Id} from '../Id'; import {MosaicNonce} from '../mosaic/MosaicNonce'; @@ -44,7 +39,7 @@ export class MosaicId { * @return {MosaicId} */ public static createFromNonce(nonce: MosaicNonce, owner: PublicAccount): MosaicId { - const mosaicId = MosaicIdentifierGenerator(nonce.nonce, convert.hexToUint8(owner.publicKey)); + const mosaicId = NamespaceMosaicIdGenerator.mosaicId(nonce.nonce, convert.hexToUint8(owner.publicKey)); return new MosaicId(mosaicId); } diff --git a/src/model/mosaic/MosaicNonce.ts b/src/model/mosaic/MosaicNonce.ts index 319bf2a0eb..2ef1dfe28f 100644 --- a/src/model/mosaic/MosaicNonce.ts +++ b/src/model/mosaic/MosaicNonce.ts @@ -13,11 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { - convert, - nacl_catapult, -} from 'nem2-library'; - +import {Crypto} from '../../core/crypto'; +import { Convert as convert} from '../../core/format'; /** * The mosaic nonce structure * @@ -36,7 +33,7 @@ export class MosaicNonce { * @return {MosaicNonce} */ public static createRandom(): MosaicNonce { - const bytes = nacl_catapult.randomBytes(4); + const bytes = Crypto.randomBytes(4); const nonce = new Uint8Array(bytes); return new MosaicNonce(nonce); } diff --git a/src/model/mosaic/NetworkHarvestMosaic.ts b/src/model/mosaic/NetworkHarvestMosaic.ts index d8f4359fb2..f9df23fb98 100644 --- a/src/model/mosaic/NetworkHarvestMosaic.ts +++ b/src/model/mosaic/NetworkHarvestMosaic.ts @@ -13,9 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import {convert, mosaicId as MosaicIdGenerator} from 'nem2-library'; -import {PublicAccount} from '../account/PublicAccount'; import {NamespaceId} from '../namespace/NamespaceId'; import {UInt64} from '../UInt64'; import {Mosaic} from './Mosaic'; diff --git a/src/model/namespace/AddressAlias.ts b/src/model/namespace/AddressAlias.ts index 5e5c091513..de1aade68c 100644 --- a/src/model/namespace/AddressAlias.ts +++ b/src/model/namespace/AddressAlias.ts @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {namespaceId as NamespaceIdGenerator} from 'nem2-library'; import {Address} from '../account/Address'; import {Alias} from './Alias'; diff --git a/src/model/namespace/Alias.ts b/src/model/namespace/Alias.ts index 5f2e56b179..b05262610a 100644 --- a/src/model/namespace/Alias.ts +++ b/src/model/namespace/Alias.ts @@ -13,12 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {namespaceId as NamespaceIdGenerator} from 'nem2-library'; import {Address} from '../account/Address'; import {MosaicId} from '../mosaic/MosaicId'; -import {AddressAlias} from './AddressAlias'; -import {AliasType} from './AliasType'; -import {MosaicAlias} from './MosaicAlias'; /** * The alias structure defines an interface for Aliases diff --git a/src/model/namespace/EmptyAlias.ts b/src/model/namespace/EmptyAlias.ts index ace9a03254..35e625f63e 100644 --- a/src/model/namespace/EmptyAlias.ts +++ b/src/model/namespace/EmptyAlias.ts @@ -13,8 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {namespaceId as NamespaceIdGenerator} from 'nem2-library'; -import {Address} from '../account/Address'; import {Alias} from './Alias'; /** diff --git a/src/model/namespace/MosaicAlias.ts b/src/model/namespace/MosaicAlias.ts index fa8048ad04..c49640016c 100644 --- a/src/model/namespace/MosaicAlias.ts +++ b/src/model/namespace/MosaicAlias.ts @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {namespaceId as NamespaceIdGenerator} from 'nem2-library'; import {MosaicId} from '../mosaic/MosaicId'; import {Alias} from './Alias'; diff --git a/src/model/namespace/NamespaceId.ts b/src/model/namespace/NamespaceId.ts index 4b8f956cba..d0b4af4767 100644 --- a/src/model/namespace/NamespaceId.ts +++ b/src/model/namespace/NamespaceId.ts @@ -13,7 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {convert, namespaceId as NamespaceIdGenerator} from 'nem2-library'; +import {Convert as convert} from '../../core/format'; +import {NamespaceMosaicIdGenerator} from '../../infrastructure/transaction/NamespaceMosaicIdGenerator'; import {Id} from '../Id'; /** @@ -44,7 +45,7 @@ export class NamespaceId { this.id = new Id(id); } else if (typeof id === 'string') { this.fullName = id; - this.id = new Id(NamespaceIdGenerator(id)); + this.id = new Id(NamespaceMosaicIdGenerator.namespaceId(id)); } } diff --git a/src/model/transaction/AccountLinkTransaction.ts b/src/model/transaction/AccountLinkTransaction.ts index a837f135de..78915b03a3 100644 --- a/src/model/transaction/AccountLinkTransaction.ts +++ b/src/model/transaction/AccountLinkTransaction.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import { AccountLinkTransaction as AccountLinkTransactionLibrary, VerifiableTransaction } from 'nem2-library'; +import { Builder } from '../../infrastructure/builders/AccountLinkTransaction'; +import { VerifiableTransaction } from '../../infrastructure/builders/VerifiableTransaction'; import { PublicAccount } from '../account/PublicAccount'; import { NetworkType } from '../blockchain/NetworkType'; import { UInt64 } from '../UInt64'; @@ -101,7 +102,7 @@ export class AccountLinkTransaction extends Transaction { * @returns {VerifiableTransaction} */ protected buildTransaction(): VerifiableTransaction { - return new AccountLinkTransactionLibrary.Builder() + return new Builder() .addDeadline(this.deadline.toDTO()) .addFee(this.maxFee.toDTO()) .addVersion(this.versionToDTO()) diff --git a/src/model/transaction/AddressAliasTransaction.ts b/src/model/transaction/AddressAliasTransaction.ts index a0e37a7049..a0ac7d269f 100644 --- a/src/model/transaction/AddressAliasTransaction.ts +++ b/src/model/transaction/AddressAliasTransaction.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import { AddressAliasTransaction as AddressAliasTransactionLibrary, VerifiableTransaction } from 'nem2-library'; +import { Builder } from '../../infrastructure/builders/AddressAliasTransaction'; +import { VerifiableTransaction } from '../../infrastructure/builders/VerifiableTransaction'; import { Address } from '../account/Address'; import { PublicAccount } from '../account/PublicAccount'; import { NetworkType } from '../blockchain/NetworkType'; @@ -115,7 +116,7 @@ export class AddressAliasTransaction extends Transaction { * @returns {VerifiableTransaction} */ protected buildTransaction(): VerifiableTransaction { - return new AddressAliasTransactionLibrary.Builder() + return new Builder() .addDeadline(this.deadline.toDTO()) .addFee(this.maxFee.toDTO()) .addVersion(this.versionToDTO()) diff --git a/src/model/transaction/AggregateTransaction.ts b/src/model/transaction/AggregateTransaction.ts index 2c20541943..b6cf37736c 100644 --- a/src/model/transaction/AggregateTransaction.ts +++ b/src/model/transaction/AggregateTransaction.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import { AggregateTransaction as AggregateTransactionLibrary } from 'nem2-library'; +import { Builder } from '../../infrastructure/builders/AggregateTransaction'; +import { AggregateTransaction as AggregatedTransactionCore} from '../../infrastructure/builders/AggregateTransaction'; import { Account } from '../account/Account'; import { PublicAccount } from '../account/PublicAccount'; import { NetworkType } from '../blockchain/NetworkType'; @@ -116,8 +117,8 @@ export class AggregateTransaction extends Transaction { * @internal * @returns {AggregateTransaction} */ - public buildTransaction(): AggregateTransactionLibrary { - return new AggregateTransactionLibrary.Builder() + public buildTransaction(): AggregatedTransactionCore { + return new Builder() .addDeadline(this.deadline.toDTO()) .addType(this.type) .addFee(this.maxFee.toDTO()) diff --git a/src/model/transaction/AliasTransaction.ts b/src/model/transaction/AliasTransaction.ts index 579f9d4969..2333bd04be 100644 --- a/src/model/transaction/AliasTransaction.ts +++ b/src/model/transaction/AliasTransaction.ts @@ -14,9 +14,7 @@ * limitations under the License. */ -import { MosaicSupplyChangeTransaction as MosaicSupplyChangeTransactionLibrary, VerifiableTransaction } from 'nem2-library'; import { Address } from '../account/Address'; -import { PublicAccount } from '../account/PublicAccount'; import { NetworkType } from '../blockchain/NetworkType'; import { MosaicId } from '../mosaic/MosaicId'; import { AliasActionType } from '../namespace/AliasActionType'; @@ -26,9 +24,6 @@ import { AddressAliasTransaction } from './AddressAliasTransaction'; import { Deadline } from './Deadline'; import { MosaicAliasTransaction } from './MosaicAliasTransaction'; import { Transaction } from './Transaction'; -import { TransactionInfo } from './TransactionInfo'; -import { TransactionType } from './TransactionType'; -import { TransactionVersion } from './TransactionVersion'; export abstract class AliasTransaction extends Transaction { diff --git a/src/model/transaction/CosignatureTransaction.ts b/src/model/transaction/CosignatureTransaction.ts index fe9017cf1d..e783dd6659 100644 --- a/src/model/transaction/CosignatureTransaction.ts +++ b/src/model/transaction/CosignatureTransaction.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {CosignatureTransaction as CosignaturetransactionLibrary} from 'nem2-library'; +import {CosignatureTransaction as CosignaturetransactionLibrary} from '../../infrastructure/builders/CosignatureTransaction'; import {Account} from '../account/Account'; import {AggregateTransaction} from './AggregateTransaction'; import {CosignatureSignedTransaction} from './CosignatureSignedTransaction'; diff --git a/src/model/transaction/EncryptedMessage.ts b/src/model/transaction/EncryptedMessage.ts index 170378174b..de23a5516d 100644 --- a/src/model/transaction/EncryptedMessage.ts +++ b/src/model/transaction/EncryptedMessage.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {crypto} from 'nem2-library'; +import {Crypto} from '../../core/crypto'; import {PublicAccount} from '../account/PublicAccount'; import {Message} from './Message'; import {MessageType} from './MessageType'; @@ -41,7 +41,7 @@ export class EncryptedMessage extends Message { */ public static create(message: string, recipientPublicAccount: PublicAccount, privateKey) { return new EncryptedMessage( - crypto.encode(privateKey, recipientPublicAccount.publicKey, message).toUpperCase(), + Crypto.encode(privateKey, recipientPublicAccount.publicKey, message).toUpperCase(), recipientPublicAccount); } @@ -60,6 +60,6 @@ export class EncryptedMessage extends Message { * @param recipientPublicAccount - Sender public account */ public static decrypt(encryptMessage: EncryptedMessage, privateKey, recipientPublicAccount: PublicAccount): PlainMessage { - return new PlainMessage(this.decodeHex(crypto.decode(privateKey, recipientPublicAccount.publicKey, encryptMessage.payload))); + return new PlainMessage(this.decodeHex(Crypto.decode(privateKey, recipientPublicAccount.publicKey, encryptMessage.payload))); } } diff --git a/src/model/transaction/HashType.ts b/src/model/transaction/HashType.ts index df42501603..6219e7cb05 100644 --- a/src/model/transaction/HashType.ts +++ b/src/model/transaction/HashType.ts @@ -21,7 +21,7 @@ * 2: Op_Hash_160 (first with SHA-256 and then with RIPEMD-160 (BTC compatibility)) * 3: Op_Hash_256: input is hashed twice with SHA-256 (BTC compatibility) */ -import {convert} from 'nem2-library'; +import {Convert as convert} from '../../core/format'; export enum HashType { Op_Sha3_256 = 0, diff --git a/src/model/transaction/LockFundsTransaction.ts b/src/model/transaction/LockFundsTransaction.ts index aeafd6328a..4036654043 100644 --- a/src/model/transaction/LockFundsTransaction.ts +++ b/src/model/transaction/LockFundsTransaction.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import { HashLockTransaction, VerifiableTransaction } from 'nem2-library'; +import { Builder } from '../../infrastructure/builders/HashLockTransaction'; +import {VerifiableTransaction} from '../../infrastructure/builders/VerifiableTransaction'; import { PublicAccount } from '../account/PublicAccount'; import { NetworkType } from '../blockchain/NetworkType'; import { Mosaic } from '../mosaic/Mosaic'; @@ -124,7 +125,7 @@ export class LockFundsTransaction extends Transaction { * @return {VerifiableTransaction} */ protected buildTransaction(): VerifiableTransaction { - return new HashLockTransaction.Builder() + return new Builder() .addDeadline(this.deadline.toDTO()) .addType(this.type) .addFee(this.maxFee.toDTO()) diff --git a/src/model/transaction/ModifyAccountPropertyAddressTransaction.ts b/src/model/transaction/ModifyAccountPropertyAddressTransaction.ts index 2c7874d5d7..4cfa610839 100644 --- a/src/model/transaction/ModifyAccountPropertyAddressTransaction.ts +++ b/src/model/transaction/ModifyAccountPropertyAddressTransaction.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import { AccountPropertiesAddressTransaction as AccountPropertiesAddressTransactionLibrary, VerifiableTransaction } from 'nem2-library'; +import { Builder } from '../../infrastructure/builders/AccountPropertiesAddressTransaction'; +import {VerifiableTransaction} from '../../infrastructure/builders/VerifiableTransaction'; import { PropertyType } from '../account/PropertyType'; import { PublicAccount } from '../account/PublicAccount'; import { NetworkType } from '../blockchain/NetworkType'; @@ -100,7 +101,7 @@ export class ModifyAccountPropertyAddressTransaction extends Transaction { * @returns {VerifiableTransaction} */ protected buildTransaction(): VerifiableTransaction { - return new AccountPropertiesAddressTransactionLibrary.Builder() + return new Builder() .addDeadline(this.deadline.toDTO()) .addFee(this.maxFee.toDTO()) .addVersion(this.versionToDTO()) diff --git a/src/model/transaction/ModifyAccountPropertyEntityTypeTransaction.ts b/src/model/transaction/ModifyAccountPropertyEntityTypeTransaction.ts index 70caa85e74..a49c4873a9 100644 --- a/src/model/transaction/ModifyAccountPropertyEntityTypeTransaction.ts +++ b/src/model/transaction/ModifyAccountPropertyEntityTypeTransaction.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import { AccountPropertiesEntityTypeTransaction as AccountPropertiesEntityTypeTransactionLibrary, - VerifiableTransaction } from 'nem2-library'; +import { Builder } from '../../infrastructure/builders/AccountPropertiesEntityTypeTransaction'; +import {VerifiableTransaction} from '../../infrastructure/builders/VerifiableTransaction'; import { PropertyType } from '../account/PropertyType'; import { PublicAccount } from '../account/PublicAccount'; import { NetworkType } from '../blockchain/NetworkType'; @@ -101,7 +101,7 @@ export class ModifyAccountPropertyEntityTypeTransaction extends Transaction { * @returns {VerifiableTransaction} */ protected buildTransaction(): VerifiableTransaction { - return new AccountPropertiesEntityTypeTransactionLibrary.Builder() + return new Builder() .addDeadline(this.deadline.toDTO()) .addFee(this.maxFee.toDTO()) .addVersion(this.versionToDTO()) diff --git a/src/model/transaction/ModifyAccountPropertyMosaicTransaction.ts b/src/model/transaction/ModifyAccountPropertyMosaicTransaction.ts index d8bd9e3dfb..1ec9770ae7 100644 --- a/src/model/transaction/ModifyAccountPropertyMosaicTransaction.ts +++ b/src/model/transaction/ModifyAccountPropertyMosaicTransaction.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import { AccountPropertiesMosaicTransaction as AccountPropertiesMosaicTransactionLibrary, VerifiableTransaction } from 'nem2-library'; +import { Builder } from '../../infrastructure/builders/AccountPropertiesMosaicTransaction'; +import {VerifiableTransaction} from '../../infrastructure/builders/VerifiableTransaction'; import { PropertyType } from '../account/PropertyType'; import { PublicAccount } from '../account/PublicAccount'; import { NetworkType } from '../blockchain/NetworkType'; @@ -100,7 +101,7 @@ export class ModifyAccountPropertyMosaicTransaction extends Transaction { * @returns {VerifiableTransaction} */ protected buildTransaction(): VerifiableTransaction { - return new AccountPropertiesMosaicTransactionLibrary.Builder() + return new Builder() .addDeadline(this.deadline.toDTO()) .addFee(this.maxFee.toDTO()) .addVersion(this.versionToDTO()) diff --git a/src/model/transaction/ModifyMultisigAccountTransaction.ts b/src/model/transaction/ModifyMultisigAccountTransaction.ts index 2510e8770a..e8afe30251 100644 --- a/src/model/transaction/ModifyMultisigAccountTransaction.ts +++ b/src/model/transaction/ModifyMultisigAccountTransaction.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import { MultisigModificationTransaction as ModifyMultisigAccountTransactionLibrary, VerifiableTransaction } from 'nem2-library'; +import { Builder } from '../../infrastructure/builders/MultisigModificationTransaction'; +import {VerifiableTransaction} from '../../infrastructure/builders/VerifiableTransaction'; import { PublicAccount } from '../account/PublicAccount'; import { NetworkType } from '../blockchain/NetworkType'; import { UInt64 } from '../UInt64'; @@ -121,7 +122,7 @@ export class ModifyMultisigAccountTransaction extends Transaction { * @returns {VerifiableTransaction} */ protected buildTransaction(): VerifiableTransaction { - return new ModifyMultisigAccountTransactionLibrary.Builder() + return new Builder() .addDeadline(this.deadline.toDTO()) .addFee(this.maxFee.toDTO()) .addVersion(this.versionToDTO()) diff --git a/src/model/transaction/MosaicAliasTransaction.ts b/src/model/transaction/MosaicAliasTransaction.ts index 6214dce9a8..8cc1d1914a 100644 --- a/src/model/transaction/MosaicAliasTransaction.ts +++ b/src/model/transaction/MosaicAliasTransaction.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import { MosaicAliasTransaction as MosaicAliasTransactionLibrary, VerifiableTransaction } from 'nem2-library'; +import { Builder } from '../../infrastructure/builders/MosaicAliasTransaction'; +import {VerifiableTransaction} from '../../infrastructure/builders/VerifiableTransaction'; import { PublicAccount } from '../account/PublicAccount'; import { NetworkType } from '../blockchain/NetworkType'; import { MosaicId } from '../mosaic/MosaicId'; @@ -111,7 +112,7 @@ export class MosaicAliasTransaction extends Transaction { * @returns {VerifiableTransaction} */ protected buildTransaction(): VerifiableTransaction { - return new MosaicAliasTransactionLibrary.Builder() + return new Builder() .addDeadline(this.deadline.toDTO()) .addFee(this.maxFee.toDTO()) .addVersion(this.versionToDTO()) diff --git a/src/model/transaction/MosaicDefinitionTransaction.ts b/src/model/transaction/MosaicDefinitionTransaction.ts index a5890df079..0df96430aa 100644 --- a/src/model/transaction/MosaicDefinitionTransaction.ts +++ b/src/model/transaction/MosaicDefinitionTransaction.ts @@ -14,11 +14,8 @@ * limitations under the License. */ -import { - MosaicCreationTransaction as MosaicDefinitionTransactionLibrary, - mosaicId as mosaicIdLibrary, - VerifiableTransaction, -} from 'nem2-library'; +import { Builder } from '../../infrastructure/builders/MosaicCreationTransaction'; +import {VerifiableTransaction} from '../../infrastructure/builders/VerifiableTransaction'; import { PublicAccount } from '../account/PublicAccount'; import { NetworkType } from '../blockchain/NetworkType'; import { MosaicId } from '../mosaic/MosaicId'; @@ -123,7 +120,7 @@ export class MosaicDefinitionTransaction extends Transaction { * @returns {VerifiableTransaction} */ protected buildTransaction(): VerifiableTransaction { - let mosaicDefinitionTransaction = new MosaicDefinitionTransactionLibrary.Builder() + let mosaicDefinitionTransaction = new Builder() .addDeadline(this.deadline.toDTO()) .addFee(this.maxFee.toDTO()) .addVersion(this.versionToDTO()) diff --git a/src/model/transaction/MosaicSupplyChangeTransaction.ts b/src/model/transaction/MosaicSupplyChangeTransaction.ts index 4518f21edd..39b33d8318 100644 --- a/src/model/transaction/MosaicSupplyChangeTransaction.ts +++ b/src/model/transaction/MosaicSupplyChangeTransaction.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import { MosaicSupplyChangeTransaction as MosaicSupplyChangeTransactionLibrary, VerifiableTransaction } from 'nem2-library'; +import { Builder } from '../../infrastructure/builders/MosaicSupplyChangeTransaction'; +import {VerifiableTransaction} from '../../infrastructure/builders/VerifiableTransaction'; import { PublicAccount } from '../account/PublicAccount'; import { NetworkType } from '../blockchain/NetworkType'; import { MosaicId } from '../mosaic/MosaicId'; @@ -114,7 +115,7 @@ export class MosaicSupplyChangeTransaction extends Transaction { * @returns {VerifiableTransaction} */ protected buildTransaction(): VerifiableTransaction { - return new MosaicSupplyChangeTransactionLibrary.Builder() + return new Builder() .addDeadline(this.deadline.toDTO()) .addFee(this.maxFee.toDTO()) .addVersion(this.versionToDTO()) diff --git a/src/model/transaction/RegisterNamespaceTransaction.ts b/src/model/transaction/RegisterNamespaceTransaction.ts index 5cbabf32e3..da05639507 100644 --- a/src/model/transaction/RegisterNamespaceTransaction.ts +++ b/src/model/transaction/RegisterNamespaceTransaction.ts @@ -14,7 +14,10 @@ * limitations under the License. */ -import { convert, NamespaceCreationTransaction as RegisterNamespaceTransactionLibrary, subnamespaceNamespaceId, subnamespaceParentId, namespaceId, VerifiableTransaction } from 'nem2-library'; +import { Convert as convert } from '../../core/format'; +import { Builder } from '../../infrastructure/builders/NamespaceCreationTransaction'; +import {VerifiableTransaction} from '../../infrastructure/builders/VerifiableTransaction'; +import {NamespaceMosaicIdGenerator} from '../../infrastructure/transaction/NamespaceMosaicIdGenerator'; import { PublicAccount } from '../account/PublicAccount'; import { NetworkType } from '../blockchain/NetworkType'; import { NamespaceId } from '../namespace/NamespaceId'; @@ -73,7 +76,7 @@ export class RegisterNamespaceTransaction extends Transaction { maxFee: UInt64 = new UInt64([0, 0])): RegisterNamespaceTransaction { let parentId: NamespaceId; if (typeof parentNamespace === 'string') { - parentId = new NamespaceId(subnamespaceParentId(parentNamespace, namespaceName)); + parentId = new NamespaceId(NamespaceMosaicIdGenerator.subnamespaceParentId(parentNamespace, namespaceName)); } else { parentId = parentNamespace; } @@ -84,8 +87,8 @@ export class RegisterNamespaceTransaction extends Transaction { NamespaceType.SubNamespace, namespaceName, typeof parentNamespace === 'string' ? - new NamespaceId(subnamespaceNamespaceId(parentNamespace, namespaceName)) : - new NamespaceId(namespaceId(namespaceName)), + new NamespaceId(NamespaceMosaicIdGenerator.subnamespaceNamespaceId(parentNamespace, namespaceName)) : + new NamespaceId(NamespaceMosaicIdGenerator.namespaceId(namespaceName)), undefined, parentId, ); @@ -162,7 +165,7 @@ export class RegisterNamespaceTransaction extends Transaction { * @returns {VerifiableTransaction} */ protected buildTransaction(): VerifiableTransaction { - let registerNamespacetransaction = new RegisterNamespaceTransactionLibrary.Builder() + let registerNamespacetransaction = new Builder() .addDeadline(this.deadline.toDTO()) .addFee(this.maxFee.toDTO()) .addVersion(this.versionToDTO()) diff --git a/src/model/transaction/SecretLockTransaction.ts b/src/model/transaction/SecretLockTransaction.ts index 2d66cd3612..6862dc7a3b 100644 --- a/src/model/transaction/SecretLockTransaction.ts +++ b/src/model/transaction/SecretLockTransaction.ts @@ -13,7 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { convert, SecretLockTransaction as SecretLockTransactionLibrary, VerifiableTransaction } from 'nem2-library'; +import { Convert as convert } from '../../core/format'; +import { Builder } from '../../infrastructure/builders/SecretLockTransaction'; +import {VerifiableTransaction} from '../../infrastructure/builders/VerifiableTransaction'; import { Address } from '../account/Address'; import { PublicAccount } from '../account/PublicAccount'; import { NetworkType } from '../blockchain/NetworkType'; @@ -137,7 +139,7 @@ export class SecretLockTransaction extends Transaction { * @returns {VerifiableTransaction} */ protected buildTransaction(): VerifiableTransaction { - return new SecretLockTransactionLibrary.Builder() + return new Builder() .addDeadline(this.deadline.toDTO()) .addType(this.type) .addFee(this.maxFee.toDTO()) diff --git a/src/model/transaction/SecretProofTransaction.ts b/src/model/transaction/SecretProofTransaction.ts index 644e7fe023..cf41678857 100644 --- a/src/model/transaction/SecretProofTransaction.ts +++ b/src/model/transaction/SecretProofTransaction.ts @@ -13,7 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { convert, SecretProofTransaction as SecretProofTransactionLibrary, VerifiableTransaction } from 'nem2-library'; + +import { Convert as convert } from '../../core/format'; +import { Builder } from '../../infrastructure/builders/SecretProofTransaction'; +import {VerifiableTransaction} from '../../infrastructure/builders/VerifiableTransaction'; import { Address } from '../account/Address'; import { PublicAccount } from '../account/PublicAccount'; import { NetworkType } from '../blockchain/NetworkType'; @@ -115,7 +118,7 @@ export class SecretProofTransaction extends Transaction { * @returns {VerifiableTransaction} */ protected buildTransaction(): VerifiableTransaction { - return new SecretProofTransactionLibrary.Builder() + return new Builder() .addDeadline(this.deadline.toDTO()) .addType(this.type) .addFee(this.maxFee.toDTO()) diff --git a/src/model/transaction/Transaction.ts b/src/model/transaction/Transaction.ts index c414bc8e78..8e6363be53 100644 --- a/src/model/transaction/Transaction.ts +++ b/src/model/transaction/Transaction.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { VerifiableTransaction } from 'nem2-library'; +import { VerifiableTransaction } from '../../infrastructure/builders/VerifiableTransaction'; import { SerializeTransactionToJSON } from '../../infrastructure/transaction/SerializeTransactionToJSON'; import { Account } from '../account/Account'; import { PublicAccount } from '../account/PublicAccount'; diff --git a/src/model/transaction/TransactionStatus.ts b/src/model/transaction/TransactionStatus.ts index 41c36e57a9..d96569d544 100644 --- a/src/model/transaction/TransactionStatus.ts +++ b/src/model/transaction/TransactionStatus.ts @@ -30,24 +30,24 @@ export class TransactionStatus { * @param height */ constructor( - /** - * The transaction status group "failed", "unconfirmed", "confirmed", etc... - */ - public readonly group: string, /** * The transaction status being the error name in case of failure and success otherwise. */ public readonly status: string, + /** + * The transaction status group "failed", "unconfirmed", "confirmed", etc... + */ + public readonly group?: string, /** * The transaction hash. */ - public readonly hash: string, + public readonly hash?: string, /** * The transaction deadline. */ - public readonly deadline: Deadline, + public readonly deadline?: Deadline, /** * The height of the block at which it was confirmed or rejected. */ - public readonly height: UInt64) {} + public readonly height?: UInt64) {} } diff --git a/src/model/transaction/TransferTransaction.ts b/src/model/transaction/TransferTransaction.ts index 5994c63f81..880374187d 100644 --- a/src/model/transaction/TransferTransaction.ts +++ b/src/model/transaction/TransferTransaction.ts @@ -14,7 +14,9 @@ * limitations under the License. */ -import { convert, TransferTransaction as TransferTransactionLibrary, VerifiableTransaction } from 'nem2-library'; +import { Convert as convert } from '../../core/format'; +import { Builder } from '../../infrastructure/builders/TransferTransaction'; +import {VerifiableTransaction} from '../../infrastructure/builders/VerifiableTransaction'; import { Address } from '../account/Address'; import { PublicAccount } from '../account/PublicAccount'; import { NetworkType } from '../blockchain/NetworkType'; @@ -134,7 +136,7 @@ export class TransferTransaction extends Transaction { * @returns {VerifiableTransaction} */ protected buildTransaction(): VerifiableTransaction { - return new TransferTransactionLibrary.Builder() + return new Builder() .addDeadline(this.deadline.toDTO()) .addFee(this.maxFee.toDTO()) .addVersion(this.versionToDTO()) diff --git a/src/model/wallet/EncryptedPrivateKey.ts b/src/model/wallet/EncryptedPrivateKey.ts index b6172679ee..ff6f21132b 100644 --- a/src/model/wallet/EncryptedPrivateKey.ts +++ b/src/model/wallet/EncryptedPrivateKey.ts @@ -14,8 +14,9 @@ * limitations under the License. */ -import {crypto} from 'nem2-library'; +import {Crypto} from '../../core/crypto'; import {Password} from './Password'; +import { WalletAlgorithm } from './WalletAlgorithm'; /** * EncryptedPrivateKey model @@ -52,7 +53,7 @@ export class EncryptedPrivateKey { encrypted: this.encryptedKey, iv: this.iv, }; - crypto.passwordToPrivatekey(common, wallet, 'pass:bip32'); + Crypto.passwordToPrivateKey(common, wallet, WalletAlgorithm.Pass_bip32); return common.privateKey; } } diff --git a/src/model/wallet/SimpleWallet.ts b/src/model/wallet/SimpleWallet.ts index 3a130134f4..f1ce97225d 100644 --- a/src/model/wallet/SimpleWallet.ts +++ b/src/model/wallet/SimpleWallet.ts @@ -15,7 +15,8 @@ */ import {LocalDateTime} from 'js-joda'; -import {convert, crypto, KeyPair, nacl_catapult} from 'nem2-library'; +import {Crypto, KeyPair} from '../../core/crypto'; +import { Convert as convert} from '../../core/format'; import {Account} from '../account/Account'; import {Address} from '../account/Address'; import {NetworkType} from '../blockchain/NetworkType'; @@ -56,7 +57,7 @@ export class SimpleWallet extends Wallet { */ public static create(name: string, password: Password, network: NetworkType): SimpleWallet { // Create random bytes - const randomBytesArray = nacl_catapult.randomBytes(32); + const randomBytesArray = Crypto.randomBytes(32); // Hash random bytes with entropy seed // Finalize and keep only 32 bytes const hashKey = convert.uint8ToHex(randomBytesArray); // TODO: derive private key correctly @@ -68,7 +69,7 @@ export class SimpleWallet extends Wallet { const address = Address.createFromPublicKey(convert.uint8ToHex(keyPair.publicKey), network); // Encrypt private key using password - const encrypted = crypto.encodePrivKey(hashKey, password.value); + const encrypted = Crypto.encodePrivateKey(hashKey, password.value); const encryptedPrivateKey = new EncryptedPrivateKey(encrypted.ciphertext, encrypted.iv); @@ -91,7 +92,7 @@ export class SimpleWallet extends Wallet { const address = Address.createFromPublicKey(convert.uint8ToHex(keyPair.publicKey), network); // Encrypt private key using password - const encrypted = crypto.encodePrivKey(privateKey, password.value); + const encrypted = Crypto.encodePrivateKey(privateKey, password.value); const encryptedPrivateKey = new EncryptedPrivateKey(encrypted.ciphertext, encrypted.iv); diff --git a/src/model/wallet/WalletAlgorithm.ts b/src/model/wallet/WalletAlgorithm.ts new file mode 100644 index 0000000000..fd7bec5a2e --- /dev/null +++ b/src/model/wallet/WalletAlgorithm.ts @@ -0,0 +1,22 @@ +/* + * Copyright 2019 NEM + * + * 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 enum WalletAlgorithm { + Pass_6k = 1, + Pass_bip32 = 2, + Pass_enc = 4, + Trezor = 3, +} diff --git a/test/core/crypto/crypto.spec.ts b/test/core/crypto/crypto.spec.ts new file mode 100644 index 0000000000..f022085c48 --- /dev/null +++ b/test/core/crypto/crypto.spec.ts @@ -0,0 +1,481 @@ +/* + * Copyright 2019 NEM + * + * 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 {expect} from 'chai'; +import {Crypto} from '../../../src/core/crypto'; +import {Convert as convert} from '../../../src/core/format'; +import { WalletAlgorithm } from '../../../src/model/model'; + +const CryptoJS = require('crypto-js'); +describe('crypto tests', () => { + it('Can derive a key from password and count', () => { + // Arrange: + const password = 'TestTest'; + const count = 20; + const expectedKey = '8cd87bc513857a7079d182a6e19b370e907107d97bd3f81a85bcebcc4b5bd3b5'; + + // Act: + const result = Crypto.derivePassSha(password, count); + + // Assert: + expect(result.priv).equal(expectedKey); + }); + + it('Can encrypt a private key', () => { + // Arrange: + const password = 'TestTest'; + const privateKey = '2a91e1d5c110a8d0105aad4683f962c2a56663a3cad46666b16d243174673d90'; + const expectedKey = '8cd87bc513857a7079d182a6e19b370e907107d97bd3f81a85bcebcc4b5bd3b5'; + + // Act: + const result = Crypto.encodePrivateKey(privateKey, password); + const pass = Crypto.derivePassSha(password, 20); + + // Assert: + expect(pass.priv).equal(expectedKey); + expect(result.iv.length).equal(16 * 2); + expect(result.ciphertext.length).equal(48 * 2); + }); + + it('Can decrypt a private key', () => { + // Arrange: + const expectedPrivateKey = '2a91e1d5c110a8d0105aad4683f962c2a56663a3cad46666b16d243174673d90'; + const key = '8cd87bc513857a7079d182a6e19b370e907107d97bd3f81a85bcebcc4b5bd3b5'; + const encrypted = 'c09ef3ed0cadd6ca6d3638b5dd854ac871a0afaec6b7fed791166b571a64d57f564376dc0180c851b0a1120b5896e6a0'; + const iv = '0329814121c7a4bb11418084dbe40560'; + const obj = { + ciphertext: CryptoJS.enc.Hex.parse(encrypted), + iv: convert.hexToUint8(iv), + key: convert.hexToUint8(key), + }; + + // Act: + const decrypted = Crypto.decrypt(obj); + + // Assert: + expect(decrypted).equal(expectedPrivateKey); + }); + + it('Can encrypt and decrypt private Key', () => { + // Arrange: + const password = 'TestTest'; + const privateKey = '2a91e1d5c110a8d0105aad4683f962c2a56663a3cad46666b16d243174673d90'; + + // Act: + const result = Crypto.encodePrivateKey(privateKey, password); + const pass = Crypto.derivePassSha(password, 20); + const obj = { + ciphertext: CryptoJS.enc.Hex.parse(result.ciphertext), + iv: convert.hexToUint8(result.iv), + key: convert.hexToUint8(pass.priv), + }; + const decrypted = Crypto.decrypt(obj); + + // Assert: + expect(privateKey).equal(decrypted); + }); + + describe('Encrypt private key edge-cases', () => { + it('Encryption throw error if no password', () => { + // Arrange: + const password = ''; + const privateKey = '2a91e1d5c110a8d0105aad4683f962c2a56663a3cad46666b16d243174673d90'; + + // Act: + const result = Crypto.encodePrivateKey.bind(null, privateKey, password); + + // Assert: + expect(result).to.throw('Missing argument !'); + }); + + it('Encryption throw error if no private key', () => { + // Arrange: + const password = 'TestTest'; + const privateKey = ''; + + // Act + const result = Crypto.encodePrivateKey.bind(null, privateKey, password); + + // Assert: + expect(result).to.throw('Missing argument !'); + }); + }); + + it('Can decrypt private key of pass:enc wallets', () => { + // Arrange: + const common = { + password: 'TestTest', + privateKey: '', + }; + const walletAccount = { + encrypted: '2e1717f245b7e1138b0dfe99dfce65b16b1c9d8ca03a9f90b86b43677b6337ce56ec474c64f73244790eb2490ad14752', + iv: 'dccffaa4883cda85d6b06714aabe6ec6', + }; + const mainAlgo = WalletAlgorithm.Pass_enc; + const expectedPrivateKey = '2a91e1d5c110a8d0105aad4683f962c2a56663a3cad46666b16d243174673d90'; + + // Act: + const result = Crypto.passwordToPrivateKey(common, walletAccount, mainAlgo); + + // Assert: + expect(result).equal(true); + expect(common.privateKey).equal(expectedPrivateKey); + }); + + it('Can decrypt private key of pass:bip32 wallets', () => { + // Arrange: + const common = { + password: 'TestTest', + privateKey: '', + }; + const walletAccount = { + encrypted: '2e1717f245b7e1138b0dfe99dfce65b16b1c9d8ca03a9f90b86b43677b6337ce56ec474c64f73244790eb2490ad14752', + iv: 'dccffaa4883cda85d6b06714aabe6ec6', + }; + const mainAlgo = WalletAlgorithm.Pass_bip32; + const expectedPrivateKey = '2a91e1d5c110a8d0105aad4683f962c2a56663a3cad46666b16d243174673d90'; + + // Act: + const result = Crypto.passwordToPrivateKey(common, walletAccount, mainAlgo); + + // Assert: + expect(result).equal(true); + expect(common.privateKey).equal(expectedPrivateKey); + }); + + it('Can decrypt private key of pass:6k wallets', () => { + // Arrange: + const common = { + password: 'TestTest', + privateKey: '', + }; + const walletAccount = { + encrypted: '', + iv: '', + }; + const mainAlgo = WalletAlgorithm.Pass_6k; + const expectedPrivateKey = '8fac70ea9aca3ae3418e25c0d31d9a0723e0a1790ae8fa97747c00dc0037472e'; + + // Act: + const result = Crypto.passwordToPrivateKey(common, walletAccount, mainAlgo); + + // Assert: + expect(result).equal(true); + expect(common.privateKey).equal(expectedPrivateKey); + }); + + it('Can decrypt private key of pass:6k wallets childs', () => { + // Arrange: + const common = { + password: 'TestTest', + privateKey: '', + }; + const walletAccount = { + encrypted: '5c3a7ebbefb391e5175a29ec5a22cb162cd590bb2e0b09416273f86bdc39fa83c04c4bb53b9c64fd1e6eaba5dba149bd', + iv: 'f131d9a4dfb1b0b696e05ccae9412e8f', + }; + const mainAlgo = WalletAlgorithm.Pass_6k; + const expectedPrivateKey = '4f27ca43521bbc394a6f6dde65b533e0768f954fa47ce320b0e9f4b5fe450f9d'; + + // Act: + const result = Crypto.passwordToPrivateKey(common, walletAccount, mainAlgo); + + // Assert: + expect(result).equal(true); + expect(common.privateKey).equal(expectedPrivateKey); + }); + + describe('Decrypt private key edge-cases', () => { + it('Private key decryption throw error if no algo', () => { + // Arrange: + const common = { + password: 'TestTest', + privateKey: '', + }; + const walletAccount = { + encrypted: '2e1717f245b7e1138b0dfe99dfce65b16b1c9d8ca03a9f90b86b43677b6337ce56ec474c64f73244790eb2490ad14752', + iv: 'dccffaa4883cda85d6b06714aabe6ec6', + }; + const mainAlgo = ''; + + // Act: + const result = Crypto.passwordToPrivateKey.bind(null, common, walletAccount, mainAlgo); + + // Assert: + expect(result).to.throw('Missing argument !'); + }); + + it('Decryption of pass:enc wallets thow error if no password', () => { + // Arrange: + const common = { + password: '', + privateKey: '', + }; + const walletAccount = { + encrypted: '2e1717f245b7e1138b0dfe99dfce65b16b1c9d8ca03a9f90b86b43677b6337ce56ec474c64f73244790eb2490ad14752', + iv: 'dccffaa4883cda85d6b06714aabe6ec6', + }; + const mainAlgo = WalletAlgorithm.Pass_enc; + + // Act: + const result = Crypto.passwordToPrivateKey.bind(null, common, walletAccount, mainAlgo); + + // Assert: + expect(result).to.throw('Missing argument !'); + }); + + it('Decryption of pass:bip32 wallets throw error if no password', () => { + // Arrange: + const common = { + password: '', + privateKey: '', + }; + const walletAccount = { + encrypted: '2e1717f245b7e1138b0dfe99dfce65b16b1c9d8ca03a9f90b86b43677b6337ce56ec474c64f73244790eb2490ad14752', + iv: 'dccffaa4883cda85d6b06714aabe6ec6', + }; + const mainAlgo = WalletAlgorithm.Pass_bip32; + + // Act: + const result = Crypto.passwordToPrivateKey.bind(null, common, walletAccount, mainAlgo); + + // Assert: + expect(result).to.throw('Missing argument !'); + }); + + it('Decryption of pass:6k wallets throw error if no password', () => { + // Arrange: + const common = { + password: '', + privateKey: '', + }; + const walletAccount = { + encrypted: '2e1717f245b7e1138b0dfe99dfce65b16b1c9d8ca03a9f90b86b43677b6337ce56ec474c64f73244790eb2490ad14752', + iv: 'dccffaa4883cda85d6b06714aabe6ec6', + }; + const mainAlgo = WalletAlgorithm.Pass_6k; + + // Act: + const result = Crypto.passwordToPrivateKey.bind(null, common, walletAccount, mainAlgo); + + // Assert: + expect(result).to.throw('Missing argument !'); + }); + + it('Decryption of pass:6k wallets generate a private key if no encrypted and iv in wallet account', () => { + // Arrange: + const common = { + password: 'TestTest', + privateKey: '', + }; + const walletAccount = { + encrypted: '', + iv: '', + }; + const mainAlgo = WalletAlgorithm.Pass_6k; + const expectedPrivateKey = '8fac70ea9aca3ae3418e25c0d31d9a0723e0a1790ae8fa97747c00dc0037472e'; + + // Act: + const result = Crypto.passwordToPrivateKey(common, walletAccount, mainAlgo); + + // Assert: + expect(result).equal(true); + expect(common.privateKey).equal(expectedPrivateKey); + }); + + it('Decryption of pass:6k wallets return false if encrypted data but no iv', () => { + // Arrange: + const common = { + password: 'TestTest', + privateKey: '', + }; + const walletAccount = { + encrypted: '2e1717f245b7e1138b0dfe99dfce65b16b1c9d8ca03a9f90b86b43677b6337ce56ec474c64f73244790eb2490ad14752', + iv: '', + }; + const mainAlgo = WalletAlgorithm.Pass_6k; + + // Act: + const result = Crypto.passwordToPrivateKey(common, walletAccount, mainAlgo); + + // Assert: + expect(result).equal(false); + expect(common.privateKey).equal(''); + }); + + it('Decryption of pass:6k wallets return false if no encrypted data but iv', () => { + // Arrange: + const common = { + password: 'TestTest', + privateKey: '', + }; + const walletAccount = { + encrypted: '', + iv: 'dccffaa4883cda85d6b06714aabe6ec6', + }; + const mainAlgo = WalletAlgorithm.Pass_6k; + + // Act: + const result = Crypto.passwordToPrivateKey(common, walletAccount, mainAlgo); + + // Assert: + expect(result).equal(false); + expect(common.privateKey).equal(''); + }); + }); + + it('Can encode and decode message', () => { + const senderPriv = 'E1C8521608F4896CA26A0C2DE739310EA4B06861D126CF4D6922064678A1969B'; + const recipientPublic = '12AAD2D33020C3EAE12592875CD7D2FF54A61DD03C1FAADB84A083D41F75C229'; + const message = 'NEM is awesome !'; + const encryptedMessage = Crypto.encode(senderPriv, recipientPublic, message); + const senderPublic = '9F784BF20318AE3CA6246C0EC2207FE095FFF7A84B6787E7E3C2CE4C3B92A2EA'; + const recipientPriv = 'A22A4BBF126A2D7D7ECE823174DFD184C5DE0FDE4CB2075D30CFA409F7EF8908'; + const expectedMessage = 'NEM is awesome !'; + const decrypted = Crypto.decode(recipientPriv, senderPublic, encryptedMessage); + + expect(decrypted).equal(convert.utf8ToHex(expectedMessage)); + }); + + it('Can encode a message and failed decode with wrong key', () => { + const senderPriv = 'E1C8521608F4896CA26A0C2DE739310EA4B06861D126CF4D6922064678A1969B'; + const recipientPublic = '12AAD2D33020C3EAE12592875CD7D2FF54A61DD03C1FAADB84A083D41F75C229'; + const message = 'NEM is awesome !'; + const encryptedMessage = Crypto.encode(senderPriv, recipientPublic, message); + const senderPublic = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const recipientPriv = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const expectedMessage = 'NEM is awesome !'; + const decrypted = Crypto.decode(recipientPriv, senderPublic, encryptedMessage); + + expect(decrypted).not.equal(convert.utf8ToHex(expectedMessage)); + }); + + describe('Encode & decode message edge-cases', () => { + it('Message encoding throw error if no sender private key', () => { + // Arrange: + const senderPriv = ''; + const recipientPublic = '2618090794e9c9682f2ac6504369a2f4fb9fe7ee7746f9560aca228d355b1cb9'; + const message = 'NEM is awesome !'; + + // Act: + const result = Crypto.encode.bind(null, senderPriv, recipientPublic, message); + + // Assert: + expect(result).to.throw(); + }); + + it('Message encoding throw error if no recipient public key', () => { + // Arrange: + const senderPriv = '2a91e1d5c110a8d0105aad4683f962c2a56663a3cad46666b16d243174673d90'; + const recipientPublic = ''; + const message = 'NEM is awesome !'; + + // Act: + const result = Crypto.encode.bind(null, senderPriv, recipientPublic, message); + + // Assert: + expect(result).to.throw(); + }); + + it('Message encoding throw error if no message', () => { + // Arrange: + const senderPriv = '2a91e1d5c110a8d0105aad4683f962c2a56663a3cad46666b16d243174673d90'; + const recipientPublic = '2618090794e9c9682f2ac6504369a2f4fb9fe7ee7746f9560aca228d355b1cb9'; + const message = ''; + + // Act: + const result = Crypto.encode.bind(null, senderPriv, recipientPublic, message); + + // Assert: + expect(result).to.throw(); + }); + + it('Message decoding throw error if no recipient private key', () => { + // Arrange: + const senderPublic = '9291abb3c52134be9d20ef21a796743497df7776d2661237bda9cadade34e44c'; + const recipientPriv = ''; + const message = 'NEM is awesome !'; + const encryptedMessage = 'dd31d6b4111c1023bae6533399e74f73a29c6e6b48ab550f8a7bea127e27ddd' + + 'b4fd3fe4fad3c835307c0da52d9c268f56237d1810e07912e6a6568cba09d9a9176ee6b1ade9569c2e1e273e9675bd4ff'; + + // Act: + const result = Crypto.decode.bind(null, recipientPriv, senderPublic, encryptedMessage); + + // Assert: + expect(result).to.throw(); + }); + + it('Message decoding throw error if no sender public key', () => { + // Arrange: + const senderPublic = ''; + const recipientPriv = '2618090794e9c9682f2ac6504369a2f4fb9fe7ee7746f9560aca228d355b1cb9'; + const message = 'NEM is awesome !'; + const encryptedMessage = 'dd31d6b4111c1023bae6533399e74f73a29c6e6b48ab550f8a7bea127e27ddd' + + 'b4fd3fe4fad3c835307c0da52d9c268f56237d1810e07912e6a6568cba09d9a9176ee6b1ade9569c2e1e273e9675bd4ff'; + + // Act: + const result = Crypto.decode.bind(null, recipientPriv, senderPublic, encryptedMessage); + + // Assert: + expect(result).to.throw(); + }); + + it('Message decoding throw error if no payload', () => { + // Arrange: + const senderPublic = '9291abb3c52134be9d20ef21a796743497df7776d2661237bda9cadade34e44c'; + const recipientPriv = '2618090794e9c9682f2ac6504369a2f4fb9fe7ee7746f9560aca228d355b1cb9'; + const message = 'NEM is awesome !'; + const encryptedMessage = ''; + + // Act: + const result = Crypto.decode.bind(null, recipientPriv, senderPublic, encryptedMessage); + + // Assert: + expect(result).to.throw(); + }); + }); + + it('Can encrypt and decrypt private key for mobile', () => { + // Arrange: + const privateKey = '2a91e1d5c110a8d0105aad4683f962c2a56663a3cad46666b16d243174673d90'; + const password = 'TestTest'; + + // Act: + const result = Crypto.toMobileKey(password, privateKey); + const encrypted = result.encrypted; + const salt = CryptoJS.enc.Hex.parse(result.salt); + + const key = CryptoJS.PBKDF2(password, salt, { + keySize: 256 / 32, + iterations: 2000, + }); + + const iv = encrypted.substring(0, 32); + const encryptedPrvKey = encrypted.substring(32, 128); + + const obj = { + ciphertext: CryptoJS.enc.Hex.parse(encryptedPrvKey), + iv: convert.hexToUint8(iv), + key: convert.hexToUint8(key.toString()), + }; + + const decrypted = Crypto.decrypt(obj); + + // Assert: + expect(encrypted.length).equal(128); + expect(salt.toString().length).equal(32 * 2); + expect(decrypted).equal(privateKey); + }); +}); diff --git a/test/core/crypto/keyPair.spec.ts b/test/core/crypto/keyPair.spec.ts new file mode 100644 index 0000000000..8f4d9af157 --- /dev/null +++ b/test/core/crypto/keyPair.spec.ts @@ -0,0 +1,420 @@ +/* + * Copyright 2019 NEM + * + * 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 {expect} from 'chai'; +import {Crypto, KeyPair} from '../../../src/core/crypto'; +import {Convert as convert} from '../../../src/core/format'; + +describe('key pair', () => { + const randomKeyPair = () => KeyPair.createKeyPairFromPrivateKeyString(convert.uint8ToHex(Crypto.randomBytes(32))); + const Private_Key_Size = 32; + const Signature_Size = 64; + + const Private_Keys = [ + '8D31B712AB28D49591EAF5066E9E967B44507FC19C3D54D742F7B3A255CFF4AB', + '15923F9D2FFFB11D771818E1F7D7DDCD363913933264D58533CB3A5DD2DAA66A', + 'A9323CEF24497AB770516EA572A0A2645EE2D5A75BC72E78DE534C0A03BC328E', + 'D7D816DA0566878EE739EDE2131CD64201BCCC27F88FA51BA5815BCB0FE33CC8', + '27FC9998454848B987FAD89296558A34DEED4358D1517B953572F3E0AAA0A22D', + ]; + + describe('construction', () => { + it('can extract from private key test vectors', () => { + // Arrange: + const Expected_Public_Keys = [ + '53C659B47C176A70EB228DE5C0A0FF391282C96640C2A42CD5BBD0982176AB1B', + '3FE4A1AA148F5E76891CE924F5DC05627A87047B2B4AD9242C09C0ECED9B2338', + 'F398C0A2BDACDBD7037D2F686727201641BBF87EF458F632AE2A04B4E8F57994', + '6A283A241A8D8203B3A1E918B1E6F0A3E14E75E16D4CFFA45AE4EF89E38ED6B5', + '4DC62B38215826438DE2369743C6BBE6D13428405025DFEFF2857B9A9BC9D821', + ]; + + // Sanity: + expect(Private_Keys.length).equal(Expected_Public_Keys.length); + + for (let i = 0; i < Private_Keys.length; ++i) { + // Arrange: + const privateKeyHex = Private_Keys[i]; + const expectedPublicKey = Expected_Public_Keys[i]; + + // Act: + const keyPair = KeyPair.createKeyPairFromPrivateKeyString(privateKeyHex); + + // Assert: + const message = ` from ${privateKeyHex}`; + expect(convert.uint8ToHex(keyPair.publicKey), `public ${message}`).equal(expectedPublicKey); + expect(convert.uint8ToHex(keyPair.privateKey), `private ${message}`).equal(privateKeyHex); + } + }); + + it('cannot extract from invalid private key', () => { + // Arrange: + const invalidPrivateKeys = [ + '', // empty + '53C659B47C176A70EB228DE5C0A0FF391282C96640C2A42CD5BBD0982176AB', // short + '53C659B47C176A70EB228DE5C0A0FF391282C96640C2A42CD5BBD0982176AB1BBB', // long + ]; + + // Act: + invalidPrivateKeys.forEach((privateKey) => { + // Assert: + expect(() => { + KeyPair.createKeyPairFromPrivateKeyString(privateKey); + }, `from ${privateKey}`) + .to.throw('private key has unexpected size'); + }); + }); + }); + + describe('sign', () => { + it('fills the signature', () => { + // Arrange: + const keyPair = randomKeyPair(); + const payload = Crypto.randomBytes(100); + + // Act: + const signature = KeyPair.sign(keyPair, payload); + + // Assert: + expect(signature).to.not.deep.equal(new Uint8Array(Signature_Size)); + }); + + it('returns same signature for same data signed by same key pairs', () => { + // Arrange: + const privateKey = convert.uint8ToHex(Crypto.randomBytes(Private_Key_Size)); + const keyPair1 = KeyPair.createKeyPairFromPrivateKeyString(privateKey); + const keyPair2 = KeyPair.createKeyPairFromPrivateKeyString(privateKey); + const payload = Crypto.randomBytes(100); + + // Act: + const signature1 = KeyPair.sign(keyPair1, payload); + const signature2 = KeyPair.sign(keyPair2, payload); + + // Assert: + expect(signature2).to.deep.equal(signature1); + }); + + it('returns different signature for same data signed by different key pairs', () => { + // Arrange: + const keyPair1 = randomKeyPair(); + const keyPair2 = randomKeyPair(); + const payload = Crypto.randomBytes(100); + + // Act: + const signature1 = KeyPair.sign(keyPair1, payload); + const signature2 = KeyPair.sign(keyPair2, payload); + + // Assert: + expect(signature2).to.not.deep.equal(signature1); + }); + + it('cannot sign unsupported data type', () => { + // Arrange: + const keyPair = KeyPair.createKeyPairFromPrivateKeyString(Private_Keys[0]); + + // Assert: + expect(() => { + KeyPair.sign(keyPair, {}); + }).to.throw('unsupported data type'); + }); + }); + + describe('verify', () => { + it('returns true for data signed with same key pair', () => { + // Arrange: + const keyPair = randomKeyPair(); + const payload = Crypto.randomBytes(100); + const signature = KeyPair.sign(keyPair, payload); + + // Act: + const isVerified = KeyPair.verify(keyPair.publicKey, payload, signature); + + // Assert: + expect(isVerified).to.equal(true); + }); + + it('returns false for data signed with different key pair', () => { + // Arrange: + const keyPair1 = randomKeyPair(); + const keyPair2 = randomKeyPair(); + const payload = Crypto.randomBytes(100); + const signature = KeyPair.sign(keyPair1, payload); + + // Act: + const isVerified = KeyPair.verify(keyPair2.publicKey, payload, signature); + + // Assert: + expect(isVerified).to.equal(false); + }); + + it('returns false if signature has been modified', () => { + // Arrange: + const keyPair = randomKeyPair(); + const payload = Crypto.randomBytes(100); + + for (let i = 0; i < Signature_Size; i += 4) { + const signature = KeyPair.sign(keyPair, payload); + signature[i] ^= 0xFF; + + // Act: + const isVerified = KeyPair.verify(keyPair.publicKey, payload, signature); + + // Assert: + expect(isVerified, `signature modified at ${i}`).to.equal(false); + } + }); + + it('returns false if payload has been modified', () => { + // Arrange: + const keyPair = randomKeyPair(); + const payload = Crypto.randomBytes(44); + + for (let i = 0; i < payload.length; i += 4) { + const signature = KeyPair.sign(keyPair, payload); + payload[i] ^= 0xFF; + + // Act: + const isVerified = KeyPair.verify(keyPair.publicKey, payload, signature); + + // Assert: + expect(isVerified, `payload modified at ${i}`).to.equal(false); + } + }); + + it('fails if public key is not on curve', () => { + // Arrange: + const keyPair = randomKeyPair(); + keyPair.publicKey.fill(0); + keyPair.publicKey[keyPair.publicKey.length - 1] = 1; + + const payload = Crypto.randomBytes(100); + const signature = KeyPair.sign(keyPair, payload); + + // Act: + const isVerified = KeyPair.verify(keyPair.publicKey, payload, signature); + + // Assert: + expect(isVerified).to.equal(false); + }); + + it('fails if public key does not correspond to private key', () => { + // Arrange: + const keyPair = randomKeyPair(); + const payload = Crypto.randomBytes(100); + const signature = KeyPair.sign(keyPair, payload); + + for (let i = 0; i < keyPair.publicKey.length; ++i) { + keyPair.publicKey[i] ^= 0xFF; + } + + // Act: + const isVerified = KeyPair.verify(keyPair.publicKey, payload, signature); + + // Assert: + expect(isVerified).to.equal(false); + }); + + it('rejects zero public key', () => { + // Arrange: + const keyPair = randomKeyPair(); + keyPair.publicKey.fill(0); + + const payload = Crypto.randomBytes(100); + const signature = KeyPair.sign(keyPair, payload); + + // Act: + const isVerified = KeyPair.verify(keyPair.publicKey, payload, signature); + + // Assert: + expect(isVerified).to.equal(false); + }); + + it('cannot verify non canonical signature', () => { + function scalarAddGroupOrder(scalar) { + // 2^252 + 27742317777372353535851937790883648493, little endian + const Group_Order = [ + 0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, + ]; + + let r = 0; + for (let i = 0; i < scalar.length; ++i) { + const t = scalar[i] + Group_Order[i]; + scalar[i] += Group_Order[i] + r; + r = (t >> 8) & 0xFF; + } + } + + // Arrange: + const keyPair = randomKeyPair(); + const payload = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]); + const canonicalSignature = KeyPair.sign(keyPair, payload); + + // this is signature with group order added to 'encodedS' part of signature + const nonCanonicalSignature = canonicalSignature.slice(); + scalarAddGroupOrder(nonCanonicalSignature.subarray(32)); + + // Act: + const isCanonicalVerified = KeyPair.verify(keyPair.publicKey, payload, canonicalSignature); + const isNonCanonicalVerified = KeyPair.verify(keyPair.privateKey, payload, nonCanonicalSignature); + + // Assert: + expect(isCanonicalVerified).to.equal(true); + expect(isNonCanonicalVerified).to.equal(false); + }); + }); + + describe('test vectors', () => { + const Input_Data = [ + '8ce03cd60514233b86789729102ea09e867fc6d964dea8c2018ef7d0a2e0e24bf7e348e917116690b9', + 'e4a92208a6fc52282b620699191ee6fb9cf04daf48b48fd542c5e43daa9897763a199aaa4b6f10546109f47ac3564fade0', + '13ed795344c4448a3b256f23665336645a853c5c44dbff6db1b9224b5303b6447fbf8240a2249c55', + 'a2704638434e9f7340f22d08019c4c8e3dbee0df8dd4454a1d70844de11694f4c8ca67fdcb08fed0cec9abb2112b5e5f89', + 'd2488e854dbcdfdb2c9d16c8c0b2fdbc0abb6bac991bfe2b14d359a6bc99d66c00fd60d731ae06d0', + ]; + const Expected_Signatures = [ + 'C9B1342EAB27E906567586803DA265CC15CCACA411E0AEF44508595ACBC47600D0' + + '2527F2EED9AB3F28C856D27E30C3808AF7F22F5F243DE698182D373A9ADE03', + '0755E437ED4C8DD66F1EC29F581F6906AB1E98704ECA94B428A25937DF00EC6479' + + '6F08E5FEF30C6F6C57E4A5FB4C811D617FA661EB6958D55DAE66DDED205501', + '15D6585A2A456E90E89E8774E9D12FE01A6ACFE09936EE41271AA1FBE0551264A9' + + 'FF9329CB6FEE6AE034238C8A91522A6258361D48C5E70A41C1F1C51F55330D', + 'F6FB0D8448FEC0605CF74CFFCC7B7AE8D31D403BCA26F7BD21CB4AC87B00769E9C' + + 'C7465A601ED28CDF08920C73C583E69D621BA2E45266B86B5FCF8165CBE309', + 'E88D8C32FE165D34B775F70657B96D8229FFA9C783E61198A6F3CCB92F487982D0' + + '8F8B16AB9157E2EFC3B78F126088F585E26055741A9F25127AC13E883C9A05', + ]; + + function assertCanSignTestVectors(dataTransform) { + // Sanity: + expect(Private_Keys.length).equal(Input_Data.length); + expect(Private_Keys.length).equal(Expected_Signatures.length); + + for (let i = 0; i < Private_Keys.length; ++i) { + // Arrange: + const inputData = dataTransform(Input_Data[i]); + const keyPair = KeyPair.createKeyPairFromPrivateKeyString(Private_Keys[i]); + + // Act: + const signature = KeyPair.sign(keyPair, inputData); + + // Assert: + const message = `signing with ${Private_Keys[i]}`; + expect(convert.uint8ToHex(signature), message).equal(Expected_Signatures[i]); + } + } + + it('can sign test vectors as hex string', () => { + // Assert: + assertCanSignTestVectors((data) => data); + }); + + it('can sign test vectors as binary', () => { + // Assert: + assertCanSignTestVectors((data) => convert.hexToUint8(data)); + }); + + function assertCanVerifyTestVectors(dataTransform) { + // Sanity: + expect(Private_Keys.length).equal(Input_Data.length); + expect(Private_Keys.length).equal(Expected_Signatures.length); + + for (let i = 0; i < Private_Keys.length; ++i) { + // Arrange: + const inputData = dataTransform(Input_Data[i]); + const keyPair = KeyPair.createKeyPairFromPrivateKeyString(Private_Keys[i]); + const signature = KeyPair.sign(keyPair, inputData); + + // Act: + const isVerified = KeyPair.verify(keyPair.publicKey, inputData, signature); + + // Assert: + const message = `verifying with ${Private_Keys[i]}`; + expect(isVerified, message).equal(true); + } + } + + it('can verify test vectors as hex string', () => { + // Assert: + assertCanVerifyTestVectors((data) => data); + }); + + it('can verify test vectors as binary', () => { + // Assert: + assertCanVerifyTestVectors((data) => convert.hexToUint8(data)); + }); + }); + + describe('derive shared key', () => { + const Salt_Size = 32; + + it('fails if salt is wrong size', () => { + // Arrange: create a salt that is too long + const keyPair = randomKeyPair(); + const publicKey = Crypto.randomBytes(32); + const salt = Crypto.randomBytes(Salt_Size + 1); + + // Act: + expect(() => { + KeyPair.deriveSharedKey(keyPair, publicKey, salt); + }) + .to.throw('salt has unexpected size'); + }); + + it('derives same shared key for both partners', () => { + // Arrange: + const keyPair1 = randomKeyPair(); + const keyPair2 = randomKeyPair(); + const salt = Crypto.randomBytes(Salt_Size); + + // Act: + const sharedKey1 = KeyPair.deriveSharedKey(keyPair1, keyPair2.publicKey, salt); + const sharedKey2 = KeyPair.deriveSharedKey(keyPair2, keyPair1.publicKey, salt); + + // Assert: + expect(sharedKey1).to.deep.equal(sharedKey2); + }); + + it('derives different shared keys for different partners', () => { + // Arrange: + const keyPair = randomKeyPair(); + const publicKey1 = Crypto.randomBytes(32); + const publicKey2 = Crypto.randomBytes(32); + const salt = Crypto.randomBytes(Salt_Size); + + // Act: + const sharedKey1 = KeyPair.deriveSharedKey(keyPair, publicKey1, salt); + const sharedKey2 = KeyPair.deriveSharedKey(keyPair, publicKey2, salt); + + // Assert: + expect(sharedKey1).to.not.deep.equal(sharedKey2); + }); + + it('can derive deterministic shared key from well known inputs', () => { + // Arrange: + const privateKey = convert.hexToUint8('8F545C2816788AB41D352F236D80DBBCBC34705B5F902EFF1F1D88327C7C1300'); + const publicKey = convert.hexToUint8('BF684FB1A85A8C8091EE0442EDDB22E51683802AFA0C0E7C6FE3F3E3E87A8D72'); + const salt = convert.hexToUint8('422C39DF16AAE42A74A5597D6EE2D59CFB4EEB6B3F26D98425B9163A03DAA3B5'); + + // Act: + const sharedKey = KeyPair.deriveSharedKey({ + privateKey, + }, publicKey, salt); + + // Assert: + expect(convert.uint8ToHex(sharedKey)).to.equal('FF9623D28FBC13B6F0E0659117FC7BE294DB3385C046055A6BAC39EDF198D50D'); + }); + }); +}); diff --git a/test/core/crypto/sha3Hasher.spec.ts b/test/core/crypto/sha3Hasher.spec.ts new file mode 100644 index 0000000000..4f9b731238 --- /dev/null +++ b/test/core/crypto/sha3Hasher.spec.ts @@ -0,0 +1,150 @@ +/* + * Copyright 2019 NEM + * + * 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 {expect} from 'chai'; +import {SHA3Hasher as sha3Hasher} from '../../../src/core/crypto/SHA3Hasher'; +import {Convert as convert} from '../../../src/core/format'; + +describe('hasher', () => { + const inputs = [ + '', + 'CC', + '41FB', + '1F877C', + 'C1ECFDFC', + '9F2FCC7C90DE090D6B87CD7E9718C1EA6CB21118FC2D5DE9F97E5DB6AC1E9C10' + ]; + + function addSha3Tests(length, expectedOutputs) { + describe('func', () => { + it('can hash test vectors', () => { + // Sanity: + expect(expectedOutputs.length).equal(inputs.length); + + for (let i = 0; i < inputs.length; ++i) { + // Arrange: + const inputHex = inputs[i]; + const inputBuffer = convert.hexToUint8(inputHex); + const expectedHash = expectedOutputs[i]; + + // Act: + const hash = new Uint8Array(length); + sha3Hasher.func(hash, inputBuffer, length); + + // Assert: + expect(convert.uint8ToHex(hash), `hashing ${inputHex}`).equal(expectedHash); + } + }); + }); + + describe('object', () => { + it('can hash test vectors', () => { + // Sanity: + expect(expectedOutputs.length).equal(inputs.length); + + for (let i = 0; i < inputs.length; ++i) { + // Arrange: + const inputHex = inputs[i]; + const inputBuffer = convert.hexToUint8(inputHex); + const expectedHash = expectedOutputs[i]; + + const hasher = sha3Hasher.createHasher(length); + hasher.reset(); + + // Act: hash the input in two parts + hasher.update(inputBuffer.subarray(0, inputBuffer.length / 2)); + hasher.update(inputBuffer.subarray(inputBuffer.length / 2)); + + const hash = new Uint8Array(length); + hasher.finalize(hash); + + // Assert: + expect(convert.uint8ToHex(hash), `hashing ${inputHex}`).equal(expectedHash); + } + }); + + it('can hash string', () => { + // Arrange: + const inputHex = inputs[3]; + const expectedHash = expectedOutputs[3]; + + const hasher = sha3Hasher.createHasher(length); + hasher.reset(); + + // Act: + hasher.update(inputHex); + + const hash = new Uint8Array(length); + hasher.finalize(hash); + + // Assert: + expect(convert.uint8ToHex(hash), `hashing ${inputHex}`).equal(expectedHash); + }); + + it('cannot hash unsupported data type', () => { + // Arrange: + const hasher = sha3Hasher.createHasher(length); + hasher.reset(); + + // Act: + expect(() => hasher.update({})).to.throw('unsupported data type'); + }); + + it('can reuse after reset', () => { + // Arrange: + const inputHex = inputs[3]; + const expectedHash = expectedOutputs[3]; + + const hasher = sha3Hasher.createHasher(length); + hasher.reset(); + hasher.update('ABCD'); + + // Act: + hasher.reset(); + hasher.update(inputHex); + + const hash = new Uint8Array(length); + hasher.finalize(hash); + + // Assert: + expect(convert.uint8ToHex(hash), `hashing ${inputHex}`).equal(expectedHash); + }); + }); + } + + describe('sha3 256', () => { + // https://github.com/gvanas/KeccakCodePackage/blob/master/TestVectors/ShortMsgKAT_SHA3-256.txt + addSha3Tests(32, [ + 'A7FFC6F8BF1ED76651C14756A061D662F580FF4DE43B49FA82D80A4B80F8434A', + '677035391CD3701293D385F037BA32796252BB7CE180B00B582DD9B20AAAD7F0', + '39F31B6E653DFCD9CAED2602FD87F61B6254F581312FB6EEEC4D7148FA2E72AA', + 'BC22345E4BD3F792A341CF18AC0789F1C9C966712A501B19D1B6632CCD408EC5', + 'C5859BE82560CC8789133F7C834A6EE628E351E504E601E8059A0667FF62C124', + '2F1A5F7159E34EA19CDDC70EBF9B81F1A66DB40615D7EAD3CC1F1B954D82A3AF' + ]); + }); + + describe('sha3 512', () => { + // https://github.com/gvanas/KeccakCodePackage/blob/master/TestVectors/ShortMsgKAT_SHA3-512.txt + addSha3Tests(64, [ + 'A69F73CCA23A9AC5C8B567DC185A756E97C982164FE25859E0D1DCC1475C80A615B2123AF1F5F94C11E3E9402C3AC558F500199D95B6D3E301758586281DCD26', + '3939FCC8B57B63612542DA31A834E5DCC36E2EE0F652AC72E02624FA2E5ADEECC7DD6BB3580224B4D6138706FC6E80597B528051230B00621CC2B22999EAA205', + 'AA092865A40694D91754DBC767B5202C546E226877147A95CB8B4C8F8709FE8CD6905256B089DA37896EA5CA19D2CD9AB94C7192FC39F7CD4D598975A3013C69', + 'CB20DCF54955F8091111688BECCEF48C1A2F0D0608C3A575163751F002DB30F40F2F671834B22D208591CFAF1F5ECFE43C49863A53B3225BDFD7C6591BA7658B', + 'D4B4BDFEF56B821D36F4F70AB0D231B8D0C9134638FD54C46309D14FADA92A2840186EED5415AD7CF3969BDFBF2DAF8CCA76ABFE549BE6578C6F4143617A4F1A', + 'B087C90421AEBF87911647DE9D465CBDA166B672EC47CCD4054A7135A1EF885E7903B52C3F2C3FE722B1C169297A91B82428956A02C631A2240F12162C7BC726' + ]); + }); +}); diff --git a/test/core/format/Base32.spec.ts b/test/core/format/Base32.spec.ts new file mode 100644 index 0000000000..ff414f02f9 --- /dev/null +++ b/test/core/format/Base32.spec.ts @@ -0,0 +1,188 @@ +/* + * Copyright 2019 NEM + * + * 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 {expect} from 'chai'; +import {Convert as convert} from '../../../src/core/format'; +import {Base32 as base32} from '../../../src/core/format/Base32'; + +describe('base32', () => { + const Test_Vectors = [{ + decoded: '68BA9E8D1AA4502E1F73DA19784B5D7DA16CA1E4AF895FAC12', + encoded: 'NC5J5DI2URIC4H3T3IMXQS25PWQWZIPEV6EV7LAS' + }, + { + decoded: '684C2605E5B366BB94BC30755EC9F50D74E80FC9283D20E283', + encoded: 'NBGCMBPFWNTLXFF4GB2V5SPVBV2OQD6JFA6SBYUD' + }, + { + decoded: '68D7B09A14BEA7CE060E71C0FA9AC9B4226DE167013DE10B3D', + encoded: 'NDL3BGQUX2T44BQOOHAPVGWJWQRG3YLHAE66CCZ5' + }, + { + decoded: '686C44C024F1089669F53C45AC6D62CC17A0D9CBA67A6205E6', + encoded: 'NBWEJQBE6EEJM2PVHRC2Y3LCZQL2BWOLUZ5GEBPG' + }, + { + decoded: '98A0FE84BBFC5EEE7CADC2B12F790DAA4A7A9505096E674FAB', + encoded: 'TCQP5BF37RPO47FNYKYS66INVJFHVFIFBFXGOT5L' + } + ]; + + describe('encode', () => { + it('can convert empty input', () => { + // Act: + const encoded = base32.Base32Encode(new Uint8Array([])); + + // Assert: + expect(encoded).to.equal(''); + }); + + it('can convert test vectors', () => { + // Arrange: + for (const sample of Test_Vectors) { + const input = convert.hexToUint8(sample.decoded); + + // Act: + const encoded = base32.Base32Encode(input); + + // Assert: + expect(encoded, `input ${sample.decoded}`).to.equal(sample.encoded); + } + }); + + it('accepts all byte values', () => { + // Arrange: + const data: any = []; + for (let i = 0; 260 > i; ++i) { + data.push(i & 0xFF); + } + + // Act: + const encoded = base32.Base32Encode(data); + + // Assert: + const expected = + 'AAAQEAYEAUDAOCAJBIFQYDIOB4IBCEQTCQKRMFYY' + + 'DENBWHA5DYPSAIJCEMSCKJRHFAUSUKZMFUXC6MBR' + + 'GIZTINJWG44DSOR3HQ6T4P2AIFBEGRCFIZDUQSKK' + + 'JNGE2TSPKBIVEU2UKVLFOWCZLJNVYXK6L5QGCYTD' + + 'MRSWMZ3INFVGW3DNNZXXA4LSON2HK5TXPB4XU634' + + 'PV7H7AEBQKBYJBMGQ6EITCULRSGY5D4QSGJJHFEV' + + 'S2LZRGM2TOOJ3HU7UCQ2FI5EUWTKPKFJVKV2ZLNO' + + 'V6YLDMVTWS23NN5YXG5LXPF5X274BQOCYPCMLRWH' + + 'ZDE4VS6MZXHM7UGR2LJ5JVOW27MNTWW33TO55X7A' + + '4HROHZHF43T6R2PK5PWO33XP6DY7F47U6X3PP6HZ' + + '7L57Z7P674AACAQD'; + expect(encoded).to.equal(expected); + }); + + it('throws if input size is not a multiple of block size', () => { + // Arrange: + for (let i = 2; 10 > i; i += 2) { + const input = new Uint8Array(i); + + // Act + Assert: + expect(() => { + base32.Base32Encode(input); + }, `input at ${i}`).to.throw('decoded size must be multiple of 5'); + } + }); + }); + + describe('decode', () => { + it('can convert empty input', () => { + // Act: + const decoded = base32.Base32Decode(''); + + // Assert: + expect(convert.uint8ToHex(decoded)).to.equal(''); + }); + + it('can convert test vectors', () => { + // Arrange: + for (const sample of Test_Vectors) { + // Act: + const decoded = base32.Base32Decode(sample.encoded); + + // Assert: + expect(convert.uint8ToHex(decoded), `input ${sample.encoded}`).to.equal(sample.decoded); + } + }); + + it('accepts all valid characters', () => { + // Act: + const decoded = base32.Base32Decode('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'); + + // Assert: + expect(convert.uint8ToHex(decoded)).to.equal('00443214C74254B635CF84653A56D7C675BE77DF'); + }); + + it('throws if input size is not a multiple of block size', () => { + // Arrange: + for (let i = 1; 8 > i; ++i) { + const input = 'A'.repeat(i); + + // Act + Assert: + expect(() => { + base32.Base32Decode(input); + }, `input at ${i}`).to.throw('encoded size must be multiple of 8'); + } + }); + + it('throws if input contains an invalid character', () => { + // Arrange: + const illegalInputs = [ + 'NC5J5DI2URIC4H3T3IMXQS21PWQWZIPEV6EV7LAS', // contains char '1' + 'NBGCMBPFWNTLXFF4GB2V5SPV!V2OQD6JFA6SBYUD', // contains char '!' + 'NDL3BGQUX2T44BQOOHAPVGWJWQRG3YLHAE)6CCZ5' // contains char ')' + ]; + + // Act + Assert: + for (const input of illegalInputs) { + expect(() => { + base32.Base32Decode(input); + }, `input ${input}`).to.throw('illegal base32 character'); + } + }); + }); + + describe('roundtrip', () => { + it('decode -> encode', () => { + // Arrange: inputs + const inputs = ['BDS73DQ5NC33MKYI3K6GXLJ53C2HJ35A', '46FNYP7T4DD3SWAO6C4NX62FJI5CBA26']; + for (const input of inputs) { + // Act: + const decoded = base32.Base32Decode(input); + const result = base32.Base32Encode(decoded); + + // Assert: + expect(result, `input ${input}`).to.equal(input); + } + }); + + it('encode -> decode', () => { + // Arrange: inputs + const inputs = ['8A4E7DF5B61CC0F97ED572A95F6ACA', '2D96E4ABB65F0AD3C29FEA48C132CE']; + for (const input of inputs) { + // Act: + const encoded = base32.Base32Encode(convert.hexToUint8(input)); + const result = base32.Base32Decode(encoded); + + // Assert: + expect(convert.uint8ToHex(result), `input ${input}`).to.equal(input); + } + }); + }); +}); diff --git a/test/core/format/Convert.spec.ts b/test/core/format/Convert.spec.ts new file mode 100644 index 0000000000..d40aa5b8b0 --- /dev/null +++ b/test/core/format/Convert.spec.ts @@ -0,0 +1,352 @@ +/* + * Copyright 2019 NEM + * + * 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 {expect} from 'chai'; +import {Convert as convert} from '../../../src/core/format'; + +describe('convert', () => { + describe('toByte', () => { + it('can convert all valid hex char combinations to byte', () => { + // Arrange: + const charToValueMappings: any = []; + for (let code = '0'.charCodeAt(0); code <= '9'.charCodeAt(0); ++code) { + charToValueMappings.push([String.fromCharCode(code), code - '0'.charCodeAt(0)]); + } + for (let code = 'a'.charCodeAt(0); code <= 'f'.charCodeAt(0); ++code) { + charToValueMappings.push([String.fromCharCode(code), code - 'a'.charCodeAt(0) + 10]); + } + for (let code = 'A'.charCodeAt(0); code <= 'F'.charCodeAt(0); ++code) { + charToValueMappings.push([String.fromCharCode(code), code - 'A'.charCodeAt(0) + 10]); + } + + // Act: + let numTests = 0; + charToValueMappings.forEach((pair1) => { + charToValueMappings.forEach((pair2) => { + // Act: + const byte = convert.toByte(pair1[0], pair2[0]); + + // Assert: + const expected = (pair1[1] * 16) + pair2[1]; + expect(byte, `input: ${pair1[0]}${pair2[0]}`).to.equal(expected); + ++numTests; + }); + }); + + // Sanity: + expect(numTests).to.equal(22 * 22); + }); + + it('cannot convert invalid hex chars to byte', () => { + // Arrange: + const pairs = [ + ['G', '6'], + ['7', 'g'], + ['*', '8'], + ['9', '!'], + ]; + + // Act: + pairs.forEach((pair) => { + // Assert: + const message = `input: ${pair[0]}${pair[0]}`; + expect(() => { + convert.toByte(pair[0], pair[1]); + }, message).to.throw('unrecognized hex char'); + }); + }); + }); + + describe('isHexString', () => { + it('returns true for valid hex strings', () => { + // Arrange: + const inputs = [ + '', + '026ee415fc15', + 'abcdef0123456789ABCDEF', + ]; + + // Act: + for (const input of inputs) { + const isHexString = convert.isHexString(input); + + // Assert: + expect(isHexString, `input ${input}`).to.equal(true); + } + }); + + it('returns false for invalid hex strings', () => { + // Arrange: + const inputs = [ + 'abcdef012345G789ABCDEF', // invalid ('G') char + 'abcdef0123456789ABCDE', // invalid (odd) length + ]; + + // Act: + for (const input of inputs) { + const isHexString = convert.isHexString(input); + + // Assert: + expect(isHexString, `input ${input}`).to.equal(false); + } + }); + }); + + describe('hexToUint8', () => { + it('can parse empty hex string into array', () => { + // Act: + const actual = convert.hexToUint8(''); + + // Assert: + const expected = Uint8Array.of(); + expect(actual).to.deep.equal(expected); + }); + + it('can parse valid hex string into array', () => { + // Act: + const actual = convert.hexToUint8('026ee415fc15'); + + // Assert: + const expected = Uint8Array.of(0x02, 0x6E, 0xE4, 0x15, 0xFC, 0x15); + expect(actual).to.deep.equal(expected); + }); + + it('can parse valid hex string containing all valid hex characters into array', () => { + // Act: + const actual = convert.hexToUint8('abcdef0123456789ABCDEF'); + + // Assert: + const expected = Uint8Array.of(0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF); + expect(actual).to.deep.equal(expected); + }); + + it('cannot parse hex string with invalid characters into array', () => { + // Assert: + expect(() => { + convert.hexToUint8('abcdef012345G789ABCDEF'); + }).to.throw('unrecognized hex char'); + }); + + it('cannot parse hex string with invalid size into array', () => { + // Assert: + expect(() => { + convert.hexToUint8('abcdef012345G789ABCDE'); + }).to.throw('hex string has unexpected size'); + }); + }); + + describe('uint8ToHex', () => { + it('can format empty array into hex string', () => { + // Act: + const actual = convert.uint8ToHex(Uint8Array.of()); + + // Assert: + expect(actual).to.equal(''); + }); + + it('can format single value array into hex string', () => { + // Act: + const actual = convert.uint8ToHex(Uint8Array.of(0xD2)); + + // Assert: + expect(actual).to.equal('D2'); + }); + + it('can format multi value array into hex string', () => { + // Act: + const actual = convert.uint8ToHex(Uint8Array.of(0x02, 0x6E, 0xE4, 0x15, 0xFC, 0x15)); + + // Assert: + expect(actual).to.equal('026EE415FC15'); + }); + }); + + describe('uint8ToUint32', () => { + it('uint8 array with zero length can be converted to uint32 array', () => { + // Act: + const actual = convert.uint8ToUint32(Uint8Array.of()); + + // Assert: + expect(actual).to.deep.equal(Uint32Array.of()); + }); + + it('uint8 array with length multiple of four can be converted to uint32 array', () => { + // Act: + const actual = convert.uint8ToUint32(Uint8Array.of(0x02, 0x6E, 0x89, 0xAB, 0xCD, 0xEF, 0xE4, 0x15)); + + // Assert: + expect(actual).to.deep.equal(Uint32Array.of(0xAB896E02, 0x15E4EFCD)); + }); + + it('uint8 array with length not multiple of four cannot be converted to uint32 array', () => { + // Assert: + expect(() => { + convert.uint8ToUint32(Uint8Array.of(0x02, 0x6E, 0xE4, 0x15, 0x15)); + }) + .to.throw('byte length of Uint32Array should be a multiple of 4'); + }); + }); + + describe('uint32ToUint8', () => { + it('uint32 array with zero length can be converted to uint8 array', () => { + // Act: + const actual = convert.uint32ToUint8(Uint32Array.of()); + + // Assert: + expect(actual).to.deep.equal(Uint8Array.of()); + }); + + it('uint32 array with nonzero length can be converted to uint8 array', () => { + // Act: + const actual = convert.uint32ToUint8(Uint32Array.of(0xAB896E02, 0x15E4EFCD)); + + // Assert: + expect(actual).to.deep.equal(Uint8Array.of(0x02, 0x6E, 0x89, 0xAB, 0xCD, 0xEF, 0xE4, 0x15)); + }); + }); + + describe('utf8ToHex', () => { + it('utf8 text to hex', () => { + // Act: + const actual = convert.utf8ToHex('test words |@#¢∞¬÷“”≠[]}{–'); + + // Assert: + expect(actual).to.equal('7465737420776f726473207c4023c2a2e2889ec2acc3b7e2809ce2809de289a05b5d7d7be28093'); + }); + + it('utf8 text to hex', () => { + // Act: + const actual = convert.utf8ToHex('先秦兩漢'); + + // Assert: + expect(actual).to.equal('e58588e7a7a6e585a9e6bca2'); + }); + }); + + describe('signed <-> unsigned byte', () => { + const testCases = [{ + signed: -128, + unsigned: 0x80, + description: 'min negative', + }, + { + signed: -127, + unsigned: 0x81, + description: 'min negative plus one', + }, + { + signed: -87, + unsigned: 0xA9, + description: 'negative', + }, + { + signed: -1, + unsigned: 0xFF, + description: 'negative one', + }, + { + signed: 0, + unsigned: 0, + description: 'zero', + }, + { + signed: 1, + unsigned: 0x01, + description: 'positive one', + }, + { + signed: 57, + unsigned: 0x39, + description: 'positive', + }, + { + signed: 126, + unsigned: 0x7E, + description: 'max positive minus one', + }, + { + signed: 127, + unsigned: 0x7F, + description: 'max positive', + }, + ]; + + describe('uint8ToInt8', () => { + const failureTestCases = [{ + input: 256, + description: 'one too large', + }, + { + input: 1000, + description: 'very large', + }, + ]; + + for (const testCase of failureTestCases) { + it(`cannot convert number that is ${testCase.description}`, () => { + // Assert: + expect(() => convert.uint8ToInt8(testCase.input)).to.throw(`input '${testCase.input}' is out of range`); + }); + } + + for (const testCase of testCases) { + it(`can convert ${testCase.description}`, () => { + // Act: + const value = convert.uint8ToInt8(testCase.unsigned); + + // Assert: + expect(value).to.equal(testCase.signed); + }); + } + }); + + describe('int8ToUint8', () => { + const failureTestCases = [{ + input: -1000, + description: 'very small', + }, + { + input: -129, + description: 'one too small', + }, + { + input: 128, + description: 'one too large', + }, + { + input: 1000, + description: 'very large', + }, + ]; + + for (const testCase of failureTestCases) { + it(`cannot convert number that is ${testCase.description}`, () => { + // Assert: + expect(() => convert.int8ToUint8(testCase.input)).to.throw(`input '${testCase.input}' is out of range`); + }); + } + + for (const testCase of testCases) { + it(`can convert ${testCase.description}`, () => { + // Act: + const value = convert.int8ToUint8(testCase.signed); + + // Assert: + expect(value).to.equal(testCase.unsigned); + }); + } + }); + }); +}); diff --git a/test/core/format/IdGenerator.spec.ts b/test/core/format/IdGenerator.spec.ts new file mode 100644 index 0000000000..32921fd12b --- /dev/null +++ b/test/core/format/IdGenerator.spec.ts @@ -0,0 +1,251 @@ +/* + * Copyright 2019 NEM + * + * 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 {expect} from 'chai'; +import {sha3_256} from 'js-sha3'; +import { + Convert as convert, + IdGenerator as idGenerator, + RawUInt64 as uint64, +} from '../../../src/core/format'; + +const constants = { + nem_id: [0x375FFA4B, 0x84B3552D], + xem_id: [0xD95FCF29, 0xD525AD41], + namespace_base_id: [0, 0], +}; + +const basicMosaicInfo = { + nonce: [0x78, 0xE3, 0x6F, 0xB7], + publicId: [ + 0x4A, 0xFF, 0x7B, 0x4B, 0xA8, 0xC1, 0xC2, 0x6A, 0x79, 0x17, 0x57, 0x59, 0x93, 0x34, 0x66, 0x27, + 0xCB, 0x6C, 0x80, 0xDE, 0x62, 0xCD, 0x92, 0xF7, 0xF9, 0xAE, 0xDB, 0x70, 0x64, 0xA3, 0xDE, 0x62, + ], + id: [0xC0AFC518, 0x3AD842A8], +}; + +const mosaicTestVector = { + rows: [{ + publicKey: '4AFF7B4BA8C1C26A7917575993346627CB6C80DE62CD92F7F9AEDB7064A3DE62', + nonce: 'B76FE378', + expectedMosaicId: '3AD842A8C0AFC518', + }, + { + publicKey: '3811EDF245F1D30171FF1474B24C4366FECA365A8457AAFA084F3DE4AEA0BA60', + nonce: '21832A2A', + expectedMosaicId: '24C54740A9F3893F', + }, + { + publicKey: '3104D468D20491EC12C988C50CAD9282256052907415359201C46CBD7A0BCD75', + nonce: '2ADBB332', + expectedMosaicId: '43908F2DEEA04245', + }, + { + publicKey: '6648E16513F351E9907B0EA34377E25F579BE640D4698B28E06585A21E94CFE2', + nonce: 'B9175E0F', + expectedMosaicId: '183172772BD29E78', + }, + { + publicKey: '1C05C40D38463FE725CF0584A3A69E3B0D6B780196A88C50624E49B921EE1404', + nonce: 'F6077DDD', + expectedMosaicId: '423DB0B12F787422', + }, + { + publicKey: '37926B3509987093C776C8EA3E7F978E3A78142B5C96B9434C3376177DC65EFD', + nonce: '08190C6D', + expectedMosaicId: '1F07D26B6CD352D5', + }, + { + publicKey: 'FDC6B0D415D90536263431F05C46AC492D0BD9B3CFA1B79D5A35E0F371655C0C', + nonce: '81662AA5', + expectedMosaicId: '74511F54940729CB', + }, + { + publicKey: '2D4EA99965477AEB3BC162C09C24C8DA4DABE408956C2F69642554EA48AAE1B2', + nonce: 'EA16BF58', + expectedMosaicId: '4C55843B6EB4A5BD', + }, + { + publicKey: '68EB2F91E74D005A7C22D6132926AEF9BFD90A3ACA3C7F989E579A93EFF24D51', + nonce: 'E5F87A8B', + expectedMosaicId: '4D89DE2B6967666A', + }, + { + publicKey: '3B082C0074F65D1E205643CDE72C6B0A3D0579C7ACC4D6A7E23A6EC46363B90F', + nonce: '1E6BB49F', + expectedMosaicId: '0A96B3A44615B62F', + }, + { + publicKey: '81245CA233B729FAD1752662EADFD73C5033E3B918CE854E01F6EB51E98CD9F1', + nonce: 'B82965E3', + expectedMosaicId: '1D6D8E655A77C4E6', + }, + { + publicKey: 'D3A2C1BFD5D48239001174BFF62A83A52BC9A535B8CDBDF289203146661D8AC4', + nonce: 'F37FB460', + expectedMosaicId: '268A3CC23ADCDA2D', + }, + { + publicKey: '4C4CA89B7A31C42A7AB963B8AB9D85628BBB94735C999B2BD462001A002DBDF3', + nonce: 'FF6323B0', + expectedMosaicId: '51202B5C51F6A5A9', + }, + { + publicKey: '2F95D9DCD4F18206A54FA95BD138DA1C038CA82546525A8FCC330185DA0647DC', + nonce: '99674492', + expectedMosaicId: '5CE4E38B09F1423D', + }, + { + publicKey: 'A7892491F714B8A7469F763F695BDB0B3BF28D1CC6831D17E91F550A2D48BD12', + nonce: '55141880', + expectedMosaicId: '5EFD001B3350C9CB', + }, + { + publicKey: '68BBDDF5C08F54278DA516F0E4A5CCF795C10E2DE26CAF127FF4357DA7ACF686', + nonce: '11FA5BAF', + expectedMosaicId: '179F0CDD6D2CCA7B', + }, + { + publicKey: '014F6EF90792F814F6830D64017107534F5B718E2DD43C25ACAABBE347DEC81E', + nonce: '6CFBF7B3', + expectedMosaicId: '53095813DEB3D108', + }, + { + publicKey: '95A6344597E0412C51B3559F58F564F9C2DE3101E5CC1DD8B115A93CE7040A71', + nonce: '905EADFE', + expectedMosaicId: '3551C4B12DDF067D', + }, + { + publicKey: '0D7DDFEB652E8B65915EA734420A1233A233119BF1B0D41E1D5118CDD44447EE', + nonce: '61F5B671', + expectedMosaicId: '696E2FB0682D3199', + }, + { + publicKey: 'FFD781A20B01D0C999AABC337B8BAE82D1E7929A9DD77CC1A71E4B99C0749684', + nonce: 'D8542F1A', + expectedMosaicId: '6C55E05D11D19FBD', + }, + ], +}; + +describe('id generator', () => { + function generateNamespaceId(parentId, name) { + const hash = sha3_256.create(); + hash.update(Uint32Array.from(parentId).buffer); + hash.update(name); + const result = new Uint32Array(hash.arrayBuffer()); + // right zero-filling required to keep unsigned number representation + return [result[0], (result[1] | 0x80000000) >>> 0]; + } + + function addBasicTests(generator) { + it('produces different results for different names', () => { + // Assert: + ['bloodyrookie.alice', 'nem.mex', 'bloodyrookie.xem', 'bloody_rookie.xem'].forEach((name) => + expect(generator(name), `nem.xem vs ${name}`).to.not.equal(generator('nem.xem'))); + }); + + it('rejects names with uppercase characters', () => { + // Assert: + ['NEM.xem', 'NEM.XEM', 'nem.XEM', 'nEm.XeM', 'NeM.xEm'].forEach((name) => + expect(() => generator(name), `name ${name}`).to.throw('invalid part name')); + }); + + it('rejects improper qualified names', () => { + // Assert: + ['.', '..', '...', '.a', 'b.', 'a..b', '.a.b', 'b.a.'].forEach((name) => + expect(() => generator(name), `name ${name}`).to.throw('empty part')); + }); + + it('rejects improper part names', () => { + // Assert: + ['alpha.bet@.zeta', 'a!pha.beta.zeta', 'alpha.beta.ze^a'].forEach((name) => + expect(() => generator(name), `name ${name}`).to.throw('invalid part name')); + }); + + it('rejects empty string', () => { + // Assert: + expect(() => generator(''), 'empty string').to.throw('having zero length'); + }); + } + + describe('generate mosaic id', () => { + it('generates correct well known id', () => { + // Assert: + expect(idGenerator.generateMosaicId(basicMosaicInfo.nonce, basicMosaicInfo.publicId)) + .to.deep.equal(basicMosaicInfo.id); + }); + + // @dataProvider mosaicTestVector + it('generates correct mosaicId given nonce and public key', () => { + mosaicTestVector.rows.map((row, i) => { + const pubKey = convert.hexToUint8(row.publicKey); + const nonce = convert.hexToUint8(row.nonce).reverse(); // Little-Endianness! + const mosaicId = idGenerator.generateMosaicId(nonce, pubKey); + const expectedId = uint64.fromHex(row.expectedMosaicId); + + // Assert: + expect(mosaicId) + .to.deep.equal(expectedId); + }); + }); + }); + + describe('generate namespace paths', () => { + it('generates correct well known root path', () => { + // Act: + const path = idGenerator.generateNamespacePath('nem'); + + // Assert: + expect(path.length).to.equal(1); + expect(path[0]).to.deep.equal(constants.nem_id); + }); + + it('generates correct well known child path', () => { + // Act: + const path = idGenerator.generateNamespacePath('nem.xem'); + + // Assert: + expect(path.length).to.equal(2); + expect(path[0]).to.deep.equal(constants.nem_id); + expect(path[1]).to.deep.equal(constants.xem_id); + }); + + it('supports multi level namespaces', () => { + // Arrange: + const expected: any = []; + expected.push(generateNamespaceId(constants.namespace_base_id, 'foo')); + expected.push(generateNamespaceId(expected[0], 'bar')); + expected.push(generateNamespaceId(expected[1], 'baz')); + + // Assert: + expect(idGenerator.generateNamespacePath('foo.bar.baz')).to.deep.equal(expected); + }); + + it('rejects names with too many parts', () => { + // Assert: + ['a.b.c.d', 'a.b.c.d.e'].forEach((name) => + expect(() => idGenerator.generateNamespacePath(name), `name ${name}`).to.throw('too many parts')); + }); + + it('rejects improper qualified names', () => { + // Assert: + ['a:b:c', 'a::b'].forEach((name) => + expect(() => idGenerator.generateNamespacePath(name), `name ${name}`).to.throw('invalid part name')); + }); + + addBasicTests(idGenerator.generateNamespacePath); + }); +}); diff --git a/test/core/format/RawAddress.spec.ts b/test/core/format/RawAddress.spec.ts new file mode 100644 index 0000000000..c6580fb656 --- /dev/null +++ b/test/core/format/RawAddress.spec.ts @@ -0,0 +1,216 @@ +/* + * Copyright 2019 NEM + * + * 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 {expect} from 'chai'; +import { + Convert as convert, + RawAddress as address, +} from '../../../src/core/format'; + +const Address_Decoded_Size = 25; +const Network_Mijin_Identifier = 0x60; +const Network_Public_Test_Identifier = 0x98; + +describe('address', () => { + describe('stringToAddress', () => { + function assertCannotCreateAddress(encoded, message) { + // Assert: + expect(() => { + address.stringToAddress(encoded); + }).to.throw(message); + } + + it('can create address from valid encoded address', () => { + // Arrange: + const encoded = 'NAR3W7B4BCOZSZMFIZRYB3N5YGOUSWIYJCJ6HDFG'; + const expectedHex = '6823BB7C3C089D996585466380EDBDC19D4959184893E38CA6'; + + // Act: + const decoded = address.stringToAddress(encoded); + + // Assert: + expect(address.isValidAddress(decoded)).to.equal(true); + expect(convert.uint8ToHex(decoded)).to.equal(expectedHex); + }); + + it('cannot create address from encoded string with wrong length', () => { + // Assert: + assertCannotCreateAddress( + 'NC5J5DI2URIC4H3T3IMXQS25PWQWZIPEV6EV7LASABCDEFGH', + 'NC5J5DI2URIC4H3T3IMXQS25PWQWZIPEV6EV7LASABCDEFGH does not represent a valid encoded address' + ); + }); + + it('cannot create address from invalid encoded string', () => { + // Assert: + assertCannotCreateAddress('NC5(5DI2URIC4H3T3IMXQS25PWQWZIPEV6EV7LAS', 'illegal base32 character ('); + assertCannotCreateAddress('NC5J1DI2URIC4H3T3IMXQS25PWQWZIPEV6EV7LAS', 'illegal base32 character 1'); + assertCannotCreateAddress('NC5J5?I2URIC4H3T3IMXQS25PWQWZIPEV6EV7LAS', 'illegal base32 character ?'); + }); + }); + + describe('addressToString', () => { + it('can create encoded address from address', () => { + // Arrange: + const decodedHex = '6823BB7C3C089D996585466380EDBDC19D4959184893E38CA6'; + const expected = 'NAR3W7B4BCOZSZMFIZRYB3N5YGOUSWIYJCJ6HDFG'; + + // Act: + const encoded = address.addressToString(convert.hexToUint8(decodedHex)); + + // Assert: + expect(encoded).to.equal(expected); + }); + }); + + describe('publicKeyToAddress', () => { + it('can create address from public key for well known network', () => { + // Arrange: + const expectedHex = '6023BB7C3C089D996585466380EDBDC19D49591848B3727714'; + const publicKey = convert.hexToUint8('3485D98EFD7EB07ADAFCFD1A157D89DE2796A95E780813C0258AF3F5F84ED8CB'); + + // Act: + const decoded = address.publicKeyToAddress(publicKey, Network_Mijin_Identifier); + + // Assert: + expect(decoded[0]).to.equal(Network_Mijin_Identifier); + expect(address.isValidAddress(decoded)).to.equal(true); + expect(convert.uint8ToHex(decoded)).to.equal(expectedHex); + }); + + it('can create address from public key for custom network', () => { + // Arrange: + const expectedHex = '9823BB7C3C089D996585466380EDBDC19D495918484BF7E997'; + const publicKey = convert.hexToUint8('3485D98EFD7EB07ADAFCFD1A157D89DE2796A95E780813C0258AF3F5F84ED8CB'); + + // Act: + const decoded = address.publicKeyToAddress(publicKey, Network_Public_Test_Identifier); + + // Assert: + expect(decoded[0]).to.equal(Network_Public_Test_Identifier); + expect(address.isValidAddress(decoded)).to.equal(true); + expect(convert.uint8ToHex(decoded)).to.equal(expectedHex); + }); + + it('address calculation is deterministic', () => { + // Arrange: + const publicKey = convert.hexToUint8('3485D98EFD7EB07ADAFCFD1A157D89DE2796A95E780813C0258AF3F5F84ED8CB'); + + // Act: + const decoded1 = address.publicKeyToAddress(publicKey, Network_Mijin_Identifier); + const decoded2 = address.publicKeyToAddress(publicKey, Network_Mijin_Identifier); + + // Assert: + expect(address.isValidAddress(decoded1)).to.equal(true); + expect(decoded1).to.deep.equal(decoded2); + }); + + it('different public keys result in different addresses', () => { + // Arrange: + const publicKey1 = convert.hexToUint8('1464953393CE96A08ABA6184601FD08864E910696B060FF7064474726E666CA8'); + const publicKey2 = convert.hexToUint8('b4f12e7c9f6946091e2cb8b6d3a12b50d17ccbbf646386ea27ce2946a7423dcf'); + + // Act: + const decoded1 = address.publicKeyToAddress(publicKey1, Network_Mijin_Identifier); + const decoded2 = address.publicKeyToAddress(publicKey2, Network_Mijin_Identifier); + + // Assert: + expect(address.isValidAddress(decoded1)).to.equal(true); + expect(address.isValidAddress(decoded2)).to.equal(true); + expect(decoded1).to.not.deep.equal(decoded2); + }); + + it('different networks result in different addresses', () => { + // Arrange: + const publicKey = convert.hexToUint8('b4f12e7c9f6946091e2cb8b6d3a12b50d17ccbbf646386ea27ce2946a7423dcf'); + + // Act: + const decoded1 = address.publicKeyToAddress(publicKey, Network_Mijin_Identifier); + const decoded2 = address.publicKeyToAddress(publicKey, Network_Public_Test_Identifier); + + // Assert: + expect(address.isValidAddress(decoded1)).to.equal(true); + expect(address.isValidAddress(decoded2)).to.equal(true); + expect(decoded1).to.not.deep.equal(decoded2); + }); + }); + + describe('isValidAddress', () => { + it('returns true for valid address', () => { + // Arrange: + const validHex = '6823BB7C3C089D996585466380EDBDC19D4959184893E38CA6'; + const decoded = convert.hexToUint8(validHex); + + // Assert: + expect(address.isValidAddress(decoded)).to.equal(true); + }); + + it('returns false for address with invalid checksum', () => { + // Arrange: + const validHex = '6823BB7C3C089D996585466380EDBDC19D4959184893E38CA6'; + const decoded = convert.hexToUint8(validHex); + decoded[Address_Decoded_Size - 1] ^= 0xff; // ruin checksum + + // Assert: + expect(address.isValidAddress(decoded)).to.equal(false); + }); + + it('returns false for address with invalid hash', () => { + // Arrange: + const validHex = '6823BB7C3C089D996585466380EDBDC19D4959184893E38CA6'; + const decoded = convert.hexToUint8(validHex); + decoded[5] ^= 0xff; // ruin ripemd160 hash + + // Assert: + expect(address.isValidAddress(decoded)).to.equal(false); + }); + }); + + describe('isValidEncodedAddress', () => { + it('returns true for valid encoded address', () => { + // Arrange: + const encoded = 'NAR3W7B4BCOZSZMFIZRYB3N5YGOUSWIYJCJ6HDFG'; + + // Assert: + expect(address.isValidEncodedAddress(encoded)).to.equal(true); + }); + + it('returns false for invalid encoded address', () => { + // Arrange: changed last char + const encoded = 'NAR3W7B4BCOZSZMFIZRYB3N5YGOUSWIYJCJ6HDFH'; + + // Assert: + expect(address.isValidEncodedAddress(encoded)).to.equal(false); + }); + + it('returns false for encoded address with wrong length', () => { + // Arrange: added ABC + const encoded = 'NAR3W7B4BCOZSZMFIZRYB3N5YGOUSWIYJCJ6HDFGABC'; + + // Assert: + expect(address.isValidEncodedAddress(encoded)).to.equal(false); + }); + + it('adding leading or trailing white space invalidates encoded address', () => { + // Arrange: + const encoded = 'NAR3W7B4BCOZSZMFIZRYB3N5YGOUSWIYJCJ6HDFG'; + + // Assert: + expect(address.isValidEncodedAddress(` \t ${encoded}`)).to.equal(false); + expect(address.isValidEncodedAddress(`${encoded} \t `)).to.equal(false); + expect(address.isValidEncodedAddress(` \t ${encoded} \t `)).to.equal(false); + }); + }); +}); \ No newline at end of file diff --git a/test/core/format/RawArray.spec.ts b/test/core/format/RawArray.spec.ts new file mode 100644 index 0000000000..a1017c4c05 --- /dev/null +++ b/test/core/format/RawArray.spec.ts @@ -0,0 +1,223 @@ +/* + * Copyright 2019 NEM + * + * 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 {expect} from 'chai'; +import { Convert as convert, RawArray as array} from '../../../src/core/format'; + +describe('array', () => { + describe('uint8View', () => { + it('can get uint8 view of array buffer', () => { + // Arrange: + const src = convert.hexToUint8('0A12B5675069'); + + // Act: + const view = array.uint8View(src.buffer); + + // Assert: + expect(convert.uint8ToHex(view)).to.equal('0A12B5675069'); + }); + + it('can get uint8 view of uint8 typed array', () => { + // Arrange: + const src = convert.hexToUint8('0A12B5675069'); + + // Act: + const view = array.uint8View(src); + + // Assert: + expect(convert.uint8ToHex(view)).to.equal('0A12B5675069'); + }); + + it('cannot get uint8 view of arbitrary typed array', () => { + // Arrange: + const src = new Uint16Array(10); + + // Act: + expect(() => array.uint8View(src)).to.throw('unsupported type passed to uint8View'); + }); + }); + + describe('copy', () => { + it('can copy full typed array', () => { + // Arrange: + const src = convert.hexToUint8('0A12B5675069'); + const dest = new Uint8Array(src.length); + + // Act: + array.copy(dest, src); + + // Assert: + expect(convert.uint8ToHex(dest)).to.equal('0A12B5675069'); + }); + + it('can copy partial typed array when dest is same size as src', () => { + // Arrange: + const src = convert.hexToUint8('0A12B5675069'); + const dest = new Uint8Array(src.length); + + // Act: + array.copy(dest, src, 3); + + // Assert: + expect(convert.uint8ToHex(dest)).to.equal('0A12B5000000'); + }); + + it('can copy partial typed array when dest is smaller than src', () => { + // Arrange: + const src = convert.hexToUint8('0A12B5675069'); + const dest = new Uint8Array(4); + + // Act: + array.copy(dest, src); + + // Assert: + expect(convert.uint8ToHex(dest)).to.equal('0A12B567'); + }); + + it('can copy partial typed array with custom offsets', () => { + // Arrange: + const src = convert.hexToUint8('0A12B5675069'); + const dest = new Uint8Array(src.length); + + // Act: + array.copy(dest, src, 3, 2, 1); + + // Assert: + expect(convert.uint8ToHex(dest)).to.equal('000012B56700'); + }); + }); + + describe('isZeroFilled', () => { + it('returns true if typed array is zero', () => { + // Act: + const isZero = array.isZeroFilled(new Uint16Array(10)); + + // Assert: + expect(isZero).to.equal(true); + }); + + function assertIsNonZero(length, nonZeroOffset) { + // Arrange: + const src = new Uint16Array(length); + src[nonZeroOffset] = 2; + + // Act + const isZero = array.isZeroFilled(src); + + // Assert: + expect(isZero, `nonzero offset ${nonZeroOffset}`).to.equal(false); + } + + it('returns false if typed array is non zero', () => { + // Assert: + assertIsNonZero(10, 0); + assertIsNonZero(10, 5); + assertIsNonZero(10, 9); + }); + }); + + describe('deepEqual', () => { + it('returns true if typed arrays are equal', () => { + // Arrange: + const lhs = convert.hexToUint8('0A12B5675069'); + const rhs = convert.hexToUint8('0A12B5675069'); + + // Act: + const isEqual = array.deepEqual(lhs, rhs); + + // Assert: + expect(isEqual).to.equal(true); + }); + + it('returns false if typed arrays have different sizes', () => { + // Arrange: + const shorter = convert.hexToUint8('0A12B5675069'); + const longer = convert.hexToUint8('0A12B567506983'); + + // Act: + const isEqual1 = array.deepEqual(shorter, longer); + const isEqual2 = array.deepEqual(longer, shorter); + + // Assert: + expect(isEqual1).to.equal(false); + expect(isEqual2).to.equal(false); + }); + + function assertNotEqual(lhs, unequalOffset) { + // Arrange: + const rhs = new Uint8Array(lhs.length); + array.copy(rhs, lhs); + rhs[unequalOffset] ^= 0xFF; + + // Act + const isEqual = array.deepEqual(lhs, rhs); + + // Assert: + expect(isEqual, `unequal offset ${unequalOffset}`).to.equal(false); + } + + it('returns false if typed arrays are not equal', () => { + // Arrange: + const lhs = convert.hexToUint8('0A12B5675069'); + + // Assert: + assertNotEqual(lhs, 0); + assertNotEqual(lhs, 3); + assertNotEqual(lhs, 5); + }); + + it('returns true if subset of typed arrays are equal', () => { + // Arrange: different at 2 + const lhs = convert.hexToUint8('0A12B5675069'); + const rhs = convert.hexToUint8('0A12C5675069'); + + // Act: + const isEqualSubset = array.deepEqual(lhs, rhs, 2); + const isEqualAll = array.deepEqual(lhs, rhs); + + // Assert: + expect(isEqualSubset).to.equal(true); + expect(isEqualAll).to.equal(false); + }); + + it('returns true if subset of typed arrays of different lengths are equal', () => { + // Arrange: + const shorter = convert.hexToUint8('0A12B5'); + const longer = convert.hexToUint8('0A12B567506983'); + + // Act: + const isEqual1 = array.deepEqual(shorter, longer, 3); + const isEqual2 = array.deepEqual(longer, shorter, 3); + + // Assert: + expect(isEqual1).to.equal(true); + expect(isEqual2).to.equal(true); + }); + + it('returns false if either typed array has fewer elements than requested for comparison', () => { + // Arrange: + const shorter = convert.hexToUint8('0A12B5'); + const longer = convert.hexToUint8('0A12B567506983'); + + // Act: + const isEqual1 = array.deepEqual(shorter, longer, 4); + const isEqual2 = array.deepEqual(longer, shorter, 4); + + // Assert: + expect(isEqual1).to.equal(false); + expect(isEqual2).to.equal(false); + }); + }); +}); \ No newline at end of file diff --git a/test/core/format/RawUInt64.spec.ts b/test/core/format/RawUInt64.spec.ts new file mode 100644 index 0000000000..f7d3c26bdc --- /dev/null +++ b/test/core/format/RawUInt64.spec.ts @@ -0,0 +1,319 @@ +/* + * Copyright 2019 NEM + * + * 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 { + expect +} from 'chai'; +import { Convert as convert, RawUInt64 as uint64} from '../../../src/core/format'; + +describe('uint64', () => { + describe('compact', () => { + it('can compact 32 bit value', () => { + // Act: + const result = uint64.compact([0x12345678, 0x00000000]); + + // Assert: + expect(result).to.equal(0x12345678); + }); + + it('can compact less than max safe integer', () => { + // Act: + const result = uint64.compact([0x00ABCDEF, 0x000FDFFF]); + + // Assert: + expect(result).to.equal(0xFDFFF00ABCDEF); + }); + + it('can compact max safe integer', () => { + // Sanity: + expect(0x1FFFFFFFFFFFFF).to.equal(Number.MAX_SAFE_INTEGER); + + // Act: + const result = uint64.compact([0xFFFFFFFF, 0x001FFFFF]); + + // Assert: + expect(result).to.equal(Number.MAX_SAFE_INTEGER); + }); + + it('cannot compact min unsafe integer', () => { + // Sanity: + expect(0x0020000000000000 + 1).to.equal(0x0020000000000000); + + // Act: + const result = uint64.compact([0x00000000, 0x00200000]); + + // Assert: + expect(result).to.deep.equal([0x00000000, 0x00200000]); + }); + + it('cannot compact greater than min unsafe integer', () => { + // Act: + const result = uint64.compact([0xF0000000, 0x01000D00]); + + // Assert: + expect(result).to.deep.equal([0xF0000000, 0x01000D00]); + }); + }); + + describe('fromUint', () => { + // const failureTestCases = [ + // { number: 0x0020000000000000, description: 'min unsafe integer' }, + // { number: 0x01000D00F0000000, description: 'greater than min unsafe integer' }, + // { number: -1, description: 'negative' }, + // { number: 1234.56, description: 'floating point' } + // ]; + + // failureTestCases.forEach(testCase => { + // it(`cannot parse number that is ${testCase.description}`, () => { + // // Assert: + // expect(() => uint64.fromUint(testCase.number)).to.throw(`number cannot be converted to uint '${testCase.number}'`); + // }); + // }); + + const successTestCases = [{ + number: 0, + uint64: [0, 0], + description: '0' + }, + { + number: 0xA1B2, + uint64: [0xA1B2, 0], + description: '(0, 8)' + }, + { + number: 0x12345678, + uint64: [0x12345678, 0], + description: '8' + }, + { + number: 0xABCD12345678, + uint64: [0x12345678, 0xABCD], + description: '(8, 16)' + }, + { + number: 0x0014567890ABCDEF, + uint64: [0x90ABCDEF, 0x00145678], + description: '14' + }, + { + number: Number.MAX_SAFE_INTEGER, + uint64: [0xFFFFFFFF, 0x001FFFFF], + description: '14 (max value)' + } + ]; + + successTestCases.forEach(testCase => { + it(`can parse numeric with ${testCase.description} significant digits`, () => { + // Act: + const value = uint64.fromUint(testCase.number); + + // Assert: + expect(value).to.deep.equal(testCase.uint64); + }); + }); + }); + + const hexTestCases = [{ + str: '0000000000000000', + value: [0, 0], + description: '0' + }, + { + str: '000000000000A1B2', + value: [0xA1B2, 0], + description: '(0, 8)' + }, + { + str: '0000000012345678', + value: [0x12345678, 0], + description: '8' + }, + { + str: '0000ABCD12345678', + value: [0x12345678, 0xABCD], + description: '(8, 16)' + }, + { + str: '1234567890ABCDEF', + value: [0x90ABCDEF, 0x12345678], + description: '16' + }, + { + str: 'FFFFFFFFFFFFFFFF', + value: [0xFFFFFFFF, 0xFFFFFFFF], + description: '16 (max value)' + } + ]; + + describe('fromBytes', () => { + hexTestCases.forEach(testCase => { + it(`can parse byte array with ${testCase.description} significant digits`, () => { + // Arrange: prepare little-endian bytes + const bytes = convert.hexToUint8(testCase.str).reverse(); + + // Act: + const value = uint64.fromBytes(bytes); + + // Assert: + expect(value).to.deep.equal(testCase.value); + }); + }); + + it('cannot parse byte array with invalid size into uint64', () => { + // Arrange: + const errorMessage = 'byte array has unexpected size'; + + // Assert: + [0, 3, 4, 5, 7, 9].forEach(size => { + expect(() => { + uint64.fromBytes(new Uint8Array(size)); + }, `size ${size}`).to.throw(errorMessage); + }); + }); + }); + + describe('fromBytes32', () => { + const fromBytes32TestCases = [{ + str: '00000000', + value: [0, 0], + description: '0' + }, + { + str: '0000A1B2', + value: [0xA1B2, 0], + description: '(0, 8)' + }, + { + str: '12345678', + value: [0x12345678, 0], + description: '8' + }, + { + str: 'FFFFFFFF', + value: [0xFFFFFFFF, 0], + description: '8 (max value)' + } + ]; + + fromBytes32TestCases.forEach(testCase => { + it(`can parse byte array with ${testCase.description} significant digits`, () => { + // Arrange: prepare little-endian bytes + const bytes = convert.hexToUint8(testCase.str).reverse(); + + // Act: + const value = uint64.fromBytes32(bytes); + + // Assert: + expect(value).to.deep.equal(testCase.value); + }); + }); + + it('cannot parse byte array with invalid size into uint64', () => { + // Arrange: + const errorMessage = 'byte array has unexpected size'; + + // Assert: + [0, 3, 5, 7, 8, 9].forEach(size => { + expect(() => { + uint64.fromBytes32(new Uint8Array(size)); + }, `size ${size}`).to.throw(errorMessage); + }); + }); + }); + + describe('fromHex', () => { + hexTestCases.forEach(testCase => { + it(`can parse hex string with ${testCase.description} significant digits`, () => { + // Act: + const value = uint64.fromHex(testCase.str); + + // Assert: + expect(value).to.deep.equal(testCase.value); + }); + }); + + it('cannot parse hex string with invalid characters into uint64', () => { + // Assert: + expect(() => { + uint64.fromHex('0000000012345G78'); + }).to.throw('unrecognized hex char'); // contains 'G' + }); + + it('cannot parse hex string with invalid size into uint64', () => { + // Arrange: + const errorMessage = 'hex string has unexpected size'; + + // Assert: + expect(() => { + uint64.fromHex(''); + }).to.throw(errorMessage); // empty string + expect(() => { + uint64.fromHex('1'); + }).to.throw(errorMessage); // odd number of chars + expect(() => { + uint64.fromHex('ABCDEF12'); + }).to.throw(errorMessage); // too short + expect(() => { + uint64.fromHex('1234567890ABCDEF12'); + }).to.throw(errorMessage); // too long + }); + }); + + describe('toHex', () => { + hexTestCases.forEach(testCase => { + it(`can format hex string with ${testCase.description} significant digits`, () => { + // Act: + const str = uint64.toHex(testCase.value); + + // Assert: + expect(str).to.equal(testCase.str); + }); + }); + }); + + describe('isZero', () => { + const zeroTestCases = [{ + description: 'low and high are zero', + value: [0, 0], + isZero: true + }, + { + description: 'low is nonzero and high is zero', + value: [1, 0], + isZero: false + }, + { + description: 'low is zero and high is nonzero', + value: [0, 1], + isZero: false + }, + { + description: 'low and high are nonzero', + value: [74, 12], + isZero: false + } + ]; + + zeroTestCases.forEach(testCase => { + it(`returns ${testCase.isZero} when ${testCase.description}`, () => { + // Act: + const isZero = uint64.isZero(testCase.value); + + // Assert: + expect(isZero).to.equal(testCase.isZero); + }); + }); + }); +}); diff --git a/test/core/format/Utilities.spec.ts b/test/core/format/Utilities.spec.ts new file mode 100644 index 0000000000..26fa600e4a --- /dev/null +++ b/test/core/format/Utilities.spec.ts @@ -0,0 +1,146 @@ +/* + * Copyright 2019 NEM + * + * 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 {expect} from 'chai'; +import * as utilities from '../../../src/core/format/Utilities'; + +describe('Char Mapping', () => { + describe('builder', () => { + it('initially has empty map', () => { + // Arrange: + const builder = utilities.createBuilder(); + + // Act: + const map = builder.map; + + // Assert: + expect(map).to.deep.equal({}); + }); + + it('can add single arbitrary range with zero base', () => { + // Arrange: + const builder = utilities.createBuilder(); + + // Act: + builder.addRange('d', 'f', 0); + const map = builder.map; + + // Assert: + expect(map).to.deep.equal({ + d: 0, + e: 1, + f: 2, + }); + }); + + it('can add single arbitrary range with nonzero base', () => { + // Arrange: + const builder = utilities.createBuilder(); + + // Act: + builder.addRange('d', 'f', 17); + const map = builder.map; + + // Assert: + expect(map).to.deep.equal({ + d: 17, + e: 18, + f: 19, + }); + }); + + it('can add multiple arbitrary ranges', () => { + // Arrange: + const builder = utilities.createBuilder(); + + // Act: + builder.addRange('b', 'b', 8); + builder.addRange('d', 'f', 17); + builder.addRange('y', 'z', 0); + const map = builder.map; + + // Assert: + expect(map).to.deep.equal({ + b: 8, + d: 17, + e: 18, + f: 19, + y: 0, + z: 1, + }); + }); + + it('can add multiple arbitrary overlapping ranges', () => { + // Arrange: + const builder = utilities.createBuilder(); + + // Act: + builder.addRange('b', 'b', 18); + builder.addRange('d', 'f', 17); + builder.addRange('y', 'z', 19); + const map = builder.map; + + // Assert: + expect(map).to.deep.equal({ + b: 18, + d: 17, + e: 18, + f: 19, + y: 19, + z: 20, + }); + }); + }); +}); + +describe('Convert', () => { + describe('tryParseUint', () => { + function addTryParseSuccessTest(name, str, expectedValue) { + it(name, () => { + // Act: + const value = utilities.tryParseUint(str); + + // Assert: + expect(value).to.equal(expectedValue); + }); + } + + addTryParseSuccessTest('can parse decimal string', '14952', 14952); + addTryParseSuccessTest('can parse zero decimal string', '0', 0); + addTryParseSuccessTest('can parse decimal string with all digits', '1234567890', 1234567890); + addTryParseSuccessTest('can parse decimal string with zeros', '10002', 10002); + addTryParseSuccessTest('can parse max safe integer decimal string', Number.MAX_SAFE_INTEGER.toString(), 9007199254740991); + + function addTryParseFailureTest(name, str) { + it(name, () => { + // Act: + const value = utilities.tryParseUint(str); + + // Assert: + expect(value).to.equal(undefined); + }); + } + + addTryParseFailureTest('cannot parse decimal string with left padding', ' 14952'); + addTryParseFailureTest('cannot parse decimal string with right padding', '14952 '); + addTryParseFailureTest('cannot parse decimal string too large', '9007199254740992'); + addTryParseFailureTest('cannot parse zeros string', '00'); + addTryParseFailureTest('cannot parse octal string', '0123'); + addTryParseFailureTest('cannot parse hex string', '0x14A52'); + addTryParseFailureTest('cannot parse double string', '14.52'); + addTryParseFailureTest('cannot parse negative decimal string', '-14952'); + addTryParseFailureTest('cannot parse arbitrary string', 'catapult'); + }); +}); diff --git a/test/core/utils/TransactionMapping.spec.ts b/test/core/utils/TransactionMapping.spec.ts index 0b1ca6bca8..c7bc986b01 100644 --- a/test/core/utils/TransactionMapping.spec.ts +++ b/test/core/utils/TransactionMapping.spec.ts @@ -17,7 +17,7 @@ import {deepEqual} from 'assert'; import { expect } from 'chai'; import { sha3_256 } from 'js-sha3'; -import { convert } from 'nem2-library'; +import {Convert as convert} from '../../../src/core/format'; import { TransactionMapping } from '../../../src/core/utils/TransactionMapping'; import { Account } from '../../../src/model/account/Account'; import { Address } from '../../../src/model/account/Address'; diff --git a/test/infrastructure/SerializeTransactionToJSON.spec.ts b/test/infrastructure/SerializeTransactionToJSON.spec.ts index 655e644a01..3c2d1bcdf9 100644 --- a/test/infrastructure/SerializeTransactionToJSON.spec.ts +++ b/test/infrastructure/SerializeTransactionToJSON.spec.ts @@ -16,7 +16,7 @@ import { expect } from 'chai'; import { sha3_256 } from 'js-sha3'; -import { convert } from 'nem2-library'; +import {Convert as convert} from '../../src/core/format'; import { Account } from '../../src/model/account/Account'; import { Address } from '../../src/model/account/Address'; import { PropertyModificationType } from '../../src/model/account/PropertyModificationType'; diff --git a/test/model/transaction/SecretLockTransaction.spec.ts b/test/model/transaction/SecretLockTransaction.spec.ts index 9795d7f5ae..26bbd11ede 100644 --- a/test/model/transaction/SecretLockTransaction.spec.ts +++ b/test/model/transaction/SecretLockTransaction.spec.ts @@ -17,7 +17,7 @@ import {deepEqual} from 'assert'; import {expect} from 'chai'; import * as CryptoJS from 'crypto-js'; import {keccak_256, sha3_256} from 'js-sha3'; -import {convert} from 'nem2-library'; +import {Convert as convert} from '../../../src/core/format'; import {Address} from '../../../src/model/account/Address'; import {NetworkType} from '../../../src/model/blockchain/NetworkType'; import {NetworkCurrencyMosaic} from '../../../src/model/mosaic/NetworkCurrencyMosaic'; diff --git a/test/model/transaction/SecretProofTransaction.spec.ts b/test/model/transaction/SecretProofTransaction.spec.ts index 12ccf662a0..6ee0b3aaab 100644 --- a/test/model/transaction/SecretProofTransaction.spec.ts +++ b/test/model/transaction/SecretProofTransaction.spec.ts @@ -16,7 +16,7 @@ import {expect} from 'chai'; import * as CryptoJS from 'crypto-js'; import {keccak_256, sha3_256} from 'js-sha3'; -import {convert} from 'nem2-library'; +import {Convert as convert} from '../../../src/core/format'; import { Account } from '../../../src/model/account/Account'; import {NetworkType} from '../../../src/model/blockchain/NetworkType'; import {Deadline} from '../../../src/model/transaction/Deadline'; diff --git a/test/model/transaction/Transaction.spec.ts b/test/model/transaction/Transaction.spec.ts index 578321c514..04b2b4c0e2 100644 --- a/test/model/transaction/Transaction.spec.ts +++ b/test/model/transaction/Transaction.spec.ts @@ -15,7 +15,7 @@ */ import { expect } from 'chai'; -import { VerifiableTransaction } from 'nem2-library'; +import { VerifiableTransaction } from '../../../src/infrastructure/builders/VerifiableTransaction'; import { Account } from '../../../src/model/account/Account'; import { Address } from '../../../src/model/account/Address'; import { NetworkType } from '../../../src/model/blockchain/NetworkType'; diff --git a/test/model/transaction/TransactionStatus.spec.ts b/test/model/transaction/TransactionStatus.spec.ts index 0e0e335d09..dc82a6276a 100644 --- a/test/model/transaction/TransactionStatus.spec.ts +++ b/test/model/transaction/TransactionStatus.spec.ts @@ -31,8 +31,8 @@ describe('TransactionStatus', () => { }; const transactionStatus = new TransactionStatus( - transactionStatusDTO.group, transactionStatusDTO.status, + transactionStatusDTO.group, transactionStatusDTO.hash, transactionStatusDTO.deadline, transactionStatusDTO.height,