Skip to content
This repository has been archived by the owner on May 8, 2023. It is now read-only.

Commit

Permalink
Protect against non-parsable docs and missing teams
Browse files Browse the repository at this point in the history
  • Loading branch information
chmanie committed Jan 18, 2023
1 parent 69853a4 commit 106e937
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/node/automation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const start = async () => {
const colonyNetwork = await ColonyNetwork.init(wallet);
// Get an instance of your favourite colony
const colony = await colonyNetwork.getColony(
'0x5D70776164466eB2985C5d49d9b535e4EAc95A2d',
'0x364B3153A24bb9ECa28B8c7aCeB15E3942eb4fc5',
);
// Mint 100 of the colony's native token
await colony.mint(w`100`).metaTx();
Expand Down
6 changes: 6 additions & 0 deletions src/ColonyNetwork/Colony.ts
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,12 @@ export class Colony {
// eslint-disable-next-line max-len
'moveFundsBetweenPots(uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256,address)',
async () => {
const domain = await this.colonyClient.getDomain(toTeam);
if (domain.fundingPotId.isZero()) {
throw new Error(
`Team with id ${BigNumber.from(toTeam).toString()} does not exist`,
);
}
// Manual permission proofs are needed here
const [permissionDomainId, childSkillIndex] = await getPermissionProofs(
this.colonyClient,
Expand Down
13 changes: 10 additions & 3 deletions src/TxCreator/TxCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { MetadataValue } from '../ipfs';
import { ParsedLogTransactionReceipt } from '../types';
import { IPFS_METADATA_EVENTS } from '../ipfs/IpfsMetadata';
import { ColonyNetwork } from '../ColonyNetwork';
import { nonNullable } from '../utils';

export interface TxConfig<M> {
metadataType?: M;
Expand Down Expand Up @@ -157,9 +158,15 @@ export class TxCreator<
const receipt = (await provider.waitForTransaction(
parsed.data.txHash,
)) as ParsedLogTransactionReceipt;
receipt.parsedLogs = receipt.logs.map((log) =>
this.contract.interface.parseLog(log),
);
receipt.parsedLogs = receipt.logs
.map((log) => {
try {
return this.contract.interface.parseLog(log);
} catch (e) {
return null;
}
})
.filter(nonNullable);

return receipt;
}
Expand Down

0 comments on commit 106e937

Please sign in to comment.