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

[ABW-3465] Decode deep link and download metadata #180

Merged
merged 85 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
d3cde8b
HKDF key agreement
GhenadieVP Apr 28, 2024
c30ac72
wip
GhenadieVP Apr 29, 2024
009c20e
wip
GhenadieVP Apr 30, 2024
a81a3b8
wip
GhenadieVP Apr 30, 2024
b2eb4d0
wip
GhenadieVP May 30, 2024
db36c21
wip
danvleju-rdx Jun 6, 2024
8aab5f5
rename to key_agreement
GhenadieVP Jun 7, 2024
7b40d1e
rename keys
GhenadieVP Jun 7, 2024
c1a2216
Add SymmetricKey
GhenadieVP Jun 7, 2024
95e72aa
compare by public key
GhenadieVP Jun 7, 2024
2042513
move hkdf
GhenadieVP Jun 7, 2024
0fbcec0
Fix hkdf ref
GhenadieVP Jun 7, 2024
1b6b418
update link_request
GhenadieVP Jun 8, 2024
eeb44cd
wip
GhenadieVP Jun 10, 2024
ff8b32e
[ABW-3208] Callback_path fetching (#159)
jakub-rdx Jun 10, 2024
4560409
wip
danvleju-rdx Jun 10, 2024
66ee8d8
wip
GhenadieVP Jun 10, 2024
56c7b57
wip
GhenadieVP Jun 11, 2024
ee32831
Merge branch 'main' into rcm_linking
GhenadieVP Jun 11, 2024
e98055d
update parser
GhenadieVP Jun 11, 2024
03a7cea
export
GhenadieVP Jun 11, 2024
645aaa3
wip
danvleju-rdx Jun 11, 2024
3ea7600
wip
danvleju-rdx Jun 11, 2024
11c6ca4
no hkdf for now
GhenadieVP Jun 11, 2024
e1f0bd7
change WalletInteractionId from UUID to String
danvleju-rdx Jun 11, 2024
03c7032
Revert "wip"
danvleju-rdx Jun 11, 2024
1daf79f
Merge branch 'main' into ABW-3230-use-wallet-interaction-models-from-…
danvleju-rdx Jun 11, 2024
c13ea5e
wip
GhenadieVP Jun 11, 2024
ba91c39
wip
GhenadieVP Jun 11, 2024
4d62681
Merge remote-tracking branch 'origin/ABW-3230-use-wallet-interaction-…
GhenadieVP Jun 11, 2024
9e77d70
wip
GhenadieVP Jun 11, 2024
41dcb77
request in deepLink
GhenadieVP Jun 11, 2024
944c2a0
Implement RadixConnectSessionStorage for kotlin (#163)
micbakos-rdx Jun 12, 2024
bd34a56
Expose kotlin serde for RadixConnectMobileLinkRequest (#164)
micbakos-rdx Jun 13, 2024
8842991
request in deepLink URL
GhenadieVP Jun 13, 2024
2774460
Optional request body for `GET` methods (#165)
micbakos-rdx Jun 13, 2024
f99a4df
wip
GhenadieVP Jun 14, 2024
e4a933a
Merge branch 'rcm_linking' of https://github.com/radixdlt/sargon into…
GhenadieVP Jun 14, 2024
696136f
Merge branch 'main' into rcm_linking
GhenadieVP Jun 14, 2024
cdbc6da
wip
GhenadieVP Jun 14, 2024
88b947b
Redo PR #164 since some methods of `RadixConnectMobileLinkRequest` we…
micbakos-rdx Jun 14, 2024
7483c16
Merge branch 'main' into rcm_linking
GhenadieVP Jun 17, 2024
855edf9
wip
GhenadieVP Jun 18, 2024
24f5cd0
signature validation
GhenadieVP Jun 18, 2024
9fde320
wip
GhenadieVP Jun 20, 2024
e18ac17
wip
GhenadieVP Jun 20, 2024
f5c5bcf
wip
GhenadieVP Jun 20, 2024
94132fb
wip
GhenadieVP Jun 20, 2024
6778672
Merge branch 'main' into rcm_linking
GhenadieVP Jun 20, 2024
b7ddec5
hkdf
GhenadieVP Jun 20, 2024
27da157
wip
GhenadieVP Jun 21, 2024
16a2691
update parse_url_into_request test
danvleju-rdx Jun 21, 2024
981a249
tests
danvleju-rdx Jun 21, 2024
e9509a4
tests
danvleju-rdx Jun 21, 2024
5e35944
wip
sergiupuhalschi-rdx Jun 24, 2024
83950f0
Merge branch 'main' into mb/af-dl
matiasbzurovski Jun 26, 2024
f8ca099
WIP
matiasbzurovski Jun 26, 2024
32bf160
WIP
matiasbzurovski Jun 26, 2024
b8fe839
Add tests
matiasbzurovski Jun 26, 2024
32ff810
Updates
matiasbzurovski Jun 27, 2024
9deeede
Merge main
sergiupuhalschi-rdx Jun 28, 2024
ce8c80b
Revert changes after merge
sergiupuhalschi-rdx Jun 29, 2024
74c5315
Add cards manager. Update mod structure
sergiupuhalschi-rdx Jun 29, 2024
f76160e
Rename cards
sergiupuhalschi-rdx Jul 1, 2024
52c59ee
Updates to model and logic
matiasbzurovski Jul 1, 2024
15f727c
Add parser struct
matiasbzurovski Jul 1, 2024
2d13af8
WIP add metadata support
matiasbzurovski Jul 1, 2024
f917270
Logic to fetch metadata
matiasbzurovski Jul 1, 2024
4f944a3
Merge branch 'main' into mb/deferred-parsing
matiasbzurovski Jul 2, 2024
b572e9e
Bump
matiasbzurovski Jul 2, 2024
5c99851
Lint
matiasbzurovski Jul 2, 2024
dcf9795
Remove connector card from parser
matiasbzurovski Jul 2, 2024
23871a1
Implement home cards manager
sergiupuhalschi-rdx Jul 2, 2024
3c114a7
Implement home cards ordering
sergiupuhalschi-rdx Jul 3, 2024
2272670
Add home cards manager init for new wallet function
sergiupuhalschi-rdx Jul 3, 2024
ab3570f
Changes after feedback
matiasbzurovski Jul 3, 2024
2f8a090
Rename exposed functions
sergiupuhalschi-rdx Jul 4, 2024
7b025ea
changes after feedback
matiasbzurovski Jul 4, 2024
e187b29
Expose home cards manager in kt
sergiupuhalschi-rdx Jul 4, 2024
a3479e8
Version bump
sergiupuhalschi-rdx Jul 4, 2024
2d50937
Replace StartRadQuest card after resolving DL if needed. Update defau…
sergiupuhalschi-rdx Jul 8, 2024
0527ee2
Update API
sergiupuhalschi-rdx Jul 8, 2024
4af5f0e
Address PR comment
sergiupuhalschi-rdx Jul 9, 2024
9021fdc
Version bump
sergiupuhalschi-rdx Jul 9, 2024
c54e8b2
Merge branch 'main' into mb/deferred-parsing
sergiupuhalschi-rdx Jul 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sargon"
version = "1.0.22"
version = "1.0.23"
edition = "2021"
build = "build.rs"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,83 +25,9 @@
},
"metadata":
{
"total_count": 2,
"total_count": 0,
matiasbzurovski marked this conversation as resolved.
Show resolved Hide resolved
"items":
[
{
"key": "owner_keys",
"value":
{
"raw_hex": "5c228f01202201010120071d3ecafcab915867ec8446550f6c5b44c52dd8a947237f29b3d2a07697f8",
"programmatic_json":
{
"variant_id": 143,
"fields":
[
{
"element_kind": "Enum",
"elements":
[
{
"variant_id": 1,
"fields":
[
{
"element_kind": "U8",
"hex": "3ecafcab915867ec8446550f6c5b44c52dd8a947237f29b3d2a07697f8",
"kind": "Bytes"
}
],
"kind": "Enum"
}
],
"kind": "Array"
}
],
"kind": "Enum"
},
"typed":
{
"values":
[
{
"hash_hex": "3ecafcab915867ec8446550f6c5b44c52dd8a947237f29b3d2a07697f8",
"key_hash_type": "EddsaEd25519"
}
],
"type": "PublicKeyHashArray"
}
},
"is_locked": false,
"last_updated_at_state_version": 0
},
{
"key": "owner_badge",
"value":
{
"raw_hex": "5c220b01c0021e513ecafcab915867ec8446550f6c5b44c52dd8a947237f29b3d2a07697f8",
"programmatic_json":
{
"variant_id": 11,
"fields":
[
{
"value": "[513ecafcab915867ec8446550f6c5b44c52dd8a947237f29b3d2a07697f8]",
"kind": "NonFungibleLocalId"
}
],
"kind": "Enum"
},
"typed":
{
"value": "[513ecafcab915867ec8446550f6c5b44c52dd8a947237f29b3d2a07697f8]",
"type": "NonFungibleLocalId"
}
},
"is_locked": true,
"last_updated_at_state_version": 0
}
]
[]
},
"explicit_metadata":
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,50 +25,9 @@
},
"metadata":
{
"total_count": 5,
"total_count": 4,
"items":
[
{
"key": "tags",
"value":
{
"raw_hex": "5c228001200c0206536172676f6e055275737479",
"programmatic_json":
{
"variant_id": 128,
"fields":
[
{
"element_kind": "String",
"elements":
[
{
"value": "Sargon",
"kind": "String"
},
{
"value": "Rusty",
"kind": "String"
}
],
"kind": "Array"
}
],
"kind": "Enum"
},
"typed":
{
"values":
[
"Sargon",
"Rusty"
],
"type": "StringArray"
}
},
"is_locked": false,
"last_updated_at_state_version": 73654060
},
{
"key": "icon_url",
"value":
Expand Down
15 changes: 15 additions & 0 deletions src/core/error/common_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,21 @@ pub enum CommonError {

#[error("Radix Connect Mobile failed to create new in flight session")]
RadixConnectMobileFailedToCreateNewSession = 10151,

#[error("Deferred Deep Link invalid deep link value format")]
DeferredDeepLinkInvalidValueFormat = 10152,
GhenadieVP marked this conversation as resolved.
Show resolved Hide resolved

#[error("Deferred Deep Link decoding failed")]
DeferredDeepLinkDecodingFailed = 10153,

#[error("Failed updating home cards from deferred deep link")]
FailedUpdatingHomeCardsFromDeferredDeepLink = 10154,

#[error("Home cards not found")]
HomeCardsNotFound = 10155,

#[error("Invalid Metadata format")]
InvalidMetadataFormat = 10156,
}

#[uniffi::export]
Expand Down
43 changes: 40 additions & 3 deletions src/gateway_api/methods/state_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
address: AccountAddress,
) -> Result<Option<Decimal192>> {
let response: StateEntityDetailsResponse = self
.state_entity_details(StateEntityDetailsRequest {
addresses: vec![address.into()],
})
.state_entity_details(StateEntityDetailsRequest::new(vec![
address.address()
]))
.await?;

let Some(response_item) = response
Expand Down Expand Up @@ -54,3 +54,40 @@
.map(|x| x.unwrap_or(Decimal192::zero()))
}
}

impl GatewayClient {
/// Fetches the metadata for the given address and returns the `icon_url` value.
pub async fn icon_url_of_address(
matiasbzurovski marked this conversation as resolved.
Show resolved Hide resolved
&self,
address: String,
matiasbzurovski marked this conversation as resolved.
Show resolved Hide resolved
) -> Result<Option<Url>> {
let response: StateEntityDetailsResponse = self
matiasbzurovski marked this conversation as resolved.
Show resolved Hide resolved
.state_entity_details(StateEntityDetailsRequest::address(
address.clone(),
vec![MetadataKey::IconUrl],
))
.await?;

let Some(response_item) = response
.items
.into_iter()
.find(|x| x.address.to_string() == address)
else {
return Ok(None);

Check warning on line 76 in src/gateway_api/methods/state_methods.rs

View check run for this annotation

Codecov / codecov/patch

src/gateway_api/methods/state_methods.rs#L76

Added line #L76 was not covered by tests
};

let Some(item) = response_item
.metadata
.items
.into_iter()
.find(|x| x.key == MetadataKey::IconUrl.to_string())
else {
return Ok(None);

Check warning on line 85 in src/gateway_api/methods/state_methods.rs

View check run for this annotation

Codecov / codecov/patch

src/gateway_api/methods/state_methods.rs#L85

Added line #L85 was not covered by tests
};

match item.value.typed {
MetadataTypedValue::MetadataUrlValue { value } => Ok(Some(value)),
_ => Err(CommonError::InvalidMetadataFormat),

Check warning on line 90 in src/gateway_api/methods/state_methods.rs

View check run for this annotation

Codecov / codecov/patch

src/gateway_api/methods/state_methods.rs#L90

Added line #L90 was not covered by tests
}
matiasbzurovski marked this conversation as resolved.
Show resolved Hide resolved
}
}
6 changes: 4 additions & 2 deletions src/gateway_api/models/types/request/state/entity/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
mod state_entity_details;
mod opt_ins;
mod request;

pub use state_entity_details::*;
pub use opt_ins::*;
pub use request::*;
25 changes: 25 additions & 0 deletions src/gateway_api/models/types/request/state/entity/opt_ins.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use crate::prelude::*;

#[derive(
Clone,
Debug,
PartialEq,
Eq,
Serialize,
Deserialize, /* Deserialize so we can test roundtrip of JSON vectors */
)]
pub struct StateEntityDetailsOptIns {
#[serde(
rename = "explicit_metadata",
matiasbzurovski marked this conversation as resolved.
Show resolved Hide resolved
skip_serializing_if = "Option::is_none"
)]
pub explicit_metadata: Option<Vec<MetadataKey>>,
}

