Skip to content

Commit

Permalink
Feat/make isRegistered public (storyprotocol#311)
Browse files Browse the repository at this point in the history
* make isRegistered public

* make isRegistered public
  • Loading branch information
DonFungible authored and bonnie57 committed Nov 14, 2024
1 parent 9f752f0 commit c9eb9ee
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/core-sdk/src/resources/ipAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ export class IPAssetClient {
return ipId;
}

private async isRegistered(ipId: Hex): Promise<boolean> {
public async isRegistered(ipId: Hex): Promise<boolean> {
return await this.ipAssetRegistryClient.isRegistered({ id: getAddress(ipId, "ipId") });
}

Expand Down
12 changes: 12 additions & 0 deletions packages/core-sdk/test/integration/ipAsset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)", () => {
Expand Down
21 changes: 21 additions & 0 deletions packages/core-sdk/test/unit/resources/ipAsset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});
});

0 comments on commit c9eb9ee

Please sign in to comment.