Skip to content

Commit 98ab5af

Browse files
Krishang NadgaudaKrishang Nadgauda
authored andcommitted
add multiwrap deploy script
1 parent 0bc2a6c commit 98ab5af

File tree

3 files changed

+79
-258
lines changed

3 files changed

+79
-258
lines changed

docs/IMultiwrap.md

Lines changed: 1 addition & 258 deletions
Original file line numberDiff line numberDiff line change
@@ -4,234 +4,12 @@
44

55

66

7-
Thirdweb's Multiwrap contract lets you wrap arbitrary ERC20, ERC721 and ERC1155 tokens you own into a single wrapped token / NFT. A wrapped NFT can be unwrapped i.e. burned in exchange for its underlying contents.
7+
Thirdweb's Multiwrap contract lets you wrap arbitrary ERC20, ERC721 and ERC1155 tokens you own into a single wrapped token / NFT. A wrapped NFT can be unwrapped i.e. burned in exchange for its underlying contents.
88

99

1010

1111
## Methods
1212

13-
### contractType
14-
15-
```solidity
16-
function contractType() external pure returns (bytes32)
17-
```
18-
19-
20-
21-
*Returns the module type of the contract.*
22-
23-
24-
#### Returns
25-
26-
| Name | Type | Description |
27-
|---|---|---|
28-
| _0 | bytes32 | undefined
29-
30-
### contractURI
31-
32-
```solidity
33-
function contractURI() external view returns (string)
34-
```
35-
36-
37-
38-
*Returns the metadata URI of the contract.*
39-
40-
41-
#### Returns
42-
43-
| Name | Type | Description |
44-
|---|---|---|
45-
| _0 | string | undefined
46-
47-
### contractVersion
48-
49-
```solidity
50-
function contractVersion() external pure returns (uint8)
51-
```
52-
53-
54-
55-
*Returns the version of the contract.*
56-
57-
58-
#### Returns
59-
60-
| Name | Type | Description |
61-
|---|---|---|
62-
| _0 | uint8 | undefined
63-
64-
### getDefaultRoyaltyInfo
65-
66-
```solidity
67-
function getDefaultRoyaltyInfo() external view returns (address, uint16)
68-
```
69-
70-
71-
72-
*Returns the royalty recipient and fee bps.*
73-
74-
75-
#### Returns
76-
77-
| Name | Type | Description |
78-
|---|---|---|
79-
| _0 | address | undefined
80-
| _1 | uint16 | undefined
81-
82-
### getRoyaltyInfoForToken
83-
84-
```solidity
85-
function getRoyaltyInfoForToken(uint256 tokenId) external view returns (address, uint16)
86-
```
87-
88-
89-
90-
*Returns the royalty recipient for a particular token Id.*
91-
92-
#### Parameters
93-
94-
| Name | Type | Description |
95-
|---|---|---|
96-
| tokenId | uint256 | undefined
97-
98-
#### Returns
99-
100-
| Name | Type | Description |
101-
|---|---|---|
102-
| _0 | address | undefined
103-
| _1 | uint16 | undefined
104-
105-
### owner
106-
107-
```solidity
108-
function owner() external view returns (address)
109-
```
110-
111-
112-
113-
*Returns the owner of the contract.*
114-
115-
116-
#### Returns
117-
118-
| Name | Type | Description |
119-
|---|---|---|
120-
| _0 | address | undefined
121-
122-
### royaltyInfo
123-
124-
```solidity
125-
function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount)
126-
```
127-
128-
129-
130-
*Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of exchange. The royalty amount is denominated and should be payed in that same unit of exchange.*
131-
132-
#### Parameters
133-
134-
| Name | Type | Description |
135-
|---|---|---|
136-
| tokenId | uint256 | undefined
137-
| salePrice | uint256 | undefined
138-
139-
#### Returns
140-
141-
| Name | Type | Description |
142-
|---|---|---|
143-
| receiver | address | undefined
144-
| royaltyAmount | uint256 | undefined
145-
146-
### setContractURI
147-
148-
```solidity
149-
function setContractURI(string _uri) external nonpayable
150-
```
151-
152-
153-
154-
*Sets contract URI for the storefront-level metadata of the contract. Only module admin can call this function.*
155-
156-
#### Parameters
157-
158-
| Name | Type | Description |
159-
|---|---|---|
160-
| _uri | string | undefined
161-
162-
### setDefaultRoyaltyInfo
163-
164-
```solidity
165-
function setDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) external nonpayable
166-
```
167-
168-
169-
170-
*Lets a module admin update the royalty bps and recipient.*
171-
172-
#### Parameters
173-
174-
| Name | Type | Description |
175-
|---|---|---|
176-
| _royaltyRecipient | address | undefined
177-
| _royaltyBps | uint256 | undefined
178-
179-
### setOwner
180-
181-
```solidity
182-
function setOwner(address _newOwner) external nonpayable
183-
```
184-
185-
186-
187-
*Lets a module admin set a new owner for the contract. The new owner must be a module admin.*
188-
189-
#### Parameters
190-
191-
| Name | Type | Description |
192-
|---|---|---|
193-
| _newOwner | address | undefined
194-
195-
### setRoyaltyInfoForToken
196-
197-
```solidity
198-
function setRoyaltyInfoForToken(uint256 tokenId, address recipient, uint256 bps) external nonpayable
199-
```
200-
201-
202-
203-
*Lets a module admin set the royalty recipient for a particular token Id.*
204-
205-
#### Parameters
206-
207-
| Name | Type | Description |
208-
|---|---|---|
209-
| tokenId | uint256 | undefined
210-
| recipient | address | undefined
211-
| bps | uint256 | undefined
212-
213-
### supportsInterface
214-
215-
```solidity
216-
function supportsInterface(bytes4 interfaceId) external view returns (bool)
217-
```
218-
219-
220-
221-
*Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.*
222-
223-
#### Parameters
224-
225-
| Name | Type | Description |
226-
|---|---|---|
227-
| interfaceId | bytes4 | undefined
228-
229-
#### Returns
230-
231-
| Name | Type | Description |
232-
|---|---|---|
233-
| _0 | bool | undefined
234-
23513
### unwrap
23614

