@iota/bundle
Advanced tools
Comparing version 1.0.0-beta.29 to 1.0.0-beta.30
@@ -1,1 +0,1 @@ | ||
{"processes":{"f6be6753-f98a-413d-ac12-e49c5eda5cc7":{"parent":null,"children":[]}},"files":{"/Users/chris/Desktop/fix-index/iota.js/packages/bundle/out/bundle/src/index.js":["f6be6753-f98a-413d-ac12-e49c5eda5cc7"]},"externalIds":{}} | ||
{"processes":{"1fc50b35-ab03-438c-856e-5a1f23fb9ed6":{"parent":null,"children":[]}},"files":{"/Users/umairsarfraz/workspace/iota.js/packages/bundle/out/bundle/src/index.js":["1fc50b35-ab03-438c-856e-5a1f23fb9ed6"]},"externalIds":{}} |
@@ -11,6 +11,6 @@ "use strict"; | ||
/** | ||
* Creates a bundle with given transaction entries. | ||
* | ||
* @method createBundle | ||
* | ||
* @summary Creates a bundle array from the given transaction entries. | ||
* | ||
* @param {BundleEntry[]} [entries=[]] - Entries of single or multiple transactions with the same address | ||
@@ -25,15 +25,40 @@ * | ||
/** | ||
* Adds given transaction entry to a bundle. | ||
* Adds transaction trits in the given entry object to a given bundle array. | ||
* | ||
* ## Related methods | ||
* | ||
* See the [converter](https://github.com/iotaledger/iota.js/tree/next/packages/converter) package for methods that convert values to trits. | ||
* | ||
* @method addEntry | ||
* | ||
* @param {object} entry - Entry of a single or multiple transactions with the same address. | ||
* @param {Int8Array} entry.address - Address. | ||
* @param {Int8Array} entry.value - Value to transfer in iotas. | ||
* @param {Int8Array} [entry.signatureOrMessage] - Signature or message fragment(s). | ||
* @param {Int8Array} [entry.timestamp] - Issuance timestamp (in seconds). | ||
* @param {Int8Array} [entry.tag] - Optional Tag, **Deprecated**. | ||
* @param {Int8Array} bundle - Bundle buffer. | ||
* @summary Adds the given transaction entry to a bundle array. | ||
* | ||
* @return {Int8Array} Bundle copy with new entries. | ||
* @memberof module:bundle | ||
* | ||
* @param {object} entry - Transaction entry object | ||
* @param {Int8Array} entry.address - An address in trits | ||
* @param {Int8Array} entry.value - An amount of IOTA tokens in trits | ||
* @param {Int8Array} [entry.signatureOrMessage] - Signature fragments or a message in trits | ||
* @param {Int8Array} [entry.issuanceTimestamp] - Unix epoch in trits | ||
* @param {Int8Array} [entry.tag] - (deprecated) | ||
* @param {Int8Array} bundle - Bundle array to which to add the entry object | ||
* | ||
* @example | ||
* ```js | ||
* let bundle = new Int8Array(); | ||
* | ||
* bundle = Bundle.addEntry(bundle, { | ||
* address: Converter.trytesToTrits(outputAddress), | ||
* value: Converter.valueToTrits(value), | ||
* issuanceTimestamp: Converter.valueToTrits(Math.floor(Date.now() / 1000)); | ||
* }); | ||
* ``` | ||
* | ||
* @return {Int8Array} A copy of the original bundle that also includes the added entries. | ||
* | ||
* @throws {errors.ILLEGAL_TRANSACTION_BUFFER_LENGTH}: Make sure that the `bundle` argument contains valid transaction trits | ||
* @throws {errors.ILLEGAL_SIGNATURE_OR_MESSAGE_LENGTH}: Make sure that the `entry.signatureOrMessage` argument contains 6,561 trits | ||
* @throws {errors.ILLEGAL_ADDRESS_LENGTH}: Make sure that the `entry.address` argument contains 243 trits | ||
* @throws {errors.ILLEGAL_VALUE_LENGTH}: Make sure that the `entry.value` argument contains 6,561 trits | ||
* @throws {errors.ILLEGAL_ISSUANCE_TIMESTAMP_LENGTH}: Make sure that the `entry.timestamp` argument contains 81 trits | ||
*/ | ||
@@ -125,11 +150,24 @@ exports.addEntry = function (bundle, entry) { | ||
/** | ||
* Finalizes a bundle by calculating the bundle hash. | ||
* This method takes an array of transaction trits, generates the bundle hash, and adds it to each transaction. | ||
* | ||
* ## Related methods | ||
* | ||
* See the [`addEntry()`]{@link #module_bundle.addEntry} method for creating new bundles. | ||
* | ||
* @method finalizeBundle | ||
* | ||
* @param {Int8Array} bundle - Bundle transaction trits | ||
* @summary Generates a bundle hash. | ||
* | ||
* @param {number} [numberOfFragments=3] | ||
* @memberof module:bundle | ||
* | ||
* @return {Int8Array} List of transactions in the finalized bundle | ||
* @param {Int8Array} bundle - Transaction trits | ||
* | ||
* @example | ||
* ```js | ||
* const result = Bundle.finalizeBundle(bundle); | ||
* ``` | ||
* | ||
* @return {Int8Array} Transaction trits that include a bundle hash | ||
* | ||
* @throws {errors.ILLEGAL_TRANSACTION_BUFFER_LENGTH}: Make sure that the `bundle` argument contains valid transaction trits | ||
*/ | ||
@@ -169,11 +207,32 @@ exports.finalizeBundle = function (bundle, numberOfFragments) { | ||
/** | ||
* Adds signature message fragments to transactions in a bundle starting at offset. | ||
* This method takes an array of transaction trits, and add the given message or signature to the transactions, starting from the given index. | ||
* | ||
* If the signature or message is too long to fit in a single transaction, it is split across the next transaction in the bundle, starting from the given index. | ||
* | ||
* ## Related methods | ||
* | ||
* See the [`addEntry()`]{@link #module_bundle.addEntry} method for creating new bundles. | ||
* | ||
* @method addSignatureOrMessage | ||
* | ||
* @param {Int8Array} bundle - Bundle buffer. | ||
* @param {Int8Array} signatureOrMessage - Signature or message to add. | ||
* @param {number} index - Transaction index as entry point for signature or message fragments. | ||
* @summary Adds signature message fragments to transactions in a bundle. | ||
* | ||
* @return {Int8Array} List of transactions in the updated bundle | ||
* @memberof module:bundle | ||
* | ||
* @param {Int8Array} bundle - Transaction trits | ||
* @param {Int8Array} signatureOrMessage - Signature or message to add to the bundle | ||
* @param {number} index - Transaction index at which to start adding the signature or message | ||
* | ||
* @example | ||
* ```js | ||
* const signature = Converter.trytesToTrits('SIGNATURE...') | ||
* bundle.set(Bundle.addSignatureOrMessage(bundle, signature, 1)); | ||
* ``` | ||
* | ||
* @return {Int8Array} Transaction trits that include a bundle hash. | ||
* | ||
* @throws {errors.ILLEGAL_TRANSACTION_BUFFER_LENGTH}: Make sure that the `bundle` argument contains valid transaction trits | ||
* @throws {errors.ILLEGAL_TRANSACTION_INDEX}: Make sure that the `index` argument is a number and that the bundle contains enough transactions | ||
* @throws {errors.ILLEGAL_SIGNATURE_OR_MESSAGE_LENGTH}: Make sure that the `signatureOrMessage` argument contains at least 6,561 trits | ||
* | ||
*/ | ||
@@ -200,13 +259,2 @@ exports.addSignatureOrMessage = function (bundle, signatureOrMessage, index) { | ||
}; | ||
/** | ||
* Sums up transaction values in a bundle starting at offset. | ||
* | ||
* @method valueSum | ||
* | ||
* @param {Int8Array} bundle - Bundle buffer. | ||
* @param {number} offset - Offset from the start of the bundle buffer. | ||
* @param {number} length - Length of transactions in which values should be summed. | ||
* | ||
* @return {number} Total value of 'length' transactions in the bundle starting at offset. | ||
*/ | ||
exports.valueSum = function (buffer, offset, length) { | ||
@@ -213,0 +261,0 @@ if (!transaction_1.isMultipleOfTransactionLength(buffer.length)) { |
{ | ||
"name": "@iota/bundle", | ||
"version": "1.0.0-beta.29", | ||
"version": "1.0.0-beta.30", | ||
"description": "Utilities for generating and signing bundles", | ||
@@ -60,6 +60,6 @@ "main": "./out/bundle/src/index.js", | ||
"dependencies": { | ||
"@iota/converter": "^1.0.0-beta.23", | ||
"@iota/kerl": "^1.0.0-beta.23", | ||
"@iota/signing": "^1.0.0-beta.23", | ||
"@iota/transaction": "^1.0.0-beta.23", | ||
"@iota/converter": "^1.0.0-beta.30", | ||
"@iota/kerl": "^1.0.0-beta.30", | ||
"@iota/signing": "^1.0.0-beta.30", | ||
"@iota/transaction": "^1.0.0-beta.30", | ||
"@types/warning": "^3.0.0", | ||
@@ -72,3 +72,3 @@ "warning": "^4.0.3" | ||
}, | ||
"gitHead": "d42eb4ac7e6fb23fedb4bbd0caa05e1ae9ee45b3" | ||
"gitHead": "9f37d7e9b4981a9b971f331ccd268646bdbce9a1" | ||
} |
132
README.md
@@ -24,77 +24,117 @@ # @iota/bundle | ||
* [~createBundle([entries])](#module_bundle..createBundle) | ||
* _static_ | ||
* [.addEntry(entry, bundle)](#module_bundle.addEntry) | ||
* [~addEntry(entry, bundle)](#module_bundle..addEntry) | ||
* [.finalizeBundle(bundle)](#module_bundle.finalizeBundle) | ||
* [~finalizeBundle(bundle)](#module_bundle..finalizeBundle) | ||
* [.addSignatureOrMessage(bundle, signatureOrMessage, index)](#module_bundle.addSignatureOrMessage) | ||
* [~addSignatureOrMessage(bundle, signatureOrMessage, index)](#module_bundle..addSignatureOrMessage) | ||
* _inner_ | ||
* [~createBundle([entries])](#module_bundle..createBundle) | ||
* [~valueSum(bundle, offset, length)](#module_bundle..valueSum) | ||
<a name="module_bundle.addEntry"></a> | ||
<a name="module_bundle..createBundle"></a> | ||
### *bundle*.addEntry(entry, bundle) | ||
**Summary**: Adds the given transaction entry to a bundle array. | ||
**Throws**: | ||
### *bundle*~createBundle([entries]) | ||
- <code>errors.ILLEGAL\_TRANSACTION\_BUFFER\_LENGTH</code> : Make sure that the `bundle` argument contains valid transaction trits | ||
- <code>errors.ILLEGAL\_SIGNATURE\_OR\_MESSAGE\_LENGTH</code> : Make sure that the `entry.signatureOrMessage` argument contains 6,561 trits | ||
- <code>errors.ILLEGAL\_ADDRESS\_LENGTH</code> : Make sure that the `entry.address` argument contains 243 trits | ||
- <code>errors.ILLEGAL\_VALUE\_LENGTH</code> : Make sure that the `entry.value` argument contains 6,561 trits | ||
- <code>errors.ILLEGAL\_ISSUANCE\_TIMESTAMP\_LENGTH</code> : Make sure that the `entry.timestamp` argument contains 81 trits | ||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| [entries] | <code>Array.<BundleEntry></code> | <code>[]</code> | Entries of single or multiple transactions with the same address | | ||
Creates a bundle with given transaction entries. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| entry | <code>object</code> | Transaction entry object | | ||
| entry.address | <code>Int8Array</code> | An address in trits | | ||
| entry.value | <code>Int8Array</code> | An amount of IOTA tokens in trits | | ||
| [entry.signatureOrMessage] | <code>Int8Array</code> | Signature fragments or a message in trits | | ||
| [entry.issuanceTimestamp] | <code>Int8Array</code> | Unix epoch in trits | | ||
| [entry.tag] | <code>Int8Array</code> | (deprecated) | | ||
| bundle | <code>Int8Array</code> | Bundle array to which to add the entry object | | ||
**Returns**: <code>Array.<Int8Array></code> - List of transactions in the bundle | ||
<a name="module_bundle..addEntry"></a> | ||
Adds transaction trits in the given entry object to a given bundle array. | ||
### *bundle*~addEntry(entry, bundle) | ||
## Related methods | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| entry | <code>object</code> | Entry of a single or multiple transactions with the same address. | | ||
| entry.address | <code>Int8Array</code> | Address. | | ||
| entry.value | <code>Int8Array</code> | Value to transfer in iotas. | | ||
| [entry.signatureOrMessage] | <code>Int8Array</code> | Signature or message fragment(s). | | ||
| [entry.timestamp] | <code>Int8Array</code> | Issuance timestamp (in seconds). | | ||
| [entry.tag] | <code>Int8Array</code> | Optional Tag, **Deprecated**. | | ||
| bundle | <code>Int8Array</code> | Bundle buffer. | | ||
See the [converter](https://github.com/iotaledger/iota.js/tree/next/packages/converter) package for methods that convert values to trits. | ||
Adds given transaction entry to a bundle. | ||
**Returns**: <code>Int8Array</code> - A copy of the original bundle that also includes the added entries. | ||
**Example** | ||
```js | ||
let bundle = new Int8Array(); | ||
**Returns**: <code>Int8Array</code> - Bundle copy with new entries. | ||
<a name="module_bundle..finalizeBundle"></a> | ||
bundle = Bundle.addEntry(bundle, { | ||
address: Converter.trytesToTrits(outputAddress), | ||
value: Converter.valueToTrits(value), | ||
issuanceTimestamp: Converter.valueToTrits(Math.floor(Date.now() / 1000)); | ||
}); | ||
``` | ||
<a name="module_bundle.finalizeBundle"></a> | ||
### *bundle*~finalizeBundle(bundle) | ||
### *bundle*.finalizeBundle(bundle) | ||
**Summary**: Generates a bundle hash. | ||
**Throws**: | ||
- <code>errors.ILLEGAL\_TRANSACTION\_BUFFER\_LENGTH</code> : Make sure that the `bundle` argument contains valid transaction trits | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| bundle | <code>Int8Array</code> | Bundle transaction trits | | ||
| bundle | <code>Int8Array</code> | Transaction trits | | ||
Finalizes a bundle by calculating the bundle hash. | ||
This method takes an array of transaction trits, generates the bundle hash, and adds it to each transaction. | ||
**Returns**: <code>Int8Array</code> - List of transactions in the finalized bundle | ||
<a name="module_bundle..addSignatureOrMessage"></a> | ||
## Related methods | ||
### *bundle*~addSignatureOrMessage(bundle, signatureOrMessage, index) | ||
See the [`addEntry()`](#module_bundle.addEntry) method for creating new bundles. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| bundle | <code>Int8Array</code> | Bundle buffer. | | ||
| signatureOrMessage | <code>Int8Array</code> | Signature or message to add. | | ||
| index | <code>number</code> | Transaction index as entry point for signature or message fragments. | | ||
**Returns**: <code>Int8Array</code> - Transaction trits that include a bundle hash | ||
**Example** | ||
```js | ||
const result = Bundle.finalizeBundle(bundle); | ||
``` | ||
<a name="module_bundle.addSignatureOrMessage"></a> | ||
Adds signature message fragments to transactions in a bundle starting at offset. | ||
### *bundle*.addSignatureOrMessage(bundle, signatureOrMessage, index) | ||
**Summary**: Adds signature message fragments to transactions in a bundle. | ||
**Throws**: | ||
**Returns**: <code>Int8Array</code> - List of transactions in the updated bundle | ||
<a name="module_bundle..valueSum"></a> | ||
- <code>errors.ILLEGAL\_TRANSACTION\_BUFFER\_LENGTH</code> : Make sure that the `bundle` argument contains valid transaction trits | ||
- <code>errors.ILLEGAL\_TRANSACTION\_INDEX</code> : Make sure that the `index` argument is a number and that the bundle contains enough transactions | ||
- <code>errors.ILLEGAL\_SIGNATURE\_OR\_MESSAGE\_LENGTH</code> : Make sure that the `signatureOrMessage` argument contains at least 6,561 trits | ||
### *bundle*~valueSum(bundle, offset, length) | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| bundle | <code>Int8Array</code> | Bundle buffer. | | ||
| offset | <code>number</code> | Offset from the start of the bundle buffer. | | ||
| length | <code>number</code> | Length of transactions in which values should be summed. | | ||
| bundle | <code>Int8Array</code> | Transaction trits | | ||
| signatureOrMessage | <code>Int8Array</code> | Signature or message to add to the bundle | | ||
| index | <code>number</code> | Transaction index at which to start adding the signature or message | | ||
Sums up transaction values in a bundle starting at offset. | ||
This method takes an array of transaction trits, and add the given message or signature to the transactions, starting from the given index. | ||
**Returns**: <code>number</code> - Total value of 'length' transactions in the bundle starting at offset. | ||
If the signature or message is too long to fit in a single transaction, it is split across the next transaction in the bundle, starting from the given index. | ||
## Related methods | ||
See the [`addEntry()`](#module_bundle.addEntry) method for creating new bundles. | ||
**Returns**: <code>Int8Array</code> - Transaction trits that include a bundle hash. | ||
**Example** | ||
```js | ||
const signature = Converter.trytesToTrits('SIGNATURE...') | ||
bundle.set(Bundle.addSignatureOrMessage(bundle, signature, 1)); | ||
``` | ||
<a name="module_bundle..createBundle"></a> | ||
### *bundle*~createBundle([entries]) | ||
**Summary**: Creates a bundle array from the given transaction entries. | ||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| [entries] | <code>Array.<BundleEntry></code> | <code>[]</code> | Entries of single or multiple transactions with the same address | | ||
**Returns**: <code>Array.<Int8Array></code> - List of transactions in the bundle |
114
src/index.ts
@@ -46,5 +46,5 @@ /** @module bundle */ | ||
/** | ||
* Creates a bundle with given transaction entries. | ||
* | ||
* @method createBundle | ||
* | ||
* @summary Creates a bundle array from the given transaction entries. | ||
* | ||
@@ -59,15 +59,40 @@ * @param {BundleEntry[]} [entries=[]] - Entries of single or multiple transactions with the same address | ||
/** | ||
* Adds given transaction entry to a bundle. | ||
* Adds transaction trits in the given entry object to a given bundle array. | ||
* | ||
* ## Related methods | ||
* | ||
* See the [converter](https://github.com/iotaledger/iota.js/tree/next/packages/converter) package for methods that convert values to trits. | ||
* | ||
* @method addEntry | ||
* | ||
* @summary Adds the given transaction entry to a bundle array. | ||
* | ||
* @memberof module:bundle | ||
* | ||
* @param {object} entry - Entry of a single or multiple transactions with the same address. | ||
* @param {Int8Array} entry.address - Address. | ||
* @param {Int8Array} entry.value - Value to transfer in iotas. | ||
* @param {Int8Array} [entry.signatureOrMessage] - Signature or message fragment(s). | ||
* @param {Int8Array} [entry.timestamp] - Issuance timestamp (in seconds). | ||
* @param {Int8Array} [entry.tag] - Optional Tag, **Deprecated**. | ||
* @param {Int8Array} bundle - Bundle buffer. | ||
* @param {object} entry - Transaction entry object | ||
* @param {Int8Array} entry.address - An address in trits | ||
* @param {Int8Array} entry.value - An amount of IOTA tokens in trits | ||
* @param {Int8Array} [entry.signatureOrMessage] - Signature fragments or a message in trits | ||
* @param {Int8Array} [entry.issuanceTimestamp] - Unix epoch in trits | ||
* @param {Int8Array} [entry.tag] - (deprecated) | ||
* @param {Int8Array} bundle - Bundle array to which to add the entry object | ||
* | ||
* @example | ||
* ```js | ||
* let bundle = new Int8Array(); | ||
* | ||
* bundle = Bundle.addEntry(bundle, { | ||
* address: Converter.trytesToTrits(outputAddress), | ||
* value: Converter.valueToTrits(value), | ||
* issuanceTimestamp: Converter.valueToTrits(Math.floor(Date.now() / 1000)); | ||
* }); | ||
* ``` | ||
* | ||
* @return {Int8Array} Bundle copy with new entries. | ||
* @return {Int8Array} A copy of the original bundle that also includes the added entries. | ||
* | ||
* @throws {errors.ILLEGAL_TRANSACTION_BUFFER_LENGTH}: Make sure that the `bundle` argument contains valid transaction trits | ||
* @throws {errors.ILLEGAL_SIGNATURE_OR_MESSAGE_LENGTH}: Make sure that the `entry.signatureOrMessage` argument contains 6,561 trits | ||
* @throws {errors.ILLEGAL_ADDRESS_LENGTH}: Make sure that the `entry.address` argument contains 243 trits | ||
* @throws {errors.ILLEGAL_VALUE_LENGTH}: Make sure that the `entry.value` argument contains 6,561 trits | ||
* @throws {errors.ILLEGAL_ISSUANCE_TIMESTAMP_LENGTH}: Make sure that the `entry.timestamp` argument contains 81 trits | ||
*/ | ||
@@ -192,11 +217,24 @@ export const addEntry = (bundle: Int8Array, entry: Partial<BundleEntry>): Int8Array => { | ||
/** | ||
* Finalizes a bundle by calculating the bundle hash. | ||
* This method takes an array of transaction trits, generates the bundle hash, and adds it to each transaction. | ||
* | ||
* ## Related methods | ||
* | ||
* See the [`addEntry()`]{@link #module_bundle.addEntry} method for creating new bundles. | ||
* | ||
* @method finalizeBundle | ||
* | ||
* @summary Generates a bundle hash. | ||
* | ||
* @memberof module:bundle | ||
* | ||
* @param {Int8Array} bundle - Bundle transaction trits | ||
* | ||
* @param {number} [numberOfFragments=3] | ||
* | ||
* @return {Int8Array} List of transactions in the finalized bundle | ||
* @param {Int8Array} bundle - Transaction trits | ||
* | ||
* @example | ||
* ```js | ||
* const result = Bundle.finalizeBundle(bundle); | ||
* ``` | ||
* | ||
* @return {Int8Array} Transaction trits that include a bundle hash | ||
* | ||
* @throws {errors.ILLEGAL_TRANSACTION_BUFFER_LENGTH}: Make sure that the `bundle` argument contains valid transaction trits | ||
*/ | ||
@@ -247,11 +285,32 @@ export const finalizeBundle = (bundle: Int8Array, numberOfFragments = 3): Int8Array => { | ||
/** | ||
* Adds signature message fragments to transactions in a bundle starting at offset. | ||
* This method takes an array of transaction trits, and add the given message or signature to the transactions, starting from the given index. | ||
* | ||
* If the signature or message is too long to fit in a single transaction, it is split across the next transaction in the bundle, starting from the given index. | ||
* | ||
* ## Related methods | ||
* | ||
* See the [`addEntry()`]{@link #module_bundle.addEntry} method for creating new bundles. | ||
* | ||
* @method addSignatureOrMessage | ||
* | ||
* @summary Adds signature message fragments to transactions in a bundle. | ||
* | ||
* @memberof module:bundle | ||
* | ||
* @param {Int8Array} bundle - Bundle buffer. | ||
* @param {Int8Array} signatureOrMessage - Signature or message to add. | ||
* @param {number} index - Transaction index as entry point for signature or message fragments. | ||
* @param {Int8Array} bundle - Transaction trits | ||
* @param {Int8Array} signatureOrMessage - Signature or message to add to the bundle | ||
* @param {number} index - Transaction index at which to start adding the signature or message | ||
* | ||
* @example | ||
* ```js | ||
* const signature = Converter.trytesToTrits('SIGNATURE...') | ||
* bundle.set(Bundle.addSignatureOrMessage(bundle, signature, 1)); | ||
* ``` | ||
* | ||
* @return {Int8Array} Transaction trits that include a bundle hash. | ||
* | ||
* @throws {errors.ILLEGAL_TRANSACTION_BUFFER_LENGTH}: Make sure that the `bundle` argument contains valid transaction trits | ||
* @throws {errors.ILLEGAL_TRANSACTION_INDEX}: Make sure that the `index` argument is a number and that the bundle contains enough transactions | ||
* @throws {errors.ILLEGAL_SIGNATURE_OR_MESSAGE_LENGTH}: Make sure that the `signatureOrMessage` argument contains at least 6,561 trits | ||
* | ||
* @return {Int8Array} List of transactions in the updated bundle | ||
*/ | ||
@@ -288,13 +347,2 @@ export const addSignatureOrMessage = (bundle: Int8Array, signatureOrMessage: Int8Array, index: number): Int8Array => { | ||
/** | ||
* Sums up transaction values in a bundle starting at offset. | ||
* | ||
* @method valueSum | ||
* | ||
* @param {Int8Array} bundle - Bundle buffer. | ||
* @param {number} offset - Offset from the start of the bundle buffer. | ||
* @param {number} length - Length of transactions in which values should be summed. | ||
* | ||
* @return {number} Total value of 'length' transactions in the bundle starting at offset. | ||
*/ | ||
export const valueSum = (buffer: Int8Array, offset: number, length: number): number => { | ||
@@ -301,0 +349,0 @@ if (!isMultipleOfTransactionLength(buffer.length)) { |
@@ -12,6 +12,6 @@ /** @module bundle */ | ||
/** | ||
* Creates a bundle with given transaction entries. | ||
* | ||
* @method createBundle | ||
* | ||
* @summary Creates a bundle array from the given transaction entries. | ||
* | ||
* @param {BundleEntry[]} [entries=[]] - Entries of single or multiple transactions with the same address | ||
@@ -23,52 +23,100 @@ * | ||
/** | ||
* Adds given transaction entry to a bundle. | ||
* Adds transaction trits in the given entry object to a given bundle array. | ||
* | ||
* ## Related methods | ||
* | ||
* See the [converter](https://github.com/iotaledger/iota.js/tree/next/packages/converter) package for methods that convert values to trits. | ||
* | ||
* @method addEntry | ||
* | ||
* @param {object} entry - Entry of a single or multiple transactions with the same address. | ||
* @param {Int8Array} entry.address - Address. | ||
* @param {Int8Array} entry.value - Value to transfer in iotas. | ||
* @param {Int8Array} [entry.signatureOrMessage] - Signature or message fragment(s). | ||
* @param {Int8Array} [entry.timestamp] - Issuance timestamp (in seconds). | ||
* @param {Int8Array} [entry.tag] - Optional Tag, **Deprecated**. | ||
* @param {Int8Array} bundle - Bundle buffer. | ||
* @summary Adds the given transaction entry to a bundle array. | ||
* | ||
* @return {Int8Array} Bundle copy with new entries. | ||
* @memberof module:bundle | ||
* | ||
* @param {object} entry - Transaction entry object | ||
* @param {Int8Array} entry.address - An address in trits | ||
* @param {Int8Array} entry.value - An amount of IOTA tokens in trits | ||
* @param {Int8Array} [entry.signatureOrMessage] - Signature fragments or a message in trits | ||
* @param {Int8Array} [entry.issuanceTimestamp] - Unix epoch in trits | ||
* @param {Int8Array} [entry.tag] - (deprecated) | ||
* @param {Int8Array} bundle - Bundle array to which to add the entry object | ||
* | ||
* @example | ||
* ```js | ||
* let bundle = new Int8Array(); | ||
* | ||
* bundle = Bundle.addEntry(bundle, { | ||
* address: Converter.trytesToTrits(outputAddress), | ||
* value: Converter.valueToTrits(value), | ||
* issuanceTimestamp: Converter.valueToTrits(Math.floor(Date.now() / 1000)); | ||
* }); | ||
* ``` | ||
* | ||
* @return {Int8Array} A copy of the original bundle that also includes the added entries. | ||
* | ||
* @throws {errors.ILLEGAL_TRANSACTION_BUFFER_LENGTH}: Make sure that the `bundle` argument contains valid transaction trits | ||
* @throws {errors.ILLEGAL_SIGNATURE_OR_MESSAGE_LENGTH}: Make sure that the `entry.signatureOrMessage` argument contains 6,561 trits | ||
* @throws {errors.ILLEGAL_ADDRESS_LENGTH}: Make sure that the `entry.address` argument contains 243 trits | ||
* @throws {errors.ILLEGAL_VALUE_LENGTH}: Make sure that the `entry.value` argument contains 6,561 trits | ||
* @throws {errors.ILLEGAL_ISSUANCE_TIMESTAMP_LENGTH}: Make sure that the `entry.timestamp` argument contains 81 trits | ||
*/ | ||
export declare const addEntry: (bundle: Int8Array, entry: Partial<BundleEntry>) => Int8Array; | ||
/** | ||
* Finalizes a bundle by calculating the bundle hash. | ||
* This method takes an array of transaction trits, generates the bundle hash, and adds it to each transaction. | ||
* | ||
* ## Related methods | ||
* | ||
* See the [`addEntry()`]{@link #module_bundle.addEntry} method for creating new bundles. | ||
* | ||
* @method finalizeBundle | ||
* | ||
* @param {Int8Array} bundle - Bundle transaction trits | ||
* @summary Generates a bundle hash. | ||
* | ||
* @param {number} [numberOfFragments=3] | ||
* @memberof module:bundle | ||
* | ||
* @return {Int8Array} List of transactions in the finalized bundle | ||
* @param {Int8Array} bundle - Transaction trits | ||
* | ||
* @example | ||
* ```js | ||
* const result = Bundle.finalizeBundle(bundle); | ||
* ``` | ||
* | ||
* @return {Int8Array} Transaction trits that include a bundle hash | ||
* | ||
* @throws {errors.ILLEGAL_TRANSACTION_BUFFER_LENGTH}: Make sure that the `bundle` argument contains valid transaction trits | ||
*/ | ||
export declare const finalizeBundle: (bundle: Int8Array, numberOfFragments?: number) => Int8Array; | ||
/** | ||
* Adds signature message fragments to transactions in a bundle starting at offset. | ||
* This method takes an array of transaction trits, and add the given message or signature to the transactions, starting from the given index. | ||
* | ||
* If the signature or message is too long to fit in a single transaction, it is split across the next transaction in the bundle, starting from the given index. | ||
* | ||
* ## Related methods | ||
* | ||
* See the [`addEntry()`]{@link #module_bundle.addEntry} method for creating new bundles. | ||
* | ||
* @method addSignatureOrMessage | ||
* | ||
* @param {Int8Array} bundle - Bundle buffer. | ||
* @param {Int8Array} signatureOrMessage - Signature or message to add. | ||
* @param {number} index - Transaction index as entry point for signature or message fragments. | ||
* @summary Adds signature message fragments to transactions in a bundle. | ||
* | ||
* @return {Int8Array} List of transactions in the updated bundle | ||
*/ | ||
export declare const addSignatureOrMessage: (bundle: Int8Array, signatureOrMessage: Int8Array, index: number) => Int8Array; | ||
/** | ||
* Sums up transaction values in a bundle starting at offset. | ||
* @memberof module:bundle | ||
* | ||
* @method valueSum | ||
* @param {Int8Array} bundle - Transaction trits | ||
* @param {Int8Array} signatureOrMessage - Signature or message to add to the bundle | ||
* @param {number} index - Transaction index at which to start adding the signature or message | ||
* | ||
* @param {Int8Array} bundle - Bundle buffer. | ||
* @param {number} offset - Offset from the start of the bundle buffer. | ||
* @param {number} length - Length of transactions in which values should be summed. | ||
* @example | ||
* ```js | ||
* const signature = Converter.trytesToTrits('SIGNATURE...') | ||
* bundle.set(Bundle.addSignatureOrMessage(bundle, signature, 1)); | ||
* ``` | ||
* | ||
* @return {number} Total value of 'length' transactions in the bundle starting at offset. | ||
* @return {Int8Array} Transaction trits that include a bundle hash. | ||
* | ||
* @throws {errors.ILLEGAL_TRANSACTION_BUFFER_LENGTH}: Make sure that the `bundle` argument contains valid transaction trits | ||
* @throws {errors.ILLEGAL_TRANSACTION_INDEX}: Make sure that the `index` argument is a number and that the bundle contains enough transactions | ||
* @throws {errors.ILLEGAL_SIGNATURE_OR_MESSAGE_LENGTH}: Make sure that the `signatureOrMessage` argument contains at least 6,561 trits | ||
* | ||
*/ | ||
export declare const addSignatureOrMessage: (bundle: Int8Array, signatureOrMessage: Int8Array, index: number) => Int8Array; | ||
export declare const valueSum: (buffer: Int8Array, offset: number, length: number) => number; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
237156
2308
140
1