@story-protocol/core-sdk 0.1.0-rc.7 → 1.0.0-rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. package/README.md +94 -55
  2. package/dist/declarations/src/abi/generated.d.ts +14196 -0
  3. package/dist/declarations/src/abi/generated.d.ts.map +1 -0
  4. package/dist/declarations/src/client.d.ts +42 -49
  5. package/dist/declarations/src/client.d.ts.map +1 -1
  6. package/dist/declarations/src/clients/storyAPI.d.ts +9 -0
  7. package/dist/declarations/src/clients/storyAPI.d.ts.map +1 -0
  8. package/dist/declarations/src/constants/common.d.ts +4 -0
  9. package/dist/declarations/src/constants/common.d.ts.map +1 -0
  10. package/dist/declarations/src/index.d.ts +13 -10
  11. package/dist/declarations/src/index.d.ts.map +1 -1
  12. package/dist/declarations/src/resources/dispute.d.ts +49 -0
  13. package/dist/declarations/src/resources/dispute.d.ts.map +1 -0
  14. package/dist/declarations/src/resources/ipAccount.d.ts +28 -0
  15. package/dist/declarations/src/resources/ipAccount.d.ts.map +1 -0
  16. package/dist/declarations/src/resources/ipAsset.d.ts +44 -20
  17. package/dist/declarations/src/resources/ipAsset.d.ts.map +1 -1
  18. package/dist/declarations/src/resources/license.d.ts +83 -18
  19. package/dist/declarations/src/resources/license.d.ts.map +1 -1
  20. package/dist/declarations/src/resources/permission.d.ts +30 -0
  21. package/dist/declarations/src/resources/permission.d.ts.map +1 -0
  22. package/dist/declarations/src/resources/royalty.d.ts +34 -0
  23. package/dist/declarations/src/resources/royalty.d.ts.map +1 -0
  24. package/dist/declarations/src/types/common.d.ts +6 -0
  25. package/dist/declarations/src/types/common.d.ts.map +1 -0
  26. package/dist/declarations/src/types/config.d.ts +27 -12
  27. package/dist/declarations/src/types/config.d.ts.map +1 -1
  28. package/dist/declarations/src/types/options.d.ts +10 -0
  29. package/dist/declarations/src/types/options.d.ts.map +1 -0
  30. package/dist/declarations/src/types/resources/dispute.d.ts +50 -0
  31. package/dist/declarations/src/types/resources/dispute.d.ts.map +1 -0
  32. package/dist/declarations/src/types/resources/ipAccount.d.ts +25 -0
  33. package/dist/declarations/src/types/resources/ipAccount.d.ts.map +1 -0
  34. package/dist/declarations/src/types/resources/ipAsset.d.ts +23 -63
  35. package/dist/declarations/src/types/resources/ipAsset.d.ts.map +1 -1
  36. package/dist/declarations/src/types/resources/license.d.ts +56 -68
  37. package/dist/declarations/src/types/resources/license.d.ts.map +1 -1
  38. package/dist/declarations/src/types/resources/permission.d.ts +14 -0
  39. package/dist/declarations/src/types/resources/permission.d.ts.map +1 -0
  40. package/dist/declarations/src/types/resources/royalty.d.ts +58 -0
  41. package/dist/declarations/src/types/resources/royalty.d.ts.map +1 -0
  42. package/dist/story-protocol-core-sdk.cjs.d.ts +1 -1
  43. package/dist/story-protocol-core-sdk.cjs.dev.js +10649 -1617
  44. package/dist/story-protocol-core-sdk.cjs.prod.js +10649 -1617
  45. package/dist/story-protocol-core-sdk.esm.js +10645 -1616
  46. package/package.json +16 -13
  47. package/dist/declarations/src/abi/generated/CollectModule.d.ts +0 -80
  48. package/dist/declarations/src/abi/generated/CollectModule.d.ts.map +0 -1
  49. package/dist/declarations/src/abi/generated/FranchiseRegistry.d.ts +0 -78
  50. package/dist/declarations/src/abi/generated/FranchiseRegistry.d.ts.map +0 -1
  51. package/dist/declarations/src/abi/generated/IpAssetRegistry.d.ts +0 -94
  52. package/dist/declarations/src/abi/generated/IpAssetRegistry.d.ts.map +0 -1
  53. package/dist/declarations/src/abi/generated/LicensingModule.d.ts +0 -97
  54. package/dist/declarations/src/abi/generated/LicensingModule.d.ts.map +0 -1
  55. package/dist/declarations/src/abi/generated/RelationshipModule.d.ts +0 -116
  56. package/dist/declarations/src/abi/generated/RelationshipModule.d.ts.map +0 -1
  57. package/dist/declarations/src/abi/generated/common.d.ts +0 -22
  58. package/dist/declarations/src/abi/generated/common.d.ts.map +0 -1
  59. package/dist/declarations/src/abi/generated/factories/CollectModule__factory.d.ts +0 -52
  60. package/dist/declarations/src/abi/generated/factories/CollectModule__factory.d.ts.map +0 -1
  61. package/dist/declarations/src/abi/generated/factories/FranchiseRegistry__factory.d.ts +0 -58
  62. package/dist/declarations/src/abi/generated/factories/FranchiseRegistry__factory.d.ts.map +0 -1
  63. package/dist/declarations/src/abi/generated/factories/IpAssetRegistry__factory.d.ts +0 -112
  64. package/dist/declarations/src/abi/generated/factories/IpAssetRegistry__factory.d.ts.map +0 -1
  65. package/dist/declarations/src/abi/generated/factories/LicensingModule__factory.d.ts +0 -88
  66. package/dist/declarations/src/abi/generated/factories/LicensingModule__factory.d.ts.map +0 -1
  67. package/dist/declarations/src/abi/generated/factories/RelationshipModule__factory.d.ts +0 -175
  68. package/dist/declarations/src/abi/generated/factories/RelationshipModule__factory.d.ts.map +0 -1
  69. package/dist/declarations/src/abi/generated/factories/index.d.ts +0 -6
  70. package/dist/declarations/src/abi/generated/factories/index.d.ts.map +0 -1
  71. package/dist/declarations/src/abi/generated/index.d.ts +0 -12
  72. package/dist/declarations/src/abi/generated/index.d.ts.map +0 -1
  73. package/dist/declarations/src/enums/Environment.d.ts +0 -8
  74. package/dist/declarations/src/enums/Environment.d.ts.map +0 -1
  75. package/dist/declarations/src/enums/IPAssetType.d.ts +0 -12
  76. package/dist/declarations/src/enums/IPAssetType.d.ts.map +0 -1
  77. package/dist/declarations/src/enums/ResourceType.d.ts +0 -11
  78. package/dist/declarations/src/enums/ResourceType.d.ts.map +0 -1
  79. package/dist/declarations/src/resources/collect.d.ts +0 -17
  80. package/dist/declarations/src/resources/collect.d.ts.map +0 -1
  81. package/dist/declarations/src/resources/collectReadOnly.d.ts +0 -15
  82. package/dist/declarations/src/resources/collectReadOnly.d.ts.map +0 -1
  83. package/dist/declarations/src/resources/franchise.d.ts +0 -26
  84. package/dist/declarations/src/resources/franchise.d.ts.map +0 -1
  85. package/dist/declarations/src/resources/franchiseReadOnly.d.ts +0 -27
  86. package/dist/declarations/src/resources/franchiseReadOnly.d.ts.map +0 -1
  87. package/dist/declarations/src/resources/ipAssetReadOnly.d.ts +0 -25
  88. package/dist/declarations/src/resources/ipAssetReadOnly.d.ts.map +0 -1
  89. package/dist/declarations/src/resources/licenseReadOnly.d.ts +0 -27
  90. package/dist/declarations/src/resources/licenseReadOnly.d.ts.map +0 -1
  91. package/dist/declarations/src/resources/relationship.d.ts +0 -47
  92. package/dist/declarations/src/resources/relationship.d.ts.map +0 -1
  93. package/dist/declarations/src/resources/relationshipReadOnly.d.ts +0 -16
  94. package/dist/declarations/src/resources/relationshipReadOnly.d.ts.map +0 -1
  95. package/dist/declarations/src/resources/transaction.d.ts +0 -10
  96. package/dist/declarations/src/resources/transaction.d.ts.map +0 -1
  97. package/dist/declarations/src/resources/transactionReadOnly.d.ts +0 -25
  98. package/dist/declarations/src/resources/transactionReadOnly.d.ts.map +0 -1
  99. package/dist/declarations/src/types/client.d.ts +0 -29
  100. package/dist/declarations/src/types/client.d.ts.map +0 -1
  101. package/dist/declarations/src/types/resources/collect.d.ts +0 -45
  102. package/dist/declarations/src/types/resources/collect.d.ts.map +0 -1
  103. package/dist/declarations/src/types/resources/franchise.d.ts +0 -71
  104. package/dist/declarations/src/types/resources/franchise.d.ts.map +0 -1
  105. package/dist/declarations/src/types/resources/relationship.d.ts +0 -83
  106. package/dist/declarations/src/types/resources/relationship.d.ts.map +0 -1
  107. package/dist/declarations/src/types/resources/transaction.d.ts +0 -40
  108. package/dist/declarations/src/types/resources/transaction.d.ts.map +0 -1
  109. package/dist/story-protocol-core-sdk.cjs.d.ts.map +0 -1
