* Encodes all the arguments for the given function ABI. * @returns The encoded arguments.
()
| 207 | * @returns The encoded arguments. |
| 208 | */ |
| 209 | public encode() { |
| 210 | if (this.args.length !== this.abi.parameters.length) { |
| 211 | throw new Error( |
| 212 | `Function '${this.abi.name}' expects ${this.abi.parameters.length} argument(s) but received ${this.args.length}`, |
| 213 | ); |
| 214 | } |
| 215 | for (let i = 0; i < this.abi.parameters.length; i += 1) { |
| 216 | const parameterAbi = this.abi.parameters[i]; |
| 217 | this.encodeArgument(parameterAbi.type, this.args[i], parameterAbi.name); |
| 218 | } |
| 219 | return this.flattened; |
| 220 | } |
| 221 | |
| 222 | /** |
| 223 | * Encodes an array as a BoundedVec struct. |