/* 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 TokenPairFactoryContractJson } from "../dex/TokenPairFactory.ral.json"; import { getContractByCodeHash, registerContract } from "./contracts"; // Custom types for the contract export namespace TokenPairFactoryTypes { export type Fields = { pairTemplateId: HexString; dexAccount0: HexString; pairSize: bigint; feeSetter: Address; feeCollectorFactory: HexString; }; export type State = ContractState; export type PairCreatedEvent = ContractEvent<{ token0: HexString; token1: HexString; pair: HexString; currentPairSize: bigint; }>; export interface CallMethodTable { setFeeCollectorFactory: { params: CallContractParams<{ factory: HexString }>; result: CallContractResult; }; updateFeeSetter: { params: CallContractParams<{ newFeeSetter: Address }>; result: CallContractResult; }; getFeeSetter: { params: Omit, "args">; result: CallContractResult
; }; enableFeeCollector: { params: CallContractParams<{ tokenPair: HexString; alphAmount: bigint }>; result: CallContractResult; }; updateFeeCollector: { params: CallContractParams<{ tokenPair: HexString; newFeeCollectorId: HexString; }>; result: CallContractResult; }; sortTokens: { params: CallContractParams<{ tokenA: HexString; tokenB: HexString }>; result: CallContractResult<[HexString, HexString]>; }; createPair: { params: CallContractParams<{ payer: Address; alphAmount: bigint; tokenAId: HexString; tokenBId: 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 { setFeeCollectorFactory: { params: SignExecuteContractMethodParams<{ factory: HexString }>; result: SignExecuteScriptTxResult; }; updateFeeSetter: { params: SignExecuteContractMethodParams<{ newFeeSetter: Address }>; result: SignExecuteScriptTxResult; }; getFeeSetter: { params: Omit, "args">; result: SignExecuteScriptTxResult; }; enableFeeCollector: { params: SignExecuteContractMethodParams<{ tokenPair: HexString; alphAmount: bigint; }>; result: SignExecuteScriptTxResult; }; updateFeeCollector: { params: SignExecuteContractMethodParams<{ tokenPair: HexString; newFeeCollectorId: HexString; }>; result: SignExecuteScriptTxResult; }; sortTokens: { params: SignExecuteContractMethodParams<{ tokenA: HexString; tokenB: HexString; }>; result: SignExecuteScriptTxResult; }; createPair: { params: SignExecuteContractMethodParams<{ payer: Address; alphAmount: bigint; tokenAId: HexString; tokenBId: HexString; }>; result: SignExecuteScriptTxResult; }; } export type SignExecuteMethodParams = SignExecuteMethodTable[T]["params"]; export type SignExecuteMethodResult = SignExecuteMethodTable[T]["result"]; } class Factory extends ContractFactory< TokenPairFactoryInstance, TokenPairFactoryTypes.Fields > { encodeFields(fields: TokenPairFactoryTypes.Fields) { return encodeContractFields( addStdIdToFields(this.contract, fields), this.contract.fieldsSig, [] ); } eventIndex = { PairCreated: 0 }; consts = { ErrorCodes: { ReserveOverflow: BigInt("0"), InsufficientInitLiquidity: BigInt("1"), InsufficientLiquidityMinted: BigInt("2"), InsufficientLiquidityBurned: BigInt("3"), InvalidToAddress: BigInt("4"), InsufficientLiquidity: BigInt("5"), InvalidTokenInId: BigInt("6"), InvalidCalleeId: BigInt("7"), InvalidK: BigInt("8"), InsufficientOutputAmount: BigInt("9"), InsufficientInputAmount: BigInt("10"), IdenticalTokenIds: BigInt("11"), Expired: BigInt("12"), InsufficientToken0Amount: BigInt("13"), InsufficientToken1Amount: BigInt("14"), TokenNotExist: BigInt("15"), InvalidCaller: BigInt("16"), FeeCollectorNotEnabled: BigInt("17"), InvalidAccount: BigInt("18"), }, }; at(address: string): TokenPairFactoryInstance { return new TokenPairFactoryInstance(address); } tests = { setFeeCollectorFactory: async ( params: TestContractParamsWithoutMaps< TokenPairFactoryTypes.Fields, { factory: HexString } > ): Promise> => { return testMethod( this, "setFeeCollectorFactory", params, getContractByCodeHash ); }, updateFeeSetter: async ( params: TestContractParamsWithoutMaps< TokenPairFactoryTypes.Fields, { newFeeSetter: Address } > ): Promise> => { return testMethod(this, "updateFeeSetter", params, getContractByCodeHash); }, getFeeSetter: async ( params: Omit< TestContractParamsWithoutMaps, "args" > ): Promise> => { return testMethod(this, "getFeeSetter", params, getContractByCodeHash); }, enableFeeCollector: async ( params: TestContractParamsWithoutMaps< TokenPairFactoryTypes.Fields, { tokenPair: HexString; alphAmount: bigint } > ): Promise> => { return testMethod( this, "enableFeeCollector", params, getContractByCodeHash ); }, updateFeeCollector: async ( params: TestContractParamsWithoutMaps< TokenPairFactoryTypes.Fields, { tokenPair: HexString; newFeeCollectorId: HexString } > ): Promise> => { return testMethod( this, "updateFeeCollector", params, getContractByCodeHash ); }, sortTokens: async ( params: TestContractParamsWithoutMaps< TokenPairFactoryTypes.Fields, { tokenA: HexString; tokenB: HexString } > ): Promise> => { return testMethod(this, "sortTokens", params, getContractByCodeHash); }, createPair: async ( params: TestContractParamsWithoutMaps< TokenPairFactoryTypes.Fields, { payer: Address; alphAmount: bigint; tokenAId: HexString; tokenBId: HexString; } > ): Promise> => { return testMethod(this, "createPair", params, getContractByCodeHash); }, }; stateForTest( initFields: TokenPairFactoryTypes.Fields, asset?: Asset, address?: string ) { return this.stateForTest_(initFields, asset, address, undefined); } } // Use this object to test and deploy the contract export const TokenPairFactory = new Factory( Contract.fromJson( TokenPairFactoryContractJson, "", "597644c0643972e3d6e7f5a681e2d9908de74775e9b4e205e15ba39397a9e48c", [] ) ); registerContract(TokenPairFactory); // Use this class to interact with the blockchain export class TokenPairFactoryInstance extends ContractInstance { constructor(address: Address) { super(address); } async fetchState(): Promise { return fetchContractState(TokenPairFactory, this); } async getContractEventsCurrentCount(): Promise { return getContractEventsCurrentCount(this.address); } subscribePairCreatedEvent( options: EventSubscribeOptions, fromCount?: number ): EventSubscription { return subscribeContractEvent( TokenPairFactory.contract, this, options, "PairCreated", fromCount ); } view = { setFeeCollectorFactory: async ( params: TokenPairFactoryTypes.CallMethodParams<"setFeeCollectorFactory"> ): Promise< TokenPairFactoryTypes.CallMethodResult<"setFeeCollectorFactory"> > => { return callMethod( TokenPairFactory, this, "setFeeCollectorFactory", params, getContractByCodeHash ); }, updateFeeSetter: async ( params: TokenPairFactoryTypes.CallMethodParams<"updateFeeSetter"> ): Promise> => { return callMethod( TokenPairFactory, this, "updateFeeSetter", params, getContractByCodeHash ); }, getFeeSetter: async ( params?: TokenPairFactoryTypes.CallMethodParams<"getFeeSetter"> ): Promise> => { return callMethod( TokenPairFactory, this, "getFeeSetter", params === undefined ? {} : params, getContractByCodeHash ); }, enableFeeCollector: async ( params: TokenPairFactoryTypes.CallMethodParams<"enableFeeCollector"> ): Promise< TokenPairFactoryTypes.CallMethodResult<"enableFeeCollector"> > => { return callMethod( TokenPairFactory, this, "enableFeeCollector", params, getContractByCodeHash ); }, updateFeeCollector: async ( params: TokenPairFactoryTypes.CallMethodParams<"updateFeeCollector"> ): Promise< TokenPairFactoryTypes.CallMethodResult<"updateFeeCollector"> > => { return callMethod( TokenPairFactory, this, "updateFeeCollector", params, getContractByCodeHash ); }, sortTokens: async ( params: TokenPairFactoryTypes.CallMethodParams<"sortTokens"> ): Promise> => { return callMethod( TokenPairFactory, this, "sortTokens", params, getContractByCodeHash ); }, createPair: async ( params: TokenPairFactoryTypes.CallMethodParams<"createPair"> ): Promise> => { return callMethod( TokenPairFactory, this, "createPair", params, getContractByCodeHash ); }, }; transact = { setFeeCollectorFactory: async ( params: TokenPairFactoryTypes.SignExecuteMethodParams<"setFeeCollectorFactory"> ): Promise< TokenPairFactoryTypes.SignExecuteMethodResult<"setFeeCollectorFactory"> > => { return signExecuteMethod( TokenPairFactory, this, "setFeeCollectorFactory", params ); }, updateFeeSetter: async ( params: TokenPairFactoryTypes.SignExecuteMethodParams<"updateFeeSetter"> ): Promise< TokenPairFactoryTypes.SignExecuteMethodResult<"updateFeeSetter"> > => { return signExecuteMethod( TokenPairFactory, this, "updateFeeSetter", params ); }, getFeeSetter: async ( params: TokenPairFactoryTypes.SignExecuteMethodParams<"getFeeSetter"> ): Promise< TokenPairFactoryTypes.SignExecuteMethodResult<"getFeeSetter"> > => { return signExecuteMethod(TokenPairFactory, this, "getFeeSetter", params); }, enableFeeCollector: async ( params: TokenPairFactoryTypes.SignExecuteMethodParams<"enableFeeCollector"> ): Promise< TokenPairFactoryTypes.SignExecuteMethodResult<"enableFeeCollector"> > => { return signExecuteMethod( TokenPairFactory, this, "enableFeeCollector", params ); }, updateFeeCollector: async ( params: TokenPairFactoryTypes.SignExecuteMethodParams<"updateFeeCollector"> ): Promise< TokenPairFactoryTypes.SignExecuteMethodResult<"updateFeeCollector"> > => { return signExecuteMethod( TokenPairFactory, this, "updateFeeCollector", params ); }, sortTokens: async ( params: TokenPairFactoryTypes.SignExecuteMethodParams<"sortTokens"> ): Promise> => { return signExecuteMethod(TokenPairFactory, this, "sortTokens", params); }, createPair: async ( params: TokenPairFactoryTypes.SignExecuteMethodParams<"createPair"> ): Promise> => { return signExecuteMethod(TokenPairFactory, this, "createPair", params); }, }; async multicall( calls: Calls ): Promise>; async multicall( callss: Narrow ): Promise>; async multicall< Callss extends | TokenPairFactoryTypes.MultiCallParams | TokenPairFactoryTypes.MultiCallParams[] >(callss: Callss): Promise { return await multicallMethods( TokenPairFactory, this, callss, getContractByCodeHash ); } }