opportunity-service 0.0.629 → 0.0.633
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/OpportunityService.js +12 -0
- package/dist/OpportunityService.js.map +1 -1
- package/dist/api/index.js +2 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/internal/abis.js +6 -1
- package/dist/api/internal/abis.js.map +1 -1
- package/dist/api/internal/addresses.js +0 -3
- package/dist/api/internal/addresses.js.map +1 -1
- package/dist/api/internal/index.js +2 -2
- package/dist/api/internal/index.js.map +1 -1
- package/dist/blockchain/abi.json +19 -818
- package/package.json +1 -1
- package/src/OpportunityService.ts +14 -0
- package/src/api/index.ts +2 -1
- package/src/api/internal/abis.ts +8 -1
- package/src/api/internal/addresses.ts +0 -3
- package/src/api/internal/index.ts +2 -2
- package/src/blockchain/abi.json +19 -818
package/package.json
CHANGED
@@ -13,6 +13,7 @@ import opportunityStorageProvider from "./modules/storage/OpportunityStorageProv
|
|
13
13
|
import { EthNetworkID } from "dvote-js";
|
14
14
|
import Web3 from 'web3';
|
15
15
|
import OpportunityStorageProvider from "./modules/storage/OpportunityStorageProvider";
|
16
|
+
import { createAlchemyWeb3 } from "@alch/alchemy-web3"
|
16
17
|
|
17
18
|
import { Shh } from 'web3-shh'
|
18
19
|
|
@@ -20,6 +21,7 @@ class OpportunityService {
|
|
20
21
|
private eventEmitter = opportunityEventEmitter;
|
21
22
|
private running: boolean = false;
|
22
23
|
private syncing: boolean = false;
|
24
|
+
private opportunityProvider : providers.JsonRpcProvider;
|
23
25
|
private ethersProvider : providers.JsonRpcProvider = ethers.getDefaultProvider('http://localhost:8545');
|
24
26
|
private ethersSigner : providers.JsonRpcSigner = null;
|
25
27
|
private static defaultProvider = new Web3('http://localhost:8545')
|
@@ -39,7 +41,11 @@ class OpportunityService {
|
|
39
41
|
* construction calls with the `new` operator.
|
40
42
|
*/
|
41
43
|
private constructor() {
|
44
|
+
const web3 = createAlchemyWeb3(process.env.NODE_ENV == 'dev' ? "https://eth-mainnet.alchemyapi.io/v2/JKVeBInuvm4wq9_8fECUmazLbm7Vpv5V" : "https://eth-mainnet.alchemyapi.io/v2/7d2CRio84usjQwU8tRPG75rqV1wJmX_W");
|
42
45
|
this.ethNetwork = 'rinkeby'
|
46
|
+
|
47
|
+
this.opportunityProvider = new ethers.providers.JsonRpcProvider(process.env.NODE_ENV == 'dev' ? "https://eth-mainnet.alchemyapi.io/v2/JKVeBInuvm4wq9_8fECUmazLbm7Vpv5V" : "https://eth-mainnet.alchemyapi.io/v2/7d2CRio84usjQwU8tRPG75rqV1wJmX_W")
|
48
|
+
console.log(this.opportunityProvider)
|
43
49
|
}
|
44
50
|
|
45
51
|
/**
|
@@ -145,6 +151,14 @@ class OpportunityService {
|
|
145
151
|
}
|
146
152
|
|
147
153
|
getProviderInterface() : providers.JsonRpcProvider {
|
154
|
+
if (this.opportunityProvider) {
|
155
|
+
console.log('Provider is not null')
|
156
|
+
console.log(this.opportunityProvider)
|
157
|
+
return this.opportunityProvider
|
158
|
+
} else {
|
159
|
+
console.log('provider is null')
|
160
|
+
}
|
161
|
+
|
148
162
|
return this.ethersProvider;
|
149
163
|
}
|
150
164
|
|
package/src/api/index.ts
CHANGED
@@ -7,7 +7,7 @@ import { enterWorkRelationship } from "./exchange/enter-work-relationship";
|
|
7
7
|
import registerNewUser from "./identity/register-new-user";
|
8
8
|
import { createMarket } from "./market/create-market";
|
9
9
|
|
10
|
-
import { abis, events, getContractAddress} from './internal/index';
|
10
|
+
import { abis, events, getContractAddress, getContractInterface} from './internal/index';
|
11
11
|
|
12
12
|
import { sendAsync } from './ethereum/sendAsync'
|
13
13
|
import { parseCypher } from "./util/parse-cipher";
|
@@ -29,6 +29,7 @@ function generateAPI() {
|
|
29
29
|
internal: {
|
30
30
|
abis: abis,
|
31
31
|
getContractAddress,
|
32
|
+
getContractInterface
|
32
33
|
},
|
33
34
|
exchange: {
|
34
35
|
completeRelationship,
|
package/src/api/internal/abis.ts
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
|
2
|
-
import
|
2
|
+
import abiMap from '../../blockchain/abi.json';
|
3
|
+
|
4
|
+
function getContractInterface(contract: string) {
|
5
|
+
console.log(abiMap)
|
6
|
+
return abiMap[contract]
|
7
|
+
}
|
8
|
+
|
9
|
+
export { getContractInterface }
|
3
10
|
|
4
11
|
export default {
|
5
12
|
'MarketFactory': abiMap['MarketFactory'],
|
@@ -4,8 +4,5 @@ import { EthNetworkID } from 'dvote-js';
|
|
4
4
|
import { Contracts } from '../../constants';
|
5
5
|
|
6
6
|
export default function getContractAddress(network: EthNetworkID, contractName: Contracts): string {
|
7
|
-
console.log(network)
|
8
|
-
console.log(contractName)
|
9
|
-
console.log(addressMap)
|
10
7
|
return addressMap[network][contractName]
|
11
8
|
}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import abis from "./abis";
|
1
|
+
import abis, { getContractInterface } from "./abis";
|
2
2
|
import getContractAddress from "./addresses";
|
3
3
|
import events from "./events";
|
4
4
|
|
5
|
-
export { abis, getContractAddress, events};
|
5
|
+
export { abis, getContractAddress, getContractInterface, events};
|