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

Pot Page: Settings tab #123

Merged
merged 194 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
194 commits
Select commit Hold shift + click to select a range
0efc9c1
wip
carina-akaia Jul 2, 2024
ca2ac05
wip
carina-akaia Jul 2, 2024
c8e76f7
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Jul 2, 2024
23a27d5
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Jul 3, 2024
0acc8be
Create navigation helper library
carina-akaia Jul 3, 2024
b34ea3d
Implement search parameters cleanup
carina-akaia Jul 4, 2024
b39a927
Use `null` for search parameters cleanup
carina-akaia Jul 4, 2024
658890e
wip
carina-akaia Jul 4, 2024
c3c3f97
wip
carina-akaia Jul 4, 2024
f0c68d6
wip
carina-akaia Jul 4, 2024
bada8c8
wip
carina-akaia Jul 4, 2024
883927c
wip
carina-akaia Jul 4, 2024
2fb8c5f
Fix React runtime errors
carina-akaia Jul 4, 2024
575f913
wip
carina-akaia Jul 4, 2024
75c93ba
Close modal on "View donation" click
carina-akaia Jul 4, 2024
733ce54
Merge branch '73-donation-transaction-hashes' of https://github.com/P…
carina-akaia Jul 4, 2024
6508151
wip
carina-akaia Jul 4, 2024
a2be0cf
Rollback `DONATION_MIN_NEAR_AMOUNT`
carina-akaia Jul 4, 2024
51e84a8
Rollback `DONATION_MIN_NEAR_AMOUNT`
carina-akaia Jul 4, 2024
2f2091c
feat: Handle successful donation via webapp wallets
carina-akaia Jul 5, 2024
f72f4a4
Fix tests
carina-akaia Jul 5, 2024
581eb92
Fix tests
carina-akaia Jul 5, 2024
a400fb6
Refine dataflow
carina-akaia Jul 5, 2024
d175f62
chore: Format
carina-akaia Jul 5, 2024
f308f29
Merge branch '73-donation-transaction-hashes' of https://github.com/P…
carina-akaia Jul 5, 2024
1d6ad19
wip
carina-akaia Jul 6, 2024
67efd72
wip
carina-akaia Jul 6, 2024
a069af4
wip
carina-akaia Jul 6, 2024
8cb6a6a
wip: Sync design implementation
carina-akaia Jul 6, 2024
6e11a11
wip: Require selected pot to continue
carina-akaia Jul 6, 2024
72c8958
wip
carina-akaia Jul 9, 2024
28c52a1
wip
carina-akaia Jul 9, 2024
0d76a30
wip
carina-akaia Jul 11, 2024
2ca870e
wip
carina-akaia Jul 11, 2024
2af5f3e
Extract donation verification warning component
carina-akaia Jul 11, 2024
c863c72
wip
carina-akaia Jul 11, 2024
f6f85ab
Fix type mismatches
carina-akaia Jul 11, 2024
f15f926
Fix type mismatches
carina-akaia Jul 11, 2024
9fe2f6e
Use only matching pots
carina-akaia Jul 11, 2024
71ad769
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Jul 11, 2024
f2f846d
wip
carina-akaia Jul 11, 2024
628cdb6
wip
carina-akaia Jul 15, 2024
f19a871
wip
carina-akaia Jul 17, 2024
50d5d28
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Jul 18, 2024
4bf7cdb
wip
carina-akaia Jul 18, 2024
48da7f7
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Jul 18, 2024
e133b1e
wip
carina-akaia Jul 18, 2024
3812d31
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Jul 25, 2024
8a9ad0a
fix: Use quadratic matching by default if matching pots are present
carina-akaia Jul 25, 2024
61d6643
Merge branch '71-donation-pot-donation-scenarios' of https://github.c…
carina-akaia Jul 25, 2024
b754013
wip: Adjust styles
carina-akaia Jul 26, 2024
30e082f
wip
carina-akaia Jul 26, 2024
d93d2b8
wip
carina-akaia Jul 26, 2024
fcf4280
Merge branch 'fix/072024-navigation' of https://github.com/PotLock/po…
carina-akaia Jul 30, 2024
83c2eeb
Merge branch '71-donation-pot-donation-scenarios' of https://github.c…
carina-akaia Jul 30, 2024
0d0c609
wip
carina-akaia Jul 30, 2024
3e3df36
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Jul 30, 2024
3591759
Merge branch '71-donation-pot-donation-scenarios' of https://github.c…
carina-akaia Jul 30, 2024
01c0c97
wip
carina-akaia Jul 30, 2024
c3901cc
wip
carina-akaia Jul 30, 2024
c8b2ad1
wip
carina-akaia Jul 31, 2024
08b36e1
wip
carina-akaia Aug 1, 2024
3042aee
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Aug 1, 2024
d2c4d65
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Aug 1, 2024
700ccd3
wip
carina-akaia Aug 1, 2024
820e612
wip
carina-akaia Aug 1, 2024
3d2a19a
wip
carina-akaia Aug 1, 2024
2b7d434
wip
carina-akaia Aug 5, 2024
b569bfc
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Aug 5, 2024
e9e563e
wip
carina-akaia Aug 5, 2024
8507b4f
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Aug 5, 2024
e988d40
wip
carina-akaia Aug 5, 2024
05a25c7
wip
carina-akaia Aug 8, 2024
41b1269
wip: Fix data conversion
carina-akaia Aug 8, 2024
7e2ff2d
wip: Fix data conversion
carina-akaia Aug 8, 2024
9b37c17
wip: Fix data conversion
carina-akaia Aug 8, 2024
cf45ca9
wip: Create admin management modal
carina-akaia Aug 8, 2024
740b83d
wip: Update admin management modal
carina-akaia Aug 9, 2024
a2e541c
wip: Update admin management modal
carina-akaia Aug 9, 2024
22e99f0
wip: Fix value conversions
carina-akaia Aug 9, 2024
65efe5b
wip: Fix value conversions
carina-akaia Aug 12, 2024
3837c59
chore: Format
carina-akaia Aug 12, 2024
1b2c40a
Add format + typecheck precommit hook
carina-akaia Aug 13, 2024
0f05133
Merge branch 'dx/precommit-hook' of https://github.com/PotLock/potloc…
carina-akaia Aug 13, 2024
6c4c6cd
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Aug 13, 2024
b69aa22
wip
carina-akaia Aug 13, 2024
e42e51b
wip
carina-akaia Aug 14, 2024
6ffacbb
chore: Format
carina-akaia Aug 14, 2024
2036f9e
wip
carina-akaia Aug 14, 2024
8c823a2
wip
carina-akaia Aug 14, 2024
eb7288a
wip
carina-akaia Aug 14, 2024
87c76ae
fix: Validate account existence via RPC
carina-akaia Aug 14, 2024
2e3f389
fix: Calculate valid deposit amount
carina-akaia Aug 14, 2024
ce9b062
wip
carina-akaia Aug 14, 2024
9e8a39a
wip
carina-akaia Aug 14, 2024
7c42834
wip
carina-akaia Aug 15, 2024
1605e1b
wip
carina-akaia Aug 15, 2024
b132855
wip
carina-akaia Aug 15, 2024
0d6960f
wip
carina-akaia Aug 15, 2024
054fc24
wip
carina-akaia Aug 18, 2024
87fc86d
Make admins modal reusable
carina-akaia Aug 18, 2024
0eb5421
wip
carina-akaia Aug 19, 2024
f1ef7a1
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Aug 19, 2024
e25da67
wip: Update access control module
carina-akaia Aug 19, 2024
8848f55
wip: Fix admin list live update
carina-akaia Aug 19, 2024
9aa4b0a
wip: Reorganize accounts modal layout
carina-akaia Aug 21, 2024
e345ae1
wip: Reorganize accounts modal layout
carina-akaia Aug 21, 2024
2dbb6ff
wip: Reorganize accounts modal layout
carina-akaia Aug 21, 2024
eb95df4
wip
carina-akaia Aug 21, 2024
0c81b66
chore: Cleanup
carina-akaia Aug 21, 2024
63a7ad5
chore: Use basic points total explicitly
carina-akaia Aug 21, 2024
ed4e5b9
Change modal trigger label
carina-akaia Aug 21, 2024
294f62e
wip: Update accounts modal styles
carina-akaia Aug 21, 2024
8865ff2
wip: Update accounts modal styles
carina-akaia Aug 21, 2024
c161d23
fix: Adjust checkbox behavior
carina-akaia Aug 21, 2024
543c9e1
Prepare branch for code review
carina-akaia Aug 21, 2024
3695d58
Simplify `/pages` structure and routing
carina-akaia Aug 21, 2024
264770c
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Aug 23, 2024
0091244
wip
carina-akaia Aug 24, 2024
4583fb9
Update env variables and constants
carina-akaia Aug 25, 2024
29db501
chore: Format
carina-akaia Aug 25, 2024
9753f73
Generate UnoCSS themes
carina-akaia Aug 25, 2024
834bb65
Relocate layout details on domain basis & Update styles
carina-akaia Aug 25, 2024
40aa1a2
Rollback classname
carina-akaia Aug 25, 2024
80bdd82
Enable Redux DevTools trace, throw errors on deployment failure
carina-akaia Aug 25, 2024
5d18ede
wip
carina-akaia Aug 26, 2024
63a0b34
wip: Debug deposit calculation
carina-akaia Aug 26, 2024
326c414
wip: Debug deposit calculation
carina-akaia Aug 26, 2024
a3b0e43
chore: Format & Delete dead code
carina-akaia Aug 26, 2024
182272e
wip
carina-akaia Aug 26, 2024
2d6b438
wip
carina-akaia Aug 26, 2024
ca556b7
Fix deposit calculation
carina-akaia Aug 26, 2024
06f23fa
Make sure EVERY contract validation is duplicated on frontend
carina-akaia Aug 27, 2024
634cbf9
chore: Format
carina-akaia Aug 27, 2024
b41db31
Clamp fee input on 0-100
carina-akaia Aug 27, 2024
ef5a099
wip: Fix cross-field form validations
carina-akaia Aug 27, 2024
908ad12
wip: Fix cross-field form validations
carina-akaia Aug 27, 2024
97b52c5
Add default values & improve validation
carina-akaia Aug 27, 2024
2282af7
Fix basis points
carina-akaia Aug 27, 2024
29089f2
Temporarily disable Sybil Resistance option
carina-akaia Aug 28, 2024
d516b4b
Temporarily disable Sybil Resistance option
carina-akaia Aug 28, 2024
e212782
Restore pot.ts
carina-akaia Aug 28, 2024
9c5c98e
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Aug 28, 2024
3be9b6e
Fix avatar loading
carina-akaia Aug 28, 2024
5cffeae
Fix registry provider ID format
carina-akaia Aug 28, 2024
976649c
Turn default providers back on
carina-akaia Aug 28, 2024
6371bfb
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Aug 29, 2024
abcbb04
Fix validation error handling & Adjust gas
carina-akaia Aug 29, 2024
cba2c31
Fix live update for filtered pots
carina-akaia Aug 29, 2024
756b2ef
Fix favicon
carina-akaia Aug 29, 2024
2391d8b
Fix bignum conversion
carina-akaia Aug 29, 2024
5faab35
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Aug 30, 2024
726486b
Use testnet Nadabot link for testnet environments
carina-akaia Aug 30, 2024
10193a3
wip
carina-akaia Aug 30, 2024
cddc045
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Aug 30, 2024
e0ef2fa
wip
carina-akaia Aug 31, 2024
00f3ba7
wip
carina-akaia Aug 31, 2024
515fa76
wip
carina-akaia Aug 31, 2024
0641dbe
wip
carina-akaia Aug 31, 2024
a2feee0
wip
carina-akaia Sep 2, 2024
ab63f48
Extract pot editor module
carina-akaia Sep 3, 2024
8b08050
Update types
carina-akaia Sep 3, 2024
914c235
wip: Improve error handling
carina-akaia Sep 3, 2024
42bb987
wip
carina-akaia Sep 3, 2024
7359984
wip
carina-akaia Sep 3, 2024
794043a
wip
carina-akaia Sep 3, 2024
017ee22
wip
carina-akaia Sep 4, 2024
ced781b
chore: Format
carina-akaia Sep 4, 2024
c90f863
wip
carina-akaia Sep 4, 2024
e3a555e
wip
carina-akaia Sep 4, 2024
e894cb5
wip
carina-akaia Sep 4, 2024
098f7e1
wip
carina-akaia Sep 5, 2024
500f832
wip
carina-akaia Sep 6, 2024
1335124
wip
carina-akaia Sep 6, 2024
009f041
wip: Update styles
carina-akaia Sep 6, 2024
aac6fd7
wip
carina-akaia Sep 6, 2024
b58e6d6
wip
carina-akaia Sep 9, 2024
8e8b9c0
wip
carina-akaia Sep 9, 2024
24e11bf
wip
carina-akaia Sep 9, 2024
b5339f2
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Sep 9, 2024
3d14911
Remove dead code
carina-akaia Sep 9, 2024
208126f
wip
carina-akaia Sep 9, 2024
8ef1fc1
Fix datetime-local field format
carina-akaia Sep 9, 2024
547c0b5
wip
carina-akaia Sep 9, 2024
8ea0684
wip
carina-akaia Sep 9, 2024
5ce489f
wip
carina-akaia Sep 9, 2024
d610301
wip
carina-akaia Sep 9, 2024
74e4bc1
wip
carina-akaia Sep 9, 2024
6aab899
wip
carina-akaia Sep 9, 2024
91ad46b
wip
carina-akaia Sep 9, 2024
642fbc2
wip
carina-akaia Sep 9, 2024
bd1970e
wip
carina-akaia Sep 9, 2024
ad1d264
wip
carina-akaia Sep 9, 2024
44fe468
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Sep 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"cSpell.words": [
"Attributify",
"bitget",
"builddao",
"camelcase",
"cmdk",
"colocation",
Expand All @@ -35,6 +36,7 @@
"sessionid",
"shadcn",
"socialdb",
"svgr",
"typecheck",
"unocss",
"welldone",
Expand Down
29 changes: 29 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,35 @@ const nextConfig = {
},
],
},

