-
Notifications
You must be signed in to change notification settings - Fork 756
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
136 additions
and
30 deletions.
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
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,2 @@ | ||
export * from './default'; | ||
export * from './interface'; |
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,74 @@ | ||
import { Account } from '../account'; | ||
import { Provider } from '../provider'; | ||
import { | ||
AddTransactionResponse, | ||
AsyncContractFunction, | ||
ContractFunction, | ||
Invocation, | ||
Result, | ||
} from '../types'; | ||
|
||
export abstract class ContractInterface { | ||
public abstract address: string; | ||
|
||
public abstract providerOrAccount: Provider | Account; | ||
|
||
readonly functions!: { [name: string]: AsyncContractFunction }; | ||
|
||
readonly callStatic!: { [name: string]: AsyncContractFunction }; | ||
|
||
readonly populateTransaction!: { [name: string]: ContractFunction }; | ||
|
||
readonly estimateFee!: { [name: string]: ContractFunction }; | ||
|
||
readonly [key: string]: AsyncContractFunction | any; | ||
|
||
/** | ||
* Saves the address of the contract deployed on network that will be used for interaction | ||
* | ||
* @param address - address of the contract | ||
*/ | ||
public abstract attach(address: string): void; | ||
|
||
/** | ||
* Attaches to new Provider or Account | ||
* | ||
* @param providerOrAccount - new Provider or Account to attach to | ||
*/ | ||
public abstract connect(providerOrAccount: Provider | Account): void; | ||
|
||
/** | ||
* Calls a method on a contract | ||
* | ||
* @param method name of the method | ||
* @param args Array of the arguments for the call | ||
* @returns Result of the call as an array with key value pars | ||
*/ | ||
public abstract call(method: string, args: Array<any>): Promise<Result>; | ||
|
||
/** | ||
* Invokes a method on a contract | ||
* | ||
* @param method name of the method | ||
* @param args Array of the arguments for the invoke | ||
* @returns Add Transaction Response | ||
*/ | ||
public abstract invoke(method: string, args: Array<any>): Promise<AddTransactionResponse>; | ||
|
||
/** | ||
* Calls a method on a contract | ||
* | ||
* @param method name of the method | ||
* @param args Array of the arguments for the call | ||
*/ | ||
public abstract estimate(method: string, args: Array<any>): Promise<any>; | ||
|
||
/** | ||
* Calls a method on a contract | ||
* | ||
* @param method name of the method | ||
* @param args Array of the arguments for the call | ||
* @returns Invocation objet | ||
*/ | ||
public abstract populate(method: string, args: Array<any>): Invocation; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export type AsyncContractFunction<T = any> = (...args: Array<any>) => Promise<T>; | ||
export type ContractFunction = (...args: Array<any>) => any; | ||
export interface Result extends Array<any> { | ||
[key: string]: any; | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './lib'; | ||
export * from './api'; | ||
export * from './signer'; | ||
export * from './contract'; |
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