Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Switching back to u64
  • Loading branch information
blockiosaurus committed Aug 18, 2024
commit c4fb33e726934d0ce1cb81c5b6265286f4571fe1
4 changes: 2 additions & 2 deletions clients/js/src/generated/types/baseTreasury.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @see https://github.com/metaplex-foundation/kinobi
*/

import { Serializer, i64, struct } from '@metaplex-foundation/umi/serializers';
import { Serializer, struct, u64 } from '@metaplex-foundation/umi/serializers';

export type BaseTreasury = { withdrawn: bigint };

Expand All @@ -16,7 +16,7 @@ export function getBaseTreasurySerializer(): Serializer<
BaseTreasuryArgs,
BaseTreasury
> {
return struct<BaseTreasury>([['withdrawn', i64()]], {
return struct<BaseTreasury>([['withdrawn', u64()]], {
description: 'BaseTreasury',
}) as Serializer<BaseTreasuryArgs, BaseTreasury>;
}
2 changes: 1 addition & 1 deletion clients/rust/src/generated/types/treasury.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ use borsh::{BorshDeserialize, BorshSerialize};
#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Treasury {
pub withdrawn: i64,
pub withdrawn: u64,
}
2 changes: 1 addition & 1 deletion idls/mpl_core.json
Original file line number Diff line number Diff line change
Expand Up @@ -3059,7 +3059,7 @@
"fields": [
{
"name": "withdrawn",
"type": "i64"
"type": "u64"
}
]
}
Expand Down
6 changes: 2 additions & 4 deletions programs/mpl-core/src/plugins/treasury.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use super::{
#[derive(Clone, BorshSerialize, BorshDeserialize, Default, Debug, PartialEq, Eq)]
pub struct Treasury {
/// How much SOL has been withdrawn from the treasury, in lamports
pub withdrawn: i64,
pub withdrawn: u64,
}

impl PluginValidation for Treasury {
Expand Down Expand Up @@ -77,9 +77,7 @@ impl PluginValidation for Treasury {
let diff: u64 = treasury
.withdrawn
.checked_sub(self.withdrawn)
.ok_or(MplCoreError::NumericalOverflow)?
.try_into()
.map_err(|_| MplCoreError::NumericalOverflow)?;
.ok_or(MplCoreError::NumericalOverflow)?;

if diff > excess_rent {
return Err(MplCoreError::CannotOverdraw.into());
Expand Down