zemingyu / meetup-queue

A queueing system on the blockchain for meetups
MIT License
9 stars 3 forks source link

Have trouble accessing elements of an individual Meetup struct #4

Open zemingyu opened 6 years ago

zemingyu commented 6 years ago

Meetup struct is defined as:

    struct Meetup {
        // The timestamp from the block when the meetup event is created.
        uint64 birthTime;

        // The timestamp from the block when the meetup event is scheduled to start.
        uint64 startTime;

        // Capacity of the meeting.
        uint8 maxCapacity;

        // Address of the presenters.
        address[] presenters;

        // Address of people who register for the event.
        // Only the top maxCapacity people will be able to enter.
        // The rest will be on the waiting list.
        address[] registrationList;
    }

I tried to console.log an individual instance of Meetup:

    it('allows people to join the meetup event', async () => {
      // setup an event in 1 week's time
      beforeCount = await meetupBaseInstance.getMeetupCount();
      await meetupBaseInstance.createMeetup(60*60*24*7, 3, [organiser, presenter1], {from: organiser});
      afterCount = await meetupBaseInstance.getMeetupCount();
      assert.equal(beforeCount.toNumber(), afterCount.toNumber()-1);

      // return the meetup struct
      console.log(await meetupBaseInstance.meetups.call(0));
    });

However I only get:

[ BigNumber { s: 1, e: 9, c: [ 1521458584 ] }, BigNumber { s: 1, e: 9, c: [ 1522063384 ] }, BigNumber { s: 1, e: 0, c: [ 3 ] } ] ✓ allows people to join the meetup event (318ms)

Question 1: Where did presenters array go?

Question 2: How do I access birthTime? I tried meetupBaseInstance.meetups.call(0).birthTime.toNumber() and the log says it's not defined.

For reference, here's the createMeetup function:

    function createMeetup (            
        uint64 _timeUntilMeetup,        
        uint8 _maxCapacity,       
        address[] _presenters
    )
        public
        onlyAssistant() 
        returns (uint256)
    {

        address[] memory _registrationList = _presenters;

        Meetup memory _meetup = Meetup({            
            birthTime: uint64(now),
            startTime: uint64(now + _timeUntilMeetup),            
            maxCapacity: _maxCapacity,
            presenters: _presenters,
            registrationList: _registrationList
        });

        uint256 newMeetupId = meetups.push(_meetup) - 1 ;

        // emit the birth event
        Birth(_timeUntilMeetup, _maxCapacity);

        return newMeetupId;
    }