web3ext.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904
  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: 'traceCall',
  427. call: 'debug_traceCall',
  428. params: 3,
  429. inputFormatter: [null, null, null]
  430. }),
  431. new web3._extend.Method({
  432. name: 'preimage',
  433. call: 'debug_preimage',
  434. params: 1,
  435. inputFormatter: [null]
  436. }),
  437. new web3._extend.Method({
  438. name: 'getBadBlocks',
  439. call: 'debug_getBadBlocks',
  440. params: 0,
  441. }),
  442. new web3._extend.Method({
  443. name: 'storageRangeAt',
  444. call: 'debug_storageRangeAt',
  445. params: 5,
  446. }),
  447. new web3._extend.Method({
  448. name: 'getModifiedAccountsByNumber',
  449. call: 'debug_getModifiedAccountsByNumber',
  450. params: 2,
  451. inputFormatter: [null, null],
  452. }),
  453. new web3._extend.Method({
  454. name: 'getModifiedAccountsByHash',
  455. call: 'debug_getModifiedAccountsByHash',
  456. params: 2,
  457. inputFormatter:[null, null],
  458. }),
  459. new web3._extend.Method({
  460. name: 'freezeClient',
  461. call: 'debug_freezeClient',
  462. params: 1,
  463. }),
  464. ],
  465. properties: []
  466. });
  467. `
  468. const EthJs = `
  469. web3._extend({
  470. property: 'eth',
  471. methods: [
  472. new web3._extend.Method({
  473. name: 'chainId',
  474. call: 'eth_chainId',
  475. params: 0
  476. }),
  477. new web3._extend.Method({
  478. name: 'sign',
  479. call: 'eth_sign',
  480. params: 2,
  481. inputFormatter: [web3._extend.formatters.inputAddressFormatter, null]
  482. }),
  483. new web3._extend.Method({
  484. name: 'resend',
  485. call: 'eth_resend',
  486. params: 3,
  487. inputFormatter: [web3._extend.formatters.inputTransactionFormatter, web3._extend.utils.fromDecimal, web3._extend.utils.fromDecimal]
  488. }),
  489. new web3._extend.Method({
  490. name: 'signTransaction',
  491. call: 'eth_signTransaction',
  492. params: 1,
  493. inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
  494. }),
  495. new web3._extend.Method({
  496. name: 'estimateGas',
  497. call: 'eth_estimateGas',
  498. params: 2,
  499. inputFormatter: [web3._extend.formatters.inputCallFormatter, web3._extend.formatters.inputBlockNumberFormatter],
  500. outputFormatter: web3._extend.utils.toDecimal
  501. }),
  502. new web3._extend.Method({
  503. name: 'submitTransaction',
  504. call: 'eth_submitTransaction',
  505. params: 1,
  506. inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
  507. }),
  508. new web3._extend.Method({
  509. name: 'fillTransaction',
  510. call: 'eth_fillTransaction',
  511. params: 1,
  512. inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
  513. }),
  514. new web3._extend.Method({
  515. name: 'getHeaderByNumber',
  516. call: 'eth_getHeaderByNumber',
  517. params: 1
  518. }),
  519. new web3._extend.Method({
  520. name: 'getHeaderByHash',
  521. call: 'eth_getHeaderByHash',
  522. params: 1
  523. }),
  524. new web3._extend.Method({
  525. name: 'getBlockByNumber',
  526. call: 'eth_getBlockByNumber',
  527. params: 2
  528. }),
  529. new web3._extend.Method({
  530. name: 'getBlockByHash',
  531. call: 'eth_getBlockByHash',
  532. params: 2
  533. }),
  534. new web3._extend.Method({
  535. name: 'getRawTransaction',
  536. call: 'eth_getRawTransactionByHash',
  537. params: 1
  538. }),
  539. new web3._extend.Method({
  540. name: 'getRawTransactionFromBlock',
  541. call: function(args) {
  542. return (web3._extend.utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getRawTransactionByBlockHashAndIndex' : 'eth_getRawTransactionByBlockNumberAndIndex';
  543. },
  544. params: 2,
  545. inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter, web3._extend.utils.toHex]
  546. }),
  547. new web3._extend.Method({
  548. name: 'getProof',
  549. call: 'eth_getProof',
  550. params: 3,
  551. inputFormatter: [web3._extend.formatters.inputAddressFormatter, null, web3._extend.formatters.inputBlockNumberFormatter]
  552. }),
  553. ],
  554. properties: [
  555. new web3._extend.Property({
  556. name: 'pendingTransactions',
  557. getter: 'eth_pendingTransactions',
  558. outputFormatter: function(txs) {
  559. var formatted = [];
  560. for (var i = 0; i < txs.length; i++) {
  561. formatted.push(web3._extend.formatters.outputTransactionFormatter(txs[i]));
  562. formatted[i].blockHash = null;
  563. }
  564. return formatted;
  565. }
  566. }),
  567. ]
  568. });
  569. `
  570. const MinerJs = `
  571. web3._extend({
  572. property: 'miner',
  573. methods: [
  574. new web3._extend.Method({
  575. name: 'start',
  576. call: 'miner_start',
  577. params: 1,
  578. inputFormatter: [null]
  579. }),
  580. new web3._extend.Method({
  581. name: 'stop',
  582. call: 'miner_stop'
  583. }),
  584. new web3._extend.Method({
  585. name: 'setEtherbase',
  586. call: 'miner_setEtherbase',
  587. params: 1,
  588. inputFormatter: [web3._extend.formatters.inputAddressFormatter]
  589. }),
  590. new web3._extend.Method({
  591. name: 'setExtra',
  592. call: 'miner_setExtra',
  593. params: 1
  594. }),
  595. new web3._extend.Method({
  596. name: 'setGasPrice',
  597. call: 'miner_setGasPrice',
  598. params: 1,
  599. inputFormatter: [web3._extend.utils.fromDecimal]
  600. }),
  601. new web3._extend.Method({
  602. name: 'setRecommitInterval',
  603. call: 'miner_setRecommitInterval',
  604. params: 1,
  605. }),
  606. new web3._extend.Method({
  607. name: 'getHashrate',
  608. call: 'miner_getHashrate'
  609. }),
  610. ],
  611. properties: []
  612. });
  613. `
  614. const NetJs = `
  615. web3._extend({
  616. property: 'net',
  617. methods: [],
  618. properties: [
  619. new web3._extend.Property({
  620. name: 'version',
  621. getter: 'net_version'
  622. }),
  623. ]
  624. });
  625. `
  626. const PersonalJs = `
  627. web3._extend({
  628. property: 'personal',
  629. methods: [
  630. new web3._extend.Method({
  631. name: 'importRawKey',
  632. call: 'personal_importRawKey',
  633. params: 2
  634. }),
  635. new web3._extend.Method({
  636. name: 'sign',
  637. call: 'personal_sign',
  638. params: 3,
  639. inputFormatter: [null, web3._extend.formatters.inputAddressFormatter, null]
  640. }),
  641. new web3._extend.Method({
  642. name: 'ecRecover',
  643. call: 'personal_ecRecover',
  644. params: 2
  645. }),
  646. new web3._extend.Method({
  647. name: 'openWallet',
  648. call: 'personal_openWallet',
  649. params: 2
  650. }),
  651. new web3._extend.Method({
  652. name: 'deriveAccount',
  653. call: 'personal_deriveAccount',
  654. params: 3
  655. }),
  656. new web3._extend.Method({
  657. name: 'signTransaction',
  658. call: 'personal_signTransaction',
  659. params: 2,
  660. inputFormatter: [web3._extend.formatters.inputTransactionFormatter, null]
  661. }),
  662. new web3._extend.Method({
  663. name: 'unpair',
  664. call: 'personal_unpair',
  665. params: 2
  666. }),
  667. new web3._extend.Method({
  668. name: 'initializeWallet',
  669. call: 'personal_initializeWallet',
  670. params: 1
  671. })
  672. ],
  673. properties: [
  674. new web3._extend.Property({
  675. name: 'listWallets',
  676. getter: 'personal_listWallets'
  677. }),
  678. ]
  679. })
  680. `
  681. const RpcJs = `
  682. web3._extend({
  683. property: 'rpc',
  684. methods: [],
  685. properties: [
  686. new web3._extend.Property({
  687. name: 'modules',
  688. getter: 'rpc_modules'
  689. }),
  690. ]
  691. });
  692. `
  693. const ShhJs = `
  694. web3._extend({
  695. property: 'shh',
  696. methods: [
  697. ],
  698. properties:
  699. [
  700. new web3._extend.Property({
  701. name: 'version',
  702. getter: 'shh_version',
  703. outputFormatter: web3._extend.utils.toDecimal
  704. }),
  705. new web3._extend.Property({
  706. name: 'info',
  707. getter: 'shh_info'
  708. }),
  709. ]
  710. });
  711. `
  712. const SwarmfsJs = `
  713. web3._extend({
  714. property: 'swarmfs',
  715. methods:
  716. [
  717. new web3._extend.Method({
  718. name: 'mount',
  719. call: 'swarmfs_mount',
  720. params: 2
  721. }),
  722. new web3._extend.Method({
  723. name: 'unmount',
  724. call: 'swarmfs_unmount',
  725. params: 1
  726. }),
  727. new web3._extend.Method({
  728. name: 'listmounts',
  729. call: 'swarmfs_listmounts',
  730. params: 0
  731. }),
  732. ]
  733. });
  734. `
  735. const TxpoolJs = `
  736. web3._extend({
  737. property: 'txpool',
  738. methods: [],
  739. properties:
  740. [
  741. new web3._extend.Property({
  742. name: 'content',
  743. getter: 'txpool_content'
  744. }),
  745. new web3._extend.Property({
  746. name: 'inspect',
  747. getter: 'txpool_inspect'
  748. }),
  749. new web3._extend.Property({
  750. name: 'status',
  751. getter: 'txpool_status',
  752. outputFormatter: function(status) {
  753. status.pending = web3._extend.utils.toDecimal(status.pending);
  754. status.queued = web3._extend.utils.toDecimal(status.queued);
  755. return status;
  756. }
  757. }),
  758. ]
  759. });
  760. `
  761. const AccountingJs = `
  762. web3._extend({
  763. property: 'accounting',
  764. methods: [
  765. new web3._extend.Property({
  766. name: 'balance',
  767. getter: 'account_balance'
  768. }),
  769. new web3._extend.Property({
  770. name: 'balanceCredit',
  771. getter: 'account_balanceCredit'
  772. }),
  773. new web3._extend.Property({
  774. name: 'balanceDebit',
  775. getter: 'account_balanceDebit'
  776. }),
  777. new web3._extend.Property({
  778. name: 'bytesCredit',
  779. getter: 'account_bytesCredit'
  780. }),
  781. new web3._extend.Property({
  782. name: 'bytesDebit',
  783. getter: 'account_bytesDebit'
  784. }),
  785. new web3._extend.Property({
  786. name: 'msgCredit',
  787. getter: 'account_msgCredit'
  788. }),
  789. new web3._extend.Property({
  790. name: 'msgDebit',
  791. getter: 'account_msgDebit'
  792. }),
  793. new web3._extend.Property({
  794. name: 'peerDrops',
  795. getter: 'account_peerDrops'
  796. }),
  797. new web3._extend.Property({
  798. name: 'selfDrops',
  799. getter: 'account_selfDrops'
  800. }),
  801. ]
  802. });
  803. `
  804. const LESJs = `
  805. web3._extend({
  806. property: 'les',
  807. methods:
  808. [
  809. new web3._extend.Method({
  810. name: 'getCheckpoint',
  811. call: 'les_getCheckpoint',
  812. params: 1
  813. }),
  814. new web3._extend.Method({
  815. name: 'clientInfo',
  816. call: 'les_clientInfo',
  817. params: 1
  818. }),
  819. new web3._extend.Method({
  820. name: 'priorityClientInfo',
  821. call: 'les_priorityClientInfo',
  822. params: 3
  823. }),
  824. new web3._extend.Method({
  825. name: 'setClientParams',
  826. call: 'les_setClientParams',
  827. params: 2
  828. }),
  829. new web3._extend.Method({
  830. name: 'setDefaultParams',
  831. call: 'les_setDefaultParams',
  832. params: 1
  833. }),
  834. new web3._extend.Method({
  835. name: 'addBalance',
  836. call: 'les_addBalance',
  837. params: 2
  838. }),
  839. ],
  840. properties:
  841. [
  842. new web3._extend.Property({
  843. name: 'latestCheckpoint',
  844. getter: 'les_latestCheckpoint'
  845. }),
  846. new web3._extend.Property({
  847. name: 'checkpointContractAddress',
  848. getter: 'les_getCheckpointContractAddress'
  849. }),
  850. new web3._extend.Property({
  851. name: 'serverInfo',
  852. getter: 'les_serverInfo'
  853. }),
  854. ]
  855. });
  856. `
  857. const LESPayJs = `
  858. web3._extend({
  859. property: 'lespay',
  860. methods:
  861. [
  862. new web3._extend.Method({
  863. name: 'distribution',
  864. call: 'lespay_distribution',
  865. params: 2
  866. }),
  867. new web3._extend.Method({
  868. name: 'timeout',
  869. call: 'lespay_timeout',
  870. params: 2
  871. }),
  872. new web3._extend.Method({
  873. name: 'value',
  874. call: 'lespay_value',
  875. params: 2
  876. }),
  877. ],
  878. properties:
  879. [
  880. new web3._extend.Property({
  881. name: 'requestStats',
  882. getter: 'lespay_requestStats'
  883. }),
  884. ]
  885. });
  886. `