-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix no storage -> deposit issue (#635)
* fix deposit issue * remove comment * update deposit cost
- Loading branch information
1 parent
802e892
commit 4bb2bfd
Showing
6 changed files
with
68 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// https://docs.rs/near-sdk/latest/near_sdk/env/constant.STORAGE_PRICE_PER_BYTE.html | ||
const STORAGE_PRICE_PER_BYTE = "10000000000000000000"; | ||
// https://github.com/NearSocial/social-db/blob/d28c647252ce25a06c70c3b7f4930ccdcd217fd9/contract/src/account.rs#L8C5-L8C50 | ||
const MIN_STORAGE_BYTES = "2000"; | ||
const MIN_STORAGE_COST = Big(STORAGE_PRICE_PER_BYTE).times(MIN_STORAGE_BYTES); | ||
|
||
// in case the user is new and doesn't have min storage cost, increasing the deposit | ||
function getDepositAmountForWriteAccess(userStorageDeposit) { | ||
const depositAmt = Big(userStorageDeposit?.available).gt(MIN_STORAGE_COST) | ||
? Big(10).pow(22) | ||
: Big(MIN_STORAGE_COST).plus(Big(10).pow(22)); | ||
|
||
return depositAmt; | ||
} | ||
|
||
return { getDepositAmountForWriteAccess }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters