@zkp2p/sdk 0.3.2-rc.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-J5LGTIGS.mjs +9 -0
- package/dist/chunk-J5LGTIGS.mjs.map +1 -0
- package/dist/chunk-JRDFLSA7.mjs +40529 -0
- package/dist/chunk-JRDFLSA7.mjs.map +1 -0
- package/dist/{currency-PKI2EGJD.mjs → currency-MARF3D2J.mjs} +3 -2
- package/dist/{currency-PKI2EGJD.mjs.map → currency-MARF3D2J.mjs.map} +1 -1
- package/dist/index.cjs +40672 -219
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +87 -11
- package/dist/index.mjs.map +1 -1
- package/dist/protocolViewerParsers-CQSES3QX.mjs +5 -0
- package/dist/{protocolViewerParsers-ZQZ6QGEX.mjs.map → protocolViewerParsers-CQSES3QX.mjs.map} +1 -1
- package/dist/react.mjs +1 -0
- package/dist/react.mjs.map +1 -1
- package/dist/{timeout-QB7K5SOB.mjs → timeout-YLP3WHZF.mjs} +3 -2
- package/dist/timeout-YLP3WHZF.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-ENH4KRFK.mjs +0 -506
- package/dist/chunk-ENH4KRFK.mjs.map +0 -1
- package/dist/protocolViewerParsers-ZQZ6QGEX.mjs +0 -4
- package/dist/timeout-QB7K5SOB.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export { ZERO_RATE_MANAGER_ID, classifyDelegationState, getDelegationRoute, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry } from './chunk-LPJE2MN7.mjs';
|
|
2
2
|
import { ValidationError, NetworkError, APIError } from './chunk-GHQK65J2.mjs';
|
|
3
3
|
export { APIError, ContractError, ErrorCode, NetworkError, ValidationError, ZKP2PError } from './chunk-GHQK65J2.mjs';
|
|
4
|
-
import { getContracts, getRateManagerContracts, getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog, getGatingServiceAddress, parseBigIntLike, resolveFiatCurrencyBytes32, resolvePaymentMethodNameFromHash } from './chunk-
|
|
5
|
-
export { asciiToBytes32, enrichPvDepositView, enrichPvIntentView, ensureBytes32, getContracts, getGatingServiceAddress, getPaymentMethodsCatalog, getRateManagerContracts, parseDepositView, parseIntentView, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash } from './chunk-
|
|
4
|
+
import { getContracts, getRateManagerContracts, getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog, getGatingServiceAddress, parseBigIntLike, resolveFiatCurrencyBytes32, resolvePaymentMethodNameFromHash } from './chunk-JRDFLSA7.mjs';
|
|
5
|
+
export { asciiToBytes32, enrichPvDepositView, enrichPvIntentView, ensureBytes32, getContracts, getGatingServiceAddress, getPaymentMethodsCatalog, getRateManagerContracts, parseDepositView, parseIntentView, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash } from './chunk-JRDFLSA7.mjs';
|
|
6
6
|
import { Currency, currencyKeccak256 } from './chunk-ZFBH4HD7.mjs';
|
|
7
7
|
export { Currency, currencyInfo, getCurrencyCodeFromHash, getCurrencyInfoFromCountryCode, getCurrencyInfoFromHash, isSupportedCurrencyHash, mapConversionRatesToOnchainMinRate } from './chunk-ZFBH4HD7.mjs';
|
|
8
|
+
import './chunk-J5LGTIGS.mjs';
|
|
8
9
|
import { concatHex, encodeFunctionData, encodeAbiParameters, createPublicClient, http, formatUnits } from 'viem';
|
|
9
10
|
import { hardhat, base } from 'viem/chains';
|
|
10
11
|
import { AbiCoder } from 'ethers';
|
|
11
12
|
import { Attribution } from 'ox/erc8021';
|
|
12
|
-
import chainlinkFeeds from '@zkp2p/contracts-v2/oracleFeeds/chainlink.json';
|
|
13
13
|
|
|
14
14
|
// src/utils/address.ts
|
|
15
15
|
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
@@ -340,7 +340,7 @@ async function withRetry(fn, maxRetries = 3, delayMs = 1e3, timeoutMs) {
|
|
|
340
340
|
for (let i = 0; i < maxRetries; i++) {
|
|
341
341
|
try {
|
|
342
342
|
if (timeoutMs) {
|
|
343
|
-
const { withTimeout } = await import('./timeout-
|
|
343
|
+
const { withTimeout } = await import('./timeout-YLP3WHZF.mjs');
|
|
344
344
|
return await withTimeout(fn(), timeoutMs, `Operation timed out after ${timeoutMs}ms`);
|
|
345
345
|
}
|
|
346
346
|
return await fn();
|
|
@@ -602,6 +602,82 @@ var PAYMENT_PLATFORMS = [
|
|
|
602
602
|
|
|
603
603
|
// src/utils/constants.ts
|
|
604
604
|
var DEFAULT_BASE_API_URL = "https://api.zkp2p.xyz";
|
|
605
|
+
|
|
606
|
+
// ../../node_modules/.pnpm/@zkp2p+contracts-v2@0.2.1_ethers@6.16.0_bufferutil@4.1.0_utf-8-validate@5.0.10__typescript@5.9.3_zod@4.2.1/node_modules/@zkp2p/contracts-v2/oracleFeeds/chainlink.json
|
|
607
|
+
var chainlink_default = {
|
|
608
|
+
feeds: [
|
|
609
|
+
{
|
|
610
|
+
pair: "AUD/USD",
|
|
611
|
+
feed: "0x46e51B8cA41d709928EdA9Ae43e42193E6CDf229",
|
|
612
|
+
decimals: 8
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
pair: "BRL/USD",
|
|
616
|
+
feed: "0x0b0E64c05083FdF9ED7C5D3d8262c4216eFc9394",
|
|
617
|
+
decimals: 8
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
pair: "CAD/USD",
|
|
621
|
+
feed: "0xA840145F87572E82519d578b1F36340368a25D5d",
|
|
622
|
+
decimals: 8
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
pair: "CHF/USD",
|
|
626
|
+
feed: "0x3A1d6444fb6a402470098E23DaD0B7E86E14252F",
|
|
627
|
+
decimals: 8
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
pair: "EUR/USD",
|
|
631
|
+
feed: "0xc91D87E81faB8f93699ECf7Ee9B44D11e1D53F0F",
|
|
632
|
+
decimals: 8
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
pair: "GBP/USD",
|
|
636
|
+
feed: "0xCceA6576904C118037695eB71195a5425E69Fa15",
|
|
637
|
+
decimals: 8
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
pair: "IDR/USD",
|
|
641
|
+
feed: "0x05A6cF213EcC5501A11a08EBefA4A8a60313ef97",
|
|
642
|
+
decimals: 8
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
pair: "MXN/USD",
|
|
646
|
+
feed: "0x9e8Ee77c76d4fa41306056D1C3196AF5da1600bd",
|
|
647
|
+
decimals: 8
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
pair: "NGN/USD",
|
|
651
|
+
feed: "0xdfbb5Cbc88E382de007bfe6CE99C388176ED80aD",
|
|
652
|
+
decimals: 8
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
pair: "NZD/USD",
|
|
656
|
+
feed: "0x06bdFe07E71C476157FC025d3cCD4BBe08e83EF9",
|
|
657
|
+
decimals: 8
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
pair: "PHP/USD",
|
|
661
|
+
feed: "0x0396000dc82bfAEe746A9Ac6dC69dAd3223Ca9c6",
|
|
662
|
+
decimals: 8
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
pair: "SGD/USD",
|
|
666
|
+
feed: "0x81575495532fB311Efc5C993B612564274F0949b",
|
|
667
|
+
decimals: 8
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
pair: "TRY/USD",
|
|
671
|
+
feed: "0x29413773e7CD4Dfd6Ad89a50887877b88a6C592C",
|
|
672
|
+
decimals: 8
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
pair: "ZAR/USD",
|
|
676
|
+
feed: "0x2ecc8A8B370fC6a217166b2782a35339bEBEe98B",
|
|
677
|
+
decimals: 8
|
|
678
|
+
}
|
|
679
|
+
]
|
|
680
|
+
};
|
|
605
681
|
var ZERO_ADDRESS2 = "0x0000000000000000000000000000000000000000";
|
|
606
682
|
var CHAINLINK_ORACLE_ADAPTER = "0xfc81d1b5841e697973af3072fc8e03af76cb39ef";
|
|
607
683
|
var PYTH_ORACLE_ADAPTER = "0xaa2bBDa3072bD37af76613846268Ec48bd0bB885";
|
|
@@ -635,7 +711,7 @@ function parseUsdPair(pair) {
|
|
|
635
711
|
}
|
|
636
712
|
function buildChainlinkOracleFeeds() {
|
|
637
713
|
const map = {};
|
|
638
|
-
for (const feed of
|
|
714
|
+
for (const feed of chainlink_default.feeds) {
|
|
639
715
|
const parsed = parseUsdPair(feed.pair);
|
|
640
716
|
if (!parsed) continue;
|
|
641
717
|
map[parsed.currency] = {
|
|
@@ -1495,7 +1571,7 @@ var ProtocolViewerReader = class {
|
|
|
1495
1571
|
if (inputCount === null) {
|
|
1496
1572
|
throw new Error("Configured ProtocolViewer ABI does not expose getDeposit");
|
|
1497
1573
|
}
|
|
1498
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
1574
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-CQSES3QX.mjs');
|
|
1499
1575
|
if (inputCount >= 3) {
|
|
1500
1576
|
return tryContexts(
|
|
1501
1577
|
protocolViewerContexts,
|
|
@@ -1574,7 +1650,7 @@ var ProtocolViewerReader = class {
|
|
|
1574
1650
|
return Promise.all(ids.map((id) => this.config.host.getPvDepositById(id)));
|
|
1575
1651
|
}
|
|
1576
1652
|
const bn = ids.map((id) => typeof id === "bigint" ? id : parseRawDepositId(id));
|
|
1577
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
1653
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-CQSES3QX.mjs');
|
|
1578
1654
|
if (inputCount >= 2) {
|
|
1579
1655
|
const requests = ids.map((id, index) => ({
|
|
1580
1656
|
index,
|
|
@@ -1679,7 +1755,7 @@ var ProtocolViewerReader = class {
|
|
|
1679
1755
|
if (!protocolViewerAddress || !protocolViewerAbi || inputCount === null) {
|
|
1680
1756
|
return this.config.host.getPvAccountDepositsFromIndexer(owner);
|
|
1681
1757
|
}
|
|
1682
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
1758
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-CQSES3QX.mjs');
|
|
1683
1759
|
const { address, abi } = this.config.host.requireProtocolViewer();
|
|
1684
1760
|
if (inputCount >= 2) {
|
|
1685
1761
|
const readAndFilter = async (raw2) => {
|
|
@@ -1750,7 +1826,7 @@ var ProtocolViewerReader = class {
|
|
|
1750
1826
|
if (protocolViewerEntries.length === 0) {
|
|
1751
1827
|
throw new Error("ProtocolViewer not available for this network");
|
|
1752
1828
|
}
|
|
1753
|
-
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-
|
|
1829
|
+
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-CQSES3QX.mjs');
|
|
1754
1830
|
const intentsByHash = /* @__PURE__ */ new Map();
|
|
1755
1831
|
let attemptedRead = false;
|
|
1756
1832
|
let hadSuccessfulRead = false;
|
|
@@ -1858,7 +1934,7 @@ var ProtocolViewerReader = class {
|
|
|
1858
1934
|
if (protocolViewerEntries.length === 0) {
|
|
1859
1935
|
throw new Error("ProtocolViewer not available for this network");
|
|
1860
1936
|
}
|
|
1861
|
-
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-
|
|
1937
|
+
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-CQSES3QX.mjs');
|
|
1862
1938
|
let lastError;
|
|
1863
1939
|
for (const pvEntry of protocolViewerEntries) {
|
|
1864
1940
|
const inputCount = this.pvEntryFunctionInputCount(pvEntry, "getIntent");
|
|
@@ -7388,7 +7464,7 @@ var Zkp2pClient = class {
|
|
|
7388
7464
|
}
|
|
7389
7465
|
}
|
|
7390
7466
|
});
|
|
7391
|
-
const { mapConversionRatesToOnchainMinRate: mapConversionRatesToOnchainMinRate2 } = await import('./currency-
|
|
7467
|
+
const { mapConversionRatesToOnchainMinRate: mapConversionRatesToOnchainMinRate2 } = await import('./currency-MARF3D2J.mjs');
|
|
7392
7468
|
const normalized = params.conversionRates.map(
|
|
7393
7469
|
(group) => group.map((r) => ({ currency: r.currency, conversionRate: r.conversionRate }))
|
|
7394
7470
|
);
|