ran prettier
This commit is contained in:
@@ -32,30 +32,31 @@ export class Erc1155Wrapper {
|
||||
this._contractOwner = contractOwner;
|
||||
this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts);
|
||||
}
|
||||
public async getBalancesAsync(
|
||||
owners: string[],
|
||||
tokens: BigNumber[]
|
||||
): Promise<BigNumber[]> {
|
||||
const balances = await this._erc1155Contract.balanceOfBatch.callAsync(
|
||||
owners,
|
||||
tokens,
|
||||
);
|
||||
public async getBalancesAsync(owners: string[], tokens: BigNumber[]): Promise<BigNumber[]> {
|
||||
const balances = await this._erc1155Contract.balanceOfBatch.callAsync(owners, tokens);
|
||||
return balances;
|
||||
}
|
||||
public async safeTransferFromAsync(from: string, to: string, token: BigNumber, value: BigNumber, callbackData: string = '0x'): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
public async safeTransferFromAsync(
|
||||
from: string,
|
||||
to: string,
|
||||
token: BigNumber,
|
||||
value: BigNumber,
|
||||
callbackData: string = '0x',
|
||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(
|
||||
await this._erc1155Contract.safeTransferFrom.sendTransactionAsync(
|
||||
await this._erc1155Contract.safeTransferFrom.sendTransactionAsync(from, to, token, value, callbackData, {
|
||||
from,
|
||||
to,
|
||||
token,
|
||||
value,
|
||||
callbackData,
|
||||
{ from },
|
||||
),
|
||||
}),
|
||||
);
|
||||
return tx;
|
||||
}
|
||||
public async safeBatchTransferFromAsync(from: string, to: string, tokens: BigNumber[], values: BigNumber[], callbackData: string = '0x'): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
public async safeBatchTransferFromAsync(
|
||||
from: string,
|
||||
to: string,
|
||||
tokens: BigNumber[],
|
||||
values: BigNumber[],
|
||||
callbackData: string = '0x',
|
||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(
|
||||
await this._erc1155Contract.safeBatchTransferFrom.sendTransactionAsync(
|
||||
from,
|
||||
@@ -72,7 +73,9 @@ export class Erc1155Wrapper {
|
||||
const tokenUri = 'dummyFungibleToken';
|
||||
const tokenIsNonFungible = false;
|
||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(
|
||||
await this._erc1155Contract.create.sendTransactionAsync(tokenUri, tokenIsNonFungible, { from: this._contractOwner })
|
||||
await this._erc1155Contract.create.sendTransactionAsync(tokenUri, tokenIsNonFungible, {
|
||||
from: this._contractOwner,
|
||||
}),
|
||||
);
|
||||
const createFungibleTokenLog = tx.logs[0] as LogWithDecodedArgs<ERC1155TransferSingleEventArgs>;
|
||||
const token = createFungibleTokenLog.args._id;
|
||||
@@ -84,33 +87,39 @@ export class Erc1155Wrapper {
|
||||
);
|
||||
return token;
|
||||
}
|
||||
public async mintNonFungibleTokenAsync(beneficiary: string): Promise<[BigNumber,BigNumber]> {
|
||||
public async mintNonFungibleTokenAsync(beneficiary: string): Promise<[BigNumber, BigNumber]> {
|
||||
const tokenUri = 'dummyNonFungibleToken';
|
||||
const tokenIsNonFungible = true;
|
||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(
|
||||
await this._erc1155Contract.create.sendTransactionAsync(tokenUri, tokenIsNonFungible, { from: this._contractOwner })
|
||||
await this._erc1155Contract.create.sendTransactionAsync(tokenUri, tokenIsNonFungible, {
|
||||
from: this._contractOwner,
|
||||
}),
|
||||
);
|
||||
const createFungibleTokenLog = tx.logs[0] as LogWithDecodedArgs<ERC1155TransferSingleEventArgs>;
|
||||
const token = createFungibleTokenLog.args._id;
|
||||
await this._web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await this._erc1155Contract.mintNonFungible.sendTransactionAsync(token, [beneficiary], { from: this._contractOwner }),
|
||||
await this._erc1155Contract.mintNonFungible.sendTransactionAsync(token, [beneficiary], {
|
||||
from: this._contractOwner,
|
||||
}),
|
||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||
);
|
||||
const nftId = token.plus(1);
|
||||
return [token, nftId];
|
||||
}
|
||||
public async assertBalancesAsync(owners: string[], tokens: BigNumber[], expectedBalances: BigNumber[]): Promise<void> {
|
||||
public async assertBalancesAsync(
|
||||
owners: string[],
|
||||
tokens: BigNumber[],
|
||||
expectedBalances: BigNumber[],
|
||||
): Promise<void> {
|
||||
const ownersExtended: string[] = [];
|
||||
const tokensExtended: BigNumber[] = [];
|
||||
_.each(tokens, (token: BigNumber) => {
|
||||
ownersExtended.concat(owners);
|
||||
_.range(0, owners.length, () => {tokensExtended.push(token)});
|
||||
|
||||
_.range(0, owners.length, () => {
|
||||
tokensExtended.push(token);
|
||||
});
|
||||
});
|
||||
const balances = await this.getBalancesAsync(
|
||||
ownersExtended,
|
||||
tokensExtended,
|
||||
);
|
||||
const balances = await this.getBalancesAsync(ownersExtended, tokensExtended);
|
||||
_.each(balances, (balance: BigNumber, i: number) => {
|
||||
expect(balance, `${ownersExtended[i]}${tokensExtended[i]}`).to.be.bignumber.equal(expectedBalances[i]);
|
||||
});
|
||||
|
Reference in New Issue
Block a user