/* Autogenerated file. Do not edit manually. */ /* tslint:disable */ /* eslint-disable */ import { Address, Contract, ContractState, TestContractResult, HexString, ContractFactory, EventSubscribeOptions, EventSubscription, CallContractParams, CallContractResult, TestContractParams, ContractEvent, subscribeContractEvent, subscribeContractEvents, testMethod, callMethod, multicallMethods, fetchContractState, Asset, ContractInstance, getContractEventsCurrentCount, TestContractParamsWithoutMaps, TestContractResultWithoutMaps, SignExecuteContractMethodParams, SignExecuteScriptTxResult, signExecuteMethod, addStdIdToFields, encodeContractFields, Narrow, } from "@alephium/web3"; import { default as PoolFactoryContractJson } from "../PoolFactory.ral.json"; import { getContractByCodeHash, registerContract } from "./contracts"; import * as types from "./types"; // Custom types for the contract export namespace PoolFactoryTypes { export type Fields = { owner: Address; poolTemplate: HexString; positionTemplate: HexString; tickTemplate: HexString; wordTemplate: HexString; poolConfigTemplate: HexString; dexAccountTemplate: HexString; nextConfigIndex: bigint; }; export type State = ContractState; export type ConfigCreatedEvent = ContractEvent<{ index: bigint }>; export type PoolCreatedEvent = ContractEvent<{ id: HexString; token0: HexString; token1: HexString; configIndex: bigint; }>; export type FeeTierEnabledEvent = ContractEvent<{ fee: bigint; tickSpacing: bigint; index: bigint; }>; export interface CallMethodTable { configPath: { params: CallContractParams<{ configIndex_: bigint }>; result: CallContractResult; }; poolPath: { params: CallContractParams<{ factory: HexString; tokens: HexString; configIndex_: bigint; }>; result: CallContractResult; }; poolContractId: { params: CallContractParams<{ factory: HexString; tokens: HexString; configIndex_: bigint; }>; result: CallContractResult; }; tickSpacingToMaxLiquidityPerTick: { params: CallContractParams<{ tickSpacing: bigint }>; result: CallContractResult; }; createConfig: { params: CallContractParams<{ config: types.Config }>; result: CallContractResult; }; create: { params: CallContractParams<{ token0: HexString; token1: HexString; configIndex: bigint; sqrtPriceX96: bigint; rewardToken: HexString; }>; result: CallContractResult; }; collectProtocolFees: { params: CallContractParams<{ recipient: Address; configIndex: bigint; token0: HexString; token1: HexString; }>; result: CallContractResult; }; setRewardParams: { params: CallContractParams<{ configIndex: bigint; token0: HexString; token1: HexString; payer: Address; tokenId: HexString; index: bigint; openTime: bigint; endTime: bigint; amount: bigint; }>; result: CallContractResult; }; upgrate: { params: CallContractParams<{ newBytecode: HexString; newEncodedImmFields: HexString; newEncodedMutFields: HexString; }>; result: CallContractResult; }; } export type CallMethodParams = CallMethodTable[T]["params"]; export type CallMethodResult = CallMethodTable[T]["result"]; export type MultiCallParams = Partial<{ [Name in keyof CallMethodTable]: CallMethodTable[Name]["params"]; }>; export type MultiCallResults = { [MaybeName in keyof T]: MaybeName extends keyof CallMethodTable ? CallMethodTable[MaybeName]["result"] : undefined; }; export type MulticallReturnType = { [index in keyof Callss]: MultiCallResults; }; export interface SignExecuteMethodTable { configPath: { params: SignExecuteContractMethodParams<{ configIndex_: bigint }>; result: SignExecuteScriptTxResult; }; poolPath: { params: SignExecuteContractMethodParams<{ factory: HexString; tokens: HexString; configIndex_: bigint; }>; result: SignExecuteScriptTxResult; }; poolContractId: { params: SignExecuteContractMethodParams<{ factory: HexString; tokens: HexString; configIndex_: bigint; }>; result: SignExecuteScriptTxResult; }; tickSpacingToMaxLiquidityPerTick: { params: SignExecuteContractMethodParams<{ tickSpacing: bigint }>; result: SignExecuteScriptTxResult; }; createConfig: { params: SignExecuteContractMethodParams<{ config: types.Config }>; result: SignExecuteScriptTxResult; }; create: { params: SignExecuteContractMethodParams<{ token0: HexString; token1: HexString; configIndex: bigint; sqrtPriceX96: bigint; rewardToken: HexString; }>; result: SignExecuteScriptTxResult; }; collectProtocolFees: { params: SignExecuteContractMethodParams<{ recipient: Address; configIndex: bigint; token0: HexString; token1: HexString; }>; result: SignExecuteScriptTxResult; }; setRewardParams: { params: SignExecuteContractMethodParams<{ configIndex: bigint; token0: HexString; token1: HexString; payer: Address; tokenId: HexString; index: bigint; openTime: bigint; endTime: bigint; amount: bigint; }>; result: SignExecuteScriptTxResult; }; upgrate: { params: SignExecuteContractMethodParams<{ newBytecode: HexString; newEncodedImmFields: HexString; newEncodedMutFields: HexString; }>; result: SignExecuteScriptTxResult; }; } export type SignExecuteMethodParams = SignExecuteMethodTable[T]["params"]; export type SignExecuteMethodResult = SignExecuteMethodTable[T]["result"]; } class Factory extends ContractFactory< PoolFactoryInstance, PoolFactoryTypes.Fields > { encodeFields(fields: PoolFactoryTypes.Fields) { return encodeContractFields( addStdIdToFields(this.contract, fields), this.contract.fieldsSig, types.AllStructs ); } eventIndex = { ConfigCreated: 0, PoolCreated: 1, FeeTierEnabled: 2 }; consts = { FactoryError: { InvalidTokenOrder: BigInt("701"), UnauthorizedRewardSender: BigInt("702"), UnauthorizedFeeCollector: BigInt("703"), }, }; at(address: string): PoolFactoryInstance { return new PoolFactoryInstance(address); } tests = { configPath: async ( params: TestContractParamsWithoutMaps< PoolFactoryTypes.Fields, { configIndex_: bigint } > ): Promise> => { return testMethod(this, "configPath", params, getContractByCodeHash); }, poolPath: async ( params: TestContractParamsWithoutMaps< PoolFactoryTypes.Fields, { factory: HexString; tokens: HexString; configIndex_: bigint } > ): Promise> => { return testMethod(this, "poolPath", params, getContractByCodeHash); }, poolContractId: async ( params: TestContractParamsWithoutMaps< PoolFactoryTypes.Fields, { factory: HexString; tokens: HexString; configIndex_: bigint } > ): Promise> => { return testMethod(this, "poolContractId", params, getContractByCodeHash); }, tickSpacingToMaxLiquidityPerTick: async ( params: TestContractParamsWithoutMaps< PoolFactoryTypes.Fields, { tickSpacing: bigint } > ): Promise> => { return testMethod( this, "tickSpacingToMaxLiquidityPerTick", params, getContractByCodeHash ); }, createConfig: async ( params: TestContractParamsWithoutMaps< PoolFactoryTypes.Fields, { config: types.Config } > ): Promise> => { return testMethod(this, "createConfig", params, getContractByCodeHash); }, create: async ( params: TestContractParamsWithoutMaps< PoolFactoryTypes.Fields, { token0: HexString; token1: HexString; configIndex: bigint; sqrtPriceX96: bigint; rewardToken: HexString; } > ): Promise> => { return testMethod(this, "create", params, getContractByCodeHash); }, collectProtocolFees: async ( params: TestContractParamsWithoutMaps< PoolFactoryTypes.Fields, { recipient: Address; configIndex: bigint; token0: HexString; token1: HexString; } > ): Promise> => { return testMethod( this, "collectProtocolFees", params, getContractByCodeHash ); }, setRewardParams: async ( params: TestContractParamsWithoutMaps< PoolFactoryTypes.Fields, { configIndex: bigint; token0: HexString; token1: HexString; payer: Address; tokenId: HexString; index: bigint; openTime: bigint; endTime: bigint; amount: bigint; } > ): Promise> => { return testMethod(this, "setRewardParams", params, getContractByCodeHash); }, upgrate: async ( params: TestContractParamsWithoutMaps< PoolFactoryTypes.Fields, { newBytecode: HexString; newEncodedImmFields: HexString; newEncodedMutFields: HexString; } > ): Promise> => { return testMethod(this, "upgrate", params, getContractByCodeHash); }, }; stateForTest( initFields: PoolFactoryTypes.Fields, asset?: Asset, address?: string ) { return this.stateForTest_(initFields, asset, address, undefined); } } // Use this object to test and deploy the contract export const PoolFactory = new Factory( Contract.fromJson( PoolFactoryContractJson, "", "4f2990418f84360134e2fe3c2732c0ad191b52d772a8406ae9afe6e87c427bf3", types.AllStructs ) ); registerContract(PoolFactory); // Use this class to interact with the blockchain export class PoolFactoryInstance extends ContractInstance { constructor(address: Address) { super(address); } async fetchState(): Promise { return fetchContractState(PoolFactory, this); } async getContractEventsCurrentCount(): Promise { return getContractEventsCurrentCount(this.address); } subscribeConfigCreatedEvent( options: EventSubscribeOptions, fromCount?: number ): EventSubscription { return subscribeContractEvent( PoolFactory.contract, this, options, "ConfigCreated", fromCount ); } subscribePoolCreatedEvent( options: EventSubscribeOptions, fromCount?: number ): EventSubscription { return subscribeContractEvent( PoolFactory.contract, this, options, "PoolCreated", fromCount ); } subscribeFeeTierEnabledEvent( options: EventSubscribeOptions, fromCount?: number ): EventSubscription { return subscribeContractEvent( PoolFactory.contract, this, options, "FeeTierEnabled", fromCount ); } subscribeAllEvents( options: EventSubscribeOptions< | PoolFactoryTypes.ConfigCreatedEvent | PoolFactoryTypes.PoolCreatedEvent | PoolFactoryTypes.FeeTierEnabledEvent >, fromCount?: number ): EventSubscription { return subscribeContractEvents( PoolFactory.contract, this, options, fromCount ); } view = { configPath: async ( params: PoolFactoryTypes.CallMethodParams<"configPath"> ): Promise> => { return callMethod( PoolFactory, this, "configPath", params, getContractByCodeHash ); }, poolPath: async ( params: PoolFactoryTypes.CallMethodParams<"poolPath"> ): Promise> => { return callMethod( PoolFactory, this, "poolPath", params, getContractByCodeHash ); }, poolContractId: async ( params: PoolFactoryTypes.CallMethodParams<"poolContractId"> ): Promise> => { return callMethod( PoolFactory, this, "poolContractId", params, getContractByCodeHash ); }, tickSpacingToMaxLiquidityPerTick: async ( params: PoolFactoryTypes.CallMethodParams<"tickSpacingToMaxLiquidityPerTick"> ): Promise< PoolFactoryTypes.CallMethodResult<"tickSpacingToMaxLiquidityPerTick"> > => { return callMethod( PoolFactory, this, "tickSpacingToMaxLiquidityPerTick", params, getContractByCodeHash ); }, createConfig: async ( params: PoolFactoryTypes.CallMethodParams<"createConfig"> ): Promise> => { return callMethod( PoolFactory, this, "createConfig", params, getContractByCodeHash ); }, create: async ( params: PoolFactoryTypes.CallMethodParams<"create"> ): Promise> => { return callMethod( PoolFactory, this, "create", params, getContractByCodeHash ); }, collectProtocolFees: async ( params: PoolFactoryTypes.CallMethodParams<"collectProtocolFees"> ): Promise> => { return callMethod( PoolFactory, this, "collectProtocolFees", params, getContractByCodeHash ); }, setRewardParams: async ( params: PoolFactoryTypes.CallMethodParams<"setRewardParams"> ): Promise> => { return callMethod( PoolFactory, this, "setRewardParams", params, getContractByCodeHash ); }, upgrate: async ( params: PoolFactoryTypes.CallMethodParams<"upgrate"> ): Promise> => { return callMethod( PoolFactory, this, "upgrate", params, getContractByCodeHash ); }, }; transact = { configPath: async ( params: PoolFactoryTypes.SignExecuteMethodParams<"configPath"> ): Promise> => { return signExecuteMethod(PoolFactory, this, "configPath", params); }, poolPath: async ( params: PoolFactoryTypes.SignExecuteMethodParams<"poolPath"> ): Promise> => { return signExecuteMethod(PoolFactory, this, "poolPath", params); }, poolContractId: async ( params: PoolFactoryTypes.SignExecuteMethodParams<"poolContractId"> ): Promise> => { return signExecuteMethod(PoolFactory, this, "poolContractId", params); }, tickSpacingToMaxLiquidityPerTick: async ( params: PoolFactoryTypes.SignExecuteMethodParams<"tickSpacingToMaxLiquidityPerTick"> ): Promise< PoolFactoryTypes.SignExecuteMethodResult<"tickSpacingToMaxLiquidityPerTick"> > => { return signExecuteMethod( PoolFactory, this, "tickSpacingToMaxLiquidityPerTick", params ); }, createConfig: async ( params: PoolFactoryTypes.SignExecuteMethodParams<"createConfig"> ): Promise> => { return signExecuteMethod(PoolFactory, this, "createConfig", params); }, create: async ( params: PoolFactoryTypes.SignExecuteMethodParams<"create"> ): Promise> => { return signExecuteMethod(PoolFactory, this, "create", params); }, collectProtocolFees: async ( params: PoolFactoryTypes.SignExecuteMethodParams<"collectProtocolFees"> ): Promise< PoolFactoryTypes.SignExecuteMethodResult<"collectProtocolFees"> > => { return signExecuteMethod( PoolFactory, this, "collectProtocolFees", params ); }, setRewardParams: async ( params: PoolFactoryTypes.SignExecuteMethodParams<"setRewardParams"> ): Promise> => { return signExecuteMethod(PoolFactory, this, "setRewardParams", params); }, upgrate: async ( params: PoolFactoryTypes.SignExecuteMethodParams<"upgrate"> ): Promise> => { return signExecuteMethod(PoolFactory, this, "upgrate", params); }, }; async multicall( calls: Calls ): Promise>; async multicall( callss: Narrow ): Promise>; async multicall< Callss extends | PoolFactoryTypes.MultiCallParams | PoolFactoryTypes.MultiCallParams[] >(callss: Callss): Promise { return await multicallMethods( PoolFactory, this, callss, getContractByCodeHash ); } }