Skip to content

Commit

Permalink
Lint clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
edisonz0718 committed Jan 27, 2024
1 parent bea3b48 commit d012879
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 29 deletions.
4 changes: 2 additions & 2 deletions packages/core-sdk/src/abi/accessController.abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import errorsJson from "./json/Errors.json";

export const ErrorsAbi = errorsJson;

const mergedABI = [...AccessControllerABI, ...ErrorsAbi];
export const AccessControllerABImerged = [...AccessControllerABI, ...ErrorsAbi];

export const AccessControllerConfig = {
abi: mergedABI,
abi: AccessControllerABImerged,
address: getAddress(
process.env.ACCESS_CONTROLLER || process.env.NEXT_PUBLIC_ACCESS_CONTROLLER || "",
),
Expand Down
6 changes: 6 additions & 0 deletions packages/core-sdk/src/abi/ipAccountImpl.abi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import IPAccountImplABI from "./json/IPAccountImpl.abi";
import errorsJson from "./json/Errors.json";

export const ErrorsAbi = errorsJson;

export const IPAccountImplMerged = [...IPAccountImplABI, ...ErrorsAbi];
8 changes: 0 additions & 8 deletions packages/core-sdk/src/resources/ipAsset.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { AxiosInstance } from "axios";
import { PublicClient, WalletClient, getAddress } from "viem";

// import { handleError } from "../utils/errors";
import { IPAssetReadOnlyClient } from "./ipAssetReadOnly";
import { handleError } from "../utils/errors";
import { IPAccountRegistryConfig } from "../abi/ipAccountRegistry.abi";
Expand All @@ -10,15 +9,9 @@ import {
RegisterDerivativeIpResponse,
RegisterRootIpRequest,
RegisterRootIpResponse,
addPolicyRequest,
addPolicyResponse,
// addPolicyToIpRequest,
// addPolicyToIpResponse,
} from "../types/resources/ipAsset";
import { parseToBigInt, waitTxAndFilterLog } from "../utils/utils";
import { RegistrationModuleConfig } from "../abi/registrationModule.abi";
import { LicenseRegistryConfig } from "../abi/licenseRegistry.abi";
// import { HashZero } from "../constants/common";

export class IPAssetClient extends IPAssetReadOnlyClient {
private readonly wallet: WalletClient;
Expand Down Expand Up @@ -91,7 +84,6 @@ export class IPAssetClient extends IPAssetReadOnlyClient {
...IPAccountRegistryConfig,
eventName: "IPAccountRegistered",
});
console.log({ targetLog });
return { txHash: txHash, ipAccountId: targetLog?.args.account.toString() };
} else {
return { txHash: txHash };
Expand Down
34 changes: 25 additions & 9 deletions packages/core-sdk/src/resources/permission.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { AxiosInstance } from "axios";
import { PublicClient, WalletClient, getAddress, Hex } from "viem";
import { PublicClient, WalletClient, getAddress, Hex, encodeFunctionData } from "viem";

import { handleError } from "../utils/errors";
import { setPermissionsRequest, setPermissionsResponse } from "../types/resources/permission";
import { PermissionReadOnlyClient } from "./permissionReadOnly";
import { AccessControllerConfig } from "../abi/accessController.abi";
import { IPAccountImplMerged } from "../abi/ipAccountImpl.abi";
import { AccessControllerABImerged } from "../abi/accessController.abi";

// import { HashZero } from "../constants/common";

Expand All @@ -24,15 +25,30 @@ export class PermissionClient extends PermissionReadOnlyClient {
*/
public async setPermission(request: setPermissionsRequest): Promise<setPermissionsResponse> {
try {
const IPAccountConfig = {
abi: IPAccountImplMerged,
address: getAddress(request.ipAsset),
};
const accessController = getAddress(
process.env.ACCESS_CONTROLLER || process.env.NEXT_PUBLIC_ACCESS_CONTROLLER || "",
); //to
const { request: call } = await this.rpcClient.simulateContract({
...AccessControllerConfig,
functionName: "setPermission",
...IPAccountConfig,
functionName: "execute",
args: [
getAddress(request.ipAsset), // 0x Address
getAddress(request.signer), // 0x Address
getAddress(request.to), // 0x Address
request.func as Hex, // bytes4
request.permission, // uint8
accessController,
0,
encodeFunctionData({
abi: AccessControllerABImerged,
functionName: "setPermission",
args: [
getAddress(request.ipAsset), // 0x Address
getAddress(request.signer), // 0x Address
getAddress(request.to), // 0x Address
request.func as Hex, // bytes4
request.permission, // uint8
],
}),
],
account: this.wallet.account,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/core-sdk/test/integration/ipAsset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { sepolia } from "viem/chains";
import { Hex, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";

describe("IP Asset Functions", () => {
describe.skip("IP Asset Functions", () => {
let client: Client;
let senderAddress: string;

Expand Down
8 changes: 4 additions & 4 deletions packages/core-sdk/test/integration/permission.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ describe("Permission Functions", () => {
// TODO: this test is failing because only the IPAccount/IPAsset owner can set permission for the IPAccount. (wrong wallet)
const response = await expect(
client.permission.setPermission({
ipAsset: "0x06cb17d43f16ad5cc3cd7757296fa87ce7ac741d",
signer: "0x0baa92f82d8992ff152047f29084079c263be7f7",
to: "0x6c88f438cbfd9866dcd067ffe18b951f19b968da",
func: "0xa2b4192f",
ipAsset: "0x0F710802c59255110874c58d9051e545f6e75D96",
signer: "0x9A3A5EdDDFEe1E3A1BBef6Fdf0850B10D4979405",
to: "0x32f0471E404096B978248d0ECE3A8998D87a4b67",
func: "0x00000000",
permission: 1,
txOptions: {
waitForTransaction: waitForTransaction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe("Permission client integration tests", function () {
const response = await client.permission.get({
permissionId:
(process.env.TEST_PERMISSION_ID as string) ||
"47d64d52821188b04d2d549917a6e639d71ba967a9020bc2a144a53932a9163223cee3c012e7aeb680b59573e290f9068e4ec1ce83ec813faa670e8c1857dcb2f08c652bf97d0273ebd0cc52a5160c66bba6d9d3909857f1962c854249a7c59d2de86705e74bf05d2efd29e9bc6f40f3e92e5a9e8e5c60f326e7b875fe63cbc00c2d85616fea2c2f8d3f03cdf29029c35f03f015ded2227446e2abdd8d1069ab",
"0x06cb17d43f16ad5cc3cd7757296fa87ce7ac741d-0x6c88f438cbfd9866dcd067ffe18b951f19b968da-0x0baa92f82d8992ff152047f29084079c263be7f7-0xa2b4192f",
});

expect(response).to.have.property("data");
Expand Down
2 changes: 1 addition & 1 deletion packages/core-sdk/test/integration/platform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { goerli } from "viem/chains";
import { Hex, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";

describe("Platform client integration tests", () => {
describe.skip("Platform client integration tests", () => {
let client: Client;
before(() => {
global.FileReader = createFileReaderMock(
Expand Down
6 changes: 3 additions & 3 deletions packages/core-sdk/test/unit/resources/permission.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe("Test Permission", function () {
ipAsset: AddressZero,
signer: AddressZero,
to: AddressZero,
func: AddressZero,
func: "0x00000000",
permission: 0,
txOptions: {
waitForTransaction: false,
Expand All @@ -60,7 +60,7 @@ describe("Test Permission", function () {
ipAsset: AddressZero,
signer: AddressZero,
to: AddressZero,
func: AddressZero,
func: "0x00000000",
permission: 0,
txOptions: {
waitForTransaction: false,
Expand Down Expand Up @@ -117,7 +117,7 @@ describe("Test Permission", function () {
ipAsset: AddressZero,
signer: AddressZero,
to: AddressZero,
func: AddressZero,
func: "0x00000000",
permission: 0,
txOptions: {
waitForTransaction: false,
Expand Down

0 comments on commit d012879

Please sign in to comment.