Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement payout justification publishing #342

Merged
merged 14 commits into from
Feb 16, 2025
Prev Previous commit
Next Next commit
wip
carina-akaia committed Feb 11, 2025
commit 2302e593d6899f6314dcecec014dbfb435d783fd
31 changes: 18 additions & 13 deletions src/common/contracts/core/pot/client.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { MemoryCache, calculateDepositByDataSize } from "@wpdas/naxios";
import { parseNearAmount } from "near-api-js/lib/utils/format";

import { PotId } from "@/common/api/indexer";
import { type ByPotId, PotId } from "@/common/api/indexer";
import { nearProtocolClient } from "@/common/blockchains/near-protocol";
import { FULL_TGAS, ONE_HUNDREDTH_NEAR } from "@/common/constants";
import type { AccountId } from "@/common/types";

import {
Application,
@@ -132,20 +133,24 @@ export const chef_set_application_status = (args: {
gas: FULL_TGAS,
});

/**
* Admin update round payout Challenge
*/
export const admin_update_payouts_challenge = (args: {
potId: string;
challengerId: string;
notes: string;
shouldResolveChallenge: boolean;
}) => {
const depositFloat = args.notes.length * 0.00003;
export type PayoutChallengeUpdateArgs = {
challenger_id: AccountId;
notes?: null | string;
resolve_challenge: boolean;
};

contractApi(args.potId).call<typeof args, Challenge[]>("admin_update_payouts_challenge", {
export const admin_update_payouts_challenge = ({
potId,
args,
}: ByPotId & { args: PayoutChallengeUpdateArgs }) => {
return contractApi(potId).call<typeof args, void>("admin_update_payouts_challenge", {
args,
deposit: `${depositFloat}`,

deposit:
parseNearAmount(calculateDepositByDataSize(args)) ??
parseNearAmount(`${(args.notes?.length ?? 1) * 0.00003}`) ??
"0",

gas: FULL_TGAS,
});
};
21 changes: 9 additions & 12 deletions src/entities/pot/hooks/forms.ts
Original file line number Diff line number Diff line change
@@ -68,19 +68,16 @@ export const useChallengeResolveForm = ({
resolve_challenge: formData.data.resolve,
};

try {
await naxiosInstance
.contractApi({ contractId: potId })
.call("admin_update_payouts_challenge", {
args,
deposit: parseNearAmount(calculateDepositByDataSize(args))!,
gas: FULL_TGAS,
});
} catch (e) {
console.error(e);
setInProgress(false);
}
potContractClient
.admin_update_payouts_challenge({ potId, args })
.catch((error) => {
console.error(error);
})
.finally(() => {
setInProgress(false);
});
},

[potId, challengerId],
);


Unchanged files with check annotations Beta

import { useCallback } from "react";
import { useRouter } from "next/navigation";

Check failure on line 3 in src/entities/list/components/ListHero.tsx

GitHub Actions / build (20.x)

_tests/homepage.tests.tsx

Error: [vitest] There was an error when mocking a module. If you are using "vi.mock" factory, make sure there are no top level variables inside, since this call is hoisted to top of the file. Read more: https://vitest.dev/api/vi.html#vi-mock ❯ src/entities/list/components/ListHero.tsx:3:31 Caused by: ReferenceError: Cannot access '__vi_import_2__' before initialization ❯ _tests/homepage.tests.tsx:2:50 ❯ src/entities/list/components/ListHero.tsx:3:31
import { walletApi } from "@/common/blockchains/near-protocol/client";
import { Button } from "@/common/ui/components";