Skip to content

Commit

Permalink
Merge pull request #699 from LIT-Protocol/feat/convert-wrapped-keys-l…
Browse files Browse the repository at this point in the history
…it-actions-to-ts

feat: add types and convert lit actions to typescripts
  • Loading branch information
Ansonhkg authored Oct 23, 2024
2 parents c2cfb89 + 73c25e2 commit 1e074af
Show file tree
Hide file tree
Showing 47 changed files with 1,126 additions and 482 deletions.
62 changes: 41 additions & 21 deletions packages/wrapped-keys-lit-actions/esbuild.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const wrapIIFEInStringPlugin = {

result.outputFiles.forEach((outputFile) => {
let content = outputFile.text;

// Use JSON.stringify to safely encode the content
const wrappedContent = `/**
* DO NOT EDIT THIS FILE. IT IS GENERATED ON BUILD. RUN \`yarn generate-lit-actions\` IN THE ROOT DIRECTORY TO UPDATE THIS FILE.
Expand All @@ -48,24 +47,45 @@ module.exports = {
};

(async () => {
await esbuild.build({
entryPoints: [
'./src/lib/self-executing-actions/solana/signTransactionWithEncryptedSolanaKey.js',
'./src/lib/self-executing-actions/solana/signMessageWithEncryptedSolanaKey.js',
'./src/lib/self-executing-actions/solana/generateEncryptedSolanaPrivateKey.js',
'./src/lib/self-executing-actions/ethereum/signTransactionWithEncryptedEthereumKey.js',
'./src/lib/self-executing-actions/ethereum/signMessageWithEncryptedEthereumKey.js',
'./src/lib/self-executing-actions/ethereum/generateEncryptedEthereumPrivateKey.js',
'./src/lib/self-executing-actions/common/exportPrivateKey.js',
'./src/lib/self-executing-actions/common/batchGenerateEncryptedKeys.js',
],
bundle: true,
minify: true,
sourcemap: false,
treeShaking: true,
outdir: './src/generated/',
inject: ['./buffer.shim.js'],
plugins: [wrapIIFEInStringPlugin],
platform: 'browser',
});
try {
await esbuild
.build({
entryPoints: [
'./src/lib/self-executing-actions/solana/signTransactionWithEncryptedSolanaKey.ts',
'./src/lib/self-executing-actions/solana/signMessageWithEncryptedSolanaKey.ts',
'./src/lib/self-executing-actions/solana/generateEncryptedSolanaPrivateKey.ts',
'./src/lib/self-executing-actions/ethereum/signTransactionWithEncryptedEthereumKey.ts',
'./src/lib/self-executing-actions/ethereum/signMessageWithEncryptedEthereumKey.ts',
'./src/lib/self-executing-actions/ethereum/generateEncryptedEthereumPrivateKey.ts',
'./src/lib/self-executing-actions/common/exportPrivateKey.ts',
'./src/lib/self-executing-actions/common/batchGenerateEncryptedKeys.ts',
],
bundle: true,
minify: true,
sourcemap: false,
treeShaking: true,
outdir: './src/generated/',
inject: ['./buffer.shim.js'],
external: ['ethers'],
plugins: [wrapIIFEInStringPlugin],
platform: 'browser',
})
.then((result) => {
result.outputFiles.forEach((file) => {
const bytes = file.text.length;
const mbInBinary = (bytes / (1024 * 1024)).toFixed(4);
const mbInDecimal = (bytes / 1_000_000).toFixed(4);

console.log(
`✅ ${file.path
.split('/')
.pop()}\n- ${mbInDecimal} MB (in decimal)\n- ${mbInBinary} MB (in binary)`
);
});
});
console.log('✅ Lit actions built successfully');
} catch (e) {
console.error('❌ Error building lit actions: ', e);
process.exit(1);
}
})();
Loading

0 comments on commit 1e074af

Please sign in to comment.