1- /*
2- This truffle script generates dummy data. It generates a history of
3- exchange rate reports and rebase events on the blockchain which are useful in
4- integration testing or bootstrapping dependent components.
5- */
1+ /**
2+ * This truffle script generates dummy data. It generates a history of
3+ * exchange rate reports and rebase events on the blockchain which are useful in
4+ * integration testing or bootstrapping dependent components.
5+ *
6+ * Example usage:
7+ * $ npm run blockchain:start gethDev
8+ * $ npm run genDummyData
9+ */
10+ const yaml = require ( 'js-yaml' ) ;
11+ const fs = require ( 'fs' ) ;
12+ const APP_ROOT_PATH = require ( 'app-root-path' ) ;
13+
614const UFragments = artifacts . require ( 'UFragments.sol' ) ;
715const UFragmentsPolicy = artifacts . require ( 'UFragmentsPolicy.sol' ) ;
8- const ProxyContract = artifacts . require ( 'ProxyContract .sol' ) ;
16+ const MarketSource = artifacts . require ( 'market-oracle/MarketSource .sol' ) ;
917
1018const Stochasm = require ( 'stochasm' ) ;
1119const BigNumber = require ( 'bignumber.js' ) ;
@@ -16,6 +24,7 @@ const chain = new BlockchainCaller(web3);
1624const network = artifacts . options . _values . network ;
1725const truffleConfig = _require ( '/truffle.js' ) ;
1826const config = truffleConfig . networks [ network ] ;
27+ const chainConfig = yaml . safeLoad ( fs . readFileSync ( `${ APP_ROOT_PATH } /migrations/deployments/${ config . ref } .yaml` ) ) ;
1928
2029async function mockData ( ) {
2130 const accounts = await chain . getUserAccounts ( ) ;
@@ -25,9 +34,9 @@ async function mockData () {
2534 from : deployer
2635 } ;
2736
28- const uFragments = await UFragments . deployed ( ) ;
29- const policy = await UFragmentsPolicy . deployed ( ) ;
30- const proxy = await ProxyContract . deployed ( ) ;
37+ const uFragments = UFragments . at ( chainConfig . UFragments ) ;
38+ const policy = UFragmentsPolicy . at ( chainConfig . UFragmentsPolicy ) ;
39+ const marketSource = await MarketSource . at ( chainConfig . MarketSource ) ;
3140 await policy . setMinRebaseTimeIntervalSec ( 1 ) ;
3241
3342 const rateGen = new Stochasm ( { mean : 1.75 , stdev : 0.5 , min : 0.5 , max : 5 , seed : 'fragments.org' } ) ;
@@ -43,18 +52,14 @@ async function mockData () {
4352 supply = await uFragments . totalSupply . call ( ) ;
4453 supply = new BigNumber ( supply ) ;
4554
46- // Mocking policy interactions with oracle and uFragments
47- await proxy . storeRate ( rate , txConfig ) ;
48- await proxy . storeSupply ( supply , txConfig ) ;
49- await proxy . storeVolume ( volume , txConfig ) ;
55+ // Report data through market oracle
56+ await marketSource . reportRate ( rate , volume , txConfig ) ;
5057
5158 // Calling policy rebase
5259 r = await policy . rebase ( txConfig ) ;
5360
54- // Calling uFragments rebase
5561 const epoch = await policy . epoch . call ( ) ;
5662 const supplyDelta = r . logs [ 0 ] . args . appliedSupplyAdjustment ;
57- await proxy . callThroughToUFRGRebase ( epoch , supplyDelta , txConfig ) ;
5863 const supply_ = await uFragments . totalSupply . call ( ) ;
5964 console . log ( `Rebase: SupplyDelta=${ supplyDelta } Supply_=${ supply_ } Epoch=${ epoch } ` ) ;
6065 await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ;
0 commit comments