Skip to content

Commit

Permalink
Enhance LicenseTermsData type
Browse files Browse the repository at this point in the history
  • Loading branch information
bonnie57 committed Feb 19, 2025
1 parent 5655080 commit d5af98e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
9 changes: 3 additions & 6 deletions packages/core-sdk/src/resources/ipAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ import { AccessPermission } from "../types/resources/permission";
import { LicenseTerms, RegisterPILTermsRequest } from "../types/resources/license";
import { MAX_ROYALTY_TOKEN, royaltySharesTotalSupply } from "../constants/common";
import { getFunctionSignature } from "../utils/getFunctionSignature";
import { LicensingConfig, ValidatedLicensingConfig } from "../types/common";
import { LicensingConfig } from "../types/common";
import { validateLicenseConfig } from "../utils/validateLicenseConfig";
import { getIpMetadataForWorkflow } from "../utils/getIpMetadataForWorkflow";
import {
Expand Down Expand Up @@ -1880,13 +1880,10 @@ export class IPAssetClient {
licenseTermsData: LicenseTermsData<RegisterPILTermsRequest, LicensingConfig>[],
): Promise<{
licenseTerms: LicenseTerms[];
licenseTermsData: ValidatedLicenseTermsData<LicenseTerms, ValidatedLicensingConfig>[];
licenseTermsData: ValidatedLicenseTermsData[];
}> {
const licenseTerms: LicenseTerms[] = [];
const processedLicenseTermsData: ValidatedLicenseTermsData<
LicenseTerms,
ValidatedLicensingConfig
>[] = [];
const processedLicenseTermsData: ValidatedLicenseTermsData[] = [];
for (let i = 0; i < licenseTermsData.length; i++) {
const licenseTerm = await validateLicenseTerms(licenseTermsData[i].terms, this.rpcClient);
const licensingConfig = validateLicenseConfig(licenseTermsData[i].licensingConfig);
Expand Down
26 changes: 15 additions & 11 deletions packages/core-sdk/src/types/resources/ipAsset.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Address, Hash, Hex, TransactionReceipt } from "viem";

import { TxOptions, WithWipOptions } from "../options";
import { RegisterPILTermsRequest } from "./license";
import { LicenseTerms, RegisterPILTermsRequest } from "./license";
import { EncodedTxData } from "../../abi/generated";
import { IpMetadataAndTxOptions, LicensingConfig } from "../common";
import { IpMetadataAndTxOptions, LicensingConfig, ValidatedLicensingConfig } from "../common";
import { IpMetadataForWorkflow } from "../../utils/getIpMetadataForWorkflow";

export type DerivativeData = {
Expand Down Expand Up @@ -68,20 +68,24 @@ export type RegisterDerivativeResponse = {
txHash?: Hex;
encodedTxData?: EncodedTxData;
};
export type LicenseTermsData<T, U> = {
export type LicenseTermsData<T = RegisterPILTermsRequest, C = LicensingConfig> = {
terms: T;
licensingConfig?: U;
licensingConfig?: C;
};

export type ValidatedLicenseTermsData<T, U> = LicenseTermsData<T, U> & {
licensingConfig: U;
export type ValidatedLicenseTermsData = Omit<
LicenseTermsData<LicenseTerms, ValidatedLicensingConfig>,
"licensingConfig"
> & {
licensingConfig: ValidatedLicensingConfig;
};

export type MintAndRegisterIpAssetWithPilTermsRequest = {
spgNftContract: Address;
/** Indicates whether the license terms can be attached to the same IP ID or not. */
allowDuplicates: boolean;
/** The data of the license and its configuration to be attached to the IP. */
licenseTermsData: LicenseTermsData<RegisterPILTermsRequest, LicensingConfig>[];
licenseTermsData: LicenseTermsData[];
/**
* The address to receive the minted NFT.
* @default wallet address
Expand Down Expand Up @@ -124,7 +128,7 @@ export type RegisterIpAndAttachPilTermsRequest = {
nftContract: Address;
tokenId: bigint | string | number;
/** The data of the license and its configuration to be attached to the IP. */
licenseTermsData: LicenseTermsData<RegisterPILTermsRequest, LicensingConfig>[];
licenseTermsData: LicenseTermsData[];
/**
* The deadline for the signature in seconds.
* @default 1000s
Expand Down Expand Up @@ -257,7 +261,7 @@ export type MintAndRegisterIpRequest = {
export type RegisterPilTermsAndAttachRequest = {
ipId: Address;
/** The data of the license and its configuration to be attached to the IP. */
licenseTermsData: LicenseTermsData<RegisterPILTermsRequest, LicensingConfig>[];
licenseTermsData: LicenseTermsData[];
/** The deadline for the signature in seconds.
* @default 1000s
*/
Expand Down Expand Up @@ -336,7 +340,7 @@ export type RegisterIPAndAttachLicenseTermsAndDistributeRoyaltyTokensRequest = {
nftContract: Address;
tokenId: bigint | string | number;
/** The data of the license and its configuration to be attached to the new group IP. */
licenseTermsData: LicenseTermsData<RegisterPILTermsRequest, LicensingConfig>[];
licenseTermsData: LicenseTermsData[];
/**
* The deadline for the signature in seconds.
* @default 1000s
Expand Down Expand Up @@ -404,7 +408,7 @@ export type MintAndRegisterIpAndAttachPILTermsAndDistributeRoyaltyTokensRequest
/** Set to true to allow minting an NFT with a duplicate metadata hash. */
allowDuplicates: boolean;
/** The data of the license and its configuration to be attached to the new group IP. */
licenseTermsData: LicenseTermsData<RegisterPILTermsRequest, LicensingConfig>[];
licenseTermsData: LicenseTermsData[];
/** Authors of the IP and their shares of the royalty tokens */
royaltyShares: RoyaltyShare[];
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/core-sdk/src/types/resources/license.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export type SetLicensingConfigRequest = {
ipId: Address;
/** The ID of the license terms within the license template. */
licenseTermsId: string | number | bigint;
/** The address of the license template used, If not specified, the configuration applies to all licenses. */
/** The address of the license template used. */
licenseTemplate: Address;
/** The licensing configuration for the license. */
licensingConfig?: LicensingConfig;
Expand Down
8 changes: 4 additions & 4 deletions packages/core-sdk/test/unit/utils/feeUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import {
royaltyModuleAddress,
derivativeWorkflowsAddress,
wrappedIpAddress,
erc20Address,
multicall3Address,
erc20Address,
} from "../../../src/abi/generated";
import { createMock, generateRandomAddress, generateRandomHash } from "../testUtils";
import { ContractCallWithFees } from "../../../src/types/utils/wip";
import { aeneid, txHash } from "../mockData";
import { contractCallWithFees } from "../../../src/utils/feeUtils";
import { TEST_WALLET_ADDRESS } from "../../integration/utils/util";
import { WIP_TOKEN_ADDRESS } from "../../../src/constants/common";
import { ContractCallWithFees } from "../../../src/types/utils/wip";
import { ERC20Client, WIPTokenClient } from "../../../src/utils/token";
import { aeneid, txHash } from "../mockData";
import { contractCallWithFees } from "../../../src/utils/feeUtils";

chai.use(chaiAsPromised);
const expect = chai.expect;
Expand Down

0 comments on commit d5af98e

Please sign in to comment.