@harmony-js/transaction
Advanced tools
Comparing version 0.1.51 to 0.1.54
@@ -8,3 +8,2 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AbstractTransaction = void 0; | ||
var AbstractTransaction = /** @class */ (function () { | ||
@@ -11,0 +10,0 @@ function AbstractTransaction() { |
@@ -9,6 +9,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TransactionFactory = void 0; | ||
var crypto_1 = require("@harmony-js/crypto"); | ||
var transaction_1 = require("./transaction"); | ||
var shardingTransaction_1 = require("./shardingTransaction"); | ||
var types_1 = require("./types"); | ||
var TransactionFactory = /** @class */ (function () { | ||
@@ -52,5 +52,5 @@ function TransactionFactory(messenger) { | ||
if (!sharding) { | ||
return new transaction_1.Transaction(txParams, this.messenger, "INITIALIZED" /* INTIALIZED */); | ||
return new transaction_1.Transaction(txParams, this.messenger, types_1.TxStatus.INTIALIZED); | ||
} | ||
return new shardingTransaction_1.ShardingTransaction(txParams, this.messenger, "INITIALIZED" /* INTIALIZED */); | ||
return new shardingTransaction_1.ShardingTransaction(txParams, this.messenger, types_1.TxStatus.INTIALIZED); | ||
}; | ||
@@ -69,3 +69,3 @@ /** | ||
TransactionFactory.prototype.clone = function (transaction) { | ||
return new transaction_1.Transaction(transaction.txParams, this.messenger, "INITIALIZED" /* INTIALIZED */); | ||
return new transaction_1.Transaction(transaction.txParams, this.messenger, types_1.TxStatus.INTIALIZED); | ||
}; | ||
@@ -83,3 +83,3 @@ /** | ||
TransactionFactory.prototype.recover = function (txHash) { | ||
var newTxn = new transaction_1.Transaction({}, this.messenger, "INITIALIZED" /* INTIALIZED */); | ||
var newTxn = new transaction_1.Transaction({}, this.messenger, types_1.TxStatus.INTIALIZED); | ||
newTxn.recover(txHash); | ||
@@ -86,0 +86,0 @@ return newTxn; |
@@ -1015,3 +1015,3 @@ /** | ||
}, | ||
enumerable: false, | ||
enumerable: true, | ||
configurable: true | ||
@@ -1047,3 +1047,3 @@ }); | ||
}, | ||
enumerable: false, | ||
enumerable: true, | ||
configurable: true | ||
@@ -1050,0 +1050,0 @@ }); |
@@ -1012,3 +1012,3 @@ /** | ||
}, | ||
enumerable: false, | ||
enumerable: true, | ||
configurable: true | ||
@@ -1044,3 +1044,3 @@ }); | ||
}, | ||
enumerable: false, | ||
enumerable: true, | ||
configurable: true | ||
@@ -1047,0 +1047,0 @@ }); |
@@ -8,6 +8,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ShardingTransaction = void 0; | ||
var tslib_1 = require("tslib"); | ||
var utils_1 = require("@harmony-js/utils"); | ||
var transaction_1 = require("./transaction"); | ||
var types_1 = require("./types"); | ||
var utils_2 = require("./utils"); | ||
@@ -18,3 +18,3 @@ var ShardingTransaction = /** @class */ (function (_super) { | ||
if (messenger === void 0) { messenger = utils_2.defaultMessenger; } | ||
if (txStatus === void 0) { txStatus = "INITIALIZED" /* INTIALIZED */; } | ||
if (txStatus === void 0) { txStatus = types_1.TxStatus.INTIALIZED; } | ||
var _this = this; | ||
@@ -21,0 +21,0 @@ var fromAddress = params.from; |
@@ -7,6 +7,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Transaction = void 0; | ||
var tslib_1 = require("tslib"); | ||
var crypto_1 = require("@harmony-js/crypto"); | ||
var utils_1 = require("@harmony-js/utils"); | ||
var network_1 = require("@harmony-js/network"); | ||
var types_1 = require("./types"); | ||
var utils_2 = require("./utils"); | ||
@@ -39,3 +40,3 @@ var transactionBase_1 = require("./transactionBase"); | ||
if (messenger === void 0) { messenger = utils_2.defaultMessenger; } | ||
if (txStatus === void 0) { txStatus = "INITIALIZED" /* INTIALIZED */; } | ||
if (txStatus === void 0) { txStatus = types_1.TxStatus.INTIALIZED; } | ||
var _this = _super.call(this, messenger, txStatus) || this; | ||
@@ -77,3 +78,3 @@ // intialize transaction | ||
_this.receipt = params && params.receipt ? params.receipt : undefined; | ||
_this.cxStatus = _this.isCrossShard() ? "INITIALIZED" /* INTIALIZED */ : "NONE" /* NONE */; | ||
_this.cxStatus = _this.isCrossShard() ? types_1.TxStatus.INTIALIZED : types_1.TxStatus.NONE; | ||
return _this; | ||
@@ -93,3 +94,3 @@ } | ||
// temp setting to be compatible with eth | ||
var fields = this.messenger.chainType === "hmy" /* Harmony */ ? utils_2.transactionFields : utils_2.transactionFieldsETH; | ||
var fields = this.messenger.chainType === utils_1.ChainType.Harmony ? utils_2.transactionFields : utils_2.transactionFieldsETH; | ||
fields.forEach(function (field) { | ||
@@ -120,3 +121,3 @@ var value = _this.txParams[field.name] || []; | ||
// temp setting to be compatible with eth | ||
var rawLength = this.messenger.chainType === "hmy" /* Harmony */ ? 11 : 9; | ||
var rawLength = this.messenger.chainType === utils_1.ChainType.Harmony ? 11 : 9; | ||
var sig = crypto_1.splitSignature(signature); | ||
@@ -147,3 +148,3 @@ var v = 27 + (sig.recoveryParam || 0); | ||
// temp setting to be compatible with eth | ||
var recovered = this.messenger.chainType === "hmy" /* Harmony */ | ||
var recovered = this.messenger.chainType === utils_1.ChainType.Harmony | ||
? utils_2.recover(rawTransaction) | ||
@@ -177,3 +178,3 @@ : utils_2.recoverETH(rawTransaction); | ||
}, | ||
enumerable: false, | ||
enumerable: true, | ||
configurable: true | ||
@@ -209,3 +210,3 @@ }); | ||
}, | ||
enumerable: false, | ||
enumerable: true, | ||
configurable: true | ||
@@ -268,6 +269,6 @@ }); | ||
if (this.rawTransaction !== '0x') { | ||
this.setTxStatus("SIGNED" /* SIGNED */); | ||
this.setTxStatus(types_1.TxStatus.SIGNED); | ||
} | ||
else { | ||
this.setTxStatus("INITIALIZED" /* INTIALIZED */); | ||
this.setTxStatus(types_1.TxStatus.INTIALIZED); | ||
} | ||
@@ -313,3 +314,3 @@ }; | ||
} | ||
return [4 /*yield*/, this.messenger.send("hmy_sendRawTransaction" /* SendRawTransaction */, this.rawTransaction, this.messenger.chainType, typeof this.shardID === 'string' ? Number.parseInt(this.shardID, 10) : this.shardID)]; | ||
return [4 /*yield*/, this.messenger.send(network_1.RPCMethod.SendRawTransaction, this.rawTransaction, this.messenger.chainType, typeof this.shardID === 'string' ? Number.parseInt(this.shardID, 10) : this.shardID)]; | ||
case 1: | ||
@@ -321,3 +322,3 @@ res = _a.sent(); | ||
this.emitTransactionHash(this.id); | ||
this.setTxStatus("PENDING" /* PENDING */); | ||
this.setTxStatus(types_1.TxStatus.PENDING); | ||
// await this.confirm(this.id, 20, 1000); | ||
@@ -328,3 +329,3 @@ return [2 /*return*/, [this, res.result]]; | ||
this.emitConfirm("transaction failed:" + res.error.message); | ||
this.setTxStatus("REJECTED" /* REJECTED */); | ||
this.setTxStatus(types_1.TxStatus.REJECTED); | ||
return [2 /*return*/, [this, "transaction failed:" + res.error.message]]; | ||
@@ -331,0 +332,0 @@ } |
@@ -8,3 +8,2 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TransactionBase = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -14,2 +13,3 @@ var crypto_1 = require("@harmony-js/crypto"); | ||
var network_1 = require("@harmony-js/network"); | ||
var types_1 = require("./types"); | ||
var utils_2 = require("./utils"); | ||
@@ -21,3 +21,3 @@ var TransactionBase = /** @class */ (function () { | ||
this.confirmationCheck = 0; | ||
this.cxStatus = "INITIALIZED" /* INTIALIZED */; | ||
this.cxStatus = types_1.TxStatus.INTIALIZED; | ||
this.cxBlockNumbers = []; | ||
@@ -62,24 +62,24 @@ this.cxConfirmations = 0; | ||
TransactionBase.prototype.isInitialized = function () { | ||
return this.getTxStatus() === "INITIALIZED" /* INTIALIZED */; | ||
return this.getTxStatus() === types_1.TxStatus.INTIALIZED; | ||
}; | ||
TransactionBase.prototype.isSigned = function () { | ||
return this.getTxStatus() === "SIGNED" /* SIGNED */; | ||
return this.getTxStatus() === types_1.TxStatus.SIGNED; | ||
}; | ||
TransactionBase.prototype.isPending = function () { | ||
return this.getTxStatus() === "PENDING" /* PENDING */; | ||
return this.getTxStatus() === types_1.TxStatus.PENDING; | ||
}; | ||
TransactionBase.prototype.isRejected = function () { | ||
return this.getTxStatus() === "REJECTED" /* REJECTED */; | ||
return this.getTxStatus() === types_1.TxStatus.REJECTED; | ||
}; | ||
TransactionBase.prototype.isConfirmed = function () { | ||
return this.getTxStatus() === "CONFIRMED" /* CONFIRMED */; | ||
return this.getTxStatus() === types_1.TxStatus.CONFIRMED; | ||
}; | ||
TransactionBase.prototype.isCxPending = function () { | ||
return this.getCxStatus() === "PENDING" /* PENDING */; | ||
return this.getCxStatus() === types_1.TxStatus.PENDING; | ||
}; | ||
TransactionBase.prototype.isCxRejected = function () { | ||
return this.getCxStatus() === "REJECTED" /* REJECTED */; | ||
return this.getCxStatus() === types_1.TxStatus.REJECTED; | ||
}; | ||
TransactionBase.prototype.isCxConfirmed = function () { | ||
return this.getCxStatus() === "CONFIRMED" /* CONFIRMED */; | ||
return this.getCxStatus() === types_1.TxStatus.CONFIRMED; | ||
}; | ||
@@ -98,3 +98,3 @@ TransactionBase.prototype.observed = function () { | ||
} | ||
return [4 /*yield*/, this.messenger.send("hmy_getTransactionReceipt" /* GetTransactionReceipt */, txHash, this.messenger.chainType, typeof shardID === 'string' ? Number.parseInt(shardID, 10) : shardID)]; | ||
return [4 /*yield*/, this.messenger.send(network_1.RPCMethod.GetTransactionReceipt, txHash, this.messenger.chainType, typeof shardID === 'string' ? Number.parseInt(shardID, 10) : shardID)]; | ||
case 1: | ||
@@ -110,15 +110,15 @@ res = _a.sent(); | ||
this.receipt.byzantium = true; | ||
this.txStatus = "CONFIRMED" /* CONFIRMED */; | ||
this.txStatus = types_1.TxStatus.CONFIRMED; | ||
} | ||
else if (this.receipt.status && this.receipt.status === '0x0') { | ||
this.receipt.byzantium = true; | ||
this.txStatus = "REJECTED" /* REJECTED */; | ||
this.txStatus = types_1.TxStatus.REJECTED; | ||
} | ||
else if (this.receipt.status === undefined && this.receipt.root) { | ||
this.receipt.byzantium = false; | ||
this.txStatus = "CONFIRMED" /* CONFIRMED */; | ||
this.txStatus = types_1.TxStatus.CONFIRMED; | ||
} | ||
return [2 /*return*/, true]; | ||
case 2: | ||
this.txStatus = "PENDING" /* PENDING */; | ||
this.txStatus = types_1.TxStatus.PENDING; | ||
return [4 /*yield*/, this.getBlockNumber(shardID)]; | ||
@@ -132,3 +132,3 @@ case 3: | ||
case 5: | ||
this.txStatus = "PENDING" /* PENDING */; | ||
this.txStatus = types_1.TxStatus.PENDING; | ||
return [4 /*yield*/, this.getBlockNumber(shardID)]; | ||
@@ -154,3 +154,3 @@ case 6: | ||
if (!(this.messenger.provider instanceof network_1.HttpProvider)) return [3 /*break*/, 13]; | ||
this.txStatus = "PENDING" /* PENDING */; | ||
this.txStatus = types_1.TxStatus.PENDING; | ||
return [4 /*yield*/, this.getBlockNumber(shardID)]; | ||
@@ -192,3 +192,3 @@ case 1: | ||
err_1 = _a.sent(); | ||
this.txStatus = "REJECTED" /* REJECTED */; | ||
this.txStatus = types_1.TxStatus.REJECTED; | ||
this.emitConfirm(this.txStatus); | ||
@@ -208,3 +208,3 @@ throw err_1; | ||
case 12: | ||
this.txStatus = "REJECTED" /* REJECTED */; | ||
this.txStatus = types_1.TxStatus.REJECTED; | ||
this.emitConfirm(this.txStatus); | ||
@@ -226,3 +226,3 @@ throw new Error("The transaction is still not confirmed after " + maxAttempts + " attempts."); | ||
error_1 = _a.sent(); | ||
this.txStatus = "REJECTED" /* REJECTED */; | ||
this.txStatus = types_1.TxStatus.REJECTED; | ||
this.emitConfirm(this.txStatus); | ||
@@ -267,3 +267,3 @@ throw new Error("The transaction is still not confirmed after " + maxAttempts * interval + " mil seconds."); | ||
if (!(this.confirmationCheck === maxAttempts)) return [3 /*break*/, 5]; | ||
this.txStatus = "REJECTED" /* REJECTED */; | ||
this.txStatus = types_1.TxStatus.REJECTED; | ||
this.emitConfirm(this.txStatus); | ||
@@ -282,3 +282,3 @@ return [4 /*yield*/, p.unsubscribe()]; | ||
case 0: | ||
this.txStatus = "REJECTED" /* REJECTED */; | ||
this.txStatus = types_1.TxStatus.REJECTED; | ||
this.emitConfirm(this.txStatus); | ||
@@ -328,3 +328,3 @@ this.emitError(error); | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.messenger.send("hmy_blockNumber" /* BlockNumber */, [], this.messenger.chainPrefix, typeof shardID === 'string' ? Number.parseInt(shardID, 10) : shardID)]; | ||
return [4 /*yield*/, this.messenger.send(network_1.RPCMethod.BlockNumber, [], this.messenger.chainPrefix, typeof shardID === 'string' ? Number.parseInt(shardID, 10) : shardID)]; | ||
case 1: | ||
@@ -351,3 +351,3 @@ currentBlock = _a.sent(); | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.messenger.send("hmy_getBlockByNumber" /* GetBlockByNumber */, [blockNumber, true], this.messenger.chainPrefix, typeof this.shardID === 'string' ? Number.parseInt(this.shardID, 10) : this.shardID)]; | ||
return [4 /*yield*/, this.messenger.send(network_1.RPCMethod.GetBlockByNumber, [blockNumber, true], this.messenger.chainPrefix, typeof this.shardID === 'string' ? Number.parseInt(this.shardID, 10) : this.shardID)]; | ||
case 1: | ||
@@ -412,3 +412,3 @@ block = _a.sent(); | ||
err_2 = _a.sent(); | ||
this.cxStatus = "REJECTED" /* REJECTED */; | ||
this.cxStatus = types_1.TxStatus.REJECTED; | ||
this.emitCxConfirm(this.cxStatus); | ||
@@ -426,3 +426,3 @@ throw err_2; | ||
case 12: | ||
this.cxStatus = "REJECTED" /* REJECTED */; | ||
this.cxStatus = types_1.TxStatus.REJECTED; | ||
this.emitCxConfirm(this.cxStatus); | ||
@@ -444,3 +444,3 @@ throw new Error("The transaction is still not confirmed after " + maxAttempts + " attempts."); | ||
error_4 = _a.sent(); | ||
this.cxStatus = "REJECTED" /* REJECTED */; | ||
this.cxStatus = types_1.TxStatus.REJECTED; | ||
this.emitCxConfirm(this.cxStatus); | ||
@@ -462,3 +462,3 @@ throw new Error("The transaction is still not confirmed after " + maxAttempts * interval + " mil seconds."); | ||
} | ||
return [4 /*yield*/, this.messenger.send("hmy_getCXReceiptByHash" /* GetCXReceiptByHash */, txHash, this.messenger.chainPrefix, typeof toShardID === 'string' ? Number.parseInt(toShardID, 10) : toShardID)]; | ||
return [4 /*yield*/, this.messenger.send(network_1.RPCMethod.GetCXReceiptByHash, txHash, this.messenger.chainPrefix, typeof toShardID === 'string' ? Number.parseInt(toShardID, 10) : toShardID)]; | ||
case 1: | ||
@@ -468,3 +468,3 @@ res = _a.sent(); | ||
this.emitCxReceipt(res.result); | ||
this.cxStatus = "CONFIRMED" /* CONFIRMED */; | ||
this.cxStatus = types_1.TxStatus.CONFIRMED; | ||
return [2 /*return*/, true]; | ||
@@ -476,3 +476,3 @@ case 2: return [4 /*yield*/, this.getBlockNumber(toShardID)]; | ||
this.cxConfirmationCheck += 1; | ||
this.cxStatus = "PENDING" /* PENDING */; | ||
this.cxStatus = types_1.TxStatus.PENDING; | ||
return [2 /*return*/, false]; | ||
@@ -515,3 +515,3 @@ } | ||
if (!(this.cxConfirmationCheck === maxAttempts)) return [3 /*break*/, 5]; | ||
this.cxStatus = "REJECTED" /* REJECTED */; | ||
this.cxStatus = types_1.TxStatus.REJECTED; | ||
this.emitCxConfirm(this.cxStatus); | ||
@@ -530,3 +530,3 @@ return [4 /*yield*/, p.unsubscribe()]; | ||
case 0: | ||
this.cxStatus = "REJECTED" /* REJECTED */; | ||
this.cxStatus = types_1.TxStatus.REJECTED; | ||
this.emitCxConfirm(this.cxStatus); | ||
@@ -533,0 +533,0 @@ this.emitError(error); |
@@ -105,3 +105,3 @@ /** | ||
} | ||
export declare const enum TxStatus { | ||
export declare enum TxStatus { | ||
NONE = "NONE", | ||
@@ -108,0 +108,0 @@ INTIALIZED = "INITIALIZED", |
@@ -88,3 +88,2 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TxStatus = void 0; | ||
var TxStatus; | ||
@@ -91,0 +90,0 @@ (function (TxStatus) { |
@@ -8,3 +8,2 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RLPSign = exports.defaultMessenger = exports.TransactionEvents = exports.sleep = exports.recoverETH = exports.recover = exports.handleAddress = exports.handleNumber = exports.transactionFieldsETH = exports.transactionFields = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -229,3 +228,3 @@ var utils_1 = require("@harmony-js/utils"); | ||
})(TransactionEvents = exports.TransactionEvents || (exports.TransactionEvents = {})); | ||
exports.defaultMessenger = new network_1.Messenger(new network_1.HttpProvider('http://localhost:9500'), "hmy" /* Harmony */); | ||
exports.defaultMessenger = new network_1.Messenger(new network_1.HttpProvider('http://localhost:9500'), utils_1.ChainType.Harmony); | ||
exports.RLPSign = function (transaction, prv) { | ||
@@ -232,0 +231,0 @@ var _a = tslib_1.__read(transaction.getRLPUnsigned(), 2), unsignedRawTransaction = _a[0], raw = _a[1]; |
{ | ||
"name": "@harmony-js/transaction", | ||
"version": "0.1.51", | ||
"version": "0.1.54", | ||
"description": "transaction package for harmony", | ||
@@ -21,7 +21,7 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@harmony-js/crypto": "0.1.48", | ||
"@harmony-js/network": "0.1.51", | ||
"@harmony-js/utils": "0.1.48" | ||
"@harmony-js/crypto": "0.1.54", | ||
"@harmony-js/network": "0.1.54", | ||
"@harmony-js/utils": "0.1.54" | ||
}, | ||
"gitHead": "3f6005764d7407b4ecd9905d4f835668e649fa0a" | ||
"gitHead": "4033b3f9712f01cfad8b97db4be5aa679c430321" | ||
} |
@@ -107,3 +107,3 @@ /** | ||
export const enum TxStatus { | ||
export enum TxStatus { | ||
NONE = 'NONE', | ||
@@ -110,0 +110,0 @@ INTIALIZED = 'INITIALIZED', |
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 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
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
849422
10280
+ Added@harmony-js/crypto@0.1.54(transitive)
+ Added@harmony-js/network@0.1.54(transitive)
+ Added@harmony-js/utils@0.1.54(transitive)
- Removed@harmony-js/crypto@0.1.48(transitive)
- Removed@harmony-js/network@0.1.51(transitive)
- Removed@harmony-js/utils@0.1.48(transitive)
Updated@harmony-js/crypto@0.1.54
Updated@harmony-js/network@0.1.54
Updated@harmony-js/utils@0.1.54