import { ApiDecoration, AugmentedEvent, AugmentedQueries, AugmentedQuery, AugmentedQueryDoubleMap, ObsInnerType } from '@polkadot/api/types'; import { Bytes, Option, StorageKey } from '@polkadot/types'; import { EventRecord, RewardDestination } from '@polkadot/types/interfaces'; import { BlockHash } from '@polkadot/types/interfaces/chain'; import { PalletAssetAssetDetails, PalletCorporateActionsCorporateAction, PolymeshPrimitivesIdentityId, PolymeshPrimitivesSecondaryKeyKeyRecord, PolymeshPrimitivesStatisticsStatType, PolymeshPrimitivesTransferComplianceTransferCondition } from '../../node_modules/@polymeshassociation/polymesh-types/polkadot/types-lookup'; import type { Callback, Observable } from '@polkadot/types/types'; import { AnyFunction, AnyTuple, IEvent, ISubmittableResult } from '@polkadot/types/types'; import BigNumber from 'bignumber.js'; import { CorporateBallotDetails } from '../api/entities/CorporateBallot/types'; import { Account, BaseAsset, Checkpoint, CheckpointSchedule, Context, FungibleAsset, Identity, MultiSig, Nft } from '../internal'; import { Claim as MiddlewareClaim } from '../middleware/types'; import { MiddlewareScope } from '../middleware/typesV1'; import { Asset, AssetStat, Authorization, AuthorizationRequest, Claim, Condition, InputCaCheckpoint, InputCondition, ModuleName, NextKey, NoArgsProcedureMethod, OptionalArgsProcedureMethod, PaginationOptions, PermissionedAccount, ProcedureMethod, StatClaimIssuer, StatType, SubCallback, TransferRestriction, TransferRestrictionType, TxTag, UnsubCallback } from '../types'; import { Events, Falsyable, MapTxWithArgs, MiddlewarePermissions, MiddlewareV6Extrinsic, PolymeshTx, TxWithArgs } from '../types/internal'; import { HumanReadableType, ProcedureFunc, QueryFunction, UnionOfProcedureFuncs } from '../types/utils'; export * from '../generated/utils'; /** * @hidden * Promisified version of a timeout * * @param amount - time to wait */ export declare function delay(amount: number): Promise; /** * @hidden * Convert an entity type and its unique Identifiers to a base64 string */ export declare function serialize(entityType: string, uniqueIdentifiers: UniqueIdentifiers): string; /** * @hidden * Convert a uuid string to an Identifier object */ export declare function unserialize(id: string): UniqueIdentifiers; /** * @hidden * Extract the DID from an Identity, or return the DID of the signing Identity if no Identity is passed */ export declare function getDid(value: string | Identity | undefined, context: Context): Promise; /** * @hidden * Given a DID return the corresponding Identity, given an Identity return the Identity */ export declare function asIdentity(value: string | Identity, context: Context): Identity; /** * @hidden * Given an address return the corresponding Account, given an Account return the Account */ export declare function asAccount(value: string | Account, context: Context): Account; /** * @hidden * DID | Identity -> DID */ export declare function asDid(value: string | Identity): string; /** * @hidden * Given an Identity, return the Identity, given a DID returns the corresponding Identity, if value is falsy, then return currentIdentity */ export declare function getIdentity(value: string | Identity | undefined, context: Context): Promise; /** * @hidden */ export declare function createClaim(claimType: string, jurisdiction: Falsyable, middlewareScope: Falsyable, cddId: Falsyable, customClaimTypeId: Falsyable): Claim; /** * @hidden */ type EventData = Event extends AugmentedEvent<'promise', infer Data> ? Data : never; /** * @hidden * Find every occurrence of a specific event inside a receipt * * @param skipError - optional. If true, no error will be thrown if the event is not found, * and the function will return an empty array */ export declare function filterEventRecords(receipt: ISubmittableResult, mod: ModuleName, eventName: EventName, skipError?: true): IEvent>[]; /** * @hidden * * Segment a batch transaction receipt's events into arrays, each representing a specific extrinsic's * associated events. This is useful for scenarios where we need to isolate and process events * for individual extrinsics in a batch. * * In a batch transaction receipt, events corresponding to multiple extrinsics are listed sequentially. * This function identifies boundaries between these event sequences, typically demarcated by * events like 'utility.ItemCompleted', to segment events into individual arrays. * * A key use case is when we want to slice or filter events for a subset of the extrinsics. By * segmenting events this way, it becomes simpler to apply operations or analyses to events * corresponding to specific extrinsics in the batch. * * @param events - array of events from a batch transaction receipt * * @returns an array of arrays, where each inner array contains events specific to an extrinsic in the batch. * * @note this function does not mutate the input events */ export declare function segmentEventsByTransaction(events: EventRecord[]): EventRecord[][]; /** * @hidden * * Return a clone of a batch transaction receipt that only contains events for a subset of the * extrinsics in the batch. This is useful when a batch has several extrinsics that emit * the same events and we want `filterEventRecords` to only search among the events emitted by * some of them. * * A good example of this is when merging similar batches together. If we wish to preserve the return * value of each batch, this is a good way of ensuring that the resolver function of a batch has * access to the events that correspond only to the extrinsics in said batch * * @param from - index of the first transaction in the subset * @param to - end index of the subset (not included) * * @note this function does not mutate the original receipt */ export declare function sliceBatchReceipt(receipt: ISubmittableResult, from: number, to: number): ISubmittableResult; /** * Return a clone of the last receipt in the passes array, containing the accumulated events * of all receipts */ export declare function mergeReceipts(receipts: ISubmittableResult[], context: Context): ISubmittableResult; /** * @hidden */ export declare function padString(value: string, length: number): string; /** * @hidden */ export declare function removePadding(value: string): string; /** * @hidden * * Return whether the string is fully printable ASCII */ export declare function isPrintableAscii(value: string): boolean; /** * @hidden * * Return whether the string contains alphanumeric values or _ - . / */ export declare function isAllowedCharacters(value: string): boolean; /** * @hidden * * Makes an entries request to the chain. If pagination options are supplied, * the request will be paginated. Otherwise, all entries will be requested at once */ export declare function requestPaginated(query: AugmentedQuery<'promise', F, T> | AugmentedQueryDoubleMap<'promise', F, T>, opts: { paginationOpts?: PaginationOptions | undefined; arg?: Parameters[0]; }): Promise<{ entries: [StorageKey, ObsInnerType>][]; lastKey: NextKey; }>; /** * @hidden * * Gets Polymesh API instance at a particular block */ export declare function getApiAtBlock(context: Context, blockHash: string | BlockHash): Promise>; type QueryMultiParam[]> = { [index in keyof T]: T[index] extends AugmentedQuery<'promise', infer Fun> ? Fun extends (firstArg: infer First, ...restArg: infer Rest) => ReturnType ? Rest extends never[] ? [T[index], First] : [T[index], Parameters] : never : never; }; type QueryMultiReturnType[]> = { [index in keyof T]: T[index] extends AugmentedQuery<'promise', infer Fun> ? ReturnType extends Observable ? R : never : never; }; /** * @hidden * * Makes an multi request to the chain */ export declare function requestMulti[]>(context: Context, queries: QueryMultiParam): Promise>; export declare function requestMulti[]>(context: Context, queries: QueryMultiParam, callback: Callback>): Promise; /** * @hidden * * Makes a request to the chain. If a block hash is supplied, * the request will be made at that block. Otherwise, the most recent block will be queried */ export declare function requestAtBlock, QueryName extends keyof AugmentedQueries<'promise'>[ModuleName]>(moduleName: ModuleName, queryName: QueryName, opts: { blockHash?: string | BlockHash; args: Parameters>; }, context: Context): Promise>>>; /** * @hidden * * Calculates next page number for paginated GraphQL ResultSet. * Returns null if there is no next page. * * @param size - page size requested * @param start - start index requested * @param totalCount - total amount of elements returned by query * * @hidden * */ export declare function calculateNextKey(totalCount: BigNumber, size: number, start?: BigNumber): NextKey; /** * Create a method that prepares a procedure */ export declare function createProcedureMethod>(args: { getProcedureAndArgs: () => [ (UnionOfProcedureFuncs | ProcedureFunc), ProcedureArgs ]; voidArgs: true; }, context: Context): NoArgsProcedureMethod; export declare function createProcedureMethod>(args: { getProcedureAndArgs: () => [ (UnionOfProcedureFuncs | ProcedureFunc), ProcedureArgs ]; voidArgs: true; transformer: (value: ProcedureReturnValue) => ReturnValue | Promise; }, context: Context): NoArgsProcedureMethod; export declare function createProcedureMethod>(args: { getProcedureAndArgs: (methodArgs?: MethodArgs) => [ (UnionOfProcedureFuncs | ProcedureFunc), ProcedureArgs ]; optionalArgs: true; }, context: Context): OptionalArgsProcedureMethod; export declare function createProcedureMethod>(args: { getProcedureAndArgs: (methodArgs: MethodArgs) => [ (UnionOfProcedureFuncs | ProcedureFunc), ProcedureArgs ]; optionalArgs: true; transformer: (value: ProcedureReturnValue) => ReturnValue | Promise; }, context: Context): OptionalArgsProcedureMethod; export declare function createProcedureMethod>(args: { getProcedureAndArgs: (methodArgs: MethodArgs) => [ (UnionOfProcedureFuncs | ProcedureFunc), ProcedureArgs ]; }, context: Context): ProcedureMethod; export declare function createProcedureMethod>(args: { getProcedureAndArgs: (methodArgs: MethodArgs) => [ (UnionOfProcedureFuncs | ProcedureFunc), ProcedureArgs ]; transformer: (value: ProcedureReturnValue) => ReturnValue | Promise; }, context: Context): ProcedureMethod; /** * @hidden */ export declare function assertIsInteger(value: BigNumber): void; /** * @hidden */ export declare function assertIsPositive(value: BigNumber): void; /** * @hidden */ export declare function assertAddressValid(address: string, ss58Format: BigNumber): void; /** * @hidden * * Validates a ticker value */ export declare function assertTickerValid(ticker: string): void; /** * @hidden * * Validates a ticker's length against the chain's current ticker registration rules. * * @note this is distinct from {@link assertTickerValid}, which enforces the fixed 12 byte * width of the on chain `Ticker` type. `maxTickerLength` is a separate, governance * configurable ceiling (never greater than 12) used to validate new ticker registrations */ export declare function assertTickerLengthValid(ticker: string, context: Context): Promise; /** * @hidden */ export declare function getTickerForAsset(id: string, context: Context): Promise; /** * @hidden */ export declare function getAssetIdForTicker(ticker: string, context: Context): Promise; /** * @hidden */ export declare function getAssetIdAndTicker(assetId: string, context: Context): Promise<{ ticker?: string | undefined; assetId: string; }>; /** * @hidden */ export declare function asUuid(id: string): string; /** * @hidden */ export declare function asBaseAsset(asset: string | BaseAsset, context: Context): Promise; /** * @hidden */ export declare function asAssetId(asset: string | BaseAsset, context: Context): Promise; /** * @hidden * * @note alternatively {@link asBaseAsset} returns a generic `BaseAsset`, but is synchronous */ export declare function asAsset(asset: string | Asset, context: Context): Promise; /** * @hidden * Transforms asset or ticker into a `FungibleAsset` entity */ export declare function asFungibleAsset(asset: string | BaseAsset, context: Context): Promise; /** * @hidden */ export declare function xor(a: boolean, b: boolean): boolean; /** * @hidden * Transform a conversion util into a version that returns null if the input is falsy */ export declare function optionize(converter: (input: InputType, ...rest: RestType) => OutputType): (val: InputType | null | undefined, ...rest: RestType) => OutputType | null; /** * @hidden * Compare two tags/modules and return true if they are equal, or if one is the other one's module */ export declare function isModuleOrTagMatch(a: TxTag | ModuleName, b: TxTag | ModuleName): boolean; /** * @hidden * * Recursively convert a value into a human readable (JSON compliant) version: * - Entities are converted via their `.toHuman` method * - Dates are converted to ISO strings * - BigNumbers are converted to numerical strings */ export declare function toHumanReadable(obj: T): HumanReadableType; /** * @hidden * * Return whether the two arrays have same elements. * It uses a `comparator` function to check if elements are equal. * If no comparator function is provided, it uses `isEqual` function of `lodash` */ export declare function hasSameElements(first: T[], second: T[], comparator?: (a: T, b: T) => boolean): boolean; /** * @hidden * * Perform a deep comparison between two compliance conditions */ export declare function conditionsAreEqual(a: Condition | InputCondition, b: Condition | InputCondition): boolean; /** * @hidden * * Transforms `InputCACheckpoint` values to `Checkpoint | CheckpointSchedule | Date` for easier processing */ export declare function getCheckpointValue(checkpoint: InputCaCheckpoint, asset: string | FungibleAsset, context: Context): Promise; /** * @hidden */ export interface TxAndArgsArray = Readonly> { transaction: PolymeshTx; argsArray: Args[]; } type MapTxAndArgsArray> = { [K in keyof Args]: Args[K] extends unknown[] ? TxAndArgsArray : never; }; /** * Assemble the `transactions` array that is expected in a `BatchTransactionSpec` from a set of parameter arrays with their * respective transaction * * @note This method ensures type safety for batches with a variable amount of transactions */ export declare function assembleBatchTransactions>(txsAndArgs: MapTxAndArgsArray): MapTxWithArgs; /** * @hidden * * Returns portfolio numbers for a set of portfolio names */ export declare function getPortfolioIdsByName(rawIdentityId: PolymeshPrimitivesIdentityId, rawNames: Bytes[], context: Context): Promise<(BigNumber | null)[]>; /** * @hidden * * Check if a transaction matches the type of its args. Returns the same value but stripped of the types. This function has no logic, it's strictly * for type safety when returning a `BatchTransactionSpec` with a variable amount of transactions */ export declare function checkTxType(tx: TxWithArgs): TxWithArgs; /** * @hidden * * Add an empty handler to a promise to avoid false positive unhandled promise errors. The original promise * is returned, so rejections are still bubbled up and caught properly. This is an ugly hack and should be used * sparingly and only if you KNOW that rejections will be handled properly down the line * * More info: * * - https://github.com/facebook/jest/issues/6028#issuecomment-567851031 * - https://stackoverflow.com/questions/59060508/how-to-handle-an-unhandled-promise-rejection-asynchronously * - https://stackoverflow.com/questions/40920179/should-i-refrain-from-handling-promise-rejection-asynchronously/40921505#40921505 */ export declare function defusePromise(promise: Promise): Promise; /** * @hidden * * Transform an array of Identities into exempted IDs for Transfer Managers. * * @note even though the signature for `addExemptedEntities` requires `ScopeId`s as parameters, * it accepts and handles `PolymeshPrimitivesIdentityId` parameters as well. Nothing special has to be done typing-wise since they're both aliases * for `U8aFixed` * * @throws * - if there are duplicated Identities/ScopeIDs */ export declare function getExemptedIds(identities: (string | Identity)[], context: Context): string[]; /** * @hidden * * Get the allowed majors for a given range and supported spec semver */ export declare const getAllowedMajors: (range: string, supportedSpecSemver: string) => string[]; /** * @hidden * * Get latest SQ version */ export declare function getLatestSqVersion(context: Context): Promise; /** * @hidden * * Checks SQ version compatibility with the SDK */ export declare function warnUnexpectedSqVersion(context: Context): Promise; /** * @hidden * * @returns protocol present in `url`, or `undefined` if one is not found */ export declare function extractProtocol(url: string): string | undefined; /** * @hidden * * Checks chain version. This function uses a websocket/fetch as it's intended to be called during initialization * @param nodeUrl - URL for the chain node * @returns A promise that resolves if the version is in the expected range, otherwise it will reject */ export declare function assertExpectedChainVersion(nodeUrl: string): Promise; /** * @hidden * @returns true if the given StatType is able to track the data for the given transfer condition */ export declare function compareTransferRestrictionToStat(transferCondition: PolymeshPrimitivesTransferComplianceTransferCondition, type: StatType, claimIssuer?: StatClaimIssuer): boolean; /** * @hidden * @param args.type TransferRestriction type that was given * @param args.claimIssuer optional Issuer and ClaimType for the scope of the Stat * @param context * @returns encoded StatType needed for the TransferRestriction to be enabled */ export declare function neededStatTypeForRestrictionInput(args: { type: TransferRestrictionType; claimIssuer?: StatClaimIssuer | undefined; }, context: Context): PolymeshPrimitivesStatisticsStatType; /** * @hidden * @throws if stat is not found in the given set */ export declare function assertStatIsSet(currentStats: AssetStat[], restriction: TransferRestriction): void; /** * @hidden * * Fetches Account permissions for the given secondary Accounts * * @note non secondary Accounts will be skipped, so there maybe less PermissionedAccounts returned than Accounts given * * @param args.accounts a list of accounts to fetch permissions for * @param args.identity optional. If passed, Accounts that are not part of the given Identity will be filtered out */ export declare function getSecondaryAccountPermissions(args: { accounts: Account[]; identity?: Identity; }, context: Context, callback: SubCallback): Promise; export declare function getSecondaryAccountPermissions(args: { accounts: (Account | MultiSig)[]; identity?: Identity; }, context: Context): Promise; /** * @hidden */ export declare function getIdentityFromKeyRecord(keyRecord: PolymeshPrimitivesSecondaryKeyKeyRecord, context: Context): Promise; /** * @hidden * * helper to construct proper type asset * * @note `assetDetails` and `tickers` must have the same offset */ export declare function assembleAssetQuery(assetDetails: Option[], assetIds: string[], context: Context): Asset[]; /** * @hidden */ export declare function asNftId(nft: Nft | BigNumber): BigNumber; /** * @hidden */ export declare function areSameClaims(claim: Claim, { scope, type, customClaimTypeId }: MiddlewareClaim): boolean; /** * @hidden */ export declare function assertNoPendingAuthorizationExists(params: { authorizationRequests: AuthorizationRequest[]; message: string; authorization: Partial; issuer?: Identity; target?: string | Identity; }): void; /** * @hidden */ export declare function assertIdentityExists(identity: Identity): Promise; /** * @hidden */ export declare function getAccount(args: { address: string; }, context: Context): Promise; /** * @hidden * * Used for querying middleware which stores asset ID in hex format * * @returns assetId in hex format */ export declare function getAssetIdForMiddleware(assetIdOrTicker: string | BaseAsset, context: Context): Promise; /** * @hidden * * used for converting assetId from SQ format to SDK format * * @returns asset ID as UUID format */ export declare function getAssetIdFromMiddleware(id: string | undefined): string; /** * @hidden */ export declare function prepareStorageForCustomType(customType: string | BigNumber, knownTypes: string[], context: Context, method: string): Promise; /** * Determines the middleware permissions follows the legacy format */ export declare function isMiddlewareV6Extrinsic(permissions: MiddlewarePermissions): permissions is MiddlewareV6Extrinsic; /** * @hidden * * @throws if payee is not associated with an Identity * * @returns raw payee for staking extrinsics */ export declare function calculateRawStakingPayee(payee: Account, stash: Account, autoStake: boolean, context: Context): Promise; /** * @hidden */ export declare function areSameAccounts(account1: Account, account2: Account): boolean; /** * @hidden */ export declare function assertMetaLength(meta: string): void; /** * @hidden */ export declare function assertDeclarationDate(declarationDate: Date): void; /** * @hidden */ export declare function getCorporateBallotDetailsOrNull(asset: FungibleAsset, id: BigNumber, context: Context): Promise; /** * @hidden */ export declare function getCorporateBallotDetailsOrThrow(asset: FungibleAsset, id: BigNumber, context: Context): Promise; /** * @hidden */ export declare function assertBallotNotStarted({ startDate, }: Pick): void; /** * @hidden */ export declare function getCorporateActionWithDescription(asset: FungibleAsset, id: BigNumber, context: Context): Promise<{ corporateAction: PalletCorporateActionsCorporateAction; description: Bytes; }>; //# sourceMappingURL=internal.d.ts.map