Skip to content

Commit d547ab3

Browse files
committed
Merge branch 'main' of https://github.com/PotLock/potlock-nextjs-app into campaign-feedback
2 parents 29f343e + c5bab79 commit d547ab3

File tree

17 files changed

+315
-113
lines changed

17 files changed

+315
-113
lines changed

.coderabbit.yaml

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
2+
3+
language: en-US
4+
tone_instructions: ""
5+
early_access: false
6+
enable_free_tier: true
7+
8+
reviews:
9+
profile: chill
10+
request_changes_workflow: false
11+
high_level_summary: true
12+
high_level_summary_placeholder: "@coderabbitai summary"
13+
high_level_summary_in_walkthrough: false
14+
auto_title_placeholder: "@coderabbitai"
15+
auto_title_instructions: ""
16+
review_status: true
17+
commit_status: true
18+
fail_commit_status: false
19+
collapse_walkthrough: false
20+
changed_files_summary: true
21+
sequence_diagrams: true
22+
assess_linked_issues: true
23+
related_issues: true
24+
related_prs: true
25+
suggested_labels: true
26+
auto_apply_labels: false
27+
suggested_reviewers: true
28+
poem: true
29+
labeling_instructions: []
30+
path_filters: []
31+
path_instructions: []
32+
abort_on_close: true
33+
auto_review:
34+
enabled: true
35+
auto_incremental_review: true
36+
ignore_title_keywords: []
37+
labels: []
38+
drafts: false
39+
base_branches: []
40+
finishing_touches:
41+
docstrings:
42+
enabled: true
43+
tools:
44+
shellcheck:
45+
enabled: true
46+
ruff:
47+
enabled: true
48+
markdownlint:
49+
enabled: true
50+
github-checks:
51+
enabled: true
52+
timeout_ms: 90000
53+
languagetool:
54+
enabled: true
55+
enabled_only: false
56+
level: default
57+
biome:
58+
enabled: true
59+
yamllint:
60+
enabled: true
61+
gitleaks:
62+
enabled: true
63+
64+
chat:
65+
auto_reply: true
66+
integrations:
67+
jira:
68+
usage: auto
69+
linear:
70+
usage: auto
71+
72+
knowledge_base:
73+
opt_out: false
74+
web_search:
75+
enabled: true
76+
learnings:
77+
scope: auto
78+
issues:
79+
scope: auto
80+
jira:
81+
usage: auto
82+
project_keys: []
83+
linear:
84+
usage: auto
85+
team_keys: []
86+
pull_requests:
87+
scope: auto
88+
89+
code_generation:
90+
docstrings:
91+
language: en-US

.vscode/settings.json

+5
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@
5454
"campaignstest",
5555
"cmdk",
5656
"codegen",
57+
"coderabbitai",
5758
"colocation",
5859
"cooldown",
5960
"data-testid",
6061
"datetime",
6162
"defi",
6263
"deployers",
64+
"docstrings",
6365
"dontcare",
6466
"Elrond",
6567
"extralight",
@@ -72,8 +74,10 @@
7274
"intear",
7375
"Jikugodwill",
7476
"kubb",
77+
"languagetool",
7578
"Linea",
7679
"linktree",
80+
"localnet",
7781
"METAPOOL",
7882
"mpdao",
7983
"mpdaovoting",
@@ -97,6 +101,7 @@
97101
"RPGF",
98102
"sessionid",
99103
"shadcn",
104+
"shellcheck",
100105
"socialdb",
101106
"Solana",
102107
"SOURCECODE",

src/common/_config/evmWalletConfig.ts

-29
This file was deleted.

src/common/blockchains/near-protocol/web3modal.ts

+37-3
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,63 @@
11
import { injected, walletConnect } from "@wagmi/connectors";
22
import { createConfig, http, reconnect } from "@wagmi/core";
33
import { createWeb3Modal } from "@web3modal/wagmi";
4+
import { Network } from "@wpdas/naxios";
45

