@0xsequence/provider 0.0.0-20231214172616 → 0.0.0-20240111142017

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,9 +32,7 @@ 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
-
36
35
  // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
37
-
38
36
  // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
39
37
  class WindowSessionParams extends URLSearchParams {
40
38
  static new(init) {
@@ -133,6 +131,7 @@ class BaseProviderTransport {
133
131
  if (!_this.isOpened()) {
134
132
  await _this.waitUntilOpened(); // will throw on timeout
135
133
  }
134
+
136
135
  const response = await _this.sendMessageRequest({
137
136
  idx: nextMessageIdx(),
138
137
  type: EventType.MESSAGE,
@@ -337,6 +336,7 @@ class BaseProviderTransport {
337
336
  }
338
337
  }, 500); // TODO: be smarter about timer as we're processing the response callbacks..
339
338
  }
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, _window$ue2$sequencew;
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 || (_window$ue2 = _window$ue2.sequencewallettransport) == null ? void 0 : _window$ue2.onmessagefromwallet) === this.onUnrealCallback) {
1365
+ if (((_window$ue2 = window.ue) == null ? void 0 : (_window$ue2$sequencew = _window$ue2.sequencewallettransport) == null ? void 0 : _window$ue2$sequencew.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, _window$ue3$sequencew;
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 || (_window$ue3 = _window$ue3.sequencewallettransport) == null || _window$ue3.sendmessagetowallet(postedMessage);
1421
+ (_window$ue3 = window.ue) == null ? void 0 : (_window$ue3$sequencew = _window$ue3.sequencewallettransport) == null ? void 0 : _window$ue3$sequencew.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 || (_window$ue2 = _window$ue2.sequencewallettransport) == null ? void 0 : _window$ue2.onmessagefromsequencejs) === this.onMessageFromUnreal) {
1504
+ var _window$ue2, _window$ue2$sequencew;
1505
+ if (((_window$ue2 = window.ue) == null ? void 0 : (_window$ue2$sequencew = _window$ue2.sequencewallettransport) == null ? void 0 : _window$ue2$sequencew.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, _window$ue3$sequencew;
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 || (_window$ue3 = _window$ue3.sequencewallettransport) == null || _window$ue3.sendmessagetosequencejs(payload);
1521
+ (_window$ue3 = window.ue) == null ? void 0 : (_window$ue3$sequencew = _window$ue3.sequencewallettransport) == null ? void 0 : _window$ue3$sequencew.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 || _this$walletWindow.close();
1810
+ (_this$walletWindow = this.walletWindow) == null ? void 0 : _this$walletWindow.close();
1811
1811
  }
1812
1812
  sendMessage(message) {
1813
1813
  if (!this.walletWindow) {
@@ -2063,6 +2063,7 @@ 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
+
2066
2067
  if ((_template$unrealTrans = template.unrealTransport) != null && _template$unrealTrans.enabled && template.windowTransport && template.walletAppURL) {
2067
2068
  const unrealMessageProvider = new UnrealMessageProvider(template.walletAppURL);
2068
2069
  muxMessageProvider.add(unrealMessageProvider);
@@ -2790,7 +2791,7 @@ class WalletRequestHandler {
2790
2791
  setConnectOptions(options) {
2791
2792
  var _this$onConnectOption;
2792
2793
  this._connectOptions = options;
2793
- (_this$onConnectOption = this.onConnectOptionsChange) == null || _this$onConnectOption.call(this, options);
2794
+ (_this$onConnectOption = this.onConnectOptionsChange) == null ? void 0 : _this$onConnectOption.call(this, options);
2794
2795
  }
2795
2796
  async setDefaultChainId(chainId) {
2796
2797
  var _this$prompter4;
@@ -2832,7 +2833,7 @@ class WalletRequestHandler {
2832
2833
  if (network$1) {
2833
2834
  var _session$networks;
2834
2835
  // Delete the isDefaultChain property from the session network
2835
- (_session$networks = session.networks) == null || _session$networks.forEach(n => delete n.isDefaultChain);
2836
+ (_session$networks = session.networks) == null ? void 0 : _session$networks.forEach(n => delete n.isDefaultChain);
2836
2837
 
2837
2838
  // Add the isDefaultChain property to the network with the given networkId
2838
2839
  network$1.isDefaultChain = true;
@@ -3573,7 +3574,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
3573
3574
 
3574
3575
  var packageJson = {
3575
3576
  name: "@0xsequence/provider",
3576
- version: "0.0.0-20231214172616",
3577
+ version: "0.0.0-20240111142017",
3577
3578
  description: "provider sub-package for Sequence",
3578
3579
  repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
3579
3580
  source: "src/index.ts",
@@ -3701,9 +3702,7 @@ DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
3701
3702
  * and it allows to perform all sequence specific (or write) operations related to the wallet.
3702
3703
  *s
3703
3704
  * It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
3704
- */
3705
-
3706
- // TODO: rename Client to transport.. or something.. like SequenceTransport ..
3705
+ */ // TODO: rename Client to transport.. or something.. like SequenceTransport ..
3707
3706
  class SequenceClient {
3708
3707
  constructor(transport, store, options, projectAccessKey) {
3709
3708
  var _options$defaultEIP;
@@ -3729,12 +3728,12 @@ class SequenceClient {
3729
3728
  if (accounts.length > 1) {
3730
3729
  console.warn('SequenceClient: wallet-webapp returned more than one account');
3731
3730
  }
3732
- (_this$callbacks$accou = this.callbacks.accountsChanged) == null || _this$callbacks$accou.forEach(cb => cb(accounts));
3731
+ (_this$callbacks$accou = this.callbacks.accountsChanged) == null ? void 0 : _this$callbacks$accou.forEach(cb => cb(accounts));
3733
3732
  });
3734
3733
  this.transport.on('connect', response => {
3735
3734
  var _this$callbacks$conne;
3736
3735
  const chainIdHex = ethers.ethers.utils.hexValue(this.getChainId());
3737
- (_this$callbacks$conne = this.callbacks.connect) == null || _this$callbacks$conne.forEach(cb => cb(_extends({}, response, {
3736
+ (_this$callbacks$conne = this.callbacks.connect) == null ? void 0 : _this$callbacks$conne.forEach(cb => cb(_extends({}, response, {
3738
3737
  // Ignore the full connect response
3739
3738
  // use the chainId defined locally
3740
3739
  chainId: chainIdHex
@@ -3742,27 +3741,27 @@ class SequenceClient {
3742
3741
  });
3743
3742
  this.transport.on('disconnect', (error, origin) => {
3744
3743
  var _this$callbacks$disco;
3745
- (_this$callbacks$disco = this.callbacks.disconnect) == null || _this$callbacks$disco.forEach(cb => cb(error, origin));
3744
+ (_this$callbacks$disco = this.callbacks.disconnect) == null ? void 0 : _this$callbacks$disco.forEach(cb => cb(error, origin));
3746
3745
  });
3747
3746
  this.transport.on('networks', networks => {
3748
3747
  var _this$callbacks$netwo;
3749
- (_this$callbacks$netwo = this.callbacks.networks) == null || _this$callbacks$netwo.forEach(cb => cb(networks));
3748
+ (_this$callbacks$netwo = this.callbacks.networks) == null ? void 0 : _this$callbacks$netwo.forEach(cb => cb(networks));
3750
3749
  });
3751
3750
  this.transport.on('walletContext', context => {
3752
3751
  var _this$callbacks$walle;
3753
- (_this$callbacks$walle = this.callbacks.walletContext) == null || _this$callbacks$walle.forEach(cb => cb(context));
3752
+ (_this$callbacks$walle = this.callbacks.walletContext) == null ? void 0 : _this$callbacks$walle.forEach(cb => cb(context));
3754
3753
  });
3755
3754
  this.transport.on('open', info => {
3756
3755
  var _this$callbacks$open;
3757
- (_this$callbacks$open = this.callbacks.open) == null || _this$callbacks$open.forEach(cb => cb(info));
3756
+ (_this$callbacks$open = this.callbacks.open) == null ? void 0 : _this$callbacks$open.forEach(cb => cb(info));
3758
3757
  });
3759
3758
  this.transport.on('close', () => {
3760
3759
  var _this$callbacks$close;
3761
- (_this$callbacks$close = this.callbacks.close) == null || _this$callbacks$close.forEach(cb => cb());
3760
+ (_this$callbacks$close = this.callbacks.close) == null ? void 0 : _this$callbacks$close.forEach(cb => cb());
3762
3761
  });
3763
3762
  this.transport.on('chainChanged', (chainIdHex, origin) => {
3764
3763
  var _this$callbacks$chain;
3765
- (_this$callbacks$chain = this.callbacks.chainChanged) == null || _this$callbacks$chain.forEach(cb => cb(chainIdHex, origin));
3764
+ (_this$callbacks$chain = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain.forEach(cb => cb(chainIdHex, origin));
3766
3765
  });
3767
3766
 
3768
3767
  // We don't listen for the transport chainChanged event
@@ -3770,7 +3769,7 @@ class SequenceClient {
3770
3769
  this.defaultChainId.onDefaultChainIdChanged(chainId => {
3771
3770
  var _this$callbacks$chain2;
3772
3771
  const chainIdHex = ethers.ethers.utils.hexValue(chainId);
3773
- (_this$callbacks$chain2 = this.callbacks.chainChanged) == null || _this$callbacks$chain2.forEach(cb => cb(chainIdHex));
3772
+ (_this$callbacks$chain2 = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain2.forEach(cb => cb(chainIdHex));
3774
3773
  });
3775
3774
  }
3776
3775
 
@@ -32,9 +32,7 @@ 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
-
36
35
  // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
37
-
38
36
  // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
39
37
  class WindowSessionParams extends URLSearchParams {
40
38
  static new(init) {
@@ -133,6 +131,7 @@ class BaseProviderTransport {
133
131
  if (!_this.isOpened()) {
134
132
  await _this.waitUntilOpened(); // will throw on timeout
135
133
  }
134
+
136
135
  const response = await _this.sendMessageRequest({
137
136
  idx: nextMessageIdx(),
138
137
  type: EventType.MESSAGE,
@@ -337,6 +336,7 @@ class BaseProviderTransport {
337
336
  }
338
337
  }, 500); // TODO: be smarter about timer as we're processing the response callbacks..
339
338
  }
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, _window$ue2$sequencew;
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 || (_window$ue2 = _window$ue2.sequencewallettransport) == null ? void 0 : _window$ue2.onmessagefromwallet) === this.onUnrealCallback) {
1365
+ if (((_window$ue2 = window.ue) == null ? void 0 : (_window$ue2$sequencew = _window$ue2.sequencewallettransport) == null ? void 0 : _window$ue2$sequencew.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, _window$ue3$sequencew;
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 || (_window$ue3 = _window$ue3.sequencewallettransport) == null || _window$ue3.sendmessagetowallet(postedMessage);
1421
+ (_window$ue3 = window.ue) == null ? void 0 : (_window$ue3$sequencew = _window$ue3.sequencewallettransport) == null ? void 0 : _window$ue3$sequencew.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 || (_window$ue2 = _window$ue2.sequencewallettransport) == null ? void 0 : _window$ue2.onmessagefromsequencejs) === this.onMessageFromUnreal) {
1504
+ var _window$ue2, _window$ue2$sequencew;
1505
+ if (((_window$ue2 = window.ue) == null ? void 0 : (_window$ue2$sequencew = _window$ue2.sequencewallettransport) == null ? void 0 : _window$ue2$sequencew.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, _window$ue3$sequencew;
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 || (_window$ue3 = _window$ue3.sequencewallettransport) == null || _window$ue3.sendmessagetosequencejs(payload);
1521
+ (_window$ue3 = window.ue) == null ? void 0 : (_window$ue3$sequencew = _window$ue3.sequencewallettransport) == null ? void 0 : _window$ue3$sequencew.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 || _this$walletWindow.close();
1810
+ (_this$walletWindow = this.walletWindow) == null ? void 0 : _this$walletWindow.close();
1811
1811
  }
1812
1812
  sendMessage(message) {
1813
1813
  if (!this.walletWindow) {
@@ -2063,6 +2063,7 @@ 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
+
2066
2067
  if ((_template$unrealTrans = template.unrealTransport) != null && _template$unrealTrans.enabled && template.windowTransport && template.walletAppURL) {
2067
2068
  const unrealMessageProvider = new UnrealMessageProvider(template.walletAppURL);
2068
2069
  muxMessageProvider.add(unrealMessageProvider);
@@ -2790,7 +2791,7 @@ class WalletRequestHandler {
2790
2791
  setConnectOptions(options) {
2791
2792
  var _this$onConnectOption;
2792
2793
  this._connectOptions = options;
2793
- (_this$onConnectOption = this.onConnectOptionsChange) == null || _this$onConnectOption.call(this, options);
2794
+ (_this$onConnectOption = this.onConnectOptionsChange) == null ? void 0 : _this$onConnectOption.call(this, options);
2794
2795
  }
2795
2796
  async setDefaultChainId(chainId) {
2796
2797
  var _this$prompter4;
@@ -2832,7 +2833,7 @@ class WalletRequestHandler {
2832
2833
  if (network$1) {
2833
2834
  var _session$networks;
2834
2835
  // Delete the isDefaultChain property from the session network
2835
- (_session$networks = session.networks) == null || _session$networks.forEach(n => delete n.isDefaultChain);
2836
+ (_session$networks = session.networks) == null ? void 0 : _session$networks.forEach(n => delete n.isDefaultChain);
2836
2837
 
2837
2838
  // Add the isDefaultChain property to the network with the given networkId
2838
2839
  network$1.isDefaultChain = true;
@@ -3573,7 +3574,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
3573
3574
 
3574
3575
  var packageJson = {
3575
3576
  name: "@0xsequence/provider",
3576
- version: "0.0.0-20231214172616",
3577
+ version: "0.0.0-20240111142017",
3577
3578
  description: "provider sub-package for Sequence",
3578
3579
  repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
3579
3580
  source: "src/index.ts",
@@ -3701,9 +3702,7 @@ DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
3701
3702
  * and it allows to perform all sequence specific (or write) operations related to the wallet.
3702
3703
  *s
3703
3704
  * It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
3704
- */
3705
-
3706
- // TODO: rename Client to transport.. or something.. like SequenceTransport ..
3705
+ */ // TODO: rename Client to transport.. or something.. like SequenceTransport ..
3707
3706
  class SequenceClient {
3708
3707
  constructor(transport, store, options, projectAccessKey) {
3709
3708
  var _options$defaultEIP;
@@ -3729,12 +3728,12 @@ class SequenceClient {
3729
3728
  if (accounts.length > 1) {
3730
3729
  console.warn('SequenceClient: wallet-webapp returned more than one account');
3731
3730
  }
3732
- (_this$callbacks$accou = this.callbacks.accountsChanged) == null || _this$callbacks$accou.forEach(cb => cb(accounts));
3731
+ (_this$callbacks$accou = this.callbacks.accountsChanged) == null ? void 0 : _this$callbacks$accou.forEach(cb => cb(accounts));
3733
3732
  });
3734
3733
  this.transport.on('connect', response => {
3735
3734
  var _this$callbacks$conne;
3736
3735
  const chainIdHex = ethers.ethers.utils.hexValue(this.getChainId());
3737
- (_this$callbacks$conne = this.callbacks.connect) == null || _this$callbacks$conne.forEach(cb => cb(_extends({}, response, {
3736
+ (_this$callbacks$conne = this.callbacks.connect) == null ? void 0 : _this$callbacks$conne.forEach(cb => cb(_extends({}, response, {
3738
3737
  // Ignore the full connect response
3739
3738
  // use the chainId defined locally
3740
3739
  chainId: chainIdHex
@@ -3742,27 +3741,27 @@ class SequenceClient {
3742
3741
  });
3743
3742
  this.transport.on('disconnect', (error, origin) => {
3744
3743
  var _this$callbacks$disco;
3745
- (_this$callbacks$disco = this.callbacks.disconnect) == null || _this$callbacks$disco.forEach(cb => cb(error, origin));
3744
+ (_this$callbacks$disco = this.callbacks.disconnect) == null ? void 0 : _this$callbacks$disco.forEach(cb => cb(error, origin));
3746
3745
  });
3747
3746
  this.transport.on('networks', networks => {
3748
3747
  var _this$callbacks$netwo;
3749
- (_this$callbacks$netwo = this.callbacks.networks) == null || _this$callbacks$netwo.forEach(cb => cb(networks));
3748
+ (_this$callbacks$netwo = this.callbacks.networks) == null ? void 0 : _this$callbacks$netwo.forEach(cb => cb(networks));
3750
3749
  });
3751
3750
  this.transport.on('walletContext', context => {
3752
3751
  var _this$callbacks$walle;
3753
- (_this$callbacks$walle = this.callbacks.walletContext) == null || _this$callbacks$walle.forEach(cb => cb(context));
3752
+ (_this$callbacks$walle = this.callbacks.walletContext) == null ? void 0 : _this$callbacks$walle.forEach(cb => cb(context));
3754
3753
  });
3755
3754
  this.transport.on('open', info => {
3756
3755
  var _this$callbacks$open;
3757
- (_this$callbacks$open = this.callbacks.open) == null || _this$callbacks$open.forEach(cb => cb(info));
3756
+ (_this$callbacks$open = this.callbacks.open) == null ? void 0 : _this$callbacks$open.forEach(cb => cb(info));
3758
3757
  });
3759
3758
  this.transport.on('close', () => {
3760
3759
  var _this$callbacks$close;
3761
- (_this$callbacks$close = this.callbacks.close) == null || _this$callbacks$close.forEach(cb => cb());
3760
+ (_this$callbacks$close = this.callbacks.close) == null ? void 0 : _this$callbacks$close.forEach(cb => cb());
3762
3761
  });
3763
3762
  this.transport.on('chainChanged', (chainIdHex, origin) => {
3764
3763
  var _this$callbacks$chain;
3765
- (_this$callbacks$chain = this.callbacks.chainChanged) == null || _this$callbacks$chain.forEach(cb => cb(chainIdHex, origin));
3764
+ (_this$callbacks$chain = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain.forEach(cb => cb(chainIdHex, origin));
3766
3765
  });
3767
3766
 
3768
3767
  // We don't listen for the transport chainChanged event
@@ -3770,7 +3769,7 @@ class SequenceClient {
3770
3769
  this.defaultChainId.onDefaultChainIdChanged(chainId => {
3771
3770
  var _this$callbacks$chain2;
3772
3771
  const chainIdHex = ethers.ethers.utils.hexValue(chainId);
3773
- (_this$callbacks$chain2 = this.callbacks.chainChanged) == null || _this$callbacks$chain2.forEach(cb => cb(chainIdHex));
3772
+ (_this$callbacks$chain2 = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain2.forEach(cb => cb(chainIdHex));
3774
3773
  });
3775
3774
  }
3776
3775
 
@@ -28,9 +28,7 @@ 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
-
32
31
  // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
33
-
34
32
  // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
35
33
  class WindowSessionParams extends URLSearchParams {
36
34
  static new(init) {
@@ -129,6 +127,7 @@ class BaseProviderTransport {
129
127
  if (!_this.isOpened()) {
130
128
  await _this.waitUntilOpened(); // will throw on timeout
131
129
  }
130
+
132
131
  const response = await _this.sendMessageRequest({
133
132
  idx: nextMessageIdx(),
134
133
  type: EventType.MESSAGE,
@@ -333,6 +332,7 @@ class BaseProviderTransport {
333
332
  }
334
333
  }, 500); // TODO: be smarter about timer as we're processing the response callbacks..
335
334
  }
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, _window$ue2$sequencew;
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 || (_window$ue2 = _window$ue2.sequencewallettransport) == null ? void 0 : _window$ue2.onmessagefromwallet) === this.onUnrealCallback) {
1361
+ if (((_window$ue2 = window.ue) == null ? void 0 : (_window$ue2$sequencew = _window$ue2.sequencewallettransport) == null ? void 0 : _window$ue2$sequencew.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, _window$ue3$sequencew;
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 || (_window$ue3 = _window$ue3.sequencewallettransport) == null || _window$ue3.sendmessagetowallet(postedMessage);
1417
+ (_window$ue3 = window.ue) == null ? void 0 : (_window$ue3$sequencew = _window$ue3.sequencewallettransport) == null ? void 0 : _window$ue3$sequencew.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 || (_window$ue2 = _window$ue2.sequencewallettransport) == null ? void 0 : _window$ue2.onmessagefromsequencejs) === this.onMessageFromUnreal) {
1500
+ var _window$ue2, _window$ue2$sequencew;
1501
+ if (((_window$ue2 = window.ue) == null ? void 0 : (_window$ue2$sequencew = _window$ue2.sequencewallettransport) == null ? void 0 : _window$ue2$sequencew.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, _window$ue3$sequencew;
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 || (_window$ue3 = _window$ue3.sequencewallettransport) == null || _window$ue3.sendmessagetosequencejs(payload);
1517
+ (_window$ue3 = window.ue) == null ? void 0 : (_window$ue3$sequencew = _window$ue3.sequencewallettransport) == null ? void 0 : _window$ue3$sequencew.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 || _this$walletWindow.close();
1806
+ (_this$walletWindow = this.walletWindow) == null ? void 0 : _this$walletWindow.close();
1807
1807
  }
1808
1808
  sendMessage(message) {
1809
1809
  if (!this.walletWindow) {
@@ -2059,6 +2059,7 @@ 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
+
2062
2063
  if ((_template$unrealTrans = template.unrealTransport) != null && _template$unrealTrans.enabled && template.windowTransport && template.walletAppURL) {
2063
2064
  const unrealMessageProvider = new UnrealMessageProvider(template.walletAppURL);
2064
2065
  muxMessageProvider.add(unrealMessageProvider);
@@ -2786,7 +2787,7 @@ class WalletRequestHandler {
2786
2787
  setConnectOptions(options) {
2787
2788
  var _this$onConnectOption;
2788
2789
  this._connectOptions = options;
2789
- (_this$onConnectOption = this.onConnectOptionsChange) == null || _this$onConnectOption.call(this, options);
2790
+ (_this$onConnectOption = this.onConnectOptionsChange) == null ? void 0 : _this$onConnectOption.call(this, options);
2790
2791
  }
2791
2792
  async setDefaultChainId(chainId) {
2792
2793
  var _this$prompter4;
@@ -2828,7 +2829,7 @@ class WalletRequestHandler {
2828
2829
  if (network) {
2829
2830
  var _session$networks;
2830
2831
  // Delete the isDefaultChain property from the session network
2831
- (_session$networks = session.networks) == null || _session$networks.forEach(n => delete n.isDefaultChain);
2832
+ (_session$networks = session.networks) == null ? void 0 : _session$networks.forEach(n => delete n.isDefaultChain);
2832
2833
 
2833
2834
  // Add the isDefaultChain property to the network with the given networkId
2834
2835
  network.isDefaultChain = true;
@@ -3569,7 +3570,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
3569
3570
 
3570
3571
  var packageJson = {
3571
3572
  name: "@0xsequence/provider",
3572
- version: "0.0.0-20231214172616",
3573
+ version: "0.0.0-20240111142017",
3573
3574
  description: "provider sub-package for Sequence",
3574
3575
  repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
3575
3576
  source: "src/index.ts",
@@ -3697,9 +3698,7 @@ DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
3697
3698
  * and it allows to perform all sequence specific (or write) operations related to the wallet.
3698
3699
  *s
3699
3700
  * It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
3700
- */
3701
-
3702
- // TODO: rename Client to transport.. or something.. like SequenceTransport ..
3701
+ */ // TODO: rename Client to transport.. or something.. like SequenceTransport ..
3703
3702
  class SequenceClient {
3704
3703
  constructor(transport, store, options, projectAccessKey) {
3705
3704
  var _options$defaultEIP;
@@ -3725,12 +3724,12 @@ class SequenceClient {
3725
3724
  if (accounts.length > 1) {
3726
3725
  console.warn('SequenceClient: wallet-webapp returned more than one account');
3727
3726
  }
3728
- (_this$callbacks$accou = this.callbacks.accountsChanged) == null || _this$callbacks$accou.forEach(cb => cb(accounts));
3727
+ (_this$callbacks$accou = this.callbacks.accountsChanged) == null ? void 0 : _this$callbacks$accou.forEach(cb => cb(accounts));
3729
3728
  });
3730
3729
  this.transport.on('connect', response => {
3731
3730
  var _this$callbacks$conne;
3732
3731
  const chainIdHex = ethers.utils.hexValue(this.getChainId());
3733
- (_this$callbacks$conne = this.callbacks.connect) == null || _this$callbacks$conne.forEach(cb => cb(_extends({}, response, {
3732
+ (_this$callbacks$conne = this.callbacks.connect) == null ? void 0 : _this$callbacks$conne.forEach(cb => cb(_extends({}, response, {
3734
3733
  // Ignore the full connect response
3735
3734
  // use the chainId defined locally
3736
3735
  chainId: chainIdHex
@@ -3738,27 +3737,27 @@ class SequenceClient {
3738
3737
  });
3739
3738
  this.transport.on('disconnect', (error, origin) => {
3740
3739
  var _this$callbacks$disco;
3741
- (_this$callbacks$disco = this.callbacks.disconnect) == null || _this$callbacks$disco.forEach(cb => cb(error, origin));
3740
+ (_this$callbacks$disco = this.callbacks.disconnect) == null ? void 0 : _this$callbacks$disco.forEach(cb => cb(error, origin));
3742
3741
  });
3743
3742
  this.transport.on('networks', networks => {
3744
3743
  var _this$callbacks$netwo;
3745
- (_this$callbacks$netwo = this.callbacks.networks) == null || _this$callbacks$netwo.forEach(cb => cb(networks));
3744
+ (_this$callbacks$netwo = this.callbacks.networks) == null ? void 0 : _this$callbacks$netwo.forEach(cb => cb(networks));
3746
3745
  });
3747
3746
  this.transport.on('walletContext', context => {
3748
3747
  var _this$callbacks$walle;
3749
- (_this$callbacks$walle = this.callbacks.walletContext) == null || _this$callbacks$walle.forEach(cb => cb(context));
3748
+ (_this$callbacks$walle = this.callbacks.walletContext) == null ? void 0 : _this$callbacks$walle.forEach(cb => cb(context));
3750
3749
  });
3751
3750
  this.transport.on('open', info => {
3752
3751
  var _this$callbacks$open;
3753
- (_this$callbacks$open = this.callbacks.open) == null || _this$callbacks$open.forEach(cb => cb(info));
3752
+ (_this$callbacks$open = this.callbacks.open) == null ? void 0 : _this$callbacks$open.forEach(cb => cb(info));
3754
3753
  });
3755
3754
  this.transport.on('close', () => {
3756
3755
  var _this$callbacks$close;
3757
- (_this$callbacks$close = this.callbacks.close) == null || _this$callbacks$close.forEach(cb => cb());
3756
+ (_this$callbacks$close = this.callbacks.close) == null ? void 0 : _this$callbacks$close.forEach(cb => cb());
3758
3757
  });
3759
3758
  this.transport.on('chainChanged', (chainIdHex, origin) => {
3760
3759
  var _this$callbacks$chain;
3761
- (_this$callbacks$chain = this.callbacks.chainChanged) == null || _this$callbacks$chain.forEach(cb => cb(chainIdHex, origin));
3760
+ (_this$callbacks$chain = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain.forEach(cb => cb(chainIdHex, origin));
3762
3761
  });
3763
3762
 
3764
3763
  // We don't listen for the transport chainChanged event
@@ -3766,7 +3765,7 @@ class SequenceClient {
3766
3765
  this.defaultChainId.onDefaultChainIdChanged(chainId => {
3767
3766
  var _this$callbacks$chain2;
3768
3767
  const chainIdHex = ethers.utils.hexValue(chainId);
3769
- (_this$callbacks$chain2 = this.callbacks.chainChanged) == null || _this$callbacks$chain2.forEach(cb => cb(chainIdHex));
3768
+ (_this$callbacks$chain2 = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain2.forEach(cb => cb(chainIdHex));
3770
3769
  });
3771
3770
  }
3772
3771
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/provider",
3
- "version": "0.0.0-20231214172616",
3
+ "version": "0.0.0-20240111142017",
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/abi": "0.0.0-20231214172616",
15
- "@0xsequence/account": "0.0.0-20231214172616",
16
- "@0xsequence/auth": "0.0.0-20231214172616",
17
- "@0xsequence/core": "0.0.0-20231214172616",
18
- "@0xsequence/migration": "0.0.0-20231214172616",
19
- "@0xsequence/network": "0.0.0-20231214172616",
20
- "@0xsequence/relayer": "0.0.0-20231214172616",
21
- "@0xsequence/utils": "0.0.0-20231214172616",
22
- "@0xsequence/wallet": "0.0.0-20231214172616"
14
+ "@0xsequence/abi": "0.0.0-20240111142017",
15
+ "@0xsequence/account": "0.0.0-20240111142017",
16
+ "@0xsequence/migration": "0.0.0-20240111142017",
17
+ "@0xsequence/core": "0.0.0-20240111142017",
18
+ "@0xsequence/auth": "0.0.0-20240111142017",
19
+ "@0xsequence/network": "0.0.0-20240111142017",
20
+ "@0xsequence/relayer": "0.0.0-20240111142017",
21
+ "@0xsequence/wallet": "0.0.0-20240111142017",
22
+ "@0xsequence/utils": "0.0.0-20240111142017"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "ethers": ">=5.5 < 6"