-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add non-encoded extrinsic to SendableExtrinsic * bump versions * Remove CallRepresentation from Extrinsic * Expose Extrinsic encoding without a length * Code style
- Loading branch information
Showing
9 changed files
with
108 additions
and
136 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
buildscript { | ||
ext { | ||
// App version | ||
versionName = '2.3.0' | ||
versionName = '2.4.0' | ||
versionCode = 1 | ||
|
||
// SDK and tools | ||
|
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
49 changes: 49 additions & 0 deletions
49
...main/java/io/novasama/substrate_sdk_android/runtime/extrinsic/signer/SendableExtrinsic.kt
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,8 +1,57 @@ | ||
package io.novasama.substrate_sdk_android.runtime.extrinsic.signer | ||
|
||
import io.novasama.substrate_sdk_android.runtime.RuntimeSnapshot | ||
import io.novasama.substrate_sdk_android.runtime.definitions.types.generics.Extrinsic | ||
import io.novasama.substrate_sdk_android.runtime.definitions.types.generics.toBytesWithoutLength | ||
import io.novasama.substrate_sdk_android.runtime.definitions.types.toHex | ||
import io.novasama.substrate_sdk_android.runtime.definitions.types.toHexUntyped | ||
|
||
interface SendableExtrinsic { | ||
|
||
val extrinsic: Extrinsic.Instance | ||
|
||
val signatureHex: String | ||
|
||
val extrinsicHex: String | ||
|
||
val bytesWithoutLength: ByteArray | ||
} | ||
|
||
fun SendableExtrinsic( | ||
runtime: RuntimeSnapshot, | ||
extrinsic: Extrinsic.Instance | ||
): SendableExtrinsic { | ||
return RealSendableExtrinsic(runtime, extrinsic) | ||
} | ||
|
||
private class RealSendableExtrinsic( | ||
private val runtime: RuntimeSnapshot, | ||
override val extrinsic: Extrinsic.Instance | ||
) : SendableExtrinsic { | ||
|
||
override val extrinsicHex by lazy { | ||
createExtrinsicHex() | ||
} | ||
|
||
override val bytesWithoutLength: ByteArray by lazy { | ||
Extrinsic.toBytesWithoutLength(runtime, extrinsic) | ||
} | ||
|
||
override val signatureHex by lazy { | ||
createSignatureHex() | ||
} | ||
|
||
private fun createExtrinsicHex(): String { | ||
return Extrinsic.toHex(runtime, extrinsic) | ||
} | ||
|
||
private fun createSignatureHex(): String { | ||
requireNotNull(extrinsic.signature) { | ||
"Extrinsic is unsigned" | ||
} | ||
|
||
val signatureType = Extrinsic.signatureType(runtime) | ||
|
||
return signatureType.toHexUntyped(runtime, extrinsic.signature.signature) | ||
} | ||
} |
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
Oops, something went wrong.