-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsolana.ts
More file actions
112 lines (100 loc) · 3.92 KB
/
Copy pathsolana.ts
File metadata and controls
112 lines (100 loc) · 3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import { BIP32Path, HDWallet, HDWalletInfo } from "./wallet";
export interface SolanaGetAddress {
addressNList: BIP32Path;
showDisplay?: boolean;
}
export interface SolanaAddress {
address: string;
}
export interface SolanaTokenInfo {
/** 32-byte SPL mint, encoded as bytes, hex, base64, or base58. */
mint: Uint8Array | string;
symbol?: string;
decimals?: number;
signature?: Uint8Array | string;
signerKeyId?: number;
}
export interface SolanaSignTx {
addressNList: BIP32Path;
rawTx: Uint8Array | string;
/** Optional token definitions used by firmware display policy. */
tokenInfo?: SolanaTokenInfo[];
/**
* Candidate owners for signed SPL token destinations (for example x402
* payTo). Firmware displays one only after deriving and matching its ATA.
*/
tokenRecipientOwners?: Array<Uint8Array | string>;
/** One-request opaque-signing authorization; does not mutate AdvancedMode. */
allowBlindSigning?: boolean;
/**
* Transaction-bound, signer-attested resolution of the Address Lookup
* Table accounts this exact message references (KKSOLSW1). `accounts` is
* the raw canonical account list: all writable lookup keys, then all
* readonly lookup keys, in lookup-table/index order — max 8. Firmware
* verifies `signature` (64-byte compact secp256k1) over
* SHA256("KeepKeySolanaTxAccounts/1" || message_hash(32) || count(LE32) ||
* account[0..count-1]).
*
* `signerKeyId` is a runtime clear-sign signer slot (0-3) for the
* annotation-only path (Advanced Mode still required), or the certified
* delegate sentinel 0x80 when `certificate` is also set on the request.
*/
lutProof?: {
accounts: Array<Uint8Array | string>;
signature: Uint8Array | string;
signerKeyId: number;
};
/**
* Signer-attested KKSOLSC1 instruction schema. Unlike lutProof this is
* NOT bound to one transaction: it describes how to read a program's
* instruction, so a single signature is reused for every transaction to
* that program and the device decodes values from the bytes it signs.
*/
schema?: {
payload: Uint8Array | string;
signature: Uint8Array | string;
signerKeyId: number;
};
/**
* 139-byte KeepKey root certificate authorizing the delegate that signed
* `schema` and, when present, `lutProof`. Required for the certified path —
* schema.signerKeyId and any present lutProof.signerKeyId MUST be 0x80.
* Self-contained legacy/v0 messages intentionally omit lutProof because all
* instruction accounts are already committed by rawTx.
*/
certificate?: Uint8Array | string;
}
export interface SolanaSignedTx {
signature: Uint8Array | string;
}
export interface SolanaGetAccountPaths {
accountIdx: number;
}
export interface SolanaAccountPath {
addressNList: BIP32Path;
}
export interface SolanaWalletInfo extends HDWalletInfo {
readonly _supportsSolanaInfo: boolean;
solanaGetAccountPaths(msg: SolanaGetAccountPaths): Array<SolanaAccountPath>;
solanaNextAccountPath(msg: SolanaAccountPath): SolanaAccountPath | undefined;
}
// ── Off-chain message signing (domain-separated envelope) ────────────
export interface SolanaSignOffchainMessage {
addressNList: BIP32Path;
/** Off-chain message spec version. Only 0 is currently defined. */
version?: number;
/** 0 = restricted ASCII, 1 = UTF-8 limited (max 1212 bytes). Format 2 is not supported on KeepKey. */
messageFormat?: number;
message: Uint8Array | string;
showDisplay?: boolean;
}
export interface SolanaOffchainMessageSignature {
publicKey: Uint8Array | string;
signature: Uint8Array | string;
}
export interface SolanaWallet extends SolanaWalletInfo, HDWallet {
readonly _supportsSolana: boolean;
solanaGetAddress(msg: SolanaGetAddress): Promise<string | null>;
solanaSignTx(msg: SolanaSignTx): Promise<SolanaSignedTx | null>;
solanaSignOffchainMessage(msg: SolanaSignOffchainMessage): Promise<SolanaOffchainMessageSignature | null>;
}