@harmony-js/transaction
Advanced tools
Comparing version 0.1.43 to 0.1.45
@@ -0,1 +1,6 @@ | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
import { Messenger } from '@harmony-js/network'; | ||
@@ -2,0 +7,0 @@ import { TxStatus } from './types'; |
"use strict"; | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AbstractTransaction = void 0; | ||
var AbstractTransaction = /** @class */ (function () { | ||
@@ -4,0 +10,0 @@ function AbstractTransaction() { |
@@ -0,1 +1,7 @@ | ||
/** | ||
* ## hhahaha | ||
* | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
*/ | ||
import { Messenger } from '@harmony-js/network'; | ||
@@ -9,6 +15,51 @@ import { Transaction } from './transaction'; | ||
setMessenger(messenger: Messenger): void; | ||
/** | ||
* Create a new Transaction | ||
* @params | ||
* ``` | ||
* // to: Address of the receiver | ||
* // value: value transferred in wei | ||
* // gasLimit: the maximum gas would pay, can use string | ||
* // shardID: send token from shardID | ||
* // toShardId: send token to shardID | ||
* // gasPrice: you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN | ||
* ``` | ||
* | ||
* @example | ||
* ```javascript | ||
* const txn = hmy.transactions.newTx({ | ||
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', | ||
* value: '10000', | ||
* gasLimit: '210000', | ||
* shardID: 0, | ||
* toShardID: 0, | ||
* gasPrice: new hmy.utils.Unit('100').asGwei().toWei(), | ||
* }); | ||
* ``` | ||
*/ | ||
newTx(txParams?: TxParams | any, sharding?: boolean): Transaction; | ||
/** | ||
* clone the transaction | ||
* | ||
* @param transaction | ||
* | ||
* @example | ||
* ```javascript | ||
* const cloneTxn = hmy.transactions.clone(txn); | ||
* console.log(cloneTxn) | ||
* ``` | ||
*/ | ||
clone(transaction: Transaction): Transaction; | ||
/** | ||
* | ||
* @example | ||
* ```javascript | ||
* txHash = '0xf8698085174876e8008252088080949d72989b68777a1f3ffd6f1db079f1928373ee52830186a08027a0ab8229ff5d5240948098f26372eaed9ab2e9be23e8594b08e358ca56a47f8ae9a0084e5c4d1fec496af444423d8a714f65c079260ff01a1be1de7005dd424adf44' | ||
* | ||
* const recoverTx = hmy.transactions.recover(txHash); | ||
* console.log(recoverTx); | ||
* ``` | ||
*/ | ||
recover(txHash: string): Transaction; | ||
} | ||
//# sourceMappingURL=factory.d.ts.map |
"use strict"; | ||
/** | ||
* ## hhahaha | ||
* | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TransactionFactory = void 0; | ||
var crypto_1 = require("@harmony-js/crypto"); | ||
@@ -17,2 +24,26 @@ var transaction_1 = require("./transaction"); | ||
}; | ||
/** | ||
* Create a new Transaction | ||
* @params | ||
* ``` | ||
* // to: Address of the receiver | ||
* // value: value transferred in wei | ||
* // gasLimit: the maximum gas would pay, can use string | ||
* // shardID: send token from shardID | ||
* // toShardId: send token to shardID | ||
* // gasPrice: you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN | ||
* ``` | ||
* | ||
* @example | ||
* ```javascript | ||
* const txn = hmy.transactions.newTx({ | ||
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', | ||
* value: '10000', | ||
* gasLimit: '210000', | ||
* shardID: 0, | ||
* toShardID: 0, | ||
* gasPrice: new hmy.utils.Unit('100').asGwei().toWei(), | ||
* }); | ||
* ``` | ||
*/ | ||
TransactionFactory.prototype.newTx = function (txParams, sharding) { | ||
@@ -25,5 +56,26 @@ if (sharding === void 0) { sharding = false; } | ||
}; | ||
/** | ||
* clone the transaction | ||
* | ||
* @param transaction | ||
* | ||
* @example | ||
* ```javascript | ||
* const cloneTxn = hmy.transactions.clone(txn); | ||
* console.log(cloneTxn) | ||
* ``` | ||
*/ | ||
TransactionFactory.prototype.clone = function (transaction) { | ||
return new transaction_1.Transaction(transaction.txParams, this.messenger, "INITIALIZED" /* INTIALIZED */); | ||
}; | ||
/** | ||
* | ||
* @example | ||
* ```javascript | ||
* txHash = '0xf8698085174876e8008252088080949d72989b68777a1f3ffd6f1db079f1928373ee52830186a08027a0ab8229ff5d5240948098f26372eaed9ab2e9be23e8594b08e358ca56a47f8ae9a0084e5c4d1fec496af444423d8a714f65c079260ff01a1be1de7005dd424adf44' | ||
* | ||
* const recoverTx = hmy.transactions.recover(txHash); | ||
* console.log(recoverTx); | ||
* ``` | ||
*/ | ||
TransactionFactory.prototype.recover = function (txHash) { | ||
@@ -30,0 +82,0 @@ var newTxn = new transaction_1.Transaction({}, this.messenger, "INITIALIZED" /* INTIALIZED */); |
@@ -14,14 +14,14 @@ /** | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Copyright (c) Microsoft Corporation. | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
@@ -109,2 +109,7 @@ /* global Reflect, Promise */ | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
var transactionFields = [ | ||
@@ -334,2 +339,7 @@ { name: 'nonce', length: 32, fix: false }, | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
var TransactionBase = /** @class */ (function () { | ||
@@ -846,5 +856,29 @@ function TransactionBase(messenger, txStatus) { | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
*/ | ||
var Transaction = /** @class */ (function (_super) { | ||
__extends(Transaction, _super); | ||
// constructor | ||
/** | ||
* | ||
* @Params | ||
* ```javascript | ||
* id: string; | ||
from: string; | ||
to: string; | ||
nonce: number | string; | ||
gasLimit: number | string | BN; | ||
gasPrice: number | string | BN; | ||
shardID: number | string; | ||
toShardID: number | string; | ||
data: string; | ||
value: number | string | BN; | ||
chainId: number; | ||
rawTransaction: string; | ||
unsignedRawTransaction: string; | ||
signature: Signature; | ||
receipt?: TransasctionReceipt; | ||
* ``` | ||
*/ | ||
function Transaction(params, messenger, txStatus) { | ||
@@ -892,2 +926,10 @@ if (messenger === void 0) { messenger = defaultMessenger; } | ||
} | ||
/** | ||
* | ||
* @example | ||
* ```javascript | ||
* const unsigned = txn.getRLPUnsigned(txn); | ||
* console.log(unsigned); | ||
* ``` | ||
*/ | ||
Transaction.prototype.getRLPUnsigned = function () { | ||
@@ -937,5 +979,12 @@ var _this = this; | ||
}; | ||
/** | ||
* @example | ||
* ```javascript | ||
* console.log(txn.getRawTransaction()); | ||
* ``` | ||
*/ | ||
Transaction.prototype.getRawTransaction = function () { | ||
return this.rawTransaction; | ||
}; | ||
/** @hidden */ | ||
Transaction.prototype.recover = function (rawTransaction) { | ||
@@ -950,3 +999,11 @@ // temp setting to be compatible with eth | ||
Object.defineProperty(Transaction.prototype, "txPayload", { | ||
// use when using eth_sendTransaction | ||
/** | ||
* get the payload of transaction | ||
* | ||
* @example | ||
* ``` | ||
* const payload = txn.txPayload; | ||
* console.log(payload); | ||
* ``` | ||
*/ | ||
get: function () { | ||
@@ -965,6 +1022,15 @@ return { | ||
}, | ||
enumerable: true, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Transaction.prototype, "txParams", { | ||
/** | ||
* get transaction params | ||
* | ||
* @example | ||
* ``` | ||
* const txParams = txn.txParams; | ||
* console.log(txParams) | ||
* ``` | ||
*/ | ||
get: function () { | ||
@@ -988,5 +1054,26 @@ return { | ||
}, | ||
enumerable: true, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
/** | ||
* set the params to the txn | ||
* | ||
* @example | ||
* ``` | ||
* txn.setParams({ | ||
* to: 'one1ew56rqrucu6p6n598fmjmnfh8dd4xpg6atne9c', | ||
* value: '1200', | ||
* gasLimit: '230000', | ||
* shardID: 1, | ||
* toShardID: 0, | ||
* gasPrice: new hmy.utils.Unit('101').asGwei().toWei(), | ||
* signature: { | ||
* r: '0xd693b532a80fed6392b428604171fb32fdbf953728a3a7ecc7d4062b1652c042', | ||
* s: '0x24e9c602ac800b983b035700a14b23f78a253ab762deab5dc27e3555a750b354', | ||
* v: 0 | ||
* }, | ||
* }); | ||
* console.log(txn); | ||
* ``` | ||
*/ | ||
Transaction.prototype.setParams = function (params) { | ||
@@ -1032,2 +1119,3 @@ this.id = params && params.id ? params.id : '0x'; | ||
}; | ||
/** @hidden */ | ||
Transaction.prototype.map = function (fn) { | ||
@@ -1038,5 +1126,22 @@ var newParams = fn(this.txParams); | ||
}; | ||
/** | ||
* Check whether the transaction is cross shard | ||
* | ||
* @example | ||
* ```javascript | ||
* console.log(txn.isCrossShard()); | ||
* ``` | ||
*/ | ||
Transaction.prototype.isCrossShard = function () { | ||
return new crypto.BN(this.txParams.shardID).toString() !== new crypto.BN(this.txParams.toShardID).toString(); | ||
}; | ||
/** | ||
* | ||
* @example | ||
* ``` | ||
* txn.sendTransaction().then((value) => { | ||
* console.log(value); | ||
* }); | ||
* ``` | ||
*/ | ||
Transaction.prototype.sendTransaction = function () { | ||
@@ -1107,2 +1212,7 @@ return __awaiter(this, void 0, void 0, function () { | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
var ShardingTransaction = /** @class */ (function (_super) { | ||
@@ -1140,2 +1250,8 @@ __extends(ShardingTransaction, _super); | ||
/** | ||
* ## hhahaha | ||
* | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
*/ | ||
var TransactionFactory = /** @class */ (function () { | ||
@@ -1152,2 +1268,26 @@ function TransactionFactory(messenger) { | ||
}; | ||
/** | ||
* Create a new Transaction | ||
* @params | ||
* ``` | ||
* // to: Address of the receiver | ||
* // value: value transferred in wei | ||
* // gasLimit: the maximum gas would pay, can use string | ||
* // shardID: send token from shardID | ||
* // toShardId: send token to shardID | ||
* // gasPrice: you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN | ||
* ``` | ||
* | ||
* @example | ||
* ```javascript | ||
* const txn = hmy.transactions.newTx({ | ||
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', | ||
* value: '10000', | ||
* gasLimit: '210000', | ||
* shardID: 0, | ||
* toShardID: 0, | ||
* gasPrice: new hmy.utils.Unit('100').asGwei().toWei(), | ||
* }); | ||
* ``` | ||
*/ | ||
TransactionFactory.prototype.newTx = function (txParams, sharding) { | ||
@@ -1160,5 +1300,26 @@ if (sharding === void 0) { sharding = false; } | ||
}; | ||
/** | ||
* clone the transaction | ||
* | ||
* @param transaction | ||
* | ||
* @example | ||
* ```javascript | ||
* const cloneTxn = hmy.transactions.clone(txn); | ||
* console.log(cloneTxn) | ||
* ``` | ||
*/ | ||
TransactionFactory.prototype.clone = function (transaction) { | ||
return new Transaction(transaction.txParams, this.messenger, "INITIALIZED" /* INTIALIZED */); | ||
}; | ||
/** | ||
* | ||
* @example | ||
* ```javascript | ||
* txHash = '0xf8698085174876e8008252088080949d72989b68777a1f3ffd6f1db079f1928373ee52830186a08027a0ab8229ff5d5240948098f26372eaed9ab2e9be23e8594b08e358ca56a47f8ae9a0084e5c4d1fec496af444423d8a714f65c079260ff01a1be1de7005dd424adf44' | ||
* | ||
* const recoverTx = hmy.transactions.recover(txHash); | ||
* console.log(recoverTx); | ||
* ``` | ||
*/ | ||
TransactionFactory.prototype.recover = function (txHash) { | ||
@@ -1172,2 +1333,87 @@ var newTxn = new Transaction({}, this.messenger, "INITIALIZED" /* INTIALIZED */); | ||
/** | ||
* ## About this package | ||
* | ||
* `@harmony-js/transaction` provides the functions to build transactions | ||
* | ||
* Develop can use this package to: | ||
* - build a transaction offline! | ||
* - set params of transaction | ||
* - | ||
* | ||
* ## How to use this package | ||
* ### Step 1: create a Harmony Instance | ||
* ```javascript | ||
* const { Harmony } = require('@harmony-js/core'); | ||
* const { ChainID, ChainType } = require('@harmony-js/utils'); | ||
* const { BN } = require('@harmony-js/crypto'); | ||
* | ||
* const hmy = new Harmony( | ||
* 'http://localhost:9500', | ||
* { | ||
* chainType: ChainType.Harmony, | ||
* chainId: ChainID.HmyLocal, | ||
* }, | ||
* ); | ||
* ``` | ||
* | ||
* ### Step 2: build a transaction | ||
* ```javascript | ||
* const txn = hmy.transactions.newTx({ | ||
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', | ||
* value: '10000', | ||
* gasLimit: '210000', | ||
* shardID: 0, | ||
* toShardID: 0, | ||
* gasPrice: new hmy.utils.Unit('100').asGwei().toWei(), | ||
* }); | ||
* ``` | ||
* | ||
* ## some important information | ||
* Transaction Parameters | ||
* ```java | ||
* // interface TxParams | ||
* id: string; | ||
* from: string; | ||
* to: string; | ||
* nonce: number | string; | ||
* gasLimit: number | string | BN; | ||
* gasPrice: number | string | BN; | ||
* shardID: number | string; | ||
* toShardID: number | string; | ||
* data: string; | ||
* value: number | string | BN; | ||
* chainId: number; | ||
* rawTransaction: string; | ||
* unsignedRawTransaction: string; | ||
* signature: Signature; | ||
* receipt?: TransasctionReceipt; | ||
* ``` | ||
* | ||
* Transaction Receipt | ||
* ```java | ||
* // interface TransasctionReceipt | ||
* transactionHash: string; | ||
* transactionIndex: string; | ||
* blockHash: string; | ||
* blockNumber: string; // 11 | ||
* from: string; | ||
* to: string; | ||
* gasUsed: string; | ||
* cumulativeGasUsed: string; // 13244 | ||
* contractAddress?: string | null; // or null, if none was created | ||
* logs: any[]; | ||
* logsBloom: string; // 256 byte bloom filter | ||
* v: string; | ||
* r: string; | ||
* s: string; | ||
* responseType?: string; | ||
* byzantium?: boolean; | ||
* status?: string; // post Byzantium will return `0x0` or `0x1` | ||
* root?: string; // pre Byzantium will return `root` | ||
* ``` | ||
* | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
*/ | ||
(function (TxStatus) { | ||
@@ -1182,2 +1428,7 @@ TxStatus["NONE"] = "NONE"; | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
var AbstractTransaction = /** @class */ (function () { | ||
@@ -1189,2 +1440,8 @@ function AbstractTransaction() { | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
exports.TransactionFactory = TransactionFactory; | ||
@@ -1191,0 +1448,0 @@ exports.Transaction = Transaction; |
@@ -0,1 +1,6 @@ | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
export * from './factory'; | ||
@@ -2,0 +7,0 @@ export * from './transaction'; |
@@ -10,14 +10,14 @@ /** | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Copyright (c) Microsoft Corporation. | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
@@ -105,2 +105,7 @@ /* global Reflect, Promise */ | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
var transactionFields = [ | ||
@@ -331,2 +336,7 @@ { name: 'nonce', length: 32, fix: false }, | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
var TransactionBase = /** @class */ (function () { | ||
@@ -843,5 +853,29 @@ function TransactionBase(messenger, txStatus) { | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
*/ | ||
var Transaction = /** @class */ (function (_super) { | ||
__extends(Transaction, _super); | ||
// constructor | ||
/** | ||
* | ||
* @Params | ||
* ```javascript | ||
* id: string; | ||
from: string; | ||
to: string; | ||
nonce: number | string; | ||
gasLimit: number | string | BN; | ||
gasPrice: number | string | BN; | ||
shardID: number | string; | ||
toShardID: number | string; | ||
data: string; | ||
value: number | string | BN; | ||
chainId: number; | ||
rawTransaction: string; | ||
unsignedRawTransaction: string; | ||
signature: Signature; | ||
receipt?: TransasctionReceipt; | ||
* ``` | ||
*/ | ||
function Transaction(params, messenger, txStatus) { | ||
@@ -889,2 +923,10 @@ if (messenger === void 0) { messenger = defaultMessenger; } | ||
} | ||
/** | ||
* | ||
* @example | ||
* ```javascript | ||
* const unsigned = txn.getRLPUnsigned(txn); | ||
* console.log(unsigned); | ||
* ``` | ||
*/ | ||
Transaction.prototype.getRLPUnsigned = function () { | ||
@@ -934,5 +976,12 @@ var _this = this; | ||
}; | ||
/** | ||
* @example | ||
* ```javascript | ||
* console.log(txn.getRawTransaction()); | ||
* ``` | ||
*/ | ||
Transaction.prototype.getRawTransaction = function () { | ||
return this.rawTransaction; | ||
}; | ||
/** @hidden */ | ||
Transaction.prototype.recover = function (rawTransaction) { | ||
@@ -947,3 +996,11 @@ // temp setting to be compatible with eth | ||
Object.defineProperty(Transaction.prototype, "txPayload", { | ||
// use when using eth_sendTransaction | ||
/** | ||
* get the payload of transaction | ||
* | ||
* @example | ||
* ``` | ||
* const payload = txn.txPayload; | ||
* console.log(payload); | ||
* ``` | ||
*/ | ||
get: function () { | ||
@@ -962,6 +1019,15 @@ return { | ||
}, | ||
enumerable: true, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Transaction.prototype, "txParams", { | ||
/** | ||
* get transaction params | ||
* | ||
* @example | ||
* ``` | ||
* const txParams = txn.txParams; | ||
* console.log(txParams) | ||
* ``` | ||
*/ | ||
get: function () { | ||
@@ -985,5 +1051,26 @@ return { | ||
}, | ||
enumerable: true, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
/** | ||
* set the params to the txn | ||
* | ||
* @example | ||
* ``` | ||
* txn.setParams({ | ||
* to: 'one1ew56rqrucu6p6n598fmjmnfh8dd4xpg6atne9c', | ||
* value: '1200', | ||
* gasLimit: '230000', | ||
* shardID: 1, | ||
* toShardID: 0, | ||
* gasPrice: new hmy.utils.Unit('101').asGwei().toWei(), | ||
* signature: { | ||
* r: '0xd693b532a80fed6392b428604171fb32fdbf953728a3a7ecc7d4062b1652c042', | ||
* s: '0x24e9c602ac800b983b035700a14b23f78a253ab762deab5dc27e3555a750b354', | ||
* v: 0 | ||
* }, | ||
* }); | ||
* console.log(txn); | ||
* ``` | ||
*/ | ||
Transaction.prototype.setParams = function (params) { | ||
@@ -1029,2 +1116,3 @@ this.id = params && params.id ? params.id : '0x'; | ||
}; | ||
/** @hidden */ | ||
Transaction.prototype.map = function (fn) { | ||
@@ -1035,5 +1123,22 @@ var newParams = fn(this.txParams); | ||
}; | ||
/** | ||
* Check whether the transaction is cross shard | ||
* | ||
* @example | ||
* ```javascript | ||
* console.log(txn.isCrossShard()); | ||
* ``` | ||
*/ | ||
Transaction.prototype.isCrossShard = function () { | ||
return new BN(this.txParams.shardID).toString() !== new BN(this.txParams.toShardID).toString(); | ||
}; | ||
/** | ||
* | ||
* @example | ||
* ``` | ||
* txn.sendTransaction().then((value) => { | ||
* console.log(value); | ||
* }); | ||
* ``` | ||
*/ | ||
Transaction.prototype.sendTransaction = function () { | ||
@@ -1104,2 +1209,7 @@ return __awaiter(this, void 0, void 0, function () { | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
var ShardingTransaction = /** @class */ (function (_super) { | ||
@@ -1137,2 +1247,8 @@ __extends(ShardingTransaction, _super); | ||
/** | ||
* ## hhahaha | ||
* | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
*/ | ||
var TransactionFactory = /** @class */ (function () { | ||
@@ -1149,2 +1265,26 @@ function TransactionFactory(messenger) { | ||
}; | ||
/** | ||
* Create a new Transaction | ||
* @params | ||
* ``` | ||
* // to: Address of the receiver | ||
* // value: value transferred in wei | ||
* // gasLimit: the maximum gas would pay, can use string | ||
* // shardID: send token from shardID | ||
* // toShardId: send token to shardID | ||
* // gasPrice: you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN | ||
* ``` | ||
* | ||
* @example | ||
* ```javascript | ||
* const txn = hmy.transactions.newTx({ | ||
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', | ||
* value: '10000', | ||
* gasLimit: '210000', | ||
* shardID: 0, | ||
* toShardID: 0, | ||
* gasPrice: new hmy.utils.Unit('100').asGwei().toWei(), | ||
* }); | ||
* ``` | ||
*/ | ||
TransactionFactory.prototype.newTx = function (txParams, sharding) { | ||
@@ -1157,5 +1297,26 @@ if (sharding === void 0) { sharding = false; } | ||
}; | ||
/** | ||
* clone the transaction | ||
* | ||
* @param transaction | ||
* | ||
* @example | ||
* ```javascript | ||
* const cloneTxn = hmy.transactions.clone(txn); | ||
* console.log(cloneTxn) | ||
* ``` | ||
*/ | ||
TransactionFactory.prototype.clone = function (transaction) { | ||
return new Transaction(transaction.txParams, this.messenger, "INITIALIZED" /* INTIALIZED */); | ||
}; | ||
/** | ||
* | ||
* @example | ||
* ```javascript | ||
* txHash = '0xf8698085174876e8008252088080949d72989b68777a1f3ffd6f1db079f1928373ee52830186a08027a0ab8229ff5d5240948098f26372eaed9ab2e9be23e8594b08e358ca56a47f8ae9a0084e5c4d1fec496af444423d8a714f65c079260ff01a1be1de7005dd424adf44' | ||
* | ||
* const recoverTx = hmy.transactions.recover(txHash); | ||
* console.log(recoverTx); | ||
* ``` | ||
*/ | ||
TransactionFactory.prototype.recover = function (txHash) { | ||
@@ -1169,2 +1330,87 @@ var newTxn = new Transaction({}, this.messenger, "INITIALIZED" /* INTIALIZED */); | ||
/** | ||
* ## About this package | ||
* | ||
* `@harmony-js/transaction` provides the functions to build transactions | ||
* | ||
* Develop can use this package to: | ||
* - build a transaction offline! | ||
* - set params of transaction | ||
* - | ||
* | ||
* ## How to use this package | ||
* ### Step 1: create a Harmony Instance | ||
* ```javascript | ||
* const { Harmony } = require('@harmony-js/core'); | ||
* const { ChainID, ChainType } = require('@harmony-js/utils'); | ||
* const { BN } = require('@harmony-js/crypto'); | ||
* | ||
* const hmy = new Harmony( | ||
* 'http://localhost:9500', | ||
* { | ||
* chainType: ChainType.Harmony, | ||
* chainId: ChainID.HmyLocal, | ||
* }, | ||
* ); | ||
* ``` | ||
* | ||
* ### Step 2: build a transaction | ||
* ```javascript | ||
* const txn = hmy.transactions.newTx({ | ||
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', | ||
* value: '10000', | ||
* gasLimit: '210000', | ||
* shardID: 0, | ||
* toShardID: 0, | ||
* gasPrice: new hmy.utils.Unit('100').asGwei().toWei(), | ||
* }); | ||
* ``` | ||
* | ||
* ## some important information | ||
* Transaction Parameters | ||
* ```java | ||
* // interface TxParams | ||
* id: string; | ||
* from: string; | ||
* to: string; | ||
* nonce: number | string; | ||
* gasLimit: number | string | BN; | ||
* gasPrice: number | string | BN; | ||
* shardID: number | string; | ||
* toShardID: number | string; | ||
* data: string; | ||
* value: number | string | BN; | ||
* chainId: number; | ||
* rawTransaction: string; | ||
* unsignedRawTransaction: string; | ||
* signature: Signature; | ||
* receipt?: TransasctionReceipt; | ||
* ``` | ||
* | ||
* Transaction Receipt | ||
* ```java | ||
* // interface TransasctionReceipt | ||
* transactionHash: string; | ||
* transactionIndex: string; | ||
* blockHash: string; | ||
* blockNumber: string; // 11 | ||
* from: string; | ||
* to: string; | ||
* gasUsed: string; | ||
* cumulativeGasUsed: string; // 13244 | ||
* contractAddress?: string | null; // or null, if none was created | ||
* logs: any[]; | ||
* logsBloom: string; // 256 byte bloom filter | ||
* v: string; | ||
* r: string; | ||
* s: string; | ||
* responseType?: string; | ||
* byzantium?: boolean; | ||
* status?: string; // post Byzantium will return `0x0` or `0x1` | ||
* root?: string; // pre Byzantium will return `root` | ||
* ``` | ||
* | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
*/ | ||
var TxStatus; | ||
@@ -1180,2 +1426,7 @@ (function (TxStatus) { | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
var AbstractTransaction = /** @class */ (function () { | ||
@@ -1187,3 +1438,9 @@ function AbstractTransaction() { | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
export { TransactionFactory, Transaction, ShardingTransaction, TxStatus, transactionFields, transactionFieldsETH, handleNumber, handleAddress, recover, recoverETH, sleep, TransactionEvents, defaultMessenger, RLPSign, TransactionBase, AbstractTransaction }; | ||
//# sourceMappingURL=index.esm.js.map |
"use strict"; | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -3,0 +8,0 @@ var tslib_1 = require("tslib"); |
@@ -0,1 +1,6 @@ | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
import { Messenger } from '@harmony-js/network'; | ||
@@ -2,0 +7,0 @@ import { Transaction } from './transaction'; |
"use strict"; | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ShardingTransaction = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -4,0 +10,0 @@ var utils_1 = require("@harmony-js/utils"); |
@@ -0,1 +1,5 @@ | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
*/ | ||
import { Signature } from '@harmony-js/crypto'; | ||
@@ -6,19 +10,76 @@ import { Messenger } from '@harmony-js/network'; | ||
declare class Transaction extends TransactionBase { | ||
/** @hidden */ | ||
private from; | ||
/** @hidden */ | ||
private nonce; | ||
/** @hidden */ | ||
private to; | ||
/** @hidden */ | ||
private toShardID; | ||
/** @hidden */ | ||
private gasLimit; | ||
/** @hidden */ | ||
private gasPrice; | ||
/** @hidden */ | ||
private data; | ||
/** @hidden */ | ||
private value; | ||
/** @hidden */ | ||
private chainId; | ||
/** @hidden */ | ||
private rawTransaction; | ||
/** @hidden */ | ||
private unsignedRawTransaction; | ||
/** @hidden */ | ||
private signature; | ||
/** | ||
* | ||
* @Params | ||
* ```javascript | ||
* id: string; | ||
from: string; | ||
to: string; | ||
nonce: number | string; | ||
gasLimit: number | string | BN; | ||
gasPrice: number | string | BN; | ||
shardID: number | string; | ||
toShardID: number | string; | ||
data: string; | ||
value: number | string | BN; | ||
chainId: number; | ||
rawTransaction: string; | ||
unsignedRawTransaction: string; | ||
signature: Signature; | ||
receipt?: TransasctionReceipt; | ||
* ``` | ||
*/ | ||
constructor(params?: TxParams | any, messenger?: Messenger, txStatus?: TxStatus); | ||
/** | ||
* | ||
* @example | ||
* ```javascript | ||
* const unsigned = txn.getRLPUnsigned(txn); | ||
* console.log(unsigned); | ||
* ``` | ||
*/ | ||
getRLPUnsigned(): [string, any[]]; | ||
getRLPSigned(raw: any[], signature: Signature): string; | ||
/** | ||
* @example | ||
* ```javascript | ||
* console.log(txn.getRawTransaction()); | ||
* ``` | ||
*/ | ||
getRawTransaction(): string; | ||
/** @hidden */ | ||
recover(rawTransaction: string): Transaction; | ||
/** | ||
* get the payload of transaction | ||
* | ||
* @example | ||
* ``` | ||
* const payload = txn.txPayload; | ||
* console.log(payload); | ||
* ``` | ||
*/ | ||
get txPayload(): { | ||
@@ -35,6 +96,54 @@ from: string; | ||
}; | ||
/** | ||
* get transaction params | ||
* | ||
* @example | ||
* ``` | ||
* const txParams = txn.txParams; | ||
* console.log(txParams) | ||
* ``` | ||
*/ | ||
get txParams(): TxParams; | ||
/** | ||
* set the params to the txn | ||
* | ||
* @example | ||
* ``` | ||
* txn.setParams({ | ||
* to: 'one1ew56rqrucu6p6n598fmjmnfh8dd4xpg6atne9c', | ||
* value: '1200', | ||
* gasLimit: '230000', | ||
* shardID: 1, | ||
* toShardID: 0, | ||
* gasPrice: new hmy.utils.Unit('101').asGwei().toWei(), | ||
* signature: { | ||
* r: '0xd693b532a80fed6392b428604171fb32fdbf953728a3a7ecc7d4062b1652c042', | ||
* s: '0x24e9c602ac800b983b035700a14b23f78a253ab762deab5dc27e3555a750b354', | ||
* v: 0 | ||
* }, | ||
* }); | ||
* console.log(txn); | ||
* ``` | ||
*/ | ||
setParams(params: TxParams): void; | ||
/** @hidden */ | ||
map(fn: any): this; | ||
/** | ||
* Check whether the transaction is cross shard | ||
* | ||
* @example | ||
* ```javascript | ||
* console.log(txn.isCrossShard()); | ||
* ``` | ||
*/ | ||
isCrossShard(): boolean; | ||
/** | ||
* | ||
* @example | ||
* ``` | ||
* txn.sendTransaction().then((value) => { | ||
* console.log(value); | ||
* }); | ||
* ``` | ||
*/ | ||
sendTransaction(): Promise<[Transaction, string]>; | ||
@@ -41,0 +150,0 @@ confirm(txHash: string, maxAttempts?: number, interval?: number, shardID?: number | string, toShardID?: number | string): Promise<TransactionBase>; |
"use strict"; | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Transaction = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -10,3 +15,23 @@ var crypto_1 = require("@harmony-js/crypto"); | ||
tslib_1.__extends(Transaction, _super); | ||
// constructor | ||
/** | ||
* | ||
* @Params | ||
* ```javascript | ||
* id: string; | ||
from: string; | ||
to: string; | ||
nonce: number | string; | ||
gasLimit: number | string | BN; | ||
gasPrice: number | string | BN; | ||
shardID: number | string; | ||
toShardID: number | string; | ||
data: string; | ||
value: number | string | BN; | ||
chainId: number; | ||
rawTransaction: string; | ||
unsignedRawTransaction: string; | ||
signature: Signature; | ||
receipt?: TransasctionReceipt; | ||
* ``` | ||
*/ | ||
function Transaction(params, messenger, txStatus) { | ||
@@ -54,2 +79,10 @@ if (messenger === void 0) { messenger = utils_2.defaultMessenger; } | ||
} | ||
/** | ||
* | ||
* @example | ||
* ```javascript | ||
* const unsigned = txn.getRLPUnsigned(txn); | ||
* console.log(unsigned); | ||
* ``` | ||
*/ | ||
Transaction.prototype.getRLPUnsigned = function () { | ||
@@ -99,5 +132,12 @@ var _this = this; | ||
}; | ||
/** | ||
* @example | ||
* ```javascript | ||
* console.log(txn.getRawTransaction()); | ||
* ``` | ||
*/ | ||
Transaction.prototype.getRawTransaction = function () { | ||
return this.rawTransaction; | ||
}; | ||
/** @hidden */ | ||
Transaction.prototype.recover = function (rawTransaction) { | ||
@@ -112,3 +152,11 @@ // temp setting to be compatible with eth | ||
Object.defineProperty(Transaction.prototype, "txPayload", { | ||
// use when using eth_sendTransaction | ||
/** | ||
* get the payload of transaction | ||
* | ||
* @example | ||
* ``` | ||
* const payload = txn.txPayload; | ||
* console.log(payload); | ||
* ``` | ||
*/ | ||
get: function () { | ||
@@ -127,6 +175,15 @@ return { | ||
}, | ||
enumerable: true, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Transaction.prototype, "txParams", { | ||
/** | ||
* get transaction params | ||
* | ||
* @example | ||
* ``` | ||
* const txParams = txn.txParams; | ||
* console.log(txParams) | ||
* ``` | ||
*/ | ||
get: function () { | ||
@@ -150,5 +207,26 @@ return { | ||
}, | ||
enumerable: true, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
/** | ||
* set the params to the txn | ||
* | ||
* @example | ||
* ``` | ||
* txn.setParams({ | ||
* to: 'one1ew56rqrucu6p6n598fmjmnfh8dd4xpg6atne9c', | ||
* value: '1200', | ||
* gasLimit: '230000', | ||
* shardID: 1, | ||
* toShardID: 0, | ||
* gasPrice: new hmy.utils.Unit('101').asGwei().toWei(), | ||
* signature: { | ||
* r: '0xd693b532a80fed6392b428604171fb32fdbf953728a3a7ecc7d4062b1652c042', | ||
* s: '0x24e9c602ac800b983b035700a14b23f78a253ab762deab5dc27e3555a750b354', | ||
* v: 0 | ||
* }, | ||
* }); | ||
* console.log(txn); | ||
* ``` | ||
*/ | ||
Transaction.prototype.setParams = function (params) { | ||
@@ -194,2 +272,3 @@ this.id = params && params.id ? params.id : '0x'; | ||
}; | ||
/** @hidden */ | ||
Transaction.prototype.map = function (fn) { | ||
@@ -200,5 +279,22 @@ var newParams = fn(this.txParams); | ||
}; | ||
/** | ||
* Check whether the transaction is cross shard | ||
* | ||
* @example | ||
* ```javascript | ||
* console.log(txn.isCrossShard()); | ||
* ``` | ||
*/ | ||
Transaction.prototype.isCrossShard = function () { | ||
return new crypto_1.BN(this.txParams.shardID).toString() !== new crypto_1.BN(this.txParams.toShardID).toString(); | ||
}; | ||
/** | ||
* | ||
* @example | ||
* ``` | ||
* txn.sendTransaction().then((value) => { | ||
* console.log(value); | ||
* }); | ||
* ``` | ||
*/ | ||
Transaction.prototype.sendTransaction = function () { | ||
@@ -205,0 +301,0 @@ return tslib_1.__awaiter(this, void 0, void 0, function () { |
@@ -0,1 +1,6 @@ | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
/// <reference types="bn.js" /> | ||
@@ -2,0 +7,0 @@ import { BN } from '@harmony-js/crypto'; |
"use strict"; | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TransactionBase = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -4,0 +10,0 @@ var crypto_1 = require("@harmony-js/crypto"); |
@@ -0,1 +1,86 @@ | ||
/** | ||
* ## About this package | ||
* | ||
* `@harmony-js/transaction` provides the functions to build transactions | ||
* | ||
* Develop can use this package to: | ||
* - build a transaction offline! | ||
* - set params of transaction | ||
* - | ||
* | ||
* ## How to use this package | ||
* ### Step 1: create a Harmony Instance | ||
* ```javascript | ||
* const { Harmony } = require('@harmony-js/core'); | ||
* const { ChainID, ChainType } = require('@harmony-js/utils'); | ||
* const { BN } = require('@harmony-js/crypto'); | ||
* | ||
* const hmy = new Harmony( | ||
* 'http://localhost:9500', | ||
* { | ||
* chainType: ChainType.Harmony, | ||
* chainId: ChainID.HmyLocal, | ||
* }, | ||
* ); | ||
* ``` | ||
* | ||
* ### Step 2: build a transaction | ||
* ```javascript | ||
* const txn = hmy.transactions.newTx({ | ||
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', | ||
* value: '10000', | ||
* gasLimit: '210000', | ||
* shardID: 0, | ||
* toShardID: 0, | ||
* gasPrice: new hmy.utils.Unit('100').asGwei().toWei(), | ||
* }); | ||
* ``` | ||
* | ||
* ## some important information | ||
* Transaction Parameters | ||
* ```java | ||
* // interface TxParams | ||
* id: string; | ||
* from: string; | ||
* to: string; | ||
* nonce: number | string; | ||
* gasLimit: number | string | BN; | ||
* gasPrice: number | string | BN; | ||
* shardID: number | string; | ||
* toShardID: number | string; | ||
* data: string; | ||
* value: number | string | BN; | ||
* chainId: number; | ||
* rawTransaction: string; | ||
* unsignedRawTransaction: string; | ||
* signature: Signature; | ||
* receipt?: TransasctionReceipt; | ||
* ``` | ||
* | ||
* Transaction Receipt | ||
* ```java | ||
* // interface TransasctionReceipt | ||
* transactionHash: string; | ||
* transactionIndex: string; | ||
* blockHash: string; | ||
* blockNumber: string; // 11 | ||
* from: string; | ||
* to: string; | ||
* gasUsed: string; | ||
* cumulativeGasUsed: string; // 13244 | ||
* contractAddress?: string | null; // or null, if none was created | ||
* logs: any[]; | ||
* logsBloom: string; // 256 byte bloom filter | ||
* v: string; | ||
* r: string; | ||
* s: string; | ||
* responseType?: string; | ||
* byzantium?: boolean; | ||
* status?: string; // post Byzantium will return `0x0` or `0x1` | ||
* root?: string; // pre Byzantium will return `root` | ||
* ``` | ||
* | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
*/ | ||
/// <reference types="bn.js" /> | ||
@@ -2,0 +87,0 @@ import { BN, Signature } from '@harmony-js/crypto'; |
"use strict"; | ||
/** | ||
* ## About this package | ||
* | ||
* `@harmony-js/transaction` provides the functions to build transactions | ||
* | ||
* Develop can use this package to: | ||
* - build a transaction offline! | ||
* - set params of transaction | ||
* - | ||
* | ||
* ## How to use this package | ||
* ### Step 1: create a Harmony Instance | ||
* ```javascript | ||
* const { Harmony } = require('@harmony-js/core'); | ||
* const { ChainID, ChainType } = require('@harmony-js/utils'); | ||
* const { BN } = require('@harmony-js/crypto'); | ||
* | ||
* const hmy = new Harmony( | ||
* 'http://localhost:9500', | ||
* { | ||
* chainType: ChainType.Harmony, | ||
* chainId: ChainID.HmyLocal, | ||
* }, | ||
* ); | ||
* ``` | ||
* | ||
* ### Step 2: build a transaction | ||
* ```javascript | ||
* const txn = hmy.transactions.newTx({ | ||
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', | ||
* value: '10000', | ||
* gasLimit: '210000', | ||
* shardID: 0, | ||
* toShardID: 0, | ||
* gasPrice: new hmy.utils.Unit('100').asGwei().toWei(), | ||
* }); | ||
* ``` | ||
* | ||
* ## some important information | ||
* Transaction Parameters | ||
* ```java | ||
* // interface TxParams | ||
* id: string; | ||
* from: string; | ||
* to: string; | ||
* nonce: number | string; | ||
* gasLimit: number | string | BN; | ||
* gasPrice: number | string | BN; | ||
* shardID: number | string; | ||
* toShardID: number | string; | ||
* data: string; | ||
* value: number | string | BN; | ||
* chainId: number; | ||
* rawTransaction: string; | ||
* unsignedRawTransaction: string; | ||
* signature: Signature; | ||
* receipt?: TransasctionReceipt; | ||
* ``` | ||
* | ||
* Transaction Receipt | ||
* ```java | ||
* // interface TransasctionReceipt | ||
* transactionHash: string; | ||
* transactionIndex: string; | ||
* blockHash: string; | ||
* blockNumber: string; // 11 | ||
* from: string; | ||
* to: string; | ||
* gasUsed: string; | ||
* cumulativeGasUsed: string; // 13244 | ||
* contractAddress?: string | null; // or null, if none was created | ||
* logs: any[]; | ||
* logsBloom: string; // 256 byte bloom filter | ||
* v: string; | ||
* r: string; | ||
* s: string; | ||
* responseType?: string; | ||
* byzantium?: boolean; | ||
* status?: string; // post Byzantium will return `0x0` or `0x1` | ||
* root?: string; // pre Byzantium will return `root` | ||
* ``` | ||
* | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TxStatus = void 0; | ||
var TxStatus; | ||
@@ -4,0 +90,0 @@ (function (TxStatus) { |
@@ -0,1 +1,6 @@ | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
import { Signature } from '@harmony-js/crypto'; | ||
@@ -2,0 +7,0 @@ import { Messenger } from '@harmony-js/network'; |
"use strict"; | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
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"); | ||
@@ -4,0 +10,0 @@ var utils_1 = require("@harmony-js/utils"); |
{ | ||
"name": "@harmony-js/transaction", | ||
"version": "0.1.43", | ||
"version": "0.1.45", | ||
"description": "transaction package for harmony", | ||
@@ -21,7 +21,7 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@harmony-js/crypto": "^0.1.43", | ||
"@harmony-js/network": "^0.1.43", | ||
"@harmony-js/utils": "^0.1.43" | ||
"@harmony-js/crypto": "^0.1.45", | ||
"@harmony-js/network": "^0.1.45", | ||
"@harmony-js/utils": "^0.1.45" | ||
}, | ||
"gitHead": "bdcfbf0f8050d96da22ed009da33465f7ad7671b" | ||
"gitHead": "a35db780aea823fab8510da0881b22805d35648f" | ||
} |
@@ -0,1 +1,7 @@ | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
import { Messenger } from '@harmony-js/network'; | ||
@@ -2,0 +8,0 @@ import { TxStatus } from './types'; |
@@ -0,1 +1,8 @@ | ||
/** | ||
* ## hhahaha | ||
* | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
*/ | ||
import { getContractAddress, getAddress } from '@harmony-js/crypto'; | ||
@@ -23,2 +30,26 @@ import { Messenger } from '@harmony-js/network'; | ||
/** | ||
* Create a new Transaction | ||
* @params | ||
* ``` | ||
* // to: Address of the receiver | ||
* // value: value transferred in wei | ||
* // gasLimit: the maximum gas would pay, can use string | ||
* // shardID: send token from shardID | ||
* // toShardId: send token to shardID | ||
* // gasPrice: you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN | ||
* ``` | ||
* | ||
* @example | ||
* ```javascript | ||
* const txn = hmy.transactions.newTx({ | ||
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', | ||
* value: '10000', | ||
* gasLimit: '210000', | ||
* shardID: 0, | ||
* toShardID: 0, | ||
* gasPrice: new hmy.utils.Unit('100').asGwei().toWei(), | ||
* }); | ||
* ``` | ||
*/ | ||
newTx(txParams?: TxParams | any, sharding: boolean = false): Transaction { | ||
@@ -31,2 +62,13 @@ if (!sharding) { | ||
/** | ||
* clone the transaction | ||
* | ||
* @param transaction | ||
* | ||
* @example | ||
* ```javascript | ||
* const cloneTxn = hmy.transactions.clone(txn); | ||
* console.log(cloneTxn) | ||
* ``` | ||
*/ | ||
clone(transaction: Transaction): Transaction { | ||
@@ -36,2 +78,12 @@ return new Transaction(transaction.txParams, this.messenger, TxStatus.INTIALIZED); | ||
/** | ||
* | ||
* @example | ||
* ```javascript | ||
* txHash = '0xf8698085174876e8008252088080949d72989b68777a1f3ffd6f1db079f1928373ee52830186a08027a0ab8229ff5d5240948098f26372eaed9ab2e9be23e8594b08e358ca56a47f8ae9a0084e5c4d1fec496af444423d8a714f65c079260ff01a1be1de7005dd424adf44' | ||
* | ||
* const recoverTx = hmy.transactions.recover(txHash); | ||
* console.log(recoverTx); | ||
* ``` | ||
*/ | ||
recover(txHash: string): Transaction { | ||
@@ -38,0 +90,0 @@ const newTxn = new Transaction({}, this.messenger, TxStatus.INTIALIZED); |
@@ -0,1 +1,7 @@ | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
export * from './factory'; | ||
@@ -2,0 +8,0 @@ export * from './transaction'; |
@@ -0,1 +1,7 @@ | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
import { Messenger } from '@harmony-js/network'; | ||
@@ -2,0 +8,0 @@ import { AddressSuffix } from '@harmony-js/utils'; |
@@ -0,1 +1,6 @@ | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
*/ | ||
import { | ||
@@ -24,17 +29,49 @@ BN, | ||
class Transaction extends TransactionBase { | ||
/** @hidden */ | ||
private from: string; | ||
/** @hidden */ | ||
private nonce: number | string; | ||
/** @hidden */ | ||
private to: string; | ||
// private shardID: number | string; | ||
/** @hidden */ | ||
private toShardID: number | string; | ||
/** @hidden */ | ||
private gasLimit: BN; | ||
/** @hidden */ | ||
private gasPrice: BN; | ||
/** @hidden */ | ||
private data: string; | ||
/** @hidden */ | ||
private value: BN; | ||
/** @hidden */ | ||
private chainId: number; | ||
/** @hidden */ | ||
private rawTransaction: string; | ||
/** @hidden */ | ||
private unsignedRawTransaction: string; | ||
/** @hidden */ | ||
private signature: Signature; | ||
// constructor | ||
/** | ||
* | ||
* @Params | ||
* ```javascript | ||
* id: string; | ||
from: string; | ||
to: string; | ||
nonce: number | string; | ||
gasLimit: number | string | BN; | ||
gasPrice: number | string | BN; | ||
shardID: number | string; | ||
toShardID: number | string; | ||
data: string; | ||
value: number | string | BN; | ||
chainId: number; | ||
rawTransaction: string; | ||
unsignedRawTransaction: string; | ||
signature: Signature; | ||
receipt?: TransasctionReceipt; | ||
* ``` | ||
*/ | ||
constructor( | ||
@@ -86,2 +123,10 @@ params?: TxParams | any, | ||
/** | ||
* | ||
* @example | ||
* ```javascript | ||
* const unsigned = txn.getRLPUnsigned(txn); | ||
* console.log(unsigned); | ||
* ``` | ||
*/ | ||
getRLPUnsigned(): [string, any[]] { | ||
@@ -143,2 +188,8 @@ const raw: Array<string | Uint8Array> = []; | ||
/** | ||
* @example | ||
* ```javascript | ||
* console.log(txn.getRawTransaction()); | ||
* ``` | ||
*/ | ||
getRawTransaction(): string { | ||
@@ -148,2 +199,3 @@ return this.rawTransaction; | ||
/** @hidden */ | ||
recover(rawTransaction: string): Transaction { | ||
@@ -159,3 +211,12 @@ // temp setting to be compatible with eth | ||
} | ||
// use when using eth_sendTransaction | ||
/** | ||
* get the payload of transaction | ||
* | ||
* @example | ||
* ``` | ||
* const payload = txn.txPayload; | ||
* console.log(payload); | ||
* ``` | ||
*/ | ||
get txPayload() { | ||
@@ -175,2 +236,11 @@ return { | ||
/** | ||
* get transaction params | ||
* | ||
* @example | ||
* ``` | ||
* const txParams = txn.txParams; | ||
* console.log(txParams) | ||
* ``` | ||
*/ | ||
get txParams(): TxParams { | ||
@@ -194,2 +264,24 @@ return { | ||
} | ||
/** | ||
* set the params to the txn | ||
* | ||
* @example | ||
* ``` | ||
* txn.setParams({ | ||
* to: 'one1ew56rqrucu6p6n598fmjmnfh8dd4xpg6atne9c', | ||
* value: '1200', | ||
* gasLimit: '230000', | ||
* shardID: 1, | ||
* toShardID: 0, | ||
* gasPrice: new hmy.utils.Unit('101').asGwei().toWei(), | ||
* signature: { | ||
* r: '0xd693b532a80fed6392b428604171fb32fdbf953728a3a7ecc7d4062b1652c042', | ||
* s: '0x24e9c602ac800b983b035700a14b23f78a253ab762deab5dc27e3555a750b354', | ||
* v: 0 | ||
* }, | ||
* }); | ||
* console.log(txn); | ||
* ``` | ||
*/ | ||
setParams(params: TxParams) { | ||
@@ -235,2 +327,3 @@ this.id = params && params.id ? params.id : '0x'; | ||
/** @hidden */ | ||
map(fn: any) { | ||
@@ -243,2 +336,10 @@ const newParams = fn(this.txParams); | ||
/** | ||
* Check whether the transaction is cross shard | ||
* | ||
* @example | ||
* ```javascript | ||
* console.log(txn.isCrossShard()); | ||
* ``` | ||
*/ | ||
isCrossShard(): boolean { | ||
@@ -248,2 +349,12 @@ return new BN(this.txParams.shardID).toString() !== new BN(this.txParams.toShardID).toString(); | ||
/** | ||
* | ||
* @example | ||
* ``` | ||
* txn.sendTransaction().then((value) => { | ||
* console.log(value); | ||
* }); | ||
* ``` | ||
*/ | ||
async sendTransaction(): Promise<[Transaction, string]> { | ||
@@ -250,0 +361,0 @@ if (this.rawTransaction === 'tx' || this.rawTransaction === undefined) { |
@@ -0,1 +1,7 @@ | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
import { BN, getAddress, HarmonyAddress } from '@harmony-js/crypto'; | ||
@@ -2,0 +8,0 @@ import { hexToNumber } from '@harmony-js/utils'; |
@@ -0,2 +1,89 @@ | ||
/** | ||
* ## About this package | ||
* | ||
* `@harmony-js/transaction` provides the functions to build transactions | ||
* | ||
* Develop can use this package to: | ||
* - build a transaction offline! | ||
* - set params of transaction | ||
* - | ||
* | ||
* ## How to use this package | ||
* ### Step 1: create a Harmony Instance | ||
* ```javascript | ||
* const { Harmony } = require('@harmony-js/core'); | ||
* const { ChainID, ChainType } = require('@harmony-js/utils'); | ||
* const { BN } = require('@harmony-js/crypto'); | ||
* | ||
* const hmy = new Harmony( | ||
* 'http://localhost:9500', | ||
* { | ||
* chainType: ChainType.Harmony, | ||
* chainId: ChainID.HmyLocal, | ||
* }, | ||
* ); | ||
* ``` | ||
* | ||
* ### Step 2: build a transaction | ||
* ```javascript | ||
* const txn = hmy.transactions.newTx({ | ||
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', | ||
* value: '10000', | ||
* gasLimit: '210000', | ||
* shardID: 0, | ||
* toShardID: 0, | ||
* gasPrice: new hmy.utils.Unit('100').asGwei().toWei(), | ||
* }); | ||
* ``` | ||
* | ||
* ## some important information | ||
* Transaction Parameters | ||
* ```java | ||
* // interface TxParams | ||
* id: string; | ||
* from: string; | ||
* to: string; | ||
* nonce: number | string; | ||
* gasLimit: number | string | BN; | ||
* gasPrice: number | string | BN; | ||
* shardID: number | string; | ||
* toShardID: number | string; | ||
* data: string; | ||
* value: number | string | BN; | ||
* chainId: number; | ||
* rawTransaction: string; | ||
* unsignedRawTransaction: string; | ||
* signature: Signature; | ||
* receipt?: TransasctionReceipt; | ||
* ``` | ||
* | ||
* Transaction Receipt | ||
* ```java | ||
* // interface TransasctionReceipt | ||
* transactionHash: string; | ||
* transactionIndex: string; | ||
* blockHash: string; | ||
* blockNumber: string; // 11 | ||
* from: string; | ||
* to: string; | ||
* gasUsed: string; | ||
* cumulativeGasUsed: string; // 13244 | ||
* contractAddress?: string | null; // or null, if none was created | ||
* logs: any[]; | ||
* logsBloom: string; // 256 byte bloom filter | ||
* v: string; | ||
* r: string; | ||
* s: string; | ||
* responseType?: string; | ||
* byzantium?: boolean; | ||
* status?: string; // post Byzantium will return `0x0` or `0x1` | ||
* root?: string; // pre Byzantium will return `root` | ||
* ``` | ||
* | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
*/ | ||
import { BN, Signature } from '@harmony-js/crypto'; | ||
export interface TxParams { | ||
@@ -3,0 +90,0 @@ id: string; |
@@ -0,1 +1,7 @@ | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @hidden | ||
*/ | ||
import { hexToNumber, isHex, isAddress, strip0x, ChainType } from '@harmony-js/utils'; | ||
@@ -2,0 +8,0 @@ import { |
@@ -0,1 +1,7 @@ | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @ignore | ||
*/ | ||
import { TransactionFactory, Transaction, TxStatus } from '../src'; | ||
@@ -2,0 +8,0 @@ // tslint:disable-next-line: no-implicit-dependencies |
@@ -0,1 +1,7 @@ | ||
/** | ||
* @packageDocumentation | ||
* @module harmony-transaction | ||
* @ignore | ||
*/ | ||
import { Transaction } from '../src/transaction'; | ||
@@ -2,0 +8,0 @@ import { RLPSign } from '../src/utils'; |
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
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
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
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
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
0
10282
845061
56
1
+ Added@types/node@22.9.4(transitive)
+ Addedcipher-base@1.0.5(transitive)
+ Addedundici-types@6.19.8(transitive)
- Removed@types/node@22.10.1(transitive)
- Removedcipher-base@1.0.6(transitive)
- Removedundici-types@6.20.0(transitive)
Updated@harmony-js/crypto@^0.1.45
Updated@harmony-js/network@^0.1.45
Updated@harmony-js/utils@^0.1.45