Skip to content

Commit

Permalink
fix(sui): don't include txcontext arg in builder functions (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
nithilan4 authored Feb 7, 2024
1 parent 45ea76b commit 2c2b65c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions packages/move/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ export class TypeDescriptor<T = any> {
const parts = this.qname.split(SPLITTER)
return parts[parts.length - 1]
}

module(): string {
const parts = this.qname.split(SPLITTER)
return parts[parts.length - 2]
}
}

export function parseMoveType(type: string): TypeDescriptor {
Expand Down
7 changes: 5 additions & 2 deletions packages/sui/src/codegen/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,11 @@ export class SuiCodegen extends AbstractCodegen<

private generateArgs(module: InternalMoveModule, func: InternalMoveFunction) {
const args = []
const argsLen = func.params.length
for (const [idx, arg] of func.params.entries()) {
if (arg.reference) {
if (idx === argsLen - 1 && arg.name() == 'TxContext' && arg.module() == 'tx_context') {
continue
} else if (arg.reference) {
args.push({
paramType: `${this.ADDRESS_TYPE} | ObjectCallArg | TransactionArgument`,
callValue: `_args.push(transactionArgumentOrObject(args[${idx}], tx))`
Expand Down Expand Up @@ -197,7 +200,7 @@ export class SuiCodegen extends AbstractCodegen<
return `export function ${camel(normalizeToJSName(func.name))}${genericString}(tx: TransactionBlock,
args: [${args.map((a) => a.paramType).join(',')}],
${typeParamArg.length > 0 ? `typeArguments: [${typeParamArg}]` : ``} ):
TransactionArgument & [ ${'TransactionArgument,'.repeat(func.params.length)} ] {
TransactionArgument & [ ${'TransactionArgument,'.repeat(args.length)} ] {
const _args: any[] = []
${args.map((a) => a.callValue).join('\n')}
Expand Down

0 comments on commit 2c2b65c

Please sign in to comment.