Skip to content

Commit

Permalink
Merge branch '2.0' into implicit-account-creation-address-sync-options
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez authored Mar 6, 2024
2 parents d6b9561 + eb1873e commit fc73ca5
Show file tree
Hide file tree
Showing 16 changed files with 696 additions and 127 deletions.
9 changes: 9 additions & 0 deletions sdk/tests/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const SLOT_COMMITMENT_ID: SlotCommitmentId = SlotCommitmentHash::null().const_in
enum Build<'a> {
Basic {
amount: u64,
mana: u64,
address: Address,
native_token: Option<(&'a str, u64)>,
sender: Option<Address>,
Expand All @@ -74,6 +75,7 @@ enum Build<'a> {
},
Nft {
amount: u64,
mana: u64,
nft_id: NftId,
address: Address,
sender: Option<Address>,
Expand All @@ -83,6 +85,7 @@ enum Build<'a> {
},
Account {
amount: u64,
mana: u64,
account_id: AccountId,
address: Address,
sender: Option<Address>,
Expand Down Expand Up @@ -111,6 +114,7 @@ impl<'a> Build<'a> {
match self {
Build::Basic {
amount,
mana,
address,
native_token,
sender,
Expand All @@ -119,6 +123,7 @@ impl<'a> Build<'a> {
expiration,
} => {
let mut builder = BasicOutputBuilder::new_with_amount(amount)
.with_mana(mana)
.add_unlock_condition(AddressUnlockCondition::new(address.clone()));

if let Some((id, amount)) = native_token {
Expand Down Expand Up @@ -149,6 +154,7 @@ impl<'a> Build<'a> {
}
Build::Nft {
amount,
mana,
nft_id,
address,
sender,
Expand All @@ -157,6 +163,7 @@ impl<'a> Build<'a> {
expiration,
} => {
let mut builder = NftOutputBuilder::new_with_amount(amount, nft_id)
.with_mana(mana)
.add_unlock_condition(AddressUnlockCondition::new(address));

if let Some(sender) = sender {
Expand All @@ -180,12 +187,14 @@ impl<'a> Build<'a> {
}
Build::Account {
amount,
mana,
account_id,
address,
sender,
issuer,
} => {
let mut builder = AccountOutputBuilder::new_with_amount(amount, account_id)
.with_mana(mana)
.add_unlock_condition(AddressUnlockCondition::new(address));

if let Some(sender) = sender {
Expand Down
7 changes: 7 additions & 0 deletions sdk/tests/client/signing/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ async fn sign_account_state_transition() -> Result<(), Box<dyn std::error::Error
[(
Account {
amount: 1_000_000,
mana: 0,
account_id: account_id,
address: address.clone(),
sender: None,
Expand All @@ -66,6 +67,7 @@ async fn sign_account_state_transition() -> Result<(), Box<dyn std::error::Error

let outputs = build_outputs([Account {
amount: 1_000_000,
mana: 0,
account_id: account_id,
address: address.clone(),
sender: None,
Expand Down Expand Up @@ -131,6 +133,7 @@ async fn account_reference_unlocks() -> Result<(), Box<dyn std::error::Error>> {
(
Account {
amount: 1_000_000,
mana: 0,
account_id: account_id,
address: address.clone(),
sender: None,
Expand All @@ -141,6 +144,7 @@ async fn account_reference_unlocks() -> Result<(), Box<dyn std::error::Error>> {
(
Basic {
amount: 1_000_000,
mana: 0,
address: account_address.clone(),
native_token: None,
sender: None,
Expand All @@ -153,6 +157,7 @@ async fn account_reference_unlocks() -> Result<(), Box<dyn std::error::Error>> {
(
Basic {
amount: 1_000_000,
mana: 0,
address: account_address.clone(),
native_token: None,
sender: None,
Expand All @@ -169,13 +174,15 @@ async fn account_reference_unlocks() -> Result<(), Box<dyn std::error::Error>> {
let outputs = build_outputs([
Account {
amount: 1_000_000,
mana: 0,
account_id: account_id,
address: address,
sender: None,
issuer: None,
},
Basic {
amount: 2_000_000,
mana: 0,
address: account_address,
native_token: None,
sender: None,
Expand Down
9 changes: 9 additions & 0 deletions sdk/tests/client/signing/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ async fn single_ed25519_unlock() -> Result<(), Box<dyn std::error::Error>> {
[(
Basic {
amount: 1_000_000,
mana: 0,
address: address_0.clone(),
native_token: None,
sender: None,
Expand All @@ -59,6 +60,7 @@ async fn single_ed25519_unlock() -> Result<(), Box<dyn std::error::Error>> {

let outputs = build_outputs([Basic {
amount: 1_000_000,
mana: 0,
address: address_0,
native_token: None,
sender: None,
Expand Down Expand Up @@ -124,6 +126,7 @@ async fn ed25519_reference_unlocks() -> Result<(), Box<dyn std::error::Error>> {
(
Basic {
amount: 1_000_000,
mana: 0,
address: address_0.clone(),
native_token: None,
sender: None,
Expand All @@ -136,6 +139,7 @@ async fn ed25519_reference_unlocks() -> Result<(), Box<dyn std::error::Error>> {
(
Basic {
amount: 1_000_000,
mana: 0,
address: address_0.clone(),
native_token: None,
sender: None,
Expand All @@ -148,6 +152,7 @@ async fn ed25519_reference_unlocks() -> Result<(), Box<dyn std::error::Error>> {
(
Basic {
amount: 1_000_000,
mana: 0,
address: address_0.clone(),
native_token: None,
sender: None,
Expand All @@ -163,6 +168,7 @@ async fn ed25519_reference_unlocks() -> Result<(), Box<dyn std::error::Error>> {

let outputs = build_outputs([Basic {
amount: 3_000_000,
mana: 0,
address: address_0,
native_token: None,
sender: None,
Expand Down Expand Up @@ -249,6 +255,7 @@ async fn two_signature_unlocks() -> Result<(), Box<dyn std::error::Error>> {
(
Basic {
amount: 1_000_000,
mana: 0,
address: address_0.clone(),
native_token: None,
sender: None,
Expand All @@ -261,6 +268,7 @@ async fn two_signature_unlocks() -> Result<(), Box<dyn std::error::Error>> {
(
Basic {
amount: 1_000_000,
mana: 0,
address: address_1,
native_token: None,
sender: None,
Expand All @@ -276,6 +284,7 @@ async fn two_signature_unlocks() -> Result<(), Box<dyn std::error::Error>> {

let outputs = build_outputs([Basic {
amount: 2_000_000,
mana: 0,
address: address_0,
native_token: None,
sender: None,
Expand Down
8 changes: 8 additions & 0 deletions sdk/tests/client/signing/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ async fn valid_creation() -> Result<(), Box<dyn std::error::Error>> {
[(
Basic {
amount: 1_000_000,
mana: 0,
address: address.clone(),
native_token: None,
sender: None,
Expand Down Expand Up @@ -135,6 +136,7 @@ async fn creation_missing_commitment_input() -> Result<(), Box<dyn std::error::E
[(
Basic {
amount: 1_000_000,
mana: 0,
address: address.clone(),
native_token: None,
sender: None,
Expand Down Expand Up @@ -197,6 +199,7 @@ async fn non_null_id_creation() -> Result<(), Box<dyn std::error::Error>> {
[(
Basic {
amount: 1_000_000,
mana: 0,
address: address.clone(),
native_token: None,
sender: None,
Expand Down Expand Up @@ -281,6 +284,7 @@ async fn mismatch_amount_creation() -> Result<(), Box<dyn std::error::Error>> {
[(
Basic {
amount: 1_000_000,
mana: 0,
address: address.clone(),
native_token: None,
sender: None,
Expand Down Expand Up @@ -365,6 +369,7 @@ async fn non_zero_end_epoch_creation() -> Result<(), Box<dyn std::error::Error>>
[(
Basic {
amount: 1_000_000,
mana: 0,
address: address.clone(),
native_token: None,
sender: None,
Expand Down Expand Up @@ -449,6 +454,7 @@ async fn invalid_start_epoch_creation() -> Result<(), Box<dyn std::error::Error>
[(
Basic {
amount: 1_000_000,
mana: 0,
address: address.clone(),
native_token: None,
sender: None,
Expand Down Expand Up @@ -1019,6 +1025,7 @@ async fn destroy_null_id() -> Result<(), Box<dyn std::error::Error>> {

let outputs = build_outputs([Basic {
amount: 1_000_000,
mana: 0,
address,
native_token: None,
sender: None,
Expand Down Expand Up @@ -1111,6 +1118,7 @@ async fn destroy_reward_missing() -> Result<(), Box<dyn std::error::Error>> {

let outputs = build_outputs([Basic {
amount: 1_000_000,
mana: 0,
address,
native_token: None,
sender: None,
Expand Down
Loading

0 comments on commit fc73ca5

Please sign in to comment.