Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
xmonader committed Nov 10, 2021
2 parents f959bd1 + 895b591 commit d5aaf5d
Show file tree
Hide file tree
Showing 36 changed files with 435 additions and 208 deletions.
2 changes: 1 addition & 1 deletion docs/wiki/identity.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Parameters:
- explorer_url: The explorer url for the explorer you want to use:
- Testnet: `https://explorer.testnet.grid.tf/api/v1/`
- Mainnet: `https://explorer.grid.tf/explorer/`
- Mainnet: `https://explorer.grid.tf/api/v1/`
- Devnet: `https://explorer.devnet.grid.tf/api/v1/`

It's really recommended to use tname, email, words from ThreeFold Connect application .
Expand Down
5 changes: 3 additions & 2 deletions jumpscale/clients/stellar/stellar.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from urllib import parse
from urllib.parse import urlparse
from typing import Union

import gevent
import stellar_sdk
from jumpscale.clients.base import Client
from jumpscale.core.base import fields
Expand Down Expand Up @@ -486,6 +486,7 @@ def transfer(
)
except Exception as e:
nretries += 1
gevent.sleep(1)
j.logger.warning(str(e))

raise j.exceptions.Runtime(f"Failed to make transaction for {retries} times, Please try again later")
Expand All @@ -505,7 +506,7 @@ def _transfer(
sign: bool = True,
):
issuer = None
j.logger.info(f"Sending {amount} {asset} to {destination_address}")
j.logger.info(f"Sending {amount} {asset} from {self.address} to {destination_address}")
if asset != "XLM":
assetStr = asset.split(":")
if len(assetStr) != 2:
Expand Down
11 changes: 9 additions & 2 deletions jumpscale/packages/admin/actors/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def get_identity(self, identity_instance_name: str) -> str:
"tid": identity.tid,
"explorer_url": identity.explorer_url,
"words": identity.words,
"admins": identity.admins,
}
}
)
Expand Down Expand Up @@ -127,7 +128,13 @@ def check_identity_instance_name(self, name) -> str:
return j.data.serializers.json.dumps({"data": False})

@actor_method
def add_identity(self, display_name: str, tname: str, email: str, words: str, explorer_type: str) -> str:
def add_identity(self, display_name: str, tname: str, email: str, words: str, explorer_type: str, admins: list) -> str:
checked_admins = []
for admin in admins:
if type(admin) is str and not admin.endswith(".3bot"):
admin = admin + ".3bot"
checked_admins.append(admin)

