Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

feat(studio): Generate Viem contract factories #3025

Merged
merged 7 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

- name: Studio Background Check 🚓
env:
NODE_OPTIONS: '--max_old_space_size=4096'
NODE_OPTIONS: '--max_old_space_size=8192'
run: pnpm build

unit:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:

- name: Build package
env:
NODE_OPTIONS: '--max_old_space_size=4096'
NODE_OPTIONS: '--max_old_space_size=8192'
run: pnpm build
if: ${{ steps.release.outputs.release_created }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const generateEthersContractFactory = async (location: string) => {
${imports.join('\n')}
${isRoot ? '' : "import { ContractFactory } from '~contract/contracts'"}

type ContractOpts = {address: string, network: Network};
${abis.length ? `type ContractOpts = {address: string, network: Network};` : ''}
${!isRoot ? '' : 'type NetworkProviderResolver = (network: Network) => StaticJsonRpcProvider;'}

${
Expand Down
44 changes: 44 additions & 0 deletions src/apps/aave-safety-module/contracts/ethers.contract-factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Injectable, Inject } from '@nestjs/common';

import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface';
import { ContractFactory } from '~contract/contracts';
import { Network } from '~types/network.interface';

import {
AaveAbpt__factory,
AaveBpt__factory,
AaveStkAave__factory,
AaveStkAbpt__factory,
AaveStkApyHelper__factory,
} from './ethers';

type ContractOpts = { address: string; network: Network };

@Injectable()
export class AaveSafetyModuleContractFactory extends ContractFactory {
constructor(@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit) {
super((network: Network) => appToolkit.getNetworkProvider(network));
}

aaveAbpt({ address, network }: ContractOpts) {
return AaveAbpt__factory.connect(address, this.appToolkit.getNetworkProvider(network));
}
aaveBpt({ address, network }: ContractOpts) {
return AaveBpt__factory.connect(address, this.appToolkit.getNetworkProvider(network));
}
aaveStkAave({ address, network }: ContractOpts) {
return AaveStkAave__factory.connect(address, this.appToolkit.getNetworkProvider(network));
}
aaveStkAbpt({ address, network }: ContractOpts) {
return AaveStkAbpt__factory.connect(address, this.appToolkit.getNetworkProvider(network));
}
aaveStkApyHelper({ address, network }: ContractOpts) {
return AaveStkApyHelper__factory.connect(address, this.appToolkit.getNetworkProvider(network));
}
}

export type { AaveAbpt } from './ethers';
export type { AaveBpt } from './ethers';
export type { AaveStkAave } from './ethers';
export type { AaveStkAbpt } from './ethers';
export type { AaveStkApyHelper } from './ethers';
50 changes: 5 additions & 45 deletions src/apps/aave-safety-module/contracts/index.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,5 @@
import { Injectable, Inject } from '@nestjs/common';

import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface';
import { ContractFactory } from '~contract/contracts';
import { Network } from '~types/network.interface';

import {
AaveAbpt__factory,
AaveBpt__factory,
AaveStkAave__factory,
AaveStkAbpt__factory,
AaveStkApyHelper__factory,
} from './ethers';

// eslint-disable-next-line
type ContractOpts = { address: string; network: Network };

@Injectable()
export class AaveSafetyModuleContractFactory extends ContractFactory {
constructor(@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit) {
super((network: Network) => appToolkit.getNetworkProvider(network));
}

aaveAbpt({ address, network }: ContractOpts) {
return AaveAbpt__factory.connect(address, this.appToolkit.getNetworkProvider(network));
}
aaveBpt({ address, network }: ContractOpts) {
return AaveBpt__factory.connect(address, this.appToolkit.getNetworkProvider(network));
}
aaveStkAave({ address, network }: ContractOpts) {
return AaveStkAave__factory.connect(address, this.appToolkit.getNetworkProvider(network));
}
aaveStkAbpt({ address, network }: ContractOpts) {
return AaveStkAbpt__factory.connect(address, this.appToolkit.getNetworkProvider(network));
}
aaveStkApyHelper({ address, network }: ContractOpts) {
return AaveStkApyHelper__factory.connect(address, this.appToolkit.getNetworkProvider(network));
}
}

export type { AaveAbpt } from './ethers';
export type { AaveBpt } from './ethers';
export type { AaveStkAave } from './ethers';
export type { AaveStkAbpt } from './ethers';
export type { AaveStkApyHelper } from './ethers';
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export * from './ethers.contract-factory';
export * from './viem.contract-factory';
35 changes: 35 additions & 0 deletions src/apps/aave-safety-module/contracts/viem.contract-factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Injectable, Inject } from '@nestjs/common';

import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface';
import { Network } from '~types/network.interface';

import {
AaveAbpt__factory,
AaveBpt__factory,
AaveStkAave__factory,
AaveStkAbpt__factory,
AaveStkApyHelper__factory,
} from './viem';

type ContractOpts = { address: string; network: Network };

@Injectable()
export class AaveSafetyModuleViemContractFactory {
constructor(@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit) {}

aaveAbpt({ address, network }: ContractOpts) {
return AaveAbpt__factory.connect(address, this.appToolkit.getViemNetworkProvider(network));
}
aaveBpt({ address, network }: ContractOpts) {
return AaveBpt__factory.connect(address, this.appToolkit.getViemNetworkProvider(network));
}
aaveStkAave({ address, network }: ContractOpts) {
return AaveStkAave__factory.connect(address, this.appToolkit.getViemNetworkProvider(network));
}
aaveStkAbpt({ address, network }: ContractOpts) {
return AaveStkAbpt__factory.connect(address, this.appToolkit.getViemNetworkProvider(network));
}
aaveStkApyHelper({ address, network }: ContractOpts) {
return AaveStkApyHelper__factory.connect(address, this.appToolkit.getViemNetworkProvider(network));
}
}
Loading
Loading