@zoralabs/protocol-sdk 0.5.8-DEV.1 → 0.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +15 -0
- package/CHANGELOG.md +5 -12
- package/dist/index.cjs +218 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +218 -50
- package/dist/index.js.map +1 -1
- package/dist/mints/mints-contracts.d.ts +2855 -129
- package/dist/mints/mints-contracts.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/create/1155-create-helper.test.ts +104 -0
- package/src/mint/mint-client.test.ts +114 -0
- package/src/mints/mints-contracts.test.ts +719 -0
- package/src/mints/mints-contracts.ts +310 -63
- package/src/mints/mints-queries.test.ts +105 -0
- package/src/premint/premint-client.test.ts +239 -0
- package/src/premint/preminter.test.ts +619 -0
- package/test-integration/premint-client.test.ts +146 -0
- package/tsconfig.build.json +10 -0
- package/tsup.config.ts +12 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mints-contracts.d.ts","sourceRoot":"","sources":["../../src/mints/mints-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,
|
|
1
|
+
{"version":3,"file":"mints-contracts.d.ts","sourceRoot":"","sources":["../../src/mints/mints-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAEnB,0BAA0B,EAG3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,6BAA6B,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EACL,aAAa,IAAI,oBAAoB,EACrC,eAAe,EAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EACL,OAAO,EACP,OAAO,EACP,6BAA6B,EAC7B,GAAG,EACH,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAO3B,MAAM,MAAM,CAAC;AAEd,wBAAgB,iB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://github.com/ourzora/zora-protocol",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"lint": "prettier --check 'src/**/*.ts' 'test-integration/**/*.ts'"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@zoralabs/protocol-deployments": "
|
|
28
|
+
"@zoralabs/protocol-deployments": "*",
|
|
29
29
|
"abitype": "^0.10.3"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { parseEther } from "viem";
|
|
2
|
+
import { describe, expect } from "vitest";
|
|
3
|
+
import {
|
|
4
|
+
create1155CreatorClient,
|
|
5
|
+
getTokenIdFromCreateReceipt,
|
|
6
|
+
} from "./1155-create-helper";
|
|
7
|
+
import { anvilTest } from "src/anvil";
|
|
8
|
+
|
|
9
|
+
const demoTokenMetadataURI = "ipfs://DUMMY/token.json";
|
|
10
|
+
const demoContractMetadataURI = "ipfs://DUMMY/contract.json";
|
|
11
|
+
|
|
12
|
+
describe("create-helper", () => {
|
|
13
|
+
anvilTest(
|
|
14
|
+
"creates a new contract given arguments",
|
|
15
|
+
async ({ viemClients: { testClient, publicClient, walletClient } }) => {
|
|
16
|
+
const addresses = await walletClient.getAddresses();
|
|
17
|
+
const creatorAddress = addresses[0]!;
|
|
18
|
+
await testClient.setBalance({
|
|
19
|
+
address: creatorAddress,
|
|
20
|
+
value: parseEther("1"),
|
|
21
|
+
});
|
|
22
|
+
const creatorClient = create1155CreatorClient({
|
|
23
|
+
publicClient: publicClient,
|
|
24
|
+
});
|
|
25
|
+
const { request } = await creatorClient.createNew1155Token({
|
|
26
|
+
contract: {
|
|
27
|
+
name: "testContract",
|
|
28
|
+
uri: demoContractMetadataURI,
|
|
29
|
+
},
|
|
30
|
+
tokenMetadataURI: demoTokenMetadataURI,
|
|
31
|
+
account: creatorAddress,
|
|
32
|
+
mintToCreatorCount: 1,
|
|
33
|
+
});
|
|
34
|
+
const { request: simulationResponse } =
|
|
35
|
+
await publicClient.simulateContract(request);
|
|
36
|
+
const hash = await walletClient.writeContract(simulationResponse);
|
|
37
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
38
|
+
expect(receipt).not.toBeNull();
|
|
39
|
+
expect(receipt.to).to.equal("0x777777c338d93e2c7adf08d102d45ca7cc4ed021");
|
|
40
|
+
expect(getTokenIdFromCreateReceipt(receipt)).to.be.equal(1n);
|
|
41
|
+
},
|
|
42
|
+
20 * 1000,
|
|
43
|
+
);
|
|
44
|
+
anvilTest(
|
|
45
|
+
"creates a new contract, than creates a new token on this existing contract",
|
|
46
|
+
async ({ viemClients: { publicClient, walletClient } }) => {
|
|
47
|
+
const addresses = await walletClient.getAddresses();
|
|
48
|
+
const creatorAccount = addresses[0]!;
|
|
49
|
+
|
|
50
|
+
const creatorClient = create1155CreatorClient({
|
|
51
|
+
publicClient: publicClient,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const { request, contractAddress, contractExists } =
|
|
55
|
+
await creatorClient.createNew1155Token({
|
|
56
|
+
contract: {
|
|
57
|
+
name: "testContract2",
|
|
58
|
+
uri: demoContractMetadataURI,
|
|
59
|
+
},
|
|
60
|
+
tokenMetadataURI: demoTokenMetadataURI,
|
|
61
|
+
account: creatorAccount,
|
|
62
|
+
mintToCreatorCount: 1,
|
|
63
|
+
});
|
|
64
|
+
expect(contractAddress).to.be.equal(
|
|
65
|
+
"0xb1A8928dF830C21eD682949Aa8A83C1C215194d3",
|
|
66
|
+
);
|
|
67
|
+
expect(contractExists).to.be.false;
|
|
68
|
+
const { request: simulateResponse } =
|
|
69
|
+
await publicClient.simulateContract(request);
|
|
70
|
+
const hash = await walletClient.writeContract(simulateResponse);
|
|
71
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
72
|
+
const firstTokenId = getTokenIdFromCreateReceipt(receipt);
|
|
73
|
+
expect(firstTokenId).to.be.equal(1n);
|
|
74
|
+
expect(receipt).not.toBeNull();
|
|
75
|
+
|
|
76
|
+
const newTokenOnExistingContract = await creatorClient.createNew1155Token(
|
|
77
|
+
{
|
|
78
|
+
contract: {
|
|
79
|
+
name: "testContract2",
|
|
80
|
+
uri: demoContractMetadataURI,
|
|
81
|
+
},
|
|
82
|
+
tokenMetadataURI: demoTokenMetadataURI,
|
|
83
|
+
account: creatorAccount,
|
|
84
|
+
mintToCreatorCount: 1,
|
|
85
|
+
},
|
|
86
|
+
);
|
|
87
|
+
expect(newTokenOnExistingContract.contractAddress).to.be.equal(
|
|
88
|
+
"0xb1A8928dF830C21eD682949Aa8A83C1C215194d3",
|
|
89
|
+
);
|
|
90
|
+
expect(newTokenOnExistingContract.contractExists).to.be.true;
|
|
91
|
+
const { request: simulateRequest } = await publicClient.simulateContract(
|
|
92
|
+
newTokenOnExistingContract.request,
|
|
93
|
+
);
|
|
94
|
+
const newHash = await walletClient.writeContract(simulateRequest);
|
|
95
|
+
const newReceipt = await publicClient.waitForTransactionReceipt({
|
|
96
|
+
hash: newHash,
|
|
97
|
+
});
|
|
98
|
+
const tokenId = getTokenIdFromCreateReceipt(newReceipt);
|
|
99
|
+
expect(tokenId).to.be.equal(2n);
|
|
100
|
+
expect(newReceipt).not.toBeNull();
|
|
101
|
+
},
|
|
102
|
+
20 * 1000,
|
|
103
|
+
);
|
|
104
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Address, parseAbi, parseEther } from "viem";
|
|
2
|
+
import { zora } from "viem/chains";
|
|
3
|
+
import { describe, expect } from "vitest";
|
|
4
|
+
import { createMintClient } from "./mint-client";
|
|
5
|
+
import { zoraCreator1155ImplABI } from "@zoralabs/protocol-deployments";
|
|
6
|
+
import { anvilTest, forkUrls, makeAnvilTest } from "src/anvil";
|
|
7
|
+
|
|
8
|
+
const erc721ABI = parseAbi([
|
|
9
|
+
"function balanceOf(address owner) public view returns (uint256)",
|
|
10
|
+
] as const);
|
|
11
|
+
|
|
12
|
+
describe("mint-helper", () => {
|
|
13
|
+
anvilTest(
|
|
14
|
+
"mints a new 1155 token",
|
|
15
|
+
async ({ viemClients }) => {
|
|
16
|
+
const { testClient, walletClient, publicClient } = viemClients;
|
|
17
|
+
const creatorAccount = (await walletClient.getAddresses())[0]!;
|
|
18
|
+
await testClient.setBalance({
|
|
19
|
+
address: creatorAccount,
|
|
20
|
+
value: parseEther("2000"),
|
|
21
|
+
});
|
|
22
|
+
const targetContract: Address =
|
|
23
|
+
"0xa2fea3537915dc6c7c7a97a82d1236041e6feb2e";
|
|
24
|
+
const targetTokenId = 1n;
|
|
25
|
+
const minter = createMintClient({ chain: zora });
|
|
26
|
+
|
|
27
|
+
const params = await minter.makePrepareMintTokenParams({
|
|
28
|
+
minterAccount: creatorAccount,
|
|
29
|
+
tokenId: targetTokenId,
|
|
30
|
+
tokenAddress: targetContract,
|
|
31
|
+
mintArguments: {
|
|
32
|
+
mintToAddress: creatorAccount,
|
|
33
|
+
quantityToMint: 1,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const oldBalance = await publicClient.readContract({
|
|
38
|
+
abi: zoraCreator1155ImplABI,
|
|
39
|
+
address: targetContract,
|
|
40
|
+
functionName: "balanceOf",
|
|
41
|
+
args: [creatorAccount, targetTokenId],
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const simulationResult = await publicClient.simulateContract(params);
|
|
45
|
+
|
|
46
|
+
const hash = await walletClient.writeContract(simulationResult.request);
|
|
47
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
48
|
+
const newBalance = await publicClient.readContract({
|
|
49
|
+
abi: zoraCreator1155ImplABI,
|
|
50
|
+
address: targetContract,
|
|
51
|
+
functionName: "balanceOf",
|
|
52
|
+
args: [creatorAccount, targetTokenId],
|
|
53
|
+
});
|
|
54
|
+
expect(receipt).to.not.be.null;
|
|
55
|
+
expect(oldBalance).to.be.equal(0n);
|
|
56
|
+
expect(newBalance).to.be.equal(1n);
|
|
57
|
+
},
|
|
58
|
+
12 * 1000,
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
makeAnvilTest({
|
|
62
|
+
forkUrl: forkUrls.zoraMainnet,
|
|
63
|
+
forkBlockNumber: 6133407,
|
|
64
|
+
})(
|
|
65
|
+
"mints a new 721 token",
|
|
66
|
+
async ({ viemClients }) => {
|
|
67
|
+
const { testClient, walletClient, publicClient } = viemClients;
|
|
68
|
+
const creatorAccount = (await walletClient.getAddresses())[0]!;
|
|
69
|
+
await testClient.setBalance({
|
|
70
|
+
address: creatorAccount,
|
|
71
|
+
value: parseEther("2000"),
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const targetContract: Address =
|
|
75
|
+
"0x7aae7e67515A2CbB8585C707Ca6db37BDd3EA839";
|
|
76
|
+
const targetTokenId = undefined;
|
|
77
|
+
const minter = createMintClient({ chain: zora });
|
|
78
|
+
|
|
79
|
+
const params = await minter.makePrepareMintTokenParams({
|
|
80
|
+
tokenId: targetTokenId,
|
|
81
|
+
tokenAddress: targetContract,
|
|
82
|
+
minterAccount: creatorAccount,
|
|
83
|
+
mintArguments: {
|
|
84
|
+
mintToAddress: creatorAccount,
|
|
85
|
+
quantityToMint: 1,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
const oldBalance = await publicClient.readContract({
|
|
89
|
+
abi: erc721ABI,
|
|
90
|
+
address: targetContract,
|
|
91
|
+
functionName: "balanceOf",
|
|
92
|
+
args: [creatorAccount],
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const simulated = await publicClient.simulateContract(params);
|
|
96
|
+
|
|
97
|
+
const hash = await walletClient.writeContract(simulated.request);
|
|
98
|
+
|
|
99
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
100
|
+
expect(receipt).not.to.be.null;
|
|
101
|
+
|
|
102
|
+
const newBalance = await publicClient.readContract({
|
|
103
|
+
abi: erc721ABI,
|
|
104
|
+
address: targetContract,
|
|
105
|
+
functionName: "balanceOf",
|
|
106
|
+
args: [creatorAccount],
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
expect(oldBalance).to.be.equal(0n);
|
|
110
|
+
expect(newBalance).to.be.equal(1n);
|
|
111
|
+
},
|
|
112
|
+
12 * 1000,
|
|
113
|
+
);
|
|
114
|
+
});
|