quantumcoin 6.14.2 → 6.14.4
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 +12 -22
- package/dist/README.md +1 -1
- package/lib.commonjs/_version.js +1 -1
- package/lib.commonjs/crypto/signing-key.d.ts +1 -1
- package/lib.commonjs/crypto/signing-key.d.ts.map +1 -1
- package/lib.commonjs/crypto/signing-key.js +14 -8
- package/lib.commonjs/crypto/signing-key.js.map +1 -1
- package/lib.commonjs/quantumcoin.d.ts +2 -0
- package/lib.commonjs/quantumcoin.d.ts.map +1 -1
- package/lib.commonjs/quantumcoin.js +11 -5
- package/lib.commonjs/quantumcoin.js.map +1 -1
- package/lib.commonjs/transaction/address.d.ts.map +1 -1
- package/lib.commonjs/transaction/address.js +8 -3
- package/lib.commonjs/transaction/address.js.map +1 -1
- package/lib.commonjs/wallet/json-keystore.d.ts.map +1 -1
- package/lib.commonjs/wallet/json-keystore.js +7 -7
- package/lib.commonjs/wallet/json-keystore.js.map +1 -1
- package/lib.commonjs/wallet/wallet.d.ts.map +1 -1
- package/lib.commonjs/wallet/wallet.js +2 -2
- package/lib.commonjs/wallet/wallet.js.map +1 -1
- package/lib.esm/_version.js +1 -1
- package/lib.esm/crypto/signing-key.d.ts +1 -1
- package/lib.esm/crypto/signing-key.d.ts.map +1 -1
- package/lib.esm/crypto/signing-key.js +15 -8
- package/lib.esm/crypto/signing-key.js.map +1 -1
- package/lib.esm/quantumcoin.d.ts +2 -0
- package/lib.esm/quantumcoin.d.ts.map +1 -1
- package/lib.esm/quantumcoin.js +6 -0
- package/lib.esm/quantumcoin.js.map +1 -1
- package/lib.esm/transaction/address.d.ts.map +1 -1
- package/lib.esm/transaction/address.js +8 -2
- package/lib.esm/transaction/address.js.map +1 -1
- package/lib.esm/wallet/json-keystore.d.ts.map +1 -1
- package/lib.esm/wallet/json-keystore.js +11 -5
- package/lib.esm/wallet/json-keystore.js.map +1 -1
- package/lib.esm/wallet/wallet.d.ts.map +1 -1
- package/lib.esm/wallet/wallet.js +3 -1
- package/lib.esm/wallet/wallet.js.map +1 -1
- package/package.json +6 -5
- package/src.ts/_version.ts +1 -1
- package/src.ts/crypto/signing-key.ts +14 -9
- package/src.ts/quantumcoin.ts +10 -2
- package/src.ts/transaction/address.ts +7 -3
- package/src.ts/wallet/json-keystore.ts +8 -6
- package/src.ts/wallet/wallet.ts +2 -3
- package/dist/quantumcoin.js +0 -21137
- package/dist/quantumcoin.js.map +0 -1
- package/dist/quantumcoin.min.js +0 -1
- package/dist/quantumcoin.min.js'.gz' +0 -0
- package/dist/quantumcoin.umd.js +0 -21316
- package/dist/quantumcoin.umd.js.map +0 -1
- package/dist/quantumcoin.umd.min.js +0 -1
- package/dist/quantumcoin.umd.min.js'.gz' +0 -0
- package/dist/wordlists-extra.js +0 -1500
- package/dist/wordlists-extra.js.map +0 -1
- package/dist/wordlists-extra.min.js +0 -1
- package/dist/wordlists-extra.min.js'.gz' +0 -0
- package/lib.commonjs/providers/provider-alchemy.d.ts +0 -50
- package/lib.commonjs/providers/provider-alchemy.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-alchemy.js +0 -151
- package/lib.commonjs/providers/provider-alchemy.js.map +0 -1
- package/lib.commonjs/providers/provider-ankr.d.ts +0 -61
- package/lib.commonjs/providers/provider-ankr.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-ankr.js +0 -137
- package/lib.commonjs/providers/provider-ankr.js.map +0 -1
- package/lib.commonjs/providers/provider-blockscout.d.ts +0 -59
- package/lib.commonjs/providers/provider-blockscout.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-blockscout.js +0 -145
- package/lib.commonjs/providers/provider-blockscout.js.map +0 -1
- package/lib.commonjs/providers/provider-chainstack.d.ts +0 -46
- package/lib.commonjs/providers/provider-chainstack.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-chainstack.js +0 -102
- package/lib.commonjs/providers/provider-chainstack.js.map +0 -1
- package/lib.commonjs/providers/provider-cloudflare.d.ts +0 -14
- package/lib.commonjs/providers/provider-cloudflare.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-cloudflare.js +0 -26
- package/lib.commonjs/providers/provider-cloudflare.js.map +0 -1
- package/lib.commonjs/providers/provider-etherscan.d.ts +0 -147
- package/lib.commonjs/providers/provider-etherscan.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-etherscan.js +0 -587
- package/lib.commonjs/providers/provider-etherscan.js.map +0 -1
- package/lib.commonjs/providers/provider-infura.d.ts +0 -101
- package/lib.commonjs/providers/provider-infura.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-infura.js +0 -206
- package/lib.commonjs/providers/provider-infura.js.map +0 -1
- package/lib.commonjs/providers/provider-pocket.d.ts +0 -54
- package/lib.commonjs/providers/provider-pocket.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-pocket.js +0 -109
- package/lib.commonjs/providers/provider-pocket.js.map +0 -1
- package/lib.commonjs/providers/provider-quicknode.d.ts +0 -59
- package/lib.commonjs/providers/provider-quicknode.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-quicknode.js +0 -163
- package/lib.commonjs/providers/provider-quicknode.js.map +0 -1
- package/lib.commonjs/wallet/hdwallet.d.ts +0 -248
- package/lib.commonjs/wallet/hdwallet.d.ts.map +0 -1
- package/lib.commonjs/wallet/hdwallet.js +0 -505
- package/lib.commonjs/wallet/hdwallet.js.map +0 -1
- package/lib.commonjs/wallet/json-crowdsale.d.ts +0 -27
- package/lib.commonjs/wallet/json-crowdsale.d.ts.map +0 -1
- package/lib.commonjs/wallet/json-crowdsale.js +0 -60
- package/lib.commonjs/wallet/json-crowdsale.js.map +0 -1
- package/lib.commonjs/wallet/mnemonic.d.ts +0 -65
- package/lib.commonjs/wallet/mnemonic.d.ts.map +0 -1
- package/lib.commonjs/wallet/mnemonic.js +0 -169
- package/lib.commonjs/wallet/mnemonic.js.map +0 -1
- package/lib.commonjs/wallet/seedwallet.d.ts +0 -4
- package/lib.commonjs/wallet/seedwallet.d.ts.map +0 -1
- package/lib.commonjs/wallet/seedwallet.js +0 -8
- package/lib.commonjs/wallet/seedwallet.js.map +0 -1
- package/lib.esm/providers/provider-alchemy.d.ts +0 -50
- package/lib.esm/providers/provider-alchemy.d.ts.map +0 -1
- package/lib.esm/providers/provider-alchemy.js +0 -147
- package/lib.esm/providers/provider-alchemy.js.map +0 -1
- package/lib.esm/providers/provider-ankr.d.ts +0 -61
- package/lib.esm/providers/provider-ankr.d.ts.map +0 -1
- package/lib.esm/providers/provider-ankr.js +0 -133
- package/lib.esm/providers/provider-ankr.js.map +0 -1
- package/lib.esm/providers/provider-blockscout.d.ts +0 -59
- package/lib.esm/providers/provider-blockscout.d.ts.map +0 -1
- package/lib.esm/providers/provider-blockscout.js +0 -141
- package/lib.esm/providers/provider-blockscout.js.map +0 -1
- package/lib.esm/providers/provider-chainstack.d.ts +0 -46
- package/lib.esm/providers/provider-chainstack.d.ts.map +0 -1
- package/lib.esm/providers/provider-chainstack.js +0 -98
- package/lib.esm/providers/provider-chainstack.js.map +0 -1
- package/lib.esm/providers/provider-cloudflare.d.ts +0 -14
- package/lib.esm/providers/provider-cloudflare.d.ts.map +0 -1
- package/lib.esm/providers/provider-cloudflare.js +0 -22
- package/lib.esm/providers/provider-cloudflare.js.map +0 -1
- package/lib.esm/providers/provider-etherscan.d.ts +0 -147
- package/lib.esm/providers/provider-etherscan.d.ts.map +0 -1
- package/lib.esm/providers/provider-etherscan.js +0 -584
- package/lib.esm/providers/provider-etherscan.js.map +0 -1
- package/lib.esm/providers/provider-infura.d.ts +0 -101
- package/lib.esm/providers/provider-infura.d.ts.map +0 -1
- package/lib.esm/providers/provider-infura.js +0 -201
- package/lib.esm/providers/provider-infura.js.map +0 -1
- package/lib.esm/providers/provider-pocket.d.ts +0 -54
- package/lib.esm/providers/provider-pocket.d.ts.map +0 -1
- package/lib.esm/providers/provider-pocket.js +0 -105
- package/lib.esm/providers/provider-pocket.js.map +0 -1
- package/lib.esm/providers/provider-quicknode.d.ts +0 -59
- package/lib.esm/providers/provider-quicknode.d.ts.map +0 -1
- package/lib.esm/providers/provider-quicknode.js +0 -159
- package/lib.esm/providers/provider-quicknode.js.map +0 -1
- package/lib.esm/wallet/hdwallet.d.ts +0 -248
- package/lib.esm/wallet/hdwallet.d.ts.map +0 -1
- package/lib.esm/wallet/hdwallet.js +0 -498
- package/lib.esm/wallet/hdwallet.js.map +0 -1
- package/lib.esm/wallet/json-crowdsale.d.ts +0 -27
- package/lib.esm/wallet/json-crowdsale.d.ts.map +0 -1
- package/lib.esm/wallet/json-crowdsale.js +0 -55
- package/lib.esm/wallet/json-crowdsale.js.map +0 -1
- package/lib.esm/wallet/mnemonic.d.ts +0 -65
- package/lib.esm/wallet/mnemonic.d.ts.map +0 -1
- package/lib.esm/wallet/mnemonic.js +0 -165
- package/lib.esm/wallet/mnemonic.js.map +0 -1
- package/lib.esm/wallet/seedwallet.d.ts +0 -4
- package/lib.esm/wallet/seedwallet.d.ts.map +0 -1
- package/lib.esm/wallet/seedwallet.js +0 -4
- package/lib.esm/wallet/seedwallet.js.map +0 -1
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { BytesLike } from "../utils/index.js";
|
|
2
|
-
import type { Wordlist } from "../wordlists/index.js";
|
|
3
|
-
/**
|
|
4
|
-
* A **Mnemonic** wraps all properties required to compute [[link-bip-39]]
|
|
5
|
-
* seeds and convert between phrases and entropy.
|
|
6
|
-
*/
|
|
7
|
-
export declare class Mnemonic {
|
|
8
|
-
/**
|
|
9
|
-
* The mnemonic phrase of 12, 15, 18, 21 or 24 words.
|
|
10
|
-
*
|
|
11
|
-
* Use the [[wordlist]] ``split`` method to get the individual words.
|
|
12
|
-
*/
|
|
13
|
-
readonly phrase: string;
|
|
14
|
-
/**
|
|
15
|
-
* The password used for this mnemonic. If no password is used this
|
|
16
|
-
* is the empty string (i.e. ``""``) as per the specification.
|
|
17
|
-
*/
|
|
18
|
-
readonly password: string;
|
|
19
|
-
/**
|
|
20
|
-
* The wordlist for this mnemonic.
|
|
21
|
-
*/
|
|
22
|
-
readonly wordlist: Wordlist;
|
|
23
|
-
/**
|
|
24
|
-
* The underlying entropy which the mnemonic encodes.
|
|
25
|
-
*/
|
|
26
|
-
readonly entropy: string;
|
|
27
|
-
/**
|
|
28
|
-
* @private
|
|
29
|
-
*/
|
|
30
|
-
constructor(guard: any, entropy: string, phrase: string, password?: null | string, wordlist?: null | Wordlist);
|
|
31
|
-
/**
|
|
32
|
-
* Returns the seed for the mnemonic.
|
|
33
|
-
*/
|
|
34
|
-
computeSeed(): string;
|
|
35
|
-
/**
|
|
36
|
-
* Creates a new Mnemonic for the %%phrase%%.
|
|
37
|
-
*
|
|
38
|
-
* The default %%password%% is the empty string and the default
|
|
39
|
-
* wordlist is the [English wordlists](LangEn).
|
|
40
|
-
*/
|
|
41
|
-
static fromPhrase(phrase: string, password?: null | string, wordlist?: null | Wordlist): Mnemonic;
|
|
42
|
-
/**
|
|
43
|
-
* Create a new **Mnemonic** from the %%entropy%%.
|
|
44
|
-
*
|
|
45
|
-
* The default %%password%% is the empty string and the default
|
|
46
|
-
* wordlist is the [English wordlists](LangEn).
|
|
47
|
-
*/
|
|
48
|
-
static fromEntropy(_entropy: BytesLike, password?: null | string, wordlist?: null | Wordlist): Mnemonic;
|
|
49
|
-
/**
|
|
50
|
-
* Returns the phrase for %%mnemonic%%.
|
|
51
|
-
*/
|
|
52
|
-
static entropyToPhrase(_entropy: BytesLike, wordlist?: null | Wordlist): string;
|
|
53
|
-
/**
|
|
54
|
-
* Returns the entropy for %%phrase%%.
|
|
55
|
-
*/
|
|
56
|
-
static phraseToEntropy(phrase: string, wordlist?: null | Wordlist): string;
|
|
57
|
-
/**
|
|
58
|
-
* Returns true if %%phrase%% is a valid [[link-bip-39]] phrase.
|
|
59
|
-
*
|
|
60
|
-
* This checks all the provided words belong to the %%wordlist%%,
|
|
61
|
-
* that the length is valid and the checksum is correct.
|
|
62
|
-
*/
|
|
63
|
-
static isValidMn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,QAAQ,GAAG,MAAM;IAK/E;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,IAAI,GAAG,QAAQ,GAAG,MAAM;IAI1E;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,IAAI,GAAG,QAAQ,GAAG,OAAO;CAO9E"}
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Mnemonic = void 0;
|
|
4
|
-
const index_js_1 = require("../crypto/index.js");
|
|
5
|
-
const index_js_2 = require("../utils/index.js");
|
|
6
|
-
const lang_en_js_1 = require("../wordlists/lang-en.js");
|
|
7
|
-
// Returns a byte with the MSB bits set
|
|
8
|
-
function getUpperMask(bits) {
|
|
9
|
-
return ((1 << bits) - 1) << (8 - bits) & 0xff;
|
|
10
|
-
}
|
|
11
|
-
// Returns a byte with the LSB bits set
|
|
12
|
-
function getLowerMask(bits) {
|
|
13
|
-
return ((1 << bits) - 1) & 0xff;
|
|
14
|
-
}
|
|
15
|
-
function mnemonicToEntropy(mnemonic, wordlist) {
|
|
16
|
-
(0, index_js_2.assertNormalize)("NFKD");
|
|
17
|
-
if (wordlist == null) {
|
|
18
|
-
wordlist = lang_en_js_1.LangEn.wordlist();
|
|
19
|
-
}
|
|
20
|
-
const words = wordlist.split(mnemonic);
|
|
21
|
-
(0, index_js_2.assertArgument)((words.length % 3) === 0 && words.length >= 12 && words.length <= 24, "invalid mnemonic length", "mnemonic", "[ REDACTED ]");
|
|
22
|
-
const entropy = new Uint8Array(Math.ceil(11 * words.length / 8));
|
|
23
|
-
let offset = 0;
|
|
24
|
-
for (let i = 0; i < words.length; i++) {
|
|
25
|
-
let index = wordlist.getWordIndex(words[i].normalize("NFKD"));
|
|
26
|
-
(0, index_js_2.assertArgument)(index >= 0, `invalid mnemonic word at index ${i}`, "mnemonic", "[ REDACTED ]");
|
|
27
|
-
for (let bit = 0; bit < 11; bit++) {
|
|
28
|
-
if (index & (1 << (10 - bit))) {
|
|
29
|
-
entropy[offset >> 3] |= (1 << (7 - (offset % 8)));
|
|
30
|
-
}
|
|
31
|
-
offset++;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const entropyBits = 32 * words.length / 3;
|
|
35
|
-
const checksumBits = words.length / 3;
|
|
36
|
-
const checksumMask = getUpperMask(checksumBits);
|
|
37
|
-
const checksum = (0, index_js_2.getBytes)((0, index_js_1.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
|
38
|
-
(0, index_js_2.assertArgument)(checksum === (entropy[entropy.length - 1] & checksumMask), "invalid mnemonic checksum", "mnemonic", "[ REDACTED ]");
|
|
39
|
-
return (0, index_js_2.hexlify)(entropy.slice(0, entropyBits / 8));
|
|
40
|
-
}
|
|
41
|
-
function entropyToMnemonic(entropy, wordlist) {
|
|
42
|
-
(0, index_js_2.assertArgument)((entropy.length % 4) === 0 && entropy.length >= 16 && entropy.length <= 32, "invalid entropy size", "entropy", "[ REDACTED ]");
|
|
43
|
-
if (wordlist == null) {
|
|
44
|
-
wordlist = lang_en_js_1.LangEn.wordlist();
|
|
45
|
-
}
|
|
46
|
-
const indices = [0];
|
|
47
|
-
let remainingBits = 11;
|
|
48
|
-
for (let i = 0; i < entropy.length; i++) {
|
|
49
|
-
// Consume the whole byte (with still more to go)
|
|
50
|
-
if (remainingBits > 8) {
|
|
51
|
-
indices[indices.length - 1] <<= 8;
|
|
52
|
-
indices[indices.length - 1] |= entropy[i];
|
|
53
|
-
remainingBits -= 8;
|
|
54
|
-
// This byte will complete an 11-bit index
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
indices[indices.length - 1] <<= remainingBits;
|
|
58
|
-
indices[indices.length - 1] |= entropy[i] >> (8 - remainingBits);
|
|
59
|
-
// Start the next word
|
|
60
|
-
indices.push(entropy[i] & getLowerMask(8 - remainingBits));
|
|
61
|
-
remainingBits += 3;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
// Compute the checksum bits
|
|
65
|
-
const checksumBits = entropy.length / 4;
|
|
66
|
-
const checksum = parseInt((0, index_js_1.sha256)(entropy).substring(2, 4), 16) & getUpperMask(checksumBits);
|
|
67
|
-
// Shift the checksum into the word indices
|
|
68
|
-
indices[indices.length - 1] <<= checksumBits;
|
|
69
|
-
indices[indices.length - 1] |= (checksum >> (8 - checksumBits));
|
|
70
|
-
return wordlist.join(indices.map((index) => wordlist.getWord(index)));
|
|
71
|
-
}
|
|
72
|
-
const _guard = {};
|
|
73
|
-
/**
|
|
74
|
-
* A **Mnemonic** wraps all properties required to compute [[link-bip-39]]
|
|
75
|
-
* seeds and convert between phrases and entropy.
|
|
76
|
-
*/
|
|
77
|
-
class Mnemonic {
|
|
78
|
-
/**
|
|
79
|
-
* The mnemonic phrase of 12, 15, 18, 21 or 24 words.
|
|
80
|
-
*
|
|
81
|
-
* Use the [[wordlist]] ``split`` method to get the individual words.
|
|
82
|
-
*/
|
|
83
|
-
phrase;
|
|
84
|
-
/**
|
|
85
|
-
* The password used for this mnemonic. If no password is used this
|
|
86
|
-
* is the empty string (i.e. ``""``) as per the specification.
|
|
87
|
-
*/
|
|
88
|
-
password;
|
|
89
|
-
/**
|
|
90
|
-
* The wordlist for this mnemonic.
|
|
91
|
-
*/
|
|
92
|
-
wordlist;
|
|
93
|
-
/**
|
|
94
|
-
* The underlying entropy which the mnemonic encodes.
|
|
95
|
-
*/
|
|
96
|
-
entropy;
|
|
97
|
-
/**
|
|
98
|
-
* @private
|
|
99
|
-
*/
|
|
100
|
-
constructor(guard, entropy, phrase, password, wordlist) {
|
|
101
|
-
if (password == null) {
|
|
102
|
-
password = "";
|
|
103
|
-
}
|
|
104
|
-
if (wordlist == null) {
|
|
105
|
-
wordlist = lang_en_js_1.LangEn.wordlist();
|
|
106
|
-
}
|
|
107
|
-
(0, index_js_2.assertPrivate)(guard, _guard, "Mnemonic");
|
|
108
|
-
(0, index_js_2.defineProperties)(this, { phrase, password, wordlist, entropy });
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Returns the seed for the mnemonic.
|
|
112
|
-
*/
|
|
113
|
-
computeSeed() {
|
|
114
|
-
const salt = (0, index_js_2.toUtf8Bytes)("mnemonic" + this.password, "NFKD");
|
|
115
|
-
return (0, index_js_1.pbkdf2)((0, index_js_2.toUtf8Bytes)(this.phrase, "NFKD"), salt, 2048, 64, "sha512");
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Creates a new Mnemonic for the %%phrase%%.
|
|
119
|
-
*
|
|
120
|
-
* The default %%password%% is the empty string and the default
|
|
121
|
-
* wordlist is the [English wordlists](LangEn).
|
|
122
|
-
*/
|
|
123
|
-
static fromPhrase(phrase, password, wordlist) {
|
|
124
|
-
// Normalize the case and space; throws if invalid
|
|
125
|
-
const entropy = mnemonicToEntropy(phrase, wordlist);
|
|
126
|
-
phrase = entropyToMnemonic((0, index_js_2.getBytes)(entropy), wordlist);
|
|
127
|
-
return new Mnemonic(_guard, entropy, phrase, password, wordlist);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Create a new **Mnemonic** from the %%entropy%%.
|
|
131
|
-
*
|
|
132
|
-
* The default %%password%% is the empty string and the default
|
|
133
|
-
* wordlist is the [English wordlists](LangEn).
|
|
134
|
-
*/
|
|
135
|
-
static fromEntropy(_entropy, password, wordlist) {
|
|
136
|
-
const entropy = (0, index_js_2.getBytes)(_entropy, "entropy");
|
|
137
|
-
const phrase = entropyToMnemonic(entropy, wordlist);
|
|
138
|
-
return new Mnemonic(_guard, (0, index_js_2.hexlify)(entropy), phrase, password, wordlist);
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Returns the phrase for %%mnemonic%%.
|
|
142
|
-
*/
|
|
143
|
-
static entropyToPhrase(_entropy, wordlist) {
|
|
144
|
-
const entropy = (0, index_js_2.getBytes)(_entropy, "entropy");
|
|
145
|
-
return entropyToMnemonic(entropy, wordlist);
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Returns the entropy for %%phrase%%.
|
|
149
|
-
*/
|
|
150
|
-
static phraseToEntropy(phrase, wordlist) {
|
|
151
|
-
return mnemonicToEntropy(phrase, wordlist);
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Returns true if %%phrase%% is a valid [[link-bip-39]] phrase.
|
|
155
|
-
*
|
|
156
|
-
* This checks all the provided words belong to the %%wordlist%%,
|
|
157
|
-
* that the length is valid and the checksum is correct.
|
|
158
|
-
*/
|
|
159
|
-
static isValidMnemonic(phrase, wordlist) {
|
|
160
|
-
try {
|
|
161
|
-
mnemonicToEntropy(phrase, wordlist);
|
|
162
|
-
return true;
|
|
163
|
-
}
|
|
164
|
-
catch (error) { }
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
exports.Mnemonic = Mnemonic;
|
|
169
|
-
//# sourceMappingURL=mnemonic.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mnemonic.js","sourceRoot":"","sources":["../../src.ts/wallet/mnemonic.ts"],"names":[],"mappings":";;;AAAA,iDAAoD;AACpD,gDAE2B;AAC3B,wDAAiD;AAMjD,uCAAuC;AACvC,SAAS,YAAY,CAAC,IAAY;IAC/B,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;AACjD,CAAC;AAED,uCAAuC;AACvC,SAAS,YAAY,CAAC,IAAY;IAC/B,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;AACnC,CAAC;AAGD,SAAS,iBAAiB,CAAC,QAAgB,EAAE,QAA0B;IACnE,IAAA,0BAAe,EAAC,MAAM,CAAC,CAAC;IAExB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AW,CAAC,QAAmB,EAAE,QAAwB,EAAE,QAA0B;QACxF,MAAM,OAAO,GAAG,IAAA,mBAAQ,EAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAC9C,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACpD,OAAO,IAAI,QAAQ,CAAC,MAAM,EAAE,IAAA,kBAAO,EAAC,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC9E,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,QAAmB,EAAE,QAA0B;QAClE,MAAM,OAAO,GAAG,IAAA,mBAAQ,EAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAC9C,OAAO,iBAAiB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,MAAc,EAAE,QAA0B;QAC7D,OAAO,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CAAC,MAAc,EAAE,QAA0B;QAC7D,IAAI;YACA,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACpC,OAAO,IAAI,CAAC;SACf;QAAC,OAAO,KAAK,EAAE,GAAG;QACnB,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AA/FD,4BA+FC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"seedwallet.d.ts","sourceRoot":"","sources":["../../src.ts/wallet/seedwallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,qBAAa,YAAa,SAAQ,UAAU;CAE3C"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HDNodeWallet = void 0;
|
|
4
|
-
const base_wallet_js_1 = require("./base-wallet.js");
|
|
5
|
-
class HDNodeWallet extends base_wallet_js_1.BaseWallet {
|
|
6
|
-
}
|
|
7
|
-
exports.HDNodeWallet = HDNodeWallet;
|
|
8
|
-
//# sourceMappingURL=seedwallet.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"seedwallet.js","sourceRoot":"","sources":["../../src.ts/wallet/seedwallet.ts"],"names":[],"mappings":";;;AAAA,qDAA8C;AAE9C,MAAa,YAAa,SAAQ,2BAAU;CAE3C;AAFD,oCAEC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* [[link-alchemy]] provides a third-party service for connecting to
|
|
3
|
-
* various blockchains over JSON-RPC.
|
|
4
|
-
*
|
|
5
|
-
* **Supported Networks**
|
|
6
|
-
*
|
|
7
|
-
* - Ethereum Mainnet (``mainnet``)
|
|
8
|
-
* - Goerli Testnet (``goerli``)
|
|
9
|
-
* - Sepolia Testnet (``sepolia``)
|
|
10
|
-
* - Arbitrum (``arbitrum``)
|
|
11
|
-
* - Arbitrum Goerli Testnet (``arbitrum-goerli``)
|
|
12
|
-
* - Arbitrum Sepolia Testnet (``arbitrum-sepolia``)
|
|
13
|
-
* - Base (``base``)
|
|
14
|
-
* - Base Goerlia Testnet (``base-goerli``)
|
|
15
|
-
* - Base Sepolia Testnet (``base-sepolia``)
|
|
16
|
-
* - Optimism (``optimism``)
|
|
17
|
-
* - Optimism Goerli Testnet (``optimism-goerli``)
|
|
18
|
-
* - Optimism Sepolia Testnet (``optimism-sepolia``)
|
|
19
|
-
* - Polygon (``matic``)
|
|
20
|
-
* - Polygon Amoy Testnet (``matic-amoy``)
|
|
21
|
-
* - Polygon Mumbai Testnet (``matic-mumbai``)
|
|
22
|
-
*
|
|
23
|
-
* @_subsection: api/providers/thirdparty:Alchemy [providers-alchemy]
|
|
24
|
-
*/
|
|
25
|
-
import { FetchRequest } from "../utils/index.js";
|
|
26
|
-
import { Network } from "./network.js";
|
|
27
|
-
import { JsonRpcProvider } from "./provider-jsonrpc.js";
|
|
28
|
-
import type { AbstractProvider, PerformActionRequest } from "./abstract-provider.js";
|
|
29
|
-
import type { CommunityResourcable } from "./community.js";
|
|
30
|
-
import type { Networkish } from "./network.js";
|
|
31
|
-
/**
|
|
32
|
-
* The **AlchemyProvider** connects to the [[link-alchemy]]
|
|
33
|
-
* JSON-RPC end-points.
|
|
34
|
-
*
|
|
35
|
-
* By default, a highly-throttled API key is used, which is
|
|
36
|
-
* appropriate for quick prototypes and simple scripts. To
|
|
37
|
-
* gain access to an increased rate-limit, it is highly
|
|
38
|
-
* recommended to [sign up here](link-alchemy-signup).
|
|
39
|
-
*
|
|
40
|
-
* @_docloc: api/providers/thirdparty
|
|
41
|
-
*/
|
|
42
|
-
export declare class AlchemyProvider extends JsonRpcProvider implements CommunityResourcable {
|
|
43
|
-
readonly apiKey: string;
|
|
44
|
-
constructor(_network?: Networkish, apiKey?: null | string);
|
|
45
|
-
_getProvider(chainId: number): AbstractProvider;
|
|
46
|
-
_perform(req: PerformActionRequest): Promise<any>;
|
|
47
|
-
isCommunityResource(): boolean;
|
|
48
|
-
static getRequest(network: Network, apiKey?: string): FetchRequest;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=provider-alchemy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider-alchemy.d.ts","sourceRoot":"","sources":["../../src.ts/providers/provider-alchemy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAEH,YAAY,EACf,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA2C/C;;;;;;;;;;GAUG;AACH,qBAAa,eAAgB,SAAQ,eAAgB,YAAW,oBAAoB;IAChF,QAAQ,CAAC,MAAM,EAAG,MAAM,CAAC;gBAEb,QAAQ,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM;IAWzD,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB;IAOzC,QAAQ,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC;IAmCvD,mBAAmB,IAAI,OAAO;IAI9B,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,YAAY;CAerE"}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* [[link-alchemy]] provides a third-party service for connecting to
|
|
3
|
-
* various blockchains over JSON-RPC.
|
|
4
|
-
*
|
|
5
|
-
* **Supported Networks**
|
|
6
|
-
*
|
|
7
|
-
* - Ethereum Mainnet (``mainnet``)
|
|
8
|
-
* - Goerli Testnet (``goerli``)
|
|
9
|
-
* - Sepolia Testnet (``sepolia``)
|
|
10
|
-
* - Arbitrum (``arbitrum``)
|
|
11
|
-
* - Arbitrum Goerli Testnet (``arbitrum-goerli``)
|
|
12
|
-
* - Arbitrum Sepolia Testnet (``arbitrum-sepolia``)
|
|
13
|
-
* - Base (``base``)
|
|
14
|
-
* - Base Goerlia Testnet (``base-goerli``)
|
|
15
|
-
* - Base Sepolia Testnet (``base-sepolia``)
|
|
16
|
-
* - Optimism (``optimism``)
|
|
17
|
-
* - Optimism Goerli Testnet (``optimism-goerli``)
|
|
18
|
-
* - Optimism Sepolia Testnet (``optimism-sepolia``)
|
|
19
|
-
* - Polygon (``matic``)
|
|
20
|
-
* - Polygon Amoy Testnet (``matic-amoy``)
|
|
21
|
-
* - Polygon Mumbai Testnet (``matic-mumbai``)
|
|
22
|
-
*
|
|
23
|
-
* @_subsection: api/providers/thirdparty:Alchemy [providers-alchemy]
|
|
24
|
-
*/
|
|
25
|
-
import { defineProperties, resolveProperties, assert, assertArgument, FetchRequest } from "../utils/index.js";
|
|
26
|
-
import { showThrottleMessage } from "./community.js";
|
|
27
|
-
import { Network } from "./network.js";
|
|
28
|
-
import { JsonRpcProvider } from "./provider-jsonrpc.js";
|
|
29
|
-
const defaultApiKey = "_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";
|
|
30
|
-
function getHost(name) {
|
|
31
|
-
switch (name) {
|
|
32
|
-
case "mainnet":
|
|
33
|
-
return "eth-mainnet.alchemyapi.io";
|
|
34
|
-
case "goerli":
|
|
35
|
-
return "eth-goerli.g.alchemy.com";
|
|
36
|
-
case "sepolia":
|
|
37
|
-
return "eth-sepolia.g.alchemy.com";
|
|
38
|
-
case "arbitrum":
|
|
39
|
-
return "arb-mainnet.g.alchemy.com";
|
|
40
|
-
case "arbitrum-goerli":
|
|
41
|
-
return "arb-goerli.g.alchemy.com";
|
|
42
|
-
case "arbitrum-sepolia":
|
|
43
|
-
return "arb-sepolia.g.alchemy.com";
|
|
44
|
-
case "base":
|
|
45
|
-
return "base-mainnet.g.alchemy.com";
|
|
46
|
-
case "base-goerli":
|
|
47
|
-
return "base-goerli.g.alchemy.com";
|
|
48
|
-
case "base-sepolia":
|
|
49
|
-
return "base-sepolia.g.alchemy.com";
|
|
50
|
-
case "matic":
|
|
51
|
-
return "polygon-mainnet.g.alchemy.com";
|
|
52
|
-
case "matic-amoy":
|
|
53
|
-
return "polygon-amoy.g.alchemy.com";
|
|
54
|
-
case "matic-mumbai":
|
|
55
|
-
return "polygon-mumbai.g.alchemy.com";
|
|
56
|
-
case "optimism":
|
|
57
|
-
return "opt-mainnet.g.alchemy.com";
|
|
58
|
-
case "optimism-goerli":
|
|
59
|
-
return "opt-goerli.g.alchemy.com";
|
|
60
|
-
case "optimism-sepolia":
|
|
61
|
-
return "opt-sepolia.g.alchemy.com";
|
|
62
|
-
}
|
|
63
|
-
assertArgument(false, "unsupported network", "network", name);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* The **AlchemyProvider** connects to the [[link-alchemy]]
|
|
67
|
-
* JSON-RPC end-points.
|
|
68
|
-
*
|
|
69
|
-
* By default, a highly-throttled API key is used, which is
|
|
70
|
-
* appropriate for quick prototypes and simple scripts. To
|
|
71
|
-
* gain access to an increased rate-limit, it is highly
|
|
72
|
-
* recommended to [sign up here](link-alchemy-signup).
|
|
73
|
-
*
|
|
74
|
-
* @_docloc: api/providers/thirdparty
|
|
75
|
-
*/
|
|
76
|
-
export class AlchemyProvider extends JsonRpcProvider {
|
|
77
|
-
apiKey;
|
|
78
|
-
constructor(_network, apiKey) {
|
|
79
|
-
if (_network == null) {
|
|
80
|
-
_network = "mainnet";
|
|
81
|
-
}
|
|
82
|
-
const network = Network.from(_network);
|
|
83
|
-
if (apiKey == null) {
|
|
84
|
-
apiKey = defaultApiKey;
|
|
85
|
-
}
|
|
86
|
-
const request = AlchemyProvider.getRequest(network, apiKey);
|
|
87
|
-
super(request, network, { staticNetwork: network });
|
|
88
|
-
defineProperties(this, { apiKey });
|
|
89
|
-
}
|
|
90
|
-
_getProvider(chainId) {
|
|
91
|
-
try {
|
|
92
|
-
return new AlchemyProvider(chainId, this.apiKey);
|
|
93
|
-
}
|
|
94
|
-
catch (error) { }
|
|
95
|
-
return super._getProvider(chainId);
|
|
96
|
-
}
|
|
97
|
-
async _perform(req) {
|
|
98
|
-
// https://docs.alchemy.com/reference/trace-transaction
|
|
99
|
-
if (req.method === "getTransactionResult") {
|
|
100
|
-
const { trace, tx } = await resolveProperties({
|
|
101
|
-
trace: this.send("trace_transaction", [req.hash]),
|
|
102
|
-
tx: this.getTransaction(req.hash)
|
|
103
|
-
});
|
|
104
|
-
if (trace == null || tx == null) {
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
|
-
let data;
|
|
108
|
-
let error = false;
|
|
109
|
-
try {
|
|
110
|
-
data = trace[0].result.output;
|
|
111
|
-
error = (trace[0].error === "Reverted");
|
|
112
|
-
}
|
|
113
|
-
catch (error) { }
|
|
114
|
-
if (data) {
|
|
115
|
-
assert(!error, "an error occurred during transaction executions", "CALL_EXCEPTION", {
|
|
116
|
-
action: "getTransactionResult",
|
|
117
|
-
data,
|
|
118
|
-
reason: null,
|
|
119
|
-
transaction: tx,
|
|
120
|
-
invocation: null,
|
|
121
|
-
revert: null // @TODO
|
|
122
|
-
});
|
|
123
|
-
return data;
|
|
124
|
-
}
|
|
125
|
-
assert(false, "could not parse trace result", "BAD_DATA", { value: trace });
|
|
126
|
-
}
|
|
127
|
-
return await super._perform(req);
|
|
128
|
-
}
|
|
129
|
-
isCommunityResource() {
|
|
130
|
-
return (this.apiKey === defaultApiKey);
|
|
131
|
-
}
|
|
132
|
-
static getRequest(network, apiKey) {
|
|
133
|
-
if (apiKey == null) {
|
|
134
|
-
apiKey = defaultApiKey;
|
|
135
|
-
}
|
|
136
|
-
const request = new FetchRequest(`https:/\/${getHost(network.name)}/v2/${apiKey}`);
|
|
137
|
-
request.allowGzip = true;
|
|
138
|
-
if (apiKey === defaultApiKey) {
|
|
139
|
-
request.retryFunc = async (request, response, attempt) => {
|
|
140
|
-
showThrottleMessage("alchemy");
|
|
141
|
-
return true;
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
return request;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
//# sourceMappingURL=provider-alchemy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider-alchemy.js","sourceRoot":"","sources":["../../src.ts/providers/provider-alchemy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACH,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,EAAE,cAAc,EAC3D,YAAY,EACf,MAA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
|
-
* various blockchains over JSON-RPC.
|
|
4
|
-
*
|
|
5
|
-
* **Supported Networks**
|
|
6
|
-
*
|
|
7
|
-
* - Ethereum Mainnet (``mainnet``)
|
|
8
|
-
* - Goerli Testnet (``goerli``)
|
|
9
|
-
* - Sepolia Testnet (``sepolia``)
|
|
10
|
-
* - Arbitrum (``arbitrum``)
|
|
11
|
-
* - Base (``base``)
|
|
12
|
-
* - Base Goerlia Testnet (``base-goerli``)
|
|
13
|
-
* - Base Sepolia Testnet (``base-sepolia``)
|
|
14
|
-
* - BNB (``bnb``)
|
|
15
|
-
* - BNB Testnet (``bnbt``)
|
|
16
|
-
* - Optimism (``optimism``)
|
|
17
|
-
* - Optimism Goerli Testnet (``optimism-goerli``)
|
|
18
|
-
* - Optimism Sepolia Testnet (``optimism-sepolia``)
|
|
19
|
-
* - Polygon (``matic``)
|
|
20
|
-
* - Polygon Mumbai Testnet (``matic-mumbai``)
|
|
21
|
-
*
|
|
22
|
-
* @_subsection: api/providers/thirdparty:Ankr [providers-ankr]
|
|
23
|
-
*/
|
|
24
|
-
import { FetchRequest } from "../utils/index.js";
|
|
25
|
-
import { AbstractProvider } from "./abstract-provider.js";
|
|
26
|
-
import { Network } from "./network.js";
|
|
27
|
-
import { JsonRpcProvider } from "./provider-jsonrpc.js";
|
|
28
|
-
import type { CommunityResourcable } from "./community.js";
|
|
29
|
-
import type { Networkish } from "./network.js";
|
|
30
|
-
import type { JsonRpcError, JsonRpcPayload } from "./provider-jsonrpc.js";
|
|
31
|
-
/**
|
|
32
|
-
* The **AnkrProvider** connects to the [[link-ankr]]
|
|
33
|
-
* JSON-RPC end-points.
|
|
34
|
-
*
|
|
35
|
-
* By default, a highly-throttled API key is used, which is
|
|
36
|
-
* appropriate for quick prototypes and simple scripts. To
|
|
37
|
-
* gain access to an increased rate-limit, it is highly
|
|
38
|
-
* recommended to [sign up here](link-ankr-signup).
|
|
39
|
-
*/
|
|
40
|
-
export declare class AnkrProvider extends JsonRpcProvider implements CommunityResourcable {
|
|
41
|
-
/**
|
|
42
|
-
* The API key for the Ankr connection.
|
|
43
|
-
*/
|
|
44
|
-
readonly apiKey: string;
|
|
45
|
-
/**
|
|
46
|
-
* Create a new **AnkrProvider**.
|
|
47
|
-
*
|
|
48
|
-
* By default connecting to ``mainnet`` with a highly throttled
|
|
49
|
-
* API key.
|
|
50
|
-
*/
|
|
51
|
-
constructor(_network?: Networkish, apiKey?: null | string);
|
|
52
|
-
_getProvider(chainId: number): AbstractProvider;
|
|
53
|
-
/**
|
|
54
|
-
* Returns a prepared request for connecting to %%network%% with
|
|
55
|
-
* %%apiKey%%.
|
|
56
|
-
*/
|
|
57
|
-
static getRequest(network: Network, apiKey?: null | string): FetchRequest;
|
|
58
|
-
getRpcError(payload: JsonRpcPayload, error: JsonRpcError): Error;
|
|
59
|
-
isCommunityResource(): boolean;
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=provider-ankr.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider-ankr.d.ts","sourceRoot":"","sources":["../../src.ts/providers/provider-ankr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EACe,YAAY,EACjC,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AA0C1E;;;;;;;;GAQG;AACH,qBAAa,YAAa,SAAQ,eAAgB,YAAW,oBAAoB;IAE7E;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAG,MAAM,CAAC;IAEzB;;;;;OAKG;gBACS,QAAQ,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM;IAczD,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB;IAO/C;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,YAAY;IAgBzE,WAAW,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,GAAG,KAAK;IAUhE,mBAAmB,IAAI,OAAO;CAGjC"}
|