Skip to content

Commit 234119d

Browse files
committed
Improve account labels
1 parent 1f279e0 commit 234119d

File tree

2 files changed

+96
-16
lines changed

2 files changed

+96
-16
lines changed

transaction-status/src/parse_token/extension/confidential_mint_burn.rs

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,22 +123,37 @@ pub(in crate::parse_token) fn parse_confidential_mint_burn_instruction(
123123
// Assume that extra accounts are proof accounts and not multisig
124124
// signers. This might be wrong, but it's the best possible option.
125125
if offset < account_indexes.len() - 1 {
126+
let label = if mint_data.equality_proof_instruction_offset == 0 {
127+
"equalityProofContextStateAccount"
128+
} else {
129+
"equalityProofRecordAccount"
130+
};
126131
map.insert(
127-
"equalityProofRecordAccount".to_string(),
132+
label.to_string(),
128133
json!(account_keys[account_indexes[offset] as usize].to_string()),
129134
);
130135
offset += 1;
131136
}
132137
if offset < account_indexes.len() - 1 {
138+
let label = if mint_data.ciphertext_validity_proof_instruction_offset == 0 {
139+
"ciphertextValidityProofContextStateAccount"
140+
} else {
141+
"ciphertextValidityProofRecordAccount"
142+
};
133143
map.insert(
134-
"ciphertextValidityProofRecordAccount".to_string(),
144+
label.to_string(),
135145
json!(account_keys[account_indexes[offset] as usize].to_string()),
136146
);
137147
offset += 1;
138148
}
139149
if offset < account_indexes.len() - 1 {
150+
let label = if mint_data.range_proof_instruction_offset == 0 {
151+
"rangeProofContextStateAccount"
152+
} else {
153+
"rangeProofRecordAccount"
154+
};
140155
map.insert(
141-
"rangeProofRecordAccount".to_string(),
156+
label.to_string(),
142157
json!(account_keys[account_indexes[offset] as usize].to_string()),
143158
);
144159
offset += 1;
@@ -188,22 +203,37 @@ pub(in crate::parse_token) fn parse_confidential_mint_burn_instruction(
188203
// Assume that extra accounts are proof accounts and not multisig
189204
// signers. This might be wrong, but it's the best possible option.
190205
if offset < account_indexes.len() - 1 {
206+
let label = if burn_data.equality_proof_instruction_offset == 0 {
207+
"equalityProofContextStateAccount"
208+
} else {
209+
"equalityProofRecordAccount"
210+
};
191211
map.insert(
192-
"equalityProofRecordAccount".to_string(),
212+
label.to_string(),
193213
json!(account_keys[account_indexes[offset] as usize].to_string()),
194214
);
195215
offset += 1;
196216
}
197217
if offset < account_indexes.len() - 1 {
218+
let label = if burn_data.ciphertext_validity_proof_instruction_offset == 0 {
219+
"ciphertextValidityProofContextStateAccount"
220+
} else {
221+
"ciphertextValidityProofRecordAccount"
222+
};
198223
map.insert(
199-
"ciphertextValidityProofRecordAccount".to_string(),
224+
label.to_string(),
200225
json!(account_keys[account_indexes[offset] as usize].to_string()),
201226
);
202227
offset += 1;
203228
}
204229
if offset < account_indexes.len() - 1 {
230+
let label = if burn_data.range_proof_instruction_offset == 0 {
231+
"rangeProofContextStateAccount"
232+
} else {
233+
"rangeProofRecordAccount"
234+
};
205235
map.insert(
206-
"rangeProofRecordAccount".to_string(),
236+
label.to_string(),
207237
json!(account_keys[account_indexes[offset] as usize].to_string()),
208238
);
209239
offset += 1;

transaction-status/src/parse_token/extension/confidential_transfer.rs

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,26 @@ pub(in crate::parse_token) fn parse_confidential_transfer_instruction(
228228
// Assume that extra accounts are proof accounts and not multisig
229229
// signers. This might be wrong, but it's the best possible option.
230230
if offset < account_indexes.len() - 1 {
231+
let label = if withdrawal_data.equality_proof_instruction_offset == 0 {
232+
"equalityProofContextStateAccount"
233+
} else {
234+
"equalityProofRecordAccount"
235+
};
231236
map.insert(
232-
"equalityProofAccount".to_string(),
237+
label.to_string(),
233238
json!(account_keys[account_indexes[offset] as usize].to_string()),
234239
);
235240
offset += 1;
236241
}
237242

238243
if offset < account_indexes.len() - 1 {
244+
let label = if withdrawal_data.range_proof_instruction_offset == 0 {
245+
"rangeProofContextStateAccount"
246+
} else {
247+
"rangeProofRecordAccount"
248+
};
239249
map.insert(
240-
"rangeProofAccount".to_string(),
250+
label.to_string(),
241251
json!(account_keys[account_indexes[offset] as usize].to_string()),
242252
);
243253
offset += 1;
@@ -287,24 +297,39 @@ pub(in crate::parse_token) fn parse_confidential_transfer_instruction(
287297
// Assume that extra accounts are proof accounts and not multisig
288298
// signers. This might be wrong, but it's the best possible option.
289299
if offset < account_indexes.len() - 1 {
300+
let label = if transfer_data.equality_proof_instruction_offset == 0 {
301+
"equalityProofContextStateAccount"
302+
} else {
303+
"equalityProofRecordAccount"
304+
};
290305
map.insert(
291-
"equalityProofAccount".to_string(),
306+
label.to_string(),
292307
json!(account_keys[account_indexes[offset] as usize].to_string()),
293308
);
294309
offset += 1;
295310
}
296311

297312
if offset < account_indexes.len() - 1 {
313+
let label = if transfer_data.ciphertext_validity_proof_instruction_offset == 0 {
314+
"ciphertextValidityProofContextStateAccount"
315+
} else {
316+
"ciphertextValidityProofRecordAccount"
317+
};
298318
map.insert(
299-
"ciphertextValidityProofAccount".to_string(),
319+
label.to_string(),
300320
json!(account_keys[account_indexes[offset] as usize].to_string()),
301321
);
302322
offset += 1;
303323
}
304324

305325
if offset < account_indexes.len() - 1 {
326+
let label = if transfer_data.range_proof_instruction_offset == 0 {
327+
"rangeProofContextStateAccount"
328+
} else {
329+
"rangeProofRecordAccount"
330+
};
306331
map.insert(
307-
"rangeProofAccount".to_string(),
332+
label.to_string(),
308333
json!(account_keys[account_indexes[offset] as usize].to_string()),
309334
);
310335
offset += 1;
@@ -368,36 +393,61 @@ pub(in crate::parse_token) fn parse_confidential_transfer_instruction(
368393
// Assume that extra accounts are proof accounts and not multisig
369394
// signers. This might be wrong, but it's the best possible option.
370395
if offset < account_indexes.len() - 1 {
396+
let label = if equality_proof_instruction_offset == 0 {
397+
"equalityProofContextStateAccount"
398+
} else {
399+
"equalityProofRecordAccount"
400+
};
371401
map.insert(
372-
"equalityProofAccount".to_string(),
402+
label.to_string(),
373403
json!(account_keys[account_indexes[offset] as usize].to_string()),
374404
);
375405
offset += 1;
376406
}
377407
if offset < account_indexes.len() - 1 {
408+
let label = if transfer_amount_ciphertext_validity_proof_instruction_offset == 0 {
409+
"transferAmountCiphertextValidityProofContextStateAccount"
410+
} else {
411+
"transferAmountCiphertextValidityProofRecordAccount"
412+
};
378413
map.insert(
379-
"transferAmountCiphertextValidityProofAccount".to_string(),
414+
label.to_string(),
380415
json!(account_keys[account_indexes[offset] as usize].to_string()),
381416
);
382417
offset += 1;
383418
}
384419
if offset < account_indexes.len() - 1 {
420+
let label = if fee_ciphertext_validity_proof_instruction_offset == 0 {
421+
"feeCiphertextValidityProofContextStateAccount"
422+
} else {
423+
"feeCiphertextValidityProofRecordAccount"
424+
};
385425
map.insert(
386-
"feeCiphertextValidityProofAccount".to_string(),
426+
label.to_string(),
387427
json!(account_keys[account_indexes[offset] as usize].to_string()),
388428
);
389429
offset += 1;
390430
}
391431
if offset < account_indexes.len() - 1 {
432+
let label = if fee_sigma_proof_instruction_offset == 0 {
433+
"feeSigmaProofContextStateAccount"
434+
} else {
435+
"feeSigmaProofRecordAccount"
436+
};
392437
map.insert(
393-
"feeSigmaProofAccount".to_string(),
438+
label.to_string(),
394439
json!(account_keys[account_indexes[offset] as usize].to_string()),
395440
);
396441
offset += 1;
397442
}
398443
if offset < account_indexes.len() - 1 {
444+
let label = if range_proof_instruction_offset == 0 {
445+
"rangeProofContextStateAccount"
446+
} else {
447+
"rangeProofRecordAccount"
448+
};
399449
map.insert(
400-
"rangeProofAccount".to_string(),
450+
label.to_string(),
401451
json!(account_keys[account_indexes[offset] as usize].to_string()),
402452
);
403453
offset += 1;

0 commit comments

Comments
 (0)