If you're building apps with Immutable, please use Immutable's Unified SDK
The ImmutableX Core SDK Swift provides convenient access to the Immutable API's for applications written on the ImmutableX platform.
See the developer guides for information on building on ImmutableX.
See the API reference documentation for more information on our API's.
- iOS 13.0 or macOS 10.15
- Swift 5.7
In your Package.swift
:
dependencies: [
.package(url: "https://github.com/immutable/imx-core-sdk-swift.git", from: "1.0.0-beta.2")
]
In your Podfile
:
platform :ios, '13.0'
use_frameworks!
target 'MyApp' do
pod 'ImmutableXCore'
end
The Core SDK must be initialised before any of its classes are used. Upon initialisation the base environment and log level may be defined. Once initialised a shared instace will be available for accessing the Workflow Functions.
For example, you initialise the SDK and retrieve a URL to buy crypto through Moonpay:
ImmutableX.initialize(base: .sandbox)
let url = try await ImmutableX.shared.buyCryptoURL(signer: signer)
Utility functions accessed via ImmutableX.shared
that will chain necessary API calls to complete a process or perform a transaction.
- Register a user with ImmutableX
- Buy cryptocurrency via Moonpay
- Buy ERC721
- Sell ERC721
- Cancel order
- Transfer ERC20/ERC721/ETH
The Core SDK includes classes that interact with the ImmutableX APIs.
e.g. Get a list of collections ordered by name in ascending order
let collections = try await CollectionsAPI.listCollections(
pageSize: 20,
orderBy: .name,
direction: "asc"
)
View the OpenAPI spec for a full list of API requests available in the Core SDK.
In order to use any workflow functions, you will need to pass in the connected wallet provider. This means you will need to implement your own Wallet L1 Signer and L2 StarkSigner.
Once you have a Signer
instance you can generate the user's Stark key pair and use the result to instantiate a StarkSigner
, for example, by using the default StandardStarkSigner
provided by the SDK.
let keyPair = try await StarkKey.generateKeyPair(from: signer)
let starkSigner = StandardStarkSigner(pair: keyPair)
Parts of the Core SDK are automagically generated.
We use OpenAPI (formally known as Swagger) to auto-generate the API clients that connect to the public APIs.
The OpenAPI spec is retrieved from https://api.x.immutable.com/openapi and also saved in the repo here.
Upon updating the openapi.json
file, ensure openapi-generator is installed, then run ./generateapi.sh
to regenerate the files. Any custom templates should be appropriately modified or removed as needed. These can be found in the .openapi-generator/templates
directory.
The following headings should be used as appropriate
- Added
- Changed
- Deprecated
- Removed
- Fixed
What follows is an example with all the change headings, for real world use only use headings when appropriate.
This goes at the top of the CHANGELOG.md
above the most recent release:
...
## [Unreleased]
### Added
for new features.
### Changed
for changes in existing functionality.
### Deprecated
for soon-to-be removed features.
### Removed
for now removed features.
### Fixed
for any bug fixes.
...
If you would like to contribute by reporting bugs, suggest enchacements or pull requests, please read our contributing guide.
ImmutableX is open to all to build on, with no approvals required. If you want to talk to us to learn more, or apply for developer grants, click below:
To get help from other developers, discuss ideas, and stay up-to-date on what's happening, become a part of our community on Discord.
You can also join the conversation, connect with other projects, and ask questions in our ImmutableX Discourse forum.
You can also apply for marketing support for your project. Or, if you need help with an issue related to what you're building with ImmutableX, click below to submit an issue. Select I have a question or issue related to building on ImmutableX as your issue type.
ImmutableX Core SDK Swift repository is distributed under the terms of the Apache License (Version 2.0).