| 100 | } |
| 101 | |
| 102 | export const encodeConstructorArguments = ( |
| 103 | artifact: Artifact, |
| 104 | constructorArgs: ConstructorArgument[], |
| 105 | encodeFunction: EncodeFunction = encodeFunctionArgument, |
| 106 | ): Uint8Array[] => { |
| 107 | // Check there's no signature templates in the constructor |
| 108 | if (constructorArgs.some((arg) => arg instanceof SignatureTemplate)) { |
| 109 | throw new Error('Cannot use signatures in constructor'); |
| 110 | } |
| 111 | |
| 112 | const encodedArgs = constructorArgs |
| 113 | .map((arg, i) => encodeFunction(arg, artifact.constructorInputs[i].type)); |
| 114 | |
| 115 | return encodedArgs as Uint8Array[]; |
| 116 | }; |
| 117 | |
| 118 | export const encodeFunctionArguments = ( |
| 119 | abiFunction: AbiFunction, |