Skip to content

Commit

Permalink
fix: [#41] fix for "like" interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
mdnorman committed Jan 11, 2022
1 parent 9fb8f47 commit ae83b94
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/contracts/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
*/

import { IActivityHooks } from '../../types/contracts';
import { LikeInterface } from '../interfaces';

export type ActivityHooksLike = IActivityHooks;
export type ActivityHooksLike = LikeInterface<IActivityHooks>;
3 changes: 2 additions & 1 deletion src/contracts/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import { ArtifactInit, ERC721Init, ERC721TokenInfoInit, IERC721Hooks } from '../../types/contracts';
import { IArtifact } from '../../types/contracts/IActivityExecutor';
import { LikeInterface } from '../interfaces';
import ContractAddress from './ContractAddress';
import { DiamondInitFunction } from './diamonds';
import { TransferHooksLike } from './transfer';
Expand All @@ -36,7 +37,7 @@ export interface ArtifactData {
transferHooks: TransferHooksLike;
}

type ERC721HooksLike = IERC721Hooks;
type ERC721HooksLike = LikeInterface<IERC721Hooks>;

export const buildArtifactInitFunction = (init: ArtifactInit, initData: ArtifactData): DiamondInitFunction => ({
initAddress: init.address,
Expand Down
7 changes: 4 additions & 3 deletions src/contracts/consumables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import { IConsumable, IConsumableHooks, IERC20 } from '../../types/contracts';
import { IConsumable as IConsumableNamespace } from '../../types/contracts/IConsumableConsumer';
import { LikeInterface } from '../interfaces';
import ContractAddress from './ContractAddress';

export type ConsumableAmountLike = ConsumableAmount | ConsumableAmountBN;
Expand All @@ -30,7 +31,7 @@ export interface ConsumableAmount {

export type ConsumableAmountBN = IConsumableNamespace.ConsumableAmountStructOutput;

export type ERC20Like = IERC20 | ConsumableLike;
export type ConsumableLike = IConsumable;
export type ERC20Like = LikeInterface<IERC20> | ConsumableLike;
export type ConsumableLike = LikeInterface<IConsumable>;

export type ConsumableHooksLike = IConsumableHooks;
export type ConsumableHooksLike = LikeInterface<IConsumableHooks>;
3 changes: 2 additions & 1 deletion src/contracts/consumables/exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import { ConsumableExchangeInit, IConsumableExchange } from '../../../types/contracts';
import { IConsumableExchange as IConsumableExchangeNamespace } from '../../../types/contracts/ConsumableExchangeFacet';
import { LikeInterface } from '../../interfaces';
import { ConsumableHooksLike, ERC20Like } from '../consumables';
import { DiamondInitFunction } from '../diamonds';

Expand All @@ -29,7 +30,7 @@ export interface ExchangeRate {

export type ExchangeRateBN = IConsumableExchangeNamespace.ExchangeRateStructOutput;

export type ConsumableExchangeLike = ERC20Like | IConsumableExchange;
export type ConsumableExchangeLike = LikeInterface<ERC20Like> | LikeInterface<IConsumableExchange>;

export interface ConsumableExchangeInitData {
exchangeConsumableHooks: ConsumableHooksLike;
Expand Down
3 changes: 2 additions & 1 deletion src/contracts/skills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import { ISkillHooks } from '../../types/contracts';
import { ISkill } from '../../types/contracts/SkillConstrainedInit';
import { LikeInterface } from '../interfaces';
import ContractAddress from './ContractAddress';

export interface SkillLevel {
Expand All @@ -28,4 +29,4 @@ export interface SkillLevel {

export type SkillLevelBN = ISkill.SkillLevelStructOutput;

export type SkillHooksLike = ISkillHooks;
export type SkillHooksLike = LikeInterface<ISkillHooks>;
3 changes: 2 additions & 1 deletion src/contracts/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
*/

import { ITransferHooks } from '../../types/contracts';
import { LikeInterface } from '../interfaces';

export type TransferHooksLike = ITransferHooks;
export type TransferHooksLike = LikeInterface<ITransferHooks>;
32 changes: 32 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2022 The Paypr Company, LLC
*
* This file is part of Paypr Ethereum Contracts.
*
* Paypr Ethereum Contracts is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Paypr Ethereum Contracts is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Paypr Ethereum Contracts. If not, see <https://www.gnu.org/licenses/>.
*/

export type LikeInterface<I> = Omit<
I,
| 'attach'
| 'connect'
| 'contractName'
| 'deployed'
| 'interface'
| 'off'
| 'on'
| 'once'
| 'removeAllListeners'
| 'removeListener'
>;

0 comments on commit ae83b94

Please sign in to comment.