-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Save unbonding token metadata when it's needed
- Loading branch information
1 parent
69e02d5
commit 23d0ef1
Showing
10 changed files
with
95 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
|
||
PRAX=lkpmkhpnhknhmibgnmmhdhgdilepfghe | ||
IDB_VERSION=32 | ||
IDB_VERSION=33 | ||
USDC_ASSET_ID="reum7wQmk/owgvGMWMZn/6RFPV24zIKq3W6In/WwZgg=" | ||
MINIFRONT_URL=https://app.testnet.penumbra.zone/ | ||
PENUMBRA_NODE_PD_URL=https://grpc.testnet.penumbra.zone/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use penumbra_proto::core::asset::v1::Metadata; | ||
use regex::Regex; | ||
|
||
pub static UNBONDING_TOKEN_REGEX: &str = "^uunbonding_(?P<data>start_at_(?P<start>[0-9]+)_(?P<validator>penumbravalid1(?P<id>[a-zA-HJ-NP-Z0-9]+)))$"; | ||
pub static DELEGATION_TOKEN_REGEX: &str = | ||
"^udelegation_(?P<data>penumbravalid1[a-zA-HJ-NP-Z0-9]+)$"; | ||
pub static SHORTENED_ID_LENGTH: usize = 8; | ||
|
||
pub fn customize_symbol(metadata: Metadata) -> Metadata { | ||
if let Some(unbonding_match) = Regex::new(UNBONDING_TOKEN_REGEX) | ||
.expect("regex is valid") | ||
.captures(&metadata.base) | ||
{ | ||
let id_match = unbonding_match.name(&"id").unwrap().as_str(); | ||
let shortened_id = id_match | ||
.chars() | ||
.take(SHORTENED_ID_LENGTH) | ||
.collect::<String>(); | ||
let start_match = unbonding_match.name(&"start").unwrap().as_str(); | ||
|
||
let customized = Metadata { | ||
symbol: format!("unbondUMat{start_match}({shortened_id}…)"), | ||
..metadata | ||
}; | ||
|
||
return customized; | ||
} else if let Some(delegation_match) = Regex::new(DELEGATION_TOKEN_REGEX) | ||
.expect("regex is valid") | ||
.captures(&metadata.base) | ||
{ | ||
let id_match = delegation_match.name(&"id").unwrap().as_str(); | ||
let shortened_id = id_match | ||
.chars() | ||
.take(SHORTENED_ID_LENGTH) | ||
.collect::<String>(); | ||
|
||
// let customized = metadata.clone(); | ||
let customized = Metadata { | ||
symbol: format!("delUM({shortened_id}…)"), | ||
..metadata | ||
}; | ||
|
||
return customized; | ||
} else { | ||
metadata | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters