@iota/transaction
Advanced tools
Comparing version 1.0.0-beta.8 to 1.0.0-beta.9
"use strict"; | ||
exports.__esModule = true; | ||
exports.ILLEGAL_LENGTH = 'Illegal trits length'; | ||
exports.ILLEGAL_SUBSEED_INDEX = 'Illegal subseed length'; | ||
exports.ILLEGAL_SUBSEED_LENGTH = 'Illegal subseed length'; | ||
exports.ILLEGAL_KEY_LENGTH = 'Illegal key length'; | ||
exports.ILLEGAL_DIGESTS_LENGTH = 'Illegal digests length'; | ||
exports.ILLEGAL_NORMALIZED_FRAGMENT_LENGTH = 'Illegal normalized fragment length'; | ||
exports.ILLEGAL_SIGNATURE_FRAGMENT_LENGTH = 'Illegal signature fragment length'; | ||
exports.ILLEGAL_BUNDLE_HASH_LENGTH = 'Illegal bundle hash length'; | ||
exports.ILLEGAL_KEY_FRAGMENT_LENGTH = 'Illegal key fragment length'; | ||
exports.ILLEGAL_TRIT_CONVERSION_INPUT = 'Illegal conversion input. Expected trits as Int8Array.'; | ||
@@ -50,2 +58,3 @@ exports.ILLEGAL_TRYTE_CONVERSION_INPUT = 'Illegal conversion input. Expected trytes string or integer.'; | ||
exports.INVALID_DELAY = 'Invalid delay.'; | ||
exports.INVALID_ADDRESS_LAST_TRIT = 'Invalid address: Last trit of address of value transaction must be 0.'; | ||
//# sourceMappingURL=errors.js.map |
"use strict"; | ||
exports.__esModule = true; | ||
exports.HASH_SIZE = 81; | ||
exports.HASH_TRYTES_SIZE = 81; | ||
exports.HASH_TRITS_SIZE = exports.HASH_TRYTES_SIZE * 3; | ||
exports.TRANSACTION_TRYTES_SIZE = 2673; | ||
@@ -5,0 +6,0 @@ exports.SIGNATURE_MESSAGE_FRAGMENT_TRYTES_SIZE = 2187; |
@@ -56,3 +56,5 @@ "use strict"; | ||
Number.isInteger(tx.attachmentTimestampUpperBound) && | ||
guards_1.isTrytesOfExactLength(tx.nonce, constants_1.NONCE_TRYTES_SIZE); | ||
guards_1.isTrytesOfExactLength(tx.nonce, constants_1.NONCE_TRYTES_SIZE) && | ||
// Check that last trit of address with balance is 0. | ||
(tx.value === 0 || converter_1.trytesToTrits(tx.address)[constants_1.HASH_TRITS_SIZE - 1] === 0); | ||
}; | ||
@@ -83,3 +85,3 @@ /** | ||
exports.isTransactionHash = function (hash, minWeightMagnitude) { | ||
var hasCorrectHashLength = guards_1.isTrytesOfExactLength(hash, constants_1.HASH_SIZE); | ||
var hasCorrectHashLength = guards_1.isTrytesOfExactLength(hash, constants_1.HASH_TRYTES_SIZE); | ||
if (minWeightMagnitude) { | ||
@@ -122,3 +124,3 @@ return (hasCorrectHashLength && | ||
return guards_1.isTrytesOfExactLength(trytes, constants_1.TRANSACTION_TRYTES_SIZE) && | ||
!/^[9]+$/.test(trytes.slice(constants_1.TRANSACTION_TRYTES_SIZE - 3 * constants_1.HASH_SIZE)); | ||
!/^[9]+$/.test(trytes.slice(constants_1.TRANSACTION_TRYTES_SIZE - constants_1.HASH_TRITS_SIZE)); | ||
}; | ||
@@ -125,0 +127,0 @@ exports.isAttachedTrytesArray = guards_1.isArray(exports.isAttachedTrytes); |
@@ -14,5 +14,7 @@ "use strict"; | ||
exports.__esModule = true; | ||
var converter_1 = require("@iota/converter"); | ||
var samples_1 = require("@iota/samples"); | ||
var ava_1 = require("ava"); | ||
var src_1 = require("../src"); | ||
var constants_1 = require("../src/constants"); | ||
ava_1["default"]('isTransaction() returns false for transaction with invalid hash.', function (t) { | ||
@@ -30,2 +32,9 @@ t.is(src_1.isTransaction(__assign({}, samples_1.transactionObject, { hash: samples_1.transactionObject.hash.slice(1) })), false, 'isTransaction() should return false for transaction with invalid hash.'); | ||
}); | ||
ava_1["default"]('isTransaction() returns false for value transaction with last trit of address != 0.', function (t) { | ||
var invalidAddressTrits = converter_1.trytesToTrits(samples_1.transactionObject.address); | ||
invalidAddressTrits[constants_1.HASH_TRITS_SIZE - 1] = 1; | ||
var invalidAddressTrytes = converter_1.tritsToTrytes(invalidAddressTrits); | ||
t.is(src_1.isTransaction(__assign({}, samples_1.transactionObject, { value: 1, address: invalidAddressTrytes })), false, 'isTransaction() should return false for value transaction with last trit of address != 0.'); | ||
t.is(src_1.isTransaction(__assign({}, samples_1.transactionObject, { value: -1, address: invalidAddressTrytes })), false, 'isTransaction() should return false for value transaction with last trit of address != 0.'); | ||
}); | ||
ava_1["default"]('isTransaction() returns false for transaction with non-integer value.', function (t) { | ||
@@ -32,0 +41,0 @@ t.is(src_1.isTransaction(__assign({}, samples_1.transactionObject, { value: '0' })), false, 'isTransaction() should return false for transaction with non-integer value.'); |
{ | ||
"name": "@iota/transaction", | ||
"version": "1.0.0-beta.8", | ||
"version": "1.0.0-beta.9", | ||
"description": "Utilities and validators for transactions.", | ||
@@ -68,8 +68,8 @@ "main": "./out/transaction/src/index.js", | ||
"dependencies": { | ||
"@iota/converter": "^1.0.0-beta.8", | ||
"@iota/curl": "^1.0.0-beta.8" | ||
"@iota/converter": "^1.0.0-beta.9", | ||
"@iota/curl": "^1.0.0-beta.9" | ||
}, | ||
"devDependencies": { | ||
"@iota/samples": "^1.0.0-beta.8" | ||
"@iota/samples": "^1.0.0-beta.9" | ||
} | ||
} |
@@ -1,2 +0,3 @@ | ||
export const HASH_SIZE = 81 | ||
export const HASH_TRYTES_SIZE = 81 | ||
export const HASH_TRITS_SIZE = HASH_TRYTES_SIZE * 3 | ||
export const TRANSACTION_TRYTES_SIZE = 2673 | ||
@@ -3,0 +4,0 @@ export const SIGNATURE_MESSAGE_FRAGMENT_TRYTES_SIZE = 2187 |
@@ -12,3 +12,4 @@ /** | ||
import { | ||
HASH_SIZE, | ||
HASH_TRITS_SIZE, | ||
HASH_TRYTES_SIZE, | ||
NONCE_TRYTES_SIZE, | ||
@@ -71,3 +72,5 @@ OBSOLETE_TAG_TRYTES_SIZE, | ||
Number.isInteger(tx.attachmentTimestampUpperBound) && | ||
isTrytesOfExactLength(tx.nonce, NONCE_TRYTES_SIZE) | ||
isTrytesOfExactLength(tx.nonce, NONCE_TRYTES_SIZE) && | ||
// Check that last trit of address with balance is 0. | ||
(tx.value === 0 || trytesToTrits(tx.address)[HASH_TRITS_SIZE - 1] === 0) | ||
@@ -98,3 +101,3 @@ /** | ||
export const isTransactionHash = (hash: any, minWeightMagnitude?: number): hash is Hash => { | ||
const hasCorrectHashLength = isTrytesOfExactLength(hash, HASH_SIZE) | ||
const hasCorrectHashLength = isTrytesOfExactLength(hash, HASH_TRYTES_SIZE) | ||
@@ -145,3 +148,3 @@ if (minWeightMagnitude) { | ||
isTrytesOfExactLength(trytes, TRANSACTION_TRYTES_SIZE) && | ||
!/^[9]+$/.test(trytes.slice(TRANSACTION_TRYTES_SIZE - 3 * HASH_SIZE)) | ||
!/^[9]+$/.test(trytes.slice(TRANSACTION_TRYTES_SIZE - HASH_TRITS_SIZE)) | ||
@@ -148,0 +151,0 @@ export const isAttachedTrytesArray = isArray(isAttachedTrytes) |
@@ -0,4 +1,6 @@ | ||
import { tritsToTrytes, trytesToTrits } from '@iota/converter' | ||
import { transactionObject } from '@iota/samples' | ||
import test from 'ava' | ||
import { isTransaction } from '../src' | ||
import { HASH_TRITS_SIZE } from '../src/constants' | ||
@@ -49,2 +51,20 @@ test('isTransaction() returns false for transaction with invalid hash.', t => { | ||
test('isTransaction() returns false for value transaction with last trit of address != 0.', t => { | ||
const invalidAddressTrits = trytesToTrits(transactionObject.address) | ||
invalidAddressTrits[HASH_TRITS_SIZE - 1] = 1 | ||
const invalidAddressTrytes = tritsToTrytes(invalidAddressTrits) | ||
t.is( | ||
isTransaction({ ...transactionObject, value: 1, address: invalidAddressTrytes }), | ||
false, | ||
'isTransaction() should return false for value transaction with last trit of address != 0.' | ||
) | ||
t.is( | ||
isTransaction({ ...transactionObject, value: -1, address: invalidAddressTrytes }), | ||
false, | ||
'isTransaction() should return false for value transaction with last trit of address != 0.' | ||
) | ||
}) | ||
test('isTransaction() returns false for transaction with non-integer value.', t => { | ||
@@ -51,0 +71,0 @@ t.is( |
export declare const ILLEGAL_LENGTH = "Illegal trits length"; | ||
export declare const ILLEGAL_SUBSEED_INDEX = "Illegal subseed length"; | ||
export declare const ILLEGAL_SUBSEED_LENGTH = "Illegal subseed length"; | ||
export declare const ILLEGAL_KEY_LENGTH = "Illegal key length"; | ||
export declare const ILLEGAL_DIGESTS_LENGTH = "Illegal digests length"; | ||
export declare const ILLEGAL_NORMALIZED_FRAGMENT_LENGTH = "Illegal normalized fragment length"; | ||
export declare const ILLEGAL_SIGNATURE_FRAGMENT_LENGTH = "Illegal signature fragment length"; | ||
export declare const ILLEGAL_BUNDLE_HASH_LENGTH = "Illegal bundle hash length"; | ||
export declare const ILLEGAL_KEY_FRAGMENT_LENGTH = "Illegal key fragment length"; | ||
export declare const ILLEGAL_TRIT_CONVERSION_INPUT = "Illegal conversion input. Expected trits as Int8Array."; | ||
@@ -48,1 +56,2 @@ export declare const ILLEGAL_TRYTE_CONVERSION_INPUT = "Illegal conversion input. Expected trytes string or integer."; | ||
export declare const INVALID_DELAY = "Invalid delay."; | ||
export declare const INVALID_ADDRESS_LAST_TRIT = "Invalid address: Last trit of address of value transaction must be 0."; |
@@ -1,2 +0,3 @@ | ||
export declare const HASH_SIZE = 81; | ||
export declare const HASH_TRYTES_SIZE = 81; | ||
export declare const HASH_TRITS_SIZE: number; | ||
export declare const TRANSACTION_TRYTES_SIZE = 2673; | ||
@@ -3,0 +4,0 @@ export declare const SIGNATURE_MESSAGE_FRAGMENT_TRYTES_SIZE = 2187; |
@@ -124,2 +124,3 @@ import * as Promise from 'bluebird'; | ||
readonly threshold: number; | ||
readonly tips?: ReadonlyArray<Hash>; | ||
} | ||
@@ -126,0 +127,0 @@ export interface GetBalancesResponse { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
1868
112305
60
Updated@iota/curl@^1.0.0-beta.9