@sentio/sdk 1.16.4 → 1.17.1

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.
Files changed (126) hide show
  1. package/lib/aptos-processor.d.ts +21 -0
  2. package/lib/aptos-processor.js +65 -0
  3. package/lib/aptos-processor.js.map +1 -0
  4. package/lib/bind-options.d.ts +2 -0
  5. package/lib/bind-options.js +4 -1
  6. package/lib/bind-options.js.map +1 -1
  7. package/lib/builtin/eacaggregatorproxy/index.d.ts +2 -0
  8. package/lib/builtin/eacaggregatorproxy/index.js +22 -0
  9. package/lib/builtin/eacaggregatorproxy/index.js.map +1 -0
  10. package/lib/builtin/eacaggregatorproxy/test-utils.d.ts +6 -0
  11. package/lib/builtin/eacaggregatorproxy/test-utils.js +57 -0
  12. package/lib/builtin/eacaggregatorproxy/test-utils.js.map +1 -0
  13. package/lib/builtin/internal/EACAggregatorProxy.d.ts +460 -0
  14. package/lib/builtin/internal/EACAggregatorProxy.js +3 -0
  15. package/lib/builtin/internal/EACAggregatorProxy.js.map +1 -0
  16. package/lib/builtin/internal/eacaggregatorproxy_processor.d.ts +317 -0
  17. package/lib/builtin/internal/eacaggregatorproxy_processor.js +813 -0
  18. package/lib/builtin/internal/eacaggregatorproxy_processor.js.map +1 -0
  19. package/lib/builtin/internal/factories/EACAggregatorProxy__factory.d.ts +46 -0
  20. package/lib/builtin/internal/factories/EACAggregatorProxy__factory.js +527 -0
  21. package/lib/builtin/internal/factories/EACAggregatorProxy__factory.js.map +1 -0
  22. package/lib/builtin/internal/factories/index.d.ts +1 -0
  23. package/lib/builtin/internal/factories/index.js +3 -1
  24. package/lib/builtin/internal/factories/index.js.map +1 -1
  25. package/lib/builtin/internal/index.d.ts +2 -0
  26. package/lib/builtin/internal/index.js +3 -1
  27. package/lib/builtin/internal/index.js.map +1 -1
  28. package/lib/context.d.ts +5 -0
  29. package/lib/context.js +15 -3
  30. package/lib/context.js.map +1 -1
  31. package/lib/gen/processor/protos/processor.d.ts +2 -0
  32. package/lib/gen/processor/protos/processor.js +19 -0
  33. package/lib/gen/processor/protos/processor.js.map +1 -1
  34. package/lib/index.d.ts +2 -1
  35. package/lib/index.js +4 -1
  36. package/lib/index.js.map +1 -1
  37. package/lib/meter.js +17 -0
  38. package/lib/meter.js.map +1 -1
  39. package/lib/processor-state.d.ts +2 -0
  40. package/lib/processor-state.js +1 -0
  41. package/lib/processor-state.js.map +1 -1
  42. package/lib/service.js +47 -0
  43. package/lib/service.js.map +1 -1
  44. package/lib/solana/builtin/spl-token-processor.d.ts +16 -1
  45. package/lib/solana/builtin/spl-token-processor.js +120 -0
  46. package/lib/solana/builtin/spl-token-processor.js.map +1 -1
  47. package/lib/solana/builtin/types.d.ts +97 -0
  48. package/lib/solana/builtin/types.js.map +1 -1
  49. package/lib/test/{mirrorworld.d.ts → aptos.test.d.ts} +0 -0
  50. package/lib/test/aptos.test.js +142 -0
  51. package/lib/test/aptos.test.js.map +1 -0
  52. package/lib/test/erc20.js.map +1 -1
  53. package/lib/test/erc20.test.js.map +1 -1
  54. package/lib/test/solana.test.js +1 -17
  55. package/lib/test/solana.test.js.map +1 -1
  56. package/lib/test/souffl3.d.ts +1 -0
  57. package/lib/test/souffl3.js +24 -0
  58. package/lib/test/souffl3.js.map +1 -0
  59. package/lib/test/test-provider.d.ts +1 -1
  60. package/lib/test/test-provider.js +11 -5
  61. package/lib/test/test-provider.js.map +1 -1
  62. package/lib/test/types/{game_wallet.d.ts → basic_1.d.ts} +2 -21
  63. package/lib/test/types/basic_1.js +66 -0
  64. package/lib/test/types/basic_1.js.map +1 -0
  65. package/lib/test/types/basic_1_processor.d.ts +13 -0
  66. package/lib/test/types/basic_1_processor.js +41 -0
  67. package/lib/test/types/basic_1_processor.js.map +1 -0
  68. package/lib/utils/chainlink-oracles-goerli.csv +8 -0
  69. package/lib/utils/chainlink-oracles.csv +217 -0
  70. package/lib/utils/dex-price.d.ts +22 -0
  71. package/lib/utils/dex-price.js +114 -0
  72. package/lib/utils/dex-price.js.map +1 -0
  73. package/lib/utils/dex-price.test.d.ts +1 -0
  74. package/lib/utils/dex-price.test.js +22 -0
  75. package/lib/utils/dex-price.test.js.map +1 -0
  76. package/lib/utils/erc20.d.ts +1 -0
  77. package/lib/utils/erc20.js +7 -3
  78. package/lib/utils/erc20.js.map +1 -1
  79. package/lib/utils/index.d.ts +3 -1
  80. package/lib/utils/index.js +6 -1
  81. package/lib/utils/index.js.map +1 -1
  82. package/package.json +3 -3
  83. package/src/abis/EACAggregatorProxy.json +227 -0
  84. package/src/aptos-processor.ts +75 -0
  85. package/src/bind-options.ts +1 -0
  86. package/src/builtin/eacaggregatorproxy/index.ts +6 -0
  87. package/src/builtin/eacaggregatorproxy/test-utils.ts +89 -0
  88. package/src/builtin/internal/EACAggregatorProxy.ts +861 -0
  89. package/src/builtin/internal/eacaggregatorproxy_processor.ts +1417 -0
  90. package/src/builtin/internal/factories/EACAggregatorProxy__factory.ts +533 -0
  91. package/src/builtin/internal/factories/index.ts +1 -0
  92. package/src/builtin/internal/index.ts +2 -0
  93. package/src/context.ts +15 -2
  94. package/src/gen/processor/protos/processor.ts +20 -0
  95. package/src/index.ts +2 -1
  96. package/src/meter.ts +18 -2
  97. package/src/processor-state.ts +3 -0
  98. package/src/service.ts +51 -0
  99. package/src/solana/builtin/spl-token-processor.ts +137 -1
  100. package/src/solana/builtin/types.ts +11 -0
  101. package/src/test/abis/solana/basic_1.json +62 -0
  102. package/src/test/aptos.test.ts +148 -0
  103. package/src/test/erc20.test.ts +1 -1
  104. package/src/test/erc20.ts +0 -1
  105. package/src/test/solana.test.ts +1 -18
  106. package/src/test/souffl3.ts +24 -0
  107. package/src/test/test-provider.ts +11 -5
  108. package/src/test/types/basic_1.ts +62 -0
  109. package/src/test/types/basic_1_processor.ts +41 -0
  110. package/src/utils/chainlink-oracles-goerli.csv +8 -0
  111. package/src/utils/chainlink-oracles.csv +217 -0
  112. package/src/utils/dex-price.test.ts +24 -0
  113. package/src/utils/dex-price.ts +136 -0
  114. package/src/utils/erc20.ts +5 -1
  115. package/src/utils/index.ts +3 -1
  116. package/lib/test/mirrorworld.js +0 -42
  117. package/lib/test/mirrorworld.js.map +0 -1
  118. package/lib/test/types/game_wallet.js +0 -1396
  119. package/lib/test/types/game_wallet.js.map +0 -1
  120. package/lib/test/types/game_wallet_processor.d.ts +0 -107
  121. package/lib/test/types/game_wallet_processor.js +0 -105
  122. package/lib/test/types/game_wallet_processor.js.map +0 -1
  123. package/src/test/abis/solana/mirrorworld.json +0 -1392
  124. package/src/test/mirrorworld.ts +0 -40
  125. package/src/test/types/game_wallet.ts +0 -1392
  126. package/src/test/types/game_wallet_processor.ts +0 -113
