@partylayer/sdk 0.18.2 → 0.19.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/README.md +2 -0
- package/dist/index.d.mts +36 -5
- package/dist/index.d.ts +36 -5
- package/dist/index.js +137 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +131 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -125,6 +125,8 @@ await client.disconnect();
|
|
|
125
125
|
| Cantor8 | devnet, mainnet | submitTransaction, transactionStatus | No | `@partylayer/adapter-cantor8` |
|
|
126
126
|
| Bron | devnet, testnet, mainnet | signMessage, signTransaction | Yes | `@partylayer/adapter-bron` |
|
|
127
127
|
| Nightly | devnet, testnet, mainnet | signMessage, submitTransaction | No | `@partylayer/adapter-nightly` |
|
|
128
|
+
| Cauri Wallet | devnet, mainnet | signMessage, signTransaction, submitTransaction, transactionStatus | No | `@lithiumdigital/cauri-dapp-sdk` |
|
|
129
|
+
| OneSwap V2 Wallet | devnet, mainnet | signMessage, submitTransaction | No | `@oneswap/wallet-cip0103-adapter` |
|
|
128
130
|
| Send | mainnet | signMessage, submitTransaction, transactionStatus | No | `@partylayer/adapter-send` |
|
|
129
131
|
| Walley | mainnet, testnet, devnet | signMessage, submitTransaction, transactionStatus | No | `@k2flabs/walley-dapp-sdk` |
|
|
130
132
|
| WalletConnect | devnet, testnet, mainnet | signMessage, submitTransaction | Yes | `@partylayer/adapter-walletconnect` |
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _partylayer_core from '@partylayer/core';
|
|
2
|
-
import { WalletAdapter, NetworkId, OfficialProviderAdapter, OfficialAdapterFactory, StorageAdapter, CryptoAdapter, TelemetryAdapter, LoggerAdapter, WalletId, Session, SessionId, TransactionHash, TransactionStatus, WalletInfo, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, LedgerApiParams, LedgerApiResult, CIP0103Provider, CapabilityKey, AdapterDetectResult, AdapterContext, AdapterConnectResult, NetworkHosts, PersistedSession } from '@partylayer/core';
|
|
3
|
-
export { AdapterConnectResult, AdapterContext, AdapterDetectResult, AdapterNotRegisteredError, PartyLayerError as CantonConnectError, CapabilityKey, CapabilityNotSupportedError, ENABLEMENT_METRICS, ERROR_METRICS, ErrorCode, InternalError, LedgerApiParams, LedgerApiResult, METRICS, MetricName, MetricsPayload, NetworkHosts, NetworkId, OfficialAdapterFactory, OfficialProviderAdapter, OriginNotAllowedError, PartyId, PartyLayerError, REGISTRY_METRICS, RegistryFetchFailedError, RegistrySchemaInvalidError, RegistryVerificationFailedError, Session, SessionExpiredError, SessionId, SignMessageParams, SignTransactionParams, SignedMessage, SignedTransaction, SubmitTransactionParams, TimeoutError, TransactionStatus, TransportError, TxReceipt, UserRejectedError, WalletAdapter, WalletId, WalletInfo, WalletNotFoundError, WalletNotInstalledError, errorMetricName, isOfficialAdapterFactory, isOfficialProviderAdapter } from '@partylayer/core';
|
|
2
|
+
import { WalletAdapter, NetworkId, OfficialProviderAdapter, OfficialAdapterFactory, StorageAdapter, CryptoAdapter, TelemetryAdapter, LoggerAdapter, WalletId, Session, SessionId, TransactionHash, TransactionStatus, WalletInfo, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, LedgerApiParams, LedgerApiResult, TransferIntent, TransferResult, CIP0103Provider, CapabilityKey, AdapterDetectResult, AdapterContext, AdapterConnectResult, NetworkHosts, PersistedSession } from '@partylayer/core';
|
|
3
|
+
export { AdapterConnectResult, AdapterContext, AdapterDetectResult, AdapterNotRegisteredError, PartyLayerError as CantonConnectError, CapabilityKey, CapabilityNotSupportedError, ENABLEMENT_METRICS, ERROR_METRICS, ErrorCode, InternalError, LedgerApiParams, LedgerApiResult, METRICS, MetricName, MetricsPayload, NetworkHosts, NetworkId, OfficialAdapterFactory, OfficialProviderAdapter, OriginNotAllowedError, PartyId, PartyLayerError, REGISTRY_METRICS, RegistryFetchFailedError, RegistrySchemaInvalidError, RegistryVerificationFailedError, Session, SessionExpiredError, SessionId, SignMessageParams, SignTransactionParams, SignedMessage, SignedTransaction, SubmitTransactionParams, TRANSFER_INTENT_FIELDS, TimeoutError, TokenInstrumentId, TransactionStatus, TransferIntent, TransferResult, TransportError, TxReceipt, UserRejectedError, WalletAdapter, WalletId, WalletInfo, WalletNotFoundError, WalletNotInstalledError, errorMetricName, isOfficialAdapterFactory, isOfficialProviderAdapter, toTransferIntent } from '@partylayer/core';
|
|
4
4
|
import { RegistryClient, RegistryStatus } from '@partylayer/registry-client';
|
|
5
5
|
export { Cip0103StatusForDetection, Cip0103Support, ProviderDetection, ProviderMatcher, RegistryStatus, deriveGenericWalletName, findMatchingWallet, findMatchingWalletInfo, isCip0103Native, matchesProviderDetection } from '@partylayer/registry-client';
|
|
6
6
|
export { CANTON_NETWORKS, CIP0103Account, CIP0103ConnectResult, CIP0103Event, CIP0103EventBus, CIP0103Method, CIP0103Network, CIP0103Provider, CIP0103StatusEvent, CIP0103TxChangedEvent, CIP0103TxStatus, CIP0103_EVENTS, CIP0103_MANDATORY_METHODS, CIP0103_METHODS, DiscoveredProvider, JSON_RPC_ERRORS, PartyLayerProvider, PartyLayerProviderOptions, ProviderRpcError, RPC_ERRORS, createProviderBridge, discoverInjectedProviders, fromCAIP2Network, isCIP0103Provider, isValidCAIP2, toCAIP2Network, waitForProvider } from '@partylayer/provider';
|
|
@@ -298,7 +298,14 @@ interface SessionNetworkMismatchEvent {
|
|
|
298
298
|
interface TxStatusEvent {
|
|
299
299
|
type: 'tx:status';
|
|
300
300
|
sessionId: SessionId;
|
|
301
|
-
|
|
301
|
+
/**
|
|
302
|
+
* The transaction id, when the wallet reported one. Optional for the same
|
|
303
|
+
* reason as `TxReceipt.transactionHash`, which is where it comes from: a
|
|
304
|
+
* wallet with no hash to give produces an event with no id, and saying so
|
|
305
|
+
* beats emitting an invented one. Prefer reading `updateId` off the receipt
|
|
306
|
+
* when you need a ledger identifier.
|
|
307
|
+
*/
|
|
308
|
+
txId?: TransactionHash;
|
|
302
309
|
status: TransactionStatus;
|
|
303
310
|
raw?: unknown;
|
|
304
311
|
}
|
|
@@ -548,6 +555,20 @@ declare class PartyLayerClient {
|
|
|
548
555
|
* Proxy a JSON Ledger API request through the active wallet adapter
|
|
549
556
|
*/
|
|
550
557
|
ledgerApi(params: LedgerApiParams): Promise<LedgerApiResult>;
|
|
558
|
+
/**
|
|
559
|
+
* Request a typed transfer. The application says what it wants; the wallet
|
|
560
|
+
* builds the command, shows the user what they are authorising, obtains their
|
|
561
|
+
* approval, signs, executes, and returns the real update id.
|
|
562
|
+
*
|
|
563
|
+
* The acting party comes from the active session, never from the caller, and
|
|
564
|
+
* the intent is narrowed to the allowlisted fields before any adapter sees it,
|
|
565
|
+
* so no caller-supplied option can reach the wallet.
|
|
566
|
+
*
|
|
567
|
+
* Throws `CapabilityNotSupportedError` when the active wallet does not
|
|
568
|
+
* implement it. Ask first with `session.capabilitiesSnapshot.includes('transfer')`,
|
|
569
|
+
* or require it at connect with `connect({ requiredCapabilities: ['transfer'] })`.
|
|
570
|
+
*/
|
|
571
|
+
requestTransfer(intent: TransferIntent): Promise<TransferResult>;
|
|
551
572
|
/**
|
|
552
573
|
* Subscribe to events
|
|
553
574
|
*/
|
|
@@ -744,6 +765,11 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
|
|
|
744
765
|
private readonly staticMetadata?;
|
|
745
766
|
private readonly mapError?;
|
|
746
767
|
private readonly signMessageBase64;
|
|
768
|
+
/**
|
|
769
|
+
* Which execute verb this wallet turned out to support. Resolved on the first
|
|
770
|
+
* submit and reused, so the wallet is asked at most once.
|
|
771
|
+
*/
|
|
772
|
+
private readonly executeVerb;
|
|
747
773
|
restore?: WalletAdapter['restore'];
|
|
748
774
|
on?: WalletAdapter['on'];
|
|
749
775
|
ledgerApi?: WalletAdapter['ledgerApi'];
|
|
@@ -764,7 +790,7 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
|
|
|
764
790
|
connect(ctx: AdapterContext): Promise<AdapterConnectResult>;
|
|
765
791
|
disconnect(): Promise<void>;
|
|
766
792
|
private signMessageImpl;
|
|
767
|
-
submitTransaction(
|
|
793
|
+
submitTransaction(ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
|
|
768
794
|
/** events: bridge the provider's CIP-0103 `txChanged` push event → `txStatus`. */
|
|
769
795
|
private makeOn;
|
|
770
796
|
/** restore: silent status()/getPrimaryAccount() probe + expiry + party-match. */
|
|
@@ -863,6 +889,11 @@ declare class GenericDiscoveryAdapter implements WalletAdapter {
|
|
|
863
889
|
private networkHosts;
|
|
864
890
|
/** Lazily resolved from `official.provider()` — NOT at construction (SSR-safe). */
|
|
865
891
|
private providerInstance;
|
|
892
|
+
/**
|
|
893
|
+
* Which execute verb this wallet turned out to support. Resolved on the first
|
|
894
|
+
* submit and reused, so the wallet is asked at most once.
|
|
895
|
+
*/
|
|
896
|
+
private readonly executeVerb;
|
|
866
897
|
constructor(args: GenericDiscoveryAdapterArgs);
|
|
867
898
|
/** Whether this bridge resolves its host from `networkHosts` (factory form). */
|
|
868
899
|
usesFactory(): boolean;
|
|
@@ -916,7 +947,7 @@ declare class GenericDiscoveryAdapter implements WalletAdapter {
|
|
|
916
947
|
restore(ctx: AdapterContext, persisted: PersistedSession): Promise<Session | null>;
|
|
917
948
|
disconnect(): Promise<void>;
|
|
918
949
|
signMessage(_ctx: AdapterContext, _session: Session, params: SignMessageParams): Promise<SignedMessage>;
|
|
919
|
-
submitTransaction(
|
|
950
|
+
submitTransaction(ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
|
|
920
951
|
}
|
|
921
952
|
|
|
922
953
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _partylayer_core from '@partylayer/core';
|
|
2
|
-
import { WalletAdapter, NetworkId, OfficialProviderAdapter, OfficialAdapterFactory, StorageAdapter, CryptoAdapter, TelemetryAdapter, LoggerAdapter, WalletId, Session, SessionId, TransactionHash, TransactionStatus, WalletInfo, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, LedgerApiParams, LedgerApiResult, CIP0103Provider, CapabilityKey, AdapterDetectResult, AdapterContext, AdapterConnectResult, NetworkHosts, PersistedSession } from '@partylayer/core';
|
|
3
|
-
export { AdapterConnectResult, AdapterContext, AdapterDetectResult, AdapterNotRegisteredError, PartyLayerError as CantonConnectError, CapabilityKey, CapabilityNotSupportedError, ENABLEMENT_METRICS, ERROR_METRICS, ErrorCode, InternalError, LedgerApiParams, LedgerApiResult, METRICS, MetricName, MetricsPayload, NetworkHosts, NetworkId, OfficialAdapterFactory, OfficialProviderAdapter, OriginNotAllowedError, PartyId, PartyLayerError, REGISTRY_METRICS, RegistryFetchFailedError, RegistrySchemaInvalidError, RegistryVerificationFailedError, Session, SessionExpiredError, SessionId, SignMessageParams, SignTransactionParams, SignedMessage, SignedTransaction, SubmitTransactionParams, TimeoutError, TransactionStatus, TransportError, TxReceipt, UserRejectedError, WalletAdapter, WalletId, WalletInfo, WalletNotFoundError, WalletNotInstalledError, errorMetricName, isOfficialAdapterFactory, isOfficialProviderAdapter } from '@partylayer/core';
|
|
2
|
+
import { WalletAdapter, NetworkId, OfficialProviderAdapter, OfficialAdapterFactory, StorageAdapter, CryptoAdapter, TelemetryAdapter, LoggerAdapter, WalletId, Session, SessionId, TransactionHash, TransactionStatus, WalletInfo, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, LedgerApiParams, LedgerApiResult, TransferIntent, TransferResult, CIP0103Provider, CapabilityKey, AdapterDetectResult, AdapterContext, AdapterConnectResult, NetworkHosts, PersistedSession } from '@partylayer/core';
|
|
3
|
+
export { AdapterConnectResult, AdapterContext, AdapterDetectResult, AdapterNotRegisteredError, PartyLayerError as CantonConnectError, CapabilityKey, CapabilityNotSupportedError, ENABLEMENT_METRICS, ERROR_METRICS, ErrorCode, InternalError, LedgerApiParams, LedgerApiResult, METRICS, MetricName, MetricsPayload, NetworkHosts, NetworkId, OfficialAdapterFactory, OfficialProviderAdapter, OriginNotAllowedError, PartyId, PartyLayerError, REGISTRY_METRICS, RegistryFetchFailedError, RegistrySchemaInvalidError, RegistryVerificationFailedError, Session, SessionExpiredError, SessionId, SignMessageParams, SignTransactionParams, SignedMessage, SignedTransaction, SubmitTransactionParams, TRANSFER_INTENT_FIELDS, TimeoutError, TokenInstrumentId, TransactionStatus, TransferIntent, TransferResult, TransportError, TxReceipt, UserRejectedError, WalletAdapter, WalletId, WalletInfo, WalletNotFoundError, WalletNotInstalledError, errorMetricName, isOfficialAdapterFactory, isOfficialProviderAdapter, toTransferIntent } from '@partylayer/core';
|
|
4
4
|
import { RegistryClient, RegistryStatus } from '@partylayer/registry-client';
|
|
5
5
|
export { Cip0103StatusForDetection, Cip0103Support, ProviderDetection, ProviderMatcher, RegistryStatus, deriveGenericWalletName, findMatchingWallet, findMatchingWalletInfo, isCip0103Native, matchesProviderDetection } from '@partylayer/registry-client';
|
|
6
6
|
export { CANTON_NETWORKS, CIP0103Account, CIP0103ConnectResult, CIP0103Event, CIP0103EventBus, CIP0103Method, CIP0103Network, CIP0103Provider, CIP0103StatusEvent, CIP0103TxChangedEvent, CIP0103TxStatus, CIP0103_EVENTS, CIP0103_MANDATORY_METHODS, CIP0103_METHODS, DiscoveredProvider, JSON_RPC_ERRORS, PartyLayerProvider, PartyLayerProviderOptions, ProviderRpcError, RPC_ERRORS, createProviderBridge, discoverInjectedProviders, fromCAIP2Network, isCIP0103Provider, isValidCAIP2, toCAIP2Network, waitForProvider } from '@partylayer/provider';
|
|
@@ -298,7 +298,14 @@ interface SessionNetworkMismatchEvent {
|
|
|
298
298
|
interface TxStatusEvent {
|
|
299
299
|
type: 'tx:status';
|
|
300
300
|
sessionId: SessionId;
|
|
301
|
-
|
|
301
|
+
/**
|
|
302
|
+
* The transaction id, when the wallet reported one. Optional for the same
|
|
303
|
+
* reason as `TxReceipt.transactionHash`, which is where it comes from: a
|
|
304
|
+
* wallet with no hash to give produces an event with no id, and saying so
|
|
305
|
+
* beats emitting an invented one. Prefer reading `updateId` off the receipt
|
|
306
|
+
* when you need a ledger identifier.
|
|
307
|
+
*/
|
|
308
|
+
txId?: TransactionHash;
|
|
302
309
|
status: TransactionStatus;
|
|
303
310
|
raw?: unknown;
|
|
304
311
|
}
|
|
@@ -548,6 +555,20 @@ declare class PartyLayerClient {
|
|
|
548
555
|
* Proxy a JSON Ledger API request through the active wallet adapter
|
|
549
556
|
*/
|
|
550
557
|
ledgerApi(params: LedgerApiParams): Promise<LedgerApiResult>;
|
|
558
|
+
/**
|
|
559
|
+
* Request a typed transfer. The application says what it wants; the wallet
|
|
560
|
+
* builds the command, shows the user what they are authorising, obtains their
|
|
561
|
+
* approval, signs, executes, and returns the real update id.
|
|
562
|
+
*
|
|
563
|
+
* The acting party comes from the active session, never from the caller, and
|
|
564
|
+
* the intent is narrowed to the allowlisted fields before any adapter sees it,
|
|
565
|
+
* so no caller-supplied option can reach the wallet.
|
|
566
|
+
*
|
|
567
|
+
* Throws `CapabilityNotSupportedError` when the active wallet does not
|
|
568
|
+
* implement it. Ask first with `session.capabilitiesSnapshot.includes('transfer')`,
|
|
569
|
+
* or require it at connect with `connect({ requiredCapabilities: ['transfer'] })`.
|
|
570
|
+
*/
|
|
571
|
+
requestTransfer(intent: TransferIntent): Promise<TransferResult>;
|
|
551
572
|
/**
|
|
552
573
|
* Subscribe to events
|
|
553
574
|
*/
|
|
@@ -744,6 +765,11 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
|
|
|
744
765
|
private readonly staticMetadata?;
|
|
745
766
|
private readonly mapError?;
|
|
746
767
|
private readonly signMessageBase64;
|
|
768
|
+
/**
|
|
769
|
+
* Which execute verb this wallet turned out to support. Resolved on the first
|
|
770
|
+
* submit and reused, so the wallet is asked at most once.
|
|
771
|
+
*/
|
|
772
|
+
private readonly executeVerb;
|
|
747
773
|
restore?: WalletAdapter['restore'];
|
|
748
774
|
on?: WalletAdapter['on'];
|
|
749
775
|
ledgerApi?: WalletAdapter['ledgerApi'];
|
|
@@ -764,7 +790,7 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
|
|
|
764
790
|
connect(ctx: AdapterContext): Promise<AdapterConnectResult>;
|
|
765
791
|
disconnect(): Promise<void>;
|
|
766
792
|
private signMessageImpl;
|
|
767
|
-
submitTransaction(
|
|
793
|
+
submitTransaction(ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
|
|
768
794
|
/** events: bridge the provider's CIP-0103 `txChanged` push event → `txStatus`. */
|
|
769
795
|
private makeOn;
|
|
770
796
|
/** restore: silent status()/getPrimaryAccount() probe + expiry + party-match. */
|
|
@@ -863,6 +889,11 @@ declare class GenericDiscoveryAdapter implements WalletAdapter {
|
|
|
863
889
|
private networkHosts;
|
|
864
890
|
/** Lazily resolved from `official.provider()` — NOT at construction (SSR-safe). */
|
|
865
891
|
private providerInstance;
|
|
892
|
+
/**
|
|
893
|
+
* Which execute verb this wallet turned out to support. Resolved on the first
|
|
894
|
+
* submit and reused, so the wallet is asked at most once.
|
|
895
|
+
*/
|
|
896
|
+
private readonly executeVerb;
|
|
866
897
|
constructor(args: GenericDiscoveryAdapterArgs);
|
|
867
898
|
/** Whether this bridge resolves its host from `networkHosts` (factory form). */
|
|
868
899
|
usesFactory(): boolean;
|
|
@@ -916,7 +947,7 @@ declare class GenericDiscoveryAdapter implements WalletAdapter {
|
|
|
916
947
|
restore(ctx: AdapterContext, persisted: PersistedSession): Promise<Session | null>;
|
|
917
948
|
disconnect(): Promise<void>;
|
|
918
949
|
signMessage(_ctx: AdapterContext, _session: Session, params: SignMessageParams): Promise<SignedMessage>;
|
|
919
|
-
submitTransaction(
|
|
950
|
+
submitTransaction(ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
|
|
920
951
|
}
|
|
921
952
|
|
|
922
953
|
/**
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,64 @@ var adapterSend = require('@partylayer/adapter-send');
|
|
|
11
11
|
var adapterBron = require('@partylayer/adapter-bron');
|
|
12
12
|
|
|
13
13
|
// src/client.ts
|
|
14
|
+
var UNSUPPORTED_METHOD = 4200;
|
|
15
|
+
var METHOD_NOT_FOUND = -32601;
|
|
16
|
+
function isUnsupportedMethod(err) {
|
|
17
|
+
const code = err?.code;
|
|
18
|
+
return code === UNSUPPORTED_METHOD || code === METHOD_NOT_FOUND;
|
|
19
|
+
}
|
|
20
|
+
function receiptFromExecutedTx(result) {
|
|
21
|
+
const tx = result?.tx;
|
|
22
|
+
const updateId = tx?.payload?.updateId;
|
|
23
|
+
if (typeof updateId !== "string" || updateId.length === 0) return null;
|
|
24
|
+
return {
|
|
25
|
+
transactionHash: core.toTransactionHash(updateId),
|
|
26
|
+
submittedAt: Date.now(),
|
|
27
|
+
commandId: typeof tx?.commandId === "string" ? tx.commandId : void 0,
|
|
28
|
+
updateId
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function reportOnce(state, walletId, detail, logger) {
|
|
32
|
+
if (state.logged) return;
|
|
33
|
+
state.logged = true;
|
|
34
|
+
logger?.warn(
|
|
35
|
+
`[PartyLayer] ${walletId}: ${detail} Receipts from it carry no real updateId.`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
async function submitViaPrepareExecute(provider, params, opts) {
|
|
39
|
+
const rpcParams = params;
|
|
40
|
+
const { walletId, state, logger } = opts;
|
|
41
|
+
if (state.verb !== "plain") {
|
|
42
|
+
try {
|
|
43
|
+
const result = await provider.request({
|
|
44
|
+
method: "prepareExecuteAndWait",
|
|
45
|
+
params: rpcParams
|
|
46
|
+
});
|
|
47
|
+
state.verb = "awaited";
|
|
48
|
+
const receipt = receiptFromExecutedTx(result);
|
|
49
|
+
if (receipt) return receipt;
|
|
50
|
+
reportOnce(
|
|
51
|
+
state,
|
|
52
|
+
walletId,
|
|
53
|
+
"prepareExecuteAndWait returned no updateId.",
|
|
54
|
+
logger
|
|
55
|
+
);
|
|
56
|
+
return result;
|
|
57
|
+
} catch (err) {
|
|
58
|
+
if (!isUnsupportedMethod(err)) throw err;
|
|
59
|
+
state.verb = "plain";
|
|
60
|
+
reportOnce(
|
|
61
|
+
state,
|
|
62
|
+
walletId,
|
|
63
|
+
"has no prepareExecuteAndWait; using prepareExecute, which the CIP-0103 types return as null.",
|
|
64
|
+
logger
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return provider.request({ method: "prepareExecute", params: rpcParams });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/announce-adapter.ts
|
|
14
72
|
var ANNOUNCED_WALLET_ID_PREFIX = "browser:ext:";
|
|
15
73
|
function announcedWalletId(announceId) {
|
|
16
74
|
return core.toWalletId(`${ANNOUNCED_WALLET_ID_PREFIX}${announceId}`);
|
|
@@ -44,6 +102,11 @@ var GenericAnnounceAdapter = class {
|
|
|
44
102
|
staticMetadata;
|
|
45
103
|
mapError;
|
|
46
104
|
signMessageBase64;
|
|
105
|
+
/**
|
|
106
|
+
* Which execute verb this wallet turned out to support. Resolved on the first
|
|
107
|
+
* submit and reused, so the wallet is asked at most once.
|
|
108
|
+
*/
|
|
109
|
+
executeVerb = {};
|
|
47
110
|
// Optional WalletAdapter surface — assigned in the ctor ONLY when configured,
|
|
48
111
|
// so `getCapabilities()` and `'x' in adapter` feature-detection stay honest.
|
|
49
112
|
restore;
|
|
@@ -139,11 +202,12 @@ var GenericAnnounceAdapter = class {
|
|
|
139
202
|
};
|
|
140
203
|
});
|
|
141
204
|
}
|
|
142
|
-
async submitTransaction(
|
|
205
|
+
async submitTransaction(ctx, _session, params) {
|
|
143
206
|
return this.guarded(
|
|
144
|
-
() => this.provider
|
|
145
|
-
|
|
146
|
-
|
|
207
|
+
() => submitViaPrepareExecute(this.provider, params, {
|
|
208
|
+
walletId: String(this.walletId),
|
|
209
|
+
state: this.executeVerb,
|
|
210
|
+
logger: ctx.logger
|
|
147
211
|
})
|
|
148
212
|
);
|
|
149
213
|
}
|
|
@@ -256,6 +320,11 @@ var GenericDiscoveryAdapter = class {
|
|
|
256
320
|
networkHosts;
|
|
257
321
|
/** Lazily resolved from `official.provider()` — NOT at construction (SSR-safe). */
|
|
258
322
|
providerInstance = null;
|
|
323
|
+
/**
|
|
324
|
+
* Which execute verb this wallet turned out to support. Resolved on the first
|
|
325
|
+
* submit and reused, so the wallet is asked at most once.
|
|
326
|
+
*/
|
|
327
|
+
executeVerb = {};
|
|
259
328
|
constructor(args) {
|
|
260
329
|
if (args.official) {
|
|
261
330
|
this.official = args.official;
|
|
@@ -423,10 +492,11 @@ var GenericDiscoveryAdapter = class {
|
|
|
423
492
|
params: { message: params.message }
|
|
424
493
|
});
|
|
425
494
|
}
|
|
426
|
-
async submitTransaction(
|
|
427
|
-
return this.provider
|
|
428
|
-
|
|
429
|
-
|
|
495
|
+
async submitTransaction(ctx, _session, params) {
|
|
496
|
+
return submitViaPrepareExecute(this.provider, params, {
|
|
497
|
+
walletId: String(this.walletId),
|
|
498
|
+
state: this.executeVerb,
|
|
499
|
+
logger: ctx.logger
|
|
430
500
|
});
|
|
431
501
|
}
|
|
432
502
|
};
|
|
@@ -1037,7 +1107,8 @@ var PartyLayerClient = class {
|
|
|
1037
1107
|
);
|
|
1038
1108
|
}
|
|
1039
1109
|
if (!filter?.includeExperimental) {
|
|
1040
|
-
|
|
1110
|
+
const channel = this.config.channel || "stable";
|
|
1111
|
+
return registryWallets.filter((walletInfo) => walletInfo.channel === channel);
|
|
1041
1112
|
}
|
|
1042
1113
|
return registryWallets;
|
|
1043
1114
|
}
|
|
@@ -1686,6 +1757,55 @@ var PartyLayerClient = class {
|
|
|
1686
1757
|
throw error;
|
|
1687
1758
|
}
|
|
1688
1759
|
}
|
|
1760
|
+
/**
|
|
1761
|
+
* Request a typed transfer. The application says what it wants; the wallet
|
|
1762
|
+
* builds the command, shows the user what they are authorising, obtains their
|
|
1763
|
+
* approval, signs, executes, and returns the real update id.
|
|
1764
|
+
*
|
|
1765
|
+
* The acting party comes from the active session, never from the caller, and
|
|
1766
|
+
* the intent is narrowed to the allowlisted fields before any adapter sees it,
|
|
1767
|
+
* so no caller-supplied option can reach the wallet.
|
|
1768
|
+
*
|
|
1769
|
+
* Throws `CapabilityNotSupportedError` when the active wallet does not
|
|
1770
|
+
* implement it. Ask first with `session.capabilitiesSnapshot.includes('transfer')`,
|
|
1771
|
+
* or require it at connect with `connect({ requiredCapabilities: ['transfer'] })`.
|
|
1772
|
+
*/
|
|
1773
|
+
async requestTransfer(intent) {
|
|
1774
|
+
const session = await this.getActiveSession();
|
|
1775
|
+
if (!session) {
|
|
1776
|
+
throw new Error("No active session");
|
|
1777
|
+
}
|
|
1778
|
+
const adapter = this.adapters.get(session.walletId);
|
|
1779
|
+
if (!adapter || !adapter.requestTransfer) {
|
|
1780
|
+
throw new core.CapabilityNotSupportedError(
|
|
1781
|
+
session.walletId,
|
|
1782
|
+
"transfer"
|
|
1783
|
+
);
|
|
1784
|
+
}
|
|
1785
|
+
const safeIntent = core.toTransferIntent(intent);
|
|
1786
|
+
const correlationId = newCorrelationId();
|
|
1787
|
+
this.log("debug", "requestTransfer:start", "requestTransfer", {}, correlationId);
|
|
1788
|
+
try {
|
|
1789
|
+
this.assertNetworkOk(session);
|
|
1790
|
+
const ctx = this.createAdapterContext();
|
|
1791
|
+
const result = await adapter.requestTransfer(ctx, session, safeIntent);
|
|
1792
|
+
this.emit("tx:status", {
|
|
1793
|
+
type: "tx:status",
|
|
1794
|
+
sessionId: session.sessionId,
|
|
1795
|
+
txId: result.updateId,
|
|
1796
|
+
status: "committed",
|
|
1797
|
+
raw: result
|
|
1798
|
+
}, correlationId);
|
|
1799
|
+
return result;
|
|
1800
|
+
} catch (err) {
|
|
1801
|
+
const error = core.mapUnknownErrorToPartyLayerError(err, {
|
|
1802
|
+
phase: "requestTransfer",
|
|
1803
|
+
walletId: String(session.walletId)
|
|
1804
|
+
});
|
|
1805
|
+
this.emit("error", { type: "error", error }, correlationId);
|
|
1806
|
+
throw error;
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1689
1809
|
/**
|
|
1690
1810
|
* Subscribe to events
|
|
1691
1811
|
*/
|
|
@@ -2046,6 +2166,10 @@ Object.defineProperty(exports, "SessionExpiredError", {
|
|
|
2046
2166
|
enumerable: true,
|
|
2047
2167
|
get: function () { return core.SessionExpiredError; }
|
|
2048
2168
|
});
|
|
2169
|
+
Object.defineProperty(exports, "TRANSFER_INTENT_FIELDS", {
|
|
2170
|
+
enumerable: true,
|
|
2171
|
+
get: function () { return core.TRANSFER_INTENT_FIELDS; }
|
|
2172
|
+
});
|
|
2049
2173
|
Object.defineProperty(exports, "TimeoutError", {
|
|
2050
2174
|
enumerable: true,
|
|
2051
2175
|
get: function () { return core.TimeoutError; }
|
|
@@ -2078,6 +2202,10 @@ Object.defineProperty(exports, "isOfficialProviderAdapter", {
|
|
|
2078
2202
|
enumerable: true,
|
|
2079
2203
|
get: function () { return core.isOfficialProviderAdapter; }
|
|
2080
2204
|
});
|
|
2205
|
+
Object.defineProperty(exports, "toTransferIntent", {
|
|
2206
|
+
enumerable: true,
|
|
2207
|
+
get: function () { return core.toTransferIntent; }
|
|
2208
|
+
});
|
|
2081
2209
|
Object.defineProperty(exports, "deriveGenericWalletName", {
|
|
2082
2210
|
enumerable: true,
|
|
2083
2211
|
get: function () { return registryClient.deriveGenericWalletName; }
|