Coder Social home page Coder Social logo

airgap-it / beacon-ios-sdk Goto Github PK

View Code? Open in Web Editor NEW
8.0 8.0 13.0 2.65 MB

The beacon sdk allows iOS developers of dApps and wallets on Tezos to implement the wallet interaction standard tzip-10.

License: MIT License

Swift 99.23% Ruby 0.77%

beacon-ios-sdk's People

Contributors

godenzim avatar jsamol avatar mlaeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

beacon-ios-sdk's Issues

[Feature Request]: Remove permission by accountID, appName and address

There are currently 3 methods for removing permissions removeAll, removeForAccount and removeByType. When theres only 1 wallet, all will do the same thing, as the accountIdentifier is always the same:

 storageManager.removeAllPermissions(where: { $0.accountID == accountIdentifier })

What i'm looking for is to remove a permissions for a specific app. I want to give users the ability to say remove permission for OBJKT.com, for wallet address X. So something more like

 storageManager.removeAllPermissions(where: { $0.appMetadata.senderID == app && $0.address == address })

I'm not sure if accountID is needed in the above as well or not

Deeplinking question / discussion

When trying to connect to a website you need to scan a QR code which has the url tezos://xxxxxxxxx. This will allow users to scan with their camera app and get a link to a wallet/app

There is an issue on iOS though, that when multiple apps request to use tezos as a URL scheme, which one will be launched is "undefined". iOS doesn't currently display a share sheet style screen to list all the apps, it just picks one. While experimenting with this library I had AirGap installed on my phone and was unable to get the QR code to launch my app, until I deleted AirGap. Relying on this as a method of opening apps is going to cause a headache for users as the number of apps grow.

Short term it would be a good idea to promote the idea that third party apps should embed their own QR scanner, it might be good for BeaconSDK to include a basic one in-built in the SDK. I'm also not sure if i missed it or not, but I found no code in the library to take a tezos://xxxxxx URL and turn it into a P2P class or even turn the data into JSON. I also couldn't find any documentation on how it was encoded or what to do with it. I had to go read the code of a website to see what they did. If such a function doesn't exist, it really needs too. If it does, it should be added to the README documentation.

Longer term, it might be a good idea to try build a website with buttons/deeplinks to whitelisted mobile apps. When the QR code is scanned with the inbuilt camera app, it would bring users to an AIrGap website, with a list of options to launch various apps from there. Hopefully it could be done in such a way that scanning with the default camera app went to the webpage, but scanning with custom in-app, would still contain the necessary data

[Feature Request]: Beacon.P2PPeer init with url

When scanning a QR code and receiving a URL with a tzip standard, it would be great if the Beacon SDK took care of all of the processing and logic and just had an init that took in a URL. It takes a lot of experimentation and research to figure out what needs to be done with the URL

Beacon.P2PPeer(initWithURL: URL)

Can't compile after added as dependency on XCode

I have added beacon-ios-sdk repo into my newly created XCode iOS Project but it can't compile due to error

"Type 'Tezos' does not conform to protocol 'Blockchain'

and then 134 others error following.

Using XCode 12.5.1 on Bigsur 11.1

<!--

Feature Request

  • I'm using the latest version of the SDK.

Summary

Expected Behaviour

Use Case

Additional Context

Originally posted by @Jacobtarango1996 in #26

Fix CocoaPods support

As mentioned below, the current CocoaPods setup is invalid and must be fixed.

iOS

We're not planning on releasing to CocoaPods. But yes, it's possible to add the dependency directly from GitHub. I'll make sure the pod spec file is up to date and update README with detailed information on how to do it.

I have tried current podspec file from here. There are several building issues due to the fact that Cocoapods builds single framework from subspecs:

  • duplicate file AppMetadata.swift
  • not needed 'import BeaconCore' in subspecs (for example, BeaconBlockchainSubstrate)
  • various definition duplicates, for example, ExtendedDependencyRegistry

Looks like we need a separate podspecs instead of subspecs.

Originally posted by @ERussel in airgap-it/beacon-android-sdk#4 (comment)

[Feature Request]: Return callbacks to the main thread

Most of the callbacks used are connected to a UI event, but all callbacks are returned on a background thread. I think the majority, if not all, should be bounced back to the main thread.

Examples:

  • When a request comes in, first thing I do is put a spinner on the screen to show the user that something is incoming. That means having to put a call to run on main thread at the start of every incoming request
  • Removing peers / permissions are trigger via a UI button, its not something I do in the background without user action. Again my exception would be to throw up a spinner, call the code to remove and then remove the spinner and refresh
  • Adding peers or permissions, again trigger by UI event

Can't parse signing request from DApp

Version: 3.0.1-beta.3

