mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 11:39:22 +00:00
baad7f7469
* init * updates * nano updates * updates * updates * [skipci] wip deep link changes * fix deep links * minor fix * add reminder message on buy and exchange routes * [skip ci] font fixes * review updates * [skip ci] minor fix * save * fixes * minor code cleanup * minor potential fix
101 lines
2.7 KiB
Dart
101 lines
2.7 KiB
Dart
import 'dart:convert';
|
|
import 'dart:io';
|
|
import 'utils/secret_key.dart';
|
|
import 'utils/utils.dart';
|
|
|
|
const configPath = 'tool/.secrets-config.json';
|
|
const evmChainsConfigPath = 'tool/.evm-secrets-config.json';
|
|
const solanaConfigPath = 'tool/.solana-secrets-config.json';
|
|
const nanoConfigPath = 'tool/.nano-secrets-config.json';
|
|
const tronConfigPath = 'tool/.tron-secrets-config.json';
|
|
|
|
Future<void> main(List<String> args) async => generateSecretsConfig(args);
|
|
|
|
Future<void> generateSecretsConfig(List<String> args) async {
|
|
final extraInfo = args.fold(<String, dynamic>{}, (Map<String, dynamic> acc, String arg) {
|
|
final parts = arg.split('=');
|
|
final key = normalizeKeyName(parts[0]);
|
|
acc[key] = acc[key] = parts.length > 1 ? parts[1] : 1;
|
|
return acc;
|
|
});
|
|
|
|
final configFile = File(configPath);
|
|
final evmChainsConfigFile = File(evmChainsConfigPath);
|
|
final solanaConfigFile = File(solanaConfigPath);
|
|
final nanoConfigFile = File(nanoConfigPath);
|
|
final tronConfigFile = File(tronConfigPath);
|
|
|
|
final secrets = <String, dynamic>{};
|
|
|
|
secrets.addAll(extraInfo);
|
|
secrets.removeWhere((key, dynamic value) {
|
|
if (key.contains('--')) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
});
|
|
|
|
if (configFile.existsSync()) {
|
|
if (extraInfo['--force'] == 1) {
|
|
await configFile.delete();
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
|
|
// base:
|
|
SecretKey.base.forEach((sec) {
|
|
if (secrets[sec.name] != null) {
|
|
return;
|
|
}
|
|
secrets[sec.name] = sec.generate();
|
|
});
|
|
var secretsJson = JsonEncoder.withIndent(' ').convert(secrets);
|
|
await configFile.writeAsString(secretsJson);
|
|
secrets.clear();
|
|
|
|
// evm chains:
|
|
SecretKey.evmChainsSecrets.forEach((sec) {
|
|
if (secrets[sec.name] != null) {
|
|
return;
|
|
}
|
|
secrets[sec.name] = sec.generate();
|
|
});
|
|
secretsJson = JsonEncoder.withIndent(' ').convert(secrets);
|
|
await evmChainsConfigFile.writeAsString(secretsJson);
|
|
secrets.clear();
|
|
|
|
// solana:
|
|
SecretKey.solanaSecrets.forEach((sec) {
|
|
if (secrets[sec.name] != null) {
|
|
return;
|
|
}
|
|
secrets[sec.name] = sec.generate();
|
|
});
|
|
secretsJson = JsonEncoder.withIndent(' ').convert(secrets);
|
|
await solanaConfigFile.writeAsString(secretsJson);
|
|
secrets.clear();
|
|
|
|
// nano:
|
|
SecretKey.nanoSecrets.forEach((sec) {
|
|
if (secrets[sec.name] != null) {
|
|
return;
|
|
}
|
|
secrets[sec.name] = sec.generate();
|
|
});
|
|
secretsJson = JsonEncoder.withIndent(' ').convert(secrets);
|
|
await nanoConfigFile.writeAsString(secretsJson);
|
|
secrets.clear();
|
|
|
|
SecretKey.tronSecrets.forEach((sec) {
|
|
if (secrets[sec.name] != null) {
|
|
return;
|
|
}
|
|
|
|
secrets[sec.name] = sec.generate();
|
|
});
|
|
secretsJson = JsonEncoder.withIndent(' ').convert(secrets);
|
|
await tronConfigFile.writeAsString(secretsJson);
|
|
secrets.clear();
|
|
}
|