MCPcopy Create free account
hub / github.com/CashScript/cashscript / encodeConstructorArguments

Function encodeConstructorArguments

packages/cashscript/src/Argument.ts:102–116  ·  view source on GitHub ↗
(
  artifact: Artifact,
  constructorArgs: ConstructorArgument[],
  encodeFunction: EncodeFunction = encodeFunctionArgument,
)

Source from the content-addressed store, hash-verified

100}
101
102export 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
118export const encodeFunctionArguments = (
119 abiFunction: AbiFunction,

Callers 1

constructorMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected