@solana/web3.js 1.40.1 → 1.41.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/lib/index.browser.cjs.js +648 -388
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +646 -388
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +648 -388
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +96 -30
- package/lib/index.esm.js +646 -388
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +680 -629
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +2 -24
- package/lib/index.iife.min.js.map +1 -1
- package/package.json +11 -8
- package/src/compute-budget.ts +189 -0
- package/src/connection.ts +657 -486
- package/src/index.ts +1 -0
- package/src/loader.ts +2 -1
- package/src/message.ts +1 -1
- package/src/transaction-constants.ts +10 -0
- package/src/transaction.ts +7 -16
package/lib/index.iife.js
CHANGED
|
@@ -13761,6 +13761,16 @@ var solanaWeb3 = (function (exports) {
|
|
|
13761
13761
|
/** Factory for {@link Constant} values. */
|
|
13762
13762
|
Layout$1.constant = ((value, property) => new Constant(value, property));
|
|
13763
13763
|
|
|
13764
|
+
/**
|
|
13765
|
+
* Maximum over-the-wire size of a Transaction
|
|
13766
|
+
*
|
|
13767
|
+
* 1280 is IPv6 minimum MTU
|
|
13768
|
+
* 40 bytes is the size of the IPv6 header
|
|
13769
|
+
* 8 bytes is the size of the fragment header
|
|
13770
|
+
*/
|
|
13771
|
+
const PACKET_DATA_SIZE = 1280 - 40 - 8;
|
|
13772
|
+
const SIGNATURE_LENGTH_IN_BYTES = 64;
|
|
13773
|
+
|
|
13764
13774
|
/**
|
|
13765
13775
|
* Layout for a public key
|
|
13766
13776
|
*/
|
|
@@ -14020,20 +14030,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
14020
14030
|
|
|
14021
14031
|
/**
|
|
14022
14032
|
* Default (empty) signature
|
|
14023
|
-
*
|
|
14024
|
-
* Signatures are 64 bytes in length
|
|
14025
14033
|
*/
|
|
14026
|
-
const DEFAULT_SIGNATURE = buffer.Buffer.alloc(
|
|
14027
|
-
/**
|
|
14028
|
-
* Maximum over-the-wire size of a Transaction
|
|
14029
|
-
*
|
|
14030
|
-
* 1280 is IPv6 minimum MTU
|
|
14031
|
-
* 40 bytes is the size of the IPv6 header
|
|
14032
|
-
* 8 bytes is the size of the fragment header
|
|
14033
|
-
*/
|
|
14034
|
-
|
|
14035
|
-
const PACKET_DATA_SIZE = 1280 - 40 - 8;
|
|
14036
|
-
const SIGNATURE_LENGTH = 64;
|
|
14034
|
+
const DEFAULT_SIGNATURE = buffer.Buffer.alloc(SIGNATURE_LENGTH_IN_BYTES).fill(0);
|
|
14037
14035
|
/**
|
|
14038
14036
|
* Account metadata used to define instructions
|
|
14039
14037
|
*/
|
|
@@ -14663,8 +14661,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
14663
14661
|
let signatures = [];
|
|
14664
14662
|
|
|
14665
14663
|
for (let i = 0; i < signatureCount; i++) {
|
|
14666
|
-
const signature = byteArray.slice(0,
|
|
14667
|
-
byteArray = byteArray.slice(
|
|
14664
|
+
const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
|
|
14665
|
+
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
14668
14666
|
signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
|
|
14669
14667
|
}
|
|
14670
14668
|
|
|
@@ -15553,11 +15551,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
15553
15551
|
}
|
|
15554
15552
|
SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
|
|
15555
15553
|
|
|
15556
|
-
// Keep program chunks under PACKET_DATA_SIZE, leaving enough room for the
|
|
15557
15554
|
// rest of the Transaction fields
|
|
15558
15555
|
//
|
|
15559
15556
|
// TODO: replace 300 with a proper constant for the size of the other
|
|
15560
15557
|
// Transaction fields
|
|
15558
|
+
|
|
15561
15559
|
const CHUNK_SIZE = PACKET_DATA_SIZE - 300;
|
|
15562
15560
|
/**
|
|
15563
15561
|
* Program loader interface
|
|
@@ -15757,6 +15755,136 @@ var solanaWeb3 = (function (exports) {
|
|
|
15757
15755
|
|
|
15758
15756
|
}
|
|
15759
15757
|
|
|
15758
|
+
/**
|
|
15759
|
+
* Compute Budget Instruction class
|
|
15760
|
+
*/
|
|
15761
|
+
|
|
15762
|
+
class ComputeBudgetInstruction {
|
|
15763
|
+
/**
|
|
15764
|
+
* @internal
|
|
15765
|
+
*/
|
|
15766
|
+
constructor() {}
|
|
15767
|
+
/**
|
|
15768
|
+
* Decode a compute budget instruction and retrieve the instruction type.
|
|
15769
|
+
*/
|
|
15770
|
+
|
|
15771
|
+
|
|
15772
|
+
static decodeInstructionType(instruction) {
|
|
15773
|
+
this.checkProgramId(instruction.programId);
|
|
15774
|
+
const instructionTypeLayout = u8('instruction');
|
|
15775
|
+
const typeIndex = instructionTypeLayout.decode(instruction.data);
|
|
15776
|
+
let type;
|
|
15777
|
+
|
|
15778
|
+
for (const [ixType, layout] of Object.entries(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS)) {
|
|
15779
|
+
if (layout.index == typeIndex) {
|
|
15780
|
+
type = ixType;
|
|
15781
|
+
break;
|
|
15782
|
+
}
|
|
15783
|
+
}
|
|
15784
|
+
|
|
15785
|
+
if (!type) {
|
|
15786
|
+
throw new Error('Instruction type incorrect; not a ComputeBudgetInstruction');
|
|
15787
|
+
}
|
|
15788
|
+
|
|
15789
|
+
return type;
|
|
15790
|
+
}
|
|
15791
|
+
/**
|
|
15792
|
+
* Decode request units compute budget instruction and retrieve the instruction params.
|
|
15793
|
+
*/
|
|
15794
|
+
|
|
15795
|
+
|
|
15796
|
+
static decodeRequestUnits(instruction) {
|
|
15797
|
+
this.checkProgramId(instruction.programId);
|
|
15798
|
+
const {
|
|
15799
|
+
units,
|
|
15800
|
+
additionalFee
|
|
15801
|
+
} = decodeData(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestUnits, instruction.data);
|
|
15802
|
+
return {
|
|
15803
|
+
units,
|
|
15804
|
+
additionalFee
|
|
15805
|
+
};
|
|
15806
|
+
}
|
|
15807
|
+
/**
|
|
15808
|
+
* Decode request heap frame compute budget instruction and retrieve the instruction params.
|
|
15809
|
+
*/
|
|
15810
|
+
|
|
15811
|
+
|
|
15812
|
+
static decodeRequestHeapFrame(instruction) {
|
|
15813
|
+
this.checkProgramId(instruction.programId);
|
|
15814
|
+
const {
|
|
15815
|
+
bytes
|
|
15816
|
+
} = decodeData(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestHeapFrame, instruction.data);
|
|
15817
|
+
return {
|
|
15818
|
+
bytes
|
|
15819
|
+
};
|
|
15820
|
+
}
|
|
15821
|
+
/**
|
|
15822
|
+
* @internal
|
|
15823
|
+
*/
|
|
15824
|
+
|
|
15825
|
+
|
|
15826
|
+
static checkProgramId(programId) {
|
|
15827
|
+
if (!programId.equals(ComputeBudgetProgram.programId)) {
|
|
15828
|
+
throw new Error('invalid instruction; programId is not ComputeBudgetProgram');
|
|
15829
|
+
}
|
|
15830
|
+
}
|
|
15831
|
+
|
|
15832
|
+
}
|
|
15833
|
+
/**
|
|
15834
|
+
* An enumeration of valid ComputeBudgetInstructionType's
|
|
15835
|
+
*/
|
|
15836
|
+
|
|
15837
|
+
/**
|
|
15838
|
+
* An enumeration of valid ComputeBudget InstructionType's
|
|
15839
|
+
* @internal
|
|
15840
|
+
*/
|
|
15841
|
+
const COMPUTE_BUDGET_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
15842
|
+
RequestUnits: {
|
|
15843
|
+
index: 0,
|
|
15844
|
+
layout: struct([u8('instruction'), u32('units'), u32('additionalFee')])
|
|
15845
|
+
},
|
|
15846
|
+
RequestHeapFrame: {
|
|
15847
|
+
index: 1,
|
|
15848
|
+
layout: struct([u8('instruction'), u32('bytes')])
|
|
15849
|
+
}
|
|
15850
|
+
});
|
|
15851
|
+
/**
|
|
15852
|
+
* Factory class for transaction instructions to interact with the Compute Budget program
|
|
15853
|
+
*/
|
|
15854
|
+
|
|
15855
|
+
class ComputeBudgetProgram {
|
|
15856
|
+
/**
|
|
15857
|
+
* @internal
|
|
15858
|
+
*/
|
|
15859
|
+
constructor() {}
|
|
15860
|
+
/**
|
|
15861
|
+
* Public key that identifies the Compute Budget program
|
|
15862
|
+
*/
|
|
15863
|
+
|
|
15864
|
+
|
|
15865
|
+
static requestUnits(params) {
|
|
15866
|
+
const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestUnits;
|
|
15867
|
+
const data = encodeData(type, params);
|
|
15868
|
+
return new TransactionInstruction({
|
|
15869
|
+
keys: [],
|
|
15870
|
+
programId: this.programId,
|
|
15871
|
+
data
|
|
15872
|
+
});
|
|
15873
|
+
}
|
|
15874
|
+
|
|
15875
|
+
static requestHeapFrame(params) {
|
|
15876
|
+
const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestHeapFrame;
|
|
15877
|
+
const data = encodeData(type, params);
|
|
15878
|
+
return new TransactionInstruction({
|
|
15879
|
+
keys: [],
|
|
15880
|
+
programId: this.programId,
|
|
15881
|
+
data
|
|
15882
|
+
});
|
|
15883
|
+
}
|
|
15884
|
+
|
|
15885
|
+
}
|
|
15886
|
+
ComputeBudgetProgram.programId = new PublicKey('ComputeBudget111111111111111111111111111111');
|
|
15887
|
+
|
|
15760
15888
|
var browserPonyfill = {exports: {}};
|
|
15761
15889
|
|
|
15762
15890
|
(function (module, exports) {
|
|
@@ -16318,6 +16446,82 @@ var solanaWeb3 = (function (exports) {
|
|
|
16318
16446
|
|
|
16319
16447
|
var crossFetch = /*@__PURE__*/getDefaultExportFromCjs(browserPonyfill.exports);
|
|
16320
16448
|
|
|
16449
|
+
var objToString = Object.prototype.toString;
|
|
16450
|
+
var objKeys = Object.keys || function(obj) {
|
|
16451
|
+
var keys = [];
|
|
16452
|
+
for (var name in obj) {
|
|
16453
|
+
keys.push(name);
|
|
16454
|
+
}
|
|
16455
|
+
return keys;
|
|
16456
|
+
};
|
|
16457
|
+
|
|
16458
|
+
function stringify$1(val, isArrayProp) {
|
|
16459
|
+
var i, max, str, keys, key, propVal, toStr;
|
|
16460
|
+
if (val === true) {
|
|
16461
|
+
return "true";
|
|
16462
|
+
}
|
|
16463
|
+
if (val === false) {
|
|
16464
|
+
return "false";
|
|
16465
|
+
}
|
|
16466
|
+
switch (typeof val) {
|
|
16467
|
+
case "object":
|
|
16468
|
+
if (val === null) {
|
|
16469
|
+
return null;
|
|
16470
|
+
} else if (val.toJSON && typeof val.toJSON === "function") {
|
|
16471
|
+
return stringify$1(val.toJSON(), isArrayProp);
|
|
16472
|
+
} else {
|
|
16473
|
+
toStr = objToString.call(val);
|
|
16474
|
+
if (toStr === "[object Array]") {
|
|
16475
|
+
str = '[';
|
|
16476
|
+
max = val.length - 1;
|
|
16477
|
+
for(i = 0; i < max; i++) {
|
|
16478
|
+
str += stringify$1(val[i], true) + ',';
|
|
16479
|
+
}
|
|
16480
|
+
if (max > -1) {
|
|
16481
|
+
str += stringify$1(val[i], true);
|
|
16482
|
+
}
|
|
16483
|
+
return str + ']';
|
|
16484
|
+
} else if (toStr === "[object Object]") {
|
|
16485
|
+
// only object is left
|
|
16486
|
+
keys = objKeys(val).sort();
|
|
16487
|
+
max = keys.length;
|
|
16488
|
+
str = "";
|
|
16489
|
+
i = 0;
|
|
16490
|
+
while (i < max) {
|
|
16491
|
+
key = keys[i];
|
|
16492
|
+
propVal = stringify$1(val[key], false);
|
|
16493
|
+
if (propVal !== undefined) {
|
|
16494
|
+
if (str) {
|
|
16495
|
+
str += ',';
|
|
16496
|
+
}
|
|
16497
|
+
str += JSON.stringify(key) + ':' + propVal;
|
|
16498
|
+
}
|
|
16499
|
+
i++;
|
|
16500
|
+
}
|
|
16501
|
+
return '{' + str + '}';
|
|
16502
|
+
} else {
|
|
16503
|
+
return JSON.stringify(val);
|
|
16504
|
+
}
|
|
16505
|
+
}
|
|
16506
|
+
case "function":
|
|
16507
|
+
case "undefined":
|
|
16508
|
+
return isArrayProp ? null : undefined;
|
|
16509
|
+
case "string":
|
|
16510
|
+
return JSON.stringify(val);
|
|
16511
|
+
default:
|
|
16512
|
+
return isFinite(val) ? val : null;
|
|
16513
|
+
}
|
|
16514
|
+
}
|
|
16515
|
+
|
|
16516
|
+
var fastStableStringify = function(val) {
|
|
16517
|
+
var returnVal = stringify$1(val, false);
|
|
16518
|
+
if (returnVal !== undefined) {
|
|
16519
|
+
return ''+ returnVal;
|
|
16520
|
+
}
|
|
16521
|
+
};
|
|
16522
|
+
|
|
16523
|
+
var fastStableStringify$1 = fastStableStringify;
|
|
16524
|
+
|
|
16321
16525
|
/**
|
|
16322
16526
|
* A `StructFailure` represents a single specific failure in validation.
|
|
16323
16527
|
*/
|
|
@@ -16942,6 +17146,31 @@ var solanaWeb3 = (function (exports) {
|
|
|
16942
17146
|
module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16943
17147
|
}(interopRequireDefault));
|
|
16944
17148
|
|
|
17149
|
+
var createClass = {exports: {}};
|
|
17150
|
+
|
|
17151
|
+
(function (module) {
|
|
17152
|
+
function _defineProperties(target, props) {
|
|
17153
|
+
for (var i = 0; i < props.length; i++) {
|
|
17154
|
+
var descriptor = props[i];
|
|
17155
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
17156
|
+
descriptor.configurable = true;
|
|
17157
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
17158
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
17159
|
+
}
|
|
17160
|
+
}
|
|
17161
|
+
|
|
17162
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
17163
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
17164
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
17165
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
17166
|
+
writable: false
|
|
17167
|
+
});
|
|
17168
|
+
return Constructor;
|
|
17169
|
+
}
|
|
17170
|
+
|
|
17171
|
+
module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
17172
|
+
}(createClass));
|
|
17173
|
+
|
|
16945
17174
|
var classCallCheck = {exports: {}};
|
|
16946
17175
|
|
|
16947
17176
|
(function (module) {
|
|
@@ -17059,31 +17288,6 @@ var solanaWeb3 = (function (exports) {
|
|
|
17059
17288
|
|
|
17060
17289
|
var websocket_browser = {};
|
|
17061
17290
|
|
|
17062
|
-
var createClass = {exports: {}};
|
|
17063
|
-
|
|
17064
|
-
(function (module) {
|
|
17065
|
-
function _defineProperties(target, props) {
|
|
17066
|
-
for (var i = 0; i < props.length; i++) {
|
|
17067
|
-
var descriptor = props[i];
|
|
17068
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
17069
|
-
descriptor.configurable = true;
|
|
17070
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
17071
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
17072
|
-
}
|
|
17073
|
-
}
|
|
17074
|
-
|
|
17075
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
17076
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
17077
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
17078
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
17079
|
-
writable: false
|
|
17080
|
-
});
|
|
17081
|
-
return Constructor;
|
|
17082
|
-
}
|
|
17083
|
-
|
|
17084
|
-
module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
17085
|
-
}(createClass));
|
|
17086
|
-
|
|
17087
17291
|
var eventemitter3 = {exports: {}};
|
|
17088
17292
|
|
|
17089
17293
|
(function (module) {
|
|
@@ -17452,7 +17656,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
17452
17656
|
|
|
17453
17657
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
17454
17658
|
|
|
17455
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
17659
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
17456
17660
|
|
|
17457
17661
|
var WebSocketBrowserImpl = /*#__PURE__*/function (_EventEmitter) {
|
|
17458
17662
|
(0, _inherits2["default"])(WebSocketBrowserImpl, _EventEmitter);
|
|
@@ -18353,215 +18557,6 @@ var solanaWeb3 = (function (exports) {
|
|
|
18353
18557
|
module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
18354
18558
|
}(asyncToGenerator));
|
|
18355
18559
|
|
|
18356
|
-
/*!
|
|
18357
|
-
Copyright (C) 2013-2017 by Andrea Giammarchi - @WebReflection
|
|
18358
|
-
|
|
18359
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18360
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
18361
|
-
in the Software without restriction, including without limitation the rights
|
|
18362
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18363
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
18364
|
-
furnished to do so, subject to the following conditions:
|
|
18365
|
-
|
|
18366
|
-
The above copyright notice and this permission notice shall be included in
|
|
18367
|
-
all copies or substantial portions of the Software.
|
|
18368
|
-
|
|
18369
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18370
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18371
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18372
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18373
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18374
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
18375
|
-
THE SOFTWARE.
|
|
18376
|
-
|
|
18377
|
-
*/
|
|
18378
|
-
|
|
18379
|
-
var
|
|
18380
|
-
// should be a not so common char
|
|
18381
|
-
// possibly one JSON does not encode
|
|
18382
|
-
// possibly one encodeURIComponent does not encode
|
|
18383
|
-
// right now this char is '~' but this might change in the future
|
|
18384
|
-
specialChar = '~',
|
|
18385
|
-
safeSpecialChar = '\\x' + (
|
|
18386
|
-
'0' + specialChar.charCodeAt(0).toString(16)
|
|
18387
|
-
).slice(-2),
|
|
18388
|
-
escapedSafeSpecialChar = '\\' + safeSpecialChar,
|
|
18389
|
-
specialCharRG = new RegExp(safeSpecialChar, 'g'),
|
|
18390
|
-
safeSpecialCharRG = new RegExp(escapedSafeSpecialChar, 'g'),
|
|
18391
|
-
|
|
18392
|
-
safeStartWithSpecialCharRG = new RegExp('(?:^|([^\\\\]))' + escapedSafeSpecialChar),
|
|
18393
|
-
|
|
18394
|
-
indexOf = [].indexOf || function(v){
|
|
18395
|
-
for(var i=this.length;i--&&this[i]!==v;);
|
|
18396
|
-
return i;
|
|
18397
|
-
},
|
|
18398
|
-
$String = String // there's no way to drop warnings in JSHint
|
|
18399
|
-
// about new String ... well, I need that here!
|
|
18400
|
-
// faked, and happy linter!
|
|
18401
|
-
;
|
|
18402
|
-
|
|
18403
|
-
function generateReplacer(value, replacer, resolve) {
|
|
18404
|
-
var
|
|
18405
|
-
doNotIgnore = false,
|
|
18406
|
-
inspect = !!replacer,
|
|
18407
|
-
path = [],
|
|
18408
|
-
all = [value],
|
|
18409
|
-
seen = [value],
|
|
18410
|
-
mapp = [resolve ? specialChar : '[Circular]'],
|
|
18411
|
-
last = value,
|
|
18412
|
-
lvl = 1,
|
|
18413
|
-
i, fn
|
|
18414
|
-
;
|
|
18415
|
-
if (inspect) {
|
|
18416
|
-
fn = typeof replacer === 'object' ?
|
|
18417
|
-
function (key, value) {
|
|
18418
|
-
return key !== '' && replacer.indexOf(key) < 0 ? void 0 : value;
|
|
18419
|
-
} :
|
|
18420
|
-
replacer;
|
|
18421
|
-
}
|
|
18422
|
-
return function(key, value) {
|
|
18423
|
-
// the replacer has rights to decide
|
|
18424
|
-
// if a new object should be returned
|
|
18425
|
-
// or if there's some key to drop
|
|
18426
|
-
// let's call it here rather than "too late"
|
|
18427
|
-
if (inspect) value = fn.call(this, key, value);
|
|
18428
|
-
|
|
18429
|
-
// first pass should be ignored, since it's just the initial object
|
|
18430
|
-
if (doNotIgnore) {
|
|
18431
|
-
if (last !== this) {
|
|
18432
|
-
i = lvl - indexOf.call(all, this) - 1;
|
|
18433
|
-
lvl -= i;
|
|
18434
|
-
all.splice(lvl, all.length);
|
|
18435
|
-
path.splice(lvl - 1, path.length);
|
|
18436
|
-
last = this;
|
|
18437
|
-
}
|
|
18438
|
-
// console.log(lvl, key, path);
|
|
18439
|
-
if (typeof value === 'object' && value) {
|
|
18440
|
-
// if object isn't referring to parent object, add to the
|
|
18441
|
-
// object path stack. Otherwise it is already there.
|
|
18442
|
-
if (indexOf.call(all, value) < 0) {
|
|
18443
|
-
all.push(last = value);
|
|
18444
|
-
}
|
|
18445
|
-
lvl = all.length;
|
|
18446
|
-
i = indexOf.call(seen, value);
|
|
18447
|
-
if (i < 0) {
|
|
18448
|
-
i = seen.push(value) - 1;
|
|
18449
|
-
if (resolve) {
|
|
18450
|
-
// key cannot contain specialChar but could be not a string
|
|
18451
|
-
path.push(('' + key).replace(specialCharRG, safeSpecialChar));
|
|
18452
|
-
mapp[i] = specialChar + path.join(specialChar);
|
|
18453
|
-
} else {
|
|
18454
|
-
mapp[i] = mapp[0];
|
|
18455
|
-
}
|
|
18456
|
-
} else {
|
|
18457
|
-
value = mapp[i];
|
|
18458
|
-
}
|
|
18459
|
-
} else {
|
|
18460
|
-
if (typeof value === 'string' && resolve) {
|
|
18461
|
-
// ensure no special char involved on deserialization
|
|
18462
|
-
// in this case only first char is important
|
|
18463
|
-
// no need to replace all value (better performance)
|
|
18464
|
-
value = value .replace(safeSpecialChar, escapedSafeSpecialChar)
|
|
18465
|
-
.replace(specialChar, safeSpecialChar);
|
|
18466
|
-
}
|
|
18467
|
-
}
|
|
18468
|
-
} else {
|
|
18469
|
-
doNotIgnore = true;
|
|
18470
|
-
}
|
|
18471
|
-
return value;
|
|
18472
|
-
};
|
|
18473
|
-
}
|
|
18474
|
-
|
|
18475
|
-
function retrieveFromPath(current, keys) {
|
|
18476
|
-
for(var i = 0, length = keys.length; i < length; current = current[
|
|
18477
|
-
// keys should be normalized back here
|
|
18478
|
-
keys[i++].replace(safeSpecialCharRG, specialChar)
|
|
18479
|
-
]);
|
|
18480
|
-
return current;
|
|
18481
|
-
}
|
|
18482
|
-
|
|
18483
|
-
function generateReviver(reviver) {
|
|
18484
|
-
return function(key, value) {
|
|
18485
|
-
var isString = typeof value === 'string';
|
|
18486
|
-
if (isString && value.charAt(0) === specialChar) {
|
|
18487
|
-
return new $String(value.slice(1));
|
|
18488
|
-
}
|
|
18489
|
-
if (key === '') value = regenerate(value, value, {});
|
|
18490
|
-
// again, only one needed, do not use the RegExp for this replacement
|
|
18491
|
-
// only keys need the RegExp
|
|
18492
|
-
if (isString) value = value .replace(safeStartWithSpecialCharRG, '$1' + specialChar)
|
|
18493
|
-
.replace(escapedSafeSpecialChar, safeSpecialChar);
|
|
18494
|
-
return reviver ? reviver.call(this, key, value) : value;
|
|
18495
|
-
};
|
|
18496
|
-
}
|
|
18497
|
-
|
|
18498
|
-
function regenerateArray(root, current, retrieve) {
|
|
18499
|
-
for (var i = 0, length = current.length; i < length; i++) {
|
|
18500
|
-
current[i] = regenerate(root, current[i], retrieve);
|
|
18501
|
-
}
|
|
18502
|
-
return current;
|
|
18503
|
-
}
|
|
18504
|
-
|
|
18505
|
-
function regenerateObject(root, current, retrieve) {
|
|
18506
|
-
for (var key in current) {
|
|
18507
|
-
if (current.hasOwnProperty(key)) {
|
|
18508
|
-
current[key] = regenerate(root, current[key], retrieve);
|
|
18509
|
-
}
|
|
18510
|
-
}
|
|
18511
|
-
return current;
|
|
18512
|
-
}
|
|
18513
|
-
|
|
18514
|
-
function regenerate(root, current, retrieve) {
|
|
18515
|
-
return current instanceof Array ?
|
|
18516
|
-
// fast Array reconstruction
|
|
18517
|
-
regenerateArray(root, current, retrieve) :
|
|
18518
|
-
(
|
|
18519
|
-
current instanceof $String ?
|
|
18520
|
-
(
|
|
18521
|
-
// root is an empty string
|
|
18522
|
-
current.length ?
|
|
18523
|
-
(
|
|
18524
|
-
retrieve.hasOwnProperty(current) ?
|
|
18525
|
-
retrieve[current] :
|
|
18526
|
-
retrieve[current] = retrieveFromPath(
|
|
18527
|
-
root, current.split(specialChar)
|
|
18528
|
-
)
|
|
18529
|
-
) :
|
|
18530
|
-
root
|
|
18531
|
-
) :
|
|
18532
|
-
(
|
|
18533
|
-
current instanceof Object ?
|
|
18534
|
-
// dedicated Object parser
|
|
18535
|
-
regenerateObject(root, current, retrieve) :
|
|
18536
|
-
// value as it is
|
|
18537
|
-
current
|
|
18538
|
-
)
|
|
18539
|
-
)
|
|
18540
|
-
;
|
|
18541
|
-
}
|
|
18542
|
-
|
|
18543
|
-
var CircularJSON = {
|
|
18544
|
-
stringify: function stringify(value, replacer, space, doNotResolve) {
|
|
18545
|
-
return CircularJSON.parser.stringify(
|
|
18546
|
-
value,
|
|
18547
|
-
generateReplacer(value, replacer, !doNotResolve),
|
|
18548
|
-
space
|
|
18549
|
-
);
|
|
18550
|
-
},
|
|
18551
|
-
parse: function parse(text, reviver) {
|
|
18552
|
-
return CircularJSON.parser.parse(
|
|
18553
|
-
text,
|
|
18554
|
-
generateReviver(reviver)
|
|
18555
|
-
);
|
|
18556
|
-
},
|
|
18557
|
-
// A parser should be an API 1:1 compatible with JSON
|
|
18558
|
-
// it should expose stringify and parse methods.
|
|
18559
|
-
// The default parser is the native JSON.
|
|
18560
|
-
parser: JSON
|
|
18561
|
-
};
|
|
18562
|
-
|
|
18563
|
-
var circularJson_node = CircularJSON;
|
|
18564
|
-
|
|
18565
18560
|
/**
|
|
18566
18561
|
* "Client" wraps "ws" or a browser-implemented "WebSocket" library
|
|
18567
18562
|
* according to the environment providing JSON RPC 2.0 support on top.
|
|
@@ -18595,11 +18590,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
18595
18590
|
|
|
18596
18591
|
var _eventemitter = eventemitter3.exports;
|
|
18597
18592
|
|
|
18598
|
-
var _circularJson = _interopRequireDefault(circularJson_node);
|
|
18599
|
-
|
|
18600
18593
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
18601
18594
|
|
|
18602
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
18595
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
18603
18596
|
|
|
18604
18597
|
var __rest = function (s, e) {
|
|
18605
18598
|
var t = {};
|
|
@@ -18983,7 +18976,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18983
18976
|
if (message instanceof ArrayBuffer) message = Buffer.from(message).toString();
|
|
18984
18977
|
|
|
18985
18978
|
try {
|
|
18986
|
-
message =
|
|
18979
|
+
message = JSON.parse(message);
|
|
18987
18980
|
} catch (error) {
|
|
18988
18981
|
return;
|
|
18989
18982
|
} // check if any listeners are attached and forward event
|
|
@@ -19054,6 +19047,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
19054
19047
|
});
|
|
19055
19048
|
var Client_1 = index_browser.Client = void 0;
|
|
19056
19049
|
|
|
19050
|
+
var _createClass2 = _interopRequireDefault(createClass.exports);
|
|
19051
|
+
|
|
19057
19052
|
var _classCallCheck2 = _interopRequireDefault(classCallCheck.exports);
|
|
19058
19053
|
|
|
19059
19054
|
var _inherits2 = _interopRequireDefault(inherits$3.exports);
|
|
@@ -19068,7 +19063,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
19068
19063
|
|
|
19069
19064
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
19070
19065
|
|
|
19071
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
19066
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
19072
19067
|
|
|
19073
19068
|
var Client = /*#__PURE__*/function (_CommonClient) {
|
|
19074
19069
|
(0, _inherits2["default"])(Client, _CommonClient);
|
|
@@ -19098,7 +19093,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
19098
19093
|
}, generate_request_id);
|
|
19099
19094
|
}
|
|
19100
19095
|
|
|
19101
|
-
return Client;
|
|
19096
|
+
return (0, _createClass2["default"])(Client);
|
|
19102
19097
|
}(_client["default"]);
|
|
19103
19098
|
|
|
19104
19099
|
Client_1 = index_browser.Client = Client;
|
|
@@ -20095,6 +20090,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
20095
20090
|
*/
|
|
20096
20091
|
|
|
20097
20092
|
const BLOCKHASH_CACHE_TIMEOUT_MS = 30 * 1000;
|
|
20093
|
+
/**
|
|
20094
|
+
* HACK.
|
|
20095
|
+
* Copied from rpc-websockets/dist/lib/client.
|
|
20096
|
+
* Otherwise, `yarn build` fails with:
|
|
20097
|
+
* https://gist.github.com/steveluscher/c057eca81d479ef705cdb53162f9971d
|
|
20098
|
+
*/
|
|
20098
20099
|
|
|
20099
20100
|
/**
|
|
20100
20101
|
* @internal
|
|
@@ -20963,14 +20964,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
20963
20964
|
* Filter for log subscriptions.
|
|
20964
20965
|
*/
|
|
20965
20966
|
|
|
20966
|
-
function createSubscriptionWarningMessage(id, label) {
|
|
20967
|
-
return 'Ignored unsubscribe request because an active subscription ' + `with id \`${id}\` for '${label}' events could not be found.`;
|
|
20968
|
-
}
|
|
20969
20967
|
/**
|
|
20970
20968
|
* A connection to a fullnode JSON RPC endpoint
|
|
20971
20969
|
*/
|
|
20972
|
-
|
|
20973
|
-
|
|
20974
20970
|
class Connection {
|
|
20975
20971
|
/** @internal */
|
|
20976
20972
|
|
|
@@ -20994,21 +20990,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
20994
20990
|
|
|
20995
20991
|
/** @internal */
|
|
20996
20992
|
|
|
20997
|
-
/** @internal
|
|
20998
|
-
|
|
20999
|
-
|
|
21000
|
-
|
|
21001
|
-
|
|
21002
|
-
|
|
21003
|
-
|
|
21004
|
-
|
|
21005
|
-
/** @internal */
|
|
21006
|
-
|
|
21007
|
-
/** @internal */
|
|
21008
|
-
|
|
21009
|
-
/** @internal */
|
|
21010
|
-
|
|
21011
|
-
/** @internal */
|
|
20993
|
+
/** @internal
|
|
20994
|
+
* A number that we increment every time an active connection closes.
|
|
20995
|
+
* Used to determine whether the same socket connection that was open
|
|
20996
|
+
* when an async operation started is the same one that's active when
|
|
20997
|
+
* its continuation fires.
|
|
20998
|
+
*
|
|
20999
|
+
*/
|
|
21012
21000
|
|
|
21013
21001
|
/** @internal */
|
|
21014
21002
|
|
|
@@ -21024,7 +21012,19 @@ var solanaWeb3 = (function (exports) {
|
|
|
21024
21012
|
|
|
21025
21013
|
/** @internal */
|
|
21026
21014
|
|
|
21027
|
-
/**
|
|
21015
|
+
/**
|
|
21016
|
+
* Special case.
|
|
21017
|
+
* After a signature is processed, RPCs automatically dispose of the
|
|
21018
|
+
* subscription on the server side. We need to track which of these
|
|
21019
|
+
* subscriptions have been disposed in such a way, so that we know
|
|
21020
|
+
* whether the client is dealing with a not-yet-processed signature
|
|
21021
|
+
* (in which case we must tear down the server subscription) or an
|
|
21022
|
+
* already-processed signature (in which case the client can simply
|
|
21023
|
+
* clear out the subscription locally without telling the server).
|
|
21024
|
+
*
|
|
21025
|
+
* NOTE: There is a proposal to eliminate this special case, here:
|
|
21026
|
+
* https://github.com/solana-labs/solana/issues/18892
|
|
21027
|
+
*/
|
|
21028
21028
|
|
|
21029
21029
|
/** @internal */
|
|
21030
21030
|
|
|
@@ -21046,6 +21046,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
21046
21046
|
this._rpcWebSocketConnected = false;
|
|
21047
21047
|
this._rpcWebSocketHeartbeat = null;
|
|
21048
21048
|
this._rpcWebSocketIdleTimeout = null;
|
|
21049
|
+
this._rpcWebSocketGeneration = 0;
|
|
21049
21050
|
this._disableBlockhashCaching = false;
|
|
21050
21051
|
this._pollingBlockhash = false;
|
|
21051
21052
|
this._blockhashInfo = {
|
|
@@ -21054,20 +21055,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
21054
21055
|
transactionSignatures: [],
|
|
21055
21056
|
simulatedSignatures: []
|
|
21056
21057
|
};
|
|
21057
|
-
this.
|
|
21058
|
-
this.
|
|
21059
|
-
this.
|
|
21060
|
-
this.
|
|
21061
|
-
this.
|
|
21062
|
-
this._rootSubscriptions = {};
|
|
21063
|
-
this._signatureSubscriptionCounter = 0;
|
|
21064
|
-
this._signatureSubscriptions = {};
|
|
21065
|
-
this._slotSubscriptionCounter = 0;
|
|
21066
|
-
this._slotSubscriptions = {};
|
|
21067
|
-
this._logsSubscriptionCounter = 0;
|
|
21068
|
-
this._logsSubscriptions = {};
|
|
21069
|
-
this._slotUpdateSubscriptionCounter = 0;
|
|
21070
|
-
this._slotUpdateSubscriptions = {};
|
|
21058
|
+
this._nextClientSubscriptionId = 0;
|
|
21059
|
+
this._subscriptionDisposeFunctionsByClientSubscriptionId = {};
|
|
21060
|
+
this._subscriptionCallbacksByServerSubscriptionId = {};
|
|
21061
|
+
this._subscriptionsByHash = {};
|
|
21062
|
+
this._subscriptionsAutoDisposedByRpc = new Set();
|
|
21071
21063
|
let url = new URL(endpoint);
|
|
21072
21064
|
const useHttps = url.protocol === 'https:';
|
|
21073
21065
|
let wsEndpoint;
|
|
@@ -22835,6 +22827,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
22835
22827
|
|
|
22836
22828
|
|
|
22837
22829
|
_wsOnClose(code) {
|
|
22830
|
+
this._rpcWebSocketGeneration++;
|
|
22831
|
+
|
|
22838
22832
|
if (this._rpcWebSocketHeartbeat) {
|
|
22839
22833
|
clearInterval(this._rpcWebSocketHeartbeat);
|
|
22840
22834
|
this._rpcWebSocketHeartbeat = null;
|
|
@@ -22848,85 +22842,20 @@ var solanaWeb3 = (function (exports) {
|
|
|
22848
22842
|
} // implicit close, prepare subscriptions for auto-reconnect
|
|
22849
22843
|
|
|
22850
22844
|
|
|
22851
|
-
this.
|
|
22852
|
-
|
|
22853
|
-
|
|
22854
|
-
|
|
22855
|
-
|
|
22856
|
-
|
|
22857
|
-
|
|
22858
|
-
async _subscribe(sub, rpcMethod, rpcArgs) {
|
|
22859
|
-
if (sub.subscriptionId == null) {
|
|
22860
|
-
sub.subscriptionId = 'subscribing';
|
|
22861
|
-
|
|
22862
|
-
try {
|
|
22863
|
-
const id = await this._rpcWebSocket.call(rpcMethod, rpcArgs);
|
|
22864
|
-
|
|
22865
|
-
if (typeof id === 'number' && sub.subscriptionId === 'subscribing') {
|
|
22866
|
-
// eslint-disable-next-line require-atomic-updates
|
|
22867
|
-
sub.subscriptionId = id;
|
|
22868
|
-
}
|
|
22869
|
-
} catch (err) {
|
|
22870
|
-
if (sub.subscriptionId === 'subscribing') {
|
|
22871
|
-
// eslint-disable-next-line require-atomic-updates
|
|
22872
|
-
sub.subscriptionId = null;
|
|
22873
|
-
}
|
|
22874
|
-
|
|
22875
|
-
if (err instanceof Error) {
|
|
22876
|
-
console.error(`${rpcMethod} error for argument`, rpcArgs, err.message);
|
|
22877
|
-
}
|
|
22878
|
-
}
|
|
22879
|
-
}
|
|
22880
|
-
}
|
|
22881
|
-
/**
|
|
22882
|
-
* @internal
|
|
22883
|
-
*/
|
|
22884
|
-
|
|
22885
|
-
|
|
22886
|
-
async _unsubscribe(sub, rpcMethod) {
|
|
22887
|
-
const subscriptionId = sub.subscriptionId;
|
|
22888
|
-
|
|
22889
|
-
if (subscriptionId != null && typeof subscriptionId != 'string') {
|
|
22890
|
-
const unsubscribeId = subscriptionId;
|
|
22891
|
-
|
|
22892
|
-
try {
|
|
22893
|
-
await this._rpcWebSocket.call(rpcMethod, [unsubscribeId]);
|
|
22894
|
-
} catch (err) {
|
|
22895
|
-
if (err instanceof Error) {
|
|
22896
|
-
console.error(`${rpcMethod} error:`, err.message);
|
|
22897
|
-
}
|
|
22898
|
-
}
|
|
22899
|
-
}
|
|
22900
|
-
}
|
|
22901
|
-
/**
|
|
22902
|
-
* @internal
|
|
22903
|
-
*/
|
|
22904
|
-
|
|
22905
|
-
|
|
22906
|
-
_resetSubscriptions() {
|
|
22907
|
-
Object.values(this._accountChangeSubscriptions).forEach(s => s.subscriptionId = null);
|
|
22908
|
-
Object.values(this._logsSubscriptions).forEach(s => s.subscriptionId = null);
|
|
22909
|
-
Object.values(this._programAccountChangeSubscriptions).forEach(s => s.subscriptionId = null);
|
|
22910
|
-
Object.values(this._rootSubscriptions).forEach(s => s.subscriptionId = null);
|
|
22911
|
-
Object.values(this._signatureSubscriptions).forEach(s => s.subscriptionId = null);
|
|
22912
|
-
Object.values(this._slotSubscriptions).forEach(s => s.subscriptionId = null);
|
|
22913
|
-
Object.values(this._slotUpdateSubscriptions).forEach(s => s.subscriptionId = null);
|
|
22845
|
+
this._subscriptionCallbacksByServerSubscriptionId = {};
|
|
22846
|
+
Object.entries(this._subscriptionsByHash).forEach(([hash, subscription]) => {
|
|
22847
|
+
this._subscriptionsByHash[hash] = { ...subscription,
|
|
22848
|
+
state: 'pending'
|
|
22849
|
+
};
|
|
22850
|
+
});
|
|
22914
22851
|
}
|
|
22915
22852
|
/**
|
|
22916
22853
|
* @internal
|
|
22917
22854
|
*/
|
|
22918
22855
|
|
|
22919
22856
|
|
|
22920
|
-
_updateSubscriptions() {
|
|
22921
|
-
|
|
22922
|
-
const programKeys = Object.keys(this._programAccountChangeSubscriptions).map(Number);
|
|
22923
|
-
const slotKeys = Object.keys(this._slotSubscriptions).map(Number);
|
|
22924
|
-
const slotUpdateKeys = Object.keys(this._slotUpdateSubscriptions).map(Number);
|
|
22925
|
-
const signatureKeys = Object.keys(this._signatureSubscriptions).map(Number);
|
|
22926
|
-
const rootKeys = Object.keys(this._rootSubscriptions).map(Number);
|
|
22927
|
-
const logsKeys = Object.keys(this._logsSubscriptions).map(Number);
|
|
22928
|
-
|
|
22929
|
-
if (accountKeys.length === 0 && programKeys.length === 0 && slotKeys.length === 0 && slotUpdateKeys.length === 0 && signatureKeys.length === 0 && rootKeys.length === 0 && logsKeys.length === 0) {
|
|
22857
|
+
async _updateSubscriptions() {
|
|
22858
|
+
if (Object.keys(this._subscriptionsByHash).length === 0) {
|
|
22930
22859
|
if (this._rpcWebSocketConnected) {
|
|
22931
22860
|
this._rpcWebSocketConnected = false;
|
|
22932
22861
|
this._rpcWebSocketIdleTimeout = setTimeout(() => {
|
|
@@ -22958,60 +22887,167 @@ var solanaWeb3 = (function (exports) {
|
|
|
22958
22887
|
return;
|
|
22959
22888
|
}
|
|
22960
22889
|
|
|
22961
|
-
|
|
22962
|
-
const sub = this._accountChangeSubscriptions[id];
|
|
22890
|
+
const activeWebSocketGeneration = this._rpcWebSocketGeneration;
|
|
22963
22891
|
|
|
22964
|
-
|
|
22965
|
-
|
|
22966
|
-
|
|
22967
|
-
for (let id of programKeys) {
|
|
22968
|
-
const sub = this._programAccountChangeSubscriptions[id];
|
|
22892
|
+
const isCurrentConnectionStillActive = () => {
|
|
22893
|
+
return activeWebSocketGeneration === this._rpcWebSocketGeneration;
|
|
22894
|
+
};
|
|
22969
22895
|
|
|
22970
|
-
|
|
22971
|
-
|
|
22972
|
-
|
|
22973
|
-
|
|
22896
|
+
await Promise.all( // Don't be tempted to change this to `Object.entries`. We call
|
|
22897
|
+
// `_updateSubscriptions` recursively when processing the state,
|
|
22898
|
+
// so it's important that we look up the *current* version of
|
|
22899
|
+
// each subscription, every time we process a hash.
|
|
22900
|
+
Object.keys(this._subscriptionsByHash).map(async hash => {
|
|
22901
|
+
const subscription = this._subscriptionsByHash[hash];
|
|
22974
22902
|
|
|
22975
|
-
|
|
22976
|
-
|
|
22903
|
+
if (subscription === undefined) {
|
|
22904
|
+
// This entry has since been deleted. Skip.
|
|
22905
|
+
return;
|
|
22906
|
+
}
|
|
22977
22907
|
|
|
22978
|
-
|
|
22979
|
-
|
|
22908
|
+
switch (subscription.state) {
|
|
22909
|
+
case 'pending':
|
|
22910
|
+
case 'unsubscribed':
|
|
22911
|
+
if (subscription.callbacks.size === 0) {
|
|
22912
|
+
/**
|
|
22913
|
+
* You can end up here when:
|
|
22914
|
+
*
|
|
22915
|
+
* - a subscription has recently unsubscribed
|
|
22916
|
+
* without having new callbacks added to it
|
|
22917
|
+
* while the unsubscribe was in flight, or
|
|
22918
|
+
* - when a pending subscription has its
|
|
22919
|
+
* listeners removed before a request was
|
|
22920
|
+
* sent to the server.
|
|
22921
|
+
*
|
|
22922
|
+
* Being that nobody is interested in this
|
|
22923
|
+
* subscription any longer, delete it.
|
|
22924
|
+
*/
|
|
22925
|
+
delete this._subscriptionsByHash[hash];
|
|
22926
|
+
|
|
22927
|
+
if (subscription.state === 'unsubscribed') {
|
|
22928
|
+
delete this._subscriptionCallbacksByServerSubscriptionId[subscription.serverSubscriptionId];
|
|
22929
|
+
}
|
|
22980
22930
|
|
|
22981
|
-
|
|
22982
|
-
|
|
22931
|
+
await this._updateSubscriptions();
|
|
22932
|
+
return;
|
|
22933
|
+
}
|
|
22983
22934
|
|
|
22984
|
-
|
|
22985
|
-
|
|
22935
|
+
await (async () => {
|
|
22936
|
+
const {
|
|
22937
|
+
args,
|
|
22938
|
+
method
|
|
22939
|
+
} = subscription;
|
|
22986
22940
|
|
|
22987
|
-
|
|
22988
|
-
|
|
22989
|
-
|
|
22990
|
-
|
|
22941
|
+
try {
|
|
22942
|
+
this._subscriptionsByHash[hash] = { ...subscription,
|
|
22943
|
+
state: 'subscribing'
|
|
22944
|
+
};
|
|
22945
|
+
const serverSubscriptionId = await this._rpcWebSocket.call(method, args);
|
|
22946
|
+
this._subscriptionsByHash[hash] = { ...subscription,
|
|
22947
|
+
serverSubscriptionId,
|
|
22948
|
+
state: 'subscribed'
|
|
22949
|
+
};
|
|
22950
|
+
this._subscriptionCallbacksByServerSubscriptionId[serverSubscriptionId] = subscription.callbacks;
|
|
22951
|
+
await this._updateSubscriptions();
|
|
22952
|
+
} catch (e) {
|
|
22953
|
+
if (e instanceof Error) {
|
|
22954
|
+
console.error(`${method} error for argument`, args, e.message);
|
|
22955
|
+
}
|
|
22956
|
+
|
|
22957
|
+
if (!isCurrentConnectionStillActive()) {
|
|
22958
|
+
return;
|
|
22959
|
+
} // TODO: Maybe add an 'errored' state or a retry limit?
|
|
22991
22960
|
|
|
22992
|
-
this._subscribe(sub, 'signatureSubscribe', args);
|
|
22993
|
-
}
|
|
22994
22961
|
|
|
22995
|
-
|
|
22996
|
-
|
|
22962
|
+
this._subscriptionsByHash[hash] = { ...subscription,
|
|
22963
|
+
state: 'pending'
|
|
22964
|
+
};
|
|
22965
|
+
await this._updateSubscriptions();
|
|
22966
|
+
}
|
|
22967
|
+
})();
|
|
22968
|
+
break;
|
|
22997
22969
|
|
|
22998
|
-
|
|
22999
|
-
|
|
22970
|
+
case 'subscribed':
|
|
22971
|
+
if (subscription.callbacks.size === 0) {
|
|
22972
|
+
// By the time we successfully set up a subscription
|
|
22973
|
+
// with the server, the client stopped caring about it.
|
|
22974
|
+
// Tear it down now.
|
|
22975
|
+
await (async () => {
|
|
22976
|
+
const {
|
|
22977
|
+
serverSubscriptionId,
|
|
22978
|
+
unsubscribeMethod
|
|
22979
|
+
} = subscription;
|
|
22980
|
+
|
|
22981
|
+
if (this._subscriptionsAutoDisposedByRpc.has(serverSubscriptionId)) {
|
|
22982
|
+
/**
|
|
22983
|
+
* Special case.
|
|
22984
|
+
* If we're dealing with a subscription that has been auto-
|
|
22985
|
+
* disposed by the RPC, then we can skip the RPC call to
|
|
22986
|
+
* tear down the subscription here.
|
|
22987
|
+
*
|
|
22988
|
+
* NOTE: There is a proposal to eliminate this special case, here:
|
|
22989
|
+
* https://github.com/solana-labs/solana/issues/18892
|
|
22990
|
+
*/
|
|
22991
|
+
this._subscriptionsAutoDisposedByRpc.delete(serverSubscriptionId);
|
|
22992
|
+
} else {
|
|
22993
|
+
this._subscriptionsByHash[hash] = { ...subscription,
|
|
22994
|
+
state: 'unsubscribing'
|
|
22995
|
+
};
|
|
22996
|
+
|
|
22997
|
+
try {
|
|
22998
|
+
await this._rpcWebSocket.call(unsubscribeMethod, [serverSubscriptionId]);
|
|
22999
|
+
} catch (e) {
|
|
23000
|
+
if (e instanceof Error) {
|
|
23001
|
+
console.error(`${unsubscribeMethod} error:`, e.message);
|
|
23002
|
+
}
|
|
23003
|
+
|
|
23004
|
+
if (!isCurrentConnectionStillActive()) {
|
|
23005
|
+
return;
|
|
23006
|
+
} // TODO: Maybe add an 'errored' state or a retry limit?
|
|
23007
|
+
|
|
23008
|
+
|
|
23009
|
+
this._subscriptionsByHash[hash] = { ...subscription,
|
|
23010
|
+
state: 'subscribed'
|
|
23011
|
+
};
|
|
23012
|
+
await this._updateSubscriptions();
|
|
23013
|
+
return;
|
|
23014
|
+
}
|
|
23015
|
+
}
|
|
23000
23016
|
|
|
23001
|
-
|
|
23002
|
-
|
|
23003
|
-
|
|
23017
|
+
this._subscriptionsByHash[hash] = { ...subscription,
|
|
23018
|
+
state: 'unsubscribed'
|
|
23019
|
+
};
|
|
23020
|
+
await this._updateSubscriptions();
|
|
23021
|
+
})();
|
|
23022
|
+
}
|
|
23004
23023
|
|
|
23005
|
-
|
|
23006
|
-
filter = {
|
|
23007
|
-
mentions: [sub.filter.toString()]
|
|
23008
|
-
};
|
|
23009
|
-
} else {
|
|
23010
|
-
filter = sub.filter;
|
|
23024
|
+
break;
|
|
23011
23025
|
}
|
|
23026
|
+
}));
|
|
23027
|
+
}
|
|
23028
|
+
/**
|
|
23029
|
+
* @internal
|
|
23030
|
+
*/
|
|
23031
|
+
|
|
23012
23032
|
|
|
23013
|
-
|
|
23033
|
+
_handleServerNotification(serverSubscriptionId, callbackArgs) {
|
|
23034
|
+
const callbacks = this._subscriptionCallbacksByServerSubscriptionId[serverSubscriptionId];
|
|
23035
|
+
|
|
23036
|
+
if (callbacks === undefined) {
|
|
23037
|
+
return;
|
|
23014
23038
|
}
|
|
23039
|
+
|
|
23040
|
+
callbacks.forEach(cb => {
|
|
23041
|
+
try {
|
|
23042
|
+
cb( // I failed to find a way to convince TypeScript that `cb` is of type
|
|
23043
|
+
// `TCallback` which is certainly compatible with `Parameters<TCallback>`.
|
|
23044
|
+
// See https://github.com/microsoft/TypeScript/issues/47615
|
|
23045
|
+
// @ts-ignore
|
|
23046
|
+
...callbackArgs);
|
|
23047
|
+
} catch (e) {
|
|
23048
|
+
console.error(e);
|
|
23049
|
+
}
|
|
23050
|
+
});
|
|
23015
23051
|
}
|
|
23016
23052
|
/**
|
|
23017
23053
|
* @internal
|
|
@@ -23019,14 +23055,71 @@ var solanaWeb3 = (function (exports) {
|
|
|
23019
23055
|
|
|
23020
23056
|
|
|
23021
23057
|
_wsOnAccountNotification(notification) {
|
|
23022
|
-
const
|
|
23058
|
+
const {
|
|
23059
|
+
result,
|
|
23060
|
+
subscription
|
|
23061
|
+
} = create(notification, AccountNotificationResult);
|
|
23023
23062
|
|
|
23024
|
-
|
|
23025
|
-
|
|
23026
|
-
|
|
23027
|
-
|
|
23028
|
-
|
|
23063
|
+
this._handleServerNotification(subscription, [result.value, result.context]);
|
|
23064
|
+
}
|
|
23065
|
+
/**
|
|
23066
|
+
* @internal
|
|
23067
|
+
*/
|
|
23068
|
+
|
|
23069
|
+
|
|
23070
|
+
_makeSubscription(subscriptionConfig,
|
|
23071
|
+
/**
|
|
23072
|
+
* When preparing `args` for a call to `_makeSubscription`, be sure
|
|
23073
|
+
* to carefully apply a default `commitment` property, if necessary.
|
|
23074
|
+
*
|
|
23075
|
+
* - If the user supplied a `commitment` use that.
|
|
23076
|
+
* - Otherwise, if the `Connection::commitment` is set, use that.
|
|
23077
|
+
* - Otherwise, set it to the RPC server default: `finalized`.
|
|
23078
|
+
*
|
|
23079
|
+
* This is extremely important to ensure that these two fundamentally
|
|
23080
|
+
* identical subscriptions produce the same identifying hash:
|
|
23081
|
+
*
|
|
23082
|
+
* - A subscription made without specifying a commitment.
|
|
23083
|
+
* - A subscription made where the commitment specified is the same
|
|
23084
|
+
* as the default applied to the subscription above.
|
|
23085
|
+
*
|
|
23086
|
+
* Example; these two subscriptions must produce the same hash:
|
|
23087
|
+
*
|
|
23088
|
+
* - An `accountSubscribe` subscription for `'PUBKEY'`
|
|
23089
|
+
* - An `accountSubscribe` subscription for `'PUBKEY'` with commitment
|
|
23090
|
+
* `'finalized'`.
|
|
23091
|
+
*
|
|
23092
|
+
* See the 'making a subscription with defaulted params omitted' test
|
|
23093
|
+
* in `connection-subscriptions.ts` for more.
|
|
23094
|
+
*/
|
|
23095
|
+
args) {
|
|
23096
|
+
const clientSubscriptionId = this._nextClientSubscriptionId++;
|
|
23097
|
+
const hash = fastStableStringify$1([subscriptionConfig.method, args], true
|
|
23098
|
+
/* isArrayProp */
|
|
23099
|
+
);
|
|
23100
|
+
const existingSubscription = this._subscriptionsByHash[hash];
|
|
23101
|
+
|
|
23102
|
+
if (existingSubscription === undefined) {
|
|
23103
|
+
this._subscriptionsByHash[hash] = { ...subscriptionConfig,
|
|
23104
|
+
args,
|
|
23105
|
+
callbacks: new Set([subscriptionConfig.callback]),
|
|
23106
|
+
state: 'pending'
|
|
23107
|
+
};
|
|
23108
|
+
} else {
|
|
23109
|
+
existingSubscription.callbacks.add(subscriptionConfig.callback);
|
|
23029
23110
|
}
|
|
23111
|
+
|
|
23112
|
+
this._subscriptionDisposeFunctionsByClientSubscriptionId[clientSubscriptionId] = async () => {
|
|
23113
|
+
delete this._subscriptionDisposeFunctionsByClientSubscriptionId[clientSubscriptionId];
|
|
23114
|
+
const subscription = this._subscriptionsByHash[hash];
|
|
23115
|
+
assert$c(subscription !== undefined, `Could not find a \`Subscription\` when tearing down client subscription #${clientSubscriptionId}`);
|
|
23116
|
+
subscription.callbacks.delete(subscriptionConfig.callback);
|
|
23117
|
+
await this._updateSubscriptions();
|
|
23118
|
+
};
|
|
23119
|
+
|
|
23120
|
+
this._updateSubscriptions();
|
|
23121
|
+
|
|
23122
|
+
return clientSubscriptionId;
|
|
23030
23123
|
}
|
|
23031
23124
|
/**
|
|
23032
23125
|
* Register a callback to be invoked whenever the specified account changes
|
|
@@ -23039,35 +23132,24 @@ var solanaWeb3 = (function (exports) {
|
|
|
23039
23132
|
|
|
23040
23133
|
|
|
23041
23134
|
onAccountChange(publicKey, callback, commitment) {
|
|
23042
|
-
const
|
|
23043
|
-
|
|
23044
|
-
publicKey: publicKey.toBase58(),
|
|
23045
|
-
callback,
|
|
23046
|
-
commitment,
|
|
23047
|
-
subscriptionId: null
|
|
23048
|
-
};
|
|
23135
|
+
const args = this._buildArgs([publicKey.toBase58()], commitment || this._commitment || 'finalized', // Apply connection/server default.
|
|
23136
|
+
'base64');
|
|
23049
23137
|
|
|
23050
|
-
this.
|
|
23051
|
-
|
|
23052
|
-
|
|
23138
|
+
return this._makeSubscription({
|
|
23139
|
+
callback,
|
|
23140
|
+
method: 'accountSubscribe',
|
|
23141
|
+
unsubscribeMethod: 'accountUnsubscribe'
|
|
23142
|
+
}, args);
|
|
23053
23143
|
}
|
|
23054
23144
|
/**
|
|
23055
23145
|
* Deregister an account notification callback
|
|
23056
23146
|
*
|
|
23057
|
-
* @param id subscription id to deregister
|
|
23147
|
+
* @param id client subscription id to deregister
|
|
23058
23148
|
*/
|
|
23059
23149
|
|
|
23060
23150
|
|
|
23061
|
-
async removeAccountChangeListener(
|
|
23062
|
-
|
|
23063
|
-
const subInfo = this._accountChangeSubscriptions[id];
|
|
23064
|
-
delete this._accountChangeSubscriptions[id];
|
|
23065
|
-
await this._unsubscribe(subInfo, 'accountUnsubscribe');
|
|
23066
|
-
|
|
23067
|
-
this._updateSubscriptions();
|
|
23068
|
-
} else {
|
|
23069
|
-
console.warn(createSubscriptionWarningMessage(id, 'account change'));
|
|
23070
|
-
}
|
|
23151
|
+
async removeAccountChangeListener(clientSubscriptionId) {
|
|
23152
|
+
await this._unsubscribeClientSubscription(clientSubscriptionId, 'account change');
|
|
23071
23153
|
}
|
|
23072
23154
|
/**
|
|
23073
23155
|
* @internal
|
|
@@ -23075,21 +23157,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
23075
23157
|
|
|
23076
23158
|
|
|
23077
23159
|
_wsOnProgramAccountNotification(notification) {
|
|
23078
|
-
const
|
|
23160
|
+
const {
|
|
23161
|
+
result,
|
|
23162
|
+
subscription
|
|
23163
|
+
} = create(notification, ProgramAccountNotificationResult);
|
|
23079
23164
|
|
|
23080
|
-
|
|
23081
|
-
|
|
23082
|
-
|
|
23083
|
-
|
|
23084
|
-
context
|
|
23085
|
-
} = res.result;
|
|
23086
|
-
sub.callback({
|
|
23087
|
-
accountId: value.pubkey,
|
|
23088
|
-
accountInfo: value.account
|
|
23089
|
-
}, context);
|
|
23090
|
-
return;
|
|
23091
|
-
}
|
|
23092
|
-
}
|
|
23165
|
+
this._handleServerNotification(subscription, [{
|
|
23166
|
+
accountId: result.value.pubkey,
|
|
23167
|
+
accountInfo: result.value.account
|
|
23168
|
+
}, result.context]);
|
|
23093
23169
|
}
|
|
23094
23170
|
/**
|
|
23095
23171
|
* Register a callback to be invoked whenever accounts owned by the
|
|
@@ -23104,36 +23180,30 @@ var solanaWeb3 = (function (exports) {
|
|
|
23104
23180
|
|
|
23105
23181
|
|
|
23106
23182
|
onProgramAccountChange(programId, callback, commitment, filters) {
|
|
23107
|
-
const
|
|
23108
|
-
|
|
23109
|
-
|
|
23110
|
-
|
|
23111
|
-
|
|
23112
|
-
|
|
23113
|
-
|
|
23114
|
-
|
|
23115
|
-
|
|
23116
|
-
this._updateSubscriptions();
|
|
23183
|
+
const args = this._buildArgs([programId.toBase58()], commitment || this._commitment || 'finalized', // Apply connection/server default.
|
|
23184
|
+
'base64'
|
|
23185
|
+
/* encoding */
|
|
23186
|
+
, filters ? {
|
|
23187
|
+
filters: filters
|
|
23188
|
+
} : undefined
|
|
23189
|
+
/* extra */
|
|
23190
|
+
);
|
|
23117
23191
|
|
|
23118
|
-
return
|
|
23192
|
+
return this._makeSubscription({
|
|
23193
|
+
callback,
|
|
23194
|
+
method: 'programSubscribe',
|
|
23195
|
+
unsubscribeMethod: 'programUnsubscribe'
|
|
23196
|
+
}, args);
|
|
23119
23197
|
}
|
|
23120
23198
|
/**
|
|
23121
23199
|
* Deregister an account notification callback
|
|
23122
23200
|
*
|
|
23123
|
-
* @param id subscription id to deregister
|
|
23201
|
+
* @param id client subscription id to deregister
|
|
23124
23202
|
*/
|
|
23125
23203
|
|
|
23126
23204
|
|
|
23127
|
-
async removeProgramAccountChangeListener(
|
|
23128
|
-
|
|
23129
|
-
const subInfo = this._programAccountChangeSubscriptions[id];
|
|
23130
|
-
delete this._programAccountChangeSubscriptions[id];
|
|
23131
|
-
await this._unsubscribe(subInfo, 'programUnsubscribe');
|
|
23132
|
-
|
|
23133
|
-
this._updateSubscriptions();
|
|
23134
|
-
} else {
|
|
23135
|
-
console.warn(createSubscriptionWarningMessage(id, 'program account change'));
|
|
23136
|
-
}
|
|
23205
|
+
async removeProgramAccountChangeListener(clientSubscriptionId) {
|
|
23206
|
+
await this._unsubscribeClientSubscription(clientSubscriptionId, 'program account change');
|
|
23137
23207
|
}
|
|
23138
23208
|
/**
|
|
23139
23209
|
* Registers a callback to be invoked whenever logs are emitted.
|
|
@@ -23141,35 +23211,26 @@ var solanaWeb3 = (function (exports) {
|
|
|
23141
23211
|
|
|
23142
23212
|
|
|
23143
23213
|
onLogs(filter, callback, commitment) {
|
|
23144
|
-
const
|
|
23145
|
-
|
|
23146
|
-
|
|
23147
|
-
|
|
23148
|
-
commitment,
|
|
23149
|
-
subscriptionId: null
|
|
23150
|
-
};
|
|
23151
|
-
|
|
23152
|
-
this._updateSubscriptions();
|
|
23214
|
+
const args = this._buildArgs([typeof filter === 'object' ? {
|
|
23215
|
+
mentions: [filter.toString()]
|
|
23216
|
+
} : filter], commitment || this._commitment || 'finalized' // Apply connection/server default.
|
|
23217
|
+
);
|
|
23153
23218
|
|
|
23154
|
-
return
|
|
23219
|
+
return this._makeSubscription({
|
|
23220
|
+
callback,
|
|
23221
|
+
method: 'logsSubscribe',
|
|
23222
|
+
unsubscribeMethod: 'logsUnsubscribe'
|
|
23223
|
+
}, args);
|
|
23155
23224
|
}
|
|
23156
23225
|
/**
|
|
23157
23226
|
* Deregister a logs callback.
|
|
23158
23227
|
*
|
|
23159
|
-
* @param id subscription id to deregister.
|
|
23228
|
+
* @param id client subscription id to deregister.
|
|
23160
23229
|
*/
|
|
23161
23230
|
|
|
23162
23231
|
|
|
23163
|
-
async removeOnLogsListener(
|
|
23164
|
-
|
|
23165
|
-
const subInfo = this._logsSubscriptions[id];
|
|
23166
|
-
delete this._logsSubscriptions[id];
|
|
23167
|
-
await this._unsubscribe(subInfo, 'logsUnsubscribe');
|
|
23168
|
-
|
|
23169
|
-
this._updateSubscriptions();
|
|
23170
|
-
} else {
|
|
23171
|
-
console.warn(createSubscriptionWarningMessage(id, 'logs'));
|
|
23172
|
-
}
|
|
23232
|
+
async removeOnLogsListener(clientSubscriptionId) {
|
|
23233
|
+
await this._unsubscribeClientSubscription(clientSubscriptionId, 'logs');
|
|
23173
23234
|
}
|
|
23174
23235
|
/**
|
|
23175
23236
|
* @internal
|
|
@@ -23177,17 +23238,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
23177
23238
|
|
|
23178
23239
|
|
|
23179
23240
|
_wsOnLogsNotification(notification) {
|
|
23180
|
-
const
|
|
23181
|
-
|
|
23182
|
-
|
|
23183
|
-
|
|
23184
|
-
const sub = this._logsSubscriptions[id];
|
|
23241
|
+
const {
|
|
23242
|
+
result,
|
|
23243
|
+
subscription
|
|
23244
|
+
} = create(notification, LogsNotificationResult);
|
|
23185
23245
|
|
|
23186
|
-
|
|
23187
|
-
sub.callback(res.result.value, res.result.context);
|
|
23188
|
-
return;
|
|
23189
|
-
}
|
|
23190
|
-
}
|
|
23246
|
+
this._handleServerNotification(subscription, [result.value, result.context]);
|
|
23191
23247
|
}
|
|
23192
23248
|
/**
|
|
23193
23249
|
* @internal
|
|
@@ -23195,14 +23251,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
23195
23251
|
|
|
23196
23252
|
|
|
23197
23253
|
_wsOnSlotNotification(notification) {
|
|
23198
|
-
const
|
|
23254
|
+
const {
|
|
23255
|
+
result,
|
|
23256
|
+
subscription
|
|
23257
|
+
} = create(notification, SlotNotificationResult);
|
|
23199
23258
|
|
|
23200
|
-
|
|
23201
|
-
if (sub.subscriptionId === res.subscription) {
|
|
23202
|
-
sub.callback(res.result);
|
|
23203
|
-
return;
|
|
23204
|
-
}
|
|
23205
|
-
}
|
|
23259
|
+
this._handleServerNotification(subscription, [result]);
|
|
23206
23260
|
}
|
|
23207
23261
|
/**
|
|
23208
23262
|
* Register a callback to be invoked upon slot changes
|
|
@@ -23213,33 +23267,23 @@ var solanaWeb3 = (function (exports) {
|
|
|
23213
23267
|
|
|
23214
23268
|
|
|
23215
23269
|
onSlotChange(callback) {
|
|
23216
|
-
|
|
23217
|
-
this._slotSubscriptions[id] = {
|
|
23270
|
+
return this._makeSubscription({
|
|
23218
23271
|
callback,
|
|
23219
|
-
|
|
23220
|
-
|
|
23221
|
-
|
|
23222
|
-
|
|
23223
|
-
|
|
23224
|
-
return id;
|
|
23272
|
+
method: 'slotSubscribe',
|
|
23273
|
+
unsubscribeMethod: 'slotUnsubscribe'
|
|
23274
|
+
}, []
|
|
23275
|
+
/* args */
|
|
23276
|
+
);
|
|
23225
23277
|
}
|
|
23226
23278
|
/**
|
|
23227
23279
|
* Deregister a slot notification callback
|
|
23228
23280
|
*
|
|
23229
|
-
* @param id subscription id to deregister
|
|
23281
|
+
* @param id client subscription id to deregister
|
|
23230
23282
|
*/
|
|
23231
23283
|
|
|
23232
23284
|
|
|
23233
|
-
async removeSlotChangeListener(
|
|
23234
|
-
|
|
23235
|
-
const subInfo = this._slotSubscriptions[id];
|
|
23236
|
-
delete this._slotSubscriptions[id];
|
|
23237
|
-
await this._unsubscribe(subInfo, 'slotUnsubscribe');
|
|
23238
|
-
|
|
23239
|
-
this._updateSubscriptions();
|
|
23240
|
-
} else {
|
|
23241
|
-
console.warn(createSubscriptionWarningMessage(id, 'slot change'));
|
|
23242
|
-
}
|
|
23285
|
+
async removeSlotChangeListener(clientSubscriptionId) {
|
|
23286
|
+
await this._unsubscribeClientSubscription(clientSubscriptionId, 'slot change');
|
|
23243
23287
|
}
|
|
23244
23288
|
/**
|
|
23245
23289
|
* @internal
|
|
@@ -23247,14 +23291,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
23247
23291
|
|
|
23248
23292
|
|
|
23249
23293
|
_wsOnSlotUpdatesNotification(notification) {
|
|
23250
|
-
const
|
|
23294
|
+
const {
|
|
23295
|
+
result,
|
|
23296
|
+
subscription
|
|
23297
|
+
} = create(notification, SlotUpdateNotificationResult);
|
|
23251
23298
|
|
|
23252
|
-
|
|
23253
|
-
if (sub.subscriptionId === res.subscription) {
|
|
23254
|
-
sub.callback(res.result);
|
|
23255
|
-
return;
|
|
23256
|
-
}
|
|
23257
|
-
}
|
|
23299
|
+
this._handleServerNotification(subscription, [result]);
|
|
23258
23300
|
}
|
|
23259
23301
|
/**
|
|
23260
23302
|
* Register a callback to be invoked upon slot updates. {@link SlotUpdate}'s
|
|
@@ -23266,32 +23308,36 @@ var solanaWeb3 = (function (exports) {
|
|
|
23266
23308
|
|
|
23267
23309
|
|
|
23268
23310
|
onSlotUpdate(callback) {
|
|
23269
|
-
|
|
23270
|
-
this._slotUpdateSubscriptions[id] = {
|
|
23311
|
+
return this._makeSubscription({
|
|
23271
23312
|
callback,
|
|
23272
|
-
|
|
23273
|
-
|
|
23274
|
-
|
|
23275
|
-
|
|
23276
|
-
|
|
23277
|
-
return id;
|
|
23313
|
+
method: 'slotsUpdatesSubscribe',
|
|
23314
|
+
unsubscribeMethod: 'slotsUpdatesUnsubscribe'
|
|
23315
|
+
}, []
|
|
23316
|
+
/* args */
|
|
23317
|
+
);
|
|
23278
23318
|
}
|
|
23279
23319
|
/**
|
|
23280
23320
|
* Deregister a slot update notification callback
|
|
23281
23321
|
*
|
|
23282
|
-
* @param id subscription id to deregister
|
|
23322
|
+
* @param id client subscription id to deregister
|
|
23283
23323
|
*/
|
|
23284
23324
|
|
|
23285
23325
|
|
|
23286
|
-
async removeSlotUpdateListener(
|
|
23287
|
-
|
|
23288
|
-
|
|
23289
|
-
|
|
23290
|
-
|
|
23326
|
+
async removeSlotUpdateListener(clientSubscriptionId) {
|
|
23327
|
+
await this._unsubscribeClientSubscription(clientSubscriptionId, 'slot update');
|
|
23328
|
+
}
|
|
23329
|
+
/**
|
|
23330
|
+
* @internal
|
|
23331
|
+
*/
|
|
23291
23332
|
|
|
23292
|
-
|
|
23333
|
+
|
|
23334
|
+
async _unsubscribeClientSubscription(clientSubscriptionId, subscriptionName) {
|
|
23335
|
+
const dispose = this._subscriptionDisposeFunctionsByClientSubscriptionId[clientSubscriptionId];
|
|
23336
|
+
|
|
23337
|
+
if (dispose) {
|
|
23338
|
+
await dispose();
|
|
23293
23339
|
} else {
|
|
23294
|
-
console.warn(
|
|
23340
|
+
console.warn('Ignored unsubscribe request because an active subscription with id ' + `\`${clientSubscriptionId}\` for '${subscriptionName}' events ` + 'could not be found.');
|
|
23295
23341
|
}
|
|
23296
23342
|
}
|
|
23297
23343
|
|
|
@@ -23338,30 +23384,34 @@ var solanaWeb3 = (function (exports) {
|
|
|
23338
23384
|
|
|
23339
23385
|
|
|
23340
23386
|
_wsOnSignatureNotification(notification) {
|
|
23341
|
-
const
|
|
23342
|
-
|
|
23343
|
-
|
|
23344
|
-
|
|
23345
|
-
|
|
23346
|
-
|
|
23347
|
-
|
|
23348
|
-
|
|
23349
|
-
|
|
23350
|
-
|
|
23351
|
-
|
|
23352
|
-
|
|
23353
|
-
|
|
23354
|
-
|
|
23355
|
-
|
|
23356
|
-
|
|
23357
|
-
|
|
23358
|
-
|
|
23359
|
-
|
|
23360
|
-
|
|
23361
|
-
|
|
23362
|
-
|
|
23363
|
-
|
|
23364
|
-
|
|
23387
|
+
const {
|
|
23388
|
+
result,
|
|
23389
|
+
subscription
|
|
23390
|
+
} = create(notification, SignatureNotificationResult);
|
|
23391
|
+
|
|
23392
|
+
if (result.value !== 'receivedSignature') {
|
|
23393
|
+
/**
|
|
23394
|
+
* Special case.
|
|
23395
|
+
* After a signature is processed, RPCs automatically dispose of the
|
|
23396
|
+
* subscription on the server side. We need to track which of these
|
|
23397
|
+
* subscriptions have been disposed in such a way, so that we know
|
|
23398
|
+
* whether the client is dealing with a not-yet-processed signature
|
|
23399
|
+
* (in which case we must tear down the server subscription) or an
|
|
23400
|
+
* already-processed signature (in which case the client can simply
|
|
23401
|
+
* clear out the subscription locally without telling the server).
|
|
23402
|
+
*
|
|
23403
|
+
* NOTE: There is a proposal to eliminate this special case, here:
|
|
23404
|
+
* https://github.com/solana-labs/solana/issues/18892
|
|
23405
|
+
*/
|
|
23406
|
+
this._subscriptionsAutoDisposedByRpc.add(subscription);
|
|
23407
|
+
}
|
|
23408
|
+
|
|
23409
|
+
this._handleServerNotification(subscription, result.value === 'receivedSignature' ? [{
|
|
23410
|
+
type: 'received'
|
|
23411
|
+
}, result.context] : [{
|
|
23412
|
+
type: 'status',
|
|
23413
|
+
result: result.value
|
|
23414
|
+
}, result.context]);
|
|
23365
23415
|
}
|
|
23366
23416
|
/**
|
|
23367
23417
|
* Register a callback to be invoked upon signature updates
|
|
@@ -23374,23 +23424,26 @@ var solanaWeb3 = (function (exports) {
|
|
|
23374
23424
|
|
|
23375
23425
|
|
|
23376
23426
|
onSignature(signature, callback, commitment) {
|
|
23377
|
-
const
|
|
23378
|
-
|
|
23379
|
-
|
|
23427
|
+
const args = this._buildArgs([signature], commitment || this._commitment || 'finalized' // Apply connection/server default.
|
|
23428
|
+
);
|
|
23429
|
+
|
|
23430
|
+
const clientSubscriptionId = this._makeSubscription({
|
|
23380
23431
|
callback: (notification, context) => {
|
|
23381
23432
|
if (notification.type === 'status') {
|
|
23382
|
-
callback(notification.result, context);
|
|
23433
|
+
callback(notification.result, context); // Signatures subscriptions are auto-removed by the RPC service
|
|
23434
|
+
// so no need to explicitly send an unsubscribe message.
|
|
23435
|
+
|
|
23436
|
+
try {
|
|
23437
|
+
this.removeSignatureListener(clientSubscriptionId); // eslint-disable-next-line no-empty
|
|
23438
|
+
} catch {// Already removed.
|
|
23439
|
+
}
|
|
23383
23440
|
}
|
|
23384
23441
|
},
|
|
23385
|
-
|
|
23386
|
-
|
|
23387
|
-
|
|
23388
|
-
subscriptionId: null
|
|
23389
|
-
};
|
|
23442
|
+
method: 'signatureSubscribe',
|
|
23443
|
+
unsubscribeMethod: 'signatureUnsubscribe'
|
|
23444
|
+
}, args);
|
|
23390
23445
|
|
|
23391
|
-
|
|
23392
|
-
|
|
23393
|
-
return id;
|
|
23446
|
+
return clientSubscriptionId;
|
|
23394
23447
|
}
|
|
23395
23448
|
/**
|
|
23396
23449
|
* Register a callback to be invoked when a transaction is
|
|
@@ -23405,35 +23458,43 @@ var solanaWeb3 = (function (exports) {
|
|
|
23405
23458
|
|
|
23406
23459
|
|
|
23407
23460
|
onSignatureWithOptions(signature, callback, options) {
|
|
23408
|
-
const
|
|
23409
|
-
|
|
23410
|
-
|
|
23411
|
-
|
|
23412
|
-
options
|
|
23413
|
-
|
|
23461
|
+
const {
|
|
23462
|
+
commitment,
|
|
23463
|
+
...extra
|
|
23464
|
+
} = { ...options,
|
|
23465
|
+
commitment: options && options.commitment || this._commitment || 'finalized' // Apply connection/server default.
|
|
23466
|
+
|
|
23414
23467
|
};
|
|
23415
23468
|
|
|
23416
|
-
this.
|
|
23469
|
+
const args = this._buildArgs([signature], commitment, undefined
|
|
23470
|
+
/* encoding */
|
|
23471
|
+
, extra);
|
|
23472
|
+
|
|
23473
|
+
const clientSubscriptionId = this._makeSubscription({
|
|
23474
|
+
callback: (notification, context) => {
|
|
23475
|
+
callback(notification, context); // Signatures subscriptions are auto-removed by the RPC service
|
|
23476
|
+
// so no need to explicitly send an unsubscribe message.
|
|
23417
23477
|
|
|
23418
|
-
|
|
23478
|
+
try {
|
|
23479
|
+
this.removeSignatureListener(clientSubscriptionId); // eslint-disable-next-line no-empty
|
|
23480
|
+
} catch {// Already removed.
|
|
23481
|
+
}
|
|
23482
|
+
},
|
|
23483
|
+
method: 'signatureSubscribe',
|
|
23484
|
+
unsubscribeMethod: 'signatureUnsubscribe'
|
|
23485
|
+
}, args);
|
|
23486
|
+
|
|
23487
|
+
return clientSubscriptionId;
|
|
23419
23488
|
}
|
|
23420
23489
|
/**
|
|
23421
23490
|
* Deregister a signature notification callback
|
|
23422
23491
|
*
|
|
23423
|
-
* @param id subscription id to deregister
|
|
23492
|
+
* @param id client subscription id to deregister
|
|
23424
23493
|
*/
|
|
23425
23494
|
|
|
23426
23495
|
|
|
23427
|
-
async removeSignatureListener(
|
|
23428
|
-
|
|
23429
|
-
const subInfo = this._signatureSubscriptions[id];
|
|
23430
|
-
delete this._signatureSubscriptions[id];
|
|
23431
|
-
await this._unsubscribe(subInfo, 'signatureUnsubscribe');
|
|
23432
|
-
|
|
23433
|
-
this._updateSubscriptions();
|
|
23434
|
-
} else {
|
|
23435
|
-
console.warn(createSubscriptionWarningMessage(id, 'signature result'));
|
|
23436
|
-
}
|
|
23496
|
+
async removeSignatureListener(clientSubscriptionId) {
|
|
23497
|
+
await this._unsubscribeClientSubscription(clientSubscriptionId, 'signature result');
|
|
23437
23498
|
}
|
|
23438
23499
|
/**
|
|
23439
23500
|
* @internal
|
|
@@ -23441,14 +23502,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
23441
23502
|
|
|
23442
23503
|
|
|
23443
23504
|
_wsOnRootNotification(notification) {
|
|
23444
|
-
const
|
|
23505
|
+
const {
|
|
23506
|
+
result,
|
|
23507
|
+
subscription
|
|
23508
|
+
} = create(notification, RootNotificationResult);
|
|
23445
23509
|
|
|
23446
|
-
|
|
23447
|
-
if (sub.subscriptionId === res.subscription) {
|
|
23448
|
-
sub.callback(res.result);
|
|
23449
|
-
return;
|
|
23450
|
-
}
|
|
23451
|
-
}
|
|
23510
|
+
this._handleServerNotification(subscription, [result]);
|
|
23452
23511
|
}
|
|
23453
23512
|
/**
|
|
23454
23513
|
* Register a callback to be invoked upon root changes
|
|
@@ -23459,33 +23518,23 @@ var solanaWeb3 = (function (exports) {
|
|
|
23459
23518
|
|
|
23460
23519
|
|
|
23461
23520
|
onRootChange(callback) {
|
|
23462
|
-
|
|
23463
|
-
this._rootSubscriptions[id] = {
|
|
23521
|
+
return this._makeSubscription({
|
|
23464
23522
|
callback,
|
|
23465
|
-
|
|
23466
|
-
|
|
23467
|
-
|
|
23468
|
-
|
|
23469
|
-
|
|
23470
|
-
return id;
|
|
23523
|
+
method: 'rootSubscribe',
|
|
23524
|
+
unsubscribeMethod: 'rootUnsubscribe'
|
|
23525
|
+
}, []
|
|
23526
|
+
/* args */
|
|
23527
|
+
);
|
|
23471
23528
|
}
|
|
23472
23529
|
/**
|
|
23473
23530
|
* Deregister a root notification callback
|
|
23474
23531
|
*
|
|
23475
|
-
* @param id subscription id to deregister
|
|
23532
|
+
* @param id client subscription id to deregister
|
|
23476
23533
|
*/
|
|
23477
23534
|
|
|
23478
23535
|
|
|
23479
|
-
async removeRootChangeListener(
|
|
23480
|
-
|
|
23481
|
-
const subInfo = this._rootSubscriptions[id];
|
|
23482
|
-
delete this._rootSubscriptions[id];
|
|
23483
|
-
await this._unsubscribe(subInfo, 'rootUnsubscribe');
|
|
23484
|
-
|
|
23485
|
-
this._updateSubscriptions();
|
|
23486
|
-
} else {
|
|
23487
|
-
console.warn(createSubscriptionWarningMessage(id, 'root change'));
|
|
23488
|
-
}
|
|
23536
|
+
async removeRootChangeListener(clientSubscriptionId) {
|
|
23537
|
+
await this._unsubscribeClientSubscription(clientSubscriptionId, 'root change');
|
|
23489
23538
|
}
|
|
23490
23539
|
|
|
23491
23540
|
}
|
|
@@ -29975,6 +30024,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
29975
30024
|
exports.BPF_LOADER_DEPRECATED_PROGRAM_ID = BPF_LOADER_DEPRECATED_PROGRAM_ID;
|
|
29976
30025
|
exports.BPF_LOADER_PROGRAM_ID = BPF_LOADER_PROGRAM_ID;
|
|
29977
30026
|
exports.BpfLoader = BpfLoader;
|
|
30027
|
+
exports.COMPUTE_BUDGET_INSTRUCTION_LAYOUTS = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS;
|
|
30028
|
+
exports.ComputeBudgetInstruction = ComputeBudgetInstruction;
|
|
30029
|
+
exports.ComputeBudgetProgram = ComputeBudgetProgram;
|
|
29978
30030
|
exports.Connection = Connection;
|
|
29979
30031
|
exports.Ed25519Program = Ed25519Program;
|
|
29980
30032
|
exports.Enum = Enum;
|
|
@@ -29988,7 +30040,6 @@ var solanaWeb3 = (function (exports) {
|
|
|
29988
30040
|
exports.Message = Message;
|
|
29989
30041
|
exports.NONCE_ACCOUNT_LENGTH = NONCE_ACCOUNT_LENGTH;
|
|
29990
30042
|
exports.NonceAccount = NonceAccount;
|
|
29991
|
-
exports.PACKET_DATA_SIZE = PACKET_DATA_SIZE;
|
|
29992
30043
|
exports.PublicKey = PublicKey;
|
|
29993
30044
|
exports.SOLANA_SCHEMA = SOLANA_SCHEMA;
|
|
29994
30045
|
exports.STAKE_CONFIG_ID = STAKE_CONFIG_ID;
|