Skip to content

Commit

Permalink
fix(move): return type should be registered (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
zfy0701 authored Nov 12, 2024
1 parent 5e3c019 commit 0def7f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/aptos/src/codegen/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class AptosCodegen extends AbstractCodegen<MoveModuleBytecode, Event | Mo
import { Aptos, Account as AptosAccount, MoveAddressType, PendingTransactionResponse, InputGenerateTransactionOptions, MoveStructId, InputViewFunctionData } from '@aptos-labs/ts-sdk'
`
}
protected generateExtra(address: string, module: InternalMoveModule) {
protected generateExtra(address: string | undefined, module: InternalMoveModule) {
const funcs = module.exposedFunctions.map((f) => this.generateEntryForFunction(module, f))

const viewFuncs = module.exposedFunctions.map((f) => this.generateViewFunction(module, f))
Expand Down
22 changes: 5 additions & 17 deletions packages/move/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,12 @@ export class AccountRegister {
accountImports = new Map<string, AccountModulesImportInfo>()
pendingAccounts = new Set<string>()

register(
module: InternalMoveModule,
tsModuleName: string
): AccountModulesImportInfo {
register(module: InternalMoveModule, tsModuleName: string): AccountModulesImportInfo {
const currentModuleFqn = moduleQname(module)

let accountModuleImports = this.accountImports.get(module.address)
if (!accountModuleImports) {
accountModuleImports = new AccountModulesImportInfo(
module.address,
tsModuleName
)
accountModuleImports = new AccountModulesImportInfo(module.address, tsModuleName)
this.accountImports.set(module.address, accountModuleImports)
// the account has already be processed, delete pending task
this.pendingAccounts.delete(module.address)
Expand All @@ -54,15 +48,12 @@ export class AccountRegister {
return accountModuleImports
}

private registerFunctions(
module: InternalMoveModule,
accountModuleImports: AccountModulesImportInfo
): void {
private registerFunctions(module: InternalMoveModule, accountModuleImports: AccountModulesImportInfo): void {
for (const func of module.exposedFunctions) {
if (!func.isEntry) {
continue
}
for (const param of func.params) {
for (const param of func.params.concat(func.return)) {
for (const type of param.dependedTypes()) {
const [account, module] = moduleQnameForType(type)
accountModuleImports.addImport(account, module)
Expand All @@ -74,10 +65,7 @@ export class AccountRegister {
}
}

private registerStruct(
module: InternalMoveModule,
accountModuleImports: AccountModulesImportInfo
): void {
private registerStruct(module: InternalMoveModule, accountModuleImports: AccountModulesImportInfo): void {
for (const struct of module.structs) {
for (const field of struct.fields) {
for (const type of field.type.dependedTypes()) {
Expand Down

0 comments on commit 0def7f3

Please sign in to comment.