-
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(send): implement send_transaction, bindings
- Loading branch information
1 parent
cf7c229
commit b3e5c01
Showing
36 changed files
with
1,628 additions
and
321 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 |
---|---|---|
|
@@ -51,21 +51,21 @@ jobs: | |
- run: cargo install cargo-udeps | ||
- run: cargo +nightly udeps --workspace | ||
|
||
build_wasm: | ||
name: Build on WASM | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run sccache-cache | ||
uses: mozilla-actions/[email protected] | ||
- uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9 | ||
- run: rustup update stable && rustup default stable | ||
- run: rustup target add wasm32-unknown-unknown | ||
- run: git submodule update --init --recursive | ||
- run: make setup-thirdparty | ||
- run: cargo build --workspace --all-features --lib --bins --target wasm32-unknown-unknown --exclude=ffi | ||
# build_wasm: | ||
# name: Build on WASM | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v4 | ||
# - name: Run sccache-cache | ||
# uses: mozilla-actions/[email protected] | ||
# - uses: pnpm/action-setup@v4 | ||
# with: | ||
# version: 9 | ||
# - run: rustup update stable && rustup default stable | ||
# - run: rustup target add wasm32-unknown-unknown | ||
# - run: git submodule update --init --recursive | ||
# - run: make setup-thirdparty | ||
# - run: cargo build --workspace --all-features --lib --bins --target wasm32-unknown-unknown --exclude=ffi | ||
|
||
build_swift_and_test: | ||
name: Swift Package - latest | ||
|
@@ -89,5 +89,21 @@ jobs: | |
run: sudo xcode-select -s /Applications/Xcode_15.4.app | ||
- name: Build ${{ matrix.config }} | ||
run: make CONFIG=${{ matrix.config }} build-swift-apple-platforms | ||
- name: Install Docker | ||
run: | | ||
HOMEBREW_NO_AUTO_UPDATE=1 brew install --cask docker | ||
sudo /Applications/Docker.app/Contents/MacOS/Docker --unattended --install-privileged-components | ||
open -a /Applications/Docker.app --args --unattended --accept-license | ||
echo "We are waiting for Docker to be up and running. It can take over 2 minutes..." | ||
while ! /Applications/Docker.app/Contents/Resources/bin/docker info &>/dev/null; do sleep 1; done | ||
- name: Start test infrastructure | ||
run: docker compose up --debug | ||
working-directory: test/scripts/forked_state | ||
- name: Wait for local RPC to be ready | ||
run: while ! curl localhost:8545/health; do sleep 1; done | ||
- name: Wait for local bundler to be ready | ||
run: while ! curl localhost:4337/health; do sleep 1; done | ||
- name: Wait for local paymaster to be ready | ||
run: while ! curl localhost:3000/ping; do sleep 1; done | ||
- name: Run ${{ matrix.config }} tests | ||
run: make CONFIG=${{ matrix.config }} test-swift-apple-platforms |
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
31 changes: 31 additions & 0 deletions
31
crates/ffi/YttriumCore/Sources/YttriumCore/SwiftFFI/PrivateKeySignerFFI.swift
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,31 @@ | ||
import Foundation | ||
|
||
public final class PrivateKeySignerFFI { | ||
|
||
public let signerId: SignerId | ||
|
||
private let pK: String | ||
|
||
public init(signer_id: RustString) { | ||
let idString = signer_id.toString() | ||
let signerId = SignerId(rawValue: idString)! | ||
self.signerId = signerId | ||
self.pK = Signers.shared.signer(id: signerId)!.privateKeySigner!.privateKey | ||
} | ||
|
||
public func private_key() -> FFIStringResult { | ||
.Ok(pK.intoRustString()) | ||
} | ||
} | ||
|
||
public struct PrivateKeySigner: Identifiable { | ||
|
||
public let id: SignerId | ||
|
||
public let privateKey: String | ||
|
||
public init(id: SignerId, privateKey: String) { | ||
self.id = id | ||
self.privateKey = privateKey | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
crates/ffi/YttriumCore/Sources/YttriumCore/SwiftFFI/Signer.swift
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,69 @@ | ||
import Foundation | ||
|
||
public enum Signer { | ||
case native(NativeSigner) | ||
case privateKey(PrivateKeySigner) | ||
|
||
public var signerType: SignerType { | ||
switch self { | ||
case .native: | ||
return .native | ||
case .privateKey: | ||
return .privateKey | ||
} | ||
} | ||
|
||
public var signerId: SignerId { | ||
switch self { | ||
case .native(let native): | ||
return native.id | ||
case .privateKey(let privateKey): | ||
return privateKey.id | ||
} | ||
} | ||
|
||
public var privateKeySigner: PrivateKeySigner? { | ||
switch self { | ||
case .native: | ||
return nil | ||
case .privateKey(let privateKey): | ||
return privateKey | ||
} | ||
} | ||
|
||
public var nativeSigner: NativeSigner? { | ||
switch self { | ||
case .native(let native): | ||
return native | ||
case .privateKey: | ||
return nil | ||
} | ||
} | ||
} | ||
|
||
public enum SignerType: String, Codable { | ||
case native = "Native" | ||
case privateKey = "PrivateKey" | ||
|
||
public func toRustString() -> RustString { | ||
rawValue.intoRustString() | ||
} | ||
} | ||
|
||
public enum SignerError: Error { | ||
case unknown | ||
} | ||
|
||
extension String: Error {} | ||
|
||
extension Result where Success == String, Failure == String { | ||
|
||
public var ffi: FFIStringResult { | ||
switch self { | ||
case .success(let value): | ||
return .Ok(value.intoRustString()) | ||
case .failure(let error): | ||
return .Err(error.localizedDescription.intoRustString()) | ||
} | ||
} | ||
} |
Oops, something went wrong.