Skip to content

Commit

Permalink
Merge pull request #368 from storyprotocol/dev
Browse files Browse the repository at this point in the history
Bump up version to 1.2.0-rc.4
  • Loading branch information
bonnie57 authored Dec 17, 2024
2 parents 5700159 + f9bba29 commit 1447478
Show file tree
Hide file tree
Showing 11 changed files with 150 additions and 117 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pr-external.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Workflow for External PRs
name: Workflow for External PRs with Unit Tests

on:
pull_request_target:
Expand All @@ -21,10 +21,10 @@ jobs:
Timestamp_PR_APPROVED:
needs: [authorize]
uses: storyprotocol/gha-workflows/.github/workflows/reusable-timestamp.yml@main

build_and_test:
needs: [authorize, Timestamp_PR_APPROVED]
uses: storyprotocol/gha-workflows/.github/workflows/reusable-build-test-workflow.yml@main
uses: storyprotocol/gha-workflows/.github/workflows/reusable-build-unit-test-workflow.yml@main
with:
sha: ${{ github.event.pull_request.head.sha }}
ENVIRONMENT: "beta-sepolia"
Expand Down
23 changes: 16 additions & 7 deletions .github/workflows/pr-internal.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
name: Workflow for internal PRs
name: Conditional Workflow

on:
push:
pull_request:
branches:
- main
- dev

pull_request:
push:
branches:
- main
- dev

jobs:
Timestamp:
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
uses: storyprotocol/gha-workflows/.github/workflows/reusable-timestamp.yml@main

build_and_test:
pr_build_and_test:
if: github.event_name == 'pull_request'
needs: [Timestamp]
uses: storyprotocol/gha-workflows/.github/workflows/reusable-build-test-workflow.yml@main
uses: storyprotocol/gha-workflows/.github/workflows/reusable-build-unit-test-workflow.yml@main
with:
sha: ${{ github.event.pull_request.head.sha }}
ENVIRONMENT: "beta-sepolia"
secrets:
WALLET_PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }}
TEST_WALLET_ADDRESS: ${{ secrets.TEST_WALLET_ADDRESS }}

