Skip to content

Commit

Permalink
Merge pull request #207 from storyprotocol/dev
Browse files Browse the repository at this point in the history
rc.13
  • Loading branch information
edisonz0718 authored Jun 1, 2024
2 parents 65f9acc + 9a94e68 commit 1a7d208
Show file tree
Hide file tree
Showing 39 changed files with 6,841 additions and 7,593 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/publish-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
# and the event triggering the workflow is a push
if: needs.fetch_latest_version.outputs.LATEST_VERSION != needs.print_version_to_publish.outputs.version_to_be_published && github.event_name == 'push'
runs-on: ubuntu-latest
environment: 'beta-sepolia'
environment: "beta-sepolia"
env:
RPC_PROVIDER_URL: ${{ secrets.RPC_PROVIDER_URL }}
WALLET_PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }}
Expand Down Expand Up @@ -93,21 +93,21 @@ jobs:

- name: Install dependencies
run: pnpm install

- name: Fix
run: pnpm fix

- name: Run Anvil
id: run_anvil
run: anvil --fork-url ${SEPOLIA_RPC_PROVIDER_URL} --block-time 1 --silent &
run: anvil --fork-url ${SEPOLIA_RPC_PROVIDER_URL} --silent &

- name: Check on Run Anvil
if: steps.run_anvil.outcome != 'success'
run: exit 1

- name: Test
run: pnpm test

- name: Build
run: pnpm build

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.0.0-rc.12",
"version": "1.0.0-rc.13",
"description": "Story Protocol Core SDK",
"main": "dist/story-protocol-core-sdk.cjs.js",
"module": "dist/story-protocol-core-sdk.esm.js",
Expand Down
66 changes: 66 additions & 0 deletions packages/core-sdk/src/abi/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7445,6 +7445,34 @@ export type AccessControllerPermissionSetEvent = {
permission: number;
};

/**
* AccessControllerSetAllPermissionsRequest
*
* @param ipAccount address
* @param signer address
* @param permission uint8
*/
export type AccessControllerSetAllPermissionsRequest = {
ipAccount: Address;
signer: Address;
permission: number;
};

/**
* AccessControllerSetBatchPermissionsRequest
*
* @param permissions tuple[]
*/
export type AccessControllerSetBatchPermissionsRequest = {
permissions: {
ipAccount: Address;
signer: Address;
to: Address;
func: Hex;
permission: number;
}[];
};

/**
* AccessControllerSetPermissionRequest
*
Expand Down Expand Up @@ -7527,6 +7555,44 @@ export class AccessControllerClient extends AccessControllerEventClient {
this.wallet = wallet;
}

/**
* method setAllPermissions for contract AccessController
*
* @param request AccessControllerSetAllPermissionsRequest
* @return Promise<WriteContractReturnType>
*/
public async setAllPermissions(
request: AccessControllerSetAllPermissionsRequest,
): Promise<WriteContractReturnType> {
const { request: call } = await this.rpcClient.simulateContract({
abi: accessControllerAbi,
address: this.address,
functionName: "setAllPermissions",
account: this.wallet.account,
args: [request.ipAccount, request.signer, request.permission],
});
return await this.wallet.writeContract(call as WriteContractParameters);
}

/**
* method setBatchPermissions for contract AccessController
*
* @param request AccessControllerSetBatchPermissionsRequest
* @return Promise<WriteContractReturnType>
*/
public async setBatchPermissions(
request: AccessControllerSetBatchPermissionsRequest,
): Promise<WriteContractReturnType> {
const { request: call } = await this.rpcClient.simulateContract({
abi: accessControllerAbi,
address: this.address,
functionName: "setBatchPermissions",
account: this.wallet.account,
args: [request.permissions],
});
return await this.wallet.writeContract(call as WriteContractParameters);
}

