-
{{ shortHex(requestId) }}
-
leslie@flowbite.com
+
+
+
+
+
+
- {{ shortHex(content.cid) }} |
+
+
+ |
diff --git a/src/components/Tooltip.vue b/src/components/Tooltip.vue
new file mode 100644
index 0000000..921aa61
--- /dev/null
+++ b/src/components/Tooltip.vue
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/main.js b/src/main.js
index 65b607d..011c9ba 100644
--- a/src/main.js
+++ b/src/main.js
@@ -2,13 +2,14 @@
import { createApp } from 'vue'
import { createPinia } from 'pinia'
+import uniqueId from '@/plugins/UniqueIdPlugin'
-import App from './App.vue'
-import router from './router'
-import ethersPlugin from './plugins/EthersPlugin'
-import codexPlugin from './plugins/CodexPlugin'
-import marketplacePlugin from './plugins/MarketplacePlugin'
-import testTokenPlugin from './plugins/TestTokenPlugin'
+import App from '@/App.vue'
+import router from '@/router'
+import ethersPlugin from '@/plugins/EthersPlugin'
+import codexPlugin from '@/plugins/CodexPlugin'
+import marketplacePlugin from '@/plugins/MarketplacePlugin'
+import testTokenPlugin from '@/plugins/TestTokenPlugin'
import './index.css'
@@ -1084,6 +1085,7 @@ app.use(marketplacePlugin, {
}
],
address: '0x4cBDfab37baB0AA3AC69A7b12C4396907dfF5227'
+ // address: '0x9C88D67c7C745D2F0A4E411c18A6a22c15b37EaA' // new address!
})
app.use(testTokenPlugin, {
abi: [
@@ -1387,5 +1389,5 @@ app.use(codexPlugin, {
codexRestUrl: 'http://localhost:8080/api/codex/v1',
myAddress: '0xE3b2588a05260caC3EEAbfBFd7937BbC14eB0aC7'
})
-
+app.use(uniqueId)
app.mount('#app')
diff --git a/src/plugins/UniqueIdPlugin.js b/src/plugins/UniqueIdPlugin.js
new file mode 100644
index 0000000..7df854e
--- /dev/null
+++ b/src/plugins/UniqueIdPlugin.js
@@ -0,0 +1,70 @@
+// Copyright (c) 2019, Bertrand Guay-Paquet
+//
+// Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+const methods = {
+ /**
+ * Generate a component-scoped unique HTML identifier.
+ *
+ * Example: $id('my-id') => 'uid-42-my-id'
+ *
+ * @param {string} id id to scope
+ */
+ $idFactory(uidProperty) {
+ return function $id(id = '') {
+ return `${this[uidProperty]}-${id}`;
+ };
+ },
+
+ /**
+ * Generate a component-scoped unique HTML identifier reference. Prepends '#' to the id generated
+ * by the call $id(id).
+ *
+ * Example: $idRef('my-id') => '#uid-42-my-id'
+ *
+ * @param {string} id id to scope
+ */
+ $idRef(id) {
+ return `#${this.$id(id)}`;
+ },
+};
+
+const DEFAULTS = {
+ // {string} Property name of the component's unique identifier. Change this if 'vm.uid' conflicts
+ // with another plugin or your own props.
+ uidProperty: 'uid',
+
+ // {string} Prefix to use when generating HTML ids. Change this to make your ids more unique on a
+ // page that already uses or could use a similar naming scheme.
+ uidPrefix: 'uid-',
+};
+
+function installVueGlobal(Vue, globalName, globalValue) {
+ const globalPrototype = Vue.version.slice(0, 2) === '3.' ? Vue.config.globalProperties : Vue.prototype;
+
+ // Don't use Object.assign() to match the Vue.js supported browsers (ECMAScript 5)
+ globalPrototype[globalName] = globalValue;
+}
+
+export default function install(Vue, options = {}) {
+ // Don't use object spread to merge the defaults because bublé transforms that to Object.assign
+ const uidProperty = options.uidProperty || DEFAULTS.uidProperty;
+ const uidPrefix = options.uidPrefix || DEFAULTS.uidPrefix;
+
+ // Assign a unique id to each component
+ let uidCounter = 0;
+ Vue.mixin({
+ beforeCreate() {
+ uidCounter += 1;
+ const uid = uidPrefix + uidCounter;
+ Object.defineProperties(this, {
+ [uidProperty]: { get() { return uid; } },
+ });
+ },
+ });
+
+ installVueGlobal(Vue, '$id', methods.$idFactory(uidProperty));
+ installVueGlobal(Vue, '$idRef', methods.$idRef);
+}
\ No newline at end of file
diff --git a/src/stores/requests.js b/src/stores/requests.js
index 5fd1931..6b1ff69 100644
--- a/src/stores/requests.js
+++ b/src/stores/requests.js
@@ -27,7 +27,7 @@ export const useRequestsStore = defineStore('request', () => {
// const requestFailedEvents = ref([]) // {blockNumber, requestId}
// const requestFinishedEvents = ref([]) // {blockNumber, requestId}
const loading = ref(false)
- const fetched = ref(false)
+ const blocks = ref(new Map())
// const request = computed(() => count.value * 2)
// onStorageRequested => add request to requests ref, along with slots
@@ -75,30 +75,58 @@ export const useRequestsStore = defineStore('request', () => {
// blockNumbers.value.add(blockNumber)
}
+ const getBlock = async (blockHash) => {
+ if (blocks.value.has(blockHash)) {
+ return blocks.value.get(blockHash)
+ } else {
+ let block = await ethProvider.getBlock(blockHash)
+ blocks.value.set(blockHash, block)
+ return block
+ }
+ }
+
async function fetch() {
// query past events
loading.value = true
try {
- let pastRequests = await marketplace.queryFilter(StorageRequested)
- pastRequests.forEach(async (event) => {
+ let events = await marketplace.queryFilter(StorageRequested)
+ console.log('got ', events.length, ' StorageRequested events')
+ let reqs = new Map()
+ events.forEach(async (event, i) => {
+ console.log('getting details for StorageRequested event ', i)
+ let start = Date.now()
+ // let event = events[i]
+ // await events.forEach(async (event) => {
let { requestId, ask, expiry } = event.args
- // let { blockNumber } = event
+ let { blockHash, blockNumber } = event
let arrRequest = await marketplace.getRequest(requestId)
let request = arrayToObject(arrRequest)
let state = await getRequestState(requestId)
let slots = await getSlots(requestId, request.ask.slots)
+ let block = await getBlock(blockHash)
+ // populate temp map to constrain state update volume
+ // reqs.set(requestId, {
+ // ...request,
+ // state,
+ // slots: [],
+ // requestedAt: block.timestamp,
+ // requestFinishedId: null
+ // })
requests.value.set(requestId, {
...request,
state,
slots,
+ requestedAt: block.timestamp,
requestFinishedId: null
})
+ console.log(`got details for ${i} in ${(Date.now() - start) / 1000} seconds`)
+ if (i === events.length - 1) {
+ loading.value = false
+ }
})
+ // reqs.forEach((request, requestId) => requests.value.set(requestId, request))
} catch (error) {
console.error(`failed to load past contract events: ${error.message}`)
- } finally {
- loading.value = false
- fetched.value = true
}
}
@@ -152,15 +180,17 @@ export const useRequestsStore = defineStore('request', () => {
onSlotFilled
) {
marketplace.on(StorageRequested, async (requestId, ask, expiry, event) => {
- let { blockNumber } = event.log
+ let { blockNumber, blockHash } = event.log
let arrRequest = await marketplace.getRequest(requestId)
let request = arrayToObject(arrRequest)
let state = await getRequestState(requestId)
let slots = await getSlots(requestId, request.ask.slots)
+ let block = await getBlock(blockHash)
requests.value.set(requestId, {
...request,
state,
slots,
+ requestedAt: block.timestamp,
requestFinishedId: null
})
@@ -239,7 +269,6 @@ export const useRequestsStore = defineStore('request', () => {
// requestFinishedEvents,
fetch,
listenForNewEvents,
- loading,
- fetched
+ loading
}
})
diff --git a/src/utils/ids.js b/src/utils/ids.js
index 85c929b..c43ad13 100644
--- a/src/utils/ids.js
+++ b/src/utils/ids.js
@@ -1,28 +1,7 @@
import { keccak256 } from 'ethers/crypto'
import { AbiCoder } from 'ethers/abi'
-// func shortLog*(long: string, ellipses = "*", start = 3, stop = 6): string =
-// ## Returns compact string representation of ``long``.
-// var short = long
-// let minLen = start + ellipses.len + stop
-// if len(short) > minLen:
-// short.insert(ellipses, start)
-
-// when (NimMajor, NimMinor) > (1, 4):
-// short.delete(start + ellipses.len .. short.high - stop)
-// else:
-// short.delete(start + ellipses.len, short.high - stop)
-
-// short
-
-// func shortHexLog*(long: string): string =
-// if long[0..1] == "0x": result &= "0x"
-// result &= long[2..long.high].shortLog("..", 4, 4)
-
-// func short0xHexLog*[N: static[int], T: array[N, byte]](v: T): string =
-// v.to0xHex.shortHexLog
-
-export function short(long, ellipses = '*', start = 3, stop = 6) {
+function short(long, ellipses = '*', start = 3, stop = 6) {
var short = long
const minLen = start + ellipses.length + stop
if (short.length > minLen) {
@@ -33,14 +12,14 @@ export function short(long, ellipses = '*', start = 3, stop = 6) {
return short
}
-export function shortHex(long, chars = 4) {
+export function shorten(long, ellipses = '..', chars = 4) {
let shortened = ''
let rest = long
if (long.substring(0, 2) === '0x') {
shortened = '0x'
rest = long.substring(2)
}
- shortened += short(rest, '..', chars, chars)
+ shortened += short(rest, ellipses, chars, chars)
return shortened
}
diff --git a/src/views/RequestsView.vue b/src/views/RequestsView.vue
index 8180bba..55819e5 100644
--- a/src/views/RequestsView.vue
+++ b/src/views/RequestsView.vue
@@ -6,9 +6,9 @@ import SkeletonLoading from '@/components/SkeletonLoading.vue'
import { computed } from 'vue'
const requestsStore = useRequestsStore()
-const { loading, fetched, requests } = storeToRefs(requestsStore)
+const { loading, requests } = storeToRefs(requestsStore)
const isLoading = computed(
- () => loading.value || !fetched.value || !requests.value || requests.value?.size === 0
+ () => loading.value || !requests.value
)
diff --git a/yarn.lock b/yarn.lock
index a37a98b..7ab236d 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -470,6 +470,11 @@
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.0.tgz#a5417ae8427873f1dd08b70b3574b453e67b5f7f"
integrity sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==
+"@feelinglovelynow/get-relative-time@^1.1.2":
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/@feelinglovelynow/get-relative-time/-/get-relative-time-1.1.2.tgz#7c11a0345926918094c9745085f72fd591916338"
+ integrity sha512-3nnyH71EkAVH5sdxJpWWBjRTm5yXNtOQSPp1WtkKMd1//noO//tzdJShsDfCy9D1XQV0BbAPJ2btUstqtMT2mw==
+
"@humanwhocodes/config-array@^0.11.14":
version "0.11.14"
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.14.tgz#d78e481a039f7566ecc9660b4ea7fe6b1fec442b"
@@ -2603,6 +2608,11 @@ vue-router@^4.3.0:
dependencies:
"@vue/devtools-api" "^6.5.1"
+vue-unique-id@^3.2.1:
+ version "3.2.1"
+ resolved "https://registry.yarnpkg.com/vue-unique-id/-/vue-unique-id-3.2.1.tgz#e5db2e8620409a4b718578ca7f00eac78b15e818"
+ integrity sha512-Ih4vw3nx5O0M0q16Omx23T6VQW5U+RD16SEEbGa+aJWLJxFco8slQN6z6GUuzwgREgofH3ns9n7a97qr6DI73g==
+
vue@^3.4.21:
version "3.4.27"
resolved "https://registry.yarnpkg.com/vue/-/vue-3.4.27.tgz#40b7d929d3e53f427f7f5945386234d2854cc2a1"
|