Skip to content

Commit

Permalink
Update project build settings (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcmz authored Jan 15, 2025
1 parent 7a4b8e5 commit e439967
Show file tree
Hide file tree
Showing 21 changed files with 39,675 additions and 43 deletions.
21 changes: 15 additions & 6 deletions flow/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@ kotlin {
}

val xcf = XCFramework()
ios {
iosX64 {
binaries {
framework {
baseName = "Flow"
xcf.add(this)
}
}
}

iosArm64 {
binaries {
framework {
baseName = "Flow"
Expand All @@ -39,7 +48,7 @@ kotlin {
val kotlincrypto = "0.5.3"

sourceSets {kotlin
val commonMain by getting {
commonMain {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion") {
version {
Expand All @@ -62,24 +71,24 @@ kotlin {
implementation("org.kotlincrypto.hash:sha3:$kotlincrypto")
}
}
val commonTest by getting {
commonTest {
dependencies {
implementation(kotlin("test"))
}
}
val androidMain by getting {
androidMain {
dependencies {
implementation("io.ktor:ktor-client-okhttp:$ktorVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutineVersion")
}
}
val iosMain by getting {
iosMain {
dependencies {
implementation("io.ktor:ktor-client-darwin:$ktorVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.8")
}
}
val iosTest by getting
iosTest
}
}

Expand Down
2 changes: 1 addition & 1 deletion flow/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="org.onflow.flow" />
<manifest />
5 changes: 3 additions & 2 deletions flow/src/commonTest/kotlin/org/onflow/flow/FlowApiTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ class FlowApiTests {
@Test
fun testRunScript() {
runBlocking {
val a = Cadence.string("Ryan")
val response = api.executeScript("""
access(all) fun main(name: String): String {
let greeting = "Hello, "
return greeting.concat(name)
}
""".trimIndent(), listOf(a))
""".trimIndent(),
listOf(Cadence.string("Ryan"))
)
println(format.encodeToString(response))
val result = response.decode<String>()
assertTrue(result == "Hello, Ryan")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class FlowMainnetApiTests {
}
}

@Ignore
@Test
fun testGetEvents() {
runBlocking {
Expand Down
68 changes: 34 additions & 34 deletions flow/src/commonTest/kotlin/org/onflow/flow/FlowTransactionTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,38 @@ class FlowTransactionTests {

private val api = FlowApi(ChainId.Testnet)

@Test
fun testSignTestnet() {
runBlocking {
val account = api.getAccount("0x328649a25184b171")
val key = account.keys!!.first()
val signer = object : Signer {
override var address: String = account.address
override var keyIndex: Int = key.index.toInt()
override suspend fun sign(transaction: Transaction, bytes: ByteArray): ByteArray {
return key.sign(bytes)
}
override suspend fun sign(bytes: ByteArray): ByteArray {
return key.sign(bytes)
}
}
val tx = Transaction(
script = """
access(all) transaction {
prepare(signer: AuthAccount) {
log(signer.address)
}
}
""".trimIndent(),
arguments = emptyList(),
referenceBlockId = null,
payerAddress = account.address,
authorizers = listOf(account.address),
payloadSignatures = emptyList()
)
val signedTx = tx.sign(signer)
val result = api.sendTransaction(signedTx)
println(result)
}
}
// @Test
// fun testSignTestnet() {
// runBlocking {
// val account = api.getAccount("0x328649a25184b171")
// val key = account.keys!!.first()
// val signer = object : Signer {
// override var address: String = account.address
// override var keyIndex: Int = key.index.toInt()
// override suspend fun sign(transaction: Transaction, bytes: ByteArray): ByteArray {
// return key.sign(bytes)
// }
// override suspend fun sign(bytes: ByteArray): ByteArray {
// return key.sign(bytes)
// }
// }
// val tx = Transaction(
// script = """
// access(all) transaction {
// prepare(signer: AuthAccount) {
// log(signer.address)
// }
// }
// """.trimIndent(),
// arguments = emptyList(),
// referenceBlockId = null,
// payerAddress = account.address,
// authorizers = listOf(account.address),
// payloadSignatures = emptyList()
// )
// val signedTx = tx.sign(signer)
// val result = api.sendTransaction(signedTx)
// println(result)
// }
// }
}
2 changes: 2 additions & 0 deletions flow/src/iosMain/kotlin/org.onflow.flow.models/NSData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import platform.Foundation.NSData
import platform.Foundation.create
import platform.posix.memcpy

@kotlinx.cinterop.ExperimentalForeignApi
internal inline fun ByteArray.toData(): NSData {
if (isEmpty()) return NSData()
val pinned = pin()
Expand All @@ -17,6 +18,7 @@ internal inline fun ByteArray.toData(): NSData {
)
}

@kotlinx.cinterop.ExperimentalForeignApi
internal fun NSData.toByteArray(): ByteArray {
val size = length.toInt()
val bytes = ByteArray(size)
Expand Down
47 changes: 47 additions & 0 deletions flow/swiftpackage/Flow.xcframework/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AvailableLibraries</key>
<array>
<dict>
<key>BinaryPath</key>
<string>Flow.framework/Flow</string>
<key>DebugSymbolsPath</key>
<string>dSYMs</string>
<key>LibraryIdentifier</key>
<string>ios-x86_64-simulator</string>
<key>LibraryPath</key>
<string>Flow.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>Flow.framework/Flow</string>
<key>DebugSymbolsPath</key>
<string>dSYMs</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>Flow.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>
<key>XCFrameworkFormatVersion</key>
<string>1.0</string>
</dict>
</plist>
Binary file not shown.
Loading

0 comments on commit e439967

Please sign in to comment.