crypto-aio 0.0.1

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 (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +23 -0
  3. package/dist/index.d.ts +14 -0
  4. package/dist/index.js +52 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/libs/eth/_eth.d.ts +17 -0
  7. package/dist/libs/eth/_eth.js +56 -0
  8. package/dist/libs/eth/_eth.js.map +1 -0
  9. package/dist/libs/eth/account.d.ts +9 -0
  10. package/dist/libs/eth/account.js +58 -0
  11. package/dist/libs/eth/account.js.map +1 -0
  12. package/dist/libs/eth/contract.d.ts +2 -0
  13. package/dist/libs/eth/contract.js +7 -0
  14. package/dist/libs/eth/contract.js.map +1 -0
  15. package/dist/libs/eth/index.d.ts +19 -0
  16. package/dist/libs/eth/index.js +59 -0
  17. package/dist/libs/eth/index.js.map +1 -0
  18. package/dist/libs/eth/transact.d.ts +2 -0
  19. package/dist/libs/eth/transact.js +7 -0
  20. package/dist/libs/eth/transact.js.map +1 -0
  21. package/dist/libs/index.d.ts +1 -0
  22. package/dist/libs/index.js +18 -0
  23. package/dist/libs/index.js.map +1 -0
  24. package/dist/tool/common.d.ts +28 -0
  25. package/dist/tool/common.js +33 -0
  26. package/dist/tool/common.js.map +1 -0
  27. package/dist/tool/eth-tools.d.ts +3 -0
  28. package/dist/tool/eth-tools.js +33 -0
  29. package/dist/tool/eth-tools.js.map +1 -0
  30. package/dist/tool/index.d.ts +4 -0
  31. package/dist/tool/index.js +21 -0
  32. package/dist/tool/index.js.map +1 -0
  33. package/dist/tool/logging.d.ts +3 -0
  34. package/dist/tool/logging.js +11 -0
  35. package/dist/tool/logging.js.map +1 -0
  36. package/dist/tool/options.d.ts +4 -0
  37. package/dist/tool/options.js +30 -0
  38. package/dist/tool/options.js.map +1 -0
  39. package/dist/type/account.d.ts +9 -0
  40. package/dist/type/account.js +3 -0
  41. package/dist/type/account.js.map +1 -0
  42. package/dist/type/common.d.ts +15 -0
  43. package/dist/type/common.js +3 -0
  44. package/dist/type/common.js.map +1 -0
  45. package/dist/type/index.d.ts +3 -0
  46. package/dist/type/index.js +20 -0
  47. package/dist/type/index.js.map +1 -0
  48. package/dist/type/lib-types.d.ts +7 -0
  49. package/dist/type/lib-types.js +3 -0
  50. package/dist/type/lib-types.js.map +1 -0
  51. package/package.json +69 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Vahid V.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # Crypto-AIO
2
+
3
+ [![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
+ [![npm](https://img.shields.io/npm/v/crypto-aio)](https://www.npmjs.com/package/crypto-aio)
5
+ ![npm](https://img.shields.io/npm/dm/crypto-aio)
6
+ [![Coverage](https://raw.githubusercontent.com/vhidvz/crypto-aio/main/docs/coverage.svg)](https://htmlpreview.github.io/?https://github.com/vhidvz/crypto-aio/blob/main/docs/coverage/lcov-report/index.html)
7
+ [![GitHub](https://img.shields.io/github/license/vhidvz/crypto-aio?style=flat)](https://github.com/vhidvz/crypto-aio/blob/master/LICENSE)
8
+ [![documentation](https://img.shields.io/badge/documentation-click_to_read-c27cf4)](https://vhidvz.github.io/crypto-aio/)
9
+
10
+ ## Quick Start
11
+
12
+ ```ts
13
+ import { CryptoAio } from 'crypto-aio';
14
+
15
+ const caio = new CryptoAio();
16
+
17
+ caio.eth.getGasPrice();
18
+
19
+ caio.eth.createAccount();
20
+ caio.eth.account.create();
21
+
22
+ caio.eth.account.getBalance();
23
+ ```
@@ -0,0 +1,14 @@
1
+ import { Ethereum, EthereumOptions } from './libs';
2
+ export * from './libs';
3
+ export * from './tool';
4
+ export * from './type';
5
+ export interface CryptoAioOptions {
6
+ [Ethereum.symbol]?: EthereumOptions;
7
+ }
8
+ export declare const cryptoAioOptions: (env?: string) => CryptoAioOptions;
9
+ export declare class CryptoAio {
10
+ #private;
11
+ readonly options: CryptoAioOptions;
12
+ constructor(options?: CryptoAioOptions);
13
+ get eth(): Ethereum;
14
+ }
package/dist/index.js ADDED
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
17
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
18
+ 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");
19
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
20
+ };
21
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
22
+ if (kind === "m") throw new TypeError("Private method is not writable");
23
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
24
+ 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");
25
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
26
+ };
27
+ var _CryptoAio_eth;
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.CryptoAio = exports.cryptoAioOptions = void 0;
30
+ const libs_1 = require("./libs");
31
+ const tool_1 = require("./tool");
32
+ __exportStar(require("./libs"), exports);
33
+ __exportStar(require("./tool"), exports);
34
+ __exportStar(require("./type"), exports);
35
+ const cryptoAioOptions = (env) => {
36
+ return {
37
+ ETH: (0, tool_1.defaultEthereumOptions)(env),
38
+ };
39
+ };
40
+ exports.cryptoAioOptions = cryptoAioOptions;
41
+ class CryptoAio {
42
+ constructor(options = (0, exports.cryptoAioOptions)()) {
43
+ this.options = options;
44
+ _CryptoAio_eth.set(this, void 0);
45
+ }
46
+ get eth() {
47
+ return (__classPrivateFieldSet(this, _CryptoAio_eth, __classPrivateFieldGet(this, _CryptoAio_eth, "f") || new libs_1.Ethereum(this.options['ETH']), "f"));
48
+ }
49
+ }
50
+ exports.CryptoAio = CryptoAio;
51
+ _CryptoAio_eth = new WeakMap();
52
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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"}
@@ -0,0 +1,17 @@
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
+ }
@@ -0,0 +1,56 @@
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 _Ethereum_account;
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.Ethereum = void 0;
25
+ const ethers_1 = require("ethers");
26
+ const web3_1 = require("web3");
27
+ const account_1 = require("./account");
28
+ const tool_1 = require("../../tool");
29
+ class Ethereum {
30
+ constructor(options = (0, tool_1.defaultEthereumOptions)()) {
31
+ this.options = options;
32
+ _Ethereum_account.set(this, void 0);
33
+ (0, tool_1.initEth)(options);
34
+ }
35
+ get account() {
36
+ return (__classPrivateFieldSet(this, _Ethereum_account, __classPrivateFieldGet(this, _Ethereum_account, "f") || new account_1.EthereumAccount(this.options), "f"));
37
+ }
38
+ createAccount(CommonOptions = (0, tool_1.defaultCommonOptions)('ETH')) {
39
+ return this.account.create(CommonOptions);
40
+ }
41
+ getGasPrice() {
42
+ 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');
50
+ });
51
+ }
52
+ }
53
+ exports.Ethereum = Ethereum;
54
+ _Ethereum_account = new WeakMap();
55
+ Ethereum.symbol = 'ETH';
56
+ //# sourceMappingURL=_eth.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,9 @@
1
+ import { EthereumOptions } from './index';
2
+ import { Account, CommonOptions } from '../../type';
3
+ export declare class EthereumAccount implements Account<EthereumOptions> {
4
+ readonly options: EthereumOptions;
5
+ constructor(options?: EthereumOptions);
6
+ getBalance(address?: string | undefined): Promise<bigint>;
7
+ create(CommonOptions?: CommonOptions): EthereumAccount;
8
+ static create(options?: CommonOptions): EthereumAccount;
9
+ }
@@ -0,0 +1,58 @@
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.EthereumAccount = 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");
20
+ class EthereumAccount {
21
+ constructor(options = (0, tool_1.defaultEthereumOptions)()) {
22
+ this.options = options;
23
+ (0, tool_1.initEth)(options);
24
+ }
25
+ getBalance() {
26
+ return __awaiter(this, arguments, void 0, function* (address = this.options.address) {
27
+ (0, node_assert_1.default)(address, 'address is required');
28
+ const { client } = this.options;
29
+ if (client instanceof web3_1.Web3)
30
+ return client.eth.getBalance(address);
31
+ else if (client instanceof ethers_1.ethers.JsonRpcProvider)
32
+ return client.getBalance(address);
33
+ else
34
+ throw new Error('unknown client');
35
+ });
36
+ }
37
+ create(CommonOptions = (0, tool_1.defaultCommonOptions)('ETH')) {
38
+ return EthereumAccount.create(CommonOptions);
39
+ }
40
+ static create(options = (0, tool_1.defaultCommonOptions)('ETH')) {
41
+ var _a;
42
+ const wallet = ethers_1.ethers.Wallet.createRandom();
43
+ const account = {
44
+ address: wallet.address,
45
+ private: wallet.privateKey,
46
+ phrases: (_a = wallet.mnemonic) === null || _a === void 0 ? void 0 : _a.phrase.split(/ /),
47
+ };
48
+ const { address } = account;
49
+ const { console, emitter } = options;
50
+ if (emitter)
51
+ emitter.emit((0, tool_1.bt)('ETH', 'account.create'), account);
52
+ if (console)
53
+ console((0, tool_1.info)(`an account created with the ${address} address`));
54
+ return new EthereumAccount(Object.assign(Object.assign({}, options), account));
55
+ }
56
+ }
57
+ exports.EthereumAccount = EthereumAccount;
58
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../../src/libs/eth/account.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,8DAAiC;AACjC,mCAAgC;AAChC,+BAA4B;AAE5B,qCAMoB;AAIpB,MAAa,eAAe;IAC1B,YAAqB,UAA2B,IAAA,6BAAsB,GAAE;QAAnD,YAAO,GAAP,OAAO,CAA4C;QACtE,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,YAAY,WAAI;gBAAE,OAAO,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;iBAC7D,IAAI,MAAM,YAAY,eAAM,CAAC,eAAe;gBAAE,OAAO,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;;gBAChF,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACzC,CAAC;KAAA;IAED,MAAM,CAAC,aAAa,GAAG,IAAA,2BAAoB,EAAC,KAAK,CAAC;QAChD,OAAO,eAAe,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,UAAyB,IAAA,2BAAoB,EAAC,KAAK,CAAC;;QAChE,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,iCAAM,OAAO,GAAK,OAAO,EAAG,CAAC;IACzD,CAAC;CACF;AAjCD,0CAiCC"}
@@ -0,0 +1,2 @@
1
+ export declare class EthereumContract {
2
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EthereumContract = void 0;
4
+ class EthereumContract {
5
+ }
6
+ exports.EthereumContract = EthereumContract;
7
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../src/libs/eth/contract.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAgB;CAAG;AAAhC,4CAAgC"}
@@ -0,0 +1,19 @@
1
+ import { ethers } from 'ethers';
2
+ import { Web3 } from 'web3';
3
+ import { EthereumAccount } from './account';
4
+ import { Crypto, CryptoOptions } from '../../type';
5
+ export { EthereumAccount } from './account';
6
+ export { EthereumContract } from './contract';
7
+ export { EthereumTransact } from './transact';
8
+ export interface EthereumOptions extends CryptoOptions {
9
+ lib?: 'web3' | 'ethers';
10
+ client?: Web3 | ethers.Provider;
11
+ }
12
+ export declare class Ethereum implements Crypto<EthereumOptions> {
13
+ #private;
14
+ readonly options: EthereumOptions;
15
+ static readonly symbol = "ETH";
16
+ constructor(options?: EthereumOptions);
17
+ get account(): EthereumAccount;
18
+ getGasPrice(): Promise<bigint | null>;
19
+ }
@@ -0,0 +1,59 @@
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 _Ethereum_account;
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.Ethereum = exports.EthereumTransact = exports.EthereumContract = exports.EthereumAccount = void 0;
25
+ const ethers_1 = require("ethers");
26
+ const web3_1 = require("web3");
27
+ const account_1 = require("./account");
28
+ const tool_1 = require("../../tool");
29
+ var account_2 = require("./account");
30
+ 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; } });
35
+ class Ethereum {
36
+ constructor(options = (0, tool_1.defaultEthereumOptions)()) {
37
+ this.options = options;
38
+ _Ethereum_account.set(this, void 0);
39
+ (0, tool_1.initEth)(options);
40
+ }
41
+ get account() {
42
+ return (__classPrivateFieldSet(this, _Ethereum_account, __classPrivateFieldGet(this, _Ethereum_account, "f") || new account_1.EthereumAccount(this.options), "f"));
43
+ }
44
+ getGasPrice() {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const { client } = this.options;
47
+ if (client instanceof web3_1.Web3)
48
+ return client.eth.getGasPrice();
49
+ else if (client instanceof ethers_1.ethers.JsonRpcProvider)
50
+ return (yield client.getFeeData()).gasPrice;
51
+ else
52
+ throw new Error('unknown client');
53
+ });
54
+ }
55
+ }
56
+ exports.Ethereum = Ethereum;
57
+ _Ethereum_account = new WeakMap();
58
+ Ethereum.symbol = 'ETH';
59
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,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;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;;AAnBH,4BAoBC;;AAjBwB,eAAM,GAAG,KAAK,AAAR,CAAS"}
@@ -0,0 +1,2 @@
1
+ export declare class EthereumTransact {
2
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EthereumTransact = void 0;
4
+ class EthereumTransact {
5
+ }
6
+ exports.EthereumTransact = EthereumTransact;
7
+ //# sourceMappingURL=transact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transact.js","sourceRoot":"","sources":["../../../src/libs/eth/transact.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAgB;CAAG;AAAhC,4CAAgC"}
@@ -0,0 +1 @@
1
+ export * from './eth';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./eth"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/libs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB"}
@@ -0,0 +1,28 @@
1
+ import { Net } from '../type';
2
+ /**
3
+ * The function an env on the provided network, postfix, and environment variables.
4
+ *
5
+ * @param {Net} net - The `net` parameter is a variable representing the network.
6
+ * @param {string} postfix - The `postfix` parameter is a string that will be appended to the base
7
+ * topic before returning the final topic string.
8
+ * @param {string | undefined} env - The `env` parameter is a string that represents the environment in
9
+ * which the topic is being generated. It is optional and defaults to the value of the `CRYPTO_AIO_ENV`
10
+ * environment variable from the process environment.
11
+ *
12
+ * @returns The function returns a string that is formatted as `CRYPTO_AIO_[${env}_]${net}_${postfix}
13
+ */
14
+ export declare const bp: <T = string>(net: Net, postfix: string, env?: string | undefined) => T;
15
+ /**
16
+ * The function generates a topic string based on the provided network, postfix, and
17
+ * optional environment variables.
18
+ *
19
+ * @param {Net} net - The `net` parameter is a variable representing the network.
20
+ * @param {string} postfix - The `postfix` parameter is a string that will be appended to the base
21
+ * topic before returning the final topic string.
22
+ * @param {string | undefined} env - The `env` parameter is a string that represents the environment in
23
+ * which the topic is being generated. It is optional and defaults to the value of the `CRYPTO_AIO_ENV`
24
+ * environment variable from the process environment.
25
+ *
26
+ * @returns The function returns a string that is formatted as `crypto-aio.[${env}.]${net}.${postfix}
27
+ */
28
+ export declare const bt: (net: Net, postfix: string, env?: string | undefined) => string;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bt = exports.bp = void 0;
4
+ /**
5
+ * The function an env on the provided network, postfix, and environment variables.
6
+ *
7
+ * @param {Net} net - The `net` parameter is a variable representing the network.
8
+ * @param {string} postfix - The `postfix` parameter is a string that will be appended to the base
9
+ * topic before returning the final topic string.
10
+ * @param {string | undefined} env - The `env` parameter is a string that represents the environment in
11
+ * which the topic is being generated. It is optional and defaults to the value of the `CRYPTO_AIO_ENV`
12
+ * environment variable from the process environment.
13
+ *
14
+ * @returns The function returns a string that is formatted as `CRYPTO_AIO_[${env}_]${net}_${postfix}
15
+ */
16
+ const bp = (net, postfix, env = process.env['CRYPTO_AIO_ENV']) => process.env[`CRYPTO_AIO_${env ? env.toUpperCase() + '_' : ''}${net}_${postfix}`];
17
+ exports.bp = bp;
18
+ /**
19
+ * The function generates a topic string based on the provided network, postfix, and
20
+ * optional environment variables.
21
+ *
22
+ * @param {Net} net - The `net` parameter is a variable representing the network.
23
+ * @param {string} postfix - The `postfix` parameter is a string that will be appended to the base
24
+ * topic before returning the final topic string.
25
+ * @param {string | undefined} env - The `env` parameter is a string that represents the environment in
26
+ * which the topic is being generated. It is optional and defaults to the value of the `CRYPTO_AIO_ENV`
27
+ * environment variable from the process environment.
28
+ *
29
+ * @returns The function returns a string that is formatted as `crypto-aio.[${env}.]${net}.${postfix}
30
+ */
31
+ const bt = (net, postfix, env = process.env['CRYPTO_AIO_ENV']) => `crypto-aio.${env ? env.toLowerCase() + '.' : ''}${net.toLowerCase()}.${postfix}`;
32
+ exports.bt = bt;
33
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/tool/common.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;GAWG;AACI,MAAM,EAAE,GAAG,CAChB,GAAQ,EACR,OAAe,EACf,MAA0B,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,EACpD,EAAE,CACL,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,IAAI,OAAO,EAAE,CAAM,CAAC;AAL3E,QAAA,EAAE,MAKyE;AAExF;;;;;;;;;;;;GAYG;AACI,MAAM,EAAE,GAAG,CAChB,GAAQ,EACR,OAAe,EACf,MAA0B,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAC/C,EAAE,CACV,cAAc,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,WAAW,EAAE,IAAI,OAAO,EAAE,CAAC;AALvE,QAAA,EAAE,MAKqE"}
@@ -0,0 +1,3 @@
1
+ import { EthereumOptions } from '../libs';
2
+ export declare const defaultEthereumOptions: (env?: string) => EthereumOptions;
3
+ export declare const initEth: (options?: EthereumOptions) => void;
@@ -0,0 +1,33 @@
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.initEth = exports.defaultEthereumOptions = void 0;
7
+ const node_assert_1 = __importDefault(require("node:assert"));
8
+ const ethers_1 = require("ethers");
9
+ const web3_1 = require("web3");
10
+ const common_1 = require("./common");
11
+ const logging_1 = require("./logging");
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)()) => {
16
+ const { client, url, lib } = options;
17
+ if (!client) {
18
+ (0, node_assert_1.default)(url, 'client or url option is required');
19
+ options.lib = lib || (0, common_1.bp)('ETH', 'LIB') || 'ethers';
20
+ if (lib === 'web3')
21
+ options.client = new web3_1.Web3(url);
22
+ else if (lib === 'ethers')
23
+ options.client = new ethers_1.ethers.JsonRpcProvider(url);
24
+ else {
25
+ options.client = new web3_1.Web3(url);
26
+ const { console } = options;
27
+ if (console)
28
+ console((0, logging_1.warn)('Unknown lib, Web3 used by default'));
29
+ }
30
+ }
31
+ };
32
+ exports.initEth = initEth;
33
+ //# sourceMappingURL=eth-tools.js.map
@@ -0,0 +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"}
@@ -0,0 +1,4 @@
1
+ export * from './common';
2
+ export * from './logging';
3
+ export * from './options';
4
+ export * from './eth-tools';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./common"), exports);
18
+ __exportStar(require("./logging"), exports);
19
+ __exportStar(require("./options"), exports);
20
+ __exportStar(require("./eth-tools"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tool/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,4CAA0B;AAE1B,8CAA4B"}
@@ -0,0 +1,3 @@
1
+ export declare const warn: (msg: string) => string;
2
+ export declare const info: (msg: string) => string;
3
+ export declare const logger: (namespace: string) => import("debug").Debugger;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logger = exports.info = exports.warn = void 0;
4
+ const debug_1 = require("debug");
5
+ const warn = (msg) => `\x1b[33m[WARN] ${msg}\x1b[0m`;
6
+ exports.warn = warn;
7
+ const info = (msg) => `\x1b[34m[INFO] ${msg}\x1b[0m`;
8
+ exports.info = info;
9
+ const logger = (namespace) => (0, debug_1.debug)('crypto-aio').extend(namespace);
10
+ exports.logger = logger;
11
+ //# sourceMappingURL=logging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../src/tool/logging.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAEvB,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,kBAAkB,GAAG,SAAS,CAAC;AAAvD,QAAA,IAAI,QAAmD;AAC7D,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,kBAAkB,GAAG,SAAS,CAAC;AAAvD,QAAA,IAAI,QAAmD;AAE7D,MAAM,MAAM,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,IAAA,aAAK,EAAC,YAAY,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAAtE,QAAA,MAAM,UAAgE"}
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,30 @@
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.defaultCryptoOptions = exports.defaultAccountOptions = exports.defaultCommonOptions = void 0;
7
+ const node_events_1 = __importDefault(require("node:events"));
8
+ const common_1 = require("./common");
9
+ const logging_1 = require("./logging");
10
+ const defaultCommonOptions = (net, env) => {
11
+ return {
12
+ url: (0, common_1.bp)(net, 'URL', env),
13
+ emitter: new node_events_1.default(),
14
+ console: (0, logging_1.logger)(net.toLowerCase()),
15
+ };
16
+ };
17
+ exports.defaultCommonOptions = defaultCommonOptions;
18
+ const defaultAccountOptions = (net, env) => {
19
+ return {
20
+ address: (0, common_1.bp)(net, 'ADDRESS', env),
21
+ private: (0, common_1.bp)(net, 'PRIVATE', env),
22
+ phrases: (0, common_1.bp)(net, 'PHRASES', env).split(/,/),
23
+ };
24
+ };
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;
30
+ //# sourceMappingURL=options.js.map
@@ -0,0 +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"}
@@ -0,0 +1,9 @@
1
+ export type AccountOptions = {
2
+ private?: string;
3
+ address?: string;
4
+ phrases?: string[];
5
+ };
6
+ export interface Account<Options extends AccountOptions> {
7
+ readonly options: Options;
8
+ getBalance(address?: string): Promise<bigint>;
9
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/type/account.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ /// <reference types="node" />
2
+ import EventEmitter from 'node:events';
3
+ import { logger } from '../tool';
4
+ import { Ethereum } from '../libs';
5
+ export type Net = typeof Ethereum.symbol;
6
+ export type EmitterOptions = {
7
+ emitter?: EventEmitter;
8
+ };
9
+ export type LoggerOptions = {
10
+ console?: ReturnType<typeof logger>;
11
+ };
12
+ export type ProviderOptions = {
13
+ url?: string;
14
+ };
15
+ export type CommonOptions = ProviderOptions & EmitterOptions & LoggerOptions;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/type/common.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export * from './common';
2
+ export * from './account';
3
+ export * from './lib-types';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./common"), exports);
18
+ __exportStar(require("./account"), exports);
19
+ __exportStar(require("./lib-types"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/type/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,8CAA4B"}
@@ -0,0 +1,7 @@
1
+ import { AccountOptions } from './account';
2
+ import { CommonOptions } from './common';
3
+ export type CryptoOptions = CommonOptions & AccountOptions;
4
+ export interface Crypto<Options extends CryptoOptions> {
5
+ readonly options: Options;
6
+ getGasPrice(): Promise<bigint | null>;
7
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=lib-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib-types.js","sourceRoot":"","sources":["../../src/type/lib-types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "crypto-aio",
3
+ "version": "0.0.1",
4
+ "description": "All-In-One Crypto-Currency for Backend",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "debug": "jest --watch",
9
+ "prebuild": "rimraf dist",
10
+ "doc": "typedoc --out docs src/",
11
+ "build": "tsc -p ./tsconfig.json",
12
+ "clean": "rm -rf ./dist && rm -rf ./docs",
13
+ "lint": "eslint . '*/**/*.{js,ts}' --quiet --fix",
14
+ "fresh": "npm run clean && npm run doc && npm run test",
15
+ "format": "prettier --write \"(src|test)/**/*.(ts|js)\"",
16
+ "start:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register src/index.ts",
17
+ "test": "jest && make-coverage-badge --report-path docs/coverage/coverage-summary.json --output-path docs/coverage.svg"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/vhidvz/crypto-aio.git"
22
+ },
23
+ "author": "Vahid V. <vhid.vz@gmail.com>",
24
+ "license": "MIT",
25
+ "bugs": {
26
+ "url": "https://github.com/vhidvz/crypto-aio/issues"
27
+ },
28
+ "keywords": [
29
+ "bitcoin",
30
+ "ethereum",
31
+ "solana",
32
+ "tron",
33
+ "ton"
34
+ ],
35
+ "homepage": "https://github.com/vhidvz/crypto-aio#readme",
36
+ "dependencies": {
37
+ "debug": "^4.3.4",
38
+ "ethers": "^6.12.1",
39
+ "web3": "^4.8.0"
40
+ },
41
+ "devDependencies": {
42
+ "@types/debug": "^4.1.12",
43
+ "@types/jest": "^29.5.12",
44
+ "@types/node": "^20.12.11",
45
+ "@typescript-eslint/eslint-plugin": "^7.8.0",
46
+ "@typescript-eslint/parser": "^7.8.0",
47
+ "dotenv": "^16.4.5",
48
+ "eslint": "^8.57.0",
49
+ "eslint-config-prettier": "^9.1.0",
50
+ "eslint-plugin-prettier": "^5.1.3",
51
+ "jest": "^29.7.0",
52
+ "jshint": "^2.13.6",
53
+ "make-coverage-badge": "^1.2.0",
54
+ "prettier": "^3.2.5",
55
+ "rimraf": "^5.0.5",
56
+ "ts-jest": "^29.1.2",
57
+ "ts-node": "^10.9.2",
58
+ "tsconfig-paths": "^4.2.0",
59
+ "typedoc": "^0.25.13",
60
+ "typescript": "^5.4.5"
61
+ },
62
+ "publishConfig": {
63
+ "access": "public",
64
+ "registry": "https://registry.npmjs.org/"
65
+ },
66
+ "files": [
67
+ "/dist"
68
+ ]
69
+ }