diff --git a/packages/core-sdk/src/resources/ipAsset.ts b/packages/core-sdk/src/resources/ipAsset.ts index 86005227..16974eec 100644 --- a/packages/core-sdk/src/resources/ipAsset.ts +++ b/packages/core-sdk/src/resources/ipAsset.ts @@ -1206,7 +1206,7 @@ export class IPAssetClient { return ipId; } - private async isRegistered(ipId: Hex): Promise { + public async isRegistered(ipId: Hex): Promise { return await this.ipAssetRegistryClient.isRegistered({ id: getAddress(ipId, "ipId") }); } diff --git a/packages/core-sdk/test/integration/ipAsset.test.ts b/packages/core-sdk/test/integration/ipAsset.test.ts index 5694f5a6..da6213d1 100644 --- a/packages/core-sdk/test/integration/ipAsset.test.ts +++ b/packages/core-sdk/test/integration/ipAsset.test.ts @@ -106,6 +106,18 @@ describe("IP Asset Functions ", () => { }); expect(response.txHash).to.be.a("string").not.empty; }); + + it("should return true if IP asset is registered", async () => { + const registeredIpId = "0x4197f9d584148cf58cC623a40ac67ce57C0Ec7FA"; // https://explorer.story.foundation/ipa/0x4197f9d584148cf58cC623a40ac67ce57C0Ec7FA + const isRegistered = await client.ipAsset.isRegistered(registeredIpId); + expect(isRegistered).to.be.true; + }); + + it("should return false if IP asset is not registered", async () => { + const unregisteredIpId = "0x1234567890123456789012345678901234567890"; + const isRegistered = await client.ipAsset.isRegistered(unregisteredIpId); + expect(isRegistered).to.be.false; + }); }); describe("NFT Client (SPG)", () => { diff --git a/packages/core-sdk/test/unit/resources/ipAsset.test.ts b/packages/core-sdk/test/unit/resources/ipAsset.test.ts index 46b57b28..99053c53 100644 --- a/packages/core-sdk/test/unit/resources/ipAsset.test.ts +++ b/packages/core-sdk/test/unit/resources/ipAsset.test.ts @@ -1828,4 +1828,25 @@ describe("Test IpAssetClient", () => { expect(result.encodedTxData!.data).to.be.a("string").and.not.empty; }); }); + + describe("Test ipAssetClient.isRegistered", async () => { + beforeEach(() => { + sinon + .stub(ipAssetClient.ipAssetRegistryClient, "ipId") + .resolves("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); + }); + it("should return true if IP asset is registered", async () => { + sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(true); + + expect(await ipAssetClient.isRegistered("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c")).to.be + .true; + }); + + it("should return false if IP asset is not registered", async () => { + sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(false); + + expect(await ipAssetClient.isRegistered("0x2BCAE3197Bc469Cb97B917aa460a12dD95c6538D")).to.be + .false; + }); + }); });