Skip to content

Commit b0daa1a

Browse files
committed
Merge branch 'feat/naga-fix-bls-wasm-cleanup' into anshs
2 parents 309512b + 1196d13 commit b0daa1a

File tree

547 files changed

+25661
-158652
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

547 files changed

+25661
-158652
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -42,51 +42,44 @@ jobs:
4242
- name: Build
4343
run: yarn build:dev
4444
- name: Run Unit tests
45-
run: yarn tools --test --unit
46-
integration-tests:
45+
run: yarn test:unit
46+
naga-integration-tests:
4747
runs-on: ubuntu-latest
4848
timeout-minutes: 30
49+
env:
50+
NAGA_COMMIT_HASH: 7afa4d33bcc127dba4aff40979166fc25fb01103
4951
steps:
5052
- name: Checkout repo
5153
uses: actions/checkout@v2
5254
with:
5355
fetch-depth: 0
54-
- name: Find latest datil commit hash for last successful "rust/lit-node-build-commit-hash" workflow in the Lit Assets repo
55-
uses: LIT-Protocol/last-successful-build-action@372ea3325a894558ee74d970217ca421ea562fba
56-
id: last-successful-build
57-
with:
58-
token: "${{ secrets.GH_PAT_FOR_SHIVA }}"
59-
branch: "datil"
60-
workflow: "rust/lit-node-build-commit-hash"
61-
repo: LIT-Protocol/lit-assets
62-
# this outputs to dollarSign{{ steps.last-successful-build.outputs.lastSuccessfulBuildSha }}
63-
- name: Checkout Lit Assets
56+
- name: Checkout Lit Actions
6457
uses: actions/checkout@v4
6558
id: checkout
66-
with:
59+
with:
6760
fetch-depth: 0
6861
repository: LIT-Protocol/lit-assets
69-
ref: ${{ steps.last-successful-build.outputs.lastSuccessfulBuildSha }}
62+
ref: ${{env.NAGA_COMMIT_HASH}}
7063
token: ${{secrets.GH_PAT_FOR_SHIVA}}
7164
path: ${{ github.workspace }}/lit-assets/
7265
submodules: false
7366
sparse-checkout: |
74-
blockchain
75-
rust/lit-node
67+
blockchain
68+
rust/lit-node
7669
- name: Check LA dir
7770
run: ls -la ${{github.workspace}}/lit-assets
7871
- name: Install LA Blockchain Dependencies
7972
run: npm i
8073
working-directory: ${{github.workspace}}/lit-assets/blockchain/contracts
8174
- name: Docker login
8275
id: login
83-
run: docker login ghcr.io/ -u ${{ github.actor }} --password ${{secrets.GH_PAT_FOR_SHIVA}}
76+
run: docker login ghcr.io/ -u ${{secrets.GH_USER}} --password ${{secrets.GH_PAT_FOR_SHIVA}}
8477
- name: Pull Shiva Container
8578
id: shiva-pull
86-
run: docker pull ghcr.io/lit-protocol/shiva:latest
79+
run: docker pull ghcr.io/lit-protocol/shiva:latest
8780
- name: Run Shiva Container
8881
id: shiva-runner
89-
run: docker run -d -m 32g -p 8000:8000 -p 8545:8545 -p 7470:7470 -p 7471:7471 -p 7472:7472 -p 7473:7473 -p 7474:7474 -p 7475:7475 -v ${{github.workspace}}/lit-assets:/data -e GH_PAT=${{secrets.GH_PAT_FOR_SHIVA}} -e HASH=${{ steps.last-successful-build.outputs.lastSuccessfulBuildSha }} -e IPFS_API_KEY=${{secrets.IPFS_API_KEY}} --name shiva ghcr.io/lit-protocol/shiva:latest
82+
run: docker run -d -m 32g -p 8000:8000 -p 8545:8545 -p 7470:7470 -p 7471:7471 -p 7472:7472 -p 7473:7473 -p 7474:7474 -p 7475:7475 -v ${{github.workspace}}/lit-assets:/data -e GH_PAT=${{secrets.GH_PAT_FOR_SHIVA}} -e HASH=$NAGA_COMMIT_HASH -e IPFS_API_KEY=${{secrets.IPFS_API_KEY}} --name shiva ghcr.io/lit-protocol/shiva:latest
9083
- name: Set up Node.js
9184
uses: actions/setup-node@v3
9285
with:
@@ -117,34 +110,4 @@ jobs:
117110
run: docker stop shiva && docker rm shiva
118111
- name: Post Pull Shiva Image
119112
if: steps.shiva-pull.outputs.exit_code == 0
120-
run: docker rmi ghcr.io/lit-protocol/shiva
121-
ping-lit-configuration-guides:
122-
runs-on: ubuntu-latest
123-
# needs: [unit-tests, integration-tests] # Make sure this job runs after others complete
124-
steps:
125-
- name: Get PR labels
126-
id: pr-labels
127-
uses: actions/github-script@v6
128-
if: github.event_name == 'pull_request'
129-
with:
130-
script: |
131-
const labels = context.payload.pull_request.labels
132-
.map(label => label.name)
133-
.filter(name => name.startsWith('tag:'))
134-
.map(name => name.split(':')[1]);
135-
if (labels.length > 0) {
136-
core.setOutput('tag', labels[0]);
137-
} else {
138-
core.setOutput('skip', 'true');
139-
}
140-
- name: Trigger dependencies bot in lit-configuration-guides
141-
if: steps.pr-labels.outputs.skip != 'true'
142-
run: |
143-
TAG="${{ steps.pr-labels.outputs.tag }}"
144-
curl -X POST \
145-
-H "Accept: application/vnd.github.everest-preview+json" \
146-
-H "Authorization: token ${{ secrets.GH_PAT_LIT_CONFIGURATION_GUIDES_REPO }}" \
147-
https://api.github.com/repos/LIT-Protocol/lit-configuration-guides/dispatches \
148-
-d "{\"event_type\":\"dependency_update\", \"client_payload\": {\"labels\": [\"$TAG\"]}}"
149-
env:
150-
GH_PAT_LIT_CONFIGURATION_GUIDES_REPO: ${{ secrets.GH_PAT_LIT_CONFIGURATION_GUIDES_REPO }}
113+
run: docker rmi ghcr.io/lit-protocol/shiva

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
/out-tsc
77
**/dist
88
**/out-tsc
9+
local-tests/**/*.js
910

