forked from cake-tech/cake_wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport_secrets_config.dart
35 lines (26 loc) · 1.16 KB
/
import_secrets_config.dart
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
import 'dart:convert';
import 'dart:io';
import 'utils/utils.dart';
const configPath = 'tool/.secrets-config.json';
const outputPath = 'lib/.secrets.g.dart';
const evmChainsConfigPath = 'tool/.evm-secrets-config.json';
const evmChainsOutputPath = 'cw_evm/lib/.secrets.g.dart';
Future<void> main(List<String> args) async => importSecretsConfig();
Future<void> importSecretsConfig() async {
final outputFile = File(outputPath);
final input = json.decode(File(configPath).readAsStringSync()) as Map<String, dynamic>;
final output = input.keys.fold('', (String acc, String val) => acc + generateConst(val, input));
final evmChainsOutputFile = File(evmChainsOutputPath);
final evmChainsInput =
json.decode(File(evmChainsConfigPath).readAsStringSync()) as Map<String, dynamic>;
final evmChainsOutput = evmChainsInput.keys
.fold('', (String acc, String val) => acc + generateConst(val, evmChainsInput));
if (outputFile.existsSync()) {
await outputFile.delete();
}
await outputFile.writeAsString(output);
if (evmChainsOutputFile.existsSync()) {
await evmChainsOutputFile.delete();
}
await evmChainsOutputFile.writeAsString(evmChainsOutput);
}