@temple-digital-group/temple-canton-js 2.0.2 → 2.0.3-beta.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.
Files changed (38) hide show
  1. package/README.md +457 -457
  2. package/index.js +15 -15
  3. package/package.json +50 -49
  4. package/src/api/config.d.ts +20 -20
  5. package/src/api/index.ts +322 -322
  6. package/src/api/tokenStore.ts +30 -30
  7. package/src/api/types.ts +196 -196
  8. package/src/auth0/index.d.ts +1 -1
  9. package/src/auth0/index.js +50 -50
  10. package/src/canton/deposits.ts +563 -563
  11. package/src/canton/helpers.ts +266 -266
  12. package/src/canton/index.d.ts +41 -41
  13. package/src/canton/index.js +3301 -3472
  14. package/src/canton/instrumentCatalog.d.ts +7 -7
  15. package/src/canton/instrumentCatalog.js +283 -283
  16. package/src/canton/request_schemas/cancel_orders_amulet.json +77 -77
  17. package/src/canton/request_schemas/cancel_orders_utility.json +68 -68
  18. package/src/canton/request_schemas/create_order_proposal_amulet.json +94 -94
  19. package/src/canton/request_schemas/create_order_proposal_utility.json +121 -121
  20. package/src/canton/request_schemas/create_utility_credential.json +31 -31
  21. package/src/canton/request_schemas/execute_transfer_factory.json +43 -43
  22. package/src/canton/request_schemas/get_allocation_factory.json +21 -21
  23. package/src/canton/request_schemas/get_amulet_holdings.json +21 -21
  24. package/src/canton/request_schemas/get_instrument_configurations.json +21 -21
  25. package/src/canton/request_schemas/get_locked_amulet_holdings.json +21 -21
  26. package/src/canton/request_schemas/get_order_proposals.json +21 -21
  27. package/src/canton/request_schemas/get_orders.json +21 -21
  28. package/src/canton/request_schemas/get_sender_credentials.json +22 -22
  29. package/src/canton/request_schemas/get_transfer_factory.json +28 -28
  30. package/src/canton/request_schemas/get_utility_holdings.json +21 -21
  31. package/src/canton/request_schemas/unlock_amulet.json +38 -38
  32. package/src/canton/walletAdapter.d.ts +7 -7
  33. package/src/canton/walletAdapter.js +112 -112
  34. package/src/canton/withdrawals.ts +511 -511
  35. package/src/config/index.d.ts +63 -63
  36. package/src/config/index.js +188 -188
  37. package/src/websocket/index.ts +341 -341
  38. package/src/websocket/ws.d.ts +24 -24
