@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.
@@ -4,7 +4,8 @@ import BN from 'bn.js';
4
4
  import bs58 from 'bs58';
5
5
  import { serialize, deserialize, deserializeUnchecked } from 'borsh';
6
6
  import * as BufferLayout from '@solana/buffer-layout';
7
- import { u64 } from '@solana/buffer-layout-utils';
7
+ import { blob } from '@solana/buffer-layout';
8
+ import { toBigIntLE, toBufferLE } from 'bigint-buffer';
8
9
  import { coerce, instance, string, tuple, literal, unknown, union, type, optional, any, number, array, nullable, create, boolean, record, assert as assert$7 } from 'superstruct';
9
10
  import { Client } from 'rpc-websockets';
10
11
  import RpcClient from 'jayson/lib/client/browser';
@@ -21,12 +22,6 @@ const toBuffer = arr => {
21
22
  }
22
23
  };
23
24
 
24
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
25
-
26
- function getDefaultExportFromCjs (x) {
27
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
28
- }
29
-
30
25
  var hash$1 = {};
31
26
 
32
27
  var utils$9 = {};
@@ -1263,22 +1258,22 @@ Hmac.prototype.digest = function digest(enc) {
1263
1258
  };
1264
1259
 
1265
1260
  (function (exports) {
1266
- var hash = exports;
1267
-
1268
- hash.utils = utils$9;
1269
- hash.common = common$5;
1270
- hash.sha = sha;
1271
- hash.ripemd = ripemd;
1272
- hash.hmac = hmac;
1273
-
1274
- // Proxy hash functions to the main object
1275
- hash.sha1 = hash.sha.sha1;
1276
- hash.sha256 = hash.sha.sha256;
1277
- hash.sha224 = hash.sha.sha224;
1278
- hash.sha384 = hash.sha.sha384;
1279
- hash.sha512 = hash.sha.sha512;
1280
- hash.ripemd160 = hash.ripemd.ripemd160;
1281
- }(hash$1));
1261
+ var hash = exports;
1262
+
1263
+ hash.utils = utils$9;
1264
+ hash.common = common$5;
1265
+ hash.sha = sha;
1266
+ hash.ripemd = ripemd;
1267
+ hash.hmac = hmac;
1268
+
1269
+ // Proxy hash functions to the main object
1270
+ hash.sha1 = hash.sha.sha1;
1271
+ hash.sha256 = hash.sha.sha256;
1272
+ hash.sha224 = hash.sha.sha224;
1273
+ hash.sha384 = hash.sha.sha384;
1274
+ hash.sha512 = hash.sha.sha512;
1275
+ hash.ripemd160 = hash.ripemd.ripemd160;
1276
+ } (hash$1));
1282
1277
 
1283
1278
  var hash = hash$1;
1284
1279
 
@@ -2573,13 +2568,6 @@ class Transaction {
2573
2568
  isSigner: false,
2574
2569
  isWritable: false
2575
2570
  });
2576
- }); // Sort. Prioritizing first by signer, then by writable
2577
-
2578
- accountMetas.sort(function (x, y) {
2579
- const pubkeySorting = x.pubkey.toBase58().localeCompare(y.pubkey.toBase58());
2580
- const checkSigner = x.isSigner === y.isSigner ? 0 : x.isSigner ? -1 : 1;
2581
- const checkWritable = x.isWritable === y.isWritable ? pubkeySorting : x.isWritable ? -1 : 1;
2582
- return checkSigner || checkWritable;
2583
2571
  }); // Cull duplicate account metas
2584
2572
 
2585
2573
  const uniqueMetas = [];
@@ -2591,9 +2579,17 @@ class Transaction {
2591
2579
 
2592
2580
  if (uniqueIndex > -1) {
2593
2581
  uniqueMetas[uniqueIndex].isWritable = uniqueMetas[uniqueIndex].isWritable || accountMeta.isWritable;
2582
+ uniqueMetas[uniqueIndex].isSigner = uniqueMetas[uniqueIndex].isSigner || accountMeta.isSigner;
2594
2583
  } else {
2595
2584
  uniqueMetas.push(accountMeta);
2596
2585
  }
2586
+ }); // Sort. Prioritizing first by signer, then by writable
2587
+
2588
+ uniqueMetas.sort(function (x, y) {
2589
+ const pubkeySorting = x.pubkey.toBase58().localeCompare(y.pubkey.toBase58());
2590
+ const checkSigner = x.isSigner === y.isSigner ? 0 : x.isSigner ? -1 : 1;
2591
+ const checkWritable = x.isWritable === y.isWritable ? pubkeySorting : x.isWritable ? -1 : 1;
2592
+ return checkSigner || checkWritable;
2597
2593
  }); // Move fee payer to the front
