Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

Commit

Permalink
Bootstrap all types
Browse files Browse the repository at this point in the history
  • Loading branch information
gre committed Jan 3, 2022
1 parent d40c77c commit 3f317f6
Show file tree
Hide file tree
Showing 23 changed files with 1,403 additions and 1 deletion.
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
* @ledgerhq/live-blockchain-support
packages/types-devices @ledgerhq/live-devices
packages/devices @ledgerhq/live-devices
packages/hw-transport-* @ledgerhq/live-devices
packages/react-native-* @ledgerhq/live-devices
74 changes: 74 additions & 0 deletions packages/types-cryptoassets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<img src="https://user-images.githubusercontent.com/211411/34776833-6f1ef4da-f618-11e7-8b13-f0697901d6a8.png" height="100" />

## @ledgerhq/types-cryptoassets

Ledger types for crypto assets and tokens.

## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

#### Table of Contents

* [Unit](#unit)
* [Properties](#properties)
* [CurrencyCommon](#currencycommon)
* [Properties](#properties-1)
* [TokenCurrency](#tokencurrency)
* [FiatCurrency](#fiatcurrency)
* [ExplorerView](#explorerview)
* [Properties](#properties-2)
* [CryptoCurrency](#cryptocurrency)
* [Currency](#currency)

### Unit

Type: {name: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), code: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), magnitude: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), showAllDigits: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, prefixCode: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?}

#### Properties

* `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
* `code` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
* `magnitude` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
* `showAllDigits` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?**
* `prefixCode` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?**

### CurrencyCommon

Type: {name: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), ticker: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), units: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Unit](#unit)>, symbol: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, disableCountervalue: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, delisted: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, countervalueTicker: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?}

#### Properties

* `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
* `ticker` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
* `units` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Unit](#unit)>**
* `symbol` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**
* `disableCountervalue` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?**
* `delisted` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?**
* `countervalueTicker` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**

### TokenCurrency

Type: any

### FiatCurrency

Type: any

### ExplorerView

Type: {tx: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, address: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, token: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?}

#### Properties

* `tx` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**
* `address` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**
* `token` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**

### CryptoCurrency

Type: any

### Currency

Type: ([FiatCurrency](#fiatcurrency) | [CryptoCurrency](#cryptocurrency) | [TokenCurrency](#tokencurrency))
29 changes: 29 additions & 0 deletions packages/types-cryptoassets/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "@ledgerhq/types-cryptoassets",
"version": "6.21.3",
"description": "Ledger types for crypto assets and tokens",
"keywords": [
"Ledger"
],
"repository": {
"type": "git",
"url": "https://github.com/LedgerHQ/ledgerjs"
},
"bugs": {
"url": "https://github.com/LedgerHQ/ledgerjs/issues"
},
"homepage": "https://github.com/LedgerHQ/ledgerjs",
"publishConfig": {
"access": "public"
},
"main": "lib/index.js",
"module": "lib-es/index.js",
"types": "lib/index.d.ts",
"license": "Apache-2.0",
"scripts": {
"clean": "bash ../../script/clean.sh",
"build": "bash ../../script/build.sh",
"watch": "bash ../../script/watch.sh",
"doc": "bash ../../script/doc.sh"
}
}
117 changes: 117 additions & 0 deletions packages/types-cryptoassets/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/**
*
*/
export type Unit = {
// display name of a given unit (example: satoshi)
name: string;
// string to use when formatting the unit. like 'BTC' or 'USD'
code: string;
// number of digits after the '.'
magnitude: number;
// should it always print all digits even if they are 0 (usually: true for fiats, false for cryptos)
showAllDigits?: boolean;
// true if the code should prefix amount when formatting
prefixCode?: boolean;
};

/**
*
*/
type CurrencyCommon = {
// display name of a currency
name: string;
// the ticker name in exchanges / countervalue apis (e.g. BTC).
ticker: string;
// all units of a currency (e.g. Bitcoin have bitcoin, mBTC, bit, satoshi)
// by convention, [0] is the default and have "highest" magnitude
units: Unit[];
// a shorter version of code using the symbol of the currency. like Ƀ . not all cryptocurrencies have a symbol
symbol?: string;
// tells if countervalue need to be disabled (typically because colliding with other coins)
disableCountervalue?: boolean;
delisted?: boolean;
// some countervalue will have a ticker alias
countervalueTicker?: string;
};

/**
*
*/
export type TokenCurrency = CurrencyCommon & {
type: "TokenCurrency";
id: string;
ledgerSignature?: string;
contractAddress: string;
// the currency it belongs to. e.g. 'ethereum'
parentCurrency: CryptoCurrency;
// the type of token in the blockchain it belongs. e.g. 'erc20'
tokenType: string;
// indicates this is a compound token and it's "parent" erc20 have this id
compoundFor?: string;
};

/**
*
*/
export type FiatCurrency = CurrencyCommon & {
type: "FiatCurrency";
};

/**
*
*/
export type ExplorerView = {
tx?: string;
address?: string;
token?: string;
};

/**
*
*/
export type CryptoCurrency = CurrencyCommon & {
type: "CryptoCurrency";
// unique internal id of a crypto currency
id: string;
// define if a crypto is a fork from another coin. helps dealing with split/unsplit
forkedFrom?: string;
// name of the app as shown in the Manager
managerAppName: string;
// coin type according to slip44. THIS IS NOT GUARANTEED UNIQUE across currencies (e.g testnets,..)
coinType: number;
// the scheme name to use when formatting an URI (without the ':')
scheme: string;
// used for UI
color: string;
family: string;
blockAvgTime?: number;
// in seconds
supportsSegwit?: boolean;
supportsNativeSegwit?: boolean;
// if defined this coin is a testnet for another crypto (id)};
isTestnetFor?: string;
// TODO later we could express union of types with mandatory bitcoinLikeInfo for "bitcoin" family...
bitcoinLikeInfo?: {
P2PKH: number;
P2SH: number;
XPUBVersion?: number;
// FIXME optional as we miss some data to fill
hasTimestamp?: boolean;
};
ethereumLikeInfo?: {
chainId: number;
networkId?: number;
baseChain?: string;
hardfork?: string;
};
explorerViews: ExplorerView[];
terminated?: {
link: string;
};
deviceTicker?: string;
};

/**
*
*/
export type Currency = FiatCurrency | CryptoCurrency | TokenCurrency;
7 changes: 7 additions & 0 deletions packages/types-cryptoassets/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "lib"
},
"include": ["src/**/*"]
}
99 changes: 99 additions & 0 deletions packages/types-devices/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<img src="https://user-images.githubusercontent.com/211411/34776833-6f1ef4da-f618-11e7-8b13-f0697901d6a8.png" height="100" />

## @ledgerhq/types-devices

Ledger types for devices and transport.

## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

#### Table of Contents

* [DeviceModelId](#devicemodelid)
* [DeviceModel](#devicemodel)
* [BluetoothInfos](#bluetoothinfos)
* [Subscription](#subscription)
* [Properties](#properties)
* [Device](#device)
* [Observer](#observer)
* [send](#send)
* [Parameters](#parameters)
* [on](#on)
* [off](#off)
* [setExchangeTimeout](#setexchangetimeout)
* [setExchangeUnresponsiveTimeout](#setexchangeunresponsivetimeout)

### DeviceModelId

DeviceModelId is a unique identifier to identify the model of a Ledger hardware wallet.

### DeviceModel

a DeviceModel contains all the information of a specific Ledger hardware wallet model.

### BluetoothInfos

### Subscription

represent an ongoing job that can be stopped with .unsubscribe()

Type: {unsubscribe: function (): void}

#### Properties

* `unsubscribe` **function (): void**

### Device

data about the device. not yet typed

Type: any

### Observer

Type: Readonly<{next: function (event: Ev): any, error: function (e: any): any, complete: function (): any}>

### send

wrapper on top of exchange to simplify work of the implementation.

Type: function (cla: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), ins: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), p1: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), p2: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), data: [Buffer](https://nodejs.org/api/buffer.html), statusList: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>): [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Buffer](https://nodejs.org/api/buffer.html)>

#### Parameters

* `cla`
* `ins`
* `p1`
* `p2`
* `data`
* `statusList` is a list of accepted status code (shorts). \[0x9000] by default

Returns **any** a Promise of response buffer

### on

Listen to an event on an instance of transport.
Transport implementation can have specific events. Here is the common events:

* `"disconnect"` : triggered if Transport is disconnected

Type: function (eventName: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), cb: function (...args: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<any>): any): void

### off

Stop listening to an event on an instance of transport.

Type: function (eventName: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), cb: function (...args: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<any>): any): void

### setExchangeTimeout

Set a timeout (in milliseconds) for the exchange call. Only some transport might implement it. (e.g. U2F)

Type: function (exchangeTimeout: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)): void

### setExchangeUnresponsiveTimeout

Define the delay before emitting "unresponsive" on an exchange that does not respond

Type: function (unresponsiveTimeout: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)): void
29 changes: 29 additions & 0 deletions packages/types-devices/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "@ledgerhq/types-devices",
"version": "6.21.3",
"description": "Ledger types for devices and transport.",
"keywords": [
"Ledger"
],
"repository": {
"type": "git",
"url": "https://github.com/LedgerHQ/ledgerjs"
},
"bugs": {
"url": "https://github.com/LedgerHQ/ledgerjs/issues"
},
"homepage": "https://github.com/LedgerHQ/ledgerjs",
"publishConfig": {
"access": "public"
},
"main": "lib/index.js",
"module": "lib-es/index.js",
"types": "lib/index.d.ts",
"license": "Apache-2.0",
"scripts": {
"clean": "bash ../../script/clean.sh",
"build": "bash ../../script/build.sh",
"watch": "bash ../../script/watch.sh",
"doc": "bash ../../script/doc.sh"
}
}
Loading

0 comments on commit 3f317f6

Please sign in to comment.