Skip to content

Commit 32c5f5b

Browse files
committed
Rename InnerPILTerms and PILTerms
1 parent f447b49 commit 32c5f5b

File tree

10 files changed

+41
-41
lines changed

10 files changed

+41
-41
lines changed

packages/core-sdk/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export type {
7070
MintLicenseTokensResponse,
7171
LicenseTermsId,
7272
PILTerms,
73+
PILTermsInput,
7374
PredictMintingLicenseFeeRequest,
7475
SetLicensingConfigRequest,
7576
SetLicensingConfigResponse,

packages/core-sdk/src/resources/PILFlavor.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Address, zeroAddress } from "viem";
22

3-
import { InnerPILTerms } from "../types/resources/license";
3+
import { PILTerms } from "../types/resources/license";
44
import { getAddress } from "../utils/utils";
55
import { getRevenueShare } from "../utils/licenseTermsHelper";
66

77
export class PILFlavor {
8-
static nonComSocialRemixingPIL(): InnerPILTerms {
8+
static nonComSocialRemixingPIL(): PILTerms {
99
return {
1010
transferable: true,
1111
royaltyPolicy: zeroAddress,
@@ -31,7 +31,7 @@ export class PILFlavor {
3131
defaultMintingFee: bigint | number | string,
3232
royaltyPolicy: Address,
3333
currency: Address,
34-
): InnerPILTerms {
34+
): PILTerms {
3535
if (defaultMintingFee === undefined || currency === undefined || royaltyPolicy === undefined) {
3636
throw new Error(
3737
"DefaultMintingFee, currency and royaltyPolicy are required for commercial use PIL.",
@@ -63,7 +63,7 @@ export class PILFlavor {
6363
royaltyPolicy: Address,
6464
currency: Address,
6565
commercialRevShare: number | string,
66-
): InnerPILTerms {
66+
): PILTerms {
6767
return {
6868
transferable: true,
6969
royaltyPolicy: getAddress(royaltyPolicy, "royaltyPolicyLAPAddress"),

packages/core-sdk/src/resources/ipAsset.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ import {
9797
import { getRevenueShare, validateLicenseTerms } from "../utils/licenseTermsHelper";
9898
import { getDeadline, getPermissionSignature, getSignature } from "../utils/sign";
9999
import { AccessPermission } from "../types/resources/permission";
100-
import { InnerPILTerms, InnerLicensingConfig, PILTerms } from "../types/resources/license";
100+
import { PILTerms, InnerLicensingConfig, PILTermsInput } from "../types/resources/license";
101101
import { MAX_ROYALTY_TOKEN, royaltySharesTotalSupply } from "../constants/common";
102102
import { getFunctionSignature } from "../utils/getFunctionSignature";
103103
import { LicensingConfig } from "../types/common";
@@ -769,7 +769,7 @@ export class IPAssetClient {
769769
}));
770770
// Due to emit event log by sequence, we need to get license terms id from request.args
771771
for (let j = 0; j < request.args.length; j++) {
772-
const licenseTerms: InnerPILTerms[] = [];
772+
const licenseTerms: PILTerms[] = [];
773773
const licenseTermsData = request.args[j].licenseTermsData;
774774
for (let i = 0; i < licenseTermsData.length; i++) {
775775
const licenseTerm = await validateLicenseTerms(
@@ -1942,7 +1942,7 @@ export class IPAssetClient {
19421942
return await this.ipAssetRegistryClient.isRegistered({ id: getAddress(ipId, "ipId") });
19431943
}
19441944

1945-
private async getLicenseTermsId(licenseTerms: InnerPILTerms[]): Promise<bigint[]> {
1945+
private async getLicenseTermsId(licenseTerms: PILTerms[]): Promise<bigint[]> {
19461946
const licenseTermsIds: bigint[] = [];
19471947
for (const licenseTerm of licenseTerms) {
19481948
const licenseRes = await this.licenseTemplateClient.getLicenseTermsId({
@@ -2066,13 +2066,13 @@ export class IPAssetClient {
20662066
}
20672067

20682068
private async validateLicenseTermsData(
2069-
licenseTermsData: LicenseTermsData<PILTerms, LicensingConfig>[],
2069+
licenseTermsData: LicenseTermsData<PILTermsInput, LicensingConfig>[],
20702070
): Promise<{
2071-
licenseTerms: InnerPILTerms[];
2072-
licenseTermsData: LicenseTermsData<InnerPILTerms, InnerLicensingConfig>[];
2071+
licenseTerms: PILTerms[];
2072+
licenseTermsData: LicenseTermsData<PILTerms, InnerLicensingConfig>[];
20732073
}> {
2074-
const licenseTerms: InnerPILTerms[] = [];
2075-
const processedLicenseTermsData: LicenseTermsData<InnerPILTerms, InnerLicensingConfig>[] = [];
2074+
const licenseTerms: PILTerms[] = [];
2075+
const processedLicenseTermsData: LicenseTermsData<PILTerms, InnerLicensingConfig>[] = [];
20762076
for (let i = 0; i < licenseTermsData.length; i++) {
20772077
const licenseTerm = await validateLicenseTerms(licenseTermsData[i].terms, this.rpcClient);
20782078
licenseTerms.push(licenseTerm);

packages/core-sdk/src/resources/license.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ import {
2424
PIL_TYPE,
2525
AttachLicenseTermsResponse,
2626
LicenseTermsId,
27-
InnerPILTerms,
27+
PILTerms,
2828
PredictMintingLicenseFeeRequest,
2929
SetLicensingConfigRequest,
3030
SetLicensingConfigResponse,
3131
RegisterPILTermsRequest,
3232
CommercialLicenseTerms,
3333
CommercialRemixLicenseTerms,
34-
PILTerms,
34+
PILTermsInput,
3535
} from "../types/resources/license";
3636
import { handleError } from "../utils/errors";
3737
import { getRevenueShare, validateLicenseTerms } from "../utils/licenseTermsHelper";
@@ -73,13 +73,13 @@ export class LicenseClient {
7373
request: RegisterPILTermsRequest<PILType>,
7474
): Promise<RegisterPILResponse> {
7575
try {
76-
let terms: InnerPILTerms;
76+
let terms: PILTerms;
7777
if (!request.terms && !request.PILType) {
7878
terms = PILFlavor.nonComSocialRemixingPIL();
7979
} else if (request.PILType !== undefined) {
8080
terms = this.createTerms(request.PILType, request.terms);
8181
} else {
82-
terms = await validateLicenseTerms(request.terms as PILTerms, this.rpcClient);
82+
terms = await validateLicenseTerms(request.terms as PILTermsInput, this.rpcClient);
8383
}
8484
const licenseTermsId = await this.getLicenseTermsId(terms);
8585
if (licenseTermsId !== 0n) {
@@ -432,15 +432,15 @@ export class LicenseClient {
432432
handleError(error, "Failed to set licensing config");
433433
}
434434
}
435-
private async getLicenseTermsId(request: InnerPILTerms): Promise<LicenseTermsIdResponse> {
435+
private async getLicenseTermsId(request: PILTerms): Promise<LicenseTermsIdResponse> {
436436
const licenseRes = await this.licenseTemplateClient.getLicenseTermsId({ terms: request });
437437
return licenseRes.selectedLicenseTermsId;
438438
}
439439
private createTerms(
440440
PILType: PIL_TYPE,
441441
terms: RegisterPILTermsRequest<PIL_TYPE>["terms"],
442-
): InnerPILTerms {
443-
let innerTerms: InnerPILTerms;
442+
): PILTerms {
443+
let innerTerms: PILTerms;
444444
switch (PILType) {
445445
case PIL_TYPE.NON_COMMERCIAL_REMIX:
446446
innerTerms = PILFlavor.nonComSocialRemixingPIL();

packages/core-sdk/src/types/resources/ipAsset.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Address, Hex } from "viem";
22

33
import { TxOptions } from "../options";
4-
import { PILTerms } from "./license";
4+
import { PILTermsInput } from "./license";
55
import { EncodedTxData } from "../../abi/generated";
66
import { IpMetadataAndTxOption, LicensingConfig } from "../common";
77
import { IpMetadataForWorkflow } from "../../utils/getIpMetadataForWorkflow";
@@ -64,7 +64,7 @@ export type LicenseTermsData<T, U> = {
6464
export type MintAndRegisterIpAssetWithPilTermsRequest = {
6565
spgNftContract: Address;
6666
allowDuplicates: boolean;
67-
licenseTermsData: LicenseTermsData<PILTerms, LicensingConfig>[];
67+
licenseTermsData: LicenseTermsData<PILTermsInput, LicensingConfig>[];
6868
recipient?: Address;
6969
royaltyPolicyAddress?: Address;
7070
} & IpMetadataAndTxOption;
@@ -99,7 +99,7 @@ export type RegisterIpAndMakeDerivativeResponse = {
9999
export type RegisterIpAndAttachPilTermsRequest = {
100100
nftContract: Address;
101101
tokenId: bigint | string | number;
102-
licenseTermsData: LicenseTermsData<PILTerms, LicensingConfig>[];
102+
licenseTermsData: LicenseTermsData<PILTermsInput, LicensingConfig>[];
103103
deadline?: bigint | number | string;
104104
} & IpMetadataAndTxOption;
105105

@@ -224,7 +224,7 @@ export type MintAndRegisterIpRequest = {
224224

225225
export type RegisterPilTermsAndAttachRequest = {
226226
ipId: Address;
227-
licenseTermsData: LicenseTermsData<PILTerms, LicensingConfig>[];
227+
licenseTermsData: LicenseTermsData<PILTermsInput, LicensingConfig>[];
228228
deadline?: string | number | bigint;
229229
txOptions?: TxOptions;
230230
};
@@ -297,7 +297,7 @@ export type BatchRegisterResponse = {
297297
export type RegisterIPAndAttachLicenseTermsAndDistributeRoyaltyTokensRequest = {
298298
nftContract: Address;
299299
tokenId: bigint | string | number;
300-
licenseTermsData: LicenseTermsData<PILTerms, LicensingConfig>[];
300+
licenseTermsData: LicenseTermsData<PILTermsInput, LicensingConfig>[];
301301
deadline?: string | number | bigint;
302302
royaltyShares: RoyaltyShare[];
303303
txOptions?: Omit<TxOptions, "encodedTxDataOnly">;
@@ -347,7 +347,7 @@ export type MintAndRegisterIpAndAttachPILTermsAndDistributeRoyaltyTokensRequest
347347
spgNftContract: Address;
348348
allowDuplicates: boolean;
349349
licenseTermsData: {
350-
terms: PILTerms;
350+
terms: PILTermsInput;
351351
licensingConfig: LicensingConfig;
352352
}[];
353353
royaltyShares: RoyaltyShare[];

packages/core-sdk/src/types/resources/license.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ export interface CommercialRemixLicenseTerms extends CommercialLicenseTerms {
1919

2020
/**
2121
* This structure defines the terms for a Programmable IP License (PIL). These terms can be attached to IP Assets. The legal document of the PIL can be found in this repository.
22-
* @type PILTerms
2322
**/
24-
export interface PILTerms extends CommercialLicenseTerms, CommercialRemixLicenseTerms {
23+
export interface PILTermsInput extends CommercialLicenseTerms, CommercialRemixLicenseTerms {
2524
/** Indicates whether the license is transferable or not.*/
2625
transferable: boolean;
2726
/** The expiration period of the license.*/
@@ -58,7 +57,7 @@ export type RegisterPILTermsRequest<PILType extends PIL_TYPE> = {
5857
| (PILType extends PIL_TYPE.COMMERCIAL_USE ? CommercialLicenseTerms : never)
5958
| (PILType extends PIL_TYPE.COMMERCIAL_REMIX ? CommercialRemixLicenseTerms : never)
6059
| (PILType extends PIL_TYPE.NON_COMMERCIAL_REMIX ? undefined : never)
61-
| PILTerms;
60+
| PILTermsInput;
6261
/** The type of the license terms to be registered, including no-commercial, commercial,commercial remix. */
6362
PILType?: PILType;
6463
/** This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property. */
@@ -72,8 +71,8 @@ export type RegisterPILResponse = {
7271
/** The encoded transaction data of the register PIL terms. */
7372
encodedTxData?: EncodedTxData;
7473
};
75-
export type InnerPILTerms = Omit<
76-
PILTerms,
74+
export type PILTerms = Omit<
75+
PILTermsInput,
7776
| "defaultMintingFee"
7877
| "expiration"
7978
| "commercialRevCeiling"

packages/core-sdk/src/utils/licenseTermsHelper.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { PublicClient, zeroAddress } from "viem";
22

3-
import { InnerPILTerms, PILTerms } from "../types/resources/license";
3+
import { PILTerms, PILTermsInput } from "../types/resources/license";
44
import { getAddress } from "./utils";
55
import { RoyaltyModuleReadOnlyClient } from "../abi/generated";
66
import { MAX_ROYALTY_TOKEN } from "../constants/common";
77

88
export async function validateLicenseTerms(
9-
params: PILTerms,
9+
params: PILTermsInput,
1010
rpcClient: PublicClient,
11-
): Promise<InnerPILTerms> {
11+
): Promise<PILTerms> {
1212
const { royaltyPolicy, currency } = params;
1313
const royaltyModuleReadOnlyClient = new RoyaltyModuleReadOnlyClient(rpcClient);
1414
if (getAddress(royaltyPolicy, "params.royaltyPolicy") !== zeroAddress) {
@@ -42,7 +42,7 @@ export async function validateLicenseTerms(
4242
return object;
4343
}
4444

45-
const verifyCommercialUse = (terms: InnerPILTerms) => {
45+
const verifyCommercialUse = (terms: PILTerms) => {
4646
if (!terms.commercialUse) {
4747
if (terms.commercialAttribution) {
4848
throw new Error("Cannot add commercial attribution when commercial use is disabled.");
@@ -71,7 +71,7 @@ const verifyCommercialUse = (terms: InnerPILTerms) => {
7171
}
7272
};
7373

74-
const verifyDerivatives = (terms: InnerPILTerms) => {
74+
const verifyDerivatives = (terms: PILTerms) => {
7575
if (!terms.derivativesAllowed) {
7676
if (terms.derivativesAttribution) {
7777
throw new Error("Cannot add derivative attribution when derivative use is disabled.");

packages/core-sdk/test/unit/resources/ipAsset.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { LicenseRegistryReadOnlyClient } from "../../../src/abi/generated";
1818
import { MAX_ROYALTY_TOKEN, royaltySharesTotalSupply } from "../../../src/constants/common";
1919
import { LicensingConfig } from "../../../src/types/common";
2020
import { DerivativeData } from "../../../src/types/resources/ipAsset";
21-
import { InnerPILTerms } from "../../../src/types/resources/license";
21+
import { PILTerms } from "../../../src/types/resources/license";
2222
const {
2323
RoyaltyModuleReadOnlyClient,
2424
IpRoyaltyVaultImplReadOnlyClient,
@@ -27,7 +27,7 @@ const {
2727
const txHash = "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997";
2828
chai.use(chaiAsPromised);
2929
const expect = chai.expect;
30-
const licenseTerms: InnerPILTerms = {
30+
const licenseTerms: PILTerms = {
3131
transferable: true,
3232
royaltyPolicy: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c",
3333
defaultMintingFee: BigInt(1),

packages/core-sdk/test/unit/resources/license.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { LicenseClient } from "../../../src";
55
import { PublicClient, WalletClient, Account, zeroAddress, Hex } from "viem";
66
import chaiAsPromised from "chai-as-promised";
77
import { PiLicenseTemplateGetLicenseTermsResponse } from "../../../src/abi/generated";
8-
import { PILTerms, PIL_TYPE } from "../../../src/types/resources/license";
8+
import { PILTermsInput, PIL_TYPE } from "../../../src/types/resources/license";
99
import { MockERC20 } from "../../integration/utils/mockERC20";
1010
const { RoyaltyModuleReadOnlyClient } = require("../../../src/abi/generated");
1111

@@ -38,7 +38,7 @@ describe("Test LicenseClient", () => {
3838
.resolves(true);
3939
RoyaltyModuleReadOnlyClient.prototype.isWhitelistedRoyaltyToken = sinon.stub().resolves(true);
4040
});
41-
const licenseTerms: PILTerms = {
41+
const licenseTerms: PILTermsInput = {
4242
defaultMintingFee: 3n,
4343
currency: MockERC20.address,
4444
royaltyPolicy: zeroAddress,

packages/core-sdk/test/unit/utils/licenseTermsHelper.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { PublicClient, zeroAddress } from "viem";
2-
import { PILTerms } from "../../../src/types/resources/license";
2+
import { PILTermsInput } from "../../../src/types/resources/license";
33
import { getRevenueShare, validateLicenseTerms } from "../../../src/utils/licenseTermsHelper";
44
import { expect } from "chai";
55
import { MockERC20 } from "../../integration/utils/mockERC20";
@@ -13,7 +13,7 @@ describe("License Terms Helper", () => {
1313
beforeEach(() => {
1414
rpcMock = createMock<PublicClient>();
1515
});
16-
const licenseTerms: PILTerms = {
16+
const licenseTerms: PILTermsInput = {
1717
defaultMintingFee: 1513n,
1818
currency: MockERC20.address,
1919
royaltyPolicy: zeroAddress,

0 commit comments

Comments
 (0)