Skip to content

Commit ef43c17

Browse files
authored
Merge pull request #1002 from liquality/feat/sovryn-fixes
Feat/sovryn fixes
2 parents f31ce7a + 1ab93f7 commit ef43c17

File tree

13 files changed

+93
-190
lines changed

13 files changed

+93
-190
lines changed

.env

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
VUE_APP_LEDGER_BRIDGE_URL=https://liquality.github.io/hw-web-bridge-app/dist/0.1.0
21
VUE_APP_SOVRYN_RPC_URL_TESTNET=https://testnet.sovryn.app/rpc
32
VUE_APP_SOVRYN_RPC_URL_MAINNET=https://mainnet.sovryn.app/rpc
43
VUE_APP_TRANSAK_WIDGET_URL=
@@ -24,4 +23,7 @@ VUE_APP_MAX_ERROR_LOG_SIZE=100
2423
VUE_APP_REPORT_TARGETS=Sentry,Console
2524
VUE_APP_NPM_PACKAGE_VERSION=0_81_0
2625
VUE_APP_SENTRY_DSN=https://2c52b9d6e67741cf9d4eabe32369827a@o241807.ingest.sentry.io/5444900
26+
VUE_APP_INFURA_NFT_API_URL=https://nft.api.infura.io/
27+
VUE_APP_INFURA_API_KEY=
28+
VUE_APP_INFURA_API_KEY_SECRET=
2729

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
},
2525
"dependencies": {
2626
"@chainify/hw-ledger": "2.4.0",
27-
"@liquality/cryptoassets": "2.8.0",
28-
"@liquality/error-parser": "2.2.6",
27+
"@liquality/cryptoassets": "2.9.0",
28+
"@liquality/error-parser": "2.2.8",
2929
"@liquality/ethereum-utils": "^1.13.12",
3030
"@liquality/terra-networks": "^1.13.12",
3131
"@liquality/types": "^1.13.12",
32-
"@liquality/wallet-core": "4.21.1",
32+
"@liquality/wallet-core": "4.23.0",
3333
"@terra-money/terra.js": "^3.1.6",
3434
"@testing-library/vue": "^5.8.2",
3535
"amplitude-js": "8.18.2",

src/broker/Background.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ class Background {
3636
} else if (isInternal) {
3737
this.onInternalConnection(connection)
3838
} else {
39-
if (connection.name !== 'HW-BRIDGE') {
40-
this.onExternalConnection(connection)
41-
}
39+
this.onExternalConnection(connection)
4240
}
4341
})
4442
}

src/components/ConnectionDrawer.vue

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,12 @@ export default {
138138
})
139139
}
140140
},
141-
created() {
142-
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
143-
if (tabs.length > 0) {
144-
const { origin } = new URL(tabs[0].url)
145-
this.currentOrigin = origin
146-
}
147-
})
141+
async created() {
142+
const [tab] = await browser.tabs.query({ active: true, currentWindow: true })
143+
if (tab) {
144+
const { origin } = new URL(tab.url)
145+
this.currentOrigin = origin
146+
}
148147
}
149148
}
150149
</script>

src/components/Head.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ export default {
8080
},
8181
methods: {
8282
...mapActions(['changeActiveNetwork']),
83-
...mapActions('app', ['settingsModalOpen']),
8483
toggleShowNetworks() {
8584
this.showNetworks = !this.showNetworks
8685
if (this.showNetworks) {
@@ -95,7 +94,6 @@ export default {
9594
if (this.showConnectionDrawer) {
9695
this.showNetworks = false
9796
}
98-
this.settingsModalOpen(false)
9997
},
10098
hideConnectionDrawer() {
10199
this.showConnectionDrawer = false

src/components/NavBar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export default {
235235
}
236236
})
237237
this.showMenuList = false
238-
chrome.tabs.create({
238+
browser.tabs.create({
239239
url: browser.runtime.getURL('/index.html#/accounts/hardware-wallet?mode=tab')
240240
})
241241
},

src/main.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import devtools from '@vue/devtools'
21
import Vue from 'vue'
32
import App from './App.vue'
43
import store from './store'
@@ -19,7 +18,3 @@ new Vue({
1918
store,
2019
render: (h) => h(App)
2120
}).$mount('#app')
22-
23-
if (process.env.NODE_ENV === 'development' && process.env.VUE_APP_USE_VUE_DEV_TOOLS) {
24-
devtools.connect()
25-
}

src/store/modules/app/requestPermission.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const ALLOWED = [
3636
]
3737

3838
export const requestPermission = async (
39-
{ state, dispatch, commit, rootState },
39+
{ state, dispatch, commit, rootState, rootGetters },
4040
{ origin, data }
4141
) => {
4242
const { requestPermissionActive } = state
@@ -103,7 +103,14 @@ export const requestPermission = async (
103103
permissionRoute = '/permission/signPsbt'
104104
}
105105

106-
createPopup(`${permissionRoute}?${query}`, () => reject(new UserDeclinedError()))
106+
const url = `${permissionRoute}?${query}`
107+
const account = rootGetters.accountItem(accountId)
108+
109+
if (account?.type.includes('ledger')) {
110+
browser.tabs.create({ url: browser.runtime.getURL(`/index.html#${url}`) })
111+
} else {
112+
createPopup(url, () => reject(new UserDeclinedError()))
113+
}
107114
})
108115
} else {
109116
commit('SET_REQUEST_PERMISSION_ACTIVE', { active: false })

src/utils/hardware-wallet.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
1-
import { LedgerDeviceConnectionError } from '@liquality/error-parser'
1+
// import { LedgerDeviceConnectionError } from '@liquality/error-parser'
22

33
export const LEDGER_USB_VENDOR_ID = '0x2c97'
44

5-
export async function tryConnectLedgerDevice() {
6-
const connectedDevices = await window.navigator.hid.requestDevice({
7-
filters: [{ vendorId: LEDGER_USB_VENDOR_ID }]
8-
})
9-
const userApprovedWebHidConnection = connectedDevices.some(
10-
(device) => device.vendorId === Number(LEDGER_USB_VENDOR_ID)
11-
)
12-
return !!userApprovedWebHidConnection
13-
}
14-
155
export const ledgerConnectMixin = {
166
data() {
177
return {
@@ -21,12 +11,20 @@ export const ledgerConnectMixin = {
2111
methods: {
2212
async connectLedger() {
2313
if (!this.ledgerConnected) {
24-
const connected = await tryConnectLedgerDevice()
25-
26-
if (!connected) {
27-
throw new LedgerDeviceConnectionError()
14+
if ('hid' in navigator) {
15+
let alreadyAssignedDevices = await navigator.hid.getDevices()
16+
const alreadyAssignedDevice = alreadyAssignedDevices.filter(
17+
(d) => d.vendorId === Number(LEDGER_USB_VENDOR_ID)
18+
)
19+
if (alreadyAssignedDevice.length > 0) {
20+
this.ledgerConnected = true
21+
} else {
22+
const [device] = await navigator.hid.requestDevice({
23+
filters: [{ vendorId: LEDGER_USB_VENDOR_ID }]
24+
})
25+
this.ledgerConnected = !!device
26+
}
2827
}
29-
this.ledgerConnected = connected
3028
}
3129
}
3230
}

src/views/PermissionSend.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ export default {
275275
} else {
276276
window.close()
277277
}
278+
} catch (err) {
279+
console.error(err)
278280
} finally {
279281
this.signRequestModalOpen = false
280282
this.loading = false

0 commit comments

Comments
 (0)