Skip to content

Commit

Permalink
adapt changes from sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
H34D committed Mar 6, 2023
1 parent cf04820 commit 6a547a7
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 21 deletions.
16 changes: 10 additions & 6 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ program
.description("Creates a masa identity with soul name")
.action(
async (soulName: string, duration: number) =>
await identityCreate(soulName, duration)
await identityCreate("eth", soulName, duration)
);

identity
Expand Down Expand Up @@ -141,7 +141,7 @@ program
.description("Creates a new soul name")
.action(
async (soulName: string, duration: number) =>
await soulNameCreate(soulName, duration)
await soulNameCreate("eth", soulName, duration)
);

soulName
Expand Down Expand Up @@ -192,7 +192,7 @@ program
creditScore
.command("create")
.description("Creates a Credit Score")
.action(async () => await creditScoreCreate());
.action(async () => await creditScoreCreate("eth"));

creditScore
.command("burn")
Expand Down Expand Up @@ -227,13 +227,15 @@ program
.command("establish")
.argument("<passport>", "Masa Soul Linker passport")
.description("Establishes a link to a Credit Score")
.action(async (passport) => await creditScoreLinkEstablish(passport));
.action(
async (passport) => await creditScoreLinkEstablish("eth", passport)
);

creditScoreLink
.command("query")
.argument("<passport>", "Masa Soul Linker passport")
.description("Queries a link to a Credit Score")
.action(async (passport) => await creditScoreLinkQuery(passport));
.action(async (passport) => await creditScoreLinkQuery("eth", passport));

creditScoreLink
.command("list")
Expand Down Expand Up @@ -289,7 +291,9 @@ program
.command("create")
.argument("<phone-number>", "The phone number to verify")
.description("Creates a Green Token")
.action(async (phoneNumber: string) => await greenCreate(phoneNumber));
.action(
async (phoneNumber: string) => await greenCreate("eth", phoneNumber)
);

green
.command("burn")
Expand Down
5 changes: 3 additions & 2 deletions src/commands/credit-score/create.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { masa } from "../../helpers";
import { PaymentMethod } from "@masa-finance/masa-sdk";

export const create = async () => {
const result = await masa.creditScore.create();
export const create = async (paymentMethod: PaymentMethod) => {
const result = await masa.creditScore.create(paymentMethod);
if (!result || !result.success) console.error(result?.message);
};
9 changes: 7 additions & 2 deletions src/commands/credit-score/link/establish.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { masa } from "../../../helpers";
import { PaymentMethod } from "@masa-finance/masa-sdk";

/**
*
* @param paymentMethod
* @param passport the base64 encoded soul linker passport
*/
export const establish = async (passport: string) => {
await masa.creditScore.links.establish(passport);
export const establish = async (
paymentMethod: PaymentMethod,
passport: string
) => {
await masa.creditScore.links.establish(paymentMethod, passport);
};
6 changes: 4 additions & 2 deletions src/commands/credit-score/link/query.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { masa } from "../../../helpers";
import { PaymentMethod } from "@masa-finance/masa-sdk";

/**
*
* @param paymentMethod
* @param passport the base64 encoded soul linker passport
*/
export const query = async (passport: string) => {
await masa.creditScore.links.query(passport);
export const query = async (paymentMethod: PaymentMethod, passport: string) => {
await masa.creditScore.links.query(paymentMethod, passport);
};
7 changes: 6 additions & 1 deletion src/commands/green/create.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { masa, readLine } from "../../helpers";
import { PaymentMethod } from "@masa-finance/masa-sdk";

export const create = async (phoneNumber: string) => {
export const create = async (
paymentMethod: PaymentMethod,
phoneNumber: string
) => {
console.log(`Creating Green for phone number: '${phoneNumber}'`);

const generateResult = await masa.green.generate(phoneNumber);
Expand Down Expand Up @@ -38,6 +42,7 @@ export const create = async (phoneNumber: string) => {
console.log(`Minting Green on '${masa.config.network}'`);

mintGreenResult = await masa.green.mint(
paymentMethod,
verifyGreenResult.authorityAddress,
verifyGreenResult.signatureDate,
verifyGreenResult.signature
Expand Down
6 changes: 3 additions & 3 deletions src/commands/identity/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { masa } from "../../helpers";
import { PaymentMethod } from "@masa-finance/masa-sdk";

export const create = async (
paymentMethod: PaymentMethod,
soulName: string,
duration: number,
paymentMethod: PaymentMethod = "eth"
duration: number
) => {
await masa.identity.createWithSoulName(soulName, duration, paymentMethod);
await masa.identity.createWithSoulName(paymentMethod, soulName, duration);
};

export const register = async () => {
Expand Down
6 changes: 3 additions & 3 deletions src/commands/soul-name/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { masa } from "../../helpers";
import { PaymentMethod } from "@masa-finance/masa-sdk";

export const create = async (
paymentMethod: PaymentMethod,
soulName: string,
duration: number,
paymentMethod: PaymentMethod = "eth"
duration: number
) => {
await masa.soulName.create(soulName, duration, paymentMethod);
await masa.soulName.create(paymentMethod, soulName, duration);
};
3 changes: 1 addition & 2 deletions src/commands/soul-name/verify.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { masa } from "../../helpers";

export const verify = async (soulName: string) => {
const extension =
await masa.contracts.instances.SoulNameContract.extension();
const extension = await masa.contracts.instances.SoulNameContract.extension();

const result = await masa.soulName.verify(soulName.replace(extension, ""));

Expand Down
1 change: 1 addition & 0 deletions src/doc.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { Argument, Command, Option } from "commander";
import program from "./cli";

Expand Down

0 comments on commit 6a547a7

Please sign in to comment.