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