push_build_and_test:
if: github.event_name == 'push'
uses: storyprotocol/gha-workflows/.github/workflows/reusable-build-integration-test-workflow.yml@main
with:
sha: ${{ github.sha }}
ENVIRONMENT: "beta-sepolia"
secrets:
WALLET_PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }}
TEST_WALLET_ADDRESS: ${{ secrets.TEST_WALLET_ADDRESS }}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"lint": "turbo run lint",
"fix": "turbo run fix",
"test": "turbo run test --no-cache --concurrency=1",
"test:integration": "turbo run test:integration --no-cache",
"prepare": "husky install"
},
"devDependencies": {
Expand Down
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.2.0-rc.3",
"version": "1.2.0-rc.4",
"description": "Story Protocol Core SDK",
"main": "dist/story-protocol-core-sdk.cjs.js",
"module": "dist/story-protocol-core-sdk.esm.js",
Expand Down
20 changes: 10 additions & 10 deletions packages/core-sdk/src/abi/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10946,8 +10946,8 @@ export const royaltyTokenDistributionWorkflowsAbi = [
},
{
name: "terms",
internalType: "struct PILTerms",
type: "tuple",
internalType: "struct PILTerms[]",
type: "tuple[]",
components: [
{ name: "transferable", internalType: "bool", type: "bool" },
{ name: "royaltyPolicy", internalType: "address", type: "address" },
Expand Down Expand Up @@ -11010,7 +11010,7 @@ export const royaltyTokenDistributionWorkflowsAbi = [
outputs: [
{ name: "ipId", internalType: "address", type: "address" },
{ name: "tokenId", internalType: "uint256", type: "uint256" },
{ name: "licenseTermsId", internalType: "uint256", type: "uint256" },
{ name: "licenseTermsIds", internalType: "uint256[]", type: "uint256[]" },
],
stateMutability: "nonpayable",
},
Expand Down Expand Up @@ -11094,8 +11094,8 @@ export const royaltyTokenDistributionWorkflowsAbi = [
},
{
name: "terms",
internalType: "struct PILTerms",
type: "tuple",
internalType: "struct PILTerms[]",
type: "tuple[]",
components: [
{ name: "transferable", internalType: "bool", type: "bool" },
{ name: "royaltyPolicy", internalType: "address", type: "address" },
Expand Down Expand Up @@ -11168,7 +11168,7 @@ export const royaltyTokenDistributionWorkflowsAbi = [
name: "registerIpAndAttachPILTermsAndDeployRoyaltyVault",
outputs: [
{ name: "ipId", internalType: "address", type: "address" },
{ name: "licenseTermsId", internalType: "uint256", type: "uint256" },
{ name: "licenseTermsIds", internalType: "uint256[]", type: "uint256[]" },
{ name: "ipRoyaltyVault", internalType: "address", type: "address" },
],
stateMutability: "nonpayable",
Expand Down Expand Up @@ -23809,7 +23809,7 @@ export type RoyaltyTokenDistributionWorkflowsDistributeRoyaltyTokensRequest = {
* @param spgNftContract address
* @param recipient address
* @param ipMetadata tuple
* @param terms tuple
* @param terms tuple[]
* @param royaltyShares tuple[]
*/
export type RoyaltyTokenDistributionWorkflowsMintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokensRequest =
Expand Down Expand Up @@ -23840,7 +23840,7 @@ export type RoyaltyTokenDistributionWorkflowsMintAndRegisterIpAndAttachPilTermsA
derivativeRevCeiling: bigint;
currency: Address;
uri: string;
};
}[];
royaltyShares: {
author: Address;
percentage: number;
Expand Down Expand Up @@ -23884,7 +23884,7 @@ export type RoyaltyTokenDistributionWorkflowsMintAndRegisterIpAndMakeDerivativeA
* @param nftContract address
* @param tokenId uint256
* @param ipMetadata tuple
* @param terms tuple
* @param terms tuple[]
* @param sigMetadata tuple
* @param sigAttach tuple
*/
Expand Down Expand Up @@ -23916,7 +23916,7 @@ export type RoyaltyTokenDistributionWorkflowsRegisterIpAndAttachPilTermsAndDeplo
derivativeRevCeiling: bigint;
currency: Address;
uri: string;
};
}[];
sigMetadata: {
signer: Address;
deadline: bigint;
Expand Down
3 changes: 3 additions & 0 deletions packages/core-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export type {
RegisterNonComSocialRemixingPILRequest,
RegisterCommercialUsePILRequest,
RegisterCommercialRemixPILRequest,
RegisterPILTermsRequest,
RegisterPILResponse,
AttachLicenseTermsRequest,
AttachLicenseTermsResponse,
Expand Down Expand Up @@ -156,3 +157,5 @@ export type {
export { getPermissionSignature, getSignature } from "./utils/sign";

export { convertCIDtoHashIPFS, convertHashIPFStoCID } from "./utils/ipfs";

export type { TxOptions } from "./types/options";
53 changes: 32 additions & 21 deletions packages/core-sdk/src/resources/ipAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1524,12 +1524,12 @@ export class IPAssetClient {
}
}
/**
* Register the given NFT and attach license terms and distribute royalty tokens. In order to successfully distribute royalty tokens, the license terms attached to the IP must be
* Register the given NFT and attach license terms and distribute royalty tokens. In order to successfully distribute royalty tokens, the first license terms attached to the IP must be
* a commercial license.
* @param request - The request object that contains all data needed to register ip and attach license terms and distribute royalty tokens.
* @param request.nftContract The address of the NFT collection.
* @param request.tokenId The ID of the NFT.
* @param request.terms The array of license terms to be attached.
* @param {Array} request.terms The array of license terms to be attached.
* @param request.terms.transferable Indicates whether the license is transferable or not.
* @param request.terms.royaltyPolicy The address of the royalty policy contract which required to StoryProtocol in advance.
* @param request.terms.mintingFee The fee to be paid when minting a license.
Expand Down Expand Up @@ -1557,19 +1557,24 @@ export class IPAssetClient {
* @param request.royaltyShares.percentage The percentage of the royalty share, 10 represents 10%.
* @param request.deadline [Optional] The deadline for the signature in seconds, default is 1000s.
* @param request.txOptions [Optional] This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property, without encodedTxData option.
* @returns A Promise that resolves to a transaction hashes, IP ID, License terms ID, and IP royalty vault.
* @returns A Promise that resolves to a transaction hashes, IP ID, IP royalty vault and an array containing the license terms ID.
* @emits IPRegistered (ipId, chainId, tokenContract, tokenId, name, uri, registrationDate)
* @emits IpRoyaltyVaultDeployed (ipId, ipRoyaltyVault)
*/
public async registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens(
request: RegisterIPAndAttachLicenseTermsAndDistributeRoyaltyTokensRequest,
): Promise<RegisterIPAndAttachLicenseTermsAndDistributeRoyaltyTokensResponse> {
try {
if (!request.terms.commercialUse) {
throw new Error("Commercial use is required to deploy a royalty vault.");
}
const { royaltyShares, totalAmount } = this.getRoyaltyShares(request.royaltyShares);
const licenseTerm = await validateLicenseTerms(request.terms, this.rpcClient);
const licenseTerms: LicenseTerms[] = [];
for (let i = 0; i < request.terms.length; i++) {
const term = request.terms[i];
if (i === 0 && !term.commercialUse) {
throw new Error("The first license term must be a commercial license.");
}
const licenseTerm = await validateLicenseTerms(term, this.rpcClient);
licenseTerms.push(licenseTerm);
}
const blockTimestamp = (await this.rpcClient.getBlock()).timestamp;
const calculatedDeadline = getDeadline(blockTimestamp, request.deadline);
const ipIdAddress = await this.getIpIdAddress(
Expand Down Expand Up @@ -1629,7 +1634,7 @@ export class IPAssetClient {
nftMetadataURI: request.ipMetadata?.nftMetadataURI || "",
nftMetadataHash: request.ipMetadata?.nftMetadataHash || zeroHash,
},
terms: licenseTerm,
terms: licenseTerms,
sigMetadata: {
signer: this.wallet.account!.address,
deadline: calculatedDeadline,
Expand All @@ -1647,7 +1652,7 @@ export class IPAssetClient {
hash: registerIpAndAttachPilTermsAndDeployRoyaltyVaultTxHash,
});
const { ipId } = this.getIpIdAndTokenIdsFromEvent(txReceipt)[0];
const licenseTermsId = await this.getLicenseTermsId([licenseTerm]);
const licenseTermsIds = await this.getLicenseTermsId(licenseTerms);
const { ipRoyaltyVault } =
this.royaltyModuleEventClient.parseTxIpRoyaltyVaultDeployedEvent(txReceipt)[0];
const distributeRoyaltyTokensTxHash = await this.distributeRoyaltyTokens({
Expand All @@ -1669,7 +1674,7 @@ export class IPAssetClient {
registerIpAndAttachPilTermsAndDeployRoyaltyVaultTxHash,
distributeRoyaltyTokensTxHash,
ipId,
licenseTermsId: licenseTermsId[0],
licenseTermsIds,
ipRoyaltyVault,
};
} catch (error) {
Expand Down Expand Up @@ -1703,7 +1708,7 @@ export class IPAssetClient {
* @emits IPRegistered (ipId, chainId, tokenContract, tokenId, name, uri, registrationDate)
* @emits IpRoyaltyVaultDeployed (ipId, ipRoyaltyVault)
*/
public async registerDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokens(
public async registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens(
request: RegisterDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensRequest,
): Promise<RegisterDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensResponse> {
try {
Expand Down Expand Up @@ -1806,7 +1811,7 @@ export class IPAssetClient {
});
}
return {
registerDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensTxHash: txHash,
registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokensTxHash: txHash,
distributeRoyaltyTokensTxHash,
ipId,
tokenId,
Expand All @@ -1821,11 +1826,11 @@ export class IPAssetClient {
}

/**
* Mint an NFT and register the IP, attach PIL terms, and distribute royalty tokens. In order to successfully distribute royalty tokens, the license terms attached to the IP must be
* Mint an NFT and register the IP, attach PIL terms, and distribute royalty tokens. In order to successfully distribute royalty tokens, First the license terms attached to the IP must be
* a commercial license.
* @param request - The request object that contains all data needed to mint an NFT and register the IP, attach PIL terms, and distribute royalty tokens.
* @param request.spgNftContract The address of the SPG NFT contract.
* @param request.terms The array of license terms to be attached.
* @param {Array} request.terms The array of license terms to be attached.
* @param request.terms.transferable Indicates whether the license is transferable or not.
* @param request.terms.royaltyPolicy The address of the royalty policy contract which required to StoryProtocol in advance.
* @param request.terms.mintingFee The fee to be paid when minting a license.
Expand Down Expand Up @@ -1853,17 +1858,23 @@ export class IPAssetClient {
* @param request.royaltyShares.percentage The percentage of the royalty share, 10 represents 10%.
* @param request.recipient - [Optional] The address to receive the minted NFT,default value is your wallet address.
* @param request.txOptions [Optional] This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property, without encodedTxData option.
* @returns A Promise that resolves to a transaction hash, IP ID, License terms ID, and IP royalty vault, Token ID.
* @returns A Promise that resolves to a transaction hash, IP ID, IP royalty vault, Token ID, and an array containing the license terms ID.
* @emits IPRegistered (ipId, chainId, tokenContract, tokenId, name, uri, registrationDate)
* @emits IpRoyaltyVaultDeployed (ipId, ipRoyaltyVault)
*/
public async mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens(
request: MintAndRegisterIpAndAttachPILTermsAndDistributeRoyaltyTokensRequest,
): Promise<MintAndRegisterIpAndAttachPILTermsAndDistributeRoyaltyTokensResponse> {
try {
if (!request.terms.commercialUse) {
throw new Error("Commercial use is required to deploy a royalty vault.");
const licenseTerms: LicenseTerms[] = [];
for (let i = 0; i < request.terms.length; i++) {
const term = request.terms[i];
if (i === 0 && !term.commercialUse) {
throw new Error("First license term must be a commercial license.");
}
const licenseTerm = await validateLicenseTerms(term, this.rpcClient);
licenseTerms.push(licenseTerm);
}
const licenseTerm = await validateLicenseTerms(request.terms, this.rpcClient);
const { royaltyShares } = this.getRoyaltyShares(request.royaltyShares);
const txHash =
await this.royaltyTokenDistributionWorkflowsClient.mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens(
Expand All @@ -1878,7 +1889,7 @@ export class IPAssetClient {
nftMetadataURI: request.ipMetadata?.nftMetadataURI || "",
nftMetadataHash: request.ipMetadata?.nftMetadataHash || zeroHash,
},
terms: licenseTerm,
terms: licenseTerms,
royaltyShares,
},
);
Expand All @@ -1888,13 +1899,13 @@ export class IPAssetClient {
hash: txHash,
});
const { ipId, tokenId } = this.getIpIdAndTokenIdsFromEvent(txReceipt)[0];
const licenseTermsId = await this.getLicenseTermsId([licenseTerm]);
const licenseTermsIds = await this.getLicenseTermsId(licenseTerms);
const { ipRoyaltyVault } =
this.royaltyModuleEventClient.parseTxIpRoyaltyVaultDeployedEvent(txReceipt)[0];
return {
txHash,
ipId,
licenseTermsId: licenseTermsId[0],
licenseTermsIds,
ipRoyaltyVault,
tokenId,
};
Expand Down
10 changes: 5 additions & 5 deletions packages/core-sdk/src/types/resources/ipAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export type BatchRegisterResponse = {
export type RegisterIPAndAttachLicenseTermsAndDistributeRoyaltyTokensRequest = {
nftContract: Address;
tokenId: bigint | string | number;
terms: RegisterPILTermsRequest;
terms: RegisterPILTermsRequest[];
deadline?: string | number | bigint;
royaltyShares: RoyaltyShare[];
txOptions?: Omit<TxOptions, "encodedTxDataOnly">;
Expand All @@ -284,7 +284,7 @@ export type RegisterIPAndAttachLicenseTermsAndDistributeRoyaltyTokensResponse =
registerIpAndAttachPilTermsAndDeployRoyaltyVaultTxHash: Hex;
distributeRoyaltyTokensTxHash: Hex;
ipId: Address;
licenseTermsId: bigint;
licenseTermsIds: bigint[];
ipRoyaltyVault: Address;
};
export type DistributeRoyaltyTokens = {
Expand Down Expand Up @@ -318,7 +318,7 @@ export type RegisterDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensReq
} & IPMetadataInfo;

export type RegisterDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensResponse = {
registerDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensTxHash: Address;
registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokensTxHash: Address;
distributeRoyaltyTokensTxHash: Address;
ipId: Address;
tokenId: bigint;
Expand All @@ -327,7 +327,7 @@ export type RegisterDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensRes

export type MintAndRegisterIpAndAttachPILTermsAndDistributeRoyaltyTokensRequest = {
spgNftContract: Address;
terms: RegisterPILTermsRequest;
terms: RegisterPILTermsRequest[];
royaltyShares: {
author: Address;
percentage: number;
Expand All @@ -339,7 +339,7 @@ export type MintAndRegisterIpAndAttachPILTermsAndDistributeRoyaltyTokensRequest
export type MintAndRegisterIpAndAttachPILTermsAndDistributeRoyaltyTokensResponse = {
txHash: Hex;
ipId?: Address;
licenseTermsId?: bigint;
licenseTermsIds?: bigint[];
ipRoyaltyVault?: Address;
tokenId?: bigint;
};
Expand Down
Loading

0 comments on commit 1447478

Please sign in to comment.