package/README.md CHANGED
@@ -1,85 +1,124 @@
1
- core-sdk is the base level sdk to interact with story protocol. It provides functions to both read and write data to the protocol.
1
+ # Story Protocol SDK
2
2
 
3
- ## Installation
3
+ Welcome to the documents for Story Protocol SDK. The SDK provides the APIs for developers to build applications with Story Protocol. By using the SDK, developers can create the resources like IP assets and perform actions to interact with the resource.
4
4
 
5
- Install the SDK and ethers.js
5
+ ## How to use Story Protocol SDK in Your Project
6
6
 
7
- npm
7
+ ### Install Story Protocol core SDK
8
8
 
9
- ```shell
10
- npm i @story-protocol/core-sdk ethers@^5.7.2
11
- ```
9
+ Suppose you already have a node project or created a new node project. First, you need to install `@story-protocol/core-sdk` in your project. You can use one of the following command to install the package:
12
10
 
13
- pnpm
11
+ Use `npm`:
14
12
 
15
- ```shell
16
- pnpm i @story-protocol/core-sdk ethers@^5.7.2
13
+ ```
14
+ npm install --save @story-protocol/core-sdk viem@1.21.4
17
15
  ```
18
16
 
19
- yarn
17
+ Use `pnpm`:
20
18
 
21
- ```shell
22
- yarn add @story-protocol/core-sdk ethers@^5.7.2
19
+ ```
20
+ pnpm install @story-protocol/core-sdk viem@1.21.4
23
21
  ```
