Skip to content

Commit

Permalink
style: linted
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Aug 31, 2023
1 parent 1ad3fea commit d942c77
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 148 deletions.
56 changes: 25 additions & 31 deletions src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export class Account {
readonly eosioContract: Eosio.Contract
readonly client: APIClient

constructor({ accountData, client }: AccountArgs) {
constructor({accountData, client}: AccountArgs) {
this.account_data = accountData
this.eosioContract = new Eosio.Contract({ client })
this.eosioContract = new Eosio.Contract({client})
this.client = client
}

Expand All @@ -42,8 +42,8 @@ export class Account {
}

getPermission(permissionName: NameType): Permission {
const permissionObject = this.account_data.permissions.find(
(permission) => permission.perm_name.equals(permissionName)
const permissionObject = this.account_data.permissions.find((permission) =>
permission.perm_name.equals(permissionName)
)

if (!permissionObject) {
Expand All @@ -57,7 +57,7 @@ export class Account {
parent: permissionObject.parent,
permission: permissionObject.perm_name,
auth: Authority.from(permissionObject.required_auth),
authorized_by: "............1",
authorized_by: '............1',
})
}

Expand All @@ -67,58 +67,52 @@ export class Account {

removePermission(permissionName: NameType): Action {
return this.eosioContract.action('deleteauth', {
account: "............1",
authorized_by: "............1",
account: '............1',
authorized_by: '............1',
permission: permissionName,
})
}

buyRam(amount: AssetType): Action {
return this.eosioContract.action('buyram', {
payer: "............1",
receiver: "............1",
payer: '............1',
receiver: '............1',
quant: amount,
})
}

buyRamBytes(bytes: number): Action {
return this.eosioContract.action('buyrambytes', {
payer: "............1",
receiver: "............1",
payer: '............1',
receiver: '............1',
bytes,
})
}

sellRam(bytes: number): Action {
return this.eosioContract.action('sellram', {
account: "............1",
account: '............1',
bytes,
})
}

delegateResources(cpu: AssetType, net: AssetType): Action {
return this.eosioContract.action(
'delegatebw',
{
from: "............1",
receiver: "............1",
stake_cpu_quantity: cpu,
stake_net_quantity: net,
transfer: false,
}
)
return this.eosioContract.action('delegatebw', {
from: '............1',
receiver: '............1',
stake_cpu_quantity: cpu,
stake_net_quantity: net,
transfer: false,
})
}

undelegateResources(cpu: AssetType, net: AssetType): Action {
return this.eosioContract.action(
'undelegatebw',
{
from: "............1",
receiver: "............1",
unstake_cpu_quantity: cpu,
unstake_net_quantity: net,
}
)
return this.eosioContract.action('undelegatebw', {
from: '............1',
receiver: '............1',
unstake_cpu_quantity: cpu,
unstake_net_quantity: net,
})
}

getResources(): Resources {
Expand Down
1 change: 0 additions & 1 deletion src/contracts/eosio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1536,4 +1536,3 @@ export namespace Eosio {
}
}
export default Eosio

3 changes: 1 addition & 2 deletions src/kit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import {APIClient, Name, NameType} from '@wharfkit/antelope'
import {Account} from './account'

Expand Down Expand Up @@ -39,4 +38,4 @@ export class AccountKit {
client: this.client,
})
}
}
}
163 changes: 83 additions & 80 deletions test/tests/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {API, APIClient} from '@wharfkit/antelope'
import {Account, AccountKit, Permission} from '../../src'
import {MockProvider} from '../utils/mock-provider'
import {deserializedMockAccountObject} from '../utils/mock-data'
import { Name } from '@greymass/eosio'
import { deserialize } from 'test/utils/helpers'
import {Name} from '@greymass/eosio'
import {deserialize} from 'test/utils/helpers'

