@partylayer/adapter-cantor8 0.2.20 → 0.3.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 CHANGED
@@ -1,97 +1,74 @@
1
1
  import * as _partylayer_core from '@partylayer/core';
2
- import { ConnectRequest, ConnectResponse, SignRequest, SignResponse, JobStatus, WalletAdapter, CapabilityKey, AdapterDetectResult, AdapterContext, AdapterConnectResult, SignMessageParams, SignTransactionParams } from '@partylayer/core';
2
+ import { WalletAdapter, CapabilityKey, AdapterDetectResult, AdapterContext, AdapterConnectResult, Session, SignMessageParams, SignedMessage, SubmitTransactionParams, TxReceipt, AdapterEventName } from '@partylayer/core';
3
3
 
4
4
  /**
5
- * Cantor8 Vendor Integration Module
6
- *
7
- * This module abstracts vendor-specific endpoints and can be swapped
8
- * without breaking the adapter API.
9
- *
10
- * References:
11
- * - Cantor8 ecosystem: https://www.canton.network/ecosystem/cantor8
12
- * - Cantor8 site: https://cantor8.tech/about
5
+ * The shape `submitTransaction` expects in `params.signedTx`: the Cantor8 SDK's
6
+ * `signAndExecute` input. The caller owns this shape (passthrough).
13
7
  */
