@solana/web3.js 1.66.2 → 1.66.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -4
- package/lib/index.browser.cjs.js +134 -21
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +134 -21
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +134 -21
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +4 -2
- package/lib/index.esm.js +134 -21
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +134 -21
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +1 -1
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +134 -21
- package/lib/index.native.js.map +1 -1
- package/package.json +1 -2
- package/src/bpf-loader.ts +2 -2
- package/src/connection.ts +134 -19
package/lib/index.iife.js
CHANGED
|
@@ -13775,12 +13775,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
13775
13775
|
return Loader.getMinNumSignatures(dataLength);
|
|
13776
13776
|
}
|
|
13777
13777
|
/**
|
|
13778
|
-
* Load a
|
|
13778
|
+
* Load a SBF program
|
|
13779
13779
|
*
|
|
13780
13780
|
* @param connection The connection to use
|
|
13781
13781
|
* @param payer Account that will pay program loading fees
|
|
13782
13782
|
* @param program Account to load the program into
|
|
13783
|
-
* @param elf The entire ELF containing the
|
|
13783
|
+
* @param elf The entire ELF containing the SBF program
|
|
13784
13784
|
* @param loaderProgramId The program id of the BPF loader to use
|
|
13785
13785
|
* @return true if program was loaded successfully, false if program was already loaded
|
|
13786
13786
|
*/
|
|
@@ -18258,6 +18258,10 @@ var solanaWeb3 = (function (exports) {
|
|
|
18258
18258
|
|
|
18259
18259
|
/** @internal */
|
|
18260
18260
|
|
|
18261
|
+
/** @internal */
|
|
18262
|
+
|
|
18263
|
+
/** @internal */
|
|
18264
|
+
|
|
18261
18265
|
/**
|
|
18262
18266
|
* Special case.
|
|
18263
18267
|
* After a signature is processed, RPCs automatically dispose of the
|
|
@@ -18303,6 +18307,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
18303
18307
|
};
|
|
18304
18308
|
this._nextClientSubscriptionId = 0;
|
|
18305
18309
|
this._subscriptionDisposeFunctionsByClientSubscriptionId = {};
|
|
18310
|
+
this._subscriptionHashByClientSubscriptionId = {};
|
|
18311
|
+
this._subscriptionStateChangeCallbacksByHash = {};
|
|
18306
18312
|
this._subscriptionCallbacksByServerSubscriptionId = {};
|
|
18307
18313
|
this._subscriptionsByHash = {};
|
|
18308
18314
|
this._subscriptionsAutoDisposedByRpc = new Set();
|
|
@@ -18832,12 +18838,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
18832
18838
|
assert$1(decodedSignature.length === 64, 'signature has invalid length');
|
|
18833
18839
|
const subscriptionCommitment = commitment || this.commitment;
|
|
18834
18840
|
let timeoutId;
|
|
18835
|
-
let
|
|
18841
|
+
let signatureSubscriptionId;
|
|
18842
|
+
let disposeSignatureSubscriptionStateChangeObserver;
|
|
18836
18843
|
let done = false;
|
|
18837
18844
|
const confirmationPromise = new Promise((resolve, reject) => {
|
|
18838
18845
|
try {
|
|
18839
|
-
|
|
18840
|
-
|
|
18846
|
+
signatureSubscriptionId = this.onSignature(rawSignature, (result, context) => {
|
|
18847
|
+
signatureSubscriptionId = undefined;
|
|
18841
18848
|
const response = {
|
|
18842
18849
|
context,
|
|
18843
18850
|
value: result
|
|
@@ -18848,6 +18855,48 @@ var solanaWeb3 = (function (exports) {
|
|
|
18848
18855
|
response
|
|
18849
18856
|
});
|
|
18850
18857
|
}, subscriptionCommitment);
|
|
18858
|
+
const subscriptionSetupPromise = new Promise(resolveSubscriptionSetup => {
|
|
18859
|
+
if (signatureSubscriptionId == null) {
|
|
18860
|
+
resolveSubscriptionSetup();
|
|
18861
|
+
} else {
|
|
18862
|
+
disposeSignatureSubscriptionStateChangeObserver = this._onSubscriptionStateChange(signatureSubscriptionId, nextState => {
|
|
18863
|
+
if (nextState === 'subscribed') {
|
|
18864
|
+
resolveSubscriptionSetup();
|
|
18865
|
+
}
|
|
18866
|
+
});
|
|
18867
|
+
}
|
|
18868
|
+
});
|
|
18869
|
+
|
|
18870
|
+
(async () => {
|
|
18871
|
+
await subscriptionSetupPromise;
|
|
18872
|
+
if (done) return;
|
|
18873
|
+
const response = await this.getSignatureStatus(rawSignature);
|
|
18874
|
+
if (done) return;
|
|
18875
|
+
|
|
18876
|
+
if (response == null) {
|
|
18877
|
+
return;
|
|
18878
|
+
}
|
|
18879
|
+
|
|
18880
|
+
const {
|
|
18881
|
+
context,
|
|
18882
|
+
value
|
|
18883
|
+
} = response;
|
|
18884
|
+
|
|
18885
|
+
if (value !== null && value !== void 0 && value.err) {
|
|
18886
|
+
reject(value.err);
|
|
18887
|
+
}
|
|
18888
|
+
|
|
18889
|
+
if (value) {
|
|
18890
|
+
done = true;
|
|
18891
|
+
resolve({
|
|
18892
|
+
__type: exports.TransactionStatus.PROCESSED,
|
|
18893
|
+
response: {
|
|
18894
|
+
context,
|
|
18895
|
+
value
|
|
18896
|
+
}
|
|
18897
|
+
});
|
|
18898
|
+
}
|
|
18899
|
+
})();
|
|
18851
18900
|
} catch (err) {
|
|
18852
18901
|
reject(err);
|
|
18853
18902
|
}
|
|
@@ -18920,8 +18969,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
18920
18969
|
} finally {
|
|
18921
18970
|
clearTimeout(timeoutId);
|
|
18922
18971
|
|
|
18923
|
-
if (
|
|
18924
|
-
|
|
18972
|
+
if (disposeSignatureSubscriptionStateChangeObserver) {
|
|
18973
|
+
disposeSignatureSubscriptionStateChangeObserver();
|
|
18974
|
+
}
|
|
18975
|
+
|
|
18976
|
+
if (signatureSubscriptionId) {
|
|
18977
|
+
this.removeSignatureListener(signatureSubscriptionId);
|
|
18925
18978
|
}
|
|
18926
18979
|
}
|
|
18927
18980
|
|
|
@@ -20423,9 +20476,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
20423
20476
|
|
|
20424
20477
|
this._subscriptionCallbacksByServerSubscriptionId = {};
|
|
20425
20478
|
Object.entries(this._subscriptionsByHash).forEach(([hash, subscription]) => {
|
|
20426
|
-
this.
|
|
20479
|
+
this._setSubscription(hash, { ...subscription,
|
|
20427
20480
|
state: 'pending'
|
|
20428
|
-
};
|
|
20481
|
+
});
|
|
20429
20482
|
});
|
|
20430
20483
|
}
|
|
20431
20484
|
/**
|
|
@@ -20433,6 +20486,53 @@ var solanaWeb3 = (function (exports) {
|
|
|
20433
20486
|
*/
|
|
20434
20487
|
|
|
20435
20488
|
|
|
20489
|
+
_setSubscription(hash, nextSubscription) {
|
|
20490
|
+
var _this$_subscriptionsB;
|
|
20491
|
+
|
|
20492
|
+
const prevState = (_this$_subscriptionsB = this._subscriptionsByHash[hash]) === null || _this$_subscriptionsB === void 0 ? void 0 : _this$_subscriptionsB.state;
|
|
20493
|
+
this._subscriptionsByHash[hash] = nextSubscription;
|
|
20494
|
+
|
|
20495
|
+
if (prevState !== nextSubscription.state) {
|
|
20496
|
+
const stateChangeCallbacks = this._subscriptionStateChangeCallbacksByHash[hash];
|
|
20497
|
+
|
|
20498
|
+
if (stateChangeCallbacks) {
|
|
20499
|
+
stateChangeCallbacks.forEach(cb => {
|
|
20500
|
+
try {
|
|
20501
|
+
cb(nextSubscription.state); // eslint-disable-next-line no-empty
|
|
20502
|
+
} catch {}
|
|
20503
|
+
});
|
|
20504
|
+
}
|
|
20505
|
+
}
|
|
20506
|
+
}
|
|
20507
|
+
/**
|
|
20508
|
+
* @internal
|
|
20509
|
+
*/
|
|
20510
|
+
|
|
20511
|
+
|
|
20512
|
+
_onSubscriptionStateChange(clientSubscriptionId, callback) {
|
|
20513
|
+
var _this$_subscriptionSt;
|
|
20514
|
+
|
|
20515
|
+
const hash = this._subscriptionHashByClientSubscriptionId[clientSubscriptionId];
|
|
20516
|
+
|
|
20517
|
+
if (hash == null) {
|
|
20518
|
+
return () => {};
|
|
20519
|
+
}
|
|
20520
|
+
|
|
20521
|
+
const stateChangeCallbacks = (_this$_subscriptionSt = this._subscriptionStateChangeCallbacksByHash)[hash] || (_this$_subscriptionSt[hash] = new Set());
|
|
20522
|
+
stateChangeCallbacks.add(callback);
|
|
20523
|
+
return () => {
|
|
20524
|
+
stateChangeCallbacks.delete(callback);
|
|
20525
|
+
|
|
20526
|
+
if (stateChangeCallbacks.size === 0) {
|
|
20527
|
+
delete this._subscriptionStateChangeCallbacksByHash[hash];
|
|
20528
|
+
}
|
|
20529
|
+
};
|
|
20530
|
+
}
|
|
20531
|
+
/**
|
|
20532
|
+
* @internal
|
|
20533
|
+
*/
|
|
20534
|
+
|
|
20535
|
+
|
|
20436
20536
|
async _updateSubscriptions() {
|
|
20437
20537
|
if (Object.keys(this._subscriptionsByHash).length === 0) {
|
|
20438
20538
|
if (this._rpcWebSocketConnected) {
|
|
@@ -20518,14 +20618,17 @@ var solanaWeb3 = (function (exports) {
|
|
|
20518
20618
|
} = subscription;
|
|
20519
20619
|
|
|
20520
20620
|
try {
|
|
20521
|
-
this.
|
|
20621
|
+
this._setSubscription(hash, { ...subscription,
|
|
20522
20622
|
state: 'subscribing'
|
|
20523
|
-
};
|
|
20623
|
+
});
|
|
20624
|
+
|
|
20524
20625
|
const serverSubscriptionId = await this._rpcWebSocket.call(method, args);
|
|
20525
|
-
|
|
20626
|
+
|
|
20627
|
+
this._setSubscription(hash, { ...subscription,
|
|
20526
20628
|
serverSubscriptionId,
|
|
20527
20629
|
state: 'subscribed'
|
|
20528
|
-
};
|
|
20630
|
+
});
|
|
20631
|
+
|
|
20529
20632
|
this._subscriptionCallbacksByServerSubscriptionId[serverSubscriptionId] = subscription.callbacks;
|
|
20530
20633
|
await this._updateSubscriptions();
|
|
20531
20634
|
} catch (e) {
|
|
@@ -20538,9 +20641,10 @@ var solanaWeb3 = (function (exports) {
|
|
|
20538
20641
|
} // TODO: Maybe add an 'errored' state or a retry limit?
|
|
20539
20642
|
|
|
20540
20643
|
|
|
20541
|
-
this.
|
|
20644
|
+
this._setSubscription(hash, { ...subscription,
|
|
20542
20645
|
state: 'pending'
|
|
20543
|
-
};
|
|
20646
|
+
});
|
|
20647
|
+
|
|
20544
20648
|
await this._updateSubscriptions();
|
|
20545
20649
|
}
|
|
20546
20650
|
})();
|
|
@@ -20569,9 +20673,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
20569
20673
|
*/
|
|
20570
20674
|
this._subscriptionsAutoDisposedByRpc.delete(serverSubscriptionId);
|
|
20571
20675
|
} else {
|
|
20572
|
-
this.
|
|
20676
|
+
this._setSubscription(hash, { ...subscription,
|
|
20573
20677
|
state: 'unsubscribing'
|
|
20574
|
-
};
|
|
20678
|
+
});
|
|
20679
|
+
|
|
20680
|
+
this._setSubscription(hash, { ...subscription,
|
|
20681
|
+
state: 'unsubscribing'
|
|
20682
|
+
});
|
|
20575
20683
|
|
|
20576
20684
|
try {
|
|
20577
20685
|
await this._rpcWebSocket.call(unsubscribeMethod, [serverSubscriptionId]);
|
|
@@ -20585,17 +20693,19 @@ var solanaWeb3 = (function (exports) {
|
|
|
20585
20693
|
} // TODO: Maybe add an 'errored' state or a retry limit?
|
|
20586
20694
|
|
|
20587
20695
|
|
|
20588
|
-
this.
|
|
20696
|
+
this._setSubscription(hash, { ...subscription,
|
|
20589
20697
|
state: 'subscribed'
|
|
20590
|
-
};
|
|
20698
|
+
});
|
|
20699
|
+
|
|
20591
20700
|
await this._updateSubscriptions();
|
|
20592
20701
|
return;
|
|
20593
20702
|
}
|
|
20594
20703
|
}
|
|
20595
20704
|
|
|
20596
|
-
this.
|
|
20705
|
+
this._setSubscription(hash, { ...subscription,
|
|
20597
20706
|
state: 'unsubscribed'
|
|
20598
|
-
};
|
|
20707
|
+
});
|
|
20708
|
+
|
|
20599
20709
|
await this._updateSubscriptions();
|
|
20600
20710
|
})();
|
|
20601
20711
|
}
|
|
@@ -20688,8 +20798,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
20688
20798
|
existingSubscription.callbacks.add(subscriptionConfig.callback);
|
|
20689
20799
|
}
|
|
20690
20800
|
|
|
20801
|
+
this._subscriptionHashByClientSubscriptionId[clientSubscriptionId] = hash;
|
|
20802
|
+
|
|
20691
20803
|
this._subscriptionDisposeFunctionsByClientSubscriptionId[clientSubscriptionId] = async () => {
|
|
20692
20804
|
delete this._subscriptionDisposeFunctionsByClientSubscriptionId[clientSubscriptionId];
|
|
20805
|
+
delete this._subscriptionHashByClientSubscriptionId[clientSubscriptionId];
|
|
20693
20806
|
const subscription = this._subscriptionsByHash[hash];
|
|
20694
20807
|
assert$1(subscription !== undefined, `Could not find a \`Subscription\` when tearing down client subscription #${clientSubscriptionId}`);
|
|
20695
20808
|
subscription.callbacks.delete(subscriptionConfig.callback);
|