Skip to content

Commit

Permalink
fix prettier formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Nov 27, 2023
1 parent e8c291f commit 71dfef9
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 53 deletions.
2 changes: 1 addition & 1 deletion packages/protocol-sdk/src/anvil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const makeAnvilTest = ({
{
cwd: join(__dirname, ".."),
killSignal: "SIGINT",
}
},
);
const anvilHost = `http://0.0.0.0:${port}`;
await waitForAnvilInit(anvil);
Expand Down
6 changes: 3 additions & 3 deletions packages/protocol-sdk/src/apis/http-api-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const get = async <T>(url: string) => {
throw new BadResponseError(
`Invalid response, status ${response.status}`,
response.status,
json
json,
);
}
return (await response.json()) as T;
Expand Down Expand Up @@ -65,7 +65,7 @@ export const post = async <T>(url: string, data: any) => {
throw new BadResponseError(
`Bad response: ${response.status}`,
response.status,
json
json,
);
}
return (await response.json()) as T;
Expand All @@ -75,7 +75,7 @@ export const retries = async <T>(
tryFn: () => T,
maxTries: number = 3,
atTry: number = 1,
linearBackoffMS: number = 200
linearBackoffMS: number = 200,
): Promise<T> => {
try {
return await tryFn();
Expand Down
17 changes: 8 additions & 9 deletions packages/protocol-sdk/src/create/1155-create-helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe("create-helper", () => {
expect(receipt.to).to.equal("0x777777c338d93e2c7adf08d102d45ca7cc4ed021");
expect(getTokenIdFromCreateReceipt(receipt)).to.be.equal(1n);
},
20 * 1000
20 * 1000,
);
anvilTest(
"creates a new contract, than creates a new token on this existing contract",
Expand All @@ -62,12 +62,11 @@ describe("create-helper", () => {
mintToCreatorCount: 1,
});
expect(contractAddress).to.be.equal(
"0xb1A8928dF830C21eD682949Aa8A83C1C215194d3"
"0xb1A8928dF830C21eD682949Aa8A83C1C215194d3",
);
expect(contractExists).to.be.false;
const { request: simulateResponse } = await publicClient.simulateContract(
request
);
const { request: simulateResponse } =
await publicClient.simulateContract(request);
const hash = await walletClient.writeContract(simulateResponse);
const receipt = await publicClient.waitForTransactionReceipt({ hash });
const firstTokenId = getTokenIdFromCreateReceipt(receipt);
Expand All @@ -83,14 +82,14 @@ describe("create-helper", () => {
tokenMetadataURI: demoTokenMetadataURI,
account: creatorAccount,
mintToCreatorCount: 1,
}
},
);
expect(newTokenOnExistingContract.contractAddress).to.be.equal(
"0xb1A8928dF830C21eD682949Aa8A83C1C215194d3"
"0xb1A8928dF830C21eD682949Aa8A83C1C215194d3",
);
expect(newTokenOnExistingContract.contractExists).to.be.true;
const { request: simulateRequest } = await publicClient.simulateContract(
newTokenOnExistingContract.request
newTokenOnExistingContract.request,
);
const newHash = await walletClient.writeContract(simulateRequest);
const newReceipt = await publicClient.waitForTransactionReceipt({
Expand All @@ -100,6 +99,6 @@ describe("create-helper", () => {
expect(tokenId).to.be.equal(2n);
expect(newReceipt).not.toBeNull();
},
20 * 1000
20 * 1000,
);
});
10 changes: 5 additions & 5 deletions packages/protocol-sdk/src/create/1155-create-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export function create1155TokenSetupArgs({
abi: zoraCreator1155ImplABI,
functionName: "adminMint",
args: [account, nextTokenId, mintToCreatorCount, "0x"],
})
}),
);
}

Expand All @@ -160,15 +160,15 @@ export function create1155TokenSetupArgs({
royaltyRecipient: royaltySettings?.royaltyRecipient || account,
},
],
})
}),
);
}

return setupActions;
}

