@0xslots/sdk 0.8.1 → 0.9.0

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;
@@ -750,6 +750,7 @@ type MetadataSlot_Filter = {
750
750
  type MetadataSlot_OrderBy = 'createdAt' | 'createdTx' | 'id' | 'slot' | 'slot__collectedTax' | 'slot__createdAt' | 'slot__createdTx' | 'slot__deposit' | 'slot__id' | 'slot__liquidationBountyBps' | 'slot__manager' | 'slot__minDepositSeconds' | 'slot__mutableModule' | 'slot__mutableTax' | 'slot__occupant' | 'slot__price' | 'slot__recipient' | 'slot__taxPercentage' | 'slot__totalCollected' | 'slot__updatedAt' | 'updateCount' | 'updatedAt' | 'updatedBy' | 'updatedTx' | 'uri';
751
751
  type MetadataUpdatedEvent = {
752
752
  __typename?: 'MetadataUpdatedEvent';
753
+ author: Account;
753
754
  blockNumber: Scalars['BigInt']['output'];
754
755
  id: Scalars['ID']['output'];
755
756
  slot: Slot;
@@ -761,6 +762,27 @@ type MetadataUpdatedEvent_Filter = {
761
762
  /** Filter for the block changed event. */
762
763
  _change_block?: InputMaybe<BlockChangedFilter>;
763
764
  and?: InputMaybe<Array<InputMaybe<MetadataUpdatedEvent_Filter>>>;
765
+ author?: InputMaybe<Scalars['String']['input']>;
766
+ author_?: InputMaybe<Account_Filter>;
767
+ author_contains?: InputMaybe<Scalars['String']['input']>;
768
+ author_contains_nocase?: InputMaybe<Scalars['String']['input']>;
769
+ author_ends_with?: InputMaybe<Scalars['String']['input']>;
770
+ author_ends_with_nocase?: InputMaybe<Scalars['String']['input']>;
771
+ author_gt?: InputMaybe<Scalars['String']['input']>;
772
+ author_gte?: InputMaybe<Scalars['String']['input']>;
773
+ author_in?: InputMaybe<Array<Scalars['String']['input']>>;
774
+ author_lt?: InputMaybe<Scalars['String']['input']>;
775
+ author_lte?: InputMaybe<Scalars['String']['input']>;
776
+ author_not?: InputMaybe<Scalars['String']['input']>;
777
+ author_not_contains?: InputMaybe<Scalars['String']['input']>;
778
+ author_not_contains_nocase?: InputMaybe<Scalars['String']['input']>;
779
+ author_not_ends_with?: InputMaybe<Scalars['String']['input']>;
780
+ author_not_ends_with_nocase?: InputMaybe<Scalars['String']['input']>;
781
+ author_not_in?: InputMaybe<Array<Scalars['String']['input']>>;
782
+ author_not_starts_with?: InputMaybe<Scalars['String']['input']>;
783
+ author_not_starts_with_nocase?: InputMaybe<Scalars['String']['input']>;
784
+ author_starts_with?: InputMaybe<Scalars['String']['input']>;
785
+ author_starts_with_nocase?: InputMaybe<Scalars['String']['input']>;
764
786
  blockNumber?: InputMaybe<Scalars['BigInt']['input']>;
765
787
  blockNumber_gt?: InputMaybe<Scalars['BigInt']['input']>;
766
788
  blockNumber_gte?: InputMaybe<Scalars['BigInt']['input']>;
@@ -838,7 +860,7 @@ type MetadataUpdatedEvent_Filter = {
838
860
  uri_starts_with?: InputMaybe<Scalars['String']['input']>;
839
861
  uri_starts_with_nocase?: InputMaybe<Scalars['String']['input']>;
840
862
  };
841
- type MetadataUpdatedEvent_OrderBy = 'blockNumber' | 'id' | 'slot' | 'slot__collectedTax' | 'slot__createdAt' | 'slot__createdTx' | 'slot__deposit' | 'slot__id' | 'slot__liquidationBountyBps' | 'slot__manager' | 'slot__minDepositSeconds' | 'slot__mutableModule' | 'slot__mutableTax' | 'slot__occupant' | 'slot__price' | 'slot__recipient' | 'slot__taxPercentage' | 'slot__totalCollected' | 'slot__updatedAt' | 'timestamp' | 'tx' | 'uri';
863
+ type MetadataUpdatedEvent_OrderBy = 'author' | 'author__id' | 'author__occupiedCount' | 'author__slotCount' | 'author__type' | 'blockNumber' | 'id' | 'slot' | 'slot__collectedTax' | 'slot__createdAt' | 'slot__createdTx' | 'slot__deposit' | 'slot__id' | 'slot__liquidationBountyBps' | 'slot__manager' | 'slot__minDepositSeconds' | 'slot__mutableModule' | 'slot__mutableTax' | 'slot__occupant' | 'slot__price' | 'slot__recipient' | 'slot__taxPercentage' | 'slot__totalCollected' | 'slot__updatedAt' | 'timestamp' | 'tx' | 'uri';
842
864
  type Module = {
843
865
  __typename?: 'Module';
844
866
  factory: Factory;
@@ -3311,6 +3333,154 @@ type GetModulesQuery = {
3311
3333
  version: string;
3312
3334
  }>;
3313
3335
  };
3336
+ type MetadataSlotFieldsFragment = {
3337
+ __typename?: 'MetadataSlot';
3338
+ id: string;
3339
+ uri: string;
3340
+ updatedBy: string;
3341
+ updateCount: string;
3342
+ createdAt: string;
3343
+ createdTx: string;
3344
+ updatedAt: string;
3345
+ updatedTx: string;
3346
+ slot: {
3347
+ __typename?: 'Slot';
3348
+ id: string;
3349
+ recipient: string;
3350
+ occupant?: string | null;
3351
+ price: string;
3352
+ deposit: string;
3353
+ currency: {
3354
+ __typename?: 'Currency';
3355
+ id: string;
3356
+ symbol?: string | null;
3357
+ decimals: number;
3358
+ };
3359
+ };
3360
+ };
3361
+ type GetMetadataSlotsQueryVariables = Exact<{
3362
+ first?: InputMaybe<Scalars['Int']['input']>;
3363
+ skip?: InputMaybe<Scalars['Int']['input']>;
3364
+ orderBy?: InputMaybe<MetadataSlot_OrderBy>;
3365
+ orderDirection?: InputMaybe<OrderDirection>;
3366
+ }>;
3367
+ type GetMetadataSlotsQuery = {
3368
+ __typename?: 'Query';
3369
+ metadataSlots: Array<{
3370
+ __typename?: 'MetadataSlot';
3371
+ id: string;
3372
+ uri: string;
3373
+ updatedBy: string;
3374
+ updateCount: string;
3375
+ createdAt: string;
3376
+ createdTx: string;
3377
+ updatedAt: string;
3378
+ updatedTx: string;
3379
+ slot: {
3380
+ __typename?: 'Slot';
3381
+ id: string;
3382
+ recipient: string;
3383
+ occupant?: string | null;
3384
+ price: string;
3385
+ deposit: string;
3386
+ currency: {
3387
+ __typename?: 'Currency';
3388
+ id: string;
3389
+ symbol?: string | null;
3390
+ decimals: number;
3391
+ };
3392
+ };
3393
+ }>;
3394
+ };
3395
+ type GetMetadataSlotQueryVariables = Exact<{
3396
+ id: Scalars['ID']['input'];
3397
+ }>;
3398
+ type GetMetadataSlotQuery = {
3399
+ __typename?: 'Query';
3400
+ metadataSlot?: {
3401
+ __typename?: 'MetadataSlot';
3402
+ id: string;
3403
+ uri: string;
3404
+ updatedBy: string;
3405
+ updateCount: string;
3406
+ createdAt: string;
3407
+ createdTx: string;
3408
+ updatedAt: string;
3409
+ updatedTx: string;
3410
+ slot: {
3411
+ __typename?: 'Slot';
3412
+ id: string;
3413
+ recipient: string;
3414
+ occupant?: string | null;
3415
+ price: string;
3416
+ deposit: string;
3417
+ currency: {
3418
+ __typename?: 'Currency';
3419
+ id: string;
3420
+ symbol?: string | null;
3421
+ decimals: number;
3422
+ };
3423
+ };
3424
+ } | null;
3425
+ };
3426
+ type GetMetadataSlotsByRecipientQueryVariables = Exact<{
3427
+ recipient: Scalars['Bytes']['input'];
3428
+ first?: InputMaybe<Scalars['Int']['input']>;
3429
+ }>;
3430
+ type GetMetadataSlotsByRecipientQuery = {
3431
+ __typename?: 'Query';
3432
+ metadataSlots: Array<{
3433
+ __typename?: 'MetadataSlot';
3434
+ id: string;
3435
+ uri: string;
3436
+ updatedBy: string;
3437
+ updateCount: string;
3438
+ createdAt: string;
3439
+ createdTx: string;
3440
+ updatedAt: string;
3441
+ updatedTx: string;
3442
+ slot: {
3443
+ __typename?: 'Slot';
3444
+ id: string;
3445
+ recipient: string;
3446
+ occupant?: string | null;
3447
+ price: string;
3448
+ deposit: string;
3449
+ currency: {
3450
+ __typename?: 'Currency';
3451
+ id: string;
3452
+ symbol?: string | null;
3453
+ decimals: number;
3454
+ };
3455
+ };
3456
+ }>;
3457
+ };
3458
+ type GetMetadataUpdatedEventsQueryVariables = Exact<{
3459
+ slot?: InputMaybe<Scalars['String']['input']>;
3460
+ first?: InputMaybe<Scalars['Int']['input']>;
3461
+ orderBy?: InputMaybe<MetadataUpdatedEvent_OrderBy>;
3462
+ orderDirection?: InputMaybe<OrderDirection>;
3463
+ }>;
3464
+ type GetMetadataUpdatedEventsQuery = {
3465
+ __typename?: 'Query';
3466
+ metadataUpdatedEvents: Array<{
3467
+ __typename?: 'MetadataUpdatedEvent';
3468
+ id: string;
3469
+ uri: string;
3470
+ timestamp: string;
3471
+ blockNumber: string;
3472
+ tx: string;
3473
+ slot: {
3474
+ __typename?: 'Slot';
3475
+ id: string;
3476
+ };
3477
+ author: {
3478
+ __typename?: 'Account';
3479
+ id: string;
3480
+ type: AccountType;
3481
+ };
3482
+ }>;
3483
+ };
3314
3484
  type SlotFieldsFragment = {
3315
3485
  __typename?: 'Slot';
3316
3486
  id: string;
@@ -3588,6 +3758,7 @@ type GetSlotsByOccupantQuery = {
3588
3758
  };
3589
3759
  declare const AccountFieldsFragmentDoc: graphql.DocumentNode;
3590
3760
  declare const CurrencyFieldsFragmentDoc: graphql.DocumentNode;
3761
+ declare const MetadataSlotFieldsFragmentDoc: graphql.DocumentNode;
3591
3762
  declare const SlotFieldsFragmentDoc: graphql.DocumentNode;
3592
3763
  declare const GetAccountDocument: graphql.DocumentNode;
3593
3764
  declare const GetAccountsDocument: graphql.DocumentNode;
@@ -3604,6 +3775,10 @@ declare const GetPriceUpdatedEventsDocument: graphql.DocumentNode;
3604
3775
  declare const GetSlotActivityDocument: graphql.DocumentNode;
3605
3776
  declare const GetFactoryDocument: graphql.DocumentNode;
3606
3777
  declare const GetModulesDocument: graphql.DocumentNode;
3778
+ declare const GetMetadataSlotsDocument: graphql.DocumentNode;
3779
+ declare const GetMetadataSlotDocument: graphql.DocumentNode;
3780
+ declare const GetMetadataSlotsByRecipientDocument: graphql.DocumentNode;
3781
+ declare const GetMetadataUpdatedEventsDocument: graphql.DocumentNode;
3607
3782
  declare const GetSlotsDocument: graphql.DocumentNode;
3608
3783
  declare const GetSlotDocument: graphql.DocumentNode;
3609
3784
  declare const GetSlotsByRecipientDocument: graphql.DocumentNode;
@@ -3625,6 +3800,10 @@ declare function getSdk(client: GraphQLClient, withWrapper?: SdkFunctionWrapper)
3625
3800
  GetSlotActivity(variables: GetSlotActivityQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetSlotActivityQuery>;
3626
3801
  GetFactory(variables?: GetFactoryQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetFactoryQuery>;
3627
3802
  GetModules(variables: GetModulesQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetModulesQuery>;
3803
+ GetMetadataSlots(variables?: GetMetadataSlotsQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetMetadataSlotsQuery>;
3804
+ GetMetadataSlot(variables: GetMetadataSlotQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetMetadataSlotQuery>;
3805
+ GetMetadataSlotsByRecipient(variables: GetMetadataSlotsByRecipientQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetMetadataSlotsByRecipientQuery>;
3806
+ GetMetadataUpdatedEvents(variables?: GetMetadataUpdatedEventsQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetMetadataUpdatedEventsQuery>;
3628
3807
  GetSlots(variables: GetSlotsQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetSlotsQuery>;
3629
3808
  GetSlot(variables: GetSlotQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetSlotQuery>;
3630
3809
  GetSlotsByRecipient(variables: GetSlotsByRecipientQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, signal?: RequestInit["signal"]): Promise<GetSlotsByRecipientQuery>;
@@ -3632,6 +3811,54 @@ declare function getSdk(client: GraphQLClient, withWrapper?: SdkFunctionWrapper)
3632
3811
  };
3633
3812
  type Sdk = ReturnType<typeof getSdk>;
3634
3813
 
3814
+ /**
3815
+ * Module namespace for MetadataModule operations.
3816
+ * Accessible via `client.modules.metadata`.
3817
+ *
3818
+ * Read: subgraph queries for MetadataSlot entities
3819
+ * Write: `updateMetadata(slot, uri)` on the MetadataModule contract
3820
+ * RPC read: `tokenURI(slot)` on the MetadataModule contract
3821
+ */
3822
+ declare class MetadataModuleClient {
3823
+ private readonly sdk;
3824
+ private readonly chainId;
3825
+ private readonly _publicClient?;
3826
+ private readonly _walletClient?;
3827
+ private readonly _moduleAddress?;
3828
+ constructor(opts: {
3829
+ sdk: ReturnType<typeof getSdk>;
3830
+ chainId: number;
3831
+ publicClient?: PublicClient;
3832
+ walletClient?: WalletClient;
3833
+ moduleAddress?: Address;
3834
+ });
3835
+ private get moduleAddress();
3836
+ private get wallet();
3837
+ private get account();
3838
+ private get chain();
3839
+ private get publicClient();
3840
+ private query;
3841
+ /** Get all slots with metadata, ordered by most recently updated. */
3842
+ getSlots(...args: Parameters<ReturnType<typeof getSdk>["GetMetadataSlots"]>): Promise<GetMetadataSlotsQuery>;
3843
+ /** Get a single metadata slot by slot address. */
3844
+ getSlot(...args: Parameters<ReturnType<typeof getSdk>["GetMetadataSlot"]>): Promise<GetMetadataSlotQuery>;
3845
+ /** Get all metadata slots for a given recipient. */
3846
+ getSlotsByRecipient(...args: Parameters<ReturnType<typeof getSdk>["GetMetadataSlotsByRecipient"]>): Promise<GetMetadataSlotsByRecipientQuery>;
3847
+ /** Get metadata update history for a slot. */
3848
+ getUpdateHistory(...args: Parameters<ReturnType<typeof getSdk>["GetMetadataUpdatedEvents"]>): Promise<GetMetadataUpdatedEventsQuery>;
3849
+ /** Read the current URI for a slot directly from chain (bypasses subgraph). */
3850
+ getURI(slot: Address): Promise<string>;
3851
+ /**
3852
+ * Update the metadata URI for a slot. Only callable by the current occupant.
3853
+ * @param slot - The slot contract address
3854
+ * @param uri - The new URI (e.g. ipfs://..., https://...)
3855
+ * @returns Transaction hash
3856
+ */
3857
+ updateMetadata(slot: Address, uri: string): Promise<Hash>;
3858
+ /** Returns the MetadataModule contract address for the configured chain. */
3859
+ getAddress(): Address;
3860
+ }
3861
+
3635
3862
  interface SubgraphMeta {
3636
3863
  _meta: {
3637
3864
  block: {
@@ -3678,6 +3905,7 @@ interface SlotsClientConfig {
3678
3905
  publicClient?: PublicClient;
3679
3906
  walletClient?: WalletClient;
3680
3907
  subgraphUrl?: string;
3908
+ subgraphApiKey?: string;
3681
3909
  headers?: Record<string, string>;
3682
3910
  }
3683
3911
  /**
@@ -3704,6 +3932,10 @@ declare class SlotsClient {
3704
3932
  private readonly walletClient?;
3705
3933
  private readonly _factory?;
3706
3934
  private _atomicSupport;
3935
+ /** Module namespaces for protocol extensions. */
3936
+ readonly modules: {
3937
+ metadata: MetadataModuleClient;
3938
+ };
3707
3939
  constructor(config: SlotsClientConfig);
3708
3940
  /** Returns the chain ID this client was configured for. */
3709
3941
  getChainId(): SlotsChain;
@@ -3726,6 +3958,10 @@ declare class SlotsClient {
3726
3958
  GetSlotActivity(variables: GetSlotActivityQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetSlotActivityQuery>;
3727
3959
  GetFactory(variables?: GetFactoryQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetFactoryQuery>;
3728
3960
  GetModules(variables: GetModulesQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetModulesQuery>;
3961
+ GetMetadataSlots(variables?: GetMetadataSlotsQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetMetadataSlotsQuery>;
3962
+ GetMetadataSlot(variables: GetMetadataSlotQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetMetadataSlotQuery>;
3963
+ GetMetadataSlotsByRecipient(variables: GetMetadataSlotsByRecipientQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetMetadataSlotsByRecipientQuery>;
3964
+ GetMetadataUpdatedEvents(variables?: GetMetadataUpdatedEventsQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetMetadataUpdatedEventsQuery>;
3729
3965
  GetSlots(variables: GetSlotsQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetSlotsQuery>;
3730
3966
  GetSlot(variables: GetSlotQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetSlotQuery>;
3731
3967
  GetSlotsByRecipient(variables: GetSlotsByRecipientQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetSlotsByRecipientQuery>;
@@ -3925,4 +4161,4 @@ declare class SlotsError extends Error {
3925
4161
  constructor(operation: string, cause: unknown);
3926
4162
  }
3927
4163
 
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 };
4164
+ 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,60 @@ 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
+ author {
765
+ id
766
+ type
767
+ }
768
+ uri
769
+ timestamp
770
+ blockNumber
771
+ tx
772
+ }
773
+ }
774
+ `;
697
775
  var GetSlotsDocument = gql`
698
776
  query GetSlots($first: Int!, $skip: Int, $orderBy: Slot_orderBy, $orderDirection: OrderDirection, $where: Slot_filter, $block: Block_height) {
699
777
  slots(
@@ -791,6 +869,18 @@ function getSdk(client, withWrapper = defaultWrapper) {
791
869
  GetModules(variables, requestHeaders, signal) {
792
870
  return withWrapper((wrappedRequestHeaders) => client.request({ document: GetModulesDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetModules", "query", variables);
793
871
  },
872
+ GetMetadataSlots(variables, requestHeaders, signal) {
873
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetMetadataSlotsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetMetadataSlots", "query", variables);
874
+ },
875
+ GetMetadataSlot(variables, requestHeaders, signal) {
876
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetMetadataSlotDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetMetadataSlot", "query", variables);
877
+ },
878
+ GetMetadataSlotsByRecipient(variables, requestHeaders, signal) {
879
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetMetadataSlotsByRecipientDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetMetadataSlotsByRecipient", "query", variables);
880
+ },
881
+ GetMetadataUpdatedEvents(variables, requestHeaders, signal) {
882
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetMetadataUpdatedEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetMetadataUpdatedEvents", "query", variables);
883
+ },
794
884
  GetSlots(variables, requestHeaders, signal) {
795
885
  return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlots", "query", variables);
796
886
  },
@@ -816,6 +906,101 @@ var SlotsError = class extends Error {
816
906
  this.cause = cause;
817
907
  }
818
908
  };
909
+ var MetadataModuleClient = class {
910
+ constructor(opts) {
911
+ this.sdk = opts.sdk;
912
+ this.chainId = opts.chainId;
913
+ this._publicClient = opts.publicClient;
914
+ this._walletClient = opts.walletClient;
915
+ this._moduleAddress = opts.moduleAddress ?? getMetadataModuleAddress(opts.chainId);
916
+ }
917
+ get moduleAddress() {
918
+ if (!this._moduleAddress) throw new SlotsError("metadata", `No MetadataModule deployed on chain ${this.chainId}`);
919
+ return this._moduleAddress;
920
+ }
921
+ get wallet() {
922
+ if (!this._walletClient) throw new SlotsError("metadata", "No walletClient provided");
923
+ return this._walletClient;
924
+ }
925
+ get account() {
926
+ const account = this.wallet.account;
927
+ if (!account) throw new SlotsError("metadata", "WalletClient must have an account");
928
+ return account.address;
929
+ }
930
+ get chain() {
931
+ const chain = this.wallet.chain;
932
+ if (!chain) throw new SlotsError("metadata", "WalletClient must have a chain");
933
+ return chain;
934
+ }
935
+ get publicClient() {
936
+ if (!this._publicClient) throw new SlotsError("metadata", "No publicClient provided");
937
+ return this._publicClient;
938
+ }
939
+ async query(operation, fn) {
940
+ try {
941
+ return await fn();
942
+ } catch (error) {
943
+ throw new SlotsError(operation, error);
944
+ }
945
+ }
946
+ // ═══════════════════════════════════════════════════════════════════════════
947
+ // READ — Subgraph
948
+ // ═══════════════════════════════════════════════════════════════════════════
949
+ /** Get all slots with metadata, ordered by most recently updated. */
950
+ getSlots(...args) {
951
+ return this.query("metadata.getSlots", () => this.sdk.GetMetadataSlots(...args));
952
+ }
953
+ /** Get a single metadata slot by slot address. */
954
+ getSlot(...args) {
955
+ return this.query("metadata.getSlot", () => this.sdk.GetMetadataSlot(...args));
956
+ }
957
+ /** Get all metadata slots for a given recipient. */
958
+ getSlotsByRecipient(...args) {
959
+ return this.query("metadata.getSlotsByRecipient", () => this.sdk.GetMetadataSlotsByRecipient(...args));
960
+ }
961
+ /** Get metadata update history for a slot. */
962
+ getUpdateHistory(...args) {
963
+ return this.query("metadata.getUpdateHistory", () => this.sdk.GetMetadataUpdatedEvents(...args));
964
+ }
965
+ // ═══════════════════════════════════════════════════════════════════════════
966
+ // READ — RPC
967
+ // ═══════════════════════════════════════════════════════════════════════════
968
+ /** Read the current URI for a slot directly from chain (bypasses subgraph). */
969
+ async getURI(slot) {
970
+ return this.query(
971
+ "metadata.getURI",
972
+ () => this.publicClient.readContract({
973
+ address: this.moduleAddress,
974
+ abi: metadataModuleAbi,
975
+ functionName: "tokenURI",
976
+ args: [slot]
977
+ })
978
+ );
979
+ }
980
+ // ═══════════════════════════════════════════════════════════════════════════
981
+ // WRITE
982
+ // ═══════════════════════════════════════════════════════════════════════════
983
+ /**
984
+ * Update the metadata URI for a slot. Only callable by the current occupant.
985
+ * @param slot - The slot contract address
986
+ * @param uri - The new URI (e.g. ipfs://..., https://...)
987
+ * @returns Transaction hash
988
+ */
989
+ async updateMetadata(slot, uri) {
990
+ return this.wallet.writeContract({
991
+ address: this.moduleAddress,
992
+ abi: metadataModuleAbi,
993
+ functionName: "updateMetadata",
994
+ args: [slot, uri],
995
+ account: this.account,
996
+ chain: this.chain
997
+ });
998
+ }
999
+ /** Returns the MetadataModule contract address for the configured chain. */
1000
+ getAddress() {
1001
+ return this.moduleAddress;
1002
+ }
1003
+ };
819
1004
 
820
1005
  // src/client.ts
821
1006
  var META_QUERY = gql$1`
@@ -836,7 +1021,7 @@ var SlotsChain = /* @__PURE__ */ ((SlotsChain2) => {
836
1021
  return SlotsChain2;
837
1022
  })(SlotsChain || {});
838
1023
  var SUBGRAPH_URLS = {
839
- [84532 /* BASE_SEPOLIA */]: "https://api.studio.thegraph.com/query/958/0-x-slots-base-sepolia/version/latest",
1024
+ [84532 /* BASE_SEPOLIA */]: "https://gateway.thegraph.com/api/subgraphs/id/Z361DLoMdPh9WAopH7shJP8WoXYAB9XeKrLUCTYjdZR",
840
1025
  [42161 /* ARBITRUM */]: "https://api.studio.thegraph.com/query/958/0-x-slots-arb/version/latest"
841
1026
  };
842
1027
  var SlotsClient = class {
@@ -847,8 +1032,20 @@ var SlotsClient = class {
847
1032
  this._factory = config.factoryAddress ?? getSlotsHubAddress(config.chainId);
848
1033
  const url = config.subgraphUrl || SUBGRAPH_URLS[config.chainId];
849
1034
  if (!url) throw new Error(`No subgraph URL for chain ${config.chainId}`);
850
- this.gqlClient = new GraphQLClient(url, { headers: config.headers });
1035
+ const headers = { ...config.headers };
1036
+ if (config.subgraphApiKey) {
1037
+ headers["Authorization"] = `Bearer ${config.subgraphApiKey}`;
1038
+ }
1039
+ this.gqlClient = new GraphQLClient(url, { headers });
851
1040
  this.sdk = getSdk(this.gqlClient);
1041
+ this.modules = {
1042
+ metadata: new MetadataModuleClient({
1043
+ sdk: this.sdk,
1044
+ chainId: config.chainId,
1045
+ publicClient: config.publicClient,
1046
+ walletClient: config.walletClient
1047
+ })
1048
+ };
852
1049
  }
853
1050
  // ─── Accessors ──────────────────────────────────────────────────────────────
854
1051
  /** Returns the chain ID this client was configured for. */
@@ -1345,6 +1542,6 @@ function createSlotsClient(config) {
1345
1542
  return new SlotsClient(config);
1346
1543
  }
1347
1544
 
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 };
1545
+ 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
1546
  //# sourceMappingURL=index.js.map
1350
1547
  //# sourceMappingURL=index.js.map