How to reproduce:

  1. Open https://andreasgassmann.github.io/apps
  2. Choose Nova Wallet
  3. Scan QR
  4. SDK is successfully connected
  5. Accept permission request from DApp
  6. Open Accounts -> Send -> Enter amount -> Sign Transaction
  7. SDK receives the message for signing
{\"id\":\"7df08e75-a54c-512d-74d7-eae9bf11c473\",\"version\":\"3\",\"senderId\":\"21QXo8LWoWsqd\",\"message\":{\"blockchainData\":{\"address\":\"0x5464864242fd9a50c0aafd65cdc49939d80097e7dc4a741aa1cdbfb61fc7862d\",\"metadata\":{\"genesisHash\":\"\",\"runtimeVersion\":\"\",\"transactionVersion\":\"\"},\"mode\":\"return\",\"payload\":\"0x0403005464864242fd9a50c0aafd65cdc49939d80097e7dc4a741aa1cdbfb61fc7862d02286bee45021000c823000009000000e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423ede745e5f21c254da470b5f6bd6f60bf1337f752ae06b2d323ca3f324c755179e\",\"scope\":\"sign_raw\"},\"blockchainIdentifier\":\"substrate\",\"type\":\"blockchain_request\",\"accountId\":\"ZwkjmCErtCqLxLGpBdr\"}}
  1. SDK throws an error during parsing:
Swift.DecodingError.keyNotFound(CodingKeys(stringValue: "type", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "message", intValue: nil), CodingKeys(stringValue: "blockchainData", intValue: nil)], debugDescription: "No value associated with key CodingKeys(stringValue: \"type\", intValue: nil) (\"type\").", underlyingError: nil))

Main

Feature Request

  • I'm using the latest version of the SDK.

Summary

Expected Behaviour

Use Case

Additional Context

[Feature Request]: Function to convert signPayload body into human readable string

When receiving a signPayload request, I can't find anything to help me convert the hex into a human readable string. I roughly followed a snippet on the Taquito docs to figure out what needs to be done, but i'm not sure if it will cover all cases, if there are tzips etc. And I can't use taquito to parse it.

It would be great if the SDK did this for you, by having a "humanReadable" string property as part of the signPayload request object

[Bug]: Memory leaks

As mentioned on slack, i've encountered an issue where the below callback / print out gets executed twice whenever I add a Peer:

beaconClient?.add([.p2p(peer)], completion: { result in
	switch result {
		case .success():
			print("peer added success")
					
			completion(true)
					
		case .failure(_):
			completion(false)
	}
})

Digging through it and a few other issues I ran the leak inspector and found a few leaks while starting beacon, removing peers/permissions and trying to add a new peer:

Screenshot 2022-05-11 at 15 06 57

[Bug]: Duplicate permissions

Not sure if a symptom of: #12 or not

While testing, I connected to the same app over and over, each time removing all peers and permissions in between each test. I repeated this many times. Due to the above mentioned issue, removing the permissions didn't do anything. But the SDK allowed the app to store identical permissions over and over, differing only based on permission.connectedAt

index: 2, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H, sppk7c97qQxH3Dm74qwEbCqT2s7ZHxAbSC7hjevVcow8u4brTDYgzhc [BeaconBlockchainTezos.Tezos.Permission.Scope.operationRequest, BeaconBlockchainTezos.Tezos.Permission.Scope.sign] Network(type: BeaconBlockchainTezos.Tezos.Network.Type.mainnet, name: nil, rpcURL: nil) tz2HmW8Am8cpkvMHMe9sGRykTnrHXCLWVMAu 1652197579646
index: 3, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H, sppk7c97qQxH3Dm74qwEbCqT2s7ZHxAbSC7hjevVcow8u4brTDYgzhc [BeaconBlockchainTezos.Tezos.Permission.Scope.operationRequest, BeaconBlockchainTezos.Tezos.Permission.Scope.sign] Network(type: BeaconBlockchainTezos.Tezos.Network.Type.mainnet, name: nil, rpcURL: nil) tz2HmW8Am8cpkvMHMe9sGRykTnrHXCLWVMAu 1652197725338
index: 4, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H, sppk7c97qQxH3Dm74qwEbCqT2s7ZHxAbSC7hjevVcow8u4brTDYgzhc [BeaconBlockchainTezos.Tezos.Permission.Scope.operationRequest, BeaconBlockchainTezos.Tezos.Permission.Scope.sign] Network(type: BeaconBlockchainTezos.Tezos.Network.Type.mainnet, name: nil, rpcURL: nil) tz2HmW8Am8cpkvMHMe9sGRykTnrHXCLWVMAu 1652198603654
index: 5, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H, sppk7c97qQxH3Dm74qwEbCqT2s7ZHxAbSC7hjevVcow8u4brTDYgzhc [BeaconBlockchainTezos.Tezos.Permission.Scope.operationRequest, BeaconBlockchainTezos.Tezos.Permission.Scope.sign] Network(type: BeaconBlockchainTezos.Tezos.Network.Type.mainnet, name: nil, rpcURL: nil) tz2HmW8Am8cpkvMHMe9sGRykTnrHXCLWVMAu 1652199196001
index: 6, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H, sppk7c97qQxH3Dm74qwEbCqT2s7ZHxAbSC7hjevVcow8u4brTDYgzhc [BeaconBlockchainTezos.Tezos.Permission.Scope.operationRequest, BeaconBlockchainTezos.Tezos.Permission.Scope.sign] Network(type: BeaconBlockchainTezos.Tezos.Network.Type.mainnet, name: nil, rpcURL: nil) tz2HmW8Am8cpkvMHMe9sGRykTnrHXCLWVMAu 1652199264466

