@zkp2p/sdk 0.2.0 → 0.2.3
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 +2 -2
- package/dist/{chunk-J33LUXNA.mjs → chunk-AXX3QCRW.mjs} +10 -52
- package/dist/chunk-AXX3QCRW.mjs.map +1 -0
- package/dist/index.cjs +163 -281
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.mjs +160 -238
- package/dist/index.mjs.map +1 -1
- package/dist/protocolViewerParsers-TPB47QOH.mjs +4 -0
- package/dist/{protocolViewerParsers-VVASNOXW.mjs.map → protocolViewerParsers-TPB47QOH.mjs.map} +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/{vaultUtils-zw4Xgu-G.d.mts → vaultUtils-DiAumiXp.d.mts} +6 -33
- package/dist/{vaultUtils-zw4Xgu-G.d.ts → vaultUtils-DiAumiXp.d.ts} +6 -33
- package/package.json +17 -17
- package/dist/chunk-J33LUXNA.mjs.map +0 -1
- package/dist/protocolViewerParsers-VVASNOXW.mjs +0 -4
package/dist/{protocolViewerParsers-VVASNOXW.mjs.map → protocolViewerParsers-TPB47QOH.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"protocolViewerParsers-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"protocolViewerParsers-TPB47QOH.mjs"}
|
package/dist/react.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Z as Zkp2pClient, i as SignalIntentMethodParams, ac as PreparedTransaction, af as TakerTier, f as GetTakerTierRequest, g as GetTakerTierResponse, F as FulfillIntentMethodParams,
|
|
2
|
-
export {
|
|
1
|
+
import { Z as Zkp2pClient, i as SignalIntentMethodParams, ac as PreparedTransaction, af as TakerTier, f as GetTakerTierRequest, g as GetTakerTierResponse, F as FulfillIntentMethodParams, bu as SendTransactionFn, bv as SendBatchFn, bs as DelegationDepositTarget, bt as BatchResult } from './vaultUtils-DiAumiXp.mjs';
|
|
2
|
+
export { bq as DelegationRoute, br as DelegationState, bw as VAULT_ZERO_ADDRESS, bk as ZERO_RATE_MANAGER_ID, bx as asErrorMessage, by as assertDelegationMethodSupport, bp as classifyDelegationState, bo as getDelegationRoute, bl as isZeroRateManagerId, bm as normalizeRateManagerId, bn as normalizeRegistry } from './vaultUtils-DiAumiXp.mjs';
|
|
3
3
|
import { Hash, Address, Hex } from 'viem';
|
|
4
4
|
import '@zkp2p/indexer-schema';
|
|
5
5
|
import 'abitype';
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Z as Zkp2pClient, i as SignalIntentMethodParams, ac as PreparedTransaction, af as TakerTier, f as GetTakerTierRequest, g as GetTakerTierResponse, F as FulfillIntentMethodParams,
|
|
2
|
-
export {
|
|
1
|
+
import { Z as Zkp2pClient, i as SignalIntentMethodParams, ac as PreparedTransaction, af as TakerTier, f as GetTakerTierRequest, g as GetTakerTierResponse, F as FulfillIntentMethodParams, bu as SendTransactionFn, bv as SendBatchFn, bs as DelegationDepositTarget, bt as BatchResult } from './vaultUtils-DiAumiXp.js';
|
|
2
|
+
export { bq as DelegationRoute, br as DelegationState, bw as VAULT_ZERO_ADDRESS, bk as ZERO_RATE_MANAGER_ID, bx as asErrorMessage, by as assertDelegationMethodSupport, bp as classifyDelegationState, bo as getDelegationRoute, bl as isZeroRateManagerId, bm as normalizeRateManagerId, bn as normalizeRegistry } from './vaultUtils-DiAumiXp.js';
|
|
3
3
|
import { Hash, Address, Hex } from 'viem';
|
|
4
4
|
import '@zkp2p/indexer-schema';
|
|
5
5
|
import 'abitype';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _zkp2p_indexer_schema from '@zkp2p/indexer-schema';
|
|
2
2
|
import { Deposit, DepositStatus as DepositStatus$2, IntentStatus as IntentStatus$1, DepositPaymentMethod, MethodCurrency, Intent as Intent$1, RateManager, ManagerAggregateStats, RateManagerRate, ManagerStats, DepositFundActivity, DepositDailySnapshot, ManagerDailySnapshot } from '@zkp2p/indexer-schema';
|
|
3
|
-
import { Address, Hex, AccessList, AuthorizationList,
|
|
3
|
+
import { Address, Hex, AccessList, AuthorizationList, Hash, WalletClient, PublicClient } from 'viem';
|
|
4
4
|
import { Abi } from 'abitype';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -161,7 +161,6 @@ declare function isSupportedCurrencyHash(hash: string): boolean;
|
|
|
161
161
|
* @module contracts
|
|
162
162
|
*/
|
|
163
163
|
|
|
164
|
-
declare const HISTORICAL_ESCROW_ADDRESSES: Record<string, `0x${string}`[]>;
|
|
165
164
|
/**
|
|
166
165
|
* Contract addresses for a specific deployment.
|
|
167
166
|
*/
|
|
@@ -283,7 +282,7 @@ declare function getPaymentMethodsCatalog(_chainId: number, env?: RuntimeEnv): P
|
|
|
283
282
|
* @param env - Runtime environment
|
|
284
283
|
* @returns Gating service signer address
|
|
285
284
|
*/
|
|
286
|
-
declare function getGatingServiceAddress(_chainId: number,
|
|
285
|
+
declare function getGatingServiceAddress(_chainId: number, _env?: RuntimeEnv): `0x${string}`;
|
|
287
286
|
declare function getRateManagerContracts(chainId: number, env?: RuntimeEnv): {
|
|
288
287
|
addresses: {
|
|
289
288
|
registry: `0x${string}`;
|
|
@@ -738,31 +737,6 @@ type TimeoutConfig = {
|
|
|
738
737
|
transaction?: number;
|
|
739
738
|
};
|
|
740
739
|
type AuthorizationTokenProvider = () => string | null | undefined | Promise<string | null | undefined>;
|
|
741
|
-
type Zkp2pClientOptions = {
|
|
742
|
-
walletClient: WalletClient;
|
|
743
|
-
/** Curator API key for authenticated endpoints (optional for basic deposit/payee flows) */
|
|
744
|
-
apiKey?: string;
|
|
745
|
-
chainId: number;
|
|
746
|
-
/** Runtime environment (defaults to 'production') */
|
|
747
|
-
runtimeEnv?: 'production' | 'preproduction' | 'staging';
|
|
748
|
-
/**
|
|
749
|
-
* @deprecated Use `runtimeEnv` instead. Kept for backward compatibility.
|
|
750
|
-
*/
|
|
751
|
-
environment?: 'production' | 'staging';
|
|
752
|
-
baseApiUrl?: string;
|
|
753
|
-
witnessUrl?: string;
|
|
754
|
-
rpcUrl?: string;
|
|
755
|
-
/** Optional bearer token for hybrid auth */
|
|
756
|
-
authorizationToken?: string;
|
|
757
|
-
/** Optional async token provider for indexer auth in long-lived clients */
|
|
758
|
-
getAuthorizationToken?: AuthorizationTokenProvider;
|
|
759
|
-
/** Optional API key for indexer proxy authentication */
|
|
760
|
-
indexerApiKey?: string;
|
|
761
|
-
/** Optional indexer URL override */
|
|
762
|
-
indexerUrl?: string;
|
|
763
|
-
/** Optional timeout configuration */
|
|
764
|
-
timeouts?: TimeoutConfig;
|
|
765
|
-
};
|
|
766
740
|
/**
|
|
767
741
|
* Callback function for transaction actions
|
|
768
742
|
* @param params - Transaction callback parameters
|
|
@@ -1635,7 +1609,6 @@ declare class Zkp2pClient {
|
|
|
1635
1609
|
private normalizeCurrencyTuples;
|
|
1636
1610
|
supportsInlineOracleRateConfig(params?: {
|
|
1637
1611
|
escrowAddress?: Address;
|
|
1638
|
-
preferV2?: boolean;
|
|
1639
1612
|
}): boolean;
|
|
1640
1613
|
private parseManagerFeeFromRead;
|
|
1641
1614
|
private getAbiFunction;
|
|
@@ -1938,7 +1911,6 @@ declare class Zkp2pClient {
|
|
|
1938
1911
|
* @param params.amount - Minimum required allowance amount
|
|
1939
1912
|
* @param params.spender - Spender address override
|
|
1940
1913
|
* @param params.escrowAddress - Escrow context used for default spender resolution
|
|
1941
|
-
* @param params.preferV2 - Prefer EscrowV2 for default spender resolution
|
|
1942
1914
|
* @param params.maxApprove - If true, approves MaxUint256 instead of exact amount
|
|
1943
1915
|
* @param params.txOverrides - Optional viem transaction overrides
|
|
1944
1916
|
* @returns Object with `hadAllowance` (true if no approval needed) and optional `hash`
|
|
@@ -1962,7 +1934,6 @@ declare class Zkp2pClient {
|
|
|
1962
1934
|
amount: bigint;
|
|
1963
1935
|
spender?: Address;
|
|
1964
1936
|
escrowAddress?: Address;
|
|
1965
|
-
preferV2?: boolean;
|
|
1966
1937
|
maxApprove?: boolean;
|
|
1967
1938
|
txOverrides?: TxOverrides;
|
|
1968
1939
|
}): Promise<{
|
|
@@ -2908,7 +2879,9 @@ declare class Zkp2pClient {
|
|
|
2908
2879
|
* @returns Intent parameters needed for fulfillment
|
|
2909
2880
|
* @throws Error if intent not found or payee details cannot be resolved
|
|
2910
2881
|
*/
|
|
2911
|
-
getFulfillIntentInputs(intentHash: `0x${string}
|
|
2882
|
+
getFulfillIntentInputs(intentHash: `0x${string}`, options?: {
|
|
2883
|
+
orchestratorAddress?: `0x${string}`;
|
|
2884
|
+
}): Promise<{
|
|
2912
2885
|
amount: string;
|
|
2913
2886
|
fiatCurrency: `0x${string}`;
|
|
2914
2887
|
conversionRate: string;
|
|
@@ -2976,4 +2949,4 @@ type SendBatchFn = (txs: Array<{
|
|
|
2976
2949
|
value?: bigint;
|
|
2977
2950
|
}>) => Promise<string>;
|
|
2978
2951
|
|
|
2979
|
-
export { type GetDepositByIdResponse as $, type AuthorizationTokenProvider as A, type QuoteResponseObject as B, type CurrencyType as C, type DepositWithRelations as D, type QuoteSingleResponse as E, type FulfillIntentMethodParams as F, type GetPayeeDetailsRequest as G, type QuoteIntentResponse as H, type IntentEntity as I, type QuoteFeesResponse as J, type FiatResponse as K, type TokenResponse as L, type NearbySuggestions as M, type NearbyQuote as N, type ApiDeposit as O, type PostDepositDetailsRequest as P, type QuoteRequest as Q, type ReferrerFeeConfig as R, type SignalIntentReferralFee as S, type TxOverrides as T, type DepositVerifier as U, type ValidatePayeeDetailsRequest as V, type WithdrawDepositParams as W, type DepositVerifierCurrency as X, type DepositStatus as Y, Zkp2pClient as Z, type GetDepositByIdRequest as _, type ValidatePayeeDetailsResponse as a, getCurrencyInfoFromCountryCode as a$, type Intent as a0, type ApiIntentStatus as a1, type GetOwnerIntentsRequest as a2, type GetOwnerIntentsResponse as a3, type GetIntentsByDepositRequest as a4, type GetIntentsByDepositResponse as a5, type GetIntentByHashRequest as a6, type GetIntentByHashResponse as a7, type RegisterPayeeDetailsRequest as a8, type RegisterPayeeDetailsResponse as a9, type ManagerStatsEntity as aA, type ManagerDailySnapshotEntity as aB, type RateManagerListItem as aC, type RateManagerDetail as aD, type ManualRateUpdateEntity as aE, type OracleConfigUpdateEntity as aF, type DepositFundActivityEntity as aG, type DepositDailySnapshotEntity as aH, type DepositFundActivityType as aI, type DepositFilter as aJ, type PaginationOptions as aK, type DepositOrderField as aL, type OrderDirection$1 as aM, type RateManagerFilter as aN, type RateManagerPaginationOptions as aO, type RateManagerDelegationPaginationOptions as aP, type RateManagerOrderField as aQ, type OrderDirection as aR, type DeploymentEnv as aS, type FulfillmentRecord as aT, type PaymentVerifiedRecord as aU, type FulfillmentAndPaymentResponse as aV, PAYMENT_PLATFORMS as aW, type PaymentPlatformType as aX, Currency as aY, currencyInfo as aZ, getCurrencyInfoFromHash as a_, type OnchainCurrency as aa, type DepositVerifierData as ab, type PreparedTransaction as ac, type OrderStats as ad, type DepositIntentStatistics as ae, type TakerTier as af, type TakerTierStats as ag, type TakerTierLevel as ah, type PlatformLimit as ai, type PlatformRiskLevel as aj, IndexerClient as ak, defaultIndexerEndpoint as al, IndexerDepositService as am, IndexerRateManagerService as an, compareEventCursorIdsByRecency as ao, fetchFulfillmentAndPayment as ap, type DepositEntity as aq, type IntentFulfilledEntity as ar, type IntentFulfillmentAmountsEntity as as, type DepositPaymentMethodEntity as at, type MethodCurrencyEntity as au, type IntentStatus as av, type RateManagerEntity as aw, type RateManagerRateEntity as ax, type RateManagerDelegationEntity as ay, type ManagerAggregateStatsEntity as az, type PostDepositDetailsResponse as b, getCurrencyCodeFromHash as b0, isSupportedCurrencyHash as b1, mapConversionRatesToOnchainMinRate as b2, type CurrencyData as b3, getContracts as b4, getRateManagerContracts as b5, getPaymentMethodsCatalog as b6, getGatingServiceAddress as b7,
|
|
2952
|
+
export { type GetDepositByIdResponse as $, type AuthorizationTokenProvider as A, type QuoteResponseObject as B, type CurrencyType as C, type DepositWithRelations as D, type QuoteSingleResponse as E, type FulfillIntentMethodParams as F, type GetPayeeDetailsRequest as G, type QuoteIntentResponse as H, type IntentEntity as I, type QuoteFeesResponse as J, type FiatResponse as K, type TokenResponse as L, type NearbySuggestions as M, type NearbyQuote as N, type ApiDeposit as O, type PostDepositDetailsRequest as P, type QuoteRequest as Q, type ReferrerFeeConfig as R, type SignalIntentReferralFee as S, type TxOverrides as T, type DepositVerifier as U, type ValidatePayeeDetailsRequest as V, type WithdrawDepositParams as W, type DepositVerifierCurrency as X, type DepositStatus as Y, Zkp2pClient as Z, type GetDepositByIdRequest as _, type ValidatePayeeDetailsResponse as a, getCurrencyInfoFromCountryCode as a$, type Intent as a0, type ApiIntentStatus as a1, type GetOwnerIntentsRequest as a2, type GetOwnerIntentsResponse as a3, type GetIntentsByDepositRequest as a4, type GetIntentsByDepositResponse as a5, type GetIntentByHashRequest as a6, type GetIntentByHashResponse as a7, type RegisterPayeeDetailsRequest as a8, type RegisterPayeeDetailsResponse as a9, type ManagerStatsEntity as aA, type ManagerDailySnapshotEntity as aB, type RateManagerListItem as aC, type RateManagerDetail as aD, type ManualRateUpdateEntity as aE, type OracleConfigUpdateEntity as aF, type DepositFundActivityEntity as aG, type DepositDailySnapshotEntity as aH, type DepositFundActivityType as aI, type DepositFilter as aJ, type PaginationOptions as aK, type DepositOrderField as aL, type OrderDirection$1 as aM, type RateManagerFilter as aN, type RateManagerPaginationOptions as aO, type RateManagerDelegationPaginationOptions as aP, type RateManagerOrderField as aQ, type OrderDirection as aR, type DeploymentEnv as aS, type FulfillmentRecord as aT, type PaymentVerifiedRecord as aU, type FulfillmentAndPaymentResponse as aV, PAYMENT_PLATFORMS as aW, type PaymentPlatformType as aX, Currency as aY, currencyInfo as aZ, getCurrencyInfoFromHash as a_, type OnchainCurrency as aa, type DepositVerifierData as ab, type PreparedTransaction as ac, type OrderStats as ad, type DepositIntentStatistics as ae, type TakerTier as af, type TakerTierStats as ag, type TakerTierLevel as ah, type PlatformLimit as ai, type PlatformRiskLevel as aj, IndexerClient as ak, defaultIndexerEndpoint as al, IndexerDepositService as am, IndexerRateManagerService as an, compareEventCursorIdsByRecency as ao, fetchFulfillmentAndPayment as ap, type DepositEntity as aq, type IntentFulfilledEntity as ar, type IntentFulfillmentAmountsEntity as as, type DepositPaymentMethodEntity as at, type MethodCurrencyEntity as au, type IntentStatus as av, type RateManagerEntity as aw, type RateManagerRateEntity as ax, type RateManagerDelegationEntity as ay, type ManagerAggregateStatsEntity as az, type PostDepositDetailsResponse as b, getCurrencyCodeFromHash as b0, isSupportedCurrencyHash as b1, mapConversionRatesToOnchainMinRate as b2, type CurrencyData as b3, getContracts as b4, getRateManagerContracts as b5, getPaymentMethodsCatalog as b6, getGatingServiceAddress as b7, type RuntimeEnv as b8, parseDepositView as b9, parseIntentView as ba, enrichPvDepositView as bb, enrichPvIntentView as bc, type PV_DepositView as bd, type PV_Deposit as be, type PV_PaymentMethodData as bf, type PV_Currency as bg, type PV_ReferralFee as bh, type PV_IntentView as bi, type PV_Intent as bj, ZERO_RATE_MANAGER_ID as bk, isZeroRateManagerId as bl, normalizeRateManagerId as bm, normalizeRegistry as bn, getDelegationRoute as bo, classifyDelegationState as bp, type DelegationRoute as bq, type DelegationState as br, type DelegationDepositTarget as bs, type BatchResult as bt, type SendTransactionFn as bu, type SendBatchFn as bv, ZERO_ADDRESS as bw, asErrorMessage as bx, assertDelegationMethodSupport as by, type GetPayeeDetailsResponse as c, type GetOwnerDepositsRequest as d, type GetOwnerDepositsResponse as e, type GetTakerTierRequest as f, type GetTakerTierResponse as g, type PaymentMethodCatalog as h, type SignalIntentMethodParams as i, type CancelIntentMethodParams as j, type Zkp2pNextOptions as k, type TimeoutConfig as l, type ActionCallback as m, type CreateDepositParams as n, type CreateDepositConversionRate as o, type Range as p, type SignalIntentParams as q, type FulfillIntentParams as r, type ReleaseFundsToPayerParams as s, type CancelIntentParams as t, type GetNearbyQuote as u, type GetNearbySuggestions as v, type GetQuoteResponse as w, type GetQuoteResponseObject as x, type GetQuoteSingleResponse as y, type QuoteResponse as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _zkp2p_indexer_schema from '@zkp2p/indexer-schema';
|
|
2
2
|
import { Deposit, DepositStatus as DepositStatus$2, IntentStatus as IntentStatus$1, DepositPaymentMethod, MethodCurrency, Intent as Intent$1, RateManager, ManagerAggregateStats, RateManagerRate, ManagerStats, DepositFundActivity, DepositDailySnapshot, ManagerDailySnapshot } from '@zkp2p/indexer-schema';
|
|
3
|
-
import { Address, Hex, AccessList, AuthorizationList,
|
|
3
|
+
import { Address, Hex, AccessList, AuthorizationList, Hash, WalletClient, PublicClient } from 'viem';
|
|
4
4
|
import { Abi } from 'abitype';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -161,7 +161,6 @@ declare function isSupportedCurrencyHash(hash: string): boolean;
|
|
|
161
161
|
* @module contracts
|
|
162
162
|
*/
|
|
163
163
|
|
|
164
|
-
declare const HISTORICAL_ESCROW_ADDRESSES: Record<string, `0x${string}`[]>;
|
|
165
164
|
/**
|
|
166
165
|
* Contract addresses for a specific deployment.
|
|
167
166
|
*/
|
|
@@ -283,7 +282,7 @@ declare function getPaymentMethodsCatalog(_chainId: number, env?: RuntimeEnv): P
|
|
|
283
282
|
* @param env - Runtime environment
|
|
284
283
|
* @returns Gating service signer address
|
|
285
284
|
*/
|
|
286
|
-
declare function getGatingServiceAddress(_chainId: number,
|
|
285
|
+
declare function getGatingServiceAddress(_chainId: number, _env?: RuntimeEnv): `0x${string}`;
|
|
287
286
|
declare function getRateManagerContracts(chainId: number, env?: RuntimeEnv): {
|
|
288
287
|
addresses: {
|
|
289
288
|
registry: `0x${string}`;
|
|
@@ -738,31 +737,6 @@ type TimeoutConfig = {
|
|
|
738
737
|
transaction?: number;
|
|
739
738
|
};
|
|
740
739
|
type AuthorizationTokenProvider = () => string | null | undefined | Promise<string | null | undefined>;
|
|
741
|
-
type Zkp2pClientOptions = {
|
|
742
|
-
walletClient: WalletClient;
|
|
743
|
-
/** Curator API key for authenticated endpoints (optional for basic deposit/payee flows) */
|
|
744
|
-
apiKey?: string;
|
|
745
|
-
chainId: number;
|
|
746
|
-
/** Runtime environment (defaults to 'production') */
|
|
747
|
-
runtimeEnv?: 'production' | 'preproduction' | 'staging';
|
|
748
|
-
/**
|
|
749
|
-
* @deprecated Use `runtimeEnv` instead. Kept for backward compatibility.
|
|
750
|
-
*/
|
|
751
|
-
environment?: 'production' | 'staging';
|
|
752
|
-
baseApiUrl?: string;
|
|
753
|
-
witnessUrl?: string;
|
|
754
|
-
rpcUrl?: string;
|
|
755
|
-
/** Optional bearer token for hybrid auth */
|
|
756
|
-
authorizationToken?: string;
|
|
757
|
-
/** Optional async token provider for indexer auth in long-lived clients */
|
|
758
|
-
getAuthorizationToken?: AuthorizationTokenProvider;
|
|
759
|
-
/** Optional API key for indexer proxy authentication */
|
|
760
|
-
indexerApiKey?: string;
|
|
761
|
-
/** Optional indexer URL override */
|
|
762
|
-
indexerUrl?: string;
|
|
763
|
-
/** Optional timeout configuration */
|
|
764
|
-
timeouts?: TimeoutConfig;
|
|
765
|
-
};
|
|
766
740
|
/**
|
|
767
741
|
* Callback function for transaction actions
|
|
768
742
|
* @param params - Transaction callback parameters
|
|
@@ -1635,7 +1609,6 @@ declare class Zkp2pClient {
|
|
|
1635
1609
|
private normalizeCurrencyTuples;
|
|
1636
1610
|
supportsInlineOracleRateConfig(params?: {
|
|
1637
1611
|
escrowAddress?: Address;
|
|
1638
|
-
preferV2?: boolean;
|
|
1639
1612
|
}): boolean;
|
|
1640
1613
|
private parseManagerFeeFromRead;
|
|
1641
1614
|
private getAbiFunction;
|
|
@@ -1938,7 +1911,6 @@ declare class Zkp2pClient {
|
|
|
1938
1911
|
* @param params.amount - Minimum required allowance amount
|
|
1939
1912
|
* @param params.spender - Spender address override
|
|
1940
1913
|
* @param params.escrowAddress - Escrow context used for default spender resolution
|
|
1941
|
-
* @param params.preferV2 - Prefer EscrowV2 for default spender resolution
|
|
1942
1914
|
* @param params.maxApprove - If true, approves MaxUint256 instead of exact amount
|
|
1943
1915
|
* @param params.txOverrides - Optional viem transaction overrides
|
|
1944
1916
|
* @returns Object with `hadAllowance` (true if no approval needed) and optional `hash`
|
|
@@ -1962,7 +1934,6 @@ declare class Zkp2pClient {
|
|
|
1962
1934
|
amount: bigint;
|
|
1963
1935
|
spender?: Address;
|
|
1964
1936
|
escrowAddress?: Address;
|
|
1965
|
-
preferV2?: boolean;
|
|
1966
1937
|
maxApprove?: boolean;
|
|
1967
1938
|
txOverrides?: TxOverrides;
|
|
1968
1939
|
}): Promise<{
|
|
@@ -2908,7 +2879,9 @@ declare class Zkp2pClient {
|
|
|
2908
2879
|
* @returns Intent parameters needed for fulfillment
|
|
2909
2880
|
* @throws Error if intent not found or payee details cannot be resolved
|
|
2910
2881
|
*/
|
|
2911
|
-
getFulfillIntentInputs(intentHash: `0x${string}
|
|
2882
|
+
getFulfillIntentInputs(intentHash: `0x${string}`, options?: {
|
|
2883
|
+
orchestratorAddress?: `0x${string}`;
|
|
2884
|
+
}): Promise<{
|
|
2912
2885
|
amount: string;
|
|
2913
2886
|
fiatCurrency: `0x${string}`;
|
|
2914
2887
|
conversionRate: string;
|
|
@@ -2976,4 +2949,4 @@ type SendBatchFn = (txs: Array<{
|
|
|
2976
2949
|
value?: bigint;
|
|
2977
2950
|
}>) => Promise<string>;
|
|
2978
2951
|
|
|
2979
|
-
export { type GetDepositByIdResponse as $, type AuthorizationTokenProvider as A, type QuoteResponseObject as B, type CurrencyType as C, type DepositWithRelations as D, type QuoteSingleResponse as E, type FulfillIntentMethodParams as F, type GetPayeeDetailsRequest as G, type QuoteIntentResponse as H, type IntentEntity as I, type QuoteFeesResponse as J, type FiatResponse as K, type TokenResponse as L, type NearbySuggestions as M, type NearbyQuote as N, type ApiDeposit as O, type PostDepositDetailsRequest as P, type QuoteRequest as Q, type ReferrerFeeConfig as R, type SignalIntentReferralFee as S, type TxOverrides as T, type DepositVerifier as U, type ValidatePayeeDetailsRequest as V, type WithdrawDepositParams as W, type DepositVerifierCurrency as X, type DepositStatus as Y, Zkp2pClient as Z, type GetDepositByIdRequest as _, type ValidatePayeeDetailsResponse as a, getCurrencyInfoFromCountryCode as a$, type Intent as a0, type ApiIntentStatus as a1, type GetOwnerIntentsRequest as a2, type GetOwnerIntentsResponse as a3, type GetIntentsByDepositRequest as a4, type GetIntentsByDepositResponse as a5, type GetIntentByHashRequest as a6, type GetIntentByHashResponse as a7, type RegisterPayeeDetailsRequest as a8, type RegisterPayeeDetailsResponse as a9, type ManagerStatsEntity as aA, type ManagerDailySnapshotEntity as aB, type RateManagerListItem as aC, type RateManagerDetail as aD, type ManualRateUpdateEntity as aE, type OracleConfigUpdateEntity as aF, type DepositFundActivityEntity as aG, type DepositDailySnapshotEntity as aH, type DepositFundActivityType as aI, type DepositFilter as aJ, type PaginationOptions as aK, type DepositOrderField as aL, type OrderDirection$1 as aM, type RateManagerFilter as aN, type RateManagerPaginationOptions as aO, type RateManagerDelegationPaginationOptions as aP, type RateManagerOrderField as aQ, type OrderDirection as aR, type DeploymentEnv as aS, type FulfillmentRecord as aT, type PaymentVerifiedRecord as aU, type FulfillmentAndPaymentResponse as aV, PAYMENT_PLATFORMS as aW, type PaymentPlatformType as aX, Currency as aY, currencyInfo as aZ, getCurrencyInfoFromHash as a_, type OnchainCurrency as aa, type DepositVerifierData as ab, type PreparedTransaction as ac, type OrderStats as ad, type DepositIntentStatistics as ae, type TakerTier as af, type TakerTierStats as ag, type TakerTierLevel as ah, type PlatformLimit as ai, type PlatformRiskLevel as aj, IndexerClient as ak, defaultIndexerEndpoint as al, IndexerDepositService as am, IndexerRateManagerService as an, compareEventCursorIdsByRecency as ao, fetchFulfillmentAndPayment as ap, type DepositEntity as aq, type IntentFulfilledEntity as ar, type IntentFulfillmentAmountsEntity as as, type DepositPaymentMethodEntity as at, type MethodCurrencyEntity as au, type IntentStatus as av, type RateManagerEntity as aw, type RateManagerRateEntity as ax, type RateManagerDelegationEntity as ay, type ManagerAggregateStatsEntity as az, type PostDepositDetailsResponse as b, getCurrencyCodeFromHash as b0, isSupportedCurrencyHash as b1, mapConversionRatesToOnchainMinRate as b2, type CurrencyData as b3, getContracts as b4, getRateManagerContracts as b5, getPaymentMethodsCatalog as b6, getGatingServiceAddress as b7,
|
|
2952
|
+
export { type GetDepositByIdResponse as $, type AuthorizationTokenProvider as A, type QuoteResponseObject as B, type CurrencyType as C, type DepositWithRelations as D, type QuoteSingleResponse as E, type FulfillIntentMethodParams as F, type GetPayeeDetailsRequest as G, type QuoteIntentResponse as H, type IntentEntity as I, type QuoteFeesResponse as J, type FiatResponse as K, type TokenResponse as L, type NearbySuggestions as M, type NearbyQuote as N, type ApiDeposit as O, type PostDepositDetailsRequest as P, type QuoteRequest as Q, type ReferrerFeeConfig as R, type SignalIntentReferralFee as S, type TxOverrides as T, type DepositVerifier as U, type ValidatePayeeDetailsRequest as V, type WithdrawDepositParams as W, type DepositVerifierCurrency as X, type DepositStatus as Y, Zkp2pClient as Z, type GetDepositByIdRequest as _, type ValidatePayeeDetailsResponse as a, getCurrencyInfoFromCountryCode as a$, type Intent as a0, type ApiIntentStatus as a1, type GetOwnerIntentsRequest as a2, type GetOwnerIntentsResponse as a3, type GetIntentsByDepositRequest as a4, type GetIntentsByDepositResponse as a5, type GetIntentByHashRequest as a6, type GetIntentByHashResponse as a7, type RegisterPayeeDetailsRequest as a8, type RegisterPayeeDetailsResponse as a9, type ManagerStatsEntity as aA, type ManagerDailySnapshotEntity as aB, type RateManagerListItem as aC, type RateManagerDetail as aD, type ManualRateUpdateEntity as aE, type OracleConfigUpdateEntity as aF, type DepositFundActivityEntity as aG, type DepositDailySnapshotEntity as aH, type DepositFundActivityType as aI, type DepositFilter as aJ, type PaginationOptions as aK, type DepositOrderField as aL, type OrderDirection$1 as aM, type RateManagerFilter as aN, type RateManagerPaginationOptions as aO, type RateManagerDelegationPaginationOptions as aP, type RateManagerOrderField as aQ, type OrderDirection as aR, type DeploymentEnv as aS, type FulfillmentRecord as aT, type PaymentVerifiedRecord as aU, type FulfillmentAndPaymentResponse as aV, PAYMENT_PLATFORMS as aW, type PaymentPlatformType as aX, Currency as aY, currencyInfo as aZ, getCurrencyInfoFromHash as a_, type OnchainCurrency as aa, type DepositVerifierData as ab, type PreparedTransaction as ac, type OrderStats as ad, type DepositIntentStatistics as ae, type TakerTier as af, type TakerTierStats as ag, type TakerTierLevel as ah, type PlatformLimit as ai, type PlatformRiskLevel as aj, IndexerClient as ak, defaultIndexerEndpoint as al, IndexerDepositService as am, IndexerRateManagerService as an, compareEventCursorIdsByRecency as ao, fetchFulfillmentAndPayment as ap, type DepositEntity as aq, type IntentFulfilledEntity as ar, type IntentFulfillmentAmountsEntity as as, type DepositPaymentMethodEntity as at, type MethodCurrencyEntity as au, type IntentStatus as av, type RateManagerEntity as aw, type RateManagerRateEntity as ax, type RateManagerDelegationEntity as ay, type ManagerAggregateStatsEntity as az, type PostDepositDetailsResponse as b, getCurrencyCodeFromHash as b0, isSupportedCurrencyHash as b1, mapConversionRatesToOnchainMinRate as b2, type CurrencyData as b3, getContracts as b4, getRateManagerContracts as b5, getPaymentMethodsCatalog as b6, getGatingServiceAddress as b7, type RuntimeEnv as b8, parseDepositView as b9, parseIntentView as ba, enrichPvDepositView as bb, enrichPvIntentView as bc, type PV_DepositView as bd, type PV_Deposit as be, type PV_PaymentMethodData as bf, type PV_Currency as bg, type PV_ReferralFee as bh, type PV_IntentView as bi, type PV_Intent as bj, ZERO_RATE_MANAGER_ID as bk, isZeroRateManagerId as bl, normalizeRateManagerId as bm, normalizeRegistry as bn, getDelegationRoute as bo, classifyDelegationState as bp, type DelegationRoute as bq, type DelegationState as br, type DelegationDepositTarget as bs, type BatchResult as bt, type SendTransactionFn as bu, type SendBatchFn as bv, ZERO_ADDRESS as bw, asErrorMessage as bx, assertDelegationMethodSupport as by, type GetPayeeDetailsResponse as c, type GetOwnerDepositsRequest as d, type GetOwnerDepositsResponse as e, type GetTakerTierRequest as f, type GetTakerTierResponse as g, type PaymentMethodCatalog as h, type SignalIntentMethodParams as i, type CancelIntentMethodParams as j, type Zkp2pNextOptions as k, type TimeoutConfig as l, type ActionCallback as m, type CreateDepositParams as n, type CreateDepositConversionRate as o, type Range as p, type SignalIntentParams as q, type FulfillIntentParams as r, type ReleaseFundsToPayerParams as s, type CancelIntentParams as t, type GetNearbyQuote as u, type GetNearbySuggestions as v, type GetQuoteResponse as w, type GetQuoteResponseObject as x, type GetQuoteSingleResponse as y, type QuoteResponse as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zkp2p/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "ZKP2P Client SDK - TypeScript SDK for deposit management, liquidity provision, and onramping",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -36,6 +36,19 @@
|
|
|
36
36
|
]
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsup",
|
|
41
|
+
"clean": "rimraf dist",
|
|
42
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
43
|
+
"lint": "eslint . --ext .ts,.tsx",
|
|
44
|
+
"format": "prettier --check .",
|
|
45
|
+
"format:write": "prettier --write .",
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"test:coverage": "vitest run --coverage",
|
|
48
|
+
"test:watch": "vitest",
|
|
49
|
+
"release": "release-it",
|
|
50
|
+
"docs": "typedoc"
|
|
51
|
+
},
|
|
39
52
|
"files": [
|
|
40
53
|
"dist",
|
|
41
54
|
"README.md",
|
|
@@ -81,6 +94,7 @@
|
|
|
81
94
|
"devDependencies": {
|
|
82
95
|
"@testing-library/react": "^16.1.0",
|
|
83
96
|
"@vitest/coverage-v8": "^1.6.1",
|
|
97
|
+
"@zkp2p/core": "workspace:*",
|
|
84
98
|
"@release-it/conventional-changelog": "^9.0.4",
|
|
85
99
|
"@types/node": "^20.10.0",
|
|
86
100
|
"@types/react": "^19.1.11",
|
|
@@ -99,8 +113,7 @@
|
|
|
99
113
|
"typedoc": "^0.25.12",
|
|
100
114
|
"typescript": "^5.4.0",
|
|
101
115
|
"typescript-eslint": "^8.50.1",
|
|
102
|
-
"vitest": "^1.5.0"
|
|
103
|
-
"@zkp2p/core": "0.0.1"
|
|
116
|
+
"vitest": "^1.5.0"
|
|
104
117
|
},
|
|
105
118
|
"peerDependencies": {
|
|
106
119
|
"react": ">=16.8.0",
|
|
@@ -110,18 +123,5 @@
|
|
|
110
123
|
"react": {
|
|
111
124
|
"optional": true
|
|
112
125
|
}
|
|
113
|
-
},
|
|
114
|
-
"scripts": {
|
|
115
|
-
"build": "tsup",
|
|
116
|
-
"clean": "rimraf dist",
|
|
117
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
118
|
-
"lint": "eslint . --ext .ts,.tsx",
|
|
119
|
-
"format": "prettier --check .",
|
|
120
|
-
"format:write": "prettier --write .",
|
|
121
|
-
"test": "vitest run",
|
|
122
|
-
"test:coverage": "vitest run --coverage",
|
|
123
|
-
"test:watch": "vitest",
|
|
124
|
-
"release": "release-it",
|
|
125
|
-
"docs": "typedoc"
|
|
126
126
|
}
|
|
127
|
-
}
|
|
127
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/bigint.ts","../src/contracts.ts","../src/utils/bytes32.ts","../src/utils/paymentMethodHashes.ts","../src/utils/paymentResolution.ts","../src/utils/protocolViewerParsers.ts"],"names":["baseStagingPaymentMethods"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAO,SAAS,eAAA,CACd,KAAA,EACA,YAAA,GAAe,2BAAA,EACP;AACR,EAA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,IAAA,EACA,OAAA,EACA,GAAA,GAAkB,YAAA,EAClB;AACA,EAAA,MAAM,OAAA,GAAU,wBAAA,CAAyB,OAAA,EAAS,GAAG,CAAA;AACrD,EAAA,OAAO;AAAA,IACL,GAAG,IAAA;AAAA,IACH,MAAA,EAAQ;AAAA,MACN,GAAG,IAAA,CAAK,MAAA;AAAA,MACR,aAAA,EAAe,gCAAA,CAAiC,IAAA,CAAK,MAAA,CAAO,eAAe,OAAO,CAAA;AAAA,MAClF,YAAA,EAAc,uBAAA,CAAwB,IAAA,CAAK,MAAA,CAAO,YAAY;AAAA,KAChE;AAAA,IACA,OAAA,EAAS,mBAAA,CAAoB,IAAA,CAAK,OAAA,EAAgB,SAAS,GAAG;AAAA,GAChE;AACF","file":"chunk-J33LUXNA.mjs","sourcesContent":["export function parseBigIntLike(\n value: unknown,\n errorMessage = 'Unsupported numeric value',\n): bigint {\n if (typeof value === 'bigint') return value;\n if (typeof value === 'number') return BigInt(value);\n if (typeof value === 'string') {\n const normalized = value.trim();\n if (!normalized) throw new Error(errorMessage);\n return BigInt(normalized);\n }\n\n if (value && typeof (value as { toString?: () => string }).toString === 'function') {\n const normalized = (value as { toString: () => string }).toString().trim();\n if (!normalized) throw new Error(errorMessage);\n return BigInt(normalized);\n }\n\n throw new Error(errorMessage);\n}\n","/**\n * Contract resolution utilities for the SDK.\n *\n * Provides access to deployed contract addresses and ABIs for different\n * networks (Base) and environments (production, staging).\n *\n * @module contracts\n */\n\nimport type { Abi } from 'abitype';\n\n// Typed imports from @zkp2p/contracts-v2 (module declarations provided in src/@types)\n// Use *Raw suffix for imports that need runtime normalization (addresses, constants)\nimport baseAddressesRaw from '@zkp2p/contracts-v2/addresses/base';\nimport baseStagingAddressesRaw from '@zkp2p/contracts-v2/addresses/baseStaging';\nimport * as baseAbisRaw from '@zkp2p/contracts-v2/abis/base';\nimport * as baseStagingAbisRaw from '@zkp2p/contracts-v2/abis/baseStaging';\n\nimport EscrowBase from '@zkp2p/contracts-v2/abis/base/Escrow.json';\nimport OrchestratorBase from '@zkp2p/contracts-v2/abis/base/Orchestrator.json';\nimport ProtocolViewerBase from '@zkp2p/contracts-v2/abis/base/ProtocolViewer.json';\nimport UnifiedPaymentVerifierBase from '@zkp2p/contracts-v2/abis/base/UnifiedPaymentVerifier.json';\n\nimport EscrowBaseStaging from '@zkp2p/contracts-v2/abis/baseStaging/Escrow.json';\nimport OrchestratorBaseStaging from '@zkp2p/contracts-v2/abis/baseStaging/Orchestrator.json';\nimport UnifiedPaymentVerifierBaseStaging from '@zkp2p/contracts-v2/abis/baseStaging/UnifiedPaymentVerifier.json';\nimport ProtocolViewerBaseStaging from '@zkp2p/contracts-v2/abis/baseStaging/ProtocolViewer.json';\n\nimport baseConstantsRaw from '@zkp2p/contracts-v2/constants/base';\nimport baseStagingConstantsRaw from '@zkp2p/contracts-v2/constants/baseStaging';\n// Payment methods catalogs (JSON). Import statically so ESM bundlers include the data.\n// These modules are present in @zkp2p/contracts-v2; tsconfig sets resolveJsonModule: true\nimport basePaymentMethodsRaw from '@zkp2p/contracts-v2/paymentMethods/base.json';\nimport baseStagingPaymentMethodsRaw from '@zkp2p/contracts-v2/paymentMethods/baseStaging.json';\n\n// ---------------------------------------------------------------------------\n// Runtime normalization helpers for ESM/CJS interoperability\n// ---------------------------------------------------------------------------\n// In certain runtimes (tsx, Node ESM), deep imports from @zkp2p/contracts-v2\n// resolve as { default: [Getter] } or { default: { contracts: {...} } } instead\n// of the expected shape. These helpers unwrap the actual data regardless of shape.\n\n/**\n * Normalize address module shape. Handles:\n * - { contracts: {...} } (direct)\n * - { default: { contracts: {...} } } (wrapped)\n * - { default: [Getter] } (lazy)\n */\nfunction unwrapAddresses(mod: unknown): {\n name?: string;\n chainId?: number;\n contracts?: Record<string, `0x${string}`>;\n} {\n if (!mod) return {} as ReturnType<typeof unwrapAddresses>;\n const m = mod as Record<string, unknown>;\n // Direct shape\n if (m.contracts) return m as ReturnType<typeof unwrapAddresses>;\n // Wrapped shape\n if ((m.default as Record<string, unknown>)?.contracts)\n return m.default as ReturnType<typeof unwrapAddresses>;\n // Lazy getter shape\n try {\n const d = typeof m.default === 'function' ? (m.default as () => unknown)() : m.default;\n if ((d as Record<string, unknown>)?.contracts) return d as ReturnType<typeof unwrapAddresses>;\n } catch {\n // ignore\n }\n return m as ReturnType<typeof unwrapAddresses>;\n}\n\n/**\n * Normalize payment methods module shape. Handles:\n * - { methods: {...} } (direct)\n * - { default: { methods: {...} } } (wrapped)\n * - { default: [Getter] } (lazy)\n */\nfunction unwrapMethods(mod: unknown): {\n methods?: Record<string, { paymentMethodHash: `0x${string}`; currencies?: `0x${string}`[] }>;\n} {\n if (!mod) return {} as ReturnType<typeof unwrapMethods>;\n const m = mod as Record<string, unknown>;\n if (m.methods) return m as ReturnType<typeof unwrapMethods>;\n if ((m.default as Record<string, unknown>)?.methods)\n return m.default as ReturnType<typeof unwrapMethods>;\n try {\n const d = typeof m.default === 'function' ? (m.default as () => unknown)() : m.default;\n if ((d as Record<string, unknown>)?.methods) return d as ReturnType<typeof unwrapMethods>;\n } catch {\n // ignore\n }\n return m as ReturnType<typeof unwrapMethods>;\n}\n\n/**\n * Normalize constants module shape (for USDC address, etc.)\n */\nfunction unwrapConstants(mod: unknown): Record<string, unknown> {\n if (!mod) return {};\n const m = mod as Record<string, unknown>;\n if (m.USDC) return m;\n if ((m.default as Record<string, unknown>)?.USDC) return m.default as Record<string, unknown>;\n try {\n const d = typeof m.default === 'function' ? (m.default as () => unknown)() : m.default;\n if ((d as Record<string, unknown>)?.USDC) return d as Record<string, unknown>;\n } catch {\n // ignore\n }\n return m;\n}\n\n// ---------------------------------------------------------------------------\n// Historical escrow addresses\n// ---------------------------------------------------------------------------\n// Escrow addresses from prior deployments. Merged into escrowAddresses so\n// deposits from retired escrows remain queryable. Current addresses come from\n// contracts-v2 dynamically.\n// Source of truth for what the indexer indexes:\n// STAGING: zkp2p-indexer releases/staging config.base_staging.yaml\n// PROD: zkp2p-indexer main config.base_prod.yaml\n\nexport const HISTORICAL_ESCROW_ADDRESSES: Record<string, `0x${string}`[]> = {\n base: [\n '0x2f121CDDCA6d652f35e8B3E560f9760898888888', // EscrowV2 production (contracts-v2 0.2.0-rc.6)\n ],\n base_staging: [\n '0x5C2a8D9246777eE4501B6C426a8B8C7635C7b5b5', // EscrowV2 staging (contracts-v2 0.2.0-rc.5)\n '0x18EAcBf3FF19528ABe8035CF5cA266F31A2e3f14', // EscrowV2 staging (contracts-v2 0.1.11-rc.3)\n '0x07Cc97c254A5Fb0957553E9F58E4040699357f28', // EscrowV2 staging (contracts-v2 0.1.11-rc.2)\n '0x8455b9a31041125C785044f45458eCf2cbB12eF7', // v2.1 staging Escrow (2025-10-18, PR #83)\n '0x21f007107269ea1c8Fe0730736548090F4945736', // v2.1 staging Escrow (2025-10-04, PR #71)\n ],\n};\n\nexport const HISTORICAL_ORCHESTRATOR_ADDRESSES: Record<string, `0x${string}`[]> = {\n base: [\n '0x88888883Ed048FF0a415271B28b2F52d431810D0', // OrchestratorV2 production (contracts-v2 0.2.0-rc.6)\n ],\n base_staging: [\n '0xF9b9CD27Deea496B960b3cb5221b514705fCaF5e', // OrchestratorV2 staging (contracts-v2 0.2.0-rc.5)\n '0xC0389b3d7A4E6B823e361e562C4a29F04B6C4fB5', // OrchestratorV2 staging (contracts-v2 0.1.11-rc.3)\n ],\n};\n\nconst STAGING_ESCROW_V2_FALLBACK = '0x77e8f808FE201075e0bD651CD46fdF239fc83265';\nconst STAGING_ORCHESTRATOR_V2_FALLBACK = '0xc17a59227B136c45fAa153086a15EF87ED14bE00';\n\nconst ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';\n\nfunction isValidAddress(value?: string | null): value is `0x${string}` {\n return (\n typeof value === 'string' &&\n /^0x[a-fA-F0-9]{40}$/.test(value) &&\n value.toLowerCase() !== ZERO_ADDRESS\n );\n}\n\nfunction pickAddress(\n contracts: Record<string, string> | undefined,\n keys: string[],\n): `0x${string}` | undefined {\n if (!contracts) return undefined;\n for (const key of keys) {\n const candidate = contracts[key];\n if (isValidAddress(candidate)) return candidate;\n }\n return undefined;\n}\n\nfunction pickAbi(source: Record<string, unknown>, names: string[]): Abi | undefined {\n for (const name of names) {\n const candidate = source[name];\n if (Array.isArray(candidate)) return candidate as unknown as Abi;\n // ESM interop: import * as abis may yield { default: [...] } per entry\n if (\n candidate &&\n typeof candidate === 'object' &&\n Array.isArray((candidate as Record<string, unknown>).default)\n ) {\n return (candidate as Record<string, unknown>).default as unknown as Abi;\n }\n }\n return undefined;\n}\n\nfunction uniqueAddresses(...values: Array<string | undefined>): `0x${string}`[] {\n const seen = new Set<string>();\n const addresses: `0x${string}`[] = [];\n for (const value of values) {\n if (!isValidAddress(value)) continue;\n const normalized = value.toLowerCase();\n if (seen.has(normalized)) continue;\n seen.add(normalized);\n addresses.push(value);\n }\n return addresses;\n}\n\nfunction addressesEqual(left?: string, right?: string): boolean {\n return Boolean(left && right && left.toLowerCase() === right.toLowerCase());\n}\n\nfunction readRuntimeEnv(key: string): string | undefined {\n try {\n const meta = import.meta as { env?: Record<string, string | undefined> };\n const fromVite = meta?.env?.[key];\n if (fromVite) return fromVite;\n } catch {\n // ignore\n }\n try {\n const proc = (\n globalThis as {\n process?: { env?: Record<string, string | undefined> };\n }\n ).process;\n return proc?.env?.[key];\n } catch {\n // ignore\n }\n return undefined;\n}\n\nfunction resolveRuntimeAddressOverride(envKeys: string[]): `0x${string}` | undefined {\n for (const key of envKeys) {\n const candidate = readRuntimeEnv(key);\n if (isValidAddress(candidate)) return candidate;\n }\n return undefined;\n}\n\n// Apply runtime normalization to all imports\nconst baseAddresses = unwrapAddresses(baseAddressesRaw);\nconst baseStagingAddresses = unwrapAddresses(baseStagingAddressesRaw);\nconst basePaymentMethods = unwrapMethods(basePaymentMethodsRaw);\nconst baseStagingPaymentMethods = unwrapMethods(baseStagingPaymentMethodsRaw);\nconst baseConstants = unwrapConstants(baseConstantsRaw);\nconst baseStagingConstants = unwrapConstants(baseStagingConstantsRaw);\n\n/**\n * Contract addresses for a specific deployment.\n */\nexport type V2ContractAddresses = {\n /** Escrow contract (holds deposits and manages intents) */\n escrow: `0x${string}`;\n /** EscrowV2 contract (supports native rate-manager delegation) */\n escrowV2?: `0x${string}`;\n /** All supported upgraded escrow addresses (current first, then historical) */\n escrowAddresses?: `0x${string}`[];\n /** Orchestrator contract (handles intent signaling and fulfillment) */\n orchestrator?: `0x${string}`;\n /** OrchestratorV2 contract (queries EscrowV2 effective rates) */\n orchestratorV2?: `0x${string}`;\n /** All supported upgraded orchestrator addresses (current first, then historical) */\n orchestratorAddresses?: `0x${string}`[];\n /** UnifiedPaymentVerifier contract (verifies payment proofs) */\n unifiedPaymentVerifier?: `0x${string}`;\n /** UnifiedPaymentVerifierV2 contract (updated verifier) */\n unifiedPaymentVerifierV2?: `0x${string}`;\n /** ProtocolViewer contract (batch read operations) */\n protocolViewer?: `0x${string}`;\n /** Ordered list of all ProtocolViewer instances (primary first, legacy fallback after) */\n protocolViewerEntries?: Array<{ address: `0x${string}`; abi: Abi }>;\n /** USDC token address */\n usdc?: `0x${string}`;\n /** RateManagerV1 contract */\n rateManagerV1?: `0x${string}`;\n /** OrchestratorRegistry contract */\n orchestratorRegistry?: `0x${string}`;\n /** DepositRateManagerRegistryV1 contract */\n rateManagerRegistry?: `0x${string}`;\n /** DepositRateManagerController contract */\n rateManagerController?: `0x${string}`;\n /** ChainlinkOracleAdapter contract */\n chainlinkOracleAdapter?: `0x${string}`;\n /** PythOracleAdapter contract */\n pythOracleAdapter?: `0x${string}`;\n};\n\n/**\n * Contract ABIs for a specific deployment.\n */\nexport type V2ContractAbis = {\n escrow: Abi;\n escrowV2?: Abi;\n orchestrator?: Abi;\n orchestratorV2?: Abi;\n unifiedPaymentVerifier?: Abi;\n unifiedPaymentVerifierV2?: Abi;\n protocolViewer?: Abi;\n rateManagerV1?: Abi;\n orchestratorRegistry?: Abi;\n rateManagerRegistry?: Abi;\n rateManagerController?: Abi;\n};\n\n/**\n * Runtime environment: 'production' for mainnet, 'preproduction' for preprod\n * (production contracts + preprod indexer), 'staging' for testnet/dev.\n */\nexport type RuntimeEnv = 'production' | 'preproduction' | 'staging';\n\n/**\n * Converts a chain ID to its network key.\n * @internal\n */\nexport function networkKeyFromChainId(_chainId: number): 'base' {\n return 'base';\n}\n\n/**\n * Retrieves deployed contract addresses and ABIs for a given chain and environment.\n *\n * @param chainId - The chain ID (8453 for Base)\n * @param env - Runtime environment ('production' or 'staging')\n * @returns Object containing addresses and ABIs\n *\n * @example\n * ```typescript\n * import { getContracts } from '@zkp2p/sdk';\n *\n * const { addresses, abis } = getContracts(8453, 'production');\n * console.log(addresses.escrow); // \"0x...\"\n * console.log(addresses.usdc); // \"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913\"\n * ```\n */\nexport function getContracts(\n chainId: number,\n env: RuntimeEnv = 'production',\n): { addresses: V2ContractAddresses; abis: V2ContractAbis } {\n const key = networkKeyFromChainId(chainId);\n const baseContracts = (baseAddresses.contracts ?? {}) as Record<string, string>;\n const baseV2ProtocolViewerAbi = pickAbi(baseAbisRaw as unknown as Record<string, unknown>, [\n 'ProtocolViewerV2',\n ]);\n const baseV2ProtocolViewerAddress = pickAddress(baseContracts, ['ProtocolViewerV2']);\n const baseV1ProtocolViewerAddress = pickAddress(baseContracts, ['ProtocolViewer']);\n const baseProtocolViewerEntries = (() => {\n const entries: Array<{ address: `0x${string}`; abi: Abi }> = [];\n if (baseV2ProtocolViewerAddress && baseV2ProtocolViewerAbi) {\n entries.push({ address: baseV2ProtocolViewerAddress, abi: baseV2ProtocolViewerAbi });\n }\n if (\n baseV1ProtocolViewerAddress &&\n !addressesEqual(baseV1ProtocolViewerAddress, baseV2ProtocolViewerAddress)\n ) {\n entries.push({ address: baseV1ProtocolViewerAddress, abi: ProtocolViewerBase as Abi });\n }\n return entries.length > 0 ? entries : undefined;\n })();\n\n const addressesByKey: Record<'base', V2ContractAddresses> = {\n base: {\n escrow:\n pickAddress(baseContracts, ['EscrowV2', 'Escrow_V2']) ??\n pickAddress(baseContracts, ['Escrow']) ??\n ('' as `0x${string}`),\n escrowV2: pickAddress(baseContracts, ['EscrowV2', 'Escrow_V2']),\n escrowAddresses: uniqueAddresses(\n pickAddress(baseContracts, ['EscrowV2', 'Escrow_V2']),\n ...HISTORICAL_ESCROW_ADDRESSES.base,\n ),\n orchestrator:\n pickAddress(baseContracts, ['OrchestratorV2', 'Orchestrator_V2']) ??\n pickAddress(baseContracts, ['Orchestrator']),\n orchestratorV2: pickAddress(baseContracts, ['OrchestratorV2', 'Orchestrator_V2']),\n orchestratorAddresses: uniqueAddresses(\n pickAddress(baseContracts, ['OrchestratorV2', 'Orchestrator_V2']),\n ...HISTORICAL_ORCHESTRATOR_ADDRESSES.base,\n ),\n unifiedPaymentVerifier: pickAddress(baseContracts, [\n 'UnifiedPaymentVerifierV2',\n 'UnifiedPaymentVerifier',\n ]),\n unifiedPaymentVerifierV2: pickAddress(baseContracts, ['UnifiedPaymentVerifierV2']),\n protocolViewer:\n baseProtocolViewerEntries?.[0]?.address ??\n baseV1ProtocolViewerAddress ??\n baseV2ProtocolViewerAddress,\n protocolViewerEntries: baseProtocolViewerEntries,\n usdc: baseConstants.USDC as `0x${string}` | undefined,\n rateManagerV1: pickAddress(baseContracts, ['RateManagerV1', 'DepositRateManagerRegistryV1']),\n orchestratorRegistry: pickAddress(baseContracts, ['OrchestratorRegistry']),\n rateManagerRegistry: pickAddress(baseContracts, [\n 'DepositRateManagerRegistryV1',\n 'RateManagerV1',\n ]),\n rateManagerController: pickAddress(baseContracts, ['DepositRateManagerController']),\n chainlinkOracleAdapter: pickAddress(baseContracts, ['ChainlinkOracleAdapter']),\n pythOracleAdapter: pickAddress(baseContracts, ['PythOracleAdapter']),\n },\n };\n\n const abisByKey: Record<'base', V2ContractAbis> = {\n base: {\n escrow: EscrowBase as unknown as Abi,\n escrowV2: (pickAbi(baseAbisRaw as unknown as Record<string, unknown>, ['EscrowV2']) ??\n (EscrowBase as unknown as Abi)) as Abi,\n orchestrator: OrchestratorBase as unknown as Abi,\n orchestratorV2: (pickAbi(baseAbisRaw as unknown as Record<string, unknown>, [\n 'OrchestratorV2',\n ]) ?? (OrchestratorBase as unknown as Abi)) as Abi,\n unifiedPaymentVerifier: (pickAbi(baseAbisRaw as unknown as Record<string, unknown>, [\n 'UnifiedPaymentVerifierV2',\n ]) ?? (UnifiedPaymentVerifierBase as unknown as Abi)) as Abi,\n unifiedPaymentVerifierV2: pickAbi(baseAbisRaw as unknown as Record<string, unknown>, [\n 'UnifiedPaymentVerifierV2',\n ]),\n protocolViewer: (baseProtocolViewerEntries?.[0]?.abi ??\n (ProtocolViewerBase as unknown as Abi)) as Abi,\n rateManagerV1: pickAbi(baseAbisRaw as unknown as Record<string, unknown>, [\n 'RateManagerV1',\n 'DepositRateManagerRegistryV1',\n ]),\n orchestratorRegistry: pickAbi(baseAbisRaw as unknown as Record<string, unknown>, [\n 'OrchestratorRegistry',\n ]),\n rateManagerRegistry: pickAbi(baseAbisRaw as unknown as Record<string, unknown>, [\n 'DepositRateManagerRegistryV1',\n 'RateManagerV1',\n ]),\n rateManagerController: pickAbi(baseAbisRaw as unknown as Record<string, unknown>, [\n 'DepositRateManagerController',\n ]),\n },\n };\n\n // Staging overrides (addresses/abis from contracts-v2 baseStaging deployment)\n if (env === 'staging') {\n const sc = baseStagingAddresses.contracts as Record<string, string> | undefined;\n const stagingEscrowV2Override = resolveRuntimeAddressOverride([\n 'VITE_BASE_STAGING_ESCROW_V2_ADDRESS',\n 'VITE_ESCROW_V2_ADDRESS',\n ]);\n const stagingEscrowCurrent =\n stagingEscrowV2Override ??\n pickAddress(sc, ['EscrowV2', 'Escrow_V2']) ??\n pickAddress(sc, ['Escrow']) ??\n STAGING_ESCROW_V2_FALLBACK;\n const stagingOrchestratorV2Override = resolveRuntimeAddressOverride([\n 'VITE_BASE_STAGING_ORCHESTRATOR_V2_ADDRESS',\n 'VITE_ORCHESTRATOR_V2_ADDRESS',\n 'VITE_ORCHESTRATORV2_ADDRESS',\n ]);\n const stagingOrchestratorCurrent =\n stagingOrchestratorV2Override ??\n pickAddress(sc, ['OrchestratorV2', 'Orchestrator_V2']) ??\n pickAddress(sc, ['Orchestrator']) ??\n STAGING_ORCHESTRATOR_V2_FALLBACK;\n const stagingRateManagerV1 = pickAddress(sc, ['RateManagerV1', 'DepositRateManagerRegistryV1']);\n\n return {\n addresses: {\n escrow: stagingEscrowCurrent as `0x${string}`,\n escrowV2: stagingEscrowCurrent,\n escrowAddresses: uniqueAddresses(\n stagingEscrowCurrent,\n ...HISTORICAL_ESCROW_ADDRESSES.base_staging,\n ),\n orchestrator: stagingOrchestratorCurrent,\n orchestratorV2: stagingOrchestratorCurrent,\n orchestratorAddresses: uniqueAddresses(\n stagingOrchestratorCurrent,\n ...HISTORICAL_ORCHESTRATOR_ADDRESSES.base_staging,\n ),\n unifiedPaymentVerifier: pickAddress(sc, [\n 'UnifiedPaymentVerifierV2',\n 'UnifiedPaymentVerifier',\n ]),\n unifiedPaymentVerifierV2: pickAddress(sc, ['UnifiedPaymentVerifierV2']),\n protocolViewer: pickAddress(sc, ['ProtocolViewerV2', 'ProtocolViewer']),\n protocolViewerEntries: (() => {\n const entries: Array<{ address: `0x${string}`; abi: Abi }> = [];\n // Primary: V2 PV (reads from V2 orchestrator)\n const pvV2Address = pickAddress(sc, ['ProtocolViewerV2']);\n const pvV2Abi = pickAbi(baseStagingAbisRaw as unknown as Record<string, unknown>, [\n 'ProtocolViewerV2',\n ]) as Abi | undefined;\n if (pvV2Address && pvV2Abi) {\n entries.push({ address: pvV2Address, abi: pvV2Abi });\n }\n // Fallback: V1 PV (reads V1 orchestrator intents via 1-input functions)\n const pvV1Address = pickAddress(sc, ['ProtocolViewer']);\n const pvV1Abi = ProtocolViewerBaseStaging as unknown as Abi;\n if (pvV1Address && !addressesEqual(pvV1Address, pvV2Address) && pvV1Abi) {\n entries.push({ address: pvV1Address, abi: pvV1Abi });\n }\n return entries.length > 0 ? entries : undefined;\n })(),\n usdc: baseStagingConstants.USDC as `0x${string}` | undefined,\n rateManagerV1: stagingRateManagerV1,\n orchestratorRegistry: pickAddress(sc, ['OrchestratorRegistry']),\n rateManagerRegistry: (pickAddress(sc, ['DepositRateManagerRegistryV1']) ??\n stagingRateManagerV1) as `0x${string}` | undefined,\n rateManagerController: pickAddress(sc, ['DepositRateManagerController']),\n chainlinkOracleAdapter: pickAddress(sc, ['ChainlinkOracleAdapter']),\n pythOracleAdapter: pickAddress(sc, ['PythOracleAdapter']),\n },\n abis: {\n escrow: EscrowBaseStaging as unknown as Abi,\n escrowV2: (addressesEqual(stagingEscrowCurrent, pickAddress(sc, ['Escrow']))\n ? (EscrowBaseStaging as unknown as Abi)\n : (pickAbi(baseStagingAbisRaw as unknown as Record<string, unknown>, ['EscrowV2']) ??\n (EscrowBaseStaging as unknown as Abi))) as Abi,\n orchestrator: OrchestratorBaseStaging as unknown as Abi,\n orchestratorV2: (addressesEqual(\n stagingOrchestratorCurrent,\n pickAddress(sc, ['Orchestrator']),\n )\n ? (OrchestratorBaseStaging as unknown as Abi)\n : (pickAbi(baseStagingAbisRaw as unknown as Record<string, unknown>, [\n 'OrchestratorV2',\n ]) ?? (OrchestratorBaseStaging as unknown as Abi))) as Abi,\n unifiedPaymentVerifier: (pickAbi(baseStagingAbisRaw as unknown as Record<string, unknown>, [\n 'UnifiedPaymentVerifierV2',\n ]) ?? (UnifiedPaymentVerifierBaseStaging as unknown as Abi)) as Abi,\n unifiedPaymentVerifierV2: pickAbi(\n baseStagingAbisRaw as unknown as Record<string, unknown>,\n ['UnifiedPaymentVerifierV2'],\n ),\n protocolViewer: (pickAbi(baseStagingAbisRaw as unknown as Record<string, unknown>, [\n 'ProtocolViewerV2',\n ]) ?? (ProtocolViewerBaseStaging as unknown as Abi)) as Abi,\n rateManagerV1: pickAbi(baseStagingAbisRaw as unknown as Record<string, unknown>, [\n 'RateManagerV1',\n 'DepositRateManagerRegistryV1',\n ]),\n orchestratorRegistry: pickAbi(baseStagingAbisRaw as unknown as Record<string, unknown>, [\n 'OrchestratorRegistry',\n ]),\n rateManagerRegistry: pickAbi(baseStagingAbisRaw as unknown as Record<string, unknown>, [\n 'DepositRateManagerRegistryV1',\n 'RateManagerV1',\n ]),\n rateManagerController: pickAbi(baseStagingAbisRaw as unknown as Record<string, unknown>, [\n 'DepositRateManagerController',\n ]),\n },\n };\n }\n\n const result = { addresses: addressesByKey[key], abis: abisByKey[key] };\n\n return result;\n}\n\n/**\n * Catalog of payment methods with their hashes and supported currencies.\n */\nexport type PaymentMethodCatalog = Record<\n string,\n { paymentMethodHash: `0x${string}`; currencies?: `0x${string}`[] }\n>;\n\n/**\n * Retrieves the payment methods catalog for a given chain and environment.\n *\n * The catalog maps payment platform names (e.g., 'wise', 'revolut') to their\n * on-chain hashes and supported currency hashes.\n *\n * @param chainId - The chain ID\n * @param env - Runtime environment\n * @returns Payment method catalog keyed by platform name\n *\n * @example\n * ```typescript\n * import { getPaymentMethodsCatalog } from '@zkp2p/sdk';\n *\n * const catalog = getPaymentMethodsCatalog(8453, 'production');\n * console.log(Object.keys(catalog)); // ['wise', 'venmo', 'revolut', ...]\n * console.log(catalog.wise.paymentMethodHash); // \"0x...\"\n * console.log(catalog.wise.currencies); // [\"0x...\", \"0x...\"] (currency hashes)\n * ```\n */\nexport function getPaymentMethodsCatalog(\n _chainId: number,\n env: RuntimeEnv = 'production',\n): PaymentMethodCatalog {\n const src = env === 'staging' ? baseStagingPaymentMethods : basePaymentMethods;\n const methods = (src?.methods ?? {}) as PaymentMethodCatalog;\n return methods;\n}\n\n/**\n * Returns the gating service address for a given chain and environment.\n *\n * The gating service signs intent parameters before they can be submitted\n * on-chain, providing an additional validation layer.\n *\n * @param chainId - The chain ID\n * @param env - Runtime environment\n * @returns Gating service signer address\n */\nexport function getGatingServiceAddress(\n _chainId: number,\n env: RuntimeEnv = 'production',\n): `0x${string}` {\n // Base Staging & Production share the same gating service in current deployments\n if (env === 'staging') {\n return '0x396D31055Db28C0C6f36e8b36f18FE7227248a97' as `0x${string}`;\n }\n // Base mainnet (production)\n return '0x396D31055Db28C0C6f36e8b36f18FE7227248a97' as `0x${string}`;\n}\n\nexport function getRateManagerContracts(\n chainId: number,\n env: RuntimeEnv = 'production',\n): {\n addresses: { registry: `0x${string}`; controller?: `0x${string}` };\n abis: { registry: Abi; controller?: Abi };\n} {\n const { addresses, abis } = getContracts(chainId, env);\n const registryAddress = addresses.rateManagerV1 ?? addresses.rateManagerRegistry;\n const registryAbi = abis.rateManagerV1 ?? abis.rateManagerRegistry;\n if (!registryAddress || !registryAbi) {\n throw new Error(`Rate manager contracts not available for chainId=${chainId}, env=${env}`);\n }\n const controllerAddress = addresses.rateManagerController;\n const controllerAbi = controllerAddress ? abis.rateManagerController : undefined;\n\n return {\n addresses: {\n registry: registryAddress,\n ...(controllerAddress ? { controller: controllerAddress } : {}),\n },\n abis: {\n registry: registryAbi,\n ...(controllerAbi ? { controller: controllerAbi } : {}),\n },\n };\n}\n","import { keccak256, toBytes, hexToBytes, bytesToHex } from 'viem';\n\n/**\n * Ensure a value is 32 bytes hex (0x + 64 nibbles). If ascii, keccak256 by default when hash=true.\n */\nexport function ensureBytes32(\n value: string,\n { hashIfAscii = false }: { hashIfAscii?: boolean } = {},\n): `0x${string}` {\n if (value.startsWith('0x')) {\n const bytes = hexToBytes(value as `0x${string}`);\n if (bytes.length !== 32) throw new Error('Expected 32-byte hex value');\n return value as `0x${string}`;\n }\n if (!hashIfAscii)\n throw new Error('Expected 32-byte hex; received ascii string. Pass hashIfAscii=true to hash.');\n const hashed = keccak256(toBytes(value));\n return hashed as `0x${string}`;\n}\n\n/**\n * Encode ASCII (<=32 chars) left-aligned, right-padded with zeros to 32 bytes.\n */\nexport function asciiToBytes32(value: string): `0x${string}` {\n const b = toBytes(value);\n if (b.length > 32) throw new Error('ASCII input exceeds 32 bytes');\n const padded = new Uint8Array(32);\n padded.set(b);\n return bytesToHex(padded);\n}\n","import lookups from '@zkp2p/contracts-v2/paymentMethods/lookups.json';\n\n/**\n * Canonical payment-method hash map sourced from contracts.\n */\nexport const METHOD_NAME_TO_HASH = lookups.nameToHash;\n","/**\n * Payment method resolution utilities.\n *\n * These functions convert between human-readable payment platform names\n * (e.g., 'wise', 'revolut') and their on-chain bytes32 hashes.\n *\n * @module paymentResolution\n */\n\nimport { ensureBytes32 } from './bytes32';\nimport { currencyKeccak256 } from './currencyKeccak256';\nimport { METHOD_NAME_TO_HASH } from './paymentMethodHashes';\nimport type { PaymentMethodCatalog } from '../contracts';\n\n// Optional JSON maps from @zkp2p/contracts-v2 (only provided on some envs)\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport baseStagingPaymentMethods from '@zkp2p/contracts-v2/paymentMethods/baseStaging';\n\ntype NetworkKey = 'base';\ntype RuntimeEnv = 'production' | 'preproduction' | 'staging';\n\nfunction getPaymentMethodMap(\n env: RuntimeEnv,\n _network: NetworkKey,\n): Record<string, { paymentMethodHash: `0x${string}` }> | null {\n if (env === 'staging') {\n const m = (baseStagingPaymentMethods?.methods ?? {}) as Record<\n string,\n { paymentMethodHash: `0x${string}` }\n >;\n return m && Object.keys(m).length ? m : null;\n }\n return null;\n}\n\n/**\n * Resolves a payment method hash from a human-readable name.\n *\n * First attempts to look up the hash from contracts-v2 payment method maps.\n * Falls back to keccak256(name) when maps are unavailable.\n *\n * **Warning**: The fallback may not match on-chain mappings. Prefer using\n * `resolvePaymentMethodHashFromCatalog` with an explicit catalog.\n *\n * @param nameOrBytes - Payment method name ('wise') or existing bytes32 hash\n * @param opts.env - Runtime environment ('production' | 'staging')\n * @param opts.network - Network key ('base')\n * @returns bytes32 payment method hash\n *\n * @example\n * ```typescript\n * const hash = resolvePaymentMethodHash('wise', { env: 'production' });\n * ```\n */\nexport function resolvePaymentMethodHash(\n nameOrBytes: string,\n opts: { env?: RuntimeEnv; network?: NetworkKey } = {},\n): `0x${string}` {\n const { env = 'production', network = 'base' } = opts;\n if (nameOrBytes.startsWith('0x')) return ensureBytes32(nameOrBytes) as `0x${string}`;\n const mapping = getPaymentMethodMap(env, network);\n if (mapping) {\n const key = nameOrBytes.toLowerCase();\n const entry = mapping[key];\n if (entry?.paymentMethodHash) return entry.paymentMethodHash;\n }\n // Fallback: hash ascii name to bytes32\n return ensureBytes32(nameOrBytes, { hashIfAscii: true });\n}\n\n/**\n * Encodes a fiat currency code into bytes32 format (keccak256 hash).\n *\n * If the input is already a hex string (0x-prefixed), it's normalized to bytes32.\n * Otherwise, the currency code is hashed using keccak256.\n *\n * @param codeOrBytes - Currency code ('USD') or existing bytes32 hash\n * @returns bytes32 keccak256 hash of the currency code\n *\n * @example\n * ```typescript\n * const bytes = resolveFiatCurrencyBytes32('USD');\n * // Returns: 0xc4ae21aac0c6549d71dd96035b7e0bdb6c79ebdba8891b666115bc976d16a29e\n * ```\n */\nexport function resolveFiatCurrencyBytes32(codeOrBytes: string): `0x${string}` {\n if (codeOrBytes.startsWith('0x')) return ensureBytes32(codeOrBytes) as `0x${string}`;\n return currencyKeccak256(codeOrBytes.toUpperCase()) as `0x${string}`;\n}\n\n/**\n * Resolves a payment method hash from a provided catalog.\n *\n * This is the recommended method for resolving payment methods as it uses\n * the exact catalog from `getPaymentMethodsCatalog()`, ensuring consistency\n * with on-chain registrations.\n *\n * If the processor is not found in the catalog, falls back to the known\n * protocol payment method hashes before throwing an error.\n *\n * @param processorName - Payment platform name ('wise', 'revolut', etc.)\n * @param catalog - Payment method catalog from `getPaymentMethodsCatalog()`\n * @returns bytes32 payment method hash\n * @throws Error with available processors if not found in catalog or fallback\n *\n * @example\n * ```typescript\n * import { getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog } from '@zkp2p/sdk';\n *\n * const catalog = getPaymentMethodsCatalog(8453, 'production');\n * const hash = resolvePaymentMethodHashFromCatalog('wise', catalog);\n * ```\n */\nexport function resolvePaymentMethodHashFromCatalog(\n processorName: string,\n catalog: Record<string, { paymentMethodHash: `0x${string}`; currencies?: `0x${string}`[] }>,\n): `0x${string}` {\n if (!processorName) {\n throw new Error('processorName is required to resolve paymentMethodHash');\n }\n if (processorName.startsWith('0x')) {\n return ensureBytes32(processorName) as `0x${string}`;\n }\n const key = processorName.toLowerCase();\n const entry = catalog?.[key];\n if (entry?.paymentMethodHash) return entry.paymentMethodHash;\n\n // Fallback to known protocol payment method hashes when catalog is missing the entry\n const fallbackHash = METHOD_NAME_TO_HASH[key as keyof typeof METHOD_NAME_TO_HASH];\n if (fallbackHash) return fallbackHash as `0x${string}`;\n\n const available = Object.keys(catalog || {})\n .sort()\n .join(', ');\n throw new Error(\n available\n ? `Unknown processorName: ${processorName}. Available: ${available}`\n : `Unknown processorName: ${processorName}. The payment methods catalog is empty or unavailable.`,\n );\n}\n\n/**\n * Reverse-lookup: converts a payment method hash back to its name.\n *\n * @param hash - The payment method hash (bytes32)\n * @param catalog - Payment method catalog from `getPaymentMethodsCatalog()`\n * @returns Payment platform name (e.g., 'wise') or undefined if not found\n *\n * @example\n * ```typescript\n * const name = resolvePaymentMethodNameFromHash('0x...', catalog);\n * console.log(name); // \"wise\"\n * ```\n */\nexport function resolvePaymentMethodNameFromHash(\n hash: string,\n catalog: PaymentMethodCatalog,\n): string | undefined {\n if (!hash) return undefined;\n const target = ensureBytes32(hash) as `0x${string}`;\n for (const [name, entry] of Object.entries(catalog || {})) {\n if (entry?.paymentMethodHash?.toLowerCase() === target.toLowerCase()) return name;\n }\n return undefined;\n}\n","import { parseBigIntLike as toBigInt } from './bigint';\n\nexport type PV_ReferralFee = {\n recipient: `0x${string}`;\n fee: bigint;\n};\n\nexport type PV_Deposit = {\n depositor: string;\n delegate: string;\n token: string;\n amount: bigint;\n intentAmountRange: { min: bigint; max: bigint };\n acceptingIntents: boolean;\n remainingDeposits: bigint;\n outstandingIntentAmount: bigint;\n makerProtocolFee: bigint;\n reservedMakerFees: bigint;\n accruedMakerFees: bigint;\n accruedReferrerFees: bigint;\n intentGuardian: string;\n retainOnEmpty: boolean;\n referrer: string;\n referrerFee: bigint;\n};\n\nexport type PV_Currency = { code: string; minConversionRate: bigint };\nexport type PV_PaymentMethodData = {\n paymentMethod: string; // bytes32\n verificationData: {\n intentGatingService: string;\n payeeDetails: string; // bytes32\n data: string; // bytes\n };\n currencies: PV_Currency[];\n};\n\nexport type PV_DepositView = {\n depositId: bigint;\n deposit: PV_Deposit;\n availableLiquidity: bigint;\n paymentMethods: PV_PaymentMethodData[];\n intentHashes: string[];\n};\n\nexport type PV_Intent = {\n owner: string;\n to: string;\n escrow: string;\n depositId: bigint;\n amount: bigint;\n timestamp: bigint;\n paymentMethod: string; // bytes32\n fiatCurrency: string; // bytes32\n conversionRate: bigint;\n referralFees: PV_ReferralFee[];\n postIntentHook: string;\n data: string;\n};\n\nexport type PV_IntentView = {\n intentHash: string;\n intent: PV_Intent;\n deposit: Omit<PV_DepositView, 'intentHashes'>;\n};\n\nfunction parseReferralFees(rawIntent: any): PV_ReferralFee[] {\n if (Array.isArray(rawIntent?.referralFees)) {\n return rawIntent.referralFees.map((fee: any) => ({\n recipient: (fee.recipient ?? '') as `0x${string}`,\n fee: toBigInt(fee.fee ?? 0),\n }));\n }\n\n const legacyRecipient = rawIntent?.referrer ?? '';\n const legacyFee = toBigInt(rawIntent?.referrerFee ?? 0);\n if (\n typeof legacyRecipient === 'string' &&\n legacyRecipient !== '' &&\n legacyRecipient !== '0x0000000000000000000000000000000000000000' &&\n legacyFee > 0n\n ) {\n return [{ recipient: legacyRecipient as `0x${string}`, fee: legacyFee }];\n }\n\n return [];\n}\n\nexport function parseDepositView(raw: any): PV_DepositView {\n return {\n depositId: toBigInt(raw.depositId),\n deposit: {\n depositor: raw.deposit.depositor,\n delegate: raw.deposit.delegate,\n token: raw.deposit.token,\n amount: toBigInt(raw.deposit.amount ?? 0),\n intentAmountRange: {\n min: toBigInt(raw.deposit.intentAmountRange?.min ?? 0),\n max: toBigInt(raw.deposit.intentAmountRange?.max ?? 0),\n },\n acceptingIntents: raw.deposit.acceptingIntents ?? false,\n remainingDeposits: toBigInt(raw.deposit.remainingDeposits ?? 0),\n outstandingIntentAmount: toBigInt(raw.deposit.outstandingIntentAmount ?? 0),\n makerProtocolFee: toBigInt(raw.deposit.makerProtocolFee ?? 0),\n reservedMakerFees: toBigInt(raw.deposit.reservedMakerFees ?? 0),\n accruedMakerFees: toBigInt(raw.deposit.accruedMakerFees ?? 0),\n accruedReferrerFees: toBigInt(raw.deposit.accruedReferrerFees ?? 0),\n intentGuardian: raw.deposit.intentGuardian ?? '',\n retainOnEmpty: raw.deposit.retainOnEmpty ?? false,\n referrer: raw.deposit.referrer ?? '',\n referrerFee: toBigInt(raw.deposit.referrerFee ?? 0),\n },\n availableLiquidity: toBigInt(raw.availableLiquidity),\n paymentMethods: (raw.paymentMethods || []).map((pm: any) => ({\n paymentMethod: pm.paymentMethod,\n verificationData: {\n intentGatingService: pm.verificationData.intentGatingService,\n payeeDetails: pm.verificationData.payeeDetails,\n data: pm.verificationData.data,\n },\n currencies: (pm.currencies || []).map((c: any) => ({\n code: c.code,\n minConversionRate: toBigInt(c.minConversionRate),\n })),\n })),\n intentHashes: raw.intentHashes || [],\n };\n}\n\nexport function parseIntentView(raw: any): PV_IntentView {\n const parsedDeposit = parseDepositView(raw.deposit);\n const deposit: Omit<PV_DepositView, 'intentHashes'> = {\n depositId: parsedDeposit.depositId,\n deposit: parsedDeposit.deposit,\n availableLiquidity: parsedDeposit.availableLiquidity,\n paymentMethods: parsedDeposit.paymentMethods,\n };\n return {\n intentHash: raw.intentHash,\n intent: {\n owner: raw.intent.owner,\n to: raw.intent.to,\n escrow: raw.intent.escrow,\n depositId: toBigInt(raw.intent.depositId),\n amount: toBigInt(raw.intent.amount),\n timestamp: toBigInt(raw.intent.timestamp),\n paymentMethod: raw.intent.paymentMethod,\n fiatCurrency: raw.intent.fiatCurrency,\n conversionRate: toBigInt(raw.intent.conversionRate),\n referralFees: parseReferralFees(raw.intent),\n postIntentHook: raw.intent.postIntentHook,\n data: raw.intent.data,\n },\n deposit,\n };\n}\n\n// Enrichment helpers for dashboards/explorers\nimport { getPaymentMethodsCatalog, type RuntimeEnv } from '../contracts';\nimport { resolvePaymentMethodNameFromHash } from './paymentResolution';\nimport { getCurrencyInfoFromHash } from './currency';\n\nexport function enrichPvDepositView(\n view: PV_DepositView,\n chainId: number,\n env: RuntimeEnv = 'production',\n) {\n const catalog = getPaymentMethodsCatalog(chainId, env);\n return {\n ...view,\n paymentMethods: view.paymentMethods.map((pm) => ({\n ...pm,\n processorName: resolvePaymentMethodNameFromHash(pm.paymentMethod, catalog),\n currencies: pm.currencies.map((c) => ({\n ...c,\n currencyInfo: getCurrencyInfoFromHash(c.code),\n })),\n })),\n };\n}\n\nexport function enrichPvIntentView(\n view: PV_IntentView,\n chainId: number,\n env: RuntimeEnv = 'production',\n) {\n const catalog = getPaymentMethodsCatalog(chainId, env);\n return {\n ...view,\n intent: {\n ...view.intent,\n processorName: resolvePaymentMethodNameFromHash(view.intent.paymentMethod, catalog),\n currencyInfo: getCurrencyInfoFromHash(view.intent.fiatCurrency),\n },\n deposit: enrichPvDepositView(view.deposit as any, chainId, env),\n } as any;\n}\n"]}
|