@evefrontier/dapp-kit 0.1.8 → 0.2.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -25
- package/dist/config/dapp-kit.d.ts +4 -0
- package/dist/config/dapp-kit.d.ts.map +1 -0
- package/dist/config/dapp-kit.js +14 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +1 -0
- package/dist/graphql/client.d.ts +277 -0
- package/dist/graphql/client.d.ts.map +1 -0
- package/dist/graphql/client.js +346 -0
- package/dist/graphql/index.d.ts +4 -0
- package/dist/graphql/index.d.ts.map +1 -0
- package/dist/graphql/index.js +16 -0
- package/dist/graphql/queries.d.ts +103 -0
- package/dist/graphql/queries.d.ts.map +1 -0
- package/{graphql/queries.ts → dist/graphql/queries.js} +113 -223
- package/dist/graphql/types.d.ts +396 -0
- package/dist/graphql/types.d.ts.map +1 -0
- package/dist/graphql/types.js +4 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +8 -0
- package/dist/hooks/useCharacterDirectory.d.ts +16 -0
- package/dist/hooks/useCharacterDirectory.d.ts.map +1 -0
- package/dist/hooks/useCharacterDirectory.js +23 -0
- package/dist/hooks/useCharacterSearch.d.ts +24 -0
- package/dist/hooks/useCharacterSearch.d.ts.map +1 -0
- package/dist/hooks/useCharacterSearch.js +24 -0
- package/dist/hooks/useConnection.d.ts +51 -0
- package/dist/hooks/useConnection.d.ts.map +1 -0
- package/{hooks/useConnection.ts → dist/hooks/useConnection.js} +8 -10
- package/dist/hooks/useEntityRole.d.ts +26 -0
- package/dist/hooks/useEntityRole.d.ts.map +1 -0
- package/dist/hooks/useEntityRole.js +91 -0
- package/dist/hooks/useNotification.d.ts +72 -0
- package/dist/hooks/useNotification.d.ts.map +1 -0
- package/{hooks/useNotification.ts → dist/hooks/useNotification.js} +8 -12
- package/dist/hooks/useSmartObject.d.ts +44 -0
- package/dist/hooks/useSmartObject.d.ts.map +1 -0
- package/dist/hooks/useSmartObject.js +50 -0
- package/dist/hooks/useSponsoredTransaction.d.ts +147 -0
- package/dist/hooks/useSponsoredTransaction.d.ts.map +1 -0
- package/dist/hooks/useSponsoredTransaction.js +240 -0
- package/dist/hooks/useTypeNames.d.ts +11 -0
- package/dist/hooks/useTypeNames.d.ts.map +1 -0
- package/dist/hooks/useTypeNames.js +24 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/providers/EveFrontierProvider.d.ts +23 -0
- package/dist/providers/EveFrontierProvider.d.ts.map +1 -0
- package/dist/providers/EveFrontierProvider.js +23 -0
- package/dist/providers/NotificationProvider.d.ts +14 -0
- package/dist/providers/NotificationProvider.d.ts.map +1 -0
- package/dist/providers/NotificationProvider.js +66 -0
- package/dist/providers/SmartObjectProvider.d.ts +31 -0
- package/dist/providers/SmartObjectProvider.d.ts.map +1 -0
- package/dist/providers/SmartObjectProvider.js +80 -0
- package/dist/providers/VaultProvider.d.ts +10 -0
- package/dist/providers/VaultProvider.d.ts.map +1 -0
- package/dist/providers/VaultProvider.js +79 -0
- package/dist/providers/index.d.ts +5 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +4 -0
- package/dist/providers/smartObject/useEntityData.d.ts +29 -0
- package/dist/providers/smartObject/useEntityData.d.ts.map +1 -0
- package/dist/providers/smartObject/useEntityData.js +135 -0
- package/dist/providers/smartObject/useEntitySubscription.d.ts +14 -0
- package/dist/providers/smartObject/useEntitySubscription.d.ts.map +1 -0
- package/dist/providers/smartObject/useEntitySubscription.js +58 -0
- package/dist/providers/smartObject/useObjectSelection.d.ts +11 -0
- package/dist/providers/smartObject/useObjectSelection.d.ts.map +1 -0
- package/dist/providers/smartObject/useObjectSelection.js +27 -0
- package/dist/providers/smartObject/usePollingBackstop.d.ts +18 -0
- package/dist/providers/smartObject/usePollingBackstop.d.ts.map +1 -0
- package/dist/providers/smartObject/usePollingBackstop.js +38 -0
- package/dist/types/character.d.ts +21 -0
- package/dist/types/character.d.ts.map +1 -0
- package/dist/types/character.js +1 -0
- package/dist/types/contexts.d.ts +61 -0
- package/dist/types/contexts.d.ts.map +1 -0
- package/dist/types/contexts.js +6 -0
- package/dist/types/entity.d.ts +245 -0
- package/dist/types/entity.d.ts.map +1 -0
- package/dist/types/entity.js +6 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/sponsoredTransaction.d.ts +26 -0
- package/dist/types/sponsoredTransaction.d.ts.map +1 -0
- package/dist/types/sponsoredTransaction.js +10 -0
- package/dist/types/types.d.ts +110 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +41 -0
- package/dist/types/worldApiReturnTypes.d.ts +68 -0
- package/dist/types/worldApiReturnTypes.d.ts.map +1 -0
- package/dist/types/worldApiReturnTypes.js +1 -0
- package/{utils/burnRate.ts → dist/utils/burnRate.d.ts} +4 -29
- package/dist/utils/burnRate.d.ts.map +1 -0
- package/dist/utils/burnRate.js +25 -0
- package/dist/utils/characters.d.ts +26 -0
- package/dist/utils/characters.d.ts.map +1 -0
- package/dist/utils/characters.js +84 -0
- package/dist/utils/constants.d.ts +153 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +190 -0
- package/dist/utils/datahub.d.ts +40 -0
- package/dist/utils/datahub.d.ts.map +1 -0
- package/{utils/datahub.ts → dist/utils/datahub.js} +32 -25
- package/dist/utils/entity.d.ts +58 -0
- package/dist/utils/entity.d.ts.map +1 -0
- package/dist/utils/entity.js +386 -0
- package/dist/utils/errors.d.ts +18 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +128 -0
- package/dist/utils/events/entityEvents.d.ts +44 -0
- package/dist/utils/events/entityEvents.d.ts.map +1 -0
- package/dist/utils/events/entityEvents.js +95 -0
- package/dist/utils/events/entitySubscription.d.ts +30 -0
- package/dist/utils/events/entitySubscription.d.ts.map +1 -0
- package/dist/utils/events/entitySubscription.js +84 -0
- package/dist/utils/events/graphqlEventStream.d.ts +90 -0
- package/dist/utils/events/graphqlEventStream.d.ts.map +1 -0
- package/dist/utils/events/graphqlEventStream.js +198 -0
- package/dist/utils/events/refetchScheduler.d.ts +30 -0
- package/dist/utils/events/refetchScheduler.d.ts.map +1 -0
- package/dist/utils/events/refetchScheduler.js +57 -0
- package/dist/utils/events/sseClient.d.ts +42 -0
- package/dist/utils/events/sseClient.d.ts.map +1 -0
- package/dist/utils/events/sseClient.js +97 -0
- package/dist/utils/fuel.d.ts +231 -0
- package/dist/utils/fuel.d.ts.map +1 -0
- package/dist/utils/fuel.js +652 -0
- package/dist/utils/grid.d.ts +115 -0
- package/dist/utils/grid.d.ts.map +1 -0
- package/dist/utils/grid.js +115 -0
- package/dist/utils/index.d.ts +15 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +22 -0
- package/dist/utils/inventory.d.ts +3 -0
- package/dist/utils/inventory.d.ts.map +1 -0
- package/dist/utils/inventory.js +12 -0
- package/dist/utils/logger.d.ts +25 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +228 -0
- package/dist/utils/mapping.d.ts +30 -0
- package/dist/utils/mapping.d.ts.map +1 -0
- package/dist/utils/mapping.js +73 -0
- package/dist/utils/mvr/worldTypes.d.ts +35 -0
- package/dist/utils/mvr/worldTypes.d.ts.map +1 -0
- package/dist/utils/mvr/worldTypes.js +54 -0
- package/dist/utils/role.d.ts +116 -0
- package/dist/utils/role.d.ts.map +1 -0
- package/dist/utils/role.js +120 -0
- package/dist/utils/smartObject.d.ts +24 -0
- package/dist/utils/smartObject.d.ts.map +1 -0
- package/dist/utils/smartObject.js +24 -0
- package/dist/utils/utils.d.ts +133 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +213 -0
- package/dist/wallet/features.d.ts +28 -0
- package/dist/wallet/features.d.ts.map +1 -0
- package/dist/wallet/features.js +22 -0
- package/dist/wallet/index.d.ts +9 -0
- package/dist/wallet/index.d.ts.map +1 -0
- package/dist/wallet/index.js +9 -0
- package/dist/wallet/utils.d.ts +71 -0
- package/dist/wallet/utils.d.ts.map +1 -0
- package/dist/wallet/utils.js +79 -0
- package/package.json +69 -35
- package/config/dapp-kit.ts +0 -20
- package/config/index.ts +0 -1
- package/graphql/client.ts +0 -578
- package/graphql/index.ts +0 -39
- package/graphql/types.ts +0 -468
- package/hooks/index.ts +0 -15
- package/hooks/useSmartObject.ts +0 -66
- package/hooks/useSponsoredTransaction.ts +0 -442
- package/index.ts +0 -88
- package/providers/EveFrontierProvider.tsx +0 -41
- package/providers/NotificationProvider.tsx +0 -108
- package/providers/SmartObjectProvider.tsx +0 -296
- package/providers/VaultProvider.tsx +0 -108
- package/providers/index.ts +0 -10
- package/types/contexts.ts +0 -67
- package/types/global.d.ts +0 -7
- package/types/index.ts +0 -4
- package/types/sponsoredTransaction.ts +0 -70
- package/types/types.ts +0 -198
- package/types/worldApiReturnTypes.ts +0 -144
- package/utils/__tests__/burnRate.test.ts +0 -121
- package/utils/__tests__/character.test.ts +0 -112
- package/utils/__tests__/characterOwnedObjects.test.ts +0 -225
- package/utils/__tests__/config.test.ts +0 -424
- package/utils/__tests__/datahub.test.ts +0 -58
- package/utils/__tests__/logger.test.ts +0 -145
- package/utils/__tests__/mapping.test.ts +0 -439
- package/utils/__tests__/utils.test.ts +0 -299
- package/utils/character.ts +0 -46
- package/utils/characterOwnedObjects.ts +0 -53
- package/utils/config.ts +0 -151
- package/utils/constants.ts +0 -254
- package/utils/errors.ts +0 -171
- package/utils/index.ts +0 -47
- package/utils/logger.ts +0 -300
- package/utils/mapping.ts +0 -118
- package/utils/transforms.ts +0 -263
- package/utils/utils.ts +0 -270
- package/wallet/features.ts +0 -136
- package/wallet/index.ts +0 -26
- package/wallet/utils.ts +0 -117
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ApiTier } from '@evefrontier/wallet-core/jwt';
|
|
2
|
+
import { type WorldPackage, type WorldTypeKey } from '@evefrontier/wallet-core/tenant';
|
|
3
|
+
/**
|
|
4
|
+
* The world tier to resolve against: VITE_EVE_WORLD_TIER when set, otherwise the
|
|
5
|
+
* tenant's tier from TENANT_CONFIG.
|
|
6
|
+
*
|
|
7
|
+
* @param tenant - Tenant id (e.g. from `?tenant=`); used when no env tier is set
|
|
8
|
+
* @returns The world tier
|
|
9
|
+
* @throws If VITE_EVE_WORLD_TIER is not a valid tier, or there is no env tier
|
|
10
|
+
* and the tenant is unknown
|
|
11
|
+
* @category Utilities - Config
|
|
12
|
+
*/
|
|
13
|
+
export declare function getWorldTier(tenant?: string): ApiTier;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve a world Move type to its fully-qualified, type-origin tag.
|
|
16
|
+
*
|
|
17
|
+
* @param key - Package-qualified key, e.g. `core::entity_key::EntityKey`
|
|
18
|
+
* @param tenant - Tenant whose tier to use when VITE_EVE_WORLD_TIER is unset
|
|
19
|
+
* @returns The type tag, e.g. `0x…::entity_key::EntityKey`
|
|
20
|
+
* @throws If the tier cannot be determined or has no MVR resolution
|
|
21
|
+
* @category Utilities - Config
|
|
22
|
+
*/
|
|
23
|
+
export declare const getWorldType: (key: WorldTypeKey, tenant?: string) => string;
|
|
24
|
+
/**
|
|
25
|
+
* A world package's id (type-origin) for the resolved tier.
|
|
26
|
+
*
|
|
27
|
+
* @param pkg - World package, e.g. `core` or `inventory`
|
|
28
|
+
* @param tenant - Tenant whose tier to use when VITE_EVE_WORLD_TIER is unset
|
|
29
|
+
* @throws If the tier cannot be determined or has no MVR resolution
|
|
30
|
+
* @category Utilities - Config
|
|
31
|
+
*/
|
|
32
|
+
export declare const getWorldPackageId: (pkg: WorldPackage, tenant?: string) => string;
|
|
33
|
+
/** Type string for the core ObjectRegistry. @category Utilities - Config */
|
|
34
|
+
export declare const getObjectRegistryType: (tenant?: string) => string;
|
|
35
|
+
//# sourceMappingURL=worldTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worldTypes.d.ts","sourceRoot":"","sources":["../../../utils/mvr/worldTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAe,MAAM,8BAA8B,CAAA;AACxE,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,YAAY,EAGlB,MAAM,iCAAiC,CAAA;AAYxC;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAkBrD;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,QAAS,YAAY,WAAW,MAAM,KAAG,MACf,CAAA;AAEnD;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,QAAS,YAAY,WAAW,MAAM,KAAG,MACf,CAAA;AAExD,4EAA4E;AAC5E,eAAO,MAAM,qBAAqB,YAAa,MAAM,KAAG,MACO,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { VALID_TIERS } from '@evefrontier/wallet-core/jwt';
|
|
2
|
+
import { TENANT_CONFIG, getWorldPackageId as walletCoreGetWorldPackageId, getWorldType as walletCoreGetWorldType, } from '@evefrontier/wallet-core/tenant';
|
|
3
|
+
/**
|
|
4
|
+
* World types and package ids are resolved by @evefrontier/wallet-core from its
|
|
5
|
+
* embedded MVR snapshot, per world tier (`@evefrontier/world-<package>-<tier>`).
|
|
6
|
+
* Each type is pinned to the package version in which it was first defined (its
|
|
7
|
+
* type-origin), which is what on-chain type tags carry.
|
|
8
|
+
*/
|
|
9
|
+
const isApiTier = (value) => VALID_TIERS.includes(value);
|
|
10
|
+
/**
|
|
11
|
+
* The world tier to resolve against: VITE_EVE_WORLD_TIER when set, otherwise the
|
|
12
|
+
* tenant's tier from TENANT_CONFIG.
|
|
13
|
+
*
|
|
14
|
+
* @param tenant - Tenant id (e.g. from `?tenant=`); used when no env tier is set
|
|
15
|
+
* @returns The world tier
|
|
16
|
+
* @throws If VITE_EVE_WORLD_TIER is not a valid tier, or there is no env tier
|
|
17
|
+
* and the tenant is unknown
|
|
18
|
+
* @category Utilities - Config
|
|
19
|
+
*/
|
|
20
|
+
export function getWorldTier(tenant) {
|
|
21
|
+
const envTier = import.meta.env.VITE_EVE_WORLD_TIER;
|
|
22
|
+
if (envTier) {
|
|
23
|
+
if (!isApiTier(envTier)) {
|
|
24
|
+
throw new Error(`Invalid VITE_EVE_WORLD_TIER "${envTier}". Expected one of: ${VALID_TIERS.join(', ')}.`);
|
|
25
|
+
}
|
|
26
|
+
return envTier;
|
|
27
|
+
}
|
|
28
|
+
const config = tenant ? TENANT_CONFIG[tenant] : undefined;
|
|
29
|
+
if (!config) {
|
|
30
|
+
throw new Error(`No world tier for tenant "${tenant ?? ''}". Set VITE_EVE_WORLD_TIER or use a known tenant.`);
|
|
31
|
+
}
|
|
32
|
+
return config.worldTier;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolve a world Move type to its fully-qualified, type-origin tag.
|
|
36
|
+
*
|
|
37
|
+
* @param key - Package-qualified key, e.g. `core::entity_key::EntityKey`
|
|
38
|
+
* @param tenant - Tenant whose tier to use when VITE_EVE_WORLD_TIER is unset
|
|
39
|
+
* @returns The type tag, e.g. `0x…::entity_key::EntityKey`
|
|
40
|
+
* @throws If the tier cannot be determined or has no MVR resolution
|
|
41
|
+
* @category Utilities - Config
|
|
42
|
+
*/
|
|
43
|
+
export const getWorldType = (key, tenant) => walletCoreGetWorldType(getWorldTier(tenant), key);
|
|
44
|
+
/**
|
|
45
|
+
* A world package's id (type-origin) for the resolved tier.
|
|
46
|
+
*
|
|
47
|
+
* @param pkg - World package, e.g. `core` or `inventory`
|
|
48
|
+
* @param tenant - Tenant whose tier to use when VITE_EVE_WORLD_TIER is unset
|
|
49
|
+
* @throws If the tier cannot be determined or has no MVR resolution
|
|
50
|
+
* @category Utilities - Config
|
|
51
|
+
*/
|
|
52
|
+
export const getWorldPackageId = (pkg, tenant) => walletCoreGetWorldPackageId(getWorldTier(tenant), pkg);
|
|
53
|
+
/** Type string for the core ObjectRegistry. @category Utilities - Config */
|
|
54
|
+
export const getObjectRegistryType = (tenant) => getWorldType('core::object_registry::ObjectRegistry', tenant);
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { CharacterSummary, EntityOwner } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* What the connected wallet is to an entity:
|
|
4
|
+
* - `shell`: it holds the entity's AccessCap (the contract's `access_cap::Owner`)
|
|
5
|
+
* - `controller`: its character is on the entity's access list
|
|
6
|
+
* - `visitor`: anyone else, including no wallet
|
|
7
|
+
*
|
|
8
|
+
* @category Utilities - Access
|
|
9
|
+
*/
|
|
10
|
+
export type EntityRole = 'shell' | 'controller' | 'visitor';
|
|
11
|
+
/**
|
|
12
|
+
* True when two Sui addresses or object ids are the same, ignoring case and
|
|
13
|
+
* leading zeros.
|
|
14
|
+
*
|
|
15
|
+
* @category Utilities - Access
|
|
16
|
+
*/
|
|
17
|
+
export declare function sameAddress(a: string | null | undefined, b: string | null | undefined): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The character bound to a wallet, from the character directory.
|
|
20
|
+
*
|
|
21
|
+
* @category Utilities - Access
|
|
22
|
+
*/
|
|
23
|
+
export declare function findCharacterByWallet(characters: CharacterSummary[], walletAddress: string | null | undefined): CharacterSummary | null;
|
|
24
|
+
/**
|
|
25
|
+
* All characters bound to a wallet, from the character directory. A wallet
|
|
26
|
+
* can be bound to more than one character.
|
|
27
|
+
*
|
|
28
|
+
* @category Utilities - Access
|
|
29
|
+
*/
|
|
30
|
+
export declare function findCharactersByWallet(characters: CharacterSummary[], walletAddress: string | null | undefined): CharacterSummary[];
|
|
31
|
+
/**
|
|
32
|
+
* True for a whole Sui address: 0x and 64 hex digits, ignoring surrounding
|
|
33
|
+
* whitespace.
|
|
34
|
+
*
|
|
35
|
+
* @category Utilities - Access
|
|
36
|
+
*/
|
|
37
|
+
export declare function isFullAddress(input: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* True for the roles that manage an entity: the shell and controllers.
|
|
40
|
+
*
|
|
41
|
+
* @category Utilities - Access
|
|
42
|
+
*/
|
|
43
|
+
export declare function canManage(role: EntityRole): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* True when a character already controls the entity: it is the shell, or it
|
|
46
|
+
* is on the access list.
|
|
47
|
+
*
|
|
48
|
+
* @category Utilities - Access
|
|
49
|
+
*/
|
|
50
|
+
export declare function isController(characterId: string, controllers: string[] | null | undefined, shellId?: string | null): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Result of {@link resolveNewController}.
|
|
53
|
+
*
|
|
54
|
+
* @category Utilities - Access
|
|
55
|
+
*/
|
|
56
|
+
export type NewControllerResult = {
|
|
57
|
+
ok: true;
|
|
58
|
+
character: CharacterSummary;
|
|
59
|
+
} | {
|
|
60
|
+
ok: false;
|
|
61
|
+
/**
|
|
62
|
+
* - `invalidAddress`: not 0x and 64 hex digits
|
|
63
|
+
* - `unknownCharacter`: no character is bound to this wallet
|
|
64
|
+
* - `alreadyController`: the character is the shell or already on the list
|
|
65
|
+
*/
|
|
66
|
+
error: 'invalidAddress' | 'unknownCharacter' | 'alreadyController';
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Checks a pasted wallet address before adding its character to an entity's
|
|
70
|
+
* access list. Only a wallet bound to a character is accepted, never a
|
|
71
|
+
* character id; the character id it is bound to is what gets stored.
|
|
72
|
+
*
|
|
73
|
+
* @category Utilities - Access
|
|
74
|
+
* @param input - The wallet address as typed or pasted
|
|
75
|
+
* @param characters - The character directory
|
|
76
|
+
* @param controllers - The entity's access list (character ids), or null
|
|
77
|
+
* @param shellId - The shell's character id, when known; the shell is
|
|
78
|
+
* always a controller, so it can't be added again
|
|
79
|
+
*/
|
|
80
|
+
export declare function resolveNewController(input: string, characters: CharacterSummary[], controllers: string[] | null | undefined, shellId?: string | null): NewControllerResult;
|
|
81
|
+
/** Inputs of {@link getEntityRole}. @category Utilities - Access */
|
|
82
|
+
export interface EntityRoleInput {
|
|
83
|
+
/** Connected wallet, or null when none is */
|
|
84
|
+
walletAddress: string | null | undefined;
|
|
85
|
+
/** Holder of the entity's AccessCap */
|
|
86
|
+
entityOwner: EntityOwner | null | undefined;
|
|
87
|
+
/** The entity's access list (character ids), or null when it has none */
|
|
88
|
+
controllers: string[] | null | undefined;
|
|
89
|
+
/** The wallet's character id, when known */
|
|
90
|
+
characterId: string | null | undefined;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Works out the connected wallet's role on an entity. The shell is checked
|
|
94
|
+
* first, so a shell that is also on the access list is still the shell.
|
|
95
|
+
*
|
|
96
|
+
* @category Utilities - Access
|
|
97
|
+
*/
|
|
98
|
+
export declare function getEntityRole(input: EntityRoleInput): EntityRole;
|
|
99
|
+
/** Inputs of {@link needsCharacterDirectory}. @category Utilities - Access */
|
|
100
|
+
export interface DirectoryNeedInput {
|
|
101
|
+
walletAddress: string | null | undefined;
|
|
102
|
+
entityOwner: EntityOwner | null | undefined;
|
|
103
|
+
controllers: string[] | null | undefined;
|
|
104
|
+
/** The wallet's character id, when the caller already knows it */
|
|
105
|
+
knownCharacterId: string | null | undefined;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Whether working out the wallet's role needs the character directory (every
|
|
109
|
+
* character event): only when a wallet is connected, its character isn't
|
|
110
|
+
* known, it isn't the shell's wallet, and the answer could depend on a
|
|
111
|
+
* character (the entity has controllers, or its cap is parked on one).
|
|
112
|
+
*
|
|
113
|
+
* @category Utilities - Access
|
|
114
|
+
*/
|
|
115
|
+
export declare function needsCharacterDirectory(input: DirectoryNeedInput): boolean;
|
|
116
|
+
//# sourceMappingURL=role.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"role.d.ts","sourceRoot":"","sources":["../../utils/role.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE7D;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,YAAY,GAAG,SAAS,CAAA;AAE3D;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC5B,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC3B,OAAO,CAGT;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,gBAAgB,EAAE,EAC9B,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACvC,gBAAgB,GAAG,IAAI,CAOzB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,gBAAgB,EAAE,EAC9B,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACvC,gBAAgB,EAAE,CAKpB;AAID;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAEnD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,EACxC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GACtB,OAAO,CAKT;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAC3B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,gBAAgB,CAAA;CAAE,GACzC;IACE,EAAE,EAAE,KAAK,CAAA;IACT;;;;OAIG;IACH,KAAK,EAAE,gBAAgB,GAAG,kBAAkB,GAAG,mBAAmB,CAAA;CACnE,CAAA;AAEL;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,gBAAgB,EAAE,EAC9B,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,EACxC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GACtB,mBAAmB,CAQrB;AAED,oEAAoE;AACpE,MAAM,WAAW,eAAe;IAC9B,6CAA6C;IAC7C,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACxC,uCAAuC;IACvC,WAAW,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAA;IAC3C,yEAAyE;IACzE,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,CAAA;IACxC,4CAA4C;IAC5C,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CACvC;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,GAAG,UAAU,CAchE;AAED,8EAA8E;AAC9E,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACxC,WAAW,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAA;IAC3C,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,CAAA;IACxC,kEAAkE;IAClE,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAC5C;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAQ1E"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { normalizeSuiAddress } from '@mysten/sui/utils';
|
|
2
|
+
/**
|
|
3
|
+
* True when two Sui addresses or object ids are the same, ignoring case and
|
|
4
|
+
* leading zeros.
|
|
5
|
+
*
|
|
6
|
+
* @category Utilities - Access
|
|
7
|
+
*/
|
|
8
|
+
export function sameAddress(a, b) {
|
|
9
|
+
if (!a || !b)
|
|
10
|
+
return false;
|
|
11
|
+
return normalizeSuiAddress(a) === normalizeSuiAddress(b);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The character bound to a wallet, from the character directory.
|
|
15
|
+
*
|
|
16
|
+
* @category Utilities - Access
|
|
17
|
+
*/
|
|
18
|
+
export function findCharacterByWallet(characters, walletAddress) {
|
|
19
|
+
if (!walletAddress)
|
|
20
|
+
return null;
|
|
21
|
+
return (characters.find((character) => sameAddress(character.walletAddress, walletAddress)) ?? null);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* All characters bound to a wallet, from the character directory. A wallet
|
|
25
|
+
* can be bound to more than one character.
|
|
26
|
+
*
|
|
27
|
+
* @category Utilities - Access
|
|
28
|
+
*/
|
|
29
|
+
export function findCharactersByWallet(characters, walletAddress) {
|
|
30
|
+
if (!walletAddress)
|
|
31
|
+
return [];
|
|
32
|
+
return characters.filter((character) => sameAddress(character.walletAddress, walletAddress));
|
|
33
|
+
}
|
|
34
|
+
const FULL_ADDRESS = /^0x[0-9a-fA-F]{64}$/;
|
|
35
|
+
/**
|
|
36
|
+
* True for a whole Sui address: 0x and 64 hex digits, ignoring surrounding
|
|
37
|
+
* whitespace.
|
|
38
|
+
*
|
|
39
|
+
* @category Utilities - Access
|
|
40
|
+
*/
|
|
41
|
+
export function isFullAddress(input) {
|
|
42
|
+
return FULL_ADDRESS.test(input.trim());
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* True for the roles that manage an entity: the shell and controllers.
|
|
46
|
+
*
|
|
47
|
+
* @category Utilities - Access
|
|
48
|
+
*/
|
|
49
|
+
export function canManage(role) {
|
|
50
|
+
return role === 'shell' || role === 'controller';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* True when a character already controls the entity: it is the shell, or it
|
|
54
|
+
* is on the access list.
|
|
55
|
+
*
|
|
56
|
+
* @category Utilities - Access
|
|
57
|
+
*/
|
|
58
|
+
export function isController(characterId, controllers, shellId) {
|
|
59
|
+
return (sameAddress(characterId, shellId) ||
|
|
60
|
+
!!controllers?.some((id) => sameAddress(id, characterId)));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Checks a pasted wallet address before adding its character to an entity's
|
|
64
|
+
* access list. Only a wallet bound to a character is accepted, never a
|
|
65
|
+
* character id; the character id it is bound to is what gets stored.
|
|
66
|
+
*
|
|
67
|
+
* @category Utilities - Access
|
|
68
|
+
* @param input - The wallet address as typed or pasted
|
|
69
|
+
* @param characters - The character directory
|
|
70
|
+
* @param controllers - The entity's access list (character ids), or null
|
|
71
|
+
* @param shellId - The shell's character id, when known; the shell is
|
|
72
|
+
* always a controller, so it can't be added again
|
|
73
|
+
*/
|
|
74
|
+
export function resolveNewController(input, characters, controllers, shellId) {
|
|
75
|
+
if (!isFullAddress(input))
|
|
76
|
+
return { ok: false, error: 'invalidAddress' };
|
|
77
|
+
const character = findCharacterByWallet(characters, input.trim());
|
|
78
|
+
if (!character)
|
|
79
|
+
return { ok: false, error: 'unknownCharacter' };
|
|
80
|
+
if (isController(character.characterId, controllers, shellId)) {
|
|
81
|
+
return { ok: false, error: 'alreadyController' };
|
|
82
|
+
}
|
|
83
|
+
return { ok: true, character };
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Works out the connected wallet's role on an entity. The shell is checked
|
|
87
|
+
* first, so a shell that is also on the access list is still the shell.
|
|
88
|
+
*
|
|
89
|
+
* @category Utilities - Access
|
|
90
|
+
*/
|
|
91
|
+
export function getEntityRole(input) {
|
|
92
|
+
const { walletAddress, entityOwner, controllers, characterId } = input;
|
|
93
|
+
if (!walletAddress)
|
|
94
|
+
return 'visitor';
|
|
95
|
+
if (sameAddress(walletAddress, entityOwner?.walletAddress))
|
|
96
|
+
return 'shell';
|
|
97
|
+
if (entityOwner?.kind === 'character' &&
|
|
98
|
+
sameAddress(characterId, entityOwner.holder)) {
|
|
99
|
+
return 'shell';
|
|
100
|
+
}
|
|
101
|
+
if (characterId && controllers?.some((id) => sameAddress(id, characterId))) {
|
|
102
|
+
return 'controller';
|
|
103
|
+
}
|
|
104
|
+
return 'visitor';
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Whether working out the wallet's role needs the character directory (every
|
|
108
|
+
* character event): only when a wallet is connected, its character isn't
|
|
109
|
+
* known, it isn't the shell's wallet, and the answer could depend on a
|
|
110
|
+
* character (the entity has controllers, or its cap is parked on one).
|
|
111
|
+
*
|
|
112
|
+
* @category Utilities - Access
|
|
113
|
+
*/
|
|
114
|
+
export function needsCharacterDirectory(input) {
|
|
115
|
+
const { walletAddress, entityOwner, controllers, knownCharacterId } = input;
|
|
116
|
+
return (!knownCharacterId &&
|
|
117
|
+
!!walletAddress &&
|
|
118
|
+
!sameAddress(walletAddress, entityOwner?.walletAddress) &&
|
|
119
|
+
(!!controllers?.length || entityOwner?.kind === 'character'));
|
|
120
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Input for fetching object data: either itemId + tenant (derive object ID) or a Sui object ID directly.
|
|
2
|
+
* @category Types
|
|
3
|
+
*/
|
|
4
|
+
export type FetchObjectDataInput = {
|
|
5
|
+
itemId: string;
|
|
6
|
+
selectedTenant: string;
|
|
7
|
+
} | {
|
|
8
|
+
objectId: string;
|
|
9
|
+
};
|
|
10
|
+
/** The object a SmartObjectProvider shows, as chosen by env or query params. */
|
|
11
|
+
export type ObjectSelection = {
|
|
12
|
+
/** A Sui object ID when isObjectIdDirect, otherwise an in-game item ID. */
|
|
13
|
+
objectId: string;
|
|
14
|
+
tenant: string;
|
|
15
|
+
isObjectIdDirect: boolean;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Reads the object to show: VITE_OBJECT_ID (a Sui object ID) wins, else the
|
|
19
|
+
* ?itemId= query param. Tenant comes from ?tenant= with fallback DEFAULT_TENANT.
|
|
20
|
+
* Returns null when neither is set.
|
|
21
|
+
*/
|
|
22
|
+
export declare function readObjectSelection(search: string, envObjectId: string | undefined): ObjectSelection | null;
|
|
23
|
+
export declare function toFetchObjectDataInput(selectedObjectId: string, selectedTenant: string, isObjectIdDirect: boolean): FetchObjectDataInput;
|
|
24
|
+
//# sourceMappingURL=smartObject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smartObject.d.ts","sourceRoot":"","sources":["../../utils/smartObject.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC5B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAA;AAExB,gFAAgF;AAChF,MAAM,MAAM,eAAe,GAAG;IAC5B,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,gBAAgB,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,eAAe,GAAG,IAAI,CAcxB;AAED,wBAAgB,sBAAsB,CACpC,gBAAgB,EAAE,MAAM,EACxB,cAAc,EAAE,MAAM,EACtB,gBAAgB,EAAE,OAAO,GACxB,oBAAoB,CAItB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { QueryParams } from '../types/index.js';
|
|
2
|
+
import { DEFAULT_TENANT } from './constants.js';
|
|
3
|
+
/**
|
|
4
|
+
* Reads the object to show: VITE_OBJECT_ID (a Sui object ID) wins, else the
|
|
5
|
+
* ?itemId= query param. Tenant comes from ?tenant= with fallback DEFAULT_TENANT.
|
|
6
|
+
* Returns null when neither is set.
|
|
7
|
+
*/
|
|
8
|
+
export function readObjectSelection(search, envObjectId) {
|
|
9
|
+
const queryParams = new URLSearchParams(search);
|
|
10
|
+
const tenant = queryParams.get(QueryParams.TENANT)?.trim() || DEFAULT_TENANT;
|
|
11
|
+
if (envObjectId) {
|
|
12
|
+
return { objectId: envObjectId, tenant, isObjectIdDirect: true };
|
|
13
|
+
}
|
|
14
|
+
const queryItemId = queryParams.get(QueryParams.ITEM_ID);
|
|
15
|
+
if (queryItemId) {
|
|
16
|
+
return { objectId: queryItemId, tenant, isObjectIdDirect: false };
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
export function toFetchObjectDataInput(selectedObjectId, selectedTenant, isObjectIdDirect) {
|
|
21
|
+
return isObjectIdDirect
|
|
22
|
+
? { objectId: selectedObjectId }
|
|
23
|
+
: { itemId: selectedObjectId, selectedTenant };
|
|
24
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { SuiChain } from '@mysten/wallet-standard';
|
|
2
|
+
import { type DetailedAssemblyResponse, type SmartAssemblyResponse } from '../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Abbreviate a Sui address or hex string for display.
|
|
5
|
+
*
|
|
6
|
+
* Shortens long addresses to show only the beginning and end characters
|
|
7
|
+
* with ellipsis in the middle.
|
|
8
|
+
*
|
|
9
|
+
* @category Utilities - Formatting
|
|
10
|
+
* @param string - The address or hex string to abbreviate
|
|
11
|
+
* @param precision - Number of characters to show on each end (default: 5)
|
|
12
|
+
* @param expanded - If true, returns the full string without abbreviation
|
|
13
|
+
* @returns The abbreviated string (e.g., "0x123...abc")
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* abbreviateAddress("0x1234567890abcdef1234567890abcdef"); // "0x123...cdef"
|
|
18
|
+
* abbreviateAddress("0x1234567890abcdef", 3); // "0x1...def"
|
|
19
|
+
* abbreviateAddress("0x1234567890abcdef", 5, true); // Full address
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const abbreviateAddress: (string?: `0x${string}` | string, precision?: number, expanded?: boolean) => string;
|
|
23
|
+
/**
|
|
24
|
+
* Check if an account is the owner of a smart assembly.
|
|
25
|
+
*
|
|
26
|
+
* Compares the assembly's owner address with the provided account address
|
|
27
|
+
* to determine ownership.
|
|
28
|
+
*
|
|
29
|
+
* @category Utilities - Assembly
|
|
30
|
+
* @param assembly - The assembly object to check ownership of
|
|
31
|
+
* @param account - The account address to check against
|
|
32
|
+
* @returns True if the account owns the assembly, false otherwise
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* // assembly is a DetailedAssemblyResponse from the World API
|
|
37
|
+
* if (isOwner(assembly, currentAccount?.address)) {
|
|
38
|
+
* // Show owner-only actions
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare const isOwner: (assembly: DetailedAssemblyResponse | SmartAssemblyResponse | null, account?: `0x${string}` | string) => boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Generate a Suiscan transaction URL for a given transaction hash.
|
|
45
|
+
*
|
|
46
|
+
* @category Utilities - Assembly
|
|
47
|
+
* @param suiChain - The Sui chain identifier (e.g., "sui:testnet", "sui:mainnet")
|
|
48
|
+
* @param txHash - The transaction digest hash
|
|
49
|
+
* @returns Full Suiscan URL to view the transaction
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const url = getTxUrl("sui:testnet", "ABC123...");
|
|
54
|
+
* // Returns: "https://suiscan.xyz/testnet/tx/ABC123..."
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare const getTxUrl: (suiChain: SuiChain, txHash: string) => string;
|
|
58
|
+
/** Strips protocol (e.g. https://) from a URL and returns the rest. @category Utilities - Formatting */
|
|
59
|
+
export declare const parseURL: (string: string) => string;
|
|
60
|
+
/** Copies the given string to the clipboard. @category Utilities - Formatting */
|
|
61
|
+
export declare const clickToCopy: (string: string) => Promise<void>;
|
|
62
|
+
/** Returns elements that appear in both arrays. @category Utilities - Formatting */
|
|
63
|
+
export declare const getCommonItems: (array1: any[], array2: any[]) => any[];
|
|
64
|
+
/** Removes trailing zeros after the last significant decimal. @category Utilities - Formatting */
|
|
65
|
+
export declare const removeTrailingZeros: (number: string) => string;
|
|
66
|
+
/** Returns the env value or fallback if empty. @category Utilities - Config */
|
|
67
|
+
export declare const getEnv: (env: string, fallback: string) => string;
|
|
68
|
+
/**
|
|
69
|
+
* Volume in m³ from unit quantity and volume per unit (litres, 10^3).
|
|
70
|
+
* @param quantity - Unit quantity of the item
|
|
71
|
+
* @param volume - Volume per unit in litres (10^3)
|
|
72
|
+
* @returns Volume in m³
|
|
73
|
+
* @category Utilities - Formatting
|
|
74
|
+
*/
|
|
75
|
+
export declare const getVolumeM3: (quantity: bigint, volume: bigint) => number;
|
|
76
|
+
/**
|
|
77
|
+
* Format from cubic decimeters/litres (dm³\l) to cubic meters (m³).
|
|
78
|
+
*
|
|
79
|
+
* @category Utilities - Formatting
|
|
80
|
+
* @param quantity - The raw volume value as string or bigint in cubic decimeters/litres (dm³/l)
|
|
81
|
+
* @returns Volume in cubic meters
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const m3 = formatM3(BigInt("1000")); // 1.0 m³
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare const formatM3: (quantity: string | bigint) => number;
|
|
89
|
+
/**
|
|
90
|
+
* Get the dApp URL for an assembly, ensuring it has a protocol prefix.
|
|
91
|
+
*
|
|
92
|
+
* @category Utilities - Assembly
|
|
93
|
+
* @param assembly - The assembly object
|
|
94
|
+
* @param fallbackUrl - Used when the assembly has no `dappURL` of its own.
|
|
95
|
+
* @returns The full dApp URL with https:// prefix if needed
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* // assembly is a DetailedAssemblyResponse from the World API
|
|
100
|
+
* const dappUrl = getDappUrl(assembly);
|
|
101
|
+
* if (dappUrl) {
|
|
102
|
+
* window.open(dappUrl, '_blank');
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export declare const getDappUrl: (assembly: Pick<DetailedAssemblyResponse, 'dappURL'> | null, fallbackUrl?: string) => string;
|
|
107
|
+
/**
|
|
108
|
+
* Check if two addresses match.
|
|
109
|
+
*
|
|
110
|
+
* @category Utilities - Assembly
|
|
111
|
+
* @param address1 - First address to compare
|
|
112
|
+
* @param address2 - Second address to compare
|
|
113
|
+
* @returns True if addresses match, false otherwise
|
|
114
|
+
*/
|
|
115
|
+
export declare const findOwnerByAddress: (address1: string | undefined, address2: string | undefined) => boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Format a duration in seconds to a human-readable string.
|
|
118
|
+
*
|
|
119
|
+
* Displays the duration in days, hours, minutes, and seconds as appropriate.
|
|
120
|
+
*
|
|
121
|
+
* @category Utilities - Formatting
|
|
122
|
+
* @param seconds - Duration in seconds
|
|
123
|
+
* @returns Formatted duration string (e.g., "02d 05h 30m 15s")
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* formatDuration(3665); // "01h 01m 05s"
|
|
128
|
+
* formatDuration(90061); // "01d 01h 01m 01s"
|
|
129
|
+
* formatDuration(45); // "45s"
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export declare const formatDuration: (seconds: number) => string;
|
|
133
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../utils/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC3B,MAAM,UAAU,CAAA;AAEjB;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,iBAAiB,YACnB,KAAK,MAAM,EAAE,GAAG,MAAM,6CAG9B,MAKF,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,OAAO,aACR,wBAAwB,GAAG,qBAAqB,GAAG,IAAI,YACvD,KAAK,MAAM,EAAE,GAAG,MAAM,KAC/B,OAGF,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,QAAQ,aAAc,QAAQ,UAAU,MAAM,KAAG,MAI7D,CAAA;AAED,wGAAwG;AACxG,eAAO,MAAM,QAAQ,WAAY,MAAM,KAAG,MAKzC,CAAA;AAED,iFAAiF;AACjF,eAAO,MAAM,WAAW,WAAY,MAAM,kBAEzC,CAAA;AAED,oFAAoF;AACpF,eAAO,MAAM,cAAc,WAAY,GAAG,EAAE,UAAU,GAAG,EAAE,UAa1D,CAAA;AAED,kGAAkG;AAClG,eAAO,MAAM,mBAAmB,WAAY,MAAM,WAEjD,CAAA;AAED,+EAA+E;AAC/E,eAAO,MAAM,MAAM,QAAS,MAAM,YAAY,MAAM,KAAG,MAGtD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,aAAc,MAAM,UAAU,MAAM,KAAG,MAG9D,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ,aAAc,MAAM,GAAG,MAAM,KAAG,MAEpD,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,UAAU,aACX,IAAI,CAAC,wBAAwB,EAAE,SAAS,CAAC,GAAG,IAAI,gBAC5C,MAAM,KACnB,MAMF,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,aACnB,MAAM,GAAG,SAAS,YAClB,MAAM,GAAG,SAAS,KAC3B,OAGF,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,YAAa,MAAM,KAAG,MAwBhD,CAAA"}
|