Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bitbox02: add types for the bitbox02-api dependency
They will eventually be upstreamed. Excluded from eslint because eslint expects Javascript, not pure Typescript (e.g. it can't parse the constructor type without a body).
- Loading branch information
Showing
3 changed files
with
129 additions
and
14 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules/ | ||
app/bitbox02-api.d.ts | ||
app/dist/ | ||
app/tests/dist/ | ||
app/node_modules/ | ||
|
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,105 @@ | ||
declare module 'bitbox02-api' { | ||
export function getDevicePath(options?: {forceBridge: boolean}): string | ||
|
||
type CardanoNetwork = 0 | 1 | ||
|
||
export const constants = { | ||
Status: { | ||
PairingFailed: string, | ||
}, | ||
Product: { | ||
BitBox02Multi: string, | ||
BitBox02BTCOnly: string, | ||
}, | ||
messages: { | ||
CardanoNetwork: { | ||
CardanoMainnet: CardanoNetwork, | ||
CardanoTestnet: CardanoNetwork, | ||
}, | ||
}, | ||
} | ||
|
||
declare class Firmware { | ||
Product(): string | ||
} | ||
|
||
type Keypath = number[] | ||
type ScriptConfig = { | ||
pkhSkh: { | ||
keypathPayment: Keypath | ||
keypathStake: Keypath | ||
} | ||
} | ||
|
||
type CardanoInput = { | ||
keypath: Keypath | ||
prevOutHash: Uint8Array | ||
prevOutIndex: number | ||
} | ||
|
||
type CardanoOutput = { | ||
encodedAddress: string | ||
value: string | ||
scriptConfig?: ScriptConfig | ||
} | ||
|
||
type CardanoCertificate = | ||
| { | ||
stakeRegistration: { | ||
keypath: Keypath | ||
} | ||
} | ||
| { | ||
stakeDeregistration: { | ||
keypath: Keypath | ||
} | ||
} | ||
| { | ||
stakeDelegation: { | ||
keypath: Keypath | ||
poolKeyhash: Uint8Array | ||
} | ||
} | ||
|
||
type CardanoWithdrawal = { | ||
keypath: Keypath | ||
value: string | ||
} | ||
|
||
type CardanoShelleyWitness = { | ||
signature: Uint8Array | ||
publicKey: Uint8Array | ||
} | ||
|
||
export declare class BitBox02API { | ||
constructor(devicePath: string) | ||
connect( | ||
showPairingCb: (string) => void, | ||
userVerify: () => Promise<void>, | ||
handleAttestationCb: (bool) => void, | ||
onCloseCb: () => void, | ||
setStatusCb: (string) => void | ||
) | ||
close(): boolean | ||
firmware(): Firmware | ||
version(): string | ||
cardanoXPubs(keypaths: Keypath[]): Promise<Uint8Array[]> | ||
cardanoAddress( | ||
network: CardanoNetwork, | ||
scriptConfig: ScriptConfig, | ||
display?: boolean | ||
): Promise<string> | ||
cardanoSignTransaction(params: { | ||
network: CardanoNetwork | ||
inputs: CardanoInput[] | ||
outputs: CardanoOutput[] | ||
fee: string | ||
ttl: string | ||
certificates: CardanoCertificate[] | ||
withdrawals: CardanoWithdrawal[] | ||
validityIntervalStart: string | ||
}): Promise<{ | ||
shelleyWitnesses: CardanoShelleyWitness[] | ||
}> | ||
} | ||
} |
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