@0xsequence/provider 0.0.0-20240123145607 → 0.0.0-20240123153410
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.
|
@@ -32,7 +32,9 @@ function isProviderTransport(transport) {
|
|
|
32
32
|
// ProviderMessageCallback is used to respond to ProviderMessage requests. The error
|
|
33
33
|
// argument is for exceptions during the execution, and response is the response payload
|
|
34
34
|
// which may contain the result or an error payload from the wallet.
|
|
35
|
+
|
|
35
36
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
37
|
+
|
|
36
38
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
37
39
|
class WindowSessionParams extends URLSearchParams {
|
|
38
40
|
static new(init) {
|
|
@@ -131,7 +133,6 @@ class BaseProviderTransport {
|
|
|
131
133
|
if (!_this.isOpened()) {
|
|
132
134
|
await _this.waitUntilOpened(); // will throw on timeout
|
|
133
135
|
}
|
|
134
|
-
|
|
135
136
|
const response = await _this.sendMessageRequest({
|
|
136
137
|
idx: nextMessageIdx(),
|
|
137
138
|
type: EventType.MESSAGE,
|
|
@@ -336,7 +337,6 @@ class BaseProviderTransport {
|
|
|
336
337
|
}
|
|
337
338
|
}, 500); // TODO: be smarter about timer as we're processing the response callbacks..
|
|
338
339
|
}
|
|
339
|
-
|
|
340
340
|
if (!responseCallback) {
|
|
341
341
|
// NOTE: this would occur if 'idx' isn't set, which should never happen
|
|
342
342
|
// or when we register two handler, or duplicate messages with the same idx are sent,
|
|
@@ -1354,7 +1354,7 @@ class UnrealMessageProvider extends BaseProviderTransport {
|
|
|
1354
1354
|
console.log('registering transport!');
|
|
1355
1355
|
};
|
|
1356
1356
|
this.unregister = () => {
|
|
1357
|
-
var _window$ue2
|
|
1357
|
+
var _window$ue2;
|
|
1358
1358
|
this._registered = false;
|
|
1359
1359
|
this.closeWallet();
|
|
1360
1360
|
|
|
@@ -1362,7 +1362,7 @@ class UnrealMessageProvider extends BaseProviderTransport {
|
|
|
1362
1362
|
if (registeredUnrealMessageProvider === this) {
|
|
1363
1363
|
registeredUnrealMessageProvider = undefined;
|
|
1364
1364
|
}
|
|
1365
|
-
if (((_window$ue2 = window.ue) == null
|
|
1365
|
+
if (((_window$ue2 = window.ue) == null || (_window$ue2 = _window$ue2.sequencewallettransport) == null ? void 0 : _window$ue2.onmessagefromwallet) === this.onUnrealCallback) {
|
|
1366
1366
|
delete window.ue.sequencewallettransport.onmessagefromwallet;
|
|
1367
1367
|
}
|
|
1368
1368
|
|
|
@@ -1415,10 +1415,10 @@ class UnrealMessageProvider extends BaseProviderTransport {
|
|
|
1415
1415
|
}
|
|
1416
1416
|
// all lowercase is an annoying limitation of Unreal CEF BindUObject
|
|
1417
1417
|
sendMessage(message) {
|
|
1418
|
-
var _window$ue3
|
|
1418
|
+
var _window$ue3;
|
|
1419
1419
|
const postedMessage = typeof message !== 'string' ? JSON.stringify(message) : message;
|
|
1420
1420
|
console.log('Sending message to wallet:', postedMessage);
|
|
1421
|
-
(_window$ue3 = window.ue) == null
|
|
1421
|
+
(_window$ue3 = window.ue) == null || (_window$ue3 = _window$ue3.sequencewallettransport) == null || _window$ue3.sendmessagetowallet(postedMessage);
|
|
1422
1422
|
}
|
|
1423
1423
|
}
|
|
1424
1424
|
|
|
@@ -1501,15 +1501,15 @@ class UnrealMessageHandler extends BaseWalletTransport {
|
|
|
1501
1501
|
});
|
|
1502
1502
|
}
|
|
1503
1503
|
unregister() {
|
|
1504
|
-
var _window$ue2
|
|
1505
|
-
if (((_window$ue2 = window.ue) == null
|
|
1504
|
+
var _window$ue2;
|
|
1505
|
+
if (((_window$ue2 = window.ue) == null || (_window$ue2 = _window$ue2.sequencewallettransport) == null ? void 0 : _window$ue2.onmessagefromsequencejs) === this.onMessageFromUnreal) {
|
|
1506
1506
|
delete window.ue.sequencewallettransport.onmessagefromsequencejs;
|
|
1507
1507
|
}
|
|
1508
1508
|
this._registered = false;
|
|
1509
1509
|
}
|
|
1510
1510
|
// sendMessage sends message to the dapp window
|
|
1511
1511
|
sendMessage(message) {
|
|
1512
|
-
var _window$ue3
|
|
1512
|
+
var _window$ue3;
|
|
1513
1513
|
if (message.type !== EventType.INIT && this._init !== InitState.OK) {
|
|
1514
1514
|
utils.logger.error('impossible state, should not be calling postMessage until inited');
|
|
1515
1515
|
return;
|
|
@@ -1518,7 +1518,7 @@ class UnrealMessageHandler extends BaseWalletTransport {
|
|
|
1518
1518
|
const payload = JSON.stringify(message);
|
|
1519
1519
|
|
|
1520
1520
|
// post-message to app.
|
|
1521
|
-
(_window$ue3 = window.ue) == null
|
|
1521
|
+
(_window$ue3 = window.ue) == null || (_window$ue3 = _window$ue3.sequencewallettransport) == null || _window$ue3.sendmessagetosequencejs(payload);
|
|
1522
1522
|
}
|
|
1523
1523
|
}
|
|
1524
1524
|
|
|
@@ -1807,7 +1807,7 @@ class WindowMessageProvider extends BaseProviderTransport {
|
|
|
1807
1807
|
closeWallet() {
|
|
1808
1808
|
var _this$walletWindow;
|
|
1809
1809
|
this.close();
|
|
1810
|
-
(_this$walletWindow = this.walletWindow) == null
|
|
1810
|
+
(_this$walletWindow = this.walletWindow) == null || _this$walletWindow.close();
|
|
1811
1811
|
}
|
|
1812
1812
|
sendMessage(message) {
|
|
1813
1813
|
if (!this.walletWindow) {
|
|
@@ -2063,7 +2063,6 @@ class MuxMessageProvider {
|
|
|
2063
2063
|
// send all requests to the WindowMessageProvider anyways. By allowing it, if browser restarts, it will break
|
|
2064
2064
|
// the entire extension because messageProvider.provider will be undefined. So this is a hack to fix it.
|
|
2065
2065
|
}
|
|
2066
|
-
|
|
2067
2066
|
if ((_template$unrealTrans = template.unrealTransport) != null && _template$unrealTrans.enabled && template.windowTransport && template.walletAppURL) {
|
|
2068
2067
|
const unrealMessageProvider = new UnrealMessageProvider(template.walletAppURL);
|
|
2069
2068
|
muxMessageProvider.add(unrealMessageProvider);
|
|
@@ -2791,7 +2790,7 @@ class WalletRequestHandler {
|
|
|
2791
2790
|
setConnectOptions(options) {
|
|
2792
2791
|
var _this$onConnectOption;
|
|
2793
2792
|
this._connectOptions = options;
|
|
2794
|
-
(_this$onConnectOption = this.onConnectOptionsChange) == null
|
|
2793
|
+
(_this$onConnectOption = this.onConnectOptionsChange) == null || _this$onConnectOption.call(this, options);
|
|
2795
2794
|
}
|
|
2796
2795
|
async setDefaultChainId(chainId) {
|
|
2797
2796
|
var _this$prompter4;
|
|
@@ -2833,7 +2832,7 @@ class WalletRequestHandler {
|
|
|
2833
2832
|
if (network$1) {
|
|
2834
2833
|
var _session$networks;
|
|
2835
2834
|
// Delete the isDefaultChain property from the session network
|
|
2836
|
-
(_session$networks = session.networks) == null
|
|
2835
|
+
(_session$networks = session.networks) == null || _session$networks.forEach(n => delete n.isDefaultChain);
|
|
2837
2836
|
|
|
2838
2837
|
// Add the isDefaultChain property to the network with the given networkId
|
|
2839
2838
|
network$1.isDefaultChain = true;
|
|
@@ -3574,7 +3573,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
|
|
|
3574
3573
|
|
|
3575
3574
|
var packageJson = {
|
|
3576
3575
|
name: "@0xsequence/provider",
|
|
3577
|
-
version: "0.0.0-
|
|
3576
|
+
version: "0.0.0-20240123153410",
|
|
3578
3577
|
description: "provider sub-package for Sequence",
|
|
3579
3578
|
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3580
3579
|
source: "src/index.ts",
|
|
@@ -3702,7 +3701,9 @@ DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
|
|
|
3702
3701
|
* and it allows to perform all sequence specific (or write) operations related to the wallet.
|
|
3703
3702
|
*s
|
|
3704
3703
|
* It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
|
|
3705
|
-
*/
|
|
3704
|
+
*/
|
|
3705
|
+
|
|
3706
|
+
// TODO: rename Client to transport.. or something.. like SequenceTransport ..
|
|
3706
3707
|
class SequenceClient {
|
|
3707
3708
|
constructor(transport, store, options, projectAccessKey) {
|
|
3708
3709
|
var _options$defaultEIP;
|
|
@@ -3728,12 +3729,12 @@ class SequenceClient {
|
|
|
3728
3729
|
if (accounts.length > 1) {
|
|
3729
3730
|
console.warn('SequenceClient: wallet-webapp returned more than one account');
|
|
3730
3731
|
}
|
|
3731
|
-
(_this$callbacks$accou = this.callbacks.accountsChanged) == null
|
|
3732
|
+
(_this$callbacks$accou = this.callbacks.accountsChanged) == null || _this$callbacks$accou.forEach(cb => cb(accounts));
|
|
3732
3733
|
});
|
|
3733
3734
|
this.transport.on('connect', response => {
|
|
3734
3735
|
var _this$callbacks$conne;
|
|
3735
3736
|
const chainIdHex = ethers.ethers.utils.hexValue(this.getChainId());
|
|
3736
|
-
(_this$callbacks$conne = this.callbacks.connect) == null
|
|
3737
|
+
(_this$callbacks$conne = this.callbacks.connect) == null || _this$callbacks$conne.forEach(cb => cb(_extends({}, response, {
|
|
3737
3738
|
// Ignore the full connect response
|
|
3738
3739
|
// use the chainId defined locally
|
|
3739
3740
|
chainId: chainIdHex
|
|
@@ -3741,27 +3742,27 @@ class SequenceClient {
|
|
|
3741
3742
|
});
|
|
3742
3743
|
this.transport.on('disconnect', (error, origin) => {
|
|
3743
3744
|
var _this$callbacks$disco;
|
|
3744
|
-
(_this$callbacks$disco = this.callbacks.disconnect) == null
|
|
3745
|
+
(_this$callbacks$disco = this.callbacks.disconnect) == null || _this$callbacks$disco.forEach(cb => cb(error, origin));
|
|
3745
3746
|
});
|
|
3746
3747
|
this.transport.on('networks', networks => {
|
|
3747
3748
|
var _this$callbacks$netwo;
|
|
3748
|
-
(_this$callbacks$netwo = this.callbacks.networks) == null
|
|
3749
|
+
(_this$callbacks$netwo = this.callbacks.networks) == null || _this$callbacks$netwo.forEach(cb => cb(networks));
|
|
3749
3750
|
});
|
|
3750
3751
|
this.transport.on('walletContext', context => {
|
|
3751
3752
|
var _this$callbacks$walle;
|
|
3752
|
-
(_this$callbacks$walle = this.callbacks.walletContext) == null
|
|
3753
|
+
(_this$callbacks$walle = this.callbacks.walletContext) == null || _this$callbacks$walle.forEach(cb => cb(context));
|
|
3753
3754
|
});
|
|
3754
3755
|
this.transport.on('open', info => {
|
|
3755
3756
|
var _this$callbacks$open;
|
|
3756
|
-
(_this$callbacks$open = this.callbacks.open) == null
|
|
3757
|
+
(_this$callbacks$open = this.callbacks.open) == null || _this$callbacks$open.forEach(cb => cb(info));
|
|
3757
3758
|
});
|
|
3758
3759
|
this.transport.on('close', () => {
|
|
3759
3760
|
var _this$callbacks$close;
|
|
3760
|
-
(_this$callbacks$close = this.callbacks.close) == null
|
|
3761
|
+
(_this$callbacks$close = this.callbacks.close) == null || _this$callbacks$close.forEach(cb => cb());
|
|
3761
3762
|
});
|
|
3762
3763
|
this.transport.on('chainChanged', (chainIdHex, origin) => {
|
|
3763
3764
|
var _this$callbacks$chain;
|
|
3764
|
-
(_this$callbacks$chain = this.callbacks.chainChanged) == null
|
|
3765
|
+
(_this$callbacks$chain = this.callbacks.chainChanged) == null || _this$callbacks$chain.forEach(cb => cb(chainIdHex, origin));
|
|
3765
3766
|
});
|
|
3766
3767
|
|
|
3767
3768
|
// We don't listen for the transport chainChanged event
|
|
@@ -3769,7 +3770,7 @@ class SequenceClient {
|
|
|
3769
3770
|
this.defaultChainId.onDefaultChainIdChanged(chainId => {
|
|
3770
3771
|
var _this$callbacks$chain2;
|
|
3771
3772
|
const chainIdHex = ethers.ethers.utils.hexValue(chainId);
|
|
3772
|
-
(_this$callbacks$chain2 = this.callbacks.chainChanged) == null
|
|
3773
|
+
(_this$callbacks$chain2 = this.callbacks.chainChanged) == null || _this$callbacks$chain2.forEach(cb => cb(chainIdHex));
|
|
3773
3774
|
});
|
|
3774
3775
|
}
|
|
3775
3776
|
|
|
@@ -32,7 +32,9 @@ function isProviderTransport(transport) {
|
|
|
32
32
|
// ProviderMessageCallback is used to respond to ProviderMessage requests. The error
|
|
33
33
|
// argument is for exceptions during the execution, and response is the response payload
|
|
34
34
|
// which may contain the result or an error payload from the wallet.
|
|
35
|
+
|
|
35
36
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
37
|
+
|
|
36
38
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
37
39
|
class WindowSessionParams extends URLSearchParams {
|
|
38
40
|
static new(init) {
|
|
@@ -131,7 +133,6 @@ class BaseProviderTransport {
|
|
|
131
133
|
if (!_this.isOpened()) {
|
|
132
134
|
await _this.waitUntilOpened(); // will throw on timeout
|
|
133
135
|
}
|
|
134
|
-
|
|
135
136
|
const response = await _this.sendMessageRequest({
|
|
136
137
|
idx: nextMessageIdx(),
|
|
137
138
|
type: EventType.MESSAGE,
|
|
@@ -336,7 +337,6 @@ class BaseProviderTransport {
|
|
|
336
337
|
}
|
|
337
338
|
}, 500); // TODO: be smarter about timer as we're processing the response callbacks..
|
|
338
339
|
}
|
|
339
|
-
|
|
340
340
|
if (!responseCallback) {
|
|
341
341
|
// NOTE: this would occur if 'idx' isn't set, which should never happen
|
|
342
342
|
// or when we register two handler, or duplicate messages with the same idx are sent,
|
|
@@ -1354,7 +1354,7 @@ class UnrealMessageProvider extends BaseProviderTransport {
|
|
|
1354
1354
|
console.log('registering transport!');
|
|
1355
1355
|
};
|
|
1356
1356
|
this.unregister = () => {
|
|
1357
|
-
var _window$ue2
|
|
1357
|
+
var _window$ue2;
|
|
1358
1358
|
this._registered = false;
|
|
1359
1359
|
this.closeWallet();
|
|
1360
1360
|
|
|
@@ -1362,7 +1362,7 @@ class UnrealMessageProvider extends BaseProviderTransport {
|
|
|
1362
1362
|
if (registeredUnrealMessageProvider === this) {
|
|
1363
1363
|
registeredUnrealMessageProvider = undefined;
|
|
1364
1364
|
}
|
|
1365
|
-
if (((_window$ue2 = window.ue) == null
|
|
1365
|
+
if (((_window$ue2 = window.ue) == null || (_window$ue2 = _window$ue2.sequencewallettransport) == null ? void 0 : _window$ue2.onmessagefromwallet) === this.onUnrealCallback) {
|
|
1366
1366
|
delete window.ue.sequencewallettransport.onmessagefromwallet;
|
|
1367
1367
|
}
|
|
1368
1368
|
|
|
@@ -1415,10 +1415,10 @@ class UnrealMessageProvider extends BaseProviderTransport {
|
|
|
1415
1415
|
}
|
|
1416
1416
|
// all lowercase is an annoying limitation of Unreal CEF BindUObject
|
|
1417
1417
|
sendMessage(message) {
|
|
1418
|
-
var _window$ue3
|
|
1418
|
+
var _window$ue3;
|
|
1419
1419
|
const postedMessage = typeof message !== 'string' ? JSON.stringify(message) : message;
|
|
1420
1420
|
console.log('Sending message to wallet:', postedMessage);
|
|
1421
|
-
(_window$ue3 = window.ue) == null
|
|
1421
|
+
(_window$ue3 = window.ue) == null || (_window$ue3 = _window$ue3.sequencewallettransport) == null || _window$ue3.sendmessagetowallet(postedMessage);
|
|
1422
1422
|
}
|
|
1423
1423
|
}
|
|
1424
1424
|
|
|
@@ -1501,15 +1501,15 @@ class UnrealMessageHandler extends BaseWalletTransport {
|
|
|
1501
1501
|
});
|
|
1502
1502
|
}
|
|
1503
1503
|
unregister() {
|
|
1504
|
-
var _window$ue2
|
|
1505
|
-
if (((_window$ue2 = window.ue) == null
|
|
1504
|
+
var _window$ue2;
|
|
1505
|
+
if (((_window$ue2 = window.ue) == null || (_window$ue2 = _window$ue2.sequencewallettransport) == null ? void 0 : _window$ue2.onmessagefromsequencejs) === this.onMessageFromUnreal) {
|
|
1506
1506
|
delete window.ue.sequencewallettransport.onmessagefromsequencejs;
|
|
1507
1507
|
}
|
|
1508
1508
|
this._registered = false;
|
|
1509
1509
|
}
|
|
1510
1510
|
// sendMessage sends message to the dapp window
|
|
1511
1511
|
sendMessage(message) {
|
|
1512
|
-
var _window$ue3
|
|
1512
|
+
var _window$ue3;
|
|
1513
1513
|
if (message.type !== EventType.INIT && this._init !== InitState.OK) {
|
|
1514
1514
|
utils.logger.error('impossible state, should not be calling postMessage until inited');
|
|
1515
1515
|
return;
|
|
@@ -1518,7 +1518,7 @@ class UnrealMessageHandler extends BaseWalletTransport {
|
|
|
1518
1518
|
const payload = JSON.stringify(message);
|
|
1519
1519
|
|
|
1520
1520
|
// post-message to app.
|
|
1521
|
-
(_window$ue3 = window.ue) == null
|
|
1521
|
+
(_window$ue3 = window.ue) == null || (_window$ue3 = _window$ue3.sequencewallettransport) == null || _window$ue3.sendmessagetosequencejs(payload);
|
|
1522
1522
|
}
|
|
1523
1523
|
}
|
|
1524
1524
|
|
|
@@ -1807,7 +1807,7 @@ class WindowMessageProvider extends BaseProviderTransport {
|
|
|
1807
1807
|
closeWallet() {
|
|
1808
1808
|
var _this$walletWindow;
|
|
1809
1809
|
this.close();
|
|
1810
|
-
(_this$walletWindow = this.walletWindow) == null
|
|
1810
|
+
(_this$walletWindow = this.walletWindow) == null || _this$walletWindow.close();
|
|
1811
1811
|
}
|
|
1812
1812
|
sendMessage(message) {
|
|
1813
1813
|
if (!this.walletWindow) {
|
|
@@ -2063,7 +2063,6 @@ class MuxMessageProvider {
|
|
|
2063
2063
|
// send all requests to the WindowMessageProvider anyways. By allowing it, if browser restarts, it will break
|
|
2064
2064
|
// the entire extension because messageProvider.provider will be undefined. So this is a hack to fix it.
|
|
2065
2065
|
}
|
|
2066
|
-
|
|
2067
2066
|
if ((_template$unrealTrans = template.unrealTransport) != null && _template$unrealTrans.enabled && template.windowTransport && template.walletAppURL) {
|
|
2068
2067
|
const unrealMessageProvider = new UnrealMessageProvider(template.walletAppURL);
|
|
2069
2068
|
muxMessageProvider.add(unrealMessageProvider);
|
|
@@ -2791,7 +2790,7 @@ class WalletRequestHandler {
|
|
|
2791
2790
|
setConnectOptions(options) {
|
|
2792
2791
|
var _this$onConnectOption;
|
|
2793
2792
|
this._connectOptions = options;
|
|
2794
|
-
(_this$onConnectOption = this.onConnectOptionsChange) == null
|
|
2793
|
+
(_this$onConnectOption = this.onConnectOptionsChange) == null || _this$onConnectOption.call(this, options);
|
|
2795
2794
|
}
|
|
2796
2795
|
async setDefaultChainId(chainId) {
|
|
2797
2796
|
var _this$prompter4;
|
|
@@ -2833,7 +2832,7 @@ class WalletRequestHandler {
|
|
|
2833
2832
|
if (network$1) {
|
|
2834
2833
|
var _session$networks;
|
|
2835
2834
|
// Delete the isDefaultChain property from the session network
|
|
2836
|
-
(_session$networks = session.networks) == null
|
|
2835
|
+
(_session$networks = session.networks) == null || _session$networks.forEach(n => delete n.isDefaultChain);
|
|
2837
2836
|
|
|
2838
2837
|
// Add the isDefaultChain property to the network with the given networkId
|
|
2839
2838
|
network$1.isDefaultChain = true;
|
|
@@ -3574,7 +3573,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
|
|
|
3574
3573
|
|
|
3575
3574
|
var packageJson = {
|
|
3576
3575
|
name: "@0xsequence/provider",
|
|
3577
|
-
version: "0.0.0-
|
|
3576
|
+
version: "0.0.0-20240123153410",
|
|
3578
3577
|
description: "provider sub-package for Sequence",
|
|
3579
3578
|
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3580
3579
|
source: "src/index.ts",
|
|
@@ -3702,7 +3701,9 @@ DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
|
|
|
3702
3701
|
* and it allows to perform all sequence specific (or write) operations related to the wallet.
|
|
3703
3702
|
*s
|
|
3704
3703
|
* It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
|
|
3705
|
-
*/
|
|
3704
|
+
*/
|
|
3705
|
+
|
|
3706
|
+
// TODO: rename Client to transport.. or something.. like SequenceTransport ..
|
|
3706
3707
|
class SequenceClient {
|
|
3707
3708
|
constructor(transport, store, options, projectAccessKey) {
|
|
3708
3709
|
var _options$defaultEIP;
|
|
@@ -3728,12 +3729,12 @@ class SequenceClient {
|
|
|
3728
3729
|
if (accounts.length > 1) {
|
|
3729
3730
|
console.warn('SequenceClient: wallet-webapp returned more than one account');
|
|
3730
3731
|
}
|
|
3731
|
-
(_this$callbacks$accou = this.callbacks.accountsChanged) == null
|
|
3732
|
+
(_this$callbacks$accou = this.callbacks.accountsChanged) == null || _this$callbacks$accou.forEach(cb => cb(accounts));
|
|
3732
3733
|
});
|
|
3733
3734
|
this.transport.on('connect', response => {
|
|
3734
3735
|
var _this$callbacks$conne;
|
|
3735
3736
|
const chainIdHex = ethers.ethers.utils.hexValue(this.getChainId());
|
|
3736
|
-
(_this$callbacks$conne = this.callbacks.connect) == null
|
|
3737
|
+
(_this$callbacks$conne = this.callbacks.connect) == null || _this$callbacks$conne.forEach(cb => cb(_extends({}, response, {
|
|
3737
3738
|
// Ignore the full connect response
|
|
3738
3739
|
// use the chainId defined locally
|
|
3739
3740
|
chainId: chainIdHex
|
|
@@ -3741,27 +3742,27 @@ class SequenceClient {
|
|
|
3741
3742
|
});
|
|
3742
3743
|
this.transport.on('disconnect', (error, origin) => {
|
|
3743
3744
|
var _this$callbacks$disco;
|
|
3744
|
-
(_this$callbacks$disco = this.callbacks.disconnect) == null
|
|
3745
|
+
(_this$callbacks$disco = this.callbacks.disconnect) == null || _this$callbacks$disco.forEach(cb => cb(error, origin));
|
|
3745
3746
|
});
|
|
3746
3747
|
this.transport.on('networks', networks => {
|
|
3747
3748
|
var _this$callbacks$netwo;
|
|
3748
|
-
(_this$callbacks$netwo = this.callbacks.networks) == null
|
|
3749
|
+
(_this$callbacks$netwo = this.callbacks.networks) == null || _this$callbacks$netwo.forEach(cb => cb(networks));
|
|
3749
3750
|
});
|
|
3750
3751
|
this.transport.on('walletContext', context => {
|
|
3751
3752
|
var _this$callbacks$walle;
|
|
3752
|
-
(_this$callbacks$walle = this.callbacks.walletContext) == null
|
|
3753
|
+
(_this$callbacks$walle = this.callbacks.walletContext) == null || _this$callbacks$walle.forEach(cb => cb(context));
|
|
3753
3754
|
});
|
|
3754
3755
|
this.transport.on('open', info => {
|
|
3755
3756
|
var _this$callbacks$open;
|
|
3756
|
-
(_this$callbacks$open = this.callbacks.open) == null
|
|
3757
|
+
(_this$callbacks$open = this.callbacks.open) == null || _this$callbacks$open.forEach(cb => cb(info));
|
|
3757
3758
|
});
|
|
3758
3759
|
this.transport.on('close', () => {
|
|
3759
3760
|
var _this$callbacks$close;
|
|
3760
|
-
(_this$callbacks$close = this.callbacks.close) == null
|
|
3761
|
+
(_this$callbacks$close = this.callbacks.close) == null || _this$callbacks$close.forEach(cb => cb());
|
|
3761
3762
|
});
|
|
3762
3763
|
this.transport.on('chainChanged', (chainIdHex, origin) => {
|
|
3763
3764
|
var _this$callbacks$chain;
|
|
3764
|
-
(_this$callbacks$chain = this.callbacks.chainChanged) == null
|
|
3765
|
+
(_this$callbacks$chain = this.callbacks.chainChanged) == null || _this$callbacks$chain.forEach(cb => cb(chainIdHex, origin));
|
|
3765
3766
|
});
|
|
3766
3767
|
|
|
3767
3768
|
// We don't listen for the transport chainChanged event
|
|
@@ -3769,7 +3770,7 @@ class SequenceClient {
|
|
|
3769
3770
|
this.defaultChainId.onDefaultChainIdChanged(chainId => {
|
|
3770
3771
|
var _this$callbacks$chain2;
|
|
3771
3772
|
const chainIdHex = ethers.ethers.utils.hexValue(chainId);
|
|
3772
|
-
(_this$callbacks$chain2 = this.callbacks.chainChanged) == null
|
|
3773
|
+
(_this$callbacks$chain2 = this.callbacks.chainChanged) == null || _this$callbacks$chain2.forEach(cb => cb(chainIdHex));
|
|
3773
3774
|
});
|
|
3774
3775
|
}
|
|
3775
3776
|
|
|
@@ -28,7 +28,9 @@ function isProviderTransport(transport) {
|
|
|
28
28
|
// ProviderMessageCallback is used to respond to ProviderMessage requests. The error
|
|
29
29
|
// argument is for exceptions during the execution, and response is the response payload
|
|
30
30
|
// which may contain the result or an error payload from the wallet.
|
|
31
|
+
|
|
31
32
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
33
|
+
|
|
32
34
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
33
35
|
class WindowSessionParams extends URLSearchParams {
|
|
34
36
|
static new(init) {
|
|
@@ -127,7 +129,6 @@ class BaseProviderTransport {
|
|
|
127
129
|
if (!_this.isOpened()) {
|
|
128
130
|
await _this.waitUntilOpened(); // will throw on timeout
|
|
129
131
|
}
|
|
130
|
-
|
|
131
132
|
const response = await _this.sendMessageRequest({
|
|
132
133
|
idx: nextMessageIdx(),
|
|
133
134
|
type: EventType.MESSAGE,
|
|
@@ -332,7 +333,6 @@ class BaseProviderTransport {
|
|
|
332
333
|
}
|
|
333
334
|
}, 500); // TODO: be smarter about timer as we're processing the response callbacks..
|
|
334
335
|
}
|
|
335
|
-
|
|
336
336
|
if (!responseCallback) {
|
|
337
337
|
// NOTE: this would occur if 'idx' isn't set, which should never happen
|
|
338
338
|
// or when we register two handler, or duplicate messages with the same idx are sent,
|
|
@@ -1350,7 +1350,7 @@ class UnrealMessageProvider extends BaseProviderTransport {
|
|
|
1350
1350
|
console.log('registering transport!');
|
|
1351
1351
|
};
|
|
1352
1352
|
this.unregister = () => {
|
|
1353
|
-
var _window$ue2
|
|
1353
|
+
var _window$ue2;
|
|
1354
1354
|
this._registered = false;
|
|
1355
1355
|
this.closeWallet();
|
|
1356
1356
|
|
|
@@ -1358,7 +1358,7 @@ class UnrealMessageProvider extends BaseProviderTransport {
|
|
|
1358
1358
|
if (registeredUnrealMessageProvider === this) {
|
|
1359
1359
|
registeredUnrealMessageProvider = undefined;
|
|
1360
1360
|
}
|
|
1361
|
-
if (((_window$ue2 = window.ue) == null
|
|
1361
|
+
if (((_window$ue2 = window.ue) == null || (_window$ue2 = _window$ue2.sequencewallettransport) == null ? void 0 : _window$ue2.onmessagefromwallet) === this.onUnrealCallback) {
|
|
1362
1362
|
delete window.ue.sequencewallettransport.onmessagefromwallet;
|
|
1363
1363
|
}
|
|
1364
1364
|
|
|
@@ -1411,10 +1411,10 @@ class UnrealMessageProvider extends BaseProviderTransport {
|
|
|
1411
1411
|
}
|
|
1412
1412
|
// all lowercase is an annoying limitation of Unreal CEF BindUObject
|
|
1413
1413
|
sendMessage(message) {
|
|
1414
|
-
var _window$ue3
|
|
1414
|
+
var _window$ue3;
|
|
1415
1415
|
const postedMessage = typeof message !== 'string' ? JSON.stringify(message) : message;
|
|
1416
1416
|
console.log('Sending message to wallet:', postedMessage);
|
|
1417
|
-
(_window$ue3 = window.ue) == null
|
|
1417
|
+
(_window$ue3 = window.ue) == null || (_window$ue3 = _window$ue3.sequencewallettransport) == null || _window$ue3.sendmessagetowallet(postedMessage);
|
|
1418
1418
|
}
|
|
1419
1419
|
}
|
|
1420
1420
|
|
|
@@ -1497,15 +1497,15 @@ class UnrealMessageHandler extends BaseWalletTransport {
|
|
|
1497
1497
|
});
|
|
1498
1498
|
}
|
|
1499
1499
|
unregister() {
|
|
1500
|
-
var _window$ue2
|
|
1501
|
-
if (((_window$ue2 = window.ue) == null
|
|
1500
|
+
var _window$ue2;
|
|
1501
|
+
if (((_window$ue2 = window.ue) == null || (_window$ue2 = _window$ue2.sequencewallettransport) == null ? void 0 : _window$ue2.onmessagefromsequencejs) === this.onMessageFromUnreal) {
|
|
1502
1502
|
delete window.ue.sequencewallettransport.onmessagefromsequencejs;
|
|
1503
1503
|
}
|
|
1504
1504
|
this._registered = false;
|
|
1505
1505
|
}
|
|
1506
1506
|
// sendMessage sends message to the dapp window
|
|
1507
1507
|
sendMessage(message) {
|
|
1508
|
-
var _window$ue3
|
|
1508
|
+
var _window$ue3;
|
|
1509
1509
|
if (message.type !== EventType.INIT && this._init !== InitState.OK) {
|
|
1510
1510
|
logger.error('impossible state, should not be calling postMessage until inited');
|
|
1511
1511
|
return;
|
|
@@ -1514,7 +1514,7 @@ class UnrealMessageHandler extends BaseWalletTransport {
|
|
|
1514
1514
|
const payload = JSON.stringify(message);
|
|
1515
1515
|
|
|
1516
1516
|
// post-message to app.
|
|
1517
|
-
(_window$ue3 = window.ue) == null
|
|
1517
|
+
(_window$ue3 = window.ue) == null || (_window$ue3 = _window$ue3.sequencewallettransport) == null || _window$ue3.sendmessagetosequencejs(payload);
|
|
1518
1518
|
}
|
|
1519
1519
|
}
|
|
1520
1520
|
|
|
@@ -1803,7 +1803,7 @@ class WindowMessageProvider extends BaseProviderTransport {
|
|
|
1803
1803
|
closeWallet() {
|
|
1804
1804
|
var _this$walletWindow;
|
|
1805
1805
|
this.close();
|
|
1806
|
-
(_this$walletWindow = this.walletWindow) == null
|
|
1806
|
+
(_this$walletWindow = this.walletWindow) == null || _this$walletWindow.close();
|
|
1807
1807
|
}
|
|
1808
1808
|
sendMessage(message) {
|
|
1809
1809
|
if (!this.walletWindow) {
|
|
@@ -2059,7 +2059,6 @@ class MuxMessageProvider {
|
|
|
2059
2059
|
// send all requests to the WindowMessageProvider anyways. By allowing it, if browser restarts, it will break
|
|
2060
2060
|
// the entire extension because messageProvider.provider will be undefined. So this is a hack to fix it.
|
|
2061
2061
|
}
|
|
2062
|
-
|
|
2063
2062
|
if ((_template$unrealTrans = template.unrealTransport) != null && _template$unrealTrans.enabled && template.windowTransport && template.walletAppURL) {
|
|
2064
2063
|
const unrealMessageProvider = new UnrealMessageProvider(template.walletAppURL);
|
|
2065
2064
|
muxMessageProvider.add(unrealMessageProvider);
|
|
@@ -2787,7 +2786,7 @@ class WalletRequestHandler {
|
|
|
2787
2786
|
setConnectOptions(options) {
|
|
2788
2787
|
var _this$onConnectOption;
|
|
2789
2788
|
this._connectOptions = options;
|
|
2790
|
-
(_this$onConnectOption = this.onConnectOptionsChange) == null
|
|
2789
|
+
(_this$onConnectOption = this.onConnectOptionsChange) == null || _this$onConnectOption.call(this, options);
|
|
2791
2790
|
}
|
|
2792
2791
|
async setDefaultChainId(chainId) {
|
|
2793
2792
|
var _this$prompter4;
|
|
@@ -2829,7 +2828,7 @@ class WalletRequestHandler {
|
|
|
2829
2828
|
if (network) {
|
|
2830
2829
|
var _session$networks;
|
|
2831
2830
|
// Delete the isDefaultChain property from the session network
|
|
2832
|
-
(_session$networks = session.networks) == null
|
|
2831
|
+
(_session$networks = session.networks) == null || _session$networks.forEach(n => delete n.isDefaultChain);
|
|
2833
2832
|
|
|
2834
2833
|
// Add the isDefaultChain property to the network with the given networkId
|
|
2835
2834
|
network.isDefaultChain = true;
|
|
@@ -3570,7 +3569,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
|
|
|
3570
3569
|
|
|
3571
3570
|
var packageJson = {
|
|
3572
3571
|
name: "@0xsequence/provider",
|
|
3573
|
-
version: "0.0.0-
|
|
3572
|
+
version: "0.0.0-20240123153410",
|
|
3574
3573
|
description: "provider sub-package for Sequence",
|
|
3575
3574
|
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3576
3575
|
source: "src/index.ts",
|
|
@@ -3698,7 +3697,9 @@ DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
|
|
|
3698
3697
|
* and it allows to perform all sequence specific (or write) operations related to the wallet.
|
|
3699
3698
|
*s
|
|
3700
3699
|
* It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
|
|
3701
|
-
*/
|
|
3700
|
+
*/
|
|
3701
|
+
|
|
3702
|
+
// TODO: rename Client to transport.. or something.. like SequenceTransport ..
|
|
3702
3703
|
class SequenceClient {
|
|
3703
3704
|
constructor(transport, store, options, projectAccessKey) {
|
|
3704
3705
|
var _options$defaultEIP;
|
|
@@ -3724,12 +3725,12 @@ class SequenceClient {
|
|
|
3724
3725
|
if (accounts.length > 1) {
|
|
3725
3726
|
console.warn('SequenceClient: wallet-webapp returned more than one account');
|
|
3726
3727
|
}
|
|
3727
|
-
(_this$callbacks$accou = this.callbacks.accountsChanged) == null
|
|
3728
|
+
(_this$callbacks$accou = this.callbacks.accountsChanged) == null || _this$callbacks$accou.forEach(cb => cb(accounts));
|
|
3728
3729
|
});
|
|
3729
3730
|
this.transport.on('connect', response => {
|
|
3730
3731
|
var _this$callbacks$conne;
|
|
3731
3732
|
const chainIdHex = ethers.utils.hexValue(this.getChainId());
|
|
3732
|
-
(_this$callbacks$conne = this.callbacks.connect) == null
|
|
3733
|
+
(_this$callbacks$conne = this.callbacks.connect) == null || _this$callbacks$conne.forEach(cb => cb(_extends({}, response, {
|
|
3733
3734
|
// Ignore the full connect response
|
|
3734
3735
|
// use the chainId defined locally
|
|
3735
3736
|
chainId: chainIdHex
|
|
@@ -3737,27 +3738,27 @@ class SequenceClient {
|
|
|
3737
3738
|
});
|
|
3738
3739
|
this.transport.on('disconnect', (error, origin) => {
|
|
3739
3740
|
var _this$callbacks$disco;
|
|
3740
|
-
(_this$callbacks$disco = this.callbacks.disconnect) == null
|
|
3741
|
+
(_this$callbacks$disco = this.callbacks.disconnect) == null || _this$callbacks$disco.forEach(cb => cb(error, origin));
|
|
3741
3742
|
});
|
|
3742
3743
|
this.transport.on('networks', networks => {
|
|
3743
3744
|
var _this$callbacks$netwo;
|
|
3744
|
-
(_this$callbacks$netwo = this.callbacks.networks) == null
|
|
3745
|
+
(_this$callbacks$netwo = this.callbacks.networks) == null || _this$callbacks$netwo.forEach(cb => cb(networks));
|
|
3745
3746
|
});
|
|
3746
3747
|
this.transport.on('walletContext', context => {
|
|
3747
3748
|
var _this$callbacks$walle;
|
|
3748
|
-
(_this$callbacks$walle = this.callbacks.walletContext) == null
|
|
3749
|
+
(_this$callbacks$walle = this.callbacks.walletContext) == null || _this$callbacks$walle.forEach(cb => cb(context));
|
|
3749
3750
|
});
|
|
3750
3751
|
this.transport.on('open', info => {
|
|
3751
3752
|
var _this$callbacks$open;
|
|
3752
|
-
(_this$callbacks$open = this.callbacks.open) == null
|
|
3753
|
+
(_this$callbacks$open = this.callbacks.open) == null || _this$callbacks$open.forEach(cb => cb(info));
|
|
3753
3754
|
});
|
|
3754
3755
|
this.transport.on('close', () => {
|
|
3755
3756
|
var _this$callbacks$close;
|
|
3756
|
-
(_this$callbacks$close = this.callbacks.close) == null
|
|
3757
|
+
(_this$callbacks$close = this.callbacks.close) == null || _this$callbacks$close.forEach(cb => cb());
|
|
3757
3758
|
});
|
|
3758
3759
|
this.transport.on('chainChanged', (chainIdHex, origin) => {
|
|
3759
3760
|
var _this$callbacks$chain;
|
|
3760
|
-
(_this$callbacks$chain = this.callbacks.chainChanged) == null
|
|
3761
|
+
(_this$callbacks$chain = this.callbacks.chainChanged) == null || _this$callbacks$chain.forEach(cb => cb(chainIdHex, origin));
|
|
3761
3762
|
});
|
|
3762
3763
|
|
|
3763
3764
|
// We don't listen for the transport chainChanged event
|
|
@@ -3765,7 +3766,7 @@ class SequenceClient {
|
|
|
3765
3766
|
this.defaultChainId.onDefaultChainIdChanged(chainId => {
|
|
3766
3767
|
var _this$callbacks$chain2;
|
|
3767
3768
|
const chainIdHex = ethers.utils.hexValue(chainId);
|
|
3768
|
-
(_this$callbacks$chain2 = this.callbacks.chainChanged) == null
|
|
3769
|
+
(_this$callbacks$chain2 = this.callbacks.chainChanged) == null || _this$callbacks$chain2.forEach(cb => cb(chainIdHex));
|
|
3769
3770
|
});
|
|
3770
3771
|
}
|
|
3771
3772
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/provider",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-20240123153410",
|
|
4
4
|
"description": "provider sub-package for Sequence",
|
|
5
5
|
"repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"eventemitter2": "^6.4.5",
|
|
13
13
|
"webextension-polyfill": "^0.10.0",
|
|
14
|
-
"@0xsequence/
|
|
15
|
-
"@0xsequence/
|
|
16
|
-
"@0xsequence/auth": "0.0.0-
|
|
17
|
-
"@0xsequence/core": "0.0.0-
|
|
18
|
-
"@0xsequence/
|
|
19
|
-
"@0xsequence/
|
|
20
|
-
"@0xsequence/
|
|
21
|
-
"@0xsequence/utils": "0.0.0-
|
|
22
|
-
"@0xsequence/wallet": "0.0.0-
|
|
14
|
+
"@0xsequence/abi": "0.0.0-20240123153410",
|
|
15
|
+
"@0xsequence/account": "0.0.0-20240123153410",
|
|
16
|
+
"@0xsequence/auth": "0.0.0-20240123153410",
|
|
17
|
+
"@0xsequence/core": "0.0.0-20240123153410",
|
|
18
|
+
"@0xsequence/migration": "0.0.0-20240123153410",
|
|
19
|
+
"@0xsequence/network": "0.0.0-20240123153410",
|
|
20
|
+
"@0xsequence/relayer": "0.0.0-20240123153410",
|
|
21
|
+
"@0xsequence/utils": "0.0.0-20240123153410",
|
|
22
|
+
"@0xsequence/wallet": "0.0.0-20240123153410"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"ethers": ">=5.5 < 6"
|