webpack(config) {
// Grab the existing rule that handles SVG imports
const fileLoaderRule = config.module.rules.find((rule) =>
rule.test?.test?.(".svg"),
);

config.module.rules.push(
// Reapply the existing rule, but only for svg imports ending in ?url
{
...fileLoaderRule,
test: /\.svg$/i,
resourceQuery: /url/, // *.svg?url
},

// Convert all other *.svg imports to React components
{
test: /\.svg$/i,
issuer: fileLoaderRule.issuer,
resourceQuery: { not: [...fileLoaderRule.resourceQuery.not, /url/] }, // exclude if *.svg?url
use: ["@svgr/webpack"],
},
);

// Modify the file loader rule to ignore *.svg, since we have it handled now.
fileLoaderRule.exclude = /\.svg$/i;

return config;
},
};

export default nextConfig;
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "nextjs-app",
"version": "0.1.0",
"packageManager": "yarn@1.22.22",
"private": true,
"type": "module",
"scripts": {
Expand Down Expand Up @@ -99,6 +100,7 @@
"zod": "^3.23.8"
},
"devDependencies": {
"@svgr/webpack": "^8.1.0",
"@testing-library/react": "^15.0.7",
"@types/big.js": "^6.2.2",
"@types/node": "^20",
Expand Down Expand Up @@ -134,4 +136,4 @@
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"
}
}
}
16 changes: 0 additions & 16 deletions src/app/layout.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/common/api/near.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import naxios from "@wpdas/naxios";

