Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add createAssetId function #2646

Closed
matt-user opened this issue Jun 28, 2024 · 3 comments
Closed

Add createAssetId function #2646

matt-user opened this issue Jun 28, 2024 · 3 comments
Labels
feat Issue is a feature good first issue Suitable for newcomers looking to contribute

Comments

@matt-user
Copy link
Contributor

matt-user commented Jun 28, 2024

Motivation

Creating an assetId manually is easy, but is also easy to mess up. For new devs this function would be helpful.

Summary

Usage example

const assetId = createAssetId(contractId, subId)

Possible implementations

function createAssetId(contractId: string, subId: string) {
    const contractIdBytes = arrayify(contractId);
    const subIdBytes = arrayify(subId);
    const bits = sha256(concat([contractIdBytes, subIdBytes]));
    const assetId: AssetIdInput = {
        bits
    }
    return assetId
}
@matt-user matt-user added feat Issue is a feature good first issue Suitable for newcomers looking to contribute labels Jun 28, 2024
@matt-user matt-user changed the title There should be a createAssetId function Add createAssetId function Jun 28, 2024
@petertonysmith94
Copy link
Contributor

Could this be an extension of getMintedAssetId?

@Torres-ssf
Copy link
Contributor

@matt-user We already have the helper getMintesAssetId that hashes both the contractId and the subId to return the assetId

@bolajahmad
Copy link
Contributor

I agree with @Torres-ssf, there is already the getMintedAsset that returns pretty much the assetId and is the same function I had to use when writing the createAssetId. They are also located in the same file

Is there some special feature of the new createAssetId.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Issue is a feature good first issue Suitable for newcomers looking to contribute
Projects
None yet
Development

No branches or pull requests

4 participants