Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#54 Public account type #65

Merged
merged 9 commits into from
Feb 10, 2022
Merged

#54 Public account type #65

merged 9 commits into from
Feb 10, 2022

Conversation

sekimondre
Copy link

closes #54

Adds a public Account type to handle CAIP-10 account ids when making SDK calls.

@sekimondre sekimondre self-assigned this Feb 4, 2022
@llbartekll
Copy link
Contributor

@MisterVants that is pr into main, change for develop

@sekimondre sekimondre changed the base branch from main to develop February 9, 2022 21:33
@sekimondre
Copy link
Author

@MisterVants that is pr into main, change for develop

done

@sekimondre sekimondre marked this pull request as ready for review February 9, 2022 21:37
Copy link
Contributor

@hewigovens hewigovens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, left some comments

@@ -150,8 +150,8 @@ extension ResponderViewController: SessionViewControllerDelegate {
print("[RESPONDER] Approving session...")
let proposal = currentProposal!
currentProposal = nil
let accounts = proposal.permissions.blockchains.map {$0+":\(account)"}
client.approve(proposal: proposal, accounts: Set(accounts))
let accounts = Set(proposal.permissions.blockchains.compactMap { Account($0+":\(account)") })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add another convenience init to avoid passing the : , It looks easy to forget

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added two more init to make the type more flexible.

public struct Account: Equatable, Hashable {

/// A blockchain namespace. Usually describes an ecosystem or standard.
public var namespace: String
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use let for stored properties? immutable is better

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just changed to let

This initializer returns nil if the string doesn't represent a valid account id in conformance with
[CAIP-10](https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-10.md).
*/
public init?(_ string: String) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it would make sense to create a Chain and add init from a chain and an address.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, but IMHO only if we use the Chain type in more places in the engine. Sounds like an overkill if we add it just to use in an Account

@sekimondre sekimondre merged commit 35c010d into develop Feb 10, 2022
@sekimondre sekimondre deleted the #54-account-type branch February 10, 2022 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Implement public Account type
3 participants