@talismn/keyring 0.0.0-pr2277-20251211070508 → 0.0.0-pr2295-20260110031023
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +202 -0
- package/dist/index.d.ts +202 -0
- package/dist/index.js +467 -0
- package/dist/index.js.map +1 -0
- package/dist/{talismn-keyring.esm.js → index.mjs} +180 -168
- package/dist/index.mjs.map +1 -0
- package/package.json +21 -7
- package/dist/declarations/src/index.d.ts +0 -2
- package/dist/declarations/src/keyring/Keyring.d.ts +0 -44
- package/dist/declarations/src/keyring/encryption.d.ts +0 -3
- package/dist/declarations/src/keyring/index.d.ts +0 -1
- package/dist/declarations/src/keyring/types.d.ts +0 -9
- package/dist/declarations/src/keyring/utils.d.ts +0 -4
- package/dist/declarations/src/types/account.d.ts +0 -48
- package/dist/declarations/src/types/index.d.ts +0 -4
- package/dist/declarations/src/types/keyring.d.ts +0 -38
- package/dist/declarations/src/types/mnemonic.d.ts +0 -6
- package/dist/declarations/src/types/utils.d.ts +0 -59
- package/dist/talismn-keyring.cjs.d.ts +0 -1
- package/dist/talismn-keyring.cjs.dev.js +0 -451
- package/dist/talismn-keyring.cjs.js +0 -7
- package/dist/talismn-keyring.cjs.prod.js +0 -451
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import * as _talismn_crypto from '@talismn/crypto';
|
|
2
|
+
import { KeypairCurve } from '@talismn/crypto';
|
|
3
|
+
|
|
4
|
+
type Mnemonic = {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
confirmed: boolean;
|
|
8
|
+
createdAt: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type LedgerPolkadotCurve = "ed25519" | "ethereum";
|
|
12
|
+
type AccountBase = {
|
|
13
|
+
address: string;
|
|
14
|
+
name: string;
|
|
15
|
+
createdAt: number;
|
|
16
|
+
};
|
|
17
|
+
type AccountKeypair = AccountBase & {
|
|
18
|
+
type: "keypair";
|
|
19
|
+
curve: KeypairCurve;
|
|
20
|
+
mnemonicId?: string;
|
|
21
|
+
derivationPath?: string;
|
|
22
|
+
};
|
|
23
|
+
type AccountContact = AccountBase & {
|
|
24
|
+
type: "contact";
|
|
25
|
+
genesisHash?: `0x${string}`;
|
|
26
|
+
};
|
|
27
|
+
type AccountWatchOnly = AccountBase & {
|
|
28
|
+
type: "watch-only";
|
|
29
|
+
isPortfolio: boolean;
|
|
30
|
+
};
|
|
31
|
+
type AccountLedgerPolkadot = AccountBase & {
|
|
32
|
+
type: "ledger-polkadot";
|
|
33
|
+
curve: LedgerPolkadotCurve;
|
|
34
|
+
app: string;
|
|
35
|
+
accountIndex: number;
|
|
36
|
+
addressOffset: number;
|
|
37
|
+
genesisHash?: `0x${string}`;
|
|
38
|
+
};
|
|
39
|
+
type AccountLedgerEthereum = AccountBase & {
|
|
40
|
+
type: "ledger-ethereum";
|
|
41
|
+
derivationPath: string;
|
|
42
|
+
};
|
|
43
|
+
type AccountLedgerSolana = AccountBase & {
|
|
44
|
+
type: "ledger-solana";
|
|
45
|
+
derivationPath: string;
|
|
46
|
+
};
|
|
47
|
+
type AccountPolkadotVault = AccountBase & {
|
|
48
|
+
type: "polkadot-vault";
|
|
49
|
+
genesisHash: `0x${string}` | null;
|
|
50
|
+
};
|
|
51
|
+
type AccountSignet = AccountBase & {
|
|
52
|
+
type: "signet";
|
|
53
|
+
genesisHash: `0x${string}`;
|
|
54
|
+
url: string;
|
|
55
|
+
};
|
|
56
|
+
type Account = AccountKeypair | AccountContact | AccountWatchOnly | AccountLedgerEthereum | AccountLedgerPolkadot | AccountLedgerSolana | AccountPolkadotVault | AccountSignet;
|
|
57
|
+
type AccountType = Account["type"];
|
|
58
|
+
|
|
59
|
+
type AccountOfType<Type extends AccountType> = Extract<Account, {
|
|
60
|
+
type: Type;
|
|
61
|
+
}>;
|
|
62
|
+
declare const isAccountOfType: <Type extends AccountType>(account: Account | null | undefined, type: Type) => account is AccountOfType<Type>;
|
|
63
|
+
declare const isAccountInTypes: <Types extends AccountType[]>(account: Account | null | undefined, types: Types) => account is AccountOfType<Types[number]>;
|
|
64
|
+
declare const ACCOUNT_TYPES_OWNED: readonly ["keypair", "ledger-ethereum", "ledger-polkadot", "ledger-solana", "polkadot-vault"];
|
|
65
|
+
declare const ACCOUNT_TYPES_EXTERNAL: readonly ["contact", "watch-only", "ledger-ethereum", "ledger-polkadot", "ledger-solana", "polkadot-vault", "signet"];
|
|
66
|
+
declare const ACCOUNT_TYPES_ADDRESS_ETHEREUM: readonly ["contact", "watch-only", "keypair", "ledger-ethereum", "ledger-polkadot"];
|
|
67
|
+
declare const ACCOUNT_TYPES_PLATFORM_ETHEREUM: readonly ["contact", "watch-only", "keypair", "ledger-ethereum"];
|
|
68
|
+
declare const ACCOUNT_TYPES_PLATFORM_POLKADOT: readonly ["contact", "watch-only", "keypair", "ledger-polkadot", "polkadot-vault", "signet"];
|
|
69
|
+
declare const ACCOUNT_TYPES_ADDRESS_SS58: readonly ["contact", "watch-only", "keypair", "ledger-polkadot", "polkadot-vault", "signet"];
|
|
70
|
+
declare const ACCOUNT_TYPES_PLATFORM_SOLANA: readonly ["contact", "watch-only", "keypair", "ledger-solana"];
|
|
71
|
+
declare const ACCOUNT_TYPES_BITCOIN: readonly ["contact", "watch-only"];
|
|
72
|
+
declare const isAccountExternal: (account: Account | null | undefined) => account is AccountOfType<(typeof ACCOUNT_TYPES_EXTERNAL)[number]>;
|
|
73
|
+
declare const isAccountOwned: (account: Account | null | undefined) => account is AccountOfType<(typeof ACCOUNT_TYPES_OWNED)[number]>;
|
|
74
|
+
declare const isAccountPortfolio: (account: Account | null | undefined) => account is Account;
|
|
75
|
+
declare const isAccountNotContact: (acc: Account) => acc is AccountKeypair | AccountWatchOnly | AccountLedgerPolkadot | AccountLedgerEthereum | AccountLedgerSolana | AccountPolkadotVault | AccountSignet;
|
|
76
|
+
type AccountAddressEthereum = Extract<Account, {
|
|
77
|
+
type: (typeof ACCOUNT_TYPES_ADDRESS_ETHEREUM)[number];
|
|
78
|
+
}> & {
|
|
79
|
+
address: `0x${string}`;
|
|
80
|
+
};
|
|
81
|
+
declare const isAccountAddressEthereum: (account: Account | null | undefined) => account is AccountAddressEthereum;
|
|
82
|
+
type AccountPlatformEthereum = Extract<Account, {
|
|
83
|
+
type: (typeof ACCOUNT_TYPES_PLATFORM_ETHEREUM)[number];
|
|
84
|
+
}> & {
|
|
85
|
+
address: `0x${string}`;
|
|
86
|
+
};
|
|
87
|
+
declare const isAccountPlatformEthereum: (account: Account | null | undefined) => account is AccountPlatformEthereum;
|
|
88
|
+
type AccountPlatformSolana = Extract<Account, {
|
|
89
|
+
type: (typeof ACCOUNT_TYPES_PLATFORM_SOLANA)[number];
|
|
90
|
+
}>;
|
|
91
|
+
declare const isAccountPlatformSolana: (account: Account | null | undefined) => account is AccountPlatformSolana;
|
|
92
|
+
type AccountPlatformPolkadot = Extract<Account, {
|
|
93
|
+
type: (typeof ACCOUNT_TYPES_PLATFORM_POLKADOT)[number];
|
|
94
|
+
}>;
|
|
95
|
+
declare const isAccountPlatformPolkadot: (account: Account | null | undefined) => account is AccountPlatformPolkadot;
|
|
96
|
+
type AccountAddressSs58 = Extract<Account, {
|
|
97
|
+
type: (typeof ACCOUNT_TYPES_ADDRESS_SS58)[number];
|
|
98
|
+
}> & {
|
|
99
|
+
genesisHash?: `0x${string}`;
|
|
100
|
+
};
|
|
101
|
+
declare const isAccountAddressSs58: (account: Account | null | undefined) => account is AccountAddressSs58;
|
|
102
|
+
declare const isAccountLedgerPolkadot: (account: Account | null | undefined) => account is AccountLedgerPolkadot;
|
|
103
|
+
declare const isAccountLedgerPolkadotGeneric: (account: Account | null | undefined) => account is AccountLedgerPolkadot & {
|
|
104
|
+
genesisHash: undefined;
|
|
105
|
+
};
|
|
106
|
+
declare const isAccountLedgerPolkadotLegacy: (account: Account | null | undefined) => account is AccountLedgerPolkadot & {
|
|
107
|
+
genesisHash: `0x${string}`;
|
|
108
|
+
};
|
|
109
|
+
type AccountBitcoin = Extract<Account, {
|
|
110
|
+
type: (typeof ACCOUNT_TYPES_BITCOIN)[number];
|
|
111
|
+
}>;
|
|
112
|
+
declare const isAccountBitcoin: (account: Account | null | undefined) => account is AccountBitcoin;
|
|
113
|
+
declare const getAccountGenesisHash: (account: Account | null | undefined) => `0x${string}` | undefined;
|
|
114
|
+
declare const getAccountSignetUrl: (account: Account | null | undefined) => string | undefined;
|
|
115
|
+
declare const getAccountPlatform: (account: Account | null | undefined) => _talismn_crypto.AccountPlatform | undefined;
|
|
116
|
+
|
|
117
|
+
type AddMnemonicOptions = {
|
|
118
|
+
mnemonic: string;
|
|
119
|
+
name: string;
|
|
120
|
+
confirmed: boolean;
|
|
121
|
+
};
|
|
122
|
+
type UpdateMnemonicOptions = {
|
|
123
|
+
name?: string;
|
|
124
|
+
confirmed?: boolean;
|
|
125
|
+
};
|
|
126
|
+
type DeriveFromNewMnemonic = {
|
|
127
|
+
type: "new-mnemonic";
|
|
128
|
+
mnemonic: string;
|
|
129
|
+
mnemonicName: string;
|
|
130
|
+
confirmed: boolean;
|
|
131
|
+
curve: KeypairCurve;
|
|
132
|
+
derivationPath: string;
|
|
133
|
+
};
|
|
134
|
+
type DeriveFromExistingMnemonic = {
|
|
135
|
+
type: "existing-mnemonic";
|
|
136
|
+
mnemonicId: string;
|
|
137
|
+
curve: KeypairCurve;
|
|
138
|
+
derivationPath: string;
|
|
139
|
+
};
|
|
140
|
+
type DeriveFromMnemonicOptions = DeriveFromNewMnemonic | DeriveFromExistingMnemonic;
|
|
141
|
+
type AddAccountDeriveOptions = Omit<AccountBase, "createdAt" | "address"> & DeriveFromMnemonicOptions;
|
|
142
|
+
type AddAccountKeypairOptions = Omit<AccountBase, "createdAt" | "address"> & {
|
|
143
|
+
curve: KeypairCurve;
|
|
144
|
+
secretKey: Uint8Array;
|
|
145
|
+
};
|
|
146
|
+
type AddAccountExternalOptions = Omit<AccountContact, "createdAt"> | Omit<AccountWatchOnly, "createdAt"> | Omit<AccountLedgerEthereum, "createdAt"> | Omit<AccountLedgerPolkadot, "createdAt"> | Omit<AccountLedgerSolana, "createdAt"> | Omit<AccountPolkadotVault, "createdAt"> | Omit<AccountSignet, "createdAt">;
|
|
147
|
+
type UpdateAccountOptions = {
|
|
148
|
+
name?: string;
|
|
149
|
+
isPortfolio?: boolean;
|
|
150
|
+
genesisHash?: `0x${string}`;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
type MnemonicStorage = Mnemonic & {
|
|
154
|
+
entropy: string;
|
|
155
|
+
};
|
|
156
|
+
type AccountKeypairStorage = AccountKeypair & {
|
|
157
|
+
secretKey: string;
|
|
158
|
+
};
|
|
159
|
+
type AccountStorage = AccountKeypairStorage | AccountContact | AccountWatchOnly | AccountLedgerEthereum | AccountLedgerPolkadot | AccountLedgerSolana | AccountPolkadotVault | AccountSignet;
|
|
160
|
+
|
|
161
|
+
type KeyringStorage = {
|
|
162
|
+
passwordCheck: string | null;
|
|
163
|
+
mnemonics: MnemonicStorage[];
|
|
164
|
+
accounts: AccountStorage[];
|
|
165
|
+
};
|
|
166
|
+
declare class Keyring {
|
|
167
|
+
#private;
|
|
168
|
+
protected constructor(data: KeyringStorage);
|
|
169
|
+
static create(): Keyring;
|
|
170
|
+
static load(data: KeyringStorage): Keyring;
|
|
171
|
+
private checkPassword;
|
|
172
|
+
toJson(): KeyringStorage;
|
|
173
|
+
export(password: string, jsonPassword: string): Promise<KeyringStorage>;
|
|
174
|
+
getMnemonics(): Mnemonic[];
|
|
175
|
+
addMnemonic({ name, mnemonic, confirmed }: AddMnemonicOptions, password: string): Promise<Mnemonic>;
|
|
176
|
+
getMnemonic(id: string): Mnemonic | null;
|
|
177
|
+
updateMnemonic(id: string, { name, confirmed }: UpdateMnemonicOptions): Mnemonic;
|
|
178
|
+
removeMnemonic(id: string): void;
|
|
179
|
+
getMnemonicText(id: string, password: string): Promise<string>;
|
|
180
|
+
getExistingMnemonicId(mnemonic: string): string | null;
|
|
181
|
+
getAccounts(): Account[];
|
|
182
|
+
getAccount(address: string): Account | null;
|
|
183
|
+
updateAccount(address: string, { name, isPortfolio, genesisHash }: UpdateAccountOptions): Account;
|
|
184
|
+
removeAccount(address: string): void;
|
|
185
|
+
addAccountExternal(options: AddAccountExternalOptions): Account;
|
|
186
|
+
/**
|
|
187
|
+
* Needs to be called before deriving an account from a mnemonic.
|
|
188
|
+
*
|
|
189
|
+
* This will ensure that it is present (or add it if possible) in the keyring before actually creating the account.
|
|
190
|
+
*
|
|
191
|
+
* @param options
|
|
192
|
+
* @param password
|
|
193
|
+
* @returns the id of the mnemonic
|
|
194
|
+
*/
|
|
195
|
+
private ensureMnemonic;
|
|
196
|
+
addAccountDerive(options: AddAccountDeriveOptions, password: string): Promise<Account>;
|
|
197
|
+
addAccountKeypair({ curve, name, secretKey }: AddAccountKeypairOptions, password: string): Promise<Account>;
|
|
198
|
+
getAccountSecretKey(address: string, password: string): Promise<Uint8Array>;
|
|
199
|
+
getDerivedAddress(mnemonicId: string, derivationPath: string, curve: KeypairCurve, password: string): Promise<string>;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export { type Account, type AccountBase, type AccountContact, type AccountKeypair, type AccountLedgerEthereum, type AccountLedgerPolkadot, type AccountLedgerSolana, type AccountOfType, type AccountPolkadotVault, type AccountSignet, type AccountType, type AccountWatchOnly, type AddAccountDeriveOptions, type AddAccountExternalOptions, type AddAccountKeypairOptions, type AddMnemonicOptions, Keyring, type KeyringStorage, type LedgerPolkadotCurve, type Mnemonic, type UpdateAccountOptions, type UpdateMnemonicOptions, getAccountGenesisHash, getAccountPlatform, getAccountSignetUrl, isAccountAddressEthereum, isAccountAddressSs58, isAccountBitcoin, isAccountExternal, isAccountInTypes, isAccountLedgerPolkadot, isAccountLedgerPolkadotGeneric, isAccountLedgerPolkadotLegacy, isAccountNotContact, isAccountOfType, isAccountOwned, isAccountPlatformEthereum, isAccountPlatformPolkadot, isAccountPlatformSolana, isAccountPortfolio };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import * as _talismn_crypto from '@talismn/crypto';
|
|
2
|
+
import { KeypairCurve } from '@talismn/crypto';
|
|
3
|
+
|
|
4
|
+
type Mnemonic = {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
confirmed: boolean;
|
|
8
|
+
createdAt: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type LedgerPolkadotCurve = "ed25519" | "ethereum";
|
|
12
|
+
type AccountBase = {
|
|
13
|
+
address: string;
|
|
14
|
+
name: string;
|
|
15
|
+
createdAt: number;
|
|
16
|
+
};
|
|
17
|
+
type AccountKeypair = AccountBase & {
|
|
18
|
+
type: "keypair";
|
|
19
|
+
curve: KeypairCurve;
|
|
20
|
+
mnemonicId?: string;
|
|
21
|
+
derivationPath?: string;
|
|
22
|
+
};
|
|
23
|
+
type AccountContact = AccountBase & {
|
|
24
|
+
type: "contact";
|
|
25
|
+
genesisHash?: `0x${string}`;
|
|
26
|
+
};
|
|
27
|
+
type AccountWatchOnly = AccountBase & {
|
|
28
|
+
type: "watch-only";
|
|
29
|
+
isPortfolio: boolean;
|
|
30
|
+
};
|
|
31
|
+
type AccountLedgerPolkadot = AccountBase & {
|
|
32
|
+
type: "ledger-polkadot";
|
|
33
|
+
curve: LedgerPolkadotCurve;
|
|
34
|
+
app: string;
|
|
35
|
+
accountIndex: number;
|
|
36
|
+
addressOffset: number;
|
|
37
|
+
genesisHash?: `0x${string}`;
|
|
38
|
+
};
|
|
39
|
+
type AccountLedgerEthereum = AccountBase & {
|
|
40
|
+
type: "ledger-ethereum";
|
|
41
|
+
derivationPath: string;
|
|
42
|
+
};
|
|
43
|
+
type AccountLedgerSolana = AccountBase & {
|
|
44
|
+
type: "ledger-solana";
|
|
45
|
+
derivationPath: string;
|
|
46
|
+
};
|
|
47
|
+
type AccountPolkadotVault = AccountBase & {
|
|
48
|
+
type: "polkadot-vault";
|
|
49
|
+
genesisHash: `0x${string}` | null;
|
|
50
|
+
};
|
|
51
|
+
type AccountSignet = AccountBase & {
|
|
52
|
+
type: "signet";
|
|
53
|
+
genesisHash: `0x${string}`;
|
|
54
|
+
url: string;
|
|
55
|
+
};
|
|
56
|
+
type Account = AccountKeypair | AccountContact | AccountWatchOnly | AccountLedgerEthereum | AccountLedgerPolkadot | AccountLedgerSolana | AccountPolkadotVault | AccountSignet;
|
|
57
|
+
type AccountType = Account["type"];
|
|
58
|
+
|
|
59
|
+
type AccountOfType<Type extends AccountType> = Extract<Account, {
|
|
60
|
+
type: Type;
|
|
61
|
+
}>;
|
|
62
|
+
declare const isAccountOfType: <Type extends AccountType>(account: Account | null | undefined, type: Type) => account is AccountOfType<Type>;
|
|
63
|
+
declare const isAccountInTypes: <Types extends AccountType[]>(account: Account | null | undefined, types: Types) => account is AccountOfType<Types[number]>;
|
|
64
|
+
declare const ACCOUNT_TYPES_OWNED: readonly ["keypair", "ledger-ethereum", "ledger-polkadot", "ledger-solana", "polkadot-vault"];
|
|
65
|
+
declare const ACCOUNT_TYPES_EXTERNAL: readonly ["contact", "watch-only", "ledger-ethereum", "ledger-polkadot", "ledger-solana", "polkadot-vault", "signet"];
|
|
66
|
+
declare const ACCOUNT_TYPES_ADDRESS_ETHEREUM: readonly ["contact", "watch-only", "keypair", "ledger-ethereum", "ledger-polkadot"];
|
|
67
|
+
declare const ACCOUNT_TYPES_PLATFORM_ETHEREUM: readonly ["contact", "watch-only", "keypair", "ledger-ethereum"];
|
|
68
|
+
declare const ACCOUNT_TYPES_PLATFORM_POLKADOT: readonly ["contact", "watch-only", "keypair", "ledger-polkadot", "polkadot-vault", "signet"];
|
|
69
|
+
declare const ACCOUNT_TYPES_ADDRESS_SS58: readonly ["contact", "watch-only", "keypair", "ledger-polkadot", "polkadot-vault", "signet"];
|
|
70
|
+
declare const ACCOUNT_TYPES_PLATFORM_SOLANA: readonly ["contact", "watch-only", "keypair", "ledger-solana"];
|
|
71
|
+
declare const ACCOUNT_TYPES_BITCOIN: readonly ["contact", "watch-only"];
|
|
72
|
+
declare const isAccountExternal: (account: Account | null | undefined) => account is AccountOfType<(typeof ACCOUNT_TYPES_EXTERNAL)[number]>;
|
|
73
|
+
declare const isAccountOwned: (account: Account | null | undefined) => account is AccountOfType<(typeof ACCOUNT_TYPES_OWNED)[number]>;
|
|
74
|
+
declare const isAccountPortfolio: (account: Account | null | undefined) => account is Account;
|
|
75
|
+
declare const isAccountNotContact: (acc: Account) => acc is AccountKeypair | AccountWatchOnly | AccountLedgerPolkadot | AccountLedgerEthereum | AccountLedgerSolana | AccountPolkadotVault | AccountSignet;
|
|
76
|
+
type AccountAddressEthereum = Extract<Account, {
|
|
77
|
+
type: (typeof ACCOUNT_TYPES_ADDRESS_ETHEREUM)[number];
|
|
78
|
+
}> & {
|
|
79
|
+
address: `0x${string}`;
|
|
80
|
+
};
|
|
81
|
+
declare const isAccountAddressEthereum: (account: Account | null | undefined) => account is AccountAddressEthereum;
|
|
82
|
+
type AccountPlatformEthereum = Extract<Account, {
|
|
83
|
+
type: (typeof ACCOUNT_TYPES_PLATFORM_ETHEREUM)[number];
|
|
84
|
+
}> & {
|
|
85
|
+
address: `0x${string}`;
|
|
86
|
+
};
|
|
87
|
+
declare const isAccountPlatformEthereum: (account: Account | null | undefined) => account is AccountPlatformEthereum;
|
|
88
|
+
type AccountPlatformSolana = Extract<Account, {
|
|
89
|
+
type: (typeof ACCOUNT_TYPES_PLATFORM_SOLANA)[number];
|
|
90
|
+
}>;
|
|
91
|
+
declare const isAccountPlatformSolana: (account: Account | null | undefined) => account is AccountPlatformSolana;
|
|
92
|
+
type AccountPlatformPolkadot = Extract<Account, {
|
|
93
|
+
type: (typeof ACCOUNT_TYPES_PLATFORM_POLKADOT)[number];
|
|
94
|
+
}>;
|
|
95
|
+
declare const isAccountPlatformPolkadot: (account: Account | null | undefined) => account is AccountPlatformPolkadot;
|
|
96
|
+
type AccountAddressSs58 = Extract<Account, {
|
|
97
|
+
type: (typeof ACCOUNT_TYPES_ADDRESS_SS58)[number];
|
|
98
|
+
}> & {
|
|
99
|
+
genesisHash?: `0x${string}`;
|
|
100
|
+
};
|
|
101
|
+
declare const isAccountAddressSs58: (account: Account | null | undefined) => account is AccountAddressSs58;
|
|
102
|
+
declare const isAccountLedgerPolkadot: (account: Account | null | undefined) => account is AccountLedgerPolkadot;
|
|
103
|
+
declare const isAccountLedgerPolkadotGeneric: (account: Account | null | undefined) => account is AccountLedgerPolkadot & {
|
|
104
|
+
genesisHash: undefined;
|
|
105
|
+
};
|
|
106
|
+
declare const isAccountLedgerPolkadotLegacy: (account: Account | null | undefined) => account is AccountLedgerPolkadot & {
|
|
107
|
+
genesisHash: `0x${string}`;
|
|
108
|
+
};
|
|
109
|
+
type AccountBitcoin = Extract<Account, {
|
|
110
|
+
type: (typeof ACCOUNT_TYPES_BITCOIN)[number];
|
|
111
|
+
}>;
|
|
112
|
+
declare const isAccountBitcoin: (account: Account | null | undefined) => account is AccountBitcoin;
|
|
113
|
+
declare const getAccountGenesisHash: (account: Account | null | undefined) => `0x${string}` | undefined;
|
|
114
|
+
declare const getAccountSignetUrl: (account: Account | null | undefined) => string | undefined;
|
|
115
|
+
declare const getAccountPlatform: (account: Account | null | undefined) => _talismn_crypto.AccountPlatform | undefined;
|
|
116
|
+
|
|
117
|
+
type AddMnemonicOptions = {
|
|
118
|
+
mnemonic: string;
|
|
119
|
+
name: string;
|
|
120
|
+
confirmed: boolean;
|
|
121
|
+
};
|
|
122
|
+
type UpdateMnemonicOptions = {
|
|
123
|
+
name?: string;
|
|
124
|
+
confirmed?: boolean;
|
|
125
|
+
};
|
|
126
|
+
type DeriveFromNewMnemonic = {
|
|
127
|
+
type: "new-mnemonic";
|
|
128
|
+
mnemonic: string;
|
|
129
|
+
mnemonicName: string;
|
|
130
|
+
confirmed: boolean;
|
|
131
|
+
curve: KeypairCurve;
|
|
132
|
+
derivationPath: string;
|
|
133
|
+
};
|
|
134
|
+
type DeriveFromExistingMnemonic = {
|
|
135
|
+
type: "existing-mnemonic";
|
|
136
|
+
mnemonicId: string;
|
|
137
|
+
curve: KeypairCurve;
|
|
138
|
+
derivationPath: string;
|
|
139
|
+
};
|
|
140
|
+
type DeriveFromMnemonicOptions = DeriveFromNewMnemonic | DeriveFromExistingMnemonic;
|
|
141
|
+
type AddAccountDeriveOptions = Omit<AccountBase, "createdAt" | "address"> & DeriveFromMnemonicOptions;
|
|
142
|
+
type AddAccountKeypairOptions = Omit<AccountBase, "createdAt" | "address"> & {
|
|
143
|
+
curve: KeypairCurve;
|
|
144
|
+
secretKey: Uint8Array;
|
|
145
|
+
};
|
|
146
|
+
type AddAccountExternalOptions = Omit<AccountContact, "createdAt"> | Omit<AccountWatchOnly, "createdAt"> | Omit<AccountLedgerEthereum, "createdAt"> | Omit<AccountLedgerPolkadot, "createdAt"> | Omit<AccountLedgerSolana, "createdAt"> | Omit<AccountPolkadotVault, "createdAt"> | Omit<AccountSignet, "createdAt">;
|
|
147
|
+
type UpdateAccountOptions = {
|
|
148
|
+
name?: string;
|
|
149
|
+
isPortfolio?: boolean;
|
|
150
|
+
genesisHash?: `0x${string}`;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
type MnemonicStorage = Mnemonic & {
|
|
154
|
+
entropy: string;
|
|
155
|
+
};
|
|
156
|
+
type AccountKeypairStorage = AccountKeypair & {
|
|
157
|
+
secretKey: string;
|
|
158
|
+
};
|
|
159
|
+
type AccountStorage = AccountKeypairStorage | AccountContact | AccountWatchOnly | AccountLedgerEthereum | AccountLedgerPolkadot | AccountLedgerSolana | AccountPolkadotVault | AccountSignet;
|
|
160
|
+
|
|
161
|
+
type KeyringStorage = {
|
|
162
|
+
passwordCheck: string | null;
|
|
163
|
+
mnemonics: MnemonicStorage[];
|
|
164
|
+
accounts: AccountStorage[];
|
|
165
|
+
};
|
|
166
|
+
declare class Keyring {
|
|
167
|
+
#private;
|
|
168
|
+
protected constructor(data: KeyringStorage);
|
|
169
|
+
static create(): Keyring;
|
|
170
|
+
static load(data: KeyringStorage): Keyring;
|
|
171
|
+
private checkPassword;
|
|
172
|
+
toJson(): KeyringStorage;
|
|
173
|
+
export(password: string, jsonPassword: string): Promise<KeyringStorage>;
|
|
174
|
+
getMnemonics(): Mnemonic[];
|
|
175
|
+
addMnemonic({ name, mnemonic, confirmed }: AddMnemonicOptions, password: string): Promise<Mnemonic>;
|
|
176
|
+
getMnemonic(id: string): Mnemonic | null;
|
|
177
|
+
updateMnemonic(id: string, { name, confirmed }: UpdateMnemonicOptions): Mnemonic;
|
|
178
|
+
removeMnemonic(id: string): void;
|
|
179
|
+
getMnemonicText(id: string, password: string): Promise<string>;
|
|
180
|
+
getExistingMnemonicId(mnemonic: string): string | null;
|
|
181
|
+
getAccounts(): Account[];
|
|
182
|
+
getAccount(address: string): Account | null;
|
|
183
|
+
updateAccount(address: string, { name, isPortfolio, genesisHash }: UpdateAccountOptions): Account;
|
|
184
|
+
removeAccount(address: string): void;
|
|
185
|
+
addAccountExternal(options: AddAccountExternalOptions): Account;
|
|
186
|
+
/**
|
|
187
|
+
* Needs to be called before deriving an account from a mnemonic.
|
|
188
|
+
*
|
|
189
|
+
* This will ensure that it is present (or add it if possible) in the keyring before actually creating the account.
|
|
190
|
+
*
|
|
191
|
+
* @param options
|
|
192
|
+
* @param password
|
|
193
|
+
* @returns the id of the mnemonic
|
|
194
|
+
*/
|
|
195
|
+
private ensureMnemonic;
|
|
196
|
+
addAccountDerive(options: AddAccountDeriveOptions, password: string): Promise<Account>;
|
|
197
|
+
addAccountKeypair({ curve, name, secretKey }: AddAccountKeypairOptions, password: string): Promise<Account>;
|
|
198
|
+
getAccountSecretKey(address: string, password: string): Promise<Uint8Array>;
|
|
199
|
+
getDerivedAddress(mnemonicId: string, derivationPath: string, curve: KeypairCurve, password: string): Promise<string>;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export { type Account, type AccountBase, type AccountContact, type AccountKeypair, type AccountLedgerEthereum, type AccountLedgerPolkadot, type AccountLedgerSolana, type AccountOfType, type AccountPolkadotVault, type AccountSignet, type AccountType, type AccountWatchOnly, type AddAccountDeriveOptions, type AddAccountExternalOptions, type AddAccountKeypairOptions, type AddMnemonicOptions, Keyring, type KeyringStorage, type LedgerPolkadotCurve, type Mnemonic, type UpdateAccountOptions, type UpdateMnemonicOptions, getAccountGenesisHash, getAccountPlatform, getAccountSignetUrl, isAccountAddressEthereum, isAccountAddressSs58, isAccountBitcoin, isAccountExternal, isAccountInTypes, isAccountLedgerPolkadot, isAccountLedgerPolkadotGeneric, isAccountLedgerPolkadotLegacy, isAccountNotContact, isAccountOfType, isAccountOwned, isAccountPlatformEthereum, isAccountPlatformPolkadot, isAccountPlatformSolana, isAccountPortfolio };
|