@sentio/sdk 1.21.0 → 1.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,13 +7,14 @@ declare type IndexConfigure = {
7
7
  network: AptosNetwork;
8
8
  startVersion: Long;
9
9
  };
10
- export interface EventFilter extends ArgumentsFilter {
10
+ export interface EventFilter {
11
11
  type: string;
12
12
  }
13
- export interface CallFilter extends CallArgumentsFilter {
13
+ export interface FunctionNameAndCallFilter extends CallFilter {
14
14
  function: string;
15
15
  }
16
- export interface CallArgumentsFilter extends ArgumentsFilter {
16
+ export interface CallFilter {
17
+ includeFailed?: boolean;
17
18
  typeArguments?: string[];
18
19
  }
19
20
  export interface ArgumentsFilter {
@@ -24,7 +25,7 @@ declare class EventHandler {
24
25
  handler: (event: EventInstance) => Promise<ProcessResult>;
25
26
  }
26
27
  declare class CallHandler {
27
- filters: CallFilter[];
28
+ filters: FunctionNameAndCallFilter[];
28
29
  handler: (call: Transaction_UserTransaction) => Promise<ProcessResult>;
29
30
  }
30
31
  export declare class AptosBaseProcessor {
@@ -35,7 +36,7 @@ export declare class AptosBaseProcessor {
35
36
  constructor(moduleName: string, options: AptosBindOptions);
36
37
  onTransaction(handler: (transaction: Transaction_UserTransaction, ctx: AptosContext) => void): AptosBaseProcessor;
37
38
  onEvent(handler: (event: EventInstance, ctx: AptosContext) => void, filter: EventFilter | EventFilter[]): AptosBaseProcessor;
38
- onEntryFunctionCall(handler: (call: TransactionPayload_EntryFunctionPayload, ctx: AptosContext) => void, filter: CallFilter | CallFilter[]): AptosBaseProcessor;
39
+ onEntryFunctionCall(handler: (call: TransactionPayload_EntryFunctionPayload, ctx: AptosContext) => void, filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[]): AptosBaseProcessor;
39
40
  private configure;
40
41
  getChainId(): string;
41
42
  loadTypes(registry: TypeRegistry): void;
@@ -1 +1 @@
1
- {"version":3,"file":"aptos-processor.js","sourceRoot":"","sources":["../../src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AC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;gBACnD,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAA;aACnD;SACF;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;YACrD,OAAO,OAAO,CAAA;SACf;QAED,OAAO,EAAE,GAAG,OAAO,EAAE,eAAe,EAAE,cAAc,EAAoC,CAAA;IAC1F,CAAC;CACF;AApLD,gDAoLC","sourcesContent":["import { ProcessResult } from '../gen'\nimport {\n AptosBindOptions,\n AptosContext,\n AptosNetwork,\n Transaction_UserTransaction,\n TransactionPayload_EntryFunctionPayload,\n TypedEntryFunctionPayload,\n TypedEventInstance,\n TypeRegistry,\n} from '.'\n\nimport Long from 'long'\nimport { APTOS_MAINNET_ID, APTOS_TESTNET_ID } from '../utils/chain'\nimport { EventInstance, GLOBAL_TYPE_REGISTRY } from './types'\nimport { parseMoveType } from '../aptos-codegen/typegen'\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: EventInstance) => Promise<ProcessResult>\n}\n\nclass CallHandler {\n filters: CallFilter[]\n handler: (call: Transaction_UserTransaction) => Promise<ProcessResult>\n}\n\nexport class AptosBaseProcessor {\n readonly moduleName: string\n config: IndexConfigure\n eventHandlers: EventHandler[] = []\n callHandlers: CallHandler[] = []\n\n constructor(moduleName: string, options: AptosBindOptions) {\n this.moduleName = moduleName\n this.configure(options)\n global.PROCESSOR_STATE.aptosProcessors.push(this)\n }\n\n // getABI(): MoveModule | undefined {\n // return undefined\n // }\n\n public onTransaction(\n handler: (transaction: Transaction_UserTransaction, ctx: AptosContext) => void\n ): AptosBaseProcessor {\n const address = this.config.address\n const moduleName = this.moduleName\n this.callHandlers.push({\n handler: async function (tx) {\n const ctx = new AptosContext(moduleName, 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: EventInstance, 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 // const moduleName = this.moduleName\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const processor = this\n\n this.eventHandlers.push({\n handler: async function (event) {\n const ctx = new AptosContext(processor.moduleName, processor.config.address, Long.fromString(event.version))\n if (event) {\n const decoded = processor.decodeEvent(event)\n handler(decoded, 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 // const moduleName = this.moduleName\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const processor = this\n\n this.callHandlers.push({\n handler: async function (tx) {\n const ctx = new AptosContext(processor.moduleName, processor.config.address, Long.fromString(tx.version), tx)\n if (tx) {\n const payload = tx.payload as TransactionPayload_EntryFunctionPayload\n const decoded = processor.decodeFunctionPayload(payload)\n handler(decoded, 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 loadTypes(registry: TypeRegistry) {\n if (registry.contains(this.config.address, this.moduleName)) {\n return\n }\n this.loadTypesInternal(registry)\n }\n\n protected loadTypesInternal(registry: TypeRegistry) {\n // should be override by subclass\n }\n\n private decodeEvent(event: EventInstance): EventInstance {\n const registry = GLOBAL_TYPE_REGISTRY\n this.loadTypes(registry)\n // TODO check if module is not loaded\n\n let dataTyped = undefined\n try {\n dataTyped = registry.decode(event.data, parseMoveType(event.type))\n } catch (e) {\n console.warn('Decoding error for ', event.type)\n return event\n }\n\n return { ...event, data_typed: dataTyped } as TypedEventInstance<any>\n }\n\n private decodeFunctionPayload(\n payload: TransactionPayload_EntryFunctionPayload\n ): TransactionPayload_EntryFunctionPayload {\n const registry = GLOBAL_TYPE_REGISTRY\n this.loadTypes(registry)\n const argumentsTyped: any[] = []\n\n try {\n const func = registry.getMoveFunction(payload.function)\n for (const [idx, arg] of payload.arguments.entries()) {\n // TODO consider apply payload.type_arguments, but this might be hard since we don't code gen for them\n const argType = parseMoveType(func.params[idx + 1])\n argumentsTyped.push(registry.decode(arg, argType))\n }\n } catch (e) {\n console.warn('Decoding error for ', payload.function)\n return payload\n }\n\n return { ...payload, arguments_typed: argumentsTyped } as TypedEntryFunctionPayload<any>\n }\n}\n"]}
1
+ {"version":3,"file":"aptos-processor.js","sourceRoot":"","sources":["../../src/aptos/aptos-processor.ts"],"names":[],"mappings":";;;;;;AACA,wBASU;AAEV,gDAAuB;AACv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AAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAA;aACnD;SACF;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;YACrD,OAAO,OAAO,CAAA;SACf;QAED,OAAO,EAAE,GAAG,OAAO,EAAE,eAAe,EAAE,cAAc,EAAoC,CAAA;IAC1F,CAAC;CACF;AApLD,gDAoLC","sourcesContent":["import { ProcessResult, RecordMetaData } from '../gen'\nimport {\n AptosBindOptions,\n AptosContext,\n AptosNetwork,\n Transaction_UserTransaction,\n TransactionPayload_EntryFunctionPayload,\n TypedEntryFunctionPayload,\n TypedEventInstance,\n TypeRegistry,\n} from '.'\n\nimport Long from 'long'\nimport { APTOS_MAINNET_ID, APTOS_TESTNET_ID } from '../utils/chain'\nimport { EventInstance, GLOBAL_TYPE_REGISTRY } from './types'\nimport { parseMoveType } from '../aptos-codegen/typegen'\n\ntype IndexConfigure = {\n address: string\n network: AptosNetwork\n startVersion: Long\n // endSeqNumber?: Long\n}\n\n// TODO extends ArgumentsFilter\nexport interface EventFilter {\n type: string\n}\n\nexport interface FunctionNameAndCallFilter extends CallFilter {\n function: string\n}\n\n// TODO extends ArgumentsFilter\nexport interface CallFilter {\n includeFailed?: boolean\n typeArguments?: string[]\n}\n\nexport interface ArgumentsFilter {\n arguments?: string[]\n}\n\nclass EventHandler {\n filters: EventFilter[]\n handler: (event: EventInstance) => Promise<ProcessResult>\n}\n\nclass CallHandler {\n filters: FunctionNameAndCallFilter[]\n handler: (call: Transaction_UserTransaction) => Promise<ProcessResult>\n}\n\nexport class AptosBaseProcessor {\n readonly moduleName: string\n config: IndexConfigure\n eventHandlers: EventHandler[] = []\n callHandlers: CallHandler[] = []\n\n constructor(moduleName: string, options: AptosBindOptions) {\n this.moduleName = moduleName\n this.configure(options)\n global.PROCESSOR_STATE.aptosProcessors.push(this)\n }\n\n // getABI(): MoveModule | undefined {\n // return undefined\n // }\n\n public onTransaction(\n handler: (transaction: Transaction_UserTransaction, ctx: AptosContext) => void\n ): AptosBaseProcessor {\n const address = this.config.address\n const moduleName = this.moduleName\n this.callHandlers.push({\n handler: async function (tx) {\n const ctx = new AptosContext(moduleName, 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: EventInstance, 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 // const moduleName = this.moduleName\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const processor = this\n\n this.eventHandlers.push({\n handler: async function (event) {\n const ctx = new AptosContext(processor.moduleName, processor.config.address, Long.fromString(event.version))\n if (event) {\n const decoded = processor.decodeEvent(event)\n handler(decoded, 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: FunctionNameAndCallFilter | FunctionNameAndCallFilter[]\n ): AptosBaseProcessor {\n let _filters: FunctionNameAndCallFilter[] = []\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n // const address = this.config.address\n // const moduleName = this.moduleName\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const processor = this\n\n this.callHandlers.push({\n handler: async function (tx) {\n const ctx = new AptosContext(processor.moduleName, processor.config.address, Long.fromString(tx.version), tx)\n if (tx) {\n const payload = tx.payload as TransactionPayload_EntryFunctionPayload\n const decoded = processor.decodeFunctionPayload(payload)\n handler(decoded, 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 loadTypes(registry: TypeRegistry) {\n if (registry.contains(this.config.address, this.moduleName)) {\n return\n }\n this.loadTypesInternal(registry)\n }\n\n protected loadTypesInternal(registry: TypeRegistry) {\n // should be override by subclass\n }\n\n private decodeEvent(event: EventInstance): EventInstance {\n const registry = GLOBAL_TYPE_REGISTRY\n this.loadTypes(registry)\n // TODO check if module is not loaded\n\n let dataTyped = undefined\n try {\n dataTyped = registry.decode(event.data, parseMoveType(event.type))\n } catch (e) {\n console.warn('Decoding error for ', event.type)\n return event\n }\n\n return { ...event, data_typed: dataTyped } as TypedEventInstance<any>\n }\n\n private decodeFunctionPayload(\n payload: TransactionPayload_EntryFunctionPayload\n ): TransactionPayload_EntryFunctionPayload {\n const registry = GLOBAL_TYPE_REGISTRY\n this.loadTypes(registry)\n const argumentsTyped: any[] = []\n\n try {\n const func = registry.getMoveFunction(payload.function)\n for (const [idx, arg] of payload.arguments.entries()) {\n // TODO consider apply payload.type_arguments, but this might be hard since we don't code gen for them\n const argType = parseMoveType(func.params[idx + 1])\n argumentsTyped.push(registry.decode(arg, argType))\n }\n } catch (e) {\n console.warn('Decoding error for ', payload.function)\n return payload\n }\n\n return { ...payload, arguments_typed: argumentsTyped } as TypedEntryFunctionPayload<any>\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  export type { Transaction_UserTransaction, TransactionPayload_EntryFunctionPayload } from 'aptos/src/generated';
2
2
  export type { EventInstance, TypedEventInstance, TypeRegistry, TypedEntryFunctionPayload } from './types';
3
- export type { CallFilter, EventFilter } from './aptos-processor';
3
+ export type { FunctionNameAndCallFilter, EventFilter, CallFilter, ArgumentsFilter } from './aptos-processor';
4
4
  export { AptosBaseProcessor } from './aptos-processor';
5
5
  export { AptosContext } from './context';
6
6
  export { AptosBindOptions, AptosNetwork } from './bind-options';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/aptos/index.ts"],"names":[],"mappings":";;;AAGA,qDAAsD;AAA7C,qHAAA,kBAAkB,OAAA;AAC3B,qCAAwC;AAA/B,uGAAA,YAAY,OAAA;AACrB,+CAA+D;AAAtD,gHAAA,gBAAgB,OAAA;AAAE,4GAAA,YAAY,OAAA","sourcesContent":["export type { Transaction_UserTransaction, TransactionPayload_EntryFunctionPayload } from 'aptos/src/generated'\nexport type { EventInstance, TypedEventInstance, TypeRegistry, TypedEntryFunctionPayload } from './types'\nexport type { CallFilter, EventFilter } from './aptos-processor'\nexport { AptosBaseProcessor } from './aptos-processor'\nexport { AptosContext } from './context'\nexport { AptosBindOptions, AptosNetwork } from './bind-options'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/aptos/index.ts"],"names":[],"mappings":";;;AAGA,qDAAsD;AAA7C,qHAAA,kBAAkB,OAAA;AAC3B,qCAAwC;AAA/B,uGAAA,YAAY,OAAA;AACrB,+CAA+D;AAAtD,gHAAA,gBAAgB,OAAA;AAAE,4GAAA,YAAY,OAAA","sourcesContent":["export type { Transaction_UserTransaction, TransactionPayload_EntryFunctionPayload } from 'aptos/src/generated'\nexport type { EventInstance, TypedEventInstance, TypeRegistry, TypedEntryFunctionPayload } from './types'\nexport type { FunctionNameAndCallFilter, EventFilter, CallFilter, ArgumentsFilter } from './aptos-processor'\nexport { AptosBaseProcessor } from './aptos-processor'\nexport { AptosContext } from './context'\nexport { AptosBindOptions, AptosNetwork } from './bind-options'\n"]}
@@ -248,8 +248,9 @@ function generateOnEntryFunctions(module, func) {
248
248
  const genericString = generateFunctionTypeParameters(func);
249
249
  const camelFuncName = capitalizeFirstChar(camelize(func.name));
250
250
  const source = `
251
- onEntry${camelFuncName}${genericString}(func: (call: ${module.name}.${camelFuncName}Payload${genericString}, ctx: aptos.AptosContext) => void): ${module.name} {
251
+ onEntry${camelFuncName}${genericString}(func: (call: ${module.name}.${camelFuncName}Payload${genericString}, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): ${module.name} {
252
252
  this.onEntryFunctionCall(func, {
253
+ ...filter,
253
254
  function: '${module.name}::${func.name}'
254
255
  })
255
256
  return this
@@ -1 +1 @@
1
- {"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/aptos-codegen/codegen.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,gDAAuB;AACvB,wDAA+B;AAE/B,uCAAyD;AACzD,0CAAmD;AAEnD,SAAgB,QAAQ,CAAC,MAAc,EAAE,SAAiB;IACxD,MAAM,KAAK,GAAG,YAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IACpC,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IAEnC,YAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAE5C,MAAM,MAAM,GAAG,IAAI,yBAAe,EAAE,CAAA;IAEpC,uFAAuF;IACvF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAC3B,SAAQ;SACT;QACD,2EAA2E;QAC3E,8BAA8B;QAC9B,MAAM,IAAI,GAAG,YAAE,CAAC,YAAY,CAAC,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAA;QAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAEhC,KAAK,MAAM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AG,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, MoveStruct, MoveModuleBytecode } from 'aptos/src/generated'\nimport { generateType, AccountRegister } from './typegen'\nimport { isFrameworkAccount } from '../aptos/utils'\n\nexport function generate(srcDir: string, outputDir: string) {\n const files = fs.readdirSync(srcDir)\n outputDir = path.resolve(outputDir)\n\n fs.mkdirSync(outputDir, { recursive: true })\n\n const loader = new AccountRegister()\n\n // The first path, identify import relation and module name (filename) of those imports\n for (const file of files) {\n if (!file.endsWith('.json')) {\n continue\n }\n // Reading file is duplicated, but since they are small files probably file\n // TODO add file manager class\n const json = fs.readFileSync(path.join(srcDir, file), 'utf-8')\n const modules = JSON.parse(json)\n\n for (const module of modules) {\n if (module.abi) {\n loader.register(module.abi, path.basename(file, '.json'))\n }\n }\n }\n\n for (const file of files) {\n if (!file.endsWith('.json')) {\n continue\n }\n const codeGen = new AccountCodegen(loader, {\n srcFile: path.join(srcDir, file),\n outputDir: outputDir,\n })\n\n codeGen.generate()\n }\n\n // when generating user code, don't need to generate framework account\n loader.pendingAccounts.delete('0x1')\n loader.pendingAccounts.delete('0x2')\n loader.pendingAccounts.delete('0x3')\n\n if (loader.pendingAccounts.size > 0) {\n // TODO automatic download dependencies\n console.error('Missing ABIs from the following accounts', loader.pendingAccounts)\n }\n}\n\ninterface Config {\n srcFile: string\n outputDir: string\n}\n\nexport class AccountCodegen {\n modules: MoveModuleBytecode[]\n config: Config\n loader: AccountRegister\n\n constructor(loader: AccountRegister, config: Config) {\n const json = fs.readFileSync(config.srcFile, 'utf-8')\n this.modules = JSON.parse(json)\n this.config = config\n this.loader = loader\n }\n\n generate() {\n if (!this.modules) {\n return\n }\n const baseName = path.basename(this.config.srcFile, '.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/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, moduleImported] 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 const items = Array.from(moduleImported)\n moduleImports.push(`import { ${items.join(',')} } from \"${tsAccountModule}\"`)\n\n // Ideally we should use per module's load types, but it doesn't matter since we are loading the entire\n // account modules anyway\n items.forEach((m) => dependedAccounts.push(m))\n }\n }\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 ${moduleImports.join('\\n')}\n \n ${this.modules.map((m) => generateModule(m, dependedAccounts)).join('\\n')}\n \n function loadAllTypes(registry: aptos.TypeRegistry) {\n ${dependedAccounts.map((m) => `${m}.loadTypes(registry)`).join('\\n')}\n\n ${this.modules\n .map((m) => {\n return `registry.load(${m.abi?.name}.ABI)`\n })\n .join('\\n')}\n }\n ` // source\n\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, dependedModules: string[]) {\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 const structs = module.structs.map((s) => generateStructs(module, s))\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.TEST_NET \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(registry: aptos.TypeRegistry) {\n loadAllTypes(registry)\n }\n export const ABI: MoveModule = JSON.parse('${JSON.stringify(module)}')\n }\n `\n}\n\nfunction generateStructs(module: MoveModule, struct: MoveStruct) {\n const genericString = generateStructTypeParameters(struct)\n\n const fields = struct.fields.map((field) => {\n return `${field.name}: ${generateType(field.type)}`\n })\n\n let eventPayload = ''\n if (isEvent(struct)) {\n eventPayload = `\n export interface ${struct.name}Instance${genericString} extends \n aptos.TypedEventInstance<${struct.name}${genericString}> {\n data_typed: ${struct.name}${genericString}\n }\n `\n }\n\n return `\n export class ${struct.name}${genericString} {\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\n })\n .join(',')\n genericString = `<${params}>`\n }\n return genericString\n}\n\nfunction generateStructTypeParameters(struct: MoveStruct) {\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 '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 // the first param is always signer so ignore\n // TODO check if there is any edge case\n const fields = func.params.slice(1).map((param) => {\n return `${generateType(param)}`\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 }\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}${genericString}(func: (call: ${module.name}.${camelFuncName}Payload${genericString}, 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 isEvent(struct: MoveStruct) {\n return struct.abilities.includes('drop') && struct.abilities.includes('store') && struct.name.endsWith('Event')\n}\n\nfunction generateOnEvents(module: MoveModule, struct: MoveStruct): string {\n // for struct that has drop + store\n if (!isEvent(struct)) {\n return ''\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,uCAAyD;AACzD,0CAAmD;AAEnD,SAAgB,QAAQ,CAAC,MAAc,EAAE,SAAiB;IACxD,MAAM,KAAK,GAAG,YAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IACpC,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IAEnC,YAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAE5C,MAAM,MAAM,GAAG,IAAI,yBAAe,EAAE,CAAA;IAEpC,uFAAuF;IACvF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAC3B,SAAQ;SACT;QACD,2EAA2E;QAC3E,8BAA8B;QAC9B,MAAM,IAAI,GAAG,YAAE,CAAC,YAAY,CAAC,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAA;QAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAEhC,KAAK,MAAM,MAAM,IAAI,OAA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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, MoveStruct, MoveModuleBytecode } from 'aptos/src/generated'\nimport { generateType, AccountRegister } from './typegen'\nimport { isFrameworkAccount } from '../aptos/utils'\n\nexport function generate(srcDir: string, outputDir: string) {\n const files = fs.readdirSync(srcDir)\n outputDir = path.resolve(outputDir)\n\n fs.mkdirSync(outputDir, { recursive: true })\n\n const loader = new AccountRegister()\n\n // The first path, identify import relation and module name (filename) of those imports\n for (const file of files) {\n if (!file.endsWith('.json')) {\n continue\n }\n // Reading file is duplicated, but since they are small files probably file\n // TODO add file manager class\n const json = fs.readFileSync(path.join(srcDir, file), 'utf-8')\n const modules = JSON.parse(json)\n\n for (const module of modules) {\n if (module.abi) {\n loader.register(module.abi, path.basename(file, '.json'))\n }\n }\n }\n\n for (const file of files) {\n if (!file.endsWith('.json')) {\n continue\n }\n const codeGen = new AccountCodegen(loader, {\n srcFile: path.join(srcDir, file),\n outputDir: outputDir,\n })\n\n codeGen.generate()\n }\n\n // when generating user code, don't need to generate framework account\n loader.pendingAccounts.delete('0x1')\n loader.pendingAccounts.delete('0x2')\n loader.pendingAccounts.delete('0x3')\n\n if (loader.pendingAccounts.size > 0) {\n // TODO automatic download dependencies\n console.error('Missing ABIs from the following accounts', loader.pendingAccounts)\n }\n}\n\ninterface Config {\n srcFile: string\n outputDir: string\n}\n\nexport class AccountCodegen {\n modules: MoveModuleBytecode[]\n config: Config\n loader: AccountRegister\n\n constructor(loader: AccountRegister, config: Config) {\n const json = fs.readFileSync(config.srcFile, 'utf-8')\n this.modules = JSON.parse(json)\n this.config = config\n this.loader = loader\n }\n\n generate() {\n if (!this.modules) {\n return\n }\n const baseName = path.basename(this.config.srcFile, '.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/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, moduleImported] 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 const items = Array.from(moduleImported)\n moduleImports.push(`import { ${items.join(',')} } from \"${tsAccountModule}\"`)\n\n // Ideally we should use per module's load types, but it doesn't matter since we are loading the entire\n // account modules anyway\n items.forEach((m) => dependedAccounts.push(m))\n }\n }\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 ${moduleImports.join('\\n')}\n \n ${this.modules.map((m) => generateModule(m, dependedAccounts)).join('\\n')}\n \n function loadAllTypes(registry: aptos.TypeRegistry) {\n ${dependedAccounts.map((m) => `${m}.loadTypes(registry)`).join('\\n')}\n\n ${this.modules\n .map((m) => {\n return `registry.load(${m.abi?.name}.ABI)`\n })\n .join('\\n')}\n }\n ` // source\n\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, dependedModules: string[]) {\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 const structs = module.structs.map((s) => generateStructs(module, s))\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.TEST_NET \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(registry: aptos.TypeRegistry) {\n loadAllTypes(registry)\n }\n export const ABI: MoveModule = JSON.parse('${JSON.stringify(module)}')\n }\n `\n}\n\nfunction generateStructs(module: MoveModule, struct: MoveStruct) {\n const genericString = generateStructTypeParameters(struct)\n\n const fields = struct.fields.map((field) => {\n return `${field.name}: ${generateType(field.type)}`\n })\n\n let eventPayload = ''\n if (isEvent(struct)) {\n eventPayload = `\n export interface ${struct.name}Instance${genericString} extends \n aptos.TypedEventInstance<${struct.name}${genericString}> {\n data_typed: ${struct.name}${genericString}\n }\n `\n }\n\n return `\n export class ${struct.name}${genericString} {\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\n })\n .join(',')\n genericString = `<${params}>`\n }\n return genericString\n}\n\nfunction generateStructTypeParameters(struct: MoveStruct) {\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 '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 // the first param is always signer so ignore\n // TODO check if there is any edge case\n const fields = func.params.slice(1).map((param) => {\n return `${generateType(param)}`\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 }\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}${genericString}(func: (call: ${module.name}.${camelFuncName}Payload${genericString}, 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 isEvent(struct: MoveStruct) {\n return struct.abilities.includes('drop') && struct.abilities.includes('store') && struct.name.endsWith('Event')\n}\n\nfunction generateOnEvents(module: MoveModule, struct: MoveStruct): string {\n // for struct that has drop + store\n if (!isEvent(struct)) {\n return ''\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"]}
@@ -23,7 +23,7 @@ export declare class code extends aptos.AptosBaseProcessor {
23
23
  constructor(options: aptos.AptosBindOptions);
24
24
  static DEFAULT_OPTIONS: aptos.AptosBindOptions;
25
25
  static bind(options?: Partial<aptos.AptosBindOptions>): code;
26
- onEntryPublishPackageTxn(func: (call: code.PublishPackageTxnPayload, ctx: aptos.AptosContext) => void): code;
26
+ onEntryPublishPackageTxn(func: (call: code.PublishPackageTxnPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): code;
27
27
  loadTypesInternal(registry: aptos.TypeRegistry): void;
28
28
  }
29
29
  export declare namespace code {
@@ -67,10 +67,10 @@ export declare class coin extends aptos.AptosBaseProcessor {
67
67
  constructor(options: aptos.AptosBindOptions);
68
68
  static DEFAULT_OPTIONS: aptos.AptosBindOptions;
69
69
  static bind(options?: Partial<aptos.AptosBindOptions>): coin;
70
- onEntryFreezeCoinStore<T0>(func: (call: coin.FreezeCoinStorePayload<T0>, ctx: aptos.AptosContext) => void): coin;
71
- onEntryTransfer<T0>(func: (call: coin.TransferPayload<T0>, ctx: aptos.AptosContext) => void): coin;
72
- onEntryUnfreezeCoinStore<T0>(func: (call: coin.UnfreezeCoinStorePayload<T0>, ctx: aptos.AptosContext) => void): coin;
73
- onEntryUpgradeSupply<T0>(func: (call: coin.UpgradeSupplyPayload<T0>, ctx: aptos.AptosContext) => void): coin;
70
+ onEntryFreezeCoinStore<T0>(func: (call: coin.FreezeCoinStorePayload<T0>, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): coin;
71
+ onEntryTransfer<T0>(func: (call: coin.TransferPayload<T0>, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): coin;
72
+ onEntryUnfreezeCoinStore<T0>(func: (call: coin.UnfreezeCoinStorePayload<T0>, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): coin;
73
+ onEntryUpgradeSupply<T0>(func: (call: coin.UpgradeSupplyPayload<T0>, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): coin;
74
74
  onEventDepositEvent(func: (event: coin.DepositEventInstance, ctx: aptos.AptosContext) => void): coin;
75
75
  onEventWithdrawEvent(func: (event: coin.WithdrawEventInstance, ctx: aptos.AptosContext) => void): coin;
76
76
  loadTypesInternal(registry: aptos.TypeRegistry): void;
@@ -207,19 +207,19 @@ export declare class stake extends aptos.AptosBaseProcessor {
207
207
  constructor(options: aptos.AptosBindOptions);
208
208
  static DEFAULT_OPTIONS: aptos.AptosBindOptions;
209
209
  static bind(options?: Partial<aptos.AptosBindOptions>): stake;
210
- onEntryAddStake(func: (call: stake.AddStakePayload, ctx: aptos.AptosContext) => void): stake;
211
- onEntryIncreaseLockup(func: (call: stake.IncreaseLockupPayload, ctx: aptos.AptosContext) => void): stake;
212
- onEntryInitializeStakeOwner(func: (call: stake.InitializeStakeOwnerPayload, ctx: aptos.AptosContext) => void): stake;
213
- onEntryInitializeValidator(func: (call: stake.InitializeValidatorPayload, ctx: aptos.AptosContext) => void): stake;
214
- onEntryJoinValidatorSet(func: (call: stake.JoinValidatorSetPayload, ctx: aptos.AptosContext) => void): stake;
215
- onEntryLeaveValidatorSet(func: (call: stake.LeaveValidatorSetPayload, ctx: aptos.AptosContext) => void): stake;
216
- onEntryReactivateStake(func: (call: stake.ReactivateStakePayload, ctx: aptos.AptosContext) => void): stake;
217
- onEntryRotateConsensusKey(func: (call: stake.RotateConsensusKeyPayload, ctx: aptos.AptosContext) => void): stake;
218
- onEntrySetDelegatedVoter(func: (call: stake.SetDelegatedVoterPayload, ctx: aptos.AptosContext) => void): stake;
219
- onEntrySetOperator(func: (call: stake.SetOperatorPayload, ctx: aptos.AptosContext) => void): stake;
220
- onEntryUnlock(func: (call: stake.UnlockPayload, ctx: aptos.AptosContext) => void): stake;
221
- onEntryUpdateNetworkAndFullnodeAddresses(func: (call: stake.UpdateNetworkAndFullnodeAddressesPayload, ctx: aptos.AptosContext) => void): stake;
222
- onEntryWithdraw(func: (call: stake.WithdrawPayload, ctx: aptos.AptosContext) => void): stake;
210
+ onEntryAddStake(func: (call: stake.AddStakePayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): stake;
211
+ onEntryIncreaseLockup(func: (call: stake.IncreaseLockupPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): stake;
212
+ onEntryInitializeStakeOwner(func: (call: stake.InitializeStakeOwnerPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): stake;
213
+ onEntryInitializeValidator(func: (call: stake.InitializeValidatorPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): stake;
214
+ onEntryJoinValidatorSet(func: (call: stake.JoinValidatorSetPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): stake;
215
+ onEntryLeaveValidatorSet(func: (call: stake.LeaveValidatorSetPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): stake;
216
+ onEntryReactivateStake(func: (call: stake.ReactivateStakePayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): stake;
217
+ onEntryRotateConsensusKey(func: (call: stake.RotateConsensusKeyPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): stake;
218
+ onEntrySetDelegatedVoter(func: (call: stake.SetDelegatedVoterPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): stake;
219
+ onEntrySetOperator(func: (call: stake.SetOperatorPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): stake;
220
+ onEntryUnlock(func: (call: stake.UnlockPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): stake;
221
+ onEntryUpdateNetworkAndFullnodeAddresses(func: (call: stake.UpdateNetworkAndFullnodeAddressesPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): stake;
222
+ onEntryWithdraw(func: (call: stake.WithdrawPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): stake;
223
223
  onEventAddStakeEvent(func: (event: stake.AddStakeEventInstance, ctx: aptos.AptosContext) => void): stake;
224
224
  onEventDistributeRewardsEvent(func: (event: stake.DistributeRewardsEventInstance, ctx: aptos.AptosContext) => void): stake;
225
225
  onEventIncreaseLockupEvent(func: (event: stake.IncreaseLockupEventInstance, ctx: aptos.AptosContext) => void): stake;
@@ -529,9 +529,9 @@ export declare class account extends aptos.AptosBaseProcessor {
529
529
  constructor(options: aptos.AptosBindOptions);
530
530
  static DEFAULT_OPTIONS: aptos.AptosBindOptions;
531
531
  static bind(options?: Partial<aptos.AptosBindOptions>): account;
532
- onEntryOfferSignerCapability(func: (call: account.OfferSignerCapabilityPayload, ctx: aptos.AptosContext) => void): account;
533
- onEntryRevokeSignerCapability(func: (call: account.RevokeSignerCapabilityPayload, ctx: aptos.AptosContext) => void): account;
534
- onEntryRotateAuthenticationKey(func: (call: account.RotateAuthenticationKeyPayload, ctx: aptos.AptosContext) => void): account;
532
+ onEntryOfferSignerCapability(func: (call: account.OfferSignerCapabilityPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): account;
533
+ onEntryRevokeSignerCapability(func: (call: account.RevokeSignerCapabilityPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): account;
534
+ onEntryRotateAuthenticationKey(func: (call: account.RotateAuthenticationKeyPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): account;
535
535
  onEventCoinRegisterEvent(func: (event: account.CoinRegisterEventInstance, ctx: aptos.AptosContext) => void): account;
536
536
  onEventKeyRotationEvent(func: (event: account.KeyRotationEventInstance, ctx: aptos.AptosContext) => void): account;
537
537
  loadTypesInternal(registry: aptos.TypeRegistry): void;
@@ -664,7 +664,7 @@ export declare class version extends aptos.AptosBaseProcessor {
664
664
  constructor(options: aptos.AptosBindOptions);
665
665
  static DEFAULT_OPTIONS: aptos.AptosBindOptions;
666
666
  static bind(options?: Partial<aptos.AptosBindOptions>): version;
667
- onEntrySetVersion(func: (call: version.SetVersionPayload, ctx: aptos.AptosContext) => void): version;
667
+ onEntrySetVersion(func: (call: version.SetVersionPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): version;
668
668
  loadTypesInternal(registry: aptos.TypeRegistry): void;
669
669
  }
670
670
  export declare namespace version {
@@ -684,19 +684,19 @@ export declare class vesting extends aptos.AptosBaseProcessor {
684
684
  constructor(options: aptos.AptosBindOptions);
685
685
  static DEFAULT_OPTIONS: aptos.AptosBindOptions;
686
686
  static bind(options?: Partial<aptos.AptosBindOptions>): vesting;
687
- onEntryAdminWithdraw(func: (call: vesting.AdminWithdrawPayload, ctx: aptos.AptosContext) => void): vesting;
688
- onEntryDistribute(func: (call: vesting.DistributePayload, ctx: aptos.AptosContext) => void): vesting;
689
- onEntryResetBeneficiary(func: (call: vesting.ResetBeneficiaryPayload, ctx: aptos.AptosContext) => void): vesting;
690
- onEntryResetLockup(func: (call: vesting.ResetLockupPayload, ctx: aptos.AptosContext) => void): vesting;
691
- onEntrySetBeneficiary(func: (call: vesting.SetBeneficiaryPayload, ctx: aptos.AptosContext) => void): vesting;
692
- onEntrySetBeneficiaryResetter(func: (call: vesting.SetBeneficiaryResetterPayload, ctx: aptos.AptosContext) => void): vesting;
693
- onEntrySetManagementRole(func: (call: vesting.SetManagementRolePayload, ctx: aptos.AptosContext) => void): vesting;
694
- onEntryTerminateVestingContract(func: (call: vesting.TerminateVestingContractPayload, ctx: aptos.AptosContext) => void): vesting;
695
- onEntryUnlockRewards(func: (call: vesting.UnlockRewardsPayload, ctx: aptos.AptosContext) => void): vesting;
696
- onEntryUpdateOperator(func: (call: vesting.UpdateOperatorPayload, ctx: aptos.AptosContext) => void): vesting;
697
- onEntryUpdateOperatorWithSameCommission(func: (call: vesting.UpdateOperatorWithSameCommissionPayload, ctx: aptos.AptosContext) => void): vesting;
698
- onEntryUpdateVoter(func: (call: vesting.UpdateVoterPayload, ctx: aptos.AptosContext) => void): vesting;
699
- onEntryVest(func: (call: vesting.VestPayload, ctx: aptos.AptosContext) => void): vesting;
687
+ onEntryAdminWithdraw(func: (call: vesting.AdminWithdrawPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): vesting;
688
+ onEntryDistribute(func: (call: vesting.DistributePayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): vesting;
689
+ onEntryResetBeneficiary(func: (call: vesting.ResetBeneficiaryPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): vesting;
690
+ onEntryResetLockup(func: (call: vesting.ResetLockupPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): vesting;
691
+ onEntrySetBeneficiary(func: (call: vesting.SetBeneficiaryPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): vesting;
692
+ onEntrySetBeneficiaryResetter(func: (call: vesting.SetBeneficiaryResetterPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): vesting;
693
+ onEntrySetManagementRole(func: (call: vesting.SetManagementRolePayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): vesting;
694
+ onEntryTerminateVestingContract(func: (call: vesting.TerminateVestingContractPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): vesting;
695
+ onEntryUnlockRewards(func: (call: vesting.UnlockRewardsPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): vesting;
696
+ onEntryUpdateOperator(func: (call: vesting.UpdateOperatorPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): vesting;
697
+ onEntryUpdateOperatorWithSameCommission(func: (call: vesting.UpdateOperatorWithSameCommissionPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): vesting;
698
+ onEntryUpdateVoter(func: (call: vesting.UpdateVoterPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): vesting;
699
+ onEntryVest(func: (call: vesting.VestPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): vesting;
700
700
  onEventAdminWithdrawEvent(func: (event: vesting.AdminWithdrawEventInstance, ctx: aptos.AptosContext) => void): vesting;
701
701
  onEventCreateVestingContractEvent(func: (event: vesting.CreateVestingContractEventInstance, ctx: aptos.AptosContext) => void): vesting;
702
702
  onEventDistributeEvent(func: (event: vesting.DistributeEventInstance, ctx: aptos.AptosContext) => void): vesting;
@@ -977,9 +977,9 @@ export declare class aptos_coin extends aptos.AptosBaseProcessor {
977
977
  constructor(options: aptos.AptosBindOptions);
978
978
  static DEFAULT_OPTIONS: aptos.AptosBindOptions;
979
979
  static bind(options?: Partial<aptos.AptosBindOptions>): aptos_coin;
980
- onEntryClaimMintCapability(func: (call: aptos_coin.ClaimMintCapabilityPayload, ctx: aptos.AptosContext) => void): aptos_coin;
981
- onEntryDelegateMintCapability(func: (call: aptos_coin.DelegateMintCapabilityPayload, ctx: aptos.AptosContext) => void): aptos_coin;
982
- onEntryMint(func: (call: aptos_coin.MintPayload, ctx: aptos.AptosContext) => void): aptos_coin;
980
+ onEntryClaimMintCapability(func: (call: aptos_coin.ClaimMintCapabilityPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): aptos_coin;
981
+ onEntryDelegateMintCapability(func: (call: aptos_coin.DelegateMintCapabilityPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): aptos_coin;
982
+ onEntryMint(func: (call: aptos_coin.MintPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): aptos_coin;
983
983
  loadTypesInternal(registry: aptos.TypeRegistry): void;
984
984
  }
985
985
  export declare namespace aptos_coin {
@@ -1118,10 +1118,10 @@ export declare class managed_coin extends aptos.AptosBaseProcessor {
1118
1118
  constructor(options: aptos.AptosBindOptions);
1119
1119
  static DEFAULT_OPTIONS: aptos.AptosBindOptions;
1120
1120
  static bind(options?: Partial<aptos.AptosBindOptions>): managed_coin;
1121
- onEntryBurn<T0>(func: (call: managed_coin.BurnPayload<T0>, ctx: aptos.AptosContext) => void): managed_coin;
1122
- onEntryInitialize<T0>(func: (call: managed_coin.InitializePayload<T0>, ctx: aptos.AptosContext) => void): managed_coin;
1123
- onEntryMint<T0>(func: (call: managed_coin.MintPayload<T0>, ctx: aptos.AptosContext) => void): managed_coin;
1124
- onEntryRegister<T0>(func: (call: managed_coin.RegisterPayload<T0>, ctx: aptos.AptosContext) => void): managed_coin;
1121
+ onEntryBurn<T0>(func: (call: managed_coin.BurnPayload<T0>, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): managed_coin;
1122
+ onEntryInitialize<T0>(func: (call: managed_coin.InitializePayload<T0>, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): managed_coin;
1123
+ onEntryMint<T0>(func: (call: managed_coin.MintPayload<T0>, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): managed_coin;
1124
+ onEntryRegister<T0>(func: (call: managed_coin.RegisterPayload<T0>, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): managed_coin;
1125
1125
  loadTypesInternal(registry: aptos.TypeRegistry): void;
1126
1126
  }
1127
1127
  export declare namespace managed_coin {
@@ -1162,8 +1162,8 @@ export declare class aptos_account extends aptos.AptosBaseProcessor {
1162
1162
  constructor(options: aptos.AptosBindOptions);
1163
1163
  static DEFAULT_OPTIONS: aptos.AptosBindOptions;
1164
1164
  static bind(options?: Partial<aptos.AptosBindOptions>): aptos_account;
1165
- onEntryCreateAccount(func: (call: aptos_account.CreateAccountPayload, ctx: aptos.AptosContext) => void): aptos_account;
1166
- onEntryTransfer(func: (call: aptos_account.TransferPayload, ctx: aptos.AptosContext) => void): aptos_account;
1165
+ onEntryCreateAccount(func: (call: aptos_account.CreateAccountPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): aptos_account;
1166
+ onEntryTransfer(func: (call: aptos_account.TransferPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): aptos_account;
1167
1167
  loadTypesInternal(registry: aptos.TypeRegistry): void;
1168
1168
  }
1169
1169
  export declare namespace aptos_account {
@@ -1200,14 +1200,14 @@ export declare class staking_proxy extends aptos.AptosBaseProcessor {
1200
1200
  constructor(options: aptos.AptosBindOptions);
1201
1201
  static DEFAULT_OPTIONS: aptos.AptosBindOptions;
1202
1202
  static bind(options?: Partial<aptos.AptosBindOptions>): staking_proxy;
1203
- onEntrySetOperator(func: (call: staking_proxy.SetOperatorPayload, ctx: aptos.AptosContext) => void): staking_proxy;
1204
- onEntrySetStakePoolOperator(func: (call: staking_proxy.SetStakePoolOperatorPayload, ctx: aptos.AptosContext) => void): staking_proxy;
1205
- onEntrySetStakePoolVoter(func: (call: staking_proxy.SetStakePoolVoterPayload, ctx: aptos.AptosContext) => void): staking_proxy;
1206
- onEntrySetStakingContractOperator(func: (call: staking_proxy.SetStakingContractOperatorPayload, ctx: aptos.AptosContext) => void): staking_proxy;
1207
- onEntrySetStakingContractVoter(func: (call: staking_proxy.SetStakingContractVoterPayload, ctx: aptos.AptosContext) => void): staking_proxy;
1208
- onEntrySetVestingContractOperator(func: (call: staking_proxy.SetVestingContractOperatorPayload, ctx: aptos.AptosContext) => void): staking_proxy;
1209
- onEntrySetVestingContractVoter(func: (call: staking_proxy.SetVestingContractVoterPayload, ctx: aptos.AptosContext) => void): staking_proxy;
1210
- onEntrySetVoter(func: (call: staking_proxy.SetVoterPayload, ctx: aptos.AptosContext) => void): staking_proxy;
1203
+ onEntrySetOperator(func: (call: staking_proxy.SetOperatorPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): staking_proxy;
1204
+ onEntrySetStakePoolOperator(func: (call: staking_proxy.SetStakePoolOperatorPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): staking_proxy;
1205
+ onEntrySetStakePoolVoter(func: (call: staking_proxy.SetStakePoolVoterPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): staking_proxy;
1206
+ onEntrySetStakingContractOperator(func: (call: staking_proxy.SetStakingContractOperatorPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): staking_proxy;
1207
+ onEntrySetStakingContractVoter(func: (call: staking_proxy.SetStakingContractVoterPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): staking_proxy;
1208
+ onEntrySetVestingContractOperator(func: (call: staking_proxy.SetVestingContractOperatorPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): staking_proxy;
1209
+ onEntrySetVestingContractVoter(func: (call: staking_proxy.SetVestingContractVoterPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): staking_proxy;
1210
+ onEntrySetVoter(func: (call: staking_proxy.SetVoterPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): staking_proxy;
1211
1211
  loadTypesInternal(registry: aptos.TypeRegistry): void;
1212
1212
  }
1213
1213
  export declare namespace staking_proxy {
@@ -1302,9 +1302,9 @@ export declare class aptos_governance extends aptos.AptosBaseProcessor {
1302
1302
  constructor(options: aptos.AptosBindOptions);
1303
1303
  static DEFAULT_OPTIONS: aptos.AptosBindOptions;
1304
1304
  static bind(options?: Partial<aptos.AptosBindOptions>): aptos_governance;
1305
- onEntryAddApprovedScriptHashScript(func: (call: aptos_governance.AddApprovedScriptHashScriptPayload, ctx: aptos.AptosContext) => void): aptos_governance;
1306
- onEntryCreateProposal(func: (call: aptos_governance.CreateProposalPayload, ctx: aptos.AptosContext) => void): aptos_governance;
1307
- onEntryVote(func: (call: aptos_governance.VotePayload, ctx: aptos.AptosContext) => void): aptos_governance;
1305
+ onEntryAddApprovedScriptHashScript(func: (call: aptos_governance.AddApprovedScriptHashScriptPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): aptos_governance;
1306
+ onEntryCreateProposal(func: (call: aptos_governance.CreateProposalPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): aptos_governance;
1307
+ onEntryVote(func: (call: aptos_governance.VotePayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): aptos_governance;
1308
1308
  onEventCreateProposalEvent(func: (event: aptos_governance.CreateProposalEventInstance, ctx: aptos.AptosContext) => void): aptos_governance;
1309
1309
  onEventUpdateConfigEvent(func: (event: aptos_governance.UpdateConfigEventInstance, ctx: aptos.AptosContext) => void): aptos_governance;
1310
1310
  onEventVoteEvent(func: (event: aptos_governance.VoteEventInstance, ctx: aptos.AptosContext) => void): aptos_governance;
@@ -1385,9 +1385,9 @@ export declare class resource_account extends aptos.AptosBaseProcessor {
1385
1385
  constructor(options: aptos.AptosBindOptions);
1386
1386
  static DEFAULT_OPTIONS: aptos.AptosBindOptions;
1387
1387
  static bind(options?: Partial<aptos.AptosBindOptions>): resource_account;
1388
- onEntryCreateResourceAccount(func: (call: resource_account.CreateResourceAccountPayload, ctx: aptos.AptosContext) => void): resource_account;
1389
- onEntryCreateResourceAccountAndFund(func: (call: resource_account.CreateResourceAccountAndFundPayload, ctx: aptos.AptosContext) => void): resource_account;
1390
- onEntryCreateResourceAccountAndPublishPackage(func: (call: resource_account.CreateResourceAccountAndPublishPackagePayload, ctx: aptos.AptosContext) => void): resource_account;
1388
+ onEntryCreateResourceAccount(func: (call: resource_account.CreateResourceAccountPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): resource_account;
1389
+ onEntryCreateResourceAccountAndFund(func: (call: resource_account.CreateResourceAccountAndFundPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): resource_account;
1390
+ onEntryCreateResourceAccountAndPublishPackage(func: (call: resource_account.CreateResourceAccountAndPublishPackagePayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): resource_account;
1391
1391
  loadTypesInternal(registry: aptos.TypeRegistry): void;
1392
1392
  }
1393
1393
  export declare namespace resource_account {
@@ -1410,16 +1410,16 @@ export declare class staking_contract extends aptos.AptosBaseProcessor {
1410
1410
  constructor(options: aptos.AptosBindOptions);
1411
1411
  static DEFAULT_OPTIONS: aptos.AptosBindOptions;
1412
1412
  static bind(options?: Partial<aptos.AptosBindOptions>): staking_contract;
1413
- onEntryAddStake(func: (call: staking_contract.AddStakePayload, ctx: aptos.AptosContext) => void): staking_contract;
1414
- onEntryCreateStakingContract(func: (call: staking_contract.CreateStakingContractPayload, ctx: aptos.AptosContext) => void): staking_contract;
1415
- onEntryDistribute(func: (call: staking_contract.DistributePayload, ctx: aptos.AptosContext) => void): staking_contract;
1416
- onEntryRequestCommission(func: (call: staking_contract.RequestCommissionPayload, ctx: aptos.AptosContext) => void): staking_contract;
1417
- onEntryResetLockup(func: (call: staking_contract.ResetLockupPayload, ctx: aptos.AptosContext) => void): staking_contract;
1418
- onEntrySwitchOperator(func: (call: staking_contract.SwitchOperatorPayload, ctx: aptos.AptosContext) => void): staking_contract;
1419
- onEntrySwitchOperatorWithSameCommission(func: (call: staking_contract.SwitchOperatorWithSameCommissionPayload, ctx: aptos.AptosContext) => void): staking_contract;
1420
- onEntryUnlockRewards(func: (call: staking_contract.UnlockRewardsPayload, ctx: aptos.AptosContext) => void): staking_contract;
1421
- onEntryUnlockStake(func: (call: staking_contract.UnlockStakePayload, ctx: aptos.AptosContext) => void): staking_contract;
1422
- onEntryUpdateVoter(func: (call: staking_contract.UpdateVoterPayload, ctx: aptos.AptosContext) => void): staking_contract;
1413
+ onEntryAddStake(func: (call: staking_contract.AddStakePayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): staking_contract;
1414
+ onEntryCreateStakingContract(func: (call: staking_contract.CreateStakingContractPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): staking_contract;
1415
+ onEntryDistribute(func: (call: staking_contract.DistributePayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): staking_contract;
1416
+ onEntryRequestCommission(func: (call: staking_contract.RequestCommissionPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): staking_contract;
1417
+ onEntryResetLockup(func: (call: staking_contract.ResetLockupPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): staking_contract;
1418
+ onEntrySwitchOperator(func: (call: staking_contract.SwitchOperatorPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): staking_contract;
1419
+ onEntrySwitchOperatorWithSameCommission(func: (call: staking_contract.SwitchOperatorWithSameCommissionPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): staking_contract;
1420
+ onEntryUnlockRewards(func: (call: staking_contract.UnlockRewardsPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): staking_contract;
1421
+ onEntryUnlockStake(func: (call: staking_contract.UnlockStakePayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): staking_contract;
1422
+ onEntryUpdateVoter(func: (call: staking_contract.UpdateVoterPayload, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): staking_contract;
1423
1423
  onEventAddDistributionEvent(func: (event: staking_contract.AddDistributionEventInstance, ctx: aptos.AptosContext) => void): staking_contract;
1424
1424
  onEventAddStakeEvent(func: (event: staking_contract.AddStakeEventInstance, ctx: aptos.AptosContext) => void): staking_contract;
1425
1425
  onEventCreateStakingContractEvent(func: (event: staking_contract.CreateStakingContractEventInstance, ctx: aptos.AptosContext) => void): staking_contract;