iOS/macOS Cross-platform Ark-Ecosystem Framework in Swift | Powered by Ѧrk.io |

Overview

ARKKit

a macOS & iOS Swift Framework for Ark.io.

ARKKit Version BUILD License: MIT

Swift Version Platform Platform Xcode Version

Platform Platform Platform

What is ARKKit?

ARKKit is wrapper for interacting with the Ark Ecosystem.
It is written purely in Swift 4.0, using no external dependencies or libraries.
This allows for a quick, easy, and dependecy-free integration into your Computer, Server, or iDevice project!

Articles

Todo:

  • Implement URLSession
  • Signature/Cryptographic Integration
  • Transaction Creation & Signing
  • Voting
  • Delegate Registration
  • Restructure API
  • Your suggestions!

Usage

samples:

Check an account on mainnet or devnet:

  let devAccount = ARK.dev.account(from: "DHQ4Fjsyiop3qBR4otAjAu6cBHkgRELqGA")  
  let mainAccount = ARK.main.account(from: "AZreeHxX23s4jttL3ML8n6A2aLrwHPfVGZ")  

returning:

Account(username: nil,
        address: DHQ4Fjsyiop3qBR4otAjAu6cBHkgRELqGA,
        balance: 1901565824885,
        unconfirmedBalance: 1901565824885,
        publicKey: 0275776018638e5c40f1b922901e96cac2caa734585ef302b4a2801ee9a338a456,
        unconfirmedSignature: nil,
        secondSignature: nil,
        secondPublicKey: Optional("03ad2a481719c80571061f0c941d57e91c928700d8dd132726edfc0bf9c4cb2869"),
        multisignatures: Optional([]), unconfirmedMultisignatures: Optional([])) 

See all of the blocks on mainnet or devnet:

  let allDevBlocks = ARK.dev.allBlocks()  
  let allMainBlocks = ARK.main.allBlocks()  

returning:

