@0xsequence/provider 1.7.2 → 1.8.0
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 +83 -10
- package/dist/0xsequence-provider.cjs.prod.js +83 -10
- package/dist/0xsequence-provider.esm.js +83 -10
- package/dist/declarations/src/analytics.d.ts +13 -0
- package/dist/declarations/src/client.d.ts +6 -2
- package/dist/declarations/src/init.d.ts +2 -0
- package/package.json +13 -12
- package/src/analytics.ts +47 -0
- package/src/client.ts +23 -8
- package/src/init.ts +11 -10
|
@@ -9,6 +9,7 @@ var network = require('@0xsequence/network');
|
|
|
9
9
|
var core = require('@0xsequence/core');
|
|
10
10
|
var auth = require('@0xsequence/auth');
|
|
11
11
|
var abi = require('@0xsequence/abi');
|
|
12
|
+
var tracker = require('@databeat/tracker');
|
|
12
13
|
|
|
13
14
|
function _extends() {
|
|
14
15
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -3571,9 +3572,47 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
|
|
|
3571
3572
|
}
|
|
3572
3573
|
}
|
|
3573
3574
|
|
|
3575
|
+
// Analytics sub-class to add some custom helper methods
|
|
3576
|
+
class Analytics extends tracker.Databeat {}
|
|
3577
|
+
|
|
3578
|
+
// Setup analytics tracker
|
|
3579
|
+
const setupAnalytics = (projectAccessKey, server) => {
|
|
3580
|
+
if (!server) {
|
|
3581
|
+
server = 'https://nodes.sequence.app';
|
|
3582
|
+
}
|
|
3583
|
+
|
|
3584
|
+
// disable tracking if projectAccessKey is not set
|
|
3585
|
+
const noop = !projectAccessKey;
|
|
3586
|
+
|
|
3587
|
+
// auth
|
|
3588
|
+
const auth = {};
|
|
3589
|
+
if (projectAccessKey) {
|
|
3590
|
+
auth.headers = {
|
|
3591
|
+
'X-Access-Key': projectAccessKey
|
|
3592
|
+
};
|
|
3593
|
+
}
|
|
3594
|
+
return new Analytics(server, auth, {
|
|
3595
|
+
noop: noop,
|
|
3596
|
+
defaultEnabled: true,
|
|
3597
|
+
privacy: {
|
|
3598
|
+
userIdHash: true,
|
|
3599
|
+
userAgentSalt: false
|
|
3600
|
+
},
|
|
3601
|
+
initProps: () => {
|
|
3602
|
+
if (!tracker.isBrowser()) {
|
|
3603
|
+
return {};
|
|
3604
|
+
} else {
|
|
3605
|
+
return {
|
|
3606
|
+
origin: window.location.origin
|
|
3607
|
+
};
|
|
3608
|
+
}
|
|
3609
|
+
}
|
|
3610
|
+
});
|
|
3611
|
+
};
|
|
3612
|
+
|
|
3574
3613
|
var packageJson = {
|
|
3575
3614
|
name: "@0xsequence/provider",
|
|
3576
|
-
version: "1.
|
|
3615
|
+
version: "1.8.0",
|
|
3577
3616
|
description: "provider sub-package for Sequence",
|
|
3578
3617
|
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3579
3618
|
source: "src/index.ts",
|
|
@@ -3602,6 +3641,7 @@ var packageJson = {
|
|
|
3602
3641
|
"@0xsequence/relayer": "workspace:*",
|
|
3603
3642
|
"@0xsequence/utils": "workspace:*",
|
|
3604
3643
|
"@0xsequence/wallet": "workspace:*",
|
|
3644
|
+
"@databeat/tracker": "^0.8.1",
|
|
3605
3645
|
eventemitter2: "^6.4.5",
|
|
3606
3646
|
"webextension-polyfill": "^0.10.0"
|
|
3607
3647
|
},
|
|
@@ -3610,8 +3650,8 @@ var packageJson = {
|
|
|
3610
3650
|
},
|
|
3611
3651
|
devDependencies: {
|
|
3612
3652
|
"@types/webextension-polyfill": "^0.10.0",
|
|
3613
|
-
|
|
3614
|
-
|
|
3653
|
+
ethers: "^5.7.2",
|
|
3654
|
+
hardhat: "^2.12.2"
|
|
3615
3655
|
},
|
|
3616
3656
|
files: [
|
|
3617
3657
|
"src",
|
|
@@ -3705,14 +3745,15 @@ DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
|
|
|
3705
3745
|
|
|
3706
3746
|
// TODO: rename Client to transport.. or something.. like SequenceTransport ..
|
|
3707
3747
|
class SequenceClient {
|
|
3708
|
-
constructor(transport, store, options
|
|
3748
|
+
constructor(transport, store, options) {
|
|
3709
3749
|
var _options$defaultEIP;
|
|
3710
|
-
this.projectAccessKey = projectAccessKey;
|
|
3711
3750
|
this.session = void 0;
|
|
3712
3751
|
this.defaultChainId = void 0;
|
|
3713
3752
|
this.callbacks = {};
|
|
3714
3753
|
this.transport = void 0;
|
|
3715
3754
|
this.defaultEIP6492 = void 0;
|
|
3755
|
+
this.projectAccessKey = void 0;
|
|
3756
|
+
this.analytics = void 0;
|
|
3716
3757
|
if (isMuxTransportTemplate(transport)) {
|
|
3717
3758
|
this.transport = MuxMessageProvider.new(transport);
|
|
3718
3759
|
} else if (isProviderTransport(transport)) {
|
|
@@ -3720,8 +3761,8 @@ class SequenceClient {
|
|
|
3720
3761
|
} else {
|
|
3721
3762
|
throw new Error('Invalid transport');
|
|
3722
3763
|
}
|
|
3723
|
-
const defaultChainId =
|
|
3724
|
-
this.defaultEIP6492 =
|
|
3764
|
+
const defaultChainId = options == null ? void 0 : options.defaultChainId;
|
|
3765
|
+
this.defaultEIP6492 = (_options$defaultEIP = options == null ? void 0 : options.defaultEIP6492) != null ? _options$defaultEIP : false;
|
|
3725
3766
|
this.session = new SequenceClientSession(store);
|
|
3726
3767
|
this.defaultChainId = new DefaultChainIdTracker(store, defaultChainId);
|
|
3727
3768
|
this.transport.on('accountsChanged', accounts => {
|
|
@@ -3772,6 +3813,14 @@ class SequenceClient {
|
|
|
3772
3813
|
const chainIdHex = ethers.ethers.utils.hexValue(chainId);
|
|
3773
3814
|
(_this$callbacks$chain2 = this.callbacks.chainChanged) == null || _this$callbacks$chain2.forEach(cb => cb(chainIdHex));
|
|
3774
3815
|
});
|
|
3816
|
+
if (options != null && options.projectAccessKey) {
|
|
3817
|
+
this.projectAccessKey = options.projectAccessKey;
|
|
3818
|
+
}
|
|
3819
|
+
if (this.projectAccessKey && options != null && options.analytics) {
|
|
3820
|
+
this.analytics = setupAnalytics(this.projectAccessKey);
|
|
3821
|
+
} else {
|
|
3822
|
+
this.analytics = setupAnalytics(''); // noop analytics
|
|
3823
|
+
}
|
|
3775
3824
|
}
|
|
3776
3825
|
|
|
3777
3826
|
// Callbacks
|
|
@@ -3985,7 +4034,14 @@ class SequenceClient {
|
|
|
3985
4034
|
return method;
|
|
3986
4035
|
}
|
|
3987
4036
|
async signMessage(message, options) {
|
|
4037
|
+
var _this$analytics;
|
|
3988
4038
|
const method = this.signMethod(options);
|
|
4039
|
+
(_this$analytics = this.analytics) == null || _this$analytics.track({
|
|
4040
|
+
event: 'SIGN_MESSAGE_REQUEST',
|
|
4041
|
+
props: {
|
|
4042
|
+
chainId: `${(options == null ? void 0 : options.chainId) || this.getChainId()}`
|
|
4043
|
+
}
|
|
4044
|
+
});
|
|
3989
4045
|
|
|
3990
4046
|
// Address is ignored by the wallet webapp
|
|
3991
4047
|
return this.send({
|
|
@@ -3994,6 +4050,7 @@ class SequenceClient {
|
|
|
3994
4050
|
}, options == null ? void 0 : options.chainId);
|
|
3995
4051
|
}
|
|
3996
4052
|
async signTypedData(typedData, options) {
|
|
4053
|
+
var _this$analytics2;
|
|
3997
4054
|
const method = this.signTypedDataMethod(options);
|
|
3998
4055
|
|
|
3999
4056
|
// TODO: Stop using ethers for this, this is the only place where we use it
|
|
@@ -4005,14 +4062,27 @@ class SequenceClient {
|
|
|
4005
4062
|
// - The one provided in the typedData.domain.chainId
|
|
4006
4063
|
// - The default chainId
|
|
4007
4064
|
|
|
4065
|
+
(_this$analytics2 = this.analytics) == null || _this$analytics2.track({
|
|
4066
|
+
event: 'SIGN_TYPED_DATA_REQUEST',
|
|
4067
|
+
props: {
|
|
4068
|
+
chainId: `${(options == null ? void 0 : options.chainId) || this.getChainId()}`
|
|
4069
|
+
}
|
|
4070
|
+
});
|
|
4008
4071
|
return this.send({
|
|
4009
4072
|
method,
|
|
4010
4073
|
params: [this.getAddress(), encoded]
|
|
4011
4074
|
}, (options == null ? void 0 : options.chainId) || typedData.domain.chainId && ethers.ethers.BigNumber.from(typedData.domain.chainId).toNumber() || this.getChainId());
|
|
4012
4075
|
}
|
|
4013
4076
|
async sendTransaction(tx, options) {
|
|
4077
|
+
var _this$analytics3;
|
|
4014
4078
|
const sequenceTxs = Array.isArray(tx) ? tx : [tx];
|
|
4015
4079
|
const extendedTxs = toExtended(sequenceTxs);
|
|
4080
|
+
(_this$analytics3 = this.analytics) == null || _this$analytics3.track({
|
|
4081
|
+
event: 'SEND_TRANSACTION_REQUEST',
|
|
4082
|
+
props: {
|
|
4083
|
+
chainId: `${(options == null ? void 0 : options.chainId) || this.getChainId()}`
|
|
4084
|
+
}
|
|
4085
|
+
});
|
|
4016
4086
|
return this.send({
|
|
4017
4087
|
method: 'eth_sendTransaction',
|
|
4018
4088
|
params: [extendedTxs]
|
|
@@ -4048,7 +4118,8 @@ const DefaultProviderConfig = {
|
|
|
4048
4118
|
enabled: false
|
|
4049
4119
|
}
|
|
4050
4120
|
},
|
|
4051
|
-
defaultNetwork: 1
|
|
4121
|
+
defaultNetwork: 1,
|
|
4122
|
+
analytics: true
|
|
4052
4123
|
};
|
|
4053
4124
|
let sequenceWalletProvider;
|
|
4054
4125
|
|
|
@@ -4121,8 +4192,10 @@ const initWallet = (projectAccessKey, partialConfig) => {
|
|
|
4121
4192
|
// Create client, provider and return signer
|
|
4122
4193
|
const client = new SequenceClient(config.transports, itemStore, {
|
|
4123
4194
|
defaultChainId: defaultNetwork,
|
|
4124
|
-
defaultEIP6492: config.defaultEIP6492
|
|
4125
|
-
|
|
4195
|
+
defaultEIP6492: config.defaultEIP6492,
|
|
4196
|
+
projectAccessKey: projectAccessKey,
|
|
4197
|
+
analytics: config.analytics
|
|
4198
|
+
});
|
|
4126
4199
|
sequenceWalletProvider = new SequenceProvider(client, providerForChainId);
|
|
4127
4200
|
return sequenceWalletProvider;
|
|
4128
4201
|
};
|
|
@@ -9,6 +9,7 @@ var network = require('@0xsequence/network');
|
|
|
9
9
|
var core = require('@0xsequence/core');
|
|
10
10
|
var auth = require('@0xsequence/auth');
|
|
11
11
|
var abi = require('@0xsequence/abi');
|
|
12
|
+
var tracker = require('@databeat/tracker');
|
|
12
13
|
|
|
13
14
|
function _extends() {
|
|
14
15
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -3571,9 +3572,47 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
|
|
|
3571
3572
|
}
|
|
3572
3573
|
}
|
|
3573
3574
|
|
|
3575
|
+
// Analytics sub-class to add some custom helper methods
|
|
3576
|
+
class Analytics extends tracker.Databeat {}
|
|
3577
|
+
|
|
3578
|
+
// Setup analytics tracker
|
|
3579
|
+
const setupAnalytics = (projectAccessKey, server) => {
|
|
3580
|
+
if (!server) {
|
|
3581
|
+
server = 'https://nodes.sequence.app';
|
|
3582
|
+
}
|
|
3583
|
+
|
|
3584
|
+
// disable tracking if projectAccessKey is not set
|
|
3585
|
+
const noop = !projectAccessKey;
|
|
3586
|
+
|
|
3587
|
+
// auth
|
|
3588
|
+
const auth = {};
|
|
3589
|
+
if (projectAccessKey) {
|
|
3590
|
+
auth.headers = {
|
|
3591
|
+
'X-Access-Key': projectAccessKey
|
|
3592
|
+
};
|
|
3593
|
+
}
|
|
3594
|
+
return new Analytics(server, auth, {
|
|
3595
|
+
noop: noop,
|
|
3596
|
+
defaultEnabled: true,
|
|
3597
|
+
privacy: {
|
|
3598
|
+
userIdHash: true,
|
|
3599
|
+
userAgentSalt: false
|
|
3600
|
+
},
|
|
3601
|
+
initProps: () => {
|
|
3602
|
+
if (!tracker.isBrowser()) {
|
|
3603
|
+
return {};
|
|
3604
|
+
} else {
|
|
3605
|
+
return {
|
|
3606
|
+
origin: window.location.origin
|
|
3607
|
+
};
|
|
3608
|
+
}
|
|
3609
|
+
}
|
|
3610
|
+
});
|
|
3611
|
+
};
|
|
3612
|
+
|
|
3574
3613
|
var packageJson = {
|
|
3575
3614
|
name: "@0xsequence/provider",
|
|
3576
|
-
version: "1.
|
|
3615
|
+
version: "1.8.0",
|
|
3577
3616
|
description: "provider sub-package for Sequence",
|
|
3578
3617
|
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3579
3618
|
source: "src/index.ts",
|
|
@@ -3602,6 +3641,7 @@ var packageJson = {
|
|
|
3602
3641
|
"@0xsequence/relayer": "workspace:*",
|
|
3603
3642
|
"@0xsequence/utils": "workspace:*",
|
|
3604
3643
|
"@0xsequence/wallet": "workspace:*",
|
|
3644
|
+
"@databeat/tracker": "^0.8.1",
|
|
3605
3645
|
eventemitter2: "^6.4.5",
|
|
3606
3646
|
"webextension-polyfill": "^0.10.0"
|
|
3607
3647
|
},
|
|
@@ -3610,8 +3650,8 @@ var packageJson = {
|
|
|
3610
3650
|
},
|
|
3611
3651
|
devDependencies: {
|
|
3612
3652
|
"@types/webextension-polyfill": "^0.10.0",
|
|
3613
|
-
|
|
3614
|
-
|
|
3653
|
+
ethers: "^5.7.2",
|
|
3654
|
+
hardhat: "^2.12.2"
|
|
3615
3655
|
},
|
|
3616
3656
|
files: [
|
|
3617
3657
|
"src",
|
|
@@ -3705,14 +3745,15 @@ DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
|
|
|
3705
3745
|
|
|
3706
3746
|
// TODO: rename Client to transport.. or something.. like SequenceTransport ..
|
|
3707
3747
|
class SequenceClient {
|
|
3708
|
-
constructor(transport, store, options
|
|
3748
|
+
constructor(transport, store, options) {
|
|
3709
3749
|
var _options$defaultEIP;
|
|
3710
|
-
this.projectAccessKey = projectAccessKey;
|
|
3711
3750
|
this.session = void 0;
|
|
3712
3751
|
this.defaultChainId = void 0;
|
|
3713
3752
|
this.callbacks = {};
|
|
3714
3753
|
this.transport = void 0;
|
|
3715
3754
|
this.defaultEIP6492 = void 0;
|
|
3755
|
+
this.projectAccessKey = void 0;
|
|
3756
|
+
this.analytics = void 0;
|
|
3716
3757
|
if (isMuxTransportTemplate(transport)) {
|
|
3717
3758
|
this.transport = MuxMessageProvider.new(transport);
|
|
3718
3759
|
} else if (isProviderTransport(transport)) {
|
|
@@ -3720,8 +3761,8 @@ class SequenceClient {
|
|
|
3720
3761
|
} else {
|
|
3721
3762
|
throw new Error('Invalid transport');
|
|
3722
3763
|
}
|
|
3723
|
-
const defaultChainId =
|
|
3724
|
-
this.defaultEIP6492 =
|
|
3764
|
+
const defaultChainId = options == null ? void 0 : options.defaultChainId;
|
|
3765
|
+
this.defaultEIP6492 = (_options$defaultEIP = options == null ? void 0 : options.defaultEIP6492) != null ? _options$defaultEIP : false;
|
|
3725
3766
|
this.session = new SequenceClientSession(store);
|
|
3726
3767
|
this.defaultChainId = new DefaultChainIdTracker(store, defaultChainId);
|
|
3727
3768
|
this.transport.on('accountsChanged', accounts => {
|
|
@@ -3772,6 +3813,14 @@ class SequenceClient {
|
|
|
3772
3813
|
const chainIdHex = ethers.ethers.utils.hexValue(chainId);
|
|
3773
3814
|
(_this$callbacks$chain2 = this.callbacks.chainChanged) == null || _this$callbacks$chain2.forEach(cb => cb(chainIdHex));
|
|
3774
3815
|
});
|
|
3816
|
+
if (options != null && options.projectAccessKey) {
|
|
3817
|
+
this.projectAccessKey = options.projectAccessKey;
|
|
3818
|
+
}
|
|
3819
|
+
if (this.projectAccessKey && options != null && options.analytics) {
|
|
3820
|
+
this.analytics = setupAnalytics(this.projectAccessKey);
|
|
3821
|
+
} else {
|
|
3822
|
+
this.analytics = setupAnalytics(''); // noop analytics
|
|
3823
|
+
}
|
|
3775
3824
|
}
|
|
3776
3825
|
|
|
3777
3826
|
// Callbacks
|
|
@@ -3985,7 +4034,14 @@ class SequenceClient {
|
|
|
3985
4034
|
return method;
|
|
3986
4035
|
}
|
|
3987
4036
|
async signMessage(message, options) {
|
|
4037
|
+
var _this$analytics;
|
|
3988
4038
|
const method = this.signMethod(options);
|
|
4039
|
+
(_this$analytics = this.analytics) == null || _this$analytics.track({
|
|
4040
|
+
event: 'SIGN_MESSAGE_REQUEST',
|
|
4041
|
+
props: {
|
|
4042
|
+
chainId: `${(options == null ? void 0 : options.chainId) || this.getChainId()}`
|
|
4043
|
+
}
|
|
4044
|
+
});
|
|
3989
4045
|
|
|
3990
4046
|
// Address is ignored by the wallet webapp
|
|
3991
4047
|
return this.send({
|
|
@@ -3994,6 +4050,7 @@ class SequenceClient {
|
|
|
3994
4050
|
}, options == null ? void 0 : options.chainId);
|
|
3995
4051
|
}
|
|
3996
4052
|
async signTypedData(typedData, options) {
|
|
4053
|
+
var _this$analytics2;
|
|
3997
4054
|
const method = this.signTypedDataMethod(options);
|
|
3998
4055
|
|
|
3999
4056
|
// TODO: Stop using ethers for this, this is the only place where we use it
|
|
@@ -4005,14 +4062,27 @@ class SequenceClient {
|
|
|
4005
4062
|
// - The one provided in the typedData.domain.chainId
|
|
4006
4063
|
// - The default chainId
|
|
4007
4064
|
|
|
4065
|
+
(_this$analytics2 = this.analytics) == null || _this$analytics2.track({
|
|
4066
|
+
event: 'SIGN_TYPED_DATA_REQUEST',
|
|
4067
|
+
props: {
|
|
4068
|
+
chainId: `${(options == null ? void 0 : options.chainId) || this.getChainId()}`
|
|
4069
|
+
}
|
|
4070
|
+
});
|
|
4008
4071
|
return this.send({
|
|
4009
4072
|
method,
|
|
4010
4073
|
params: [this.getAddress(), encoded]
|
|
4011
4074
|
}, (options == null ? void 0 : options.chainId) || typedData.domain.chainId && ethers.ethers.BigNumber.from(typedData.domain.chainId).toNumber() || this.getChainId());
|
|
4012
4075
|
}
|
|
4013
4076
|
async sendTransaction(tx, options) {
|
|
4077
|
+
var _this$analytics3;
|
|
4014
4078
|
const sequenceTxs = Array.isArray(tx) ? tx : [tx];
|
|
4015
4079
|
const extendedTxs = toExtended(sequenceTxs);
|
|
4080
|
+
(_this$analytics3 = this.analytics) == null || _this$analytics3.track({
|
|
4081
|
+
event: 'SEND_TRANSACTION_REQUEST',
|
|
4082
|
+
props: {
|
|
4083
|
+
chainId: `${(options == null ? void 0 : options.chainId) || this.getChainId()}`
|
|
4084
|
+
}
|
|
4085
|
+
});
|
|
4016
4086
|
return this.send({
|
|
4017
4087
|
method: 'eth_sendTransaction',
|
|
4018
4088
|
params: [extendedTxs]
|
|
@@ -4048,7 +4118,8 @@ const DefaultProviderConfig = {
|
|
|
4048
4118
|
enabled: false
|
|
4049
4119
|
}
|
|
4050
4120
|
},
|
|
4051
|
-
defaultNetwork: 1
|
|
4121
|
+
defaultNetwork: 1,
|
|
4122
|
+
analytics: true
|
|
4052
4123
|
};
|
|
4053
4124
|
let sequenceWalletProvider;
|
|
4054
4125
|
|
|
@@ -4121,8 +4192,10 @@ const initWallet = (projectAccessKey, partialConfig) => {
|
|
|
4121
4192
|
// Create client, provider and return signer
|
|
4122
4193
|
const client = new SequenceClient(config.transports, itemStore, {
|
|
4123
4194
|
defaultChainId: defaultNetwork,
|
|
4124
|
-
defaultEIP6492: config.defaultEIP6492
|
|
4125
|
-
|
|
4195
|
+
defaultEIP6492: config.defaultEIP6492,
|
|
4196
|
+
projectAccessKey: projectAccessKey,
|
|
4197
|
+
analytics: config.analytics
|
|
4198
|
+
});
|
|
4126
4199
|
sequenceWalletProvider = new SequenceProvider(client, providerForChainId);
|
|
4127
4200
|
return sequenceWalletProvider;
|
|
4128
4201
|
};
|
|
@@ -5,6 +5,7 @@ import { findSupportedNetwork, ChainId, findNetworkConfig, allNetworks, JsonRpcR
|
|
|
5
5
|
import { commons } from '@0xsequence/core';
|
|
6
6
|
import { signAuthorization } from '@0xsequence/auth';
|
|
7
7
|
import { walletContracts } from '@0xsequence/abi';
|
|
8
|
+
import { isBrowser, Databeat } from '@databeat/tracker';
|
|
8
9
|
|
|
9
10
|
function _extends() {
|
|
10
11
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -3567,9 +3568,47 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
|
|
|
3567
3568
|
}
|
|
3568
3569
|
}
|
|
3569
3570
|
|
|
3571
|
+
// Analytics sub-class to add some custom helper methods
|
|
3572
|
+
class Analytics extends Databeat {}
|
|
3573
|
+
|
|
3574
|
+
// Setup analytics tracker
|
|
3575
|
+
const setupAnalytics = (projectAccessKey, server) => {
|
|
3576
|
+
if (!server) {
|
|
3577
|
+
server = 'https://nodes.sequence.app';
|
|
3578
|
+
}
|
|
3579
|
+
|
|
3580
|
+
// disable tracking if projectAccessKey is not set
|
|
3581
|
+
const noop = !projectAccessKey;
|
|
3582
|
+
|
|
3583
|
+
// auth
|
|
3584
|
+
const auth = {};
|
|
3585
|
+
if (projectAccessKey) {
|
|
3586
|
+
auth.headers = {
|
|
3587
|
+
'X-Access-Key': projectAccessKey
|
|
3588
|
+
};
|
|
3589
|
+
}
|
|
3590
|
+
return new Analytics(server, auth, {
|
|
3591
|
+
noop: noop,
|
|
3592
|
+
defaultEnabled: true,
|
|
3593
|
+
privacy: {
|
|
3594
|
+
userIdHash: true,
|
|
3595
|
+
userAgentSalt: false
|
|
3596
|
+
},
|
|
3597
|
+
initProps: () => {
|
|
3598
|
+
if (!isBrowser()) {
|
|
3599
|
+
return {};
|
|
3600
|
+
} else {
|
|
3601
|
+
return {
|
|
3602
|
+
origin: window.location.origin
|
|
3603
|
+
};
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3606
|
+
});
|
|
3607
|
+
};
|
|
3608
|
+
|
|
3570
3609
|
var packageJson = {
|
|
3571
3610
|
name: "@0xsequence/provider",
|
|
3572
|
-
version: "1.
|
|
3611
|
+
version: "1.8.0",
|
|
3573
3612
|
description: "provider sub-package for Sequence",
|
|
3574
3613
|
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3575
3614
|
source: "src/index.ts",
|
|
@@ -3598,6 +3637,7 @@ var packageJson = {
|
|
|
3598
3637
|
"@0xsequence/relayer": "workspace:*",
|
|
3599
3638
|
"@0xsequence/utils": "workspace:*",
|
|
3600
3639
|
"@0xsequence/wallet": "workspace:*",
|
|
3640
|
+
"@databeat/tracker": "^0.8.1",
|
|
3601
3641
|
eventemitter2: "^6.4.5",
|
|
3602
3642
|
"webextension-polyfill": "^0.10.0"
|
|
3603
3643
|
},
|
|
@@ -3606,8 +3646,8 @@ var packageJson = {
|
|
|
3606
3646
|
},
|
|
3607
3647
|
devDependencies: {
|
|
3608
3648
|
"@types/webextension-polyfill": "^0.10.0",
|
|
3609
|
-
|
|
3610
|
-
|
|
3649
|
+
ethers: "^5.7.2",
|
|
3650
|
+
hardhat: "^2.12.2"
|
|
3611
3651
|
},
|
|
3612
3652
|
files: [
|
|
3613
3653
|
"src",
|
|
@@ -3701,14 +3741,15 @@ DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
|
|
|
3701
3741
|
|
|
3702
3742
|
// TODO: rename Client to transport.. or something.. like SequenceTransport ..
|
|
3703
3743
|
class SequenceClient {
|
|
3704
|
-
constructor(transport, store, options
|
|
3744
|
+
constructor(transport, store, options) {
|
|
3705
3745
|
var _options$defaultEIP;
|
|
3706
|
-
this.projectAccessKey = projectAccessKey;
|
|
3707
3746
|
this.session = void 0;
|
|
3708
3747
|
this.defaultChainId = void 0;
|
|
3709
3748
|
this.callbacks = {};
|
|
3710
3749
|
this.transport = void 0;
|
|
3711
3750
|
this.defaultEIP6492 = void 0;
|
|
3751
|
+
this.projectAccessKey = void 0;
|
|
3752
|
+
this.analytics = void 0;
|
|
3712
3753
|
if (isMuxTransportTemplate(transport)) {
|
|
3713
3754
|
this.transport = MuxMessageProvider.new(transport);
|
|
3714
3755
|
} else if (isProviderTransport(transport)) {
|
|
@@ -3716,8 +3757,8 @@ class SequenceClient {
|
|
|
3716
3757
|
} else {
|
|
3717
3758
|
throw new Error('Invalid transport');
|
|
3718
3759
|
}
|
|
3719
|
-
const defaultChainId =
|
|
3720
|
-
this.defaultEIP6492 =
|
|
3760
|
+
const defaultChainId = options == null ? void 0 : options.defaultChainId;
|
|
3761
|
+
this.defaultEIP6492 = (_options$defaultEIP = options == null ? void 0 : options.defaultEIP6492) != null ? _options$defaultEIP : false;
|
|
3721
3762
|
this.session = new SequenceClientSession(store);
|
|
3722
3763
|
this.defaultChainId = new DefaultChainIdTracker(store, defaultChainId);
|
|
3723
3764
|
this.transport.on('accountsChanged', accounts => {
|
|
@@ -3768,6 +3809,14 @@ class SequenceClient {
|
|
|
3768
3809
|
const chainIdHex = ethers.utils.hexValue(chainId);
|
|
3769
3810
|
(_this$callbacks$chain2 = this.callbacks.chainChanged) == null || _this$callbacks$chain2.forEach(cb => cb(chainIdHex));
|
|
3770
3811
|
});
|
|
3812
|
+
if (options != null && options.projectAccessKey) {
|
|
3813
|
+
this.projectAccessKey = options.projectAccessKey;
|
|
3814
|
+
}
|
|
3815
|
+
if (this.projectAccessKey && options != null && options.analytics) {
|
|
3816
|
+
this.analytics = setupAnalytics(this.projectAccessKey);
|
|
3817
|
+
} else {
|
|
3818
|
+
this.analytics = setupAnalytics(''); // noop analytics
|
|
3819
|
+
}
|
|
3771
3820
|
}
|
|
3772
3821
|
|
|
3773
3822
|
// Callbacks
|
|
@@ -3981,7 +4030,14 @@ class SequenceClient {
|
|
|
3981
4030
|
return method;
|
|
3982
4031
|
}
|
|
3983
4032
|
async signMessage(message, options) {
|
|
4033
|
+
var _this$analytics;
|
|
3984
4034
|
const method = this.signMethod(options);
|
|
4035
|
+
(_this$analytics = this.analytics) == null || _this$analytics.track({
|
|
4036
|
+
event: 'SIGN_MESSAGE_REQUEST',
|
|
4037
|
+
props: {
|
|
4038
|
+
chainId: `${(options == null ? void 0 : options.chainId) || this.getChainId()}`
|
|
4039
|
+
}
|
|
4040
|
+
});
|
|
3985
4041
|
|
|
3986
4042
|
// Address is ignored by the wallet webapp
|
|
3987
4043
|
return this.send({
|
|
@@ -3990,6 +4046,7 @@ class SequenceClient {
|
|
|
3990
4046
|
}, options == null ? void 0 : options.chainId);
|
|
3991
4047
|
}
|
|
3992
4048
|
async signTypedData(typedData, options) {
|
|
4049
|
+
var _this$analytics2;
|
|
3993
4050
|
const method = this.signTypedDataMethod(options);
|
|
3994
4051
|
|
|
3995
4052
|
// TODO: Stop using ethers for this, this is the only place where we use it
|
|
@@ -4001,14 +4058,27 @@ class SequenceClient {
|
|
|
4001
4058
|
// - The one provided in the typedData.domain.chainId
|
|
4002
4059
|
// - The default chainId
|
|
4003
4060
|
|
|
4061
|
+
(_this$analytics2 = this.analytics) == null || _this$analytics2.track({
|
|
4062
|
+
event: 'SIGN_TYPED_DATA_REQUEST',
|
|
4063
|
+
props: {
|
|
4064
|
+
chainId: `${(options == null ? void 0 : options.chainId) || this.getChainId()}`
|
|
4065
|
+
}
|
|
4066
|
+
});
|
|
4004
4067
|
return this.send({
|
|
4005
4068
|
method,
|
|
4006
4069
|
params: [this.getAddress(), encoded]
|
|
4007
4070
|
}, (options == null ? void 0 : options.chainId) || typedData.domain.chainId && ethers.BigNumber.from(typedData.domain.chainId).toNumber() || this.getChainId());
|
|
4008
4071
|
}
|
|
4009
4072
|
async sendTransaction(tx, options) {
|
|
4073
|
+
var _this$analytics3;
|
|
4010
4074
|
const sequenceTxs = Array.isArray(tx) ? tx : [tx];
|
|
4011
4075
|
const extendedTxs = toExtended(sequenceTxs);
|
|
4076
|
+
(_this$analytics3 = this.analytics) == null || _this$analytics3.track({
|
|
4077
|
+
event: 'SEND_TRANSACTION_REQUEST',
|
|
4078
|
+
props: {
|
|
4079
|
+
chainId: `${(options == null ? void 0 : options.chainId) || this.getChainId()}`
|
|
4080
|
+
}
|
|
4081
|
+
});
|
|
4012
4082
|
return this.send({
|
|
4013
4083
|
method: 'eth_sendTransaction',
|
|
4014
4084
|
params: [extendedTxs]
|
|
@@ -4044,7 +4114,8 @@ const DefaultProviderConfig = {
|
|
|
4044
4114
|
enabled: false
|
|
4045
4115
|
}
|
|
4046
4116
|
},
|
|
4047
|
-
defaultNetwork: 1
|
|
4117
|
+
defaultNetwork: 1,
|
|
4118
|
+
analytics: true
|
|
4048
4119
|
};
|
|
4049
4120
|
let sequenceWalletProvider;
|
|
4050
4121
|
|
|
@@ -4117,8 +4188,10 @@ const initWallet = (projectAccessKey, partialConfig) => {
|
|
|
4117
4188
|
// Create client, provider and return signer
|
|
4118
4189
|
const client = new SequenceClient(config.transports, itemStore, {
|
|
4119
4190
|
defaultChainId: defaultNetwork,
|
|
4120
|
-
defaultEIP6492: config.defaultEIP6492
|
|
4121
|
-
|
|
4191
|
+
defaultEIP6492: config.defaultEIP6492,
|
|
4192
|
+
projectAccessKey: projectAccessKey,
|
|
4193
|
+
analytics: config.analytics
|
|
4194
|
+
});
|
|
4122
4195
|
sequenceWalletProvider = new SequenceProvider(client, providerForChainId);
|
|
4123
4196
|
return sequenceWalletProvider;
|
|
4124
4197
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Databeat, Event as DatabeatEvent } from '@databeat/tracker';
|
|
2
|
+
export declare enum EventType {
|
|
3
|
+
INIT = 0,
|
|
4
|
+
VIEW = 1,
|
|
5
|
+
SIGN_MESSAGE_REQUEST = 2,
|
|
6
|
+
SIGN_TYPED_DATA_REQUEST = 3,
|
|
7
|
+
SEND_TRANSACTION_REQUEST = 4
|
|
8
|
+
}
|
|
9
|
+
export type EventTypes = keyof typeof EventType;
|
|
10
|
+
export type Event = DatabeatEvent<EventTypes>;
|
|
11
|
+
export declare class Analytics extends Databeat<EventTypes> {
|
|
12
|
+
}
|
|
13
|
+
export declare const setupAnalytics: (projectAccessKey: string, server?: string) => Analytics;
|
|
@@ -2,6 +2,7 @@ import { JsonRpcRequest, NetworkConfig } from '@0xsequence/network';
|
|
|
2
2
|
import { ConnectDetails, ConnectOptions, ItemStore, MuxTransportTemplate, OpenWalletIntent, OptionalChainId, OptionalEIP6492, ProviderTransport, WalletEventTypes, WalletSession } from "./index.js";
|
|
3
3
|
import { commons } from '@0xsequence/core';
|
|
4
4
|
import { TypedData } from '@0xsequence/utils';
|
|
5
|
+
import { Analytics } from "./analytics.js";
|
|
5
6
|
import { ethers } from 'ethers';
|
|
6
7
|
/**
|
|
7
8
|
* This session class is meant to persist the state of the wallet connection
|
|
@@ -36,6 +37,8 @@ export declare class DefaultChainIdTracker {
|
|
|
36
37
|
export type SequenceClientOptions = {
|
|
37
38
|
defaultChainId?: number;
|
|
38
39
|
defaultEIP6492?: boolean;
|
|
40
|
+
projectAccessKey?: string;
|
|
41
|
+
analytics?: boolean;
|
|
39
42
|
};
|
|
40
43
|
/**
|
|
41
44
|
* This is a wallet client for sequence wallet-webapp. It connects using *some* transport
|
|
@@ -44,13 +47,14 @@ export type SequenceClientOptions = {
|
|
|
44
47
|
* It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
|
|
45
48
|
*/
|
|
46
49
|
export declare class SequenceClient {
|
|
47
|
-
projectAccessKey?: string | undefined;
|
|
48
50
|
private readonly session;
|
|
49
51
|
private readonly defaultChainId;
|
|
50
52
|
private readonly callbacks;
|
|
51
53
|
readonly transport: ProviderTransport;
|
|
52
54
|
readonly defaultEIP6492: boolean;
|
|
53
|
-
|
|
55
|
+
readonly projectAccessKey?: string;
|
|
56
|
+
readonly analytics?: Analytics;
|
|
57
|
+
constructor(transport: ProviderTransport | MuxTransportTemplate, store: ItemStore, options?: SequenceClientOptions);
|
|
54
58
|
registerCallback<K extends keyof WalletEventTypes>(eventName: K, callback: WalletEventTypes[K]): () => void;
|
|
55
59
|
onOpen(callback: WalletEventTypes['open']): () => void;
|
|
56
60
|
onClose(callback: WalletEventTypes['close']): () => void;
|
|
@@ -8,6 +8,7 @@ export interface ProviderConfig {
|
|
|
8
8
|
defaultEIP6492?: boolean;
|
|
9
9
|
networks?: Partial<NetworkConfig>[];
|
|
10
10
|
transports?: MuxTransportTemplate;
|
|
11
|
+
analytics?: boolean;
|
|
11
12
|
}
|
|
12
13
|
export declare const DefaultProviderConfig: {
|
|
13
14
|
transports: {
|
|
@@ -20,6 +21,7 @@ export declare const DefaultProviderConfig: {
|
|
|
20
21
|
};
|
|
21
22
|
};
|
|
22
23
|
defaultNetwork: number;
|
|
24
|
+
analytics: boolean;
|
|
23
25
|
};
|
|
24
26
|
/**
|
|
25
27
|
* Initializes a wallet with the provided project access key and optional configuration.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/provider",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
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",
|
|
@@ -9,25 +9,26 @@
|
|
|
9
9
|
"author": "Horizon Blockchain Games",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
|
+
"@databeat/tracker": "^0.8.1",
|
|
12
13
|
"eventemitter2": "^6.4.5",
|
|
13
14
|
"webextension-polyfill": "^0.10.0",
|
|
14
|
-
"@0xsequence/abi": "1.
|
|
15
|
-
"@0xsequence/account": "1.
|
|
16
|
-
"@0xsequence/auth": "1.
|
|
17
|
-
"@0xsequence/core": "1.
|
|
18
|
-
"@0xsequence/migration": "1.
|
|
19
|
-
"@0xsequence/network": "1.
|
|
20
|
-
"@0xsequence/relayer": "1.
|
|
21
|
-
"@0xsequence/utils": "1.
|
|
22
|
-
"@0xsequence/wallet": "1.
|
|
15
|
+
"@0xsequence/abi": "1.8.0",
|
|
16
|
+
"@0xsequence/account": "1.8.0",
|
|
17
|
+
"@0xsequence/auth": "1.8.0",
|
|
18
|
+
"@0xsequence/core": "1.8.0",
|
|
19
|
+
"@0xsequence/migration": "1.8.0",
|
|
20
|
+
"@0xsequence/network": "1.8.0",
|
|
21
|
+
"@0xsequence/relayer": "1.8.0",
|
|
22
|
+
"@0xsequence/utils": "1.8.0",
|
|
23
|
+
"@0xsequence/wallet": "1.8.0"
|
|
23
24
|
},
|
|
24
25
|
"peerDependencies": {
|
|
25
26
|
"ethers": ">=5.5 < 6"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@types/webextension-polyfill": "^0.10.0",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
30
|
+
"ethers": "^5.7.2",
|
|
31
|
+
"hardhat": "^2.12.2"
|
|
31
32
|
},
|
|
32
33
|
"files": [
|
|
33
34
|
"src",
|
package/src/analytics.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Databeat, Event as DatabeatEvent, Auth, isBrowser } from '@databeat/tracker'
|
|
2
|
+
|
|
3
|
+
export enum EventType {
|
|
4
|
+
// Core types part of Databeat
|
|
5
|
+
INIT,
|
|
6
|
+
VIEW,
|
|
7
|
+
|
|
8
|
+
// Provider specific
|
|
9
|
+
SIGN_MESSAGE_REQUEST,
|
|
10
|
+
SIGN_TYPED_DATA_REQUEST,
|
|
11
|
+
SEND_TRANSACTION_REQUEST
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type EventTypes = keyof typeof EventType
|
|
15
|
+
export type Event = DatabeatEvent<EventTypes>
|
|
16
|
+
|
|
17
|
+
// Analytics sub-class to add some custom helper methods
|
|
18
|
+
export class Analytics extends Databeat<EventTypes> {}
|
|
19
|
+
|
|
20
|
+
// Setup analytics tracker
|
|
21
|
+
export const setupAnalytics = (projectAccessKey: string, server?: string) => {
|
|
22
|
+
if (!server) {
|
|
23
|
+
server = 'https://nodes.sequence.app'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// disable tracking if projectAccessKey is not set
|
|
27
|
+
const noop = !projectAccessKey
|
|
28
|
+
|
|
29
|
+
// auth
|
|
30
|
+
const auth: Auth = {}
|
|
31
|
+
if (projectAccessKey) {
|
|
32
|
+
auth.headers = { 'X-Access-Key': projectAccessKey }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return new Analytics(server, auth, {
|
|
36
|
+
noop: noop,
|
|
37
|
+
defaultEnabled: true,
|
|
38
|
+
privacy: { userIdHash: true, userAgentSalt: false },
|
|
39
|
+
initProps: () => {
|
|
40
|
+
if (!isBrowser()) {
|
|
41
|
+
return {}
|
|
42
|
+
} else {
|
|
43
|
+
return { origin: window.location.origin }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
}
|
package/src/client.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import { commons } from '@0xsequence/core'
|
|
18
18
|
import { TypedData } from '@0xsequence/utils'
|
|
19
19
|
import { toExtended } from './extended'
|
|
20
|
+
import { Analytics, setupAnalytics } from './analytics'
|
|
20
21
|
import { ethers } from 'ethers'
|
|
21
22
|
|
|
22
23
|
import packageJson from '../package.json'
|
|
@@ -117,6 +118,8 @@ export class DefaultChainIdTracker {
|
|
|
117
118
|
export type SequenceClientOptions = {
|
|
118
119
|
defaultChainId?: number
|
|
119
120
|
defaultEIP6492?: boolean
|
|
121
|
+
projectAccessKey?: string
|
|
122
|
+
analytics?: boolean
|
|
120
123
|
}
|
|
121
124
|
|
|
122
125
|
/**
|
|
@@ -135,13 +138,10 @@ export class SequenceClient {
|
|
|
135
138
|
public readonly transport: ProviderTransport
|
|
136
139
|
|
|
137
140
|
public readonly defaultEIP6492: boolean
|
|
141
|
+
public readonly projectAccessKey?: string
|
|
142
|
+
public readonly analytics?: Analytics
|
|
138
143
|
|
|
139
|
-
constructor(
|
|
140
|
-
transport: ProviderTransport | MuxTransportTemplate,
|
|
141
|
-
store: ItemStore,
|
|
142
|
-
options?: SequenceClientOptions | number,
|
|
143
|
-
public projectAccessKey?: string
|
|
144
|
-
) {
|
|
144
|
+
constructor(transport: ProviderTransport | MuxTransportTemplate, store: ItemStore, options?: SequenceClientOptions) {
|
|
145
145
|
if (isMuxTransportTemplate(transport)) {
|
|
146
146
|
this.transport = MuxMessageProvider.new(transport)
|
|
147
147
|
} else if (isProviderTransport(transport)) {
|
|
@@ -150,8 +150,8 @@ export class SequenceClient {
|
|
|
150
150
|
throw new Error('Invalid transport')
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
const defaultChainId =
|
|
154
|
-
this.defaultEIP6492 =
|
|
153
|
+
const defaultChainId = options?.defaultChainId
|
|
154
|
+
this.defaultEIP6492 = options?.defaultEIP6492 ?? false
|
|
155
155
|
|
|
156
156
|
this.session = new SequenceClientSession(store)
|
|
157
157
|
this.defaultChainId = new DefaultChainIdTracker(store, defaultChainId)
|
|
@@ -206,6 +206,15 @@ export class SequenceClient {
|
|
|
206
206
|
const chainIdHex = ethers.utils.hexValue(chainId)
|
|
207
207
|
this.callbacks.chainChanged?.forEach(cb => cb(chainIdHex))
|
|
208
208
|
})
|
|
209
|
+
|
|
210
|
+
if (options?.projectAccessKey) {
|
|
211
|
+
this.projectAccessKey = options.projectAccessKey
|
|
212
|
+
}
|
|
213
|
+
if (this.projectAccessKey && options?.analytics) {
|
|
214
|
+
this.analytics = setupAnalytics(this.projectAccessKey)
|
|
215
|
+
} else {
|
|
216
|
+
this.analytics = setupAnalytics('') // noop analytics
|
|
217
|
+
}
|
|
209
218
|
}
|
|
210
219
|
|
|
211
220
|
// Callbacks
|
|
@@ -454,6 +463,8 @@ export class SequenceClient {
|
|
|
454
463
|
async signMessage(message: ethers.BytesLike, options?: OptionalEIP6492 & OptionalChainId): Promise<string> {
|
|
455
464
|
const method = this.signMethod(options)
|
|
456
465
|
|
|
466
|
+
this.analytics?.track({ event: 'SIGN_MESSAGE_REQUEST', props: { chainId: `${options?.chainId || this.getChainId()}` } })
|
|
467
|
+
|
|
457
468
|
// Address is ignored by the wallet webapp
|
|
458
469
|
return this.send({ method, params: [message, this.getAddress()] }, options?.chainId)
|
|
459
470
|
}
|
|
@@ -470,6 +481,8 @@ export class SequenceClient {
|
|
|
470
481
|
// - The one provided in the typedData.domain.chainId
|
|
471
482
|
// - The default chainId
|
|
472
483
|
|
|
484
|
+
this.analytics?.track({ event: 'SIGN_TYPED_DATA_REQUEST', props: { chainId: `${options?.chainId || this.getChainId()}` } })
|
|
485
|
+
|
|
473
486
|
return this.send(
|
|
474
487
|
{ method, params: [this.getAddress(), encoded] },
|
|
475
488
|
options?.chainId ||
|
|
@@ -485,6 +498,8 @@ export class SequenceClient {
|
|
|
485
498
|
const sequenceTxs = Array.isArray(tx) ? tx : [tx]
|
|
486
499
|
const extendedTxs = toExtended(sequenceTxs)
|
|
487
500
|
|
|
501
|
+
this.analytics?.track({ event: 'SEND_TRANSACTION_REQUEST', props: { chainId: `${options?.chainId || this.getChainId()}` } })
|
|
502
|
+
|
|
488
503
|
return this.send({ method: 'eth_sendTransaction', params: [extendedTxs] }, options?.chainId)
|
|
489
504
|
}
|
|
490
505
|
|
package/src/init.ts
CHANGED
|
@@ -40,6 +40,9 @@ export interface ProviderConfig {
|
|
|
40
40
|
|
|
41
41
|
// transports for dapp to wallet jron-rpc communication
|
|
42
42
|
transports?: MuxTransportTemplate
|
|
43
|
+
|
|
44
|
+
// analytics .... (default: true)
|
|
45
|
+
analytics?: boolean
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
export const DefaultProviderConfig = {
|
|
@@ -49,7 +52,8 @@ export const DefaultProviderConfig = {
|
|
|
49
52
|
proxyTransport: { enabled: false }
|
|
50
53
|
},
|
|
51
54
|
|
|
52
|
-
defaultNetwork: 1
|
|
55
|
+
defaultNetwork: 1,
|
|
56
|
+
analytics: true
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
let sequenceWalletProvider: SequenceProvider | undefined
|
|
@@ -134,15 +138,12 @@ export const initWallet = (projectAccessKey: string, partialConfig?: Partial<Pro
|
|
|
134
138
|
const itemStore = config.localStorage || useBestStore()
|
|
135
139
|
|
|
136
140
|
// Create client, provider and return signer
|
|
137
|
-
const client = new SequenceClient(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
},
|
|
144
|
-
projectAccessKey
|
|
145
|
-
)
|
|
141
|
+
const client = new SequenceClient(config.transports, itemStore, {
|
|
142
|
+
defaultChainId: defaultNetwork,
|
|
143
|
+
defaultEIP6492: config.defaultEIP6492,
|
|
144
|
+
projectAccessKey: projectAccessKey,
|
|
145
|
+
analytics: config.analytics
|
|
146
|
+
})
|
|
146
147
|
|
|
147
148
|
sequenceWalletProvider = new SequenceProvider(client, providerForChainId)
|
|
148
149
|
return sequenceWalletProvider
|