Skip to content

Commit

Permalink
feat(proto): update ics20 withdrawal to have a memo field (#1056)
Browse files Browse the repository at this point in the history
## Summary
update ics20 withdrawal to have a memo field as we'll need it for
bridging (and good to have in general)

## Changes
- update ics20 withdrawal to have a memo field

## Testing
n/a

## Breaking Changelist
- `Ics20Withdrawal` now contains a `memo` field
  • Loading branch information
noot authored May 9, 2024
1 parent 6a12eb8 commit 570002d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion crates/astria-core/src/protocol/transaction/v1alpha1/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,8 @@ pub struct Ics20Withdrawal {
source_channel: ChannelId,
// the asset to use for fee payment.
fee_asset_id: asset::Id,
// a memo to include with the transfer
memo: String,
}

impl Ics20Withdrawal {
Expand Down Expand Up @@ -719,14 +721,19 @@ impl Ics20Withdrawal {
&self.fee_asset_id
}

#[must_use]
pub fn memo(&self) -> &str {
&self.memo
}

#[must_use]
pub fn to_fungible_token_packet_data(&self) -> FungibleTokenPacketData {
FungibleTokenPacketData {
amount: self.amount.to_string(),
denom: self.denom.to_string(),
sender: self.return_address.to_string(),
receiver: self.destination_chain_address.clone(),
memo: String::new(),
memo: self.memo.clone(),
}
}

Expand All @@ -741,6 +748,7 @@ impl Ics20Withdrawal {
timeout_time: self.timeout_time,
source_channel: self.source_channel.to_string(),
fee_asset_id: self.fee_asset_id.get().to_vec(),
memo: self.memo.clone(),
}
}

Expand All @@ -755,6 +763,7 @@ impl Ics20Withdrawal {
timeout_time: self.timeout_time,
source_channel: self.source_channel.to_string(),
fee_asset_id: self.fee_asset_id.get().to_vec(),
memo: self.memo,
}
}

Expand Down Expand Up @@ -789,6 +798,7 @@ impl Ics20Withdrawal {
.map_err(Ics20WithdrawalError::invalid_source_channel)?,
fee_asset_id: asset::Id::try_from_slice(&proto.fee_asset_id)
.map_err(Ics20WithdrawalError::invalid_fee_asset_id)?,
memo: proto.memo,
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ message Ics20Withdrawal {
string source_channel = 7;
// the asset used to pay the transaction fee
bytes fee_asset_id = 8;
// a memo to include with the transfer
string memo = 9;
}

message IbcHeight {
Expand Down

0 comments on commit 570002d

Please sign in to comment.