@supanovaapp/sdk 0.2.37 → 0.2.39
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 +24 -2
- package/dist/core/client.d.ts +3 -0
- package/dist/core/types.d.ts +36 -4
- package/dist/index.cjs.js +256 -256
- package/dist/index.d.ts +5 -0
- package/dist/index.esm.js +2935 -2905
- package/dist/providers/canton/types.d.ts +9 -4
- package/dist/services/cantonService.d.ts +9 -4
- package/dist/utils/canton.d.ts +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -418,6 +418,27 @@ const filteredContracts = await getActiveContracts([
|
|
|
418
418
|
'template-id-1',
|
|
419
419
|
'template-id-2'
|
|
420
420
|
]);
|
|
421
|
+
|
|
422
|
+
// With pagination (limit required, offset optional)
|
|
423
|
+
const page = await getActiveContracts(undefined, { limit: 10 });
|
|
424
|
+
const nextPage = await getActiveContracts(undefined, { limit: 10, offset: 10 });
|
|
425
|
+
|
|
426
|
+
// Combined: filter + pagination
|
|
427
|
+
const filtered = await getActiveContracts(['template-id-1'], { limit: 5, offset: 0 });
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
**Parameters:**
|
|
431
|
+
- `templateIds` (optional) - Array of template IDs to filter by
|
|
432
|
+
- `pagination` (optional) - `{ limit: number; offset?: number }`. `offset` requires `limit`.
|
|
433
|
+
|
|
434
|
+
**Note:** The API may return contracts in two formats (legacy wrapped or flat). Use `normalizeContractItem()` to get a consistent shape:
|
|
435
|
+
|
|
436
|
+
```tsx
|
|
437
|
+
import { normalizeContractItem } from '@supanovaapp/sdk';
|
|
438
|
+
|
|
439
|
+
const contracts = await getActiveContracts();
|
|
440
|
+
const normalized = contracts.map(normalizeContractItem);
|
|
441
|
+
// normalized[0].contractId, .templateId, .createArgument, .createdAt
|
|
421
442
|
```
|
|
422
443
|
|
|
423
444
|
#### Get Canton Balances
|
|
@@ -513,13 +534,14 @@ const { calculateTransferFee } = useCanton();
|
|
|
513
534
|
|
|
514
535
|
const feeCc = await calculateTransferFee(
|
|
515
536
|
'USDC', // instrumentId (optional, defaults to Amulet)
|
|
516
|
-
'token-admin::1220abc123...' // optional instrumentAdmin
|
|
537
|
+
'token-admin::1220abc123...', // optional instrumentAdmin
|
|
538
|
+
'receiver-party::1220abc123...' // optional partyId (recommended: recipient)
|
|
517
539
|
);
|
|
518
540
|
|
|
519
541
|
console.log('Transfer fee (CC):', feeCc);
|
|
520
542
|
```
|
|
521
543
|
|
|
522
|
-
**Note**: The amount cannot have more than 10 decimal places. Transfers are only supported to wallets with preapproved transfers enabled.
|
|
544
|
+
**Note**: The amount cannot have more than 10 decimal places. Transfers are only supported to wallets with preapproved transfers enabled. If `partyId` is omitted, SDK falls back to the current user party ID.
|
|
523
545
|
|
|
524
546
|
#### Submit a Transaction
|
|
525
547
|
|
package/dist/core/client.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export interface ClientConfig {
|
|
|
4
4
|
nodeIdentifier: string;
|
|
5
5
|
/** Optional app identifier for app-specific backend rules */
|
|
6
6
|
supaAppId?: string;
|
|
7
|
+
/** Optional SDK version (sent as X-Supa-SDK header) */
|
|
8
|
+
sdkVersion?: string;
|
|
7
9
|
getAccessToken?: () => Promise<string | null>;
|
|
8
10
|
}
|
|
9
11
|
export declare class ApiClient {
|
|
@@ -11,6 +13,7 @@ export declare class ApiClient {
|
|
|
11
13
|
private getAccessToken?;
|
|
12
14
|
private nodeIdentifier;
|
|
13
15
|
private supaAppId?;
|
|
16
|
+
private sdkVersion?;
|
|
14
17
|
constructor(config?: ClientConfig);
|
|
15
18
|
get<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
16
19
|
post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
package/dist/core/types.d.ts
CHANGED
|
@@ -143,15 +143,47 @@ export interface CantonJsActiveContract {
|
|
|
143
143
|
export interface CantonContractEntry {
|
|
144
144
|
JsActiveContract: CantonJsActiveContract;
|
|
145
145
|
}
|
|
146
|
-
/** Active contract
|
|
147
|
-
export interface
|
|
146
|
+
/** Active contract item — legacy wrapped format (Canton Ledger API) */
|
|
147
|
+
export interface CantonActiveContractItemLegacy {
|
|
148
148
|
/** Workflow ID (can be empty) */
|
|
149
149
|
workflowId: string;
|
|
150
150
|
/** Contract entry containing the active contract */
|
|
151
151
|
contractEntry: CantonContractEntry;
|
|
152
152
|
}
|
|
153
|
+
/** Active contract item — new flat format */
|
|
154
|
+
export interface CantonActiveContractItemFlat {
|
|
155
|
+
/** Contract ID */
|
|
156
|
+
contractId: string;
|
|
157
|
+
/** Template ID in format packageId:module:entity */
|
|
158
|
+
templateId: string;
|
|
159
|
+
/** Create argument data — varies per template */
|
|
160
|
+
createArgument: CantonAmuletCreateArgument | Record<string, unknown>;
|
|
161
|
+
/** Created event blob (base64) */
|
|
162
|
+
createdEventBlob: string;
|
|
163
|
+
}
|
|
164
|
+
/** Active contract response item — supports both legacy and flat formats */
|
|
165
|
+
export type CantonActiveContractItem = CantonActiveContractItemLegacy | CantonActiveContractItemFlat;
|
|
166
|
+
/** Normalized contract data extracted from either format */
|
|
167
|
+
export interface CantonNormalizedContract {
|
|
168
|
+
contractId: string;
|
|
169
|
+
templateId: string;
|
|
170
|
+
createArgument: CantonAmuletCreateArgument | Record<string, unknown>;
|
|
171
|
+
createdEventBlob: string;
|
|
172
|
+
/** Only available in legacy format */
|
|
173
|
+
createdAt: string | null;
|
|
174
|
+
}
|
|
153
175
|
/** Response from /canton/api/active_contracts */
|
|
154
176
|
export type CantonActiveContractsResponseDto = CantonActiveContractItem[];
|
|
177
|
+
/** Parameters for getActiveContracts (offset requires limit) */
|
|
178
|
+
export type GetActiveContractsParams = {
|
|
179
|
+
templateIds?: string[];
|
|
180
|
+
limit?: number;
|
|
181
|
+
offset?: never;
|
|
182
|
+
} | {
|
|
183
|
+
templateIds?: string[];
|
|
184
|
+
limit: number;
|
|
185
|
+
offset?: number;
|
|
186
|
+
};
|
|
155
187
|
export interface CantonActiveContract {
|
|
156
188
|
/** Contract ID */
|
|
157
189
|
contractId: string;
|
|
@@ -272,8 +304,8 @@ export interface CantonPrepareTransferResponseDto extends CantonPrepareTransacti
|
|
|
272
304
|
}
|
|
273
305
|
/** Request params for transfer fee calculation */
|
|
274
306
|
export interface CantonCalculateTransferFeeRequestDto {
|
|
275
|
-
/**
|
|
276
|
-
partyId
|
|
307
|
+
/** Party ID used for fee calculation (receiver recommended for transfer flows) */
|
|
308
|
+
partyId?: string;
|
|
277
309
|
/** Instrument ID of the transferred token */
|
|
278
310
|
instrumentId: string;
|
|
279
311
|
/** Optional instrument admin party ID */
|