Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/docs-and-deploy.yml
#	Package.swift
#	README.md
#	Sources/KukaiCoreSwift/Models/BakingBad/BetterCallDevTokenMetadata.swift
#	Sources/KukaiCoreSwift/Models/Token.swift
  • Loading branch information
simonmcl committed Sep 21, 2023
2 parents 45e64cc + 3beeffe commit 1d45740
Show file tree
Hide file tree
Showing 254 changed files with 37,262 additions and 7,162 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
module-name: KukaiCoreSwift
format: "html"
output: "Documentation"
base-url: "https://kukai-core-swift.kukai.app"
base-url: "https://kukai-core-swift.kukai.app/"
- name: Update Permissions
run: 'sudo chown --recursive $USER Documentation'
- name: Deploy to GitHub Pages
Expand Down
23 changes: 19 additions & 4 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,30 @@ on:
# Checkout the code, and run mxcl's xcodebuild action to run the unit tests
jobs:
build:
runs-on: macOS-latest
runs-on: macos-12
strategy:
matrix:
platform:
- iOS
xcode:
- ^14
steps:
- uses: actions/checkout@v2.3.4
- uses: mxcl/xcodebuild@v1
- uses: actions/checkout@v3.1.0

- uses: mxcl/xcodebuild@v1.11.0
with:
platform: ${{ matrix.platform }}
xcode: ${{ matrix.xcode }}
action: test
code-coverage: true
scheme: KukaiCoreSwift
code-coverage: true
upload-logs: always

#- name: Test
# run: xcodebuild -scheme KukaiCoreSwift test -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 12' -enableCodeCoverage YES -resultBundlePath "../../xcode-$GITHUB_RUN_ID.xcresult"
#
#- name: Upload results
# uses: actions/upload-artifact@v2
# with:
# name: "results-$GITHUB_RUN_ID.xcresult"
# path: "/Users/runner/work/xcode-$GITHUB_RUN_ID.xcresult"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Package.resolved

# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
.swiftpm
#.swiftpm

.build/

Expand Down
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

130 changes: 130 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/KukaiCoreSwift.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "KukaiCoreSwift_KukaiCoreSwift"
BuildableName = "KukaiCoreSwift_KukaiCoreSwift"
BlueprintName = "KukaiCoreSwift_KukaiCoreSwift"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "KukaiCoreSwift_KukaiCoreSwiftTests"
BuildableName = "KukaiCoreSwift_KukaiCoreSwiftTests"
BlueprintName = "KukaiCoreSwift_KukaiCoreSwiftTests"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "KukaiCoreSwift"
BuildableName = "KukaiCoreSwift"
BlueprintName = "KukaiCoreSwift"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "KukaiCoreSwiftTests"
BuildableName = "KukaiCoreSwiftTests"
BlueprintName = "KukaiCoreSwiftTests"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES"
onlyGenerateCoverageForSpecifiedTargets = "YES">
<CodeCoverageTargets>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "KukaiCoreSwift"
BuildableName = "KukaiCoreSwift"
BlueprintName = "KukaiCoreSwift"
ReferencedContainer = "container:">
</BuildableReference>
</CodeCoverageTargets>
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "KukaiCoreSwiftTests"
BuildableName = "KukaiCoreSwiftTests"
BlueprintName = "KukaiCoreSwiftTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "KukaiCoreSwift_KukaiCoreSwift"
BuildableName = "KukaiCoreSwift_KukaiCoreSwift"
BlueprintName = "KukaiCoreSwift_KukaiCoreSwift"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
55 changes: 31 additions & 24 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,47 @@
import PackageDescription

