Skip to content

Commit

Permalink
fix antipatterns
Browse files Browse the repository at this point in the history
  • Loading branch information
H34D committed Jun 12, 2023
1 parent 20951fd commit f3229b9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/modules/sbt/ASBT/deploy.ts
Expand Up @@ -17,6 +17,8 @@ export const deployASBT = async (
limit: number = 1,
adminAddress?: string
): Promise<string | undefined> => {
let result = undefined;

adminAddress = adminAddress || (await masa.config.signer.getAddress());

console.log(`Deploying ASBT to network '${masa.config.networkName}'`);
Expand Down Expand Up @@ -71,10 +73,12 @@ export const deployASBT = async (
`ASBT successfully deployed to '${masa.config.networkName}' with contract address: '${address}'`
);

return address;
result = address;
} catch (error: unknown) {
if (error instanceof Error) {
console.error("ASBT deployment failed!", error.message);
}
}

return result;
};
22 changes: 19 additions & 3 deletions src/modules/sbt/SSSBT/sign.ts
Expand Up @@ -7,6 +7,14 @@ export const signSSSBT = async (
contract: ReferenceSBTSelfSovereign,
receiver: string
) => {
let result:
| {
authorityAddress: string;
signatureDate: number;
signature: string;
}
| undefined = undefined;

const [name, symbol] = await Promise.all([
contract.name(),
contract.symbol(),
Expand Down Expand Up @@ -43,17 +51,25 @@ export const signSSSBT = async (

// sign to create a signature
const signResult = await sign("ReferenceSBTSelfSovereign", types, value);
if (!signResult) return;
if (!signResult) {
return result;
}

const { signature, authorityAddress } = signResult;

if (masa.config.verbose) {
console.info({ signature, authorityAddress, signatureDate });
console.info({
signature,
authorityAddress,
signatureDate,
});
}

return {
result = {
authorityAddress,
signatureDate,
signature,
};

return result;
};

0 comments on commit f3229b9

Please sign in to comment.