Skip to content

Commit

Permalink
resolving conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Viterbo committed Sep 14, 2022
2 parents 818c6f8 + 5730913 commit 4494139
Show file tree
Hide file tree
Showing 68 changed files with 383 additions and 221 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"dependencies": {
"@quasar/extras": "^1.0.0",
"@telosnetwork/ual-cleos": "^0.1.0",
"assert": "^2.0.0",
"axios": "^0.21.1",
"core-js": "^3.6.5",
Expand Down
2 changes: 1 addition & 1 deletion quasar.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ module.exports = configure(function (ctx) {
directives: ["ClosePopup", "Ripple"],

// Quasar plugins
plugins: ["Notify", "Loading", "BottomSheet"],
plugins: ["Notify", "Dialog", "Loading", "BottomSheet"],
},

// animations: 'all', // --- includes all animations
Expand Down
35 changes: 13 additions & 22 deletions src/boot/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@ const signTransaction = async function (actions) {
});
let transaction = null;
try {
if (this.$type === "ual") {
transaction = await this.$ualUser.signTransaction(
{
actions,
},
{
blocksBehind: 3,
expireSeconds: 30,
}
);
}
transaction = await this.$ualUser.signTransaction(
{
actions,
},
{
blocksBehind: 3,
expireSeconds: 30,
}
);
} catch (e) {
throw e.cause.error.details[0].message.replace(
/assertion failure with message: /g,
Expand All @@ -38,26 +36,19 @@ const signTransaction = async function (actions) {
};

const getTableRows = async function (options) {
if (this.$type === "ual") {
return this.$ualUser.rpc.get_table_rows({
json: true,
...options,
});
} else {
try {
return this.$defaultApi.rpc.get_table_rows({
json: true,
...options,
});
} catch (e) {
console.error(e);
}
};

const getAccount = async function (account) {
try {
if (this.$type === "ual") {
return this.$ualUser.rpc.get_account(account);
} else {
return this.$defaultApi.rpc.get_account(account);
}
return this.$defaultApi.rpc.get_account(account);
} catch (e) {
console.error(e);
}
Expand Down
12 changes: 6 additions & 6 deletions src/boot/layouts.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { boot } from "quasar/wrappers";
import LayoutMain from "../layouts/main.vue";
import LayoutEmpty from "../layouts/empty.vue";
import LayoutGuest from "../layouts/guest.vue";
import AuthLayout from "../layouts/AuthLayout.vue";
import EmptyLayout from "../layouts/EmptyLayout.vue";
import GuestLayout from "../layouts/GuestLayout.vue";

// "async" is optional;
// more info on params: https://v2.quasar.dev/quasar-cli/boot-files
export default boot(async ({ app }) => {
app.component("layout-main", LayoutMain);
app.component("layout-empty", LayoutEmpty);
app.component("layout-guest", LayoutGuest);
app.component("layout-main", AuthLayout);
app.component("layout-empty", EmptyLayout);
app.component("layout-guest", GuestLayout);
});
124 changes: 124 additions & 0 deletions src/boot/ual.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { boot } from "quasar/wrappers";
import { UAL } from "universal-authenticator-library";
import { Anchor } from "ual-anchor";
import { CleosAuthenticator } from "@telosnetwork/ual-cleos";
import { copyToClipboard } from "quasar";

// "async" is optional;
// more info on params: https://v2.quasar.dev/quasar-cli/boot-files
Expand All @@ -17,8 +19,130 @@ export default boot(async ({ app, store }) => {
],
};

async function loginHandler() {
let accountName = "eosio";
let permission = "active";
if (localStorage.getItem("autoLogin") === "cleos") {
accountName = localStorage.getItem("account");
} else {
await new Promise((resolve) => {
app.config.globalProperties.$q
.dialog({
color: "primary",
title: "Connect to cleos",
message: "Account name",
prompt: {
model: "",
type: "text",
},
cancel: true,
persistent: true,
})
.onOk((data) => {
accountName = data != "" ? data : "eosio";
})
.onCancel(() => {
throw "Cancelled!";
})
.onDismiss(() => {
resolve(true);
});
});
await new Promise((resolve) => {
app.config.globalProperties.$q
.dialog({
color: "primary",
title: "Connect to cleos",
message: "Account permission",
options: {
type: "radio",
model: [],
items: [
{ label: "Active", value: "active" },
{ label: "Owner", value: "owner" },
],
},
cancel: true,
persistent: true,
})
.onOk((data) => {
permission = data;
})
.onCancel(() => {
throw "Cancelled!";
})
.onDismiss(() => {
resolve(true);
});
});
}
return {
accountName,
permission,
};
}

async function signHandler(trx) {
const trxJSON = JSON.stringify(
Object.assign(
{
delay_sec: 0,
max_cpu_usage_ms: 0,
},
trx
),
null,
4
);
await new Promise((resolve) => {
app.config.globalProperties.$q
.dialog({
color: "primary",
message: `<pre>cleos -u https://${process.env.NETWORK_HOST} push transaction '${trxJSON}'</pre>`,
html: true,
cancel: true,
fullWidth: true,
ok: {
label: "Copy",
},
})
.onOk(() => {
copyToClipboard(
`cleos -u https://${process.env.NETWORK_HOST} push transaction '${trxJSON}`
)
.then(() => {
app.config.globalProperties.$q.notify({
color: "green-4",
textColor: "white",
message: "Copied to clipboard",
timeout: 1000,
});
})
.catch(() => {
app.config.globalProperties.$q.notify({
color: "red-8",
textColor: "white",
message: "Could not copy",
timeout: 1000,
});
});
})
.onCancel(() => {
throw "Cancelled!";
})
.onDismiss(() => {
resolve(true);
});
});
}

const authenticators = [
new Anchor([mainChain], { appName: process.env.APP_NAME }),
new CleosAuthenticator([mainChain], {
appName: process.env.APP_NAME,
loginHandler,
signHandler,
}),
];

const ual = new UAL([mainChain], "tet-ual", authenticators);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script>
import Btn from "./btn";
import Btn from "./CustomButton";
import { mapActions, mapMutations, mapGetters } from "vuex";
import { scroll } from "quasar";
export default {
name: "action-bar",
name: "ActionBar",
components: { Btn },
props: {
treasuriesOptions: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ q-dialog(

<script>
export default {
name: 'confirm-dialog',
name: 'ConfirmDialog',
props: {
show: { type: Boolean, required: true }
},
Expand Down
3 changes: 1 addition & 2 deletions src/components/btn.vue → src/components/CustomButton.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script>
export default {
// eslint-disable-next-line vue/multi-word-component-names
name: "btn",
name: "CustomButton",
props: {
primary: Boolean,
labelText: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script>
import { mapGetters } from "vuex";
import Btn from "./btn";
import Btn from "./CustomButton";
export default {
name: "welcome-card",
name: "WelcomeCard",
components: { Btn },
data() {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script>
import { mapActions, mapMutations, mapGetters } from "vuex";
import HeaderMenu from "~/components/layout/header-menu";
import RightMenuAuthenticated from "~/components/layout/right-menu-authenticated";
import RightMenuGuest from "~/components/layout/right-menu-guest";
import HeaderMenu from "~/components/layout/HeaderMenu";
import RightMenuAuthenticated from "~/components/layout/RightMenuAuthenticated";
import RightMenuGuest from "~/components/layout/RightMenuGuest";
export default {
name: "app-header",
name: "AppHeader",
components: {
HeaderMenu,
RightMenuAuthenticated,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { mapGetters } from "vuex";
export default {
name: "header-menu",
name: "HeaderMenu",
computed: {
...mapGetters("accounts", ["isAuthenticated"]),
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
export default {
name: "left-menu-authenticated",
name: "LeftMenu",
methods: {
closeMenu: function () {
this.$emit("close");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import { mapActions, mapGetters } from "vuex";
export default {
// eslint-disable-next-line vue/multi-word-component-names
name: "login",
name: "LoginLayout",
data() {
return {
show: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { mapActions, mapGetters } from "vuex";
import ProfileAvatar from "src/pages/profiles/ProfileAvatar.vue";
export default {
name: "right-menu-authenticated",
name: "RightMenuAuthenticated",
components: {
ProfileAvatar,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script>
import Btn from "../btn";
import Btn from "../CustomButton";
import { mapActions } from "vuex";
export default {
name: "right-menu-guest",
name: "RightMenuGuest",
components: { Btn },
props: {
landingPage: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { mapGetters, mapMutations } from 'vuex'
export default {
name: 'right-menu-notifications',
name: 'RightMenuNotifications',
computed: {
...mapGetters('notifications', ['notifications'])
},
Expand Down
8 changes: 4 additions & 4 deletions src/layouts/main.vue → src/layouts/AuthLayout.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script>
import { mapActions, mapGetters, mapMutations } from "vuex";
import AppHeader from "~/components/layout/app-header";
import LeftMenu from "~/components/layout/left-menu";
import RightMenuNotifications from "~/components/layout/right-menu-notifications";
import AppHeader from "~/components/layout/AppHeader";
import LeftMenu from "~/components/layout/LeftMenu";
import RightMenuNotifications from "~/components/layout/RightMenuNotifications";
export default {
name: "layout-auth",
name: "AuthLayout",
components: {
AppHeader,
LeftMenu,
Expand Down
6 changes: 3 additions & 3 deletions src/layouts/empty.vue → src/layouts/EmptyLayout.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
import { mapActions, mapGetters, mapMutations } from "vuex";
import RightMenuAuthenticated from "~/components/layout/right-menu-authenticated";
import RightMenuGuest from "~/components/layout/right-menu-guest";
import RightMenuAuthenticated from "~/components/layout/RightMenuAuthenticated";
import RightMenuGuest from "~/components/layout/RightMenuGuest";
export default {
components: {
Expand All @@ -20,7 +20,7 @@ export default {
]),
...mapActions("accounts", ["autoLogin"]),
},
name: "layout-empty",
name: "EmptyLayout",
};
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/layouts/guest.vue → src/layouts/GuestLayout.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
export default {
name: "layout-guest",
name: "GuestLayout",
computed: {
title() {
return this.$t(this.$route.meta.title || "common.defaultTitle");
Expand Down
Loading

0 comments on commit 4494139

Please sign in to comment.