package/src/meter.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { MetricDescriptor, RecordMetaData } from './gen/processor/protos/processor'
2
- import { BaseContext, Context, SolanaContext, SuiContext } from './context'
2
+ import { AptosContext, BaseContext, Context, SolanaContext, SuiContext } from './context'
3
3
  import { toMetricValue, Numberish } from './numberish'
4
4
  import Long from 'long'
5
5
 
@@ -42,6 +42,7 @@ function GetRecordMetaData(ctx: BaseContext, metric: Metric, labels: Labels): Re
42
42
  contractAddress: ctx.contract.rawContract.address,
43
43
  blockNumber: Long.fromNumber(ctx.log.blockNumber, true), // TODO need number type to be long
44
44
  transactionIndex: ctx.log.transactionIndex,
45
+ transactionHash: ctx.transactionHash || '',
45
46
  logIndex: ctx.log.logIndex,
46
47
  chainId: ctx.chainId.toString(),
47
48
  descriptor: descriptor,
@@ -53,6 +54,7 @@ function GetRecordMetaData(ctx: BaseContext, metric: Metric, labels: Labels): Re
53
54
  contractAddress: ctx.contract.rawContract.address,
54
55
  blockNumber: Long.fromNumber(ctx.block.number, true),
55
56
  transactionIndex: -1,
