@sentio/sdk 1.36.0-rc.2 → 1.36.0-rc.3
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/core/bind-options.d.ts +0 -4
- package/lib/core/bind-options.js +1 -5
- package/lib/core/bind-options.js.map +1 -1
- package/lib/core/context.d.ts +0 -7
- package/lib/core/context.js +1 -26
- package/lib/core/context.js.map +1 -1
- package/lib/core/index.d.ts +5 -3
- package/lib/core/index.js +7 -5
- package/lib/core/index.js.map +1 -1
- package/lib/core/solana-context.d.ts +12 -0
- package/lib/core/solana-context.js +34 -0
- package/lib/core/solana-context.js.map +1 -0
- package/lib/core/solana-options.d.ts +9 -0
- package/lib/core/solana-options.js +13 -0
- package/lib/core/solana-options.js.map +1 -0
- package/lib/core/solana-processor.d.ts +3 -2
- package/lib/core/solana-processor.js +5 -2
- package/lib/core/solana-processor.js.map +1 -1
- package/package.json +2 -11
- package/src/core/bind-options.ts +0 -5
- package/src/core/context.ts +0 -27
- package/src/core/index.ts +6 -4
- package/src/core/solana-context.ts +35 -0
- package/src/core/solana-options.ts +10 -0
- package/src/core/solana-processor.ts +6 -3
|
@@ -15,10 +15,6 @@ export declare class BindInternalOptions {
|
|
|
15
15
|
startBlock: Long;
|
|
16
16
|
endBlock?: Long;
|
|
17
17
|
}
|
|
18
|
-
export declare class SolanaBindOptions extends BindOptions {
|
|
19
|
-
network?: string;
|
|
20
|
-
processInnerInstruction?: boolean;
|
|
21
|
-
}
|
|
22
18
|
export declare class AccountBindOptions {
|
|
23
19
|
address: string;
|
|
24
20
|
network?: Networkish;
|
package/lib/core/bind-options.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AccountBindOptions = exports.
|
|
3
|
+
exports.AccountBindOptions = exports.BindInternalOptions = exports.getOptionsSignature = exports.BindOptions = void 0;
|
|
4
4
|
const providers_1 = require("@ethersproject/providers");
|
|
5
5
|
class BindOptions {
|
|
6
6
|
// Contract address
|
|
@@ -38,10 +38,6 @@ class BindInternalOptions {
|
|
|
38
38
|
endBlock;
|
|
39
39
|
}
|
|
40
40
|
exports.BindInternalOptions = BindInternalOptions;
|
|
41
|
-
class SolanaBindOptions extends BindOptions {
|
|
42
|
-
processInnerInstruction;
|
|
43
|
-
}
|
|
44
|
-
exports.SolanaBindOptions = SolanaBindOptions;
|
|
45
41
|
class AccountBindOptions {
|
|
46
42
|
address;
|
|
47
43
|
network;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind-options.js","sourceRoot":"","sources":["../../src/core/bind-options.ts"],"names":[],"mappings":";;;AAEA,wDAAqD;AAErD,MAAa,WAAW;IACtB,mBAAmB;IACnB,OAAO,CAAQ;IACf,6CAA6C;IAC7C,OAAO,GAAgB,CAAC,CAAA;IACxB,2CAA2C;IAC3C,IAAI,CAAS;IACb,UAAU,CAAgB;IAC1B,QAAQ,CAAgB;CACzB;AATD,kCASC;AAED,SAAgB,mBAAmB,CAAC,IAAiB;IACnD,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC1B,IAAI,IAAI,CAAC,OAAO,EAAE;QAChB,GAAG,CAAC,IAAI,CAAC,IAAA,sBAAU,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;KACtD;IACD,IAAI,IAAI,CAAC,IAAI,EAAE;QACb,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;KACpB;IACD,IAAI,IAAI,CAAC,UAAU,EAAE;QACnB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAA;KACrC;IACD,IAAI,IAAI,CAAC,QAAQ,EAAE;QACjB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC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;IACf,OAAO,CAAY;IACnB,IAAI,CAAQ;IACZ,UAAU,CAAM;IAChB,QAAQ,CAAO;CAChB;AAND,kDAMC;AAED,MAAa,kBAAkB;IAC7B,OAAO,CAAQ;IACf,OAAO,CAAa;IACpB,UAAU,CAAgB;CAC3B;AAJD,gDAIC","sourcesContent":["import { Networkish } from '@ethersproject/networks'\nimport Long from 'long'\nimport { getNetwork } from '@ethersproject/providers'\n\nexport class BindOptions {\n // Contract address\n address: string\n // Optional, if not set, then use eth mainnet\n network?: Networkish = 1\n // Optional, override default contract name\n name?: string\n startBlock?: Long | number\n endBlock?: Long | number\n}\n\nexport function getOptionsSignature(opts: BindOptions): string {\n const sig = [opts.address]\n if (opts.network) {\n sig.push(getNetwork(opts.network).chainId.toString())\n }\n if (opts.name) {\n sig.push(opts.name)\n }\n if (opts.startBlock) {\n sig.push(opts.startBlock.toString())\n }\n if (opts.endBlock) {\n sig.push(opts.endBlock.toString())\n }\n return sig.join('_')\n}\n\nexport class BindInternalOptions {\n address: string\n network: Networkish\n name: string\n startBlock: Long\n endBlock?: Long\n}\n\nexport class AccountBindOptions {\n address: string\n network?: Networkish\n startBlock?: Long | number\n}\n"]}
|
package/lib/core/context.d.ts
CHANGED
|
@@ -46,13 +46,6 @@ export declare class BoundContractView<TContract extends BaseContract, TContract
|
|
|
46
46
|
[name: string]: (...args: any[]) => EventFilter;
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
export declare class SolanaContext extends BaseContext {
|
|
50
|
-
address: string;
|
|
51
|
-
programName: string;
|
|
52
|
-
blockNumber: Long;
|
|
53
|
-
constructor(programName: string, address: string, slot: Long);
|
|
54
|
-
getMetaData(name: string, labels: Labels): RecordMetaData;
|
|
55
|
-
}
|
|
56
49
|
export declare class SuiContext extends BaseContext {
|
|
57
50
|
address: string;
|
|
58
51
|
moduleName: string;
|
package/lib/core/context.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SuiContext = exports.
|
|
6
|
+
exports.SuiContext = exports.BoundContractView = exports.ContractView = exports.ContractContext = exports.AccountContext = exports.EthContext = void 0;
|
|
7
7
|
const meter_1 = require("./meter");
|
|
8
8
|
const long_1 = __importDefault(require("long"));
|
|
9
9
|
const chain_1 = require("../utils/chain");
|
|
@@ -135,31 +135,6 @@ class BoundContractView {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
exports.BoundContractView = BoundContractView;
|
|
138
|
-
class SolanaContext extends base_context_1.BaseContext {
|
|
139
|
-
address;
|
|
140
|
-
programName;
|
|
141
|
-
blockNumber;
|
|
142
|
-
constructor(programName, address, slot) {
|
|
143
|
-
super();
|
|
144
|
-
this.programName = programName;
|
|
145
|
-
this.address = address;
|
|
146
|
-
this.blockNumber = slot;
|
|
147
|
-
}
|
|
148
|
-
getMetaData(name, labels) {
|
|
149
|
-
return {
|
|
150
|
-
address: this.address,
|
|
151
|
-
contractName: this.programName,
|
|
152
|
-
blockNumber: this.blockNumber,
|
|
153
|
-
transactionIndex: 0,
|
|
154
|
-
transactionHash: '',
|
|
155
|
-
logIndex: 0,
|
|
156
|
-
chainId: chain_1.CHAIN_IDS.SOLANA_MAINNET,
|
|
157
|
-
name: name,
|
|
158
|
-
labels: (0, meter_1.normalizeLabels)(labels),
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
exports.SolanaContext = SolanaContext;
|
|
163
138
|
class SuiContext extends base_context_1.BaseContext {
|
|
164
139
|
address;
|
|
165
140
|
moduleName;
|
package/lib/core/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/core/context.ts"],"names":[],"mappings":";;;;;;AAGA,mCAAyC;AACzC,gDAAuB;AAGvB,0CAA0C;AA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AI,CAAC,UAAU;YAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,gBAAgB,EAAE,CAAC;YACnB,eAAe,EAAE,EAAE;YACnB,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,iBAAS,CAAC,UAAU;YAC7B,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,IAAA,uBAAe,EAAC,MAAM,CAAC;SAChC,CAAA;IACH,CAAC;CACF;AAxBD,gCAwBC","sourcesContent":["import { RecordMetaData, ProcessResult } from '../gen'\nimport { BaseContract, EventFilter } from 'ethers'\nimport { Block, Log } from '@ethersproject/abstract-provider'\nimport { normalizeLabels } from './meter'\nimport Long from 'long'\nimport { Trace } from './trace'\nimport { Labels } from './metadata'\nimport { CHAIN_IDS } from '../utils/chain'\nimport { BaseContext } from './base-context'\n\nexport abstract class EthContext extends BaseContext {\n chainId: number\n address: string\n log?: Log\n block?: Block\n trace?: Trace\n blockNumber: Long\n transactionHash?: string\n\n protected constructor(chainId: number, address: string, block?: Block, log?: Log, trace?: Trace) {\n super()\n this.chainId = chainId\n this.log = log\n this.block = block\n this.trace = trace\n this.address = address\n if (log) {\n this.blockNumber = Long.fromNumber(log.blockNumber, true)\n this.transactionHash = log.transactionHash\n } else if (block) {\n this.blockNumber = Long.fromNumber(block.number, true)\n } else if (trace) {\n this.blockNumber = Long.fromNumber(trace.blockNumber, true)\n this.transactionHash = trace.transactionHash\n }\n }\n\n protected abstract getContractName(): string\n\n getMetaData(name: string, labels: Labels): RecordMetaData {\n if (this.log) {\n return {\n address: this.address,\n contractName: this.getContractName(),\n blockNumber: this.blockNumber,\n transactionIndex: this.log.transactionIndex,\n transactionHash: this.transactionHash || '',\n logIndex: this.log.logIndex,\n chainId: this.chainId.toString(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n if (this.block) {\n return {\n address: this.address,\n contractName: this.getContractName(),\n blockNumber: this.blockNumber,\n transactionIndex: -1,\n transactionHash: '',\n logIndex: -1,\n chainId: this.chainId.toString(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n if (this.trace) {\n return {\n address: this.address,\n contractName: this.getContractName(),\n blockNumber: this.blockNumber,\n transactionIndex: this.trace.transactionPosition,\n transactionHash: this.transactionHash || '',\n logIndex: -1,\n chainId: this.chainId.toString(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n throw new Error(\"Invaid ctx argument can't happen\")\n }\n}\n\nexport class AccountContext extends EthContext {\n constructor(chainId: number, address: string, block?: Block, log?: Log, trace?: Trace) {\n super(chainId, address, block, log, trace)\n }\n protected getContractName(): string {\n return 'account'\n }\n}\n\nexport class ContractContext<\n TContract extends BaseContract,\n TContractBoundView extends BoundContractView<TContract, ContractView<TContract>>\n> extends EthContext {\n contract: TContractBoundView\n contractName: string\n\n constructor(\n contractName: string,\n view: TContractBoundView,\n chainId: number,\n block?: Block,\n log?: Log,\n trace?: Trace\n ) {\n super(chainId, view.rawContract.address, block, log, trace)\n view.context = this\n this.contractName = contractName\n this.contract = view\n }\n\n protected getContractName(): string {\n return this.contractName\n }\n}\n\nexport class ContractView<TContract extends BaseContract> {\n filters: { [name: string]: (...args: Array<any>) => EventFilter }\n protected contract: TContract\n\n constructor(contract: TContract) {\n this.contract = contract\n this.filters = contract.filters\n }\n\n get rawContract() {\n return this.contract\n }\n\n get provider() {\n return this.contract.provider\n }\n}\n\nexport class BoundContractView<TContract extends BaseContract, TContractView extends ContractView<TContract>> {\n protected view: TContractView\n // context will be set right after context creation (in context's constructor)\n context: ContractContext<TContract, BoundContractView<TContract, TContractView>>\n\n constructor(view: TContractView) {\n this.view = view\n }\n\n get rawContract() {\n return this.view.rawContract\n }\n\n get provider() {\n return this.view.provider\n }\n\n get filters() {\n return this.view.filters\n }\n}\n\nexport class SolanaContext extends BaseContext {\n address: string\n programName: string\n blockNumber: Long\n\n constructor(programName: string, address: string, slot: Long) {\n super()\n this.programName = programName\n this.address = address\n this.blockNumber = slot\n }\n\n getMetaData(name: string, labels: Labels): RecordMetaData {\n return {\n address: this.address,\n contractName: this.programName,\n blockNumber: this.blockNumber,\n transactionIndex: 0,\n transactionHash: '', // TODO add\n logIndex: 0,\n chainId: CHAIN_IDS.SOLANA_MAINNET, // TODO set in context\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n}\n\nexport class SuiContext extends BaseContext {\n address: string\n moduleName: string\n blockNumber: Long\n\n constructor(address: string, slot: Long) {\n super()\n this.address = address\n this.blockNumber = slot\n }\n\n getMetaData(name: string, labels: Labels): RecordMetaData {\n return {\n address: this.address,\n contractName: this.moduleName,\n blockNumber: this.blockNumber,\n transactionIndex: 0,\n transactionHash: '', // TODO\n logIndex: 0,\n chainId: CHAIN_IDS.SUI_DEVNET, // TODO set in context\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/core/context.ts"],"names":[],"mappings":";;;;;;AAGA,mCAAyC;AACzC,gDAAuB;AAGvB,0CAA0C;AAC1C,iDAA4C;AAE5C,MAAsB,UAAW,SAAQ,0BAAW;IAClD,OAAO,CAAQ;IACf,OAAO,CAAQ;IACf,GAAG,CAAM;IACT,KAAK,CAAQ;IACb,KAAK,CAAQ;IACb,WAAW,CAAM;IACjB,eAAe,CAAS;IAExB,YAAsB,OAAe,EAAE,OAAe,EAAE,KAAa,EAAE,GAAS,EAAE,KAAa;QAC7F,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,GAAG,EAAE;YACP,IAAI,CAAC,WAAW,GAAG,cAAI,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;YACzD,IAAI,CAAC,eAAe,GAAG,GAAG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AAC;YACnB,eAAe,EAAE,EAAE;YACnB,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,iBAAS,CAAC,UAAU;YAC7B,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,IAAA,uBAAe,EAAC,MAAM,CAAC;SAChC,CAAA;IACH,CAAC;CACF;AAxBD,gCAwBC","sourcesContent":["import { RecordMetaData, ProcessResult } from '../gen'\nimport { BaseContract, EventFilter } from 'ethers'\nimport { Block, Log } from '@ethersproject/abstract-provider'\nimport { normalizeLabels } from './meter'\nimport Long from 'long'\nimport { Trace } from './trace'\nimport { Labels } from './metadata'\nimport { CHAIN_IDS } from '../utils/chain'\nimport { BaseContext } from './base-context'\n\nexport abstract class EthContext extends BaseContext {\n chainId: number\n address: string\n log?: Log\n block?: Block\n trace?: Trace\n blockNumber: Long\n transactionHash?: string\n\n protected constructor(chainId: number, address: string, block?: Block, log?: Log, trace?: Trace) {\n super()\n this.chainId = chainId\n this.log = log\n this.block = block\n this.trace = trace\n this.address = address\n if (log) {\n this.blockNumber = Long.fromNumber(log.blockNumber, true)\n this.transactionHash = log.transactionHash\n } else if (block) {\n this.blockNumber = Long.fromNumber(block.number, true)\n } else if (trace) {\n this.blockNumber = Long.fromNumber(trace.blockNumber, true)\n this.transactionHash = trace.transactionHash\n }\n }\n\n protected abstract getContractName(): string\n\n getMetaData(name: string, labels: Labels): RecordMetaData {\n if (this.log) {\n return {\n address: this.address,\n contractName: this.getContractName(),\n blockNumber: this.blockNumber,\n transactionIndex: this.log.transactionIndex,\n transactionHash: this.transactionHash || '',\n logIndex: this.log.logIndex,\n chainId: this.chainId.toString(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n if (this.block) {\n return {\n address: this.address,\n contractName: this.getContractName(),\n blockNumber: this.blockNumber,\n transactionIndex: -1,\n transactionHash: '',\n logIndex: -1,\n chainId: this.chainId.toString(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n if (this.trace) {\n return {\n address: this.address,\n contractName: this.getContractName(),\n blockNumber: this.blockNumber,\n transactionIndex: this.trace.transactionPosition,\n transactionHash: this.transactionHash || '',\n logIndex: -1,\n chainId: this.chainId.toString(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n throw new Error(\"Invaid ctx argument can't happen\")\n }\n}\n\nexport class AccountContext extends EthContext {\n constructor(chainId: number, address: string, block?: Block, log?: Log, trace?: Trace) {\n super(chainId, address, block, log, trace)\n }\n protected getContractName(): string {\n return 'account'\n }\n}\n\nexport class ContractContext<\n TContract extends BaseContract,\n TContractBoundView extends BoundContractView<TContract, ContractView<TContract>>\n> extends EthContext {\n contract: TContractBoundView\n contractName: string\n\n constructor(\n contractName: string,\n view: TContractBoundView,\n chainId: number,\n block?: Block,\n log?: Log,\n trace?: Trace\n ) {\n super(chainId, view.rawContract.address, block, log, trace)\n view.context = this\n this.contractName = contractName\n this.contract = view\n }\n\n protected getContractName(): string {\n return this.contractName\n }\n}\n\nexport class ContractView<TContract extends BaseContract> {\n filters: { [name: string]: (...args: Array<any>) => EventFilter }\n protected contract: TContract\n\n constructor(contract: TContract) {\n this.contract = contract\n this.filters = contract.filters\n }\n\n get rawContract() {\n return this.contract\n }\n\n get provider() {\n return this.contract.provider\n }\n}\n\nexport class BoundContractView<TContract extends BaseContract, TContractView extends ContractView<TContract>> {\n protected view: TContractView\n // context will be set right after context creation (in context's constructor)\n context: ContractContext<TContract, BoundContractView<TContract, TContractView>>\n\n constructor(view: TContractView) {\n this.view = view\n }\n\n get rawContract() {\n return this.view.rawContract\n }\n\n get provider() {\n return this.view.provider\n }\n\n get filters() {\n return this.view.filters\n }\n}\n\nexport class SuiContext extends BaseContext {\n address: string\n moduleName: string\n blockNumber: Long\n\n constructor(address: string, slot: Long) {\n super()\n this.address = address\n this.blockNumber = slot\n }\n\n getMetaData(name: string, labels: Labels): RecordMetaData {\n return {\n address: this.address,\n contractName: this.moduleName,\n blockNumber: this.blockNumber,\n transactionIndex: 0,\n transactionHash: '', // TODO\n logIndex: 0,\n chainId: CHAIN_IDS.SUI_DEVNET, // TODO set in context\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n}\n"]}
|
package/lib/core/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export { BigDecimal } from './big-decimal';
|
|
2
|
-
export { ContractContext, ContractView, BoundContractView
|
|
2
|
+
export { ContractContext, ContractView, BoundContractView } from './context';
|
|
3
3
|
export { CounterBinding, Meter, GaugeBinding, Counter, Gauge, MetricOptions } from './meter';
|
|
4
4
|
export { EventTracker, AccountEventTracker } from './event-tracker';
|
|
5
5
|
export { type Numberish, toBigInteger, toMetricValue } from './numberish';
|
|
6
|
-
export { BindOptions
|
|
6
|
+
export { BindOptions } from './bind-options';
|
|
7
7
|
export { BaseProcessor } from './base-processor';
|
|
8
8
|
export { GenericProcessor } from './generic-processor';
|
|
9
9
|
export { BaseProcessorTemplate } from './base-processor-template';
|
|
10
|
-
export { SolanaBaseProcessor } from './solana-processor';
|
|
11
10
|
export { SuiBaseProcessor, SuiBindOptions } from './sui-processor';
|
|
11
|
+
export { SolanaContext } from './solana-context';
|
|
12
|
+
export { SolanaBindOptions } from './solana-options';
|
|
13
|
+
export { SolanaBaseProcessor } from './solana-processor';
|
|
12
14
|
export type { TypedCallTrace, Trace } from './trace';
|
package/lib/core/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.SolanaBaseProcessor = exports.SolanaBindOptions = exports.SolanaContext = exports.SuiBindOptions = exports.SuiBaseProcessor = exports.BaseProcessorTemplate = exports.GenericProcessor = exports.BaseProcessor = exports.BindOptions = exports.toMetricValue = exports.toBigInteger = exports.AccountEventTracker = exports.EventTracker = exports.MetricOptions = exports.Gauge = exports.Counter = exports.GaugeBinding = exports.Meter = exports.CounterBinding = exports.BoundContractView = exports.ContractView = exports.ContractContext = exports.BigDecimal = void 0;
|
|
4
4
|
var big_decimal_1 = require("./big-decimal");
|
|
5
5
|
Object.defineProperty(exports, "BigDecimal", { enumerable: true, get: function () { return big_decimal_1.BigDecimal; } });
|
|
6
6
|
var context_1 = require("./context");
|
|
7
7
|
Object.defineProperty(exports, "ContractContext", { enumerable: true, get: function () { return context_1.ContractContext; } });
|
|
8
8
|
Object.defineProperty(exports, "ContractView", { enumerable: true, get: function () { return context_1.ContractView; } });
|
|
9
9
|
Object.defineProperty(exports, "BoundContractView", { enumerable: true, get: function () { return context_1.BoundContractView; } });
|
|
10
|
-
Object.defineProperty(exports, "SolanaContext", { enumerable: true, get: function () { return context_1.SolanaContext; } });
|
|
11
10
|
var meter_1 = require("./meter");
|
|
12
11
|
Object.defineProperty(exports, "CounterBinding", { enumerable: true, get: function () { return meter_1.CounterBinding; } });
|
|
13
12
|
Object.defineProperty(exports, "Meter", { enumerable: true, get: function () { return meter_1.Meter; } });
|
|
@@ -23,16 +22,19 @@ Object.defineProperty(exports, "toBigInteger", { enumerable: true, get: function
|
|
|
23
22
|
Object.defineProperty(exports, "toMetricValue", { enumerable: true, get: function () { return numberish_1.toMetricValue; } });
|
|
24
23
|
var bind_options_1 = require("./bind-options");
|
|
25
24
|
Object.defineProperty(exports, "BindOptions", { enumerable: true, get: function () { return bind_options_1.BindOptions; } });
|
|
26
|
-
Object.defineProperty(exports, "SolanaBindOptions", { enumerable: true, get: function () { return bind_options_1.SolanaBindOptions; } });
|
|
27
25
|
var base_processor_1 = require("./base-processor");
|
|
28
26
|
Object.defineProperty(exports, "BaseProcessor", { enumerable: true, get: function () { return base_processor_1.BaseProcessor; } });
|
|
29
27
|
var generic_processor_1 = require("./generic-processor");
|
|
30
28
|
Object.defineProperty(exports, "GenericProcessor", { enumerable: true, get: function () { return generic_processor_1.GenericProcessor; } });
|
|
31
29
|
var base_processor_template_1 = require("./base-processor-template");
|
|
32
30
|
Object.defineProperty(exports, "BaseProcessorTemplate", { enumerable: true, get: function () { return base_processor_template_1.BaseProcessorTemplate; } });
|
|
33
|
-
var solana_processor_1 = require("./solana-processor");
|
|
34
|
-
Object.defineProperty(exports, "SolanaBaseProcessor", { enumerable: true, get: function () { return solana_processor_1.SolanaBaseProcessor; } });
|
|
35
31
|
var sui_processor_1 = require("./sui-processor");
|
|
36
32
|
Object.defineProperty(exports, "SuiBaseProcessor", { enumerable: true, get: function () { return sui_processor_1.SuiBaseProcessor; } });
|
|
37
33
|
Object.defineProperty(exports, "SuiBindOptions", { enumerable: true, get: function () { return sui_processor_1.SuiBindOptions; } });
|
|
34
|
+
var solana_context_1 = require("./solana-context");
|
|
35
|
+
Object.defineProperty(exports, "SolanaContext", { enumerable: true, get: function () { return solana_context_1.SolanaContext; } });
|
|
36
|
+
var solana_options_1 = require("./solana-options");
|
|
37
|
+
Object.defineProperty(exports, "SolanaBindOptions", { enumerable: true, get: function () { return solana_options_1.SolanaBindOptions; } });
|
|
38
|
+
var solana_processor_1 = require("./solana-processor");
|
|
39
|
+
Object.defineProperty(exports, "SolanaBaseProcessor", { enumerable: true, get: function () { return solana_processor_1.SolanaBaseProcessor; } });
|
|
38
40
|
//# sourceMappingURL=index.js.map
|
package/lib/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAAjC,yGAAA,UAAU,OAAA;AACnB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAAjC,yGAAA,UAAU,OAAA;AACnB,qCAA4E;AAAnE,0GAAA,eAAe,OAAA;AAAE,uGAAA,YAAY,OAAA;AAAE,4GAAA,iBAAiB,OAAA;AACzD,iCAA4F;AAAnF,uGAAA,cAAc,OAAA;AAAE,8FAAA,KAAK,OAAA;AAAE,qGAAA,YAAY,OAAA;AAAE,gGAAA,OAAO,OAAA;AAAE,8FAAA,KAAK,OAAA;AAAE,sGAAA,aAAa,OAAA;AAC3E,iDAAmE;AAA1D,6GAAA,YAAY,OAAA;AAAE,oHAAA,mBAAmB,OAAA;AAC1C,yCAAyE;AAAhD,yGAAA,YAAY,OAAA;AAAE,0GAAA,aAAa,OAAA;AAEpD,+CAA4C;AAAnC,2GAAA,WAAW,OAAA;AAEpB,mDAAgD;AAAvC,+GAAA,aAAa,OAAA;AACtB,yDAAsD;AAA7C,qHAAA,gBAAgB,OAAA;AACzB,qEAAiE;AAAxD,gIAAA,qBAAqB,OAAA;AAC9B,iDAAkE;AAAzD,iHAAA,gBAAgB,OAAA;AAAE,+GAAA,cAAc,OAAA;AAEzC,mDAAgD;AAAvC,+GAAA,aAAa,OAAA;AACtB,mDAAoD;AAA3C,mHAAA,iBAAiB,OAAA;AAC1B,uDAAwD;AAA/C,uHAAA,mBAAmB,OAAA","sourcesContent":["export { BigDecimal } from './big-decimal'\nexport { ContractContext, ContractView, BoundContractView } from './context'\nexport { CounterBinding, Meter, GaugeBinding, Counter, Gauge, MetricOptions } from './meter'\nexport { EventTracker, AccountEventTracker } from './event-tracker'\nexport { type Numberish, toBigInteger, toMetricValue } from './numberish'\n\nexport { BindOptions } from './bind-options'\n\nexport { BaseProcessor } from './base-processor'\nexport { GenericProcessor } from './generic-processor'\nexport { BaseProcessorTemplate } from './base-processor-template'\nexport { SuiBaseProcessor, SuiBindOptions } from './sui-processor'\n\nexport { SolanaContext } from './solana-context'\nexport { SolanaBindOptions } from './solana-options'\nexport { SolanaBaseProcessor } from './solana-processor'\n\nexport type { TypedCallTrace, Trace } from './trace'\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseContext } from './base-context';
|
|
2
|
+
import Long from 'long';
|
|
3
|
+
import { Labels } from './metadata';
|
|
4
|
+
import { RecordMetaData } from '@sentio/sdk';
|
|
5
|
+
export declare class SolanaContext extends BaseContext {
|
|
6
|
+
network: string;
|
|
7
|
+
address: string;
|
|
8
|
+
programName: string;
|
|
9
|
+
blockNumber: Long;
|
|
10
|
+
constructor(programName: string, network: string, address: string, slot: Long);
|
|
11
|
+
getMetaData(name: string, labels: Labels): RecordMetaData;
|
|
12
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SolanaContext = void 0;
|
|
4
|
+
const base_context_1 = require("./base-context");
|
|
5
|
+
const chain_1 = require("../utils/chain");
|
|
6
|
+
const meter_1 = require("./meter");
|
|
7
|
+
class SolanaContext extends base_context_1.BaseContext {
|
|
8
|
+
network;
|
|
9
|
+
address;
|
|
10
|
+
programName;
|
|
11
|
+
blockNumber;
|
|
12
|
+
constructor(programName, network, address, slot) {
|
|
13
|
+
super();
|
|
14
|
+
this.network = network || chain_1.CHAIN_IDS.SOLANA_MAINNET;
|
|
15
|
+
this.programName = programName;
|
|
16
|
+
this.address = address;
|
|
17
|
+
this.blockNumber = slot;
|
|
18
|
+
}
|
|
19
|
+
getMetaData(name, labels) {
|
|
20
|
+
return {
|
|
21
|
+
address: this.address,
|
|
22
|
+
contractName: this.programName,
|
|
23
|
+
blockNumber: this.blockNumber,
|
|
24
|
+
transactionIndex: 0,
|
|
25
|
+
transactionHash: '',
|
|
26
|
+
logIndex: 0,
|
|
27
|
+
chainId: this.network,
|
|
28
|
+
name: name,
|
|
29
|
+
labels: (0, meter_1.normalizeLabels)(labels),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.SolanaContext = SolanaContext;
|
|
34
|
+
//# sourceMappingURL=solana-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solana-context.js","sourceRoot":"","sources":["../../src/core/solana-context.ts"],"names":[],"mappings":";;;AAAA,iDAA4C;AAI5C,0CAA0C;AAC1C,mCAAyC;AAEzC,MAAa,aAAc,SAAQ,0BAAW;IAC5C,OAAO,CAAQ;IACf,OAAO,CAAQ;IACf,WAAW,CAAQ;IACnB,WAAW,CAAM;IAEjB,YAAY,WAAmB,EAAE,OAAe,EAAE,OAAe,EAAE,IAAU;QAC3E,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,iBAAS,CAAC,cAAc,CAAA;QAClD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;IACzB,CAAC;IAED,WAAW,CAAC,IAAY,EAAE,MAAc;QACtC,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;YACnB,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,IAAA,uBAAe,EAAC,MAAM,CAAC;SAChC,CAAA;IACH,CAAC;CACF;AA3BD,sCA2BC","sourcesContent":["import { BaseContext } from './base-context'\nimport Long from 'long'\nimport { Labels } from './metadata'\nimport { RecordMetaData } from '@sentio/sdk'\nimport { CHAIN_IDS } from '../utils/chain'\nimport { normalizeLabels } from './meter'\n\nexport class SolanaContext extends BaseContext {\n network: string\n address: string\n programName: string\n blockNumber: Long\n\n constructor(programName: string, network: string, address: string, slot: Long) {\n super()\n this.network = network || CHAIN_IDS.SOLANA_MAINNET\n this.programName = programName\n this.address = address\n this.blockNumber = slot\n }\n\n getMetaData(name: string, labels: Labels): RecordMetaData {\n return {\n address: this.address,\n contractName: this.programName,\n blockNumber: this.blockNumber,\n transactionIndex: 0,\n transactionHash: '', // TODO add\n logIndex: 0,\n chainId: this.network,\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SolanaBindOptions = void 0;
|
|
4
|
+
class SolanaBindOptions {
|
|
5
|
+
address;
|
|
6
|
+
network;
|
|
7
|
+
name;
|
|
8
|
+
startBlock;
|
|
9
|
+
endBlock;
|
|
10
|
+
processInnerInstruction;
|
|
11
|
+
}
|
|
12
|
+
exports.SolanaBindOptions = SolanaBindOptions;
|
|
13
|
+
//# sourceMappingURL=solana-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solana-options.js","sourceRoot":"","sources":["../../src/core/solana-options.ts"],"names":[],"mappings":";;;AAEA,MAAa,iBAAiB;IAC5B,OAAO,CAAQ;IACf,OAAO,CAAS;IAChB,IAAI,CAAS;IACb,UAAU,CAAgB;IAC1B,QAAQ,CAAgB;IACxB,uBAAuB,CAAU;CAClC;AAPD,8CAOC","sourcesContent":["import Long from 'long'\n\nexport class SolanaBindOptions {\n address: string\n network?: string\n name?: string\n startBlock?: Long | number\n endBlock?: Long | number\n processInnerInstruction?: boolean\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ProcessResult } from '../gen';
|
|
2
|
-
import { SolanaContext } from './context';
|
|
2
|
+
import { SolanaContext } from './solana-context';
|
|
3
3
|
import Long from 'long';
|
|
4
4
|
import { Instruction } from '@project-serum/anchor';
|
|
5
|
-
import { SolanaBindOptions } from './
|
|
5
|
+
import { SolanaBindOptions } from './solana-options';
|
|
6
6
|
import { ListStateStorage } from '../state/state-storage';
|
|
7
7
|
declare type IndexConfigure = {
|
|
8
8
|
startSlot: Long;
|
|
@@ -17,6 +17,7 @@ export declare class SolanaBaseProcessor {
|
|
|
17
17
|
address: string;
|
|
18
18
|
endpoint: string;
|
|
19
19
|
contractName: string;
|
|
20
|
+
network: string;
|
|
20
21
|
processInnerInstruction: boolean;
|
|
21
22
|
config: IndexConfigure;
|
|
22
23
|
decodeInstruction: (rawInstruction: string) => Instruction | null;
|
|
@@ -4,9 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.SolanaBaseProcessor = exports.SolanaProcessorState = void 0;
|
|
7
|
-
const
|
|
7
|
+
const solana_context_1 = require("./solana-context");
|
|
8
8
|
const long_1 = __importDefault(require("long"));
|
|
9
9
|
const state_storage_1 = require("../state/state-storage");
|
|
10
|
+
const chain_1 = require("../utils/chain");
|
|
10
11
|
class SolanaProcessorState extends state_storage_1.ListStateStorage {
|
|
11
12
|
static INSTANCE = new SolanaProcessorState();
|
|
12
13
|
}
|
|
@@ -16,6 +17,7 @@ class SolanaBaseProcessor {
|
|
|
16
17
|
address;
|
|
17
18
|
endpoint;
|
|
18
19
|
contractName;
|
|
20
|
+
network;
|
|
19
21
|
processInnerInstruction;
|
|
20
22
|
config = { startSlot: new long_1.default(0) };
|
|
21
23
|
decodeInstruction;
|
|
@@ -30,6 +32,7 @@ class SolanaBaseProcessor {
|
|
|
30
32
|
this.address = options.address;
|
|
31
33
|
this.contractName = options.name || '';
|
|
32
34
|
this.processInnerInstruction = options.processInnerInstruction || false;
|
|
35
|
+
this.network = options.network || chain_1.CHAIN_IDS.SOLANA_MAINNET;
|
|
33
36
|
if (options.startBlock) {
|
|
34
37
|
this.startSlot(options.startBlock);
|
|
35
38
|
}
|
|
@@ -65,7 +68,7 @@ class SolanaBaseProcessor {
|
|
|
65
68
|
}
|
|
66
69
|
// TODO this should be a async function
|
|
67
70
|
handleInstruction(parsedInstruction, accounts, handler, slot) {
|
|
68
|
-
const ctx = new
|
|
71
|
+
const ctx = new solana_context_1.SolanaContext(this.contractName, this.network, this.address, slot);
|
|
69
72
|
handler(parsedInstruction, ctx, accounts);
|
|
70
73
|
return ctx.getProcessResult();
|
|
71
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solana-processor.js","sourceRoot":"","sources":["../../src/core/solana-processor.ts"],"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zC,OAAO,GAAG,CAAC,gBAAgB,EAAE,CAAA;IAC/B,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAC,OAAO,KAAK,IAAI,CAAA;IAC9B,CAAC;IAEM,SAAS,CAAC,SAAwB;QACvC,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;YACjC,SAAS,GAAG,cAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;SACvC;QACD,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,SAAS,CAAA;QACjC,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,QAAQ,CAAC,QAAuB;QACrC,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAChC,QAAQ,GAAG,cAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;SACrC;QACD,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAA;QAC9B,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AA9FD,kDA8FC","sourcesContent":["import { ProcessResult } from '../gen'\nimport { SolanaContext } from './solana-context'\nimport Long from 'long'\nimport { Instruction } from '@project-serum/anchor'\nimport { SolanaBindOptions } from './solana-options'\nimport { ListStateStorage } from '../state/state-storage'\nimport { CHAIN_IDS } from '../utils/chain'\n\ntype IndexConfigure = {\n startSlot: Long\n endSlot?: Long\n}\n\nexport type SolanaInstructionHandler = (instruction: Instruction, ctx: SolanaContext, accounts?: string[]) => void\n\nexport class SolanaProcessorState extends ListStateStorage<SolanaBaseProcessor> {\n static INSTANCE: SolanaProcessorState = new SolanaProcessorState()\n}\n\nexport class SolanaBaseProcessor {\n public instructionHandlerMap: Map<string, SolanaInstructionHandler> = new Map()\n address: string\n endpoint: string\n contractName: string\n network: string\n processInnerInstruction: boolean\n config: IndexConfigure = { startSlot: new Long(0) }\n decodeInstruction: (rawInstruction: string) => Instruction | null\n fromParsedInstruction: (instruction: { type: string; info: any }) => Instruction | null\n\n constructor(options: SolanaBindOptions) {\n if (options) {\n this.bind(options)\n }\n SolanaProcessorState.INSTANCE.addValue(this)\n }\n\n bind(options: SolanaBindOptions) {\n this.address = options.address\n this.contractName = options.name || ''\n this.processInnerInstruction = options.processInnerInstruction || false\n this.network = options.network || CHAIN_IDS.SOLANA_MAINNET\n if (options.startBlock) {\n this.startSlot(options.startBlock)\n }\n if (options.endBlock) {\n this.endBlock(options.endBlock)\n }\n this.endpoint = options.network || 'https://api.mainnet-beta.solana.com'\n }\n\n innerInstruction(flag: boolean) {\n this.processInnerInstruction = flag\n return this\n }\n\n public onInstruction(instructionName: string, handler: SolanaInstructionHandler) {\n if (!this.isBind()) {\n throw new Error(\"Processor doesn't bind to an address\")\n }\n\n this.instructionHandlerMap.set(instructionName, handler)\n\n return this\n }\n\n public getParsedInstruction(ins: string | { type: string; info: any }): Instruction | null {\n if (ins) {\n if ((ins as { type: string; info: any }).info) {\n return this.fromParsedInstruction ? this.fromParsedInstruction(ins as { type: string; info: any }) : null\n }\n if (this.decodeInstruction != null) {\n return this.decodeInstruction(ins as string)\n }\n }\n return null\n }\n\n public getInstructionHandler(parsedInstruction: Instruction): SolanaInstructionHandler | undefined {\n return this.instructionHandlerMap.get(parsedInstruction.name)\n }\n\n // TODO this should be a async function\n public handleInstruction(\n parsedInstruction: Instruction,\n accounts: string[],\n handler: SolanaInstructionHandler,\n slot: Long\n ): ProcessResult {\n const ctx = new SolanaContext(this.contractName, this.network, this.address, slot)\n handler(parsedInstruction, ctx, accounts)\n return ctx.getProcessResult()\n }\n\n public isBind() {\n return this.address !== null\n }\n\n public startSlot(startSlot: Long | number) {\n if (typeof startSlot === 'number') {\n startSlot = Long.fromNumber(startSlot)\n }\n this.config.startSlot = startSlot\n return this\n }\n\n public endBlock(endBlock: Long | number) {\n if (typeof endBlock === 'number') {\n endBlock = Long.fromNumber(endBlock)\n }\n this.config.endSlot = endBlock\n return this\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentio/sdk",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "1.36.0-rc.
|
|
4
|
+
"version": "1.36.0-rc.3",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"compile_target": "yarn tsc -b src/target-ethers-sentio/tsconfig.json",
|
|
7
7
|
"compile": "tsc -p . && cp src/utils/*.csv lib/utils",
|
|
@@ -57,21 +57,12 @@
|
|
|
57
57
|
"@types/fs-extra": "^9.0.13",
|
|
58
58
|
"@types/google-protobuf": "^3.15.6",
|
|
59
59
|
"@types/js-yaml": "^4.0.5",
|
|
60
|
-
"@types/mkdirp": "^1.0.2",
|
|
61
60
|
"@types/node": "^18.0.4",
|
|
62
61
|
"chai": "^4.3.6",
|
|
63
|
-
"clean-publish": "^4.0.1",
|
|
64
|
-
"conventional-changelog-conventionalcommits": "^5.0.0",
|
|
65
|
-
"eslint": "^8.27.0",
|
|
66
|
-
"eslint-import-resolver-typescript": "^3.5.2",
|
|
67
|
-
"eslint-plugin-import": "^2.26.0",
|
|
68
62
|
"jest": "^29.0.3",
|
|
69
|
-
"semantic-release": "^19.0.5",
|
|
70
63
|
"ts-jest": "^29.0.3",
|
|
71
64
|
"ts-node": "^10.9.1",
|
|
72
|
-
"
|
|
73
|
-
"typedoc": "^0.23.15",
|
|
74
|
-
"typescript": "^4.8.0"
|
|
65
|
+
"typedoc": "^0.23.15"
|
|
75
66
|
},
|
|
76
67
|
"bin": {
|
|
77
68
|
"processor-runner": "./lib/processor-runner.js"
|
package/src/core/bind-options.ts
CHANGED
|
@@ -38,11 +38,6 @@ export class BindInternalOptions {
|
|
|
38
38
|
endBlock?: Long
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
export class SolanaBindOptions extends BindOptions {
|
|
42
|
-
declare network?: string
|
|
43
|
-
processInnerInstruction?: boolean
|
|
44
|
-
}
|
|
45
|
-
|
|
46
41
|
export class AccountBindOptions {
|
|
47
42
|
address: string
|
|
48
43
|
network?: Networkish
|
package/src/core/context.ts
CHANGED
|
@@ -156,33 +156,6 @@ export class BoundContractView<TContract extends BaseContract, TContractView ext
|
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
export class SolanaContext extends BaseContext {
|
|
160
|
-
address: string
|
|
161
|
-
programName: string
|
|
162
|
-
blockNumber: Long
|
|
163
|
-
|
|
164
|
-
constructor(programName: string, address: string, slot: Long) {
|
|
165
|
-
super()
|
|
166
|
-
this.programName = programName
|
|
167
|
-
this.address = address
|
|
168
|
-
this.blockNumber = slot
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
getMetaData(name: string, labels: Labels): RecordMetaData {
|
|
172
|
-
return {
|
|
173
|
-
address: this.address,
|
|
174
|
-
contractName: this.programName,
|
|
175
|
-
blockNumber: this.blockNumber,
|
|
176
|
-
transactionIndex: 0,
|
|
177
|
-
transactionHash: '', // TODO add
|
|
178
|
-
logIndex: 0,
|
|
179
|
-
chainId: CHAIN_IDS.SOLANA_MAINNET, // TODO set in context
|
|
180
|
-
name: name,
|
|
181
|
-
labels: normalizeLabels(labels),
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
159
|
export class SuiContext extends BaseContext {
|
|
187
160
|
address: string
|
|
188
161
|
moduleName: string
|
package/src/core/index.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
export { BigDecimal } from './big-decimal'
|
|
2
|
-
export { ContractContext, ContractView, BoundContractView
|
|
2
|
+
export { ContractContext, ContractView, BoundContractView } from './context'
|
|
3
3
|
export { CounterBinding, Meter, GaugeBinding, Counter, Gauge, MetricOptions } from './meter'
|
|
4
4
|
export { EventTracker, AccountEventTracker } from './event-tracker'
|
|
5
5
|
export { type Numberish, toBigInteger, toMetricValue } from './numberish'
|
|
6
6
|
|
|
7
|
-
export { BindOptions
|
|
7
|
+
export { BindOptions } from './bind-options'
|
|
8
8
|
|
|
9
9
|
export { BaseProcessor } from './base-processor'
|
|
10
10
|
export { GenericProcessor } from './generic-processor'
|
|
11
11
|
export { BaseProcessorTemplate } from './base-processor-template'
|
|
12
|
-
export { SolanaBaseProcessor } from './solana-processor'
|
|
13
12
|
export { SuiBaseProcessor, SuiBindOptions } from './sui-processor'
|
|
14
|
-
|
|
13
|
+
|
|
14
|
+
export { SolanaContext } from './solana-context'
|
|
15
|
+
export { SolanaBindOptions } from './solana-options'
|
|
16
|
+
export { SolanaBaseProcessor } from './solana-processor'
|
|
15
17
|
|
|
16
18
|
export type { TypedCallTrace, Trace } from './trace'
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BaseContext } from './base-context'
|
|
2
|
+
import Long from 'long'
|
|
3
|
+
import { Labels } from './metadata'
|
|
4
|
+
import { RecordMetaData } from '@sentio/sdk'
|
|
5
|
+
import { CHAIN_IDS } from '../utils/chain'
|
|
6
|
+
import { normalizeLabels } from './meter'
|
|
7
|
+
|
|
8
|
+
export class SolanaContext extends BaseContext {
|
|
9
|
+
network: string
|
|
10
|
+
address: string
|
|
11
|
+
programName: string
|
|
12
|
+
blockNumber: Long
|
|
13
|
+
|
|
14
|
+
constructor(programName: string, network: string, address: string, slot: Long) {
|
|
15
|
+
super()
|
|
16
|
+
this.network = network || CHAIN_IDS.SOLANA_MAINNET
|
|
17
|
+
this.programName = programName
|
|
18
|
+
this.address = address
|
|
19
|
+
this.blockNumber = slot
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getMetaData(name: string, labels: Labels): RecordMetaData {
|
|
23
|
+
return {
|
|
24
|
+
address: this.address,
|
|
25
|
+
contractName: this.programName,
|
|
26
|
+
blockNumber: this.blockNumber,
|
|
27
|
+
transactionIndex: 0,
|
|
28
|
+
transactionHash: '', // TODO add
|
|
29
|
+
logIndex: 0,
|
|
30
|
+
chainId: this.network,
|
|
31
|
+
name: name,
|
|
32
|
+
labels: normalizeLabels(labels),
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ProcessResult } from '../gen'
|
|
2
|
-
import { SolanaContext } from './context'
|
|
2
|
+
import { SolanaContext } from './solana-context'
|
|
3
3
|
import Long from 'long'
|
|
4
4
|
import { Instruction } from '@project-serum/anchor'
|
|
5
|
-
import { SolanaBindOptions } from './
|
|
5
|
+
import { SolanaBindOptions } from './solana-options'
|
|
6
6
|
import { ListStateStorage } from '../state/state-storage'
|
|
7
|
+
import { CHAIN_IDS } from '../utils/chain'
|
|
7
8
|
|
|
8
9
|
type IndexConfigure = {
|
|
9
10
|
startSlot: Long
|
|
@@ -21,6 +22,7 @@ export class SolanaBaseProcessor {
|
|
|
21
22
|
address: string
|
|
22
23
|
endpoint: string
|
|
23
24
|
contractName: string
|
|
25
|
+
network: string
|
|
24
26
|
processInnerInstruction: boolean
|
|
25
27
|
config: IndexConfigure = { startSlot: new Long(0) }
|
|
26
28
|
decodeInstruction: (rawInstruction: string) => Instruction | null
|
|
@@ -37,6 +39,7 @@ export class SolanaBaseProcessor {
|
|
|
37
39
|
this.address = options.address
|
|
38
40
|
this.contractName = options.name || ''
|
|
39
41
|
this.processInnerInstruction = options.processInnerInstruction || false
|
|
42
|
+
this.network = options.network || CHAIN_IDS.SOLANA_MAINNET
|
|
40
43
|
if (options.startBlock) {
|
|
41
44
|
this.startSlot(options.startBlock)
|
|
42
45
|
}
|
|
@@ -84,7 +87,7 @@ export class SolanaBaseProcessor {
|
|
|
84
87
|
handler: SolanaInstructionHandler,
|
|
85
88
|
slot: Long
|
|
86
89
|
): ProcessResult {
|
|
87
|
-
const ctx = new SolanaContext(this.contractName, this.address, slot)
|
|
90
|
+
const ctx = new SolanaContext(this.contractName, this.network, this.address, slot)
|
|
88
91
|
handler(parsedInstruction, ctx, accounts)
|
|
89
92
|
return ctx.getProcessResult()
|
|
90
93
|
}
|