Skip to content

Commit

Permalink
Merge pull request #325 from ava-labs/update/dependencies
Browse files Browse the repository at this point in the history
Update/dependencies
  • Loading branch information
abenso authored Sep 23, 2024
2 parents 440b131 + 8886272 commit d5f6768
Show file tree
Hide file tree
Showing 28 changed files with 4,664 additions and 5,206 deletions.
8 changes: 8 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Checklist
<!-- Put an `x` in each box when you have completed the items. -->
- [ ] App update process has been followed <!-- See comment below -->
- [ ] Target branch is `develop` <!-- unless you have a very good reason -->
- [ ] Application version has been bumped <!-- required if your changes are to be deployed -->

<!-- Make sure you followed the process described in https://developers.ledger.com/docs/embedded-app/maintenance/ before opening your Pull Request.
Don't hesitate to contact us directly on Discord if you have any questions ! https://developers.ledger.com/discord -->
1 change: 1 addition & 0 deletions .github/workflows/guidelines_enforcer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ name: Ensure compliance with Ledger guidelines
#
# More information on the guidelines can be found in the repository:
# LedgerHQ/ledger-app-workflows/

on:
workflow_dispatch:
push:
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Lint and format 💅

on:
workflow_dispatch:
# push:
# pull_request:
# branches:
# - main
# - develop

jobs:
lint:
runs-on: ubuntu-latest
container: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-legacy:latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Add missing deps
run: |
DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y bear sudo
- name: Generate compilation database
run: bear -- make -j BOLOS_SDK="$NANOSP_SDK"
- name: Lint and format 💅
uses: cpp-linter/cpp-linter-action@v2
id: linter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file-annotations: true
files-changed-only: false
ignore: "app/build|cmake|deps|fuzz|tests"
step-summary: true
style: file # uses .clang-format
thread-comments: true
tidy-checks: "" # use only .clang-tidy checks
- name: Fail if errors
if: steps.linter.outputs.checks-failed > 0
run: |
echo "Linter or formatter failed!"
exit 1
8 changes: 6 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ jobs:
submodules: true

- name: Install node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Install yarn
run: npm install -g yarn
Expand Down Expand Up @@ -163,7 +165,9 @@ jobs:
submodules: recursive
- run: sudo apt-get update -y && sudo apt-get install -y libusb-1.0.0 libudev-dev
- name: Install node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install yarn
run: |
npm install -g yarn
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ jobs:
with:
submodules: true
- name: Install node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: "https://registry.npmjs.org"
scope: "@zondax"
- name: Install yarn
Expand Down
1 change: 1 addition & 0 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.side_loading

include $(BOLOS_SDK)/Makefile.rules


dep/%.d: %.c Makefile

listvariants:
Expand Down
2 changes: 1 addition & 1 deletion app/Makefile.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ include Makefile.version
# Enable debug output in speculos and other development features
APP_TESTING ?= 0

