-
Notifications
You must be signed in to change notification settings - Fork 24
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
Add additional wallets to a client #383
Changes from 6 commits
38931cd
84418c0
53383cc
1375f13
da6bf1e
99bf8fc
3ac131e
8077be1
b6ceda0
460f899
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,9 @@ import LibXMTP | |
public protocol SigningKey { | ||
/// A wallet address for this key | ||
var address: String { get } | ||
|
||
/// If this signing key is a smart contract wallet | ||
var isSmartContractWallet: Bool { get } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also pass a chainId |
||
|
||
/// Sign the data and return a secp256k1 compact recoverable signature. | ||
func sign(_ data: Data) async throws -> Signature | ||
|
@@ -29,6 +32,10 @@ public protocol SigningKey { | |
} | ||
|
||
extension SigningKey { | ||
public var isSmartContractWallet: Bool { | ||
return false | ||
} | ||
|
||
func createIdentity(_ identity: PrivateKey, preCreateIdentityCallback: PreEventCallback? = nil) async throws -> AuthorizedIdentity { | ||
var slimKey = PublicKey() | ||
slimKey.timestamp = UInt64(Date().millisecondsSinceEpoch) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -455,4 +455,42 @@ class ClientTests: XCTestCase { | |
|
||
XCTAssertEqual(inboxId, alixClient.inboxID) | ||
} | ||
|
||
func testAddAdditionalEOAWallets() async throws { | ||
let key = try Crypto.secureRandomBytes(count: 32) | ||
let alixWallet1 = try PrivateKey.generate() | ||
let alix = try await Client.create( | ||
account: alixWallet1, | ||
options: .init( | ||
api: .init(env: .local, isSecure: false), | ||
enableV3: true, | ||
encryptionKey: key | ||
) | ||
) | ||
XCTAssertEqual(alix.addresses.count, 1) | ||
|
||
let alixWallet2 = try PrivateKey.generate() | ||
try await alix.addWallet(account: alixWallet2) | ||
XCTAssertEqual(alix.addresses.count, 2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @neekolas what would be a good thing to test on a client to see if a wallet was added? Is there something I can expose from libxmtp to show me all the wallets attached? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The one we already expose is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can for sure use that in the test. But what if I want to see all the addresses I have on my account so I can revoke some? Should we also expose addresses on client? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Easy enough to add. We have all the information in the local DB. Happy to pick that one up, should be a small task. Would definitely be helpful for revocation, where you need to see all your own account addresses and installations. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When we talk about revoking a wallet that is different than revoking installations correct? Revoking a wallet would just revoke all the installations for that address? |
||
} | ||
|
||
func testAddAdditionalSCWWallets() async throws { | ||
let key = try Crypto.secureRandomBytes(count: 32) | ||
let alixWallet1 = try PrivateKey.generate() | ||
let alix = try await Client.create( | ||
account: alixWallet1, | ||
options: .init( | ||
api: .init(env: .local, isSecure: false), | ||
enableV3: true, | ||
encryptionKey: key, | ||
chainRPCUrl: "https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID" | ||
) | ||
) | ||
XCTAssertEqual(alix.addresses.count, 1) | ||
|
||
let alixWallet2 = try PrivateKey.generate() | ||
try await alix.addWallet(account: alixWallet2) | ||
XCTAssertEqual(alix.addresses.count, 2) | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After adding the wallet to their identity what benefits do they get/ how can the interact with the wallet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would allow someone else to enter any one of the added wallet addresses and reach the same inbox.
And for an app that has access to any of the added wallets to create a new installation for that inbox.