@solana/web3.js 1.43.0 → 1.43.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.browser.cjs.js +65 -597
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +63 -594
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +114 -67
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +14 -5
- package/lib/index.esm.js +111 -63
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +26021 -26079
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +6 -4
- package/lib/index.iife.min.js.map +1 -1
- package/package.json +8 -7
- package/src/__forks__/browser/fetch-impl.ts +4 -0
- package/src/compute-budget.ts +1 -1
- package/src/connection.ts +17 -14
- package/src/fetch-impl.ts +13 -0
- package/src/system-program.ts +1 -1
- package/src/transaction.ts +13 -11
- package/src/util/bigint.ts +43 -0
package/lib/index.browser.cjs.js
CHANGED
|
@@ -8,7 +8,7 @@ var BN = require('bn.js');
|
|
|
8
8
|
var bs58 = require('bs58');
|
|
9
9
|
var borsh = require('borsh');
|
|
10
10
|
var BufferLayout = require('@solana/buffer-layout');
|
|
11
|
-
var
|
|
11
|
+
var bigintBuffer = require('bigint-buffer');
|
|
12
12
|
var superstruct = require('superstruct');
|
|
13
13
|
var rpcWebsockets = require('rpc-websockets');
|
|
14
14
|
var RpcClient = require('jayson/lib/client/browser');
|
|
@@ -53,12 +53,6 @@ const toBuffer = arr => {
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
57
|
-
|
|
58
|
-
function getDefaultExportFromCjs (x) {
|
|
59
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
56
|
var hash$1 = {};
|
|
63
57
|
|
|
64
58
|
var utils$9 = {};
|
|
@@ -1295,22 +1289,22 @@ Hmac.prototype.digest = function digest(enc) {
|
|
|
1295
1289
|
};
|
|
1296
1290
|
|
|
1297
1291
|
(function (exports) {
|
|
1298
|
-
var hash = exports;
|
|
1299
|
-
|
|
1300
|
-
hash.utils = utils$9;
|
|
1301
|
-
hash.common = common$5;
|
|
1302
|
-
hash.sha = sha;
|
|
1303
|
-
hash.ripemd = ripemd;
|
|
1304
|
-
hash.hmac = hmac;
|
|
1305
|
-
|
|
1306
|
-
// Proxy hash functions to the main object
|
|
1307
|
-
hash.sha1 = hash.sha.sha1;
|
|
1308
|
-
hash.sha256 = hash.sha.sha256;
|
|
1309
|
-
hash.sha224 = hash.sha.sha224;
|
|
1310
|
-
hash.sha384 = hash.sha.sha384;
|
|
1311
|
-
hash.sha512 = hash.sha.sha512;
|
|
1312
|
-
hash.ripemd160 = hash.ripemd.ripemd160;
|
|
1313
|
-
}(hash$1));
|
|
1292
|
+
var hash = exports;
|
|
1293
|
+
|
|
1294
|
+
hash.utils = utils$9;
|
|
1295
|
+
hash.common = common$5;
|
|
1296
|
+
hash.sha = sha;
|
|
1297
|
+
hash.ripemd = ripemd;
|
|
1298
|
+
hash.hmac = hmac;
|
|
1299
|
+
|
|
1300
|
+
// Proxy hash functions to the main object
|
|
1301
|
+
hash.sha1 = hash.sha.sha1;
|
|
1302
|
+
hash.sha256 = hash.sha.sha256;
|
|
1303
|
+
hash.sha224 = hash.sha.sha224;
|
|
1304
|
+
hash.sha384 = hash.sha.sha384;
|
|
1305
|
+
hash.sha512 = hash.sha.sha512;
|
|
1306
|
+
hash.ripemd160 = hash.ripemd.ripemd160;
|
|
1307
|
+
} (hash$1));
|
|
1314
1308
|
|
|
1315
1309
|
var hash = hash$1;
|
|
1316
1310
|
|
|
@@ -2605,13 +2599,6 @@ class Transaction {
|
|
|
2605
2599
|
isSigner: false,
|
|
2606
2600
|
isWritable: false
|
|
2607
2601
|
});
|
|
2608
|
-
}); // Sort. Prioritizing first by signer, then by writable
|
|
2609
|
-
|
|
2610
|
-
accountMetas.sort(function (x, y) {
|
|
2611
|
-
const pubkeySorting = x.pubkey.toBase58().localeCompare(y.pubkey.toBase58());
|
|
2612
|
-
const checkSigner = x.isSigner === y.isSigner ? 0 : x.isSigner ? -1 : 1;
|
|
2613
|
-
const checkWritable = x.isWritable === y.isWritable ? pubkeySorting : x.isWritable ? -1 : 1;
|
|
2614
|
-
return checkSigner || checkWritable;
|
|
2615
2602
|
}); // Cull duplicate account metas
|
|
2616
2603
|
|
|
2617
2604
|
const uniqueMetas = [];
|
|
@@ -2623,9 +2610,17 @@ class Transaction {
|
|
|
2623
2610
|
|
|
2624
2611
|
if (uniqueIndex > -1) {
|
|
2625
2612
|
uniqueMetas[uniqueIndex].isWritable = uniqueMetas[uniqueIndex].isWritable || accountMeta.isWritable;
|
|
2613
|
+
uniqueMetas[uniqueIndex].isSigner = uniqueMetas[uniqueIndex].isSigner || accountMeta.isSigner;
|
|
2626
2614
|
} else {
|
|
2627
2615
|
uniqueMetas.push(accountMeta);
|
|
2628
2616
|
}
|
|
2617
|
+
}); // Sort. Prioritizing first by signer, then by writable
|
|
2618
|
+
|
|
2619
|
+
uniqueMetas.sort(function (x, y) {
|
|
2620
|
+
const pubkeySorting = x.pubkey.toBase58().localeCompare(y.pubkey.toBase58());
|
|
2621
|
+
const checkSigner = x.isSigner === y.isSigner ? 0 : x.isSigner ? -1 : 1;
|
|
2622
|
+
const checkWritable = x.isWritable === y.isWritable ? pubkeySorting : x.isWritable ? -1 : 1;
|
|
2623
|
+
return checkSigner || checkWritable;
|
|
2629
2624
|
}); // Move fee payer to the front
|
|
2630
2625
|
|
|
2631
2626
|
const feePayerIndex = uniqueMetas.findIndex(x => {
|
|
@@ -3207,6 +3202,38 @@ class NonceAccount {
|
|
|
3207
3202
|
|
|
3208
3203
|
}
|
|
3209
3204
|
|
|
3205
|
+
const encodeDecode = layout => {
|
|
3206
|
+
const decode = layout.decode.bind(layout);
|
|
3207
|
+
const encode = layout.encode.bind(layout);
|
|
3208
|
+
return {
|
|
3209
|
+
decode,
|
|
3210
|
+
encode
|
|
3211
|
+
};
|
|
3212
|
+
};
|
|
3213
|
+
|
|
3214
|
+
const bigInt = length => property => {
|
|
3215
|
+
const layout = BufferLayout.blob(length, property);
|
|
3216
|
+
const {
|
|
3217
|
+
encode,
|
|
3218
|
+
decode
|
|
3219
|
+
} = encodeDecode(layout);
|
|
3220
|
+
const bigIntLayout = layout;
|
|
3221
|
+
|
|
3222
|
+
bigIntLayout.decode = (buffer$1, offset) => {
|
|
3223
|
+
const src = decode(buffer$1, offset);
|
|
3224
|
+
return bigintBuffer.toBigIntLE(buffer.Buffer.from(src));
|
|
3225
|
+
};
|
|
3226
|
+
|
|
3227
|
+
bigIntLayout.encode = (bigInt, buffer, offset) => {
|
|
3228
|
+
const src = bigintBuffer.toBufferLE(bigInt, length);
|
|
3229
|
+
return encode(src, buffer, offset);
|
|
3230
|
+
};
|
|
3231
|
+
|
|
3232
|
+
return bigIntLayout;
|
|
3233
|
+
};
|
|
3234
|
+
|
|
3235
|
+
const u64 = bigInt(8);
|
|
3236
|
+
|
|
3210
3237
|
/**
|
|
3211
3238
|
* Create account system transaction params
|
|
3212
3239
|
*/
|
|
@@ -3508,7 +3535,7 @@ const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
3508
3535
|
},
|
|
3509
3536
|
Transfer: {
|
|
3510
3537
|
index: 2,
|
|
3511
|
-
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'),
|
|
3538
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), u64('lamports')])
|
|
3512
3539
|
},
|
|
3513
3540
|
CreateWithSeed: {
|
|
3514
3541
|
index: 3,
|
|
@@ -3544,7 +3571,7 @@ const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
3544
3571
|
},
|
|
3545
3572
|
TransferWithSeed: {
|
|
3546
3573
|
index: 11,
|
|
3547
|
-
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'),
|
|
3574
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), u64('lamports'), rustString('seed'), publicKey('programId')])
|
|
3548
3575
|
}
|
|
3549
3576
|
});
|
|
3550
3577
|
/**
|
|
@@ -4248,7 +4275,7 @@ const COMPUTE_BUDGET_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
4248
4275
|
},
|
|
4249
4276
|
SetComputeUnitPrice: {
|
|
4250
4277
|
index: 3,
|
|
4251
|
-
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u8('instruction'),
|
|
4278
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u8('instruction'), u64('microLamports')])
|
|
4252
4279
|
}
|
|
4253
4280
|
});
|
|
4254
4281
|
/**
|
|
@@ -4310,567 +4337,6 @@ class ComputeBudgetProgram {
|
|
|
4310
4337
|
}
|
|
4311
4338
|
ComputeBudgetProgram.programId = new PublicKey('ComputeBudget111111111111111111111111111111');
|
|
4312
4339
|
|
|
4313
|
-
var browserPonyfill = {exports: {}};
|
|
4314
|
-
|
|
4315
|
-
(function (module, exports) {
|
|
4316
|
-
var global = typeof self !== 'undefined' ? self : commonjsGlobal;
|
|
4317
|
-
var __self__ = (function () {
|
|
4318
|
-
function F() {
|
|
4319
|
-
this.fetch = false;
|
|
4320
|
-
this.DOMException = global.DOMException;
|
|
4321
|
-
}
|
|
4322
|
-
F.prototype = global;
|
|
4323
|
-
return new F();
|
|
4324
|
-
})();
|
|
4325
|
-
(function(self) {
|
|
4326
|
-
|
|
4327
|
-
((function (exports) {
|
|
4328
|
-
|
|
4329
|
-
var support = {
|
|
4330
|
-
searchParams: 'URLSearchParams' in self,
|
|
4331
|
-
iterable: 'Symbol' in self && 'iterator' in Symbol,
|
|
4332
|
-
blob:
|
|
4333
|
-
'FileReader' in self &&
|
|
4334
|
-
'Blob' in self &&
|
|
4335
|
-
(function() {
|
|
4336
|
-
try {
|
|
4337
|
-
new Blob();
|
|
4338
|
-
return true
|
|
4339
|
-
} catch (e) {
|
|
4340
|
-
return false
|
|
4341
|
-
}
|
|
4342
|
-
})(),
|
|
4343
|
-
formData: 'FormData' in self,
|
|
4344
|
-
arrayBuffer: 'ArrayBuffer' in self
|
|
4345
|
-
};
|
|
4346
|
-
|
|
4347
|
-
function isDataView(obj) {
|
|
4348
|
-
return obj && DataView.prototype.isPrototypeOf(obj)
|
|
4349
|
-
}
|
|
4350
|
-
|
|
4351
|
-
if (support.arrayBuffer) {
|
|
4352
|
-
var viewClasses = [
|
|
4353
|
-
'[object Int8Array]',
|
|
4354
|
-
'[object Uint8Array]',
|
|
4355
|
-
'[object Uint8ClampedArray]',
|
|
4356
|
-
'[object Int16Array]',
|
|
4357
|
-
'[object Uint16Array]',
|
|
4358
|
-
'[object Int32Array]',
|
|
4359
|
-
'[object Uint32Array]',
|
|
4360
|
-
'[object Float32Array]',
|
|
4361
|
-
'[object Float64Array]'
|
|
4362
|
-
];
|
|
4363
|
-
|
|
4364
|
-
var isArrayBufferView =
|
|
4365
|
-
ArrayBuffer.isView ||
|
|
4366
|
-
function(obj) {
|
|
4367
|
-
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
|
|
4368
|
-
};
|
|
4369
|
-
}
|
|
4370
|
-
|
|
4371
|
-
function normalizeName(name) {
|
|
4372
|
-
if (typeof name !== 'string') {
|
|
4373
|
-
name = String(name);
|
|
4374
|
-
}
|
|
4375
|
-
if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) {
|
|
4376
|
-
throw new TypeError('Invalid character in header field name')
|
|
4377
|
-
}
|
|
4378
|
-
return name.toLowerCase()
|
|
4379
|
-
}
|
|
4380
|
-
|
|
4381
|
-
function normalizeValue(value) {
|
|
4382
|
-
if (typeof value !== 'string') {
|
|
4383
|
-
value = String(value);
|
|
4384
|
-
}
|
|
4385
|
-
return value
|
|
4386
|
-
}
|
|
4387
|
-
|
|
4388
|
-
// Build a destructive iterator for the value list
|
|
4389
|
-
function iteratorFor(items) {
|
|
4390
|
-
var iterator = {
|
|
4391
|
-
next: function() {
|
|
4392
|
-
var value = items.shift();
|
|
4393
|
-
return {done: value === undefined, value: value}
|
|
4394
|
-
}
|
|
4395
|
-
};
|
|
4396
|
-
|
|
4397
|
-
if (support.iterable) {
|
|
4398
|
-
iterator[Symbol.iterator] = function() {
|
|
4399
|
-
return iterator
|
|
4400
|
-
};
|
|
4401
|
-
}
|
|
4402
|
-
|
|
4403
|
-
return iterator
|
|
4404
|
-
}
|
|
4405
|
-
|
|
4406
|
-
function Headers(headers) {
|
|
4407
|
-
this.map = {};
|
|
4408
|
-
|
|
4409
|
-
if (headers instanceof Headers) {
|
|
4410
|
-
headers.forEach(function(value, name) {
|
|
4411
|
-
this.append(name, value);
|
|
4412
|
-
}, this);
|
|
4413
|
-
} else if (Array.isArray(headers)) {
|
|
4414
|
-
headers.forEach(function(header) {
|
|
4415
|
-
this.append(header[0], header[1]);
|
|
4416
|
-
}, this);
|
|
4417
|
-
} else if (headers) {
|
|
4418
|
-
Object.getOwnPropertyNames(headers).forEach(function(name) {
|
|
4419
|
-
this.append(name, headers[name]);
|
|
4420
|
-
}, this);
|
|
4421
|
-
}
|
|
4422
|
-
}
|
|
4423
|
-
|
|
4424
|
-
Headers.prototype.append = function(name, value) {
|
|
4425
|
-
name = normalizeName(name);
|
|
4426
|
-
value = normalizeValue(value);
|
|
4427
|
-
var oldValue = this.map[name];
|
|
4428
|
-
this.map[name] = oldValue ? oldValue + ', ' + value : value;
|
|
4429
|
-
};
|
|
4430
|
-
|
|
4431
|
-
Headers.prototype['delete'] = function(name) {
|
|
4432
|
-
delete this.map[normalizeName(name)];
|
|
4433
|
-
};
|
|
4434
|
-
|
|
4435
|
-
Headers.prototype.get = function(name) {
|
|
4436
|
-
name = normalizeName(name);
|
|
4437
|
-
return this.has(name) ? this.map[name] : null
|
|
4438
|
-
};
|
|
4439
|
-
|
|
4440
|
-
Headers.prototype.has = function(name) {
|
|
4441
|
-
return this.map.hasOwnProperty(normalizeName(name))
|
|
4442
|
-
};
|
|
4443
|
-
|
|
4444
|
-
Headers.prototype.set = function(name, value) {
|
|
4445
|
-
this.map[normalizeName(name)] = normalizeValue(value);
|
|
4446
|
-
};
|
|
4447
|
-
|
|
4448
|
-
Headers.prototype.forEach = function(callback, thisArg) {
|
|
4449
|
-
for (var name in this.map) {
|
|
4450
|
-
if (this.map.hasOwnProperty(name)) {
|
|
4451
|
-
callback.call(thisArg, this.map[name], name, this);
|
|
4452
|
-
}
|
|
4453
|
-
}
|
|
4454
|
-
};
|
|
4455
|
-
|
|
4456
|
-
Headers.prototype.keys = function() {
|
|
4457
|
-
var items = [];
|
|
4458
|
-
this.forEach(function(value, name) {
|
|
4459
|
-
items.push(name);
|
|
4460
|
-
});
|
|
4461
|
-
return iteratorFor(items)
|
|
4462
|
-
};
|
|
4463
|
-
|
|
4464
|
-
Headers.prototype.values = function() {
|
|
4465
|
-
var items = [];
|
|
4466
|
-
this.forEach(function(value) {
|
|
4467
|
-
items.push(value);
|
|
4468
|
-
});
|
|
4469
|
-
return iteratorFor(items)
|
|
4470
|
-
};
|
|
4471
|
-
|
|
4472
|
-
Headers.prototype.entries = function() {
|
|
4473
|
-
var items = [];
|
|
4474
|
-
this.forEach(function(value, name) {
|
|
4475
|
-
items.push([name, value]);
|
|
4476
|
-
});
|
|
4477
|
-
return iteratorFor(items)
|
|
4478
|
-
};
|
|
4479
|
-
|
|
4480
|
-
if (support.iterable) {
|
|
4481
|
-
Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
|
|
4482
|
-
}
|
|
4483
|
-
|
|
4484
|
-
function consumed(body) {
|
|
4485
|
-
if (body.bodyUsed) {
|
|
4486
|
-
return Promise.reject(new TypeError('Already read'))
|
|
4487
|
-
}
|
|
4488
|
-
body.bodyUsed = true;
|
|
4489
|
-
}
|
|
4490
|
-
|
|
4491
|
-
function fileReaderReady(reader) {
|
|
4492
|
-
return new Promise(function(resolve, reject) {
|
|
4493
|
-
reader.onload = function() {
|
|
4494
|
-
resolve(reader.result);
|
|
4495
|
-
};
|
|
4496
|
-
reader.onerror = function() {
|
|
4497
|
-
reject(reader.error);
|
|
4498
|
-
};
|
|
4499
|
-
})
|
|
4500
|
-
}
|
|
4501
|
-
|
|
4502
|
-
function readBlobAsArrayBuffer(blob) {
|
|
4503
|
-
var reader = new FileReader();
|
|
4504
|
-
var promise = fileReaderReady(reader);
|
|
4505
|
-
reader.readAsArrayBuffer(blob);
|
|
4506
|
-
return promise
|
|
4507
|
-
}
|
|
4508
|
-
|
|
4509
|
-
function readBlobAsText(blob) {
|
|
4510
|
-
var reader = new FileReader();
|
|
4511
|
-
var promise = fileReaderReady(reader);
|
|
4512
|
-
reader.readAsText(blob);
|
|
4513
|
-
return promise
|
|
4514
|
-
}
|
|
4515
|
-
|
|
4516
|
-
function readArrayBufferAsText(buf) {
|
|
4517
|
-
var view = new Uint8Array(buf);
|
|
4518
|
-
var chars = new Array(view.length);
|
|
4519
|
-
|
|
4520
|
-
for (var i = 0; i < view.length; i++) {
|
|
4521
|
-
chars[i] = String.fromCharCode(view[i]);
|
|
4522
|
-
}
|
|
4523
|
-
return chars.join('')
|
|
4524
|
-
}
|
|
4525
|
-
|
|
4526
|
-
function bufferClone(buf) {
|
|
4527
|
-
if (buf.slice) {
|
|
4528
|
-
return buf.slice(0)
|
|
4529
|
-
} else {
|
|
4530
|
-
var view = new Uint8Array(buf.byteLength);
|
|
4531
|
-
view.set(new Uint8Array(buf));
|
|
4532
|
-
return view.buffer
|
|
4533
|
-
}
|
|
4534
|
-
}
|
|
4535
|
-
|
|
4536
|
-
function Body() {
|
|
4537
|
-
this.bodyUsed = false;
|
|
4538
|
-
|
|
4539
|
-
this._initBody = function(body) {
|
|
4540
|
-
this._bodyInit = body;
|
|
4541
|
-
if (!body) {
|
|
4542
|
-
this._bodyText = '';
|
|
4543
|
-
} else if (typeof body === 'string') {
|
|
4544
|
-
this._bodyText = body;
|
|
4545
|
-
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
|
|
4546
|
-
this._bodyBlob = body;
|
|
4547
|
-
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
|
|
4548
|
-
this._bodyFormData = body;
|
|
4549
|
-
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
|
4550
|
-
this._bodyText = body.toString();
|
|
4551
|
-
} else if (support.arrayBuffer && support.blob && isDataView(body)) {
|
|
4552
|
-
this._bodyArrayBuffer = bufferClone(body.buffer);
|
|
4553
|
-
// IE 10-11 can't handle a DataView body.
|
|
4554
|
-
this._bodyInit = new Blob([this._bodyArrayBuffer]);
|
|
4555
|
-
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
|
|
4556
|
-
this._bodyArrayBuffer = bufferClone(body);
|
|
4557
|
-
} else {
|
|
4558
|
-
this._bodyText = body = Object.prototype.toString.call(body);
|
|
4559
|
-
}
|
|
4560
|
-
|
|
4561
|
-
if (!this.headers.get('content-type')) {
|
|
4562
|
-
if (typeof body === 'string') {
|
|
4563
|
-
this.headers.set('content-type', 'text/plain;charset=UTF-8');
|
|
4564
|
-
} else if (this._bodyBlob && this._bodyBlob.type) {
|
|
4565
|
-
this.headers.set('content-type', this._bodyBlob.type);
|
|
4566
|
-
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
|
4567
|
-
this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
|
|
4568
|
-
}
|
|
4569
|
-
}
|
|
4570
|
-
};
|
|
4571
|
-
|
|
4572
|
-
if (support.blob) {
|
|
4573
|
-
this.blob = function() {
|
|
4574
|
-
var rejected = consumed(this);
|
|
4575
|
-
if (rejected) {
|
|
4576
|
-
return rejected
|
|
4577
|
-
}
|
|
4578
|
-
|
|
4579
|
-
if (this._bodyBlob) {
|
|
4580
|
-
return Promise.resolve(this._bodyBlob)
|
|
4581
|
-
} else if (this._bodyArrayBuffer) {
|
|
4582
|
-
return Promise.resolve(new Blob([this._bodyArrayBuffer]))
|
|
4583
|
-
} else if (this._bodyFormData) {
|
|
4584
|
-
throw new Error('could not read FormData body as blob')
|
|
4585
|
-
} else {
|
|
4586
|
-
return Promise.resolve(new Blob([this._bodyText]))
|
|
4587
|
-
}
|
|
4588
|
-
};
|
|
4589
|
-
|
|
4590
|
-
this.arrayBuffer = function() {
|
|
4591
|
-
if (this._bodyArrayBuffer) {
|
|
4592
|
-
return consumed(this) || Promise.resolve(this._bodyArrayBuffer)
|
|
4593
|
-
} else {
|
|
4594
|
-
return this.blob().then(readBlobAsArrayBuffer)
|
|
4595
|
-
}
|
|
4596
|
-
};
|
|
4597
|
-
}
|
|
4598
|
-
|
|
4599
|
-
this.text = function() {
|
|
4600
|
-
var rejected = consumed(this);
|
|
4601
|
-
if (rejected) {
|
|
4602
|
-
return rejected
|
|
4603
|
-
}
|
|
4604
|
-
|
|
4605
|
-
if (this._bodyBlob) {
|
|
4606
|
-
return readBlobAsText(this._bodyBlob)
|
|
4607
|
-
} else if (this._bodyArrayBuffer) {
|
|
4608
|
-
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
|
|
4609
|
-
} else if (this._bodyFormData) {
|
|
4610
|
-
throw new Error('could not read FormData body as text')
|
|
4611
|
-
} else {
|
|
4612
|
-
return Promise.resolve(this._bodyText)
|
|
4613
|
-
}
|
|
4614
|
-
};
|
|
4615
|
-
|
|
4616
|
-
if (support.formData) {
|
|
4617
|
-
this.formData = function() {
|
|
4618
|
-
return this.text().then(decode)
|
|
4619
|
-
};
|
|
4620
|
-
}
|
|
4621
|
-
|
|
4622
|
-
this.json = function() {
|
|
4623
|
-
return this.text().then(JSON.parse)
|
|
4624
|
-
};
|
|
4625
|
-
|
|
4626
|
-
return this
|
|
4627
|
-
}
|
|
4628
|
-
|
|
4629
|
-
// HTTP methods whose capitalization should be normalized
|
|
4630
|
-
var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];
|
|
4631
|
-
|
|
4632
|
-
function normalizeMethod(method) {
|
|
4633
|
-
var upcased = method.toUpperCase();
|
|
4634
|
-
return methods.indexOf(upcased) > -1 ? upcased : method
|
|
4635
|
-
}
|
|
4636
|
-
|
|
4637
|
-
function Request(input, options) {
|
|
4638
|
-
options = options || {};
|
|
4639
|
-
var body = options.body;
|
|
4640
|
-
|
|
4641
|
-
if (input instanceof Request) {
|
|
4642
|
-
if (input.bodyUsed) {
|
|
4643
|
-
throw new TypeError('Already read')
|
|
4644
|
-
}
|
|
4645
|
-
this.url = input.url;
|
|
4646
|
-
this.credentials = input.credentials;
|
|
4647
|
-
if (!options.headers) {
|
|
4648
|
-
this.headers = new Headers(input.headers);
|
|
4649
|
-
}
|
|
4650
|
-
this.method = input.method;
|
|
4651
|
-
this.mode = input.mode;
|
|
4652
|
-
this.signal = input.signal;
|
|
4653
|
-
if (!body && input._bodyInit != null) {
|
|
4654
|
-
body = input._bodyInit;
|
|
4655
|
-
input.bodyUsed = true;
|
|
4656
|
-
}
|
|
4657
|
-
} else {
|
|
4658
|
-
this.url = String(input);
|
|
4659
|
-
}
|
|
4660
|
-
|
|
4661
|
-
this.credentials = options.credentials || this.credentials || 'same-origin';
|
|
4662
|
-
if (options.headers || !this.headers) {
|
|
4663
|
-
this.headers = new Headers(options.headers);
|
|
4664
|
-
}
|
|
4665
|
-
this.method = normalizeMethod(options.method || this.method || 'GET');
|
|
4666
|
-
this.mode = options.mode || this.mode || null;
|
|
4667
|
-
this.signal = options.signal || this.signal;
|
|
4668
|
-
this.referrer = null;
|
|
4669
|
-
|
|
4670
|
-
if ((this.method === 'GET' || this.method === 'HEAD') && body) {
|
|
4671
|
-
throw new TypeError('Body not allowed for GET or HEAD requests')
|
|
4672
|
-
}
|
|
4673
|
-
this._initBody(body);
|
|
4674
|
-
}
|
|
4675
|
-
|
|
4676
|
-
Request.prototype.clone = function() {
|
|
4677
|
-
return new Request(this, {body: this._bodyInit})
|
|
4678
|
-
};
|
|
4679
|
-
|
|
4680
|
-
function decode(body) {
|
|
4681
|
-
var form = new FormData();
|
|
4682
|
-
body
|
|
4683
|
-
.trim()
|
|
4684
|
-
.split('&')
|
|
4685
|
-
.forEach(function(bytes) {
|
|
4686
|
-
if (bytes) {
|
|
4687
|
-
var split = bytes.split('=');
|
|
4688
|
-
var name = split.shift().replace(/\+/g, ' ');
|
|
4689
|
-
var value = split.join('=').replace(/\+/g, ' ');
|
|
4690
|
-
form.append(decodeURIComponent(name), decodeURIComponent(value));
|
|
4691
|
-
}
|
|
4692
|
-
});
|
|
4693
|
-
return form
|
|
4694
|
-
}
|
|
4695
|
-
|
|
4696
|
-
function parseHeaders(rawHeaders) {
|
|
4697
|
-
var headers = new Headers();
|
|
4698
|
-
// Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
|
|
4699
|
-
// https://tools.ietf.org/html/rfc7230#section-3.2
|
|
4700
|
-
var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
|
|
4701
|
-
preProcessedHeaders.split(/\r?\n/).forEach(function(line) {
|
|
4702
|
-
var parts = line.split(':');
|
|
4703
|
-
var key = parts.shift().trim();
|
|
4704
|
-
if (key) {
|
|
4705
|
-
var value = parts.join(':').trim();
|
|
4706
|
-
headers.append(key, value);
|
|
4707
|
-
}
|
|
4708
|
-
});
|
|
4709
|
-
return headers
|
|
4710
|
-
}
|
|
4711
|
-
|
|
4712
|
-
Body.call(Request.prototype);
|
|
4713
|
-
|
|
4714
|
-
function Response(bodyInit, options) {
|
|
4715
|
-
if (!options) {
|
|
4716
|
-
options = {};
|
|
4717
|
-
}
|
|
4718
|
-
|
|
4719
|
-
this.type = 'default';
|
|
4720
|
-
this.status = options.status === undefined ? 200 : options.status;
|
|
4721
|
-
this.ok = this.status >= 200 && this.status < 300;
|
|
4722
|
-
this.statusText = 'statusText' in options ? options.statusText : 'OK';
|
|
4723
|
-
this.headers = new Headers(options.headers);
|
|
4724
|
-
this.url = options.url || '';
|
|
4725
|
-
this._initBody(bodyInit);
|
|
4726
|
-
}
|
|
4727
|
-
|
|
4728
|
-
Body.call(Response.prototype);
|
|
4729
|
-
|
|
4730
|
-
Response.prototype.clone = function() {
|
|
4731
|
-
return new Response(this._bodyInit, {
|
|
4732
|
-
status: this.status,
|
|
4733
|
-
statusText: this.statusText,
|
|
4734
|
-
headers: new Headers(this.headers),
|
|
4735
|
-
url: this.url
|
|
4736
|
-
})
|
|
4737
|
-
};
|
|
4738
|
-
|
|
4739
|
-
Response.error = function() {
|
|
4740
|
-
var response = new Response(null, {status: 0, statusText: ''});
|
|
4741
|
-
response.type = 'error';
|
|
4742
|
-
return response
|
|
4743
|
-
};
|
|
4744
|
-
|
|
4745
|
-
var redirectStatuses = [301, 302, 303, 307, 308];
|
|
4746
|
-
|
|
4747
|
-
Response.redirect = function(url, status) {
|
|
4748
|
-
if (redirectStatuses.indexOf(status) === -1) {
|
|
4749
|
-
throw new RangeError('Invalid status code')
|
|
4750
|
-
}
|
|
4751
|
-
|
|
4752
|
-
return new Response(null, {status: status, headers: {location: url}})
|
|
4753
|
-
};
|
|
4754
|
-
|
|
4755
|
-
exports.DOMException = self.DOMException;
|
|
4756
|
-
try {
|
|
4757
|
-
new exports.DOMException();
|
|
4758
|
-
} catch (err) {
|
|
4759
|
-
exports.DOMException = function(message, name) {
|
|
4760
|
-
this.message = message;
|
|
4761
|
-
this.name = name;
|
|
4762
|
-
var error = Error(message);
|
|
4763
|
-
this.stack = error.stack;
|
|
4764
|
-
};
|
|
4765
|
-
exports.DOMException.prototype = Object.create(Error.prototype);
|
|
4766
|
-
exports.DOMException.prototype.constructor = exports.DOMException;
|
|
4767
|
-
}
|
|
4768
|
-
|
|
4769
|
-
function fetch(input, init) {
|
|
4770
|
-
return new Promise(function(resolve, reject) {
|
|
4771
|
-
var request = new Request(input, init);
|
|
4772
|
-
|
|
4773
|
-
if (request.signal && request.signal.aborted) {
|
|
4774
|
-
return reject(new exports.DOMException('Aborted', 'AbortError'))
|
|
4775
|
-
}
|
|
4776
|
-
|
|
4777
|
-
var xhr = new XMLHttpRequest();
|
|
4778
|
-
|
|
4779
|
-
function abortXhr() {
|
|
4780
|
-
xhr.abort();
|
|
4781
|
-
}
|
|
4782
|
-
|
|
4783
|
-
xhr.onload = function() {
|
|
4784
|
-
var options = {
|
|
4785
|
-
status: xhr.status,
|
|
4786
|
-
statusText: xhr.statusText,
|
|
4787
|
-
headers: parseHeaders(xhr.getAllResponseHeaders() || '')
|
|
4788
|
-
};
|
|
4789
|
-
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
|
|
4790
|
-
var body = 'response' in xhr ? xhr.response : xhr.responseText;
|
|
4791
|
-
resolve(new Response(body, options));
|
|
4792
|
-
};
|
|
4793
|
-
|
|
4794
|
-
xhr.onerror = function() {
|
|
4795
|
-
reject(new TypeError('Network request failed'));
|
|
4796
|
-
};
|
|
4797
|
-
|
|
4798
|
-
xhr.ontimeout = function() {
|
|
4799
|
-
reject(new TypeError('Network request failed'));
|
|
4800
|
-
};
|
|
4801
|
-
|
|
4802
|
-
xhr.onabort = function() {
|
|
4803
|
-
reject(new exports.DOMException('Aborted', 'AbortError'));
|
|
4804
|
-
};
|
|
4805
|
-
|
|
4806
|
-
xhr.open(request.method, request.url, true);
|
|
4807
|
-
|
|
4808
|
-
if (request.credentials === 'include') {
|
|
4809
|
-
xhr.withCredentials = true;
|
|
4810
|
-
} else if (request.credentials === 'omit') {
|
|
4811
|
-
xhr.withCredentials = false;
|
|
4812
|
-
}
|
|
4813
|
-
|
|
4814
|
-
if ('responseType' in xhr && support.blob) {
|
|
4815
|
-
xhr.responseType = 'blob';
|
|
4816
|
-
}
|
|
4817
|
-
|
|
4818
|
-
request.headers.forEach(function(value, name) {
|
|
4819
|
-
xhr.setRequestHeader(name, value);
|
|
4820
|
-
});
|
|
4821
|
-
|
|
4822
|
-
if (request.signal) {
|
|
4823
|
-
request.signal.addEventListener('abort', abortXhr);
|
|
4824
|
-
|
|
4825
|
-
xhr.onreadystatechange = function() {
|
|
4826
|
-
// DONE (success or failure)
|
|
4827
|
-
if (xhr.readyState === 4) {
|
|
4828
|
-
request.signal.removeEventListener('abort', abortXhr);
|
|
4829
|
-
}
|
|
4830
|
-
};
|
|
4831
|
-
}
|
|
4832
|
-
|
|
4833
|
-
xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
|
|
4834
|
-
})
|
|
4835
|
-
}
|
|
4836
|
-
|
|
4837
|
-
fetch.polyfill = true;
|
|
4838
|
-
|
|
4839
|
-
if (!self.fetch) {
|
|
4840
|
-
self.fetch = fetch;
|
|
4841
|
-
self.Headers = Headers;
|
|
4842
|
-
self.Request = Request;
|
|
4843
|
-
self.Response = Response;
|
|
4844
|
-
}
|
|
4845
|
-
|
|
4846
|
-
exports.Headers = Headers;
|
|
4847
|
-
exports.Request = Request;
|
|
4848
|
-
exports.Response = Response;
|
|
4849
|
-
exports.fetch = fetch;
|
|
4850
|
-
|
|
4851
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4852
|
-
|
|
4853
|
-
return exports;
|
|
4854
|
-
|
|
4855
|
-
}))({});
|
|
4856
|
-
})(__self__);
|
|
4857
|
-
__self__.fetch.ponyfill = true;
|
|
4858
|
-
// Remove "polyfill" property added by whatwg-fetch
|
|
4859
|
-
delete __self__.fetch.polyfill;
|
|
4860
|
-
// Choose between native implementation (global) or custom implementation (__self__)
|
|
4861
|
-
// var ctx = global.fetch ? global : __self__;
|
|
4862
|
-
var ctx = __self__; // this line disable service worker support temporarily
|
|
4863
|
-
exports = ctx.fetch; // To enable: import fetch from 'cross-fetch'
|
|
4864
|
-
exports.default = ctx.fetch; // For TypeScript consumers without esModuleInterop.
|
|
4865
|
-
exports.fetch = ctx.fetch; // To enable: import {fetch} from 'cross-fetch'
|
|
4866
|
-
exports.Headers = ctx.Headers;
|
|
4867
|
-
exports.Request = ctx.Request;
|
|
4868
|
-
exports.Response = ctx.Response;
|
|
4869
|
-
module.exports = exports;
|
|
4870
|
-
}(browserPonyfill, browserPonyfill.exports));
|
|
4871
|
-
|
|
4872
|
-
var crossFetch = /*@__PURE__*/getDefaultExportFromCjs(browserPonyfill.exports);
|
|
4873
|
-
|
|
4874
4340
|
var objToString = Object.prototype.toString;
|
|
4875
4341
|
var objKeys = Object.keys || function(obj) {
|
|
4876
4342
|
var keys = [];
|
|
@@ -5052,6 +4518,8 @@ class SendTransactionError extends Error {
|
|
|
5052
4518
|
|
|
5053
4519
|
}
|
|
5054
4520
|
|
|
4521
|
+
var fetchImpl = globalThis.fetch;
|
|
4522
|
+
|
|
5055
4523
|
// TODO: These constants should be removed in favor of reading them out of a
|
|
5056
4524
|
// Syscall account
|
|
5057
4525
|
|
|
@@ -5301,15 +4769,15 @@ const BlockProductionResponseStruct = jsonRpcResultAndContext(superstruct.type({
|
|
|
5301
4769
|
*/
|
|
5302
4770
|
|
|
5303
4771
|
function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit) {
|
|
5304
|
-
const fetch = customFetch ? customFetch :
|
|
4772
|
+
const fetch = customFetch ? customFetch : fetchImpl;
|
|
5305
4773
|
|
|
5306
4774
|
let fetchWithMiddleware;
|
|
5307
4775
|
|
|
5308
4776
|
if (fetchMiddleware) {
|
|
5309
|
-
fetchWithMiddleware = async (
|
|
4777
|
+
fetchWithMiddleware = async (info, init) => {
|
|
5310
4778
|
const modifiedFetchArgs = await new Promise((resolve, reject) => {
|
|
5311
4779
|
try {
|
|
5312
|
-
fetchMiddleware(
|
|
4780
|
+
fetchMiddleware(info, init, (modifiedInfo, modifiedInit) => resolve([modifiedInfo, modifiedInit]));
|
|
5313
4781
|
} catch (error) {
|
|
5314
4782
|
reject(error);
|
|
5315
4783
|
}
|