@0xsequence/provider 1.2.2 → 1.2.4

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.
@@ -360,7 +360,7 @@ class BaseProviderTransport {
360
360
 
361
361
  // CHAIN_CHANGED -- when a user changes their default chain
362
362
  if (message.type === EventType.CHAIN_CHANGED) {
363
- this.events.emit('chainChanged', message.data);
363
+ this.events.emit('chainChanged', message.data, message.origin);
364
364
  return;
365
365
  }
366
366
 
@@ -949,9 +949,12 @@ class BaseWalletTransport {
949
949
  if (!networks || networks.length === 0) {
950
950
  this.notifyChainChanged('0x0');
951
951
  } else {
952
- this.notifyChainChanged(ethers.ethers.utils.hexlify(networks.find(network => network.isDefaultChain).chainId));
952
+ this.notifyChainChanged(ethers.ethers.utils.hexValue(networks.find(network => network.isDefaultChain).chainId));
953
953
  }
954
954
  });
955
+ this.walletRequestHandler.on('chainChanged', (chainIdHex, origin) => {
956
+ this.notifyChainChanged(chainIdHex, origin);
957
+ });
955
958
  this.walletRequestHandler.on('walletContext', walletContext => {
956
959
  if (!this.registered || !walletContext) return;
957
960
  this.notifyWalletContext(walletContext);
@@ -1021,14 +1024,15 @@ class BaseWalletTransport {
1021
1024
  idx: -1,
1022
1025
  type: EventType.ACCOUNTS_CHANGED,
1023
1026
  data: accounts,
1024
- origin: origin
1027
+ origin
1025
1028
  });
1026
1029
  }
