Skip to content

Commit

Permalink
use p1 to get or show address
Browse files Browse the repository at this point in the history
  • Loading branch information
abenso committed Feb 4, 2025
1 parent ce0809e commit 020f83d
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 4 deletions.
74 changes: 74 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

yarn.lock

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

\.idea/

.vscode

TODO\.md

\dist
/certs/cert.pem
/certs/server.cert
/certs/server.key
8 changes: 6 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class MinaApp extends BaseApp {
}
}

async getAddress(account?: number): Promise<GetAddressResponse> {
async getAddress(account?: number, showAddrInDevice = true): Promise<GetAddressResponse> {
if (!Number.isInteger(account)) {
return {
publicKey: null,
Expand All @@ -156,8 +156,12 @@ export class MinaApp extends BaseApp {

const accountBuf = Buffer.from(account.toString(16).padStart(8, '0'), 'hex');

const p1 = showAddrInDevice
? P1_VALUES.SHOW_ADDRESS_IN_DEVICE
: P1_VALUES.ONLY_RETRIEVE;

try {
const responseBuffer = await this.transport.send(this.CLA, this.INS.GET_ADDR, 0, 0, accountBuf)
const responseBuffer = await this.transport.send(this.CLA, this.INS.GET_ADDR, p1, 0, accountBuf)
const response = processResponse(responseBuffer)

return {
Expand Down
4 changes: 2 additions & 2 deletions src/consts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const enum P1_VALUES {
ONLY_RETRIEVE = 0x00,
SHOW_ADDRESS_IN_DEVICE = 0x01,
SHOW_ADDRESS_IN_DEVICE = 0x00,
ONLY_RETRIEVE = 0x01,
}

export const PUBKEYLEN = 55;

0 comments on commit 020f83d

Please sign in to comment.