opportunity-service 0.0.653 → 0.0.657
Sign up to get free protection for your applications and to get access to all the features.
@@ -22,22 +22,33 @@ function registerNewUser() {
|
|
22
22
|
if (typeof msgSender == 'undefined')
|
23
23
|
throw new Error('Message sender is undefined');
|
24
24
|
const userRegistrationInstance = new ethers.Contract(userRegistrationAddress, userRegistrationInterface, opportunityService.getProviderInterface());
|
25
|
-
|
25
|
+
console.log('Checking true identificaiton of msgSender: ' + msgSender);
|
26
|
+
const id = yield userRegistrationInstance.getTrueIdentification(msgSender);
|
27
|
+
console.log('The true identificaiton is: ' + id);
|
28
|
+
if (id == '0x0000000000000000000000000000000000000000') {
|
26
29
|
console.log('Registering new user: ' + msgSender);
|
27
|
-
const tx = new Contract(addressMap[opportunityService.getEthNetwork()][Contracts.USER_REGISTRATION], abiMap[Contracts.USER_REGISTRATION])
|
30
|
+
const tx = yield new Contract(addressMap[opportunityService.getEthNetwork()][Contracts.USER_REGISTRATION], abiMap[Contracts.USER_REGISTRATION])
|
31
|
+
.connect(opportunityService.getSignersInterface())
|
28
32
|
.registerNewUser({
|
29
33
|
from: msgSender
|
30
34
|
});
|
35
|
+
console.log(tx);
|
31
36
|
const receipt = yield tx.wait();
|
32
37
|
console.log('the receipt');
|
33
38
|
console.log(receipt);
|
34
39
|
if (Number(receipt.status) === 1) {
|
40
|
+
console.log('transaction succeeded');
|
35
41
|
resolve(true);
|
36
42
|
}
|
37
43
|
else {
|
44
|
+
console.log('Transaction failed');
|
38
45
|
resolve(false);
|
39
46
|
}
|
40
47
|
}
|
48
|
+
else {
|
49
|
+
console.log('User already registered');
|
50
|
+
resolve(false);
|
51
|
+
}
|
41
52
|
}
|
42
53
|
catch (error) {
|
43
54
|
console.log(error);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"register-new-user.js","sourceRoot":"","sources":["../../../src/api/identity/register-new-user.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,QAAQ,CAAC;A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Ae,CAAC"}
|
package/package.json
CHANGED
@@ -5,6 +5,7 @@ import { Contracts } from '../../constants';
|
|
5
5
|
import addressMap from '../../blockchain/addresses.json'
|
6
6
|
import abiMap from '../../blockchain/abi.json'
|
7
7
|
import { Result } from 'ethers/lib/utils';
|
8
|
+
import { TransactionResponse } from '@ethersproject/providers';
|
8
9
|
|
9
10
|
async function registerNewUser() {
|
10
11
|
return new Promise(async (resolve, reject) => {
|
@@ -16,25 +17,37 @@ async function registerNewUser() {
|
|
16
17
|
if (typeof msgSender == 'undefined') throw new Error('Message sender is undefined')
|
17
18
|
|
18
19
|
const userRegistrationInstance = new ethers.Contract(userRegistrationAddress, userRegistrationInterface, opportunityService.getProviderInterface())
|
19
|
-
|
20
|
+
|
21
|
+
console.log('Checking true identificaiton of msgSender: ' + msgSender)
|
22
|
+
const id = await userRegistrationInstance.getTrueIdentification(msgSender)
|
23
|
+
console.log('The true identificaiton is: ' + id)
|
24
|
+
|
25
|
+
if (id == '0x0000000000000000000000000000000000000000')
|
20
26
|
{
|
21
27
|
console.log('Registering new user: ' + msgSender)
|
22
|
-
const tx = new Contract(
|
23
|
-
addressMap[opportunityService.getEthNetwork()][Contracts.USER_REGISTRATION],
|
24
|
-
|
28
|
+
const tx : TransactionResponse = await new Contract(
|
29
|
+
addressMap[opportunityService.getEthNetwork()][Contracts.USER_REGISTRATION], abiMap[Contracts.USER_REGISTRATION])
|
30
|
+
.connect(opportunityService.getSignersInterface())
|
25
31
|
.registerNewUser({
|
26
32
|
from: msgSender
|
27
33
|
})
|
28
34
|
|
35
|
+
console.log(tx)
|
36
|
+
|
29
37
|
const receipt = await tx.wait()
|
30
38
|
console.log('the receipt')
|
31
39
|
console.log(receipt)
|
32
40
|
|
33
41
|
if (Number(receipt.status) === 1) {
|
42
|
+
console.log('transaction succeeded')
|
34
43
|
resolve(true);
|
35
44
|
} else {
|
45
|
+
console.log('Transaction failed')
|
36
46
|
resolve(false)
|
37
47
|
}
|
48
|
+
} else {
|
49
|
+
console.log('User already registered')
|
50
|
+
resolve(false)
|
38
51
|
}
|
39
52
|
|
40
53
|
|