Skip to content

Commit 64165fd

Browse files
committed
Adjust some comments
1 parent 02af2d4 commit 64165fd

File tree

8 files changed

+40
-18
lines changed

8 files changed

+40
-18
lines changed

Ed25519/writePrivateEd25519.pem

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
-----BEGIN PRIVATE KEY-----
2-
MFECAQEwBQYDK2VwBCIEIFFJdyp+KNOXOy4YpwmkwVcLQqOPIfo8ucpnsSgMFpq9
3-
gSEAKwKITw7sUNeQzOve0O3YNrg2+R9wb5U6ZwgXXfW1Vrc=
2+
MFECAQEwBQYDK2VwBCIEIEFrP6T+gyR+W/UrzugVpUuZOPplv964wILr7+wpW3Q5
3+
gSEACzgT7uBp8rSMpQHNeMZs5+82ZdkM5Gt70fzWyWmuV5M=
44
-----END PRIVATE KEY-----

Ed25519/writePublicEd25519.pem

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
-----BEGIN PUBLIC KEY-----
2-
MCowBQYDK2VwAyEAKwKITw7sUNeQzOve0O3YNrg2+R9wb5U6ZwgXXfW1Vrc=
2+
MCowBQYDK2VwAyEACzgT7uBp8rSMpQHNeMZs5+82ZdkM5Gt70fzWyWmuV5M=
33
-----END PUBLIC KEY-----
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-----BEGIN EC PRIVATE KEY-----
2-
MHQCAQEEIJlCzfYUDUcEo2whNxJAGCdErYS83/uAkH7SqUgrXc+uoAcGBSuBBAAK
3-
oUQDQgAE9QQlZbUwtjLOM5KY54bVU7ulC1GINK7nhPVgpQQik5njyB/KVNhL568X
4-
D3aEQEoGukMocfkye2OrukG7CseNIQ==
2+
MHQCAQEEIFjtyNeZaEaxjwyALiNLeZZkHdZD21M962A0wLtyC0xFoAcGBSuBBAAK
3+
oUQDQgAE+5cxHhGK+CWGFzEWE2DVzPYVZJnFT4V7s8gRYT3H86Xl/GjS0148Z540
4+
N6KV5QqhdwOY4gw98gs0APNx0MEnHg==
55
-----END EC PRIVATE KEY-----

Secp256k1/writePublicSecp256k1.pem

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
-----BEGIN PUBLIC KEY-----
2-
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE9QQlZbUwtjLOM5KY54bVU7ulC1GINK7n
3-
hPVgpQQik5njyB/KVNhL568XD3aEQEoGukMocfkye2OrukG7CseNIQ==
2+
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE+5cxHhGK+CWGFzEWE2DVzPYVZJnFT4V7
3+
s8gRYT3H86Xl/GjS0148Z540N6KV5QqhdwOY4gw98gs0APNx0MEnHg==
44
-----END PUBLIC KEY-----

