Ejemplo n.º 1
0
  handleAction(actionName) {
    var args = [];
    switch (actionName) {
      case 'grant':
        args.push(this.state.attendees);
        break;
      case 'attend':
        args.push(this.state.attendees);
        break;
      case 'register':
        args.push(this.state.name);
        break;
      case 'registerWithEncryption':
        args.push(this.state.name);
        let encryptedData = cryptoBrowserify.publicEncrypt(this.state.detail.encryption, new Buffer(this.state.full_name, 'utf-8'));
        args.push(encryptedData.toString('hex'));
        break;
    }
    if(actionName == 'register' || actionName == 'registerWithEncryption'){
      let obj = {
        action:'register',
        user:this.state.address,
        contract:this.state.detail.contractAddress,
        agent: navigator.userAgent,
        provider:web3.currentProvider.constructor.name,
        hostname: window.location.hostname,
        created_at: new Date()
      }
      this.props.eventEmitter.emit('logger', obj);
    }

    this.props.action(actionName, this.state.address.trim(), args)
    this.setState({
      name: null,
      attendees:[]
    });
    this.props.eventEmitter.emit('attendees', []);
  }
Ejemplo n.º 2
0
    it('increments registered', async function(){
      var publicKey = fs.readFileSync('./test/fixtures/fixture_public.key', {encoding: 'ascii'});
      var privateKey = fs.readFileSync('./test/fixtures/fixture_private.key', {encoding: 'ascii'});
      var message = "マコト";
      conference = await Conference.new('', 0, 0, 10, publicKey);
      var publicKeyFromContract = await conference.encryption.call();
      var encrypted = cryptoBrowserify.publicEncrypt(publicKeyFromContract, new Buffer(message, 'utf-8'));

      console.log(getTransaction('create   ', conference.transactionHash));
      deposit = (await conference.deposit.call()).toNumber();

      let registered = await conference.registerWithEncryption.sendTransaction(twitterOne, encrypted.toString('hex'), {value:deposit});
      console.log(getTransaction('register   ', registered));
      let decrypted;
      let event = conference.RegisterEvent({});
      let watcher = async function(err, result) {
        event.stopWatching();
        if (err) { throw err; }
        decrypted = crypto.privateDecrypt(privateKey, new Buffer(result.args._encryption, 'hex'));
        console.log('decrypted', decrypted.toString('utf8'));
      };
      await awaitEvent(event, watcher);
    })