Skip to content

Commit

Permalink
dto and save support for MintFeeConfiguration v1 (#463)
Browse files Browse the repository at this point in the history
v1

Add mintFeeConfiguration to TokenMintConfigurationDto and
saveTokenMintConfiguration methods()
  • Loading branch information
sentientforest authored Dec 10, 2024
1 parent 560337d commit c7fba7e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
11 changes: 11 additions & 0 deletions chain-api/src/types/mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { ArrayUniqueObjects, BigNumberIsNotNegative, BigNumberProperty, IsUserAl
import { TokenClassKey } from "./TokenClass";
import {
BurnToMintConfiguration,
MintFeeConfiguration,
PostMintLockConfiguration,
TokenMintConfiguration
} from "./TokenMintConfiguration";
Expand Down Expand Up @@ -410,6 +411,16 @@ export class TokenMintConfigurationDto extends ChainCallDTO {
@ValidateNested()
@Type(() => PostMintLockConfiguration)
postMintLock?: PostMintLockConfiguration;

@JSONSchema({
description:
"(optional) Specify a `MintFeeConfiguration` to define " +
"additional properties that affect $GALA `MintToken` fees"
})
@IsOptional()
@ValidateNested()
@Type(() => MintFeeConfiguration)
additionalFee?: MintFeeConfiguration;
}

@JSONSchema({
Expand Down
1 change: 0 additions & 1 deletion chaincode/src/mint/fetchMintConfigurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
ValidationFailedError,
createValidDTO
} from "@gala-chain/api";
import { plainToInstance } from "class-transformer";

import { GalaChainContext, createValidChainObject } from "../types";
import { getObjectsByPartialCompositeKeyWithPagination, takeUntilUndefined } from "../utils";
Expand Down
19 changes: 18 additions & 1 deletion chaincode/src/mint/saveMintConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
BurnToMintConfiguration,
ChainError,
ErrorCode,
MintFeeConfiguration,
PostMintLockConfiguration,
TokenClass,
TokenMintConfiguration,
Expand All @@ -34,6 +35,7 @@ export interface IMintConfiguration {
preMintBurn?: BurnToMintConfiguration;
postMintBurn?: BurnToMintConfiguration;
postMintLock?: PostMintLockConfiguration;
additionalFee?: MintFeeConfiguration;
}

const curatorOrgMsp = process.env.CURATOR_ORG_MSP ?? "CuratorOrg";
Expand All @@ -42,7 +44,16 @@ export async function saveTokenMintConfiguration(
ctx: GalaChainContext,
data: IMintConfiguration
): Promise<TokenMintConfiguration> {
const { collection, category, type, additionalKey, preMintBurn, postMintBurn, postMintLock } = data;
const {
collection,
category,
type,
additionalKey,
preMintBurn,
postMintBurn,
postMintLock,
additionalFee
} = data;

const existingTokenClass = await getObjectByKey(
ctx,
Expand Down Expand Up @@ -77,6 +88,12 @@ export async function saveTokenMintConfiguration(

newConfiguration.validatePostProcessingTotals();

if (additionalFee !== undefined) {
await additionalFee.validateOrReject();

newConfiguration.additionalFee = additionalFee;
}

await putChainObject(ctx, newConfiguration);

return newConfiguration;
Expand Down

0 comments on commit c7fba7e

Please sign in to comment.