PolymathNetwork/polymath.js

allow polymath.js to easily pass through a 0 value for investor _from and _to for modifyInvestor() and modifyInvestorMulti()

Closed this issue · 0 comments

When we remove an investor, we just pass a timestamp of 0 to the solidity contract. The way to do this with polymath js. would be to call modifyWhitelistMulti(), but right now the investor type only accepts date objects, and it is cumbersome to get the timestamp of 0 passed through because of javascripts built in usage of timezones.

I have two suggestions to make this easier. The first is to make a removeInvestorMulti() function:

async removeWhitelistMulti (investors: Array<Address>): Promise<Web3Receipt> {
return this._tx(this._methods.modifyWhitelistMulti(addresses, 0, 0))
  }

But on second thought, we will want instances where we can update an address with a real timestamp for one value, and a 0 value for another , like so:
this._methods.modifyWhitelistMulti(addresses, 1578978784, 0)

So it would be nice if we had one function that can do this, and i think we can get the current modifyInvestorWhitelist to do so. I suggest updating the investor type to be as follows:

export type Investor = {
  address: Address,
  addedBy: Address,
  added: Date,
  from: Date | 0,
  to: Date | 0,
}

This might cause toUnixTS() helper to fail, but I suggest just doing an if statement check, and if 0 is passed, skip using toUnixTS()

The second suggestion I think will make it easiest to use, but there could be a better way I am not thinking of. Please review and indicate which design you will go with