Skip to content

Commit c996000

Browse files
authored
Merge pull request #65 from PotLock/feat/donation-ft
Donation contract FT support
2 parents f57a9b7 + 168285b commit c996000

File tree

10 files changed

+740
-103
lines changed

10 files changed

+740
-103
lines changed

contracts/Cargo.lock

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/donation/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ crate-type = ["cdylib"]
99
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1010
[dependencies]
1111
near-sdk = "4.1.1"
12+
# near-sdk = "5.0.0-alpha.2"
1213
# [profile.release] # removed as added to root Cargo.toml
1314
# codegen-units = 1
1415
# # Tell `rustc` to optimize for small code size.

contracts/donation/README.md

+21
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ pub struct Donation {
7575
}
7676
```
7777

78+
### Storage
79+
80+
The storage-related methods (`storage_deposit`, `storage_withdraw` and `storage_balance_of`) are utilized for fungible token (FT) donations, where the user must prepay storage on this Donation contract - to cover the storage of the Donation data - before calling `ft_transfer_call` on the FT contract.
81+
82+
This is a simplified version of the [Storage Management standard](https://nomicon.io/Standards/StorageManagement).
83+
7884
### Contract Source Metadata
7985

8086
_NB: Below implemented as per NEP 0330 (https://github.com/near/NEPs/blob/master/neps/nep-0330.md), with addition of `commit_hash`_
@@ -120,6 +126,13 @@ pub fn donate(
120126
) -> Donation
121127

122128

129+
// STORAGE
130+
131+
pub fn storage_deposit(&mut self) -> U128
132+
133+
pub fn storage_withdraw(&mut self, amount: Option<U128>) -> U128
134+
135+
123136
// OWNER
124137

125138
#[payable]
@@ -145,6 +158,7 @@ pub fn self_set_source_metadata(&mut self, source_metadata: ContractSourceMetada
145158

146159
pub fn get_config(&self) -> Config
147160

161+
148162
// DONATIONS
149163
pub fn get_donations(&self, from_index: Option<u128>, limit: Option<u64>) -> Vec<Donation>
150164

@@ -171,10 +185,17 @@ pub fn get_donations_for_ft(
171185
limit: Option<u64>,
172186
) -> Vec<Donation>
173187

188+
189+
// STORAGE
190+
191+
pub fn storage_balance_of(&self, account_id: &AccountId) -> U128
192+
193+
174194
// OWNER
175195

176196
pub fn get_owner(&self) -> AccountId
177197

198+
178199
// SOURCE METADATA
179200

180201
pub fn get_contract_source_metadata(&self) -> Option<ContractSourceMetadata>

contracts/donation/out/main.wasm

58.6 KB
Binary file not shown.

contracts/donation/src/constants.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
use crate::*;
2+
13
pub const MAX_PROTOCOL_FEE_BASIS_POINTS: u32 = 1000;
24
pub const MAX_REFERRAL_FEE_BASIS_POINTS: u32 = 200;
35

46
pub const EVENT_JSON_PREFIX: &str = "EVENT_JSON:";
7+
8+
pub const TGAS: u64 = 1_000_000_000_000; // 1 TGAS
9+
pub const XCC_GAS_DEFAULT: u64 = TGAS * 10; // 10 TGAS
10+
pub const NO_DEPOSIT: Balance = 0;
11+
pub const ONE_YOCTO: Balance = 1;

0 commit comments

Comments
 (0)