| 1 | import 'package:cw_core/enumerable_item.dart'; |
| 2 | import 'package:cw_core/wallet_info.dart'; |
| 3 | |
| 4 | class MoneroSeedType extends EnumerableItem<int> with Serializable<int> { |
| 5 | const MoneroSeedType({required String title, required int raw, this.shortTitle}) |
| 6 | : super(title: title, raw: raw); |
| 7 | |
| 8 | final String? shortTitle; |
| 9 | |
| 10 | static const all = [legacy, polyseed, bip39]; |
| 11 | |
| 12 | static const defaultSeedType = polyseed; |
| 13 | |
| 14 | static const legacy = MoneroSeedType(raw: 0, title: 'Legacy (25 words)', shortTitle: "Legacy"); |
| 15 | static const polyseed = |
| 16 | MoneroSeedType(raw: 1, title: 'Polyseed (16 words)', shortTitle: "Polyseed"); |
| 17 | static const wowneroSeed = MoneroSeedType(raw: 2, title: 'Wownero'); |
| 18 | static const bip39 = MoneroSeedType(raw: 3, title: 'BIP39 (12 words)', shortTitle: "BIP39"); |
| 19 | |
| 20 | static MoneroSeedType deserialize({required int raw}) { |
| 21 | switch (raw) { |
| 22 | case 0: |
| 23 | return legacy; |
| 24 | case 1: |
| 25 | return polyseed; |
| 26 | case 2: |
| 27 | return wowneroSeed; |
| 28 | case 3: |
| 29 | return bip39; |
| 30 | default: |
| 31 | throw Exception('Unexpected token: $raw for SeedType deserialize'); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | @override |
| 36 | String toString() => title; |
| 37 | } |
| 38 | |
| 39 | class BitcoinSeedType extends EnumerableItem<int> with Serializable<int> { |
| 40 | const BitcoinSeedType(this.type, {required String title, required int raw}) |
| 41 | : super(title: title, raw: raw); |
| 42 | |
| 43 | final DerivationType type; |
| 44 | |
| 45 | static const all = [BitcoinSeedType.electrum, BitcoinSeedType.bip39]; |
| 46 | |
| 47 | static const defaultDerivationType = bip39; |
| 48 | |
| 49 | static const electrum = BitcoinSeedType(DerivationType.electrum, raw: 0, title: 'Electrum'); |
| 50 | static const bip39 = BitcoinSeedType(DerivationType.bip39, raw: 1, title: 'BIP39'); |
| 51 | |
| 52 | static BitcoinSeedType deserialize({required int raw}) { |
| 53 | switch (raw) { |
| 54 | case 0: |
| 55 | return electrum; |
| 56 | case 1: |
| 57 | return bip39; |
| 58 | default: |
| 59 | throw Exception('Unexpected token: $raw for SeedType deserialize'); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | class NanoSeedType extends EnumerableItem<int> with Serializable<int> { |
| 65 | const NanoSeedType(this.type, {required String title, required int raw}) |
| 66 | : super(title: title, raw: raw); |
| 67 | |
| 68 | final DerivationType type; |
| 69 | |
| 70 | static const all = [NanoSeedType.nanoStandard, NanoSeedType.bip39]; |
| 71 | |
| 72 | static const defaultDerivationType = bip39; |
| 73 | |
| 74 | static const nanoStandard = NanoSeedType(DerivationType.nano, raw: 0, title: 'Nano'); |
| 75 | static const bip39 = NanoSeedType(DerivationType.bip39, raw: 1, title: 'BIP39'); |
| 76 | |
| 77 | static NanoSeedType deserialize({required int raw}) { |
| 78 | switch (raw) { |
| 79 | case 0: |
| 80 | return nanoStandard; |
| 81 | case 1: |
| 82 | return bip39; |
| 83 | default: |
| 84 | throw Exception('Unexpected token: $raw for SeedType deserialize'); |
| 85 | } |
| 86 | } |
| 87 | } |