@joai/warps-adapter-solana 1.1.0 → 1.2.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.cts CHANGED
@@ -83,6 +83,7 @@ declare class WarpSolanaDataLoader implements AdapterWarpDataLoader {
83
83
  getAccountAssets(address: string): Promise<WarpChainAsset[]>;
84
84
  getAsset(identifier: string): Promise<WarpChainAsset | null>;
85
85
  getAction(identifier: string, awaitCompleted?: boolean): Promise<WarpChainAction | null>;
86
+ getAccountNfts(address: string, options?: WarpDataLoaderOptions): Promise<WarpChainAsset[]>;
86
87
  getAccountActions(address: string, options?: WarpDataLoaderOptions): Promise<WarpChainAction[]>;
87
88
  private getTokenBalances;
88
89
  private getTokenMetadata;
package/dist/index.d.ts CHANGED
@@ -83,6 +83,7 @@ declare class WarpSolanaDataLoader implements AdapterWarpDataLoader {
83
83
  getAccountAssets(address: string): Promise<WarpChainAsset[]>;
84
84
  getAsset(identifier: string): Promise<WarpChainAsset | null>;
85
85
  getAction(identifier: string, awaitCompleted?: boolean): Promise<WarpChainAction | null>;
86
+ getAccountNfts(address: string, options?: WarpDataLoaderOptions): Promise<WarpChainAsset[]>;
86
87
  getAccountActions(address: string, options?: WarpDataLoaderOptions): Promise<WarpChainAction[]>;
87
88
  private getTokenBalances;
88
89
  private getTokenMetadata;
package/dist/index.js CHANGED
@@ -472,6 +472,38 @@ var WarpSolanaDataLoader = class {
472
472
  return null;
473
473
  }
474
474
  }
475
+ async getAccountNfts(address, options) {
476
+ try {
477
+ const publicKey = new import_web32.PublicKey(address);
478
+ const tokenAccounts = await this.connection.getParsedTokenAccountsByOwner(publicKey, {
479
+ programId: new import_web32.PublicKey(WarpSolanaConstants.Programs.TokenProgram)
480
+ });
481
+ const size = options?.size || 25;
482
+ const page = options?.page || 0;
483
+ const from = page * size;
484
+ const nftAccounts = tokenAccounts.value.filter((tokenAccount) => {
485
+ const decimals = tokenAccount.account.data.parsed.info.tokenAmount.decimals;
486
+ const amount = tokenAccount.account.data.parsed.info.tokenAmount.amount;
487
+ return decimals === 0 && amount === "1";
488
+ });
489
+ const paged = nftAccounts.slice(from, from + size);
490
+ return paged.map((tokenAccount) => {
491
+ const mintAddress = tokenAccount.account.data.parsed.info.mint;
492
+ return {
493
+ chain: this.chain.name,
494
+ identifier: mintAddress,
495
+ name: mintAddress.slice(0, 8) + "...",
496
+ symbol: "",
497
+ amount: 1n,
498
+ decimals: 0,
499
+ type: "nft",
500
+ nft: {}
501
+ };
502
+ });
503
+ } catch {
504
+ return [];
505
+ }
506
+ }
475
507
  async getAccountActions(address, options) {
476
508
  return [];
477
509
  }