Skip to content

Commit

Permalink
Refactor generateIpMetadata and generateCreatorMetadata (#248)
Browse files Browse the repository at this point in the history
* Refactor generateIpMetadata and generateCreatorMetadata

* Update ipAsset type

* Delete useless code

* Modify annotation format

* Remove useless code

* Remove integration test from workflow

* Add other parameter into waitForTransactionReceipt

* Remove useless code

* Bump up version to 1.0.0-rc.22
  • Loading branch information
bonnie57 authored Sep 12, 2024
1 parent 972539a commit ac62f70
Show file tree
Hide file tree
Showing 16 changed files with 212 additions and 158 deletions.
2 changes: 1 addition & 1 deletion packages/core-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@story-protocol/core-sdk",
"version": "1.0.0-rc.21",
"version": "1.0.0-rc.22",
"description": "Story Protocol Core SDK",
"main": "dist/story-protocol-core-sdk.cjs.js",
"module": "dist/story-protocol-core-sdk.esm.js",
Expand Down
8 changes: 8 additions & 0 deletions packages/core-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@ export type {
RegisterIpAndAttachPilTermsRequest,
RegisterIpAndAttachPilTermsResponse,
MintAndRegisterIpAndMakeDerivativeRequest,
GenerateCreatorMetadataParam,
IpCreator,
GenerateIpMetadataParam,
IpMetadata,
IpRelationship,
IpAttribute,
IpCreatorSocial,
IpMedia,
IPRobotTerms,
StoryProtocolApp,
} from "./types/resources/ipAsset";

export type {
Expand Down
19 changes: 15 additions & 4 deletions packages/core-sdk/src/resources/dispute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class DisputeClient {
* @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 options.
* @param request.txOptions - [Optional] transaction. 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 @@ -52,7 +52,10 @@ export class DisputeClient {
const txHash = await this.disputeModuleClient.raiseDispute(req);

if (request.txOptions?.waitForTransaction) {
const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash });
const txReceipt = await this.rpcClient.waitForTransactionReceipt({
...request.txOptions,
hash: txHash,
});
const targetLogs = this.disputeModuleClient.parseTxDisputeRaisedEvent(txReceipt);
return {
txHash: txHash,
Expand All @@ -71,6 +74,7 @@ export class DisputeClient {
* @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.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
* @throws NotDisputeInitiator, if the transaction executor is not the one that initiated the dispute
Expand All @@ -90,7 +94,10 @@ export class DisputeClient {
const txHash = await this.disputeModuleClient.cancelDispute(req);

if (request.txOptions?.waitForTransaction) {
await this.rpcClient.waitForTransactionReceipt({ hash: txHash });
await this.rpcClient.waitForTransactionReceipt({
...request.txOptions,
hash: txHash,
});
}

return { txHash: txHash };
Expand All @@ -105,6 +112,7 @@ export class DisputeClient {
* @param request - The request object containing details to resolve the dispute.
* @param request.disputeId The ID of the dispute to be resolved.
* @param request.data The data to resolve the dispute.
* @param request.txOptions - [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property.
* @returns A Promise that resolves to a ResolveDisputeResponse.
* @throws NotAbleToResolve, if currentTag is still in dispute (i.e still needs a judgement to be set)
* @throws NotDisputeInitiator, if the transaction executor is not the one that initiated the dispute
Expand All @@ -122,7 +130,10 @@ export class DisputeClient {
} else {
const txHash = await this.disputeModuleClient.resolveDispute(req);
if (request.txOptions?.waitForTransaction) {
await this.rpcClient.waitForTransactionReceipt({ hash: txHash });
await this.rpcClient.waitForTransactionReceipt({
...request.txOptions,
hash: txHash,
});
}

return { txHash: txHash };
Expand Down
12 changes: 10 additions & 2 deletions packages/core-sdk/src/resources/ipAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class IPAccountClient {
* @param request.value The amount of Ether to send.
* @param request.accountAddress The ipId to send.
* @param request.data The data to send along with the transaction.
* @param request.txOptions - [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property.
* @returns Tx hash for the transaction.
*/
public async execute(request: IPAccountExecuteRequest): Promise<IPAccountExecuteResponse> {
Expand All @@ -49,7 +50,10 @@ export class IPAccountClient {
const txHash = await ipAccountClient.execute({ ...req, operation: 0 });

if (request.txOptions?.waitForTransaction) {
await this.rpcClient.waitForTransactionReceipt({ hash: txHash });
await this.rpcClient.waitForTransactionReceipt({
...request.txOptions,
hash: txHash,
});
}
return { txHash: txHash };
}
Expand All @@ -67,6 +71,7 @@ export class IPAccountClient {
* @param request.signer The signer of the transaction.
* @param request.deadline The deadline of the transaction signature.
* @param request.signature The signature of the transaction, EIP-712 encoded.
* @param request.txOptions - [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property.
* @returns Tx hash for the transaction.
*/
public async executeWithSig(
Expand Down Expand Up @@ -94,7 +99,10 @@ export class IPAccountClient {
const txHash = await ipAccountClient.executeWithSig(req);

if (request.txOptions?.waitForTransaction) {
await this.rpcClient.waitForTransactionReceipt({ hash: txHash });
await this.rpcClient.waitForTransactionReceipt({
...request.txOptions,
hash: txHash,
});
}
return { txHash: txHash };
}
Expand Down
Loading

0 comments on commit ac62f70

Please sign in to comment.