crypto-aio 0.0.2 → 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 (46) hide show
  1. package/dist/libs/eth/contract.d.ts +6 -1
  2. package/dist/libs/eth/contract.js +35 -0
  3. package/dist/libs/eth/contract.js.map +1 -1
  4. package/dist/libs/eth/index.d.ts +4 -0
  5. package/dist/libs/eth/index.js +16 -6
  6. package/dist/libs/eth/index.js.map +1 -1
  7. package/dist/libs/eth/transact.d.ts +6 -1
  8. package/dist/libs/eth/transact.js +19 -0
  9. package/dist/libs/eth/transact.js.map +1 -1
  10. package/dist/libs/index.d.ts +1 -0
  11. package/dist/libs/index.js +1 -0
  12. package/dist/libs/index.js.map +1 -1
  13. package/dist/libs/trx/account.d.ts +9 -0
  14. package/dist/libs/trx/account.js +55 -0
  15. package/dist/libs/trx/account.js.map +1 -0
  16. package/dist/libs/trx/contract.d.ts +7 -0
  17. package/dist/libs/trx/contract.js +27 -0
  18. package/dist/libs/trx/contract.js.map +1 -0
  19. package/dist/libs/trx/index.d.ts +22 -0
  20. package/dist/libs/trx/index.js +64 -0
  21. package/dist/libs/trx/index.js.map +1 -0
  22. package/dist/libs/trx/transact.d.ts +7 -0
  23. package/dist/libs/trx/transact.js +26 -0
  24. package/dist/libs/trx/transact.js.map +1 -0
  25. package/dist/tool/index.d.ts +1 -0
  26. package/dist/tool/index.js +1 -0
  27. package/dist/tool/index.js.map +1 -1
  28. package/dist/tool/options.d.ts +3 -1
  29. package/dist/tool/options.js +20 -7
  30. package/dist/tool/options.js.map +1 -1
  31. package/dist/tool/trx-tools.d.ts +3 -0
  32. package/dist/tool/trx-tools.js +20 -0
  33. package/dist/tool/trx-tools.js.map +1 -0
  34. package/dist/type/account.d.ts +1 -1
  35. package/dist/type/common.d.ts +2 -2
  36. package/dist/type/contract.d.ts +10 -0
  37. package/dist/type/contract.js +3 -0
  38. package/dist/type/contract.js.map +1 -0
  39. package/dist/type/index.d.ts +2 -0
  40. package/dist/type/index.js +2 -0
  41. package/dist/type/index.js.map +1 -1
  42. package/dist/type/lib-types.d.ts +4 -2
  43. package/dist/type/transact.d.ts +7 -0
  44. package/dist/type/transact.js +3 -0
  45. package/dist/type/transact.js.map +1 -0
  46. package/package.json +5 -4
@@ -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,6 +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;
18
22
  createAccount(options?: import("../../type").CommonOptions, lib?: "web3" | "ethers" | undefined): EthereumAccount;
19
23
  getGasPrice(): Promise<bigint | null>;
20
24
  }
@@ -19,28 +19,38 @@ 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
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
+ }
44
54
  createAccount(options = (0, tool_1.commonOptions)('ETH'), lib = (0, tool_1.bp)('ETH', 'LIB')) {
45
55
  return this.account.create(options, lib);
46
56
  }
@@ -57,6 +67,6 @@ class Ethereum {
57
67
  }
58
68
  }
59
69
  exports.Ethereum = Ethereum;
60
- _Ethereum_account = new WeakMap();
70
+ _Ethereum_account = new WeakMap(), _Ethereum_contract = new WeakMap(), _Ethereum_transact = new WeakMap();
61
71
  Ethere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K,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
+ }
@@ -0,0 +1,64 @@
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 __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
17
+ if (kind === "m") throw new TypeError("Private method is not writable");
18
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
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
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
21
+ };
22
+ var _Tronix_account, _Tronix_contract, _Tronix_transact;
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.Tronix = exports.TronixTransact = exports.TronixContract = exports.TronixAccount = void 0;
25
+ const account_1 = require("./account");
26
+ const contract_1 = require("./contract");
27
+ const transact_1 = require("./transact");
28
+ const tool_1 = require("../../tool");
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)()) {
37
+ this.options = 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);
42
+ }
43
+ get account() {
44
+ return (__classPrivateFieldSet(this, _Tronix_account, __classPrivateFieldGet(this, _Tronix_account, "f") || new account_1.TronixAccount(this.options), "f"));
45
+ }
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);
54
+ }
55
+ getGasPrice() {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ throw new Error('unknown client');
58
+ });
59
+ }
60
+ }
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"}
@@ -2,3 +2,4 @@ export * from './common';
2
2
  export * from './logging';
3
3
  export * from './options';
4
4
  export * 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';
1
+ import { Net, CryptoOptions, CommonOptions, AccountOptions, ContractOptions } from '../type';
2
2
  export declare const commonOptions: (net: Net, env?: string) => CommonOptions;
3
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;
4
6
  export declare const cryptoOptions: (net: Net, env?: string) => CryptoOptions;
@@ -3,7 +3,7 @@ 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.cryptoOptions = exports.accountOptions = exports.commonOptions = 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");
@@ -17,12 +17,25 @@ const commonOptions = (net, env) => {
17
17
  });
18
18
  };
19
19
  exports.commonOptions = commonOptions;
20
- const accountOptions = (net, env) => ({
21
- address: (0, common_1.bp)(net, 'ADDRESS', env),
22
- private: (0, common_1.bp)(net, 'PRIVATE', env),
23
- phrases: (0, common_1.bp)(net, 'PHRASES', env).split(/,/),
24
- });
20
+ const accountOptions = (net, env) => {
21
+ var _a;
22
+ return ({
23
+ address: (0, common_1.bp)(net, 'ADDRESS', env),
24
+ private: (0, common_1.bp)(net, 'PRIVATE', env),
25
+ phrases: (_a = (0, common_1.bp)(net, 'PHRASES', env)) === null || _a === void 0 ? void 0 : _a.split(/,/),
26
+ });
27
+ };
25
28
  exports.accountOptions = accountOptions;
26
- const cryptoOptions = (net, env) => (Object.assign(Object.assign({}, (0, exports.commonOptions)(net, env)), (0, exports.accountOptions)(net, env)));
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)));
27
40
  exports.cryptoOptions = cryptoOptions;
28
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,aAAa,GAAG,CAAC,GAAQ,EAAE,GAAY,EAAiB,EAAE;;IAAC,OAAA,CAAC;QACvE,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;QAClC,GAAG,EAAE,MAAA,OAAO,CAAC,GAAG,CAAC,cAAc,0CAAE,WAAW,EAAE;KAC/C,CAAC,CAAA;CAAA,CAAC;AALU,QAAA,aAAa,iBAKvB;AAEI,MAAM,cAA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ptions;
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,8 +1,8 @@
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
  };
@@ -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.2",
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",