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

Sponsorship Policy API functions and Integrate with paymaster data generation endpoint #111

Merged
merged 43 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
43 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
6bc3ef6
feat: PRO-2455 validate userOp in sponsorMode with sponsorshipPolicy …
kanthgithub Jun 17, 2024
f1048ab
feat: PRO-2455 refactor sponsorship-policy to include EP version and …
kanthgithub Jun 18, 2024
1bed175
feat: PRO-2455 sponsorship-policy validation logic updated
kanthgithub Jun 18, 2024
c80ebc3
fix: PRO-2455 fix sequelize model update pattern
kanthgithub Jun 18, 2024
5ce1242
fix: PRO-2455 SponsorshipPolicy query functions from chainId, EntryPo…
kanthgithub Jun 19, 2024
2779225
feat: PRO-2455 api-endpoint refactoring for sponsorship policy extrac…
kanthgithub Jun 19, 2024
6c8ad04
feat: PRO-2455 HMAC env added and function imports fixed
kanthgithub Jun 20, 2024
4497b76
feat: PRO-2455 configure the SSL options for sequelize
kanthgithub Jun 20, 2024
177e4b0
feat: PRO-2455 sequelize migration standalone script and added script…
kanthgithub Jun 20, 2024
5072ea1
fix: PRO-2455 docker-compose fixes
kanthgithub Jun 20, 2024
de555a0
fix: PRO-2455 sponsorship-policy api endpoints fixed
kanthgithub Jun 20, 2024
2dd8641
feat: PRO-2455 externalise values from docker-compose to env variable…
kanthgithub Jun 22, 2024
ffcd5b0
doc: PRO-2455 backend and arka docker startup instructions
kanthgithub Jun 22, 2024
c0564e8
feat: rearrange docker-compose files
kanthgithub Jun 24, 2024
1f302e7
Merge branch 'master' into PRO-2455-Sponsorship-Policy-Integration
kanthgithub Jun 24, 2024
254778c
feat: PRO-2455 add new api route functions for sponsorship-policy
kanthgithub Jun 24, 2024
b7ce71d
feat: PRO-2455 split functions in routes
kanthgithub Jun 24, 2024
1e47614
feat: PRO-2455 split functions in routes
kanthgithub Jun 24, 2024
024696e
feat: PRO-2455 refactor local docker setup instructions and local pos…
kanthgithub Jun 25, 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
18 changes: 18 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
LOG_LEVEL=
API_HOST=
API_PORT=
UNSAFE_MODE=true
SUPPORTED_NETWORKS=
CRON_PRIVATE_KEY=
DEFAULT_INDEXER_ENDPOINT=
FEE_MARKUP=0
MULTI_TOKEN_MARKUP=
ADMIN_WALLET_ADDRESS=
ETHERSCAN_GAS_ORACLES=""
DEFAULT_API_KEY=""
WEBHOOK_URL=
HMAC_SECRET=
DATABASE_URL=
DATABASE_SCHEMA_NAME=arka
DATABASE_SSL_ENABLED=false
DATABASE_SSL_REJECT_UNAUTHORIZED=false
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
Loading