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 mintNonFungible functions with token index support #157

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ADD . /SBOM
RUN apk add --no-cache curl
RUN curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.48.3
RUN trivy fs --format spdx-json --output /sbom.spdx.json /SBOM
RUN trivy sbom /sbom.spdx.json --severity UNKNOWN,HIGH,CRITICAL --exit-code 1
RUN trivy sbom /sbom.spdx.json --severity UNKNOWN,HIGH,CRITICAL --db-repository public.ecr.aws/aquasecurity/trivy-db --exit-code 1

FROM $BASE_IMAGE
RUN apk add curl=8.9.1-r1
Expand Down
37 changes: 37 additions & 0 deletions src/tokens/erc1155.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,43 @@ export const DynamicMethods: Record<TokenOperation, MethodSignature[]> = {
return undefined;
},
},
{
// Option with token index and single receiver
name: 'mintNonFungibleWithURI',
inputs: [{ type: 'uint256' }, { type: 'uint256' }, { type: 'address' }, { type: 'bytes' }, { type: 'string' }],
map: (poolLocator: PoolLocator, dto: TokenMint) => {
if (!poolLocator.isFungible) {
const amount = BigInt(dto.amount);
if (amount !== BigInt(1)) {
throw new BadRequestException('Amount for nonfungible tokens must be 1');
}
return [
computeTokenId(poolLocator),
dto.tokenIndex,
dto.to,
encodeHex(dto.data ?? ''),
dto.uri ?? '',
];
}
return undefined;
},
},
{
// Option with token index and single receiver
name: 'mintNonFungible',
inputs: [{ type: 'uint256' }, { type: 'uint256' }, { type: 'address' }, { type: 'bytes' }],
map: (poolLocator: PoolLocator, dto: TokenMint) => {
if (!poolLocator.isFungible) {
// In the case of a non-fungible token, we parse the value as a whole integer count of NFTs to mint
const amount = parseInt(dto.amount);
if (amount !== 1) {
throw new BadRequestException('Amount for nonfungible tokens must be 1');
}
return [computeTokenId(poolLocator), dto.tokenIndex, dto.to, encodeHex(dto.data ?? '')];
}
return undefined;
},
},
{
// Source: OpenZeppelin extension
name: 'mint',
Expand Down
Loading