impl StateEntityDetailsOptIns {
pub fn new(
explicit_metadata: Option<Vec<MetadataKey>>,
) -> StateEntityDetailsOptIns {
StateEntityDetailsOptIns { explicit_metadata }
}
}
36 changes: 36 additions & 0 deletions src/gateway_api/models/types/request/state/entity/request.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use crate::prelude::*;

#[derive(
Clone,
Debug,
PartialEq,
Eq,
Serialize,
Deserialize, /* Deserialize so we can test roundtrip of JSON vectors */
)]
pub struct StateEntityDetailsRequest {
pub(crate) addresses: Vec<String>,
matiasbzurovski marked this conversation as resolved.
Show resolved Hide resolved
#[serde(rename = "opt_ins", skip_serializing_if = "Option::is_none")]
matiasbzurovski marked this conversation as resolved.
Show resolved Hide resolved
pub(crate) opt_ins: Option<StateEntityDetailsOptIns>,
}

impl StateEntityDetailsRequest {
pub fn new(addresses: Vec<String>) -> StateEntityDetailsRequest {
StateEntityDetailsRequest {
addresses,
opt_ins: None,
}
}

pub fn address(
address: String,
explicit_metadata: Vec<MetadataKey>,
) -> StateEntityDetailsRequest {
StateEntityDetailsRequest {
addresses: vec![address],
opt_ins: Some(StateEntityDetailsOptIns::new(Some(
explicit_metadata,
))),
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use crate::prelude::*;

#[derive(
Deserialize, Serialize, Clone, PartialEq, Eq, Debug, uniffi::Record,
Copy link
Contributor

Choose a reason for hiding this comment

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

meant to be a uniffi::Record? let's not make it so for now. Same for other models, unless you plan to expose this to the wallet and replace the models.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, since we are exposing StateEntityDetailsResponse (which has a Vec<StateEntityDetailsResponseItem>, and each item has an EntityMetadataCollection).

Copy link
Contributor

Choose a reason for hiding this comment

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

.... ok, there is really no reason for StateEntityDetailsResponse to be UniFFI exposed, but since it is already, so be it for now.

)]
pub struct EntityMetadataCollection {
pub items: Vec<EntityMetadataItem>,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use crate::prelude::*;

#[derive(
Deserialize, Serialize, Clone, PartialEq, Eq, Debug, uniffi::Record,
)]
pub struct EntityMetadataItem {
pub key: String,
pub value: EntityMetadataItemValue,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use crate::prelude::*;

#[derive(
Deserialize, Serialize, Clone, PartialEq, Eq, Debug, uniffi::Record,
)]
pub struct EntityMetadataItemValue {
pub typed: MetadataTypedValue,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
mod collection;
mod item;
mod item_value;
mod typed_value;

pub use collection::*;
pub use item::*;
pub use item_value::*;
pub use typed_value::*;
Loading
Loading