const eosApiClient = new APIClient({
provider: new MockProvider('https://eos.greymass.com'),
Expand All @@ -15,11 +15,14 @@ suite('Account', function () {
let testAccount: Account

this.beforeAll(async function () {
testAccount = await (new AccountKit({client: eosApiClient})).load('teamgreymass')
testAccount = await new AccountKit({client: eosApiClient}).load('teamgreymass')
})

test('construct', function () {
const account = new Account({ client: eosApiClient, accountData: deserializedMockAccountObject})
const account = new Account({
client: eosApiClient,
accountData: deserializedMockAccountObject,
})

assert.instanceOf(account, Account)
})
Expand Down Expand Up @@ -69,11 +72,11 @@ suite('Account', function () {

suite('updatePermission', () => {
test('returns current Action', () => {
const permission = new Permission("permission", {
account: "............1",
parent: "............1",
permission: "............1",
authorized_by: "............1",
const permission = new Permission('permission', {
account: '............1',
parent: '............1',
permission: '............1',
authorized_by: '............1',
auth: {
accounts: [],
keys: [
Expand All @@ -85,123 +88,123 @@ suite('Account', function () {
threshold: 1,
waits: [],
},
});
const action = testAccount.updatePermission(permission);
})
const action = testAccount.updatePermission(permission)
assert.deepEqual(deserialize(action), {
account: "eosio",
account: 'eosio',
authorization: [
{
actor: "............1",
permission: "............2"
}
actor: '............1',
permission: '............2',
},
],
data: "01000000000000000100000000000000010000000000000001000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cf010000000100000000000000",
name: "updateauth"
});
});
});
data: '01000000000000000100000000000000010000000000000001000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cf010000000100000000000000',
name: 'updateauth',
})
})
})

suite('removePermission', () => {
test('returns current Action', () => {
const action = testAccount.removePermission("someName");
const action = testAccount.removePermission('someName')
assert.deepEqual(deserialize(action), {
account: "eosio",
account: 'eosio',
authorization: [
{
actor: "............1",
permission: "............2"
}
actor: '............1',
permission: '............2',
},
],
data: "01000000000000000000004a1aa024c50100000000000000",
name: "deleteauth"
});
});
});
data: '01000000000000000000004a1aa024c50100000000000000',
name: 'deleteauth',
})
})
})

suite('buyRam', () => {
test('returns current Action', () => {
const action = testAccount.buyRam("1.0000 EOS");
const action = testAccount.buyRam('1.0000 EOS')
assert.deepEqual(deserialize(action), {
account: "eosio",
account: 'eosio',
authorization: [
{
"actor": "............1",
"permission": "............2"
}
actor: '............1',
permission: '............2',
},
],
data: "01000000000000000100000000000000102700000000000004454f5300000000",
name: "buyram"
});
});
});
data: '01000000000000000100000000000000102700000000000004454f5300000000',
name: 'buyram',
})
})
})

suite('buyRamBytes', () => {
test('returns current Action', () => {
const action = testAccount.buyRamBytes(1024);
const action = testAccount.buyRamBytes(1024)
assert.deepEqual(deserialize(action), {
account: "eosio",
account: 'eosio',
authorization: [
{
actor: "............1",
permission: "............2"
}
actor: '............1',
permission: '............2',
},
],
data: "0100000000000000010000000000000000040000",
name: "buyrambytes"
});
});
});
data: '0100000000000000010000000000000000040000',
name: 'buyrambytes',
})
})
})

suite('sellRam', () => {
test('returns current Action', () => {
const action = testAccount.sellRam(1024);
const action = testAccount.sellRam(1024)
assert.deepEqual(deserialize(action), {
account: "eosio",
account: 'eosio',
authorization: [
{
actor: "............1",
permission: "............2"
}
actor: '............1',
permission: '............2',
},
],
data: "01000000000000000004000000000000",
name: "sellram"
});
});
});
data: '01000000000000000004000000000000',
name: 'sellram',
})
})
})

suite('delegateResources', () => {
test('returns current Action', () => {
const action = testAccount.delegateResources("1.0000 EOS", "0.5000 EOS");
const action = testAccount.delegateResources('1.0000 EOS', '0.5000 EOS')
assert.deepEqual(deserialize(action), {
account: "eosio",
account: 'eosio',
authorization: [
{
actor: "............1",
permission: "............2"
}
actor: '............1',
permission: '............2',
},
],
data: "01000000000000000100000000000000881300000000000004454f5300000000102700000000000004454f530000000000",
name: "delegatebw"
});
});
});
data: '01000000000000000100000000000000881300000000000004454f5300000000102700000000000004454f530000000000',
name: 'delegatebw',
})
})
})

suite('undelegateResources', () => {
test('returns current Action', () => {
const action = testAccount.undelegateResources("0.5000 EOS", "1.0000 EOS");
const action = testAccount.undelegateResources('0.5000 EOS', '1.0000 EOS')
assert.deepEqual(deserialize(action), {
account: "eosio",
account: 'eosio',
authorization: [
{
actor: "............1",
permission: "............2"
}
actor: '............1',
permission: '............2',
},
],
data: "01000000000000000100000000000000102700000000000004454f5300000000881300000000000004454f5300000000",
name: "undelegatebw"
});
});
});
data: '01000000000000000100000000000000102700000000000004454f5300000000881300000000000004454f5300000000',
name: 'undelegatebw',
})
})
})

suite('getBalance', function () {
this.slow(200)
Expand Down
Loading

0 comments on commit d942c77

Please sign in to comment.