let package = Package(
name: "KukaiCoreSwift",
platforms: [.iOS(.v14)],
products: [
.library(name: "KukaiCoreSwift", targets: ["KukaiCoreSwift"]),
],
dependencies: [
.package(url: "https://github.com/attaswift/BigInt.git", from: "5.2.1"),
.package(name: "Sodium", url: "https://github.com/jedisct1/swift-sodium.git", from: "0.9.1"),
.package(name: "secp256k1", url: "https://github.com/Boilertalk/secp256k1.swift.git", from: "0.1.4"),
.package(url: "https://github.com/onevcat/Kingfisher.git", from: "6.3.0"),
.package(name: "WalletCore", url: "https://github.com/hewigovens/wallet-core-spm", .revisionItem("f32880f28b2de1d500b86db6f4bd1fb6329e546b")),
],
targets: [
.target(
name: "KukaiCoreSwift",
platforms: [
.iOS("15.0"),
],
products: [
.library(name: "KukaiCoreSwift", targets: ["KukaiCoreSwift"]),
],
dependencies: [
.package(name: "KukaiCryptoSwift", url: "https://github.com/kukai-wallet/kukai-crypto-swift", from: "1.0.10"),
//.package(url: "https://github.com/onevcat/Kingfisher.git", from: "7.6.2"),
.package(url: "https://github.com/simonmcl/Kingfisher.git", from: "1.0.0"),
.package(name: "CustomAuth", url: "https://github.com/torusresearch/customauth-swift-sdk", from: "6.0.0"),
.package(url: "https://github.com/simonmcl/SVGKit", from: "3.0.3"),
.package(name: "SignalRClient", url: "https://github.com/moozzyk/SignalR-Client-Swift", from: "0.8.0"),
],
targets: [
.target(
name: "KukaiCoreSwift",
dependencies: [
"BigInt",
"Sodium",
.product(name: "Clibsodium", package: "Sodium"),
"secp256k1",
"KukaiCryptoSwift",
"Kingfisher",
"WalletCore",
"SVGKit",
"CustomAuth",
"SignalRClient",
],
resources: [
.copy("Services/External")
.copy("Services/kukai-dex-calculations.js"),
.copy("Services/ledger_app_tezos.js"),
.copy("Services/taquito_local_forging.js")
]
),

.testTarget(
.testTarget(
name: "KukaiCoreSwiftTests",
dependencies: ["KukaiCoreSwift"],
dependencies: [
"KukaiCoreSwift"
],
resources: [
.copy("Stubs")
.copy("Stubs"),
.copy("Services/MockData")
]
),
]
]
)
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,28 @@
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/kukai-wallet/kukai-core-swift/blob/main/LICENSE)


Kukai Core Swift is a native Swift library for interacting with the Tezos blockchain and other applications in the Tezos ecosystem, such as the indexer [TzKT](https://tzkt.io) and the smart contract explorer [Better Call Dev](https://better-call.dev/). It leverages [WalletCore](https://github.com/trustwallet/wallet-core) the open source library built by [TrustWallet](https://trustwallet.com/), for key and wallet creation.
Kukai Core Swift is a native Swift library for interacting with the Tezos blockchain and other applications in the Tezos ecosystem, such as the Tezos Node RPC, the indexer [TzKT](https://tzkt.io), the smart contract explorer [Better Call Dev](https://better-call.dev/), the API from the NFT marketplace [OBJKT.com](https://objkt.com) etc.

The purpose of this SDK is not to provide a complete feature set for every aspect of Tezos, instead it is the base building block for the Kukai iOS mobile app, that we open source and make avaialble for anyone looking for similar functionality. We are open to accepting PR's and discussing changes/features. However if its not related to the kuaki mobile app, such work is likely better suited in a standalone package, with this as a dependency.

<br/>

Feature set includes:

- Create Linear or HD Wallets
- Create Regular and HD wallets
- A service to cache and retrieve encrypted wallet details from disk, using the secure enclave
- Fetching a wallet's XTZ balance, all FA token balances, owned NFT's grouped together by type, all in a single function call
- Fetching and caching token metadata
- Fetching transaction history
- Fetching transaction history, including token transfers
- Remote forging using a second node or Local forging via [@taquito/local-forging](https://github.com/ecadlabs/taquito/tree/master/packages/taquito-local-forging)
- Using a "vanilla" javascript version of the local-forging package specifically. These JS files can be found under the taquito github releases, under assets, named `taquito-local-forging-vanilla.zip`. e.g. [here](https://github.com/ecadlabs/taquito/releases/tag/17.2.0)
- Created using [this webpack config](https://github.com/simonmcl/taquito/tree/feature/mobile_friendly_webpack/packages/taquito-local-forging) as a starting point
- Estimating Gas, Storage and Fees for operations
- Parsing Michelson JSON into a Swift object using Codable
- Wait for an operation to be injected
- Fetch Tezos domains from addresses, and addresses from domains
- Media proxy tools for dealing with collectible and token images
- Helpers for dealing with Michelson JSON
- Helpers for parsing contents of Operations
- Helpers for parsing errors
- Dex fee + return calculation



Expand All @@ -28,13 +35,13 @@ Feature set includes:

# Install

Kukai Core Swift supports the Swift Package Manager. Either use the Xcode editor to add to your project by clicking `File` -> `Swift Packages` -> `Add Package Dependency`, search for the git repo `https://github.com/kukai-wallet/kukai-core-swift.git` and choose from version `0.1.0`.
Kukai Core Swift supports the Swift Package Manager. Either use the Xcode editor to add to your project by clicking `File` -> `Swift Packages` -> `Add Package Dependency`, search for the git repo `https://github.com/kukai-wallet/kukai-core-swift.git` and choose from version `x.x.x` (see tags for latest).

Or add it to your `Package.swift` dependencies like so:

```
dependencies: [
.package(url: "https://github.com/kukai-wallet/kukai-core-swift", from: "0.1.0")
.package(url: "https://github.com/kukai-wallet/kukai-core-swift", from: "x.x.x")
]
```

Expand All @@ -45,12 +52,12 @@ dependencies: [

# How to use

Wallets are created using dedicated classes for each type, conforming to the `Wallet` protocol.
Wallets are created using dedicated classes for each type, conforming to the `Wallet` protocol. Wallets are created using `Mnemonic` objects, see [Kukai Crypto Swift](https://github.com/kukai-wallet/kukai-crypto-swift) for more details on those

- [LinearWallet](https://kukai-core-swift.kukai.app/LinearWallet/)
- Created using a BIP 39 mnemonic and optional passphrase
- [RegularWallet](https://kukai-core-swift.kukai.app/RegularWallet/)
- Created using a `Mnemonic`, an optional passphrase, and optionally specify the `EllipticalCurve` you want (`ed25519` for TZ1..., `secp256k1` for TZ2...)
- [HDWallet](https://kukai-core-swift.kukai.app/HDWallet/)
- Created using a BIP 39 mnemonic, optional passphrase, and a BIP 44 derivation path
- Created using a `Mnemonic`, an optional passphrase, and an optional BIP 44 derivation path

<br/>

Expand All @@ -60,11 +67,8 @@ The main functionality centres around client classes and a factory:
- Query details about the node
- Estimate fees via the node RPC
- Send operations
- [BetterCallDevClient](https://kukai-core-swift.kukai.app/BetterCallDevClient/)
- Fetching balances
- Fetching metadata
- Detailed operation errors
- [TzKTClient](https://kukai-core-swift.kukai.app/TzKTClient/)
- Fetching balances
- Transaction history
- Determining if an operation has been successfully injected
- [OperationFactory](https://kukai-core-swift.kukai.app/OperationFactory/)
Expand All @@ -73,7 +77,7 @@ The main functionality centres around client classes and a factory:

<br/>

You can see some of this functionality inside the repo's example iOS-Example project. The app is a simple tableview, with the first section responsible for creating and caching wallets. The rest of the sections will load the cached wallet and use its details to fetch/display balances or estiamte/send operations.
For working example, see the kukai mobile ios app [here](https://github.com/kukai-wallet/kukai-mobile-ios)



Expand All @@ -82,4 +86,4 @@ You can see some of this functionality inside the repo's example iOS-Example pro

# Documentation

Compiled Swift Doc's can be found [here](https://kukai-core-swift.kukai.app)
Compiled Swift Doc's can be found [here](https://kukai-core-swift.kukai.app/)
Loading

0 comments on commit 1d45740

Please sign in to comment.