Skip to content

Commit

Permalink
added phone number as a paramerter for 2fa
Browse files Browse the repository at this point in the history
  • Loading branch information
H34D committed Nov 7, 2022
1 parent 652ccbe commit a3fb3cb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/2fa/2fa.ts
Expand Up @@ -5,8 +5,8 @@ import { BigNumber } from "ethers";
import Masa from "../masa";

export const twofa = (masa: Masa) => ({
mint: (address: string, signature: string) =>
masa.client.twofaMint(address, signature),
mint: (address: string, phoneNumber: string, signature: string) =>
masa.client.twofaMint(address, phoneNumber, signature),
create: (phoneNumber: string) => create2fa(masa, phoneNumber),
burn: (twofaId: number) => burn2fa(masa, twofaId),
list: (address?: string) => list2fas(masa, address),
Expand Down
9 changes: 3 additions & 6 deletions src/2fa/burn.ts
Expand Up @@ -14,8 +14,6 @@ export const burn2faById = async (
console.log("Waiting for the burn tx to finalize");
await tx.wait();

console.log(`2fa with id '${twofaId}' burned!`);

return true;
} catch (err: any) {
console.error(`Burning of 2fa Failed! '${err.message}'`);
Expand All @@ -32,14 +30,13 @@ export const burn2fa = async (

if (await masa.session.checkLogin()) {
const identityId = await masa.identity.load();
if (!identityId) {
return success;
}
if (!identityId) return success;
console.log(`Burning 2fa with id '${twofaId}'!`);

success = await burn2faById(masa, twofaId);

if (success) {
console.log(`Burning 2fa with id ${twofaId}!`);
console.log(`Burned 2fa with id '${twofaId}'!`);
}
} else {
console.log("Not logged in please login first");
Expand Down
6 changes: 5 additions & 1 deletion src/2fa/create.ts
Expand Up @@ -32,7 +32,11 @@ export const create2fa = async (

// 2. mint 2fa
console.log("\nCreating 2fa");
const storeMetadataData = await masa.twofa.mint(address, signature);
const storeMetadataData = await masa.twofa.mint(
address,
phoneNumber,
signature
);

if (storeMetadataData) {
const { success, message, tokenId } = storeMetadataData;
Expand Down
2 changes: 2 additions & 0 deletions src/utils/clients/middleware.ts
Expand Up @@ -193,6 +193,7 @@ export class MasaClient {

twofaMint = async (
address: string,
phoneNumber: string,
signature: string
): Promise<
| {
Expand All @@ -207,6 +208,7 @@ export class MasaClient {
`/contracts/2fa/mint`,
{
address,
phoneNumber,
signature,
},
{
Expand Down

0 comments on commit a3fb3cb

Please sign in to comment.