src/main/kotlin/com/casper/sdk/putdeploy/ExecutableDeployItemHelper.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package com.casper.sdk.putdeploy
33
import com.casper.sdk.ConstValues
44
import com.casper.sdk.clvalue.CLValue
55
import com.casper.sdk.getdeploy.ExecutableDeployItem.*
6-
6+
// This class does the work of turning an ExecutableDeployItem object to Json String, used for account_put_deploy RPC call
77
class ExecutableDeployItemHelper {
8+
// This function does the work of turning an ExecutableDeployItem object to Json String, used for account_put_deploy RPC call
89
companion object {
910
fun toJsonString(executableDeployItem: ExecutableDeployItem) : String {
1011
if (executableDeployItem.itsType == ExecutableDeployItem.MODULE_BYTES) {
@@ -58,6 +59,7 @@ class ExecutableDeployItemHelper {
5859
}
5960
return ConstValues.INVALID_VALUE
6061
}
62+
// This function does the work of turning an RuntimeArgs object to Json String, used for ExecutableDeployItemHelper.toJsonString function
6163
fun argsToJsonString(args: RuntimeArgs) :String{
6264
var ret = ""
6365
val totalArgs:Int = args.listNamedArg.size - 1

src/main/kotlin/com/casper/sdk/putdeploy/PutDeployRPC.kt

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,29 @@ import java.io.BufferedReader
1212
import java.io.InputStreamReader
1313
import java.net.HttpURLConnection
1414
import java.net.URL
15+
// This class handles account_put_deploy RPC call
1516
class PutDeployRPC {
1617
companion object {
1718
var methodURL: String = ConstValues.TESTNET_URL
1819
var putDeployCounter:Int = 0
20+
/*
21+
This function does account_put_deploy RPC call
22+
This function initiate the process of sending POST request with given parameter in JSON string format like this:
23+
{"id": 1,"method": "account_put_deploy","jsonrpc": "2.0","params":
24+
[{"header": {"account": "0152a685e0edd9060da4a0d52e500d65e21789df3cbfcb878c91ffeaea756d1c53",
25+
"timestamp": "2022-06-28T11:35:19.349Z","ttl":"1h 30m","gas_price":1,
26+
"body_hash":"798a65dae48dbefb398ba2f0916fa5591950768b7a467ca609a9a631caf13001","dependencies": [],
27+
"chain_name": "casper-test"},
28+
"payment": {"ModuleBytes": {"module_bytes": "","args":
29+
[["amount",{"bytes": "0400ca9a3b","cl_type":"U512","parsed":"1000000000"}]]}},
30+
"session": {"Transfer": {"args": [["amount",{"bytes": "04005ed0b2","cl_type":"U512","parsed":"3000000000"}],
31+
["target",{"bytes": "015f12b5776c66d2782a4408d3910f64485dd4047448040955573aa026256cfa0a","cl_type":"PublicKey","parsed":"015f12b5776c66d2782a4408d3910f64485dd4047448040955573aa026256cfa0a"}],
32+
["id",{"bytes": "010000000000000000","cl_type":{"Option": "U64"},"parsed":0}],["spender",{"bytes": "01dde7472639058717a42e22d297d6cf3e07906bb57bc28efceac3677f8a3dc83b","cl_type":"Key","parsed":{"Hash":"hash-dde7472639058717a42e22d297d6cf3e07906bb57bc28efceac3677f8a3dc83b"}}]]}},
33+
"approvals": [{"signer": "0152a685e0edd9060da4a0d52e500d65e21789df3cbfcb878c91ffeaea756d1c53",
34+
"signature": "016596f09083d32eaffc50556f1a5d22202e8927d5aa3267639aff4b9d3412b5ae4a3475a5da6c1c1086a9a090b0e1090db5d7e1b7084bb60b2fee3ce9447a2a04"}],
35+
"hash": "65c6ccdc5aacc9dcd073ca79358bf0b5115061e8d561b3e6f461a34a6c5858f0"}]}
36+
Then the PutDeployResult is retrieved by parsing JsonObject result taken from the RPC POST request
37+
*/
1938
fun putDeploy(deploy: Deploy) :String {
2039
val deployHash:String = deploy.hash
2140
val jsonStr:String = fromDeployToJsonString(deploy)
@@ -38,7 +57,6 @@ class PutDeployRPC {
3857
response.append(responseLine!!.trim { it <= ' ' })
3958
}
4059
val json = response.toString().toJson()
41-
4260
if (json.get("error") != null) {
4361
val message = json.get("error").get("message")
4462
if (message == "invalid deploy: the approval at index 0 is invalid: asymmetric key error: failed to verify secp256k1 signature: signature error") {
@@ -58,14 +76,16 @@ class PutDeployRPC {
5876
}
5977
} else {
6078
val putDeployResult: PutDeployResult =
61-
PutDeployResult.fromJsonObjectToGetAuctionInfoResult(json.get("result") as JsonObject)
79+
PutDeployResult.fromJsonObjectToPutDeployResult(json.get("result") as JsonObject)
6280
println("Put deploy successfull with deploy hash:" + putDeployResult.deployHash)
6381
putDeployCounter = 0
6482
return putDeployResult.deployHash
6583
}
6684
return deployHash
6785
}
6886
}
87+
//This function does the work of turing a deploy object to a Json string, used as parameter to send for
88+
//POST method of the account_put_deploy RPC call.
6989
fun fromDeployToJsonString(deploy: Deploy):String {
7090
val headerString:String = "\"header\": {\"account\": \"" + deploy.header.account + "\",\"timestamp\": \"" + deploy.header.timeStamp + "\",\"ttl\":\""+deploy.header.ttl+"\",\"gas_price\":"+deploy.header.gasPrice+",\"body_hash\":\"" + deploy.header.bodyHash + "\",\"dependencies\": [],\"chain_name\": \"" + deploy.header.chainName + "\"}"
7191
val paymentJsonStr:String = "\"payment\": " + ExecutableDeployItemHelper.toJsonString(deploy.payment)

src/main/kotlin/com/casper/sdk/putdeploy/PutDeployResult.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.casper.sdk.putdeploy
22
import net.jemzart.jsonkraken.values.JsonObject
3-
3+
//This class hold the information of the account_put_deploy RPC calling method, which includes 2 attributes: api_version and deploy_hash
44
class PutDeployResult {
55
var apiVersion: String = ""
66
var deployHash:String = ""
77
companion object {
8-
/** This function parse the JsonObject (taken from server RPC method call) to GetAuctionInfoResult object */
9-
fun fromJsonObjectToGetAuctionInfoResult(from: JsonObject): PutDeployResult {
8+
/** This function parse the JsonObject (taken from server RPC method call) to PutDeployResult object */
9+
fun fromJsonObjectToPutDeployResult(from: JsonObject): PutDeployResult {
1010
val ret = PutDeployResult()
1111
ret.apiVersion = from["api_version"].toString()
1212
ret.deployHash = from["deploy_hash"].toString()

src/main/kotlin/com/casper/sdk/serialization/CLParseSerialization.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ Then the String.serialization("HeW,o") = "0500000072652c6f"
109109
/// Sample value and serialization:
110110
/// For URef
111111
/// "uref-be1dc0fd639a3255c1e3e5e2aa699df66171e40fa9450688c5d718b470e057c6-007" will has the serialization with value
112-
/// "be1dc0fd639a3255c1e3e5e2aa699df66171e40fa9450688c5d718b470e057c607"
112+
/// "02be1dc0fd639a3255c1e3e5e2aa699df66171e40fa9450688c5d718b470e057c607"
113113
/// For Account
114114
/// "account-hash-d0bc9cA1353597c4004B8F881b397a89c1779004F5E547e04b57c2e7967c6269" will has the serialization with value
115-
/// "d0bc9cA1353597c4004B8F881b397a89c1779004F5E547e04b57c2e7967c6269"
115+
/// "00d0bc9cA1353597c4004B8F881b397a89c1779004F5E547e04b57c2e7967c6269"
116116
/// For Hash
117117
/// "hash-8cf5e4acf51f54eb59291599187838dc3bc234089c46fc6ca8ad17e762ae4401" will has the serialization with value
118-
/// "8cf5e4acf51f54eb59291599187838dc3bc234089c46fc6ca8ad17e762ae4401"
118+
/// "018cf5e4acf51f54eb59291599187838dc3bc234089c46fc6ca8ad17e762ae4401"
119119
fun serializeFromCLParseKey(clParse: CLParsed) : String {
120120
val keyStr : String = clParse.itsValueInStr
121121
if(keyStr.contains("account-hash-")) {
@@ -133,7 +133,7 @@ Then the String.serialization("HeW,o") = "0500000072652c6f"
133133
}
134134
/// This function serialize CLValue of type URef
135135
/// Sample serialization for value : uref-be1dc0fd639a3255c1e3e5e2aa699df66171e40fa9450688c5d718b470e057c6-007
136-
/// Return result will be be1dc0fd639a3255c1e3e5e2aa699df66171e40fa9450688c5d718b470e057c607
136+
/// Return result will be 02be1dc0fd639a3255c1e3e5e2aa699df66171e40fa9450688c5d718b470e057c607
137137
fun serializeFromCLParseURef(clParse: CLParsed): String {
138138
val keyStr : String = clParse.itsValueInStr
139139
if (keyStr.contains("uref-")) {

0 commit comments

Comments
 (0)