Skip to content

Commit

Permalink
feat: add createReferral to createNew1155Token params (#336)
Browse files Browse the repository at this point in the history
* feat: add create referral to new 1155 params

* chore: add changeset

* chore: update deployments package
  • Loading branch information
kulkarohan authored Apr 8, 2024
1 parent 5c436fb commit 825e5f7
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/giant-books-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zoralabs/protocol-sdk": patch
---

Adds optional `createReferral` to `createNew1155Token` params
4 changes: 2 additions & 2 deletions packages/protocol-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"abitype": "^0.10.3"
},
"peerDependencies": {
"viem": "^1.19.15",
"graphql-request": "^6.1.0"
"graphql-request": "^6.1.0",
"viem": "^1.19.15"
},
"devDependencies": {
"@lavamoat/preinstall-always-fail": "2.0.0",
Expand Down
33 changes: 33 additions & 0 deletions packages/protocol-sdk/src/create/1155-create-helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,37 @@ describe("create-helper", () => {
},
20 * 1000,
);
anvilTest(
"creates a new token with a create referral address",
async ({ viemClients: { testClient, publicClient, walletClient } }) => {
const addresses = await walletClient.getAddresses();
const creatorAddress = addresses[0]!;
await testClient.setBalance({
address: creatorAddress,
value: parseEther("1"),
});
const creatorClient = create1155CreatorClient({
publicClient: publicClient,
});
const { request } = await creatorClient.createNew1155Token({
contract: {
name: "testContract",
uri: demoContractMetadataURI,
},
tokenMetadataURI: demoTokenMetadataURI,
account: creatorAddress,
mintToCreatorCount: 1,
createReferral: creatorAddress,
});
const { request: simulationResponse } =
await publicClient.simulateContract(request);
const hash = await walletClient.writeContract(simulationResponse);
const receipt = await publicClient.waitForTransactionReceipt({ hash });
expect(receipt).not.toBeNull();
console.log(receipt);
expect(receipt.to).to.equal("0xa72724cc3dcef210141a1b84c61824074151dc99");
expect(getTokenIdFromCreateReceipt(receipt)).to.be.equal(2n);
},
20 * 1000,
);
});
3 changes: 3 additions & 0 deletions packages/protocol-sdk/src/create/1155-create-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ export function create1155CreatorClient({
maxSupply,
account,
royaltySettings,
createReferral,
getAdditionalSetupActions,
}: {
account: Address;
Expand All @@ -256,6 +257,7 @@ export function create1155CreatorClient({
tokenMetadataURI: string;
mintToCreatorCount?: bigint | number;
salesConfig?: SalesConfigParamsType;
createReferral?: Address;
getAdditionalSetupActions?: (args: {
tokenId: bigint;
contractAddress: Address;
Expand Down Expand Up @@ -296,6 +298,7 @@ export function create1155CreatorClient({
account,
mintToCreatorCount,
royaltySettings,
createReferral,
});
if (getAdditionalSetupActions) {
tokenSetupActions = [
Expand Down

0 comments on commit 825e5f7

Please sign in to comment.