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

feat: PRO-2395 Design doc for sponsorship policy management #107

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b4ec24b
feat: PRO-2395 Design doc for sponsorship policy management
kanthgithub Jun 5, 2024
df5476a
feat: PRO-2395 sponsorship policy db migration
kanthgithub Jun 6, 2024
ce1a9a2
feat: PRO-2395 sequelize integration to backend and property name upd…
kanthgithub Jun 7, 2024
508a357
feat: PRO-2395 update apiKey sequelize based response reference in ad…
kanthgithub Jun 7, 2024
b571783
feat: PRO-2395 sequelize models and centralised model association fil…
kanthgithub Jun 10, 2024
17d3603
feat: PRO-2395 refactor sequelize models and their initialisation in …
kanthgithub Jun 10, 2024
41757fe
fix: PRO-2395 admin-frontend to parse the error message from response…
kanthgithub Jun 10, 2024
2b14746
feat: PRO-2395 sequelize models updated with new association relation…
kanthgithub Jun 10, 2024
82b42b2
feat: PRO-2395 sequelize init and test
kanthgithub Jun 10, 2024
e2a2d45
feat: PRO-2395 migration scripts refactored and updated
kanthgithub Jun 12, 2024
72d9fc1
Merge branch 'master' into PRO-2395-Sponsorship-Policies
kanthgithub Jun 12, 2024
8ea0217
feat: PRO-2395 sequelize repository updates and conflict resolution
kanthgithub Jun 12, 2024
227452a
fix: PRO-2395 admin-frontend global-config components fix
kanthgithub Jun 12, 2024
4006f8b
chore: PRO-2395 logging updates
kanthgithub Jun 13, 2024
6ac302b
feat: PRO-2395 restricted sequelize references from repository, serve…
kanthgithub Jun 13, 2024
2709a72
fix: PRO-2395 Fix SponsorshipPolicy migrations and sequelize models n…
kanthgithub Jun 13, 2024
234d43c
chore: PRO-2395 delete obselete file at root directory
kanthgithub Jun 13, 2024
03d1f1d
feat: PRO-2395 denormalize SponsorshipPolicy table data
kanthgithub Jun 13, 2024
11fb2d7
feat: PRO-2395 refactor types and optimise imports
kanthgithub Jun 13, 2024
625afd0
fix: PRO-2395 adjust the property name to typescript model fieldnames
kanthgithub Jun 13, 2024
06e4617
feat: PRO-2395 SponsorshipPolicy repository functions and package ver…
kanthgithub Jun 14, 2024
acb5e01
fix: PRO-2395 fix imports in backend
kanthgithub Jun 14, 2024
ecbbbf0
feat: PRO-2395 SponsorshipPolicy validations, db model updates and do…
kanthgithub Jun 16, 2024
a4d8a9b
doc: PRO-2395 docker documentation for backend updated in readme file
kanthgithub Jun 16, 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
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules

# build
/build/

# misc
.DS_Store
.env.production

# debug
npm-debug.log*

.nyc_output
coverage

.env
config.json
database.sqlite

package-lock.json
pnpm-lock.yaml

# Ponder
/indexer/.ponder
/indexer/generated
yarn.lock
4 changes: 2 additions & 2 deletions admin_frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

