@oneshot-agent/sdk 0.32.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -2
- package/dist/errors.d.ts +14 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +19 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +49 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +225 -21
- package/dist/index.js.map +1 -1
- package/dist/providers/read-only.d.ts +14 -0
- package/dist/providers/read-only.d.ts.map +1 -0
- package/dist/providers/read-only.js +21 -0
- package/dist/providers/read-only.js.map +1 -0
- package/dist/types.d.ts +43 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -182,7 +182,12 @@ mainnet only.
|
|
|
182
182
|
|
|
183
183
|
```typescript
|
|
184
184
|
interface OneShotConfig {
|
|
185
|
-
privateKey
|
|
185
|
+
privateKey?: string; // Option A: raw key
|
|
186
|
+
cdp?: boolean; // Option B: Coinbase CDP server wallet
|
|
187
|
+
walletProvider?: WalletProvider; // Option C: bring your own signer
|
|
188
|
+
accessToken?: string; // Option D: credits-only session, no key (see Access tokens)
|
|
189
|
+
address?: string; // With accessToken in the sync constructor; create() resolves it
|
|
190
|
+
defaultHeaders?: Record<string, string>; // Sent on every request
|
|
186
191
|
baseUrl?: string; // Override API URL
|
|
187
192
|
rpcUrl?: string; // Override RPC URL
|
|
188
193
|
debug?: boolean; // Enable logging
|
|
@@ -257,6 +262,31 @@ Every request identifies you by your wallet address (`X-Agent-ID`). Paid tools a
|
|
|
257
262
|
|
|
258
263
|
This is fully automatic — you don't do anything beyond providing your `privateKey`. **Requires SDK ≥ 0.25.0.** Older SDKs (or raw HTTP callers) will keep working until the API enables enforcement, after which they must send a valid `x-agent-proof`; upgrade to stay ahead of it.
|
|
259
264
|
|
|
265
|
+
### Access tokens (credits-only sessions)
|
|
266
|
+
|
|
267
|
+
Some code can't hold your wallet key — a hosted MCP client such as Grok Bot, a cloud
|
|
268
|
+
runner, a third-party agent platform. For those, mint an **access token** from a wallet
|
|
269
|
+
session and hand it over instead:
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
// From a wallet session (once):
|
|
273
|
+
const { token } = await agent.createAccessToken({ name: 'grok-bot' });
|
|
274
|
+
|
|
275
|
+
// In the hosted environment:
|
|
276
|
+
const hosted = await OneShot.create({ accessToken: token }); // resolves the wallet address
|
|
277
|
+
await hosted.webSearch({ query: '…' }); // billed to the agent's credits
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
An access-token session identifies the agent with the token (no `x-agent-proof`), **pays
|
|
281
|
+
every call from the agent's prepaid credit balance**, and never signs x402. When credits
|
|
282
|
+
can't cover a call it throws `InsufficientCreditsError` (`required`, `balance`,
|
|
283
|
+
`shortfall`) — top up and retry. Budgets set on the agent still apply, with credit-funded
|
|
284
|
+
spend counted; they are **read-only** from a token session (`agent.budgets()` works,
|
|
285
|
+
passing `budgets` to the constructor throws). A token cannot mint, list, or revoke
|
|
286
|
+
tokens; do that from the wallet session (`listAccessTokens()`, `revokeAccessToken(id)`).
|
|
287
|
+
`accessToken` is exclusive with `privateKey` / `cdp` / `walletProvider` and with
|
|
288
|
+
`currency: 'ETH'`. **Requires SDK ≥ 0.33.0.**
|
|
289
|
+
|
|
260
290
|
## Tool Options
|
|
261
291
|
|
|
262
292
|
All methods accept these common options:
|
|
@@ -605,7 +635,7 @@ The signal **cannot** cancel:
|
|
|
605
635
|
## Links
|
|
606
636
|
|
|
607
637
|
- [Documentation](https://docs.oneshotagent.com)
|
|
608
|
-
- [MCP Server](https://www.npmjs.com/package/@oneshot-agent/mcp-server) — Claude Desktop, Cursor, Claude Code
|
|
638
|
+
- [MCP Server](https://www.npmjs.com/package/@oneshot-agent/mcp-server) — Claude Desktop, Cursor, Claude Code (local), or the hosted endpoint at `https://win.oneshotagent.com/mcp` with an access token
|
|
609
639
|
- [Python SDK (LangChain)](https://pypi.org/project/langchain-oneshot/) — 26 tools as LangChain BaseTool
|
|
610
640
|
- [Python SDK (Core)](https://pypi.org/project/oneshot-python/) — HTTP client with x402 payments
|
|
611
641
|
- [Pricing](https://docs.oneshotagent.com/pricing)
|
package/dist/errors.d.ts
CHANGED
|
@@ -103,4 +103,18 @@ export declare class BudgetSyncError extends OneShotError {
|
|
|
103
103
|
readonly responseBody?: string | undefined;
|
|
104
104
|
constructor(message: string, status?: number | undefined, responseBody?: string | undefined);
|
|
105
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* An access-token session's credit balance cannot cover the call (HTTP 402
|
|
108
|
+
* `insufficient_credits`). Access-token sessions pay from credits only and
|
|
109
|
+
* never sign x402, so this is the end of the road for the call: top up the
|
|
110
|
+
* agent's credits (or use a wallet session) and retry. `required` is the
|
|
111
|
+
* gross price of the call and `balance` the current credit balance, in USDC,
|
|
112
|
+
* when the server reported them.
|
|
113
|
+
*/
|
|
114
|
+
export declare class InsufficientCreditsError extends OneShotError {
|
|
115
|
+
readonly required?: number | undefined;
|
|
116
|
+
readonly balance?: number | undefined;
|
|
117
|
+
readonly shortfall?: number | undefined;
|
|
118
|
+
constructor(message: string, required?: number | undefined, balance?: number | undefined, shortfall?: number | undefined);
|
|
119
|
+
}
|
|
106
120
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAMA,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAK5B;AAED,qBAAa,SAAU,SAAQ,YAAY;aAGvB,UAAU,EAAE,MAAM;aAClB,YAAY,EAAE,MAAM;gBAFpC,OAAO,EAAE,MAAM,EACC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM;CAKvC;AAED;;;;;;;;;GASG;AACH,qBAAa,YAAa,SAAQ,YAAY;aAG1B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,EAAE,MAAM,YAAA;CAKpC;AAED;;;;;;;;;GASG;AACH,qBAAa,eAAgB,SAAQ,YAAY;aACF,MAAM,CAAC,EAAE,MAAM;aAAkB,YAAY,CAAC,EAAE,MAAM;gBAAvF,OAAO,EAAE,MAAM,EAAkB,MAAM,CAAC,EAAE,MAAM,YAAA,EAAkB,YAAY,CAAC,EAAE,MAAM,YAAA;CAIpG;AAED;;;;;;;GAOG;AACH,qBAAa,wBAAyB,SAAQ,YAAY;aAGtC,QAAQ,CAAC,EAAE,MAAM;aACjB,OAAO,CAAC,EAAE,MAAM;aAChB,SAAS,CAAC,EAAE,MAAM;gBAHlC,OAAO,EAAE,MAAM,EACC,QAAQ,CAAC,EAAE,MAAM,YAAA,EACjB,OAAO,CAAC,EAAE,MAAM,YAAA,EAChB,SAAS,CAAC,EAAE,MAAM,YAAA;CAKrC"}
|
package/dist/errors.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// that drove the throw (statusCode/responseBody, jobId, field, categories, …)
|
|
6
6
|
// so error handlers don't need to re-parse strings.
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.BudgetSyncError = exports.BudgetExceededError = exports.EmergencyNumberError = exports.ContentBlockedError = exports.ValidationError = exports.RequestTimeoutError = exports.JobTimeoutError = exports.JobError = exports.PaymentError = exports.ToolError = exports.OneShotError = void 0;
|
|
8
|
+
exports.InsufficientCreditsError = exports.BudgetSyncError = exports.BudgetExceededError = exports.EmergencyNumberError = exports.ContentBlockedError = exports.ValidationError = exports.RequestTimeoutError = exports.JobTimeoutError = exports.JobError = exports.PaymentError = exports.ToolError = exports.OneShotError = void 0;
|
|
9
9
|
class OneShotError extends Error {
|
|
10
10
|
constructor(message) {
|
|
11
11
|
super(message);
|
|
@@ -147,4 +147,22 @@ class BudgetSyncError extends OneShotError {
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
exports.BudgetSyncError = BudgetSyncError;
|
|
150
|
+
/**
|
|
151
|
+
* An access-token session's credit balance cannot cover the call (HTTP 402
|
|
152
|
+
* `insufficient_credits`). Access-token sessions pay from credits only and
|
|
153
|
+
* never sign x402, so this is the end of the road for the call: top up the
|
|
154
|
+
* agent's credits (or use a wallet session) and retry. `required` is the
|
|
155
|
+
* gross price of the call and `balance` the current credit balance, in USDC,
|
|
156
|
+
* when the server reported them.
|
|
157
|
+
*/
|
|
158
|
+
class InsufficientCreditsError extends OneShotError {
|
|
159
|
+
constructor(message, required, balance, shortfall) {
|
|
160
|
+
super(message);
|
|
161
|
+
this.required = required;
|
|
162
|
+
this.balance = balance;
|
|
163
|
+
this.shortfall = shortfall;
|
|
164
|
+
this.name = 'InsufficientCreditsError';
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
exports.InsufficientCreditsError = InsufficientCreditsError;
|
|
150
168
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,0EAA0E;AAC1E,gFAAgF;AAChF,8EAA8E;AAC9E,oDAAoD;;;AAEpD,MAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAND,oCAMC;AAED,MAAa,SAAU,SAAQ,YAAY;IACzC,YACE,OAAe,EACC,UAAkB,EAClB,YAAoB;QAEpC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,eAAU,GAAV,UAAU,CAAQ;QAClB,iBAAY,GAAZ,YAAY,CAAQ;QAGpC,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF;AATD,8BASC;AA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AAC;CACF;AALD,0CAKC;AAED;;;;;;;GAOG;AACH,MAAa,wBAAyB,SAAQ,YAAY;IACxD,YACE,OAAe,EACC,QAAiB,EACjB,OAAgB,EAChB,SAAkB;QAElC,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,aAAQ,GAAR,QAAQ,CAAS;QACjB,YAAO,GAAP,OAAO,CAAS;QAChB,cAAS,GAAT,SAAS,CAAS;QAGlC,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AAVD,4DAUC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,11 +4,12 @@ import type { WalletProvider } from './wallet-provider';
|
|
|
4
4
|
export type { WalletProvider, TypedDataDomain, TypedDataField, TransactionRequest, TransactionResponse } from './wallet-provider';
|
|
5
5
|
export { EthersWalletProvider } from './providers/ethers';
|
|
6
6
|
export { CdpWalletProvider } from './providers/cdp';
|
|
7
|
+
export { ReadOnlyWalletProvider } from './providers/read-only';
|
|
7
8
|
export { getSwapQuote, executeSwap } from './swap';
|
|
8
9
|
export type { SwapQuote, SwapResult, UniswapAddresses } from './swap';
|
|
9
10
|
export * from './errors';
|
|
10
11
|
export * from './types';
|
|
11
|
-
import type { StatusUpdateFn, OneShotConfig, ToolOptions, EmailToolOptions, ResearchToolOptions, PeopleSearchOptions, EnrichProfileOptions, FindEmailOptions, VerifyEmailOptions, CompanySearchOptions, CompanySearchResult, EnrichCompanyOptions, EnrichCompanyResult, LocalSearchOptions, LocalSearchResult, LocalResolveOptions, LocalResolveResult, GovSolicitationsOptions, GovSolicitationsResult, DeepResearchPersonOptions, SocialProfilesOptions, ArticleSearchOptions, PersonNewsfeedOptions, PersonInterestsOptions, PersonInteractionsOptions, InboxListOptions, CommerceBuyOptions, CommerceSearchOptions, WebSearchOptions, WebSearchResult, WebReadOptions, WebReadResult, VoiceCallOptions, SmsOptions, SmsInboxOptions, PeopleSearchResult, ResearchResult, EmailResult, EnrichProfileResult, FindEmailResult, DeepResearchPersonResult, SocialProfilesResult, ArticleSearchResult, PersonNewsfeedResult, PersonInterestsResult, PersonInteractionsResult, VerifyEmailResult, InboxEmail, InboxListResult, CommerceBuyResult, CommerceSearchResult, VoiceCallResult, SmsSendResult, SmsInboxMessage, SmsInboxResult, NotificationsListOptions, NotificationsResult, BuildOptions, BuildResult, BrowserTaskOptions, BrowserProfile, BrowserResult, UpdateBuildOptions, SpendBreakdown, RoCSResult, RoCSByGoalResult, ReceiptsListResult, UnifiedBalance, ComputeOptions, ComputeGoalResult, ComputeGoalStatus, ComputeTask, ComputeBudgetStatus, DomainPoolListResult, DomainPoolStatusResult, AgentBudgetConfig, AgentBudgetStatus } from './types';
|
|
12
|
+
import type { StatusUpdateFn, OneShotConfig, ToolOptions, EmailToolOptions, ResearchToolOptions, PeopleSearchOptions, EnrichProfileOptions, FindEmailOptions, VerifyEmailOptions, CompanySearchOptions, CompanySearchResult, EnrichCompanyOptions, EnrichCompanyResult, LocalSearchOptions, LocalSearchResult, LocalResolveOptions, LocalResolveResult, GovSolicitationsOptions, GovSolicitationsResult, DeepResearchPersonOptions, SocialProfilesOptions, ArticleSearchOptions, PersonNewsfeedOptions, PersonInterestsOptions, PersonInteractionsOptions, InboxListOptions, CommerceBuyOptions, CommerceSearchOptions, WebSearchOptions, WebSearchResult, WebReadOptions, WebReadResult, VoiceCallOptions, SmsOptions, SmsInboxOptions, PeopleSearchResult, ResearchResult, EmailResult, EnrichProfileResult, FindEmailResult, DeepResearchPersonResult, SocialProfilesResult, ArticleSearchResult, PersonNewsfeedResult, PersonInterestsResult, PersonInteractionsResult, VerifyEmailResult, InboxEmail, InboxListResult, CommerceBuyResult, CommerceSearchResult, VoiceCallResult, SmsSendResult, SmsInboxMessage, SmsInboxResult, NotificationsListOptions, NotificationsResult, BuildOptions, BuildResult, BrowserTaskOptions, BrowserProfile, BrowserResult, UpdateBuildOptions, SpendBreakdown, RoCSResult, RoCSByGoalResult, ReceiptsListResult, UnifiedBalance, ComputeOptions, ComputeGoalResult, ComputeGoalStatus, ComputeTask, ComputeBudgetStatus, DomainPoolListResult, DomainPoolStatusResult, AgentBudgetConfig, AgentBudgetStatus, AccessTokenCreated, AccessTokenInfo } from './types';
|
|
12
13
|
export declare class OneShot {
|
|
13
14
|
readonly physicalMail: PhysicalMail;
|
|
14
15
|
private readonly provider;
|
|
@@ -20,6 +21,9 @@ export declare class OneShot {
|
|
|
20
21
|
private readonly _slippage;
|
|
21
22
|
private readonly _budgets?;
|
|
22
23
|
private readonly _alertEmail?;
|
|
24
|
+
/** Set in access-token mode; the session pays from credits and never signs. */
|
|
25
|
+
private readonly _accessToken?;
|
|
26
|
+
private readonly _defaultHeaders;
|
|
23
27
|
/**
|
|
24
28
|
* In-flight/settled budget sync. One PUT per instance: kept as a promise (not
|
|
25
29
|
* a boolean) so concurrent first calls await the same request instead of
|
|
@@ -90,6 +94,8 @@ export declare class OneShot {
|
|
|
90
94
|
* Federal contract opportunities (SAM.gov) by NAICS code — Sources Sought
|
|
91
95
|
* and Presolicitation notices with the contracting officer's published
|
|
92
96
|
* contact. Flat price per search; zero notices is a completed result.
|
|
97
|
+
* `data_as_of` on the result is the snapshot behind the rows (SAM.gov's
|
|
98
|
+
* daily extract publish time, or "now" when the live API served).
|
|
93
99
|
*/
|
|
94
100
|
govSolicitations(options: GovSolicitationsOptions): Promise<GovSolicitationsResult>;
|
|
95
101
|
findEmail(options: FindEmailOptions): Promise<FindEmailResult>;
|
|
@@ -501,6 +507,8 @@ export declare class OneShot {
|
|
|
501
507
|
private log;
|
|
502
508
|
private validate;
|
|
503
509
|
private headers;
|
|
510
|
+
/** True for access-token sessions: credits-only, never signs. */
|
|
511
|
+
get isAccessTokenSession(): boolean;
|
|
504
512
|
/** Auth headers plus Content-Type for JSON-body requests. */
|
|
505
513
|
private jsonHeaders;
|
|
506
514
|
/**
|
|
@@ -548,6 +556,30 @@ export declare class OneShot {
|
|
|
548
556
|
* ```
|
|
549
557
|
*/
|
|
550
558
|
budgets(): Promise<AgentBudgetStatus>;
|
|
559
|
+
private assertWalletSession;
|
|
560
|
+
/**
|
|
561
|
+
* Mint an access token for this agent: a revocable, credits-only credential
|
|
562
|
+
* for code that runs where the wallet key cannot be (hosted MCP clients,
|
|
563
|
+
* cloud runners). The plaintext is returned once and never stored.
|
|
564
|
+
*
|
|
565
|
+
* @example
|
|
566
|
+
* ```typescript
|
|
567
|
+
* const { token } = await agent.createAccessToken({ name: 'grok-bot' });
|
|
568
|
+
* // hand `token` to the hosted client; it uses OneShot.create({ accessToken: token })
|
|
569
|
+
* ```
|
|
570
|
+
*/
|
|
571
|
+
createAccessToken(opts?: {
|
|
572
|
+
name?: string;
|
|
573
|
+
}): Promise<AccessTokenCreated>;
|
|
574
|
+
/** List this agent's access tokens (prefix, label, last use, spend today — never the token). */
|
|
575
|
+
listAccessTokens(opts?: {
|
|
576
|
+
activeOnly?: boolean;
|
|
577
|
+
}): Promise<AccessTokenInfo[]>;
|
|
578
|
+
/** Revoke an access token. Sessions using it fail with 401 from the next request. */
|
|
579
|
+
revokeAccessToken(id: string): Promise<{
|
|
580
|
+
id: string;
|
|
581
|
+
revoked_at: string;
|
|
582
|
+
}>;
|
|
551
583
|
/** Local fast-fail guard: throw when a quote total exceeds the caller's cap. */
|
|
552
584
|
private assertWithinMaxCost;
|
|
553
585
|
/**
|
|
@@ -586,6 +618,22 @@ export declare class OneShot {
|
|
|
586
618
|
* `ToolError` shape.
|
|
587
619
|
*/
|
|
588
620
|
private failFromResponse;
|
|
621
|
+
/**
|
|
622
|
+
* Map a 402 `insufficient_credits` body (access-token sessions) onto a typed
|
|
623
|
+
* error. Any other 402 falls through to the payment-rejection / quote parse.
|
|
624
|
+
*/
|
|
625
|
+
private parseInsufficientCredits;
|
|
626
|
+
/**
|
|
627
|
+
* Access-token sessions never sign. When a paid call answers 402 the SDK
|
|
628
|
+
* either got the server's `insufficient_credits` verdict (throw it) or a
|
|
629
|
+
* quote (re-POST with `x-quote-id` and no payment: the server executes
|
|
630
|
+
* when the quote's credits cover it, otherwise answers `insufficient_credits`
|
|
631
|
+
* with the balance and shortfall, which failFromResponse turns into the
|
|
632
|
+
* typed error). Server-decided on purpose — the SDK holds no ledger.
|
|
633
|
+
*/
|
|
634
|
+
private retryAsCreditsSession;
|
|
635
|
+
/** GET /v1/agents/me with the token, for OneShot.create({ accessToken }) without an address. */
|
|
636
|
+
private static resolveTokenAddress;
|
|
589
637
|
/**
|
|
590
638
|
* Map a 403 `budget_exceeded` body onto a typed error, so callers can catch
|
|
591
639
|
* "my own budget stopped this" separately from an auth failure or a payment
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,cAAc,iBAAiB,CAAC;AAIhC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAexD,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAClI,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACnD,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AACtE,cAAc,UAAU,CAAC;AA2EzB,cAAc,SAAS,CAAC;AAExB,OAAO,KAAK,EAEA,cAAc,EAAE,aAAa,EAAmB,WAAW,EACrE,gBAAgB,EAAE,mBAAmB,EAAE,mBAAmB,EAC1D,oBAAoB,EAAE,gBAAgB,EAAE,kBAAkB,EAC1D,oBAAoB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,mBAAmB,EACpF,kBAAkB,EAAE,iBAAiB,EAAE,m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;;;;OAIG;YACW,eAAe;IAoB7B,gHAAgH;IAChH,OAAO,CAAC,oBAAoB;IAqC5B;;;;OAIG;YACW,uBAAuB;YAoBvB,wBAAwB;CA6GvC"}
|
package/dist/index.js
CHANGED
|
@@ -36,11 +36,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.OneShot = exports.executeSwap = exports.getSwapQuote = exports.CdpWalletProvider = exports.EthersWalletProvider = void 0;
|
|
39
|
+
exports.OneShot = exports.executeSwap = exports.getSwapQuote = exports.ReadOnlyWalletProvider = exports.CdpWalletProvider = exports.EthersWalletProvider = void 0;
|
|
40
40
|
const physical_mail_1 = require("./physical-mail");
|
|
41
41
|
__exportStar(require("./physical-mail"), exports);
|
|
42
42
|
const deadline_1 = require("./deadline");
|
|
43
43
|
const errors_1 = require("./errors");
|
|
44
|
+
const read_only_1 = require("./providers/read-only");
|
|
44
45
|
const ethers_1 = require("ethers");
|
|
45
46
|
const ethers_2 = require("./providers/ethers");
|
|
46
47
|
const errors_2 = require("./errors");
|
|
@@ -48,12 +49,14 @@ var ethers_3 = require("./providers/ethers");
|
|
|
48
49
|
Object.defineProperty(exports, "EthersWalletProvider", { enumerable: true, get: function () { return ethers_3.EthersWalletProvider; } });
|
|
49
50
|
var cdp_1 = require("./providers/cdp");
|
|
50
51
|
Object.defineProperty(exports, "CdpWalletProvider", { enumerable: true, get: function () { return cdp_1.CdpWalletProvider; } });
|
|
52
|
+
var read_only_2 = require("./providers/read-only");
|
|
53
|
+
Object.defineProperty(exports, "ReadOnlyWalletProvider", { enumerable: true, get: function () { return read_only_2.ReadOnlyWalletProvider; } });
|
|
51
54
|
var swap_1 = require("./swap");
|
|
52
55
|
Object.defineProperty(exports, "getSwapQuote", { enumerable: true, get: function () { return swap_1.getSwapQuote; } });
|
|
53
56
|
Object.defineProperty(exports, "executeSwap", { enumerable: true, get: function () { return swap_1.executeSwap; } });
|
|
54
57
|
__exportStar(require("./errors"), exports);
|
|
55
58
|
// Keep in sync with package.json `version`. Guarded by version.test.ts.
|
|
56
|
-
const SDK_VERSION = '0.
|
|
59
|
+
const SDK_VERSION = '0.33.0';
|
|
57
60
|
/** HTTP poll cadence while push is unconfirmed: fast first checks, settling at 2s. */
|
|
58
61
|
const HTTP_POLL_BACKOFF_MS = [300, 600, 1000, 2000];
|
|
59
62
|
/** HTTP poll cadence once the WebSocket has delivered for this request. */
|
|
@@ -160,6 +163,14 @@ class OneShot {
|
|
|
160
163
|
* ```
|
|
161
164
|
*/
|
|
162
165
|
static async create(config) {
|
|
166
|
+
if (config.accessToken) {
|
|
167
|
+
if (config.address)
|
|
168
|
+
return new OneShot(config);
|
|
169
|
+
// The API keys job status and the WebSocket on X-Agent-ID, so the
|
|
170
|
+
// session needs its wallet address even though it never signs with it.
|
|
171
|
+
const address = await OneShot.resolveTokenAddress(config);
|
|
172
|
+
return new OneShot({ ...config, address });
|
|
173
|
+
}
|
|
163
174
|
if (config.walletProvider) {
|
|
164
175
|
return new OneShot(config, config.walletProvider);
|
|
165
176
|
}
|
|
@@ -204,8 +215,38 @@ class OneShot {
|
|
|
204
215
|
this._swapBufferMultiplier = validateSwapBufferMultiplier(config.swapBufferMultiplier);
|
|
205
216
|
this._budgets = validateBudgetConfig(config.budgets);
|
|
206
217
|
this._alertEmail = config.alerts?.email;
|
|
218
|
+
this._defaultHeaders = { ...(config.defaultHeaders ?? {}) };
|
|
207
219
|
this.rpcProvider = new ethers_1.ethers.JsonRpcProvider(config.rpcUrl ?? RPC_URL);
|
|
208
|
-
if (
|
|
220
|
+
if (config.accessToken) {
|
|
221
|
+
// Option D: access-token session. Exclusive with every wallet option,
|
|
222
|
+
// and budgets are read-only (a delegated credential that could raise its
|
|
223
|
+
// own cap would make the cap meaningless) — set them from a wallet.
|
|
224
|
+
if (!/^oneshot_[0-9a-f]{64}$/.test(config.accessToken)) {
|
|
225
|
+
throw new errors_2.ValidationError('accessToken must be oneshot_<64 lowercase hex characters>', 'accessToken');
|
|
226
|
+
}
|
|
227
|
+
if (config.privateKey || config.cdp || config.walletProvider || walletProvider) {
|
|
228
|
+
throw new errors_2.ValidationError('accessToken cannot be combined with privateKey, cdp, or walletProvider', 'accessToken');
|
|
229
|
+
}
|
|
230
|
+
if (config.budgets || config.alerts) {
|
|
231
|
+
throw new errors_2.ValidationError('budgets and alerts are read-only for access-token sessions; set them from a wallet session or the API', 'budgets');
|
|
232
|
+
}
|
|
233
|
+
if (this._currency === 'ETH') {
|
|
234
|
+
throw new errors_2.ValidationError('ETH currency mode is not available to access-token sessions (they pay from credits)', 'currency');
|
|
235
|
+
}
|
|
236
|
+
if (!config.address) {
|
|
237
|
+
throw new errors_2.ValidationError('address is required with accessToken in the constructor; use OneShot.create() to resolve it', 'address');
|
|
238
|
+
}
|
|
239
|
+
let address;
|
|
240
|
+
try {
|
|
241
|
+
address = ethers_1.ethers.getAddress(config.address);
|
|
242
|
+
}
|
|
243
|
+
catch {
|
|
244
|
+
throw new errors_2.ValidationError('address must be a valid Ethereum address', 'address');
|
|
245
|
+
}
|
|
246
|
+
this._accessToken = config.accessToken;
|
|
247
|
+
this.provider = new read_only_1.ReadOnlyWalletProvider(address);
|
|
248
|
+
}
|
|
249
|
+
else if (walletProvider) {
|
|
209
250
|
this.provider = walletProvider;
|
|
210
251
|
}
|
|
211
252
|
else if (config.privateKey) {
|
|
@@ -406,6 +447,8 @@ class OneShot {
|
|
|
406
447
|
* Federal contract opportunities (SAM.gov) by NAICS code — Sources Sought
|
|
407
448
|
* and Presolicitation notices with the contracting officer's published
|
|
408
449
|
* contact. Flat price per search; zero notices is a completed result.
|
|
450
|
+
* `data_as_of` on the result is the snapshot behind the rows (SAM.gov's
|
|
451
|
+
* daily extract publish time, or "now" when the live API served).
|
|
409
452
|
*/
|
|
410
453
|
async govSolicitations(options) {
|
|
411
454
|
if (!options.naics || options.naics.length === 0) {
|
|
@@ -1244,6 +1287,13 @@ class OneShot {
|
|
|
1244
1287
|
const quoteData = await quoteResp.json();
|
|
1245
1288
|
this.log(`Compute fund quote: $${quoteData.payment_request.amount} to top up ${goalId}`);
|
|
1246
1289
|
this.assertWithinBudget(quoteData.payment_request.amount);
|
|
1290
|
+
if (this._accessToken) {
|
|
1291
|
+
const fundResp = await this.retryAsCreditsSession(quoteData, path, payload, quoteData.context.quote_id);
|
|
1292
|
+
if (!fundResp.ok)
|
|
1293
|
+
await this.failFromResponse('Failed to fund compute goal', fundResp);
|
|
1294
|
+
const json = await fundResp.json();
|
|
1295
|
+
return json.data;
|
|
1296
|
+
}
|
|
1247
1297
|
const paymentInfo = {
|
|
1248
1298
|
protocol: 'x402',
|
|
1249
1299
|
network: `eip155:${quoteData.payment_request.chain_id}`,
|
|
@@ -1436,10 +1486,16 @@ class OneShot {
|
|
|
1436
1486
|
}
|
|
1437
1487
|
headers() {
|
|
1438
1488
|
return {
|
|
1489
|
+
...this._defaultHeaders,
|
|
1439
1490
|
'X-Agent-ID': this.provider.address,
|
|
1440
|
-
'X-OneShot-SDK-Version': SDK_VERSION
|
|
1491
|
+
'X-OneShot-SDK-Version': SDK_VERSION,
|
|
1492
|
+
...(this._accessToken ? { Authorization: `Bearer ${this._accessToken}` } : {}),
|
|
1441
1493
|
};
|
|
1442
1494
|
}
|
|
1495
|
+
/** True for access-token sessions: credits-only, never signs. */
|
|
1496
|
+
get isAccessTokenSession() {
|
|
1497
|
+
return this._accessToken !== undefined;
|
|
1498
|
+
}
|
|
1443
1499
|
/** Auth headers plus Content-Type for JSON-body requests. */
|
|
1444
1500
|
jsonHeaders() {
|
|
1445
1501
|
return { 'Content-Type': 'application/json', ...this.headers() };
|
|
@@ -1455,6 +1511,10 @@ class OneShot {
|
|
|
1455
1511
|
*/
|
|
1456
1512
|
async signedReadHeaders(scope = 'read') {
|
|
1457
1513
|
const base = this.headers();
|
|
1514
|
+
// The bearer token already binds the request to the agent (and is
|
|
1515
|
+
// revocable); the API accepts it in place of the signed proof.
|
|
1516
|
+
if (this._accessToken)
|
|
1517
|
+
return base;
|
|
1458
1518
|
try {
|
|
1459
1519
|
const agent = this.provider.address;
|
|
1460
1520
|
const issuedAt = Math.floor(Date.now() / 1000);
|
|
@@ -1580,6 +1640,61 @@ class OneShot {
|
|
|
1580
1640
|
const body = await response.json();
|
|
1581
1641
|
return (body.data ?? body);
|
|
1582
1642
|
}
|
|
1643
|
+
// ---------------------------------------------------------------------------
|
|
1644
|
+
// Access tokens (wallet sessions only)
|
|
1645
|
+
// ---------------------------------------------------------------------------
|
|
1646
|
+
assertWalletSession(action) {
|
|
1647
|
+
if (this._accessToken) {
|
|
1648
|
+
throw new errors_2.ValidationError(`Access tokens cannot ${action}; use a wallet session`, 'accessToken');
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
/**
|
|
1652
|
+
* Mint an access token for this agent: a revocable, credits-only credential
|
|
1653
|
+
* for code that runs where the wallet key cannot be (hosted MCP clients,
|
|
1654
|
+
* cloud runners). The plaintext is returned once and never stored.
|
|
1655
|
+
*
|
|
1656
|
+
* @example
|
|
1657
|
+
* ```typescript
|
|
1658
|
+
* const { token } = await agent.createAccessToken({ name: 'grok-bot' });
|
|
1659
|
+
* // hand `token` to the hosted client; it uses OneShot.create({ accessToken: token })
|
|
1660
|
+
* ```
|
|
1661
|
+
*/
|
|
1662
|
+
async createAccessToken(opts = {}) {
|
|
1663
|
+
this.assertWalletSession('mint access tokens');
|
|
1664
|
+
const response = await fetch(`${this.baseUrl}/v1/agents/me/access-tokens`, {
|
|
1665
|
+
method: 'POST',
|
|
1666
|
+
headers: { 'Content-Type': 'application/json', ...(await this.signedReadHeaders('write')) },
|
|
1667
|
+
body: JSON.stringify(opts.name !== undefined ? { name: opts.name } : {}),
|
|
1668
|
+
});
|
|
1669
|
+
if (!response.ok)
|
|
1670
|
+
throw new errors_2.ToolError('Failed to create access token', response.status, await response.text());
|
|
1671
|
+
const body = await response.json();
|
|
1672
|
+
return body.data;
|
|
1673
|
+
}
|
|
1674
|
+
/** List this agent's access tokens (prefix, label, last use, spend today — never the token). */
|
|
1675
|
+
async listAccessTokens(opts = {}) {
|
|
1676
|
+
this.assertWalletSession('list access tokens');
|
|
1677
|
+
const response = await fetch(`${this.baseUrl}/v1/agents/me/access-tokens${opts.activeOnly ? '?active=true' : ''}`, {
|
|
1678
|
+
headers: await this.signedReadHeaders(),
|
|
1679
|
+
});
|
|
1680
|
+
if (!response.ok)
|
|
1681
|
+
throw new errors_2.ToolError('Failed to list access tokens', response.status, await response.text());
|
|
1682
|
+
const body = await response.json();
|
|
1683
|
+
return body.data.tokens;
|
|
1684
|
+
}
|
|
1685
|
+
/** Revoke an access token. Sessions using it fail with 401 from the next request. */
|
|
1686
|
+
async revokeAccessToken(id) {
|
|
1687
|
+
this.assertWalletSession('revoke access tokens');
|
|
1688
|
+
this.validate(id, 'id');
|
|
1689
|
+
const response = await fetch(`${this.baseUrl}/v1/agents/me/access-tokens/${encodeURIComponent(id)}`, {
|
|
1690
|
+
method: 'DELETE',
|
|
1691
|
+
headers: await this.signedReadHeaders('write'),
|
|
1692
|
+
});
|
|
1693
|
+
if (!response.ok)
|
|
1694
|
+
throw new errors_2.ToolError('Failed to revoke access token', response.status, await response.text());
|
|
1695
|
+
const body = await response.json();
|
|
1696
|
+
return body.data;
|
|
1697
|
+
}
|
|
1583
1698
|
/** Local fast-fail guard: throw when a quote total exceeds the caller's cap. */
|
|
1584
1699
|
assertWithinMaxCost(total, maxCost) {
|
|
1585
1700
|
if (maxCost && parseFloat(total) > maxCost) {
|
|
@@ -1623,6 +1738,9 @@ class OneShot {
|
|
|
1623
1738
|
*/
|
|
1624
1739
|
async failFromResponse(message, response) {
|
|
1625
1740
|
const text = await response.text();
|
|
1741
|
+
const credits = response.status === 402 ? this.parseInsufficientCredits(text) : undefined;
|
|
1742
|
+
if (credits)
|
|
1743
|
+
throw credits;
|
|
1626
1744
|
const rejection = response.status === 402 ? this.parsePaymentRejection(text) : undefined;
|
|
1627
1745
|
if (rejection)
|
|
1628
1746
|
throw rejection;
|
|
@@ -1631,6 +1749,75 @@ class OneShot {
|
|
|
1631
1749
|
throw budget;
|
|
1632
1750
|
throw new errors_2.ToolError(message, response.status, text);
|
|
1633
1751
|
}
|
|
1752
|
+
/**
|
|
1753
|
+
* Map a 402 `insufficient_credits` body (access-token sessions) onto a typed
|
|
1754
|
+
* error. Any other 402 falls through to the payment-rejection / quote parse.
|
|
1755
|
+
*/
|
|
1756
|
+
parseInsufficientCredits(text) {
|
|
1757
|
+
let body;
|
|
1758
|
+
try {
|
|
1759
|
+
body = typeof text === 'string' ? JSON.parse(text) : text;
|
|
1760
|
+
}
|
|
1761
|
+
catch {
|
|
1762
|
+
return undefined;
|
|
1763
|
+
}
|
|
1764
|
+
if (!body || body.error !== 'insufficient_credits')
|
|
1765
|
+
return undefined;
|
|
1766
|
+
const num = (v) => (typeof v === 'string' || typeof v === 'number') && Number.isFinite(parseFloat(String(v))) ? parseFloat(String(v)) : undefined;
|
|
1767
|
+
return new errors_1.InsufficientCreditsError(body.message ?? 'Credit balance does not cover this call', num(body.required_usdc), num(body.credits_balance), num(body.shortfall_usdc));
|
|
1768
|
+
}
|
|
1769
|
+
/**
|
|
1770
|
+
* Access-token sessions never sign. When a paid call answers 402 the SDK
|
|
1771
|
+
* either got the server's `insufficient_credits` verdict (throw it) or a
|
|
1772
|
+
* quote (re-POST with `x-quote-id` and no payment: the server executes
|
|
1773
|
+
* when the quote's credits cover it, otherwise answers `insufficient_credits`
|
|
1774
|
+
* with the balance and shortfall, which failFromResponse turns into the
|
|
1775
|
+
* typed error). Server-decided on purpose — the SDK holds no ledger.
|
|
1776
|
+
*/
|
|
1777
|
+
async retryAsCreditsSession(body, endpoint, payload, quoteId, signal, timeoutMs, extraHeaders) {
|
|
1778
|
+
const credits = body ? this.parseInsufficientCredits(body) : undefined;
|
|
1779
|
+
if (credits)
|
|
1780
|
+
throw credits;
|
|
1781
|
+
const qid = quoteId ?? body?.context?.quote_id;
|
|
1782
|
+
if (!qid) {
|
|
1783
|
+
const amount = body?.payment_request?.amount;
|
|
1784
|
+
throw new errors_1.InsufficientCreditsError(`Credits do not cover ${amount ? `$${amount}` : 'this call'}; top up credits or use a wallet session`, amount ? parseFloat(amount) : undefined);
|
|
1785
|
+
}
|
|
1786
|
+
this.log(`Access-token session: retrying quote ${qid} against credits`);
|
|
1787
|
+
const retry = await this.makeRequest(endpoint, payload, undefined, qid, signal, timeoutMs, extraHeaders);
|
|
1788
|
+
if (retry.status === 402)
|
|
1789
|
+
await this.failFromResponse('Credits do not cover this call', retry);
|
|
1790
|
+
return retry;
|
|
1791
|
+
}
|
|
1792
|
+
/** GET /v1/agents/me with the token, for OneShot.create({ accessToken }) without an address. */
|
|
1793
|
+
static async resolveTokenAddress(config) {
|
|
1794
|
+
const TOKEN_RESOLVE_TIMEOUT_MS = 10000;
|
|
1795
|
+
const baseUrl = config.baseUrl ?? BASE_URL;
|
|
1796
|
+
let response;
|
|
1797
|
+
try {
|
|
1798
|
+
response = await fetch(`${baseUrl}/v1/agents/me`, {
|
|
1799
|
+
headers: {
|
|
1800
|
+
...(config.defaultHeaders ?? {}),
|
|
1801
|
+
Authorization: `Bearer ${config.accessToken}`,
|
|
1802
|
+
'X-OneShot-SDK-Version': SDK_VERSION,
|
|
1803
|
+
},
|
|
1804
|
+
// Bounded: with no signal, Node's fetch can wait minutes on a hung
|
|
1805
|
+
// connection and OneShot.create() would hang with it.
|
|
1806
|
+
signal: AbortSignal.timeout(TOKEN_RESOLVE_TIMEOUT_MS),
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
catch (err) {
|
|
1810
|
+
throw new errors_2.ToolError(`Could not resolve the access token's agent (network): ${err}`, 0, String(err));
|
|
1811
|
+
}
|
|
1812
|
+
if (!response.ok) {
|
|
1813
|
+
throw new errors_2.ToolError('Could not resolve the access token\'s agent', response.status, await response.text());
|
|
1814
|
+
}
|
|
1815
|
+
const json = await response.json();
|
|
1816
|
+
const address = json.data?.wallet_address;
|
|
1817
|
+
if (!address)
|
|
1818
|
+
throw new errors_2.ToolError('GET /v1/agents/me returned no wallet_address', response.status, JSON.stringify(json));
|
|
1819
|
+
return address;
|
|
1820
|
+
}
|
|
1634
1821
|
/**
|
|
1635
1822
|
* Map a 403 `budget_exceeded` body onto a typed error, so callers can catch
|
|
1636
1823
|
* "my own budget stopped this" separately from an auth failure or a payment
|
|
@@ -1802,23 +1989,30 @@ class OneShot {
|
|
|
1802
1989
|
const { accepted, resource, extensions } = this.parsePaymentRequired(paymentRequiredHeader);
|
|
1803
1990
|
// Fallback: parse legacy body format for amount display
|
|
1804
1991
|
const data = await response.json();
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1992
|
+
if (this._accessToken) {
|
|
1993
|
+
// Credits-only session: never sign. Let the server settle it.
|
|
1994
|
+
this.checkAbortBeforePayment(signal);
|
|
1995
|
+
response = await this.retryAsCreditsSession(data, endpoint, payload, quoteId, signal, undefined, extraHeaders);
|
|
1996
|
+
}
|
|
1997
|
+
else {
|
|
1998
|
+
const paymentInfo = {
|
|
1999
|
+
protocol: 'x402',
|
|
2000
|
+
network: accepted.network,
|
|
2001
|
+
payTo: accepted.payTo,
|
|
2002
|
+
amount: this.chargeAmount(accepted, data.payment_request?.amount),
|
|
2003
|
+
currency: 'USD',
|
|
2004
|
+
facilitator_url: this.baseUrl,
|
|
2005
|
+
token: { address: accepted.asset, symbol: 'USDC', decimals: 6 }
|
|
2006
|
+
};
|
|
2007
|
+
this.log(`Payment required: ${paymentInfo.amount} USDC`);
|
|
2008
|
+
this.assertWithinBudget(paymentInfo.amount);
|
|
2009
|
+
this.checkAbortBeforePayment(signal);
|
|
2010
|
+
context.phase = 'payment';
|
|
2011
|
+
const signed = await this.signPaymentAuthorization(paymentInfo, accepted, resource, extensions);
|
|
2012
|
+
this.checkAbortBeforePayment(signal);
|
|
2013
|
+
context.phase = 'submission';
|
|
2014
|
+
response = await this.makePaidRequest(signed, endpoint, payload, quoteId, signal, undefined, extraHeaders);
|
|
2015
|
+
}
|
|
1822
2016
|
}
|
|
1823
2017
|
if (!response.ok) {
|
|
1824
2018
|
await this.failFromResponse('Tool request failed', response);
|
|
@@ -1864,6 +2058,11 @@ class OneShot {
|
|
|
1864
2058
|
cfg.onQuote(quoteData.context);
|
|
1865
2059
|
this.assertWithinMaxCost(cfg.totalOf(quoteData.context), cfg.maxCost);
|
|
1866
2060
|
this.assertWithinBudget(cfg.totalOf(quoteData.context));
|
|
2061
|
+
if (this._accessToken) {
|
|
2062
|
+
this.checkAbortBeforePayment(cfg.signal);
|
|
2063
|
+
const execResp = await this.retryAsCreditsSession(quoteData, cfg.endpoint, cfg.payload, quoteData.context.quote_id, cfg.signal, cfg.execTimeoutMs);
|
|
2064
|
+
return { context: quoteData.context, execResp };
|
|
2065
|
+
}
|
|
1867
2066
|
const paymentInfo = {
|
|
1868
2067
|
protocol: 'x402',
|
|
1869
2068
|
network: `eip155:${quoteData.payment_request.chain_id}`,
|
|
@@ -2485,6 +2684,11 @@ class OneShot {
|
|
|
2485
2684
|
},
|
|
2486
2685
|
} };
|
|
2487
2686
|
}
|
|
2687
|
+
// Belt and braces: every paid path branches to retryAsCreditsSession
|
|
2688
|
+
// before reaching here in access-token mode.
|
|
2689
|
+
if (this._accessToken) {
|
|
2690
|
+
throw new errors_1.InsufficientCreditsError(`Credits do not cover $${paymentInfo.amount}; top up credits or use a wallet session`, parseFloat(paymentInfo.amount));
|
|
2691
|
+
}
|
|
2488
2692
|
// If paying with ETH, make sure USDC covers the charge (swapping a buffer if not) and reserve it
|
|
2489
2693
|
const reservation = await this.ensureUsdcBalance(paymentInfo);
|
|
2490
2694
|
const now = Math.floor(Date.now() / 1000);
|