@sentio/sdk 2.41.4-rc.1 → 2.41.4-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/btc/btc-plugin.d.ts.map +1 -1
- package/lib/btc/btc-plugin.js +42 -8
- package/lib/btc/btc-plugin.js.map +1 -1
- package/lib/btc/btc-processor.d.ts +4 -3
- package/lib/btc/btc-processor.d.ts.map +1 -1
- package/lib/btc/btc-processor.js +4 -3
- package/lib/btc/btc-processor.js.map +1 -1
- package/lib/btc/types.d.ts +15 -0
- package/lib/btc/types.d.ts.map +1 -1
- package/lib/btc/types.js.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +131 -145
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.js +44 -52
- package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.js +104 -112
- package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.js +53 -55
- package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.js +80 -88
- package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.js +67 -65
- package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
- package/lib/eth/codegen/function-calls.d.ts.map +1 -1
- package/lib/eth/codegen/function-calls.js +3 -5
- package/lib/eth/codegen/function-calls.js.map +1 -1
- package/lib/store/store.d.ts.map +1 -1
- package/lib/store/store.js +6 -46
- package/lib/store/store.js.map +1 -1
- package/lib/store/util.d.ts +3 -0
- package/lib/store/util.d.ts.map +1 -0
- package/lib/store/util.js +46 -0
- package/lib/store/util.js.map +1 -0
- package/package.json +4 -3
- package/src/btc/btc-plugin.ts +49 -8
- package/src/btc/btc-processor.ts +10 -5
- package/src/btc/types.ts +31 -0
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +131 -168
- package/src/eth/builtin/internal/erc1155-processor.ts +44 -60
- package/src/eth/builtin/internal/erc20-processor.ts +104 -130
- package/src/eth/builtin/internal/erc20bytes-processor.ts +53 -64
- package/src/eth/builtin/internal/erc721-processor.ts +80 -102
- package/src/eth/builtin/internal/weth9-processor.ts +67 -76
- package/src/eth/codegen/function-calls.ts +3 -5
- package/src/store/store.ts +7 -53
- package/src/store/util.ts +53 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentio/sdk",
|
3
|
-
"version": "2.41.4-rc.
|
3
|
+
"version": "2.41.4-rc.3",
|
4
4
|
"license": "Apache-2.0",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -84,8 +84,8 @@
|
|
84
84
|
"typechain": "^8.3.2",
|
85
85
|
"utility-types": "^3.11.0",
|
86
86
|
"yaml": "^2.3.4",
|
87
|
-
"@sentio/
|
88
|
-
"@sentio/
|
87
|
+
"@sentio/runtime": "^2.41.4-rc.3",
|
88
|
+
"@sentio/protos": "2.41.4-rc.3"
|
89
89
|
},
|
90
90
|
"peerDependencies": {
|
91
91
|
"tsup": "npm:@sentio/tsup@^6.7.2"
|
@@ -123,6 +123,7 @@
|
|
123
123
|
"gen:sui": "cp ../../node_modules/@typemove/sui/src/abis/*.json src/sui/abis && tsx src/sui/codegen/run.ts src/sui/abis src/sui/builtin && pnpm gen:sui_test",
|
124
124
|
"gen:sui_test": "tsx src/sui/codegen/run.ts src/sui/tests/abis src/sui/tests/types",
|
125
125
|
"test": "glob -c 'tsx --test' '**/*.test.ts'",
|
126
|
+
"test:btc": "tsx --test src/btc/tests/processor.test.ts",
|
126
127
|
"test:starknet": "tsx --test src/stark/tests/event.test.ts"
|
127
128
|
}
|
128
129
|
}
|
package/src/btc/btc-plugin.ts
CHANGED
@@ -1,17 +1,22 @@
|
|
1
1
|
import { errorString, GLOBAL_CONFIG, mergeProcessResults, Plugin, PluginManager, USER_PROCESSOR } from '@sentio/runtime'
|
2
2
|
import {
|
3
|
+
BTCTransactionFilter_FieldFilters,
|
3
4
|
ContractConfig,
|
4
5
|
Data_BTCTransaction,
|
5
6
|
DataBinding,
|
6
7
|
HandlerType,
|
7
8
|
ProcessConfigResponse,
|
8
9
|
ProcessResult,
|
10
|
+
RichValue,
|
9
11
|
StartRequest
|
10
12
|
} from '@sentio/protos'
|
11
13
|
|
12
14
|
import { ServerError, Status } from 'nice-grpc'
|
13
15
|
import { TemplateInstanceState } from '../core/template.js'
|
14
16
|
import { BTCProcessorState } from './btc-processor.js'
|
17
|
+
import { TransactionFilter, TransactionFilters } from './types.js'
|
18
|
+
import { serializeRichValue } from '../store/util.js'
|
19
|
+
import { isArray } from 'radash'
|
15
20
|
|
16
21
|
interface Handlers {
|
17
22
|
txHandlers: ((trace: Data_BTCTransaction) => Promise<ProcessResult>)[]
|
@@ -43,14 +48,25 @@ export class BTCPlugin extends Plugin {
|
|
43
48
|
for (const callHandler of processor.callHandlers) {
|
44
49
|
const handlerId = handlers.txHandlers.push(callHandler.handler) - 1
|
45
50
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
if (callHandler.filter) {
|
52
|
+
contractConfig.btcTransactionConfigs.push({
|
53
|
+
filters: [
|
54
|
+
{
|
55
|
+
fieldFilters: toFilters(callHandler.filter)
|
56
|
+
}
|
57
|
+
],
|
58
|
+
handlerId
|
59
|
+
})
|
60
|
+
} else {
|
61
|
+
contractConfig.btcTransactionConfigs.push({
|
62
|
+
filters: [
|
63
|
+
{
|
64
|
+
address: contractConfig.contract?.address || '*'
|
65
|
+
}
|
66
|
+
],
|
67
|
+
handlerId
|
68
|
+
})
|
69
|
+
}
|
54
70
|
}
|
55
71
|
|
56
72
|
// Finish up a contract
|
@@ -103,3 +119,28 @@ export class BTCPlugin extends Plugin {
|
|
103
119
|
}
|
104
120
|
|
105
121
|
PluginManager.INSTANCE.register(new BTCPlugin())
|
122
|
+
|
123
|
+
function toFilters(filters: TransactionFilters): BTCTransactionFilter_FieldFilters {
|
124
|
+
const arr = !isArray(filters) ? [filters] : filters
|
125
|
+
return {
|
126
|
+
filters: arr.map((f: TransactionFilter) => {
|
127
|
+
const { field, ...rest } = f
|
128
|
+
return {
|
129
|
+
field: field,
|
130
|
+
...toValues(rest)
|
131
|
+
}
|
132
|
+
})
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
function toValues(rest: Omit<TransactionFilter, 'field'>): Record<keyof Omit<TransactionFilter, 'field'>, RichValue> {
|
137
|
+
return Object.entries(rest).reduce(
|
138
|
+
(acc, [key, value]) => {
|
139
|
+
if (value !== undefined) {
|
140
|
+
acc[key] = serializeRichValue(value)
|
141
|
+
}
|
142
|
+
return acc
|
143
|
+
},
|
144
|
+
{} as Record<string, RichValue>
|
145
|
+
)
|
146
|
+
}
|
package/src/btc/btc-processor.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ListStateStorage } from '@sentio/runtime'
|
2
|
-
import { BTCContext, Transaction } from './types.js'
|
2
|
+
import { BTCContext, Transaction, TransactionFilters } from './types.js'
|
3
3
|
import { Data_BTCTransaction, ProcessResult } from '@sentio/protos'
|
4
4
|
|
5
5
|
export class BTCProcessorState extends ListStateStorage<BTCProcessor> {
|
@@ -17,7 +17,10 @@ export class BTCProcessor {
|
|
17
17
|
return processor
|
18
18
|
}
|
19
19
|
|
20
|
-
public onTransaction(
|
20
|
+
public onTransaction(
|
21
|
+
handler: (transaction: Transaction, ctx: BTCContext) => void | Promise<void>,
|
22
|
+
filter?: TransactionFilters
|
23
|
+
) {
|
21
24
|
const callHandler = {
|
22
25
|
handler: async (call: Data_BTCTransaction) => {
|
23
26
|
const tx = call.transaction as Transaction
|
@@ -26,11 +29,12 @@ export class BTCProcessor {
|
|
26
29
|
this.config.chainId,
|
27
30
|
this.config.name ?? this.config.address ?? '',
|
28
31
|
tx,
|
29
|
-
this.config.address
|
32
|
+
this.config.address ?? tx.vout[0].scriptpubkey_address
|
30
33
|
)
|
31
34
|
await handler(tx, ctx)
|
32
35
|
return ctx.stopAndGetResult()
|
33
|
-
}
|
36
|
+
},
|
37
|
+
filter
|
34
38
|
}
|
35
39
|
this.callHandlers.push(callHandler)
|
36
40
|
return this
|
@@ -40,11 +44,12 @@ export class BTCProcessor {
|
|
40
44
|
interface BTCProcessorConfig {
|
41
45
|
chainId: string
|
42
46
|
name?: string
|
43
|
-
address
|
47
|
+
address?: string
|
44
48
|
startBlock?: bigint
|
45
49
|
endBlock?: bigint
|
46
50
|
}
|
47
51
|
|
48
52
|
export type CallHandler<T> = {
|
49
53
|
handler: (call: T) => Promise<ProcessResult>
|
54
|
+
filter?: TransactionFilters
|
50
55
|
}
|
package/src/btc/types.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { BaseContext, Labels, normalizeLabels } from '../core/index.js'
|
2
2
|
import { RecordMetaData } from '@sentio/protos'
|
3
3
|
import { ChainId } from '@sentio/chain'
|
4
|
+
import { BigDecimal } from '@sentio/bigdecimal'
|
4
5
|
|
5
6
|
type Vin = {
|
6
7
|
txid: string
|
@@ -91,3 +92,33 @@ export class BTCContext extends BaseContext {
|
|
91
92
|
return this.chainId as ChainId
|
92
93
|
}
|
93
94
|
}
|
95
|
+
|
96
|
+
export type TransactionFilter = {
|
97
|
+
field:
|
98
|
+
| 'vin.txid'
|
99
|
+
| 'vin.vout'
|
100
|
+
| 'vin.is_coinbase'
|
101
|
+
| 'vin.scriptsig'
|
102
|
+
| 'vin.scriptsig_asm'
|
103
|
+
| 'vout.scriptpubkey'
|
104
|
+
| 'vout.scriptpubkey_asm'
|
105
|
+
| 'vout.scriptpubkey_type'
|
106
|
+
| 'vout.scriptpubkey_address'
|
107
|
+
| 'vout.value'
|
108
|
+
| 'status.block_height'
|
109
|
+
| 'status.block_hash'
|
110
|
+
| 'status.block_time'
|
111
|
+
prefix?: string
|
112
|
+
equals?: Comparable
|
113
|
+
gt?: Comparable
|
114
|
+
gte?: Comparable
|
115
|
+
lt?: Comparable
|
116
|
+
lte?: Comparable
|
117
|
+
ne?: Comparable
|
118
|
+
contains?: string
|
119
|
+
not_contains?: string
|
120
|
+
}
|
121
|
+
|
122
|
+
type Comparable = number | BigDecimal | bigint | Date
|
123
|
+
|
124
|
+
export type TransactionFilters = TransactionFilter | TransactionFilter[]
|