Skip to content

Commit 31685be

Browse files
committed
Adjust some comments and code
1 parent df76c89 commit 31685be

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

src/main/kotlin/com/casper/sdk/CasperUtils.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ class CasperUtils {
108108
ret = milisecond.toULong()
109109
return ret
110110
}
111+
//This function change ttl (Time to live) to milisecond
112+
//The ttl is in format defined in this link
113+
//https:// docs.rs/humantime/latest/humantime/fn.parse_duration.html
111114
fun ttlToMilisecond(ttl:String) :ULong {
112115
var ret:ULong = 0u
113116
if(ttl.contains(" ")) {

src/main/kotlin/com/casper/sdk/getdeploy/Deploy.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,25 @@ class Deploy{
2626
}
2727
return ret
2828
}
29+
// This function counts the deploy hash based on the the Deploy header serialization
30+
// Just take the serialization of the deploy header, then use blake2b256 over the deploy header serialization.
2931
fun getDeployHash(deploy: Deploy) : String {
3032
val deployHeaderSerialization:String = DeploySerializeHelper.serializeForHeader(deploy.header)
3133
val deployHash:String = CasperUtils.getBlake2bFromStr(deployHeaderSerialization)
3234
return deployHash
3335
}
36+
// This function counts the deploy body hash based on the serialization of the deploy payment and session
37+
// The flow is:
38+
// 1. take the deploy payment serialization
39+
// 2. take the deploy session serialization
40+
// 3. make the concatenation of deploy payment serialization and deploy session serialization
41+
// 4. take the blake2b256 hash over the concatenation string.
3442
fun getBodyHash(deploy: Deploy): String {
3543
val paymentSerialization: String =
3644
ExecutableDeployItemSerializationHelper.serializeForExecutableDeployItem(deploy.payment)
3745
val sessionSerialization =
3846
ExecutableDeployItemSerializationHelper.serializeForExecutableDeployItem(deploy.session)
39-
val deployBodyHash: String = CasperUtils.getBlake2bFromStr(paymentSerialization + sessionSerialization)
47+
val deployBodyHash: String = CasperUtils.getBlake2bFromStr(paymentSerialization + sessionSerialization)
4048
return deployBodyHash
4149
}
4250
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ Then the String.serialization("HeW,o") = "0500000072652c6f"
288288
return "NONE_COMPOUND"
289289
}
290290
/** Serialize for CLParse in general
291-
The flow is quite simple:
291+
The flow is:
292292
If the CLParse is of type Primitive, such as Bool, U8, U32 ... - CLParse that does not contain recursive type inside it, then call function
293293
serializeFromCLParsePrimitive to get the CLParse serialization value.
294294
If the CLParse is of type Compound, such as List, Option, Map ... - CLParse that contains recursive type inside it, then call function

src/test/kotlin/com/casper/sdk/putdeploy/PutDeployRPCTest.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ internal class PutDeployRPCTest {
2525
val deployHashEd25519 = testPutDeploy(isEd25519 = true)
2626
//Positive path - put deploy for secp256k1 account
2727
//Use this account 0202d3de886567b1281eaa5687a85e14b4f2922e19b89a3f1014c7932f442c9d9635
28-
val deployHashSecp256k1 =testPutDeploy(isEd25519 = false)
28+
val deployHashSecp256k1 = testPutDeploy(isEd25519 = false)
2929
assert(deployHashEd25519.length > 0)
3030
assert(deployHashSecp256k1.length > 0)
31-
//println("Deploy hash ed25519 is: " + deployHashEd25519 + " deploy Hash secp256k1:" + deployHashSecp256k1)
3231
//Negative path 1 - put deploy with wrong deploy hash - for ed25519 account
3332
val deploy1 = setupDeploy(isEd25519=true)
3433
//Try to make a wrong deploy by give it a fake deploy hash
@@ -112,7 +111,7 @@ internal class PutDeployRPCTest {
112111
val session = ExecutableDeployItem()
113112
session.itsType = ExecutableDeployItem.TRANSFER
114113
val ediSession = ExecutableDeployItem_Transfer()
115-
//set up RuntimeArgs with 1 element of NamedArg only
114+
//set up RuntimeArgs with 4 elements of NamedArg
116115
//setup 1st NamedArgs
117116
val oneNASession1 = NamedArg()
118117
oneNASession1.itsName = "amount"
@@ -398,8 +397,8 @@ internal class PutDeployRPCTest {
398397
val session = ExecutableDeployItem()
399398
session.itsType = ExecutableDeployItem.TRANSFER
400399
val ediSession = ExecutableDeployItem_Transfer()
401-
//set up RuntimeArgs with 1 element of NamedArg only
402-
//setup 1st NamedArgs
400+
//set up RuntimeArgs with 4 elements of NamedArg only
401+
//setup 1st NamedArg
403402
val oneNASession1 = NamedArg()
404403
oneNASession1.itsName = "amount"
405404
val oneCLValueSession1 = CLValue()
@@ -413,7 +412,7 @@ internal class PutDeployRPCTest {
413412
oneCLValueSession1.itsParse = oneCLParseSession1
414413
oneNASession1.clValue = oneCLValueSession1
415414

416-
//setup 2nd NamedArgs
415+
//setup 2nd NamedArg
417416
val oneNASession2 = NamedArg()
418417
oneNASession2.itsName = "target"
419418
val oneCLValueSession2 = CLValue()

0 commit comments

Comments
 (0)