1027
- notifyChainChanged(chainIdHex) {
1030
+ notifyChainChanged(chainIdHex, origin) {
1028
1031
  this.sendMessage({
1029
1032
  idx: -1,
1030
1033
  type: EventType.CHAIN_CHANGED,
1031
- data: chainIdHex
1034
+ data: chainIdHex,
1035
+ origin
1032
1036
  });
1033
1037
  }
1034
1038
  notifyNetworks(networks) {
@@ -2682,7 +2686,8 @@ class WalletRequestHandler {
2682
2686
  const authOptions = {
2683
2687
  app: options.app,
2684
2688
  origin: options.origin,
2685
- expiry: options.expiry
2689
+ expiry: options.expiry,
2690
+ nonce: options.authorizeNonce
2686
2691
  };
2687
2692
  // if (typeof(options.authorize) === 'object') {
2688
2693
  // authOptions = { ...authOptions, ...options.authorize }
@@ -2808,13 +2813,16 @@ class WalletRequestHandler {
2808
2813
  this.events.emit('accountsChanged', [], origin);
2809
2814
  this.events.emit('disconnect');
2810
2815
  }
2816
+ notifyChainChanged(chainId, origin) {
2817
+ this.events.emit('chainChanged', ethers.ethers.utils.hexValue(chainId), origin);
2818
+ }
2811
2819
  async notifyNetworks(networks) {
2812
2820
  const n = networks || (await this.getNetworks(true));
2813
2821
  this.events.emit('networks', n);
2814
2822
  if (n.length > 0) {
2815
2823
  const defaultNetwork = n.find(network => network.chainId === this.defaultChainId());
2816
2824
  if (defaultNetwork) {
2817
- this.events.emit('chainChanged', ethers.ethers.utils.hexlify(defaultNetwork.chainId));
2825
+ this.events.emit('chainChanged', ethers.ethers.utils.hexValue(defaultNetwork.chainId));
2818
2826
  }
2819
2827
  } else {
2820
2828
  this.events.emit('chainChanged', '0x0');
@@ -3523,7 +3531,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
3523
3531
 
3524
3532
  var packageJson = {
3525
3533
  name: "@0xsequence/provider",
3526
- version: "1.2.2",
3534
+ version: "1.2.4",
3527
3535
  description: "provider sub-package for Sequence",
3528
3536
  repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
3529
3537
  source: "src/index.ts",
@@ -3703,13 +3711,17 @@ class SequenceClient {
3703
3711
  var _this$callbacks$close;
3704
3712
  (_this$callbacks$close = this.callbacks.close) == null ? void 0 : _this$callbacks$close.forEach(cb => cb());
3705
3713
  });
3714
+ this.transport.on('chainChanged', (chainIdHex, origin) => {
3715
+ var _this$callbacks$chain;
3716
+ (_this$callbacks$chain = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain.forEach(cb => cb(chainIdHex, origin));
3717
+ });
3706
3718
 
3707
3719
  // We don't listen for the transport chainChanged event
3708
3720
  // instead we handle it locally, so we listen for changes in the store
3709
3721
  this.defaultChainId.onDefaultChainIdChanged(chainId => {
3710
- var _this$callbacks$chain;
3722
+ var _this$callbacks$chain2;
3711
3723
  const chainIdHex = ethers.ethers.utils.hexValue(chainId);
3712
- (_this$callbacks$chain = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain.forEach(cb => cb(chainIdHex));
3724
+ (_this$callbacks$chain2 = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain2.forEach(cb => cb(chainIdHex));
3713
3725
  });
3714
3726
  }
3715
3727
 
@@ -3750,6 +3762,9 @@ class SequenceClient {
3750
3762
  onWalletContext(callback) {
3751
3763
  return this.registerCallback('walletContext', callback);
3752
3764
  }
3765
+ onChainChanged(callback) {
3766
+ return this.registerCallback('chainChanged', callback);
3767
+ }
3753
3768
  onDefaultChainIdChanged(callback) {
3754
3769
  return this.registerCallback('chainChanged', callback);
3755
3770
  }
@@ -360,7 +360,7 @@ class BaseProviderTransport {
360
360
 
361
361
  // CHAIN_CHANGED -- when a user changes their default chain
362
362
  if (message.type === EventType.CHAIN_CHANGED) {
363
- this.events.emit('chainChanged', message.data);
363
+ this.events.emit('chainChanged', message.data, message.origin);
364
364
  return;
365
365
  }
366
366
 
@@ -949,9 +949,12 @@ class BaseWalletTransport {
949
949
  if (!networks || networks.length === 0) {
950
950
  this.notifyChainChanged('0x0');
951
951
  } else {
952
- this.notifyChainChanged(ethers.ethers.utils.hexlify(networks.find(network => network.isDefaultChain).chainId));
952
+ this.notifyChainChanged(ethers.ethers.utils.hexValue(networks.find(network => network.isDefaultChain).chainId));
953
953
  }
954
954
  });
955
+ this.walletRequestHandler.on('chainChanged', (chainIdHex, origin) => {
956
+ this.notifyChainChanged(chainIdHex, origin);
957
+ });
955
958
  this.walletRequestHandler.on('walletContext', walletContext => {
956
959
  if (!this.registered || !walletContext) return;
957
960
  this.notifyWalletContext(walletContext);
@@ -1021,14 +1024,15 @@ class BaseWalletTransport {
1021
1024
  idx: -1,
1022
1025
  type: EventType.ACCOUNTS_CHANGED,
1023
1026
  data: accounts,
1024
- origin: origin
1027
+ origin
1025
1028
  });
1026
1029
  }
1027
- notifyChainChanged(chainIdHex) {
1030
+ notifyChainChanged(chainIdHex, origin) {
1028
1031
  this.sendMessage({
1029
1032
  idx: -1,
1030
1033
  type: EventType.CHAIN_CHANGED,
1031
- data: chainIdHex
1034
+ data: chainIdHex,
1035
+ origin
1032
1036
  });
1033
1037
  }
1034
1038
  notifyNetworks(networks) {
@@ -2682,7 +2686,8 @@ class WalletRequestHandler {
2682
2686
  const authOptions = {
2683
2687
  app: options.app,
2684
2688
  origin: options.origin,
2685
- expiry: options.expiry
2689
+ expiry: options.expiry,
2690
+ nonce: options.authorizeNonce
2686
2691
  };
2687
2692
  // if (typeof(options.authorize) === 'object') {
2688
2693
  // authOptions = { ...authOptions, ...options.authorize }
@@ -2808,13 +2813,16 @@ class WalletRequestHandler {
2808
2813
  this.events.emit('accountsChanged', [], origin);
2809
2814
  this.events.emit('disconnect');
2810
2815
  }
2816
+ notifyChainChanged(chainId, origin) {
2817
+ this.events.emit('chainChanged', ethers.ethers.utils.hexValue(chainId), origin);
2818
+ }
2811
2819
  async notifyNetworks(networks) {
2812
2820
  const n = networks || (await this.getNetworks(true));
2813
2821
  this.events.emit('networks', n);
2814
2822
  if (n.length > 0) {
2815
2823
  const defaultNetwork = n.find(network => network.chainId === this.defaultChainId());
2816
2824
  if (defaultNetwork) {
2817
- this.events.emit('chainChanged', ethers.ethers.utils.hexlify(defaultNetwork.chainId));
2825
+ this.events.emit('chainChanged', ethers.ethers.utils.hexValue(defaultNetwork.chainId));
2818
2826
  }
2819
2827
  } else {
2820
2828
  this.events.emit('chainChanged', '0x0');
@@ -3523,7 +3531,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
3523
3531
 
3524
3532
  var packageJson = {
3525
3533
  name: "@0xsequence/provider",
3526
- version: "1.2.2",
3534
+ version: "1.2.4",
3527
3535
  description: "provider sub-package for Sequence",
3528
3536
  repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
3529
3537
  source: "src/index.ts",
@@ -3703,13 +3711,17 @@ class SequenceClient {
3703
3711
  var _this$callbacks$close;
3704
3712
  (_this$callbacks$close = this.callbacks.close) == null ? void 0 : _this$callbacks$close.forEach(cb => cb());
3705
3713
  });
3714
+ this.transport.on('chainChanged', (chainIdHex, origin) => {
3715
+ var _this$callbacks$chain;
3716
+ (_this$callbacks$chain = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain.forEach(cb => cb(chainIdHex, origin));
3717
+ });
3706
3718
 
3707
3719
  // We don't listen for the transport chainChanged event
3708
3720
  // instead we handle it locally, so we listen for changes in the store
3709
3721
  this.defaultChainId.onDefaultChainIdChanged(chainId => {
3710
- var _this$callbacks$chain;
3722
+ var _this$callbacks$chain2;
3711
3723
  const chainIdHex = ethers.ethers.utils.hexValue(chainId);
3712
- (_this$callbacks$chain = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain.forEach(cb => cb(chainIdHex));
3724
+ (_this$callbacks$chain2 = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain2.forEach(cb => cb(chainIdHex));
3713
3725
  });
3714
3726
  }
3715
3727
 
@@ -3750,6 +3762,9 @@ class SequenceClient {
3750
3762
  onWalletContext(callback) {
3751
3763
  return this.registerCallback('walletContext', callback);
3752
3764
  }
3765
+ onChainChanged(callback) {
3766
+ return this.registerCallback('chainChanged', callback);
3767
+ }
3753
3768
  onDefaultChainIdChanged(callback) {
3754
3769
  return this.registerCallback('chainChanged', callback);
3755
3770
  }
@@ -356,7 +356,7 @@ class BaseProviderTransport {
356
356
 
357
357
  // CHAIN_CHANGED -- when a user changes their default chain
358
358
  if (message.type === EventType.CHAIN_CHANGED) {
359
- this.events.emit('chainChanged', message.data);
359
+ this.events.emit('chainChanged', message.data, message.origin);
360
360
  return;
361
361
  }
362
362
 
@@ -945,9 +945,12 @@ class BaseWalletTransport {
945
945
  if (!networks || networks.length === 0) {
946
946
  this.notifyChainChanged('0x0');
947
947
  } else {
948
- this.notifyChainChanged(ethers.utils.hexlify(networks.find(network => network.isDefaultChain).chainId));
948
+ this.notifyChainChanged(ethers.utils.hexValue(networks.find(network => network.isDefaultChain).chainId));
949
949
  }
950
950
  });
951
+ this.walletRequestHandler.on('chainChanged', (chainIdHex, origin) => {
952
+ this.notifyChainChanged(chainIdHex, origin);
953
+ });
951
954
  this.walletRequestHandler.on('walletContext', walletContext => {
952
955
  if (!this.registered || !walletContext) return;
953
956
  this.notifyWalletContext(walletContext);
@@ -1017,14 +1020,15 @@ class BaseWalletTransport {
1017
1020
  idx: -1,
1018
1021
  type: EventType.ACCOUNTS_CHANGED,
1019
1022
  data: accounts,
1020
- origin: origin
1023
+ origin
1021
1024
  });
1022
1025
  }
1023
- notifyChainChanged(chainIdHex) {
1026
+ notifyChainChanged(chainIdHex, origin) {
1024
1027
  this.sendMessage({
1025
1028
  idx: -1,
1026
1029
  type: EventType.CHAIN_CHANGED,
1027
- data: chainIdHex
1030
+ data: chainIdHex,
1031
+ origin
1028
1032
  });
1029
1033
  }
1030
1034
  notifyNetworks(networks) {
@@ -2678,7 +2682,8 @@ class WalletRequestHandler {
2678
2682
  const authOptions = {
2679
2683
  app: options.app,
2680
2684
  origin: options.origin,
2681
- expiry: options.expiry
2685
+ expiry: options.expiry,
2686
+ nonce: options.authorizeNonce
2682
2687
  };
2683
2688
  // if (typeof(options.authorize) === 'object') {
2684
2689
  // authOptions = { ...authOptions, ...options.authorize }
@@ -2804,13 +2809,16 @@ class WalletRequestHandler {
2804
2809
  this.events.emit('accountsChanged', [], origin);
2805
2810
  this.events.emit('disconnect');
2806
2811
  }
2812
+ notifyChainChanged(chainId, origin) {
2813
+ this.events.emit('chainChanged', ethers.utils.hexValue(chainId), origin);
2814
+ }
2807
2815
  async notifyNetworks(networks) {
2808
2816
  const n = networks || (await this.getNetworks(true));
2809
2817
  this.events.emit('networks', n);
2810
2818
  if (n.length > 0) {
2811
2819
  const defaultNetwork = n.find(network => network.chainId === this.defaultChainId());
2812
2820
  if (defaultNetwork) {
2813
- this.events.emit('chainChanged', ethers.utils.hexlify(defaultNetwork.chainId));
2821
+ this.events.emit('chainChanged', ethers.utils.hexValue(defaultNetwork.chainId));
2814
2822
  }
2815
2823
  } else {
2816
2824
  this.events.emit('chainChanged', '0x0');
@@ -3519,7 +3527,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
3519
3527
 
3520
3528
  var packageJson = {
3521
3529
  name: "@0xsequence/provider",
3522
- version: "1.2.2",
3530
+ version: "1.2.4",
3523
3531
  description: "provider sub-package for Sequence",
3524
3532
  repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
3525
3533
  source: "src/index.ts",
@@ -3699,13 +3707,17 @@ class SequenceClient {
3699
3707
  var _this$callbacks$close;
3700
3708
  (_this$callbacks$close = this.callbacks.close) == null ? void 0 : _this$callbacks$close.forEach(cb => cb());
3701
3709
  });
3710
+ this.transport.on('chainChanged', (chainIdHex, origin) => {
3711
+ var _this$callbacks$chain;
3712
+ (_this$callbacks$chain = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain.forEach(cb => cb(chainIdHex, origin));
3713
+ });
3702
3714
 
3703
3715
  // We don't listen for the transport chainChanged event
3704
3716
  // instead we handle it locally, so we listen for changes in the store
3705
3717
  this.defaultChainId.onDefaultChainIdChanged(chainId => {
3706
- var _this$callbacks$chain;
3718
+ var _this$callbacks$chain2;
3707
3719
  const chainIdHex = ethers.utils.hexValue(chainId);
3708
- (_this$callbacks$chain = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain.forEach(cb => cb(chainIdHex));
3720
+ (_this$callbacks$chain2 = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain2.forEach(cb => cb(chainIdHex));
3709
3721
  });
3710
3722
  }
3711
3723
 
@@ -3746,6 +3758,9 @@ class SequenceClient {
3746
3758
  onWalletContext(callback) {
3747
3759
  return this.registerCallback('walletContext', callback);
3748
3760
  }
3761
+ onChainChanged(callback) {
3762
+ return this.registerCallback('chainChanged', callback);
3763
+ }
3749
3764
  onDefaultChainIdChanged(callback) {
3750
3765
  return this.registerCallback('chainChanged', callback);
3751
3766
  }
@@ -58,6 +58,7 @@ export declare class SequenceClient {
58
58
  onNetworks(callback: WalletEventTypes['networks']): () => void;
59
59
  onAccountsChanged(callback: WalletEventTypes['accountsChanged']): () => void;
60
60
  onWalletContext(callback: WalletEventTypes['walletContext']): () => void;
61
+ onChainChanged(callback: WalletEventTypes['chainChanged']): () => void;
61
62
  onDefaultChainIdChanged(callback: WalletEventTypes['chainChanged']): () => void;
62
63
  getChainId(): number;
63
64
  setDefaultChainId(chainId: number): void;
@@ -28,7 +28,7 @@ export declare abstract class BaseWalletTransport implements WalletTransport {
28
28
  notifyConnect(connectDetails: ConnectDetails): void;
29
29
  notifyDisconnect(error?: ProviderRpcError): void;
30
30
  notifyAccountsChanged(accounts: string[], origin?: string): void;
31
- notifyChainChanged(chainIdHex: string): void;
31
+ notifyChainChanged(chainIdHex: string, origin?: string): void;
32
32
  notifyNetworks(networks: NetworkConfig[]): void;
33
33
  notifyWalletContext(walletContext: commons.context.VersionedContext): void;
34
34
  protected isValidInitAck(message: ProviderMessage<any>): boolean;
@@ -39,6 +39,7 @@ export declare class WalletRequestHandler implements ExternalProvider, JsonRpcHa
39
39
  walletSession(networkId?: ChainIdLike): WalletSession | undefined;
40
40
  notifyConnect(connectDetails: ConnectDetails, origin?: string): void;
41
41
  notifyDisconnect(origin?: string): void;
42
+ notifyChainChanged(chainId: number, origin?: string): void;
42
43
  notifyNetworks(networks?: NetworkConfig[]): Promise<void>;
43
44
  notifyWalletContext(): Promise<void>;
44
45
  notifyClose(error?: ProviderRpcError): void;
@@ -86,7 +86,7 @@ export interface WalletEventTypes {
86
86
  connect: (connectDetails: ConnectDetails) => void;
87
87
  disconnect: (error?: ProviderRpcError) => void;
88
88
  accountsChanged: (accounts: string[], origin?: string) => void;
89
- chainChanged: (chainIdHex: string) => void;
89
+ chainChanged: (chainIdHex: string, origin?: string) => void;
90
90
  networks: (networks: NetworkConfig[]) => void;
91
91
  walletContext: (walletContext: commons.context.VersionedContext) => void;
92
92
  }
@@ -115,6 +115,8 @@ export interface ConnectOptions {
115
115
  expiry?: number;
116
116
  /** authorize will perform an ETHAuth eip712 signing and return the proof to the dapp. */
117
117
  authorize?: boolean;
118
+ /** authorizeNonce is an optional number to be passed as ETHAuth's nonce claim for replay protection. **/
119
+ authorizeNonce?: number;
118
120
  /** authorizeVersion is the version of the SDK that will validate the ETHAuth proof. */
119
121
  authorizeVersion?: number;
120
122
  /** askForEmail will prompt to give permission to the dapp to access email address */
@@ -189,7 +191,7 @@ export interface Settings {
189
191
  * you can use the camel case version of the name in the wallet settings.
190
192
  * For example: "Blue Dark" on wallet UI can be passed as "blueDark" */
191
193
  export type ThemeOption = 'light' | 'dark' | string;
192
- export type PaymentProviderOption = 'moonpay' | 'wyre' | 'ramp';
194
+ export type PaymentProviderOption = 'ramp' | 'moonpay' | 'transak' | 'onmeta' | 'paytrie' | 'sardine';
193
195
  export type CurrencyOption = 'usdc' | 'eth' | 'matic';
194
196
  export type SignInOption = 'email' | 'google' | 'apple' | 'facebook' | 'discord' | 'twitch';
195
197
  export type BannerSize = 'small' | 'medium';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/provider",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
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": "1.2.2",
15
- "@0xsequence/migration": "1.2.2",
16
- "@0xsequence/auth": "1.2.2",
17
- "@0xsequence/account": "1.2.2",
18
- "@0xsequence/core": "1.2.2",
19
- "@0xsequence/network": "1.2.2",
20
- "@0xsequence/relayer": "1.2.2",
21
- "@0xsequence/utils": "1.2.2",
22
- "@0xsequence/wallet": "1.2.2"
14
+ "@0xsequence/abi": "1.2.4",
15
+ "@0xsequence/account": "1.2.4",
16
+ "@0xsequence/auth": "1.2.4",
17
+ "@0xsequence/core": "1.2.4",
18
+ "@0xsequence/migration": "1.2.4",
19
+ "@0xsequence/relayer": "1.2.4",
20
+ "@0xsequence/network": "1.2.4",
21
+ "@0xsequence/utils": "1.2.4",
22
+ "@0xsequence/wallet": "1.2.4"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "ethers": ">=5.5 < 6"
package/src/client.ts CHANGED
@@ -189,6 +189,10 @@ export class SequenceClient {
189
189
  this.callbacks.close?.forEach(cb => cb())
190
190
  })
191
191
 
192
+ this.transport.on('chainChanged', (chainIdHex, origin) => {
193
+ this.callbacks.chainChanged?.forEach(cb => cb(chainIdHex, origin))
194
+ })
195
+
192
196
  // We don't listen for the transport chainChanged event
193
197
  // instead we handle it locally, so we listen for changes in the store
194
198
  this.defaultChainId.onDefaultChainIdChanged((chainId: number) => {
@@ -242,6 +246,10 @@ export class SequenceClient {
242
246
  return this.registerCallback('walletContext', callback)
243
247
  }
244
248
 
249
+ onChainChanged(callback: WalletEventTypes['chainChanged']) {
250
+ return this.registerCallback('chainChanged', callback)
251
+ }
252
+
245
253
  onDefaultChainIdChanged(callback: WalletEventTypes['chainChanged']) {
246
254
  return this.registerCallback('chainChanged', callback)
247
255
  }
@@ -240,7 +240,7 @@ export abstract class BaseProviderTransport implements ProviderTransport {
240
240
 
241
241
  // CHAIN_CHANGED -- when a user changes their default chain
242
242
  if (message.type === EventType.CHAIN_CHANGED) {
243
- this.events.emit('chainChanged', message.data)
243
+ this.events.emit('chainChanged', message.data, message.origin)
244
244
  return
245
245
  }
246
246
 
@@ -65,10 +65,14 @@ export abstract class BaseWalletTransport implements WalletTransport {
65
65
  if (!networks || networks.length === 0) {
66
66
  this.notifyChainChanged('0x0')
67
67
  } else {
68
- this.notifyChainChanged(ethers.utils.hexlify(networks.find(network => network.isDefaultChain)!.chainId))
68
+ this.notifyChainChanged(ethers.utils.hexValue(networks.find(network => network.isDefaultChain)!.chainId))
69
69
  }
70
70
  })
71
71
 
72
+ this.walletRequestHandler.on('chainChanged', (chainIdHex: string, origin?: string) => {
73
+ this.notifyChainChanged(chainIdHex, origin)
74
+ })
75
+
72
76
  this.walletRequestHandler.on('walletContext', (walletContext: commons.context.VersionedContext) => {
73
77
  if (!this.registered || !walletContext) return
74
78
  this.notifyWalletContext(walletContext)
@@ -210,15 +214,16 @@ export abstract class BaseWalletTransport implements WalletTransport {
210
214
  idx: -1,
211
215
  type: EventType.ACCOUNTS_CHANGED,
212
216
  data: accounts,
213
- origin: origin
217
+ origin
214
218
  })
215
219
  }
216
220
 
217
- notifyChainChanged(chainIdHex: string) {
221
+ notifyChainChanged(chainIdHex: string, origin?: string) {
218
222
  this.sendMessage({
219
223
  idx: -1,
220
224
  type: EventType.CHAIN_CHANGED,
221
- data: chainIdHex
225
+ data: chainIdHex,
226
+ origin
222
227
  })
223
228
  }
224
229
 
@@ -159,7 +159,8 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
159
159
  const authOptions: AuthorizationOptions = {
160
160
  app: options.app,
161
161
  origin: options.origin,
162
- expiry: options.expiry
162
+ expiry: options.expiry,
163
+ nonce: options.authorizeNonce
163
164
  }
164
165
  // if (typeof(options.authorize) === 'object') {
165
166
  // authOptions = { ...authOptions, ...options.authorize }
@@ -770,13 +771,17 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
770
771
  this.events.emit('disconnect')
771
772
  }
772
773
 
774
+ notifyChainChanged(chainId: number, origin?: string) {
775
+ this.events.emit('chainChanged', ethers.utils.hexValue(chainId), origin)
776
+ }
777
+
773
778
  async notifyNetworks(networks?: NetworkConfig[]) {
774
779
  const n = networks || (await this.getNetworks(true))
775
780
  this.events.emit('networks', n)
776
781
  if (n.length > 0) {
777
782
  const defaultNetwork = n.find(network => network.chainId === this.defaultChainId())
778
783
  if (defaultNetwork) {
779
- this.events.emit('chainChanged', ethers.utils.hexlify(defaultNetwork.chainId))
784
+ this.events.emit('chainChanged', ethers.utils.hexValue(defaultNetwork.chainId))
780
785
  }
781
786
  } else {
782
787
  this.events.emit('chainChanged', '0x0')
package/src/types.ts CHANGED
@@ -132,7 +132,7 @@ export interface WalletEventTypes {
132
132
  disconnect: (error?: ProviderRpcError) => void
133
133
 
134
134
  accountsChanged: (accounts: string[], origin?: string) => void
135
- chainChanged: (chainIdHex: string) => void
135
+ chainChanged: (chainIdHex: string, origin?: string) => void
136
136
 
137
137
  networks: (networks: NetworkConfig[]) => void
138
138
  walletContext: (walletContext: commons.context.VersionedContext) => void
@@ -171,6 +171,9 @@ export interface ConnectOptions {
171
171
  /** authorize will perform an ETHAuth eip712 signing and return the proof to the dapp. */
172
172
  authorize?: boolean
173
173
 
174
+ /** authorizeNonce is an optional number to be passed as ETHAuth's nonce claim for replay protection. **/
175
+ authorizeNonce?: number
176
+
174
177
  /** authorizeVersion is the version of the SDK that will validate the ETHAuth proof. */
175
178
  authorizeVersion?: number
176
179
 
@@ -263,7 +266,7 @@ export interface Settings {
263
266
  * you can use the camel case version of the name in the wallet settings.
264
267
  * For example: "Blue Dark" on wallet UI can be passed as "blueDark" */
265
268
  export type ThemeOption = 'light' | 'dark' | string
266
- export type PaymentProviderOption = 'moonpay' | 'wyre' | 'ramp'
269
+ export type PaymentProviderOption = 'ramp' | 'moonpay' | 'transak' | 'onmeta' | 'paytrie' | 'sardine'
267
270
  export type CurrencyOption = 'usdc' | 'eth' | 'matic'
268
271
  export type SignInOption = 'email' | 'google' | 'apple' | 'facebook' | 'discord' | 'twitch'
269
272
  export type BannerSize = 'small' | 'medium' // | 'large'