Skip to content

Commit

Permalink
Revert "Feature/transfer token"
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstage authored Oct 23, 2024
1 parent 81fca0c commit e8f4ce2
Show file tree
Hide file tree
Showing 25 changed files with 4,694 additions and 94,099 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
node_modules
build
.vscode

Binary file added build/favicon.ico
Binary file not shown.
5 changes: 5 additions & 0 deletions build/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("./localServer/index");
const port = parseInt(process.argv[2]) || 3001;
new index_1.Daemon(port, '');
68 changes: 68 additions & 0 deletions build/localServer/encrypt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"use strict";
const workerReadyChannel = 'conet-platform';
const workerProcessChannel = 'workerLoader';
const channelWrokerListenName = 'toMainWroker';
const responseChannel = new BroadcastChannel('toServiceWroker');
const channel = new BroadcastChannel(channelWrokerListenName);
const backGroundPoolWorker = [];
self.onhashchange = () => {
channel.removeEventListener('message', channelWorkerDoCommand);
};
const initEncryptWorker = async () => {
const baseUrl = self.name + 'workers/';
const channelLoading = new BroadcastChannel(workerProcessChannel);
self.importScripts(baseUrl + 'Buffer.js');
channelLoading.postMessage(10);
self.importScripts('https://cdnjs.cloudflare.com/ajax/libs/uuid/8.3.2/uuid.min.js');
self.importScripts('https://cdnjs.cloudflare.com/ajax/libs/pouchdb/9.0.0/pouchdb.min.js');
self.importScripts('https://cdnjs.cloudflare.com/ajax/libs/async/3.2.5/async.min.js');
self.importScripts('https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js');
self.importScripts('https://cdnjs.cloudflare.com/ajax/libs/jimp/0.22.12/jimp.min.js');
channelLoading.postMessage(30);
self.importScripts(baseUrl + 'util.js');
// self.importScripts ( 'https://cdnjs.cloudflare.com/ajax/libs/forge/1.3.1/forge.min.js' )
//self.importScripts ( baseUrl + 'Pouchdb.js' )
// self.importScripts ( baseUrl + 'PouchdbFind.js' )
self.importScripts(baseUrl + 'main.js');
self.importScripts('https://cdnjs.cloudflare.com/ajax/libs/ethers/6.13.1/ethers.umd.min.js');
channelLoading.postMessage(90);
channel.addEventListener('message', channelWorkerDoCommand);
await checkStorage();
};
const returnUUIDChannel = (cmd) => {
if (!cmd.uuid) {
return logger(`getPrimaryBalance cmd uuid is null`, cmd);
}
const sendChannel = new BroadcastChannel(cmd.uuid);
sendChannel.postMessage(JSON.stringify(cmd));
sendChannel.close();
};
const channelWorkerDoCommand = (async (e) => {
const jsonData = buffer.Buffer.from(e.data).toString();
let cmd;
try {
cmd = JSON.parse(jsonData);
}
catch (ex) {
return console.dir(ex);
}
processCmd(cmd);
});
let getFaucetCount = 0;
const processCmd = async (cmd) => {
switch (cmd.cmd) {
case 'getWallet': {
return getWallet(cmd);
}
default: {
cmd.err = 'INVALID_COMMAND';
responseChannel.postMessage(JSON.stringify(cmd));
console.log(`channelWorkerDoCommand unknow command!`, cmd);
return returnUUIDChannel(cmd);
}
}
};
/**
*
*/
initEncryptWorker();
95 changes: 95 additions & 0 deletions build/localServer/encrypt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@


/**
* CONET Platform
*
*/
declare const ethers

const workerReadyChannel = 'conet-platform'
const workerProcessChannel = 'workerLoader'
const channelWrokerListenName = 'toMainWroker'
const responseChannel = new BroadcastChannel('toServiceWroker')
const channel = new BroadcastChannel(channelWrokerListenName)

const backGroundPoolWorker: clientPoolWroker[] = []

self.onhashchange = () => {
channel.removeEventListener('message', channelWorkerDoCommand)
}

const initEncryptWorker = async () => {

const baseUrl = self.name + 'workers/'
const channelLoading = new BroadcastChannel(workerProcessChannel)
self.importScripts ( baseUrl + 'Buffer.js' )
channelLoading.postMessage(10)

self.importScripts ( 'https://cdnjs.cloudflare.com/ajax/libs/uuid/8.3.2/uuid.min.js' )
self.importScripts ( 'https://cdnjs.cloudflare.com/ajax/libs/pouchdb/9.0.0/pouchdb.min.js' )
self.importScripts ( 'https://cdnjs.cloudflare.com/ajax/libs/async/3.2.5/async.min.js' )
self.importScripts ( 'https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js' )
self.importScripts ( 'https://cdnjs.cloudflare.com/ajax/libs/jimp/0.22.12/jimp.min.js')
channelLoading.postMessage(30)
self.importScripts ( baseUrl + 'util.js' )
// self.importScripts ( 'https://cdnjs.cloudflare.com/ajax/libs/forge/1.3.1/forge.min.js' )
//self.importScripts ( baseUrl + 'Pouchdb.js' )
// self.importScripts ( baseUrl + 'PouchdbFind.js' )
self.importScripts ( baseUrl + 'main.js' )

self.importScripts ( 'https://cdnjs.cloudflare.com/ajax/libs/ethers/6.13.1/ethers.umd.min.js' )

channelLoading.postMessage(90)
channel.addEventListener('message', channelWorkerDoCommand )
await checkStorage()
}


const returnUUIDChannel = (cmd: worker_command) => {
if (!cmd.uuid) {
return logger(`getPrimaryBalance cmd uuid is null`, cmd)
}
const sendChannel = new BroadcastChannel(cmd.uuid)
sendChannel.postMessage (JSON.stringify(cmd))
sendChannel.close()
}


const channelWorkerDoCommand = (async e => {
const jsonData = buffer.Buffer.from ( e.data ).toString()
let cmd: worker_command
try {
cmd = JSON.parse ( jsonData )
} catch ( ex ) {
return console.dir ( ex )
}

processCmd(cmd)

})


let getFaucetCount = 0

const processCmd = async (cmd: worker_command) => {
switch (cmd.cmd) {
case 'getWallet': {
return getWallet(cmd)
}

default: {
cmd.err = 'INVALID_COMMAND'
responseChannel.postMessage(JSON.stringify(cmd))
console.log (`channelWorkerDoCommand unknow command!`, cmd)
return returnUUIDChannel(cmd)
}
}
}

/**
*
*/


initEncryptWorker()

Loading

0 comments on commit e8f4ce2

Please sign in to comment.