forked from LimeChain/Fruzhin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fix creation of chainspec form json
- Loading branch information
Showing
18 changed files
with
153 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,4 @@ out/ | |
/test | ||
|
||
### Local Chain Spec | ||
/genesis/westend-local.json | ||
/src/main/webapp/genesis/westend-local.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.limechain.teavm; | ||
|
||
import org.teavm.jso.JSBody; | ||
import org.teavm.jso.JSObject; | ||
|
||
public class HttpRequest { | ||
@JSBody(params = {"method", "url", "body"}, script = "return httpRequestSync(method, url, body);") | ||
public static native String httpRequestSync(String method, String url, JSObject body); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,16 @@ | ||
package com.limechain.utils.json; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.FileReader; | ||
import java.io.IOException; | ||
import com.limechain.teavm.HttpRequest; | ||
|
||
import java.util.Map; | ||
|
||
public class JsonUtil { | ||
|
||
static Map<String, Object> parseJson(String jsonPath) { | ||
try { | ||
return new JsonParser(readJsonFromFile(jsonPath)).parse(); | ||
} catch (IOException e) { | ||
throw new IllegalStateException("Failed to parse json at path " + jsonPath); | ||
} | ||
return new JsonParser(readJsonFromFile(jsonPath)).parse(); | ||
} | ||
|
||
private static String readJsonFromFile(String filePath) throws IOException { | ||
StringBuilder jsonStringBuilder = new StringBuilder(); | ||
try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) { | ||
String line; | ||
while ((line = reader.readLine()) != null) { | ||
jsonStringBuilder.append(line); | ||
} | ||
} | ||
return jsonStringBuilder.toString(); | ||
private static String readJsonFromFile(String filePath) { | ||
return HttpRequest.httpRequestSync("GET", filePath, null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.limechain.utils.json; | ||
|
||
import com.limechain.chain.spec.ChainSpec; | ||
|
||
public class ObjectFactory { | ||
public static ChainSpec createChainSpec() { | ||
return new ChainSpec(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2014 Alexey Andreev. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<web-app xmlns="http://java.sun.com/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" | ||
version="3.0"> | ||
</web-app> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
function httpRequestSync(method, url, body) { | ||
var xhr = new XMLHttpRequest(); | ||
xhr.open(method, url, false); // false for synchronous request | ||
xhr.setRequestHeader('Content-Type', 'application/json'); | ||
if (method === 'POST' && body) { | ||
xhr.send(JSON.stringify(body)); | ||
} else { | ||
xhr.send(); | ||
} | ||
if (xhr.status === 200) { | ||
return xhr.responseText; | ||
} else { | ||
throw new Error('Request failed with status ' + xhr.status); | ||
} | ||
} |