Skip to content

Commit 8c9c023

Browse files
committed
Add leaf schema version to RPC response for compressed assets
1 parent fc4dba9 commit 8c9c023

File tree

34 files changed

+92
-34
lines changed

34 files changed

+92
-34
lines changed

digital_asset_types/src/dapi/common/asset.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,17 @@ pub fn asset_to_rpc(asset: FullAsset, options: &Options) -> Result<RpcAsset, DbE
454454
None
455455
};
456456

457+
// Infer leaf schema version based on whether a collection hash is saved for the asset.
458+
let leaf_schema_version = if asset.compressed {
459+
if asset.collection_hash.is_some() {
460+
Some(2)
461+
} else {
462+
Some(1)
463+
}
464+
} else {
465+
None
466+
};
467+
457468
Ok(RpcAsset {
458469
interface: interface.clone(),
459470
id: bs58::encode(asset.id).into_string(),
@@ -488,6 +499,7 @@ pub fn asset_to_rpc(asset: FullAsset, options: &Options) -> Result<RpcAsset, DbE
488499
.asset_data_hash
489500
.map(|e| if asset.compressed { e.trim() } else { "" }.to_string()),
490501
flags: asset.bubblegum_flags.and_then(|val| val.try_into().ok()),
502+
leaf_schema_version,
491503
}),
492504
grouping: Some(rpc_groups),
493505
royalty: Some(Royalty {

digital_asset_types/src/rpc/asset.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ pub struct Compression {
229229
pub tree: String,
230230
pub seq: i64,
231231
pub leaf_id: i64,
232+
#[serde(skip_serializing_if = "Option::is_none")]
233+
pub leaf_schema_version: Option<i64>,
232234
}
233235

234236
pub type GroupKey = String;

integration_tests/tests/integration_tests/snapshots/integration_tests__cnft_tests__cnft_owners_table-base.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
source: integration_tests/tests/integration_tests/cnft_tests.rs
3+
assertion_line: 152
34
expression: response
45
---
56
{
@@ -37,7 +38,8 @@ expression: response
3738
"asset_hash": "3TP6JZ2e3CPzoktSC1cx5K8GM2dWrS6F8xuM51m78Tqr",
3839
"tree": "8Uyk1cZGDcytRBdyKkqHJhTAvSPzSNDDEJTacWUEW8p6",
3940
"seq": 258421,
40-
"leaf_id": 170433
41+
"leaf_id": 170433,
42+
"leaf_schema_version": 1
4143
},
4244
"grouping": [
4345
{

integration_tests/tests/integration_tests/snapshots/integration_tests__cnft_tests__cnft_scenario_mint_update_metadata.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
source: integration_tests/tests/integration_tests/cnft_tests.rs
3+
assertion_line: 36
34
expression: response
45
---
56
{
@@ -32,7 +33,8 @@ expression: response
3233
"asset_hash": "4Un9hicHokmeRx3mcqzuVd1k1zAzjqXymm7xo8xqJTeK",
3334
"tree": "EzppnpWWMKg4egUkfe86aQQyYabFL9jPPWTrZjniDHxv",
3435
"seq": 2,
35-
"leaf_id": 0
36+
"leaf_id": 0,
37+
"leaf_schema_version": 1
3638
},
3739
"grouping": [],
3840
"royalty": {

integration_tests/tests/integration_tests/snapshots/integration_tests__cnft_tests__cnft_scenario_mint_update_metadata_remove_creators.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
source: integration_tests/tests/integration_tests/cnft_tests.rs
3+
assertion_line: 36
34
expression: response
45
---
56
{
@@ -32,7 +33,8 @@ expression: response
3233
"asset_hash": "CbsvyFdcQ8SyGaVpqNE5zjLfSbgnuKDnJZEyQgC4P5Wt",
3334
"tree": "8PkWaY1BYd6ysBZt3JEwuAXjNrZE6omW18cKEJzbyaw4",
3435
"seq": 2,
35-
"leaf_id": 0
36+
"leaf_id": 0,
37+
"leaf_schema_version": 1
3638
},
3739
"grouping": [],
3840
"royalty": {

integration_tests/tests/integration_tests/snapshots/integration_tests__cnft_tests__mint_delegate_transfer.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
source: integration_tests/tests/integration_tests/cnft_tests.rs
3+
assertion_line: 36
34
expression: response
45
---
56
{
@@ -32,7 +33,8 @@ expression: response
3233
"asset_hash": "BvK9Z52tdghAc8ohBdSbeJfbfHgirzJEKkaNdexBHHQ9",
3334
"tree": "2AsVtpcSDi4nUhMEvtZPApGvucu6kP4qrKV6SZ9hG3WT",
3435
"seq": 3,
35-
"leaf_id": 0
36+
"leaf_id": 0,
37+
"leaf_schema_version": 1
3638
},
3739
"grouping": [],
3840
"royalty": {

integration_tests/tests/integration_tests/snapshots/integration_tests__cnft_tests__mint_no_json_uri.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
source: integration_tests/tests/integration_tests/cnft_tests.rs
3+
assertion_line: 36
34
expression: response
45
---
56
{
@@ -32,7 +33,8 @@ expression: response
3233
"asset_hash": "HKvUDBDmeFo727WTYiE9SdR7bqpkQeJecZQoJbUep9Pg",
3334
"tree": "67B3xvadpVeBJ6MT5tQqBqntrBeLNjrWbcF6uEAH1EEi",
3435
"seq": 4,
35-
"leaf_id": 3
36+
"leaf_id": 3,
37+
"leaf_schema_version": 1
3638
},
3739
"grouping": [
3840
{

integration_tests/tests/integration_tests/snapshots/integration_tests__cnft_tests__mint_redeem.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
source: integration_tests/tests/integration_tests/cnft_tests.rs
3+
assertion_line: 36
34
expression: response
45
---
56
{
@@ -32,7 +33,8 @@ expression: response
3233
"asset_hash": "11111111111111111111111111111111",
3334
"tree": "tree9kmh23Qwa9K8sZ9rQtYshSwKA85CTEvw5bvTrau",
3435
"seq": 62,
35-
"leaf_id": 58
36+
"leaf_id": 58,
37+
"leaf_schema_version": 1
3638
},
3739
"grouping": [
3840
{

integration_tests/tests/integration_tests/snapshots/integration_tests__cnft_tests__mint_redeem_cancel_redeem.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
source: integration_tests/tests/integration_tests/cnft_tests.rs
3+
assertion_line: 36
34
expression: response
45
---
56
{
@@ -32,7 +33,8 @@ expression: response
3233
"asset_hash": "AqMe3832WCXHbaaKAPs5MFo55oWBEKKN5iigTaoRtHFr",
3334
"tree": "Hk1644vHxBJ33ZZ1QW5P1zpex9qJ22RdHCwk46aaR16k",
3435
"seq": 3,
35-
"leaf_id": 0
36+
"leaf_id": 0,
37+
"leaf_schema_version": 1
3638
},
3739
"grouping": [],
3840
"royalty": {

integration_tests/tests/integration_tests/snapshots/integration_tests__cnft_tests__mint_transfer_burn.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
source: integration_tests/tests/integration_tests/cnft_tests.rs
3+
assertion_line: 36
34
expression: response
45
---
56
{
@@ -32,7 +33,8 @@ expression: response
3233
"asset_hash": "4R8dTjLuyetziKZFeM45Qa1XuGn3vd4LdJkGPEJhotAq",
3334
"tree": "CnBt2TJrw1dXUBfVBf2Ah4Cz5s84jhBG7cejdPF19Eyh",
3435
"seq": 3,
35-
"leaf_id": 0
36+
"leaf_id": 0,
37+
"leaf_schema_version": 1
3638
},
3739
"grouping": [],
3840
"royalty": {

0 commit comments

Comments
 (0)