@sentio/sdk 2.38.1-rc.2 → 2.39.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.
Files changed (74) hide show
  1. package/lib/aptos/aptos-plugin.d.ts.map +1 -1
  2. package/lib/aptos/aptos-plugin.js +2 -1
  3. package/lib/aptos/aptos-plugin.js.map +1 -1
  4. package/lib/aptos/aptos-resource-processor-template.d.ts.map +1 -1
  5. package/lib/aptos/aptos-resource-processor-template.js +2 -1
  6. package/lib/aptos/aptos-resource-processor-template.js.map +1 -1
  7. package/lib/cosmos/context.d.ts +15 -0
  8. package/lib/cosmos/context.d.ts.map +1 -0
  9. package/lib/cosmos/context.js +33 -0
  10. package/lib/cosmos/context.js.map +1 -0
  11. package/lib/cosmos/cosmos-plugin.d.ts +17 -0
  12. package/lib/cosmos/cosmos-plugin.d.ts.map +1 -0
  13. package/lib/cosmos/cosmos-plugin.js +71 -0
  14. package/lib/cosmos/cosmos-plugin.js.map +1 -0
  15. package/lib/cosmos/cosmos-processor.d.ts +12 -0
  16. package/lib/cosmos/cosmos-processor.d.ts.map +1 -0
  17. package/lib/cosmos/cosmos-processor.js +36 -0
  18. package/lib/cosmos/cosmos-processor.js.map +1 -0
  19. package/lib/cosmos/index.d.ts +5 -0
  20. package/lib/cosmos/index.d.ts.map +1 -0
  21. package/lib/cosmos/index.js +5 -0
  22. package/lib/cosmos/index.js.map +1 -0
  23. package/lib/cosmos/network.d.ts +8 -0
  24. package/lib/cosmos/network.d.ts.map +1 -0
  25. package/lib/cosmos/network.js +14 -0
  26. package/lib/cosmos/network.js.map +1 -0
  27. package/lib/cosmos/transaction.d.ts +48 -0
  28. package/lib/cosmos/transaction.d.ts.map +1 -0
  29. package/lib/cosmos/transaction.js +2 -0
  30. package/lib/cosmos/transaction.js.map +1 -0
  31. package/lib/cosmos/types.d.ts +21 -0
  32. package/lib/cosmos/types.d.ts.map +1 -0
  33. package/lib/cosmos/types.js +5 -0
  34. package/lib/cosmos/types.js.map +1 -0
  35. package/lib/eth/base-processor-template.d.ts.map +1 -1
  36. package/lib/eth/base-processor-template.js +9 -14
  37. package/lib/eth/base-processor-template.js.map +1 -1
  38. package/lib/eth/eth-plugin.d.ts.map +1 -1
  39. package/lib/eth/eth-plugin.js +2 -1
  40. package/lib/eth/eth-plugin.js.map +1 -1
  41. package/lib/fuel/network.d.ts.map +1 -1
  42. package/lib/fuel/network.js +0 -1
  43. package/lib/fuel/network.js.map +1 -1
  44. package/lib/sui/sui-object-processor-template.d.ts.map +1 -1
  45. package/lib/sui/sui-object-processor-template.js +2 -1
  46. package/lib/sui/sui-object-processor-template.js.map +1 -1
  47. package/lib/sui/sui-plugin.d.ts.map +1 -1
  48. package/lib/sui/sui-plugin.js +2 -1
  49. package/lib/sui/sui-plugin.js.map +1 -1
  50. package/lib/testing/cosmos-facet.d.ts +9 -0
  51. package/lib/testing/cosmos-facet.d.ts.map +1 -0
  52. package/lib/testing/cosmos-facet.js +46 -0
  53. package/lib/testing/cosmos-facet.js.map +1 -0
  54. package/lib/testing/test-processor-server.d.ts +2 -0
  55. package/lib/testing/test-processor-server.d.ts.map +1 -1
  56. package/lib/testing/test-processor-server.js +3 -0
  57. package/lib/testing/test-processor-server.js.map +1 -1
  58. package/package.json +5 -4
  59. package/src/aptos/aptos-plugin.ts +2 -1
  60. package/src/aptos/aptos-resource-processor-template.ts +2 -1
  61. package/src/cosmos/context.ts +38 -0
  62. package/src/cosmos/cosmos-plugin.ts +100 -0
  63. package/src/cosmos/cosmos-processor.ts +43 -0
  64. package/src/cosmos/index.ts +4 -0
  65. package/src/cosmos/network.ts +16 -0
  66. package/src/cosmos/transaction.ts +46 -0
  67. package/src/cosmos/types.ts +23 -0
  68. package/src/eth/base-processor-template.ts +9 -14
  69. package/src/eth/eth-plugin.ts +2 -1
  70. package/src/fuel/network.ts +0 -2
  71. package/src/sui/sui-object-processor-template.ts +2 -1
  72. package/src/sui/sui-plugin.ts +2 -1
  73. package/src/testing/cosmos-facet.ts +54 -0
  74. package/src/testing/test-processor-server.ts +3 -0
