UNPKG

@river-build/web3

Version:

Dapps for our Space and Registry contracts

211 lines 13.2 kB
import { BasicRoleInfo, ChannelDetails, ChannelMetadata, EntitlementModuleType, Permission, PricingModuleStruct, RoleDetails, VersionedRuleData } from '../ContractTypes'; import { BytesLike, ContractReceipt, ContractTransaction, ethers } from 'ethers'; import { CreateLegacySpaceParams, CreateSpaceParams, ISpaceDapp, TransactionOpts, LegacyUpdateRoleParams, UpdateRoleParams, SetChannelPermissionOverridesParams, ClearChannelPermissionOverridesParams, RemoveChannelParams, UpdateChannelParams } from '../ISpaceDapp'; import { IRolesBase } from './IRolesShim'; import { Space } from './Space'; import { SpaceRegistrar } from './SpaceRegistrar'; import { BaseChainConfig } from '../IStaticContractsInfo'; import { WalletLink } from './WalletLink'; import { SpaceInfo } from '../types'; import { IRuleEntitlementBase, IRuleEntitlementV2Base, RiverAirdropDapp } from './index'; import { PricingModules } from './PricingModules'; import { XchainConfig } from '../entitlement'; import { PlatformRequirements } from './PlatformRequirements'; import { EntitlementCache, Keyable } from '../EntitlementCache'; import { TipEventObject } from '@river-build/generated/dev/typings/ITipping'; type EntitlementData = { entitlementType: EntitlementModuleType; ruleEntitlement: VersionedRuleData | undefined; userEntitlement: string[] | undefined; }; declare class EntitlementRequest implements Keyable { spaceId: string; channelId: string; userId: string; permission: Permission; constructor(spaceId: string, channelId: string, userId: string, permission: Permission); toKey(): string; } type EntitledWallet = string | undefined; export declare class SpaceDapp implements ISpaceDapp { private isLegacySpaceCache; readonly config: BaseChainConfig; readonly provider: ethers.providers.Provider; readonly spaceRegistrar: SpaceRegistrar; readonly pricingModules: PricingModules; readonly walletLink: WalletLink; readonly platformRequirements: PlatformRequirements; readonly airdrop: RiverAirdropDapp; readonly entitlementCache: EntitlementCache<EntitlementRequest, EntitlementData[]>; readonly entitledWalletCache: EntitlementCache<EntitlementRequest, EntitledWallet>; readonly entitlementEvaluationCache: EntitlementCache<EntitlementRequest, boolean>; constructor(config: BaseChainConfig, provider: ethers.providers.Provider); isLegacySpace(spaceId: string): Promise<boolean>; addRoleToChannel(spaceId: string, channelNetworkId: string, roleId: number, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; waitForRoleCreated(spaceId: string, txn: ContractTransaction): Promise<{ roleId: number | undefined; error: Error | undefined; }>; banWalletAddress(spaceId: string, walletAddress: string, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; unbanWalletAddress(spaceId: string, walletAddress: string, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; walletAddressIsBanned(spaceId: string, walletAddress: string): Promise<boolean>; bannedWalletAddresses(spaceId: string): Promise<string[]>; createLegacySpace(params: CreateLegacySpaceParams, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; createSpace(params: CreateSpaceParams, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; createChannel(spaceId: string, channelName: string, channelDescription: string, channelNetworkId: string, roleIds: number[], signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; createChannelWithPermissionOverrides(spaceId: string, channelName: string, channelDescription: string, channelNetworkId: string, roles: { roleId: number; permissions: Permission[]; }[], signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; legacyCreateRole(spaceId: string, roleName: string, permissions: Permission[], users: string[], ruleData: IRuleEntitlementBase.RuleDataStruct, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; createRole(spaceId: string, roleName: string, permissions: Permission[], users: string[], ruleData: IRuleEntitlementV2Base.RuleDataV2Struct, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; deleteRole(spaceId: string, roleId: number, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; getChannels(spaceId: string): Promise<ChannelMetadata[]>; tokenURI(spaceId: string): Promise<string>; memberTokenURI(spaceId: string, tokenId: string): Promise<string>; getChannelDetails(spaceId: string, channelNetworkId: string): Promise<ChannelDetails | null>; getPermissionsByRoleId(spaceId: string, roleId: number): Promise<Permission[]>; getRole(spaceId: string, roleId: number): Promise<RoleDetails | null>; getRoles(spaceId: string): Promise<BasicRoleInfo[]>; getSpaceInfo(spaceId: string): Promise<SpaceInfo | undefined>; updateSpaceInfo(spaceId: string, name: string, uri: string, shortDescription: string, longDescription: string, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; private decodeEntitlementData; private getEntitlementsForPermission; private getEntitlementsForPermissionUncached; private getChannelEntitlementsForPermission; private getChannelEntitlementsForPermissionUncached; getLinkedWallets(wallet: string): Promise<string[]>; getLinkedWalletsWithDelegations(wallet: string): Promise<string[]>; private evaluateEntitledWallet; /** * Checks if user has a wallet entitled to join a space based on the minter role rule entitlements */ getEntitledWalletForJoiningSpace(spaceId: string, rootKey: string, xchainConfig: XchainConfig): Promise<EntitledWallet>; private getEntitledWalletForJoiningSpaceUncached; isEntitledToSpace(spaceId: string, user: string, permission: Permission): Promise<boolean>; isEntitledToSpaceUncached(spaceId: string, user: string, permission: Permission): Promise<boolean>; isEntitledToChannel(spaceId: string, channelNetworkId: string, user: string, permission: Permission, xchainConfig?: XchainConfig): Promise<boolean>; isEntitledToChannelUncached(spaceId: string, channelNetworkId: string, user: string, permission: Permission, xchainConfig: XchainConfig): Promise<boolean>; parseSpaceFactoryError(error: unknown): Error; parseSpaceError(spaceId: string, error: unknown): Error; /** * Attempts to parse an error against all contracts * If you're error is not showing any data with this call, make sure the contract is listed either in parseSpaceError or nonSpaceContracts * @param args * @returns */ parseAllContractErrors(args: { spaceId?: string; error: unknown; }): Error; parseSpaceLogs(spaceId: string, logs: ethers.providers.Log[]): Promise<(ethers.utils.LogDescription | undefined)[]>; updateChannel(params: UpdateChannelParams, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; encodedUpdateChannelData(space: Space, params: UpdateChannelParams): Promise<BytesLike[]>; removeChannel(params: RemoveChannelParams, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; legacyUpdateRole(params: LegacyUpdateRoleParams, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; updateRole(params: UpdateRoleParams, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; getChannelPermissionOverrides(spaceId: string, roleId: number, channelNetworkId: string): Promise<Permission[]>; setChannelPermissionOverrides(params: SetChannelPermissionOverridesParams, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; clearChannelPermissionOverrides(params: ClearChannelPermissionOverridesParams, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; setSpaceAccess(spaceId: string, disabled: boolean, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; /** * * @param spaceId * @param priceInWei * @param signer */ setMembershipPrice(spaceId: string, priceInWei: ethers.BigNumberish, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; setMembershipPricingModule(spaceId: string, pricingModule: string, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; setMembershipLimit(spaceId: string, limit: number, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; setMembershipFreeAllocation(spaceId: string, freeAllocation: number, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; prepayMembership(spaceId: string, supply: number, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; getPrepaidMembershipSupply(spaceId: string): Promise<ethers.BigNumber>; setChannelAccess(spaceId: string, channelNetworkId: string, disabled: boolean, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; getSpaceMembershipTokenAddress(spaceId: string): Promise<string>; getJoinSpacePriceDetails(spaceId: string): Promise<{ price: ethers.BigNumber; prepaidSupply: ethers.BigNumber; remainingFreeSupply: ethers.BigNumber; }>; getMembershipFreeAllocation(spaceId: string): Promise<ethers.BigNumber>; joinSpace(spaceId: string, recipient: string, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<{ issued: true; tokenId: string; } | { issued: false; tokenId: undefined; }>; hasSpaceMembership(spaceId: string, address: string): Promise<boolean>; getMembershipSupply(spaceId: string): Promise<{ totalSupply: number; }>; getMembershipInfo(spaceId: string): Promise<{ price: ethers.BigNumber; maxSupply: number; currency: string; feeRecipient: string; duration: number; totalSupply: number; pricingModule: string; prepaidSupply: number; remainingFreeSupply: number; }>; getWalletLink(): WalletLink; getSpace(spaceId: string): Space | undefined; listPricingModules(): Promise<PricingModuleStruct[]>; private encodeUpdateChannelRoles; private encodeAddRolesToChannel; private encodeRemoveRolesFromChannel; createLegacyUpdatedEntitlements(space: Space, params: LegacyUpdateRoleParams): Promise<IRolesBase.CreateEntitlementStruct[]>; createUpdatedEntitlements(space: Space, params: UpdateRoleParams): Promise<IRolesBase.CreateEntitlementStruct[]>; refreshMetadata(spaceId: string, signer: ethers.Signer, txnOpts?: TransactionOpts): Promise<ContractTransaction>; /** * Get the space address from the receipt and sender address * @param receipt - The receipt from the transaction * @param senderAddress - The address of the sender. Required for the case of a receipt containing multiple events of the same type. * @returns The space address or undefined if the receipt is not successful */ getSpaceAddress(receipt: ContractReceipt, senderAddress: string): string | undefined; getTipEvent(spaceId: string, receipt: ContractReceipt, senderAddress: string): TipEventObject | undefined; withdrawSpaceFunds(spaceId: string, recipient: string, signer: ethers.Signer): Promise<ContractTransaction>; listenForMembershipEvent(spaceId: string, receiver: string, abortController?: AbortController): Promise<{ issued: true; tokenId: string; error?: Error | undefined; } | { issued: false; tokenId: undefined; error?: Error | undefined; }>; /** * Get the token id for the owner * Returns the first token id matched from the linked wallets of the owner * @param spaceId - The space id * @param owner - The owner * @returns The token id */ getTokenIdOfOwner(spaceId: string, owner: string): Promise<string | undefined>; /** * Tip a user * @param args * @param args.spaceId - The space id * @param args.tokenId - The token id to tip. Obtainable from getTokenIdOfOwner * @param args.currency - The currency to tip - address or 0xEeeeeeeeee... for native currency * @param args.amount - The amount to tip * @param args.messageId - The message id - needs to be hex encoded to 64 characters * @param args.channelId - The channel id - needs to be hex encoded to 64 characters * @param signer - The signer to use for the tip * @returns The transaction */ tip(args: { spaceId: string; tokenId: string; currency: string; amount: bigint; messageId: string; channelId: string; receiver: string; }, signer: ethers.Signer): Promise<ContractTransaction>; } export {}; //# sourceMappingURL=SpaceDapp.d.ts.map