Skip to content

Commit

Permalink
fix: contract interface
Browse files Browse the repository at this point in the history
  • Loading branch information
janek26 committed Mar 11, 2022
1 parent 95185d1 commit 696116d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
16 changes: 10 additions & 6 deletions src/contract/default.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import BN from 'bn.js';
import assert from 'minimalistic-assert';

import { Account } from '../account';
import { Provider, defaultProvider } from '../provider';
import { AccountInterface } from '../account';
import { ProviderInterface, defaultProvider } from '../provider';
import {
Abi,
AbiEntry,
Expand Down Expand Up @@ -85,7 +85,7 @@ export class Contract implements ContractInterface {

address: string;

providerOrAccount: Provider | Account;
providerOrAccount: ProviderInterface | AccountInterface;

deployTransactionHash?: string;

Expand All @@ -108,7 +108,11 @@ export class Contract implements ContractInterface {
* @param address (optional) - address to connect to
* @param providerOrAccount (optional) - Provider or Account to attach to
*/
constructor(abi: Abi, address: string, providerOrAccount: Provider | Account = defaultProvider) {
constructor(
abi: Abi,
address: string,
providerOrAccount: ProviderInterface | AccountInterface = defaultProvider
) {
this.address = address;
this.providerOrAccount = providerOrAccount;
this.abi = abi;
Expand Down Expand Up @@ -202,7 +206,7 @@ export class Contract implements ContractInterface {
*
* @param providerOrAccount - new Provider or Account to attach to
*/
public connect(providerOrAccount: Provider | Account) {
public connect(providerOrAccount: ProviderInterface | AccountInterface) {
this.providerOrAccount = providerOrAccount;
}

Expand Down Expand Up @@ -554,7 +558,7 @@ export class Contract implements ContractInterface {
calldata,
entrypoint: method,
};
if (this.providerOrAccount instanceof Account) {
if (this.providerOrAccount instanceof AccountInterface) {
return this.providerOrAccount.execute(invocation);
}
return this.providerOrAccount.invokeFunction({
Expand Down
8 changes: 4 additions & 4 deletions src/contract/interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Account } from '../account';
import { Provider } from '../provider';
import { AccountInterface } from '../account';
import { ProviderInterface } from '../provider';
import {
Abi,
AddTransactionResponse,
Expand All @@ -14,7 +14,7 @@ export abstract class ContractInterface {

public abstract address: string;

public abstract providerOrAccount: Provider | Account;
public abstract providerOrAccount: ProviderInterface | AccountInterface;

public abstract deployTransactionHash?: string;

Expand All @@ -40,7 +40,7 @@ export abstract class ContractInterface {
*
* @param providerOrAccount - new Provider or Account to attach to
*/
public abstract connect(providerOrAccount: Provider | Account): void;
public abstract connect(providerOrAccount: ProviderInterface | AccountInterface): void;

/**
* Resolves when contract is deployed on the network or when no deployment transaction is found
Expand Down

0 comments on commit 696116d

Please sign in to comment.