diff --git a/python/src/skale_contracts/projects/paymaster.py b/python/src/skale_contracts/projects/paymaster.py index b01a669..ccaad15 100644 --- a/python/src/skale_contracts/projects/paymaster.py +++ b/python/src/skale_contracts/projects/paymaster.py @@ -22,7 +22,7 @@ def get_contract_address( return self.address if name == "PaymasterAccessManager": return to_canonical_address( - self.get_contract("FastForwardPaymaster") + self.get_contract("Paymaster") .functions.authority().call() ) raise RuntimeError(f"Can't get address of {name} contract") diff --git a/typescript/base/src/projects/factory.ts b/typescript/base/src/projects/factory.ts index 05281d9..2aa8beb 100644 --- a/typescript/base/src/projects/factory.ts +++ b/typescript/base/src/projects/factory.ts @@ -1,5 +1,6 @@ import { MainnetImaProject } from "./ima/mainnet/MainnetImaProject"; import { Network } from "../network"; +import { PaymasterProject } from "./paymaster/paymasterProject"; import { Project } from "../project"; import { ProjectNotFoundError @@ -14,6 +15,10 @@ export const projects = { "name": "mainnet-ima", "path": "mainnet-ima" }, + "paymaster": { + "name": "paymaster", + "path": "paymaster" + }, "schainIma": { "name": "schain-ima", "path": "schain-ima" @@ -53,6 +58,11 @@ export const createProject = network, projects.skaleAllocator ); + } else if (name === projects.paymaster.name) { + return new PaymasterProject( + network, + projects.paymaster + ); } throw new ProjectNotFoundError(`Project with name ${name} is unknown`); }; diff --git a/typescript/base/src/projects/paymaster/paymasterInstance.ts b/typescript/base/src/projects/paymaster/paymasterInstance.ts new file mode 100644 index 0000000..d8318e9 --- /dev/null +++ b/typescript/base/src/projects/paymaster/paymasterInstance.ts @@ -0,0 +1,40 @@ +import { + ContractAddress, + ContractName +} from "../../domain/types"; +import { Instance } from "../../instance"; + + +export class PaymasterInstance extends + Instance { + async getContractAddress (name: ContractName): Promise { + if ([ + "Paymaster", + "FastForwardPaymaster" + ].includes(name)) { + return this.address; + } + if (name === "PaymasterAccessManager") { + return await this.callPaymaster( + "authority", + [] + ) as ContractAddress; + } + throw new Error(`Contract ${name} is not found`); + } + + // Private + + private async callPaymaster (functionName: string, args: unknown[]) { + return this.project.network.adapter.makeCall( + { + "abi": await this.getContractAbi("Paymaster"), + "address": this.address + }, + { + args, + functionName + } + ); + } +} diff --git a/typescript/base/src/projects/paymaster/paymasterProject.ts b/typescript/base/src/projects/paymaster/paymasterProject.ts new file mode 100644 index 0000000..94991ab --- /dev/null +++ b/typescript/base/src/projects/paymaster/paymasterProject.ts @@ -0,0 +1,19 @@ +import { Instance } from "../../instance"; +import { PaymasterInstance } from "./paymasterInstance"; +import { Project } from "../../project"; + +export class PaymasterProject extends + Project { + githubRepo = "https://github.com/skalenetwork/paymaster/"; + + createInstance (address: string): Instance { + return new PaymasterInstance( + this, + address + ); + } + + getAbiFilename (version: string) { + return `${this.metadata.name}-${version}-abi.json`; + } +}