@@ -0,0 +1,23 @@
1
+ import { ListStateStorage } from '@sentio/runtime'
2
+ import { CosmosProcessor } from './cosmos-processor.js'
3
+ import { ProcessResult } from '@sentio/protos'
4
+ import { CosmosNetwork } from './network.js'
5
+
6
+ export class CosmosProcessorState extends ListStateStorage<CosmosProcessor> {
7
+ static INSTANCE = new CosmosProcessorState()
8
+ }
9
+
10
+ export type CallHandler<T> = {
11
+ handler: (call: T) => Promise<ProcessResult>
12
+ logConfig?: {
13
+ logFilters: string[]
14
+ }
15
+ }
16
+
17
+ export type CosmosProcessorConfig = {
18
+ address: string
19
+ name?: string
20
+ chainId: CosmosNetwork
21
+ startBlock?: bigint
22
+ endBlock?: bigint
23
+ }
@@ -52,7 +52,7 @@ export abstract class BaseProcessorTemplate<
52
52
  public bind(options: Omit<BindOptions, 'network'>, ctx: EthContext): void {
53
53
  const sig = getOptionsSignature({
54
54
  address: options.address,
55
- network: ctx.chainId,
55
+ network: ctx.chainId
56
56
  })
57
57
  if (this.binds.has(sig)) {
58
58
  console.log(`Same address can be bind to one template only once, ignore duplicate bind: ${sig}`)
@@ -80,22 +80,17 @@ export abstract class BaseProcessorTemplate<
80
80
  address: options.address,
81
81
  name: options.name || '',
82
82
  chainId: ctx.chainId,
83
- abi: '',
83
+ abi: ''
84
84
  },
85
- startBlock: 0n,
86
- endBlock: 0n,
87
- }
88
- if (options.startBlock) {
89
- instance.startBlock = BigInt(options.startBlock)
90
- }
91
- if (options.endBlock) {
92
- instance.endBlock = BigInt(options.endBlock)
85
+ startBlock: BigInt(options.startBlock || 0),
86
+ endBlock: BigInt(options.endBlock || 0),
87
+ baseLabels: options.baseLabels
93
88
  }
94
89
  TemplateInstanceState.INSTANCE.addValue(instance)
95
90
  ctx.update({
96
91
  states: {
97
- configUpdated: true,
98
- },
92
+ configUpdated: true
93
+ }
99
94
  })
100
95
  }
101
96
 
@@ -107,7 +102,7 @@ export abstract class BaseProcessorTemplate<
107
102
  this.eventHandlers.push({
108
103
  handler: handler,
109
104
  filter: filter,
110
- fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),
105
+ fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {})
111
106
  })
112
107
  return this
113
108
  }
@@ -123,7 +118,7 @@ export abstract class BaseProcessorTemplate<
123
118
  undefined,
124
119
  {
125
120
  recentInterval: blockInterval,
126
- backfillInterval: backfillBlockInterval,
121
+ backfillInterval: backfillBlockInterval
127
122
  },
128
123
  fetchConfig
129
124
  )
@@ -273,7 +273,8 @@ export class EthPlugin extends Plugin {
273
273
  name: instance.contract.name,
274
274
  address: validateAndNormalizeAddress(instance.contract.address),
275
275
  startBlock: instance.startBlock,
276
- endBlock: instance.endBlock
276
+ endBlock: instance.endBlock,
277
+ baseLabels: instance.baseLabels
277
278
  },
278
279
  ctx
279
280
  )
@@ -1,8 +1,6 @@
1
1
  import { FuelChainId } from '@sentio/chain'
2
2
  import { FUEL_NETWORK_URL } from 'fuels'