/**
* method setPermission for contract AccessController
*
Expand Down
2 changes: 1 addition & 1 deletion packages/core-sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class StoryClient {
*/
public get permission(): PermissionClient {
if (this._permission === null) {
this._permission = new PermissionClient(this.rpcClient, this.wallet);
this._permission = new PermissionClient(this.rpcClient, this.wallet, this.config.chainId);
}

return this._permission;
Expand Down
6 changes: 3 additions & 3 deletions packages/core-sdk/src/constants/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const AddressZero = "0x0000000000000000000000000000000000000000";
import { Hex } from "viem";

export const AddressZero = "0x0000000000000000000000000000000000000000";
export const HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";

export const SepoliaChainId = "11155111";
export const defaultFunctionSelector: Hex = "0x00000000";
11 changes: 9 additions & 2 deletions packages/core-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,15 @@ export type {
RoyaltyVaultAddress,
} from "./types/resources/royalty";

export type { SetPermissionsRequest, SetPermissionsResponse } from "./types/resources/permission";

export type {
SetPermissionsRequest,
SetPermissionsResponse,
CreateSetPermissionSignatureRequest,
SetAllPermissionsRequest,
SetBatchPermissionsRequest,
CreateBatchPermissionSignatureRequest,
} from "./types/resources/permission";
export { AccessPermission } from "./types/resources/permission";
export type {
Dispute,
RaiseDisputeRequest,
Expand Down
17 changes: 12 additions & 5 deletions packages/core-sdk/src/resources/ipAccount.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PublicClient, getAddress } from "viem";
import { PublicClient } from "viem";

import {
IPAccountExecuteRequest,
Expand All @@ -12,6 +12,7 @@ import {
IpAccountImplStateResponse,
SimpleWalletClient,
} from "../abi/generated";
import { getAddress } from "../utils/utils";

export class IPAccountClient {
private readonly wallet: SimpleWalletClient;
Expand All @@ -24,6 +25,7 @@ export class IPAccountClient {

/** Executes a transaction from the IP Account.
* @param request - The request object containing necessary data to execute IP Account a transaction.
* @param request.ipId The Ip Id to get ip account.
* @param request.to The recipient of the transaction.
* @param request.value The amount of Ether to send.
* @param request.accountAddress The ipId to send.
Expand All @@ -35,7 +37,7 @@ export class IPAccountClient {
const ipAccountClient = new IpAccountImplClient(
this.rpcClient,
this.wallet,
getAddress(request.accountAddress),
getAddress(request.ipId, "request.ipId"),
);

const txHash = await ipAccountClient.execute({
Expand All @@ -55,6 +57,7 @@ export class IPAccountClient {

/** Executes a transaction from the IP Account.
* @param request - The request object containing necessary data to execute IP Account a transaction.
* @param request.ipId The Ip Id to get ip account.
* @param request.to The recipient of the transaction.
* @param request.value The amount of Ether to send.
* @param request.data The data to send along with the transaction.
Expand All @@ -70,7 +73,7 @@ export class IPAccountClient {
const ipAccountClient = new IpAccountImplClient(
this.rpcClient,
this.wallet,
getAddress(request.accountAddress),
getAddress(request.ipId, "request.ipId"),
);

const txHash = await ipAccountClient.executeWithSig({
Expand All @@ -93,10 +96,14 @@ export class IPAccountClient {

/** Returns the IPAccount's internal nonce for transaction ordering.
* @param ipId The IP ID
* @returns The IPAccount's internal nonce for transaction ordering.
* @returns The nonce for transaction ordering.
*/
public async getIpAccountNonce(ipId: string): Promise<IpAccountImplStateResponse> {
const ipAccount = new IpAccountImplClient(this.rpcClient, this.wallet, getAddress(ipId));
const ipAccount = new IpAccountImplClient(
this.rpcClient,
this.wallet,
getAddress(ipId, "ipId"),
);
return await ipAccount.state();
}
}
Loading

0 comments on commit 1a7d208

Please sign in to comment.