This repository has been archived by the owner on Feb 6, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move IC canisters and providers to Papyrs (#1513)
* refactor: move canisters to papyrs Signed-off-by: peterpeterparker <[email protected]> * feat: deploy script Signed-off-by: peterpeterparker <[email protected]> * feat: use papyrs ic providers Signed-off-by: peterpeterparker <[email protected]> * feat: types move to papyrs Signed-off-by: peterpeterparker <[email protected]> * refactor: move ic providers to papyrs Signed-off-by: peterpeterparker <[email protected]> * docs: ic moved to papyrs Signed-off-by: peterpeterparker <[email protected]>
- Loading branch information
1 parent
245f9c5
commit f64b1f5
Showing
87 changed files
with
77 additions
and
6,353 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,3 +50,5 @@ config.prod.json | |
storybook-static/ | ||
|
||
webcomponents/monaco-editor/workers | ||
|
||
canisters/canisters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,10 @@ | ||
#!/usr/bin/env node | ||
|
||
const prettier = require('prettier'); | ||
|
||
const {join, extname, basename} = require('path'); | ||
const {existsSync, readdirSync, writeFileSync, lstatSync, copyFileSync, readFileSync} = require('fs'); | ||
|
||
const copyTypes = async ({src, dest = `./providers/ic/src/canisters`}) => { | ||
const promises = readdirSync(src) | ||
.filter((subFolder) => !['assets', 'idl'].includes(subFolder)) | ||
.map( | ||
(dirent) => | ||
new Promise(async (resolve) => { | ||
const [srcPath, destPath] = [src, dest].map((dirPath) => join(dirPath, dirent)); | ||
|
||
const stat = lstatSync(srcPath); | ||
|
||
if (stat.isDirectory()) { | ||
await copyTypes({src: srcPath, dest: destPath}); | ||
} else if (stat.isFile()) { | ||
await copyFile({srcPath, destPath}); | ||
} | ||
|
||
resolve(); | ||
}) | ||
); | ||
|
||
await Promise.all(promises); | ||
}; | ||
|
||
const copyFile = async ({srcPath, destPath}) => { | ||
if (extname(srcPath) === '.wasm') { | ||
return; | ||
} | ||
|
||
if (basename(srcPath) === 'index.js') { | ||
return; | ||
} | ||
|
||
if (basename(srcPath).indexOf('.old.') > -1) { | ||
return; | ||
} | ||
|
||
if (['.did', '.most'].includes(extname(srcPath))) { | ||
copyFileSync(srcPath, destPath); | ||
return; | ||
} | ||
|
||
if (extname(srcPath) === '.mjs') { | ||
return; | ||
} | ||
|
||
const buffer = readFileSync(srcPath); | ||
const config = await prettier.resolveConfig('./prettierrc'); | ||
const output = prettier.format(buffer.toString('utf-8'), {parser: 'babel', ...config}); | ||
|
||
writeFileSync(destPath.replace('.did.js', '.utils.did.js'), output); | ||
}; | ||
const {writeFileSync, readFileSync} = require('fs'); | ||
|
||
const copyAdminManagerMjs = ({src}) => { | ||
const buffer = readFileSync(`${src}manager/manager.did.js`); | ||
writeFileSync(`${src}manager/manager.did.mjs`, buffer.toString('utf-8')); | ||
}; | ||
|
||
(async () => { | ||
try { | ||
if (existsSync('.dfx/local/canisters/')) { | ||
await copyTypes({src: `.dfx/local/canisters/`}); | ||
} else if (existsSync('.dfx/ic/canisters/')) { | ||
await copyTypes({src: `.dfx/ic/canisters/`}); | ||
} | ||
|
||
copyAdminManagerMjs({src: '.dfx/local/canisters/'}); | ||
|
||
console.log(`Internet Computer types declarations generated!`); | ||
} catch (err) { | ||
console.error(`Error while generating the types for the Internet Computer.`, err); | ||
} | ||
})(); | ||
copyAdminManagerMjs({src: '.dfx/local/canisters/'}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.