23715
```solidity
@@ -277,23 +55,6 @@ Wrap multiple ERC1155, ERC721, ERC20 tokens into a single wrapped NFT.
27755

27856
## Events
27957

280-
### DefaultRoyalty
281-
282-
```solidity
283-
event DefaultRoyalty(address newRoyaltyRecipient, uint256 newRoyaltyBps)
284-
```
285-
286-
287-
288-
289-
290-
#### Parameters
291-
292-
| Name | Type | Description |
293-
|---|---|---|
294-
| newRoyaltyRecipient | address | undefined |
295-
| newRoyaltyBps | uint256 | undefined |
296-
29758
### OwnerUpdated
29859

29960
```solidity
@@ -311,24 +72,6 @@ event OwnerUpdated(address prevOwner, address newOwner)
31172
| prevOwner | address | undefined |
31273
| newOwner | address | undefined |
31374

314-
### RoyaltyForToken
315-
316-
```solidity
317-
event RoyaltyForToken(uint256 indexed tokenId, address royaltyRecipient, uint256 royaltyBps)
318-
```
319-
320-
321-
322-
323-
324-
#### Parameters
325-
326-
| Name | Type | Description |
327-
|---|---|---|
328-
| tokenId `indexed` | uint256 | undefined |
329-
| royaltyRecipient | address | undefined |
330-
| royaltyBps | uint256 | undefined |
331-
33275
### TokensUnwrapped
33376

33477
```solidity

docs/Multiwrap.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,28 @@ function getRoyaltyInfoForToken(uint256 _tokenId) external view returns (address
247247
| _0 | address | undefined
248248
| _1 | uint16 | undefined
249249

250+
### getWrappedContents
251+
252+
```solidity
253+
function getWrappedContents(uint256 _tokenId) external view returns (struct IMultiwrap.Token[] contents)
254+
```
255+
256+
257+
258+
*Returns the underlygin contents of a wrapped NFT.*
259+
260+
#### Parameters
261+
262+
| Name | Type | Description |
263+
|---|---|---|
264+
| _tokenId | uint256 | undefined
265+
266+
#### Returns
267+
268+
| Name | Type | Description |
269+
|---|---|---|
270+
| contents | IMultiwrap.Token[] | undefined
271+
250272
### grantRole
251273

252274
```solidity

scripts/deploy/multiwrap.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import hre, { ethers } from "hardhat";
2+
3+
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
4+
5+
import { TWFactory } from "typechain/TWFactory";
6+
import { Multiwrap } from "typechain/Multiwrap";
7+
8+
async function main() {
9+
10+
const [caller]: SignerWithAddress[] = await ethers.getSigners();
11+
12+
const nativeTokenWrapperAddress: string = ethers.constants.AddressZero; // replace
13+
const twFactoryAddress: string = ethers.constants.AddressZero; // replace
14+
15+
const twFactory: TWFactory = await ethers.getContractAt('TWFactory', twFactoryAddress);
16+
17+
const hasFactoryRole = await twFactory.hasRole(
18+
ethers.utils.solidityKeccak256(["string"], ["FACTORY_ROLE"]),
19+
caller.address
20+
)
21+
if(!hasFactoryRole) {
22+
throw new Error("Caller does not have FACTORY_ROLE on factory");
23+
}
24+
const multiwrap: Multiwrap = await ethers.getContractFactory("Multiwrap").then(f => f.deploy(nativeTokenWrapperAddress));
25+
26+
console.log("Deploying Multiwrap \ntransaction: ", multiwrap.deployTransaction.hash, "\naddress: ", multiwrap.address);
27+
28+
console.log("\n")
29+
30+
const addImplementationTx = await twFactory.addImplementation(multiwrap.address)
31+
console.log("Adding Multiwrap implementation to TWFactory: ", addImplementationTx.hash);
32+
await addImplementationTx.wait();
33+
34+
console.log("\n")
35+
36+
console.log("Verifying contract.")
37+
await verify(multiwrap.address, [nativeTokenWrapperAddress]);
38+
}
39+
40+
async function verify(address: string, args: any[]) {
41+
try {
42+
return await hre.run("verify:verify", {
43+
address: address,
44+
constructorArguments: args,
45+
});
46+
} catch (e) {
47+
console.log(address, args, e);
48+
}
49+
}
50+
51+
main()
52+
.then(() => process.exit(0))
53+
.catch((e) => {
54+
console.error(e)
55+
process.exit(1)
56+
})

0 commit comments

Comments
 (0)