diff --git a/src/modules/[chain]/faucet/index.vue b/src/modules/[chain]/faucet/index.vue index ac0b3a4a..c8803849 100644 --- a/src/modules/[chain]/faucet/index.vue +++ b/src/modules/[chain]/faucet/index.vue @@ -6,9 +6,35 @@ import { ref, onMounted, computed } from 'vue'; const chainStore = useBlockchain(); const format = useFormatter(); +interface FaucetResponse { + status: string; + result: any; + message: string; +} + +const address = ref(''); +const faucet = ref(''); +const balances = ref([]); +const faucetModal = ref(false); +const ret = ref({} as FaucetResponse); +const configChecker = ref(''); + +const checklist = computed(() => { + const endpoint = chainStore.current?.endpoints?.rest + const bs = balances.value.length > 0 && balances.value.findIndex((v:any) => v.amount <= 10) === -1; + return [ + { title: 'Rest Endpoint', status: endpoint && endpoint[0].address !== '' }, + { title: 'Has Faucet Configured', status: chainStore.current?.faucet !== undefined }, + { title: 'Faucet Account', status: faucet.value !== ''}, + { title: 'Faucet Balance', status: bs}, + ]; +}); const notReady = computed(() => { - return chainStore.current === undefined || chainStore.current.faucet === undefined; + for (const it of checklist.value) { + if (!it.status) return true; + } + return false; }); const validAddress = computed(() => { @@ -22,18 +48,6 @@ const faucetUrl = computed(() => { }); -interface FaucetResponse { - status: string; - result: any; - message: string; -} - -const address = ref(''); -const faucet = ref(''); -const balances = ref([]); -const faucetModal = ref(false); -const ret = ref({} as FaucetResponse); - function claim() { ret.value = {} as FaucetResponse; @@ -49,14 +63,19 @@ function claim() { function balance() { get(`${faucetUrl.value}/balance`).then(res => { + if(res.status === 'error') { + configChecker.value = res.message; + return; + } balances.value = res.result?.balance; faucet.value = res.result?.address; }); } onMounted(() => { - if (notReady.value) return; - balance(); + if (chainStore.current && chainStore.current.faucet) { + balance(); + } }); @@ -105,9 +124,14 @@ onMounted(() => {
1. Submit chain configuation
-
https://github.com/ping-pub/faucet 
+
+
{{ it.title }}: {{ it.status ? '✅' : '❌' }} 
+
+ +
{{ configChecker }}
+

                     Go
+                        href="https://github.com/ping-pub/ping.pub/blob/main/faucet.md">Update
                 
2. Fund the faucet account