Skip to content

Commit cec63c6

Browse files
committed
Major change to chifra export --accounting options - Reconciliations work!
1 parent 21ebbac commit cec63c6

File tree

108 files changed

+4847
-2265
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+4847
-2265
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.2.0
1+
4.3.0

docs/content/api/openapi.yaml

Lines changed: 57 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ info:
77
license:
88
name: GPL 3.0
99
url: http://www.gnu.org/licenses/
10-
version: 4.2.0-release
10+
version: 4.3.0-release
1111
description: >
1212
A REST layer over the TrueBlocks chifra command line. With `chifra daemon`, you can
1313
run this on your own machine, and make calls to `localhost`.
@@ -316,16 +316,24 @@ paths:
316316
explode: true
317317
schema:
318318
type: boolean
319-
- name: accounting
320-
description: attach accounting records to the exported data (applies to transactions export only)
319+
- name: statements
320+
description: export only statements
321321
required: false
322322
style: form
323323
in: query
324324
explode: true
325325
schema:
326326
type: boolean
327-
- name: statements
328-
description: for the accounting options only, export only statements
327+
- name: transfers
328+
description: export only eth or token transfers
329+
required: false
330+
style: form
331+
in: query
332+
explode: true
333+
schema:
334+
type: boolean
335+
- name: assets
336+
description: list all assets (with names) that appear in any transfer
329337
required: false
330338
style: form
331339
in: query
@@ -420,6 +428,14 @@ paths:
420428
items:
421429
type: string
422430
format: topic
431+
- name: nfts
432+
description: for the --logs option only, filter logs to show only nft transfers
433+
required: false
434+
style: form
435+
in: query
436+
explode: true
437+
schema:
438+
type: boolean
423439
- name: reverted
424440
description: export only transactions that were reverted
425441
required: false
@@ -429,7 +445,7 @@ paths:
429445
schema:
430446
type: boolean
431447
- name: asset
432-
description: for the accounting options only, export statements only for this asset
448+
description: export transfers, balances, or statements only for this asset
433449
required: false
434450
style: form
435451
in: query
@@ -440,7 +456,7 @@ paths:
440456
type: string
441457
format: address
442458
- name: flow
443-
description: for the accounting options only, export statements with incoming, outgoing, or zero value
459+
description: export transfers, balances, or statements with incoming, outgoing, or zero value
444460
required: false
445461
style: form
446462
in: query
@@ -501,6 +517,14 @@ paths:
501517
schema:
502518
type: number
503519
format: blknum
520+
- name: accounting
521+
description: deprecated option, you may simply remove it
522+
required: false
523+
style: form
524+
in: query
525+
explode: true
526+
schema:
527+
type: boolean
504528
- name: chain
505529
description: the chain to use
506530
required: false
@@ -3242,11 +3266,11 @@ components:
32423266
type: string
32433267
format: datetime
32443268
description: "the timestamp as a date (calculated)"
3245-
assetAddr:
3269+
asset:
32463270
type: string
32473271
format: address
32483272
description: "0xeeee...eeee for ETH reconciliations, the token address otherwise"
3249-
assetSymbol:
3273+
symbol:
32503274
type: string
32513275
format: string
32523276
description: "either ETH, WEI, or the symbol of the asset being reconciled as extracted from the chain"
@@ -3277,19 +3301,15 @@ components:
32773301
begBal:
32783302
type: string
32793303
format: int256
3280-
description: "the beginning balance of the asset prior to the transaction"
3304+
description: "the on-chain or running beginning balance prior to the transaction (see notes about intra-block reconciliations)"
32813305
amountNet:
32823306
type: string
32833307
format: int256
32843308
description: "totalIn - totalOut (calculated)"
32853309
endBal:
32863310
type: string
32873311
format: int256
3288-
description: "the on-chain balance of the asset (see notes about intra-block reconciliations)"
3289-
reconciliationType:
3290-
type: string
3291-
format: string
3292-
description: "one of `regular`, `prevDiff-same`, `same-nextDiff`, or `same-same`. Appended with `eth` or `token` (calculated)"
3312+
description: "the on-chain or running balance after the transaction (see notes about intra-block reconciliations)"
32933313
reconciled:
32943314
type: boolean
32953315
format: boolean
@@ -3326,10 +3346,18 @@ components:
33263346
type: string
33273347
format: int256
33283348
description: "the uncle reward if the miner who won the uncle block is the accountedFor address"
3329-
correctingIn:
3349+
correctBegBalIn:
3350+
type: string
3351+
format: int256
3352+
description: "for unreconciled transfers, increase in beginning balance need to match previous balance"
3353+
correctAmountIn:
3354+
type: string
3355+
format: int256
3356+
description: "for unreconciled transfers, increase in the amount of a transfer"
3357+
correctEndBalIn:
33303358
type: string
33313359
format: int256
3332-
description: "for unreconciled token transfers only, the incoming amount needed to correct the transfer so it balances"
3360+
description: "for unreconciled transfers, increase in ending balance need to match running balance or block balance"
33333361
prefundIn:
33343362
type: string
33353363
format: int256
@@ -3346,10 +3374,18 @@ components:
33463374
type: string
33473375
format: int256
33483376
description: "the value of any internal value transfers out of the accountedFor account"
3349-
correctingOut:
3377+
correctBegBalOut:
3378+
type: string
3379+
format: int256
3380+
description: "for unreconciled transfers, decrease in beginning balance need to match previous balance"
3381+
correctAmountOut:
33503382
type: string
33513383
format: int256
3352-
description: "for unreconciled token transfers only, the outgoing amount needed to correct the transfer so it balances"
3384+
description: "for unreconciled transfers, decrease in the amount of a transfer"
3385+
correctEndBalOut:
3386+
type: string
3387+
format: int256
3388+
description: "for unreconciled transfers, decrease in ending balance need to match running balance or block balance"
33533389
selfDestructOut:
33543390
type: string
33553391
format: int256
@@ -3358,10 +3394,6 @@ components:
33583394
type: string
33593395
format: int256
33603396
description: "if the transaction's original sender is the accountedFor address, the amount of gas expended"
3361-
totalOutLessGas:
3362-
type: string
3363-
format: int256
3364-
description: "totalOut - gasOut (calculated)"
33653397
prevBal:
33663398
type: string
33673399
format: int256
@@ -3378,10 +3410,10 @@ components:
33783410
type: string
33793411
format: int256
33803412
description: "begBal + amountNet (calculated)"
3381-
correctingReason:
3413+
correctingReasons:
33823414
type: string
33833415
format: string
3384-
description: "the reason for the correcting entries, if any"
3416+
description: "for unreconciled transfers, the reasons for the correcting entries, if any"
33853417
transfer:
33863418
description: "a movement of an asset from one address to another (derived from a transaction or a log)"
33873419
type: object

