@0xslots/sdk 0.8.1 → 0.8.3

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/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { GraphQLClient, RequestOptions } from 'graphql-request';
2
2
  import * as graphql from 'graphql';
3
- import { Address, PublicClient, WalletClient, Hash } from 'viem';
3
+ import { PublicClient, WalletClient, Address, Hash } from 'viem';
4
4
 
5
5
  type Maybe<T> = T | null;
6
6
  type InputMaybe<T> = T | null;
@@ -3311,6 +3311,149 @@ type GetModulesQuery = {
3311
3311
  version: string;
3312
3312
  }>;
3313
3313
  };
3314
+ type MetadataSlotFieldsFragment = {
3315
+ __typename?: 'MetadataSlot';
3316
+ id: string;
3317
+ uri: string;
3318
+ updatedBy: string;
3319
+ updateCount: string;
3320
+ createdAt: string;
3321
+ createdTx: string;
3322
+ updatedAt: string;
3323
+ updatedTx: string;
3324
+ slot: {
3325
+ __typename?: 'Slot';
3326
+ id: string;
3327
+ recipient: string;
3328
+ occupant?: string | null;
3329
+ price: string;
3330
+ deposit: string;
3331
+ currency: {
3332
+ __typename?: 'Currency';
3333
+ id: string;
3334
+ symbol?: string | null;
3335
+ decimals: number;
3336
+ };
3337
+ };
3338
+ };
3339
+ type GetMetadataSlotsQueryVariables = Exact<{
3340
+ first?: InputMaybe<Scalars['Int']['input']>;
3341
+ skip?: InputMaybe<Scalars['Int']['input']>;
3342
+ orderBy?: InputMaybe<MetadataSlot_OrderBy>;
3343
+ orderDirection?: InputMaybe<OrderDirection>;
3344
+ }>;
3345
+ type GetMetadataSlotsQuery = {
3346
+ __typename?: 'Query';
3347
+ metadataSlots: Array<{
3348
+ __typename?: 'MetadataSlot';
3349
+ id: string;
3350
+ uri: string;
3351
+ updatedBy: string;
3352
+ updateCount: string;
3353
+ createdAt: string;
3354
+ createdTx: string;
3355
+ updatedAt: string;
3356
+ updatedTx: string;
3357
+ slot: {
3358
+ __typename?: 'Slot';
3359
+ id: string;
3360
+ recipient: string;
3361
+ occupant?: string | null;
3362
+ price: string;
3363
+ deposit: string;
3364
+ currency: {
3365
+ __typename?: 'Currency';
3366
+ id: string;
3367
+ symbol?: string | null;
3368
+ decimals: number;
3369
+ };
3370
+ };
3371
+ }>;
3372
+ };
3373
+ type GetMetadataSlotQueryVariables = Exact<{
3374
+ id: Scalars['ID']['input'];
3375
+ }>;
3376
+ type GetMetadataSlotQuery = {
3377
+ __typename?: 'Query';
3378
+ metadataSlot?: {
3379
+ __typename?: 'MetadataSlot';
3380
+ id: string;
3381
+ uri: string;
3382
+ updatedBy: string;
3383
+ updateCount: string;
3384
+ createdAt: string;
3385
+ createdTx: string;
3386
+ updatedAt: string;
3387
+ updatedTx: string;
3388
+ slot: {
3389
+ __typename?: 'Slot';
3390
+ id: string;
3391
+ recipient: string;
3392
+ occupant?: string | null;
3393
+ price: string;
3394
+ deposit: string;
3395
+ currency: {
3396
+ __typename?: 'Currency';
3397
+ id: string;
3398
+ symbol?: string | null;
3399
+ decimals: number;
3400
+ };
3401
+ };
3402
+ } | null;
3403
+ };
3404
+ type GetMetadataSlotsByRecipientQueryVariables = Exact<{
3405
+ recipient: Scalars['Bytes']['input'];
3406
+ first?: InputMaybe<Scalars['Int']['input']>;
3407
+ }>;
3408
+ type GetMetadataSlotsByRecipientQuery = {
3409
+ __typename?: 'Query';
3410
+ metadataSlots: Array<{
3411
+ __typename?: 'MetadataSlot';
3412
+ id: string;
3413
+ uri: string;
3414
+ updatedBy: string;
3415
+ updateCount: string;
3416
+ createdAt: string;
3417
+ createdTx: string;
3418
+ updatedAt: string;
3419
+ updatedTx: string;
3420
+ slot: {
3421
+ __typename?: 'Slot';
3422
+ id: string;
3423
+ recipient: string;
3424
+ occupant?: string | null;
3425
+ price: string;
3426
+ deposit: string;
3427
+ currency: {
3428
+ __typename?: 'Currency';
3429
+ id: string;
3430
+ symbol?: string | null;
3431
+ decimals: number;
3432
+ };
3433
+ };
3434
+ }>;
3435
+ };
3436
+ type GetMetadataUpdatedEventsQueryVariables = Exact<{
3437
+ slot?: InputMaybe<Scalars['String']['input']>;
3438
+ first?: InputMaybe<Scalars['Int']['input']>;
3439
+ orderBy?: InputMaybe<MetadataUpdatedEvent_OrderBy>;
3440
+ orderDirection?: InputMaybe<OrderDirection>;
3441
+ }>;
3442
+ type GetMetadataUpdatedEventsQuery = {
3443
+ __typename?: 'Query';
3444
+ metadataUpdatedEvents: Array<{
3445
+ __typename?: 'MetadataUpdatedEvent';
3446
+ id: string;
3447
+ uri: string;
3448
+ timestamp: string;
3449
+ blockNumber: string;
3450
+ tx: string;
3451
+ slot: {
3452
+ __typename?: 'Slot';
3453
+ id: string;
3454
+ };
3455
+ }>;
3456
+ };
3314
3457
  type SlotFieldsFragment = {
3315
3458
  __typename?: 'Slot';
3316
3459
  id: string;
@@ -3588,6 +3731,7 @@ type GetSlotsByOccupantQuery = {
3588
3731
  };
3589
3732
  declare const AccountFieldsFragmentDoc: graphql.DocumentNode;
3590
3733
  declare const CurrencyFieldsFragmentDoc: graphql.DocumentNode;
3734
+ declare const MetadataSlotFieldsFragmentDoc: graphql.DocumentNode;
3591
3735
  declare const SlotFieldsFragmentDoc: graphql.DocumentNode;
3592
3736
  declare const GetAccountDocument: graphql.DocumentNode;
3593
3737
  declare const GetAccountsDocument: graphql.DocumentNode;
@@ -3604,6 +3748,10 @@ declare const GetPriceUpdatedEventsDocument: graphql.DocumentNode;
3604
3748
  declare const GetSlotActivityDocument: graphql.DocumentNode;
3605
3749
  declare const GetFactoryDocument: graphql.DocumentNode;
3606
3750
  declare const GetModulesDocument: graphql.DocumentNode;
3751
+ declare const GetMetadataSlotsDocument: graphql.DocumentNode;
3752
+ declare const GetMetadataSlotDocument: graphql.DocumentNode;
3753
+ declare const GetMetadataSlotsByRecipientDocument: graphql.DocumentNode;
3754
+ declare const GetMetadataUpdatedEventsDocument: graphql.DocumentNode;
3607
3755
  declare const GetSlotsDocument: graphql.DocumentNode;
3608
3756
  declare const GetSlotDocument: graphql.DocumentNode;
3609
3757
  declare const GetSlotsByRecipientDocument: graphql.DocumentNode;
@@ -3625,6 +3773,10 @@ declare function getSdk(client: GraphQLClient, withWrapper?: SdkFunctionWrapper)
3625
3773
  GetSlotActivity(variables: GetSlotActivityQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetSlotActivityQuery>;
3626
3774
  GetFactory(variables?: GetFactoryQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetFactoryQuery>;
3627
3775
  GetModules(variables: GetModulesQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetModulesQuery>;
3776
+ GetMetadataSlots(variables?: GetMetadataSlotsQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetMetadataSlotsQuery>;
3777
+ GetMetadataSlot(variables: GetMetadataSlotQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetMetadataSlotQuery>;
3778
+ GetMetadataSlotsByRecipient(variables: GetMetadataSlotsByRecipientQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetMetadataSlotsByRecipientQuery>;
3779
+ GetMetadataUpdatedEvents(variables?: GetMetadataUpdatedEventsQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetMetadataUpdatedEventsQuery>;
3628
3780
  GetSlots(variables: GetSlotsQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetSlotsQuery>;
3629
3781
  GetSlot(variables: GetSlotQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetSlotQuery>;
3630
3782
  GetSlotsByRecipient(variables: GetSlotsByRecipientQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetSlotsByRecipientQuery>;
@@ -3632,6 +3784,54 @@ declare function getSdk(client: GraphQLClient, withWrapper?: SdkFunctionWrapper)
3632
3784
  };
3633
3785
  type Sdk = ReturnType<typeof getSdk>;
3634
3786
 
3787
+ /**
3788
+ * Module namespace for MetadataModule operations.
3789
+ * Accessible via `client.modules.metadata`.
3790
+ *
3791
+ * Read: subgraph queries for MetadataSlot entities
3792
+ * Write: `updateMetadata(slot, uri)` on the MetadataModule contract
3793
+ * RPC read: `tokenURI(slot)` on the MetadataModule contract
3794
+ */
3795
+ declare class MetadataModuleClient {
3796
+ private readonly sdk;
3797
+ private readonly chainId;
3798
+ private readonly _publicClient?;
3799
+ private readonly _walletClient?;
3800
+ private readonly _moduleAddress?;
3801
+ constructor(opts: {
3802
+ sdk: ReturnType<typeof getSdk>;
3803
+ chainId: number;
3804
+ publicClient?: PublicClient;
3805
+ walletClient?: WalletClient;
3806
+ moduleAddress?: Address;
3807
+ });
3808
+ private get moduleAddress();
3809
+ private get wallet();
3810
+ private get account();
3811
+ private get chain();
3812
+ private get publicClient();
3813
+ private query;
3814
+ /** Get all slots with metadata, ordered by most recently updated. */
3815
+ getSlots(...args: Parameters<ReturnType<typeof getSdk>["GetMetadataSlots"]>): Promise<GetMetadataSlotsQuery>;
3816
+ /** Get a single metadata slot by slot address. */
3817
+ getSlot(...args: Parameters<ReturnType<typeof getSdk>["GetMetadataSlot"]>): Promise<GetMetadataSlotQuery>;
3818
+ /** Get all metadata slots for a given recipient. */
3819
+ getSlotsByRecipient(...args: Parameters<ReturnType<typeof getSdk>["GetMetadataSlotsByRecipient"]>): Promise<GetMetadataSlotsByRecipientQuery>;
3820
+ /** Get metadata update history for a slot. */
3821
+ getUpdateHistory(...args: Parameters<ReturnType<typeof getSdk>["GetMetadataUpdatedEvents"]>): Promise<GetMetadataUpdatedEventsQuery>;
3822
+ /** Read the current URI for a slot directly from chain (bypasses subgraph). */
3823
+ getURI(slot: Address): Promise<string>;
3824
+ /**
3825
+ * Update the metadata URI for a slot. Only callable by the current occupant.
3826
+ * @param slot - The slot contract address
3827
+ * @param uri - The new URI (e.g. ipfs://..., https://...)
3828
+ * @returns Transaction hash
3829
+ */
3830
+ updateMetadata(slot: Address, uri: string): Promise<Hash>;
3831
+ /** Returns the MetadataModule contract address for the configured chain. */
3832
+ getAddress(): Address;
3833
+ }
3834
+
3635
3835
  interface SubgraphMeta {
3636
3836
  _meta: {
3637
3837
  block: {
@@ -3678,6 +3878,7 @@ interface SlotsClientConfig {
3678
3878
  publicClient?: PublicClient;
3679
3879
  walletClient?: WalletClient;
3680
3880
  subgraphUrl?: string;
3881
+ subgraphApiKey?: string;
3681
3882
  headers?: Record<string, string>;
3682
3883
  }
3683
3884
  /**
@@ -3704,6 +3905,10 @@ declare class SlotsClient {
3704
3905
  private readonly walletClient?;
3705
3906
  private readonly _factory?;
3706
3907
  private _atomicSupport;
3908
+ /** Module namespaces for protocol extensions. */
3909
+ readonly modules: {
3910
+ metadata: MetadataModuleClient;
3911
+ };
3707
3912
  constructor(config: SlotsClientConfig);
3708
3913
  /** Returns the chain ID this client was configured for. */
3709
3914
  getChainId(): SlotsChain;
@@ -3726,6 +3931,10 @@ declare class SlotsClient {
3726
3931
  GetSlotActivity(variables: GetSlotActivityQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetSlotActivityQuery>;
3727
3932
  GetFactory(variables?: GetFactoryQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetFactoryQuery>;
3728
3933
  GetModules(variables: GetModulesQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetModulesQuery>;
3934
+ GetMetadataSlots(variables?: GetMetadataSlotsQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetMetadataSlotsQuery>;
3935
+ GetMetadataSlot(variables: GetMetadataSlotQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetMetadataSlotQuery>;
3936
+ GetMetadataSlotsByRecipient(variables: GetMetadataSlotsByRecipientQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetMetadataSlotsByRecipientQuery>;
3937
+ GetMetadataUpdatedEvents(variables?: GetMetadataUpdatedEventsQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetMetadataUpdatedEventsQuery>;
3729
3938
  GetSlots(variables: GetSlotsQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetSlotsQuery>;
3730
3939
  GetSlot(variables: GetSlotQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetSlotQuery>;
3731
3940
  GetSlotsByRecipient(variables: GetSlotsByRecipientQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetSlotsByRecipientQuery>;
@@ -3925,4 +4134,4 @@ declare class SlotsError extends Error {
3925
4134
  constructor(operation: string, cause: unknown);
3926
4135
  }
3927
4136
 
3928
- export { type Account, type AccountFieldsFragment, AccountFieldsFragmentDoc, type AccountSlotsAsOccupantArgs, type AccountSlotsAsRecipientArgs, type AccountType, type Account_Filter, type Account_OrderBy, type Aggregation_Current, type Aggregation_Interval, type BlockChangedFilter, type Block_Height, type BoughtEvent, type BoughtEvent_Filter, type BoughtEvent_OrderBy, type BuyParams, type CreateSlotParams, type CreateSlotsParams, type Currency, type CurrencyFieldsFragment, CurrencyFieldsFragmentDoc, type Currency_Filter, type Currency_OrderBy, type DepositedEvent, type DepositedEvent_Filter, type DepositedEvent_OrderBy, type Exact, type Factory, type FactoryModulesArgs, type Factory_Filter, type Factory_OrderBy, GetAccountDocument, type GetAccountQuery, type GetAccountQueryVariables, GetAccountsDocument, type GetAccountsQuery, type GetAccountsQueryVariables, GetBoughtEventsDocument, type GetBoughtEventsQuery, type GetBoughtEventsQueryVariables, GetDepositedEventsDocument, type GetDepositedEventsQuery, type GetDepositedEventsQueryVariables, GetFactoryDocument, type GetFactoryQuery, type GetFactoryQueryVariables, GetLiquidatedEventsDocument, type GetLiquidatedEventsQuery, type GetLiquidatedEventsQueryVariables, GetModulesDocument, type GetModulesQuery, type GetModulesQueryVariables, GetPriceUpdatedEventsDocument, type GetPriceUpdatedEventsQuery, type GetPriceUpdatedEventsQueryVariables, GetRecentEventsDocument, type GetRecentEventsQuery, type GetRecentEventsQueryVariables, GetReleasedEventsDocument, type GetReleasedEventsQuery, type GetReleasedEventsQueryVariables, GetSettledEventsDocument, type GetSettledEventsQuery, type GetSettledEventsQueryVariables, GetSlotActivityDocument, type GetSlotActivityQuery, type GetSlotActivityQueryVariables, GetSlotDeployedEventsDocument, type GetSlotDeployedEventsQuery, type GetSlotDeployedEventsQueryVariables, GetSlotDocument, type GetSlotQuery, type GetSlotQueryVariables, GetSlotsByOccupantDocument, type GetSlotsByOccupantQuery, type GetSlotsByOccupantQueryVariables, GetSlotsByRecipientDocument, type GetSlotsByRecipientQuery, type GetSlotsByRecipientQueryVariables, GetSlotsDocument, type GetSlotsQuery, type GetSlotsQueryVariables, GetTaxCollectedEventsDocument, type GetTaxCollectedEventsQuery, type GetTaxCollectedEventsQueryVariables, GetWithdrawnEventsDocument, type GetWithdrawnEventsQuery, type GetWithdrawnEventsQueryVariables, type Incremental, type InputMaybe, type LiquidatedEvent, type LiquidatedEvent_Filter, type LiquidatedEvent_OrderBy, type MakeEmpty, type MakeMaybe, type MakeOptional, type Maybe, type MetadataSlot, type MetadataSlot_Filter, type MetadataSlot_OrderBy, type MetadataUpdatedEvent, type MetadataUpdatedEvent_Filter, type MetadataUpdatedEvent_OrderBy, type Module, type ModuleUpdateProposedEvent, type ModuleUpdateProposedEvent_Filter, type ModuleUpdateProposedEvent_OrderBy, type Module_Filter, type Module_OrderBy, type OrderDirection, type PendingUpdateCancelledEvent, type PendingUpdateCancelledEvent_Filter, type PendingUpdateCancelledEvent_OrderBy, type PriceUpdatedEvent, type PriceUpdatedEvent_Filter, type PriceUpdatedEvent_OrderBy, type Query, type QueryAccountArgs, type QueryAccountsArgs, type QueryBoughtEventArgs, type QueryBoughtEventsArgs, type QueryCurrenciesArgs, type QueryCurrencyArgs, type QueryDepositedEventArgs, type QueryDepositedEventsArgs, type QueryFactoriesArgs, type QueryFactoryArgs, type QueryLiquidatedEventArgs, type QueryLiquidatedEventsArgs, type QueryMetadataSlotArgs, type QueryMetadataSlotsArgs, type QueryMetadataUpdatedEventArgs, type QueryMetadataUpdatedEventsArgs, type QueryModuleArgs, type QueryModuleUpdateProposedEventArgs, type QueryModuleUpdateProposedEventsArgs, type QueryModulesArgs, type QueryPendingUpdateCancelledEventArgs, type QueryPendingUpdateCancelledEventsArgs, type QueryPriceUpdatedEventArgs, type QueryPriceUpdatedEventsArgs, type QueryReleasedEventArgs, type QueryReleasedEventsArgs, type QuerySettledEventArgs, type QuerySettledEventsArgs, type QuerySlotArgs, type QuerySlotDeployedEventArgs, type QuerySlotDeployedEventsArgs, type QuerySlotsArgs, type QueryTaxCollectedEventArgs, type QueryTaxCollectedEventsArgs, type QueryTaxUpdateProposedEventArgs, type QueryTaxUpdateProposedEventsArgs, type QueryWithdrawnEventArgs, type QueryWithdrawnEventsArgs, type Query_MetaArgs, type ReleasedEvent, type ReleasedEvent_Filter, type ReleasedEvent_OrderBy, SUBGRAPH_URLS, type Scalars, type Sdk, type SdkFunctionWrapper, type SettledEvent, type SettledEvent_Filter, type SettledEvent_OrderBy, type Slot, type SlotConfig, type SlotDeployedEvent, type SlotDeployedEvent_Filter, type SlotDeployedEvent_OrderBy, type SlotDepositsArgs, type SlotFieldsFragment, SlotFieldsFragmentDoc, type SlotInitParams, type SlotLiquidationsArgs, type SlotMetadataUpdatesArgs, type SlotModuleUpdateProposalsArgs, type SlotPendingUpdateCancellationsArgs, type SlotPriceUpdatesArgs, type SlotPurchasesArgs, type SlotReleasesArgs, type SlotSettlementsArgs, type SlotTaxCollectionsArgs, type SlotTaxUpdateProposalsArgs, type SlotWithdrawalsArgs, type Slot_Filter, type Slot_OrderBy, SlotsChain, SlotsClient, type SlotsClientConfig, SlotsError, type SubgraphMeta, type TaxCollectedEvent, type TaxCollectedEvent_Filter, type TaxCollectedEvent_OrderBy, type TaxUpdateProposedEvent, type TaxUpdateProposedEvent_Filter, type TaxUpdateProposedEvent_OrderBy, type WithdrawnEvent, type WithdrawnEvent_Filter, type WithdrawnEvent_OrderBy, type _Block_, type _Meta_, type _SubgraphErrorPolicy_, createSlotsClient, getSdk };
4137
+ export { type Account, type AccountFieldsFragment, AccountFieldsFragmentDoc, type AccountSlotsAsOccupantArgs, type AccountSlotsAsRecipientArgs, type AccountType, type Account_Filter, type Account_OrderBy, type Aggregation_Current, type Aggregation_Interval, type BlockChangedFilter, type Block_Height, type BoughtEvent, type BoughtEvent_Filter, type BoughtEvent_OrderBy, type BuyParams, type CreateSlotParams, type CreateSlotsParams, type Currency, type CurrencyFieldsFragment, CurrencyFieldsFragmentDoc, type Currency_Filter, type Currency_OrderBy, type DepositedEvent, type DepositedEvent_Filter, type DepositedEvent_OrderBy, type Exact, type Factory, type FactoryModulesArgs, type Factory_Filter, type Factory_OrderBy, GetAccountDocument, type GetAccountQuery, type GetAccountQueryVariables, GetAccountsDocument, type GetAccountsQuery, type GetAccountsQueryVariables, GetBoughtEventsDocument, type GetBoughtEventsQuery, type GetBoughtEventsQueryVariables, GetDepositedEventsDocument, type GetDepositedEventsQuery, type GetDepositedEventsQueryVariables, GetFactoryDocument, type GetFactoryQuery, type GetFactoryQueryVariables, GetLiquidatedEventsDocument, type GetLiquidatedEventsQuery, type GetLiquidatedEventsQueryVariables, GetMetadataSlotDocument, type GetMetadataSlotQuery, type GetMetadataSlotQueryVariables, GetMetadataSlotsByRecipientDocument, type GetMetadataSlotsByRecipientQuery, type GetMetadataSlotsByRecipientQueryVariables, GetMetadataSlotsDocument, type GetMetadataSlotsQuery, type GetMetadataSlotsQueryVariables, GetMetadataUpdatedEventsDocument, type GetMetadataUpdatedEventsQuery, type GetMetadataUpdatedEventsQueryVariables, GetModulesDocument, type GetModulesQuery, type GetModulesQueryVariables, GetPriceUpdatedEventsDocument, type GetPriceUpdatedEventsQuery, type GetPriceUpdatedEventsQueryVariables, GetRecentEventsDocument, type GetRecentEventsQuery, type GetRecentEventsQueryVariables, GetReleasedEventsDocument, type GetReleasedEventsQuery, type GetReleasedEventsQueryVariables, GetSettledEventsDocument, type GetSettledEventsQuery, type GetSettledEventsQueryVariables, GetSlotActivityDocument, type GetSlotActivityQuery, type GetSlotActivityQueryVariables, GetSlotDeployedEventsDocument, type GetSlotDeployedEventsQuery, type GetSlotDeployedEventsQueryVariables, GetSlotDocument, type GetSlotQuery, type GetSlotQueryVariables, GetSlotsByOccupantDocument, type GetSlotsByOccupantQuery, type GetSlotsByOccupantQueryVariables, GetSlotsByRecipientDocument, type GetSlotsByRecipientQuery, type GetSlotsByRecipientQueryVariables, GetSlotsDocument, type GetSlotsQuery, type GetSlotsQueryVariables, GetTaxCollectedEventsDocument, type GetTaxCollectedEventsQuery, type GetTaxCollectedEventsQueryVariables, GetWithdrawnEventsDocument, type GetWithdrawnEventsQuery, type GetWithdrawnEventsQueryVariables, type Incremental, type InputMaybe, type LiquidatedEvent, type LiquidatedEvent_Filter, type LiquidatedEvent_OrderBy, type MakeEmpty, type MakeMaybe, type MakeOptional, type Maybe, MetadataModuleClient, type MetadataSlot, type MetadataSlotFieldsFragment, MetadataSlotFieldsFragmentDoc, type MetadataSlot_Filter, type MetadataSlot_OrderBy, type MetadataUpdatedEvent, type MetadataUpdatedEvent_Filter, type MetadataUpdatedEvent_OrderBy, type Module, type ModuleUpdateProposedEvent, type ModuleUpdateProposedEvent_Filter, type ModuleUpdateProposedEvent_OrderBy, type Module_Filter, type Module_OrderBy, type OrderDirection, type PendingUpdateCancelledEvent, type PendingUpdateCancelledEvent_Filter, type PendingUpdateCancelledEvent_OrderBy, type PriceUpdatedEvent, type PriceUpdatedEvent_Filter, type PriceUpdatedEvent_OrderBy, type Query, type QueryAccountArgs, type QueryAccountsArgs, type QueryBoughtEventArgs, type QueryBoughtEventsArgs, type QueryCurrenciesArgs, type QueryCurrencyArgs, type QueryDepositedEventArgs, type QueryDepositedEventsArgs, type QueryFactoriesArgs, type QueryFactoryArgs, type QueryLiquidatedEventArgs, type QueryLiquidatedEventsArgs, type QueryMetadataSlotArgs, type QueryMetadataSlotsArgs, type QueryMetadataUpdatedEventArgs, type QueryMetadataUpdatedEventsArgs, type QueryModuleArgs, type QueryModuleUpdateProposedEventArgs, type QueryModuleUpdateProposedEventsArgs, type QueryModulesArgs, type QueryPendingUpdateCancelledEventArgs, type QueryPendingUpdateCancelledEventsArgs, type QueryPriceUpdatedEventArgs, type QueryPriceUpdatedEventsArgs, type QueryReleasedEventArgs, type QueryReleasedEventsArgs, type QuerySettledEventArgs, type QuerySettledEventsArgs, type QuerySlotArgs, type QuerySlotDeployedEventArgs, type QuerySlotDeployedEventsArgs, type QuerySlotsArgs, type QueryTaxCollectedEventArgs, type QueryTaxCollectedEventsArgs, type QueryTaxUpdateProposedEventArgs, type QueryTaxUpdateProposedEventsArgs, type QueryWithdrawnEventArgs, type QueryWithdrawnEventsArgs, type Query_MetaArgs, type ReleasedEvent, type ReleasedEvent_Filter, type ReleasedEvent_OrderBy, SUBGRAPH_URLS, type Scalars, type Sdk, type SdkFunctionWrapper, type SettledEvent, type SettledEvent_Filter, type SettledEvent_OrderBy, type Slot, type SlotConfig, type SlotDeployedEvent, type SlotDeployedEvent_Filter, type SlotDeployedEvent_OrderBy, type SlotDepositsArgs, type SlotFieldsFragment, SlotFieldsFragmentDoc, type SlotInitParams, type SlotLiquidationsArgs, type SlotMetadataUpdatesArgs, type SlotModuleUpdateProposalsArgs, type SlotPendingUpdateCancellationsArgs, type SlotPriceUpdatesArgs, type SlotPurchasesArgs, type SlotReleasesArgs, type SlotSettlementsArgs, type SlotTaxCollectionsArgs, type SlotTaxUpdateProposalsArgs, type SlotWithdrawalsArgs, type Slot_Filter, type Slot_OrderBy, SlotsChain, SlotsClient, type SlotsClientConfig, SlotsError, type SubgraphMeta, type TaxCollectedEvent, type TaxCollectedEvent_Filter, type TaxCollectedEvent_OrderBy, type TaxUpdateProposedEvent, type TaxUpdateProposedEvent_Filter, type TaxUpdateProposedEvent_OrderBy, type WithdrawnEvent, type WithdrawnEvent_Filter, type WithdrawnEvent_OrderBy, type _Block_, type _Meta_, type _SubgraphErrorPolicy_, createSlotsClient, getSdk };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { gql as gql$1, GraphQLClient } from 'graphql-request';
2
2
  import gql from 'graphql-tag';
3
3
  import { encodeFunctionData, erc20Abi } from 'viem';
4
- import { getSlotsHubAddress, slotAbi, slotFactoryAbi } from '@0xslots/contracts';
4
+ import { getMetadataModuleAddress, metadataModuleAbi, getSlotsHubAddress, slotAbi, slotFactoryAbi } from '@0xslots/contracts';
5
5
 
6
6
  // src/client.ts
7
7
  var AccountFieldsFragmentDoc = gql`
@@ -26,6 +26,30 @@ var CurrencyFieldsFragmentDoc = gql`
26
26
  decimals
27
27
  }
28
28
  `;
29
+ var MetadataSlotFieldsFragmentDoc = gql`
30
+ fragment MetadataSlotFields on MetadataSlot {
31
+ id
32
+ uri
33
+ updatedBy
34
+ updateCount
35
+ createdAt
36
+ createdTx
37
+ updatedAt
38
+ updatedTx
39
+ slot {
40
+ id
41
+ recipient
42
+ occupant
43
+ price
44
+ deposit
45
+ currency {
46
+ id
47
+ symbol
48
+ decimals
49
+ }
50
+ }
51
+ }
52
+ `;
29
53
  var SlotFieldsFragmentDoc = gql`
30
54
  fragment SlotFields on Slot {
31
55
  id
@@ -694,6 +718,56 @@ var GetModulesDocument = gql`
694
718
  }
695
719
  }
696
720
  `;
721
+ var GetMetadataSlotsDocument = gql`
722
+ query GetMetadataSlots($first: Int = 100, $skip: Int = 0, $orderBy: MetadataSlot_orderBy = updatedAt, $orderDirection: OrderDirection = desc) {
723
+ metadataSlots(
724
+ first: $first
725
+ skip: $skip
726
+ orderBy: $orderBy
727
+ orderDirection: $orderDirection
728
+ ) {
729
+ ...MetadataSlotFields
730
+ }
731
+ }
732
+ ${MetadataSlotFieldsFragmentDoc}`;
733
+ var GetMetadataSlotDocument = gql`
734
+ query GetMetadataSlot($id: ID!) {
735
+ metadataSlot(id: $id) {
736
+ ...MetadataSlotFields
737
+ }
738
+ }
739
+ ${MetadataSlotFieldsFragmentDoc}`;
740
+ var GetMetadataSlotsByRecipientDocument = gql`
741
+ query GetMetadataSlotsByRecipient($recipient: Bytes!, $first: Int = 100) {
742
+ metadataSlots(
743
+ first: $first
744
+ where: {slot_: {recipient: $recipient}}
745
+ orderBy: updatedAt
746
+ orderDirection: desc
747
+ ) {
748
+ ...MetadataSlotFields
749
+ }
750
+ }
751
+ ${MetadataSlotFieldsFragmentDoc}`;
752
+ var GetMetadataUpdatedEventsDocument = gql`
753
+ query GetMetadataUpdatedEvents($slot: String, $first: Int = 50, $orderBy: MetadataUpdatedEvent_orderBy = timestamp, $orderDirection: OrderDirection = desc) {
754
+ metadataUpdatedEvents(
755
+ first: $first
756
+ where: {slot: $slot}
757
+ orderBy: $orderBy
758
+ orderDirection: $orderDirection
759
+ ) {
760
+ id
761
+ slot {
762
+ id
763
+ }
764
+ uri
765
+ timestamp
766
+ blockNumber
767
+ tx
768
+ }
769
+ }
770
+ `;
697
771
  var GetSlotsDocument = gql`
698
772
  query GetSlots($first: Int!, $skip: Int, $orderBy: Slot_orderBy, $orderDirection: OrderDirection, $where: Slot_filter, $block: Block_height) {
699
773
  slots(
@@ -791,6 +865,18 @@ function getSdk(client, withWrapper = defaultWrapper) {
791
865
  GetModules(variables, requestHeaders, signal) {
792
866
  return withWrapper((wrappedRequestHeaders) => client.request({ document: GetModulesDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetModules", "query", variables);
793
867
  },
868
+ GetMetadataSlots(variables, requestHeaders, signal) {
869
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetMetadataSlotsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetMetadataSlots", "query", variables);
870
+ },
871
+ GetMetadataSlot(variables, requestHeaders, signal) {
872
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetMetadataSlotDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetMetadataSlot", "query", variables);
873
+ },
874
+ GetMetadataSlotsByRecipient(variables, requestHeaders, signal) {
875
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetMetadataSlotsByRecipientDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetMetadataSlotsByRecipient", "query", variables);
876
+ },
877
+ GetMetadataUpdatedEvents(variables, requestHeaders, signal) {
878
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetMetadataUpdatedEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetMetadataUpdatedEvents", "query", variables);
879
+ },
794
880
  GetSlots(variables, requestHeaders, signal) {
795
881
  return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlots", "query", variables);
796
882
  },
@@ -816,6 +902,101 @@ var SlotsError = class extends Error {
816
902
  this.cause = cause;
817
903
  }
818
904
  };
905
+ var MetadataModuleClient = class {
906
+ constructor(opts) {
907
+ this.sdk = opts.sdk;
908
+ this.chainId = opts.chainId;
909
+ this._publicClient = opts.publicClient;
910
+ this._walletClient = opts.walletClient;
911
+ this._moduleAddress = opts.moduleAddress ?? getMetadataModuleAddress(opts.chainId);
912
+ }
913
+ get moduleAddress() {
914
+ if (!this._moduleAddress) throw new SlotsError("metadata", `No MetadataModule deployed on chain ${this.chainId}`);
915
+ return this._moduleAddress;
916
+ }
917
+ get wallet() {
918
+ if (!this._walletClient) throw new SlotsError("metadata", "No walletClient provided");
919
+ return this._walletClient;
920
+ }
921
+ get account() {
922
+ const account = this.wallet.account;
923
+ if (!account) throw new SlotsError("metadata", "WalletClient must have an account");
924
+ return account.address;
925
+ }
926
+ get chain() {
927
+ const chain = this.wallet.chain;
928
+ if (!chain) throw new SlotsError("metadata", "WalletClient must have a chain");
929
+ return chain;
930
+ }
931
+ get publicClient() {
932
+ if (!this._publicClient) throw new SlotsError("metadata", "No publicClient provided");
933
+ return this._publicClient;
934
+ }
935
+ async query(operation, fn) {
936
+ try {
937
+ return await fn();
938
+ } catch (error) {
939
+ throw new SlotsError(operation, error);
940
+ }
941
+ }
942
+ // ═══════════════════════════════════════════════════════════════════════════
943
+ // READ — Subgraph
944
+ // ═══════════════════════════════════════════════════════════════════════════
945
+ /** Get all slots with metadata, ordered by most recently updated. */
946
+ getSlots(...args) {
947
+ return this.query("metadata.getSlots", () => this.sdk.GetMetadataSlots(...args));
948
+ }
949
+ /** Get a single metadata slot by slot address. */
950
+ getSlot(...args) {
951
+ return this.query("metadata.getSlot", () => this.sdk.GetMetadataSlot(...args));
952
+ }
953
+ /** Get all metadata slots for a given recipient. */
954
+ getSlotsByRecipient(...args) {
955
+ return this.query("metadata.getSlotsByRecipient", () => this.sdk.GetMetadataSlotsByRecipient(...args));
956
+ }
957
+ /** Get metadata update history for a slot. */
958
+ getUpdateHistory(...args) {
959
+ return this.query("metadata.getUpdateHistory", () => this.sdk.GetMetadataUpdatedEvents(...args));
960
+ }
961
+ // ═══════════════════════════════════════════════════════════════════════════
962
+ // READ — RPC
963
+ // ═══════════════════════════════════════════════════════════════════════════
964
+ /** Read the current URI for a slot directly from chain (bypasses subgraph). */
965
+ async getURI(slot) {
966
+ return this.query(
967
+ "metadata.getURI",
968
+ () => this.publicClient.readContract({
969
+ address: this.moduleAddress,
970
+ abi: metadataModuleAbi,
971
+ functionName: "tokenURI",
972
+ args: [slot]
973
+ })
974
+ );
975
+ }
976
+ // ═══════════════════════════════════════════════════════════════════════════
977
+ // WRITE
978
+ // ═══════════════════════════════════════════════════════════════════════════
979
+ /**
980
+ * Update the metadata URI for a slot. Only callable by the current occupant.
981
+ * @param slot - The slot contract address
982
+ * @param uri - The new URI (e.g. ipfs://..., https://...)
983
+ * @returns Transaction hash
984
+ */
985
+ async updateMetadata(slot, uri) {
986
+ return this.wallet.writeContract({
987
+ address: this.moduleAddress,
988
+ abi: metadataModuleAbi,
989
+ functionName: "updateMetadata",
990
+ args: [slot, uri],
991
+ account: this.account,
992
+ chain: this.chain
993
+ });
994
+ }
995
+ /** Returns the MetadataModule contract address for the configured chain. */
996
+ getAddress() {
997
+ return this.moduleAddress;
998
+ }
999
+ };
819
1000
 
820
1001
  // src/client.ts
821
1002
  var META_QUERY = gql$1`
@@ -836,7 +1017,7 @@ var SlotsChain = /* @__PURE__ */ ((SlotsChain2) => {
836
1017
  return SlotsChain2;
837
1018
  })(SlotsChain || {});
838
1019
  var SUBGRAPH_URLS = {
839
- [84532 /* BASE_SEPOLIA */]: "https://api.studio.thegraph.com/query/958/0-x-slots-base-sepolia/version/latest",
1020
+ [84532 /* BASE_SEPOLIA */]: "https://gateway.thegraph.com/api/subgraphs/id/Z361DLoMdPh9WAopH7shJP8WoXYAB9XeKrLUCTYjdZR",
840
1021
  [42161 /* ARBITRUM */]: "https://api.studio.thegraph.com/query/958/0-x-slots-arb/version/latest"
841
1022
  };
842
1023
  var SlotsClient = class {
@@ -847,8 +1028,20 @@ var SlotsClient = class {
847
1028
  this._factory = config.factoryAddress ?? getSlotsHubAddress(config.chainId);
848
1029
  const url = config.subgraphUrl || SUBGRAPH_URLS[config.chainId];
849
1030
  if (!url) throw new Error(`No subgraph URL for chain ${config.chainId}`);
850
- this.gqlClient = new GraphQLClient(url, { headers: config.headers });
1031
+ const headers = { ...config.headers };
1032
+ if (config.subgraphApiKey) {
1033
+ headers["Authorization"] = `Bearer ${config.subgraphApiKey}`;
1034
+ }
1035
+ this.gqlClient = new GraphQLClient(url, { headers });
851
1036
  this.sdk = getSdk(this.gqlClient);
1037
+ this.modules = {
1038
+ metadata: new MetadataModuleClient({
1039
+ sdk: this.sdk,
1040
+ chainId: config.chainId,
1041
+ publicClient: config.publicClient,
1042
+ walletClient: config.walletClient
1043
+ })
1044
+ };
852
1045
  }
853
1046
  // ─── Accessors ──────────────────────────────────────────────────────────────
854
1047
  /** Returns the chain ID this client was configured for. */
@@ -1345,6 +1538,6 @@ function createSlotsClient(config) {
1345
1538
  return new SlotsClient(config);
1346
1539
  }
1347
1540
 
1348
- export { AccountFieldsFragmentDoc, CurrencyFieldsFragmentDoc, GetAccountDocument, GetAccountsDocument, GetBoughtEventsDocument, GetDepositedEventsDocument, GetFactoryDocument, GetLiquidatedEventsDocument, GetModulesDocument, GetPriceUpdatedEventsDocument, GetRecentEventsDocument, GetReleasedEventsDocument, GetSettledEventsDocument, GetSlotActivityDocument, GetSlotDeployedEventsDocument, GetSlotDocument, GetSlotsByOccupantDocument, GetSlotsByRecipientDocument, GetSlotsDocument, GetTaxCollectedEventsDocument, GetWithdrawnEventsDocument, SUBGRAPH_URLS, SlotFieldsFragmentDoc, SlotsChain, SlotsClient, SlotsError, createSlotsClient, getSdk };
1541
+ export { AccountFieldsFragmentDoc, CurrencyFieldsFragmentDoc, GetAccountDocument, GetAccountsDocument, GetBoughtEventsDocument, GetDepositedEventsDocument, GetFactoryDocument, GetLiquidatedEventsDocument, GetMetadataSlotDocument, GetMetadataSlotsByRecipientDocument, GetMetadataSlotsDocument, GetMetadataUpdatedEventsDocument, GetModulesDocument, GetPriceUpdatedEventsDocument, GetRecentEventsDocument, GetReleasedEventsDocument, GetSettledEventsDocument, GetSlotActivityDocument, GetSlotDeployedEventsDocument, GetSlotDocument, GetSlotsByOccupantDocument, GetSlotsByRecipientDocument, GetSlotsDocument, GetTaxCollectedEventsDocument, GetWithdrawnEventsDocument, MetadataModuleClient, MetadataSlotFieldsFragmentDoc, SUBGRAPH_URLS, SlotFieldsFragmentDoc, SlotsChain, SlotsClient, SlotsError, createSlotsClient, getSdk };
1349
1542
  //# sourceMappingURL=index.js.map
1350
1543
  //# sourceMappingURL=index.js.map