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

SDK V1.3.0.beta.2 release #411

Merged
merged 30 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
014b962
[feat] add boris to pr reviewer (#400)
AndyBoWu Jan 29, 2025
f5b7eec
feat: remove homer and add aeneid support
DracoLi Feb 2, 2025
ef99bd9
Update ipAsset.test.ts
bpolania Feb 4, 2025
56c2e36
Update ipAsset.test.ts
bpolania Feb 4, 2025
d4c7897
Merge pull request #405 from storyprotocol/bp/aeneid-support/debug
DracoLi Feb 4, 2025
7cd1726
Merge pull request #404 from storyprotocol/dl/aeneid-support
DracoLi Feb 4, 2025
93c85e3
feat: add wip client
DracoLi Feb 2, 2025
ffb4739
keep properties private
DracoLi Feb 4, 2025
2f5ddb8
fix wip address
DracoLi Feb 4, 2025
33fe87b
Merge pull request #406 from storyprotocol/dl/client-wip
DracoLi Feb 4, 2025
9da296e
feat: added auto wip conversion for ipAssets
DracoLi Feb 4, 2025
ae5f0a6
improve docs
DracoLi Feb 5, 2025
66c13c4
Merge pull request #407 from storyprotocol/dl/wip-ipasset
DracoLi Feb 5, 2025
d3ce3f8
feat: add claimAllRevenue and update royalty to have wip support
DracoLi Feb 5, 2025
c16294d
feat: update mintLicenseTokens to support wip
DracoLi Feb 5, 2025
3bca2a4
Merge pull request #409 from storyprotocol/dl/loyalty-license
DracoLi Feb 5, 2025
572cd3f
fix: group types
DracoLi Feb 5, 2025
02fb6b7
update version to beta.2
DracoLi Feb 5, 2025
c5bd290
Merge pull request #410 from storyprotocol/dl/beta2
DracoLi Feb 5, 2025
12ce919
fix license integration tests
DracoLi Feb 5, 2025
eedbe2f
raise timeout since we are not using multicall
DracoLi Feb 5, 2025
b50b442
fix integration tests
DracoLi Feb 5, 2025
54dbbed
add back encodedTxs
DracoLi Feb 5, 2025
06682cd
update for transient permission change from spg
DracoLi Feb 5, 2025
62813b5
don't try to validate balance for integration tests
DracoLi Feb 5, 2025
60f13e6
fix ipaccount permissions
DracoLi Feb 5, 2025
54c54f8
skip disputes for now
DracoLi Feb 5, 2025
eb30fa9
add note to batch register issue with multicall
DracoLi Feb 5, 2025
8d25b84
disable batch test with metadata
DracoLi Feb 5, 2025
470849a
Merge pull request #412 from storyprotocol/dl/fix-license-tests
DracoLi Feb 5, 2025
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
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @LeoHChen @DonFungible @edisonz0718 @jacob-tucker @AndyBoWu @allenchuang
* @LeoHChen @DonFungible @edisonz0718 @jacob-tucker @AndyBoWu @allenchuang @bpolania
17 changes: 17 additions & 0 deletions packages/core-sdk/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Run Test File",
"outputCapture": "std",
"program": "${workspaceRoot}/node_modules/mocha/bin/mocha.js",
"args": ["-r", "ts-node/register", "${relativeFile}"],
"console": "integratedTerminal",
"env": {
"TS_NODE_PROJECT": "./tsconfig.test.json"
}
}
]
}
4 changes: 2 additions & 2 deletions 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.3.0-beta.1",
"version": "1.3.0-beta.2",
"description": "Story Protocol Core SDK",
"main": "dist/story-protocol-core-sdk.cjs.js",
"module": "dist/story-protocol-core-sdk.esm.js",
Expand All @@ -19,7 +19,7 @@
"build": "pnpm run fix && preconstruct build",
"test": "pnpm run test:unit",
"test:unit": "TS_NODE_PROJECT='./tsconfig.test.json' c8 --all --src ./src mocha -r ts-node/register './test/unit/**/*.test.ts'",
"test:integration": "TS_NODE_PROJECT='./tsconfig.test.json' mocha -r ts-node/register './test/integration/**/*.test.ts' --timeout 240000",
"test:integration": "TS_NODE_PROJECT='./tsconfig.test.json' mocha -r ts-node/register './test/integration/**/*.test.ts' --timeout 300000",
"fix": "pnpm run format:fix && pnpm run lint:fix",
"format": "prettier --check .",
"format:fix": "prettier --write .",
Expand Down
20 changes: 14 additions & 6 deletions packages/core-sdk/src/abi/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export const accessControllerAbi = [
],
},
],
name: "setBatchPermissions",
name: "setBatchTransientPermissions",
outputs: [],
stateMutability: "nonpayable",
},
Expand All @@ -357,7 +357,7 @@ export const accessControllerAbi = [
{ name: "func", internalType: "bytes4", type: "bytes4" },
{ name: "permission", internalType: "uint8", type: "uint8" },
],
name: "setPermission",
name: "setTransientPermission",
outputs: [],
stateMutability: "nonpayable",
},
Expand Down Expand Up @@ -15270,7 +15270,7 @@ export class AccessControllerClient extends AccessControllerEventClient {
const { request: call } = await this.rpcClient.simulateContract({
abi: accessControllerAbi,
address: this.address,
functionName: "setBatchPermissions",
functionName: "setBatchTransientPermissions",
account: this.wallet.account,
args: [request.permissions],
});
Expand All @@ -15290,7 +15290,7 @@ export class AccessControllerClient extends AccessControllerEventClient {
to: this.address,
data: encodeFunctionData({
abi: accessControllerAbi,
functionName: "setBatchPermissions",
functionName: "setBatchTransientPermissions",
args: [request.permissions],
}),
};
Expand All @@ -15308,7 +15308,7 @@ export class AccessControllerClient extends AccessControllerEventClient {
const { request: call } = await this.rpcClient.simulateContract({
abi: accessControllerAbi,
address: this.address,
functionName: "setPermission",
functionName: "setTransientPermission",
account: this.wallet.account,
args: [request.ipAccount, request.signer, request.to, request.func, request.permission],
});
Expand All @@ -15326,7 +15326,7 @@ export class AccessControllerClient extends AccessControllerEventClient {
to: this.address,
data: encodeFunctionData({
abi: accessControllerAbi,
functionName: "setPermission",
functionName: "setTransientPermission",
args: [request.ipAccount, request.signer, request.to, request.func, request.permission],
}),
};
Expand Down Expand Up @@ -20672,6 +20672,14 @@ export class IpAccountImplReadOnlyClient {
functionName: "token",
});
}

