@sentio/sdk 1.36.0-rc.1 → 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/aptos/network.d.ts +1 -1
- package/lib/aptos/network.js +7 -7
- package/lib/aptos/network.js.map +1 -1
- package/lib/aptos-codegen/codegen.js +1 -1
- package/lib/aptos-codegen/codegen.js.map +1 -1
- 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 +2 -27
- 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/lib/service.js +2 -2
- package/lib/service.js.map +1 -1
- package/lib/utils/chain.d.ts +86 -6
- package/lib/utils/chain.js +95 -91
- package/lib/utils/chain.js.map +1 -1
- package/package.json +2 -11
- package/src/aptos/network.ts +6 -6
- package/src/aptos-codegen/codegen.ts +2 -2
- package/src/core/bind-options.ts +0 -5
- package/src/core/context.ts +2 -29
- 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
- package/src/service.ts +3 -3
- package/src/utils/chain.ts +94 -91
package/lib/aptos/network.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare enum AptosNetwork {
|
|
|
4
4
|
TEST_NET = 2
|
|
5
5
|
}
|
|
6
6
|
export declare function getChainId(network: AptosNetwork): string;
|
|
7
|
-
export declare function
|
|
7
|
+
export declare function getAptosChainName(network: AptosNetwork): string;
|
|
8
8
|
export declare function getRpcEndpoint(network: AptosNetwork): string;
|
|
9
9
|
export declare function getRpcClient(network: AptosNetwork): AptosClient;
|
|
10
10
|
export declare class AptosBindOptions {
|
package/lib/aptos/network.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AptosBindOptions = exports.getRpcClient = exports.getRpcEndpoint = exports.
|
|
3
|
+
exports.AptosBindOptions = exports.getRpcClient = exports.getRpcEndpoint = exports.getAptosChainName = exports.getChainId = exports.AptosNetwork = void 0;
|
|
4
4
|
const chain_1 = require("../utils/chain");
|
|
5
5
|
const aptos_sdk_1 = require("aptos-sdk");
|
|
6
6
|
var AptosNetwork;
|
|
@@ -12,19 +12,19 @@ var AptosNetwork;
|
|
|
12
12
|
function getChainId(network) {
|
|
13
13
|
switch (network) {
|
|
14
14
|
case AptosNetwork.TEST_NET:
|
|
15
|
-
return chain_1.
|
|
15
|
+
return chain_1.CHAIN_IDS.APTOS_TESTNET;
|
|
16
16
|
}
|
|
17
|
-
return chain_1.
|
|
17
|
+
return chain_1.CHAIN_IDS.APTOS_MAINNET;
|
|
18
18
|
}
|
|
19
19
|
exports.getChainId = getChainId;
|
|
20
|
-
function
|
|
20
|
+
function getAptosChainName(network) {
|
|
21
21
|
switch (network) {
|
|
22
22
|
case AptosNetwork.TEST_NET:
|
|
23
|
-
return chain_1.
|
|
23
|
+
return (0, chain_1.getChainName)(chain_1.CHAIN_IDS.APTOS_TESTNET);
|
|
24
24
|
}
|
|
25
|
-
return chain_1.
|
|
25
|
+
return (0, chain_1.getChainName)(chain_1.CHAIN_IDS.APTOS_MAINNET);
|
|
26
26
|
}
|
|
27
|
-
exports.
|
|
27
|
+
exports.getAptosChainName = getAptosChainName;
|
|
28
28
|
function getRpcEndpoint(network) {
|
|
29
29
|
switch (network) {
|
|
30
30
|
case AptosNetwork.TEST_NET:
|
package/lib/aptos/network.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/aptos/network.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/aptos/network.ts"],"names":[],"mappings":";;;AAAA,0CAAmE;AACnE,yCAAuC;AAEvC,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,uDAAY,CAAA;IACZ,uDAAY,CAAA;IACZ,WAAW;AACb,CAAC,EAJW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAIvB;AAED,SAAgB,UAAU,CAAC,OAAqB;IAC9C,QAAQ,OAAO,EAAE;QACf,KAAK,YAAY,CAAC,QAAQ;YACxB,OAAO,iBAAS,CAAC,aAAa,CAAA;KACjC;IACD,OAAO,iBAAS,CAAC,aAAa,CAAA;AAChC,CAAC;AAND,gCAMC;AAED,SAAgB,iBAAiB,CAAC,OAAqB;IACrD,QAAQ,OAAO,EAAE;QACf,KAAK,YAAY,CAAC,QAAQ;YACxB,OAAO,IAAA,oBAAY,EAAC,iBAAS,CAAC,aAAa,CAAC,CAAA;KAC/C;IACD,OAAO,IAAA,oBAAY,EAAC,iBAAS,CAAC,aAAa,CAAC,CAAA;AAC9C,CAAC;AAND,8CAMC;AAED,SAAgB,cAAc,CAAC,OAAqB;IAClD,QAAQ,OAAO,EAAE;QACf,KAAK,YAAY,CAAC,QAAQ;YACxB,OAAO,gCAAgC,CAAA;KAC1C;IACD,OAAO,gCAAgC,CAAA;AACzC,CAAC;AAND,wCAMC;AAED,SAAgB,YAAY,CAAC,OAAqB;IAChD,OAAO,IAAI,uBAAW,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAA;AACjD,CAAC;AAFD,oCAEC;AAED,MAAa,gBAAgB;IAC3B,OAAO,CAAQ;IACf,OAAO,GAAkB,YAAY,CAAC,QAAQ,CAAA;IAC9C,YAAY,CAAkB;CAC/B;AAJD,4CAIC","sourcesContent":["import { CHAIN_IDS, CHAIN_MAP, getChainName } from '../utils/chain'\nimport { AptosClient } from 'aptos-sdk'\n\nexport enum AptosNetwork {\n MAIN_NET = 1,\n TEST_NET = 2,\n // DEV_NET,\n}\n\nexport function getChainId(network: AptosNetwork): string {\n switch (network) {\n case AptosNetwork.TEST_NET:\n return CHAIN_IDS.APTOS_TESTNET\n }\n return CHAIN_IDS.APTOS_MAINNET\n}\n\nexport function getAptosChainName(network: AptosNetwork): string {\n switch (network) {\n case AptosNetwork.TEST_NET:\n return getChainName(CHAIN_IDS.APTOS_TESTNET)\n }\n return getChainName(CHAIN_IDS.APTOS_MAINNET)\n}\n\nexport function getRpcEndpoint(network: AptosNetwork): string {\n switch (network) {\n case AptosNetwork.TEST_NET:\n return 'https://testnet.aptoslabs.com/'\n }\n return 'https://mainnet.aptoslabs.com/'\n}\n\nexport function getRpcClient(network: AptosNetwork): AptosClient {\n return new AptosClient(getRpcEndpoint(network))\n}\n\nexport class AptosBindOptions {\n address: string\n network?: AptosNetwork = AptosNetwork.MAIN_NET\n startVersion?: bigint | number\n}\n"]}
|
|
@@ -62,7 +62,7 @@ async function generateForNetwork(srcDir, outputDir, network) {
|
|
|
62
62
|
}
|
|
63
63
|
while (loader.pendingAccounts.size > 0) {
|
|
64
64
|
for (const account of loader.pendingAccounts) {
|
|
65
|
-
console.log(`download dependent module for account ${account} at ${(0, network_1.
|
|
65
|
+
console.log(`download dependent module for account ${account} at ${(0, network_1.getAptosChainName)(network)}`);
|
|
66
66
|
try {
|
|
67
67
|
const modules = await client.getAccountModules(account);
|
|
68
68
|
fs_1.default.writeFileSync(path_1.default.resolve(srcDir, account + '.json'), JSON.stringify(modules, null, '\t'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/aptos-codegen/codegen.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,gDAAuB;AACvB,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,CAAA;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC7B,OAAO,KAAK;SACT,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,CACL,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CACf,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,EACvG,EAAE,CACH,CAAA;AACL,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa;IACxC,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,KAAK,CAAA;KACb;IACD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;AAC9E,CAAC","sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport prettier from 'prettier'\nimport { MoveFunction, MoveModule, MoveModuleBytecode, MoveStruct } from 'aptos-sdk/src/generated'\nimport { AccountModulesImportInfo, AccountRegister, generateType } from './typegen'\nimport { getMeaningfulFunctionParams, isFrameworkAccount, moduleQname, SPLITTER } from '../aptos/utils'\nimport chalk from 'chalk'\nimport { AptosNetwork, getChainName, getRpcClient } from '../aptos/network'\nimport { parseMoveType } from '../aptos/types'\n\nexport function codeGenAptosProcessor(abisDir: string, outDir = 'src/types/aptos') {\n if (!fs.existsSync(abisDir)) {\n return\n }\n console.log(chalk.green('Generated Types for Aptos'))\n generate(abisDir, outDir)\n}\n\nexport async function generate(srcDir: string, outputDir: string) {\n await generateForNetwork(srcDir, outputDir, AptosNetwork.MAIN_NET)\n await generateForNetwork(path.join(srcDir, 'testnet'), path.join(outputDir, 'testnet'), AptosNetwork.TEST_NET)\n}\n\nexport async function generateForNetwork(srcDir: string, outputDir: string, network: AptosNetwork) {\n if (!fs.existsSync(srcDir)) {\n return\n }\n if (network === AptosNetwork.TEST_NET) {\n console.log('Found testnet directory, generate code for testnet modules')\n }\n const files = fs.readdirSync(srcDir)\n outputDir = path.resolve(outputDir)\n const outputs: OutputFile[] = []\n\n fs.mkdirSync(outputDir, { recursive: true })\n\n const loader = new AccountRegister()\n\n // when generating user code, don't need to generate framework account\n loader.accountImports.set('0x1', new AccountModulesImportInfo('0x1', '0x1'))\n loader.accountImports.set('0x2', new AccountModulesImportInfo('0x2', '0x2'))\n loader.accountImports.set('0x3', new AccountModulesImportInfo('0x3', '0x3'))\n const client = getRpcClient(network)\n\n for (const file of files) {\n if (!file.endsWith('.json')) {\n continue\n }\n const fullPath = path.resolve(srcDir, file)\n const modules = JSON.parse(fs.readFileSync(fullPath, 'utf-8'))\n\n for (const module of modules) {\n if (module.abi) {\n loader.register(module.abi, path.basename(file, '.json'))\n }\n }\n const codeGen = new AccountCodegen(loader, modules, {\n fileName: path.basename(file, '.json'),\n outputDir: outputDir,\n network,\n })\n\n outputs.push(...codeGen.generate())\n }\n\n while (loader.pendingAccounts.size > 0) {\n for (const account of loader.pendingAccounts) {\n console.log(`download dependent module for account ${account} at ${getChainName(network)}`)\n\n try {\n const modules = await client.getAccountModules(account)\n fs.writeFileSync(path.resolve(srcDir, account + '.json'), JSON.stringify(modules, null, '\\t'))\n\n for (const module of modules) {\n if (module.abi) {\n loader.register(module.abi, account)\n }\n }\n const codeGen = new AccountCodegen(loader, modules, {\n fileName: account,\n outputDir: outputDir,\n network,\n })\n\n outputs.push(...codeGen.generate())\n } catch (e) {\n console.error(\n chalk.red(\n 'Error downloading account module, check if you choose the right network,or download account modules manually into your director'\n )\n )\n console.error(e)\n process.exit(1)\n }\n }\n }\n\n for (const output of outputs) {\n const content = prettier.format(output.fileContent, { parser: 'typescript' })\n fs.writeFileSync(path.join(outputDir, output.fileName), content)\n }\n}\n\ninterface OutputFile {\n fileName: string\n fileContent: string\n}\n\ninterface Config {\n fileName: string\n outputDir: string\n network: AptosNetwork\n}\n\nexport class AccountCodegen {\n modules: MoveModuleBytecode[]\n config: Config\n loader: AccountRegister\n\n constructor(loader: AccountRegister, modules: MoveModuleBytecode[], config: Config) {\n // const json = fs.readFileSync(config.srcFile, 'utf-8')\n this.modules = modules\n this.config = config\n this.loader = loader\n }\n\n generate(): OutputFile[] {\n if (!this.modules) {\n return []\n }\n // const baseName = path.basename(this.config.fileName, '.json')\n\n let address: string | undefined\n for (const module of this.modules) {\n if (module.abi && module.abi.address) {\n address = module.abi.address\n }\n }\n if (!address) {\n return []\n }\n\n const imports = `\n import { aptos } from \"@sentio/sdk\"\n import { Address, MoveModule } from \"aptos-sdk/src/generated\"\n `\n\n const dependedAccounts: string[] = []\n\n const moduleImports: string[] = []\n\n const info = this.loader.accountImports.get(address)\n\n if (info) {\n for (const [account] of info.imports.entries()) {\n // Remap to user's filename if possible, TODO codepath not well tested\n let tsAccountModule = './' + (this.loader.accountImports.get(account)?.moduleName || account)\n if (isFrameworkAccount(account) && !isFrameworkAccount(address)) {\n // Decide where to find runtime library\n let srcRoot = 'lib'\n if (__dirname.includes('sdk/src/aptos-codegen')) {\n srcRoot = 'src'\n }\n tsAccountModule = `@sentio/sdk/${srcRoot}/builtin/aptos/${account}`\n }\n moduleImports.push(`import * as _${account} from \"${tsAccountModule}\"`)\n\n dependedAccounts.push(account)\n }\n }\n\n const source = `\n /* Autogenerated file. Do not edit manually. */\n /* tslint:disable */\n /* eslint-disable */\n \n /* Generated modules for account ${address} */\n \n ${imports}\n \n ${moduleImports.join('\\n')}\n \n ${this.modules.map((m) => generateModule(m, this.config.network)).join('\\n')}\n \n export function loadAllTypes(_r: aptos.TypeRegistry) {\n ${dependedAccounts.map((a) => `_${a}.loadAllTypes(_r)`).join('\\n')}\n\n ${this.modules\n .map((m) => {\n return `_r.load(${m.abi?.name}.ABI)`\n })\n .join('\\n')}\n }\n ` // source\n\n return [\n {\n fileName: this.config.fileName + '.ts',\n fileContent: source,\n },\n ]\n }\n}\n\nfunction generateNetworkOption(network: AptosNetwork) {\n switch (network) {\n case AptosNetwork.TEST_NET:\n return 'TEST_NET'\n }\n return 'MAIN_NET'\n}\n\nfunction generateModule(moduleByteCode: MoveModuleBytecode, network: AptosNetwork) {\n if (!moduleByteCode.abi) {\n return ''\n }\n const module = moduleByteCode.abi\n\n const functions = module.exposed_functions.map((f) => generateOnEntryFunctions(module, f)).filter((s) => s !== '')\n\n const eventStructs = getEventStructs(module)\n const eventTypes = new Set(eventStructs.keys())\n const events = Array.from(eventStructs.values())\n .map((e) => generateOnEvents(module, e))\n .filter((s) => s !== '')\n const structs = module.structs.map((s) => generateStructs(module, s, eventTypes))\n const callArgs = module.exposed_functions.map((f) => generateCallArgsStructs(module, f))\n\n let processor = ''\n if (functions.length > 0 || events.length > 0) {\n processor = `export class ${module.name} extends aptos.AptosBaseProcessor {\n\n constructor(options: aptos.AptosBindOptions) {\n super(\"${module.name}\", options)\n }\n static DEFAULT_OPTIONS: aptos.AptosBindOptions = {\n address: \"${module.address}\",\n network: aptos.AptosNetwork.${generateNetworkOption(network)} \n }\n\n static bind(options: Partial<aptos.AptosBindOptions> = {}): ${module.name} {\n return new ${module.name}({ ...${module.name}.DEFAULT_OPTIONS, ...options })\n }\n \n ${functions.join('\\n')}\n \n ${events.join('\\n')}\n \n loadTypesInternal(registry: aptos.TypeRegistry) {\n loadAllTypes(registry)\n }\n }\n `\n }\n\n return `\n ${processor}\n\n export namespace ${module.name} {\n ${structs.join('\\n')}\n \n ${callArgs.join('\\n')}\n \n export function loadTypes(_r: aptos.TypeRegistry) {\n loadAllTypes(_r)\n }\n export const ABI: MoveModule = JSON.parse('${JSON.stringify(module)}')\n }\n `\n}\n\nfunction generateStructs(module: MoveModule, struct: MoveStruct, events: Set<string>) {\n const genericString = generateStructTypeParameters(struct)\n const genericStringAny = generateStructTypeParameters(struct, true)\n\n const fields = struct.fields.map((field) => {\n return `${field.name}: ${generateType(field.type, module.address)}`\n })\n\n let eventPayload = ''\n if (events.has(moduleQname(module) + SPLITTER + struct.name)) {\n eventPayload = `\n export interface ${struct.name}Instance extends \n aptos.TypedEventInstance<${struct.name}${genericStringAny}> {\n data_typed: ${struct.name}${genericStringAny}\n type_arguments: [${struct.generic_type_params.map((_) => 'string').join(', ')}]\n }\n `\n }\n\n return `\n export class ${struct.name}${genericString} {\n static TYPE_QNAME = '${module.address}::${module.name}::${struct.name}'\n ${fields.join('\\n')} \n }\n \n ${eventPayload}\n `\n}\n\nfunction generateFunctionTypeParameters(func: MoveFunction) {\n let genericString = ''\n if (func.generic_type_params && func.generic_type_params.length > 0) {\n const params = func.generic_type_params\n .map((v, idx) => {\n return `T${idx}=any`\n })\n .join(',')\n genericString = `<${params}>`\n }\n return genericString\n}\n\nfunction generateStructTypeParameters(struct: MoveStruct, useAny = false) {\n let genericString = ''\n\n if (struct.generic_type_params && struct.generic_type_params.length > 0) {\n const params = struct.generic_type_params\n .map((v, idx) => {\n return useAny ? 'any' : 'T' + idx\n })\n .join(',')\n genericString = `<${params}>`\n }\n return genericString\n}\n\nfunction generateCallArgsStructs(module: MoveModule, func: MoveFunction) {\n if (!func.is_entry) {\n return\n }\n\n const fields = getMeaningfulFunctionParams(func).map((param) => {\n return `${generateType(param, module.address)}`\n })\n\n const camelFuncName = capitalizeFirstChar(camelize(func.name))\n\n const genericString = generateFunctionTypeParameters(func)\n return `\n export interface ${camelFuncName}Payload${genericString}\n extends aptos.TypedEntryFunctionPayload<[${fields.join(',')}]> {\n arguments_typed: [${fields.join(',')}],\n type_arguments: [${func.generic_type_params.map((_) => 'string').join(', ')}]\n }\n `\n}\n\nfunction generateOnEntryFunctions(module: MoveModule, func: MoveFunction) {\n if (!func.is_entry) {\n return ''\n }\n\n // const genericString = generateFunctionTypeParameters(func)\n\n const camelFuncName = capitalizeFirstChar(camelize(func.name))\n const source = `\n onEntry${camelFuncName}(func: (call: ${module.name}.${camelFuncName}Payload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): ${module.name} {\n this.onEntryFunctionCall(func, {\n ...filter,\n function: '${module.name}::${func.name}'\n })\n return this\n }`\n\n return source\n}\n\nfunction getEventStructs(module: MoveModule) {\n const qname = moduleQname(module)\n const structMap = new Map<string, MoveStruct>()\n const eventMap = new Map<string, MoveStruct>()\n\n for (const struct of module.structs) {\n structMap.set(qname + SPLITTER + struct.name, struct)\n }\n\n for (const struct of module.structs) {\n for (const field of struct.fields) {\n const t = parseMoveType(field.type)\n if (t.qname === '0x1::event::EventHandle') {\n const event = t.typeArgs[0].qname\n const eventStruct = structMap.get(event)\n if (eventStruct) {\n eventMap.set(event, eventStruct)\n }\n }\n }\n }\n\n return eventMap\n}\n\nfunction generateOnEvents(module: MoveModule, struct: MoveStruct): string {\n // for struct that has drop + store\n // if (!isEvent(struct, module)) {\n // return ''\n // }\n\n // const genericString = generateStructTypeParameters(struct)\n\n const source = `\n onEvent${struct.name}(func: (event: ${module.name}.${struct.name}Instance, ctx: aptos.AptosContext) => void): ${module.name} {\n this.onEvent(func, {\n type: '${module.name}::${struct.name}'\n })\n return this\n }\n `\n return source\n}\n\nfunction camelize(input: string): string {\n return input\n .split('_')\n .reduce(\n (res, word, i) =>\n i === 0 ? word.toLowerCase() : `${res}${word.charAt(0).toUpperCase()}${word.substr(1).toLowerCase()}`,\n ''\n )\n}\n\nfunction capitalizeFirstChar(input: string): string {\n if (!input) {\n return input\n }\n return input[0].toUpperCase() + (input.length > 1 ? input.substring(1) : '')\n}\n"]}
|
|
1
|
+
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/aptos-codegen/codegen.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,gDAAuB;AACvB,wDAA+B;AAE/B,uCAAmF;AACnF,0CAAuG;AACvG,kDAAyB;AACzB,8CAAgF;AAChF,0CAA8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AAO,KAAK;SACT,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,CACL,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CACf,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,EACvG,EAAE,CACH,CAAA;AACL,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa;IACxC,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,KAAK,CAAA;KACb;IACD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;AAC9E,CAAC","sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport prettier from 'prettier'\nimport { MoveFunction, MoveModule, MoveModuleBytecode, MoveStruct } from 'aptos-sdk/src/generated'\nimport { AccountModulesImportInfo, AccountRegister, generateType } from './typegen'\nimport { getMeaningfulFunctionParams, isFrameworkAccount, moduleQname, SPLITTER } from '../aptos/utils'\nimport chalk from 'chalk'\nimport { AptosNetwork, getAptosChainName, getRpcClient } from '../aptos/network'\nimport { parseMoveType } from '../aptos/types'\n\nexport function codeGenAptosProcessor(abisDir: string, outDir = 'src/types/aptos') {\n if (!fs.existsSync(abisDir)) {\n return\n }\n console.log(chalk.green('Generated Types for Aptos'))\n generate(abisDir, outDir)\n}\n\nexport async function generate(srcDir: string, outputDir: string) {\n await generateForNetwork(srcDir, outputDir, AptosNetwork.MAIN_NET)\n await generateForNetwork(path.join(srcDir, 'testnet'), path.join(outputDir, 'testnet'), AptosNetwork.TEST_NET)\n}\n\nexport async function generateForNetwork(srcDir: string, outputDir: string, network: AptosNetwork) {\n if (!fs.existsSync(srcDir)) {\n return\n }\n if (network === AptosNetwork.TEST_NET) {\n console.log('Found testnet directory, generate code for testnet modules')\n }\n const files = fs.readdirSync(srcDir)\n outputDir = path.resolve(outputDir)\n const outputs: OutputFile[] = []\n\n fs.mkdirSync(outputDir, { recursive: true })\n\n const loader = new AccountRegister()\n\n // when generating user code, don't need to generate framework account\n loader.accountImports.set('0x1', new AccountModulesImportInfo('0x1', '0x1'))\n loader.accountImports.set('0x2', new AccountModulesImportInfo('0x2', '0x2'))\n loader.accountImports.set('0x3', new AccountModulesImportInfo('0x3', '0x3'))\n const client = getRpcClient(network)\n\n for (const file of files) {\n if (!file.endsWith('.json')) {\n continue\n }\n const fullPath = path.resolve(srcDir, file)\n const modules = JSON.parse(fs.readFileSync(fullPath, 'utf-8'))\n\n for (const module of modules) {\n if (module.abi) {\n loader.register(module.abi, path.basename(file, '.json'))\n }\n }\n const codeGen = new AccountCodegen(loader, modules, {\n fileName: path.basename(file, '.json'),\n outputDir: outputDir,\n network,\n })\n\n outputs.push(...codeGen.generate())\n }\n\n while (loader.pendingAccounts.size > 0) {\n for (const account of loader.pendingAccounts) {\n console.log(`download dependent module for account ${account} at ${getAptosChainName(network)}`)\n\n try {\n const modules = await client.getAccountModules(account)\n fs.writeFileSync(path.resolve(srcDir, account + '.json'), JSON.stringify(modules, null, '\\t'))\n\n for (const module of modules) {\n if (module.abi) {\n loader.register(module.abi, account)\n }\n }\n const codeGen = new AccountCodegen(loader, modules, {\n fileName: account,\n outputDir: outputDir,\n network,\n })\n\n outputs.push(...codeGen.generate())\n } catch (e) {\n console.error(\n chalk.red(\n 'Error downloading account module, check if you choose the right network,or download account modules manually into your director'\n )\n )\n console.error(e)\n process.exit(1)\n }\n }\n }\n\n for (const output of outputs) {\n const content = prettier.format(output.fileContent, { parser: 'typescript' })\n fs.writeFileSync(path.join(outputDir, output.fileName), content)\n }\n}\n\ninterface OutputFile {\n fileName: string\n fileContent: string\n}\n\ninterface Config {\n fileName: string\n outputDir: string\n network: AptosNetwork\n}\n\nexport class AccountCodegen {\n modules: MoveModuleBytecode[]\n config: Config\n loader: AccountRegister\n\n constructor(loader: AccountRegister, modules: MoveModuleBytecode[], config: Config) {\n // const json = fs.readFileSync(config.srcFile, 'utf-8')\n this.modules = modules\n this.config = config\n this.loader = loader\n }\n\n generate(): OutputFile[] {\n if (!this.modules) {\n return []\n }\n // const baseName = path.basename(this.config.fileName, '.json')\n\n let address: string | undefined\n for (const module of this.modules) {\n if (module.abi && module.abi.address) {\n address = module.abi.address\n }\n }\n if (!address) {\n return []\n }\n\n const imports = `\n import { aptos } from \"@sentio/sdk\"\n import { Address, MoveModule } from \"aptos-sdk/src/generated\"\n `\n\n const dependedAccounts: string[] = []\n\n const moduleImports: string[] = []\n\n const info = this.loader.accountImports.get(address)\n\n if (info) {\n for (const [account] of info.imports.entries()) {\n // Remap to user's filename if possible, TODO codepath not well tested\n let tsAccountModule = './' + (this.loader.accountImports.get(account)?.moduleName || account)\n if (isFrameworkAccount(account) && !isFrameworkAccount(address)) {\n // Decide where to find runtime library\n let srcRoot = 'lib'\n if (__dirname.includes('sdk/src/aptos-codegen')) {\n srcRoot = 'src'\n }\n tsAccountModule = `@sentio/sdk/${srcRoot}/builtin/aptos/${account}`\n }\n moduleImports.push(`import * as _${account} from \"${tsAccountModule}\"`)\n\n dependedAccounts.push(account)\n }\n }\n\n const source = `\n /* Autogenerated file. Do not edit manually. */\n /* tslint:disable */\n /* eslint-disable */\n \n /* Generated modules for account ${address} */\n \n ${imports}\n \n ${moduleImports.join('\\n')}\n \n ${this.modules.map((m) => generateModule(m, this.config.network)).join('\\n')}\n \n export function loadAllTypes(_r: aptos.TypeRegistry) {\n ${dependedAccounts.map((a) => `_${a}.loadAllTypes(_r)`).join('\\n')}\n\n ${this.modules\n .map((m) => {\n return `_r.load(${m.abi?.name}.ABI)`\n })\n .join('\\n')}\n }\n ` // source\n\n return [\n {\n fileName: this.config.fileName + '.ts',\n fileContent: source,\n },\n ]\n }\n}\n\nfunction generateNetworkOption(network: AptosNetwork) {\n switch (network) {\n case AptosNetwork.TEST_NET:\n return 'TEST_NET'\n }\n return 'MAIN_NET'\n}\n\nfunction generateModule(moduleByteCode: MoveModuleBytecode, network: AptosNetwork) {\n if (!moduleByteCode.abi) {\n return ''\n }\n const module = moduleByteCode.abi\n\n const functions = module.exposed_functions.map((f) => generateOnEntryFunctions(module, f)).filter((s) => s !== '')\n\n const eventStructs = getEventStructs(module)\n const eventTypes = new Set(eventStructs.keys())\n const events = Array.from(eventStructs.values())\n .map((e) => generateOnEvents(module, e))\n .filter((s) => s !== '')\n const structs = module.structs.map((s) => generateStructs(module, s, eventTypes))\n const callArgs = module.exposed_functions.map((f) => generateCallArgsStructs(module, f))\n\n let processor = ''\n if (functions.length > 0 || events.length > 0) {\n processor = `export class ${module.name} extends aptos.AptosBaseProcessor {\n\n constructor(options: aptos.AptosBindOptions) {\n super(\"${module.name}\", options)\n }\n static DEFAULT_OPTIONS: aptos.AptosBindOptions = {\n address: \"${module.address}\",\n network: aptos.AptosNetwork.${generateNetworkOption(network)} \n }\n\n static bind(options: Partial<aptos.AptosBindOptions> = {}): ${module.name} {\n return new ${module.name}({ ...${module.name}.DEFAULT_OPTIONS, ...options })\n }\n \n ${functions.join('\\n')}\n \n ${events.join('\\n')}\n \n loadTypesInternal(registry: aptos.TypeRegistry) {\n loadAllTypes(registry)\n }\n }\n `\n }\n\n return `\n ${processor}\n\n export namespace ${module.name} {\n ${structs.join('\\n')}\n \n ${callArgs.join('\\n')}\n \n export function loadTypes(_r: aptos.TypeRegistry) {\n loadAllTypes(_r)\n }\n export const ABI: MoveModule = JSON.parse('${JSON.stringify(module)}')\n }\n `\n}\n\nfunction generateStructs(module: MoveModule, struct: MoveStruct, events: Set<string>) {\n const genericString = generateStructTypeParameters(struct)\n const genericStringAny = generateStructTypeParameters(struct, true)\n\n const fields = struct.fields.map((field) => {\n return `${field.name}: ${generateType(field.type, module.address)}`\n })\n\n let eventPayload = ''\n if (events.has(moduleQname(module) + SPLITTER + struct.name)) {\n eventPayload = `\n export interface ${struct.name}Instance extends \n aptos.TypedEventInstance<${struct.name}${genericStringAny}> {\n data_typed: ${struct.name}${genericStringAny}\n type_arguments: [${struct.generic_type_params.map((_) => 'string').join(', ')}]\n }\n `\n }\n\n return `\n export class ${struct.name}${genericString} {\n static TYPE_QNAME = '${module.address}::${module.name}::${struct.name}'\n ${fields.join('\\n')} \n }\n \n ${eventPayload}\n `\n}\n\nfunction generateFunctionTypeParameters(func: MoveFunction) {\n let genericString = ''\n if (func.generic_type_params && func.generic_type_params.length > 0) {\n const params = func.generic_type_params\n .map((v, idx) => {\n return `T${idx}=any`\n })\n .join(',')\n genericString = `<${params}>`\n }\n return genericString\n}\n\nfunction generateStructTypeParameters(struct: MoveStruct, useAny = false) {\n let genericString = ''\n\n if (struct.generic_type_params && struct.generic_type_params.length > 0) {\n const params = struct.generic_type_params\n .map((v, idx) => {\n return useAny ? 'any' : 'T' + idx\n })\n .join(',')\n genericString = `<${params}>`\n }\n return genericString\n}\n\nfunction generateCallArgsStructs(module: MoveModule, func: MoveFunction) {\n if (!func.is_entry) {\n return\n }\n\n const fields = getMeaningfulFunctionParams(func).map((param) => {\n return `${generateType(param, module.address)}`\n })\n\n const camelFuncName = capitalizeFirstChar(camelize(func.name))\n\n const genericString = generateFunctionTypeParameters(func)\n return `\n export interface ${camelFuncName}Payload${genericString}\n extends aptos.TypedEntryFunctionPayload<[${fields.join(',')}]> {\n arguments_typed: [${fields.join(',')}],\n type_arguments: [${func.generic_type_params.map((_) => 'string').join(', ')}]\n }\n `\n}\n\nfunction generateOnEntryFunctions(module: MoveModule, func: MoveFunction) {\n if (!func.is_entry) {\n return ''\n }\n\n // const genericString = generateFunctionTypeParameters(func)\n\n const camelFuncName = capitalizeFirstChar(camelize(func.name))\n const source = `\n onEntry${camelFuncName}(func: (call: ${module.name}.${camelFuncName}Payload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): ${module.name} {\n this.onEntryFunctionCall(func, {\n ...filter,\n function: '${module.name}::${func.name}'\n })\n return this\n }`\n\n return source\n}\n\nfunction getEventStructs(module: MoveModule) {\n const qname = moduleQname(module)\n const structMap = new Map<string, MoveStruct>()\n const eventMap = new Map<string, MoveStruct>()\n\n for (const struct of module.structs) {\n structMap.set(qname + SPLITTER + struct.name, struct)\n }\n\n for (const struct of module.structs) {\n for (const field of struct.fields) {\n const t = parseMoveType(field.type)\n if (t.qname === '0x1::event::EventHandle') {\n const event = t.typeArgs[0].qname\n const eventStruct = structMap.get(event)\n if (eventStruct) {\n eventMap.set(event, eventStruct)\n }\n }\n }\n }\n\n return eventMap\n}\n\nfunction generateOnEvents(module: MoveModule, struct: MoveStruct): string {\n // for struct that has drop + store\n // if (!isEvent(struct, module)) {\n // return ''\n // }\n\n // const genericString = generateStructTypeParameters(struct)\n\n const source = `\n onEvent${struct.name}(func: (event: ${module.name}.${struct.name}Instance, ctx: aptos.AptosContext) => void): ${module.name} {\n this.onEvent(func, {\n type: '${module.name}::${struct.name}'\n })\n return this\n }\n `\n return source\n}\n\nfunction camelize(input: string): string {\n return input\n .split('_')\n .reduce(\n (res, word, i) =>\n i === 0 ? word.toLowerCase() : `${res}${word.charAt(0).toUpperCase()}${word.substr(1).toLowerCase()}`,\n ''\n )\n}\n\nfunction capitalizeFirstChar(input: string): string {\n if (!input) {\n return input\n }\n return input[0].toUpperCase() + (input.length > 1 ? input.substring(1) : '')\n}\n"]}
|
|
@@ -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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I,IAAI,CAAC,QAAQ,EAAE;QACjB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAA;KACnC;IACD,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACtB,CAAC;AAfD,kDAeC;AAED,MAAa,mBAAmB;IAC9B,OAAO,CAAQ;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.SOL_MAINMET_ID,
|
|
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;
|
|
@@ -177,7 +152,7 @@ class SuiContext extends base_context_1.BaseContext {
|
|
|
177
152
|
transactionIndex: 0,
|
|
178
153
|
transactionHash: '',
|
|
179
154
|
logIndex: 0,
|
|
180
|
-
chainId: chain_1.
|
|
155
|
+
chainId: chain_1.CHAIN_IDS.SUI_DEVNET,
|
|
181
156
|
name: name,
|
|
182
157
|
labels: (0, meter_1.normalizeLabels)(labels),
|
|
183
158
|
};
|
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,0CAA8D;AAC9D,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,CAAC,eAAe,CAAA;SAC3C;aAAM,IAAI,KAAK,EAAE;YAChB,IAAI,CAAC,WAAW,GAAG,cAAI,CAAC,UAAU,CAAC,KAAK,CAAC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X,OAAO,EAAE,sBAAc;YACvB,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,IAAA,uBAAe,EAAC,MAAM,CAAC;SAChC,CAAA;IACH,CAAC;CACF;AAzBD,sCAyBC;AAED,MAAa,UAAW,SAAQ,0BAAW;IACzC,OAAO,CAAQ;IACf,UAAU,CAAQ;IAClB,WAAW,CAAM;IAEjB,YAAY,OAAe,EAAE,IAAU;QACrC,KAAK,EAAE,CAAA;QACP,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,UAAU;YAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,gBAAgB,EAAE,CAAC;YACnB,eAAe,EAAE,EAAE;YACnB,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,qBAAa;YACtB,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 { SOL_MAINMET_ID, SUI_DEVNET_ID } 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: SOL_MAINMET_ID, // 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: SUI_DEVNET_ID, // 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,eAA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AC,OAAO,CAAA;IAC1B,CAAC;CACF;AApBD,8CAoBC;AAED,MAAa,UAAW,SAAQ,0BAAW;IACzC,OAAO,CAAQ;IACf,UAAU,CAAQ;IAClB,WAAW,CAAM;IAEjB,YAAY,OAAe,EAAE,IAAU;QACrC,KAAK,EAAE,CAAA;QACP,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,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 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"],"names":[],"mappings":";;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"solana-processor.js","sourceRoot":"","sources":["../../src/core/solana-processor.ts"],"names":[],"mappings":";;;;;;AACA,qDAAgD;AAChD,gDAAuB;AAGvB,0DAAyD;AACzD,0CAA0C;AAS1C,MAAa,oBAAqB,SAAQ,gCAAqC;IAC7E,MAAM,CAAC,QAAQ,GAAyB,IAAI,oBAAoB,EAAE,CAAA;;AADpE,oDAEC;AAED,MAAa,mBAAmB;IACvB,qBAAqB,GAA0C,IAAI,GAAG,EAAE,CAAA;IAC/E,OAAO,CAAQ;IACf,QAAQ,CAAQ;IAChB,YAAY,CAAQ;IACpB,OAAO,CAAQ;IACf,uBAAuB,CAAS;IAChC,MAAM,GAAmB,EAAE,SAAS,EAAE,IAAI,cAAI,CAAC,CAAC,CAAC,EAAE,CAAA;IACnD,iBAAiB,CAAgD;IACjE,qBAAqB,CAAkE;IAEvF,YAAY,OAA0B;QACpC,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;SACnB;QACD,oBAAoB,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC9C,CAAC;IAED,IAAI,CAAC,OAA0B;QAC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AAC,CAAA;aAC7C;SACF;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,qBAAqB,CAAC,iBAA8B;QACzD,OAAO,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAC/D,CAAC;IAED,uCAAuC;IAChC,iBAAiB,CACtB,iBAA8B,EAC9B,QAAkB,EAClB,OAAiC,EACjC,IAAU;QAEV,MAAM,GAAG,GAAG,IAAI,8BAAa,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QAClF,OAAO,CAAC,iBAAiB,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAA;QACzC,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/lib/service.js
CHANGED
|
@@ -225,7 +225,7 @@ class ProcessorServiceImpl {
|
|
|
225
225
|
processorType: USER_PROCESSOR,
|
|
226
226
|
contract: {
|
|
227
227
|
name: solanaProcessor.contractName,
|
|
228
|
-
chainId: chain_1.
|
|
228
|
+
chainId: chain_1.CHAIN_IDS.SOLANA_MAINNET,
|
|
229
229
|
address: solanaProcessor.address,
|
|
230
230
|
abi: '',
|
|
231
231
|
},
|
|
@@ -250,7 +250,7 @@ class ProcessorServiceImpl {
|
|
|
250
250
|
processorType: USER_PROCESSOR,
|
|
251
251
|
contract: {
|
|
252
252
|
name: 'sui contract',
|
|
253
|
-
chainId: chain_1.
|
|
253
|
+
chainId: chain_1.CHAIN_IDS.SUI_DEVNET,
|
|
254
254
|
address: suiProcessor.address,
|
|
255
255
|
abi: '',
|
|
256
256
|
},
|