1011
# dependencies
1112
node_modules
@@ -74,3 +75,6 @@ local-tests/build
7475
.env
7576

7677
packages/wrapped-keys-lit-actions/src/generated
78+
79+
digest
80+
generate-digest.ts

.vscode/settings.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,26 @@
66
"lit-node-client-nodejs",
77
"core",
88
],
9+
"workbench.colorCustomizations": {
10+
"activityBar.activeBackground": "#2f7c47",
11+
"activityBar.background": "#2f7c47",
12+
"activityBar.foreground": "#e7e7e7",
13+
"activityBar.inactiveForeground": "#e7e7e799",
14+
"activityBarBadge.background": "#422c74",
15+
"activityBarBadge.foreground": "#e7e7e7",
16+
"commandCenter.border": "#e7e7e799",
17+
"sash.hoverBorder": "#2f7c47",
18+
"statusBar.background": "#215732",
19+
"statusBar.foreground": "#e7e7e7",
20+
"statusBarItem.hoverBackground": "#2f7c47",
21+
"statusBarItem.remoteBackground": "#215732",
22+
"statusBarItem.remoteForeground": "#e7e7e7",
23+
"titleBar.activeBackground": "#215732",
24+
"titleBar.activeForeground": "#e7e7e7",
25+
"titleBar.inactiveBackground": "#21573299",
26+
"titleBar.inactiveForeground": "#e7e7e799"
27+
},
28+
"peacock.color": "#215732",
929
// "restoreTerminals.terminals": [
1030
// {
1131
// "splitTerminals": [

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
33
"useNx": true,
44
"useWorkspaces": true,
5-
"version": "7.0.4"
5+
"version": "8.0.0-alpha.0"
66
}

local-tests/build.mjs

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,67 @@
11
import * as esbuild from 'esbuild';
22
import { nodeExternalsPlugin } from 'esbuild-node-externals';
3-
import fs from 'fs';
3+
import { fileURLToPath } from 'url';
44

5-
const TEST_DIR = 'local-tests';
5+
const ALLOW_LIST = [
6+
'ethers',
7+
'@lit-protocol/accs-schemas',
8+
'@lit-protocol/contracts',
9+
'crypto',
10+
'secp256k1',
11+
'cross-fetch',
12+
];
13+
14+
const getPath = (relativePath) =>
15+
fileURLToPath(new URL(relativePath, import.meta.url));
616