2598
2594
 
2599
2595
  const feePayerIndex = uniqueMetas.findIndex(x => {
@@ -3175,6 +3171,38 @@ class NonceAccount {
3175
3171
 
3176
3172
  }
3177
3173
 
3174
+ const encodeDecode = layout => {
3175
+ const decode = layout.decode.bind(layout);
3176
+ const encode = layout.encode.bind(layout);
3177
+ return {
3178
+ decode,
3179
+ encode
3180
+ };
3181
+ };
3182
+
3183
+ const bigInt = length => property => {
3184
+ const layout = blob(length, property);
3185
+ const {
3186
+ encode,
3187
+ decode
3188
+ } = encodeDecode(layout);
3189
+ const bigIntLayout = layout;
3190
+
3191
+ bigIntLayout.decode = (buffer, offset) => {
3192
+ const src = decode(buffer, offset);
3193
+ return toBigIntLE(Buffer.from(src));
3194
+ };
3195
+
3196
+ bigIntLayout.encode = (bigInt, buffer, offset) => {
3197
+ const src = toBufferLE(bigInt, length);
3198
+ return encode(src, buffer, offset);
3199
+ };
3200
+
3201
+ return bigIntLayout;
3202
+ };
3203
+
3204
+ const u64 = bigInt(8);
3205
+
3178
3206
  /**
3179
3207
  * Create account system transaction params
3180
3208
  */
@@ -4278,567 +4306,6 @@ class ComputeBudgetProgram {
4278
4306
  }
4279
4307
  ComputeBudgetProgram.programId = new PublicKey('ComputeBudget111111111111111111111111111111');
4280
4308
 
4281
- var browserPonyfill = {exports: {}};
4282
-
4283
- (function (module, exports) {
4284
- var global = typeof self !== 'undefined' ? self : commonjsGlobal;
4285
- var __self__ = (function () {
4286
- function F() {
4287
- this.fetch = false;
4288
- this.DOMException = global.DOMException;
4289
- }
4290
- F.prototype = global;
4291
- return new F();
4292
- })();
4293
- (function(self) {
4294
-
4295
- ((function (exports) {
4296
-
4297
- var support = {
4298
- searchParams: 'URLSearchParams' in self,
4299
- iterable: 'Symbol' in self && 'iterator' in Symbol,
4300
- blob:
4301
- 'FileReader' in self &&
4302
- 'Blob' in self &&
4303
- (function() {
4304
- try {
4305
- new Blob();
4306
- return true
4307
- } catch (e) {
4308
- return false
4309
- }
4310
- })(),
4311
- formData: 'FormData' in self,
4312
- arrayBuffer: 'ArrayBuffer' in self
4313
- };
4314
-
4315
- function isDataView(obj) {
4316
- return obj && DataView.prototype.isPrototypeOf(obj)
4317
- }
4318
-
4319
- if (support.arrayBuffer) {
4320
- var viewClasses = [
4321
- '[object Int8Array]',
4322
- '[object Uint8Array]',
4323
- '[object Uint8ClampedArray]',
4324
- '[object Int16Array]',
4325
- '[object Uint16Array]',
4326
- '[object Int32Array]',
4327
- '[object Uint32Array]',
4328
- '[object Float32Array]',
4329
- '[object Float64Array]'
4330
- ];
4331
-
4332
- var isArrayBufferView =
4333
- ArrayBuffer.isView ||
4334
- function(obj) {
4335
- return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
4336
- };
4337
- }
4338
-
4339
- function normalizeName(name) {
4340
- if (typeof name !== 'string') {
4341
- name = String(name);
4342
- }
4343
- if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) {
4344
- throw new TypeError('Invalid character in header field name')
4345
- }
4346
- return name.toLowerCase()
4347
- }
4348
-
4349
- function normalizeValue(value) {
4350
- if (typeof value !== 'string') {
4351
- value = String(value);
4352
- }
4353
- return value
4354
- }
4355
-
4356
- // Build a destructive iterator for the value list
4357
- function iteratorFor(items) {
4358
- var iterator = {
4359
- next: function() {
4360
- var value = items.shift();
4361
- return {done: value === undefined, value: value}
4362
- }
4363
- };
4364
-
4365
- if (support.iterable) {
4366
- iterator[Symbol.iterator] = function() {
4367
- return iterator
4368
- };
4369
- }
4370
-
4371
- return iterator
4372
- }
4373
-
4374
- function Headers(headers) {
4375
- this.map = {};
4376
-
4377
- if (headers instanceof Headers) {
4378
- headers.forEach(function(value, name) {
4379
- this.append(name, value);
4380
- }, this);
4381
- } else if (Array.isArray(headers)) {
4382
- headers.forEach(function(header) {
4383
- this.append(header[0], header[1]);
4384
- }, this);
4385
- } else if (headers) {
4386
- Object.getOwnPropertyNames(headers).forEach(function(name) {
4387
- this.append(name, headers[name]);
4388
- }, this);
4389
- }
4390
- }
4391
-
4392
- Headers.prototype.append = function(name, value) {
4393
- name = normalizeName(name);
4394
- value = normalizeValue(value);
4395
- var oldValue = this.map[name];
4396
- this.map[name] = oldValue ? oldValue + ', ' + value : value;
4397
- };
4398
-
4399
- Headers.prototype['delete'] = function(name) {
4400
- delete this.map[normalizeName(name)];
4401
- };
4402
-
4403
- Headers.prototype.get = function(name) {
4404
- name = normalizeName(name);
4405
- return this.has(name) ? this.map[name] : null
4406
- };
4407
-
4408
- Headers.prototype.has = function(name) {
4409
- return this.map.hasOwnProperty(normalizeName(name))
4410
- };
4411
-
4412
- Headers.prototype.set = function(name, value) {
4413
- this.map[normalizeName(name)] = normalizeValue(value);
4414
- };
4415
-
4416
- Headers.prototype.forEach = function(callback, thisArg) {
4417
- for (var name in this.map) {
4418
- if (this.map.hasOwnProperty(name)) {
4419
- callback.call(thisArg, this.map[name], name, this);
4420
- }
4421
- }
4422
- };
4423
-
4424
- Headers.prototype.keys = function() {
4425
- var items = [];
4426
- this.forEach(function(value, name) {
4427
- items.push(name);
4428
- });
4429
- return iteratorFor(items)
4430
- };
4431
-
4432
- Headers.prototype.values = function() {
4433
- var items = [];
4434
- this.forEach(function(value) {
4435
- items.push(value);
4436
- });
4437
- return iteratorFor(items)
4438
- };
4439
-
4440
- Headers.prototype.entries = function() {
4441
- var items = [];
4442
- this.forEach(function(value, name) {
4443
- items.push([name, value]);
4444
- });
4445
- return iteratorFor(items)
4446
- };
4447
-
4448
- if (support.iterable) {
4449
- Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
4450
- }
4451
-
4452
- function consumed(body) {
4453
- if (body.bodyUsed) {
4454
- return Promise.reject(new TypeError('Already read'))
4455
- }
4456
- body.bodyUsed = true;
4457
- }
4458
-
4459
- function fileReaderReady(reader) {
4460
- return new Promise(function(resolve, reject) {
4461
- reader.onload = function() {
4462
- resolve(reader.result);
4463
- };
4464
- reader.onerror = function() {
4465
- reject(reader.error);
4466
- };
4467
- })
4468
- }
4469
-
4470
- function readBlobAsArrayBuffer(blob) {
4471
- var reader = new FileReader();
4472
- var promise = fileReaderReady(reader);
4473
- reader.readAsArrayBuffer(blob);
4474
- return promise
4475
- }
4476
-
4477
- function readBlobAsText(blob) {
4478
- var reader = new FileReader();
4479
- var promise = fileReaderReady(reader);
4480
- reader.readAsText(blob);
4481
- return promise
4482
- }
4483
-
4484
- function readArrayBufferAsText(buf) {
4485
- var view = new Uint8Array(buf);
4486
- var chars = new Array(view.length);
4487
-
4488
- for (var i = 0; i < view.length; i++) {
4489
- chars[i] = String.fromCharCode(view[i]);
4490
- }
4491
- return chars.join('')
4492
- }
4493
-
4494
- function bufferClone(buf) {
4495
- if (buf.slice) {
4496
- return buf.slice(0)
4497
- } else {
4498
- var view = new Uint8Array(buf.byteLength);
4499
- view.set(new Uint8Array(buf));
4500
- return view.buffer
4501
- }
4502
- }
4503
-
4504
- function Body() {
4505
- this.bodyUsed = false;
4506
-
4507
- this._initBody = function(body) {
4508
- this._bodyInit = body;
4509
- if (!body) {
4510
- this._bodyText = '';
4511
- } else if (typeof body === 'string') {
4512
- this._bodyText = body;
4513
- } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
4514
- this._bodyBlob = body;
4515
- } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
4516
- this._bodyFormData = body;
4517
- } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
4518
- this._bodyText = body.toString();
4519
- } else if (support.arrayBuffer && support.blob && isDataView(body)) {
4520
- this._bodyArrayBuffer = bufferClone(body.buffer);
4521
- // IE 10-11 can't handle a DataView body.
4522
- this._bodyInit = new Blob([this._bodyArrayBuffer]);
4523
- } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
4524
- this._bodyArrayBuffer = bufferClone(body);
4525
- } else {
4526
- this._bodyText = body = Object.prototype.toString.call(body);
4527
- }
4528
-
4529
- if (!this.headers.get('content-type')) {
4530
- if (typeof body === 'string') {
4531
- this.headers.set('content-type', 'text/plain;charset=UTF-8');
4532
- } else if (this._bodyBlob && this._bodyBlob.type) {
4533
- this.headers.set('content-type', this._bodyBlob.type);
4534
- } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
4535
- this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
4536
- }
4537
- }
4538
- };
4539
-
4540
- if (support.blob) {
4541
- this.blob = function() {
4542
- var rejected = consumed(this);
4543
- if (rejected) {
4544
- return rejected
4545
- }
4546
-
4547
- if (this._bodyBlob) {
4548
- return Promise.resolve(this._bodyBlob)
4549
- } else if (this._bodyArrayBuffer) {
4550
- return Promise.resolve(new Blob([this._bodyArrayBuffer]))
4551
- } else if (this._bodyFormData) {
4552
- throw new Error('could not read FormData body as blob')
4553
- } else {
4554
- return Promise.resolve(new Blob([this._bodyText]))
4555
- }
4556
- };
4557
-
4558
- this.arrayBuffer = function() {
4559
- if (this._bodyArrayBuffer) {
4560
- return consumed(this) || Promise.resolve(this._bodyArrayBuffer)
4561
- } else {
4562
- return this.blob().then(readBlobAsArrayBuffer)
4563
- }
4564
- };
4565
- }
4566
-
4567
- this.text = function() {
4568
- var rejected = consumed(this);
4569
- if (rejected) {
4570
- return rejected
4571
- }
4572
-
4573
- if (this._bodyBlob) {
4574
- return readBlobAsText(this._bodyBlob)
4575
- } else if (this._bodyArrayBuffer) {
4576
- return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
4577
- } else if (this._bodyFormData) {
4578
- throw new Error('could not read FormData body as text')
4579
- } else {
4580
- return Promise.resolve(this._bodyText)
4581
- }
4582
- };
4583
-
4584
- if (support.formData) {
4585
- this.formData = function() {
4586
- return this.text().then(decode)
4587
- };
4588
- }
4589
-
4590
- this.json = function() {
4591
- return this.text().then(JSON.parse)
4592
- };
4593
-
4594
- return this
4595
- }
4596
-
4597
- // HTTP methods whose capitalization should be normalized
4598
- var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];
4599
-
4600
- function normalizeMethod(method) {
4601
- var upcased = method.toUpperCase();
4602
- return methods.indexOf(upcased) > -1 ? upcased : method
4603
- }
4604
-
4605
- function Request(input, options) {
4606
- options = options || {};
4607
- var body = options.body;
4608
-
4609
- if (input instanceof Request) {
4610
- if (input.bodyUsed) {
4611
- throw new TypeError('Already read')
4612
- }
4613
- this.url = input.url;
4614
- this.credentials = input.credentials;
4615
- if (!options.headers) {
4616
- this.headers = new Headers(input.headers);
4617
- }
4618
- this.method = input.method;
4619
- this.mode = input.mode;
4620
- this.signal = input.signal;
4621
- if (!body && input._bodyInit != null) {
4622
- body = input._bodyInit;
4623
- input.bodyUsed = true;
4624
- }
4625
- } else {
4626
- this.url = String(input);
4627
- }
4628
-
4629
- this.credentials = options.credentials || this.credentials || 'same-origin';
4630
- if (options.headers || !this.headers) {
4631
- this.headers = new Headers(options.headers);
4632
- }
4633
- this.method = normalizeMethod(options.method || this.method || 'GET');
4634
- this.mode = options.mode || this.mode || null;
4635
- this.signal = options.signal || this.signal;
4636
- this.referrer = null;
4637
-
4638
- if ((this.method === 'GET' || this.method === 'HEAD') && body) {
4639
- throw new TypeError('Body not allowed for GET or HEAD requests')
4640
- }
4641
- this._initBody(body);
4642
- }
4643
-
4644
- Request.prototype.clone = function() {
4645
- return new Request(this, {body: this._bodyInit})
4646
- };
4647
-
4648
- function decode(body) {
4649
- var form = new FormData();
4650
- body
4651
- .trim()
4652
- .split('&')
4653
- .forEach(function(bytes) {
4654
- if (bytes) {
4655
- var split = bytes.split('=');
4656
- var name = split.shift().replace(/\+/g, ' ');
4657
- var value = split.join('=').replace(/\+/g, ' ');
4658
- form.append(decodeURIComponent(name), decodeURIComponent(value));
4659
- }
4660
- });
4661
- return form
4662
- }
4663
-
4664
- function parseHeaders(rawHeaders) {
4665
- var headers = new Headers();
4666
- // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
4667
- // https://tools.ietf.org/html/rfc7230#section-3.2
4668
- var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
4669
- preProcessedHeaders.split(/\r?\n/).forEach(function(line) {
4670
- var parts = line.split(':');
4671
- var key = parts.shift().trim();
4672
- if (key) {
4673
- var value = parts.join(':').trim();
4674
- headers.append(key, value);
4675
- }
4676
- });
4677
- return headers
4678
- }
4679
-
4680
- Body.call(Request.prototype);
4681
-
4682
- function Response(bodyInit, options) {
4683
- if (!options) {
4684
- options = {};
4685
- }
4686
-
4687
- this.type = 'default';
4688
- this.status = options.status === undefined ? 200 : options.status;
4689
- this.ok = this.status >= 200 && this.status < 300;
4690
- this.statusText = 'statusText' in options ? options.statusText : 'OK';
4691
- this.headers = new Headers(options.headers);
4692
- this.url = options.url || '';
4693
- this._initBody(bodyInit);
4694
- }
4695
-
4696
- Body.call(Response.prototype);
4697
-
4698
- Response.prototype.clone = function() {
4699
- return new Response(this._bodyInit, {
4700
- status: this.status,
4701
- statusText: this.statusText,
4702
- headers: new Headers(this.headers),
4703
- url: this.url
4704
- })
4705
- };
4706
-
4707
- Response.error = function() {
4708
- var response = new Response(null, {status: 0, statusText: ''});
4709
- response.type = 'error';
4710
- return response
4711
- };
4712
-
4713
- var redirectStatuses = [301, 302, 303, 307, 308];
4714
-
4715
- Response.redirect = function(url, status) {
4716
- if (redirectStatuses.indexOf(status) === -1) {
4717
- throw new RangeError('Invalid status code')
4718
- }
4719
-
4720
- return new Response(null, {status: status, headers: {location: url}})
4721
- };
4722
-
4723
- exports.DOMException = self.DOMException;
4724
- try {
4725
- new exports.DOMException();
4726
- } catch (err) {
4727
- exports.DOMException = function(message, name) {
4728
- this.message = message;
4729
- this.name = name;
4730
- var error = Error(message);
4731
- this.stack = error.stack;
4732
- };
4733
- exports.DOMException.prototype = Object.create(Error.prototype);
4734
- exports.DOMException.prototype.constructor = exports.DOMException;
4735
- }
4736
-
4737
- function fetch(input, init) {
4738
- return new Promise(function(resolve, reject) {
4739
- var request = new Request(input, init);
4740
-
4741
- if (request.signal && request.signal.aborted) {
4742
- return reject(new exports.DOMException('Aborted', 'AbortError'))
4743
- }
4744
-
4745
- var xhr = new XMLHttpRequest();
4746
-
4747
- function abortXhr() {
4748
- xhr.abort();
4749
- }
4750
-
4751
- xhr.onload = function() {
4752
- var options = {
4753
- status: xhr.status,
4754
- statusText: xhr.statusText,
4755
- headers: parseHeaders(xhr.getAllResponseHeaders() || '')
4756
- };
4757
- options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
4758
- var body = 'response' in xhr ? xhr.response : xhr.responseText;
4759
- resolve(new Response(body, options));
4760
- };
4761
-
4762
- xhr.onerror = function() {
4763
- reject(new TypeError('Network request failed'));
4764
- };
4765
-
4766
- xhr.ontimeout = function() {
4767
- reject(new TypeError('Network request failed'));
4768
- };
4769
-
4770
- xhr.onabort = function() {
4771
- reject(new exports.DOMException('Aborted', 'AbortError'));
4772
- };
4773
-
4774
- xhr.open(request.method, request.url, true);
4775
-
4776
- if (request.credentials === 'include') {
4777
- xhr.withCredentials = true;
4778
- } else if (request.credentials === 'omit') {
4779
- xhr.withCredentials = false;
4780
- }
4781
-
4782
- if ('responseType' in xhr && support.blob) {
4783
- xhr.responseType = 'blob';
4784
- }
4785
-
4786
- request.headers.forEach(function(value, name) {
4787
- xhr.setRequestHeader(name, value);
4788
- });
4789
-
4790
- if (request.signal) {
4791
- request.signal.addEventListener('abort', abortXhr);
4792
-
4793
- xhr.onreadystatechange = function() {
4794
- // DONE (success or failure)
4795
- if (xhr.readyState === 4) {
4796
- request.signal.removeEventListener('abort', abortXhr);
4797
- }
4798
- };
4799
- }
4800
-
4801
- xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
4802
- })
4803
- }
4804
-
4805
- fetch.polyfill = true;
4806
-
4807
- if (!self.fetch) {
4808
- self.fetch = fetch;
4809
- self.Headers = Headers;
4810
- self.Request = Request;
4811
- self.Response = Response;
4812
- }
4813
-
4814
- exports.Headers = Headers;
4815
- exports.Request = Request;
4816
- exports.Response = Response;
4817
- exports.fetch = fetch;
4818
-
4819
- Object.defineProperty(exports, '__esModule', { value: true });
4820
-
4821
- return exports;
4822
-
4823
- }))({});
4824
- })(__self__);
4825
- __self__.fetch.ponyfill = true;
4826
- // Remove "polyfill" property added by whatwg-fetch
4827
- delete __self__.fetch.polyfill;
4828
- // Choose between native implementation (global) or custom implementation (__self__)
4829
- // var ctx = global.fetch ? global : __self__;
4830
- var ctx = __self__; // this line disable service worker support temporarily
4831
- exports = ctx.fetch; // To enable: import fetch from 'cross-fetch'
4832
- exports.default = ctx.fetch; // For TypeScript consumers without esModuleInterop.
4833
- exports.fetch = ctx.fetch; // To enable: import {fetch} from 'cross-fetch'
4834
- exports.Headers = ctx.Headers;
4835
- exports.Request = ctx.Request;
4836
- exports.Response = ctx.Response;
4837
- module.exports = exports;
4838
- }(browserPonyfill, browserPonyfill.exports));
4839
-
4840
- var crossFetch = /*@__PURE__*/getDefaultExportFromCjs(browserPonyfill.exports);
4841
-
4842
4309
  var objToString = Object.prototype.toString;
