Merge pull request #9 from pmmax/master
Added minor validations to AlgoMiner. Created integration tests for "terminate" function in all contracts. Updated the playground to support the "terminate" function for all contracts. Added the "reset" command to the playground. Updated playground docs. Updated playground sample scripts.
This commit is contained in:
27 files changed
+3403
-2829
No files matched your search
+5
@@ -15,6 +15,7 @@ namespace AdvancedAlgos.AlgoToken.AlgoTokenDistribution
|
||||
private Function _registerMiner;
|
||||
private Function _unregisterMiner;
|
||||
private Function _mine;
|
||||
private Function _terminate;
|
||||
|
||||
private Function _addSystem;
|
||||
private Function _addCoreTeam;
|
||||
@@ -37,6 +38,7 @@ namespace AdvancedAlgos.AlgoToken.AlgoTokenDistribution
|
||||
_registerMiner = contractDescriptor.GetFunction("registerMiner");
|
||||
_unregisterMiner = contractDescriptor.GetFunction("unregisterMiner");
|
||||
_mine = contractDescriptor.GetFunction("mine");
|
||||
_terminate = contractDescriptor.GetFunction("terminate");
|
||||
|
||||
_addSystem = contractDescriptor.GetFunction("addSystem");
|
||||
_addCoreTeam = contractDescriptor.GetFunction("addCoreTeam");
|
||||
@@ -54,6 +56,9 @@ namespace AdvancedAlgos.AlgoToken.AlgoTokenDistribution
|
||||
public Task<TransactionReceipt> MineAsync() =>
|
||||
InvokeAsync(_mine, 1500000);
|
||||
|
||||
public Task<TransactionReceipt> TerminateAsync() =>
|
||||
InvokeAsync(_terminate, 900000);
|
||||
|
||||
public Task<TransactionReceipt> AddSystemAsync(string account) =>
|
||||
InvokeAsync(_addSystem, 900000, account);
|
||||
|
||||
|
||||
+5
@@ -22,6 +22,7 @@ namespace AdvancedAlgos.AlgoToken.AlgoTokenDistribution
|
||||
private Function _startMining;
|
||||
private Function _stopMining;
|
||||
private Function _mine;
|
||||
private Function _terminate;
|
||||
|
||||
private Function _addSystem;
|
||||
private Function _addCoreTeam;
|
||||
@@ -49,6 +50,7 @@ namespace AdvancedAlgos.AlgoToken.AlgoTokenDistribution
|
||||
_startMining = contractDescriptor.GetFunction("startMining");
|
||||
_stopMining = contractDescriptor.GetFunction("stopMining");
|
||||
_mine = contractDescriptor.GetFunction("mine");
|
||||
_terminate = contractDescriptor.GetFunction("terminate");
|
||||
|
||||
_addSystem = contractDescriptor.GetFunction("addSystem");
|
||||
_addCoreTeam = contractDescriptor.GetFunction("addCoreTeam");
|
||||
@@ -85,6 +87,9 @@ namespace AdvancedAlgos.AlgoToken.AlgoTokenDistribution
|
||||
public Task<TransactionReceipt> MineAsync() =>
|
||||
InvokeAsync(_mine, 900000);
|
||||
|
||||
public Task<TransactionReceipt> TerminateAsync() =>
|
||||
InvokeAsync(_terminate, 900000);
|
||||
|
||||
public Task<TransactionReceipt> AddSystemAsync(string account) =>
|
||||
InvokeAsync(_addSystem, 900000, account);
|
||||
|
||||
|
||||
+5
@@ -13,6 +13,7 @@ namespace AdvancedAlgos.AlgoToken.AlgoTokenDistribution
|
||||
public class AlgoPool : SmartContract<AlgoPool>
|
||||
{
|
||||
private Function _trasferToMiner;
|
||||
private Function _terminate;
|
||||
|
||||
public AlgoPool(Web3 web3, IGasPriceProvider gasPriceProvider) : base(web3, gasPriceProvider) { }
|
||||
public AlgoPool(string contractAddress, Web3 web3, IGasPriceProvider gasPriceProvider) : base(contractAddress, web3, gasPriceProvider) { }
|
||||
@@ -27,9 +28,13 @@ namespace AdvancedAlgos.AlgoToken.AlgoTokenDistribution
|
||||
protected override void Initialize(Contract contractDescriptor)
|
||||
{
|
||||
_trasferToMiner = contractDescriptor.GetFunction("trasferToMiner");
|
||||
_terminate = contractDescriptor.GetFunction("terminate");
|
||||
}
|
||||
|
||||
public Task<TransactionReceipt> TrasferToMinerAsync(string minerAddress) =>
|
||||
InvokeAsync(_trasferToMiner, 900000, minerAddress);
|
||||
|
||||
public Task<TransactionReceipt> TerminateAsync() =>
|
||||
InvokeAsync(_terminate, 900000);
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -46,6 +46,11 @@ contract AlgoMiner is AlgoCommon, ERC20TokenHolder, AlgoSystemRole, AlgoCoreTeam
|
||||
public {
|
||||
|
||||
require(category >= 0 && category <= 5);
|
||||
require(minerAccountAddress != address(0));
|
||||
|
||||
if(minerType == MinerType.PoolBased) {
|
||||
require(referralAccountAddress != address(0));
|
||||
}
|
||||
|
||||
_minerType = minerType;
|
||||
_category = category;
|
||||
@@ -150,18 +155,13 @@ contract AlgoMiner is AlgoCommon, ERC20TokenHolder, AlgoSystemRole, AlgoCoreTeam
|
||||
}
|
||||
|
||||
uint256 minerTokens = _currentYearSupply / DAYS_PER_YEAR;
|
||||
uint256 referralTokens = minerTokens * 10 / 100;
|
||||
|
||||
require(minerTokens > 0);
|
||||
require(referralTokens > 0);
|
||||
|
||||
_token.safeTransfer(_miner, minerTokens);
|
||||
|
||||
if(_referral != address(0)) {
|
||||
uint256 referralTokens = minerTokens * 10 / 100;
|
||||
|
||||
require(referralTokens > 0);
|
||||
|
||||
_token.safeTransfer(_referral, referralTokens);
|
||||
}
|
||||
_token.safeTransfer(_referral, referralTokens);
|
||||
}
|
||||
|
||||
function terminate() public onlyCoreTeam {
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ contract IAlgoMiner {
|
||||
function isAlgoMiner() public pure returns (bool);
|
||||
function getMinerType() public view returns (uint8);
|
||||
function getCategory() public view returns (uint8);
|
||||
function isMining() public view returns (bool);
|
||||
function getMiner() public view returns (address);
|
||||
function getReferral() public view returns (address);
|
||||
function isMining() public view returns (bool);
|
||||
}
|
||||
+1
-1
@@ -2016,9 +2016,9 @@
|
||||
}
|
||||
],
|
||||
"contractDependencies": [
|
||||
750,
|
||||
86,
|
||||
693,
|
||||
750,
|
||||
815
|
||||
],
|
||||
"contractKind": "contract",
|
||||
|
||||
+3013
-2776
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -1 +1 @@
|
||||
60806040523480156200001157600080fd5b5060405160a080620014c7833981016040908152815160208301519183015160608401516080909401516000805433600160a060020a0319918216811760a060020a60ff02191690925560018054909116600160a060020a0384161790559294919262000087906401000000006200014c810204565b6200009b336401000000006200016a810204565b620000af3364010000000062000185810204565b60008460ff1610158015620000c8575060058460ff1611155b1515620000d457600080fd5b6005805486919060ff191660018381811115620000ed57fe5b0217905550506005805461ff00191661010060ff9590951694909402939093176201000060b060020a03191662010000600160a060020a03938416021790925560068054600160a060020a031916929091169190911790555062000233565b62000167600282640100000000620011be620001a082021704565b50565b62000167600382640100000000620011be620001a082021704565b62000167600482640100000000620011be620001a082021704565b600160a060020a0381161515620001b657600080fd5b620001cb8282640100000000620001fb810204565b15620001d657600080fd5b600160a060020a0316600090815260209190915260409020805460ff19166001179055565b6000600160a060020a03821615156200021357600080fd5b50600160a060020a03166000908152602091909152604090205460ff1690565b61128480620002436000396000f30060806040526004361061017f5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630c08bf888114610184578063162f986d1461019b5780631777fb4b146101b057806319a74ab3146101d957806321b79d98146101ee578063231d4e2a1461020357806329d10b6e146102245780632e6b684914610245578063302c11ca14610266578063329b1c921461029757806334cdcf26146102ac578063363aa6c7146102cd5780633e6968b6146102e2578063427534a41461030e5780634969ae7014610323578063608d3d3d1461034e57806374be75921461036f57806380258e471461039057806381a24459146103a55780638329138f146103c657806399f4b251146103ed5780639e614ca014610402578063b2a32cd514610417578063be9524941461042c578063c6846ef814610441578063cdfd0f6414610468578063ce41607a1461047d578063d43acc7914610492578063da408679146104a7578063e9d61859146104bc575b600080fd5b34801561019057600080fd5b506101996104d1565b005b3480156101a757600080fd5b506101996104ef565b3480156101bc57600080fd5b506101c561055e565b604080519115158252519081900360200190f35b3480156101e557600080fd5b506101c5610563565b3480156101fa57600080fd5b5061019961059a565b34801561020f57600080fd5b50610199600160a060020a0360043516610630565b34801561023057600080fd5b50610199600160a060020a036004351661071c565b34801561025157600080fd5b50610199600160a060020a0360043516610739565b34801561027257600080fd5b5061027b610756565b60408051600160a060020a039092168252519081900360200190f35b3480156102a357600080fd5b5061027b61076b565b3480156102b857600080fd5b506101c5600160a060020a036004351661077a565b3480156102d957600080fd5b50610199610795565b3480156102ee57600080fd5b506102f7610846565b6040805161ffff9092168252519081900360200190f35b34801561031a57600080fd5b50610199610857565b34801561032f57600080fd5b506103386108c3565b6040805160ff9092168252519081900360200190f35b34801561035a57600080fd5b506101c5600160a060020a03600435166108d7565b34801561037b57600080fd5b50610199600160a060020a03600435166108ea565b34801561039c57600080fd5b50610338610907565b3480156103b157600080fd5b506101c5600160a060020a0360043516610915565b3480156103d257600080fd5b50610199600160a060020a0360043581169060243516610928565b3480156103f957600080fd5b506101996109db565b34801561040e57600080fd5b50610199610c2e565b34801561042357600080fd5b50610199610c9f565b34801561043857600080fd5b50610199610dfd565b34801561044d57600080fd5b50610456610e06565b60408051918252519081900360200190f35b34801561047457600080fd5b50610456610e0c565b34801561048957600080fd5b50610338610e12565b34801561049e57600080fd5b50610199610e35565b3480156104b357600080fd5b50610199610e3e565b3480156104c857600080fd5b50610199610ecf565b6104da336108d7565b15156104e557600080fd5b6104ed610ed8565b565b60005460a060020a900460ff161561050657600080fd5b61050f33610915565b151561051a57600080fd5b600160065460a060020a900460ff16600381111561053457fe5b1461053e57600080fd5b600680546002919060a060020a60ff02191660a060020a835b0217905550565b600190565b6000600160065460a060020a900460ff16600381111561057f57fe5b148015610595575060065460a860020a900460ff165b905090565b60005460a060020a900460ff16156105b157600080fd5b600554620100009004600160a060020a031633146105ce57600080fd5b600160065460a060020a900460ff1660038111156105e857fe5b146105f257600080fd5b60065460a860020a900460ff161561060957600080fd5b6006805475ff000000000000000000000000000000000000000000191660a860020a179055565b610639336108d7565b151561064457600080fd5b600060065460a060020a900460ff16600381111561065e57fe5b1461066857600080fd5b600154604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051610719928492600160a060020a03909116916370a08231916024808201926020929091908290030181600087803b1580156106d457600080fd5b505af11580156106e8573d6000803e3d6000fd5b505050506040513d60208110156106fe57600080fd5b5051600154600160a060020a0316919063ffffffff610f9f16565b50565b61072533610915565b151561073057600080fd5b61071981611057565b610742336108d7565b151561074d57600080fd5b61071981611068565b600554620100009004600160a060020a031690565b600654600160a060020a031690565b600061078d6Line truncated
|
||||
60806040523480156200001157600080fd5b5060405160a080620014f7833981016040908152815160208301519183015160608401516080909401516000805433600160a060020a0319918216811760a060020a60ff02191690925560018054909116600160a060020a0384161790559294919262000087906401000000006200018e810204565b6200009b33640100000000620001ac810204565b620000af33640100000000620001c7810204565b60008460ff1610158015620000c8575060058460ff1611155b1515620000d457600080fd5b600160a060020a0383161515620000ea57600080fd5b6000856001811115620000f957fe5b14156200011657600160a060020a03821615156200011657600080fd5b6005805486919060ff1916600183818111156200012f57fe5b0217905550506005805461ff00191661010060ff9590951694909402939093176201000060b060020a03191662010000600160a060020a03938416021790925560068054600160a060020a031916929091169190911790555062000275565b620001a9600282640100000000620011ac620001e282021704565b50565b620001a9600382640100000000620011ac620001e282021704565b620001a9600482640100000000620011ac620001e282021704565b600160a060020a0381161515620001f857600080fd5b6200020d82826401000000006200023d810204565b156200021857600080fd5b600160a060020a0316600090815260209190915260409020805460ff19166001179055565b6000600160a060020a03821615156200025557600080fd5b50600160a060020a03166000908152602091909152604090205460ff1690565b61127280620002856000396000f30060806040526004361061017f5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630c08bf888114610184578063162f986d1461019b5780631777fb4b146101b057806319a74ab3146101d957806321b79d98146101ee578063231d4e2a1461020357806329d10b6e146102245780632e6b684914610245578063302c11ca14610266578063329b1c921461029757806334cdcf26146102ac578063363aa6c7146102cd5780633e6968b6146102e2578063427534a41461030e5780634969ae7014610323578063608d3d3d1461034e57806374be75921461036f57806380258e471461039057806381a24459146103a55780638329138f146103c657806399f4b251146103ed5780639e614ca014610402578063b2a32cd514610417578063be9524941461042c578063c6846ef814610441578063cdfd0f6414610468578063ce41607a1461047d578063d43acc7914610492578063da408679146104a7578063e9d61859146104bc575b600080fd5b34801561019057600080fd5b506101996104d1565b005b3480156101a757600080fd5b506101996104ef565b3480156101bc57600080fd5b506101c561055e565b604080519115158252519081900360200190f35b3480156101e557600080fd5b506101c5610563565b3480156101fa57600080fd5b5061019961059a565b34801561020f57600080fd5b50610199600160a060020a0360043516610630565b34801561023057600080fd5b50610199600160a060020a036004351661071c565b34801561025157600080fd5b50610199600160a060020a0360043516610739565b34801561027257600080fd5b5061027b610756565b60408051600160a060020a039092168252519081900360200190f35b3480156102a357600080fd5b5061027b61076b565b3480156102b857600080fd5b506101c5600160a060020a036004351661077a565b3480156102d957600080fd5b50610199610795565b3480156102ee57600080fd5b506102f7610846565b6040805161ffff9092168252519081900360200190f35b34801561031a57600080fd5b50610199610857565b34801561032f57600080fd5b506103386108c3565b6040805160ff9092168252519081900360200190f35b34801561035a57600080fd5b506101c5600160a060020a03600435166108d7565b34801561037b57600080fd5b50610199600160a060020a03600435166108ea565b34801561039c57600080fd5b50610338610907565b3480156103b157600080fd5b506101c5600160a060020a0360043516610915565b3480156103d257600080fd5b50610199600160a060020a0360043581169060243516610928565b3480156103f957600080fd5b506101996109db565b34801561040e57600080fd5b50610199610c1c565b34801561042357600080fd5b50610199610c8d565b34801561043857600080fd5b50610199610deb565b34801561044d57600080fd5b50610456610df4565b60408051918252519081900360200190f35b34801561047457600080fd5b50610456610dfa565b34801561048957600080fd5b50610338610e00565b34801561049e57600080fd5b50610199610e23565b3480156104b357600080fd5b50610199610e2c565b3480156104c857600080fd5b50610199610ebd565b6104da336108d7565b15156104e557600080fd5b6104ed610ec6565b565b60005460a060020a900460ff161561050657600080fd5b61050f33610915565b151561051a57600080fd5b600160065460a060020a900460ff16600381111561053457fe5b1461053e57600080fd5b600680546002919060a060020a60ff02191660a060020a835b0217905550565b600190565b6000600160065460a060020a900460ff16600381111561057f57fe5b148015610595575060065460a860020a900460ff165b905090565b60005460a060020a900460ff16156105b157600080fd5b600554620100009004600160a060020a031633146105ce57600080fd5b600160065460a060020a900460ff1660038111156105e857fe5b146105f257600080fd5b60065460a860020a900460ff161561060957600080fd5b6006805475ff000000000000000000000000000000000000000000191660a860020a179055565b610639336108d7565b151561064457600080fd5b600060065460a060020a900460ff16600381111561065e57fe5b1461066857600080fd5b600154604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051610719928492600160a060020a03909116916370a08231916024808201926020929091908290030181600087803b1580156106d457600080fd5b505af11580156106e8573d6000803e3d6000fd5b505050506040513d60208110156106fe57600080fd5b5051600154600160a060020a0316919063ffffffff610f8d16565b50565b61072533610915565b151561073057600080fd5b61071981611045565b610742336Line truncated
|
||||
+2
-2
@@ -407,7 +407,7 @@
|
||||
"type": "constructor"
|
||||
}
|
||||
],
|
||||
"bytecode": "60806040523480156200001157600080fd5b5060405160a080620014c7833981016040908152815160208301519183015160608401516080909401516000805433600160a060020a0319918216811760a060020a60ff02191690925560018054909116600160a060020a0384161790559294919262000087906401000000006200014c810204565b6200009b336401000000006200016a810204565b620000af3364010000000062000185810204565b60008460ff1610158015620000c8575060058460ff1611155b1515620000d457600080fd5b6005805486919060ff191660018381811115620000ed57fe5b0217905550506005805461ff00191661010060ff9590951694909402939093176201000060b060020a03191662010000600160a060020a03938416021790925560068054600160a060020a031916929091169190911790555062000233565b62000167600282640100000000620011be620001a082021704565b50565b62000167600382640100000000620011be620001a082021704565b62000167600482640100000000620011be620001a082021704565b600160a060020a0381161515620001b657600080fd5b620001cb8282640100000000620001fb810204565b15620001d657600080fd5b600160a060020a0316600090815260209190915260409020805460ff19166001179055565b6000600160a060020a03821615156200021357600080fd5b50600160a060020a03166000908152602091909152604090205460ff1690565b61128480620002436000396000f30060806040526004361061017f5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630c08bf888114610184578063162f986d1461019b5780631777fb4b146101b057806319a74ab3146101d957806321b79d98146101ee578063231d4e2a1461020357806329d10b6e146102245780632e6b684914610245578063302c11ca14610266578063329b1c921461029757806334cdcf26146102ac578063363aa6c7146102cd5780633e6968b6146102e2578063427534a41461030e5780634969ae7014610323578063608d3d3d1461034e57806374be75921461036f57806380258e471461039057806381a24459146103a55780638329138f146103c657806399f4b251146103ed5780639e614ca014610402578063b2a32cd514610417578063be9524941461042c578063c6846ef814610441578063cdfd0f6414610468578063ce41607a1461047d578063d43acc7914610492578063da408679146104a7578063e9d61859146104bc575b600080fd5b34801561019057600080fd5b506101996104d1565b005b3480156101a757600080fd5b506101996104ef565b3480156101bc57600080fd5b506101c561055e565b604080519115158252519081900360200190f35b3480156101e557600080fd5b506101c5610563565b3480156101fa57600080fd5b5061019961059a565b34801561020f57600080fd5b50610199600160a060020a0360043516610630565b34801561023057600080fd5b50610199600160a060020a036004351661071c565b34801561025157600080fd5b50610199600160a060020a0360043516610739565b34801561027257600080fd5b5061027b610756565b60408051600160a060020a039092168252519081900360200190f35b3480156102a357600080fd5b5061027b61076b565b3480156102b857600080fd5b506101c5600160a060020a036004351661077a565b3480156102d957600080fd5b50610199610795565b3480156102ee57600080fd5b506102f7610846565b6040805161ffff9092168252519081900360200190f35b34801561031a57600080fd5b50610199610857565b34801561032f57600080fd5b506103386108c3565b6040805160ff9092168252519081900360200190f35b34801561035a57600080fd5b506101c5600160a060020a03600435166108d7565b34801561037b57600080fd5b50610199600160a060020a03600435166108ea565b34801561039c57600080fd5b50610338610907565b3480156103b157600080fd5b506101c5600160a060020a0360043516610915565b3480156103d257600080fd5b50610199600160a060020a0360043581169060243516610928565b3480156103f957600080fd5b506101996109db565b34801561040e57600080fd5b50610199610c2e565b34801561042357600080fd5b50610199610c9f565b34801561043857600080fd5b50610199610dfd565b34801561044d57600080fd5b50610456610e06565b60408051918252519081900360200190f35b34801561047457600080fd5b50610456610e0c565b34801561048957600080fd5b50610338610e12565b34801561049e57600080fd5b50610199610e35565b3480156104b357600080fd5b50610199610e3e565b3480156104c857600080fd5b50610199610ecf565b6104da336108d7565b15156104e557600080fd5b6104ed610ed8565b565b60005460a060020a900460ff161561050657600080fd5b61050f33610915565b151561051a57600080fd5b600160065460a060020a900460ff16600381111561053457fe5b1461053e57600080fd5b600680546002919060a060020a60ff02191660a060020a835b0217905550565b600190565b6000600160065460a060020a900460ff16600381111561057f57fe5b148015610595575060065460a860020a900460ff165b905090565b60005460a060020a900460ff16156105b157600080fd5b600554620100009004600160a060020a031633146105ce57600080fd5b600160065460a060020a900460ff1660038111156105e857fe5b146105f257600080fd5b60065460a860020a900460ff161561060957600080fd5b6006805475ff000000000000000000000000000000000000000000191660a860020a179055565b610639336108d7565b151561064457600080fd5b600060065460a060020a900460ff16600381111561065e57fe5b1461066857600080fd5b600154604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051610719928492600160a060020a03909116916370a08231916024808201926020929091908290030181600087803b1580156106d457600080fd5b505af11580156106e8573d6000803e3d6000fd5b505050506040513d60208110156106fe57600080fd5b5051600154600160a060020a0316919063ffffffff610f9f16565b50565b61072533610915565b151561073057600080fd5b61071981611057565b610742336108d7565b151561074d57600080fd5b61071981611068565b600554620100009004600160a060020a031690565b600654600160a060020a0316Line truncated
|
||||
"bytecode": "60806040523480156200001157600080fd5b5060405160a080620014f7833981016040908152815160208301519183015160608401516080909401516000805433600160a060020a0319918216811760a060020a60ff02191690925560018054909116600160a060020a0384161790559294919262000087906401000000006200018e810204565b6200009b33640100000000620001ac810204565b620000af33640100000000620001c7810204565b60008460ff1610158015620000c8575060058460ff1611155b1515620000d457600080fd5b600160a060020a0383161515620000ea57600080fd5b6000856001811115620000f957fe5b14156200011657600160a060020a03821615156200011657600080fd5b6005805486919060ff1916600183818111156200012f57fe5b0217905550506005805461ff00191661010060ff9590951694909402939093176201000060b060020a03191662010000600160a060020a03938416021790925560068054600160a060020a031916929091169190911790555062000275565b620001a9600282640100000000620011ac620001e282021704565b50565b620001a9600382640100000000620011ac620001e282021704565b620001a9600482640100000000620011ac620001e282021704565b600160a060020a0381161515620001f857600080fd5b6200020d82826401000000006200023d810204565b156200021857600080fd5b600160a060020a0316600090815260209190915260409020805460ff19166001179055565b6000600160a060020a03821615156200025557600080fd5b50600160a060020a03166000908152602091909152604090205460ff1690565b61127280620002856000396000f30060806040526004361061017f5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630c08bf888114610184578063162f986d1461019b5780631777fb4b146101b057806319a74ab3146101d957806321b79d98146101ee578063231d4e2a1461020357806329d10b6e146102245780632e6b684914610245578063302c11ca14610266578063329b1c921461029757806334cdcf26146102ac578063363aa6c7146102cd5780633e6968b6146102e2578063427534a41461030e5780634969ae7014610323578063608d3d3d1461034e57806374be75921461036f57806380258e471461039057806381a24459146103a55780638329138f146103c657806399f4b251146103ed5780639e614ca014610402578063b2a32cd514610417578063be9524941461042c578063c6846ef814610441578063cdfd0f6414610468578063ce41607a1461047d578063d43acc7914610492578063da408679146104a7578063e9d61859146104bc575b600080fd5b34801561019057600080fd5b506101996104d1565b005b3480156101a757600080fd5b506101996104ef565b3480156101bc57600080fd5b506101c561055e565b604080519115158252519081900360200190f35b3480156101e557600080fd5b506101c5610563565b3480156101fa57600080fd5b5061019961059a565b34801561020f57600080fd5b50610199600160a060020a0360043516610630565b34801561023057600080fd5b50610199600160a060020a036004351661071c565b34801561025157600080fd5b50610199600160a060020a0360043516610739565b34801561027257600080fd5b5061027b610756565b60408051600160a060020a039092168252519081900360200190f35b3480156102a357600080fd5b5061027b61076b565b3480156102b857600080fd5b506101c5600160a060020a036004351661077a565b3480156102d957600080fd5b50610199610795565b3480156102ee57600080fd5b506102f7610846565b6040805161ffff9092168252519081900360200190f35b34801561031a57600080fd5b50610199610857565b34801561032f57600080fd5b506103386108c3565b6040805160ff9092168252519081900360200190f35b34801561035a57600080fd5b506101c5600160a060020a03600435166108d7565b34801561037b57600080fd5b50610199600160a060020a03600435166108ea565b34801561039c57600080fd5b50610338610907565b3480156103b157600080fd5b506101c5600160a060020a0360043516610915565b3480156103d257600080fd5b50610199600160a060020a0360043581169060243516610928565b3480156103f957600080fd5b506101996109db565b34801561040e57600080fd5b50610199610c1c565b34801561042357600080fd5b50610199610c8d565b34801561043857600080fd5b50610199610deb565b34801561044d57600080fd5b50610456610df4565b60408051918252519081900360200190f35b34801561047457600080fd5b50610456610dfa565b34801561048957600080fd5b50610338610e00565b34801561049e57600080fd5b50610199610e23565b3480156104b357600080fd5b50610199610e2c565b3480156104c857600080fd5b50610199610ebd565b6104da336108d7565b15156104e557600080fd5b6104ed610ec6565b565b60005460a060020a900460ff161561050657600080fd5b61050f33610915565b151561051a57600080fd5b600160065460a060020a900460ff16600381111561053457fe5b1461053e57600080fd5b600680546002919060a060020a60ff02191660a060020a835b0217905550565b600190565b6000600160065460a060020a900460ff16600381111561057f57fe5b148015610595575060065460a860020a900460ff165b905090565b60005460a060020a900460ff16156105b157600080fd5b600554620100009004600160a060020a031633146105ce57600080fd5b600160065460a060020a900460ff1660038111156105e857fe5b146105f257600080fd5b60065460a860020a900460ff161561060957600080fd5b6006805475ff000000000000000000000000000000000000000000191660a860020a179055565b610639336108d7565b151561064457600080fd5b600060065460a060020a900460ff16600381111561065e57fe5b1461066857600080fd5b600154604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051610719928492600160a060020a03909116916370a08231916024808201926020929091908290030181600087803b1580156106d457600080fd5b505af11580156106e8573d6000803e3d6000fd5b505050506040513d60208110156106fe57600080fd5b5051600154600160a060020a0316919063ffffffff610f8d16565b50565b61072533610915565b151561073057600080fd5b6107198161Line truncated
|
||||
"functionHashes": {
|
||||
"DAYS_PER_YEAR()": "c6846ef8",
|
||||
"activateMiner()": "b2a32cd5",
|
||||
@@ -442,7 +442,7 @@
|
||||
},
|
||||
"gasEstimates": {
|
||||
"creation": {
|
||||
"codeDepositCost": "948000",
|
||||
"codeDepositCost": "944400",
|
||||
"executionCost": "infinite",
|
||||
"totalCost": "infinite"
|
||||
},
|
||||
|
||||
+40
-16
@@ -117,16 +117,6 @@ namespace AdvancedAlgos.AlgoToken.AlgoTokenDistribution.IntegrationTests
|
||||
var token = new AlgoTokenV1(EthNetwork.Instance.GetWeb3(tokenOwnerAccount), EthNetwork.Instance.GasPriceProvider);
|
||||
await token.DeployAsync();
|
||||
|
||||
// Create the pools to transfer the proper number of tokens to the miners...
|
||||
var pool1 = new AlgoPool(EthNetwork.Instance.GetWeb3(coreTeamAccount), EthNetwork.Instance.GasPriceProvider);
|
||||
await pool1.DeployAsync(0, token.ContractAddress);
|
||||
var pool2 = new AlgoPool(EthNetwork.Instance.GetWeb3(coreTeamAccount), EthNetwork.Instance.GasPriceProvider);
|
||||
await pool2.DeployAsync(1, token.ContractAddress);
|
||||
|
||||
// Transfer some tokens to the pools...
|
||||
await token.TransferAsync(pool1.ContractAddress, 100.MAlgo());
|
||||
await token.TransferAsync(pool2.ContractAddress, 100.MAlgo());
|
||||
|
||||
// Create a fees...
|
||||
var fees1 = new AlgoFees(EthNetwork.Instance.GetWeb3(coreTeamAccount), EthNetwork.Instance.GasPriceProvider);
|
||||
await fees1.DeployAsync(token.ContractAddress);
|
||||
@@ -149,13 +139,9 @@ namespace AdvancedAlgos.AlgoToken.AlgoTokenDistribution.IntegrationTests
|
||||
referralAccounts[i] = EthAccountFactory.Create();
|
||||
await EthNetwork.Instance.RefillAsync(minerAccounts[i]);
|
||||
|
||||
// Create the miner...
|
||||
// Create the miner as "NonPoolBased" so it can be activated...
|
||||
miners[i] = new AlgoMiner(EthNetwork.Instance.GetWeb3(coreTeamAccount), EthNetwork.Instance.GasPriceProvider);
|
||||
await miners[i].DeployAsync(0, i, minerAccounts[i].Address, referralAccounts[i].Address, token.ContractAddress);
|
||||
|
||||
// Transfer some tokens to the miner so it can be activated...
|
||||
await pool1.TrasferToMinerAsync(miners[i].ContractAddress);
|
||||
await pool2.TrasferToMinerAsync(miners[i].ContractAddress);
|
||||
await miners[i].DeployAsync(1, i, minerAccounts[i].Address, referralAccounts[i].Address, token.ContractAddress);
|
||||
|
||||
// Activate the miner...
|
||||
await miners[i].ActivateMinerAsync();
|
||||
@@ -191,5 +177,43 @@ namespace AdvancedAlgos.AlgoToken.AlgoTokenDistribution.IntegrationTests
|
||||
Assert.Equal(40.Algo(), balance4);
|
||||
Assert.Equal(50.Algo(), balance5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TerminateTest()
|
||||
{
|
||||
EthNetwork.UseGanacheTestNet();
|
||||
|
||||
var prefundedAccount = new Account(EthNetwork.Instance.PrefundedPrivateKey);
|
||||
|
||||
var tokenOwnerAccount = EthAccountFactory.Create();
|
||||
var coreTeamAccount = EthAccountFactory.Create();
|
||||
|
||||
await EthNetwork.Instance.RefillAsync(tokenOwnerAccount);
|
||||
await EthNetwork.Instance.RefillAsync(coreTeamAccount);
|
||||
|
||||
// Create the ERC20 token...
|
||||
var token = new AlgoTokenV1(EthNetwork.Instance.GetWeb3(tokenOwnerAccount), EthNetwork.Instance.GasPriceProvider);
|
||||
await token.DeployAsync();
|
||||
|
||||
// Store the current balance of the token owner...
|
||||
var tokenOwnerAccountBalance = await token.BalanceOfAsync(tokenOwnerAccount.Address);
|
||||
|
||||
// Create a fees...
|
||||
var fees1 = new AlgoFees(EthNetwork.Instance.GetWeb3(coreTeamAccount), EthNetwork.Instance.GasPriceProvider);
|
||||
await fees1.DeployAsync(token.ContractAddress);
|
||||
|
||||
// Transfer some tokens to the fees...
|
||||
await token.TransferAsync(fees1.ContractAddress, 100.Algo());
|
||||
|
||||
// Ensure the receiver got the tokens...
|
||||
Assert.Equal(100.Algo(), await token.BalanceOfAsync(fees1.ContractAddress));
|
||||
|
||||
// Terminate the contract.
|
||||
await fees1.TerminateAsync();
|
||||
|
||||
// Ensure the contract returned all the tokens...
|
||||
Assert.Equal(0, await token.BalanceOfAsync(fees1.ContractAddress));
|
||||
Assert.Equal(100.Algo(), await token.BalanceOfAsync(coreTeamAccount.Address));
|
||||
}
|
||||
}
|
||||
}
|
||||
+40
@@ -111,5 +111,45 @@ namespace AdvancedAlgos.AlgoToken.AlgoTokenDistribution.IntegrationTests
|
||||
Assert.Equal(expectedMinerBalance, await token.BalanceOfAsync(minerAccount.Address));
|
||||
Assert.Equal(expectedReferralBalance, await token.BalanceOfAsync(referralAccount.Address));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TerminateTest()
|
||||
{
|
||||
EthNetwork.UseGanacheTestNet();
|
||||
|
||||
var prefundedAccount = new Account(EthNetwork.Instance.PrefundedPrivateKey);
|
||||
|
||||
var tokenOwnerAccount = EthAccountFactory.Create();
|
||||
var coreTeamAccount = EthAccountFactory.Create();
|
||||
var minerAccount = EthAccountFactory.Create();
|
||||
var referralAccount = EthAccountFactory.Create();
|
||||
|
||||
await EthNetwork.Instance.RefillAsync(tokenOwnerAccount);
|
||||
await EthNetwork.Instance.RefillAsync(coreTeamAccount);
|
||||
|
||||
// Create the ERC20 token...
|
||||
var token = new AlgoTokenV1(EthNetwork.Instance.GetWeb3(tokenOwnerAccount), EthNetwork.Instance.GasPriceProvider);
|
||||
await token.DeployAsync();
|
||||
|
||||
// Store the current balance of the token owner...
|
||||
var tokenOwnerAccountBalance = await token.BalanceOfAsync(tokenOwnerAccount.Address);
|
||||
|
||||
// Create a miner...
|
||||
var miner1 = new AlgoMiner(EthNetwork.Instance.GetWeb3(coreTeamAccount), EthNetwork.Instance.GasPriceProvider);
|
||||
await miner1.DeployAsync(0, 2, minerAccount.Address, referralAccount.Address, token.ContractAddress);
|
||||
|
||||
// Transfer some tokens to the miner...
|
||||
await token.TransferAsync(miner1.ContractAddress, 100.Algo());
|
||||
|
||||
// Ensure the receiver got the tokens...
|
||||
Assert.Equal(100.Algo(), await token.BalanceOfAsync(miner1.ContractAddress));
|
||||
|
||||
// Terminate the contract.
|
||||
await miner1.TerminateAsync();
|
||||
|
||||
// Ensure the contract returned all the tokens...
|
||||
Assert.Equal(0, await token.BalanceOfAsync(miner1.ContractAddress));
|
||||
Assert.Equal(100.Algo(), await token.BalanceOfAsync(coreTeamAccount.Address));
|
||||
}
|
||||
}
|
||||
}
|
||||
+38
@@ -123,5 +123,43 @@ namespace AdvancedAlgos.AlgoToken.AlgoTokenDistribution.IntegrationTests
|
||||
Assert.Equal(4.MAlgo() * 10 / 100, await token.BalanceOfAsync(miners[4].ContractAddress));
|
||||
Assert.Equal(5.MAlgo() * 10 / 100, await token.BalanceOfAsync(miners[5].ContractAddress));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TerminateTest()
|
||||
{
|
||||
EthNetwork.UseGanacheTestNet();
|
||||
|
||||
var prefundedAccount = new Account(EthNetwork.Instance.PrefundedPrivateKey);
|
||||
|
||||
var tokenOwnerAccount = EthAccountFactory.Create();
|
||||
var coreTeamAccount = EthAccountFactory.Create();
|
||||
|
||||
await EthNetwork.Instance.RefillAsync(tokenOwnerAccount);
|
||||
await EthNetwork.Instance.RefillAsync(coreTeamAccount);
|
||||
|
||||
// Create the ERC20 token...
|
||||
var token = new AlgoTokenV1(EthNetwork.Instance.GetWeb3(tokenOwnerAccount), EthNetwork.Instance.GasPriceProvider);
|
||||
await token.DeployAsync();
|
||||
|
||||
// Store the current balance of the token owner...
|
||||
var tokenOwnerAccountBalance = await token.BalanceOfAsync(tokenOwnerAccount.Address);
|
||||
|
||||
// Create a pool...
|
||||
var pool1 = new AlgoPool(EthNetwork.Instance.GetWeb3(coreTeamAccount), EthNetwork.Instance.GasPriceProvider);
|
||||
await pool1.DeployAsync(0, token.ContractAddress);
|
||||
|
||||
// Transfer some tokens to the pool...
|
||||
await token.TransferAsync(pool1.ContractAddress, 100.Algo());
|
||||
|
||||
// Ensure the receiver got the tokens...
|
||||
Assert.Equal(100.Algo(), await token.BalanceOfAsync(pool1.ContractAddress));
|
||||
|
||||
// Terminate the contract.
|
||||
await pool1.TerminateAsync();
|
||||
|
||||
// Ensure the contract returned all the tokens...
|
||||
Assert.Equal(0, await token.BalanceOfAsync(pool1.ContractAddress));
|
||||
Assert.Equal(100.Algo(), await token.BalanceOfAsync(coreTeamAccount.Address));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,7 +200,7 @@ The following commands are supported for the `AlgoPool` contract:
|
||||
`deploy-algopool <poolType> <tokenAddress> [-n <contract_name>]`
|
||||
|
||||
Creates a new instance of the `AlgoPool` contract.
|
||||
* `poolType`: the type of pool (uint8: 0 = PoolType, 1 = ReferralPool)
|
||||
* `poolType`: the type of pool (uint8: 0 = MinerPool, 1 = ReferralPool)
|
||||
* `tokenAddress`: the address of the AlgoToken contract
|
||||
|
||||
>Example: `deploy-algopool 0 token -n dev_pool`
|
||||
@@ -214,6 +214,14 @@ Transfer tokens from the AlgoPool balance to the AlgoMiner balance. The amount o
|
||||
|
||||
>Example: `dev_pool.algopool-trasfertominer miner_1`
|
||||
|
||||
#### algopool-terminate
|
||||
|
||||
`<contract>.algopool-terminate`
|
||||
|
||||
Terminates the contract and return its balance to the creator.
|
||||
|
||||
>Example: `dev_pool.algopool-terminate`
|
||||
|
||||
### AlgoMiner
|
||||
|
||||
The following commands are supported for the `AlgoMiner` contract:
|
||||
@@ -314,6 +322,14 @@ This operation is executed by the system to request a payment from the AlgoMiner
|
||||
|
||||
>Example: `miner_1.algominer-mine`
|
||||
|
||||
#### algominer-terminate
|
||||
|
||||
`<contract>.algominer-terminate`
|
||||
|
||||
Terminates the contract and return its balance to the creator.
|
||||
|
||||
>Example: `miner_1.algominer-terminate`
|
||||
|
||||
#### algominer-addsystem
|
||||
|
||||
`<contract>.algominer-addsystem <account>`
|
||||
@@ -341,6 +357,61 @@ Adds the specified account to the "Supervisor" role.
|
||||
|
||||
>Example: `miner_1.algominer-addsupervisor 0x862f8938949e4A1aA82Cd427d87E4fc76940e7a1`
|
||||
|
||||
### AlgoFees
|
||||
|
||||
The following commands are supported for the `AlgoFees` contract:
|
||||
|
||||
#### deploy-algofees
|
||||
|
||||
`deploy-algofees <tokenAddress> [-n <contract_name>]`
|
||||
|
||||
Creates a new instance of the `AlgoFees` contract.
|
||||
* `tokenAddress`: the address of the AlgoToken contract
|
||||
|
||||
>Example: `deploy-algofees token -n fees1`
|
||||
|
||||
#### algofees-registerminer
|
||||
|
||||
`<contract>.algofees-registerminer <minerAddress>`
|
||||
|
||||
Registers a miner with the AlgoFees.
|
||||
* `minerAddress`: the address of the AlgoMiner contract
|
||||
|
||||
>Example: `fees1.algofees-registerminer miner_0`
|
||||
|
||||
#### algofees-unregisterminer
|
||||
|
||||
`<contract>.algofees-unregisterminer <minerAddress>`
|
||||
|
||||
Unregisters a miner from the AlgoFees.
|
||||
* `minerAddress`: the address of the AlgoMiner contract
|
||||
|
||||
>Example: `fees1.algofees-unregisterminer miner_0`
|
||||
|
||||
#### algofees-mine
|
||||
|
||||
`<contract>.algofees-mine`
|
||||
|
||||
This operation is executed by the system to request a payment from the AlgoFees to registered miners. The amount to pay is computed using the rules specified in the "Smart Contracts Requirements / Specifications" document.
|
||||
|
||||
>Example: `fees1.algofees-mine`
|
||||
|
||||
#### algominer-terminate
|
||||
|
||||
`<contract>.algofees-terminate`
|
||||
|
||||
Terminates the contract and return its balance to the creator.
|
||||
|
||||
>Example: `algofees.algofees-terminate`
|
||||
|
||||
### System commands
|
||||
|
||||
#### reset
|
||||
|
||||
Resets the current playground instance, removing all aliases created.
|
||||
|
||||
>Example: `reset`
|
||||
|
||||
### Notes
|
||||
|
||||
* Reserved chars: the following chars are reserved chars and cannot be used in identifiers or strings not enclosed in quotes: "space" ":" "/" "-" "." ","
|
||||
|
||||
@@ -24,22 +24,6 @@ deploy-algominer 1 2 miner_2_account ref_2_account token -n miner_2
|
||||
deploy-algominer 1 3 miner_3_account ref_3_account token -n miner_3
|
||||
deploy-algominer 1 4 miner_4_account ref_4_account token -n miner_4
|
||||
deploy-algominer 1 5 miner_5_account ref_5_account token -n miner_5
|
||||
deploy-algopool 0 token -n dev_pool
|
||||
deploy-algopool 1 token -n ref_pool
|
||||
token.algotoken-transfer dev_pool 100m
|
||||
token.algotoken-transfer ref_pool 100m
|
||||
dev_pool.algopool-trasfertominer miner_0
|
||||
ref_pool.algopool-trasfertominer miner_0
|
||||
dev_pool.algopool-trasfertominer miner_1
|
||||
ref_pool.algopool-trasfertominer miner_1
|
||||
dev_pool.algopool-trasfertominer miner_2
|
||||
ref_pool.algopool-trasfertominer miner_2
|
||||
dev_pool.algopool-trasfertominer miner_3
|
||||
ref_pool.algopool-trasfertominer miner_3
|
||||
dev_pool.algopool-trasfertominer miner_4
|
||||
ref_pool.algopool-trasfertominer miner_4
|
||||
dev_pool.algopool-trasfertominer miner_5
|
||||
ref_pool.algopool-trasfertominer miner_5
|
||||
miner_0.algominer-activateminer
|
||||
miner_1.algominer-activateminer
|
||||
miner_2.algominer-activateminer
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AdvancedAlgos.AlgoToken.AlgoTokenDistribution;
|
||||
using AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Commands.ContractManagement;
|
||||
using AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Runtime;
|
||||
using Nethereum.RPC.Eth.DTOs;
|
||||
using Nethereum.Web3;
|
||||
|
||||
namespace AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Commands.AlgoFeesContract
|
||||
{
|
||||
public class AlgoFeesTerminateCommand : EthInvokeTransactionalFunctionCommand
|
||||
{
|
||||
protected override async Task<TransactionReceipt> ExecuteAsync(RuntimeContext context, string contractAddress, Web3 web3)
|
||||
{
|
||||
var algoFees = new AlgoFees(contractAddress, web3, context.GasPriceProvider);
|
||||
|
||||
return await algoFees.TerminateAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AdvancedAlgos.AlgoToken.AlgoTokenDistribution;
|
||||
using AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Commands.ContractManagement;
|
||||
using AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Runtime;
|
||||
using Nethereum.RPC.Eth.DTOs;
|
||||
using Nethereum.Web3;
|
||||
|
||||
namespace AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Commands.AlgoMinerContract
|
||||
{
|
||||
public class AlgoMinerTerminateCommand : EthInvokeTransactionalFunctionCommand
|
||||
{
|
||||
protected override async Task<TransactionReceipt> ExecuteAsync(RuntimeContext context, string contractAddress, Web3 web3)
|
||||
{
|
||||
var algoMiner = new AlgoMiner(contractAddress, web3, context.GasPriceProvider);
|
||||
|
||||
return await algoMiner.TerminateAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AdvancedAlgos.AlgoToken.AlgoTokenDistribution;
|
||||
using AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Commands.ContractManagement;
|
||||
using AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Runtime;
|
||||
using Nethereum.RPC.Eth.DTOs;
|
||||
using Nethereum.Web3;
|
||||
|
||||
namespace AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Commands.AlgoPoolContract
|
||||
{
|
||||
public class AlgoPoolTerminateCommand : EthInvokeTransactionalFunctionCommand
|
||||
{
|
||||
protected override async Task<TransactionReceipt> ExecuteAsync(RuntimeContext context, string contractAddress, Web3 web3)
|
||||
{
|
||||
var algoPool = new AlgoPool(contractAddress, web3, context.GasPriceProvider);
|
||||
|
||||
return await algoPool.TerminateAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ using AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Runtime;
|
||||
using AdvancedAlgos.AlgoToken.Framework.Ethereum;
|
||||
using Nethereum.Util;
|
||||
|
||||
namespace AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Commands.EthNetwork
|
||||
namespace AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Commands.System
|
||||
{
|
||||
public class ListEnvironmentCommand : ICommand
|
||||
{
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Runtime;
|
||||
using AdvancedAlgos.AlgoToken.Framework.Ethereum;
|
||||
using Nethereum.Util;
|
||||
|
||||
namespace AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Commands.System
|
||||
{
|
||||
public class ResetCommand : ICommand
|
||||
{
|
||||
public Task ExecuteAsync(RuntimeContext context)
|
||||
{
|
||||
context.Reset();
|
||||
|
||||
Console.WriteLine("Done.");
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -40,6 +40,12 @@ namespace AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Parsers
|
||||
{
|
||||
ContractReference = contractReference
|
||||
}).Register();
|
||||
|
||||
(from contractReference in CommonParsers.Invoke("algofees-terminate")
|
||||
select new AlgoFeesTerminateCommand
|
||||
{
|
||||
ContractReference = contractReference
|
||||
}).Register();
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -93,6 +93,12 @@ namespace AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Parsers
|
||||
ContractReference = contractReference,
|
||||
}).Register();
|
||||
|
||||
(from contractReference in CommonParsers.Invoke("algominer-terminate")
|
||||
select new AlgoMinerTerminateCommand
|
||||
{
|
||||
ContractReference = contractReference
|
||||
}).Register();
|
||||
|
||||
(from contractReference in CommonParsers.Invoke("algominer-addsystem")
|
||||
from account in CommonParsers.StringValue
|
||||
select new AlgoMinerAddSystemCommand
|
||||
|
||||
+6
@@ -28,6 +28,12 @@ namespace AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Parsers
|
||||
ContractReference = contractReference,
|
||||
MinerAddress = minerAddress
|
||||
}).Register();
|
||||
|
||||
(from contractReference in CommonParsers.Invoke("algopool-terminate")
|
||||
select new AlgoPoolTerminateCommand
|
||||
{
|
||||
ContractReference = contractReference
|
||||
}).Register();
|
||||
}
|
||||
}
|
||||
}
|
||||
-4
@@ -23,10 +23,6 @@ namespace AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Parsers
|
||||
{
|
||||
GasPrice = gasPrice
|
||||
}).Register();
|
||||
|
||||
(from command in CommonParsers.Token("list-env")
|
||||
select new ListEnvironmentCommand()
|
||||
).Register();
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Commands.System;
|
||||
using Sprache;
|
||||
|
||||
namespace AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Parsers
|
||||
{
|
||||
public static class SystemParsers
|
||||
{
|
||||
public static void Register()
|
||||
{
|
||||
(from command in CommonParsers.Token("reset")
|
||||
select new ResetCommand()
|
||||
).Register();
|
||||
|
||||
(from command in CommonParsers.Token("list-env")
|
||||
select new ListEnvironmentCommand()
|
||||
).Register();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ namespace AdvancedAlgos.AlgoToken.AlgoTokenPlayground
|
||||
|
||||
static REPL()
|
||||
{
|
||||
SystemParsers.Register();
|
||||
EthNetworkParsers.Register();
|
||||
EthTransactionsParsers.Register();
|
||||
AccountManagementParsers.Register();
|
||||
|
||||
+8
-2
@@ -12,10 +12,16 @@ namespace AdvancedAlgos.AlgoToken.AlgoTokenPlayground.Runtime
|
||||
|
||||
public string EthNetworkUrl { get; set; } = LOCAL_NETWORK_URL;
|
||||
public EthAccountDescriptor CurrentAccount { get; set; }
|
||||
public Dictionary<string, EthAccountDescriptor> Accounts { get; } = new Dictionary<string, EthAccountDescriptor>(StringComparer.OrdinalIgnoreCase);
|
||||
public Dictionary<string, EthContractDescriptor> Contracts { get; } = new Dictionary<string, EthContractDescriptor>(StringComparer.OrdinalIgnoreCase);
|
||||
public Dictionary<string, EthAccountDescriptor> Accounts { get; private set; } = new Dictionary<string, EthAccountDescriptor>(StringComparer.OrdinalIgnoreCase);
|
||||
public Dictionary<string, EthContractDescriptor> Contracts { get; private set; } = new Dictionary<string, EthContractDescriptor>(StringComparer.OrdinalIgnoreCase);
|
||||
public StaticGasPriceProvider GasPriceProvider { get; } = new StaticGasPriceProvider();
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
Accounts = new Dictionary<string, EthAccountDescriptor>(StringComparer.OrdinalIgnoreCase);
|
||||
Contracts = new Dictionary<string, EthContractDescriptor>(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public string ResolveAccountReference(string reference)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(reference) || string.Equals(reference, "0x0", StringComparison.OrdinalIgnoreCase)) return "0x0";
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
new-account -n miner_1_account
|
||||
new-account -n ref_1_account
|
||||
import-account 0936af475d2701538aad321f87e0a51f2b297634653393e8cab7290a674009a5 -n prefunded
|
||||
|
||||
deploy-algotoken -n token
|
||||
|
||||
token.algotoken-balanceof prefunded
|
||||
deploy-algopool 0 token -n dev_pool
|
||||
token.algotoken-transfer dev_pool 100m
|
||||
token.algotoken-balanceof dev_pool
|
||||
dev_pool.algopool-terminate
|
||||
token.algotoken-balanceof dev_pool
|
||||
token.algotoken-balanceof prefunded
|
||||
|
||||
token.algotoken-balanceof prefunded
|
||||
deploy-algofees token -n fees1
|
||||
token.algotoken-transfer fees1 100m
|
||||
token.algotoken-balanceof fees1
|
||||
fees1.algofees-terminate
|
||||
token.algotoken-balanceof fees1
|
||||
token.algotoken-balanceof prefunded
|
||||
|
||||
token.algotoken-balanceof prefunded
|
||||
deploy-algominer 0 2 miner_1_account ref_1_account token -n miner_1
|
||||
token.algotoken-transfer miner_1 100m
|
||||
token.algotoken-balanceof miner_1
|
||||
miner_1.algominer-terminate
|
||||
token.algotoken-balanceof miner_1
|
||||
token.algotoken-balanceof prefunded
|
||||
Reference in new issue
Block a user