-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from t4top/type-support
Add support for generating type declarations during build
- Loading branch information
Showing
5 changed files
with
111 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { MinaLedgerJS } from "./lib"; | ||
export * from "./types"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { SignTransactionArgs, Transport, SignTransactionResponse, GetAddressResponse, GetAppVersionResponse, GetAppNameResponse } from "./types"; | ||
/** | ||
* Mina App API | ||
*/ | ||
export declare class MinaLedgerJS { | ||
transport: Transport; | ||
constructor(transport: Transport, scrambleKey?: string); | ||
protected pad(n: number | string, width?: number, paddingValue?: number | string): string; | ||
protected asciiToHex(str: string): string; | ||
protected convertMemo(memo: string): string; | ||
protected createTXApdu({ txType, senderAccount, senderAddress, receiverAddress, amount, fee, nonce, validUntil, memo, networkId, }: SignTransactionArgs): string; | ||
/** | ||
* Get Mina address for a given account number. | ||
* | ||
* @param account int of the account number | ||
* @param display optionally enable or not the display | ||
* @return an object with a publicKey | ||
* @example | ||
* const result = await Mina.getAddress(1); | ||
* const { publicKey, returnCode } = result; | ||
*/ | ||
getAddress(account?: number): Promise<GetAddressResponse>; | ||
signTransaction({ txType, senderAccount, senderAddress, receiverAddress, amount, fee, nonce, validUntil, memo, networkId, }: SignTransactionArgs): Promise<SignTransactionResponse>; | ||
/** | ||
* get the version of the Mina app installed on the hardware device | ||
* the version is returned from the installed app. | ||
* | ||
* @return an object with a version | ||
*/ | ||
getAppVersion(): Promise<GetAppVersionResponse>; | ||
/** | ||
* get the name and version of the Mina app installed on the hardware device | ||
* it can be used to ping the app and know the name of the running app. | ||
* The name and version is returned from the Ledger firmware. | ||
* | ||
* @return an object with an app name and version | ||
*/ | ||
getAppName(): Promise<GetAppNameResponse>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Buffer } from "buffer/"; | ||
/** | ||
* Transport mechanism. | ||
* @see https://github.com/LedgerHQ/ledgerjs for all transport Available | ||
*/ | ||
export interface Transport { | ||
/** | ||
* Used in U2F to avoid different web apps to communicate with different ledger implementations | ||
* @param {string} key | ||
*/ | ||
setScrambleKey(key: string): void; | ||
/** | ||
* sends data to Ledger | ||
* @param {number} cla | ||
* @param {number} ins | ||
* @param {number} p1 | ||
* @param {number} p2 | ||
* @param {Buffer} data | ||
* @param {number[]} statusList Allowed status list. | ||
* @returns {Promise<Buffer>} | ||
*/ | ||
send(cla: number, ins: number, p1: number, p2: number, data?: Buffer, statusList?: number[]): Promise<Buffer>; | ||
} | ||
export interface SignTransactionArgs { | ||
txType: number; | ||
senderAccount: number; | ||
senderAddress: string; | ||
receiverAddress: string; | ||
amount: number; | ||
fee: number; | ||
nonce: number; | ||
validUntil?: number; | ||
memo?: string; | ||
networkId: number; | ||
} | ||
export interface BaseLedgerResponse { | ||
returnCode: string; | ||
statusText?: string; | ||
message?: string; | ||
} | ||
export interface GetAddressResponse extends BaseLedgerResponse { | ||
publicKey?: string; | ||
} | ||
export interface SignTransactionResponse extends BaseLedgerResponse { | ||
signature?: string; | ||
} | ||
export interface GetAppVersionResponse extends BaseLedgerResponse { | ||
version?: string; | ||
} | ||
export interface GetAppNameResponse extends BaseLedgerResponse { | ||
name?: string; | ||
version?: string; | ||
} | ||
export declare enum Networks { | ||
MAINNET = 1, | ||
DEVNET = 0 | ||
} | ||
export declare enum TxType { | ||
PAYMENT = 0, | ||
DELEGATION = 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters