mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-25 04:59:33 +00:00
09fd6a8241
Generate Ethereum specific secrets in Ethereum package
35 lines
1.2 KiB
Dart
35 lines
1.2 KiB
Dart
import 'dart:convert';
|
|
import 'dart:io';
|
|
import 'utils/utils.dart';
|
|
|
|
const configPath = 'tool/.secrets-config.json';
|
|
const outputPath = 'lib/.secrets.g.dart';
|
|
|
|
const ethereumConfigPath = 'tool/.ethereum-secrets-config.json';
|
|
const ethereumOutputPath = 'cw_ethereum/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 ethereumOutputFile = File(ethereumOutputPath);
|
|
final ethereumInput =
|
|
json.decode(File(ethereumConfigPath).readAsStringSync()) as Map<String, dynamic>;
|
|
final ethereumOutput = ethereumInput.keys
|
|
.fold('', (String acc, String val) => acc + generateConst(val, ethereumInput));
|
|
|
|
if (outputFile.existsSync()) {
|
|
await outputFile.delete();
|
|
}
|
|
|
|
await outputFile.writeAsString(output);
|
|
|
|
if (ethereumOutputFile.existsSync()) {
|
|
await ethereumOutputFile.delete();
|
|
}
|
|
|
|
await ethereumOutputFile.writeAsString(ethereumOutput);
|
|
}
|