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

Commit

Permalink
Initialize Class
Browse files Browse the repository at this point in the history
  • Loading branch information
ndeto committed May 26, 2022
1 parent e342b37 commit c728575
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"ethers": "^5"
},
"dependencies": {
"@thirdweb-dev/contracts": "2.3.9-1",
"@thirdweb-dev/contracts": "^2.3.8",
"@web-std/file": "^3.0.0",
"buffer": "^6.0.3",
"cross-fetch": "^3.1.5",
Expand Down
1 change: 1 addition & 0 deletions src/common/role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const roleMap = {
editor: "EDITOR_ROLE",
lister: "LISTER_ROLE",
asset: "ASSET_ROLE",
unwrap: "UNWRAP_ROLE",
} as const;

/**
Expand Down
110 changes: 110 additions & 0 deletions src/contracts/multiwrap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import {
ContractEncoder,
ContractEvents,
ContractMetadata,
ContractPlatformFee,
ContractPrimarySale,
ContractRoles,
ContractRoyalty,
Erc721,
GasCostEstimator,
IStorage,
NetworkOrSignerOrProvider,
} from "../core";
import { SDKOptions, TokenErc721ContractSchema } from "../schema";
import {
Multiwrap as MultiwrapContract,
MultiwrapContract,
SignatureDrop as SignatureDropContract,
} from "contracts";
import { ContractWrapper } from "../core/classes/contract-wrapper";
import { ITokenBundle } from "../../lib/Multiwrap";
import TokenStruct = ITokenBundle.TokenStruct;

/**
* Multiwrap lets you wrap arbitrary ERC20, ERC721 and ERC1155 tokens you own into a single wrapped token / NFT.
*
* @example
*
* ```javascript
* import { ThirdwebSDK } from "@thirdweb-dev/sdk";
*
* const sdk = new ThirdwebSDK("rinkeby");
* const contract = sdk.getMultiwrap("{{contract_address}}");
* ```
*
* @public
*/
export class Multiwrap extends Erc721<MultiwrapContract> {
static contractType = "multiwrap" as const;
static contractRoles = ["transfer", "minter", "unwrap", "asset"] as const;
static contractAbi = require("../../abis/Multiwrap.json");

/**
* @internal
*/
static schema = TokenErc721ContractSchema;

public encoder: ContractEncoder<MultiwrapContract>;
public estimator: GasCostEstimator<MultiwrapContract>;
public metadata: ContractMetadata<MultiwrapContract, typeof Multiwrap.schema>;
public events: ContractEvents<MultiwrapContract>;
public roles: ContractRoles<
MultiwrapContract,
typeof Multiwrap.contractRoles[number]
>;

/**
* Configure royalties
* @remarks Set your own royalties for the entire contract or per token
* @example
* ```javascript
* // royalties on the whole contract
* contract.royalty.setDefaultRoyaltyInfo({
* seller_fee_basis_points: 100, // 1%
* fee_recipient: "0x..."
* });
* // override royalty for a particular token
* contract.royalty.setTokenRoyaltyInfo(tokenId, {
* seller_fee_basis_points: 500, // 5%
* fee_recipient: "0x..."
* });
* ```
*/
public royalty: ContractRoyalty<MultiwrapContract, typeof Multiwrap.schema>;

constructor(
network: NetworkOrSignerOrProvider,
address: string,
storage: IStorage,
options: SDKOptions = {},
contractWrapper = new ContractWrapper<MultiwrapContract>(
network,
address,
Multiwrap.contractAbi,
options,
),
) {
super(contractWrapper, storage, options);
this.metadata = new ContractMetadata(
this.contractWrapper,
Multiwrap.schema,
this.storage,
);

this.roles = new ContractRoles(
this.contractWrapper,
Multiwrap.contractRoles,
);
this.encoder = new ContractEncoder(this.contractWrapper);
this.estimator = new GasCostEstimator(this.contractWrapper);
this.events = new ContractEvents(this.contractWrapper);
this.royalty = new ContractRoyalty(this.contractWrapper, this.metadata);
}

public async wrap(
tokens: TokenStruct,
wrappedTokenUri: string
recipient:
)
}
8 changes: 7 additions & 1 deletion src/core/classes/erc-721.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
DropERC721,
IERC721Supply,
IMintableERC721,
Multiwrap,
SignatureDrop,
TokenERC721,
} from "contracts";
Expand All @@ -31,7 +32,12 @@ import { DetectableFeature } from "../interfaces/DetectableFeature";
* @public
*/
export class Erc721<
T extends SignatureDrop | DropERC721 | TokenERC721 | BaseERC721 = BaseERC721,
T extends
| Multiwrap
| SignatureDrop
| DropERC721
| TokenERC721
| BaseERC721 = BaseERC721,
> implements UpdateableNetwork, DetectableFeature
{
featureName = FEATURE_NFT.name;
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -802,10 +802,10 @@
"@swc/core-win32-ia32-msvc" "1.2.194"
"@swc/core-win32-x64-msvc" "1.2.194"

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

"@tsconfig/node10@^1.0.7":
version "1.0.8"
Expand Down

0 comments on commit c728575

Please sign in to comment.