export const getTokenIdFromCreateReceipt = (
receipt: TransactionReceipt
receipt: TransactionReceipt,
): bigint | undefined => {
for (const data of receipt.logs) {
try {
Expand All @@ -188,7 +188,7 @@ async function getContractExists(
publicClient: PublicClient,
contract: ContractType,
// Account that is the creator of the contract
account: Address
account: Address,
) {
let contractAddress;
let contractExists = false;
Expand Down Expand Up @@ -266,7 +266,7 @@ export function create1155CreatorClient({
const { contractExists, contractAddress } = await getContractExists(
publicClient,
contract,
account
account,
);

// Assume the next token id is the first token available for a new contract.
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol-sdk/src/mint/mint-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ function encodeQueryParameters(params: Record<string, string>) {

const getMintable = async (
path: MintableGetTokenPathParameters,
query: MintableGetTokenGetQueryParameters
query: MintableGetTokenGetQueryParameters,
): Promise<MintableGetTokenResponse> =>
retries(() => {
return get<MintableGetTokenResponse>(
`${ZORA_API_BASE}discover/mintables/${path.chain_name}/${
path.collection_address
}${query?.token_id ? `?${encodeQueryParameters(query)}` : ""}`
}${query?.token_id ? `?${encodeQueryParameters(query)}` : ""}`,
);
});

Expand Down
4 changes: 2 additions & 2 deletions packages/protocol-sdk/src/mint/mint-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("mint-helper", () => {
expect(oldBalance).to.be.equal(0n);
expect(newBalance).to.be.equal(1n);
},
12 * 1000
12 * 1000,
);

anvilTest(
Expand Down Expand Up @@ -112,6 +112,6 @@ describe("mint-helper", () => {
expect(oldBalance).to.be.equal(0n);
expect(newBalance).to.be.equal(1n);
},
12 * 1000
12 * 1000,
);
});
8 changes: 4 additions & 4 deletions packages/protocol-sdk/src/mint/mint-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class MintClient extends ClientBase {
chain_name: this.network.zoraBackendChainName,
collection_address: tokenContract,
},
{ token_id: tokenId?.toString() }
{ token_id: tokenId?.toString() },
);
}

Expand Down Expand Up @@ -95,11 +95,11 @@ class MintClient extends ClientBase {

if (
!["zora_create", "zora_create_1155"].includes(
mintable.mint_context?.mint_context_type!
mintable.mint_context?.mint_context_type!,
)
) {
throw new MintError(
`Mintable type ${mintable.mint_context.mint_context_type} is currently unsupported.`
`Mintable type ${mintable.mint_context.mint_context_type} is currently unsupported.`,
);
}

Expand Down Expand Up @@ -150,7 +150,7 @@ class MintClient extends ClientBase {
contractAddress: mintable.contract_address,
tokenId: mintable.token_id!,
subgraphUrl: this.network.subgraphUrl,
}
},
);

const result: SimulateContractParameters<
Expand Down
16 changes: 8 additions & 8 deletions packages/protocol-sdk/src/premint/premint-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,28 @@ export type PremintSignatureGetResponse =
export type BackendChainNames = components["schemas"]["ChainName"];

const postSignature = async (
data: PremintSignatureRequestBody
data: PremintSignatureRequestBody,
): Promise<PremintSignatureResponse> =>
retries(() =>
post<PremintSignatureResponse>(`${ZORA_API_BASE}premint/signature`, data)
post<PremintSignatureResponse>(`${ZORA_API_BASE}premint/signature`, data),
);

const getNextUID = async (
path: PremintNextUIDGetPathParameters
path: PremintNextUIDGetPathParameters,
): Promise<PremintNextUIDGetResponse> =>
retries(() =>
get<PremintNextUIDGetResponse>(
`${ZORA_API_BASE}premint/signature/${path.chain_name}/${path.collection_address}/next_uid`
)
`${ZORA_API_BASE}premint/signature/${path.chain_name}/${path.collection_address}/next_uid`,
),
);

const getSignature = async (
path: PremintSignatureGetPathParameters
path: PremintSignatureGetPathParameters,
): Promise<PremintSignatureGetResponse> =>
retries(() =>
get<PremintSignatureGetResponse>(
`${ZORA_API_BASE}premint/signature/${path.chain_name}/${path.collection_address}/${path.uid}`
)
`${ZORA_API_BASE}premint/signature/${path.chain_name}/${path.collection_address}/${path.uid}`,
),
);

export const PremintAPIClient = {
Expand Down
11 changes: 5 additions & 6 deletions packages/protocol-sdk/src/premint/premint-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe("ZoraCreator1155Premint", () => {
"0x588d19641de9ba1dade4d2bb5387c8dc96f4a990fef69787534b60caead759e6334975a6be10a796da948cd7d1d4f5580b3f84d49d9fa4e0b41c97759507975a1c",
});
},
20 * 1000
20 * 1000,
);

anvilTest.skip(
Expand Down Expand Up @@ -112,7 +112,7 @@ describe("ZoraCreator1155Premint", () => {
publicClient,
});
expect(signatureValid.isValid).toBe(true);
}
},
);

anvilTest(
Expand Down Expand Up @@ -163,9 +163,8 @@ describe("ZoraCreator1155Premint", () => {
mintComment: "",
},
});
const { request: simulateRequest } = await publicClient.simulateContract(
request
);
const { request: simulateRequest } =
await publicClient.simulateContract(request);
const hash = await walletClient.writeContract(simulateRequest);
const receipt = await publicClient.waitForTransactionReceipt({ hash });
const { premintedLog, urls } =
Expand Down Expand Up @@ -208,6 +207,6 @@ describe("ZoraCreator1155Premint", () => {
uid: 3,
});
},
20 * 1000
20 * 1000,
);
});
6 changes: 3 additions & 3 deletions packages/protocol-sdk/src/premint/premint-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const DefaultMintArguments = {
* @returns Premint event arguments
*/
export function getPremintedLogFromReceipt(
receipt: TransactionReceipt
receipt: TransactionReceipt,
): PremintedLogType | undefined {
for (const data of receipt.logs) {
try {
Expand All @@ -104,7 +104,7 @@ export function getPremintedLogFromReceipt(
* @returns Viem type-compatible premint object
*/
export const convertPremint = (
premint: PremintSignatureGetResponse["premint"]
premint: PremintSignatureGetResponse["premint"],
) => ({
...premint,
tokenConfig: {
Expand All @@ -120,7 +120,7 @@ export const convertPremint = (
});

export const convertCollection = (
collection: PremintSignatureGetResponse["collection"]
collection: PremintSignatureGetResponse["collection"],
) => ({
...collection,
contractAdmin: collection.contractAdmin as Address,
Expand Down
18 changes: 9 additions & 9 deletions packages/protocol-sdk/src/premint/preminter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const defaultContractConfig = ({

const defaultTokenConfigV1 = (
fixedPriceMinterAddress: Address,
creatorAccount: Address
creatorAccount: Address,
): TokenCreationConfigV1 => ({
tokenURI: "ipfs://tokenIpfsId0",
maxSupply: 100n,
Expand All @@ -54,7 +54,7 @@ const defaultTokenConfigV1 = (
const defaultTokenConfigV2 = (
fixedPriceMinterAddress: Address,
creatorAccount: Address,
createReferral: Address
createReferral: Address,
): TokenCreationConfigV2 => ({
tokenURI: "ipfs://tokenIpfsId0",
maxSupply: 100n,
Expand Down Expand Up @@ -93,7 +93,7 @@ const defaultPremintConfigV2 = ({
tokenConfig: defaultTokenConfigV2(
fixedPriceMinter,
creatorAccount,
createReferral
createReferral,
),
deleted: false,
uid: 106,
Expand Down Expand Up @@ -182,7 +182,7 @@ describe("ZoraCreator1155Preminter", () => {
contractAddress,
});
},
20 * 1000
20 * 1000,
);
anvilTest(
"can sign and recover a v1 premint config signature",
Expand Down Expand Up @@ -236,7 +236,7 @@ describe("ZoraCreator1155Preminter", () => {
expect(recoveredAddress).to.equal(creatorAccount);
},

20 * 1000
20 * 1000,
);
makeAnvilTest({
forkUrl: forkUrls.zoraSepoli,
Expand Down Expand Up @@ -294,7 +294,7 @@ describe("ZoraCreator1155Preminter", () => {
expect(recoveredAddress).to.equal(creatorAccount);
},

20 * 1000
20 * 1000,
);
anvilTest(
"can sign and mint multiple tokens",
Expand Down Expand Up @@ -456,7 +456,7 @@ describe("ZoraCreator1155Preminter", () => {
// now have the collector execute the second signed message.
// it should create a new token against the existing contract
const mintHash2 = await viemClients.walletClient.writeContract(
simulationResult.request
simulationResult.request,
);

const premintV2Receipt =
Expand Down Expand Up @@ -487,7 +487,7 @@ describe("ZoraCreator1155Preminter", () => {
expect(tokenBalance2).toBe(quantityToMint2);
},
// 10 second timeout
40 * 1000
40 * 1000,
);

anvilTest(
Expand Down Expand Up @@ -594,6 +594,6 @@ describe("ZoraCreator1155Preminter", () => {

expect(creatorFromEvent).toBe(creatorAccount);
expect(recoveredSigner).toBe(creatorFromEvent);
}
},
);
});
2 changes: 1 addition & 1 deletion packages/protocol-sdk/src/premint/preminter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ export const recoverCreatorFromCreatorAttribution = async ({
export const supportsPremintVersion = async (
version: PremintConfigVersion,
tokenContract: Address,
publicClient: PublicClient
publicClient: PublicClient,
) => {
const supportedPremintSignatureVersions = await publicClient.readContract({
abi: preminterAbi,
Expand Down

0 comments on commit 71dfef9

Please sign in to comment.