Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.

Commit c728575

Browse files
committed
Initialize Class
1 parent e342b37 commit c728575

File tree

5 files changed

+123
-6
lines changed

5 files changed

+123
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"ethers": "^5"
8383
},
8484
"dependencies": {
85-
"@thirdweb-dev/contracts": "2.3.9-1",
85+
"@thirdweb-dev/contracts": "^2.3.8",
8686
"@web-std/file": "^3.0.0",
8787
"buffer": "^6.0.3",
8888
"cross-fetch": "^3.1.5",

src/common/role.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const roleMap = {
1212
editor: "EDITOR_ROLE",
1313
lister: "LISTER_ROLE",
1414
asset: "ASSET_ROLE",
15+
unwrap: "UNWRAP_ROLE",
1516
} as const;
1617

1718
/**

src/contracts/multiwrap.ts

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import {
2+
ContractEncoder,
3+
ContractEvents,
4+
ContractMetadata,
5+
ContractPlatformFee,
6+
ContractPrimarySale,
7+
ContractRoles,
8+
ContractRoyalty,
9+
Erc721,
10+
GasCostEstimator,
11+
IStorage,
12+
NetworkOrSignerOrProvider,
13+
} from "../core";
14+
import { SDKOptions, TokenErc721ContractSchema } from "../schema";
15+
import {
16+
Multiwrap as MultiwrapContract,
17+
MultiwrapContract,
18+
SignatureDrop as SignatureDropContract,
19+
} from "contracts";
20+
import { ContractWrapper } from "../core/classes/contract-wrapper";
21+
import { ITokenBundle } from "../../lib/Multiwrap";
22+
import TokenStruct = ITokenBundle.TokenStruct;
23+
24+
/**
25+
* Multiwrap lets you wrap arbitrary ERC20, ERC721 and ERC1155 tokens you own into a single wrapped token / NFT.
26+
*
27+
* @example
28+
*
29+
* ```javascript
30+
* import { ThirdwebSDK } from "@thirdweb-dev/sdk";
31+
*
32+
* const sdk = new ThirdwebSDK("rinkeby");
33+
* const contract = sdk.getMultiwrap("{{contract_address}}");
34+
* ```
35+
*
36+
* @public
37+
*/
38+
export class Multiwrap extends Erc721<MultiwrapContract> {
39+
static contractType = "multiwrap" as const;
40+
static contractRoles = ["transfer", "minter", "unwrap", "asset"] as const;
41+
static contractAbi = require("../../abis/Multiwrap.json");
42+
43+
/**
44+
* @internal
45+
*/
46+
static schema = TokenErc721ContractSchema;
47+
48+
public encoder: ContractEncoder<MultiwrapContract>;
49+
public estimator: GasCostEstimator<MultiwrapContract>;
50+
public metadata: ContractMetadata<MultiwrapContract, typeof Multiwrap.schema>;
51+
public events: ContractEvents<MultiwrapContract>;
52+
public roles: ContractRoles<
53+
MultiwrapContract,
54+
typeof Multiwrap.contractRoles[number]
55+
>;
56+
57+
/**
58+
* Configure royalties
59+
* @remarks Set your own royalties for the entire contract or per token
60+
* @example
61+
* ```javascript
62+
* // royalties on the whole contract
63+
* contract.royalty.setDefaultRoyaltyInfo({
64+
* seller_fee_basis_points: 100, // 1%
65+
* fee_recipient: "0x..."
66+
* });
67+
* // override royalty for a particular token
68+
* contract.royalty.setTokenRoyaltyInfo(tokenId, {
69+
* seller_fee_basis_points: 500, // 5%
70+
* fee_recipient: "0x..."
71+
* });
72+
* ```
73+
*/
74+
public royalty: ContractRoyalty<MultiwrapContract, typeof Multiwrap.schema>;
75+
76+
constructor(
77+
network: NetworkOrSignerOrProvider,
78+
address: string,
79+
storage: IStorage,
80+
options: SDKOptions = {},
81+
contractWrapper = new ContractWrapper<MultiwrapContract>(
82+
network,
83+
address,
84+
Multiwrap.contractAbi,
85+
options,
86+
),
87+
) {
88+
super(contractWrapper, storage, options);
89+
this.metadata = new ContractMetadata(
90+
this.contractWrapper,
91+
Multiwrap.schema,
92+
this.storage,
93+
);
94+
95+
this.roles = new ContractRoles(
96+
this.contractWrapper,
97+
Multiwrap.contractRoles,
98+
);
99+
this.encoder = new ContractEncoder(this.contractWrapper);
100+
this.estimator = new GasCostEstimator(this.contractWrapper);
101+
this.events = new ContractEvents(this.contractWrapper);
102+
this.royalty = new ContractRoyalty(this.contractWrapper, this.metadata);
103+
}
104+
105+
public async wrap(
106+
tokens: TokenStruct,
107+
wrappedTokenUri: string
108+
recipient:
109+
)
110+
}

src/core/classes/erc-721.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
DropERC721,
1212
IERC721Supply,
1313
IMintableERC721,
14+
Multiwrap,
1415
SignatureDrop,
1516
TokenERC721,
1617
} from "contracts";
@@ -31,7 +32,12 @@ import { DetectableFeature } from "../interfaces/DetectableFeature";
3132
* @public
3233
*/
3334
export class Erc721<
34-
T extends SignatureDrop | DropERC721 | TokenERC721 | BaseERC721 = BaseERC721,
35+
T extends
36+
| Multiwrap
37+
| SignatureDrop
38+
| DropERC721
39+
| TokenERC721
40+
| BaseERC721 = BaseERC721,
3541
> implements UpdateableNetwork, DetectableFeature
3642
{
3743
featureName = FEATURE_NFT.name;

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -802,10 +802,10 @@
802802
"@swc/core-win32-ia32-msvc" "1.2.194"
803803
"@swc/core-win32-x64-msvc" "1.2.194"
804804

805-
"@thirdweb-dev/contracts@2.3.9-1":
806-
version "2.3.9-1"
807-
resolved "https://registry.yarnpkg.com/@thirdweb-dev/contracts/-/contracts-2.3.9-1.tgz#98dd38ed67ee505a38cf888d5ccd36e27c606674"
808-
integrity sha512-AMbTw92sKZgIS5udTClX+RNRVASbcrVNjQzlivLoxJR25Zhi91Ul+OcllYFANI0WTslYR6Riq9NGsAZRW8I1FA==
805+
"@thirdweb-dev/contracts@^2.3.8":
806+
version "2.3.8"
807+
resolved "https://registry.yarnpkg.com/@thirdweb-dev/contracts/-/contracts-2.3.8.tgz#7c565b4d4f1917bbbc76dc48c9f6bffc8c6eabdd"
808+
integrity sha512-cSVwIzPSYaS8gFlkq4r+G9UyVwr/62uE+p6SzrZFXYCbeCJwJTml3VnrVEptJ7g8RukL4Lh6uwQ6IPtgMTY4cQ==
809809

810810
"@tsconfig/node10@^1.0.7":
811811
version "1.0.8"

0 commit comments

Comments
 (0)