-
Notifications
You must be signed in to change notification settings - Fork 9
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
[ABW-3230] Use Wallet Interaction models from Sargon #1171
Changes from 9 commits
0471e0e
2e6ddcc
0428f15
ec8ede9
d503e42
ffd0fb7
cca2f80
1bd648c
9d6e988
da60a14
9b9c66a
9f34b1a
fc08f7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,14 +36,14 @@ extension ROLAClient { | |
return Self( | ||
performDappDefinitionVerification: { metadata async throws in | ||
_ = try await onLedgerEntitiesClient.getDappMetadata( | ||
metadata.dAppDefinitionAddress, | ||
validatingWebsite: metadata.origin.url | ||
metadata.dappDefinitionAddress, | ||
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. mm we are using 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 variable name in Rust 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. On the one hand dApp is the correct style, on the other hand we did decide to generally write it Dapp, while would lead to |
||
validatingWebsite: metadata.origin | ||
) | ||
}, | ||
performWellKnownFileCheck: { metadata async throws in | ||
@Dependency(\.urlSession) var urlSession | ||
|
||
let originURL = metadata.origin.url | ||
let originURL = metadata.origin | ||
|
||
let url = originURL.appending(path: Constants.wellKnownFilePath) | ||
|
||
|
@@ -73,7 +73,7 @@ extension ROLAClient { | |
let response = try await fetchWellKnownFile() | ||
|
||
let dAppDefinitionAddresses = response.dApps.map(\.dAppDefinitionAddress) | ||
guard dAppDefinitionAddresses.contains(metadata.dAppDefinitionAddress) else { | ||
guard dAppDefinitionAddresses.contains(metadata.dappDefinitionAddress) else { | ||
throw ROLAFailure.unknownDappDefinitionAddress | ||
} | ||
}, | ||
|
@@ -115,13 +115,13 @@ extension ROLAClient { | |
extension ROLAClient { | ||
/// `0x52 || challenge(32) || L_dda(1) || dda_utf8(L_dda) || origin_utf8` | ||
static func payloadToHash( | ||
challenge: P2P.Dapp.Request.AuthChallengeNonce, | ||
challenge: DappToWalletInteractionAuthChallengeNonce, | ||
dAppDefinitionAddress accountAddress: AccountAddress, | ||
origin metadataOrigin: P2P.Dapp.Request.Metadata.Origin | ||
origin metadataOrigin: DappToWalletInteractionMetadata.Origin | ||
) -> Data { | ||
let rPrefix: UInt8 = 0x52 | ||
let dAppDefinitionAddress = accountAddress.address | ||
let origin = metadataOrigin.urlString.rawValue | ||
let origin = metadataOrigin.absoluteString | ||
precondition(dAppDefinitionAddress.count <= UInt8.max) | ||
let challengeBytes = [UInt8](challenge.data.data) | ||
let lengthDappDefinitionAddress = UInt8(dAppDefinitionAddress.count) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,14 +15,24 @@ extension P2P { | |
} | ||
|
||
public enum Request: Sendable, Hashable, Equatable, Decodable { | ||
case dapp(P2P.Dapp.RequestUnvalidated) | ||
case dapp(DappToWalletInteractionUnvalidated) | ||
} | ||
} | ||
} | ||
|
||
extension P2P.RTCMessageFromPeer.Request { | ||
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. Small improvement maybe - we could remove the Codable conformance from Request, and then decode the DappToWalletInteractionUnvalidated separately and embed it in the request afterwards. |
||
public init(from decoder: Decoder) throws { | ||
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. Do we actually need this to be generally Decodable? 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. Removed Decodable |
||
self = try .dapp(.init(from: decoder)) | ||
@Dependency(\.jsonEncoder) var jsonEncoder | ||
|
||
let container = try decoder.singleValueContainer() | ||
let jsonValue = try container.decode(JSONValue.self) | ||
let jsonData = try jsonEncoder().encode(jsonValue.dictionary ?? [:]) | ||
|
||
guard let jsonString = String(data: jsonData, encoding: .utf8) else { | ||
throw DecodingError.dataCorruptedError(in: container, debugDescription: "Invalid data") | ||
} | ||
|
||
self = try .dapp(.init(jsonString: jsonString)) | ||
} | ||
} | ||
|
||
|
This file was deleted.
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.
We are now using
WalletInteractionId
, which is a typealias ofUUID
. Then, how can it contain a prefix that we manually set on line 29?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.
WalletInteractionId
is a typealias ofString
for now. Wrote an explanation here.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.
oh, I was navigating to an oudated typealias.
Thanks