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

Advanced FT support #214

Merged
merged 60 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
0001f5a
wip
carina-akaia Oct 28, 2024
89d6b4a
Regroup donation contract api
carina-akaia Oct 28, 2024
78a0b6b
wip
carina-akaia Oct 28, 2024
e0c60a3
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Oct 29, 2024
5061bee
wip
carina-akaia Oct 31, 2024
f80424c
wip
carina-akaia Nov 1, 2024
12b2ef8
wip
carina-akaia Nov 1, 2024
1560c02
Implement token service
carina-akaia Nov 3, 2024
f9caf09
Implement token service
carina-akaia Nov 4, 2024
07c2b01
wip: Integrate FT balances
carina-akaia Nov 4, 2024
07ed75f
wip: Integrate FT balances
carina-akaia Nov 4, 2024
eb71558
wip
carina-akaia Nov 4, 2024
7fbecc0
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Nov 4, 2024
11f4795
wip: Integrate FT registry into donation module
carina-akaia Nov 4, 2024
7add51e
wip: Integrate FT registry into donation module
carina-akaia Nov 4, 2024
d96852b
wip: Integrate FT registry into donation module
carina-akaia Nov 4, 2024
b016eb5
Check prices for other FTs
carina-akaia Nov 4, 2024
26e2e4e
wip
carina-akaia Nov 4, 2024
d4f8439
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Nov 4, 2024
e8e9352
Migrate away from Pagoda EAPI
carina-akaia Nov 5, 2024
046754b
Implement token selector
carina-akaia Nov 5, 2024
c095d09
chore: Format
carina-akaia Nov 5, 2024
1374527
wip
carina-akaia Nov 5, 2024
1139d45
Integrate native token into ft service
carina-akaia Nov 5, 2024
612e78b
wip
carina-akaia Nov 5, 2024
0e7d45d
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Nov 6, 2024
353d970
Freeze FT feature
carina-akaia Nov 6, 2024
5f5fbc6
Refresh indexer API bindings
carina-akaia Nov 6, 2024
4e4eeb8
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Nov 7, 2024
4d53f5a
wip: Fix performance and UX issues
carina-akaia Nov 8, 2024
f42e3bc
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Nov 12, 2024
c4ebb27
wip
carina-akaia Nov 13, 2024
a184be4
Fix scroll area height
carina-akaia Nov 13, 2024
e5a94d0
freeze FT support
carina-akaia Nov 13, 2024
b49b4b5
chore: Format
carina-akaia Nov 13, 2024
a41a083
wip
carina-akaia Nov 13, 2024
6aa32a8
wip
carina-akaia Nov 13, 2024
e908a58
wip
carina-akaia Nov 13, 2024
7f5a1f3
Setup INTEAR price API bindings
carina-akaia Nov 14, 2024
4776e43
Resolve FT token prices
carina-akaia Nov 14, 2024
956b47e
wip
carina-akaia Nov 14, 2024
3b7c413
Put core contracts under `contracts/core` namespace
carina-akaia Nov 14, 2024
ba47f0a
Implement NEAR price retrieval
carina-akaia Nov 15, 2024
fb21de0
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Nov 15, 2024
ed3fe36
wip
carina-akaia Nov 18, 2024
1cd3b40
chore: Format
carina-akaia Nov 18, 2024
b61e74a
Place core contract bindings under `contracts/core` namespace
carina-akaia Nov 18, 2024
20f0c3d
Merge branch '17112024-naming-adjustment' of https://github.com/PotLo…
carina-akaia Nov 18, 2024
789fcd5
wip
carina-akaia Nov 18, 2024
30a8183
wip
carina-akaia Nov 18, 2024
212fd5b
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Nov 18, 2024
ca09be9
wip
carina-akaia Nov 18, 2024
bde6808
wip
carina-akaia Nov 18, 2024
bbb1de0
wip
carina-akaia Nov 18, 2024
9ff5194
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Nov 22, 2024
b32ecae
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Nov 28, 2024
d651fba
chore: Format
carina-akaia Nov 28, 2024
2ed62a9
Temporarily patch FT service for network mismatch case
carina-akaia Nov 28, 2024
c83198a
Temporarily patch FT service for network mismatch case
carina-akaia Nov 28, 2024
7448da5
Update API bindings
carina-akaia Nov 28, 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
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"bitget",
"builddao",
"camelcase",
"campaignstest",
"cmdk",
"codegen",
"colocation",
Expand Down
29 changes: 27 additions & 2 deletions api.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
//? NOTE: Orval does not support ESM configs at the moment
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { resolve } = require("path");

const apiPath = resolve(__dirname, "./src/common/api");
const clientPath = "internal/client.generated.ts";

const targetPaths = {
indexer: "./src/common/api/indexer/internal/client.generated.ts",
indexer: resolve(apiPath, "indexer", clientPath),
prices: resolve(apiPath, "prices", clientPath),
};

