diff --git a/README.md b/README.md index 1ea9369..1a36dad 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,11 @@ * [`masa green list`](#masa-green-list) * [`masa green create `](#masa-green-create-phone-number) * [`masa green burn `](#masa-green-burn-green-id) - * [`masa factory`](#masa-factory) - * [`masa factory info
`](#masa-factory-info-address) - * [`masa factory sign
`](#masa-factory-sign-address-name-types-value) + * [`masa sbt`](#masa-sbt) + * [`masa sbt info `](#masa-sbt-info-contract-address) + * [`masa sbt list `](#masa-sbt-list-contract-address) + * [`masa sbt sign `](#masa-sbt-sign-contract-address-name-types-value) + * [`masa sbt burn `](#masa-sbt-burn-contract-address-sbt-id) * [`masa settings`](#masa-settings) * [`masa settings set `](#masa-settings-set-key-value) * [`masa settings preset `](#masa-settings-preset-environment) @@ -118,9 +120,11 @@ Commands: green list [options] Lists your Greens green create Creates a Green Token green burn Burns a green - factory Factory Commands - factory info
Shows info about an SBT - factory sign
Signs an SBT + sbt SBT Commands + sbt info Shows info about an SBT + sbt list [options] Lists your SBTs + sbt sign Signs an SBT + sbt burn Burns an SBT settings Set config settings settings set Changes setting to settings preset Changes setting presets @@ -389,25 +393,41 @@ Burns a green - ` ID of the Green to burn` -### `masa factory` +### `masa sbt` -Factory Commands +SBT Commands -#### `masa factory info
` +#### `masa sbt info ` -Shows info about Masa Green +Shows info about an SBT + +- ` Address of the SBT to sign` + +#### `masa sbt list ` -- `
Address of the SBT to sign` +Lists your SBTs + +- ` Address of the SBT contract to list` + Options: +- `-a, --address
` + Address override -#### `masa factory sign
` +#### `masa sbt sign ` Signs an SBT -- `
Address of the SBT to sign` +- ` Address of the SBT to sign` - ` Name of the contract` - ` Types structure to sign` - ` Values of the structure` +#### `masa sbt burn ` + +Burns an SBT + +- ` Address of the SBT to sign` +- ` ID of the SBT to burn` + ### `masa settings` Set config settings diff --git a/src/cli.ts b/src/cli.ts index 5e1548f..e7d0dd7 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -27,6 +27,10 @@ import { identityShow, login, logout, + sbtBurn, + sbtInfo, + sbtList, + sbtSign, settingsPreset, settingsSet, settingsShow, @@ -42,7 +46,6 @@ import { version, } from "./commands"; import { reloadMasa } from "./helpers"; -import { factoryInfo, factorySign } from "./commands/factory"; import { BigNumber, TypedDataField } from "ethers"; clear(); @@ -321,28 +324,48 @@ program } { - const factory = program.command("factory").description("Factory Commands"); + const sbt = program.command("sbt").description("SBT Commands"); - factory + sbt .command("info") .description("Shows info about an SBT") - .argument("
", "Address of the SBT to sign") - .action(async (address: string) => await factoryInfo(address)); + .argument("", "Address of the SBT to sign") + .action(async (contractAddress: string) => await sbtInfo(contractAddress)); - factory + sbt + .command("list") + .description("Lists your SBTs") + .argument("", "Address of the SBT contract to list") + .option("-a, --address
", "Address override") + .action( + async (contractAddress: string, { address }) => + await sbtList(contractAddress, address) + ); + + sbt .command("sign") .description("Signs an SBT") - .argument("
", "Address of the SBT to sign") + .argument("", "Address of the SBT to sign") .argument("", "Name of the contract") .argument("", "Types structure to sign") .argument("", "Values of the structure") .action( async ( - address: string, + contractAddress: string, name: string, types: Record>, value: Record - ) => await factorySign(address, name, types, value) + ) => await sbtSign(contractAddress, name, types, value) + ); + + sbt + .command("burn") + .argument("", "Address of the SBT to sign") + .argument("", "ID of the SBT to burn") + .description("Burns an SBT") + .action( + async (contractAddress: string, greenId: string) => + await sbtBurn(contractAddress, greenId) ); } diff --git a/src/commands/factory/index.ts b/src/commands/factory/index.ts deleted file mode 100644 index 6bcbec8..0000000 --- a/src/commands/factory/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { sign as factorySign } from "./sign"; -export { info as factoryInfo } from "./info"; diff --git a/src/commands/green/burn.ts b/src/commands/green/burn.ts index ad9152c..2c5edbe 100644 --- a/src/commands/green/burn.ts +++ b/src/commands/green/burn.ts @@ -1,5 +1,6 @@ import { masa } from "../../helpers"; +import { BigNumber } from "ethers"; -export const burn = async (greenId: number) => { - await masa.green.burn(greenId); +export const burn = async (greenId: string) => { + await masa.green.burn(BigNumber.from(greenId)); }; diff --git a/src/commands/index.ts b/src/commands/index.ts index b2866c8..f339b52 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -8,3 +8,4 @@ export * from "./identity"; export * from "./version"; export * from "./credit-score"; export * from "./green"; +export * from "./sbt"; diff --git a/src/commands/sbt/burn.ts b/src/commands/sbt/burn.ts new file mode 100644 index 0000000..ce6513a --- /dev/null +++ b/src/commands/sbt/burn.ts @@ -0,0 +1,7 @@ +import { masa } from "../../helpers"; +import { BigNumber } from "ethers"; + +export const burn = async (contractAddress: string, SBTId: string) => { + const { burn } = await masa.sbt.connect(contractAddress); + await burn(BigNumber.from(SBTId)); +}; diff --git a/src/commands/sbt/index.ts b/src/commands/sbt/index.ts new file mode 100644 index 0000000..74074fa --- /dev/null +++ b/src/commands/sbt/index.ts @@ -0,0 +1,4 @@ +export { sign as sbtSign } from "./sign"; +export { info as sbtInfo } from "./info"; +export { list as sbtList } from "./list"; +export { burn as sbtBurn } from "./burn"; diff --git a/src/commands/factory/info.ts b/src/commands/sbt/info.ts similarity index 69% rename from src/commands/factory/info.ts rename to src/commands/sbt/info.ts index aee34db..ed5f9fb 100644 --- a/src/commands/factory/info.ts +++ b/src/commands/sbt/info.ts @@ -1,11 +1,12 @@ import { masa } from "../../helpers"; export const info = async (address: string) => { - const { selfSovereignSBT } = await masa.contracts.factory(address); + const { selfSovereignSBT } = await masa.contracts.sbt(address); if (selfSovereignSBT) { - console.log("Self Sovereign SBT\n"); + console.log("Self Sovereign SBT Contract Information:\n"); console.log(`Contract Name: '${await selfSovereignSBT.name()}'`); + console.log(`Contract Symbol: '${await selfSovereignSBT.symbol()}'`); console.log(`Contract Address: '${selfSovereignSBT.address}'`); console.log( `Total SBTs: ${(await selfSovereignSBT.totalSupply()).toNumber()}` diff --git a/src/commands/sbt/list.ts b/src/commands/sbt/list.ts new file mode 100644 index 0000000..779be06 --- /dev/null +++ b/src/commands/sbt/list.ts @@ -0,0 +1,6 @@ +import { masa } from "../../helpers"; + +export const list = async (contractAddress: string, address?: string) => { + const { list } = await masa.sbt.connect(contractAddress); + await list(address); +}; diff --git a/src/commands/factory/sign.ts b/src/commands/sbt/sign.ts similarity index 91% rename from src/commands/factory/sign.ts rename to src/commands/sbt/sign.ts index b32ffd2..d061d3c 100644 --- a/src/commands/factory/sign.ts +++ b/src/commands/sbt/sign.ts @@ -7,7 +7,7 @@ export const sign = async ( types: Record>, value: Record ) => { - const { sign } = await masa.contracts.factory(address); + const { sign } = await masa.contracts.sbt(address); const signResult = await sign(name, types, value); /*