I would have expected the same app, requesting access to the same wallet, to overwrite an identical permission to avoid any issues with lingering permissions/connections from causing issues

Can't import via SPM

Can't import via SPM due to an underlying issue with the way sodium is packaged. There is a work around, but the owner refuses to integrate as he wants Apple to fix the underlying issue in Xcode instead. Its listed as an "known issue" in Xcode 13 so will hopefully be fixed with that release.

Screenshot 2021-08-06 at 09 44 23

Someone else made a fork that fixes the issue in most cases for now. You can update your dependency to use:

.package(name: "Sodium", url: "https://github.com/junelife/swift-sodium.git", .branch("spm")),

and remove the line

.product(name: "Clibsodium", package: "Sodium"),

And take note to revert it back when the issue is addressed.

[Bug]: Removing permissions doesn't do anything

I've tried calling:

beaconClient?.removeAllPermissions(completion: { result in
	...
})

and

beaconClient?.removePermissions(forAccountIdentifier: permission.accountIdentifier, completion: { result in
	...
})

neither are removing any permissions. Here is my console log. I fetched all permissions, found that there were many that should have been removed a long time ago after multiple calls to removeAll.... Tried to delete the first (printing that I have the correct ID), then afterwards reloaded my tableview and all the same ones are present

Removing Peers is working fine

=== Fetching permissions ===
index: 0, name: Mooncakes, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 1, name: Mooncakes, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 2, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 3, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 4, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 5, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 6, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 7, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 8, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 9, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 10, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 11, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 12, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 13, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 14, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 15, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 16, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 17, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 18, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 19, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 20, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 21, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 22, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
=== End Fetching permissions ===


Delete tapped for row: 0
inside permissions
Remove: name: Mooncakes, accountIdentifier: SEJf6AoXUeeELGPmh6H
permission - result: success()


=== Fetching permissions ===
index: 0, name: Mooncakes, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 1, name: Mooncakes, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 2, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 3, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 4, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 5, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 6, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 7, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 8, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 9, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 10, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 11, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 12, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 13, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 14, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 15, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 16, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 17, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 18, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 19, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 20, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 21, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
index: 22, name: objkt.com, accountIdentifier: SEJf6AoXUeeELGPmh6H
=== End Fetching permissions ===

Unable to find a specification for `BeaconClientDApp`

.podspec file

  s.dependency 'BeaconBlockchainSubstrate'
  s.dependency 'BeaconBlockchainTezos'
  s.dependency 'BeaconClientWallet'
  s.dependency 'BeaconCore'
  s.dependency 'BeaconTransportP2PMatrix'
  s.dependency 'BeaconClientDApp'
  s.platform = :ios, '13.0'

Error

[!] Unable to find a specification for `BeaconClientDApp` depended upon by `beacon`

You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

Beacon.Request all properties public

version on Beacon.Request is not listed as public and not accessible on request objects. One of the constructors for a response required passing in the version, I had to workaround it to store it and retrieve it from elsewhere

Disconnect / stop listening

I'm confused how to manage beacon within the iOS app lifecycle events (e.g. going to background, foreground, suspend etc.). I have created a Beacon.Client instance, told it to connect, and I registered a function to listen for incoming events. How do I disconnect / stop listening when the app goes into background and reconnect when it's reopened? I can't see any public disconnect / stop listening function, only the ability to remove a peer entirely

Mocking

Can you expose the underlying URLSession object to devs so that the requests can be mocked easily?

If you expose a URLSession parameter, I can just create a Mock instance of URLProtocol, pass it a list of URLs and file names, and then everything is mocked throughout my app/library with a handful of lines of code. Without that, it means having to subclass and duplicate many classes and understand business logic in order to be able to implement unit tests around the code. Multiple this by 10 third party libraries and it becomes a lot of effort, and going forward having to update whenever a function definition is changed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.