|
| 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 | +} |
0 commit comments