56
import { NETWORK } from "@/common/_config";
6-
import { EVMWalletChain, projectId } from "@/common/_config/evmWalletConfig";
7+
import { NATIVE_TOKEN_ID } from "@/common/constants";
8+
9+
// Chains for EVM Wallets
10+
export const evmWalletChains = {
11+
mainnet: {
12+
chainId: 397,
13+
name: "Near Mainnet",
14+
explorer: "https://eth-explorer.near.org",
15+
rpc: "https://eth-rpc.mainnet.near.org",
16+
},
17+
18+
testnet: {
19+
chainId: 398,
20+
name: "Near Testnet",
21+
explorer: "https://eth-explorer-testnet.near.org",
22+
rpc: "https://eth-rpc.testnet.near.org",
23+
},
24+
25+
localnet: {
26+
chainId: 398,
27+
name: "Near Testnet",
28+
explorer: "https://eth-explorer-testnet.near.org",
29+
rpc: "https://eth-rpc.testnet.near.org",
30+
},
31+
};
32+
33+
export const EVMWalletChain = evmWalletChains[NETWORK as Network];
34+
35+
export const projectId = "1adabeaaefb2b771ff4ebdf902b128b7";
736

837
// Config
938
const near = {
1039
id: EVMWalletChain.chainId,
1140
name: EVMWalletChain.name,
41+
1242
nativeCurrency: {
43+
// TODO: Investigate if this is the right value
1344
decimals: 18,
14-
name: "NEAR",
15-
symbol: "NEAR",
45+
name: NATIVE_TOKEN_ID.toUpperCase(),
46+
symbol: NATIVE_TOKEN_ID.toUpperCase(),
1647
},
48+
1749
rpcUrls: {
1850
default: { http: [EVMWalletChain.rpc] },
1951
public: { http: [EVMWalletChain.rpc] },
2052
},
53+
2154
blockExplorers: {
2255
default: {
2356
name: "NEAR Explorer",
2457
url: EVMWalletChain.explorer,
2558
},
2659
},
60+
2761
testnet: NETWORK === "testnet",
2862
};
2963

src/common/constants.ts

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { Metadata } from "next";
66
import { NETWORK, PLATFORM_NAME } from "./_config";
77
import { ChronologicalSortOrderVariant, type TokenId } from "./types";
88

9+
export { PLATFORM_NAME };
10+
911
export const IS_CLIENT = typeof window !== "undefined";
1012

1113
export const DEBUG = process.env.NEXT_PUBLIC_DEBUG === "true" ? true : false;

src/common/contracts/core/campaigns/client.ts

+13-28
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import { MemoryCache } from "@wpdas/naxios";
22

33
import { CAMPAIGNS_CONTRACT_ACCOUNT_ID } from "@/common/_config";
44
import { naxiosInstance } from "@/common/blockchains/near-protocol/client";
5+
import { FULL_TGAS } from "@/common/constants";
56
import { floatToYoctoNear } from "@/common/lib";
6-
import { AccountId, ByCampaignId, CampaignId } from "@/common/types";
7+
import { AccountId, CampaignId, type IndivisibleUnits } from "@/common/types";
78

89
import {
910
Campaign,
1011
CampaignDonation,
11-
CampaignFormFields,
12+
CampaignInputs,
1213
DirectCampaignDonationArgs,
1314
} from "./interfaces";
1415

@@ -17,73 +18,57 @@ const contractApi = naxiosInstance.contractApi({
1718
cache: new MemoryCache({ expirationTime: 10 }),
1819
});
1920

