Added target to Makefile to download, compress, and add the chains.zip file to the AlphaWallet project.
parent
a88e0e349d
commit
91d34bdb3d
@ -0,0 +1,22 @@ |
|||||||
|
The chains.json file is downloaded from https://chainid.network/chains.json. |
||||||
|
|
||||||
|
This file is then compressed using NSData.CompressionAlgorithm.lzma and stored raw without any headers. |
||||||
|
|
||||||
|
It is then renamed as chains.zip and must be added to the Rpc Network group of the project. |
||||||
|
|
||||||
|
A Makefile target has been added to automate this process. At the command line, type in: |
||||||
|
|
||||||
|
``` |
||||||
|
make update_chains_file |
||||||
|
``` |
||||||
|
|
||||||
|
and you should see the following response: |
||||||
|
|
||||||
|
```console |
||||||
|
Deleting chains file in scripts folder. |
||||||
|
Downloading chains file. |
||||||
|
################################################################################################################# 100.0% |
||||||
|
Compressing. |
||||||
|
Moving compressed file into project. |
||||||
|
Update completed. |
||||||
|
``` |
@ -0,0 +1,24 @@ |
|||||||
|
#!/usr/bin/env swift |
||||||
|
|
||||||
|
import Foundation |
||||||
|
|
||||||
|
let selectedCompressionAlgorithm = NSData.CompressionAlgorithm.lzma |
||||||
|
|
||||||
|
func compressChainFile(inputFileName: String, outputFileName: String) throws { |
||||||
|
let inputFileHandle = FileHandle(forReadingAtPath: inputFileName)! |
||||||
|
let inputData = inputFileHandle.readDataToEndOfFile() as NSData |
||||||
|
let outputData = try inputData.compressed(using: selectedCompressionAlgorithm) as Data |
||||||
|
FileManager.default.createFile(atPath: outputFileName, contents: outputData, attributes: nil) |
||||||
|
try inputFileHandle.close() |
||||||
|
} |
||||||
|
|
||||||
|
do { |
||||||
|
try compressChainFile(inputFileName: "scripts/chains.json", outputFileName: "scripts/chains.json.zip") |
||||||
|
exit(0) |
||||||
|
} catch { |
||||||
|
print("An error occurred: \(error)") |
||||||
|
exit(-1) |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in new issue