Skip to content

Commit

Permalink
lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Nov 28, 2023
1 parent 4edcd6a commit ac87bc4
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .changeset/pink-turtles-watch.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"@zoralabs/protocol-sdk": patch
---

premintClient has http methods overridable via dependency injection, and now takes publicClient and http overrides in `createPremintClient` function. it no longer takes `publicClient` as an argument in functions, and rather uses them from the constructor
premintClient can have http methods overridable via DI, and now takes publicClient and http overrides in `createPremintClient` function. it no longer takes `publicClient` as an argument in functions, and rather uses them from the constructor. `executePremint` has been renamed ot `makeMintParameters`
2 changes: 1 addition & 1 deletion packages/protocol-sdk/src/premint/premint-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type PremintSignatureGetPathParameters =
export type PremintSignatureGetResponse =
SignaturePremintGetType["responses"][200]["content"]["application/json"];

export type PremintCollection = PremintSignatureGetResponse['collection'];
export type PremintCollection = PremintSignatureGetResponse["collection"];

export type BackendChainNames = components["schemas"]["ChainName"];

Expand Down
37 changes: 23 additions & 14 deletions packages/protocol-sdk/src/premint/premint-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ describe("ZoraCreator1155Premint", () => {
"can sign on the forked premint contract",
async ({ viemClients: { walletClient, publicClient } }) => {
const [deployerAccount] = await walletClient.getAddresses();
const premintClient = createPremintClient({ chain: foundry, publicClient });
const premintClient = createPremintClient({
chain: foundry,
publicClient,
});

premintClient.apiClient.getNextUID = vi
.fn()
Expand Down Expand Up @@ -68,7 +71,10 @@ describe("ZoraCreator1155Premint", () => {
anvilTest(
"can validate premint on network",
async ({ viemClients: { publicClient } }) => {
const premintClient = createPremintClient({ chain: foundry, publicClient });
const premintClient = createPremintClient({
chain: foundry,
publicClient,
});

const premintData = {
collection: {
Expand Down Expand Up @@ -145,19 +151,22 @@ describe("ZoraCreator1155Premint", () => {
});
premintClient.apiClient.postSignature = vi.fn();

const simulateContractParameters = await premintClient.makeMintParameters({
account: deployerAccount!,
data: await premintClient.getPremintData({
address: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
uid: 3,
}),
mintArguments: {
quantityToMint: 1,
mintComment: "",
const simulateContractParameters = await premintClient.makeMintParameters(
{
account: deployerAccount!,
data: await premintClient.getPremintData({
address: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
uid: 3,
}),
mintArguments: {
quantityToMint: 1,
mintComment: "",
},
},
});
const { request: simulateRequest } =
await publicClient.simulateContract(simulateContractParameters);
);
const { request: simulateRequest } = await publicClient.simulateContract(
simulateContractParameters,
);
const hash = await walletClient.writeContract(simulateRequest);
const receipt = await publicClient.waitForTransactionReceipt({ hash });
const { premintedLog, urls } =
Expand Down
14 changes: 10 additions & 4 deletions packages/protocol-sdk/src/premint/premint-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,15 @@ class PremintClient {
readonly publicClient: PublicClient;
readonly chain: Chain;

constructor(chain: Chain, publicClient?: PublicClient, httpClient?: IHttpClient) {
constructor(
chain: Chain,
publicClient?: PublicClient,
httpClient?: IHttpClient,
) {
this.chain = chain;
this.apiClient = new PremintAPIClient(chain.id, httpClient);
this.publicClient =
publicClient || createPublicClient({ chain, transport: http() });
publicClient || createPublicClient({ chain, transport: http() });
}

/**
Expand Down Expand Up @@ -590,9 +594,11 @@ class PremintClient {
export function createPremintClient({
chain,
httpClient,
publicClient
publicClient,
}: {
chain: Chain, publicClient?: PublicClient, httpClient?: IHttpClient
chain: Chain;
publicClient?: PublicClient;
httpClient?: IHttpClient;
}) {
return new PremintClient(chain, publicClient, httpClient);
}

0 comments on commit ac87bc4

Please sign in to comment.