Skip to content

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
DonFungible committed Feb 5, 2024
2 parents 947a5e5 + e583c30 commit 9711994
Show file tree
Hide file tree
Showing 36 changed files with 961 additions and 186 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ on:
RPC_PROVIDER_URL:
required: true
WALLET_PRIVATE_KEY:
required: true
DISPUTE_MODULE:
required: true

jobs:
build:
Expand All @@ -41,6 +44,7 @@ jobs:
NEXT_PUBLIC_IP_ACCOUNT_REGISTRY: ${{ secrets.IP_ACCOUNT_REGISTRY }}
NEXT_PUBLIC_REGISTRATION_MODULE: ${{ secrets.REGISTRATION_MODULE }}
NEXT_PUBLIC_TAGGING_MODULE: ${{ secrets.TAGGING_MODULE }}
NEXT_PUBLIC_DISPUTE_MODULE: ${{ secrets.DISPUTE_MODULE }}
NEXT_PUBLIC_LICENSE_REGISTRY: ${{ secrets.LICENSE_REGISTRY }}
NEXT_PUBLIC_ACCESS_CONTROLLER: ${{ secrets.ACCESS_CONTROLLER }}
RPC_PROVIDER_URL: ${{ secrets.RPC_PROVIDER_URL }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/internal-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
IP_ACCOUNT_REGISTRY: ${{ secrets.IP_ACCOUNT_REGISTRY }}
REGISTRATION_MODULE: ${{ secrets.REGISTRATION_MODULE }}
TAGGING_MODULE: ${{ secrets.TAGGING_MODULE }}
DISPUTE_MODULE: ${{ secrets.DISPUTE_MODULE }}
LICENSE_REGISTRY: ${{ secrets.LICENSE_REGISTRY }}
ACCESS_CONTROLLER: ${{ secrets.ACCESS_CONTROLLER }}
API_BASE_URL: ${{ secrets.API_BASE_URL }}
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "packages/core-sdk/protocol-contracts"]
path = packages/core-sdk/protocol-contracts
url = https://github.com/storyprotocol/protocol-core
branch = beta-rc1
branch = beta-rc2
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
compile_contracts:
git submodule add -b beta-rc1 --force https://github.com/storyprotocol/protocol-core packages/core-sdk/protocol-contracts
git submodule add -b beta-rc2 --force https://github.com/storyprotocol/protocol-core packages/core-sdk/protocol-contracts
git submodule update --remote --merge
cd packages/core-sdk/protocol-contracts && npm i --force && forge install

