aufacicenta / splitfund-contracts

Sp/itfund is a co-ownership protocol built on NEAR.
https://splitfund.xyz
2 stars 1 forks source link

refactor: timestamp manipulation #11

Closed netpoe closed 2 years ago

netpoe commented 2 years ago

This refactor will return the correct DateTime formats in the contract logs:

Log [ce5.escrowfactory.testnet]: Withdrawal is only allowed after Wed Jan 19 18:48:51 2022, if the minimum of 1000000000000000000000000 NEAR is not reached. Current total funds: 0. Current block timestamp: Wed Jan 19 17:50:26 2022

And expires_at and env::block_timestamp comparisons will be almost accurate.

almost because expires_at is passed with 000000 nanoseconds.

For the frontend implementation, we should consider using https://www.npmjs.com/package/nano-time in the backend to deploy contracts with arguments:

near deploy --wasmFile target/wasm32-unknown-unknown/release/conditional_escrow.wasm --accountId ce5.escrowfactory.testnet --initFunction new --initArgs '{ "expires_at": 1642618131903000000, "min_funding_amount": 1000000000000000000000000, "recipient_account_id": "svpervnder.testnet" }'