@0xsequence/provider 0.0.0-20240402220106 → 0.0.0-20240403204458
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 +31 -67
- package/dist/0xsequence-provider.cjs.prod.js +31 -67
- package/dist/0xsequence-provider.esm.js +31 -67
- package/dist/declarations/src/types.d.ts +1 -0
- package/package.json +10 -10
- package/src/client.ts +2 -4
- package/src/transports/base-provider-transport.ts +6 -4
- package/src/transports/base-wallet-transport.ts +19 -10
- package/src/transports/proxy-transport/proxy-message-provider.ts +5 -2
- package/src/transports/wallet-request-handler.ts +2 -3
- package/src/types.ts +1 -0
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var eventemitter2 = require('eventemitter2');
|
|
6
6
|
var utils = require('@0xsequence/utils');
|
|
7
7
|
var ethers = require('ethers');
|
|
8
|
-
var network = require('@0xsequence/network');
|
|
9
8
|
var core = require('@0xsequence/core');
|
|
9
|
+
var network = require('@0xsequence/network');
|
|
10
10
|
var auth = require('@0xsequence/auth');
|
|
11
11
|
var abi = require('@0xsequence/abi');
|
|
12
12
|
var tracker = require('@databeat/tracker');
|
|
@@ -242,7 +242,8 @@ class BaseProviderTransport {
|
|
|
242
242
|
idx: nextMessageIdx(),
|
|
243
243
|
type: EventType.MESSAGE,
|
|
244
244
|
data: request,
|
|
245
|
-
chainId: request.chainId
|
|
245
|
+
chainId: request.chainId,
|
|
246
|
+
clientVersion: core.VERSION
|
|
246
247
|
});
|
|
247
248
|
return response.data;
|
|
248
249
|
}
|
|
@@ -268,7 +269,8 @@ class BaseProviderTransport {
|
|
|
268
269
|
data: {
|
|
269
270
|
sessionId: this._sessionId,
|
|
270
271
|
nonce: nonce
|
|
271
|
-
}
|
|
272
|
+
},
|
|
273
|
+
clientVersion: core.VERSION
|
|
272
274
|
});
|
|
273
275
|
}
|
|
274
276
|
if (this._init !== InitState.OK) {
|
|
@@ -1003,7 +1005,8 @@ class BaseWalletTransport {
|
|
|
1003
1005
|
sessionId,
|
|
1004
1006
|
session,
|
|
1005
1007
|
error
|
|
1006
|
-
}
|
|
1008
|
+
},
|
|
1009
|
+
clientVersion: core.VERSION
|
|
1007
1010
|
});
|
|
1008
1011
|
}
|
|
1009
1012
|
notifyClose(error) {
|
|
@@ -1012,14 +1015,16 @@ class BaseWalletTransport {
|
|
|
1012
1015
|
type: EventType.CLOSE,
|
|
1013
1016
|
data: error ? {
|
|
1014
1017
|
error
|
|
1015
|
-
} : null
|
|
1018
|
+
} : null,
|
|
1019
|
+
clientVersion: core.VERSION
|
|
1016
1020
|
});
|
|
1017
1021
|
}
|
|
1018
1022
|
notifyConnect(connectDetails) {
|
|
1019
1023
|
this.sendMessage({
|
|
1020
1024
|
idx: -1,
|
|
1021
1025
|
type: EventType.CONNECT,
|
|
1022
|
-
data: connectDetails
|
|
1026
|
+
data: connectDetails,
|
|
1027
|
+
clientVersion: core.VERSION
|
|
1023
1028
|
});
|
|
1024
1029
|
}
|
|
1025
1030
|
notifyDisconnect(error, origin) {
|
|
@@ -1029,7 +1034,8 @@ class BaseWalletTransport {
|
|
|
1029
1034
|
data: error ? {
|
|
1030
1035
|
error
|
|
1031
1036
|
} : null,
|
|
1032
|
-
origin
|
|
1037
|
+
origin,
|
|
1038
|
+
clientVersion: core.VERSION
|
|
1033
1039
|
});
|
|
1034
1040
|
}
|
|
1035
1041
|
notifyAccountsChanged(accounts, origin) {
|
|
@@ -1037,7 +1043,8 @@ class BaseWalletTransport {
|
|
|
1037
1043
|
idx: -1,
|
|
1038
1044
|
type: EventType.ACCOUNTS_CHANGED,
|
|
1039
1045
|
data: accounts,
|
|
1040
|
-
origin
|
|
1046
|
+
origin,
|
|
1047
|
+
clientVersion: core.VERSION
|
|
1041
1048
|
});
|
|
1042
1049
|
}
|
|
1043
1050
|
notifyChainChanged(chainIdHex, origin) {
|
|
@@ -1045,21 +1052,24 @@ class BaseWalletTransport {
|
|
|
1045
1052
|
idx: -1,
|
|
1046
1053
|
type: EventType.CHAIN_CHANGED,
|
|
1047
1054
|
data: chainIdHex,
|
|
1048
|
-
origin
|
|
1055
|
+
origin,
|
|
1056
|
+
clientVersion: core.VERSION
|
|
1049
1057
|
});
|
|
1050
1058
|
}
|
|
1051
1059
|
notifyNetworks(networks) {
|
|
1052
1060
|
this.sendMessage({
|
|
1053
1061
|
idx: -1,
|
|
1054
1062
|
type: EventType.NETWORKS,
|
|
1055
|
-
data: networks
|
|
1063
|
+
data: networks,
|
|
1064
|
+
clientVersion: core.VERSION
|
|
1056
1065
|
});
|
|
1057
1066
|
}
|
|
1058
1067
|
notifyWalletContext(walletContext) {
|
|
1059
1068
|
this.sendMessage({
|
|
1060
1069
|
idx: -1,
|
|
1061
1070
|
type: EventType.WALLET_CONTEXT,
|
|
1062
|
-
data: walletContext
|
|
1071
|
+
data: walletContext,
|
|
1072
|
+
clientVersion: core.VERSION
|
|
1063
1073
|
});
|
|
1064
1074
|
}
|
|
1065
1075
|
isValidInitAck(message) {
|
|
@@ -1130,7 +1140,8 @@ class BaseWalletTransport {
|
|
|
1130
1140
|
type: EventType.INIT,
|
|
1131
1141
|
data: {
|
|
1132
1142
|
nonce: this._initNonce
|
|
1133
|
-
}
|
|
1143
|
+
},
|
|
1144
|
+
clientVersion: core.VERSION
|
|
1134
1145
|
});
|
|
1135
1146
|
this._init = InitState.SENT_NONCE;
|
|
1136
1147
|
|
|
@@ -1229,7 +1240,8 @@ class ProxyMessageProvider extends BaseProviderTransport {
|
|
|
1229
1240
|
intent,
|
|
1230
1241
|
networkId,
|
|
1231
1242
|
sessionId
|
|
1232
|
-
}
|
|
1243
|
+
},
|
|
1244
|
+
clientVersion: core.VERSION
|
|
1233
1245
|
});
|
|
1234
1246
|
}
|
|
1235
1247
|
};
|
|
@@ -1247,7 +1259,8 @@ class ProxyMessageProvider extends BaseProviderTransport {
|
|
|
1247
1259
|
this.sendMessage({
|
|
1248
1260
|
idx: -1,
|
|
1249
1261
|
type: EventType.CLOSE,
|
|
1250
|
-
data: null
|
|
1262
|
+
data: null,
|
|
1263
|
+
clientVersion: core.VERSION
|
|
1251
1264
|
});
|
|
1252
1265
|
this.close();
|
|
1253
1266
|
}
|
|
@@ -2344,10 +2357,10 @@ class WalletRequestHandler {
|
|
|
2344
2357
|
// (aka, the signer in this instance) and then responds with a wrapped response of
|
|
2345
2358
|
// ProviderMessageResponse to be sent over the transport
|
|
2346
2359
|
async sendMessageRequest(message) {
|
|
2347
|
-
var
|
|
2360
|
+
var _message$clientVersio;
|
|
2348
2361
|
// Older versions of the client require the response to be jsonrpc wrapped
|
|
2349
|
-
const majorVersion = Number(((
|
|
2350
|
-
const isJsonRpcResponse = majorVersion
|
|
2362
|
+
const majorVersion = Number(((_message$clientVersio = message.clientVersion) == null ? void 0 : _message$clientVersio.split('.')[0]) || '0');
|
|
2363
|
+
const isJsonRpcResponse = majorVersion < 2;
|
|
2351
2364
|
const jsonRpcResponse = {
|
|
2352
2365
|
id: message.data.id,
|
|
2353
2366
|
jsonrpc: '2.0',
|
|
@@ -3673,55 +3686,6 @@ const setupAnalytics = (projectAccessKey, server) => {
|
|
|
3673
3686
|
});
|
|
3674
3687
|
};
|
|
3675
3688
|
|
|
3676
|
-
var packageJson = {
|
|
3677
|
-
name: "@0xsequence/provider",
|
|
3678
|
-
version: "0.0.0-20240402220106",
|
|
3679
|
-
description: "provider sub-package for Sequence",
|
|
3680
|
-
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3681
|
-
source: "src/index.ts",
|
|
3682
|
-
main: "dist/0xsequence-provider.cjs.js",
|
|
3683
|
-
module: "dist/0xsequence-provider.esm.js",
|
|
3684
|
-
author: "Horizon Blockchain Games",
|
|
3685
|
-
license: "Apache-2.0",
|
|
3686
|
-
scripts: {
|
|
3687
|
-
test: "pnpm test:concurrently 'pnpm test:run'",
|
|
3688
|
-
"test:run": "pnpm test:file tests/**/*.spec.ts",
|
|
3689
|
-
"test:file": "NODE_OPTIONS='--import tsx' mocha --timeout 30000",
|
|
3690
|
-
typecheck: "tsc --noEmit",
|
|
3691
|
-
"test:concurrently": "concurrently -k --success first 'pnpm start:hardhat1' 'pnpm start:hardhat2'",
|
|
3692
|
-
"start:hardhat1": "pnpm start:hardhat1:verbose > /dev/null 2>&1",
|
|
3693
|
-
"start:hardhat2": "pnpm start:hardhat2:verbose > /dev/null 2>&1",
|
|
3694
|
-
"start:hardhat1:verbose": "hardhat node --config hardhat1.config.js --hostname 0.0.0.0 --port 9595",
|
|
3695
|
-
"start:hardhat2:verbose": "hardhat node --config hardhat2.config.js --hostname 0.0.0.0 --port 8595"
|
|
3696
|
-
},
|
|
3697
|
-
dependencies: {
|
|
3698
|
-
"@0xsequence/abi": "workspace:*",
|
|
3699
|
-
"@0xsequence/account": "workspace:*",
|
|
3700
|
-
"@0xsequence/auth": "workspace:*",
|
|
3701
|
-
"@0xsequence/core": "workspace:*",
|
|
3702
|
-
"@0xsequence/migration": "workspace:*",
|
|
3703
|
-
"@0xsequence/network": "workspace:*",
|
|
3704
|
-
"@0xsequence/relayer": "workspace:*",
|
|
3705
|
-
"@0xsequence/utils": "workspace:*",
|
|
3706
|
-
"@0xsequence/wallet": "workspace:*",
|
|
3707
|
-
"@databeat/tracker": "^0.9.1",
|
|
3708
|
-
eventemitter2: "^6.4.5",
|
|
3709
|
-
"webextension-polyfill": "^0.10.0"
|
|
3710
|
-
},
|
|
3711
|
-
peerDependencies: {
|
|
3712
|
-
ethers: "corbanbrook/ethers.js"
|
|
3713
|
-
},
|
|
3714
|
-
devDependencies: {
|
|
3715
|
-
"@types/webextension-polyfill": "^0.10.0",
|
|
3716
|
-
ethers: "corbanbrook/ethers.js",
|
|
3717
|
-
hardhat: "^2.20.1"
|
|
3718
|
-
},
|
|
3719
|
-
files: [
|
|
3720
|
-
"src",
|
|
3721
|
-
"dist"
|
|
3722
|
-
]
|
|
3723
|
-
};
|
|
3724
|
-
|
|
3725
3689
|
/**
|
|
3726
3690
|
* This session class is meant to persist the state of the wallet connection
|
|
3727
3691
|
* whitin the dapp. This enables the client to retain the wallet address (and some more)
|
|
@@ -3986,7 +3950,7 @@ class SequenceClient {
|
|
|
3986
3950
|
type: 'connect',
|
|
3987
3951
|
options: _extends({}, options, {
|
|
3988
3952
|
networkId: this.getChainId(),
|
|
3989
|
-
clientVersion:
|
|
3953
|
+
clientVersion: core.VERSION
|
|
3990
3954
|
})
|
|
3991
3955
|
});
|
|
3992
3956
|
const connectDetails = await this.transport.waitUntilConnected().catch(error => {
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var eventemitter2 = require('eventemitter2');
|
|
6
6
|
var utils = require('@0xsequence/utils');
|
|
7
7
|
var ethers = require('ethers');
|
|
8
|
-
var network = require('@0xsequence/network');
|
|
9
8
|
var core = require('@0xsequence/core');
|
|
9
|
+
var network = require('@0xsequence/network');
|
|
10
10
|
var auth = require('@0xsequence/auth');
|
|
11
11
|
var abi = require('@0xsequence/abi');
|
|
12
12
|
var tracker = require('@databeat/tracker');
|
|
@@ -242,7 +242,8 @@ class BaseProviderTransport {
|
|
|
242
242
|
idx: nextMessageIdx(),
|
|
243
243
|
type: EventType.MESSAGE,
|
|
244
244
|
data: request,
|
|
245
|
-
chainId: request.chainId
|
|
245
|
+
chainId: request.chainId,
|
|
246
|
+
clientVersion: core.VERSION
|
|
246
247
|
});
|
|
247
248
|
return response.data;
|
|
248
249
|
}
|
|
@@ -268,7 +269,8 @@ class BaseProviderTransport {
|
|
|
268
269
|
data: {
|
|
269
270
|
sessionId: this._sessionId,
|
|
270
271
|
nonce: nonce
|
|
271
|
-
}
|
|
272
|
+
},
|
|
273
|
+
clientVersion: core.VERSION
|
|
272
274
|
});
|
|
273
275
|
}
|
|
274
276
|
if (this._init !== InitState.OK) {
|
|
@@ -1003,7 +1005,8 @@ class BaseWalletTransport {
|
|
|
1003
1005
|
sessionId,
|
|
1004
1006
|
session,
|
|
1005
1007
|
error
|
|
1006
|
-
}
|
|
1008
|
+
},
|
|
1009
|
+
clientVersion: core.VERSION
|
|
1007
1010
|
});
|
|
1008
1011
|
}
|
|
1009
1012
|
notifyClose(error) {
|
|
@@ -1012,14 +1015,16 @@ class BaseWalletTransport {
|
|
|
1012
1015
|
type: EventType.CLOSE,
|
|
1013
1016
|
data: error ? {
|
|
1014
1017
|
error
|
|
1015
|
-
} : null
|
|
1018
|
+
} : null,
|
|
1019
|
+
clientVersion: core.VERSION
|
|
1016
1020
|
});
|
|
1017
1021
|
}
|
|
1018
1022
|
notifyConnect(connectDetails) {
|
|
1019
1023
|
this.sendMessage({
|
|
1020
1024
|
idx: -1,
|
|
1021
1025
|
type: EventType.CONNECT,
|
|
1022
|
-
data: connectDetails
|
|
1026
|
+
data: connectDetails,
|
|
1027
|
+
clientVersion: core.VERSION
|
|
1023
1028
|
});
|
|
1024
1029
|
}
|
|
1025
1030
|
notifyDisconnect(error, origin) {
|
|
@@ -1029,7 +1034,8 @@ class BaseWalletTransport {
|
|
|
1029
1034
|
data: error ? {
|
|
1030
1035
|
error
|
|
1031
1036
|
} : null,
|
|
1032
|
-
origin
|
|
1037
|
+
origin,
|
|
1038
|
+
clientVersion: core.VERSION
|
|
1033
1039
|
});
|
|
1034
1040
|
}
|
|
1035
1041
|
notifyAccountsChanged(accounts, origin) {
|
|
@@ -1037,7 +1043,8 @@ class BaseWalletTransport {
|
|
|
1037
1043
|
idx: -1,
|
|
1038
1044
|
type: EventType.ACCOUNTS_CHANGED,
|
|
1039
1045
|
data: accounts,
|
|
1040
|
-
origin
|
|
1046
|
+
origin,
|
|
1047
|
+
clientVersion: core.VERSION
|
|
1041
1048
|
});
|
|
1042
1049
|
}
|
|
1043
1050
|
notifyChainChanged(chainIdHex, origin) {
|
|
@@ -1045,21 +1052,24 @@ class BaseWalletTransport {
|
|
|
1045
1052
|
idx: -1,
|
|
1046
1053
|
type: EventType.CHAIN_CHANGED,
|
|
1047
1054
|
data: chainIdHex,
|
|
1048
|
-
origin
|
|
1055
|
+
origin,
|
|
1056
|
+
clientVersion: core.VERSION
|
|
1049
1057
|
});
|
|
1050
1058
|
}
|
|
1051
1059
|
notifyNetworks(networks) {
|
|
1052
1060
|
this.sendMessage({
|
|
1053
1061
|
idx: -1,
|
|
1054
1062
|
type: EventType.NETWORKS,
|
|
1055
|
-
data: networks
|
|
1063
|
+
data: networks,
|
|
1064
|
+
clientVersion: core.VERSION
|
|
1056
1065
|
});
|
|
1057
1066
|
}
|
|
1058
1067
|
notifyWalletContext(walletContext) {
|
|
1059
1068
|
this.sendMessage({
|
|
1060
1069
|
idx: -1,
|
|
1061
1070
|
type: EventType.WALLET_CONTEXT,
|
|
1062
|
-
data: walletContext
|
|
1071
|
+
data: walletContext,
|
|
1072
|
+
clientVersion: core.VERSION
|
|
1063
1073
|
});
|
|
1064
1074
|
}
|
|
1065
1075
|
isValidInitAck(message) {
|
|
@@ -1130,7 +1140,8 @@ class BaseWalletTransport {
|
|
|
1130
1140
|
type: EventType.INIT,
|
|
1131
1141
|
data: {
|
|
1132
1142
|
nonce: this._initNonce
|
|
1133
|
-
}
|
|
1143
|
+
},
|
|
1144
|
+
clientVersion: core.VERSION
|
|
1134
1145
|
});
|
|
1135
1146
|
this._init = InitState.SENT_NONCE;
|
|
1136
1147
|
|
|
@@ -1229,7 +1240,8 @@ class ProxyMessageProvider extends BaseProviderTransport {
|
|
|
1229
1240
|
intent,
|
|
1230
1241
|
networkId,
|
|
1231
1242
|
sessionId
|
|
1232
|
-
}
|
|
1243
|
+
},
|
|
1244
|
+
clientVersion: core.VERSION
|
|
1233
1245
|
});
|
|
1234
1246
|
}
|
|
1235
1247
|
};
|
|
@@ -1247,7 +1259,8 @@ class ProxyMessageProvider extends BaseProviderTransport {
|
|
|
1247
1259
|
this.sendMessage({
|
|
1248
1260
|
idx: -1,
|
|
1249
1261
|
type: EventType.CLOSE,
|
|
1250
|
-
data: null
|
|
1262
|
+
data: null,
|
|
1263
|
+
clientVersion: core.VERSION
|
|
1251
1264
|
});
|
|
1252
1265
|
this.close();
|
|
1253
1266
|
}
|
|
@@ -2344,10 +2357,10 @@ class WalletRequestHandler {
|
|
|
2344
2357
|
// (aka, the signer in this instance) and then responds with a wrapped response of
|
|
2345
2358
|
// ProviderMessageResponse to be sent over the transport
|
|
2346
2359
|
async sendMessageRequest(message) {
|
|
2347
|
-
var
|
|
2360
|
+
var _message$clientVersio;
|
|
2348
2361
|
// Older versions of the client require the response to be jsonrpc wrapped
|
|
2349
|
-
const majorVersion = Number(((
|
|
2350
|
-
const isJsonRpcResponse = majorVersion
|
|
2362
|
+
const majorVersion = Number(((_message$clientVersio = message.clientVersion) == null ? void 0 : _message$clientVersio.split('.')[0]) || '0');
|
|
2363
|
+
const isJsonRpcResponse = majorVersion < 2;
|
|
2351
2364
|
const jsonRpcResponse = {
|
|
2352
2365
|
id: message.data.id,
|
|
2353
2366
|
jsonrpc: '2.0',
|
|
@@ -3673,55 +3686,6 @@ const setupAnalytics = (projectAccessKey, server) => {
|
|
|
3673
3686
|
});
|
|
3674
3687
|
};
|
|
3675
3688
|
|
|
3676
|
-
var packageJson = {
|
|
3677
|
-
name: "@0xsequence/provider",
|
|
3678
|
-
version: "0.0.0-20240402220106",
|
|
3679
|
-
description: "provider sub-package for Sequence",
|
|
3680
|
-
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3681
|
-
source: "src/index.ts",
|
|
3682
|
-
main: "dist/0xsequence-provider.cjs.js",
|
|
3683
|
-
module: "dist/0xsequence-provider.esm.js",
|
|
3684
|
-
author: "Horizon Blockchain Games",
|
|
3685
|
-
license: "Apache-2.0",
|
|
3686
|
-
scripts: {
|
|
3687
|
-
test: "pnpm test:concurrently 'pnpm test:run'",
|
|
3688
|
-
"test:run": "pnpm test:file tests/**/*.spec.ts",
|
|
3689
|
-
"test:file": "NODE_OPTIONS='--import tsx' mocha --timeout 30000",
|
|
3690
|
-
typecheck: "tsc --noEmit",
|
|
3691
|
-
"test:concurrently": "concurrently -k --success first 'pnpm start:hardhat1' 'pnpm start:hardhat2'",
|
|
3692
|
-
"start:hardhat1": "pnpm start:hardhat1:verbose > /dev/null 2>&1",
|
|
3693
|
-
"start:hardhat2": "pnpm start:hardhat2:verbose > /dev/null 2>&1",
|
|
3694
|
-
"start:hardhat1:verbose": "hardhat node --config hardhat1.config.js --hostname 0.0.0.0 --port 9595",
|
|
3695
|
-
"start:hardhat2:verbose": "hardhat node --config hardhat2.config.js --hostname 0.0.0.0 --port 8595"
|
|
3696
|
-
},
|
|
3697
|
-
dependencies: {
|
|
3698
|
-
"@0xsequence/abi": "workspace:*",
|
|
3699
|
-
"@0xsequence/account": "workspace:*",
|
|
3700
|
-
"@0xsequence/auth": "workspace:*",
|
|
3701
|
-
"@0xsequence/core": "workspace:*",
|
|
3702
|
-
"@0xsequence/migration": "workspace:*",
|
|
3703
|
-
"@0xsequence/network": "workspace:*",
|
|
3704
|
-
"@0xsequence/relayer": "workspace:*",
|
|
3705
|
-
"@0xsequence/utils": "workspace:*",
|
|
3706
|
-
"@0xsequence/wallet": "workspace:*",
|
|
3707
|
-
"@databeat/tracker": "^0.9.1",
|
|
3708
|
-
eventemitter2: "^6.4.5",
|
|
3709
|
-
"webextension-polyfill": "^0.10.0"
|
|
3710
|
-
},
|
|
3711
|
-
peerDependencies: {
|
|
3712
|
-
ethers: "corbanbrook/ethers.js"
|
|
3713
|
-
},
|
|
3714
|
-
devDependencies: {
|
|
3715
|
-
"@types/webextension-polyfill": "^0.10.0",
|
|
3716
|
-
ethers: "corbanbrook/ethers.js",
|
|
3717
|
-
hardhat: "^2.20.1"
|
|
3718
|
-
},
|
|
3719
|
-
files: [
|
|
3720
|
-
"src",
|
|
3721
|
-
"dist"
|
|
3722
|
-
]
|
|
3723
|
-
};
|
|
3724
|
-
|
|
3725
3689
|
/**
|
|
3726
3690
|
* This session class is meant to persist the state of the wallet connection
|
|
3727
3691
|
* whitin the dapp. This enables the client to retain the wallet address (and some more)
|
|
@@ -3986,7 +3950,7 @@ class SequenceClient {
|
|
|
3986
3950
|
type: 'connect',
|
|
3987
3951
|
options: _extends({}, options, {
|
|
3988
3952
|
networkId: this.getChainId(),
|
|
3989
|
-
clientVersion:
|
|
3953
|
+
clientVersion: core.VERSION
|
|
3990
3954
|
})
|
|
3991
3955
|
});
|
|
3992
3956
|
const connectDetails = await this.transport.waitUntilConnected().catch(error => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EventEmitter2 } from 'eventemitter2';
|
|
2
2
|
import { logger, encodeMessageDigest, encodeTypedDataDigest, sanitizeNumberString, sanitizeHost, sanitizeAlphanumeric, base64EncodeObject, base64DecodeObject, toHexString } from '@0xsequence/utils';
|
|
3
3
|
import { ethers } from 'ethers';
|
|
4
|
+
import { VERSION, commons } from '@0xsequence/core';
|
|
4
5
|
import { findSupportedNetwork, ChainId, findNetworkConfig, allNetworks, JsonRpcProvider, loggingProviderMiddleware, exceptionProviderMiddleware, CachedProvider } from '@0xsequence/network';
|
|
5
|
-
import { commons } from '@0xsequence/core';
|
|
6
6
|
import { signAuthorization } from '@0xsequence/auth';
|
|
7
7
|
import { walletContracts } from '@0xsequence/abi';
|
|
8
8
|
import { isBrowser, Databeat } from '@databeat/tracker';
|
|
@@ -238,7 +238,8 @@ class BaseProviderTransport {
|
|
|
238
238
|
idx: nextMessageIdx(),
|
|
239
239
|
type: EventType.MESSAGE,
|
|
240
240
|
data: request,
|
|
241
|
-
chainId: request.chainId
|
|
241
|
+
chainId: request.chainId,
|
|
242
|
+
clientVersion: VERSION
|
|
242
243
|
});
|
|
243
244
|
return response.data;
|
|
244
245
|
}
|
|
@@ -264,7 +265,8 @@ class BaseProviderTransport {
|
|
|
264
265
|
data: {
|
|
265
266
|
sessionId: this._sessionId,
|
|
266
267
|
nonce: nonce
|
|
267
|
-
}
|
|
268
|
+
},
|
|
269
|
+
clientVersion: VERSION
|
|
268
270
|
});
|
|
269
271
|
}
|
|
270
272
|
if (this._init !== InitState.OK) {
|
|
@@ -999,7 +1001,8 @@ class BaseWalletTransport {
|
|
|
999
1001
|
sessionId,
|
|
1000
1002
|
session,
|
|
1001
1003
|
error
|
|
1002
|
-
}
|
|
1004
|
+
},
|
|
1005
|
+
clientVersion: VERSION
|
|
1003
1006
|
});
|
|
1004
1007
|
}
|
|
1005
1008
|
notifyClose(error) {
|
|
@@ -1008,14 +1011,16 @@ class BaseWalletTransport {
|
|
|
1008
1011
|
type: EventType.CLOSE,
|
|
1009
1012
|
data: error ? {
|
|
1010
1013
|
error
|
|
1011
|
-
} : null
|
|
1014
|
+
} : null,
|
|
1015
|
+
clientVersion: VERSION
|
|
1012
1016
|
});
|
|
1013
1017
|
}
|
|
1014
1018
|
notifyConnect(connectDetails) {
|
|
1015
1019
|
this.sendMessage({
|
|
1016
1020
|
idx: -1,
|
|
1017
1021
|
type: EventType.CONNECT,
|
|
1018
|
-
data: connectDetails
|
|
1022
|
+
data: connectDetails,
|
|
1023
|
+
clientVersion: VERSION
|
|
1019
1024
|
});
|
|
1020
1025
|
}
|
|
1021
1026
|
notifyDisconnect(error, origin) {
|
|
@@ -1025,7 +1030,8 @@ class BaseWalletTransport {
|
|
|
1025
1030
|
data: error ? {
|
|
1026
1031
|
error
|
|
1027
1032
|
} : null,
|
|
1028
|
-
origin
|
|
1033
|
+
origin,
|
|
1034
|
+
clientVersion: VERSION
|
|
1029
1035
|
});
|
|
1030
1036
|
}
|
|
1031
1037
|
notifyAccountsChanged(accounts, origin) {
|
|
@@ -1033,7 +1039,8 @@ class BaseWalletTransport {
|
|
|
1033
1039
|
idx: -1,
|
|
1034
1040
|
type: EventType.ACCOUNTS_CHANGED,
|
|
1035
1041
|
data: accounts,
|
|
1036
|
-
origin
|
|
1042
|
+
origin,
|
|
1043
|
+
clientVersion: VERSION
|
|
1037
1044
|
});
|
|
1038
1045
|
}
|
|
1039
1046
|
notifyChainChanged(chainIdHex, origin) {
|
|
@@ -1041,21 +1048,24 @@ class BaseWalletTransport {
|
|
|
1041
1048
|
idx: -1,
|
|
1042
1049
|
type: EventType.CHAIN_CHANGED,
|
|
1043
1050
|
data: chainIdHex,
|
|
1044
|
-
origin
|
|
1051
|
+
origin,
|
|
1052
|
+
clientVersion: VERSION
|
|
1045
1053
|
});
|
|
1046
1054
|
}
|
|
1047
1055
|
notifyNetworks(networks) {
|
|
1048
1056
|
this.sendMessage({
|
|
1049
1057
|
idx: -1,
|
|
1050
1058
|
type: EventType.NETWORKS,
|
|
1051
|
-
data: networks
|
|
1059
|
+
data: networks,
|
|
1060
|
+
clientVersion: VERSION
|
|
1052
1061
|
});
|
|
1053
1062
|
}
|
|
1054
1063
|
notifyWalletContext(walletContext) {
|
|
1055
1064
|
this.sendMessage({
|
|
1056
1065
|
idx: -1,
|
|
1057
1066
|
type: EventType.WALLET_CONTEXT,
|
|
1058
|
-
data: walletContext
|
|
1067
|
+
data: walletContext,
|
|
1068
|
+
clientVersion: VERSION
|
|
1059
1069
|
});
|
|
1060
1070
|
}
|
|
1061
1071
|
isValidInitAck(message) {
|
|
@@ -1126,7 +1136,8 @@ class BaseWalletTransport {
|
|
|
1126
1136
|
type: EventType.INIT,
|
|
1127
1137
|
data: {
|
|
1128
1138
|
nonce: this._initNonce
|
|
1129
|
-
}
|
|
1139
|
+
},
|
|
1140
|
+
clientVersion: VERSION
|
|
1130
1141
|
});
|
|
1131
1142
|
this._init = InitState.SENT_NONCE;
|
|
1132
1143
|
|
|
@@ -1225,7 +1236,8 @@ class ProxyMessageProvider extends BaseProviderTransport {
|
|
|
1225
1236
|
intent,
|
|
1226
1237
|
networkId,
|
|
1227
1238
|
sessionId
|
|
1228
|
-
}
|
|
1239
|
+
},
|
|
1240
|
+
clientVersion: VERSION
|
|
1229
1241
|
});
|
|
1230
1242
|
}
|
|
1231
1243
|
};
|
|
@@ -1243,7 +1255,8 @@ class ProxyMessageProvider extends BaseProviderTransport {
|
|
|
1243
1255
|
this.sendMessage({
|
|
1244
1256
|
idx: -1,
|
|
1245
1257
|
type: EventType.CLOSE,
|
|
1246
|
-
data: null
|
|
1258
|
+
data: null,
|
|
1259
|
+
clientVersion: VERSION
|
|
1247
1260
|
});
|
|
1248
1261
|
this.close();
|
|
1249
1262
|
}
|
|
@@ -2340,10 +2353,10 @@ class WalletRequestHandler {
|
|
|
2340
2353
|
// (aka, the signer in this instance) and then responds with a wrapped response of
|
|
2341
2354
|
// ProviderMessageResponse to be sent over the transport
|
|
2342
2355
|
async sendMessageRequest(message) {
|
|
2343
|
-
var
|
|
2356
|
+
var _message$clientVersio;
|
|
2344
2357
|
// Older versions of the client require the response to be jsonrpc wrapped
|
|
2345
|
-
const majorVersion = Number(((
|
|
2346
|
-
const isJsonRpcResponse = majorVersion
|
|
2358
|
+
const majorVersion = Number(((_message$clientVersio = message.clientVersion) == null ? void 0 : _message$clientVersio.split('.')[0]) || '0');
|
|
2359
|
+
const isJsonRpcResponse = majorVersion < 2;
|
|
2347
2360
|
const jsonRpcResponse = {
|
|
2348
2361
|
id: message.data.id,
|
|
2349
2362
|
jsonrpc: '2.0',
|
|
@@ -3669,55 +3682,6 @@ const setupAnalytics = (projectAccessKey, server) => {
|
|
|
3669
3682
|
});
|
|
3670
3683
|
};
|
|
3671
3684
|
|
|
3672
|
-
var packageJson = {
|
|
3673
|
-
name: "@0xsequence/provider",
|
|
3674
|
-
version: "0.0.0-20240402220106",
|
|
3675
|
-
description: "provider sub-package for Sequence",
|
|
3676
|
-
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3677
|
-
source: "src/index.ts",
|
|
3678
|
-
main: "dist/0xsequence-provider.cjs.js",
|
|
3679
|
-
module: "dist/0xsequence-provider.esm.js",
|
|
3680
|
-
author: "Horizon Blockchain Games",
|
|
3681
|
-
license: "Apache-2.0",
|
|
3682
|
-
scripts: {
|
|
3683
|
-
test: "pnpm test:concurrently 'pnpm test:run'",
|
|
3684
|
-
"test:run": "pnpm test:file tests/**/*.spec.ts",
|
|
3685
|
-
"test:file": "NODE_OPTIONS='--import tsx' mocha --timeout 30000",
|
|
3686
|
-
typecheck: "tsc --noEmit",
|
|
3687
|
-
"test:concurrently": "concurrently -k --success first 'pnpm start:hardhat1' 'pnpm start:hardhat2'",
|
|
3688
|
-
"start:hardhat1": "pnpm start:hardhat1:verbose > /dev/null 2>&1",
|
|
3689
|
-
"start:hardhat2": "pnpm start:hardhat2:verbose > /dev/null 2>&1",
|
|
3690
|
-
"start:hardhat1:verbose": "hardhat node --config hardhat1.config.js --hostname 0.0.0.0 --port 9595",
|
|
3691
|
-
"start:hardhat2:verbose": "hardhat node --config hardhat2.config.js --hostname 0.0.0.0 --port 8595"
|
|
3692
|
-
},
|
|
3693
|
-
dependencies: {
|
|
3694
|
-
"@0xsequence/abi": "workspace:*",
|
|
3695
|
-
"@0xsequence/account": "workspace:*",
|
|
3696
|
-
"@0xsequence/auth": "workspace:*",
|
|
3697
|
-
"@0xsequence/core": "workspace:*",
|
|
3698
|
-
"@0xsequence/migration": "workspace:*",
|
|
3699
|
-
"@0xsequence/network": "workspace:*",
|
|
3700
|
-
"@0xsequence/relayer": "workspace:*",
|
|
3701
|
-
"@0xsequence/utils": "workspace:*",
|
|
3702
|
-
"@0xsequence/wallet": "workspace:*",
|
|
3703
|
-
"@databeat/tracker": "^0.9.1",
|
|
3704
|
-
eventemitter2: "^6.4.5",
|
|
3705
|
-
"webextension-polyfill": "^0.10.0"
|
|
3706
|
-
},
|
|
3707
|
-
peerDependencies: {
|
|
3708
|
-
ethers: "corbanbrook/ethers.js"
|
|
3709
|
-
},
|
|
3710
|
-
devDependencies: {
|
|
3711
|
-
"@types/webextension-polyfill": "^0.10.0",
|
|
3712
|
-
ethers: "corbanbrook/ethers.js",
|
|
3713
|
-
hardhat: "^2.20.1"
|
|
3714
|
-
},
|
|
3715
|
-
files: [
|
|
3716
|
-
"src",
|
|
3717
|
-
"dist"
|
|
3718
|
-
]
|
|
3719
|
-
};
|
|
3720
|
-
|
|
3721
3685
|
/**
|
|
3722
3686
|
* This session class is meant to persist the state of the wallet connection
|
|
3723
3687
|
* whitin the dapp. This enables the client to retain the wallet address (and some more)
|
|
@@ -3982,7 +3946,7 @@ class SequenceClient {
|
|
|
3982
3946
|
type: 'connect',
|
|
3983
3947
|
options: _extends({}, options, {
|
|
3984
3948
|
networkId: this.getChainId(),
|
|
3985
|
-
clientVersion:
|
|
3949
|
+
clientVersion: VERSION
|
|
3986
3950
|
})
|
|
3987
3951
|
});
|
|
3988
3952
|
const connectDetails = await this.transport.waitUntilConnected().catch(error => {
|
|
@@ -37,6 +37,7 @@ export interface ProviderMessage<T> {
|
|
|
37
37
|
data: T;
|
|
38
38
|
chainId?: number;
|
|
39
39
|
origin?: string;
|
|
40
|
+
clientVersion: string;
|
|
40
41
|
}
|
|
41
42
|
export type ProviderMessageRequest = ProviderMessage<JsonRpcRequest>;
|
|
42
43
|
export type ProviderMessageResponse = ProviderMessage<JsonRpcResponse | any>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/provider",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-20240403204458",
|
|
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",
|
|
@@ -12,15 +12,15 @@
|
|
|
12
12
|
"@databeat/tracker": "^0.9.1",
|
|
13
13
|
"eventemitter2": "^6.4.5",
|
|
14
14
|
"webextension-polyfill": "^0.10.0",
|
|
15
|
-
"@0xsequence/abi": "0.0.0-
|
|
16
|
-
"@0xsequence/account": "0.0.0-
|
|
17
|
-
"@0xsequence/auth": "0.0.0-
|
|
18
|
-
"@0xsequence/core": "0.0.0-
|
|
19
|
-
"@0xsequence/migration": "0.0.0-
|
|
20
|
-
"@0xsequence/network": "0.0.0-
|
|
21
|
-
"@0xsequence/relayer": "0.0.0-
|
|
22
|
-
"@0xsequence/utils": "0.0.0-
|
|
23
|
-
"@0xsequence/wallet": "0.0.0-
|
|
15
|
+
"@0xsequence/abi": "0.0.0-20240403204458",
|
|
16
|
+
"@0xsequence/account": "0.0.0-20240403204458",
|
|
17
|
+
"@0xsequence/auth": "0.0.0-20240403204458",
|
|
18
|
+
"@0xsequence/core": "0.0.0-20240403204458",
|
|
19
|
+
"@0xsequence/migration": "0.0.0-20240403204458",
|
|
20
|
+
"@0xsequence/network": "0.0.0-20240403204458",
|
|
21
|
+
"@0xsequence/relayer": "0.0.0-20240403204458",
|
|
22
|
+
"@0xsequence/utils": "0.0.0-20240403204458",
|
|
23
|
+
"@0xsequence/wallet": "0.0.0-20240403204458"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"ethers": "corbanbrook/ethers.js"
|
package/src/client.ts
CHANGED
|
@@ -14,14 +14,12 @@ import {
|
|
|
14
14
|
isMuxTransportTemplate,
|
|
15
15
|
isProviderTransport
|
|
16
16
|
} from '.'
|
|
17
|
-
import { commons } from '@0xsequence/core'
|
|
17
|
+
import { commons, VERSION } from '@0xsequence/core'
|
|
18
18
|
import { TypedData } from '@0xsequence/utils'
|
|
19
19
|
import { toExtended } from './extended'
|
|
20
20
|
import { Analytics, setupAnalytics } from './analytics'
|
|
21
21
|
import { ethers } from 'ethers'
|
|
22
22
|
|
|
23
|
-
import packageJson from '../package.json'
|
|
24
|
-
|
|
25
23
|
/**
|
|
26
24
|
* This session class is meant to persist the state of the wallet connection
|
|
27
25
|
* whitin the dapp. This enables the client to retain the wallet address (and some more)
|
|
@@ -336,7 +334,7 @@ export class SequenceClient {
|
|
|
336
334
|
|
|
337
335
|
await this.openWallet(undefined, {
|
|
338
336
|
type: 'connect',
|
|
339
|
-
options: { ...options, networkId: this.getChainId(), clientVersion:
|
|
337
|
+
options: { ...options, networkId: this.getChainId(), clientVersion: VERSION }
|
|
340
338
|
})
|
|
341
339
|
|
|
342
340
|
const connectDetails = await this.transport.waitUntilConnected().catch((error): ConnectDetails => {
|
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
TypedEventEmitter
|
|
18
18
|
} from '../types'
|
|
19
19
|
|
|
20
|
-
import {
|
|
20
|
+
import { NetworkConfig } from '@0xsequence/network'
|
|
21
21
|
import { logger } from '@0xsequence/utils'
|
|
22
22
|
import { ethers } from 'ethers'
|
|
23
|
-
import { commons } from '@0xsequence/core'
|
|
23
|
+
import { VERSION, commons } from '@0xsequence/core'
|
|
24
24
|
|
|
25
25
|
export const PROVIDER_OPEN_TIMEOUT = 30000 // in ms
|
|
26
26
|
|
|
@@ -112,7 +112,8 @@ export abstract class BaseProviderTransport implements ProviderTransport {
|
|
|
112
112
|
idx: nextMessageIdx(),
|
|
113
113
|
type: EventType.MESSAGE,
|
|
114
114
|
data: request,
|
|
115
|
-
chainId: request.chainId
|
|
115
|
+
chainId: request.chainId,
|
|
116
|
+
clientVersion: VERSION
|
|
116
117
|
})
|
|
117
118
|
|
|
118
119
|
return response.data
|
|
@@ -136,7 +137,8 @@ export abstract class BaseProviderTransport implements ProviderTransport {
|
|
|
136
137
|
data: {
|
|
137
138
|
sessionId: this._sessionId,
|
|
138
139
|
nonce: nonce
|
|
139
|
-
}
|
|
140
|
+
},
|
|
141
|
+
clientVersion: VERSION
|
|
140
142
|
})
|
|
141
143
|
}
|
|
142
144
|
|
|
@@ -20,7 +20,7 @@ import { AuthorizationOptions } from '@0xsequence/auth'
|
|
|
20
20
|
|
|
21
21
|
import { PROVIDER_OPEN_TIMEOUT } from './base-provider-transport'
|
|
22
22
|
import { isBrowserExtension, useBestStore } from '../utils'
|
|
23
|
-
import { commons } from '@0xsequence/core'
|
|
23
|
+
import { VERSION, commons } from '@0xsequence/core'
|
|
24
24
|
|
|
25
25
|
const TRANSPORT_SESSION_LS_KEY = '@sequence.transportSession'
|
|
26
26
|
|
|
@@ -181,7 +181,8 @@ export abstract class BaseWalletTransport implements WalletTransport {
|
|
|
181
181
|
sessionId,
|
|
182
182
|
session,
|
|
183
183
|
error
|
|
184
|
-
}
|
|
184
|
+
},
|
|
185
|
+
clientVersion: VERSION
|
|
185
186
|
})
|
|
186
187
|
}
|
|
187
188
|
|
|
@@ -189,7 +190,8 @@ export abstract class BaseWalletTransport implements WalletTransport {
|
|
|
189
190
|
this.sendMessage({
|
|
190
191
|
idx: -1,
|
|
191
192
|
type: EventType.CLOSE,
|
|
192
|
-
data: error ? { error } : null
|
|
193
|
+
data: error ? { error } : null,
|
|
194
|
+
clientVersion: VERSION
|
|
193
195
|
})
|
|
194
196
|
}
|
|
195
197
|
|
|
@@ -197,7 +199,8 @@ export abstract class BaseWalletTransport implements WalletTransport {
|
|
|
197
199
|
this.sendMessage({
|
|
198
200
|
idx: -1,
|
|
199
201
|
type: EventType.CONNECT,
|
|
200
|
-
data: connectDetails
|
|
202
|
+
data: connectDetails,
|
|
203
|
+
clientVersion: VERSION
|
|
201
204
|
})
|
|
202
205
|
}
|
|
203
206
|
|
|
@@ -206,7 +209,8 @@ export abstract class BaseWalletTransport implements WalletTransport {
|
|
|
206
209
|
idx: -1,
|
|
207
210
|
type: EventType.DISCONNECT,
|
|
208
211
|
data: error ? { error } : null,
|
|
209
|
-
origin
|
|
212
|
+
origin,
|
|
213
|
+
clientVersion: VERSION
|
|
210
214
|
})
|
|
211
215
|
}
|
|
212
216
|
|
|
@@ -215,7 +219,8 @@ export abstract class BaseWalletTransport implements WalletTransport {
|
|
|
215
219
|
idx: -1,
|
|
216
220
|
type: EventType.ACCOUNTS_CHANGED,
|
|
217
221
|
data: accounts,
|
|
218
|
-
origin
|
|
222
|
+
origin,
|
|
223
|
+
clientVersion: VERSION
|
|
219
224
|
})
|
|
220
225
|
}
|
|
221
226
|
|
|
@@ -224,7 +229,8 @@ export abstract class BaseWalletTransport implements WalletTransport {
|
|
|
224
229
|
idx: -1,
|
|
225
230
|
type: EventType.CHAIN_CHANGED,
|
|
226
231
|
data: chainIdHex,
|
|
227
|
-
origin
|
|
232
|
+
origin,
|
|
233
|
+
clientVersion: VERSION
|
|
228
234
|
})
|
|
229
235
|
}
|
|
230
236
|
|
|
@@ -232,7 +238,8 @@ export abstract class BaseWalletTransport implements WalletTransport {
|
|
|
232
238
|
this.sendMessage({
|
|
233
239
|
idx: -1,
|
|
234
240
|
type: EventType.NETWORKS,
|
|
235
|
-
data: networks
|
|
241
|
+
data: networks,
|
|
242
|
+
clientVersion: VERSION
|
|
236
243
|
})
|
|
237
244
|
}
|
|
238
245
|
|
|
@@ -240,7 +247,8 @@ export abstract class BaseWalletTransport implements WalletTransport {
|
|
|
240
247
|
this.sendMessage({
|
|
241
248
|
idx: -1,
|
|
242
249
|
type: EventType.WALLET_CONTEXT,
|
|
243
|
-
data: walletContext
|
|
250
|
+
data: walletContext,
|
|
251
|
+
clientVersion: VERSION
|
|
244
252
|
})
|
|
245
253
|
}
|
|
246
254
|
|
|
@@ -309,7 +317,8 @@ export abstract class BaseWalletTransport implements WalletTransport {
|
|
|
309
317
|
this.sendMessage({
|
|
310
318
|
idx: -1,
|
|
311
319
|
type: EventType.INIT,
|
|
312
|
-
data: { nonce: this._initNonce }
|
|
320
|
+
data: { nonce: this._initNonce },
|
|
321
|
+
clientVersion: VERSION
|
|
313
322
|
})
|
|
314
323
|
this._init = InitState.SENT_NONCE
|
|
315
324
|
|
|
@@ -3,6 +3,7 @@ import { BaseProviderTransport } from '../base-provider-transport'
|
|
|
3
3
|
import { ProviderMessage, OpenState, OpenWalletIntent, EventType, InitState } from '../../types'
|
|
4
4
|
|
|
5
5
|
import { ProxyMessageChannelPort, ProxyEventTypes } from './proxy-message-channel'
|
|
6
|
+
import { VERSION } from '@0xsequence/core'
|
|
6
7
|
|
|
7
8
|
export class ProxyMessageProvider extends BaseProviderTransport {
|
|
8
9
|
private port: ProxyMessageChannelPort
|
|
@@ -62,7 +63,8 @@ export class ProxyMessageProvider extends BaseProviderTransport {
|
|
|
62
63
|
intent,
|
|
63
64
|
networkId,
|
|
64
65
|
sessionId
|
|
65
|
-
}
|
|
66
|
+
},
|
|
67
|
+
clientVersion: VERSION
|
|
66
68
|
})
|
|
67
69
|
}
|
|
68
70
|
}
|
|
@@ -71,7 +73,8 @@ export class ProxyMessageProvider extends BaseProviderTransport {
|
|
|
71
73
|
this.sendMessage({
|
|
72
74
|
idx: -1,
|
|
73
75
|
type: EventType.CLOSE,
|
|
74
|
-
data: null
|
|
76
|
+
data: null,
|
|
77
|
+
clientVersion: VERSION
|
|
75
78
|
})
|
|
76
79
|
this.close()
|
|
77
80
|
}
|
|
@@ -213,8 +213,8 @@ export class WalletRequestHandler implements EIP1193Provider, ProviderMessageReq
|
|
|
213
213
|
// ProviderMessageResponse to be sent over the transport
|
|
214
214
|
async sendMessageRequest(message: ProviderMessageRequest): Promise<ProviderMessageResponse> {
|
|
215
215
|
// Older versions of the client require the response to be jsonrpc wrapped
|
|
216
|
-
const majorVersion = Number(
|
|
217
|
-
const isJsonRpcResponse = majorVersion
|
|
216
|
+
const majorVersion = Number(message.clientVersion?.split('.')[0] || '0')
|
|
217
|
+
const isJsonRpcResponse = majorVersion < 2
|
|
218
218
|
const jsonRpcResponse: JsonRpcResponse = {
|
|
219
219
|
id: message.data.id!,
|
|
220
220
|
jsonrpc: '2.0',
|
|
@@ -668,7 +668,6 @@ export class WalletRequestHandler implements EIP1193Provider, ProviderMessageReq
|
|
|
668
668
|
|
|
669
669
|
setConnectOptions(options: ConnectOptions | undefined) {
|
|
670
670
|
this._connectOptions = options
|
|
671
|
-
|
|
672
671
|
this.onConnectOptionsChange?.(options)
|
|
673
672
|
}
|
|
674
673
|
|
package/src/types.ts
CHANGED
|
@@ -61,6 +61,7 @@ export interface ProviderMessage<T> {
|
|
|
61
61
|
data: T // the ethereum json-rpc payload
|
|
62
62
|
chainId?: number // chain id which the message is intended
|
|
63
63
|
origin?: string // origin of the message
|
|
64
|
+
clientVersion: string // client version of the message
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
export type ProviderMessageRequest = ProviderMessage<JsonRpcRequest>
|