solc --pretty-json --base-path packages/core-sdk/protocol-contracts --include-path packages/core-sdk/protocol-contracts/node_modules/ --abi packages/core-sdk/protocol-contracts/contracts/IPAccountImpl.sol -o packages/core-sdk/src/abi/json/tmp/IPAccountImpl
solc --pretty-json --base-path packages/core-sdk/protocol-contracts --include-path packages/core-sdk/protocol-contracts/node_modules/ --abi packages/core-sdk/protocol-contracts/contracts/AccessController.sol -o packages/core-sdk/src/abi/json/tmp/AccessController
solc --pretty-json --base-path packages/core-sdk/protocol-contracts --include-path packages/core-sdk/protocol-contracts/node_modules/ --abi packages/core-sdk/protocol-contracts/contracts/modules/RegistrationModule.sol -o packages/core-sdk/src/abi/json/tmp/RegistrationModule
solc --pretty-json --base-path packages/core-sdk/protocol-contracts --include-path packages/core-sdk/protocol-contracts/node_modules/ --abi packages/core-sdk/protocol-contracts/contracts/modules/tagging/TaggingModule.sol -o packages/core-sdk/src/abi/json/tmp/TaggingModule
solc --pretty-json --base-path packages/core-sdk/protocol-contracts --include-path packages/core-sdk/protocol-contracts/node_modules/ --abi packages/core-sdk/protocol-contracts/contracts/modules/dispute-module/DisputeModule.sol -o packages/core-sdk/src/abi/json/tmp/DisputeModule
solc --pretty-json --base-path packages/core-sdk/protocol-contracts --include-path packages/core-sdk/protocol-contracts/node_modules/ --abi packages/core-sdk/protocol-contracts/contracts/interfaces/registries/IIPAccountRegistry.sol -o packages/core-sdk/src/abi/json/tmp/IIPAccountRegistry
solc --pretty-json --base-path packages/core-sdk/protocol-contracts --include-path packages/core-sdk/protocol-contracts/node_modules/ --abi packages/core-sdk/protocol-contracts/contracts/registries/IPRecordRegistry.sol -o packages/core-sdk/src/abi/json/tmp/IPRecordRegistry
solc --pretty-json --base-path packages/core-sdk/protocol-contracts --include-path packages/core-sdk/protocol-contracts/node_modules/ --abi packages/core-sdk/protocol-contracts/contracts/registries/LicenseRegistry.sol -o packages/core-sdk/src/abi/json/tmp/LicenseRegistry
Expand All @@ -19,6 +20,7 @@ compile_contracts:
echo 'export default '"$$(jq --argjson entities "$$(jq -c '.' packages/core-sdk/src/abi/sdkEntities.json)" 'map(select(.name as $$name | $$entities | if type == "array" then index($$name) else false end))' packages/core-sdk/src/abi/json/tmp/AccessController/AccessController.abi)"' as const;' > packages/core-sdk/src/abi/json/AccessController.abi.ts
echo 'export default '"$$(jq --argjson entities "$$(jq -c '.' packages/core-sdk/src/abi/sdkEntities.json)" 'map(select(.name as $$name | $$entities | if type == "array" then index($$name) else false end))' packages/core-sdk/src/abi/json/tmp/RegistrationModule/RegistrationModule.abi)"' as const;' > packages/core-sdk/src/abi/json/RegistrationModule.abi.ts
echo 'export default '"$$(jq --argjson entities "$$(jq -c '.' packages/core-sdk/src/abi/sdkEntities.json)" 'map(select(.name as $$name | $$entities | if type == "array" then index($$name) else false end))' packages/core-sdk/src/abi/json/tmp/TaggingModule/TaggingModule.abi)"' as const;' > packages/core-sdk/src/abi/json/TaggingModule.abi.ts
echo 'export default '"$$(jq --argjson entities "$$(jq -c '.' packages/core-sdk/src/abi/sdkEntities.json)" 'map(select(.name as $$name | $$entities | if type == "array" then index($$name) else false end))' packages/core-sdk/src/abi/json/tmp/DisputeModule/DisputeModule.abi)"' as const;' > packages/core-sdk/src/abi/json/DisputeModule.abi.ts
echo 'export default '"$$(jq --argjson entities "$$(jq -c '.' packages/core-sdk/src/abi/sdkEntities.json)" 'map(select(.name as $$name | $$entities | if type == "array" then index($$name) else false end))' packages/core-sdk/src/abi/json/tmp/IIPAccountRegistry/IIPAccountRegistry.abi)"' as const;' > packages/core-sdk/src/abi/json/IIPAccountRegistry.abi.ts
echo 'export default '"$$(jq --argjson entities "$$(jq -c '.' packages/core-sdk/src/abi/sdkEntities.json)" 'map(select(.name as $$name | $$entities | if type == "array" then index($$name) else false end))' packages/core-sdk/src/abi/json/tmp/IPRecordRegistry/IPRecordRegistry.abi)"' as const;' > packages/core-sdk/src/abi/json/IPRecordRegistry.abi.ts
echo 'export default '"$$(jq --argjson entities "$$(jq -c '.' packages/core-sdk/src/abi/sdkEntities.json)" 'map(select(.name as $$name | $$entities | if type == "array" then index($$name) else false end))' packages/core-sdk/src/abi/json/tmp/LicenseRegistry/LicenseRegistry.abi)"' as const;' > packages/core-sdk/src/abi/json/LicenseRegistry.abi.ts
Expand Down
58 changes: 34 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@ Welcome to the documents for Story Protocol SDK. The SDK provides the APIs for d
## How to use Story Protocol SDK in Your Project

