crypto-aio 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +2 -0
  2. package/dist/index.js +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/libs/eth/account.d.ts +3 -3
  5. package/dist/libs/eth/account.js +5 -5
  6. package/dist/libs/eth/account.js.map +1 -1
  7. package/dist/libs/eth/contract.d.ts +6 -1
  8. package/dist/libs/eth/contract.js +35 -0
  9. package/dist/libs/eth/contract.js.map +1 -1
  10. package/dist/libs/eth/index.d.ts +5 -0
  11. package/dist/libs/eth/index.js +20 -7
  12. package/dist/libs/eth/index.js.map +1 -1
  13. package/dist/libs/eth/transact.d.ts +6 -1
  14. package/dist/libs/eth/transact.js +19 -0
  15. package/dist/libs/eth/transact.js.map +1 -1
  16. package/dist/libs/index.d.ts +1 -0
  17. package/dist/libs/index.js +1 -0
  18. package/dist/libs/index.js.map +1 -1
  19. package/dist/libs/trx/account.d.ts +9 -0
  20. package/dist/libs/trx/account.js +55 -0
  21. package/dist/libs/trx/account.js.map +1 -0
  22. package/dist/libs/trx/contract.d.ts +7 -0
  23. package/dist/libs/trx/contract.js +27 -0
  24. package/dist/libs/trx/contract.js.map +1 -0
  25. package/dist/libs/trx/index.d.ts +22 -0
  26. package/dist/libs/{eth/_eth.js → trx/index.js} +30 -22
  27. package/dist/libs/trx/index.js.map +1 -0
  28. package/dist/libs/trx/transact.d.ts +7 -0
  29. package/dist/libs/trx/transact.js +26 -0
  30. package/dist/libs/trx/transact.js.map +1 -0
  31. package/dist/tool/eth-tools.d.ts +1 -1
  32. package/dist/tool/eth-tools.js +5 -5
  33. package/dist/tool/eth-tools.js.map +1 -1
  34. package/dist/tool/index.d.ts +1 -0
  35. package/dist/tool/index.js +1 -0
  36. package/dist/tool/index.js.map +1 -1
  37. package/dist/tool/options.d.ts +6 -4
  38. package/dist/tool/options.js +25 -14
  39. package/dist/tool/options.js.map +1 -1
  40. package/dist/tool/trx-tools.d.ts +3 -0
  41. package/dist/tool/trx-tools.js +20 -0
  42. package/dist/tool/trx-tools.js.map +1 -0
  43. package/dist/type/account.d.ts +1 -1
  44. package/dist/type/common.d.ts +6 -3
  45. package/dist/type/contract.d.ts +10 -0
  46. package/dist/type/contract.js +3 -0
  47. package/dist/type/contract.js.map +1 -0
  48. package/dist/type/index.d.ts +2 -0
  49. package/dist/type/index.js +2 -0
  50. package/dist/type/index.js.map +1 -1
  51. package/dist/type/lib-types.d.ts +4 -2
  52. package/dist/type/transact.d.ts +7 -0
  53. package/dist/type/transact.js +3 -0
  54. package/dist/type/transact.js.map +1 -0
  55. package/package.json +5 -4
  56. package/dist/libs/eth/_eth.d.ts +0 -17
  57. package/dist/libs/eth/_eth.js.map +0 -1
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Crypto-AIO
2
2
 
