Skip to content

Commit

Permalink
Ran make format
Browse files Browse the repository at this point in the history
  • Loading branch information
aaroncox committed Oct 12, 2023
1 parent c49d79c commit 2eb4458
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
10 changes: 4 additions & 6 deletions src/kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import {Contract} from '@wharfkit/contract'

import {Account} from './account'
import {TelosAccountObject, WAXAccountObject} from './types'
export interface ChainDefinition<DataType extends API.v1.AccountObject = any> {
id: string
url: string
dataType?: typeof API.v1.AccountObject
id: string
url: string
dataType?: typeof API.v1.AccountObject
}
export namespace Chains {
export const EOS: ChainDefinition<API.v1.AccountObject> = {
id: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906',
Expand Down Expand Up @@ -56,7 +54,7 @@ export class AccountKit<DataType extends API.v1.AccountObject = API.v1.AccountOb
constructor(chain: ChainDefinition<DataType>, options?: AccountKitOptions) {
this.chain = chain
this.contract = options?.contract
this.client = options?.client || new APIClient({ url: this.chain.url })
this.client = options?.client || new APIClient({url: this.chain.url})
}

async load(accountName: NameType): Promise<Account<DataType>> {
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ export class WAXAccountVoterInfo extends API.v1.AccountVoterInfo {
@Struct.type('wax_account_object')
export class WAXAccountObject extends API.v1.AccountObject {
@Struct.field(WAXAccountVoterInfo, {optional: true}) declare voter_info?: WAXAccountVoterInfo
}
}
2 changes: 1 addition & 1 deletion test/tests/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {Account, AccountKit, Chains, Permission, SystemContract} from '../../src
const mockAccountName = 'wharfkit1133'

const client = makeClient('https://jungle4.greymass.com')
const accountKit = new AccountKit(Chains.Jungle4, { client })
const accountKit = new AccountKit(Chains.Jungle4, {client})
const session = new Session(
{
...mockSessionArgs,
Expand Down
21 changes: 10 additions & 11 deletions test/tests/kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {assert, expect} from 'chai'

import {Account, AccountKit, Chains, SystemContract} from '../../src'
import {makeClient} from '@wharfkit/mock-data'
import { API } from '@wharfkit/antelope'
import { TelosAccountObject, WAXAccountObject } from 'src/types'
import {API} from '@wharfkit/antelope'
import {TelosAccountObject, WAXAccountObject} from 'src/types'

const client = makeClient('https://jungle4.greymass.com')

Expand All @@ -20,20 +20,17 @@ suite('AccountKit', function () {
})

test('allow overriding of default contract', function () {
const kit = new AccountKit(
Chains.Jungle4,
{
contract: new SystemContract.Contract({ client }),
},
)
const kit = new AccountKit(Chains.Jungle4, {
contract: new SystemContract.Contract({client}),
})

expect(kit.contract).to.exist
})
})

suite('load', function () {
this.beforeAll(function () {
accountKit = new AccountKit(Chains.Jungle4, { client })
accountKit = new AccountKit(Chains.Jungle4, {client})
})

test('throws error if account does not exist', async function () {
Expand All @@ -51,7 +48,9 @@ suite('AccountKit', function () {
})

test('returns telos account type', async function () {
const kit = new AccountKit(Chains.Telos, { client: makeClient('https://telos.greymass.com') })
const kit = new AccountKit(Chains.Telos, {
client: makeClient('https://telos.greymass.com'),
})
const account = await kit.load('teamgreymass')
expect(account.data).to.be.instanceOf(API.v1.AccountObject)
expect(account.data).to.be.instanceOf(TelosAccountObject)
Expand All @@ -60,7 +59,7 @@ suite('AccountKit', function () {
})

test('returns wax account type', async function () {
const kit = new AccountKit(Chains.WAX, { client: makeClient('https://wax.greymass.com') })
const kit = new AccountKit(Chains.WAX, {client: makeClient('https://wax.greymass.com')})
const account = await kit.load('teamgreymass')
expect(account.data).to.be.instanceOf(API.v1.AccountObject)
expect(account.data).not.to.be.instanceOf(TelosAccountObject)
Expand Down

0 comments on commit 2eb4458

Please sign in to comment.