@dynamic-labs/wallet-connector-core 4.0.0-alpha.25 → 4.0.0-alpha.26
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/CHANGELOG.md +2 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +7 -7
- package/src/index.cjs +2 -0
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDeepLinks/getDeepLinks.cjs +16 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDeepLinks/getDeepLinks.d.ts +3 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDeepLinks/getDeepLinks.js +12 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDeepLinks/index.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDownloadLinks/getDownloadLinks.cjs +36 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDownloadLinks/getDownloadLinks.d.ts +3 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDownloadLinks/getDownloadLinks.js +32 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDownloadLinks/index.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getIconUrl/getIconUrl.cjs +15 -0
- package/src/utils/getWalletMetadataFromWalletBook/getIconUrl/getIconUrl.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getIconUrl/getIconUrl.js +11 -0
- package/src/utils/getWalletMetadataFromWalletBook/getIconUrl/index.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getValidHexColor/getValidHexColor.cjs +15 -0
- package/src/utils/getWalletMetadataFromWalletBook/getValidHexColor/getValidHexColor.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getValidHexColor/getValidHexColor.js +11 -0
- package/src/utils/getWalletMetadataFromWalletBook/getValidHexColor/index.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletLimitations/getWalletLimitations.cjs +19 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletLimitations/getWalletLimitations.d.ts +3 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletLimitations/getWalletLimitations.js +15 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletLimitations/index.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletMetadataFromWalletBook.cjs +36 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletMetadataFromWalletBook.d.ts +9 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletMetadataFromWalletBook.js +32 -0
- package/src/utils/getWalletMetadataFromWalletBook/index.d.ts +1 -0
- package/src/utils/index.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.0.0-alpha.26](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.25...v4.0.0-alpha.26) (2024-11-04)
|
|
3
|
+
|
|
2
4
|
## [4.0.0-alpha.25](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.24...v4.0.0-alpha.25) (2024-11-01)
|
|
3
5
|
|
|
4
6
|
## [4.0.0-alpha.24](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.23...v4.0.0-alpha.24) (2024-10-31)
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/wallet-connector-core",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.26",
|
|
4
4
|
"description": "Core package for utilities and types for handling multiple wallet/chain support Dynamic SDK",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"@dynamic-labs/sdk-api-core": "0.0.559"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@dynamic-labs/assert-package-version": "4.0.0-alpha.
|
|
25
|
-
"@dynamic-labs/logger": "4.0.0-alpha.
|
|
26
|
-
"@dynamic-labs/rpc-providers": "4.0.0-alpha.
|
|
27
|
-
"@dynamic-labs/types": "4.0.0-alpha.
|
|
28
|
-
"@dynamic-labs/utils": "4.0.0-alpha.
|
|
29
|
-
"@dynamic-labs/wallet-book": "4.0.0-alpha.
|
|
24
|
+
"@dynamic-labs/assert-package-version": "4.0.0-alpha.26",
|
|
25
|
+
"@dynamic-labs/logger": "4.0.0-alpha.26",
|
|
26
|
+
"@dynamic-labs/rpc-providers": "4.0.0-alpha.26",
|
|
27
|
+
"@dynamic-labs/types": "4.0.0-alpha.26",
|
|
28
|
+
"@dynamic-labs/utils": "4.0.0-alpha.26",
|
|
29
|
+
"@dynamic-labs/wallet-book": "4.0.0-alpha.26",
|
|
30
30
|
"eventemitter3": "5.0.1"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/index.cjs
CHANGED
|
@@ -36,6 +36,7 @@ var isSendBalanceWalletConnector = require('./utils/isSendBalanceWalletConnector
|
|
|
36
36
|
var isSessionKeyCompatibleWallet = require('./utils/isSessionKeyCompatible/isSessionKeyCompatibleWallet/isSessionKeyCompatibleWallet.cjs');
|
|
37
37
|
var isSessionKeyCompatibleWalletConnector = require('./utils/isSessionKeyCompatible/isSessionKeyCompatibleWalletConnector/isSessionKeyCompatibleWalletConnector.cjs');
|
|
38
38
|
var getMobileExperience = require('./utils/getMobileExperience/getMobileExperience.cjs');
|
|
39
|
+
var getWalletMetadataFromWalletBook = require('./utils/getWalletMetadataFromWalletBook/getWalletMetadataFromWalletBook.cjs');
|
|
39
40
|
var Wallet = require('./Wallet/Wallet.cjs');
|
|
40
41
|
var WalletConnectorBase = require('./WalletConnectorBase/WalletConnectorBase.cjs');
|
|
41
42
|
var types = require('./WalletConnectorBase/types.cjs');
|
|
@@ -77,6 +78,7 @@ exports.isSendBalanceWalletConnector = isSendBalanceWalletConnector.isSendBalanc
|
|
|
77
78
|
exports.isSessionKeyCompatibleWallet = isSessionKeyCompatibleWallet.isSessionKeyCompatibleWallet;
|
|
78
79
|
exports.isSessionKeyCompatibleWalletConnector = isSessionKeyCompatibleWalletConnector.isSessionKeyCompatibleWalletConnector;
|
|
79
80
|
exports.getMobileExperience = getMobileExperience.getMobileExperience;
|
|
81
|
+
exports.getWalletMetadataFromWalletBook = getWalletMetadataFromWalletBook.getWalletMetadataFromWalletBook;
|
|
80
82
|
exports.Wallet = Wallet.Wallet;
|
|
81
83
|
exports.WalletConnectorBase = WalletConnectorBase.WalletConnectorBase;
|
|
82
84
|
exports.Chains = types.Chains;
|
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { walletConnectorEvents } from './events';
|
|
2
2
|
export { type Attestation, type AuthenticatorRecoveryHandler, type AuthenticatorType, type BitcoinSignPsbtRequest, type BitcoinSignPsbtRequestSignature, type BitcoinSignPsbtResponse, type ExportHandler, type ExtendedPrivateKey, type IAccountAbstractionWalletConnector, type IBitcoinWalletConnector, type ICoinbaseMPCWalletConnector, type IEmailOTPWalletConnector, type IEmailWalletConnector, type IHardwareWalletConnector, type IPasskeyWalletConnector, type IPhantomRedirectConnector, type IPhantomRedirectConnectorWithEvents, type ISendBalanceWalletConnector, type ISessionKeyCompatibleWalletConnector, type ISMSWalletConnector, type ITurnkeyWalletConnector, type ITurnkeyWalletConnectorStamper, type IWalletConnectConnector, type RawPrivateKey, type RecoveryEmailParams, type RecoveryWebAuthnAttestation, type SignAllTransactionsListener, type SignAndSendTransactionListener, type SignMessageListener, type SignTransactionListener, type WebAuthnAttestation, } from './interfaces';
|
|
3
3
|
export type { AccountChangeEventHandler, ChainChangeEventHandler, DisconnectEventHandler, WalletConnectorCore, WalletMetadata, } from './types';
|
|
4
|
-
export { addHexPrefix, bufferToHex, eventListenerHandlers, getChainInfo, getChainInfoWithOverrides, getDeepLink, getMobileExperience, getRpcUrlForChain, getWalletConnectorByKey, isAccountAbstractionConnector, isBitcoinConnector, isBloctoConnector, isCoinbaseMpcWalletConnector, isEmailOTPWalletConnector, isEmailWalletConnector, isEmbeddedConnector, isHardwareWalletConnector, isHex, isMagicConnector, isPasskeyWalletConnector, isPhantomRedirectConnector, isSameAddress, isSendBalanceWalletConnector, isSessionKeyCompatibleWallet, isSessionKeyCompatibleWalletConnector, isSocialWalletConnector, isTurnkeyWalletConnector, isWalletConnectConnector, logger, performPlatformSpecificConnectionMethod, ProviderLookup, setChainInfoOverrides, shouldLowercaseAddress, utf8ToHex, type ChainDisplayOverrides, type DeepLinkVariant, type ProviderCondition, } from './utils';
|
|
4
|
+
export { addHexPrefix, bufferToHex, eventListenerHandlers, getChainInfo, getChainInfoWithOverrides, getDeepLink, getMobileExperience, getRpcUrlForChain, getWalletConnectorByKey, isAccountAbstractionConnector, isBitcoinConnector, isBloctoConnector, isCoinbaseMpcWalletConnector, isEmailOTPWalletConnector, isEmailWalletConnector, isEmbeddedConnector, isHardwareWalletConnector, isHex, isMagicConnector, isPasskeyWalletConnector, isPhantomRedirectConnector, isSameAddress, isSendBalanceWalletConnector, isSessionKeyCompatibleWallet, isSessionKeyCompatibleWalletConnector, isSocialWalletConnector, isTurnkeyWalletConnector, isWalletConnectConnector, getWalletMetadataFromWalletBook, logger, performPlatformSpecificConnectionMethod, ProviderLookup, setChainInfoOverrides, shouldLowercaseAddress, utf8ToHex, type ChainDisplayOverrides, type DeepLinkVariant, type ProviderCondition, } from './utils';
|
|
5
5
|
export { Wallet, type WalletConstructor, type WalletProps } from './Wallet';
|
|
6
6
|
export { Chains, socialProviders, WalletConnectorBase, type Chain, type ChainInfo, type GetAddressOpts, type InternalWalletConnector, type NameServiceData, type PayloadParams, type SocialProvider, type WalletConnector, type WalletConnectorConstructor, type WalletConnectorEventTypes, type WalletConnectorExtension, type WalletConnectorsMethod, } from './WalletConnectorBase';
|
package/src/index.js
CHANGED
|
@@ -32,6 +32,7 @@ export { isSendBalanceWalletConnector } from './utils/isSendBalanceWalletConnect
|
|
|
32
32
|
export { isSessionKeyCompatibleWallet } from './utils/isSessionKeyCompatible/isSessionKeyCompatibleWallet/isSessionKeyCompatibleWallet.js';
|
|
33
33
|
export { isSessionKeyCompatibleWalletConnector } from './utils/isSessionKeyCompatible/isSessionKeyCompatibleWalletConnector/isSessionKeyCompatibleWalletConnector.js';
|
|
34
34
|
export { getMobileExperience } from './utils/getMobileExperience/getMobileExperience.js';
|
|
35
|
+
export { getWalletMetadataFromWalletBook } from './utils/getWalletMetadataFromWalletBook/getWalletMetadataFromWalletBook.js';
|
|
35
36
|
export { Wallet } from './Wallet/Wallet.js';
|
|
36
37
|
export { WalletConnectorBase } from './WalletConnectorBase/WalletConnectorBase.js';
|
|
37
38
|
export { Chains, socialProviders } from './WalletConnectorBase/types.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const getDeepLinks = (mobile) => {
|
|
7
|
+
if (!mobile) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
native: mobile.native,
|
|
12
|
+
universal: mobile.universal,
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.getDeepLinks = getDeepLinks;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getDeepLinks';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const getMobileDownloadLinks = (mobile) => {
|
|
7
|
+
if (!mobile) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
androidId: mobile.androidId,
|
|
12
|
+
iosId: mobile.iosId,
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
const getDesktopDownloadLinks = (desktop) => {
|
|
16
|
+
if (!desktop) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
chromeId: desktop.chromeId,
|
|
21
|
+
edgeId: desktop.edgeId,
|
|
22
|
+
firefoxId: desktop.firefoxId,
|
|
23
|
+
operaId: desktop.operaId,
|
|
24
|
+
safariId: desktop.safariId,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const getDownloadLinks = (wallet) => {
|
|
28
|
+
const mobileLinks = getMobileDownloadLinks(wallet.mobile);
|
|
29
|
+
const desktopLinks = getDesktopDownloadLinks(wallet.desktop);
|
|
30
|
+
if (!mobileLinks && !desktopLinks) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
return Object.assign(Object.assign({}, mobileLinks), desktopLinks);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.getDownloadLinks = getDownloadLinks;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const getMobileDownloadLinks = (mobile) => {
|
|
3
|
+
if (!mobile) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
return {
|
|
7
|
+
androidId: mobile.androidId,
|
|
8
|
+
iosId: mobile.iosId,
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
const getDesktopDownloadLinks = (desktop) => {
|
|
12
|
+
if (!desktop) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
chromeId: desktop.chromeId,
|
|
17
|
+
edgeId: desktop.edgeId,
|
|
18
|
+
firefoxId: desktop.firefoxId,
|
|
19
|
+
operaId: desktop.operaId,
|
|
20
|
+
safariId: desktop.safariId,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const getDownloadLinks = (wallet) => {
|
|
24
|
+
const mobileLinks = getMobileDownloadLinks(wallet.mobile);
|
|
25
|
+
const desktopLinks = getDesktopDownloadLinks(wallet.desktop);
|
|
26
|
+
if (!mobileLinks && !desktopLinks) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
return Object.assign(Object.assign({}, mobileLinks), desktopLinks);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { getDownloadLinks };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getDownloadLinks';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var walletBook = require('@dynamic-labs/wallet-book');
|
|
7
|
+
|
|
8
|
+
const getIconUrl = (spriteId) => {
|
|
9
|
+
if (!spriteId) {
|
|
10
|
+
return walletBook.renderTemplate('iconicUrl', 'defaultwallet');
|
|
11
|
+
}
|
|
12
|
+
return walletBook.renderTemplate('iconicUrl', spriteId);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.getIconUrl = getIconUrl;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getIconUrl: (spriteId?: string) => string | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { renderTemplate } from '@dynamic-labs/wallet-book';
|
|
3
|
+
|
|
4
|
+
const getIconUrl = (spriteId) => {
|
|
5
|
+
if (!spriteId) {
|
|
6
|
+
return renderTemplate('iconicUrl', 'defaultwallet');
|
|
7
|
+
}
|
|
8
|
+
return renderTemplate('iconicUrl', spriteId);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { getIconUrl };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getIconUrl';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const getValidHexColor = (color) => {
|
|
7
|
+
if (!color) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
// Check if string starts with # and is followed by either 3 or 6 valid hex characters
|
|
11
|
+
const hexColorRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
|
|
12
|
+
return hexColorRegex.test(color) ? color : undefined;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.getValidHexColor = getValidHexColor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getValidHexColor: (color?: string) => `#${string}` | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const getValidHexColor = (color) => {
|
|
3
|
+
if (!color) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
// Check if string starts with # and is followed by either 3 or 6 valid hex characters
|
|
7
|
+
const hexColorRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
|
|
8
|
+
return hexColorRegex.test(color) ? color : undefined;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { getValidHexColor };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getValidHexColor';
|
package/src/utils/getWalletMetadataFromWalletBook/getWalletLimitations/getWalletLimitations.cjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const getWalletLimitations = (walletLimitations) => {
|
|
7
|
+
if (!(walletLimitations === null || walletLimitations === void 0 ? void 0 : walletLimitations.browserExtension)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const { unsupportedEvents, unsupportedMethods } = walletLimitations.browserExtension;
|
|
11
|
+
return {
|
|
12
|
+
browserExtension: {
|
|
13
|
+
unsupportedEvents: unsupportedEvents,
|
|
14
|
+
unsupportedMethods: unsupportedMethods,
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.getWalletLimitations = getWalletLimitations;
|
package/src/utils/getWalletMetadataFromWalletBook/getWalletLimitations/getWalletLimitations.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const getWalletLimitations = (walletLimitations) => {
|
|
3
|
+
if (!(walletLimitations === null || walletLimitations === void 0 ? void 0 : walletLimitations.browserExtension)) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
const { unsupportedEvents, unsupportedMethods } = walletLimitations.browserExtension;
|
|
7
|
+
return {
|
|
8
|
+
browserExtension: {
|
|
9
|
+
unsupportedEvents: unsupportedEvents,
|
|
10
|
+
unsupportedMethods: unsupportedMethods,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { getWalletLimitations };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getWalletLimitations';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var walletBook = require('@dynamic-labs/wallet-book');
|
|
7
|
+
var getIconUrl = require('./getIconUrl/getIconUrl.cjs');
|
|
8
|
+
var getValidHexColor = require('./getValidHexColor/getValidHexColor.cjs');
|
|
9
|
+
var getDeepLinks = require('./getDeepLinks/getDeepLinks.cjs');
|
|
10
|
+
var getDownloadLinks = require('./getDownloadLinks/getDownloadLinks.cjs');
|
|
11
|
+
var getWalletLimitations = require('./getWalletLimitations/getWalletLimitations.cjs');
|
|
12
|
+
|
|
13
|
+
const getWalletMetadataFromWalletBook = ({ walletKey, walletBookWallet, walletBook: walletBook$1, }) => {
|
|
14
|
+
var _a, _b, _c, _d, _e;
|
|
15
|
+
if (!walletBook$1) {
|
|
16
|
+
throw new Error('Wallet book is required');
|
|
17
|
+
}
|
|
18
|
+
const wallet = walletBookWallet !== null && walletBookWallet !== void 0 ? walletBookWallet : walletBook.findWalletBookWallet(walletBook$1, walletKey);
|
|
19
|
+
// if no walletBookWallet is provided and no wallet is found in the wallet book, throw an error
|
|
20
|
+
if (!wallet) {
|
|
21
|
+
throw new Error('Wallet not found in wallet book');
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
brandColor: getValidHexColor.getValidHexColor((_a = wallet === null || wallet === void 0 ? void 0 : wallet.brand) === null || _a === void 0 ? void 0 : _a.primaryColor),
|
|
25
|
+
deepLinks: getDeepLinks.getDeepLinks(wallet === null || wallet === void 0 ? void 0 : wallet.mobile),
|
|
26
|
+
downloadLinks: getDownloadLinks.getDownloadLinks(wallet),
|
|
27
|
+
groupKey: (_b = wallet === null || wallet === void 0 ? void 0 : wallet.chainGroup) !== null && _b !== void 0 ? _b : wallet === null || wallet === void 0 ? void 0 : wallet.walletGroup,
|
|
28
|
+
icon: (_d = getIconUrl.getIconUrl((_c = wallet === null || wallet === void 0 ? void 0 : wallet.brand) === null || _c === void 0 ? void 0 : _c.spriteId)) !== null && _d !== void 0 ? _d : '',
|
|
29
|
+
id: walletKey,
|
|
30
|
+
name: wallet.name,
|
|
31
|
+
rdns: (_e = wallet.eip6963Config) === null || _e === void 0 ? void 0 : _e.rdns,
|
|
32
|
+
walletLimitations: getWalletLimitations.getWalletLimitations(wallet.walletLimitations),
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.getWalletMetadataFromWalletBook = getWalletMetadataFromWalletBook;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WalletBookSchema, WalletSchema } from '@dynamic-labs/wallet-book';
|
|
2
|
+
import { WalletMetadata } from '../../types';
|
|
3
|
+
type GetWalletMetadataFromWalletBookOpts = {
|
|
4
|
+
walletKey: string;
|
|
5
|
+
walletBookWallet?: WalletSchema;
|
|
6
|
+
walletBook?: WalletBookSchema;
|
|
7
|
+
};
|
|
8
|
+
export declare const getWalletMetadataFromWalletBook: ({ walletKey, walletBookWallet, walletBook, }: GetWalletMetadataFromWalletBookOpts) => WalletMetadata;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
3
|
+
import { getIconUrl } from './getIconUrl/getIconUrl.js';
|
|
4
|
+
import { getValidHexColor } from './getValidHexColor/getValidHexColor.js';
|
|
5
|
+
import { getDeepLinks } from './getDeepLinks/getDeepLinks.js';
|
|
6
|
+
import { getDownloadLinks } from './getDownloadLinks/getDownloadLinks.js';
|
|
7
|
+
import { getWalletLimitations } from './getWalletLimitations/getWalletLimitations.js';
|
|
8
|
+
|
|
9
|
+
const getWalletMetadataFromWalletBook = ({ walletKey, walletBookWallet, walletBook, }) => {
|
|
10
|
+
var _a, _b, _c, _d, _e;
|
|
11
|
+
if (!walletBook) {
|
|
12
|
+
throw new Error('Wallet book is required');
|
|
13
|
+
}
|
|
14
|
+
const wallet = walletBookWallet !== null && walletBookWallet !== void 0 ? walletBookWallet : findWalletBookWallet(walletBook, walletKey);
|
|
15
|
+
// if no walletBookWallet is provided and no wallet is found in the wallet book, throw an error
|
|
16
|
+
if (!wallet) {
|
|
17
|
+
throw new Error('Wallet not found in wallet book');
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
brandColor: getValidHexColor((_a = wallet === null || wallet === void 0 ? void 0 : wallet.brand) === null || _a === void 0 ? void 0 : _a.primaryColor),
|
|
21
|
+
deepLinks: getDeepLinks(wallet === null || wallet === void 0 ? void 0 : wallet.mobile),
|
|
22
|
+
downloadLinks: getDownloadLinks(wallet),
|
|
23
|
+
groupKey: (_b = wallet === null || wallet === void 0 ? void 0 : wallet.chainGroup) !== null && _b !== void 0 ? _b : wallet === null || wallet === void 0 ? void 0 : wallet.walletGroup,
|
|
24
|
+
icon: (_d = getIconUrl((_c = wallet === null || wallet === void 0 ? void 0 : wallet.brand) === null || _c === void 0 ? void 0 : _c.spriteId)) !== null && _d !== void 0 ? _d : '',
|
|
25
|
+
id: walletKey,
|
|
26
|
+
name: wallet.name,
|
|
27
|
+
rdns: (_e = wallet.eip6963Config) === null || _e === void 0 ? void 0 : _e.rdns,
|
|
28
|
+
walletLimitations: getWalletLimitations(wallet.walletLimitations),
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { getWalletMetadataFromWalletBook };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getWalletMetadataFromWalletBook';
|
package/src/utils/index.d.ts
CHANGED