Skip to content

Commit

Permalink
Lower maximum number of transfers in mintMany
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub committed Sep 29, 2018
1 parent 96f877c commit 8663a0c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions scripts/distribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async function deployVestingContract(token: PhotochainToken, beneficiary: Addres
}

class TransactionAggregator {
private static readonly MAX_MINT_MANY = 200;
private static readonly MAX = 168;

private txs: Array<Promise<TransactionResult>> = [];
private addresses: Address[] = [];
Expand All @@ -95,7 +95,7 @@ class TransactionAggregator {
this.addresses.push(beneficiary);
this.amounts.push(amount);

if (this.addresses.length >= TransactionAggregator.MAX_MINT_MANY) {
if (this.addresses.length >= TransactionAggregator.MAX) {
this.mintAggregated();
}
}
Expand Down
8 changes: 5 additions & 3 deletions test/photochaintoken.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,8 @@ contract('PhotochainToken', accounts => {
}
});

const maxMintMany = 200;
it(`should accept ${maxMintMany} beneficiaries at once`, async () => {
const maxMintMany = 168;
it(`should accept ${maxMintMany} beneficiaries at once and keep gas usage under 5.3 mln`, async () => {
const prevSupply = await token.totalSupply();

const beneficiaries = [];
Expand All @@ -456,7 +456,9 @@ contract('PhotochainToken', accounts => {
}
const totalAmount = amounts.reduce((a: BigNumber, b: BigNumber) => a.add(b), new BigNumber(0));

await token.mintMany(beneficiaries, amounts);
const tx = await token.mintMany(beneficiaries, amounts);

assert.isBelow(tx.receipt.gasUsed, 5_300_000);

// check total supply change to confirm the transaction has succeeded
assertPhtEqual(await token.totalSupply(), prevSupply.add(totalAmount));
Expand Down

0 comments on commit 8663a0c

Please sign in to comment.