Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Ansonhkg committed Jan 24, 2024
1 parent a133202 commit af7ab76
Show file tree
Hide file tree
Showing 43 changed files with 154 additions and 180 deletions.
2 changes: 1 addition & 1 deletion e2e-nodejs/loader.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ if (!useCache) {
console.log('could not parse or write to lit.config.json');
console.log(e);
}
}
}
2 changes: 1 addition & 1 deletion lit.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion packages/access-control-conditions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
"version": "3.0.29",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
13 changes: 5 additions & 8 deletions packages/access-control-conditions/src/lib/hashing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@ import {

// ---------- Test Cases ----------
describe('hashing.ts', () => {

it('creates a hash for RLI delegation accs', async () => {
const hash = await generateUnifiedAccsForRLIDelegation(['0x01', '0x02']);

const hash = await generateUnifiedAccsForRLIDelegation([
'0x01',
'0x02'
]);

expect(hash).toBe('95ccb92934f816417d7b87fef8c03f9c9c13ca13c75de993d4cb31a0c63f04d9');
})
expect(hash).toBe(
'95ccb92934f816417d7b87fef8c03f9c9c13ca13c75de993d4cb31a0c63f04d9'
);
});

it('hashes a resource id', async () => {
const path = '/bglyaysu8rvblxlk7x0ksn';
Expand Down
10 changes: 5 additions & 5 deletions packages/access-control-conditions/src/lib/hashing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
} from './canonicalFormatter';
import { uint8arrayToString } from '@lit-protocol/uint8arrays';


// Same as:
// const unifiedAccs = [
// {
Expand Down Expand Up @@ -48,8 +47,10 @@ import { uint8arrayToString } from '@lit-protocol/uint8arrays';
// },
// },
// ];
export const generateUnifiedAccsForRLIDelegation = async (ethAddresses: string[]): Promise<string> => {
const unifiedAccs: (any)[] = [];
export const generateUnifiedAccsForRLIDelegation = async (
ethAddresses: string[]
): Promise<string> => {
const unifiedAccs: any[] = [];

ethAddresses.forEach((address, index) => {
const condition = {
Expand All @@ -76,8 +77,7 @@ export const generateUnifiedAccsForRLIDelegation = async (ethAddresses: string[]
const hash = await hashUnifiedAccessControlConditions(unifiedAccs);

return uint8arrayToString(new Uint8Array(hash), 'base16');

}
};

/**
*
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
"version": "3.0.29",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/auth-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
"version": "3.0.29",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/auth-helpers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export * from './lib/models';
export * from './lib/session-capability-object';
export * from './lib/resources';
export * from './lib/siwe';
export * from './lib/recap/recap-session-capability-object'
export * from './lib/recap/recap-session-capability-object';
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ describe('recapSessionCapabilityObject', () => {
expect(recapSessionCapabilityObject.proofs).toEqual([]);
});


it('should be able to decode a RecapSessionCapabilityObject', async () => {
const recapSessionCapabilityObject = new RecapSessionCapabilityObject();
const litResource = new LitAccessControlConditionResource('someResource');
Expand Down Expand Up @@ -106,7 +105,6 @@ describe('recapSessionCapabilityObject', () => {
});

it('shold be able to add rate limit auth sig', async () => {

const att = {
someResource: {
'lit-ratelimitincrease/1337': [{}],
Expand All @@ -119,11 +117,12 @@ describe('recapSessionCapabilityObject', () => {
);

const mockAuthSig = {
"sig": "0x137b66529678d1fc58ab5b340ad036082af5b9912f823ba22c2851b8f50990a666ad8f2ab2328e8c94414c0a870163743bde91a5f96e9f967fd45d5e0c17c3911b",
"derivedVia": "web3.eth.personal.sign",
"signedMessage": "localhost wants you to sign in with your Ethereum account:\n0xeF71c2604f17Ec6Fc13409DF24EfdC440D240d37\n\nTESTING TESTING 123\n\nURI: https://localhost/login\nVersion: 1\nChain ID: 1\nNonce: eoeo0dsvyLL2gcHsC\nIssued At: 2023-11-17T15:04:20.324Z\nExpiration Time: 2215-07-14T15:04:20.323Z",
"address": "0xeF71c2604f17Ec6Fc13409DF24EfdC440D240d37"
}
sig: '0x137b66529678d1fc58ab5b340ad036082af5b9912f823ba22c2851b8f50990a666ad8f2ab2328e8c94414c0a870163743bde91a5f96e9f967fd45d5e0c17c3911b',
derivedVia: 'web3.eth.personal.sign',
signedMessage:
'localhost wants you to sign in with your Ethereum account:\n0xeF71c2604f17Ec6Fc13409DF24EfdC440D240d37\n\nTESTING TESTING 123\n\nURI: https://localhost/login\nVersion: 1\nChain ID: 1\nNonce: eoeo0dsvyLL2gcHsC\nIssued At: 2023-11-17T15:04:20.324Z\nExpiration Time: 2215-07-14T15:04:20.323Z',
address: '0xeF71c2604f17Ec6Fc13409DF24EfdC440D240d37',
};

await recapSessionCapabilityObject.addRateLimitAuthSig(mockAuthSig);

Expand All @@ -132,7 +131,9 @@ describe('recapSessionCapabilityObject', () => {
'lit-ratelimitincrease/1337': [{}],
},
});
expect(recapSessionCapabilityObject.proofs[0]).toBe("QmQiy7M88uboUkSF68Hv73NWL8dnrbMNZmbstVVi3UVrgM");
expect(recapSessionCapabilityObject.proofs[0]).toBe(
'QmQiy7M88uboUkSF68Hv73NWL8dnrbMNZmbstVVi3UVrgM'
);
});

it('should be able to get proofs', async () => {
Expand Down Expand Up @@ -218,8 +219,10 @@ describe('recapSessionCapabilityObject', () => {
const newSiweMessage =
recapSessionCapabilityObject.addToSiweMessage(siweMessage);
expect(newSiweMessage.statement).toEqual(
`This is some existing statement. I further authorize the stated URI to perform the following actions on my behalf: (1) '${LitNamespace.Threshold
}': '${LitRecapAbility.Decryption
`This is some existing statement. I further authorize the stated URI to perform the following actions on my behalf: (1) '${
LitNamespace.Threshold
}': '${
LitRecapAbility.Decryption
}' for '${litResource.getResourceKey()}'.`
);
expect(newSiweMessage.resources).toEqual([
Expand Down Expand Up @@ -445,19 +448,19 @@ describe('recapSessionCapabilityObject', () => {

describe('strToCID', () => {
it('should handle string input', async () => {
const input = "Hello, world!";
const input = 'Hello, world!';
const result = await RecapSessionCapabilityObject.strToCID(input);
expect(result).toBe('QmWGeRAEgtsHW3ec7U4qW2CyVy7eA2mFRVbk1nb24jFyks');
});

it('should handle Uint8Array input', async () => {
const input = new TextEncoder().encode("Hello, world!");
const input = new TextEncoder().encode('Hello, world!');
const result = await RecapSessionCapabilityObject.strToCID(input);
expect(result).toBe('QmWGeRAEgtsHW3ec7U4qW2CyVy7eA2mFRVbk1nb24jFyks');
});

it('should handle object input', async () => {
const input = { message: "Hello, world!" };
const input = { message: 'Hello, world!' };
const result = await RecapSessionCapabilityObject.strToCID(input);
expect(result).toBe('QmTR2kDqux4yo5X9W6GKJKEn6azDqXqifRMGYtX27oAQLk');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export class RecapSessionCapabilityObject implements ISessionCapabilityObject {
// This should ideally be placed in the IPFSBundledSDK package, but for some reasons
// there seems to be bundling issues where the jest test would fail, but somehow
// works here.
public static async strToCID(data: string | Uint8Array | object): Promise<string> {
public static async strToCID(
data: string | Uint8Array | object
): Promise<string> {
let content: Uint8Array;

// Check the type of data and convert accordingly
Expand All @@ -50,7 +52,7 @@ export class RecapSessionCapabilityObject implements ISessionCapabilityObject {
content = new TextEncoder().encode(contentStr);
} else {
// console.log("Type D");
throw new Error("Invalid content type");
throw new Error('Invalid content type');
}

// Create the CID
Expand All @@ -65,7 +67,7 @@ export class RecapSessionCapabilityObject implements ISessionCapabilityObject {

// Validate the IPFS ID
if (!ipfsId) {
throw new Error("Could not create IPFS ID");
throw new Error('Could not create IPFS ID');
}

// Return the IPFS ID as a string
Expand All @@ -82,7 +84,6 @@ export class RecapSessionCapabilityObject implements ISessionCapabilityObject {
* @param authSig The AuthSig object containing the rate limit authorization details.
*/
async addRateLimitAuthSig(authSig: AuthSig) {

const ipfsId = await RecapSessionCapabilityObject.strToCID(authSig);

try {
Expand Down Expand Up @@ -161,7 +162,7 @@ export class RecapSessionCapabilityObject implements ISessionCapabilityObject {
return this.addAttenuation(
litResource.getResourceKey(),
recapNamespace,
recapAbility,
recapAbility
);
}

Expand All @@ -171,7 +172,6 @@ export class RecapSessionCapabilityObject implements ISessionCapabilityObject {
recapAbility,
data
);

}

verifyCapabilitiesForResource(
Expand Down
4 changes: 2 additions & 2 deletions packages/auth-helpers/src/lib/siwe.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sanitizeSiweMessage } from "./siwe";
import { sanitizeSiweMessage } from './siwe';

describe('sanitizeSiweMessage', () => {
it('should unescape double-escaped newlines', () => {
Expand Down Expand Up @@ -30,4 +30,4 @@ describe('sanitizeSiweMessage', () => {
const expectedOutput = "This 'is' a test\\n\\nNew line";
expect(sanitizeSiweMessage(input)).toBe(expectedOutput);
});
});
});
2 changes: 1 addition & 1 deletion packages/auth-helpers/src/lib/siwe.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function sanitizeSiweMessage(message: string): string {
// Unescape double-escaped newlines
let sanitizedMessage = message.replace(/\\\\n/g, "\\n");
let sanitizedMessage = message.replace(/\\\\n/g, '\\n');

// Replace escaped double quotes with single quotes
sanitizedMessage = sanitizedMessage.replace(/\\"/g, "'");
Expand Down
2 changes: 1 addition & 1 deletion packages/bls-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
"version": "3.0.29",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/constants/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
"version": "3.0.29",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
24 changes: 0 additions & 24 deletions packages/constants/src/lib/constants/autogen_internal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<<<<<<< HEAD
// Last Modified: 2024-01-24 11:31:24
// This file is auto-generated by tools/scripts/gen-internal-dev.mjs
export const INTERNAL_DEV = [
Expand All @@ -12,18 +11,6 @@ export const INTERNAL_DEV = [
'https://199.115.117.113:443',
'https://64.131.85.106:443',
'https://167.114.17.205:443',
=======
// Last Modified: 2024-01-18 22:24:07
// This file is auto-generated by tools/scripts/gen-internal-dev.mjs
export const INTERNAL_DEV = [
"https://167.114.17.204:443",
"https://199.115.117.115:443",
"https://167.114.17.203:443",
"https://167.114.17.202:443",
"https://64.131.85.108:443",
"https://167.114.17.201:443",
"https://108.62.0.105:443"
>>>>>>> origin/nft-delegation-2
];

export const INTERNAL_MIN_NODE_COUNT = 2;
Expand All @@ -33,7 +20,6 @@ export const INTERNAL_DEFAULT_CONFIG = {
minNodeCount: 2,
debug: true,
bootstrapUrls: [
<<<<<<< HEAD
'https://167.114.17.204:443',
'https://199.115.117.115:443',
'https://108.62.0.105:443',
Expand All @@ -45,16 +31,6 @@ export const INTERNAL_DEFAULT_CONFIG = {
'https://64.131.85.106:443',
'https://167.114.17.205:443',
],
=======
"https://167.114.17.204:443",
"https://199.115.117.115:443",
"https://167.114.17.203:443",
"https://167.114.17.202:443",
"https://64.131.85.108:443",
"https://167.114.17.201:443",
"https://108.62.0.105:443"
],
>>>>>>> origin/nft-delegation-2
litNetwork: 'internalDev',
connectTimeout: 20000,
};
2 changes: 1 addition & 1 deletion packages/contracts-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
"version": "3.0.29",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
22 changes: 11 additions & 11 deletions packages/contracts-sdk/src/abis/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export * from "./StakingBalances.sol/StakingBalances.ts";
export * from "./Staking.sol/Staking.ts";
export * from "./Multisender.sol/Multisender.ts";
export * from "./LITToken.sol/LITToken.ts";
export * from "./PubkeyRouter.sol/PubkeyRouter.ts";
export * from "./PKPNFT.sol/PKPNFT.ts";
export * from "./RateLimitNFT.sol/RateLimitNFT.ts";
export * from "./PKPHelper.sol/PKPHelper.ts";
export * from "./PKPPermissions.sol/PKPPermissions.ts";
export * from "./PKPNFTMetadata.sol/PKPNFTMetadata.ts";
export * from "./Allowlist.sol/Allowlist.ts";
export * from './StakingBalances.sol/StakingBalances.ts';
export * from './Staking.sol/Staking.ts';
export * from './Multisender.sol/Multisender.ts';
export * from './LITToken.sol/LITToken.ts';
export * from './PubkeyRouter.sol/PubkeyRouter.ts';
export * from './PKPNFT.sol/PKPNFT.ts';
export * from './RateLimitNFT.sol/RateLimitNFT.ts';
export * from './PKPHelper.sol/PKPHelper.ts';
export * from './PKPPermissions.sol/PKPPermissions.ts';
export * from './PKPNFTMetadata.sol/PKPNFTMetadata.ts';
export * from './Allowlist.sol/Allowlist.ts';
Loading

0 comments on commit af7ab76

Please sign in to comment.