clarinet icon indicating copy to clipboard operation
clarinet copied to clipboard

Unify signature of expect NFT and FT events

Open friedger opened this issue 3 years ago • 3 comments
trafficstars

expectFungibleTokenTransferEvent and expectNonFungibleTokenTransferEvent have confusing signatures:

    expectFungibleTokenTransferEvent(
      amount: Number|bigint,
      sender: String,
      recipient: String,
      assetId: String,
    ): Object;

and

    expectNonFungibleTokenTransferEvent(
      tokenId: String, 
      sender: String, 
      recipient: String, 
      assetAddress: String,
      assetId: String
    ): Object;

For the first, assetId includes the native asset while for the second the asset id is split into assetAddress and assetName (named as assetId)

The signature should use the same assetId for all expect-NFT-and-FT-event functions. And expecting assetContractAddress, assetContractName and assetName in one string.

friedger avatar Feb 13 '22 21:02 friedger

@friedger what do you think about changing also signatures of these functions to match the signatures of clarity functions (make assetId first argument)?

LNow avatar Feb 17 '22 00:02 LNow

@friedger what do you think about changing also signatures of these functions to match the signatures of clarity functions (make assetId first argument)?

tokenId and amount are already the first argument, like in the transfer functions.

friedger avatar Feb 17 '22 18:02 friedger

I was thinking about something like this:

// (ft-transfer? token-name amount sender recipient)
expectFungibleTokenTransferEvent(assetId: String, amount: Number|bigint, sender: String, recipient: String)

// (ft-mint? token-name amount recipient)
expectFungibleTokenMintEvent(assetId: String, amount: Number|bigint, recipient: String, )

// (ft-burn? token-name amount sender)
expectFungibleTokenBurnEvent(assetId: String, amount: Number|bigint, sender: String)

// (nft-transfer? asset-class asset-identifier sender recipient)
expectNonFungibleTokenTransferEvent(assetId: String, tokenId: String, sender: String, recipient: String)

// (nft-mint? asset-class asset-identifier recipient)
expectNonFungibleTokenMintEvent(assetId: String, tokenId: String, recipient: String)

// (nft-burn? asset-class asset-identifier recipient)
expectNonFungibleTokenBurnEvent(assetId: String, tokenId: String, sender: String)

LNow avatar Feb 24 '22 17:02 LNow

To be improved as part of clarinet-sdk https://github.com/hirosystems/clarinet/issues/1065

hugoclrd avatar Sep 20 '23 16:09 hugoclrd

Closing this issue now that the SDK is out. But we should keep this in mind for #1128

hugoclrd avatar Feb 26 '24 18:02 hugoclrd