@0xsequence/provider 1.2.3 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/0xsequence-provider.cjs.dev.js +32 -17
- package/dist/0xsequence-provider.cjs.prod.js +32 -17
- package/dist/0xsequence-provider.esm.js +32 -17
- package/dist/declarations/src/client.d.ts +1 -0
- package/dist/declarations/src/transports/base-wallet-transport.d.ts +2 -2
- package/dist/declarations/src/transports/wallet-request-handler.d.ts +1 -0
- package/dist/declarations/src/types.d.ts +4 -5
- package/package.json +10 -10
- package/src/client.ts +10 -2
- package/src/transports/base-provider-transport.ts +2 -2
- package/src/transports/base-wallet-transport.ts +14 -8
- package/src/transports/wallet-request-handler.ts +6 -2
- package/src/types.ts +4 -5
|
@@ -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
|
|
|
@@ -394,7 +394,7 @@ class BaseProviderTransport {
|
|
|
394
394
|
// NOTIFY DISCONNECT -- when wallet instructs to disconnect
|
|
395
395
|
if (message.type === EventType.DISCONNECT) {
|
|
396
396
|
if (this.isConnected()) {
|
|
397
|
-
this.events.emit('disconnect', message.data);
|
|
397
|
+
this.events.emit('disconnect', message.data, message.origin);
|
|
398
398
|
this.close();
|
|
399
399
|
}
|
|
400
400
|
}
|
|
@@ -934,10 +934,10 @@ class BaseWalletTransport {
|
|
|
934
934
|
// means user has logged in and wallet is connected to the app
|
|
935
935
|
this.notifyConnect(connectDetails);
|
|
936
936
|
});
|
|
937
|
-
this.walletRequestHandler.on('disconnect', error => {
|
|
937
|
+
this.walletRequestHandler.on('disconnect', (error, origin) => {
|
|
938
938
|
if (!this.registered) return;
|
|
939
939
|
// means user has logged out the app / disconnected wallet from the app
|
|
940
|
-
this.notifyDisconnect(error);
|
|
940
|
+
this.notifyDisconnect(error, origin);
|
|
941
941
|
});
|
|
942
942
|
this.walletRequestHandler.on('accountsChanged', (accounts, origin) => {
|
|
943
943
|
if (!this.registered) return;
|
|
@@ -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.
|
|
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);
|
|
@@ -1007,13 +1010,14 @@ class BaseWalletTransport {
|
|
|
1007
1010
|
data: connectDetails
|
|
1008
1011
|
});
|
|
1009
1012
|
}
|
|
1010
|
-
notifyDisconnect(error) {
|
|
1013
|
+
notifyDisconnect(error, origin) {
|
|
1011
1014
|
this.sendMessage({
|
|
1012
1015
|
idx: -1,
|
|
1013
1016
|
type: EventType.DISCONNECT,
|
|
1014
1017
|
data: error ? {
|
|
1015
1018
|
error
|
|
1016
|
-
} : null
|
|
1019
|
+
} : null,
|
|
1020
|
+
origin
|
|
1017
1021
|
});
|
|
1018
1022
|
}
|
|
1019
1023
|
notifyAccountsChanged(accounts, origin) {
|
|
@@ -1021,14 +1025,15 @@ class BaseWalletTransport {
|
|
|
1021
1025
|
idx: -1,
|
|
1022
1026
|
type: EventType.ACCOUNTS_CHANGED,
|
|
1023
1027
|
data: accounts,
|
|
1024
|
-
origin
|
|
1028
|
+
origin
|
|
1025
1029
|
});
|
|
1026
1030
|
}
|
|
1027
|
-
notifyChainChanged(chainIdHex) {
|
|
1031
|
+
notifyChainChanged(chainIdHex, origin) {
|
|
1028
1032
|
this.sendMessage({
|
|
1029
1033
|
idx: -1,
|
|
1030
1034
|
type: EventType.CHAIN_CHANGED,
|
|
1031
|
-
data: chainIdHex
|
|
1035
|
+
data: chainIdHex,
|
|
1036
|
+
origin
|
|
1032
1037
|
});
|
|
1033
1038
|
}
|
|
1034
1039
|
notifyNetworks(networks) {
|
|
@@ -2807,7 +2812,10 @@ class WalletRequestHandler {
|
|
|
2807
2812
|
}
|
|
2808
2813
|
notifyDisconnect(origin) {
|
|
2809
2814
|
this.events.emit('accountsChanged', [], origin);
|
|
2810
|
-
this.events.emit('disconnect');
|
|
2815
|
+
this.events.emit('disconnect', undefined, origin);
|
|
2816
|
+
}
|
|
2817
|
+
notifyChainChanged(chainId, origin) {
|
|
2818
|
+
this.events.emit('chainChanged', ethers.ethers.utils.hexValue(chainId), origin);
|
|
2811
2819
|
}
|
|
2812
2820
|
async notifyNetworks(networks) {
|
|
2813
2821
|
const n = networks || (await this.getNetworks(true));
|
|
@@ -2815,7 +2823,7 @@ class WalletRequestHandler {
|
|
|
2815
2823
|
if (n.length > 0) {
|
|
2816
2824
|
const defaultNetwork = n.find(network => network.chainId === this.defaultChainId());
|
|
2817
2825
|
if (defaultNetwork) {
|
|
2818
|
-
this.events.emit('chainChanged', ethers.ethers.utils.
|
|
2826
|
+
this.events.emit('chainChanged', ethers.ethers.utils.hexValue(defaultNetwork.chainId));
|
|
2819
2827
|
}
|
|
2820
2828
|
} else {
|
|
2821
2829
|
this.events.emit('chainChanged', '0x0');
|
|
@@ -3524,7 +3532,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
|
|
|
3524
3532
|
|
|
3525
3533
|
var packageJson = {
|
|
3526
3534
|
name: "@0xsequence/provider",
|
|
3527
|
-
version: "1.2.
|
|
3535
|
+
version: "1.2.6",
|
|
3528
3536
|
description: "provider sub-package for Sequence",
|
|
3529
3537
|
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3530
3538
|
source: "src/index.ts",
|
|
@@ -3684,9 +3692,9 @@ class SequenceClient {
|
|
|
3684
3692
|
chainId: chainIdHex
|
|
3685
3693
|
})));
|
|
3686
3694
|
});
|
|
3687
|
-
this.transport.on('disconnect', error => {
|
|
3695
|
+
this.transport.on('disconnect', (error, origin) => {
|
|
3688
3696
|
var _this$callbacks$disco;
|
|
3689
|
-
(_this$callbacks$disco = this.callbacks.disconnect) == null ? void 0 : _this$callbacks$disco.forEach(cb => cb(error));
|
|
3697
|
+
(_this$callbacks$disco = this.callbacks.disconnect) == null ? void 0 : _this$callbacks$disco.forEach(cb => cb(error, origin));
|
|
3690
3698
|
});
|
|
3691
3699
|
this.transport.on('networks', networks => {
|
|
3692
3700
|
var _this$callbacks$netwo;
|
|
@@ -3704,13 +3712,17 @@ class SequenceClient {
|
|
|
3704
3712
|
var _this$callbacks$close;
|
|
3705
3713
|
(_this$callbacks$close = this.callbacks.close) == null ? void 0 : _this$callbacks$close.forEach(cb => cb());
|
|
3706
3714
|
});
|
|
3715
|
+
this.transport.on('chainChanged', (chainIdHex, origin) => {
|
|
3716
|
+
var _this$callbacks$chain;
|
|
3717
|
+
(_this$callbacks$chain = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain.forEach(cb => cb(chainIdHex, origin));
|
|
3718
|
+
});
|
|
3707
3719
|
|
|
3708
3720
|
// We don't listen for the transport chainChanged event
|
|
3709
3721
|
// instead we handle it locally, so we listen for changes in the store
|
|
3710
3722
|
this.defaultChainId.onDefaultChainIdChanged(chainId => {
|
|
3711
|
-
var _this$callbacks$
|
|
3723
|
+
var _this$callbacks$chain2;
|
|
3712
3724
|
const chainIdHex = ethers.ethers.utils.hexValue(chainId);
|
|
3713
|
-
(_this$callbacks$
|
|
3725
|
+
(_this$callbacks$chain2 = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain2.forEach(cb => cb(chainIdHex));
|
|
3714
3726
|
});
|
|
3715
3727
|
}
|
|
3716
3728
|
|
|
@@ -3751,6 +3763,9 @@ class SequenceClient {
|
|
|
3751
3763
|
onWalletContext(callback) {
|
|
3752
3764
|
return this.registerCallback('walletContext', callback);
|
|
3753
3765
|
}
|
|
3766
|
+
onChainChanged(callback) {
|
|
3767
|
+
return this.registerCallback('chainChanged', callback);
|
|
3768
|
+
}
|
|
3754
3769
|
onDefaultChainIdChanged(callback) {
|
|
3755
3770
|
return this.registerCallback('chainChanged', callback);
|
|
3756
3771
|
}
|
|
@@ -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
|
|
|
@@ -394,7 +394,7 @@ class BaseProviderTransport {
|
|
|
394
394
|
// NOTIFY DISCONNECT -- when wallet instructs to disconnect
|
|
395
395
|
if (message.type === EventType.DISCONNECT) {
|
|
396
396
|
if (this.isConnected()) {
|
|
397
|
-
this.events.emit('disconnect', message.data);
|
|
397
|
+
this.events.emit('disconnect', message.data, message.origin);
|
|
398
398
|
this.close();
|
|
399
399
|
}
|
|
400
400
|
}
|
|
@@ -934,10 +934,10 @@ class BaseWalletTransport {
|
|
|
934
934
|
// means user has logged in and wallet is connected to the app
|
|
935
935
|
this.notifyConnect(connectDetails);
|
|
936
936
|
});
|
|
937
|
-
this.walletRequestHandler.on('disconnect', error => {
|
|
937
|
+
this.walletRequestHandler.on('disconnect', (error, origin) => {
|
|
938
938
|
if (!this.registered) return;
|
|
939
939
|
// means user has logged out the app / disconnected wallet from the app
|
|
940
|
-
this.notifyDisconnect(error);
|
|
940
|
+
this.notifyDisconnect(error, origin);
|
|
941
941
|
});
|
|
942
942
|
this.walletRequestHandler.on('accountsChanged', (accounts, origin) => {
|
|
943
943
|
if (!this.registered) return;
|
|
@@ -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.
|
|
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);
|
|
@@ -1007,13 +1010,14 @@ class BaseWalletTransport {
|
|
|
1007
1010
|
data: connectDetails
|
|
1008
1011
|
});
|
|
1009
1012
|
}
|
|
1010
|
-
notifyDisconnect(error) {
|
|
1013
|
+
notifyDisconnect(error, origin) {
|
|
1011
1014
|
this.sendMessage({
|
|
1012
1015
|
idx: -1,
|
|
1013
1016
|
type: EventType.DISCONNECT,
|
|
1014
1017
|
data: error ? {
|
|
1015
1018
|
error
|
|
1016
|
-
} : null
|
|
1019
|
+
} : null,
|
|
1020
|
+
origin
|
|
1017
1021
|
});
|
|
1018
1022
|
}
|
|
1019
1023
|
notifyAccountsChanged(accounts, origin) {
|
|
@@ -1021,14 +1025,15 @@ class BaseWalletTransport {
|
|
|
1021
1025
|
idx: -1,
|
|
1022
1026
|
type: EventType.ACCOUNTS_CHANGED,
|
|
1023
1027
|
data: accounts,
|
|
1024
|
-
origin
|
|
1028
|
+
origin
|
|
1025
1029
|
});
|
|
1026
1030
|
}
|
|
1027
|
-
notifyChainChanged(chainIdHex) {
|
|
1031
|
+
notifyChainChanged(chainIdHex, origin) {
|
|
1028
1032
|
this.sendMessage({
|
|
1029
1033
|
idx: -1,
|
|
1030
1034
|
type: EventType.CHAIN_CHANGED,
|
|
1031
|
-
data: chainIdHex
|
|
1035
|
+
data: chainIdHex,
|
|
1036
|
+
origin
|
|
1032
1037
|
});
|
|
1033
1038
|
}
|
|
1034
1039
|
notifyNetworks(networks) {
|
|
@@ -2807,7 +2812,10 @@ class WalletRequestHandler {
|
|
|
2807
2812
|
}
|
|
2808
2813
|
notifyDisconnect(origin) {
|
|
2809
2814
|
this.events.emit('accountsChanged', [], origin);
|
|
2810
|
-
this.events.emit('disconnect');
|
|
2815
|
+
this.events.emit('disconnect', undefined, origin);
|
|
2816
|
+
}
|
|
2817
|
+
notifyChainChanged(chainId, origin) {
|
|
2818
|
+
this.events.emit('chainChanged', ethers.ethers.utils.hexValue(chainId), origin);
|
|
2811
2819
|
}
|
|
2812
2820
|
async notifyNetworks(networks) {
|
|
2813
2821
|
const n = networks || (await this.getNetworks(true));
|
|
@@ -2815,7 +2823,7 @@ class WalletRequestHandler {
|
|
|
2815
2823
|
if (n.length > 0) {
|
|
2816
2824
|
const defaultNetwork = n.find(network => network.chainId === this.defaultChainId());
|
|
2817
2825
|
if (defaultNetwork) {
|
|
2818
|
-
this.events.emit('chainChanged', ethers.ethers.utils.
|
|
2826
|
+
this.events.emit('chainChanged', ethers.ethers.utils.hexValue(defaultNetwork.chainId));
|
|
2819
2827
|
}
|
|
2820
2828
|
} else {
|
|
2821
2829
|
this.events.emit('chainChanged', '0x0');
|
|
@@ -3524,7 +3532,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
|
|
|
3524
3532
|
|
|
3525
3533
|
var packageJson = {
|
|
3526
3534
|
name: "@0xsequence/provider",
|
|
3527
|
-
version: "1.2.
|
|
3535
|
+
version: "1.2.6",
|
|
3528
3536
|
description: "provider sub-package for Sequence",
|
|
3529
3537
|
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3530
3538
|
source: "src/index.ts",
|
|
@@ -3684,9 +3692,9 @@ class SequenceClient {
|
|
|
3684
3692
|
chainId: chainIdHex
|
|
3685
3693
|
})));
|
|
3686
3694
|
});
|
|
3687
|
-
this.transport.on('disconnect', error => {
|
|
3695
|
+
this.transport.on('disconnect', (error, origin) => {
|
|
3688
3696
|
var _this$callbacks$disco;
|
|
3689
|
-
(_this$callbacks$disco = this.callbacks.disconnect) == null ? void 0 : _this$callbacks$disco.forEach(cb => cb(error));
|
|
3697
|
+
(_this$callbacks$disco = this.callbacks.disconnect) == null ? void 0 : _this$callbacks$disco.forEach(cb => cb(error, origin));
|
|
3690
3698
|
});
|
|
3691
3699
|
this.transport.on('networks', networks => {
|
|
3692
3700
|
var _this$callbacks$netwo;
|
|
@@ -3704,13 +3712,17 @@ class SequenceClient {
|
|
|
3704
3712
|
var _this$callbacks$close;
|
|
3705
3713
|
(_this$callbacks$close = this.callbacks.close) == null ? void 0 : _this$callbacks$close.forEach(cb => cb());
|
|
3706
3714
|
});
|
|
3715
|
+
this.transport.on('chainChanged', (chainIdHex, origin) => {
|
|
3716
|
+
var _this$callbacks$chain;
|
|
3717
|
+
(_this$callbacks$chain = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain.forEach(cb => cb(chainIdHex, origin));
|
|
3718
|
+
});
|
|
3707
3719
|
|
|
3708
3720
|
// We don't listen for the transport chainChanged event
|
|
3709
3721
|
// instead we handle it locally, so we listen for changes in the store
|
|
3710
3722
|
this.defaultChainId.onDefaultChainIdChanged(chainId => {
|
|
3711
|
-
var _this$callbacks$
|
|
3723
|
+
var _this$callbacks$chain2;
|
|
3712
3724
|
const chainIdHex = ethers.ethers.utils.hexValue(chainId);
|
|
3713
|
-
(_this$callbacks$
|
|
3725
|
+
(_this$callbacks$chain2 = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain2.forEach(cb => cb(chainIdHex));
|
|
3714
3726
|
});
|
|
3715
3727
|
}
|
|
3716
3728
|
|
|
@@ -3751,6 +3763,9 @@ class SequenceClient {
|
|
|
3751
3763
|
onWalletContext(callback) {
|
|
3752
3764
|
return this.registerCallback('walletContext', callback);
|
|
3753
3765
|
}
|
|
3766
|
+
onChainChanged(callback) {
|
|
3767
|
+
return this.registerCallback('chainChanged', callback);
|
|
3768
|
+
}
|
|
3754
3769
|
onDefaultChainIdChanged(callback) {
|
|
3755
3770
|
return this.registerCallback('chainChanged', callback);
|
|
3756
3771
|
}
|
|
@@ -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
|
|
|
@@ -390,7 +390,7 @@ class BaseProviderTransport {
|
|
|
390
390
|
// NOTIFY DISCONNECT -- when wallet instructs to disconnect
|
|
391
391
|
if (message.type === EventType.DISCONNECT) {
|
|
392
392
|
if (this.isConnected()) {
|
|
393
|
-
this.events.emit('disconnect', message.data);
|
|
393
|
+
this.events.emit('disconnect', message.data, message.origin);
|
|
394
394
|
this.close();
|
|
395
395
|
}
|
|
396
396
|
}
|
|
@@ -930,10 +930,10 @@ class BaseWalletTransport {
|
|
|
930
930
|
// means user has logged in and wallet is connected to the app
|
|
931
931
|
this.notifyConnect(connectDetails);
|
|
932
932
|
});
|
|
933
|
-
this.walletRequestHandler.on('disconnect', error => {
|
|
933
|
+
this.walletRequestHandler.on('disconnect', (error, origin) => {
|
|
934
934
|
if (!this.registered) return;
|
|
935
935
|
// means user has logged out the app / disconnected wallet from the app
|
|
936
|
-
this.notifyDisconnect(error);
|
|
936
|
+
this.notifyDisconnect(error, origin);
|
|
937
937
|
});
|
|
938
938
|
this.walletRequestHandler.on('accountsChanged', (accounts, origin) => {
|
|
939
939
|
if (!this.registered) return;
|
|
@@ -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.
|
|
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);
|
|
@@ -1003,13 +1006,14 @@ class BaseWalletTransport {
|
|
|
1003
1006
|
data: connectDetails
|
|
1004
1007
|
});
|
|
1005
1008
|
}
|
|
1006
|
-
notifyDisconnect(error) {
|
|
1009
|
+
notifyDisconnect(error, origin) {
|
|
1007
1010
|
this.sendMessage({
|
|
1008
1011
|
idx: -1,
|
|
1009
1012
|
type: EventType.DISCONNECT,
|
|
1010
1013
|
data: error ? {
|
|
1011
1014
|
error
|
|
1012
|
-
} : null
|
|
1015
|
+
} : null,
|
|
1016
|
+
origin
|
|
1013
1017
|
});
|
|
1014
1018
|
}
|
|
1015
1019
|
notifyAccountsChanged(accounts, origin) {
|
|
@@ -1017,14 +1021,15 @@ class BaseWalletTransport {
|
|
|
1017
1021
|
idx: -1,
|
|
1018
1022
|
type: EventType.ACCOUNTS_CHANGED,
|
|
1019
1023
|
data: accounts,
|
|
1020
|
-
origin
|
|
1024
|
+
origin
|
|
1021
1025
|
});
|
|
1022
1026
|
}
|
|
1023
|
-
notifyChainChanged(chainIdHex) {
|
|
1027
|
+
notifyChainChanged(chainIdHex, origin) {
|
|
1024
1028
|
this.sendMessage({
|
|
1025
1029
|
idx: -1,
|
|
1026
1030
|
type: EventType.CHAIN_CHANGED,
|
|
1027
|
-
data: chainIdHex
|
|
1031
|
+
data: chainIdHex,
|
|
1032
|
+
origin
|
|
1028
1033
|
});
|
|
1029
1034
|
}
|
|
1030
1035
|
notifyNetworks(networks) {
|
|
@@ -2803,7 +2808,10 @@ class WalletRequestHandler {
|
|
|
2803
2808
|
}
|
|
2804
2809
|
notifyDisconnect(origin) {
|
|
2805
2810
|
this.events.emit('accountsChanged', [], origin);
|
|
2806
|
-
this.events.emit('disconnect');
|
|
2811
|
+
this.events.emit('disconnect', undefined, origin);
|
|
2812
|
+
}
|
|
2813
|
+
notifyChainChanged(chainId, origin) {
|
|
2814
|
+
this.events.emit('chainChanged', ethers.utils.hexValue(chainId), origin);
|
|
2807
2815
|
}
|
|
2808
2816
|
async notifyNetworks(networks) {
|
|
2809
2817
|
const n = networks || (await this.getNetworks(true));
|
|
@@ -2811,7 +2819,7 @@ class WalletRequestHandler {
|
|
|
2811
2819
|
if (n.length > 0) {
|
|
2812
2820
|
const defaultNetwork = n.find(network => network.chainId === this.defaultChainId());
|
|
2813
2821
|
if (defaultNetwork) {
|
|
2814
|
-
this.events.emit('chainChanged', ethers.utils.
|
|
2822
|
+
this.events.emit('chainChanged', ethers.utils.hexValue(defaultNetwork.chainId));
|
|
2815
2823
|
}
|
|
2816
2824
|
} else {
|
|
2817
2825
|
this.events.emit('chainChanged', '0x0');
|
|
@@ -3520,7 +3528,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
|
|
|
3520
3528
|
|
|
3521
3529
|
var packageJson = {
|
|
3522
3530
|
name: "@0xsequence/provider",
|
|
3523
|
-
version: "1.2.
|
|
3531
|
+
version: "1.2.6",
|
|
3524
3532
|
description: "provider sub-package for Sequence",
|
|
3525
3533
|
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3526
3534
|
source: "src/index.ts",
|
|
@@ -3680,9 +3688,9 @@ class SequenceClient {
|
|
|
3680
3688
|
chainId: chainIdHex
|
|
3681
3689
|
})));
|
|
3682
3690
|
});
|
|
3683
|
-
this.transport.on('disconnect', error => {
|
|
3691
|
+
this.transport.on('disconnect', (error, origin) => {
|
|
3684
3692
|
var _this$callbacks$disco;
|
|
3685
|
-
(_this$callbacks$disco = this.callbacks.disconnect) == null ? void 0 : _this$callbacks$disco.forEach(cb => cb(error));
|
|
3693
|
+
(_this$callbacks$disco = this.callbacks.disconnect) == null ? void 0 : _this$callbacks$disco.forEach(cb => cb(error, origin));
|
|
3686
3694
|
});
|
|
3687
3695
|
this.transport.on('networks', networks => {
|
|
3688
3696
|
var _this$callbacks$netwo;
|
|
@@ -3700,13 +3708,17 @@ class SequenceClient {
|
|
|
3700
3708
|
var _this$callbacks$close;
|
|
3701
3709
|
(_this$callbacks$close = this.callbacks.close) == null ? void 0 : _this$callbacks$close.forEach(cb => cb());
|
|
3702
3710
|
});
|
|
3711
|
+
this.transport.on('chainChanged', (chainIdHex, origin) => {
|
|
3712
|
+
var _this$callbacks$chain;
|
|
3713
|
+
(_this$callbacks$chain = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain.forEach(cb => cb(chainIdHex, origin));
|
|
3714
|
+
});
|
|
3703
3715
|
|
|
3704
3716
|
// We don't listen for the transport chainChanged event
|
|
3705
3717
|
// instead we handle it locally, so we listen for changes in the store
|
|
3706
3718
|
this.defaultChainId.onDefaultChainIdChanged(chainId => {
|
|
3707
|
-
var _this$callbacks$
|
|
3719
|
+
var _this$callbacks$chain2;
|
|
3708
3720
|
const chainIdHex = ethers.utils.hexValue(chainId);
|
|
3709
|
-
(_this$callbacks$
|
|
3721
|
+
(_this$callbacks$chain2 = this.callbacks.chainChanged) == null ? void 0 : _this$callbacks$chain2.forEach(cb => cb(chainIdHex));
|
|
3710
3722
|
});
|
|
3711
3723
|
}
|
|
3712
3724
|
|
|
@@ -3747,6 +3759,9 @@ class SequenceClient {
|
|
|
3747
3759
|
onWalletContext(callback) {
|
|
3748
3760
|
return this.registerCallback('walletContext', callback);
|
|
3749
3761
|
}
|
|
3762
|
+
onChainChanged(callback) {
|
|
3763
|
+
return this.registerCallback('chainChanged', callback);
|
|
3764
|
+
}
|
|
3750
3765
|
onDefaultChainIdChanged(callback) {
|
|
3751
3766
|
return this.registerCallback('chainChanged', callback);
|
|
3752
3767
|
}
|
|
@@ -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;
|
|
@@ -26,9 +26,9 @@ export declare abstract class BaseWalletTransport implements WalletTransport {
|
|
|
26
26
|
}): void;
|
|
27
27
|
notifyClose(error?: ProviderRpcError): void;
|
|
28
28
|
notifyConnect(connectDetails: ConnectDetails): void;
|
|
29
|
-
notifyDisconnect(error?: ProviderRpcError): void;
|
|
29
|
+
notifyDisconnect(error?: ProviderRpcError, origin?: string): 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;
|
|
@@ -84,9 +84,9 @@ export interface WalletEventTypes {
|
|
|
84
84
|
}) => void;
|
|
85
85
|
close: (error?: ProviderRpcError) => void;
|
|
86
86
|
connect: (connectDetails: ConnectDetails) => void;
|
|
87
|
-
disconnect: (error?: ProviderRpcError) => void;
|
|
87
|
+
disconnect: (error?: ProviderRpcError, origin?: string) => 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,8 +115,7 @@ 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
|
|
119
|
-
* challenge and security feature. **/
|
|
118
|
+
/** authorizeNonce is an optional number to be passed as ETHAuth's nonce claim for replay protection. **/
|
|
120
119
|
authorizeNonce?: number;
|
|
121
120
|
/** authorizeVersion is the version of the SDK that will validate the ETHAuth proof. */
|
|
122
121
|
authorizeVersion?: number;
|
|
@@ -192,7 +191,7 @@ export interface Settings {
|
|
|
192
191
|
* you can use the camel case version of the name in the wallet settings.
|
|
193
192
|
* For example: "Blue Dark" on wallet UI can be passed as "blueDark" */
|
|
194
193
|
export type ThemeOption = 'light' | 'dark' | string;
|
|
195
|
-
export type PaymentProviderOption = 'moonpay' | '
|
|
194
|
+
export type PaymentProviderOption = 'ramp' | 'moonpay' | 'transak' | 'onmeta' | 'paytrie' | 'sardine';
|
|
196
195
|
export type CurrencyOption = 'usdc' | 'eth' | 'matic';
|
|
197
196
|
export type SignInOption = 'email' | 'google' | 'apple' | 'facebook' | 'discord' | 'twitch';
|
|
198
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.
|
|
3
|
+
"version": "1.2.6",
|
|
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.
|
|
15
|
-
"@0xsequence/
|
|
16
|
-
"@0xsequence/
|
|
17
|
-
"@0xsequence/
|
|
18
|
-
"@0xsequence/
|
|
19
|
-
"@0xsequence/network": "1.2.
|
|
20
|
-
"@0xsequence/
|
|
21
|
-
"@0xsequence/
|
|
22
|
-
"@0xsequence/wallet": "1.2.
|
|
14
|
+
"@0xsequence/abi": "1.2.6",
|
|
15
|
+
"@0xsequence/core": "1.2.6",
|
|
16
|
+
"@0xsequence/account": "1.2.6",
|
|
17
|
+
"@0xsequence/auth": "1.2.6",
|
|
18
|
+
"@0xsequence/migration": "1.2.6",
|
|
19
|
+
"@0xsequence/network": "1.2.6",
|
|
20
|
+
"@0xsequence/utils": "1.2.6",
|
|
21
|
+
"@0xsequence/relayer": "1.2.6",
|
|
22
|
+
"@0xsequence/wallet": "1.2.6"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"ethers": ">=5.5 < 6"
|
package/src/client.ts
CHANGED
|
@@ -169,8 +169,8 @@ export class SequenceClient {
|
|
|
169
169
|
)
|
|
170
170
|
})
|
|
171
171
|
|
|
172
|
-
this.transport.on('disconnect', error => {
|
|
173
|
-
this.callbacks.disconnect?.forEach(cb => cb(error))
|
|
172
|
+
this.transport.on('disconnect', (error, origin) => {
|
|
173
|
+
this.callbacks.disconnect?.forEach(cb => cb(error, origin))
|
|
174
174
|
})
|
|
175
175
|
|
|
176
176
|
this.transport.on('networks', networks => {
|
|
@@ -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
|
|
|
@@ -274,7 +274,7 @@ export abstract class BaseProviderTransport implements ProviderTransport {
|
|
|
274
274
|
// NOTIFY DISCONNECT -- when wallet instructs to disconnect
|
|
275
275
|
if (message.type === EventType.DISCONNECT) {
|
|
276
276
|
if (this.isConnected()) {
|
|
277
|
-
this.events.emit('disconnect', message.data)
|
|
277
|
+
this.events.emit('disconnect', message.data, message.origin)
|
|
278
278
|
this.close()
|
|
279
279
|
}
|
|
280
280
|
}
|
|
@@ -48,10 +48,10 @@ export abstract class BaseWalletTransport implements WalletTransport {
|
|
|
48
48
|
this.notifyConnect(connectDetails)
|
|
49
49
|
})
|
|
50
50
|
|
|
51
|
-
this.walletRequestHandler.on('disconnect', (error?: ProviderRpcError) => {
|
|
51
|
+
this.walletRequestHandler.on('disconnect', (error?: ProviderRpcError, origin?: string) => {
|
|
52
52
|
if (!this.registered) return
|
|
53
53
|
// means user has logged out the app / disconnected wallet from the app
|
|
54
|
-
this.notifyDisconnect(error)
|
|
54
|
+
this.notifyDisconnect(error, origin)
|
|
55
55
|
})
|
|
56
56
|
|
|
57
57
|
this.walletRequestHandler.on('accountsChanged', (accounts: string[], origin?: string) => {
|
|
@@ -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.
|
|
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)
|
|
@@ -197,11 +201,12 @@ export abstract class BaseWalletTransport implements WalletTransport {
|
|
|
197
201
|
})
|
|
198
202
|
}
|
|
199
203
|
|
|
200
|
-
notifyDisconnect(error?: ProviderRpcError) {
|
|
204
|
+
notifyDisconnect(error?: ProviderRpcError, origin?: string) {
|
|
201
205
|
this.sendMessage({
|
|
202
206
|
idx: -1,
|
|
203
207
|
type: EventType.DISCONNECT,
|
|
204
|
-
data: error ? { error } : null
|
|
208
|
+
data: error ? { error } : null,
|
|
209
|
+
origin
|
|
205
210
|
})
|
|
206
211
|
}
|
|
207
212
|
|
|
@@ -210,15 +215,16 @@ export abstract class BaseWalletTransport implements WalletTransport {
|
|
|
210
215
|
idx: -1,
|
|
211
216
|
type: EventType.ACCOUNTS_CHANGED,
|
|
212
217
|
data: accounts,
|
|
213
|
-
origin
|
|
218
|
+
origin
|
|
214
219
|
})
|
|
215
220
|
}
|
|
216
221
|
|
|
217
|
-
notifyChainChanged(chainIdHex: string) {
|
|
222
|
+
notifyChainChanged(chainIdHex: string, origin?: string) {
|
|
218
223
|
this.sendMessage({
|
|
219
224
|
idx: -1,
|
|
220
225
|
type: EventType.CHAIN_CHANGED,
|
|
221
|
-
data: chainIdHex
|
|
226
|
+
data: chainIdHex,
|
|
227
|
+
origin
|
|
222
228
|
})
|
|
223
229
|
}
|
|
224
230
|
|
|
@@ -768,7 +768,11 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
|
|
|
768
768
|
|
|
769
769
|
notifyDisconnect(origin?: string) {
|
|
770
770
|
this.events.emit('accountsChanged', [], origin)
|
|
771
|
-
this.events.emit('disconnect')
|
|
771
|
+
this.events.emit('disconnect', undefined, origin)
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
notifyChainChanged(chainId: number, origin?: string) {
|
|
775
|
+
this.events.emit('chainChanged', ethers.utils.hexValue(chainId), origin)
|
|
772
776
|
}
|
|
773
777
|
|
|
774
778
|
async notifyNetworks(networks?: NetworkConfig[]) {
|
|
@@ -777,7 +781,7 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
|
|
|
777
781
|
if (n.length > 0) {
|
|
778
782
|
const defaultNetwork = n.find(network => network.chainId === this.defaultChainId())
|
|
779
783
|
if (defaultNetwork) {
|
|
780
|
-
this.events.emit('chainChanged', ethers.utils.
|
|
784
|
+
this.events.emit('chainChanged', ethers.utils.hexValue(defaultNetwork.chainId))
|
|
781
785
|
}
|
|
782
786
|
} else {
|
|
783
787
|
this.events.emit('chainChanged', '0x0')
|
package/src/types.ts
CHANGED
|
@@ -129,10 +129,10 @@ export interface WalletEventTypes {
|
|
|
129
129
|
close: (error?: ProviderRpcError) => void
|
|
130
130
|
|
|
131
131
|
connect: (connectDetails: ConnectDetails) => void
|
|
132
|
-
disconnect: (error?: ProviderRpcError) => void
|
|
132
|
+
disconnect: (error?: ProviderRpcError, origin?: string) => 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,8 +171,7 @@ 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
|
|
175
|
-
* challenge and security feature. **/
|
|
174
|
+
/** authorizeNonce is an optional number to be passed as ETHAuth's nonce claim for replay protection. **/
|
|
176
175
|
authorizeNonce?: number
|
|
177
176
|
|
|
178
177
|
/** authorizeVersion is the version of the SDK that will validate the ETHAuth proof. */
|
|
@@ -267,7 +266,7 @@ export interface Settings {
|
|
|
267
266
|
* you can use the camel case version of the name in the wallet settings.
|
|
268
267
|
* For example: "Blue Dark" on wallet UI can be passed as "blueDark" */
|
|
269
268
|
export type ThemeOption = 'light' | 'dark' | string
|
|
270
|
-
export type PaymentProviderOption = 'moonpay' | '
|
|
269
|
+
export type PaymentProviderOption = 'ramp' | 'moonpay' | 'transak' | 'onmeta' | 'paytrie' | 'sardine'
|
|
271
270
|
export type CurrencyOption = 'usdc' | 'eth' | 'matic'
|
|
272
271
|
export type SignInOption = 'email' | 'google' | 'apple' | 'facebook' | 'discord' | 'twitch'
|
|
273
272
|
export type BannerSize = 'small' | 'medium' // | 'large'
|