Skip to content

Commit

Permalink
v1.0.3: Transaction Taxonomies & Semantics for Symbol from NEM
Browse files Browse the repository at this point in the history
  • Loading branch information
ubcdevs committed Apr 17, 2021
1 parent f68334e commit 7daf09f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ Donations can also be made with cryptocurrencies and will be used for running th

## License

Copyright 2020-2021 Using Blockchain Ltd, Reg No.: 12658136, United Kingdom, All rights reserved.
Copyright 2020-2021 [Using Blockchain Ltd][ref-ltd], Reg No.: 12658136, United Kingdom, All rights reserved.

Licensed under the [AGPL v3 License](LICENSE).

[ref-docs]: https://symbol-taxonomy.symbol.ninja/

[ref-ltd]: https://using-blockchain.org
[npm-url]: https://www.npmjs.com/package/@ubcdigital/symbol-taxonomy
[npm-badge]: https://img.shields.io/npm/v/@ubcdigital/symbol-taxonomy
[size-badge]: https://img.shields.io/bundlephobia/min/@ubcdigital/symbol-taxonomy
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ubcdigital/symbol-taxonomy",
"version": "1.0.2",
"version": "1.0.3",
"license": "AGPL-3.0",
"description": "Open source library for defining transaction taxonomies and in-aggregate semantics for Symbol from NEM",
"keywords": [
Expand Down
16 changes: 10 additions & 6 deletions src/SemanticsMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ import { TaxonomyMapEntry } from './TaxonomyMap'
* @class SemanticsMap
* @since v1.0.0
* @description Class that describes indexed semantic rulesets.
*
* @example How to create a semantics map
*
* ```javascript
* import * as Lib from '@ubcdigital/symbol-taxonomy'
*
* const semantics = new Lib.SemanticsMap([
* [0, Lib.RequiredEntry([], 1, 5)],
* ])
* ```
*/
export class SemanticsMap extends Map<number, SemanticRuleset> {
/**
Expand Down Expand Up @@ -51,12 +61,6 @@ export class SemanticsMap extends Map<number, SemanticRuleset> {
return -1
}

// - Gets the next transaction following bundle(s)
const bundlesUntilIdx = numOccurences * entries.length
const nextTransaction = bundlesUntilIdx > 0 && bundlesUntilIdx < transactions.length
? transactions.slice(bundlesUntilIdx, bundlesUntilIdx+1).shift()
: null

// - Repeatable entries must be kept within boundaries
if (! this.validateBoundaries(ruleset, numOccurences)) {
return -2
Expand Down
17 changes: 10 additions & 7 deletions src/Taxonomy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,22 @@ import { SemanticRuleset } from './Semantics/SemanticRuleset'
* @example How to create a transaction taxonomy
*
* ```javascript
* import { Taxonomy, TaxonomyMap } from '@ubcdigital/symbol-taxonomy'
* import * as Lib from '@ubcdigital/symbol-taxonomy'
* import {
* AggregateTransaction,
* TransactionType as TType,
* } from 'symbol-sdk'
*
* cont taxonomy = new Taxonomy(
* const taxonomy = new Lib.Taxonomy(
* 'UBCDigital.NamedAssetCreation',
* new TaxonomyMap([
* [0, { type: TType.NAMESPACE_REGISTRATION, required: true }],
* [1, { type: TType.MOSAIC_DEFINITION, required: true }],
* [2, { type: TType.MOSAIC_SUPPLY_CHANGE, required: false }],
* [3, { type: TType.TRANSFER, required: true }],
* new Lib.TaxonomyMap([
* [0, { type: TType.NAMESPACE_REGISTRATION, required: true }],
* [1, { type: TType.MOSAIC_DEFINITION, required: true }],
* [2, { type: TType.MOSAIC_SUPPLY_CHANGE, required: false }],
* [3, { type: TType.TRANSFER, required: false }],
* ]),
* new Lib.SemanticsMap([
* [3, new Lib.OptionalEntry([], 0)]
* ])
* )
*
Expand Down

0 comments on commit 7daf09f

Please sign in to comment.