@vapi-network/core 0.9.0 → 0.9.4
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 +2 -2
- package/dist/api-key.js +2 -1
- package/dist/api-key.js.map +1 -1
- package/dist/backup.js +2 -1
- package/dist/backup.js.map +1 -1
- package/dist/call-contracts-wire.d.ts +176 -110
- package/dist/call-contracts-wire.d.ts.map +1 -1
- package/dist/call-contracts.d.ts +7 -1
- package/dist/call-contracts.d.ts.map +1 -1
- package/dist/cloud-backup.js +2 -1
- package/dist/cloud-backup.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1138 -973
- package/dist/index.js.map +3 -3
- package/dist/marketplace-contracts.d.ts +126 -86
- package/dist/marketplace-contracts.d.ts.map +1 -1
- package/dist/router-client.d.ts +2 -2
- package/dist/router-client.d.ts.map +1 -1
- package/dist/router-client.js +84 -20
- package/dist/router-client.js.map +2 -2
- package/dist/searches.d.ts +1 -0
- package/dist/searches.d.ts.map +1 -1
- package/dist/secrets.js +2 -1
- package/dist/secrets.js.map +1 -1
- package/dist/support-report.d.ts +1 -1
- package/dist/tasks/chain-error.d.ts.map +1 -1
- package/dist/tasks/chain-port.d.ts +2 -0
- package/dist/tasks/chain-port.d.ts.map +1 -1
- package/dist/tasks/chain.d.ts.map +1 -1
- package/dist/tasks/client.d.ts.map +1 -1
- package/dist/tasks/index.d.ts +1 -0
- package/dist/tasks/index.d.ts.map +1 -1
- package/dist/tasks/operation-support.d.ts.map +1 -1
- package/dist/tasks/operations.d.ts +56 -1
- package/dist/tasks/operations.d.ts.map +1 -1
- package/dist/tasks/types.d.ts +5 -5
- package/dist/tasks/types.d.ts.map +1 -1
- package/dist/tasks/wait.d.ts +18 -0
- package/dist/tasks/wait.d.ts.map +1 -0
- package/dist/tasks.js +249 -46
- package/dist/tasks.js.map +3 -3
- package/dist/vault-key.d.ts +4 -0
- package/dist/vault-key.d.ts.map +1 -1
- package/dist/wallet-store.d.ts +2 -0
- package/dist/wallet-store.d.ts.map +1 -1
- package/dist/x402-networks.d.ts +1 -0
- package/dist/x402-networks.d.ts.map +1 -1
- package/dist/x402-pay.d.ts +2 -2
- package/dist/x402-pay.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28912,378 +28912,6 @@ function date4(params) {
|
|
|
28912
28912
|
return _coercedDate(ZodDate, params);
|
|
28913
28913
|
}
|
|
28914
28914
|
|
|
28915
|
-
// src/marketplace-contracts.ts
|
|
28916
|
-
var MARKETPLACE_DISCOVERY_PROTOCOL = "vapi.marketplace.discovery/1";
|
|
28917
|
-
var MARKETPLACE_RANKING_VERSION = "marketplace-ranking-v1";
|
|
28918
|
-
var MARKETPLACE_KINDS = ["api", "service_offer", "open_request"];
|
|
28919
|
-
var MARKETPLACE_EXECUTION_METHODS = [
|
|
28920
|
-
"GET",
|
|
28921
|
-
"HEAD",
|
|
28922
|
-
"POST",
|
|
28923
|
-
"PUT",
|
|
28924
|
-
"PATCH",
|
|
28925
|
-
"DELETE"
|
|
28926
|
-
];
|
|
28927
|
-
var marketplaceExecutionMethodSchema = external_exports.enum(MARKETPLACE_EXECUTION_METHODS);
|
|
28928
|
-
var marketplaceKindSchema = external_exports.enum(MARKETPLACE_KINDS);
|
|
28929
|
-
var EXECUTION_MODES = ["direct", "gateway"];
|
|
28930
|
-
var executionModeSchema = external_exports.enum(EXECUTION_MODES);
|
|
28931
|
-
var PROVENANCES = ["indexed", "self_listed", "partner"];
|
|
28932
|
-
var provenanceSchema = external_exports.enum(PROVENANCES);
|
|
28933
|
-
var FIRST_PARTY_PROVENANCES = ["self_listed", "partner"];
|
|
28934
|
-
var firstPartyProvenanceSchema = external_exports.enum(FIRST_PARTY_PROVENANCES);
|
|
28935
|
-
var LISTING_GROUPS = ["vapi", "added", "partner", "external"];
|
|
28936
|
-
var listingGroupSchema = external_exports.enum(LISTING_GROUPS);
|
|
28937
|
-
var listingFeeSchema = external_exports.looseObject({
|
|
28938
|
-
bps: external_exports.number().int().min(0),
|
|
28939
|
-
label: external_exports.string()
|
|
28940
|
-
});
|
|
28941
|
-
var LISTING_VERIFICATIONS = ["none", "requested", "verified"];
|
|
28942
|
-
var listingVerificationSchema = external_exports.enum(LISTING_VERIFICATIONS);
|
|
28943
|
-
var listingVerificationFieldSchema = listingVerificationSchema.default("none").catch("none");
|
|
28944
|
-
var listingLivenessSchema = external_exports.looseObject({
|
|
28945
|
-
uptime7d: external_exports.number().min(0).max(1),
|
|
28946
|
-
latencyP50Ms: external_exports.number().nonnegative().nullable(),
|
|
28947
|
-
latencyP95Ms: external_exports.number().nonnegative().nullable(),
|
|
28948
|
-
checks7d: external_exports.number().int().nonnegative()
|
|
28949
|
-
});
|
|
28950
|
-
var listingConformanceSchema = external_exports.looseObject({
|
|
28951
|
-
declaredVersion: external_exports.union([external_exports.literal(1), external_exports.literal(2)]).nullable(),
|
|
28952
|
-
versionConformant: external_exports.boolean(),
|
|
28953
|
-
offerTransport: external_exports.enum(["body", "header", "both"]),
|
|
28954
|
-
issues: external_exports.array(external_exports.string())
|
|
28955
|
-
});
|
|
28956
|
-
var listingIdentitySchema = external_exports.looseObject({
|
|
28957
|
-
erc8004Id: external_exports.string().trim().min(1),
|
|
28958
|
-
reputation: external_exports.looseObject({
|
|
28959
|
-
score: external_exports.number().finite(),
|
|
28960
|
-
count: external_exports.number().int().nonnegative()
|
|
28961
|
-
}).optional().catch(void 0)
|
|
28962
|
-
});
|
|
28963
|
-
var listingDisclosureShape = {
|
|
28964
|
-
group: listingGroupSchema.optional(),
|
|
28965
|
-
fee: listingFeeSchema.optional(),
|
|
28966
|
-
verification: listingVerificationFieldSchema,
|
|
28967
|
-
liveness: listingLivenessSchema.optional().catch(void 0),
|
|
28968
|
-
conformance: listingConformanceSchema.optional().catch(void 0),
|
|
28969
|
-
identity: listingIdentitySchema.optional().catch(void 0)
|
|
28970
|
-
};
|
|
28971
|
-
var marketplaceBadgeCodeSchema = external_exports.enum([
|
|
28972
|
-
"live_x402",
|
|
28973
|
-
"partner",
|
|
28974
|
-
"payout_wallet_confirmed",
|
|
28975
|
-
"vapi_verified",
|
|
28976
|
-
"external_catalog",
|
|
28977
|
-
"approved_vendor"
|
|
28978
|
-
]);
|
|
28979
|
-
var marketplaceBadgeSchema = external_exports.looseObject({
|
|
28980
|
-
code: marketplaceBadgeCodeSchema,
|
|
28981
|
-
label: external_exports.string().trim().min(1).max(80)
|
|
28982
|
-
});
|
|
28983
|
-
var marketplacePublicFactSchema = external_exports.looseObject({
|
|
28984
|
-
label: external_exports.string().trim().min(1).max(80),
|
|
28985
|
-
value: external_exports.string().trim().min(1).max(160)
|
|
28986
|
-
});
|
|
28987
|
-
var marketplaceHrefSchema = external_exports.union([
|
|
28988
|
-
external_exports.string().trim().min(1).max(2048).regex(/^\/(?!\/)/),
|
|
28989
|
-
external_exports.url().max(2048).regex(/^https:\/\//)
|
|
28990
|
-
]);
|
|
28991
|
-
var marketplaceCardSchema = external_exports.looseObject({
|
|
28992
|
-
title: external_exports.string().trim().min(1).max(160),
|
|
28993
|
-
summary: external_exports.string().trim().min(1).max(1e3),
|
|
28994
|
-
byline: external_exports.string().trim().min(1).max(160).optional(),
|
|
28995
|
-
bylineHref: marketplaceHrefSchema.optional(),
|
|
28996
|
-
badges: external_exports.array(marketplaceBadgeSchema).max(8),
|
|
28997
|
-
facts: external_exports.array(marketplacePublicFactSchema).max(12)
|
|
28998
|
-
});
|
|
28999
|
-
var marketplaceHitBase = {
|
|
29000
|
-
ref: external_exports.string().trim().min(1).max(512),
|
|
29001
|
-
card: marketplaceCardSchema,
|
|
29002
|
-
...listingDisclosureShape
|
|
29003
|
-
};
|
|
29004
|
-
var invokeApiActionSchema = external_exports.looseObject({
|
|
29005
|
-
type: external_exports.literal("invoke_api"),
|
|
29006
|
-
href: marketplaceHrefSchema
|
|
29007
|
-
});
|
|
29008
|
-
var firstPartyApiMarketplaceHitSchema = external_exports.looseObject({
|
|
29009
|
-
...marketplaceHitBase,
|
|
29010
|
-
kind: external_exports.literal("api"),
|
|
29011
|
-
provenance: firstPartyProvenanceSchema,
|
|
29012
|
-
execution: external_exports.looseObject({
|
|
29013
|
-
mode: executionModeSchema
|
|
29014
|
-
}),
|
|
29015
|
-
action: invokeApiActionSchema
|
|
29016
|
-
});
|
|
29017
|
-
var mirroredApiMarketplaceHitSchema = external_exports.looseObject({
|
|
29018
|
-
...marketplaceHitBase,
|
|
29019
|
-
kind: external_exports.literal("api"),
|
|
29020
|
-
provenance: external_exports.literal("indexed"),
|
|
29021
|
-
execution: external_exports.looseObject({
|
|
29022
|
-
mode: external_exports.literal("direct"),
|
|
29023
|
-
url: external_exports.url().max(2048).regex(/^https:\/\/(?![^/?#]*@)/),
|
|
29024
|
-
method: marketplaceExecutionMethodSchema.nullable(),
|
|
29025
|
-
network: external_exports.string().trim().max(160).regex(/^eip155:[1-9]\d*$/)
|
|
29026
|
-
}),
|
|
29027
|
-
action: invokeApiActionSchema
|
|
29028
|
-
});
|
|
29029
|
-
var apiMarketplaceHitSchema = external_exports.discriminatedUnion("provenance", [
|
|
29030
|
-
firstPartyApiMarketplaceHitSchema,
|
|
29031
|
-
mirroredApiMarketplaceHitSchema
|
|
29032
|
-
]);
|
|
29033
|
-
var serviceOfferMarketplaceHitSchema = external_exports.looseObject({
|
|
29034
|
-
...marketplaceHitBase,
|
|
29035
|
-
kind: external_exports.literal("service_offer"),
|
|
29036
|
-
action: external_exports.looseObject({
|
|
29037
|
-
type: external_exports.literal("start_engagement"),
|
|
29038
|
-
href: marketplaceHrefSchema
|
|
29039
|
-
})
|
|
29040
|
-
});
|
|
29041
|
-
var openRequestMarketplaceHitSchema = external_exports.looseObject({
|
|
29042
|
-
...marketplaceHitBase,
|
|
29043
|
-
kind: external_exports.literal("open_request"),
|
|
29044
|
-
action: external_exports.looseObject({
|
|
29045
|
-
type: external_exports.literal("propose_to_request"),
|
|
29046
|
-
href: marketplaceHrefSchema
|
|
29047
|
-
})
|
|
29048
|
-
});
|
|
29049
|
-
var marketplaceHitSchema = external_exports.union([
|
|
29050
|
-
apiMarketplaceHitSchema,
|
|
29051
|
-
serviceOfferMarketplaceHitSchema,
|
|
29052
|
-
openRequestMarketplaceHitSchema
|
|
29053
|
-
]);
|
|
29054
|
-
var marketplaceDiscoveryInputSchema = external_exports.strictObject({
|
|
29055
|
-
q: external_exports.string().trim().max(200).optional(),
|
|
29056
|
-
kinds: external_exports.array(marketplaceKindSchema).min(1).max(MARKETPLACE_KINDS.length).optional(),
|
|
29057
|
-
network: external_exports.string().trim().min(1).max(160).optional(),
|
|
29058
|
-
cursor: external_exports.string().trim().min(1).max(4096).optional(),
|
|
29059
|
-
limit: external_exports.number().int().min(1).max(50).optional(),
|
|
29060
|
-
includeUnverified: external_exports.boolean().optional()
|
|
29061
|
-
}).superRefine((input2, context) => {
|
|
29062
|
-
if (input2.kinds && new Set(input2.kinds).size !== input2.kinds.length) {
|
|
29063
|
-
context.addIssue({
|
|
29064
|
-
code: "custom",
|
|
29065
|
-
path: ["kinds"],
|
|
29066
|
-
message: "Marketplace kinds must be unique"
|
|
29067
|
-
});
|
|
29068
|
-
}
|
|
29069
|
-
});
|
|
29070
|
-
function isMirroredHit(hit) {
|
|
29071
|
-
return hit.kind === "api" && hit.provenance === "indexed";
|
|
29072
|
-
}
|
|
29073
|
-
var marketplaceDiscoveryPageSchema = external_exports.looseObject({
|
|
29074
|
-
protocol: external_exports.literal(MARKETPLACE_DISCOVERY_PROTOCOL),
|
|
29075
|
-
items: external_exports.array(marketplaceHitSchema),
|
|
29076
|
-
nextCursor: external_exports.string().min(1).max(4096).nullable(),
|
|
29077
|
-
unavailableKinds: external_exports.array(marketplaceKindSchema).max(MARKETPLACE_KINDS.length),
|
|
29078
|
-
rankingVersion: external_exports.literal(MARKETPLACE_RANKING_VERSION)
|
|
29079
|
-
});
|
|
29080
|
-
|
|
29081
|
-
// src/call-contracts-wire.ts
|
|
29082
|
-
var CALLABLE_KIND = "agent";
|
|
29083
|
-
var CALLABLE_CATEGORIES = ["ai", "data", "crypto", "compute", "search"];
|
|
29084
|
-
var callableCategorySchema = external_exports.enum(CALLABLE_CATEGORIES);
|
|
29085
|
-
var DISCOVERY_CATEGORIES = [...CALLABLE_CATEGORIES, "other"];
|
|
29086
|
-
var discoveryCategorySchema = external_exports.enum(DISCOVERY_CATEGORIES);
|
|
29087
|
-
var CALLABLE_CATEGORY_LABELS = {
|
|
29088
|
-
ai: { catalog: "AI / LLM", publish: "AI and models" },
|
|
29089
|
-
data: { catalog: "Data", publish: "Data" },
|
|
29090
|
-
crypto: { catalog: "Crypto", publish: "Crypto" },
|
|
29091
|
-
compute: { catalog: "Compute", publish: "Compute" },
|
|
29092
|
-
search: { catalog: "Search", publish: "Search" }
|
|
29093
|
-
};
|
|
29094
|
-
var CALLABLE_CATEGORY_SET = new Set(CALLABLE_CATEGORIES);
|
|
29095
|
-
function isCallableListing(kind, category) {
|
|
29096
|
-
return kind === CALLABLE_KIND && CALLABLE_CATEGORY_SET.has(category);
|
|
29097
|
-
}
|
|
29098
|
-
var serviceTierSchema = external_exports.enum(["listed", "verified", "partner"]);
|
|
29099
|
-
var discoveryEndpointSchema = external_exports.looseObject({
|
|
29100
|
-
name: external_exports.string(),
|
|
29101
|
-
method: external_exports.string(),
|
|
29102
|
-
url: external_exports.url(),
|
|
29103
|
-
price: external_exports.string(),
|
|
29104
|
-
description: external_exports.string(),
|
|
29105
|
-
operationId: external_exports.string().trim().min(1).optional(),
|
|
29106
|
-
requestContentType: external_exports.string().trim().min(1).optional(),
|
|
29107
|
-
requestSchema: external_exports.json().optional(),
|
|
29108
|
-
responseContentType: external_exports.string().trim().min(1).optional(),
|
|
29109
|
-
pathTemplate: external_exports.string().trim().min(1).optional(),
|
|
29110
|
-
pathParameters: external_exports.array(external_exports.string().trim().min(1)).optional(),
|
|
29111
|
-
payment: external_exports.looseObject({
|
|
29112
|
-
scheme: external_exports.literal("exact"),
|
|
29113
|
-
network: external_exports.string().regex(/^eip155:\d+$/),
|
|
29114
|
-
asset: external_exports.string().regex(/^0x[0-9a-fA-F]{40}$/),
|
|
29115
|
-
payTo: external_exports.string().regex(/^0x[0-9a-fA-F]{40}$/),
|
|
29116
|
-
checkedAt: external_exports.iso.datetime()
|
|
29117
|
-
}).optional()
|
|
29118
|
-
});
|
|
29119
|
-
var serviceSummarySchema = external_exports.looseObject({
|
|
29120
|
-
id: external_exports.string(),
|
|
29121
|
-
name: external_exports.string(),
|
|
29122
|
-
description: external_exports.string(),
|
|
29123
|
-
category: discoveryCategorySchema,
|
|
29124
|
-
tier: serviceTierSchema,
|
|
29125
|
-
...listingDisclosureShape,
|
|
29126
|
-
verified: external_exports.boolean(),
|
|
29127
|
-
wrapped: external_exports.boolean(),
|
|
29128
|
-
price: external_exports.string(),
|
|
29129
|
-
networks: external_exports.array(external_exports.string()),
|
|
29130
|
-
endpoints: external_exports.array(discoveryEndpointSchema)
|
|
29131
|
-
});
|
|
29132
|
-
var searchServicesResponseSchema = external_exports.looseObject({
|
|
29133
|
-
services: external_exports.array(serviceSummarySchema)
|
|
29134
|
-
});
|
|
29135
|
-
var listServicesResponseSchema = searchServicesResponseSchema;
|
|
29136
|
-
var discoveryServiceSchema = serviceSummarySchema;
|
|
29137
|
-
var discoveryResponseSchema = searchServicesResponseSchema;
|
|
29138
|
-
|
|
29139
|
-
// src/call-contracts.ts
|
|
29140
|
-
var DiscoveryCatalogError = class extends Error {
|
|
29141
|
-
name = "DiscoveryCatalogError";
|
|
29142
|
-
code;
|
|
29143
|
-
serviceId;
|
|
29144
|
-
constructor(code, message, serviceId) {
|
|
29145
|
-
super(message);
|
|
29146
|
-
this.code = code;
|
|
29147
|
-
this.serviceId = serviceId;
|
|
29148
|
-
}
|
|
29149
|
-
};
|
|
29150
|
-
function parseDiscovery(raw) {
|
|
29151
|
-
const parsed = discoveryResponseSchema.safeParse(raw);
|
|
29152
|
-
if (!parsed.success) {
|
|
29153
|
-
const malformedUrl = parsed.error.issues.find(
|
|
29154
|
-
(issue2) => issue2.path.at(-1) === "url" && issue2.path.includes("endpoints")
|
|
29155
|
-
);
|
|
29156
|
-
if (malformedUrl) {
|
|
29157
|
-
const serviceIndex = pathIndexAfter(malformedUrl.path, "services");
|
|
29158
|
-
const serviceId = rawServiceId(raw, serviceIndex);
|
|
29159
|
-
throw new DiscoveryCatalogError(
|
|
29160
|
-
"malformed_url",
|
|
29161
|
-
`Service ${JSON.stringify(serviceId ?? "unknown")} has a malformed endpoint URL.`,
|
|
29162
|
-
serviceId
|
|
29163
|
-
);
|
|
29164
|
-
}
|
|
29165
|
-
throw new DiscoveryCatalogError("invalid_discovery", "Discovery response is malformed.");
|
|
29166
|
-
}
|
|
29167
|
-
for (const service of parsed.data.services) {
|
|
29168
|
-
buildTargets(service);
|
|
29169
|
-
}
|
|
29170
|
-
const resolveListing = (serviceId, endpointName) => {
|
|
29171
|
-
const service = parsed.data.services.find((candidate) => candidate.id === serviceId);
|
|
29172
|
-
if (!service) {
|
|
29173
|
-
throw new DiscoveryCatalogError(
|
|
29174
|
-
"service_not_found",
|
|
29175
|
-
`No payable endpoint found for service ${JSON.stringify(serviceId)}.`,
|
|
29176
|
-
serviceId
|
|
29177
|
-
);
|
|
29178
|
-
}
|
|
29179
|
-
return { service, endpoint: resolveTarget(service, endpointName) };
|
|
29180
|
-
};
|
|
29181
|
-
return {
|
|
29182
|
-
services: parsed.data.services,
|
|
29183
|
-
resolve: (serviceId, endpointName) => resolveListing(serviceId, endpointName).endpoint,
|
|
29184
|
-
resolveListing
|
|
29185
|
-
};
|
|
29186
|
-
}
|
|
29187
|
-
function resolveTarget(service, endpointName) {
|
|
29188
|
-
const { targets, targetsByName } = buildTargets(service);
|
|
29189
|
-
if (endpointName !== void 0) {
|
|
29190
|
-
const selected = targetsByName.get(endpointName.trim());
|
|
29191
|
-
if (!selected) {
|
|
29192
|
-
throw new DiscoveryCatalogError(
|
|
29193
|
-
"endpoint_not_found",
|
|
29194
|
-
`Service ${JSON.stringify(service.id)} has no endpoint ${JSON.stringify(endpointName)}. Available endpoints: ${[...targetsByName.keys()].join(", ")}.`,
|
|
29195
|
-
service.id
|
|
29196
|
-
);
|
|
29197
|
-
}
|
|
29198
|
-
return { ...selected };
|
|
29199
|
-
}
|
|
29200
|
-
if (targets.size !== 1) {
|
|
29201
|
-
throw new DiscoveryCatalogError(
|
|
29202
|
-
"ambiguous_default",
|
|
29203
|
-
`Service ${JSON.stringify(service.id)} has ${targets.size} distinct payable endpoints. Choose one with endpoint: ${[...targetsByName.keys()].join(", ")}.`,
|
|
29204
|
-
service.id
|
|
29205
|
-
);
|
|
29206
|
-
}
|
|
29207
|
-
return targets.values().next().value;
|
|
29208
|
-
}
|
|
29209
|
-
function buildTargets(service) {
|
|
29210
|
-
if (service.endpoints.length === 0) {
|
|
29211
|
-
throw new DiscoveryCatalogError(
|
|
29212
|
-
"no_endpoint",
|
|
29213
|
-
`Service ${JSON.stringify(service.id)} has no payable endpoint.`,
|
|
29214
|
-
service.id
|
|
29215
|
-
);
|
|
29216
|
-
}
|
|
29217
|
-
const namedEndpoints = [...service.endpoints].sort(
|
|
29218
|
-
(left, right) => compareNames(left.name.trim(), right.name.trim())
|
|
29219
|
-
);
|
|
29220
|
-
const names = /* @__PURE__ */ new Set();
|
|
29221
|
-
const targets = /* @__PURE__ */ new Map();
|
|
29222
|
-
const targetsByName = /* @__PURE__ */ new Map();
|
|
29223
|
-
for (const endpoint of namedEndpoints) {
|
|
29224
|
-
const name = endpoint.name.trim();
|
|
29225
|
-
if (!name) {
|
|
29226
|
-
throw new DiscoveryCatalogError(
|
|
29227
|
-
"invalid_endpoint_name",
|
|
29228
|
-
`Service ${JSON.stringify(service.id)} has a blank endpoint name.`,
|
|
29229
|
-
service.id
|
|
29230
|
-
);
|
|
29231
|
-
}
|
|
29232
|
-
if (names.has(name)) {
|
|
29233
|
-
throw new DiscoveryCatalogError(
|
|
29234
|
-
"duplicate_endpoint_name",
|
|
29235
|
-
`Service ${JSON.stringify(service.id)} has duplicate endpoint name ${JSON.stringify(name)}.`,
|
|
29236
|
-
service.id
|
|
29237
|
-
);
|
|
29238
|
-
}
|
|
29239
|
-
names.add(name);
|
|
29240
|
-
const method = endpoint.method.trim().toUpperCase();
|
|
29241
|
-
if (!method) {
|
|
29242
|
-
throw new DiscoveryCatalogError(
|
|
29243
|
-
"blank_method",
|
|
29244
|
-
`Service ${JSON.stringify(service.id)} has a blank endpoint method.`,
|
|
29245
|
-
service.id
|
|
29246
|
-
);
|
|
29247
|
-
}
|
|
29248
|
-
const url2 = new URL(endpoint.url);
|
|
29249
|
-
if (url2.protocol !== "http:" && url2.protocol !== "https:") {
|
|
29250
|
-
throw new DiscoveryCatalogError(
|
|
29251
|
-
"malformed_url",
|
|
29252
|
-
`Service ${JSON.stringify(service.id)} has a non-HTTP endpoint URL.`,
|
|
29253
|
-
service.id
|
|
29254
|
-
);
|
|
29255
|
-
}
|
|
29256
|
-
const transportKey = `${method}\0${endpoint.url}`;
|
|
29257
|
-
const normalized = { ...endpoint, name, method };
|
|
29258
|
-
targetsByName.set(name, normalized);
|
|
29259
|
-
if (!targets.has(transportKey)) targets.set(transportKey, normalized);
|
|
29260
|
-
}
|
|
29261
|
-
return { targets, targetsByName };
|
|
29262
|
-
}
|
|
29263
|
-
function compareNames(left, right) {
|
|
29264
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
29265
|
-
}
|
|
29266
|
-
function pathIndexAfter(path, key) {
|
|
29267
|
-
const keyIndex = path.indexOf(key);
|
|
29268
|
-
const candidate = path[keyIndex + 1];
|
|
29269
|
-
return typeof candidate === "number" ? candidate : void 0;
|
|
29270
|
-
}
|
|
29271
|
-
function rawServiceId(raw, serviceIndex) {
|
|
29272
|
-
if (serviceIndex === void 0 || typeof raw !== "object" || raw === null) {
|
|
29273
|
-
return void 0;
|
|
29274
|
-
}
|
|
29275
|
-
const services = Reflect.get(raw, "services");
|
|
29276
|
-
if (!Array.isArray(services)) {
|
|
29277
|
-
return void 0;
|
|
29278
|
-
}
|
|
29279
|
-
const service = services[serviceIndex];
|
|
29280
|
-
if (typeof service !== "object" || service === null) {
|
|
29281
|
-
return void 0;
|
|
29282
|
-
}
|
|
29283
|
-
const id = Reflect.get(service, "id");
|
|
29284
|
-
return typeof id === "string" ? id : void 0;
|
|
29285
|
-
}
|
|
29286
|
-
|
|
29287
28915
|
// ../../node_modules/.pnpm/viem@2.56.1_typescript@6.0.3_zod@4.5.4/node_modules/viem/_esm/utils/getAction.js
|
|
29288
28916
|
function getAction(client, actionFn, name) {
|
|
29289
28917
|
const action_implicit = client[actionFn.name];
|
|
@@ -39084,6 +38712,7 @@ var ARC_MAINNET_CAIP2 = "eip155:5042";
|
|
|
39084
38712
|
var ARC_TESTNET_CAIP2 = "eip155:5042002";
|
|
39085
38713
|
var SOLANA_MAINNET_CAIP2 = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d";
|
|
39086
38714
|
var X402_SOLANA_MAINNET_CAIP2 = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
38715
|
+
var SOLANA_DEVNET_CAIP2 = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";
|
|
39087
38716
|
var SOLANA_MAINNET_USDC = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
39088
38717
|
function canonicalIdentity(usdc, eip712Domain) {
|
|
39089
38718
|
return Object.freeze({
|
|
@@ -39127,375 +38756,194 @@ var BROWSER_ENABLED_X402_NETWORK_CONFIG = Object.freeze({
|
|
|
39127
38756
|
[ARC_TESTNET_CAIP2]: browserNetwork(arcTestnetUsdc)
|
|
39128
38757
|
});
|
|
39129
38758
|
|
|
39130
|
-
// src/
|
|
39131
|
-
|
|
39132
|
-
|
|
39133
|
-
|
|
39134
|
-
|
|
39135
|
-
|
|
39136
|
-
|
|
39137
|
-
|
|
39138
|
-
|
|
38759
|
+
// src/marketplace-contracts.ts
|
|
38760
|
+
var MARKETPLACE_DISCOVERY_PROTOCOL = "vapi.marketplace.discovery/1";
|
|
38761
|
+
var MARKETPLACE_RANKING_VERSION = "marketplace-ranking-v1";
|
|
38762
|
+
var MARKETPLACE_KINDS = ["api", "service_offer", "open_request"];
|
|
38763
|
+
var MARKETPLACE_EXECUTION_METHODS = [
|
|
38764
|
+
"GET",
|
|
38765
|
+
"HEAD",
|
|
38766
|
+
"POST",
|
|
38767
|
+
"PUT",
|
|
38768
|
+
"PATCH",
|
|
38769
|
+
"DELETE"
|
|
38770
|
+
];
|
|
38771
|
+
var marketplaceExecutionMethodSchema = external_exports.enum(MARKETPLACE_EXECUTION_METHODS);
|
|
38772
|
+
var marketplaceKindSchema = external_exports.enum(MARKETPLACE_KINDS);
|
|
38773
|
+
var EXECUTION_MODES = ["direct", "gateway"];
|
|
38774
|
+
var executionModeSchema = external_exports.enum(EXECUTION_MODES);
|
|
38775
|
+
var PROVENANCES = ["indexed", "self_listed", "partner"];
|
|
38776
|
+
var provenanceSchema = external_exports.enum(PROVENANCES);
|
|
38777
|
+
var FIRST_PARTY_PROVENANCES = ["self_listed", "partner"];
|
|
38778
|
+
var firstPartyProvenanceSchema = external_exports.enum(FIRST_PARTY_PROVENANCES);
|
|
38779
|
+
var LISTING_GROUPS = ["vapi", "added", "partner", "external"];
|
|
38780
|
+
var listingGroupSchema = external_exports.enum(LISTING_GROUPS);
|
|
38781
|
+
var listingFeeSchema = external_exports.looseObject({
|
|
38782
|
+
bps: external_exports.number().int().min(0),
|
|
38783
|
+
label: external_exports.string()
|
|
38784
|
+
});
|
|
38785
|
+
var LISTING_VERIFICATIONS = ["none", "requested", "verified"];
|
|
38786
|
+
var listingVerificationSchema = external_exports.enum(LISTING_VERIFICATIONS);
|
|
38787
|
+
var listingVerificationFieldSchema = listingVerificationSchema.default("none").catch("none");
|
|
38788
|
+
var listingLivenessSchema = external_exports.looseObject({
|
|
38789
|
+
uptime7d: external_exports.number().min(0).max(1),
|
|
38790
|
+
latencyP50Ms: external_exports.number().nonnegative().nullable(),
|
|
38791
|
+
latencyP95Ms: external_exports.number().nonnegative().nullable(),
|
|
38792
|
+
checks7d: external_exports.number().int().nonnegative()
|
|
38793
|
+
});
|
|
38794
|
+
var listingConformanceSchema = external_exports.looseObject({
|
|
38795
|
+
declaredVersion: external_exports.union([external_exports.literal(1), external_exports.literal(2)]).nullable(),
|
|
38796
|
+
versionConformant: external_exports.boolean(),
|
|
38797
|
+
offerTransport: external_exports.enum(["body", "header", "both"]),
|
|
38798
|
+
issues: external_exports.array(external_exports.string())
|
|
38799
|
+
});
|
|
38800
|
+
var listingIdentitySchema = external_exports.looseObject({
|
|
38801
|
+
erc8004Id: external_exports.string().trim().min(1),
|
|
38802
|
+
reputation: external_exports.looseObject({
|
|
38803
|
+
score: external_exports.number().finite(),
|
|
38804
|
+
count: external_exports.number().int().nonnegative()
|
|
38805
|
+
}).optional().catch(void 0)
|
|
38806
|
+
});
|
|
38807
|
+
var listingDisclosureShape = {
|
|
38808
|
+
// Presentation metadata must not make an otherwise executable row vanish
|
|
38809
|
+
// when the registry adds a new group or changes the fee display shape.
|
|
38810
|
+
group: listingGroupSchema.optional().catch(void 0),
|
|
38811
|
+
fee: listingFeeSchema.optional().catch(void 0),
|
|
38812
|
+
verification: listingVerificationFieldSchema,
|
|
38813
|
+
liveness: listingLivenessSchema.optional().catch(void 0),
|
|
38814
|
+
conformance: listingConformanceSchema.optional().catch(void 0),
|
|
38815
|
+
identity: listingIdentitySchema.optional().catch(void 0)
|
|
39139
38816
|
};
|
|
39140
|
-
|
|
39141
|
-
|
|
39142
|
-
|
|
39143
|
-
|
|
39144
|
-
|
|
39145
|
-
|
|
39146
|
-
|
|
39147
|
-
|
|
39148
|
-
|
|
39149
|
-
|
|
39150
|
-
|
|
39151
|
-
|
|
39152
|
-
|
|
39153
|
-
|
|
39154
|
-
|
|
39155
|
-
|
|
39156
|
-
|
|
39157
|
-
|
|
39158
|
-
|
|
39159
|
-
|
|
39160
|
-
|
|
39161
|
-
|
|
39162
|
-
|
|
39163
|
-
|
|
39164
|
-
|
|
39165
|
-
|
|
39166
|
-
|
|
39167
|
-
|
|
39168
|
-
|
|
39169
|
-
|
|
39170
|
-
|
|
39171
|
-
|
|
39172
|
-
|
|
39173
|
-
|
|
39174
|
-
|
|
39175
|
-
|
|
39176
|
-
|
|
39177
|
-
|
|
39178
|
-
|
|
39179
|
-
|
|
39180
|
-
lookup: lookupFn,
|
|
39181
|
-
timeoutMs: 5e3
|
|
39182
|
-
});
|
|
39183
|
-
const normalized = new Request(input2, init);
|
|
39184
|
-
const bytes = normalized.body ? Buffer.from(await normalized.arrayBuffer()) : null;
|
|
39185
|
-
return await new Promise((resolve2, reject) => {
|
|
39186
|
-
const requestOptions = {
|
|
39187
|
-
method: normalized.method,
|
|
39188
|
-
headers: Object.fromEntries(normalized.headers),
|
|
39189
|
-
signal: normalized.signal,
|
|
39190
|
-
...options.allowPrivateNetwork ? {} : { lookup: pinnedLookup(lookupFn) }
|
|
39191
|
-
};
|
|
39192
|
-
const onResponse = (incoming) => {
|
|
39193
|
-
try {
|
|
39194
|
-
const headers = new Headers();
|
|
39195
|
-
for (const [name, value] of Object.entries(incoming.headers)) {
|
|
39196
|
-
if (Array.isArray(value)) {
|
|
39197
|
-
for (const item of value) headers.append(name, item);
|
|
39198
|
-
} else if (value !== void 0) {
|
|
39199
|
-
headers.set(name, value);
|
|
39200
|
-
}
|
|
39201
|
-
}
|
|
39202
|
-
const status = incoming.statusCode ?? 500;
|
|
39203
|
-
const bodyForbidden = normalized.method === "HEAD" || [204, 205, 304].includes(status);
|
|
39204
|
-
if (bodyForbidden) incoming.resume();
|
|
39205
|
-
const response = new Response(
|
|
39206
|
-
bodyForbidden ? null : Readable.toWeb(incoming),
|
|
39207
|
-
{ status, statusText: incoming.statusMessage, headers }
|
|
39208
|
-
);
|
|
39209
|
-
Object.defineProperty(response, "url", { value: url2.toString() });
|
|
39210
|
-
resolve2(response);
|
|
39211
|
-
} catch (error61) {
|
|
39212
|
-
incoming.destroy();
|
|
39213
|
-
reject(error61);
|
|
39214
|
-
}
|
|
39215
|
-
};
|
|
39216
|
-
const request = url2.protocol === "https:" ? httpsRequest(url2, requestOptions, onResponse) : httpRequest(url2, requestOptions, onResponse);
|
|
39217
|
-
request.on("error", reject);
|
|
39218
|
-
if (bytes) request.write(bytes);
|
|
39219
|
-
request.end();
|
|
39220
|
-
});
|
|
39221
|
-
});
|
|
39222
|
-
}
|
|
39223
|
-
function pinnedLookup(lookup) {
|
|
39224
|
-
return (hostname3, dnsOptions, callback) => {
|
|
39225
|
-
void lookup(normalizeHostname(hostname3)).then((addresses) => {
|
|
39226
|
-
if (addresses.length === 0 || addresses.some(isNonPublicAddress)) {
|
|
39227
|
-
callback(guardError(new URL(`https://${hostname3}`)), "");
|
|
39228
|
-
return;
|
|
39229
|
-
}
|
|
39230
|
-
const address2 = addresses[0];
|
|
39231
|
-
const family = isIP(address2);
|
|
39232
|
-
callback(
|
|
39233
|
-
null,
|
|
39234
|
-
dnsOptions.all ? [{ address: address2, family }] : address2,
|
|
39235
|
-
dnsOptions.all ? void 0 : family
|
|
39236
|
-
);
|
|
39237
|
-
}).catch(
|
|
39238
|
-
(error61) => callback(error61 instanceof Error ? error61 : new Error("DNS lookup failed."), "")
|
|
39239
|
-
);
|
|
39240
|
-
};
|
|
39241
|
-
}
|
|
39242
|
-
async function withTimeout2(operation, timeoutMs) {
|
|
39243
|
-
let timeout;
|
|
39244
|
-
try {
|
|
39245
|
-
return await Promise.race([
|
|
39246
|
-
operation,
|
|
39247
|
-
new Promise((_resolve, reject) => {
|
|
39248
|
-
timeout = setTimeout(() => reject(new Error("DNS lookup timed out.")), timeoutMs);
|
|
39249
|
-
})
|
|
39250
|
-
]);
|
|
39251
|
-
} finally {
|
|
39252
|
-
if (timeout) clearTimeout(timeout);
|
|
39253
|
-
}
|
|
39254
|
-
}
|
|
39255
|
-
function normalizeHostname(hostname3) {
|
|
39256
|
-
const unbracketed = hostname3.startsWith("[") && hostname3.endsWith("]") ? hostname3.slice(1, -1) : hostname3;
|
|
39257
|
-
return unbracketed.endsWith(".") ? unbracketed.slice(0, -1) : unbracketed;
|
|
39258
|
-
}
|
|
39259
|
-
function isNonPublicAddress(address2) {
|
|
39260
|
-
const normalized = normalizeHostname(address2);
|
|
39261
|
-
const version5 = isIP(normalized);
|
|
39262
|
-
if (version5 === 4) {
|
|
39263
|
-
return isNonPublicIpv4(parseIpv4(normalized));
|
|
39264
|
-
}
|
|
39265
|
-
if (version5 === 6) {
|
|
39266
|
-
return isNonPublicIpv6(parseIpv6(normalized));
|
|
39267
|
-
}
|
|
39268
|
-
return true;
|
|
39269
|
-
}
|
|
39270
|
-
function parseIpv4(address2) {
|
|
39271
|
-
const octets = address2.split(".").map(Number);
|
|
39272
|
-
return [octets[0], octets[1], octets[2], octets[3]];
|
|
39273
|
-
}
|
|
39274
|
-
function isNonPublicIpv4([first, second, third]) {
|
|
39275
|
-
return first === 0 || first === 10 || first === 100 && second >= 64 && second <= 127 || first === 127 || first === 169 && second === 254 || first === 172 && second >= 16 && second <= 31 || first === 192 && second === 0 && (third === 0 || third === 2) || first === 192 && second === 168 || first === 198 && second >= 18 && second <= 19 || first === 198 && second === 51 && third === 100 || first === 203 && second === 0 && third === 113 || first >= 224;
|
|
39276
|
-
}
|
|
39277
|
-
function parseIpv6(address2) {
|
|
39278
|
-
let normalized = address2.toLowerCase();
|
|
39279
|
-
const lastColon = normalized.lastIndexOf(":");
|
|
39280
|
-
const dottedTail = normalized.slice(lastColon + 1);
|
|
39281
|
-
if (dottedTail.includes(".")) {
|
|
39282
|
-
const [first, second, third, fourth] = parseIpv4(dottedTail);
|
|
39283
|
-
normalized = `${normalized.slice(0, lastColon + 1)}${(first << 8 | second).toString(16)}:${(third << 8 | fourth).toString(16)}`;
|
|
39284
|
-
}
|
|
39285
|
-
const halves = normalized.split("::");
|
|
39286
|
-
const left = halves[0] ? halves[0].split(":").map(parseHex) : [];
|
|
39287
|
-
const right = halves[1] ? halves[1].split(":").map(parseHex) : [];
|
|
39288
|
-
const omittedCount = 8 - left.length - right.length;
|
|
39289
|
-
return halves.length === 2 ? [...left, ...Array.from({ length: omittedCount }, () => 0), ...right] : left;
|
|
39290
|
-
}
|
|
39291
|
-
function parseHex(value) {
|
|
39292
|
-
return Number.parseInt(value, 16);
|
|
39293
|
-
}
|
|
39294
|
-
function isNonPublicIpv6(hextets) {
|
|
39295
|
-
if (hextets.slice(0, 5).every((hextet) => hextet === 0) && hextets[5] === 65535) {
|
|
39296
|
-
const embeddedIpv4 = [
|
|
39297
|
-
hextets[6] >> 8,
|
|
39298
|
-
hextets[6] & 255,
|
|
39299
|
-
hextets[7] >> 8,
|
|
39300
|
-
hextets[7] & 255
|
|
39301
|
-
];
|
|
39302
|
-
return isNonPublicIpv4(embeddedIpv4);
|
|
39303
|
-
}
|
|
39304
|
-
if (hextets.slice(0, 6).every((hextet) => hextet === 0)) {
|
|
39305
|
-
const compatibleIpv4 = [
|
|
39306
|
-
hextets[6] >> 8,
|
|
39307
|
-
hextets[6] & 255,
|
|
39308
|
-
hextets[7] >> 8,
|
|
39309
|
-
hextets[7] & 255
|
|
39310
|
-
];
|
|
39311
|
-
if (isNonPublicIpv4(compatibleIpv4)) return true;
|
|
39312
|
-
}
|
|
39313
|
-
const isUnspecified = hextets.every((hextet) => hextet === 0);
|
|
39314
|
-
const isLoopback = hextets.slice(0, 7).every((hextet) => hextet === 0) && hextets[7] === 1;
|
|
39315
|
-
const first = hextets[0];
|
|
39316
|
-
const isUniqueLocal = first >= 64512 && first <= 65023;
|
|
39317
|
-
const isLinkLocal = first >= 65152 && first <= 65215;
|
|
39318
|
-
const isSiteLocal = first >= 65216 && first <= 65279;
|
|
39319
|
-
const isMulticast = first >= 65280;
|
|
39320
|
-
const isDocumentation = first === 8193 && hextets[1] === 3512;
|
|
39321
|
-
return isUnspecified || isLoopback || isUniqueLocal || isLinkLocal || isSiteLocal || isMulticast || isDocumentation;
|
|
39322
|
-
}
|
|
39323
|
-
function guardError(url2) {
|
|
39324
|
-
return new Error(
|
|
39325
|
-
`URL hostname ${JSON.stringify(url2.hostname)} is not allowed; private or internal destinations require allowPrivateNetwork true in the vAPI config.`
|
|
39326
|
-
);
|
|
39327
|
-
}
|
|
39328
|
-
|
|
39329
|
-
// src/networks.ts
|
|
39330
|
-
var USDC_DECIMALS = 6;
|
|
39331
|
-
var DEFAULT_ARC_GAS_HEADROOM_ATOMIC = 50000n;
|
|
39332
|
-
var NETWORKS = {
|
|
39333
|
-
[BASE_MAINNET_CAIP2]: {
|
|
39334
|
-
family: "evm",
|
|
39335
|
-
chainId: 8453,
|
|
39336
|
-
name: "Base mainnet",
|
|
39337
|
-
usdc: CANONICAL_X402_USDC_NETWORKS[BASE_MAINNET_CAIP2].usdc,
|
|
39338
|
-
gasToken: "ETH",
|
|
39339
|
-
rpcEnv: "BASE_RPC_URL",
|
|
39340
|
-
publicRpcUrl: "https://mainnet.base.org",
|
|
39341
|
-
explorerUrl: "https://basescan.org"
|
|
39342
|
-
},
|
|
39343
|
-
[ARC_MAINNET_CAIP2]: {
|
|
39344
|
-
family: "evm",
|
|
39345
|
-
chainId: 5042,
|
|
39346
|
-
name: "Arc mainnet",
|
|
39347
|
-
usdc: CANONICAL_X402_USDC_NETWORKS[ARC_MAINNET_CAIP2].usdc,
|
|
39348
|
-
gasToken: "USDC",
|
|
39349
|
-
rpcEnv: "ARC_RPC_URL",
|
|
39350
|
-
publicRpcUrl: "https://rpc.mainnet.arc.io",
|
|
39351
|
-
explorerUrl: "https://explorer.arc.io"
|
|
39352
|
-
},
|
|
39353
|
-
[ARC_TESTNET_CAIP2]: {
|
|
39354
|
-
family: "evm",
|
|
39355
|
-
chainId: 5042002,
|
|
39356
|
-
name: "Arc testnet",
|
|
39357
|
-
usdc: CANONICAL_X402_USDC_NETWORKS[ARC_TESTNET_CAIP2].usdc,
|
|
39358
|
-
gasToken: "USDC",
|
|
39359
|
-
rpcEnv: "ARC_TESTNET_RPC_URL"
|
|
39360
|
-
},
|
|
39361
|
-
[SOLANA_MAINNET_CAIP2]: {
|
|
39362
|
-
family: "svm",
|
|
39363
|
-
name: "Solana mainnet",
|
|
39364
|
-
usdc: SOLANA_MAINNET_USDC,
|
|
39365
|
-
gasToken: "SOL",
|
|
39366
|
-
rpcEnv: "SOLANA_RPC_URL",
|
|
39367
|
-
publicRpcUrl: "https://api.mainnet-beta.solana.com"
|
|
39368
|
-
},
|
|
39369
|
-
[X402_SOLANA_MAINNET_CAIP2]: {
|
|
39370
|
-
family: "svm",
|
|
39371
|
-
name: "Solana mainnet",
|
|
39372
|
-
usdc: SOLANA_MAINNET_USDC,
|
|
39373
|
-
gasToken: "SOL",
|
|
39374
|
-
rpcEnv: "SOLANA_RPC_URL",
|
|
39375
|
-
publicRpcUrl: "https://api.mainnet-beta.solana.com"
|
|
39376
|
-
}
|
|
38817
|
+
var marketplaceBadgeCodeSchema = external_exports.enum([
|
|
38818
|
+
"live_x402",
|
|
38819
|
+
"mpp",
|
|
38820
|
+
"partner",
|
|
38821
|
+
"payout_wallet_confirmed",
|
|
38822
|
+
"vapi_verified",
|
|
38823
|
+
"external_catalog",
|
|
38824
|
+
"approved_vendor",
|
|
38825
|
+
"unverified"
|
|
38826
|
+
]);
|
|
38827
|
+
var marketplaceBadgeSchema = external_exports.looseObject({
|
|
38828
|
+
code: marketplaceBadgeCodeSchema,
|
|
38829
|
+
label: external_exports.string().trim().min(1).max(80)
|
|
38830
|
+
});
|
|
38831
|
+
var marketplacePublicFactSchema = external_exports.looseObject({
|
|
38832
|
+
label: external_exports.string().trim().min(1).max(80),
|
|
38833
|
+
value: external_exports.string().trim().min(1).max(160)
|
|
38834
|
+
});
|
|
38835
|
+
var marketplaceHrefSchema = external_exports.union([
|
|
38836
|
+
external_exports.string().trim().min(1).max(2048).regex(/^\/(?!\/)/),
|
|
38837
|
+
external_exports.url().max(2048).regex(/^https:\/\//)
|
|
38838
|
+
]);
|
|
38839
|
+
var marketplaceCardSchema = external_exports.looseObject({
|
|
38840
|
+
title: external_exports.string().trim().min(1).max(160),
|
|
38841
|
+
summary: external_exports.string().trim().min(1).max(1e3),
|
|
38842
|
+
byline: external_exports.string().trim().min(1).max(160).optional(),
|
|
38843
|
+
bylineHref: marketplaceHrefSchema.optional(),
|
|
38844
|
+
badges: external_exports.preprocess(
|
|
38845
|
+
(badges) => Array.isArray(badges) ? badges.flatMap((badge) => {
|
|
38846
|
+
const parsed = marketplaceBadgeSchema.safeParse(badge);
|
|
38847
|
+
return parsed.success ? [parsed.data] : [];
|
|
38848
|
+
}) : badges,
|
|
38849
|
+
external_exports.array(marketplaceBadgeSchema).max(8)
|
|
38850
|
+
),
|
|
38851
|
+
facts: external_exports.array(marketplacePublicFactSchema).max(12)
|
|
38852
|
+
});
|
|
38853
|
+
var marketplaceHitBase = {
|
|
38854
|
+
ref: external_exports.string().trim().min(1).max(512),
|
|
38855
|
+
card: marketplaceCardSchema,
|
|
38856
|
+
...listingDisclosureShape
|
|
39377
38857
|
};
|
|
39378
|
-
|
|
39379
|
-
|
|
39380
|
-
|
|
39381
|
-
|
|
39382
|
-
|
|
39383
|
-
|
|
39384
|
-
|
|
39385
|
-
|
|
39386
|
-
|
|
39387
|
-
|
|
39388
|
-
}
|
|
39389
|
-
|
|
39390
|
-
|
|
39391
|
-
|
|
39392
|
-
|
|
39393
|
-
|
|
39394
|
-
|
|
39395
|
-
|
|
39396
|
-
|
|
39397
|
-
|
|
39398
|
-
|
|
39399
|
-
|
|
39400
|
-
|
|
39401
|
-
|
|
39402
|
-
|
|
39403
|
-
|
|
39404
|
-
|
|
39405
|
-
|
|
39406
|
-
|
|
39407
|
-
|
|
39408
|
-
|
|
39409
|
-
|
|
39410
|
-
|
|
39411
|
-
|
|
39412
|
-
|
|
39413
|
-
|
|
39414
|
-
|
|
39415
|
-
|
|
39416
|
-
|
|
39417
|
-
|
|
39418
|
-
|
|
39419
|
-
|
|
39420
|
-
|
|
39421
|
-
|
|
39422
|
-
|
|
39423
|
-
}
|
|
39424
|
-
|
|
39425
|
-
|
|
39426
|
-
|
|
39427
|
-
|
|
39428
|
-
|
|
39429
|
-
|
|
39430
|
-
|
|
39431
|
-
|
|
39432
|
-
|
|
39433
|
-
|
|
39434
|
-
|
|
39435
|
-
|
|
39436
|
-
|
|
39437
|
-
|
|
39438
|
-
|
|
39439
|
-
|
|
39440
|
-
|
|
39441
|
-
|
|
39442
|
-
|
|
39443
|
-
|
|
39444
|
-
|
|
39445
|
-
|
|
39446
|
-
|
|
39447
|
-
|
|
39448
|
-
|
|
39449
|
-
|
|
39450
|
-
|
|
39451
|
-
|
|
39452
|
-
const rpcUrl = envUrl || configured.rpcUrl.trim();
|
|
39453
|
-
if (rpcUrl) {
|
|
39454
|
-
return rpcUrl;
|
|
39455
|
-
}
|
|
39456
|
-
if (network === ARC_TESTNET_CAIP2) {
|
|
39457
|
-
throw new Error(
|
|
39458
|
-
"Arc testnet RPC is required. Set ARC_TESTNET_RPC_URL or add rpcUrl for eip155:5042002 in config.json."
|
|
39459
|
-
);
|
|
39460
|
-
}
|
|
39461
|
-
throw new Error(`RPC URL is required for ${network}.`);
|
|
39462
|
-
}
|
|
39463
|
-
function createChain(network, rpcUrl) {
|
|
39464
|
-
const definition = getNetworkDefinition(network);
|
|
39465
|
-
if (definition.family !== "evm" || definition.chainId === void 0) {
|
|
39466
|
-
throw new Error(`Network ${network} is not an EVM chain.`);
|
|
38858
|
+
var invokeApiActionSchema = external_exports.looseObject({
|
|
38859
|
+
type: external_exports.literal("invoke_api"),
|
|
38860
|
+
href: marketplaceHrefSchema
|
|
38861
|
+
});
|
|
38862
|
+
var firstPartyApiMarketplaceHitSchema = external_exports.looseObject({
|
|
38863
|
+
...marketplaceHitBase,
|
|
38864
|
+
kind: external_exports.literal("api"),
|
|
38865
|
+
provenance: firstPartyProvenanceSchema,
|
|
38866
|
+
execution: external_exports.looseObject({
|
|
38867
|
+
mode: executionModeSchema
|
|
38868
|
+
}),
|
|
38869
|
+
action: invokeApiActionSchema
|
|
38870
|
+
});
|
|
38871
|
+
var mirroredApiMarketplaceHitSchema = external_exports.looseObject({
|
|
38872
|
+
...marketplaceHitBase,
|
|
38873
|
+
kind: external_exports.literal("api"),
|
|
38874
|
+
provenance: external_exports.literal("indexed"),
|
|
38875
|
+
execution: external_exports.looseObject({
|
|
38876
|
+
mode: external_exports.literal("direct"),
|
|
38877
|
+
url: external_exports.url().max(2048).regex(/^https:\/\/(?![^/?#]*@)/),
|
|
38878
|
+
method: marketplaceExecutionMethodSchema.nullable(),
|
|
38879
|
+
network: external_exports.string().trim().max(160).transform((network) => {
|
|
38880
|
+
if (network === "solana") return X402_SOLANA_MAINNET_CAIP2;
|
|
38881
|
+
if (network === "solana-devnet") return SOLANA_DEVNET_CAIP2;
|
|
38882
|
+
return network;
|
|
38883
|
+
}).pipe(
|
|
38884
|
+
external_exports.union([
|
|
38885
|
+
external_exports.string().regex(/^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}$/),
|
|
38886
|
+
// Persisted mainnet configs also use the full genesis hash.
|
|
38887
|
+
external_exports.literal(SOLANA_MAINNET_CAIP2)
|
|
38888
|
+
])
|
|
38889
|
+
)
|
|
38890
|
+
}),
|
|
38891
|
+
action: invokeApiActionSchema
|
|
38892
|
+
});
|
|
38893
|
+
var apiMarketplaceHitSchema = external_exports.discriminatedUnion("provenance", [
|
|
38894
|
+
firstPartyApiMarketplaceHitSchema,
|
|
38895
|
+
mirroredApiMarketplaceHitSchema
|
|
38896
|
+
]);
|
|
38897
|
+
var serviceOfferMarketplaceHitSchema = external_exports.looseObject({
|
|
38898
|
+
...marketplaceHitBase,
|
|
38899
|
+
kind: external_exports.literal("service_offer"),
|
|
38900
|
+
action: external_exports.looseObject({
|
|
38901
|
+
type: external_exports.literal("start_engagement"),
|
|
38902
|
+
href: marketplaceHrefSchema
|
|
38903
|
+
})
|
|
38904
|
+
});
|
|
38905
|
+
var openRequestMarketplaceHitSchema = external_exports.looseObject({
|
|
38906
|
+
...marketplaceHitBase,
|
|
38907
|
+
kind: external_exports.literal("open_request"),
|
|
38908
|
+
action: external_exports.looseObject({
|
|
38909
|
+
type: external_exports.literal("propose_to_request"),
|
|
38910
|
+
href: marketplaceHrefSchema
|
|
38911
|
+
})
|
|
38912
|
+
});
|
|
38913
|
+
var marketplaceHitSchema = external_exports.union([
|
|
38914
|
+
apiMarketplaceHitSchema,
|
|
38915
|
+
serviceOfferMarketplaceHitSchema,
|
|
38916
|
+
openRequestMarketplaceHitSchema
|
|
38917
|
+
]);
|
|
38918
|
+
var marketplaceDiscoveryInputSchema = external_exports.strictObject({
|
|
38919
|
+
q: external_exports.string().trim().max(200).optional(),
|
|
38920
|
+
kinds: external_exports.array(marketplaceKindSchema).min(1).max(MARKETPLACE_KINDS.length).optional(),
|
|
38921
|
+
network: external_exports.string().trim().min(1).max(160).optional(),
|
|
38922
|
+
cursor: external_exports.string().trim().min(1).max(4096).optional(),
|
|
38923
|
+
limit: external_exports.number().int().min(1).max(50).optional(),
|
|
38924
|
+
includeUnverified: external_exports.boolean().optional()
|
|
38925
|
+
}).superRefine((input2, context) => {
|
|
38926
|
+
if (input2.kinds && new Set(input2.kinds).size !== input2.kinds.length) {
|
|
38927
|
+
context.addIssue({
|
|
38928
|
+
code: "custom",
|
|
38929
|
+
path: ["kinds"],
|
|
38930
|
+
message: "Marketplace kinds must be unique"
|
|
38931
|
+
});
|
|
39467
38932
|
}
|
|
39468
|
-
|
|
39469
|
-
|
|
39470
|
-
|
|
39471
|
-
nativeCurrency: definition.gasToken === "USDC" ? { name: "USDC", symbol: "USDC", decimals: USDC_DECIMALS } : { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
39472
|
-
rpcUrls: {
|
|
39473
|
-
default: { http: [rpcUrl] }
|
|
39474
|
-
},
|
|
39475
|
-
...definition.explorerUrl ? {
|
|
39476
|
-
blockExplorers: {
|
|
39477
|
-
default: { name: `${definition.name} explorer`, url: definition.explorerUrl }
|
|
39478
|
-
}
|
|
39479
|
-
} : {}
|
|
39480
|
-
});
|
|
39481
|
-
}
|
|
39482
|
-
function createNetworkPublicClient(network, configured, options = {}) {
|
|
39483
|
-
const rpcUrl = requireRpcUrl(network, configured);
|
|
39484
|
-
return createPublicClient({
|
|
39485
|
-
chain: createChain(network, rpcUrl),
|
|
39486
|
-
transport: createNetworkHttpTransport(rpcUrl, options)
|
|
39487
|
-
});
|
|
39488
|
-
}
|
|
39489
|
-
function createNetworkHttpTransport(rpcUrl, options = {}) {
|
|
39490
|
-
const fetchFn = options.fetch ?? createPublicFetch({
|
|
39491
|
-
allowPrivateNetwork: options.allowPrivateNetwork ?? false,
|
|
39492
|
-
...options.lookup ? { lookup: options.lookup } : {}
|
|
39493
|
-
});
|
|
39494
|
-
return http(rpcUrl, { fetchFn, fetchOptions: { redirect: "manual" } });
|
|
39495
|
-
}
|
|
39496
|
-
function formatUsdc(amountAtomic) {
|
|
39497
|
-
return formatUnits(amountAtomic, USDC_DECIMALS);
|
|
38933
|
+
});
|
|
38934
|
+
function isMirroredHit(hit) {
|
|
38935
|
+
return hit.kind === "api" && hit.provenance === "indexed";
|
|
39498
38936
|
}
|
|
38937
|
+
var marketplaceDiscoveryEnvelopeSchema = external_exports.looseObject({
|
|
38938
|
+
protocol: external_exports.literal(MARKETPLACE_DISCOVERY_PROTOCOL),
|
|
38939
|
+
items: external_exports.array(external_exports.unknown()),
|
|
38940
|
+
nextCursor: external_exports.string().min(1).max(4096).nullable(),
|
|
38941
|
+
unavailableKinds: external_exports.array(marketplaceKindSchema).max(MARKETPLACE_KINDS.length),
|
|
38942
|
+
rankingVersion: external_exports.literal(MARKETPLACE_RANKING_VERSION)
|
|
38943
|
+
});
|
|
38944
|
+
var marketplaceDiscoveryPageSchema = marketplaceDiscoveryEnvelopeSchema.extend({
|
|
38945
|
+
items: external_exports.array(marketplaceHitSchema)
|
|
38946
|
+
});
|
|
39499
38947
|
|
|
39500
38948
|
// ../../node_modules/.pnpm/@solana+errors@5.5.1_typescript@6.0.3/node_modules/@solana/errors/dist/index.node.mjs
|
|
39501
38949
|
var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 1;
|
|
@@ -44477,16 +43925,16 @@ var DEFAULT_COMPUTE_UNIT_PRICE_MICROLAMPORTS = 1;
|
|
|
44477
43925
|
var DEFAULT_COMPUTE_UNIT_LIMIT = 2e4;
|
|
44478
43926
|
var MAX_MEMO_BYTES = 256;
|
|
44479
43927
|
var SOLANA_MAINNET_CAIP22 = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
44480
|
-
var
|
|
43928
|
+
var SOLANA_DEVNET_CAIP22 = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";
|
|
44481
43929
|
var SOLANA_TESTNET_CAIP2 = "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z";
|
|
44482
43930
|
var V1_TO_V2_NETWORK_MAP = {
|
|
44483
43931
|
solana: SOLANA_MAINNET_CAIP22,
|
|
44484
|
-
"solana-devnet":
|
|
43932
|
+
"solana-devnet": SOLANA_DEVNET_CAIP22,
|
|
44485
43933
|
"solana-testnet": SOLANA_TESTNET_CAIP2
|
|
44486
43934
|
};
|
|
44487
43935
|
function normalizeNetwork(network) {
|
|
44488
43936
|
if (network.includes(":")) {
|
|
44489
|
-
const supported = [SOLANA_MAINNET_CAIP22,
|
|
43937
|
+
const supported = [SOLANA_MAINNET_CAIP22, SOLANA_DEVNET_CAIP22, SOLANA_TESTNET_CAIP2];
|
|
44490
43938
|
if (!supported.includes(network)) {
|
|
44491
43939
|
throw new Error(`Unsupported SVM network: ${network}`);
|
|
44492
43940
|
}
|
|
@@ -44534,7 +43982,7 @@ var DEFAULT_ASSETS = {
|
|
|
44534
43982
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS2
|
|
44535
43983
|
}
|
|
44536
43984
|
],
|
|
44537
|
-
[
|
|
43985
|
+
[SOLANA_DEVNET_CAIP22]: [
|
|
44538
43986
|
{
|
|
44539
43987
|
asset: USDC_DEVNET_ADDRESS,
|
|
44540
43988
|
decimals: 6,
|
|
@@ -44584,209 +44032,579 @@ var findDefaultAsset = (asset, network) => {
|
|
|
44584
44032
|
if (!assets) {
|
|
44585
44033
|
return void 0;
|
|
44586
44034
|
}
|
|
44587
|
-
return assets.find((entry) => entry.asset === asset);
|
|
44588
|
-
};
|
|
44589
|
-
function createRpcClient(network, customRpcUrl) {
|
|
44590
|
-
const caip2Network = normalizeNetwork(network);
|
|
44591
|
-
switch (caip2Network) {
|
|
44592
|
-
case
|
|
44593
|
-
const url2 = customRpcUrl || DEVNET_RPC_URL;
|
|
44594
|
-
return createSolanaRpc(devnet(url2));
|
|
44595
|
-
}
|
|
44596
|
-
case SOLANA_TESTNET_CAIP2: {
|
|
44597
|
-
const url2 = customRpcUrl || TESTNET_RPC_URL;
|
|
44598
|
-
return createSolanaRpc(testnet(url2));
|
|
44599
|
-
}
|
|
44600
|
-
case SOLANA_MAINNET_CAIP22: {
|
|
44601
|
-
const url2 = customRpcUrl || MAINNET_RPC_URL;
|
|
44602
|
-
return createSolanaRpc(mainnet(url2));
|
|
44603
|
-
}
|
|
44604
|
-
default:
|
|
44605
|
-
throw new Error(`Unsupported network: ${network}`);
|
|
44035
|
+
return assets.find((entry) => entry.asset === asset);
|
|
44036
|
+
};
|
|
44037
|
+
function createRpcClient(network, customRpcUrl) {
|
|
44038
|
+
const caip2Network = normalizeNetwork(network);
|
|
44039
|
+
switch (caip2Network) {
|
|
44040
|
+
case SOLANA_DEVNET_CAIP22: {
|
|
44041
|
+
const url2 = customRpcUrl || DEVNET_RPC_URL;
|
|
44042
|
+
return createSolanaRpc(devnet(url2));
|
|
44043
|
+
}
|
|
44044
|
+
case SOLANA_TESTNET_CAIP2: {
|
|
44045
|
+
const url2 = customRpcUrl || TESTNET_RPC_URL;
|
|
44046
|
+
return createSolanaRpc(testnet(url2));
|
|
44047
|
+
}
|
|
44048
|
+
case SOLANA_MAINNET_CAIP22: {
|
|
44049
|
+
const url2 = customRpcUrl || MAINNET_RPC_URL;
|
|
44050
|
+
return createSolanaRpc(mainnet(url2));
|
|
44051
|
+
}
|
|
44052
|
+
default:
|
|
44053
|
+
throw new Error(`Unsupported network: ${network}`);
|
|
44054
|
+
}
|
|
44055
|
+
}
|
|
44056
|
+
async function resolveBlockhash(rpc, requirements) {
|
|
44057
|
+
const provided = requirements.extra?.recentBlockhash;
|
|
44058
|
+
if (typeof provided === "string" && provided !== "") {
|
|
44059
|
+
try {
|
|
44060
|
+
if (getBase58Encoder().encode(provided).length === 32) {
|
|
44061
|
+
const lastValid = requirements.extra?.lastValidBlockHeight;
|
|
44062
|
+
let lastValidBlockHeight = 0n;
|
|
44063
|
+
if (typeof lastValid === "string" && /^\d+$/.test(lastValid)) {
|
|
44064
|
+
lastValidBlockHeight = BigInt(lastValid);
|
|
44065
|
+
} else if (typeof lastValid === "number" && Number.isSafeInteger(lastValid) && lastValid >= 0) {
|
|
44066
|
+
lastValidBlockHeight = BigInt(lastValid);
|
|
44067
|
+
}
|
|
44068
|
+
return { blockhash: provided, lastValidBlockHeight };
|
|
44069
|
+
}
|
|
44070
|
+
} catch {
|
|
44071
|
+
}
|
|
44072
|
+
}
|
|
44073
|
+
const { value } = await rpc.getLatestBlockhash().send();
|
|
44074
|
+
return value;
|
|
44075
|
+
}
|
|
44076
|
+
|
|
44077
|
+
// ../../node_modules/.pnpm/@solana-program+compute-budget@0.11.0_@solana+kit@5.5.1_typescript@6.0.3_/node_modules/@solana-program/compute-budget/dist/src/index.mjs
|
|
44078
|
+
var COMPUTE_BUDGET_PROGRAM_ADDRESS = "ComputeBudget111111111111111111111111111111";
|
|
44079
|
+
var SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR = 2;
|
|
44080
|
+
function getSetComputeUnitLimitInstructionDataEncoder() {
|
|
44081
|
+
return transformEncoder(
|
|
44082
|
+
getStructEncoder([
|
|
44083
|
+
["discriminator", getU8Encoder()],
|
|
44084
|
+
["units", getU32Encoder()]
|
|
44085
|
+
]),
|
|
44086
|
+
(value) => ({
|
|
44087
|
+
...value,
|
|
44088
|
+
discriminator: SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR
|
|
44089
|
+
})
|
|
44090
|
+
);
|
|
44091
|
+
}
|
|
44092
|
+
function getSetComputeUnitLimitInstruction(input2, config2) {
|
|
44093
|
+
const programAddress = config2?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;
|
|
44094
|
+
const args = { ...input2 };
|
|
44095
|
+
return Object.freeze({
|
|
44096
|
+
data: getSetComputeUnitLimitInstructionDataEncoder().encode(
|
|
44097
|
+
args
|
|
44098
|
+
),
|
|
44099
|
+
programAddress
|
|
44100
|
+
});
|
|
44101
|
+
}
|
|
44102
|
+
var SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR = 3;
|
|
44103
|
+
function getSetComputeUnitPriceInstructionDataEncoder() {
|
|
44104
|
+
return transformEncoder(
|
|
44105
|
+
getStructEncoder([
|
|
44106
|
+
["discriminator", getU8Encoder()],
|
|
44107
|
+
["microLamports", getU64Encoder()]
|
|
44108
|
+
]),
|
|
44109
|
+
(value) => ({
|
|
44110
|
+
...value,
|
|
44111
|
+
discriminator: SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR
|
|
44112
|
+
})
|
|
44113
|
+
);
|
|
44114
|
+
}
|
|
44115
|
+
function getSetComputeUnitPriceInstruction(input2, config2) {
|
|
44116
|
+
const programAddress = config2?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;
|
|
44117
|
+
const args = { ...input2 };
|
|
44118
|
+
return Object.freeze({
|
|
44119
|
+
data: getSetComputeUnitPriceInstructionDataEncoder().encode(
|
|
44120
|
+
args
|
|
44121
|
+
),
|
|
44122
|
+
programAddress
|
|
44123
|
+
});
|
|
44124
|
+
}
|
|
44125
|
+
function setTransactionMessageComputeUnitPrice(microLamports, transactionMessage) {
|
|
44126
|
+
return appendTransactionMessageInstruction(
|
|
44127
|
+
getSetComputeUnitPriceInstruction({ microLamports }),
|
|
44128
|
+
transactionMessage
|
|
44129
|
+
);
|
|
44130
|
+
}
|
|
44131
|
+
|
|
44132
|
+
// ../../node_modules/.pnpm/@x402+svm@2.25.0_@solana+kit@5.5.1_typescript@6.0.3__@solana+sysvars@5.5.1_typescript@6.0.3_/node_modules/@x402/svm/dist/esm/chunk-FKOM6YTW.mjs
|
|
44133
|
+
var ExactSvmScheme = class {
|
|
44134
|
+
/**
|
|
44135
|
+
* Creates a new ExactSvmClient instance.
|
|
44136
|
+
*
|
|
44137
|
+
* @param signer - The SVM signer for client operations
|
|
44138
|
+
* @param config - Optional configuration with custom RPC URL
|
|
44139
|
+
* @returns ExactSvmClient instance
|
|
44140
|
+
*/
|
|
44141
|
+
constructor(signer, config2) {
|
|
44142
|
+
this.signer = signer;
|
|
44143
|
+
this.config = config2;
|
|
44144
|
+
this.scheme = "exact";
|
|
44145
|
+
this.findDefaultAsset = findDefaultAsset;
|
|
44146
|
+
this.mintCache = /* @__PURE__ */ new Map();
|
|
44147
|
+
}
|
|
44148
|
+
/**
|
|
44149
|
+
* Creates a payment payload for the Exact scheme.
|
|
44150
|
+
*
|
|
44151
|
+
* @param x402Version - The x402 protocol version
|
|
44152
|
+
* @param paymentRequirements - The payment requirements
|
|
44153
|
+
* @returns Promise resolving to a payment payload
|
|
44154
|
+
*/
|
|
44155
|
+
async createPaymentPayload(x402Version, paymentRequirements) {
|
|
44156
|
+
const rpc = createRpcClient(paymentRequirements.network, this.config?.rpcUrl);
|
|
44157
|
+
const mintMetadata = await getCachedMintMetadata(
|
|
44158
|
+
rpc,
|
|
44159
|
+
paymentRequirements.network,
|
|
44160
|
+
paymentRequirements.asset,
|
|
44161
|
+
this.mintCache
|
|
44162
|
+
);
|
|
44163
|
+
const tokenProgramAddress = mintMetadata.programAddress;
|
|
44164
|
+
if (tokenProgramAddress.toString() !== TOKEN_PROGRAM_ADDRESS.toString() && tokenProgramAddress.toString() !== TOKEN_2022_PROGRAM_ADDRESS.toString()) {
|
|
44165
|
+
throw new Error("Asset was not created by a known token program");
|
|
44166
|
+
}
|
|
44167
|
+
const [sourceATA] = await findAssociatedTokenPda({
|
|
44168
|
+
mint: paymentRequirements.asset,
|
|
44169
|
+
owner: this.signer.address,
|
|
44170
|
+
tokenProgram: tokenProgramAddress
|
|
44171
|
+
});
|
|
44172
|
+
const [destinationATA] = await findAssociatedTokenPda({
|
|
44173
|
+
mint: paymentRequirements.asset,
|
|
44174
|
+
owner: paymentRequirements.payTo,
|
|
44175
|
+
tokenProgram: tokenProgramAddress
|
|
44176
|
+
});
|
|
44177
|
+
const transferIx = getTransferCheckedInstruction(
|
|
44178
|
+
{
|
|
44179
|
+
source: sourceATA,
|
|
44180
|
+
mint: paymentRequirements.asset,
|
|
44181
|
+
destination: destinationATA,
|
|
44182
|
+
authority: this.signer,
|
|
44183
|
+
amount: BigInt(paymentRequirements.amount),
|
|
44184
|
+
decimals: mintMetadata.decimals
|
|
44185
|
+
},
|
|
44186
|
+
{ programAddress: tokenProgramAddress }
|
|
44187
|
+
);
|
|
44188
|
+
const feePayer = paymentRequirements.extra?.feePayer;
|
|
44189
|
+
if (!feePayer) {
|
|
44190
|
+
throw new Error("feePayer is required in paymentRequirements.extra for SVM transactions");
|
|
44191
|
+
}
|
|
44192
|
+
const latestBlockhash = await resolveBlockhash(rpc, paymentRequirements);
|
|
44193
|
+
const sellerMemo = paymentRequirements.extra?.memo;
|
|
44194
|
+
let memoData;
|
|
44195
|
+
if (sellerMemo) {
|
|
44196
|
+
memoData = new TextEncoder().encode(sellerMemo);
|
|
44197
|
+
if (memoData.byteLength > MAX_MEMO_BYTES) {
|
|
44198
|
+
throw new Error(`extra.memo exceeds maximum ${MAX_MEMO_BYTES} bytes`);
|
|
44199
|
+
}
|
|
44200
|
+
} else {
|
|
44201
|
+
const nonce = crypto.getRandomValues(new Uint8Array(16));
|
|
44202
|
+
memoData = new TextEncoder().encode(
|
|
44203
|
+
Array.from(nonce).map((b) => b.toString(16).padStart(2, "0")).join("")
|
|
44204
|
+
);
|
|
44205
|
+
}
|
|
44206
|
+
const memoIx = {
|
|
44207
|
+
programAddress: MEMO_PROGRAM_ADDRESS,
|
|
44208
|
+
accounts: [],
|
|
44209
|
+
data: memoData
|
|
44210
|
+
};
|
|
44211
|
+
const tx = pipe2(
|
|
44212
|
+
createTransactionMessage({ version: 0 }),
|
|
44213
|
+
(tx2) => setTransactionMessageComputeUnitPrice(DEFAULT_COMPUTE_UNIT_PRICE_MICROLAMPORTS, tx2),
|
|
44214
|
+
(tx2) => setTransactionMessageFeePayer(feePayer, tx2),
|
|
44215
|
+
(tx2) => prependTransactionMessageInstruction(
|
|
44216
|
+
getSetComputeUnitLimitInstruction({ units: DEFAULT_COMPUTE_UNIT_LIMIT }),
|
|
44217
|
+
tx2
|
|
44218
|
+
),
|
|
44219
|
+
(tx2) => appendTransactionMessageInstructions([transferIx, memoIx], tx2),
|
|
44220
|
+
(tx2) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx2)
|
|
44221
|
+
);
|
|
44222
|
+
const signedTransaction = await partiallySignTransactionMessageWithSigners(tx);
|
|
44223
|
+
const base64EncodedWireTransaction = getBase64EncodedWireTransaction(signedTransaction);
|
|
44224
|
+
const payload = {
|
|
44225
|
+
transaction: base64EncodedWireTransaction
|
|
44226
|
+
};
|
|
44227
|
+
return {
|
|
44228
|
+
x402Version,
|
|
44229
|
+
payload
|
|
44230
|
+
};
|
|
44231
|
+
}
|
|
44232
|
+
};
|
|
44233
|
+
|
|
44234
|
+
// ../../node_modules/.pnpm/@x402+svm@2.25.0_@solana+kit@5.5.1_typescript@6.0.3__@solana+sysvars@5.5.1_typescript@6.0.3_/node_modules/@x402/svm/dist/esm/chunk-N4DEEDTQ.mjs
|
|
44235
|
+
var addressEncoder = getAddressEncoder();
|
|
44236
|
+
var compiledMessageDecoder = getCompiledTransactionMessageDecoder();
|
|
44237
|
+
|
|
44238
|
+
// src/net-guard.ts
|
|
44239
|
+
import { lookup as dnsLookup } from "node:dns/promises";
|
|
44240
|
+
import { request as httpRequest } from "node:http";
|
|
44241
|
+
import { request as httpsRequest } from "node:https";
|
|
44242
|
+
import { isIP } from "node:net";
|
|
44243
|
+
import { Readable } from "node:stream";
|
|
44244
|
+
var defaultLookup = async (hostname3) => {
|
|
44245
|
+
const addresses = await dnsLookup(hostname3, { all: true });
|
|
44246
|
+
return addresses.map(({ address: address2 }) => address2);
|
|
44247
|
+
};
|
|
44248
|
+
async function assertPublicUrl(url2, options) {
|
|
44249
|
+
if (url2.username || url2.password) {
|
|
44250
|
+
throw guardError(url2);
|
|
44251
|
+
}
|
|
44252
|
+
if (url2.protocol !== "http:" && url2.protocol !== "https:") {
|
|
44253
|
+
throw guardError(url2);
|
|
44254
|
+
}
|
|
44255
|
+
if (options.allowPrivateNetwork) {
|
|
44256
|
+
return;
|
|
44257
|
+
}
|
|
44258
|
+
const hostname3 = normalizeHostname(url2.hostname);
|
|
44259
|
+
const lowercaseHostname = hostname3.toLowerCase();
|
|
44260
|
+
if (!lowercaseHostname || lowercaseHostname === "localhost" || lowercaseHostname.endsWith(".localhost") || lowercaseHostname.endsWith(".local") || lowercaseHostname.endsWith(".internal")) {
|
|
44261
|
+
throw guardError(url2);
|
|
44262
|
+
}
|
|
44263
|
+
if (isIP(hostname3)) {
|
|
44264
|
+
if (isNonPublicAddress(hostname3)) {
|
|
44265
|
+
throw guardError(url2);
|
|
44266
|
+
}
|
|
44267
|
+
return;
|
|
44268
|
+
}
|
|
44269
|
+
let addresses;
|
|
44270
|
+
try {
|
|
44271
|
+
addresses = await withTimeout2(
|
|
44272
|
+
(options.lookup ?? defaultLookup)(hostname3),
|
|
44273
|
+
options.timeoutMs ?? 5e3
|
|
44274
|
+
);
|
|
44275
|
+
} catch {
|
|
44276
|
+
throw guardError(url2);
|
|
44277
|
+
}
|
|
44278
|
+
if (addresses.length === 0 || addresses.some(isNonPublicAddress)) {
|
|
44279
|
+
throw guardError(url2);
|
|
44280
|
+
}
|
|
44281
|
+
}
|
|
44282
|
+
function createPublicFetch(options) {
|
|
44283
|
+
const lookupFn = options.lookup ?? defaultLookup;
|
|
44284
|
+
return (async (input2, init) => {
|
|
44285
|
+
const url2 = new URL(input2 instanceof Request ? input2.url : input2);
|
|
44286
|
+
await assertPublicUrl(url2, {
|
|
44287
|
+
allowPrivateNetwork: options.allowPrivateNetwork,
|
|
44288
|
+
lookup: lookupFn,
|
|
44289
|
+
timeoutMs: 5e3
|
|
44290
|
+
});
|
|
44291
|
+
const normalized = new Request(input2, init);
|
|
44292
|
+
const bytes = normalized.body ? Buffer.from(await normalized.arrayBuffer()) : null;
|
|
44293
|
+
return await new Promise((resolve2, reject) => {
|
|
44294
|
+
const requestOptions = {
|
|
44295
|
+
method: normalized.method,
|
|
44296
|
+
headers: Object.fromEntries(normalized.headers),
|
|
44297
|
+
signal: normalized.signal,
|
|
44298
|
+
...options.allowPrivateNetwork ? {} : { lookup: pinnedLookup(lookupFn) }
|
|
44299
|
+
};
|
|
44300
|
+
const onResponse = (incoming) => {
|
|
44301
|
+
try {
|
|
44302
|
+
const headers = new Headers();
|
|
44303
|
+
for (const [name, value] of Object.entries(incoming.headers)) {
|
|
44304
|
+
if (Array.isArray(value)) {
|
|
44305
|
+
for (const item of value) headers.append(name, item);
|
|
44306
|
+
} else if (value !== void 0) {
|
|
44307
|
+
headers.set(name, value);
|
|
44308
|
+
}
|
|
44309
|
+
}
|
|
44310
|
+
const status = incoming.statusCode ?? 500;
|
|
44311
|
+
const bodyForbidden = normalized.method === "HEAD" || [204, 205, 304].includes(status);
|
|
44312
|
+
if (bodyForbidden) incoming.resume();
|
|
44313
|
+
const response = new Response(
|
|
44314
|
+
bodyForbidden ? null : Readable.toWeb(incoming),
|
|
44315
|
+
{ status, statusText: incoming.statusMessage, headers }
|
|
44316
|
+
);
|
|
44317
|
+
Object.defineProperty(response, "url", { value: url2.toString() });
|
|
44318
|
+
resolve2(response);
|
|
44319
|
+
} catch (error61) {
|
|
44320
|
+
incoming.destroy();
|
|
44321
|
+
reject(error61);
|
|
44322
|
+
}
|
|
44323
|
+
};
|
|
44324
|
+
const request = url2.protocol === "https:" ? httpsRequest(url2, requestOptions, onResponse) : httpRequest(url2, requestOptions, onResponse);
|
|
44325
|
+
request.on("error", reject);
|
|
44326
|
+
if (bytes) request.write(bytes);
|
|
44327
|
+
request.end();
|
|
44328
|
+
});
|
|
44329
|
+
});
|
|
44330
|
+
}
|
|
44331
|
+
function pinnedLookup(lookup) {
|
|
44332
|
+
return (hostname3, dnsOptions, callback) => {
|
|
44333
|
+
void lookup(normalizeHostname(hostname3)).then((addresses) => {
|
|
44334
|
+
if (addresses.length === 0 || addresses.some(isNonPublicAddress)) {
|
|
44335
|
+
callback(guardError(new URL(`https://${hostname3}`)), "");
|
|
44336
|
+
return;
|
|
44337
|
+
}
|
|
44338
|
+
const address2 = addresses[0];
|
|
44339
|
+
const family = isIP(address2);
|
|
44340
|
+
callback(
|
|
44341
|
+
null,
|
|
44342
|
+
dnsOptions.all ? [{ address: address2, family }] : address2,
|
|
44343
|
+
dnsOptions.all ? void 0 : family
|
|
44344
|
+
);
|
|
44345
|
+
}).catch(
|
|
44346
|
+
(error61) => callback(error61 instanceof Error ? error61 : new Error("DNS lookup failed."), "")
|
|
44347
|
+
);
|
|
44348
|
+
};
|
|
44349
|
+
}
|
|
44350
|
+
async function withTimeout2(operation, timeoutMs) {
|
|
44351
|
+
let timeout;
|
|
44352
|
+
try {
|
|
44353
|
+
return await Promise.race([
|
|
44354
|
+
operation,
|
|
44355
|
+
new Promise((_resolve, reject) => {
|
|
44356
|
+
timeout = setTimeout(() => reject(new Error("DNS lookup timed out.")), timeoutMs);
|
|
44357
|
+
})
|
|
44358
|
+
]);
|
|
44359
|
+
} finally {
|
|
44360
|
+
if (timeout) clearTimeout(timeout);
|
|
44361
|
+
}
|
|
44362
|
+
}
|
|
44363
|
+
function normalizeHostname(hostname3) {
|
|
44364
|
+
const unbracketed = hostname3.startsWith("[") && hostname3.endsWith("]") ? hostname3.slice(1, -1) : hostname3;
|
|
44365
|
+
return unbracketed.endsWith(".") ? unbracketed.slice(0, -1) : unbracketed;
|
|
44366
|
+
}
|
|
44367
|
+
function isNonPublicAddress(address2) {
|
|
44368
|
+
const normalized = normalizeHostname(address2);
|
|
44369
|
+
const version5 = isIP(normalized);
|
|
44370
|
+
if (version5 === 4) {
|
|
44371
|
+
return isNonPublicIpv4(parseIpv4(normalized));
|
|
44372
|
+
}
|
|
44373
|
+
if (version5 === 6) {
|
|
44374
|
+
return isNonPublicIpv6(parseIpv6(normalized));
|
|
44375
|
+
}
|
|
44376
|
+
return true;
|
|
44377
|
+
}
|
|
44378
|
+
function parseIpv4(address2) {
|
|
44379
|
+
const octets = address2.split(".").map(Number);
|
|
44380
|
+
return [octets[0], octets[1], octets[2], octets[3]];
|
|
44381
|
+
}
|
|
44382
|
+
function isNonPublicIpv4([first, second, third]) {
|
|
44383
|
+
return first === 0 || first === 10 || first === 100 && second >= 64 && second <= 127 || first === 127 || first === 169 && second === 254 || first === 172 && second >= 16 && second <= 31 || first === 192 && second === 0 && (third === 0 || third === 2) || first === 192 && second === 168 || first === 198 && second >= 18 && second <= 19 || first === 198 && second === 51 && third === 100 || first === 203 && second === 0 && third === 113 || first >= 224;
|
|
44384
|
+
}
|
|
44385
|
+
function parseIpv6(address2) {
|
|
44386
|
+
let normalized = address2.toLowerCase();
|
|
44387
|
+
const lastColon = normalized.lastIndexOf(":");
|
|
44388
|
+
const dottedTail = normalized.slice(lastColon + 1);
|
|
44389
|
+
if (dottedTail.includes(".")) {
|
|
44390
|
+
const [first, second, third, fourth] = parseIpv4(dottedTail);
|
|
44391
|
+
normalized = `${normalized.slice(0, lastColon + 1)}${(first << 8 | second).toString(16)}:${(third << 8 | fourth).toString(16)}`;
|
|
44392
|
+
}
|
|
44393
|
+
const halves = normalized.split("::");
|
|
44394
|
+
const left = halves[0] ? halves[0].split(":").map(parseHex) : [];
|
|
44395
|
+
const right = halves[1] ? halves[1].split(":").map(parseHex) : [];
|
|
44396
|
+
const omittedCount = 8 - left.length - right.length;
|
|
44397
|
+
return halves.length === 2 ? [...left, ...Array.from({ length: omittedCount }, () => 0), ...right] : left;
|
|
44398
|
+
}
|
|
44399
|
+
function parseHex(value) {
|
|
44400
|
+
return Number.parseInt(value, 16);
|
|
44401
|
+
}
|
|
44402
|
+
function isNonPublicIpv6(hextets) {
|
|
44403
|
+
if (hextets.slice(0, 5).every((hextet) => hextet === 0) && hextets[5] === 65535) {
|
|
44404
|
+
const embeddedIpv4 = [
|
|
44405
|
+
hextets[6] >> 8,
|
|
44406
|
+
hextets[6] & 255,
|
|
44407
|
+
hextets[7] >> 8,
|
|
44408
|
+
hextets[7] & 255
|
|
44409
|
+
];
|
|
44410
|
+
return isNonPublicIpv4(embeddedIpv4);
|
|
44411
|
+
}
|
|
44412
|
+
if (hextets.slice(0, 6).every((hextet) => hextet === 0)) {
|
|
44413
|
+
const compatibleIpv4 = [
|
|
44414
|
+
hextets[6] >> 8,
|
|
44415
|
+
hextets[6] & 255,
|
|
44416
|
+
hextets[7] >> 8,
|
|
44417
|
+
hextets[7] & 255
|
|
44418
|
+
];
|
|
44419
|
+
if (isNonPublicIpv4(compatibleIpv4)) return true;
|
|
44420
|
+
}
|
|
44421
|
+
const isUnspecified = hextets.every((hextet) => hextet === 0);
|
|
44422
|
+
const isLoopback = hextets.slice(0, 7).every((hextet) => hextet === 0) && hextets[7] === 1;
|
|
44423
|
+
const first = hextets[0];
|
|
44424
|
+
const isUniqueLocal = first >= 64512 && first <= 65023;
|
|
44425
|
+
const isLinkLocal = first >= 65152 && first <= 65215;
|
|
44426
|
+
const isSiteLocal = first >= 65216 && first <= 65279;
|
|
44427
|
+
const isMulticast = first >= 65280;
|
|
44428
|
+
const isDocumentation = first === 8193 && hextets[1] === 3512;
|
|
44429
|
+
return isUnspecified || isLoopback || isUniqueLocal || isLinkLocal || isSiteLocal || isMulticast || isDocumentation;
|
|
44430
|
+
}
|
|
44431
|
+
function guardError(url2) {
|
|
44432
|
+
return new Error(
|
|
44433
|
+
`URL hostname ${JSON.stringify(url2.hostname)} is not allowed; private or internal destinations require allowPrivateNetwork true in the vAPI config.`
|
|
44434
|
+
);
|
|
44435
|
+
}
|
|
44436
|
+
|
|
44437
|
+
// src/networks.ts
|
|
44438
|
+
var USDC_DECIMALS = 6;
|
|
44439
|
+
var DEFAULT_ARC_GAS_HEADROOM_ATOMIC = 50000n;
|
|
44440
|
+
var NETWORKS2 = {
|
|
44441
|
+
[BASE_MAINNET_CAIP2]: {
|
|
44442
|
+
family: "evm",
|
|
44443
|
+
chainId: 8453,
|
|
44444
|
+
name: "Base mainnet",
|
|
44445
|
+
usdc: CANONICAL_X402_USDC_NETWORKS[BASE_MAINNET_CAIP2].usdc,
|
|
44446
|
+
gasToken: "ETH",
|
|
44447
|
+
rpcEnv: "BASE_RPC_URL",
|
|
44448
|
+
publicRpcUrl: "https://mainnet.base.org",
|
|
44449
|
+
explorerUrl: "https://basescan.org"
|
|
44450
|
+
},
|
|
44451
|
+
[ARC_MAINNET_CAIP2]: {
|
|
44452
|
+
family: "evm",
|
|
44453
|
+
chainId: 5042,
|
|
44454
|
+
name: "Arc mainnet",
|
|
44455
|
+
usdc: CANONICAL_X402_USDC_NETWORKS[ARC_MAINNET_CAIP2].usdc,
|
|
44456
|
+
gasToken: "USDC",
|
|
44457
|
+
rpcEnv: "ARC_RPC_URL",
|
|
44458
|
+
publicRpcUrl: "https://rpc.mainnet.arc.io",
|
|
44459
|
+
explorerUrl: "https://explorer.arc.io"
|
|
44460
|
+
},
|
|
44461
|
+
[ARC_TESTNET_CAIP2]: {
|
|
44462
|
+
family: "evm",
|
|
44463
|
+
chainId: 5042002,
|
|
44464
|
+
name: "Arc testnet",
|
|
44465
|
+
usdc: CANONICAL_X402_USDC_NETWORKS[ARC_TESTNET_CAIP2].usdc,
|
|
44466
|
+
gasToken: "USDC",
|
|
44467
|
+
rpcEnv: "ARC_TESTNET_RPC_URL"
|
|
44468
|
+
},
|
|
44469
|
+
[SOLANA_MAINNET_CAIP2]: {
|
|
44470
|
+
family: "svm",
|
|
44471
|
+
name: "Solana mainnet",
|
|
44472
|
+
usdc: SOLANA_MAINNET_USDC,
|
|
44473
|
+
gasToken: "SOL",
|
|
44474
|
+
rpcEnv: "SOLANA_RPC_URL",
|
|
44475
|
+
publicRpcUrl: "https://api.mainnet-beta.solana.com"
|
|
44476
|
+
},
|
|
44477
|
+
[X402_SOLANA_MAINNET_CAIP2]: {
|
|
44478
|
+
family: "svm",
|
|
44479
|
+
name: "Solana mainnet",
|
|
44480
|
+
usdc: SOLANA_MAINNET_USDC,
|
|
44481
|
+
gasToken: "SOL",
|
|
44482
|
+
rpcEnv: "SOLANA_RPC_URL",
|
|
44483
|
+
publicRpcUrl: "https://api.mainnet-beta.solana.com"
|
|
44484
|
+
}
|
|
44485
|
+
};
|
|
44486
|
+
function parseEip155ChainId(network) {
|
|
44487
|
+
const match = /^eip155:(\d+)$/.exec(network);
|
|
44488
|
+
if (!match) {
|
|
44489
|
+
throw new Error(`Unsupported network ${network}; expected eip155:<chainId>.`);
|
|
44490
|
+
}
|
|
44491
|
+
const chainId = Number(match[1]);
|
|
44492
|
+
if (!Number.isSafeInteger(chainId) || chainId <= 0) {
|
|
44493
|
+
throw new Error(`Invalid EVM chain ID in network ${network}.`);
|
|
44494
|
+
}
|
|
44495
|
+
return chainId;
|
|
44496
|
+
}
|
|
44497
|
+
function isSolanaNetwork(network) {
|
|
44498
|
+
return network === SOLANA_MAINNET_CAIP2 || network === X402_SOLANA_MAINNET_CAIP2;
|
|
44499
|
+
}
|
|
44500
|
+
function usesUsdcGas(network) {
|
|
44501
|
+
try {
|
|
44502
|
+
return getNetworkDefinition(network).gasToken === "USDC";
|
|
44503
|
+
} catch {
|
|
44504
|
+
return false;
|
|
44505
|
+
}
|
|
44506
|
+
}
|
|
44507
|
+
function explorerTransactionUrl(network, hash4) {
|
|
44508
|
+
try {
|
|
44509
|
+
const explorerUrl = getNetworkDefinition(network).explorerUrl;
|
|
44510
|
+
return explorerUrl ? `${explorerUrl}/tx/${hash4}` : void 0;
|
|
44511
|
+
} catch {
|
|
44512
|
+
return void 0;
|
|
44513
|
+
}
|
|
44514
|
+
}
|
|
44515
|
+
function explorerAddressUrl(network, address2) {
|
|
44516
|
+
try {
|
|
44517
|
+
const explorerUrl = getNetworkDefinition(network).explorerUrl;
|
|
44518
|
+
return explorerUrl ? `${explorerUrl}/address/${address2}` : void 0;
|
|
44519
|
+
} catch {
|
|
44520
|
+
return void 0;
|
|
44521
|
+
}
|
|
44522
|
+
}
|
|
44523
|
+
function areSamePaymentNetwork(left, right) {
|
|
44524
|
+
return left === right || isSolanaNetwork(left) && isSolanaNetwork(right);
|
|
44525
|
+
}
|
|
44526
|
+
function isSupportedPaymentNetwork(network) {
|
|
44527
|
+
if (isSolanaNetwork(network)) return true;
|
|
44528
|
+
try {
|
|
44529
|
+
parseEip155ChainId(network);
|
|
44530
|
+
return true;
|
|
44531
|
+
} catch {
|
|
44532
|
+
return false;
|
|
44606
44533
|
}
|
|
44607
44534
|
}
|
|
44608
|
-
|
|
44609
|
-
const
|
|
44610
|
-
if (
|
|
44611
|
-
|
|
44612
|
-
|
|
44613
|
-
|
|
44614
|
-
|
|
44615
|
-
|
|
44616
|
-
|
|
44617
|
-
|
|
44618
|
-
|
|
44619
|
-
}
|
|
44620
|
-
return { blockhash: provided, lastValidBlockHeight };
|
|
44621
|
-
}
|
|
44622
|
-
} catch {
|
|
44623
|
-
}
|
|
44535
|
+
function configuredNetworkFor(networks, network) {
|
|
44536
|
+
const configured = networks[network];
|
|
44537
|
+
if (configured) return configured;
|
|
44538
|
+
if (network === X402_SOLANA_MAINNET_CAIP2) return networks[SOLANA_MAINNET_CAIP2];
|
|
44539
|
+
if (network === SOLANA_MAINNET_CAIP2) return networks[X402_SOLANA_MAINNET_CAIP2];
|
|
44540
|
+
return void 0;
|
|
44541
|
+
}
|
|
44542
|
+
function getNetworkDefinition(network) {
|
|
44543
|
+
const known = NETWORKS2[network];
|
|
44544
|
+
if (known) {
|
|
44545
|
+
return known;
|
|
44624
44546
|
}
|
|
44625
|
-
const
|
|
44626
|
-
return
|
|
44547
|
+
const chainId = parseEip155ChainId(network);
|
|
44548
|
+
return {
|
|
44549
|
+
family: "evm",
|
|
44550
|
+
chainId,
|
|
44551
|
+
name: network,
|
|
44552
|
+
usdc: getAddress("0x0000000000000000000000000000000000000000"),
|
|
44553
|
+
gasToken: "ETH",
|
|
44554
|
+
rpcEnv: ""
|
|
44555
|
+
};
|
|
44627
44556
|
}
|
|
44628
|
-
|
|
44629
|
-
|
|
44630
|
-
|
|
44631
|
-
|
|
44632
|
-
|
|
44633
|
-
|
|
44634
|
-
|
|
44635
|
-
|
|
44636
|
-
|
|
44637
|
-
|
|
44638
|
-
|
|
44639
|
-
|
|
44640
|
-
|
|
44641
|
-
})
|
|
44642
|
-
);
|
|
44557
|
+
function requireRpcUrl(network, configured) {
|
|
44558
|
+
const definition = getNetworkDefinition(network);
|
|
44559
|
+
const envUrl = definition.rpcEnv ? process.env[definition.rpcEnv]?.trim() : void 0;
|
|
44560
|
+
const rpcUrl = envUrl || configured.rpcUrl.trim();
|
|
44561
|
+
if (rpcUrl) {
|
|
44562
|
+
return rpcUrl;
|
|
44563
|
+
}
|
|
44564
|
+
if (network === ARC_TESTNET_CAIP2) {
|
|
44565
|
+
throw new Error(
|
|
44566
|
+
"Arc testnet RPC is required. Set ARC_TESTNET_RPC_URL or add rpcUrl for eip155:5042002 in config.json."
|
|
44567
|
+
);
|
|
44568
|
+
}
|
|
44569
|
+
throw new Error(`RPC URL is required for ${network}.`);
|
|
44643
44570
|
}
|
|
44644
|
-
function
|
|
44645
|
-
const
|
|
44646
|
-
|
|
44647
|
-
|
|
44648
|
-
|
|
44649
|
-
|
|
44650
|
-
|
|
44651
|
-
|
|
44571
|
+
function createChain(network, rpcUrl) {
|
|
44572
|
+
const definition = getNetworkDefinition(network);
|
|
44573
|
+
if (definition.family !== "evm" || definition.chainId === void 0) {
|
|
44574
|
+
throw new Error(`Network ${network} is not an EVM chain.`);
|
|
44575
|
+
}
|
|
44576
|
+
return defineChain({
|
|
44577
|
+
id: definition.chainId,
|
|
44578
|
+
name: definition.name,
|
|
44579
|
+
nativeCurrency: definition.gasToken === "USDC" ? { name: "USDC", symbol: "USDC", decimals: USDC_DECIMALS } : { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
44580
|
+
rpcUrls: {
|
|
44581
|
+
default: { http: [rpcUrl] }
|
|
44582
|
+
},
|
|
44583
|
+
...definition.explorerUrl ? {
|
|
44584
|
+
blockExplorers: {
|
|
44585
|
+
default: { name: `${definition.name} explorer`, url: definition.explorerUrl }
|
|
44586
|
+
}
|
|
44587
|
+
} : {}
|
|
44652
44588
|
});
|
|
44653
44589
|
}
|
|
44654
|
-
|
|
44655
|
-
|
|
44656
|
-
return
|
|
44657
|
-
|
|
44658
|
-
|
|
44659
|
-
|
|
44660
|
-
]),
|
|
44661
|
-
(value) => ({
|
|
44662
|
-
...value,
|
|
44663
|
-
discriminator: SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR
|
|
44664
|
-
})
|
|
44665
|
-
);
|
|
44590
|
+
function createNetworkPublicClient(network, configured, options = {}) {
|
|
44591
|
+
const rpcUrl = requireRpcUrl(network, configured);
|
|
44592
|
+
return createPublicClient({
|
|
44593
|
+
chain: createChain(network, rpcUrl),
|
|
44594
|
+
transport: createNetworkHttpTransport(rpcUrl, options)
|
|
44595
|
+
});
|
|
44666
44596
|
}
|
|
44667
|
-
function
|
|
44668
|
-
const
|
|
44669
|
-
|
|
44670
|
-
|
|
44671
|
-
data: getSetComputeUnitPriceInstructionDataEncoder().encode(
|
|
44672
|
-
args
|
|
44673
|
-
),
|
|
44674
|
-
programAddress
|
|
44597
|
+
function createNetworkHttpTransport(rpcUrl, options = {}) {
|
|
44598
|
+
const fetchFn = options.fetch ?? createPublicFetch({
|
|
44599
|
+
allowPrivateNetwork: options.allowPrivateNetwork ?? false,
|
|
44600
|
+
...options.lookup ? { lookup: options.lookup } : {}
|
|
44675
44601
|
});
|
|
44602
|
+
return http(rpcUrl, { fetchFn, fetchOptions: { redirect: "manual" } });
|
|
44676
44603
|
}
|
|
44677
|
-
function
|
|
44678
|
-
return
|
|
44679
|
-
getSetComputeUnitPriceInstruction({ microLamports }),
|
|
44680
|
-
transactionMessage
|
|
44681
|
-
);
|
|
44604
|
+
function formatUsdc(amountAtomic) {
|
|
44605
|
+
return formatUnits(amountAtomic, USDC_DECIMALS);
|
|
44682
44606
|
}
|
|
44683
44607
|
|
|
44684
|
-
// ../../node_modules/.pnpm/@x402+svm@2.25.0_@solana+kit@5.5.1_typescript@6.0.3__@solana+sysvars@5.5.1_typescript@6.0.3_/node_modules/@x402/svm/dist/esm/chunk-FKOM6YTW.mjs
|
|
44685
|
-
var ExactSvmScheme = class {
|
|
44686
|
-
/**
|
|
44687
|
-
* Creates a new ExactSvmClient instance.
|
|
44688
|
-
*
|
|
44689
|
-
* @param signer - The SVM signer for client operations
|
|
44690
|
-
* @param config - Optional configuration with custom RPC URL
|
|
44691
|
-
* @returns ExactSvmClient instance
|
|
44692
|
-
*/
|
|
44693
|
-
constructor(signer, config2) {
|
|
44694
|
-
this.signer = signer;
|
|
44695
|
-
this.config = config2;
|
|
44696
|
-
this.scheme = "exact";
|
|
44697
|
-
this.findDefaultAsset = findDefaultAsset;
|
|
44698
|
-
this.mintCache = /* @__PURE__ */ new Map();
|
|
44699
|
-
}
|
|
44700
|
-
/**
|
|
44701
|
-
* Creates a payment payload for the Exact scheme.
|
|
44702
|
-
*
|
|
44703
|
-
* @param x402Version - The x402 protocol version
|
|
44704
|
-
* @param paymentRequirements - The payment requirements
|
|
44705
|
-
* @returns Promise resolving to a payment payload
|
|
44706
|
-
*/
|
|
44707
|
-
async createPaymentPayload(x402Version, paymentRequirements) {
|
|
44708
|
-
const rpc = createRpcClient(paymentRequirements.network, this.config?.rpcUrl);
|
|
44709
|
-
const mintMetadata = await getCachedMintMetadata(
|
|
44710
|
-
rpc,
|
|
44711
|
-
paymentRequirements.network,
|
|
44712
|
-
paymentRequirements.asset,
|
|
44713
|
-
this.mintCache
|
|
44714
|
-
);
|
|
44715
|
-
const tokenProgramAddress = mintMetadata.programAddress;
|
|
44716
|
-
if (tokenProgramAddress.toString() !== TOKEN_PROGRAM_ADDRESS.toString() && tokenProgramAddress.toString() !== TOKEN_2022_PROGRAM_ADDRESS.toString()) {
|
|
44717
|
-
throw new Error("Asset was not created by a known token program");
|
|
44718
|
-
}
|
|
44719
|
-
const [sourceATA] = await findAssociatedTokenPda({
|
|
44720
|
-
mint: paymentRequirements.asset,
|
|
44721
|
-
owner: this.signer.address,
|
|
44722
|
-
tokenProgram: tokenProgramAddress
|
|
44723
|
-
});
|
|
44724
|
-
const [destinationATA] = await findAssociatedTokenPda({
|
|
44725
|
-
mint: paymentRequirements.asset,
|
|
44726
|
-
owner: paymentRequirements.payTo,
|
|
44727
|
-
tokenProgram: tokenProgramAddress
|
|
44728
|
-
});
|
|
44729
|
-
const transferIx = getTransferCheckedInstruction(
|
|
44730
|
-
{
|
|
44731
|
-
source: sourceATA,
|
|
44732
|
-
mint: paymentRequirements.asset,
|
|
44733
|
-
destination: destinationATA,
|
|
44734
|
-
authority: this.signer,
|
|
44735
|
-
amount: BigInt(paymentRequirements.amount),
|
|
44736
|
-
decimals: mintMetadata.decimals
|
|
44737
|
-
},
|
|
44738
|
-
{ programAddress: tokenProgramAddress }
|
|
44739
|
-
);
|
|
44740
|
-
const feePayer = paymentRequirements.extra?.feePayer;
|
|
44741
|
-
if (!feePayer) {
|
|
44742
|
-
throw new Error("feePayer is required in paymentRequirements.extra for SVM transactions");
|
|
44743
|
-
}
|
|
44744
|
-
const latestBlockhash = await resolveBlockhash(rpc, paymentRequirements);
|
|
44745
|
-
const sellerMemo = paymentRequirements.extra?.memo;
|
|
44746
|
-
let memoData;
|
|
44747
|
-
if (sellerMemo) {
|
|
44748
|
-
memoData = new TextEncoder().encode(sellerMemo);
|
|
44749
|
-
if (memoData.byteLength > MAX_MEMO_BYTES) {
|
|
44750
|
-
throw new Error(`extra.memo exceeds maximum ${MAX_MEMO_BYTES} bytes`);
|
|
44751
|
-
}
|
|
44752
|
-
} else {
|
|
44753
|
-
const nonce = crypto.getRandomValues(new Uint8Array(16));
|
|
44754
|
-
memoData = new TextEncoder().encode(
|
|
44755
|
-
Array.from(nonce).map((b) => b.toString(16).padStart(2, "0")).join("")
|
|
44756
|
-
);
|
|
44757
|
-
}
|
|
44758
|
-
const memoIx = {
|
|
44759
|
-
programAddress: MEMO_PROGRAM_ADDRESS,
|
|
44760
|
-
accounts: [],
|
|
44761
|
-
data: memoData
|
|
44762
|
-
};
|
|
44763
|
-
const tx = pipe2(
|
|
44764
|
-
createTransactionMessage({ version: 0 }),
|
|
44765
|
-
(tx2) => setTransactionMessageComputeUnitPrice(DEFAULT_COMPUTE_UNIT_PRICE_MICROLAMPORTS, tx2),
|
|
44766
|
-
(tx2) => setTransactionMessageFeePayer(feePayer, tx2),
|
|
44767
|
-
(tx2) => prependTransactionMessageInstruction(
|
|
44768
|
-
getSetComputeUnitLimitInstruction({ units: DEFAULT_COMPUTE_UNIT_LIMIT }),
|
|
44769
|
-
tx2
|
|
44770
|
-
),
|
|
44771
|
-
(tx2) => appendTransactionMessageInstructions([transferIx, memoIx], tx2),
|
|
44772
|
-
(tx2) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx2)
|
|
44773
|
-
);
|
|
44774
|
-
const signedTransaction = await partiallySignTransactionMessageWithSigners(tx);
|
|
44775
|
-
const base64EncodedWireTransaction = getBase64EncodedWireTransaction(signedTransaction);
|
|
44776
|
-
const payload = {
|
|
44777
|
-
transaction: base64EncodedWireTransaction
|
|
44778
|
-
};
|
|
44779
|
-
return {
|
|
44780
|
-
x402Version,
|
|
44781
|
-
payload
|
|
44782
|
-
};
|
|
44783
|
-
}
|
|
44784
|
-
};
|
|
44785
|
-
|
|
44786
|
-
// ../../node_modules/.pnpm/@x402+svm@2.25.0_@solana+kit@5.5.1_typescript@6.0.3__@solana+sysvars@5.5.1_typescript@6.0.3_/node_modules/@x402/svm/dist/esm/chunk-N4DEEDTQ.mjs
|
|
44787
|
-
var addressEncoder = getAddressEncoder();
|
|
44788
|
-
var compiledMessageDecoder = getCompiledTransactionMessageDecoder();
|
|
44789
|
-
|
|
44790
44608
|
// src/x402.ts
|
|
44791
44609
|
var MAX_CHALLENGE_BYTES = 1048576;
|
|
44792
44610
|
var MAX_UINT256 = (1n << 256n) - 1n;
|
|
@@ -45646,6 +45464,255 @@ function isRecord2(value) {
|
|
|
45646
45464
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
45647
45465
|
}
|
|
45648
45466
|
|
|
45467
|
+
// src/call-contracts-wire.ts
|
|
45468
|
+
var CALLABLE_KIND = "agent";
|
|
45469
|
+
var CALLABLE_CATEGORIES = ["ai", "data", "crypto", "compute", "search"];
|
|
45470
|
+
var callableCategorySchema = external_exports.enum(CALLABLE_CATEGORIES);
|
|
45471
|
+
var DISCOVERY_CATEGORIES = [...CALLABLE_CATEGORIES, "other"];
|
|
45472
|
+
var discoveryCategorySchema = external_exports.string().trim().min(1);
|
|
45473
|
+
var CALLABLE_CATEGORY_LABELS = {
|
|
45474
|
+
ai: { catalog: "AI / LLM", publish: "AI and models" },
|
|
45475
|
+
data: { catalog: "Data", publish: "Data" },
|
|
45476
|
+
crypto: { catalog: "Crypto", publish: "Crypto" },
|
|
45477
|
+
compute: { catalog: "Compute", publish: "Compute" },
|
|
45478
|
+
search: { catalog: "Search", publish: "Search" }
|
|
45479
|
+
};
|
|
45480
|
+
var CALLABLE_CATEGORY_SET = new Set(CALLABLE_CATEGORIES);
|
|
45481
|
+
function isCallableListing(kind, category) {
|
|
45482
|
+
return kind === CALLABLE_KIND && CALLABLE_CATEGORY_SET.has(category);
|
|
45483
|
+
}
|
|
45484
|
+
var serviceTierSchema = external_exports.string().trim().min(1);
|
|
45485
|
+
var discoveryEndpointSchema = external_exports.looseObject({
|
|
45486
|
+
name: external_exports.string(),
|
|
45487
|
+
method: external_exports.string(),
|
|
45488
|
+
url: external_exports.url(),
|
|
45489
|
+
price: external_exports.string(),
|
|
45490
|
+
description: external_exports.string(),
|
|
45491
|
+
operationId: external_exports.string().trim().min(1).optional(),
|
|
45492
|
+
requestContentType: external_exports.string().trim().min(1).optional(),
|
|
45493
|
+
requestSchema: external_exports.json().optional(),
|
|
45494
|
+
responseContentType: external_exports.string().trim().min(1).optional(),
|
|
45495
|
+
pathTemplate: external_exports.string().trim().min(1).optional(),
|
|
45496
|
+
pathParameters: external_exports.array(external_exports.string().trim().min(1)).optional(),
|
|
45497
|
+
payment: external_exports.union([
|
|
45498
|
+
external_exports.looseObject({
|
|
45499
|
+
scheme: external_exports.literal("exact"),
|
|
45500
|
+
network: external_exports.string().regex(/^eip155:\d+$/),
|
|
45501
|
+
asset: external_exports.string().regex(/^0x[0-9a-fA-F]{40}$/),
|
|
45502
|
+
payTo: external_exports.string().regex(/^0x[0-9a-fA-F]{40}$/),
|
|
45503
|
+
checkedAt: external_exports.iso.datetime()
|
|
45504
|
+
}),
|
|
45505
|
+
external_exports.looseObject({
|
|
45506
|
+
scheme: external_exports.literal("exact"),
|
|
45507
|
+
network: external_exports.union([
|
|
45508
|
+
external_exports.string().regex(/^solana:[-_a-zA-Z0-9]{1,32}$/),
|
|
45509
|
+
external_exports.literal(SOLANA_MAINNET_CAIP2)
|
|
45510
|
+
]),
|
|
45511
|
+
asset: external_exports.string().refine(isSolanaAddress, "Expected a Solana base58 address."),
|
|
45512
|
+
payTo: external_exports.string().refine(isSolanaAddress, "Expected a Solana base58 address."),
|
|
45513
|
+
checkedAt: external_exports.iso.datetime()
|
|
45514
|
+
}),
|
|
45515
|
+
external_exports.looseObject({
|
|
45516
|
+
protocol: external_exports.literal("mpp"),
|
|
45517
|
+
intent: external_exports.enum(["charge", "authorize", "subscription"]).nullable(),
|
|
45518
|
+
method: external_exports.string().trim().min(1).max(40).nullable(),
|
|
45519
|
+
checkedAt: external_exports.iso.datetime(),
|
|
45520
|
+
// Keep common x402 properties readable on the union while making it
|
|
45521
|
+
// impossible for MPP metadata to masquerade as executable x402 terms.
|
|
45522
|
+
network: external_exports.never().optional(),
|
|
45523
|
+
payTo: external_exports.never().optional()
|
|
45524
|
+
}),
|
|
45525
|
+
external_exports.looseObject({
|
|
45526
|
+
// Future payment protocols remain visible to callers so the payment
|
|
45527
|
+
// layer can refuse them explicitly instead of discovery losing the row.
|
|
45528
|
+
protocol: external_exports.string().trim().min(1).max(40),
|
|
45529
|
+
checkedAt: external_exports.iso.datetime(),
|
|
45530
|
+
network: external_exports.never().optional(),
|
|
45531
|
+
payTo: external_exports.never().optional()
|
|
45532
|
+
})
|
|
45533
|
+
]).optional()
|
|
45534
|
+
});
|
|
45535
|
+
var serviceSummarySchema = external_exports.looseObject({
|
|
45536
|
+
id: external_exports.string(),
|
|
45537
|
+
name: external_exports.string(),
|
|
45538
|
+
description: external_exports.string(),
|
|
45539
|
+
category: discoveryCategorySchema,
|
|
45540
|
+
tier: serviceTierSchema,
|
|
45541
|
+
...listingDisclosureShape,
|
|
45542
|
+
verified: external_exports.boolean(),
|
|
45543
|
+
wrapped: external_exports.boolean(),
|
|
45544
|
+
price: external_exports.string(),
|
|
45545
|
+
networks: external_exports.array(external_exports.string()),
|
|
45546
|
+
endpoints: external_exports.array(discoveryEndpointSchema)
|
|
45547
|
+
});
|
|
45548
|
+
var searchServicesResponseSchema = external_exports.looseObject({
|
|
45549
|
+
services: external_exports.array(serviceSummarySchema)
|
|
45550
|
+
});
|
|
45551
|
+
var listServicesResponseSchema = searchServicesResponseSchema;
|
|
45552
|
+
var discoveryServiceSchema = serviceSummarySchema;
|
|
45553
|
+
var discoveryResponseSchema = searchServicesResponseSchema;
|
|
45554
|
+
|
|
45555
|
+
// src/call-contracts.ts
|
|
45556
|
+
var DiscoveryCatalogError = class extends Error {
|
|
45557
|
+
constructor(code, message, serviceId, paymentNetworks) {
|
|
45558
|
+
super(message);
|
|
45559
|
+
this.paymentNetworks = paymentNetworks;
|
|
45560
|
+
this.code = code;
|
|
45561
|
+
this.serviceId = serviceId;
|
|
45562
|
+
}
|
|
45563
|
+
paymentNetworks;
|
|
45564
|
+
name = "DiscoveryCatalogError";
|
|
45565
|
+
code;
|
|
45566
|
+
serviceId;
|
|
45567
|
+
};
|
|
45568
|
+
function isDiscoveryCatalogError(error61) {
|
|
45569
|
+
if (!(error61 instanceof Error) || error61.name !== "DiscoveryCatalogError" || !("code" in error61) || typeof error61.code !== "string") {
|
|
45570
|
+
return false;
|
|
45571
|
+
}
|
|
45572
|
+
const networks = Reflect.get(error61, "paymentNetworks");
|
|
45573
|
+
return networks === void 0 || Array.isArray(networks) && networks.every((network) => typeof network === "string");
|
|
45574
|
+
}
|
|
45575
|
+
function parseDiscovery(raw) {
|
|
45576
|
+
const parsed = discoveryResponseSchema.safeParse(raw);
|
|
45577
|
+
if (!parsed.success) {
|
|
45578
|
+
const malformedUrl = parsed.error.issues.find(
|
|
45579
|
+
(issue2) => issue2.path.at(-1) === "url" && issue2.path.includes("endpoints")
|
|
45580
|
+
);
|
|
45581
|
+
if (malformedUrl) {
|
|
45582
|
+
const serviceIndex = pathIndexAfter(malformedUrl.path, "services");
|
|
45583
|
+
const serviceId = rawServiceId(raw, serviceIndex);
|
|
45584
|
+
throw new DiscoveryCatalogError(
|
|
45585
|
+
"malformed_url",
|
|
45586
|
+
`Service ${JSON.stringify(serviceId ?? "unknown")} has a malformed endpoint URL.`,
|
|
45587
|
+
serviceId
|
|
45588
|
+
);
|
|
45589
|
+
}
|
|
45590
|
+
throw new DiscoveryCatalogError("invalid_discovery", "Discovery response is malformed.");
|
|
45591
|
+
}
|
|
45592
|
+
for (const service of parsed.data.services) {
|
|
45593
|
+
buildTargets(service);
|
|
45594
|
+
}
|
|
45595
|
+
const resolveListing = (serviceId, endpointName) => {
|
|
45596
|
+
const service = parsed.data.services.find((candidate) => candidate.id === serviceId);
|
|
45597
|
+
if (!service) {
|
|
45598
|
+
throw new DiscoveryCatalogError(
|
|
45599
|
+
"service_not_found",
|
|
45600
|
+
`No payable endpoint found for service ${JSON.stringify(serviceId)}.`,
|
|
45601
|
+
serviceId
|
|
45602
|
+
);
|
|
45603
|
+
}
|
|
45604
|
+
return { service, endpoint: resolveTarget(service, endpointName) };
|
|
45605
|
+
};
|
|
45606
|
+
return {
|
|
45607
|
+
services: parsed.data.services,
|
|
45608
|
+
resolve: (serviceId, endpointName) => resolveListing(serviceId, endpointName).endpoint,
|
|
45609
|
+
resolveListing
|
|
45610
|
+
};
|
|
45611
|
+
}
|
|
45612
|
+
function resolveTarget(service, endpointName) {
|
|
45613
|
+
const { targets, targetsByName } = buildTargets(service);
|
|
45614
|
+
if (endpointName !== void 0) {
|
|
45615
|
+
const selected = targetsByName.get(endpointName.trim());
|
|
45616
|
+
if (!selected) {
|
|
45617
|
+
throw new DiscoveryCatalogError(
|
|
45618
|
+
"endpoint_not_found",
|
|
45619
|
+
`Service ${JSON.stringify(service.id)} has no endpoint ${JSON.stringify(endpointName)}. Available endpoints: ${[...targetsByName.keys()].join(", ")}.`,
|
|
45620
|
+
service.id
|
|
45621
|
+
);
|
|
45622
|
+
}
|
|
45623
|
+
return { ...selected };
|
|
45624
|
+
}
|
|
45625
|
+
if (targets.size !== 1) {
|
|
45626
|
+
const paymentNetworks = service.endpoints.flatMap(
|
|
45627
|
+
(endpoint) => typeof endpoint.payment?.network === "string" ? [endpoint.payment.network] : []
|
|
45628
|
+
);
|
|
45629
|
+
throw new DiscoveryCatalogError(
|
|
45630
|
+
"ambiguous_default",
|
|
45631
|
+
`Service ${JSON.stringify(service.id)} has ${targets.size} distinct payable endpoints. Choose one with endpoint: ${[...targetsByName.keys()].join(", ")}.`,
|
|
45632
|
+
service.id,
|
|
45633
|
+
paymentNetworks.length === service.endpoints.length ? paymentNetworks : void 0
|
|
45634
|
+
);
|
|
45635
|
+
}
|
|
45636
|
+
return targets.values().next().value;
|
|
45637
|
+
}
|
|
45638
|
+
function buildTargets(service) {
|
|
45639
|
+
if (service.endpoints.length === 0) {
|
|
45640
|
+
throw new DiscoveryCatalogError(
|
|
45641
|
+
"no_endpoint",
|
|
45642
|
+
`Service ${JSON.stringify(service.id)} has no payable endpoint.`,
|
|
45643
|
+
service.id
|
|
45644
|
+
);
|
|
45645
|
+
}
|
|
45646
|
+
const namedEndpoints = [...service.endpoints].sort(
|
|
45647
|
+
(left, right) => compareNames(left.name.trim(), right.name.trim())
|
|
45648
|
+
);
|
|
45649
|
+
const names = /* @__PURE__ */ new Set();
|
|
45650
|
+
const targets = /* @__PURE__ */ new Map();
|
|
45651
|
+
const targetsByName = /* @__PURE__ */ new Map();
|
|
45652
|
+
for (const endpoint of namedEndpoints) {
|
|
45653
|
+
const name = endpoint.name.trim();
|
|
45654
|
+
if (!name) {
|
|
45655
|
+
throw new DiscoveryCatalogError(
|
|
45656
|
+
"invalid_endpoint_name",
|
|
45657
|
+
`Service ${JSON.stringify(service.id)} has a blank endpoint name.`,
|
|
45658
|
+
service.id
|
|
45659
|
+
);
|
|
45660
|
+
}
|
|
45661
|
+
if (names.has(name)) {
|
|
45662
|
+
throw new DiscoveryCatalogError(
|
|
45663
|
+
"duplicate_endpoint_name",
|
|
45664
|
+
`Service ${JSON.stringify(service.id)} has duplicate endpoint name ${JSON.stringify(name)}.`,
|
|
45665
|
+
service.id
|
|
45666
|
+
);
|
|
45667
|
+
}
|
|
45668
|
+
names.add(name);
|
|
45669
|
+
const method = endpoint.method.trim().toUpperCase();
|
|
45670
|
+
if (!method) {
|
|
45671
|
+
throw new DiscoveryCatalogError(
|
|
45672
|
+
"blank_method",
|
|
45673
|
+
`Service ${JSON.stringify(service.id)} has a blank endpoint method.`,
|
|
45674
|
+
service.id
|
|
45675
|
+
);
|
|
45676
|
+
}
|
|
45677
|
+
const url2 = new URL(endpoint.url);
|
|
45678
|
+
if (url2.protocol !== "http:" && url2.protocol !== "https:") {
|
|
45679
|
+
throw new DiscoveryCatalogError(
|
|
45680
|
+
"malformed_url",
|
|
45681
|
+
`Service ${JSON.stringify(service.id)} has a non-HTTP endpoint URL.`,
|
|
45682
|
+
service.id
|
|
45683
|
+
);
|
|
45684
|
+
}
|
|
45685
|
+
const transportKey = `${method}\0${endpoint.url}`;
|
|
45686
|
+
const normalized = { ...endpoint, name, method };
|
|
45687
|
+
targetsByName.set(name, normalized);
|
|
45688
|
+
if (!targets.has(transportKey)) targets.set(transportKey, normalized);
|
|
45689
|
+
}
|
|
45690
|
+
return { targets, targetsByName };
|
|
45691
|
+
}
|
|
45692
|
+
function compareNames(left, right) {
|
|
45693
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
45694
|
+
}
|
|
45695
|
+
function pathIndexAfter(path, key) {
|
|
45696
|
+
const keyIndex = path.indexOf(key);
|
|
45697
|
+
const candidate = path[keyIndex + 1];
|
|
45698
|
+
return typeof candidate === "number" ? candidate : void 0;
|
|
45699
|
+
}
|
|
45700
|
+
function rawServiceId(raw, serviceIndex) {
|
|
45701
|
+
if (serviceIndex === void 0 || typeof raw !== "object" || raw === null) {
|
|
45702
|
+
return void 0;
|
|
45703
|
+
}
|
|
45704
|
+
const services = Reflect.get(raw, "services");
|
|
45705
|
+
if (!Array.isArray(services)) {
|
|
45706
|
+
return void 0;
|
|
45707
|
+
}
|
|
45708
|
+
const service = services[serviceIndex];
|
|
45709
|
+
if (typeof service !== "object" || service === null) {
|
|
45710
|
+
return void 0;
|
|
45711
|
+
}
|
|
45712
|
+
const id = Reflect.get(service, "id");
|
|
45713
|
+
return typeof id === "string" ? id : void 0;
|
|
45714
|
+
}
|
|
45715
|
+
|
|
45649
45716
|
// src/sweep.ts
|
|
45650
45717
|
var ERC20_ABI = [
|
|
45651
45718
|
{
|
|
@@ -46497,7 +46564,7 @@ var configSchema = external_exports.object({
|
|
|
46497
46564
|
}
|
|
46498
46565
|
for (const [network, configured] of Object.entries(config2.networks)) {
|
|
46499
46566
|
if (isSolanaNetwork(network)) {
|
|
46500
|
-
if (configured.usdc !==
|
|
46567
|
+
if (configured.usdc !== NETWORKS2[SOLANA_MAINNET_CAIP2].usdc) {
|
|
46501
46568
|
context.addIssue({
|
|
46502
46569
|
code: "custom",
|
|
46503
46570
|
path: ["networks", network, "usdc"],
|
|
@@ -46508,7 +46575,7 @@ var configSchema = external_exports.object({
|
|
|
46508
46575
|
}
|
|
46509
46576
|
try {
|
|
46510
46577
|
const usdc = getAddress(configured.usdc);
|
|
46511
|
-
if ((network === ARC_MAINNET_CAIP2 || network === ARC_TESTNET_CAIP2) && usdc !== getAddress(
|
|
46578
|
+
if ((network === ARC_MAINNET_CAIP2 || network === ARC_TESTNET_CAIP2) && usdc !== getAddress(NETWORKS2[network].usdc)) {
|
|
46512
46579
|
context.addIssue({
|
|
46513
46580
|
code: "custom",
|
|
46514
46581
|
path: ["networks", network, "usdc"],
|
|
@@ -46535,7 +46602,8 @@ function getVapiPaths(directory = process.env.VAPI_HOME?.trim() || join2(homedir
|
|
|
46535
46602
|
keystore: join2(directory, "keystore.json"),
|
|
46536
46603
|
receipts: join2(directory, "receipts.jsonl"),
|
|
46537
46604
|
searches: join2(directory, "searches.jsonl"),
|
|
46538
|
-
ledger: join2(directory, "spend-ledger.json")
|
|
46605
|
+
ledger: join2(directory, "spend-ledger.json"),
|
|
46606
|
+
updateCheck: join2(directory, "update-check.json")
|
|
46539
46607
|
};
|
|
46540
46608
|
}
|
|
46541
46609
|
var getAgentCashPaths = getVapiPaths;
|
|
@@ -46660,15 +46728,15 @@ function getDefaultConfig(source = process.env, options = {}) {
|
|
|
46660
46728
|
const tasksEscrowFactoryOverrides = tasksFactoryOverridesFromEnv(source);
|
|
46661
46729
|
if (requested.has("base") || requested.has(BASE_MAINNET_CAIP2)) {
|
|
46662
46730
|
networks[BASE_MAINNET_CAIP2] = {
|
|
46663
|
-
rpcUrl: source.BASE_RPC_URL?.trim() ||
|
|
46664
|
-
usdc:
|
|
46731
|
+
rpcUrl: source.BASE_RPC_URL?.trim() || NETWORKS2[BASE_MAINNET_CAIP2].publicRpcUrl,
|
|
46732
|
+
usdc: NETWORKS2[BASE_MAINNET_CAIP2].usdc
|
|
46665
46733
|
};
|
|
46666
46734
|
}
|
|
46667
46735
|
const arcMainnetRpcUrl = source.ARC_RPC_URL?.trim();
|
|
46668
46736
|
if (arcMainnetRpcUrl || requested.has("arc") || requested.has(ARC_MAINNET_CAIP2)) {
|
|
46669
46737
|
networks[ARC_MAINNET_CAIP2] = {
|
|
46670
|
-
rpcUrl: arcMainnetRpcUrl ||
|
|
46671
|
-
usdc:
|
|
46738
|
+
rpcUrl: arcMainnetRpcUrl || NETWORKS2[ARC_MAINNET_CAIP2].publicRpcUrl,
|
|
46739
|
+
usdc: NETWORKS2[ARC_MAINNET_CAIP2].usdc
|
|
46672
46740
|
};
|
|
46673
46741
|
}
|
|
46674
46742
|
const arcTestnetRpcUrl = source.ARC_TESTNET_RPC_URL?.trim();
|
|
@@ -46680,14 +46748,14 @@ function getDefaultConfig(source = process.env, options = {}) {
|
|
|
46680
46748
|
}
|
|
46681
46749
|
networks[ARC_TESTNET_CAIP2] = {
|
|
46682
46750
|
rpcUrl: arcTestnetRpcUrl,
|
|
46683
|
-
usdc:
|
|
46751
|
+
usdc: NETWORKS2[ARC_TESTNET_CAIP2].usdc
|
|
46684
46752
|
};
|
|
46685
46753
|
}
|
|
46686
46754
|
const solanaRpcUrl = source.SOLANA_RPC_URL?.trim();
|
|
46687
46755
|
if (solanaRpcUrl || requested.has("solana") || requested.has(SOLANA_MAINNET_CAIP2)) {
|
|
46688
46756
|
networks[SOLANA_MAINNET_CAIP2] = {
|
|
46689
|
-
rpcUrl: solanaRpcUrl ||
|
|
46690
|
-
usdc:
|
|
46757
|
+
rpcUrl: solanaRpcUrl || NETWORKS2[SOLANA_MAINNET_CAIP2].publicRpcUrl,
|
|
46758
|
+
usdc: NETWORKS2[SOLANA_MAINNET_CAIP2].usdc
|
|
46691
46759
|
};
|
|
46692
46760
|
}
|
|
46693
46761
|
return {
|
|
@@ -46745,21 +46813,21 @@ Run vapi init to write the new URLs to ${path}.`
|
|
|
46745
46813
|
if (arcMainnetRpcUrl) {
|
|
46746
46814
|
const existing = config2.networks[ARC_MAINNET_CAIP2];
|
|
46747
46815
|
config2.networks[ARC_MAINNET_CAIP2] = {
|
|
46748
|
-
...existing ?? { usdc:
|
|
46816
|
+
...existing ?? { usdc: NETWORKS2[ARC_MAINNET_CAIP2].usdc },
|
|
46749
46817
|
rpcUrl: arcMainnetRpcUrl
|
|
46750
46818
|
};
|
|
46751
46819
|
}
|
|
46752
46820
|
if (arcTestnetRpcUrl) {
|
|
46753
46821
|
const existing = config2.networks[ARC_TESTNET_CAIP2];
|
|
46754
46822
|
config2.networks[ARC_TESTNET_CAIP2] = {
|
|
46755
|
-
...existing ?? { usdc:
|
|
46823
|
+
...existing ?? { usdc: NETWORKS2[ARC_TESTNET_CAIP2].usdc },
|
|
46756
46824
|
rpcUrl: arcTestnetRpcUrl
|
|
46757
46825
|
};
|
|
46758
46826
|
}
|
|
46759
46827
|
if (solanaRpcUrl) {
|
|
46760
46828
|
config2.networks[SOLANA_MAINNET_CAIP2] = {
|
|
46761
46829
|
rpcUrl: solanaRpcUrl,
|
|
46762
|
-
usdc: config2.networks[SOLANA_MAINNET_CAIP2]?.usdc ??
|
|
46830
|
+
usdc: config2.networks[SOLANA_MAINNET_CAIP2]?.usdc ?? NETWORKS2[SOLANA_MAINNET_CAIP2].usdc
|
|
46763
46831
|
};
|
|
46764
46832
|
}
|
|
46765
46833
|
if (registryUrl) {
|
|
@@ -46772,7 +46840,7 @@ Run vapi init to write the new URLs to ${path}.`
|
|
|
46772
46840
|
for (const [network, configured] of Object.entries(config2.networks)) {
|
|
46773
46841
|
configured.rpcUrl = configured.rpcUrl.trim();
|
|
46774
46842
|
configured.usdc = configured.usdc.trim();
|
|
46775
|
-
if (isSolanaNetwork(network) && configured.usdc !==
|
|
46843
|
+
if (isSolanaNetwork(network) && configured.usdc !== NETWORKS2[SOLANA_MAINNET_CAIP2].usdc) {
|
|
46776
46844
|
throw new Error(`Network ${network} must use canonical Solana mainnet USDC.`);
|
|
46777
46845
|
}
|
|
46778
46846
|
if (!configured.rpcUrl) delete config2.networks[network];
|
|
@@ -46828,14 +46896,14 @@ async function enableDefaultNetwork(network, path = getVapiPaths().config, sourc
|
|
|
46828
46896
|
const config2 = await loadConfig(path, source);
|
|
46829
46897
|
if (network === "solana") {
|
|
46830
46898
|
config2.networks[SOLANA_MAINNET_CAIP2] = {
|
|
46831
|
-
rpcUrl: source.SOLANA_RPC_URL?.trim() ||
|
|
46832
|
-
usdc:
|
|
46899
|
+
rpcUrl: source.SOLANA_RPC_URL?.trim() || NETWORKS2[SOLANA_MAINNET_CAIP2].publicRpcUrl,
|
|
46900
|
+
usdc: NETWORKS2[SOLANA_MAINNET_CAIP2].usdc
|
|
46833
46901
|
};
|
|
46834
46902
|
} else {
|
|
46835
46903
|
const existing = config2.networks[ARC_MAINNET_CAIP2];
|
|
46836
46904
|
config2.networks[ARC_MAINNET_CAIP2] = {
|
|
46837
|
-
...existing ?? { usdc:
|
|
46838
|
-
rpcUrl: source.ARC_RPC_URL?.trim() ||
|
|
46905
|
+
...existing ?? { usdc: NETWORKS2[ARC_MAINNET_CAIP2].usdc },
|
|
46906
|
+
rpcUrl: source.ARC_RPC_URL?.trim() || NETWORKS2[ARC_MAINNET_CAIP2].publicRpcUrl
|
|
46839
46907
|
};
|
|
46840
46908
|
}
|
|
46841
46909
|
await writeConfigFile(path, config2);
|
|
@@ -70954,6 +71022,8 @@ var VAULT_KEY_ACCOUNT = "vault-key";
|
|
|
70954
71022
|
var VAULT_SESSION_ACCOUNT = "vault-session";
|
|
70955
71023
|
var DEVICE_KEY_LENGTH = 32;
|
|
70956
71024
|
var DEFAULT_SESSION_HOURS = 8;
|
|
71025
|
+
var RESTORE_GAP_LIMIT = 5;
|
|
71026
|
+
var MAX_RESTORE_ACCOUNTS = 1e4;
|
|
70957
71027
|
var BASE64_PATTERN = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u;
|
|
70958
71028
|
var deviceKeyOperations = Promise.resolve();
|
|
70959
71029
|
var sessionSchema = external_exports.object({
|
|
@@ -71103,26 +71173,41 @@ async function restoreVault(args) {
|
|
|
71103
71173
|
throw new VaultError("corrupt", "That recovery phrase is not valid.", { cause: error61 });
|
|
71104
71174
|
}
|
|
71105
71175
|
let seed;
|
|
71106
|
-
|
|
71176
|
+
if (args.accountCount !== void 0 && (!Number.isSafeInteger(args.accountCount) || args.accountCount < 1 || args.accountCount > MAX_RESTORE_ACCOUNTS)) {
|
|
71177
|
+
throw new VaultError(
|
|
71178
|
+
"corrupt",
|
|
71179
|
+
`Account count must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
|
|
71180
|
+
);
|
|
71181
|
+
}
|
|
71182
|
+
let discoveredAccounts = args.accountCount ?? 0;
|
|
71183
|
+
let scannedAddresses = 0;
|
|
71107
71184
|
try {
|
|
71108
71185
|
seed = phraseToSeed(phrase);
|
|
71109
71186
|
} catch (error61) {
|
|
71110
71187
|
throw asVaultError2(error61, "Unable to derive an account while restoring the vault.");
|
|
71111
71188
|
}
|
|
71112
71189
|
try {
|
|
71113
|
-
for (let index2 = 0; ; index2 += 1) {
|
|
71190
|
+
for (let index2 = 0, emptyRun = 0; args.accountCount === void 0; index2 += 1) {
|
|
71114
71191
|
let address2;
|
|
71115
71192
|
try {
|
|
71116
71193
|
address2 = privateKeyToAccount(deriveEvmPrivateKey(seed, `m/44'/60'/0'/0/${index2}`)).address;
|
|
71117
71194
|
} catch (error61) {
|
|
71118
71195
|
throw asVaultError2(error61, "Unable to derive an account while restoring the vault.");
|
|
71119
71196
|
}
|
|
71120
|
-
|
|
71121
|
-
|
|
71197
|
+
const funded = await args.probe(address2);
|
|
71198
|
+
scannedAddresses += 1;
|
|
71199
|
+
if (funded) {
|
|
71200
|
+
discoveredAccounts = index2 + 1;
|
|
71201
|
+
emptyRun = 0;
|
|
71202
|
+
} else {
|
|
71203
|
+
emptyRun += 1;
|
|
71204
|
+
if (emptyRun === RESTORE_GAP_LIMIT) break;
|
|
71205
|
+
}
|
|
71122
71206
|
}
|
|
71123
71207
|
} finally {
|
|
71124
71208
|
seed.fill(0);
|
|
71125
71209
|
}
|
|
71210
|
+
args.onScanComplete?.(scannedAddresses);
|
|
71126
71211
|
let vault;
|
|
71127
71212
|
try {
|
|
71128
71213
|
vault = await createVault({ path: args.path, key: args.key, phrase, now: args.now });
|
|
@@ -71611,6 +71696,26 @@ var WalletStore = class _WalletStore {
|
|
|
71611
71696
|
}
|
|
71612
71697
|
);
|
|
71613
71698
|
}
|
|
71699
|
+
/** Checks a cached signer's current vault session without decrypting its account again. */
|
|
71700
|
+
async assertSigningAuthority(name) {
|
|
71701
|
+
const stored = await this.readVaultUnlocked();
|
|
71702
|
+
if (!stored?.protected || !stored.accounts.some((account) => account.name === name)) return;
|
|
71703
|
+
try {
|
|
71704
|
+
const key = await unlockProtectedVault({
|
|
71705
|
+
path: this.vaultPath,
|
|
71706
|
+
secrets: this.secrets,
|
|
71707
|
+
env: this.environment,
|
|
71708
|
+
now: () => this.now()
|
|
71709
|
+
});
|
|
71710
|
+
key.fill(0);
|
|
71711
|
+
} catch (error61) {
|
|
71712
|
+
this.dropVaultCache();
|
|
71713
|
+
if (error61 instanceof VaultError && error61.code === "password_required") {
|
|
71714
|
+
throw new KeystoreError(VAULT_LOCKED_MESSAGE, { cause: error61 });
|
|
71715
|
+
}
|
|
71716
|
+
throw error61;
|
|
71717
|
+
}
|
|
71718
|
+
}
|
|
71614
71719
|
/** Returns one wallet's vault signer, migrating its legacy keystore if needed. */
|
|
71615
71720
|
async unlock(name, passphrase) {
|
|
71616
71721
|
const wallet = this.resolve({ name });
|
|
@@ -76900,7 +77005,7 @@ function createRunBudget(args) {
|
|
|
76900
77005
|
import { mkdir as mkdir15, writeFile as writeFile8 } from "node:fs/promises";
|
|
76901
77006
|
import { arch, platform, release } from "node:os";
|
|
76902
77007
|
import { join as join13 } from "node:path";
|
|
76903
|
-
var VAPI_CLIENT_VERSION = "0.9.
|
|
77008
|
+
var VAPI_CLIENT_VERSION = "0.9.4";
|
|
76904
77009
|
async function createSupportReport(options) {
|
|
76905
77010
|
const message = options.message.trim();
|
|
76906
77011
|
if (!message) throw new Error("Support report message must not be empty.");
|
|
@@ -77173,7 +77278,7 @@ async function completeX402Payment(args) {
|
|
|
77173
77278
|
let paidAttempt;
|
|
77174
77279
|
const requestStarted = nowMs();
|
|
77175
77280
|
try {
|
|
77176
|
-
paidAttempt = await args.send(paidRequest);
|
|
77281
|
+
paidAttempt = await args.send(paidRequest, quote);
|
|
77177
77282
|
} catch (error61) {
|
|
77178
77283
|
if (trace) trace.phases.requestMs = elapsed(nowMs, requestStarted);
|
|
77179
77284
|
throw settlementUnknown(
|
|
@@ -77191,7 +77296,7 @@ async function completeX402Payment(args) {
|
|
|
77191
77296
|
const settleStarted = nowMs();
|
|
77192
77297
|
const settlement = parseSettlementResponse(paidResponse.headers);
|
|
77193
77298
|
const settlementOutcome = classifySettlement(settlement);
|
|
77194
|
-
const receiptSettlement =
|
|
77299
|
+
const receiptSettlement = sanitizeReturnedValue(settlement, receiptSecrets);
|
|
77195
77300
|
if (trace) {
|
|
77196
77301
|
const transaction = settlementTransaction(receiptSettlement);
|
|
77197
77302
|
const explorerUrl = transaction ? explorerTransactionUrl(quote.accepted.network, transaction) : void 0;
|
|
@@ -77268,6 +77373,7 @@ async function completeX402Payment(args) {
|
|
|
77268
77373
|
trace.phases.requestMs = (trace.phases.requestMs ?? 0) + elapsed(nowMs, bodyStarted);
|
|
77269
77374
|
}
|
|
77270
77375
|
}
|
|
77376
|
+
body = sanitizeReturnedValue(body, receiptSecrets);
|
|
77271
77377
|
}
|
|
77272
77378
|
const result = {
|
|
77273
77379
|
response: paidResponse,
|
|
@@ -77276,7 +77382,11 @@ async function completeX402Payment(args) {
|
|
|
77276
77382
|
quote,
|
|
77277
77383
|
payer,
|
|
77278
77384
|
...payment.paymentId ? { paymentId: payment.paymentId } : {},
|
|
77279
|
-
|
|
77385
|
+
paymentProof: sanitizeReturnedValue(
|
|
77386
|
+
paidResponse.headers.get("x-vapi-payment-proof"),
|
|
77387
|
+
receiptSecrets
|
|
77388
|
+
),
|
|
77389
|
+
settlement: receiptSettlement,
|
|
77280
77390
|
settlementOutcome
|
|
77281
77391
|
};
|
|
77282
77392
|
if (settlementOutcome === "succeeded" && args.ceilingSweep) {
|
|
@@ -77413,19 +77523,70 @@ function sanitizeThrownError(error61, secrets) {
|
|
|
77413
77523
|
}
|
|
77414
77524
|
return new Error(message, cause === void 0 ? void 0 : { cause });
|
|
77415
77525
|
}
|
|
77416
|
-
function
|
|
77526
|
+
function sanitizeReturnedValue(value, secrets) {
|
|
77417
77527
|
if (typeof value === "string") return redactKnownSecrets(value, secrets);
|
|
77418
|
-
if (value
|
|
77419
|
-
|
|
77420
|
-
|
|
77421
|
-
|
|
77528
|
+
if (!isPlainReturnedContainer(value)) return value;
|
|
77529
|
+
const nodes = /* @__PURE__ */ new WeakMap();
|
|
77530
|
+
const ordered = [];
|
|
77531
|
+
const nodeFor = (source) => {
|
|
77532
|
+
const existing = nodes.get(source);
|
|
77533
|
+
if (existing) return existing;
|
|
77534
|
+
const copy = Array.isArray(source) ? new Array(source.length) : Object.create(Object.getPrototypeOf(source));
|
|
77535
|
+
const node2 = { source, copy, parents: /* @__PURE__ */ new Set(), changed: false };
|
|
77536
|
+
nodes.set(source, node2);
|
|
77537
|
+
ordered.push(node2);
|
|
77538
|
+
return node2;
|
|
77539
|
+
};
|
|
77540
|
+
const root = nodeFor(value);
|
|
77541
|
+
for (let index2 = 0; index2 < ordered.length; index2 += 1) {
|
|
77542
|
+
const node2 = ordered[index2];
|
|
77543
|
+
for (const [key, item] of Object.entries(node2.source)) {
|
|
77544
|
+
const safeKey = Array.isArray(node2.source) ? key : redactKnownSecrets(key, secrets);
|
|
77545
|
+
if (safeKey !== key) node2.changed = true;
|
|
77546
|
+
if (typeof item === "string") {
|
|
77547
|
+
const safeItem = redactKnownSecrets(item, secrets);
|
|
77548
|
+
defineReturnedProperty(node2.copy, safeKey, safeItem);
|
|
77549
|
+
if (safeItem !== item) node2.changed = true;
|
|
77550
|
+
} else if (isPlainReturnedContainer(item)) {
|
|
77551
|
+
const child = nodeFor(item);
|
|
77552
|
+
child.parents.add(node2);
|
|
77553
|
+
defineReturnedProperty(node2.copy, safeKey, child.copy);
|
|
77554
|
+
} else {
|
|
77555
|
+
defineReturnedProperty(node2.copy, safeKey, item);
|
|
77556
|
+
}
|
|
77557
|
+
}
|
|
77422
77558
|
}
|
|
77423
|
-
|
|
77424
|
-
|
|
77425
|
-
|
|
77426
|
-
|
|
77427
|
-
|
|
77428
|
-
|
|
77559
|
+
const changed = ordered.filter((node2) => node2.changed);
|
|
77560
|
+
for (let index2 = 0; index2 < changed.length; index2 += 1) {
|
|
77561
|
+
for (const parent of changed[index2].parents) {
|
|
77562
|
+
if (parent.changed) continue;
|
|
77563
|
+
parent.changed = true;
|
|
77564
|
+
changed.push(parent);
|
|
77565
|
+
}
|
|
77566
|
+
}
|
|
77567
|
+
for (const node2 of ordered) {
|
|
77568
|
+
for (const [key, item] of Object.entries(node2.source)) {
|
|
77569
|
+
if (!isPlainReturnedContainer(item)) continue;
|
|
77570
|
+
const safeKey = Array.isArray(node2.source) ? key : redactKnownSecrets(key, secrets);
|
|
77571
|
+
const child = nodes.get(item);
|
|
77572
|
+
defineReturnedProperty(node2.copy, safeKey, child.changed ? child.copy : item);
|
|
77573
|
+
}
|
|
77574
|
+
}
|
|
77575
|
+
return root.changed ? root.copy : value;
|
|
77576
|
+
}
|
|
77577
|
+
function defineReturnedProperty(target, key, value) {
|
|
77578
|
+
Object.defineProperty(target, key, {
|
|
77579
|
+
value,
|
|
77580
|
+
enumerable: true,
|
|
77581
|
+
configurable: true,
|
|
77582
|
+
writable: true
|
|
77583
|
+
});
|
|
77584
|
+
}
|
|
77585
|
+
function isPlainReturnedContainer(value) {
|
|
77586
|
+
if (Array.isArray(value)) return true;
|
|
77587
|
+
if (value === null || typeof value !== "object") return false;
|
|
77588
|
+
const prototype = Object.getPrototypeOf(value);
|
|
77589
|
+
return prototype === Object.prototype || prototype === null;
|
|
77429
77590
|
}
|
|
77430
77591
|
function redactKnownSecrets(value, secrets) {
|
|
77431
77592
|
let redacted = value;
|
|
@@ -77460,9 +77621,7 @@ function possibleSettlement(quote, payment, payer, receipt) {
|
|
|
77460
77621
|
payTo: quote.accepted.payTo,
|
|
77461
77622
|
payer,
|
|
77462
77623
|
...payment.paymentId ? { paymentId: payment.paymentId } : {},
|
|
77463
|
-
...isSvmPaymentRequirements(quote.accepted) ? {
|
|
77464
|
-
authorizationTransaction: "transaction" in payment.payload.payload ? payment.payload.payload.transaction : ""
|
|
77465
|
-
} : "authorization" in payment.payload.payload ? {
|
|
77624
|
+
...isSvmPaymentRequirements(quote.accepted) ? {} : "authorization" in payment.payload.payload ? {
|
|
77466
77625
|
authorizationNonce: payment.payload.payload.authorization.nonce,
|
|
77467
77626
|
authorizationExpiresAt: payment.payload.payload.authorization.validBefore
|
|
77468
77627
|
} : {},
|
|
@@ -78022,6 +78181,7 @@ var searchEventSchema = external_exports.strictObject({
|
|
|
78022
78181
|
source: external_exports.string().min(1),
|
|
78023
78182
|
latencyMs: external_exports.number().nonnegative().finite(),
|
|
78024
78183
|
count: external_exports.number().int().nonnegative(),
|
|
78184
|
+
dropped: external_exports.number().int().nonnegative().optional(),
|
|
78025
78185
|
error: external_exports.string().optional()
|
|
78026
78186
|
})
|
|
78027
78187
|
),
|
|
@@ -81256,13 +81416,15 @@ export {
|
|
|
81256
81416
|
MARKETPLACE_EXECUTION_METHODS,
|
|
81257
81417
|
MARKETPLACE_KINDS,
|
|
81258
81418
|
MARKETPLACE_RANKING_VERSION,
|
|
81419
|
+
MAX_RESTORE_ACCOUNTS,
|
|
81259
81420
|
MovementError,
|
|
81260
|
-
NETWORKS,
|
|
81421
|
+
NETWORKS2 as NETWORKS,
|
|
81261
81422
|
ONRAMP_FALLBACK_INSTRUCTIONS,
|
|
81262
81423
|
ONRAMP_NETWORK,
|
|
81263
81424
|
PASSPHRASE_ENVIRONMENT_VARIABLE,
|
|
81264
81425
|
PROVENANCES,
|
|
81265
81426
|
RELAY_MAX_PER_TRANSFER_ATOMIC,
|
|
81427
|
+
RESTORE_GAP_LIMIT,
|
|
81266
81428
|
ROUTER_TOPUP_TIERS,
|
|
81267
81429
|
RUN_ID_PATTERN,
|
|
81268
81430
|
RunBudgetError,
|
|
@@ -81272,6 +81434,7 @@ export {
|
|
|
81272
81434
|
SIGN_IN_WITH_X,
|
|
81273
81435
|
SIWxError,
|
|
81274
81436
|
SOLANA_DERIVATION_PATH,
|
|
81437
|
+
SOLANA_DEVNET_CAIP2,
|
|
81275
81438
|
SOLANA_MAINNET_CAIP2,
|
|
81276
81439
|
SOLANA_MAINNET_USDC,
|
|
81277
81440
|
STATS_RANGES,
|
|
@@ -81395,6 +81558,7 @@ export {
|
|
|
81395
81558
|
getNetworkDefinition,
|
|
81396
81559
|
getVapiPaths,
|
|
81397
81560
|
isCallableListing,
|
|
81561
|
+
isDiscoveryCatalogError,
|
|
81398
81562
|
isEvmPaymentRequirements,
|
|
81399
81563
|
isMirroredHit,
|
|
81400
81564
|
isMissingFile,
|
|
@@ -81427,6 +81591,7 @@ export {
|
|
|
81427
81591
|
lowerAccountCaps,
|
|
81428
81592
|
marketplaceBadgeCodeSchema,
|
|
81429
81593
|
marketplaceBadgeSchema,
|
|
81594
|
+
marketplaceDiscoveryEnvelopeSchema,
|
|
81430
81595
|
marketplaceDiscoveryInputSchema,
|
|
81431
81596
|
marketplaceDiscoveryPageSchema,
|
|
81432
81597
|
marketplaceExecutionMethodSchema,
|