import { FULL_TGAS, NETWORK, SOCIAL_DB_CONTRACT_ID } from "@/common/constants";

export const RPC_NODE_URL = `https://${NETWORK === "mainnet" ? "free.rpc.fastnear.com" : "rpc.testnet.near.org"}`;
export const RPC_NODE_URL = `https://${NETWORK === "mainnet" ? "free.rpc.fastnear.com" : "test.rpc.fastnear.com"}`;

// Naxios (Contract/Wallet) Instance
export const naxiosInstance = new naxios({
Expand Down
30 changes: 30 additions & 0 deletions src/common/assets/svgs/chef-hat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/common/assets/svgs/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as ChefHat } from "./chef-hat.svg";
export { WarningIcon } from "./warning";
export { GroupIcon } from "./group";
export { CopyPasteIcon } from "./CopyPasteIcon";
Expand Down
1 change: 0 additions & 1 deletion src/common/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Network } from "@wpdas/naxios";
import { AxiosRequestConfig } from "axios";
import Big from "big.js";
import { utils } from "near-api-js";
import { Metadata } from "next";
Expand Down
13 changes: 3 additions & 10 deletions src/common/contracts/potlock/donate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,15 @@ export const getConfig = () => contractApi.view<{}, Config>("get_config");
* Get direct donations
*/
export const getDonations = (args: { fromIndex?: number; limit?: number }) =>
contractApi.view<typeof args, DirectDonation[]>("get_donations", {
args,
});
contractApi.view<typeof args, DirectDonation[]>("get_donations", { args });

