Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SDK according to PoC Periphery Supported Workflows #292

Merged
merged 24 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1f55307
Remove collectRoyaltyTokens methods and Update getRoyaltyVaultAddress…
bonnie57 Sep 30, 2024
fe98761
Update createNFTCollection params
bonnie57 Sep 30, 2024
07edc67
Update contract addresses
bonnie57 Sep 30, 2024
59baaf4
Update unit and integration tests
bonnie57 Sep 30, 2024
a67f058
Add mintAndRegisterIp method in ipAsset
bonnie57 Oct 8, 2024
969c328
Refactor validate license terms
bonnie57 Oct 8, 2024
1a1e05f
Add registerPilTermsAndAttach method in ipAsset
bonnie57 Oct 8, 2024
57f9559
Adjust related methods referencing address
bonnie57 Oct 10, 2024
b811e91
Add todo hint
bonnie57 Oct 11, 2024
02189ac
Add registerIpAndMakeDerivativeWithLicenseTokens method in IpAsset mo…
bonnie57 Oct 11, 2024
a437d4f
Add transferToVaultAndSnapshotAndClaimByTokenBatch method
bonnie57 Oct 11, 2024
78e49da
Add royalty related workflow methods
bonnie57 Oct 12, 2024
207b055
Solve ERC721 error
bonnie57 Oct 12, 2024
b0b5379
Add group workflow relate methods
bonnie57 Oct 12, 2024
454298f
Update new contract address
bonnie57 Oct 14, 2024
3f4dfe2
Add debugger log
bonnie57 Oct 14, 2024
2d805c2
Add registerGroupAndAttachLicenseAndAddIps unit tests
bonnie57 Oct 15, 2024
2b02d23
Solve invalid signature and royalty error
bonnie57 Oct 17, 2024
bbe6732
Add the related methods unit tests
bonnie57 Oct 17, 2024
24f797b
Add tests and enhance code
bonnie57 Oct 18, 2024
27a8ce4
Remove license terms register check
bonnie57 Oct 18, 2024
003c113
Add integration tests in command
bonnie57 Oct 18, 2024
613df16
Update group pool description
bonnie57 Oct 18, 2024
7aa4400
Skip integration tests
bonnie57 Oct 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20,701 changes: 14,714 additions & 5,987 deletions packages/core-sdk/src/abi/generated.ts

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion packages/core-sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { IPAccountClient } from "./resources/ipAccount";
import { chainStringToViemChain } from "./utils/utils";
import { RoyaltyClient } from "./resources/royalty";
import { NftClient } from "./resources/nftClient";
import { GroupClient } from "./resources/group";
import { SimpleWalletClient } from "./abi/generated";

