Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
feat: move IC canisters and providers to Papyrs (#1513)
Browse files Browse the repository at this point in the history
* 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
peterpeterparker authored Mar 20, 2022
1 parent 245f9c5 commit f64b1f5
Show file tree
Hide file tree
Showing 87 changed files with 77 additions and 6,353 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ config.prod.json
storybook-static/

webcomponents/monaco-editor/workers

canisters/canisters
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
### Providers

- firebase: v4.1.3 ([CHANGELOG](https://github.com/deckgo/deckdeckgo/blob/main/providers/firebase/CHANGELOG.md))
- ic: v7.1.0 ([CHANGELOG](https://github.com/deckgo/deckdeckgo/blob/main/providers/ic/CHANGELOG.md))

### Providers: Deprecated and integrated into `papyrs`

- ic

### Web Components: New

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ If you like the project, you can become a sponsor at [Open Collective](https://o
| **AWS (Backend)** | ![version](https://img.shields.io/static/v1.svg?label=production&message=v2.0.0&color=success) | [`README`](backend/README.md) | [`CHANGELOG`](backend/CHANGELOG.md) |
| **AWS (Infra)** | ![version](https://img.shields.io/static/v1.svg?label=production&message=up&color=success) | [`README`](infra/README.md) | |
| **Firebase (Cloud)** | ![version](https://img.shields.io/static/v1.svg?label=production&message=v2.2.1&color=success) | [`README`](cloud/README.md) | [`CHANGELOG`](cloud/CHANGELOG.md) |
| **Internet Computer** | ![version](https://img.shields.io/static/v1.svg?label=alpha&message=up&color=blueviolet) | [`README`](canisters/README.md) | [`CHANGELOG`](canisters/CHANGELOG.md) |

## Providers

Expand Down
5 changes: 0 additions & 5 deletions canisters/CHANGELOG.md

This file was deleted.

2 changes: 1 addition & 1 deletion canisters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# DeckDeckGo - Canisters

The canisters on the Internet Computer of [DeckDeckGo].
Deploy script and environment variables of the (backend) canisters on the Internet Computer of [DeckDeckGo].

## License

Expand Down
73 changes: 2 additions & 71 deletions canisters/scripts/ic.types.js
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/'});
32 changes: 0 additions & 32 deletions canisters/src/data/data.filter.mo

This file was deleted.

93 changes: 0 additions & 93 deletions canisters/src/data/data.mo

This file was deleted.

69 changes: 0 additions & 69 deletions canisters/src/data/data.store.mo

This file was deleted.

16 changes: 0 additions & 16 deletions canisters/src/data/data.types.mo

This file was deleted.

Loading

0 comments on commit f64b1f5

Please sign in to comment.