Skip to content

Commit

Permalink
Issue#20 (LIT-Protocol#97)
Browse files Browse the repository at this point in the history
* add gen-lib

* WIP: attempt to fix ecdsa-sdk build warnings

* looks like it works

* feat: improve build #LIT-436 #LIT-439

* feat: build commands for #LIT-436 #LIT-439

* feat: LIT-438 - prettier config

* chore: prettified
  • Loading branch information
Ansonhkg authored May 4, 2023
1 parent 79a2426 commit 3c3f51b
Show file tree
Hide file tree
Showing 179 changed files with 19,200 additions and 16,454 deletions.
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,12 @@

/dist
/coverage
/apps
/doc
/cypress
/.github
/.vscode
/node_modules
/tmp
/packages/*/dist
/packages/lit-third-party-libs
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"vueIndentScriptAndStyle": false,
"vueIndentScriptAndStyle": false
}
44 changes: 22 additions & 22 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apps/html/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- (DO NOT EDIT!) (HTML) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-html.mjs Mon, 01 May 2023 01:52:35 GMT -->
<!-- (DO NOT EDIT!) (HTML) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-html.mjs Thu, 04 May 2023 13:24:43 GMT -->
<!DOCTYPE html>
<html lang="en">
<head>
Expand Down Expand Up @@ -62,7 +62,7 @@
</style>
</head>
<body>
(HTML) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-html.mjs Mon, 01 May 2023 01:52:35 GMT
(HTML) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-html.mjs Thu, 04 May 2023 13:24:43 GMT

<!-- ==================== ALL EXPORTED VANILLA LIBRARIES ==================== -->
<script src="dist/packages/access-control-conditions-vanilla/access-control-conditions.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion apps/react/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1648,7 +1648,7 @@ pre {
`,
}}
/>
(REACT) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-react.mjs Mon, 01 May 2023 01:52:35 GMT
(REACT) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-react.mjs Thu, 04 May 2023 13:24:44 GMT
<div id="root"></div>
<pre><code id="result"></code></pre>
</>
Expand Down
2 changes: 1 addition & 1 deletion jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
global.TextEncoder = require('util').TextEncoder;
global.TextDecoder = require('util').TextDecoder;
global.TextDecoder = require('util').TextDecoder;
4 changes: 2 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useNx": true,
"useWorkspaces": true,
"version": "2.1.139"
}
"version": "2.1.155"
}
4 changes: 1 addition & 3 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
},
"targetDefaults": {
"build": {
"dependsOn": [
"^build"
]
"dependsOn": ["^build"]
}
},
"workspaceLayout": {
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"postBuild:mapDistFolderNameToPackageJson": "node ./tools/scripts/map-dist-folder-name-to-package-json.mjs",
"postBuild:mapDepsToDist": "node tools/scripts/map-deps-to-dist.mjs packages dist @lit-protocol",
"build": "yarn build:packages",
"build:packages": "yarn reset && yarn tools --build --packages && yarn tools --setup-local-dev && yarn postBuild:mapDepsToDist && yarn tool:genReadme",
"build:packages": "yarn reset && yarn tools --build --packages && yarn tools --postBuild && yarn tools --setup-local-dev && yarn postBuild:mapDepsToDist && yarn tool:genReadme && yarn build:verify",
"build:target": "yarn node tools/scripts/build.mjs",
"build:setupLocalDev": "yarn tools --setup-local-dev",
"build:verify": "yarn tools --verify",
Expand All @@ -22,6 +22,7 @@
"test:e2e": "yarn tools --test --e2e run-react-and-test",
"test:unit": "yarn test:packages",
"test:custom": "yarn tools --test --custom",
"bbp": "yarn bump && yarn build && yarn publish:dev",
"publish:packages": "yarn node ./tools/scripts/pub.mjs --prod",
"publish:dev": "yarn node ./tools/scripts/pub.mjs --tag dev",
"publish:test": "yarn node ./tools/scripts/pub.mjs --tag test",
Expand Down Expand Up @@ -51,7 +52,8 @@
"bump:minor": "yarn tools --v --minor",
"bump:major": "yarn tools --v --major",
"b": "git branch --show",
"txServer": "node tx-handler-server.mjs"
"txServer": "node tx-handler-server.mjs",
"prettier": "nx format:write --all"
},
"private": true,
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/access-control-conditions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ yarn add @lit-protocol/access-control-conditions
<script>
console.log(LitJsSdk_accessControlConditions);
</script>
```
```
4 changes: 2 additions & 2 deletions packages/access-control-conditions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"tags": [
"universal"
],
"version": "2.1.139",
"version": "2.1.155",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/access-control-conditions/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"sourceRoot": "packages/access-control-conditions/src",
"projectType": "library",
"targets": {
"build":{
"build": {
"executor": "nx:run-commands",
"options": {
"commands": [
Expand Down
2 changes: 1 addition & 1 deletion packages/access-control-conditions/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './lib/canonicalFormatter';
export * from './lib/hashing';
export * from './lib/humanizer';
export * from './lib/humanizer';
123 changes: 64 additions & 59 deletions packages/access-control-conditions/src/lib/hashing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ global.TextEncoder = TextEncoder;
// @ts-ignore
global.TextDecoder = TextDecoder;

import crypto, { createHash } from 'crypto'
Object.defineProperty(global.self, "crypto", {
import crypto, { createHash } from 'crypto';
Object.defineProperty(global.self, 'crypto', {
value: {
getRandomValues: (arr: any) => crypto.randomBytes(arr.length),
subtle: {
digest: (algorithm: string, data: Uint8Array) => {
return new Promise((resolve, reject) =>
resolve(
createHash(algorithm.toLowerCase().replace("-", ""))
createHash(algorithm.toLowerCase().replace('-', ''))
.update(data)
.digest()
)
Expand All @@ -22,24 +22,29 @@ Object.defineProperty(global.self, "crypto", {
},
});



import { hashAccessControlConditions, hashEVMContractConditions, hashResourceId, hashResourceIdForSigning, hashSolRpcConditions, hashUnifiedAccessControlConditions } from './hashing';
import {
hashAccessControlConditions,
hashEVMContractConditions,
hashResourceId,
hashResourceIdForSigning,
hashSolRpcConditions,
hashUnifiedAccessControlConditions,
} from './hashing';

// ---------- Test Cases ----------
describe('hashing.ts', () => {
it('should call hashUnifiedAccessControlConditions in node.js', async () => {
const OUTPUT = await hashUnifiedAccessControlConditions([
{
conditionType: "evmBasic",
contractAddress: "",
standardContractType: "",
chain: "ethereum",
method: "eth_getBalance",
parameters: [":userAddress", "latest"],
conditionType: 'evmBasic',
contractAddress: '',
standardContractType: '',
chain: 'ethereum',
method: 'eth_getBalance',
parameters: [':userAddress', 'latest'],
returnValueTest: {
comparator: ">=",
value: "0",
comparator: '>=',
value: '0',
},
},
]);
Expand Down Expand Up @@ -68,104 +73,104 @@ describe('hashing.ts', () => {
extraData: '',
});
// console.log(typeof OUTPUT);
expect(OUTPUT).toBe("5b36d72f2145af3617e5da2a8a626f9f42e64ed14340622bdfe1a6f0702b9e8d");
expect(OUTPUT).toBe(
'5b36d72f2145af3617e5da2a8a626f9f42e64ed14340622bdfe1a6f0702b9e8d'
);
});

it('should call hashAccessControlConditions in node.js', async () => {
const OUTPUT = await hashAccessControlConditions([
{
conditionType: "evmBasic",
contractAddress: "",
standardContractType: "",
chain: "ethereum",
method: "eth_getBalance",
parameters: [":userAddress", "latest"],
conditionType: 'evmBasic',
contractAddress: '',
standardContractType: '',
chain: 'ethereum',
method: 'eth_getBalance',
parameters: [':userAddress', 'latest'],
returnValueTest: {
comparator: ">=",
value: "0",
comparator: '>=',
value: '0',
},
},
]);
// console.log(typeof OUTPUT);
expect(typeof OUTPUT).toBe("object");
expect(typeof OUTPUT).toBe('object');
});

it('should call hashEVMContractConditions in node.js', async () => {
const OUTPUT = await hashEVMContractConditions([
{
contractAddress: "0xb71a679cfff330591d556c4b9f21c7739ca9590c",
functionName: "members",
functionParams: [":userAddress"],
contractAddress: '0xb71a679cfff330591d556c4b9f21c7739ca9590c',
functionName: 'members',
functionParams: [':userAddress'],
functionAbi: {
constant: true,
inputs: [
{
name: "",
type: "address",
name: '',
type: 'address',
},
],
name: "members",
name: 'members',
outputs: [
{
name: "delegateKey",
type: "address",
name: 'delegateKey',
type: 'address',
},
{
name: "shares",
type: "uint256",
name: 'shares',
type: 'uint256',
},
{
name: "loot",
type: "uint256",
name: 'loot',
type: 'uint256',
},
{
name: "exists",
type: "bool",
name: 'exists',
type: 'bool',
},
{
name: "highestIndexYesVote",
type: "uint256",
name: 'highestIndexYesVote',
type: 'uint256',
},
{
name: "jailed",
type: "uint256",
name: 'jailed',
type: 'uint256',
},
],
payable: false,
stateMutability: "view",
type: "function",
stateMutability: 'view',
type: 'function',
},
chain: "xdai",
chain: 'xdai',
returnValueTest: {
key: "shares",
comparator: ">=",
value: "1",
key: 'shares',
comparator: '>=',
value: '1',
},
},
]);
// console.log(typeof OUTPUT);
expect(typeof OUTPUT).toBe("object");
expect(typeof OUTPUT).toBe('object');
});

it('should call hashSolRpcConditions in node.js', async () => {
const OUTPUT = await hashSolRpcConditions([
{
method: "getBalance",
params: [":userAddress"],
method: 'getBalance',
params: [':userAddress'],
pdaParams: [],
pdaInterface: { offset: 0, fields: {} },
pdaKey: "",
chain: "solana",
pdaKey: '',
chain: 'solana',
returnValueTest: {
key: "",
comparator: ">=",
value: "100000000", // equals 0.1 SOL
key: '',
comparator: '>=',
value: '100000000', // equals 0.1 SOL
},
},
]);
// console.log(typeof OUTPUT);
expect(typeof OUTPUT).toBe("object");
expect(typeof OUTPUT).toBe('object');
});


});
Loading

0 comments on commit 3c3f51b

Please sign in to comment.