if not display_name.isidentifier() or not display_name.islower():
raise j.exceptions.Value(
"The display name must be a lowercase valid python identitifier (English letters, underscores, and numbers not starting with a number)."
Expand All @@ -138,7 +145,7 @@ def add_identity(self, display_name: str, tname: str, email: str, words: str, ex
raise j.exceptions.Value("Identity with the same name already exists")
try:
new_identity = j.core.identity.new(
name=identity_instance_name, tname=tname, email=email, words=words, explorer_url=explorer_url
name=identity_instance_name, tname=tname, email=email, words=words, explorer_url=explorer_url, admins=checked_admins
)
new_identity.register()
new_identity.save()
Expand Down
2 changes: 1 addition & 1 deletion jumpscale/packages/admin/frontend/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
<v-btn
depressed
color="primary"
href="https://support.grid.tf/"
href="https://threefold.io/support"
target="_blank"
>Support</v-btn
>
Expand Down
4 changes: 2 additions & 2 deletions jumpscale/packages/admin/frontend/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,12 @@ const apiClient = {
url: `${baseURL}/admin/list_identities`
})
},
add: (display_name, tname, email, words, explorer_type) => {
add: (display_name, tname, email, words, explorer_type, admins) => {
return axios({
url: `${baseURL}/admin/add_identity`,
method: "post",
headers: { 'Content-Type': 'application/json' },
data: { display_name: display_name, tname: tname, email: email, words: words, explorer_type: explorer_type }
data: { display_name, tname, email, words, explorer_type, admins }
})
},
generateMnemonic: () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<template>
<v-container>
<v-row v-if="loading" style="height:100%" align="center" justify="center">
<v-progress-circular size="100" width="5" color="primary" indeterminate></v-progress-circular>
<v-row v-if="loading" style="height: 100%" align="center" justify="center">
<v-progress-circular
size="100"
width="5"
color="primary"
indeterminate
></v-progress-circular>
</v-row>
<!-- <vue-simple-markdown v-else :source="source" :emoji="false"></vue-simple-markdown> -->
<div v-html="source"></div>
Expand All @@ -13,24 +18,24 @@ module.exports = {
data() {
return {
source: "",
loading: true
loading: true,
};
},
props: {
url: String,
baseUrl: String
baseUrl: String,
},
mounted() {
this.loading = true;
this.$root.$emit("sidebar", true);
this.$api.content.get(this.url).then(res => {
this.$api.content.get(this.url).then((res) => {
let options = {};
if (this.baseUrl) {
options.baseUrl = this.baseUrl;
}
this.source = marked(res.data, options);
this.source = marked.parse(res.data, options);
this.loading = false;
});
}
},
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,30 @@
</v-text-field>
<v-text-field v-model="form.tname" label="3Bot name" @blur="checkTNameExists(form.tname)" dense></v-text-field>
<v-text-field v-model="form.email" label="Email" dense></v-text-field>
<!-- Start Admins -->
<v-combobox
v-model="selectedAdmins"
:items="[]"
chips
clearable
label="Add admins"
multiple
solo
>
<template v-slot:selection="{ attrs, item, select, selected }">
<v-chip
v-bind="attrs"
:input-value="selected"
close
@click="select"
@click:close="removeFromAdmins(item)"
color="primary"
>
<span>{{ item }}</span>
</v-chip>
</template>
</v-combobox>
<!-- End Admins -->
<v-text-field v-model="words" label="Words" dense>
<template v-slot:append>
<v-btn
Expand Down Expand Up @@ -52,6 +76,7 @@ module.exports = {
display_name:"",
words: "",
allowCreatMnemonics: false,
selectedAdmins: [],
}
},
computed: {
Expand All @@ -66,13 +91,37 @@ module.exports = {
submit () {
this.loading = true
this.error = null
this.$api.identities.add(this.form.display_name, this.form.tname, this.form.email, this.words, this.explorers[this.selected_explorer].type).then((response) => {
this.done("New Identity added", "success")
}).catch((error) => {
this.$api.admins.getCurrentUser()
.then(({ data }) => {
if (data.username) {
if (this.selectedAdmins.indexOf(data.username) === -1) {
this.selectedAdmins.push(data.username);
}
return this.$api
.identities
.add(
this.form.display_name,
this.form.tname,
this.form.email,
this.words,
this.explorers[this.selected_explorer].type,
this.selectedAdmins);
}
this.error = "Couldn't load current username.";
return null;
})
.then((res) => {
if (res) {
this.done("New Identity added", "success")
}
})
.catch(error => {
this.error = error.response.data.error
}).finally(() => {
this.loading = false
})
})
.finally(() => {
this.loading = false
})
},
getMnemonics(){
this.$api.identities.generateMnemonic().then((response) => {
Expand Down Expand Up @@ -117,7 +166,10 @@ module.exports = {
this.close()
// clear dialog
this.display_name = this.tname = this.email = this.words = "";
}
},
removeFromAdmins(admin) {
this.selectedAdmins = this.selectedAdmins.filter(a => a !== admin);
},
}
}
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<base-dialog title="Admin Confirmation" v-model="dialog" :error="error" :loading="loading">
<template #default>
No admins were found. Are you sure you want to set as default ?
</template>
<template #actions>
<v-btn text @click="close">No</v-btn>
<v-btn text @click="$emit('admin-confirm')" color="red">Yes</v-btn>
</template>
</base-dialog>
</template>

<script>
module.exports = {
mixins: [dialog]
}
</script>
Loading

0 comments on commit d5aaf5d

Please sign in to comment.