Skip to content

Commit

Permalink
added add authority command
Browse files Browse the repository at this point in the history
  • Loading branch information
H34D committed May 26, 2023
1 parent e9eb4dc commit 8e01085
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 19 deletions.
10 changes: 10 additions & 0 deletions src/sbt/SSSBT/add-authority.ts
@@ -0,0 +1,10 @@
import Masa from "../../masa";
import { MasaSBTSelfSovereign } from "@masa-finance/masa-contracts-identity";

export const addAuthority = async (
masa: Masa,
contract: MasaSBTSelfSovereign,
authorityAddress: string
) => {
await contract.addAuthority(authorityAddress);
};
1 change: 1 addition & 0 deletions src/sbt/SSSBT/index.ts
@@ -1,3 +1,4 @@
export * from "./add-authority";
export * from "./deploy";
export * from "./mint";
export * from "./sign";
Expand Down
16 changes: 7 additions & 9 deletions src/sbt/SSSBT/mint.ts
Expand Up @@ -7,7 +7,7 @@ import { PayableOverrides } from "ethers";

export const mintSSSBT = async (
masa: Masa,
sbtContract: ReferenceSBTSelfSovereign,
contract: ReferenceSBTSelfSovereign,
authorityAddress: string,
signatureDate: number,
signature: string,
Expand All @@ -16,19 +16,17 @@ export const mintSSSBT = async (
const receiver = await masa.config.signer.getAddress();

const [name, symbol] = await Promise.all([
sbtContract.name(),
sbtContract.symbol(),
contract.name(),
contract.symbol(),
]);

console.log(`Minting SSSBT on: '${masa.config.networkName}'`);
console.log(`Contract Name: '${name}'`);
console.log(`Contract Symbol: '${symbol}'`);
console.log(`Contract Address: '${sbtContract.address}'`);
console.log(`Contract Address: '${contract.address}'`);
console.log(`To receiver: '${receiver}'`);

const { prepareMint, getPrice } = await masa.contracts.sbt.attach(
sbtContract
);
const { prepareMint, getPrice } = await masa.contracts.sbt.attach(contract);

const types = {
Mint: [
Expand Down Expand Up @@ -79,7 +77,7 @@ export const mintSSSBT = async (
const {
"mint(address,address,address,uint256,bytes)": mint,
estimateGas: { "mint(address,address,address,uint256,bytes)": estimateGas },
} = sbtContract;
} = contract;

const gasLimit = await estimateGas(...mintSSSBTArguments, mintSSSBTOverrides);

Expand All @@ -92,7 +90,7 @@ export const mintSSSBT = async (

const { logs } = await wait();

const parsedLogs = masa.contracts.parseLogs(logs, [sbtContract]);
const parsedLogs = masa.contracts.parseLogs(logs, [contract]);

const mintEvent = parsedLogs.find(
(log: LogDescription) => log.name === "Mint"
Expand Down
10 changes: 5 additions & 5 deletions src/sbt/SSSBT/sign.ts
Expand Up @@ -3,18 +3,18 @@ import { ReferenceSBTSelfSovereign } from "@masa-finance/masa-contracts-identity

export const signSSSBT = async (
masa: Masa,
sbtContract: ReferenceSBTSelfSovereign,
contract: ReferenceSBTSelfSovereign,
receiver: string
) => {
const [name, symbol] = await Promise.all([
sbtContract.name(),
sbtContract.symbol(),
contract.name(),
contract.symbol(),
]);

console.log(`Signing SSSBT on: '${masa.config.networkName}'`);
console.log(`Contract Name: '${name}'`);
console.log(`Contract Symbol: '${symbol}'`);
console.log(`Contract Address: '${sbtContract.address}'`);
console.log(`Contract Address: '${contract.address}'`);
console.log(`To receiver: '${receiver}'`);

const signatureDate = Date.now();
Expand All @@ -39,7 +39,7 @@ export const signSSSBT = async (
};

const { sign } = await masa.contracts.sbt.attach<ReferenceSBTSelfSovereign>(
sbtContract
contract
);

// sign to create a signature
Expand Down
8 changes: 8 additions & 0 deletions src/sbt/SSSBT/sssbt.ts
Expand Up @@ -7,6 +7,7 @@ import { signSSSBT } from "./sign";
import { mintSSSBT } from "./mint";
import { MasaSBT, SBTWrapper } from "../sbt";
import Masa from "../../masa";
import { addAuthority } from "./add-authority";

export class SSSBTWrapper<
Contract extends ReferenceSBTSelfSovereign
Expand All @@ -31,6 +32,13 @@ export class SSSBTWrapper<
signatureDate,
signature
);

/**
*
* @param authorityAddress
*/
addAuthority = (authorityAddress: string) =>
addAuthority(this.masa, this.contract, authorityAddress);
}

export class MasaSSSBT<
Expand Down
15 changes: 10 additions & 5 deletions src/utils/clients/masa-client.ts
Expand Up @@ -477,12 +477,17 @@ export class MasaClient extends MasaBase {
const { data: getData, status } = getResponse || {};

if (this.masa.config.verbose) {
console.info({
getResponse: {
status,
getData,
console.dir(
{
getResponse: {
status,
getData,
},
},
});
{
depth: null,
}
);
}

return getData;
Expand Down

0 comments on commit 8e01085

Please sign in to comment.