4843
4310
  var objKeys = Object.keys || function(obj) {
4844
4311
  var keys = [];
@@ -5020,6 +4487,8 @@ class SendTransactionError extends Error {
5020
4487
 
5021
4488
  }
5022
4489
 
4490
+ var fetchImpl = globalThis.fetch;
4491
+
5023
4492
  // TODO: These constants should be removed in favor of reading them out of a
5024
4493
  // Syscall account
5025
4494
 
@@ -5269,15 +4738,15 @@ const BlockProductionResponseStruct = jsonRpcResultAndContext(type({
5269
4738
  */
5270
4739
 
5271
4740
  function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit) {
5272
- const fetch = customFetch ? customFetch : crossFetch;
4741
+ const fetch = customFetch ? customFetch : fetchImpl;
5273
4742
 
5274
4743
  let fetchWithMiddleware;
5275
4744
 
5276
4745
  if (fetchMiddleware) {
5277
- fetchWithMiddleware = async (url, options) => {
4746
+ fetchWithMiddleware = async (info, init) => {
5278
4747
  const modifiedFetchArgs = await new Promise((resolve, reject) => {
5279
4748
  try {
5280
- fetchMiddleware(url, options, (modifiedUrl, modifiedOptions) => resolve([modifiedUrl, modifiedOptions]));
4749
+ fetchMiddleware(info, init, (modifiedInfo, modifiedInit) => resolve([modifiedInfo, modifiedInit]));
5281
4750
  } catch (error) {
5282
4751
  reject(error);
5283
4752
  }