24
22
 
25
- ## Set up `.env` file
26
-
27
- (Ask the team to provide the values)
23
+ Use `yarn`:
28
24
 
29
25
  ```
30
- NEXT_PUBLIC_API_BASE_URL =
31
- NEXT_PUBLIC_FRANCHISE_REGISTRY_CONTRACT =
32
- NEXT_PUBLIC_RELATIONSHIP_MODULE_CONTRACT =
33
- NEXT_PUBLIC_COLLECT_MODULE_CONTRACT =
34
- NEXT_PUBLIC_LICENSING_MODULE_CONTRACT =
26
+ yarn add @story-protocol/core-sdk viem@1.21.4
35
27
  ```
36
28
 
37
- ## Set up SDK client
29
+ Besides the Story Protocol SDK package `@story-protocol/core-sdk`, we also require the package `viem` (https://www.npmjs.com/package/viem) to access the DeFi wallet accounts.
38
30
 
39
- Using browser wallet
31
+ # Initiate SDK Client
40
32
 
41
- ```typescript
42
- import { StoryClient } from "@story-protocol/core-sdk";
43
- import ethers from "ethers";
33
+ Next we can initiate the SDK Client by first setting up our wallet and then the client itself.
44
34
 
45
- // Provider/Signer from browser wallet (i.e Metamask)
46
- const provider = new ethers.providers.Web3Provider(window.ethereum);
47
- await provider.send("eth_requestAccounts", []);
48
- const signer = await provider.getSigner();
35
+ ## Set up your wallet
49
36
 
50
- // Instantiate a read-only Story Client with an optional provider
51
- const client = StoryClient.newReadOnlyClient({ provider });
37
+ The SDK supports using `viem` for initiating SDK client. Create a typescript file and write the following code to initiate the client with a private key:
52
38
 
53
- // Instatiate a read/write Story Client with a signer
54
- const client = StoryClient.newClient({ signer });
39
+ > :information-source: Make sure to have WALLET_PRIVATE_KEY set up in your .env file.
40
+
41
+ ```typescript index.ts
42
+ import { privateKeyToAccount } from "viem/accounts";
43
+
44
+ const WALLET_PRIVATE_KEY = process.env.WALLET_PRIVATE_KEY || "0x";
45
+ const account = privateKeyToAccount(WALLET_PRIVATE_KEY as `0x${string}`);
55
46
  ```
56
47
 
57
- Using private key
48
+ The preceding code created the `account` object for creating the SDK client.
49
+
50
+ ## Set up SDK client
58
51
 
59
- ```typescript
60
- import { StoryClient } from "@story-protocol/core-sdk"
61
- import ethers from "ethers"
52
+ To set up the SDK client, import `StoryClient` and `StoryConfig` from `@story-protocol/core-sdk`. Write the following code, utilizing the `account` we created previously.
62
53
 
63
- // Signer from private key
64
- const provider = new ethers.providers.JsonRpcProvider(<YOUR RPC URL>)
65
- const signer = new ethers.Wallet(<YOUR PRIVATE KEY>, provider)
54
+ > :information-source: Make sure to have RPC_PROVIDER_URL for your desired chain set up in your .env file. We recommend using the Sepolia network with `RPC_PROVIDER_URL=https://rpc.ankr.com/eth_sepolia`.
66
55
 
67
- // Instantiate the Story Client
68
- const client = StoryClient.newClient({ signer })
56
+ ```typescript index.ts
57
+ import { StoryClient, StoryConfig } from "@story-protocol/core-sdk";
69
58
 
59
+ const config: StoryConfig = {
60
+ transport: http(process.env.RPC_PROVIDER_URL),
61
+ account: account,
62
+ };
63
+ const client = StoryClient.newClient(config);
70
64
  ```
71
65
 
72
- ## Use SDK client
66
+ ## How To Build and Test Story Protocol SDK for local testing
73
67
 
74
- ```typescript
75
- // Create a new franchise
76
- const response = await client.franchise.create({
77
- franchiseName: "Alice in Wonderland",
78
- franchiseSymbol: "Wonderland",
79
- franchiseDescription:
80
- "Fantastical journey, curious girl, whimsical characters, dreamlike adventures.",
81
- });
68
+ This section provides the instructions on how to build Story Protocol SDK from source code.
82
69
 
83
- // List franchises
84
- const { data: franchise } = await client.franchise.list();
85
- ```
70
+ ### Prerequisite
71
+
72
+ - Install PNPM: Execute `npm install -g pnpm`
73
+ - Install TypeScript: Run `pnpm add typescript -D`
74
+ - Install Yalc: Use `npm install -g yalc`
75
+
76
+ ### Steps for Using Yalc for Local Testing of Core-SDK
77
+
78
+ For manual testing of the core-sdk, set up a separate web project. The guide below uses `yalc` to link the `core-sdk` locally, enabling its installation and import for testing.
79
+
80
+ Under the `typescript-sdk/packages/core-sdk` directory:
81
+
82
+ - Navigate to the `core-sdk` directory.
83
+ - Execute `npm run build` to build your latest code.
84
+ - Run `yalc publish`. You should see a message like `@story-protocol/core-sdk@<version> published in store.` (Note: The version number may vary).
85
+
86
+ To set up your testing environment (e.g., a new Next.js project), use `yalc add @story-protocol/core-sdk@<version>` (ensure the version number is updated accordingly).
87
+
88
+ - Run `pnpm install`. This installs `@story-protocol/core-sdk@<version>` with your local changes.
89
+
90
+ ### Steps to Refresh the Changes
91
+
92
+ Under the `typescript-sdk/packages/core-sdk` directory:
93
+
94
+ - Execute `npm run build` to build your latest code.
95
+ - Run `yalc push`.
96
+
97
+ In your testing environment:
98
+
99
+ - Run `yalc update` to pull the latest changes.
100
+
101
+ ## Steps to pull and compile latest smart contract ABIs (Currently pulls from the protocol-contracts `dev` branch)
102
+
103
+ Must have `solc` installed (https://docs.soliditylang.org/en/v0.8.9/installing-solidity.html)
104
+
105
+ - run `make compile_contracts`
106
+
107
+ ## Release
108
+
109
+ | Package | Description |
110
+ | :------------------------------ | :--------------------------------------------- |
111
+ | [core-sdk](./packages/core-sdk) | The core sdk for interacting with the protocol |
112
+
113
+ ## Contributing
114
+
115
+ Pull requests are welcome. For major changes, please open an issue first
116
+ to discuss what you would like to change. Details see: [CONTRIBUTING](/CONTRIBUTING.md)
117
+
118
+ Please make sure to update tests as appropriate.
119
+
120
+ ## License
121
+
122
+ [MIT License](/LICENSE.md)
123
+
124
+ ## Contact Us