@sentio/sdk 2.11.6-rc.3 → 2.11.6-rc.4
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/codegen/codegen.js +2 -1
- package/lib/aptos/codegen/codegen.js.map +1 -1
- package/lib/eth/codegen/ethers-sentio.js +1 -1
- package/lib/eth/codegen/ethers-sentio.js.map +1 -1
- package/lib/sui/codegen/codegen.js +2 -1
- package/lib/sui/codegen/codegen.js.map +1 -1
- package/package.json +4 -4
- package/src/aptos/codegen/codegen.ts +2 -1
- package/src/eth/codegen/ethers-sentio.ts +1 -1
- package/src/sui/codegen/codegen.ts +2 -1
@@ -6,7 +6,8 @@ import { AptosNetwork } from '../network.js';
|
|
6
6
|
import { AptosClient } from 'aptos-sdk';
|
7
7
|
import { getMeaningfulFunctionParams } from '../utils.js';
|
8
8
|
import { AbstractCodegen } from '../../move/abstract-codegen.js';
|
9
|
-
|
9
|
+
import { join } from "path";
|
10
|
+
export async function codegen(abisDir, outDir = join('src', 'types', 'aptos'), genExample = false) {
|
10
11
|
if (!fs.existsSync(abisDir)) {
|
11
12
|
return;
|
12
13
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../../src/aptos/codegen/codegen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,EAAsB,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACvE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAkB,MAAM,qBAAqB,CAAA;AAC3E,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;
|
1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AE;oBACzC,MAAM,KAAK,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;oBACjC,MAAM,WAAW,GAAG,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;oBACxC,IAAI,WAAW,EAAE;wBACf,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC,CAAA;qBACjC;iBACF;aACF;SACF;QAED,OAAO,QAAQ,CAAA;IACjB,CAAC;CACF","sourcesContent":["import * as fs from 'fs'\nimport { MoveModuleBytecode, toInternalModule } from '../move-types.js'\nimport { moduleQname, SPLITTER, TypeDescriptor } from '../../move/index.js'\nimport chalk from 'chalk'\nimport { AptosNetwork } from '../network.js'\nimport { AptosClient } from 'aptos-sdk'\nimport { getMeaningfulFunctionParams } from '../utils.js'\nimport { InternalMoveModule, InternalMoveStruct } from '../../move/internal-models.js'\nimport { AbstractCodegen } from '../../move/abstract-codegen.js'\nimport {join} from \"path\";\n\nexport async function codegen(abisDir: string, outDir = join('src', 'types', 'aptos'), genExample = false) {\n if (!fs.existsSync(abisDir)) {\n return\n }\n const gen = new AptosCodegen()\n const numFiles = await gen.generate(abisDir, outDir)\n console.log(chalk.green(`Generated ${numFiles} for Aptos`))\n}\n\nfunction getRpcEndpoint(network: AptosNetwork): string {\n switch (network) {\n case AptosNetwork.TEST_NET:\n return 'https://testnet.aptoslabs.com/'\n }\n return 'https://mainnet.aptoslabs.com/'\n}\n\nfunction getRpcClient(network: AptosNetwork): AptosClient {\n return new AptosClient(getRpcEndpoint(network))\n}\n\nclass AptosCodegen extends AbstractCodegen<MoveModuleBytecode[], AptosNetwork> {\n ADDRESS_TYPE = 'Address'\n MAIN_NET = AptosNetwork.MAIN_NET\n TEST_NET = AptosNetwork.TEST_NET\n PREFIX = 'Aptos'\n\n async fetchModules(account: string, network: AptosNetwork): Promise<MoveModuleBytecode[]> {\n const client = getRpcClient(network)\n return await client.getAccountModules(account)\n }\n\n toInternalModules(modules: MoveModuleBytecode[]): InternalMoveModule[] {\n return modules.flatMap((m) => (m.abi ? [toInternalModule(m)] : []))\n }\n\n getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[] {\n return getMeaningfulFunctionParams(params)\n }\n\n getEventStructs(module: InternalMoveModule) {\n const qname = moduleQname(module)\n const structMap = new Map<string, InternalMoveStruct>()\n const eventMap = new Map<string, InternalMoveStruct>()\n\n for (const struct of module.structs) {\n structMap.set(qname + SPLITTER + struct.name, struct)\n }\n\n for (const struct of module.structs) {\n for (const field of struct.fields) {\n const t = field.type\n if (t.qname === '0x1::event::EventHandle') {\n const event = t.typeArgs[0].qname\n const eventStruct = structMap.get(event)\n if (eventStruct) {\n eventMap.set(event, eventStruct)\n }\n }\n }\n }\n\n return eventMap\n }\n}\n"]}
|
@@ -50,7 +50,7 @@ export default class EthersSentio extends Ethers.default {
|
|
50
50
|
if (file.path.endsWith('__factory.ts')) {
|
51
51
|
file.contents = '// @ts-nocheck\n' + file.contents;
|
52
52
|
}
|
53
|
-
else if (file.path.endsWith('factories
|
53
|
+
else if (file.path.endsWith(join('factories', 'index.ts'))) {
|
54
54
|
file.contents = file.contents.replaceAll("__factory'", "__factory.js'");
|
55
55
|
}
|
56
56
|
else if (file.path.endsWith('_processor.ts')) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ethers-sentio.js","sourceRoot":"","sources":["../../../src/eth/codegen/ethers-sentio.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAEL,UAAU,EACV,oBAAoB,EAEpB,KAAK,EACL,uBAAuB,GAExB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAOjF,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,MAAM,CA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;;;;;;;;;;;;;;;;;CAiBzF,CAAA;gBACO,cAAc,IAAI,OAAO,CAAA;aAC1B;YAED,KAAK,CAAC,IAAI,CAAC;gBACT,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,0BAA0B,CAAC;gBAC/C,QAAQ,EAAE,cAAc;aACzB,CAAC,CAAA;SACH;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF;AAED,MAAM,cAAc,GAAG;;;;;;CAMtB,CAAA","sourcesContent":["import Ethers from '@sentio/ethers-v6'\nimport {\n Config,\n extractAbi,\n extractDocumentation,\n FileDescription,\n parse,\n shortenFullJsonFilePath,\n Contract,\n} from 'typechain'\nimport { dirname, join, relative } from 'path'\nimport { codeGenIndex, codeGenSentioFile, codeGenTestUtilsFile } from './file.js'\nimport { YamlContractConfig } from '../../core/yaml-contract-config.js'\n\nexport interface SentioEthersConfig extends Config {\n contractsToGenExample: YamlContractConfig[]\n}\n\nexport default class EthersSentio extends Ethers.default {\n constructor(config: SentioEthersConfig) {\n if (!config.outDir) {\n throw new Error('Out put path not specificed')\n }\n super(config)\n }\n\n private processedABIs: Contract[] = []\n\n // TODO(pc): also have to override transformBinFile, transformFile\n override transformAbiOrFullJsonFile(file: FileDescription): FileDescription[] | void {\n const abi = extractAbi(file.contents)\n if (abi.length === 0) {\n return\n }\n\n const documentation = extractDocumentation(file.contents)\n\n const jsonPath = relative(this.cfg.inputDir, shortenFullJsonFilePath(file.path, this.cfg.allFiles))\n const contract = parse(abi, jsonPath, documentation)\n const files = super.transformAbiOrFullJsonFile(file)\n this.processedABIs.push(contract)\n\n if (files !== undefined) {\n // files.forEach(this.transformFilePath)\n // for (const file of files) {\n // this.transformFilePath(file)\n // }\n\n return [\n ...files,\n {\n path: join(dirname(files[0].path), `${contract.name.toLowerCase()}-processor.ts`),\n contents: codeGenSentioFile(contract),\n },\n {\n path: join(dirname(files[0].path), '..', `${contract.name.toLowerCase()}.ts`),\n contents: codeGenIndex(contract),\n },\n {\n path: join(dirname(files[0].path), `${contract.name.toLowerCase()}-test-utils.ts`),\n contents: codeGenTestUtilsFile(contract),\n },\n ]\n }\n }\n\n override afterRun() {\n const commonPath = join('internal', 'common.ts')\n const files = super.afterRun()\n for (const [idx, file] of files.entries()) {\n if (file.path.endsWith('__factory.ts')) {\n file.contents = '// @ts-nocheck\\n' + file.contents\n } else if (file.path.endsWith(join('factories', 'index.ts'))) {\n file.contents = file.contents.replaceAll(\"__factory'\", \"__factory.js'\")\n } else if (file.path.endsWith('_processor.ts')) {\n } else if (file.path.endsWith(commonPath)) {\n file.contents = COMMON_CONTENT\n }\n }\n\n let indexContent = ''\n for (const contract of this.processedABIs) {\n const content = `\n export * as ${contract.name.toLowerCase().replaceAll('-', '_')} from './${contract.name.toLowerCase()}.js'\n export { ${contract.name}Processor, ${\n contract.name\n }ProcessorTemplate } from './${contract.name.toLowerCase()}.js'\n `\n indexContent += content\n }\n files.push({\n path: join(dirname(files[0].path), '../index.ts'),\n contents: indexContent,\n })\n\n const rootDir = join(dirname(files[0].path), '../../..')\n\n const contractsToGenExample = (this.cfg as SentioEthersConfig).contractsToGenExample\n if (contractsToGenExample.length > 0) {\n const processors = this.processedABIs.map((abi) => `${abi.name}Processor`).join(',')\n let exampleContent = `import { ${processors} } from './types/eth/index.js'`\n\n for (const contract of contractsToGenExample) {\n const chainId = parseInt(contract.chain)\n if (isNaN(chainId) || !isFinite(chainId)) {\n continue\n }\n\n const content = `\n\n${contract.name}Processor.bind({ address: '${contract.address}', network: ${contract.chain} })\n .onAllEvents((evt, ctx) => {\n ctx.meter.Counter('event_count').add(1, { name: evt.name })\n ctx.eventLogger.emit(evt.name, {\n ...evt.args.toObject(),\n })\n})\n .onAllTraces(function (trace, ctx) {\n const succeed = trace.error === undefined\n ctx.meter.Counter('trace_count').add(1, { name: trace.name, success: String(succeed) })\n if (succeed) {\n ctx.eventLogger.emit(trace.name, {\n distinctId: trace.action.from,\n ...trace.args.toObject(),\n })\n }\n })\n`\n exampleContent += content\n }\n\n files.push({\n path: join(rootDir, 'processor.eth.example.ts'),\n contents: exampleContent,\n })\n }\n return files\n }\n}\n\nconst COMMON_CONTENT = `/* Autogenerated file. Do not edit manually. */\n/* tslint:disable */\n/* eslint-disable */\n\nexport type { TypedEvent, TypedEventFilter } from \"@sentio/sdk/eth\"\nexport type { PromiseOrValue } from '@sentio/sdk/core'\n`\n"]}
|
@@ -6,7 +6,8 @@ import { AbstractCodegen } from '../../move/abstract-codegen.js';
|
|
6
6
|
import { toInternalModule } from '../move-types.js';
|
7
7
|
import { moduleQname, SPLITTER, structQname } from '../../move/index.js';
|
8
8
|
import { getMeaningfulFunctionParams } from '../utils.js';
|
9
|
-
|
9
|
+
import { join } from "path";
|
10
|
+
export async function codegen(abisDir, outDir = join('src', 'types', 'sui'), genExample = false) {
|
10
11
|
if (!fs.existsSync(abisDir)) {
|
11
12
|
return;
|
12
13
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../../src/sui/codegen/codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAA4B,MAAM,gBAAgB,CAAA;AAEtF,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAkB,MAAM,qBAAqB,CAAA;AACxF,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;
|
1
|
+
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../../src/sui/codegen/codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAA4B,MAAM,gBAAgB,CAAA;AAEtF,OA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,CAAC,MAAM,EAAE;YACd,OAAO,GAAG,CAAC,MAAM,CAAA;SAClB;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,eAAe,CAAC,MAA0B,EAAE,MAA0B,EAAE,MAAmB;QACzF,QAAQ,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;YACnC,KAAK,iBAAiB;gBACpB,OAAO,eAAe,MAAM,CAAC,IAAI,WAAW,CAAA;YAC9C,KAAK,iBAAiB;gBACpB,OAAO,eAAe,MAAM,CAAC,IAAI,cAAc,CAAA;YACjD,KAAK,qBAAqB;gBACxB,OAAO,uCAAuC,CAAA;SACjD;QACD,OAAO,KAAK,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IACtD,CAAC;IAED,gBAAgB,CAAC,MAA0B,EAAE,MAA0B;QACrE,QAAQ,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;YACnC,KAAK,iBAAiB,CAAC;YACvB,KAAK,iBAAiB,CAAC;YACvB,KAAK,qBAAqB;gBACxB,OAAO,EAAE,CAAA;SACZ;QACD,OAAO,KAAK,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/C,CAAC;CACF","sourcesContent":["import { Connection, JsonRpcProvider, SuiMoveNormalizedModules } from '@mysten/sui.js'\n\nimport { SuiNetwork } from '../network.js'\nimport * as fs from 'fs'\nimport chalk from 'chalk'\nimport { InternalMoveModule, InternalMoveStruct } from '../../move/internal-models.js'\nimport { AbstractCodegen } from '../../move/abstract-codegen.js'\nimport { toInternalModule } from '../move-types.js'\nimport { moduleQname, SPLITTER, structQname, TypeDescriptor } from '../../move/index.js'\nimport { getMeaningfulFunctionParams } from '../utils.js'\nimport {join} from \"path\";\n\nexport async function codegen(abisDir: string, outDir = join('src','types','sui'), genExample = false) {\n if (!fs.existsSync(abisDir)) {\n return\n }\n const gen = new SuiCodegen()\n const numFiles = await gen.generate(abisDir, outDir)\n console.log(chalk.green(`Generated ${numFiles} for Sui`))\n}\n\nfunction getRpcEndpoint(network: SuiNetwork): string {\n switch (network) {\n case SuiNetwork.TEST_NET:\n return 'https://fullnode.testnet.sui.io/'\n }\n return 'https://fullnode.mainnet.sui.io/'\n}\n\nfunction getRpcClient(network: SuiNetwork): JsonRpcProvider {\n return new JsonRpcProvider(new Connection({ fullnode: getRpcEndpoint(network) }))\n}\n\nclass SuiCodegen extends AbstractCodegen<SuiMoveNormalizedModules, SuiNetwork> {\n ADDRESS_TYPE = 'SuiAddress'\n MAIN_NET = SuiNetwork.MAIN_NET\n TEST_NET = SuiNetwork.TEST_NET\n PREFIX = 'Sui'\n STRUCT_FIELD_NAME = 'fields'\n // GENERATE_ON_ENTRY = true\n PAYLOAD_OPTIONAL = true\n\n async fetchModules(account: string, network: SuiNetwork): Promise<SuiMoveNormalizedModules> {\n const client = getRpcClient(network)\n return await client.getNormalizedMoveModulesByPackage({ package: account })\n }\n\n getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[] {\n return getMeaningfulFunctionParams(params)\n }\n\n toInternalModules(modules: SuiMoveNormalizedModules): InternalMoveModule[] {\n return Object.values(modules).map(toInternalModule)\n }\n\n getEventStructs(module: InternalMoveModule) {\n const qname = moduleQname(module)\n const eventMap = new Map<string, InternalMoveStruct>()\n\n for (const struct of module.structs) {\n const abilities = new Set(struct.abilities)\n if (abilities.has('Drop') && abilities.has('Copy')) {\n eventMap.set(qname + SPLITTER + struct.name, struct)\n }\n }\n return eventMap\n }\n\n readModulesFile(fullPath: string) {\n const res = super.readModulesFile(fullPath)\n if (res.result) {\n return res.result\n }\n return res\n }\n\n generateStructs(module: InternalMoveModule, struct: InternalMoveStruct, events: Set<string>): string {\n switch (structQname(module, struct)) {\n case '0x2::object::ID':\n return `export type ${struct.name} = string`\n case '0x2::coin::Coin':\n return `export type ${struct.name}<T> = string`\n case '0x1::option::Option':\n return `export type Option<T> = T | undefined`\n }\n return super.generateStructs(module, struct, events)\n }\n\n generateOnEvents(module: InternalMoveModule, struct: InternalMoveStruct): string {\n switch (structQname(module, struct)) {\n case '0x2::object::ID':\n case '0x2::coin::Coin':\n case '0x1::option::Option':\n return ''\n }\n return super.generateOnEvents(module, struct)\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": "2.11.6-rc.
|
4
|
+
"version": "2.11.6-rc.4",
|
5
5
|
"type": "module",
|
6
6
|
"scripts": {
|
7
7
|
"compile": "tsc && cp src/utils/*.csv lib/utils && cp src/tsup.config.ts lib",
|
@@ -23,8 +23,8 @@
|
|
23
23
|
"@project-serum/anchor": "^0.26.0",
|
24
24
|
"@sentio/bigdecimal": "^9.1.1-patch.3",
|
25
25
|
"@sentio/ethers-v6": "^1.0.28",
|
26
|
-
"@sentio/protos": "^2.11.6-rc.
|
27
|
-
"@sentio/runtime": "^2.11.6-rc.
|
26
|
+
"@sentio/protos": "^2.11.6-rc.4",
|
27
|
+
"@sentio/runtime": "^2.11.6-rc.4",
|
28
28
|
"@solana/web3.js": "^1.74.0",
|
29
29
|
"@types/prettier": "^2.7.2",
|
30
30
|
"aptos-sdk": "npm:aptos@^1.7.2",
|
@@ -87,5 +87,5 @@
|
|
87
87
|
"engines": {
|
88
88
|
"node": ">=16"
|
89
89
|
},
|
90
|
-
"gitHead": "
|
90
|
+
"gitHead": "73f13a94fd95196d0d077685ceaf9306eb18f982"
|
91
91
|
}
|
@@ -7,8 +7,9 @@ import { AptosClient } from 'aptos-sdk'
|
|
7
7
|
import { getMeaningfulFunctionParams } from '../utils.js'
|
8
8
|
import { InternalMoveModule, InternalMoveStruct } from '../../move/internal-models.js'
|
9
9
|
import { AbstractCodegen } from '../../move/abstract-codegen.js'
|
10
|
+
import {join} from "path";
|
10
11
|
|
11
|
-
export async function codegen(abisDir: string, outDir = 'src
|
12
|
+
export async function codegen(abisDir: string, outDir = join('src', 'types', 'aptos'), genExample = false) {
|
12
13
|
if (!fs.existsSync(abisDir)) {
|
13
14
|
return
|
14
15
|
}
|
@@ -70,7 +70,7 @@ export default class EthersSentio extends Ethers.default {
|
|
70
70
|
for (const [idx, file] of files.entries()) {
|
71
71
|
if (file.path.endsWith('__factory.ts')) {
|
72
72
|
file.contents = '// @ts-nocheck\n' + file.contents
|
73
|
-
} else if (file.path.endsWith('factories
|
73
|
+
} else if (file.path.endsWith(join('factories', 'index.ts'))) {
|
74
74
|
file.contents = file.contents.replaceAll("__factory'", "__factory.js'")
|
75
75
|
} else if (file.path.endsWith('_processor.ts')) {
|
76
76
|
} else if (file.path.endsWith(commonPath)) {
|
@@ -8,8 +8,9 @@ import { AbstractCodegen } from '../../move/abstract-codegen.js'
|
|
8
8
|
import { toInternalModule } from '../move-types.js'
|
9
9
|
import { moduleQname, SPLITTER, structQname, TypeDescriptor } from '../../move/index.js'
|
10
10
|
import { getMeaningfulFunctionParams } from '../utils.js'
|
11
|
+
import {join} from "path";
|
11
12
|
|
12
|
-
export async function codegen(abisDir: string, outDir = 'src
|
13
|
+
export async function codegen(abisDir: string, outDir = join('src','types','sui'), genExample = false) {
|
13
14
|
if (!fs.existsSync(abisDir)) {
|
14
15
|
return
|
15
16
|
}
|