Skip to content

Commit

Permalink
problem: not using mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
gsovereignty committed Nov 1, 2023
1 parent aa83161 commit bb9cafa
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 5 deletions.
90 changes: 90 additions & 0 deletions src/components/modals/DeleteEvent.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<script lang="ts">
import makeEvent from "$lib/helpers/eventMaker";
import { rocketNameValidator, simulateEvents } from "../../settings";
import { currentUser } from "$lib/stores/hot_resources/current-user";
import { Button, Form, Modal, TextInput } from "carbon-components-svelte";
import { Rocket } from "carbon-pictograms-svelte";
import LoginNip07Button from "../elements/LoginNIP07Button.svelte";
let formOpen = false;
let rocketName = "";
let formValidation = true;
let nameError = "";
let nameInvalid = false;
function reset() {
rocketName = "";
nameError = "";
}
function onFormSubmit() {
let e = makeEvent({kind:5})
e.tags.push(["e", rocketName]);
if (!simulateEvents) {
e.publish()
.then((x) => {
console.log(e.rawEvent());
console.log("published to:", x);
formOpen = false;
reset();
})
.catch(() => console.log("failed to publish"));
} else {
console.log("simulation mode, not publishing events");
e.sign().then(() => {
console.log(e.rawEvent());
formOpen = false;
reset();
});
}
}
function onFormOpen() {
// Hack form assocation
const modal = document.querySelector(".bx--modal");
const form = modal.querySelector("form");
const button = modal.querySelector(".bx--btn--primary");
const id = "I" + Math.random().toString().substring(2);
form.setAttribute("id", id);
button.setAttribute("form", id);
// Reverted by binding update on input change
button.setAttribute("type", "submit");
}
</script>

<Button
icon={Rocket}
on:click={() => {
formOpen = true;
}}>Delete an event (kind 5)</Button
>

<Modal
bind:open={formOpen}
shouldSubmitOnEnter={false}
primaryButtonText="Let's Fucking Go"
secondaryButtonText="Cancel"
primaryButtonIcon={Rocket}
selectorPrimaryFocus=".bx--text-input"
modalHeading="Launch a New Rocket!"
hasForm
on:open={onFormOpen}
on:click:button--secondary={() => (formOpen = false)}
on:submit={() => (formValidation ? onFormSubmit() : null)}
>
<Form on:submit={onFormSubmit}>
{#if !$currentUser}
<LoginNip07Button />
{/if}
<TextInput
helperText="Use a name that describes the purpose of this new Rocket"
invalid={nameInvalid}
invalidText={nameError}
labelText="Rocket Name"
bind:value={rocketName}
required
/>
</Form>
</Modal>
3 changes: 2 additions & 1 deletion src/components/problems/AddProblemModal.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import makeEvent from "$lib/helpers/eventMaker";
import {
ignitionPubkey,
nostrocketIgnitionEvent,
nostrocketIgnitionTag,
simulateEvents
Expand Down Expand Up @@ -60,7 +61,7 @@
function onFormSubmit() {
if (!buttonDisabled) {
if (parent.length != 64) {
if (parent.length != 64 && $currentUser?.pubkey !== ignitionPubkey) {
console.log("todo: add safeguards and user notifications for logging problems at the root level")
throw new Error("comment out to log a problem at the root level")
}
Expand Down
3 changes: 1 addition & 2 deletions src/components/views/Landing.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<Row>
<Column>
<Tile>

<Row>
<Column>
<Tile light>
Expand Down Expand Up @@ -47,7 +46,7 @@
<Column>
<Tile light>
<h1 class="bolditalic center">LFG!</h1>
<h4 class="center">The <a href="#">Nostrocket Ignition Event</a> was published on the 31st of October, 2023.</h4>
<h4 class="center">The <a href="{base}/eventviewer/1bf16cac62588cfd7e3c336b8548fa49a09627f03dbf06c7a4fee27bc01972c8">Nostrocket Ignition Event</a> has been broadcast.</h4>
<br />
<h4 class="center">The current state is now considered <span class="italic">mainnet</span>.</h4>
<br />
Expand Down
2 changes: 2 additions & 0 deletions src/routes/consensustip/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
Row,
Tile
} from "carbon-components-svelte";
import DeleteEvent from "../../components/modals/DeleteEvent.svelte";
</script>
<Row>
<Tile style="margin-bottom:1%;">
<Button on:click={()=>{console.log($consensusTipState)}}>Print consensusTipState to console</Button>
</Tile>
</Row>
<Row><DeleteEvent /></Row>

4 changes: 2 additions & 2 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export var nostrocketIgnitionEvent =

export const simulateEvents = false; //will not publish events if set to True.

export const testnet = true;
export const testnet = false;

const testnetRoot =
"b43986227b5e84aee127501749886e34b15f232fc381c5048023a1047086b121";
Expand Down Expand Up @@ -56,4 +56,4 @@ export const defaultRelays = [
// "wss://eden.nostr.land",
// "wss://nos.lol"
// 'ws://localhost:8080',
];
];

0 comments on commit bb9cafa

Please sign in to comment.