-
Notifications
You must be signed in to change notification settings - Fork 55
/
types.ts
76 lines (66 loc) · 2.37 KB
/
types.ts
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
import { AccountKeyDerivationPath } from '@cardano-sdk/key-management';
import { Bip32PublicKeyHex } from '@cardano-sdk/crypto';
import { Cardano } from '@cardano-sdk/core';
import { HexBlob } from '@cardano-sdk/util';
export enum WalletType {
InMemory = 'InMemory',
Ledger = 'Ledger',
Trezor = 'Trezor',
Script = 'Script'
}
/** For BIP-32 wallets: hash of extended account public key. For script wallets: script hash */
export type WalletId = string;
export type Bip32WalletAccount<Metadata extends {}> = {
accountIndex: number;
/** e.g. account name, picture */
metadata: Metadata;
extendedAccountPublicKey: Bip32PublicKeyHex;
};
export type Bip32Wallet<WalletMetadata extends {}, AccountMetadata extends {}> = {
walletId: WalletId;
metadata: WalletMetadata;
accounts: Bip32WalletAccount<AccountMetadata>[];
};
export type HardwareWallet<WalletMetadata extends {}, AccountMetadata extends {}> = Bip32Wallet<
WalletMetadata,
AccountMetadata
> & {
type: WalletType.Ledger | WalletType.Trezor;
};
export type InMemoryWallet<WalletMetadata extends {}, AccountMetadata extends {}> = Bip32Wallet<
WalletMetadata,
AccountMetadata
> & {
type: WalletType.InMemory;
encryptedSecrets: {
/**
* The key material is derived by concatenating the mnemonic words (separated by spaces) into a single string.
* This concatenated string is then encrypted using the 'emip3encrypt' method. The resulting
* encrypted data is encoded as a hexadecimal string.
*/
keyMaterial: HexBlob;
rootPrivateKeyBytes: HexBlob;
};
};
export type AnyBip32Wallet<WalletMetadata extends {}, AccountMetadata extends {}> =
| HardwareWallet<WalletMetadata, AccountMetadata>
| InMemoryWallet<WalletMetadata, AccountMetadata>;
export type OwnSignerAccount = {
walletId: WalletId;
accountIndex: number;
stakingScriptKeyPath: AccountKeyDerivationPath;
paymentScriptKeyPath: AccountKeyDerivationPath;
};
export type ScriptWallet<Metadata extends {}> = {
type: WalletType.Script;
walletId: WalletId;
/** e.g. account name, picture */
metadata: Metadata;
paymentScript: Cardano.Script;
stakingScript: Cardano.Script;
ownSigners: OwnSignerAccount[];
};
export type AnyWallet<WalletMetadata extends {}, AccountMetadata extends {}> =
| HardwareWallet<WalletMetadata, AccountMetadata>
| InMemoryWallet<WalletMetadata, AccountMetadata>
| ScriptWallet<WalletMetadata>;