Guest User

Untitled

a guest
Jul 16th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.87 KB | None | 0 0
  1. pragma solidity 0.4.24;
  2.  
  3. contract AM {
  4. using SafeMath for uint256;
  5.  
  6. struct StateStruct {
  7.  
  8. mapping(bytes32 => bytes32) subSt;
  9. }
  10.  
  11. struct AStruct {
  12. StateStruct st;
  13. address owner;
  14. bool isAs;
  15. bytes32 rev;
  16. bytes32 act;
  17. bytes32 pl;
  18. bytes32 actSt;
  19. bytes32 asSte;
  20. bool isOw;
  21. }
  22.  
  23. mapping(uint256 => AStruct) asStr;
  24. uint256[] public aList;
  25.  
  26. uint256 public _public_id = 0;
  27.  
  28. mapping(address => uint) public balance;
  29. mapping(uint256 => mapping (address => mapping(address => bool))) public isPDM;
  30. mapping(uint256 => mapping (address => bool)) public isPDU;
  31.  
  32.  
  33. event LNAF(address sender, uint256 indexed _id, bytes32 subStsTypes, bytes32 subSatesValues, address owner, bytes32 _asSte);
  34.  
  35.  
  36. event LNAFPay(address sender, uint256 indexed _id, bytes32 subStsTypes, bytes32 subSatesValues, address owner, bytes32 _asSte, uint256 _token);
  37.  
  38.  
  39. event LCASF(address sender, uint256 indexed _id, bytes32 subStsTypes, bytes32 subSatesValues, bytes32 _asSte);
  40.  
  41.  
  42. event LNANF(address sender, uint256 indexed _id, bytes32 _rev, address _owner);
  43.  
  44.  
  45. event LNANFPay(address sender, uint256 indexed _id, bytes32 _rev, address _owner, uint256 _token);
  46.  
  47.  
  48. event LCASNF(address sender, uint256 indexed _id, bytes32 _rev);
  49.  
  50.  
  51. event LNAOA(uint256 indexed _id, bytes32 _act, bytes32 _pl, bytes32 _actSt, address _owner);
  52.  
  53.  
  54. event LNAOAPay(uint256 indexed _id, bytes32 _act, bytes32 _pl, bytes32 _actSt, address _owner, uint256 _token);
  55.  
  56.  
  57. event LCASOA(address sender, uint256 indexed _public_id, bytes32 _act, bytes32 _pl, bytes32 _actSt);
  58.  
  59.  
  60. event LCAO(address sender, uint256 indexed _id, address newOwner);
  61.  
  62.  
  63. event LCASFPay(address sender, uint256 indexed _id, bytes32 subStsTypes, bytes32 subSatesValues, bytes32 _asSte, uint256 _token);
  64.  
  65.  
  66. event LCASNFPay(address sender, uint256 indexed _id, bytes32 _rev, uint256 _token);
  67.  
  68.  
  69. function isAs(uint256 _id) public view returns(bool isIndeed) {
  70. return asStr[_id].isAs;
  71. }
  72.  
  73. function isOw(uint256 _id, address _pl) public view returns(bool isIndeed) {
  74. if(asStr[_id].owner == _pl)
  75. return true;
  76. else
  77. return false;
  78. }
  79.  
  80. function plPM(uint256 _id, address _pl, uint256 _token) public returns(bool isIndeed) {
  81.  
  82. require(_token > balance[_pl]);
  83.  
  84. address _owner;
  85.  
  86. _owner = asStr[_id].owner;
  87.  
  88. balance[_owner] = balance[_owner].add(_token);
  89.  
  90. balance[_pl] = balance[_pl].sub(_token);
  91.  
  92. isPDM[_id][_pl][_owner] = true;
  93.  
  94. return true;
  95. }
  96.  
  97. function plPU(uint256 _id, address _pl, uint256 _token) public returns(bool isIndeed) {
  98.  
  99. balance[_pl] = balance[_pl].sub(_token);
  100.  
  101. isPDU[_id][_pl] = true;
  102.  
  103. return true;
  104. }
  105.  
  106. function updateBalance(address _pl, uint256 newBalance) public {
  107. balance[_pl] = newBalance;
  108. }
  109.  
  110. function getAC() public view returns(uint count) {
  111. return aList.length;
  112. }
  113.  
  114. function newAFMID(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, address _owner, bytes32 _asSte) public returns(bool success) {
  115. require(!isAs(_id));
  116.  
  117. uint256 counter=0;
  118. for(counter; counter < numberOfSubStates; counter++) {
  119.  
  120. asStr[_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];
  121.  
  122. emit LNAF(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), address(_owner), bytes32(_asSte));
  123.  
  124. }
  125.  
  126. asStr[_id].owner = _owner;
  127. asStr[_id].isAs = true;
  128. asStr[_id].asSte = _asSte;
  129.  
  130. aList.push(_id);
  131.  
  132. return true;
  133. }
  134.  
  135. function newAFMIDpayU(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
  136. require(!isAs(_id));
  137.  
  138. plPU(_id, msg.sender, _token);
  139.  
  140. require(isPDU[_id][msg.sender]);
  141.  
  142. uint256 counter=0;
  143. for(counter; counter < numberOfSubStates; counter++) {
  144.  
  145. asStr[_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];
  146.  
  147. emit LNAFPay(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), address(_owner), bytes32(_asSte), uint256(_token));
  148.  
  149. }
  150.  
  151. asStr[_id].owner = _owner;
  152. asStr[_id].isAs = true;
  153. asStr[_id].asSte = _asSte;
  154.  
  155. aList.push(_id);
  156.  
  157. return true;
  158. }
  159.  
  160. function newAFMIDonlyLog(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, address _owner, bytes32 _asSte) public returns(bool success) {
  161. require(!isAs(_id));
  162.  
  163. uint256 counter=0;
  164. for(counter; counter < numberOfSubStates; counter++) {
  165.  
  166. emit LNAF(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), address(_owner), bytes32(_asSte));
  167.  
  168. }
  169.  
  170. asStr[_id].owner = _owner;
  171. asStr[_id].isAs = true;
  172. asStr[_id].asSte = _asSte;
  173.  
  174. aList.push(_id);
  175.  
  176. return true;
  177. }
  178.  
  179. function newAFMIDonlyLogPayU(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
  180. require(!isAs(_id));
  181.  
  182. plPU(_id, msg.sender, _token);
  183.  
  184. require(isPDU[_id][msg.sender]);
  185.  
  186. uint256 counter=0;
  187. for(counter; counter < numberOfSubStates; counter++) {
  188.  
  189. emit LNAFPay(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), address(_owner), bytes32(_asSte), uint256(_token));
  190.  
  191. }
  192.  
  193. asStr[_id].owner = _owner;
  194. asStr[_id].isAs = true;
  195. asStr[_id].asSte = _asSte;
  196.  
  197. aList.push(_id);
  198.  
  199. return true;
  200. }
  201.  
  202. function newAssetFieldAutoID(uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, address _owner, bytes32 _asSte) public returns(bool success) {
  203. require(!isAs(_public_id));
  204.  
  205. uint256 counter=0;
  206. for(counter; counter < numberOfSubStates; counter++) {
  207.  
  208. asStr[_public_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];
  209.  
  210. emit LNAF(address(msg.sender), uint256(_public_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), address(_owner), bytes32(_asSte));
  211.  
  212. }
  213.  
  214. asStr[_public_id].owner = _owner;
  215. asStr[_public_id].isAs = true;
  216. asStr[_public_id].asSte = _asSte;
  217.  
  218. aList.push(_public_id);
  219.  
  220. _public_id = _public_id + 1;
  221.  
  222. return true;
  223. }
  224.  
  225. function newAFAIDpayU(uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
  226. require(!isAs(_public_id));
  227.  
  228. plPU(_public_id, msg.sender, _token);
  229.  
  230. require(isPDU[_public_id][msg.sender]);
  231.  
  232. uint256 counter=0;
  233. for(counter; counter < numberOfSubStates; counter++) {
  234.  
  235. asStr[_public_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];
  236.  
  237. emit LNAFPay(address(msg.sender), uint256(_public_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), address(_owner), bytes32(_asSte), uint256(_token));
  238.  
  239. }
  240.  
  241. asStr[_public_id].owner = _owner;
  242. asStr[_public_id].isAs = true;
  243. asStr[_public_id].asSte = _asSte;
  244.  
  245. aList.push(_public_id);
  246.  
  247. _public_id = _public_id + 1;
  248.  
  249. return true;
  250. }
  251.  
  252. function newAssetFieldAutoIDonlyLog(uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, address _owner, bytes32 _asSte) public returns(bool success) {
  253. require(!isAs(_public_id));
  254.  
  255. uint256 counter=0;
  256. for(counter; counter < numberOfSubStates; counter++) {
  257.  
  258. emit LNAF(address(msg.sender), uint256(_public_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), address(_owner), bytes32(_asSte));
  259.  
  260. }
  261.  
  262. asStr[_public_id].owner = _owner;
  263. asStr[_public_id].isAs = true;
  264. asStr[_public_id].asSte = _asSte;
  265.  
  266. aList.push(_public_id);
  267.  
  268. _public_id = _public_id + 1;
  269.  
  270. return true;
  271. }
  272.  
  273. function newAFieldAutoIDonlyLogPayU(uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
  274. require(!isAs(_public_id));
  275.  
  276. plPU(_public_id, msg.sender, _token);
  277.  
  278. require(isPDU[_public_id][msg.sender]);
  279.  
  280. uint256 counter=0;
  281. for(counter; counter < numberOfSubStates; counter++) {
  282.  
  283. emit LNAFPay(address(msg.sender), uint256(_public_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), address(_owner), bytes32(_asSte), uint256(_token));
  284.  
  285. }
  286.  
  287. asStr[_public_id].owner = _owner;
  288. asStr[_public_id].isAs = true;
  289. asStr[_public_id].asSte = _asSte;
  290.  
  291. aList.push(_public_id);
  292.  
  293. _public_id = _public_id + 1;
  294.  
  295. return true;
  296. }
  297.  
  298. function newANoFMID(uint256 _id, bytes32 _rev, address _owner, bytes32 _asSte) public returns(bool success) {
  299. require(!isAs(_id));
  300.  
  301. asStr[_id].owner = _owner;
  302. asStr[_id].isAs = true;
  303. asStr[_id].asSte = _asSte;
  304.  
  305. asStr[_id].rev = _rev;
  306.  
  307. emit LNANF(address(msg.sender), uint256(_id), bytes32(_rev), address(_owner));
  308.  
  309. aList.push(_id);
  310.  
  311. return true;
  312. }
  313.  
  314. function newANoFMIDpayU(uint256 _id, bytes32 _rev, address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
  315. require(!isAs(_id));
  316.  
  317. plPU(_id, msg.sender, _token);
  318.  
  319. require(isPDU[_id][msg.sender]);
  320.  
  321. asStr[_id].owner = _owner;
  322. asStr[_id].isAs = true;
  323. asStr[_id].asSte = _asSte;
  324.  
  325. asStr[_id].rev = _rev;
  326.  
  327. emit LNANFPay(address(msg.sender), uint256(_id), bytes32(_rev), address(_owner), uint256(_token));
  328.  
  329. aList.push(_id);
  330.  
  331. return true;
  332. }
  333.  
  334. function newANoFMIDonlyLog(uint256 _id, bytes32 _rev, address _owner, bytes32 _asSte) public returns(bool success) {
  335. require(!isAs(_id));
  336.  
  337. asStr[_id].owner = _owner;
  338. asStr[_id].isAs = true;
  339. asStr[_id].asSte = _asSte;
  340.  
  341. emit LNANF(address(msg.sender), uint256(_id), bytes32(_rev), address(_owner));
  342.  
  343. aList.push(_id);
  344.  
  345. return true;
  346. }
  347.  
  348. function newANoFMIDonlyLogPayU(uint256 _id, bytes32 _rev, address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
  349. require(!isAs(_id));
  350.  
  351. plPU(_id, msg.sender, _token);
  352.  
  353. require(isPDU[_id][msg.sender]);
  354.  
  355. asStr[_id].owner = _owner;
  356. asStr[_id].isAs = true;
  357. asStr[_id].asSte = _asSte;
  358.  
  359. emit LNANFPay(address(msg.sender), uint256(_id), bytes32(_rev), address(_owner), uint256(_token));
  360.  
  361. aList.push(_id);
  362.  
  363. return true;
  364. }
  365.  
  366. function newAssetNoFieldAutoID(bytes32 _rev, address _owner, bytes32 _asSte) public returns(bool success) {
  367. require(isAs(_public_id));
  368.  
  369. asStr[_public_id].owner = _owner;
  370. asStr[_public_id].isAs = true;
  371. asStr[_public_id].asSte = _asSte;
  372.  
  373. asStr[_public_id].rev = _rev;
  374.  
  375. emit LNANF(address(msg.sender), uint256(_public_id), bytes32(_rev), address(_owner));
  376.  
  377. aList.push(_public_id);
  378.  
  379. _public_id = _public_id + 1;
  380.  
  381. return true;
  382. }
  383.  
  384. function newANoFieldAutoIDpayUni(bytes32 _rev, address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
  385. require(isAs(_public_id));
  386.  
  387. plPU(_public_id, msg.sender, _token);
  388.  
  389. require(isPDU[_public_id][msg.sender]);
  390.  
  391. asStr[_public_id].owner = _owner;
  392. asStr[_public_id].isAs = true;
  393. asStr[_public_id].asSte = _asSte;
  394.  
  395. asStr[_public_id].rev = _rev;
  396.  
  397. emit LNANFPay(address(msg.sender), uint256(_public_id), bytes32(_rev), address(_owner), uint256(_token));
  398.  
  399. aList.push(_public_id);
  400.  
  401. _public_id = _public_id + 1;
  402.  
  403. return true;
  404. }
  405.  
  406. function newANoFieldAutoIDonlyLog(bytes32 _rev, address _owner, bytes32 _asSte) public returns(bool success) {
  407. require(isAs(_public_id));
  408.  
  409. asStr[_public_id].owner = _owner;
  410. asStr[_public_id].isAs = true;
  411. asStr[_public_id].asSte = _asSte;
  412.  
  413. emit LNANF(address(msg.sender), uint256(_public_id), bytes32(_rev), address(_owner));
  414.  
  415. aList.push(_public_id);
  416.  
  417. _public_id = _public_id + 1;
  418.  
  419. return true;
  420. }
  421.  
  422. function newANoFieldAutoIDonlyLogPayU(bytes32 _rev, address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
  423. require(isAs(_public_id));
  424.  
  425. plPU(_public_id, msg.sender, _token);
  426.  
  427. require(isPDU[_public_id][msg.sender]);
  428.  
  429. asStr[_public_id].owner = _owner;
  430. asStr[_public_id].isAs = true;
  431. asStr[_public_id].asSte = _asSte;
  432.  
  433. emit LNANFPay(address(msg.sender), uint256(_public_id), bytes32(_rev), address(_owner), uint256(_token));
  434.  
  435. aList.push(_public_id);
  436.  
  437. _public_id = _public_id + 1;
  438.  
  439. return true;
  440. }
  441.  
  442. function newAOneActManID(uint256 _id, bytes32 _act, bytes32 _pl, bytes32 _actSt, address _owner, bytes32 _asSte) public returns(bool success) {
  443. require(!isAs(_id));
  444.  
  445. asStr[_id].owner = _owner;
  446. asStr[_id].isAs = true;
  447. asStr[_id].asSte = _asSte;
  448.  
  449. asStr[_id].act = _act;
  450. asStr[_id].pl = _pl;
  451. asStr[_id].actSt = _actSt;
  452.  
  453. aList.push(_id);
  454.  
  455. emit LNAOA(uint256(_id), bytes32(_act), bytes32(_pl), bytes32(_actSt), address(_owner));
  456.  
  457. return true;
  458. }
  459.  
  460. function newAOneActManIDpayU(uint256 _id, bytes32 _act, bytes32 _pl, bytes32 _actSt, address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
  461. require(!isAs(_id));
  462.  
  463. plPU(_id, msg.sender, _token);
  464.  
  465. require(isPDU[_id][msg.sender]);
  466.  
  467. asStr[_id].owner = _owner;
  468. asStr[_id].isAs = true;
  469. asStr[_id].asSte = _asSte;
  470.  
  471. asStr[_id].act = _act;
  472. asStr[_id].pl = _pl;
  473. asStr[_id].actSt = _actSt;
  474.  
  475. aList.push(_id);
  476.  
  477. emit LNAOAPay(uint256(_id), bytes32(_act), bytes32(_pl), bytes32(_actSt), address(_owner), uint256(_token));
  478.  
  479. return true;
  480. }
  481.  
  482. function newAOneActionAID(bytes32 _act, bytes32 _pl, bytes32 _actSt, address _owner, bytes32 _asSte) public returns(bool success) {
  483. require(!isAs(_public_id));
  484.  
  485. asStr[_public_id].owner = _owner;
  486. asStr[_public_id].isAs = true;
  487. asStr[_public_id].asSte = _asSte;
  488.  
  489. asStr[_public_id].act = _act;
  490. asStr[_public_id].pl = _pl;
  491. asStr[_public_id].actSt = _actSt;
  492.  
  493.  
  494. aList.push(_public_id);
  495.  
  496. emit LNAOA(uint256(_public_id), bytes32(_act), bytes32(_pl), bytes32(_actSt), address(_owner));
  497.  
  498. _public_id = _public_id + 1;
  499.  
  500. return true;
  501. }
  502.  
  503. function newAOneActAIDpayUnil(bytes32 _act, bytes32 _pl, bytes32 _actSt, address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
  504. require(!isAs(_public_id));
  505.  
  506. plPU(_public_id, msg.sender, _token);
  507.  
  508. require(isPDU[_public_id][msg.sender]);
  509.  
  510. asStr[_public_id].owner = _owner;
  511. asStr[_public_id].isAs = true;
  512. asStr[_public_id].asSte = _asSte;
  513.  
  514. asStr[_public_id].act = _act;
  515. asStr[_public_id].pl = _pl;
  516. asStr[_public_id].actSt = _actSt;
  517.  
  518.  
  519. aList.push(_public_id);
  520.  
  521. emit LNAOAPay(uint256(_public_id), bytes32(_act), bytes32(_pl), bytes32(_actSt), address(_owner), uint256(_token));
  522.  
  523. _public_id = _public_id + 1;
  524.  
  525. return true;
  526. }
  527.  
  528. function changeASField(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte) public returns(bool success) {
  529. require(isAs(_id));
  530.  
  531. uint256 counter=0;
  532. for(counter; counter < numberOfSubStates; counter++) {
  533.  
  534. asStr[_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];
  535.  
  536. emit LCASF(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte));
  537.  
  538. }
  539.  
  540. return true;
  541. }
  542.  
  543. function changeASFPer(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte) public returns(bool success) {
  544. require(isAs(_id));
  545. require(isOw(_id, msg.sender));
  546.  
  547. uint256 counter=0;
  548. for(counter; counter < numberOfSubStates; counter++) {
  549.  
  550. asStr[_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];
  551.  
  552. emit LCASF(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte));
  553.  
  554. }
  555.  
  556. return true;
  557. }
  558.  
  559. function changeASFieldOnlyL(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte) public returns(bool success) {
  560. require(isAs(_id));
  561.  
  562. uint256 counter=0;
  563. for(counter; counter < numberOfSubStates; counter++) {
  564.  
  565. emit LCASF(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte));
  566.  
  567. }
  568.  
  569. return true;
  570. }
  571.  
  572. function changeASFieldOnlyLPer(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte) public returns(bool success) {
  573. require(isAs(_id));
  574. require(isOw(_id, msg.sender));
  575.  
  576. uint256 counter=0;
  577. for(counter; counter < numberOfSubStates; counter++) {
  578.  
  579. emit LCASF(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte));
  580.  
  581. }
  582.  
  583. return true;
  584. }
  585.  
  586. function changeAssetStateNoF(uint256 _id, bytes32 _rev) public returns(bool success) {
  587. require(isAs(_id));
  588.  
  589. asStr[_id].rev = _rev;
  590.  
  591. emit LCASNF(address(msg.sender), uint256(_id), bytes32(_rev));
  592.  
  593. return true;
  594. }
  595.  
  596. function changeAStateNoFPer(uint256 _id, bytes32 _rev) public returns(bool success) {
  597. require(isAs(_id));
  598. require(isOw(_id, msg.sender));
  599.  
  600. asStr[_id].rev = _rev;
  601.  
  602. emit LCASNF(address(msg.sender), uint256(_id), bytes32(_rev));
  603.  
  604. return true;
  605. }
  606.  
  607. function changeAStateNoFOnlyLog(uint256 _id, bytes32 _rev) public returns(bool success) {
  608. require(isAs(_id));
  609.  
  610. emit LCASNF(address(msg.sender), uint256(_id), bytes32(_rev));
  611.  
  612. return true;
  613. }
  614.  
  615. function changeAStateNoFOnlyLogPer(uint256 _id, bytes32 _rev) public returns(bool success) {
  616. require(isAs(_id));
  617. require(isOw(_id, msg.sender));
  618.  
  619. emit LCASNF(address(msg.sender), uint256(_id), bytes32(_rev));
  620.  
  621. return true;
  622. }
  623.  
  624. function changeASFieldPayMu(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte, uint256 _token) public returns(bool success) {
  625. require(isAs(_id));
  626.  
  627. address _owner;
  628. _owner = asStr[_id].owner;
  629.  
  630. plPM(_id, msg.sender, _token);
  631.  
  632. require(isPDM[_id][msg.sender][_owner]);
  633.  
  634. uint256 counter=0;
  635. for(counter; counter < numberOfSubStates; counter++) {
  636.  
  637. asStr[_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];
  638.  
  639. emit LCASFPay(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte), uint256(_token));
  640.  
  641. }
  642.  
  643. isPDM[_id][msg.sender][_owner] = false;
  644.  
  645. return true;
  646. }
  647.  
  648. function changeASFieldPayMuPer(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte, uint256 _token) public returns(bool success) {
  649. require(isAs(_id));
  650. require(isOw(_id, msg.sender));
  651.  
  652. address _owner;
  653. _owner = asStr[_id].owner;
  654.  
  655. plPM(_id, msg.sender, _token);
  656.  
  657. require(isPDM[_id][msg.sender][_owner]);
  658.  
  659. uint256 counter=0;
  660. for(counter; counter < numberOfSubStates; counter++) {
  661.  
  662. asStr[_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];
  663.  
  664. emit LCASFPay(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte), uint256(_token));
  665.  
  666. }
  667.  
  668. isPDM[_id][msg.sender][_owner] = false;
  669.  
  670. return true;
  671. }
  672.  
  673. function changeASFieldPayUn(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte, uint256 _token) public returns(bool success) {
  674. require(isAs(_id));
  675.  
  676. plPU(_id, msg.sender, _token);
  677.  
  678. require(isPDU[_id][msg.sender]);
  679.  
  680. uint256 counter=0;
  681. for(counter; counter < numberOfSubStates; counter++) {
  682.  
  683. asStr[_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];
  684.  
  685. emit LCASFPay(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte), uint256(_token));
  686.  
  687. }
  688.  
  689. isPDU[_id][msg.sender] = false;
  690.  
  691. return true;
  692. }
  693.  
  694. function changeASFieldPayUnPer(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte, uint256 _token) public returns(bool success) {
  695. require(isAs(_id));
  696. require(isOw(_id, msg.sender));
  697.  
  698. plPU(_id, msg.sender, _token);
  699.  
  700. require(isPDU[_id][msg.sender]);
  701.  
  702. uint256 counter=0;
  703. for(counter; counter < numberOfSubStates; counter++) {
  704.  
  705. asStr[_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];
  706.  
  707. emit LCASFPay(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte), uint256(_token));
  708.  
  709. }
  710.  
  711. isPDU[_id][msg.sender] = false;
  712.  
  713. return true;
  714. }
  715.  
  716. function changeASFieldOnlyLPayMu(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte, uint256 _token) public returns(bool success) {
  717. require(isAs(_id));
  718.  
  719. address _owner;
  720. _owner = asStr[_id].owner;
  721.  
  722. plPM(_id, msg.sender, _token);
  723.  
  724. require(isPDM[_id][msg.sender][_owner]);
  725.  
  726. uint256 counter=0;
  727. for(counter; counter < numberOfSubStates; counter++) {
  728.  
  729. emit LCASFPay(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte), uint256(_token));
  730.  
  731. }
  732.  
  733. return true;
  734. }
  735.  
  736. function changeASFieldOnlyLPayMuPer(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte, uint256 _token) public returns(bool success) {
  737. require(isAs(_id));
  738. require(isOw(_id, msg.sender));
  739.  
  740. address _owner;
  741. _owner = asStr[_id].owner;
  742.  
  743. plPM(_id, msg.sender, _token);
  744.  
  745. require(isPDM[_id][msg.sender][_owner]);
  746.  
  747. uint256 counter=0;
  748. for(counter; counter < numberOfSubStates; counter++) {
  749.  
  750. emit LCASFPay(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte), uint256(_token));
  751.  
  752. }
  753.  
  754. return true;
  755. }
  756.  
  757. function changeASFieldOnlyLPayUn(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte, uint256 _token) public returns(bool success) {
  758. require(isAs(_id));
  759.  
  760. plPU(_id, msg.sender, _token);
  761.  
  762. require(isPDU[_id][msg.sender]);
  763.  
  764. uint256 counter=0;
  765. for(counter; counter < numberOfSubStates; counter++) {
  766.  
  767. emit LCASFPay(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte), uint256(_token));
  768.  
  769. }
  770.  
  771. return true;
  772. }
  773. }
  774.  
  775. /////////////////////////////////////////////////////////////////
  776.  
  777. library SafeMath {
  778.  
  779. function sub(uint256 a, uint256 b) internal pure returns (uint256) {
  780. assert(b <= a);
  781. return a - b;
  782. }
  783.  
  784. function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
  785. c = a + b;
  786. assert(c >= a);
  787. return c;
  788. }
  789. }
Add Comment
Please, Sign In to add comment