@rhea-finance/confidential-swap 0.3.7 → 0.3.8
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/adapters/index.d.cts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/{api-xFv7YgFM.d.cts → api-DiFtUiFv.d.cts} +3 -1
- package/dist/{api-xFv7YgFM.d.ts → api-DiFtUiFv.d.ts} +3 -1
- package/dist/index.cjs +26 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/adapters/index.d.ts
CHANGED
|
@@ -310,6 +310,8 @@ interface ExecuteOptions {
|
|
|
310
310
|
onSignatureProgress?: (progress: SignatureProgress) => void;
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
+
declare function isTronBase58Address(address?: string): boolean;
|
|
314
|
+
declare function normalizeQuoteTronAddress(address: string | undefined, type: "CONFIDENTIAL_INTENTS" | "DESTINATION_CHAIN" | "ORIGIN_CHAIN" | undefined): string | undefined;
|
|
313
315
|
interface HttpApiConfig {
|
|
314
316
|
/** Full /v0 URL; balances are sent here, never to the proxy. */
|
|
315
317
|
directUrl: string;
|
|
@@ -357,4 +359,4 @@ declare class HttpConfidentialApi implements ConfidentialApi {
|
|
|
357
359
|
getOrders(token: string, signerId: string, limit: number, offset: number, signal?: AbortSignal): Promise<OrderPage>;
|
|
358
360
|
}
|
|
359
361
|
|
|
360
|
-
export { type AppFee as A, type Balance as B, type ConfidentialApi as C, type SwapFundingRequest as D, type ExecutionStore as E, type FundingIdentity as F, type WithdrawPreview as G, HttpConfidentialApi as H, type WithdrawProgress as I, type LinkingKind as L, type OrderPage as O, type PollingOptions as P, type QuotePlan as Q, type SigningAdapter as S, type Token as T, type UnsignedData as U, type WalletKind as W, type LinkingIdentity as a, type SigningStandard as b, type FundingRoute as c, type FundingAdapter as d, type FundingSwapAdapter as e, type SessionStore as f, type QuoteResponse as g, type QuoteRequest as h, type Login as i, type ExecutionSnapshot as j, type ExecuteOptions as k, type BalanceSnapshotEntry as l, type AppFeeEstimate as m, type ExecutionStage as n, type FundingReceipt as o, type FundingRouteKind as p, type FundingSwapQuote as q, type HttpApiConfig as r, type PrivateOrder as s, type PrivateWithdrawRequest as t, type PrivateWithdrawRow as u, type QuoteParams as v, type Session as w, type SignatureProgress as x, type SignedData as y, type StatusResponse as z };
|
|
362
|
+
export { type AppFee as A, type Balance as B, type ConfidentialApi as C, type SwapFundingRequest as D, type ExecutionStore as E, type FundingIdentity as F, type WithdrawPreview as G, HttpConfidentialApi as H, type WithdrawProgress as I, isTronBase58Address as J, normalizeQuoteTronAddress as K, type LinkingKind as L, type OrderPage as O, type PollingOptions as P, type QuotePlan as Q, type SigningAdapter as S, type Token as T, type UnsignedData as U, type WalletKind as W, type LinkingIdentity as a, type SigningStandard as b, type FundingRoute as c, type FundingAdapter as d, type FundingSwapAdapter as e, type SessionStore as f, type QuoteResponse as g, type QuoteRequest as h, type Login as i, type ExecutionSnapshot as j, type ExecuteOptions as k, type BalanceSnapshotEntry as l, type AppFeeEstimate as m, type ExecutionStage as n, type FundingReceipt as o, type FundingRouteKind as p, type FundingSwapQuote as q, type HttpApiConfig as r, type PrivateOrder as s, type PrivateWithdrawRequest as t, type PrivateWithdrawRow as u, type QuoteParams as v, type Session as w, type SignatureProgress as x, type SignedData as y, type StatusResponse as z };
|
|
@@ -310,6 +310,8 @@ interface ExecuteOptions {
|
|
|
310
310
|
onSignatureProgress?: (progress: SignatureProgress) => void;
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
+
declare function isTronBase58Address(address?: string): boolean;
|
|
314
|
+
declare function normalizeQuoteTronAddress(address: string | undefined, type: "CONFIDENTIAL_INTENTS" | "DESTINATION_CHAIN" | "ORIGIN_CHAIN" | undefined): string | undefined;
|
|
313
315
|
interface HttpApiConfig {
|
|
314
316
|
/** Full /v0 URL; balances are sent here, never to the proxy. */
|
|
315
317
|
directUrl: string;
|
|
@@ -357,4 +359,4 @@ declare class HttpConfidentialApi implements ConfidentialApi {
|
|
|
357
359
|
getOrders(token: string, signerId: string, limit: number, offset: number, signal?: AbortSignal): Promise<OrderPage>;
|
|
358
360
|
}
|
|
359
361
|
|
|
360
|
-
export { type AppFee as A, type Balance as B, type ConfidentialApi as C, type SwapFundingRequest as D, type ExecutionStore as E, type FundingIdentity as F, type WithdrawPreview as G, HttpConfidentialApi as H, type WithdrawProgress as I, type LinkingKind as L, type OrderPage as O, type PollingOptions as P, type QuotePlan as Q, type SigningAdapter as S, type Token as T, type UnsignedData as U, type WalletKind as W, type LinkingIdentity as a, type SigningStandard as b, type FundingRoute as c, type FundingAdapter as d, type FundingSwapAdapter as e, type SessionStore as f, type QuoteResponse as g, type QuoteRequest as h, type Login as i, type ExecutionSnapshot as j, type ExecuteOptions as k, type BalanceSnapshotEntry as l, type AppFeeEstimate as m, type ExecutionStage as n, type FundingReceipt as o, type FundingRouteKind as p, type FundingSwapQuote as q, type HttpApiConfig as r, type PrivateOrder as s, type PrivateWithdrawRequest as t, type PrivateWithdrawRow as u, type QuoteParams as v, type Session as w, type SignatureProgress as x, type SignedData as y, type StatusResponse as z };
|
|
362
|
+
export { type AppFee as A, type Balance as B, type ConfidentialApi as C, type SwapFundingRequest as D, type ExecutionStore as E, type FundingIdentity as F, type WithdrawPreview as G, HttpConfidentialApi as H, type WithdrawProgress as I, isTronBase58Address as J, normalizeQuoteTronAddress as K, type LinkingKind as L, type OrderPage as O, type PollingOptions as P, type QuotePlan as Q, type SigningAdapter as S, type Token as T, type UnsignedData as U, type WalletKind as W, type LinkingIdentity as a, type SigningStandard as b, type FundingRoute as c, type FundingAdapter as d, type FundingSwapAdapter as e, type SessionStore as f, type QuoteResponse as g, type QuoteRequest as h, type Login as i, type ExecutionSnapshot as j, type ExecuteOptions as k, type BalanceSnapshotEntry as l, type AppFeeEstimate as m, type ExecutionStage as n, type FundingReceipt as o, type FundingRouteKind as p, type FundingSwapQuote as q, type HttpApiConfig as r, type PrivateOrder as s, type PrivateWithdrawRequest as t, type PrivateWithdrawRow as u, type QuoteParams as v, type Session as w, type SignatureProgress as x, type SignedData as y, type StatusResponse as z };
|
package/dist/index.cjs
CHANGED
|
@@ -38,9 +38,11 @@ __export(index_exports, {
|
|
|
38
38
|
identityKey: () => identityKey,
|
|
39
39
|
isRecoverableExecution: () => isRecoverableExecution,
|
|
40
40
|
isTransientPollError: () => isTransientPollError,
|
|
41
|
+
isTronBase58Address: () => isTronBase58Address,
|
|
41
42
|
isUserRejectedError: () => isUserRejectedError,
|
|
42
43
|
needsWithdrawalReview: () => needsWithdrawalReview,
|
|
43
44
|
normalizeChain: () => normalizeChain,
|
|
45
|
+
normalizeQuoteTronAddress: () => normalizeQuoteTronAddress,
|
|
44
46
|
normalizeStatus: () => normalizeStatus,
|
|
45
47
|
resolveFundingRoute: () => resolveFundingRoute,
|
|
46
48
|
resolveIntentsCreditAsset: () => resolveIntentsCreditAsset,
|
|
@@ -617,6 +619,24 @@ function toMultiPayload(data) {
|
|
|
617
619
|
bytes[64] = bytes[64] - 27;
|
|
618
620
|
return { ...data, signature: `secp256k1:${import_base4.base58.encode(bytes)}` };
|
|
619
621
|
}
|
|
622
|
+
function isTronBase58Address(address) {
|
|
623
|
+
if (typeof address !== "string") return false;
|
|
624
|
+
const trimmed = address.trim();
|
|
625
|
+
if (trimmed.length !== 34 || !trimmed.startsWith("T")) return false;
|
|
626
|
+
try {
|
|
627
|
+
tronRecoveredAddressHex(trimmed);
|
|
628
|
+
return true;
|
|
629
|
+
} catch {
|
|
630
|
+
return false;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
function normalizeQuoteTronAddress(address, type) {
|
|
634
|
+
if (!address) return address;
|
|
635
|
+
if (type === "CONFIDENTIAL_INTENTS" && isTronBase58Address(address)) {
|
|
636
|
+
return tronRecoveredAddressHex(address);
|
|
637
|
+
}
|
|
638
|
+
return address;
|
|
639
|
+
}
|
|
620
640
|
function record(value) {
|
|
621
641
|
responseAssert(value && typeof value === "object" && !Array.isArray(value), "Expected an object response.");
|
|
622
642
|
return value;
|
|
@@ -789,8 +809,12 @@ var HttpConfidentialApi = class {
|
|
|
789
809
|
const isWithdrawal = params.depositType === "CONFIDENTIAL_INTENTS" && params.recipientType === "DESTINATION_CHAIN";
|
|
790
810
|
const { appFees: requestedAppFees, ...quoteParams } = params;
|
|
791
811
|
const appFees = requestedAppFees === void 0 ? this.appFees.map((fee) => ({ ...fee })) : normalizeAppFees(requestedAppFees, true);
|
|
812
|
+
const recipient = normalizeQuoteTronAddress(quoteParams.recipient, quoteParams.recipientType);
|
|
813
|
+
const refundTo = normalizeQuoteTronAddress(quoteParams.refundTo, quoteParams.refundType);
|
|
792
814
|
const data = await this.request(`${this.proxy}/quote`, "POST", {
|
|
793
815
|
...quoteParams,
|
|
816
|
+
...recipient !== void 0 ? { recipient } : {},
|
|
817
|
+
...refundTo !== void 0 ? { refundTo } : {},
|
|
794
818
|
swapType: params.swapType ?? "EXACT_INPUT",
|
|
795
819
|
deadline: new Date(this.now() + 36e5).toISOString(),
|
|
796
820
|
referral: this.config.referral ?? "rhea",
|
|
@@ -2113,9 +2137,11 @@ function createConfidentialSwapClient(config) {
|
|
|
2113
2137
|
identityKey,
|
|
2114
2138
|
isRecoverableExecution,
|
|
2115
2139
|
isTransientPollError,
|
|
2140
|
+
isTronBase58Address,
|
|
2116
2141
|
isUserRejectedError,
|
|
2117
2142
|
needsWithdrawalReview,
|
|
2118
2143
|
normalizeChain,
|
|
2144
|
+
normalizeQuoteTronAddress,
|
|
2119
2145
|
normalizeStatus,
|
|
2120
2146
|
resolveFundingRoute,
|
|
2121
2147
|
resolveIntentsCreditAsset,
|