@zkp2p/sdk 0.11.2 → 0.12.1
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 +104 -9
- package/dist/{chunk-LPKFXAKY.mjs → chunk-DZQOCRT4.mjs} +44196 -1199
- package/dist/chunk-DZQOCRT4.mjs.map +1 -0
- package/dist/index.cjs +45095 -1568
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +33 -5
- package/dist/index.d.ts +33 -5
- package/dist/index.mjs +538 -16
- package/dist/index.mjs.map +1 -1
- package/dist/protocolViewerParsers-WK2QPJH7.mjs +5 -0
- package/dist/{protocolViewerParsers-M7C2ICV3.mjs.map → protocolViewerParsers-WK2QPJH7.mjs.map} +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/{vaultUtils-CbfjrxgD.d.mts → vaultUtils-Bc9KwywX.d.mts} +330 -7
- package/dist/{vaultUtils-CbfjrxgD.d.ts → vaultUtils-Bc9KwywX.d.ts} +330 -7
- package/package.json +1 -1
- package/dist/chunk-LPKFXAKY.mjs.map +0 -1
- package/dist/protocolViewerParsers-M7C2ICV3.mjs +0 -5
package/dist/index.mjs
CHANGED
|
@@ -2,12 +2,12 @@ import { IntentGuardianOperations } from './chunk-FCOH36IX.mjs';
|
|
|
2
2
|
export { ZERO_RATE_MANAGER_ID, classifyDelegationState, classifyIntentGuardianError, getDelegationRoute, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry } from './chunk-FCOH36IX.mjs';
|
|
3
3
|
import { NetworkError, ValidationError, APIError } from './chunk-GHQK65J2.mjs';
|
|
4
4
|
export { APIError, ContractError, ErrorCode, NetworkError, ValidationError, ZKP2PError } from './chunk-GHQK65J2.mjs';
|
|
5
|
-
import { METHOD_NAME_TO_HASH, matchesQuotePaymentMethod, matchesPaymentMethodNameAndHash, getContracts, getRateManagerContracts, getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog, getGatingServiceAddress, parseBigIntLike, SUPPORTED_PAYMENT_METHOD_HASHES, resolveFiatCurrencyBytes32, resolvePaymentMethodNameFromHash } from './chunk-
|
|
6
|
-
export { PAYMENT_PLATFORMS, asciiToBytes32, enrichPvDepositView, enrichPvIntentView, ensureBytes32, getContracts, getGatingServiceAddress, getIntentGuardianContract, getPaymentMethodsCatalog, getRateManagerContracts, hasIntentGuardian, parseDepositView, parseIntentView, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash } from './chunk-
|
|
5
|
+
import { METHOD_NAME_TO_HASH, matchesQuotePaymentMethod, matchesPaymentMethodNameAndHash, getContracts, getRateManagerContracts, getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog, getGatingServiceAddress, parseBigIntLike, SUPPORTED_PAYMENT_METHOD_HASHES, resolveFiatCurrencyBytes32, resolvePaymentMethodNameFromHash } from './chunk-DZQOCRT4.mjs';
|
|
6
|
+
export { CHARGEBACK_POLICY_ABI, ORCHESTRATOR_V3_ABI, PAYMENT_PLATFORMS, STAKE_VAULT_ABI, asciiToBytes32, enrichPvDepositView, enrichPvIntentView, ensureBytes32, getChargebackPolicyContract, getContracts, getGatingServiceAddress, getIntentGuardianContract, getOrchestratorV3Contract, getPaymentMethodsCatalog, getRateManagerContracts, getStakeVaultContract, hasIntentGuardian, parseDepositView, parseIntentView, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash } from './chunk-DZQOCRT4.mjs';
|
|
7
7
|
import { Currency, currencyKeccak256 } from './chunk-ZFBH4HD7.mjs';
|
|
8
8
|
export { Currency, currencyInfo, getCurrencyCodeFromHash, getCurrencyInfoFromCountryCode, getCurrencyInfoFromHash, isSupportedCurrencyHash, mapConversionRatesToOnchainMinRate } from './chunk-ZFBH4HD7.mjs';
|
|
9
9
|
import './chunk-J5LGTIGS.mjs';
|
|
10
|
-
import { concatHex, encodeFunctionData, encodeAbiParameters, createPublicClient, http, formatUnits } from 'viem';
|
|
10
|
+
import { concatHex, encodeFunctionData, encodeAbiParameters, createPublicClient, http, isAddress, zeroAddress, formatUnits } from 'viem';
|
|
11
11
|
import { hardhat, base } from 'viem/chains';
|
|
12
12
|
import { createEncryptedBuyerTeeSessionMaterial as createEncryptedBuyerTeeSessionMaterial$1, createEncryptedSellerCredentialUpload } from '@zkp2p/zkp2p-attestation';
|
|
13
13
|
export { createNitroAttestationClient } from '@zkp2p/zkp2p-attestation';
|
|
@@ -852,7 +852,7 @@ async function sendTransactionWithAttribution(walletClient, request, referrer, o
|
|
|
852
852
|
// src/utils/constants.ts
|
|
853
853
|
var DEFAULT_BASE_API_URL = "https://api.zkp2p.xyz";
|
|
854
854
|
|
|
855
|
-
// ../../node_modules/.pnpm/@zkp2p+contracts-v2@0.4.0_ethers@6.16.0_bufferutil@4.1.0_utf-8-validate@5.0.10__typescript@5.9.3_zod@4.
|
|
855
|
+
// ../../node_modules/.pnpm/@zkp2p+contracts-v2@0.4.0_ethers@6.16.0_bufferutil@4.1.0_utf-8-validate@5.0.10__typescript@5.9.3_zod@4.4.3/node_modules/@zkp2p/contracts-v2/oracleFeeds/chainlink.json
|
|
856
856
|
var chainlink_default = {
|
|
857
857
|
feeds: [
|
|
858
858
|
{
|
|
@@ -1898,7 +1898,7 @@ var ProtocolViewerReader = class {
|
|
|
1898
1898
|
if (inputCount === null) {
|
|
1899
1899
|
throw new Error("Configured ProtocolViewer ABI does not expose getDeposit");
|
|
1900
1900
|
}
|
|
1901
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
1901
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-WK2QPJH7.mjs');
|
|
1902
1902
|
if (inputCount >= 3) {
|
|
1903
1903
|
return tryContexts(
|
|
1904
1904
|
protocolViewerContexts,
|
|
@@ -1984,7 +1984,7 @@ var ProtocolViewerReader = class {
|
|
|
1984
1984
|
return Promise.all(ids.map((id) => this.config.host.getPvDepositById(id)));
|
|
1985
1985
|
}
|
|
1986
1986
|
const bn = ids.map((id) => typeof id === "bigint" ? id : parseRawDepositId(id));
|
|
1987
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
1987
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-WK2QPJH7.mjs');
|
|
1988
1988
|
if (inputCount >= 2) {
|
|
1989
1989
|
const requests = ids.map((id, index) => ({
|
|
1990
1990
|
index,
|
|
@@ -2089,7 +2089,7 @@ var ProtocolViewerReader = class {
|
|
|
2089
2089
|
if (!protocolViewerAddress || !protocolViewerAbi || inputCount === null) {
|
|
2090
2090
|
return this.config.host.getPvAccountDepositsFromIndexer(owner);
|
|
2091
2091
|
}
|
|
2092
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
2092
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-WK2QPJH7.mjs');
|
|
2093
2093
|
const { address, abi } = this.config.host.requireProtocolViewer();
|
|
2094
2094
|
if (inputCount >= 2) {
|
|
2095
2095
|
const readAndFilter = async (raw2) => {
|
|
@@ -2160,7 +2160,7 @@ var ProtocolViewerReader = class {
|
|
|
2160
2160
|
if (protocolViewerEntries.length === 0) {
|
|
2161
2161
|
throw new Error("ProtocolViewer not available for this network");
|
|
2162
2162
|
}
|
|
2163
|
-
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-
|
|
2163
|
+
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-WK2QPJH7.mjs');
|
|
2164
2164
|
const intentsByHash = /* @__PURE__ */ new Map();
|
|
2165
2165
|
let attemptedRead = false;
|
|
2166
2166
|
let hadSuccessfulRead = false;
|
|
@@ -2268,7 +2268,7 @@ var ProtocolViewerReader = class {
|
|
|
2268
2268
|
if (protocolViewerEntries.length === 0) {
|
|
2269
2269
|
throw new Error("ProtocolViewer not available for this network");
|
|
2270
2270
|
}
|
|
2271
|
-
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-
|
|
2271
|
+
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-WK2QPJH7.mjs');
|
|
2272
2272
|
let lastError;
|
|
2273
2273
|
for (const pvEntry of protocolViewerEntries) {
|
|
2274
2274
|
const inputCount = this.pvEntryFunctionInputCount(pvEntry, "getIntent");
|
|
@@ -3559,6 +3559,68 @@ var FULFILLMENT_AND_PAYMENT_QUERY = (
|
|
|
3559
3559
|
}
|
|
3560
3560
|
`
|
|
3561
3561
|
);
|
|
3562
|
+
var STAKING_STATE_QUERY = (
|
|
3563
|
+
/* GraphQL */
|
|
3564
|
+
`
|
|
3565
|
+
query StakingState(
|
|
3566
|
+
$takerStateId: String!
|
|
3567
|
+
$stakeAccountId: String!
|
|
3568
|
+
$claimAccountId: String!
|
|
3569
|
+
$vaultConfigId: String!
|
|
3570
|
+
$chainId: Int!
|
|
3571
|
+
$vault: String!
|
|
3572
|
+
$taker: String!
|
|
3573
|
+
$policy: String!
|
|
3574
|
+
) {
|
|
3575
|
+
TakerStakeState_by_pk(id: $takerStateId) {
|
|
3576
|
+
taker
|
|
3577
|
+
stakeOwner
|
|
3578
|
+
selectedStakeOwner
|
|
3579
|
+
selectionAuthorized
|
|
3580
|
+
updatedAtBlockNumber
|
|
3581
|
+
updatedAt
|
|
3582
|
+
}
|
|
3583
|
+
StakeAccountState_by_pk(id: $stakeAccountId) {
|
|
3584
|
+
stakeOwner
|
|
3585
|
+
totalStake
|
|
3586
|
+
lockedStake
|
|
3587
|
+
freeStake
|
|
3588
|
+
updatedAtBlockNumber
|
|
3589
|
+
updatedAt
|
|
3590
|
+
}
|
|
3591
|
+
ClaimAccountState_by_pk(id: $claimAccountId) {
|
|
3592
|
+
beneficiary
|
|
3593
|
+
claimableAmount
|
|
3594
|
+
updatedAtBlockNumber
|
|
3595
|
+
updatedAt
|
|
3596
|
+
}
|
|
3597
|
+
TakerStakeAuthorization(
|
|
3598
|
+
where: { chainId: { _eq: $chainId }, vaultAddress: { _eq: $vault }, taker: { _eq: $taker } }
|
|
3599
|
+
order_by: { updatedAt: desc }
|
|
3600
|
+
) {
|
|
3601
|
+
stakeOwner
|
|
3602
|
+
authorized
|
|
3603
|
+
updatedAtBlockNumber
|
|
3604
|
+
updatedAt
|
|
3605
|
+
}
|
|
3606
|
+
ChargebackRiskWindow(
|
|
3607
|
+
where: { chainId: { _eq: $chainId }, policyAddress: { _eq: $policy } }
|
|
3608
|
+
order_by: { paymentMethod: asc }
|
|
3609
|
+
) {
|
|
3610
|
+
paymentMethod
|
|
3611
|
+
riskWindow
|
|
3612
|
+
updatedAt
|
|
3613
|
+
}
|
|
3614
|
+
StakeVaultConfig_by_pk(id: $vaultConfigId) {
|
|
3615
|
+
controller
|
|
3616
|
+
pendingController
|
|
3617
|
+
pendingControllerValidAt
|
|
3618
|
+
updatedAtBlockNumber
|
|
3619
|
+
updatedAt
|
|
3620
|
+
}
|
|
3621
|
+
}
|
|
3622
|
+
`
|
|
3623
|
+
);
|
|
3562
3624
|
|
|
3563
3625
|
// src/indexer/converters.ts
|
|
3564
3626
|
var ZERO = "0x0000000000000000000000000000000000000000";
|
|
@@ -5453,6 +5515,110 @@ var AccessPolicyOperations = class {
|
|
|
5453
5515
|
);
|
|
5454
5516
|
}
|
|
5455
5517
|
};
|
|
5518
|
+
var StakeOperations = class {
|
|
5519
|
+
constructor(config) {
|
|
5520
|
+
this.config = config;
|
|
5521
|
+
}
|
|
5522
|
+
getContract() {
|
|
5523
|
+
const address = this.config.getStakeVaultAddress();
|
|
5524
|
+
const abi = this.config.getStakeVaultAbi();
|
|
5525
|
+
const stakeToken = this.config.getStakeTokenAddress();
|
|
5526
|
+
if (!address || !abi || !stakeToken) {
|
|
5527
|
+
throw new Error("StakeVault not available for this chain/environment");
|
|
5528
|
+
}
|
|
5529
|
+
return { address, abi, stakeToken };
|
|
5530
|
+
}
|
|
5531
|
+
getPolicyContract() {
|
|
5532
|
+
const address = this.config.getChargebackPolicyAddress();
|
|
5533
|
+
const abi = this.config.getChargebackPolicyAbi();
|
|
5534
|
+
if (!address || !abi) {
|
|
5535
|
+
throw new Error("ChargebackPolicy not available for this chain/environment");
|
|
5536
|
+
}
|
|
5537
|
+
return { address, abi };
|
|
5538
|
+
}
|
|
5539
|
+
read(functionName, args = []) {
|
|
5540
|
+
const { address, abi } = this.getContract();
|
|
5541
|
+
return this.config.getPublicClient().readContract({
|
|
5542
|
+
address,
|
|
5543
|
+
abi,
|
|
5544
|
+
functionName,
|
|
5545
|
+
args
|
|
5546
|
+
});
|
|
5547
|
+
}
|
|
5548
|
+
readPolicy(functionName, args = []) {
|
|
5549
|
+
const { address, abi } = this.getPolicyContract();
|
|
5550
|
+
return this.config.getPublicClient().readContract({
|
|
5551
|
+
address,
|
|
5552
|
+
abi,
|
|
5553
|
+
functionName,
|
|
5554
|
+
args
|
|
5555
|
+
});
|
|
5556
|
+
}
|
|
5557
|
+
getStakeBalance(stakeOwner) {
|
|
5558
|
+
return this.read("stakeBalance", [stakeOwner]);
|
|
5559
|
+
}
|
|
5560
|
+
getLockedStake(stakeOwner) {
|
|
5561
|
+
return this.read("lockedStake", [stakeOwner]);
|
|
5562
|
+
}
|
|
5563
|
+
getFreeStake(stakeOwner) {
|
|
5564
|
+
return this.read("freeStake", [stakeOwner]);
|
|
5565
|
+
}
|
|
5566
|
+
getClaimable(beneficiary) {
|
|
5567
|
+
return this.read("claimable", [beneficiary]);
|
|
5568
|
+
}
|
|
5569
|
+
getStakeOwner(taker) {
|
|
5570
|
+
return this.read("stakeOwnerOf", [taker]);
|
|
5571
|
+
}
|
|
5572
|
+
getSelectedStakeOwner(taker) {
|
|
5573
|
+
return this.read("selectedStakeOwner", [taker]);
|
|
5574
|
+
}
|
|
5575
|
+
getTakerAuthorization(stakeOwner, taker) {
|
|
5576
|
+
return this.read("authorizedTakers", [stakeOwner, taker]);
|
|
5577
|
+
}
|
|
5578
|
+
/** Whether the policy is refusing new chargebackable admissions. */
|
|
5579
|
+
getAdmissionsPaused() {
|
|
5580
|
+
return this.readPolicy("admissionsPaused");
|
|
5581
|
+
}
|
|
5582
|
+
/**
|
|
5583
|
+
* Minimum collateral lock window for a payment method, in seconds. Zero
|
|
5584
|
+
* means intents on this method admit unbonded — no stake is locked at all.
|
|
5585
|
+
*/
|
|
5586
|
+
getRiskWindow(paymentMethodHash) {
|
|
5587
|
+
return this.readPolicy("getRiskWindow", [paymentMethodHash]);
|
|
5588
|
+
}
|
|
5589
|
+
/** Whether a specific escrow deposit has opted into chargeback coverage. */
|
|
5590
|
+
isChargebackEnabled(escrow, depositId) {
|
|
5591
|
+
return this.readPolicy("isChargebackEnabled", [escrow, depositId]);
|
|
5592
|
+
}
|
|
5593
|
+
async getStakeVaultState(params) {
|
|
5594
|
+
const taker = params.taker ?? params.staker;
|
|
5595
|
+
const { stakeToken } = this.getContract();
|
|
5596
|
+
const [stakeOwner, rawSelection, staked, locked, free, claimable, admissionsPaused] = await Promise.all([
|
|
5597
|
+
this.getStakeOwner(taker),
|
|
5598
|
+
this.getSelectedStakeOwner(taker),
|
|
5599
|
+
this.getStakeBalance(params.staker),
|
|
5600
|
+
this.getLockedStake(params.staker),
|
|
5601
|
+
this.getFreeStake(params.staker),
|
|
5602
|
+
this.getClaimable(params.staker),
|
|
5603
|
+
this.getAdmissionsPaused()
|
|
5604
|
+
]);
|
|
5605
|
+
const selectedStakeOwner = rawSelection === zeroAddress ? null : rawSelection;
|
|
5606
|
+
const selectionAuthorized = selectedStakeOwner ? await this.getTakerAuthorization(selectedStakeOwner, taker) : false;
|
|
5607
|
+
return {
|
|
5608
|
+
staker: params.staker,
|
|
5609
|
+
taker,
|
|
5610
|
+
stakeToken,
|
|
5611
|
+
stakeOwner,
|
|
5612
|
+
selectedStakeOwner,
|
|
5613
|
+
selectionAuthorized,
|
|
5614
|
+
staked,
|
|
5615
|
+
locked,
|
|
5616
|
+
free,
|
|
5617
|
+
claimable,
|
|
5618
|
+
admissionsPaused
|
|
5619
|
+
};
|
|
5620
|
+
}
|
|
5621
|
+
};
|
|
5456
5622
|
|
|
5457
5623
|
// src/indexer/rateManagerService.ts
|
|
5458
5624
|
var DEFAULT_LIMIT2 = 50;
|
|
@@ -6172,6 +6338,168 @@ var IndexerRateManagerService = class {
|
|
|
6172
6338
|
}
|
|
6173
6339
|
}
|
|
6174
6340
|
};
|
|
6341
|
+
var ZERO_STAKE = {
|
|
6342
|
+
totalUsdc: "0",
|
|
6343
|
+
lockedUsdc: "0",
|
|
6344
|
+
freeUsdc: "0"
|
|
6345
|
+
};
|
|
6346
|
+
function normalizeAddress4(value, field) {
|
|
6347
|
+
if (!isAddress(value)) {
|
|
6348
|
+
throw new ValidationError(`${field} must be a valid Ethereum address`, field);
|
|
6349
|
+
}
|
|
6350
|
+
return value.toLowerCase();
|
|
6351
|
+
}
|
|
6352
|
+
function normalizeNullableAddress(value, field) {
|
|
6353
|
+
return value ? normalizeAddress4(value, field) : null;
|
|
6354
|
+
}
|
|
6355
|
+
function normalizeDecimal(value, field) {
|
|
6356
|
+
if (!/^\d+$/.test(value)) {
|
|
6357
|
+
throw new Error(`${field} must be an unsigned decimal string`);
|
|
6358
|
+
}
|
|
6359
|
+
return value;
|
|
6360
|
+
}
|
|
6361
|
+
function freshnessOf(row, field) {
|
|
6362
|
+
if (!row) return null;
|
|
6363
|
+
return {
|
|
6364
|
+
updatedAtBlockNumber: normalizeDecimal(
|
|
6365
|
+
row.updatedAtBlockNumber,
|
|
6366
|
+
`${field}.updatedAtBlockNumber`
|
|
6367
|
+
),
|
|
6368
|
+
updatedAt: normalizeDecimal(row.updatedAt, `${field}.updatedAt`)
|
|
6369
|
+
};
|
|
6370
|
+
}
|
|
6371
|
+
function minimumBlockNumber(rows) {
|
|
6372
|
+
const blockNumbers = rows.filter((row) => row !== null).map((row) => BigInt(row.updatedAtBlockNumber));
|
|
6373
|
+
if (blockNumbers.length === 0) return null;
|
|
6374
|
+
return blockNumbers.reduce((minimum, block) => block < minimum ? block : minimum).toString();
|
|
6375
|
+
}
|
|
6376
|
+
function buildStakingEntityIds(params) {
|
|
6377
|
+
if (!Number.isInteger(params.chainId) || params.chainId <= 0) {
|
|
6378
|
+
throw new ValidationError("chainId must be a positive integer", "chainId");
|
|
6379
|
+
}
|
|
6380
|
+
const vaultAddress = normalizeAddress4(params.vaultAddress, "vaultAddress");
|
|
6381
|
+
const chargebackPolicyAddress = normalizeAddress4(
|
|
6382
|
+
params.chargebackPolicyAddress,
|
|
6383
|
+
"chargebackPolicyAddress"
|
|
6384
|
+
);
|
|
6385
|
+
const taker = normalizeAddress4(params.taker, "taker");
|
|
6386
|
+
const stakeOwner = normalizeAddress4(params.stakeOwner, "stakeOwner");
|
|
6387
|
+
return {
|
|
6388
|
+
takerStateId: `${params.chainId}_${vaultAddress}_${taker}`,
|
|
6389
|
+
stakeAccountId: `${params.chainId}_${vaultAddress}_${stakeOwner}`,
|
|
6390
|
+
claimAccountId: `${params.chainId}_${vaultAddress}_${taker}`,
|
|
6391
|
+
vaultConfigId: `${params.chainId}_${vaultAddress}`,
|
|
6392
|
+
policy: chargebackPolicyAddress
|
|
6393
|
+
};
|
|
6394
|
+
}
|
|
6395
|
+
var IndexerStakingService = class {
|
|
6396
|
+
constructor(client) {
|
|
6397
|
+
this.client = client;
|
|
6398
|
+
}
|
|
6399
|
+
async fetchStakingState(params, init) {
|
|
6400
|
+
const ids = buildStakingEntityIds(params);
|
|
6401
|
+
const vaultAddress = normalizeAddress4(params.vaultAddress, "vaultAddress");
|
|
6402
|
+
const taker = normalizeAddress4(params.taker, "taker");
|
|
6403
|
+
const requestedStakeOwner = normalizeAddress4(params.stakeOwner, "stakeOwner");
|
|
6404
|
+
const data = await this.client.query(
|
|
6405
|
+
{
|
|
6406
|
+
query: STAKING_STATE_QUERY,
|
|
6407
|
+
variables: {
|
|
6408
|
+
...ids,
|
|
6409
|
+
chainId: params.chainId,
|
|
6410
|
+
vault: vaultAddress,
|
|
6411
|
+
taker
|
|
6412
|
+
}
|
|
6413
|
+
},
|
|
6414
|
+
init
|
|
6415
|
+
);
|
|
6416
|
+
const takerState = data.TakerStakeState_by_pk;
|
|
6417
|
+
const indexedStakeOwner = takerState ? normalizeAddress4(takerState.stakeOwner, "TakerStakeState.stakeOwner") : taker;
|
|
6418
|
+
const selectedStakeOwner = normalizeNullableAddress(
|
|
6419
|
+
takerState?.selectedStakeOwner,
|
|
6420
|
+
"TakerStakeState.selectedStakeOwner"
|
|
6421
|
+
);
|
|
6422
|
+
const stakeAccount = data.StakeAccountState_by_pk;
|
|
6423
|
+
const stakeAccountOwner = stakeAccount ? normalizeAddress4(stakeAccount.stakeOwner, "StakeAccountState.stakeOwner") : requestedStakeOwner;
|
|
6424
|
+
const stakeAccountMatchesEffectiveOwner = requestedStakeOwner === indexedStakeOwner && stakeAccountOwner === indexedStakeOwner;
|
|
6425
|
+
const claimAccount = data.ClaimAccountState_by_pk;
|
|
6426
|
+
if (claimAccount && normalizeAddress4(claimAccount.beneficiary, "ClaimAccountState.beneficiary") !== taker) {
|
|
6427
|
+
throw new Error("ClaimAccountState beneficiary does not match the requested taker");
|
|
6428
|
+
}
|
|
6429
|
+
const authorizations = data.TakerStakeAuthorization.map((authorization, index) => ({
|
|
6430
|
+
stakeOwner: normalizeAddress4(
|
|
6431
|
+
authorization.stakeOwner,
|
|
6432
|
+
`TakerStakeAuthorization[${index}].stakeOwner`
|
|
6433
|
+
),
|
|
6434
|
+
authorized: authorization.authorized,
|
|
6435
|
+
freshness: freshnessOf(
|
|
6436
|
+
authorization,
|
|
6437
|
+
`TakerStakeAuthorization[${index}]`
|
|
6438
|
+
)
|
|
6439
|
+
}));
|
|
6440
|
+
const riskWindows = data.ChargebackRiskWindow.map((row, index) => ({
|
|
6441
|
+
paymentMethod: row.paymentMethod,
|
|
6442
|
+
riskWindowSeconds: normalizeDecimal(
|
|
6443
|
+
row.riskWindow,
|
|
6444
|
+
`ChargebackRiskWindow[${index}].riskWindow`
|
|
6445
|
+
),
|
|
6446
|
+
updatedAt: normalizeDecimal(row.updatedAt, `ChargebackRiskWindow[${index}].updatedAt`)
|
|
6447
|
+
}));
|
|
6448
|
+
const takerFreshness = freshnessOf(takerState, "TakerStakeState");
|
|
6449
|
+
const stakeFreshness = freshnessOf(stakeAccount, "StakeAccountState");
|
|
6450
|
+
const claimFreshness = freshnessOf(claimAccount, "ClaimAccountState");
|
|
6451
|
+
const vaultFreshness = freshnessOf(data.StakeVaultConfig_by_pk, "StakeVaultConfig");
|
|
6452
|
+
const authorizationFreshness = authorizations.map((authorization) => authorization.freshness);
|
|
6453
|
+
return {
|
|
6454
|
+
chainId: params.chainId,
|
|
6455
|
+
environment: params.environment,
|
|
6456
|
+
taker,
|
|
6457
|
+
stakeOwner: indexedStakeOwner,
|
|
6458
|
+
selectedStakeOwner,
|
|
6459
|
+
selectionAuthorized: takerState?.selectionAuthorized ?? false,
|
|
6460
|
+
stake: stakeAccount && stakeAccountMatchesEffectiveOwner ? {
|
|
6461
|
+
totalUsdc: normalizeDecimal(stakeAccount.totalStake, "StakeAccountState.totalStake"),
|
|
6462
|
+
lockedUsdc: normalizeDecimal(
|
|
6463
|
+
stakeAccount.lockedStake,
|
|
6464
|
+
"StakeAccountState.lockedStake"
|
|
6465
|
+
),
|
|
6466
|
+
freeUsdc: normalizeDecimal(stakeAccount.freeStake, "StakeAccountState.freeStake")
|
|
6467
|
+
} : { ...ZERO_STAKE },
|
|
6468
|
+
claimableUsdc: claimAccount ? normalizeDecimal(claimAccount.claimableAmount, "ClaimAccountState.claimableAmount") : "0",
|
|
6469
|
+
authorizations,
|
|
6470
|
+
riskWindows,
|
|
6471
|
+
vault: data.StakeVaultConfig_by_pk ? {
|
|
6472
|
+
controller: normalizeNullableAddress(
|
|
6473
|
+
data.StakeVaultConfig_by_pk.controller,
|
|
6474
|
+
"StakeVaultConfig.controller"
|
|
6475
|
+
),
|
|
6476
|
+
pendingController: normalizeNullableAddress(
|
|
6477
|
+
data.StakeVaultConfig_by_pk.pendingController,
|
|
6478
|
+
"StakeVaultConfig.pendingController"
|
|
6479
|
+
),
|
|
6480
|
+
pendingControllerValidAt: data.StakeVaultConfig_by_pk.pendingControllerValidAt ? normalizeDecimal(
|
|
6481
|
+
data.StakeVaultConfig_by_pk.pendingControllerValidAt,
|
|
6482
|
+
"StakeVaultConfig.pendingControllerValidAt"
|
|
6483
|
+
) : null
|
|
6484
|
+
} : null,
|
|
6485
|
+
stakeAccountMatchesEffectiveOwner,
|
|
6486
|
+
freshness: {
|
|
6487
|
+
takerStakeState: takerFreshness,
|
|
6488
|
+
stakeAccountState: stakeFreshness,
|
|
6489
|
+
claimAccountState: claimFreshness,
|
|
6490
|
+
stakeVaultConfig: vaultFreshness,
|
|
6491
|
+
authorizations: authorizationFreshness,
|
|
6492
|
+
indexedBlockNumber: minimumBlockNumber([
|
|
6493
|
+
takerFreshness,
|
|
6494
|
+
stakeFreshness,
|
|
6495
|
+
claimFreshness,
|
|
6496
|
+
vaultFreshness,
|
|
6497
|
+
...authorizationFreshness
|
|
6498
|
+
])
|
|
6499
|
+
}
|
|
6500
|
+
};
|
|
6501
|
+
}
|
|
6502
|
+
};
|
|
6175
6503
|
|
|
6176
6504
|
// src/indexer/intentVerification.ts
|
|
6177
6505
|
async function fetchFulfillmentAndPayment(client, intentHash) {
|
|
@@ -6518,6 +6846,41 @@ var Zkp2pClient = class {
|
|
|
6518
6846
|
* @throws Error if walletClient is missing an account
|
|
6519
6847
|
*/
|
|
6520
6848
|
constructor(opts) {
|
|
6849
|
+
/** Deposit USDC stake owned by the transaction sender. */
|
|
6850
|
+
this.depositStake = this.buildStakeVaultMethod(
|
|
6851
|
+
"depositStake",
|
|
6852
|
+
(params) => [params.amount]
|
|
6853
|
+
);
|
|
6854
|
+
/** Withdraw the sender's free stake immediately; locked stake cannot move. */
|
|
6855
|
+
this.withdrawStake = this.buildStakeVaultMethod(
|
|
6856
|
+
"withdrawStake",
|
|
6857
|
+
(params) => [params.amount]
|
|
6858
|
+
);
|
|
6859
|
+
/** Withdraw the sender's complete claimable USDC balance. */
|
|
6860
|
+
this.claim = this.buildStakeVaultMethod("claim", () => []);
|
|
6861
|
+
/** Grant or revoke a taker's access to the sender's stake. */
|
|
6862
|
+
this.setTakerAuthorization = this.buildStakeVaultMethod("setTakerAuthorization", (params) => [params.taker, params.authorized]);
|
|
6863
|
+
/** Select the authorizing stake owner that backs the connected taker. */
|
|
6864
|
+
this.selectStakeOwner = this.buildStakeVaultMethod(
|
|
6865
|
+
"selectStakeOwner",
|
|
6866
|
+
(params) => [params.stakeOwner]
|
|
6867
|
+
);
|
|
6868
|
+
/** Clear the connected taker's selection and return to self-stake. */
|
|
6869
|
+
this.clearStakeOwner = this.buildStakeVaultMethod(
|
|
6870
|
+
"clearStakeOwner",
|
|
6871
|
+
() => []
|
|
6872
|
+
);
|
|
6873
|
+
/**
|
|
6874
|
+
* Release one chargeback intent whose risk window matured, unlocking its
|
|
6875
|
+
* stake cover. Permissionless once mature. Pass `chargebackPolicyAddress` to
|
|
6876
|
+
* pin the transaction to a snapshotted deployment.
|
|
6877
|
+
*/
|
|
6878
|
+
this.releaseMaturedChargebackIntent = this.buildChargebackPolicyMethod("releaseMaturedChargebackIntent", (params) => [params.intentHash]);
|
|
6879
|
+
/**
|
|
6880
|
+
* Release multiple matured chargeback intents in one transaction.
|
|
6881
|
+
* Pass `chargebackPolicyAddress` to pin the transaction to a snapshotted deployment.
|
|
6882
|
+
*/
|
|
6883
|
+
this.releaseMaturedChargebackIntents = this.buildChargebackPolicyMethod("releaseMaturedChargebackIntents", (params) => [params.intentHashes]);
|
|
6521
6884
|
// ╔═══════════════════════════════════════════════════════════════════════════╗
|
|
6522
6885
|
// ║ CORE: DEPOSIT MANAGEMENT ║
|
|
6523
6886
|
// ╚═══════════════════════════════════════════════════════════════════════════╝
|
|
@@ -7421,9 +7784,7 @@ var Zkp2pClient = class {
|
|
|
7421
7784
|
]);
|
|
7422
7785
|
this.orchestratorAddress = this.orchestratorV2Address ?? toAddress(addresses.orchestrator) ?? this.orchestratorAddresses[0];
|
|
7423
7786
|
this.orchestratorAbi = abis.orchestrator ?? this.orchestratorV2Abi;
|
|
7424
|
-
this.unifiedPaymentVerifier = toAddress(
|
|
7425
|
-
addresses.unifiedPaymentVerifierV2 ?? addresses.unifiedPaymentVerifier
|
|
7426
|
-
);
|
|
7787
|
+
this.unifiedPaymentVerifier = toAddress(addresses.unifiedPaymentVerifier);
|
|
7427
7788
|
this.protocolViewerAddress = toAddress(addresses.protocolViewer);
|
|
7428
7789
|
this.protocolViewerAbi = abis.protocolViewer;
|
|
7429
7790
|
const resolvedPvEntries = addresses.protocolViewerEntries;
|
|
@@ -7450,6 +7811,10 @@ var Zkp2pClient = class {
|
|
|
7450
7811
|
this.rateManagerControllerAbi = abis.rateManagerController;
|
|
7451
7812
|
this.intentGuardianAddress = toAddress(addresses.intentGuardian);
|
|
7452
7813
|
this.intentGuardianAbi = abis.intentGuardian;
|
|
7814
|
+
this.stakeVaultAddress = toAddress(addresses.stakeVault);
|
|
7815
|
+
this.stakeVaultAbi = abis.stakeVault;
|
|
7816
|
+
this.chargebackPolicyAddress = toAddress(addresses.chargebackPolicy);
|
|
7817
|
+
this.chargebackPolicyAbi = abis.chargebackPolicy;
|
|
7453
7818
|
if (!this.rateManagerRegistryAddress || !this.rateManagerRegistryAbi) {
|
|
7454
7819
|
try {
|
|
7455
7820
|
const rateManagerContracts = getRateManagerContracts(this.chainId, this.runtimeEnv);
|
|
@@ -7493,6 +7858,7 @@ var Zkp2pClient = class {
|
|
|
7493
7858
|
});
|
|
7494
7859
|
this._indexerService = new IndexerDepositService(this._indexerClient);
|
|
7495
7860
|
this._indexerRateManagerService = new IndexerRateManagerService(this._indexerClient);
|
|
7861
|
+
this._indexerStakingService = new IndexerStakingService(this._indexerClient);
|
|
7496
7862
|
this.baseApiUrl = opts.baseApiUrl;
|
|
7497
7863
|
this.apiKey = opts.apiKey;
|
|
7498
7864
|
this.apiHeaders = opts.apiHeaders;
|
|
@@ -7533,6 +7899,14 @@ var Zkp2pClient = class {
|
|
|
7533
7899
|
prepareContractTransaction: (tx) => this.prepareContractTransaction(tx)
|
|
7534
7900
|
}
|
|
7535
7901
|
});
|
|
7902
|
+
this._stakeOps = new StakeOperations({
|
|
7903
|
+
getPublicClient: () => this.publicClient,
|
|
7904
|
+
getStakeVaultAddress: () => this.stakeVaultAddress,
|
|
7905
|
+
getStakeVaultAbi: () => this.stakeVaultAbi,
|
|
7906
|
+
getStakeTokenAddress: () => this._usdcAddress,
|
|
7907
|
+
getChargebackPolicyAddress: () => this.chargebackPolicyAddress,
|
|
7908
|
+
getChargebackPolicyAbi: () => this.chargebackPolicyAbi
|
|
7909
|
+
});
|
|
7536
7910
|
this._intentGuardianOps = new IntentGuardianOperations({
|
|
7537
7911
|
getPublicClient: () => this.publicClient,
|
|
7538
7912
|
getGuardianAddress: () => this.intentGuardianAddress,
|
|
@@ -7947,7 +8321,7 @@ var Zkp2pClient = class {
|
|
|
7947
8321
|
buildContractMethod(resolveContract, functionName, buildArgs, buildValue) {
|
|
7948
8322
|
return Object.assign(
|
|
7949
8323
|
async (params) => {
|
|
7950
|
-
const contract = resolveContract();
|
|
8324
|
+
const contract = resolveContract(params);
|
|
7951
8325
|
if (!contract.address || !contract.abi) {
|
|
7952
8326
|
throw new Error(`${contract.label} not available`);
|
|
7953
8327
|
}
|
|
@@ -7963,7 +8337,7 @@ var Zkp2pClient = class {
|
|
|
7963
8337
|
},
|
|
7964
8338
|
{
|
|
7965
8339
|
prepare: async (params) => {
|
|
7966
|
-
const contract = resolveContract();
|
|
8340
|
+
const contract = resolveContract(params);
|
|
7967
8341
|
if (!contract.address || !contract.abi) {
|
|
7968
8342
|
throw new Error(`${contract.label} not available`);
|
|
7969
8343
|
}
|
|
@@ -7985,6 +8359,28 @@ var Zkp2pClient = class {
|
|
|
7985
8359
|
}
|
|
7986
8360
|
);
|
|
7987
8361
|
}
|
|
8362
|
+
buildStakeVaultMethod(functionName, buildArgs) {
|
|
8363
|
+
return this.buildContractMethod(
|
|
8364
|
+
() => ({
|
|
8365
|
+
address: this.stakeVaultAddress,
|
|
8366
|
+
abi: this.stakeVaultAbi,
|
|
8367
|
+
label: "StakeVault"
|
|
8368
|
+
}),
|
|
8369
|
+
functionName,
|
|
8370
|
+
buildArgs
|
|
8371
|
+
);
|
|
8372
|
+
}
|
|
8373
|
+
buildChargebackPolicyMethod(functionName, buildArgs) {
|
|
8374
|
+
return this.buildContractMethod(
|
|
8375
|
+
(params) => ({
|
|
8376
|
+
address: params.chargebackPolicyAddress ?? this.chargebackPolicyAddress,
|
|
8377
|
+
abi: this.chargebackPolicyAbi,
|
|
8378
|
+
label: "ChargebackPolicy"
|
|
8379
|
+
}),
|
|
8380
|
+
functionName,
|
|
8381
|
+
buildArgs
|
|
8382
|
+
);
|
|
8383
|
+
}
|
|
7988
8384
|
buildIntentGuardianMethod(functionName, buildArgs) {
|
|
7989
8385
|
return this.buildContractMethod(
|
|
7990
8386
|
() => ({
|
|
@@ -8235,6 +8631,7 @@ var Zkp2pClient = class {
|
|
|
8235
8631
|
get indexer() {
|
|
8236
8632
|
const service = this._indexerService;
|
|
8237
8633
|
const rateManagerService = this._indexerRateManagerService;
|
|
8634
|
+
const stakingService = this._indexerStakingService;
|
|
8238
8635
|
const client = this._indexerClient;
|
|
8239
8636
|
return {
|
|
8240
8637
|
/** Raw GraphQL client for custom queries */
|
|
@@ -8371,6 +8768,16 @@ var Zkp2pClient = class {
|
|
|
8371
8768
|
getOracleConfigUpdates: (rateManagerId, options) => {
|
|
8372
8769
|
return rateManagerService.fetchOracleConfigUpdates(rateManagerId, options);
|
|
8373
8770
|
},
|
|
8771
|
+
/**
|
|
8772
|
+
* Composes the hard-cut 0.14.0-rc.0 staking current-state rows. Pass the
|
|
8773
|
+
* caller's fresh stakeOwnerOf(taker) result so the account rows can be
|
|
8774
|
+
* fetched together and checked against indexed ownership.
|
|
8775
|
+
*/
|
|
8776
|
+
getStakingState: (params, options) => {
|
|
8777
|
+
return stakingService.fetchStakingState(params, {
|
|
8778
|
+
signal: options?.signal
|
|
8779
|
+
});
|
|
8780
|
+
},
|
|
8374
8781
|
/**
|
|
8375
8782
|
* Fetches chronological fund activities for a specific deposit.
|
|
8376
8783
|
*/
|
|
@@ -8453,6 +8860,91 @@ var Zkp2pClient = class {
|
|
|
8453
8860
|
});
|
|
8454
8861
|
return { hadAllowance: false, hash };
|
|
8455
8862
|
}
|
|
8863
|
+
// ╔═══════════════════════════════════════════════════════════════════════════╗
|
|
8864
|
+
// ║ CORE: TAKER STAKING ║
|
|
8865
|
+
// ╚═══════════════════════════════════════════════════════════════════════════╝
|
|
8866
|
+
/**
|
|
8867
|
+
* Return the resolved StakeVault coordinates for advanced wallet, relayer,
|
|
8868
|
+
* or reactive read integrations.
|
|
8869
|
+
*/
|
|
8870
|
+
getStakeVaultContract() {
|
|
8871
|
+
return this._stakeOps.getContract();
|
|
8872
|
+
}
|
|
8873
|
+
/** Return the resolved OrchestratorV3 coordinates for advanced integrations. */
|
|
8874
|
+
getOrchestratorV3Contract() {
|
|
8875
|
+
if (!this.orchestratorV3Address || !this.orchestratorV3Abi) {
|
|
8876
|
+
throw new Error("OrchestratorV3 not available for this chain/environment");
|
|
8877
|
+
}
|
|
8878
|
+
return { address: this.orchestratorV3Address, abi: this.orchestratorV3Abi };
|
|
8879
|
+
}
|
|
8880
|
+
/** Return the resolved ChargebackPolicy coordinates for keeper integrations. */
|
|
8881
|
+
getChargebackPolicyContract() {
|
|
8882
|
+
if (!this.chargebackPolicyAddress || !this.chargebackPolicyAbi) {
|
|
8883
|
+
throw new Error("ChargebackPolicy not available for this chain/environment");
|
|
8884
|
+
}
|
|
8885
|
+
return { address: this.chargebackPolicyAddress, abi: this.chargebackPolicyAbi };
|
|
8886
|
+
}
|
|
8887
|
+
/**
|
|
8888
|
+
* Ensure the connected wallet has approved enough USDC for StakeVault.
|
|
8889
|
+
* If an approval is submitted, wait for it to confirm before depositing.
|
|
8890
|
+
*/
|
|
8891
|
+
async ensureStakeAllowance(params) {
|
|
8892
|
+
const { address, stakeToken } = this._stakeOps.getContract();
|
|
8893
|
+
return this.ensureAllowance({
|
|
8894
|
+
token: stakeToken,
|
|
8895
|
+
spender: address,
|
|
8896
|
+
amount: params.amount,
|
|
8897
|
+
maxApprove: params.maxApprove,
|
|
8898
|
+
txOverrides: params.txOverrides
|
|
8899
|
+
});
|
|
8900
|
+
}
|
|
8901
|
+
/** Read total stake owned by an address directly from StakeVault. */
|
|
8902
|
+
getStakeBalance(stakeOwner) {
|
|
8903
|
+
return this._stakeOps.getStakeBalance(stakeOwner);
|
|
8904
|
+
}
|
|
8905
|
+
/** Read stake committed to active StakeVault locks. */
|
|
8906
|
+
getLockedStake(stakeOwner) {
|
|
8907
|
+
return this._stakeOps.getLockedStake(stakeOwner);
|
|
8908
|
+
}
|
|
8909
|
+
/** Read stake available for immediate withdrawal or a new lock. */
|
|
8910
|
+
getFreeStake(stakeOwner) {
|
|
8911
|
+
return this._stakeOps.getFreeStake(stakeOwner);
|
|
8912
|
+
}
|
|
8913
|
+
/** Read the non-stake USDC withdrawable by a beneficiary with `claim()`. */
|
|
8914
|
+
getClaimable(beneficiary) {
|
|
8915
|
+
return this._stakeOps.getClaimable(beneficiary);
|
|
8916
|
+
}
|
|
8917
|
+
/** Resolve the effective stake owner backing a taker. */
|
|
8918
|
+
getStakeOwner(taker) {
|
|
8919
|
+
return this._stakeOps.getStakeOwner(taker);
|
|
8920
|
+
}
|
|
8921
|
+
/** Read a taker's raw selection, which is stale once authorization is revoked. */
|
|
8922
|
+
getSelectedStakeOwner(taker) {
|
|
8923
|
+
return this._stakeOps.getSelectedStakeOwner(taker);
|
|
8924
|
+
}
|
|
8925
|
+
/** Read whether a stake owner currently authorizes a taker. */
|
|
8926
|
+
getTakerAuthorization(stakeOwner, taker) {
|
|
8927
|
+
return this._stakeOps.getTakerAuthorization(stakeOwner, taker);
|
|
8928
|
+
}
|
|
8929
|
+
/** Read the complete authoritative StakeVault state needed by a staking UI. */
|
|
8930
|
+
getStakeVaultState(params) {
|
|
8931
|
+
return this._stakeOps.getStakeVaultState(params);
|
|
8932
|
+
}
|
|
8933
|
+
/** Read whether the ChargebackPolicy is refusing new chargebackable admissions. */
|
|
8934
|
+
getAdmissionsPaused() {
|
|
8935
|
+
return this._stakeOps.getAdmissionsPaused();
|
|
8936
|
+
}
|
|
8937
|
+
/**
|
|
8938
|
+
* Read a payment method's minimum collateral lock window in seconds. Zero
|
|
8939
|
+
* means the method admits unbonded — no stake is locked at admission.
|
|
8940
|
+
*/
|
|
8941
|
+
getRiskWindow(paymentMethodHash) {
|
|
8942
|
+
return this._stakeOps.getRiskWindow(paymentMethodHash);
|
|
8943
|
+
}
|
|
8944
|
+
/** Read whether an escrow deposit has opted into chargeback coverage. */
|
|
8945
|
+
isChargebackEnabled(escrow, depositId) {
|
|
8946
|
+
return this._stakeOps.isChargebackEnabled(escrow, depositId);
|
|
8947
|
+
}
|
|
8456
8948
|
/**
|
|
8457
8949
|
* Registers payee details with the curator API and returns hashed on-chain IDs.
|
|
8458
8950
|
*
|
|
@@ -9249,6 +9741,8 @@ var Zkp2pClient = class {
|
|
|
9249
9741
|
unifiedPaymentVerifier: this.unifiedPaymentVerifier,
|
|
9250
9742
|
rateManagerV1: this.rateManagerV1Address,
|
|
9251
9743
|
orchestratorRegistry: this.orchestratorRegistryAddress,
|
|
9744
|
+
stakeVault: this.stakeVaultAddress,
|
|
9745
|
+
chargebackPolicy: this.chargebackPolicyAddress,
|
|
9252
9746
|
usdc: this._usdcAddress
|
|
9253
9747
|
};
|
|
9254
9748
|
}
|
|
@@ -9311,18 +9805,46 @@ var getPeerExtensionState = async (options) => {
|
|
|
9311
9805
|
return "needs_connection";
|
|
9312
9806
|
}
|
|
9313
9807
|
};
|
|
9808
|
+
var sanitizePeerAuthenticateParams = (params) => {
|
|
9809
|
+
const sanitizedParams = { ...params };
|
|
9810
|
+
delete sanitizedParams.providerConfig;
|
|
9811
|
+
return sanitizedParams;
|
|
9812
|
+
};
|
|
9314
9813
|
var createPeerExtensionSdk = (options = {}) => ({
|
|
9315
9814
|
isAvailable: () => isPeerExtensionAvailable(options),
|
|
9316
9815
|
requestConnection: () => requirePeer(options).requestConnection(),
|
|
9317
9816
|
checkConnectionStatus: () => requirePeer(options).checkConnectionStatus(),
|
|
9318
9817
|
getVersion: () => requirePeer(options).getVersion(),
|
|
9319
|
-
authenticate: (params) => requirePeer(options).authenticate(params),
|
|
9818
|
+
authenticate: (params) => requirePeer(options).authenticate(sanitizePeerAuthenticateParams(params)),
|
|
9320
9819
|
onMetadataMessage: (callback) => requirePeer(options).onMetadataMessage(callback),
|
|
9321
9820
|
openInstallPage: () => openPeerExtensionInstallPage(options),
|
|
9322
9821
|
getState: () => getPeerExtensionState(options)
|
|
9323
9822
|
});
|
|
9324
9823
|
var peerExtensionSdk = createPeerExtensionSdk();
|
|
9325
9824
|
|
|
9825
|
+
// src/riskMath.ts
|
|
9826
|
+
var RISK_BPS_DENOMINATOR = 10000n;
|
|
9827
|
+
function integer(value, label) {
|
|
9828
|
+
if (typeof value === "number" && (!Number.isSafeInteger(value) || value < 0)) {
|
|
9829
|
+
throw new RangeError(`${label} must be a non-negative safe integer`);
|
|
9830
|
+
}
|
|
9831
|
+
const parsed = BigInt(value.toString());
|
|
9832
|
+
if (parsed < 0n) throw new RangeError(`${label} must be non-negative`);
|
|
9833
|
+
return parsed;
|
|
9834
|
+
}
|
|
9835
|
+
function calculateRequiredCoverage(amount, chargebackable) {
|
|
9836
|
+
return chargebackable ? integer(amount, "amount") : 0n;
|
|
9837
|
+
}
|
|
9838
|
+
function calculateStakeBackedCapacity(freeStake) {
|
|
9839
|
+
return integer(freeStake, "freeStake");
|
|
9840
|
+
}
|
|
9841
|
+
function selectRiskMode(amount, freeStake, chargebackable) {
|
|
9842
|
+
const required = calculateRequiredCoverage(amount, chargebackable);
|
|
9843
|
+
if (!chargebackable) return "UNBONDED";
|
|
9844
|
+
if (integer(freeStake, "freeStake") >= required) return "STAKE_BACKED";
|
|
9845
|
+
throw new RangeError("insufficient free stake for chargebackable admission");
|
|
9846
|
+
}
|
|
9847
|
+
|
|
9326
9848
|
// src/client/accessPolicyPlan.ts
|
|
9327
9849
|
var MAX_GROUPS_PER_DEPOSIT = 10;
|
|
9328
9850
|
var MAX_ADDRESSES_PER_CALL = 50;
|
|
@@ -9479,6 +10001,6 @@ var planAccessPolicyUpdate = (persistedInput, draftInput) => {
|
|
|
9479
10001
|
};
|
|
9480
10002
|
};
|
|
9481
10003
|
|
|
9482
|
-
export { AccessPolicyOperations, AccessPolicyUnsupportedError, BASE_BUILDER_CODE, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractRouter, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, IndexerClient, IndexerDepositService, IndexerRateManagerService, MAX_ADDRESSES_PER_CALL, MAX_GROUPS_PER_DEPOSIT, MAX_WHITELISTED_ADDRESSES, Zkp2pClient as OfframpClient, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, REFERRAL_SIGNATURE_DOMAIN, REFERRAL_SIGNATURE_TYPES, SPREAD_ORACLE_FEEDS, SUPPORTED_CHAIN_IDS, TOKEN_METADATA, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, Zkp2pClient, apiCreateReferralCode, apiCreateSellerCredentialBundle, apiGetDepositBundle, apiGetOrderbook, apiGetOrderbookTable, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetQuote, apiGetQuotesBestByPlatform, apiGetReferralDashboard, apiGetReferralEarnings, apiLookupReferralCode, apiPostDepositDetails, apiRedeemReferralCode, apiRequestIdentityAttestation, apiSignIntentV3, apiSignIntentV3Raw, apiUpdateReferralCode, apiUploadGoogleOAuthSellerCredential, apiUploadSellerCredentialBundle, apiValidatePayeeDetails, apiVerifyBuyerTeePayment, appendAttributionToCalldata, assertValidReferrerFeeConfig, compareEventCursorIdsByRecency, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createEncryptedBuyerTeeSessionMaterial, createPeerExtensionSdk, defaultIndexerEndpoint, diffAccessPolicy, encodePythAdapterConfig, encodeSpreadOracleAdapterConfig, encodeWithAttribution, fetchFulfillmentAndPayment as fetchIndexerFulfillmentAndPayment, getAttributionDataSuffix, getPeerExtensionState, getSpreadOracleConfig, isPeerExtensionAvailable, isValidReferralCode, isValidReferrerFeeBps, isValidReferrerFeeRecipient, logger, normalizeAccessPolicyState, normalizeReferralCode, openPeerExtensionInstallPage, parseReferrerFeeConfig, peerExtensionSdk, planAccessPolicyUpdate, referrerFeeConfigToPreciseUnits, sendTransactionWithAttribution, setLogLevel, validateOracleFeedsOnChain };
|
|
10004
|
+
export { AccessPolicyOperations, AccessPolicyUnsupportedError, BASE_BUILDER_CODE, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractRouter, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, IndexerClient, IndexerDepositService, IndexerRateManagerService, IndexerStakingService, MAX_ADDRESSES_PER_CALL, MAX_GROUPS_PER_DEPOSIT, MAX_WHITELISTED_ADDRESSES, Zkp2pClient as OfframpClient, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, REFERRAL_SIGNATURE_DOMAIN, REFERRAL_SIGNATURE_TYPES, RISK_BPS_DENOMINATOR, SPREAD_ORACLE_FEEDS, SUPPORTED_CHAIN_IDS, TOKEN_METADATA, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, Zkp2pClient, apiCreateReferralCode, apiCreateSellerCredentialBundle, apiGetDepositBundle, apiGetOrderbook, apiGetOrderbookTable, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetQuote, apiGetQuotesBestByPlatform, apiGetReferralDashboard, apiGetReferralEarnings, apiLookupReferralCode, apiPostDepositDetails, apiRedeemReferralCode, apiRequestIdentityAttestation, apiSignIntentV3, apiSignIntentV3Raw, apiUpdateReferralCode, apiUploadGoogleOAuthSellerCredential, apiUploadSellerCredentialBundle, apiValidatePayeeDetails, apiVerifyBuyerTeePayment, appendAttributionToCalldata, assertValidReferrerFeeConfig, buildStakingEntityIds, calculateRequiredCoverage, calculateStakeBackedCapacity, compareEventCursorIdsByRecency, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createEncryptedBuyerTeeSessionMaterial, createPeerExtensionSdk, defaultIndexerEndpoint, diffAccessPolicy, encodePythAdapterConfig, encodeSpreadOracleAdapterConfig, encodeWithAttribution, fetchFulfillmentAndPayment as fetchIndexerFulfillmentAndPayment, getAttributionDataSuffix, getPeerExtensionState, getSpreadOracleConfig, isPeerExtensionAvailable, isValidReferralCode, isValidReferrerFeeBps, isValidReferrerFeeRecipient, logger, normalizeAccessPolicyState, normalizeReferralCode, openPeerExtensionInstallPage, parseReferrerFeeConfig, peerExtensionSdk, planAccessPolicyUpdate, referrerFeeConfigToPreciseUnits, selectRiskMode, sendTransactionWithAttribution, setLogLevel, validateOracleFeedsOnChain };
|
|
9483
10005
|
//# sourceMappingURL=index.mjs.map
|
|
9484
10006
|
//# sourceMappingURL=index.mjs.map
|