Skip to content

Commit c97e211

Browse files
authored
Merge pull request #357 from ava-labs/dev
Ledger v2 Release
2 parents 5800f16 + c63d2a4 commit c97e211

File tree

14 files changed

+692
-642
lines changed

14 files changed

+692
-642
lines changed

.github/workflows/release.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Cloudflare Release
2+
on: [push]
3+
4+
jobs:
5+
release:
6+
runs-on: ubuntu-latest
7+
env:
8+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: actions/setup-node@v3
12+
with:
13+
node-version: 15
14+
cache: yarn
15+
- name: Create .npmrc
16+
run: echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> .npmrc
17+
- name: Install dependencies
18+
run: yarn install --frozen-lockfile
19+
- run: yarn build
20+
- run: yarn test
21+
- name: Publish Web Wallet
22+
uses: cloudflare/[email protected]
23+
with:
24+
apiToken: ${{ secrets.CLOUDFLARE_PAGES_API_TOKEN }}
25+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
26+
command: pages publish ./dist --project-name=web-wallet

package.json

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
"private": true,
44
"version": "0.1.4",
55
"engines": {
6-
"node": "15.x"
6+
"node": "15.x"
77
},
88
"scripts": {
99
"build": "vue-cli-service build",
1010
"cypress": "cypress run",
1111
"format": "prettier '**/*.{js,ts,vue}' --write",
1212
"lint": "vue-cli-service lint",
13-
"release": "release-it",
1413
"serve": "vue-cli-service serve",
1514
"start": "node server/index.js",
1615
"test_watch": "jest --verbose --watch ./tests",
1716
"test_debug": "node --inspect-brk node_modules/.bin/jest ./tests --runInBand",
1817
"test": "jest --verbose ./tests"
1918
},
2019
"dependencies": {
21-
"@avalabs/avalanche-wallet-sdk": "0.18.3",
20+
"@avalabs/avalanche-wallet-sdk": "0.19.0-alpha.2",
21+
"@avalabs/hw-app-avalanche": "0.6.6",
2222
"@avalabs/vue_components": "0.10.0",
2323
"@ethereumjs/common": "2.0.0",
2424
"@ethereumjs/tx": "3.0.0",
@@ -27,7 +27,8 @@
2727
"@fortawesome/free-regular-svg-icons": "5.12.0",
2828
"@fortawesome/free-solid-svg-icons": "5.12.0",
2929
"@fortawesome/vue-fontawesome": "0.1.9",
30-
"@ledgerhq/hw-app-eth": "6.12.2",
30+
"@ledgerhq/hw-app-eth": "6.29.7",
31+
"@ledgerhq/hw-transport": "6.27.5",
3132
"@ledgerhq/hw-transport-u2f": "5.22.0",
3233
"@ledgerhq/hw-transport-webhid": "^5.51.1",
3334
"@ledgerhq/hw-transport-webusb": "5.22.0",
@@ -48,7 +49,7 @@
4849
"axios": "0.21.2",
4950
"big.js": "5.2.2",
5051
"bip32": "2.0.5",
51-
"bip32-path": "^0.4.2",
52+
"bip32-path": "0.4.2",
5253
"bip39": "3.0.2",
5354
"body-parser": "1.19.0",
5455
"bootstrap": "4.5.0",
@@ -112,12 +113,12 @@
112113
"@types/randomstring": "^1.1.8",
113114
"@typescript-eslint/eslint-plugin": "4.33.0",
114115
"@typescript-eslint/parser": "4.33.0",
115-
"@vue/cli-plugin-babel": "^4.1.0",
116-
"@vue/cli-plugin-eslint": "^4.1.0",
117-
"@vue/cli-plugin-router": "^4.1.0",
118-
"@vue/cli-plugin-typescript": "^4.3.1",
119-
"@vue/cli-plugin-vuex": "^4.1.0",
120-
"@vue/cli-service": "^4.5.13",
116+
"@vue/cli-plugin-babel": "4.5.13",
117+
"@vue/cli-plugin-eslint": "4.5.13",
118+
"@vue/cli-plugin-router": "4.5.13",
119+
"@vue/cli-plugin-typescript": "4.5.13",
120+
"@vue/cli-plugin-vuex": "4.5.13",
121+
"@vue/cli-service": "4.5.13",
121122
"@vue/eslint-config-typescript": "7.0.0",
122123
"@vue/test-utils": "^1.0.3",
123124
"babel-core": "^7.0.0-bridge.0",

src/components/Ledger/LedgerButton.vue

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,18 @@ import TransportWebHID from '@ledgerhq/hw-transport-webhid'
2424
import Eth from '@ledgerhq/hw-app-eth'
2525
// @ts-ignore
2626
import AppAvax from '@obsidiansystems/hw-app-avalanche'
27+
import AvalancheApp from '@avalabs/hw-app-avalanche'
28+
import Transport from '@ledgerhq/hw-transport'
29+
2730
import Spinner from '@/components/misc/Spinner.vue'
2831
import LedgerBlock from '@/components/modals/LedgerBlock.vue'
29-
import { LedgerWallet, MIN_EVM_SUPPORT_V } from '@/js/wallets/LedgerWallet'
32+
import { LedgerWallet } from '@/js/wallets/LedgerWallet'
3033
import { AVA_ACCOUNT_PATH, LEDGER_ETH_ACCOUNT_PATH } from '@/js/wallets/MnemonicWallet'
3134
import { ILedgerAppConfig } from '@/store/types'
3235
import { LEDGER_EXCHANGE_TIMEOUT } from '@/store/modules/ledger/types'
3336
import ImageDayNight from '@/components/misc/ImageDayNight.vue'
37+
import { getLedgerProvider } from '@avalabs/avalanche-wallet-sdk'
38+
import { MIN_LEDGER_V } from '@/js/wallets/constants'
3439
3540
@Component({
3641
components: {
@@ -41,8 +46,7 @@ import ImageDayNight from '@/components/misc/ImageDayNight.vue'
4146
})
4247
export default class LedgerButton extends Vue {
4348
isLoading: boolean = false
44-
config?: ILedgerAppConfig = undefined
45-
49+
version?: string = undefined
4650
destroyed() {
4751
this.$store.commit('Ledger/closeModal')
4852
}
@@ -71,26 +75,23 @@ export default class LedgerButton extends Vue {
7175
let transport = await this.getTransport()
7276
transport.setExchangeTimeout(LEDGER_EXCHANGE_TIMEOUT)
7377
74-
let app = new AppAvax(transport, 'w0w')
75-
let eth = new Eth(transport, 'w0w')
76-
7778
// Wait for app config
78-
await this.waitForConfig(app)
79+
await this.waitForConfig(transport)
7980
8081
// Close the initial prompt modal if exists
8182
this.$store.commit('Ledger/setIsUpgradeRequired', false)
8283
this.isLoading = true
8384
84-
if (!this.config) {
85+
if (!this.version) {
8586
this.$store.commit('Ledger/setIsUpgradeRequired', true)
8687
this.isLoading = false
8788
throw new Error('')
8889
}
8990
90-
if (this.config.version < MIN_EVM_SUPPORT_V) {
91+
if (this.version < MIN_LEDGER_V) {
9192
this.$store.commit('Ledger/setIsUpgradeRequired', true)
9293
this.isLoading = false
93-
return
94+
throw new Error('')
9495
}
9596
9697
let title = 'Provide Public Keys'
@@ -110,11 +111,7 @@ export default class LedgerButton extends Vue {
110111
messages,
111112
})
112113
113-
let wallet = await LedgerWallet.fromApp(
114-
app,
115-
eth,
116-
(this.config as unknown) as ILedgerAppConfig
117-
)
114+
let wallet = await LedgerWallet.fromTransport(transport)
118115
try {
119116
await this.loadWallet(wallet)
120117
this.onsuccess()
@@ -126,15 +123,20 @@ export default class LedgerButton extends Vue {
126123
}
127124
}
128125
129-
async waitForConfig(app: AppAvax) {
126+
async waitForConfig(t: Transport) {
130127
// Config is found immediately if the device is connected and the app is open.
131128
// If no config was found that means user has not opened the Avalanche app.
132129
setTimeout(() => {
133-
if (this.config) return
130+
if (this.version) return
134131
this.$store.commit('Ledger/setIsUpgradeRequired', true)
135132
}, 1000)
136133
137-
this.config = await app.getAppConfiguration()
134+
try {
135+
const prov = await getLedgerProvider(t)
136+
this.version = await prov.getVersion(t)
137+
} catch (e) {
138+
// this.version = await (app as AvalancheApp).
139+
}
138140
}
139141
140142
async loadWallet(wallet: LedgerWallet) {
@@ -160,11 +162,11 @@ export default class LedgerButton extends Vue {
160162
onsuccess() {
161163
this.$store.commit('Ledger/setIsWalletLoading', false)
162164
this.isLoading = false
163-
this.config = undefined
165+
this.version = undefined
164166
}
165167
onerror(err: any) {
166168
this.isLoading = false
167-
this.config = undefined
169+
this.version = undefined
168170
this.$store.commit('Ledger/closeModal')
169171
console.error(err)
170172

src/components/modals/HdDerivationList/HdDerivationListRow.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,8 @@ export default class HdDerivationListRow extends Vue {
6767
6868
async verifyLedgerAddress() {
6969
const wallet = this.wallet as LedgerWallet
70-
71-
let networkId = ava.getNetworkID()
72-
let hrp = getPreferredHRP(networkId)
73-
74-
wallet.app.getWalletAddress(`${AVA_ACCOUNT_PATH}/${this.path}/${this.index}`, hrp)
70+
const isInternal = this.path == 1
71+
wallet.verifyAddress(this.index, isInternal)
7572
}
7673
}
7774
</script>

src/components/modals/HdDerivationList/HdEmptyAddressRow.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,8 @@ export default class HdEmptyAddressRow extends Vue {
3636
3737
async verifyLedgerAddress() {
3838
const wallet = this.wallet as LedgerWallet
39-
40-
let networkId = ava.getNetworkID()
41-
let hrp = getPreferredHRP(networkId)
42-
43-
wallet.app.getWalletAddress(`${AVA_ACCOUNT_PATH}/${this.path}/${this.index}`, hrp)
39+
const isInternal = this.path == 1
40+
wallet.verifyAddress(this.index, isInternal)
4441
}
4542
}
4643
</script>

src/components/modals/LedgerUpgrade.vue

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<li>Enter your PIN and access your device.</li>
77
<li>
88
Ensure you have installed the
9-
<b>Avalanche App v0.5.9</b>
10-
and open it on your device.
9+
<b>Avalanche App v{{ minV }}</b>
10+
or above and open it on your device.
1111
</li>
1212
</ol>
1313
<p style="margin-top: 12px !important">
@@ -16,8 +16,8 @@
1616
<a href="https://www.ledger.com/ledger-live/download" target="_blank">
1717
Ledger Live
1818
</a>
19-
app manager. The minimum version required to use the app is version 0.5.9, more
20-
instructions can be found
19+
app manager. The minimum version required to use the app is version {{ minV }},
20+
more instructions can be found
2121
<a
2222
target="_blank"
2323
href="https://support.avax.network/en/articles/6150237-how-to-use-a-ledger-nano-s-or-nano-x-with-avalanche"
@@ -31,13 +31,13 @@
3131
</modal>
3232
</template>
3333
<script lang="ts">
34-
import { LedgerWallet, MIN_EVM_SUPPORT_V } from '@/js/wallets/LedgerWallet'
3534
import { WalletType } from '@/js/wallets/types'
3635
3736
import 'reflect-metadata'
3837
import { Vue, Component, Watch } from 'vue-property-decorator'
3938
4039
import Modal from './Modal.vue'
40+
import { MIN_LEDGER_V } from '@/js/wallets/constants'
4141
4242
@Component({
4343
components: {
@@ -66,7 +66,7 @@ export default class LedgerUpgrade extends Vue {
6666
}
6767
6868
get minV() {
69-
return MIN_EVM_SUPPORT_V
69+
return MIN_LEDGER_V
7070
}
7171
7272
get isActive() {
@@ -77,11 +77,6 @@ export default class LedgerUpgrade extends Vue {
7777
return this.$store.state.activeWallet as WalletType
7878
}
7979
80-
get config() {
81-
if (!this.wallet) return {}
82-
return (this.wallet as LedgerWallet).config
83-
}
84-
8580
@Watch('isActive', { immediate: true })
8681
onActive(val: boolean): void {
8782
if (!this.$refs.modal) return

src/components/wallet/TopCards/AddressCard/AddressCard.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,10 @@ export default class AddressCard extends Vue {
244244
switch (this.chainNow) {
245245
case 'X':
246246
case 'P':
247-
wallet.app.getWalletAddress(`${AVA_ACCOUNT_PATH}/0/${this.activeIdx}`, hrp)
247+
wallet.verifyAddress(this.activeIdx, false, this.chainNow)
248248
break
249249
case 'C':
250-
wallet.ethApp.getAddress(`${LEDGER_ETH_ACCOUNT_PATH}`)
250+
wallet.ethApp.getAddress(`${LEDGER_ETH_ACCOUNT_PATH}`, true)
251251
}
252252
}
253253

0 commit comments

Comments
 (0)