-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
3,989 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,55 @@ | ||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
import { ref, toValue } from 'vue' | ||
const count = ref(0) | ||
import { ethersBrowserProvider } from '../wallet'; | ||
import { useIExec } from '../iexec'; | ||
import { ProtectedData } from '@iexec/dataprotector'; | ||
const { dataProtectorCore, dataProtectorWallet } = useIExec(); | ||
const results = ref<ProtectedData[]>([]); | ||
const isLoading = ref(false); | ||
async function refreshData() { | ||
isLoading.value = true; | ||
try { | ||
const browserOwner = (await toValue(ethersBrowserProvider)!.getSigner()).address; | ||
//const dpw = toValue(dataProtectorWallet)! | ||
const dpc = toValue(dataProtectorCore)!; | ||
const blah = results.value = await dpc.getProtectedData({ | ||
owner: browserOwner | ||
}); | ||
console.log(blah); | ||
} finally { | ||
isLoading.value = false; | ||
} | ||
} | ||
refreshData(); | ||
</script> | ||
|
||
<template> | ||
<h1>Hello!</h1> | ||
|
||
<p v-if="isLoading">Loading!...</p> | ||
|
||
owner: {{ dataProtectorWallet?.address }} | ||
|
||
<div class="card"> | ||
<button type="button" @click="count++">count is {{ count }}</button> | ||
<div class="item" v-for="item in results"> | ||
Address: {{ item.address }}<br /> | ||
Schema: {{ item.schema }}<br /> | ||
Timestamp: {{ item.creationTimestamp }}<br /> | ||
Owner: {{ item.owner }}<br /> | ||
</div> | ||
|
||
<button @click.prevent="refreshData">Refresh</button> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
.read-the-docs { | ||
color: #888; | ||
div.item { | ||
border: 1px solid #333; | ||
margin-bottom: 5px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<script setup lang="ts"> | ||
import { randomBytes } from '@noble/hashes/utils'; | ||
import { hexlify } from 'ethers'; | ||
//defineProps(['modelValue']); | ||
const {q} = defineProps<{ | ||
q: Question, | ||
modelValue: string, | ||
disabled?: boolean | ||
}>(); | ||
const emit = defineEmits<{ | ||
(e: 'update:modelValue', modelValue: string): void | ||
}>(); | ||
function updateValue (value:string) { | ||
emit('update:modelValue', value) | ||
}; | ||
type InfoQ = readonly [string, 'info'] | ||
type PromptQ = readonly ['', 'prompt', string]; // Ignored | ||
type NumberRangeQ = readonly [string, 'range', readonly [number,number]]; | ||
type SelectQ = readonly [string, 'select', readonly string[]]; | ||
type NumberQ = readonly [string, 'number']; | ||
type StringQ = readonly [string, 'string']; | ||
type Question = PromptQ | NumberRangeQ | SelectQ | StringQ | NumberQ | InfoQ; | ||
if( q === undefined ) { | ||
throw new Error('Unknown question type!'); | ||
} | ||
const randomId = hexlify(randomBytes(8)); | ||
const [desc, qtype, ...extra] = q; | ||
const range:number[] = []; | ||
if( qtype == 'range' ) { | ||
for( let i = q[2][0]; i <= q[2][1]; i++ ) { | ||
range.push(i); | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<label v-if="qtype!='info'" :for="randomId">{{ desc }}</label> | ||
<div v-if="qtype=='number'"> | ||
<input :disabled="disabled" type="text" size="3" :id="randomId" :value="modelValue" @input="updateValue(($event.target as HTMLInputElement).value)" /> | ||
</div> | ||
<div v-else-if="qtype=='range'"> | ||
<select :disabled="disabled" :id="randomId" @change="updateValue(($event.target as HTMLSelectElement).value)"> | ||
<option value=""></option> | ||
<option v-for="x of range" :value="x">{{ x }}</option> | ||
</select> | ||
</div> | ||
<div v-else-if="qtype=='select'"> | ||
<select :disabled="disabled" :id="randomId" @change="updateValue(($event.target as HTMLSelectElement).value)"> | ||
<option value=""></option> | ||
<option v-for="x of extra[0]" :value="x">{{ x }}</option> | ||
</select> | ||
</div> | ||
<div v-else-if="qtype=='string'" @input="updateValue(($event.target as HTMLInputElement).value)" > | ||
<input :disabled="disabled" type="text" :value="modelValue" :id="randomId" /> | ||
</div> | ||
<div v-else-if="qtype=='info'"> | ||
<p>{{ desc }}</p> | ||
</div> | ||
</template> |
Oops, something went wrong.