57
+ transactionHash: '',
56
58
  logIndex: -1,
57
59
  chainId: ctx.chainId.toString(),
58
60
  descriptor: descriptor,
@@ -63,7 +65,8 @@ function GetRecordMetaData(ctx: BaseContext, metric: Metric, labels: Labels): Re
63
65
  return {
64
66
  contractAddress: ctx.contract.rawContract.address,
65
67
  blockNumber: Long.fromNumber(ctx.trace.blockNumber, true),
66
- transactionIndex: ctx.trace.transactionPosition, // TODO make sure if this is the right value to set
68
+ transactionIndex: ctx.trace.transactionPosition,
69
+ transactionHash: ctx.transactionHash || '',
67
70
  logIndex: -1,
68
71
  chainId: ctx.chainId.toString(),
69
72
  descriptor: descriptor,
@@ -75,6 +78,7 @@ function GetRecordMetaData(ctx: BaseContext, metric: Metric, labels: Labels): Re
75
78
  contractAddress: ctx.address,
76
79
  blockNumber: Long.ZERO, // TODO need number type to be long
77
80
  transactionIndex: 0,
81
+ transactionHash: '', // TODO add
78
82
  logIndex: 0,
79
83
  chainId: 'SOL_mainnet', // TODO set in context
80
84
  descriptor: descriptor,
@@ -85,11 +89,23 @@ function GetRecordMetaData(ctx: BaseContext, metric: Metric, labels: Labels): Re
85
89
  contractAddress: ctx.address,
86
90
  blockNumber: Long.ZERO, // TODO need number type to be long
87
91
  transactionIndex: 0,
92
+ transactionHash: '', // TODO
88
93
  logIndex: 0,
89
94
  chainId: 'SUI_devnet', // TODO set in context
90
95
  descriptor: descriptor,
91
96
  labels: normalizeLabels(labels),
92
97
  }
98
+ } else if (ctx instanceof AptosContext) {
99
+ return {
100
+ contractAddress: ctx.address,
101
+ blockNumber: Long.ZERO, // TODO need number type to be long
102
+ transactionIndex: 0,
103
+ transactionHash: '', // TODO
104
+ logIndex: 0,
105
+ chainId: 'aptos_devnet', // TODO set in context
106
+ descriptor: descriptor,
107
+ labels: normalizeLabels(labels),
108
+ }
93
109
  }
94
110
  throw new Error("This can't happen")
95
111
  }
@@ -6,6 +6,7 @@ import { TemplateInstance } from './gen/processor/protos/processor'
6
6
  import { Provider } from '@ethersproject/providers'
7
7
  import { SolanaBaseProcessor } from './solana-processor'
8
8
  import { SuiBaseProcessor } from './sui-processor'
9
+ import { AptosBaseProcessor } from './aptos-processor'
9
10
 
10
11
  export class ProcessorState {
11
12
  // from abiName_address_chainId => contract wrapper
@@ -24,4 +25,6 @@ export class ProcessorState {
24
25
  solanaProcessors: SolanaBaseProcessor[] = []
25
26
 
26
27
  suiProcessors: SuiBaseProcessor[] = []
28
+
29
+ aptosProcessors: AptosBaseProcessor[] = []
27
30
  }
package/src/service.ts CHANGED
@@ -195,6 +195,26 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
195
195
  }
196
196
  this.contractConfigs.push(contractConfig)
197
197
  }
198
+
199
+ // Part 3, prepare aptos constractors
200
+ for (const aptosProcessor of global.PROCESSOR_STATE.aptosProcessors) {
201
+ const contractConfig: ContractConfig = {
202
+ processorType: 'user_processor',
203
+ contract: {
204
+ name: 'aptos processor',
205
+ chainId: 'aptos_testnet',
206
+ address: aptosProcessor.address,
207
+ abi: '',
208
+ },
209
+ blockConfigs: [],
210
+ logConfigs: [],
211
+ traceConfigs: [],
212
+ startBlock: aptosProcessor.config.startSeqNumber,
213
+ endBlock: DEFAULT_MAX_BLOCK,
214
+ instructionConfig: undefined,
215
+ }
216
+ this.contractConfigs.push(contractConfig)
217
+ }
198
218
  }
199
219
 
200
220
  async start(request: StartRequest, context: CallContext): Promise<Empty> {
@@ -339,6 +359,37 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
339
359
  await Promise.all(processorPromises)
340
360
  }
341
361
 
