Utilities
getSchema
The SDK uses Zod schemas in order to verify inputs for createNewInstance, according to their target Solidity types. The getSchema
function is exported as a utility function, to get the Zod schema for a corresponding Solidity type.
Arguments:
solidityType
- The name of the Solidity type, e.g. "uint256".
Response:
The Zod schema for the provided type.
verify
Verify a value according to its target Solidity type.
Arguments:
val
- The value to verify.type
- The target Solidity type for the provided value.
Response:
true
if the provided value is compatible with the Solidity type, false
otherwise.
solidityToTypescriptType
Utility function that maps between a Solidity type to its compatible Typescript type.
Arguments:
solidityType
- The name of the Solidity type, e.g. "uint256".
Response:
The name of the Typescript type which is compatible to the provided Solidity one.
checkAndEncodeArgs
Check and encode the immutable and mutable arguments for module creation.
This is a utility function for interacting with the HatsModuleFactory directly, rather than using the createNewInstance function from the SDK. This may be useful in cases where the module creation is proxied by another contract and expects similar input parameters as the createHatsModule function from the factory.
Arguments:
module
- The module object of the module that will be created.
immutableArgs
- The module's immutable arguments.
mutableArgs
- The modules's mutable arguments.
Response:
The encoded immutable and mutable arguments, as expected by the createHatsModule function from the factory.
checkImmutableArgs
Check the immutable arguments for module creation.
Checks that the provided immutable arguments are valid according to the module's schema from the registry. If not, the function will throw a detailed error.
Arguments:
module
- The module object of the module that will be created.
immutableArgs
- The module's immutable arguments.
checkMutableArgs
Check the mutable arguments for module creation.
Checks that the provided mutable arguments are valid according to the module's schema from the registry. If not, the function will throw a detailed error.
Arguments:
module
- The module object of the module that will be created.
mutableArgs
- The module's mutable arguments.
getNewInstancesFromReceipt
Get the addresses of newly created module instance/s, using the creation transaction receipt.
Arguments:
receipt
- The transaction receipt as a TransactionReceipt Viem object.
Response:
An array of the newly created instances/s.
Last updated