docs/content/chifra/accounts.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ Flags:
114114
-l, --logs export logs instead of transactional data
115115
-t, --traces export traces instead of transactional data
116116
-n, --neighbors export the neighbors of the given address
117-
-C, --accounting attach accounting records to the exported data (applies to transactions export only)
118-
-A, --statements for the accounting options only, export only statements
117+
-A, --statements export only statements
118+
-X, --transfers export only eth or token transfers
119+
-s, --assets list all assets (with names) that appear in any transfer
119120
-b, --balances traverse the transaction history and show each change in ETH balances
120121
-i, --withdrawals export withdrawals for the given address
121122
-a, --articulate articulate transactions, traces, logs, and outputs
@@ -126,16 +127,18 @@ Flags:
126127
-N, --relevant for log and accounting export only, export only logs relevant to one of the given export addresses
127128
-m, --emitter strings for the --logs option only, filter logs to show only those logs emitted by the given address(es)
128129
-B, --topic strings for the --logs option only, filter logs to show only those with this topic(s)
130+
-T, --nfts for the --logs option only, filter logs to show only nft transfers
129131
-V, --reverted export only transactions that were reverted
130-
-P, --asset strings for the accounting options only, export statements only for this asset
131-
-f, --flow string for the accounting options only, export statements with incoming, outgoing, or zero value
132+
-P, --asset strings export transfers, balances, or statements only for this asset
133+
-f, --flow string export transfers, balances, or statements with incoming, outgoing, or zero value
132134
One of [ in | out | zero ]
133135
-y, --factory for --traces only, report addresses created by (or self-destructed by) the given address(es)
134136
-u, --unripe export transactions labeled unripe (i.e. less than 28 blocks old)
135137
-E, --reversed produce results in reverse chronological order
136138
-z, --no_zero for the --count option only, suppress the display of zero appearance accounts
137139
-F, --first_block uint first block to process (inclusive)
138140
-L, --last_block uint last block to process (inclusive)
141+
-C, --accounting deprecated option, you may simply remove it
139142
-H, --ether specify value in ether
140143
-o, --cache force the results of the query into the cache
141144
-D, --decache removes related items from the cache