362
+ if (request.chainId.toLowerCase().startsWith('apt') && global.PROCESSOR_STATE.aptosProcessors) {
363
+ const processorPromises: Promise<void>[] = []
364
+ for (const txn of request.transactions) {
365
+ processorPromises.push(
366
+ new Promise((resolve, _) => {
367
+ for (const processor of global.PROCESSOR_STATE.aptosProcessors) {
368
+ if (processor.address === txn.programAccountId!) {
369
+ const res = processor.handleTransaction(JSON.parse(new TextDecoder().decode(txn.raw)))
370
+ if (res) {
371
+ res.gauges.forEach((g) => {
372
+ if (g.metadata && txn.slot) {
373
+ g.metadata.blockNumber = txn.slot
374
+ }
375
+ result.gauges.push(g)
376
+ })
377
+ res.counters.forEach((c) => {
378
+ if (c.metadata && txn.slot) {
379
+ c.metadata.blockNumber = txn.slot
380
+ }
381
+ result.counters.push(c)
382
+ })
383
+ }
384
+ }
385
+ }
386
+ resolve()
387
+ })
388
+ )
389
+ }
390
+ await Promise.all(processorPromises)
391
+ }
392
+
342
393
  recordRuntimeInfo(result, HandlerType.TRANSACTION)
343
394
  return {
344
395
  result,
@@ -1,7 +1,7 @@
1
1
  import { SolanaBaseProcessor } from '../../solana-processor'
2
2
  import { SolanaContext } from '../../context'
3
3
  import { Instruction } from '@project-serum/anchor'
4
- import { Approve, Burn, CloseAccount, FreezeAccount, InitializeAccount, InitializeAccount2, InitializeAccount3, InitializeMint, InitializeMultisig, MintTo, Revoke, ThawAccount, Transfer } from './types';
4
+ import { AmountToUiAmount, Approve, ApproveChecked, Burn, BurnChecked, CloseAccount, CreateNativeMint, DefaultAccountStateExtension, FreezeAccount, GetAccountDataSize, InitializeAccount, InitializeAccount2, InitializeAccount3, InitializeImmutableOwner, InitializeMint, InitializeMintCloseAuthority, InitializeMultisig, MemoTransferExtension, MintTo, MintToChecked, Reallocate, Revoke, SyncNative, ThawAccount, Transfer, TransferChecked, TransferFeeExtension, UiAmountToAmount } from './types';
5
5
  import { SolanaBindOptions } from '../../bind-options';
6
6
 
7
7
  export class SPLTokenProcessor extends SolanaBaseProcessor {
@@ -160,5 +160,141 @@ export class SPLTokenProcessor extends SolanaBaseProcessor {
160
160
  })
161
161
  return this
162
162
  }