3
+ All-In-One Crypto-Currency for Backend
4
+
3
5
  [![Build, Test and Publish](https://github.com/vhidvz/crypto-aio/actions/workflows/npm-ci.yml/badge.svg)](https://github.com/vhidvz/crypto-aio/actions/workflows/npm-ci.yml)
4
6
  [![npm](https://img.shields.io/npm/v/crypto-aio)](https://www.npmjs.com/package/crypto-aio)
5
7
  ![npm](https://img.shields.io/npm/dm/crypto-aio)
package/dist/index.js CHANGED
@@ -34,7 +34,7 @@ __exportStar(require("./tool"), exports);
34
34
  __exportStar(require("./type"), exports);
35
35
  const cryptoAioOptions = (env) => {
36
36
  return {
37
- ETH: (0, tool_1.defaultEthereumOptions)(env),
37
+ ETH: (0, tool_1.ethereumOptions)(env),
38
38
  };
39
39
  };
40
40
  exports.cryptoAioOptions = cryptoAioOptions;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAmD;AACnD,iCAAgD;AAEhD,yCAAuB;AACvB,yCAAuB;AACvB,yCAAuB;AAMhB,MAAM,gBAAgB,GAAG,CAAC,GAAY,EAAoB,EAAE;IACjE,OAAO;QACL,GAAG,EAAE,IAAA,6BAAsB,EAAC,GAAG,CAAC;KACjC,CAAC;AACJ,CAAC,CAAC;AAJW,QAAA,gBAAgB,oBAI3B;AAEF,MAAa,SAAS;IAGpB,YAAqB,UAA4B,IAAA,wBAAgB,GAAE;QAA9C,YAAO,GAAP,OAAO,CAAuC;QAFnE,iCAAgB;IAEsD,CAAC;IAEvE,IAAI,GAAG;QACL,OAAO,CAAC,uBAAA,IAAI,kBAAQ,uBAAA,IAAI,sBAAK,IAAI,IAAI,eAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAA,CAAC,CAAC;IACtE,CAAC;CACF;AARD,8BAQC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAmD;AACnD,iCAAyC;AAEzC,yCAAuB;AACvB,yCAAuB;AACvB,yCAAuB;AAMhB,MAAM,gBAAgB,GAAG,CAAC,GAAY,EAAoB,EAAE;IACjE,OAAO;QACL,GAAG,EAAE,IAAA,sBAAe,EAAC,GAAG,CAAC;KAC1B,CAAC;AACJ,CAAC,CAAC;AAJW,QAAA,gBAAgB,oBAI3B;AAEF,MAAa,SAAS;IAGpB,YAAqB,UAA4B,IAAA,wBAAgB,GAAE;QAA9C,YAAO,GAAP,OAAO,CAAuC;QAFnE,iCAAgB;IAEsD,CAAC;IAEvE,IAAI,GAAG;QACL,OAAO,CAAC,uBAAA,IAAI,kBAAQ,uBAAA,IAAI,sBAAK,IAAI,IAAI,eAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAA,CAAC,CAAC;IACtE,CAAC;CACF;AARD,8BAQC"}
@@ -1,9 +1,9 @@
1
1
  import { EthereumOptions } from './index';
2
- import { Account, CommonOptions } from '../../type';
2
+ import { Account } from '../../type';
3
3
  export declare class EthereumAccount implements Account<EthereumOptions> {
4
4
  readonly options: EthereumOptions;
5
5
  constructor(options?: EthereumOptions);
6
6
  getBalance(address?: string | undefined): Promise<bigint>;
7
- create(CommonOptions?: CommonOptions): EthereumAccount;
8
- static create(options?: CommonOptions): EthereumAccount;
7
+ create(options?: import("../../type").CommonOptions, lib?: "web3" | "ethers" | undefined): EthereumAccount;
8
+ static create(options?: import("../../type").CommonOptions, lib?: "web3" | "ethers" | undefined): EthereumAccount;
9
9
  }
@@ -18,7 +18,7 @@ const ethers_1 = require("ethers");
18
18
  const web3_1 = require("web3");
19
19
  const tool_1 = require("../../tool");
20
20
  class EthereumAccount {
21
- constructor(options = (0, tool_1.defaultEthereumOptions)()) {
21
+ constructor(options = (0, tool_1.ethereumOptions)()) {
22
22
  this.options = options;
23
23
  (0, tool_1.initEth)(options);
24
24
  }
@@ -34,10 +34,10 @@ class EthereumAccount {
34
34
  throw new Error('unknown client');
35
35
  });
36
36
  }
37
- create(CommonOptions = (0, tool_1.defaultCommonOptions)('ETH')) {
38
- return EthereumAccount.create(CommonOptions);
37
+ create(options = (0, tool_1.commonOptions)('ETH'), lib = (0, tool_1.bp)('ETH', 'LIB')) {
38
+ return EthereumAccount.create(options, lib);
39
39
  }
40
- static create(options = (0, tool_1.defaultCommonOptions)('ETH')) {
40
+ static create(options = (0, tool_1.commonOptions)('ETH'), lib = (0, tool_1.bp)('ETH', 'LIB')) {
41
41
  var _a;
42
42
  const wallet = ethers_1.ethers.Wallet.createRandom();
43
43
  const account = {
@@ -51,7 +51,7 @@ class EthereumAccount {
51
51
  emitter.emit((0, tool_1.bt)('ETH', 'account.create'), account);
52
52
  if (console)
53
53
  console((0, tool_1.info)(`an account created with the ${address} address`));
54
- return new EthereumAccount(Object.assign(Object.assign({}, options), account));
54
+ return new EthereumAccount(Object.assign(Object.assign({ lib }, options), account));
55
55
  }
56
56
  }
57
57
  exports.EthereumAccount = EthereumAccount;
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SAAE,EAAgC,KAAK,EAAE,KAAK,CAAC;QAErD,OAAO,eAAe,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,CAAC,MAAM,CACX,OAAO,GAAG,IAAA,oBAAa,EAAC,KAAK,CAAC,EAC9B,MAAM,IAAA,SAAE,EAAgC,KAAK,EAAE,KAAK,CAAC;;QAErD,MAAM,MAAM,GAAG,eAAM,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;QAC5C,MAAM,OAAO,GAAmB;YAC9B,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,UAAU;YAC1B,OAAO,EAAE,MAAA,MAAM,CAAC,QAAQ,0CAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;SAC5C,CAAC;QAEF,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAC5B,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QACrC,IAAI,OAAO;YAAE,OAAO,CAAC,IAAI,CAAC,IAAA,SAAE,EAAC,KAAK,EAAE,gBAAgB,CAAC,EAAE,OAAO,CAAC,CAAC;QAChE,IAAI,OAAO;YAAE,OAAO,CAAC,IAAA,WAAI,EAAC,+BAA+B,OAAO,UAAU,CAAC,CAAC,CAAC;QAE7E,OAAO,IAAI,eAAe,+BAAG,GAAG,IAAK,OAAO,GAAK,OAAO,EAAG,CAAC;IAC9D,CAAC;CACF;AAvCD,0CAuCC"}
@@ -1,2 +1,7 @@
1
- export declare class EthereumContract {
1
+ import { EthereumOptions } from './index';
2
+ import { Contract, ContractOptions } from '../../type';
3
+ export declare class EthereumContract implements Contract<EthereumOptions> {
4
+ readonly options: EthereumOptions;
5
+ constructor(options?: EthereumOptions);
6
+ estimateGas(method?: string, options?: ContractOptions): Promise<bigint>;
2
7
  }
@@ -1,7 +1,42 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
2
14
  Object.defineProperty(exports, "__esModule", { value: true });
3
15
  exports.EthereumContract = void 0;
16
+ const node_assert_1 = __importDefault(require("node:assert"));
17
+ const ethers_1 = require("ethers");
18
+ const web3_1 = require("web3");
19
+ const tool_1 = require("../../tool");
4
20
  class EthereumContract {
21
+ constructor(options = (0, tool_1.ethereumOptions)()) {
22
+ this.options = options;
23
+ (0, tool_1.initEth)(options);
24
+ }
25
+ estimateGas() {
26
+ return __awaiter(this, arguments, void 0, function* (method = 'transfer', options = this.options) {
27
+ const { abi, contract: address } = options;
28
+ (0, node_assert_1.default)((abi === null || abi === void 0 ? void 0 : abi.length) && address, 'abi and contract are required');
29
+ const { client } = this.options;
30
+ if (client instanceof web3_1.Web3) {
31
+ return client.eth.estimateGas({ from: address, type: method });
32
+ }
33
+ else if (client instanceof ethers_1.ethers.JsonRpcProvider) {
34
+ return client.estimateGas({ from: address, value: method });
35
+ }
36
+ else
37
+ throw new Error('unknown client');
38
+ });
39
+ }
5
40
  }
6
41
  exports.EthereumContract = EthereumContract;
7
42
  //# sourceMappingURL=contract.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../src/libs/eth/contract.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAgB;CAAG;AAAhC,4CAAgC"}
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../src/libs/eth/contract.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,8DAAiC;AACjC,mCAAgC;AAChC,+BAA4B;AAG5B,qCAAsD;AAGtD,MAAa,gBAAgB;IAC3B,YAAqB,UAA2B,IAAA,sBAAe,GAAE;QAA5C,YAAO,GAAP,OAAO,CAAqC;QAC/D,IAAA,cAAO,EAAC,OAAO,CAAC,CAAC;IACnB,CAAC;IAEK,WAAW;6DACf,SAAiB,UAAU,EAC3B,UAA2B,IAAI,CAAC,OAAO;YAEvC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;YAC3C,IAAA,qBAAM,EAAC,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,KAAI,OAAO,EAAE,+BAA+B,CAAC,CAAC;YAEhE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;YAChC,IAAI,MAAM,YAAY,WAAI,EAAE,CAAC;gBAC3B,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;YACjE,CAAC;iBAAM,IAAI,MAAM,YAAY,eAAM,CAAC,eAAe,EAAE,CAAC;gBACpD,OAAO,MAAM,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;YAC9D,CAAC;;gBAAM,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAC3C,CAAC;KAAA;CACF;AAnBD,4CAmBC"}
@@ -1,6 +1,8 @@
1
1
  import { ethers } from 'ethers';
2
2
  import { Web3 } from 'web3';
3
3
  import { EthereumAccount } from './account';
4
+ import { EthereumContract } from './contract';
5
+ import { EthereumTransact } from './transact';
4
6
  import { Crypto, CryptoOptions } from '../../type';
5
7
  export { EthereumAccount } from './account';
6
8
  export { EthereumContract } from './contract';
@@ -15,5 +17,8 @@ export declare class Ethereum implements Crypto<EthereumOptions> {
15
17
  static readonly symbol = "ETH";
16
18
  constructor(options?: EthereumOptions);
17
19
  get account(): EthereumAccount;
20
+ get contract(): EthereumContract;
21
+ get transact(): EthereumTransact;
22
+ createAccount(options?: import("../../type").CommonOptions, lib?: "web3" | "ethers" | undefined): EthereumAccount;
18
23
  getGasPrice(): Promise<bigint | null>;
19
24
  }
@@ -19,28 +19,41 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
19
19
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
20
20
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
21
21
  };
22
- var _Ethereum_account;
22
+ var _Ethereum_account, _Ethereum_contract, _Ethereum_transact;
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.Ethereum = exports.EthereumTransact = exports.EthereumContract = exports.EthereumAccount = void 0;
25
25
  const ethers_1 = require("ethers");
26
26
  const web3_1 = require("web3");
27
27
  const account_1 = require("./account");
28
+ const contract_1 = require("./contract");
29
+ const transact_1 = require("./transact");
28
30
  const tool_1 = require("../../tool");
29
31
  var account_2 = require("./account");
30
32
  Object.defineProperty(exports, "EthereumAccount", { enumerable: true, get: function () { return account_2.EthereumAccount; } });
31
- var contract_1 = require("./contract");
32
- Object.defineProperty(exports, "EthereumContract", { enumerable: true, get: function () { return contract_1.EthereumContract; } });
33
- var transact_1 = require("./transact");
34
- Object.defineProperty(exports, "EthereumTransact", { enumerable: true, get: function () { return transact_1.EthereumTransact; } });
33
+ var contract_2 = require("./contract");
34
+ Object.defineProperty(exports, "EthereumContract", { enumerable: true, get: function () { return contract_2.EthereumContract; } });
35
+ var transact_2 = require("./transact");
36
+ Object.defineProperty(exports, "EthereumTransact", { enumerable: true, get: function () { return transact_2.EthereumTransact; } });
35
37
  class Ethereum {
36
- constructor(options = (0, tool_1.defaultEthereumOptions)()) {
38
+ constructor(options = (0, tool_1.ethereumOptions)()) {
37
39
  this.options = options;
38
40
  _Ethereum_account.set(this, void 0);
41
+ _Ethereum_contract.set(this, void 0);
42
+ _Ethereum_transact.set(this, void 0);
39
43
  (0, tool_1.initEth)(options);
40
44
  }
41
45
  get account() {
42
46
  return (__classPrivateFieldSet(this, _Ethereum_account, __classPrivateFieldGet(this, _Ethereum_account, "f") || new account_1.EthereumAccount(this.options), "f"));
43
47
  }
48
+ get contract() {
49
+ return (__classPrivateFieldSet(this, _Ethereum_contract, __classPrivateFieldGet(this, _Ethereum_contract, "f") || new contract_1.EthereumContract(this.options), "f"));
50
+ }
51
+ get transact() {
52
+ return (__classPrivateFieldSet(this, _Ethereum_transact, __classPrivateFieldGet(this, _Ethereum_transact, "f") || new transact_1.EthereumTransact(this.options), "f"));
53
+ }
54
+ createAccount(options = (0, tool_1.commonOptions)('ETH'), lib = (0, tool_1.bp)('ETH', 'LIB')) {
55
+ return this.account.create(options, lib);
56
+ }
44
57
  getGasPrice() {
45
58
  return __awaiter(this, void 0, void 0, function* () {
46
59
  const { client } = this.options;
@@ -54,6 +67,6 @@ class Ethereum {
54
67
  }
55
68
  }
56
69
  exports.Ethereum = Ethereum;
57
- _Ethereum_account = new WeakMap();
70
+ _Ethereum_account = new WeakMap(), _Ethereum_contract = new WeakMap(), _Ethereum_transact = new WeakMap();
58
71
  Ethereum.symbol = 'ETH';
59
72
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/libs/eth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAgC;AAChC,+BAA4B;AAE5B,uCAA4C;AAE5C,qCAA6D;AAE7D,qCAA4C;AAAnC,0GAAA,eAAe,OAAA;AACxB,uCAA8C;AAArC,4GAAA,gBAAgB,OAAA;AACzB,uCAA8C;AAArC,4GAAA,gBAAgB,OAAA;AAOzB,MAAa,QAAQ;IAKnB,YAAqB,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CAAC,uBAAA,IAAI,qBAAY,uBAAA,IAAI,yBAAS,IAAI,IAAI,yBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,MAAA,CAAC,CAAC;IAC9E,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,CAAC,uBAAA,IAAI,sBAAa,uBAAA,IAAI,0BAAU,IAAI,IAAI,2BAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,MAAA,CAAC,CAAC;IACjF,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,CAAC,uBAAA,IAAI,sBAAa,uBAAA,IAAI,0BAAU,IAAI,IAAI,2BAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,MAAA,CAAC,CAAC;IACjF,CAAC;IAED,aAAa,CACX,OAAO,GAAG,IAAA,oBAAa,EAAC,KAAK,CAAC,EAC9B,MAAM,IAAA,SAAE,EAAgC,KAAK,EAAE,KAAK,CAAC;QAErD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC3C,CAAC;IAEK,WAAW;;YACf,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;YAChC,IAAI,MAAM,YAAY,WAAI;gBAAE,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;iBACvD,IAAI,MAAM,YAAY,eAAM,CAAC,eAAe;gBAC/C,OAAO,CAAC,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC;;gBACzC,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACzC,CAAC;KAAA;;AApCH,4BAqCC;;AAhCwB,eAAM,GAAG,KAAK,AAAR,CAAS"}
@@ -1,2 +1,7 @@
1
- export declare class EthereumTransact {
1
+ import { Transact, TransactOptions } from '../../type';
2
+ import { EthereumOptions } from './index';
3
+ export declare class EthereumTransact implements Transact<EthereumOptions> {
4
+ readonly options: EthereumOptions;
5
+ constructor(options?: EthereumOptions);
6
+ transfer(method?: string, options?: TransactOptions): Promise<bigint>;
2
7
  }
@@ -1,7 +1,26 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.EthereumTransact = void 0;
13
+ const tool_1 = require("../../tool");
4
14
  class EthereumTransact {
15
+ constructor(options = (0, tool_1.ethereumOptions)()) {
16
+ this.options = options;
17
+ (0, tool_1.initEth)(options);
18
+ }
19
+ transfer(method, options) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ throw new Error('Method not implemented.');
22
+ });
23
+ }
5
24
  }
6
25
  exports.EthereumTransact = EthereumTransact;
7
26
  //# sourceMappingURL=transact.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transact.js","sourceRoot":"","sources":["../../../src/libs/eth/transact.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAgB;CAAG;AAAhC,4CAAgC"}
1
+ {"version":3,"file":"transact.js","sourceRoot":"","sources":["../../../src/libs/eth/transact.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qCAAsD;AAGtD,MAAa,gBAAgB;IAC3B,YAAqB,UAA2B,IAAA,sBAAe,GAAE;QAA5C,YAAO,GAAP,OAAO,CAAqC;QAC/D,IAAA,cAAO,EAAC,OAAO,CAAC,CAAC;IACnB,CAAC;IAEK,QAAQ,CAAC,MAAe,EAAE,OAAyB;;YACvD,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;KAAA;CACF;AARD,4CAQC"}
@@ -1 +1,2 @@
1
1
  export * from './eth';
2
+ export * from './trx';
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./eth"), exports);
18
+ __exportStar(require("./trx"), exports);
18
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/libs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/libs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,wCAAsB"}
@@ -0,0 +1,9 @@
1
+ import { TronixOptions } from './index';
2
+ import { Account } from '../../type';
3
+ export declare class TronixAccount implements Account<TronixOptions> {
4
+ readonly options: TronixOptions;
5
+ constructor(options?: TronixOptions);
6
+ getBalance(address?: string | undefined): Promise<bigint | number>;
7
+ create(options?: import("../../type").CommonOptions): TronixAccount;
8
+ static create(options?: import("../../type").CommonOptions): TronixAccount;
9
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.TronixAccount = void 0;
16
+ const tronweb_1 = require("tronweb");
17
+ const node_assert_1 = __importDefault(require("node:assert"));
18
+ const tool_1 = require("../../tool");
19
+ class TronixAccount {
20
+ constructor(options = (0, tool_1.tronixOptions)()) {
21
+ this.options = options;
22
+ (0, tool_1.initTrx)(options);
23
+ }
24
+ getBalance() {
25
+ return __awaiter(this, arguments, void 0, function* (address = this.options.address) {
26
+ (0, node_assert_1.default)(address, 'address is required');
27
+ const { client } = this.options;
28
+ if (client)
29
+ return client.trx.getBalance(address);
30
+ else
31
+ throw new Error('unknown client');
32
+ });
33
+ }
34
+ create(options = (0, tool_1.commonOptions)('TRX')) {
35
+ return TronixAccount.create(options);
36
+ }
37
+ static create(options = (0, tool_1.commonOptions)('TRX')) {
38
+ var _a;
39
+ const wallet = tronweb_1.TronWeb.createRandom();
40
+ const account = {
41
+ address: wallet.address,
42
+ private: wallet.privateKey,
43
+ phrases: (_a = wallet.mnemonic) === null || _a === void 0 ? void 0 : _a.phrase.split(/ /),
44
+ };
45
+ const { address } = account;
46
+ const { console, emitter } = options;
47
+ if (emitter)
48
+ emitter.emit((0, tool_1.bt)('TRX', 'account.create'), account);
49
+ if (console)
50
+ console((0, tool_1.info)(`an account created with the ${address} address`));
51
+ return new TronixAccount(Object.assign(Object.assign({}, options), account));
52
+ }
53
+ }
54
+ exports.TronixAccount = TronixAccount;
55
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../../src/libs/trx/account.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,qCAAkC;AAClC,8DAAiC;AAIjC,qCAA6E;AAE7E,MAAa,aAAa;IACxB,YAAqB,UAAyB,IAAA,oBAAa,GAAE;QAAxC,YAAO,GAAP,OAAO,CAAiC;QAC3D,IAAA,cAAO,EAAC,OAAO,CAAC,CAAC;IACnB,CAAC;IAEK,UAAU;6DAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO;YAC7C,IAAA,qBAAM,EAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC;YAEvC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;YAChC,IAAI,MAAM;gBAAE,OAAO,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;;gBAC7C,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACzC,CAAC;KAAA;IAED,MAAM,CAAC,OAAO,GAAG,IAAA,oBAAa,EAAC,KAAK,CAAC;QACnC,OAAO,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,OAAO,GAAG,IAAA,oBAAa,EAAC,KAAK,CAAC;;QAC1C,MAAM,MAAM,GAAG,iBAAO,CAAC,YAAY,EAAE,CAAC;QACtC,MAAM,OAAO,GAAmB;YAC9B,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,UAAU;YAC1B,OAAO,EAAE,MAAA,MAAM,CAAC,QAAQ,0CAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;SAC5C,CAAC;QAEF,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAC5B,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QACrC,IAAI,OAAO;YAAE,OAAO,CAAC,IAAI,CAAC,IAAA,SAAE,EAAC,KAAK,EAAE,gBAAgB,CAAC,EAAE,OAAO,CAAC,CAAC;QAChE,IAAI,OAAO;YAAE,OAAO,CAAC,IAAA,WAAI,EAAC,+BAA+B,OAAO,UAAU,CAAC,CAAC,CAAC;QAE7E,OAAO,IAAI,aAAa,iCAAM,OAAO,GAAK,OAAO,EAAG,CAAC;IACvD,CAAC;CACF;AAhCD,sCAgCC"}
@@ -0,0 +1,7 @@
1
+ import { TronixOptions } from './index';
2
+ import { Contract, ContractOptions } from '../../type';
3
+ export declare class TronixContract implements Contract<TronixOptions> {
4
+ readonly options: TronixOptions;
5
+ constructor(options?: TronixOptions);
6
+ estimateGas(method?: string, options?: ContractOptions): Promise<bigint>;
7
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-unused-vars */
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.TronixContract = void 0;
14
+ const tool_1 = require("../../tool");
15
+ class TronixContract {
16
+ constructor(options = (0, tool_1.tronixOptions)()) {
17
+ this.options = options;
18
+ (0, tool_1.initTrx)(options);
19
+ }
20
+ estimateGas() {
21
+ return __awaiter(this, arguments, void 0, function* (method = 'transfer', options = this.options) {
22
+ throw new Error('unknown client');
23
+ });
24
+ }
25
+ }
26
+ exports.TronixContract = TronixContract;
27
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../src/libs/trx/contract.ts"],"names":[],"mappings":";AAAA,sDAAsD;;;;;;;;;;;;AAGtD,qCAAoD;AAGpD,MAAa,cAAc;IACzB,YAAqB,UAAyB,IAAA,oBAAa,GAAE;QAAxC,YAAO,GAAP,OAAO,CAAiC;QAC3D,IAAA,cAAO,EAAC,OAAO,CAAC,CAAC;IACnB,CAAC;IAEK,WAAW;6DACf,SAAiB,UAAU,EAC3B,UAA2B,IAAI,CAAC,OAAO;YAEvC,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACpC,CAAC;KAAA;CACF;AAXD,wCAWC"}
@@ -0,0 +1,22 @@
1
+ import { TronWeb } from 'tronweb';
2
+ import { TronixAccount } from './account';
3
+ import { TronixContract } from './contract';
4
+ import { TronixTransact } from './transact';
5
+ import { Crypto, CryptoOptions } from '../../type';
6
+ export { TronixAccount } from './account';
7
+ export { TronixContract } from './contract';
8
+ export { TronixTransact } from './transact';
9
+ export interface TronixOptions extends CryptoOptions {
10
+ client?: TronWeb;
11
+ }
12
+ export declare class Tronix implements Crypto<TronixOptions> {
13
+ #private;
14
+ readonly options: TronixOptions;
15
+ static readonly symbol = "TRX";
16
+ constructor(options?: TronixOptions);
17
+ get account(): TronixAccount;
18
+ get contract(): TronixContract;
19
+ get transact(): TronixTransact;
20
+ createAccount(options?: import("../../type").CommonOptions): TronixAccount;
21
+ getGasPrice(): Promise<bigint | null>;
22
+ }
@@ -19,38 +19,46 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
19
19
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
20
20
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
21
21
  };
22
- var _Ethereum_account;
22
+ var _Tronix_account, _Tronix_contract, _Tronix_transact;
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.Ethereum = void 0;
25
- const ethers_1 = require("ethers");
26
- const web3_1 = require("web3");
24
+ exports.Tronix = exports.TronixTransact = exports.TronixContract = exports.TronixAccount = void 0;
27
25
  const account_1 = require("./account");
26
+ const contract_1 = require("./contract");
27
+ const transact_1 = require("./transact");
28
28
  const tool_1 = require("../../tool");
29
- class Ethereum {
30
- constructor(options = (0, tool_1.defaultEthereumOptions)()) {
29
+ var account_2 = require("./account");
30
+ Object.defineProperty(exports, "TronixAccount", { enumerable: true, get: function () { return account_2.TronixAccount; } });
31
+ var contract_2 = require("./contract");
32
+ Object.defineProperty(exports, "TronixContract", { enumerable: true, get: function () { return contract_2.TronixContract; } });
33
+ var transact_2 = require("./transact");
34
+ Object.defineProperty(exports, "TronixTransact", { enumerable: true, get: function () { return transact_2.TronixTransact; } });
35
+ class Tronix {
36
+ constructor(options = (0, tool_1.tronixOptions)()) {
31
37
  this.options = options;
32
- _Ethereum_account.set(this, void 0);
33
- (0, tool_1.initEth)(options);
38
+ _Tronix_account.set(this, void 0);
39
+ _Tronix_contract.set(this, void 0);
40
+ _Tronix_transact.set(this, void 0);
41
+ (0, tool_1.initTrx)(options);
34
42
  }
35
43
  get account() {
36
- return (__classPrivateFieldSet(this, _Ethereum_account, __classPrivateFieldGet(this, _Ethereum_account, "f") || new account_1.EthereumAccount(this.options), "f"));
44
+ return (__classPrivateFieldSet(this, _Tronix_account, __classPrivateFieldGet(this, _Tronix_account, "f") || new account_1.TronixAccount(this.options), "f"));
37
45
  }
38
- createAccount(CommonOptions = (0, tool_1.defaultCommonOptions)('ETH')) {
39
- return this.account.create(CommonOptions);
46
+ get contract() {
47
+ return (__classPrivateFieldSet(this, _Tronix_contract, __classPrivateFieldGet(this, _Tronix_contract, "f") || new contract_1.TronixContract(this.options), "f"));
48
+ }
49
+ get transact() {
50
+ return (__classPrivateFieldSet(this, _Tronix_transact, __classPrivateFieldGet(this, _Tronix_transact, "f") || new transact_1.TronixTransact(this.options), "f"));
51
+ }
52
+ createAccount(options = (0, tool_1.commonOptions)('TRX')) {
53
+ return this.account.create(options);
40
54
  }
41
55
  getGasPrice() {
42
56
  return __awaiter(this, void 0, void 0, function* () {
43
- const { client } = this.options;
44
- if (client instanceof web3_1.Web3)
45
- return client.eth.getGasPrice();
46
- else if (client instanceof ethers_1.ethers.JsonRpcProvider)
47
- return (yield client.getFeeData()).gasPrice;
48
- else
49
- throw new Error('unknown client');
57
+ throw new Error('unknown client');
50
58
  });
51
59
  }
52
60
  }
53
- exports.Ethereum = Ethereum;
54
- _Ethereum_account = new WeakMap();
55
- Ethereum.symbol = 'ETH';
56
- //# sourceMappingURL=_eth.js.map
61
+ exports.Tronix = Tronix;
62
+ _Tronix_account = new WeakMap(), _Tronix_contract = new WeakMap(), _Tronix_transact = new WeakMap();
63
+ Tronix.symbol = 'TRX';
64
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/libs/trx/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAEA,uCAA0C;AAC1C,yCAA4C;AAC5C,yCAA4C;AAE5C,qCAAmE;AAEnE,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AAMvB,MAAa,MAAM;IAOjB,YAAqB,UAAyB,IAAA,oBAAa,GAAE;QAAxC,YAAO,GAAP,OAAO,CAAiC;QAN7D,kCAAyB;QACzB,mCAA2B;QAC3B,mCAA2B;QAKzB,IAAA,cAAO,EAAC,OAAO,CAAC,CAAC;IACnB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,CAAC,uBAAA,IAAI,mBAAY,uBAAA,IAAI,uBAAS,IAAI,IAAI,uBAAa,CAAC,IAAI,CAAC,OAAO,CAAC,MAAA,CAAC,CAAC;IAC5E,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,CAAC,uBAAA,IAAI,oBAAa,uBAAA,IAAI,wBAAU,IAAI,IAAI,yBAAc,CAAC,IAAI,CAAC,OAAO,CAAC,MAAA,CAAC,CAAC;IAC/E,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,CAAC,uBAAA,IAAI,oBAAa,uBAAA,IAAI,wBAAU,IAAI,IAAI,yBAAc,CAAC,IAAI,CAAC,OAAO,CAAC,MAAA,CAAC,CAAC;IAC/E,CAAC;IAED,aAAa,CAAC,OAAO,GAAG,IAAA,oBAAa,EAAC,KAAK,CAAC;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAEK,WAAW;;YACf,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACpC,CAAC;KAAA;;AA7BH,wBA8BC;;AAzBwB,aAAM,GAAG,KAAK,AAAR,CAAS"}
@@ -0,0 +1,7 @@
1
+ import { Transact, TransactOptions } from '../../type';
2
+ import { TronixOptions } from './index';
3
+ export declare class TronixTransact implements Transact<TronixOptions> {
4
+ readonly options: TronixOptions;
5
+ constructor(options?: TronixOptions);
6
+ transfer(method?: string, options?: TransactOptions): Promise<bigint>;
7
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.TronixTransact = void 0;
13
+ const tool_1 = require("../../tool");
14
+ class TronixTransact {
15
+ constructor(options = (0, tool_1.tronixOptions)()) {
16
+ this.options = options;
17
+ (0, tool_1.initTrx)(options);
18
+ }
19
+ transfer(method, options) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ throw new Error('Method not implemented.');
22
+ });
23
+ }
24
+ }
25
+ exports.TronixTransact = TronixTransact;
26
+ //# sourceMappingURL=transact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transact.js","sourceRoot":"","sources":["../../../src/libs/trx/transact.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qCAAoD;AAGpD,MAAa,cAAc;IACzB,YAAqB,UAAyB,IAAA,oBAAa,GAAE;QAAxC,YAAO,GAAP,OAAO,CAAiC;QAC3D,IAAA,cAAO,EAAC,OAAO,CAAC,CAAC;IACnB,CAAC;IAEK,QAAQ,CAAC,MAAe,EAAE,OAAyB;;YACvD,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;KAAA;CACF;AARD,wCAQC"}
@@ -1,3 +1,3 @@
1
1
  import { EthereumOptions } from '../libs';
2
- export declare const defaultEthereumOptions: (env?: string) => EthereumOptions;
2
+ export declare const ethereumOptions: (env?: string) => EthereumOptions;
3
3
  export declare const initEth: (options?: EthereumOptions) => void;
@@ -3,20 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.initEth = exports.defaultEthereumOptions = void 0;
6
+ exports.initEth = exports.ethereumOptions = void 0;
7
7
  const node_assert_1 = __importDefault(require("node:assert"));
8
8
  const ethers_1 = require("ethers");
9
9
  const web3_1 = require("web3");
10
10
  const common_1 = require("./common");
11
11
  const logging_1 = require("./logging");
12
12
  const options_1 = require("./options");
13
- const defaultEthereumOptions = (env) => (0, options_1.defaultCryptoOptions)('ETH', env);
14
- exports.defaultEthereumOptions = defaultEthereumOptions;
15
- const initEth = (options = (0, exports.defaultEthereumOptions)()) => {
13
+ const ethereumOptions = (env) => (Object.assign({ lib: (0, common_1.bp)('ETH', 'LIB', env) }, (0, options_1.cryptoOptions)('ETH', env)));
14
+ exports.ethereumOptions = ethereumOptions;
15
+ const initEth = (options = (0, exports.ethereumOptions)()) => {
16
16
  const { client, url, lib } = options;
17
17
  if (!client) {
18
18
  (0, node_assert_1.default)(url, 'client or url option is required');
19
- options.lib = lib || (0, common_1.bp)('ETH', 'LIB') || 'ethers';
19
+ options.lib = lib || (0, common_1.bp)('ETH', 'LIB', options.env) || 'ethers';
20
20
  if (lib === 'web3')
21
21
  options.client = new web3_1.Web3(url);
22
22
  else if (lib === 'ethers')
@@ -1 +1 @@
1
- {"version":3,"file":"eth-tools.js","sourceRoot":"","sources":["../../src/tool/eth-tools.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAiC;AACjC,mCAAgC;AAChC,+BAA4B;AAE5B,qCAA8B;AAC9B,uCAAiC;AAEjC,uCAAiD;AAE1C,MAAM,sBAAsB,GAAG,CAAC,GAAY,EAAmB,EAAE,CACtE,IAAA,8BAAoB,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AADtB,QAAA,sBAAsB,0BACA;AAE5B,MAAM,OAAO,GAAG,CAAC,UAA2B,IAAA,8BAAsB,GAAE,EAAE,EAAE;IAC7E,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACrC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,IAAA,qBAAM,EAAC,GAAG,EAAE,kCAAkC,CAAC,CAAC;QAChD,OAAO,CAAC,GAAG,GAAG,GAAG,IAAI,IAAA,WAAE,EAAC,KAAK,EAAE,KAAK,CAAC,IAAI,QAAQ,CAAC;QAElD,IAAI,GAAG,KAAK,MAAM;YAAE,OAAO,CAAC,MAAM,GAAG,IAAI,WAAI,CAAC,GAAG,CAAC,CAAC;aAC9C,IAAI,GAAG,KAAK,QAAQ;YAAE,OAAO,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;aACvE,CAAC;YACJ,OAAO,CAAC,MAAM,GAAG,IAAI,WAAI,CAAC,GAAG,CAAC,CAAC;YAE/B,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;YAC5B,IAAI,OAAO;gBAAE,OAAO,CAAC,IAAA,cAAI,EAAC,mCAAmC,CAAC,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAfW,QAAA,OAAO,WAelB"}
1
+ {"version":3,"file":"eth-tools.js","sourceRoot":"","sources":["../../src/tool/eth-tools.ts"],"names":[],"m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from './eth-tools';
5
+ export * from './trx-tools';
@@ -18,4 +18,5 @@ __exportStar(require("./common"), exports);
18
18
  __exportStar(require("./logging"), exports);
19
19
  __exportStar(require("./options"), exports);
20
20
  __exportStar(require("./eth-tools"), exports);
21
+ __exportStar(require("./trx-tools"), exports);
21
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tool/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,4CAA0B;AAE1B,8CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tool/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,4CAA0B;AAE1B,8CAA4B;AAC5B,8CAA4B"}
@@ -1,4 +1,6 @@
1
- import { AccountOptions, CommonOptions, CryptoOptions, Net } from '../type';
2
- export declare const defaultCommonOptions: (net: Net, env?: string) => CommonOptions;
3
- export declare const defaultAccountOptions: (net: Net, env?: string) => AccountOptions;
4
- export declare const defaultCryptoOptions: (net: Net, env?: string) => CryptoOptions;
1
+ import { Net, CryptoOptions, CommonOptions, AccountOptions, ContractOptions } from '../type';
2
+ export declare const commonOptions: (net: Net, env?: string) => CommonOptions;
3
+ export declare const accountOptions: (net: Net, env?: string) => AccountOptions;
4
+ export declare const contractOptions: (net: Net, env?: string) => ContractOptions;
5
+ export declare const transactOptions: (net: Net, env?: string) => ContractOptions;
6
+ export declare const cryptoOptions: (net: Net, env?: string) => CryptoOptions;
@@ -3,28 +3,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.defaultCryptoOptions = exports.defaultAccountOptions = exports.defaultCommonOptions = void 0;
6
+ exports.cryptoOptions = exports.transactOptions = exports.contractOptions = exports.accountOptions = exports.commonOptions = void 0;
7
7
  const node_events_1 = __importDefault(require("node:events"));
8
8
  const common_1 = require("./common");
9
9
  const logging_1 = require("./logging");
10
- const defaultCommonOptions = (net, env) => {
11
- return {
10
+ const commonOptions = (net, env) => {
11
+ var _a;
12
+ return ({
12
13
  url: (0, common_1.bp)(net, 'URL', env),
13
14
  emitter: new node_events_1.default(),
14
15
  console: (0, logging_1.logger)(net.toLowerCase()),
15
- };
16
+ env: (_a = process.env.CRYPTO_AIO_ENV) === null || _a === void 0 ? void 0 : _a.toLowerCase(),
17
+ });
16
18
  };
17
- exports.defaultCommonOptions = defaultCommonOptions;
18
- const defaultAccountOptions = (net, env) => {
19
- return {
19
+ exports.commonOptions = commonOptions;
20
+ const accountOptions = (net, env) => {
21
+ var _a;
22
+ return ({
20
23
  address: (0, common_1.bp)(net, 'ADDRESS', env),
21
24
  private: (0, common_1.bp)(net, 'PRIVATE', env),
22
- phrases: (0, common_1.bp)(net, 'PHRASES', env).split(/,/),
23
- };
25
+ phrases: (_a = (0, common_1.bp)(net, 'PHRASES', env)) === null || _a === void 0 ? void 0 : _a.split(/,/),
26
+ });
24
27
  };
25
- exports.defaultAccountOptions = defaultAccountOptions;
26
- const defaultCryptoOptions = (net, env) => {
27
- return Object.assign(Object.assign({}, (0, exports.defaultAccountOptions)(net, env)), (0, exports.defaultCommonOptions)(net, env));
28
- };
29
- exports.defaultCryptoOptions = defaultCryptoOptions;
28
+ exports.accountOptions = accountOptions;
29
+ const contractOptions = (net, env) => ({
30
+ contract: (0, common_1.bp)(net, 'CONTRACT', env),
31
+ abi: JSON.parse((0, common_1.bp)(net, 'ABI', env) || '[]'),
32
+ });
33
+ exports.contractOptions = contractOptions;
34
+ const transactOptions = (net, env) => ({
35
+ contract: (0, common_1.bp)(net, 'CONTRACT', env),
36
+ abi: JSON.parse((0, common_1.bp)(net, 'ABI', env) || '[]'),
37
+ });
38
+ exports.transactOptions = transactOptions;
39
+ const cryptoOptions = (net, env) => (Object.assign(Object.assign(Object.assign(Object.assign({}, (0, exports.commonOptions)(net, env)), (0, exports.accountOptions)(net, env)), (0, exports.contractOptions)(net, env)), (0, exports.transactOptions)(net, env)));
40
+ exports.cryptoOptions = cryptoOptions;
30
41
  //# sourceMappingURL=options.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/tool/options.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAuC;AAEvC,qCAA8B;AAC9B,uCAAmC;AAG5B,MAAM,oBAAoB,GAAG,CAAC,GAAQ,EAAE,GAAY,EAAiB,EAAE;IAC5E,OAAO;QACL,GAAG,EAAE,IAAA,WAAE,EAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC;QACxB,OAAO,EAAE,IAAI,qBAAY,EAAE;QAC3B,OAAO,EAAE,IAAA,gBAAM,EAAC,GAAG,CAAC,WAAW,EAAE,CAAC;KACnC,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,oBAAoB,wBAM/B;AAEK,MAAM,qBAAqB,GAAG,CAAC,GAAQ,EAAE,GAAY,EAAkB,EAAE;IAC9E,OAAO;QACL,OAAO,EAAE,IAAA,WAAE,EAAC,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC;QAChC,OAAO,EAAE,IAAA,WAAE,EAAC,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC;QAChC,OAAO,EAAE,IAAA,WAAE,EAAC,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;KAC5C,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,qBAAqB,yBAMhC;AAEK,MAAM,oBAAoB,GAAG,CAAC,GAAQ,EAAE,GAAY,EAAiB,EAAE;IAC5E,uCAAY,IAAA,6BAAqB,EAAC,GAAG,EAAE,GAAG,CAAC,GAAK,IAAA,4BAAoB,EAAC,GAAG,EAAE,GAAG,CAAC,EAAG;AACnF,CAAC,CAAC;AAFW,QAAA,oBAAoB,wBAE/B"}
1
+ {"version":3,"file":"options.js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,GAAY,EAAmB,EAAE,CAAC,CAAC;IAC3E,QAAQ,EAAE,IAAA,WAAE,EAAC,GAAG,EAAE,UAAU,EAAE,GAAG,CAAC;IAClC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAA,WAAE,EAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC;CAC7C,CAAC,CAAC;AAHU,QAAA,eAAe,mBAGzB;AAEI,MAAM,aAAa,GAAG,CAAC,GAAQ,EAAE,GAAY,EAAiB,EAAE,CAAC,6DACnE,IAAA,qBAAa,EAAC,GAAG,EAAE,GAAG,CAAC,GACvB,IAAA,sBAAc,EAAC,GAAG,EAAE,GAAG,CAAC,GACxB,IAAA,uBAAe,EAAC,GAAG,EAAE,GAAG,CAAC,GACzB,IAAA,uBAAe,EAAC,GAAG,EAAE,GAAG,CAAC,EAC5B,CAAC;AALU,QAAA,aAAa,iBAKvB"}
@@ -0,0 +1,3 @@
1
+ import { TronixOptions } from '../libs';
2
+ export declare const tronixOptions: (env?: string) => TronixOptions;
3
+ export declare const initTrx: (options?: TronixOptions) => void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.initTrx = exports.tronixOptions = void 0;
7
+ const tronweb_1 = require("tronweb");
8
+ const node_assert_1 = __importDefault(require("node:assert"));
9
+ const options_1 = require("./options");
10
+ const tronixOptions = (env) => (Object.assign({}, (0, options_1.cryptoOptions)('TRX', env)));
11
+ exports.tronixOptions = tronixOptions;
12
+ const initTrx = (options = (0, exports.tronixOptions)()) => {
13
+ const { client, url } = options;
14
+ if (!client) {
15
+ (0, node_assert_1.default)(url, 'client or url option is required');
16
+ options.client = new tronweb_1.TronWeb({ fullHost: url });
17
+ }
18
+ };
19
+ exports.initTrx = initTrx;
20
+ //# sourceMappingURL=trx-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trx-tools.js","sourceRoot":"","sources":["../../src/tool/trx-tools.ts"],"names":[],"mappings":";;;;;;AAAA,qCAAkC;AAClC,8DAAiC;AAGjC,uCAA0C;AAEnC,MAAM,aAAa,GAAG,CAAC,GAAY,EAAiB,EAAE,CAAC,mBACzD,IAAA,uBAAa,EAAC,KAAK,EAAE,GAAG,CAAC,EAC5B,CAAC;AAFU,QAAA,aAAa,iBAEvB;AAEI,MAAM,OAAO,GAAG,CAAC,UAAyB,IAAA,qBAAa,GAAE,EAAE,EAAE;IAClE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IAChC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,IAAA,qBAAM,EAAC,GAAG,EAAE,kCAAkC,CAAC,CAAC;QAChD,OAAO,CAAC,MAAM,GAAG,IAAI,iBAAO,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC;IAClD,CAAC;AACH,CAAC,CAAC;AANW,QAAA,OAAO,WAMlB"}
@@ -5,5 +5,5 @@ export type AccountOptions = {
5
5
  };
6
6
  export interface Account<Options extends AccountOptions> {
7
7
  readonly options: Options;
8
- getBalance(address?: string): Promise<bigint>;
8
+ getBalance(address?: string): Promise<bigint | number>;
9
9
  }
@@ -1,15 +1,18 @@
1
1
  /// <reference types="node" />
2
2
  import EventEmitter from 'node:events';
3
3
  import { logger } from '../tool';
4
- import { Ethereum } from '../libs';
5
- export type Net = typeof Ethereum.symbol;
4
+ import { Ethereum, Tronix } from '../libs';
5
+ export type Net = typeof Ethereum.symbol | typeof Tronix.symbol;
6
6
  export type EmitterOptions = {
7
7
  emitter?: EventEmitter;
8
8
  };
9
9
  export type LoggerOptions = {
10
10
  console?: ReturnType<typeof logger>;
11
11
  };
12
+ export type EnvOptions = {
13
+ env?: string;
14
+ };
12
15
  export type ProviderOptions = {
13
16
  url?: string;
14
17
  };
15
- export type CommonOptions = ProviderOptions & EmitterOptions & LoggerOptions;
18
+ export type CommonOptions = EnvOptions & ProviderOptions & EmitterOptions & LoggerOptions;
@@ -0,0 +1,10 @@
1
+ import { InterfaceAbi } from 'ethers';
2
+ import { ContractAbi } from 'web3';
3
+ export type ContractOptions = {
4
+ contract?: string;
5
+ abi?: ContractAbi | InterfaceAbi;
6
+ };
7
+ export interface Contract<Options extends ContractOptions> {
8
+ readonly options: Options;
9
+ estimateGas(method?: string, options?: ContractOptions): Promise<bigint>;
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/type/contract.ts"],"names":[],"mappings":""}
@@ -1,3 +1,5 @@
1
1
  export * from './common';
2
2
  export * from './account';
3
+ export * from './contract';
4
+ export * from './transact';
3
5
  export * from './lib-types';
@@ -16,5 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./common"), exports);
18
18
  __exportStar(require("./account"), exports);
19
+ __exportStar(require("./contract"), exports);
20
+ __exportStar(require("./transact"), exports);
19
21
  __exportStar(require("./lib-types"), exports);
20
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/type/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,8CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/type/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,6CAA2B;AAC3B,6CAA2B;AAC3B,8CAA4B"}
@@ -1,6 +1,8 @@
1
- import { AccountOptions } from './account';
2
1
  import { CommonOptions } from './common';
3
- export type CryptoOptions = CommonOptions & AccountOptions;
2
+ import { AccountOptions } from './account';
3
+ import { ContractOptions } from './contract';
4
+ import { TransactOptions } from './transact';
5
+ export type CryptoOptions = CommonOptions & AccountOptions & ContractOptions & TransactOptions;
4
6
  export interface Crypto<Options extends CryptoOptions> {
5
7
  readonly options: Options;
6
8
  getGasPrice(): Promise<bigint | null>;
@@ -0,0 +1,7 @@
1
+ export type TransactOptions = {
2
+ method?: string;
3
+ };
4
+ export interface Transact<Options extends TransactOptions> {
5
+ readonly options: Options;
6
+ transfer(method?: string, options?: TransactOptions): Promise<bigint>;
7
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=transact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transact.js","sourceRoot":"","sources":["../../src/type/transact.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crypto-aio",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "All-In-One Crypto-Currency for Backend",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -34,9 +34,10 @@
34
34
  ],
35
35
  "homepage": "https://github.com/vhidvz/crypto-aio#readme",
36
36
  "dependencies": {
37
- "debug": "^4.3.4",
38
- "ethers": "^6.12.1",
39
- "web3": "^4.8.0"
37
+ "debug": "^4.3.7",
38
+ "ethers": "^6.13.4",
39
+ "tronweb": "^6.0.0",
40
+ "web3": "^4.14.0"
40
41
  },
41
42
  "devDependencies": {
42
43
  "@types/debug": "^4.1.12",
@@ -1,17 +0,0 @@
1
- import { ethers } from 'ethers';
2
- import { Web3 } from 'web3';
3
- import { EthereumAccount } from './account';
4
- import { Crypto, CryptoOptions } from '../../type';
5
- export interface EthereumOptions extends CryptoOptions {
6
- lib?: 'web3' | 'ethers';
7
- client?: Web3 | ethers.Provider;
8
- }
9
- export declare class Ethereum implements Crypto<EthereumOptions> {
10
- #private;
11
- readonly options: EthereumOptions;
12
- static readonly symbol = "ETH";
13
- constructor(options?: EthereumOptions);
14
- get account(): EthereumAccount;
15
- createAccount(CommonOptions?: import("../../type").CommonOptions): EthereumAccount;
16
- getGasPrice(): Promise<bigint | null>;
17
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"_eth.js","sourceRoot":"","sources":["../../../src/libs/eth/_eth.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAgC;AAChC,+BAA4B;AAE5B,uCAA4C;AAE5C,qCAAmF;AAOnF,MAAa,QAAQ;IAKnB,YAAqB,UAA2B,IAAA,6BAAsB,GAAE;QAAnD,YAAO,GAAP,OAAO,CAA4C;QAJxE,oCAA2B;QAKzB,IAAA,cAAO,EAAC,OAAO,CAAC,CAAC;IACnB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,CAAC,uBAAA,IAAI,qBAAY,uBAAA,IAAI,yBAAS,IAAI,IAAI,yBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,MAAA,CAAC,CAAC;IAC9E,CAAC;IAED,aAAa,CAAC,aAAa,GAAG,IAAA,2BAAoB,EAAC,KAAK,CAAC;QACvD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAC5C,CAAC;IAEK,WAAW;;YACf,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;YAChC,IAAI,MAAM,YAAY,WAAI;gBAAE,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;iBACvD,IAAI,MAAM,YAAY,eAAM,CAAC,eAAe;gBAC/C,OAAO,CAAC,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC;;gBACzC,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACzC,CAAC;KAAA;;AAvBH,4BAwBC;;AArBwB,eAAM,GAAG,KAAK,AAAR,CAAS"}