/**
* Get donations for a recipient id
*/
export const getDonationsForRecipient = (args: { recipient_id: string }) =>
contractApi.view<typeof args, DirectDonation[]>(
"get_donations_for_recipient",
{
args,
},
{ args },
);

/**
Expand All @@ -51,10 +47,7 @@ export const getDonationsForDonor = (args: { donor_id: string }) =>
args,
});

export const donateNearDirectly = (
args: DirectDonationArgs,
depositAmountYocto: string,
) =>
export const donate = (args: DirectDonationArgs, depositAmountYocto: string) =>
contractApi.call<typeof args, DirectDonation>("donate", {
args,
deposit: depositAmountYocto,
Expand Down
7 changes: 6 additions & 1 deletion src/common/contracts/potlock/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import * as donate from "./donate";
import * as pot from "./pot";
import * as potFactory from "./pot-factory";

export { potFactory };
export * from "./interfaces/pot.interfaces";
export * from "./interfaces/pot-factory.interfaces";

export { donate, pot, potFactory };
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { PotId } from "@/common/api/potlock";
import { AccountId, ProviderId } from "@/common/types";

export type Pot = {
id: string;
export type PotDeploymentResult = {
id: PotId;
deployed_by: string;
deployed_at_ms: number;
};
Expand Down Expand Up @@ -63,8 +64,3 @@ export type PotArgs = {
protocol_config_provider?: null | ProviderId;
source_metadata: ContractSourceMetadata;
};

export type PotDeploymentArgs = {
pot_args: PotArgs;
pot_handle?: null | string;
};
43 changes: 34 additions & 9 deletions src/common/contracts/potlock/interfaces/pot.interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { AccountId, ProviderId, TokenId } from "@/common/types";

export enum ApplicationStatus {
Pending = "Pending",
Approved = "Approved",
Expand Down Expand Up @@ -37,33 +39,56 @@ export interface PayoutDetailed extends Payout {
export interface PotConfig {
owner: string;
admins: string[];
chef: string;
chef?: null | string;
pot_name: string;
pot_description: string;
max_projects: number;
base_currency: "near";
base_currency: TokenId; // Only supports NEAR at the moment
application_start_ms: number;
application_end_ms: number;
public_round_start_ms: number;
public_round_end_ms: number;
deployed_by: string;
registry_provider: string;
deployed_by: AccountId;
registry_provider?: null | ProviderId;
min_matching_pool_donation_amount: string;
sybil_wrapper_provider: string;
custom_sybil_checks: null | string;
custom_min_threshold_score: null | string;
sybil_wrapper_provider?: null | ProviderId;
/** JSON string */
custom_sybil_checks?: null | string;
custom_min_threshold_score?: null | string;
referral_fee_matching_pool_basis_points: number;
referral_fee_public_round_basis_points: number;
chef_fee_basis_points: number;
matching_pool_balance: string;
total_public_donations: string;
public_donations_count: number;
payouts: Payout[];
cooldown_end_ms: number | null;
cooldown_end_ms?: null | number;
all_paid_out: boolean;
protocol_config_provider: string;
protocol_config_provider?: null | ProviderId;
}

