@prosopo/config 0.2.15 → 0.2.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,152 +0,0 @@
1
- import { Alias } from 'vite'
2
- import { getLogger } from '@prosopo/common'
3
- import path from 'path'
4
-
5
- // List of interfaces to replace with mock. The interface is required if commented out.
6
- const POLKADOT_INTERFACES = [
7
- './assetConversion/definitions.js',
8
- './assets/definitions.js',
9
- './attestations/definitions.js',
10
- './aura/definitions.js',
11
- './author/definitions.js',
12
- './authorship/definitions.js',
13
- './babe/definitions.js',
14
- // './balances/definitions.js',
15
- './beefy/definitions.js',
16
- './benchmark/definitions.js',
17
- './blockbuilder/definitions.js',
18
- './bridges/definitions.js',
19
- // './chain/definitions.js',
20
- './childstate/definitions.js',
21
- './claims/definitions.js',
22
- './collective/definitions.js',
23
- './consensus/definitions.js',
24
- // './contracts/definitions.js',
25
- // './contractsAbi/definitions.js',
26
- './crowdloan/definitions.js',
27
- './cumulus/definitions.js',
28
- './democracy/definitions.js',
29
- './dev/definitions.js',
30
- './discovery/definitions.js',
31
- './elections/definitions.js',
32
- './engine/definitions.js',
33
- './eth/definitions.js',
34
- './evm/definitions.js',
35
- // './extrinsics/definitions.js',
36
- './finality/definitions.js',
37
- './fungibles/definitions.js',
38
- './genericAsset/definitions.js',
39
- './gilt/definitions.js',
40
- './grandpa/definitions.js',
41
- './identity/definitions.js',
42
- './imOnline/definitions.js',
43
- './lottery/definitions.js',
44
- //'./metadata/definitions.js',
45
- './mmr/definitions.js',
46
- './nfts/definitions.js',
47
- './nimbus/definitions.js',
48
- './nompools/definitions.js',
49
- './offchain/definitions.js',
50
- './offences/definitions.js',
51
- './ormlOracle/definitions.js',
52
- './ormlTokens/definitions.js',
53
- './parachains/definitions.js',
54
- './payment/definitions.js',
55
- './poll/definitions.js',
56
- './pow/definitions.js',
57
- './proxy/definitions.js',
58
- './purchase/definitions.js',
59
- './recovery/definitions.js',
60
- // './rpc/definitions.js',
61
- // './runtime/definitions.js',
62
- //'./scaleInfo/definitions.js',
63
- './scheduler/definitions.js',
64
- './session/definitions.js',
65
- './society/definitions.js',
66
- './staking/definitions.js',
67
- //'./state/definitions.js',
68
- './support/definitions.js',
69
- './syncstate/definitions.js',
70
- // './system/definitions.js',
71
- './treasury/definitions.js',
72
- './txpayment/definitions.js',
73
- './txqueue/definitions.js',
74
- './uniques/definitions.js',
75
- //'./utility/definitions.js',
76
- './vesting/definitions.js',
77
- './xcm/definitions.js',
78
- ]
79
-
80
- const POLKADOT_UPGRADES = [
81
- './centrifuge-chain.js',
82
- './kusama.js',
83
- './node.js',
84
- './node-template.js',
85
- './polkadot.js',
86
- './shell.js',
87
- './statemint.js',
88
- './westend.js',
89
- ]
90
-
91
- const API_DERIVE = [
92
- //'./accounts/index.js',
93
- './alliance/index.js',
94
- './bagsList/index.js',
95
- //'./balances/index.js',
96
- './bounties/index.js',
97
- //'./chain/index.js',
98
- //'./contracts/index.js',
99
- './council/index.js',
100
- './crowdloan/index.js',
101
- './democracy/index.js',
102
- './elections/index.js',
103
- './imOnline/index.js',
104
- './membership/index.js',
105
- './parachains/index.js',
106
- './session/index.js',
107
- './society/index.js',
108
- './staking/index.js',
109
- './technicalCommittee/index.js',
110
- './treasury/index.js',
111
- //'./tx/index.js',
112
- ]
113
-
114
- const KNOWN_SUBSTRATE_CHAINS = ['./genesis.js']
115
-
116
- const WASM_BYTES = ['./bytes.js', './cjs/bytes.js']
117
-
118
- const log = getLogger(`Info`, `config.polkadot.exclude.js`)
119
-
120
- export function getAliases(dir: string): Alias[] {
121
- const alias: Alias[] = []
122
-
123
- const mockUpgrade = path.resolve(dir, '../../dev/config/dist/polkadot/mockUpgrade.js')
124
- const mockInterface = path.resolve(dir, '../../dev/config/dist/polkadot/mockInterface.js')
125
- const mockSubstrate = path.resolve(dir, '../../dev/config/dist/polkadot/mockSubstrateGenesis.js')
126
- const mockAPIDerive = path.resolve(dir, '../../dev/config/dist/polkadot/mockApiDerive.js')
127
- const slimmedWASM = path.resolve(dir, '../../dev/config/dist/polkadot/bytes.js')
128
-
129
- POLKADOT_UPGRADES.forEach((file) => {
130
- log.debug(`resolving ${file} to ${mockUpgrade.split('/').slice(-1)}`)
131
- alias.push({ find: file, replacement: mockUpgrade })
132
- })
133
- POLKADOT_INTERFACES.forEach((file) => {
134
- log.debug(`resolving ${file} to ${mockUpgrade.split('/').slice(-1)}`)
135
- alias.push({ find: file, replacement: mockInterface })
136
- })
137
- KNOWN_SUBSTRATE_CHAINS.forEach((file) => {
138
- log.debug(`resolving ${file} to ${mockUpgrade.split('/').slice(-1)}`)
139
- alias.push({ find: file, replacement: mockSubstrate })
140
- })
141
- WASM_BYTES.forEach((file) => {
142
- log.debug(`resolving ${file} to ${mockUpgrade.split('/').slice(-1)}`)
143
- alias.push({ find: file, replacement: slimmedWASM })
144
- })
145
-
146
- API_DERIVE.forEach((file) => {
147
- log.debug(`resolving ${file} to ${mockUpgrade.split('/').slice(-1)}`)
148
- alias.push({ find: file, replacement: mockAPIDerive })
149
- })
150
-
151
- return alias
152
- }
@@ -1 +0,0 @@
1
- export { getAliases } from './exclude.js'
@@ -1 +0,0 @@
1
- export default {}
@@ -1 +0,0 @@
1
- export default { types: {} }
@@ -1,46 +0,0 @@
1
- export const knownGenesis = {
2
- kusama: [
3
- '0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe',
4
- '0xe3777fa922cafbff200cadeaea1a76bd7898ad5b89f7848999058b50e715f636',
5
- '0x3fd7b9eb6a00376e5be61f01abb429ffb0b104be05eaff4d458da48fcd425baf',
6
- ],
7
- polkadot: ['0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3'],
8
- rococo: [
9
- '0x6408de7737c59c238890533af25896a2c20608d8b380bb01029acb392781063e',
10
- '0xaaf2cd1b74b5f726895921259421b534124726263982522174147046b8827897',
11
- '0x037f5f3c8e67b314062025fc886fcd6238ea25a4a9b45dce8d246815c9ebe770',
12
- '0xc196f81260cf1686172b47a79cf002120735d7cb0eb1474e8adce56618456fff',
13
- '0xf6e9983c37baf68846fedafe21e56718790e39fb1c582abc408b81bc7b208f9a',
14
- '0x5fce687da39305dfe682b117f0820b319348e8bb37eb16cf34acbf6a202de9d9',
15
- '0xe7c3d5edde7db964317cd9b51a3a059d7cd99f81bdbce14990047354334c9779',
16
- '0x1611e1dbf0405379b861e2e27daa90f480b2e6d3682414a80835a52e8cb8a215',
17
- '0x343442f12fa715489a8714e79a7b264ea88c0d5b8c66b684a7788a516032f6b9',
18
- '0x78bcd530c6b3a068bc17473cf5d2aff9c287102bed9af3ae3c41c33b9d6c6147',
19
- '0x47381ee0697153d64404fc578392c8fd5cba9073391908f46c888498415647bd',
20
- '0x19c0e4fa8ab75f5ac7865e0b8f74ff91eb9a100d336f423cd013a8befba40299',
21
- ],
22
- westend: ['0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e'],
23
- }
24
- export const knownIcon = {
25
- centrifuge: 'polkadot',
26
- kusama: 'polkadot',
27
- polkadot: 'polkadot',
28
- sora: 'polkadot',
29
- statemine: 'polkadot',
30
- statemint: 'polkadot',
31
- westmint: 'polkadot',
32
- }
33
- export const knownLedger = {
34
- kusama: 434,
35
- polkadot: 354,
36
- }
37
- export const knownTestnet = {
38
- '': true,
39
- 'cess-testnet': true,
40
- 'dock-testnet': true,
41
- jupiter: true,
42
- 'mathchain-testnet': true,
43
- p3dt: true,
44
- subspace_testnet: true,
45
- 'zero-alphaville': true,
46
- }
@@ -1,7 +0,0 @@
1
- export const upgrades = []
2
- export const versioned = []
3
- export const statemint = []
4
- export const polkadot = []
5
- export const centrifugeChain = []
6
- export const shell = []
7
- export default []
@@ -1,108 +0,0 @@
1
- export const getContractNames = () => {
2
- return ['captcha', 'common', 'proxy']
3
- }
4
-
5
- export type Paths = {
6
- root: string
7
- dev: string
8
- demos: string
9
- contract: string
10
- protocol: string
11
- packages: string
12
- config: string
13
- scripts: string
14
- protocolCli: string
15
- protocolDist: string
16
- clientExample: string
17
- clientExampleServer: string
18
- clientBundleExample: string
19
- dappExample: string
20
- common: string
21
- api: string
22
- cli: string
23
- util: string
24
- database: string
25
- datasets: string
26
- datasetsFs: string
27
- env: string
28
- fileServer: string
29
- procaptcha: string
30
- procaptchaReact: string
31
- procaptchaBundle: string
32
- provider: string
33
- server: string
34
- typesDatabase: string
35
- typesEnv: string
36
- types: string
37
- contractPackagesDir: string
38
- }
39
-
40
- export const getPaths = (): Paths => {
41
- const root = new URL('../../..', import.meta.url).pathname.slice(0, -1)
42
- const dev = `${root}/dev`
43
- const packages = `${root}/packages`
44
- const protocol = `${root}/protocol`
45
- const demos = `${root}/demos`
46
- const contract = `${packages}/contract`
47
- const types = `${packages}/types`
48
- const config = `${dev}/config`
49
- const scripts = `${dev}/scripts`
50
- const protocolCli = `${protocol}/dist/cli`
51
- const protocolDist = `${protocol}/target/ink`
52
- const clientExample = `${demos}/client-example`
53
- const clientExampleServer = `${demos}/client-example-server`
54
- const clientBundleExample = `${demos}/client-bundle-example`
55
- const dappExample = `${demos}/dapp-example`
56
- const common = `${packages}/common`
57
- const api = `${packages}/api`
58
- const cli = `${packages}/cli`
59
- const util = `${packages}/util`
60
- const database = `${packages}/database`
61
- const datasets = `${packages}/datasets`
62
- const datasetsFs = `${packages}/datasets-fs`
63
- const env = `${packages}/env`
64
- const fileServer = `${packages}/file-server`
65
- const procaptcha = `${packages}/procaptcha`
66
- const procaptchaReact = `${packages}/procaptcha-react`
67
- const procaptchaBundle = `${packages}/procaptcha-bundle`
68
- const provider = `${packages}/provider`
69
- const server = `${packages}/server`
70
- const typesDatabase = `${packages}/types-database`
71
- const typesEnv = `${packages}/types-env`
72
- const contractPackagesDir = `${root}/contracts`
73
-
74
- return {
75
- contractPackagesDir,
76
- root,
77
- dev,
78
- demos,
79
- contract,
80
- protocol,
81
- packages,
82
- config,
83
- scripts,
84
- protocolCli,
85
- protocolDist,
86
- clientExample,
87
- clientExampleServer,
88
- clientBundleExample,
89
- dappExample,
90
- common,
91
- api,
92
- cli,
93
- util,
94
- database,
95
- datasets,
96
- datasetsFs,
97
- env,
98
- fileServer,
99
- procaptcha,
100
- procaptchaReact,
101
- procaptchaBundle,
102
- provider,
103
- server,
104
- typesDatabase,
105
- typesEnv,
106
- types,
107
- }
108
- }
@@ -1 +0,0 @@
1
- export { default as getTestConfig } from './test.js'
@@ -1,40 +0,0 @@
1
- import {
2
- DatabaseTypes,
3
- EnvironmentTypesSchema,
4
- NetworkNamesSchema,
5
- NetworkPairTypeSchema,
6
- ProsopoConfigSchema,
7
- } from '@prosopo/types'
8
- import { getLogLevel } from '@prosopo/common'
9
-
10
- const logLevel = getLogLevel()
11
- export default function getTestConfig() {
12
- return ProsopoConfigSchema.parse({
13
- logLevel,
14
- defaultEnvironment: EnvironmentTypesSchema.Values.development,
15
- defaultNetwork: NetworkNamesSchema.Values.development,
16
- account: {
17
- password: '',
18
- address: '',
19
- },
20
- database: {
21
- development: { type: DatabaseTypes.enum.mongoMemory, endpoint: '', dbname: 'prosopo_test', authSource: '' },
22
- },
23
- server: {
24
- baseURL: 'http://localhost',
25
- port: 9229,
26
- fileServePaths: '[]',
27
- },
28
- networks: {
29
- development: {
30
- endpoint: 'ws://localhost:9944',
31
- contract: {
32
- address: process.env.PROSOPO_CONTRACT_ADDRESS || '',
33
- name: 'prosopo',
34
- },
35
- pairType: NetworkPairTypeSchema.parse('sr25519'),
36
- ss58Format: 42,
37
- },
38
- },
39
- })
40
- }
@@ -1,29 +0,0 @@
1
- // Copyright 2021-2023 Prosopo (UK) Ltd.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- import { describe, expect, test } from 'vitest'
15
- import { flattenObj } from '@prosopo/util'
16
- import { getPaths } from '../projectInfo.js'
17
- import fs from 'fs'
18
-
19
- describe('paths', () => {
20
- test('paths exist', () => {
21
- const paths = getPaths()
22
- const flat = flattenObj(paths)
23
- for (const [key, value] of Object.entries(flat)) {
24
- expect(value).to.not.be.undefined
25
- expect(value).to.not.be.null
26
- expect(fs.existsSync(String(value))).to.be.true
27
- }
28
- })
29
- })
package/src/vite/index.ts DELETED
@@ -1,7 +0,0 @@
1
- export { default as VitePluginCloseAndCopy } from './vite-plugin-close-and-copy.js'
2
- export { default as ViteTestConfig } from './vite.test.config.js'
3
- export { default as VitePluginSourceMapExclude } from './vite-plugin-sourcemap-exclude.js'
4
- export { default as ViteFrontendConfig } from './vite.frontend.config.js'
5
- export { default as ViteBackendConfig } from './vite.backend.config.js'
6
- export { default as VitePluginFixAbsoluteImports } from './vite-plugin-fix-absolute-imports.js'
7
- export { default as ViteCommonJSConfig } from './vite.commonjs.config.js'
package/src/vite/types.ts DELETED
File without changes
@@ -1,44 +0,0 @@
1
- import { Plugin } from 'vite'
2
- import { getLogger } from '@prosopo/common'
3
- import fs from 'node:fs'
4
- import path from 'path'
5
- const log = getLogger(`Info`, `config.vite.vite-plugin-close.js`)
6
- export interface ClosePluginOptions {
7
- srcDir: string
8
- destDir: string
9
- bundleName: string
10
- }
11
- /**
12
- * description: Closes Vite after the bundle has been build. Optionally copies the bundle to a different directory.
13
- * @param { ClosePluginOptions } options - The options object
14
- **/
15
- export default function VitePluginCloseAndCopy(options?: ClosePluginOptions): Plugin {
16
- const __dirname = path.resolve()
17
- return {
18
- name: 'close-plugin', // required, will show up in warnings and errors
19
- buildStart() {
20
- log.info('Bundle build started')
21
- },
22
- buildEnd(error) {
23
- log.info('Build end')
24
- if (error) {
25
- console.log(error)
26
- log.error(error)
27
- }
28
- },
29
- closeBundle() {
30
- if (options) {
31
- for (const file of fs.readdirSync(path.resolve(__dirname, options.srcDir))) {
32
- if (file.startsWith(options.bundleName) && file.endsWith('js')) {
33
- const src = path.resolve(__dirname, options.srcDir, file)
34
- const dest = path.resolve(__dirname, options.destDir, file)
35
- fs.copyFileSync(src, dest)
36
- log.info(`Copied ${src} to ${dest}`)
37
- }
38
- }
39
- }
40
- log.info('Bundle closed')
41
- process.exit(0)
42
- },
43
- }
44
- }
@@ -1,24 +0,0 @@
1
- import { builtinModules } from 'module'
2
- import type { Plugin } from 'vite'
3
-
4
- export default function VitePluginFixAbsoluteImports(): Plugin {
5
- return {
6
- name: 'fix-absolute-imports',
7
- transform(code: string, id: string) {
8
- for (const module of builtinModules) {
9
- const moduleImportRegex = new RegExp(`from "(${module}(/.*)*/.*.js)";`, 'g')
10
- // if matches, replace match with _module
11
- const matches = code.match(moduleImportRegex)
12
- if (matches) {
13
- for (const match of matches) {
14
- code = code.replace(match, `from "${module}";`)
15
- }
16
- }
17
- }
18
- return {
19
- code,
20
- }
21
- },
22
- enforce: 'post',
23
- }
24
- }
@@ -1,21 +0,0 @@
1
- import type { Plugin } from 'vite'
2
-
3
- interface SourcemapExclude {
4
- excludeNodeModules?: boolean
5
- }
6
- // Taken from https://github.com/vitejs/vite/issues/2433#issuecomment-1487472995 to prevent memory leaks
7
- export default function VitePluginSourcemapExclude(opts?: SourcemapExclude): Plugin {
8
- return {
9
- name: 'sourcemap-exclude',
10
- transform(code: string, id: string) {
11
- if (opts?.excludeNodeModules && id.includes('node_modules')) {
12
- return {
13
- code,
14
- // https://github.com/rollup/rollup/blob/master/docs/plugin-development/index.md#source-code-transformations
15
- map: { mappings: '' },
16
- }
17
- }
18
- return
19
- },
20
- }
21
- }