.env
yarn.lock
.env
2 changes: 1 addition & 1 deletion admin_frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "admin_frontend",
"version": "1.2.6",
"version": "1.2.7",
"private": true,
"dependencies": {
"@emotion/react": "11.11.3",
Expand Down
44 changes: 22 additions & 22 deletions admin_frontend/src/components/ApiKeys.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ const ApiKeysPage = () => {
);
const dataJson = await data.json();
dataJson.filter((element) => {
if (element.SUPPORTED_NETWORKS) {
const buffer = Buffer.from(element.SUPPORTED_NETWORKS, "base64");
if (element.supportedNetworks) {
const buffer = Buffer.from(element.supportedNetworks, "base64");
const parsedSupportedNetowrks = JSON.parse(buffer.toString());
element.SUPPORTED_NETWORKS = parsedSupportedNetowrks;
element.supportedNetworks = parsedSupportedNetowrks;
}
if (element.ERC20_PAYMASTERS) {
const buffer = Buffer.from(element.ERC20_PAYMASTERS, "base64");
if (element.erc20Paymasters) {
const buffer = Buffer.from(element.erc20Paymasters, "base64");
const parsedErc20Paymasters = JSON.parse(buffer.toString());
element.ERC20_PAYMASTERS = parsedErc20Paymasters;
element.erc20Paymasters = parsedErc20Paymasters;
}
return element;
});
Expand Down Expand Up @@ -135,12 +135,12 @@ const ApiKeysPage = () => {
JSON.stringify(customErc20Paymaster)
).toString("base64");
const requestData = {
API_KEY: apiKey,
PRIVATE_KEY: privateKey,
SUPPORTED_NETWORKS:
apiKey: apiKey,
privateKey: privateKey,
supportedNetworks:
Buffer.from(JSON.stringify(supportedNetworks)).toString("base64") ??
"",
ERC20_PAYMASTERS: base64Erc20 ?? "",
erc20Paymasters: base64Erc20 ?? "",
};
const data = await fetch(
`${process.env.REACT_APP_SERVER_URL}${ENDPOINTS["saveKey"]}`,
Expand All @@ -149,15 +149,15 @@ const ApiKeysPage = () => {
body: JSON.stringify(requestData),
}
);
const dataJson = data.json();
const dataJson = await data.json();
if (!dataJson.error) {
toast.success("Saved Successfully");
setApiKey("");
setPrivateKey("");
fetchData();
} else {
setLoading(false);
toast.error(`${dataJson.message} Please try again or contant Arka support team`);
toast.error(`${dataJson.error} Please try again or contant Arka support team`);
}
} catch (err) {
if (err?.message?.includes("Failed to fetch")) {
Expand All @@ -174,7 +174,7 @@ const ApiKeysPage = () => {
`${process.env.REACT_APP_SERVER_URL}${ENDPOINTS["deleteKey"]}`,
{
method: "POST",
body: JSON.stringify({ API_KEY: key }),
body: JSON.stringify({ apiKey: key }),
}
);
const dataJson = data.json();
Expand Down Expand Up @@ -280,12 +280,12 @@ const ApiKeysPage = () => {
</TableCell>
</TableRow>
{keys.map((row, index) => (
<TableRow key={row.API_KEY}>
<TableCell>{row.WALLET_ADDRESS}</TableCell>
<TableCell>{row.API_KEY}</TableCell>
<TableRow key={row.apiKey}>
<TableCell>{row.walletAddress}</TableCell>
<TableCell>{row.apiKey}</TableCell>
<TableCell>
<div className="flex flex-row">
<div>{showPassword ? row.PRIVATE_KEY : "*****"} </div>
<div>{showPassword ? row.privateKey : "*****"} </div>
<div>
<InputAdornment position="end">
<IconButton
Expand All @@ -302,16 +302,16 @@ const ApiKeysPage = () => {
</TableCell>
<TableCell>
<Button
disabled={row.SUPPORTED_NETWORKS === ""}
onClick={() => handleViewOpen(row.SUPPORTED_NETWORKS)}
disabled={row.supportedNetworks === ""}
onClick={() => handleViewOpen(row.supportedNetworks)}
>
View
</Button>
</TableCell>
<TableCell>
<Button
disabled={row.ERC20_PAYMASTERS === ""}
onClick={() => handleViewERC20Open(row.ERC20_PAYMASTERS)}
disabled={row.erc20Paymasters === ""}
onClick={() => handleViewERC20Open(row.erc20Paymasters)}
>
View
</Button>
Expand All @@ -324,7 +324,7 @@ const ApiKeysPage = () => {
startIcon={<RemoveCircleIcon />}
variant="contained"
onClick={() => {
handleDelete(row.API_KEY);
handleDelete(row.apiKey);
}}
>
Delete Row
Expand Down
76 changes: 38 additions & 38 deletions admin_frontend/src/components/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ const InfoTextStyle = {

const Dashboard = () => {
const defaultConfig = {
COINGECKO_API_URL: "",
COINGECKO_IDS: "",
CRON_TIME: "",
CUSTOM_CHAINLINK_DEPLOYED: "",
DEPLOYED_ERC20_PAYMASTERS: "",
PYTH_MAINNET_CHAIN_IDS: "",
PYTH_MAINNET_URL: "",
PYTH_TESTNET_CHAIN_IDS: "",
PYTH_TESTNET_URL: "",
coingeckoApiUrl: "",
coingeckoIds: "",
cronTime: "",
customChainlinkDeployed: "",
deployedErc20Paymasters: "",
pythMainnetChainIds: "",
pythMainnetUrl: "",
pythTestnetChainIds: "",
pythTestnetUrl: "",
id: 1,
};
const [config, setConfig] = useState(defaultConfig);
Expand Down Expand Up @@ -87,23 +87,23 @@ const Dashboard = () => {
setConfig(dataJson);
setEdittedConfig(dataJson);
let buffer;
if (data.COINGECKO_IDS && data.COINGECKO_IDS !== "") {
buffer = Buffer.from(data.COINGECKO_IDS, "base64");
if (data.coingeckoIds && data.coingeckoIds !== "") {
buffer = Buffer.from(data.coingeckoIds, "base64");
const coingeckoIds = JSON.parse(buffer.toString());
setCoingeckoIds(coingeckoIds);
}
if (
data.DEPLOYED_ERC20_PAYMASTERS &&
data.DEPLOYED_ERC20_PAYMASTERS !== ""
data.deployedErc20Paymasters &&
data.deployedErc20Paymasters !== ""
) {
buffer = Buffer.from(data.DEPLOYED_ERC20_PAYMASTERS, "base64");
buffer = Buffer.from(data.deployedErc20Paymasters, "base64");
setDeployedPaymasters(JSON.parse(buffer.toString()));
}
if (
data.CUSTOM_CHAINLINK_DEPLOYED &&
data.CUSTOM_CHAINLINK_DEPLOYED !== ""
data.customChainlinkDeployed &&
data.customChainlinkDeployed !== ""
) {
buffer = Buffer.from(data.CUSTOM_CHAINLINK_DEPLOYED, "base64");
buffer = Buffer.from(data.customChainlinkDeployed, "base64");
setCustomChainlink(JSON.parse(buffer.toString()));
}
setDisableSave(true);
Expand Down Expand Up @@ -135,13 +135,13 @@ const Dashboard = () => {
if (signedIn) {
try {
setLoading(true);
edittedConfig.COINGECKO_IDS = Buffer.from(
edittedConfig.coingeckoIds = Buffer.from(
JSON.stringify(coingeckoIds)
).toString("base64");
edittedConfig.DEPLOYED_ERC20_PAYMASTERS = Buffer.from(
edittedConfig.deployedErc20Paymasters = Buffer.from(
JSON.stringify(deployedPaymasters)
).toString("base64");
edittedConfig.CUSTOM_CHAINLINK_DEPLOYED = Buffer.from(
edittedConfig.customChainlinkDeployed = Buffer.from(
JSON.stringify(customChainlink)
).toString("base64");
const data = await fetch(
Expand Down Expand Up @@ -202,16 +202,16 @@ const Dashboard = () => {
onChange={(e) => {
setEdittedConfig({
...edittedConfig,
COINGECKO_API_URL: e.target.value,
coingeckoApiUrl: e.target.value,
});
if (disableSave) setDisableSave(false);
else if (
!disableSave &&
e.target.value === config.COINGECKO_API_URL
e.target.value === config.coingeckoApiUrl
)
setDisableSave(true);
}}
value={edittedConfig.COINGECKO_API_URL}
value={edittedConfig.coingeckoApiUrl}
required
fullWidth
multiline
Expand All @@ -232,13 +232,13 @@ const Dashboard = () => {
onChange={(e) => {
setEdittedConfig({
...edittedConfig,
CRON_TIME: e.target.value,
cronTime: e.target.value,
});
if (disableSave) setDisableSave(false);
else if (!disableSave && e.target.value === config.CRON_TIME)
else if (!disableSave && e.target.value === config.cronTime)
setDisableSave(true);
}}
value={edittedConfig.CRON_TIME}
value={edittedConfig.cronTime}
required
fullWidth
/>
Expand Down Expand Up @@ -291,16 +291,16 @@ const Dashboard = () => {
onChange={(e) => {
setEdittedConfig({
...edittedConfig,
PYTH_MAINNET_CHAIN_IDS: e.target.value,
pythMainnetChainIds: e.target.value,
});
if (disableSave) setDisableSave(false);
else if (
!disableSave &&
e.target.value === config.PYTH_MAINNET_CHAIN_IDS
e.target.value === config.pythMainnetChainIds
)
setDisableSave(true);
}}
value={edittedConfig.PYTH_MAINNET_CHAIN_IDS}
value={edittedConfig.pythMainnetChainIds}
required
fullWidth
multiline
Expand All @@ -322,13 +322,13 @@ const Dashboard = () => {
onChange={(e) => {
setEdittedConfig({
...edittedConfig,
PYTH_MAINNET_URL: e.target.value,
pythMainnetUrl: e.target.value,
});
if (disableSave) setDisableSave(false);
else if (!disableSave && e.target.value === config.PYTH_MAINNET_URL)
else if (!disableSave && e.target.value === config.pythMainnetUrl)
setDisableSave(true);
}}
value={edittedConfig.PYTH_MAINNET_URL}
value={edittedConfig.pythMainnetUrl}
required
fullWidth
multiline
Expand All @@ -350,16 +350,16 @@ const Dashboard = () => {
onChange={(e) => {
setEdittedConfig({
...edittedConfig,
PYTH_TESTNET_CHAIN_IDS: e.target.value,
pythTestnetChainIds: e.target.value,
});
if (disableSave) setDisableSave(false);
else if (
!disableSave &&
e.target.value === config.PYTH_TESTNET_CHAIN_IDS
e.target.value === config.pythTestnetChainIds
)
setDisableSave(true);
}}
value={edittedConfig.PYTH_TESTNET_CHAIN_IDS}
value={edittedConfig.pythTestnetChainIds}
required
fullWidth
multiline
Expand All @@ -381,13 +381,13 @@ const Dashboard = () => {
onChange={(e) => {
setEdittedConfig({
...edittedConfig,
PYTH_TESTNET_URL: e.target.value,
pythTestnetUrl: e.target.value,
});
if (disableSave) setDisableSave(false);
else if (!disableSave && e.target.value === config.PYTH_TESTNET_URL)
else if (!disableSave && e.target.value === config.pythTestnetUrl)
setDisableSave(true);
}}
value={edittedConfig.PYTH_TESTNET_URL}
value={edittedConfig.pythTestnetUrl}
required
fullWidth
multiline
Expand Down
4 changes: 2 additions & 2 deletions admin_frontend/src/context/AuthContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const AuthContextProvider = ({ children }) => {
try {
const data = await fetch(`${process.env.REACT_APP_SERVER_URL}${ENDPOINTS['adminLogin']}`, {
method: "POST",
body: JSON.stringify({ WALLET_ADDRESS: accounts[0] }),
body: JSON.stringify({ walletAddress: accounts[0] }),
});
const dataJson = await data.json();
if (!dataJson.error) {
Expand Down Expand Up @@ -47,7 +47,7 @@ export const AuthContextProvider = ({ children }) => {
const address = await initializeProvider();
const data = await fetch(`${process.env.REACT_APP_SERVER_URL}${ENDPOINTS['adminLogin']}`, {
method: "POST",
body: JSON.stringify({ WALLET_ADDRESS: address }),
body: JSON.stringify({ walletAddress: address }),
});
const dataJson = await data.json();
if (!dataJson.error) {
Expand Down
10 changes: 0 additions & 10 deletions admin_frontend/src/modals/AddERC20Paymaster.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ const AddERC20PaymasterModal = ({
setERC20Row(defaultERC20Row);
Object.keys(supportedNetworks).map((key) => {
Object.keys(supportedNetworks[key]).map((sym) => {
console.log(
tokens.find(
(element) => element.chainId == key && element.token == sym
)
);
if (
!tokens.find(
(element) => element.chainId == key && element.token == sym
Expand Down Expand Up @@ -112,11 +107,6 @@ const AddERC20PaymasterModal = ({
useEffect(() => {
Object.keys(supportedNetworks).map((key) => {
Object.keys(supportedNetworks[key]).map((sym) => {
console.log(
tokens.find(
(element) => element.chainId == key && element.token == sym
)
);
if (
!tokens.find(
(element) => element.chainId == key && element.token == sym
Expand Down
2 changes: 1 addition & 1 deletion admin_frontend/src/modals/AddSupportedNetworksModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const AddSupportedNetworksModal = ({
</Button>
</TableCell>
</TableRow>
{supportedNetworks.map((network, index) => {
{Array.isArray(supportedNetworks) && supportedNetworks.map((network, index) => {
return (
<TableRow key={network.chainId}>
<TableCell>{network.chainId}</TableCell>
Expand Down
Loading
Loading