Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nxignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages/wrapped-keys/update-ipfs-cids.js
4 changes: 4 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
}
},
"targetDefaults": {
"prebuild": {
"dependsOn": ["^prebuild"],
"inputs": ["production", "^production"]
},
"build": {
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "6.9.0",
"inquirer": "^9.2.21",
"ipfs-only-hash": "^4.0.0",
"ipfs-unixfs-importer": "12.0.1",
"jest": "27.5.1",
"lerna": "^5.4.3",
Expand Down
4 changes: 3 additions & 1 deletion packages/wrapped-keys-lit-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"genReact": false
},
"scripts": {
"generate-lit-actions": "yarn node ./esbuild.config.js"
"prepublishOnly": "yarn generate-lit-actions && yarn publish-lit-actions",
"generate-lit-actions": "yarn node ./esbuild.config.js",
"publish-lit-actions": "yarn node ./sync-actions-to-ipfs"
},
"version": "7.1.0",
"main": "./dist/src/index.js",
Expand Down
8 changes: 4 additions & 4 deletions packages/wrapped-keys-lit-actions/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"sourceRoot": "packages/wrapped-keys-lit-actions/src",
"projectType": "library",
"targets": {
"build-la": {
"cache": false,
"prebuild": {
"executor": "nx:run-commands",
"options": {
"commands": [
"yarn --cwd ./packages/wrapped-keys-lit-actions generate-lit-actions"
],
"cwd": "."
}
},
"dependsOn": []
},
"build": {
"cache": false,
Expand All @@ -32,7 +32,7 @@
],
"updateBuildableProjectDepsInPackageJson": true
},
"dependsOn": ["build-la", "^build"]
"dependsOn": ["wrapped-keys:build"]
},
"lint": {
"executor": "@nx/linter:eslint",
Expand Down
4 changes: 4 additions & 0 deletions packages/wrapped-keys/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"buildOptions": {
"genReact": false
},
"scripts": {
"prepare": "yarn update-ipfs-cids",
"update-ipfs-cids": "yarn node ./update-ipfs-cids.js"
},
"version": "7.1.0",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
Expand Down
11 changes: 10 additions & 1 deletion packages/wrapped-keys/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
"sourceRoot": "packages/wrapped-keys/src",
"projectType": "library",
"targets": {
"prebuild": {
"executor": "nx:run-commands",
"options": {
"commands": ["yarn --cwd ./packages/wrapped-keys update-ipfs-cids"],
"cwd": "."
},
"dependsOn": ["wrapped-keys-lit-actions:prebuild"]
},
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
Expand All @@ -13,7 +21,8 @@
"tsConfig": "packages/wrapped-keys/tsconfig.lib.json",
"assets": ["packages/wrapped-keys/*.md"],
"updateBuildableProjectDepsInPackageJson": true
}
},
"dependsOn": ["prebuild", "^build"]
},
"lint": {
"executor": "@nx/linter:eslint",
Expand Down
49 changes: 31 additions & 18 deletions packages/wrapped-keys/src/lib/lit-actions-client/constants.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
import * as GENERATED_LIT_ACTION_CID_REPOSITORY_COMMON from './lit-action-cid-repository-common.json';
import * as GENERATED_LIT_ACTION_CID_REPOSITORY from './lit-action-cid-repository.json';
import { LitCidRepository, LitCidRepositoryCommon } from './types';

const LIT_ACTION_CID_REPOSITORY: LitCidRepository = Object.freeze({
signTransaction: Object.freeze({
evm: 'QmRpAgGKEmgeBRhqdC2EH17QUt6puwsbm8Z2nNneVN4uJG',
solana: 'QmR1nPG2tnmC72zuCEMZUZrrMEkbDiMPNHW45Dsm2n7xnk',
}),
signMessage: Object.freeze({
evm: 'QmXi9iqJvXrHoUGSo5WREonrruDhzQ7cFr7Cry3wX2hmue',
solana: 'QmcEJGVqRYtVukjm2prCPT7Fs66GpaqZwmZoxEHMHor6Jz',
}),
generateEncryptedKey: Object.freeze({
evm: 'QmeD6NYCWhUCLgxgpkgSguaKjwnpCnJ6Yf8SdsyPpK4eKK',
solana: 'QmPkVD3hEjMi1T5zQuvdrFCXaGTEMHNdAhAL4WHkqxijrQ',
}),
exportPrivateKey: Object.freeze({
evm: 'QmUJ74pTUqeeHzDGdfwCph1vJVNJ1rRzJdvMiTjS1BMwYj',
solana: 'QmUJ74pTUqeeHzDGdfwCph1vJVNJ1rRzJdvMiTjS1BMwYj',
}),
function deepFreeze<T extends Record<string, any>>(obj: T): T {
Object.freeze(obj);
for (const key in obj) {
if (key in obj && typeof obj[key] === 'object') {
deepFreeze(obj[key]);
}
}
return obj;
}

const LIT_ACTION_CID_REPOSITORY: LitCidRepository = deepFreeze({
signTransaction: {
evm: GENERATED_LIT_ACTION_CID_REPOSITORY.signTransaction.evm,
solana: GENERATED_LIT_ACTION_CID_REPOSITORY.signTransaction.solana,
},
signMessage: {
evm: GENERATED_LIT_ACTION_CID_REPOSITORY.signMessage.evm,
solana: GENERATED_LIT_ACTION_CID_REPOSITORY.signMessage.solana,
},
generateEncryptedKey: {
evm: GENERATED_LIT_ACTION_CID_REPOSITORY.generateEncryptedKey.evm,
solana: GENERATED_LIT_ACTION_CID_REPOSITORY.generateEncryptedKey.solana,
},
exportPrivateKey: {
evm: GENERATED_LIT_ACTION_CID_REPOSITORY.exportPrivateKey.evm,
solana: GENERATED_LIT_ACTION_CID_REPOSITORY.exportPrivateKey.solana,
},
});

const LIT_ACTION_CID_REPOSITORY_COMMON: LitCidRepositoryCommon = Object.freeze({
batchGenerateEncryptedKeys: 'QmR8Zs7ctSEctxBrSnAYhMXFXCC1ub8K1xvMn5Js3NCSAA',
batchGenerateEncryptedKeys:
GENERATED_LIT_ACTION_CID_REPOSITORY_COMMON.batchGenerateEncryptedKeys,
});

export { LIT_ACTION_CID_REPOSITORY, LIT_ACTION_CID_REPOSITORY_COMMON };
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"batchGenerateEncryptedKeys": "QmQB1uSKwuzUWHiAgaGtTf3rFZf42AJWN1XKJSNNPuxKhB"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"signTransaction": {
"evm": "QmYTEJyniRRkTxe3D9mmkURXCFBAXWK7TEGk5LxvWSETWn",
"solana": "QmWUozjthkrjEBGkkEvGTvCaxCaiPMTke6FUpiwhn28k8Z"
},
"signMessage": {
"evm": "Qmdm4mGn6A8RmqeiDgRPXFt2yYEKCUMUVimSb5iPJfs31e",
"solana": "QmS4Y6f2zHriNzioxBbysbuXQbjX7ga468CCyYcuY2AeeH"
},
"generateEncryptedKey": {
"evm": "QmfW6g5PJ8SVS56XwDVC5W4gcUnobEempNkR28bj2g99tk",
"solana": "QmWYcBCZqFmJJzsRfzVRHbPD5Hvuou45sbXPQcQzLbUgKd"
},
"exportPrivateKey": {
"evm": "QmfZ8hYEmNFwHraNieSz25dAp65YBoNjAMC2tXm9oaQCt6",
"solana": "QmfZ8hYEmNFwHraNieSz25dAp65YBoNjAMC2tXm9oaQCt6"
}
}
3 changes: 2 additions & 1 deletion packages/wrapped-keys/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true
},
"files": [],
"include": [],
Expand Down
77 changes: 77 additions & 0 deletions packages/wrapped-keys/update-ipfs-cids.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
const fs = require('fs');
const path = require('path');

const Hash = require('ipfs-only-hash');

const {
code: batchGenerateEncryptedKey,
} = require('../wrapped-keys-lit-actions/src/generated/common/batchGenerateEncryptedKeys');
const {
code: exportPrivateKey,
} = require('../wrapped-keys-lit-actions/src/generated/common/exportPrivateKey');
const {
code: generateEncryptedEthereumPrivateKey,
} = require('../wrapped-keys-lit-actions/src/generated/ethereum/generateEncryptedEthereumPrivateKey');
const {
code: signMessageWithEncryptedEthereumKey,
} = require('../wrapped-keys-lit-actions/src/generated/ethereum/signMessageWithEncryptedEthereumKey');
const {
code: signTransactionWithEncryptedEthereumKey,
} = require('../wrapped-keys-lit-actions/src/generated/ethereum/signTransactionWithEncryptedEthereumKey');
const {
code: generateEncryptedSolanaPrivateKey,
} = require('../wrapped-keys-lit-actions/src/generated/solana/generateEncryptedSolanaPrivateKey');
const {
code: signMessageWithEncryptedSolanaKey,
} = require('../wrapped-keys-lit-actions/src/generated/solana/signMessageWithEncryptedSolanaKey');
const {
code: signTransactionWithEncryptedSolanaKey,
} = require('../wrapped-keys-lit-actions/src/generated/solana/signTransactionWithEncryptedSolanaKey');

async function updateConstants() {
// Generate new CID hashes
const litActionCIDRepository = {
signTransaction: {
evm: await Hash.of(signTransactionWithEncryptedEthereumKey),
solana: await Hash.of(signTransactionWithEncryptedSolanaKey),
},
signMessage: {
evm: await Hash.of(signMessageWithEncryptedEthereumKey),
solana: await Hash.of(signMessageWithEncryptedSolanaKey),
},
generateEncryptedKey: {
evm: await Hash.of(generateEncryptedEthereumPrivateKey),
solana: await Hash.of(generateEncryptedSolanaPrivateKey),
},
exportPrivateKey: {
evm: await Hash.of(exportPrivateKey),
solana: await Hash.of(exportPrivateKey),
},
};
const litActionCIDRepositoryCommon = {
batchGenerateEncryptedKeys: await Hash.of(batchGenerateEncryptedKey),
};

// Write constant json files with lit action hashes
// Extra \n is for prettier rule
fs.writeFileSync(
path.join(
__dirname,
'./src/lib/lit-actions-client/lit-action-cid-repository.json'
),
JSON.stringify(litActionCIDRepository, null, 2) + '\n',
'utf-8'
);
fs.writeFileSync(
path.join(
__dirname,
'./src/lib/lit-actions-client/lit-action-cid-repository-common.json'
),
JSON.stringify(litActionCIDRepositoryCommon, null, 2) + '\n',
'utf-8'
);
}

updateConstants().then(() => {
console.log('Constants file updated successfully!');
});
3 changes: 1 addition & 2 deletions tools/scripts/pub.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
redLog,
question,
writeJsonFile,
yellowLog,
} from './utils.mjs';

const args = getArgs();
Expand Down Expand Up @@ -178,7 +177,7 @@ await question('Are you sure you want to publish to? (y/n)', {
});

while (true) {
// wait for 1 second
// wait a few secs to check again if all packages are published
await new Promise((resolve) => setTimeout(resolve, 2000));
if (counter >= dirs.length) {
greenLog('🎉 Publish complete!', true);
Expand Down
2 changes: 1 addition & 1 deletion tools/scripts/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export const spawnCommand = (
if (options2.logExit) {
console.log(`child process exited with code ${code}`);
}
options2.exitCallback(code);
options2.exitCallback?.(code);
});
};

Expand Down
Loading