Skip to content

Commit

Permalink
Pre-Auth manifests and nonfungibles adjustments (#252)
Browse files Browse the repository at this point in the history
* wip

* unknown resources

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip
  • Loading branch information
GhenadieVP authored Nov 4, 2024
1 parent c52270b commit 15824be
Show file tree
Hide file tree
Showing 37 changed files with 1,114 additions and 807 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ resource_tdx_2_1thw7yclz24h5xjp3086cj8z2ya0d7p9mydk0yh68c28ha02uhzrnyy = "resour
resource_tdx_2_1ntuaekqexa73m9en04jj3vdt3fk9u9kdk8q9su4efldun2y7nd3cga = "resource_tdx_2_1ntuaekqexa73m9en04jj3vdt3fk9u9kdk8q9su4efldun2y7nd3cga"
package_tdx_2_1p4lftg7zjtmvyw5dwv3fg9cxyumlrya03p5uecqdge9thje4nm5qtk = "package_tdx_2_1p4lftg7zjtmvyw5dwv3fg9cxyumlrya03p5uecqdge9thje4nm5qtk"
account_tdx_2_12yf9gd53yfep7a669fv2t3wm7nz9zeezwd04n02a433ker8vza6rhe = "account_tdx_2_12yf9gd53yfep7a669fv2t3wm7nz9zeezwd04n02a433ker8vza6rhe"
resource_tdx_2_1th4gzm9rk5s28yf5gud0a32m082g4x60d6na4ecsccte032y3xu785 = "resource_tdx_2_1th4gzm9rk5s28yf5gud0a32m082g4x60d6na4ecsccte032y3xu785"
ec4892a8ba3b86f1 = "ec4892a8ba3b86f1"
f87611f279e0daa3 = "f87611f279e0daa3"
fo = "fo"
Expand Down
2 changes: 1 addition & 1 deletion crates/sargon-uniffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "sargon-uniffi"
# Don't forget to update version in crates/sargon/Cargo.toml
version = "1.1.43"
version = "1.1.44"
edition = "2021"
build = "build.rs"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::prelude::*;
use sargon::AccountDeposit as InternalAccountDeposit;
use sargon::AccountDeposits as InternalAccountDeposits;

/// Represents an account deposit, which includes specified and unspecified resources.
#[derive(Clone, PartialEq, Eq, InternalConversion, uniffi::Record)]
pub struct AccountDeposit {
specified_resources: HashMap<ResourceAddress, SimpleResourceBounds>,
pub struct AccountDeposits {
specified_resources: Vec<SimpleResourceBounds>,
unspecified_resources: UnspecifiedResources,
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
mod account_deposit;
mod allowed_ids;
mod change_source;
mod lower_bound;
mod simple_fungible_resource_bounds;
mod simple_non_fungible_resource_bounds;
mod simple_resource_bounds;
mod unspecified_resources;
mod upper_bound;

pub use account_deposit::*;
pub use allowed_ids::*;
pub use change_source::*;
pub use lower_bound::*;
pub use simple_fungible_resource_bounds::*;
pub use simple_non_fungible_resource_bounds::*;
pub use simple_resource_bounds::*;
pub use unspecified_resources::*;
pub use upper_bound::*;
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::prelude::*;
use sargon::SimpleFungibleResourceBounds as InternalSimpleFungibleResourceBounds;
use sargon::SimpleCountedResourceBounds as InternalSimpleCountedResourceBounds;

/// Represents the bounds for a simple fungible resource, which can
/// be exact, at most, at least, between, or unknown amount.
#[derive(Clone, PartialEq, Eq, InternalConversion, uniffi::Enum)]
pub enum SimpleFungibleResourceBounds {
pub enum SimpleCountedResourceBounds {
Exact {
amount: Decimal,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@ use crate::prelude::*;
use sargon::SimpleNonFungibleResourceBounds as InternalSimpleNonFungibleResourceBounds;

/// Represents the bounds for a simple non-fungible resource, which can be either exact or not exact.
#[derive(Clone, PartialEq, Eq, InternalConversion, uniffi::Enum)]
pub enum SimpleNonFungibleResourceBounds {
Exact {
amount: Decimal,
certain_ids: Vec<NonFungibleLocalId>,
},
NotExact {
certain_ids: Vec<NonFungibleLocalId>,
lower_bound: LowerBound,
upper_bound: UpperBound,
allowed_ids: AllowedIds,
},
#[derive(Clone, PartialEq, Eq, InternalConversion, uniffi::Record)]
pub struct SimpleNonFungibleResourceBounds {
pub certain_ids: Vec<NonFungibleLocalId>,
pub additional_amount: Option<SimpleCountedResourceBounds>,
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ use sargon::SimpleResourceBounds as InternalSimpleResourceBounds;
#[derive(Clone, PartialEq, Eq, InternalConversion, uniffi::Enum)]
pub enum SimpleResourceBounds {
Fungible {
bounds: SimpleFungibleResourceBounds,
resource_address: ResourceAddress,
bounds: SimpleCountedResourceBounds,
},
NonFungible {
resource_address: ResourceAddress,
bounds: SimpleNonFungibleResourceBounds,
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ pub enum UnspecifiedResources {
NonePresent,

/// There might be non-zero balances of unspecified resources present
MayBePresent { change_sources: Vec<ChangeSource> },
MayBePresent,
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct ManifestSummary {
pub account_withdrawals: HashMap<AccountAddress, Vec<AccountWithdraw>>,

/// The deposits done in the manifest.
pub account_deposits: HashMap<AccountAddress, Vec<AccountDeposit>>,
pub account_deposits: HashMap<AccountAddress, AccountDeposits>,

/// The list of the resources of proofs that were presented in the manifest.
pub presented_proofs: Vec<ResourceSpecifier>,
Expand Down
2 changes: 1 addition & 1 deletion crates/sargon/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "sargon"
# Don't forget to update version in crates/sargon-uniffi/Cargo.toml
version = "1.1.43"
version = "1.1.44"
edition = "2021"
build = "build.rs"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ CALL_METHOD
Address("account_tdx_2_129qq7m9ttup2kn6t4g4s0dvazxplktj7vd7my76hfd7xh7ham5zeac")
"deposit"
Bucket("bucket2")
;
;
52 changes: 52 additions & 0 deletions crates/sargon/fixtures/transaction/open_subintent_fungibles.rtm
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
ASSERT_WORKTOP_RESOURCES_INCLUDE
Map<Address, Enum>(
Address("resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc") => Enum<ResourceConstraint::General>(
Tuple(
Array<NonFungibleLocalId>(),
Enum<LowerBound::NonZero>(),
Enum<UpperBound::Unbounded>(),
Enum<AllowedIds::Any>()
)
),
Address("resource_tdx_2_1th4gzm9rk5s28yf5gud0a32m082g4x60d6na4ecsccte032y3xu785") => Enum<ResourceConstraint::General>(
Tuple(
Array<NonFungibleLocalId>(),
Enum<LowerBound::Inclusive>(Decimal("6")),
Enum<UpperBound::Unbounded>(),
Enum<AllowedIds::Any>()
)
),
Address("resource_tdx_2_1tkd957yt3rwqze7elmzlphfjnmfyzkf9l5rau5ccsx9h2vs9nq3tzp") => Enum<ResourceConstraint::General>(
Tuple(
Array<NonFungibleLocalId>(),
Enum<LowerBound::NonZero>(),
Enum<UpperBound::Inclusive>(Decimal("10")),
Enum<AllowedIds::Any>()
)
),
Address("resource_tdx_2_1t5jcmwqx39ym7fw0hrlpnxwechr0mzlgulcfcye59qm9y9fa5uvdrd") => Enum<ResourceConstraint::General>(
Tuple(
Array<NonFungibleLocalId>(),
Enum<LowerBound::Inclusive>(Decimal("100")),
Enum<UpperBound::Inclusive>(Decimal("159")),
Enum<AllowedIds::Any>()
)
),
Address("resource_tdx_2_1t5dapa24l4xvwqtqe2jrdphtn7ga46gw67wr9fwn4gp532myfjqpck") => Enum<ResourceConstraint::General>(
Tuple(
Array<NonFungibleLocalId>(),
Enum<LowerBound::Inclusive>(Decimal("3")),
Enum<UpperBound::Inclusive>(Decimal("3")),
Enum<AllowedIds::Any>()
)
),
)
;

CALL_METHOD
Address("account_tdx_2_129rfcz44zxflyaf6d65fdvaqtk5rlvdu8nzek2nz435zknhqure2xl")
"deposit_batch"
Expression("ENTIRE_WORKTOP")
;

YIELD_TO_PARENT;
Loading

0 comments on commit 15824be

Please sign in to comment.