crypto-aio 0.0.1 → 0.0.2
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.
- package/README.md +2 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/libs/eth/account.d.ts +3 -3
- package/dist/libs/eth/account.js +5 -5
- package/dist/libs/eth/account.js.map +1 -1
- package/dist/libs/eth/index.d.ts +1 -0
- package/dist/libs/eth/index.js +4 -1
- package/dist/libs/eth/index.js.map +1 -1
- package/dist/tool/eth-tools.d.ts +1 -1
- package/dist/tool/eth-tools.js +5 -5
- package/dist/tool/eth-tools.js.map +1 -1
- package/dist/tool/options.d.ts +3 -3
- package/dist/tool/options.js +15 -17
- package/dist/tool/options.js.map +1 -1
- package/dist/type/common.d.ts +4 -1
- package/package.json +1 -1
- package/dist/libs/eth/_eth.d.ts +0 -17
- package/dist/libs/eth/_eth.js +0 -56
- 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
|
[](https://github.com/vhidvz/crypto-aio/actions/workflows/npm-ci.yml)
|
|
4
6
|
[](https://www.npmjs.com/package/crypto-aio)
|
|
5
7
|

|
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.
|
|
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,
|
|
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
|
|
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?:
|
|
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
|
}
|
package/dist/libs/eth/account.js
CHANGED
|
@@ -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.
|
|
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(
|
|
38
|
-
return EthereumAccount.create(
|
|
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.
|
|
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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../src/libs/eth/account.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,8DAAiC;AACjC,mCAAgC;AAChC,+BAA4B;
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../src/libs/eth/account.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,8DAAiC;AACjC,mCAAgC;AAChC,+BAA4B;AAI5B,qCAAmF;AAEnF,MAAa,eAAe;IAC1B,YAAqB,UAA2B,IAAA,sBAAe,GAAE;QAA5C,YAAO,GAAP,OAAO,CAAqC;QAC/D,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,CACJ,OAAO,GAAG,IAAA,oBAAa,EAAC,KAAK,CAAC,EAC9B,MAAM,IAAA,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"}
|
package/dist/libs/eth/index.d.ts
CHANGED
|
@@ -15,5 +15,6 @@ export declare class Ethereum implements Crypto<EthereumOptions> {
|
|
|
15
15
|
static readonly symbol = "ETH";
|
|
16
16
|
constructor(options?: EthereumOptions);
|
|
17
17
|
get account(): EthereumAccount;
|
|
18
|
+
createAccount(options?: import("../../type").CommonOptions, lib?: "web3" | "ethers" | undefined): EthereumAccount;
|
|
18
19
|
getGasPrice(): Promise<bigint | null>;
|
|
19
20
|
}
|
package/dist/libs/eth/index.js
CHANGED
|
@@ -33,7 +33,7 @@ Object.defineProperty(exports, "EthereumContract", { enumerable: true, get: func
|
|
|
33
33
|
var transact_1 = require("./transact");
|
|
34
34
|
Object.defineProperty(exports, "EthereumTransact", { enumerable: true, get: function () { return transact_1.EthereumTransact; } });
|
|
35
35
|
class Ethereum {
|
|
36
|
-
constructor(options = (0, tool_1.
|
|
36
|
+
constructor(options = (0, tool_1.ethereumOptions)()) {
|
|
37
37
|
this.options = options;
|
|
38
38
|
_Ethereum_account.set(this, void 0);
|
|
39
39
|
(0, tool_1.initEth)(options);
|
|
@@ -41,6 +41,9 @@ class Ethereum {
|
|
|
41
41
|
get account() {
|
|
42
42
|
return (__classPrivateFieldSet(this, _Ethereum_account, __classPrivateFieldGet(this, _Ethereum_account, "f") || new account_1.EthereumAccount(this.options), "f"));
|
|
43
43
|
}
|
|
44
|
+
createAccount(options = (0, tool_1.commonOptions)('ETH'), lib = (0, tool_1.bp)('ETH', 'LIB')) {
|
|
45
|
+
return this.account.create(options, lib);
|
|
46
|
+
}
|
|
44
47
|
getGasPrice() {
|
|
45
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
49
|
const { client } = this.options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/libs/eth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAgC;AAChC,+BAA4B;AAE5B,uCAA4C;AAE5C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/libs/eth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAgC;AAChC,+BAA4B;AAE5B,uCAA4C;AAE5C,qCAAyE;AAEzE,qCAA4C;AAAnC,0GAAA,eAAe,OAAA;AACxB,uCAA8C;AAArC,4GAAA,gBAAgB,OAAA;AACzB,uCAA8C;AAArC,4GAAA,gBAAgB,OAAA;AAOzB,MAAa,QAAQ;IAKnB,YAAqB,UAA2B,IAAA,sBAAe,GAAE;QAA5C,YAAO,GAAP,OAAO,CAAqC;QAJjE,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,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;;AA1BH,4BA2BC;;AAxBwB,eAAM,GAAG,KAAK,AAAR,CAAS"}
|
package/dist/tool/eth-tools.d.ts
CHANGED
package/dist/tool/eth-tools.js
CHANGED
|
@@ -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.
|
|
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
|
|
14
|
-
exports.
|
|
15
|
-
const initEth = (options = (0, exports.
|
|
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;
|
|
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;AACjC,uCAA0C;AAGnC,MAAM,eAAe,GAAG,CAAC,GAAY,EAAmB,EAAE,CAAC,iBAChE,GAAG,EAAE,IAAA,WAAE,EAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,IACvB,IAAA,uBAAa,EAAC,KAAK,EAAE,GAAG,CAAC,EAC5B,CAAC;AAHU,QAAA,eAAe,mBAGzB;AAEI,MAAM,OAAO,GAAG,CAAC,UAA2B,IAAA,uBAAe,GAAE,EAAE,EAAE;IACtE,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,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC;QAE/D,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"}
|
package/dist/tool/options.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { AccountOptions, CommonOptions, CryptoOptions, Net } from '../type';
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
2
|
+
export declare const commonOptions: (net: Net, env?: string) => CommonOptions;
|
|
3
|
+
export declare const accountOptions: (net: Net, env?: string) => AccountOptions;
|
|
4
|
+
export declare const cryptoOptions: (net: Net, env?: string) => CryptoOptions;
|
package/dist/tool/options.js
CHANGED
|
@@ -3,28 +3,26 @@ 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.
|
|
6
|
+
exports.cryptoOptions = 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
|
|
11
|
-
|
|
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.
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
exports.
|
|
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;
|
|
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
|
+
});
|
|
25
|
+
exports.accountOptions = accountOptions;
|
|
26
|
+
const cryptoOptions = (net, env) => (Object.assign(Object.assign({}, (0, exports.commonOptions)(net, env)), (0, exports.accountOptions)(net, env)));
|
|
27
|
+
exports.cryptoOptions = cryptoOptions;
|
|
30
28
|
//# sourceMappingURL=options.js.map
|
package/dist/tool/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/tool/options.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAuC;AAEvC,qCAA8B;AAC9B,uCAAmC;AAG5B,MAAM,
|
|
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,cAAc,GAAG,CAAC,GAAQ,EAAE,GAAY,EAAkB,EAAE,CAAC,CAAC;IACzE,OAAO,EAAE,IAAA,WAAE,EAAC,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC;IAChC,OAAO,EAAE,IAAA,WAAE,EAAC,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC;IAChC,OAAO,EAAE,IAAA,WAAE,EAAC,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;CAC5C,CAAC,CAAC;AAJU,QAAA,cAAc,kBAIxB;AAEI,MAAM,aAAa,GAAG,CAAC,GAAQ,EAAE,GAAY,EAAiB,EAAE,CAAC,iCACnE,IAAA,qBAAa,EAAC,GAAG,EAAE,GAAG,CAAC,GACvB,IAAA,sBAAc,EAAC,GAAG,EAAE,GAAG,CAAC,EAC3B,CAAC;AAHU,QAAA,aAAa,iBAGvB"}
|
package/dist/type/common.d.ts
CHANGED
|
@@ -9,7 +9,10 @@ export type EmitterOptions = {
|
|
|
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;
|
package/package.json
CHANGED
package/dist/libs/eth/_eth.d.ts
DELETED
|
@@ -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
|
-
}
|
package/dist/libs/eth/_eth.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
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
|
|
@@ -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"}
|