solana-developers / solana-grants

Site for hosting Community funded Solana grants
solana-grants.vercel.app
MIT License
18 stars 6 forks source link

Feat: Donations #21

Closed coszio closed 2 years ago

coszio commented 2 years ago

Context

When donating to a grant (either from a user or from a matcher) we want to deposit the money into the grant account first before releasing it to the grant creator. Once an arbitrary constrain has been cleared (e.g. a deadline has passed), the money will be transferred to the grant creator, else, the grant can be cancelled and the money be refunded to each donor.

Implementation

A Donation will be a PDA derived from a grant and a user, so a user can only have one escrow account per grant to avoid multiple escrow accounts. Users should be able to donate again, which will increase the funds of the Grant account.

Another Link account will be created along each donation, which will be derived from the grant + donation_count of it to be able to track all current donations related to the grant.

To cancel a donation requires that the grant it relates to has already been cancelled.

Action Items:

vercel[bot] commented 2 years ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
solana-grants ✅ Ready (Inspect) Visit Preview Aug 6, 2022 at 2:02AM (UTC)
coszio commented 2 years ago

Great suggestion, I'll make sure to do that when merging with your PR

vercel[bot] commented 2 years ago

@coszio is attempting to deploy a commit to the Solana Team on Vercel.

A member of the Team first needs to authorize it.

coszio commented 2 years ago

Just merged the changes from #23 which is already on main, which required some refactoring work on the anchor side, and a lot of it on the tests side.

buffalojoec commented 2 years ago

Did not review app yet btw

jacobcreech commented 2 years ago
./src/transactions/index.ts:3:31
--
13:33:29.618 | Type error: Cannot find module '../../../target/types/grants_program' or its corresponding type declarations.
13:33:29.618 |  
13:33:29.619 | 1 \| import * as anchor from "@project-serum/anchor";
13:33:29.619 | 2 \| import { Program } from "@project-serum/anchor";
13:33:29.619 | > 3 \| import { GrantsProgram } from "../../../target/types/grants_program";
buffalojoec commented 2 years ago

I noticed your test suite doesn't seem to want to run on my local setup:

ts-mocha -p ./tsconfig.json -t 1000000 tests/suites/donations.test.ts tests/suites/grants.test.ts

  0 passing (0ms)
buffalojoec commented 2 years ago

^ nvm got it. Assuming you just run anchor test and not anchor run test at all

jacobcreech commented 2 years ago
Type error: Property 'metadata' does not exist on type '{ version: string; name: string; instructions: { name: string; accounts: { name: string; isMut: boolean; isSigner: boolean; }[]; args: { name: string; type: string; }[]; }[]; accounts: { name: string; type: { kind: string; fields: ({ ...; } | { ...; })[]; }; }[]; types: { ...; }[]; errors: { ...; }[]; }'.