Skip to content

Commit

Permalink
payable attribute - #[payable] in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Dec 23, 2024
1 parent 9fa14b5 commit 0fad48a
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ pub trait Contract:
#[init]
fn init(&self) {}

#[payable("*")]
#[payable]
#[endpoint(sellToken)]
fn sell_token_endpoint(&self) {
self.sell_token::<FunctionSelector<Self::Api>>();
}

#[payable("*")]
#[payable]
#[endpoint(buyToken)]
fn buy_token_endpoint(
&self,
Expand All @@ -42,7 +42,7 @@ pub trait Contract:
}

#[endpoint(deposit)]
#[payable("*")]
#[payable]
fn deposit_endpoint(&self, payment_token: OptionalValue<TokenIdentifier>) {
self.deposit::<FunctionSelector<Self::Api>>(payment_token)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub trait Crowdfunding {
}

#[endpoint]
#[payable("*")]
#[payable]
fn fund(&self) {
let (token, _, payment) = self.call_value().egld_or_single_esdt().into_tuple();

Expand Down
4 changes: 2 additions & 2 deletions contracts/examples/digital-cash/src/pay_fee_and_fund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{constants::*, helpers, storage};
#[multiversx_sc::module]
pub trait PayFeeAndFund: storage::StorageModule + helpers::HelpersModule {
#[endpoint(payFeeAndFundESDT)]
#[payable("*")]
#[payable]
fn pay_fee_and_fund_esdt(&self, address: ManagedAddress, valability: u64) {
let mut payments = self.call_value().all_esdt_transfers().clone();
let fee = EgldOrEsdtTokenPayment::from(payments.get(0).clone());
Expand All @@ -32,7 +32,7 @@ pub trait PayFeeAndFund: storage::StorageModule + helpers::HelpersModule {
}

#[endpoint]
#[payable("*")]
#[payable]
fn fund(&self, address: ManagedAddress, valability: u64) {
require!(!self.deposit(&address).is_empty(), FEES_NOT_COVERED_ERR_MSG);
let deposit_mapper = self.deposit(&address).get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub trait SignatureOperationsModule: storage::StorageModule + helpers::HelpersMo
}

#[endpoint]
#[payable("*")]
#[payable]
fn forward(
&self,
address: ManagedAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub trait EsdtTransferWithFee {
self.tx().to(ToCaller).payment(fees).transfer();
}

#[payable("*")]
#[payable]
#[endpoint]
fn transfer(&self, address: ManagedAddress) {
require!(
Expand Down
4 changes: 2 additions & 2 deletions contracts/examples/fractional-nfts/src/fractional_nfts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub trait FractionalNfts: default_issue_callbacks::DefaultIssueCallbacksModule {
.async_call_and_exit();
}

#[payable("*")]
#[payable]
#[endpoint(fractionalizeNFT)]
fn fractionalize_nft(
&self,
Expand Down Expand Up @@ -97,7 +97,7 @@ pub trait FractionalNfts: default_issue_callbacks::DefaultIssueCallbacksModule {
.transfer();
}

#[payable("*")]
#[payable]
#[endpoint(unFractionalizeNFT)]
fn unfractionalize_nft(&self) {
let fractional_payment = self.call_value().single_esdt();
Expand Down
2 changes: 1 addition & 1 deletion contracts/examples/lottery-esdt/src/lottery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub trait Lottery {
}

#[endpoint]
#[payable("*")]
#[payable]
fn buy_ticket(&self, lottery_name: ManagedBuffer) {
let (token_identifier, payment) = self.call_value().egld_or_single_fungible_esdt();

Expand Down
2 changes: 1 addition & 1 deletion contracts/examples/multisig/src/multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub trait Multisig:
}

/// Allows the contract to receive funds even if it is marked as unpayable in the protocol.
#[payable("*")]
#[payable]
#[endpoint]
fn deposit(&self) {}

Expand Down
2 changes: 1 addition & 1 deletion contracts/examples/nft-minter/src/nft_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub trait NftModule {

// endpoints

#[payable("*")]
#[payable]
#[endpoint(buyNft)]
fn buy_nft(&self, nft_nonce: u64) {
let payment = self.call_value().egld_or_single_esdt();
Expand Down
6 changes: 3 additions & 3 deletions contracts/examples/nft-subscription/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub trait NftSubscription:
.transfer();
}

#[payable("*")]
#[payable]
#[endpoint]
fn update_attributes(&self, attributes: ManagedBuffer) {
let payment = self.call_value().single_esdt();
Expand All @@ -65,7 +65,7 @@ pub trait NftSubscription:
.transfer();
}

#[payable("*")]
#[payable]
#[endpoint]
fn renew(&self, duration: u64) {
let payment = self.call_value().single_esdt();
Expand All @@ -84,7 +84,7 @@ pub trait NftSubscription:
.transfer();
}

#[payable("*")]
#[payable]
#[endpoint]
fn cancel(&self) {
let payment = self.call_value().single_esdt();
Expand Down
4 changes: 2 additions & 2 deletions contracts/examples/order-book/pair/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub trait Pair:
self.second_token_id().set_if_empty(&second_token_id);
}

#[payable("*")]
#[payable]
#[endpoint(createBuyOrder)]
fn create_buy_order_endpoint(&self, params: OrderInputParams<Self::Api>) {
self.require_global_op_not_ongoing();
Expand All @@ -34,7 +34,7 @@ pub trait Pair:
self.create_order(payment, params, common::OrderType::Buy);
}

#[payable("*")]
#[payable]
#[endpoint(createSellOrder)]
fn create_sell_order_endpoint(&self, params: OrderInputParams<Self::Api>) {
self.require_global_op_not_ongoing();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub trait RewardsDistribution:
self.brackets().set(brackets);
}

#[payable("*")]
#[payable]
#[endpoint(depositRoyalties)]
fn deposit_royalties(&self) {
let payment = self.call_value().egld_or_single_esdt();
Expand Down Expand Up @@ -247,7 +247,7 @@ pub trait RewardsDistribution:
);
}

#[payable("*")]
#[payable]
#[endpoint(claimRewards)]
fn claim_rewards(
&self,
Expand Down
2 changes: 1 addition & 1 deletion contracts/examples/seed-nft-minter/src/nft_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub trait NftModule:

// endpoints

#[payable("*")]
#[payable]
#[endpoint(buyNft)]
fn buy_nft(&self, nft_nonce: u64) {
let payment = self.call_value().egld_or_single_esdt();
Expand Down

0 comments on commit 0fad48a

Please sign in to comment.