20-
/**
21-
* CREATE CAMPAIGN
22-
*/
23-
24-
export const create_campaign = ({ args }: { args: CampaignFormFields }) => {
21+
export const create_campaign = ({ args }: { args: CampaignInputs }) => {
2522
return contractApi.call("create_campaign", {
2623
args,
2724
deposit: floatToYoctoNear(0.021),
28-
gas: "300000000000000",
25+
gas: FULL_TGAS,
2926
});
3027
};
3128

32-
/**
33-
* PROCESS ESCROWED DONATIONS
34-
*/
35-
3629
export const process_escrowed_donations_batch = ({
3730
args,
3831
}: {
3932
args: { campaign_id: CampaignId };
4033
}) => {
4134
return contractApi.call("process_escrowed_donations_batch", {
4235
args,
43-
gas: "300000000000000",
36+
gas: FULL_TGAS,
4437
});
4538
};
4639

47-
/**
48-
* PROCESS DONATIONS REFUND
49-
*/
50-
5140
export const process_refunds_batch = ({ args }: { args: { campaign_id: CampaignId } }) => {
5241
return contractApi.call("process_refunds_batch", {
5342
args,
54-
gas: "300000000000000",
43+
gas: FULL_TGAS,
5544
});
5645
};
5746

58-
/**
59-
* UPDATE CAMPAIGN
60-
*/
61-
6247
export const update_campaign = ({
6348
args,
6449
}: {
65-
args: CampaignFormFields & { campaign_id: CampaignId };
50+
args: CampaignInputs & { campaign_id: CampaignId };
6651
}) => {
6752
return contractApi.call<{}, Campaign>("update_campaign", {
6853
args,
6954
deposit: floatToYoctoNear(0.021),
70-
gas: "300000000000000",
55+
gas: FULL_TGAS,
7156
});
7257
};
7358

7459
export const delete_campaign = ({ args }: { args: { campaign_id: CampaignId } }) => {
7560
return contractApi.call<{}, Campaign>("delete_campaign", {
7661
args,
7762
deposit: floatToYoctoNear(0.021),
78-
gas: "300000000000000",
63+
gas: FULL_TGAS,
7964
});
8065
};
8166

82-
export const donate = (args: DirectCampaignDonationArgs, depositAmountYocto: string) =>
83-
contractApi.call<{}, Campaign>("donate", {
67+
export const donate = (args: DirectCampaignDonationArgs, depositAmountYocto: IndivisibleUnits) =>
68+
contractApi.call<{}, CampaignDonation>("donate", {
8469
args,
8570
deposit: depositAmountYocto,
86-
gas: "300000000000000",
71+
gas: FULL_TGAS,
8772
callbackUrl: window.location.href,
8873
});
8974

src/common/contracts/core/campaigns/interfaces.ts

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { AccountId, IndivisibleUnits } from "@/common/types";
1+
import { AccountId, IndivisibleUnits, type TokenId } from "@/common/types";
22

3-
export type CampaignFormFields = {
3+
export type CampaignInputs = {
44
name: string;
55
description?: string;
66
cover_image_url?: string | null;
@@ -33,20 +33,25 @@ export type Campaign = {
3333
total_raised_amount: string;
3434
};
3535

36+
/**
37+
* https://github.com/PotLock/core/blob/6a44907c1beffcfaab7e7fbc0d50be12e897c5a8/contracts/campaigns/src/donations.rs#L51
38+
*/
3639
export interface CampaignDonation {
3740
id: number;
38-
campaign_id: string;
39-
donor_id: string;
40-
recipient_id: string;
41-
message?: string;
42-
referrer_id?: string;
43-
protocol_fee: string;
44-
creator_fee?: string;
45-
ft_id: string;
46-
net_amount: string;
47-
total_amount: string;
41+
campaign_id: Campaign["id"];
42+
donor_id: AccountId;
43+
total_amount: IndivisibleUnits;
44+
net_amount: IndivisibleUnits;
45+
ft_id?: null | TokenId;
46+
message?: null | string;
4847
donated_at_ms: number;
48+
protocol_fee: IndivisibleUnits;
49+
referrer_id?: null | AccountId;
50+
referrer_fee: IndivisibleUnits;
51+
creator_fee: IndivisibleUnits;
52+
returned_at_ms?: null | number;
4953
is_in_escrow: boolean;
54+
recipient_id: AccountId;
5055
}
5156

5257
export type DirectCampaignDonationArgs = {

0 commit comments

Comments
 (0)