allBlocks = [
    Block(id: 711675773079271579,
          version: 0, timestamp: 13737984,
          height: 1015588,
          previousBlock: 11596800618568825334,
          numberOfTransactions: 0,
          totalAmount: 0,
          totalFee: 0,
          reward: 200000000,
          payloadLength: 0,
          payloadHash: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855,
          generatorPublicKey: 03bd4f16e39aaba5cba6a87b7498b08ce540f279be367e68ae96fb05dfabe203ad,
          generatorId: DBi2HdDY8TqMCD2aFLVomEF92gzeDmEHmR,
          blockSignature: 3045022100a9e3381e506daa6f050f2ebdb0de584a3f7f9a7b7caba03ff2874d086e8911250220146719ba882ebd9847857a8b681b932616f1544008cc0a02e48613fd75df256d,
          confirmations: 1,
          totalForged: 200000000),
    Block(id: 11596800618568825334,
          version: 0,
          timestamp: 13737976,
          height: 1015587,
          previousBlock: 16455111908480150750,
          numberOfTransactions: 0,
          totalAmount: 0,
          totalFee: 0,
          reward: 200000000,
          payloadLength: 0,
          payloadHash: ............

or check the current block-height of a given network:

  let currentBlockHeight = Block.height(on: .dev)   /* returned "1015611" */

Cross-convert price values between standard(human-readable), and ѦRK:

  let standardPrice = Price.arkAmount(550000000).toStandard   /* returns "5.5" */
  let arkPrice = Price.amount(5.5).toArk  /* returns "550000000" */

Check the status of a Node/Peer:

  let statusOfPeer = ARK.dev.statusOfPeerWith(ip: "35.188.148.247")  

returns:

  statusOfIP = Peer(ip: 35.188.148.247,
                    port: 4002,
                    version: 1.1.0,
                    os: linux4.10.0-32-generic,
                    height: 1015589,
                    status: OK,
                    delay: 263) 

Check for network Peers/Seeds:

  let allNetworkSeeds = ARK.dev.allSeeds()  

returning:

 peers = [
      "167.114.29.51",
      "167.114.29.52",
      "167.114.29.53",
      "35.188.148.247",
      .................
      ] 

Get all of the transaction on a given network:

  let allTransactions = ARK.dev.allTransactions()  

returning:

allTransactions = [
    Transaction(id: e40ce11cab82736da1cc91191716f3c1f446ca7b6a9f4f93b7120ef105ba06e8,
                blockID: 13149578060728881902,
                type: 0,
                timestamp: 0,
                amount: 12500000000000000,
                fee: 0,
                senderID: DUFeXjJmYt1mWY3auywA1EQSqfCv5kYYfP,
                recipientID: DGihocTkwDygiFvmg6aG8jThYTic47GzU9,
                senderPublicKey: Optional("03cb7bca143376721d0e9e3f3ccb0dc2e7e8470c06e630c3cef73f03e309b558ad"),
                signature: 3044022016ecdf3039e69514c7d75861b22fc076496b61c07a1fcf793dc4f5c76fa0532b0220579c4c0c9d13720f9db5d9df29ed8ceab0adc266c6c160d612d4894dc5867eb1,
                asset: Optional(ARKKit_macOSTests.TransactionAsset.Delegate(username: nil, publicKey: nil)),
                vendorField: nil,
                confirmations: 1015646),
    Transaction(id: eb0146ac79afc228f0474a5ae1c4771970ae7880450b998c401029f522cd8a21,]
                blockID: 13149578060728881902,
                type: 2,
                timestamp: 0,
                amount: 0,
                fee: 0,
                senderID: DNL81CT6WNG1PHjobBmLvKwLV3UUscBymB,
                recipientID: nil,
                senderPublicKey: Optional("03e5b39a83e6c7c952c5908089d4524bb8dda93acc2b2b953247e43dc4fe9aa3d1"),
                signature: 3045022100e3e38811778023e6f17fefd447f179d45ab92c398c7cfb1e34e2f6e1b167c95a022070c36439ecec0fc3c43850070f29515910435d389e059579878d61b5ff2ea337,
                asset: Optional(ARKKit_macOSTests.TransactionAsset.Delegate(username: genesis_1,
                                                                            publicKey: 03e5b39a83e6c7c952c5908089d4524bb8dda93acc2b2b953247e43dc4fe9aa3d1)),
                vendorField: nil,
                confirmations: 1015646),
    .......................
    ]

or get the total number of transactions on a given network:

  let totalTransactions = ARK.main.totalNumberOfTransactions()  /* returned "137761" */

Recommended Resources

More Ѧrk Developer-Language Integrations:

Tip Jar

ѦRK [Ѧ]: AZreeHxX23s4jttL3ML8n6A2aLrwHPfVGZ

DѦRK [DѦ]: DHQ4Fjsyiop3qBR4otAjAu6cBHkgRELqGA

You might also like...
ObjectiveFlickr, a Flickr API framework for Objective-C

ObjectiveFlickr ObjectiveFlickr is a Flickr API framework designed for Mac and iPhone apps. OAuth Support ObjectiveFlickr now supports Flickr's new OA

Unofficial Dribbble iOS wrapper allows you to integrate Dribble API into iOS application (Designer, Shot, Comment, User Story, Like, Follow)

DribbbleSDK DribbbleSDK is easy-to-use iOS wrapper for Dribbble SDK. We're working hard to complete the full coverage of available methods and make th

A Swift wrapper for Foursquare API. iOS and OSX.

Das Quadrat Das Quadrat is Foursquare API wrapper written in Swift. Features Supports iOS and OSX. Covers all API endpoints. Authorization process imp

Twitter Clone for iOS With Swift
Twitter Clone for iOS With Swift

Postwitter Date: December 1, 2021 Product Name: Postwitter Problem Statement: iO

Wanikani-swift - Unofficial Swift client for the WaniKani API

WaniKani A Swift library and client for the WaniKani REST API. It currently supp

Giphy API client for iOS in Objective-C

Giphy-iOS Giphy-iOS is a Giphy API client for iOS in Objective-C. Usage To run the example project, clone the repo, and run pod install from the Examp

The unofficial Instagram iOS SDK

InstagramKit An extensive Objective C wrapper for the Instagram API, completely compatible with Swift. Here's a quick example to retrieve trending med

The Easiest and Simplest iOS library for Twitter and Facebook. Just Drop in and Use!
The Easiest and Simplest iOS library for Twitter and Facebook. Just Drop in and Use!

EasySocial iOS Library for Twitter and Facebook This library allows your apps to use Twitter and Facebook with minimal understanding of the relevant S

Easy Proximity-based Bluetooth LE Sharing for iOS

Description Easy Proximity-based Sharing for iOS Perfect for any iOS app that needs to quickly share items with nearby friends, such as groups, photo

Comments
  • Improvements/feedback

    Improvements/feedback

    I have spent some time working with this framework in attempt to use it in the monitoring app. In the end, there were several issues preventing me from using this framework for a production ready app.This lead meyme to write my own framework SwiftyArk. I wanted to share with you some of the feedback I have.

    1. The main issue I had with the app is the networking architecture. You are making asynchronous network calls to the ark node, but the method signatures are synchronous:
    let allMainBlocks = ARK.main.allBlocks() 
    

    is a synchronous assignment with no error handling. However, behind the scenes this is an asynchronous call that has the potential for many errors, which are never handled. It is not documentation that this assignment will fail, or result in an empty array. The swift way to do this is with a completion handler and error handling:

    ARK.main.allBlock() { (error, blocks) in
            if let aError = error {
                  /// handle error
            }
            if let allBlocks = blocks {
                 // all blocks are returned here and unwrapped
            }
     }
    

    The difference between the two (besides error handling) is the second option returns data in an asynchronous manner. In your API, the assignment occurs on the main thread and will block the entire app until it returns or errrors out.

    1. The networking of this app boils down to using NSString.(contentsOf:URL:) to grab raw data and convert it to a UTF8 string. This api wasn't designed for being used for networking, but rather read files from inside your app. It is not documented anywhere the error handling and doesn't give you any access to HTTP data (headers, statusCodes etc). You should look into using URLSession as it is the primary function for networking in iOS/mac apps. This will also allow you to extend your API to allow for PUT and POST operations, something NSString.(contentsOf:URL:)

    2. Your data types are not very swift like. You declare your internal properties as variables, rather than constants. There is nothing in the API to suggest the types should be modified, so why not make them immutable?

    3. More on the data types, the initialization of them is very un-swift like and leads to several issues. Data types like Account do not have any initializers, but rather assignments in an protocol (which I will get to). This is not very safe as these are declared as ** non-optional options**:

    public struct Account: Accountable {
        public var  address: String!
        /// ...
    

    You are basically saying "I guarantee there will be an address for an Account, but you do not provide (or prevent) any initialization, so its not safe:

    let account = Account()
    let example = account.balance * 10
    // CRASH!
    

    I would recommend you get rid of the assignment inside of a protocol and move it directly to an initializer, make the types immutable constants/optionals and prevent any unintentional initialization. Swift 4 introduced the Decodable protocol to direct add an initializer from json. Using it in conjunction with URLSession is a winning combo.

    1. This last one is more of a style comment, but I have noticed you use Swift types in a non-typical way. Your primary API manager is an enum when it should be a class/struct. You also create protocols for each data type (Accountable, Delegable etc) when they essentially do the same thing for each data type. You could create one data protocol that would apply to all datatypes which can be decoded from son (like Decodable)

    I hope this helps you. I want this framework to be great. You are doing a lot of great things for the community and I would very much like to see all the features you hope to implement. If you want some inspiration, you can check out SwiftyArk or if you need any advice: [email protected]

    Andrew

    opened by Awalz 1
Owner
Simon
Tinkerer, maker, breaker of things.
Simon
This repository is for the new ARGear SDK library for the iOS platform

This repository is for the new ARGear SDK library for the iOS platform. The library is not official yet. The library will be updated frequently by applying user feedback. When the APIs are fixed, the official library will be released.

ARGear 2 Apr 5, 2022
An Elegant Spotify Web API Library Written in Swift for iOS and macOS

Written in Swift 4.2 Spartan is a lightweight, elegant, and easy to use Spotify Web API wrapper library for iOS and macOS written in Swift 3. Under th

Dalton Hinterscher 109 Aug 26, 2022
The Waterwheel Swift SDK provides classes to natively connect iOS, macOS, tvOS, and watchOS applications to Drupal 7 and 8.

Waterwheel Swift SDK for Drupal Waterwheel makes using Drupal as a backend with iOS, macOS, tvOS, or watchOS enjoyable by combining the most used feat

Kyle Browning 414 Jul 26, 2022
Studio Ghibli Movie database in Swift. For iOS, iPadOS, and MacOS.

Ghibliii Studio Ghibli Movie database in Swift *Colours are shifted due to compression About This started as a way for me to do something in this quar

Kevin Laminto 16 Aug 9, 2022
A Twitter framework for iOS & OS X written in Swift

Getting Started Installation If you're using Xcode 6 and above, Swifter can be installed by simply dragging the Swifter Xcode project into your own pr

Matt Donnelly 2.4k Sep 9, 2022
Easy and powerful way to interact with VK API for iOS and macOS

Easy and powerful way to interact with VK API for iOS and macOS. Key features ?? It's not ios-vk-sdk ?? ?? One library for iOS and mac OS ?? ?? Fully

null 260 Sep 1, 2022
👤 Framework to Generate Random Users - An Unofficial Swift SDK for randomuser.me

RandomUserSwift is an easy to use Swift framework that provides the ability to generate random users and their accompanying data for your Swift applic

Wilson Ding 95 Sep 9, 2022
A Slack API Client for the Perfect Server-Side Swift Framework

PerfectSlackAPIClient is an API Client to access the Slack API from your Perfect Server Side Swift application. It is build on top of PerfectAPIClient

Cap.雪ノ下八幡 2 Dec 1, 2019
A Jamf Classic communication framework written in Swift

JamfKit JamfKit is an iOS / macOS / tvOS framework to communicate with the JSS API offered by any Jamf host. Summary Features Installation Carthage Co

Damien R. 40 Mar 31, 2022
Swift 3 framework for accessing data in Event Registry (http://eventregistry.org/)

PPEventRegistryAPI Swift 3 framework for accessing data in Event Registry (http://eventregistry.org/) Supported API calls Log In Get Event By Identifi

Pavel Pantus 8 Nov 1, 2016