From 7eca85a174afa6164b1a53ab000684590fc13063 Mon Sep 17 00:00:00 2001 From: fboucquez Date: Tue, 9 Nov 2021 14:47:43 -0300 Subject: [PATCH] fix: added MosaicSupplyRevocation transaction support (#672) fix: upgraded bootstrap to 1.1.0 for testing Co-authored-by: Fernando --- CHANGELOG.md | 6 ++++ catapult-sdk/src/model/EntityType.js | 3 ++ catapult-sdk/src/plugins/mosaic.js | 24 +++++++++++++++ catapult-sdk/test/model/EntityType_spec.js | 1 + catapult-sdk/test/plugins/mosaic_spec.js | 31 +++++++++++++++++--- rest/package.json | 2 +- rest/yarn.lock | 34 +++++++++++++++------- 7 files changed, 86 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14173dc22..010e4e27a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The changelog format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [v2.3.9] - 8-Nov-2021 + +### Added + +- Added mosaic supply revocation transaction support. + ## [v2.3.8] - 1-Nov-2021 ### Added diff --git a/catapult-sdk/src/model/EntityType.js b/catapult-sdk/src/model/EntityType.js index eb8e84b68..4b4d9d0c7 100644 --- a/catapult-sdk/src/model/EntityType.js +++ b/catapult-sdk/src/model/EntityType.js @@ -43,6 +43,9 @@ const EntityType = { /** Mosaic supply change transaction. */ mosaicSupplyChange: 0x424D, + /** Mosaic supply revocation transaction. */ + mosaicSupplyRevocation: 0x434d, + /** Modify multisig account transaction. */ modifyMultisigAccount: 0x4155, diff --git a/catapult-sdk/src/plugins/mosaic.js b/catapult-sdk/src/plugins/mosaic.js index e1aaf4d0c..b6df03977 100644 --- a/catapult-sdk/src/plugins/mosaic.js +++ b/catapult-sdk/src/plugins/mosaic.js @@ -22,7 +22,9 @@ /** @module plugins/mosaic */ const EntityType = require('../model/EntityType'); const ModelType = require('../model/ModelType'); +const sizes = require('../modelBinary/sizes'); +const constants = { sizes }; /** * Creates a mosaic plugin. * @type {module:plugins/CatapultPlugin} @@ -43,6 +45,12 @@ const mosaicPlugin = { action: ModelType.uint8 }); + builder.addTransactionSupport(EntityType.mosaicSupplyRevocation, { + sourceAddress: ModelType.encodedAddress, + mosaicId: ModelType.uint64HexIdentifier, + amount: ModelType.uint64 + }); + builder.addSchema('mosaicDescriptor', { id: ModelType.objectId, mosaic: { type: ModelType.object, schemaName: 'mosaicDescriptor.mosaic' } @@ -97,6 +105,22 @@ const mosaicPlugin = { serializer.writeUint8(transaction.action); } }); + + codecBuilder.addTransactionSupport(EntityType.mosaicSupplyRevocation, { + deserialize: parser => { + const transaction = {}; + transaction.sourceAddress = parser.buffer(constants.sizes.addressDecoded); + transaction.mosaicId = parser.uint64(); + transaction.amount = parser.uint64(); + return transaction; + }, + + serialize: (transaction, serializer) => { + serializer.writeBuffer(transaction.sourceAddress); + serializer.writeUint64(transaction.mosaicId); + serializer.writeUint64(transaction.amount); + } + }); } }; diff --git a/catapult-sdk/test/model/EntityType_spec.js b/catapult-sdk/test/model/EntityType_spec.js index fd33be361..070f8585d 100644 --- a/catapult-sdk/test/model/EntityType_spec.js +++ b/catapult-sdk/test/model/EntityType_spec.js @@ -32,6 +32,7 @@ describe('entity type enumeration', () => { aliasMosaic: 0x434E, mosaicDefinition: 0x414D, mosaicSupplyChange: 0x424D, + mosaicSupplyRevocation: 0x434d, modifyMultisigAccount: 0x4155, aggregateComplete: 0x4141, aggregateBonded: 0x4241, diff --git a/catapult-sdk/test/plugins/mosaic_spec.js b/catapult-sdk/test/plugins/mosaic_spec.js index 987c575e4..d605fc6bd 100644 --- a/catapult-sdk/test/plugins/mosaic_spec.js +++ b/catapult-sdk/test/plugins/mosaic_spec.js @@ -28,7 +28,8 @@ const { expect } = require('chai'); const constants = { sizes: { mosaicDefinition: 22, - mosaicSupplyChange: 17 + mosaicSupplyChange: 17, + mosaicSupplyRevocation: 40 } }; @@ -44,10 +45,11 @@ describe('mosaic plugin', () => { const modelSchema = builder.build(); // Assert: - expect(Object.keys(modelSchema).length).to.equal(numDefaultKeys + 4); + expect(Object.keys(modelSchema).length).to.equal(numDefaultKeys + 5); expect(modelSchema).to.contain.all.keys( 'mosaicDefinition', 'mosaicSupplyChange', + 'mosaicSupplyRevocation', 'mosaicDescriptor', 'mosaicDescriptor.mosaic' ); @@ -89,10 +91,11 @@ describe('mosaic plugin', () => { const codecs = getCodecs(); // Assert: codecs were registered - expect(Object.keys(codecs).length).to.equal(2); + expect(Object.keys(codecs).length).to.equal(3); expect(codecs).to.contain.all.keys([ EntityType.mosaicDefinition.toString(), - EntityType.mosaicSupplyChange.toString() + EntityType.mosaicSupplyChange.toString(), + EntityType.mosaicSupplyRevocation.toString() ]); }); @@ -137,5 +140,25 @@ describe('mosaic plugin', () => { test.binary.test.addAll(getCodec(EntityType.mosaicSupplyChange), constants.sizes.mosaicSupplyChange, generateTransaction); }); + + describe('supports mosaic supply revokation', () => { + const sourceAddressBuffer = test.random.bytes(test.constants.sizes.addressDecoded); + const generateTransaction = () => ({ + buffer: Buffer.concat([ + sourceAddressBuffer, // source address + Buffer.of(0xF2, 0x26, 0x6C, 0x06, 0x40, 0x83, 0xB2, 0x92), // mosaic id + Buffer.of(0xCA, 0xD0, 0x8E, 0x6E, 0xFF, 0x21, 0x2F, 0x49) // amount + ]), + + object: { + sourceAddress: sourceAddressBuffer, + mosaicId: [0x066C26F2, 0x92B28340], + amount: [0x6E8ED0CA, 0x492F21FF] + } + }); + + test.binary.test.addAll(getCodec(EntityType.mosaicSupplyRevocation), + constants.sizes.mosaicSupplyRevocation, generateTransaction); + }); }); }); diff --git a/rest/package.json b/rest/package.json index e447f28bb..05fce24b2 100644 --- a/rest/package.json +++ b/rest/package.json @@ -46,7 +46,7 @@ "nyc": "^14.1.1", "rimraf": "^2.6.3", "sinon": "^7.3.2", - "symbol-bootstrap": "^1.1.0-alpha-202110051739" + "symbol-bootstrap": "^1.1.0" }, "dependencies": { "catapult-sdk": "link:../catapult-sdk", diff --git a/rest/yarn.lock b/rest/yarn.lock index 0a9a6e6f0..0ff9dae24 100644 --- a/rest/yarn.lock +++ b/rest/yarn.lock @@ -1467,6 +1467,13 @@ cross-env@^5.2.0: dependencies: cross-spawn "^6.0.5" +cross-fetch@^3.1.4: + version "3.1.4" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.4.tgz#9723f3a3a247bf8b89039f3a380a9244e8fa2f39" + integrity sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ== + dependencies: + node-fetch "2.6.1" + cross-spawn@^4: version "4.0.2" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-4.0.2.tgz#7b9247621c23adfdd3856004a823cbe397424d41" @@ -2665,12 +2672,7 @@ getpass@^0.1.1: dependencies: assert-plus "^1.0.0" -github-from-package@0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce" - integrity sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4= - -glob-parent@^5.0.0, glob-parent@^5.1.0, glob-parent@~5.1.0: +glob-parent@^5.0.0, glob-parent@^5.1.2, glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== @@ -4473,6 +4475,11 @@ node-fetch-npm@^2.0.2: json-parse-better-errors "^1.0.0" safe-buffer "^5.1.1" +node-fetch@2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" + integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== + node-fetch@^2.6.0: version "2.6.5" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.5.tgz#42735537d7f080a7e5f78b6c549b7146be1742fd" @@ -6555,16 +6562,17 @@ supports-hyperlinks@^2.1.0: has-flag "^4.0.0" supports-color "^7.0.0" -symbol-bootstrap@^1.1.0-alpha-202110051739: - version "1.1.0-alpha-202110051739" - resolved "https://registry.yarnpkg.com/symbol-bootstrap/-/symbol-bootstrap-1.1.0-alpha-202110051739.tgz#f4bde604286c1b63fd59dae74e2f935f4239d618" - integrity sha512-+lvlQM2IDg76HuviUgcOhwtGN8SbO70w2ccmiVOkbsOBPaDir0AUGsqaRctnZU/eZNcszJymHdKHBX9W2KrObQ== +symbol-bootstrap@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/symbol-bootstrap/-/symbol-bootstrap-1.1.0.tgz#4136fe704fdfe38dc77d33efa6d8d4b7d424e0ad" + integrity sha512-av4Znw8TqMjMeS3hEtTDw9pS6v/Hl4aJsWWOw/z9QEBlmL1PLAQh6LuS3M43jJWI8FaKJnUzvaJm5Y/TwQduYQ== dependencies: "@oclif/command" "^1.7.0" "@oclif/config" "^1.16.0" "@oclif/plugin-autocomplete" "^0.3.0" "@oclif/plugin-help" "^3.1.0" archiver "^5.2.0" + cross-fetch "^3.1.4" figlet "^1.2.4" handlebars "^4.7.7" inquirer "^7.3.3" @@ -6577,6 +6585,7 @@ symbol-bootstrap@^1.1.0-alpha-202110051739: semver "^7.3.5" shx "^0.3.2" symbol-sdk "^1.0.1" + symbol-statistics-service-typescript-fetch-client "^1.1.1-SNAPSHOT.202110302303" tslib "^1.13.0" utf8 "^2.1.2" winston "^3.3.3" @@ -6612,6 +6621,11 @@ symbol-sdk@^1.0.1: utf8 "^2.1.2" ws "^7.3.1" +symbol-statistics-service-typescript-fetch-client@^1.1.1-SNAPSHOT.202110302303: + version "1.1.1-SNAPSHOT.202110302303" + resolved "https://registry.yarnpkg.com/symbol-statistics-service-typescript-fetch-client/-/symbol-statistics-service-typescript-fetch-client-1.1.1-SNAPSHOT.202110302303.tgz#586785ec277c16c4c5b27325b3865807d9395714" + integrity sha512-rFhjyOzkerFCk5S7enq6ugSf72Pa5ck3Cna6lXOBFFEiIKVkecQKm/anrcNFhs1ijhY53N6cJta/45mMJGXgiw== + table@^5.2.3: version "5.4.6" resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e"