Skip to content

Commit 2ee91bf

Browse files
committed
feat(wrapped-keys-la): update lit action CIDs and improve constants file generation
1 parent d770f8b commit 2ee91bf

File tree

2 files changed

+63
-15
lines changed

2 files changed

+63
-15
lines changed

packages/wrapped-keys-lit-actions/sync-actions-to-ipfs.js

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const fs = require('fs');
12
const path = require('path');
23
const axios = require('axios');
34
const FormData = require('form-data');
@@ -34,12 +35,55 @@ const {
3435
litActionRepositoryCommon,
3536
} = loadLitActionExports();
3637

38+
function renderLitActionRepository(repo) {
39+
const actionEntries = Object.entries(repo).map(
40+
([actionName, networks]) => {
41+
const networkEntries = Object.entries(networks)
42+
.map(([networkName, cid]) => ` ${networkName}: '${cid}',`)
43+
.join('\n');
44+
45+
return ` ${actionName}: Object.freeze({\n${networkEntries}\n }),`;
46+
}
47+
);
48+
49+
return `Object.freeze({\n${actionEntries.join('\n')}\n});`;
50+
}
51+
52+
function renderLitActionRepositoryCommon(repo) {
53+
const commonEntries = Object.entries(repo)
54+
.map(([actionName, cid]) => ` ${actionName}: '${cid}'`)
55+
.join(',\n');
56+
57+
return `Object.freeze({\n${commonEntries}\n});`;
58+
}
59+
60+
function updateConstantsFile(cidRepo, cidRepoCommon) {
61+
const constantsFilePath = path.resolve(
62+
__dirname,
63+
'../wrapped-keys/src/lib/lit-actions-client/constants.ts'
64+
);
65+
66+
const fileContents = `import { LitCidRepository, LitCidRepositoryCommon } from './types';
67+
68+
const LIT_ACTION_CID_REPOSITORY: LitCidRepository = ${renderLitActionRepository(
69+
cidRepo
70+
)};
71+
72+
const LIT_ACTION_CID_REPOSITORY_COMMON: LitCidRepositoryCommon = ${renderLitActionRepositoryCommon(
73+
cidRepoCommon
74+
)};
75+
76+
export { LIT_ACTION_CID_REPOSITORY, LIT_ACTION_CID_REPOSITORY_COMMON };
77+
`;
78+
79+
fs.writeFileSync(constantsFilePath, fileContents);
80+
}
81+
3782
/** Usage:
3883
* 1. Ensure you have a valid Pinata IPFS JWT in `LIT_IPFS_JWT` env var
39-
* 2. Make sure you run `yarn build` to ensure that all LIT actions code has been built into the generated directory from the current commit
40-
* 3. `node sync-actions-to-ipfs` -> this will print out JSON of the `LIT_ACTION_CID_REPOSITORY` and LIT_ACTION_CID_REPOSITORY_COMMON
41-
* 4. Copy/paste the CIDs into those objects in `packages/wrapped-keys/src/lib/lit-actions-client/constants.ts`
42-
* 5. Commit the changes and push them to your branch
84+
* 2. Make sure you run the library build (`pnpm nx build wrapped-keys-lit-actions`) so the generated actions are up to date
85+
* 3. `node sync-actions-to-ipfs` -> this will pin the latest lit actions, update `packages/wrapped-keys/src/lib/lit-actions-client/constants.ts`, and print the CID JSON for verification
86+
* 4. Review the diff in `constants.ts` and commit the changes
4387
*/
4488

4589
const JWT = process.env.LIT_IPFS_JWT || '';
@@ -123,6 +167,10 @@ async function gogo() {
123167
getCidRepository(litActionRepository),
124168
]);
125169

170+
updateConstantsFile(cidRepo, cidRepoCommon);
171+
console.log(
172+
'Updated constants file at packages/wrapped-keys/src/lib/lit-actions-client/constants.ts'
173+
);
126174
console.log('common', cidRepoCommon);
127175
console.log('byNetwork', cidRepo);
128176
}

packages/wrapped-keys/src/lib/lit-actions-client/constants.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@ import { LitCidRepository, LitCidRepositoryCommon } from './types';
22

33
const LIT_ACTION_CID_REPOSITORY: LitCidRepository = Object.freeze({
44
signTransaction: Object.freeze({
5-
evm: 'QmRpAgGKEmgeBRhqdC2EH17QUt6puwsbm8Z2nNneVN4uJG',
6-
solana: 'QmR1nPG2tnmC72zuCEMZUZrrMEkbDiMPNHW45Dsm2n7xnk',
5+
evm: 'QmdSQqkdGF5EqPCBi4pidkjGQXLNoP5kp8gxGLtgzyiw7L',
6+
solana: 'QmVeR4rKuyN27gq1JrsoJqjN2GrwZD87Sm2vHzV5MmBxwb',
77
}),
88
signMessage: Object.freeze({
9-
evm: 'QmXi9iqJvXrHoUGSo5WREonrruDhzQ7cFr7Cry3wX2hmue',
10-
solana: 'QmcEJGVqRYtVukjm2prCPT7Fs66GpaqZwmZoxEHMHor6Jz',
9+
evm: 'QmQWwWjJXLiCKi7ZpfwXnGPeXAcjfG1VXjB6CLTb3Xh31X',
10+
solana: 'QmawpLLPxL6GVKj7QW3PR8us4gNyVEijPpcDzD8Uo95jXR',
1111
}),
1212
generateEncryptedKey: Object.freeze({
13-
evm: 'QmeD6NYCWhUCLgxgpkgSguaKjwnpCnJ6Yf8SdsyPpK4eKK',
14-
solana: 'QmPkVD3hEjMi1T5zQuvdrFCXaGTEMHNdAhAL4WHkqxijrQ',
13+
evm: 'QmSKi3kMRP7biW6HhNf79vcffMSXDSu7Yr1K653ZoGXsxw',
14+
solana: 'QmZGd5gPcqTJmeM9Thdguz6DufFkQCa9Qq2oS6L3D6HD8o',
1515
}),
1616
exportPrivateKey: Object.freeze({
17-
evm: 'QmUJ74pTUqeeHzDGdfwCph1vJVNJ1rRzJdvMiTjS1BMwYj',
18-
solana: 'QmUJ74pTUqeeHzDGdfwCph1vJVNJ1rRzJdvMiTjS1BMwYj',
17+
evm: 'QmaCGGq6EqXezgBiwAAbwh2UTeeTZnLaHQxxDcXwRboFXM',
18+
solana: 'QmaCGGq6EqXezgBiwAAbwh2UTeeTZnLaHQxxDcXwRboFXM',
1919
}),
20-
});
20+
});;
2121

2222
const LIT_ACTION_CID_REPOSITORY_COMMON: LitCidRepositoryCommon = Object.freeze({
23-
batchGenerateEncryptedKeys: 'QmR8Zs7ctSEctxBrSnAYhMXFXCC1ub8K1xvMn5Js3NCSAA',
24-
});
23+
batchGenerateEncryptedKeys: 'QmUDB7jZfCMwh9CuQZZ4YDmrJnNdPq9NGdqHzmQE3RggSr'
24+
});;
2525

2626
export { LIT_ACTION_CID_REPOSITORY, LIT_ACTION_CID_REPOSITORY_COMMON };

0 commit comments

Comments
 (0)