Data Fixes

This commit is contained in:
Aaron Cox
2024-08-07 16:57:52 -07:00
parent 02bef81227
commit c44fa72d8b
7 changed files with 77 additions and 3 deletions
+5
View File
@@ -1,4 +1,5 @@
SHELL := /bin/bash
PATH := ./node_modules/.bin:$(PATH)
SRC_FILES := $(shell find src -name '*.ts')
TEST_FILES := $(wildcard test/tests/*.ts)
BIN := ./node_modules/.bin
@@ -8,6 +9,10 @@ NYC_OPTS := --temp-dir build/nyc_output --report-dir build/coverage
lib: ${SRC_FILES} package.json tsconfig.json node_modules rollup.config.mjs
@${BIN}/rollup -c && touch lib
.PHONY: dev
dev: node_modules
@onchange -k -i 'src/**/*.ts' 'config/*' -- ${BIN}/rollup -c && touch lib
.PHONY: test
test: node_modules
@TS_NODE_PROJECT='./test/tsconfig.json' MOCK_DIR='./test/data' \
+1
View File
@@ -48,6 +48,7 @@
"mocha": "^10.0.0",
"node-fetch": "^2.6.1",
"nyc": "^15.1.0",
"onchange": "^7.1",
"prettier": "^2.2.1",
"rollup": "^3.2.3",
"rollup-plugin-dts": "^5.0.0",
+4
View File
@@ -84,6 +84,10 @@ export class Account<Data extends API.v1.AccountObject = API.v1.AccountObject> {
return Permission.from(permission)
}
get permissions() {
return this.data.permissions.map((permission) => Permission.from(permission))
}
resource(resourceType: ResourceType): Resource {
return new Resource(resourceType, this.data)
}
+1
View File
@@ -1,4 +1,5 @@
export * from './account'
export * from './permission'
export * from './resource'
export * from './kit'
export * as SystemContract from './contracts/eosio'
+2 -1
View File
@@ -11,6 +11,7 @@ import {
PermissionLevelWeight,
PublicKey,
PublicKeyType,
Serializer,
Struct,
UInt16Type,
UInt32Type,
@@ -52,7 +53,7 @@ export type LinkedActionType = LinkedAction | {account: NameType; action: NameTy
@Struct.type('linked_actions')
export class LinkedAction extends Struct {
@Struct.field('name') declare account: Name
@Struct.field('name') declare action: Name
@Struct.field('name', {optional: true}) declare action?: Name
}
export type WaitWeightType = WaitWeight | {wait_sec: UInt32Type; weight: UInt16Type}
+14
View File
@@ -16,6 +16,7 @@ export class Resource {
readonly used: Int64
readonly max: Int64
readonly current_used?: Int64
readonly weight?: Int64
constructor(resource: ResourceType, data: API.v1.AccountObject) {
@@ -24,6 +25,7 @@ export class Resource {
switch (resource) {
case 'cpu': {
this.available = this.data.cpu_limit.available
this.current_used = this.data.cpu_limit.current_used
this.used = this.data.cpu_limit.used
this.max = this.data.cpu_limit.max
this.weight = this.data.cpu_weight
@@ -31,6 +33,7 @@ export class Resource {
}
case 'net': {
this.available = this.data.net_limit.available
this.current_used = this.data.net_limit.current_used
this.used = this.data.net_limit.used
this.max = this.data.net_limit.max
this.weight = this.data.net_weight
@@ -47,4 +50,15 @@ export class Resource {
}
}
}
toJSON() {
return {
resource: this.resource,
available: this.available,
current_used: this.current_used ? this.current_used : this.current_used,
used: this.used,
max: this.max,
weight: this.weight ? this.weight : undefined,
}
}
}
+50 -2
View File
@@ -194,6 +194,16 @@
"@babel/helper-validator-identifier" "^7.22.5"
to-fast-properties "^2.0.0"
"@blakeembrey/deque@^1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@blakeembrey/deque/-/deque-1.0.5.tgz#f4fa17fc5ee18317ec01a763d355782c7b395eaf"
integrity sha512-6xnwtvp9DY1EINIKdTfvfeAtCYw4OqBZJhtiqkT3ivjnEfa25VQ3TsKvaFfKm8MyGIEfE95qLe+bNEt3nB0Ylg==
"@blakeembrey/template@^1.0.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@blakeembrey/template/-/template-1.1.0.tgz#fbea7a688ffedf0763085b2cda8efe6fdd54d4c4"
integrity sha512-iZf+UWfL+DogJVpd/xMQyP6X6McYd6ArdYoPMiv/zlOTzeXXfQbYxBNJJBF6tThvsjLMbA8tLjkCdm9RWMFCCw==
"@cspotcode/source-map-support@^0.8.0":
version "0.8.1"
resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1"
@@ -755,7 +765,7 @@ archy@^1.0.0:
resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40"
integrity sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw==
arg@^4.1.0:
arg@^4.1.0, arg@^4.1.3:
version "4.1.3"
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089"
integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==
@@ -948,6 +958,21 @@ chokidar@3.5.3:
optionalDependencies:
fsevents "~2.3.2"
chokidar@^3.3.1:
version "3.6.0"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.6.0.tgz#197c6cc669ef2a8dc5e7b4d97ee4e092c3eb0d5b"
integrity sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==
dependencies:
anymatch "~3.1.2"
braces "~3.0.2"
glob-parent "~5.1.2"
is-binary-path "~2.1.0"
is-glob "~4.0.1"
normalize-path "~3.0.0"
readdirp "~3.6.0"
optionalDependencies:
fsevents "~2.3.2"
clean-stack@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b"
@@ -1020,7 +1045,7 @@ create-require@^1.1.0:
resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333"
integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==
cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
@@ -1592,6 +1617,11 @@ html-escaper@^2.0.0:
resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453"
integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==
ignore@^5.1.4:
version "5.3.1"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.1.tgz#5073e554cd42c5b33b394375f538b8593e34d4ef"
integrity sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==
ignore@^5.2.0:
version "5.2.4"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324"
@@ -2147,6 +2177,19 @@ once@^1.3.0:
dependencies:
wrappy "1"
onchange@^7.1:
version "7.1.0"
resolved "https://registry.yarnpkg.com/onchange/-/onchange-7.1.0.tgz#a6f0f7733e4d47014b4cd70aa1ad36c2b4cf3804"
integrity sha512-ZJcqsPiWUAUpvmnJri5TPBooqJOPmC0ttN65juhN15Q8xA+Nbg3BaxBHXQ45EistKKlKElb0edmbPWnKSBkvMg==
dependencies:
"@blakeembrey/deque" "^1.0.5"
"@blakeembrey/template" "^1.0.0"
arg "^4.1.3"
chokidar "^3.3.1"
cross-spawn "^7.0.1"
ignore "^5.1.4"
tree-kill "^1.2.2"
optionator@^0.9.3:
version "0.9.3"
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.3.tgz#007397d44ed1872fdc6ed31360190f81814e2c64"
@@ -2622,6 +2665,11 @@ tr46@~0.0.3:
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==
tree-kill@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc"
integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==
trim-repeated@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/trim-repeated/-/trim-repeated-1.0.0.tgz#e3646a2ea4e891312bf7eace6cfb05380bc01c21"