163
+
164
+ public onTransferChecked(handler: (data: TransferChecked, ctx: SolanaContext) => void): SPLTokenProcessor {
165
+ this.onInstruction('transferChecked', (ins: Instruction, ctx) => {
166
+ if (ins) {
167
+ handler(ins.data as TransferChecked, ctx)
168
+ }
169
+ })
170
+ return this
171
+ }
172
+
173
+ public onApproveChecked(handler: (data: ApproveChecked, ctx: SolanaContext) => void): SPLTokenProcessor {
174
+ this.onInstruction('approveChecked', (ins: Instruction, ctx) => {
175
+ if (ins) {
176
+ handler(ins.data as ApproveChecked, ctx)
177
+ }
178
+ })
179
+ return this
180
+ }
181
+
182
+ public onMintToChecked(handler: (data: MintToChecked, ctx: SolanaContext) => void): SPLTokenProcessor {
183
+ this.onInstruction('mintToChecked', (ins: Instruction, ctx) => {
184
+ if (ins) {
185
+ handler(ins.data as MintToChecked, ctx)
186
+ }
187
+ })
188
+ return this
189
+ }
190
+
191
+ public onBurnChecked(handler: (data: BurnChecked, ctx: SolanaContext) => void): SPLTokenProcessor {
192
+ this.onInstruction('burnChecked', (ins: Instruction, ctx) => {
193
+ if (ins) {
194
+ handler(ins.data as BurnChecked, ctx)
195
+ }
196
+ })
197
+ return this
198
+ }
199
+
200
+ public onSyncNative(handler: (data: SyncNative, ctx: SolanaContext) => void): SPLTokenProcessor {
201
+ this.onInstruction('syncNative', (ins: Instruction, ctx) => {
202
+ if (ins) {
203
+ handler(ins.data as SyncNative, ctx)
204
+ }
205
+ })
206
+ return this
207
+ }
208
+
209
+ public onGetAccountDataSize(handler: (data: GetAccountDataSize, ctx: SolanaContext) => void): SPLTokenProcessor {
210
+ this.onInstruction('getAccountDataSize', (ins: Instruction, ctx) => {
211
+ if (ins) {
212
+ handler(ins.data as GetAccountDataSize, ctx)
213
+ }
214
+ })
215
+ return this
216
+ }
217
+
218
+ public onInitializeImmutableOwner(handler: (data: InitializeImmutableOwner, ctx: SolanaContext) => void): SPLTokenProcessor {
219
+ this.onInstruction('initializeImmutableOwner', (ins: Instruction, ctx) => {
220
+ if (ins) {
221
+ handler(ins.data as InitializeImmutableOwner, ctx)
222
+ }
223
+ })
224
+ return this
225
+ }
226
+
227
+ public onAmountToUiAmount(handler: (data: AmountToUiAmount, ctx: SolanaContext) => void): SPLTokenProcessor {
228
+ this.onInstruction('amountToUiAmount', (ins: Instruction, ctx) => {
229
+ if (ins) {
230
+ handler(ins.data as AmountToUiAmount, ctx)
231
+ }
232
+ })
233
+ return this
234
+ }
235
+
236
+ public onUiAmountToAmount(handler: (data: UiAmountToAmount, ctx: SolanaContext) => void): SPLTokenProcessor {
237
+ this.onInstruction('uiAmountToAmount', (ins: Instruction, ctx) => {
238
+ if (ins) {
239
+ handler(ins.data as UiAmountToAmount, ctx)
240
+ }
241
+ })
242
+ return this
243
+ }
244
+
245
+ public onInitializeMintCloseAuthority(handler: (data: InitializeMintCloseAuthority, ctx: SolanaContext) => void): SPLTokenProcessor {
246
+ this.onInstruction('initializeMintCloseAuthority', (ins: Instruction, ctx) => {
247
+ if (ins) {
248
+ handler(ins.data as InitializeMintCloseAuthority, ctx)
249
+ }
250
+ })
251
+ return this
252
+ }
253
+
254
+ public onTransferFeeExtension(handler: (data: TransferFeeExtension, ctx: SolanaContext) => void): SPLTokenProcessor {
255
+ this.onInstruction('transferFeeExtension', (ins: Instruction, ctx) => {
256
+ if (ins) {
257
+ handler(ins.data as TransferFeeExtension, ctx)
258
+ }
259
+ })
260
+ return this
261
+ }
262
+
263
+ public onDefaultAccountStateExtension(handler: (data: DefaultAccountStateExtension, ctx: SolanaContext) => void): SPLTokenProcessor {
264
+ this.onInstruction('defaultAccountStateExtension', (ins: Instruction, ctx) => {
265
+ if (ins) {
266
+ handler(ins.data as DefaultAccountStateExtension, ctx)
267
+ }
268
+ })
269
+ return this
270
+ }
271
+
272
+ public onReallocate(handler: (data: Reallocate, ctx: SolanaContext) => void): SPLTokenProcessor {
273
+ this.onInstruction('reallocate', (ins: Instruction, ctx) => {
274
+ if (ins) {
275
+ handler(ins.data as Reallocate, ctx)
276
+ }
277
+ })
278
+ return this
279
+ }
280
+
281
+ public onMemoTransferExtension(handler: (data: MemoTransferExtension, ctx: SolanaContext) => void): SPLTokenProcessor {
282
+ this.onInstruction('memoTransferExtension', (ins: Instruction, ctx) => {
283
+ if (ins) {
284
+ handler(ins.data as MemoTransferExtension, ctx)
285
+ }
286
+ })
287
+ return this
288
+ }
289
+
290
+ public onCreateNativeMint(handler: (data: CreateNativeMint, ctx: SolanaContext) => void): SPLTokenProcessor {
291
+ this.onInstruction('createNativeMint', (ins: Instruction, ctx) => {
292
+ if (ins) {
293
+ handler(ins.data as CreateNativeMint, ctx)
294
+ }
295
+ })
296
+ return this
297
+ }
298
+
163
299
  // Todo(pcxu): auto gen this file
164
300
  }
@@ -205,34 +205,41 @@ const BurnChecked = type({
205
205
  tokenAmount: TokenAmountUi,
206
206
  });
207
207
 
208
+ export type SyncNative = Infer<typeof BurnChecked>;
208
209
  const SyncNative = type({
209
210
  account: PublicKeyFromString,
210
211
  });
211
212
 
213
+ export type GetAccountDataSize = Infer<typeof GetAccountDataSize>;
212
214
  const GetAccountDataSize = type({
213
215
  mint: PublicKeyFromString,
214
216
  extensionTypes: optional(array(string())),
215
217
  });
216
218
 
219
+ export type InitializeImmutableOwner = Infer<typeof InitializeImmutableOwner>;
217
220
  const InitializeImmutableOwner = type({
218
221
  account: PublicKeyFromString,
219
222
  });
220
223
 
224
+ export type AmountToUiAmount = Infer<typeof AmountToUiAmount>;
221
225
  const AmountToUiAmount = type({
222
226
  mint: PublicKeyFromString,
223
227
  amount: union([string(), number()]),
224
228
  });
225
229
 