### Install Story Protocol core SDK

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:

Use `npm`:

```
npm install --save @story-protocol/core-sdk viem
```

Use `pnpm`:

```
pnpm install @story-protocol/core-sdk viem
```

Use `yarn`:

```
yarn add @story-protocol/core-sdk viem
```
Expand Down Expand Up @@ -57,39 +61,38 @@ Next, we need create a client to access Story Protocol by using private key or f
Here is the way to create a Story Protocol client with the private key:

```typescript
import { privateKeyToAccount } from "viem/accounts";
import { privateKeyToAccount } from 'viem/accounts';

const PRIVATE_KEY = process.env.PRIVATE_KEY || "0x";
const PRIVATE_KEY = process.env.PRIVATE_KEY || '0x';
const account = privateKeyToAccount(PRIVATE_KEY as `0x${string}`);

// Instantiate the Story Client for readonly operations, using default
// Instantiate the Story Client for readonly operations, using default
export const realonlyClient = StoryClient.newReadOnlyClient({});

// Instantiate the Story Client, test environment required for alpha release.
// The private key is also required for written operations.
export const client = StoryClient.newClient({account});
export const client = StoryClient.newClient({ account });
```

Here is the way to create a Story Protocol with wallet app:

```typescript
import { createWalletClient, custom } from 'viem'
import { sepolia } from 'viem/chains'
import { createWalletClient, custom } from 'viem';

const walletClient = createWalletClient({
chain: sepolia,
transport: custom(window.ethereum)
})
chainId: 'sepolia',
transport: custom(window.ethereum),
});

// Retrieve the first account for eth_requestAccounts method
const account = await walletClient.requestAddresses()[0]
const account = await walletClient.requestAddresses()[0];

// Instantiate the Story Client for readonly operations, using default
// Instantiate the Story Client for readonly operations, using default
export const realonlyClient = StoryClient.newReadOnlyClient({});

// Instantiate the Story Client, test environment required for alpha release.
// The private key is also required for written operations.
export const client = StoryClient.newClient({account});
export const client = StoryClient.newClient({ account });
```

### Use `Client` or `ReadOnlyClient` to access Story Protocol
Expand All @@ -104,32 +107,40 @@ This section provides the instructions on how to build Story Protocol SDK from s

### Prerequisite

* Install PNPM: Execute `npm install -g pnpm`
* Install TypeScript: Run `pnpm add typescript -D`
* Install Yalc: Use `npm install -g yalc`
- Install PNPM: Execute `npm install -g pnpm`
- Install TypeScript: Run `pnpm add typescript -D`
- Install Yalc: Use `npm install -g yalc`

### Steps for Using Yalc for Local Testing of Core-SDK

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.

Under the `typescript-sdk/packages/core-sdk` directory:
* Navigate to the `core-sdk` directory.
* Execute `npm run build` to build your latest code.
* Run `yalc publish`. You should see a message like `@story-protocol/core-sdk@<version> published in store.` (Note: The version number may vary).

- Navigate to the `core-sdk` directory.
- Execute `npm run build` to build your latest code.
- Run `yalc publish`. You should see a message like `@story-protocol/core-sdk@<version> published in store.` (Note: The version number may vary).

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).
* Run `pnpm install`. This installs `@story-protocol/core-sdk@<version>` with your local changes.

- Run `pnpm install`. This installs `@story-protocol/core-sdk@<version>` with your local changes.

### Steps to Refresh the Changes

Under the `typescript-sdk/packages/core-sdk` directory:
* Execute `npm run build` to build your latest code.
* Run `yalc push`.

