@flaunch/sdk 0.4.1 → 0.4.2
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/helpers/index.cjs +14 -1
- package/dist/helpers/index.cjs.map +1 -1
- package/dist/helpers/index.js +14 -1
- package/dist/helpers/index.js.map +1 -1
- package/dist/helpers/ipfs.d.ts.map +1 -1
- package/dist/index.cjs.js +42 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +42 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/sdk/FlaunchSDK.d.ts +21 -1
- package/dist/sdk/FlaunchSDK.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ipfs.d.ts","sourceRoot":"","sources":["../../src/helpers/ipfs.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,UAAU,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"ipfs.d.ts","sourceRoot":"","sources":["../../src/helpers/ipfs.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,UAAU,EAAE,MAAM,UAAU,CAAC;AAYpD,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,MAU3C,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,UAAU,cAAc;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAU,QAAQ;IAC7C,YAAY,EAAE,YAAY,CAAC;IAC3B,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC,KAAG,OAAO,CAAC,cAAc,CA2CzB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAU,QAAQ;IAC7C,YAAY,EAAE,YAAY,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC,KAAG,OAAO,CAAC,cAAc,CAwCzB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAU,QAAQ;IAC9C,YAAY,EAAE,YAAY,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC,KAAG,OAAO,CAAC,cAAc,CAsEzB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAU,MAAM,MAAM,EAAE,QAAQ,UAAU,oBAyBtE,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -6929,9 +6929,22 @@ const FlaunchPositionManagerAbi = [
|
|
|
6929
6929
|
{ stateMutability: "payable", type: "receive" },
|
|
6930
6930
|
];
|
|
6931
6931
|
|
|
6932
|
+
// List of public IPFS gateways to cycle through
|
|
6933
|
+
const IPFS_GATEWAYS = [
|
|
6934
|
+
"https://gateway.pinata.cloud/ipfs/",
|
|
6935
|
+
"https://ipfs.io/ipfs/",
|
|
6936
|
+
"https://dweb.link/ipfs/",
|
|
6937
|
+
];
|
|
6938
|
+
// Counter to track the current gateway index
|
|
6939
|
+
let currentGatewayIndex = 0;
|
|
6932
6940
|
const resolveIPFS = (value) => {
|
|
6933
6941
|
if (value.startsWith("ipfs://")) {
|
|
6934
|
-
|
|
6942
|
+
const cid = value.slice(7);
|
|
6943
|
+
// Get the next gateway and increment the counter
|
|
6944
|
+
const gateway = IPFS_GATEWAYS[currentGatewayIndex];
|
|
6945
|
+
// Update the counter, cycling back to 0 when we reach the end
|
|
6946
|
+
currentGatewayIndex = (currentGatewayIndex + 1) % IPFS_GATEWAYS.length;
|
|
6947
|
+
return `${gateway}${cid}`;
|
|
6935
6948
|
}
|
|
6936
6949
|
return value;
|
|
6937
6950
|
};
|
|
@@ -17566,6 +17579,7 @@ class ReadFlaunchSDK {
|
|
|
17566
17579
|
this.TICK_SPACING = TICK_SPACING;
|
|
17567
17580
|
this.chainId = chainId;
|
|
17568
17581
|
this.drift = drift$1;
|
|
17582
|
+
this.resolveIPFS = resolveIPFS;
|
|
17569
17583
|
this.readPositionManager = new ReadFlaunchPositionManager(FlaunchPositionManagerAddress[this.chainId], drift$1);
|
|
17570
17584
|
this.readPositionManagerV1_1 = new ReadFlaunchPositionManagerV1_1(FlaunchPositionManagerV1_1Address[this.chainId], drift$1);
|
|
17571
17585
|
this.readPoolManager = new ReadPoolManager(PoolManagerAddress[this.chainId], drift$1);
|
|
@@ -17607,12 +17621,12 @@ class ReadFlaunchSDK {
|
|
|
17607
17621
|
const symbol = await memecoin.symbol();
|
|
17608
17622
|
const tokenURI = await memecoin.tokenURI();
|
|
17609
17623
|
// get metadata from tokenURI
|
|
17610
|
-
const metadata = (await axios__default["default"].get(resolveIPFS(tokenURI))).data;
|
|
17624
|
+
const metadata = (await axios__default["default"].get(this.resolveIPFS(tokenURI))).data;
|
|
17611
17625
|
return {
|
|
17612
17626
|
name,
|
|
17613
17627
|
symbol,
|
|
17614
17628
|
description: metadata.description ?? "",
|
|
17615
|
-
image: metadata.image ? resolveIPFS(metadata.image) : "",
|
|
17629
|
+
image: metadata.image ? this.resolveIPFS(metadata.image) : "",
|
|
17616
17630
|
external_link: metadata.websiteUrl ?? "",
|
|
17617
17631
|
collaborators: metadata.collaborators ?? [],
|
|
17618
17632
|
discordUrl: metadata.discordUrl ?? "",
|
|
@@ -17620,12 +17634,25 @@ class ReadFlaunchSDK {
|
|
|
17620
17634
|
telegramUrl: metadata.telegramUrl ?? "",
|
|
17621
17635
|
};
|
|
17622
17636
|
}
|
|
17637
|
+
/**
|
|
17638
|
+
* Retrieves metadata for a given Flaunch coin using its token ID & Flaunch contract address
|
|
17639
|
+
* @param flaunch - The address of the Flaunch contract
|
|
17640
|
+
* @param tokenId - The token ID of the coin
|
|
17641
|
+
* @returns The coin's metadata including name, symbol, description, and social links
|
|
17642
|
+
*/
|
|
17623
17643
|
async getCoinMetadataFromTokenId(flaunch, tokenId) {
|
|
17624
17644
|
const _flaunch = new ReadFlaunch(flaunch, this.drift);
|
|
17625
17645
|
const coinAddress = await _flaunch.memecoin(tokenId);
|
|
17626
17646
|
return this.getCoinMetadata(coinAddress);
|
|
17627
17647
|
}
|
|
17628
|
-
|
|
17648
|
+
/**
|
|
17649
|
+
* Retrieves metadata for multiple Flaunch coins using their token IDs & Flaunch contract addresses
|
|
17650
|
+
* @param params - An array of objects containing flaunch contract address and token ID
|
|
17651
|
+
* @param batchSize - Optional, the number of ipfs requests to process in each batch
|
|
17652
|
+
* @param batchDelay - Optional, the delay in milliseconds between batches
|
|
17653
|
+
* @returns An array of objects containing coin address, name, symbol, description, and social links
|
|
17654
|
+
*/
|
|
17655
|
+
async getCoinMetadataFromTokenIds(params, batchSize = 9, batchDelay = 500) {
|
|
17629
17656
|
const multicall = new ReadMulticall(this.drift);
|
|
17630
17657
|
// get coin addresses via multicall
|
|
17631
17658
|
const coinAddresses_calldata = params.map((p) => this.readFlaunch.contract.encodeFunctionData("memecoin", {
|
|
@@ -17678,18 +17705,17 @@ class ReadFlaunchSDK {
|
|
|
17678
17705
|
results.push({ name, symbol, tokenURI, coinAddress: coinAddresses[i] });
|
|
17679
17706
|
}
|
|
17680
17707
|
// Process IPFS requests in batches to avoid rate limiting
|
|
17681
|
-
const batchSize = 3;
|
|
17682
17708
|
const processedResults = [];
|
|
17683
17709
|
for (let i = 0; i < results.length; i += batchSize) {
|
|
17684
17710
|
const batch = results.slice(i, i + batchSize);
|
|
17685
17711
|
const batchResults = await Promise.all(batch.map(async ({ name, symbol, tokenURI, coinAddress }) => {
|
|
17686
|
-
const metadata = (await axios__default["default"].get(resolveIPFS(tokenURI))).data;
|
|
17712
|
+
const metadata = (await axios__default["default"].get(this.resolveIPFS(tokenURI))).data;
|
|
17687
17713
|
return {
|
|
17688
17714
|
coinAddress,
|
|
17689
17715
|
name,
|
|
17690
17716
|
symbol,
|
|
17691
17717
|
description: metadata.description ?? "",
|
|
17692
|
-
image: metadata.image ? resolveIPFS(metadata.image) : "",
|
|
17718
|
+
image: metadata.image ? this.resolveIPFS(metadata.image) : "",
|
|
17693
17719
|
external_link: metadata.websiteUrl ?? "",
|
|
17694
17720
|
collaborators: metadata.collaborators ?? [],
|
|
17695
17721
|
discordUrl: metadata.discordUrl ?? "",
|
|
@@ -17700,7 +17726,7 @@ class ReadFlaunchSDK {
|
|
|
17700
17726
|
processedResults.push(...batchResults);
|
|
17701
17727
|
// Add a small delay between batches to avoid rate limiting
|
|
17702
17728
|
if (i + batchSize < results.length) {
|
|
17703
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
17729
|
+
await new Promise((resolve) => setTimeout(resolve, batchDelay));
|
|
17704
17730
|
}
|
|
17705
17731
|
}
|
|
17706
17732
|
return processedResults;
|
|
@@ -18126,6 +18152,14 @@ class ReadFlaunchSDK {
|
|
|
18126
18152
|
flETHIsCurrencyZero(coinAddress) {
|
|
18127
18153
|
return coinAddress > FLETHAddress[this.chainId];
|
|
18128
18154
|
}
|
|
18155
|
+
/**
|
|
18156
|
+
* Sets a custom IPFS resolver function
|
|
18157
|
+
* @dev this is used to resolve IPFS hash to a gateway URL
|
|
18158
|
+
* @param resolverFn - Custom function to resolve IPFS URIs
|
|
18159
|
+
*/
|
|
18160
|
+
setIPFSResolver(resolverFn) {
|
|
18161
|
+
this.resolveIPFS = resolverFn;
|
|
18162
|
+
}
|
|
18129
18163
|
}
|
|
18130
18164
|
class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
|
|
18131
18165
|
constructor(chainId, drift$1 = drift.createDrift()) {
|