Skip to content

Commit

Permalink
merge with dev
Browse files Browse the repository at this point in the history
  • Loading branch information
phn210 committed Jan 24, 2024
2 parents 97b4d44 + cff0ef9 commit c3e6f31
Show file tree
Hide file tree
Showing 18 changed files with 1,912 additions and 643 deletions.
13 changes: 13 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
BERKELEY_MINA=
BERKELEY_ARCHIVE=
BERKELEY_COMMITTEE_ADDRESS=
BERKELEY_DKG_ADDRESS=
BERKELEY_ROUND_1_ADDRESS=
BERKELEY_ROUND_2_ADDRESS=
BERKELEY_REQUEST_ADDRESS=
BERKELEY_RESPONSE_ADDRESS=
BERKELEY_PROJECT_ADDRESS=
BERKELEY_CAMPAIGN_ADDRESS=
BERKELEY_PARTICIPATION_ADDRESS=
BERKELEY_FUNDING_ADDRESS=
BERKELEY_TREASURY_ADDRESS=
35 changes: 35 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,41 @@
"feepayerKeyPath": "/home/huyminh/.cache/zkapp-cli/keys/myaccount.json",
"feepayerAlias": "myaccount",
"fee": "0.1"
},
"randomaccount": {
"url": "https://proxy.berkeley.minaexplorer.com/graphql",
"keyPath": "keys/randomaccount.json",
"feepayerKeyPath": "/home/huyminh/.cache/zkapp-cli/keys/myaccount.json",
"feepayerAlias": "myaccount",
"fee": "0.1"
},
"acc4": {
"url": "https://proxy.berkeley.minaexplorer.com/graphql",
"keyPath": "keys/acc4.json",
"feepayerKeyPath": "/home/huyminh/.cache/zkapp-cli/keys/myaccount.json",
"feepayerAlias": "myaccount",
"fee": "0.1"
},
"acc3": {
"url": "https://proxy.berkeley.minaexplorer.com/graphql",
"keyPath": "keys/acc3.json",
"feepayerKeyPath": "/home/huyminh/.cache/zkapp-cli/keys/myaccount.json",
"feepayerAlias": "myaccount",
"fee": "0.1"
},
"acc2": {
"url": "https://proxy.berkeley.minaexplorer.com/graphql",
"keyPath": "keys/acc2.json",
"feepayerKeyPath": "/home/huyminh/.cache/zkapp-cli/keys/myaccount.json",
"feepayerAlias": "myaccount",
"fee": "0.1"
},
"acc1": {
"url": "https://proxy.berkeley.minaexplorer.com/graphql",
"keyPath": "keys/acc1.json",
"feepayerKeyPath": "/home/huyminh/.cache/zkapp-cli/keys/myaccount.json",
"feepayerAlias": "myaccount",
"fee": "0.1"
}
}
}
79 changes: 67 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@auxo-dev/platform",
"version": "0.1.3",
"version": "0.1.5",
"description": "Auxo's On-chain Funding platform on Mina blockchain",
"author": "",
"license": "Apache-2.0",
Expand Down Expand Up @@ -65,8 +65,9 @@
"zkapp-cli": "^0.15.0"
},
"dependencies": {
"@auxo-dev/dkg": "0.2.9",
"@auxo-dev/auxo-libs": "0.3.5",
"@auxo-dev/dkg": "0.2.12",
"dotenv": "^16.3.1",
"o1js": "0.15.1"
}
}
19 changes: 18 additions & 1 deletion src/contracts/CampaignStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,23 @@ export const enum StatusEnum {
APPLICATION,
FUNDING,
ALLOCATED,
FINALIZE_ROUND_1,
FINALIZE_ROUND_1, // check this again
__LENGTH,
}

