diff --git a/e2e/infrastructure/MosaicHttp.spec.ts b/e2e/infrastructure/MosaicHttp.spec.ts index 403cebdaec..90b878652c 100644 --- a/e2e/infrastructure/MosaicHttp.spec.ts +++ b/e2e/infrastructure/MosaicHttp.spec.ts @@ -53,29 +53,4 @@ describe('MosaicHttp', () => { }); }); }); - - describe('getMosaicsFromNamespace', () => { - it('should return mosaics given namespaceId', (done) => { - mosaicHttp.getMosaicsFromNamespace(namespaceId) - .subscribe((mosaicInfos) => { - expect(mosaicInfos[0].height.lower).to.be.equal(1); - expect(mosaicInfos[0].height.higher).to.be.equal(0); - expect(mosaicInfos[0].divisibility).to.be.equal(6); - expect(mosaicInfos[0].isSupplyMutable()).to.be.equal(false); - expect(mosaicInfos[0].isTransferable()).to.be.equal(true); - expect(mosaicInfos[0].isLevyMutable()).to.be.equal(false); - done(); - }); - }); - }); - - describe('getMosaicsName', () => { - it('should return mosaics name given array of mosaicIds', (done) => { - mosaicHttp.getMosaicsName([mosaicId]) - .subscribe((mosaicNames) => { - expect(mosaicNames[0].name).to.be.equal('xem'); - done(); - }); - }); - }); }); diff --git a/e2e/infrastructure/TransactionHttp.spec.ts b/e2e/infrastructure/TransactionHttp.spec.ts index 7fe39ebe15..6c4c0b02e0 100644 --- a/e2e/infrastructure/TransactionHttp.spec.ts +++ b/e2e/infrastructure/TransactionHttp.spec.ts @@ -151,8 +151,8 @@ describe('TransactionHttp', () => { it('standalone', (done) => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( Deadline.create(), - 'test-mosaic-name-' + Math.floor(Math.random() * 10000), - namespaceName, + new Uint8Array([0xE6, 0xDE, 0x84, 0xB8]), + UInt64.fromUint(1), MosaicProperties.create({ supplyMutable: true, transferable: true, @@ -170,8 +170,8 @@ describe('TransactionHttp', () => { it('aggregate', (done) => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( Deadline.create(), - 'test-mosaic-name-' + Math.floor(Math.random() * 10000), - namespaceName, + new Uint8Array([0xE6, 0xDE, 0x84, 0xB8]), + UInt64.fromUint(1), MosaicProperties.create({ supplyMutable: true, transferable: true, diff --git a/e2e/infrastructure/transaction/CreateTransactionFromDTO.spec.ts b/e2e/infrastructure/transaction/CreateTransactionFromDTO.spec.ts index 15b6953730..5dc958a606 100644 --- a/e2e/infrastructure/transaction/CreateTransactionFromDTO.spec.ts +++ b/e2e/infrastructure/transaction/CreateTransactionFromDTO.spec.ts @@ -413,10 +413,9 @@ describe('CreateTransactionFromDTO', () => { 3248159581, 740240531, ], - name: 'ie7rfaqxiorum1jor', - parentId: [ - 3316183705, - 3829351378, + nonce: [ + 1, + 0, ], properties: [ { @@ -502,10 +501,9 @@ describe('CreateTransactionFromDTO', () => { 3248159581, 740240531, ], - name: 'ie7rfaqxiorum1jor', - parentId: [ - 3316183705, - 3829351378, + nonce: [ + 1, + 0, ], properties: [ { diff --git a/package-lock.json b/package-lock.json index cc197e985c..56587ed03f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "nem2-sdk", - "version": "0.10.1", + "version": "0.10.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -223,9 +223,9 @@ } }, "bindings": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz", - "integrity": "sha512-DpLh5EzMR2kzvX1KIlVC0VkC3iZtHKTgdtZ0a3pglBZdaQFjt5S9g9xd1lE+YvXyfd6mtCeRnrUfOLYiTMlNSw==" + "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", @@ -295,14 +295,23 @@ } }, "browserify-des": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.1.tgz", - "integrity": "sha512-zy0Cobe3hhgpiOM32Tj7KQ3Vl91m0njwsjzZQK1L+JDf11dzP9qIvjreVinsvXrgfjhStXwUWAEpB9D7Gwmayw==", + "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" + "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": { @@ -408,9 +417,9 @@ "dev": true }, "chownr": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.0.1.tgz", - "integrity": "sha1-4qdQQqlVGQi+vSW4Uj1fl2nXkYE=" + "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", @@ -585,11 +594,18 @@ } }, "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", "requires": { - "ms": "2.0.0" + "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==" + } } }, "decompress-response": { @@ -666,9 +682,9 @@ } }, "elliptic": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz", - "integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=", + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz", + "integrity": "sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==", "requires": { "bn.js": "^4.4.0", "brorand": "^1.0.1", @@ -740,9 +756,9 @@ "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" }, "flatbuffers": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/flatbuffers/-/flatbuffers-1.9.0.tgz", - "integrity": "sha1-4e9SZ96qtIcsCNvKVqk21tvCfs0=" + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/flatbuffers/-/flatbuffers-1.10.2.tgz", + "integrity": "sha512-VK7lHZF/corkykjXZ0+dqViI8Wk1YpwPCFN2wrnTs+PMCMG5+uHRvkRW14fuA7Smkhkgx+Dj5UdS3YXktJL+qw==" }, "forever-agent": { "version": "0.6.1", @@ -873,12 +889,12 @@ } }, "hash.js": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.4.tgz", - "integrity": "sha512-A6RlQvvZEtFS5fLU43IDu0QUmBy+fDO9VMdTXvufKwIkt/rFfvICAViCax5fbDO4zdNzaC3/27ZhKUok5bAJyw==", + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", "requires": { "inherits": "^2.0.3", - "minimalistic-assert": "^1.0.0" + "minimalistic-assert": "^1.0.1" } }, "hawk": { @@ -1048,12 +1064,20 @@ "dev": true }, "md5.js": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", - "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", + "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", "requires": { "hash-base": "^3.0.0", - "inherits": "^2.0.1" + "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==" + } } }, "methods": { @@ -1090,9 +1114,9 @@ } }, "mimic-response": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.0.tgz", - "integrity": "sha1-3z02Uqc/3ta5sLJBRub9BSNTRY4=" + "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", @@ -1180,7 +1204,8 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true }, "nan": { "version": "2.10.0", @@ -1188,9 +1213,9 @@ "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==" }, "nem2-library": { - "version": "0.9.5", - "resolved": "https://registry.npmjs.org/nem2-library/-/nem2-library-0.9.5.tgz", - "integrity": "sha512-xfew4FcCFPiA9utZLPogb5BxMlhvrdh5ZfhLxh2dsnuU+dBsQ7CvfikjOfSLGZFfWYRVumv8vW8pYbY4xKdrRg==", + "version": "0.9.6", + "resolved": "https://registry.npmjs.org/nem2-library/-/nem2-library-0.9.6.tgz", + "integrity": "sha512-+UuQIRT3k2kr11Xcfq189Ei7YhUt8eMq/bFmSfX8bXFeFJ4HoXSNRvUsQ+LD3dN2s3ol+ENTmXLt/32C4WV1gA==", "requires": { "bufferutil": "^3.0.5", "crypto-browserify": "3.12.0", @@ -1205,16 +1230,16 @@ }, "dependencies": { "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" } } }, "node-abi": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.4.3.tgz", - "integrity": "sha512-b656V5C0628gOOA2kwcpNA/bxdlqYF9FvxJ+qqVX0ctdXNVZpS8J6xEUYir3WAKc7U0BH/NRlSpNbGsy+azjeg==", + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.7.1.tgz", + "integrity": "sha512-OV8Bq1OrPh6z+Y4dqwo05HqrRL9YNF7QVMRfq1/pguwKLG+q9UB/Lk0x5qXjO23JjJg+/jqCHSTaG1P3tfKfuw==", "requires": { "semver": "^5.4.1" } @@ -4035,15 +4060,16 @@ "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" }, "parse-asn1": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz", - "integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==", + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.4.tgz", + "integrity": "sha512-Qs5duJcuvNExRfFZ99HDD3z4mAi3r9Wl/FOjEOijlxwCZs7E7mW2vjTpgQ4J8LpTF8x5v+1Vn5UQFejmWT11aw==", "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" + "pbkdf2": "^3.0.3", + "safe-buffer": "^5.1.1" } }, "path-is-absolute": { @@ -4065,9 +4091,9 @@ "dev": true }, "pbkdf2": { - "version": "3.0.16", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.16.tgz", - "integrity": "sha512-y4CXP3thSxqf7c0qmOF+9UeOTrifiVTIM+u7NWlq+PRsHbr7r7dpCmvzrZxa96JJUNi0Y5w9VqG5ZNeCVMoDcA==", + "version": "3.0.17", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", + "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", "requires": { "create-hash": "^1.1.2", "create-hmac": "^1.1.4", @@ -4109,16 +4135,25 @@ "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" }, "public-encrypt": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.2.tgz", - "integrity": "sha512-4kJ5Esocg8X3h8YgJsKAuoesBgB7mqH3eowiDzMUPKiRDDE7E/BqqZD1hnTByIaAFiwAw246YEltSq7tdrOH0Q==", + "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" + "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 + } } }, "pump": { @@ -4141,9 +4176,9 @@ "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" }, "randombytes": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz", - "integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", "requires": { "safe-buffer": "^5.1.0" } @@ -4421,16 +4456,16 @@ } }, "tar-stream": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.1.tgz", - "integrity": "sha512-IFLM5wp3QrJODQFPm6/to3LJZrONdBY/otxcvDIQzu217zKye6yVR3hhi9lAjrC2Z+m/j5oDxMPb1qcd8cIvpA==", + "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.1.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.0", + "to-buffer": "^1.1.1", "xtend": "^4.0.0" } }, diff --git a/package.json b/package.json index bfb4feb575..9d11514939 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nem2-sdk", - "version": "0.10.1", + "version": "0.10.2", "description": "Reactive Nem2 sdk for typescript and javascript", "scripts": { "pretest": "npm run build", @@ -53,7 +53,7 @@ "@types/crypto-js": "^3.1.43", "crypto-js": "^3.1.9-1", "js-joda": "^1.6.2", - "nem2-library": "^0.9.5", + "nem2-library": "^0.9.6", "request": "^2.83.0", "request-promise-native": "^1.0.5", "rxjs": "^6.2.1", diff --git a/src/infrastructure/MosaicHttp.ts b/src/infrastructure/MosaicHttp.ts index 50b9ff75b2..d23b64b141 100644 --- a/src/infrastructure/MosaicHttp.ts +++ b/src/infrastructure/MosaicHttp.ts @@ -20,7 +20,6 @@ import {map, mergeMap} from 'rxjs/operators'; import {PublicAccount} from '../model/account/PublicAccount'; import {MosaicId} from '../model/mosaic/MosaicId'; import {MosaicInfo} from '../model/mosaic/MosaicInfo'; -import {MosaicName} from '../model/mosaic/MosaicName'; import {MosaicProperties} from '../model/mosaic/MosaicProperties'; import {NamespaceId} from '../model/namespace/NamespaceId'; import {UInt64} from '../model/UInt64'; @@ -65,8 +64,8 @@ export class MosaicHttp extends Http implements MosaicRepository { mosaicInfoDTO.meta.active, mosaicInfoDTO.meta.index, mosaicInfoDTO.meta.id, - new NamespaceId(mosaicInfoDTO.mosaic.namespaceId), new MosaicId(mosaicInfoDTO.mosaic.mosaicId), + new UInt64(mosaicInfoDTO.mosaic.nonce), new UInt64(mosaicInfoDTO.mosaic.supply), new UInt64(mosaicInfoDTO.mosaic.height), PublicAccount.createFromPublicKey(mosaicInfoDTO.mosaic.owner, networkType), @@ -97,8 +96,8 @@ export class MosaicHttp extends Http implements MosaicRepository { mosaicInfoDTO.meta.active, mosaicInfoDTO.meta.index, mosaicInfoDTO.meta.id, - new NamespaceId(mosaicInfoDTO.mosaic.namespaceId), new MosaicId(mosaicInfoDTO.mosaic.mosaicId), + new UInt64(mosaicInfoDTO.mosaic.nonce), new UInt64(mosaicInfoDTO.mosaic.supply), new UInt64(mosaicInfoDTO.mosaic.height), PublicAccount.createFromPublicKey(mosaicInfoDTO.mosaic.owner, networkType), @@ -112,57 +111,4 @@ export class MosaicHttp extends Http implements MosaicRepository { }); })))); } - - /** - * Gets array of MosaicInfo from mosaics created with provided namespace - * @param namespaceId - Namespace id - * @param queryParams - (Optional) Query params - * @returns Observable - */ - public getMosaicsFromNamespace(namespaceId: NamespaceId, - queryParams?: QueryParams): Observable { - return this.getNetworkTypeObservable().pipe( - mergeMap((networkType) => observableFrom( - this.mosaicRoutesApi.getMosaicsFromNamespace(namespaceId.toHex(), queryParams != null ? queryParams : {})).pipe( - map((mosaicsDefinitionDTO) => { - return mosaicsDefinitionDTO.map((mosaicInfoDTO) => { - return new MosaicInfo( - mosaicInfoDTO.meta.active, - mosaicInfoDTO.meta.index, - mosaicInfoDTO.meta.id, - new NamespaceId(mosaicInfoDTO.mosaic.namespaceId), - new MosaicId(mosaicInfoDTO.mosaic.mosaicId), - new UInt64(mosaicInfoDTO.mosaic.supply), - new UInt64(mosaicInfoDTO.mosaic.height), - PublicAccount.createFromPublicKey(mosaicInfoDTO.mosaic.owner, networkType), - new MosaicProperties( - new UInt64(mosaicInfoDTO.mosaic.properties[0]), - (new UInt64(mosaicInfoDTO.mosaic.properties[1])).compact(), - new UInt64(mosaicInfoDTO.mosaic.properties[2]), - ), - mosaicInfoDTO.mosaic.levy, - ); - }); - })))); - } - - /** - * Gets array of MosaicName for different mosaicIds - * @param mosaicIds - Array of mosaic ids - * @returns Observable - */ - public getMosaicsName(mosaicIds: MosaicId[]): Observable { - const mosaicIdsBody = { - mosaicIds: mosaicIds.map((id) => id.toHex()), - }; - return observableFrom(this.mosaicRoutesApi.getMosaicsName(mosaicIdsBody)).pipe(map((mosaicInfosDTO) => { - return mosaicInfosDTO.map((mosaicInfoDTO) => { - return new MosaicName( - new MosaicId(mosaicInfoDTO.mosaicId), - new NamespaceId(mosaicInfoDTO.parentId), - mosaicInfoDTO.name, - ); - }); - })); - } } diff --git a/src/infrastructure/MosaicRepository.ts b/src/infrastructure/MosaicRepository.ts index ed5eaf6345..a0a98921cd 100644 --- a/src/infrastructure/MosaicRepository.ts +++ b/src/infrastructure/MosaicRepository.ts @@ -17,8 +17,6 @@ import {Observable} from 'rxjs'; import {MosaicId} from '../model/mosaic/MosaicId'; import {MosaicInfo} from '../model/mosaic/MosaicInfo'; -import {MosaicName} from '../model/mosaic/MosaicName'; -import {NamespaceId} from '../model/namespace/NamespaceId'; import {QueryParams} from './QueryParams'; /** @@ -41,20 +39,4 @@ export interface MosaicRepository { * @returns Observable */ getMosaics(mosaicIds: MosaicId[]): Observable; - - /** - * Gets array of MosaicInfo from mosaics created with provided namespace - * @param namespaceId - Namespace id - * @param queryParams - (Optional) Query params - * @returns Observable - */ - getMosaicsFromNamespace(namespaceId: NamespaceId, - queryParams?: QueryParams): Observable; - - /** - * Gets array of MosaicName for different mosaicIds - * @param mosaicIds - Array of mosaic ids - * @returns Observable - */ - getMosaicsName(mosaicIds: MosaicId[]): Observable; } diff --git a/src/infrastructure/transaction/CreateTransactionFromDTO.ts b/src/infrastructure/transaction/CreateTransactionFromDTO.ts index 2c64a65e4a..d8c610b680 100644 --- a/src/infrastructure/transaction/CreateTransactionFromDTO.ts +++ b/src/infrastructure/transaction/CreateTransactionFromDTO.ts @@ -144,9 +144,8 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr extractTransactionVersion(transactionDTO.version), Deadline.createFromDTO(transactionDTO.deadline), new UInt64(transactionDTO.fee), - new NamespaceId(transactionDTO.parentId), + transactionDTO.nonce, new MosaicId(transactionDTO.mosaicId), - transactionDTO.name, new MosaicProperties( new UInt64(transactionDTO.properties[0].value), (new UInt64(transactionDTO.properties[1].value)).compact(), diff --git a/src/model/blockchain/BlockchainStorageInfo.ts b/src/model/blockchain/BlockchainStorageInfo.ts index d0915ac501..0f3ee26d9f 100644 --- a/src/model/blockchain/BlockchainStorageInfo.ts +++ b/src/model/blockchain/BlockchainStorageInfo.ts @@ -20,21 +20,21 @@ export class BlockchainStorageInfo { /** - * @param numAccounts * @param numBlocks * @param numTransactions + * @param numAccounts */ constructor(/** - * The number accounts published in the blockchain. - */ - public readonly numAccounts: number, - /** * The number of confirmed blocks. */ public readonly numBlocks: number, /** * The number of confirmed transactions. */ - public readonly numTransactions: number) { + public readonly numTransactions: number, + /** + * The number accounts published in the blockchain. + */ + public readonly numAccounts: number) { } } diff --git a/src/model/model.ts b/src/model/model.ts index 44ea541032..f337b1f430 100644 --- a/src/model/model.ts +++ b/src/model/model.ts @@ -35,7 +35,6 @@ export * from './blockchain/NetworkType'; export * from './mosaic/Mosaic'; export * from './mosaic/MosaicInfo'; export * from './mosaic/MosaicId'; -export * from './mosaic/MosaicName'; export * from './mosaic/MosaicSupplyType'; export * from './mosaic/MosaicProperties'; export * from '../service/MosaicView'; diff --git a/src/model/mosaic/MosaicId.ts b/src/model/mosaic/MosaicId.ts index 0243a13c36..3fd6e8658a 100644 --- a/src/model/mosaic/MosaicId.ts +++ b/src/model/mosaic/MosaicId.ts @@ -42,13 +42,21 @@ export class MosaicId { constructor(id: string | number[]) { if (id instanceof Array) { this.id = new Id(id); - } else if (typeof id === 'string') { + } + /** + * Deprecated initialization with MosaicName. + * To be re-introduced after AliasTransaction implementation. + * + * @deprecated + else if (typeof id === 'string') { this.fullName = id; const limiterPosition = id.indexOf(':'); const namespaceName = id.substr(0, limiterPosition); const mosaicName = id.substr(limiterPosition + 1); this.id = new Id(MosaicIdentifierGenerator(namespaceName, mosaicName)); } + * + */ } /** diff --git a/src/model/mosaic/MosaicInfo.ts b/src/model/mosaic/MosaicInfo.ts index 770fb7fac1..7d90a1f188 100644 --- a/src/model/mosaic/MosaicInfo.ts +++ b/src/model/mosaic/MosaicInfo.ts @@ -16,9 +16,8 @@ import {PublicAccount} from '../account/PublicAccount'; import {UInt64} from '../UInt64'; -import {MosaicProperties} from './MosaicProperties'; -import {NamespaceId} from '../namespace/NamespaceId'; import {MosaicId} from './MosaicId'; +import {MosaicProperties} from './MosaicProperties'; /** * The mosaic info structure describes a mosaic. @@ -29,8 +28,7 @@ export class MosaicInfo { * @param active * @param index * @param metaId - * @param namespaceId - * @param mosaicId + * @param nonce * @param supply * @param height * @param owner @@ -49,14 +47,14 @@ export class MosaicInfo { * The meta data id. */ public readonly metaId: string, - /** - * The namespace id. - */ - public readonly namespaceId: NamespaceId, /** * The mosaic id. */ public readonly mosaicId: MosaicId, + /** + * The mosaic nonce. + */ + public readonly nonce: UInt64, /** * The mosaic supply. */ @@ -118,4 +116,5 @@ export class MosaicInfo { public isLevyMutable(): boolean { return this.properties.levyMutable; } + } diff --git a/src/model/mosaic/MosaicName.ts b/src/model/mosaic/MosaicName.ts deleted file mode 100644 index 16bfe2ef59..0000000000 --- a/src/model/mosaic/MosaicName.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 {NamespaceId} from '../namespace/NamespaceId'; -import {MosaicId} from './MosaicId'; - -/** - * The mosaic name info structure describes basic information of a mosaic and name. - */ -export class MosaicName { - - /** - * @param mosaicId - * @param namespaceId - * @param name - */ - constructor(/** - * The mosaic id. - */ - public readonly mosaicId: MosaicId, - /** - * The namespace id. - */ - public readonly namespaceId: NamespaceId, - /** - * The mosaic name. - */ - public readonly name: string) { - - } -} diff --git a/src/model/mosaic/MosaicNonce.ts b/src/model/mosaic/MosaicNonce.ts new file mode 100644 index 0000000000..35f967bf9d --- /dev/null +++ b/src/model/mosaic/MosaicNonce.ts @@ -0,0 +1,50 @@ +/* + * 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. + */ + +/** + * The mosaic nonce structure + * + * @since 1.0 + */ +export class MosaicNonce { + + /** + * Mosaic id + */ + public readonly nonce: Uint8Array; + + /** + * Create MosaicId from mosaic and namespace string id (ex: nem:xem or domain.subdom.subdome:token) + * or id in form of array number (ex: [3646934825, 3576016193]) + * + * @param id + */ + constructor(nonce: Uint8Array) { + if (nonce.length !== 4) { + throw Error('Invalid byte size for nonce, should be 4 bytes but received ' + nonce.length); + } + + this.nonce = nonce; + } + + /** + * @internal + * @returns {[number,number]} + */ + public toDTO(): Uint8Array { + return this.nonce; + } +} diff --git a/src/model/mosaic/XEM.ts b/src/model/mosaic/XEM.ts index ffa85da635..35554fb9a0 100644 --- a/src/model/mosaic/XEM.ts +++ b/src/model/mosaic/XEM.ts @@ -49,15 +49,13 @@ export class XEM extends Mosaic { /** * mosaicId + * + * UInt64 XEM mosaic ID: [481110499, 231112638] + * Hexadecimal XEM mosaic ID: 85bbea6cc462b244 + * * @type {Id} */ - public static MOSAIC_ID = new MosaicId('nem:xem'); - - /** - * namespaceId - * @type {Id} - */ - public static NAMESPACE_ID = new NamespaceId('nem'); + public static MOSAIC_ID = new MosaicId([481110499, 231112638]); /** * constructor diff --git a/src/model/transaction/AggregateTransaction.ts b/src/model/transaction/AggregateTransaction.ts index a14106085d..870c336ded 100644 --- a/src/model/transaction/AggregateTransaction.ts +++ b/src/model/transaction/AggregateTransaction.ts @@ -26,6 +26,7 @@ import { SignedTransaction } from './SignedTransaction'; import { Transaction } from './Transaction'; import { TransactionInfo } from './TransactionInfo'; import { TransactionType } from './TransactionType'; +import { TransactionVersion } from './TransactionVersion'; /** * Aggregate innerTransactions contain multiple innerTransactions that can be initiated by different accounts. @@ -77,7 +78,7 @@ export class AggregateTransaction extends Transaction { cosignatures: AggregateTransactionCosignature[]): AggregateTransaction { return new AggregateTransaction(networkType, TransactionType.AGGREGATE_COMPLETE, - 2, + TransactionVersion.AGGREGATE_COMPLETE, deadline, new UInt64([0, 0]), innerTransactions, @@ -99,7 +100,7 @@ export class AggregateTransaction extends Transaction { cosignatures: AggregateTransactionCosignature[] = []): AggregateTransaction { return new AggregateTransaction(networkType, TransactionType.AGGREGATE_BONDED, - 2, + TransactionVersion.AGGREGATE_BONDED, deadline, new UInt64([0, 0]), innerTransactions, diff --git a/src/model/transaction/LockFundsTransaction.ts b/src/model/transaction/LockFundsTransaction.ts index d4846d7149..7e676b0e48 100644 --- a/src/model/transaction/LockFundsTransaction.ts +++ b/src/model/transaction/LockFundsTransaction.ts @@ -24,6 +24,7 @@ import { SignedTransaction } from './SignedTransaction'; import { Transaction } from './Transaction'; import { TransactionInfo } from './TransactionInfo'; import { TransactionType } from './TransactionType'; +import { TransactionVersion } from './TransactionVersion'; /** * Lock funds transaction is used before sending an Aggregate bonded transaction, as a deposit to announce the transaction. @@ -53,7 +54,7 @@ export class LockFundsTransaction extends Transaction { networkType: NetworkType): LockFundsTransaction { return new LockFundsTransaction( networkType, - 3, + TransactionVersion.LOCK, deadline, UInt64.fromUint(0), mosaic, diff --git a/src/model/transaction/ModifyMultisigAccountTransaction.ts b/src/model/transaction/ModifyMultisigAccountTransaction.ts index ebf3e2e98f..5f489a83c1 100644 --- a/src/model/transaction/ModifyMultisigAccountTransaction.ts +++ b/src/model/transaction/ModifyMultisigAccountTransaction.ts @@ -23,6 +23,7 @@ import { MultisigCosignatoryModification } from './MultisigCosignatoryModificati import { Transaction } from './Transaction'; import { TransactionInfo } from './TransactionInfo'; import { TransactionType } from './TransactionType'; +import { TransactionVersion } from './TransactionVersion'; /** * Modify multisig account transactions are part of the NEM's multisig account system. @@ -47,7 +48,7 @@ export class ModifyMultisigAccountTransaction extends Transaction { modifications: MultisigCosignatoryModification[], networkType: NetworkType): ModifyMultisigAccountTransaction { return new ModifyMultisigAccountTransaction(networkType, - 3, + TransactionVersion.MODIFY_MULTISIG_ACCOUNT, deadline, new UInt64([0, 0]), minApprovalDelta, diff --git a/src/model/transaction/MosaicDefinitionTransaction.ts b/src/model/transaction/MosaicDefinitionTransaction.ts index f83cc9ca9a..7da9d80169 100644 --- a/src/model/transaction/MosaicDefinitionTransaction.ts +++ b/src/model/transaction/MosaicDefinitionTransaction.ts @@ -18,6 +18,7 @@ import { MosaicCreationTransaction as MosaicDefinitionTransactionLibrary, mosaic import { PublicAccount } from '../account/PublicAccount'; import { NetworkType } from '../blockchain/NetworkType'; import { MosaicId } from '../mosaic/MosaicId'; +import { MosaicNonce } from '../mosaic/MosaicNonce'; import { MosaicProperties } from '../mosaic/MosaicProperties'; import { NamespaceId } from '../namespace/NamespaceId'; import { UInt64 } from '../UInt64'; @@ -25,6 +26,7 @@ import { Deadline } from './Deadline'; import { Transaction } from './Transaction'; import { TransactionInfo } from './TransactionInfo'; import { TransactionType } from './TransactionType'; +import { TransactionVersion } from './TransactionVersion'; /** * Before a mosaic can be created or transferred, a corresponding definition of the mosaic has to be created and published to the network. @@ -35,24 +37,23 @@ export class MosaicDefinitionTransaction extends Transaction { /** * Create a mosaic creation transaction object * @param deadline - The deadline to include the transaction. - * @param mosaicName - The mosaic name ex: xem. - * @param namespaceName - The namespace where mosaic will be included ex: nem. + * @param nonce - The mosaic nonce ex: [0xE6, 0xDE, 0x84, 0xB8]. + * @param mosaicId - The mosaic id ex: [481110499, 231112638]. * @param mosaicProperties - The mosaic properties. * @param networkType - The network type. * @returns {MosaicDefinitionTransaction} */ public static create(deadline: Deadline, - mosaicName: string, - namespaceName: string, + nonce: Uint8Array, + mosaicId: UInt64, mosaicProperties: MosaicProperties, networkType: NetworkType): MosaicDefinitionTransaction { return new MosaicDefinitionTransaction(networkType, - 2, + TransactionVersion.MOSAIC_DEFINITION, deadline, new UInt64([0, 0]), - new NamespaceId(namespaceName), - new MosaicId(mosaicIdLibrary(namespaceName, mosaicName)), - mosaicName, + new MosaicNonce(nonce), + new MosaicId(mosaicId.toDTO()), mosaicProperties, ); } @@ -62,9 +63,8 @@ export class MosaicDefinitionTransaction extends Transaction { * @param version * @param deadline * @param fee - * @param parentId + * @param mosaicNonce * @param mosaicId - * @param mosaicName * @param mosaicProperties * @param signature * @param signer @@ -75,17 +75,13 @@ export class MosaicDefinitionTransaction extends Transaction { deadline: Deadline, fee: UInt64, /** - * The namespace id. + * The mosaic nonce. */ - public readonly parentId: NamespaceId, + public readonly nonce: MosaicNonce, /** * The mosaic id. */ public readonly mosaicId: MosaicId, - /** - * The name of the mosaic. - */ - public readonly mosaicName: string, /** * The mosaic properties. */ @@ -107,9 +103,8 @@ export class MosaicDefinitionTransaction extends Transaction { .addVersion(this.versionToDTO()) .addDivisibility(this.mosaicProperties.divisibility) .addDuration(this.mosaicProperties.duration.toDTO()) - .addParentId(this.parentId.id.toDTO()) - .addMosaicId(this.mosaicId.id.toDTO()) - .addMosaicName(this.mosaicName); + .addNonce(this.nonce.toDTO()) + .addMosaicId(this.mosaicId.id.toDTO()); if (this.mosaicProperties.supplyMutable === true) { mosaicDefinitionTransaction = mosaicDefinitionTransaction.addSupplyMutable(); diff --git a/src/model/transaction/MosaicSupplyChangeTransaction.ts b/src/model/transaction/MosaicSupplyChangeTransaction.ts index 36fc2d626e..b5db90e8e5 100644 --- a/src/model/transaction/MosaicSupplyChangeTransaction.ts +++ b/src/model/transaction/MosaicSupplyChangeTransaction.ts @@ -24,6 +24,7 @@ import { Deadline } from './Deadline'; import { Transaction } from './Transaction'; import { TransactionInfo } from './TransactionInfo'; import { TransactionType } from './TransactionType'; +import { TransactionVersion } from './TransactionVersion'; /** * In case a mosaic has the flag 'supplyMutable' set to true, the creator of the mosaic can change the supply, @@ -46,7 +47,7 @@ export class MosaicSupplyChangeTransaction extends Transaction { delta: UInt64, networkType: NetworkType): MosaicSupplyChangeTransaction { return new MosaicSupplyChangeTransaction(networkType, - 2, + TransactionVersion.MOSAIC_SUPPLY_CHANGE, deadline, new UInt64([0, 0]), mosaicId, diff --git a/src/model/transaction/RegisterNamespaceTransaction.ts b/src/model/transaction/RegisterNamespaceTransaction.ts index cb21d7a370..4693697120 100644 --- a/src/model/transaction/RegisterNamespaceTransaction.ts +++ b/src/model/transaction/RegisterNamespaceTransaction.ts @@ -24,6 +24,7 @@ import { Deadline } from './Deadline'; import { Transaction } from './Transaction'; import { TransactionInfo } from './TransactionInfo'; import { TransactionType } from './TransactionType'; +import { TransactionVersion } from './TransactionVersion'; /** * Accounts can rent a namespace for an amount of blocks and after a this renew the contract. @@ -44,7 +45,7 @@ export class RegisterNamespaceTransaction extends Transaction { duration: UInt64, networkType: NetworkType): RegisterNamespaceTransaction { return new RegisterNamespaceTransaction(networkType, - 2, + TransactionVersion.REGISTER_NAMESPACE, deadline, new UInt64([0, 0]), NamespaceType.RootNamespace, @@ -73,7 +74,7 @@ export class RegisterNamespaceTransaction extends Transaction { parentId = parentNamespace; } return new RegisterNamespaceTransaction(networkType, - 2, + TransactionVersion.REGISTER_NAMESPACE, deadline, new UInt64([0, 0]), NamespaceType.SubNamespace, diff --git a/src/model/transaction/SecretLockTransaction.ts b/src/model/transaction/SecretLockTransaction.ts index 2972d1cc15..f08fc8d229 100644 --- a/src/model/transaction/SecretLockTransaction.ts +++ b/src/model/transaction/SecretLockTransaction.ts @@ -24,6 +24,7 @@ import { HashType, HashTypeLengthValidator } from './HashType'; import { Transaction } from './Transaction'; import { TransactionInfo } from './TransactionInfo'; import { TransactionType } from './TransactionType'; +import { TransactionVersion } from './TransactionVersion'; export class SecretLockTransaction extends Transaction { @@ -49,7 +50,7 @@ export class SecretLockTransaction extends Transaction { networkType: NetworkType): SecretLockTransaction { return new SecretLockTransaction( networkType, - 3, + TransactionVersion.SECRET_LOCK, deadline, UInt64.fromUint(0), mosaic, diff --git a/src/model/transaction/SecretProofTransaction.ts b/src/model/transaction/SecretProofTransaction.ts index 532bc21542..08b92667f9 100644 --- a/src/model/transaction/SecretProofTransaction.ts +++ b/src/model/transaction/SecretProofTransaction.ts @@ -22,6 +22,7 @@ import { HashType, HashTypeLengthValidator } from './HashType'; import { Transaction } from './Transaction'; import { TransactionInfo } from './TransactionInfo'; import { TransactionType } from './TransactionType'; +import { TransactionVersion } from './TransactionVersion'; export class SecretProofTransaction extends Transaction { @@ -43,7 +44,7 @@ export class SecretProofTransaction extends Transaction { networkType: NetworkType): SecretProofTransaction { return new SecretProofTransaction( networkType, - 3, + TransactionVersion.SECRET_PROOF, deadline, UInt64.fromUint(0), hashType, diff --git a/src/model/transaction/TransactionType.ts b/src/model/transaction/TransactionType.ts index be3218f0c2..a795c389c6 100644 --- a/src/model/transaction/TransactionType.ts +++ b/src/model/transaction/TransactionType.ts @@ -29,19 +29,19 @@ export class TransactionType { * Register namespace transaction type. * @type {number} */ - public static readonly REGISTER_NAMESPACE = 0x414e; + public static readonly REGISTER_NAMESPACE = 0x414E; /** * Mosaic definition transaction type. * @type {number} */ - public static readonly MOSAIC_DEFINITION = 0x414d; + public static readonly MOSAIC_DEFINITION = 0x414D; /** * Mosaic supply change transaction. * @type {number} */ - public static readonly MOSAIC_SUPPLY_CHANGE = 0x424d; + public static readonly MOSAIC_SUPPLY_CHANGE = 0x424D; /** * Modify multisig account transaction type. @@ -64,17 +64,17 @@ export class TransactionType { * Lock transaction type * @type {number} */ - public static readonly LOCK = 0x414C; + public static readonly LOCK = 0x4148; /** * Secret Lock Transaction type * @type {number} */ - public static readonly SECRET_LOCK = 0x424C; + public static readonly SECRET_LOCK = 0x4152; /** * Secret Proof transaction type * @type {number} */ - public static readonly SECRET_PROOF = 0x434C; + public static readonly SECRET_PROOF = 0x4252; } diff --git a/src/model/transaction/TransactionVersion.ts b/src/model/transaction/TransactionVersion.ts new file mode 100644 index 0000000000..d2cd21e703 --- /dev/null +++ b/src/model/transaction/TransactionVersion.ts @@ -0,0 +1,88 @@ +/* + * 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. + */ + +/** + * Static class containing transaction version constants. + * + * Transaction format versions are defined in catapult-server in + * each transaction's plugin source code. + * + * In [catapult-server](https://github.com/nemtech/catapult-server), the `DEFINE_TRANSACTION_CONSTANTS` macro + * is used to define the `TYPE` and `VERSION` of the transaction format. + * + * @see https://github.com/nemtech/catapult-server/blob/master/plugins/txes/transfer/src/model/TransferTransaction.h#L37 + */ +export class TransactionVersion { + + /** + * Transfer Transaction transaction version. + * @type {number} + */ + public static readonly TRANSFER = 3; + + /** + * Register namespace transaction version. + * @type {number} + */ + public static readonly REGISTER_NAMESPACE = 2; + + /** + * Mosaic definition transaction version. + * @type {number} + */ + public static readonly MOSAIC_DEFINITION = 3; + + /** + * Mosaic supply change transaction. + * @type {number} + */ + public static readonly MOSAIC_SUPPLY_CHANGE = 2; + + /** + * Modify multisig account transaction version. + * @type {number} + */ + public static readonly MODIFY_MULTISIG_ACCOUNT = 3; + + /** + * Aggregate complete transaction version. + * @type {number} + */ + public static readonly AGGREGATE_COMPLETE = 2; + + /** + * Aggregate bonded transaction version + */ + public static readonly AGGREGATE_BONDED = 2; + + /** + * Lock transaction version + * @type {number} + */ + public static readonly LOCK = 1; + + /** + * Secret Lock transaction version + * @type {number} + */ + public static readonly SECRET_LOCK = 1; + + /** + * Secret Proof transaction version + * @type {number} + */ + public static readonly SECRET_PROOF = 1; +} diff --git a/src/model/transaction/TransferTransaction.ts b/src/model/transaction/TransferTransaction.ts index c4608921de..736b52cf36 100644 --- a/src/model/transaction/TransferTransaction.ts +++ b/src/model/transaction/TransferTransaction.ts @@ -25,6 +25,7 @@ import { Message } from './Message'; import { Transaction } from './Transaction'; import { TransactionInfo } from './TransactionInfo'; import { TransactionType } from './TransactionType'; +import { TransactionVersion } from './TransactionVersion'; /** * Transfer transactions contain data about transfers of mosaics and message to another account. @@ -45,7 +46,7 @@ export class TransferTransaction extends Transaction { message: Message, networkType: NetworkType): TransferTransaction { return new TransferTransaction(networkType, - 3, + TransactionVersion.TRANSFER, deadline, new UInt64([0, 0]), recipient, diff --git a/src/service/MosaicAmountView.ts b/src/service/MosaicAmountView.ts index ca0cb1c24d..306e6bc185 100644 --- a/src/service/MosaicAmountView.ts +++ b/src/service/MosaicAmountView.ts @@ -32,14 +32,6 @@ export class MosaicAmountView { * The mosaic information */ public readonly mosaicInfo: MosaicInfo, - /** - * The parent namespace name - */ - public readonly namespaceName: string, - /** - * The mosaic name - */ - public readonly mosaicName: string, /** * The amount of absolute mosaics we have */ @@ -63,6 +55,6 @@ export class MosaicAmountView { * @returns {string} */ public fullName(): string { - return this.namespaceName + ':' + this.mosaicName; + return this.mosaicInfo.mosaicId.toHex(); } } diff --git a/src/service/MosaicService.ts b/src/service/MosaicService.ts index 64564a7ecc..805cd3a255 100644 --- a/src/service/MosaicService.ts +++ b/src/service/MosaicService.ts @@ -15,7 +15,7 @@ */ import { Observable, of as observableOf } from 'rxjs'; -import { filter, map, mergeMap, take, toArray, first } from 'rxjs/operators'; +import { filter, first, map, mergeMap, take, toArray } from 'rxjs/operators'; import { AccountHttp } from '../infrastructure/AccountHttp'; import { MosaicHttp } from '../infrastructure/MosaicHttp'; import { NamespaceHttp } from '../infrastructure/NamespaceHttp'; @@ -50,16 +50,11 @@ export class MosaicService { */ mosaicsView(mosaicIds: MosaicId[]): Observable { return observableOf(mosaicIds).pipe( - mergeMap((_) => this.mosaicHttp.getMosaics(mosaicIds)), - mergeMap((_) => _), - mergeMap((mosaicInfo: MosaicInfo) => this.mosaicHttp.getMosaicsName([mosaicInfo.mosaicId]).pipe(map((mosaicsName) => { - return { mosaicInfo, mosaicName: mosaicsName[0].name }; - }))), - mergeMap((_) => this.namespaceHttp.getNamespacesName([_.mosaicInfo.namespaceId]).pipe( - map((namespacesName) => { - return new MosaicView(_.mosaicInfo, namespacesName[0].name, _.mosaicName); - }))), - toArray()); + mergeMap((_) => this.mosaicHttp.getMosaics(mosaicIds).pipe( + map((mosaicInfo: MosaicInfo) => { + return new MosaicView(mosaicInfo); + }), + toArray()))); } /** @@ -73,10 +68,7 @@ export class MosaicService { mergeMap((mosaic: Mosaic) => this.mosaicsView([mosaic.id]).pipe( filter((_) => _.length !== 0), map((mosaicViews) => { - return new MosaicAmountView(mosaicViews[0].mosaicInfo, - mosaicViews[0].namespaceName, - mosaicViews[0].mosaicName, - mosaic.amount); + return new MosaicAmountView(mosaicViews[0].mosaicInfo, mosaic.amount); }), toArray()))); } diff --git a/src/service/MosaicView.ts b/src/service/MosaicView.ts index d466cdd693..83649f072e 100644 --- a/src/service/MosaicView.ts +++ b/src/service/MosaicView.ts @@ -30,23 +30,7 @@ export class MosaicView { constructor(/** * The mosaic information */ - public readonly mosaicInfo: MosaicInfo, - /** - * The parent namespace name - */ - public readonly namespaceName: string, - /** - * The mosaic name - */ - public readonly mosaicName: string) { - - } + public readonly mosaicInfo: MosaicInfo) { - /** - * Namespace and mosaic description - * @returns {string} - */ - public fullName(): string { - return this.namespaceName + ':' + this.mosaicName; } } diff --git a/test/infrastructure/Listener.spec.ts b/test/infrastructure/Listener.spec.ts index b94c72afd7..b99bd07135 100644 --- a/test/infrastructure/Listener.spec.ts +++ b/test/infrastructure/Listener.spec.ts @@ -40,8 +40,8 @@ describe('Listener', () => { throw new Error('This should not be called when expecting error'); }) .catch((error) => { - expect(error.toString()).to.be.equal("Error: getaddrinfo ENOTFOUND notcorrecturl notcorrecturl:0000"); - }) + expect(error.message.toString()).to.be.equal("getaddrinfo ENOTFOUND notcorrecturl notcorrecturl:0000"); + }); }); }); }); diff --git a/test/model/blockchain/BlockchainStorageInfo.spec.ts b/test/model/blockchain/BlockchainStorageInfo.spec.ts index 02353bd5f6..949bc665df 100644 --- a/test/model/blockchain/BlockchainStorageInfo.spec.ts +++ b/test/model/blockchain/BlockchainStorageInfo.spec.ts @@ -21,15 +21,15 @@ describe('BlockchainStorageInfo', () => { it('should createComplete an BlockchainStorageInfo object', () => { const blockchainStorageInfoDTO = { - numAccounts: 10, numBlocks: 1, numTransactions: 100, + numAccounts: 10, }; const blockchainScore = new BlockchainStorageInfo( - blockchainStorageInfoDTO.numAccounts, blockchainStorageInfoDTO.numBlocks, blockchainStorageInfoDTO.numTransactions, + blockchainStorageInfoDTO.numAccounts, ); expect(blockchainScore.numAccounts).to.be.equal(blockchainStorageInfoDTO.numAccounts); diff --git a/test/model/mosaic/MosaicAmountView.spec.ts b/test/model/mosaic/MosaicAmountView.spec.ts index b09bda4af2..97c0704c3a 100644 --- a/test/model/mosaic/MosaicAmountView.spec.ts +++ b/test/model/mosaic/MosaicAmountView.spec.ts @@ -29,8 +29,8 @@ describe('MosaicAmountView', () => { let mosaicInfo: MosaicInfo; before(() => { - mosaicInfo = new MosaicInfo(true, 0, '59FDA0733F17CF0001772CBC', new NamespaceId([929036875, 2226345261]), - new MosaicId([3646934825, 3576016193]), new UInt64([3403414400, 2095475]), new UInt64([1, 0]), + mosaicInfo = new MosaicInfo(true, 0, '59FDA0733F17CF0001772CBC', new MosaicId([3294802500, 2243684972]), + new UInt64([1, 0]), new UInt64([3403414400, 2095475]), new UInt64([1, 0]), PublicAccount.createFromPublicKey('B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF', NetworkType.MIJIN_TEST), MosaicProperties.create({ supplyMutable: true, @@ -42,19 +42,20 @@ describe('MosaicAmountView', () => { }); it('should createComplete a Mosaic Amount View', () => { - const mosaicAmountView = new MosaicAmountView(mosaicInfo, 'namespaceName', 'mosaicName', UInt64.fromUint(100)); + const mosaicAmountView = new MosaicAmountView(mosaicInfo, UInt64.fromUint(100)); expect(mosaicAmountView.amount.compact()).to.be.equal(100); - expect(mosaicAmountView.namespaceName).to.be.equal('namespaceName'); - expect(mosaicAmountView.mosaicName).to.be.equal('mosaicName'); + expect(mosaicAmountView.mosaicInfo).to.be.an.instanceof(MosaicInfo); }); it('should createComplete a Mosaic Amount View get relative amount', () => { - const mosaicAmountView = new MosaicAmountView(mosaicInfo, 'namespaceName', 'mosaicName', UInt64.fromUint(100)); + const mosaicAmountView = new MosaicAmountView(mosaicInfo, UInt64.fromUint(100)); expect(mosaicAmountView.relativeAmount()).to.be.equal(100 / Math.pow(10, 3)); + expect(mosaicAmountView.mosaicInfo).to.be.an.instanceof(MosaicInfo); }); - it('should createComplete a Mosaic Amount View get correct fullName', () => { - const mosaicAmountView = new MosaicAmountView(mosaicInfo, 'namespaceName', 'mosaicName', UInt64.fromUint(100)); - expect(mosaicAmountView.fullName()).to.be.equal('namespaceName:mosaicName'); + it('should createComplete a Mosaic Amount View get correct amount', () => { + const mosaicAmountView = new MosaicAmountView(mosaicInfo, UInt64.fromUint(100)); + expect(mosaicAmountView.mosaicInfo).to.be.an.instanceof(MosaicInfo); + expect(mosaicAmountView.amount.compact()).to.be.equal(100); }); }); diff --git a/test/model/mosaic/MosaicId.spec.ts b/test/model/mosaic/MosaicId.spec.ts index a58f34122c..24214c4057 100644 --- a/test/model/mosaic/MosaicId.spec.ts +++ b/test/model/mosaic/MosaicId.spec.ts @@ -20,15 +20,22 @@ import {MosaicId} from '../../../src/model/mosaic/MosaicId'; describe('MosaicId', () => { + /** + * Deprecated initialization with MosaicName. + * To be re-introduced after AliasTransaction implementation. + * + * @deprecated it('should be created from full name', () => { const id = new MosaicId('nem:xem'); - deepEqual(id.id, new Id([3646934825, 3576016193])); + deepEqual(id.id, new Id([3294802500, 2243684972])); expect(id.fullName).to.be.equal('nem:xem'); }); + * + */ it('should be created from id', () => { - const id = new MosaicId([3646934825, 3576016193]); - deepEqual(id.id, new Id([3646934825, 3576016193])); + const id = new MosaicId([3294802500, 2243684972]); + deepEqual(id.id, new Id([3294802500, 2243684972])); expect(id.fullName).to.be.equal(undefined); }); }); diff --git a/test/model/mosaic/MosaicInfo.spec.ts b/test/model/mosaic/MosaicInfo.spec.ts index e731048b60..d9f7243658 100644 --- a/test/model/mosaic/MosaicInfo.spec.ts +++ b/test/model/mosaic/MosaicInfo.spec.ts @@ -35,7 +35,7 @@ describe('MosaicInfo', () => { height: new UInt64([1, 0]), levy: {}, mosaicId: new MosaicId([3646934825, 3576016193]), - namespaceId: new NamespaceId([929036875, 2226345261]), + nonce: new UInt64([1, 0]), owner: PublicAccount.createFromPublicKey('B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF', NetworkType.MIJIN_TEST), properties: [ @@ -65,8 +65,8 @@ describe('MosaicInfo', () => { mosaicInfoDTO.meta.active, mosaicInfoDTO.meta.index, mosaicInfoDTO.meta.id, - mosaicInfoDTO.mosaic.namespaceId, mosaicInfoDTO.mosaic.mosaicId, + mosaicInfoDTO.mosaic.nonce, mosaicInfoDTO.mosaic.supply, mosaicInfoDTO.mosaic.height, mosaicInfoDTO.mosaic.owner, @@ -81,8 +81,8 @@ describe('MosaicInfo', () => { expect(mosaicInfo.active).to.be.equal(mosaicInfoDTO.meta.active); expect(mosaicInfo.index).to.be.equal(mosaicInfoDTO.meta.index); expect(mosaicInfo.metaId).to.be.equal(mosaicInfoDTO.meta.id); - deepEqual(mosaicInfo.namespaceId, mosaicInfoDTO.mosaic.namespaceId); deepEqual(mosaicInfo.mosaicId, mosaicInfoDTO.mosaic.mosaicId); + deepEqual(mosaicInfo.nonce, mosaicInfoDTO.mosaic.nonce); deepEqual(mosaicInfo.supply, mosaicInfoDTO.mosaic.supply); deepEqual(mosaicInfo.height, mosaicInfoDTO.mosaic.height); expect(mosaicInfo.owner).to.be.equal(mosaicInfoDTO.mosaic.owner); @@ -98,8 +98,8 @@ describe('MosaicInfo', () => { mosaicInfoDTO.meta.active, mosaicInfoDTO.meta.index, mosaicInfoDTO.meta.id, - mosaicInfoDTO.mosaic.namespaceId, mosaicInfoDTO.mosaic.mosaicId, + mosaicInfoDTO.mosaic.nonce, mosaicInfoDTO.mosaic.supply, mosaicInfoDTO.mosaic.height, mosaicInfoDTO.mosaic.owner, @@ -121,8 +121,8 @@ describe('MosaicInfo', () => { mosaicInfoDTO.meta.active, mosaicInfoDTO.meta.index, mosaicInfoDTO.meta.id, - mosaicInfoDTO.mosaic.namespaceId, mosaicInfoDTO.mosaic.mosaicId, + mosaicInfoDTO.mosaic.nonce, mosaicInfoDTO.mosaic.supply, mosaicInfoDTO.mosaic.height, mosaicInfoDTO.mosaic.owner, @@ -145,8 +145,8 @@ describe('MosaicInfo', () => { mosaicInfoDTO.meta.active, mosaicInfoDTO.meta.index, mosaicInfoDTO.meta.id, - mosaicInfoDTO.mosaic.namespaceId, mosaicInfoDTO.mosaic.mosaicId, + mosaicInfoDTO.mosaic.nonce, mosaicInfoDTO.mosaic.supply, mosaicInfoDTO.mosaic.height, mosaicInfoDTO.mosaic.owner, @@ -167,8 +167,8 @@ describe('MosaicInfo', () => { mosaicInfoDTO.meta.active, mosaicInfoDTO.meta.index, mosaicInfoDTO.meta.id, - mosaicInfoDTO.mosaic.namespaceId, mosaicInfoDTO.mosaic.mosaicId, + mosaicInfoDTO.mosaic.nonce, mosaicInfoDTO.mosaic.supply, mosaicInfoDTO.mosaic.height, mosaicInfoDTO.mosaic.owner, @@ -191,8 +191,8 @@ describe('MosaicInfo', () => { mosaicInfoDTO.meta.active, mosaicInfoDTO.meta.index, mosaicInfoDTO.meta.id, - mosaicInfoDTO.mosaic.namespaceId, mosaicInfoDTO.mosaic.mosaicId, + mosaicInfoDTO.mosaic.nonce, mosaicInfoDTO.mosaic.supply, mosaicInfoDTO.mosaic.height, mosaicInfoDTO.mosaic.owner, @@ -213,8 +213,8 @@ describe('MosaicInfo', () => { mosaicInfoDTO.meta.active, mosaicInfoDTO.meta.index, mosaicInfoDTO.meta.id, - mosaicInfoDTO.mosaic.namespaceId, mosaicInfoDTO.mosaic.mosaicId, + mosaicInfoDTO.mosaic.nonce, mosaicInfoDTO.mosaic.supply, mosaicInfoDTO.mosaic.height, mosaicInfoDTO.mosaic.owner, diff --git a/test/model/mosaic/MosaicName.spec.ts b/test/model/mosaic/MosaicName.spec.ts deleted file mode 100644 index 04cc801a7a..0000000000 --- a/test/model/mosaic/MosaicName.spec.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 {deepEqual} from 'assert'; -import {expect} from 'chai'; -import {MosaicId} from '../../../src/model/mosaic/MosaicId'; -import {MosaicName} from '../../../src/model/mosaic/MosaicName'; -import {NamespaceId} from '../../../src/model/namespace/NamespaceId'; - -describe('MosaicName', () => { - - it('should createComplete an MosaicName object', () => { - const mosaicNameDTO = { - mosaicId: new MosaicId([ 3646934825, 3576016193 ]), - name: 'xem', - parentId: new NamespaceId([ 929036875, 2226345261 ]), - }; - - const mosaicName = new MosaicName( - mosaicNameDTO.mosaicId, - mosaicNameDTO.parentId, - mosaicNameDTO.name, - ); - - deepEqual(mosaicName.mosaicId, mosaicNameDTO.mosaicId); - deepEqual(mosaicName.namespaceId, mosaicNameDTO.parentId); - expect(mosaicName.name).to.be.equal(mosaicNameDTO.name); - }); -}); diff --git a/test/model/mosaic/MosaicView.spec.ts b/test/model/mosaic/MosaicView.spec.ts index 6616d1db45..263be0e0f9 100644 --- a/test/model/mosaic/MosaicView.spec.ts +++ b/test/model/mosaic/MosaicView.spec.ts @@ -29,8 +29,8 @@ describe('MosaicView', () => { let mosaicInfo: MosaicInfo; before(() => { - mosaicInfo = new MosaicInfo(true, 0, '59FDA0733F17CF0001772CBC', new NamespaceId([929036875, 2226345261]), - new MosaicId([3646934825, 3576016193]), new UInt64([3403414400, 2095475]), new UInt64([1, 0]), + mosaicInfo = new MosaicInfo(true, 0, '59FDA0733F17CF0001772CBC', new MosaicId([3294802500, 2243684972]), + new UInt64([1, 0]), new UInt64([3403414400, 2095475]), new UInt64([1, 0]), PublicAccount.createFromPublicKey('B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF', NetworkType.MIJIN_TEST), MosaicProperties.create({ supplyMutable: true, @@ -42,13 +42,7 @@ describe('MosaicView', () => { }); it('should createComplete a Mosaic View', () => { - const mosaicView = new MosaicView(mosaicInfo, 'namespaceName', 'mosaicName'); - expect(mosaicView.namespaceName).to.be.equal('namespaceName'); - expect(mosaicView.mosaicName).to.be.equal('mosaicName'); - }); - - it('should createComplete a Mosaic View get correct fullName', () => { - const mosaicView = new MosaicView(mosaicInfo, 'namespaceName', 'mosaicName'); - expect(mosaicView.fullName()).to.be.equal('namespaceName:mosaicName'); + const mosaicView = new MosaicView(mosaicInfo); + expect(mosaicView.mosaicInfo).to.be.an.instanceof(MosaicInfo); }); }); diff --git a/test/model/mosaic/XEM.spec.ts b/test/model/mosaic/XEM.spec.ts index c5ecf37ea5..7f1f3ccf13 100644 --- a/test/model/mosaic/XEM.spec.ts +++ b/test/model/mosaic/XEM.spec.ts @@ -26,7 +26,7 @@ describe('XEM', () => { const xem = XEM.createRelative(1000); - deepEqual(xem.id.id.toHex(), 'd525ad41d95fcf29'); + deepEqual(xem.id.id.toHex(), '0dc67fbe1cad29e3'); expect(xem.amount.compact()).to.be.equal(1000 * 1000000); }); @@ -37,7 +37,6 @@ describe('XEM', () => { }); it('should have valid statics', () => { - deepEqual(XEM.NAMESPACE_ID.id, new NamespaceId([929036875, 2226345261]).id); - deepEqual(XEM.MOSAIC_ID.id, new MosaicId([3646934825, 3576016193]).id); + deepEqual(XEM.MOSAIC_ID.id, new MosaicId([481110499, 231112638]).id); }); }); diff --git a/test/model/namespace/NamespaceId.spec.ts b/test/model/namespace/NamespaceId.spec.ts index 8eb0accb08..4f149b5f3c 100644 --- a/test/model/namespace/NamespaceId.spec.ts +++ b/test/model/namespace/NamespaceId.spec.ts @@ -28,7 +28,7 @@ describe('NamespaceId', () => { it('should be created from subnamespace name ', () => { const id = new NamespaceId('nem.subnem'); - deepEqual(id.id, new Id([373240754, 1680408751])); + deepEqual(id.id, new Id([373240754, 3827892399])); expect(id.fullName).to.be.equal('nem.subnem'); }); diff --git a/test/model/transaction/AggregateTransaction.spec.ts b/test/model/transaction/AggregateTransaction.spec.ts index 0922129412..480d548410 100644 --- a/test/model/transaction/AggregateTransaction.spec.ts +++ b/test/model/transaction/AggregateTransaction.spec.ts @@ -92,14 +92,14 @@ describe('AggregateTransaction', () => { expect(signedTransaction.payload.substring( 320, signedTransaction.payload.length, - )).to.be.equal('02904E4100E803000000000000CFCBE72D994BE61B13726F6F742D746573742D6E616D657370616365'); + )).to.be.equal('02904E4100E803000000000000CFCBE72D994BE69B13726F6F742D746573742D6E616D657370616365'); }); it('should createComplete an AggregateTransaction object with MosaicDefinitionTransaction', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( Deadline.create(), - 'test-mosaic-name', - 'test-parent-name', + new Uint8Array([0xE6, 0xDE, 0x84, 0xB8]), // nonce + UInt64.fromUint(1), // ID MosaicProperties.create({ supplyMutable: true, transferable: true, @@ -119,12 +119,12 @@ describe('AggregateTransaction', () => { const signedTransaction = aggregateTransaction.signWith(account); - expect(signedTransaction.payload.substring(0, 8)).to.be.equal('D1000000'); - expect(signedTransaction.payload.substring(240, 256)).to.be.equal('5500000055000000'); + expect(signedTransaction.payload.substring(0, 8)).to.be.equal('BC000000'); + expect(signedTransaction.payload.substring(240, 256)).to.be.equal('4000000040000000'); expect(signedTransaction.payload.substring( 320, signedTransaction.payload.length, - )).to.be.equal('02904D41967D149BA9BC5A5B4CCCD78612DDF5CA10010703746573742D6D6F736169632D6E616D6502E803000000000000'); + )).to.be.equal('03904D41E6DE84B8010000000000000001070302E803000000000000'); }); it('should createComplete an AggregateTransaction object with MosaicSupplyChangeTransaction', () => { diff --git a/test/model/transaction/MosaicDefinitionTransaction.spec.ts b/test/model/transaction/MosaicDefinitionTransaction.spec.ts index fa321b103d..7d1e0db358 100644 --- a/test/model/transaction/MosaicDefinitionTransaction.spec.ts +++ b/test/model/transaction/MosaicDefinitionTransaction.spec.ts @@ -22,6 +22,7 @@ import {Deadline} from '../../../src/model/transaction/Deadline'; import {MosaicDefinitionTransaction} from '../../../src/model/transaction/MosaicDefinitionTransaction'; import {UInt64} from '../../../src/model/UInt64'; import {TestingAccount} from '../../conf/conf.spec'; +import {convert, mosaicId, uint64 as uint64_t} from 'nem2-library'; describe('MosaicDefinitionTransaction', () => { let account: Account; @@ -33,8 +34,8 @@ describe('MosaicDefinitionTransaction', () => { it('should createComplete an MosaicDefinitionTransaction object and sign it with flags 7', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( Deadline.create(), - 'test-mosaic-name', - 'test-parent-name', + new Uint8Array([0xE6, 0xDE, 0x84, 0xB8]), + UInt64.fromUint(1), MosaicProperties.create({ supplyMutable: true, transferable: true, @@ -45,7 +46,6 @@ describe('MosaicDefinitionTransaction', () => { NetworkType.MIJIN_TEST, ); - expect(mosaicDefinitionTransaction.mosaicName).to.be.equal('test-mosaic-name'); expect(mosaicDefinitionTransaction.mosaicProperties.duration.lower).to.be.equal(1000); expect(mosaicDefinitionTransaction.mosaicProperties.duration.higher).to.be.equal(0); expect(mosaicDefinitionTransaction.mosaicProperties.divisibility).to.be.equal(3); @@ -58,15 +58,17 @@ describe('MosaicDefinitionTransaction', () => { expect(signedTransaction.payload.substring( 240, signedTransaction.payload.length, - )).to.be.equal('967D149BA9BC5A5B4CCCD78612DDF5CA10010703746573742D6D6F736169632D6E616D6502E803000000000000'); + )).to.be.equal('E6DE84B8010000000000000001070302E803000000000000'); }); it('should createComplete an MosaicDefinitionTransaction object and sign it with flags 0', () => { + + const nonce = [0xE6, 0xDE, 0x84, 0xB8]; const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( Deadline.create(), - 'test-mosaic-name', - 'test-parent-name', + new Uint8Array(nonce), + UInt64.fromUint(mosaicId(nonce, convert.hexToUint8(account.publicKey))), MosaicProperties.create({ supplyMutable: false, transferable: false, @@ -77,7 +79,6 @@ describe('MosaicDefinitionTransaction', () => { NetworkType.MIJIN_TEST, ); - expect(mosaicDefinitionTransaction.mosaicName).to.be.equal('test-mosaic-name'); expect(mosaicDefinitionTransaction.mosaicProperties.duration.lower).to.be.equal(1000); expect(mosaicDefinitionTransaction.mosaicProperties.duration.higher).to.be.equal(0); expect(mosaicDefinitionTransaction.mosaicProperties.divisibility).to.be.equal(3); @@ -90,7 +91,7 @@ describe('MosaicDefinitionTransaction', () => { expect(signedTransaction.payload.substring( 240, signedTransaction.payload.length, - )).to.be.equal('967D149BA9BC5A5B4CCCD78612DDF5CA10010003746573742D6D6F736169632D6E616D6502E803000000000000'); + )).to.be.equal('E6DE84B8000000000000000001000302E803000000000000'); }); }); diff --git a/test/model/transaction/RegisterNamespaceTransaction.spec.ts b/test/model/transaction/RegisterNamespaceTransaction.spec.ts index 1c66715053..8ff4745066 100644 --- a/test/model/transaction/RegisterNamespaceTransaction.spec.ts +++ b/test/model/transaction/RegisterNamespaceTransaction.spec.ts @@ -45,7 +45,7 @@ describe('RegisterNamespaceTransaction', () => { expect(signedTransaction.payload.substring( 240, signedTransaction.payload.length, - )).to.be.equal('00E803000000000000CFCBE72D994BE61B13726F6F742D746573742D6E616D657370616365'); + )).to.be.equal('00E803000000000000CFCBE72D994BE69B13726F6F742D746573742D6E616D657370616365'); }); @@ -62,7 +62,7 @@ describe('RegisterNamespaceTransaction', () => { expect(signedTransaction.payload.substring( 240, signedTransaction.payload.length, - )).to.be.equal('014DF55E7F6D8FB77F70BB66539D9C260613726F6F742D746573742D6E616D657370616365'); + )).to.be.equal('014DF55E7F6D8FB7FF924207DF2CA1BBF313726F6F742D746573742D6E616D657370616365'); }); }); diff --git a/test/model/transaction/TransactionType.spec.ts b/test/model/transaction/TransactionType.spec.ts index 3cb1d85082..140ca857e5 100644 --- a/test/model/transaction/TransactionType.spec.ts +++ b/test/model/transaction/TransactionType.spec.ts @@ -19,15 +19,15 @@ import {TransactionType} from '../../../src/model/transaction/TransactionType'; describe('TransactionType', () => { it('Should match the specification', () => { expect(TransactionType.TRANSFER).to.be.equal(0x4154); - expect(TransactionType.REGISTER_NAMESPACE).to.be.equal(0x414e); - expect(TransactionType.MOSAIC_DEFINITION).to.be.equal(0x414d); - expect(TransactionType.MOSAIC_SUPPLY_CHANGE).to.be.equal(0x424d); + expect(TransactionType.REGISTER_NAMESPACE).to.be.equal(0x414E); + expect(TransactionType.MOSAIC_DEFINITION).to.be.equal(0x414D); + expect(TransactionType.MOSAIC_SUPPLY_CHANGE).to.be.equal(0x424D); expect(TransactionType.MODIFY_MULTISIG_ACCOUNT).to.be.equal(0x4155); expect(TransactionType.AGGREGATE_COMPLETE).to.be.equal(0x4141); expect(TransactionType.AGGREGATE_BONDED).to.be.equal(0x4241); expect(TransactionType.AGGREGATE_BONDED).to.be.equal(0x4241); - expect(TransactionType.LOCK).to.be.equal(0x414C); - expect(TransactionType.SECRET_LOCK).to.be.equal(0x424C); - expect(TransactionType.SECRET_PROOF).to.be.equal(0x434C); + expect(TransactionType.LOCK).to.be.equal(0x4148); + expect(TransactionType.SECRET_LOCK).to.be.equal(0x4152); + expect(TransactionType.SECRET_PROOF).to.be.equal(0x4252); }); }); diff --git a/test/model/transaction/TransferTransaction.spec.ts b/test/model/transaction/TransferTransaction.spec.ts index b0c1647d01..7ecde070be 100644 --- a/test/model/transaction/TransferTransaction.spec.ts +++ b/test/model/transaction/TransferTransaction.spec.ts @@ -72,7 +72,8 @@ describe('TransferTransaction', () => { expect(signedTransaction.payload.substring( 240, signedTransaction.payload.length, - )).to.be.equal('9050B9837EFAB4BBE8A4B9BB32D812F9885C00D8FC1650E1420D000100746573742D6D657373616765' + - '29CF5FD941AD25D500E1F50500000000'); + )).to.be.equal( + '9050B9837EFAB4BBE8A4B9BB32D812F9885C00D8FC1650E1420D000100746573742D6D657373616765' + + 'E329AD1CBE7FC60D00E1F50500000000'); }); }); diff --git a/test/service/MosaicService.spec.ts b/test/service/MosaicService.spec.ts index f74dc52d02..b4cda237c1 100644 --- a/test/service/MosaicService.spec.ts +++ b/test/service/MosaicService.spec.ts @@ -21,6 +21,7 @@ import {NamespaceHttp} from '../../src/infrastructure/NamespaceHttp'; import {Address} from '../../src/model/account/Address'; import {Mosaic} from '../../src/model/mosaic/Mosaic'; import {MosaicId} from '../../src/model/mosaic/MosaicId'; +import {MosaicInfo} from '../../src/model/mosaic/MosaicInfo'; import {UInt64} from '../../src/model/UInt64'; import {MosaicAmountView} from '../../src/service/MosaicAmountView'; import {MosaicService} from '../../src/service/MosaicService'; @@ -29,13 +30,12 @@ import * as conf from '../conf/conf.spec'; describe('MosaicService', () => { it('mosaicsView', () => { - const mosaicId = new MosaicId([3646934825, 3576016193]); + const mosaicId = new MosaicId([3294802500, 2243684972]); const mosaicService = new MosaicService( new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL), new NamespaceHttp(conf.NIS2_URL)); return mosaicService.mosaicsView([mosaicId]).subscribe((mosaicsView: MosaicView[]) => { const mosaicView = mosaicsView[0]; - expect(mosaicView.mosaicName).to.be.equal('xem'); - expect(mosaicView.namespaceName).to.be.equal('nem'); + expect(mosaicView.mosaicInfo).to.be.an.instanceof(MosaicInfo); }); }); @@ -54,8 +54,7 @@ describe('MosaicService', () => { return mosaicService.mosaicsAmountViewFromAddress(Address.createFromRawAddress('SARNASAS2BIAB6LMFA3FPMGBPGIJGK6IJETM3ZSP')) .subscribe((mosaicsAmountView: MosaicAmountView[]) => { const mosaicAmountView = mosaicsAmountView[0]; - expect(mosaicAmountView.mosaicName).to.be.equal('xem'); - expect(mosaicAmountView.namespaceName).to.be.equal('nem'); + expect(mosaicAmountView.mosaicInfo).to.be.an.instanceof(MosaicInfo); }); }); @@ -74,8 +73,7 @@ describe('MosaicService', () => { new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL), new NamespaceHttp(conf.NIS2_URL)); return mosaicService.mosaicsAmountView([mosaic]).subscribe((mosaicsAmountView: MosaicAmountView[]) => { const mosaicAmountView = mosaicsAmountView[0]; - expect(mosaicAmountView.mosaicName).to.be.equal('xem'); - expect(mosaicAmountView.namespaceName).to.be.equal('nem'); + expect(mosaicAmountView.mosaicInfo).to.be.an.instanceof(MosaicInfo); expect(mosaicAmountView.amount.compact()).to.be.equal(1000); }); });