/* 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 ExampleOracleSimpleContractJson } from "../examples/ExampleOracleSimple.ral.json"; import { getContractByCodeHash, registerContract } from "./contracts"; // Custom types for the contract export namespace ExampleOracleSimpleTypes { export type Fields = { pair: HexString; price0CumulativeLast: bigint; price1CumulativeLast: bigint; blockTimeStampLast: bigint; price0Average: bigint; price1Average: bigint; }; export type State = ContractState; export interface CallMethodTable { fullMul: { params: CallContractParams<{ x: bigint; y: bigint }>; result: CallContractResult<[bigint, bigint]>; }; mulDiv: { params: CallContractParams<{ a: bigint; b: bigint; denominator: bigint }>; result: CallContractResult; }; fraction: { params: CallContractParams<{ numerator: bigint; denominator: bigint }>; result: CallContractResult; }; currentCumulativePrices: { params: CallContractParams<{ currentBlockTimeStamp: bigint }>; result: CallContractResult<[bigint, bigint]>; }; update: { params: Omit, "args">; result: CallContractResult; }; consult: { params: CallContractParams<{ tokenId: HexString; amountIn: bigint }>; 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 { fullMul: { params: SignExecuteContractMethodParams<{ x: bigint; y: bigint }>; result: SignExecuteScriptTxResult; }; mulDiv: { params: SignExecuteContractMethodParams<{ a: bigint; b: bigint; denominator: bigint; }>; result: SignExecuteScriptTxResult; }; fraction: { params: SignExecuteContractMethodParams<{ numerator: bigint; denominator: bigint; }>; result: SignExecuteScriptTxResult; }; currentCumulativePrices: { params: SignExecuteContractMethodParams<{ currentBlockTimeStamp: bigint; }>; result: SignExecuteScriptTxResult; }; update: { params: Omit, "args">; result: SignExecuteScriptTxResult; }; consult: { params: SignExecuteContractMethodParams<{ tokenId: HexString; amountIn: bigint; }>; result: SignExecuteScriptTxResult; }; } export type SignExecuteMethodParams = SignExecuteMethodTable[T]["params"]; export type SignExecuteMethodResult = SignExecuteMethodTable[T]["result"]; } class Factory extends ContractFactory< ExampleOracleSimpleInstance, ExampleOracleSimpleTypes.Fields > { encodeFields(fields: ExampleOracleSimpleTypes.Fields) { return encodeContractFields( addStdIdToFields(this.contract, fields), this.contract.fieldsSig, [] ); } consts = { Resolution: BigInt("112"), Period: BigInt("86400"), ErrorCodes: { FullDivOverflow: BigInt("0"), DivByZero: BigInt("1"), FractionOverflow: BigInt("2"), PeriodNotElapsed: BigInt("3"), InvalidToken: BigInt("4"), }, }; at(address: string): ExampleOracleSimpleInstance { return new ExampleOracleSimpleInstance(address); } tests = { fullMul: async ( params: TestContractParamsWithoutMaps< ExampleOracleSimpleTypes.Fields, { x: bigint; y: bigint } > ): Promise> => { return testMethod(this, "fullMul", params, getContractByCodeHash); }, mulDiv: async ( params: TestContractParamsWithoutMaps< ExampleOracleSimpleTypes.Fields, { a: bigint; b: bigint; denominator: bigint } > ): Promise> => { return testMethod(this, "mulDiv", params, getContractByCodeHash); }, fraction: async ( params: TestContractParamsWithoutMaps< ExampleOracleSimpleTypes.Fields, { numerator: bigint; denominator: bigint } > ): Promise> => { return testMethod(this, "fraction", params, getContractByCodeHash); }, currentCumulativePrices: async ( params: TestContractParamsWithoutMaps< ExampleOracleSimpleTypes.Fields, { currentBlockTimeStamp: bigint } > ): Promise> => { return testMethod( this, "currentCumulativePrices", params, getContractByCodeHash ); }, update: async ( params: Omit< TestContractParamsWithoutMaps, "args" > ): Promise> => { return testMethod(this, "update", params, getContractByCodeHash); }, consult: async ( params: TestContractParamsWithoutMaps< ExampleOracleSimpleTypes.Fields, { tokenId: HexString; amountIn: bigint } > ): Promise> => { return testMethod(this, "consult", params, getContractByCodeHash); }, }; stateForTest( initFields: ExampleOracleSimpleTypes.Fields, asset?: Asset, address?: string ) { return this.stateForTest_(initFields, asset, address, undefined); } } // Use this object to test and deploy the contract export const ExampleOracleSimple = new Factory( Contract.fromJson( ExampleOracleSimpleContractJson, "", "c96ea41f2579f435d70c7801c2ec158031575b7571d8e8bbb2e460a8814cfbdf", [] ) ); registerContract(ExampleOracleSimple); // Use this class to interact with the blockchain export class ExampleOracleSimpleInstance extends ContractInstance { constructor(address: Address) { super(address); } async fetchState(): Promise { return fetchContractState(ExampleOracleSimple, this); } view = { fullMul: async ( params: ExampleOracleSimpleTypes.CallMethodParams<"fullMul"> ): Promise> => { return callMethod( ExampleOracleSimple, this, "fullMul", params, getContractByCodeHash ); }, mulDiv: async ( params: ExampleOracleSimpleTypes.CallMethodParams<"mulDiv"> ): Promise> => { return callMethod( ExampleOracleSimple, this, "mulDiv", params, getContractByCodeHash ); }, fraction: async ( params: ExampleOracleSimpleTypes.CallMethodParams<"fraction"> ): Promise> => { return callMethod( ExampleOracleSimple, this, "fraction", params, getContractByCodeHash ); }, currentCumulativePrices: async ( params: ExampleOracleSimpleTypes.CallMethodParams<"currentCumulativePrices"> ): Promise< ExampleOracleSimpleTypes.CallMethodResult<"currentCumulativePrices"> > => { return callMethod( ExampleOracleSimple, this, "currentCumulativePrices", params, getContractByCodeHash ); }, update: async ( params?: ExampleOracleSimpleTypes.CallMethodParams<"update"> ): Promise> => { return callMethod( ExampleOracleSimple, this, "update", params === undefined ? {} : params, getContractByCodeHash ); }, consult: async ( params: ExampleOracleSimpleTypes.CallMethodParams<"consult"> ): Promise> => { return callMethod( ExampleOracleSimple, this, "consult", params, getContractByCodeHash ); }, }; transact = { fullMul: async ( params: ExampleOracleSimpleTypes.SignExecuteMethodParams<"fullMul"> ): Promise> => { return signExecuteMethod(ExampleOracleSimple, this, "fullMul", params); }, mulDiv: async ( params: ExampleOracleSimpleTypes.SignExecuteMethodParams<"mulDiv"> ): Promise> => { return signExecuteMethod(ExampleOracleSimple, this, "mulDiv", params); }, fraction: async ( params: ExampleOracleSimpleTypes.SignExecuteMethodParams<"fraction"> ): Promise< ExampleOracleSimpleTypes.SignExecuteMethodResult<"fraction"> > => { return signExecuteMethod(ExampleOracleSimple, this, "fraction", params); }, currentCumulativePrices: async ( params: ExampleOracleSimpleTypes.SignExecuteMethodParams<"currentCumulativePrices"> ): Promise< ExampleOracleSimpleTypes.SignExecuteMethodResult<"currentCumulativePrices"> > => { return signExecuteMethod( ExampleOracleSimple, this, "currentCumulativePrices", params ); }, update: async ( params: ExampleOracleSimpleTypes.SignExecuteMethodParams<"update"> ): Promise> => { return signExecuteMethod(ExampleOracleSimple, this, "update", params); }, consult: async ( params: ExampleOracleSimpleTypes.SignExecuteMethodParams<"consult"> ): Promise> => { return signExecuteMethod(ExampleOracleSimple, this, "consult", params); }, }; async multicall( calls: Calls ): Promise>; async multicall( callss: Narrow ): Promise>; async multicall< Callss extends | ExampleOracleSimpleTypes.MultiCallParams | ExampleOracleSimpleTypes.MultiCallParams[] >(callss: Callss): Promise { return await multicallMethods( ExampleOracleSimple, this, callss, getContractByCodeHash ); } }