@sentio/sdk 2.28.4-rc.3 → 2.29.0-rc.2
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/api.d.ts +2 -2
- package/lib/aptos/api.d.ts.map +1 -1
- package/lib/aptos/api.js +2 -2
- package/lib/aptos/api.js.map +1 -1
- package/lib/aptos/aptos-processor.d.ts +4 -3
- package/lib/aptos/aptos-processor.d.ts.map +1 -1
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/aptos-resource-processor-template.d.ts +1 -1
- package/lib/aptos/aptos-resource-processor-template.d.ts.map +1 -1
- package/lib/aptos/builtin/0x1.d.ts +431 -385
- package/lib/aptos/builtin/0x1.d.ts.map +1 -1
- package/lib/aptos/builtin/0x1.js.map +1 -1
- package/lib/aptos/builtin/0x3.d.ts +95 -55
- package/lib/aptos/builtin/0x3.d.ts.map +1 -1
- package/lib/aptos/builtin/0x3.js.map +1 -1
- package/lib/aptos/builtin/0x4.d.ts +18 -13
- package/lib/aptos/builtin/0x4.d.ts.map +1 -1
- package/lib/aptos/builtin/0x4.js.map +1 -1
- package/lib/aptos/codegen/codegen.js +3 -2
- package/lib/aptos/codegen/codegen.js.map +1 -1
- package/lib/aptos/codegen/types.test.js.map +1 -1
- package/lib/aptos/context.d.ts +6 -6
- package/lib/aptos/context.d.ts.map +1 -1
- package/lib/aptos/context.js +7 -5
- package/lib/aptos/context.js.map +1 -1
- package/lib/aptos/ext/aptos-dex.d.ts +2 -1
- package/lib/aptos/ext/aptos-dex.d.ts.map +1 -1
- package/lib/aptos/ext/aptos-dex.js.map +1 -1
- package/lib/aptos/ext/coin-event.d.ts +4 -4
- package/lib/aptos/ext/coin-event.d.ts.map +1 -1
- package/lib/aptos/ext/coin-event.js.map +1 -1
- package/lib/aptos/ext/coin-event.test.js.map +1 -1
- package/lib/aptos/index.d.ts +0 -1
- package/lib/aptos/index.d.ts.map +1 -1
- package/lib/aptos/index.js.map +1 -1
- package/lib/aptos/models.d.ts +2 -2
- package/lib/aptos/models.d.ts.map +1 -1
- package/lib/aptos/network.d.ts +3 -3
- package/lib/aptos/network.d.ts.map +1 -1
- package/lib/aptos/network.js +7 -4
- package/lib/aptos/network.js.map +1 -1
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +15 -12
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/context.d.ts +2 -2
- package/lib/eth/context.d.ts.map +1 -1
- package/lib/eth/context.js +1 -1
- package/lib/eth/context.js.map +1 -1
- package/lib/testing/aptos-facet.d.ts +4 -4
- package/lib/testing/aptos-facet.d.ts.map +1 -1
- package/lib/testing/aptos-facet.js.map +1 -1
- package/lib/tsup.config.ts +1 -2
- package/package.json +14 -15
- package/src/aptos/api.ts +3 -3
- package/src/aptos/aptos-processor.ts +9 -14
- package/src/aptos/aptos-resource-processor-template.ts +1 -1
- package/src/aptos/builtin/0x1.ts +444 -384
- package/src/aptos/builtin/0x3.ts +109 -48
- package/src/aptos/builtin/0x4.ts +35 -14
- package/src/aptos/codegen/codegen.ts +6 -3
- package/src/aptos/context.ts +19 -10
- package/src/aptos/ext/aptos-dex.ts +2 -8
- package/src/aptos/ext/coin-event.ts +7 -12
- package/src/aptos/index.ts +0 -10
- package/src/aptos/models.ts +3 -2
- package/src/aptos/network.ts +8 -6
- package/src/eth/base-processor.ts +24 -12
- package/src/eth/context.ts +2 -1
- package/src/testing/aptos-facet.ts +7 -7
- package/src/tsup.config.ts +1 -2
package/src/aptos/index.ts
CHANGED
@@ -9,16 +9,6 @@ export { AptosPlugin } from './aptos-plugin.js'
|
|
9
9
|
|
10
10
|
export { defaultMoveCoder } from './move-coder.js'
|
11
11
|
|
12
|
-
export type {
|
13
|
-
Event,
|
14
|
-
Transaction_UserTransaction,
|
15
|
-
Address,
|
16
|
-
MoveResource,
|
17
|
-
MoveFunction,
|
18
|
-
MoveStruct,
|
19
|
-
MoveModuleBytecode,
|
20
|
-
TransactionPayload_EntryFunctionPayload
|
21
|
-
} from '@typemove/aptos'
|
22
12
|
export { MoveCoder } from '@typemove/aptos'
|
23
13
|
|
24
14
|
export { BUILTIN_TYPES } from '@typemove/move'
|
package/src/aptos/models.ts
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
import { Event, MoveResource,
|
1
|
+
import { Event, MoveResource, EntryFunctionPayloadResponse } from '@aptos-labs/ts-sdk'
|
2
|
+
|
2
3
|
import { DecodedStruct } from '@typemove/move'
|
3
4
|
|
4
5
|
export type TypedEventInstance<T> = DecodedStruct<Event, T>
|
5
6
|
export type TypedMoveResource<T> = DecodedStruct<MoveResource, T>
|
6
7
|
|
7
8
|
// Don't use intermediate type to make IDE happier
|
8
|
-
export type TypedFunctionPayload<T extends Array<any>> =
|
9
|
+
export type TypedFunctionPayload<T extends Array<any>> = EntryFunctionPayloadResponse & {
|
9
10
|
/**
|
10
11
|
* decoded argument data using ABI, undefined if there is decoding error, usually because the ABI/data mismatch
|
11
12
|
*/
|
package/src/aptos/network.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { AptosChainId } from '@sentio/chain'
|
2
|
-
import {
|
2
|
+
import { Aptos, AptosConfig } from '@aptos-labs/ts-sdk'
|
3
3
|
import { Labels } from '../core/index.js'
|
4
4
|
import { Endpoints } from '@sentio/runtime'
|
5
5
|
|
@@ -13,7 +13,7 @@ export const AptosNetwork = <const>{
|
|
13
13
|
export class AptosBindOptions {
|
14
14
|
address: string
|
15
15
|
network?: AptosNetwork = AptosNetwork.MAIN_NET
|
16
|
-
client?:
|
16
|
+
client?: Aptos
|
17
17
|
startVersion?: bigint | number
|
18
18
|
baseLabels?: Labels
|
19
19
|
}
|
@@ -21,16 +21,18 @@ export class AptosBindOptions {
|
|
21
21
|
export function getRpcEndpoint(network: AptosNetwork): string {
|
22
22
|
switch (network) {
|
23
23
|
case AptosNetwork.TEST_NET:
|
24
|
-
return 'https://testnet.aptoslabs.com/'
|
24
|
+
return 'https://testnet.aptoslabs.com/v1'
|
25
25
|
}
|
26
|
-
return 'https://mainnet.aptoslabs.com/'
|
26
|
+
return 'https://mainnet.aptoslabs.com/v1'
|
27
27
|
}
|
28
28
|
|
29
|
-
export function getClient(network: AptosNetwork):
|
29
|
+
export function getClient(network: AptosNetwork): Aptos {
|
30
30
|
let chainServer = Endpoints.INSTANCE.chainServer.get(network)
|
31
31
|
if (!chainServer) {
|
32
32
|
chainServer = getRpcEndpoint(network)
|
33
33
|
// throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')
|
34
|
+
} else {
|
35
|
+
chainServer = chainServer + '/v1'
|
34
36
|
}
|
35
|
-
return new
|
37
|
+
return new Aptos(new AptosConfig({ fullnode: chainServer }))
|
36
38
|
}
|
@@ -9,7 +9,7 @@ import {
|
|
9
9
|
Data_EthTransaction,
|
10
10
|
EthFetchConfig,
|
11
11
|
HandleInterval,
|
12
|
-
ProcessResult
|
12
|
+
ProcessResult
|
13
13
|
} from '@sentio/protos'
|
14
14
|
import { BindOptions } from './bind-options.js'
|
15
15
|
import { PromiseOrVoid } from '../core/promises.js'
|
@@ -77,7 +77,7 @@ export class GlobalProcessor {
|
|
77
77
|
address: '*',
|
78
78
|
name: config.name || 'Global',
|
79
79
|
network: config.network || EthChainId.ETHEREUM,
|
80
|
-
startBlock: 0n
|
80
|
+
startBlock: 0n
|
81
81
|
}
|
82
82
|
if (config.startBlock) {
|
83
83
|
this.config.startBlock = BigInt(config.startBlock)
|
@@ -98,7 +98,7 @@ export class GlobalProcessor {
|
|
98
98
|
undefined,
|
99
99
|
{
|
100
100
|
recentInterval: blockInterval,
|
101
|
-
backfillInterval: backfillBlockInterval
|
101
|
+
backfillInterval: backfillBlockInterval
|
102
102
|
},
|
103
103
|
fetchConfig
|
104
104
|
)
|
@@ -143,13 +143,13 @@ export class GlobalProcessor {
|
|
143
143
|
throw new ServerError(Status.INVALID_ARGUMENT, 'Block is empty')
|
144
144
|
}
|
145
145
|
|
146
|
-
const ctx = new GlobalContext(chainId, new Date(block.timestamp * 1000), block, undefined, undefined)
|
146
|
+
const ctx = new GlobalContext(chainId, '*', new Date(block.timestamp * 1000), block, undefined, undefined)
|
147
147
|
await handler(block, ctx)
|
148
148
|
return ctx.stopAndGetResult()
|
149
149
|
},
|
150
150
|
timeIntervalInMinutes: timeInterval,
|
151
151
|
blockInterval: blockInterval,
|
152
|
-
fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {})
|
152
|
+
fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {})
|
153
153
|
})
|
154
154
|
return this
|
155
155
|
}
|
@@ -166,11 +166,20 @@ export class GlobalProcessor {
|
|
166
166
|
if (!transaction) {
|
167
167
|
throw new ServerError(Status.INVALID_ARGUMENT, 'transaction is empty')
|
168
168
|
}
|
169
|
-
const ctx = new GlobalContext(
|
169
|
+
const ctx = new GlobalContext(
|
170
|
+
chainId,
|
171
|
+
transaction.to || '*',
|
172
|
+
data.timestamp,
|
173
|
+
block,
|
174
|
+
undefined,
|
175
|
+
trace,
|
176
|
+
transaction,
|
177
|
+
transactionReceipt
|
178
|
+
)
|
170
179
|
await handler(transaction, ctx)
|
171
180
|
return ctx.stopAndGetResult()
|
172
181
|
},
|
173
|
-
fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {})
|
182
|
+
fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {})
|
174
183
|
})
|
175
184
|
return this
|
176
185
|
}
|
@@ -192,7 +201,7 @@ export abstract class BaseProcessor<
|
|
192
201
|
name: config.name || '',
|
193
202
|
network: config.network || EthChainId.ETHEREUM,
|
194
203
|
startBlock: 0n,
|
195
|
-
baseLabels: config.baseLabels
|
204
|
+
baseLabels: config.baseLabels
|
196
205
|
}
|
197
206
|
if (config.startBlock) {
|
198
207
|
this.config.startBlock = BigInt(config.startBlock)
|
@@ -261,6 +270,9 @@ export abstract class BaseProcessor<
|
|
261
270
|
throw e
|
262
271
|
// console.log(e)
|
263
272
|
}
|
273
|
+
if (processor.config.address === '*') {
|
274
|
+
contractView.address = log.address
|
275
|
+
}
|
264
276
|
|
265
277
|
const ctx = new ContractContext<TContract, TBoundContractView>(
|
266
278
|
contractName,
|
@@ -283,7 +295,7 @@ export abstract class BaseProcessor<
|
|
283
295
|
return ctx.stopAndGetResult()
|
284
296
|
}
|
285
297
|
return ProcessResult.fromPartial({})
|
286
|
-
}
|
298
|
+
}
|
287
299
|
})
|
288
300
|
return this
|
289
301
|
}
|
@@ -299,7 +311,7 @@ export abstract class BaseProcessor<
|
|
299
311
|
undefined,
|
300
312
|
{
|
301
313
|
recentInterval: blockInterval,
|
302
|
-
backfillInterval: backfillBlockInterval
|
314
|
+
backfillInterval: backfillBlockInterval
|
303
315
|
},
|
304
316
|
fetchConfig
|
305
317
|
)
|
@@ -353,7 +365,7 @@ export abstract class BaseProcessor<
|
|
353
365
|
},
|
354
366
|
timeIntervalInMinutes: timeInterval,
|
355
367
|
blockInterval: blockInterval,
|
356
|
-
fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {})
|
368
|
+
fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {})
|
357
369
|
})
|
358
370
|
return this
|
359
371
|
}
|
@@ -415,7 +427,7 @@ export abstract class BaseProcessor<
|
|
415
427
|
)
|
416
428
|
await handler(typedTrace, ctx)
|
417
429
|
return ctx.stopAndGetResult()
|
418
|
-
}
|
430
|
+
}
|
419
431
|
})
|
420
432
|
return this
|
421
433
|
}
|
package/src/eth/context.ts
CHANGED
@@ -125,6 +125,7 @@ export class AccountContext extends EthContext {
|
|
125
125
|
export class GlobalContext extends EthContext {
|
126
126
|
constructor(
|
127
127
|
chainId: EthChainId,
|
128
|
+
address: string,
|
128
129
|
timestamp?: Date,
|
129
130
|
block?: BlockParams,
|
130
131
|
log?: LogParams,
|
@@ -193,7 +194,7 @@ export class ContractView<TContract extends BaseContract> {
|
|
193
194
|
|
194
195
|
export class BoundContractView<TContract extends BaseContract, TContractView extends ContractView<TContract>> {
|
195
196
|
protected view: TContractView
|
196
|
-
|
197
|
+
address: string
|
197
198
|
// context will be set right after context creation (in context's constructor)
|
198
199
|
// context: ContractContext<TContract, BoundContractView<TContract, TContractView>>
|
199
200
|
context: EthContext
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { UserTransactionResponse, EntryFunctionPayloadResponse } from '@aptos-labs/ts-sdk'
|
2
2
|
import { DataBinding, HandlerType } from '@sentio/protos'
|
3
3
|
import { TestProcessorServer } from './test-processor-server.js'
|
4
4
|
import { AptosNetwork } from '@sentio/sdk/aptos'
|
@@ -10,11 +10,11 @@ export class AptosFacet {
|
|
10
10
|
this.server = server
|
11
11
|
}
|
12
12
|
|
13
|
-
testEntryFunctionCall(transaction:
|
13
|
+
testEntryFunctionCall(transaction: UserTransactionResponse, network: AptosNetwork = AptosNetwork.MAIN_NET) {
|
14
14
|
return this.testEntryFunctionCalls([transaction], network)
|
15
15
|
}
|
16
16
|
|
17
|
-
testEntryFunctionCalls(transactions:
|
17
|
+
testEntryFunctionCalls(transactions: UserTransactionResponse[], network: AptosNetwork = AptosNetwork.MAIN_NET) {
|
18
18
|
const bindings = []
|
19
19
|
for (const trans of transactions) {
|
20
20
|
const binding = this.buildEntryFunctionCallBinding(trans, network)
|
@@ -29,10 +29,10 @@ export class AptosFacet {
|
|
29
29
|
}
|
30
30
|
|
31
31
|
private buildEntryFunctionCallBinding(
|
32
|
-
transaction:
|
32
|
+
transaction: UserTransactionResponse,
|
33
33
|
network: AptosNetwork = AptosNetwork.MAIN_NET
|
34
34
|
): DataBinding | undefined {
|
35
|
-
const payload = transaction.payload as
|
35
|
+
const payload = transaction.payload as EntryFunctionPayloadResponse
|
36
36
|
for (const config of this.server.contractConfigs) {
|
37
37
|
if (config.contract?.chainId !== network) {
|
38
38
|
continue
|
@@ -56,7 +56,7 @@ export class AptosFacet {
|
|
56
56
|
return undefined
|
57
57
|
}
|
58
58
|
|
59
|
-
testEvent(transaction:
|
59
|
+
testEvent(transaction: UserTransactionResponse, network: AptosNetwork = AptosNetwork.MAIN_NET) {
|
60
60
|
const binding = this.buildEventBinding(transaction, network)
|
61
61
|
if (!binding) {
|
62
62
|
throw Error('Invalid test event: ' + JSON.stringify(transaction))
|
@@ -65,7 +65,7 @@ export class AptosFacet {
|
|
65
65
|
}
|
66
66
|
|
67
67
|
private buildEventBinding(
|
68
|
-
transaction:
|
68
|
+
transaction: UserTransactionResponse,
|
69
69
|
network: AptosNetwork = AptosNetwork.MAIN_NET
|
70
70
|
): DataBinding | undefined {
|
71
71
|
// const allEvents = new Set(transaction.events.map(e => e.type))
|