@meshconnect/uwc-injected-connector 0.26.2-snapshot.bd11e28 → 0.26.3
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshconnect/uwc-injected-connector",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.3",
|
|
4
4
|
"description": "Injected connector for Universal Wallet Connector",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"buffer": "^6.0.3",
|
|
28
28
|
"uuid": "^14.0.2",
|
|
29
29
|
"viem": "^2.56.5",
|
|
30
|
-
"@meshconnect/uwc-
|
|
31
|
-
"@meshconnect/uwc-
|
|
32
|
-
"@meshconnect/uwc-ton-connector": "0.9.9
|
|
33
|
-
"@meshconnect/uwc-bitcoin": "0.5.3
|
|
34
|
-
"@meshconnect/uwc-tron-connector": "0.7.13
|
|
35
|
-
"@meshconnect/uwc-types": "0.30.1
|
|
30
|
+
"@meshconnect/uwc-bridge-child": "0.6.1",
|
|
31
|
+
"@meshconnect/uwc-constants": "0.8.1",
|
|
32
|
+
"@meshconnect/uwc-ton-connector": "0.9.9",
|
|
33
|
+
"@meshconnect/uwc-bitcoin": "0.5.3",
|
|
34
|
+
"@meshconnect/uwc-tron-connector": "0.7.13",
|
|
35
|
+
"@meshconnect/uwc-types": "0.30.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"typescript": "^7.0.2"
|
|
@@ -964,7 +964,8 @@ describe('BitcoinWalletService', () => {
|
|
|
964
964
|
expect(address).toBe('bc1qgranted')
|
|
965
965
|
})
|
|
966
966
|
|
|
967
|
-
|
|
967
|
+
// Connected on `original`; the parent has since switched to GRANTED.
|
|
968
|
+
async function connectThenSwitchInParent() {
|
|
968
969
|
const original: Account = {
|
|
969
970
|
address: 'bc1qoriginal',
|
|
970
971
|
publicKey: new Uint8Array([1])
|
|
@@ -989,16 +990,63 @@ describe('BitcoinWalletService', () => {
|
|
|
989
990
|
await service.initializeDiscovery()
|
|
990
991
|
await service.connect(NETWORK, makeProvider('metamask-uuid'))
|
|
991
992
|
const refresh = installRefresh(wallet, [GRANTED])
|
|
993
|
+
return { refresh, signMessage }
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
it('getLiveAccount follows an account switch made in the parent', async () => {
|
|
997
|
+
const { refresh } = await connectThenSwitchInParent()
|
|
992
998
|
|
|
993
999
|
expect(await service.getLiveAccount()).toBe('bc1qgranted')
|
|
994
1000
|
expect(refresh).toHaveBeenCalledWith('metamask-uuid')
|
|
1001
|
+
})
|
|
1002
|
+
|
|
1003
|
+
// Nothing else reads the accounts first, so only signMessage's own re-read
|
|
1004
|
+
// can hand the wallet the switched account.
|
|
1005
|
+
it('signMessage re-reads the parent and signs with the switched account', async () => {
|
|
1006
|
+
const { refresh, signMessage } = await connectThenSwitchInParent()
|
|
995
1007
|
|
|
996
1008
|
await service.signMessage('hi')
|
|
1009
|
+
|
|
1010
|
+
expect(refresh).toHaveBeenCalledWith('metamask-uuid')
|
|
997
1011
|
expect(signMessage).toHaveBeenCalledWith(
|
|
998
1012
|
expect.objectContaining({
|
|
999
1013
|
account: expect.objectContaining({ address: 'bc1qgranted' })
|
|
1000
1014
|
})
|
|
1001
1015
|
)
|
|
1016
|
+
expect(service.getAccount()).toBe('bc1qgranted')
|
|
1017
|
+
})
|
|
1018
|
+
|
|
1019
|
+
it('signMessage signs with the account it has when the re-read fails', async () => {
|
|
1020
|
+
const { signMessage } = await connectThenSwitchInParent()
|
|
1021
|
+
bridgedWindow.__uwcRefreshBip122Accounts = vi
|
|
1022
|
+
.fn()
|
|
1023
|
+
.mockRejectedValue(new Error('bridge gone'))
|
|
1024
|
+
|
|
1025
|
+
await service.signMessage('hi')
|
|
1026
|
+
|
|
1027
|
+
expect(signMessage).toHaveBeenCalledWith(
|
|
1028
|
+
expect.objectContaining({
|
|
1029
|
+
account: expect.objectContaining({ address: 'bc1qoriginal' })
|
|
1030
|
+
})
|
|
1031
|
+
)
|
|
1032
|
+
})
|
|
1033
|
+
|
|
1034
|
+
// ConnectionManager restores a session by checking, then setting state on
|
|
1035
|
+
// the same detected wallet.
|
|
1036
|
+
it('a restore after checkExistingConnection uses the re-read account', async () => {
|
|
1037
|
+
const detected = {
|
|
1038
|
+
uuid: 'metamask-uuid',
|
|
1039
|
+
name: 'MetaMask',
|
|
1040
|
+
features: [],
|
|
1041
|
+
wallet: { name: 'MetaMask', accounts: [] as Account[], features: {} }
|
|
1042
|
+
}
|
|
1043
|
+
installRefresh(detected.wallet, [GRANTED])
|
|
1044
|
+
|
|
1045
|
+
const address = await service.checkExistingConnection(detected)
|
|
1046
|
+
service.setConnectionState(detected, address)
|
|
1047
|
+
|
|
1048
|
+
expect(service.isConnected()).toBe(true)
|
|
1049
|
+
expect(service.getAccount()).toBe('bc1qgranted')
|
|
1002
1050
|
})
|
|
1003
1051
|
|
|
1004
1052
|
it('falls back to the accounts it has when the re-read fails', async () => {
|