-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.vue
94 lines (86 loc) · 1.71 KB
/
index.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<template>
<div>
<table>
<tr>
<td class="col1">
Data:
<textarea v-model="data" />
Schema:
<textarea v-model="schema" />
<button class="submit" @click="notarize">Notarize</button>
</td>
<td class="col2">
Output:
<pre class="output">{{ output }}</pre>
Imprint
<pre class="imprint">{{ imprint }}</pre>
</td>
</tr>
</table>
</div>
</template>
<script>
import { Cert } from '@0xcert/cert';
export default {
data() {
return {
data: "",
schema: "",
output: "",
imprint: "",
}
},
methods: {
async notarize() {
const cert = new Cert({ schema: JSON.parse(this.schema) })
const recipes = await cert.notarize(JSON.parse(this.data))
const keys = {}
recipes.forEach((recipe) => {
keys[recipe.nodes[0].hash] = recipe.path.join('.')
})
this.output = recipes.map((recipe) => {
return [
recipe.path.join('.'),
': ',
...recipe.values.map((v) => {
if (v.value.length == 64) {
return keys[v.value]
} else {
return v.value
}
}).join(', ')
].join('');
}).join('\n')
this.imprint = await cert.imprint(JSON.parse(this.data))
}
}
}
</script>
<style>
table {
width: 100%;
}
.col1, .col2 {
width: 50%;
padding: 20px;
vertical-align: top;
}
textarea {
width: 100%;
height: 300px;
}
.output {
height: 496px;
background: #c0c0c0;
}
.imprint {
height: 80px;
background: #c0c0c0;
}
.submit {
width: 200px;
background: #ff0000;
line-height: 30px;
color: #ffffff;
}
</style>