export function getStatusFromNumber(num: number): StatusEnum {
switch (num) {
case 0:
return StatusEnum.NOT_STARTED;
case 1:
return StatusEnum.APPLICATION;
case 2:
return StatusEnum.FUNDING;
case 3:
return StatusEnum.ALLOCATED;
case 4:
return StatusEnum.FINALIZE_ROUND_1;
default:
throw new Error('Invalid number');
}
}
29 changes: 11 additions & 18 deletions src/contracts/Treasury.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { FieldDynamicArray } from '@auxo-dev/auxo-libs';

import { ZkAppRef } from './SharedStorage.js';

import { Storage } from '@auxo-dev/dkg';

import {
EMPTY_LEVEL_1_TREE,
Level1CWitness,
Expand All @@ -34,7 +36,7 @@ import { ZkApp } from '@auxo-dev/dkg';

import { INSTANCE_LIMITS, ZkAppEnum } from '../constants.js';

import { Level1CWitness as indexWitness } from './ParticipationStorage.js';
import { Level1CWitness as IndexWitness } from './ParticipationStorage.js';

const DefaultLevel1Root = EMPTY_LEVEL_1_TREE().getRoot();

Expand All @@ -60,12 +62,11 @@ export class ClaimFundInput extends Struct({
projectId: Field,
requestId: Field, // TODO: Funding check requestId
payeeAddress: PublicKey, // TODO: Project check address
M: ZkApp.Request.RequestVector,
D: ZkApp.Request.RequestVector,
DWitness: MerkleMapWitness,
M: ZkApp.Request.RequestVector, // check Funding
D: ZkApp.Request.RequestVector, // check at request
DWitness: MerkleMapWitness, // TODO check request contract
investVector: InvestVector,
participationIndex: Field,
indexWitness: indexWitness,
participationIndexWitness: IndexWitness,
claimedIndex: Level1CWitness,
participationRef: ZkAppRef,
}) {
Expand Down Expand Up @@ -114,7 +115,7 @@ export const ClaimFund = ZkProgram({
});
},
},
createTreasury: {
nextStep: {
privateInputs: [
SelfProof<Void, ClaimFundProofOutput>,
TreasuryAction,
Expand Down Expand Up @@ -241,16 +242,8 @@ export class TreasuryContract extends SmartContract {
// input.participationRef.address
// );

// participationContract
// .checkParticipationIndex(
// new checkParticipationIndexInput({
// campaignId: input.campaignId,
// projectId: input.projectId,
// participationIndex: input.participationIndex,
// indexWitness: input.indexWitness,
// })
// )
// .assertEquals(Bool(true));
let participationIndex =
input.participationIndexWitness.calculateIndex();

// check if claimed
this.checkIfNotClaimed(
Expand All @@ -262,7 +255,7 @@ export class TreasuryContract extends SmartContract {
).assertEquals(Bool(true));

let claimAmount = input.investVector.get(
input.participationIndex.sub(Field(1)) // since index start from 1
participationIndex.sub(Field(1)) // since index start from 1
);

// send invest amount
Expand Down
2 changes: 2 additions & 0 deletions src/contracts/storages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import * as ProjectStorage from './ProjectStorage.js';
import * as ParticipationStorage from './ParticipationStorage.js';
import * as FundingStorage from './FundingStorage.js';
import * as TreasuryStorage from './TreasuryStorage.js';
import * as SharedStorage from './SharedStorage.js';

export {
CampaignStorage,
ProjectStorage,
ParticipationStorage,
FundingStorage,
TreasuryStorage,
SharedStorage,
};
2 changes: 1 addition & 1 deletion src/libs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function updateOutOfSnark(state: Field, action: Field[][]) {
return AccountUpdate.Actions.updateSequenceState(state, actionsHash);
}

const DEFAULT_WAIT_TIME = 7 * 60 * 1000; // 7m
const DEFAULT_WAIT_TIME = 10 * 60 * 1000; // 7m

export async function wait(time?: number): Promise<void> {
let waitTime = time || DEFAULT_WAIT_TIME;
Expand Down
Loading

0 comments on commit c3e6f31

Please sign in to comment.