public async owner(): Promise<Address> {
return await this.rpcClient.readContract({
abi: ipAccountImplAbi,
address: this.address,
functionName: "owner",
});
}
}

/**
Expand Down
27 changes: 25 additions & 2 deletions packages/core-sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import { PermissionClient } from "./resources/permission";
import { LicenseClient } from "./resources/license";
import { DisputeClient } from "./resources/dispute";
import { IPAccountClient } from "./resources/ipAccount";
import { chain, chainStringToViemChain } from "./utils/utils";
import { chain, chainStringToViemChain, validateAddress } from "./utils/utils";
import { RoyaltyClient } from "./resources/royalty";
import { NftClient } from "./resources/nftClient";
import { GroupClient } from "./resources/group";
import { SimpleWalletClient } from "./abi/generated";
import { WipClient } from "./resources/wip";

if (typeof process !== "undefined") {
dotenv.config();
Expand All @@ -36,14 +37,15 @@ export class StoryClient {
private _royalty: RoyaltyClient | null = null;
private _nftClient: NftClient | null = null;
private _group: GroupClient | null = null;
private _wip: WipClient | null = null;

/**
* @param config - the configuration for the SDK client
*/
private constructor(config: StoryConfig) {
this.config = {
...config,
chainId: chain[config.chainId || "homer"],
chainId: chain[config.chainId || "aeneid"],
};
if (!this.config.transport) {
throw new Error(
Expand Down Expand Up @@ -218,4 +220,25 @@ export class StoryClient {

return this._group;
}

public get wipClient(): WipClient {
if (this._wip === null) {
this._wip = new WipClient(this.rpcClient, this.wallet);
}
return this._wip;
}

public async getWalletBalance(): Promise<bigint> {
if (!this.wallet.account) {
throw new Error("No account found in wallet");
}
return await this.getBalance(this.wallet.account.address);
}

public async getBalance(address: string): Promise<bigint> {
const validAddress = validateAddress(address);
return await this.rpcClient.getBalance({
address: validAddress,
});
}
}
7 changes: 5 additions & 2 deletions packages/core-sdk/src/constants/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ import { Hex } from "viem";
export const AddressZero = "0x0000000000000000000000000000000000000000";
export const HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
export const defaultFunctionSelector: Hex = "0x00000000";
export const royaltySharesTotalSupply: number = 100000000;
export const MAX_ROYALTY_TOKEN = 100000000;
export const royaltySharesTotalSupply: number = 100_000_000;
export const MAX_ROYALTY_TOKEN = 100_000_000;

/** Address for the WIP contract. This address is fixed */
export const WIP_TOKEN_ADDRESS = "0x1514000000000000000000000000000000000000";
2 changes: 1 addition & 1 deletion packages/core-sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { StoryClient } from "./client";
export { AddressZero, HashZero } from "./constants/common";
export { homer } from "./utils/chain";
export { aeneid } from "./utils/chain";
export { IPAssetClient } from "./resources/ipAsset";
export { PermissionClient } from "./resources/permission";
export { LicenseClient } from "./resources/license";
Expand Down
Loading