nerzh/everscale-client-swift
--->
Get api keys and TVM endpoints:
You need to get an API-KEY here https://dashboard.evercloud.dev
Usage
All requests are async
import EverscaleClientSwift
var config: TSDKClientConfig = .init()
config.network = TSDKNetworkConfig(endpoints: ["https://net.ton.dev"])
let client: TSDKClientModule = .init(config: config)
// Crypto
client.crypto.factorize(TSDKParamsOfFactorize(composite: "17ED48941A08F981")) { (response) in
print(response.result?.factors)
}
// Boc
let payload: TSDKParamsOfParse = .init(boc: "te6ccgEBAQEAWAAAq2n+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAE/zMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzSsG8DgAAAAAjuOu9NAL7BxYpA")
client.boc.parse_message(payload) { (response) in
if let result = response.result, let parsed: [String: Any] = result.parsed.toDictionary() {
print(parsed["id"])
print(parsed["src"])
print(parsed["dst"])
}
}Errors
client.crypto.factorize(TSDKParamsOfFactorize(composite: "17ED48941A08F981")) { (response) in
if let error = response.error {
print(error.data.toJSON())
print(error.code)
}
}Native ever-sdk dependency
On Apple platforms the installer creates a local binary target:
Sources/CTonSDKBinary/CTonSDK.xcframeworkThe repository includes a small placeholder XCFramework at that path so SwiftPM can resolve the package without unsafe build flags. Run the installer to replace it with the real native library.
On Linux the installer builds libever_client.a into a user-writable SDK directory. By default this is:
~/.cache/everscale-client-swift/ever-sdk/prebuilt/<platform>/libever_client.aSet EVER_SDK_DIR to override that SDK directory. The installer also installs ctonsdk.pc into a system pkg-config directory, pointing to the built library and generated SDK header directory. By default it uses a directory from pkg-config --variable pc_path pkg-config, preferring /usr/local/lib/pkgconfig; set CTONSDK_PKG_CONFIG_DIR to override it. If the directory is not writable, the installer uses sudo.
Install or update the native dependency manually from the package checkout:
ruby install_EverSdk.rbOn macOS the default command builds macOS, iOS device, and iOS simulator libraries, then packages them into CTonSDK.xcframework. On Linux it builds the current Linux host architecture.
Useful variants:
ruby install_EverSdk.rb --platform current
ruby install_EverSdk.rb --platform linux
ruby install_EverSdk.rb --platform ios
ruby install_EverSdk.rb --platform ios-simulator
ruby install_EverSdk.rb --platform macos
ruby install_EverSdk.rb --ref master
ruby install_EverSdk.rb --skip-build --no-updateThe script clones https://github.com/everx-labs/ever-sdk into the SDK directory, installs missing Rust targets with rustup, builds with Cargo, copies the ready static libraries into the SDK directory's prebuilt folder, writes the SwiftPM XCFramework to Sources/CTonSDKBinary/CTonSDK.xcframework on Apple platforms, and installs ctonsdk.pc on Linux.
It also copies the matching ever_client/tonclient.h from the checked out ever-sdk into the SDK directory's prebuilt/include/CTonSDK/tonclient.h, so Swift sees the C API from the same SDK revision that was built without modifying package source headers.
Tests
If you use Xcode for Test
Please, set custom working directory to project folder for your xcode scheme. This is necessary for the relative path "./" to this library folders. You may change it with the xcode edit scheme menu Product > Scheme > Edit Scheme menu Run submenu Options enable checkbox "Use custom directory" and add custom working directory.
Or if above variant not available, then inside file path_to_this_library/.swiftpm/xcode/xcshareddata/xcschemes/TonClientSwift.xcscheme set to tag "LaunchAction" absolute path to this library with options: useCustomWorkingDirectory = "YES" customWorkingDirectory = "/path_to_this_library"
Tests
- inside root directory of everscale-client-swift create .env.debug file with
NET TON DEV
server_address=https://net.ton.dev
giver_address=0:653b9a6452c7a982c6dc92b2da9eba832ade1c467699ebb3b43dca6d77b780dd
giver_abi_name=Giver
giver_function=grantOptional: Install locale NodeSE for tests if you needed:
- launch docker
- docker run -d --name local-node -p 80:80 tonlabs/local-node
nodeSE will start on localhost:80
server_address=http://localhost:80
giver_abi_name=GiverNodeSE_v2
giver_amount=10000000000- Run Tests
MacOS: Run Tests inside Xcode Linux: swift test --generate-linuxmain swift test --enable-test-discovery
Update SDK
cd everscale-client-swiftbash api_generate.shPackage Metadata
Repository: nerzh/everscale-client-swift
Default branch: master
README: README.md