Skip to content

Commit

Permalink
Merge pull request #78 from rule110-io/feature/redesign-2
Browse files Browse the repository at this point in the history
Feature/redesign 2
  • Loading branch information
WizardOfCodez authored Jan 23, 2022
2 parents cffefc6 + bce7ac8 commit 63cafd2
Show file tree
Hide file tree
Showing 332 changed files with 31,261 additions and 37,981 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ db
.DS_Store
frontend/package.json.md5
Output
wailsjs
frontend/wailsjs
wailsjs
.env
14 changes: 7 additions & 7 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": "0.3.2-beta",
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Wails: build debug",
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "exec",
"program": "${workspaceFolder}/build/surge",
"preLaunchTask": "wails_debug_build",
"env": {},
"args": []
"mode": "auto",
"program": "${fileDirname}"
}
]
}
10 changes: 0 additions & 10 deletions .vscode/task.json

This file was deleted.

40 changes: 40 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package main

import (
"context"
"fmt"

surge "github.com/rule110-io/surge/backend"
)

// App struct
type App struct {
ctx context.Context
}

// NewApp creates a new App application struct
func NewApp() *App {
return &App{}
}

// startup is called at application startup
func (b *App) startup(ctx context.Context) {
// Perform your setup here
b.ctx = ctx
go surge.WailsBind(&ctx)
}

// domReady is called after the front-end dom has been loaded
func (b *App) domReady(ctx context.Context) {
// Add your action here
}

// shutdown is called at application termination
func (b *App) shutdown(ctx context.Context) {
surge.StopClient()
}

// Greet returns a greeting for the given name
func (b *App) Greet(name string) string {
return fmt.Sprintf("Hello %s, It's show time!", name)
}
Binary file modified appicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added appicon.psd
Binary file not shown.
26 changes: 22 additions & 4 deletions surge/SurgeAccount.go → backend/account.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
// Copyright 2021 rule101. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

/*
This is the surge account management code
It takes care of initializing an account as well as getting specific information about a users account
*/

package surge

import (
"io/ioutil"
"os"
"time"

"log"

nkn "github.com/nknorg/nkn-sdk-go"
"github.com/rule110-io/surge-ui/surge/platform"
"github.com/rule110-io/surge/backend/platform"
)

const accountPath = "account.surge"

// InitializeAccount will either create or fetch existing account
// InitializeAccount will create an account file and return it. If there is already an account in place it will just return the existing account.
func InitializeAccount() *nkn.Account {
var seed []byte

Expand All @@ -25,7 +35,7 @@ func InitializeAccount() *nkn.Account {

// If the file doesn't exist, create it
if os.IsNotExist(err) {
account, err := nkn.NewAccount(nil)
account, _ := nkn.NewAccount(nil)
seed = account.Seed()

f, err := os.OpenFile(accountPathOS, os.O_WRONLY|os.O_CREATE, 0644)
Expand All @@ -45,7 +55,7 @@ func InitializeAccount() *nkn.Account {
}
defer file.Close()

seed, err = ioutil.ReadAll(file)
seed, _ = ioutil.ReadAll(file)
}

account, err := nkn.NewAccount(seed)
Expand All @@ -55,3 +65,11 @@ func InitializeAccount() *nkn.Account {

return account
}

//GetAccountAddress returns current client address
func GetAccountAddress() string {
for !clientInitialized {
time.Sleep(time.Millisecond * 50)
}
return client.Addr().String()
}
33 changes: 33 additions & 0 deletions backend/blockchain.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2021 rule101. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

/*
This file contains all blockchain related functions
*/

package surge

import (
"log"

"github.com/rule110-io/surge/backend/constants"
)

func subscribeToPubSub(topic string) {
txnHash, err := client.Subscribe("", topic, constants.SubscriptionDuration, "Surge Beta Client", nil)
if err != nil {
log.Println("Probably already subscribed", err)
} else {
log.Println("Subscribed: ", txnHash)
}
}

func unsubscribeToPubSub(topic string) {
txnHash, err := client.Unsubscribe("", topic, nil)
if err != nil {
log.Println("Probably already subscribed", err)
} else {
log.Println("Subscribed: ", txnHash)
}
}
Loading

0 comments on commit 63cafd2

Please sign in to comment.