github.com/FUSIONFoundation/efsn@v3.6.2-0.20200916075423-dbb5dd5d2cc7+incompatible/internal/web3ext/web3ext.go (about) 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 17 // package web3ext contains efsn specific web3.js extensions. 18 package web3ext 19 20 var Modules = map[string]string{ 21 "admin": Admin_JS, 22 "chequebook": Chequebook_JS, 23 "clique": Clique_JS, 24 "ethash": Ethash_JS, 25 "debug": Debug_JS, 26 "eth": Eth_JS, 27 "miner": Miner_JS, 28 "net": Net_JS, 29 "personal": Personal_JS, 30 "rpc": RPC_JS, 31 "shh": Shh_JS, 32 "swarmfs": SWARMFS_JS, 33 "txpool": TxPool_JS, 34 "fsn": FsnJS, 35 "fsntx": FsnTxJS, 36 "fsnbt": FsnBT, 37 } 38 39 const Chequebook_JS = ` 40 web3._extend({ 41 property: 'chequebook', 42 methods: [ 43 new web3._extend.Method({ 44 name: 'deposit', 45 call: 'chequebook_deposit', 46 params: 1, 47 inputFormatter: [null] 48 }), 49 new web3._extend.Property({ 50 name: 'balance', 51 getter: 'chequebook_balance', 52 outputFormatter: web3._extend.utils.toDecimal 53 }), 54 new web3._extend.Method({ 55 name: 'cash', 56 call: 'chequebook_cash', 57 params: 1, 58 inputFormatter: [null] 59 }), 60 new web3._extend.Method({ 61 name: 'issue', 62 call: 'chequebook_issue', 63 params: 2, 64 inputFormatter: [null, null] 65 }), 66 ] 67 }); 68 ` 69 70 const Clique_JS = ` 71 web3._extend({ 72 property: 'clique', 73 methods: [ 74 new web3._extend.Method({ 75 name: 'getSnapshot', 76 call: 'clique_getSnapshot', 77 params: 1, 78 inputFormatter: [null] 79 }), 80 new web3._extend.Method({ 81 name: 'getSnapshotAtHash', 82 call: 'clique_getSnapshotAtHash', 83 params: 1 84 }), 85 new web3._extend.Method({ 86 name: 'getSigners', 87 call: 'clique_getSigners', 88 params: 1, 89 inputFormatter: [null] 90 }), 91 new web3._extend.Method({ 92 name: 'getSignersAtHash', 93 call: 'clique_getSignersAtHash', 94 params: 1 95 }), 96 new web3._extend.Method({ 97 name: 'propose', 98 call: 'clique_propose', 99 params: 2 100 }), 101 new web3._extend.Method({ 102 name: 'discard', 103 call: 'clique_discard', 104 params: 1 105 }), 106 ], 107 properties: [ 108 new web3._extend.Property({ 109 name: 'proposals', 110 getter: 'clique_proposals' 111 }), 112 ] 113 }); 114 ` 115 116 const Ethash_JS = ` 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 144 const Admin_JS = ` 145 web3._extend({ 146 property: 'admin', 147 methods: [ 148 new web3._extend.Method({ 149 name: 'addPeer', 150 call: 'admin_addPeer', 151 params: 1 152 }), 153 new web3._extend.Method({ 154 name: 'removePeer', 155 call: 'admin_removePeer', 156 params: 1 157 }), 158 new web3._extend.Method({ 159 name: 'addTrustedPeer', 160 call: 'admin_addTrustedPeer', 161 params: 1 162 }), 163 new web3._extend.Method({ 164 name: 'removeTrustedPeer', 165 call: 'admin_removeTrustedPeer', 166 params: 1 167 }), 168 new web3._extend.Method({ 169 name: 'exportChain', 170 call: 'admin_exportChain', 171 params: 1, 172 inputFormatter: [null] 173 }), 174 new web3._extend.Method({ 175 name: 'importChain', 176 call: 'admin_importChain', 177 params: 1 178 }), 179 new web3._extend.Method({ 180 name: 'sleepBlocks', 181 call: 'admin_sleepBlocks', 182 params: 2 183 }), 184 new web3._extend.Method({ 185 name: 'startRPC', 186 call: 'admin_startRPC', 187 params: 4, 188 inputFormatter: [null, null, null, null] 189 }), 190 new web3._extend.Method({ 191 name: 'stopRPC', 192 call: 'admin_stopRPC' 193 }), 194 new web3._extend.Method({ 195 name: 'startWS', 196 call: 'admin_startWS', 197 params: 4, 198 inputFormatter: [null, null, null, null] 199 }), 200 new web3._extend.Method({ 201 name: 'stopWS', 202 call: 'admin_stopWS' 203 }), 204 ], 205 properties: [ 206 new web3._extend.Property({ 207 name: 'nodeInfo', 208 getter: 'admin_nodeInfo' 209 }), 210 new web3._extend.Property({ 211 name: 'peers', 212 getter: 'admin_peers' 213 }), 214 new web3._extend.Property({ 215 name: 'datadir', 216 getter: 'admin_datadir' 217 }), 218 ] 219 }); 220 ` 221 222 const Debug_JS = ` 223 web3._extend({ 224 property: 'debug', 225 methods: [ 226 new web3._extend.Method({ 227 name: 'printBlock', 228 call: 'debug_printBlock', 229 params: 1 230 }), 231 new web3._extend.Method({ 232 name: 'getBlockRlp', 233 call: 'debug_getBlockRlp', 234 params: 1 235 }), 236 new web3._extend.Method({ 237 name: 'setHead', 238 call: 'debug_setHead', 239 params: 1 240 }), 241 new web3._extend.Method({ 242 name: 'seedHash', 243 call: 'debug_seedHash', 244 params: 1 245 }), 246 new web3._extend.Method({ 247 name: 'dumpBlock', 248 call: 'debug_dumpBlock', 249 params: 1 250 inputFormatter: [ 251 web3._extend.formatters.inputDefaultBlockNumberFormatter 252 ] 253 }), 254 new web3._extend.Method({ 255 name: 'chaindbProperty', 256 call: 'debug_chaindbProperty', 257 params: 1, 258 outputFormatter: console.log 259 }), 260 new web3._extend.Method({ 261 name: 'chaindbCompact', 262 call: 'debug_chaindbCompact', 263 }), 264 new web3._extend.Method({ 265 name: 'metrics', 266 call: 'debug_metrics', 267 params: 1 268 }), 269 new web3._extend.Method({ 270 name: 'verbosity', 271 call: 'debug_verbosity', 272 params: 1 273 }), 274 new web3._extend.Method({ 275 name: 'vmodule', 276 call: 'debug_vmodule', 277 params: 1 278 }), 279 new web3._extend.Method({ 280 name: 'backtraceAt', 281 call: 'debug_backtraceAt', 282 params: 1, 283 }), 284 new web3._extend.Method({ 285 name: 'stacks', 286 call: 'debug_stacks', 287 params: 0, 288 outputFormatter: console.log 289 }), 290 new web3._extend.Method({ 291 name: 'freeOSMemory', 292 call: 'debug_freeOSMemory', 293 params: 0, 294 }), 295 new web3._extend.Method({ 296 name: 'setGCPercent', 297 call: 'debug_setGCPercent', 298 params: 1, 299 }), 300 new web3._extend.Method({ 301 name: 'memStats', 302 call: 'debug_memStats', 303 params: 0, 304 }), 305 new web3._extend.Method({ 306 name: 'gcStats', 307 call: 'debug_gcStats', 308 params: 0, 309 }), 310 new web3._extend.Method({ 311 name: 'cpuProfile', 312 call: 'debug_cpuProfile', 313 params: 2 314 }), 315 new web3._extend.Method({ 316 name: 'startCPUProfile', 317 call: 'debug_startCPUProfile', 318 params: 1 319 }), 320 new web3._extend.Method({ 321 name: 'stopCPUProfile', 322 call: 'debug_stopCPUProfile', 323 params: 0 324 }), 325 new web3._extend.Method({ 326 name: 'goTrace', 327 call: 'debug_goTrace', 328 params: 2 329 }), 330 new web3._extend.Method({ 331 name: 'startGoTrace', 332 call: 'debug_startGoTrace', 333 params: 1 334 }), 335 new web3._extend.Method({ 336 name: 'stopGoTrace', 337 call: 'debug_stopGoTrace', 338 params: 0 339 }), 340 new web3._extend.Method({ 341 name: 'blockProfile', 342 call: 'debug_blockProfile', 343 params: 2 344 }), 345 new web3._extend.Method({ 346 name: 'setBlockProfileRate', 347 call: 'debug_setBlockProfileRate', 348 params: 1 349 }), 350 new web3._extend.Method({ 351 name: 'writeBlockProfile', 352 call: 'debug_writeBlockProfile', 353 params: 1 354 }), 355 new web3._extend.Method({ 356 name: 'mutexProfile', 357 call: 'debug_mutexProfile', 358 params: 2 359 }), 360 new web3._extend.Method({ 361 name: 'setMutexProfileFraction', 362 call: 'debug_setMutexProfileFraction', 363 params: 1 364 }), 365 new web3._extend.Method({ 366 name: 'writeMutexProfile', 367 call: 'debug_writeMutexProfile', 368 params: 1 369 }), 370 new web3._extend.Method({ 371 name: 'writeMemProfile', 372 call: 'debug_writeMemProfile', 373 params: 1 374 }), 375 new web3._extend.Method({ 376 name: 'traceBlock', 377 call: 'debug_traceBlock', 378 params: 2, 379 inputFormatter: [null, null] 380 }), 381 new web3._extend.Method({ 382 name: 'traceBlockFromFile', 383 call: 'debug_traceBlockFromFile', 384 params: 2, 385 inputFormatter: [null, null] 386 }), 387 new web3._extend.Method({ 388 name: 'traceBlockByNumber', 389 call: 'debug_traceBlockByNumber', 390 params: 2, 391 inputFormatter: [null, null] 392 }), 393 new web3._extend.Method({ 394 name: 'traceBlockByHash', 395 call: 'debug_traceBlockByHash', 396 params: 2, 397 inputFormatter: [null, null] 398 }), 399 new web3._extend.Method({ 400 name: 'traceTransaction', 401 call: 'debug_traceTransaction', 402 params: 2, 403 inputFormatter: [null, null] 404 }), 405 new web3._extend.Method({ 406 name: 'preimage', 407 call: 'debug_preimage', 408 params: 1, 409 inputFormatter: [null] 410 }), 411 new web3._extend.Method({ 412 name: 'getBadBlocks', 413 call: 'debug_getBadBlocks', 414 params: 0, 415 }), 416 new web3._extend.Method({ 417 name: 'storageRangeAt', 418 call: 'debug_storageRangeAt', 419 params: 5, 420 }), 421 new web3._extend.Method({ 422 name: 'getModifiedAccountsByNumber', 423 call: 'debug_getModifiedAccountsByNumber', 424 params: 2, 425 inputFormatter: [null, null], 426 }), 427 new web3._extend.Method({ 428 name: 'getModifiedAccountsByHash', 429 call: 'debug_getModifiedAccountsByHash', 430 params: 2, 431 inputFormatter:[null, null], 432 }), 433 ], 434 properties: [] 435 }); 436 ` 437 438 const Eth_JS = ` 439 web3._extend({ 440 property: 'eth', 441 methods: [ 442 new web3._extend.Method({ 443 name: 'chainId', 444 call: 'eth_chainId', 445 params: 0 446 }), 447 new web3._extend.Method({ 448 name: 'sign', 449 call: 'eth_sign', 450 params: 2, 451 inputFormatter: [web3._extend.formatters.inputAddressFormatter, null] 452 }), 453 new web3._extend.Method({ 454 name: 'resend', 455 call: 'eth_resend', 456 params: 3, 457 inputFormatter: [web3._extend.formatters.inputTransactionFormatter, web3._extend.utils.fromDecimal, web3._extend.utils.fromDecimal] 458 }), 459 new web3._extend.Method({ 460 name: 'signTransaction', 461 call: 'eth_signTransaction', 462 params: 1, 463 inputFormatter: [web3._extend.formatters.inputTransactionFormatter] 464 }), 465 new web3._extend.Method({ 466 name: 'submitTransaction', 467 call: 'eth_submitTransaction', 468 params: 1, 469 inputFormatter: [web3._extend.formatters.inputTransactionFormatter] 470 }), 471 new web3._extend.Method({ 472 name: 'getRawTransaction', 473 call: 'eth_getRawTransactionByHash', 474 params: 1 475 }), 476 new web3._extend.Method({ 477 name: 'getRawTransactionFromBlock', 478 call: function(args) { 479 return (web3._extend.utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getRawTransactionByBlockHashAndIndex' : 'eth_getRawTransactionByBlockNumberAndIndex'; 480 }, 481 params: 2, 482 inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter, web3._extend.utils.toHex] 483 }), 484 ], 485 properties: [ 486 new web3._extend.Property({ 487 name: 'pendingTransactions', 488 getter: 'eth_pendingTransactions', 489 outputFormatter: function(txs) { 490 var formatted = []; 491 for (var i = 0; i < txs.length; i++) { 492 formatted.push(web3._extend.formatters.outputTransactionFormatter(txs[i])); 493 formatted[i].blockHash = null; 494 } 495 return formatted; 496 } 497 }), 498 ] 499 }); 500 ` 501 502 const Miner_JS = ` 503 web3._extend({ 504 property: 'miner', 505 methods: [ 506 new web3._extend.Method({ 507 name: 'start', 508 call: 'miner_start', 509 params: 1, 510 inputFormatter: [null] 511 }), 512 new web3._extend.Method({ 513 name: 'stop', 514 call: 'miner_stop' 515 }), 516 new web3._extend.Method({ 517 name: 'setEtherbase', 518 call: 'miner_setEtherbase', 519 params: 1, 520 inputFormatter: [web3._extend.formatters.inputAddressFormatter] 521 }), 522 new web3._extend.Method({ 523 name: 'setExtra', 524 call: 'miner_setExtra', 525 params: 1 526 }), 527 new web3._extend.Method({ 528 name: 'setGasPrice', 529 call: 'miner_setGasPrice', 530 params: 1, 531 inputFormatter: [web3._extend.utils.fromDecimal] 532 }), 533 new web3._extend.Method({ 534 name: 'setRecommitInterval', 535 call: 'miner_setRecommitInterval', 536 params: 1, 537 }), 538 new web3._extend.Method({ 539 name: 'getHashrate', 540 call: 'miner_getHashrate' 541 }), 542 new web3._extend.Method({ 543 name: 'startAutoBuyTicket', 544 call: 'miner_startAutoBuyTicket', 545 params: 0 546 }), 547 new web3._extend.Method({ 548 name: 'stopAutoBuyTicket', 549 call: 'miner_stopAutoBuyTicket', 550 params: 0 551 }), 552 ], 553 properties: [] 554 }); 555 ` 556 557 const Net_JS = ` 558 web3._extend({ 559 property: 'net', 560 methods: [], 561 properties: [ 562 new web3._extend.Property({ 563 name: 'version', 564 getter: 'net_version' 565 }), 566 ] 567 }); 568 ` 569 570 const Personal_JS = ` 571 web3._extend({ 572 property: 'personal', 573 methods: [ 574 new web3._extend.Method({ 575 name: 'importRawKey', 576 call: 'personal_importRawKey', 577 params: 2 578 }), 579 new web3._extend.Method({ 580 name: 'sign', 581 call: 'personal_sign', 582 params: 3, 583 inputFormatter: [null, web3._extend.formatters.inputAddressFormatter, null] 584 }), 585 new web3._extend.Method({ 586 name: 'ecRecover', 587 call: 'personal_ecRecover', 588 params: 2 589 }), 590 new web3._extend.Method({ 591 name: 'openWallet', 592 call: 'personal_openWallet', 593 params: 2 594 }), 595 new web3._extend.Method({ 596 name: 'deriveAccount', 597 call: 'personal_deriveAccount', 598 params: 3 599 }), 600 new web3._extend.Method({ 601 name: 'signTransaction', 602 call: 'personal_signTransaction', 603 params: 2, 604 inputFormatter: [web3._extend.formatters.inputTransactionFormatter, null] 605 }), 606 ], 607 properties: [ 608 new web3._extend.Property({ 609 name: 'listWallets', 610 getter: 'personal_listWallets' 611 }), 612 ] 613 }) 614 ` 615 616 const RPC_JS = ` 617 web3._extend({ 618 property: 'rpc', 619 methods: [], 620 properties: [ 621 new web3._extend.Property({ 622 name: 'modules', 623 getter: 'rpc_modules' 624 }), 625 ] 626 }); 627 ` 628 629 const Shh_JS = ` 630 web3._extend({ 631 property: 'shh', 632 methods: [ 633 ], 634 properties: 635 [ 636 new web3._extend.Property({ 637 name: 'version', 638 getter: 'shh_version', 639 outputFormatter: web3._extend.utils.toDecimal 640 }), 641 new web3._extend.Property({ 642 name: 'info', 643 getter: 'shh_info' 644 }), 645 ] 646 }); 647 ` 648 649 const SWARMFS_JS = ` 650 web3._extend({ 651 property: 'swarmfs', 652 methods: 653 [ 654 new web3._extend.Method({ 655 name: 'mount', 656 call: 'swarmfs_mount', 657 params: 2 658 }), 659 new web3._extend.Method({ 660 name: 'unmount', 661 call: 'swarmfs_unmount', 662 params: 1 663 }), 664 new web3._extend.Method({ 665 name: 'listmounts', 666 call: 'swarmfs_listmounts', 667 params: 0 668 }), 669 ] 670 }); 671 ` 672 673 const TxPool_JS = ` 674 web3._extend({ 675 property: 'txpool', 676 methods: [], 677 properties: 678 [ 679 new web3._extend.Property({ 680 name: 'content', 681 getter: 'txpool_content' 682 }), 683 new web3._extend.Property({ 684 name: 'inspect', 685 getter: 'txpool_inspect' 686 }), 687 new web3._extend.Property({ 688 name: 'status', 689 getter: 'txpool_status', 690 outputFormatter: function(status) { 691 status.pending = web3._extend.utils.toDecimal(status.pending); 692 status.queued = web3._extend.utils.toDecimal(status.queued); 693 return status; 694 } 695 }), 696 ] 697 }); 698 ` 699 700 // FsnJS wacom 701 const FsnJS = ` 702 web3._extend({ 703 property: 'fsn', 704 methods: [ 705 new web3._extend.Method({ 706 name: 'getSnapshot', 707 call: 'fsn_getSnapshot', 708 params: 1, 709 inputFormatter: [ 710 web3._extend.formatters.inputDefaultBlockNumberFormatter 711 ] 712 }), 713 new web3._extend.Method({ 714 name: 'getSnapshotAtHash', 715 call: 'fsn_getSnapshotAtHash', 716 params: 1 717 }), 718 new web3._extend.Method({ 719 name: 'getBlockReward', 720 call: 'fsn_getBlockReward', 721 params: 1, 722 inputFormatter: [ 723 web3._extend.formatters.inputDefaultBlockNumberFormatter 724 ] 725 }), 726 new web3._extend.Method({ 727 name: 'getBalance', 728 call: 'fsn_getBalance', 729 params: 3, 730 inputFormatter: [ 731 null, 732 web3._extend.formatters.inputAddressFormatter, 733 web3._extend.formatters.inputDefaultBlockNumberFormatter 734 ] 735 }), 736 new web3._extend.Method({ 737 name: 'getAllBalances', 738 call: 'fsn_getAllBalances', 739 params: 2, 740 inputFormatter: [ 741 web3._extend.formatters.inputAddressFormatter, 742 web3._extend.formatters.inputDefaultBlockNumberFormatter 743 ] 744 }), 745 new web3._extend.Method({ 746 name: 'getTimeLockBalance', 747 call: 'fsn_getTimeLockBalance', 748 params: 3, 749 inputFormatter: [ 750 null, 751 web3._extend.formatters.inputAddressFormatter, 752 web3._extend.formatters.inputDefaultBlockNumberFormatter 753 ] 754 }), 755 new web3._extend.Method({ 756 name: 'getTimeLockValueByInterval', 757 call: 'fsn_getTimeLockValueByInterval', 758 params: 5, 759 inputFormatter: [ 760 null, 761 web3._extend.formatters.inputAddressFormatter, 762 null, 763 null, 764 web3._extend.formatters.inputDefaultBlockNumberFormatter 765 ] 766 }), 767 new web3._extend.Method({ 768 name: 'getAllTimeLockBalances', 769 call: 'fsn_getAllTimeLockBalances', 770 params: 2, 771 inputFormatter: [ 772 web3._extend.formatters.inputAddressFormatter, 773 web3._extend.formatters.inputDefaultBlockNumberFormatter 774 ] 775 }), 776 new web3._extend.Method({ 777 name: 'getRawTimeLockBalance', 778 call: 'fsn_getRawTimeLockBalance', 779 params: 3, 780 inputFormatter: [ 781 null, 782 web3._extend.formatters.inputAddressFormatter, 783 web3._extend.formatters.inputDefaultBlockNumberFormatter 784 ] 785 }), 786 new web3._extend.Method({ 787 name: 'getAllRawTimeLockBalances', 788 call: 'fsn_getAllRawTimeLockBalances', 789 params: 2, 790 inputFormatter: [ 791 web3._extend.formatters.inputAddressFormatter, 792 web3._extend.formatters.inputDefaultBlockNumberFormatter 793 ] 794 }), 795 new web3._extend.Method({ 796 name: 'getNotation', 797 call: 'fsn_getNotation', 798 params: 2, 799 inputFormatter: [ 800 web3._extend.formatters.inputAddressFormatter, 801 web3._extend.formatters.inputDefaultBlockNumberFormatter 802 ] 803 }), 804 new web3._extend.Method({ 805 name: 'getAddressByNotation', 806 call: 'fsn_getAddressByNotation', 807 params: 2, 808 inputFormatter: [ 809 null, 810 web3._extend.formatters.inputDefaultBlockNumberFormatter 811 ] 812 }), 813 new web3._extend.Method({ 814 name: 'allNotation', 815 call: 'fsn_allNotation', 816 params: 1, 817 inputFormatter: [ 818 web3._extend.formatters.inputDefaultBlockNumberFormatter 819 ] 820 }), 821 new web3._extend.Method({ 822 name: 'genNotation', 823 call: 'fsn_genNotation', 824 params: 2, 825 inputFormatter: [ 826 web3._extend.formatters.inputTransactionFormatter, 827 null 828 ] 829 }), 830 new web3._extend.Method({ 831 name: 'genAsset', 832 call: 'fsn_genAsset', 833 params: 2, 834 inputFormatter: [ 835 function(options){ 836 if(options.name === undefined || !options.name){ 837 throw new Error('invalid name'); 838 } 839 if(options.symbol === undefined || !options.symbol){ 840 throw new Error('invalid symbol'); 841 } 842 if(options.decimals === undefined || options.decimals <= 0 || options.decimals > 255){ 843 throw new Error('invalid decimals'); 844 } 845 if(options.total !== undefined){ 846 options.total = web3.fromDecimal(options.total) 847 } 848 return web3._extend.formatters.inputTransactionFormatter(options) 849 }, 850 null 851 ] 852 }), 853 new web3._extend.Method({ 854 name: 'allAssets', 855 call: 'fsn_allAssets', 856 params: 1, 857 inputFormatter: [ 858 web3._extend.formatters.inputDefaultBlockNumberFormatter 859 ] 860 }), 861 new web3._extend.Method({ 862 name: 'getAsset', 863 call: 'fsn_getAsset', 864 params: 2, 865 inputFormatter: [ 866 null, 867 web3._extend.formatters.inputDefaultBlockNumberFormatter 868 ] 869 }), 870 new web3._extend.Method({ 871 name: 'sendAsset', 872 call: 'fsn_sendAsset', 873 params: 2, 874 inputFormatter: [ 875 web3._extend.formatters.inputTransactionFormatter, 876 null 877 ] 878 }), 879 new web3._extend.Method({ 880 name: 'assetToTimeLock', 881 call: 'fsn_assetToTimeLock', 882 params: 2, 883 inputFormatter: [ 884 function(options){ 885 return web3._extend.formatters.inputTransactionFormatter(options) 886 }, 887 null 888 ] 889 }), 890 new web3._extend.Method({ 891 name: 'timeLockToTimeLock', 892 call: 'fsn_timeLockToTimeLock', 893 params: 2, 894 inputFormatter: [ 895 function(options){ 896 return web3._extend.formatters.inputTransactionFormatter(options) 897 }, 898 null 899 ] 900 }), 901 new web3._extend.Method({ 902 name: 'timeLockToAsset', 903 call: 'fsn_timeLockToAsset', 904 params: 2, 905 inputFormatter: [ 906 function(options){ 907 return web3._extend.formatters.inputTransactionFormatter(options) 908 }, 909 null 910 ] 911 }), 912 new web3._extend.Method({ 913 name: 'sendTimeLock', 914 call: 'fsn_sendTimeLock', 915 params: 2, 916 inputFormatter: [ 917 web3._extend.formatters.inputTransactionFormatter, 918 null 919 ] 920 }), 921 new web3._extend.Method({ 922 name: 'allTickets', 923 call: 'fsn_allTickets', 924 params: 1, 925 inputFormatter: [ 926 web3._extend.formatters.inputDefaultBlockNumberFormatter 927 ] 928 }), 929 new web3._extend.Method({ 930 name: 'allTicketsByAddress', 931 call: 'fsn_allTicketsByAddress', 932 params: 2, 933 inputFormatter: [ 934 web3._extend.formatters.inputAddressFormatter, 935 web3._extend.formatters.inputDefaultBlockNumberFormatter 936 ] 937 }), 938 new web3._extend.Method({ 939 name: 'allInfoByAddress', 940 call: 'fsn_allInfoByAddress', 941 params: 2, 942 inputFormatter: [ 943 web3._extend.formatters.inputAddressFormatter, 944 web3._extend.formatters.inputDefaultBlockNumberFormatter 945 ] 946 }), 947 new web3._extend.Method({ 948 name: 'getTransactionAndReceipt', 949 call: 'fsn_getTransactionAndReceipt', 950 params: 1, 951 }), 952 new web3._extend.Method({ 953 name: 'allAssetsByAddress', 954 call: 'fsn_allAssetsByAddress', 955 params: 2, 956 inputFormatter: [ 957 web3._extend.formatters.inputAddressFormatter, 958 web3._extend.formatters.inputDefaultBlockNumberFormatter 959 ] 960 }), 961 new web3._extend.Method({ 962 name: 'assetExistForAddress', 963 call: 'fsn_assetExistForAddress', 964 params: 3, 965 inputFormatter: [ 966 null, 967 web3._extend.formatters.inputAddressFormatter, 968 web3._extend.formatters.inputDefaultBlockNumberFormatter 969 ] 970 }), 971 new web3._extend.Method({ 972 name: 'totalNumberOfTickets', 973 call: 'fsn_totalNumberOfTickets', 974 params: 1, 975 inputFormatter: [ 976 web3._extend.formatters.inputDefaultBlockNumberFormatter 977 ] 978 }), 979 new web3._extend.Method({ 980 name: 'totalNumberOfTicketsByAddress', 981 call: 'fsn_totalNumberOfTicketsByAddress', 982 params: 2, 983 inputFormatter: [ 984 web3._extend.formatters.inputAddressFormatter, 985 web3._extend.formatters.inputDefaultBlockNumberFormatter 986 ] 987 }), 988 new web3._extend.Method({ 989 name: 'ticketPrice', 990 call: 'fsn_ticketPrice', 991 params: 1, 992 inputFormatter: [ 993 web3._extend.formatters.inputDefaultBlockNumberFormatter 994 ] 995 }), 996 new web3._extend.Method({ 997 name: 'buyTicket', 998 call: 'fsn_buyTicket', 999 params: 2, 1000 inputFormatter: [ 1001 web3._extend.formatters.inputTransactionFormatter, 1002 null 1003 ] 1004 }), 1005 new web3._extend.Method({ 1006 name: 'incAsset', 1007 call: 'fsn_incAsset', 1008 params: 2, 1009 inputFormatter: [ 1010 web3._extend.formatters.inputTransactionFormatter, 1011 null 1012 ] 1013 }), 1014 new web3._extend.Method({ 1015 name: 'decAsset', 1016 call: 'fsn_decAsset', 1017 params: 2, 1018 inputFormatter: [ 1019 web3._extend.formatters.inputTransactionFormatter, 1020 null 1021 ] 1022 }), 1023 new web3._extend.Method({ 1024 name: 'allSwaps', 1025 call: 'fsn_allSwaps', 1026 params: 1, 1027 inputFormatter: [ 1028 web3._extend.formatters.inputDefaultBlockNumberFormatter 1029 ] 1030 }), 1031 new web3._extend.Method({ 1032 name: 'allSwapsByAddress', 1033 call: 'fsn_allSwapsByAddress', 1034 params: 2, 1035 inputFormatter: [ 1036 web3._extend.formatters.inputAddressFormatter, 1037 web3._extend.formatters.inputDefaultBlockNumberFormatter 1038 ] 1039 }), 1040 new web3._extend.Method({ 1041 name: 'makeSwap', 1042 call: 'fsn_makeSwap', 1043 params: 2, 1044 inputFormatter: [ 1045 web3._extend.formatters.inputTransactionFormatter, 1046 null 1047 ] 1048 }), 1049 new web3._extend.Method({ 1050 name: 'makeMultiSwap', 1051 call: 'fsn_makeMultiSwap', 1052 params: 2, 1053 inputFormatter: [ 1054 web3._extend.formatters.inputTransactionFormatter, 1055 null 1056 ] 1057 }), 1058 new web3._extend.Method({ 1059 name: 'recallMultiSwap', 1060 call: 'fsn_recallMultiSwap', 1061 params: 2, 1062 inputFormatter: [ 1063 web3._extend.formatters.inputTransactionFormatter, 1064 null 1065 ] 1066 }), 1067 new web3._extend.Method({ 1068 name: 'takeMultiSwap', 1069 call: 'fsn_takeMultiSwap', 1070 params: 2, 1071 inputFormatter: [ 1072 web3._extend.formatters.inputTransactionFormatter, 1073 null 1074 ] 1075 }), 1076 new web3._extend.Method({ 1077 name: 'recallSwap', 1078 call: 'fsn_recallSwap', 1079 params: 2, 1080 inputFormatter: [ 1081 web3._extend.formatters.inputTransactionFormatter, 1082 null 1083 ] 1084 }), 1085 new web3._extend.Method({ 1086 name: 'takeSwap', 1087 call: 'fsn_takeSwap', 1088 params: 2, 1089 inputFormatter: [ 1090 web3._extend.formatters.inputTransactionFormatter, 1091 null 1092 ] 1093 }), 1094 new web3._extend.Method({ 1095 name: 'getSwap', 1096 call: 'fsn_getSwap', 1097 params: 2, 1098 inputFormatter: [ 1099 null, 1100 web3._extend.formatters.inputDefaultBlockNumberFormatter 1101 ] 1102 }), 1103 new web3._extend.Method({ 1104 name: 'getMultiSwap', 1105 call: 'fsn_getMultiSwap', 1106 params: 2, 1107 inputFormatter: [ 1108 null, 1109 web3._extend.formatters.inputDefaultBlockNumberFormatter 1110 ] 1111 }), 1112 new web3._extend.Method({ 1113 name: 'getStakeInfo', 1114 call: 'fsn_getStakeInfo', 1115 params: 1, 1116 inputFormatter: [ 1117 web3._extend.formatters.inputDefaultBlockNumberFormatter 1118 ] 1119 }), 1120 new web3._extend.Method({ 1121 name: 'isAutoBuyTicket', 1122 call: 'fsn_isAutoBuyTicket', 1123 params: 0 1124 }), 1125 new web3._extend.Method({ 1126 name: 'getLatestNotation', 1127 call: 'fsn_getLatestNotation', 1128 params: 1, 1129 inputFormatter: [ 1130 web3._extend.formatters.inputDefaultBlockNumberFormatter 1131 ] 1132 }), 1133 new web3._extend.Method({ 1134 name: 'getRetreatTickets', 1135 call: 'fsn_getRetreatTickets', 1136 params: 1, 1137 inputFormatter: [ 1138 web3._extend.formatters.inputDefaultBlockNumberFormatter 1139 ] 1140 }), 1141 ], 1142 properties:[ 1143 new web3._extend.Property({ 1144 name: 'coinbase', 1145 getter: 'eth_coinbase' 1146 }), 1147 ] 1148 }); 1149 ` 1150 1151 // FsnBT wacome 1152 const FsnBT = ` 1153 web3._extend({ 1154 property: 'fsnbt', 1155 methods: [ 1156 new web3._extend.Method({ 1157 name: 'getBalance', 1158 call: 'fsn_getBalance', 1159 params: 3, 1160 inputFormatter: [ 1161 null, 1162 web3._extend.formatters.inputAddressFormatter, 1163 web3._extend.formatters.inputDefaultBlockNumberFormatter 1164 ] 1165 }), 1166 new web3._extend.Method({ 1167 name: 'getAllBalances', 1168 call: 'fsn_getAllBalances', 1169 params: 2, 1170 inputFormatter: [ 1171 web3._extend.formatters.inputAddressFormatter, 1172 web3._extend.formatters.inputDefaultBlockNumberFormatter 1173 ] 1174 }), 1175 new web3._extend.Method({ 1176 name: 'getTimeLockBalance', 1177 call: 'fsn_getTimeLockBalance', 1178 params: 3, 1179 inputFormatter: [ 1180 null, 1181 web3._extend.formatters.inputAddressFormatter, 1182 web3._extend.formatters.inputDefaultBlockNumberFormatter 1183 ] 1184 }), 1185 new web3._extend.Method({ 1186 name: 'getAllTimeLockBalances', 1187 call: 'fsn_getAllTimeLockBalances', 1188 params: 2, 1189 inputFormatter: [ 1190 web3._extend.formatters.inputAddressFormatter, 1191 web3._extend.formatters.inputDefaultBlockNumberFormatter 1192 ] 1193 }), 1194 new web3._extend.Method({ 1195 name: 'getNotation', 1196 call: 'fsn_getNotation', 1197 params: 2, 1198 inputFormatter: [ 1199 web3._extend.formatters.inputAddressFormatter, 1200 web3._extend.formatters.inputDefaultBlockNumberFormatter 1201 ] 1202 }), 1203 new web3._extend.Method({ 1204 name: 'getAddressByNotation', 1205 call: 'fsn_getAddressByNotation', 1206 params: 2, 1207 inputFormatter: [ 1208 null, 1209 web3._extend.formatters.inputDefaultBlockNumberFormatter 1210 ] 1211 }), 1212 new web3._extend.Method({ 1213 name: 'allTickets', 1214 call: 'fsn_allTickets', 1215 params: 1, 1216 inputFormatter: [ 1217 web3._extend.formatters.inputDefaultBlockNumberFormatter 1218 ] 1219 }), 1220 new web3._extend.Method({ 1221 name: 'allTicketsByAddress', 1222 call: 'fsn_allTicketsByAddress', 1223 params: 2, 1224 inputFormatter: [ 1225 web3._extend.formatters.inputAddressFormatter, 1226 web3._extend.formatters.inputDefaultBlockNumberFormatter 1227 ] 1228 }), 1229 new web3._extend.Method({ 1230 name: 'allInfoByAddress', 1231 call: 'fsn_allInfoByAddress', 1232 params: 2, 1233 inputFormatter: [ 1234 web3._extend.formatters.inputAddressFormatter, 1235 web3._extend.formatters.inputDefaultBlockNumberFormatter 1236 ] 1237 }), 1238 new web3._extend.Method({ 1239 name: 'getTransactionAndReceipt', 1240 call: 'fsn_getTransactionAndReceipt', 1241 params: 1, 1242 }), 1243 new web3._extend.Method({ 1244 name: 'totalNumberOfTickets', 1245 call: 'fsn_totalNumberOfTickets', 1246 params: 1, 1247 inputFormatter: [ 1248 web3._extend.formatters.inputDefaultBlockNumberFormatter 1249 ] 1250 }), 1251 new web3._extend.Method({ 1252 name: 'totalNumberOfTicketsByAddress', 1253 call: 'fsn_totalNumberOfTicketsByAddress', 1254 params: 2, 1255 inputFormatter: [ 1256 web3._extend.formatters.inputAddressFormatter, 1257 web3._extend.formatters.inputDefaultBlockNumberFormatter 1258 ] 1259 }), 1260 new web3._extend.Method({ 1261 name: 'ticketPrice', 1262 call: 'fsn_ticketPrice', 1263 params: 1, 1264 inputFormatter: [ 1265 web3._extend.formatters.inputDefaultBlockNumberFormatter 1266 ] 1267 }), 1268 new web3._extend.Method({ 1269 name: 'buyTicket', 1270 call: 'fsn_buyTicket', 1271 params: 2, 1272 inputFormatter: [ 1273 web3._extend.formatters.inputTransactionFormatter, 1274 null 1275 ] 1276 }), 1277 new web3._extend.Method({ 1278 name: 'isAutoBuyTicket', 1279 call: 'fsn_isAutoBuyTicket', 1280 params: 0 1281 }), 1282 ] 1283 }); 1284 ` 1285 1286 // FsnTxJS wacom 1287 const FsnTxJS = ` 1288 web3._extend({ 1289 property: 'fsntx', 1290 methods: [ 1291 new web3._extend.Method({ 1292 name: 'sendRawTransaction', 1293 call: 'fsntx_sendRawTransaction', 1294 params: 1 1295 }), 1296 new web3._extend.Method({ 1297 name: 'buildGenNotationTx', 1298 call: 'fsntx_buildGenNotationTx', 1299 params: 1, 1300 inputFormatter: [ 1301 web3._extend.formatters.inputTransactionFormatter 1302 ] 1303 }), 1304 new web3._extend.Method({ 1305 name: 'genNotation', 1306 call: 'fsntx_genNotation', 1307 params: 1, 1308 inputFormatter: [ 1309 web3._extend.formatters.inputTransactionFormatter, 1310 ] 1311 }), 1312 new web3._extend.Method({ 1313 name: 'buildGenAssetTx', 1314 call: 'fsntx_buildGenAssetTx', 1315 params: 1, 1316 inputFormatter: [ 1317 function(options){ 1318 if(options.name === undefined || !options.name){ 1319 throw new Error('invalid name'); 1320 } 1321 if(options.symbol === undefined || !options.symbol){ 1322 throw new Error('invalid symbol'); 1323 } 1324 if(options.decimals === undefined || options.decimals <= 0 || options.decimals > 255){ 1325 throw new Error('invalid decimals'); 1326 } 1327 if(options.total !== undefined){ 1328 options.total = web3.fromDecimal(options.total) 1329 } 1330 return web3._extend.formatters.inputTransactionFormatter(options) 1331 } 1332 ] 1333 }), 1334 new web3._extend.Method({ 1335 name: 'genAsset', 1336 call: 'fsntx_genAsset', 1337 params: 1, 1338 inputFormatter: [ 1339 function(options){ 1340 if(options.name === undefined || !options.name){ 1341 throw new Error('invalid name'); 1342 } 1343 if(options.symbol === undefined || !options.symbol){ 1344 throw new Error('invalid symbol'); 1345 } 1346 if(options.decimals === undefined || options.decimals <= 0 || options.decimals > 255){ 1347 throw new Error('invalid decimals'); 1348 } 1349 if(options.total !== undefined){ 1350 options.total = web3.fromDecimal(options.total) 1351 } 1352 return web3._extend.formatters.inputTransactionFormatter(options) 1353 } 1354 ] 1355 }), 1356 new web3._extend.Method({ 1357 name: 'buildSendAssetTx', 1358 call: 'fsntx_buildSendAssetTx', 1359 params: 1, 1360 inputFormatter: [ 1361 web3._extend.formatters.inputTransactionFormatter 1362 ] 1363 }), 1364 new web3._extend.Method({ 1365 name: 'sendAsset', 1366 call: 'fsntx_sendAsset', 1367 params: 1, 1368 inputFormatter: [ 1369 web3._extend.formatters.inputTransactionFormatter 1370 ] 1371 }), 1372 new web3._extend.Method({ 1373 name: 'buildAssetToTimeLockTx', 1374 call: 'fsntx_buildAssetToTimeLockTx', 1375 params: 1, 1376 inputFormatter: [ 1377 function(options){ 1378 return web3._extend.formatters.inputTransactionFormatter(options) 1379 } 1380 ] 1381 }), 1382 new web3._extend.Method({ 1383 name: 'assetToTimeLock', 1384 call: 'fsntx_assetToTimeLock', 1385 params: 1, 1386 inputFormatter: [ 1387 function(options){ 1388 return web3._extend.formatters.inputTransactionFormatter(options) 1389 } 1390 ] 1391 }), 1392 new web3._extend.Method({ 1393 name: 'buildTimeLockToTimeLockTx', 1394 call: 'fsntx_buildTimeLockToTimeLockTx', 1395 params: 1, 1396 inputFormatter: [ 1397 function(options){ 1398 return web3._extend.formatters.inputTransactionFormatter(options) 1399 } 1400 ] 1401 }), 1402 new web3._extend.Method({ 1403 name: 'timeLockToTimeLock', 1404 call: 'fsntx_timeLockToTimeLock', 1405 params: 1, 1406 inputFormatter: [ 1407 function(options){ 1408 return web3._extend.formatters.inputTransactionFormatter(options) 1409 } 1410 ] 1411 }), 1412 new web3._extend.Method({ 1413 name: 'buildTimeLockToAssetTx', 1414 call: 'fsntx_buildTimeLockToAssetTx', 1415 params: 1, 1416 inputFormatter: [ 1417 function(options){ 1418 return web3._extend.formatters.inputTransactionFormatter(options) 1419 } 1420 ] 1421 }), 1422 new web3._extend.Method({ 1423 name: 'timeLockToAsset', 1424 call: 'fsntx_timeLockToAsset', 1425 params: 1, 1426 inputFormatter: [ 1427 function(options){ 1428 return web3._extend.formatters.inputTransactionFormatter(options) 1429 } 1430 ] 1431 }), 1432 new web3._extend.Method({ 1433 name: 'buildSendTimeLockTx', 1434 call: 'fsntx_buildSendTimeLockTx', 1435 params: 1, 1436 inputFormatter: [ 1437 web3._extend.formatters.inputTransactionFormatter 1438 ] 1439 }), 1440 new web3._extend.Method({ 1441 name: 'sendTimeLock', 1442 call: 'fsntx_sendTimeLock', 1443 params: 1, 1444 inputFormatter: [ 1445 web3._extend.formatters.inputTransactionFormatter 1446 ] 1447 }), 1448 new web3._extend.Method({ 1449 name: 'buildBuyTicketTx', 1450 call: 'fsntx_buildBuyTicketTx', 1451 params: 1, 1452 inputFormatter: [ 1453 web3._extend.formatters.inputTransactionFormatter 1454 ] 1455 }), 1456 new web3._extend.Method({ 1457 name: 'buyTicket', 1458 call: 'fsntx_buyTicket', 1459 params: 1, 1460 inputFormatter: [ 1461 web3._extend.formatters.inputTransactionFormatter 1462 ] 1463 }), 1464 new web3._extend.Method({ 1465 name: 'buildIncAssetTx', 1466 call: 'fsntx_buildIncAssetTx', 1467 params: 1, 1468 inputFormatter: [ 1469 web3._extend.formatters.inputTransactionFormatter 1470 ] 1471 }), 1472 new web3._extend.Method({ 1473 name: 'incAsset', 1474 call: 'fsntx_incAsset', 1475 params: 1, 1476 inputFormatter: [ 1477 web3._extend.formatters.inputTransactionFormatter 1478 ] 1479 }), 1480 new web3._extend.Method({ 1481 name: 'buildDecAssetTx', 1482 call: 'fsntx_buildDecAssetTx', 1483 params: 1, 1484 inputFormatter: [ 1485 web3._extend.formatters.inputTransactionFormatter 1486 ] 1487 }), 1488 new web3._extend.Method({ 1489 name: 'decAsset', 1490 call: 'fsntx_decAsset', 1491 params: 1, 1492 inputFormatter: [ 1493 web3._extend.formatters.inputTransactionFormatter 1494 ] 1495 }), 1496 new web3._extend.Method({ 1497 name: 'buildMakeSwapTx', 1498 call: 'fsntx_buildMakeSwapTx', 1499 params: 1, 1500 inputFormatter: [ 1501 web3._extend.formatters.inputTransactionFormatter 1502 ] 1503 }), 1504 new web3._extend.Method({ 1505 name: 'makeSwap', 1506 call: 'fsntx_makeSwap', 1507 params: 1, 1508 inputFormatter: [ 1509 web3._extend.formatters.inputTransactionFormatter 1510 ] 1511 }), 1512 new web3._extend.Method({ 1513 name: 'buildRecallSwapTx', 1514 call: 'fsntx_buildRecallSwapTx', 1515 params: 1, 1516 inputFormatter: [ 1517 web3._extend.formatters.inputTransactionFormatter 1518 ] 1519 }), 1520 new web3._extend.Method({ 1521 name: 'recallSwap', 1522 call: 'fsntx_recallSwap', 1523 params: 1, 1524 inputFormatter: [ 1525 web3._extend.formatters.inputTransactionFormatter 1526 ] 1527 }), 1528 new web3._extend.Method({ 1529 name: 'buildTakeSwapTx', 1530 call: 'fsntx_buildTakeSwapTx', 1531 params: 1, 1532 inputFormatter: [ 1533 web3._extend.formatters.inputTransactionFormatter 1534 ] 1535 }), 1536 new web3._extend.Method({ 1537 name: 'takeSwap', 1538 call: 'fsntx_takeSwap', 1539 params: 1, 1540 inputFormatter: [ 1541 web3._extend.formatters.inputTransactionFormatter 1542 ] 1543 }), 1544 new web3._extend.Method({ 1545 name: 'buildMakeMultiSwapTx', 1546 call: 'fsntx_buildMakeMultiSwapTx', 1547 params: 1, 1548 inputFormatter: [ 1549 web3._extend.formatters.inputTransactionFormatter 1550 ] 1551 }), 1552 new web3._extend.Method({ 1553 name: 'makeMultiSwap', 1554 call: 'fsntx_makeMultiSwap', 1555 params: 1, 1556 inputFormatter: [ 1557 web3._extend.formatters.inputTransactionFormatter 1558 ] 1559 }), 1560 new web3._extend.Method({ 1561 name: 'buildRecallMultiSwapTx', 1562 call: 'fsntx_buildRecallMultiSwapTx', 1563 params: 1, 1564 inputFormatter: [ 1565 web3._extend.formatters.inputTransactionFormatter 1566 ] 1567 }), 1568 new web3._extend.Method({ 1569 name: 'recallMultiSwap', 1570 call: 'fsntx_recallMultiSwap', 1571 params: 1, 1572 inputFormatter: [ 1573 web3._extend.formatters.inputTransactionFormatter 1574 ] 1575 }), 1576 new web3._extend.Method({ 1577 name: 'buildTakeMultiSwapTx', 1578 call: 'fsntx_buildTakeMultiSwapTx', 1579 params: 1, 1580 inputFormatter: [ 1581 web3._extend.formatters.inputTransactionFormatter 1582 ] 1583 }), 1584 new web3._extend.Method({ 1585 name: 'takeMultiSwap', 1586 call: 'fsntx_takeMultiSwap', 1587 params: 1, 1588 inputFormatter: [ 1589 web3._extend.formatters.inputTransactionFormatter 1590 ] 1591 }), 1592 ] 1593 }); 1594 `