if (typeof process !== "undefined") {
Expand All @@ -34,6 +35,7 @@ export class StoryClient {
private _ipAccount: IPAccountClient | null = null;
private _royalty: RoyaltyClient | null = null;
private _nftClient: NftClient | null = null;
private _group: GroupClient | null = null;

/**
* @param config - the configuration for the SDK client
Expand Down Expand Up @@ -141,7 +143,7 @@ export class StoryClient {
*/
public get license(): LicenseClient {
if (this._license === null) {
this._license = new LicenseClient(this.rpcClient, this.wallet);
this._license = new LicenseClient(this.rpcClient, this.wallet, this.config.chainId);
}

return this._license;
Expand Down Expand Up @@ -202,4 +204,18 @@ export class StoryClient {

return this._nftClient;
}

/**
* Getter for the group client. The client is lazily created when
* this method is called.
*
* @returns the GroupClient instance
*/
public get groupClient(): GroupClient {
if (this._group === null) {
this._group = new GroupClient(this.rpcClient, this.wallet, this.config.chainId);
}

return this._group;
}
}
33 changes: 28 additions & 5 deletions packages/core-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export { DisputeClient } from "./resources/dispute";
export { NftClient } from "./resources/nftClient";
export { IPAccountClient } from "./resources/ipAccount";
export { RoyaltyClient } from "./resources/royalty";
export { GroupClient } from "./resources/group";

export type { StoryConfig, SupportedChainIds } from "./types/config";

Expand Down Expand Up @@ -35,6 +36,11 @@ export type {
IpMedia,
IPRobotTerms,
StoryProtocolApp,
MintAndRegisterIpRequest,
RegisterPilTermsAndAttachRequest,
RegisterPilTermsAndAttachResponse,
MintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest,
RegisterIpAndMakeDerivativeWithLicenseTokensRequest,
} from "./types/resources/ipAsset";

export type {
Expand All @@ -52,16 +58,20 @@ export type {
export { PIL_TYPE } from "./types/resources/license";

export type {
CollectRoyaltyTokensRequest,
CollectRoyaltyTokensResponse,
PayRoyaltyOnBehalfRequest,
PayRoyaltyOnBehalfResponse,
SnapshotRequest,
SnapshotResponse,
ClaimableRevenueRequest,
ClaimableRevenueResponse,
ClaimRevenueRequest,
ClaimRevenueResponse,
SnapshotAndClaimBySnapshotBatchRequest,
SnapshotAndClaimBySnapshotBatchResponse,
SnapshotAndClaimByTokenBatchRequest,
SnapshotAndClaimByTokenBatchResponse,
TransferToVaultAndSnapshotAndClaimBySnapshotBatchRequest,
TransferToVaultAndSnapshotAndClaimBySnapshotBatchResponse,
TransferToVaultAndSnapshotAndClaimByTokenBatchRequest,
TransferToVaultAndSnapshotAndClaimByTokenBatchResponse,
} from "./types/resources/royalty";

export type {
Expand All @@ -71,6 +81,8 @@ export type {
SetAllPermissionsRequest,
SetBatchPermissionsRequest,
CreateBatchPermissionSignatureRequest,
PermissionSignatureRequest,
PermissionSignatureResponse,
} from "./types/resources/permission";
export { AccessPermission } from "./types/resources/permission";
export type {
Expand All @@ -96,11 +108,22 @@ export type {
CreateNFTCollectionResponse,
} from "./types/resources/nftClient";

export type {
RegisterGroupRequest,
RegisterGroupResponse,
RegisterGroupAndAttachLicenseRequest,
RegisterGroupAndAttachLicenseResponse,
RegisterGroupAndAttachLicenseAndAddIpsRequest,
RegisterGroupAndAttachLicenseAndAddIpsResponse,
MintAndRegisterIpAndAttachLicenseAndAddToGroupRequest,
MintAndRegisterIpAndAttachLicenseAndAddToGroupResponse,
RegisterIpAndAttachLicenseAndAddToGroupRequest,
RegisterIpAndAttachLicenseAndAddToGroupResponse,
} from "./types/resources/group";
export type {
PiLicenseTemplateGetLicenseTermsResponse,
IpAccountImplStateResponse,
EncodedTxData,
} from "./abi/generated";

export { getPermissionSignature } from "./utils/sign";
export type { PermissionSignatureRequest, PermissionSignatureResponse } from "./types/common";
19 changes: 9 additions & 10 deletions packages/core-sdk/src/resources/dispute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ export class DisputeClient {
/**
* Raises a dispute on a given ipId
* @param request - The request object containing necessary data to raise a dispute.
* @param request.targetIpId - The IP ID that is the target of the dispute.
* @param request.arbitrationPolicy - The address of the arbitration policy.
* @param request.linkToDisputeEvidence - The link to the dispute evidence.
* @param request.targetTag - The target tag of the dispute.
* @param request.calldata - Optional calldata to initialize the policy.
* @param request.txOptions - [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property.
* @param request.targetIpId The IP ID that is the target of the dispute.
* @param request.targetTag The target tag of the dispute.
* @param request.disputeEvidenceHash The hash pointing to the dispute evidence
* @param request.data The data to initialize the policy
* @param request.txOptions [Optional] This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property.
* @returns A Promise that resolves to a RaiseDisputeResponse containing the transaction hash.
* @throws `NotRegisteredIpId` if targetIpId is not registered in the IPA Registry.
* @throws `NotWhitelistedDisputeTag` if targetTag is not whitelisted.
Expand All @@ -41,9 +40,9 @@ export class DisputeClient {
try {
const req = {
targetIpId: getAddress(request.targetIpId, "request.targetIpId"),
linkToDisputeEvidence: request.linkToDisputeEvidence,
targetTag: stringToHex(request.targetTag, { size: 32 }),
data: request.calldata || "0x",
data: request.data || "0x",
disputeEvidenceHash: request.disputeEvidenceHash,
};

if (request.txOptions?.encodedTxDataOnly) {
Expand Down Expand Up @@ -73,7 +72,7 @@ export class DisputeClient {
* Cancels an ongoing dispute
* @param request - The request object containing details to cancel the dispute.
* @param request.disputeId The ID of the dispute to be cancelled.
* @param request.calldata Optional additional data used in the cancellation process.
* @param request.data [Optional] additional data used in the cancellation process.
* @param request.txOptions - [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property.
* @returns A Promise that resolves to a CancelDisputeResponse containing the transaction hash.
* @throws NotInDisputeState, if the currentTag of the Dispute is not being disputed
Expand All @@ -86,7 +85,7 @@ export class DisputeClient {
try {
const req = {
disputeId: BigInt(request.disputeId),
data: request.calldata ? request.calldata : "0x",
data: request.data ? request.data : "0x",
};
if (request.txOptions?.encodedTxDataOnly) {
return { encodedTxData: this.disputeModuleClient.cancelDisputeEncode(req) };
Expand Down
Loading
Loading