module.exports = {
Expand All @@ -8,10 +16,27 @@ module.exports = {
*/
indexer: {
input: "https://test-dev.potlock.io/api/schema",
output: { target: targetPaths.indexer, client: "swr" },

output: {
target: targetPaths.indexer,
client: "swr",
},

hooks: {
afterAllFilesWrite: `eslint --fix ${targetPaths.indexer}`,
},
},

prices: {
input: "https://prices.intear.tech/openapi",

output: {
target: targetPaths.prices,
client: "swr",
},

hooks: {
afterAllFilesWrite: `eslint --fix ${targetPaths.prices}`,
},
},
};
23 changes: 4 additions & 19 deletions src/common/_config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,10 @@ const envConfigRegistry: EnvConfigRegistry = {
test: { ...testEnvConfig, envTag: "test" },
};

const getDeFiConfig = (envConfig: EnvConfig) => ({
refFinance: {
exchangeContract: {
accountId:
envConfig.network === "mainnet" ? "v2.ref-finance.near" : "ref-finance-101.testnet",
},
},
});

export const getEnvConfig = () => {
export const getEnvConfig = (): EnvConfig => {
const deploymentEnvTag = process.env.NEXT_PUBLIC_ENV?.toLowerCase();

const activeEnvironmentConfig =
envConfigRegistry[
isEnvTag((deploymentEnvTag ?? "test") as EnvTag) ? (deploymentEnvTag as EnvTag) : "test"
];

return {
...activeEnvironmentConfig,
deFi: getDeFiConfig(activeEnvironmentConfig),
};
return envConfigRegistry[
isEnvTag((deploymentEnvTag ?? "test") as EnvTag) ? (deploymentEnvTag as EnvTag) : "test"
];
};
2 changes: 2 additions & 0 deletions src/common/_config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export const {

contractMetadata: { version: CONTRACT_SOURCECODE_VERSION, repoUrl: CONTRACT_SOURCECODE_REPO_URL },

features: FEATURE_REGISTRY,

campaigns: {
contract: { accountId: CAMPAIGNS_CONTRACT_ACCOUNT_ID },
},
Expand Down
28 changes: 27 additions & 1 deletion src/common/_config/production.env-config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EnvConfig } from "@/common/types";
import { EnvConfig, FeatureId } from "@/common/types";

export const envConfig: EnvConfig = {
network: "mainnet" as const,
Expand All @@ -8,6 +8,32 @@ export const envConfig: EnvConfig = {
repoUrl: "https://github.com/PotLock/core",
},

features: {
[FeatureId.DirectFtDonation]: {
id: FeatureId.DirectFtDonation,
name: "Direct FT donation",

/**
* The implementation is not finished yet
*/
isEnabled: false,
},

[FeatureId.DirectNativeTokenDonation]: {
id: FeatureId.DirectNativeTokenDonation,
name: "Direct native token donation",
isEnabled: true,
},
},

deFi: {
refFinance: {
exchangeContract: {
accountId: "v2.ref-finance.near",
},
},
},

campaigns: {
contract: { accountId: "campaigns.staging.potlock.near" },
},
Expand Down
28 changes: 27 additions & 1 deletion src/common/_config/staging.env-config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EnvConfig } from "@/common/types";
import { EnvConfig, FeatureId } from "@/common/types";

export const envConfig: EnvConfig = {
network: "mainnet" as const,
Expand All @@ -8,6 +8,32 @@ export const envConfig: EnvConfig = {
repoUrl: "https://github.com/PotLock/core",
},

features: {
[FeatureId.DirectFtDonation]: {
id: FeatureId.DirectFtDonation,
name: "Direct FT donation",

/**
* The implementation is not finished yet
*/
isEnabled: false,
},

[FeatureId.DirectNativeTokenDonation]: {
id: FeatureId.DirectNativeTokenDonation,
name: "Direct native token donation",
isEnabled: true,
},
},

deFi: {
refFinance: {
exchangeContract: {
accountId: "v2.ref-finance.near",
},
},
},

donation: {
contract: { accountId: "donate.staging.potlock.near" },
},
Expand Down
28 changes: 27 additions & 1 deletion src/common/_config/test.env-config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EnvConfig } from "@/common/types";
import { EnvConfig, FeatureId } from "@/common/types";

export const envConfig: EnvConfig = {
network: "testnet" as const,
Expand All @@ -8,6 +8,32 @@ export const envConfig: EnvConfig = {
repoUrl: "https://github.com/PotLock/core",
},

features: {
[FeatureId.DirectFtDonation]: {
id: FeatureId.DirectFtDonation,
name: "Direct FT donation",

/**
* The implementation is not finished yet
*/
isEnabled: false,
},

[FeatureId.DirectNativeTokenDonation]: {
id: FeatureId.DirectNativeTokenDonation,
name: "Direct native token donation",
isEnabled: true,
},
},

deFi: {
refFinance: {
exchangeContract: {
accountId: "ref-finance-101.testnet",
},
},
},

donation: {
contract: { accountId: "donate.potlock.testnet" },
},
Expand Down
1 change: 1 addition & 0 deletions src/common/api/coingecko/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { client as coingeckoClient } from "./client";
export * as coingecko from "./hooks";
1 change: 1 addition & 0 deletions src/common/api/indexer/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * as indexerClient from "./internal/client.generated";
export * as indexer from "./hooks";
export * from "./types";
20 changes: 20 additions & 0 deletions src/common/api/prices/hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ByTokenId } from "@/common/types";

import * as generatedClient from "./internal/client.generated";
import { PRICES_REQUEST_CONFIG } from "./internal/config";

/**
* https://prices.intear.tech/swagger-ui/#/Token%20Prices/get_get_token_price
*/
export const useTokenUsdPrice = ({ tokenId }: Partial<ByTokenId>) => {
const queryResult = generatedClient.useGetGetTokenPrice(
{ token_id: tokenId ?? "unknown" },

{
...PRICES_REQUEST_CONFIG,
swr: { enabled: Boolean(tokenId) },
},
);

return { ...queryResult, data: queryResult.data?.data };
};
4 changes: 4 additions & 0 deletions src/common/api/prices/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { PRICES_REQUEST_CONFIG } from "./internal/config";
export * as pricesClient from "./internal/client.generated";
export * as prices from "./hooks";
export * from "./types";
Loading
Loading