From e7a08ca450d02959a47efc30271c9bf6d3905a67 Mon Sep 17 00:00:00 2001 From: Shrinath Prabhu Date: Thu, 10 Feb 2022 08:47:58 +0530 Subject: [PATCH 1/5] Removed smart contract call on create app (#44) --- src/pages/AppConfigure.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/AppConfigure.vue b/src/pages/AppConfigure.vue index 2808a33e..fa306fea 100644 --- a/src/pages/AppConfigure.vue +++ b/src/pages/AppConfigure.vue @@ -634,7 +634,8 @@ export default { ...store.getters[env.value + "/config"], }); - makeTx(); + loading.value = false; + router.push("/"); }); } } From d85ac62c594c3a22dab19eb1fff13125a2b2bd08 Mon Sep 17 00:00:00 2001 From: KarthikSiddarth Date: Fri, 11 Feb 2022 14:28:50 +0530 Subject: [PATCH 2/5] [AR-1023] Create Radio Button Component (#50) * create Radio button component * create radio button group component * move into lib dir * bind "for" attr to label, "id" attr to input el * use modelValue to bind selected value from parent * add emits prop * change data types value to Str, Num, Bool --- src/components/lib/VRadio/VRadio.vue | 65 +++++++++++++++++++ .../lib/VRadioGroup/VRadioGroup.vue | 34 ++++++++++ 2 files changed, 99 insertions(+) create mode 100644 src/components/lib/VRadio/VRadio.vue create mode 100644 src/components/lib/VRadioGroup/VRadioGroup.vue diff --git a/src/components/lib/VRadio/VRadio.vue b/src/components/lib/VRadio/VRadio.vue new file mode 100644 index 00000000..795cfa56 --- /dev/null +++ b/src/components/lib/VRadio/VRadio.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/src/components/lib/VRadioGroup/VRadioGroup.vue b/src/components/lib/VRadioGroup/VRadioGroup.vue new file mode 100644 index 00000000..feef560c --- /dev/null +++ b/src/components/lib/VRadioGroup/VRadioGroup.vue @@ -0,0 +1,34 @@ + + + From 4467c5b493819ca7916d4d586c9a2f3f87ac2bc7 Mon Sep 17 00:00:00 2001 From: KarthikSiddarth Date: Fri, 11 Feb 2022 16:32:16 +0530 Subject: [PATCH 3/5] [AR-1024] Update the logic of selection (#51) * create Radio button component * create radio button group component * move into lib dir * add chains to constant.js file * import chains and render using v-for dir * replace VSwitch with VRadioGroup to render chains * bind currently selected chain using v-model --- src/components/app-configure/AppChain.vue | 56 ++++++----------------- src/utils/constants.js | 16 +++++++ 2 files changed, 30 insertions(+), 42 deletions(-) diff --git a/src/components/app-configure/AppChain.vue b/src/components/app-configure/AppChain.vue index 81c1f9bb..4b754d47 100644 --- a/src/components/app-configure/AppChain.vue +++ b/src/components/app-configure/AppChain.vue @@ -34,39 +34,12 @@ justify="space-between" class="flex-grow" > - - Ethereum - - - - Polygon - - - - Binance - - + @@ -97,7 +70,8 @@ import { useStore } from "vuex"; import VButton from "../lib/VButton/VButton.vue"; import VCard from "../lib/VCard/VCard.vue"; import VStack from "../lib/VStack/VStack.vue"; -import VSwitch from "../lib/VSwitch/VSwitch.vue"; +import VRadioGroup from "../lib/VRadioGroup/VRadioGroup.vue"; +import { chains } from "../../utils/constants"; export default { name: "ConfigureAppChainType", @@ -105,7 +79,7 @@ export default { isConfigured: Boolean, store: Object, }, - components: { VCard, VButton, VSwitch, VStack }, + components: { VCard, VButton, VRadioGroup, VStack }, setup(props) { const store = useStore(); @@ -113,7 +87,7 @@ export default { return store.getters.env; }); - let chainType = computed(() => { + let selectedChain = computed(() => { return store.getters[env.value + "/chainType"]; }); @@ -125,18 +99,16 @@ export default { }); } - function changeChainType({ value: isSelected }, chainType) { - store.dispatch( - env.value + "/updateChainType", - isSelected ? chainType : "" - ); + function changeChainType(selectedChain) { + store.dispatch(env.value + "/updateChainType", selectedChain); if (props.isConfigured && !store.getters.onConfigChange) { store.dispatch("configChangeDetected"); } } return { - chainType, + chains, + selectedChain, changeChainType, onLearnMoreClicked, }; diff --git a/src/utils/constants.js b/src/utils/constants.js index 3cc8849b..1c3b82b3 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -42,6 +42,21 @@ export const origin = window.location.origin; export const isAppDown = import.meta.env.VITE_IS_APP_DOWN || false; +export const chains = [ + { + label: "Ethereum", + value: "ethereum", + }, + { + label: "Polygon", + value: "polygon", + }, + { + label: "Binance", + value: "binance", + }, +]; + export default { sso, ssoRedirectUrl, @@ -50,4 +65,5 @@ export default { arcanaAppId, origin, isAppDown, + chains, }; From 37ff24bce30f6f75e40449388f88201ed6862362 Mon Sep 17 00:00:00 2001 From: Shrinath Prabhu Date: Fri, 11 Feb 2022 16:54:07 +0530 Subject: [PATCH 4/5] Replace unversioned apis with versioned apis (#42) * Removed /api prefix from all the api endpoints * Modified get env api to add versions to api 1. Added version parameter that accepts string or false 2. If version is not supplied, it fallbacks to current version 3. If version is false, then it skips api versioning and returns unversioned raw api * Added false to apis that need to be unversioned * Updated signer function for making smart contract call (#47) * Added default version if version is not passed * Named export for getEnvApi * Added negation check for version --- public/tx-sign.js | 197 +++++++++-------------------- src/services/app-config.service.js | 21 ++- src/services/auth.service.js | 4 +- src/services/dashboard.service.js | 12 +- src/services/get-env-api.js | 20 ++- src/services/profile.service.js | 4 +- src/services/user.service.js | 30 ++--- 7 files changed, 107 insertions(+), 181 deletions(-) diff --git a/public/tx-sign.js b/public/tx-sign.js index eb85a26f..caf9a903 100644 --- a/public/tx-sign.js +++ b/public/tx-sign.js @@ -17,46 +17,20 @@ module.exports={ "stateMutability": "nonpayable", "type": "function" }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_store", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_bandwidth", - "type": "uint256" - } - ], - "name": "setDefaultLimit", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, { "inputs": [ { "internalType": "string", - "name": "_id", + "name": "_client", "type": "string" - } - ], - "name": "setDiscordClientId", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ + }, { "internalType": "string", - "name": "_id", + "name": "_clientId", "type": "string" } ], - "name": "setGithubClientId", + "name": "setClientId", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -64,25 +38,17 @@ module.exports={ { "inputs": [ { - "internalType": "string", - "name": "_id", - "type": "string" - } - ], - "name": "setGoogleClientId", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ + "internalType": "string[]", + "name": "_client", + "type": "string[]" + }, { - "internalType": "string", - "name": "_id", - "type": "string" + "internalType": "string[]", + "name": "_clientId", + "type": "string[]" } ], - "name": "setRedditClientId", + "name": "setClientIds", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -90,25 +56,17 @@ module.exports={ { "inputs": [ { - "internalType": "string", - "name": "_id", - "type": "string" - } - ], - "name": "setTwitchClientId", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ + "internalType": "uint256", + "name": "_store", + "type": "uint256" + }, { - "internalType": "string", - "name": "_id", - "type": "string" + "internalType": "uint256", + "name": "_bandwidth", + "type": "uint256" } ], - "name": "setTwitterClientId", + "name": "setDefaultLimit", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -243,7 +201,7 @@ const ethers = require("ethers"); const axios = require("axios"); const sign = require("./signer.js").sign; -window.signerMakeTx = async function ({ +async function signerMakeTx({ privateKey, appAddress, rpc, @@ -253,7 +211,7 @@ window.signerMakeTx = async function ({ method, value, }) { - let wallet = new ethers.Wallet(privateKey); + const wallet = new ethers.Wallet(privateKey); const arcanaContract = new ethers.Contract(appAddress, arcana.abi, wallet); const provider = new ethers.providers.JsonRpcProvider(rpc); const forwarderContract = new ethers.Contract( @@ -261,23 +219,26 @@ window.signerMakeTx = async function ({ forwarder.abi, provider ); - let req = await sign( + const req = await sign( wallet, arcanaContract, forwarderContract, method, value ); - let res = await axios.post(gateway + "/api/meta-tx/", req, { + const res = await axios.post(gateway + "/meta-tx/", req, { headers: { Authorization: "Bearer " + accessToken, }, }); await new Promise((r) => setTimeout(r, 1000)); - let tx = await provider.getTransaction(res.data.txHash); + const tx = await provider.getTransaction(res.data.txHash); await tx.wait(); + console.log(method, "Done"); return res.data; -}; +} + +window.signerMakeTx = signerMakeTx; },{"./contracts/IArcana.sol/IArcana.json":1,"./contracts/IForwarder.sol/IForwarder.json":2,"./signer.js":264,"axios":125,"ethers":198}],4:[function(require,module,exports){ "use strict"; @@ -28169,54 +28130,36 @@ utils.intFromLE = intFromLE; },{"bn.js":155,"minimalistic-assert":225,"minimalistic-crypto-utils":226}],174:[function(require,module,exports){ module.exports={ - "_args": [ - [ - "elliptic@6.5.4", - "/home/shrinath/Downloads/DashboardSigner-master" - ] + "name": "elliptic", + "version": "6.5.4", + "description": "EC cryptography", + "main": "lib/elliptic.js", + "files": [ + "lib" ], - "_from": "elliptic@6.5.4", - "_id": "elliptic@6.5.4", - "_inBundle": false, - "_integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", - "_location": "/elliptic", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "elliptic@6.5.4", - "name": "elliptic", - "escapedName": "elliptic", - "rawSpec": "6.5.4", - "saveSpec": null, - "fetchSpec": "6.5.4" + "scripts": { + "lint": "eslint lib test", + "lint:fix": "npm run lint -- --fix", + "unit": "istanbul test _mocha --reporter=spec test/index.js", + "test": "npm run lint && npm run unit", + "version": "grunt dist && git add dist/" }, - "_requiredBy": [ - "/@ethersproject/signing-key", - "/ethereumjs-abi/ethereumjs-util", - "/ethereumjs-util", - "/secp256k1" - ], - "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", - "_spec": "6.5.4", - "_where": "/home/shrinath/Downloads/DashboardSigner-master", - "author": { - "name": "Fedor Indutny", - "email": "fedor@indutny.com" + "repository": { + "type": "git", + "url": "git@github.com:indutny/elliptic" }, + "keywords": [ + "EC", + "Elliptic", + "curve", + "Cryptography" + ], + "author": "Fedor Indutny ", + "license": "MIT", "bugs": { "url": "https://github.com/indutny/elliptic/issues" }, - "dependencies": { - "bn.js": "^4.11.9", - "brorand": "^1.1.0", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.1", - "inherits": "^2.0.4", - "minimalistic-assert": "^1.0.1", - "minimalistic-crypto-utils": "^1.0.1" - }, - "description": "EC cryptography", + "homepage": "https://github.com/indutny/elliptic", "devDependencies": { "brfs": "^2.0.2", "coveralls": "^3.1.0", @@ -28232,31 +28175,15 @@ module.exports={ "istanbul": "^0.4.5", "mocha": "^8.0.1" }, - "files": [ - "lib" - ], - "homepage": "https://github.com/indutny/elliptic", - "keywords": [ - "EC", - "Elliptic", - "curve", - "Cryptography" - ], - "license": "MIT", - "main": "lib/elliptic.js", - "name": "elliptic", - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/indutny/elliptic.git" - }, - "scripts": { - "lint": "eslint lib test", - "lint:fix": "npm run lint -- --fix", - "test": "npm run lint && npm run unit", - "unit": "istanbul test _mocha --reporter=spec test/index.js", - "version": "grunt dist && git add dist/" - }, - "version": "6.5.4" + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + } } },{}],175:[function(require,module,exports){ diff --git a/src/services/app-config.service.js b/src/services/app-config.service.js index e293e937..586f5c8a 100644 --- a/src/services/app-config.service.js +++ b/src/services/app-config.service.js @@ -9,7 +9,7 @@ const UNLIMITED_BYTE_SIZE = bytes("10 TB"); const CHAIN_TYPES = ["ethereum", "polygon", "binance"]; export function getConfig() { - return axios.get(getEnvApi() + "/get-config/"); + return axios.get(getEnvApi(false) + "/get-config/"); } export function createApp({ @@ -21,7 +21,7 @@ export function createApp({ cred, }) { return axios.post( - getEnvApi() + "/api/create-app/", + getEnvApi() + "/create-app/", { name, region, @@ -43,7 +43,7 @@ export function updateApp( { name, region, chain, bandwidth_limit, storage_limit, cred, address } ) { return axios.post( - getEnvApi() + "/api/update-app/?id=" + appId, + getEnvApi() + "/update-app/?id=" + appId, { ID: appId, name, @@ -65,7 +65,7 @@ export function updateApp( export function deleteCred(verifier) { return axios.get( getEnvApi() + - "/api/delete-cred/?id=" + + "/delete-cred/?id=" + store.getters.appId + "&verifier=" + verifier, @@ -78,14 +78,11 @@ export function deleteCred(verifier) { } export function deleteApp() { - return axios.delete( - getEnvApi() + "/api/delete-app/?id=" + store.getters.appId, - { - headers: { - Authorization: "Bearer " + store.getters.accessToken, - }, - } - ); + return axios.delete(getEnvApi() + "/delete-app/?id=" + store.getters.appId, { + headers: { + Authorization: "Bearer " + store.getters.accessToken, + }, + }); } export async function fetchAndStoreAppConfig() { diff --git a/src/services/auth.service.js b/src/services/auth.service.js index fdec1644..42e48d17 100644 --- a/src/services/auth.service.js +++ b/src/services/auth.service.js @@ -47,11 +47,11 @@ export function logout() { } export function getNonce(address) { - return axios.get(getEnvApi() + "/get-nonce/?address=" + address); + return axios.get(getEnvApi(false) + "/get-nonce/?address=" + address); } export function login({ signature, email, address }) { - return axios.post(getEnvApi() + "/login/", { + return axios.post(getEnvApi(false) + "/login/", { signature, email, address, diff --git a/src/services/dashboard.service.js b/src/services/dashboard.service.js index fb6409f9..6013a4ab 100644 --- a/src/services/dashboard.service.js +++ b/src/services/dashboard.service.js @@ -4,7 +4,7 @@ import getEnvApi from "./get-env-api"; import store from "../store"; export function fetchAllApps() { - return axios.get(getEnvApi() + "/api/user-app/", { + return axios.get(getEnvApi() + "/user-app/", { headers: { Authorization: "Bearer " + store.getters.accessToken, }, @@ -12,7 +12,7 @@ export function fetchAllApps() { } export function fetchApp(appId) { - return axios.get(getEnvApi() + "/api/get-app/?id=" + appId, { + return axios.get(getEnvApi() + "/get-app/?id=" + appId, { headers: { Authorization: "Bearer " + store.getters.accessToken, }, @@ -20,7 +20,7 @@ export function fetchApp(appId) { } export function fetchStats(appId) { - return axios.get(getEnvApi() + "/api/overview/?id=" + appId, { + return axios.get(getEnvApi() + "/overview/?id=" + appId, { headers: { Authorization: "Bearer " + store.getters.accessToken, }, @@ -29,11 +29,7 @@ export function fetchStats(appId) { export function fetchPeriodicUsage(period = "month") { return axios.get( - getEnvApi() + - "/api/app-usage/?id=" + - store.getters.appId + - "&period=" + - period, + getEnvApi() + "/app-usage/?id=" + store.getters.appId + "&period=" + period, { headers: { Authorization: "Bearer " + store.getters.accessToken, diff --git a/src/services/get-env-api.js b/src/services/get-env-api.js index 010dd0b6..c9346e15 100644 --- a/src/services/get-env-api.js +++ b/src/services/get-env-api.js @@ -1,8 +1,20 @@ import store from "../store"; import constants from "../utils/constants"; -export default function () { - return store.getters.env === "test" - ? constants.api.testnet - : constants.api.mainnet; +const CURRENT_API_VERSION = import.meta.env.VITE_CURRENT_API_VERSION; + +export default function getEnvApi(version = CURRENT_API_VERSION) { + let apiEndpoint = + store.getters.env === "test" + ? constants.api.testnet + : constants.api.mainnet; + + if (!version) { + return apiEndpoint; + } + + if (!apiEndpoint.endsWith("/")) { + apiEndpoint += "/"; + } + return apiEndpoint + "api/" + version; } diff --git a/src/services/profile.service.js b/src/services/profile.service.js index 8d4b8241..90bb64d3 100644 --- a/src/services/profile.service.js +++ b/src/services/profile.service.js @@ -3,7 +3,7 @@ import getEnvApi from "./get-env-api"; import store from "../store"; export function fetchProfile() { - return axios.get(getEnvApi() + "/api/profile/", { + return axios.get(getEnvApi() + "/profile/", { headers: { Authorization: "Bearer " + store.getters.accessToken, }, @@ -12,7 +12,7 @@ export function fetchProfile() { export function updateOrganization({ name, country, size, region }) { return axios.post( - getEnvApi() + "/api/update-organization/", + getEnvApi() + "/update-organization/", { name, country, size, region }, { headers: { diff --git a/src/services/user.service.js b/src/services/user.service.js index 5492c761..3198b91b 100644 --- a/src/services/user.service.js +++ b/src/services/user.service.js @@ -3,20 +3,17 @@ import getEnvApi from "./get-env-api"; import store from "../store"; export function fetchAllUsers() { - return axios.get( - getEnvApi() + "/api/user-details/?id=" + store.getters.appId, - { - headers: { - Authorization: "Bearer " + store.getters.accessToken, - }, - } - ); + return axios.get(getEnvApi() + "/user-details/?id=" + store.getters.appId, { + headers: { + Authorization: "Bearer " + store.getters.accessToken, + }, + }); } export function searchUsers(address) { return axios.get( getEnvApi() + - "/api/user-transactions/?id=" + + "/user-transactions/?id=" + store.getters.appId + "&address=" + address, @@ -31,7 +28,7 @@ export function searchUsers(address) { export function fetchAllUserTransactions(userAddress) { return axios.get( getEnvApi() + - "/api/user-transactions/?id=" + + "/user-transactions/?id=" + store.getters.appId + "&address=" + userAddress, @@ -44,12 +41,9 @@ export function fetchAllUserTransactions(userAddress) { } export function fetchMonthlyUsers() { - return axios.get( - getEnvApi() + "/api/no-of-users/?id=" + store.getters.appId, - { - headers: { - Authorization: "Bearer " + store.getters.accessToken, - }, - } - ); + return axios.get(getEnvApi() + "/no-of-users/?id=" + store.getters.appId, { + headers: { + Authorization: "Bearer " + store.getters.accessToken, + }, + }); } From 8ef3dd14ff9ee0a33b95369efe0eb4d34b9d4599 Mon Sep 17 00:00:00 2001 From: Shrinath Prabhu Date: Tue, 15 Feb 2022 12:29:35 +0530 Subject: [PATCH 5/5] Bumped the version to 0.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 29419824..4e859ee1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "arcana-developer-dashboard", - "version": "0.1.0", + "version": "0.1.1", "private": true, "scripts": { "dev": "vite",