@dynamic-labs/wallet-book
Advanced tools
Comparing version 4.0.0-alpha.5 to 4.0.0-alpha.6
{ | ||
"name": "@dynamic-labs/wallet-book", | ||
"version": "4.0.0-alpha.5", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git", | ||
"directory": "packages/wallet-book" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/dynamic-labs/DynamicAuth/issues" | ||
}, | ||
"homepage": "https://github.com/dynamic-labs/DynamicAuth#readme", | ||
"version": "4.0.0-alpha.6", | ||
"author": "Dynamic Labs, Inc.", | ||
@@ -29,7 +20,10 @@ "license": "MIT", | ||
"zod": "3.22.4", | ||
"@dynamic-labs/iconic": "4.0.0-alpha.5", | ||
"@dynamic-labs/logger": "4.0.0-alpha.5", | ||
"@dynamic-labs/utils": "4.0.0-alpha.5", | ||
"@dynamic-labs/assert-package-version": "4.0.0-alpha.6", | ||
"@dynamic-labs/iconic": "4.0.0-alpha.6", | ||
"@dynamic-labs/logger": "4.0.0-alpha.6", | ||
"@dynamic-labs/utils": "4.0.0-alpha.6", | ||
"eventemitter3": "5.0.1", | ||
"util": "0.12.5" | ||
}, | ||
"homepage": "https://www.dynamic.xyz/", | ||
"peerDependencies": { | ||
@@ -36,0 +30,0 @@ "react": "^18.0.0", |
'use client' | ||
import { __awaiter } from '../../_virtual/_tslib.js'; | ||
import { useState, useEffect } from 'react'; | ||
import { retryableFn } from '@dynamic-labs/utils'; | ||
import '../schemas/walletConnectSourceSchema.js'; | ||
import { walletBookSchema } from '../schemas/walletBookSchema.js'; | ||
import '../schemas/walletSchema.js'; | ||
import '../helpers/renderTemplate.js'; | ||
import { logger } from '../helpers/logger.js'; | ||
import { getWalletBookCdnUrl } from '../helpers/getWalletBookCdnUrl.js'; | ||
import walletBookFallbacks from '../../wallet-book-fallbacks.js'; | ||
import { fetchWalletBook, walletBookCache, walletBookEmitter } from './fetchWalletBook/fetchWalletBook.js'; | ||
// Initiate wallet book fetch immediately | ||
fetchWalletBook(); | ||
const useWalletBookCdn = () => { | ||
const [walletBook, setWalletBook] = useState({}); | ||
const [walletBookState, setWalletBookState] = useState(walletBookCache.current); | ||
useEffect(() => { | ||
const fetchWalletBook = () => __awaiter(void 0, void 0, void 0, function* () { | ||
const url = getWalletBookCdnUrl(); | ||
const fn = () => __awaiter(void 0, void 0, void 0, function* () { | ||
const res = yield fetch(url, { mode: 'cors' }); | ||
if (res.ok) { | ||
const json = yield res.json(); | ||
try { | ||
const parsedData = walletBookSchema.parse(json); | ||
return parsedData; | ||
} | ||
catch (e) { | ||
logger.error('Error parsing wallet book data', e, json); | ||
throw e; | ||
} | ||
} | ||
throw new Error(`Failed to fetch wallet book data from ${url} with status code ${res.status}`); | ||
}); | ||
const data = yield retryableFn(fn, { | ||
fallbackValue: walletBookSchema.parse(walletBookFallbacks), | ||
logger: logger.createLogger('useWalletBookCdn'), | ||
maxRetries: 3, | ||
retryStrategy: 'timeout-and-rejection', | ||
timeoutMs: 30000, | ||
}); | ||
setWalletBook(data); | ||
}); | ||
fetchWalletBook(); | ||
walletBookEmitter.on('walletBookLoaded', setWalletBookState); | ||
return () => { | ||
walletBookEmitter.off('walletBookLoaded', setWalletBookState); | ||
}; | ||
}, []); | ||
return walletBook; | ||
return walletBookState; | ||
}; | ||
export { useWalletBookCdn }; |
'use client' | ||
import { assertPackageVersion } from '@dynamic-labs/assert-package-version'; | ||
import { version } from '../package.js'; | ||
export { useWalletBookContext } from './context/WalletBookContext.js'; | ||
@@ -21,1 +23,3 @@ export { getWalletIconUrl } from './helpers/getWalletIconUrl.js'; | ||
export { BrandIcon } from './components/BrandIcon.js'; | ||
assertPackageVersion('@dynamic-labs/wallet-book', version); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
586439
121
1
9
7460
1
+ Addedeventemitter3@5.0.1
+ Added@dynamic-labs/assert-package-version@4.0.0-alpha.6(transitive)
+ Added@dynamic-labs/iconic@4.0.0-alpha.6(transitive)
+ Added@dynamic-labs/logger@4.0.0-alpha.6(transitive)
+ Added@dynamic-labs/types@4.0.0-alpha.6(transitive)
+ Added@dynamic-labs/utils@4.0.0-alpha.6(transitive)
- Removed@dynamic-labs/iconic@4.0.0-alpha.5(transitive)
- Removed@dynamic-labs/logger@4.0.0-alpha.5(transitive)
- Removed@dynamic-labs/types@4.0.0-alpha.5(transitive)
- Removed@dynamic-labs/utils@4.0.0-alpha.5(transitive)