├── .gitignore ├── .eslintignore ├── tsconfig.json ├── src ├── tsconfig.json ├── errors │ ├── deviceUnsupported.ts │ ├── errorBase.ts │ ├── index.ts │ ├── invalidData.ts │ └── deviceStatusError.ts ├── interactions │ ├── common │ │ ├── types.ts │ │ └── ins.ts │ ├── runTests.ts │ ├── serialization │ │ ├── operationalCertificate.ts │ │ ├── txAuxiliaryData.ts │ │ ├── messageData.ts │ │ ├── nativeScript.ts │ │ ├── addressParams.ts │ │ ├── txOutput.ts │ │ ├── cVoteRegistration.ts │ │ ├── txOther.ts │ │ ├── txInit.ts │ │ ├── txCertificate.ts │ │ └── poolRegistrationCertificate.ts │ ├── getSerial.ts │ ├── showAddress.ts │ ├── signOperationalCertificate.ts │ ├── deriveAddress.ts │ ├── signCVote.ts │ ├── getExtendedPublicKeys.ts │ ├── signMessage.ts │ ├── deriveNativeScriptHash.ts │ └── getVersion.ts ├── parsing │ ├── constants.ts │ ├── network.ts │ ├── cVote.ts │ ├── operationalCertificate.ts │ ├── messageData.ts │ ├── txAuxiliaryData.ts │ ├── nativeScript.ts │ ├── certificate.ts │ └── output.ts ├── utils │ ├── assert.ts │ ├── address.ts │ └── serialize.ts └── utils.ts ├── _typedoc └── custom-theme │ ├── templates │ ├── index.hbs │ └── reflection.hbs │ ├── assets │ └── images │ │ ├── icons.png │ │ ├── widgets.png │ │ ├── icons@2x.png │ │ └── widgets@2x.png │ ├── partials │ ├── toc.hbs │ ├── breadcrumb.hbs │ ├── member.signatures.hbs │ ├── member.reference.hbs │ ├── toc.root.hbs │ ├── hierarchy.hbs │ ├── analytics.hbs │ ├── typeParameters.hbs │ ├── members.hbs │ ├── members.group.hbs │ ├── comment.hbs │ ├── member.hbs │ ├── footer.hbs │ ├── member.sources.hbs │ ├── navigation.hbs │ ├── member.declaration.hbs │ ├── member.getterSetter.hbs │ ├── member.signature.title.hbs │ ├── typeAndParent.hbs │ ├── member.signature.body.hbs │ ├── index.hbs │ ├── header.hbs │ └── parameter.hbs │ └── layouts │ └── default.hbs ├── .prettierignore ├── .prettierrc.js ├── test ├── tsconfig.json ├── device-self-test │ └── runTestsDevice.test.ts ├── integration │ ├── signTxCVote.test.ts │ ├── getSerial.test.ts │ ├── signCVote.test.ts │ ├── signMessage.test.ts │ ├── __fixtures__ │ │ ├── signOperationalCertificate.ts │ │ ├── signCVote.ts │ │ └── getExtendedPublicKey.ts │ ├── signOperationalCertificate.test.ts │ ├── getVersion.test.ts │ ├── signTxPoolRegistration.test.ts │ ├── deriveNativeScriptHash.test.ts │ ├── signTx.test.ts │ ├── deriveAddress.test.ts │ └── getExtendedPublicKey.test.ts ├── unit │ └── parse.test.ts └── test_utils.ts ├── .flowconfig ├── example-node └── tsconfig.json ├── workspace.code-workspace ├── typedoc.json ├── tsconfig.base.json ├── .cspell.json ├── .eslintrc.js ├── README.md ├── .circleci └── config.yml └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | .vscode 4 | docs_generated/ 5 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | docs_generated/ 3 | _typedoc/ 4 | node_modules/ 5 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.base", 3 | "include": ["./**/*.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base", 3 | "include": ["./**/*.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /_typedoc/custom-theme/templates/index.hbs: -------------------------------------------------------------------------------- 1 |
2 | {{#markdown}}{{{model.readme}}}{{/markdown}} 3 |
-------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | .eslintrc.js 2 | README.md 3 | CHANGELOG.md 4 | docs 5 | docs_generated/ 6 | .vscode 7 | .circleci 8 | dist/ 9 | _typedoc/ 10 | -------------------------------------------------------------------------------- /_typedoc/custom-theme/assets/images/icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cardano-foundation/ledgerjs-hw-app-cardano/HEAD/_typedoc/custom-theme/assets/images/icons.png -------------------------------------------------------------------------------- /_typedoc/custom-theme/assets/images/widgets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cardano-foundation/ledgerjs-hw-app-cardano/HEAD/_typedoc/custom-theme/assets/images/widgets.png -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: false, 3 | quoteProps: 'consistent', 4 | semi: false, 5 | singleQuote: true, 6 | trailingComma: 'all', 7 | } 8 | -------------------------------------------------------------------------------- /_typedoc/custom-theme/assets/images/icons@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cardano-foundation/ledgerjs-hw-app-cardano/HEAD/_typedoc/custom-theme/assets/images/icons@2x.png -------------------------------------------------------------------------------- /_typedoc/custom-theme/assets/images/widgets@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cardano-foundation/ledgerjs-hw-app-cardano/HEAD/_typedoc/custom-theme/assets/images/widgets@2x.png -------------------------------------------------------------------------------- /test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base", 3 | "compilerOptions": { 4 | "lib": ["es2019"], 5 | "outDir": "lib" 6 | }, 7 | "include": ["./**/*.ts", "../src/**/*.ts"] 8 | } 9 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | .*/node_modules/resolve/test/resolver/malformed_package_json/package.json 3 | 4 | [include] 5 | 6 | [untyped] 7 | 8 | [libs] 9 | 10 | [lints] 11 | 12 | [options] 13 | -------------------------------------------------------------------------------- /example-node/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base", 3 | "compilerOptions": { 4 | "lib": ["es2019"], 5 | "outDir": "lib" 6 | }, 7 | "include": ["./**/*.ts", "../src/**/*.ts"] 8 | } 9 | -------------------------------------------------------------------------------- /workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": { 8 | "editor.formatOnSave": true, 9 | "typescript.tsdk": "node_modules/typescript/lib" 10 | } 11 | } -------------------------------------------------------------------------------- /src/errors/deviceUnsupported.ts: -------------------------------------------------------------------------------- 1 | import {ErrorBase} from './errorBase' 2 | 3 | /** 4 | * Thrown when user tried to call a method with incompatible Ledger App version 5 | * @category Errors 6 | */ 7 | export class DeviceVersionUnsupported extends ErrorBase {} 8 | -------------------------------------------------------------------------------- /src/interactions/common/types.ts: -------------------------------------------------------------------------------- 1 | export type SendParams = { 2 | ins: number 3 | p1: number 4 | p2: number 5 | data: Buffer 6 | expectedResponseLength?: number 7 | } 8 | 9 | export type Interaction = Generator 10 | -------------------------------------------------------------------------------- /src/errors/errorBase.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Base error for errors thrown by the code 3 | * @category Errors 4 | */ 5 | export class ErrorBase extends Error { 6 | public constructor(message: string) { 7 | super(message) 8 | this.name = this.constructor.name 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/parsing/constants.ts: -------------------------------------------------------------------------------- 1 | export const MAX_LOVELACE_SUPPLY_STR = '45 000 000 000.000000'.replace( 2 | /[ .]/, 3 | '', 4 | ) 5 | export const POOL_REGISTRATION_OWNERS_MAX = 1000 6 | export const POOL_REGISTRATION_RELAYS_MAX = 1000 7 | export const ASSET_GROUPS_MAX = 1000 8 | export const TOKENS_IN_GROUP_MAX = 1000 9 | -------------------------------------------------------------------------------- /src/errors/index.ts: -------------------------------------------------------------------------------- 1 | export {ErrorBase} from './errorBase' 2 | export {InvalidData} from './invalidData' 3 | export {DeviceVersionUnsupported} from './deviceUnsupported' 4 | export { 5 | DeviceStatusCodes, 6 | DeviceStatusError, 7 | DeviceStatusMessages, 8 | } from './deviceStatusError' 9 | export {InvalidDataReason} from './invalidDataReason' 10 | -------------------------------------------------------------------------------- /_typedoc/custom-theme/partials/toc.hbs: -------------------------------------------------------------------------------- 1 |
  • 2 | {{{wbr title}}} 3 | {{#if children}} 4 |
      5 | {{#each children}} 6 | {{> toc}} 7 | {{/each}} 8 |
    9 | {{/if}} 10 |
  • 11 | -------------------------------------------------------------------------------- /src/utils/assert.ts: -------------------------------------------------------------------------------- 1 | import {ErrorBase} from '../errors/errorBase' 2 | 3 | export function assert(cond: boolean, errMsg: string): asserts cond { 4 | const msg = errMsg ? `: ${errMsg}` : '' 5 | if (!cond) throw new ErrorBase(`Assertion failed${msg}`) 6 | } 7 | 8 | export function unreachable(_val: never): never { 9 | assert(false, 'Unreachable code hit') 10 | } 11 | -------------------------------------------------------------------------------- /src/interactions/common/ins.ts: -------------------------------------------------------------------------------- 1 | export const enum INS { 2 | GET_VERSION = 0x00, 3 | GET_SERIAL = 0x01, 4 | 5 | GET_EXT_PUBLIC_KEY = 0x10, 6 | DERIVE_ADDRESS = 0x11, 7 | DERIVE_NATIVE_SCRIPT_HASH = 0x12, 8 | 9 | SIGN_TX = 0x21, 10 | SIGN_OPERATIONAL_CERTIFICATE = 0x22, 11 | SIGN_CIP36_VOTE = 0x23, 12 | SIGN_MESSAGE = 0x24, 13 | 14 | RUN_TESTS = 0xf0, 15 | } 16 | -------------------------------------------------------------------------------- /src/errors/invalidData.ts: -------------------------------------------------------------------------------- 1 | import {ErrorBase} from './errorBase' 2 | import type {InvalidDataReason} from './invalidDataReason' 3 | 4 | /** 5 | * Request data is invalid, caller should check what is feeding to us 6 | * @category Errors 7 | */ 8 | export class InvalidData extends ErrorBase { 9 | public constructor(reason: InvalidDataReason) { 10 | super(reason as string) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /typedoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "entryPoints": ["src/Ada.ts"], 3 | "out": "docs_generated", 4 | "categorizeByGroup": false, 5 | "categoryOrder": [ 6 | "Main", 7 | "API request/response", 8 | "Basic types", 9 | "Addresses", 10 | "Shelley", 11 | "Mary", 12 | "Pool registration", 13 | "*" 14 | ], 15 | "sort": "source-order", 16 | "readme": "none", 17 | "includeVersion": "true" 18 | } 19 | -------------------------------------------------------------------------------- /_typedoc/custom-theme/partials/breadcrumb.hbs: -------------------------------------------------------------------------------- 1 | {{#if parent}} 2 | {{#with parent}}{{> breadcrumb}}{{/with}} 3 |
  • 4 | {{#if url}} 5 | {{name}} 6 | {{else}} 7 | {{name}} 8 | {{/if}} 9 |
  • 10 | {{else}} 11 | {{#if url}} 12 |
  • 13 | {{ name }} 14 |
  • 15 | {{/if}} 16 | {{/if}} 17 | -------------------------------------------------------------------------------- /_typedoc/custom-theme/partials/member.signatures.hbs: -------------------------------------------------------------------------------- 1 | 6 | 7 | 14 | -------------------------------------------------------------------------------- /_typedoc/custom-theme/partials/member.reference.hbs: -------------------------------------------------------------------------------- 1 | {{#with tryGetTargetReflectionDeep}} 2 | {{#ifCond ../name '===' name}} 3 | Re-exports {{name}} 4 | {{else if flags.isExported}} 5 | Renames and re-exports {{name}} 6 | {{else}} 7 | Renames and exports {{name}} 8 | {{/ifCond}} 9 | {{else}} 10 | Re-exports {{name}} 11 | {{/with}} 12 | -------------------------------------------------------------------------------- /_typedoc/custom-theme/partials/toc.root.hbs: -------------------------------------------------------------------------------- 1 | {{#if isInPath}} 2 | 3 | 17 |