web3ext.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891
  1. // Copyright 2015 The go-ethereum Authors
  2. // This file is part of the go-ethereum library.
  3. //
  4. // The go-ethereum library is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // The go-ethereum library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
  16. // package web3ext contains geth specific web3.js extensions.
  17. package web3ext
  18. var Modules = map[string]string{
  19. "accounting": AccountingJs,
  20. "admin": AdminJs,
  21. "chequebook": ChequebookJs,
  22. "clique": CliqueJs,
  23. "ethash": EthashJs,
  24. "debug": DebugJs,
  25. "eth": EthJs,
  26. "miner": MinerJs,
  27. "net": NetJs,
  28. "personal": PersonalJs,
  29. "rpc": RpcJs,
  30. "shh": ShhJs,
  31. "swarmfs": SwarmfsJs,
  32. "txpool": TxpoolJs,
  33. "les": LESJs,
  34. "lespay": LESPayJs,
  35. }
  36. const ChequebookJs = `
  37. web3._extend({
  38. property: 'chequebook',
  39. methods: [
  40. new web3._extend.Method({
  41. name: 'deposit',
  42. call: 'chequebook_deposit',
  43. params: 1,
  44. inputFormatter: [null]
  45. }),
  46. new web3._extend.Property({
  47. name: 'balance',
  48. getter: 'chequebook_balance',
  49. outputFormatter: web3._extend.utils.toDecimal
  50. }),
  51. new web3._extend.Method({
  52. name: 'cash',
  53. call: 'chequebook_cash',
  54. params: 1,
  55. inputFormatter: [null]
  56. }),
  57. new web3._extend.Method({
  58. name: 'issue',
  59. call: 'chequebook_issue',
  60. params: 2,
  61. inputFormatter: [null, null]
  62. }),
  63. ]
  64. });
  65. `
  66. const CliqueJs = `
  67. web3._extend({
  68. property: 'clique',
  69. methods: [
  70. new web3._extend.Method({
  71. name: 'getSnapshot',
  72. call: 'clique_getSnapshot',
  73. params: 1,
  74. inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter]
  75. }),
  76. new web3._extend.Method({
  77. name: 'getSnapshotAtHash',
  78. call: 'clique_getSnapshotAtHash',
  79. params: 1
  80. }),
  81. new web3._extend.Method({
  82. name: 'getSigners',
  83. call: 'clique_getSigners',
  84. params: 1,
  85. inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter]
  86. }),
  87. new web3._extend.Method({
  88. name: 'getSignersAtHash',
  89. call: 'clique_getSignersAtHash',
  90. params: 1
  91. }),
  92. new web3._extend.Method({
  93. name: 'propose',
  94. call: 'clique_propose',
  95. params: 2
  96. }),
  97. new web3._extend.Method({
  98. name: 'discard',
  99. call: 'clique_discard',
  100. params: 1
  101. }),
  102. new web3._extend.Method({
  103. name: 'status',
  104. call: 'clique_status',
  105. params: 0
  106. }),
  107. ],
  108. properties: [
  109. new web3._extend.Property({
  110. name: 'proposals',
  111. getter: 'clique_proposals'
  112. }),
  113. ]
  114. });
  115. `
  116. const EthashJs = `
  117. web3._extend({
  118. property: 'ethash',
  119. methods: [
  120. new web3._extend.Method({
  121. name: 'getWork',
  122. call: 'ethash_getWork',
  123. params: 0
  124. }),
  125. new web3._extend.Method({
  126. name: 'getHashrate',
  127. call: 'ethash_getHashrate',
  128. params: 0
  129. }),
  130. new web3._extend.Method({
  131. name: 'submitWork',
  132. call: 'ethash_submitWork',
  133. params: 3,
  134. }),
  135. new web3._extend.Method({
  136. name: 'submitHashRate',
  137. call: 'ethash_submitHashRate',
  138. params: 2,
  139. }),
  140. ]
  141. });
  142. `
  143. const AdminJs = `
  144. web3._extend({
  145. property: 'admin',
  146. methods: [
  147. new web3._extend.Method({
  148. name: 'addPeer',
  149. call: 'admin_addPeer',
  150. params: 1
  151. }),
  152. new web3._extend.Method({
  153. name: 'removePeer',
  154. call: 'admin_removePeer',
  155. params: 1
  156. }),
  157. new web3._extend.Method({
  158. name: 'addTrustedPeer',
  159. call: 'admin_addTrustedPeer',
  160. params: 1
  161. }),
  162. new web3._extend.Method({
  163. name: 'removeTrustedPeer',
  164. call: 'admin_removeTrustedPeer',
  165. params: 1
  166. }),
  167. new web3._extend.Method({
  168. name: 'exportChain',
  169. call: 'admin_exportChain',
  170. params: 3,
  171. inputFormatter: [null, null, null]
  172. }),
  173. new web3._extend.Method({
  174. name: 'importChain',
  175. call: 'admin_importChain',
  176. params: 1
  177. }),
  178. new web3._extend.Method({
  179. name: 'sleepBlocks',
  180. call: 'admin_sleepBlocks',
  181. params: 2
  182. }),
  183. new web3._extend.Method({
  184. name: 'startRPC',
  185. call: 'admin_startRPC',
  186. params: 4,
  187. inputFormatter: [null, null, null, null]
  188. }),
  189. new web3._extend.Method({
  190. name: 'stopRPC',
  191. call: 'admin_stopRPC'
  192. }),
  193. new web3._extend.Method({
  194. name: 'startWS',
  195. call: 'admin_startWS',
  196. params: 4,
  197. inputFormatter: [null, null, null, null]
  198. }),
  199. new web3._extend.Method({
  200. name: 'stopWS',
  201. call: 'admin_stopWS'
  202. }),
  203. ],
  204. properties: [
  205. new web3._extend.Property({
  206. name: 'nodeInfo',
  207. getter: 'admin_nodeInfo'
  208. }),
  209. new web3._extend.Property({
  210. name: 'peers',
  211. getter: 'admin_peers'
  212. }),
  213. new web3._extend.Property({
  214. name: 'datadir',
  215. getter: 'admin_datadir'
  216. }),
  217. ]
  218. });
  219. `
  220. const DebugJs = `
  221. web3._extend({
  222. property: 'debug',
  223. methods: [
  224. new web3._extend.Method({
  225. name: 'accountRange',
  226. call: 'debug_accountRange',
  227. params: 6,
  228. inputFormatter: [web3._extend.formatters.inputDefaultBlockNumberFormatter, null, null, null, null, null],
  229. }),
  230. new web3._extend.Method({
  231. name: 'printBlock',
  232. call: 'debug_printBlock',
  233. params: 1
  234. }),
  235. new web3._extend.Method({
  236. name: 'getBlockRlp',
  237. call: 'debug_getBlockRlp',
  238. params: 1
  239. }),
  240. new web3._extend.Method({
  241. name: 'testSignCliqueBlock',
  242. call: 'debug_testSignCliqueBlock',
  243. params: 2,
  244. inputFormatters: [web3._extend.formatters.inputAddressFormatter, null],
  245. }),
  246. new web3._extend.Method({
  247. name: 'setHead',
  248. call: 'debug_setHead',
  249. params: 1
  250. }),
  251. new web3._extend.Method({
  252. name: 'seedHash',
  253. call: 'debug_seedHash',
  254. params: 1
  255. }),
  256. new web3._extend.Method({
  257. name: 'dumpBlock',
  258. call: 'debug_dumpBlock',
  259. params: 1
  260. }),
  261. new web3._extend.Method({
  262. name: 'chaindbProperty',
  263. call: 'debug_chaindbProperty',
  264. params: 1,
  265. outputFormatter: console.log
  266. }),
  267. new web3._extend.Method({
  268. name: 'chaindbCompact',
  269. call: 'debug_chaindbCompact',
  270. }),
  271. new web3._extend.Method({
  272. name: 'verbosity',
  273. call: 'debug_verbosity',
  274. params: 1
  275. }),
  276. new web3._extend.Method({
  277. name: 'vmodule',
  278. call: 'debug_vmodule',
  279. params: 1
  280. }),
  281. new web3._extend.Method({
  282. name: 'backtraceAt',
  283. call: 'debug_backtraceAt',
  284. params: 1,
  285. }),
  286. new web3._extend.Method({
  287. name: 'stacks',
  288. call: 'debug_stacks',
  289. params: 0,
  290. outputFormatter: console.log
  291. }),
  292. new web3._extend.Method({
  293. name: 'freeOSMemory',
  294. call: 'debug_freeOSMemory',
  295. params: 0,
  296. }),
  297. new web3._extend.Method({
  298. name: 'setGCPercent',
  299. call: 'debug_setGCPercent',
  300. params: 1,
  301. }),
  302. new web3._extend.Method({
  303. name: 'memStats',
  304. call: 'debug_memStats',
  305. params: 0,
  306. }),
  307. new web3._extend.Method({
  308. name: 'gcStats',
  309. call: 'debug_gcStats',
  310. params: 0,
  311. }),
  312. new web3._extend.Method({
  313. name: 'cpuProfile',
  314. call: 'debug_cpuProfile',
  315. params: 2
  316. }),
  317. new web3._extend.Method({
  318. name: 'startCPUProfile',
  319. call: 'debug_startCPUProfile',
  320. params: 1
  321. }),
  322. new web3._extend.Method({
  323. name: 'stopCPUProfile',
  324. call: 'debug_stopCPUProfile',
  325. params: 0
  326. }),
  327. new web3._extend.Method({
  328. name: 'goTrace',
  329. call: 'debug_goTrace',
  330. params: 2
  331. }),
  332. new web3._extend.Method({
  333. name: 'startGoTrace',
  334. call: 'debug_startGoTrace',
  335. params: 1
  336. }),
  337. new web3._extend.Method({
  338. name: 'stopGoTrace',
  339. call: 'debug_stopGoTrace',
  340. params: 0
  341. }),
  342. new web3._extend.Method({
  343. name: 'blockProfile',
  344. call: 'debug_blockProfile',
  345. params: 2
  346. }),
  347. new web3._extend.Method({
  348. name: 'setBlockProfileRate',
  349. call: 'debug_setBlockProfileRate',
  350. params: 1
  351. }),
  352. new web3._extend.Method({
  353. name: 'writeBlockProfile',
  354. call: 'debug_writeBlockProfile',
  355. params: 1
  356. }),
  357. new web3._extend.Method({
  358. name: 'mutexProfile',
  359. call: 'debug_mutexProfile',
  360. params: 2
  361. }),
  362. new web3._extend.Method({
  363. name: 'setMutexProfileFraction',
  364. call: 'debug_setMutexProfileFraction',
  365. params: 1
  366. }),
  367. new web3._extend.Method({
  368. name: 'writeMutexProfile',
  369. call: 'debug_writeMutexProfile',
  370. params: 1
  371. }),
  372. new web3._extend.Method({
  373. name: 'writeMemProfile',
  374. call: 'debug_writeMemProfile',
  375. params: 1
  376. }),
  377. new web3._extend.Method({
  378. name: 'traceBlock',
  379. call: 'debug_traceBlock',
  380. params: 2,
  381. inputFormatter: [null, null]
  382. }),
  383. new web3._extend.Method({
  384. name: 'traceBlockFromFile',
  385. call: 'debug_traceBlockFromFile',
  386. params: 2,
  387. inputFormatter: [null, null]
  388. }),
  389. new web3._extend.Method({
  390. name: 'traceBadBlock',
  391. call: 'debug_traceBadBlock',
  392. params: 1,
  393. inputFormatter: [null]
  394. }),
  395. new web3._extend.Method({
  396. name: 'standardTraceBadBlockToFile',
  397. call: 'debug_standardTraceBadBlockToFile',
  398. params: 2,
  399. inputFormatter: [null, null]
  400. }),
  401. new web3._extend.Method({
  402. name: 'standardTraceBlockToFile',
  403. call: 'debug_standardTraceBlockToFile',
  404. params: 2,
  405. inputFormatter: [null, null]
  406. }),
  407. new web3._extend.Method({
  408. name: 'traceBlockByNumber',
  409. call: 'debug_traceBlockByNumber',
  410. params: 2,
  411. inputFormatter: [null, null]
  412. }),
  413. new web3._extend.Method({
  414. name: 'traceBlockByHash',
  415. call: 'debug_traceBlockByHash',
  416. params: 2,
  417. inputFormatter: [null, null]
  418. }),
  419. new web3._extend.Method({
  420. name: 'traceTransaction',
  421. call: 'debug_traceTransaction',
  422. params: 2,
  423. inputFormatter: [null, null]
  424. }),
  425. new web3._extend.Method({
  426. name: 'preimage',
  427. call: 'debug_preimage',
  428. params: 1,
  429. inputFormatter: [null]
  430. }),
  431. new web3._extend.Method({
  432. name: 'getBadBlocks',
  433. call: 'debug_getBadBlocks',
  434. params: 0,
  435. }),
  436. new web3._extend.Method({
  437. name: 'storageRangeAt',
  438. call: 'debug_storageRangeAt',
  439. params: 5,
  440. }),
  441. new web3._extend.Method({
  442. name: 'getModifiedAccountsByNumber',
  443. call: 'debug_getModifiedAccountsByNumber',
  444. params: 2,
  445. inputFormatter: [null, null],
  446. }),
  447. new web3._extend.Method({
  448. name: 'getModifiedAccountsByHash',
  449. call: 'debug_getModifiedAccountsByHash',
  450. params: 2,
  451. inputFormatter:[null, null],
  452. }),
  453. new web3._extend.Method({
  454. name: 'freezeClient',
  455. call: 'debug_freezeClient',
  456. params: 1,
  457. }),
  458. ],
  459. properties: []
  460. });
  461. `
  462. const EthJs = `
  463. web3._extend({
  464. property: 'eth',
  465. methods: [
  466. new web3._extend.Method({
  467. name: 'chainId',
  468. call: 'eth_chainId',
  469. params: 0
  470. }),
  471. new web3._extend.Method({
  472. name: 'sign',
  473. call: 'eth_sign',
  474. params: 2,
  475. inputFormatter: [web3._extend.formatters.inputAddressFormatter, null]
  476. }),
  477. new web3._extend.Method({
  478. name: 'resend',
  479. call: 'eth_resend',
  480. params: 3,
  481. inputFormatter: [web3._extend.formatters.inputTransactionFormatter, web3._extend.utils.fromDecimal, web3._extend.utils.fromDecimal]
  482. }),
  483. new web3._extend.Method({
  484. name: 'signTransaction',
  485. call: 'eth_signTransaction',
  486. params: 1,
  487. inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
  488. }),
  489. new web3._extend.Method({
  490. name: 'submitTransaction',
  491. call: 'eth_submitTransaction',
  492. params: 1,
  493. inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
  494. }),
  495. new web3._extend.Method({
  496. name: 'fillTransaction',
  497. call: 'eth_fillTransaction',
  498. params: 1,
  499. inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
  500. }),
  501. new web3._extend.Method({
  502. name: 'getHeaderByNumber',
  503. call: 'eth_getHeaderByNumber',
  504. params: 1
  505. }),
  506. new web3._extend.Method({
  507. name: 'getHeaderByHash',
  508. call: 'eth_getHeaderByHash',
  509. params: 1
  510. }),
  511. new web3._extend.Method({
  512. name: 'getBlockByNumber',
  513. call: 'eth_getBlockByNumber',
  514. params: 2
  515. }),
  516. new web3._extend.Method({
  517. name: 'getBlockByHash',
  518. call: 'eth_getBlockByHash',
  519. params: 2
  520. }),
  521. new web3._extend.Method({
  522. name: 'getRawTransaction',
  523. call: 'eth_getRawTransactionByHash',
  524. params: 1
  525. }),
  526. new web3._extend.Method({
  527. name: 'getRawTransactionFromBlock',
  528. call: function(args) {
  529. return (web3._extend.utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getRawTransactionByBlockHashAndIndex' : 'eth_getRawTransactionByBlockNumberAndIndex';
  530. },
  531. params: 2,
  532. inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter, web3._extend.utils.toHex]
  533. }),
  534. new web3._extend.Method({
  535. name: 'getProof',
  536. call: 'eth_getProof',
  537. params: 3,
  538. inputFormatter: [web3._extend.formatters.inputAddressFormatter, null, web3._extend.formatters.inputBlockNumberFormatter]
  539. }),
  540. ],
  541. properties: [
  542. new web3._extend.Property({
  543. name: 'pendingTransactions',
  544. getter: 'eth_pendingTransactions',
  545. outputFormatter: function(txs) {
  546. var formatted = [];
  547. for (var i = 0; i < txs.length; i++) {
  548. formatted.push(web3._extend.formatters.outputTransactionFormatter(txs[i]));
  549. formatted[i].blockHash = null;
  550. }
  551. return formatted;
  552. }
  553. }),
  554. ]
  555. });
  556. `
  557. const MinerJs = `
  558. web3._extend({
  559. property: 'miner',
  560. methods: [
  561. new web3._extend.Method({
  562. name: 'start',
  563. call: 'miner_start',
  564. params: 1,
  565. inputFormatter: [null]
  566. }),
  567. new web3._extend.Method({
  568. name: 'stop',
  569. call: 'miner_stop'
  570. }),
  571. new web3._extend.Method({
  572. name: 'setEtherbase',
  573. call: 'miner_setEtherbase',
  574. params: 1,
  575. inputFormatter: [web3._extend.formatters.inputAddressFormatter]
  576. }),
  577. new web3._extend.Method({
  578. name: 'setExtra',
  579. call: 'miner_setExtra',
  580. params: 1
  581. }),
  582. new web3._extend.Method({
  583. name: 'setGasPrice',
  584. call: 'miner_setGasPrice',
  585. params: 1,
  586. inputFormatter: [web3._extend.utils.fromDecimal]
  587. }),
  588. new web3._extend.Method({
  589. name: 'setRecommitInterval',
  590. call: 'miner_setRecommitInterval',
  591. params: 1,
  592. }),
  593. new web3._extend.Method({
  594. name: 'getHashrate',
  595. call: 'miner_getHashrate'
  596. }),
  597. ],
  598. properties: []
  599. });
  600. `
  601. const NetJs = `
  602. web3._extend({
  603. property: 'net',
  604. methods: [],
  605. properties: [
  606. new web3._extend.Property({
  607. name: 'version',
  608. getter: 'net_version'
  609. }),
  610. ]
  611. });
  612. `
  613. const PersonalJs = `
  614. web3._extend({
  615. property: 'personal',
  616. methods: [
  617. new web3._extend.Method({
  618. name: 'importRawKey',
  619. call: 'personal_importRawKey',
  620. params: 2
  621. }),
  622. new web3._extend.Method({
  623. name: 'sign',
  624. call: 'personal_sign',
  625. params: 3,
  626. inputFormatter: [null, web3._extend.formatters.inputAddressFormatter, null]
  627. }),
  628. new web3._extend.Method({
  629. name: 'ecRecover',
  630. call: 'personal_ecRecover',
  631. params: 2
  632. }),
  633. new web3._extend.Method({
  634. name: 'openWallet',
  635. call: 'personal_openWallet',
  636. params: 2
  637. }),
  638. new web3._extend.Method({
  639. name: 'deriveAccount',
  640. call: 'personal_deriveAccount',
  641. params: 3
  642. }),
  643. new web3._extend.Method({
  644. name: 'signTransaction',
  645. call: 'personal_signTransaction',
  646. params: 2,
  647. inputFormatter: [web3._extend.formatters.inputTransactionFormatter, null]
  648. }),
  649. new web3._extend.Method({
  650. name: 'unpair',
  651. call: 'personal_unpair',
  652. params: 2
  653. }),
  654. new web3._extend.Method({
  655. name: 'initializeWallet',
  656. call: 'personal_initializeWallet',
  657. params: 1
  658. })
  659. ],
  660. properties: [
  661. new web3._extend.Property({
  662. name: 'listWallets',
  663. getter: 'personal_listWallets'
  664. }),
  665. ]
  666. })
  667. `
  668. const RpcJs = `
  669. web3._extend({
  670. property: 'rpc',
  671. methods: [],
  672. properties: [
  673. new web3._extend.Property({
  674. name: 'modules',
  675. getter: 'rpc_modules'
  676. }),
  677. ]
  678. });
  679. `
  680. const ShhJs = `
  681. web3._extend({
  682. property: 'shh',
  683. methods: [
  684. ],
  685. properties:
  686. [
  687. new web3._extend.Property({
  688. name: 'version',
  689. getter: 'shh_version',
  690. outputFormatter: web3._extend.utils.toDecimal
  691. }),
  692. new web3._extend.Property({
  693. name: 'info',
  694. getter: 'shh_info'
  695. }),
  696. ]
  697. });
  698. `
  699. const SwarmfsJs = `
  700. web3._extend({
  701. property: 'swarmfs',
  702. methods:
  703. [
  704. new web3._extend.Method({
  705. name: 'mount',
  706. call: 'swarmfs_mount',
  707. params: 2
  708. }),
  709. new web3._extend.Method({
  710. name: 'unmount',
  711. call: 'swarmfs_unmount',
  712. params: 1
  713. }),
  714. new web3._extend.Method({
  715. name: 'listmounts',
  716. call: 'swarmfs_listmounts',
  717. params: 0
  718. }),
  719. ]
  720. });
  721. `
  722. const TxpoolJs = `
  723. web3._extend({
  724. property: 'txpool',
  725. methods: [],
  726. properties:
  727. [
  728. new web3._extend.Property({
  729. name: 'content',
  730. getter: 'txpool_content'
  731. }),
  732. new web3._extend.Property({
  733. name: 'inspect',
  734. getter: 'txpool_inspect'
  735. }),
  736. new web3._extend.Property({
  737. name: 'status',
  738. getter: 'txpool_status',
  739. outputFormatter: function(status) {
  740. status.pending = web3._extend.utils.toDecimal(status.pending);
  741. status.queued = web3._extend.utils.toDecimal(status.queued);
  742. return status;
  743. }
  744. }),
  745. ]
  746. });
  747. `
  748. const AccountingJs = `
  749. web3._extend({
  750. property: 'accounting',
  751. methods: [
  752. new web3._extend.Property({
  753. name: 'balance',
  754. getter: 'account_balance'
  755. }),
  756. new web3._extend.Property({
  757. name: 'balanceCredit',
  758. getter: 'account_balanceCredit'
  759. }),
  760. new web3._extend.Property({
  761. name: 'balanceDebit',
  762. getter: 'account_balanceDebit'
  763. }),
  764. new web3._extend.Property({
  765. name: 'bytesCredit',
  766. getter: 'account_bytesCredit'
  767. }),
  768. new web3._extend.Property({
  769. name: 'bytesDebit',
  770. getter: 'account_bytesDebit'
  771. }),
  772. new web3._extend.Property({
  773. name: 'msgCredit',
  774. getter: 'account_msgCredit'
  775. }),
  776. new web3._extend.Property({
  777. name: 'msgDebit',
  778. getter: 'account_msgDebit'
  779. }),
  780. new web3._extend.Property({
  781. name: 'peerDrops',
  782. getter: 'account_peerDrops'
  783. }),
  784. new web3._extend.Property({
  785. name: 'selfDrops',
  786. getter: 'account_selfDrops'
  787. }),
  788. ]
  789. });
  790. `
  791. const LESJs = `
  792. web3._extend({
  793. property: 'les',
  794. methods:
  795. [
  796. new web3._extend.Method({
  797. name: 'getCheckpoint',
  798. call: 'les_getCheckpoint',
  799. params: 1
  800. }),
  801. new web3._extend.Method({
  802. name: 'clientInfo',
  803. call: 'les_clientInfo',
  804. params: 1
  805. }),
  806. new web3._extend.Method({
  807. name: 'priorityClientInfo',
  808. call: 'les_priorityClientInfo',
  809. params: 3
  810. }),
  811. new web3._extend.Method({
  812. name: 'setClientParams',
  813. call: 'les_setClientParams',
  814. params: 2
  815. }),
  816. new web3._extend.Method({
  817. name: 'setDefaultParams',
  818. call: 'les_setDefaultParams',
  819. params: 1
  820. }),
  821. new web3._extend.Method({
  822. name: 'addBalance',
  823. call: 'les_addBalance',
  824. params: 3
  825. }),
  826. ],
  827. properties:
  828. [
  829. new web3._extend.Property({
  830. name: 'latestCheckpoint',
  831. getter: 'les_latestCheckpoint'
  832. }),
  833. new web3._extend.Property({
  834. name: 'checkpointContractAddress',
  835. getter: 'les_getCheckpointContractAddress'
  836. }),
  837. new web3._extend.Property({
  838. name: 'serverInfo',
  839. getter: 'les_serverInfo'
  840. }),
  841. ]
  842. });
  843. `
  844. const LESPayJs = `
  845. web3._extend({
  846. property: 'lespay',
  847. methods:
  848. [
  849. new web3._extend.Method({
  850. name: 'distribution',
  851. call: 'lespay_distribution',
  852. params: 2
  853. }),
  854. new web3._extend.Method({
  855. name: 'timeout',
  856. call: 'lespay_timeout',
  857. params: 2
  858. }),
  859. new web3._extend.Method({
  860. name: 'value',
  861. call: 'lespay_value',
  862. params: 2
  863. }),
  864. ],
  865. properties:
  866. [
  867. new web3._extend.Property({
  868. name: 'requestStats',
  869. getter: 'lespay_requestStats'
  870. }),
  871. ]
  872. });
  873. `