github.com/hashgraph/hedera-sdk-go/v2@v2.48.0/contract_function_selector.go (about) 1 package hedera 2 3 /*- 4 * 5 * Hedera Go SDK 6 * 7 * Copyright (C) 2020 - 2024 Hedera Hashgraph, LLC 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 * 21 */ 22 23 import ( 24 "golang.org/x/crypto/sha3" 25 ) 26 27 // A selector for a function with a given name. 28 type ContractFunctionSelector struct { 29 function *string 30 params string 31 paramTypes []_Solidity 32 } 33 34 type _Solidity struct { 35 ty argument 36 array bool 37 } 38 39 type argument string 40 41 const ( 42 aBool argument = "bool" 43 aString argument = "string" 44 aInt8 argument = "int8" 45 aInt16 argument = "int16" 46 aInt24 argument = "int24" 47 aInt32 argument = "int32" 48 aInt40 argument = "int40" 49 aInt48 argument = "int48" 50 aInt56 argument = "int56" 51 aInt64 argument = "int64" 52 aInt72 argument = "int72" 53 aInt80 argument = "int80" 54 aInt88 argument = "int88" 55 aInt96 argument = "int96" 56 aInt104 argument = "int104" 57 aInt112 argument = "int112" 58 aInt120 argument = "int120" 59 aInt128 argument = "int128" 60 aInt136 argument = "int136" 61 aInt144 argument = "int144" 62 aInt152 argument = "int152" 63 aInt160 argument = "int160" 64 aInt168 argument = "int168" 65 aInt176 argument = "int176" 66 aInt184 argument = "int184" 67 aInt192 argument = "int192" 68 aInt200 argument = "int200" 69 aInt208 argument = "int208" 70 aInt216 argument = "int216" 71 aInt224 argument = "int224" 72 aInt232 argument = "int232" 73 aInt240 argument = "int240" 74 aInt248 argument = "int248" 75 aInt256 argument = "int256" 76 aUint8 argument = "uint8" 77 aUint16 argument = "uint16" 78 aUint24 argument = "uint24" 79 aUint32 argument = "uint32" 80 aUint40 argument = "uint40" 81 aUint48 argument = "uint48" 82 aUint56 argument = "uint56" 83 aUint64 argument = "uint64" 84 aUint72 argument = "uint72" 85 aUint80 argument = "uint80" 86 aUint88 argument = "uint88" 87 aUint96 argument = "uint96" 88 aUint104 argument = "uint104" 89 aUint112 argument = "uint112" 90 aUint120 argument = "uint120" 91 aUint128 argument = "uint128" 92 aUint136 argument = "uint136" 93 aUint144 argument = "uint144" 94 aUint152 argument = "uint152" 95 aUint160 argument = "uint160" 96 aUint168 argument = "uint168" 97 aUint176 argument = "uint176" 98 aUint184 argument = "uint184" 99 aUint192 argument = "uint192" 100 aUint200 argument = "uint200" 101 aUint208 argument = "uint208" 102 aUint216 argument = "uint216" 103 aUint224 argument = "uint224" 104 aUint232 argument = "uint232" 105 aUint240 argument = "uint240" 106 aUint248 argument = "uint248" 107 aUint256 argument = "uint256" 108 aBytes argument = "bytes" 109 aBytes32 argument = "bytes32" 110 aFunction argument = "function" 111 aAddress argument = "address" 112 ) 113 114 // NewContractFunctionSelector starts building a selector for a function with a given name. 115 func NewContractFunctionSelector(name string) ContractFunctionSelector { 116 var function *string 117 118 if name == "" { 119 function = nil 120 } else { 121 function = &name 122 } 123 124 return ContractFunctionSelector{ 125 function: function, 126 params: "", 127 paramTypes: []_Solidity{}, 128 } 129 } 130 131 // AddParam adds a parameter to the selector. 132 func (selector *ContractFunctionSelector) _AddParam(ty _Solidity) *ContractFunctionSelector { 133 if len(selector.paramTypes) > 0 { 134 selector.params += "," 135 } 136 137 selector.params += string(ty.ty) 138 if ty.array { 139 selector.params += "[]" 140 } 141 142 selector.paramTypes = append(selector.paramTypes, ty) 143 return selector 144 } 145 146 // AddFunction adds a function parameter to the selector. 147 func (selector *ContractFunctionSelector) AddFunction() *ContractFunctionSelector { 148 return selector._AddParam(_Solidity{ 149 ty: aFunction, 150 array: false, 151 }) 152 } 153 154 // AddAddress adds an address parameter to the selector. 155 func (selector *ContractFunctionSelector) AddAddress() *ContractFunctionSelector { 156 return selector._AddParam(_Solidity{ 157 ty: aAddress, 158 array: false, 159 }) 160 } 161 162 // AddBool adds a bool parameter to the selector. 163 func (selector *ContractFunctionSelector) AddBool() *ContractFunctionSelector { 164 return selector._AddParam(_Solidity{ 165 ty: aBool, 166 array: false, 167 }) 168 } 169 170 // AddString adds a string parameter to the selector. 171 func (selector *ContractFunctionSelector) AddString() *ContractFunctionSelector { 172 return selector._AddParam(_Solidity{ 173 ty: aString, 174 array: false, 175 }) 176 } 177 178 // AddInt8 adds an int8 parameter to the selector. 179 func (selector *ContractFunctionSelector) AddInt8() *ContractFunctionSelector { 180 return selector._AddParam(_Solidity{ 181 ty: aInt8, 182 array: false, 183 }) 184 } 185 186 // AddInt16 adds an int16 parameter to the selector. 187 func (selector *ContractFunctionSelector) AddInt16() *ContractFunctionSelector { 188 return selector._AddParam(_Solidity{ 189 ty: aInt16, 190 array: false, 191 }) 192 } 193 194 // AddInt24 adds an int24 parameter to the selector. 195 func (selector *ContractFunctionSelector) AddInt24() *ContractFunctionSelector { 196 return selector._AddParam(_Solidity{ 197 ty: aInt24, 198 array: false, 199 }) 200 } 201 202 // AddInt32 adds an int32 parameter to the selector. 203 func (selector *ContractFunctionSelector) AddInt32() *ContractFunctionSelector { 204 return selector._AddParam(_Solidity{ 205 ty: aInt32, 206 array: false, 207 }) 208 } 209 210 // AddInt40 adds an int40 parameter to the selector. 211 func (selector *ContractFunctionSelector) AddInt40() *ContractFunctionSelector { 212 return selector._AddParam(_Solidity{ 213 ty: aInt40, 214 array: false, 215 }) 216 } 217 218 // AddInt48 adds an int48 parameter to the selector. 219 func (selector *ContractFunctionSelector) AddInt48() *ContractFunctionSelector { 220 return selector._AddParam(_Solidity{ 221 ty: aInt48, 222 array: false, 223 }) 224 } 225 226 // AddInt56 adds an int56 parameter to the selector. 227 func (selector *ContractFunctionSelector) AddInt56() *ContractFunctionSelector { 228 return selector._AddParam(_Solidity{ 229 ty: aInt56, 230 array: false, 231 }) 232 } 233 234 // AddInt64 adds an int64 parameter to the selector. 235 func (selector *ContractFunctionSelector) AddInt64() *ContractFunctionSelector { 236 return selector._AddParam(_Solidity{ 237 ty: aInt64, 238 array: false, 239 }) 240 } 241 242 // AddInt72 adds an int72 parameter to the selector. 243 func (selector *ContractFunctionSelector) AddInt72() *ContractFunctionSelector { 244 return selector._AddParam(_Solidity{ 245 ty: aInt72, 246 array: false, 247 }) 248 } 249 250 // AddInt80 adds an int80 parameter to the selector. 251 func (selector *ContractFunctionSelector) AddInt80() *ContractFunctionSelector { 252 return selector._AddParam(_Solidity{ 253 ty: aInt80, 254 array: false, 255 }) 256 } 257 258 // AddInt88 adds an int88 parameter to the selector. 259 func (selector *ContractFunctionSelector) AddInt88() *ContractFunctionSelector { 260 return selector._AddParam(_Solidity{ 261 ty: aInt88, 262 array: false, 263 }) 264 } 265 266 // AddInt96 adds an int96 parameter to the selector. 267 func (selector *ContractFunctionSelector) AddInt96() *ContractFunctionSelector { 268 return selector._AddParam(_Solidity{ 269 ty: aInt96, 270 array: false, 271 }) 272 } 273 274 // AddInt104 adds an int104 parameter to the selector. 275 func (selector *ContractFunctionSelector) AddInt104() *ContractFunctionSelector { 276 return selector._AddParam(_Solidity{ 277 ty: aInt104, 278 array: false, 279 }) 280 } 281 282 // AddInt112 adds an int112 parameter to the selector. 283 func (selector *ContractFunctionSelector) AddInt112() *ContractFunctionSelector { 284 return selector._AddParam(_Solidity{ 285 ty: aInt112, 286 array: false, 287 }) 288 } 289 290 // AddInt120 adds an int120 parameter to the selector. 291 func (selector *ContractFunctionSelector) AddInt120() *ContractFunctionSelector { 292 return selector._AddParam(_Solidity{ 293 ty: aInt120, 294 array: false, 295 }) 296 } 297 298 // AddInt128 adds an int128 parameter to the selector. 299 func (selector *ContractFunctionSelector) AddInt128() *ContractFunctionSelector { 300 return selector._AddParam(_Solidity{ 301 ty: aInt128, 302 array: false, 303 }) 304 } 305 306 // AddInt136 adds an int136 parameter to the selector. 307 func (selector *ContractFunctionSelector) AddInt136() *ContractFunctionSelector { 308 return selector._AddParam(_Solidity{ 309 ty: aInt136, 310 array: false, 311 }) 312 } 313 314 // AddInt144 adds an int144 parameter to the selector. 315 func (selector *ContractFunctionSelector) AddInt144() *ContractFunctionSelector { 316 return selector._AddParam(_Solidity{ 317 ty: aInt144, 318 array: false, 319 }) 320 } 321 322 // AddInt152 adds an int152 parameter to the selector. 323 func (selector *ContractFunctionSelector) AddInt152() *ContractFunctionSelector { 324 return selector._AddParam(_Solidity{ 325 ty: aInt152, 326 array: false, 327 }) 328 } 329 330 // AddInt160 adds an int160 parameter to the selector. 331 func (selector *ContractFunctionSelector) AddInt160() *ContractFunctionSelector { 332 return selector._AddParam(_Solidity{ 333 ty: aInt160, 334 array: false, 335 }) 336 } 337 338 // AddInt168 adds an int168 parameter to the selector. 339 func (selector *ContractFunctionSelector) AddInt168() *ContractFunctionSelector { 340 return selector._AddParam(_Solidity{ 341 ty: aInt168, 342 array: false, 343 }) 344 } 345 346 // AddInt176 adds an int176 parameter to the selector. 347 func (selector *ContractFunctionSelector) AddInt176() *ContractFunctionSelector { 348 return selector._AddParam(_Solidity{ 349 ty: aInt176, 350 array: false, 351 }) 352 } 353 354 // AddInt184 adds an int184 parameter to the selector. 355 func (selector *ContractFunctionSelector) AddInt184() *ContractFunctionSelector { 356 return selector._AddParam(_Solidity{ 357 ty: aInt184, 358 array: false, 359 }) 360 } 361 362 // AddInt192 adds an int192 parameter to the selector. 363 func (selector *ContractFunctionSelector) AddInt192() *ContractFunctionSelector { 364 return selector._AddParam(_Solidity{ 365 ty: aInt192, 366 array: false, 367 }) 368 } 369 370 // AddInt200 adds an int200 parameter to the selector. 371 func (selector *ContractFunctionSelector) AddInt200() *ContractFunctionSelector { 372 return selector._AddParam(_Solidity{ 373 ty: aInt200, 374 array: false, 375 }) 376 } 377 378 // AddInt208 adds an int208 parameter to the selector. 379 func (selector *ContractFunctionSelector) AddInt208() *ContractFunctionSelector { 380 return selector._AddParam(_Solidity{ 381 ty: aInt208, 382 array: false, 383 }) 384 } 385 386 // AddInt216 adds an int216 parameter to the selector. 387 func (selector *ContractFunctionSelector) AddInt216() *ContractFunctionSelector { 388 return selector._AddParam(_Solidity{ 389 ty: aInt216, 390 array: false, 391 }) 392 } 393 394 // AddInt224 adds an int224 parameter to the selector. 395 func (selector *ContractFunctionSelector) AddInt224() *ContractFunctionSelector { 396 return selector._AddParam(_Solidity{ 397 ty: aInt224, 398 array: false, 399 }) 400 } 401 402 // AddInt232 adds an int232 parameter to the selector. 403 func (selector *ContractFunctionSelector) AddInt232() *ContractFunctionSelector { 404 return selector._AddParam(_Solidity{ 405 ty: aInt232, 406 array: false, 407 }) 408 } 409 410 // AddInt240 adds an int240 parameter to the selector. 411 func (selector *ContractFunctionSelector) AddInt240() *ContractFunctionSelector { 412 return selector._AddParam(_Solidity{ 413 ty: aInt240, 414 array: false, 415 }) 416 } 417 418 // AddInt248 adds an int248 parameter to the selector. 419 func (selector *ContractFunctionSelector) AddInt248() *ContractFunctionSelector { 420 return selector._AddParam(_Solidity{ 421 ty: aInt248, 422 array: false, 423 }) 424 } 425 426 // AddInt256 adds an int256 parameter to the selector. 427 func (selector *ContractFunctionSelector) AddInt256() *ContractFunctionSelector { 428 return selector._AddParam(_Solidity{ 429 ty: aInt256, 430 array: false, 431 }) 432 } 433 434 // AddUint8 adds a uint8 parameter to the selector. 435 func (selector *ContractFunctionSelector) AddUint8() *ContractFunctionSelector { 436 return selector._AddParam(_Solidity{ 437 ty: aUint8, 438 array: false, 439 }) 440 } 441 442 // AddUint16 adds a uint16 parameter to the selector. 443 func (selector *ContractFunctionSelector) AddUint16() *ContractFunctionSelector { 444 return selector._AddParam(_Solidity{ 445 ty: aUint16, 446 array: false, 447 }) 448 } 449 450 // AddUint24 adds a uint24 parameter to the selector. 451 func (selector *ContractFunctionSelector) AddUint24() *ContractFunctionSelector { 452 return selector._AddParam(_Solidity{ 453 ty: aUint24, 454 array: false, 455 }) 456 } 457 458 // AddUint32 adds a uint32 parameter to the selector. 459 func (selector *ContractFunctionSelector) AddUint32() *ContractFunctionSelector { 460 return selector._AddParam(_Solidity{ 461 ty: aUint32, 462 array: false, 463 }) 464 } 465 466 // AddUint40 adds a uint40 parameter to the selector. 467 func (selector *ContractFunctionSelector) AddUint40() *ContractFunctionSelector { 468 return selector._AddParam(_Solidity{ 469 ty: aUint40, 470 array: false, 471 }) 472 } 473 474 // AddUint48 adds a uint48 parameter to the selector. 475 func (selector *ContractFunctionSelector) AddUint48() *ContractFunctionSelector { 476 return selector._AddParam(_Solidity{ 477 ty: aUint48, 478 array: false, 479 }) 480 } 481 482 // AddUint56 adds a uint56 parameter to the selector. 483 func (selector *ContractFunctionSelector) AddUint56() *ContractFunctionSelector { 484 return selector._AddParam(_Solidity{ 485 ty: aUint56, 486 array: false, 487 }) 488 } 489 490 // AddUint64 adds a uint64 parameter to the selector. 491 func (selector *ContractFunctionSelector) AddUint64() *ContractFunctionSelector { 492 return selector._AddParam(_Solidity{ 493 ty: aUint64, 494 array: false, 495 }) 496 } 497 498 // AddUint72 adds a uint72 parameter to the selector. 499 func (selector *ContractFunctionSelector) AddUint72() *ContractFunctionSelector { 500 return selector._AddParam(_Solidity{ 501 ty: aUint72, 502 array: false, 503 }) 504 } 505 506 // AddUint80 adds a uint80 parameter to the selector. 507 func (selector *ContractFunctionSelector) AddUint80() *ContractFunctionSelector { 508 return selector._AddParam(_Solidity{ 509 ty: aUint80, 510 array: false, 511 }) 512 } 513 514 // AddUint88 adds a uint88 parameter to the selector. 515 func (selector *ContractFunctionSelector) AddUint88() *ContractFunctionSelector { 516 return selector._AddParam(_Solidity{ 517 ty: aUint88, 518 array: false, 519 }) 520 } 521 522 // AddUint96 adds a uint96 parameter to the selector. 523 func (selector *ContractFunctionSelector) AddUint96() *ContractFunctionSelector { 524 return selector._AddParam(_Solidity{ 525 ty: aUint96, 526 array: false, 527 }) 528 } 529 530 // AddUint104 adds a uint104 parameter to the selector. 531 func (selector *ContractFunctionSelector) AddUint104() *ContractFunctionSelector { 532 return selector._AddParam(_Solidity{ 533 ty: aUint104, 534 array: false, 535 }) 536 } 537 538 // AddUint112 adds a uint112 parameter to the selector. 539 func (selector *ContractFunctionSelector) AddUint112() *ContractFunctionSelector { 540 return selector._AddParam(_Solidity{ 541 ty: aUint112, 542 array: false, 543 }) 544 } 545 546 // AddUint120 adds a uint120 parameter to the selector. 547 func (selector *ContractFunctionSelector) AddUint120() *ContractFunctionSelector { 548 return selector._AddParam(_Solidity{ 549 ty: aUint120, 550 array: false, 551 }) 552 } 553 554 // AddUint128 adds a uint128 parameter to the selector. 555 func (selector *ContractFunctionSelector) AddUint128() *ContractFunctionSelector { 556 return selector._AddParam(_Solidity{ 557 ty: aUint128, 558 array: false, 559 }) 560 } 561 562 // AddUint136 adds a uint136 parameter to the selector. 563 func (selector *ContractFunctionSelector) AddUint136() *ContractFunctionSelector { 564 return selector._AddParam(_Solidity{ 565 ty: aUint136, 566 array: false, 567 }) 568 } 569 570 // AddUint144 adds a uint144 parameter to the selector. 571 func (selector *ContractFunctionSelector) AddUint144() *ContractFunctionSelector { 572 return selector._AddParam(_Solidity{ 573 ty: aUint144, 574 array: false, 575 }) 576 } 577 578 // AddUint152 adds a uint152 parameter to the selector. 579 func (selector *ContractFunctionSelector) AddUint152() *ContractFunctionSelector { 580 return selector._AddParam(_Solidity{ 581 ty: aUint152, 582 array: false, 583 }) 584 } 585 586 // AddUint160 adds a uint160 parameter to the selector. 587 func (selector *ContractFunctionSelector) AddUint160() *ContractFunctionSelector { 588 return selector._AddParam(_Solidity{ 589 ty: aUint160, 590 array: false, 591 }) 592 } 593 594 // AddUint168 adds a uint168 parameter to the selector. 595 func (selector *ContractFunctionSelector) AddUint168() *ContractFunctionSelector { 596 return selector._AddParam(_Solidity{ 597 ty: aUint168, 598 array: false, 599 }) 600 } 601 602 // AddUint176 adds a uint176 parameter to the selector. 603 func (selector *ContractFunctionSelector) AddUint176() *ContractFunctionSelector { 604 return selector._AddParam(_Solidity{ 605 ty: aUint176, 606 array: false, 607 }) 608 } 609 610 // AddUint184 adds a uint184 parameter to the selector. 611 func (selector *ContractFunctionSelector) AddUint184() *ContractFunctionSelector { 612 return selector._AddParam(_Solidity{ 613 ty: aUint184, 614 array: false, 615 }) 616 } 617 618 // AddUint192 adds a uint192 parameter to the selector. 619 func (selector *ContractFunctionSelector) AddUint192() *ContractFunctionSelector { 620 return selector._AddParam(_Solidity{ 621 ty: aUint192, 622 array: false, 623 }) 624 } 625 626 // AddUint200 adds a uint200 parameter to the selector. 627 func (selector *ContractFunctionSelector) AddUint200() *ContractFunctionSelector { 628 return selector._AddParam(_Solidity{ 629 ty: aUint200, 630 array: false, 631 }) 632 } 633 634 // AddUint208 adds a uint208 parameter to the selector. 635 func (selector *ContractFunctionSelector) AddUint208() *ContractFunctionSelector { 636 return selector._AddParam(_Solidity{ 637 ty: aUint208, 638 array: false, 639 }) 640 } 641 642 // AddUint216 adds a uint216 parameter to the selector. 643 func (selector *ContractFunctionSelector) AddUint216() *ContractFunctionSelector { 644 return selector._AddParam(_Solidity{ 645 ty: aUint216, 646 array: false, 647 }) 648 } 649 650 // AddUint224 adds a uint224 parameter to the selector. 651 func (selector *ContractFunctionSelector) AddUint224() *ContractFunctionSelector { 652 return selector._AddParam(_Solidity{ 653 ty: aUint224, 654 array: false, 655 }) 656 } 657 658 // AddUint232 adds a uint232 parameter to the selector. 659 func (selector *ContractFunctionSelector) AddUint232() *ContractFunctionSelector { 660 return selector._AddParam(_Solidity{ 661 ty: aUint232, 662 array: false, 663 }) 664 } 665 666 // AddUint240 adds a uint240 parameter to the selector. 667 func (selector *ContractFunctionSelector) AddUint240() *ContractFunctionSelector { 668 return selector._AddParam(_Solidity{ 669 ty: aUint240, 670 array: false, 671 }) 672 } 673 674 // AddUint248 adds a uint248 parameter to the selector. 675 func (selector *ContractFunctionSelector) AddUint248() *ContractFunctionSelector { 676 return selector._AddParam(_Solidity{ 677 ty: aUint248, 678 array: false, 679 }) 680 } 681 682 // AddUint256 adds a uint256 parameter to the selector. 683 func (selector *ContractFunctionSelector) AddUint256() *ContractFunctionSelector { 684 return selector._AddParam(_Solidity{ 685 ty: aUint256, 686 array: false, 687 }) 688 } 689 690 // AddBytes adds a bytes parameter to the selector. 691 func (selector *ContractFunctionSelector) AddBytes() *ContractFunctionSelector { 692 return selector._AddParam(_Solidity{ 693 ty: aBytes, 694 array: false, 695 }) 696 } 697 698 // AddBytes32 adds a bytes32 parameter to the selector. 699 func (selector *ContractFunctionSelector) AddBytes32() *ContractFunctionSelector { 700 return selector._AddParam(_Solidity{ 701 ty: aBytes32, 702 array: false, 703 }) 704 } 705 706 // AddAddressArray adds an address[] parameter to the selector. 707 func (selector *ContractFunctionSelector) AddAddressArray() *ContractFunctionSelector { 708 return selector._AddParam(_Solidity{ 709 ty: aAddress, 710 array: true, 711 }) 712 } 713 714 // AddBoolArray adds a bool[] parameter to the selector. 715 func (selector *ContractFunctionSelector) AddBoolArray() *ContractFunctionSelector { 716 return selector._AddParam(_Solidity{ 717 ty: aBool, 718 array: true, 719 }) 720 } 721 722 // AddStringArray adds a string[] parameter to the selector. 723 func (selector *ContractFunctionSelector) AddStringArray() *ContractFunctionSelector { 724 return selector._AddParam(_Solidity{ 725 ty: aString, 726 array: true, 727 }) 728 } 729 730 // AddInt8Array adds an int8[] parameter to the selector. 731 func (selector *ContractFunctionSelector) AddInt8Array() *ContractFunctionSelector { 732 return selector._AddParam(_Solidity{ 733 ty: aInt8, 734 array: true, 735 }) 736 } 737 738 // AddInt32Array adds an int32[] parameter to the selector. 739 func (selector *ContractFunctionSelector) AddInt32Array() *ContractFunctionSelector { 740 return selector._AddParam(_Solidity{ 741 ty: aInt32, 742 array: true, 743 }) 744 } 745 746 // AddInt64Array adds an int64[] parameter to the selector. 747 func (selector *ContractFunctionSelector) AddInt64Array() *ContractFunctionSelector { 748 return selector._AddParam(_Solidity{ 749 ty: aInt64, 750 array: true, 751 }) 752 } 753 754 // AddInt256Array adds an int256[] parameter to the selector. 755 func (selector *ContractFunctionSelector) AddInt256Array() *ContractFunctionSelector { 756 return selector._AddParam(_Solidity{ 757 ty: aInt256, 758 array: true, 759 }) 760 } 761 762 // AddUint8Array adds a uint8[] parameter to the selector. 763 func (selector *ContractFunctionSelector) AddUint8Array() *ContractFunctionSelector { 764 return selector._AddParam(_Solidity{ 765 ty: aUint8, 766 array: true, 767 }) 768 } 769 770 // AddUint32Array adds a uint32[] parameter to the selector. 771 func (selector *ContractFunctionSelector) AddUint32Array() *ContractFunctionSelector { 772 return selector._AddParam(_Solidity{ 773 ty: aUint32, 774 array: true, 775 }) 776 } 777 778 // AddUint64Array adds a uint64[] parameter to the selector. 779 func (selector *ContractFunctionSelector) AddUint64Array() *ContractFunctionSelector { 780 return selector._AddParam(_Solidity{ 781 ty: aUint64, 782 array: true, 783 }) 784 } 785 786 // AddUint256Array adds a uint256[] parameter to the selector. 787 func (selector *ContractFunctionSelector) AddUint256Array() *ContractFunctionSelector { 788 return selector._AddParam(_Solidity{ 789 ty: aUint256, 790 array: true, 791 }) 792 } 793 794 // AddBytesArray adds a bytes[] parameter to the selector. 795 func (selector *ContractFunctionSelector) AddBytesArray() *ContractFunctionSelector { 796 return selector._AddParam(_Solidity{ 797 ty: aBytes, 798 array: true, 799 }) 800 } 801 802 // AddBytes32Array adds a bytes32[] parameter to the selector. 803 func (selector *ContractFunctionSelector) AddBytes32Array() *ContractFunctionSelector { 804 return selector._AddParam(_Solidity{ 805 ty: aBytes32, 806 array: true, 807 }) 808 } 809 810 // String returns the string representation of the selector. 811 func (selector *ContractFunctionSelector) String() string { 812 function := "" 813 if selector.function != nil { 814 function = *selector.function 815 } 816 817 return function + "(" + selector.params + ")" 818 } 819 820 func (selector *ContractFunctionSelector) _Build(function *string) []byte { 821 if function != nil { 822 selector.function = function 823 } else if selector.function == nil { 824 panic("unreachable: function name must be non-nil at this point") 825 } 826 827 hash := sha3.NewLegacyKeccak256() 828 if _, err := hash.Write([]byte(selector.String())); err != nil { 829 panic(err) 830 } 831 832 return hash.Sum(nil)[0:4] 833 }