Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added voter_info fields back in #72

Merged
merged 4 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@wharfkit/antelope",
"description": "Library for working with Antelope powered blockchains.",
"version": "0.7.3",
"version": "0.7.4-beta2",
"homepage": "https://github.com/wharfkit/antelope",
"license": "BSD-3-Clause-No-Military-License",
"main": "lib/antelope.js",
Expand Down
13 changes: 10 additions & 3 deletions src/api/v1/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ export class AccountVoterInfo extends Struct {
@Struct.field('name') declare proxy: Name
@Struct.field('name', {array: true}) declare producers: Name[]
@Struct.field('int64', {optional: true}) staked?: Int64
// @Struct.field('float64') declare last_vote_weight: Float64
// @Struct.field('float64') declare proxied_vote_weight: Float64
@Struct.field('float64') declare last_vote_weight: Float64
@Struct.field('float64') declare proxied_vote_weight: Float64
@Struct.field('bool') declare is_proxy: boolean
@Struct.field('uint32', {optional: true}) flags1?: UInt32
@Struct.field('uint32') reserved2!: UInt32
Expand Down Expand Up @@ -229,7 +229,14 @@ export class TrxVariant implements ABISerializableObject {

get transaction(): Transaction | undefined {
if (this.extra.packed_trx) {
return Serializer.decode({data: this.extra.packed_trx, type: Transaction})
switch (this.extra.compression) {
case 'none': {
return Serializer.decode({data: this.extra.packed_trx, type: Transaction})
}
default: {
throw new Error(`Unsupported compression type ${this.extra.compression}`)
}
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions test/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ suite('api v1', function () {
assert.equal(String(account.account_name), 'teamgreymass')
})

test('chain get_account (voter info)', async function () {
const account = await eos.v1.chain.get_account('teamgreymass')
assert.equal(String(account.account_name), 'teamgreymass')
const voterinfo = account.voter_info
assert.instanceOf(voterinfo!.last_vote_weight, Float64)
assert.instanceOf(voterinfo!.proxied_vote_weight, Float64)
})

test('chain get_account (system account)', async function () {
const account = await jungle.v1.chain.get_account('eosio')
assert.equal(String(account.account_name), 'eosio')
Expand Down
277 changes: 277 additions & 0 deletions test/data/8745e40a973fe2860ad803d3c20a76541d3b9392.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
{
"headers": {
"access-control-allow-headers": "X-Requested-With,Accept,Content-Type,Origin",
"access-control-allow-methods": "GET, POST, OPTIONS",
"access-control-allow-origin": "*",
"connection": "close",
"content-length": "3600",
"content-type": "application/json",
"date": "Sun, 30 Jul 2023 19:12:57 GMT",
"host": "eos.greymass.com",
"server": "nginx",
"x-cached": "MISS"
},
"status": 200,
"json": {
"account_name": "teamgreymass",
"head_block_num": 323116128,
"head_block_time": "2023-07-30T19:12:57.500",
"privileged": false,
"last_code_update": "1970-01-01T00:00:00.000",
"created": "2018-06-10T13:04:15.000",
"core_liquid_balance": "11768.7873 EOS",
"ram_quota": 67988,
"net_weight": 4497214,
"cpu_weight": "10674157299",
"net_limit": {
"used": 194529,
"available": 8278572,
"max": 8473101,
"last_usage_update_time": "2023-07-30T19:12:39.500",
"current_used": 194488
},
"cpu_limit": {
"used": 750173,
"available": 211970,
"max": 962143,
"last_usage_update_time": "2023-07-30T19:12:39.500",
"current_used": 750016
},
"ram_usage": 17516,
"permissions": [
{
"perm_name": "active",
"parent": "owner",
"required_auth": {
"threshold": 1,
"keys": [
{
"key": "EOS6gqJ7sdPgjHLFLtks9cRPs5qYHa9U3CwK4P2JasTLWKQ9kXZK1",
"weight": 1
}
],
"accounts": [],
"waits": []
},
"linked_actions": []
},
{
"perm_name": "claim",
"parent": "active",
"required_auth": {
"threshold": 1,
"keys": [
{
"key": "EOS6DLD9HxMcwn73U41jjdGsNe9vDFRKB26um6qTAqrtYcJFtED4C",
"weight": 1
}
],
"accounts": [],
"waits": []
},
"linked_actions": [
{
"account": "eosio",
"action": "claimrewards"
}
]
},
{
"perm_name": "decentium",
"parent": "active",
"required_auth": {
"threshold": 1,
"keys": [
{
"key": "EOS7knG7M5TUEdRv1bkVjTPddVoDQnwS7oEZXAgFk3A4hhocA3eJf",
"weight": 1
}
],
"accounts": [],
"waits": []
},
"linked_actions": [
{
"account": "decentiumorg"
}
]
},
{
"perm_name": "killswitch",
"parent": "active",
"required_auth": {
"threshold": 1,
"keys": [
{
"key": "EOS7CjC7GL71msPzAuAzd2WwiBEAzTcPL47ACrjSuiNmnnGGufYSn",
"weight": 1
}
],
"accounts": [],
"waits": []
},
"linked_actions": [
{
"account": "eosio",
"action": "unregprod"
}
]
},
{
"perm_name": "oracle",
"parent": "active",
"required_auth": {
"threshold": 1,
"keys": [
{
"key": "EOS88VqmDmJJ9S23eNqdeWYf2zySxv3ckQrWBKy7EvVRCUuhSU4f3",
"weight": 1
}
],
"accounts": [],
"waits": []
},
"linked_actions": [
{
"account": "delphioracle",
"action": "write"
}
]
},
{
"perm_name": "owner",
"parent": "",
"required_auth": {
"threshold": 1,
"keys": [
{
"key": "EOS8QzGtCea2thiqcTVeXGdyRZpdKYptQznbcWSMj73FD5RgwKN82",
"weight": 1
}
],
"accounts": [],
"waits": []
},
"linked_actions": []
},
{
"perm_name": "producerjson",
"parent": "active",
"required_auth": {
"threshold": 1,
"keys": [
{
"key": "EOS5JCEciUdfXnQmTyj85T98bXTAZZ1g7Nmajseu7ZWB8DrDa6Etp",
"weight": 1
}
],
"accounts": [],
"waits": []
},
"linked_actions": [
{
"account": "producerjson",
"action": "set"
}
]
},
{
"perm_name": "transfer",
"parent": "active",
"required_auth": {
"threshold": 1,
"keys": [
{
"key": "EOS7qZ8nnmn6KBnjQL4oukyZFWCj8DmC9nJE2nkAYAZbwgKhMu8cW",
"weight": 1
}
],
"accounts": [],
"waits": []
},
"linked_actions": [
{
"account": "eosio.token",
"action": "transfer"
}
]
},
{
"perm_name": "vote",
"parent": "active",
"required_auth": {
"threshold": 1,
"keys": [
{
"key": "EOS65NrHPVXaV4voxepQREmYCmnMJm4tAWdxPaK46CbUN1rrVmRzg",
"weight": 1
}
],
"accounts": [],
"waits": []
},
"linked_actions": [
{
"account": "eosio",
"action": "voteproducer"
}
]
},
{
"perm_name": "voting",
"parent": "active",
"required_auth": {
"threshold": 1,
"keys": [
{
"key": "EOS7pn6P5FftyNAKRfx9VcUzBFMvC4UitNbnoKbfxNe8SShELo2it",
"weight": 1
}
],
"accounts": [],
"waits": []
},
"linked_actions": [
{
"account": "eosio.forum",
"action": "vote"
},
{
"account": "eosio.forum",
"action": "unvote"
}
]
}
],
"total_resources": {
"owner": "teamgreymass",
"net_weight": "449.7214 EOS",
"cpu_weight": "1067415.7299 EOS",
"ram_bytes": 66588
},
"self_delegated_bandwidth": null,
"refund_request": null,
"voter_info": {
"owner": "teamgreymass",
"proxy": "greymassvote",
"producers": [],
"staked": 100202,
"last_vote_weight": "863265464502.93908691406250000",
"proxied_vote_weight": "0.00000000000000000",
"is_proxy": 0,
"flags1": 0,
"reserved2": 0,
"reserved3": "0.0000 EOS"
},
"rex_info": null,
"subjective_cpu_bill_limit": {
"used": 0,
"available": 0,
"max": 0,
"last_usage_update_time": "2000-01-01T00:00:00.000",
"current_used": 0
},
"eosio_any_linked_actions": []
},
"text": "{\"account_name\":\"teamgreymass\",\"head_block_num\":323116128,\"head_block_time\":\"2023-07-30T19:12:57.500\",\"privileged\":false,\"last_code_update\":\"1970-01-01T00:00:00.000\",\"created\":\"2018-06-10T13:04:15.000\",\"core_liquid_balance\":\"11768.7873 EOS\",\"ram_quota\":67988,\"net_weight\":4497214,\"cpu_weight\":\"10674157299\",\"net_limit\":{\"used\":194529,\"available\":8278572,\"max\":8473101,\"last_usage_update_time\":\"2023-07-30T19:12:39.500\",\"current_used\":194488},\"cpu_limit\":{\"used\":750173,\"available\":211970,\"max\":962143,\"last_usage_update_time\":\"2023-07-30T19:12:39.500\",\"current_used\":750016},\"ram_usage\":17516,\"permissions\":[{\"perm_name\":\"active\",\"parent\":\"owner\",\"required_auth\":{\"threshold\":1,\"keys\":[{\"key\":\"EOS6gqJ7sdPgjHLFLtks9cRPs5qYHa9U3CwK4P2JasTLWKQ9kXZK1\",\"weight\":1}],\"accounts\":[],\"waits\":[]},\"linked_actions\":[]},{\"perm_name\":\"claim\",\"parent\":\"active\",\"required_auth\":{\"threshold\":1,\"keys\":[{\"key\":\"EOS6DLD9HxMcwn73U41jjdGsNe9vDFRKB26um6qTAqrtYcJFtED4C\",\"weight\":1}],\"accounts\":[],\"waits\":[]},\"linked_actions\":[{\"account\":\"eosio\",\"action\":\"claimrewards\"}]},{\"perm_name\":\"decentium\",\"parent\":\"active\",\"required_auth\":{\"threshold\":1,\"keys\":[{\"key\":\"EOS7knG7M5TUEdRv1bkVjTPddVoDQnwS7oEZXAgFk3A4hhocA3eJf\",\"weight\":1}],\"accounts\":[],\"waits\":[]},\"linked_actions\":[{\"account\":\"decentiumorg\"}]},{\"perm_name\":\"killswitch\",\"parent\":\"active\",\"required_auth\":{\"threshold\":1,\"keys\":[{\"key\":\"EOS7CjC7GL71msPzAuAzd2WwiBEAzTcPL47ACrjSuiNmnnGGufYSn\",\"weight\":1}],\"accounts\":[],\"waits\":[]},\"linked_actions\":[{\"account\":\"eosio\",\"action\":\"unregprod\"}]},{\"perm_name\":\"oracle\",\"parent\":\"active\",\"required_auth\":{\"threshold\":1,\"keys\":[{\"key\":\"EOS88VqmDmJJ9S23eNqdeWYf2zySxv3ckQrWBKy7EvVRCUuhSU4f3\",\"weight\":1}],\"accounts\":[],\"waits\":[]},\"linked_actions\":[{\"account\":\"delphioracle\",\"action\":\"write\"}]},{\"perm_name\":\"owner\",\"parent\":\"\",\"required_auth\":{\"threshold\":1,\"keys\":[{\"key\":\"EOS8QzGtCea2thiqcTVeXGdyRZpdKYptQznbcWSMj73FD5RgwKN82\",\"weight\":1}],\"accounts\":[],\"waits\":[]},\"linked_actions\":[]},{\"perm_name\":\"producerjson\",\"parent\":\"active\",\"required_auth\":{\"threshold\":1,\"keys\":[{\"key\":\"EOS5JCEciUdfXnQmTyj85T98bXTAZZ1g7Nmajseu7ZWB8DrDa6Etp\",\"weight\":1}],\"accounts\":[],\"waits\":[]},\"linked_actions\":[{\"account\":\"producerjson\",\"action\":\"set\"}]},{\"perm_name\":\"transfer\",\"parent\":\"active\",\"required_auth\":{\"threshold\":1,\"keys\":[{\"key\":\"EOS7qZ8nnmn6KBnjQL4oukyZFWCj8DmC9nJE2nkAYAZbwgKhMu8cW\",\"weight\":1}],\"accounts\":[],\"waits\":[]},\"linked_actions\":[{\"account\":\"eosio.token\",\"action\":\"transfer\"}]},{\"perm_name\":\"vote\",\"parent\":\"active\",\"required_auth\":{\"threshold\":1,\"keys\":[{\"key\":\"EOS65NrHPVXaV4voxepQREmYCmnMJm4tAWdxPaK46CbUN1rrVmRzg\",\"weight\":1}],\"accounts\":[],\"waits\":[]},\"linked_actions\":[{\"account\":\"eosio\",\"action\":\"voteproducer\"}]},{\"perm_name\":\"voting\",\"parent\":\"active\",\"required_auth\":{\"threshold\":1,\"keys\":[{\"key\":\"EOS7pn6P5FftyNAKRfx9VcUzBFMvC4UitNbnoKbfxNe8SShELo2it\",\"weight\":1}],\"accounts\":[],\"waits\":[]},\"linked_actions\":[{\"account\":\"eosio.forum\",\"action\":\"vote\"},{\"account\":\"eosio.forum\",\"action\":\"unvote\"}]}],\"total_resources\":{\"owner\":\"teamgreymass\",\"net_weight\":\"449.7214 EOS\",\"cpu_weight\":\"1067415.7299 EOS\",\"ram_bytes\":66588},\"self_delegated_bandwidth\":null,\"refund_request\":null,\"voter_info\":{\"owner\":\"teamgreymass\",\"proxy\":\"greymassvote\",\"producers\":[],\"staked\":100202,\"last_vote_weight\":\"863265464502.93908691406250000\",\"proxied_vote_weight\":\"0.00000000000000000\",\"is_proxy\":0,\"flags1\":0,\"reserved2\":0,\"reserved3\":\"0.0000 EOS\"},\"rex_info\":null,\"subjective_cpu_bill_limit\":{\"used\":0,\"available\":0,\"max\":0,\"last_usage_update_time\":\"2000-01-01T00:00:00.000\",\"current_used\":0},\"eosio_any_linked_actions\":[]}"
}
Loading