export type UpdatePotArgs = {
owner?: null | AccountId;
admins?: null | AccountId[];
chef?: null | AccountId;
pot_name?: null | string;
pot_description?: null | string;
max_projects?: null | number;
application_start_ms?: null | number;
application_end_ms?: null | number;
public_round_start_ms?: null | number;
public_round_end_ms?: null | number;
registry_provider?: null | ProviderId;
min_matching_pool_donation_amount?: null | string;
sybil_wrapper_provider?: null | ProviderId;
/** JSON string */
custom_sybil_checks?: null | string;
custom_min_threshold_score?: null | number;
referral_fee_matching_pool_basis_points?: null | number;
referral_fee_public_round_basis_points?: null | number;
chef_fee_basis_points?: null | number;
};

export interface Challenge {
challenger_id: string;
created_at: number;
Expand Down
27 changes: 16 additions & 11 deletions src/common/contracts/potlock/pot-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import { naxiosInstance } from "@/common/api/near";
import { FULL_TGAS, POT_FACTORY_CONTRACT_ID } from "@/common/constants";
import { ByAccountId } from "@/common/types";

import { Pot, PotDeploymentArgs } from "./interfaces/pot-factory.interfaces";
import {
PotArgs,
PotDeploymentResult,
} from "./interfaces/pot-factory.interfaces";

export type { PotDeploymentResult };

/**
* Contract API
Expand All @@ -24,22 +29,22 @@ type Config = {

export const get_config = () => contractApi.view<{}, Config>("get_config");

export const calculate_min_deployment_deposit = ({
pot_args,
}: PotDeploymentArgs): Promise<undefined | string> =>
export const calculate_min_deployment_deposit = (args: {
args: PotArgs;
}): Promise<undefined | string> =>
contractApi
.view<
{ args: typeof pot_args },
string
>("calculate_min_deployment_deposit", { args: { args: pot_args } })
.view<typeof args, string>("calculate_min_deployment_deposit", { args })
.then((amount) =>
Big(amount).plus(Big("20000000000000000000000")).toFixed(),
);

export const deploy_pot = async (args: PotDeploymentArgs): Promise<Pot> =>
contractApi.call<typeof args, Pot>("deploy_pot", {
export const deploy_pot = async (args: {
pot_args: PotArgs;
pot_handle?: null | string;
}): Promise<PotDeploymentResult> =>
contractApi.call<typeof args, PotDeploymentResult>("deploy_pot", {
args,
deposit: await calculate_min_deployment_deposit(args),
deposit: await calculate_min_deployment_deposit({ args: args.pot_args }),
gas: FULL_TGAS,
callbackUrl: window.location.href,
});
Expand Down
18 changes: 17 additions & 1 deletion src/common/contracts/potlock/pot.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ONE_YOCTO } from "@builddao/near-social-js";
import { MemoryCache, calculateDepositByDataSize } from "@wpdas/naxios";
import { parseNearAmount } from "near-api-js/lib/utils/format";

Expand All @@ -13,6 +14,7 @@ import {
PotConfig,
PotDonation,
PotDonationArgs,
UpdatePotArgs,
} from "./interfaces/pot.interfaces";

/**
Expand Down Expand Up @@ -196,7 +198,7 @@ export const adminProcessPayouts = (args: { potId: string }) =>
gas: FULL_TGAS,
});

export const donateNearViaPot = (
export const donate = (
potAccountId: PotId,
args: PotDonationArgs,
depositAmountYocto: string,
Expand All @@ -206,3 +208,17 @@ export const donateNearViaPot = (
deposit: depositAmountYocto,
callbackUrl: window.location.href,
});

export const admin_dangerously_set_pot_config = (
potAccountId: PotId,
args: { update_args: UpdatePotArgs },
) =>
contractApi(potAccountId).call<typeof args, PotConfig>(
"admin_dangerously_set_pot_config",

{
args,
deposit: ONE_YOCTO,
callbackUrl: window.location.href,
},
);
25 changes: 25 additions & 0 deletions src/common/lib/datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,31 @@ export const localeStringToTimestampMs = (value: string): number => {
}
};

export const formatDatetimeLocal = (value: string): string =>
value.slice(0, 16);

export const millisecondsToDatetimeLocal = (value: number): string => {
try {
return formatDatetimeLocal(new Date(value).toISOString());
} catch {
const error = new TypeError(`Unable to parse \`${value}\``);

console.error(error);
throw error;
}
};

export const millisecondsToLocaleString = (value: number): string => {
try {
return Temporal.Instant.fromEpochMilliseconds(value).toLocaleString();
} catch {
const error = new TypeError(`Unable to parse \`${value}\``);

console.error(error);
throw error;
}
};

/**
* Converts a value in milliseconds to the equivalent number of days.
*
Expand Down
2 changes: 1 addition & 1 deletion src/common/ui/components/Spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ type Props = {
height?: number;
};

const Spinner = ({ width = 18, height = 18 }: Props) => {
export const Spinner = ({ width = 18, height = 18 }: Props) => {
return (
<span
className={`loader h-[${height}px] w-[${width}px] border-[2px]`}
Expand Down
2 changes: 1 addition & 1 deletion src/common/ui/components/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const AlertTitle = forwardRef<
<h5
ref={ref}
className={cn(
"prose font-500 important:pl-8 leading-5 tracking-normal text-neutral-950",
"prose font-500 important:pl-8 leading-5 tracking-normal",
className,
)}
{...props}
Expand Down
Loading
Loading