717
/**
8-
* Builds the project using esbuild.
9-
* @returns {Promise<void>} A promise that resolves when the build is complete.
18+
* Common esbuild configuration options.
19+
* @param {string} entry - Entry file path.
20+
* @param {string} outfile - Output file path.
21+
* @param {string} [globalName] - Optional global name for the bundle.
22+
* @returns {esbuild.BuildOptions} Esbuild configuration object.
23+
*/
24+
const createBuildConfig = (entry, outfile, globalName) => ({
25+
entryPoints: [getPath(entry)],
26+
outfile: getPath(outfile),
27+
bundle: true,
28+
plugins: [
29+
nodeExternalsPlugin({
30+
allowList: ALLOW_LIST,
31+
}),
32+
],
33+
platform: 'node',
34+
target: 'esnext',
35+
format: 'esm',
36+
inject: [getPath('./shim.mjs')],
37+
mainFields: ['module', 'main'],
38+
...(globalName ? { globalName } : {}),
39+
});
40+
41+
/**
42+
* Builds the CLI-enabled version of Tinny.
1043
*/
1144
export const build = async () => {
12-
await esbuild.build({
13-
entryPoints: [`${TEST_DIR}/test.ts`],
14-
outfile: `./${TEST_DIR}/build/test.mjs`,
15-
bundle: true,
16-
plugins: [
17-
nodeExternalsPlugin({
18-
allowList: [
19-
'ethers',
20-
'@lit-protocol/accs-schemas',
21-
'@lit-protocol/contracts',
22-
'crypto',
23-
'secp256k1',
24-
],
25-
}),
26-
],
27-
platform: 'node',
28-
target: 'esnext',
29-
format: 'esm',
30-
inject: [`./${TEST_DIR}/shim.mjs`],
31-
mainFields: ['module', 'main'],
32-
});
45+
await esbuild.build(createBuildConfig('./test.ts', './build/test.mjs'));
3346
};
3447

