aufacicenta / splitfund-contracts

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

Escrow factory #12

Closed netpoe closed 2 years ago

netpoe commented 2 years ago

🎉

We can create ConditionEscrow contracts via the EscrowFactory now. Tests working.

To deploy an EscrowFactory contract:

near deploy --wasmFile target/wasm32-unknown-unknown/release/escrow_factory.wasm --accountId escrowfactory.testnet --initFunction new

To deploy a ConditionalEscrow contract:

near call fac2.escrowfactory.testnet create_conditional_escrow '{ "name": "ce-1", "public_key": "ed25519:5APMXxJBNEbGWWiSWhWxZMzkLvnB6vdBuDQuzjpkPB7E", "args": "eyJleHBpcmVzX2F0IjoxNjQyNzA4NDgxMjQxMDAwMDAwLCJtaW5fZnVuZGluZ19hbW91bnQiOjEwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAsInJlY2lwaWVudF9hY2NvdW50X2lkIjoic3ZwZXJ2bmRlci50ZXN0bmV0In0=" }' --accountId svpervnder.testnet --gas=300000000000000 --deposit 10

The args need to be base64 encoded (make sure you remove spaces and escape the characters):

btoa("{\"expires_at\":1642708481241000000,\"min_funding_amount\":1000000000000000000000000,\"recipient_account_id\":\"svpervnder.testnet\"}")

Examples of calling the deployed ConditionalEscrow:

near call ce-1.fac2.escrowfactory.testnet get_expiration_date --accountId svpervnder.testnet

near call ce-1.fac2.escrowfactory.testnet is_deposit_allowed --accountId svpervnder.testnet

near call ce-1.fac2.escrowfactory.testnet is_withdrawal_allowed --accountId svpervnder.testnet

Proof that deposit works: https://wallet.testnet.near.org/profile/ce-1.fac2.escrowfactory.testnet

near call ce-1.fac2.escrowfactory.testnet deposit --accountId svpervnder.testnet --deposit 10