diff --git a/builing_dir/crumbs.py b/builing_dir/crumbs.py
new file mode 100644
index 0000000..c6fed15
--- /dev/null
+++ b/builing_dir/crumbs.py
@@ -0,0 +1,157 @@
+from PIL import Image, ImageTk
+import easygui
+import commands
+import subprocess as p
+import platform
+import os
+import re
+import sys
+import atexit
+from time import sleep
+import signal
+import Tkinter as tk
+
+dir_path = os.path.dirname(os.path.realpath(__file__))
+print(dir_path)
+cwd = os.getcwd()
+print(cwd)
+os.chdir(dir_path)
+cwd = os.getcwd()
+print(cwd)
+
+IMAGE_PATH = "LoadingPageDesign.ppm"
+
+class Splash(object):
+ "Splash Screen GUI"
+ def __init__(self, root):
+ self.root = root
+ self.root.overrideredirect(True)
+ w = self.root.winfo_screenwidth()
+ h = self.root.winfo_screenheight()
+ # Full screen
+ # Display an image
+ self.label = tk.Label(self.root)
+ self.label._image = tk.PhotoImage(file=IMAGE_PATH)
+ self.label.configure(image = self.label._image)
+ self.label.pack()
+ self.root.after(10000, self.root.quit)
+
+def center(win):
+ win.update_idletasks()
+ width = win.winfo_width()
+ frm_width = win.winfo_rootx() - win.winfo_x()
+ win_width = width + 2 * frm_width
+ height = win.winfo_height()
+ titlebar_height = win.winfo_rooty() - win.winfo_y()
+ win_height = height + titlebar_height + frm_width
+ x = win.winfo_screenwidth() // 2 - win_width // 2
+ y = win.winfo_screenheight() // 2 - win_height // 2
+ win.geometry('{}x{}+{}+{}'.format(width, height, x, y))
+ win.deiconify()
+
+def inplace_change(filename, old_regex, new_string):
+ # Safely read the input filename using 'with'
+ with open(filename) as f:
+ s = f.read()
+
+ # Safely write the changed content, if found in the file
+ with open(filename, 'w') as f:
+ s = re.sub(old_regex, new_string, s)
+ f.write(s)
+
+try:
+ predictorPid = int(p.check_output(['pidof','-s','nn_crumbs']))
+ os.kill(predictorPid, signal.SIGTERM)
+except:
+ a=0
+
+configPath = os.path.join('config', 'ethereumj.conf')
+
+hostSystem = platform.system()
+
+#retrieve private ips
+ip = "127.0.0.1"
+peer = "127.0.0.1"
+addresses = []
+if hostSystem == 'Linux':
+ ips = p.check_output(['hostname', '-I'])
+ addresses = ips.split()
+elif hostSystem == 'Darwin':
+ for NUMBER in [0,5]:
+ addr = commands.getoutput('ipconfig getifaddr en' + str(NUMBER))
+ if len(addr) > 1:
+ addresses.append(addr)
+elif hostSystem == 'Windows':
+ ips = commands.getoutput("ipconfig | where {$_ -match 'IPv4.+\s(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' } | out-null; $Matches[1]")
+ addresses = ips.split()
+
+#selection of bind ip
+for address in addresses:
+ print(address)
+if len(addresses) == 0:
+ ip = easygui.enterbox(msg='Unable to detect your IP address,\nplease enter the desired IP address to use.\n\nIf remained at 127.0.0.1,\nthe application will not communicate across computers.', title='No IP detected', default='127.0.0.1', strip=True)
+ if not re.match(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$', ip):
+ easygui.msgbox('Invalid IP address entered. IPv4 addresses are in the format xxx.xxx.xxx.xxx')
+ sys.exit(0)
+elif len(addresses) != 1:
+ ip = easygui.choicebox(msg='Multiple IP addresses detected, please select IP address to be used', title='Select your IP', choices=addresses)
+else:
+ ip = addresses[0]
+
+#enter ip of peers
+if ip != '127.0.0.1':
+ peerIp = easygui.enterbox(msg='Your IP address is : ' + ip + '\n\nEnter IP used by the other computer (optional)', title='IP Resolution', strip=True)
+ if peerIp:
+ print(peerIp)
+ if not re.match(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$', peer):
+ easygui.msgbox('Invalid IP address entered. IPv4 addresses are in the format xxx.xxx.xxx.xxx')
+ sys.exit(0)
+ else:
+ peer = peerIp
+inplace_change(configPath, r'ip_addr = \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', 'ip_addr = ' + ip)
+inplace_change(configPath, r'peer_ip = \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', 'peer_ip = ' + peer)
+
+#run services
+backendLog = open('backend.log','w+')
+
+backend = p.Popen(['java','-jar','ethereum-1.0.jar'], stdout=backendLog)
+
+if hostSystem == 'Linux':
+ predictor = p.Popen(['components-linux/predictor/nn_crumbs'])
+if hostSystem == 'Darwin':
+ predictor = p.Popen(['components-darwin/predictor/nn_crumbs.app/Contents/MacOS/nn_crumbs'])
+
+
+print('backend pid: ' + str(backend.pid))
+print('predictor pid: ' + str(predictor.pid))
+
+#show splash screen
+root = tk.Tk()
+appl = Splash(root)
+center(root)
+root.mainloop()
+
+sleep(9)
+
+root.destroy()
+
+if hostSystem == 'Linux':
+ frontend = p.Popen(['components-linux/frontend/crumbs'])
+elif hostSystem == 'Darwin':
+ frontend = p.Popen(['components-darwin/frontend/crumbs.app/Contents/MacOS/crumbs'])
+
+print('frontend pid: ' + str(frontend.pid))
+
+def exitHandler():
+ backend.kill()
+ predictor.kill()
+# p.call(['kill',int(p.check_output(['pidof','-s','nn_crumbs']))])
+ print(int(p.check_output(['pidof','-s','nn_crumbs'])))
+ predictorPid = int(p.check_output(['pidof','-s','nn_crumbs']))
+ os.kill(predictorPid, signal.SIGTERM)
+ print('exiting app')
+
+atexit.register(exitHandler)
+
+frontend.wait()
+sys.exit(0)
diff --git a/builing_dir/crumbs.spec b/builing_dir/crumbs.spec
new file mode 100644
index 0000000..e237a13
--- /dev/null
+++ b/builing_dir/crumbs.spec
@@ -0,0 +1,28 @@
+# -*- mode: python -*-
+
+block_cipher = None
+
+
+a = Analysis(['crumbs.py'],
+ pathex=['/home/low/crumbs/builing_dir'],
+ binaries=[],
+ datas=[],
+ hiddenimports=[],
+ hookspath=[],
+ runtime_hooks=[],
+ excludes=[],
+ win_no_prefer_redirects=False,
+ win_private_assemblies=False,
+ cipher=block_cipher)
+pyz = PYZ(a.pure, a.zipped_data,
+ cipher=block_cipher)
+exe = EXE(pyz,
+ a.scripts,
+ a.binaries,
+ a.zipfiles,
+ a.datas,
+ name='crumbs',
+ debug=False,
+ strip=False,
+ upx=True,
+ console=True )
diff --git a/builing_dir/hooks/hook-keras.pyc b/builing_dir/hooks/hook-keras.pyc
new file mode 100644
index 0000000..c1793e1
Binary files /dev/null and b/builing_dir/hooks/hook-keras.pyc differ
diff --git a/dist/components-darwin/predictor/nn_crumbs.app/Contents/Info.plist b/dist/components-darwin/predictor/nn_crumbs.app/Contents/Info.plist
new file mode 100644
index 0000000..d234022
--- /dev/null
+++ b/dist/components-darwin/predictor/nn_crumbs.app/Contents/Info.plist
@@ -0,0 +1,90 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ English
+ CFBundleDisplayName
+ nn_crumbs
+ CFBundleExecutable
+ nn_crumbs
+ CFBundleIconFile
+ nn_crumbs
+ CFBundleIdentifier
+ org.pythonmac.unspecified.nn_crumbs
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ nn_crumbs
+ CFBundlePackageType
+ APPL
+ CFBundleShortVersionString
+ 0.0.0
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ 0.0.0
+ LSHasLocalizedDisplayName
+
+ NSAppleScriptEnabled
+
+ NSHumanReadableCopyright
+ Copyright not specified
+ NSMainNibFile
+ MainMenu
+ NSPrincipalClass
+ NSApplication
+ PyMainFileNames
+
+ __boot__
+
+ PyOptions
+
+ alias
+
+ argv_emulation
+
+ emulate_shell_environment
+
+ no_chdir
+
+ prefer_ppc
+
+ site_packages
+
+ use_faulthandler
+
+ use_pythonpath
+
+ verbose
+
+
+ PyResourcePackages
+
+
+ PyRuntimeLocations
+
+ @executable_path/../Frameworks/libpython2.7.dylib
+ //anaconda/lib/libpython2.7.dylib
+
+ PythonInfoDict
+
+ PythonExecutable
+ //anaconda/bin/python
+ PythonLongVersion
+ 2.7.12 |Anaconda 4.2.0 (x86_64)| (default, Jul 2 2016, 17:43:17)
+[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)]
+ PythonShortVersion
+ 2.7
+ py2app
+
+ alias
+
+ template
+ app
+ version
+ 0.12
+
+
+
+
diff --git a/dist/components-darwin/predictor/nn_crumbs.app/Contents/MacOS/nn_crumbs b/dist/components-darwin/predictor/nn_crumbs.app/Contents/MacOS/nn_crumbs
new file mode 100644
index 0000000..32c4faf
Binary files /dev/null and b/dist/components-darwin/predictor/nn_crumbs.app/Contents/MacOS/nn_crumbs differ
diff --git a/dist/components-darwin/predictor/nn_crumbs.app/Contents/MacOS/python b/dist/components-darwin/predictor/nn_crumbs.app/Contents/MacOS/python
new file mode 100644
index 0000000..490540c
--- /dev/null
+++ b/dist/components-darwin/predictor/nn_crumbs.app/Contents/MacOS/python
@@ -0,0 +1,5 @@
+XSym
+0021
+c4a505b8f3aff1beee230ccfa9c4fc3f
+//anaconda/bin/python
+
\ No newline at end of file
diff --git a/dist/components-darwin/predictor/nn_crumbs.app/Contents/PkgInfo b/dist/components-darwin/predictor/nn_crumbs.app/Contents/PkgInfo
new file mode 100644
index 0000000..bd04210
--- /dev/null
+++ b/dist/components-darwin/predictor/nn_crumbs.app/Contents/PkgInfo
@@ -0,0 +1 @@
+APPL????
\ No newline at end of file
diff --git a/dist/components-darwin/predictor/nn_crumbs.app/Contents/Resources/__boot__.py b/dist/components-darwin/predictor/nn_crumbs.app/Contents/Resources/__boot__.py
new file mode 100644
index 0000000..8f9a903
--- /dev/null
+++ b/dist/components-darwin/predictor/nn_crumbs.app/Contents/Resources/__boot__.py
@@ -0,0 +1,109 @@
+def _reset_sys_path():
+ # Clear generic sys.path[0]
+ import sys, os
+ resources = os.environ['RESOURCEPATH']
+ while sys.path[0] == resources:
+ del sys.path[0]
+_reset_sys_path()
+
+
+def _site_packages():
+ import site, sys, os
+ paths = []
+ prefixes = [sys.prefix]
+ if sys.exec_prefix != sys.prefix:
+ prefixes.append(sys.exec_prefix)
+ for prefix in prefixes:
+ paths.append(os.path.join(prefix, 'lib', 'python' + sys.version[:3],
+ 'site-packages'))
+ if os.path.join('.framework', '') in os.path.join(sys.prefix, ''):
+ home = os.environ.get('HOME')
+ if home:
+ paths.append(os.path.join(home, 'Library', 'Python',
+ sys.version[:3], 'site-packages'))
+
+ # Work around for a misfeature in setuptools: easy_install.pth places
+ # site-packages way to early on sys.path and that breaks py2app bundles.
+ # NOTE: this is hacks into an undocumented feature of setuptools and
+ # might stop to work without warning.
+ sys.__egginsert = len(sys.path)
+
+ for path in paths:
+ site.addsitedir(path)
+_site_packages()
+
+
+def _chdir_resource():
+ import os
+ os.chdir(os.environ['RESOURCEPATH'])
+_chdir_resource()
+
+
+def _setup_ctypes():
+ from ctypes.macholib import dyld
+ import os
+ frameworks = os.path.join(os.environ['RESOURCEPATH'], '..', 'Frameworks')
+ dyld.DEFAULT_FRAMEWORK_FALLBACK.insert(0, frameworks)
+ dyld.DEFAULT_LIBRARY_FALLBACK.insert(0, frameworks)
+
+_setup_ctypes()
+
+
+def _path_inject(paths):
+ import sys
+ sys.path[:0] = paths
+
+
+_path_inject(['/Users/signapoop/Desktop/Crumbs/crumbs/builing_dir'])
+
+
+import re, sys
+cookie_re = re.compile(b"coding[:=]\s*([-\w.]+)")
+if sys.version_info[0] == 2:
+ default_encoding = 'ascii'
+else:
+ default_encoding = 'utf-8'
+
+def guess_encoding(fp):
+ for i in range(2):
+ ln = fp.readline()
+
+ m = cookie_re.search(ln)
+ if m is not None:
+ return m.group(1).decode('ascii')
+
+ return default_encoding
+
+def _run():
+ global __file__
+ import os, site
+ sys.frozen = 'macosx_app'
+
+ argv0 = os.path.basename(os.environ['ARGVZERO'])
+ script = SCRIPT_MAP.get(argv0, DEFAULT_SCRIPT)
+
+ sys.argv[0] = __file__ = script
+ if sys.version_info[0] == 2:
+ with open(script, 'rU') as fp:
+ source = fp.read() + "\n"
+ else:
+ with open(script, 'rb') as fp:
+ encoding = guess_encoding(fp)
+
+ with open(script, 'r', encoding=encoding) as fp:
+ source = fp.read() + '\n'
+
+ BOM=b'\xef\xbb\xbf'.decode('utf-8')
+ if source.startswith(BOM):
+ source = source[1:]
+
+
+ exec(compile(source, script, 'exec'), globals(), globals())
+
+
+DEFAULT_SCRIPT='/Users/signapoop/Desktop/Crumbs/crumbs/builing_dir/nn_crumbs.py'
+SCRIPT_MAP={}
+try:
+ _run()
+except KeyboardInterrupt:
+ pass
diff --git a/dist/components-darwin/predictor/nn_crumbs.app/Contents/Resources/__error__.sh b/dist/components-darwin/predictor/nn_crumbs.app/Contents/Resources/__error__.sh
new file mode 100644
index 0000000..f1122a6
--- /dev/null
+++ b/dist/components-darwin/predictor/nn_crumbs.app/Contents/Resources/__error__.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# This is the default apptemplate error script
+#
+if ( test -n "$2" ) ; then
+ echo "$1 Error"
+ echo "An unexpected error has occurred during execution of the main script"
+ echo ""
+ echo "$2: $3"
+ echo ""
+ echo "See the Console for a detailed traceback."
+else
+ echo "$1 Error"
+
+ # Usage: ERRORURL , this is used by the
+ # bundle runner to put up a dialog.
+ #echo "ERRORURL: http://www.python.org/ Visit the Python Website
+# echo "ERRORURL: http://homepages.cwi.nl/~jack/macpython/index.html Visit the MacPython Website"
+fi
diff --git a/dist/components-darwin/predictor/nn_crumbs.app/Contents/Resources/lib/python2.7/config b/dist/components-darwin/predictor/nn_crumbs.app/Contents/Resources/lib/python2.7/config
new file mode 100644
index 0000000..522e575
--- /dev/null
+++ b/dist/components-darwin/predictor/nn_crumbs.app/Contents/Resources/lib/python2.7/config
@@ -0,0 +1,5 @@
+XSym
+0031
+c7e7957faad5d299faddcca8c750325c
+//anaconda/lib/python2.7/config
+
\ No newline at end of file
diff --git a/dist/components-darwin/predictor/nn_crumbs.app/Contents/Resources/lib/python2.7/site.pyc b/dist/components-darwin/predictor/nn_crumbs.app/Contents/Resources/lib/python2.7/site.pyc
new file mode 100644
index 0000000..60b943d
--- /dev/null
+++ b/dist/components-darwin/predictor/nn_crumbs.app/Contents/Resources/lib/python2.7/site.pyc
@@ -0,0 +1,5 @@
+XSym
+0014
+3435dad934478b41333e8fbd3f4594ef
+../../site.pyc
+
\ No newline at end of file
diff --git a/dist/components-darwin/predictor/nn_crumbs.app/Contents/Resources/site.py b/dist/components-darwin/predictor/nn_crumbs.app/Contents/Resources/site.py
new file mode 100644
index 0000000..354e729
--- /dev/null
+++ b/dist/components-darwin/predictor/nn_crumbs.app/Contents/Resources/site.py
@@ -0,0 +1,132 @@
+"""
+Append module search paths for third-party packages to sys.path.
+
+This is stripped down and customized for use in py2app applications
+"""
+
+import sys
+# os is actually in the zip, so we need to do this here.
+# we can't call it python24.zip because zlib is not a built-in module (!)
+_libdir = '/lib/python' + sys.version[:3]
+_parent = '/'.join(__file__.split('/')[:-1])
+if not _parent.endswith(_libdir):
+ _parent += _libdir
+sys.path.append(_parent + '/site-packages.zip')
+
+# Stuffit decompresses recursively by default, that can mess up py2app bundles,
+# add the uncompressed site-packages to the path to compensate for that.
+sys.path.append(_parent + '/site-packages')
+
+USER_SITE=None
+
+import os
+try:
+ basestring
+except NameError:
+ basestring = str
+
+def makepath(*paths):
+ dir = os.path.abspath(os.path.join(*paths))
+ return dir, os.path.normcase(dir)
+
+for m in sys.modules.values():
+ f = getattr(m, '__file__', None)
+ if isinstance(f, basestring) and os.path.exists(f):
+ m.__file__ = os.path.abspath(m.__file__)
+del m
+
+# This ensures that the initial path provided by the interpreter contains
+# only absolute pathnames, even if we're running from the build directory.
+L = []
+_dirs_in_sys_path = {}
+dir = dircase = None # sys.path may be empty at this point
+for dir in sys.path:
+ # Filter out duplicate paths (on case-insensitive file systems also
+ # if they only differ in case); turn relative paths into absolute
+ # paths.
+ dir, dircase = makepath(dir)
+ if not dircase in _dirs_in_sys_path:
+ L.append(dir)
+ _dirs_in_sys_path[dircase] = 1
+sys.path[:] = L
+del dir, dircase, L
+_dirs_in_sys_path = None
+
+def _init_pathinfo():
+ global _dirs_in_sys_path
+ _dirs_in_sys_path = d = {}
+ for dir in sys.path:
+ if dir and not os.path.isdir(dir):
+ continue
+ dir, dircase = makepath(dir)
+ d[dircase] = 1
+
+def addsitedir(sitedir):
+ global _dirs_in_sys_path
+ if _dirs_in_sys_path is None:
+ _init_pathinfo()
+ reset = 1
+ else:
+ reset = 0
+ sitedir, sitedircase = makepath(sitedir)
+ if not sitedircase in _dirs_in_sys_path:
+ sys.path.append(sitedir) # Add path component
+ try:
+ names = os.listdir(sitedir)
+ except os.error:
+ return
+ names.sort()
+ for name in names:
+ if name[-4:] == os.extsep + "pth":
+ addpackage(sitedir, name)
+ if reset:
+ _dirs_in_sys_path = None
+
+def addpackage(sitedir, name):
+ global _dirs_in_sys_path
+ if _dirs_in_sys_path is None:
+ _init_pathinfo()
+ reset = 1
+ else:
+ reset = 0
+ fullname = os.path.join(sitedir, name)
+ try:
+ with open(fullname) as f:
+ while 1:
+ dir = f.readline()
+ if not dir:
+ break
+ if dir[0] == '#':
+ continue
+ if dir.startswith("import"):
+ exec(dir)
+ continue
+ if dir[-1] == '\n':
+ dir = dir[:-1]
+ dir, dircase = makepath(sitedir, dir)
+ if not dircase in _dirs_in_sys_path and os.path.exists(dir):
+ sys.path.append(dir)
+ _dirs_in_sys_path[dircase] = 1
+ except IOError:
+ return
+ if reset:
+ _dirs_in_sys_path = None
+
+
+#sys.setdefaultencoding('utf-8')
+
+#
+# Run custom site specific code, if available.
+#
+try:
+ import sitecustomize
+except ImportError:
+ pass
+
+#
+# Remove sys.setdefaultencoding() so that users cannot change the
+# encoding after initialization. The test for presence is needed when
+# this module is run as a script, because this code is executed twice.
+#
+if hasattr(sys, "setdefaultencoding"):
+ del sys.setdefaultencoding
diff --git a/dist/components-darwin/predictor/nn_crumbs.app/Contents/Resources/site.pyc b/dist/components-darwin/predictor/nn_crumbs.app/Contents/Resources/site.pyc
new file mode 100644
index 0000000..4a48f84
Binary files /dev/null and b/dist/components-darwin/predictor/nn_crumbs.app/Contents/Resources/site.pyc differ
diff --git a/dist/crumbs.command b/dist/crumbs.command
new file mode 100755
index 0000000..9bbca0a
--- /dev/null
+++ b/dist/crumbs.command
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+
+cd -P -- "$(dirname -- "$0")" && pwd -P
+#echo $dir
+
+if [ "$(uname)" == "Darwin" ]; then
+ ./crumbs-darwin
+elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
+ ./crumbs-linux
+fi
diff --git a/dist/ethereum-1.0.jar b/dist/ethereum-1.0.jar
index 8a7f464..66cce5f 100644
Binary files a/dist/ethereum-1.0.jar and b/dist/ethereum-1.0.jar differ
diff --git a/ethereum/src/main/java/com/crumbs/rest/MockDataCtrl.java b/ethereum/src/main/java/com/crumbs/rest/MockDataCtrl.java
index 1af466a..9a8ae48 100644
--- a/ethereum/src/main/java/com/crumbs/rest/MockDataCtrl.java
+++ b/ethereum/src/main/java/com/crumbs/rest/MockDataCtrl.java
@@ -12,8 +12,6 @@
import com.crumbs.services.ContractService;
import com.crumbs.services.InventoryService;
import com.crumbs.services.TransactionService;
-import com.crumbs.services.WebSocketSrvc;
-import com.crumbs.util.CrumbsUtil;
import com.crumbs.util.DateUtil;
import com.crumbs.util.TxCancelledException;
import org.ethereum.crypto.ECKey;
@@ -48,9 +46,6 @@ public class MockDataCtrl {
@Autowired
private ContractService contractService;
- @Autowired
- private WebSocketSrvc webSocketSrvc;
-
@Autowired
private InventoryService inventoryService;
@@ -170,36 +165,6 @@ public void receive(@RequestBody Product p) {
inventoryService.storeProduct(p);
}
- @RequestMapping(value = "/sample-contract", method = GET)
- @ResponseBody
- public void sendSampleContract() throws IOException {
- contractService.testContract();
- }
-
- @RequestMapping(value = "/modify-sample-contract", method = GET)
- @ResponseBody
- public void modifySampleContract() throws IOException, TxCancelledException {
- contractService.modifyMortalGreeting();
- }
-
- @RequestMapping(value = "/test-sample-contract", method = GET)
- @ResponseBody
- public void testSampleContract() throws IOException {
- contractService.callMortalGreet();
- }
-
- @RequestMapping(value = "/bestBlock", method = GET, produces = APPLICATION_JSON_VALUE)
- @ResponseBody
- public String getBestBlock() throws IOException {
- return ethereumBean.getBestBlock();
- }
-
- @RequestMapping(value = "/adminInfo", method = GET, produces = APPLICATION_JSON_VALUE)
- @ResponseBody
- public String getAdminInfo() throws IOException {
- return ethereumBean.getAdminInfo();
- }
-
@RequestMapping(value = "/sendMockTx", method = POST, produces = APPLICATION_JSON_VALUE)
@ResponseBody
public void sendMockTx(@RequestParam ("sender") String sender, @RequestParam("receiver") String receiver) throws IOException {
diff --git a/ethereum/src/main/java/com/crumbs/services/ContractService.java b/ethereum/src/main/java/com/crumbs/services/ContractService.java
index 3265942..b002b6c 100644
--- a/ethereum/src/main/java/com/crumbs/services/ContractService.java
+++ b/ethereum/src/main/java/com/crumbs/services/ContractService.java
@@ -204,88 +204,4 @@ public void topUpContract() throws TxCancelledException {
sendToTxContract("topup", 100);
}
- /******************************************************************************/
- /*************** OBSOLETE FUNCTIONS NO LONGER USED ****************************/
- /******************************************************************************/
-
- //EthereumJ compiler seems to be faulty after contract reached a certain complexity
- public void compileAndSend(String contract, String name) throws IOException {
- logger.info("Compiling contract...");
- SolidityCompiler.Result result = compiler.compileSrc(contract.getBytes(), true, true,
- SolidityCompiler.Options.ABI, SolidityCompiler.Options.BIN);
- if (result.isFailed()) {
- throw new RuntimeException("Contract compilation failed:\n" + result.errors);
- }
- CompilationResult res = CompilationResult.parse(result.output);
- if (res.contracts.isEmpty()) {
- throw new RuntimeException("Compilation failed, no contracts returned:\n" + result.errors);
- }
- CompilationResult.ContractMetadata metadata = res.contracts.values().iterator().next();
- if (metadata.bin == null || metadata.bin.isEmpty()) {
- throw new RuntimeException("Compilation failed, no binary returned:\n" + result.errors);
- }
- logger.info("Compiled metadata: " + JSON.toJSONString(metadata, true));
-
- SendingTxListener listener = new SendingTxListener() {
- @Override
- public void isDone(Transaction tx) {
- CrumbsContract crumbsContract = new CrumbsContract();
- crumbsContract.setContractName(name);
- crumbsContract.setAbi(metadata.abi);
- crumbsContract.setBin(metadata.bin);
- crumbsContract.setSolc(metadata.solInterface);
- crumbsContract.setMetadata(metadata.metadata);
- crumbsContract.setContractAddr(tx.getContractAddress());
- crumbsContract.setIncluded(false);
- logger.info("CONTRACT ADDRESS ON CREATION: " + ByteUtil.toHexString(tx.getContractAddress()));
- //crumbsContractRepo.delete("mortal_contract");
- crumbsContractRepo.save(crumbsContract);
- }
-
- @Override
- public void isCancelled() {
- logger.warn("transaction cancelled");
- //TODO notify of failed tx
- }
- };
- ethereumBean.sendTransaction(Hex.decode(metadata.bin), listener);
- }
-
- private final String SAMPLE_CONTRACT = "contract mortal { address owner; function mortal() { owner = msg.sender; } function kill() { if (msg.sender == owner) selfdestruct(owner); } } contract greeter is mortal {string greeting = \"default\"; function changeGreeter(string _greeting) public { greeting = _greeting; } function greet() constant returns (string) { return greeting; } }";
-
- public void testContract() throws IOException{
- compileAndSend(SAMPLE_CONTRACT, "mortal_tx");
- }
-
- public void modifyMortalGreeting() throws TxCancelledException {
-
- CrumbsContract testContract = crumbsContractRepo.findOne("mortal_tx");
- logger.info("loaded contract : " + JSON.toJSONString(testContract, true) );
- /*if (!testContract.isIncluded()) {
- logger.warn("Contract not yet included to chain");
- return;
- }*/
- logger.info("Calling the contract constructor");
- CallTransaction.Contract contract = new CallTransaction.Contract(testContract.getAbi());
- byte[] functionCallBytes = contract.getByName("changeGreeter").encode("HI THERE!");
- ethereumBean.sendTransaction(testContract.getContractAddr(), functionCallBytes);
- logger.info("Contract modified!");
-
- }
-
- public void callMortalGreet() {
- CrumbsContract testContract = crumbsContractRepo.findOne("mortal_tx");
- logger.info("loaded contract : " + JSON.toJSONString(testContract, true) );
- logger.info("Contract address: " + ByteUtil.toHexString(testContract.getContractAddr()));
- /*if (!testContract.isIncluded()) {
- logger.warn("Contract not yet included to chain");
- return;
- }*/
- CallTransaction.Contract contract = new CallTransaction.Contract(testContract.getAbi());
- ProgramResult r = ethereumBean.callConstantFunction(Hex.toHexString(testContract.getContractAddr()), accountBean.getKey(),
- contract.getByName("greet"));
- Object[] ret = contract.getByName("greet").decodeResult(r.getHReturn());
- logger.info("result: " + JSON.toJSONString(ret));
- logger.info("Current contract data member value: " + ret[0]);
- }
}
diff --git a/ethereum/src/main/java/com/crumbs/services/WebSocketSrvc.java b/ethereum/src/main/java/com/crumbs/services/WebSocketSrvc.java
deleted file mode 100644
index 7d38c91..0000000
--- a/ethereum/src/main/java/com/crumbs/services/WebSocketSrvc.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.crumbs.services;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.messaging.simp.SimpMessagingTemplate;
-import org.springframework.stereotype.Service;
-
-/**
- * Created by low on 18/2/17 6:08 PM.
- * @deprecated web socket not working with electron
- */
-@Service
-public class WebSocketSrvc {
- @Autowired
- SimpMessagingTemplate messagingTemplate;
-
- public void sendBalance(long balance) {
- String url = "/topics/balance";
- messagingTemplate.convertAndSend(url, balance);
- }
-}
diff --git a/ethereum/src/main/java/com/crumbs/util/DateUtil.java b/ethereum/src/main/java/com/crumbs/util/DateUtil.java
index c2c0b93..a106af1 100644
--- a/ethereum/src/main/java/com/crumbs/util/DateUtil.java
+++ b/ethereum/src/main/java/com/crumbs/util/DateUtil.java
@@ -27,7 +27,7 @@ public static Date today() {
public static LocalDate todayLocalDate() {
//mock todau's date as 15th April
- return LocalDate.ofYearDay(2017,104);
+ return LocalDate.of(2017,5,11);
}
public static Date addDays(Date date, long days) {
diff --git a/ethereum/src/test/java/com/crumbs/test/MatchMakingTest.java b/ethereum/src/test/java/com/crumbs/test/MatchMakingTest.java
deleted file mode 100644
index 062ab31..0000000
--- a/ethereum/src/test/java/com/crumbs/test/MatchMakingTest.java
+++ /dev/null
@@ -1,145 +0,0 @@
-package com.crumbs.test;
-
-import com.alibaba.fastjson.JSON;
-import com.crumbs.entities.Member;
-import com.crumbs.entities.TxAccepted;
-import com.crumbs.models.ExceShipVM;
-import com.crumbs.repositories.MemberRepo;
-import com.crumbs.services.MatchMakingSrvc;
-import com.crumbs.util.DateUtil;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.List;
-
-/**
- * Created by low on 24/2/17 5:19 PM.
- */
-
-@RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class MatchMakingTest {
-
- private static final Logger logger = LoggerFactory.getLogger(MatchMakingTest.class);
-
- @Autowired
- MatchMakingSrvc matchMakingSrvc;
-
- @Autowired
- MemberRepo memberRepo;
-
- @Before
- public void setUp() {
- Member own = new Member();
- byte[] addr = {0x3e, 0x2f};
- own.setAddr(addr);
- own.setName("NTUC Bedok Mall");
- own.setX(100);
- own.setY(80);
- own.setOwn(true);
- memberRepo.save(own);
- }
-
- @Test
- public void testMatchMake() {
-
- Member own = memberRepo.findByOwn(true).get(0);
-
- Member mem1 = new Member(new byte[0], "Giant Tampines Mall", "loc", 13, 14, false);
- Member mem2 = new Member(new byte[0], "Cold Storage Katong V", "loc", 53, 3, false);
- Member mem3 = new Member(new byte[0], "Lee Minimart Katong V", "loc", 23, 88, false);
- Member mem4 = new Member(new byte[0], "Bedok Givers Charity", "loc", 45, 60, false);
- //TODO add more members
-
- Calendar cal = Calendar.getInstance();
-
- List tx_list = new ArrayList<>();
- int numTransactions = 10;
- List prices = new ArrayList<>(Arrays.asList(1500L, 50L,400L,600L,250L,420L,10L,1300L,550L,350L));
- List names = new ArrayList<>(Arrays.asList("Parmesan Cheese","Onion","Sardines",
- "Marigold Milk","Carrot","Corn","Carrot",
- "Parmesan Cheese","Onion","Marigold Milk"));
- List quantities = new ArrayList<>(Arrays.asList(100,500,430,350,200,300,300,150,500,200));
-
- for (int i = 0;i l = new HashSet<>();
- l.add(s);
- Shipment s2 = new Shipment();
- s2.setProduct(p);
- s2.setQuantity(2);
- s2.setExpiry(DateUtil.daysFromToday(8));
- s2.setDateStamp(DateUtil.daysFromToday(2));
- l.add(s2);
- Shipment s3 = new Shipment();
- s3.setProduct(p);
- s3.setQuantity(3);
- s3.setExpiry(DateUtil.daysFromToday(7));
- s3.setDateStamp(DateUtil.daysFromToday(1));
- l.add(s3);
- Shipment s4 = new Shipment();
- s4.setProduct(p);
- s4.setQuantity(4);
- s4.setExpiry(DateUtil.daysFromToday(9));
- s4.setDateStamp(DateUtil.today());
- l.add(s4);
- Shipment s5 = new Shipment();
- s5.setProduct(p);
- s5.setQuantity(15);
- s5.setExpiry(DateUtil.daysFromToday(6));
- s5.setDateStamp(DateUtil.daysFromToday(3));
- l.add(s5);
- Shipment s6 = new Shipment();
- s6.setProduct(p);
- s6.setQuantity(6);
- s6.setExpiry(DateUtil.daysFromToday(7));
- s6.setDateStamp(DateUtil.daysFromToday(0));
- l.add(s6);
- Shipment s7 = new Shipment();
- s7.setProduct(p);
- s7.setQuantity(36);
- s7.setExpiry(DateUtil.daysFromToday(5));
- s7.setDateStamp(DateUtil.daysFromToday(2));
- l.add(s7);
- Shipment s8 = new Shipment();
- s8.setProduct(p);
- s8.setQuantity(36);
- s8.setExpiry(DateUtil.daysFromToday(4));
- s8.setDateStamp(DateUtil.daysFromToday(0));
- l.add(s8);
- Shipment s9 = new Shipment();
- s9.setProduct(p);
- s9.setQuantity(36);
- s9.setExpiry(DateUtil.daysFromToday(14));
- s9.setDateStamp(DateUtil.daysFromToday(7));
- l.add(s9);
- p.setShipmentsRecord(l);
- SalesRecord r1 = new SalesRecord();
- r1.setQuantity(123456);
- r1.setDateStamp(new Date(123456));
- r1.setProduct(p);
- SalesRecord r4 = new SalesRecord();
- r4.setQuantity(12345678);
- r4.setDateStamp(new Date(12345678));
- r4.setProduct(p);
- SalesRecord r2 = new SalesRecord();
- r2.setQuantity(12345);
- r2.setDateStamp(new Date(12345));
- r2.setProduct(p);
- SalesRecord r3 = new SalesRecord();
- r3.setQuantity(1234567);
- r3.setDateStamp(new Date(1234567));
- r3.setProduct(p);
- Set records = new HashSet<>();
- records.add(r1);
- records.add(r2);
- records.add(r3);
- records.add(r4);
- p.setSalesRecord(records);
-
- inventoryService.storeProduct(p);
- ProductVM outcome = inventoryService.getProduct("test");
- logger.info(JSON.toJSONString(outcome));
- }
-
- @Test
- public void predictionTest() {
- String p ="test";
- List list = new ArrayList<>();
- list.add(3);
- list.add(4);
- list.add(8);
- list.add(12);
- list.add(68);
- list.add(13);
- list.add(13);
- list.add(19);
- logger.info(JSON.toJSONString(predictionSrvc.buildPrediction(list, "test"), true));
- //logger.info(JSON.toJSONString(inventoryService.futureStockInArray(p)));
- //logger.info(JSON.toJSONString(predictionSrvc.aggregatedStock(list, p)));
- }
-
-
- @Test
- public void inventoryMapTest() {
- String p = "test";
- logger.info(JSON.toJSONString(inventoryService.futureStock(p)));
- logger.info(JSON.toJSONString(inventoryService.futureStockInArray(p)));
- }
-
- @After
- public void removeApple() {
- inventoryService.deleteProduct("test");
- }
-
-}
diff --git a/ethereum/src/test/java/com/crumbs/test/TransactionTest.java b/ethereum/src/test/java/com/crumbs/test/TransactionTest.java
deleted file mode 100644
index 29da64c..0000000
--- a/ethereum/src/test/java/com/crumbs/test/TransactionTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.crumbs.test;
-
-import com.alibaba.fastjson.JSON;
-import com.crumbs.services.TransactionService;
-import com.crumbs.util.UrgencyUtil;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-
-/**
- * Created by low on 6/2/17 1:23 PM.
- */
-public class TransactionTest {
- private static final Logger logger = LoggerFactory.getLogger(TransactionTest.class);
-
- @Test
- public void test() {
- logger.info(JSON.toJSONString(UrgencyUtil.excessUrg(23, -6 )));
- }
-
- @Test
- public void random() {
- logger.info(LocalDateTime.now(ZoneId.of("GMT")).toString());
- }
-}