PRODUCTION_BUILD ?= 0
PRODUCTION_BUILD ?= 1
2 changes: 1 addition & 1 deletion app/Makefile.version
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ APPVERSION_M=0
# Minor
APPVERSION_N=8
# Patch
APPVERSION_P=4
APPVERSION_P=5
46 changes: 23 additions & 23 deletions js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,33 @@
"url": "https://github.com/ava-labs/ledger-avalanche/issues"
},
"dependencies": {
"@ledgerhq/hw-app-eth": "6.34.3",
"@ledgerhq/hw-transport": "6.28.8",
"bs58": "5.0.0",
"@ledgerhq/hw-app-eth": "6.38.1",
"@ledgerhq/hw-transport": "6.31.3",
"bs58": "6.0.0",
"sha3": "2.1.4"
},
"devDependencies": {
"@types/bs58": "^4.0.1",
"@types/ledgerhq__hw-transport": "^4.21.4",
"@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^5.38.1",
"@types/bs58": "^4.0.4",
"@types/ledgerhq__hw-transport": "^4.21.8",
"@typescript-eslint/eslint-plugin": "^8.6.0",
"@typescript-eslint/parser": "^8.6.0",
"bip32": "^4.0.0",
"bip39": "^3.0.4",
"core-js": "^3.11.1",
"crypto-js": "4.1.1",
"esbuild": "0.18.11",
"eslint": "^8.24.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jest": "^27.0.4",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.1.2",
"prettier": "^2.8.3",
"rollup": "^3.7.0",
"rollup-plugin-dts": "^5.0.0",
"rollup-plugin-esbuild": "^5.0.0",
"semantic-release": "^21.0.2",
"typescript": "^5.0.4"
"bip39": "^3.1.0",
"core-js": "^3.38.1",
"crypto-js": "4.2.0",
"esbuild": "0.23.1",
"eslint": "^9.10.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-jest": "^28.8.3",
"eslint-plugin-prettier": "^5.2.1",
"jest": "^29.7.0",
"prettier": "^3.3.3",
"rollup": "^4.21.3",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-esbuild": "^6.1.1",
"semantic-release": "^24.1.1",
"typescript": "^5.6.2"
},
"moduleDirectories": [
"node_modules",
Expand Down
8 changes: 4 additions & 4 deletions js/src/helper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { decode as bs58_decode } from 'bs58'
import bs58 from 'bs58';

const HARDENED = 0x80000000

Expand Down Expand Up @@ -101,23 +101,23 @@ export function serializePathSuffix(path: string): Buffer {
export function serializeHrp(hrp?: string): Buffer {
if (hrp) {
const bufHrp = Buffer.from(hrp, 'ascii')
return Buffer.concat([Buffer.alloc(1, bufHrp.length), bufHrp])
return Buffer.concat([new Uint8Array(Buffer.alloc(1, bufHrp.length)), new Uint8Array(bufHrp)])
} else {
return Buffer.alloc(1, 0)
}
}

export function serializeChainID(chainid?: string): Buffer {
if (chainid) {
let decoded = bs58_decode(chainid)
let decoded = bs58.decode(chainid)
if (decoded.length == 36) {
//chop checksum off
decoded = decoded.slice(0, 32)
} else if (decoded.length != 32) {
throw Error('ChainID was not 32 bytes long (encoded with base58)')
}

return Buffer.concat([Buffer.alloc(1, decoded.length), Buffer.from(decoded)])
return Buffer.concat([new Uint8Array(Buffer.alloc(1, decoded.length)), new Uint8Array(Buffer.from(decoded))])
} else {
return Buffer.alloc(1, 0)
}
Expand Down
32 changes: 15 additions & 17 deletions js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ export default class AvalancheApp {
chunks.push(serializedPathBuffer)
}

const messageBuffer = Buffer.from(message)

const buffer = Buffer.concat([messageBuffer])
const buffer = Buffer.from(message)
for (let i = 0; i < buffer.length; i += CHUNK_SIZE) {
let end = i + CHUNK_SIZE
if (i > buffer.length) {
Expand All @@ -151,19 +149,19 @@ export default class AvalancheApp {

private concatMessageAndChangePath(message: Buffer, path?: Array<string>): Buffer {
// data
const msg = Buffer.concat([message])
const msg = message
// no change_path
if (path === undefined) {
const buffer = Buffer.alloc(1)
buffer.writeUInt8(0)
return Buffer.concat([buffer, msg])
return Buffer.concat([new Uint8Array(buffer), new Uint8Array(msg)])
} else {
let buffer = Buffer.alloc(1)
buffer.writeUInt8(path.length)
path.forEach(element => {
buffer = Buffer.concat([buffer, serializePathSuffix(element)])
buffer = Buffer.concat([new Uint8Array(buffer), new Uint8Array(serializePathSuffix(element))])
})
return Buffer.concat([buffer, msg])
return Buffer.concat([new Uint8Array(buffer), new Uint8Array(msg)])
}
}

Expand Down Expand Up @@ -230,7 +228,7 @@ export default class AvalancheApp {

//send hash and path
const first_response = await this.transport
.send(CLA, INS.SIGN_HASH, FIRST_MESSAGE, 0x00, Buffer.concat([serializePath(path_prefix), hash]), [LedgerError.NoErrors])
.send(CLA, INS.SIGN_HASH, FIRST_MESSAGE, 0x00, Buffer.concat([new Uint8Array(serializePath(path_prefix)), new Uint8Array(hash)]), [LedgerError.NoErrors])
.then((response: Buffer) => {
const errorCodeData = response.slice(-2)
const returnCode = errorCodeData[0] * 256 + errorCodeData[1]
Expand Down Expand Up @@ -463,7 +461,7 @@ export default class AvalancheApp {
const serializedChainID = serializeChainID(chainid)

return this.transport
.send(CLA, INS.GET_ADDR, p1, 0, Buffer.concat([serializedHrp, serializedChainID, serializedPath]), [LedgerError.NoErrors])
.send(CLA, INS.GET_ADDR, p1, 0, Buffer.concat([new Uint8Array(serializedHrp), new Uint8Array(serializedChainID), new Uint8Array(serializedPath)]), [LedgerError.NoErrors])
.then(processGetAddrResponse, processErrorResponse)
}

Expand All @@ -478,7 +476,7 @@ export default class AvalancheApp {
const serializedChainID = serializeChainID(chainid)

return this.transport
.send(CLA, INS.GET_EXTENDED_PUBLIC_KEY, p1, 0, Buffer.concat([serializedHrp, serializedChainID, serializedPath]), [
.send(CLA, INS.GET_EXTENDED_PUBLIC_KEY, p1, 0, Buffer.concat([new Uint8Array(serializedHrp), new Uint8Array(serializedChainID), new Uint8Array(serializedPath)]), [
LedgerError.NoErrors,
])
.then(processGetXPubResponse, processErrorResponse)
Expand Down Expand Up @@ -582,7 +580,7 @@ export default class AvalancheApp {

// Slice to remove '0x'
const addressBuffer = Buffer.from(address.slice(addr_offset), 'hex')
addressBuffer.copy(buffer, offset)
addressBuffer.copy(new Uint8Array(buffer), offset)
offset += 20

// Decimals (4 bytes, big endian)
Expand Down Expand Up @@ -637,7 +635,7 @@ export default class AvalancheApp {
buffer.write(collectionName, offset, 'utf8')
offset += collectionNameLength

Buffer.from(contractAddress.slice(2), 'hex').copy(buffer, offset) // Remove '0x' from address
Buffer.from(contractAddress.slice(2), 'hex').copy(new Uint8Array(buffer), offset) // Remove '0x' from address
offset += ADDRESS_LENGTH

buffer.writeBigUInt64BE(chainId, offset)
Expand All @@ -652,7 +650,7 @@ export default class AvalancheApp {
buffer.writeUInt8(fakeDerSignature.length, offset)
offset += SIGNATURE_LENGTH_SIZE

fakeDerSignature.copy(buffer, offset)
fakeDerSignature.copy(new Uint8Array(buffer), offset)

return this.eth.provideNFTInformation(buffer.toString('hex'))
}
Expand Down Expand Up @@ -712,13 +710,13 @@ export default class AvalancheApp {
buffer.writeUInt8(pluginNameLength, offset)
offset += PLUGIN_NAME_LENGTH_SIZE

pluginNameBuffer.copy(buffer, offset)
pluginNameBuffer.copy(new Uint8Array(buffer), offset)
offset += pluginNameLength

contractAddressBuffer.copy(buffer, offset)
contractAddressBuffer.copy(new Uint8Array(buffer), offset)
offset += contractAddressBuffer.length

methodSelectorBuffer.copy(buffer, offset)
methodSelectorBuffer.copy(new Uint8Array(buffer), offset)
offset += methodSelectorBuffer.length

buffer.writeBigUInt64BE(BigInt(chainId), offset)
Expand All @@ -735,7 +733,7 @@ export default class AvalancheApp {
buffer.writeUInt8(signatureLength, offset)
offset += SIGNATURE_LENGTH_SIZE

signatureBuffer.copy(buffer, offset)
signatureBuffer.copy(new Uint8Array(buffer), offset)

return this.eth.setPlugin(buffer.toString('hex'))
}
Expand Down
Loading

0 comments on commit d5f6768

Please sign in to comment.