@sentio/sdk 1.20.0 → 1.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/aptos/aptos-processor.d.ts +7 -2
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos-codegen/codegen.d.ts +2 -1
- package/lib/aptos-codegen/codegen.js +5 -4
- package/lib/aptos-codegen/codegen.js.map +1 -1
- package/lib/cli/build.js +2 -1
- package/lib/cli/build.js.map +1 -1
- package/lib/tests/souffl3.js +4 -4
- package/lib/tests/souffl3.js.map +1 -1
- package/lib/tests/types/aptos/{account-4188c8.d.ts → souffle.d.ts} +0 -0
- package/lib/tests/types/aptos/{account-4188c8.js → souffle.js} +3 -3
- package/lib/tests/types/aptos/souffle.js.map +1 -0
- package/package.json +1 -1
- package/src/aptos/aptos-processor.ts +9 -2
- package/src/aptos-codegen/codegen.ts +6 -4
- package/src/aptos-codegen/codgen.test.ts +1 -1
- package/src/cli/build.ts +2 -1
- package/src/tests/abis/aptos/{0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807.json → souffle.json} +0 -0
- package/src/tests/souffl3.ts +2 -2
- package/src/tests/types/aptos/{account-4188c8.ts → souffle.ts} +2 -2
- package/lib/tests/types/aptos/account-4188c8.js.map +0 -1
|
@@ -10,13 +10,18 @@ declare type IndexConfigure = {
|
|
|
10
10
|
network: AptosNetwork;
|
|
11
11
|
startVersion: Long;
|
|
12
12
|
};
|
|
13
|
-
export interface EventFilter {
|
|
13
|
+
export interface EventFilter extends ArgumentsFilter {
|
|
14
14
|
type: string;
|
|
15
15
|
}
|
|
16
|
-
export interface CallFilter {
|
|
16
|
+
export interface CallFilter extends CallArgumentsFilter {
|
|
17
17
|
function: string;
|
|
18
|
+
}
|
|
19
|
+
export interface CallArgumentsFilter extends ArgumentsFilter {
|
|
18
20
|
typeArguments?: string[];
|
|
19
21
|
}
|
|
22
|
+
export interface ArgumentsFilter {
|
|
23
|
+
arguments?: string[];
|
|
24
|
+
}
|
|
20
25
|
declare class EventHandler {
|
|
21
26
|
filters: EventFilter[];
|
|
22
27
|
handler: (event: Event) => Promise<ProcessResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aptos-processor.js","sourceRoot":"","sources":["../../src/aptos/aptos-processor.ts"],"names":[],"mappings":";;;;;;AACA,wBAMU;AAGV,gDAAuB;AACvB,0CAAmE;
|
|
1
|
+
{"version":3,"file":"aptos-processor.js","sourceRoot":"","sources":["../../src/aptos/aptos-processor.ts"],"names":[],"mappings":";;;;;;AACA,wBAMU;AAGV,gDAAuB;AACvB,0CAAmE;AA2BnE,MAAM,YAAY;IAChB,OAAO,CAAe;IACtB,OAAO,CAA0C;CAClD;AAED,MAAM,WAAW;IACf,OAAO,CAAc;IACrB,OAAO,CAA+D;CACvE;AAED,MAAa,kBAAkB;IAC7B,IAAI,CAAQ;IACZ,MAAM,CAAgB;IACtB,aAAa,GAAmB,EAAE,CAAA;IAClC,YAAY,GAAkB,EAAE,CAAA;IAEhC,YAAY,OAAyB;QACnC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,OAAO,CAAA;QAC3C,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;QACvB,MAAM,CAAC,eAAe,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACnD,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,OAAyB;QACnC,OAAO,IAAI,kBAAkB,CAAC,OAAO,CAAC,CAAA;IACxC,CAAC;IAEM,aAAa,CAClB,OAA8E;QAE9E,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAA;QACnC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;YACrB,OAAO,EAAE,KAAK,WAAW,EAAE;gBACzB,MAAM,GAAG,GAAG,IAAI,eAAY,CAAC,OAAO,EAAE,cAAI,CAAC,UAAU,CAAC,EAAE,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B,CAAA;YACzB,KAAK,eAAY,CAAC,QAAQ;gBACxB,OAAO,wBAAgB,CAAA;SAC1B;IACH,CAAC;CACF;AAzHD,gDAyHC","sourcesContent":["import { ProcessResult } from '../gen'\nimport {\n AptosBindOptions,\n AptosContext,\n AptosNetwork,\n Transaction_UserTransaction,\n TransactionPayload_EntryFunctionPayload,\n} from '.'\nimport type { Event as OldEvent } from 'aptos/src/generated'\n\nimport Long from 'long'\nimport { APTOS_MAINNET_ID, APTOS_TESTNET_ID } from '../utils/chain'\n\nexport type Event = OldEvent & { version: string }\n\ntype IndexConfigure = {\n address: string\n network: AptosNetwork\n startVersion: Long\n // endSeqNumber?: Long\n}\n\nexport interface EventFilter extends ArgumentsFilter {\n type: string\n}\n\nexport interface CallFilter extends CallArgumentsFilter {\n function: string\n}\n\nexport interface CallArgumentsFilter extends ArgumentsFilter {\n typeArguments?: string[]\n}\n\nexport interface ArgumentsFilter {\n arguments?: string[]\n}\n\nclass EventHandler {\n filters: EventFilter[]\n handler: (event: Event) => Promise<ProcessResult>\n}\n\nclass CallHandler {\n filters: CallFilter[]\n handler: (call: Transaction_UserTransaction) => Promise<ProcessResult>\n}\n\nexport class AptosBaseProcessor {\n name: string\n config: IndexConfigure\n eventHandlers: EventHandler[] = []\n callHandlers: CallHandler[] = []\n\n constructor(options: AptosBindOptions) {\n this.name = options.name || options.address\n this.configure(options)\n global.PROCESSOR_STATE.aptosProcessors.push(this)\n }\n\n static bind(options: AptosBindOptions): AptosBaseProcessor {\n return new AptosBaseProcessor(options)\n }\n\n public onTransaction(\n handler: (transaction: Transaction_UserTransaction, ctx: AptosContext) => void\n ): AptosBaseProcessor {\n const address = this.config.address\n this.callHandlers.push({\n handler: async function (tx) {\n const ctx = new AptosContext(address, Long.fromString(tx.version), tx)\n if (tx) {\n handler(tx, ctx)\n }\n return {\n gauges: ctx.gauges,\n counters: ctx.counters,\n logs: ctx.logs,\n }\n },\n filters: [],\n })\n return this\n }\n\n public onEvent(\n handler: (event: Event, ctx: AptosContext) => void,\n filter: EventFilter | EventFilter[]\n ): AptosBaseProcessor {\n let _filters: EventFilter[] = []\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n const address = this.config.address\n\n this.eventHandlers.push({\n handler: async function (event) {\n const ctx = new AptosContext(address, Long.fromString(event.version))\n if (event) {\n handler(event, ctx)\n }\n return {\n gauges: ctx.gauges,\n counters: ctx.counters,\n logs: ctx.logs,\n }\n },\n filters: _filters,\n })\n return this\n }\n\n public onEntryFunctionCall(\n handler: (call: TransactionPayload_EntryFunctionPayload, ctx: AptosContext) => void,\n filter: CallFilter | CallFilter[]\n ): AptosBaseProcessor {\n let _filters: CallFilter[] = []\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n const address = this.config.address\n\n this.callHandlers.push({\n handler: async function (tx) {\n const ctx = new AptosContext(address, Long.fromString(tx.version), tx)\n if (tx) {\n const payload = tx.payload as TransactionPayload_EntryFunctionPayload\n handler(payload, ctx)\n }\n return {\n gauges: ctx.gauges,\n counters: ctx.counters,\n logs: ctx.logs,\n }\n },\n filters: _filters,\n })\n return this\n }\n\n private configure(options: AptosBindOptions) {\n let startVersion = Long.ZERO\n if (options.startVersion) {\n startVersion = Long.fromValue(options.startVersion)\n }\n\n this.config = {\n startVersion: startVersion,\n address: options.address,\n network: options.network || AptosNetwork.TEST_NET,\n }\n }\n\n getChainId(): string {\n switch (this.config.network) {\n case AptosNetwork.TEST_NET:\n return APTOS_TESTNET_ID\n case AptosNetwork.MAIN_NET:\n return APTOS_MAINNET_ID\n }\n }\n}\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { MoveModuleBytecode } from 'aptos/src/generated';
|
|
2
2
|
interface Config {
|
|
3
|
+
srcFile: string;
|
|
3
4
|
outputDir: string;
|
|
4
5
|
}
|
|
5
6
|
export declare class AptosCodegen {
|
|
6
7
|
modules: MoveModuleBytecode[];
|
|
7
8
|
config: Config;
|
|
8
|
-
constructor(
|
|
9
|
+
constructor(config: Config);
|
|
9
10
|
generate(): void;
|
|
10
11
|
}
|
|
11
12
|
export {};
|
|
@@ -10,8 +10,8 @@ const prettier_1 = __importDefault(require("prettier"));
|
|
|
10
10
|
class AptosCodegen {
|
|
11
11
|
modules;
|
|
12
12
|
config;
|
|
13
|
-
constructor(
|
|
14
|
-
const json = fs_1.default.readFileSync(srcFile, 'utf-8');
|
|
13
|
+
constructor(config) {
|
|
14
|
+
const json = fs_1.default.readFileSync(config.srcFile, 'utf-8');
|
|
15
15
|
this.modules = JSON.parse(json);
|
|
16
16
|
this.config = config;
|
|
17
17
|
}
|
|
@@ -40,8 +40,9 @@ class AptosCodegen {
|
|
|
40
40
|
|
|
41
41
|
${this.modules.map(generateModule).join('\n')}
|
|
42
42
|
`; // source
|
|
43
|
+
const baseName = path_1.default.basename(this.config.srcFile, '.json');
|
|
43
44
|
source = prettier_1.default.format(source, { parser: 'typescript' });
|
|
44
|
-
fs_1.default.writeFileSync(path_1.default.join(this.config.outputDir,
|
|
45
|
+
fs_1.default.writeFileSync(path_1.default.join(this.config.outputDir, baseName + '.ts'), source);
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
exports.AptosCodegen = AptosCodegen;
|
|
@@ -89,7 +90,7 @@ function generateOnEvents(module, struct) {
|
|
|
89
90
|
const source = `
|
|
90
91
|
onEvent${struct.name}(func: (event: aptos.Event, ctx: aptos.AptosContext) => void): ${module.name} {
|
|
91
92
|
this.onEvent(func, {
|
|
92
|
-
type: '${module.
|
|
93
|
+
type: '${module.name}::${struct.name}'
|
|
93
94
|
})
|
|
94
95
|
return this
|
|
95
96
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/aptos-codegen/codegen.ts"],"names":[],"mappings":";;;;;;AACA,4CAAmB;AACnB,gDAAuB;AAGvB,wDAA+B;
|
|
1
|
+
{"version":3,"file":"codegen.js","sourceRoot":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{ MoveModuleBytecode } from 'aptos/src/generated'\nimport fs from 'fs'\nimport path from 'path'\nimport { MoveFunction, MoveModule } from 'aptos/src/generated'\nimport { MoveStruct } from 'aptos/src/generated/models/MoveStruct'\nimport prettier from 'prettier'\n\ninterface Config {\n srcFile: string\n outputDir: string\n}\n\nexport class AptosCodegen {\n modules: MoveModuleBytecode[]\n config: Config\n\n constructor(config: Config) {\n const json = fs.readFileSync(config.srcFile, 'utf-8')\n this.modules = JSON.parse(json)\n this.config = config\n }\n\n generate() {\n if (!this.modules) {\n return\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 = `import { aptos } from \"@sentio/sdk\"`\n\n let 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 ${this.modules.map(generateModule).join('\\n')}\n ` // source\n\n const baseName = path.basename(this.config.srcFile, '.json')\n source = prettier.format(source, { parser: 'typescript' })\n fs.writeFileSync(path.join(this.config.outputDir, baseName + '.ts'), source)\n }\n}\n\nfunction generateModule(moduleByteCode: MoveModuleBytecode) {\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 const events = module.structs.map((e) => generateOnEvents(module, e)).filter((s) => s !== '')\n\n return `\n export class ${module.name} extends aptos.AptosBaseProcessor {\n static DEFAULT_OPTIONS: aptos.NamedAptosBindOptions = {\n address: \"${module.address}\",\n network: aptos.AptosNetwork.TEST_NET \n }\n static bind(options = ${module.name}.DEFAULT_OPTIONS): ${module.name} {\n return new ${module.name}({ ...options, name: \"${module.name}\" })\n }\n \n ${functions.join('\\n')}\n \n ${events.join('\\n')}\n }`\n}\n\nfunction generateOnEntryFunctions(module: MoveModule, func: MoveFunction) {\n if (!func.is_entry) {\n return ''\n }\n\n const camelFuncName = capitalizeFirstChar(camelize(func.name))\n const source = `\n onEntry${camelFuncName}(func: (call: aptos.TransactionPayload_EntryFunctionPayload, ctx: aptos.AptosContext) => void): ${module.name} {\n this.onEntryFunctionCall(func, {\n function: '${module.name}::${func.name}'\n })\n return this\n }`\n\n return source\n}\n\nfunction generateOnEvents(module: MoveModule, struct: MoveStruct): string {\n // for struct that has drop + store\n if (!struct.abilities.includes('drop') || !struct.abilities.includes('store') || !struct.name.endsWith('Event')) {\n return ''\n }\n const source = `\n onEvent${struct.name}(func: (event: aptos.Event, 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"]}
|
package/lib/cli/build.js
CHANGED
|
@@ -48,7 +48,8 @@ function codeGenAptosProcessor(abisDir, outDir = 'src/types/aptos') {
|
|
|
48
48
|
fs_1.default.mkdirSync(outDir, { recursive: true });
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
const codegen = new codegen_1.AptosCodegen(
|
|
51
|
+
const codegen = new codegen_1.AptosCodegen({
|
|
52
|
+
srcFile: path_1.default.join(abisDir, file),
|
|
52
53
|
outputDir: outDir,
|
|
53
54
|
});
|
|
54
55
|
codegen.generate();
|
package/lib/cli/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/cli/build.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AACzB,gDAAuB;AACvB,4CAAmB;AACnB,iDAAoC;AACpC,sDAAuD;AACvD,iDAAiD;AAE1C,KAAK,UAAU,c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G,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAA;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAChB;IAED,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACjC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAEjC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC5B,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;IAEF,IAAI,KAAK,CAAC,QAAQ,EAAE;QAClB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAA;QAC9C,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;KAC7B;IACD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAA;IAC9C,OAAO,CAAC,GAAG,EAAE,CAAA;AACf,CAAC","sourcesContent":["import chalk from 'chalk'\nimport path from 'path'\nimport fs from 'fs'\nimport { exec } from 'child_process'\nimport { AptosCodegen } from '../aptos-codegen/codegen'\n// import { EVM, SOLANA, Target } from './config'\n\nexport async function buildProcessor(onlyGen: boolean) {\n if (!onlyGen) {\n await installDeps()\n }\n\n // targets.forEach(async (target) => await buildProcessorForTarget(onlyGen, target))\n // for (const target) {\n await buildProcessorForTarget(onlyGen)\n // }\n\n if (!onlyGen) {\n const WEBPACK_CONFIG = path.join(__dirname, 'webpack.config.js')\n await execStep('yarn tsc -p .', 'Compile')\n await execStep('yarn webpack --config=' + WEBPACK_CONFIG, 'Packaging')\n }\n}\n\nasync function buildProcessorForTarget(onlyGen: boolean) {\n await codeGenEthersProcessor(path.join('abis', 'evm'))\n codeGenSolanaProcessor(path.join('abis', 'solana'))\n codeGenAptosProcessor(path.join('abis', 'aptos'))\n\n if (onlyGen) {\n return\n }\n}\n\nasync function installDeps() {\n await execStep('yarn install --ignore-scripts', 'Yarn Install')\n}\n\nexport function codeGenAptosProcessor(abisDir: string, outDir = 'src/types/aptos') {\n if (!fs.existsSync(abisDir)) {\n return\n }\n\n const files = fs.readdirSync(abisDir)\n\n console.log(chalk.green('Generated Types for Aptos'))\n for (const file of files) {\n if (path.extname(file) === '.json') {\n if (!fs.existsSync(outDir)) {\n fs.mkdirSync(outDir, { recursive: true })\n }\n }\n const codegen = new AptosCodegen(path.join(abisDir, file), {\n outputDir: outDir,\n })\n codegen.generate()\n }\n}\n\nexport async function codeGenEthersProcessor(\n abisDir: string,\n ETHERS_TARGET = path.join(__dirname, '../target-ethers-sentio'),\n outDir = 'src/types/internal'\n) {\n if (!fs.existsSync(abisDir)) {\n return\n }\n\n let haveJson = false\n const files = fs.readdirSync(abisDir)\n for (const file of files) {\n if (file.toLowerCase().endsWith('.json')) {\n haveJson = true\n break\n }\n }\n if (!haveJson) {\n return\n }\n\n console.log(chalk.green('Generated Types for EVM'))\n\n // TODO this will fail during postinstall, need to locate real typechain path\n await execStep(\n 'yarn typechain --target ' + ETHERS_TARGET + ` --out-dir ${outDir} ${path.join(abisDir, '*.json')}`,\n 'Type definitions gen'\n )\n}\n\nexport function codeGenSolanaProcessor(abisDir: string, targetPath = path.join('src', 'types', 'solana')) {\n if (!fs.existsSync(abisDir)) {\n return\n }\n\n const abisFiles = fs.readdirSync(abisDir)\n\n if (abisFiles.length > 0) {\n console.log(chalk.green('Generated Types for Solana'))\n }\n\n for (const file of abisFiles) {\n if (path.extname(file) === '.json') {\n if (!fs.existsSync(targetPath)) {\n fs.mkdirSync(targetPath, { recursive: true })\n }\n const idlContent = fs.readFileSync(path.join(abisDir, file), 'utf-8')\n const idlObj = JSON.parse(idlContent)\n const idlName = idlObj.name\n const idlFile = path.join(targetPath, idlName + '.ts')\n fs.writeFileSync(idlFile, `export const ${idlName}_idl = ${idlContent}`)\n fs.writeFileSync(path.join(targetPath, `${idlName}_processor.ts`), codeGenSolanaIdlProcessor(idlObj))\n }\n }\n}\n\nfunction codeGenSolanaIdlProcessor(idlObj: any): string {\n const idlName = idlObj.name\n const idlNamePascalCase = toPascalCase(idlName)\n const instructions: any[] = idlObj.instructions\n return `import { BorshInstructionCoder, Instruction, Idl, BN } from '@project-serum/anchor'\nimport { SolanaBaseProcessor, SolanaContext, SolanaBindOptions } from \"@sentio/sdk\"\nimport { ${idlName}_idl } from \"./${idlName}\"\nimport bs58 from 'bs58'\nimport { PublicKey } from '@solana/web3.js'\n\nexport class ${idlNamePascalCase}Processor extends SolanaBaseProcessor {\n static bind(options: SolanaBindOptions): ${idlNamePascalCase}Processor {\n if (options && !options.name) {\n options.name = '${idlNamePascalCase}'\n }\n return new ${idlNamePascalCase}Processor(options)\n }\n\n decodeInstruction: (rawInstruction: string) => Instruction | null = (rawInstruction) => {\n const instructionCoder = new BorshInstructionCoder(${idlName}_idl as Idl)\n const decodedIns = instructionCoder.decode(Buffer.from(bs58.decode(rawInstruction)))\n return decodedIns\n }\n\n ${instructions.map((ins) => codeGenSolanaInstruction(idlNamePascalCase, ins)).join('')}\n}\n `\n}\n\nfunction codeGenSolanaInstruction(idlName: string, ins: any): string {\n const instructionName = ins.name\n const argsTypeString = codeGenInstructionArgs(ins.args)\n return `\n on${\n instructionName.charAt(0).toUpperCase() + instructionName.slice(1)\n }(handler: (args: ${argsTypeString}, ctx: SolanaContext) => void): ${idlName}Processor {\n this.onInstruction('${instructionName}', (ins: Instruction, ctx) => {\n if (ins) {\n handler(ins.data as ${argsTypeString}, ctx)\n }\n })\n return this\n }\n `\n}\n\nfunction codeGenInstructionArgs(args: { name: string; type: string }[]): string {\n return `{ ${args.map((arg) => arg.name + ': ' + mapType(arg.type)).join(', ')} }`\n}\n\n// Reference: https://github.com/coral-xyz/anchor/blob/93332766f13e86efbe77c9986722731742317ede/ts/src/program/namespace/types.ts#L104\nfunction mapType(tpe: string): string {\n switch (tpe) {\n case 'publicKey':\n return 'PublicKey'\n case 'bool':\n return 'boolean'\n case 'string':\n return 'string'\n case 'u8':\n case 'i8':\n case 'u16':\n case 'i16':\n case 'u32':\n case 'i32':\n case 'f32':\n case 'f64':\n return 'number'\n case 'u64':\n case 'i64':\n case 'u128':\n case 'i128':\n return 'BN'\n default:\n return 'any'\n }\n}\n\nfunction toPascalCase(str: string) {\n return `${str}`\n .toLowerCase()\n .replace(new RegExp(/[-_]+/, 'g'), ' ')\n .replace(new RegExp(/[^\\w\\s]/, 'g'), '')\n .replace(new RegExp(/\\s+(.)(\\w*)/, 'g'), ($1, $2, $3) => `${$2.toUpperCase() + $3}`)\n .replace(new RegExp(/\\w/), (s) => s.toUpperCase())\n}\n\nasync function execStep(cmd: string, stepName: string) {\n const child = exec(cmd)\n console.log(chalk.blue(stepName + ' begin'))\n\n if (!child.stdout || !child.stderr) {\n console.error(chalk.red(stepName + ' failed'))\n process.exit(1)\n }\n\n child.stdout.pipe(process.stdout)\n child.stderr.pipe(process.stderr)\n\n await new Promise((resolve) => {\n child.on('close', resolve)\n })\n\n if (child.exitCode) {\n console.error(chalk.red(stepName + ' failed'))\n process.exit(child.exitCode)\n }\n console.log(chalk.blue(stepName + ' success'))\n console.log()\n}\n"]}
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/cli/build.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AACzB,gDAAuB;AACvB,4CAAmB;AACnB,iDAAoC;AACpC,sDAAuD;AACvD,iDAAiD;AAE1C,KAAK,UAAU,cAAc,CAAC,OAAgB;IACnD,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,WAAW,EAAE,CAAA;KACpB;IAED,oFAAoF;IACpF,uBAAuB;IACvB,MAAM,uBAAuB,CAAC,OAAO,CAAC,CAAA;IACtC,IAAI;IAEJ,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,cAAc,GAAG,cAAI,CAAC,IA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MAAM,CAAC,CAAA;IAEjC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC5B,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;IAEF,IAAI,KAAK,CAAC,QAAQ,EAAE;QAClB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAA;QAC9C,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;KAC7B;IACD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAA;IAC9C,OAAO,CAAC,GAAG,EAAE,CAAA;AACf,CAAC","sourcesContent":["import chalk from 'chalk'\nimport path from 'path'\nimport fs from 'fs'\nimport { exec } from 'child_process'\nimport { AptosCodegen } from '../aptos-codegen/codegen'\n// import { EVM, SOLANA, Target } from './config'\n\nexport async function buildProcessor(onlyGen: boolean) {\n if (!onlyGen) {\n await installDeps()\n }\n\n // targets.forEach(async (target) => await buildProcessorForTarget(onlyGen, target))\n // for (const target) {\n await buildProcessorForTarget(onlyGen)\n // }\n\n if (!onlyGen) {\n const WEBPACK_CONFIG = path.join(__dirname, 'webpack.config.js')\n await execStep('yarn tsc -p .', 'Compile')\n await execStep('yarn webpack --config=' + WEBPACK_CONFIG, 'Packaging')\n }\n}\n\nasync function buildProcessorForTarget(onlyGen: boolean) {\n await codeGenEthersProcessor(path.join('abis', 'evm'))\n codeGenSolanaProcessor(path.join('abis', 'solana'))\n codeGenAptosProcessor(path.join('abis', 'aptos'))\n\n if (onlyGen) {\n return\n }\n}\n\nasync function installDeps() {\n await execStep('yarn install --ignore-scripts', 'Yarn Install')\n}\n\nexport function codeGenAptosProcessor(abisDir: string, outDir = 'src/types/aptos') {\n if (!fs.existsSync(abisDir)) {\n return\n }\n\n const files = fs.readdirSync(abisDir)\n\n console.log(chalk.green('Generated Types for Aptos'))\n for (const file of files) {\n if (path.extname(file) === '.json') {\n if (!fs.existsSync(outDir)) {\n fs.mkdirSync(outDir, { recursive: true })\n }\n }\n const codegen = new AptosCodegen({\n srcFile: path.join(abisDir, file),\n outputDir: outDir,\n })\n codegen.generate()\n }\n}\n\nexport async function codeGenEthersProcessor(\n abisDir: string,\n ETHERS_TARGET = path.join(__dirname, '../target-ethers-sentio'),\n outDir = 'src/types/internal'\n) {\n if (!fs.existsSync(abisDir)) {\n return\n }\n\n let haveJson = false\n const files = fs.readdirSync(abisDir)\n for (const file of files) {\n if (file.toLowerCase().endsWith('.json')) {\n haveJson = true\n break\n }\n }\n if (!haveJson) {\n return\n }\n\n console.log(chalk.green('Generated Types for EVM'))\n\n // TODO this will fail during postinstall, need to locate real typechain path\n await execStep(\n 'yarn typechain --target ' + ETHERS_TARGET + ` --out-dir ${outDir} ${path.join(abisDir, '*.json')}`,\n 'Type definitions gen'\n )\n}\n\nexport function codeGenSolanaProcessor(abisDir: string, targetPath = path.join('src', 'types', 'solana')) {\n if (!fs.existsSync(abisDir)) {\n return\n }\n\n const abisFiles = fs.readdirSync(abisDir)\n\n if (abisFiles.length > 0) {\n console.log(chalk.green('Generated Types for Solana'))\n }\n\n for (const file of abisFiles) {\n if (path.extname(file) === '.json') {\n if (!fs.existsSync(targetPath)) {\n fs.mkdirSync(targetPath, { recursive: true })\n }\n const idlContent = fs.readFileSync(path.join(abisDir, file), 'utf-8')\n const idlObj = JSON.parse(idlContent)\n const idlName = idlObj.name\n const idlFile = path.join(targetPath, idlName + '.ts')\n fs.writeFileSync(idlFile, `export const ${idlName}_idl = ${idlContent}`)\n fs.writeFileSync(path.join(targetPath, `${idlName}_processor.ts`), codeGenSolanaIdlProcessor(idlObj))\n }\n }\n}\n\nfunction codeGenSolanaIdlProcessor(idlObj: any): string {\n const idlName = idlObj.name\n const idlNamePascalCase = toPascalCase(idlName)\n const instructions: any[] = idlObj.instructions\n return `import { BorshInstructionCoder, Instruction, Idl, BN } from '@project-serum/anchor'\nimport { SolanaBaseProcessor, SolanaContext, SolanaBindOptions } from \"@sentio/sdk\"\nimport { ${idlName}_idl } from \"./${idlName}\"\nimport bs58 from 'bs58'\nimport { PublicKey } from '@solana/web3.js'\n\nexport class ${idlNamePascalCase}Processor extends SolanaBaseProcessor {\n static bind(options: SolanaBindOptions): ${idlNamePascalCase}Processor {\n if (options && !options.name) {\n options.name = '${idlNamePascalCase}'\n }\n return new ${idlNamePascalCase}Processor(options)\n }\n\n decodeInstruction: (rawInstruction: string) => Instruction | null = (rawInstruction) => {\n const instructionCoder = new BorshInstructionCoder(${idlName}_idl as Idl)\n const decodedIns = instructionCoder.decode(Buffer.from(bs58.decode(rawInstruction)))\n return decodedIns\n }\n\n ${instructions.map((ins) => codeGenSolanaInstruction(idlNamePascalCase, ins)).join('')}\n}\n `\n}\n\nfunction codeGenSolanaInstruction(idlName: string, ins: any): string {\n const instructionName = ins.name\n const argsTypeString = codeGenInstructionArgs(ins.args)\n return `\n on${\n instructionName.charAt(0).toUpperCase() + instructionName.slice(1)\n }(handler: (args: ${argsTypeString}, ctx: SolanaContext) => void): ${idlName}Processor {\n this.onInstruction('${instructionName}', (ins: Instruction, ctx) => {\n if (ins) {\n handler(ins.data as ${argsTypeString}, ctx)\n }\n })\n return this\n }\n `\n}\n\nfunction codeGenInstructionArgs(args: { name: string; type: string }[]): string {\n return `{ ${args.map((arg) => arg.name + ': ' + mapType(arg.type)).join(', ')} }`\n}\n\n// Reference: https://github.com/coral-xyz/anchor/blob/93332766f13e86efbe77c9986722731742317ede/ts/src/program/namespace/types.ts#L104\nfunction mapType(tpe: string): string {\n switch (tpe) {\n case 'publicKey':\n return 'PublicKey'\n case 'bool':\n return 'boolean'\n case 'string':\n return 'string'\n case 'u8':\n case 'i8':\n case 'u16':\n case 'i16':\n case 'u32':\n case 'i32':\n case 'f32':\n case 'f64':\n return 'number'\n case 'u64':\n case 'i64':\n case 'u128':\n case 'i128':\n return 'BN'\n default:\n return 'any'\n }\n}\n\nfunction toPascalCase(str: string) {\n return `${str}`\n .toLowerCase()\n .replace(new RegExp(/[-_]+/, 'g'), ' ')\n .replace(new RegExp(/[^\\w\\s]/, 'g'), '')\n .replace(new RegExp(/\\s+(.)(\\w*)/, 'g'), ($1, $2, $3) => `${$2.toUpperCase() + $3}`)\n .replace(new RegExp(/\\w/), (s) => s.toUpperCase())\n}\n\nasync function execStep(cmd: string, stepName: string) {\n const child = exec(cmd)\n console.log(chalk.blue(stepName + ' begin'))\n\n if (!child.stdout || !child.stderr) {\n console.error(chalk.red(stepName + ' failed'))\n process.exit(1)\n }\n\n child.stdout.pipe(process.stdout)\n child.stderr.pipe(process.stderr)\n\n await new Promise((resolve) => {\n child.on('close', resolve)\n })\n\n if (child.exitCode) {\n console.error(chalk.red(stepName + ' failed'))\n process.exit(child.exitCode)\n }\n console.log(chalk.blue(stepName + ' success'))\n console.log()\n}\n"]}
|
package/lib/tests/souffl3.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
|
|
3
|
+
const souffle_1 = require("./types/aptos/souffle");
|
|
4
|
+
souffle_1.SouffleChefCampaign.bind()
|
|
5
5
|
.onEntryPullTokenV2((call, ctx) => {
|
|
6
6
|
ctx.meter.Counter('call_num').add(1);
|
|
7
|
-
ctx.meter.Counter('pulled').add(parseInt(call.arguments[
|
|
7
|
+
ctx.meter.Counter('pulled').add(parseInt(call.arguments[3]));
|
|
8
8
|
})
|
|
9
9
|
.onEventBurnEnjoyEvent((evt, ctx) => {
|
|
10
10
|
ctx.meter.Counter('burned').add(1);
|
|
@@ -23,7 +23,7 @@ account_4188c8_1.SouffleChefCampaign.bind()
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
souffle_1.CandyMachine.bind().onEntryPullToken((call, ctx) => {
|
|
27
27
|
ctx.meter.Counter('pulled').add(parseInt(call.arguments[3]));
|
|
28
28
|
});
|
|
29
29
|
//# sourceMappingURL=souffl3.js.map
|
package/lib/tests/souffl3.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"souffl3.js","sourceRoot":"","sources":["../../src/tests/souffl3.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"souffl3.js","sourceRoot":"","sources":["../../src/tests/souffl3.ts"],"names":[],"mappings":";;AAAA,mDAAyE;AAEzE,6BAAmB,CAAC,IAAI,EAAE;KACvB,kBAAkB,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;IAChC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IACpC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9D,CAAC,CAAC;KACD,qBAAqB,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;IAClC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AACpC,CAAC,CAAC;KACD,OAAO,CACN,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACb,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AACrC,CAAC,EACD;IACE,IAAI,EAAE,yBAAyB;CAChC,CACF;KACA,aAAa,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;IAC1B,IAAI,GAAG,CAAC,MAAM,EAAE;QACd,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE;YAC9B,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,0BAA0B,EAAE;gBACtD,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;aACxE;SACF;KACF;AACH,CAAC,CAAC,CAAA;AAEJ,sBAAY,CAAC,IAAI,EAAE,CAAC,gBAAgB,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;IACjD,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9D,CAAC,CAAC,CAAA","sourcesContent":["import { SouffleChefCampaign, CandyMachine } from './types/aptos/souffle'\n\nSouffleChefCampaign.bind()\n .onEntryPullTokenV2((call, ctx) => {\n ctx.meter.Counter('call_num').add(1)\n ctx.meter.Counter('pulled').add(parseInt(call.arguments[3]))\n })\n .onEventBurnEnjoyEvent((evt, ctx) => {\n ctx.meter.Counter('burned').add(1)\n })\n .onEvent(\n (event, ctx) => {\n ctx.meter.Counter('evt_num').add(1)\n },\n {\n type: '0x1::coin::DepositEvent',\n }\n )\n .onTransaction((txn, ctx) => {\n if (txn.events) {\n for (const event of txn.events) {\n if (event && event.type === '0x3::token::DepositEvent') {\n ctx.meter.Counter('deposit_token_count').add(Number(event.data.amount))\n }\n }\n }\n })\n\nCandyMachine.bind().onEntryPullToken((call, ctx) => {\n ctx.meter.Counter('pulled').add(parseInt(call.arguments[3]))\n})\n"]}
|
|
File without changes
|
|
@@ -122,16 +122,16 @@ class SouffleChefCampaign extends sdk_1.aptos.AptosBaseProcessor {
|
|
|
122
122
|
}
|
|
123
123
|
onEventBurnEnjoyEvent(func) {
|
|
124
124
|
this.onEvent(func, {
|
|
125
|
-
type: "
|
|
125
|
+
type: "SouffleChefCampaign::BurnEnjoyEvent",
|
|
126
126
|
});
|
|
127
127
|
return this;
|
|
128
128
|
}
|
|
129
129
|
onEventPullTokenEvent(func) {
|
|
130
130
|
this.onEvent(func, {
|
|
131
|
-
type: "
|
|
131
|
+
type: "SouffleChefCampaign::PullTokenEvent",
|
|
132
132
|
});
|
|
133
133
|
return this;
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
exports.SouffleChefCampaign = SouffleChefCampaign;
|
|
137
|
-
//# sourceMappingURL=
|
|
137
|
+
//# sourceMappingURL=souffle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"souffle.js","sourceRoot":"","sources":["../../../../src/tests/types/aptos/souffle.ts"],"names":[],"mappings":";AAAA,+CAA+C;AAC/C,oBAAoB;AACpB,oBAAoB;;;AAEpB,sGAAsG;AAEtG,qCAAoC;AAEpC,MAAa,YAAa,SAAQ,WAAK,CAAC,kBAAkB;IACxD,MAAM,CAAC,eAAe,GAAgC;QACpD,OAAO,EACL,oEAAoE;QACtE,OAAO,EAAE,WAAK,CAAC,YAAY,CAAC,QAAQ;KACrC,CAAC;IACF,MAAM,CAAC,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC,eAAe;QAChD,OAAO,IAAI,YAAY,CAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,aAAa,CACX,IAGS;QAET,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE;YAC7B,QAAQ,EAAE,uBAAuB;SAClC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,yBAAyB,CACvB,IAGS;QAET,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE;YAC7B,QAAQ,EAAE,oCAAoC;SAC/C,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,uBAAuB,CACrB,IAGS;QAET,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE;YAC7B,QAAQ,EAAE,iCAAiC;SAC5C,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;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IAA2D;QAE3D,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;YACjB,IAAI,EAAE,qCAAqC;SAC5C,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;;AAhKH,kDAiKC","sourcesContent":["/* Autogenerated file. Do not edit manually. */\n/* tslint:disable */\n/* eslint-disable */\n\n/* Generated modules for account 0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807 */\n\nimport { aptos } from \"@sentio/sdk\";\n\nexport class CandyMachine extends aptos.AptosBaseProcessor {\n static DEFAULT_OPTIONS: aptos.NamedAptosBindOptions = {\n address:\n \"0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807\",\n network: aptos.AptosNetwork.TEST_NET,\n };\n static bind(options = CandyMachine.DEFAULT_OPTIONS): CandyMachine {\n return new CandyMachine({ ...options, name: \"CandyMachine\" });\n }\n\n onEntryAddAcl(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): CandyMachine {\n this.onEntryFunctionCall(func, {\n function: \"CandyMachine::add_acl\",\n });\n return this;\n }\n\n onEntryCreateCandyMachine(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): CandyMachine {\n this.onEntryFunctionCall(func, {\n function: \"CandyMachine::create_candy_machine\",\n });\n return this;\n }\n\n onEntryCreateCollection(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): CandyMachine {\n this.onEntryFunctionCall(func, {\n function: \"CandyMachine::create_collection\",\n });\n return this;\n }\n\n onEntryPullToken(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): CandyMachine {\n this.onEntryFunctionCall(func, {\n function: \"CandyMachine::pull_token\",\n });\n return this;\n }\n\n onEntryUpdateTokenProperty(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): CandyMachine {\n this.onEntryFunctionCall(func, {\n function: \"CandyMachine::update_token_property\",\n });\n return this;\n }\n}\n\nexport class SouffleChefCampaign extends aptos.AptosBaseProcessor {\n static DEFAULT_OPTIONS: aptos.NamedAptosBindOptions = {\n address:\n \"0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807\",\n network: aptos.AptosNetwork.TEST_NET,\n };\n static bind(\n options = SouffleChefCampaign.DEFAULT_OPTIONS\n ): SouffleChefCampaign {\n return new SouffleChefCampaign({ ...options, name: \"SouffleChefCampaign\" });\n }\n\n onEntryAddAcl(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::add_acl\",\n });\n return this;\n }\n\n onEntryAddBurnTokenRule(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::add_burn_token_rule\",\n });\n return this;\n }\n\n onEntryBatchAddAcl(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::batch_add_acl\",\n });\n return this;\n }\n\n onEntryBurnAndEnjoy(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::burn_and_enjoy\",\n });\n return this;\n }\n\n onEntryClaim(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::claim\",\n });\n return this;\n }\n\n onEntryCreateCandyMachine(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::create_candy_machine\",\n });\n return this;\n }\n\n onEntryCreateCollection(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::create_collection\",\n });\n return this;\n }\n\n onEntryPullToken(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::pull_token\",\n });\n return this;\n }\n\n onEntryPullTokenV2(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::pull_token_v2\",\n });\n return this;\n }\n\n onEntryRemoveBurnTokenRule(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::remove_burn_token_rule\",\n });\n return this;\n }\n\n onEntryUpdateTokenProperty(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::update_token_property\",\n });\n return this;\n }\n\n onEventBurnEnjoyEvent(\n func: (event: aptos.Event, ctx: aptos.AptosContext) => void\n ): SouffleChefCampaign {\n this.onEvent(func, {\n type: \"SouffleChefCampaign::BurnEnjoyEvent\",\n });\n return this;\n }\n\n onEventPullTokenEvent(\n func: (event: aptos.Event, ctx: aptos.AptosContext) => void\n ): SouffleChefCampaign {\n this.onEvent(func, {\n type: \"SouffleChefCampaign::PullTokenEvent\",\n });\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.20.
|
|
4
|
+
"version": "1.20.2",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"compile_target": "yarn tsc -b src/target-ethers-sentio/tsconfig.json",
|
|
7
7
|
"compile": "tsc -p . && cp src/cli/webpack.config.js lib/cli && cp src/utils/*.csv lib/utils",
|
|
@@ -20,15 +20,22 @@ type IndexConfigure = {
|
|
|
20
20
|
// endSeqNumber?: Long
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export interface EventFilter {
|
|
23
|
+
export interface EventFilter extends ArgumentsFilter {
|
|
24
24
|
type: string
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export interface CallFilter {
|
|
27
|
+
export interface CallFilter extends CallArgumentsFilter {
|
|
28
28
|
function: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface CallArgumentsFilter extends ArgumentsFilter {
|
|
29
32
|
typeArguments?: string[]
|
|
30
33
|
}
|
|
31
34
|
|
|
35
|
+
export interface ArgumentsFilter {
|
|
36
|
+
arguments?: string[]
|
|
37
|
+
}
|
|
38
|
+
|
|
32
39
|
class EventHandler {
|
|
33
40
|
filters: EventFilter[]
|
|
34
41
|
handler: (event: Event) => Promise<ProcessResult>
|
|
@@ -6,6 +6,7 @@ import { MoveStruct } from 'aptos/src/generated/models/MoveStruct'
|
|
|
6
6
|
import prettier from 'prettier'
|
|
7
7
|
|
|
8
8
|
interface Config {
|
|
9
|
+
srcFile: string
|
|
9
10
|
outputDir: string
|
|
10
11
|
}
|
|
11
12
|
|
|
@@ -13,8 +14,8 @@ export class AptosCodegen {
|
|
|
13
14
|
modules: MoveModuleBytecode[]
|
|
14
15
|
config: Config
|
|
15
16
|
|
|
16
|
-
constructor(
|
|
17
|
-
const json = fs.readFileSync(srcFile, 'utf-8')
|
|
17
|
+
constructor(config: Config) {
|
|
18
|
+
const json = fs.readFileSync(config.srcFile, 'utf-8')
|
|
18
19
|
this.modules = JSON.parse(json)
|
|
19
20
|
this.config = config
|
|
20
21
|
}
|
|
@@ -47,8 +48,9 @@ export class AptosCodegen {
|
|
|
47
48
|
${this.modules.map(generateModule).join('\n')}
|
|
48
49
|
` // source
|
|
49
50
|
|
|
51
|
+
const baseName = path.basename(this.config.srcFile, '.json')
|
|
50
52
|
source = prettier.format(source, { parser: 'typescript' })
|
|
51
|
-
fs.writeFileSync(path.join(this.config.outputDir,
|
|
53
|
+
fs.writeFileSync(path.join(this.config.outputDir, baseName + '.ts'), source)
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
|
|
@@ -102,7 +104,7 @@ function generateOnEvents(module: MoveModule, struct: MoveStruct): string {
|
|
|
102
104
|
const source = `
|
|
103
105
|
onEvent${struct.name}(func: (event: aptos.Event, ctx: aptos.AptosContext) => void): ${module.name} {
|
|
104
106
|
this.onEvent(func, {
|
|
105
|
-
type: '${module.
|
|
107
|
+
type: '${module.name}::${struct.name}'
|
|
106
108
|
})
|
|
107
109
|
return this
|
|
108
110
|
}
|
|
@@ -5,7 +5,7 @@ describe('Test Aptos Example', () => {
|
|
|
5
5
|
test.skip('code gen for aptos', async () => {
|
|
6
6
|
const filename = path.join(__dirname, '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807')
|
|
7
7
|
|
|
8
|
-
const codegen = new AptosCodegen(filename,
|
|
8
|
+
const codegen = new AptosCodegen({ srcFile: filename, outputDir: path.join(__dirname, '..') })
|
|
9
9
|
codegen.generate()
|
|
10
10
|
})
|
|
11
11
|
})
|
package/src/cli/build.ts
CHANGED
|
@@ -50,7 +50,8 @@ export function codeGenAptosProcessor(abisDir: string, outDir = 'src/types/aptos
|
|
|
50
50
|
fs.mkdirSync(outDir, { recursive: true })
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
const codegen = new AptosCodegen(
|
|
53
|
+
const codegen = new AptosCodegen({
|
|
54
|
+
srcFile: path.join(abisDir, file),
|
|
54
55
|
outputDir: outDir,
|
|
55
56
|
})
|
|
56
57
|
codegen.generate()
|
|
File without changes
|
package/src/tests/souffl3.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { SouffleChefCampaign, CandyMachine } from './types/aptos/
|
|
1
|
+
import { SouffleChefCampaign, CandyMachine } from './types/aptos/souffle'
|
|
2
2
|
|
|
3
3
|
SouffleChefCampaign.bind()
|
|
4
4
|
.onEntryPullTokenV2((call, ctx) => {
|
|
5
5
|
ctx.meter.Counter('call_num').add(1)
|
|
6
|
-
ctx.meter.Counter('pulled').add(parseInt(call.arguments[
|
|
6
|
+
ctx.meter.Counter('pulled').add(parseInt(call.arguments[3]))
|
|
7
7
|
})
|
|
8
8
|
.onEventBurnEnjoyEvent((evt, ctx) => {
|
|
9
9
|
ctx.meter.Counter('burned').add(1)
|
|
@@ -225,7 +225,7 @@ export class SouffleChefCampaign extends aptos.AptosBaseProcessor {
|
|
|
225
225
|
func: (event: aptos.Event, ctx: aptos.AptosContext) => void
|
|
226
226
|
): SouffleChefCampaign {
|
|
227
227
|
this.onEvent(func, {
|
|
228
|
-
type: "
|
|
228
|
+
type: "SouffleChefCampaign::BurnEnjoyEvent",
|
|
229
229
|
});
|
|
230
230
|
return this;
|
|
231
231
|
}
|
|
@@ -234,7 +234,7 @@ export class SouffleChefCampaign extends aptos.AptosBaseProcessor {
|
|
|
234
234
|
func: (event: aptos.Event, ctx: aptos.AptosContext) => void
|
|
235
235
|
): SouffleChefCampaign {
|
|
236
236
|
this.onEvent(func, {
|
|
237
|
-
type: "
|
|
237
|
+
type: "SouffleChefCampaign::PullTokenEvent",
|
|
238
238
|
});
|
|
239
239
|
return this;
|
|
240
240
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"account-4188c8.js","sourceRoot":"","sources":["../../../../src/tests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,mBAAmB,CAAC,IAAI,EAAE;YAC7B,QAAQ,EAAE,wCAAwC;SACnD,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gBAAgB,CACd,IAGS;QAET,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE;YAC7B,QAAQ,EAAE,iCAAiC;SAC5C,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,kBAAkB,CAChB,IAGS;QAET,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE;YAC7B,QAAQ,EAAE,oCAAoC;SAC/C,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,0BAA0B,CACxB,IAGS;QAET,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE;YAC7B,QAAQ,EAAE,6CAA6C;SACxD,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,0BAA0B,CACxB,IAGS;QAET,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE;YAC7B,QAAQ,EAAE,4CAA4C;SACvD,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,qBAAqB,CACnB,IAA2D;QAE3D,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;YACjB,IAAI,EAAE,yGAAyG;SAChH,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,qBAAqB,CACnB,IAA2D;QAE3D,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;YACjB,IAAI,EAAE,yGAAyG;SAChH,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;;AAhKH,kDAiKC","sourcesContent":["/* Autogenerated file. Do not edit manually. */\n/* tslint:disable */\n/* eslint-disable */\n\n/* Generated modules for account 0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807 */\n\nimport { aptos } from \"@sentio/sdk\";\n\nexport class CandyMachine extends aptos.AptosBaseProcessor {\n static DEFAULT_OPTIONS: aptos.NamedAptosBindOptions = {\n address:\n \"0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807\",\n network: aptos.AptosNetwork.TEST_NET,\n };\n static bind(options = CandyMachine.DEFAULT_OPTIONS): CandyMachine {\n return new CandyMachine({ ...options, name: \"CandyMachine\" });\n }\n\n onEntryAddAcl(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): CandyMachine {\n this.onEntryFunctionCall(func, {\n function: \"CandyMachine::add_acl\",\n });\n return this;\n }\n\n onEntryCreateCandyMachine(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): CandyMachine {\n this.onEntryFunctionCall(func, {\n function: \"CandyMachine::create_candy_machine\",\n });\n return this;\n }\n\n onEntryCreateCollection(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): CandyMachine {\n this.onEntryFunctionCall(func, {\n function: \"CandyMachine::create_collection\",\n });\n return this;\n }\n\n onEntryPullToken(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): CandyMachine {\n this.onEntryFunctionCall(func, {\n function: \"CandyMachine::pull_token\",\n });\n return this;\n }\n\n onEntryUpdateTokenProperty(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): CandyMachine {\n this.onEntryFunctionCall(func, {\n function: \"CandyMachine::update_token_property\",\n });\n return this;\n }\n}\n\nexport class SouffleChefCampaign extends aptos.AptosBaseProcessor {\n static DEFAULT_OPTIONS: aptos.NamedAptosBindOptions = {\n address:\n \"0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807\",\n network: aptos.AptosNetwork.TEST_NET,\n };\n static bind(\n options = SouffleChefCampaign.DEFAULT_OPTIONS\n ): SouffleChefCampaign {\n return new SouffleChefCampaign({ ...options, name: \"SouffleChefCampaign\" });\n }\n\n onEntryAddAcl(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::add_acl\",\n });\n return this;\n }\n\n onEntryAddBurnTokenRule(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::add_burn_token_rule\",\n });\n return this;\n }\n\n onEntryBatchAddAcl(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::batch_add_acl\",\n });\n return this;\n }\n\n onEntryBurnAndEnjoy(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::burn_and_enjoy\",\n });\n return this;\n }\n\n onEntryClaim(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::claim\",\n });\n return this;\n }\n\n onEntryCreateCandyMachine(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::create_candy_machine\",\n });\n return this;\n }\n\n onEntryCreateCollection(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::create_collection\",\n });\n return this;\n }\n\n onEntryPullToken(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::pull_token\",\n });\n return this;\n }\n\n onEntryPullTokenV2(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::pull_token_v2\",\n });\n return this;\n }\n\n onEntryRemoveBurnTokenRule(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::remove_burn_token_rule\",\n });\n return this;\n }\n\n onEntryUpdateTokenProperty(\n func: (\n call: aptos.TransactionPayload_EntryFunctionPayload,\n ctx: aptos.AptosContext\n ) => void\n ): SouffleChefCampaign {\n this.onEntryFunctionCall(func, {\n function: \"SouffleChefCampaign::update_token_property\",\n });\n return this;\n }\n\n onEventBurnEnjoyEvent(\n func: (event: aptos.Event, ctx: aptos.AptosContext) => void\n ): SouffleChefCampaign {\n this.onEvent(func, {\n type: \"0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807::SouffleChefCampaign::BurnEnjoyEvent\",\n });\n return this;\n }\n\n onEventPullTokenEvent(\n func: (event: aptos.Event, ctx: aptos.AptosContext) => void\n ): SouffleChefCampaign {\n this.onEvent(func, {\n type: \"0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807::SouffleChefCampaign::PullTokenEvent\",\n });\n return this;\n }\n}\n"]}
|