@sentio/sdk 3.2.0-rc.7 → 3.3.0-rc.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.
@@ -1,11 +1,13 @@
1
1
  import { Labels, BaseContext, RecordMetaData } from '../index.js';
2
2
  import { SolanaChainId } from '@sentio/chain';
3
+ import { TransactionResponse } from '@solana/web3.js';
3
4
  export declare class SolanaContext extends BaseContext {
4
5
  network: SolanaChainId;
5
6
  address: string;
6
7
  programName: string;
7
8
  blockNumber: bigint;
8
- constructor(programName: string, network: SolanaChainId, address: string, slot: bigint, baseLabels: Labels | undefined);
9
+ transaction?: TransactionResponse;
10
+ constructor(programName: string, network: SolanaChainId, address: string, slot: bigint, baseLabels: Labels | undefined, transaction?: TransactionResponse);
9
11
  getChainId(): SolanaChainId;
10
12
  getMetaDataInternal(name: string, labels: Labels): RecordMetaData;
11
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"solana-context.d.ts","sourceRoot":"","sources":["../../src/solana/solana-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE7C,qBAAa,aAAc,SAAQ,WAAW;IAC5C,OAAO,EAAE,aAAa,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;gBAGjB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GAAG,SAAS;IAShC,UAAU;IAIV,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc;CAalE"}
1
+ {"version":3,"file":"solana-context.d.ts","sourceRoot":"","sources":["../../src/solana/solana-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAErD,qBAAa,aAAc,SAAQ,WAAW;IAC5C,OAAO,EAAE,aAAa,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,mBAAmB,CAAA;gBAG/B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,WAAW,CAAC,EAAE,mBAAmB;IAUnC,UAAU;IAIV,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc;CAalE"}
@@ -5,12 +5,14 @@ export class SolanaContext extends BaseContext {
5
5
  address;
6
6
  programName;
7
7
  blockNumber;
8
- constructor(programName, network, address, slot, baseLabels) {
8
+ transaction;
9
+ constructor(programName, network, address, slot, baseLabels, transaction) {
9
10
  super(baseLabels);
10
11
  this.network = network || SolanaChainId.SOLANA_MAINNET;
11
12
  this.programName = programName;
12
13
  this.address = address;
13
14
  this.blockNumber = slot;
15
+ this.transaction = transaction;
14
16
  }
15
17
  getChainId() {
16
18
  return this.network;
@@ -21,7 +23,7 @@ export class SolanaContext extends BaseContext {
21
23
  contractName: this.programName,
22
24
  blockNumber: this.blockNumber,
23
25
  transactionIndex: 0,
24
- transactionHash: '', // TODO add
26
+ transactionHash: this.transaction?.transaction.signatures[0] || '',
25
27
  logIndex: 0,
26
28
  chainId: this.getChainId(),
27
29
  name: name,
@@ -1 +1 @@
1
- {"version":3,"file":"solana-context.js","sourceRoot":"","sources":["../../src/solana/solana-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,WAAW,EAAkB,MAAM,aAAa,CAAA;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE7C,MAAM,OAAO,aAAc,SAAQ,WAAW;IAC5C,OAAO,CAAe;IACtB,OAAO,CAAQ;IACf,WAAW,CAAQ;IACnB,WAAW,CAAQ;IAEnB,YACE,WAAmB,EACnB,OAAsB,EACtB,OAAe,EACf,IAAY,EACZ,UAA8B;QAE9B,KAAK,CAAC,UAAU,CAAC,CAAA;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,aAAa,CAAC,cAAc,CAAA;QACtD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;IACzB,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IAED,mBAAmB,CAAC,IAAY,EAAE,MAAc;QAC9C,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,YAAY,EAAE,IAAI,CAAC,WAAW;YAC9B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,gBAAgB,EAAE,CAAC;YACnB,eAAe,EAAE,EAAE,EAAE,WAAW;YAChC,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;YAC1B,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC;SAChC,CAAA;IACH,CAAC;CACF"}
1
+ {"version":3,"file":"solana-context.js","sourceRoot":"","sources":["../../src/solana/solana-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,WAAW,EAAkB,MAAM,aAAa,CAAA;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAG7C,MAAM,OAAO,aAAc,SAAQ,WAAW;IAC5C,OAAO,CAAe;IACtB,OAAO,CAAQ;IACf,WAAW,CAAQ;IACnB,WAAW,CAAQ;IACnB,WAAW,CAAsB;IAEjC,YACE,WAAmB,EACnB,OAAsB,EACtB,OAAe,EACf,IAAY,EACZ,UAA8B,EAC9B,WAAiC;QAEjC,KAAK,CAAC,UAAU,CAAC,CAAA;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,aAAa,CAAC,cAAc,CAAA;QACtD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;QACvB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IAED,mBAAmB,CAAC,IAAY,EAAE,MAAc;QAC9C,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,YAAY,EAAE,IAAI,CAAC,WAAW;YAC9B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,gBAAgB,EAAE,CAAC;YACnB,eAAe,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE;YAClE,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;YAC1B,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC;SAChC,CAAA;IACH,CAAC;CACF"}
@@ -11,4 +11,7 @@ export declare class SolanaBindOptions {
11
11
  instructionCoder?: InstructionCoder;
12
12
  baseLabels?: Labels;
13
13
  }
14
+ export declare class SolanaFetchConfig {
15
+ fetchTx?: boolean;
16
+ }
14
17
  //# sourceMappingURL=solana-options.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"solana-options.d.ts","sourceRoot":"","sources":["../../src/solana/solana-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE7C,qBAAa,iBAAiB;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1B,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB"}
1
+ {"version":3,"file":"solana-options.d.ts","sourceRoot":"","sources":["../../src/solana/solana-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE7C,qBAAa,iBAAiB;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1B,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB"}
@@ -8,4 +8,7 @@ export class SolanaBindOptions {
8
8
  instructionCoder;
9
9
  baseLabels;
10
10
  }
11
+ export class SolanaFetchConfig {
12
+ fetchTx;
13
+ }
11
14
  //# sourceMappingURL=solana-options.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"solana-options.js","sourceRoot":"","sources":["../../src/solana/solana-options.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,iBAAiB;IAC5B,OAAO,CAAQ;IACf,OAAO,CAAgB;IACvB,IAAI,CAAS;IACb,UAAU,CAAkB;IAC5B,QAAQ,CAAkB;IAC1B,uBAAuB,CAAU;IACjC,gBAAgB,CAAmB;IACnC,UAAU,CAAS;CACpB"}
1
+ {"version":3,"file":"solana-options.js","sourceRoot":"","sources":["../../src/solana/solana-options.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,iBAAiB;IAC5B,OAAO,CAAQ;IACf,OAAO,CAAgB;IACvB,IAAI,CAAS;IACb,UAAU,CAAkB;IAC5B,QAAQ,CAAkB;IAC1B,uBAAuB,CAAU;IACjC,gBAAgB,CAAmB;IACnC,UAAU,CAAS;CACpB;AAED,MAAM,OAAO,iBAAiB;IAC5B,OAAO,CAAU;CAClB"}
@@ -7,5 +7,6 @@ export declare class SolanaPlugin extends Plugin {
7
7
  supportedHandlers: HandlerType[];
8
8
  processBinding(request: DataBinding): Promise<ProcessResult>;
9
9
  processSolInstruction(request: DataBinding): Promise<ProcessResult>;
10
+ processSolBlock(request: DataBinding): Promise<ProcessResult>;
10
11
  }
11
12
  //# sourceMappingURL=solana-plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"solana-plugin.d.ts","sourceRoot":"","sources":["../../src/solana/solana-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,MAAM,EAAiC,MAAM,iBAAiB,CAAA;AACzG,OAAO,EAEL,WAAW,EACX,WAAW,EACX,YAAY,EACZ,qBAAqB,EACrB,aAAa,EACd,MAAM,gBAAgB,CAAA;AAOvB,qBAAa,YAAa,SAAQ,MAAM;IACtC,IAAI,EAAE,MAAM,CAAiB;IAEvB,IAAI,CAAC,MAAM,EAAE,YAAY;IAOzB,SAAS,CAAC,MAAM,EAAE,qBAAqB,EAAE,UAAU,CAAC,EAAE,MAAM;IA0BlE,iBAAiB,gBAAgC;IAEjD,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAStD,qBAAqB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;CAiD1E"}
1
+ {"version":3,"file":"solana-plugin.d.ts","sourceRoot":"","sources":["../../src/solana/solana-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,MAAM,EAAiC,MAAM,iBAAiB,CAAA;AACzG,OAAO,EAEL,WAAW,EACX,WAAW,EACX,YAAY,EAEZ,qBAAqB,EACrB,aAAa,EACd,MAAM,gBAAgB,CAAA;AAOvB,qBAAa,YAAa,SAAQ,MAAM;IACtC,IAAI,EAAE,MAAM,CAAiB;IAEvB,IAAI,CAAC,MAAM,EAAE,YAAY;IAOzB,SAAS,CAAC,MAAM,EAAE,qBAAqB,EAAE,UAAU,CAAC,EAAE,MAAM;IA+ClE,iBAAiB,gBAAuD;IAExE,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAWtD,qBAAqB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAkDnE,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;CAgBpE"}
@@ -1,5 +1,5 @@
1
1
  import { errorString, mergeProcessResults, Plugin, PluginManager, USER_PROCESSOR } from '@sentio/runtime';
2
- import { ContractConfig, HandlerType } from '@sentio/protos';
2
+ import { ContractConfig, HandlerType, OnIntervalConfig } from '@sentio/protos';
3
3
  import { ServerError, Status } from 'nice-grpc';
4
4
  import { SolanaProcessorState } from './solana-processor.js';
5
5
  export class SolanaPlugin extends Plugin {
@@ -17,6 +17,13 @@ export class SolanaPlugin extends Plugin {
17
17
  if (forChainId !== undefined && forChainId !== chainId.toString()) {
18
18
  continue;
19
19
  }
20
+ let fetchTx = false;
21
+ for (const fetchConfig of solanaProcessor.instructionHandlerMap.values()) {
22
+ if (fetchConfig.handlerOptions?.fetchTx) {
23
+ fetchTx = true;
24
+ break;
25
+ }
26
+ }
20
27
  const contractConfig = ContractConfig.fromPartial({
21
28
  processorType: USER_PROCESSOR,
22
29
  contract: {
@@ -29,17 +36,28 @@ export class SolanaPlugin extends Plugin {
29
36
  instructionConfig: {
30
37
  innerInstruction: solanaProcessor.processInnerInstruction,
31
38
  parsedInstruction: solanaProcessor.fromParsedInstruction !== null,
32
- rawDataInstruction: solanaProcessor.decodeInstruction !== null
39
+ rawDataInstruction: solanaProcessor.decodeInstruction !== null,
40
+ fetchTx: fetchTx
33
41
  }
34
42
  });
43
+ for (const [idx, handler] of solanaProcessor.blockHandlers.entries()) {
44
+ contractConfig.intervalConfigs.push(OnIntervalConfig.fromPartial({
45
+ handlerId: idx,
46
+ minutesInterval: handler.timeIntervalInMinutes,
47
+ slotInterval: handler.slotInterval,
48
+ handlerName: handler.handlerName
49
+ }));
50
+ }
35
51
  config.contractConfigs.push(contractConfig);
36
52
  }
37
53
  }
38
- supportedHandlers = [HandlerType.SOL_INSTRUCTION];
54
+ supportedHandlers = [HandlerType.SOL_INSTRUCTION, HandlerType.SOL_BLOCK];
39
55
  processBinding(request) {
40
56
  switch (request.handlerType) {
41
57
  case HandlerType.SOL_INSTRUCTION:
42
58
  return this.processSolInstruction(request);
59
+ case HandlerType.SOL_BLOCK:
60
+ return this.processSolBlock(request);
43
61
  default:
44
62
  throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType);
45
63
  }
@@ -55,7 +73,7 @@ export class SolanaPlugin extends Plugin {
55
73
  const promises = [];
56
74
  // Only have instruction handlers for solana processors
57
75
  for (const processor of SolanaProcessorState.INSTANCE.getValues()) {
58
- if (processor.address === instruction.programAccountId) {
76
+ if (processor.address === instruction.programAccountId || processor.address === '*') {
59
77
  let parsedInstruction = null;
60
78
  try {
61
79
  if (instruction.parsed) {
@@ -76,7 +94,7 @@ export class SolanaPlugin extends Plugin {
76
94
  continue;
77
95
  }
78
96
  const res = processor
79
- .handleInstruction(parsedInstruction, instruction.accounts, insHandler, instruction.slot)
97
+ .handleInstruction(parsedInstruction, instruction.accounts, insHandler, instruction)
80
98
  .catch((e) => {
81
99
  throw new ServerError(Status.INTERNAL, 'Error processing instruction: ' + JSON.stringify(instruction) + '\n' + errorString(e));
82
100
  });
@@ -85,6 +103,22 @@ export class SolanaPlugin extends Plugin {
85
103
  }
86
104
  return mergeProcessResults(await Promise.all(promises));
87
105
  }
106
+ async processSolBlock(request) {
107
+ if (!request.data?.solBlock) {
108
+ throw new ServerError(Status.INVALID_ARGUMENT, 'block data cannot be empty');
109
+ }
110
+ const block = request.data.solBlock;
111
+ const promises = [];
112
+ for (const processor of SolanaProcessorState.INSTANCE.getValues()) {
113
+ for (const handlerId of request.handlerIds) {
114
+ const handler = processor.blockHandlers[handlerId];
115
+ if (handler) {
116
+ promises.push(processor.handleBlock(block, handler));
117
+ }
118
+ }
119
+ }
120
+ return mergeProcessResults(await Promise.all(promises));
121
+ }
88
122
  }
89
123
  PluginManager.INSTANCE.register(new SolanaPlugin());
90
124
  //# sourceMappingURL=solana-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"solana-plugin.js","sourceRoot":"","sources":["../../src/solana/solana-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACzG,OAAO,EACL,cAAc,EAEd,WAAW,EAIZ,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAE/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAG5D,MAAM,OAAO,YAAa,SAAQ,MAAM;IACtC,IAAI,GAAW,cAAc,CAAA;IAE7B,KAAK,CAAC,IAAI,CAAC,MAAoB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D,CAAC;CACF;AAED,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,YAAY,EAAE,CAAC,CAAA"}
@@ -1,11 +1,12 @@
1
- import { ProcessResult } from '@sentio/protos';
1
+ import { Data_SolBlock, Data_SolInstruction, HandleInterval, ProcessResult } from '@sentio/protos';
2
2
  import { SolanaContext } from './solana-context.js';
3
3
  import { Instruction } from '@coral-xyz/anchor';
4
- import { SolanaBindOptions } from './solana-options.js';
4
+ import { SolanaBindOptions, SolanaFetchConfig } from './solana-options.js';
5
5
  import { ListStateStorage } from '@sentio/runtime';
6
- import { Labels } from '../core/index.js';
6
+ import { Labels, PromiseOrVoid } from '../core/index.js';
7
7
  import { SolanaChainId } from '@sentio/chain';
8
8
  import { HandlerOptions } from '../core/handler-options.js';
9
+ import { BlockResponse } from '@solana/web3.js';
9
10
  type IndexConfigure = {
10
11
  startSlot: bigint;
11
12
  endSlot?: bigint;
@@ -16,13 +17,21 @@ export interface InstructionCoder {
16
17
  export type SolanaInstructionHandler = (instruction: Instruction, ctx: SolanaContext, accounts?: string[]) => void;
17
18
  export interface InstructionHandlerEntry {
18
19
  handler: SolanaInstructionHandler;
19
- handlerOptions?: HandlerOptions<object, Instruction>;
20
+ handlerOptions?: HandlerOptions<SolanaFetchConfig, Instruction>;
21
+ }
22
+ export type SolanaBlockHandler<T> = (block: T, ctx: SolanaContext) => PromiseOrVoid;
23
+ export interface SolanaBlockHandlerEntry<T> {
24
+ handler: SolanaBlockHandler<T>;
25
+ timeIntervalInMinutes?: HandleInterval;
26
+ slotInterval?: HandleInterval;
27
+ handlerName: string;
20
28
  }
21
29
  export declare class SolanaProcessorState extends ListStateStorage<SolanaBaseProcessor> {
22
30
  static INSTANCE: SolanaProcessorState;
23
31
  }
24
32
  export declare class SolanaBaseProcessor {
25
33
  instructionHandlerMap: Map<string, InstructionHandlerEntry>;
34
+ blockHandlers: SolanaBlockHandlerEntry<any>[];
26
35
  address: string;
27
36
  endpoint: string;
28
37
  contractName: string;
@@ -37,16 +46,24 @@ export declare class SolanaBaseProcessor {
37
46
  info: any;
38
47
  }) => Instruction | null;
39
48
  constructor(options: SolanaBindOptions);
40
- onInstruction(instructionName: string, handler: SolanaInstructionHandler, handlerOptions?: HandlerOptions<object, Instruction>): this;
49
+ onInstruction(instructionName: string, handler: SolanaInstructionHandler, handlerOptions?: HandlerOptions<SolanaFetchConfig, Instruction>): this;
50
+ onTimeInterval(handler: SolanaBlockHandler<Data_SolBlock>, timeIntervalInMinutes?: number, backfillTimeIntervalInMinutes?: number): this;
51
+ onBlockInterval(handler: SolanaBlockHandler<Data_SolBlock>, blockInterval?: number, backfillBlockInterval?: number): this;
52
+ onInterval<T>(handler: SolanaBlockHandler<T>, timeInterval: HandleInterval | undefined, slotInterval: HandleInterval | undefined): this;
41
53
  getParsedInstruction(ins: string | {
42
54
  type: string;
43
55
  info: any;
44
56
  }): Instruction | null;
45
57
  getInstructionHandler(parsedInstruction: Instruction): InstructionHandlerEntry | undefined;
46
- handleInstruction(parsedInstruction: Instruction, accounts: string[], handlerEntry: InstructionHandlerEntry, slot: bigint): Promise<ProcessResult>;
58
+ handleInstruction(parsedInstruction: Instruction, accounts: string[], handlerEntry: InstructionHandlerEntry, data: Data_SolInstruction): Promise<ProcessResult>;
59
+ handleBlock(rawBlock: Data_SolBlock, handlerEntry: SolanaBlockHandlerEntry<BlockResponse>): Promise<ProcessResult>;
47
60
  getPartitionKey(parsedInstruction: Instruction, handlerEntry: InstructionHandlerEntry): Promise<string | undefined>;
48
61
  startSlot(startSlot: bigint | number): this;
49
62
  endBlock(endBlock: bigint | number): this;
50
63
  }
64
+ export declare class SolanaGlobalProcessor extends SolanaBaseProcessor {
65
+ static bind(options: Omit<SolanaBindOptions, 'address'>): SolanaGlobalProcessor;
66
+ constructor(options: SolanaBindOptions);
67
+ }
51
68
  export {};
52
69
  //# sourceMappingURL=solana-processor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"solana-processor.d.ts","sourceRoot":"","s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O,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAC9B,YAAY,EAAE,cAAc,GAAG,SAAS,EACxC,YAAY,EAAE,cAAc,GAAG,SAAS,GACvC,IAAI;IAUA,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAA;KAAE,GAAG,WAAW,GAAG,IAAI;IAYnF,qBAAqB,CAAC,iBAAiB,EAAE,WAAW,GAAG,uBAAuB,GAAG,SAAS;IAIpF,iBAAiB,CAC5B,iBAAiB,EAAE,WAAW,EAC9B,QAAQ,EAAE,MAAM,EAAE,EAClB,YAAY,EAAE,uBAAuB,EACrC,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,aAAa,CAAC;IAkBZ,WAAW,CACtB,QAAQ,EAAE,aAAa,EACvB,YAAY,EAAE,uBAAuB,CAAC,aAAa,CAAC,GACnD,OAAO,CAAC,aAAa,CAAC;IAOZ,eAAe,CAC1B,iBAAiB,EAAE,WAAW,EAC9B,YAAY,EAAE,uBAAuB,GACpC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IASvB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAKpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;CAI1C;AAED,qBAAa,qBAAsB,SAAQ,mBAAmB;IAC5D,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC,GAAG,qBAAqB;gBAInE,OAAO,EAAE,iBAAiB;CAIvC"}
@@ -1,11 +1,14 @@
1
1
  import { SolanaContext } from './solana-context.js';
2
2
  import { ListStateStorage } from '@sentio/runtime';
3
+ import { ALL_ADDRESS } from '../core/index.js';
3
4
  import { SolanaChainId } from '@sentio/chain';
5
+ import { getHandlerName, proxyProcessor } from '../utils/metrics.js';
4
6
  export class SolanaProcessorState extends ListStateStorage {
5
7
  static INSTANCE = new SolanaProcessorState();
6
8
  }
7
9
  export class SolanaBaseProcessor {
8
10
  instructionHandlerMap = new Map();
11
+ blockHandlers = [];
9
12
  address;
10
13
  endpoint;
11
14
  contractName;
@@ -43,6 +46,24 @@ export class SolanaBaseProcessor {
43
46
  this.instructionHandlerMap.set(instructionName, { handler, handlerOptions });
44
47
  return this;
45
48
  }
49
+ onTimeInterval(handler, timeIntervalInMinutes = 60, backfillTimeIntervalInMinutes = 240) {
50
+ return this.onInterval(handler, { recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes }, undefined);
51
+ }
52
+ onBlockInterval(handler, blockInterval = 1000, backfillBlockInterval = 4000) {
53
+ return this.onInterval(handler, undefined, {
54
+ recentInterval: blockInterval,
55
+ backfillInterval: backfillBlockInterval
56
+ });
57
+ }
58
+ onInterval(handler, timeInterval, slotInterval) {
59
+ this.blockHandlers.push({
60
+ handler: handler,
61
+ timeIntervalInMinutes: timeInterval,
62
+ slotInterval: slotInterval,
63
+ handlerName: getHandlerName()
64
+ });
65
+ return this;
66
+ }
46
67
  getParsedInstruction(ins) {
47
68
  if (ins) {
48
69
  if (ins.info) {
@@ -57,11 +78,21 @@ export class SolanaBaseProcessor {
57
78
  getInstructionHandler(parsedInstruction) {
58
79
  return this.instructionHandlerMap.get(parsedInstruction.name);
59
80
  }
60
- async handleInstruction(parsedInstruction, accounts, handlerEntry, slot) {
61
- const ctx = new SolanaContext(this.contractName, this.network, this.address, slot, this.baseLabels);
81
+ async handleInstruction(parsedInstruction, accounts, handlerEntry, data) {
82
+ let transaction = undefined;
83
+ if (data.rawTransaction) {
84
+ transaction = JSON.parse(data.rawTransaction);
85
+ }
86
+ const ctx = new SolanaContext(this.contractName, this.network, this.address, data.slot, this.baseLabels, transaction);
62
87
  await handlerEntry.handler(parsedInstruction, ctx, accounts);
63
88
  return ctx.stopAndGetResult();
64
89
  }
90
+ async handleBlock(rawBlock, handlerEntry) {
91
+ const ctx = new SolanaContext(this.contractName, this.network, this.address, rawBlock.slot, this.baseLabels);
92
+ const block = JSON.parse(rawBlock.rawBlock);
93
+ await handlerEntry.handler(block, ctx);
94
+ return ctx.stopAndGetResult();
95
+ }
65
96
  async getPartitionKey(parsedInstruction, handlerEntry) {
66
97
  const p = handlerEntry.handlerOptions?.partitionKey;
67
98
  if (!p)
@@ -80,4 +111,13 @@ export class SolanaBaseProcessor {
80
111
  return this;
81
112
  }
82
113
  }
114
+ export class SolanaGlobalProcessor extends SolanaBaseProcessor {
115
+ static bind(options) {
116
+ return new SolanaGlobalProcessor({ ...options, address: ALL_ADDRESS });
117
+ }
118
+ constructor(options) {
119
+ super(options);
120
+ return proxyProcessor(this);
121
+ }
122
+ }
83
123
  //# sourceMappingURL=solana-processor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"solana-processor.js","sourceRoot":"","sources":["../../src/solana/solana-processor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAmB7C,MAAM,OAAO,oBAAqB,SAAQ,gBAAqC;IAC7E,MAAM,CAAC,QAAQ,GAAyB,IAAI,oBAAoB,EAAE,CAAA;;AAGpE,MAAM,OAAO,mBAAmB;IACvB,qBAAqB,GAAyC,IAAI,GAAG,EAAE,CAAA;IAC9E,OAAO,CAAQ;IACf,QAAQ,CAAQ;IAChB,YAAY,CAAQ;IACpB,UAAU,CAAS;IACnB,OAAO,CAAe;IACtB,uBAAuB,CAAS;IAChC,MAAM,GAAmB,EAAE,SAAS,EAAE,EAAE,EAAE,CAAA;IAC1C,gBAAgB,CAAkB;IAElC,iBAAiB,CAAC,cAAsB;QACtC,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAA;QAC/D,CAAC;QACD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sB,SAAQ,mBAAmB;IAC5D,MAAM,CAAC,IAAI,CAAC,OAA2C;QACrD,OAAO,IAAI,qBAAqB,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAA;IACxE,CAAC;IAED,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,cAAc,CAAC,IAAI,CAAC,CAAA;IAC7B,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/sdk",
3
- "version": "3.2.0-rc.7",
3
+ "version": "3.3.0-rc.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -97,8 +97,8 @@
97
97
  "typechain": "^8.3.2",
98
98
  "utility-types": "^3.11.0",
99
99
  "yaml": "^2.3.4",
100
- "@sentio/protos": "3.2.0-rc.7",
101
- "@sentio/runtime": "^3.2.0-rc.7"
100
+ "@sentio/protos": "3.3.0-rc.1",
101
+ "@sentio/runtime": "^3.3.0-rc.1"
102
102
  },
103
103
  "peerDependencies": {
104
104
  "@sentio/tsup": "^8.3.5-rc.1"
@@ -1,24 +1,28 @@
1
1
  import { normalizeLabels, Labels, BaseContext, RecordMetaData } from '../index.js'
2
2
  import { SolanaChainId } from '@sentio/chain'
3
+ import { TransactionResponse } from '@solana/web3.js'
3
4
 
4
5
  export class SolanaContext extends BaseContext {
5
6
  network: SolanaChainId
6
7
  address: string
7
8
  programName: string
8
9
  blockNumber: bigint
10
+ transaction?: TransactionResponse
9
11
 
10
12
  constructor(
11
13
  programName: string,
12
14
  network: SolanaChainId,
13
15
  address: string,
14
16
  slot: bigint,
15
- baseLabels: Labels | undefined
17
+ baseLabels: Labels | undefined,
18
+ transaction?: TransactionResponse
16
19
  ) {
17
20
  super(baseLabels)
18
21
  this.network = network || SolanaChainId.SOLANA_MAINNET
19
22
  this.programName = programName
20
23
  this.address = address
21
24
  this.blockNumber = slot
25
+ this.transaction = transaction
22
26
  }
23
27
 
24
28
  getChainId() {
@@ -31,7 +35,7 @@ export class SolanaContext extends BaseContext {
31
35
  contractName: this.programName,
32
36
  blockNumber: this.blockNumber,
33
37
  transactionIndex: 0,
34
- transactionHash: '', // TODO add
38
+ transactionHash: this.transaction?.transaction.signatures[0] || '',
35
39
  logIndex: 0,
36
40
  chainId: this.getChainId(),
37
41
  name: name,
@@ -12,3 +12,7 @@ export class SolanaBindOptions {
12
12
  instructionCoder?: InstructionCoder
13
13
  baseLabels?: Labels
14
14
  }
15
+
16
+ export class SolanaFetchConfig {
17
+ fetchTx?: boolean
18
+ }
@@ -4,6 +4,7 @@ import {
4
4
  DataBinding,
5
5
  HandlerType,
6
6
  InitResponse,
7
+ OnIntervalConfig,
7
8
  ProcessConfigResponse,
8
9
  ProcessResult
9
10
  } from '@sentio/protos'
@@ -30,6 +31,14 @@ export class SolanaPlugin extends Plugin {
30
31
  if (forChainId !== undefined && forChainId !== chainId.toString()) {
31
32
  continue
32
33
  }
34
+ let fetchTx = false
35
+ for (const fetchConfig of solanaProcessor.instructionHandlerMap.values()) {
36
+ if (fetchConfig.handlerOptions?.fetchTx) {
37
+ fetchTx = true
38
+ break
39
+ }
40
+ }
41
+
33
42
  const contractConfig = ContractConfig.fromPartial({
34
43
  processorType: USER_PROCESSOR,
35
44
  contract: {
@@ -42,19 +51,34 @@ export class SolanaPlugin extends Plugin {
42
51
  instructionConfig: {
43
52
  innerInstruction: solanaProcessor.processInnerInstruction,
44
53
  parsedInstruction: solanaProcessor.fromParsedInstruction !== null,
45
- rawDataInstruction: solanaProcessor.decodeInstruction !== null
54
+ rawDataInstruction: solanaProcessor.decodeInstruction !== null,
55
+ fetchTx: fetchTx
46
56
  }
47
57
  })
58
+
59
+ for (const [idx, handler] of solanaProcessor.blockHandlers.entries()) {
60
+ contractConfig.intervalConfigs.push(
61
+ OnIntervalConfig.fromPartial({
62
+ handlerId: idx,
63
+ minutesInterval: handler.timeIntervalInMinutes,
64
+ slotInterval: handler.slotInterval,
65
+ handlerName: handler.handlerName
66
+ })
67
+ )
68
+ }
69
+
48
70
  config.contractConfigs.push(contractConfig)
49
71
  }
50
72
  }
51
73
 
52
- supportedHandlers = [HandlerType.SOL_INSTRUCTION]
74
+ supportedHandlers = [HandlerType.SOL_INSTRUCTION, HandlerType.SOL_BLOCK]
53
75
 
54
76
  processBinding(request: DataBinding): Promise<ProcessResult> {
55
77
  switch (request.handlerType) {
56
78
  case HandlerType.SOL_INSTRUCTION:
57
79
  return this.processSolInstruction(request)
80
+ case HandlerType.SOL_BLOCK:
81
+ return this.processSolBlock(request)
58
82
  default:
59
83
  throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)
60
84
  }
@@ -73,7 +97,7 @@ export class SolanaPlugin extends Plugin {
73
97
 
74
98
  // Only have instruction handlers for solana processors
75
99
  for (const processor of SolanaProcessorState.INSTANCE.getValues()) {
76
- if (processor.address === instruction.programAccountId) {
100
+ if (processor.address === instruction.programAccountId || processor.address === '*') {
77
101
  let parsedInstruction: SolInstruction | null = null
78
102
 
79
103
  try {
@@ -96,7 +120,7 @@ export class SolanaPlugin extends Plugin {
96
120
  continue
97
121
  }
98
122
  const res = processor
99
- .handleInstruction(parsedInstruction, instruction.accounts, insHandler, instruction.slot)
123
+ .handleInstruction(parsedInstruction, instruction.accounts, insHandler, instruction)
100
124
  .catch((e) => {
101
125
  throw new ServerError(
102
126
  Status.INTERNAL,
@@ -109,6 +133,23 @@ export class SolanaPlugin extends Plugin {
109
133
  }
110
134
  return mergeProcessResults(await Promise.all(promises))
111
135
  }
136
+
137
+ async processSolBlock(request: DataBinding): Promise<ProcessResult> {
138
+ if (!request.data?.solBlock) {
139
+ throw new ServerError(Status.INVALID_ARGUMENT, 'block data cannot be empty')
140
+ }
141
+ const block = request.data.solBlock
142
+ const promises: Promise<ProcessResult>[] = []
143
+ for (const processor of SolanaProcessorState.INSTANCE.getValues()) {
144
+ for (const handlerId of request.handlerIds) {
145
+ const handler = processor.blockHandlers[handlerId]
146
+ if (handler) {
147
+ promises.push(processor.handleBlock(block, handler))
148
+ }
149
+ }
150
+ }
151
+ return mergeProcessResults(await Promise.all(promises))
152
+ }
112
153
  }
113
154
 
114
155
  PluginManager.INSTANCE.register(new SolanaPlugin())
@@ -1,11 +1,13 @@
1
- import { ProcessResult } from '@sentio/protos'
1
+ import { Data_SolBlock, Data_SolInstruction, HandleInterval, ProcessResult } from '@sentio/protos'
2
2
  import { SolanaContext } from './solana-context.js'
3
3
  import { Instruction } from '@coral-xyz/anchor'
4
- import { SolanaBindOptions } from './solana-options.js'
4
+ import { SolanaBindOptions, SolanaFetchConfig } from './solana-options.js'
5
5
  import { ListStateStorage } from '@sentio/runtime'
6
- import { Labels } from '../core/index.js'
6
+ import { ALL_ADDRESS, Labels, PromiseOrVoid } from '../core/index.js'
7
7
  import { SolanaChainId } from '@sentio/chain'
8
8
  import { HandlerOptions } from '../core/handler-options.js'
9
+ import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
10
+ import { TransactionResponse, BlockResponse } from '@solana/web3.js'
9
11
 
10
12
  type IndexConfigure = {
11
13
  startSlot: bigint
@@ -20,7 +22,16 @@ export type SolanaInstructionHandler = (instruction: Instruction, ctx: SolanaCon
20
22
 
21
23
  export interface InstructionHandlerEntry {
22
24
  handler: SolanaInstructionHandler
23
- handlerOptions?: HandlerOptions<object, Instruction>
25
+ handlerOptions?: HandlerOptions<SolanaFetchConfig, Instruction>
26
+ }
27
+
28
+ export type SolanaBlockHandler<T> = (block: T, ctx: SolanaContext) => PromiseOrVoid
29
+
30
+ export interface SolanaBlockHandlerEntry<T> {
31
+ handler: SolanaBlockHandler<T>
32
+ timeIntervalInMinutes?: HandleInterval
33
+ slotInterval?: HandleInterval
34
+ handlerName: string
24
35
  }
25
36
 
26
37
  export class SolanaProcessorState extends ListStateStorage<SolanaBaseProcessor> {
@@ -29,6 +40,7 @@ export class SolanaProcessorState extends ListStateStorage<SolanaBaseProcessor>
29
40
 
30
41
  export class SolanaBaseProcessor {
31
42
  public instructionHandlerMap: Map<string, InstructionHandlerEntry> = new Map()
43
+ public blockHandlers: SolanaBlockHandlerEntry<any>[] = []
32
44
  address: string
33
45
  endpoint: string
34
46
  contractName: string
@@ -70,12 +82,49 @@ export class SolanaBaseProcessor {
70
82
  public onInstruction(
71
83
  instructionName: string,
72
84
  handler: SolanaInstructionHandler,
73
- handlerOptions?: HandlerOptions<object, Instruction>
85
+ handlerOptions?: HandlerOptions<SolanaFetchConfig, Instruction>
74
86
  ) {
75
87
  this.instructionHandlerMap.set(instructionName, { handler, handlerOptions })
76
88
  return this
77
89
  }
78
90
 
91
+ public onTimeInterval(
92
+ handler: SolanaBlockHandler<Data_SolBlock>,
93
+ timeIntervalInMinutes = 60,
94
+ backfillTimeIntervalInMinutes = 240
95
+ ): this {
96
+ return this.onInterval(
97
+ handler,
98
+ { recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes },
99
+ undefined
100
+ )
101
+ }
102
+
103
+ public onBlockInterval(
104
+ handler: SolanaBlockHandler<Data_SolBlock>,
105
+ blockInterval = 1000,
106
+ backfillBlockInterval = 4000
107
+ ): this {
108
+ return this.onInterval(handler, undefined, {
109
+ recentInterval: blockInterval,
110
+ backfillInterval: backfillBlockInterval
111
+ })
112
+ }
113
+
114
+ public onInterval<T>(
115
+ handler: SolanaBlockHandler<T>,
116
+ timeInterval: HandleInterval | undefined,
117
+ slotInterval: HandleInterval | undefined
118
+ ): this {
119
+ this.blockHandlers.push({
120
+ handler: handler,
121
+ timeIntervalInMinutes: timeInterval,
122
+ slotInterval: slotInterval,
123
+ handlerName: getHandlerName()
124
+ })
125
+ return this
126
+ }
127
+
79
128
  public getParsedInstruction(ins: string | { type: string; info: any }): Instruction | null {
80
129
  if (ins) {
81
130
  if ((ins as { type: string; info: any }).info) {
@@ -96,13 +145,35 @@ export class SolanaBaseProcessor {
96
145
  parsedInstruction: Instruction,
97
146
  accounts: string[],
98
147
  handlerEntry: InstructionHandlerEntry,
99
- slot: bigint
148
+ data: Data_SolInstruction
100
149
  ): Promise<ProcessResult> {
101
- const ctx = new SolanaContext(this.contractName, this.network, this.address, slot, this.baseLabels)
150
+ let transaction: TransactionResponse | undefined = undefined
151
+ if (data.rawTransaction) {
152
+ transaction = JSON.parse(data.rawTransaction) as TransactionResponse
153
+ }
154
+
155
+ const ctx = new SolanaContext(
156
+ this.contractName,
157
+ this.network,
158
+ this.address,
159
+ data.slot,
160
+ this.baseLabels,
161
+ transaction
162
+ )
102
163
  await handlerEntry.handler(parsedInstruction, ctx, accounts)
103
164
  return ctx.stopAndGetResult()
104
165
  }
105
166
 
167
+ public async handleBlock(
168
+ rawBlock: Data_SolBlock,
169
+ handlerEntry: SolanaBlockHandlerEntry<BlockResponse>
170
+ ): Promise<ProcessResult> {
171
+ const ctx = new SolanaContext(this.contractName, this.network, this.address, rawBlock.slot, this.baseLabels)
172
+ const block = JSON.parse(rawBlock.rawBlock) as BlockResponse
173
+ await handlerEntry.handler(block, ctx)
174
+ return ctx.stopAndGetResult()
175
+ }
176
+
106
177
  public async getPartitionKey(
107
178
  parsedInstruction: Instruction,
108
179
  handlerEntry: InstructionHandlerEntry
@@ -125,3 +196,14 @@ export class SolanaBaseProcessor {
125
196
  return this
126
197
  }
127
198
  }
199
+
200
+ export class SolanaGlobalProcessor extends SolanaBaseProcessor {
201
+ static bind(options: Omit<SolanaBindOptions, 'address'>): SolanaGlobalProcessor {
202
+ return new SolanaGlobalProcessor({ ...options, address: ALL_ADDRESS })
203
+ }
204
+
205
+ constructor(options: SolanaBindOptions) {
206
+ super(options)
207
+ return proxyProcessor(this)
208
+ }
209
+ }