Repository navigation
Expose Bridge V2 asset metadata #29
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,30 @@ | ||
| package api | ||
|
|
||
| import "testing" | ||
|
|
||
| func TestDecodeSyscoinBridgeAssetMetadata(t *testing.T) { | ||
| metadata := decodeSyscoinBridgeAssetMetadata("7", []byte(`{"description":"ERC20 Token","assetType":"ERC20","originDecimals":2}`)) | ||
| if metadata.Description != "ERC20 Token" || metadata.AssetType != "ERC20" { | ||
| t.Fatalf("decoded metadata = %+v", metadata) | ||
| } | ||
| if metadata.OriginDecimals == nil || *metadata.OriginDecimals != 2 { | ||
| t.Fatalf("origin decimals = %v, want 2", metadata.OriginDecimals) | ||
| } | ||
| } | ||
|
|
||
| func TestDecodeSyscoinBridgeAssetMetadataPreservesLegacyText(t *testing.T) { | ||
| metadata := decodeSyscoinBridgeAssetMetadata("7", []byte("legacy metadata")) | ||
| if metadata.Description != "legacy metadata" { | ||
| t.Fatalf("description = %q, want legacy metadata", metadata.Description) | ||
| } | ||
| if metadata.AssetType != "" || metadata.OriginDecimals != nil || metadata.TokenID != "" { | ||
| t.Fatalf("legacy metadata unexpectedly gained bridge fields: %+v", metadata) | ||
| } | ||
| } | ||
|
|
||
| func TestDecodeSyscoinBridgeAssetMetadataRecognizesLegacySYSX(t *testing.T) { | ||
| metadata := decodeSyscoinBridgeAssetMetadata("123456", []byte("Syscoin Native Asset")) | ||
| if metadata.AssetType != "SYSX" || metadata.Description != "Syscoin Native Asset" { | ||
| t.Fatalf("legacy SYSX metadata = %+v", metadata) | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
When clients consume Syscoin account balances, these fields are present in the runtime JSON but absent from both the checked-in
blockbook-api.tsTokeninterface and theTokenschema inopenapi.yaml, so generated clients cannot access the metadata without bypassing their types. The deploy check does not currently catch this omission becausecontrib/tests/run-openapi-tests.shcompares the OpenAPI schema against the already-stale checked-in TypeScript file rather than rerunning the Go typescriptify generator; update both public API artifacts alongside these fields.Useful? React with 👍 / 👎.