agentwallet-sdk 3.0.0 → 3.1.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 +214 -1
- package/dist/fiat/index.d.ts +10 -0
- package/dist/fiat/index.d.ts.map +1 -0
- package/dist/fiat/index.js +9 -0
- package/dist/fiat/index.js.map +1 -0
- package/dist/fiat/onramp.d.ts +101 -0
- package/dist/fiat/onramp.d.ts.map +1 -0
- package/dist/fiat/onramp.js +155 -0
- package/dist/fiat/onramp.js.map +1 -0
- package/dist/fiat/providers/index.d.ts +16 -0
- package/dist/fiat/providers/index.d.ts.map +1 -0
- package/dist/fiat/providers/index.js +30 -0
- package/dist/fiat/providers/index.js.map +1 -0
- package/dist/fiat/providers/moonpay.d.ts +22 -0
- package/dist/fiat/providers/moonpay.d.ts.map +1 -0
- package/dist/fiat/providers/moonpay.js +107 -0
- package/dist/fiat/providers/moonpay.js.map +1 -0
- package/dist/fiat/providers/stripe.d.ts +26 -0
- package/dist/fiat/providers/stripe.d.ts.map +1 -0
- package/dist/fiat/providers/stripe.js +135 -0
- package/dist/fiat/providers/stripe.js.map +1 -0
- package/dist/fiat/providers/transak.d.ts +26 -0
- package/dist/fiat/providers/transak.d.ts.map +1 -0
- package/dist/fiat/providers/transak.js +119 -0
- package/dist/fiat/providers/transak.js.map +1 -0
- package/dist/fiat/types.d.ts +106 -0
- package/dist/fiat/types.d.ts.map +1 -0
- package/dist/fiat/types.js +13 -0
- package/dist/fiat/types.js.map +1 -0
- package/dist/gas/index.d.ts +4 -0
- package/dist/gas/index.d.ts.map +1 -0
- package/dist/gas/index.js +3 -0
- package/dist/gas/index.js.map +1 -0
- package/dist/gas/sponsor.d.ts +70 -0
- package/dist/gas/sponsor.d.ts.map +1 -0
- package/dist/gas/sponsor.js +193 -0
- package/dist/gas/sponsor.js.map +1 -0
- package/dist/gas/types.d.ts +76 -0
- package/dist/gas/types.d.ts.map +1 -0
- package/dist/gas/types.js +21 -0
- package/dist/gas/types.js.map +1 -0
- package/dist/index.d.ts +72 -62
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/settlement/index.d.ts +4 -0
- package/dist/settlement/index.d.ts.map +1 -0
- package/dist/settlement/index.js +3 -0
- package/dist/settlement/index.js.map +1 -0
- package/dist/settlement/types.d.ts +66 -0
- package/dist/settlement/types.d.ts.map +1 -0
- package/dist/settlement/types.js +37 -0
- package/dist/settlement/types.js.map +1 -0
- package/dist/settlement/verifier.d.ts +75 -0
- package/dist/settlement/verifier.d.ts.map +1 -0
- package/dist/settlement/verifier.js +354 -0
- package/dist/settlement/verifier.js.map +1 -0
- package/dist/swap/index.d.ts +1 -0
- package/dist/swap/index.d.ts.map +1 -1
- package/dist/swap/index.js +2 -0
- package/dist/swap/index.js.map +1 -1
- package/dist/swap/router/cache.d.ts +13 -0
- package/dist/swap/router/cache.d.ts.map +1 -0
- package/dist/swap/router/cache.js +30 -0
- package/dist/swap/router/cache.js.map +1 -0
- package/dist/swap/router/flashbots.d.ts +10 -0
- package/dist/swap/router/flashbots.d.ts.map +1 -0
- package/dist/swap/router/flashbots.js +43 -0
- package/dist/swap/router/flashbots.js.map +1 -0
- package/dist/swap/router/health.d.ts +17 -0
- package/dist/swap/router/health.d.ts.map +1 -0
- package/dist/swap/router/health.js +38 -0
- package/dist/swap/router/health.js.map +1 -0
- package/dist/swap/router/index.d.ts +10 -0
- package/dist/swap/router/index.d.ts.map +1 -0
- package/dist/swap/router/index.js +10 -0
- package/dist/swap/router/index.js.map +1 -0
- package/dist/swap/router/providers/cowswap.d.ts +11 -0
- package/dist/swap/router/providers/cowswap.d.ts.map +1 -0
- package/dist/swap/router/providers/cowswap.js +79 -0
- package/dist/swap/router/providers/cowswap.js.map +1 -0
- package/dist/swap/router/providers/index.d.ts +20 -0
- package/dist/swap/router/providers/index.d.ts.map +1 -0
- package/dist/swap/router/providers/index.js +32 -0
- package/dist/swap/router/providers/index.js.map +1 -0
- package/dist/swap/router/providers/jupiter.d.ts +12 -0
- package/dist/swap/router/providers/jupiter.d.ts.map +1 -0
- package/dist/swap/router/providers/jupiter.js +73 -0
- package/dist/swap/router/providers/jupiter.js.map +1 -0
- package/dist/swap/router/providers/lifi.d.ts +11 -0
- package/dist/swap/router/providers/lifi.d.ts.map +1 -0
- package/dist/swap/router/providers/lifi.js +123 -0
- package/dist/swap/router/providers/lifi.js.map +1 -0
- package/dist/swap/router/providers/oneinch.d.ts +13 -0
- package/dist/swap/router/providers/oneinch.d.ts.map +1 -0
- package/dist/swap/router/providers/oneinch.js +71 -0
- package/dist/swap/router/providers/oneinch.js.map +1 -0
- package/dist/swap/router/providers/paraswap.d.ts +11 -0
- package/dist/swap/router/providers/paraswap.d.ts.map +1 -0
- package/dist/swap/router/providers/paraswap.js +73 -0
- package/dist/swap/router/providers/paraswap.js.map +1 -0
- package/dist/swap/router/providers/uniswap.d.ts +31 -0
- package/dist/swap/router/providers/uniswap.d.ts.map +1 -0
- package/dist/swap/router/providers/uniswap.js +116 -0
- package/dist/swap/router/providers/uniswap.js.map +1 -0
- package/dist/swap/router/providers/zerox.d.ts +13 -0
- package/dist/swap/router/providers/zerox.d.ts.map +1 -0
- package/dist/swap/router/providers/zerox.js +94 -0
- package/dist/swap/router/providers/zerox.js.map +1 -0
- package/dist/swap/router/router.d.ts +86 -0
- package/dist/swap/router/router.d.ts.map +1 -0
- package/dist/swap/router/router.js +224 -0
- package/dist/swap/router/router.js.map +1 -0
- package/dist/swap/router/rsi/engine.d.ts +60 -0
- package/dist/swap/router/rsi/engine.d.ts.map +1 -0
- package/dist/swap/router/rsi/engine.js +483 -0
- package/dist/swap/router/rsi/engine.js.map +1 -0
- package/dist/swap/router/rsi/index.d.ts +3 -0
- package/dist/swap/router/rsi/index.d.ts.map +1 -0
- package/dist/swap/router/rsi/index.js +3 -0
- package/dist/swap/router/rsi/index.js.map +1 -0
- package/dist/swap/router/rsi/types.d.ts +106 -0
- package/dist/swap/router/rsi/types.d.ts.map +1 -0
- package/dist/swap/router/rsi/types.js +3 -0
- package/dist/swap/router/rsi/types.js.map +1 -0
- package/dist/swap/router/types.d.ts +120 -0
- package/dist/swap/router/types.d.ts.map +1 -0
- package/dist/swap/router/types.js +16 -0
- package/dist/swap/router/types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MoonPay Provider
|
|
3
|
+
*
|
|
4
|
+
* Creates buy quotes and purchase URLs via MoonPay's REST API.
|
|
5
|
+
* KYC + payment happen on MoonPay's hosted page — we never see KYC data.
|
|
6
|
+
*
|
|
7
|
+
* API reference: https://dev.moonpay.com/reference/buy-quote
|
|
8
|
+
* Dashboard: https://dashboard.moonpay.com
|
|
9
|
+
*/
|
|
10
|
+
const MOONPAY_BASE_URL = 'https://api.moonpay.com';
|
|
11
|
+
const MOONPAY_SANDBOX_URL = 'https://api.moonpay.com'; // Same endpoint, uses sandbox key
|
|
12
|
+
/** MoonPay currency code mappings: our token → MoonPay currency code */
|
|
13
|
+
const TOKEN_MAP = {
|
|
14
|
+
USDC: 'usdc',
|
|
15
|
+
ETH: 'eth',
|
|
16
|
+
SOL: 'sol',
|
|
17
|
+
BTC: 'btc',
|
|
18
|
+
MATIC: 'matic_polygon',
|
|
19
|
+
USDT: 'usdt',
|
|
20
|
+
};
|
|
21
|
+
/** Chain-specific token suffixes for MoonPay (e.g., usdc on base = usdc_base) */
|
|
22
|
+
const CHAIN_TOKEN_MAP = {
|
|
23
|
+
base: { USDC: 'usdc_base', ETH: 'eth_base' },
|
|
24
|
+
ethereum: { USDC: 'usdc', ETH: 'eth', USDT: 'usdt' },
|
|
25
|
+
solana: { USDC: 'usdc_sol', SOL: 'sol' },
|
|
26
|
+
polygon: { USDC: 'usdc_polygon', MATIC: 'matic_polygon', USDT: 'usdt_polygon' },
|
|
27
|
+
arbitrum: { USDC: 'usdc_arbitrum', ETH: 'eth_arbitrum' },
|
|
28
|
+
optimism: { USDC: 'usdc_optimism', ETH: 'eth_optimism' },
|
|
29
|
+
};
|
|
30
|
+
/** Supported assets by chain */
|
|
31
|
+
const SUPPORTED_ASSETS = {
|
|
32
|
+
ethereum: ['ETH', 'USDC', 'USDT'],
|
|
33
|
+
base: ['ETH', 'USDC'],
|
|
34
|
+
solana: ['SOL', 'USDC'],
|
|
35
|
+
polygon: ['MATIC', 'USDC', 'USDT'],
|
|
36
|
+
arbitrum: ['ETH', 'USDC'],
|
|
37
|
+
optimism: ['ETH', 'USDC'],
|
|
38
|
+
};
|
|
39
|
+
function getMoonPayCurrencyCode(chain, token) {
|
|
40
|
+
return CHAIN_TOKEN_MAP[chain]?.[token] ?? TOKEN_MAP[token] ?? token.toLowerCase();
|
|
41
|
+
}
|
|
42
|
+
export class MoonPayProvider {
|
|
43
|
+
constructor(apiKey, testMode = false) {
|
|
44
|
+
this.name = 'moonpay';
|
|
45
|
+
this.supportedAssets = SUPPORTED_ASSETS;
|
|
46
|
+
this.apiKey = apiKey;
|
|
47
|
+
this.baseUrl = testMode ? MOONPAY_SANDBOX_URL : MOONPAY_BASE_URL;
|
|
48
|
+
}
|
|
49
|
+
get isConfigured() {
|
|
50
|
+
return Boolean(this.apiKey);
|
|
51
|
+
}
|
|
52
|
+
async getQuote(params) {
|
|
53
|
+
const currencyCode = getMoonPayCurrencyCode(params.chain, params.token);
|
|
54
|
+
const fiatCurrency = (params.currency ?? 'USD').toLowerCase();
|
|
55
|
+
const url = new URL(`${this.baseUrl}/v3/currencies/${currencyCode}/buy_quote`);
|
|
56
|
+
url.searchParams.set('apiKey', this.apiKey);
|
|
57
|
+
url.searchParams.set('baseCurrencyAmount', String(params.amount));
|
|
58
|
+
url.searchParams.set('baseCurrencyCode', fiatCurrency);
|
|
59
|
+
url.searchParams.set('areFeesIncluded', 'false');
|
|
60
|
+
const response = await fetch(url.toString(), {
|
|
61
|
+
headers: { Accept: 'application/json' },
|
|
62
|
+
});
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
const errorText = await response.text().catch(() => response.statusText);
|
|
65
|
+
throw new Error(`MoonPay API error ${response.status}: ${errorText}`);
|
|
66
|
+
}
|
|
67
|
+
const data = await response.json();
|
|
68
|
+
const grossCrypto = data.quoteCurrencyAmount ?? 0;
|
|
69
|
+
const feeAmount = (data.feeAmount ?? 0) + (data.extraFeeAmount ?? 0) + (data.networkFeeAmount ?? 0);
|
|
70
|
+
const feePercent = params.amount > 0 ? (feeAmount / params.amount) * 100 : 0;
|
|
71
|
+
// Build the purchase URL (MoonPay hosted widget)
|
|
72
|
+
const purchaseUrl = this.buildPurchaseUrl(params, currencyCode, fiatCurrency);
|
|
73
|
+
return {
|
|
74
|
+
provider: this.name,
|
|
75
|
+
fiatAmount: params.amount,
|
|
76
|
+
fiatCurrency: (params.currency ?? 'USD').toUpperCase(),
|
|
77
|
+
cryptoAmount: String(grossCrypto),
|
|
78
|
+
cryptoToken: params.token.toUpperCase(),
|
|
79
|
+
chain: params.chain,
|
|
80
|
+
feeAmount,
|
|
81
|
+
feePercent: Math.round(feePercent * 100) / 100,
|
|
82
|
+
netCryptoAmount: String(grossCrypto),
|
|
83
|
+
paymentMethods: ['card', 'bank_transfer', 'apple_pay', 'google_pay'],
|
|
84
|
+
estimatedTimeMinutes: 10,
|
|
85
|
+
kycRequired: true,
|
|
86
|
+
purchaseUrl,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
async createSession(params) {
|
|
90
|
+
// MoonPay uses a URL-based flow — the "session" IS the purchase URL
|
|
91
|
+
return this.getQuote(params);
|
|
92
|
+
}
|
|
93
|
+
buildPurchaseUrl(params, currencyCode, fiatCurrency) {
|
|
94
|
+
const base = 'https://buy.moonpay.com';
|
|
95
|
+
const url = new URL(base);
|
|
96
|
+
url.searchParams.set('apiKey', this.apiKey);
|
|
97
|
+
url.searchParams.set('currencyCode', currencyCode);
|
|
98
|
+
url.searchParams.set('baseCurrencyCode', fiatCurrency);
|
|
99
|
+
url.searchParams.set('baseCurrencyAmount', String(params.amount));
|
|
100
|
+
url.searchParams.set('walletAddress', params.walletAddress);
|
|
101
|
+
if (params.redirectUrl) {
|
|
102
|
+
url.searchParams.set('redirectURL', params.redirectUrl);
|
|
103
|
+
}
|
|
104
|
+
return url.toString();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=moonpay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moonpay.js","sourceRoot":"","sources":["../../../src/fiat/providers/moonpay.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,MAAM,gBAAgB,GAAG,yBAAyB,CAAC;AACnD,MAAM,mBAAmB,GAAG,yBAAyB,CAAC,CAAC,kCAAkC;AAEzF,wEAAwE;AACxE,MAAM,SAAS,GAA2B;IACxC,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,eAAe;IACtB,IAAI,EAAE,MAAM;CACb,CAAC;AAEF,iFAAiF;AACjF,MAAM,eAAe,GAA2C;IAC9D,IAAI,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,EAAE;IAC5C,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE;IACpD,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE;IACxC,OAAO,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,cAAc,EAAE;IAC/E,QAAQ,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,EAAE;IACxD,QAAQ,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,EAAE;CACzD,CAAC;AAEF,gCAAgC;AAChC,MAAM,gBAAgB,GAA6B;IACj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,CAAC,CAAC,CAAC;QAClE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,eAAe,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;QAC5D,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YACvB,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QAC1D,CAAC;QACD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stripe Crypto Onramp Provider
|
|
3
|
+
*
|
|
4
|
+
* Creates onramp sessions via Stripe's REST API.
|
|
5
|
+
* Returns a hosted URL where users complete KYC + payment on Stripe's page.
|
|
6
|
+
* We never handle KYC data — it stays entirely within Stripe's infrastructure.
|
|
7
|
+
*
|
|
8
|
+
* API reference: https://docs.stripe.com/crypto/onramp
|
|
9
|
+
* Dashboard: https://dashboard.stripe.com
|
|
10
|
+
*
|
|
11
|
+
* Note: Stripe Crypto Onramp requires a server-side secret key to create sessions.
|
|
12
|
+
* The publishable key alone cannot create sessions. For agent use cases, the
|
|
13
|
+
* stripeApiKey in config should be the secret key (sk_live_... or sk_test_...).
|
|
14
|
+
*/
|
|
15
|
+
import type { FiatProvider, FiatQuote, OnrampParams } from '../types.js';
|
|
16
|
+
export declare class StripeProvider implements FiatProvider {
|
|
17
|
+
readonly name = "stripe";
|
|
18
|
+
readonly supportedAssets: Record<string, string[]>;
|
|
19
|
+
private apiKey;
|
|
20
|
+
constructor(apiKey: string, _testMode?: boolean);
|
|
21
|
+
get isConfigured(): boolean;
|
|
22
|
+
getQuote(params: OnrampParams): Promise<FiatQuote>;
|
|
23
|
+
createSession(params: OnrampParams): Promise<FiatQuote>;
|
|
24
|
+
private estimateCrypto;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=stripe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe.d.ts","sourceRoot":"","sources":["../../../src/fiat/providers/stripe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAiCzE,qBAAa,cAAe,YAAW,YAAY;IACjD,QAAQ,CAAC,IAAI,YAAY;IACzB,QAAQ,CAAC,eAAe,2BAAoB;IAE5C,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM,EAAE,SAAS,UAAQ;IAI7C,IAAI,YAAY,IAAI,OAAO,CAE1B;IAEK,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC;IA2BlD,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC;IAoE7D,OAAO,CAAC,cAAc;CAQvB"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stripe Crypto Onramp Provider
|
|
3
|
+
*
|
|
4
|
+
* Creates onramp sessions via Stripe's REST API.
|
|
5
|
+
* Returns a hosted URL where users complete KYC + payment on Stripe's page.
|
|
6
|
+
* We never handle KYC data — it stays entirely within Stripe's infrastructure.
|
|
7
|
+
*
|
|
8
|
+
* API reference: https://docs.stripe.com/crypto/onramp
|
|
9
|
+
* Dashboard: https://dashboard.stripe.com
|
|
10
|
+
*
|
|
11
|
+
* Note: Stripe Crypto Onramp requires a server-side secret key to create sessions.
|
|
12
|
+
* The publishable key alone cannot create sessions. For agent use cases, the
|
|
13
|
+
* stripeApiKey in config should be the secret key (sk_live_... or sk_test_...).
|
|
14
|
+
*/
|
|
15
|
+
const STRIPE_API_URL = 'https://api.stripe.com/v1/crypto/onramp_sessions';
|
|
16
|
+
/** Stripe's crypto destination network identifiers */
|
|
17
|
+
const CHAIN_MAP = {
|
|
18
|
+
ethereum: 'ethereum',
|
|
19
|
+
base: 'base',
|
|
20
|
+
solana: 'solana',
|
|
21
|
+
polygon: 'polygon',
|
|
22
|
+
arbitrum: 'arbitrum',
|
|
23
|
+
optimism: 'optimism',
|
|
24
|
+
};
|
|
25
|
+
/** Stripe's crypto currency identifiers */
|
|
26
|
+
const TOKEN_MAP = {
|
|
27
|
+
USDC: 'usdc',
|
|
28
|
+
ETH: 'eth',
|
|
29
|
+
SOL: 'sol',
|
|
30
|
+
MATIC: 'matic',
|
|
31
|
+
BTC: 'btc',
|
|
32
|
+
};
|
|
33
|
+
/** Supported assets by chain for Stripe */
|
|
34
|
+
const SUPPORTED_ASSETS = {
|
|
35
|
+
ethereum: ['ETH', 'USDC'],
|
|
36
|
+
base: ['ETH', 'USDC'],
|
|
37
|
+
solana: ['SOL', 'USDC'],
|
|
38
|
+
polygon: ['MATIC', 'USDC'],
|
|
39
|
+
arbitrum: ['ETH', 'USDC'],
|
|
40
|
+
optimism: ['ETH', 'USDC'],
|
|
41
|
+
};
|
|
42
|
+
export class StripeProvider {
|
|
43
|
+
constructor(apiKey, _testMode = false) {
|
|
44
|
+
this.name = 'stripe';
|
|
45
|
+
this.supportedAssets = SUPPORTED_ASSETS;
|
|
46
|
+
this.apiKey = apiKey;
|
|
47
|
+
}
|
|
48
|
+
get isConfigured() {
|
|
49
|
+
return Boolean(this.apiKey);
|
|
50
|
+
}
|
|
51
|
+
async getQuote(params) {
|
|
52
|
+
// Stripe doesn't have a separate quote endpoint — createSession is the entry point.
|
|
53
|
+
// We estimate fees at ~1.5% (Stripe's standard crypto onramp rate).
|
|
54
|
+
const feePercent = 1.5;
|
|
55
|
+
const feeAmount = params.amount * (feePercent / 100);
|
|
56
|
+
const netFiat = params.amount - feeAmount;
|
|
57
|
+
// Placeholder rate estimates (real rates come from the session response)
|
|
58
|
+
const estimatedCryptoAmount = this.estimateCrypto(netFiat, params.token, params.currency ?? 'USD');
|
|
59
|
+
return {
|
|
60
|
+
provider: this.name,
|
|
61
|
+
fiatAmount: params.amount,
|
|
62
|
+
fiatCurrency: (params.currency ?? 'USD').toUpperCase(),
|
|
63
|
+
cryptoAmount: estimatedCryptoAmount,
|
|
64
|
+
cryptoToken: params.token.toUpperCase(),
|
|
65
|
+
chain: params.chain,
|
|
66
|
+
feeAmount,
|
|
67
|
+
feePercent,
|
|
68
|
+
netCryptoAmount: estimatedCryptoAmount,
|
|
69
|
+
paymentMethods: ['card', 'bank_transfer'],
|
|
70
|
+
estimatedTimeMinutes: 5,
|
|
71
|
+
kycRequired: true,
|
|
72
|
+
purchaseUrl: undefined, // Populated by createSession
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
async createSession(params) {
|
|
76
|
+
const stripeChain = CHAIN_MAP[params.chain] ?? params.chain;
|
|
77
|
+
const stripeToken = TOKEN_MAP[params.token] ?? params.token.toLowerCase();
|
|
78
|
+
const currency = (params.currency ?? 'USD').toLowerCase();
|
|
79
|
+
// Build form-encoded body (Stripe uses application/x-www-form-urlencoded)
|
|
80
|
+
const body = new URLSearchParams();
|
|
81
|
+
body.set('transaction_details[wallet_address]', params.walletAddress);
|
|
82
|
+
body.set('transaction_details[supported_destination_networks][]', stripeChain);
|
|
83
|
+
body.set('transaction_details[supported_destination_currencies][]', stripeToken);
|
|
84
|
+
body.set('transaction_details[destination_network]', stripeChain);
|
|
85
|
+
body.set('transaction_details[destination_currency]', stripeToken);
|
|
86
|
+
body.set('transaction_details[source_currency]', currency);
|
|
87
|
+
body.set('transaction_details[source_amount]', String(params.amount));
|
|
88
|
+
if (params.redirectUrl) {
|
|
89
|
+
body.set('customer_ip_address', ''); // Required field — agent provides blank
|
|
90
|
+
}
|
|
91
|
+
const response = await fetch(STRIPE_API_URL, {
|
|
92
|
+
method: 'POST',
|
|
93
|
+
headers: {
|
|
94
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
95
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
96
|
+
},
|
|
97
|
+
body: body.toString(),
|
|
98
|
+
});
|
|
99
|
+
if (!response.ok) {
|
|
100
|
+
const errorData = await response.json().catch(() => ({ error: { message: response.statusText } }));
|
|
101
|
+
throw new Error(`Stripe API error ${response.status}: ${errorData.error?.message ?? response.statusText}`);
|
|
102
|
+
}
|
|
103
|
+
const session = await response.json();
|
|
104
|
+
const txDetails = session.transaction_details ?? {};
|
|
105
|
+
const fiatAmount = parseFloat(txDetails.source_amount ?? String(params.amount));
|
|
106
|
+
const cryptoAmount = txDetails.destination_amount ?? '0';
|
|
107
|
+
const feeAmount = parseFloat(txDetails.fees?.amount ?? String(params.amount * 0.015));
|
|
108
|
+
const feePercent = fiatAmount > 0 ? (feeAmount / fiatAmount) * 100 : 1.5;
|
|
109
|
+
return {
|
|
110
|
+
provider: this.name,
|
|
111
|
+
fiatAmount,
|
|
112
|
+
fiatCurrency: (params.currency ?? 'USD').toUpperCase(),
|
|
113
|
+
cryptoAmount,
|
|
114
|
+
cryptoToken: params.token.toUpperCase(),
|
|
115
|
+
chain: params.chain,
|
|
116
|
+
feeAmount,
|
|
117
|
+
feePercent: Math.round(feePercent * 100) / 100,
|
|
118
|
+
netCryptoAmount: cryptoAmount,
|
|
119
|
+
paymentMethods: ['card', 'bank_transfer'],
|
|
120
|
+
estimatedTimeMinutes: 5,
|
|
121
|
+
kycRequired: true,
|
|
122
|
+
purchaseUrl: session.redirect_url,
|
|
123
|
+
sessionId: session.id,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
estimateCrypto(netFiat, token, _currency) {
|
|
127
|
+
// Very rough estimates for quote previews — real amounts come from createSession
|
|
128
|
+
const rates = {
|
|
129
|
+
ETH: 3000, SOL: 150, BTC: 65000, USDC: 1, USDT: 1, MATIC: 0.8,
|
|
130
|
+
};
|
|
131
|
+
const rate = rates[token.toUpperCase()] ?? 1;
|
|
132
|
+
return (netFiat / rate).toFixed(6);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=stripe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe.js","sourceRoot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AAE,CAAC,EAAE,KAAK,EAAE,GAAG;SAC9D,CAAC;QACF,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transak Provider
|
|
3
|
+
*
|
|
4
|
+
* Creates onramp sessions via Transak's REST API.
|
|
5
|
+
* Returns a hosted URL where users complete KYC + payment on Transak's page.
|
|
6
|
+
* We never handle KYC data — it stays entirely within Transak's infrastructure.
|
|
7
|
+
*
|
|
8
|
+
* API reference: https://docs.transak.com/reference/get-price
|
|
9
|
+
* Dashboard: https://dashboard.transak.com
|
|
10
|
+
*/
|
|
11
|
+
import type { FiatProvider, FiatQuote, OnrampParams } from '../types.js';
|
|
12
|
+
export declare class TransakProvider implements FiatProvider {
|
|
13
|
+
readonly name = "transak";
|
|
14
|
+
readonly supportedAssets: Record<string, string[]>;
|
|
15
|
+
private apiKey;
|
|
16
|
+
private testMode;
|
|
17
|
+
private baseUrl;
|
|
18
|
+
private widgetUrl;
|
|
19
|
+
constructor(apiKey: string, testMode?: boolean);
|
|
20
|
+
get isConfigured(): boolean;
|
|
21
|
+
getQuote(params: OnrampParams): Promise<FiatQuote>;
|
|
22
|
+
createSession(params: OnrampParams): Promise<FiatQuote>;
|
|
23
|
+
private buildWidgetUrl;
|
|
24
|
+
private extractPaymentMethods;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=transak.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transak.d.ts","sourceRoot":"","sources":["../../../src/fiat/providers/transak.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAgDzE,qBAAa,eAAgB,YAAW,YAAY;IAClD,QAAQ,CAAC,IAAI,aAAa;IAC1B,QAAQ,CAAC,eAAe,2BAAoB;IAE5C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,SAAS,CAAS;gBAEd,MAAM,EAAE,MAAM,EAAE,QAAQ,UAAQ;IAO5C,IAAI,YAAY,IAAI,OAAO,CAE1B;IAEK,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC;IAmDlD,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC;IAK7D,OAAO,CAAC,cAAc;IAkBtB,OAAO,CAAC,qBAAqB;CAM9B"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transak Provider
|
|
3
|
+
*
|
|
4
|
+
* Creates onramp sessions via Transak's REST API.
|
|
5
|
+
* Returns a hosted URL where users complete KYC + payment on Transak's page.
|
|
6
|
+
* We never handle KYC data — it stays entirely within Transak's infrastructure.
|
|
7
|
+
*
|
|
8
|
+
* API reference: https://docs.transak.com/reference/get-price
|
|
9
|
+
* Dashboard: https://dashboard.transak.com
|
|
10
|
+
*/
|
|
11
|
+
const TRANSAK_BASE_URL = 'https://api.transak.com/api/v2';
|
|
12
|
+
const TRANSAK_SANDBOX_URL = 'https://staging-api.transak.com/api/v2';
|
|
13
|
+
const TRANSAK_WIDGET_URL = 'https://global.transak.com';
|
|
14
|
+
const TRANSAK_SANDBOX_WIDGET_URL = 'https://global-stg.transak.com';
|
|
15
|
+
/** Transak network identifiers */
|
|
16
|
+
const CHAIN_MAP = {
|
|
17
|
+
ethereum: 'ethereum',
|
|
18
|
+
base: 'base',
|
|
19
|
+
solana: 'solana',
|
|
20
|
+
polygon: 'polygon',
|
|
21
|
+
arbitrum: 'arbitrum',
|
|
22
|
+
optimism: 'optimism',
|
|
23
|
+
avalanche: 'avaxcchain',
|
|
24
|
+
bsc: 'bsc',
|
|
25
|
+
};
|
|
26
|
+
/** Supported assets by chain */
|
|
27
|
+
const SUPPORTED_ASSETS = {
|
|
28
|
+
ethereum: ['ETH', 'USDC', 'USDT', 'DAI'],
|
|
29
|
+
base: ['ETH', 'USDC'],
|
|
30
|
+
solana: ['SOL', 'USDC'],
|
|
31
|
+
polygon: ['MATIC', 'USDC', 'USDT', 'DAI'],
|
|
32
|
+
arbitrum: ['ETH', 'USDC', 'USDT'],
|
|
33
|
+
optimism: ['ETH', 'USDC', 'USDT'],
|
|
34
|
+
avalanche: ['AVAX', 'USDC'],
|
|
35
|
+
bsc: ['BNB', 'USDT', 'BUSD'],
|
|
36
|
+
};
|
|
37
|
+
export class TransakProvider {
|
|
38
|
+
constructor(apiKey, testMode = false) {
|
|
39
|
+
this.name = 'transak';
|
|
40
|
+
this.supportedAssets = SUPPORTED_ASSETS;
|
|
41
|
+
this.apiKey = apiKey;
|
|
42
|
+
this.testMode = testMode;
|
|
43
|
+
this.baseUrl = testMode ? TRANSAK_SANDBOX_URL : TRANSAK_BASE_URL;
|
|
44
|
+
this.widgetUrl = testMode ? TRANSAK_SANDBOX_WIDGET_URL : TRANSAK_WIDGET_URL;
|
|
45
|
+
}
|
|
46
|
+
get isConfigured() {
|
|
47
|
+
return Boolean(this.apiKey);
|
|
48
|
+
}
|
|
49
|
+
async getQuote(params) {
|
|
50
|
+
const network = CHAIN_MAP[params.chain] ?? params.chain;
|
|
51
|
+
const currency = (params.currency ?? 'USD').toUpperCase();
|
|
52
|
+
const url = new URL(`${this.baseUrl}/currencies/price`);
|
|
53
|
+
url.searchParams.set('partnerApiKey', this.apiKey);
|
|
54
|
+
url.searchParams.set('fiatCurrency', currency);
|
|
55
|
+
url.searchParams.set('cryptoCurrency', params.token.toUpperCase());
|
|
56
|
+
url.searchParams.set('isBuyOrSell', 'BUY');
|
|
57
|
+
url.searchParams.set('fiatAmount', String(params.amount));
|
|
58
|
+
url.searchParams.set('network', network);
|
|
59
|
+
const response = await fetch(url.toString(), {
|
|
60
|
+
headers: { Accept: 'application/json' },
|
|
61
|
+
});
|
|
62
|
+
if (!response.ok) {
|
|
63
|
+
const errorText = await response.text().catch(() => response.statusText);
|
|
64
|
+
throw new Error(`Transak API error ${response.status}: ${errorText}`);
|
|
65
|
+
}
|
|
66
|
+
const data = await response.json();
|
|
67
|
+
if (data.error) {
|
|
68
|
+
throw new Error(`Transak error: ${data.error.message}`);
|
|
69
|
+
}
|
|
70
|
+
const r = data.response ?? {};
|
|
71
|
+
const cryptoAmount = r.cryptoAmount ?? 0;
|
|
72
|
+
const feePercent = ((r.feeDecimal ?? 0) + (r.partnerFeeDecimal ?? 0)) * 100;
|
|
73
|
+
const feeAmount = params.amount * (feePercent / 100);
|
|
74
|
+
const purchaseUrl = this.buildWidgetUrl(params, network, currency);
|
|
75
|
+
return {
|
|
76
|
+
provider: this.name,
|
|
77
|
+
fiatAmount: params.amount,
|
|
78
|
+
fiatCurrency: currency,
|
|
79
|
+
cryptoAmount: String(cryptoAmount),
|
|
80
|
+
cryptoToken: params.token.toUpperCase(),
|
|
81
|
+
chain: params.chain,
|
|
82
|
+
feeAmount,
|
|
83
|
+
feePercent: Math.round(feePercent * 100) / 100,
|
|
84
|
+
netCryptoAmount: String(cryptoAmount),
|
|
85
|
+
paymentMethods: this.extractPaymentMethods(r.payment_methods),
|
|
86
|
+
estimatedTimeMinutes: 15,
|
|
87
|
+
kycRequired: true,
|
|
88
|
+
purchaseUrl,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
async createSession(params) {
|
|
92
|
+
// Transak uses a URL-based widget flow — session = widget URL with params
|
|
93
|
+
return this.getQuote(params);
|
|
94
|
+
}
|
|
95
|
+
buildWidgetUrl(params, network, currency) {
|
|
96
|
+
const url = new URL(this.widgetUrl);
|
|
97
|
+
url.searchParams.set('apiKey', this.apiKey);
|
|
98
|
+
url.searchParams.set('fiatCurrency', currency);
|
|
99
|
+
url.searchParams.set('cryptoCurrencyCode', params.token.toUpperCase());
|
|
100
|
+
url.searchParams.set('fiatAmount', String(params.amount));
|
|
101
|
+
url.searchParams.set('network', network);
|
|
102
|
+
url.searchParams.set('walletAddress', params.walletAddress);
|
|
103
|
+
url.searchParams.set('isBuyOrSell', 'BUY');
|
|
104
|
+
if (this.testMode) {
|
|
105
|
+
url.searchParams.set('environment', 'STAGING');
|
|
106
|
+
}
|
|
107
|
+
if (params.redirectUrl) {
|
|
108
|
+
url.searchParams.set('redirectURL', params.redirectUrl);
|
|
109
|
+
}
|
|
110
|
+
return url.toString();
|
|
111
|
+
}
|
|
112
|
+
extractPaymentMethods(methods) {
|
|
113
|
+
if (!methods || methods.length === 0) {
|
|
114
|
+
return ['card', 'bank_transfer', 'apple_pay', 'google_pay'];
|
|
115
|
+
}
|
|
116
|
+
return methods.map((m) => m.id ?? 'card').filter(Boolean);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=transak.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transak.js","sourceRoot":"","sources":["../../../src/fiat/providers/transak.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,MAAM,gBAAgB,GAAG,gCAAgC,CAAC;AAC1D,MAAM,mBAAmB,GAAG,wCAAwC,CAAC;AACrE,MAAM,kBAAkB,GAAG,4BAA4B,CAAC;AACxD,MAAM,0BAA0B,GAAG,gCAAgC,CAAC;AAEpE,kCAAkC;AAClC,MAAM,SAAS,GAA2B;IACxC,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,YAAY;IACvB,GAAG,EAAE,KAAK;CACX,CAAC;AAEF,gCAAgC;AAChC,MAAM,gBAAgB,GAA6B;IACjD,QA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0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FiatOnramp Types
|
|
3
|
+
*
|
|
4
|
+
* IMPORTANT: The fiat onramp module is entirely OPT-IN.
|
|
5
|
+
* Users who fund their agent wallet via direct crypto transfer, bridge,
|
|
6
|
+
* or any other method NEVER encounter KYC and remain fully anonymous.
|
|
7
|
+
*
|
|
8
|
+
* KYC only occurs when a user explicitly chooses to use the fiat onramp
|
|
9
|
+
* feature. The SDK never collects or stores KYC data — all KYC is handled
|
|
10
|
+
* entirely by the third-party provider on their hosted page.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Configuration for the FiatOnramp module.
|
|
14
|
+
* API keys are per-provider — only configure the providers you want to use.
|
|
15
|
+
* Omitting all keys is valid; it just returns an empty provider list.
|
|
16
|
+
*/
|
|
17
|
+
export interface FiatOnrampConfig {
|
|
18
|
+
/** MoonPay publishable API key — https://dashboard.moonpay.com */
|
|
19
|
+
moonpayApiKey?: string;
|
|
20
|
+
/** Stripe publishable API key — https://dashboard.stripe.com */
|
|
21
|
+
stripeApiKey?: string;
|
|
22
|
+
/** Transak API key — https://dashboard.transak.com */
|
|
23
|
+
transakApiKey?: string;
|
|
24
|
+
/** Default fiat currency (ISO 4217). Defaults to 'USD'. */
|
|
25
|
+
defaultCurrency?: string;
|
|
26
|
+
/** Use sandbox/test mode for all providers. Defaults to false. */
|
|
27
|
+
testMode?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A quote from a single fiat onramp provider.
|
|
31
|
+
*
|
|
32
|
+
* NOTE: kycRequired is always true for fiat onramp. KYC happens entirely
|
|
33
|
+
* on the provider's hosted page — the SDK never sees any KYC data.
|
|
34
|
+
*/
|
|
35
|
+
export interface FiatQuote {
|
|
36
|
+
/** Provider identifier: 'moonpay' | 'stripe' | 'transak' */
|
|
37
|
+
provider: string;
|
|
38
|
+
/** Fiat amount the user will pay */
|
|
39
|
+
fiatAmount: number;
|
|
40
|
+
/** Fiat currency code (e.g. 'USD', 'EUR', 'GBP') */
|
|
41
|
+
fiatCurrency: string;
|
|
42
|
+
/** Estimated gross crypto output before fees */
|
|
43
|
+
cryptoAmount: string;
|
|
44
|
+
/** Crypto token symbol (e.g. 'USDC', 'ETH', 'SOL') */
|
|
45
|
+
cryptoToken: string;
|
|
46
|
+
/** Destination blockchain (e.g. 'ethereum', 'base', 'solana') */
|
|
47
|
+
chain: string;
|
|
48
|
+
/** Provider fee in fiat currency */
|
|
49
|
+
feeAmount: number;
|
|
50
|
+
/** Provider fee as a percentage of fiatAmount */
|
|
51
|
+
feePercent: number;
|
|
52
|
+
/** Net crypto amount the wallet receives after fees */
|
|
53
|
+
netCryptoAmount: string;
|
|
54
|
+
/** Supported payment methods for this quote */
|
|
55
|
+
paymentMethods: string[];
|
|
56
|
+
/** Estimated minutes until crypto arrives in wallet */
|
|
57
|
+
estimatedTimeMinutes: number;
|
|
58
|
+
/**
|
|
59
|
+
* KYC is ALWAYS required for fiat onramp — this is always true.
|
|
60
|
+
* KYC is handled entirely by the provider on their hosted page.
|
|
61
|
+
* The SDK never sees, stores, or transmits any KYC data.
|
|
62
|
+
*/
|
|
63
|
+
kycRequired: true;
|
|
64
|
+
/**
|
|
65
|
+
* URL to complete the purchase.
|
|
66
|
+
* Opening this URL takes the user to the provider's hosted KYC + payment page.
|
|
67
|
+
* After completion, crypto is sent directly to the walletAddress.
|
|
68
|
+
*/
|
|
69
|
+
purchaseUrl?: string;
|
|
70
|
+
/** Provider session ID for tracking purchase status */
|
|
71
|
+
sessionId?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Parameters for requesting a fiat onramp quote or session.
|
|
75
|
+
*/
|
|
76
|
+
export interface OnrampParams {
|
|
77
|
+
/** Fiat amount to spend (in the specified currency) */
|
|
78
|
+
amount: number;
|
|
79
|
+
/** Fiat currency code. Defaults to FiatOnrampConfig.defaultCurrency or 'USD' */
|
|
80
|
+
currency?: string;
|
|
81
|
+
/** Target crypto token (e.g. 'USDC', 'ETH', 'SOL') */
|
|
82
|
+
token: string;
|
|
83
|
+
/** Target blockchain (e.g. 'ethereum', 'base', 'solana') */
|
|
84
|
+
chain: string;
|
|
85
|
+
/** Wallet address where crypto will be delivered */
|
|
86
|
+
walletAddress: string;
|
|
87
|
+
/** Optional redirect URL after the provider's hosted purchase flow completes */
|
|
88
|
+
redirectUrl?: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Internal provider interface — implemented by each provider module.
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
export interface FiatProvider {
|
|
95
|
+
/** Provider identifier */
|
|
96
|
+
readonly name: string;
|
|
97
|
+
/** Whether this provider is configured (has an API key) */
|
|
98
|
+
readonly isConfigured: boolean;
|
|
99
|
+
/** Supported chain → token mapping */
|
|
100
|
+
readonly supportedAssets: Record<string, string[]>;
|
|
101
|
+
/** Get a quote from this provider */
|
|
102
|
+
getQuote(params: OnrampParams): Promise<FiatQuote>;
|
|
103
|
+
/** Create a purchase session (may call additional APIs beyond getQuote) */
|
|
104
|
+
createSession(params: OnrampParams): Promise<FiatQuote>;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/fiat/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,4DAA4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QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IACnD,2EAA2E;IAC3E,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;CACzD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FiatOnramp Types
|
|
3
|
+
*
|
|
4
|
+
* IMPORTANT: The fiat onramp module is entirely OPT-IN.
|
|
5
|
+
* Users who fund their agent wallet via direct crypto transfer, bridge,
|
|
6
|
+
* or any other method NEVER encounter KYC and remain fully anonymous.
|
|
7
|
+
*
|
|
8
|
+
* KYC only occurs when a user explicitly chooses to use the fiat onramp
|
|
9
|
+
* feature. The SDK never collects or stores KYC data — all KYC is handled
|
|
10
|
+
* entirely by the third-party provider on their hosted page.
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/fiat/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { GasSponsor } from './sponsor.js';
|
|
2
|
+
export type { GasSponsorConfig, GasSupportedChain, UserOperation, SponsoredTx, SponsorTxParams, SponsorBridgeParams, } from './types.js';
|
|
3
|
+
export { ALCHEMY_NETWORK_SLUGS } from './types.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,eAAe,EACf,mBAAmB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAS1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC"}
|