Swiftpack.co - p2p-org/RenVMSwift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by p2p-org.
p2p-org/RenVMSwift 1.0.1
An implementation of RenVM written in pure Swift
⭐️ 0
🕓 18 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/p2p-org/RenVMSwift.git", from: "1.0.1")

RenSwift

CI Status Version License Platform

How to use

Sending

// define ChainProvider
class SolanaChainProvider: ChainProvider {
    func getAccount() async throws -> (publicKey: Data, secret: Data) {
        let account = // account in solana chain
        return (publicKey: account.publicKey.data, secret: account.secretKey)
    }
    
    func load() async throws -> RenVMChainType {
        try await SolanaChain.load(
            client: renRPCClient,
            apiClient: solanaAPIClient,
            blockchainClient: BlockchainClient(apiClient: solanaAPIClient)
        )
    }
}

// define persistentStore for re-release transaction in case of failure
class PersistentStore: BurnAndReleasePersistentStore {
    private var fileStore = SomeFileStore()
    
    func getNonReleasedTransactions() -> [BurnAndRelease.BurnDetails] {
        fileStore.getSavedTxs()
    }
    
    func persistNonReleasedTransactions(_ transaction: BurnAndRelease.BurnDetails) {
        fileStore.write(transaction)
    }
    
    func markAsReleased(_ transaction: BurnAndRelease.BurnDetails) {
        fileStore.removeAll(where: {$0.confirmedSignature == transaction.confirmedSignature})
    }
}

// create instance of service
let service = BurnAndReleaseServiceImpl(
    rpcClient: renRPCClient,
    chainProvider: SolanaChainProvider(),
    destinationChain: .bitcoin,
    persistentStore: PersistentStore(),
    version: "1"
)

// resume all failured transaction from last time
service.resume()

// burn and release
let tx = try await service.burnAndRelease(recipient: "tb1ql7w62elx9ucw4pj5lgw4l028hmuw80sndtntxt", amount: 0.0001.toLamport(decimals: 8)) // 0.0001 renBTC
print(tx)

Requirements

Installation

RenVMSwift is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'RenVMSwift', '~> 2.0.1'

Author

Chung Tran, bigearsenal@gmail.com

License

RenSwift is available under the MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 0
Last commit: Yesterday
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Dependencies

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics