@partylayer/react 0.3.0 → 0.4.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.mts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +34 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as _partylayer_sdk from '@partylayer/sdk';
|
|
3
|
-
import { PartyLayerClient, Session, WalletInfo, ConnectOptions, RegistryStatus, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, WalletAdapter, AdapterClass, WalletId, CIP0103Provider, CapabilityKey, AdapterDetectResult, AdapterContext, PartyId, AdapterConnectResult, DiscoveredProvider } from '@partylayer/sdk';
|
|
3
|
+
import { PartyLayerClient, Session, WalletInfo, ConnectOptions, LedgerApiParams, LedgerApiResult, RegistryStatus, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, WalletAdapter, AdapterClass, WalletId, CIP0103Provider, CapabilityKey, AdapterDetectResult, AdapterContext, PartyId, AdapterConnectResult, DiscoveredProvider } from '@partylayer/sdk';
|
|
4
4
|
import * as _partylayer_core from '@partylayer/core';
|
|
5
5
|
export { RegistryStatus } from '@partylayer/registry-client';
|
|
6
6
|
|
|
@@ -84,6 +84,14 @@ declare function useSubmitTransaction(): {
|
|
|
84
84
|
isSubmitting: boolean;
|
|
85
85
|
error: Error | null;
|
|
86
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* Hook to call the Ledger API through the connected wallet
|
|
89
|
+
*/
|
|
90
|
+
declare function useLedgerApi(): {
|
|
91
|
+
ledgerApi: (params: LedgerApiParams) => Promise<LedgerApiResult | null>;
|
|
92
|
+
isLoading: boolean;
|
|
93
|
+
error: Error | null;
|
|
94
|
+
};
|
|
87
95
|
|
|
88
96
|
/**
|
|
89
97
|
* Lightweight theme system for PartyLayer UI components.
|
|
@@ -236,4 +244,4 @@ declare function createNativeAdapter(discovered: DiscoveredProvider): NativeCIP0
|
|
|
236
244
|
*/
|
|
237
245
|
declare function createSyntheticWalletInfo(discovered: DiscoveredProvider, network: string): WalletInfo;
|
|
238
246
|
|
|
239
|
-
export { PartyLayerProvider as CantonConnectProvider, ConnectButton, type ConnectButtonProps, NativeCIP0103Adapter, PartyLayerKit, type PartyLayerKitProps, PartyLayerProvider, type PartyLayerTheme, ThemeProvider, type WalletIconMap, WalletModal, type WalletModalProps, createNativeAdapter, createSyntheticWalletInfo, darkTheme, lightTheme, resolveWalletIcon, truncatePartyId, usePartyLayer as useCantonConnect, useConnect, useDisconnect, usePartyLayer, usePartyLayerContext, useRegistryStatus, useSession, useSignMessage, useSignTransaction, useSubmitTransaction, useTheme, useWalletIcons, useWallets };
|
|
247
|
+
export { PartyLayerProvider as CantonConnectProvider, ConnectButton, type ConnectButtonProps, NativeCIP0103Adapter, PartyLayerKit, type PartyLayerKitProps, PartyLayerProvider, type PartyLayerTheme, ThemeProvider, type WalletIconMap, WalletModal, type WalletModalProps, createNativeAdapter, createSyntheticWalletInfo, darkTheme, lightTheme, resolveWalletIcon, truncatePartyId, usePartyLayer as useCantonConnect, useConnect, useDisconnect, useLedgerApi, usePartyLayer, usePartyLayerContext, useRegistryStatus, useSession, useSignMessage, useSignTransaction, useSubmitTransaction, useTheme, useWalletIcons, useWallets };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as _partylayer_sdk from '@partylayer/sdk';
|
|
3
|
-
import { PartyLayerClient, Session, WalletInfo, ConnectOptions, RegistryStatus, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, WalletAdapter, AdapterClass, WalletId, CIP0103Provider, CapabilityKey, AdapterDetectResult, AdapterContext, PartyId, AdapterConnectResult, DiscoveredProvider } from '@partylayer/sdk';
|
|
3
|
+
import { PartyLayerClient, Session, WalletInfo, ConnectOptions, LedgerApiParams, LedgerApiResult, RegistryStatus, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, WalletAdapter, AdapterClass, WalletId, CIP0103Provider, CapabilityKey, AdapterDetectResult, AdapterContext, PartyId, AdapterConnectResult, DiscoveredProvider } from '@partylayer/sdk';
|
|
4
4
|
import * as _partylayer_core from '@partylayer/core';
|
|
5
5
|
export { RegistryStatus } from '@partylayer/registry-client';
|
|
6
6
|
|
|
@@ -84,6 +84,14 @@ declare function useSubmitTransaction(): {
|
|
|
84
84
|
isSubmitting: boolean;
|
|
85
85
|
error: Error | null;
|
|
86
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* Hook to call the Ledger API through the connected wallet
|
|
89
|
+
*/
|
|
90
|
+
declare function useLedgerApi(): {
|
|
91
|
+
ledgerApi: (params: LedgerApiParams) => Promise<LedgerApiResult | null>;
|
|
92
|
+
isLoading: boolean;
|
|
93
|
+
error: Error | null;
|
|
94
|
+
};
|
|
87
95
|
|
|
88
96
|
/**
|
|
89
97
|
* Lightweight theme system for PartyLayer UI components.
|
|
@@ -236,4 +244,4 @@ declare function createNativeAdapter(discovered: DiscoveredProvider): NativeCIP0
|
|
|
236
244
|
*/
|
|
237
245
|
declare function createSyntheticWalletInfo(discovered: DiscoveredProvider, network: string): WalletInfo;
|
|
238
246
|
|
|
239
|
-
export { PartyLayerProvider as CantonConnectProvider, ConnectButton, type ConnectButtonProps, NativeCIP0103Adapter, PartyLayerKit, type PartyLayerKitProps, PartyLayerProvider, type PartyLayerTheme, ThemeProvider, type WalletIconMap, WalletModal, type WalletModalProps, createNativeAdapter, createSyntheticWalletInfo, darkTheme, lightTheme, resolveWalletIcon, truncatePartyId, usePartyLayer as useCantonConnect, useConnect, useDisconnect, usePartyLayer, usePartyLayerContext, useRegistryStatus, useSession, useSignMessage, useSignTransaction, useSubmitTransaction, useTheme, useWalletIcons, useWallets };
|
|
247
|
+
export { PartyLayerProvider as CantonConnectProvider, ConnectButton, type ConnectButtonProps, NativeCIP0103Adapter, PartyLayerKit, type PartyLayerKitProps, PartyLayerProvider, type PartyLayerTheme, ThemeProvider, type WalletIconMap, WalletModal, type WalletModalProps, createNativeAdapter, createSyntheticWalletInfo, darkTheme, lightTheme, resolveWalletIcon, truncatePartyId, usePartyLayer as useCantonConnect, useConnect, useDisconnect, useLedgerApi, usePartyLayer, usePartyLayerContext, useRegistryStatus, useSession, useSignMessage, useSignTransaction, useSubmitTransaction, useTheme, useWalletIcons, useWallets };
|
package/dist/index.js
CHANGED
|
@@ -434,6 +434,28 @@ function useSubmitTransaction() {
|
|
|
434
434
|
);
|
|
435
435
|
return { submitTransaction, isSubmitting, error };
|
|
436
436
|
}
|
|
437
|
+
function useLedgerApi() {
|
|
438
|
+
const client = usePartyLayer();
|
|
439
|
+
const [isLoading, setIsLoading] = react.useState(false);
|
|
440
|
+
const [error, setError] = react.useState(null);
|
|
441
|
+
const ledgerApi = react.useCallback(
|
|
442
|
+
async (params) => {
|
|
443
|
+
setIsLoading(true);
|
|
444
|
+
setError(null);
|
|
445
|
+
try {
|
|
446
|
+
return await client.ledgerApi(params);
|
|
447
|
+
} catch (err) {
|
|
448
|
+
const error2 = err instanceof Error ? err : new Error("Ledger API call failed");
|
|
449
|
+
setError(error2);
|
|
450
|
+
return null;
|
|
451
|
+
} finally {
|
|
452
|
+
setIsLoading(false);
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
[client]
|
|
456
|
+
);
|
|
457
|
+
return { ledgerApi, isLoading, error };
|
|
458
|
+
}
|
|
437
459
|
var lightTheme = {
|
|
438
460
|
mode: "light",
|
|
439
461
|
colors: {
|
|
@@ -582,7 +604,7 @@ function nameToGradient(name) {
|
|
|
582
604
|
return `linear-gradient(135deg, hsl(${h1}, 65%, 55%), hsl(${h2}, 65%, 45%))`;
|
|
583
605
|
}
|
|
584
606
|
var KNOWN_WALLET_URLS = {
|
|
585
|
-
console: "https://
|
|
607
|
+
console: "https://consolewallet.io",
|
|
586
608
|
loop: "https://loop.5n.app",
|
|
587
609
|
cantor8: "https://cantor8.io",
|
|
588
610
|
bron: "https://bron.dev",
|
|
@@ -630,13 +652,12 @@ function extractSdkQrCode() {
|
|
|
630
652
|
deepLinkUrl = anchors[0].href;
|
|
631
653
|
}
|
|
632
654
|
}
|
|
633
|
-
container.style.display = "none";
|
|
634
655
|
return { svgHtml: svg.outerHTML, deepLinkUrl };
|
|
635
656
|
}
|
|
636
657
|
function removeSdkQrContainer() {
|
|
637
658
|
const container = document.getElementById(SDK_QR_CONTAINER_ID);
|
|
638
659
|
if (container) {
|
|
639
|
-
container.
|
|
660
|
+
container.remove();
|
|
640
661
|
}
|
|
641
662
|
}
|
|
642
663
|
function CloseIcon({ size = 20, color = "currentColor" }) {
|
|
@@ -1871,9 +1892,16 @@ function WalletModal({
|
|
|
1871
1892
|
50% { transform: scale(1.02); }
|
|
1872
1893
|
100% { transform: scale(1); opacity: 1; }
|
|
1873
1894
|
}
|
|
1874
|
-
/* Hide Console SDK's injected QR modal \u2014 we
|
|
1895
|
+
/* Hide Console SDK's injected QR/connector modal \u2014 we extract its
|
|
1896
|
+
content and render in our own modal. Using off-screen positioning
|
|
1897
|
+
instead of display:none so the SDK can fully render its DOM
|
|
1898
|
+
(QR SVG, connector buttons) before we extract them. */
|
|
1875
1899
|
#${SDK_QR_CONTAINER_ID} {
|
|
1876
|
-
|
|
1900
|
+
opacity: 0 !important;
|
|
1901
|
+
pointer-events: none !important;
|
|
1902
|
+
position: fixed !important;
|
|
1903
|
+
top: -9999px !important;
|
|
1904
|
+
left: -9999px !important;
|
|
1877
1905
|
}
|
|
1878
1906
|
` })
|
|
1879
1907
|
]
|
|
@@ -2233,6 +2261,7 @@ exports.truncatePartyId = truncatePartyId;
|
|
|
2233
2261
|
exports.useCantonConnect = usePartyLayer;
|
|
2234
2262
|
exports.useConnect = useConnect;
|
|
2235
2263
|
exports.useDisconnect = useDisconnect;
|
|
2264
|
+
exports.useLedgerApi = useLedgerApi;
|
|
2236
2265
|
exports.usePartyLayer = usePartyLayer;
|
|
2237
2266
|
exports.usePartyLayerContext = usePartyLayerContext;
|
|
2238
2267
|
exports.useRegistryStatus = useRegistryStatus;
|