UNPKG

@river-build/web3

Version:

Dapps for our Space and Registry contracts

143 lines 5.75 kB
import { IRuleEntitlementBase, IRuleEntitlementAbi } from './v3/IRuleEntitlementShim'; import { IRuleEntitlementV2Base, IRuleEntitlementV2Abi } from './v3/IRuleEntitlementV2Shim'; import { DecodeFunctionResultReturnType, Hex } from 'viem'; import { Address } from './ContractTypes'; export type XchainConfig = { supportedRpcUrls: { [chainId: number]: string; }; etherBasedChains: number[]; }; export type RuleData = DecodeFunctionResultReturnType<typeof IRuleEntitlementAbi, 'getRuleData'>; export type RuleDataV2 = DecodeFunctionResultReturnType<typeof IRuleEntitlementV2Abi, 'getRuleDataV2'>; export declare enum OperationType { NONE = 0, CHECK = 1, LOGICAL = 2 } export declare enum CheckOperationType { NONE = 0, MOCK = 1, ERC20 = 2, ERC721 = 3, ERC1155 = 4, ISENTITLED = 5, ETH_BALANCE = 6 } export declare enum LogicalOperationType { NONE = 0, AND = 1, OR = 2 } export type ContractOperation = { opType: OperationType; index: number; }; export type ContractLogicalOperation = { logOpType: LogicalOperationType; leftOperationIndex: number; rightOperationIndex: number; }; export declare function isContractLogicalOperation(operation: ContractOperation): boolean; export type CheckOperation = { opType: OperationType.CHECK; checkType: CheckOperationType; chainId: bigint; contractAddress: Address; threshold: bigint; }; export type CheckOperationV2 = { opType: OperationType.CHECK; checkType: CheckOperationType; chainId: bigint; contractAddress: Address; params: Hex; }; export type OrOperation = { opType: OperationType.LOGICAL; logicalType: LogicalOperationType.OR; leftOperation: Operation; rightOperation: Operation; }; export type AndOperation = { opType: OperationType.LOGICAL; logicalType: LogicalOperationType.AND; leftOperation: Operation; rightOperation: Operation; }; export type NoOperation = { opType: OperationType.NONE; index: number; }; export declare const NoopOperation: NoOperation; export declare const NoopRuleData: { operations: never[]; checkOperations: never[]; logicalOperations: never[]; }; export declare const EncodedNoopRuleData: `0x${string}`; type EntitledWalletOrZeroAddress = string; export type LogicalOperation = OrOperation | AndOperation; export type SupportedLogicalOperationType = LogicalOperation['logicalType']; export type Operation = CheckOperationV2 | OrOperation | AndOperation | NoOperation; export declare function postOrderArrayToTree(operations: Operation[]): Operation; export type ThresholdParams = { threshold: bigint; }; export declare function encodeThresholdParams(params: ThresholdParams): Hex; export declare function decodeThresholdParams(params: Hex): Readonly<ThresholdParams>; export type ERC1155Params = { threshold: bigint; tokenId: bigint; }; export declare function encodeERC1155Params(params: ERC1155Params): Hex; export declare function decodeERC1155Params(params: Hex): Readonly<ERC1155Params>; export declare function encodeRuleData(ruleData: IRuleEntitlementBase.RuleDataStruct): Hex; export declare function decodeRuleData(entitlementData: Hex): IRuleEntitlementBase.RuleDataStruct; export declare function encodeRuleDataV2(ruleData: IRuleEntitlementV2Base.RuleDataV2Struct): Hex; export declare function decodeRuleDataV2(entitlementData: Hex): IRuleEntitlementV2Base.RuleDataV2Struct; export declare function ruleDataToOperations(data: IRuleEntitlementV2Base.RuleDataV2Struct): Operation[]; type DeepWriteable<T> = { -readonly [P in keyof T]: DeepWriteable<T[P]>; }; export declare function postOrderTraversal(operation: Operation, data: DeepWriteable<RuleDataV2>): void; export declare function treeToRuleData(root: Operation): IRuleEntitlementV2Base.RuleDataV2Struct; /** * * @param operations * @param linkedWallets * @param providers * @returns An entitled wallet or the zero address, indicating no entitlement */ export declare function evaluateOperationsForEntitledWallet(operations: Operation[], linkedWallets: string[], xchainConfig: XchainConfig): Promise<string>; export declare function evaluateTree(controller: AbortController, linkedWallets: string[], xchainConfig: XchainConfig, entry?: Operation): Promise<EntitledWalletOrZeroAddress>; export declare function createExternalTokenStruct(addresses: Address[], options?: { checkOptions?: Partial<Omit<DecodedCheckOperation, 'address'>>; logicalOp?: SupportedLogicalOperationType; }): IRuleEntitlementV2Base.RuleDataV2Struct; export declare function createExternalNFTStruct(addresses: Address[], options?: { checkOptions?: Partial<Omit<DecodedCheckOperation, 'address'>>; logicalOp?: SupportedLogicalOperationType; }): IRuleEntitlementV2Base.RuleDataV2Struct; export declare class DecodedCheckOperationBuilder { private decodedCheckOp; setType(checkOpType: CheckOperationType): this; setChainId(chainId: bigint): this; setThreshold(threshold: bigint): this; setAddress(address: Address): this; setTokenId(tokenId: bigint): this; setByteEncodedParams(params: Hex): this; build(): DecodedCheckOperation; } export type DecodedCheckOperation = { type: CheckOperationType; chainId?: bigint; address?: Address; threshold?: bigint; tokenId?: bigint; byteEncodedParams?: Hex; }; export declare function createOperationsTree(checkOp: DecodedCheckOperation[], logicalOp?: SupportedLogicalOperationType): IRuleEntitlementV2Base.RuleDataV2Struct; export declare function createDecodedCheckOperationFromTree(entitlementData: IRuleEntitlementV2Base.RuleDataV2Struct): DecodedCheckOperation[]; export {}; //# sourceMappingURL=entitlement.d.ts.map