230
+ export type UiAmountToAmount = Infer<typeof UiAmountToAmount>;
226
231
  const UiAmountToAmount = type({
227
232
  mint: PublicKeyFromString,
228
233
  uiAmount: string(),
229
234
  });
230
235
 
236
+ export type InitializeMintCloseAuthority = Infer<typeof InitializeMintCloseAuthority>;
231
237
  const InitializeMintCloseAuthority = type({
232
238
  mint: PublicKeyFromString,
233
239
  newAuthority: PublicKeyFromString,
234
240
  });
235
241
 
242
+ export type TransferFeeExtension = Infer<typeof TransferFeeExtension>;
236
243
  const TransferFeeExtension = type({
237
244
  mint: PublicKeyFromString,
238
245
  transferFeeConfigAuthority: PublicKeyFromString,
@@ -241,12 +248,14 @@ const TransferFeeExtension = type({
241
248
  maximumFee: number(),
242
249
  });
243
250
 
251
+ export type DefaultAccountStateExtension = Infer<typeof DefaultAccountStateExtension>;
244
252
  const DefaultAccountStateExtension = type({
245
253
  mint: PublicKeyFromString,
246
254
  accountState: string(),
247
255
  freezeAuthority: optional(PublicKeyFromString),
248
256
  });
249
257
 
258
+ export type Reallocate = Infer<typeof Reallocate>;
250
259
  const Reallocate = type({
251
260
  account: PublicKeyFromString,
252
261
  payer: PublicKeyFromString,
@@ -254,6 +263,7 @@ const Reallocate = type({
254
263
  extensionTypes: array(string()),
255
264
  });
256
265
 
266
+ export type MemoTransferExtension = Infer<typeof MemoTransferExtension>;
257
267
  const MemoTransferExtension = type({
258
268
  account: PublicKeyFromString,
259
269
  owner: optional(PublicKeyFromString),
@@ -261,6 +271,7 @@ const MemoTransferExtension = type({
261
271
  signers: optional(array(PublicKeyFromString)),
262
272
  });
263
273
 
274
+ export type CreateNativeMint = Infer<typeof CreateNativeMint>;
264
275
  const CreateNativeMint = type({
265
276
  payer: PublicKeyFromString,
266
277
  nativeMint: PublicKeyFromString,
@@ -0,0 +1,62 @@
1
+ {
2
+ "version": "0.1.0",
3
+ "name": "basic_1",
4
+ "instructions": [
5
+ {
6
+ "name": "initialize",
7
+ "accounts": [
8
+ {
9
+ "name": "myAccount",
10
+ "isMut": true,
11
+ "isSigner": true
12
+ },
13
+ {
14
+ "name": "user",
15
+ "isMut": true,
16
+ "isSigner": true
17
+ },
18
+ {
19
+ "name": "systemProgram",
20
+ "isMut": false,
21
+ "isSigner": false
22
+ }
23
+ ],
24
+ "args": [
25
+ {
26
+ "name": "data",
27
+ "type": "u64"
28
+ }
29
+ ]
30
+ },
31
+ {
32
+ "name": "update",
33
+ "accounts": [
34
+ {
35
+ "name": "myAccount",
36
+ "isMut": true,
37
+ "isSigner": false
38
+ }
39
+ ],
40
+ "args": [
41
+ {
42
+ "name": "data",
43
+ "type": "u64"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "accounts": [
49
+ {
50
+ "name": "MyAccount",
51
+ "type": {
52
+ "kind": "struct",
53
+ "fields": [
54
+ {
55
+ "name": "data",
56
+ "type": "u64"
57
+ }
58
+ ]
59
+ }
60
+ }
61
+ ]
62
+ }
@@ -0,0 +1,148 @@
1
+ import { expect } from 'chai'
2
+ import { TextEncoder } from 'util'
3
+ import { ProcessTransactionsRequest } from '..'
4
+
5
+ import { TestProcessorServer } from './test-processor-server'
6
+
7
+ describe('Test Aptos Example', () => {
8
+ const service = new TestProcessorServer(() => {
9
+ require('./souffl3')
10
+ })
11
+
12
+ beforeAll(async () => {
13
+ await service.start({ templateInstances: [] })
14
+ })
15
+
16
+ test('check configuration ', async () => {
17
+ const config = await service.getConfig({})
18
+ expect(config.contractConfigs).length(1)
19
+ })
20
+
21
+ test('Check souffl3 transaction dispatch', async () => {
22
+ const request: ProcessTransactionsRequest = {
23
+ chainId: 'aptos_testnet',
24
+ transactions: [
25
+ {
26
+ raw: new TextEncoder().encode(JSON.stringify(testData)),
27
+ programAccountId: '4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
28
+ },
29
+ ],
30
+ }
31
+ const res = await service.processTransactions(request)
32
+ expect(res.result?.counters).length(1)
33
+ expect(res.result?.gauges).length(0)
34
+ })
35
+ })
36
+
37
+ const testData = {
38
+ version: '18483034',
39
+ hash: '0xbf4df6f390546a793ba9b7caff120002b3257986dbea9c697fd64acf7dfeb052',
40
+ state_change_hash: '0x6063039cca5a1eb33d3986d3665fc783238579961eaa4746c41e25fa4f72aac6',
41
+ event_root_hash: '0x425e39bcf994672108f83c34f637e84166af7ecedcbe26aed0dff0d62da8055d',
42
+ state_checkpoint_hash: null,
43
+ gas_used: '854',
44
+ success: true,
45
+ vm_status: 'Executed successfully',
46
+ accumulator_root_hash: '0x47aa479d9e15993ea2abe04043c89186fb5da0b5eb8b5c6d18bd55d5f0c2c877',
47
+ changes: [],
48
+ sender: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
49
+ sequence_number: '30',
50
+ max_gas_amount: '20000',
51
+ gas_unit_price: '1',
52
+ expiration_timestamp_secs: '1663144544',
53
+ payload: {
54
+ function: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807::SouffleChefCampaign::pull_token_v2',
55
+ type_arguments: ['0x1::aptos_coin::AptosCoin'],
56
+ arguments: [
57
+ '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
58
+ '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
59
+ 'Souffl3 BlueBerry',
60
+ '1',
61
+ ],
62
+ type: 'entry_function_payload',
63
+ },
64
+ signature: {
65
+ public_key: '0x6c3f579afbf8a728827385039f7604ec1d06e5c802d8f9689ee8ec9d349fedc5',
66
+ signature:
67
+ '0xd2db95052e774f095d924030a50c29325a17e8d69d35c748f45bb0e22eb7d3b9e47545c98bd7130fd3ef46cbedc30c9aaeaf39c2d922ee8e7d578c0b1e76f30b',
68
+ type: 'ed25519_signature',
69
+ },
70
+ events: [
71
+ {
72
+ guid: {
73
+ creation_number: '3',
74
+ account_address: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
75
+ },
76
+ sequence_number: '10',
77
+ type: '0x1::coin::WithdrawEvent',
78
+ data: {
79
+ amount: '1',
80
+ },
81
+ },
82
+ {
83
+ guid: {
84
+ creation_number: '2',
85
+ account_address: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
86
+ },
87
+ sequence_number: '11',
88
+ type: '0x1::coin::DepositEvent',
89
+ data: {
90
+ amount: '1',
91
+ },
92
+ },
93
+ {
94
+ guid: {
95
+ creation_number: '9',
96
+ account_address: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
97
+ },
98
+ sequence_number: '9',
99
+ type: '0x3::token::CreateTokenDataEvent',
100
+ data: {
101
+ description:
102
+ 'Souffl3 offers a one-stop marketplace for the launch, listing, and trading of NFT assets on APTOS.\nWebsite:https://souffl3.com/\nEveryone can win through our Bake Off campaign on the Aptos Testnet, rewards including Souffl3 Genesis NFT and whitelists of other collab projects, everyone is welcome to participate!',
103
+ id: {
104
+ collection: 'Souffl3 BlueBerry',
105
+ creator: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
106
+ name: 'Souffl3 BlueBerry #2',
107
+ },
108
+ maximum: '999999999999',
109
+ mutability_config: {
110
+ description: true,
111
+ maximum: true,
112
+ properties: true,
113
+ royalty: true,
114
+ uri: true,
115
+ },
116
+ name: 'Souffl3 BlueBerry #2',
117
+ property_keys: ['author', 'point'],
118
+ property_types: ['string', 'integer'],
119
+ property_values: ['0x33454e4a4f59204c616273', '0x30'],
120
+ royalty_payee_address: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
121
+ royalty_points_denominator: '100',
122
+ royalty_points_numerator: '20',
123
+ uri: 'https://y3x4txhvirx5zl57efzbl6dg7psaier5q35hhwuqwzjwuahrycya.arweave.net/xu_J3PVEb9yvvyFyFfhm--QEEj2G-nPakLZTagDxwLA',
124
+ },
125
+ },
126
+ {
127
+ guid: {
128
+ creation_number: '2',
129
+ account_address: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
130
+ },
131
+ sequence_number: '27',
132
+ type: '0x3::token::DepositEvent',
133
+ data: {
134
+ amount: '1',
135
+ id: {
136
+ property_version: '0',
137
+ token_data_id: {
138
+ collection: 'Souffl3 BlueBerry',
139
+ creator: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
140
+ name: 'Souffl3 BlueBerry #2',
141
+ },
142
+ },
143
+ },
144
+ },
145
+ ],
146
+ timestamp: '1663143945131218',
147
+ type: 'user_transaction',
148
+ }
@@ -7,7 +7,7 @@ import { HandlerType } from '..'
7
7
  import { TestProcessorServer } from './test-processor-server'
8
8
  import { firstCounterValue, firstGaugeValue } from './metric-utils'
9
9
  import { BigNumber } from 'ethers'
10
- import { mockApprovalLog, mockTransferLog } from '../builtin/erc20/test-utils'
10
+ import { mockTransferLog } from '../builtin/erc20/test-utils'
11
11
  import { Trace } from '../trace'
12
12
 
13
13
  describe('Test Basic Examples', () => {
package/src/test/erc20.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { ERC20Processor, ERC20ProcessorTemplate } from '../builtin/erc20'
2
- import { BigNumber } from '@ethersproject/bignumber'
3
2
 
4
3
  export const filter = ERC20Processor.filters.Transfer(
5
4
  '0x0000000000000000000000000000000000000000',
@@ -11,7 +11,6 @@ import { firstCounterValue } from './metric-utils'
11
11
 
12
12
  describe('Test Solana Example', () => {
13
13
  const service = new TestProcessorServer(() => {
14
- require('./mirrorworld')
15
14
  require('./wormhole-token-bridge')
16
15
  })
17
16
 
@@ -21,23 +20,7 @@ describe('Test Solana Example', () => {
21
20
 
22
21
  test('check configuration ', async () => {
23
22
  const config = await service.getConfig({})
24
- expect(config.contractConfigs).length(3)
25
- })
26
-
27
- test('Check mirrorworld instruction dispatch', async () => {
28
- const request: ProcessInstructionsRequest = {
29
- instructions: [
30
- {
31
- instructionData: 'CACadoFwjNvan4GP8gh3Jtm1qdeoKX5j2SbSNEiB',
32
- slot: Long.fromNumber(0),
33
- programAccountId: 'F78NhTC9XmP1DKsCBRz5LGdQc4n4yFbj2dURiv7T9gGZ',
34
- },
35
- ],
36
- }
37
- const res = await service.processInstructions(request)
38
- expect(res.result?.counters).length(3)
39
- expect(res.result?.gauges).length(0)
40
- expect(firstCounterValue(res.result, 'deposit_pool_total_value')).equal(5000000000n)
23
+ expect(config.contractConfigs).length(2)
41
24
  })
42
25
 
43
26
  test('Check wormhole token bridge instruction dispatch', async () => {
@@ -0,0 +1,24 @@
1
+ import { AptosBindOptions } from '../bind-options'
2
+ import { AptosBaseProcessor } from '../aptos-processor'
3
+
4
+ class Souffl3 extends AptosBaseProcessor {
5
+ static bind(options: AptosBindOptions): Souffl3 {
6
+ if (options && !options.name) {
7
+ options.name = 'souffl3'
8
+ }
9
+ return new Souffl3(options)
10
+ }
11
+ }
12
+
13
+ Souffl3.bind({
14
+ startBlock: 6604913,
15
+ address: '4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
16
+ }).onTransaction((txn, ctx) => {
17
+ if (txn.events) {
18
+ for (const event of txn.events) {
19
+ if (event && event.type === '0x3::token::DepositEvent') {
20
+ ctx.meter.Counter('deposit_token_count').add(Number(event.data.amount))
21
+ }
22
+ }
23
+ }
24
+ })
@@ -1,18 +1,19 @@
1
1
  import { ChainConfig } from '../chain-config'
2
2
  import { setProvider } from '@sentio/sdk'
3
+ import { CHAIN_MAP } from '../utils/chainmap'
3
4
 
4
- export function loadTestProvidersFromEnv(ids: string[] | string): boolean {
5
+ export function loadTestProvidersFromEnv(requiredChainIds: string[] | string): boolean {
5
6
  const dummyConfig: Record<string, ChainConfig> = {}
6
7
 
7
- if (!Array.isArray(ids)) {
8
- ids = [ids]
8
+ if (!Array.isArray(requiredChainIds)) {
9
+ requiredChainIds = [requiredChainIds]
9
10
  }
10
11
 
11
- for (const k of ids) {
12
+ for (const k of Object.keys(CHAIN_MAP)) {
12
13
  const envKey = 'TEST_ENDPOINT_' + k
13
14
  const http = process.env[envKey]
14
15
  if (!http) {
15
- return false
16
+ continue
16
17
  }
17
18
  dummyConfig[k] = {
18
19
  ChainID: k,
@@ -21,5 +22,10 @@ export function loadTestProvidersFromEnv(ids: string[] | string): boolean {
21
22
  }
22
23
 
23
24
  setProvider(dummyConfig)
25
+ for (const id of requiredChainIds) {
26
+ if (!requiredChainIds.includes(id)) {
27
+ return false
28
+ }
29
+ }
24
30
  return true
25
31
  }