14
-
15
- /**
16
- * Vendor configuration
17
- */
18
- interface Cantor8VendorConfig {
19
- /** Deep link scheme (e.g., "cantor8") */
20
- deepLinkScheme?: string;
21
- /** Universal link base URL (e.g., "https://app.cantor8.tech") */
22
- universalLinkBase?: string;
23
- /** Connect endpoint path */
24
- connectEndpoint?: string;
25
- /** Sign endpoint path */
26
- signEndpoint?: string;
27
- /** Job status endpoint path (for async approvals) */
28
- statusEndpoint?: string;
29
- /** Redirect URI for callbacks */
30
- redirectUri?: string;
8
+ interface Cantor8SubmitPayload {
9
+ note?: string;
10
+ partyId: string;
11
+ commandId: string;
12
+ commandsJson: string;
13
+ disclosedContracts?: string;
31
14
  }
32
15
  /**
33
- * Vendor module interface
34
- *
35
- * Implementations can be swapped without changing adapter code.
16
+ * Cantor8 adapter configuration.
36
17
  */
37
- interface Cantor8VendorModule {
38
- /**
39
- * Create connect URL
40
- */
41
- createConnectUrl(request: ConnectRequest, config: Cantor8VendorConfig): string;
42
- /**
43
- * Parse connect callback
44
- */
45
- parseConnectCallback(callbackData: unknown, expectedState: string): ConnectResponse;
46
- /**
47
- * Create sign URL
48
- */
49
- createSignUrl(request: SignRequest, config: Cantor8VendorConfig): string;
50
- /**
51
- * Parse sign callback
52
- */
53
- parseSignCallback(callbackData: unknown, expectedState: string): SignResponse;
18
+ interface Cantor8AdapterConfig {
19
+ /** dApp URL passed to the Cantor8 SDK popup handshake. Defaults to `ctx.origin`. */
20
+ dappUrl?: string;
54
21
  /**
55
- * Poll job status (optional, for async approvals)
22
+ * How long `detectInstalled()` waits for the wallet's `c8#provider_discovery`
23
+ * announcement before reporting not-detected. Default 300ms.
56
24
  */
57
- pollJobStatus?(jobId: string, statusUrl: string, timeoutMs: number): Promise<JobStatus>;
58
- }
59
-
60
- /**
61
- * Cantor8 adapter configuration
62
- */
63
- interface Cantor8AdapterConfig {
64
- /** Vendor module (defaults to stub) */
65
- vendorModule?: Cantor8VendorModule;
66
- /** Vendor configuration */
67
- vendorConfig?: Cantor8VendorConfig;
68
- /** Use mock transport in development */
69
- useMockTransport?: boolean;
25
+ detectTimeoutMs?: number;
70
26
  }
71
27
  /**
72
- * Cantor8 Wallet Adapter
28
+ * Cantor8 Wallet Adapter.
73
29
  */
74
30
  declare class Cantor8Adapter implements WalletAdapter {
75
31
  readonly walletId: _partylayer_core.WalletId;
76
32
  readonly name = "Cantor8";
77
- private vendorModule;
78
- private vendorConfig;
79
- private transport;
33
+ private readonly config;
34
+ private provider;
80
35
  constructor(config?: Cantor8AdapterConfig);
81
36
  getCapabilities(): CapabilityKey[];
37
+ /** The SDK supports devnet and mainnet only; anything else fails at connect. */
38
+ private mapNetwork;
82
39
  detectInstalled(): Promise<AdapterDetectResult>;
83
- connect(ctx: AdapterContext, opts?: {
40
+ connect(ctx: AdapterContext, _opts?: {
84
41
  timeoutMs?: number;
85
- partyId?: _partylayer_core.PartyId;
86
42
  }): Promise<AdapterConnectResult>;
87
- disconnect(_ctx: AdapterContext, _session: _partylayer_core.Session): Promise<void>;
88
- restore(_ctx: AdapterContext, persisted: _partylayer_core.PersistedSession): Promise<_partylayer_core.Session | null>;
89
- signMessage(ctx: AdapterContext, session: _partylayer_core.Session, params: SignMessageParams): Promise<_partylayer_core.SignedMessage>;
90
- signTransaction(ctx: AdapterContext, session: _partylayer_core.Session, params: SignTransactionParams): Promise<_partylayer_core.SignedTransaction>;
43
+ disconnect(_ctx: AdapterContext, _session: Session): Promise<void>;
44
+ /**
45
+ * Cantor8 has NO arbitrary-message signing. Per the honesty rule: do not
46
+ * simulate it, do not route it through `signAndExecute` (which is for
47
+ * transactions), and do not silently succeed. Fail with the typed capability
48
+ * error. `signMessage` is also absent from `getCapabilities()`, so the SDK's
49
+ * capability guard blocks it first; this is the belt-and-suspenders backstop.
50
+ */
51
+ signMessage(_ctx: AdapterContext, _session: Session, _params: SignMessageParams): Promise<SignedMessage>;
52
+ /**
53
+ * Submit a transaction through the SDK's `signAndExecute` (sign + execute
54
+ * fused; the wallet has no separate sign step). `params.signedTx` is passed
55
+ * through: the caller owns its shape, which must be a {@link Cantor8SubmitPayload}.
56
+ *
57
+ * The SDK's `signAndExecute` resolves with no id; Cantor8 delivers the
58
+ * on-ledger txId and status asynchronously via the `txChanged` event (surfaced
59
+ * through `on('txStatus')`). The receipt is therefore keyed on the
60
+ * caller-supplied `commandId`; the confirmed ledger id arrives on the event
61
+ * stream. A live run against the real wallet is required to confirm
62
+ * end-to-end execution.
63
+ */
64
+ submitTransaction(_ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
91
65
  /**
92
- * Generate random state nonce
66
+ * Forward the wallet's transaction-status stream. Cantor8 emits `txChanged`
67
+ * ({ txId, status }); PartyLayer surfaces this as the `events` capability under
68
+ * the `txStatus` event. Any other event name is a no-op. Returns an
69
+ * unsubscribe function.
93
70
  */
94
- private generateState;
71
+ on(event: AdapterEventName, handler: (payload: unknown) => void): () => void;
95
72
  }
96
73
 
97
- export { Cantor8Adapter, type Cantor8AdapterConfig };
74
+ export { Cantor8Adapter, type Cantor8AdapterConfig, type Cantor8SubmitPayload };
package/dist/index.d.ts CHANGED
@@ -1,97 +1,74 @@
1
1
  import * as _partylayer_core from '@partylayer/core';
2
- import { ConnectRequest, ConnectResponse, SignRequest, SignResponse, JobStatus, WalletAdapter, CapabilityKey, AdapterDetectResult, AdapterContext, AdapterConnectResult, SignMessageParams, SignTransactionParams } from '@partylayer/core';
2
+ import { WalletAdapter, CapabilityKey, AdapterDetectResult, AdapterContext, AdapterConnectResult, Session, SignMessageParams, SignedMessage, SubmitTransactionParams, TxReceipt, AdapterEventName } from '@partylayer/core';
3
3
 
4
4
  /**
5
- * Cantor8 Vendor Integration Module
6
- *
7
- * This module abstracts vendor-specific endpoints and can be swapped
8
- * without breaking the adapter API.
9
- *
10
- * References:
11
- * - Cantor8 ecosystem: https://www.canton.network/ecosystem/cantor8
12
- * - Cantor8 site: https://cantor8.tech/about
5
+ * The shape `submitTransaction` expects in `params.signedTx`: the Cantor8 SDK's
6
+ * `signAndExecute` input. The caller owns this shape (passthrough).
13
7
  */
14
-
15
- /**
16
- * Vendor configuration
17
- */
18
- interface Cantor8VendorConfig {
19
- /** Deep link scheme (e.g., "cantor8") */
20
- deepLinkScheme?: string;
21
- /** Universal link base URL (e.g., "https://app.cantor8.tech") */
22
- universalLinkBase?: string;
23
- /** Connect endpoint path */
24
- connectEndpoint?: string;
25
- /** Sign endpoint path */
26
- signEndpoint?: string;
27
- /** Job status endpoint path (for async approvals) */
28
- statusEndpoint?: string;
29
- /** Redirect URI for callbacks */
30
- redirectUri?: string;
8
+ interface Cantor8SubmitPayload {
9
+ note?: string;
10
+ partyId: string;
11
+ commandId: string;
12
+ commandsJson: string;
13
+ disclosedContracts?: string;
31
14
  }
32
15
  /**
33
- * Vendor module interface
34
- *
35
- * Implementations can be swapped without changing adapter code.
16
+ * Cantor8 adapter configuration.
36
17
  */
37
- interface Cantor8VendorModule {
38
- /**
39
- * Create connect URL
40
- */
41
- createConnectUrl(request: ConnectRequest, config: Cantor8VendorConfig): string;
42
- /**
43
- * Parse connect callback
44
- */
45
- parseConnectCallback(callbackData: unknown, expectedState: string): ConnectResponse;
46
- /**
47
- * Create sign URL
48
- */
49
- createSignUrl(request: SignRequest, config: Cantor8VendorConfig): string;
50
- /**
51
- * Parse sign callback
52
- */
53
- parseSignCallback(callbackData: unknown, expectedState: string): SignResponse;
18
+ interface Cantor8AdapterConfig {
19
+ /** dApp URL passed to the Cantor8 SDK popup handshake. Defaults to `ctx.origin`. */
20
+ dappUrl?: string;
54
21
  /**
55
- * Poll job status (optional, for async approvals)
22
+ * How long `detectInstalled()` waits for the wallet's `c8#provider_discovery`
23
+ * announcement before reporting not-detected. Default 300ms.
56
24
  */
57
- pollJobStatus?(jobId: string, statusUrl: string, timeoutMs: number): Promise<JobStatus>;
58
- }
59
-
60
- /**
61
- * Cantor8 adapter configuration
62
- */
63
- interface Cantor8AdapterConfig {
64
- /** Vendor module (defaults to stub) */
65
- vendorModule?: Cantor8VendorModule;
66
- /** Vendor configuration */
67
- vendorConfig?: Cantor8VendorConfig;
68
- /** Use mock transport in development */
69
- useMockTransport?: boolean;
25
+ detectTimeoutMs?: number;
70
26
  }
71
27
  /**
72
- * Cantor8 Wallet Adapter
28
+ * Cantor8 Wallet Adapter.
73
29
  */
74
30
  declare class Cantor8Adapter implements WalletAdapter {
75
31
  readonly walletId: _partylayer_core.WalletId;
76
32
  readonly name = "Cantor8";
77
- private vendorModule;
78
- private vendorConfig;
79
- private transport;
33
+ private readonly config;
34
+ private provider;
80
35
  constructor(config?: Cantor8AdapterConfig);
81
36
  getCapabilities(): CapabilityKey[];
37
+ /** The SDK supports devnet and mainnet only; anything else fails at connect. */
38
+ private mapNetwork;
82
39
  detectInstalled(): Promise<AdapterDetectResult>;
83
- connect(ctx: AdapterContext, opts?: {
40
+ connect(ctx: AdapterContext, _opts?: {
84
41
  timeoutMs?: number;
85
- partyId?: _partylayer_core.PartyId;
86
42
  }): Promise<AdapterConnectResult>;
87
- disconnect(_ctx: AdapterContext, _session: _partylayer_core.Session): Promise<void>;
88
- restore(_ctx: AdapterContext, persisted: _partylayer_core.PersistedSession): Promise<_partylayer_core.Session | null>;
89
- signMessage(ctx: AdapterContext, session: _partylayer_core.Session, params: SignMessageParams): Promise<_partylayer_core.SignedMessage>;
90
- signTransaction(ctx: AdapterContext, session: _partylayer_core.Session, params: SignTransactionParams): Promise<_partylayer_core.SignedTransaction>;
43
+ disconnect(_ctx: AdapterContext, _session: Session): Promise<void>;
44
+ /**
45
+ * Cantor8 has NO arbitrary-message signing. Per the honesty rule: do not
46
+ * simulate it, do not route it through `signAndExecute` (which is for
47
+ * transactions), and do not silently succeed. Fail with the typed capability
48
+ * error. `signMessage` is also absent from `getCapabilities()`, so the SDK's
49
+ * capability guard blocks it first; this is the belt-and-suspenders backstop.
50
+ */
51
+ signMessage(_ctx: AdapterContext, _session: Session, _params: SignMessageParams): Promise<SignedMessage>;
52
+ /**
53
+ * Submit a transaction through the SDK's `signAndExecute` (sign + execute
54
+ * fused; the wallet has no separate sign step). `params.signedTx` is passed
55
+ * through: the caller owns its shape, which must be a {@link Cantor8SubmitPayload}.
56
+ *
57
+ * The SDK's `signAndExecute` resolves with no id; Cantor8 delivers the
58
+ * on-ledger txId and status asynchronously via the `txChanged` event (surfaced
59
+ * through `on('txStatus')`). The receipt is therefore keyed on the
60
+ * caller-supplied `commandId`; the confirmed ledger id arrives on the event
61
+ * stream. A live run against the real wallet is required to confirm
62
+ * end-to-end execution.
63
+ */
64
+ submitTransaction(_ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
91
65
  /**
92
- * Generate random state nonce
66
+ * Forward the wallet's transaction-status stream. Cantor8 emits `txChanged`
67
+ * ({ txId, status }); PartyLayer surfaces this as the `events` capability under
68
+ * the `txStatus` event. Any other event name is a no-op. Returns an
69
+ * unsubscribe function.
93
70
  */
94
- private generateState;
71
+ on(event: AdapterEventName, handler: (payload: unknown) => void): () => void;
95
72
  }
96
73
 
97
- export { Cantor8Adapter, type Cantor8AdapterConfig };
74
+ export { Cantor8Adapter, type Cantor8AdapterConfig, type Cantor8SubmitPayload };