@temple-digital-group/temple-canton-js 2.1.0-beta.0 → 2.1.1
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 +21 -3
- package/dist/canton/wallet/console.js +6 -1
- package/package.json +1 -1
- package/src/canton/wallet/console.ts +6 -1
package/README.md
CHANGED
|
@@ -14,10 +14,10 @@ Call `initialize()` before using any SDK functions. It sets up the config and op
|
|
|
14
14
|
|
|
15
15
|
### Wallet Adapter
|
|
16
16
|
|
|
17
|
-
For apps using a supported wallet, pass the wallet instance as `WALLET_ADAPTER` or
|
|
17
|
+
For apps using a supported wallet, just pass the wallet instance as `WALLET_ADAPTER` (or to `setWalletAdapter`). The SDK recognizes supported wallets and wraps them automatically with default settings — you don't need to call an adapter factory yourself.
|
|
18
18
|
|
|
19
|
-
- **Loop:** pass the Loop SDK instance directly
|
|
20
|
-
- **Console:** pass the Console wallet instance directly
|
|
19
|
+
- **Loop:** pass the Loop SDK instance directly. Works both in the browser and server-side (Node) — Loop signs locally on the server or delegates to the Loop Wallet UI in the browser.
|
|
20
|
+
- **Console:** **browser only** — pass the Console wallet instance directly. Reads use `getPrimaryAccount()` and `getContracts()`, and commands are submitted through Console's `prepareExecuteAndWait()` (or `prepareExecute()`) — the same Temple Daml command object Loop receives. It can't be used in a server/headless (Node) environment.
|
|
21
21
|
|
|
22
22
|
```javascript
|
|
23
23
|
import { initialize } from "@temple-digital-group/temple-canton-js";
|
|
@@ -38,6 +38,24 @@ import { setWalletAdapter } from "@temple-digital-group/temple-canton-js";
|
|
|
38
38
|
setWalletAdapter(wallet);
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
+
#### Adapter Factories (advanced)
|
|
42
|
+
|
|
43
|
+
You only need the `create*WalletAdapter()` factories when you want to customize how a wallet is wrapped — passing a raw instance (above) already calls them for you with defaults. When you do need custom settings, build the adapter and hand the result to `WALLET_ADAPTER` / `setWalletAdapter`:
|
|
44
|
+
|
|
45
|
+
- `createLoopWalletAdapter(loop)` — normalize a Loop instance (no extra options).
|
|
46
|
+
- `createConsoleWalletAdapter(consoleWallet, options?)` — normalize a Console instance (browser only) with optional overrides:
|
|
47
|
+
- `network` — Console network variant (`CANTON_NETWORK`, `CANTON_NETWORK_TEST`, `CANTON_NETWORK_DEV`); defaults from `NETWORK`.
|
|
48
|
+
- `partyId` — seed a synchronous party id instead of resolving it from `getPrimaryAccount()`.
|
|
49
|
+
- `parties` — explicit read parties (defaults to the active account party).
|
|
50
|
+
- `waitForExecution` — `true` (default) submits via `prepareExecuteAndWait()`; `false` uses `prepareExecute()`.
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
import { setWalletAdapter, createConsoleWalletAdapter } from "@temple-digital-group/temple-canton-js";
|
|
54
|
+
|
|
55
|
+
// Only needed for custom options — otherwise just pass the raw instance.
|
|
56
|
+
setWalletAdapter(createConsoleWalletAdapter(consoleWallet, { network: "mainnet" }));
|
|
57
|
+
```
|
|
58
|
+
|
|
41
59
|
| Key | Required | Description |
|
|
42
60
|
| ---------------- | -------- | ------------------------------------------------- |
|
|
43
61
|
| `API_KEY` | Yes | Temple REST API key |
|
|
@@ -218,7 +218,12 @@ export function createConsoleWalletAdapter(consoleWallet, options = {}) {
|
|
|
218
218
|
const useWait = typeof wallet.prepareExecuteAndWait === "function" &&
|
|
219
219
|
(options.waitForExecution !== false || typeof wallet.prepareExecute !== "function");
|
|
220
220
|
try {
|
|
221
|
-
|
|
221
|
+
const result = await (useWait ? wallet.prepareExecuteAndWait(prepareRequest) : wallet.prepareExecute(prepareRequest));
|
|
222
|
+
// The Console wallet resolves (does not throw) on a successful submit
|
|
223
|
+
// but often returns nothing — it only rejects on failure/user
|
|
224
|
+
// rejection. Normalize a void success into a truthy result so callers
|
|
225
|
+
// don't misread "no return value" as a failure.
|
|
226
|
+
return result ?? { success: true };
|
|
222
227
|
}
|
|
223
228
|
catch (error) {
|
|
224
229
|
throw wrapConsoleSubmitError(error);
|
package/package.json
CHANGED
|
@@ -268,7 +268,12 @@ export function createConsoleWalletAdapter(consoleWallet: unknown, options: Cons
|
|
|
268
268
|
typeof wallet.prepareExecuteAndWait === "function" &&
|
|
269
269
|
(options.waitForExecution !== false || typeof wallet.prepareExecute !== "function");
|
|
270
270
|
try {
|
|
271
|
-
|
|
271
|
+
const result = await (useWait ? wallet.prepareExecuteAndWait!(prepareRequest) : wallet.prepareExecute!(prepareRequest));
|
|
272
|
+
// The Console wallet resolves (does not throw) on a successful submit
|
|
273
|
+
// but often returns nothing — it only rejects on failure/user
|
|
274
|
+
// rejection. Normalize a void success into a truthy result so callers
|
|
275
|
+
// don't misread "no return value" as a failure.
|
|
276
|
+
return result ?? { success: true };
|
|
272
277
|
} catch (error) {
|
|
273
278
|
throw wrapConsoleSubmitError(error);
|
|
274
279
|
}
|