certification: use BadgeReg to load the contract

This commit is contained in:
Jannis R 2016-12-09 16:40:45 +01:00
parent 452b8c9c74
commit c249c51dd3
No known key found for this signature in database
GPG Key ID: 0FE83946296A88A5
3 changed files with 10 additions and 6 deletions

View File

@ -17,6 +17,7 @@
import { observable, computed, action } from 'mobx';
import { sha3 } from '~/api/util/sha3';
import EmailVerificationABI from '~/contracts/abi/email-verification.json';
import VerificationStore, {
LOADING, QUERY_DATA, QUERY_CODE, POSTED_CONFIRMATION, DONE
} from './store';
@ -53,7 +54,7 @@ export default class EmailVerificationStore extends VerificationStore {
}
constructor (api, account, isTestnet) {
super(api, account, isTestnet, 'emailverification3');
super(api, EmailVerificationABI, 'emailverification3', account, isTestnet);
}
requestValues = () => [ sha3(this.email) ]

View File

@ -17,6 +17,7 @@
import { observable, computed, action } from 'mobx';
import phone from 'phoneformat.js';
import SMSVerificationABI from '~/contracts/abi/sms-verification.json';
import VerificationStore, {
LOADING, QUERY_DATA, QUERY_CODE, POSTED_CONFIRMATION, DONE
} from './store';
@ -52,7 +53,7 @@ export default class SMSVerificationStore extends VerificationStore {
}
constructor (api, account, isTestnet) {
super(api, account, isTestnet, 'smsverification');
super(api, SMSVerificationABI, 'smsverification', account, isTestnet);
}
@action setNumber = (number) => {

View File

@ -16,6 +16,7 @@
import { observable, autorun, action } from 'mobx';
import { sha3 } from '~/api/util/sha3';
import Contract from '~/api/contract';
import Contracts from '~/contracts';
import { checkIfVerified, checkIfRequested, awaitPuzzle } from '~/contracts/verification';
@ -46,18 +47,19 @@ export default class VerificationStore {
@observable isCodeValid = null;
@observable confirmationTx = null;
constructor (api, account, isTestnet, name) {
constructor (api, abi, name, account, isTestnet) {
this.api = api;
this.account = account;
this.isTestnet = isTestnet;
this.step = LOADING;
Contracts.get().registry.getContract(name)
.then((contract) => {
this.contract = contract;
Contracts.get().badgeReg.fetchCertifier(name)
.then(({ address }) => {
this.contract = new Contract(api, abi).at(address);
this.load();
})
.catch((err) => {
console.error('error', err);
this.error = 'Failed to fetch the contract: ' + err.message;
});