-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from skalenetwork/paymaster
Add paymaster support
- Loading branch information
Showing
4 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
typescript/base/src/projects/paymaster/paymasterInstance.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
ContractAddress, | ||
ContractName | ||
} from "../../domain/types"; | ||
import { Instance } from "../../instance"; | ||
|
||
|
||
export class PaymasterInstance<ContractType> extends | ||
Instance<ContractType> { | ||
async getContractAddress (name: ContractName): Promise<ContractAddress> { | ||
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 | ||
} | ||
); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
typescript/base/src/projects/paymaster/paymasterProject.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Instance } from "../../instance"; | ||
import { PaymasterInstance } from "./paymasterInstance"; | ||
import { Project } from "../../project"; | ||
|
||
export class PaymasterProject<ContractType> extends | ||
Project<ContractType> { | ||
githubRepo = "https://github.com/skalenetwork/paymaster/"; | ||
|
||
createInstance (address: string): Instance<ContractType> { | ||
return new PaymasterInstance( | ||
this, | ||
address | ||
); | ||
} | ||
|
||
getAbiFilename (version: string) { | ||
return `${this.metadata.name}-${version}-abi.json`; | ||
} | ||
} |