Skip to content

Conversation

@PatrickDinh
Copy link
Contributor

Proposed Changes

Base automatically changed from composer-integration to decoupling November 27, 2025 04:02
@PatrickDinh PatrickDinh marked this pull request as ready for review November 28, 2025 03:14

export type ABIMethodReturn = {
type: ABIReturnType
type: ABIType | 'void'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type: ABIType | 'void'
type: ABIMethodReturnType

*
* This value will be undefined if decoding failed or the method does not return a value (return type "void")
*/
returnValue: ABIValue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be optional?

method: ABIMethod
/** The raw return value as bytes.
*
* This value will be empty if the method does not return a value (return type "void")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This value will be empty

As in an empty Uint8Array, rather than undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed the comments in this type when integrating ABI features into utils. I think empty and undefined aren't applicable anymore.

  • The method returns undefined when ABIMethod returns void. It doesn't return ABIReturn.
  • There is another union variant that describes the decoding error case.

I updated the comments to reflex this fact.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to go into the migration guide or was it previous behaviour too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a previous behaviour

public static getABIReturn(

and the type for ABIReturn is

/** The return value of an ABI method call */
export type ABIReturn =
  | {
      rawReturnValue: Uint8Array
      returnValue: ABIValue
      method: ABIMethod
      decodeError: undefined
    }
  | { rawReturnValue?: undefined; returnValue?: undefined; method?: undefined; decodeError: Error }

}

const name = signature.slice(0, argsStart)
const args = parseTupleContent(signature.slice(argsStart + 1, argsEnd)) // hmmm the error is bad
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// hmmm the error is bad

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment was copied over from algokit-core. I'm not sure the context now to be honest. I had a look at the error messages inside parseTupleContent and they look ok to me.

One thing jumped out is that in abi-type.ts we use prefix for error messages, for example Validation Error: the content should not have consecutive commas. The rest of utils-ts doesn't do that.

Copy link
Contributor

@neilcampbell neilcampbell Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we keep consistent with utils, so remove the prefix. I guess remove the comment too?

bare_call_config: CallConfig
}

interface ABIContractParams {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure ABI is the correct term to use here?
ABI mainly refers to the encoding standard. Maybe AppSpecParams? Same applies for ABIContractNetworks and ABIContractNetworkInfo, however the rest of the names seem ok to me.

Potentially this also allows us to drop the Param suffix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The names were copied from algosdk over. I think ContractDefinition is a better name. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, maybe it's fine to keep the same. Are they user facing types?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll revert to the algosdk names. They aren't explicitly exported by are referenced by AppSpec which is public

if (str.endsWith(']')) {
const stringMatches = str.match(STATIC_ARRAY_REGEX)
if (!stringMatches || stringMatches.length !== 3) {
throw new Error(`malformed static array string: ${str}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new Error(`malformed static array string: ${str}`)
throw new Error(`Malformed static array string: ${str}`)

We tend to start error message with uppercase. This applies to all the changes removing the prefix.

@PatrickDinh PatrickDinh merged commit 49ba7de into decoupling Dec 1, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants