diff --git a/src/accounts/accountManager.ts b/src/accounts/accountManager.ts index e2e95c8..615fa20 100644 --- a/src/accounts/accountManager.ts +++ b/src/accounts/accountManager.ts @@ -136,13 +136,12 @@ export class AccountManager { /** * Grants `eosio.code` permission to the specified account's `active` key - * @note Should be moved to the `contracts/contract.ts` I think? - * @note Actually it is `account` based and not specific to contracts... + * @note Can also be called directly on a contract. * @author Kevin Brown * @author Mitch Pierias * @param account Account without `eosio.code` permissions */ - static addCodePermission = async (account: Account) => { + public static addCodePermission = async (account: Account) => { // We need to get their existing permissions, then add in a new eosio.code permission for this contract. const { permissions } = await EOSManager.rpc.get_account(account.name); const { required_auth } = permissions.find( diff --git a/src/contracts/contract.ts b/src/contracts/contract.ts index 033c1c5..dcef8ae 100644 --- a/src/contracts/contract.ts +++ b/src/contracts/contract.ts @@ -1,4 +1,4 @@ -import { Account } from '../accounts'; +import { Account, AccountManager } from '../accounts'; import { nextBlock } from '../utils'; import { Api } from 'eosjs'; import { Contract as EOSJSContract, Type } from 'eosjs/dist/eosjs-serialize'; @@ -135,7 +135,7 @@ export class Contract implements EOSJSContract { * @param table The table name * @param scope Optional table scope, defaults to the table name */ - getTableRows = async (table: string, scope?: string) => { + public getTableRows = async (table: string, scope?: string) => { // Wait for the next block to appear before we query the values. await nextBlock(); @@ -184,4 +184,12 @@ export class Contract implements EOSJSContract { return result; }; + + /** + * Grants `eosio.code` permission to the contract account's `active` key + * @note Can also be called from AccountManager, as the action is technically an account based action. + * @author Kevin Brown + * @author Mitch Pierias + */ + public addCodePermission = () => AccountManager.addCodePermission(this._account); }