/* 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 XAlphTokenContractJson } from "../XAlphToken.ral.json"; import { getContractByCodeHash, registerContract } from "./contracts"; import * as types from "./types"; import { RalphMap } from "@alephium/web3"; // Custom types for the contract export namespace XAlphTokenTypes { export type Fields = { symbol: HexString; name: HexString; decimals: bigint; unstakeVaultTemplateId: HexString; maxActiveUnstakeRequestsPerUser: bigint; unstakeDuration: bigint; totalStaked: bigint; lastUnstakeVaultIndex: bigint; }; export type State = ContractState; export type StakedEvent = ContractEvent<{ to: Address; amount: bigint }>; export type UnstakeScheduledEvent = ContractEvent<{ to: Address; amount: bigint; }>; export interface CallMethodTable { getSymbol: { params: Omit, "args">; result: CallContractResult; }; getName: { params: Omit, "args">; result: CallContractResult; }; getDecimals: { params: Omit, "args">; result: CallContractResult; }; getTotalSupply: { params: Omit, "args">; result: CallContractResult; }; get: { params: CallContractParams<{ array: HexString; index: bigint }>; result: CallContractResult; }; find: { params: CallContractParams<{ array: HexString; value: bigint }>; result: CallContractResult; }; remove: { params: CallContractParams<{ array: HexString; value: bigint }>; result: CallContractResult; }; push: { params: CallContractParams<{ array: HexString; value: bigint }>; result: CallContractResult; }; binarySearch: { params: CallContractParams<{ array: HexString; value: bigint; left: bigint; right: bigint; }>; result: CallContractResult; }; removeAt: { params: CallContractParams<{ array: HexString; index: bigint }>; result: CallContractResult; }; size: { params: CallContractParams<{ array: HexString }>; result: CallContractResult; }; empty: { params: Omit, "args">; result: CallContractResult; }; stake: { params: CallContractParams<{ amount: bigint }>; result: CallContractResult; }; startUnstake: { params: CallContractParams<{ amount: bigint }>; result: CallContractResult; }; getActiveUnstakeVaultIndexes: { params: CallContractParams<{ caller: Address }>; result: CallContractResult; }; getClaimableAmount: { params: CallContractParams<{ user: Address; vaultIndex: bigint }>; result: CallContractResult; }; claimUnstaked: { params: CallContractParams<{ vaultIndex: bigint; amount: 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 { getSymbol: { params: Omit, "args">; result: SignExecuteScriptTxResult; }; getName: { params: Omit, "args">; result: SignExecuteScriptTxResult; }; getDecimals: { params: Omit, "args">; result: SignExecuteScriptTxResult; }; getTotalSupply: { params: Omit, "args">; result: SignExecuteScriptTxResult; }; get: { params: SignExecuteContractMethodParams<{ array: HexString; index: bigint; }>; result: SignExecuteScriptTxResult; }; find: { params: SignExecuteContractMethodParams<{ array: HexString; value: bigint; }>; result: SignExecuteScriptTxResult; }; remove: { params: SignExecuteContractMethodParams<{ array: HexString; value: bigint; }>; result: SignExecuteScriptTxResult; }; push: { params: SignExecuteContractMethodParams<{ array: HexString; value: bigint; }>; result: SignExecuteScriptTxResult; }; binarySearch: { params: SignExecuteContractMethodParams<{ array: HexString; value: bigint; left: bigint; right: bigint; }>; result: SignExecuteScriptTxResult; }; removeAt: { params: SignExecuteContractMethodParams<{ array: HexString; index: bigint; }>; result: SignExecuteScriptTxResult; }; size: { params: SignExecuteContractMethodParams<{ array: HexString }>; result: SignExecuteScriptTxResult; }; empty: { params: Omit, "args">; result: SignExecuteScriptTxResult; }; stake: { params: SignExecuteContractMethodParams<{ amount: bigint }>; result: SignExecuteScriptTxResult; }; startUnstake: { params: SignExecuteContractMethodParams<{ amount: bigint }>; result: SignExecuteScriptTxResult; }; getActiveUnstakeVaultIndexes: { params: SignExecuteContractMethodParams<{ caller: Address }>; result: SignExecuteScriptTxResult; }; getClaimableAmount: { params: SignExecuteContractMethodParams<{ user: Address; vaultIndex: bigint; }>; result: SignExecuteScriptTxResult; }; claimUnstaked: { params: SignExecuteContractMethodParams<{ vaultIndex: bigint; amount: bigint; }>; result: SignExecuteScriptTxResult; }; } export type SignExecuteMethodParams = SignExecuteMethodTable[T]["params"]; export type SignExecuteMethodResult = SignExecuteMethodTable[T]["result"]; export type Maps = { userActiveUnstakeVaults?: Map }; } class Factory extends ContractFactory< XAlphTokenInstance, XAlphTokenTypes.Fields > { encodeFields(fields: XAlphTokenTypes.Fields) { return encodeContractFields( addStdIdToFields(this.contract, fields), this.contract.fieldsSig, types.AllStructs ); } eventIndex = { Staked: 0, UnstakeScheduled: 1 }; consts = { IntByteLength: BigInt("32"), ErrorCode: { InvalidArrayLength: BigInt("550"), IndexOutOfBound: BigInt("551"), InvalidByteVecLength: BigInt("552"), }, ErrorCodes: { AssetAddressCallerOnly: BigInt("10"), TooManyActiveUnstakeVaults: BigInt("11"), InvalidUnstakeDuration: BigInt("12"), NonExistantUnstakeVault: BigInt("13"), AmountMustBeGreaterThanZero: BigInt("14"), }, }; at(address: string): XAlphTokenInstance { return new XAlphTokenInstance(address); } tests = { getSymbol: async ( params: Omit< TestContractParams, "args" > ): Promise> => { return testMethod(this, "getSymbol", params, getContractByCodeHash); }, getName: async ( params: Omit< TestContractParams, "args" > ): Promise> => { return testMethod(this, "getName", params, getContractByCodeHash); }, getDecimals: async ( params: Omit< TestContractParams, "args" > ): Promise> => { return testMethod(this, "getDecimals", params, getContractByCodeHash); }, getTotalSupply: async ( params: Omit< TestContractParams, "args" > ): Promise> => { return testMethod(this, "getTotalSupply", params, getContractByCodeHash); }, get: async ( params: TestContractParams< XAlphTokenTypes.Fields, { array: HexString; index: bigint }, XAlphTokenTypes.Maps > ): Promise> => { return testMethod(this, "get", params, getContractByCodeHash); }, find: async ( params: TestContractParams< XAlphTokenTypes.Fields, { array: HexString; value: bigint }, XAlphTokenTypes.Maps > ): Promise> => { return testMethod(this, "find", params, getContractByCodeHash); }, remove: async ( params: TestContractParams< XAlphTokenTypes.Fields, { array: HexString; value: bigint }, XAlphTokenTypes.Maps > ): Promise> => { return testMethod(this, "remove", params, getContractByCodeHash); }, push: async ( params: TestContractParams< XAlphTokenTypes.Fields, { array: HexString; value: bigint }, XAlphTokenTypes.Maps > ): Promise> => { return testMethod(this, "push", params, getContractByCodeHash); }, binarySearch: async ( params: TestContractParams< XAlphTokenTypes.Fields, { array: HexString; value: bigint; left: bigint; right: bigint }, XAlphTokenTypes.Maps > ): Promise> => { return testMethod(this, "binarySearch", params, getContractByCodeHash); }, removeAt: async ( params: TestContractParams< XAlphTokenTypes.Fields, { array: HexString; index: bigint }, XAlphTokenTypes.Maps > ): Promise> => { return testMethod(this, "removeAt", params, getContractByCodeHash); }, size: async ( params: TestContractParams< XAlphTokenTypes.Fields, { array: HexString }, XAlphTokenTypes.Maps > ): Promise> => { return testMethod(this, "size", params, getContractByCodeHash); }, empty: async ( params: Omit< TestContractParams, "args" > ): Promise> => { return testMethod(this, "empty", params, getContractByCodeHash); }, stake: async ( params: TestContractParams< XAlphTokenTypes.Fields, { amount: bigint }, XAlphTokenTypes.Maps > ): Promise> => { return testMethod(this, "stake", params, getContractByCodeHash); }, startUnstake: async ( params: TestContractParams< XAlphTokenTypes.Fields, { amount: bigint }, XAlphTokenTypes.Maps > ): Promise> => { return testMethod(this, "startUnstake", params, getContractByCodeHash); }, getActiveUnstakeVaultIndexes: async ( params: TestContractParams< XAlphTokenTypes.Fields, { caller: Address }, XAlphTokenTypes.Maps > ): Promise> => { return testMethod( this, "getActiveUnstakeVaultIndexes", params, getContractByCodeHash ); }, getClaimableAmount: async ( params: TestContractParams< XAlphTokenTypes.Fields, { user: Address; vaultIndex: bigint }, XAlphTokenTypes.Maps > ): Promise> => { return testMethod( this, "getClaimableAmount", params, getContractByCodeHash ); }, claimUnstaked: async ( params: TestContractParams< XAlphTokenTypes.Fields, { vaultIndex: bigint; amount: bigint }, XAlphTokenTypes.Maps > ): Promise> => { return testMethod(this, "claimUnstaked", params, getContractByCodeHash); }, }; stateForTest( initFields: XAlphTokenTypes.Fields, asset?: Asset, address?: string, maps?: XAlphTokenTypes.Maps ) { return this.stateForTest_(initFields, asset, address, maps); } } // Use this object to test and deploy the contract export const XAlphToken = new Factory( Contract.fromJson( XAlphTokenContractJson, "=52-2+91=2+c=1-1=2+e=1-1=2-2+8f=857-1+b=235-1+b=34+7a7e0214696e73657274206174206d617020706174683a2000=333-1+2=79-1+b=69-1+c=40+7a7e021472656d6f7665206174206d617020706174683a2000=70", "8ded2201203cffd39adc32f6278f37f0ef1a543cf34872a159a1f36de68620d4", types.AllStructs ) ); registerContract(XAlphToken); // Use this class to interact with the blockchain export class XAlphTokenInstance extends ContractInstance { constructor(address: Address) { super(address); } maps = { userActiveUnstakeVaults: new RalphMap( XAlphToken.contract, this.contractId, "userActiveUnstakeVaults" ), }; async fetchState(): Promise { return fetchContractState(XAlphToken, this); } async getContractEventsCurrentCount(): Promise { return getContractEventsCurrentCount(this.address); } subscribeStakedEvent( options: EventSubscribeOptions, fromCount?: number ): EventSubscription { return subscribeContractEvent( XAlphToken.contract, this, options, "Staked", fromCount ); } subscribeUnstakeScheduledEvent( options: EventSubscribeOptions, fromCount?: number ): EventSubscription { return subscribeContractEvent( XAlphToken.contract, this, options, "UnstakeScheduled", fromCount ); } subscribeAllEvents( options: EventSubscribeOptions< XAlphTokenTypes.StakedEvent | XAlphTokenTypes.UnstakeScheduledEvent >, fromCount?: number ): EventSubscription { return subscribeContractEvents( XAlphToken.contract, this, options, fromCount ); } view = { getSymbol: async ( params?: XAlphTokenTypes.CallMethodParams<"getSymbol"> ): Promise> => { return callMethod( XAlphToken, this, "getSymbol", params === undefined ? {} : params, getContractByCodeHash ); }, getName: async ( params?: XAlphTokenTypes.CallMethodParams<"getName"> ): Promise> => { return callMethod( XAlphToken, this, "getName", params === undefined ? {} : params, getContractByCodeHash ); }, getDecimals: async ( params?: XAlphTokenTypes.CallMethodParams<"getDecimals"> ): Promise> => { return callMethod( XAlphToken, this, "getDecimals", params === undefined ? {} : params, getContractByCodeHash ); }, getTotalSupply: async ( params?: XAlphTokenTypes.CallMethodParams<"getTotalSupply"> ): Promise> => { return callMethod( XAlphToken, this, "getTotalSupply", params === undefined ? {} : params, getContractByCodeHash ); }, get: async ( params: XAlphTokenTypes.CallMethodParams<"get"> ): Promise> => { return callMethod(XAlphToken, this, "get", params, getContractByCodeHash); }, find: async ( params: XAlphTokenTypes.CallMethodParams<"find"> ): Promise> => { return callMethod( XAlphToken, this, "find", params, getContractByCodeHash ); }, remove: async ( params: XAlphTokenTypes.CallMethodParams<"remove"> ): Promise> => { return callMethod( XAlphToken, this, "remove", params, getContractByCodeHash ); }, push: async ( params: XAlphTokenTypes.CallMethodParams<"push"> ): Promise> => { return callMethod( XAlphToken, this, "push", params, getContractByCodeHash ); }, binarySearch: async ( params: XAlphTokenTypes.CallMethodParams<"binarySearch"> ): Promise> => { return callMethod( XAlphToken, this, "binarySearch", params, getContractByCodeHash ); }, removeAt: async ( params: XAlphTokenTypes.CallMethodParams<"removeAt"> ): Promise> => { return callMethod( XAlphToken, this, "removeAt", params, getContractByCodeHash ); }, size: async ( params: XAlphTokenTypes.CallMethodParams<"size"> ): Promise> => { return callMethod( XAlphToken, this, "size", params, getContractByCodeHash ); }, empty: async ( params?: XAlphTokenTypes.CallMethodParams<"empty"> ): Promise> => { return callMethod( XAlphToken, this, "empty", params === undefined ? {} : params, getContractByCodeHash ); }, stake: async ( params: XAlphTokenTypes.CallMethodParams<"stake"> ): Promise> => { return callMethod( XAlphToken, this, "stake", params, getContractByCodeHash ); }, startUnstake: async ( params: XAlphTokenTypes.CallMethodParams<"startUnstake"> ): Promise> => { return callMethod( XAlphToken, this, "startUnstake", params, getContractByCodeHash ); }, getActiveUnstakeVaultIndexes: async ( params: XAlphTokenTypes.CallMethodParams<"getActiveUnstakeVaultIndexes"> ): Promise< XAlphTokenTypes.CallMethodResult<"getActiveUnstakeVaultIndexes"> > => { return callMethod( XAlphToken, this, "getActiveUnstakeVaultIndexes", params, getContractByCodeHash ); }, getClaimableAmount: async ( params: XAlphTokenTypes.CallMethodParams<"getClaimableAmount"> ): Promise> => { return callMethod( XAlphToken, this, "getClaimableAmount", params, getContractByCodeHash ); }, claimUnstaked: async ( params: XAlphTokenTypes.CallMethodParams<"claimUnstaked"> ): Promise> => { return callMethod( XAlphToken, this, "claimUnstaked", params, getContractByCodeHash ); }, }; transact = { getSymbol: async ( params: XAlphTokenTypes.SignExecuteMethodParams<"getSymbol"> ): Promise> => { return signExecuteMethod(XAlphToken, this, "getSymbol", params); }, getName: async ( params: XAlphTokenTypes.SignExecuteMethodParams<"getName"> ): Promise> => { return signExecuteMethod(XAlphToken, this, "getName", params); }, getDecimals: async ( params: XAlphTokenTypes.SignExecuteMethodParams<"getDecimals"> ): Promise> => { return signExecuteMethod(XAlphToken, this, "getDecimals", params); }, getTotalSupply: async ( params: XAlphTokenTypes.SignExecuteMethodParams<"getTotalSupply"> ): Promise> => { return signExecuteMethod(XAlphToken, this, "getTotalSupply", params); }, get: async ( params: XAlphTokenTypes.SignExecuteMethodParams<"get"> ): Promise> => { return signExecuteMethod(XAlphToken, this, "get", params); }, find: async ( params: XAlphTokenTypes.SignExecuteMethodParams<"find"> ): Promise> => { return signExecuteMethod(XAlphToken, this, "find", params); }, remove: async ( params: XAlphTokenTypes.SignExecuteMethodParams<"remove"> ): Promise> => { return signExecuteMethod(XAlphToken, this, "remove", params); }, push: async ( params: XAlphTokenTypes.SignExecuteMethodParams<"push"> ): Promise> => { return signExecuteMethod(XAlphToken, this, "push", params); }, binarySearch: async ( params: XAlphTokenTypes.SignExecuteMethodParams<"binarySearch"> ): Promise> => { return signExecuteMethod(XAlphToken, this, "binarySearch", params); }, removeAt: async ( params: XAlphTokenTypes.SignExecuteMethodParams<"removeAt"> ): Promise> => { return signExecuteMethod(XAlphToken, this, "removeAt", params); }, size: async ( params: XAlphTokenTypes.SignExecuteMethodParams<"size"> ): Promise> => { return signExecuteMethod(XAlphToken, this, "size", params); }, empty: async ( params: XAlphTokenTypes.SignExecuteMethodParams<"empty"> ): Promise> => { return signExecuteMethod(XAlphToken, this, "empty", params); }, stake: async ( params: XAlphTokenTypes.SignExecuteMethodParams<"stake"> ): Promise> => { return signExecuteMethod(XAlphToken, this, "stake", params); }, startUnstake: async ( params: XAlphTokenTypes.SignExecuteMethodParams<"startUnstake"> ): Promise> => { return signExecuteMethod(XAlphToken, this, "startUnstake", params); }, getActiveUnstakeVaultIndexes: async ( params: XAlphTokenTypes.SignExecuteMethodParams<"getActiveUnstakeVaultIndexes"> ): Promise< XAlphTokenTypes.SignExecuteMethodResult<"getActiveUnstakeVaultIndexes"> > => { return signExecuteMethod( XAlphToken, this, "getActiveUnstakeVaultIndexes", params ); }, getClaimableAmount: async ( params: XAlphTokenTypes.SignExecuteMethodParams<"getClaimableAmount"> ): Promise< XAlphTokenTypes.SignExecuteMethodResult<"getClaimableAmount"> > => { return signExecuteMethod(XAlphToken, this, "getClaimableAmount", params); }, claimUnstaked: async ( params: XAlphTokenTypes.SignExecuteMethodParams<"claimUnstaked"> ): Promise> => { return signExecuteMethod(XAlphToken, this, "claimUnstaked", params); }, }; async multicall( calls: Calls ): Promise>; async multicall( callss: Narrow ): Promise>; async multicall< Callss extends | XAlphTokenTypes.MultiCallParams | XAlphTokenTypes.MultiCallParams[] >(callss: Callss): Promise { return await multicallMethods( XAlphToken, this, callss, getContractByCodeHash ); } }