@@ -1,22 +1,22 @@
1
- {
2
- "verbose": true,
3
- "activeAtOffset": "{{ledger_end}}",
4
- "filter": {
5
- "filtersByParty": {
6
- "{{sender}}": {
7
- "cumulative": [
8
- {
9
- "identifierFilter": {
10
- "TemplateFilter": {
11
- "value": {
12
- "templateId": "{{utility-app-credential-packageId}}:Utility.Credential.V0.Credential:Credential",
13
- "includeCreatedEventBlob": true
14
- }
15
- }
16
- }
17
- }
18
- ]
19
- }
20
- }
21
- }
22
- }
1
+ {
2
+ "verbose": true,
3
+ "activeAtOffset": "{{ledger_end}}",
4
+ "filter": {
5
+ "filtersByParty": {
6
+ "{{sender}}": {
7
+ "cumulative": [
8
+ {
9
+ "identifierFilter": {
10
+ "TemplateFilter": {
11
+ "value": {
12
+ "templateId": "{{utility-app-credential-packageId}}:Utility.Credential.V0.Credential:Credential",
13
+ "includeCreatedEventBlob": true
14
+ }
15
+ }
16
+ }
17
+ }
18
+ ]
19
+ }
20
+ }
21
+ }
22
+ }
@@ -1,29 +1,29 @@
1
- {
2
- "choiceArguments": {
3
- "expectedAdmin": "{{dso}}",
4
- "transfer": {
5
- "sender": "{{investor}}",
6
- "receiver": "{{investor}}",
7
- "amount": "{{amount}}",
8
- "instrumentId": {
9
- "admin": "{{dso}}",
10
- "id": "{{instrument_id}}"
11
- },
12
- "requestedAt": "{{time}}",
13
- "executeBefore": "{{timeEnd}}",
14
- "inputHoldingCids": "{{holding_ids}}",
15
- "meta": {
16
- "values": {}
17
- }
18
- },
19
- "extraArgs": {
20
- "context": {
21
- "values": {}
22
- },
23
- "meta": {
24
- "values": {}
25
- }
26
- }
27
- },
28
- "excludeDebugFields": true
1
+ {
2
+ "choiceArguments": {
3
+ "expectedAdmin": "{{dso}}",
4
+ "transfer": {
5
+ "sender": "{{investor}}",
6
+ "receiver": "{{investor}}",
7
+ "amount": "{{amount}}",
8
+ "instrumentId": {
9
+ "admin": "{{dso}}",
10
+ "id": "{{instrument_id}}"
11
+ },
12
+ "requestedAt": "{{time}}",
13
+ "executeBefore": "{{timeEnd}}",
14
+ "inputHoldingCids": "{{holding_ids}}",
15
+ "meta": {
16
+ "values": {}
17
+ }
18
+ },
19
+ "extraArgs": {
20
+ "context": {
21
+ "values": {}
22
+ },
23
+ "meta": {
24
+ "values": {}
25
+ }
26
+ }
27
+ },
28
+ "excludeDebugFields": true
29
29
  }
@@ -1,22 +1,22 @@
1
- {
2
- "verbose": true,
3
- "activeAtOffset": "{{ledger_end}}",
4
- "filter": {
5
- "filtersByParty": {
6
- "{{investor}}": {
7
- "cumulative": [
8
- {
9
- "identifierFilter": {
10
- "TemplateFilter": {
11
- "value": {
12
- "templateId": "#utility-registry-holding-v0:Utility.Registry.Holding.V0.Holding:Holding",
13
- "includeCreatedEventBlob": true
14
- }
15
- }
16
- }
17
- }
18
- ]
19
- }
20
- }
21
- }
1
+ {
2
+ "verbose": true,
3
+ "activeAtOffset": "{{ledger_end}}",
4
+ "filter": {
5
+ "filtersByParty": {
6
+ "{{investor}}": {
7
+ "cumulative": [
8
+ {
9
+ "identifierFilter": {
10
+ "TemplateFilter": {
11
+ "value": {
12
+ "templateId": "#utility-registry-holding-v0:Utility.Registry.Holding.V0.Holding:Holding",
13
+ "includeCreatedEventBlob": true
14
+ }
15
+ }
16
+ }
17
+ }
18
+ ]
19
+ }
20
+ }
21
+ }
22
22
  }
@@ -1,38 +1,38 @@
1
- {
2
- "commands": [
3
- {
4
- "ExerciseCommand": {
5
- "templateId": "{{locked_amulet_template_id}}",
6
- "contractId": "{{locked_amulet_cid}}",
7
- "choice": "LockedAmulet_Unlock",
8
- "choiceArgument": {
9
- "openRoundCid": "{{open_mining_round_cid}}"
10
- }
11
- }
12
- }
13
- ],
14
- "commandId": "{{randomUUID}}",
15
- "userId": "{{user_id}}",
16
- "applicationId": "temple",
17
- "actAs": ["{{investor}}"],
18
- "disclosedContracts": [
19
- {
20
- "templateId": "{{amulet_rules_template_id}}",
21
- "contractId": "{{transfer_rules_cid}}",
22
- "createdEventBlob": "{{transfer_rules_disclosure}}",
23
- "synchronizerId": "{{transfer_rules_synchronizer}}"
24
- },
25
- {
26
- "templateId": "{{open_mining_round_template_id}}",
27
- "contractId": "{{open_mining_round_cid}}",
28
- "createdEventBlob": "{{open_mining_round_disclosure}}",
29
- "synchronizerId": "{{open_mining_round_synchronizer}}"
30
- },
31
- {
32
- "templateId": "{{featured_app_right_template_id}}",
33
- "contractId": "{{featured_app_right_cid}}",
34
- "createdEventBlob": "{{featured_app_right_disclosure}}",
35
- "synchronizerId": "{{featured_app_right_synchronizer}}"
36
- }
37
- ]
38
- }
1
+ {
2
+ "commands": [
3
+ {
4
+ "ExerciseCommand": {
5
+ "templateId": "{{locked_amulet_template_id}}",
6
+ "contractId": "{{locked_amulet_cid}}",
7
+ "choice": "LockedAmulet_Unlock",
8
+ "choiceArgument": {
9
+ "openRoundCid": "{{open_mining_round_cid}}"
10
+ }
11
+ }
12
+ }
13
+ ],
14
+ "commandId": "{{randomUUID}}",
15
+ "userId": "{{user_id}}",
16
+ "applicationId": "temple",
17
+ "actAs": ["{{investor}}"],
18
+ "disclosedContracts": [
19
+ {
20
+ "templateId": "{{amulet_rules_template_id}}",
21
+ "contractId": "{{transfer_rules_cid}}",
22
+ "createdEventBlob": "{{transfer_rules_disclosure}}",
23
+ "synchronizerId": "{{transfer_rules_synchronizer}}"
24
+ },
25
+ {
26
+ "templateId": "{{open_mining_round_template_id}}",
27
+ "contractId": "{{open_mining_round_cid}}",
28
+ "createdEventBlob": "{{open_mining_round_disclosure}}",
29
+ "synchronizerId": "{{open_mining_round_synchronizer}}"
30
+ },
31
+ {
32
+ "templateId": "{{featured_app_right_template_id}}",
33
+ "contractId": "{{featured_app_right_cid}}",
34
+ "createdEventBlob": "{{featured_app_right_disclosure}}",
35
+ "synchronizerId": "{{featured_app_right_synchronizer}}"
36
+ }
37
+ ]
38
+ }
@@ -1,7 +1,7 @@
1
- export function setWalletAdapter(adapter: unknown): void;
2
- export function getWalletAdapter(): unknown;
3
- export function getAdapterProvider(): unknown;
4
- export function isServerMode(): boolean;
5
- export function getAdapterPartyId(): string | null;
6
- export function submitCommand(command: unknown): Promise<unknown>;
7
- export function payDueGasIfAny(): Promise<void>;
1
+ export function setWalletAdapter(adapter: unknown): void;
2
+ export function getWalletAdapter(): unknown;
3
+ export function getAdapterProvider(): unknown;
4
+ export function isServerMode(): boolean;
5
+ export function getAdapterPartyId(): string | null;
6
+ export function submitCommand(command: unknown): Promise<unknown>;
7
+ export function payDueGasIfAny(): Promise<void>;
@@ -1,112 +1,112 @@
1
- /**
2
- * Wallet Adapter Module
3
- *
4
- * Provides a unified interface for wallet interactions (reads and writes).
5
- * Currently supports Loop Wallet. Designed to support additional wallets in the future.
6
- *
7
- * Server-side (Loop): uses executeTransaction() — signs locally with private key
8
- * Client-side (Loop): uses submitTransaction() — delegates signing to Loop Wallet via WebSocket
9
- *
10
- * Detection: Loop server-side has null connection.ticketId and connection.ws
11
- */
12
-
13
- let _adapter = null;
14
- let _isServer = false;
15
-
16
- /**
17
- * Set the wallet adapter (e.g., Loop SDK instance).
18
- * Auto-detects server vs client mode.
19
- */
20
- export function setWalletAdapter(adapter) {
21
- _adapter = adapter;
22
- _isServer = adapter ? detectServerSide(adapter) : false;
23
- }
24
-
25
- /**
26
- * Get the current wallet adapter.
27
- */
28
- export function getWalletAdapter() {
29
- return _adapter;
30
- }
31
-
32
- /**
33
- * Returns the provider sub-object used for read operations (getActiveContracts).
34
- * For Loop, this is adapter.provider.
35
- */
36
- export function getAdapterProvider() {
37
- if (!_adapter) return null;
38
- return _adapter.provider || _adapter;
39
- }
40
-
41
- /**
42
- * Check if running in server mode.
43
- */
44
- export function isServerMode() {
45
- return _isServer;
46
- }
47
-
48
- /**
49
- * Detect if the adapter is server-side.
50
- * Loop-specific: server-side has null connection.ticketId and connection.ws
51
- */
52
- function detectServerSide(adapter) {
53
- if (adapter?.connection) {
54
- return adapter.connection.ticketId == null && adapter.connection.ws == null;
55
- }
56
- // If no connection object, assume server-side (e.g., headless/API usage)
57
- return true;
58
- }
59
-
60
- /**
61
- * Get the party ID from the wallet adapter.
62
- * For Loop, this is on adapter.connection.partyId or adapter.partyId.
63
- */
64
- export function getAdapterPartyId() {
65
- if (!_adapter) return null;
66
- return _adapter.provider?.party_id || _adapter.session?.partyId || null;
67
- }
68
-
69
- /**
70
- * Pay any outstanding network gas before submitting a transaction or reading balances.
71
- * Server-side only — client-side gas is handled by the Loop Wallet UI.
72
- */
73
- export async function payDueGasIfAny() {
74
- if (!_isServer || !_adapter) return;
75
- if (typeof _adapter.checkDueGas !== "function" || typeof _adapter.payGas !== "function") return;
76
-
77
- try {
78
- const dueGas = await _adapter.checkDueGas();
79
- if (dueGas?.pending && dueGas?.tracking_id) {
80
- console.log(`[Temple SDK] Paying outstanding network gas (tracking_id=${dueGas.tracking_id})`);
81
- await _adapter.payGas(dueGas.tracking_id);
82
- }
83
- } catch (error) {
84
- console.warn(`[Temple SDK] checkDueGas/payGas failed: ${error?.message || error}`);
85
- }
86
- }
87
-
88
- /**
89
- * Submit a command via the wallet adapter.
90
- * Server-side: calls adapter.executeTransaction(command)
91
- * Client-side: calls adapter.provider.submitTransaction(command)
92
- *
93
- * Note: callers of deposit/withdrawal/delegation should call payDueGasIfAny()
94
- * at the start of their action to ensure any outstanding gas is paid before
95
- * pulling UTXOs or submitting the command.
96
- */
97
- export async function submitCommand(command) {
98
- if (!_adapter) {
99
- throw new Error("[Temple SDK] No wallet adapter configured. Call initialize() with WALLET_ADAPTER or setWalletAdapter() first.");
100
- }
101
-
102
- if (_isServer && typeof _adapter.executeTransaction === 'function') {
103
- return _adapter.executeTransaction(command);
104
- }
105
-
106
- const provider = _adapter.provider || _adapter;
107
- if (typeof provider.submitTransaction === 'function') {
108
- return provider.submitTransaction(command);
109
- }
110
-
111
- throw new Error("[Temple SDK] Wallet adapter does not support transaction submission.");
112
- }
1
+ /**
2
+ * Wallet Adapter Module
3
+ *
4
+ * Provides a unified interface for wallet interactions (reads and writes).
5
+ * Currently supports Loop Wallet. Designed to support additional wallets in the future.
6
+ *
7
+ * Server-side (Loop): uses executeTransaction() — signs locally with private key
8
+ * Client-side (Loop): uses submitTransaction() — delegates signing to Loop Wallet via WebSocket
9
+ *
10
+ * Detection: Loop server-side has null connection.ticketId and connection.ws
11
+ */
12
+
13
+ let _adapter = null;
14
+ let _isServer = false;
15
+
16
+ /**
17
+ * Set the wallet adapter (e.g., Loop SDK instance).
18
+ * Auto-detects server vs client mode.
19
+ */
20
+ export function setWalletAdapter(adapter) {
21
+ _adapter = adapter;
22
+ _isServer = adapter ? detectServerSide(adapter) : false;
23
+ }
24
+
25
+ /**
26
+ * Get the current wallet adapter.
27
+ */
28
+ export function getWalletAdapter() {
29
+ return _adapter;
30
+ }
31
+
32
+ /**
33
+ * Returns the provider sub-object used for read operations (getActiveContracts).
34
+ * For Loop, this is adapter.provider.
35
+ */
36
+ export function getAdapterProvider() {
37
+ if (!_adapter) return null;
38
+ return _adapter.provider || _adapter;
39
+ }
40
+
41
+ /**
42
+ * Check if running in server mode.
43
+ */
44
+ export function isServerMode() {
45
+ return _isServer;
46
+ }
47
+
48
+ /**
49
+ * Detect if the adapter is server-side.
50
+ * Loop-specific: server-side has null connection.ticketId and connection.ws
51
+ */
52
+ function detectServerSide(adapter) {
53
+ if (adapter?.connection) {
54
+ return adapter.connection.ticketId == null && adapter.connection.ws == null;
55
+ }
56
+ // If no connection object, assume server-side (e.g., headless/API usage)
57
+ return true;
58
+ }
59
+
60
+ /**
61
+ * Get the party ID from the wallet adapter.
62
+ * For Loop, this is on adapter.connection.partyId or adapter.partyId.
63
+ */
64
+ export function getAdapterPartyId() {
65
+ if (!_adapter) return null;
66
+ return _adapter.provider?.party_id || _adapter.session?.partyId || null;
67
+ }
68
+
69
+ /**
70
+ * Pay any outstanding network gas before submitting a transaction or reading balances.
71
+ * Server-side only — client-side gas is handled by the Loop Wallet UI.
72
+ */
73
+ export async function payDueGasIfAny() {
74
+ if (!_isServer || !_adapter) return;
75
+ if (typeof _adapter.checkDueGas !== "function" || typeof _adapter.payGas !== "function") return;
76
+
77
+ try {
78
+ const dueGas = await _adapter.checkDueGas();
79
+ if (dueGas?.pending && dueGas?.tracking_id) {
80
+ console.log(`[Temple SDK] Paying outstanding network gas (tracking_id=${dueGas.tracking_id})`);
81
+ await _adapter.payGas(dueGas.tracking_id);
82
+ }
83
+ } catch (error) {
84
+ console.warn(`[Temple SDK] checkDueGas/payGas failed: ${error?.message || error}`);
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Submit a command via the wallet adapter.
90
+ * Server-side: calls adapter.executeTransaction(command)
91
+ * Client-side: calls adapter.provider.submitTransaction(command)
92
+ *
93
+ * Note: callers of deposit/withdrawal/delegation should call payDueGasIfAny()
94
+ * at the start of their action to ensure any outstanding gas is paid before
95
+ * pulling UTXOs or submitting the command.
96
+ */
97
+ export async function submitCommand(command) {
98
+ if (!_adapter) {
99
+ throw new Error("[Temple SDK] No wallet adapter configured. Call initialize() with WALLET_ADAPTER or setWalletAdapter() first.");
100
+ }
101
+
102
+ if (_isServer && typeof _adapter.executeTransaction === 'function') {
103
+ return _adapter.executeTransaction(command);
104
+ }
105
+
106
+ const provider = _adapter.provider || _adapter;
107
+ if (typeof provider.submitTransaction === 'function') {
108
+ return provider.submitTransaction(command);
109
+ }
110
+
111
+ throw new Error("[Temple SDK] Wallet adapter does not support transaction submission.");
112
+ }