1 Star 0 Fork 0

etos/wallet-connect-swift

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

WalletConnect

Codacy Badge CI

WalletConnect Swift SDK, implements 1.0.0 websocket based protocol.

Demo video

Requirements

  • iOS 11
  • Xcode 10.2
  • Swift 5

Features

  • Connect and disconnect
  • Approve / Reject / Kill session
  • Approve and reject eth_sign / personal_sign / eth_signTypedData
  • Approve and reject eth_signTransaction / eth_sendTransaction
  • Approve and reject bnb_sign (binance dex orders)
  • session persistent / recovery

Todo:

  • push notification (APNS)

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

WalletConnect is available through CocoaPods, Carthage and Swift Package Manager.

CocoaPods

To install it, simply add the following line to your Podfile:

pod 'WalletConnect', git: 'https://github.com/trustwallet/wallet-connect-swift', branch: 'master'

Carthage

Add following line to your Cartfile:

github "trustwallet/wallet-connect-swift"

Swift Package Manager

Add .package(url:_:) to your Package.swift:

dependencies: [
    .package(url: "https://github.com/trustwallet/wallet-connect-swift", .branch("master")),
],

Usage

parse session from scanned QR code:

let string = "wc:..."
guard let session = WCSession.from(string: string) else {
    // invalid session
    return
}
// handle session

configure and handle incoming message:

let interactor = WCInteractor(session: session, meta: clientMeta)
interactor.onSessionRequest = { [weak self] (id, peer) in
    // ask for user consent
}

interactor.onDisconnect = { [weak self] (error) in
    // handle disconnect
}

interactor.eth.onSign = { [weak self] (id, payload) in
    // handle eth_sign, personal_sign, eth_signTypedData
}

interactor.eth.onTransaction = { [weak self] (id, event, transaction) in
    // handle eth_signTransaction / eth_sendTransaction
}

interactor.bnb.onSign = { [weak self] (id, order) in
    // handle bnb_sign
}

approve session

interactor.approveSession(accounts: accounts, chainId: chainId).done {
    print("<== approveSession done")
}.cauterize()

approve request

interactor.approveRequest(id: id, result: result.hexString).done {
    print("<== approveRequest done")
}.cauterize()

approve binance dex orders

interactor?.approveBnbOrder(id: id, signed: signed).done({ confirm in
    print("<== approveBnbOrder", confirm)
}).cauterize()

Author

hewigovens

License

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

Copyright (c) 2019 hewigovens <360470+hewigovens@users.noreply.github.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
README
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/SSHTerm/wallet-connect-swift.git
git@gitee.com:SSHTerm/wallet-connect-swift.git
SSHTerm
wallet-connect-swift
wallet-connect-swift
master

搜索帮助