feat: add name and description fields to ListingAccount; update form, table, detail, dashboard
This commit is contained in:
@@ -29,6 +29,8 @@ pub fn handler(
|
||||
alt_currencies: Vec<AltCurrencyConfig>,
|
||||
accepted_resolvers: Vec<Pubkey>,
|
||||
quantity: u32,
|
||||
name: String,
|
||||
description: String,
|
||||
metadata_uri: String,
|
||||
) -> Result<()> {
|
||||
let listing = &mut ctx.accounts.listing_account;
|
||||
@@ -40,6 +42,8 @@ pub fn handler(
|
||||
listing.accepted_resolvers = accepted_resolvers;
|
||||
listing.quantity = quantity;
|
||||
listing.quantity_reserved = 0;
|
||||
listing.name = name;
|
||||
listing.description = description;
|
||||
listing.metadata_uri = metadata_uri;
|
||||
listing.listing_id = listing_id;
|
||||
listing.is_active = true;
|
||||
|
||||
@@ -25,6 +25,8 @@ pub fn handler(
|
||||
alt_currencies: Vec<AltCurrencyConfig>,
|
||||
accepted_resolvers: Vec<Pubkey>,
|
||||
quantity: u32,
|
||||
name: String,
|
||||
description: String,
|
||||
metadata_uri: String,
|
||||
) -> Result<()> {
|
||||
let listing = &mut ctx.accounts.listing_account;
|
||||
@@ -34,6 +36,8 @@ pub fn handler(
|
||||
listing.alt_currencies = alt_currencies;
|
||||
listing.accepted_resolvers = accepted_resolvers;
|
||||
listing.quantity = quantity;
|
||||
listing.name = name;
|
||||
listing.description = description;
|
||||
listing.metadata_uri = metadata_uri;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -31,11 +31,14 @@ pub mod solisting {
|
||||
alt_currencies: Vec<state::AltCurrencyConfig>,
|
||||
accepted_resolvers: Vec<Pubkey>,
|
||||
quantity: u32,
|
||||
name: String,
|
||||
description: String,
|
||||
metadata_uri: String,
|
||||
) -> Result<()> {
|
||||
create_listing::handler(
|
||||
ctx, listing_id, canonical_currency, price,
|
||||
canonical_oracle, alt_currencies, accepted_resolvers, quantity, metadata_uri,
|
||||
canonical_oracle, alt_currencies, accepted_resolvers, quantity,
|
||||
name, description, metadata_uri,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -48,11 +51,14 @@ pub mod solisting {
|
||||
alt_currencies: Vec<state::AltCurrencyConfig>,
|
||||
accepted_resolvers: Vec<Pubkey>,
|
||||
quantity: u32,
|
||||
name: String,
|
||||
description: String,
|
||||
metadata_uri: String,
|
||||
) -> Result<()> {
|
||||
update_listing::handler(
|
||||
ctx, canonical_currency, price,
|
||||
canonical_oracle, alt_currencies, accepted_resolvers, quantity, metadata_uri,
|
||||
canonical_oracle, alt_currencies, accepted_resolvers, quantity,
|
||||
name, description, metadata_uri,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,10 @@ pub struct ListingAccount {
|
||||
pub quantity: u32,
|
||||
/// Units held by pending orders. available = quantity - quantity_reserved.
|
||||
pub quantity_reserved: u32,
|
||||
#[max_len(64)]
|
||||
pub name: String,
|
||||
#[max_len(256)]
|
||||
pub description: String,
|
||||
#[max_len(256)]
|
||||
pub metadata_uri: String,
|
||||
pub listing_id: u64,
|
||||
|
||||
@@ -101,6 +101,8 @@ pub fn ix_create_listing(
|
||||
alt_currencies: Vec<AltCurrencyConfig>,
|
||||
accepted_resolvers: Vec<Pubkey>,
|
||||
quantity: u32,
|
||||
name: String,
|
||||
description: String,
|
||||
metadata_uri: String,
|
||||
) -> Instruction {
|
||||
let listing_account = listing_pda(seller, listing_id);
|
||||
@@ -114,6 +116,8 @@ pub fn ix_create_listing(
|
||||
alt_currencies,
|
||||
accepted_resolvers,
|
||||
quantity,
|
||||
name,
|
||||
description,
|
||||
metadata_uri,
|
||||
}
|
||||
.data(),
|
||||
@@ -136,6 +140,8 @@ pub fn ix_update_listing(
|
||||
alt_currencies: Vec<AltCurrencyConfig>,
|
||||
accepted_resolvers: Vec<Pubkey>,
|
||||
quantity: u32,
|
||||
name: String,
|
||||
description: String,
|
||||
metadata_uri: String,
|
||||
) -> Instruction {
|
||||
let listing_account = listing_pda(seller, listing_id);
|
||||
@@ -148,6 +154,8 @@ pub fn ix_update_listing(
|
||||
alt_currencies,
|
||||
accepted_resolvers,
|
||||
quantity,
|
||||
name,
|
||||
description,
|
||||
metadata_uri,
|
||||
}
|
||||
.data(),
|
||||
|
||||
@@ -17,7 +17,7 @@ fn seller_can_create_sol_only_listing() {
|
||||
vec![],
|
||||
vec![],
|
||||
10,
|
||||
"ipfs://test".to_string(),
|
||||
"".to_string(), "".to_string(), "ipfs://test".to_string(),
|
||||
);
|
||||
send(&mut svm, &[ix], &[&seller]);
|
||||
|
||||
@@ -48,7 +48,7 @@ fn seller_can_create_listing_with_usdc_alt_stablecoin() {
|
||||
}],
|
||||
vec![],
|
||||
5,
|
||||
"ipfs://x".to_string(),
|
||||
"".to_string(), "".to_string(), "ipfs://x".to_string(),
|
||||
);
|
||||
send(&mut svm, &[ix], &[&seller]);
|
||||
|
||||
@@ -75,7 +75,7 @@ fn seller_can_create_listing_with_bonk_alt_oracle() {
|
||||
}],
|
||||
vec![],
|
||||
5,
|
||||
"".to_string(),
|
||||
"".to_string(), "".to_string(), "".to_string(),
|
||||
);
|
||||
send(&mut svm, &[ix], &[&seller]);
|
||||
|
||||
@@ -90,7 +90,7 @@ fn seller_can_update_listing() {
|
||||
let listing_id: u64 = 2;
|
||||
let ix = ix_create_listing(
|
||||
&seller.pubkey(), listing_id, Currency::Sol, 1_000_000_000,
|
||||
None, vec![], vec![], 10, "".to_string(),
|
||||
None, vec![], vec![], 10, "".to_string(), "".to_string(), "".to_string(),
|
||||
);
|
||||
send(&mut svm, &[ix], &[&seller]);
|
||||
|
||||
@@ -103,7 +103,7 @@ fn seller_can_update_listing() {
|
||||
vec![],
|
||||
vec![],
|
||||
20,
|
||||
"ipfs://new".to_string(),
|
||||
"".to_string(), "".to_string(), "ipfs://new".to_string(),
|
||||
);
|
||||
send(&mut svm, &[ix_update], &[&seller]);
|
||||
|
||||
@@ -118,7 +118,7 @@ fn seller_can_close_listing() {
|
||||
let listing_id: u64 = 3;
|
||||
let ix = ix_create_listing(
|
||||
&seller.pubkey(), listing_id, Currency::Sol, 1_000_000_000,
|
||||
None, vec![], vec![], 5, "".to_string(),
|
||||
None, vec![], vec![], 5, "".to_string(), "".to_string(), "".to_string(),
|
||||
);
|
||||
send(&mut svm, &[ix], &[&seller]);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ fn buyer_can_create_order_canonical_sol() {
|
||||
let price = 100_000_000u64;
|
||||
let ix = ix_create_listing(
|
||||
&seller.pubkey(), listing_id, Currency::Sol, price,
|
||||
None, vec![], vec![], 5, "".to_string(),
|
||||
None, vec![], vec![], 5, "".to_string(), "".to_string(), "".to_string(),
|
||||
);
|
||||
send(&mut svm, &[ix], &[&seller]);
|
||||
|
||||
@@ -42,7 +42,7 @@ fn create_order_fails_if_listing_inactive() {
|
||||
let listing_id = 2u64;
|
||||
let ix = ix_create_listing(
|
||||
&seller.pubkey(), listing_id, Currency::Sol, 1_000_000_000,
|
||||
None, vec![], vec![], 1, "".to_string(),
|
||||
None, vec![], vec![], 1, "".to_string(), "".to_string(), "".to_string(),
|
||||
);
|
||||
send(&mut svm, &[ix], &[&seller]);
|
||||
let ix_close = ix_close_listing(&seller.pubkey(), listing_id);
|
||||
@@ -62,7 +62,7 @@ fn create_order_fails_if_out_of_stock() {
|
||||
let listing_id = 3u64;
|
||||
let ix = ix_create_listing(
|
||||
&seller.pubkey(), listing_id, Currency::Sol, 100_000_000,
|
||||
None, vec![], vec![], 1, "".to_string(),
|
||||
None, vec![], vec![], 1, "".to_string(), "".to_string(), "".to_string(),
|
||||
);
|
||||
send(&mut svm, &[ix], &[&seller]);
|
||||
send(
|
||||
@@ -87,7 +87,7 @@ fn create_order_fails_if_currency_not_accepted() {
|
||||
let listing_id = 4u64;
|
||||
let ix = ix_create_listing(
|
||||
&seller.pubkey(), listing_id, Currency::Sol, 100_000_000,
|
||||
None, vec![], vec![], 5, "".to_string(),
|
||||
None, vec![], vec![], 5, "".to_string(), "".to_string(), "".to_string(),
|
||||
);
|
||||
send(&mut svm, &[ix], &[&seller]);
|
||||
|
||||
@@ -110,7 +110,7 @@ fn create_order_fails_if_resolver_not_accepted() {
|
||||
let allowed_resolver = Pubkey::new_unique();
|
||||
let ix = ix_create_listing(
|
||||
&seller.pubkey(), listing_id, Currency::Sol, 100_000_000,
|
||||
None, vec![], vec![allowed_resolver], 5, "".to_string(),
|
||||
None, vec![], vec![allowed_resolver], 5, "".to_string(), "".to_string(), "".to_string(),
|
||||
);
|
||||
send(&mut svm, &[ix], &[&seller]);
|
||||
|
||||
@@ -132,7 +132,7 @@ fn seller_accept_creates_active_descro_escrow() {
|
||||
let price = 100_000_000u64;
|
||||
send(
|
||||
&mut svm,
|
||||
&[ix_create_listing(&seller.pubkey(), listing_id, Currency::Sol, price, None, vec![], vec![], 5, "".to_string())],
|
||||
&[ix_create_listing(&seller.pubkey(), listing_id, Currency::Sol, price, None, vec![], vec![], 5, "".to_string(), "".to_string(), "".to_string())],
|
||||
&[&seller],
|
||||
);
|
||||
let order_id = 1u64;
|
||||
@@ -166,7 +166,7 @@ fn seller_can_reject_order() {
|
||||
let price = 100_000_000u64;
|
||||
send(
|
||||
&mut svm,
|
||||
&[ix_create_listing(&seller.pubkey(), listing_id, Currency::Sol, price, None, vec![], vec![], 5, "".to_string())],
|
||||
&[ix_create_listing(&seller.pubkey(), listing_id, Currency::Sol, price, None, vec![], vec![], 5, "".to_string(), "".to_string(), "".to_string())],
|
||||
&[&seller],
|
||||
);
|
||||
send(
|
||||
@@ -197,7 +197,7 @@ fn buyer_can_cancel_order() {
|
||||
let listing_id = 21u64;
|
||||
send(
|
||||
&mut svm,
|
||||
&[ix_create_listing(&seller.pubkey(), listing_id, Currency::Sol, 100_000_000, None, vec![], vec![], 5, "".to_string())],
|
||||
&[ix_create_listing(&seller.pubkey(), listing_id, Currency::Sol, 100_000_000, None, vec![], vec![], 5, "".to_string(), "".to_string(), "".to_string())],
|
||||
&[&seller],
|
||||
);
|
||||
send(
|
||||
@@ -223,7 +223,7 @@ fn reject_handles_already_cancelled_escrow() {
|
||||
let listing_id = 22u64;
|
||||
send(
|
||||
&mut svm,
|
||||
&[ix_create_listing(&seller.pubkey(), listing_id, Currency::Sol, 100_000_000, None, vec![], vec![], 5, "".to_string())],
|
||||
&[ix_create_listing(&seller.pubkey(), listing_id, Currency::Sol, 100_000_000, None, vec![], vec![], 5, "".to_string(), "".to_string(), "".to_string())],
|
||||
&[&seller],
|
||||
);
|
||||
send(
|
||||
@@ -250,7 +250,7 @@ fn anyone_can_close_stale_order_after_terminal_escrow() {
|
||||
let listing_id = 30u64;
|
||||
send(
|
||||
&mut svm,
|
||||
&[ix_create_listing(&seller.pubkey(), listing_id, Currency::Sol, 100_000_000, None, vec![], vec![], 5, "".to_string())],
|
||||
&[ix_create_listing(&seller.pubkey(), listing_id, Currency::Sol, 100_000_000, None, vec![], vec![], 5, "".to_string(), "".to_string(), "".to_string())],
|
||||
&[&seller],
|
||||
);
|
||||
send(
|
||||
@@ -284,7 +284,7 @@ fn close_stale_order_fails_if_escrow_still_active() {
|
||||
let listing_id = 31u64;
|
||||
send(
|
||||
&mut svm,
|
||||
&[ix_create_listing(&seller.pubkey(), listing_id, Currency::Sol, 100_000_000, None, vec![], vec![], 5, "".to_string())],
|
||||
&[ix_create_listing(&seller.pubkey(), listing_id, Currency::Sol, 100_000_000, None, vec![], vec![], 5, "".to_string(), "".to_string(), "".to_string())],
|
||||
&[&seller],
|
||||
);
|
||||
send(
|
||||
|
||||
Reference in New Issue
Block a user