-
Notifications
You must be signed in to change notification settings - Fork 17
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
Remove deprecated position state #763
Conversation
let positionState = new PositionState({ | ||
state: PositionState_PositionStateEnum.WITHDRAWN, | ||
sequence: action.value.sequence, | ||
}); | ||
const metadata = getLpNftMetadata(action.value.positionId, positionState); | ||
await this.indexedDb.saveAssetsMetadata(metadata); |
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.
By default we save the withdrawn lpnft asset with sequence=0, we must additionally save the withdrawn lpnft asset with the sequence we detect
#[wasm_bindgen] | ||
pub fn get_lpnft_asset( | ||
&mut self, | ||
position_value: JsValue, | ||
position_state_value: JsValue, | ||
) -> Result<JsValue, Error> { | ||
utils::set_panic_hook(); | ||
|
||
let position: Position = serde_wasm_bindgen::from_value(position_value)?; | ||
let position_state = serde_wasm_bindgen::from_value(position_state_value)?; | ||
let lp_nft = LpNft::new(position.id(), position_state); | ||
let denom = lp_nft.denom(); | ||
serde_wasm_bindgen::to_value(&denom) | ||
} |
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.
This is not part of the view server actually, moved to dex.rs
]; | ||
|
||
for (const tx of txs) { | ||
for (const { action } of tx.body?.actions ?? []) { | ||
if (action.case === 'positionOpen' && action.value.position) { | ||
for (const state of positionStates) { | ||
const positionState = new PositionState({ state }); | ||
const metadata = this.viewServer.getLpNftMetadata(action.value.position, positionState); | ||
const metadata = getLpNftMetadata(computePositionId(action.value.position), state); |
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.
Now getLpNftMetadata()
only requires PositionId
, not Position
. This makes its use more versatile
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.
Nice catch! Just one comment.
packages/wasm/src/dex.ts
Outdated
const result = get_lpnft_asset(positionId.toJson(), positionState.toJson()) as JsonValue; | ||
return Metadata.fromJsonString(JSON.stringify(result)); |
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.
Do we have to stringify? Can we not do:
return Metadata.fromJson(result);
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.
You're right, it works without stringify
This fixes the errors during synchronization that I discovered
Related to penumbra-zone/penumbra#3883
The issue is that
PositionState_PositionStateEnum.CLAIMED
was marked as deprecated in proto, yet was removed from the rust codebase. This was causing wasm to error and stop synchronization, which caused us to not save the block completely.