Skip to content

Commit

Permalink
Made ContractLoader.at more flexible by allowing you to pass in an ac…
Browse files Browse the repository at this point in the history
…count, or just an account name if you prefer.
  • Loading branch information
thekevinbrown committed May 21, 2019
1 parent 49f1577 commit 6fa65f4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/contracts/contractLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ export class ContractLoader {
* Loads a contract instance for a contract which is already deployed to the blockchain.
*
* ```typescript
* ContractLoader.at<MyContractTypeDef>('mycontract');
* ContractLoader.at<MyContractTypeDef>(myContractAccount);
*
* // or
*
* ContractLoader.at<MyContractTypeDef>('my.contract');
* ```
* @author Kevin Brown <github.com/thekevinbrown>
* @param accountName The account name where the contract is already deployed.
* @param accountOrName The account or account name where the contract is already deployed.
* @returns Contract instance
*/
public static async at<T extends Contract>(account: Account) {
public static async at<T extends Contract>(accountOrName: Account | string) {
const account = accountOrName instanceof Account ? accountOrName : new Account(accountOrName);

// Load the ABI from the blockchain.
const { abi } = await EOSManager.rpc.get_abi(account.name);

Expand Down

0 comments on commit 6fa65f4

Please sign in to comment.