Skip to content

Commit

Permalink
Add new Network selection to settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
nyusternie committed Sep 26, 2024
1 parent dcd5bbb commit f8cce25
Show file tree
Hide file tree
Showing 4 changed files with 246 additions and 123 deletions.
116 changes: 116 additions & 0 deletions studio-wallet/components/ChooseNetwork.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<script setup lang="ts">
/* Define properties. */
// https://vuejs.org/guide/components/props.html#props-declaration
const props = defineProps({
data: {
type: [Object],
},
})
// onMounted(() => {
// console.log('Mounted!')
// // Now it's safe to perform setup operations.
// })
// onBeforeUnmount(() => {
// console.log('Before Unmount!')
// // Now is the time to perform all cleanup operations.
// })
</script>

<template>
<main>
<legend class="text-3xl font-light leading-6 text-sky-500 italic tracking-tighter">
Choose Your ACTIVE Network
</legend>

<div class="mt-6 grid grid-cols-1 gap-y-6 sm:grid-cols-3 sm:gap-x-4">
<!-- Active: "border-sky-600 ring-2 ring-sky-600", Not Active: "border-gray-300" -->
<label aria-label="Newsletter" aria-description="Last activity was an hour ago to 621 users" class="relative flex cursor-pointer rounded-lg border border-gray-300 bg-white p-4 shadow-sm focus:outline-none">
<input type="radio" name="project-type" value="Newsletter" class="sr-only" />
<span class="flex flex-1">
<span class="flex flex-col">
<span class="block text-lg font-medium text-gray-700 tracking-tighter">
Nexa Core
</span>

<span class="mt-1 flex items-center text-sm text-gray-500">
Last activity was an hour ago
</span>

<span class="mt-6 text-xs font-medium text-gray-500">
Nexa Layer1 VM
</span>
</span>
</span>
<!-- Not Checked: "invisible" -->
<svg class="invisible h-7 w-auto text-sky-600" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z" clip-rule="evenodd" />
</svg>
<!--
Active: "border", Not Active: "border-2"
Checked: "border-sky-600", Not Checked: "border-transparent"
-->
<span class="pointer-events-none absolute -inset-px rounded-lg border-2 border-transparent" aria-hidden="true"></span>
</label>

<!-- Active: "border-sky-600 ring-2 ring-sky-600", Not Active: "border-gray-300" -->
<label aria-label="Existing Customers" aria-description="Last activity was 2 weeks ago to 1200 users" class="relative flex cursor-pointer rounded-lg border border-sky-600 ring-2 ring-sky-600 bg-white p-4 shadow-sm focus:outline-none">
<input type="radio" name="project-type" value="Existing Customers" class="sr-only" />
<span class="flex flex-1">
<span class="flex flex-col">
<span class="block text-lg font-medium text-gray-700 tracking-tighter">
Nxy Supernet
</span>

<span class="mt-1 flex items-center text-sm text-gray-500">
Last activity was 4 days ago
</span>

<span class="mt-6 text-xs font-medium text-gray-500">
Nexa Layer1+ VM
</span>
</span>
</span>
<!-- Not Checked: "invisible" -->
<svg class="h-7 w-auto text-sky-600" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z" clip-rule="evenodd" />
</svg>
<!--
Active: "border", Not Active: "border-2"
Checked: "border-sky-600", Not Checked: "border-transparent"
-->
<span class="pointer-events-none absolute -inset-px rounded-lg border border-sky-600" aria-hidden="true"></span>
</label>

<!-- Active: "border-sky-600 ring-2 ring-sky-600", Not Active: "border-gray-300" -->
<label aria-label="Trial Users" aria-description="Last activity was 4 days ago to 2740 users" class="relative flex cursor-pointer rounded-lg border border-gray-300 bg-white p-4 shadow-sm focus:outline-none">
<input type="radio" name="project-type" value="Trial Users" class="sr-only" />
<span class="flex flex-1">
<span class="flex flex-col">
<span class="block text-lg font-medium text-gray-700 tracking-tighter">
Nxy MetaNet
</span>

<span class="mt-1 flex items-center text-sm text-gray-500">
There is NO activity recorded yet
</span>

<span class="mt-6 text-xs font-medium text-gray-500">
Ethereum Layer1 VM
</span>
</span>
</span>
<!-- Not Checked: "invisible" -->
<svg class="invisible h-7 w-auto text-sky-600" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z" clip-rule="evenodd" />
</svg>
<!--
Active: "border", Not Active: "border-2"
Checked: "border-sky-600", Not Checked: "border-transparent"
-->
<span class="pointer-events-none absolute -inset-px rounded-lg border-2 border-transparent" aria-hidden="true"></span>
</label>
</div>
</main>
</template>
28 changes: 16 additions & 12 deletions studio-wallet/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,13 @@ currency.value = 'USD'
<template>
<main class="flex flex-col gap-4">

<section class="pr-1 sm:px-3 flex items-center justify-between gap-4">
<ChooseNetwork />

<div class="mx-5 my-5 border-t border-gray-300" />

<section class="pr-1 flex items-center justify-between gap-4">
<span class="flex flex-grow flex-col">
<span class="text-base font-medium leading-6 text-gray-900" id="availability-label">
<span class="text-base font-medium leading-6 text-gray-700" id="availability-label">
ENABLE password protection
</span>

Expand All @@ -80,16 +84,16 @@ currency.value = 'USD'
</span>
</span>

