UNPKG

kamiweb3-sdk

Version:

TypeScript SDK for KAMI721-C, KAMI721-AC, and KAMI1155-C smart contracts

182 lines (181 loc) 10.4 kB
import { Contract, BigNumberish, AddressLike, BytesLike, Overrides, ContractTransactionResponse, InterfaceAbi } from 'ethers'; import { RoyaltyData, SignerOrProvider, RentalDetails } from '../types'; /** * Wraps an instance of the KAMI1155C contract (standard or upgradeable proxy) to provide typed methods. */ export declare class ERC1155CWrapper { readonly contract: Contract; readonly address: string; readonly abi: InterfaceAbi; /** * Creates an instance of ERC1155CWrapper. * @param address The address of the standard contract or the proxy contract. * @param signerOrProvider A Signer (for transactions) or Provider (for read-only). * @param contractAbi (Optional) The ABI to use. Defaults to the standard KAMI1155C ABI. Provide the KAMI1155CUpgradeable ABI when attaching to a proxy. */ constructor(address: AddressLike, signerOrProvider: SignerOrProvider, contractAbi?: InterfaceAbi); /** * Gets the balance of a specific token ID for an account. * @param account The address of the account. * @param id The ID of the token. * @returns A promise that resolves to the balance. */ balanceOf(account: AddressLike, id: BigNumberish): Promise<bigint>; /** * Gets the balances of multiple token IDs for multiple accounts. * @param accounts An array of account addresses. * @param ids An array of token IDs. * @returns A promise that resolves to an array of balances. */ balanceOfBatch(accounts: AddressLike[], ids: BigNumberish[]): Promise<bigint[]>; /** * Safely transfers tokens from one address to another. * Requires the caller to be the owner, approved, or the approved operator. * @param from The address to transfer from. * @param to The address to transfer to. * @param id The ID of the token to transfer. * @param amount The amount of tokens to transfer. * @param data Additional data with no specified format. * @param overrides Optional transaction overrides. * @returns A promise that resolves to the transaction response. */ safeTransferFrom(from: AddressLike, to: AddressLike, id: BigNumberish, amount: BigNumberish, data: BytesLike, overrides?: Overrides): Promise<ContractTransactionResponse>; /** * Safely transfers multiple token types from one address to another. * Requires the caller to be the owner, approved, or the approved operator. * @param from The address to transfer from. * @param to The address to transfer to. * @param ids An array of token IDs to transfer. * @param amounts An array of amounts corresponding to each token ID. * @param data Additional data with no specified format. * @param overrides Optional transaction overrides. * @returns A promise that resolves to the transaction response. */ safeBatchTransferFrom(from: AddressLike, to: AddressLike, ids: BigNumberish[], amounts: BigNumberish[], data: BytesLike, overrides?: Overrides): Promise<ContractTransactionResponse>; /** * Enables or disables approval for a third party ("operator") to manage all of the caller's tokens. * @param operator Address to add to the set of authorized operators. * @param approved True if the operator is approved, false to revoke approval. * @param overrides Optional transaction overrides. * @returns A promise that resolves to the transaction response. */ setApprovalForAll(operator: AddressLike, approved: boolean, overrides?: Overrides): Promise<ContractTransactionResponse>; /** * Queries the approval status of an operator for a given owner. * @param owner The owner of the tokens. * @param operator The address of the operator. * @returns True if the operator is approved, false otherwise. */ isApprovedForAll(owner: AddressLike, operator: AddressLike): Promise<boolean>; /** * Returns the URI for a given token ID. * @param id The ID of the token. * @returns A promise that resolves to the URI string. */ uri(id: BigNumberish): Promise<string>; supportsInterface(interfaceId: BytesLike): Promise<boolean>; /** * Mints new tokens of a specific ID to a specified address. * Requires MINTER_ROLE. * Requires the platform to have approved the contract for the total USDC cost if applicable (verify fee logic). * @param to The address to mint to. * @param id The ID of the token to mint. * @param amount The amount of tokens to mint. * @param data Optional data field. * @param overrides Optional transaction overrides. * @returns A promise that resolves to the transaction response. */ mint(to: AddressLike, id: BigNumberish, amount: BigNumberish, data?: BytesLike, overrides?: Overrides): Promise<ContractTransactionResponse>; /** * Mints batches of tokens to a specified address. * Requires MINTER_ROLE. * @param to The address to mint to. * @param ids Array of token IDs to mint. * @param amounts Array of amounts corresponding to IDs. * @param data Optional data field. * @param overrides Optional transaction overrides. * @returns A promise that resolves to the transaction response. */ mintBatch(to: AddressLike, ids: BigNumberish[], amounts: BigNumberish[], data?: BytesLike, overrides?: Overrides): Promise<ContractTransactionResponse>; /** * Sells tokens from the owner to a buyer. * Requires the seller (signer) to own or be approved for the tokens. * Requires the buyer to have approved the contract to spend the salePrice in USDC. * @param to The address of the buyer. * @param id The ID of the token being sold. * @param amount The amount of tokens being sold. * @param salePrice The total price for the amount in the smallest unit of USDC. * @param overrides Optional transaction overrides. * @returns A promise that resolves to the transaction response. */ sellToken(to: AddressLike, id: BigNumberish, amount: BigNumberish, salePrice: BigNumberish, overrides?: Overrides): Promise<ContractTransactionResponse>; /** * Rents tokens for a specified duration. * Requires the renter (signer) to approve the contract to spend the rentalPrice in USDC. * @param id The ID of the token to rent. * @param duration The rental duration in seconds. * @param rentalPrice The price in the smallest unit of USDC. * @param overrides Optional transaction overrides. * @returns A promise that resolves to the transaction response. */ rentToken(id: BigNumberish, duration: BigNumberish, rentalPrice: BigNumberish, overrides?: Overrides): Promise<ContractTransactionResponse>; /** * Ends a rental period early. * @param id The ID of the token whose rental is ending. * @param overrides Optional transaction overrides. * @returns A promise that resolves to the transaction response. */ endRental(id: BigNumberish, overrides?: Overrides): Promise<ContractTransactionResponse>; /** * Extends an existing rental. * Requires the renter (signer) to approve the additional payment. * @param id The ID of the token being extended. * @param additionalDuration Additional duration in seconds. * @param additionalPayment Additional payment in smallest USDC unit. * @param overrides Optional transaction overrides. * @returns A promise that resolves to the transaction response. */ extendRental(id: BigNumberish, additionalDuration: BigNumberish, additionalPayment: BigNumberish, overrides?: Overrides): Promise<ContractTransactionResponse>; /** * Gets the rental details for a specific token ID. * @param id The token ID. * @returns A promise resolving to the rental details. */ getRentalDetails(id: BigNumberish): Promise<RentalDetails>; setMintRoyalties(royalties: RoyaltyData[], overrides?: Overrides): Promise<ContractTransactionResponse>; setTransferRoyalties(royalties: RoyaltyData[], overrides?: Overrides): Promise<ContractTransactionResponse>; setTokenMintRoyalties(id: BigNumberish, royalties: RoyaltyData[], overrides?: Overrides): Promise<ContractTransactionResponse>; setTokenTransferRoyalties(id: BigNumberish, royalties: RoyaltyData[], overrides?: Overrides): Promise<ContractTransactionResponse>; getMintRoyaltyReceivers(id: BigNumberish): Promise<RoyaltyData[]>; getTransferRoyaltyReceivers(id: BigNumberish): Promise<RoyaltyData[]>; setMintPrice(newMintPrice: BigNumberish, overrides?: Overrides): Promise<ContractTransactionResponse>; getMintPrice(): Promise<bigint>; setPlatformCommission(newPercentage: BigNumberish, newPlatformAddress: AddressLike, overrides?: Overrides): Promise<ContractTransactionResponse>; getPlatformAddress(): Promise<string>; getPlatformCommissionPercentage(): Promise<bigint>; setBaseURI(baseURI: string, overrides?: Overrides): Promise<ContractTransactionResponse>; getBaseURI(): Promise<string>; pause(overrides?: Overrides): Promise<ContractTransactionResponse>; paused(): Promise<boolean>; unpause(overrides?: Overrides): Promise<ContractTransactionResponse>; hasRole(role: BytesLike, account: AddressLike): Promise<boolean>; getRoleAdmin(role: BytesLike): Promise<string>; grantRole(role: BytesLike, account: AddressLike, overrides?: Overrides): Promise<ContractTransactionResponse>; revokeRole(role: BytesLike, account: AddressLike, overrides?: Overrides): Promise<ContractTransactionResponse>; renounceRole(role: BytesLike, account: AddressLike, overrides?: Overrides): Promise<ContractTransactionResponse>; private requireSigner; /** * Helper to check if the current signer has a specific role. * Throws an error if the signer is missing or lacks the role. * @param role The role keccak256 hash (e.g., OWNER_ROLE). * @param errorMessage Optional custom error message. */ private requireRole; /** * Connects a different signer or provider to the contract wrapper. * Preserves the ABI used when the original wrapper was created. * @param signerOrProvider The new signer or provider. * @returns A new ERC1155CWrapper instance connected with the new signer/provider. */ connect(signerOrProvider: SignerOrProvider): ERC1155CWrapper; }