@zkp2p/sdk 0.10.0-rc.6 → 0.10.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 +63 -110
- package/dist/{chunk-3XY3E4VH.mjs → chunk-JRLUSPR3.mjs} +5062 -36836
- package/dist/chunk-JRLUSPR3.mjs.map +1 -0
- package/dist/chunk-WXEP544Y.mjs +281 -0
- package/dist/chunk-WXEP544Y.mjs.map +1 -0
- package/dist/index.cjs +7517 -38935
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +61 -47
- package/dist/index.d.ts +61 -47
- package/dist/index.mjs +453 -329
- package/dist/index.mjs.map +1 -1
- package/dist/protocolViewerParsers-QMHI74AA.mjs +5 -0
- package/dist/{protocolViewerParsers-HMOHJWSP.mjs.map → protocolViewerParsers-QMHI74AA.mjs.map} +1 -1
- package/dist/react.cjs +237 -97
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.mts +46 -33
- package/dist/react.d.ts +46 -33
- package/dist/react.mjs +191 -99
- package/dist/react.mjs.map +1 -1
- package/dist/{vaultUtils-B2FVQeaS.d.mts → vaultUtils-DeUFIx3l.d.mts} +479 -308
- package/dist/{vaultUtils-B2FVQeaS.d.ts → vaultUtils-DeUFIx3l.d.ts} +479 -308
- package/package.json +3 -3
- package/dist/chunk-3XY3E4VH.mjs.map +0 -1
- package/dist/chunk-LPJE2MN7.mjs +0 -75
- package/dist/chunk-LPJE2MN7.mjs.map +0 -1
- package/dist/protocolViewerParsers-HMOHJWSP.mjs +0 -5
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { IntentGuardianOperations } from './chunk-WXEP544Y.mjs';
|
|
2
|
+
export { TAKER_TIER_CAPS, TAKER_TIER_FEE_DISCOUNT_BPS, TAKER_TIER_ORDER, TAKER_TIER_SCHEDULE, ZERO_RATE_MANAGER_ID, classifyDelegationState, classifyIntentGuardianError, getDelegationRoute, getNextTakerTier, getTakerTierFeeDiscountBps, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry } from './chunk-WXEP544Y.mjs';
|
|
2
3
|
import { ValidationError, APIError, NetworkError } from './chunk-GHQK65J2.mjs';
|
|
3
4
|
export { APIError, ContractError, ErrorCode, NetworkError, ValidationError, ZKP2PError } from './chunk-GHQK65J2.mjs';
|
|
4
|
-
import { METHOD_NAME_TO_HASH, matchesQuotePaymentMethod, matchesPaymentMethodNameAndHash, getContracts, getRateManagerContracts, getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog, getGatingServiceAddress, parseBigIntLike, SUPPORTED_PAYMENT_METHOD_HASHES, resolveFiatCurrencyBytes32, resolvePaymentMethodNameFromHash } from './chunk-
|
|
5
|
-
export {
|
|
5
|
+
import { METHOD_NAME_TO_HASH, matchesQuotePaymentMethod, matchesPaymentMethodNameAndHash, getContracts, getRateManagerContracts, getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog, getGatingServiceAddress, parseBigIntLike, SUPPORTED_PAYMENT_METHOD_HASHES, resolveFiatCurrencyBytes32, resolvePaymentMethodNameFromHash } from './chunk-JRLUSPR3.mjs';
|
|
6
|
+
export { PAYMENT_PLATFORMS, asciiToBytes32, enrichPvDepositView, enrichPvIntentView, ensureBytes32, getContracts, getGatingServiceAddress, getIntentGuardianContract, getPaymentMethodsCatalog, getRateManagerContracts, hasIntentGuardian, parseDepositView, parseIntentView, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash } from './chunk-JRLUSPR3.mjs';
|
|
6
7
|
import { Currency, currencyKeccak256 } from './chunk-ZFBH4HD7.mjs';
|
|
7
8
|
export { Currency, currencyInfo, getCurrencyCodeFromHash, getCurrencyInfoFromCountryCode, getCurrencyInfoFromHash, isSupportedCurrencyHash, mapConversionRatesToOnchainMinRate } from './chunk-ZFBH4HD7.mjs';
|
|
8
9
|
import './chunk-J5LGTIGS.mjs';
|
|
9
|
-
import { concatHex, encodeFunctionData, encodeAbiParameters, createPublicClient, http,
|
|
10
|
+
import { concatHex, encodeFunctionData, encodeAbiParameters, createPublicClient, http, formatUnits } from 'viem';
|
|
10
11
|
import { hardhat, base } from 'viem/chains';
|
|
11
12
|
import { createEncryptedBuyerTeeSessionMaterial as createEncryptedBuyerTeeSessionMaterial$1, createEncryptedSellerCredentialUpload } from '@zkp2p/zkp2p-attestation';
|
|
12
13
|
export { createNitroAttestationClient } from '@zkp2p/zkp2p-attestation';
|
|
@@ -153,8 +154,6 @@ var ContractRouter = class {
|
|
|
153
154
|
this.orchestratorAbi = config.orchestratorAbi;
|
|
154
155
|
this.orchestratorV2Address = config.orchestratorV2Address;
|
|
155
156
|
this.orchestratorV2Abi = config.orchestratorV2Abi;
|
|
156
|
-
this.orchestratorV3Address = config.orchestratorV3Address;
|
|
157
|
-
this.orchestratorV3Abi = config.orchestratorV3Abi;
|
|
158
157
|
this.orchestratorAddresses = config.orchestratorAddresses;
|
|
159
158
|
this._registerContexts();
|
|
160
159
|
}
|
|
@@ -185,26 +184,24 @@ var ContractRouter = class {
|
|
|
185
184
|
for (let index = 0; index < configuredPairCount; index += 1) {
|
|
186
185
|
addEscrowOrchestratorPair(this.escrowAddresses[index], this.orchestratorAddresses[index]);
|
|
187
186
|
}
|
|
188
|
-
const resolveOrchestratorAbi = (address) => this.getOrchestratorContextByAddress(address)?.abi ?? (isSameAddress(address, this.
|
|
187
|
+
const resolveOrchestratorAbi = (address) => this.getOrchestratorContextByAddress(address)?.abi ?? (isSameAddress(address, this.orchestratorV2Address) ? this.orchestratorV2Abi ?? this.orchestratorAbi : this.orchestratorAbi ?? this.orchestratorV2Abi);
|
|
189
188
|
const uniqueOrchestratorAddresses = /* @__PURE__ */ new Set();
|
|
190
189
|
for (const address of [
|
|
191
190
|
primaryOrchestratorAddress,
|
|
192
191
|
this.orchestratorAddress,
|
|
193
192
|
this.orchestratorV2Address,
|
|
194
|
-
this.orchestratorV3Address,
|
|
195
193
|
...this.orchestratorAddresses
|
|
196
194
|
]) {
|
|
197
195
|
if (!address) continue;
|
|
198
196
|
const key = address.toLowerCase();
|
|
199
197
|
if (uniqueOrchestratorAddresses.has(key)) continue;
|
|
200
198
|
uniqueOrchestratorAddresses.add(key);
|
|
201
|
-
const
|
|
202
|
-
const abi = isV3 ? this.orchestratorV3Abi : isSameAddress(address, this.orchestratorV2Address) ? this.orchestratorV2Abi ?? this.orchestratorAbi : this.orchestratorAbi ?? this.orchestratorV2Abi;
|
|
199
|
+
const abi = isSameAddress(address, this.orchestratorV2Address) ? this.orchestratorV2Abi ?? this.orchestratorAbi : this.orchestratorAbi ?? this.orchestratorV2Abi;
|
|
203
200
|
if (!abi) continue;
|
|
204
201
|
registerOrchestrator({
|
|
205
202
|
address,
|
|
206
203
|
abi,
|
|
207
|
-
version:
|
|
204
|
+
version: "v2"
|
|
208
205
|
});
|
|
209
206
|
}
|
|
210
207
|
const uniqueEscrowAddresses = /* @__PURE__ */ new Set();
|
|
@@ -820,7 +817,7 @@ async function sendTransactionWithAttribution(walletClient, request, referrer, o
|
|
|
820
817
|
// src/utils/constants.ts
|
|
821
818
|
var DEFAULT_BASE_API_URL = "https://api.zkp2p.xyz";
|
|
822
819
|
|
|
823
|
-
// ../../node_modules/.pnpm/@zkp2p+contracts-v2@0.
|
|
820
|
+
// ../../node_modules/.pnpm/@zkp2p+contracts-v2@0.4.0-rc.0_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
|
|
824
821
|
var chainlink_default = {
|
|
825
822
|
feeds: [
|
|
826
823
|
{
|
|
@@ -1224,12 +1221,7 @@ var IntentOperations = class {
|
|
|
1224
1221
|
});
|
|
1225
1222
|
const currentEscrow = this.config.getEscrowV2Address();
|
|
1226
1223
|
const currentOrchestrator = this.config.getOrchestratorV2Address();
|
|
1227
|
-
|
|
1228
|
-
const hasPinnedV3Target = isOrchestratorV3 && params.orchestratorAddress !== void 0;
|
|
1229
|
-
if (!hasPinnedV3Target && currentEscrow && escrowContext.address.toLowerCase() !== currentEscrow.toLowerCase()) {
|
|
1230
|
-
throw new Error("signalIntent is only supported on the current EscrowV2 deployment");
|
|
1231
|
-
}
|
|
1232
|
-
if (!isOrchestratorV3 && currentOrchestrator && orchestratorContext.address.toLowerCase() !== currentOrchestrator.toLowerCase()) {
|
|
1224
|
+
if (currentEscrow && escrowContext.address.toLowerCase() !== currentEscrow.toLowerCase() || currentOrchestrator && orchestratorContext.address.toLowerCase() !== currentOrchestrator.toLowerCase()) {
|
|
1233
1225
|
throw new Error(
|
|
1234
1226
|
"signalIntent is only supported on the current EscrowV2 / OrchestratorV2 deployment"
|
|
1235
1227
|
);
|
|
@@ -1249,7 +1241,7 @@ var IntentOperations = class {
|
|
|
1249
1241
|
let { gatingServiceSignature, signatureExpiration } = params;
|
|
1250
1242
|
let preIntentHookData = params.preIntentHookData;
|
|
1251
1243
|
const baseApiUrl = this.config.getBaseApiUrl();
|
|
1252
|
-
if (
|
|
1244
|
+
if ((!gatingServiceSignature || !signatureExpiration) && baseApiUrl) {
|
|
1253
1245
|
const apiOpts = {
|
|
1254
1246
|
baseApiUrl,
|
|
1255
1247
|
apiKey: this.config.getApiKey(),
|
|
@@ -1297,10 +1289,7 @@ var IntentOperations = class {
|
|
|
1297
1289
|
});
|
|
1298
1290
|
}
|
|
1299
1291
|
}
|
|
1300
|
-
if (
|
|
1301
|
-
gatingServiceSignature = "0x";
|
|
1302
|
-
signatureExpiration = 0n;
|
|
1303
|
-
} else if (!gatingServiceSignature || !signatureExpiration) {
|
|
1292
|
+
if (!gatingServiceSignature || !signatureExpiration) {
|
|
1304
1293
|
throw new Error("Missing gatingServiceSignature/signatureExpiration");
|
|
1305
1294
|
}
|
|
1306
1295
|
const args = [
|
|
@@ -1980,7 +1969,7 @@ var ProtocolViewerReader = class {
|
|
|
1980
1969
|
if (inputCount === null) {
|
|
1981
1970
|
throw new Error("Configured ProtocolViewer ABI does not expose getDeposit");
|
|
1982
1971
|
}
|
|
1983
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
1972
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-QMHI74AA.mjs');
|
|
1984
1973
|
if (inputCount >= 3) {
|
|
1985
1974
|
return tryContexts(
|
|
1986
1975
|
protocolViewerContexts,
|
|
@@ -2059,7 +2048,7 @@ var ProtocolViewerReader = class {
|
|
|
2059
2048
|
return Promise.all(ids.map((id) => this.config.host.getPvDepositById(id)));
|
|
2060
2049
|
}
|
|
2061
2050
|
const bn = ids.map((id) => typeof id === "bigint" ? id : parseRawDepositId(id));
|
|
2062
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
2051
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-QMHI74AA.mjs');
|
|
2063
2052
|
if (inputCount >= 2) {
|
|
2064
2053
|
const requests = ids.map((id, index) => ({
|
|
2065
2054
|
index,
|
|
@@ -2164,7 +2153,7 @@ var ProtocolViewerReader = class {
|
|
|
2164
2153
|
if (!protocolViewerAddress || !protocolViewerAbi || inputCount === null) {
|
|
2165
2154
|
return this.config.host.getPvAccountDepositsFromIndexer(owner);
|
|
2166
2155
|
}
|
|
2167
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
2156
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-QMHI74AA.mjs');
|
|
2168
2157
|
const { address, abi } = this.config.host.requireProtocolViewer();
|
|
2169
2158
|
if (inputCount >= 2) {
|
|
2170
2159
|
const readAndFilter = async (raw2) => {
|
|
@@ -2235,7 +2224,7 @@ var ProtocolViewerReader = class {
|
|
|
2235
2224
|
if (protocolViewerEntries.length === 0) {
|
|
2236
2225
|
throw new Error("ProtocolViewer not available for this network");
|
|
2237
2226
|
}
|
|
2238
|
-
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-
|
|
2227
|
+
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-QMHI74AA.mjs');
|
|
2239
2228
|
const intentsByHash = /* @__PURE__ */ new Map();
|
|
2240
2229
|
let attemptedRead = false;
|
|
2241
2230
|
let hadSuccessfulRead = false;
|
|
@@ -2343,7 +2332,7 @@ var ProtocolViewerReader = class {
|
|
|
2343
2332
|
if (protocolViewerEntries.length === 0) {
|
|
2344
2333
|
throw new Error("ProtocolViewer not available for this network");
|
|
2345
2334
|
}
|
|
2346
|
-
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-
|
|
2335
|
+
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-QMHI74AA.mjs');
|
|
2347
2336
|
let lastError;
|
|
2348
2337
|
for (const pvEntry of protocolViewerEntries) {
|
|
2349
2338
|
const inputCount = this.pvEntryFunctionInputCount(pvEntry, "getIntent");
|
|
@@ -4537,32 +4526,13 @@ async function apiGetOwnerDeposits(req, apiKey, baseApiUrl, authToken, timeoutMs
|
|
|
4537
4526
|
statusCode: 200
|
|
4538
4527
|
};
|
|
4539
4528
|
}
|
|
4540
|
-
async function
|
|
4541
|
-
if (!isValidHexAddress(req.owner)) {
|
|
4542
|
-
throw new ValidationError("owner must be a valid Ethereum address", "owner");
|
|
4543
|
-
}
|
|
4529
|
+
async function apiGetTakerTier(req, baseApiUrl, timeoutMs) {
|
|
4544
4530
|
const normalizedOwner = req.owner.toLowerCase();
|
|
4545
4531
|
const query = new URLSearchParams({
|
|
4546
4532
|
owner: normalizedOwner,
|
|
4547
4533
|
chainId: String(req.chainId)
|
|
4548
4534
|
});
|
|
4549
|
-
const endpoint = `/v2/taker/
|
|
4550
|
-
return apiFetch({
|
|
4551
|
-
url: `${withApiBase(baseApiUrl)}${endpoint}`,
|
|
4552
|
-
method: "GET",
|
|
4553
|
-
timeoutMs
|
|
4554
|
-
});
|
|
4555
|
-
}
|
|
4556
|
-
async function apiGetTakerCapacity(req, baseApiUrl, timeoutMs) {
|
|
4557
|
-
if (!isValidHexAddress(req.owner)) {
|
|
4558
|
-
throw new ValidationError("owner must be a valid Ethereum address", "owner");
|
|
4559
|
-
}
|
|
4560
|
-
const normalizedOwner = req.owner.toLowerCase();
|
|
4561
|
-
const query = new URLSearchParams({
|
|
4562
|
-
owner: normalizedOwner,
|
|
4563
|
-
chainId: String(req.chainId)
|
|
4564
|
-
});
|
|
4565
|
-
const endpoint = `/v2/taker/capacity?${query.toString()}`;
|
|
4535
|
+
const endpoint = `/v2/taker/tier?${query.toString()}`;
|
|
4566
4536
|
return apiFetch({
|
|
4567
4537
|
url: `${withApiBase(baseApiUrl)}${endpoint}`,
|
|
4568
4538
|
method: "GET",
|
|
@@ -5288,74 +5258,209 @@ var VaultOperations = class {
|
|
|
5288
5258
|
var getRateManagerReadFunction = (abi, functionName) => Array.isArray(abi) && abi.some(
|
|
5289
5259
|
(item) => item.type === "function" && item.name === functionName
|
|
5290
5260
|
);
|
|
5291
|
-
|
|
5261
|
+
|
|
5262
|
+
// src/client/AccessPolicyOperations.ts
|
|
5263
|
+
var AccessPolicyUnsupportedError = class extends Error {
|
|
5264
|
+
constructor(contract) {
|
|
5265
|
+
super(`${contract} is not deployed for this environment.`);
|
|
5266
|
+
this.name = "AccessPolicyUnsupportedError";
|
|
5267
|
+
}
|
|
5268
|
+
};
|
|
5269
|
+
var AccessPolicyOperations = class {
|
|
5292
5270
|
constructor(config) {
|
|
5293
5271
|
this.config = config;
|
|
5294
5272
|
}
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5273
|
+
get isSupported() {
|
|
5274
|
+
return Boolean(
|
|
5275
|
+
this.config.getPolicyAddress() && this.config.getPolicyAbi() && this.config.getRegistryAddress() && this.config.getRegistryAbi()
|
|
5276
|
+
);
|
|
5277
|
+
}
|
|
5278
|
+
requirePolicy() {
|
|
5279
|
+
const address = this.config.getPolicyAddress();
|
|
5280
|
+
const abi = this.config.getPolicyAbi();
|
|
5281
|
+
if (!address || !abi) throw new AccessPolicyUnsupportedError("WhitelistPolicy");
|
|
5282
|
+
return { address, abi };
|
|
5283
|
+
}
|
|
5284
|
+
requireRegistry() {
|
|
5285
|
+
const address = this.config.getRegistryAddress();
|
|
5286
|
+
const abi = this.config.getRegistryAbi();
|
|
5287
|
+
if (!address || !abi) throw new AccessPolicyUnsupportedError("AddressGroupRegistry");
|
|
5288
|
+
return { address, abi };
|
|
5289
|
+
}
|
|
5290
|
+
/* ============ Reads ============ */
|
|
5291
|
+
async isEnabled(params) {
|
|
5292
|
+
const { address, abi } = this.requirePolicy();
|
|
5293
|
+
return await this.config.getPublicClient().readContract({
|
|
5294
|
+
address,
|
|
5295
|
+
abi,
|
|
5296
|
+
functionName: "enabled",
|
|
5297
|
+
args: [params.escrow, params.depositId]
|
|
5298
|
+
});
|
|
5299
|
+
}
|
|
5300
|
+
/** Groups are enumerable onchain; direct addresses deliberately are not. */
|
|
5301
|
+
async getAllowedGroups(params) {
|
|
5302
|
+
const { address, abi } = this.requirePolicy();
|
|
5303
|
+
return await this.config.getPublicClient().readContract({
|
|
5304
|
+
address,
|
|
5305
|
+
abi,
|
|
5306
|
+
functionName: "getAllowedGroups",
|
|
5307
|
+
args: [params.escrow, params.depositId]
|
|
5308
|
+
});
|
|
5309
|
+
}
|
|
5310
|
+
/**
|
|
5311
|
+
* Point check for one address. There is no enumeration getter, so this can
|
|
5312
|
+
* confirm a known address but can never reconstruct a missing list.
|
|
5313
|
+
*/
|
|
5314
|
+
async isWhitelisted(params) {
|
|
5315
|
+
const { address, abi } = this.requirePolicy();
|
|
5316
|
+
return await this.config.getPublicClient().readContract({
|
|
5317
|
+
address,
|
|
5318
|
+
abi,
|
|
5319
|
+
functionName: "isWhitelisted",
|
|
5320
|
+
args: [params.escrow, params.depositId, params.taker]
|
|
5321
|
+
});
|
|
5322
|
+
}
|
|
5323
|
+
async maxGroupsPerDeposit() {
|
|
5324
|
+
const { address, abi } = this.requirePolicy();
|
|
5325
|
+
return await this.config.getPublicClient().readContract({
|
|
5326
|
+
address,
|
|
5327
|
+
abi,
|
|
5328
|
+
functionName: "MAX_GROUPS_PER_DEPOSIT"
|
|
5329
|
+
});
|
|
5330
|
+
}
|
|
5331
|
+
async groupExists(groupId) {
|
|
5332
|
+
const { address, abi } = this.requireRegistry();
|
|
5333
|
+
return await this.config.getPublicClient().readContract({
|
|
5334
|
+
address,
|
|
5335
|
+
abi,
|
|
5336
|
+
functionName: "groupExists",
|
|
5337
|
+
args: [groupId]
|
|
5338
|
+
});
|
|
5339
|
+
}
|
|
5340
|
+
/** Curated membership OR resolver. Resolver failures fail closed. */
|
|
5341
|
+
async isMember(params) {
|
|
5342
|
+
const { address, abi } = this.requireRegistry();
|
|
5343
|
+
return await this.config.getPublicClient().readContract({
|
|
5344
|
+
address,
|
|
5345
|
+
abi,
|
|
5346
|
+
functionName: "isMember",
|
|
5347
|
+
args: [params.groupId, params.account]
|
|
5348
|
+
});
|
|
5303
5349
|
}
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5350
|
+
/* ============ Prepareable writes ============ */
|
|
5351
|
+
preparePolicyCall(functionName, args, txOverrides) {
|
|
5352
|
+
const { address, abi } = this.requirePolicy();
|
|
5353
|
+
return this.config.prepareContractTransaction({
|
|
5307
5354
|
address,
|
|
5308
5355
|
abi,
|
|
5309
5356
|
functionName,
|
|
5310
|
-
args
|
|
5357
|
+
args,
|
|
5358
|
+
txOverrides
|
|
5311
5359
|
});
|
|
5312
5360
|
}
|
|
5313
|
-
|
|
5314
|
-
return this.
|
|
5361
|
+
prepareConfigureDeposit(params) {
|
|
5362
|
+
return this.preparePolicyCall(
|
|
5363
|
+
"configureDeposit",
|
|
5364
|
+
[params.escrow, params.depositId, params.enabled, params.groupIds, params.takers],
|
|
5365
|
+
params.txOverrides
|
|
5366
|
+
);
|
|
5315
5367
|
}
|
|
5316
|
-
|
|
5317
|
-
return this.
|
|
5368
|
+
prepareSetEnabled(params) {
|
|
5369
|
+
return this.preparePolicyCall(
|
|
5370
|
+
"setEnabled",
|
|
5371
|
+
[params.escrow, params.depositId, params.enabled],
|
|
5372
|
+
params.txOverrides
|
|
5373
|
+
);
|
|
5318
5374
|
}
|
|
5319
|
-
|
|
5320
|
-
return this.
|
|
5375
|
+
prepareAddAllowedGroups(params) {
|
|
5376
|
+
return this.preparePolicyCall(
|
|
5377
|
+
"addAllowedGroups",
|
|
5378
|
+
[params.escrow, params.depositId, params.groupIds],
|
|
5379
|
+
params.txOverrides
|
|
5380
|
+
);
|
|
5321
5381
|
}
|
|
5322
|
-
|
|
5323
|
-
return this.
|
|
5382
|
+
prepareRemoveAllowedGroups(params) {
|
|
5383
|
+
return this.preparePolicyCall(
|
|
5384
|
+
"removeAllowedGroups",
|
|
5385
|
+
[params.escrow, params.depositId, params.groupIds],
|
|
5386
|
+
params.txOverrides
|
|
5387
|
+
);
|
|
5324
5388
|
}
|
|
5325
|
-
|
|
5326
|
-
return this.
|
|
5389
|
+
prepareAddWhitelistedAddresses(params) {
|
|
5390
|
+
return this.preparePolicyCall(
|
|
5391
|
+
"addWhitelistedAddresses",
|
|
5392
|
+
[params.escrow, params.depositId, params.takers],
|
|
5393
|
+
params.txOverrides
|
|
5394
|
+
);
|
|
5327
5395
|
}
|
|
5328
|
-
|
|
5329
|
-
return this.
|
|
5396
|
+
prepareRemoveWhitelistedAddresses(params) {
|
|
5397
|
+
return this.preparePolicyCall(
|
|
5398
|
+
"removeWhitelistedAddresses",
|
|
5399
|
+
[params.escrow, params.depositId, params.takers],
|
|
5400
|
+
params.txOverrides
|
|
5401
|
+
);
|
|
5330
5402
|
}
|
|
5331
|
-
|
|
5332
|
-
|
|
5403
|
+
/** Encodes one planner step. */
|
|
5404
|
+
preparePlanStep(params) {
|
|
5405
|
+
const { escrow, depositId, step, txOverrides } = params;
|
|
5406
|
+
switch (step.kind) {
|
|
5407
|
+
case "configureDeposit":
|
|
5408
|
+
return this.prepareConfigureDeposit({
|
|
5409
|
+
escrow,
|
|
5410
|
+
depositId,
|
|
5411
|
+
enabled: step.enabled,
|
|
5412
|
+
groupIds: step.groupIds,
|
|
5413
|
+
takers: step.takers,
|
|
5414
|
+
txOverrides
|
|
5415
|
+
});
|
|
5416
|
+
case "setEnabled":
|
|
5417
|
+
return this.prepareSetEnabled({ escrow, depositId, enabled: step.enabled, txOverrides });
|
|
5418
|
+
case "addAllowedGroups":
|
|
5419
|
+
return this.prepareAddAllowedGroups({
|
|
5420
|
+
escrow,
|
|
5421
|
+
depositId,
|
|
5422
|
+
groupIds: step.groupIds,
|
|
5423
|
+
txOverrides
|
|
5424
|
+
});
|
|
5425
|
+
case "removeAllowedGroups":
|
|
5426
|
+
return this.prepareRemoveAllowedGroups({
|
|
5427
|
+
escrow,
|
|
5428
|
+
depositId,
|
|
5429
|
+
groupIds: step.groupIds,
|
|
5430
|
+
txOverrides
|
|
5431
|
+
});
|
|
5432
|
+
case "addWhitelistedAddresses":
|
|
5433
|
+
return this.prepareAddWhitelistedAddresses({
|
|
5434
|
+
escrow,
|
|
5435
|
+
depositId,
|
|
5436
|
+
takers: step.takers,
|
|
5437
|
+
txOverrides
|
|
5438
|
+
});
|
|
5439
|
+
case "removeWhitelistedAddresses":
|
|
5440
|
+
return this.prepareRemoveWhitelistedAddresses({
|
|
5441
|
+
escrow,
|
|
5442
|
+
depositId,
|
|
5443
|
+
takers: step.takers,
|
|
5444
|
+
txOverrides
|
|
5445
|
+
});
|
|
5446
|
+
}
|
|
5333
5447
|
}
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
this.
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
stakeToken,
|
|
5351
|
-
stakeOwner,
|
|
5352
|
-
selectedStakeOwner,
|
|
5353
|
-
selectionAuthorized,
|
|
5354
|
-
staked,
|
|
5355
|
-
locked,
|
|
5356
|
-
free,
|
|
5357
|
-
claimable
|
|
5358
|
-
};
|
|
5448
|
+
/**
|
|
5449
|
+
* Encodes a whole plan, in order.
|
|
5450
|
+
*
|
|
5451
|
+
* A plan with violations encodes to nothing: an invalid draft must be
|
|
5452
|
+
* rejected before a wallet is ever opened.
|
|
5453
|
+
*/
|
|
5454
|
+
preparePlan(params) {
|
|
5455
|
+
if (params.plan.violations.length > 0) return [];
|
|
5456
|
+
return params.plan.steps.map(
|
|
5457
|
+
(step) => this.preparePlanStep({
|
|
5458
|
+
escrow: params.escrow,
|
|
5459
|
+
depositId: params.depositId,
|
|
5460
|
+
step,
|
|
5461
|
+
txOverrides: params.txOverrides
|
|
5462
|
+
})
|
|
5463
|
+
);
|
|
5359
5464
|
}
|
|
5360
5465
|
};
|
|
5361
5466
|
|
|
@@ -6418,45 +6523,6 @@ var Zkp2pClient = class {
|
|
|
6418
6523
|
* @throws Error if walletClient is missing an account
|
|
6419
6524
|
*/
|
|
6420
6525
|
constructor(opts) {
|
|
6421
|
-
/** Deposit USDC stake owned by the transaction sender. */
|
|
6422
|
-
this.depositStake = this.buildStakeVaultMethod(
|
|
6423
|
-
"depositStake",
|
|
6424
|
-
(params) => [params.amount]
|
|
6425
|
-
);
|
|
6426
|
-
/** Withdraw the sender's free stake immediately; locked stake cannot move. */
|
|
6427
|
-
this.withdrawStake = this.buildStakeVaultMethod(
|
|
6428
|
-
"withdrawStake",
|
|
6429
|
-
(params) => [params.amount]
|
|
6430
|
-
);
|
|
6431
|
-
/** Withdraw the sender's complete claimable USDC balance. */
|
|
6432
|
-
this.claim = this.buildStakeVaultMethod("claim", () => []);
|
|
6433
|
-
/** Grant or revoke a taker's access to the sender's stake. */
|
|
6434
|
-
this.setTakerAuthorization = this.buildStakeVaultMethod("setTakerAuthorization", (params) => [params.taker, params.authorized]);
|
|
6435
|
-
/** Select the authorizing stake owner that backs the connected taker. */
|
|
6436
|
-
this.selectStakeOwner = this.buildStakeVaultMethod(
|
|
6437
|
-
"selectStakeOwner",
|
|
6438
|
-
(params) => [params.stakeOwner]
|
|
6439
|
-
);
|
|
6440
|
-
/** Clear the connected taker's selection and return to self-stake. */
|
|
6441
|
-
this.clearStakeOwner = this.buildStakeVaultMethod(
|
|
6442
|
-
"clearStakeOwner",
|
|
6443
|
-
() => []
|
|
6444
|
-
);
|
|
6445
|
-
/**
|
|
6446
|
-
* Release one or more RiskManager positions whose chargeback window matured.
|
|
6447
|
-
* Pass `riskManagerAddress` to pin the transaction to a snapshotted deployment.
|
|
6448
|
-
*/
|
|
6449
|
-
this.releaseMaturedPositions = this.buildRiskManagerMethod("releaseMaturedPositions", (params) => [params.intentHashes]);
|
|
6450
|
-
/**
|
|
6451
|
-
* Reconcile one failed OrchestratorV3 cancellation callback.
|
|
6452
|
-
* Pass `riskManagerAddress` to pin the transaction to a snapshotted deployment.
|
|
6453
|
-
*/
|
|
6454
|
-
this.reconcileCancellation = this.buildRiskManagerMethod("reconcileCancellation", (params) => [params.intentHash]);
|
|
6455
|
-
/**
|
|
6456
|
-
* Reconcile multiple failed OrchestratorV3 cancellation callbacks.
|
|
6457
|
-
* Pass `riskManagerAddress` to pin the transaction to a snapshotted deployment.
|
|
6458
|
-
*/
|
|
6459
|
-
this.reconcileCancellations = this.buildRiskManagerMethod("reconcileCancellations", (params) => [params.intentHashes]);
|
|
6460
6526
|
// ╔═══════════════════════════════════════════════════════════════════════════╗
|
|
6461
6527
|
// ║ CORE: DEPOSIT MANAGEMENT ║
|
|
6462
6528
|
// ╚═══════════════════════════════════════════════════════════════════════════╝
|
|
@@ -6756,6 +6822,30 @@ var Zkp2pClient = class {
|
|
|
6756
6822
|
}
|
|
6757
6823
|
}
|
|
6758
6824
|
);
|
|
6825
|
+
/**
|
|
6826
|
+
* Pay to extend a live intent through the standalone prepaid IntentGuardian.
|
|
6827
|
+
*
|
|
6828
|
+
* Payment is prepaid and non-refundable and transfers to the deposit owner,
|
|
6829
|
+
* not the protocol. Any account may pay for any live intent — the payer does
|
|
6830
|
+
* not have to be the taker — so the deposit token must be approved to the
|
|
6831
|
+
* guardian by whoever signs this.
|
|
6832
|
+
*
|
|
6833
|
+
* `maxCost` is required slippage protection: the guardian fee is
|
|
6834
|
+
* owner-governed and may change between quoting and execution, in which case
|
|
6835
|
+
* the call reverts with ExtensionCostExceedsMax instead of overcharging.
|
|
6836
|
+
* Never pass an unbounded maximum.
|
|
6837
|
+
*
|
|
6838
|
+
* Escrow still enforces the cumulative intent lifetime cap; the guardian does
|
|
6839
|
+
* not bypass it. After confirmation, refetch the intent — canonical expiry
|
|
6840
|
+
* comes from Escrow's IntentExpiryExtended event, not from guardian events.
|
|
6841
|
+
*/
|
|
6842
|
+
this.extendIntentLifetime = this.buildIntentGuardianMethod("extendIntent", (params) => [
|
|
6843
|
+
params.escrow,
|
|
6844
|
+
params.depositId,
|
|
6845
|
+
params.intentHash,
|
|
6846
|
+
params.additionalTime,
|
|
6847
|
+
params.maxCost
|
|
6848
|
+
]);
|
|
6759
6849
|
/**
|
|
6760
6850
|
* Update vault manager fee.
|
|
6761
6851
|
*/
|
|
@@ -7315,8 +7405,6 @@ var Zkp2pClient = class {
|
|
|
7315
7405
|
this.escrowV2Abi = abis.escrowV2 ?? abis.escrow;
|
|
7316
7406
|
this.orchestratorV2Address = toAddress(addresses.orchestratorV2 ?? addresses.orchestrator);
|
|
7317
7407
|
this.orchestratorV2Abi = abis.orchestratorV2 ?? abis.orchestrator;
|
|
7318
|
-
this.orchestratorV3Address = toAddress(addresses.orchestratorV3);
|
|
7319
|
-
this.orchestratorV3Abi = abis.orchestratorV3;
|
|
7320
7408
|
const configuredEscrowAddresses = (addresses.escrowAddresses ?? []).map((value) => toAddress(value)).filter((value) => Boolean(value));
|
|
7321
7409
|
const configuredOrchestratorAddresses = (addresses.orchestratorAddresses ?? []).map((value) => toAddress(value)).filter((value) => Boolean(value));
|
|
7322
7410
|
this.escrowAddresses = uniqAddresses([
|
|
@@ -7330,7 +7418,6 @@ var Zkp2pClient = class {
|
|
|
7330
7418
|
}
|
|
7331
7419
|
this.orchestratorAddresses = uniqAddresses([
|
|
7332
7420
|
this.orchestratorV2Address ?? toAddress(addresses.orchestrator),
|
|
7333
|
-
this.orchestratorV3Address,
|
|
7334
7421
|
...configuredOrchestratorAddresses
|
|
7335
7422
|
]);
|
|
7336
7423
|
this.orchestratorAddress = this.orchestratorV2Address ?? toAddress(addresses.orchestrator) ?? this.orchestratorAddresses[0];
|
|
@@ -7354,14 +7441,16 @@ var Zkp2pClient = class {
|
|
|
7354
7441
|
this.rateManagerV1Abi = abis.rateManagerV1;
|
|
7355
7442
|
this.orchestratorRegistryAddress = toAddress(addresses.orchestratorRegistry);
|
|
7356
7443
|
this.orchestratorRegistryAbi = abis.orchestratorRegistry;
|
|
7444
|
+
this.addressGroupRegistryAddress = toAddress(addresses.addressGroupRegistry);
|
|
7445
|
+
this.addressGroupRegistryAbi = abis.addressGroupRegistry;
|
|
7446
|
+
this.whitelistPolicyAddress = toAddress(addresses.whitelistPolicy);
|
|
7447
|
+
this.whitelistPolicyAbi = abis.whitelistPolicy;
|
|
7357
7448
|
this.rateManagerRegistryAddress = toAddress(addresses.rateManagerRegistry) ?? this.rateManagerV1Address;
|
|
7358
7449
|
this.rateManagerRegistryAbi = abis.rateManagerRegistry ?? this.rateManagerV1Abi;
|
|
7359
7450
|
this.rateManagerControllerAddress = toAddress(addresses.rateManagerController);
|
|
7360
7451
|
this.rateManagerControllerAbi = abis.rateManagerController;
|
|
7361
|
-
this.
|
|
7362
|
-
this.
|
|
7363
|
-
this.riskManagerAddress = toAddress(addresses.riskManager);
|
|
7364
|
-
this.riskManagerAbi = abis.riskManager;
|
|
7452
|
+
this.intentGuardianAddress = toAddress(addresses.intentGuardian);
|
|
7453
|
+
this.intentGuardianAbi = abis.intentGuardian;
|
|
7365
7454
|
if (!this.rateManagerRegistryAddress || !this.rateManagerRegistryAbi) {
|
|
7366
7455
|
try {
|
|
7367
7456
|
const rateManagerContracts = getRateManagerContracts(this.chainId, this.runtimeEnv);
|
|
@@ -7387,8 +7476,6 @@ var Zkp2pClient = class {
|
|
|
7387
7476
|
orchestratorAbi: this.orchestratorAbi,
|
|
7388
7477
|
orchestratorV2Address: this.orchestratorV2Address,
|
|
7389
7478
|
orchestratorV2Abi: this.orchestratorV2Abi,
|
|
7390
|
-
orchestratorV3Address: this.orchestratorV3Address,
|
|
7391
|
-
orchestratorV3Abi: this.orchestratorV3Abi,
|
|
7392
7479
|
orchestratorAddresses: this.orchestratorAddresses
|
|
7393
7480
|
});
|
|
7394
7481
|
if (addresses.usdc) this._usdcAddress = addresses.usdc;
|
|
@@ -7444,11 +7531,10 @@ var Zkp2pClient = class {
|
|
|
7444
7531
|
prepareContractTransaction: (tx) => this.prepareContractTransaction(tx)
|
|
7445
7532
|
}
|
|
7446
7533
|
});
|
|
7447
|
-
this.
|
|
7534
|
+
this._intentGuardianOps = new IntentGuardianOperations({
|
|
7448
7535
|
getPublicClient: () => this.publicClient,
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
getStakeTokenAddress: () => this._usdcAddress
|
|
7536
|
+
getGuardianAddress: () => this.intentGuardianAddress,
|
|
7537
|
+
getGuardianAbi: () => this.intentGuardianAbi
|
|
7452
7538
|
});
|
|
7453
7539
|
this._intentOps = new IntentOperations({
|
|
7454
7540
|
getWalletClient: () => this.walletClient,
|
|
@@ -7473,6 +7559,14 @@ var Zkp2pClient = class {
|
|
|
7473
7559
|
getPvIntent: (intentHash) => this.getPvIntent(intentHash)
|
|
7474
7560
|
}
|
|
7475
7561
|
});
|
|
7562
|
+
this._accessPolicyOps = new AccessPolicyOperations({
|
|
7563
|
+
getPublicClient: () => this.publicClient,
|
|
7564
|
+
getPolicyAddress: () => this.whitelistPolicyAddress,
|
|
7565
|
+
getPolicyAbi: () => this.whitelistPolicyAbi,
|
|
7566
|
+
getRegistryAddress: () => this.addressGroupRegistryAddress,
|
|
7567
|
+
getRegistryAbi: () => this.addressGroupRegistryAbi,
|
|
7568
|
+
prepareContractTransaction: (tx) => this.prepareContractTransaction(tx)
|
|
7569
|
+
});
|
|
7476
7570
|
this._referralOps = new ReferralAccountOperations({
|
|
7477
7571
|
getWalletClient: () => this.walletClient,
|
|
7478
7572
|
getChainId: () => this.chainId,
|
|
@@ -7680,13 +7774,10 @@ var Zkp2pClient = class {
|
|
|
7680
7774
|
const explicit = this.getOrchestratorContextByAddress(options?.orchestratorAddress);
|
|
7681
7775
|
if (explicit) return explicit;
|
|
7682
7776
|
if (options?.orchestratorAddress) {
|
|
7683
|
-
const
|
|
7777
|
+
const addr = options.orchestratorAddress;
|
|
7778
|
+
const abi = this.orchestratorV2Abi ?? this.orchestratorAbi;
|
|
7684
7779
|
if (!abi) throw new Error("Orchestrator not available");
|
|
7685
|
-
return {
|
|
7686
|
-
address: options.orchestratorAddress,
|
|
7687
|
-
abi,
|
|
7688
|
-
version: this.orchestratorV3Abi ? "v3" : "v2"
|
|
7689
|
-
};
|
|
7780
|
+
return { address: addr, abi, version: "v2" };
|
|
7690
7781
|
}
|
|
7691
7782
|
if (options?.intentHash) {
|
|
7692
7783
|
try {
|
|
@@ -7872,7 +7963,7 @@ var Zkp2pClient = class {
|
|
|
7872
7963
|
buildContractMethod(resolveContract, functionName, buildArgs, buildValue) {
|
|
7873
7964
|
return Object.assign(
|
|
7874
7965
|
async (params) => {
|
|
7875
|
-
const contract = resolveContract(
|
|
7966
|
+
const contract = resolveContract();
|
|
7876
7967
|
if (!contract.address || !contract.abi) {
|
|
7877
7968
|
throw new Error(`${contract.label} not available`);
|
|
7878
7969
|
}
|
|
@@ -7888,7 +7979,7 @@ var Zkp2pClient = class {
|
|
|
7888
7979
|
},
|
|
7889
7980
|
{
|
|
7890
7981
|
prepare: async (params) => {
|
|
7891
|
-
const contract = resolveContract(
|
|
7982
|
+
const contract = resolveContract();
|
|
7892
7983
|
if (!contract.address || !contract.abi) {
|
|
7893
7984
|
throw new Error(`${contract.label} not available`);
|
|
7894
7985
|
}
|
|
@@ -7910,23 +8001,12 @@ var Zkp2pClient = class {
|
|
|
7910
8001
|
}
|
|
7911
8002
|
);
|
|
7912
8003
|
}
|
|
7913
|
-
|
|
8004
|
+
buildIntentGuardianMethod(functionName, buildArgs) {
|
|
7914
8005
|
return this.buildContractMethod(
|
|
7915
8006
|
() => ({
|
|
7916
|
-
address: this.
|
|
7917
|
-
abi: this.
|
|
7918
|
-
label: "
|
|
7919
|
-
}),
|
|
7920
|
-
functionName,
|
|
7921
|
-
buildArgs
|
|
7922
|
-
);
|
|
7923
|
-
}
|
|
7924
|
-
buildRiskManagerMethod(functionName, buildArgs) {
|
|
7925
|
-
return this.buildContractMethod(
|
|
7926
|
-
(params) => ({
|
|
7927
|
-
address: params.riskManagerAddress ?? this.riskManagerAddress,
|
|
7928
|
-
abi: this.riskManagerAbi,
|
|
7929
|
-
label: "RiskManager"
|
|
8007
|
+
address: this.intentGuardianAddress,
|
|
8008
|
+
abi: this.intentGuardianAbi,
|
|
8009
|
+
label: "IntentGuardian"
|
|
7930
8010
|
}),
|
|
7931
8011
|
functionName,
|
|
7932
8012
|
buildArgs
|
|
@@ -8389,76 +8469,6 @@ var Zkp2pClient = class {
|
|
|
8389
8469
|
});
|
|
8390
8470
|
return { hadAllowance: false, hash };
|
|
8391
8471
|
}
|
|
8392
|
-
// ╔═══════════════════════════════════════════════════════════════════════════╗
|
|
8393
|
-
// ║ CORE: TAKER STAKING ║
|
|
8394
|
-
// ╚═══════════════════════════════════════════════════════════════════════════╝
|
|
8395
|
-
/**
|
|
8396
|
-
* Return the resolved StakeVault coordinates for advanced wallet, relayer,
|
|
8397
|
-
* or reactive read integrations.
|
|
8398
|
-
*/
|
|
8399
|
-
getStakeVaultContract() {
|
|
8400
|
-
return this._stakeOps.getContract();
|
|
8401
|
-
}
|
|
8402
|
-
/** Return the resolved OrchestratorV3 coordinates for advanced integrations. */
|
|
8403
|
-
getOrchestratorV3Contract() {
|
|
8404
|
-
if (!this.orchestratorV3Address || !this.orchestratorV3Abi) {
|
|
8405
|
-
throw new Error("OrchestratorV3 not available for this chain/environment");
|
|
8406
|
-
}
|
|
8407
|
-
return { address: this.orchestratorV3Address, abi: this.orchestratorV3Abi };
|
|
8408
|
-
}
|
|
8409
|
-
/** Return the resolved RiskManager coordinates for keeper integrations. */
|
|
8410
|
-
getRiskManagerContract() {
|
|
8411
|
-
if (!this.riskManagerAddress || !this.riskManagerAbi) {
|
|
8412
|
-
throw new Error("RiskManager not available for this chain/environment");
|
|
8413
|
-
}
|
|
8414
|
-
return { address: this.riskManagerAddress, abi: this.riskManagerAbi };
|
|
8415
|
-
}
|
|
8416
|
-
/**
|
|
8417
|
-
* Ensure the connected wallet has approved enough USDC for StakeVault.
|
|
8418
|
-
* If an approval is submitted, wait for it to confirm before depositing.
|
|
8419
|
-
*/
|
|
8420
|
-
async ensureStakeAllowance(params) {
|
|
8421
|
-
const { address, stakeToken } = this._stakeOps.getContract();
|
|
8422
|
-
return this.ensureAllowance({
|
|
8423
|
-
token: stakeToken,
|
|
8424
|
-
spender: address,
|
|
8425
|
-
amount: params.amount,
|
|
8426
|
-
maxApprove: params.maxApprove,
|
|
8427
|
-
txOverrides: params.txOverrides
|
|
8428
|
-
});
|
|
8429
|
-
}
|
|
8430
|
-
/** Read total stake owned by an address directly from StakeVault. */
|
|
8431
|
-
getStakeBalance(stakeOwner) {
|
|
8432
|
-
return this._stakeOps.getStakeBalance(stakeOwner);
|
|
8433
|
-
}
|
|
8434
|
-
/** Read stake committed to active RiskManager locks. */
|
|
8435
|
-
getLockedStake(stakeOwner) {
|
|
8436
|
-
return this._stakeOps.getLockedStake(stakeOwner);
|
|
8437
|
-
}
|
|
8438
|
-
/** Read stake available for immediate withdrawal or a new lock. */
|
|
8439
|
-
getFreeStake(stakeOwner) {
|
|
8440
|
-
return this._stakeOps.getFreeStake(stakeOwner);
|
|
8441
|
-
}
|
|
8442
|
-
/** Read the non-stake USDC withdrawable by a beneficiary with `claim()`. */
|
|
8443
|
-
getClaimable(beneficiary) {
|
|
8444
|
-
return this._stakeOps.getClaimable(beneficiary);
|
|
8445
|
-
}
|
|
8446
|
-
/** Resolve the effective stake owner backing a taker. */
|
|
8447
|
-
getStakeOwner(taker) {
|
|
8448
|
-
return this._stakeOps.getStakeOwner(taker);
|
|
8449
|
-
}
|
|
8450
|
-
/** Read a taker's raw selection, which is stale once authorization is revoked. */
|
|
8451
|
-
getSelectedStakeOwner(taker) {
|
|
8452
|
-
return this._stakeOps.getSelectedStakeOwner(taker);
|
|
8453
|
-
}
|
|
8454
|
-
/** Read whether a stake owner currently authorizes a taker. */
|
|
8455
|
-
getTakerAuthorization(stakeOwner, taker) {
|
|
8456
|
-
return this._stakeOps.getTakerAuthorization(stakeOwner, taker);
|
|
8457
|
-
}
|
|
8458
|
-
/** Read the complete authoritative StakeVault state needed by a staking UI. */
|
|
8459
|
-
getStakeVaultState(params) {
|
|
8460
|
-
return this._stakeOps.getStakeVaultState(params);
|
|
8461
|
-
}
|
|
8462
8472
|
/**
|
|
8463
8473
|
* Registers payee details with the curator API and returns hashed on-chain IDs.
|
|
8464
8474
|
*
|
|
@@ -8694,6 +8704,31 @@ var Zkp2pClient = class {
|
|
|
8694
8704
|
});
|
|
8695
8705
|
return { depositDetails, prepared };
|
|
8696
8706
|
}
|
|
8707
|
+
/**
|
|
8708
|
+
* Live guardian policy, including whether governance has disabled extensions
|
|
8709
|
+
* by setting the fee to zero. Read this rather than caching a fee value.
|
|
8710
|
+
*/
|
|
8711
|
+
async getIntentGuardianPolicy() {
|
|
8712
|
+
return this._intentGuardianOps.getPolicy();
|
|
8713
|
+
}
|
|
8714
|
+
/**
|
|
8715
|
+
* Authoritative on-chain extension quote. Call immediately before signing and
|
|
8716
|
+
* derive `maxCost` from the result — a displayed quote is never a commitment.
|
|
8717
|
+
*/
|
|
8718
|
+
async quoteIntentExtension(params) {
|
|
8719
|
+
return this._intentGuardianOps.quoteExtensionCost(params);
|
|
8720
|
+
}
|
|
8721
|
+
/**
|
|
8722
|
+
* Payer allowance/balance against the guardian for the target deposit token.
|
|
8723
|
+
* The guardian charges `deposit.token`, which is not necessarily USDC.
|
|
8724
|
+
*/
|
|
8725
|
+
async getIntentGuardianPayerFunding(params) {
|
|
8726
|
+
return this._intentGuardianOps.getPayerFunding(params);
|
|
8727
|
+
}
|
|
8728
|
+
/** True when this deployment has a usable guardian. Gate UI on this. */
|
|
8729
|
+
hasIntentGuardian() {
|
|
8730
|
+
return this._intentGuardianOps.isAvailable();
|
|
8731
|
+
}
|
|
8697
8732
|
/**
|
|
8698
8733
|
* Read controller delegation state for a deposit.
|
|
8699
8734
|
*/
|
|
@@ -8728,6 +8763,16 @@ var Zkp2pClient = class {
|
|
|
8728
8763
|
async prepareReleaseFundsToPayer(params) {
|
|
8729
8764
|
return this._intentOps.prepareReleaseFundsToPayer(params);
|
|
8730
8765
|
}
|
|
8766
|
+
/**
|
|
8767
|
+
* Deposit access policies and verified address groups.
|
|
8768
|
+
*
|
|
8769
|
+
* `accessPolicy.isSupported` is false wherever the contracts are not
|
|
8770
|
+
* deployed. Writes are depositor-only, and saving a policy configures storage
|
|
8771
|
+
* rather than enforcing admission.
|
|
8772
|
+
*/
|
|
8773
|
+
get accessPolicy() {
|
|
8774
|
+
return this._accessPolicyOps;
|
|
8775
|
+
}
|
|
8731
8776
|
async prepareSetDepositPreIntentHook(params) {
|
|
8732
8777
|
return this._intentOps.prepareSetDepositPreIntentHook(params);
|
|
8733
8778
|
}
|
|
@@ -8894,48 +8939,25 @@ var Zkp2pClient = class {
|
|
|
8894
8939
|
return appendReferrerFeeDisplayFieldsToBestByPlatform(enrichedQuote, referrerFeeConfig);
|
|
8895
8940
|
}
|
|
8896
8941
|
// ───────────────────────────────────────────────────────────────────────────
|
|
8897
|
-
// SUPPORTING: TAKER
|
|
8898
|
-
// (Used by frontends to display
|
|
8899
|
-
// capacity; never used to filter quotes)
|
|
8942
|
+
// SUPPORTING: TAKER TIER
|
|
8943
|
+
// (Used by frontends to display taker limits)
|
|
8900
8944
|
// ───────────────────────────────────────────────────────────────────────────
|
|
8901
8945
|
/**
|
|
8902
|
-
* **Supporting Method** - Fetches
|
|
8903
|
-
* staked/pending-withdrawal/eligible/reserved/free balances, reservation
|
|
8904
|
-
* aggregates, delegation, and exit state.
|
|
8946
|
+
* **Supporting Method** - Fetches taker tier information for an address.
|
|
8905
8947
|
*
|
|
8906
|
-
* @param req -
|
|
8907
|
-
* @param req.owner - Taker address
|
|
8948
|
+
* @param req - Taker tier request parameters
|
|
8949
|
+
* @param req.owner - Taker address
|
|
8908
8950
|
* @param req.chainId - Chain ID
|
|
8909
8951
|
* @param opts - Optional overrides for API URL and timeout
|
|
8910
|
-
* @returns Taker
|
|
8952
|
+
* @returns Taker tier response
|
|
8911
8953
|
*/
|
|
8912
|
-
async
|
|
8954
|
+
async getTakerTier(req, opts) {
|
|
8913
8955
|
const baseApiUrl = (opts?.baseApiUrl ?? this.baseApiUrl ?? DEFAULT_BASE_API_URL).replace(
|
|
8914
8956
|
/\/$/,
|
|
8915
8957
|
""
|
|
8916
8958
|
);
|
|
8917
8959
|
const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
|
|
8918
|
-
return
|
|
8919
|
-
}
|
|
8920
|
-
/**
|
|
8921
|
-
* **Supporting Method** - Fetches per-platform bonded taking capacity, free
|
|
8922
|
-
* takes, curve terms, warnings, and operational gates for a taker's shared
|
|
8923
|
-
* stake portfolio. Platform capacities are alternative views of one shared
|
|
8924
|
-
* balance and must never be summed.
|
|
8925
|
-
*
|
|
8926
|
-
* @param req - Capacity request parameters
|
|
8927
|
-
* @param req.owner - Taker address (the resolved stake owner may differ)
|
|
8928
|
-
* @param req.chainId - Chain ID
|
|
8929
|
-
* @param opts - Optional overrides for API URL and timeout
|
|
8930
|
-
* @returns Taker capacity response
|
|
8931
|
-
*/
|
|
8932
|
-
async getTakerCapacity(req, opts) {
|
|
8933
|
-
const baseApiUrl = (opts?.baseApiUrl ?? this.baseApiUrl ?? DEFAULT_BASE_API_URL).replace(
|
|
8934
|
-
/\/$/,
|
|
8935
|
-
""
|
|
8936
|
-
);
|
|
8937
|
-
const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
|
|
8938
|
-
return apiGetTakerCapacity(req, baseApiUrl, timeoutMs);
|
|
8960
|
+
return apiGetTakerTier(req, baseApiUrl, timeoutMs);
|
|
8939
8961
|
}
|
|
8940
8962
|
/**
|
|
8941
8963
|
* Fetch a referral dashboard. Pass `address` for a public wallet-keyed read;
|
|
@@ -9254,15 +9276,12 @@ var Zkp2pClient = class {
|
|
|
9254
9276
|
escrowAddresses: this.escrowAddresses,
|
|
9255
9277
|
orchestrator: this.orchestratorAddress,
|
|
9256
9278
|
orchestratorV2: this.orchestratorV2Address,
|
|
9257
|
-
orchestratorV3: this.orchestratorV3Address,
|
|
9258
9279
|
orchestratorAddresses: this.orchestratorAddresses,
|
|
9259
9280
|
protocolViewer: this.protocolViewerAddress,
|
|
9260
9281
|
protocolViewerEntries: this._protocolViewerEntries.map((e) => e.address),
|
|
9261
9282
|
unifiedPaymentVerifier: this.unifiedPaymentVerifier,
|
|
9262
9283
|
rateManagerV1: this.rateManagerV1Address,
|
|
9263
9284
|
orchestratorRegistry: this.orchestratorRegistryAddress,
|
|
9264
|
-
stakeVault: this.stakeVaultAddress,
|
|
9265
|
-
riskManager: this.riskManagerAddress,
|
|
9266
9285
|
usdc: this._usdcAddress
|
|
9267
9286
|
};
|
|
9268
9287
|
}
|
|
@@ -9337,57 +9356,162 @@ var createPeerExtensionSdk = (options = {}) => ({
|
|
|
9337
9356
|
});
|
|
9338
9357
|
var peerExtensionSdk = createPeerExtensionSdk();
|
|
9339
9358
|
|
|
9340
|
-
// src/
|
|
9341
|
-
var
|
|
9342
|
-
var
|
|
9343
|
-
var
|
|
9344
|
-
|
|
9345
|
-
if (
|
|
9346
|
-
|
|
9347
|
-
|
|
9348
|
-
|
|
9349
|
-
|
|
9350
|
-
return
|
|
9351
|
-
}
|
|
9352
|
-
|
|
9353
|
-
|
|
9354
|
-
|
|
9355
|
-
|
|
9356
|
-
|
|
9357
|
-
|
|
9358
|
-
|
|
9359
|
-
|
|
9360
|
-
|
|
9361
|
-
|
|
9362
|
-
|
|
9363
|
-
|
|
9364
|
-
|
|
9365
|
-
|
|
9366
|
-
|
|
9367
|
-
|
|
9368
|
-
|
|
9369
|
-
|
|
9370
|
-
const
|
|
9371
|
-
|
|
9359
|
+
// src/client/accessPolicyPlan.ts
|
|
9360
|
+
var MAX_GROUPS_PER_DEPOSIT = 10;
|
|
9361
|
+
var MAX_ADDRESSES_PER_CALL = 50;
|
|
9362
|
+
var MAX_WHITELISTED_ADDRESSES = 500;
|
|
9363
|
+
var chunk = (values, size) => {
|
|
9364
|
+
if (values.length <= size) return values.length > 0 ? [values] : [];
|
|
9365
|
+
const batches = [];
|
|
9366
|
+
for (let index = 0; index < values.length; index += size) {
|
|
9367
|
+
batches.push(values.slice(index, index + size));
|
|
9368
|
+
}
|
|
9369
|
+
return batches;
|
|
9370
|
+
};
|
|
9371
|
+
var normalizeList = (values) => {
|
|
9372
|
+
const seen = /* @__PURE__ */ new Set();
|
|
9373
|
+
const normalized = [];
|
|
9374
|
+
for (const value of values) {
|
|
9375
|
+
if (typeof value !== "string") continue;
|
|
9376
|
+
const trimmed = value.trim().toLowerCase();
|
|
9377
|
+
if (!trimmed || seen.has(trimmed)) continue;
|
|
9378
|
+
seen.add(trimmed);
|
|
9379
|
+
normalized.push(trimmed);
|
|
9380
|
+
}
|
|
9381
|
+
return normalized;
|
|
9382
|
+
};
|
|
9383
|
+
var normalizeAccessPolicyState = (state) => ({
|
|
9384
|
+
enabled: Boolean(state.enabled),
|
|
9385
|
+
groupIds: normalizeList(state.groupIds),
|
|
9386
|
+
addresses: normalizeList(state.addresses)
|
|
9387
|
+
});
|
|
9388
|
+
var difference = (left, right) => {
|
|
9389
|
+
const exclude = new Set(right);
|
|
9390
|
+
return left.filter((value) => !exclude.has(value));
|
|
9391
|
+
};
|
|
9392
|
+
var diffAccessPolicy = (persistedInput, draftInput) => {
|
|
9393
|
+
const persisted = normalizeAccessPolicyState(persistedInput);
|
|
9394
|
+
const draft = normalizeAccessPolicyState(draftInput);
|
|
9372
9395
|
return {
|
|
9373
|
-
|
|
9374
|
-
|
|
9396
|
+
addedGroupIds: difference(draft.groupIds, persisted.groupIds),
|
|
9397
|
+
removedGroupIds: difference(persisted.groupIds, draft.groupIds),
|
|
9398
|
+
addedAddresses: difference(draft.addresses, persisted.addresses),
|
|
9399
|
+
removedAddresses: difference(persisted.addresses, draft.addresses),
|
|
9400
|
+
enabledChanged: persisted.enabled !== draft.enabled
|
|
9375
9401
|
};
|
|
9376
|
-
}
|
|
9377
|
-
|
|
9378
|
-
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
|
|
9382
|
-
|
|
9383
|
-
|
|
9384
|
-
|
|
9385
|
-
|
|
9386
|
-
if (
|
|
9387
|
-
|
|
9388
|
-
|
|
9389
|
-
|
|
9402
|
+
};
|
|
9403
|
+
var planAccessPolicyUpdate = (persistedInput, draftInput) => {
|
|
9404
|
+
const persisted = normalizeAccessPolicyState(persistedInput);
|
|
9405
|
+
const draft = normalizeAccessPolicyState(draftInput);
|
|
9406
|
+
const diff = diffAccessPolicy(persisted, draft);
|
|
9407
|
+
const hasChanges = diff.enabledChanged || diff.addedGroupIds.length > 0 || diff.removedGroupIds.length > 0 || diff.addedAddresses.length > 0 || diff.removedAddresses.length > 0;
|
|
9408
|
+
const violations = [];
|
|
9409
|
+
if (draft.enabled && draft.groupIds.length === 0 && draft.addresses.length === 0) {
|
|
9410
|
+
violations.push("empty-restricted-policy");
|
|
9411
|
+
}
|
|
9412
|
+
if (draft.groupIds.length > MAX_GROUPS_PER_DEPOSIT) {
|
|
9413
|
+
violations.push("group-cap-exceeded");
|
|
9414
|
+
}
|
|
9415
|
+
if (draft.addresses.length > MAX_WHITELISTED_ADDRESSES) {
|
|
9416
|
+
violations.push("address-cap-exceeded");
|
|
9417
|
+
}
|
|
9418
|
+
if (!hasChanges || violations.length > 0) {
|
|
9419
|
+
return {
|
|
9420
|
+
diff,
|
|
9421
|
+
steps: [],
|
|
9422
|
+
hasChanges,
|
|
9423
|
+
ordering: hasChanges ? "additions-first" : "no-changes",
|
|
9424
|
+
violations,
|
|
9425
|
+
resultingGroupCount: draft.groupIds.length
|
|
9426
|
+
};
|
|
9427
|
+
}
|
|
9428
|
+
const peakIfAddingFirst = (/* @__PURE__ */ new Set([...persisted.groupIds, ...diff.addedGroupIds])).size;
|
|
9429
|
+
const mustRemoveGroupsFirst = peakIfAddingFirst > MAX_GROUPS_PER_DEPOSIT;
|
|
9430
|
+
const ordering = !draft.enabled ? "disable-first" : mustRemoveGroupsFirst ? "removals-first" : "additions-first";
|
|
9431
|
+
const steps = [];
|
|
9432
|
+
const additionSteps = () => {
|
|
9433
|
+
const collected = [];
|
|
9434
|
+
if (diff.addedGroupIds.length > 0) {
|
|
9435
|
+
collected.push({
|
|
9436
|
+
kind: "addAllowedGroups",
|
|
9437
|
+
groupIds: diff.addedGroupIds
|
|
9438
|
+
});
|
|
9439
|
+
}
|
|
9440
|
+
for (const batch of chunk(diff.addedAddresses, MAX_ADDRESSES_PER_CALL)) {
|
|
9441
|
+
collected.push({ kind: "addWhitelistedAddresses", takers: batch });
|
|
9442
|
+
}
|
|
9443
|
+
return collected;
|
|
9444
|
+
};
|
|
9445
|
+
const removalSteps = () => {
|
|
9446
|
+
const collected = [];
|
|
9447
|
+
if (diff.removedGroupIds.length > 0) {
|
|
9448
|
+
collected.push({
|
|
9449
|
+
kind: "removeAllowedGroups",
|
|
9450
|
+
groupIds: diff.removedGroupIds
|
|
9451
|
+
});
|
|
9452
|
+
}
|
|
9453
|
+
for (const batch of chunk(diff.removedAddresses, MAX_ADDRESSES_PER_CALL)) {
|
|
9454
|
+
collected.push({ kind: "removeWhitelistedAddresses", takers: batch });
|
|
9455
|
+
}
|
|
9456
|
+
return collected;
|
|
9457
|
+
};
|
|
9458
|
+
if (ordering === "disable-first") {
|
|
9459
|
+
if (diff.enabledChanged) {
|
|
9460
|
+
steps.push({ kind: "setEnabled", enabled: false });
|
|
9461
|
+
}
|
|
9462
|
+
steps.push(...removalSteps(), ...additionSteps());
|
|
9463
|
+
return {
|
|
9464
|
+
diff,
|
|
9465
|
+
steps,
|
|
9466
|
+
hasChanges,
|
|
9467
|
+
ordering,
|
|
9468
|
+
violations,
|
|
9469
|
+
resultingGroupCount: draft.groupIds.length
|
|
9470
|
+
};
|
|
9471
|
+
}
|
|
9472
|
+
if (ordering === "removals-first") {
|
|
9473
|
+
if (persisted.enabled) {
|
|
9474
|
+
steps.push({ kind: "setEnabled", enabled: false });
|
|
9475
|
+
}
|
|
9476
|
+
steps.push(...removalSteps(), ...additionSteps());
|
|
9477
|
+
steps.push({ kind: "setEnabled", enabled: true });
|
|
9478
|
+
return {
|
|
9479
|
+
diff,
|
|
9480
|
+
steps,
|
|
9481
|
+
hasChanges,
|
|
9482
|
+
ordering,
|
|
9483
|
+
violations,
|
|
9484
|
+
resultingGroupCount: draft.groupIds.length
|
|
9485
|
+
};
|
|
9486
|
+
}
|
|
9487
|
+
if (diff.enabledChanged) {
|
|
9488
|
+
const [firstBatch = [], ...overflowBatches] = chunk(
|
|
9489
|
+
diff.addedAddresses,
|
|
9490
|
+
MAX_ADDRESSES_PER_CALL
|
|
9491
|
+
);
|
|
9492
|
+
steps.push({
|
|
9493
|
+
kind: "configureDeposit",
|
|
9494
|
+
enabled: true,
|
|
9495
|
+
groupIds: diff.addedGroupIds,
|
|
9496
|
+
takers: firstBatch
|
|
9497
|
+
});
|
|
9498
|
+
for (const batch of overflowBatches) {
|
|
9499
|
+
steps.push({ kind: "addWhitelistedAddresses", takers: batch });
|
|
9500
|
+
}
|
|
9501
|
+
} else {
|
|
9502
|
+
steps.push(...additionSteps());
|
|
9503
|
+
}
|
|
9504
|
+
steps.push(...removalSteps());
|
|
9505
|
+
return {
|
|
9506
|
+
diff,
|
|
9507
|
+
steps,
|
|
9508
|
+
hasChanges,
|
|
9509
|
+
ordering,
|
|
9510
|
+
violations,
|
|
9511
|
+
resultingGroupCount: draft.groupIds.length
|
|
9512
|
+
};
|
|
9513
|
+
};
|
|
9390
9514
|
|
|
9391
|
-
export { BASE_BUILDER_CODE, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractRouter, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, IndexerClient, IndexerDepositService, IndexerRateManagerService, Zkp2pClient as OfframpClient, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, REFERRAL_SIGNATURE_DOMAIN, REFERRAL_SIGNATURE_TYPES,
|
|
9515
|
+
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, apiGetQuotesBestByPlatform, apiGetReferralDashboard, apiGetReferralEarnings, apiGetTakerTier, apiLookupReferralCode, apiPostDepositDetails, apiRedeemReferralCode, apiRequestIdentityAttestation, 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 };
|
|
9392
9516
|
//# sourceMappingURL=index.mjs.map
|
|
9393
9517
|
//# sourceMappingURL=index.mjs.map
|