@sentio/sdk 2.31.0-rc.1 → 2.31.0-rc.10
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/aptos/builtin/0x1.js +1 -1
- package/lib/aptos/builtin/0x1.js.map +1 -1
- package/lib/aptos/builtin/0x3.js +1 -1
- package/lib/aptos/builtin/0x3.js.map +1 -1
- package/lib/aptos/builtin/0x4.js +1 -1
- package/lib/aptos/builtin/0x4.js.map +1 -1
- package/lib/core/event-logger.d.ts +9 -2
- package/lib/core/event-logger.d.ts.map +1 -1
- package/lib/core/event-logger.js +36 -16
- package/lib/core/event-logger.js.map +1 -1
- package/lib/core/event-logger.test.d.ts +2 -0
- package/lib/core/event-logger.test.d.ts.map +1 -0
- package/lib/core/event-logger.test.js.map +1 -0
- package/lib/eth/eth.d.ts.map +1 -1
- package/lib/eth/eth.js +6 -5
- package/lib/eth/eth.js.map +1 -1
- package/lib/sui/builtin/0x1.js +1 -1
- package/lib/sui/builtin/0x1.js.map +1 -1
- package/lib/sui/builtin/0x2.js +1 -1
- package/lib/sui/builtin/0x2.js.map +1 -1
- package/lib/sui/builtin/0x3.js +1 -1
- package/lib/sui/builtin/0x3.js.map +1 -1
- package/lib/sui/sui-processor.d.ts.map +1 -1
- package/lib/sui/sui-processor.js +4 -0
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/price.d.ts +25 -0
- package/lib/utils/price.d.ts.map +1 -1
- package/lib/utils/price.js +16 -0
- package/lib/utils/price.js.map +1 -1
- package/package.json +6 -6
- package/src/aptos/builtin/0x1.ts +1 -1
- package/src/aptos/builtin/0x3.ts +1 -1
- package/src/aptos/builtin/0x4.ts +1 -1
- package/src/core/event-logger.ts +53 -17
- package/src/eth/eth.ts +6 -5
- package/src/sui/builtin/0x1.ts +1 -1
- package/src/sui/builtin/0x2.ts +1 -1
- package/src/sui/builtin/0x3.ts +1 -1
- package/src/sui/sui-processor.ts +4 -0
- package/src/utils/index.ts +1 -1
- package/src/utils/price.ts +18 -0
package/src/core/event-logger.ts
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
import { BaseContext } from './base-context.js'
|
2
|
-
import {
|
2
|
+
import {
|
3
|
+
CoinID,
|
4
|
+
EventLogConfig,
|
5
|
+
EventLogConfig_BasicFieldType,
|
6
|
+
EventLogConfig_Field,
|
7
|
+
EventLogConfig_StructFieldType,
|
8
|
+
EventTrackingResult,
|
9
|
+
LogLevel
|
10
|
+
} from '@sentio/protos'
|
3
11
|
import { normalizeAttribute } from './normalization.js'
|
4
12
|
import { MapStateStorage } from '@sentio/runtime'
|
5
13
|
|
@@ -32,33 +40,61 @@ export class EventLoggerBinding {
|
|
32
40
|
}
|
33
41
|
}
|
34
42
|
|
43
|
+
export type BasicFieldType = EventLogConfig_BasicFieldType
|
44
|
+
export const BasicFieldType = EventLogConfig_BasicFieldType
|
45
|
+
|
46
|
+
export type FieldType = CoinID | BasicFieldType | Fields
|
47
|
+
|
48
|
+
export type Fields = { [key: string]: FieldType }
|
49
|
+
|
35
50
|
export interface EventLogOptions {
|
36
|
-
fields:
|
51
|
+
fields: Fields
|
52
|
+
}
|
53
|
+
|
54
|
+
export function fieldsToProtos(fields: Fields): EventLogConfig_Field[] {
|
55
|
+
const fieldsProto: EventLogConfig_Field[] = []
|
56
|
+
for (const [key, value] of Object.entries(fields)) {
|
57
|
+
let basicType: BasicFieldType | undefined
|
58
|
+
let coinType: CoinID | undefined
|
59
|
+
let structType: EventLogConfig_StructFieldType | undefined
|
60
|
+
|
61
|
+
if (typeof value === 'number') {
|
62
|
+
basicType = value
|
63
|
+
} else {
|
64
|
+
if (value.address || value.symbol) {
|
65
|
+
coinType = value
|
66
|
+
} else {
|
67
|
+
structType = EventLogConfig_StructFieldType.create({
|
68
|
+
fields: fieldsToProtos(value as Fields)
|
69
|
+
})
|
70
|
+
}
|
71
|
+
}
|
72
|
+
fieldsProto.push({
|
73
|
+
name: key,
|
74
|
+
basicType,
|
75
|
+
coinType,
|
76
|
+
structType
|
77
|
+
})
|
78
|
+
}
|
79
|
+
return fieldsProto
|
37
80
|
}
|
38
81
|
|
39
82
|
export class EventLogger {
|
40
83
|
private readonly eventName: string
|
41
84
|
config: EventLogConfig
|
42
85
|
|
43
|
-
private constructor(eventName: string, config
|
86
|
+
private constructor(eventName: string, config: EventLogConfig) {
|
44
87
|
this.eventName = eventName
|
45
|
-
this.config =
|
88
|
+
this.config = config
|
46
89
|
}
|
47
90
|
|
48
91
|
static register(eventName: string, options?: EventLogOptions): EventLogger {
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
} else {
|
56
|
-
coinType = value
|
57
|
-
}
|
58
|
-
config.fields.push({
|
59
|
-
name: key,
|
60
|
-
basicType,
|
61
|
-
coinType
|
92
|
+
let config = EventLogConfig.create()
|
93
|
+
|
94
|
+
if (options?.fields) {
|
95
|
+
config = EventLogConfig.create({
|
96
|
+
name: eventName,
|
97
|
+
fields: fieldsToProtos(options.fields)
|
62
98
|
})
|
63
99
|
}
|
64
100
|
|
package/src/eth/eth.ts
CHANGED
@@ -9,7 +9,7 @@ import {
|
|
9
9
|
formatHash,
|
10
10
|
formatReceiptLog,
|
11
11
|
object,
|
12
|
-
formatData
|
12
|
+
formatData
|
13
13
|
} from 'ethers/providers'
|
14
14
|
import { CallExceptionError, LogDescription, Result, DeferredTopicFilter, BlockParams } from 'ethers'
|
15
15
|
import { ContractContext } from './context.js'
|
@@ -109,13 +109,14 @@ const _formatTransactionReceipt = object(
|
|
109
109
|
//confirmations: allowNull(getNumber, null),
|
110
110
|
cumulativeGasUsed: getBigInt,
|
111
111
|
effectiveGasPrice: allowNull(getBigInt),
|
112
|
+
gasPrice: allowNull(getBigInt),
|
112
113
|
status: allowNull(getNumber),
|
113
|
-
type: allowNull(getNumber, 0)
|
114
|
+
type: allowNull(getNumber, 0)
|
114
115
|
},
|
115
116
|
{
|
116
|
-
effectiveGasPrice: ['gasPrice'],
|
117
|
+
// effectiveGasPrice: ['gasPrice'],
|
117
118
|
hash: ['transactionHash'],
|
118
|
-
index: ['transactionIndex']
|
119
|
+
index: ['transactionIndex']
|
119
120
|
}
|
120
121
|
)
|
121
122
|
|
@@ -143,7 +144,7 @@ export function formatEthData(data: {
|
|
143
144
|
block,
|
144
145
|
trace,
|
145
146
|
transaction,
|
146
|
-
transactionReceipt
|
147
|
+
transactionReceipt
|
147
148
|
}
|
148
149
|
}
|
149
150
|
|
package/src/sui/builtin/0x1.ts
CHANGED
package/src/sui/builtin/0x2.ts
CHANGED
package/src/sui/builtin/0x3.ts
CHANGED
package/src/sui/sui-processor.ts
CHANGED
@@ -117,6 +117,10 @@ export class SuiBaseProcessor {
|
|
117
117
|
processor.config.baseLabels
|
118
118
|
)
|
119
119
|
|
120
|
+
// const parts = typeQname.split(SPLITTER)
|
121
|
+
// if (evt.packageId && parts[0] != evt.packageId) {
|
122
|
+
// evt.type = evt.type.replace(parts[0], evt.packageId)
|
123
|
+
// }
|
120
124
|
const decoded = await processor.coder.decodeEvent<any>(evt)
|
121
125
|
await handler(decoded || evt, ctx)
|
122
126
|
processResults.push(ctx.stopAndGetResult())
|
package/src/utils/index.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
export * from './conversion.js'
|
2
2
|
export * as token from './token.js'
|
3
3
|
export * from './dex-price.js'
|
4
|
-
export { getPriceByType, getPriceClient, getPriceBySymbol } from './price.js'
|
4
|
+
export { getPriceByType, getPriceClient, getPriceBySymbol, getCoinsThatHasPrice } from './price.js'
|
5
5
|
export * from './call.js'
|
package/src/utils/price.ts
CHANGED
@@ -143,3 +143,21 @@ export async function getPriceBySymbol(
|
|
143
143
|
function dateString(date: Date) {
|
144
144
|
return [date.getUTCDate(), date.getUTCMonth() + 1, date.getUTCFullYear()].join('-')
|
145
145
|
}
|
146
|
+
|
147
|
+
/**
|
148
|
+
* get coins that has price, return results are list of coin id with both symbol and address field set
|
149
|
+
* @param chainId
|
150
|
+
*/
|
151
|
+
export async function getCoinsThatHasPrice(chainId: ChainId) {
|
152
|
+
if (!priceClient) {
|
153
|
+
priceClient = getPriceClient()
|
154
|
+
}
|
155
|
+
const response = await priceClient.listCoins({
|
156
|
+
chain: chainId
|
157
|
+
})
|
158
|
+
|
159
|
+
return Object.entries(response.coinAddressesInChain).map(([symbol, coin]) => {
|
160
|
+
coin.symbol = symbol
|
161
|
+
return coin
|
162
|
+
})
|
163
|
+
}
|