<!-- Enabled: "bg-indigo-600", Not Enabled: "bg-gray-200" -->
<button type="button" class="bg-gray-200 relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-600 focus:ring-offset-2" role="switch" aria-checked="false" aria-labelledby="availability-label" aria-describedby="availability-description">
<!-- Enabled: "bg-sky-600", Not Enabled: "bg-gray-200" -->
<button type="button" class="bg-gray-200 relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-sky-600 focus:ring-offset-2" role="switch" aria-checked="false" aria-labelledby="availability-label" aria-describedby="availability-description">
<!-- Enabled: "translate-x-5", Not Enabled: "translate-x-0" -->
<span aria-hidden="true" class="translate-x-0 pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 duration-200 ease-in-out"></span>
</button>
</section>

<section class="pr-1 sm:px-3 flex items-center justify-between gap-4">
<section class="pr-1 flex items-center justify-between gap-4">
<span class="flex flex-grow flex-col">
<span class="text-base font-medium leading-6 text-gray-900" id="availability-label">
<span class="text-base font-medium leading-6 text-gray-700" id="availability-label">
ENABLE address privacy
</span>

Expand All @@ -98,16 +102,16 @@ currency.value = 'USD'
</span>
</span>

<!-- Enabled: "bg-indigo-600", Not Enabled: "bg-gray-200" -->
<button type="button" class="bg-gray-200 relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-600 focus:ring-offset-2" role="switch" aria-checked="false" aria-labelledby="availability-label" aria-describedby="availability-description">
<!-- Enabled: "bg-sky-600", Not Enabled: "bg-gray-200" -->
<button type="button" class="bg-gray-200 relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-sky-600 focus:ring-offset-2" role="switch" aria-checked="false" aria-labelledby="availability-label" aria-describedby="availability-description">
<!-- Enabled: "translate-x-5", Not Enabled: "translate-x-0" -->
<span aria-hidden="true" class="translate-x-0 pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 duration-200 ease-in-out"></span>
</button>
</section>

<section class="pr-1 sm:px-3 flex items-center justify-between gap-4">
<section class="pr-1 flex items-center justify-between gap-4">
<span class="flex flex-grow flex-col">
<span class="text-base font-medium leading-6 text-gray-900" id="availability-label">
<span class="text-base font-medium leading-6 text-gray-700" id="availability-label">
ENABLE transaction privacy
</span>

Expand All @@ -116,8 +120,8 @@ currency.value = 'USD'
</span>
</span>

<!-- Enabled: "bg-indigo-600", Not Enabled: "bg-gray-200" -->
<button type="button" class="bg-gray-200 relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-600 focus:ring-offset-2" role="switch" aria-checked="false" aria-labelledby="availability-label" aria-describedby="availability-description">
<!-- Enabled: "bg-sky-600", Not Enabled: "bg-gray-200" -->
<button type="button" class="bg-gray-200 relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-sky-600 focus:ring-offset-2" role="switch" aria-checked="false" aria-labelledby="availability-label" aria-describedby="availability-description">
<!-- Enabled: "translate-x-5", Not Enabled: "translate-x-0" -->
<span aria-hidden="true" class="translate-x-0 pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 duration-200 ease-in-out"></span>
</button>
Expand Down
36 changes: 18 additions & 18 deletions studio-wallet/stores/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@
import { defineStore } from 'pinia'

import { encodeAddress } from '@nexajs/address'
import {
hash160,
ripemd160,
sha256,
} from '@nexajs/crypto'
import { hash160 } from '@nexajs/crypto'
import { mnemonicToEntropy } from '@nexajs/hdnode'
import { sendCoins } from '@nexajs/purse'
import {
encodeDataPush,
OP,
} from '@nexajs/script'
import {
binToHex,
hexToBin,
} from '@nexajs/utils'
import {
Wallet,
WalletStatus,
Expand Down Expand Up @@ -82,12 +74,16 @@ export const useWalletStore = defineStore('wallet', {
/**
* Networks
*
* Manages all Layer 1 Networks and Layer 1+ (Plus) Supernets
* running on the Nexa blockchain.
* Manages all Layer1 Networks, Layer1+ (Plus) Supernets,
* and Layer1 (EVM) MetaNets "managed by" the Nexa Core blockchain.
*/
_networks: [
'NEXA', // Nexa Core
'NXY', // Nxy Social
'METANEXA', // Nexa (MetaNet)
'METANXY', // Nxy (MetaNet)
'METATELR', // TΞLR (MetaNet)
'NEXA', // Nexa (Core/Base Network)
'NXY', // Nxy (Supernet)
'TELR', // TΞLR (Supernet)
],

/**
Expand Down Expand Up @@ -234,7 +230,11 @@ export const useWalletStore = defineStore('wallet', {
},

getNetwork(_networkid) {
if (this.networks.includes(_networkid.toUpperCase())) {
if (
this.wallet &&
this.wallet.publicKey &&
this.networks.includes(_networkid.toUpperCase())
) {
/* Initialize locals. */
let publicKeyHash
let scriptData
Expand All @@ -249,18 +249,18 @@ export const useWalletStore = defineStore('wallet', {
/* Set address prefix. */
network.prefix = _networkid.toLowerCase()

console.log('PUBLIC KEY', binToHex(this.wallet.publicKey))
/* Set (Script PUSH) public key. */
scriptData = encodeDataPush(this.wallet.publicKey)

publicKeyHash = ripemd160(sha256(scriptData))
// publicKeyHash = hash160(scriptData)
/* Set public key hash. */
publicKeyHash = hash160(scriptData)

/* Set script pubkey. */
scriptPubkey = new Uint8Array([
OP.ZERO,
OP.ONE,
...encodeDataPush(publicKeyHash),
])
console.log('SCRIPT PUBKEY', binToHex(scriptPubkey))

/* Set address. */
network.address = encodeAddress(
Expand Down
Loading

0 comments on commit f8cce25

Please sign in to comment.