@prosopo/env 0.1.18 → 0.1.19

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.
package/dist/env.d.ts ADDED
@@ -0,0 +1,34 @@
1
+ import { ApiPromise } from '@polkadot/api';
2
+ import { AssetsResolver, ContractAbi, EnvironmentTypes } from '@prosopo/types';
3
+ import { Database } from '@prosopo/types-database';
4
+ import { Keyring } from '@polkadot/keyring';
5
+ import { KeyringPair } from '@polkadot/keyring/types';
6
+ import { Logger } from '@prosopo/common';
7
+ import { ProsopoBasicConfig } from '@prosopo/types';
8
+ import { ProsopoCaptchaContract } from '@prosopo/contract';
9
+ import { ProsopoEnvironment } from '@prosopo/types-env';
10
+ import { WsProvider } from '@polkadot/rpc-provider';
11
+ export declare class Environment implements ProsopoEnvironment {
12
+ config: ProsopoBasicConfig;
13
+ db: Database | undefined;
14
+ contractInterface: ProsopoCaptchaContract | undefined;
15
+ contractAddress: string;
16
+ defaultEnvironment: EnvironmentTypes;
17
+ contractName: string;
18
+ abi: ContractAbi;
19
+ logger: Logger;
20
+ assetsResolver: AssetsResolver | undefined;
21
+ wsProvider: WsProvider;
22
+ keyring: Keyring;
23
+ pair: KeyringPair;
24
+ api: ApiPromise | undefined;
25
+ constructor(pair: KeyringPair, config: ProsopoBasicConfig);
26
+ getSigner(): Promise<void>;
27
+ getContractInterface(): ProsopoCaptchaContract;
28
+ getApi(): ApiPromise;
29
+ changeSigner(pair: KeyringPair): Promise<void>;
30
+ getContractApi(): Promise<ProsopoCaptchaContract>;
31
+ isReady(): Promise<void>;
32
+ importDatabase(): Promise<void>;
33
+ }
34
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE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,IAAI,CAAC;CA4BxC"}
package/dist/env.js ADDED
@@ -0,0 +1,129 @@
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 { ApiPromise } from '@polkadot/api';
15
+ import { Databases } from '@prosopo/database';
16
+ import { Keyring } from '@polkadot/keyring';
17
+ import { ProsopoEnvError, getLogger } from '@prosopo/common';
18
+ import { ProsopoCaptchaContract, abiJson } from '@prosopo/contract';
19
+ import { WsProvider } from '@polkadot/rpc-provider';
20
+ import { get } from '@prosopo/util';
21
+ export class Environment {
22
+ constructor(pair, config) {
23
+ this.config = config;
24
+ this.defaultEnvironment = this.config.defaultEnvironment;
25
+ this.pair = pair;
26
+ this.logger = getLogger(this.config.logLevel, `ProsopoEnvironment`);
27
+ if (this.config.defaultEnvironment &&
28
+ Object.prototype.hasOwnProperty.call(this.config.networks, this.config.defaultEnvironment) &&
29
+ this.config.networks &&
30
+ this.config.networks[this.defaultEnvironment]) {
31
+ this.logger.info(`Endpoint: ${this.config.networks[this.defaultEnvironment]?.endpoint}`);
32
+ this.wsProvider = new WsProvider(this.config.networks[this.defaultEnvironment]?.endpoint);
33
+ this.contractAddress = this.config.networks[this.defaultEnvironment]?.contract.address || '';
34
+ this.contractName = this.config.networks[this.defaultEnvironment]?.contract.name || '';
35
+ this.keyring = new Keyring({
36
+ type: 'sr25519', // TODO get this from the chain
37
+ });
38
+ this.keyring.addPair(this.pair);
39
+ this.abi = abiJson;
40
+ this.importDatabase().catch((err) => {
41
+ this.logger.error(err);
42
+ });
43
+ }
44
+ else {
45
+ throw new ProsopoEnvError('CONFIG.UNKNOWN_ENVIRONMENT', this.constructor.name, {}, this.config.defaultEnvironment);
46
+ }
47
+ }
48
+ async getSigner() {
49
+ await this.getApi().isReadyOrError;
50
+ try {
51
+ this.pair = this.keyring.addPair(this.pair);
52
+ }
53
+ catch (err) {
54
+ throw new ProsopoEnvError('CONTRACT.SIGNER_UNDEFINED', this.getSigner.name, {}, err);
55
+ }
56
+ }
57
+ getContractInterface() {
58
+ if (this.contractInterface === undefined) {
59
+ throw new ProsopoEnvError(new Error('contractInterface not setup! Please call isReady() first'));
60
+ }
61
+ return this.contractInterface;
62
+ }
63
+ getApi() {
64
+ if (this.api === undefined) {
65
+ throw new ProsopoEnvError(new Error('api not setup! Please call isReady() first'));
66
+ }
67
+ return this.api;
68
+ }
69
+ async changeSigner(pair) {
70
+ await this.getApi().isReadyOrError;
71
+ this.pair = pair;
72
+ await this.getSigner();
73
+ this.contractInterface = await this.getContractApi();
74
+ }
75
+ async getContractApi() {
76
+ const nonce = await this.getApi().rpc.system.accountNextIndex(this.pair.address);
77
+ this.contractInterface = new ProsopoCaptchaContract(this.getApi(), this.abi, this.contractAddress, this.pair, this.contractName,
78
+ // TODO can't find .toNumber() on Index type?
79
+ parseInt(nonce.toString()), this.config.logLevel);
80
+ return this.contractInterface;
81
+ }
82
+ async isReady() {
83
+ try {
84
+ if (this.config.account.password) {
85
+ this.pair.unlock(this.config.account.password);
86
+ }
87
+ if (!this.api) {
88
+ this.api = await ApiPromise.create({ provider: this.wsProvider });
89
+ }
90
+ await this.getSigner();
91
+ this.contractInterface = await this.getContractApi();
92
+ if (!this.db) {
93
+ await this.importDatabase().catch((err) => {
94
+ this.logger.error(err);
95
+ });
96
+ }
97
+ if (this.db && this.db.connection?.readyState !== 1) {
98
+ this.logger.warn(`Database connection is not ready, reconnecting...`);
99
+ await this.db.connect();
100
+ this.logger.info(`Connected to db`);
101
+ }
102
+ }
103
+ catch (err) {
104
+ this.logger.error(err);
105
+ // TODO fix / improve error handling
106
+ throw new ProsopoEnvError(err, 'GENERAL.ENVIRONMENT_NOT_READY');
107
+ }
108
+ }
109
+ async importDatabase() {
110
+ try {
111
+ if (this.config.database) {
112
+ const dbConfig = this.config.database[this.defaultEnvironment];
113
+ if (dbConfig) {
114
+ const ProsopoDatabase = get(Databases, dbConfig.type);
115
+ this.db = await ProsopoDatabase.create(dbConfig.endpoint, dbConfig.dbname, this.logger, dbConfig.authSource);
116
+ }
117
+ }
118
+ }
119
+ catch (err) {
120
+ // TODO fix/improve error handling
121
+ throw new ProsopoEnvError(err, 'DATABASE.DATABASE_IMPORT_FAILED', {}, this.config.database
122
+ ? this.config.database[this.defaultEnvironment]
123
+ ? this.config.database[this.defaultEnvironment]?.type
124
+ : undefined
125
+ : undefined);
126
+ }
127
+ }
128
+ }
129
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAG1C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAE3C,OAAO,EAAoB,eAAe,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE9E,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AAEnC,MAAM,OAAO,WAAW;IAepB,YAAY,IAAiB,EAAE,MA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,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC;oBAC3C,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,IAAI;oBACrD,CAAC,CAAC,SAAS;gBACf,CAAC,CAAC,SAAS,CAClB,CAAA;SACJ;IACL,CAAC;CACJ"}
@@ -0,0 +1,4 @@
1
+ export { Environment } from './env.js';
2
+ export { ProviderEnvironment } from './provider.js';
3
+ export { MockEnvironment } from './mockenv.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
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
+ export { Environment } from './env.js';
15
+ export { ProviderEnvironment } from './provider.js';
16
+ export { MockEnvironment } from './mockenv.js';
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,14 @@
1
+ /// <reference types="bn.js" />
2
+ import { BN } from '@polkadot/util';
3
+ import { KeypairType } from '@polkadot/util-crypto/types';
4
+ import { ProviderEnvironment } from './provider.js';
5
+ export declare class MockEnvironment extends ProviderEnvironment {
6
+ createAccountAndAddToKeyring(): [string, string];
7
+ }
8
+ export interface ViteTestContext {
9
+ env: MockEnvironment;
10
+ pairType: KeypairType;
11
+ ss58Format: number;
12
+ providerStakeThreshold: BN;
13
+ }
14
+ //# sourceMappingURL=mockenv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockenv.d.ts","sourceRoot":"","sources":["../src/mockenv.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEnD,qBAAa,eAAgB,SAAQ,mBAAmB;IAC7C,4BAA4B,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;CAM1D;AAED,MAAM,WAAW,eAAe;IAC5B,GAAG,EAAE,eAAe,CAAA;IACpB,QAAQ,EAAE,WAAW,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,sBAAsB,EAAE,EAAE,CAAA;CAC7B"}
@@ -0,0 +1,11 @@
1
+ import { ProviderEnvironment } from './provider.js';
2
+ import { mnemonicGenerate } from '@polkadot/util-crypto';
3
+ export class MockEnvironment extends ProviderEnvironment {
4
+ createAccountAndAddToKeyring() {
5
+ const mnemonic = mnemonicGenerate();
6
+ const account = this.keyring.addFromMnemonic(mnemonic);
7
+ const { address } = account;
8
+ return [mnemonic, address];
9
+ }
10
+ }
11
+ //# sourceMappingURL=mockenv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockenv.js","sourceRoot":"","sources":["../src/mockenv.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,MAAM,OAAO,eAAgB,SAAQ,mBAAmB;IAC7C,4BAA4B;QAC/B,MAAM,QAAQ,GAAW,gBAAgB,EAAE,CAAA;QAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAA;QACtD,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;QAC3B,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC9B,CAAC;CACJ"}
@@ -0,0 +1,6 @@
1
+ import { Environment } from './env.js';
2
+ import { ProsopoConfig } from '@prosopo/types';
3
+ export declare class ProviderEnvironment extends Environment {
4
+ config: ProsopoConfig;
5
+ }
6
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE9C,qBAAa,mBAAoB,SAAQ,WAAW;IACxC,MAAM,EAAE,aAAa,CAAA;CAChC"}
@@ -0,0 +1,17 @@
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 { Environment } from './env.js';
15
+ export class ProviderEnvironment extends Environment {
16
+ }
17
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAGtC,MAAM,OAAO,mBAAoB,SAAQ,WAAW;CAEnD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prosopo/env",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "Path env prosopo environment",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -12,13 +12,13 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@polkadot/util-crypto": "12.3.2",
15
- "@prosopo/common": "^0.1.18",
16
- "@prosopo/contract": "^0.1.18",
17
- "@prosopo/database": "^0.1.18",
18
- "@prosopo/types": "^0.1.18",
19
- "@prosopo/types-database": "^0.1.18",
20
- "@prosopo/types-env": "^0.1.18",
21
- "@prosopo/util": "^0.1.18",
15
+ "@prosopo/common": "^0.1.19",
16
+ "@prosopo/contract": "^0.1.19",
17
+ "@prosopo/database": "^0.1.19",
18
+ "@prosopo/types": "^0.1.19",
19
+ "@prosopo/types-database": "^0.1.19",
20
+ "@prosopo/types-env": "^0.1.19",
21
+ "@prosopo/util": "^0.1.19",
22
22
  "dotenv": "^16.0.1"
23
23
  },
24
24
  "devDependencies": {