@0xpolygonid/js-sdk 1.16.1 → 1.17.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/dist/browser/esm/index.js +1384 -365
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +1381 -362
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/iden3comm/handlers/credential-proposal.js +2 -1
- package/dist/node/cjs/iden3comm/handlers/message-handler.js +3 -3
- package/dist/node/cjs/iden3comm/handlers/revocation-status.js +3 -3
- package/dist/node/cjs/identity/identity-wallet.js +64 -32
- package/dist/node/cjs/kms/key-providers/bjj-provider.js +8 -0
- package/dist/node/cjs/kms/key-providers/ed25519-provider.js +8 -0
- package/dist/node/cjs/kms/key-providers/secp256k1-provider.js +8 -0
- package/dist/node/cjs/kms/kms.js +13 -0
- package/dist/node/cjs/kms/store/indexed-db-key-store.js +10 -0
- package/dist/node/cjs/kms/store/local-storage-key-store.js +14 -0
- package/dist/node/cjs/kms/store/memory-key-store.js +3 -0
- package/dist/node/cjs/storage/blockchain/state.js +1 -1
- package/dist/node/esm/iden3comm/handlers/credential-proposal.js +2 -1
- package/dist/node/esm/iden3comm/handlers/message-handler.js +3 -3
- package/dist/node/esm/iden3comm/handlers/revocation-status.js +3 -3
- package/dist/node/esm/identity/identity-wallet.js +64 -32
- package/dist/node/esm/kms/key-providers/bjj-provider.js +8 -0
- package/dist/node/esm/kms/key-providers/ed25519-provider.js +8 -0
- package/dist/node/esm/kms/key-providers/secp256k1-provider.js +8 -0
- package/dist/node/esm/kms/kms.js +13 -0
- package/dist/node/esm/kms/store/indexed-db-key-store.js +11 -1
- package/dist/node/esm/kms/store/local-storage-key-store.js +14 -0
- package/dist/node/esm/kms/store/memory-key-store.js +3 -0
- package/dist/node/esm/storage/blockchain/state.js +1 -1
- package/dist/types/iden3comm/handlers/message-handler.d.ts +1 -1
- package/dist/types/iden3comm/handlers/revocation-status.d.ts +2 -2
- package/dist/types/identity/identity-wallet.d.ts +1 -0
- package/dist/types/kms/key-providers/bjj-provider.d.ts +8 -0
- package/dist/types/kms/key-providers/ed25519-provider.d.ts +8 -0
- package/dist/types/kms/key-providers/secp256k1-provider.d.ts +8 -0
- package/dist/types/kms/kms.d.ts +19 -0
- package/dist/types/kms/store/abstract-key-store.d.ts +10 -0
- package/dist/types/kms/store/indexed-db-key-store.d.ts +10 -0
- package/dist/types/kms/store/local-storage-key-store.d.ts +10 -0
- package/dist/types/kms/store/memory-key-store.d.ts +4 -0
- package/package.json +2 -2
|
@@ -4,7 +4,7 @@ export { jsIden3Core as core };
|
|
|
4
4
|
import { Path, Merklizer, getDocumentLoader } from '@iden3/js-jsonld-merklization';
|
|
5
5
|
import * as jsJsonldMerklization from '@iden3/js-jsonld-merklization';
|
|
6
6
|
export { jsJsonldMerklization as jsonLDMerklizer };
|
|
7
|
-
import { base58ToBytes as base58ToBytes$2, base58FromBytes, Hex, PrivateKey, PublicKey, Signature as Signature$1, sha256 as sha256$
|
|
7
|
+
import { base58ToBytes as base58ToBytes$2, base58FromBytes, Hex, PrivateKey, PublicKey, Signature as Signature$1, sha256 as sha256$4, poseidon, getRandomBytes, Poseidon } from '@iden3/js-crypto';
|
|
8
8
|
import { Hash as Hash$2, Proof, verifyProof, rootFromProof, ZERO_HASH, swapEndianness as swapEndianness$1, Merkletree, InMemoryDB, str2Bytes, LocalStorageDB, IndexedDBStorage, testBit, NodeLeaf, NODE_TYPE_LEAF, hashElems } from '@iden3/js-merkletree';
|
|
9
9
|
import { groth16 } from 'snarkjs';
|
|
10
10
|
import { getCurveFromName } from 'ffjavascript';
|
|
@@ -89,6 +89,19 @@ class KMS {
|
|
|
89
89
|
}
|
|
90
90
|
return keyProvider.verify(data, signatureHex, keyId);
|
|
91
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* get all keys by key type
|
|
94
|
+
*
|
|
95
|
+
* @param keyType - Key type
|
|
96
|
+
* @returns list of keys
|
|
97
|
+
*/
|
|
98
|
+
list(keyType) {
|
|
99
|
+
const keyProvider = this._registry.get(keyType);
|
|
100
|
+
if (!keyProvider) {
|
|
101
|
+
throw new Error(`keyProvider not found for: ${keyType}`);
|
|
102
|
+
}
|
|
103
|
+
return keyProvider.list();
|
|
104
|
+
}
|
|
92
105
|
}
|
|
93
106
|
|
|
94
107
|
/**
|
|
@@ -112,6 +125,9 @@ class InMemoryPrivateKeyStore {
|
|
|
112
125
|
constructor() {
|
|
113
126
|
this._data = new Map();
|
|
114
127
|
}
|
|
128
|
+
list() {
|
|
129
|
+
return Promise.resolve(Array.from(this._data).map(([alias, key]) => ({ alias, key })));
|
|
130
|
+
}
|
|
115
131
|
async get(args) {
|
|
116
132
|
const privateKey = this._data.get(args.alias);
|
|
117
133
|
if (!privateKey) {
|
|
@@ -145,6 +161,20 @@ var KmsKeyType;
|
|
|
145
161
|
* @implements implements AbstractPrivateKeyStore interface
|
|
146
162
|
*/
|
|
147
163
|
class LocalStoragePrivateKeyStore {
|
|
164
|
+
/**
|
|
165
|
+
* get all keys
|
|
166
|
+
*
|
|
167
|
+
* @abstract
|
|
168
|
+
* @returns `Promise<{ alias: string; key: string }[]>`
|
|
169
|
+
*/
|
|
170
|
+
list() {
|
|
171
|
+
const dataStr = localStorage.getItem(LocalStoragePrivateKeyStore.storageKey);
|
|
172
|
+
if (!dataStr) {
|
|
173
|
+
throw new Error('no key under given alias');
|
|
174
|
+
}
|
|
175
|
+
const data = JSON.parse(dataStr);
|
|
176
|
+
return data.map((i) => ({ alias: i.id, key: i.value }));
|
|
177
|
+
}
|
|
148
178
|
/**
|
|
149
179
|
* Gets key from the local storage
|
|
150
180
|
*
|
|
@@ -266,6 +296,25 @@ function values(customStore = defaultGetStore()) {
|
|
|
266
296
|
return eachCursor(store, (cursor) => items.push(cursor.value)).then(() => items);
|
|
267
297
|
});
|
|
268
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* Get all entries in the store. Each entry is an array of `[key, value]`.
|
|
301
|
+
*
|
|
302
|
+
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
303
|
+
*/
|
|
304
|
+
function entries(customStore = defaultGetStore()) {
|
|
305
|
+
return customStore('readonly', (store) => {
|
|
306
|
+
// Fast path for modern browsers
|
|
307
|
+
// (although, hopefully we'll get a simpler path some day)
|
|
308
|
+
if (store.getAll && store.getAllKeys) {
|
|
309
|
+
return Promise.all([
|
|
310
|
+
promisifyRequest(store.getAllKeys()),
|
|
311
|
+
promisifyRequest(store.getAll()),
|
|
312
|
+
]).then(([keys, values]) => keys.map((key, i) => [key, values[i]]));
|
|
313
|
+
}
|
|
314
|
+
const items = [];
|
|
315
|
+
return customStore('readonly', (store) => eachCursor(store, (cursor) => items.push([cursor.key, cursor.value])).then(() => items));
|
|
316
|
+
});
|
|
317
|
+
}
|
|
269
318
|
|
|
270
319
|
/**
|
|
271
320
|
* Allows storing keys in the indexed db storage of the browser
|
|
@@ -279,6 +328,16 @@ class IndexedDBPrivateKeyStore {
|
|
|
279
328
|
constructor() {
|
|
280
329
|
this._store = createStore(`${IndexedDBPrivateKeyStore.storageKey}-db`, IndexedDBPrivateKeyStore.storageKey);
|
|
281
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* get all keys
|
|
333
|
+
*
|
|
334
|
+
* @abstract
|
|
335
|
+
* @returns `Promise<{ alias: string; key: string }[]>`
|
|
336
|
+
*/
|
|
337
|
+
async list() {
|
|
338
|
+
const allEntries = await entries(this._store);
|
|
339
|
+
return allEntries.map(([alias, key]) => ({ alias, key: key.value }));
|
|
340
|
+
}
|
|
282
341
|
/**
|
|
283
342
|
* Gets key from the indexed db storage
|
|
284
343
|
*
|
|
@@ -1743,6 +1802,14 @@ class BjjProvider {
|
|
|
1743
1802
|
this.keyType = keyType;
|
|
1744
1803
|
this.keyStore = keyStore;
|
|
1745
1804
|
}
|
|
1805
|
+
/**
|
|
1806
|
+
* get all keys
|
|
1807
|
+
* @returns list of keys
|
|
1808
|
+
*/
|
|
1809
|
+
async list() {
|
|
1810
|
+
const allKeysFromKeyStore = await this.keyStore.list();
|
|
1811
|
+
return allKeysFromKeyStore.filter((key) => key.alias.startsWith(this.keyType));
|
|
1812
|
+
}
|
|
1746
1813
|
/**
|
|
1747
1814
|
* generates a baby jub jub key from a seed phrase
|
|
1748
1815
|
* @param {Uint8Array} seed - byte array seed
|
|
@@ -2062,19 +2129,19 @@ function split$2(lst, le = false) {
|
|
|
2062
2129
|
}
|
|
2063
2130
|
return [Ah, Al];
|
|
2064
2131
|
}
|
|
2065
|
-
const toBig = (h, l) => (BigInt(h >>> 0) << _32n$1) | BigInt(l >>> 0);
|
|
2132
|
+
const toBig$1 = (h, l) => (BigInt(h >>> 0) << _32n$1) | BigInt(l >>> 0);
|
|
2066
2133
|
// for Shift in [0, 32)
|
|
2067
|
-
const shrSH = (h, _l, s) => h >>> s;
|
|
2068
|
-
const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
2134
|
+
const shrSH$1 = (h, _l, s) => h >>> s;
|
|
2135
|
+
const shrSL$1 = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
2069
2136
|
// Right rotate for Shift in [1, 32)
|
|
2070
|
-
const rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));
|
|
2071
|
-
const rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
2137
|
+
const rotrSH$1 = (h, l, s) => (h >>> s) | (l << (32 - s));
|
|
2138
|
+
const rotrSL$1 = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
2072
2139
|
// Right rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
2073
|
-
const rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));
|
|
2074
|
-
const rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));
|
|
2140
|
+
const rotrBH$1 = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));
|
|
2141
|
+
const rotrBL$1 = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));
|
|
2075
2142
|
// Right rotate for shift===32 (just swaps l&h)
|
|
2076
|
-
const rotr32H = (_h, l) => l;
|
|
2077
|
-
const rotr32L = (h, _l) => h;
|
|
2143
|
+
const rotr32H$1 = (_h, l) => l;
|
|
2144
|
+
const rotr32L$1 = (h, _l) => h;
|
|
2078
2145
|
// Left rotate for Shift in [1, 32)
|
|
2079
2146
|
const rotlSH$1 = (h, l, s) => (h << s) | (l >>> (32 - s));
|
|
2080
2147
|
const rotlSL$1 = (h, l, s) => (l << s) | (h >>> (32 - s));
|
|
@@ -2083,30 +2150,30 @@ const rotlBH$1 = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
|
|
|
2083
2150
|
const rotlBL$1 = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
|
|
2084
2151
|
// JS uses 32-bit signed integers for bitwise operations which means we cannot
|
|
2085
2152
|
// simple take carry out of low bit sum by shift, we need to use division.
|
|
2086
|
-
function add(Ah, Al, Bh, Bl) {
|
|
2153
|
+
function add$1(Ah, Al, Bh, Bl) {
|
|
2087
2154
|
const l = (Al >>> 0) + (Bl >>> 0);
|
|
2088
2155
|
return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };
|
|
2089
2156
|
}
|
|
2090
2157
|
// Addition with more than 2 elements
|
|
2091
|
-
const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
2092
|
-
const add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;
|
|
2093
|
-
const add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
2094
|
-
const add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;
|
|
2095
|
-
const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
2096
|
-
const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
|
|
2158
|
+
const add3L$1 = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
2159
|
+
const add3H$1 = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;
|
|
2160
|
+
const add4L$1 = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
2161
|
+
const add4H$1 = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;
|
|
2162
|
+
const add5L$1 = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
2163
|
+
const add5H$1 = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
|
|
2097
2164
|
// prettier-ignore
|
|
2098
|
-
const u64 = {
|
|
2099
|
-
fromBig: fromBig$1, split: split$2, toBig,
|
|
2100
|
-
shrSH, shrSL,
|
|
2101
|
-
rotrSH, rotrSL, rotrBH, rotrBL,
|
|
2102
|
-
rotr32H, rotr32L,
|
|
2165
|
+
const u64$1 = {
|
|
2166
|
+
fromBig: fromBig$1, split: split$2, toBig: toBig$1,
|
|
2167
|
+
shrSH: shrSH$1, shrSL: shrSL$1,
|
|
2168
|
+
rotrSH: rotrSH$1, rotrSL: rotrSL$1, rotrBH: rotrBH$1, rotrBL: rotrBL$1,
|
|
2169
|
+
rotr32H: rotr32H$1, rotr32L: rotr32L$1,
|
|
2103
2170
|
rotlSH: rotlSH$1, rotlSL: rotlSL$1, rotlBH: rotlBH$1, rotlBL: rotlBL$1,
|
|
2104
|
-
add, add3L, add3H, add4L, add4H, add5H, add5L,
|
|
2171
|
+
add: add$1, add3L: add3L$1, add3H: add3H$1, add4L: add4L$1, add4H: add4H$1, add5H: add5H$1, add5L: add5L$1,
|
|
2105
2172
|
};
|
|
2106
2173
|
|
|
2107
2174
|
// Round contants (first 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409):
|
|
2108
2175
|
// prettier-ignore
|
|
2109
|
-
const [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => u64.split([
|
|
2176
|
+
const [SHA512_Kh$1, SHA512_Kl$1] = /* @__PURE__ */ (() => u64$1.split([
|
|
2110
2177
|
'0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc',
|
|
2111
2178
|
'0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118',
|
|
2112
2179
|
'0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2',
|
|
@@ -2129,9 +2196,9 @@ const [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => u64.split([
|
|
|
2129
2196
|
'0x4cc5d4becb3e42b6', '0x597f299cfc657e2a', '0x5fcb6fab3ad6faec', '0x6c44198c4a475817'
|
|
2130
2197
|
].map(n => BigInt(n))))();
|
|
2131
2198
|
// Temporary buffer, not used to store anything between runs
|
|
2132
|
-
const SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
|
|
2133
|
-
const SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
|
|
2134
|
-
class SHA512 extends HashMD {
|
|
2199
|
+
const SHA512_W_H$1 = /* @__PURE__ */ new Uint32Array(80);
|
|
2200
|
+
const SHA512_W_L$1 = /* @__PURE__ */ new Uint32Array(80);
|
|
2201
|
+
let SHA512$1 = class SHA512 extends HashMD {
|
|
2135
2202
|
constructor() {
|
|
2136
2203
|
super(128, 64, 16, false);
|
|
2137
2204
|
// We cannot use array here since array allows indexing by variable which means optimizer/compiler cannot use registers.
|
|
@@ -2182,43 +2249,43 @@ class SHA512 extends HashMD {
|
|
|
2182
2249
|
process(view, offset) {
|
|
2183
2250
|
// Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array
|
|
2184
2251
|
for (let i = 0; i < 16; i++, offset += 4) {
|
|
2185
|
-
SHA512_W_H[i] = view.getUint32(offset);
|
|
2186
|
-
SHA512_W_L[i] = view.getUint32((offset += 4));
|
|
2252
|
+
SHA512_W_H$1[i] = view.getUint32(offset);
|
|
2253
|
+
SHA512_W_L$1[i] = view.getUint32((offset += 4));
|
|
2187
2254
|
}
|
|
2188
2255
|
for (let i = 16; i < 80; i++) {
|
|
2189
2256
|
// s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7)
|
|
2190
|
-
const W15h = SHA512_W_H[i - 15] | 0;
|
|
2191
|
-
const W15l = SHA512_W_L[i - 15] | 0;
|
|
2192
|
-
const s0h = u64.rotrSH(W15h, W15l, 1) ^ u64.rotrSH(W15h, W15l, 8) ^ u64.shrSH(W15h, W15l, 7);
|
|
2193
|
-
const s0l = u64.rotrSL(W15h, W15l, 1) ^ u64.rotrSL(W15h, W15l, 8) ^ u64.shrSL(W15h, W15l, 7);
|
|
2257
|
+
const W15h = SHA512_W_H$1[i - 15] | 0;
|
|
2258
|
+
const W15l = SHA512_W_L$1[i - 15] | 0;
|
|
2259
|
+
const s0h = u64$1.rotrSH(W15h, W15l, 1) ^ u64$1.rotrSH(W15h, W15l, 8) ^ u64$1.shrSH(W15h, W15l, 7);
|
|
2260
|
+
const s0l = u64$1.rotrSL(W15h, W15l, 1) ^ u64$1.rotrSL(W15h, W15l, 8) ^ u64$1.shrSL(W15h, W15l, 7);
|
|
2194
2261
|
// s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6)
|
|
2195
|
-
const W2h = SHA512_W_H[i - 2] | 0;
|
|
2196
|
-
const W2l = SHA512_W_L[i - 2] | 0;
|
|
2197
|
-
const s1h = u64.rotrSH(W2h, W2l, 19) ^ u64.rotrBH(W2h, W2l, 61) ^ u64.shrSH(W2h, W2l, 6);
|
|
2198
|
-
const s1l = u64.rotrSL(W2h, W2l, 19) ^ u64.rotrBL(W2h, W2l, 61) ^ u64.shrSL(W2h, W2l, 6);
|
|
2262
|
+
const W2h = SHA512_W_H$1[i - 2] | 0;
|
|
2263
|
+
const W2l = SHA512_W_L$1[i - 2] | 0;
|
|
2264
|
+
const s1h = u64$1.rotrSH(W2h, W2l, 19) ^ u64$1.rotrBH(W2h, W2l, 61) ^ u64$1.shrSH(W2h, W2l, 6);
|
|
2265
|
+
const s1l = u64$1.rotrSL(W2h, W2l, 19) ^ u64$1.rotrBL(W2h, W2l, 61) ^ u64$1.shrSL(W2h, W2l, 6);
|
|
2199
2266
|
// SHA256_W[i] = s0 + s1 + SHA256_W[i - 7] + SHA256_W[i - 16];
|
|
2200
|
-
const SUMl = u64.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
|
|
2201
|
-
const SUMh = u64.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);
|
|
2202
|
-
SHA512_W_H[i] = SUMh | 0;
|
|
2203
|
-
SHA512_W_L[i] = SUMl | 0;
|
|
2267
|
+
const SUMl = u64$1.add4L(s0l, s1l, SHA512_W_L$1[i - 7], SHA512_W_L$1[i - 16]);
|
|
2268
|
+
const SUMh = u64$1.add4H(SUMl, s0h, s1h, SHA512_W_H$1[i - 7], SHA512_W_H$1[i - 16]);
|
|
2269
|
+
SHA512_W_H$1[i] = SUMh | 0;
|
|
2270
|
+
SHA512_W_L$1[i] = SUMl | 0;
|
|
2204
2271
|
}
|
|
2205
2272
|
let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
2206
2273
|
// Compression function main loop, 80 rounds
|
|
2207
2274
|
for (let i = 0; i < 80; i++) {
|
|
2208
2275
|
// S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41)
|
|
2209
|
-
const sigma1h = u64.rotrSH(Eh, El, 14) ^ u64.rotrSH(Eh, El, 18) ^ u64.rotrBH(Eh, El, 41);
|
|
2210
|
-
const sigma1l = u64.rotrSL(Eh, El, 14) ^ u64.rotrSL(Eh, El, 18) ^ u64.rotrBL(Eh, El, 41);
|
|
2276
|
+
const sigma1h = u64$1.rotrSH(Eh, El, 14) ^ u64$1.rotrSH(Eh, El, 18) ^ u64$1.rotrBH(Eh, El, 41);
|
|
2277
|
+
const sigma1l = u64$1.rotrSL(Eh, El, 14) ^ u64$1.rotrSL(Eh, El, 18) ^ u64$1.rotrBL(Eh, El, 41);
|
|
2211
2278
|
//const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
|
2212
2279
|
const CHIh = (Eh & Fh) ^ (~Eh & Gh);
|
|
2213
2280
|
const CHIl = (El & Fl) ^ (~El & Gl);
|
|
2214
2281
|
// T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i]
|
|
2215
2282
|
// prettier-ignore
|
|
2216
|
-
const T1ll = u64.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
|
|
2217
|
-
const T1h = u64.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
|
|
2283
|
+
const T1ll = u64$1.add5L(Hl, sigma1l, CHIl, SHA512_Kl$1[i], SHA512_W_L$1[i]);
|
|
2284
|
+
const T1h = u64$1.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh$1[i], SHA512_W_H$1[i]);
|
|
2218
2285
|
const T1l = T1ll | 0;
|
|
2219
2286
|
// S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39)
|
|
2220
|
-
const sigma0h = u64.rotrSH(Ah, Al, 28) ^ u64.rotrBH(Ah, Al, 34) ^ u64.rotrBH(Ah, Al, 39);
|
|
2221
|
-
const sigma0l = u64.rotrSL(Ah, Al, 28) ^ u64.rotrBL(Ah, Al, 34) ^ u64.rotrBL(Ah, Al, 39);
|
|
2287
|
+
const sigma0h = u64$1.rotrSH(Ah, Al, 28) ^ u64$1.rotrBH(Ah, Al, 34) ^ u64$1.rotrBH(Ah, Al, 39);
|
|
2288
|
+
const sigma0l = u64$1.rotrSL(Ah, Al, 28) ^ u64$1.rotrBL(Ah, Al, 34) ^ u64$1.rotrBL(Ah, Al, 39);
|
|
2222
2289
|
const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch);
|
|
2223
2290
|
const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl);
|
|
2224
2291
|
Hh = Gh | 0;
|
|
@@ -2227,38 +2294,38 @@ class SHA512 extends HashMD {
|
|
|
2227
2294
|
Gl = Fl | 0;
|
|
2228
2295
|
Fh = Eh | 0;
|
|
2229
2296
|
Fl = El | 0;
|
|
2230
|
-
({ h: Eh, l: El } = u64.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
|
2297
|
+
({ h: Eh, l: El } = u64$1.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
|
2231
2298
|
Dh = Ch | 0;
|
|
2232
2299
|
Dl = Cl | 0;
|
|
2233
2300
|
Ch = Bh | 0;
|
|
2234
2301
|
Cl = Bl | 0;
|
|
2235
2302
|
Bh = Ah | 0;
|
|
2236
2303
|
Bl = Al | 0;
|
|
2237
|
-
const All = u64.add3L(T1l, sigma0l, MAJl);
|
|
2238
|
-
Ah = u64.add3H(All, T1h, sigma0h, MAJh);
|
|
2304
|
+
const All = u64$1.add3L(T1l, sigma0l, MAJl);
|
|
2305
|
+
Ah = u64$1.add3H(All, T1h, sigma0h, MAJh);
|
|
2239
2306
|
Al = All | 0;
|
|
2240
2307
|
}
|
|
2241
2308
|
// Add the compressed chunk to the current hash value
|
|
2242
|
-
({ h: Ah, l: Al } = u64.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
|
2243
|
-
({ h: Bh, l: Bl } = u64.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
|
2244
|
-
({ h: Ch, l: Cl } = u64.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
|
2245
|
-
({ h: Dh, l: Dl } = u64.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
|
2246
|
-
({ h: Eh, l: El } = u64.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
|
2247
|
-
({ h: Fh, l: Fl } = u64.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
|
2248
|
-
({ h: Gh, l: Gl } = u64.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
|
2249
|
-
({ h: Hh, l: Hl } = u64.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
|
2309
|
+
({ h: Ah, l: Al } = u64$1.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
|
2310
|
+
({ h: Bh, l: Bl } = u64$1.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
|
2311
|
+
({ h: Ch, l: Cl } = u64$1.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
|
2312
|
+
({ h: Dh, l: Dl } = u64$1.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
|
2313
|
+
({ h: Eh, l: El } = u64$1.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
|
2314
|
+
({ h: Fh, l: Fl } = u64$1.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
|
2315
|
+
({ h: Gh, l: Gl } = u64$1.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
|
2316
|
+
({ h: Hh, l: Hl } = u64$1.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
|
2250
2317
|
this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
|
|
2251
2318
|
}
|
|
2252
2319
|
roundClean() {
|
|
2253
|
-
SHA512_W_H.fill(0);
|
|
2254
|
-
SHA512_W_L.fill(0);
|
|
2320
|
+
SHA512_W_H$1.fill(0);
|
|
2321
|
+
SHA512_W_L$1.fill(0);
|
|
2255
2322
|
}
|
|
2256
2323
|
destroy() {
|
|
2257
2324
|
this.buffer.fill(0);
|
|
2258
2325
|
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
2259
2326
|
}
|
|
2260
|
-
}
|
|
2261
|
-
const sha512 = /* @__PURE__ */ wrapConstructor$1(() => new SHA512());
|
|
2327
|
+
};
|
|
2328
|
+
const sha512$1 = /* @__PURE__ */ wrapConstructor$1(() => new SHA512$1());
|
|
2262
2329
|
|
|
2263
2330
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2264
2331
|
// 100 lines of code in the file are duplicated from noble-hashes (utils).
|
|
@@ -3587,7 +3654,7 @@ const ed25519Defaults = {
|
|
|
3587
3654
|
// Base point (x, y) aka generator point
|
|
3588
3655
|
Gx: BigInt('15112221349535400772501151409588531511454012693041857206046113283949847762202'),
|
|
3589
3656
|
Gy: BigInt('46316835694926478169428394003475163141307993866256225615783033603165251855960'),
|
|
3590
|
-
hash: sha512,
|
|
3657
|
+
hash: sha512$1,
|
|
3591
3658
|
randomBytes: randomBytes$1,
|
|
3592
3659
|
adjustScalarBytes,
|
|
3593
3660
|
// dom2
|
|
@@ -3631,6 +3698,14 @@ class Ed25519Provider {
|
|
|
3631
3698
|
this.keyType = keyType;
|
|
3632
3699
|
this._keyStore = _keyStore;
|
|
3633
3700
|
}
|
|
3701
|
+
/**
|
|
3702
|
+
* get all keys
|
|
3703
|
+
* @returns list of keys
|
|
3704
|
+
*/
|
|
3705
|
+
async list() {
|
|
3706
|
+
const allKeysFromKeyStore = await this._keyStore.list();
|
|
3707
|
+
return allKeysFromKeyStore.filter((key) => key.alias.startsWith(this.keyType));
|
|
3708
|
+
}
|
|
3634
3709
|
/**
|
|
3635
3710
|
* generates a ed25519 key from a seed phrase
|
|
3636
3711
|
* @param {Uint8Array} seed - byte array seed
|
|
@@ -3796,7 +3871,7 @@ let SHA256$1 = class SHA256 extends HashMD {
|
|
|
3796
3871
|
* SHA2-256 hash function
|
|
3797
3872
|
* @param message - data that would be hashed
|
|
3798
3873
|
*/
|
|
3799
|
-
const sha256$
|
|
3874
|
+
const sha256$3 = /* @__PURE__ */ wrapConstructor$1(() => new SHA256$1());
|
|
3800
3875
|
|
|
3801
3876
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3802
3877
|
// Short Weierstrass curve. The formula is: y² = x³ + ax + b
|
|
@@ -4899,7 +4974,7 @@ const secp256k1$1 = createCurve$1({
|
|
|
4899
4974
|
return { k1neg, k1, k2neg, k2 };
|
|
4900
4975
|
},
|
|
4901
4976
|
},
|
|
4902
|
-
}, sha256$
|
|
4977
|
+
}, sha256$3);
|
|
4903
4978
|
// Schnorr signatures are superior to ECDSA from above. Below is Schnorr-specific BIP0340 code.
|
|
4904
4979
|
// https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki
|
|
4905
4980
|
BigInt(0);
|
|
@@ -6178,7 +6253,7 @@ const p256 = createCurve$1({
|
|
|
6178
6253
|
Gy: BigInt('0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5'),
|
|
6179
6254
|
h: BigInt(1),
|
|
6180
6255
|
lowS: false,
|
|
6181
|
-
}, sha256$
|
|
6256
|
+
}, sha256$3);
|
|
6182
6257
|
|
|
6183
6258
|
// https://homes.esat.kuleuven.be/~bosselae/ripemd160.html
|
|
6184
6259
|
// https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf
|
|
@@ -6956,9 +7031,9 @@ function leftpad(data, size = 64) {
|
|
|
6956
7031
|
return '0'.repeat(size - data.length) + data;
|
|
6957
7032
|
}
|
|
6958
7033
|
|
|
6959
|
-
function sha256$
|
|
7034
|
+
function sha256$2(payload) {
|
|
6960
7035
|
const data = typeof payload === 'string' ? fromString(payload) : payload;
|
|
6961
|
-
return sha256$
|
|
7036
|
+
return sha256$3(data);
|
|
6962
7037
|
}
|
|
6963
7038
|
const keccak = keccak_256$1;
|
|
6964
7039
|
function toEthereumAddress(hexPublicKey) {
|
|
@@ -6991,7 +7066,7 @@ function ES256KSigner(privateKey, recoverable = false) {
|
|
|
6991
7066
|
|
|
6992
7067
|
return function (data) {
|
|
6993
7068
|
try {
|
|
6994
|
-
const signature = secp256k1$1.sign(sha256$
|
|
7069
|
+
const signature = secp256k1$1.sign(sha256$2(data), privateKeyBytes);
|
|
6995
7070
|
return Promise.resolve(toJose({
|
|
6996
7071
|
r: leftpad(signature.r.toString(16)),
|
|
6997
7072
|
s: leftpad(signature.s.toString(16)),
|
|
@@ -7007,10 +7082,10 @@ function publicKeyToAddress$1(publicKey, otherAddress) {
|
|
|
7007
7082
|
// Use the same version/prefix byte as the given address.
|
|
7008
7083
|
const version = bytesToHex$1(base58ToBytes(otherAddress).slice(0, 1));
|
|
7009
7084
|
const publicKeyBuffer = hexToBytes$1(publicKey);
|
|
7010
|
-
const publicKeyHash = ripemd160(sha256$
|
|
7085
|
+
const publicKeyHash = ripemd160(sha256$2(publicKeyBuffer));
|
|
7011
7086
|
const step1 = version + bytesToHex$1(publicKeyHash);
|
|
7012
|
-
const step2 = sha256$
|
|
7013
|
-
const step3 = sha256$
|
|
7087
|
+
const step2 = sha256$2(hexToBytes$1(step1));
|
|
7088
|
+
const step3 = sha256$2(step2);
|
|
7014
7089
|
const checksum = bytesToHex$1(step3).substring(0, 8);
|
|
7015
7090
|
const step4 = step1 + checksum;
|
|
7016
7091
|
return bytesToBase58(hexToBytes$1(step4));
|
|
@@ -7018,7 +7093,7 @@ function publicKeyToAddress$1(publicKey, otherAddress) {
|
|
|
7018
7093
|
|
|
7019
7094
|
function publicKeyToAddress(publicKey, prefix) {
|
|
7020
7095
|
const publicKeyBuffer = secp256k1$1.ProjectivePoint.fromHex(publicKey).toRawBytes();
|
|
7021
|
-
const hash = ripemd160(sha256$
|
|
7096
|
+
const hash = ripemd160(sha256$2(publicKeyBuffer));
|
|
7022
7097
|
const words = bech32.toWords(hash);
|
|
7023
7098
|
return bech32.encode(prefix, words).replace(prefix, '');
|
|
7024
7099
|
}
|
|
@@ -7083,7 +7158,7 @@ function toSignatureObject2(signature, recoverable = false) {
|
|
|
7083
7158
|
};
|
|
7084
7159
|
}
|
|
7085
7160
|
function verifyES256(data, signature, authenticators) {
|
|
7086
|
-
const hash = sha256$
|
|
7161
|
+
const hash = sha256$2(data);
|
|
7087
7162
|
const sig = p256.Signature.fromCompact(toSignatureObject2(signature).compact);
|
|
7088
7163
|
const fullPublicKeys = authenticators.filter(a => !a.ethereumAddress && !a.blockchainAccountId);
|
|
7089
7164
|
const signer = fullPublicKeys.find(pk => {
|
|
@@ -7100,7 +7175,7 @@ function verifyES256(data, signature, authenticators) {
|
|
|
7100
7175
|
return signer;
|
|
7101
7176
|
}
|
|
7102
7177
|
function verifyES256K(data, signature, authenticators) {
|
|
7103
|
-
const hash = sha256$
|
|
7178
|
+
const hash = sha256$2(data);
|
|
7104
7179
|
const signatureNormalized = secp256k1$1.Signature.fromCompact(base64ToBytes(signature)).normalizeS();
|
|
7105
7180
|
const fullPublicKeys = authenticators.filter(a => {
|
|
7106
7181
|
return !a.ethereumAddress && !a.blockchainAccountId;
|
|
@@ -7141,7 +7216,7 @@ function verifyRecoverableES256K(data, signature, authenticators) {
|
|
|
7141
7216
|
});
|
|
7142
7217
|
}
|
|
7143
7218
|
|
|
7144
|
-
const hash = sha256$
|
|
7219
|
+
const hash = sha256$2(data);
|
|
7145
7220
|
|
|
7146
7221
|
const checkSignatureAgainstSigner = sigObj => {
|
|
7147
7222
|
const signature = secp256k1$1.Signature.fromCompact(sigObj.compact).addRecoveryBit(sigObj.recovery || 0);
|
|
@@ -7270,6 +7345,14 @@ class Sec256k1Provider {
|
|
|
7270
7345
|
this.keyType = keyType;
|
|
7271
7346
|
this._keyStore = keyStore;
|
|
7272
7347
|
}
|
|
7348
|
+
/**
|
|
7349
|
+
* get all keys
|
|
7350
|
+
* @returns list of keys
|
|
7351
|
+
*/
|
|
7352
|
+
async list() {
|
|
7353
|
+
const allKeysFromKeyStore = await this._keyStore.list();
|
|
7354
|
+
return allKeysFromKeyStore.filter((key) => key.alias.startsWith(this.keyType));
|
|
7355
|
+
}
|
|
7273
7356
|
/**
|
|
7274
7357
|
* generates a baby jub jub key from a seed phrase
|
|
7275
7358
|
* @param {Uint8Array} seed - byte array seed
|
|
@@ -7324,7 +7407,7 @@ class Sec256k1Provider {
|
|
|
7324
7407
|
*/
|
|
7325
7408
|
async verify(message, signatureHex, keyId) {
|
|
7326
7409
|
const publicKeyHex = await this.publicKey(keyId);
|
|
7327
|
-
return secp256k1$1.verify(signatureHex, sha256$
|
|
7410
|
+
return secp256k1$1.verify(signatureHex, sha256$4(message), publicKeyHex);
|
|
7328
7411
|
}
|
|
7329
7412
|
async privateKey(keyId) {
|
|
7330
7413
|
return this._keyStore.get({ alias: keyId.id });
|
|
@@ -29949,7 +30032,7 @@ const cacheLoader = (opts) => {
|
|
|
29949
30032
|
/**
|
|
29950
30033
|
* The current version of Ethers.
|
|
29951
30034
|
*/
|
|
29952
|
-
const version = "6.
|
|
30035
|
+
const version = "6.13.1";
|
|
29953
30036
|
|
|
29954
30037
|
/**
|
|
29955
30038
|
* Property helper functions.
|
|
@@ -30055,7 +30138,7 @@ function stringify(value) {
|
|
|
30055
30138
|
* Returns true if the %%error%% matches an error thrown by ethers
|
|
30056
30139
|
* that matches the error %%code%%.
|
|
30057
30140
|
*
|
|
30058
|
-
* In TypeScript
|
|
30141
|
+
* In TypeScript environments, this can be used to check that %%error%%
|
|
30059
30142
|
* matches an EthersError type, which means the expected properties will
|
|
30060
30143
|
* be set.
|
|
30061
30144
|
*
|
|
@@ -30081,13 +30164,13 @@ function isCallException(error) {
|
|
|
30081
30164
|
}
|
|
30082
30165
|
/**
|
|
30083
30166
|
* Returns a new Error configured to the format ethers emits errors, with
|
|
30084
|
-
* the %%message%%, [[api:ErrorCode]] %%code%% and
|
|
30167
|
+
* the %%message%%, [[api:ErrorCode]] %%code%% and additional properties
|
|
30085
30168
|
* for the corresponding EthersError.
|
|
30086
30169
|
*
|
|
30087
30170
|
* Each error in ethers includes the version of ethers, a
|
|
30088
|
-
* machine-readable [[ErrorCode]], and
|
|
30089
|
-
* required properties. The error message will also include the %%
|
|
30090
|
-
* ethers version, %%code%% and all
|
|
30171
|
+
* machine-readable [[ErrorCode]], and depending on %%code%%, additional
|
|
30172
|
+
* required properties. The error message will also include the %%message%%,
|
|
30173
|
+
* ethers version, %%code%% and all additional properties, serialized.
|
|
30091
30174
|
*/
|
|
30092
30175
|
function makeError(message, code, info) {
|
|
30093
30176
|
let shortMessage = message;
|
|
@@ -30169,7 +30252,7 @@ function assertArgumentCount(count, expectedCount, message) {
|
|
|
30169
30252
|
count: count,
|
|
30170
30253
|
expectedCount: expectedCount
|
|
30171
30254
|
});
|
|
30172
|
-
assert(count <= expectedCount, "too many
|
|
30255
|
+
assert(count <= expectedCount, "too many arguments" + message, "UNEXPECTED_ARGUMENT", {
|
|
30173
30256
|
count: count,
|
|
30174
30257
|
expectedCount: expectedCount
|
|
30175
30258
|
});
|
|
@@ -30239,7 +30322,7 @@ function _getBytes(value, name, copy) {
|
|
|
30239
30322
|
}
|
|
30240
30323
|
return value;
|
|
30241
30324
|
}
|
|
30242
|
-
if (typeof (value) === "string" && value.match(/^0x([0-9a-f][0-9a-f])*$/i)) {
|
|
30325
|
+
if (typeof (value) === "string" && value.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)) {
|
|
30243
30326
|
const result = new Uint8Array((value.length - 2) / 2);
|
|
30244
30327
|
let offset = 2;
|
|
30245
30328
|
for (let i = 0; i < result.length; i++) {
|
|
@@ -30548,7 +30631,7 @@ function toBeHex(_value, _width) {
|
|
|
30548
30631
|
}
|
|
30549
30632
|
else {
|
|
30550
30633
|
const width = getNumber(_width, "width");
|
|
30551
|
-
assert(width * 2 >= result.length, `value exceeds width (${width}
|
|
30634
|
+
assert(width * 2 >= result.length, `value exceeds width (${width} bytes)`, "NUMERIC_FAULT", {
|
|
30552
30635
|
operation: "toBeHex",
|
|
30553
30636
|
fault: "overflow",
|
|
30554
30637
|
value: _value
|
|
@@ -30617,12 +30700,20 @@ const BN_58 = BigInt(58);
|
|
|
30617
30700
|
* Encode %%value%% as a Base58-encoded string.
|
|
30618
30701
|
*/
|
|
30619
30702
|
function encodeBase58(_value) {
|
|
30620
|
-
|
|
30703
|
+
const bytes = getBytes(_value);
|
|
30704
|
+
let value = toBigInt(bytes);
|
|
30621
30705
|
let result = "";
|
|
30622
30706
|
while (value) {
|
|
30623
30707
|
result = Alphabet[Number(value % BN_58)] + result;
|
|
30624
30708
|
value /= BN_58;
|
|
30625
30709
|
}
|
|
30710
|
+
// Account for leading padding zeros
|
|
30711
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
30712
|
+
if (bytes[i]) {
|
|
30713
|
+
break;
|
|
30714
|
+
}
|
|
30715
|
+
result = Alphabet[0] + result;
|
|
30716
|
+
}
|
|
30626
30717
|
return result;
|
|
30627
30718
|
}
|
|
30628
30719
|
|
|
@@ -30839,6 +30930,7 @@ function getUtf8CodePoints(_bytes, onError) {
|
|
|
30839
30930
|
* If %%form%% is specified, the string is normalized.
|
|
30840
30931
|
*/
|
|
30841
30932
|
function toUtf8Bytes(str, form) {
|
|
30933
|
+
assertArgument(typeof (str) === "string", "invalid string value", "str", str);
|
|
30842
30934
|
if (form != null) {
|
|
30843
30935
|
assertNormalize(form);
|
|
30844
30936
|
str = str.normalize(form);
|
|
@@ -30893,9 +30985,9 @@ function toUtf8String(bytes, onError) {
|
|
|
30893
30985
|
return _toUtf8String(getUtf8CodePoints(bytes, onError));
|
|
30894
30986
|
}
|
|
30895
30987
|
|
|
30896
|
-
// @TODO: timeout is completely ignored; start a Promise.any with a reject?
|
|
30897
30988
|
function createGetUrl(options) {
|
|
30898
30989
|
async function getUrl(req, _signal) {
|
|
30990
|
+
assert(_signal == null || !_signal.cancelled, "request cancelled before sending", "CANCELLED");
|
|
30899
30991
|
const protocol = req.url.split(":")[0].toLowerCase();
|
|
30900
30992
|
assert(protocol === "http" || protocol === "https", `unsupported protocol ${protocol}`, "UNSUPPORTED_OPERATION", {
|
|
30901
30993
|
info: { protocol },
|
|
@@ -30904,19 +30996,36 @@ function createGetUrl(options) {
|
|
|
30904
30996
|
assert(protocol === "https" || !req.credentials || req.allowInsecureAuthentication, "insecure authorized connections unsupported", "UNSUPPORTED_OPERATION", {
|
|
30905
30997
|
operation: "request"
|
|
30906
30998
|
});
|
|
30907
|
-
let
|
|
30999
|
+
let error = null;
|
|
31000
|
+
const controller = new AbortController();
|
|
31001
|
+
const timer = setTimeout(() => {
|
|
31002
|
+
error = makeError("request timeout", "TIMEOUT");
|
|
31003
|
+
controller.abort();
|
|
31004
|
+
}, req.timeout);
|
|
30908
31005
|
if (_signal) {
|
|
30909
|
-
|
|
30910
|
-
|
|
30911
|
-
|
|
31006
|
+
_signal.addListener(() => {
|
|
31007
|
+
error = makeError("request cancelled", "CANCELLED");
|
|
31008
|
+
controller.abort();
|
|
31009
|
+
});
|
|
30912
31010
|
}
|
|
30913
31011
|
const init = {
|
|
30914
31012
|
method: req.method,
|
|
30915
31013
|
headers: new Headers(Array.from(req)),
|
|
30916
31014
|
body: req.body || undefined,
|
|
30917
|
-
signal
|
|
31015
|
+
signal: controller.signal
|
|
30918
31016
|
};
|
|
30919
|
-
|
|
31017
|
+
let resp;
|
|
31018
|
+
try {
|
|
31019
|
+
resp = await fetch(req.url, init);
|
|
31020
|
+
}
|
|
31021
|
+
catch (_error) {
|
|
31022
|
+
clearTimeout(timer);
|
|
31023
|
+
if (error) {
|
|
31024
|
+
throw error;
|
|
31025
|
+
}
|
|
31026
|
+
throw _error;
|
|
31027
|
+
}
|
|
31028
|
+
clearTimeout(timer);
|
|
30920
31029
|
const headers = {};
|
|
30921
31030
|
resp.headers.forEach((value, key) => {
|
|
30922
31031
|
headers[key.toLowerCase()] = value;
|
|
@@ -30934,7 +31043,7 @@ function createGetUrl(options) {
|
|
|
30934
31043
|
|
|
30935
31044
|
/**
|
|
30936
31045
|
* Fetching content from the web is environment-specific, so Ethers
|
|
30937
|
-
* provides an abstraction
|
|
31046
|
+
* provides an abstraction that each environment can implement to provide
|
|
30938
31047
|
* this service.
|
|
30939
31048
|
*
|
|
30940
31049
|
* On [Node.js](link-node), the ``http`` and ``https`` libs are used to
|
|
@@ -30942,10 +31051,10 @@ function createGetUrl(options) {
|
|
|
30942
31051
|
* and populate the [[FetchResponse]].
|
|
30943
31052
|
*
|
|
30944
31053
|
* In a browser, the [DOM fetch](link-js-fetch) is used, and the resulting
|
|
30945
|
-
* ``Promise`` is waited on to
|
|
31054
|
+
* ``Promise`` is waited on to retrieve the payload.
|
|
30946
31055
|
*
|
|
30947
31056
|
* The [[FetchRequest]] is responsible for handling many common situations,
|
|
30948
|
-
* such as redirects, server throttling,
|
|
31057
|
+
* such as redirects, server throttling, authentication, etc.
|
|
30949
31058
|
*
|
|
30950
31059
|
* It also handles common gateways, such as IPFS and data URIs.
|
|
30951
31060
|
*
|
|
@@ -31069,7 +31178,7 @@ class FetchRequest {
|
|
|
31069
31178
|
#throttle;
|
|
31070
31179
|
#getUrlFunc;
|
|
31071
31180
|
/**
|
|
31072
|
-
* The fetch
|
|
31181
|
+
* The fetch URL to request.
|
|
31073
31182
|
*/
|
|
31074
31183
|
get url() { return this.#url; }
|
|
31075
31184
|
set url(url) {
|
|
@@ -31083,15 +31192,15 @@ class FetchRequest {
|
|
|
31083
31192
|
* header.
|
|
31084
31193
|
*
|
|
31085
31194
|
* If %%body%% is null, the body is cleared (along with the
|
|
31086
|
-
* intrinsic ``Content-Type``)
|
|
31195
|
+
* intrinsic ``Content-Type``).
|
|
31087
31196
|
*
|
|
31088
|
-
* If %%body%% is a string, the
|
|
31197
|
+
* If %%body%% is a string, the intrinsic ``Content-Type`` is set to
|
|
31089
31198
|
* ``text/plain``.
|
|
31090
31199
|
*
|
|
31091
|
-
* If %%body%% is a Uint8Array, the
|
|
31200
|
+
* If %%body%% is a Uint8Array, the intrinsic ``Content-Type`` is set to
|
|
31092
31201
|
* ``application/octet-stream``.
|
|
31093
31202
|
*
|
|
31094
|
-
* If %%body%% is any other object, the
|
|
31203
|
+
* If %%body%% is any other object, the intrinsic ``Content-Type`` is
|
|
31095
31204
|
* set to ``application/json``.
|
|
31096
31205
|
*/
|
|
31097
31206
|
get body() {
|
|
@@ -31151,7 +31260,7 @@ class FetchRequest {
|
|
|
31151
31260
|
* The headers that will be used when requesting the URI. All
|
|
31152
31261
|
* keys are lower-case.
|
|
31153
31262
|
*
|
|
31154
|
-
* This object is a copy, so any
|
|
31263
|
+
* This object is a copy, so any changes will **NOT** be reflected
|
|
31155
31264
|
* in the ``FetchRequest``.
|
|
31156
31265
|
*
|
|
31157
31266
|
* To set a header entry, use the ``setHeader`` method.
|
|
@@ -31243,7 +31352,7 @@ class FetchRequest {
|
|
|
31243
31352
|
this.#allowInsecure = !!value;
|
|
31244
31353
|
}
|
|
31245
31354
|
/**
|
|
31246
|
-
* The timeout (in milliseconds) to wait for a
|
|
31355
|
+
* The timeout (in milliseconds) to wait for a complete response.
|
|
31247
31356
|
* //(default: 5 minutes)//
|
|
31248
31357
|
*/
|
|
31249
31358
|
get timeout() { return this.#timeout; }
|
|
@@ -31450,7 +31559,7 @@ class FetchRequest {
|
|
|
31450
31559
|
* to %%location%%.
|
|
31451
31560
|
*/
|
|
31452
31561
|
redirect(location) {
|
|
31453
|
-
// Redirection; for now we only support absolute
|
|
31562
|
+
// Redirection; for now we only support absolute locations
|
|
31454
31563
|
const current = this.url.split(":")[0].toLowerCase();
|
|
31455
31564
|
const target = location.split(":")[0].toLowerCase();
|
|
31456
31565
|
// Don't allow redirecting:
|
|
@@ -31502,6 +31611,7 @@ class FetchRequest {
|
|
|
31502
31611
|
clone.#preflight = this.#preflight;
|
|
31503
31612
|
clone.#process = this.#process;
|
|
31504
31613
|
clone.#retry = this.#retry;
|
|
31614
|
+
clone.#throttle = Object.assign({}, this.#throttle);
|
|
31505
31615
|
clone.#getUrlFunc = this.#getUrlFunc;
|
|
31506
31616
|
return clone;
|
|
31507
31617
|
}
|
|
@@ -31588,7 +31698,7 @@ class FetchRequest {
|
|
|
31588
31698
|
}
|
|
31589
31699
|
}
|
|
31590
31700
|
/**
|
|
31591
|
-
* The response for a
|
|
31701
|
+
* The response for a FetchRequest.
|
|
31592
31702
|
*/
|
|
31593
31703
|
class FetchResponse {
|
|
31594
31704
|
#statusCode;
|
|
@@ -31718,7 +31828,7 @@ class FetchResponse {
|
|
|
31718
31828
|
return this.headers[key.toLowerCase()];
|
|
31719
31829
|
}
|
|
31720
31830
|
/**
|
|
31721
|
-
* Returns true
|
|
31831
|
+
* Returns true if the response has a body.
|
|
31722
31832
|
*/
|
|
31723
31833
|
hasBody() {
|
|
31724
31834
|
return (this.#body != null);
|
|
@@ -31744,8 +31854,23 @@ class FetchResponse {
|
|
|
31744
31854
|
if (message === "") {
|
|
31745
31855
|
message = `server response ${this.statusCode} ${this.statusMessage}`;
|
|
31746
31856
|
}
|
|
31857
|
+
let requestUrl = null;
|
|
31858
|
+
if (this.request) {
|
|
31859
|
+
requestUrl = this.request.url;
|
|
31860
|
+
}
|
|
31861
|
+
let responseBody = null;
|
|
31862
|
+
try {
|
|
31863
|
+
if (this.#body) {
|
|
31864
|
+
responseBody = toUtf8String(this.#body);
|
|
31865
|
+
}
|
|
31866
|
+
}
|
|
31867
|
+
catch (e) { }
|
|
31747
31868
|
assert(false, message, "SERVER_ERROR", {
|
|
31748
|
-
request: (this.request || "unknown request"), response: this, error
|
|
31869
|
+
request: (this.request || "unknown request"), response: this, error,
|
|
31870
|
+
info: {
|
|
31871
|
+
requestUrl, responseBody,
|
|
31872
|
+
responseStatus: `${this.statusCode} ${this.statusMessage}`
|
|
31873
|
+
}
|
|
31749
31874
|
});
|
|
31750
31875
|
}
|
|
31751
31876
|
}
|
|
@@ -31892,11 +32017,38 @@ const Padding = new Uint8Array(WordSize);
|
|
|
31892
32017
|
// - `then` is used to detect if an object is a Promise for await
|
|
31893
32018
|
const passProperties$1 = ["then"];
|
|
31894
32019
|
const _guard$2 = {};
|
|
32020
|
+
const resultNames = new WeakMap();
|
|
32021
|
+
function getNames(result) {
|
|
32022
|
+
return resultNames.get(result);
|
|
32023
|
+
}
|
|
32024
|
+
function setNames(result, names) {
|
|
32025
|
+
resultNames.set(result, names);
|
|
32026
|
+
}
|
|
31895
32027
|
function throwError(name, error) {
|
|
31896
32028
|
const wrapped = new Error(`deferred error during ABI decoding triggered accessing ${name}`);
|
|
31897
32029
|
wrapped.error = error;
|
|
31898
32030
|
throw wrapped;
|
|
31899
32031
|
}
|
|
32032
|
+
function toObject(names, items, deep) {
|
|
32033
|
+
if (names.indexOf(null) >= 0) {
|
|
32034
|
+
return items.map((item, index) => {
|
|
32035
|
+
if (item instanceof Result) {
|
|
32036
|
+
return toObject(getNames(item), item, deep);
|
|
32037
|
+
}
|
|
32038
|
+
return item;
|
|
32039
|
+
});
|
|
32040
|
+
}
|
|
32041
|
+
return names.reduce((accum, name, index) => {
|
|
32042
|
+
let item = items.getValue(name);
|
|
32043
|
+
if (!(name in accum)) {
|
|
32044
|
+
if (deep && item instanceof Result) {
|
|
32045
|
+
item = toObject(getNames(item), item, deep);
|
|
32046
|
+
}
|
|
32047
|
+
accum[name] = item;
|
|
32048
|
+
}
|
|
32049
|
+
return accum;
|
|
32050
|
+
}, {});
|
|
32051
|
+
}
|
|
31900
32052
|
/**
|
|
31901
32053
|
* A [[Result]] is a sub-class of Array, which allows accessing any
|
|
31902
32054
|
* of its values either positionally by its index or, if keys are
|
|
@@ -31905,6 +32057,9 @@ function throwError(name, error) {
|
|
|
31905
32057
|
* @_docloc: api/abi
|
|
31906
32058
|
*/
|
|
31907
32059
|
class Result extends Array {
|
|
32060
|
+
// No longer used; but cannot be removed as it will remove the
|
|
32061
|
+
// #private field from the .d.ts which may break backwards
|
|
32062
|
+
// compatibility
|
|
31908
32063
|
#names;
|
|
31909
32064
|
/**
|
|
31910
32065
|
* @private
|
|
@@ -31937,20 +32092,22 @@ class Result extends Array {
|
|
|
31937
32092
|
return accum;
|
|
31938
32093
|
}, (new Map()));
|
|
31939
32094
|
// Remove any key thats not unique
|
|
31940
|
-
this
|
|
32095
|
+
setNames(this, Object.freeze(items.map((item, index) => {
|
|
31941
32096
|
const name = names[index];
|
|
31942
32097
|
if (name != null && nameCounts.get(name) === 1) {
|
|
31943
32098
|
return name;
|
|
31944
32099
|
}
|
|
31945
32100
|
return null;
|
|
31946
|
-
}));
|
|
32101
|
+
})));
|
|
32102
|
+
// Dummy operations to prevent TypeScript from complaining
|
|
32103
|
+
this.#names = [];
|
|
31947
32104
|
if (!wrap) {
|
|
31948
32105
|
return;
|
|
31949
32106
|
}
|
|
31950
32107
|
// A wrapped Result is immutable
|
|
31951
32108
|
Object.freeze(this);
|
|
31952
32109
|
// Proxy indices and names so we can trap deferred errors
|
|
31953
|
-
|
|
32110
|
+
const proxy = new Proxy(this, {
|
|
31954
32111
|
get: (target, prop, receiver) => {
|
|
31955
32112
|
if (typeof (prop) === "string") {
|
|
31956
32113
|
// Index accessor
|
|
@@ -31985,39 +32142,44 @@ class Result extends Array {
|
|
|
31985
32142
|
return Reflect.get(target, prop, receiver);
|
|
31986
32143
|
}
|
|
31987
32144
|
});
|
|
32145
|
+
setNames(proxy, getNames(this));
|
|
32146
|
+
return proxy;
|
|
31988
32147
|
}
|
|
31989
32148
|
/**
|
|
31990
|
-
* Returns the Result as a normal Array.
|
|
32149
|
+
* Returns the Result as a normal Array. If %%deep%%, any children
|
|
32150
|
+
* which are Result objects are also converted to a normal Array.
|
|
31991
32151
|
*
|
|
31992
32152
|
* This will throw if there are any outstanding deferred
|
|
31993
32153
|
* errors.
|
|
31994
32154
|
*/
|
|
31995
|
-
toArray() {
|
|
32155
|
+
toArray(deep) {
|
|
31996
32156
|
const result = [];
|
|
31997
32157
|
this.forEach((item, index) => {
|
|
31998
32158
|
if (item instanceof Error) {
|
|
31999
32159
|
throwError(`index ${index}`, item);
|
|
32000
32160
|
}
|
|
32161
|
+
if (deep && item instanceof Result) {
|
|
32162
|
+
item = item.toArray(deep);
|
|
32163
|
+
}
|
|
32001
32164
|
result.push(item);
|
|
32002
32165
|
});
|
|
32003
32166
|
return result;
|
|
32004
32167
|
}
|
|
32005
32168
|
/**
|
|
32006
|
-
* Returns the Result as an Object with each name-value pair.
|
|
32169
|
+
* Returns the Result as an Object with each name-value pair. If
|
|
32170
|
+
* %%deep%%, any children which are Result objects are also
|
|
32171
|
+
* converted to an Object.
|
|
32007
32172
|
*
|
|
32008
32173
|
* This will throw if any value is unnamed, or if there are
|
|
32009
32174
|
* any outstanding deferred errors.
|
|
32010
32175
|
*/
|
|
32011
|
-
toObject() {
|
|
32012
|
-
|
|
32013
|
-
|
|
32176
|
+
toObject(deep) {
|
|
32177
|
+
const names = getNames(this);
|
|
32178
|
+
return names.reduce((accum, name, index) => {
|
|
32179
|
+
assert(name != null, `value at index ${index} unnamed`, "UNSUPPORTED_OPERATION", {
|
|
32014
32180
|
operation: "toObject()"
|
|
32015
32181
|
});
|
|
32016
|
-
|
|
32017
|
-
if (!(name in accum)) {
|
|
32018
|
-
accum[name] = this.getValue(name);
|
|
32019
|
-
}
|
|
32020
|
-
return accum;
|
|
32182
|
+
return toObject(names, this, deep);
|
|
32021
32183
|
}, {});
|
|
32022
32184
|
}
|
|
32023
32185
|
/**
|
|
@@ -32045,10 +32207,11 @@ class Result extends Array {
|
|
|
32045
32207
|
if (end > this.length) {
|
|
32046
32208
|
end = this.length;
|
|
32047
32209
|
}
|
|
32210
|
+
const _names = getNames(this);
|
|
32048
32211
|
const result = [], names = [];
|
|
32049
32212
|
for (let i = start; i < end; i++) {
|
|
32050
32213
|
result.push(this[i]);
|
|
32051
|
-
names.push(
|
|
32214
|
+
names.push(_names[i]);
|
|
32052
32215
|
}
|
|
32053
32216
|
return new Result(_guard$2, result, names);
|
|
32054
32217
|
}
|
|
@@ -32056,6 +32219,7 @@ class Result extends Array {
|
|
|
32056
32219
|
* @_ignore
|
|
32057
32220
|
*/
|
|
32058
32221
|
filter(callback, thisArg) {
|
|
32222
|
+
const _names = getNames(this);
|
|
32059
32223
|
const result = [], names = [];
|
|
32060
32224
|
for (let i = 0; i < this.length; i++) {
|
|
32061
32225
|
const item = this[i];
|
|
@@ -32064,7 +32228,7 @@ class Result extends Array {
|
|
|
32064
32228
|
}
|
|
32065
32229
|
if (callback.call(thisArg, item, i, this)) {
|
|
32066
32230
|
result.push(item);
|
|
32067
|
-
names.push(
|
|
32231
|
+
names.push(_names[i]);
|
|
32068
32232
|
}
|
|
32069
32233
|
}
|
|
32070
32234
|
return new Result(_guard$2, result, names);
|
|
@@ -32092,7 +32256,7 @@ class Result extends Array {
|
|
|
32092
32256
|
* accessible by name.
|
|
32093
32257
|
*/
|
|
32094
32258
|
getValue(name) {
|
|
32095
|
-
const index = this
|
|
32259
|
+
const index = getNames(this).indexOf(name);
|
|
32096
32260
|
if (index === -1) {
|
|
32097
32261
|
return undefined;
|
|
32098
32262
|
}
|
|
@@ -32202,15 +32366,35 @@ class Reader {
|
|
|
32202
32366
|
allowLoose;
|
|
32203
32367
|
#data;
|
|
32204
32368
|
#offset;
|
|
32205
|
-
|
|
32369
|
+
#bytesRead;
|
|
32370
|
+
#parent;
|
|
32371
|
+
#maxInflation;
|
|
32372
|
+
constructor(data, allowLoose, maxInflation) {
|
|
32206
32373
|
defineProperties(this, { allowLoose: !!allowLoose });
|
|
32207
32374
|
this.#data = getBytesCopy(data);
|
|
32375
|
+
this.#bytesRead = 0;
|
|
32376
|
+
this.#parent = null;
|
|
32377
|
+
this.#maxInflation = (maxInflation != null) ? maxInflation : 1024;
|
|
32208
32378
|
this.#offset = 0;
|
|
32209
32379
|
}
|
|
32210
32380
|
get data() { return hexlify(this.#data); }
|
|
32211
32381
|
get dataLength() { return this.#data.length; }
|
|
32212
32382
|
get consumed() { return this.#offset; }
|
|
32213
32383
|
get bytes() { return new Uint8Array(this.#data); }
|
|
32384
|
+
#incrementBytesRead(count) {
|
|
32385
|
+
if (this.#parent) {
|
|
32386
|
+
return this.#parent.#incrementBytesRead(count);
|
|
32387
|
+
}
|
|
32388
|
+
this.#bytesRead += count;
|
|
32389
|
+
// Check for excessive inflation (see: #4537)
|
|
32390
|
+
assert(this.#maxInflation < 1 || this.#bytesRead <= this.#maxInflation * this.dataLength, `compressed ABI data exceeds inflation ratio of ${this.#maxInflation} ( see: https:/\/github.com/ethers-io/ethers.js/issues/4537 )`, "BUFFER_OVERRUN", {
|
|
32391
|
+
buffer: getBytesCopy(this.#data), offset: this.#offset,
|
|
32392
|
+
length: count, info: {
|
|
32393
|
+
bytesRead: this.#bytesRead,
|
|
32394
|
+
dataLength: this.dataLength
|
|
32395
|
+
}
|
|
32396
|
+
});
|
|
32397
|
+
}
|
|
32214
32398
|
#peekBytes(offset, length, loose) {
|
|
32215
32399
|
let alignedLength = Math.ceil(length / WordSize) * WordSize;
|
|
32216
32400
|
if (this.#offset + alignedLength > this.#data.length) {
|
|
@@ -32229,11 +32413,14 @@ class Reader {
|
|
|
32229
32413
|
}
|
|
32230
32414
|
// Create a sub-reader with the same underlying data, but offset
|
|
32231
32415
|
subReader(offset) {
|
|
32232
|
-
|
|
32416
|
+
const reader = new Reader(this.#data.slice(this.#offset + offset), this.allowLoose, this.#maxInflation);
|
|
32417
|
+
reader.#parent = this;
|
|
32418
|
+
return reader;
|
|
32233
32419
|
}
|
|
32234
32420
|
// Read bytes
|
|
32235
32421
|
readBytes(length, loose) {
|
|
32236
32422
|
let bytes = this.#peekBytes(0, length, !!loose);
|
|
32423
|
+
this.#incrementBytesRead(length);
|
|
32237
32424
|
this.#offset += bytes.length;
|
|
32238
32425
|
// @TODO: Make sure the length..end bytes are all 0?
|
|
32239
32426
|
return bytes.slice(0, length);
|
|
@@ -32649,7 +32836,7 @@ class SHA256 extends SHA2 {
|
|
|
32649
32836
|
* SHA2-256 hash function
|
|
32650
32837
|
* @param message - data that would be hashed
|
|
32651
32838
|
*/
|
|
32652
|
-
const sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
|
|
32839
|
+
const sha256$1 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
|
|
32653
32840
|
|
|
32654
32841
|
const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
32655
32842
|
const _32n = /* @__PURE__ */ BigInt(32);
|
|
@@ -32668,12 +32855,225 @@ function split$1(lst, le = false) {
|
|
|
32668
32855
|
}
|
|
32669
32856
|
return [Ah, Al];
|
|
32670
32857
|
}
|
|
32858
|
+
const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);
|
|
32859
|
+
// for Shift in [0, 32)
|
|
32860
|
+
const shrSH = (h, _l, s) => h >>> s;
|
|
32861
|
+
const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
32862
|
+
// Right rotate for Shift in [1, 32)
|
|
32863
|
+
const rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));
|
|
32864
|
+
const rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
32865
|
+
// Right rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
32866
|
+
const rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));
|
|
32867
|
+
const rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));
|
|
32868
|
+
// Right rotate for shift===32 (just swaps l&h)
|
|
32869
|
+
const rotr32H = (_h, l) => l;
|
|
32870
|
+
const rotr32L = (h, _l) => h;
|
|
32671
32871
|
// Left rotate for Shift in [1, 32)
|
|
32672
32872
|
const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
|
|
32673
32873
|
const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
|
|
32674
32874
|
// Left rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
32675
32875
|
const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
|
|
32676
32876
|
const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
|
|
32877
|
+
// JS uses 32-bit signed integers for bitwise operations which means we cannot
|
|
32878
|
+
// simple take carry out of low bit sum by shift, we need to use division.
|
|
32879
|
+
function add(Ah, Al, Bh, Bl) {
|
|
32880
|
+
const l = (Al >>> 0) + (Bl >>> 0);
|
|
32881
|
+
return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };
|
|
32882
|
+
}
|
|
32883
|
+
// Addition with more than 2 elements
|
|
32884
|
+
const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
32885
|
+
const add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;
|
|
32886
|
+
const add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
32887
|
+
const add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;
|
|
32888
|
+
const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
32889
|
+
const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
|
|
32890
|
+
// prettier-ignore
|
|
32891
|
+
const u64 = {
|
|
32892
|
+
fromBig, split: split$1, toBig,
|
|
32893
|
+
shrSH, shrSL,
|
|
32894
|
+
rotrSH, rotrSL, rotrBH, rotrBL,
|
|
32895
|
+
rotr32H, rotr32L,
|
|
32896
|
+
rotlSH, rotlSL, rotlBH, rotlBL,
|
|
32897
|
+
add, add3L, add3H, add4L, add4H, add5H, add5L,
|
|
32898
|
+
};
|
|
32899
|
+
|
|
32900
|
+
// Round contants (first 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409):
|
|
32901
|
+
// prettier-ignore
|
|
32902
|
+
const [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => u64.split([
|
|
32903
|
+
'0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc',
|
|
32904
|
+
'0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118',
|
|
32905
|
+
'0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2',
|
|
32906
|
+
'0x72be5d74f27b896f', '0x80deb1fe3b1696b1', '0x9bdc06a725c71235', '0xc19bf174cf692694',
|
|
32907
|
+
'0xe49b69c19ef14ad2', '0xefbe4786384f25e3', '0x0fc19dc68b8cd5b5', '0x240ca1cc77ac9c65',
|
|
32908
|
+
'0x2de92c6f592b0275', '0x4a7484aa6ea6e483', '0x5cb0a9dcbd41fbd4', '0x76f988da831153b5',
|
|
32909
|
+
'0x983e5152ee66dfab', '0xa831c66d2db43210', '0xb00327c898fb213f', '0xbf597fc7beef0ee4',
|
|
32910
|
+
'0xc6e00bf33da88fc2', '0xd5a79147930aa725', '0x06ca6351e003826f', '0x142929670a0e6e70',
|
|
32911
|
+
'0x27b70a8546d22ffc', '0x2e1b21385c26c926', '0x4d2c6dfc5ac42aed', '0x53380d139d95b3df',
|
|
32912
|
+
'0x650a73548baf63de', '0x766a0abb3c77b2a8', '0x81c2c92e47edaee6', '0x92722c851482353b',
|
|
32913
|
+
'0xa2bfe8a14cf10364', '0xa81a664bbc423001', '0xc24b8b70d0f89791', '0xc76c51a30654be30',
|
|
32914
|
+
'0xd192e819d6ef5218', '0xd69906245565a910', '0xf40e35855771202a', '0x106aa07032bbd1b8',
|
|
32915
|
+
'0x19a4c116b8d2d0c8', '0x1e376c085141ab53', '0x2748774cdf8eeb99', '0x34b0bcb5e19b48a8',
|
|
32916
|
+
'0x391c0cb3c5c95a63', '0x4ed8aa4ae3418acb', '0x5b9cca4f7763e373', '0x682e6ff3d6b2b8a3',
|
|
32917
|
+
'0x748f82ee5defb2fc', '0x78a5636f43172f60', '0x84c87814a1f0ab72', '0x8cc702081a6439ec',
|
|
32918
|
+
'0x90befffa23631e28', '0xa4506cebde82bde9', '0xbef9a3f7b2c67915', '0xc67178f2e372532b',
|
|
32919
|
+
'0xca273eceea26619c', '0xd186b8c721c0c207', '0xeada7dd6cde0eb1e', '0xf57d4f7fee6ed178',
|
|
32920
|
+
'0x06f067aa72176fba', '0x0a637dc5a2c898a6', '0x113f9804bef90dae', '0x1b710b35131c471b',
|
|
32921
|
+
'0x28db77f523047d84', '0x32caab7b40c72493', '0x3c9ebe0a15c9bebc', '0x431d67c49c100d4c',
|
|
32922
|
+
'0x4cc5d4becb3e42b6', '0x597f299cfc657e2a', '0x5fcb6fab3ad6faec', '0x6c44198c4a475817'
|
|
32923
|
+
].map(n => BigInt(n))))();
|
|
32924
|
+
// Temporary buffer, not used to store anything between runs
|
|
32925
|
+
const SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
|
|
32926
|
+
const SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
|
|
32927
|
+
class SHA512 extends SHA2 {
|
|
32928
|
+
constructor() {
|
|
32929
|
+
super(128, 64, 16, false);
|
|
32930
|
+
// We cannot use array here since array allows indexing by variable which means optimizer/compiler cannot use registers.
|
|
32931
|
+
// Also looks cleaner and easier to verify with spec.
|
|
32932
|
+
// Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):
|
|
32933
|
+
// h -- high 32 bits, l -- low 32 bits
|
|
32934
|
+
this.Ah = 0x6a09e667 | 0;
|
|
32935
|
+
this.Al = 0xf3bcc908 | 0;
|
|
32936
|
+
this.Bh = 0xbb67ae85 | 0;
|
|
32937
|
+
this.Bl = 0x84caa73b | 0;
|
|
32938
|
+
this.Ch = 0x3c6ef372 | 0;
|
|
32939
|
+
this.Cl = 0xfe94f82b | 0;
|
|
32940
|
+
this.Dh = 0xa54ff53a | 0;
|
|
32941
|
+
this.Dl = 0x5f1d36f1 | 0;
|
|
32942
|
+
this.Eh = 0x510e527f | 0;
|
|
32943
|
+
this.El = 0xade682d1 | 0;
|
|
32944
|
+
this.Fh = 0x9b05688c | 0;
|
|
32945
|
+
this.Fl = 0x2b3e6c1f | 0;
|
|
32946
|
+
this.Gh = 0x1f83d9ab | 0;
|
|
32947
|
+
this.Gl = 0xfb41bd6b | 0;
|
|
32948
|
+
this.Hh = 0x5be0cd19 | 0;
|
|
32949
|
+
this.Hl = 0x137e2179 | 0;
|
|
32950
|
+
}
|
|
32951
|
+
// prettier-ignore
|
|
32952
|
+
get() {
|
|
32953
|
+
const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
32954
|
+
return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];
|
|
32955
|
+
}
|
|
32956
|
+
// prettier-ignore
|
|
32957
|
+
set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {
|
|
32958
|
+
this.Ah = Ah | 0;
|
|
32959
|
+
this.Al = Al | 0;
|
|
32960
|
+
this.Bh = Bh | 0;
|
|
32961
|
+
this.Bl = Bl | 0;
|
|
32962
|
+
this.Ch = Ch | 0;
|
|
32963
|
+
this.Cl = Cl | 0;
|
|
32964
|
+
this.Dh = Dh | 0;
|
|
32965
|
+
this.Dl = Dl | 0;
|
|
32966
|
+
this.Eh = Eh | 0;
|
|
32967
|
+
this.El = El | 0;
|
|
32968
|
+
this.Fh = Fh | 0;
|
|
32969
|
+
this.Fl = Fl | 0;
|
|
32970
|
+
this.Gh = Gh | 0;
|
|
32971
|
+
this.Gl = Gl | 0;
|
|
32972
|
+
this.Hh = Hh | 0;
|
|
32973
|
+
this.Hl = Hl | 0;
|
|
32974
|
+
}
|
|
32975
|
+
process(view, offset) {
|
|
32976
|
+
// Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array
|
|
32977
|
+
for (let i = 0; i < 16; i++, offset += 4) {
|
|
32978
|
+
SHA512_W_H[i] = view.getUint32(offset);
|
|
32979
|
+
SHA512_W_L[i] = view.getUint32((offset += 4));
|
|
32980
|
+
}
|
|
32981
|
+
for (let i = 16; i < 80; i++) {
|
|
32982
|
+
// s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7)
|
|
32983
|
+
const W15h = SHA512_W_H[i - 15] | 0;
|
|
32984
|
+
const W15l = SHA512_W_L[i - 15] | 0;
|
|
32985
|
+
const s0h = u64.rotrSH(W15h, W15l, 1) ^ u64.rotrSH(W15h, W15l, 8) ^ u64.shrSH(W15h, W15l, 7);
|
|
32986
|
+
const s0l = u64.rotrSL(W15h, W15l, 1) ^ u64.rotrSL(W15h, W15l, 8) ^ u64.shrSL(W15h, W15l, 7);
|
|
32987
|
+
// s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6)
|
|
32988
|
+
const W2h = SHA512_W_H[i - 2] | 0;
|
|
32989
|
+
const W2l = SHA512_W_L[i - 2] | 0;
|
|
32990
|
+
const s1h = u64.rotrSH(W2h, W2l, 19) ^ u64.rotrBH(W2h, W2l, 61) ^ u64.shrSH(W2h, W2l, 6);
|
|
32991
|
+
const s1l = u64.rotrSL(W2h, W2l, 19) ^ u64.rotrBL(W2h, W2l, 61) ^ u64.shrSL(W2h, W2l, 6);
|
|
32992
|
+
// SHA256_W[i] = s0 + s1 + SHA256_W[i - 7] + SHA256_W[i - 16];
|
|
32993
|
+
const SUMl = u64.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
|
|
32994
|
+
const SUMh = u64.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);
|
|
32995
|
+
SHA512_W_H[i] = SUMh | 0;
|
|
32996
|
+
SHA512_W_L[i] = SUMl | 0;
|
|
32997
|
+
}
|
|
32998
|
+
let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
32999
|
+
// Compression function main loop, 80 rounds
|
|
33000
|
+
for (let i = 0; i < 80; i++) {
|
|
33001
|
+
// S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41)
|
|
33002
|
+
const sigma1h = u64.rotrSH(Eh, El, 14) ^ u64.rotrSH(Eh, El, 18) ^ u64.rotrBH(Eh, El, 41);
|
|
33003
|
+
const sigma1l = u64.rotrSL(Eh, El, 14) ^ u64.rotrSL(Eh, El, 18) ^ u64.rotrBL(Eh, El, 41);
|
|
33004
|
+
//const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
|
33005
|
+
const CHIh = (Eh & Fh) ^ (~Eh & Gh);
|
|
33006
|
+
const CHIl = (El & Fl) ^ (~El & Gl);
|
|
33007
|
+
// T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i]
|
|
33008
|
+
// prettier-ignore
|
|
33009
|
+
const T1ll = u64.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
|
|
33010
|
+
const T1h = u64.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
|
|
33011
|
+
const T1l = T1ll | 0;
|
|
33012
|
+
// S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39)
|
|
33013
|
+
const sigma0h = u64.rotrSH(Ah, Al, 28) ^ u64.rotrBH(Ah, Al, 34) ^ u64.rotrBH(Ah, Al, 39);
|
|
33014
|
+
const sigma0l = u64.rotrSL(Ah, Al, 28) ^ u64.rotrBL(Ah, Al, 34) ^ u64.rotrBL(Ah, Al, 39);
|
|
33015
|
+
const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch);
|
|
33016
|
+
const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl);
|
|
33017
|
+
Hh = Gh | 0;
|
|
33018
|
+
Hl = Gl | 0;
|
|
33019
|
+
Gh = Fh | 0;
|
|
33020
|
+
Gl = Fl | 0;
|
|
33021
|
+
Fh = Eh | 0;
|
|
33022
|
+
Fl = El | 0;
|
|
33023
|
+
({ h: Eh, l: El } = u64.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
|
33024
|
+
Dh = Ch | 0;
|
|
33025
|
+
Dl = Cl | 0;
|
|
33026
|
+
Ch = Bh | 0;
|
|
33027
|
+
Cl = Bl | 0;
|
|
33028
|
+
Bh = Ah | 0;
|
|
33029
|
+
Bl = Al | 0;
|
|
33030
|
+
const All = u64.add3L(T1l, sigma0l, MAJl);
|
|
33031
|
+
Ah = u64.add3H(All, T1h, sigma0h, MAJh);
|
|
33032
|
+
Al = All | 0;
|
|
33033
|
+
}
|
|
33034
|
+
// Add the compressed chunk to the current hash value
|
|
33035
|
+
({ h: Ah, l: Al } = u64.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
|
33036
|
+
({ h: Bh, l: Bl } = u64.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
|
33037
|
+
({ h: Ch, l: Cl } = u64.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
|
33038
|
+
({ h: Dh, l: Dl } = u64.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
|
33039
|
+
({ h: Eh, l: El } = u64.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
|
33040
|
+
({ h: Fh, l: Fl } = u64.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
|
33041
|
+
({ h: Gh, l: Gl } = u64.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
|
33042
|
+
({ h: Hh, l: Hl } = u64.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
|
33043
|
+
this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
|
|
33044
|
+
}
|
|
33045
|
+
roundClean() {
|
|
33046
|
+
SHA512_W_H.fill(0);
|
|
33047
|
+
SHA512_W_L.fill(0);
|
|
33048
|
+
}
|
|
33049
|
+
destroy() {
|
|
33050
|
+
this.buffer.fill(0);
|
|
33051
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
33052
|
+
}
|
|
33053
|
+
}
|
|
33054
|
+
const sha512 = /* @__PURE__ */ wrapConstructor(() => new SHA512());
|
|
33055
|
+
|
|
33056
|
+
/* Browser Crypto Shims */
|
|
33057
|
+
function getGlobal() {
|
|
33058
|
+
if (typeof self !== 'undefined') {
|
|
33059
|
+
return self;
|
|
33060
|
+
}
|
|
33061
|
+
if (typeof window !== 'undefined') {
|
|
33062
|
+
return window;
|
|
33063
|
+
}
|
|
33064
|
+
if (typeof global !== 'undefined') {
|
|
33065
|
+
return global;
|
|
33066
|
+
}
|
|
33067
|
+
throw new Error('unable to locate global object');
|
|
33068
|
+
}
|
|
33069
|
+
getGlobal();
|
|
33070
|
+
function createHash(algo) {
|
|
33071
|
+
switch (algo) {
|
|
33072
|
+
case "sha256": return sha256$1.create();
|
|
33073
|
+
case "sha512": return sha512.create();
|
|
33074
|
+
}
|
|
33075
|
+
assertArgument(false, "invalid hashing algorithm name", "algorithm", algo);
|
|
33076
|
+
}
|
|
32677
33077
|
|
|
32678
33078
|
// SHA3 (keccak) is based on a new design: basically, the internal state is bigger than output size.
|
|
32679
33079
|
// It's called a sponge function.
|
|
@@ -32912,6 +33312,43 @@ keccak256.register = function (func) {
|
|
|
32912
33312
|
};
|
|
32913
33313
|
Object.freeze(keccak256);
|
|
32914
33314
|
|
|
33315
|
+
const _sha256 = function (data) {
|
|
33316
|
+
return createHash("sha256").update(data).digest();
|
|
33317
|
+
};
|
|
33318
|
+
let __sha256 = _sha256;
|
|
33319
|
+
let locked256 = false;
|
|
33320
|
+
/**
|
|
33321
|
+
* Compute the cryptographic SHA2-256 hash of %%data%%.
|
|
33322
|
+
*
|
|
33323
|
+
* @_docloc: api/crypto:Hash Functions
|
|
33324
|
+
* @returns DataHexstring
|
|
33325
|
+
*
|
|
33326
|
+
* @example:
|
|
33327
|
+
* sha256("0x")
|
|
33328
|
+
* //_result:
|
|
33329
|
+
*
|
|
33330
|
+
* sha256("0x1337")
|
|
33331
|
+
* //_result:
|
|
33332
|
+
*
|
|
33333
|
+
* sha256(new Uint8Array([ 0x13, 0x37 ]))
|
|
33334
|
+
* //_result:
|
|
33335
|
+
*
|
|
33336
|
+
*/
|
|
33337
|
+
function sha256(_data) {
|
|
33338
|
+
const data = getBytes(_data, "data");
|
|
33339
|
+
return hexlify(__sha256(data));
|
|
33340
|
+
}
|
|
33341
|
+
sha256._ = _sha256;
|
|
33342
|
+
sha256.lock = function () { locked256 = true; };
|
|
33343
|
+
sha256.register = function (func) {
|
|
33344
|
+
if (locked256) {
|
|
33345
|
+
throw new Error("sha256 is locked");
|
|
33346
|
+
}
|
|
33347
|
+
__sha256 = func;
|
|
33348
|
+
};
|
|
33349
|
+
Object.freeze(sha256);
|
|
33350
|
+
Object.freeze(sha256);
|
|
33351
|
+
|
|
32915
33352
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
32916
33353
|
// 100 lines of code in the file are duplicated from noble-hashes (utils).
|
|
32917
33354
|
// This is OK: `abstract` directory does not use noble-hashes.
|
|
@@ -34727,7 +35164,7 @@ const secp256k1 = createCurve({
|
|
|
34727
35164
|
return { k1neg, k1, k2neg, k2 };
|
|
34728
35165
|
},
|
|
34729
35166
|
},
|
|
34730
|
-
}, sha256);
|
|
35167
|
+
}, sha256$1);
|
|
34731
35168
|
// Schnorr signatures are superior to ECDSA from above. Below is Schnorr-specific BIP0340 code.
|
|
34732
35169
|
// https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki
|
|
34733
35170
|
BigInt(0);
|
|
@@ -36481,7 +36918,7 @@ function id(value) {
|
|
|
36481
36918
|
return keccak256(toUtf8Bytes(value));
|
|
36482
36919
|
}
|
|
36483
36920
|
|
|
36484
|
-
// created 2023-09-
|
|
36921
|
+
// created 2023-09-25T01:01:55.148Z
|
|
36485
36922
|
// compressed base64-encoded blob for include-ens data
|
|
36486
36923
|
// source: https://github.com/adraffy/ens-normalize.js/blob/main/src/make.js
|
|
36487
36924
|
// see: https://github.com/adraffy/ens-normalize.js#security
|
|
@@ -36762,7 +37199,7 @@ function compare_arrays(a, b) {
|
|
|
36762
37199
|
return c;
|
|
36763
37200
|
}
|
|
36764
37201
|
|
|
36765
|
-
// created 2023-09-
|
|
37202
|
+
// created 2023-09-25T01:01:55.148Z
|
|
36766
37203
|
// compressed base64-encoded blob for include-nf data
|
|
36767
37204
|
// source: https://github.com/adraffy/ens-normalize.js/blob/main/src/make.js
|
|
36768
37205
|
// see: https://github.com/adraffy/ens-normalize.js#security
|
|
@@ -36978,6 +37415,7 @@ function init() {
|
|
|
36978
37415
|
let r = read_compressed_payload(COMPRESSED$1);
|
|
36979
37416
|
const read_sorted_array = () => read_sorted(r);
|
|
36980
37417
|
const read_sorted_set = () => new Set(read_sorted_array());
|
|
37418
|
+
const set_add_many = (set, v) => v.forEach(x => set.add(x));
|
|
36981
37419
|
|
|
36982
37420
|
MAPPED = new Map(read_mapped(r));
|
|
36983
37421
|
IGNORED = read_sorted_set(); // ignored characters are not valid, so just read raw codepoints
|
|
@@ -37000,13 +37438,20 @@ function init() {
|
|
|
37000
37438
|
|
|
37001
37439
|
let chunks = read_sorted_arrays(r);
|
|
37002
37440
|
let unrestricted = r();
|
|
37003
|
-
const read_chunked = () => new Set(read_sorted_array().flatMap(i => chunks[i]).concat(read_sorted_array()));
|
|
37441
|
+
//const read_chunked = () => new Set(read_sorted_array().flatMap(i => chunks[i]).concat(read_sorted_array()));
|
|
37442
|
+
const read_chunked = () => {
|
|
37443
|
+
// 20230921: build set in parts, 2x faster
|
|
37444
|
+
let set = new Set();
|
|
37445
|
+
read_sorted_array().forEach(i => set_add_many(set, chunks[i]));
|
|
37446
|
+
set_add_many(set, read_sorted_array());
|
|
37447
|
+
return set;
|
|
37448
|
+
};
|
|
37004
37449
|
GROUPS = read_array_while(i => {
|
|
37005
37450
|
// minifier property mangling seems unsafe
|
|
37006
37451
|
// so these are manually renamed to single chars
|
|
37007
37452
|
let N = read_array_while(r).map(x => x+0x60);
|
|
37008
37453
|
if (N.length) {
|
|
37009
|
-
let R = i >= unrestricted; //
|
|
37454
|
+
let R = i >= unrestricted; // unrestricted then restricted
|
|
37010
37455
|
N[0] -= 32; // capitalize
|
|
37011
37456
|
N = str_from_cps(N);
|
|
37012
37457
|
if (R) N=`Restricted[${N}]`;
|
|
@@ -37044,6 +37489,7 @@ function init() {
|
|
|
37044
37489
|
});
|
|
37045
37490
|
|
|
37046
37491
|
// compute confusable-extent complements
|
|
37492
|
+
// usage: WHOLE_MAP.get(cp).M.get(cp) = complement set
|
|
37047
37493
|
for (let {V, M} of new Set(WHOLE_MAP.values())) {
|
|
37048
37494
|
// connect all groups that have each whole character
|
|
37049
37495
|
let recs = [];
|
|
@@ -37055,34 +37501,37 @@ function init() {
|
|
|
37055
37501
|
recs.push(rec);
|
|
37056
37502
|
}
|
|
37057
37503
|
rec.V.push(cp);
|
|
37058
|
-
|
|
37504
|
+
set_add_many(rec.G, gs);
|
|
37059
37505
|
}
|
|
37060
37506
|
// per character cache groups which are not a member of the extent
|
|
37061
|
-
let union = recs.flatMap(x => Array_from(x.G));
|
|
37507
|
+
let union = recs.flatMap(x => Array_from(x.G)); // all of the groups used by this whole
|
|
37062
37508
|
for (let {G, V} of recs) {
|
|
37063
|
-
let complement = new Set(union.filter(g => !G.has(g)));
|
|
37509
|
+
let complement = new Set(union.filter(g => !G.has(g))); // groups not covered by the extent
|
|
37064
37510
|
for (let cp of V) {
|
|
37065
|
-
M.set(cp, complement);
|
|
37511
|
+
M.set(cp, complement); // this is the same reference
|
|
37066
37512
|
}
|
|
37067
37513
|
}
|
|
37068
37514
|
}
|
|
37069
37515
|
|
|
37070
37516
|
// compute valid set
|
|
37071
|
-
|
|
37517
|
+
// 20230924: VALID was union but can be re-used
|
|
37518
|
+
VALID = new Set(); // exists in 1+ groups
|
|
37072
37519
|
let multi = new Set(); // exists in 2+ groups
|
|
37073
|
-
const add_to_union = cp =>
|
|
37520
|
+
const add_to_union = cp => VALID.has(cp) ? multi.add(cp) : VALID.add(cp);
|
|
37074
37521
|
for (let g of GROUPS) {
|
|
37075
37522
|
for (let cp of g.P) add_to_union(cp);
|
|
37076
37523
|
for (let cp of g.Q) add_to_union(cp);
|
|
37077
37524
|
}
|
|
37078
37525
|
// dual purpose WHOLE_MAP: return placeholder if unique non-confusable
|
|
37079
|
-
for (let cp of
|
|
37526
|
+
for (let cp of VALID) {
|
|
37080
37527
|
if (!WHOLE_MAP.has(cp) && !multi.has(cp)) {
|
|
37081
37528
|
WHOLE_MAP.set(cp, UNIQUE_PH);
|
|
37082
37529
|
}
|
|
37083
37530
|
}
|
|
37084
|
-
|
|
37085
|
-
|
|
37531
|
+
// add all decomposed parts
|
|
37532
|
+
// see derive: "Valid is Closed (via Brute-force)"
|
|
37533
|
+
set_add_many(VALID, nfd(VALID));
|
|
37534
|
+
|
|
37086
37535
|
// decode emoji
|
|
37087
37536
|
// 20230719: emoji are now fully-expanded to avoid quirk logic
|
|
37088
37537
|
EMOJI_LIST = read_trie(r).map(v => Emoji.from(v)).sort(compare_arrays);
|
|
@@ -37135,7 +37584,7 @@ function bidi_qq(s) {
|
|
|
37135
37584
|
|
|
37136
37585
|
function check_label_extension(cps) {
|
|
37137
37586
|
if (cps.length >= 4 && cps[2] == HYPHEN && cps[3] == HYPHEN) {
|
|
37138
|
-
throw new Error(`invalid label extension: "${str_from_cps(cps.slice(0, 4))}"`);
|
|
37587
|
+
throw new Error(`invalid label extension: "${str_from_cps(cps.slice(0, 4))}"`); // this can only be ascii so cant be bidi
|
|
37139
37588
|
}
|
|
37140
37589
|
}
|
|
37141
37590
|
function check_leading_underscore(cps) {
|
|
@@ -37169,13 +37618,18 @@ function check_fenced(cps) {
|
|
|
37169
37618
|
// create a safe to print string
|
|
37170
37619
|
// invisibles are escaped
|
|
37171
37620
|
// leading cm uses placeholder
|
|
37621
|
+
// if cps exceed max, middle truncate with ellipsis
|
|
37172
37622
|
// quoter(cp) => string, eg. 3000 => "{3000}"
|
|
37173
37623
|
// note: in html, you'd call this function then replace [<>&] with entities
|
|
37174
|
-
function safe_str_from_cps(cps, quoter = quote_cp) {
|
|
37624
|
+
function safe_str_from_cps(cps, max = Infinity, quoter = quote_cp) {
|
|
37175
37625
|
//if (Number.isInteger(cps)) cps = [cps];
|
|
37176
37626
|
//if (!Array.isArray(cps)) throw new TypeError(`expected codepoints`);
|
|
37177
37627
|
let buf = [];
|
|
37178
37628
|
if (is_combining_mark(cps[0])) buf.push('◌');
|
|
37629
|
+
if (cps.length > max) {
|
|
37630
|
+
max >>= 1;
|
|
37631
|
+
cps = [...cps.slice(0, max), 0x2026, ...cps.slice(-max)];
|
|
37632
|
+
}
|
|
37179
37633
|
let prev = 0;
|
|
37180
37634
|
let n = cps.length;
|
|
37181
37635
|
for (let i = 0; i < n; i++) {
|
|
@@ -37340,7 +37794,7 @@ function flatten(split) {
|
|
|
37340
37794
|
// don't print label again if just a single label
|
|
37341
37795
|
let msg = error.message;
|
|
37342
37796
|
// bidi_qq() only necessary if msg is digits
|
|
37343
|
-
throw new Error(split.length == 1 ? msg : `Invalid label ${bidi_qq(safe_str_from_cps(input))}: ${msg}`);
|
|
37797
|
+
throw new Error(split.length == 1 ? msg : `Invalid label ${bidi_qq(safe_str_from_cps(input, 63))}: ${msg}`);
|
|
37344
37798
|
}
|
|
37345
37799
|
return str_from_cps(output);
|
|
37346
37800
|
}).join(STOP_CH);
|
|
@@ -37594,12 +38048,11 @@ function namehash(name) {
|
|
|
37594
38048
|
* This is used for various parts of ENS name resolution, such
|
|
37595
38049
|
* as the wildcard resolution.
|
|
37596
38050
|
*/
|
|
37597
|
-
function dnsEncode(name) {
|
|
38051
|
+
function dnsEncode(name, _maxLength) {
|
|
38052
|
+
const length = (_maxLength != null) ? _maxLength : 63;
|
|
38053
|
+
assertArgument(length <= 255, "DNS encoded label cannot exceed 255", "length", length);
|
|
37598
38054
|
return hexlify(concat(ensNameSplit(name).map((comp) => {
|
|
37599
|
-
|
|
37600
|
-
if (comp.length > 63) {
|
|
37601
|
-
throw new Error("invalid DNS encoded entry; length exceeds 63 bytes");
|
|
37602
|
-
}
|
|
38055
|
+
assertArgument(comp.length <= length, `label ${JSON.stringify(name)} exceeds ${length} bytes`, "name", name);
|
|
37603
38056
|
const bytes = new Uint8Array(comp.length + 1);
|
|
37604
38057
|
bytes.set(comp, 1);
|
|
37605
38058
|
bytes[0] = bytes.length - 1;
|
|
@@ -37671,6 +38124,15 @@ const BN_27 = BigInt(27);
|
|
|
37671
38124
|
const BN_28 = BigInt(28);
|
|
37672
38125
|
const BN_35 = BigInt(35);
|
|
37673
38126
|
const BN_MAX_UINT = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
38127
|
+
const BLOB_SIZE = 4096 * 32;
|
|
38128
|
+
function getVersionedHash(version, hash) {
|
|
38129
|
+
let versioned = version.toString(16);
|
|
38130
|
+
while (versioned.length < 2) {
|
|
38131
|
+
versioned = "0" + versioned;
|
|
38132
|
+
}
|
|
38133
|
+
versioned += sha256(hash).substring(4);
|
|
38134
|
+
return "0x" + versioned;
|
|
38135
|
+
}
|
|
37674
38136
|
function handleAddress(value) {
|
|
37675
38137
|
if (value === "0x") {
|
|
37676
38138
|
return null;
|
|
@@ -37708,6 +38170,13 @@ function formatNumber(_value, name) {
|
|
|
37708
38170
|
function formatAccessList(value) {
|
|
37709
38171
|
return accessListify(value).map((set) => [set.address, set.storageKeys]);
|
|
37710
38172
|
}
|
|
38173
|
+
function formatHashes(value, param) {
|
|
38174
|
+
assertArgument(Array.isArray(value), `invalid ${param}`, "value", value);
|
|
38175
|
+
for (let i = 0; i < value.length; i++) {
|
|
38176
|
+
assertArgument(isHexString(value[i], 32), "invalid ${ param } hash", `value[${i}]`, value[i]);
|
|
38177
|
+
}
|
|
38178
|
+
return value;
|
|
38179
|
+
}
|
|
37711
38180
|
function _parseLegacy(data) {
|
|
37712
38181
|
const fields = decodeRlp(data);
|
|
37713
38182
|
assertArgument(Array.isArray(fields) && (fields.length === 9 || fields.length === 6), "invalid field count for legacy transaction", "data", data);
|
|
@@ -37746,18 +38215,18 @@ function _parseLegacy(data) {
|
|
|
37746
38215
|
s: zeroPadValue(fields[8], 32),
|
|
37747
38216
|
v
|
|
37748
38217
|
});
|
|
37749
|
-
tx.hash = keccak256(data);
|
|
38218
|
+
//tx.hash = keccak256(data);
|
|
37750
38219
|
}
|
|
37751
38220
|
return tx;
|
|
37752
38221
|
}
|
|
37753
38222
|
function _serializeLegacy(tx, sig) {
|
|
37754
38223
|
const fields = [
|
|
37755
|
-
formatNumber(tx.nonce
|
|
38224
|
+
formatNumber(tx.nonce, "nonce"),
|
|
37756
38225
|
formatNumber(tx.gasPrice || 0, "gasPrice"),
|
|
37757
|
-
formatNumber(tx.gasLimit
|
|
37758
|
-
(
|
|
37759
|
-
formatNumber(tx.value
|
|
37760
|
-
|
|
38226
|
+
formatNumber(tx.gasLimit, "gasLimit"),
|
|
38227
|
+
(tx.to || "0x"),
|
|
38228
|
+
formatNumber(tx.value, "value"),
|
|
38229
|
+
tx.data,
|
|
37761
38230
|
];
|
|
37762
38231
|
let chainId = BN_0$4;
|
|
37763
38232
|
if (tx.chainId != BN_0$4) {
|
|
@@ -37820,14 +38289,12 @@ function _parseEipSignature(tx, fields) {
|
|
|
37820
38289
|
function _parseEip1559(data) {
|
|
37821
38290
|
const fields = decodeRlp(getBytes(data).slice(1));
|
|
37822
38291
|
assertArgument(Array.isArray(fields) && (fields.length === 9 || fields.length === 12), "invalid field count for transaction type: 2", "data", hexlify(data));
|
|
37823
|
-
const maxPriorityFeePerGas = handleUint(fields[2], "maxPriorityFeePerGas");
|
|
37824
|
-
const maxFeePerGas = handleUint(fields[3], "maxFeePerGas");
|
|
37825
38292
|
const tx = {
|
|
37826
38293
|
type: 2,
|
|
37827
38294
|
chainId: handleUint(fields[0], "chainId"),
|
|
37828
38295
|
nonce: handleNumber(fields[1], "nonce"),
|
|
37829
|
-
maxPriorityFeePerGas: maxPriorityFeePerGas,
|
|
37830
|
-
maxFeePerGas: maxFeePerGas,
|
|
38296
|
+
maxPriorityFeePerGas: handleUint(fields[2], "maxPriorityFeePerGas"),
|
|
38297
|
+
maxFeePerGas: handleUint(fields[3], "maxFeePerGas"),
|
|
37831
38298
|
gasPrice: null,
|
|
37832
38299
|
gasLimit: handleUint(fields[4], "gasLimit"),
|
|
37833
38300
|
to: handleAddress(fields[5]),
|
|
@@ -37839,21 +38306,21 @@ function _parseEip1559(data) {
|
|
|
37839
38306
|
if (fields.length === 9) {
|
|
37840
38307
|
return tx;
|
|
37841
38308
|
}
|
|
37842
|
-
tx.hash = keccak256(data);
|
|
38309
|
+
//tx.hash = keccak256(data);
|
|
37843
38310
|
_parseEipSignature(tx, fields.slice(9));
|
|
37844
38311
|
return tx;
|
|
37845
38312
|
}
|
|
37846
38313
|
function _serializeEip1559(tx, sig) {
|
|
37847
38314
|
const fields = [
|
|
37848
|
-
formatNumber(tx.chainId
|
|
37849
|
-
formatNumber(tx.nonce
|
|
38315
|
+
formatNumber(tx.chainId, "chainId"),
|
|
38316
|
+
formatNumber(tx.nonce, "nonce"),
|
|
37850
38317
|
formatNumber(tx.maxPriorityFeePerGas || 0, "maxPriorityFeePerGas"),
|
|
37851
38318
|
formatNumber(tx.maxFeePerGas || 0, "maxFeePerGas"),
|
|
37852
|
-
formatNumber(tx.gasLimit
|
|
37853
|
-
(
|
|
37854
|
-
formatNumber(tx.value
|
|
37855
|
-
|
|
37856
|
-
|
|
38319
|
+
formatNumber(tx.gasLimit, "gasLimit"),
|
|
38320
|
+
(tx.to || "0x"),
|
|
38321
|
+
formatNumber(tx.value, "value"),
|
|
38322
|
+
tx.data,
|
|
38323
|
+
formatAccessList(tx.accessList || [])
|
|
37857
38324
|
];
|
|
37858
38325
|
if (sig) {
|
|
37859
38326
|
fields.push(formatNumber(sig.yParity, "yParity"));
|
|
@@ -37880,20 +38347,20 @@ function _parseEip2930(data) {
|
|
|
37880
38347
|
if (fields.length === 8) {
|
|
37881
38348
|
return tx;
|
|
37882
38349
|
}
|
|
37883
|
-
tx.hash = keccak256(data);
|
|
38350
|
+
//tx.hash = keccak256(data);
|
|
37884
38351
|
_parseEipSignature(tx, fields.slice(8));
|
|
37885
38352
|
return tx;
|
|
37886
38353
|
}
|
|
37887
38354
|
function _serializeEip2930(tx, sig) {
|
|
37888
38355
|
const fields = [
|
|
37889
|
-
formatNumber(tx.chainId
|
|
37890
|
-
formatNumber(tx.nonce
|
|
38356
|
+
formatNumber(tx.chainId, "chainId"),
|
|
38357
|
+
formatNumber(tx.nonce, "nonce"),
|
|
37891
38358
|
formatNumber(tx.gasPrice || 0, "gasPrice"),
|
|
37892
|
-
formatNumber(tx.gasLimit
|
|
37893
|
-
(
|
|
37894
|
-
formatNumber(tx.value
|
|
37895
|
-
|
|
37896
|
-
|
|
38359
|
+
formatNumber(tx.gasLimit, "gasLimit"),
|
|
38360
|
+
(tx.to || "0x"),
|
|
38361
|
+
formatNumber(tx.value, "value"),
|
|
38362
|
+
tx.data,
|
|
38363
|
+
formatAccessList(tx.accessList || [])
|
|
37897
38364
|
];
|
|
37898
38365
|
if (sig) {
|
|
37899
38366
|
fields.push(formatNumber(sig.yParity, "recoveryParam"));
|
|
@@ -37902,6 +38369,96 @@ function _serializeEip2930(tx, sig) {
|
|
|
37902
38369
|
}
|
|
37903
38370
|
return concat(["0x01", encodeRlp(fields)]);
|
|
37904
38371
|
}
|
|
38372
|
+
function _parseEip4844(data) {
|
|
38373
|
+
let fields = decodeRlp(getBytes(data).slice(1));
|
|
38374
|
+
let typeName = "3";
|
|
38375
|
+
let blobs = null;
|
|
38376
|
+
// Parse the network format
|
|
38377
|
+
if (fields.length === 4 && Array.isArray(fields[0])) {
|
|
38378
|
+
typeName = "3 (network format)";
|
|
38379
|
+
const fBlobs = fields[1], fCommits = fields[2], fProofs = fields[3];
|
|
38380
|
+
assertArgument(Array.isArray(fBlobs), "invalid network format: blobs not an array", "fields[1]", fBlobs);
|
|
38381
|
+
assertArgument(Array.isArray(fCommits), "invalid network format: commitments not an array", "fields[2]", fCommits);
|
|
38382
|
+
assertArgument(Array.isArray(fProofs), "invalid network format: proofs not an array", "fields[3]", fProofs);
|
|
38383
|
+
assertArgument(fBlobs.length === fCommits.length, "invalid network format: blobs/commitments length mismatch", "fields", fields);
|
|
38384
|
+
assertArgument(fBlobs.length === fProofs.length, "invalid network format: blobs/proofs length mismatch", "fields", fields);
|
|
38385
|
+
blobs = [];
|
|
38386
|
+
for (let i = 0; i < fields[1].length; i++) {
|
|
38387
|
+
blobs.push({
|
|
38388
|
+
data: fBlobs[i],
|
|
38389
|
+
commitment: fCommits[i],
|
|
38390
|
+
proof: fProofs[i],
|
|
38391
|
+
});
|
|
38392
|
+
}
|
|
38393
|
+
fields = fields[0];
|
|
38394
|
+
}
|
|
38395
|
+
assertArgument(Array.isArray(fields) && (fields.length === 11 || fields.length === 14), `invalid field count for transaction type: ${typeName}`, "data", hexlify(data));
|
|
38396
|
+
const tx = {
|
|
38397
|
+
type: 3,
|
|
38398
|
+
chainId: handleUint(fields[0], "chainId"),
|
|
38399
|
+
nonce: handleNumber(fields[1], "nonce"),
|
|
38400
|
+
maxPriorityFeePerGas: handleUint(fields[2], "maxPriorityFeePerGas"),
|
|
38401
|
+
maxFeePerGas: handleUint(fields[3], "maxFeePerGas"),
|
|
38402
|
+
gasPrice: null,
|
|
38403
|
+
gasLimit: handleUint(fields[4], "gasLimit"),
|
|
38404
|
+
to: handleAddress(fields[5]),
|
|
38405
|
+
value: handleUint(fields[6], "value"),
|
|
38406
|
+
data: hexlify(fields[7]),
|
|
38407
|
+
accessList: handleAccessList(fields[8], "accessList"),
|
|
38408
|
+
maxFeePerBlobGas: handleUint(fields[9], "maxFeePerBlobGas"),
|
|
38409
|
+
blobVersionedHashes: fields[10]
|
|
38410
|
+
};
|
|
38411
|
+
if (blobs) {
|
|
38412
|
+
tx.blobs = blobs;
|
|
38413
|
+
}
|
|
38414
|
+
assertArgument(tx.to != null, `invalid address for transaction type: ${typeName}`, "data", data);
|
|
38415
|
+
assertArgument(Array.isArray(tx.blobVersionedHashes), "invalid blobVersionedHashes: must be an array", "data", data);
|
|
38416
|
+
for (let i = 0; i < tx.blobVersionedHashes.length; i++) {
|
|
38417
|
+
assertArgument(isHexString(tx.blobVersionedHashes[i], 32), `invalid blobVersionedHash at index ${i}: must be length 32`, "data", data);
|
|
38418
|
+
}
|
|
38419
|
+
// Unsigned EIP-4844 Transaction
|
|
38420
|
+
if (fields.length === 11) {
|
|
38421
|
+
return tx;
|
|
38422
|
+
}
|
|
38423
|
+
// @TODO: Do we need to do this? This is only called internally
|
|
38424
|
+
// and used to verify hashes; it might save time to not do this
|
|
38425
|
+
//tx.hash = keccak256(concat([ "0x03", encodeRlp(fields) ]));
|
|
38426
|
+
_parseEipSignature(tx, fields.slice(11));
|
|
38427
|
+
return tx;
|
|
38428
|
+
}
|
|
38429
|
+
function _serializeEip4844(tx, sig, blobs) {
|
|
38430
|
+
const fields = [
|
|
38431
|
+
formatNumber(tx.chainId, "chainId"),
|
|
38432
|
+
formatNumber(tx.nonce, "nonce"),
|
|
38433
|
+
formatNumber(tx.maxPriorityFeePerGas || 0, "maxPriorityFeePerGas"),
|
|
38434
|
+
formatNumber(tx.maxFeePerGas || 0, "maxFeePerGas"),
|
|
38435
|
+
formatNumber(tx.gasLimit, "gasLimit"),
|
|
38436
|
+
(tx.to || ZeroAddress),
|
|
38437
|
+
formatNumber(tx.value, "value"),
|
|
38438
|
+
tx.data,
|
|
38439
|
+
formatAccessList(tx.accessList || []),
|
|
38440
|
+
formatNumber(tx.maxFeePerBlobGas || 0, "maxFeePerBlobGas"),
|
|
38441
|
+
formatHashes(tx.blobVersionedHashes || [], "blobVersionedHashes")
|
|
38442
|
+
];
|
|
38443
|
+
if (sig) {
|
|
38444
|
+
fields.push(formatNumber(sig.yParity, "yParity"));
|
|
38445
|
+
fields.push(toBeArray(sig.r));
|
|
38446
|
+
fields.push(toBeArray(sig.s));
|
|
38447
|
+
// We have blobs; return the network wrapped format
|
|
38448
|
+
if (blobs) {
|
|
38449
|
+
return concat([
|
|
38450
|
+
"0x03",
|
|
38451
|
+
encodeRlp([
|
|
38452
|
+
fields,
|
|
38453
|
+
blobs.map((b) => b.data),
|
|
38454
|
+
blobs.map((b) => b.commitment),
|
|
38455
|
+
blobs.map((b) => b.proof),
|
|
38456
|
+
])
|
|
38457
|
+
]);
|
|
38458
|
+
}
|
|
38459
|
+
}
|
|
38460
|
+
return concat(["0x03", encodeRlp(fields)]);
|
|
38461
|
+
}
|
|
37905
38462
|
/**
|
|
37906
38463
|
* A **Transaction** describes an operation to be executed on
|
|
37907
38464
|
* Ethereum by an Externally Owned Account (EOA). It includes
|
|
@@ -37928,6 +38485,10 @@ class Transaction {
|
|
|
37928
38485
|
#chainId;
|
|
37929
38486
|
#sig;
|
|
37930
38487
|
#accessList;
|
|
38488
|
+
#maxFeePerBlobGas;
|
|
38489
|
+
#blobVersionedHashes;
|
|
38490
|
+
#kzg;
|
|
38491
|
+
#blobs;
|
|
37931
38492
|
/**
|
|
37932
38493
|
* The transaction type.
|
|
37933
38494
|
*
|
|
@@ -37954,6 +38515,11 @@ class Transaction {
|
|
|
37954
38515
|
case "eip-1559":
|
|
37955
38516
|
this.#type = 2;
|
|
37956
38517
|
break;
|
|
38518
|
+
case 3:
|
|
38519
|
+
case "cancun":
|
|
38520
|
+
case "eip-4844":
|
|
38521
|
+
this.#type = 3;
|
|
38522
|
+
break;
|
|
37957
38523
|
default:
|
|
37958
38524
|
assertArgument(false, "unsupported transaction type", "type", value);
|
|
37959
38525
|
}
|
|
@@ -37966,6 +38532,7 @@ class Transaction {
|
|
|
37966
38532
|
case 0: return "legacy";
|
|
37967
38533
|
case 1: return "eip-2930";
|
|
37968
38534
|
case 2: return "eip-1559";
|
|
38535
|
+
case 3: return "eip-4844";
|
|
37969
38536
|
}
|
|
37970
38537
|
return null;
|
|
37971
38538
|
}
|
|
@@ -37973,7 +38540,13 @@ class Transaction {
|
|
|
37973
38540
|
* The ``to`` address for the transaction or ``null`` if the
|
|
37974
38541
|
* transaction is an ``init`` transaction.
|
|
37975
38542
|
*/
|
|
37976
|
-
get to() {
|
|
38543
|
+
get to() {
|
|
38544
|
+
const value = this.#to;
|
|
38545
|
+
if (value == null && this.type === 3) {
|
|
38546
|
+
return ZeroAddress;
|
|
38547
|
+
}
|
|
38548
|
+
return value;
|
|
38549
|
+
}
|
|
37977
38550
|
set to(value) {
|
|
37978
38551
|
this.#to = (value == null) ? null : getAddress(value);
|
|
37979
38552
|
}
|
|
@@ -38010,7 +38583,7 @@ class Transaction {
|
|
|
38010
38583
|
get maxPriorityFeePerGas() {
|
|
38011
38584
|
const value = this.#maxPriorityFeePerGas;
|
|
38012
38585
|
if (value == null) {
|
|
38013
|
-
if (this.type === 2) {
|
|
38586
|
+
if (this.type === 2 || this.type === 3) {
|
|
38014
38587
|
return BN_0$4;
|
|
38015
38588
|
}
|
|
38016
38589
|
return null;
|
|
@@ -38027,7 +38600,7 @@ class Transaction {
|
|
|
38027
38600
|
get maxFeePerGas() {
|
|
38028
38601
|
const value = this.#maxFeePerGas;
|
|
38029
38602
|
if (value == null) {
|
|
38030
|
-
if (this.type === 2) {
|
|
38603
|
+
if (this.type === 2 || this.type === 3) {
|
|
38031
38604
|
return BN_0$4;
|
|
38032
38605
|
}
|
|
38033
38606
|
return null;
|
|
@@ -38071,7 +38644,9 @@ class Transaction {
|
|
|
38071
38644
|
get accessList() {
|
|
38072
38645
|
const value = this.#accessList || null;
|
|
38073
38646
|
if (value == null) {
|
|
38074
|
-
if (this.type === 1 || this.type === 2) {
|
|
38647
|
+
if (this.type === 1 || this.type === 2 || this.type === 3) {
|
|
38648
|
+
// @TODO: in v7, this should assign the value or become
|
|
38649
|
+
// a live object itself, otherwise mutation is inconsistent
|
|
38075
38650
|
return [];
|
|
38076
38651
|
}
|
|
38077
38652
|
return null;
|
|
@@ -38081,6 +38656,122 @@ class Transaction {
|
|
|
38081
38656
|
set accessList(value) {
|
|
38082
38657
|
this.#accessList = (value == null) ? null : accessListify(value);
|
|
38083
38658
|
}
|
|
38659
|
+
/**
|
|
38660
|
+
* The max fee per blob gas for Cancun transactions.
|
|
38661
|
+
*/
|
|
38662
|
+
get maxFeePerBlobGas() {
|
|
38663
|
+
const value = this.#maxFeePerBlobGas;
|
|
38664
|
+
if (value == null && this.type === 3) {
|
|
38665
|
+
return BN_0$4;
|
|
38666
|
+
}
|
|
38667
|
+
return value;
|
|
38668
|
+
}
|
|
38669
|
+
set maxFeePerBlobGas(value) {
|
|
38670
|
+
this.#maxFeePerBlobGas = (value == null) ? null : getBigInt(value, "maxFeePerBlobGas");
|
|
38671
|
+
}
|
|
38672
|
+
/**
|
|
38673
|
+
* The BLOb versioned hashes for Cancun transactions.
|
|
38674
|
+
*/
|
|
38675
|
+
get blobVersionedHashes() {
|
|
38676
|
+
// @TODO: Mutation is inconsistent; if unset, the returned value
|
|
38677
|
+
// cannot mutate the object, if set it can
|
|
38678
|
+
let value = this.#blobVersionedHashes;
|
|
38679
|
+
if (value == null && this.type === 3) {
|
|
38680
|
+
return [];
|
|
38681
|
+
}
|
|
38682
|
+
return value;
|
|
38683
|
+
}
|
|
38684
|
+
set blobVersionedHashes(value) {
|
|
38685
|
+
if (value != null) {
|
|
38686
|
+
assertArgument(Array.isArray(value), "blobVersionedHashes must be an Array", "value", value);
|
|
38687
|
+
value = value.slice();
|
|
38688
|
+
for (let i = 0; i < value.length; i++) {
|
|
38689
|
+
assertArgument(isHexString(value[i], 32), "invalid blobVersionedHash", `value[${i}]`, value[i]);
|
|
38690
|
+
}
|
|
38691
|
+
}
|
|
38692
|
+
this.#blobVersionedHashes = value;
|
|
38693
|
+
}
|
|
38694
|
+
/**
|
|
38695
|
+
* The BLObs for the Transaction, if any.
|
|
38696
|
+
*
|
|
38697
|
+
* If ``blobs`` is non-``null``, then the [[seriailized]]
|
|
38698
|
+
* will return the network formatted sidecar, otherwise it
|
|
38699
|
+
* will return the standard [[link-eip-2718]] payload. The
|
|
38700
|
+
* [[unsignedSerialized]] is unaffected regardless.
|
|
38701
|
+
*
|
|
38702
|
+
* When setting ``blobs``, either fully valid [[Blob]] objects
|
|
38703
|
+
* may be specified (i.e. correctly padded, with correct
|
|
38704
|
+
* committments and proofs) or a raw [[BytesLike]] may
|
|
38705
|
+
* be provided.
|
|
38706
|
+
*
|
|
38707
|
+
* If raw [[BytesLike]] are provided, the [[kzg]] property **must**
|
|
38708
|
+
* be already set. The blob will be correctly padded and the
|
|
38709
|
+
* [[KzgLibrary]] will be used to compute the committment and
|
|
38710
|
+
* proof for the blob.
|
|
38711
|
+
*
|
|
38712
|
+
* A BLOb is a sequence of field elements, each of which must
|
|
38713
|
+
* be within the BLS field modulo, so some additional processing
|
|
38714
|
+
* may be required to encode arbitrary data to ensure each 32 byte
|
|
38715
|
+
* field is within the valid range.
|
|
38716
|
+
*
|
|
38717
|
+
* Setting this automatically populates [[blobVersionedHashes]],
|
|
38718
|
+
* overwriting any existing values. Setting this to ``null``
|
|
38719
|
+
* does **not** remove the [[blobVersionedHashes]], leaving them
|
|
38720
|
+
* present.
|
|
38721
|
+
*/
|
|
38722
|
+
get blobs() {
|
|
38723
|
+
if (this.#blobs == null) {
|
|
38724
|
+
return null;
|
|
38725
|
+
}
|
|
38726
|
+
return this.#blobs.map((b) => Object.assign({}, b));
|
|
38727
|
+
}
|
|
38728
|
+
set blobs(_blobs) {
|
|
38729
|
+
if (_blobs == null) {
|
|
38730
|
+
this.#blobs = null;
|
|
38731
|
+
return;
|
|
38732
|
+
}
|
|
38733
|
+
const blobs = [];
|
|
38734
|
+
const versionedHashes = [];
|
|
38735
|
+
for (let i = 0; i < _blobs.length; i++) {
|
|
38736
|
+
const blob = _blobs[i];
|
|
38737
|
+
if (isBytesLike(blob)) {
|
|
38738
|
+
assert(this.#kzg, "adding a raw blob requires a KZG library", "UNSUPPORTED_OPERATION", {
|
|
38739
|
+
operation: "set blobs()"
|
|
38740
|
+
});
|
|
38741
|
+
let data = getBytes(blob);
|
|
38742
|
+
assertArgument(data.length <= BLOB_SIZE, "blob is too large", `blobs[${i}]`, blob);
|
|
38743
|
+
// Pad blob if necessary
|
|
38744
|
+
if (data.length !== BLOB_SIZE) {
|
|
38745
|
+
const padded = new Uint8Array(BLOB_SIZE);
|
|
38746
|
+
padded.set(data);
|
|
38747
|
+
data = padded;
|
|
38748
|
+
}
|
|
38749
|
+
const commit = this.#kzg.blobToKzgCommitment(data);
|
|
38750
|
+
const proof = hexlify(this.#kzg.computeBlobKzgProof(data, commit));
|
|
38751
|
+
blobs.push({
|
|
38752
|
+
data: hexlify(data),
|
|
38753
|
+
commitment: hexlify(commit),
|
|
38754
|
+
proof
|
|
38755
|
+
});
|
|
38756
|
+
versionedHashes.push(getVersionedHash(1, commit));
|
|
38757
|
+
}
|
|
38758
|
+
else {
|
|
38759
|
+
const commit = hexlify(blob.commitment);
|
|
38760
|
+
blobs.push({
|
|
38761
|
+
data: hexlify(blob.data),
|
|
38762
|
+
commitment: commit,
|
|
38763
|
+
proof: hexlify(blob.proof)
|
|
38764
|
+
});
|
|
38765
|
+
versionedHashes.push(getVersionedHash(1, commit));
|
|
38766
|
+
}
|
|
38767
|
+
}
|
|
38768
|
+
this.#blobs = blobs;
|
|
38769
|
+
this.#blobVersionedHashes = versionedHashes;
|
|
38770
|
+
}
|
|
38771
|
+
get kzg() { return this.#kzg; }
|
|
38772
|
+
set kzg(kzg) {
|
|
38773
|
+
this.#kzg = kzg;
|
|
38774
|
+
}
|
|
38084
38775
|
/**
|
|
38085
38776
|
* Creates a new Transaction with default values.
|
|
38086
38777
|
*/
|
|
@@ -38088,15 +38779,19 @@ class Transaction {
|
|
|
38088
38779
|
this.#type = null;
|
|
38089
38780
|
this.#to = null;
|
|
38090
38781
|
this.#nonce = 0;
|
|
38091
|
-
this.#gasLimit =
|
|
38782
|
+
this.#gasLimit = BN_0$4;
|
|
38092
38783
|
this.#gasPrice = null;
|
|
38093
38784
|
this.#maxPriorityFeePerGas = null;
|
|
38094
38785
|
this.#maxFeePerGas = null;
|
|
38095
38786
|
this.#data = "0x";
|
|
38096
|
-
this.#value =
|
|
38097
|
-
this.#chainId =
|
|
38787
|
+
this.#value = BN_0$4;
|
|
38788
|
+
this.#chainId = BN_0$4;
|
|
38098
38789
|
this.#sig = null;
|
|
38099
38790
|
this.#accessList = null;
|
|
38791
|
+
this.#maxFeePerBlobGas = null;
|
|
38792
|
+
this.#blobVersionedHashes = null;
|
|
38793
|
+
this.#blobs = null;
|
|
38794
|
+
this.#kzg = null;
|
|
38100
38795
|
}
|
|
38101
38796
|
/**
|
|
38102
38797
|
* The transaction hash, if signed. Otherwise, ``null``.
|
|
@@ -38105,7 +38800,7 @@ class Transaction {
|
|
|
38105
38800
|
if (this.signature == null) {
|
|
38106
38801
|
return null;
|
|
38107
38802
|
}
|
|
38108
|
-
return keccak256(this
|
|
38803
|
+
return keccak256(this.#getSerialized(true, false));
|
|
38109
38804
|
}
|
|
38110
38805
|
/**
|
|
38111
38806
|
* The pre-image hash of this transaction.
|
|
@@ -38141,9 +38836,23 @@ class Transaction {
|
|
|
38141
38836
|
* transaction are non-null.
|
|
38142
38837
|
*/
|
|
38143
38838
|
isSigned() {
|
|
38144
|
-
//isSigned(): this is SignedTransaction {
|
|
38145
38839
|
return this.signature != null;
|
|
38146
38840
|
}
|
|
38841
|
+
#getSerialized(signed, sidecar) {
|
|
38842
|
+
assert(!signed || this.signature != null, "cannot serialize unsigned transaction; maybe you meant .unsignedSerialized", "UNSUPPORTED_OPERATION", { operation: ".serialized" });
|
|
38843
|
+
const sig = signed ? this.signature : null;
|
|
38844
|
+
switch (this.inferType()) {
|
|
38845
|
+
case 0:
|
|
38846
|
+
return _serializeLegacy(this, sig);
|
|
38847
|
+
case 1:
|
|
38848
|
+
return _serializeEip2930(this, sig);
|
|
38849
|
+
case 2:
|
|
38850
|
+
return _serializeEip1559(this, sig);
|
|
38851
|
+
case 3:
|
|
38852
|
+
return _serializeEip4844(this, sig, sidecar ? this.blobs : null);
|
|
38853
|
+
}
|
|
38854
|
+
assert(false, "unsupported transaction type", "UNSUPPORTED_OPERATION", { operation: ".serialized" });
|
|
38855
|
+
}
|
|
38147
38856
|
/**
|
|
38148
38857
|
* The serialized transaction.
|
|
38149
38858
|
*
|
|
@@ -38151,16 +38860,7 @@ class Transaction {
|
|
|
38151
38860
|
* use [[unsignedSerialized]].
|
|
38152
38861
|
*/
|
|
38153
38862
|
get serialized() {
|
|
38154
|
-
|
|
38155
|
-
switch (this.inferType()) {
|
|
38156
|
-
case 0:
|
|
38157
|
-
return _serializeLegacy(this, this.signature);
|
|
38158
|
-
case 1:
|
|
38159
|
-
return _serializeEip2930(this, this.signature);
|
|
38160
|
-
case 2:
|
|
38161
|
-
return _serializeEip1559(this, this.signature);
|
|
38162
|
-
}
|
|
38163
|
-
assert(false, "unsupported transaction type", "UNSUPPORTED_OPERATION", { operation: ".serialized" });
|
|
38863
|
+
return this.#getSerialized(true, true);
|
|
38164
38864
|
}
|
|
38165
38865
|
/**
|
|
38166
38866
|
* The transaction pre-image.
|
|
@@ -38169,22 +38869,20 @@ class Transaction {
|
|
|
38169
38869
|
* authorize this transaction.
|
|
38170
38870
|
*/
|
|
38171
38871
|
get unsignedSerialized() {
|
|
38172
|
-
|
|
38173
|
-
case 0:
|
|
38174
|
-
return _serializeLegacy(this);
|
|
38175
|
-
case 1:
|
|
38176
|
-
return _serializeEip2930(this);
|
|
38177
|
-
case 2:
|
|
38178
|
-
return _serializeEip1559(this);
|
|
38179
|
-
}
|
|
38180
|
-
assert(false, "unsupported transaction type", "UNSUPPORTED_OPERATION", { operation: ".unsignedSerialized" });
|
|
38872
|
+
return this.#getSerialized(false, false);
|
|
38181
38873
|
}
|
|
38182
38874
|
/**
|
|
38183
38875
|
* Return the most "likely" type; currently the highest
|
|
38184
38876
|
* supported transaction type.
|
|
38185
38877
|
*/
|
|
38186
38878
|
inferType() {
|
|
38187
|
-
|
|
38879
|
+
const types = this.inferTypes();
|
|
38880
|
+
// Prefer London (EIP-1559) over Cancun (BLOb)
|
|
38881
|
+
if (types.indexOf(2) >= 0) {
|
|
38882
|
+
return 2;
|
|
38883
|
+
}
|
|
38884
|
+
// Return the highest inferred type
|
|
38885
|
+
return (types.pop());
|
|
38188
38886
|
}
|
|
38189
38887
|
/**
|
|
38190
38888
|
* Validates the explicit properties and returns a list of compatible
|
|
@@ -38195,6 +38893,7 @@ class Transaction {
|
|
|
38195
38893
|
const hasGasPrice = this.gasPrice != null;
|
|
38196
38894
|
const hasFee = (this.maxFeePerGas != null || this.maxPriorityFeePerGas != null);
|
|
38197
38895
|
const hasAccessList = (this.accessList != null);
|
|
38896
|
+
const hasBlob = (this.#maxFeePerBlobGas != null || this.#blobVersionedHashes);
|
|
38198
38897
|
//if (hasGasPrice && hasFee) {
|
|
38199
38898
|
// throw new Error("transaction cannot have gasPrice and maxFeePerGas");
|
|
38200
38899
|
//}
|
|
@@ -38225,10 +38924,14 @@ class Transaction {
|
|
|
38225
38924
|
types.push(1);
|
|
38226
38925
|
types.push(2);
|
|
38227
38926
|
}
|
|
38927
|
+
else if (hasBlob && this.to) {
|
|
38928
|
+
types.push(3);
|
|
38929
|
+
}
|
|
38228
38930
|
else {
|
|
38229
38931
|
types.push(0);
|
|
38230
38932
|
types.push(1);
|
|
38231
38933
|
types.push(2);
|
|
38934
|
+
types.push(3);
|
|
38232
38935
|
}
|
|
38233
38936
|
}
|
|
38234
38937
|
types.sort();
|
|
@@ -38264,6 +38967,16 @@ class Transaction {
|
|
|
38264
38967
|
isLondon() {
|
|
38265
38968
|
return (this.type === 2);
|
|
38266
38969
|
}
|
|
38970
|
+
/**
|
|
38971
|
+
* Returns true if this transaction is an [[link-eip-4844]] BLOB
|
|
38972
|
+
* transaction.
|
|
38973
|
+
*
|
|
38974
|
+
* This provides a Type Guard that the related properties are
|
|
38975
|
+
* non-null.
|
|
38976
|
+
*/
|
|
38977
|
+
isCancun() {
|
|
38978
|
+
return (this.type === 3);
|
|
38979
|
+
}
|
|
38267
38980
|
/**
|
|
38268
38981
|
* Create a copy of this transaciton.
|
|
38269
38982
|
*/
|
|
@@ -38312,6 +39025,7 @@ class Transaction {
|
|
|
38312
39025
|
switch (payload[0]) {
|
|
38313
39026
|
case 1: return Transaction.from(_parseEip2930(payload));
|
|
38314
39027
|
case 2: return Transaction.from(_parseEip1559(payload));
|
|
39028
|
+
case 3: return Transaction.from(_parseEip4844(payload));
|
|
38315
39029
|
}
|
|
38316
39030
|
assert(false, "unsupported transaction type", "UNSUPPORTED_OPERATION", { operation: "from" });
|
|
38317
39031
|
}
|
|
@@ -38337,6 +39051,9 @@ class Transaction {
|
|
|
38337
39051
|
if (tx.maxFeePerGas != null) {
|
|
38338
39052
|
result.maxFeePerGas = tx.maxFeePerGas;
|
|
38339
39053
|
}
|
|
39054
|
+
if (tx.maxFeePerBlobGas != null) {
|
|
39055
|
+
result.maxFeePerBlobGas = tx.maxFeePerBlobGas;
|
|
39056
|
+
}
|
|
38340
39057
|
if (tx.data != null) {
|
|
38341
39058
|
result.data = tx.data;
|
|
38342
39059
|
}
|
|
@@ -38352,12 +39069,24 @@ class Transaction {
|
|
|
38352
39069
|
if (tx.accessList != null) {
|
|
38353
39070
|
result.accessList = tx.accessList;
|
|
38354
39071
|
}
|
|
39072
|
+
// This will get overwritten by blobs, if present
|
|
39073
|
+
if (tx.blobVersionedHashes != null) {
|
|
39074
|
+
result.blobVersionedHashes = tx.blobVersionedHashes;
|
|
39075
|
+
}
|
|
39076
|
+
// Make sure we assign the kzg before assigning blobs, which
|
|
39077
|
+
// require the library in the event raw blob data is provided.
|
|
39078
|
+
if (tx.kzg != null) {
|
|
39079
|
+
result.kzg = tx.kzg;
|
|
39080
|
+
}
|
|
39081
|
+
if (tx.blobs != null) {
|
|
39082
|
+
result.blobs = tx.blobs;
|
|
39083
|
+
}
|
|
38355
39084
|
if (tx.hash != null) {
|
|
38356
|
-
assertArgument(result.isSigned(), "unsigned transaction cannot define hash", "tx", tx);
|
|
39085
|
+
assertArgument(result.isSigned(), "unsigned transaction cannot define '.hash'", "tx", tx);
|
|
38357
39086
|
assertArgument(result.hash === tx.hash, "hash mismatch", "tx", tx);
|
|
38358
39087
|
}
|
|
38359
39088
|
if (tx.from != null) {
|
|
38360
|
-
assertArgument(result.isSigned(), "unsigned transaction cannot define from", "tx", tx);
|
|
39089
|
+
assertArgument(result.isSigned(), "unsigned transaction cannot define '.from'", "tx", tx);
|
|
38361
39090
|
assertArgument(result.from.toLowerCase() === (tx.from || "").toLowerCase(), "from mismatch", "tx", tx);
|
|
38362
39091
|
}
|
|
38363
39092
|
return result;
|
|
@@ -38424,11 +39153,11 @@ const domainChecks = {
|
|
|
38424
39153
|
function getBaseEncoder(type) {
|
|
38425
39154
|
// intXX and uintXX
|
|
38426
39155
|
{
|
|
38427
|
-
const match = type.match(/^(u?)int(\d
|
|
39156
|
+
const match = type.match(/^(u?)int(\d+)$/);
|
|
38428
39157
|
if (match) {
|
|
38429
39158
|
const signed = (match[1] === "");
|
|
38430
|
-
const width = parseInt(match[2]
|
|
38431
|
-
assertArgument(width % 8 === 0 && width !== 0 && width <= 256 &&
|
|
39159
|
+
const width = parseInt(match[2]);
|
|
39160
|
+
assertArgument(width % 8 === 0 && width !== 0 && width <= 256 && match[2] === String(width), "invalid numeric width", "type", type);
|
|
38432
39161
|
const boundsUpper = mask(BN_MAX_UINT256, signed ? (width - 1) : width);
|
|
38433
39162
|
const boundsLower = signed ? ((boundsUpper + BN_1) * BN__1) : BN_0$3;
|
|
38434
39163
|
return function (_value) {
|
|
@@ -38470,6 +39199,23 @@ function getBaseEncoder(type) {
|
|
|
38470
39199
|
function encodeType(name, fields) {
|
|
38471
39200
|
return `${name}(${fields.map(({ name, type }) => (type + " " + name)).join(",")})`;
|
|
38472
39201
|
}
|
|
39202
|
+
// foo[][3] => { base: "foo", index: "[][3]", array: {
|
|
39203
|
+
// base: "foo", prefix: "foo[]", count: 3 } }
|
|
39204
|
+
function splitArray(type) {
|
|
39205
|
+
const match = type.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);
|
|
39206
|
+
if (match) {
|
|
39207
|
+
return {
|
|
39208
|
+
base: match[1],
|
|
39209
|
+
index: (match[2] + match[4]),
|
|
39210
|
+
array: {
|
|
39211
|
+
base: match[1],
|
|
39212
|
+
prefix: (match[1] + match[2]),
|
|
39213
|
+
count: (match[5] ? parseInt(match[5]) : -1),
|
|
39214
|
+
}
|
|
39215
|
+
};
|
|
39216
|
+
}
|
|
39217
|
+
return { base: type };
|
|
39218
|
+
}
|
|
38473
39219
|
/**
|
|
38474
39220
|
* A **TypedDataEncode** prepares and encodes [[link-eip-712]] payloads
|
|
38475
39221
|
* for signed typed data.
|
|
@@ -38504,8 +39250,7 @@ class TypedDataEncoder {
|
|
|
38504
39250
|
* do not violate the [[link-eip-712]] structural constraints as
|
|
38505
39251
|
* well as computes the [[primaryType]].
|
|
38506
39252
|
*/
|
|
38507
|
-
constructor(
|
|
38508
|
-
this.#types = JSON.stringify(types);
|
|
39253
|
+
constructor(_types) {
|
|
38509
39254
|
this.#fullTypes = new Map();
|
|
38510
39255
|
this.#encoderCache = new Map();
|
|
38511
39256
|
// Link struct types to their direct child structs
|
|
@@ -38514,26 +39259,39 @@ class TypedDataEncoder {
|
|
|
38514
39259
|
const parents = new Map();
|
|
38515
39260
|
// Link all subtypes within a given struct
|
|
38516
39261
|
const subtypes = new Map();
|
|
38517
|
-
|
|
39262
|
+
const types = {};
|
|
39263
|
+
Object.keys(_types).forEach((type) => {
|
|
39264
|
+
types[type] = _types[type].map(({ name, type }) => {
|
|
39265
|
+
// Normalize the base type (unless name conflict)
|
|
39266
|
+
let { base, index } = splitArray(type);
|
|
39267
|
+
if (base === "int" && !_types["int"]) {
|
|
39268
|
+
base = "int256";
|
|
39269
|
+
}
|
|
39270
|
+
if (base === "uint" && !_types["uint"]) {
|
|
39271
|
+
base = "uint256";
|
|
39272
|
+
}
|
|
39273
|
+
return { name, type: (base + (index || "")) };
|
|
39274
|
+
});
|
|
38518
39275
|
links.set(type, new Set());
|
|
38519
39276
|
parents.set(type, []);
|
|
38520
39277
|
subtypes.set(type, new Set());
|
|
38521
39278
|
});
|
|
39279
|
+
this.#types = JSON.stringify(types);
|
|
38522
39280
|
for (const name in types) {
|
|
38523
39281
|
const uniqueNames = new Set();
|
|
38524
39282
|
for (const field of types[name]) {
|
|
38525
39283
|
// Check each field has a unique name
|
|
38526
|
-
assertArgument(!uniqueNames.has(field.name), `duplicate variable name ${JSON.stringify(field.name)} in ${JSON.stringify(name)}`, "types",
|
|
39284
|
+
assertArgument(!uniqueNames.has(field.name), `duplicate variable name ${JSON.stringify(field.name)} in ${JSON.stringify(name)}`, "types", _types);
|
|
38527
39285
|
uniqueNames.add(field.name);
|
|
38528
39286
|
// Get the base type (drop any array specifiers)
|
|
38529
|
-
const baseType = (field.type.
|
|
38530
|
-
assertArgument(baseType !== name, `circular type reference to ${JSON.stringify(baseType)}`, "types",
|
|
39287
|
+
const baseType = splitArray(field.type).base;
|
|
39288
|
+
assertArgument(baseType !== name, `circular type reference to ${JSON.stringify(baseType)}`, "types", _types);
|
|
38531
39289
|
// Is this a base encoding type?
|
|
38532
39290
|
const encoder = getBaseEncoder(baseType);
|
|
38533
39291
|
if (encoder) {
|
|
38534
39292
|
continue;
|
|
38535
39293
|
}
|
|
38536
|
-
assertArgument(parents.has(baseType), `unknown type ${JSON.stringify(baseType)}`, "types",
|
|
39294
|
+
assertArgument(parents.has(baseType), `unknown type ${JSON.stringify(baseType)}`, "types", _types);
|
|
38537
39295
|
// Add linkage
|
|
38538
39296
|
parents.get(baseType).push(name);
|
|
38539
39297
|
links.get(name).add(baseType);
|
|
@@ -38541,12 +39299,12 @@ class TypedDataEncoder {
|
|
|
38541
39299
|
}
|
|
38542
39300
|
// Deduce the primary type
|
|
38543
39301
|
const primaryTypes = Array.from(parents.keys()).filter((n) => (parents.get(n).length === 0));
|
|
38544
|
-
assertArgument(primaryTypes.length !== 0, "missing primary type", "types",
|
|
38545
|
-
assertArgument(primaryTypes.length === 1, `ambiguous primary types or unused types: ${primaryTypes.map((t) => (JSON.stringify(t))).join(", ")}`, "types",
|
|
39302
|
+
assertArgument(primaryTypes.length !== 0, "missing primary type", "types", _types);
|
|
39303
|
+
assertArgument(primaryTypes.length === 1, `ambiguous primary types or unused types: ${primaryTypes.map((t) => (JSON.stringify(t))).join(", ")}`, "types", _types);
|
|
38546
39304
|
defineProperties(this, { primaryType: primaryTypes[0] });
|
|
38547
39305
|
// Check for circular type references
|
|
38548
39306
|
function checkCircular(type, found) {
|
|
38549
|
-
assertArgument(!found.has(type), `circular type reference to ${JSON.stringify(type)}`, "types",
|
|
39307
|
+
assertArgument(!found.has(type), `circular type reference to ${JSON.stringify(type)}`, "types", _types);
|
|
38550
39308
|
found.add(type);
|
|
38551
39309
|
for (const child of links.get(type)) {
|
|
38552
39310
|
if (!parents.has(child)) {
|
|
@@ -38589,12 +39347,12 @@ class TypedDataEncoder {
|
|
|
38589
39347
|
}
|
|
38590
39348
|
}
|
|
38591
39349
|
// Array
|
|
38592
|
-
const
|
|
38593
|
-
if (
|
|
38594
|
-
const subtype =
|
|
39350
|
+
const array = splitArray(type).array;
|
|
39351
|
+
if (array) {
|
|
39352
|
+
const subtype = array.prefix;
|
|
38595
39353
|
const subEncoder = this.getEncoder(subtype);
|
|
38596
39354
|
return (value) => {
|
|
38597
|
-
assertArgument(
|
|
39355
|
+
assertArgument(array.count === -1 || array.count === value.length, `array length mismatch; expected length ${array.count}`, "value", value);
|
|
38598
39356
|
let result = value.map(subEncoder);
|
|
38599
39357
|
if (this.#fullTypes.has(subtype)) {
|
|
38600
39358
|
result = result.map(keccak256);
|
|
@@ -38664,10 +39422,10 @@ class TypedDataEncoder {
|
|
|
38664
39422
|
}
|
|
38665
39423
|
}
|
|
38666
39424
|
// Array
|
|
38667
|
-
const
|
|
38668
|
-
if (
|
|
38669
|
-
assertArgument(
|
|
38670
|
-
return value.map((v) => this._visit(
|
|
39425
|
+
const array = splitArray(type).array;
|
|
39426
|
+
if (array) {
|
|
39427
|
+
assertArgument(array.count === -1 || array.count === value.length, `array length mismatch; expected length ${array.count}`, "value", value);
|
|
39428
|
+
return value.map((v) => this._visit(array.prefix, v, callback));
|
|
38671
39429
|
}
|
|
38672
39430
|
// Struct
|
|
38673
39431
|
const fields = this.types[type];
|
|
@@ -38806,6 +39564,8 @@ class TypedDataEncoder {
|
|
|
38806
39564
|
domainTypes.push({ name, type: domainFieldTypes[name] });
|
|
38807
39565
|
});
|
|
38808
39566
|
const encoder = TypedDataEncoder.from(types);
|
|
39567
|
+
// Get the normalized types
|
|
39568
|
+
types = encoder.types;
|
|
38809
39569
|
const typesWithDomain = Object.assign({}, types);
|
|
38810
39570
|
assertArgument(typesWithDomain.EIP712Domain == null, "types must not contain EIP712Domain type", "types.EIP712Domain", types);
|
|
38811
39571
|
typesWithDomain.EIP712Domain = domainTypes;
|
|
@@ -38856,10 +39616,10 @@ function setify(items) {
|
|
|
38856
39616
|
items.forEach((k) => result.add(k));
|
|
38857
39617
|
return Object.freeze(result);
|
|
38858
39618
|
}
|
|
38859
|
-
const _kwVisibDeploy = "external public payable";
|
|
39619
|
+
const _kwVisibDeploy = "external public payable override";
|
|
38860
39620
|
const KwVisibDeploy = setify(_kwVisibDeploy.split(" "));
|
|
38861
39621
|
// Visibility Keywords
|
|
38862
|
-
const _kwVisib = "constant external internal payable private public pure view";
|
|
39622
|
+
const _kwVisib = "constant external internal payable private public pure view override";
|
|
38863
39623
|
const KwVisib = setify(_kwVisib.split(" "));
|
|
38864
39624
|
const _kwTypes = "constructor error event fallback function receive struct";
|
|
38865
39625
|
const KwTypes = setify(_kwTypes.split(" "));
|
|
@@ -38913,7 +39673,8 @@ class TokenString {
|
|
|
38913
39673
|
// Pops and returns the value of the next token if it is `type`; throws if out of tokens
|
|
38914
39674
|
popType(type) {
|
|
38915
39675
|
if (this.peek().type !== type) {
|
|
38916
|
-
|
|
39676
|
+
const top = this.peek();
|
|
39677
|
+
throw new Error(`expected ${type}; got ${top.type} ${JSON.stringify(top.text)}`);
|
|
38917
39678
|
}
|
|
38918
39679
|
return this.pop().text;
|
|
38919
39680
|
}
|
|
@@ -39145,7 +39906,7 @@ function consumeGas(tokens) {
|
|
|
39145
39906
|
}
|
|
39146
39907
|
function consumeEoi(tokens) {
|
|
39147
39908
|
if (tokens.length) {
|
|
39148
|
-
throw new Error(`unexpected tokens: ${tokens.toString()}`);
|
|
39909
|
+
throw new Error(`unexpected tokens at offset ${tokens.offset}: ${tokens.toString()}`);
|
|
39149
39910
|
}
|
|
39150
39911
|
}
|
|
39151
39912
|
const regexArrayType = new RegExp(/^(.*)\[([0-9]*)\]$/);
|
|
@@ -39293,9 +40054,6 @@ class ParamType {
|
|
|
39293
40054
|
}
|
|
39294
40055
|
else {
|
|
39295
40056
|
if (this.isTuple()) {
|
|
39296
|
-
if (format !== "sighash") {
|
|
39297
|
-
result += this.type;
|
|
39298
|
-
}
|
|
39299
40057
|
result += "(" + this.components.map((comp) => comp.format(format)).join((format === "full") ? ", " : ",") + ")";
|
|
39300
40058
|
}
|
|
39301
40059
|
else {
|
|
@@ -39428,7 +40186,7 @@ class ParamType {
|
|
|
39428
40186
|
* Walks the **ParamType** with %%value%%, asynchronously calling
|
|
39429
40187
|
* %%process%% on each type, destructing the %%value%% recursively.
|
|
39430
40188
|
*
|
|
39431
|
-
* This can be used to resolve ENS
|
|
40189
|
+
* This can be used to resolve ENS names by walking and resolving each
|
|
39432
40190
|
* ``"address"`` type.
|
|
39433
40191
|
*/
|
|
39434
40192
|
async walkAsync(value, process) {
|
|
@@ -39837,7 +40595,9 @@ class ConstructorFragment extends Fragment {
|
|
|
39837
40595
|
});
|
|
39838
40596
|
}
|
|
39839
40597
|
const result = [`constructor${joinParams(format, this.inputs)}`];
|
|
39840
|
-
|
|
40598
|
+
if (this.payable) {
|
|
40599
|
+
result.push("payable");
|
|
40600
|
+
}
|
|
39841
40601
|
if (this.gas != null) {
|
|
39842
40602
|
result.push(`@${this.gas.toString()}`);
|
|
39843
40603
|
}
|
|
@@ -40183,6 +40943,7 @@ PanicReasons$1.set(0x51, "UNINITIALIZED_FUNCTION_CALL");
|
|
|
40183
40943
|
const paramTypeBytes = new RegExp(/^bytes([0-9]*)$/);
|
|
40184
40944
|
const paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/);
|
|
40185
40945
|
let defaultCoder = null;
|
|
40946
|
+
let defaultMaxInflation = 1024;
|
|
40186
40947
|
function getBuiltinCallException(action, tx, data, abiCoder) {
|
|
40187
40948
|
let message = "missing revert data";
|
|
40188
40949
|
let reason = null;
|
|
@@ -40319,7 +41080,11 @@ class AbiCoder {
|
|
|
40319
41080
|
decode(types, data, loose) {
|
|
40320
41081
|
const coders = types.map((type) => this.#getCoder(ParamType.from(type)));
|
|
40321
41082
|
const coder = new TupleCoder(coders, "_");
|
|
40322
|
-
return coder.decode(new Reader(data, loose));
|
|
41083
|
+
return coder.decode(new Reader(data, loose, defaultMaxInflation));
|
|
41084
|
+
}
|
|
41085
|
+
static _setDefaultMaxInflation(value) {
|
|
41086
|
+
assertArgument(typeof (value) === "number" && Number.isInteger(value), "invalid defaultMaxInflation factor", "value", value);
|
|
41087
|
+
defaultMaxInflation = value;
|
|
40323
41088
|
}
|
|
40324
41089
|
/**
|
|
40325
41090
|
* Returns the shared singleton instance of a default [[AbiCoder]].
|
|
@@ -40581,7 +41346,7 @@ class Interface {
|
|
|
40581
41346
|
frags.push(Fragment.from(a));
|
|
40582
41347
|
}
|
|
40583
41348
|
catch (error) {
|
|
40584
|
-
console.log(
|
|
41349
|
+
console.log(`[Warning] Invalid Fragment ${JSON.stringify(a)}:`, error.message);
|
|
40585
41350
|
}
|
|
40586
41351
|
}
|
|
40587
41352
|
defineProperties(this, {
|
|
@@ -41422,7 +42187,11 @@ getSelector(fragment: ErrorFragment | FunctionFragment): string {
|
|
|
41422
42187
|
if (typeof (value) === "string") {
|
|
41423
42188
|
return new Interface(JSON.parse(value));
|
|
41424
42189
|
}
|
|
41425
|
-
//
|
|
42190
|
+
// An Interface; possibly from another v6 instance
|
|
42191
|
+
if (typeof (value.formatJson) === "function") {
|
|
42192
|
+
return new Interface(value.formatJson());
|
|
42193
|
+
}
|
|
42194
|
+
// A legacy Interface; from an older version
|
|
41426
42195
|
if (typeof (value.format) === "function") {
|
|
41427
42196
|
return new Interface(value.format("json"));
|
|
41428
42197
|
}
|
|
@@ -41519,7 +42288,7 @@ function copyRequest(req) {
|
|
|
41519
42288
|
if (req.data) {
|
|
41520
42289
|
result.data = hexlify(req.data);
|
|
41521
42290
|
}
|
|
41522
|
-
const bigIntKeys = "chainId,gasLimit,gasPrice,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);
|
|
42291
|
+
const bigIntKeys = "chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);
|
|
41523
42292
|
for (const key of bigIntKeys) {
|
|
41524
42293
|
if (!(key in req) || req[key] == null) {
|
|
41525
42294
|
continue;
|
|
@@ -41545,6 +42314,20 @@ function copyRequest(req) {
|
|
|
41545
42314
|
if ("customData" in req) {
|
|
41546
42315
|
result.customData = req.customData;
|
|
41547
42316
|
}
|
|
42317
|
+
if ("blobVersionedHashes" in req && req.blobVersionedHashes) {
|
|
42318
|
+
result.blobVersionedHashes = req.blobVersionedHashes.slice();
|
|
42319
|
+
}
|
|
42320
|
+
if ("kzg" in req) {
|
|
42321
|
+
result.kzg = req.kzg;
|
|
42322
|
+
}
|
|
42323
|
+
if ("blobs" in req && req.blobs) {
|
|
42324
|
+
result.blobs = req.blobs.map((b) => {
|
|
42325
|
+
if (isBytesLike(b)) {
|
|
42326
|
+
return hexlify(b);
|
|
42327
|
+
}
|
|
42328
|
+
return Object.assign({}, b);
|
|
42329
|
+
});
|
|
42330
|
+
}
|
|
41548
42331
|
return result;
|
|
41549
42332
|
}
|
|
41550
42333
|
/**
|
|
@@ -41578,6 +42361,11 @@ class Block {
|
|
|
41578
42361
|
* The block hash of the parent block.
|
|
41579
42362
|
*/
|
|
41580
42363
|
parentHash;
|
|
42364
|
+
/**
|
|
42365
|
+
* The hash tree root of the parent beacon block for the given
|
|
42366
|
+
* execution block. See [[link-eip-4788]].
|
|
42367
|
+
*/
|
|
42368
|
+
parentBeaconBlockRoot;
|
|
41581
42369
|
/**
|
|
41582
42370
|
* The nonce.
|
|
41583
42371
|
*
|
|
@@ -41603,11 +42391,35 @@ class Block {
|
|
|
41603
42391
|
* The total gas used in this block.
|
|
41604
42392
|
*/
|
|
41605
42393
|
gasUsed;
|
|
42394
|
+
/**
|
|
42395
|
+
* The root hash for the global state after applying changes
|
|
42396
|
+
* in this block.
|
|
42397
|
+
*/
|
|
42398
|
+
stateRoot;
|
|
42399
|
+
/**
|
|
42400
|
+
* The hash of the transaction receipts trie.
|
|
42401
|
+
*/
|
|
42402
|
+
receiptsRoot;
|
|
42403
|
+
/**
|
|
42404
|
+
* The total amount of blob gas consumed by the transactions
|
|
42405
|
+
* within the block. See [[link-eip-4844]].
|
|
42406
|
+
*/
|
|
42407
|
+
blobGasUsed;
|
|
42408
|
+
/**
|
|
42409
|
+
* The running total of blob gas consumed in excess of the
|
|
42410
|
+
* target, prior to the block. See [[link-eip-4844]].
|
|
42411
|
+
*/
|
|
42412
|
+
excessBlobGas;
|
|
41606
42413
|
/**
|
|
41607
42414
|
* The miner coinbase address, wihch receives any subsidies for
|
|
41608
42415
|
* including this block.
|
|
41609
42416
|
*/
|
|
41610
42417
|
miner;
|
|
42418
|
+
/**
|
|
42419
|
+
* The latest RANDAO mix of the post beacon state of
|
|
42420
|
+
* the previous block.
|
|
42421
|
+
*/
|
|
42422
|
+
prevRandao;
|
|
41611
42423
|
/**
|
|
41612
42424
|
* Any extra data the validator wished to include.
|
|
41613
42425
|
*/
|
|
@@ -41640,13 +42452,19 @@ class Block {
|
|
|
41640
42452
|
number: block.number,
|
|
41641
42453
|
timestamp: block.timestamp,
|
|
41642
42454
|
parentHash: block.parentHash,
|
|
42455
|
+
parentBeaconBlockRoot: block.parentBeaconBlockRoot,
|
|
41643
42456
|
nonce: block.nonce,
|
|
41644
42457
|
difficulty: block.difficulty,
|
|
41645
42458
|
gasLimit: block.gasLimit,
|
|
41646
42459
|
gasUsed: block.gasUsed,
|
|
42460
|
+
blobGasUsed: block.blobGasUsed,
|
|
42461
|
+
excessBlobGas: block.excessBlobGas,
|
|
41647
42462
|
miner: block.miner,
|
|
42463
|
+
prevRandao: getValue(block.prevRandao),
|
|
41648
42464
|
extraData: block.extraData,
|
|
41649
|
-
baseFeePerGas: getValue(block.baseFeePerGas)
|
|
42465
|
+
baseFeePerGas: getValue(block.baseFeePerGas),
|
|
42466
|
+
stateRoot: block.stateRoot,
|
|
42467
|
+
receiptsRoot: block.receiptsRoot,
|
|
41650
42468
|
});
|
|
41651
42469
|
}
|
|
41652
42470
|
/**
|
|
@@ -41685,7 +42503,7 @@ class Block {
|
|
|
41685
42503
|
* Returns a JSON-friendly value.
|
|
41686
42504
|
*/
|
|
41687
42505
|
toJSON() {
|
|
41688
|
-
const { baseFeePerGas, difficulty, extraData, gasLimit, gasUsed, hash, miner, nonce, number, parentHash, timestamp, transactions } = this;
|
|
42506
|
+
const { baseFeePerGas, difficulty, extraData, gasLimit, gasUsed, hash, miner, prevRandao, nonce, number, parentHash, parentBeaconBlockRoot, stateRoot, receiptsRoot, timestamp, transactions } = this;
|
|
41689
42507
|
return {
|
|
41690
42508
|
_type: "Block",
|
|
41691
42509
|
baseFeePerGas: toJson(baseFeePerGas),
|
|
@@ -41693,7 +42511,10 @@ class Block {
|
|
|
41693
42511
|
extraData,
|
|
41694
42512
|
gasLimit: toJson(gasLimit),
|
|
41695
42513
|
gasUsed: toJson(gasUsed),
|
|
41696
|
-
|
|
42514
|
+
blobGasUsed: toJson(this.blobGasUsed),
|
|
42515
|
+
excessBlobGas: toJson(this.excessBlobGas),
|
|
42516
|
+
hash, miner, prevRandao, nonce, number, parentHash, timestamp,
|
|
42517
|
+
parentBeaconBlockRoot, stateRoot, receiptsRoot,
|
|
41697
42518
|
transactions,
|
|
41698
42519
|
};
|
|
41699
42520
|
}
|
|
@@ -41951,7 +42772,7 @@ class TransactionReceipt {
|
|
|
41951
42772
|
*/
|
|
41952
42773
|
provider;
|
|
41953
42774
|
/**
|
|
41954
|
-
* The address the transaction was
|
|
42775
|
+
* The address the transaction was sent to.
|
|
41955
42776
|
*/
|
|
41956
42777
|
to;
|
|
41957
42778
|
/**
|
|
@@ -41996,6 +42817,10 @@ class TransactionReceipt {
|
|
|
41996
42817
|
* entire gas limit. After the transaction, the difference is refunded.
|
|
41997
42818
|
*/
|
|
41998
42819
|
gasUsed;
|
|
42820
|
+
/**
|
|
42821
|
+
* The gas used for BLObs. See [[link-eip-4844]].
|
|
42822
|
+
*/
|
|
42823
|
+
blobGasUsed;
|
|
41999
42824
|
/**
|
|
42000
42825
|
* The amount of gas used by all transactions within the block for this
|
|
42001
42826
|
* and all transactions with a lower ``index``.
|
|
@@ -42012,6 +42837,10 @@ class TransactionReceipt {
|
|
|
42012
42837
|
* fee is protocol-enforced.
|
|
42013
42838
|
*/
|
|
42014
42839
|
gasPrice;
|
|
42840
|
+
/**
|
|
42841
|
+
* The price paid per BLOB in gas. See [[link-eip-4844]].
|
|
42842
|
+
*/
|
|
42843
|
+
blobGasPrice;
|
|
42015
42844
|
/**
|
|
42016
42845
|
* The [[link-eip-2718]] transaction type.
|
|
42017
42846
|
*/
|
|
@@ -42059,7 +42888,9 @@ class TransactionReceipt {
|
|
|
42059
42888
|
logsBloom: tx.logsBloom,
|
|
42060
42889
|
gasUsed: tx.gasUsed,
|
|
42061
42890
|
cumulativeGasUsed: tx.cumulativeGasUsed,
|
|
42891
|
+
blobGasUsed: tx.blobGasUsed,
|
|
42062
42892
|
gasPrice,
|
|
42893
|
+
blobGasPrice: tx.blobGasPrice,
|
|
42063
42894
|
type: tx.type,
|
|
42064
42895
|
//byzantium: tx.byzantium,
|
|
42065
42896
|
status: tx.status,
|
|
@@ -42084,6 +42915,8 @@ class TransactionReceipt {
|
|
|
42084
42915
|
cumulativeGasUsed: toJson(this.cumulativeGasUsed),
|
|
42085
42916
|
from,
|
|
42086
42917
|
gasPrice: toJson(this.gasPrice),
|
|
42918
|
+
blobGasUsed: toJson(this.blobGasUsed),
|
|
42919
|
+
blobGasPrice: toJson(this.blobGasPrice),
|
|
42087
42920
|
gasUsed: toJson(this.gasUsed),
|
|
42088
42921
|
hash, index, logs, logsBloom, root, status, to
|
|
42089
42922
|
};
|
|
@@ -42252,6 +43085,10 @@ class TransactionResponse {
|
|
|
42252
43085
|
* to charge the sender.
|
|
42253
43086
|
*/
|
|
42254
43087
|
maxFeePerGas;
|
|
43088
|
+
/**
|
|
43089
|
+
* The [[link-eip-4844]] max fee per BLOb gas.
|
|
43090
|
+
*/
|
|
43091
|
+
maxFeePerBlobGas;
|
|
42255
43092
|
/**
|
|
42256
43093
|
* The data.
|
|
42257
43094
|
*/
|
|
@@ -42274,6 +43111,10 @@ class TransactionResponse {
|
|
|
42274
43111
|
* support it, otherwise ``null``.
|
|
42275
43112
|
*/
|
|
42276
43113
|
accessList;
|
|
43114
|
+
/**
|
|
43115
|
+
* The [[link-eip-4844]] BLOb versioned hashes.
|
|
43116
|
+
*/
|
|
43117
|
+
blobVersionedHashes;
|
|
42277
43118
|
#startBlock;
|
|
42278
43119
|
/**
|
|
42279
43120
|
* @_ignore:
|
|
@@ -42294,19 +43135,22 @@ class TransactionResponse {
|
|
|
42294
43135
|
this.gasPrice = tx.gasPrice;
|
|
42295
43136
|
this.maxPriorityFeePerGas = (tx.maxPriorityFeePerGas != null) ? tx.maxPriorityFeePerGas : null;
|
|
42296
43137
|
this.maxFeePerGas = (tx.maxFeePerGas != null) ? tx.maxFeePerGas : null;
|
|
43138
|
+
this.maxFeePerBlobGas = (tx.maxFeePerBlobGas != null) ? tx.maxFeePerBlobGas : null;
|
|
42297
43139
|
this.chainId = tx.chainId;
|
|
42298
43140
|
this.signature = tx.signature;
|
|
42299
43141
|
this.accessList = (tx.accessList != null) ? tx.accessList : null;
|
|
43142
|
+
this.blobVersionedHashes = (tx.blobVersionedHashes != null) ? tx.blobVersionedHashes : null;
|
|
42300
43143
|
this.#startBlock = -1;
|
|
42301
43144
|
}
|
|
42302
43145
|
/**
|
|
42303
43146
|
* Returns a JSON-compatible representation of this transaction.
|
|
42304
43147
|
*/
|
|
42305
43148
|
toJSON() {
|
|
42306
|
-
const { blockNumber, blockHash, index, hash, type, to, from, nonce, data, signature, accessList } = this;
|
|
43149
|
+
const { blockNumber, blockHash, index, hash, type, to, from, nonce, data, signature, accessList, blobVersionedHashes } = this;
|
|
42307
43150
|
return {
|
|
42308
|
-
_type: "
|
|
43151
|
+
_type: "TransactionResponse",
|
|
42309
43152
|
accessList, blockNumber, blockHash,
|
|
43153
|
+
blobVersionedHashes,
|
|
42310
43154
|
chainId: toJson(this.chainId),
|
|
42311
43155
|
data, from,
|
|
42312
43156
|
gasLimit: toJson(this.gasLimit),
|
|
@@ -42314,6 +43158,7 @@ class TransactionResponse {
|
|
|
42314
43158
|
hash,
|
|
42315
43159
|
maxFeePerGas: toJson(this.maxFeePerGas),
|
|
42316
43160
|
maxPriorityFeePerGas: toJson(this.maxPriorityFeePerGas),
|
|
43161
|
+
maxFeePerBlobGas: toJson(this.maxFeePerBlobGas),
|
|
42317
43162
|
nonce, signature, to, index, type,
|
|
42318
43163
|
value: toJson(this.value),
|
|
42319
43164
|
};
|
|
@@ -42595,6 +43440,13 @@ class TransactionResponse {
|
|
|
42595
43440
|
isLondon() {
|
|
42596
43441
|
return (this.type === 2);
|
|
42597
43442
|
}
|
|
43443
|
+
/**
|
|
43444
|
+
* Returns true if hte transaction is a Cancun (i.e. ``type == 3``)
|
|
43445
|
+
* transaction. See [[link-eip-4844]].
|
|
43446
|
+
*/
|
|
43447
|
+
isCancun() {
|
|
43448
|
+
return (this.type === 3);
|
|
43449
|
+
}
|
|
42598
43450
|
/**
|
|
42599
43451
|
* Returns a filter which can be used to listen for orphan events
|
|
42600
43452
|
* that evict this transaction.
|
|
@@ -42754,8 +43606,8 @@ class ContractTransactionResponse extends TransactionResponse {
|
|
|
42754
43606
|
* and the transaction has not been mined, otherwise this will
|
|
42755
43607
|
* wait until enough confirmations have completed.
|
|
42756
43608
|
*/
|
|
42757
|
-
async wait(confirms) {
|
|
42758
|
-
const receipt = await super.wait(confirms);
|
|
43609
|
+
async wait(confirms, timeout) {
|
|
43610
|
+
const receipt = await super.wait(confirms, timeout);
|
|
42759
43611
|
if (receipt == null) {
|
|
42760
43612
|
return null;
|
|
42761
43613
|
}
|
|
@@ -43814,13 +44666,13 @@ class MulticoinProviderPlugin {
|
|
|
43814
44666
|
return false;
|
|
43815
44667
|
}
|
|
43816
44668
|
/**
|
|
43817
|
-
*
|
|
44669
|
+
* Resolves to the encoded %%address%% for %%coinType%%.
|
|
43818
44670
|
*/
|
|
43819
44671
|
async encodeAddress(coinType, address) {
|
|
43820
44672
|
throw new Error("unsupported coin");
|
|
43821
44673
|
}
|
|
43822
44674
|
/**
|
|
43823
|
-
*
|
|
44675
|
+
* Resolves to the decoded %%data%% for %%coinType%%.
|
|
43824
44676
|
*/
|
|
43825
44677
|
async decodeAddress(coinType, data) {
|
|
43826
44678
|
throw new Error("unsupported coin");
|
|
@@ -43900,7 +44752,7 @@ class EnsResolver {
|
|
|
43900
44752
|
info: { funcName }
|
|
43901
44753
|
});
|
|
43902
44754
|
params = [
|
|
43903
|
-
dnsEncode(this.name),
|
|
44755
|
+
dnsEncode(this.name, 255),
|
|
43904
44756
|
iface.encodeFunctionData(fragment, params)
|
|
43905
44757
|
];
|
|
43906
44758
|
funcName = "resolve(bytes,bytes)";
|
|
@@ -44255,8 +45107,11 @@ function allowNull(format, nullValue) {
|
|
|
44255
45107
|
return format(value);
|
|
44256
45108
|
});
|
|
44257
45109
|
}
|
|
44258
|
-
function arrayOf(format) {
|
|
45110
|
+
function arrayOf(format, allowNull) {
|
|
44259
45111
|
return ((array) => {
|
|
45112
|
+
if (allowNull && array == null) {
|
|
45113
|
+
return null;
|
|
45114
|
+
}
|
|
44260
45115
|
if (!Array.isArray(array)) {
|
|
44261
45116
|
throw new Error("not an array");
|
|
44262
45117
|
}
|
|
@@ -44331,15 +45186,23 @@ function formatLog(value) {
|
|
|
44331
45186
|
const _formatBlock = object({
|
|
44332
45187
|
hash: allowNull(formatHash),
|
|
44333
45188
|
parentHash: formatHash,
|
|
45189
|
+
parentBeaconBlockRoot: allowNull(formatHash, null),
|
|
44334
45190
|
number: getNumber,
|
|
44335
45191
|
timestamp: getNumber,
|
|
44336
45192
|
nonce: allowNull(formatData),
|
|
44337
45193
|
difficulty: getBigInt,
|
|
44338
45194
|
gasLimit: getBigInt,
|
|
44339
45195
|
gasUsed: getBigInt,
|
|
45196
|
+
stateRoot: allowNull(formatHash, null),
|
|
45197
|
+
receiptsRoot: allowNull(formatHash, null),
|
|
45198
|
+
blobGasUsed: allowNull(getBigInt, null),
|
|
45199
|
+
excessBlobGas: allowNull(getBigInt, null),
|
|
44340
45200
|
miner: allowNull(getAddress),
|
|
45201
|
+
prevRandao: allowNull(formatHash, null),
|
|
44341
45202
|
extraData: formatData,
|
|
44342
45203
|
baseFeePerGas: allowNull(getBigInt)
|
|
45204
|
+
}, {
|
|
45205
|
+
prevRandao: ["mixHash"]
|
|
44343
45206
|
});
|
|
44344
45207
|
function formatBlock(value) {
|
|
44345
45208
|
const result = _formatBlock(value);
|
|
@@ -44374,6 +45237,7 @@ const _formatTransactionReceipt = object({
|
|
|
44374
45237
|
index: getNumber,
|
|
44375
45238
|
root: allowNull(hexlify),
|
|
44376
45239
|
gasUsed: getBigInt,
|
|
45240
|
+
blobGasUsed: allowNull(getBigInt, null),
|
|
44377
45241
|
logsBloom: allowNull(formatData),
|
|
44378
45242
|
blockHash: formatHash,
|
|
44379
45243
|
hash: formatHash,
|
|
@@ -44382,6 +45246,7 @@ const _formatTransactionReceipt = object({
|
|
|
44382
45246
|
//confirmations: allowNull(getNumber, null),
|
|
44383
45247
|
cumulativeGasUsed: getBigInt,
|
|
44384
45248
|
effectiveGasPrice: allowNull(getBigInt),
|
|
45249
|
+
blobGasPrice: allowNull(getBigInt, null),
|
|
44385
45250
|
status: allowNull(getNumber),
|
|
44386
45251
|
type: allowNull(getNumber, 0)
|
|
44387
45252
|
}, {
|
|
@@ -44400,6 +45265,8 @@ function formatTransactionResponse(value) {
|
|
|
44400
45265
|
}
|
|
44401
45266
|
const result = object({
|
|
44402
45267
|
hash: formatHash,
|
|
45268
|
+
// Some nodes do not return this, usually test nodes (like Ganache)
|
|
45269
|
+
index: allowNull(getNumber, undefined),
|
|
44403
45270
|
type: (value) => {
|
|
44404
45271
|
if (value === "0x" || value == null) {
|
|
44405
45272
|
return 0;
|
|
@@ -44407,15 +45274,16 @@ function formatTransactionResponse(value) {
|
|
|
44407
45274
|
return getNumber(value);
|
|
44408
45275
|
},
|
|
44409
45276
|
accessList: allowNull(accessListify, null),
|
|
45277
|
+
blobVersionedHashes: allowNull(arrayOf(formatHash, true), null),
|
|
44410
45278
|
blockHash: allowNull(formatHash, null),
|
|
44411
45279
|
blockNumber: allowNull(getNumber, null),
|
|
44412
45280
|
transactionIndex: allowNull(getNumber, null),
|
|
44413
|
-
//confirmations: allowNull(getNumber, null),
|
|
44414
45281
|
from: getAddress,
|
|
44415
45282
|
// either (gasPrice) or (maxPriorityFeePerGas + maxFeePerGas) must be set
|
|
44416
45283
|
gasPrice: allowNull(getBigInt),
|
|
44417
45284
|
maxPriorityFeePerGas: allowNull(getBigInt),
|
|
44418
45285
|
maxFeePerGas: allowNull(getBigInt),
|
|
45286
|
+
maxFeePerBlobGas: allowNull(getBigInt, null),
|
|
44419
45287
|
gasLimit: getBigInt,
|
|
44420
45288
|
to: allowNull(getAddress, null),
|
|
44421
45289
|
value: getBigInt,
|
|
@@ -44425,7 +45293,8 @@ function formatTransactionResponse(value) {
|
|
|
44425
45293
|
chainId: allowNull(getBigInt, null)
|
|
44426
45294
|
}, {
|
|
44427
45295
|
data: ["input"],
|
|
44428
|
-
gasLimit: ["gas"]
|
|
45296
|
+
gasLimit: ["gas"],
|
|
45297
|
+
index: ["transactionIndex"]
|
|
44429
45298
|
})(value);
|
|
44430
45299
|
// If to and creates are empty, populate the creates from the value
|
|
44431
45300
|
if (result.to == null && result.creates == null) {
|
|
@@ -44951,23 +45820,6 @@ function getGasStationPlugin(url) {
|
|
|
44951
45820
|
}
|
|
44952
45821
|
});
|
|
44953
45822
|
}
|
|
44954
|
-
// Used by Optimism for a custom priority fee
|
|
44955
|
-
function getPriorityFeePlugin(maxPriorityFeePerGas) {
|
|
44956
|
-
return new FetchUrlFeeDataNetworkPlugin("data:", async (fetchFeeData, provider, request) => {
|
|
44957
|
-
const feeData = await fetchFeeData();
|
|
44958
|
-
// This should always fail
|
|
44959
|
-
if (feeData.maxFeePerGas == null || feeData.maxPriorityFeePerGas == null) {
|
|
44960
|
-
return feeData;
|
|
44961
|
-
}
|
|
44962
|
-
// Compute the corrected baseFee to recompute the updated values
|
|
44963
|
-
const baseFee = feeData.maxFeePerGas - feeData.maxPriorityFeePerGas;
|
|
44964
|
-
return {
|
|
44965
|
-
gasPrice: feeData.gasPrice,
|
|
44966
|
-
maxFeePerGas: (baseFee + maxPriorityFeePerGas),
|
|
44967
|
-
maxPriorityFeePerGas
|
|
44968
|
-
};
|
|
44969
|
-
});
|
|
44970
|
-
}
|
|
44971
45823
|
// See: https://chainlist.org
|
|
44972
45824
|
let injected = false;
|
|
44973
45825
|
function injectCommonNetworks() {
|
|
@@ -45003,23 +45855,30 @@ function injectCommonNetworks() {
|
|
|
45003
45855
|
registerEth("rinkeby", 4, { ensNetwork: 4 });
|
|
45004
45856
|
registerEth("goerli", 5, { ensNetwork: 5 });
|
|
45005
45857
|
registerEth("kovan", 42, { ensNetwork: 42 });
|
|
45006
|
-
registerEth("sepolia", 11155111, {});
|
|
45858
|
+
registerEth("sepolia", 11155111, { ensNetwork: 11155111 });
|
|
45859
|
+
registerEth("holesky", 17000, { ensNetwork: 17000 });
|
|
45007
45860
|
registerEth("classic", 61, {});
|
|
45008
45861
|
registerEth("classicKotti", 6, {});
|
|
45009
45862
|
registerEth("arbitrum", 42161, {
|
|
45010
45863
|
ensNetwork: 1,
|
|
45011
45864
|
});
|
|
45012
45865
|
registerEth("arbitrum-goerli", 421613, {});
|
|
45866
|
+
registerEth("arbitrum-sepolia", 421614, {});
|
|
45867
|
+
registerEth("base", 8453, { ensNetwork: 1 });
|
|
45868
|
+
registerEth("base-goerli", 84531, {});
|
|
45869
|
+
registerEth("base-sepolia", 84532, {});
|
|
45013
45870
|
registerEth("bnb", 56, { ensNetwork: 1 });
|
|
45014
45871
|
registerEth("bnbt", 97, {});
|
|
45015
45872
|
registerEth("linea", 59144, { ensNetwork: 1 });
|
|
45016
45873
|
registerEth("linea-goerli", 59140, {});
|
|
45874
|
+
registerEth("linea-sepolia", 59141, {});
|
|
45017
45875
|
registerEth("matic", 137, {
|
|
45018
45876
|
ensNetwork: 1,
|
|
45019
45877
|
plugins: [
|
|
45020
45878
|
getGasStationPlugin("https:/\/gasstation.polygon.technology/v2")
|
|
45021
45879
|
]
|
|
45022
45880
|
});
|
|
45881
|
+
registerEth("matic-amoy", 80002, {});
|
|
45023
45882
|
registerEth("matic-mumbai", 80001, {
|
|
45024
45883
|
altNames: ["maticMumbai", "maticmum"],
|
|
45025
45884
|
plugins: [
|
|
@@ -45028,11 +45887,10 @@ function injectCommonNetworks() {
|
|
|
45028
45887
|
});
|
|
45029
45888
|
registerEth("optimism", 10, {
|
|
45030
45889
|
ensNetwork: 1,
|
|
45031
|
-
plugins: [
|
|
45032
|
-
getPriorityFeePlugin(BigInt("1000000"))
|
|
45033
|
-
]
|
|
45890
|
+
plugins: []
|
|
45034
45891
|
});
|
|
45035
45892
|
registerEth("optimism-goerli", 420, {});
|
|
45893
|
+
registerEth("optimism-sepolia", 11155420, {});
|
|
45036
45894
|
registerEth("xdai", 100, { ensNetwork: 1 });
|
|
45037
45895
|
}
|
|
45038
45896
|
|
|
@@ -45166,6 +46024,34 @@ class OnBlockSubscriber {
|
|
|
45166
46024
|
pause(dropWhilePaused) { this.stop(); }
|
|
45167
46025
|
resume() { this.start(); }
|
|
45168
46026
|
}
|
|
46027
|
+
class PollingBlockTagSubscriber extends OnBlockSubscriber {
|
|
46028
|
+
#tag;
|
|
46029
|
+
#lastBlock;
|
|
46030
|
+
constructor(provider, tag) {
|
|
46031
|
+
super(provider);
|
|
46032
|
+
this.#tag = tag;
|
|
46033
|
+
this.#lastBlock = -2;
|
|
46034
|
+
}
|
|
46035
|
+
pause(dropWhilePaused) {
|
|
46036
|
+
if (dropWhilePaused) {
|
|
46037
|
+
this.#lastBlock = -2;
|
|
46038
|
+
}
|
|
46039
|
+
super.pause(dropWhilePaused);
|
|
46040
|
+
}
|
|
46041
|
+
async _poll(blockNumber, provider) {
|
|
46042
|
+
const block = await provider.getBlock(this.#tag);
|
|
46043
|
+
if (block == null) {
|
|
46044
|
+
return;
|
|
46045
|
+
}
|
|
46046
|
+
if (this.#lastBlock === -2) {
|
|
46047
|
+
this.#lastBlock = block.number;
|
|
46048
|
+
}
|
|
46049
|
+
else if (block.number > this.#lastBlock) {
|
|
46050
|
+
provider.emit(this.#tag, block.number);
|
|
46051
|
+
this.#lastBlock = block.number;
|
|
46052
|
+
}
|
|
46053
|
+
}
|
|
46054
|
+
}
|
|
45169
46055
|
/**
|
|
45170
46056
|
* @_ignore:
|
|
45171
46057
|
*
|
|
@@ -45364,10 +46250,12 @@ async function getSubscription(_event, provider) {
|
|
|
45364
46250
|
if (typeof (_event) === "string") {
|
|
45365
46251
|
switch (_event) {
|
|
45366
46252
|
case "block":
|
|
45367
|
-
case "pending":
|
|
45368
46253
|
case "debug":
|
|
45369
46254
|
case "error":
|
|
45370
|
-
case "
|
|
46255
|
+
case "finalized":
|
|
46256
|
+
case "network":
|
|
46257
|
+
case "pending":
|
|
46258
|
+
case "safe": {
|
|
45371
46259
|
return { type: _event, tag: _event };
|
|
45372
46260
|
}
|
|
45373
46261
|
}
|
|
@@ -45665,10 +46553,10 @@ class AbstractProvider {
|
|
|
45665
46553
|
switch (blockTag) {
|
|
45666
46554
|
case "earliest":
|
|
45667
46555
|
return "0x0";
|
|
46556
|
+
case "finalized":
|
|
45668
46557
|
case "latest":
|
|
45669
46558
|
case "pending":
|
|
45670
46559
|
case "safe":
|
|
45671
|
-
case "finalized":
|
|
45672
46560
|
return blockTag;
|
|
45673
46561
|
}
|
|
45674
46562
|
if (isHexString(blockTag)) {
|
|
@@ -45772,7 +46660,7 @@ class AbstractProvider {
|
|
|
45772
46660
|
return resolve(address, fromBlock, toBlock);
|
|
45773
46661
|
}
|
|
45774
46662
|
/**
|
|
45775
|
-
* Returns or
|
|
46663
|
+
* Returns or resolves to a transaction for %%request%%, resolving
|
|
45776
46664
|
* any ENS names or [[Addressable]] and returning if already a valid
|
|
45777
46665
|
* transaction.
|
|
45778
46666
|
*/
|
|
@@ -45812,16 +46700,19 @@ class AbstractProvider {
|
|
|
45812
46700
|
// No explicit network was set and this is our first time
|
|
45813
46701
|
if (this.#networkPromise == null) {
|
|
45814
46702
|
// Detect the current network (shared with all calls)
|
|
45815
|
-
const detectNetwork =
|
|
45816
|
-
|
|
45817
|
-
|
|
45818
|
-
|
|
45819
|
-
|
|
45820
|
-
if (this.#networkPromise === detectNetwork) {
|
|
45821
|
-
this.#networkPromise = null;
|
|
46703
|
+
const detectNetwork = (async () => {
|
|
46704
|
+
try {
|
|
46705
|
+
const network = await this._detectNetwork();
|
|
46706
|
+
this.emit("network", network, null);
|
|
46707
|
+
return network;
|
|
45822
46708
|
}
|
|
45823
|
-
|
|
45824
|
-
|
|
46709
|
+
catch (error) {
|
|
46710
|
+
if (this.#networkPromise === detectNetwork) {
|
|
46711
|
+
this.#networkPromise = null;
|
|
46712
|
+
}
|
|
46713
|
+
throw error;
|
|
46714
|
+
}
|
|
46715
|
+
})();
|
|
45825
46716
|
this.#networkPromise = detectNetwork;
|
|
45826
46717
|
return (await detectNetwork).clone();
|
|
45827
46718
|
}
|
|
@@ -45851,12 +46742,20 @@ class AbstractProvider {
|
|
|
45851
46742
|
async getFeeData() {
|
|
45852
46743
|
const network = await this.getNetwork();
|
|
45853
46744
|
const getFeeDataFunc = async () => {
|
|
45854
|
-
const { _block, gasPrice } = await resolveProperties({
|
|
46745
|
+
const { _block, gasPrice, priorityFee } = await resolveProperties({
|
|
45855
46746
|
_block: this.#getBlock("latest", false),
|
|
45856
46747
|
gasPrice: ((async () => {
|
|
45857
46748
|
try {
|
|
45858
|
-
const
|
|
45859
|
-
return getBigInt(
|
|
46749
|
+
const value = await this.#perform({ method: "getGasPrice" });
|
|
46750
|
+
return getBigInt(value, "%response");
|
|
46751
|
+
}
|
|
46752
|
+
catch (error) { }
|
|
46753
|
+
return null;
|
|
46754
|
+
})()),
|
|
46755
|
+
priorityFee: ((async () => {
|
|
46756
|
+
try {
|
|
46757
|
+
const value = await this.#perform({ method: "getPriorityFee" });
|
|
46758
|
+
return getBigInt(value, "%response");
|
|
45860
46759
|
}
|
|
45861
46760
|
catch (error) { }
|
|
45862
46761
|
return null;
|
|
@@ -45867,7 +46766,7 @@ class AbstractProvider {
|
|
|
45867
46766
|
// These are the recommended EIP-1559 heuristics for fee data
|
|
45868
46767
|
const block = this._wrapBlock(_block, network);
|
|
45869
46768
|
if (block && block.baseFeePerGas) {
|
|
45870
|
-
maxPriorityFeePerGas = BigInt("1000000000");
|
|
46769
|
+
maxPriorityFeePerGas = (priorityFee != null) ? priorityFee : BigInt("1000000000");
|
|
45871
46770
|
maxFeePerGas = (block.baseFeePerGas * BN_2) + maxPriorityFeePerGas;
|
|
45872
46771
|
}
|
|
45873
46772
|
return new FeeData(gasPrice, maxFeePerGas, maxPriorityFeePerGas);
|
|
@@ -46245,6 +47144,9 @@ class AbstractProvider {
|
|
|
46245
47144
|
subscriber.pollingInterval = this.pollingInterval;
|
|
46246
47145
|
return subscriber;
|
|
46247
47146
|
}
|
|
47147
|
+
case "safe":
|
|
47148
|
+
case "finalized":
|
|
47149
|
+
return new PollingBlockTagSubscriber(this, sub.type);
|
|
46248
47150
|
case "event":
|
|
46249
47151
|
return new PollingEventSubscriber(this, sub.filter);
|
|
46250
47152
|
case "transaction":
|
|
@@ -46795,8 +47697,8 @@ class AbstractSigner {
|
|
|
46795
47697
|
});
|
|
46796
47698
|
}
|
|
46797
47699
|
}
|
|
46798
|
-
else if (pop.type === 2) {
|
|
46799
|
-
// Explicitly using EIP-1559
|
|
47700
|
+
else if (pop.type === 2 || pop.type === 3) {
|
|
47701
|
+
// Explicitly using EIP-1559 or EIP-4844
|
|
46800
47702
|
// Populate missing fee data
|
|
46801
47703
|
if (pop.maxFeePerGas == null) {
|
|
46802
47704
|
pop.maxFeePerGas = feeData.maxFeePerGas;
|
|
@@ -46926,6 +47828,9 @@ class FilterIdSubscriber {
|
|
|
46926
47828
|
if (filterIdPromise) {
|
|
46927
47829
|
this.#filterIdPromise = null;
|
|
46928
47830
|
filterIdPromise.then((filterId) => {
|
|
47831
|
+
if (this.#provider.destroyed) {
|
|
47832
|
+
return;
|
|
47833
|
+
}
|
|
46929
47834
|
this.#provider.send("eth_uninstallFilter", [filterId]);
|
|
46930
47835
|
});
|
|
46931
47836
|
}
|
|
@@ -47123,12 +48028,45 @@ class JsonRpcSigner extends AbstractSigner {
|
|
|
47123
48028
|
// for it; it should show up very quickly
|
|
47124
48029
|
return await (new Promise((resolve, reject) => {
|
|
47125
48030
|
const timeouts = [1000, 100];
|
|
48031
|
+
let invalids = 0;
|
|
47126
48032
|
const checkTx = async () => {
|
|
47127
|
-
|
|
47128
|
-
|
|
47129
|
-
|
|
47130
|
-
|
|
47131
|
-
|
|
48033
|
+
try {
|
|
48034
|
+
// Try getting the transaction
|
|
48035
|
+
const tx = await this.provider.getTransaction(hash);
|
|
48036
|
+
if (tx != null) {
|
|
48037
|
+
resolve(tx.replaceableTransaction(blockNumber));
|
|
48038
|
+
return;
|
|
48039
|
+
}
|
|
48040
|
+
}
|
|
48041
|
+
catch (error) {
|
|
48042
|
+
// If we were cancelled: stop polling.
|
|
48043
|
+
// If the data is bad: the node returns bad transactions
|
|
48044
|
+
// If the network changed: calling again will also fail
|
|
48045
|
+
// If unsupported: likely destroyed
|
|
48046
|
+
if (isError(error, "CANCELLED") || isError(error, "BAD_DATA") ||
|
|
48047
|
+
isError(error, "NETWORK_ERROR" )) {
|
|
48048
|
+
if (error.info == null) {
|
|
48049
|
+
error.info = {};
|
|
48050
|
+
}
|
|
48051
|
+
error.info.sendTransactionHash = hash;
|
|
48052
|
+
reject(error);
|
|
48053
|
+
return;
|
|
48054
|
+
}
|
|
48055
|
+
// Stop-gap for misbehaving backends; see #4513
|
|
48056
|
+
if (isError(error, "INVALID_ARGUMENT")) {
|
|
48057
|
+
invalids++;
|
|
48058
|
+
if (error.info == null) {
|
|
48059
|
+
error.info = {};
|
|
48060
|
+
}
|
|
48061
|
+
error.info.sendTransactionHash = hash;
|
|
48062
|
+
if (invalids > 10) {
|
|
48063
|
+
reject(error);
|
|
48064
|
+
return;
|
|
48065
|
+
}
|
|
48066
|
+
}
|
|
48067
|
+
// Notify anyone that cares; but we will try again, since
|
|
48068
|
+
// it is likely an intermittent service error
|
|
48069
|
+
this.provider.emit("error", makeError("failed to fetch transation after sending (will try again)", "UNKNOWN_ERROR", { error }));
|
|
47132
48070
|
}
|
|
47133
48071
|
// Wait another 4 seconds
|
|
47134
48072
|
this.provider._setTimeout(() => { checkTx(); }, timeouts.pop() || 4000);
|
|
@@ -47201,11 +48139,12 @@ class JsonRpcApiProvider extends AbstractProvider {
|
|
|
47201
48139
|
#drainTimer;
|
|
47202
48140
|
#notReady;
|
|
47203
48141
|
#network;
|
|
48142
|
+
#pendingDetectNetwork;
|
|
47204
48143
|
#scheduleDrain() {
|
|
47205
48144
|
if (this.#drainTimer) {
|
|
47206
48145
|
return;
|
|
47207
48146
|
}
|
|
47208
|
-
// If we aren't using batching, no
|
|
48147
|
+
// If we aren't using batching, no harm in sending it immediately
|
|
47209
48148
|
const stallTime = (this._getOption("batchMaxCount") === 1) ? 0 : this._getOption("batchStallTime");
|
|
47210
48149
|
this.#drainTimer = setTimeout(() => {
|
|
47211
48150
|
this.#drainTimer = null;
|
|
@@ -47276,6 +48215,7 @@ class JsonRpcApiProvider extends AbstractProvider {
|
|
|
47276
48215
|
this.#payloads = [];
|
|
47277
48216
|
this.#drainTimer = null;
|
|
47278
48217
|
this.#network = null;
|
|
48218
|
+
this.#pendingDetectNetwork = null;
|
|
47279
48219
|
{
|
|
47280
48220
|
let resolve = null;
|
|
47281
48221
|
const promise = new Promise((_resolve) => {
|
|
@@ -47283,9 +48223,15 @@ class JsonRpcApiProvider extends AbstractProvider {
|
|
|
47283
48223
|
});
|
|
47284
48224
|
this.#notReady = { promise, resolve };
|
|
47285
48225
|
}
|
|
47286
|
-
// Make sure any static network is compatbile with the provided netwrok
|
|
47287
48226
|
const staticNetwork = this._getOption("staticNetwork");
|
|
47288
|
-
if (staticNetwork) {
|
|
48227
|
+
if (typeof (staticNetwork) === "boolean") {
|
|
48228
|
+
assertArgument(!staticNetwork || network !== "any", "staticNetwork cannot be used on special network 'any'", "options", options);
|
|
48229
|
+
if (staticNetwork && network != null) {
|
|
48230
|
+
this.#network = Network.from(network);
|
|
48231
|
+
}
|
|
48232
|
+
}
|
|
48233
|
+
else if (staticNetwork) {
|
|
48234
|
+
// Make sure any static network is compatbile with the provided netwrok
|
|
47289
48235
|
assertArgument(network == null || staticNetwork.matches(network), "staticNetwork MUST match network object", "options", options);
|
|
47290
48236
|
this.#network = staticNetwork;
|
|
47291
48237
|
}
|
|
@@ -47318,7 +48264,7 @@ class JsonRpcApiProvider extends AbstractProvider {
|
|
|
47318
48264
|
if (req.method === "call" || req.method === "estimateGas") {
|
|
47319
48265
|
let tx = req.transaction;
|
|
47320
48266
|
if (tx && tx.type != null && getBigInt(tx.type)) {
|
|
47321
|
-
// If there are no EIP-1559 properties, it might be
|
|
48267
|
+
// If there are no EIP-1559 or newer properties, it might be pre-EIP-1559
|
|
47322
48268
|
if (tx.maxFeePerGas == null && tx.maxPriorityFeePerGas == null) {
|
|
47323
48269
|
const feeData = await this.getFeeData();
|
|
47324
48270
|
if (feeData.maxFeePerGas == null && feeData.maxPriorityFeePerGas == null) {
|
|
@@ -47346,30 +48292,56 @@ class JsonRpcApiProvider extends AbstractProvider {
|
|
|
47346
48292
|
async _detectNetwork() {
|
|
47347
48293
|
const network = this._getOption("staticNetwork");
|
|
47348
48294
|
if (network) {
|
|
47349
|
-
|
|
48295
|
+
if (network === true) {
|
|
48296
|
+
if (this.#network) {
|
|
48297
|
+
return this.#network;
|
|
48298
|
+
}
|
|
48299
|
+
}
|
|
48300
|
+
else {
|
|
48301
|
+
return network;
|
|
48302
|
+
}
|
|
48303
|
+
}
|
|
48304
|
+
if (this.#pendingDetectNetwork) {
|
|
48305
|
+
return await this.#pendingDetectNetwork;
|
|
47350
48306
|
}
|
|
47351
48307
|
// If we are ready, use ``send``, which enabled requests to be batched
|
|
47352
48308
|
if (this.ready) {
|
|
47353
|
-
|
|
48309
|
+
this.#pendingDetectNetwork = (async () => {
|
|
48310
|
+
try {
|
|
48311
|
+
const result = Network.from(getBigInt(await this.send("eth_chainId", [])));
|
|
48312
|
+
this.#pendingDetectNetwork = null;
|
|
48313
|
+
return result;
|
|
48314
|
+
}
|
|
48315
|
+
catch (error) {
|
|
48316
|
+
this.#pendingDetectNetwork = null;
|
|
48317
|
+
throw error;
|
|
48318
|
+
}
|
|
48319
|
+
})();
|
|
48320
|
+
return await this.#pendingDetectNetwork;
|
|
47354
48321
|
}
|
|
47355
48322
|
// We are not ready yet; use the primitive _send
|
|
47356
|
-
|
|
47357
|
-
|
|
47358
|
-
|
|
47359
|
-
|
|
47360
|
-
|
|
47361
|
-
|
|
47362
|
-
|
|
47363
|
-
|
|
47364
|
-
|
|
47365
|
-
|
|
47366
|
-
|
|
47367
|
-
|
|
47368
|
-
|
|
47369
|
-
|
|
47370
|
-
|
|
47371
|
-
|
|
47372
|
-
|
|
48323
|
+
this.#pendingDetectNetwork = (async () => {
|
|
48324
|
+
const payload = {
|
|
48325
|
+
id: this.#nextId++, method: "eth_chainId", params: [], jsonrpc: "2.0"
|
|
48326
|
+
};
|
|
48327
|
+
this.emit("debug", { action: "sendRpcPayload", payload });
|
|
48328
|
+
let result;
|
|
48329
|
+
try {
|
|
48330
|
+
result = (await this._send(payload))[0];
|
|
48331
|
+
this.#pendingDetectNetwork = null;
|
|
48332
|
+
}
|
|
48333
|
+
catch (error) {
|
|
48334
|
+
this.#pendingDetectNetwork = null;
|
|
48335
|
+
this.emit("debug", { action: "receiveRpcError", error });
|
|
48336
|
+
throw error;
|
|
48337
|
+
}
|
|
48338
|
+
this.emit("debug", { action: "receiveRpcResult", result });
|
|
48339
|
+
if ("result" in result) {
|
|
48340
|
+
return Network.from(getBigInt(result.result));
|
|
48341
|
+
}
|
|
48342
|
+
throw this.getRpcError(payload, result);
|
|
48343
|
+
})();
|
|
48344
|
+
return await this.#pendingDetectNetwork;
|
|
47373
48345
|
}
|
|
47374
48346
|
/**
|
|
47375
48347
|
* Sub-classes **MUST** call this. Until [[_start]] has been called, no calls
|
|
@@ -47471,6 +48443,14 @@ class JsonRpcApiProvider extends AbstractProvider {
|
|
|
47471
48443
|
if (tx.accessList) {
|
|
47472
48444
|
result["accessList"] = accessListify(tx.accessList);
|
|
47473
48445
|
}
|
|
48446
|
+
if (tx.blobVersionedHashes) {
|
|
48447
|
+
// @TODO: Remove this <any> case once EIP-4844 added to prepared tx
|
|
48448
|
+
result["blobVersionedHashes"] = tx.blobVersionedHashes.map(h => h.toLowerCase());
|
|
48449
|
+
}
|
|
48450
|
+
// @TODO: blobs should probably also be copied over, optionally
|
|
48451
|
+
// accounting for the kzg property to backfill blobVersionedHashes
|
|
48452
|
+
// using the commitment. Or should that be left as an exercise to
|
|
48453
|
+
// the caller?
|
|
47474
48454
|
return result;
|
|
47475
48455
|
}
|
|
47476
48456
|
/**
|
|
@@ -47485,6 +48465,8 @@ class JsonRpcApiProvider extends AbstractProvider {
|
|
|
47485
48465
|
return { method: "eth_blockNumber", args: [] };
|
|
47486
48466
|
case "getGasPrice":
|
|
47487
48467
|
return { method: "eth_gasPrice", args: [] };
|
|
48468
|
+
case "getPriorityFee":
|
|
48469
|
+
return { method: "eth_maxPriorityFeePerGas", args: [] };
|
|
47488
48470
|
case "getBalance":
|
|
47489
48471
|
return {
|
|
47490
48472
|
method: "eth_getBalance",
|
|
@@ -47735,7 +48717,11 @@ class JsonRpcApiPollingProvider extends JsonRpcApiProvider {
|
|
|
47735
48717
|
#pollingInterval;
|
|
47736
48718
|
constructor(network, options) {
|
|
47737
48719
|
super(network, options);
|
|
47738
|
-
|
|
48720
|
+
let pollingInterval = this._getOption("pollingInterval");
|
|
48721
|
+
if (pollingInterval == null) {
|
|
48722
|
+
pollingInterval = defaultOptions.pollingInterval;
|
|
48723
|
+
}
|
|
48724
|
+
this.#pollingInterval = pollingInterval;
|
|
47739
48725
|
}
|
|
47740
48726
|
_getSubscriber(sub) {
|
|
47741
48727
|
const subscriber = super._getSubscriber(sub);
|
|
@@ -51327,7 +52313,7 @@ class EthStateStorage {
|
|
|
51327
52313
|
const chainId = getChainId(DID.blockchainFromId(idTyped), DID.networkIdFromId(idTyped));
|
|
51328
52314
|
const config = this.networkByChainId(chainId);
|
|
51329
52315
|
const provider = new JsonRpcProvider(config.url);
|
|
51330
|
-
const stateContract = new Contract(config.contractAddress, abi$2,
|
|
52316
|
+
const stateContract = new Contract(config.contractAddress, abi$2, provider);
|
|
51331
52317
|
return { stateContract, provider };
|
|
51332
52318
|
}
|
|
51333
52319
|
networkByChainId(chainId) {
|
|
@@ -55345,10 +56331,10 @@ class MessageHandler {
|
|
|
55345
56331
|
return null;
|
|
55346
56332
|
}
|
|
55347
56333
|
let packerParams = {};
|
|
55348
|
-
const
|
|
55349
|
-
if (unpackedMediaType === MediaType.ZKPMessage &&
|
|
56334
|
+
const senderDid = context?.senderDid;
|
|
56335
|
+
if (unpackedMediaType === MediaType.ZKPMessage && senderDid) {
|
|
55350
56336
|
packerParams = {
|
|
55351
|
-
senderDID,
|
|
56337
|
+
senderDID: senderDid,
|
|
55352
56338
|
provingMethodAlg: proving.provingMethodGroth16AuthV2Instance.methodAlg
|
|
55353
56339
|
};
|
|
55354
56340
|
return this._params.packageManager.packMessage(unpackedMediaType, response, packerParams);
|
|
@@ -55966,7 +56952,7 @@ class RevocationStatusHandler extends AbstractMessageHandler {
|
|
|
55966
56952
|
this._identityWallet = _identityWallet;
|
|
55967
56953
|
}
|
|
55968
56954
|
handle(message, context) {
|
|
55969
|
-
if (!context.
|
|
56955
|
+
if (!context.senderDid) {
|
|
55970
56956
|
throw new Error('DID is required');
|
|
55971
56957
|
}
|
|
55972
56958
|
if (!context.mediaType) {
|
|
@@ -56008,7 +56994,7 @@ class RevocationStatusHandler extends AbstractMessageHandler {
|
|
|
56008
56994
|
type: PROTOCOL_MESSAGE_TYPE.REVOCATION_STATUS_RESPONSE_MESSAGE_TYPE,
|
|
56009
56995
|
thid: rsRequest.thid ?? guid,
|
|
56010
56996
|
body: revStatus,
|
|
56011
|
-
from: context.
|
|
56997
|
+
from: context.senderDid.string(),
|
|
56012
56998
|
to: rsRequest.from
|
|
56013
56999
|
};
|
|
56014
57000
|
return response;
|
|
@@ -56038,7 +57024,7 @@ class RevocationStatusHandler extends AbstractMessageHandler {
|
|
|
56038
57024
|
}
|
|
56039
57025
|
const rsRequest = await this.parseRevocationStatusRequest(request);
|
|
56040
57026
|
const response = await this.handleRevocationStatusRequestMessage(rsRequest, {
|
|
56041
|
-
did,
|
|
57027
|
+
senderDid: did,
|
|
56042
57028
|
mediaType: opts.mediaType,
|
|
56043
57029
|
packerOptions: opts.packerOptions,
|
|
56044
57030
|
treeState: opts.treeState
|
|
@@ -56169,7 +57155,8 @@ class CredentialProposalHandler extends AbstractMessageHandler {
|
|
|
56169
57155
|
}
|
|
56170
57156
|
},
|
|
56171
57157
|
type: cred.type,
|
|
56172
|
-
context: cred.context
|
|
57158
|
+
context: cred.context,
|
|
57159
|
+
allowedIssuers: [proposalRequest.to]
|
|
56173
57160
|
});
|
|
56174
57161
|
}
|
|
56175
57162
|
catch (e) {
|
|
@@ -57849,7 +58836,7 @@ class IdentityWallet {
|
|
|
57849
58836
|
* {@inheritDoc IIdentityWallet.createIdentity}
|
|
57850
58837
|
*/
|
|
57851
58838
|
async createIdentity(opts) {
|
|
57852
|
-
const tmpIdentifier = opts.seed ? v5(Hex.encode(sha256$
|
|
58839
|
+
const tmpIdentifier = opts.seed ? v5(Hex.encode(sha256$4(opts.seed)), nil) : v4();
|
|
57853
58840
|
opts.seed = opts.seed ?? getRandomBytes(32);
|
|
57854
58841
|
await this._storage.mt.createIdentityMerkleTrees(tmpIdentifier);
|
|
57855
58842
|
const revNonce = opts.revocationOpts.nonce ?? 0;
|
|
@@ -57931,7 +58918,7 @@ class IdentityWallet {
|
|
|
57931
58918
|
opts.createBjjCredential = opts.createBjjCredential ?? true;
|
|
57932
58919
|
let credential;
|
|
57933
58920
|
const ethSigner = opts.ethSigner;
|
|
57934
|
-
if (!ethSigner) {
|
|
58921
|
+
if (opts.createBjjCredential && !ethSigner) {
|
|
57935
58922
|
throw new Error('Ethereum signer is required to create Ethereum identities in order to transit state');
|
|
57936
58923
|
}
|
|
57937
58924
|
const currentState = ZERO_HASH; // In Ethereum identities we don't have an initial state with the auth credential
|
|
@@ -57946,7 +58933,7 @@ class IdentityWallet {
|
|
|
57946
58933
|
isStatePublished: false,
|
|
57947
58934
|
isStateGenesis: true
|
|
57948
58935
|
});
|
|
57949
|
-
if (opts.createBjjCredential) {
|
|
58936
|
+
if (opts.createBjjCredential && ethSigner) {
|
|
57950
58937
|
// Old tree state genesis state
|
|
57951
58938
|
const oldTreeState = {
|
|
57952
58939
|
revocationRoot: ZERO_HASH,
|
|
@@ -58399,16 +59386,8 @@ class IdentityWallet {
|
|
|
58399
59386
|
await this.updateIdentityState(did, true, newTreeState);
|
|
58400
59387
|
return txId;
|
|
58401
59388
|
}
|
|
58402
|
-
|
|
58403
|
-
|
|
58404
|
-
) {
|
|
58405
|
-
opts.seed = opts.seed ?? getRandomBytes(32);
|
|
58406
|
-
opts.revocationOpts.nonce =
|
|
58407
|
-
opts.revocationOpts.nonce ??
|
|
58408
|
-
(isOldStateGenesis
|
|
58409
|
-
? 0
|
|
58410
|
-
: opts.revocationOpts.nonce ?? new DataView(getRandomBytes(12).buffer).getUint32(0));
|
|
58411
|
-
const { authClaim, pubKey } = await this.createAuthCoreClaim(opts.revocationOpts.nonce ?? 0, opts.seed);
|
|
59389
|
+
async getAuthBJJCredential(did, oldTreeState, { nonce, seed, id, type }) {
|
|
59390
|
+
const { authClaim, pubKey } = await this.createAuthCoreClaim(nonce, seed);
|
|
58412
59391
|
const { hi, hv } = authClaim.hiHv();
|
|
58413
59392
|
await this._storage.mt.addToMerkleTree(did.string(), MerkleTreeType.Claims, hi, hv);
|
|
58414
59393
|
// Calculate current state after adding credential to merkle tree
|
|
@@ -58418,28 +59397,68 @@ class IdentityWallet {
|
|
|
58418
59397
|
oldTreeState.revocationRoot.bigInt(),
|
|
58419
59398
|
oldTreeState.rootOfRoots.bigInt()
|
|
58420
59399
|
]);
|
|
58421
|
-
|
|
58422
|
-
|
|
58423
|
-
|
|
58424
|
-
const credsWithIden3MTPProof = await this.generateIden3SparseMerkleTreeProof(did, [credential], txId, receipt?.blockNumber, block?.timestamp, undefined, {
|
|
58425
|
-
revNonce: Number(authClaim.getRevocationNonce()),
|
|
58426
|
-
subjectPosition: SubjectPosition.None,
|
|
58427
|
-
merklizedRootPosition: MerklizedRootPosition.None,
|
|
58428
|
-
updatable: false,
|
|
58429
|
-
version: 0,
|
|
58430
|
-
merklizeOpts: { documentLoader: cacheLoader() }
|
|
59400
|
+
return this.createAuthBJJCredential(did, pubKey, authClaim, currentState, {
|
|
59401
|
+
id,
|
|
59402
|
+
type
|
|
58431
59403
|
});
|
|
58432
|
-
|
|
58433
|
-
|
|
58434
|
-
|
|
58435
|
-
|
|
58436
|
-
|
|
58437
|
-
|
|
58438
|
-
|
|
58439
|
-
|
|
58440
|
-
|
|
59404
|
+
}
|
|
59405
|
+
/** {@inheritdoc IIdentityWallet.addBJJAuthCredential} */
|
|
59406
|
+
async addBJJAuthCredential(did, oldTreeState, isOldStateGenesis, ethSigner, opts, prover // it will be needed in case of non ethereum identities
|
|
59407
|
+
) {
|
|
59408
|
+
opts.seed = opts.seed ?? getRandomBytes(32);
|
|
59409
|
+
opts.revocationOpts.nonce =
|
|
59410
|
+
opts.revocationOpts.nonce ??
|
|
59411
|
+
(isOldStateGenesis
|
|
59412
|
+
? 0
|
|
59413
|
+
: opts.revocationOpts.nonce ?? new DataView(getRandomBytes(12).buffer).getUint32(0));
|
|
59414
|
+
const credential = await this.getAuthBJJCredential(did, oldTreeState, {
|
|
59415
|
+
nonce: opts.revocationOpts.nonce,
|
|
59416
|
+
seed: opts.seed,
|
|
59417
|
+
id: opts.revocationOpts.id,
|
|
59418
|
+
type: opts.revocationOpts.type
|
|
58441
59419
|
});
|
|
58442
|
-
|
|
59420
|
+
const addMtpToCredAndPublishRevState = async () => {
|
|
59421
|
+
const { receipt, block } = await this._transactionService.getTransactionReceiptAndBlock(txId);
|
|
59422
|
+
const credsWithIden3MTPProof = await this.generateIden3SparseMerkleTreeProof(did, [credential], txId, receipt?.blockNumber, block?.timestamp, undefined, {
|
|
59423
|
+
revNonce: opts.revocationOpts.nonce ?? 0,
|
|
59424
|
+
subjectPosition: SubjectPosition.None,
|
|
59425
|
+
merklizedRootPosition: MerklizedRootPosition.None,
|
|
59426
|
+
updatable: false,
|
|
59427
|
+
version: 0,
|
|
59428
|
+
merklizeOpts: { documentLoader: cacheLoader() }
|
|
59429
|
+
});
|
|
59430
|
+
await this._credentialWallet.saveAll(credsWithIden3MTPProof);
|
|
59431
|
+
await this.publishRevocationInfoByCredentialStatusType(did, opts.revocationOpts.type, {
|
|
59432
|
+
rhsUrl: opts.revocationOpts.id,
|
|
59433
|
+
onChain: opts.revocationOpts.onChain
|
|
59434
|
+
});
|
|
59435
|
+
return credsWithIden3MTPProof[0];
|
|
59436
|
+
};
|
|
59437
|
+
let txId = '';
|
|
59438
|
+
let attempt = 2;
|
|
59439
|
+
do {
|
|
59440
|
+
try {
|
|
59441
|
+
txId = await this.transitState(did, oldTreeState, isOldStateGenesis, ethSigner, prover);
|
|
59442
|
+
break;
|
|
59443
|
+
}
|
|
59444
|
+
catch (err) {
|
|
59445
|
+
console.warn(`Error while transiting state, retrying state transition, attempt: ${attempt}`, err);
|
|
59446
|
+
}
|
|
59447
|
+
} while (--attempt);
|
|
59448
|
+
if (!txId) {
|
|
59449
|
+
const oldTransitStateInfoJson = JSON.stringify({
|
|
59450
|
+
claimsRoot: oldTreeState.claimsRoot.hex(),
|
|
59451
|
+
revocationRoot: oldTreeState.revocationRoot.hex(),
|
|
59452
|
+
rootOfRoots: oldTreeState.rootOfRoots.hex(),
|
|
59453
|
+
state: oldTreeState.state.hex(),
|
|
59454
|
+
isOldStateGenesis,
|
|
59455
|
+
credentialId: credential.id,
|
|
59456
|
+
did: did.string()
|
|
59457
|
+
}, null, 2);
|
|
59458
|
+
await this._credentialWallet.save(credential);
|
|
59459
|
+
throw new Error(`Error publishing state, info to publish: ${oldTransitStateInfoJson}`);
|
|
59460
|
+
}
|
|
59461
|
+
return addMtpToCredAndPublishRevState();
|
|
58443
59462
|
}
|
|
58444
59463
|
}
|
|
58445
59464
|
|