- Execute `npm run build` to build your latest code.
- Run `yalc push`.

In your testing environment:
* Run `yalc update` to pull the latest changes.

- Run `yalc update` to pull the latest changes.

## Steps to pull and compile latest smart contract ABIs (Currently pulls from the protocol-contracts `dev` branch)

Must have `solc` installed (https://docs.soliditylang.org/en/v0.8.9/installing-solidity.html)
* run `make compile_contracts`

- run `make compile_contracts`

## Release

Expand All @@ -149,4 +160,3 @@ Please make sure to update tests as appropriate.
[MIT License](/LICENSE.md)

## Contact Us

5 changes: 5 additions & 0 deletions packages/core-sdk/src/abi/accessController.abi.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { getAddress } from "viem";
import * as dotenv from "dotenv";

import AccessControllerABI from "./json/AccessController.abi";
import errorsJson from "./json/Errors.json";

if (typeof process !== "undefined") {
dotenv.config();
}

export const ErrorsAbi = errorsJson;

export const AccessControllerABImerged = [...AccessControllerABI, ...ErrorsAbi];
Expand Down
17 changes: 17 additions & 0 deletions packages/core-sdk/src/abi/disputeModule.abi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { formatAbi } from "abitype";
import { getAddress } from "viem";
import * as dotenv from "dotenv";

import DisputeModuleABI from "./json/DisputeModule.abi";

if (typeof process !== "undefined") {
dotenv.config();
}

export const DisputeModuleRaw = DisputeModuleABI;
export const DisputeModuleReadable = formatAbi(DisputeModuleRaw);

export const DisputeModuleConfig = {
abi: DisputeModuleRaw,
address: getAddress(process.env.DISPUTE_MODULE || process.env.NEXT_PUBLIC_DISPUTE_MODULE || ""),
};
7 changes: 6 additions & 1 deletion packages/core-sdk/src/abi/ipAccountImpl.abi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import * as dotenv from "dotenv";

import IPAccountImplABI from "./json/IPAccountImpl.abi";
import errorsJson from "./json/Errors.json";

export const ErrorsAbi = errorsJson;
if (typeof process !== "undefined") {
dotenv.config();
}

export const ErrorsAbi = errorsJson;
export const IPAccountImplMerged = [...IPAccountImplABI, ...ErrorsAbi];
123 changes: 123 additions & 0 deletions packages/core-sdk/src/abi/json/DisputeModule.abi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
export default [
{
inputs: [
{
internalType: "address",
name: "_targetIpId",
type: "address",
},
{
internalType: "address",
name: "_arbitrationPolicy",
type: "address",
},
{
internalType: "string",
name: "_linkToDisputeEvidence",
type: "string",
},
{
internalType: "bytes32",
name: "_targetTag",
type: "bytes32",
},
{
internalType: "bytes",
name: "_data",
type: "bytes",
},
],
name: "raiseDispute",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{
internalType: "uint256",
name: "_disputeId",
type: "uint256",
},
{
internalType: "bool",
name: "_decision",
type: "bool",
},
{
internalType: "bytes",
name: "_data",
type: "bytes",
},
],
name: "setDisputeJudgement",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{
internalType: "address",
name: "_arbitrationPolicy",
type: "address",
},
{
internalType: "bool",
name: "_allowed",
type: "bool",
},
],
name: "whitelistArbitrationPolicy",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{
internalType: "address",
name: "_arbitrationPolicy",
type: "address",
},
{
internalType: "address",
name: "_arbPolicyRelayer",
type: "address",
},
{
internalType: "bool",
name: "_allowed",
type: "bool",
},
],
name: "whitelistArbitrationRelayer",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{
internalType: "bytes32",
name: "_tag",
type: "bytes32",
},
{
internalType: "bool",
name: "_allowed",
type: "bool",
},
],
name: "whitelistDisputeTags",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
] as const;
Loading

0 comments on commit 9711994

Please sign in to comment.