@joai/warps-adapter-solana 1.0.2 → 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 +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +48 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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;
|
|
@@ -204,6 +205,7 @@ declare class WarpSolanaWallet implements AdapterWarpWallet {
|
|
|
204
205
|
importFromPrivateKey(privateKey: string): Promise<WarpWalletDetails>;
|
|
205
206
|
export(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
|
|
206
207
|
generate(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
|
|
208
|
+
delete(provider: WarpWalletProvider, externalId: string): Promise<void>;
|
|
207
209
|
getAddress(): string | null;
|
|
208
210
|
getPublicKey(): string | null;
|
|
209
211
|
registerX402Handlers(client: unknown): Promise<Record<string, () => void>>;
|
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;
|
|
@@ -204,6 +205,7 @@ declare class WarpSolanaWallet implements AdapterWarpWallet {
|
|
|
204
205
|
importFromPrivateKey(privateKey: string): Promise<WarpWalletDetails>;
|
|
205
206
|
export(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
|
|
206
207
|
generate(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
|
|
208
|
+
delete(provider: WarpWalletProvider, externalId: string): Promise<void>;
|
|
207
209
|
getAddress(): string | null;
|
|
208
210
|
getPublicKey(): string | null;
|
|
209
211
|
registerX402Handlers(client: unknown): Promise<Record<string, () => void>>;
|
package/dist/index.js
CHANGED
|
@@ -419,7 +419,7 @@ var WarpSolanaDataLoader = class {
|
|
|
419
419
|
return this.chain.nativeToken;
|
|
420
420
|
}
|
|
421
421
|
const cacheKey = import_warps5.WarpCacheKey.Asset(this.config.env, this.chain.name, identifier);
|
|
422
|
-
const cachedAsset = this.cache.get(cacheKey);
|
|
422
|
+
const cachedAsset = await this.cache.get(cacheKey);
|
|
423
423
|
if (cachedAsset) {
|
|
424
424
|
return cachedAsset;
|
|
425
425
|
}
|
|
@@ -446,7 +446,7 @@ var WarpSolanaDataLoader = class {
|
|
|
446
446
|
decimals: metadata.decimals,
|
|
447
447
|
logoUrl: metadata.logoUrl
|
|
448
448
|
};
|
|
449
|
-
this.cache.set(cacheKey, asset, import_warps5.CacheTtl.OneHour);
|
|
449
|
+
await this.cache.set(cacheKey, asset, import_warps5.CacheTtl.OneHour);
|
|
450
450
|
return asset;
|
|
451
451
|
} catch (error) {
|
|
452
452
|
return null;
|
|
@@ -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
|
}
|
|
@@ -874,7 +906,7 @@ var WarpSolanaOutput = class {
|
|
|
874
906
|
this.cache = new import_warps7.WarpCache(config.env, config.cache);
|
|
875
907
|
}
|
|
876
908
|
async getActionExecution(warp, actionIndex, tx) {
|
|
877
|
-
const inputs = this.cache.get(import_warps7.WarpCacheKey.WarpExecutable(this.config.env, warp.meta?.hash || "", actionIndex)) ?? [];
|
|
909
|
+
const inputs = await this.cache.get(import_warps7.WarpCacheKey.WarpExecutable(this.config.env, warp.meta?.hash || "", actionIndex)) ?? [];
|
|
878
910
|
const resolvedInputs = (0, import_warps7.extractResolvedInputValues)(inputs);
|
|
879
911
|
if (!tx) {
|
|
880
912
|
return this.createFailedExecution(warp, actionIndex, resolvedInputs);
|
|
@@ -1840,6 +1872,9 @@ var _MnemonicWalletProvider = class _MnemonicWalletProvider {
|
|
|
1840
1872
|
mnemonic
|
|
1841
1873
|
};
|
|
1842
1874
|
}
|
|
1875
|
+
async delete(externalId) {
|
|
1876
|
+
(0, import_warps9.removeWarpWalletFromConfig)(this.config, this.chain.name);
|
|
1877
|
+
}
|
|
1843
1878
|
getKeypair() {
|
|
1844
1879
|
if (this.keypair) return this.keypair;
|
|
1845
1880
|
const mnemonic = (0, import_warps9.getWarpWalletMnemonicFromConfig)(this.config, this.chain.name);
|
|
@@ -1960,6 +1995,9 @@ var _PrivateKeyWalletProvider = class _PrivateKeyWalletProvider {
|
|
|
1960
1995
|
mnemonic: null
|
|
1961
1996
|
};
|
|
1962
1997
|
}
|
|
1998
|
+
async delete(externalId) {
|
|
1999
|
+
(0, import_warps10.removeWarpWalletFromConfig)(this.config, this.chain.name);
|
|
2000
|
+
}
|
|
1963
2001
|
getKeypair() {
|
|
1964
2002
|
if (this.keypair) return this.keypair;
|
|
1965
2003
|
const privateKey = (0, import_warps10.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
|
|
@@ -2023,6 +2061,9 @@ var ReadOnlyWalletProvider = class {
|
|
|
2023
2061
|
const address = (0, import_warps11.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
|
|
2024
2062
|
throw new Error(`Wallet can not be used for signing: ${address}`);
|
|
2025
2063
|
}
|
|
2064
|
+
async delete(externalId) {
|
|
2065
|
+
(0, import_warps11.removeWarpWalletFromConfig)(this.config, this.chain.name);
|
|
2066
|
+
}
|
|
2026
2067
|
};
|
|
2027
2068
|
|
|
2028
2069
|
// src/WarpSolanaWallet.ts
|
|
@@ -2086,6 +2127,10 @@ var WarpSolanaWallet = class {
|
|
|
2086
2127
|
const walletProvider = this.createProviderForOperation(provider);
|
|
2087
2128
|
return await walletProvider.generate();
|
|
2088
2129
|
}
|
|
2130
|
+
async delete(provider, externalId) {
|
|
2131
|
+
const walletProvider = this.createProviderForOperation(provider);
|
|
2132
|
+
await walletProvider.delete(externalId);
|
|
2133
|
+
}
|
|
2089
2134
|
getAddress() {
|
|
2090
2135
|
return this.cachedAddress;
|
|
2091
2136
|
}
|