3
3
 
4
- const SENTIO_FUEL_TESTNET = 'http://sentio-0.sentio.xyz:8080/sentio-internal-api/fuel-testnet/'
5
-
6
4
  export type FuelNetwork = FuelChainId
7
5
  export const FuelNetwork = <const>{
8
6
  MAIN_NET: FuelChainId.FUEL_MAINNET,
@@ -77,7 +77,8 @@ export abstract class SuiObjectOrAddressProcessorTemplate<
77
77
  abi: ''
78
78
  },
79
79
  startBlock: config.startCheckpoint,
80
- endBlock: 0n
80
+ endBlock: 0n,
81
+ baseLabels: config.baseLabels
81
82
  })
82
83
  }
83
84
 
@@ -63,7 +63,8 @@ export class SuiPlugin extends Plugin {
63
63
  address: instance.contract?.address || '',
64
64
  objectId: instance.contract?.address || '',
65
65
  network: <SuiNetwork>instance.contract?.chainId || SuiNetwork.MAIN_NET,
66
- startCheckpoint: instance.startBlock || 0n
66
+ startCheckpoint: instance.startBlock || 0n,
67
+ baseLabels: instance.baseLabels
67
68
  },
68
69
  NoopContext
69
70
  )
@@ -0,0 +1,54 @@
1
+ import { TestProcessorServer } from './test-processor-server.js'
2
+ import { DataBinding, HandlerType } from '@sentio/protos'
3
+ import { CosmosNetwork } from '../cosmos/network.js'
4
+
5
+ export class CosmosFacet {
6
+ server: TestProcessorServer
7
+
8
+ constructor(server: TestProcessorServer) {
9
+ this.server = server
10
+ }
11
+
12
+ testOnTransaction(transaction: any, network: CosmosNetwork = CosmosNetwork.INJECTIVE_TESTNET) {
13
+ const bindings = this.buildBinding(transaction, network)
14
+ if (!bindings) {
15
+ throw Error('Invalid test transaction: ' + JSON.stringify(transaction))
16
+ }
17
+
18
+ return this.server.processBindings({
19
+ bindings
20
+ })
21
+ }
22
+
23
+ private buildBinding(transaction: any, network: CosmosNetwork): DataBinding[] {
24
+ const res: DataBinding[] = []
25
+ for (const config of this.server.contractConfigs) {
26
+ if (config.contract?.chainId !== network) {
27
+ continue
28
+ }
29
+
30
+ for (const logConfig of config.cosmosLogConfigs) {
31
+ const binding = {
32
+ data: {
33
+ cosmosCall: {
34
+ transaction,
35
+ timestamp: new Date()
36
+ }
37
+ },
38
+ handlerIds: [logConfig.handlerId],
39
+ handlerType: HandlerType.COSMOS_CALL
40
+ }
41
+
42
+ const logFilters = logConfig.logFilters
43
+ for (const log of transaction.logs || []) {
44
+ if (log.events.find((e: any) => logFilters.includes(e.type))) {
45
+ res.push(binding)
46
+ break
47
+ }
48
+ }
49
+ }
50
+ }
51
+
52
+ return res
53
+ }
54
+ }
@@ -23,6 +23,7 @@ import { SolanaFacet } from './solana-facet.js'
23
23
  import { EthFacet } from './eth-facet.js'
24
24
  import { SuiFacet } from './sui-facet.js'
25
25
  import { FuelFacet } from './fuel-facet.js'
26
+ import { CosmosFacet } from './cosmos-facet.js'
26
27
 
27
28
  export const TEST_CONTEXT: CallContext = <CallContext>{}
28
29
 
@@ -40,6 +41,7 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
40
41
  solana: SolanaFacet
41
42
  sui: SuiFacet
42
43
  fuel: FuelFacet
44
+ cosmos: CosmosFacet
43
45
 
44
46
  constructor(loader: () => Promise<any>, httpEndpoints: Record<string, string> = {}) {
45
47
  cleanTest()
@@ -50,6 +52,7 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
50
52
  this.eth = new EthFacet(this)
51
53
  this.sui = new SuiFacet(this)
52
54
  this.fuel = new FuelFacet(this)
55
+ this.cosmos = new CosmosFacet(this)
53
56
 
54
57
  for (const k in CHAIN_MAP) {
55
58
  const http = httpEndpoints[k] || ''