3548
/**
36-
* Inserts a polyfill at the beginning of a file.
37-
* The polyfill ensures that the global `fetch` function is available.
38-
* @returns {void}
49+
* Bundles Tinny as a standalone package.
3950
*/
40-
export const postBuildPolyfill = () => {
41-
try {
42-
const file = fs.readFileSync(`./${TEST_DIR}/build/test.mjs`, 'utf8');
43-
const content = `import fetch from 'node-fetch';
44-
try {
45-
if (!globalThis.fetch) {
46-
globalThis.fetch = fetch;
47-
}
48-
} catch (error) {
49-
console.error('❌ Error in polyfill', error);
50-
}
51-
`;
52-
const newFile = content + file;
53-
fs.writeFileSync(`./${TEST_DIR}/build/test.mjs`, newFile);
54-
} catch (e) {
55-
throw new Error(`Error in postBuildPolyfill: ${e}`);
56-
}
51+
export const bundle = async () => {
52+
await esbuild.build(
53+
createBuildConfig('./index.ts', './index.js', 'tinnySdk')
54+
);
5755
};
5856

5957
// Go!
6058
(async () => {
6159
const start = Date.now();
62-
await build();
63-
postBuildPolyfill();
64-
console.log(`[build.mjs] 🚀 Build time: ${Date.now() - start}ms`);
60+
try {
61+
await build();
62+
await bundle();
63+
console.log(`[build.mjs] 🚀 Build time: ${Date.now() - start}ms`);
64+
} catch (error) {
65+
console.error(`[build.mjs] ❌ Build failed:`, error);
66+
}
6567
})();

local-tests/index.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { TinnyEnvironment } from './setup/tinny-environment';
2+
import { runInBand, runTestsParallel } from './setup/tinny-operations';
3+
import * as tinnyTests from './tests';
4+
import { getEoaAuthContext } from './setup/session-sigs/get-eoa-session-sigs';
5+
import { getLitActionAuthContext } from './setup/session-sigs/get-lit-action-session-sigs';
6+
import { getPkpAuthContext } from './setup/session-sigs/get-pkp-session-sigs';
7+
import { AccessControlConditions } from './setup/accs/accs';
8+
9+
export {
10+
TinnyEnvironment,
11+
runInBand,
12+
runTestsParallel,
13+
tinnyTests,
14+
getEoaAuthContext,
15+
getLitActionAuthContext,
16+
getPkpAuthContext,
17+
AccessControlConditions,
18+
};
19+
20+
// Usage
21+
// const devEnv = new TinnyEnvironment();
22+
23+
// await devEnv.init();
24+
25+
// const testConfig = {
26+
// tests: {
27+
// testEthAuthSigToEncryptDecryptString,
28+
// },
29+
// devEnv,
30+
// }
31+
32+
// const res = await runTestsParallel(testConfig);
33+
// console.log("res:", res);

local-tests/package.json

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"name": "@lit-protocol/tinny",
3+
"version": "0.0.15",
4+
"description": "A package to run the test script for Lit Protocol with custom commands",
5+
"type": "module",
6+
"main": "./index.js",
7+
"typings": "./index.ts",
8+
"license": "MIT",
9+
"author": "Anson (https://github.com/ansonhkg)",
10+
"publishConfig": {
11+
"access": "public",
12+
"directory": "./"
13+
},
14+
"dependencies": {
15+
"@cosmjs/amino": "0.30.1",
16+
"@cosmjs/crypto": "0.30.1",
17+
"@cosmjs/encoding": "0.30.1",
18+
"@cosmjs/proto-signing": "0.30.1",
19+
"@cosmjs/stargate": "0.30.1",
20+
"@cypress/code-coverage": "^3.10.0",
21+
"@cypress/react": "^6.2.0",
22+
"@cypress/webpack-dev-server": "^2.3.0",
23+
"@lit-protocol/accs-schemas": "0.0.7",
24+
"@metamask/eth-sig-util": "5.0.2",
25+
"@mysten/sui.js": "^0.37.1",
26+
"@playwright/test": "^1.25.2",
27+
"@simplewebauthn/browser": "^7.2.0",
28+
"@simplewebauthn/typescript-types": "^7.0.0",
29+
"@spruceid/siwe-parser": "2.0.0",
30+
"@synthetixio/js": "^2.41.0",
31+
"@testing-library/cypress": "^8.0.3",
32+
"@testing-library/react": "^13.4.0",
33+
"@types/testing-library__cypress": "^5.0.9",
34+
"@walletconnect/core": "2.9.2",
35+
"@walletconnect/ethereum-provider": "2.9.2",
36+
"@walletconnect/jsonrpc-utils": "1.0.8",
37+
"@walletconnect/modal": "2.6.1",
38+
"@walletconnect/types": "2.9.2",
39+
"@walletconnect/utils": "2.9.2",
40+
"@walletconnect/web3wallet": "1.8.8",
41+
"@websaam/nx-esbuild": "^0.0.1",
42+
"ajv": "^8.12.0",
43+
"axios": "^0.27.2",
44+
"base64url": "^3.0.1",
45+
"bitcoinjs-lib": "^6.1.0",
46+
"blockstore-core": "^3.0.0",
47+
"browserify-zlib": "^0.2.0",
48+
"bs58": "^5.0.0",
49+
"bytes32": "^0.0.3",
50+
"cbor-web": "^9.0.1",
51+
"commander": "^9.4.0",
52+
"concurrently": "^7.4.0",
53+
"core-js": "^3.6.5",
54+
"cross-fetch": "3.1.4",
55+
"crypto-browserify": "^3.12.0",
56+
"cypress-wait-until": "^1.7.2",
57+
"cypress-watch-and-reload": "^1.10.3",
58+
"date-and-time": "^2.4.1",
59+
"dotenv": "^16.0.2",
60+
"dotenv-parse-variables": "^2.0.0",
61+
"download": "^8.0.0",
62+
"ethers": "^5.7.1",
63+
"etherscan-api": "^10.2.0",
64+
"find-config": "^1.0.0",
65+
"g": "^2.0.1",
66+
"https-browserify": "^1.0.0",
67+
"jose": "^4.14.4",
68+
"jszip": "^3.10.1",
69+
"micromodal": "^0.4.10",
70+
"multiformats": "^9.7.1",
71+
"nanoid": "3.3.4",
72+
"next": "13.3.0",
73+
"react": "18.0.0",
74+
"react-dom": "18.0.0",
75+
"regenerator-runtime": "0.13.7",
76+
"secp256k1": "^5.0.0",
77+
"serve": "^14.0.1",
78+
"siwe": "^2.0.5",
79+
"siwe-recap": "0.0.2-alpha.0",
80+
"stream-browserify": "^3.0.0",
81+
"stream-http": "^3.2.0",
82+
"synthetix-js": "^2.74.1",
83+
"tslib": "^2.3.0",
84+
"tweetnacl": "^1.0.3",
85+
"tweetnacl-util": "^0.15.1",
86+
"uint8arrays": "^4.0.3",
87+
"@openagenda/verror": "^3.1.4",
88+
"ipfs-unixfs-importer": "12.0.1",
89+
"@solana/web3.js": "^1.95.3",
90+
"bech32": "^2.0.0",
91+
"pako": "^2.1.0",
92+
"@lit-protocol/misc": "^7.0.0",
93+
"@lit-protocol/lit-node-client": "^7.0.0",
94+
"@lit-protocol/lit-auth-client": "^7.0.0",
95+
"@lit-protocol/contracts": "^0.0.71"
96+
}
97+
}

0 commit comments

Comments
 (0)