@usdctofiat/offramp 1.1.4 → 2.0.0
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/CHANGELOG.md +252 -0
- package/README.md +82 -2
- package/dist/{chunk-OJY6DE3I.js → chunk-HBR3Z6HX.js} +668 -248
- package/dist/chunk-HBR3Z6HX.js.map +1 -0
- package/dist/errors-Deoi_xYZ.d.cts +236 -0
- package/dist/errors-Deoi_xYZ.d.ts +236 -0
- package/dist/index.cjs +681 -248
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -5
- package/dist/index.d.ts +38 -5
- package/dist/index.js +55 -18
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +808 -277
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +90 -3
- package/dist/react.d.ts +90 -3
- package/dist/react.js +152 -14
- package/dist/react.js.map +1 -1
- package/package.json +18 -7
- package/dist/chunk-OJY6DE3I.js.map +0 -1
- package/dist/errors-Dtzrl98J.d.cts +0 -105
- package/dist/errors-Dtzrl98J.d.ts +0 -105
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
import { WalletClient } from 'viem';
|
|
2
|
-
import { O as OfframpParams, a as OnProgress, b as OfframpResult, D as DepositInfo } from './errors-
|
|
3
|
-
export {
|
|
4
|
-
|
|
2
|
+
import { O as OfframpParams, a as OnProgress, b as OfframpResult, c as OfframpCreateOptions, d as OfframpQuoteInput, e as OfframpQuote, f as OfframpVaultStatus, P as PlatformEntry, C as CurrencyEntry, D as DepositInfo } from './errors-Deoi_xYZ.js';
|
|
3
|
+
export { g as CURRENCIES, h as DepositStatus, M as MakersCreateError, i as OFFRAMP_ERROR_CODES, j as OfframpError, k as OfframpErrorCode, l as OfframpProgress, m as OfframpState, n as OfframpStep, o as PLATFORMS, p as PayeeDepositData, q as PeerExtensionRegistrationInfo, r as PlatformKey, s as getPeerExtensionRegistrationInfo, t as isPeerExtensionRegistrationError, u as normalizePaypalMeUsername } from './errors-Deoi_xYZ.js';
|
|
4
|
+
export { PEER_EXTENSION_CHROME_URL, PeerConnectionStatus, PeerExtensionApi, PeerExtensionSdk, PeerExtensionSdkOptions, PeerExtensionState, PeerExtensionWindow, createPeerExtensionSdk, getPeerExtensionState, isPeerExtensionAvailable, openPeerExtensionInstallPage, peerExtensionSdk } from '@zkp2p/sdk';
|
|
5
|
+
|
|
6
|
+
type TelemetryEventName = "sdk.init" | "sdk.createDeposit.start" | "sdk.createDeposit.progress" | "sdk.createDeposit.success" | "sdk.createDeposit.error";
|
|
7
|
+
interface TelemetryContext {
|
|
8
|
+
readonly enabled: boolean;
|
|
9
|
+
readonly sdkVersion: string;
|
|
10
|
+
readonly integratorId?: string;
|
|
11
|
+
readonly referralId?: string;
|
|
12
|
+
emit: (name: TelemetryEventName, payload?: Record<string, unknown>) => void;
|
|
13
|
+
}
|
|
14
|
+
interface CreateTelemetryContextOptions {
|
|
15
|
+
sdkVersion: string;
|
|
16
|
+
telemetry?: boolean;
|
|
17
|
+
integratorId?: string;
|
|
18
|
+
referralId?: string;
|
|
19
|
+
}
|
|
20
|
+
declare function sanitizeAttributionId(raw: unknown): string | undefined;
|
|
21
|
+
declare function emitEvent(name: TelemetryEventName, payload?: Record<string, unknown>): void;
|
|
22
|
+
declare function sendTelemetryEvent(name: TelemetryEventName, payload?: Record<string, unknown>): void;
|
|
23
|
+
declare function createTelemetryContext(options: CreateTelemetryContextOptions): TelemetryContext;
|
|
5
24
|
|
|
6
25
|
/**
|
|
7
26
|
* Create a USDC-to-fiat offramp deposit and delegate it to the vault.
|
|
@@ -9,7 +28,21 @@ import '@zkp2p/sdk';
|
|
|
9
28
|
* **Resumable**: if an existing undelegated deposit is found for this wallet,
|
|
10
29
|
* the flow skips directly to delegation instead of creating a new deposit.
|
|
11
30
|
*/
|
|
12
|
-
declare function offramp(walletClient: WalletClient, params: OfframpParams, onProgress?: OnProgress): Promise<OfframpResult>;
|
|
31
|
+
declare function offramp(walletClient: WalletClient, params: OfframpParams, onProgress?: OnProgress, telemetryContext?: TelemetryContext): Promise<OfframpResult>;
|
|
32
|
+
|
|
33
|
+
interface OfframpConstructorOptions extends OfframpCreateOptions {
|
|
34
|
+
walletClient: WalletClient;
|
|
35
|
+
}
|
|
36
|
+
declare class Offramp {
|
|
37
|
+
private readonly walletClient;
|
|
38
|
+
private readonly telemetry;
|
|
39
|
+
constructor(options: OfframpConstructorOptions);
|
|
40
|
+
createDeposit(params: OfframpParams, onProgress?: OnProgress): Promise<OfframpResult>;
|
|
41
|
+
getQuote(input: OfframpQuoteInput): OfframpQuote;
|
|
42
|
+
getVaultStatus(): OfframpVaultStatus;
|
|
43
|
+
listCurrencies(): Record<PlatformEntry["id"], CurrencyEntry[]>;
|
|
44
|
+
}
|
|
45
|
+
declare function createOfframp(options: OfframpConstructorOptions): Offramp;
|
|
13
46
|
|
|
14
47
|
/**
|
|
15
48
|
* List all deposits for a wallet address. Read-only, no wallet needed.
|
|
@@ -73,4 +106,4 @@ declare function disableOtc(walletClient: WalletClient, depositId: string, escro
|
|
|
73
106
|
*/
|
|
74
107
|
declare function getOtcLink(depositId: string, escrowAddress?: string): string;
|
|
75
108
|
|
|
76
|
-
export { DepositInfo, ESCROW_ADDRESS, type EnableOtcResult, OfframpParams, OfframpResult, OnProgress, close, delegate, deposits, disableOtc, enableOtc, getOtcLink, offramp, undelegate };
|
|
109
|
+
export { CurrencyEntry, DepositInfo, ESCROW_ADDRESS, type EnableOtcResult, Offramp, OfframpCreateOptions, OfframpParams, OfframpQuote, OfframpQuoteInput, OfframpResult, OfframpVaultStatus, OnProgress, PlatformEntry, close, createOfframp, createTelemetryContext, delegate, deposits, disableOtc, emitEvent, enableOtc, getOtcLink, offramp, sanitizeAttributionId, sendTelemetryEvent, undelegate };
|
package/dist/index.js
CHANGED
|
@@ -1,46 +1,83 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CURRENCIES,
|
|
2
3
|
ESCROW_ADDRESS,
|
|
4
|
+
MakersCreateError,
|
|
5
|
+
Offramp,
|
|
3
6
|
OfframpError,
|
|
7
|
+
PEER_EXTENSION_CHROME_URL,
|
|
4
8
|
PLATFORMS,
|
|
5
9
|
close,
|
|
10
|
+
createOfframp,
|
|
11
|
+
createPeerExtensionSdk,
|
|
12
|
+
createTelemetryContext,
|
|
6
13
|
delegate,
|
|
7
14
|
deposits,
|
|
8
15
|
disableOtc,
|
|
16
|
+
emitEvent,
|
|
9
17
|
enableOtc,
|
|
10
18
|
getOtcLink,
|
|
19
|
+
getPeerExtensionRegistrationInfo,
|
|
20
|
+
getPeerExtensionState,
|
|
21
|
+
isPeerExtensionAvailable,
|
|
22
|
+
isPeerExtensionRegistrationError,
|
|
23
|
+
normalizePaypalMeUsername,
|
|
11
24
|
offramp,
|
|
25
|
+
openPeerExtensionInstallPage,
|
|
26
|
+
peerExtensionSdk,
|
|
27
|
+
sanitizeAttributionId,
|
|
28
|
+
sendTelemetryEvent,
|
|
12
29
|
undelegate
|
|
13
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-HBR3Z6HX.js";
|
|
14
31
|
|
|
15
|
-
// src/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
// src/types.ts
|
|
33
|
+
var OFFRAMP_ERROR_CODES = {
|
|
34
|
+
VALIDATION: "VALIDATION",
|
|
35
|
+
APPROVAL_FAILED: "APPROVAL_FAILED",
|
|
36
|
+
REGISTRATION_FAILED: "REGISTRATION_FAILED",
|
|
37
|
+
/**
|
|
38
|
+
* Curator rejected the maker because the user has not registered this
|
|
39
|
+
* handle in the Peer extension yet. Thrown from `offramp()` for PayPal
|
|
40
|
+
* and Wise when `/v2/makers/create` returns 400 or a "creating the maker"
|
|
41
|
+
* message. Recover by prompting the user through the Peer extension via
|
|
42
|
+
* `usePeerExtensionRegistration(platform)` (React) or `peerExtensionSdk`
|
|
43
|
+
* directly, then call `offramp()` again.
|
|
44
|
+
*/
|
|
45
|
+
EXTENSION_REGISTRATION_REQUIRED: "EXTENSION_REGISTRATION_REQUIRED",
|
|
46
|
+
DEPOSIT_FAILED: "DEPOSIT_FAILED",
|
|
47
|
+
CONFIRMATION_FAILED: "CONFIRMATION_FAILED",
|
|
48
|
+
DELEGATION_FAILED: "DELEGATION_FAILED",
|
|
49
|
+
USER_CANCELLED: "USER_CANCELLED",
|
|
50
|
+
UNSUPPORTED: "UNSUPPORTED"
|
|
51
|
+
};
|
|
32
52
|
export {
|
|
33
53
|
CURRENCIES,
|
|
34
54
|
ESCROW_ADDRESS,
|
|
55
|
+
MakersCreateError,
|
|
56
|
+
OFFRAMP_ERROR_CODES,
|
|
57
|
+
Offramp,
|
|
35
58
|
OfframpError,
|
|
59
|
+
PEER_EXTENSION_CHROME_URL,
|
|
36
60
|
PLATFORMS,
|
|
37
61
|
close,
|
|
62
|
+
createOfframp,
|
|
63
|
+
createPeerExtensionSdk,
|
|
64
|
+
createTelemetryContext,
|
|
38
65
|
delegate,
|
|
39
66
|
deposits,
|
|
40
67
|
disableOtc,
|
|
68
|
+
emitEvent,
|
|
41
69
|
enableOtc,
|
|
42
70
|
getOtcLink,
|
|
71
|
+
getPeerExtensionRegistrationInfo,
|
|
72
|
+
getPeerExtensionState,
|
|
73
|
+
isPeerExtensionAvailable,
|
|
74
|
+
isPeerExtensionRegistrationError,
|
|
75
|
+
normalizePaypalMeUsername,
|
|
43
76
|
offramp,
|
|
77
|
+
openPeerExtensionInstallPage,
|
|
78
|
+
peerExtensionSdk,
|
|
79
|
+
sanitizeAttributionId,
|
|
80
|
+
sendTelemetryEvent,
|
|
44
81
|
undelegate
|
|
45
82
|
};
|
|
46
83
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { PlatformEntry } from \"./platforms\";\nimport type { CurrencyEntry } from \"./currencies\";\n\nexport const OFFRAMP_ERROR_CODES = {\n VALIDATION: \"VALIDATION\",\n APPROVAL_FAILED: \"APPROVAL_FAILED\",\n REGISTRATION_FAILED: \"REGISTRATION_FAILED\",\n /**\n * Curator rejected the maker because the user has not registered this\n * handle in the Peer extension yet. Thrown from `offramp()` for PayPal\n * and Wise when `/v2/makers/create` returns 400 or a \"creating the maker\"\n * message. Recover by prompting the user through the Peer extension via\n * `usePeerExtensionRegistration(platform)` (React) or `peerExtensionSdk`\n * directly, then call `offramp()` again.\n */\n EXTENSION_REGISTRATION_REQUIRED: \"EXTENSION_REGISTRATION_REQUIRED\",\n DEPOSIT_FAILED: \"DEPOSIT_FAILED\",\n CONFIRMATION_FAILED: \"CONFIRMATION_FAILED\",\n DELEGATION_FAILED: \"DELEGATION_FAILED\",\n USER_CANCELLED: \"USER_CANCELLED\",\n UNSUPPORTED: \"UNSUPPORTED\",\n} as const;\n\nexport type OfframpErrorCode = (typeof OFFRAMP_ERROR_CODES)[keyof typeof OFFRAMP_ERROR_CODES];\n\nexport interface OfframpParams {\n /** USDC amount as decimal string, min 1. */\n amount: string;\n /** Payment platform — use `PLATFORMS.REVOLUT` etc. */\n platform: PlatformEntry;\n /** Fiat currency — use `CURRENCIES.EUR` etc. */\n currency: CurrencyEntry;\n /** Platform-specific identifier (username, email, IBAN). */\n identifier: string;\n /** Optional: restrict the deposit to this taker wallet (OTC private order). */\n otcTaker?: string;\n /** Optional SDK-only referral metadata for telemetry attribution. */\n referralId?: string;\n /** Optional SDK-only integrator metadata for telemetry attribution. */\n integratorId?: string;\n /** Optional per-wallet key to replay the first successful result for 10 minutes. */\n idempotencyKey?: string;\n}\n\nexport interface OfframpResult {\n depositId: string;\n txHash: string;\n /** Whether an existing undelegated deposit was resumed. */\n resumed: boolean;\n /** OTC link for the taker, present when `otcTaker` was provided. */\n otcLink?: string;\n}\n\nexport type OfframpStep =\n | \"approving\"\n | \"registering\"\n | \"depositing\"\n | \"confirming\"\n | \"delegating\"\n | \"restricting\"\n | \"resuming\"\n | \"done\";\n\nexport type OfframpState =\n | \"idle\"\n | \"approving\"\n | \"registering\"\n | \"depositing\"\n | \"confirming\"\n | \"delegating\"\n | \"done\"\n | \"error\";\n\nexport interface OfframpProgress {\n step: OfframpStep;\n txHash?: string;\n depositId?: string;\n}\n\nexport type OnProgress = (progress: OfframpProgress) => void;\n\nexport type DepositStatus = \"active\" | \"empty\" | \"closed\";\n\nexport interface OfframpQuoteInput {\n amount: string;\n currency: CurrencyEntry;\n platform: PlatformEntry;\n}\n\nexport interface OfframpQuote {\n amountUsdc: number;\n expectedFiat: number;\n effectiveRate: number;\n vaultSpreadBps: number;\n}\n\nexport interface OfframpVaultStatus {\n rateManagerId: string;\n rateManagerAddress: string;\n feeRateBps: number;\n escrow: string;\n isActive: boolean;\n}\n\nexport interface OfframpCreateOptions {\n integratorId?: string;\n referralId?: string;\n telemetry?: boolean;\n}\n\nexport interface DepositInfo {\n /** Numeric deposit ID. Pass this to `close()`. */\n depositId: string;\n /** Composite ID (escrowAddress_depositId). */\n compositeId: string;\n /** Creation transaction hash. */\n txHash?: string;\n status: DepositStatus;\n remainingUsdc: number;\n outstandingUsdc: number;\n totalTakenUsdc: number;\n fulfilledIntents: number;\n paymentMethods: string[];\n currencies: string[];\n rateSource: string;\n delegated: boolean;\n escrowAddress: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAM,sBAAsB;AAAA,EACjC,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASrB,iCAAiC;AAAA,EACjC,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,aAAa;AACf;","names":[]}
|