docs/content/data-model/accounts.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,17 @@ Statements consist of the following fields:
181181
| transactionHash | the hash of the transaction that triggered this reconciliation | hash |
182182
| timestamp | the Unix timestamp of the object | timestamp |
183183
| date | the timestamp as a date (calculated) | datetime |
184-
| assetAddr | 0xeeee...eeee for ETH reconciliations, the token address otherwise | address |
185-
| assetSymbol | either ETH, WEI, or the symbol of the asset being reconciled as extracted from the chain | string |
184+
| asset | 0xeeee...eeee for ETH reconciliations, the token address otherwise | address |
185+
| symbol | either ETH, WEI, or the symbol of the asset being reconciled as extracted from the chain | string |
186186
| decimals | the value of `decimals` from an ERC20 contract or, if ETH or WEI, then 18 | value |
187187
| spotPrice | the on-chain price in USD (or if a token in ETH, or zero) at the time of the transaction | float |
188188
| priceSource | the on-chain source from which the spot price was taken | string |
189189
| accountedFor | the address being accounted for in this reconciliation | address |
190190
| sender | the initiator of the transfer (the sender) | address |
191191
| recipient | the receiver of the transfer (the recipient) | address |
192-
| begBal | the beginning balance of the asset prior to the transaction | int256 |
192+
| begBal | the on-chain or running beginning balance prior to the transaction (see notes about intra-block reconciliations) | int256 |
193193
| amountNet | totalIn - totalOut (calculated) | int256 |
194-
| endBal | the on-chain balance of the asset (see notes about intra-block reconciliations) | int256 |
195-
| reconciliationType | one of `regular`, `prevDiff-same`, `same-nextDiff`, or `same-same`. Appended with `eth` or `token` (calculated) | string |
194+
| endBal | the on-chain or running balance after the transaction (see notes about intra-block reconciliations) | int256 |
196195
| reconciled | true if `endBal === endBalCalc` and `begBal === prevBal`. `false` otherwise. (calculated) | bool |
197196
| totalIn | the sum of the following `In` fields (calculated) | int256 |
198197
| amountIn | the top-level value of the incoming transfer for the accountedFor address | int256 |
@@ -202,20 +201,23 @@ Statements consist of the following fields:
202201
| minerNephewRewardIn | the nephew reward if the miner is the accountedFor address | int256 |
203202
| minerTxFeeIn | the transaction fee reward if the miner is the accountedFor address | int256 |
204203
| minerUncleRewardIn | the uncle reward if the miner who won the uncle block is the accountedFor address | int256 |
205-
| correctingIn | for unreconciled token transfers only, the incoming amount needed to correct the transfer so it balances | int256 |
204+
| correctBegBalIn | for unreconciled transfers, increase in beginning balance need to match previous balance | int256 |
205+
| correctAmountIn | for unreconciled transfers, increase in the amount of a transfer | int256 |
206+
| correctEndBalIn | for unreconciled transfers, increase in ending balance need to match running balance or block balance | int256 |
206207
| prefundIn | at block zero (0) only, the amount of genesis income for the accountedFor address | int256 |
207208
| totalOut | the sum of the following `Out` fields (calculated) | int256 |
208209
| amountOut | the amount (in units of the asset) of regular outflow during this transaction | int256 |
209210
| internalOut | the value of any internal value transfers out of the accountedFor account | int256 |
210-
| correctingOut | for unreconciled token transfers only, the outgoing amount needed to correct the transfer so it balances | int256 |
211+
| correctBegBalOut | for unreconciled transfers, decrease in beginning balance need to match previous balance | int256 |
212+
| correctAmountOut | for unreconciled transfers, decrease in the amount of a transfer | int256 |
213+
| correctEndBalOut | for unreconciled transfers, decrease in ending balance need to match running balance or block balance | int256 |
211214
| selfDestructOut | the value of the self-destructed value out if the accountedFor address was self-destructed | int256 |
212215
| gasOut | if the transaction's original sender is the accountedFor address, the amount of gas expended | int256 |
213-
| totalOutLessGas | totalOut - gasOut (calculated) | int256 |
214216
| prevBal | the account balance for the given asset for the previous reconciliation | int256 |
215217
| begBalDiff | difference between expected beginning balance and balance at last reconciliation, if non-zero, the reconciliation failed (calculated) | int256 |
216218
| endBalDiff | endBal - endBalCalc, if non-zero, the reconciliation failed (calculated) | int256 |
217219
| endBalCalc | begBal + amountNet (calculated) | int256 |
218-
| correctingReason | the reason for the correcting entries, if any | string |
220+
| correctingReasons | for unreconciled transfers, the reasons for the correcting entries, if any | string |
219221

220222
## Transfer
221223

0 commit comments

Comments
 (0)