@usdctofiat/offramp 1.1.3 → 1.3.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/README.md +1 -1
- package/dist/{chunk-QELK2M73.js → chunk-JQBKGGI2.js} +738 -338
- package/dist/chunk-JQBKGGI2.js.map +1 -0
- package/dist/{errors-Dtzrl98J.d.cts → errors-CfZrDly0.d.cts} +42 -2
- package/dist/{errors-Dtzrl98J.d.ts → errors-CfZrDly0.d.ts} +42 -2
- package/dist/index.cjs +657 -259
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -4
- package/dist/index.d.ts +53 -4
- package/dist/index.js +34 -20
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +608 -271
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +5 -2
- package/dist/react.d.ts +5 -2
- package/dist/react.js +33 -14
- package/dist/react.js.map +1 -1
- package/package.json +16 -6
- package/dist/chunk-QELK2M73.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,48 @@
|
|
|
1
1
|
import { WalletClient } from 'viem';
|
|
2
|
-
import { O as OfframpParams, a as OnProgress, b as OfframpResult, D as DepositInfo } from './errors-
|
|
3
|
-
export {
|
|
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-CfZrDly0.js';
|
|
3
|
+
export { g as CURRENCIES, h as DepositStatus, i as OFFRAMP_ERROR_CODES, j as OfframpError, k as OfframpErrorCode, l as OfframpProgress, m as OfframpState, n as OfframpStep, o as PLATFORMS } from './errors-CfZrDly0.js';
|
|
4
4
|
import '@zkp2p/sdk';
|
|
5
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;
|
|
24
|
+
|
|
6
25
|
/**
|
|
7
26
|
* Create a USDC-to-fiat offramp deposit and delegate it to the vault.
|
|
8
27
|
*
|
|
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.
|
|
@@ -23,6 +56,22 @@ declare function deposits(walletAddress: string): Promise<DepositInfo[]>;
|
|
|
23
56
|
* @param depositId - The numeric deposit ID (from `DepositInfo.depositId`)
|
|
24
57
|
*/
|
|
25
58
|
declare function close(walletClient: WalletClient, depositId: string, escrowAddress?: string): Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Delegate a deposit to the configured Delegate vault.
|
|
61
|
+
*
|
|
62
|
+
* @param walletClient - viem WalletClient with the deposit owner's account
|
|
63
|
+
* @param depositId - The numeric deposit ID (from `DepositInfo.depositId`)
|
|
64
|
+
*/
|
|
65
|
+
declare function delegate(walletClient: WalletClient, depositId: string, escrowAddress?: string): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Remove Delegate rate management from a deposit.
|
|
68
|
+
*
|
|
69
|
+
* @param walletClient - viem WalletClient with the deposit owner's account
|
|
70
|
+
* @param depositId - The numeric deposit ID (from `DepositInfo.depositId`)
|
|
71
|
+
*/
|
|
72
|
+
declare function undelegate(walletClient: WalletClient, depositId: string, escrowAddress?: string): Promise<string>;
|
|
73
|
+
|
|
74
|
+
declare const ESCROW_ADDRESS: `0x${string}`;
|
|
26
75
|
|
|
27
76
|
interface EnableOtcResult {
|
|
28
77
|
depositId: string;
|
|
@@ -57,4 +106,4 @@ declare function disableOtc(walletClient: WalletClient, depositId: string, escro
|
|
|
57
106
|
*/
|
|
58
107
|
declare function getOtcLink(depositId: string, escrowAddress?: string): string;
|
|
59
108
|
|
|
60
|
-
export { DepositInfo, type EnableOtcResult, OfframpParams, OfframpResult, OnProgress, close, deposits, disableOtc, enableOtc, getOtcLink, offramp };
|
|
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,40 +1,54 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CURRENCIES,
|
|
3
|
+
ESCROW_ADDRESS,
|
|
4
|
+
Offramp,
|
|
2
5
|
OfframpError,
|
|
3
6
|
PLATFORMS,
|
|
4
7
|
close,
|
|
8
|
+
createOfframp,
|
|
9
|
+
createTelemetryContext,
|
|
10
|
+
delegate,
|
|
5
11
|
deposits,
|
|
6
12
|
disableOtc,
|
|
13
|
+
emitEvent,
|
|
7
14
|
enableOtc,
|
|
8
15
|
getOtcLink,
|
|
9
|
-
offramp
|
|
10
|
-
|
|
16
|
+
offramp,
|
|
17
|
+
sanitizeAttributionId,
|
|
18
|
+
sendTelemetryEvent,
|
|
19
|
+
undelegate
|
|
20
|
+
} from "./chunk-JQBKGGI2.js";
|
|
11
21
|
|
|
12
|
-
// src/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
countryCode: info.countryCode ?? ""
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
return entries;
|
|
27
|
-
}
|
|
28
|
-
var CURRENCIES = buildCurrencies();
|
|
22
|
+
// src/types.ts
|
|
23
|
+
var OFFRAMP_ERROR_CODES = {
|
|
24
|
+
VALIDATION: "VALIDATION",
|
|
25
|
+
APPROVAL_FAILED: "APPROVAL_FAILED",
|
|
26
|
+
REGISTRATION_FAILED: "REGISTRATION_FAILED",
|
|
27
|
+
DEPOSIT_FAILED: "DEPOSIT_FAILED",
|
|
28
|
+
CONFIRMATION_FAILED: "CONFIRMATION_FAILED",
|
|
29
|
+
DELEGATION_FAILED: "DELEGATION_FAILED",
|
|
30
|
+
USER_CANCELLED: "USER_CANCELLED",
|
|
31
|
+
UNSUPPORTED: "UNSUPPORTED"
|
|
32
|
+
};
|
|
29
33
|
export {
|
|
30
34
|
CURRENCIES,
|
|
35
|
+
ESCROW_ADDRESS,
|
|
36
|
+
OFFRAMP_ERROR_CODES,
|
|
37
|
+
Offramp,
|
|
31
38
|
OfframpError,
|
|
32
39
|
PLATFORMS,
|
|
33
40
|
close,
|
|
41
|
+
createOfframp,
|
|
42
|
+
createTelemetryContext,
|
|
43
|
+
delegate,
|
|
34
44
|
deposits,
|
|
35
45
|
disableOtc,
|
|
46
|
+
emitEvent,
|
|
36
47
|
enableOtc,
|
|
37
48
|
getOtcLink,
|
|
38
|
-
offramp
|
|
49
|
+
offramp,
|
|
50
|
+
sanitizeAttributionId,
|
|
51
|
+
sendTelemetryEvent,
|
|
52
|
+
undelegate
|
|
39
53
|
};
|
|
40
54
|
//# 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 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,EACrB,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,aAAa;AACf;","names":[]}
|