@zilliqa-js/account
Advanced tools
Comparing version 1.0.0-alpha.1 to 1.0.0
@@ -46,2 +46,7 @@ /// <reference types="node" /> | ||
private signature?; | ||
/** | ||
* to get hash or transaction id of this transaction | ||
* this can be identical returned by zilliqa network while calling CreateTransaction | ||
*/ | ||
readonly hash: string; | ||
readonly bytes: Buffer; | ||
@@ -48,0 +53,0 @@ readonly senderAddress: string; |
@@ -25,2 +25,3 @@ "use strict"; | ||
var util_2 = require("./util"); | ||
var hash_js_1 = tslib_1.__importDefault(require("hash.js")); | ||
/** | ||
@@ -82,2 +83,17 @@ * Transaction | ||
}; | ||
Object.defineProperty(Transaction.prototype, "hash", { | ||
/** | ||
* to get hash or transaction id of this transaction | ||
* this can be identical returned by zilliqa network while calling CreateTransaction | ||
*/ | ||
get: function () { | ||
var payload = this.bytes.toString('hex'); | ||
return hash_js_1.default | ||
.sha256() | ||
.update(payload, 'hex') | ||
.digest('hex'); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Transaction.prototype, "bytes", { | ||
@@ -84,0 +100,0 @@ get: function () { |
{ | ||
"name": "@zilliqa-js/account", | ||
"version": "1.0.0-alpha.1", | ||
"version": "1.0.0", | ||
"author": "Ian Tan (https://github.com/iantanwx)", | ||
@@ -30,4 +30,4 @@ "maintainers": [ | ||
"@types/hdkey": "^0.7.0", | ||
"@zilliqa-js/core": "1.0.0-alpha.1", | ||
"@zilliqa-js/crypto": "1.0.0-alpha.1", | ||
"@zilliqa-js/core": "1.0.0", | ||
"@zilliqa-js/crypto": "1.0.0", | ||
"@zilliqa-js/proto": "0.11.1", | ||
@@ -44,3 +44,3 @@ "@zilliqa-js/util": "0.11.1", | ||
}, | ||
"gitHead": "9e4a995fe7705d9b5b0d8c5d59fc7b7b1963ed3c" | ||
"gitHead": "64f0e8b610acebe6b5062789210aa57e4ebcd9df" | ||
} |
@@ -43,2 +43,4 @@ // Copyright (C) 2018 Zilliqa | ||
import hashjs from 'hash.js'; | ||
/** | ||
@@ -95,2 +97,14 @@ * Transaction | ||
/** | ||
* to get hash or transaction id of this transaction | ||
* this can be identical returned by zilliqa network while calling CreateTransaction | ||
*/ | ||
get hash(): string { | ||
const payload = this.bytes.toString('hex'); | ||
return hashjs | ||
.sha256() | ||
.update(payload, 'hex') | ||
.digest('hex'); | ||
} | ||
get bytes(): Buffer { | ||
@@ -236,3 +250,2 @@ return encodeTransactionProto(this.txParams); | ||
} | ||
/** | ||
@@ -239,0 +252,0 @@ * blockConfirm |
@@ -388,2 +388,25 @@ // Copyright (C) 2018 Zilliqa | ||
}); | ||
it('should get hash without sending to network', async () => { | ||
const tx = new Transaction( | ||
{ | ||
version: 21823489, | ||
nonce: 41, | ||
toAddr: 'zil124sjf3g7jnxua7wnx4egu0vcnm4nzlef5zcdu3', | ||
amount: new BN(100000000), | ||
pubKey: | ||
'026c7f3b8ac6f615c00c34186cbe4253a2c5acdc524b1cfae544c629d8e3564cfc', | ||
gasPrice: new BN(1000000000), | ||
gasLimit: Long.fromNumber(1), | ||
signature: | ||
'8bb3404b033b780421ae5d31b9e130161e58e750ca052ab07d9f71924d0353d525353ef6217b4c56303c7434245110c0e0faa578c6d993c2b91b5c8574b79cf7', | ||
}, | ||
provider, | ||
); | ||
expect(tx.hash).toEqual( | ||
'f0f1cefeed3e6124e80eadc668908a89fb45d130c90619004589b1c726fb178f', | ||
); | ||
}); | ||
it('should use block confirm to reject a txn', async () => { | ||
@@ -390,0 +413,0 @@ const responses = [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1397735
13766
1
+ Added@zilliqa-js/core@1.0.0(transitive)
+ Added@zilliqa-js/crypto@1.0.0(transitive)
+ Addednode-gyp-build@4.8.4(transitive)
+ Addedsodium-native@3.4.1(transitive)
- Removed@zilliqa-js/core@1.0.0-alpha.1(transitive)
- Removed@zilliqa-js/crypto@1.0.0-alpha.1(transitive)
- Removednode-addon-api@8.2.2(transitive)
- Removedsodium@3.0.2(transitive)
Updated@zilliqa-js/core@1.0.0
Updated@zilliqa-js/crypto@1.0.0