Browse Source

Standard service JS script.

Bug fix for load & LLL macros.
Move to new services.
cl-refactor
Gav Wood 11 years ago
parent
commit
fd6d794c35
  1. 2
      alethzero/MainWin.cpp
  2. 2
      include.lll
  3. 2
      liblll/CodeFragment.cpp
  4. 2
      liblll/CompilerState.cpp
  5. 73
      stdserv.js

2
alethzero/MainWin.cpp

@ -98,7 +98,7 @@ static void initUnits(QComboBox* _b)
_b->addItem(QString::fromStdString(units()[n].second), n);
}
Address c_config = Address("ccdeac59d35627b7de09332e819d5159e7bb7250");
Address c_config = Address("9ef0f0d81e040012600b0c1abdef7c48f720f88a");
using namespace boost::process;

2
include.lll

@ -1,5 +1,5 @@
{
(def 'gav 0x8a40bfaa73256b60764c1bf40675a99083efb075)
(def 'gav 0x51ba59315b3a95761d0863b05ccc7a7f54703d99)
(def 'alloc (len) (asm msize 0 1 len msize add sub mstore8))

2
liblll/CodeFragment.cpp

@ -343,7 +343,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
cs.defs.clear();
for (unsigned i = 0; i < m.args.size(); ++i)
{
requireDeposit(i, 1);
//requireDeposit(i, 1);
cs.args[m.args[i]] = code[i];
}
m_asm.append(CodeFragment(m.code, cs).m_asm);

2
liblll/CompilerState.cpp

@ -44,7 +44,7 @@ CodeFragment const& CompilerState::getDef(std::string const& _s)
void CompilerState::populateStandard()
{
static const string s = "{"
"(def 'gav 0x8a40bfaa73256b60764c1bf40675a99083efb075)"
"(def 'gav 0x51ba59315b3a95761d0863b05ccc7a7f54703d99)"
"(def 'namereg 0x2d0aceee7e5ab874e22ccf8d1a649f59106d74e8)"
"(def 'config 0xccdeac59d35627b7de09332e819d5159e7bb7250)"
"(def 'gavcoin 0x5620133321fcac7f15a5c570016f6cb6dc263f9d)"

73
stdserv.js

@ -0,0 +1,73 @@
env.note('Creating Config...')
var configCode = eth.lll("{
[[69]] (caller)
(returnlll
(when (= (caller) @@69)
(for {} (< @i (calldatasize)) [i](+ @i 64)
[[ (calldataload @i) ]] (calldataload (+ @i 32))
)
)
)
}")
env.note('Config code: ' + configCode.unbin())
var config;
eth.create(eth.key, '0', configCode, 10000, eth.gasPrice, function(a) { config = a; })
env.note('Config at address ' + config)
var nameRegCode = eth.lll("{
[[(address)]] 'NameReg
[['NameReg]] (address)
[[" + config + "]] 'Config
[['Config]] " + config + "
[[69]] (caller)
(returnlll
(if (calldatasize)
{
(when @@(calldataload 0) (stop))
(when @@(caller) [[@@(caller)]] 0)
[[(calldataload 0)]] (caller)
[[(caller)]] (calldataload 0)
}
{
(when (= (caller) @@69) (suicide (caller)))
(when @@(caller) {
[[@@(caller)]] 0
[[(caller)]] 0
})
}
)
)
}");
env.note('NameReg code: ' + nameRegCode.unbin())
var nameReg;
env.note('Create NameReg...')
eth.create(eth.key, '0', nameRegCode, 10000, eth.gasPrice, function(a) { nameReg = a; })
env.note('NameReg at address ' + nameReg)
env.note('Register NameReg...')
eth.transact(eth.key, '0', config, "0".pad(32) + nameReg.pad(32), 10000, eth.gasPrice);
var gavCoinCode = eth.lll("{
[[ (caller) ]]: 0x1000000
[0] 'GavCoin
(call (- (gas) 100) " + nameReg + " 0 0 7 0 0)
(returnlll {
(when (!= (calldatasize) 64) (stop))
[fromBal] @@(caller)
[toBal]: @@(calldataload 0)
[value]: (calldataload 32)
(when (< @fromBal @value) (stop))
[[ (caller) ]]: (- @fromBal @value)
[[ (calldataload 0) ]]: (+ @toBal @value)
})
}");
env.note('Create GavCoin...')
eth.create(eth.key, '0', gavCoinCode, 10000, eth.gasPrice);
env.note('All done.')
// env.load('/home/gav/Eth/cpp-ethereum/stdserv.js')
Loading…
Cancel
Save