Skip to content

Commit

Permalink
feat(rootstock): add rootstock community module
Browse files Browse the repository at this point in the history
  • Loading branch information
jsamol committed Jul 27, 2023
1 parent fa55e46 commit 0d531db
Show file tree
Hide file tree
Showing 3 changed files with 273 additions and 230 deletions.
123 changes: 80 additions & 43 deletions copy-builtin-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,59 @@ const browserify = require('browserify')

const rootdir = './'
const assetsdir = path.join(rootdir, 'src/assets')
const modules = [
{ path: path.join(rootdir, 'node_modules/@airgap/aeternity') },
{
path: path.join(rootdir, 'node_modules/@airgap/astar'),
jsenv: {
android: 'webview'
}
},
{ path: path.join(rootdir, 'node_modules/@airgap/bitcoin') },
{ path: path.join(rootdir, 'node_modules/@airgap/cosmos') },
{
path: path.join(rootdir, 'node_modules/@airgap/ethereum'),
jsenv: {
android: 'webview'
}
},
{ path: path.join(rootdir, 'node_modules/@airgap/groestlcoin') },
{
path: path.join(rootdir, 'node_modules/@airgap/icp'),
jsenv: {
android: 'webview'
}
},
{
path: path.join(rootdir, 'node_modules/@airgap/moonbeam'),
jsenv: {
android: 'webview'
}
},
{
path: path.join(rootdir, 'node_modules/@airgap/polkadot'),
jsenv: {
android: 'webview'
}
},
{
path: path.join(rootdir, 'node_modules/@airgap/tezos'),
jsenv: {
android: 'webview'
}
}
const airgapModules = [
// { path: path.join(rootdir, 'node_modules/@airgap/aeternity') },
// {
// path: path.join(rootdir, 'node_modules/@airgap/astar'),
// jsenv: {
// android: 'webview'
// }
// },
// { path: path.join(rootdir, 'node_modules/@airgap/bitcoin') },
// { path: path.join(rootdir, 'node_modules/@airgap/cosmos') },
// {
// path: path.join(rootdir, 'node_modules/@airgap/ethereum'),
// jsenv: {
// android: 'webview'
// }
// },
// { path: path.join(rootdir, 'node_modules/@airgap/groestlcoin') },
// {
// path: path.join(rootdir, 'node_modules/@airgap/icp'),
// jsenv: {
// android: 'webview'
// }
// },
// {
// path: path.join(rootdir, 'node_modules/@airgap/moonbeam'),
// jsenv: {
// android: 'webview'
// }
// },
// {
// path: path.join(rootdir, 'node_modules/@airgap/optimism'),
// jsenv: {
// android: 'webview'
// }
// },
// {
// path: path.join(rootdir, 'node_modules/@airgap/polkadot'),
// jsenv: {
// android: 'webview'
// }
// },
// {
// path: path.join(rootdir, 'node_modules/@airgap/tezos'),
// jsenv: {
// android: 'webview'
// }
// }
]
const communityModules = [
{ path: path.join(rootdir, 'node_modules/@airgap-community/iso-rootstock') }
]

function createAssetModule(module) {
function createAirGapModule(module) {
const packageJson = require(`./${path.join(module.path, 'package.json')}`)
const namespace = module.path.split('/').slice(-1)[0]
const outputDir = path.join(assetsdir, `protocol_modules/${namespace}`)
Expand Down Expand Up @@ -79,4 +88,32 @@ function createAssetModule(module) {
fs.writeFileSync(path.join(outputDir, 'manifest.json'), JSON.stringify(manifest, null, 2), 'utf8')
}

modules.forEach((path) => createAssetModule(path))
function copyCommunityModule(module) {
const namespace = module.path.split('/').slice(-1)[0]
const outputDir = path.join(assetsdir, `protocol_modules/${namespace}`)

fs.mkdirSync(outputDir, { recursive: true })

const manifestPath = path.join(module.path, 'manifest.json')
const manifest = require(`./${manifestPath}`)
manifest.include.forEach((file) => {
fs.copyFileSync(path.join(module.path, file), path.join(outputDir, file))
})

fs.copyFileSync(manifestPath, path.join(outputDir, 'manifest.json'))
fs.copyFileSync(path.join(module.path, 'module.sig'), path.join(outputDir, 'module.sig'))

Object.entries(manifest.res?.symbol ?? {}).forEach(([key, value]) => {
// TODO: improve robustness of the solution
if (!value.startsWith('file://')) {
return
}

const symbolPath = value.slice(7)
const symbolExtension = symbolPath.split('.').slice(-1)
fs.copyFileSync(path.join(module.path, symbolPath), path.join(rootdir, 'node_modules/@airgap/angular-core/src/assets/symbols', `${key}.${symbolExtension}`))
})
}

airgapModules.forEach((module) => createAirGapModule(module))
communityModules.forEach((module) => copyCommunityModule(module))
75 changes: 38 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"lint-ci": "ng lint app --format json > ./lintReport.json || true",
"lint-fix": "tslint --fix --project tsconfig.json",
"e2e": "ng e2e",
"postinstall": "jetifier && node apply-diagnostic-modules.js && node patch-dependency-versions.js && node fix-qrscanner-gradle.js",
"postinstall": "jetifier && node apply-diagnostic-modules.js && node patch-dependency-versions.js && node fix-qrscanner-gradle.js && node copy-builtin-modules.js",
"sonar-scanner": "sonar-scanner",
"prettier": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
"remove-sapling": "replace './assets/sapling/sapling-' './assets/no-sapling-web/sapling-' ./src/app/app.component.ts",
Expand All @@ -36,47 +36,48 @@
"apply-diagnostic-modules": "node apply-diagnostic-modules.js"
},
"resolutions": {
"@airgap/aeternity": "0.13.19-beta.10",
"@airgap/astar": "0.13.19-beta.10",
"@airgap/bitcoin": "0.13.19-beta.10",
"@airgap/coinlib-core": "0.13.19-beta.10",
"@airgap/coreum": "0.13.19-beta.10",
"@airgap/cosmos": "0.13.19-beta.10",
"@airgap/cosmos-core": "0.13.19-beta.10",
"@airgap/crypto": "0.13.19-beta.10",
"@airgap/ethereum": "0.13.19-beta.10",
"@airgap/groestlcoin": "0.13.19-beta.10",
"@airgap/icp": "0.13.19-beta.10",
"@airgap/module-kit": "0.13.19-beta.10",
"@airgap/moonbeam": "0.13.19-beta.10",
"@airgap/optimism": "0.13.19-beta.10",
"@airgap/polkadot": "0.13.19-beta.10",
"@airgap/serializer": "0.13.19-beta.10",
"@airgap/substrate": "0.13.19-beta.10",
"@airgap/tezos": "0.13.19-beta.10"
"@airgap/aeternity": "0.13.19-beta.11",
"@airgap/astar": "0.13.19-beta.11",
"@airgap/bitcoin": "0.13.19-beta.11",
"@airgap/coinlib-core": "0.13.19-beta.11",
"@airgap/coreum": "0.13.19-beta.11",
"@airgap/cosmos": "0.13.19-beta.11",
"@airgap/cosmos-core": "0.13.19-beta.11",
"@airgap/crypto": "0.13.19-beta.11",
"@airgap/ethereum": "0.13.19-beta.11",
"@airgap/groestlcoin": "0.13.19-beta.11",
"@airgap/icp": "0.13.19-beta.11",
"@airgap/module-kit": "0.13.19-beta.11",
"@airgap/moonbeam": "0.13.19-beta.11",
"@airgap/optimism": "0.13.19-beta.11",
"@airgap/polkadot": "0.13.19-beta.11",
"@airgap/serializer": "0.13.19-beta.11",
"@airgap/substrate": "0.13.19-beta.11",
"@airgap/tezos": "0.13.19-beta.11"
},
"dependencies": {
"@airgap/aeternity": "0.13.19-beta.10",
"@airgap/aeternity": "0.13.19-beta.11",
"@airgap/angular-core": "0.0.40-beta.3",
"@airgap/angular-ngrx": "0.0.40-beta.3",
"@airgap/astar": "0.13.19-beta.10",
"@airgap/bitcoin": "0.13.19-beta.10",
"@airgap/coinlib-core": "0.13.19-beta.10",
"@airgap/coreum": "0.13.19-beta.10",
"@airgap/cosmos": "0.13.19-beta.10",
"@airgap/cosmos-core": "0.13.19-beta.10",
"@airgap/crypto": "0.13.19-beta.10",
"@airgap/ethereum": "0.13.19-beta.10",
"@airgap/groestlcoin": "0.13.19-beta.10",
"@airgap/icp": "0.13.19-beta.10",
"@airgap/module-kit": "0.13.19-beta.10",
"@airgap/moonbeam": "0.13.19-beta.10",
"@airgap/optimism": "0.13.19-beta.10",
"@airgap/polkadot": "0.13.19-beta.10",
"@airgap/astar": "0.13.19-beta.11",
"@airgap/bitcoin": "0.13.19-beta.11",
"@airgap/coinlib-core": "0.13.19-beta.11",
"@airgap/coreum": "0.13.19-beta.11",
"@airgap/cosmos": "0.13.19-beta.11",
"@airgap/cosmos-core": "0.13.19-beta.11",
"@airgap/crypto": "0.13.19-beta.11",
"@airgap/ethereum": "0.13.19-beta.11",
"@airgap/groestlcoin": "0.13.19-beta.11",
"@airgap/icp": "0.13.19-beta.11",
"@airgap/module-kit": "0.13.19-beta.11",
"@airgap/moonbeam": "0.13.19-beta.11",
"@airgap/optimism": "0.13.19-beta.11",
"@airgap/polkadot": "0.13.19-beta.11",
"@airgap/sapling-wasm": "0.0.7",
"@airgap/serializer": "0.13.19-beta.10",
"@airgap/substrate": "0.13.19-beta.10",
"@airgap/tezos": "0.13.19-beta.10",
"@airgap/serializer": "0.13.19-beta.11",
"@airgap/substrate": "0.13.19-beta.11",
"@airgap/tezos": "0.13.19-beta.11",
"@airgap-community/iso-rootstock": "1.0.0-beta.0",
"@angular/cdk": "^14.2.7",
"@angular/common": "16.1.1",
"@angular/core": "16.1.1",
Expand Down
Loading

0 comments on commit 0d531db

Please sign in to comment.