@temple-digital-group/temple-canton-js 2.0.6-beta → 2.0.6
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/canton/deposits.js +2 -1
- package/dist/canton/helpers.d.ts +0 -3
- package/dist/canton/helpers.js +1 -16
- package/package.json +1 -1
- package/src/canton/deposits.ts +2 -1
- package/src/canton/helpers.ts +1 -15
- package/src/canton/index.js +2 -2
package/dist/canton/deposits.js
CHANGED
|
@@ -298,6 +298,7 @@ export async function depositFunds(opts, returnCommand = false) {
|
|
|
298
298
|
return { error: msg };
|
|
299
299
|
}
|
|
300
300
|
const isAmulet = assetId === "Amulet";
|
|
301
|
+
const usingWalletAdapter = Boolean(getWalletAdapter());
|
|
301
302
|
// --- 1. Resolve admin and factory ---
|
|
302
303
|
let admin;
|
|
303
304
|
let factoryContractId;
|
|
@@ -319,7 +320,7 @@ export async function depositFunds(opts, returnCommand = false) {
|
|
|
319
320
|
if (isAmulet && (!allocateBefore || !settleBefore)) {
|
|
320
321
|
// Compute the safe deadline from on-chain fee params to avoid
|
|
321
322
|
// "amulet expires before lock" errors on small amounts.
|
|
322
|
-
const expiryParams = await fetchAmuletExpiryParams(config.VALIDATOR_DSO_PARTY_ID);
|
|
323
|
+
const expiryParams = usingWalletAdapter ? null : await fetchAmuletExpiryParams(config.VALIDATOR_DSO_PARTY_ID);
|
|
323
324
|
const maxExpiry = expiryParams ? maxLockExpirationForFreshAmulet(amount, expiryParams) : null;
|
|
324
325
|
if (maxExpiry) {
|
|
325
326
|
// settleBefore = safe max expiry; allocateBefore = halfway between now and settleBefore
|
package/dist/canton/helpers.d.ts
CHANGED
|
@@ -16,7 +16,6 @@ export declare const DEFAULT_UTILITY_CONTEXT_KEYS: {
|
|
|
16
16
|
readonly featuredAppRight: "featured-app-right";
|
|
17
17
|
readonly featuredAppRightPrefixed: "utility.digitalasset.com/featured-app-right";
|
|
18
18
|
};
|
|
19
|
-
export declare const LOCAL_VALIDATOR_HOSTNAMES: Set<string>;
|
|
20
19
|
export declare const FORCE_LEDGER_METADATA: boolean;
|
|
21
20
|
export interface DisclosedContract {
|
|
22
21
|
templateId: string | null;
|
|
@@ -58,8 +57,6 @@ export interface ActiveContractEntry {
|
|
|
58
57
|
}
|
|
59
58
|
/** Cross-platform UUID generation. */
|
|
60
59
|
export declare const randomUUID: () => string;
|
|
61
|
-
/** Check if a validator URL points to localhost. */
|
|
62
|
-
export declare function isLocalValidatorUrl(urlValue: string | undefined | null): boolean;
|
|
63
60
|
/** Determine if ledger should be used for metadata resolution. */
|
|
64
61
|
export declare function shouldUseLedgerForMetadata(): boolean;
|
|
65
62
|
/** Trim a contract ID string. */
|
package/dist/canton/helpers.js
CHANGED
|
@@ -22,7 +22,6 @@ export const DEFAULT_UTILITY_CONTEXT_KEYS = {
|
|
|
22
22
|
featuredAppRight: "featured-app-right",
|
|
23
23
|
featuredAppRightPrefixed: "utility.digitalasset.com/featured-app-right",
|
|
24
24
|
};
|
|
25
|
-
export const LOCAL_VALIDATOR_HOSTNAMES = new Set(["localhost", "127.0.0.1", "::1", "0.0.0.0"]);
|
|
26
25
|
export const FORCE_LEDGER_METADATA = typeof process !== "undefined" && process.env
|
|
27
26
|
? String(process.env.FORCE_LEDGER_METADATA || "").toLowerCase() === "true"
|
|
28
27
|
: false;
|
|
@@ -42,25 +41,11 @@ export const randomUUID = () => {
|
|
|
42
41
|
return v.toString(16);
|
|
43
42
|
});
|
|
44
43
|
};
|
|
45
|
-
/** Check if a validator URL points to localhost. */
|
|
46
|
-
export function isLocalValidatorUrl(urlValue) {
|
|
47
|
-
if (!urlValue)
|
|
48
|
-
return false;
|
|
49
|
-
try {
|
|
50
|
-
const parsed = new URL(urlValue);
|
|
51
|
-
return LOCAL_VALIDATOR_HOSTNAMES.has(parsed.hostname.toLowerCase());
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
44
|
/** Determine if ledger should be used for metadata resolution. */
|
|
58
45
|
export function shouldUseLedgerForMetadata() {
|
|
59
|
-
if (FORCE_LEDGER_METADATA)
|
|
60
|
-
return true;
|
|
61
46
|
if (!config.VALIDATOR_API_URL)
|
|
62
47
|
return false;
|
|
63
|
-
return
|
|
48
|
+
return FORCE_LEDGER_METADATA;
|
|
64
49
|
}
|
|
65
50
|
/** Trim a contract ID string. */
|
|
66
51
|
export function normalizeContractId(value) {
|
package/package.json
CHANGED
package/src/canton/deposits.ts
CHANGED
|
@@ -407,6 +407,7 @@ export async function depositFunds(
|
|
|
407
407
|
}
|
|
408
408
|
|
|
409
409
|
const isAmulet = assetId === "Amulet";
|
|
410
|
+
const usingWalletAdapter = Boolean(getWalletAdapter());
|
|
410
411
|
|
|
411
412
|
// --- 1. Resolve admin and factory ---
|
|
412
413
|
let admin: string;
|
|
@@ -431,7 +432,7 @@ export async function depositFunds(
|
|
|
431
432
|
if (isAmulet && (!allocateBefore || !settleBefore)) {
|
|
432
433
|
// Compute the safe deadline from on-chain fee params to avoid
|
|
433
434
|
// "amulet expires before lock" errors on small amounts.
|
|
434
|
-
const expiryParams = await fetchAmuletExpiryParams(config.VALIDATOR_DSO_PARTY_ID);
|
|
435
|
+
const expiryParams = usingWalletAdapter ? null : await fetchAmuletExpiryParams(config.VALIDATOR_DSO_PARTY_ID);
|
|
435
436
|
const maxExpiry = expiryParams ? maxLockExpirationForFreshAmulet(amount, expiryParams) : null;
|
|
436
437
|
if (maxExpiry) {
|
|
437
438
|
// settleBefore = safe max expiry; allocateBefore = halfway between now and settleBefore
|
package/src/canton/helpers.ts
CHANGED
|
@@ -26,8 +26,6 @@ export const DEFAULT_UTILITY_CONTEXT_KEYS = {
|
|
|
26
26
|
featuredAppRightPrefixed: "utility.digitalasset.com/featured-app-right",
|
|
27
27
|
} as const;
|
|
28
28
|
|
|
29
|
-
export const LOCAL_VALIDATOR_HOSTNAMES = new Set(["localhost", "127.0.0.1", "::1", "0.0.0.0"]);
|
|
30
|
-
|
|
31
29
|
export const FORCE_LEDGER_METADATA: boolean =
|
|
32
30
|
typeof process !== "undefined" && process.env
|
|
33
31
|
? String(process.env.FORCE_LEDGER_METADATA || "").toLowerCase() === "true"
|
|
@@ -95,22 +93,10 @@ export const randomUUID = (): string => {
|
|
|
95
93
|
});
|
|
96
94
|
};
|
|
97
95
|
|
|
98
|
-
/** Check if a validator URL points to localhost. */
|
|
99
|
-
export function isLocalValidatorUrl(urlValue: string | undefined | null): boolean {
|
|
100
|
-
if (!urlValue) return false;
|
|
101
|
-
try {
|
|
102
|
-
const parsed = new URL(urlValue);
|
|
103
|
-
return LOCAL_VALIDATOR_HOSTNAMES.has(parsed.hostname.toLowerCase());
|
|
104
|
-
} catch {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
96
|
/** Determine if ledger should be used for metadata resolution. */
|
|
110
97
|
export function shouldUseLedgerForMetadata(): boolean {
|
|
111
|
-
if (FORCE_LEDGER_METADATA) return true;
|
|
112
98
|
if (!config.VALIDATOR_API_URL) return false;
|
|
113
|
-
return
|
|
99
|
+
return FORCE_LEDGER_METADATA;
|
|
114
100
|
}
|
|
115
101
|
|
|
116
102
|
/** Trim a contract ID string. */
|
package/src/canton/index.js
CHANGED
|
@@ -895,7 +895,7 @@ async function queryLedgerContractsByTemplate(templateId, returnCommand = false)
|
|
|
895
895
|
* @returns {Promise<Object|null>} The AmuletRules contract data, or null on failure
|
|
896
896
|
*/
|
|
897
897
|
export async function getAmuletRules(dso, returnCommand = false) {
|
|
898
|
-
if (
|
|
898
|
+
if (shouldUseLedgerForMetadata()) {
|
|
899
899
|
const headers = await buildHeaders();
|
|
900
900
|
const url = `${config.VALIDATOR_SCAN_API_URL}/amulet-rules?provider=${dso}`;
|
|
901
901
|
if (returnCommand) {
|
|
@@ -1012,7 +1012,7 @@ export async function getFeaturedAppRight(returnCommand = false) {
|
|
|
1012
1012
|
* @returns {Promise<Object|null>} Mining rounds data with open_mining_rounds array, or null on failure
|
|
1013
1013
|
*/
|
|
1014
1014
|
export async function getOpenMiningRounds(dso, returnCommand = false) {
|
|
1015
|
-
if (
|
|
1015
|
+
if (shouldUseLedgerForMetadata()) {
|
|
1016
1016
|
const headers = await buildHeaders();
|
|
1017
1017
|
const url = `${config.VALIDATOR_SCAN_API_URL}/open-and-issuing-mining-rounds?provider=${dso}`;
|
|
1018
1018
|
if (returnCommand) {
|