@perkos/agent-sdk 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +63 -0
- package/README.md +114 -2
- package/SECURITY.md +10 -1
- package/dist/builders.d.ts +3 -1
- package/dist/builders.d.ts.map +1 -1
- package/dist/builders.js +22 -8
- package/dist/builders.js.map +1 -1
- package/dist/clarity.d.ts +1 -0
- package/dist/clarity.d.ts.map +1 -1
- package/dist/clarity.js +8 -0
- package/dist/clarity.js.map +1 -1
- package/dist/client.d.ts +6 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +79 -4
- package/dist/client.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +58 -0
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mpp.d.ts +135 -0
- package/dist/mpp.d.ts.map +1 -0
- package/dist/mpp.js +784 -0
- package/dist/mpp.js.map +1 -0
- package/dist/types.d.ts +13 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/x402-direct.js +1 -1
- package/docs/ARCHITECTURE.md +37 -5
- package/docs/MPP_PAYMENTS.md +161 -0
- package/examples/mpp-usdcx.ts +91 -0
- package/package.json +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,69 @@ All notable changes to `@perkos/agent-sdk` are documented here.
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
## 0.5.1 - 2026-08-30
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Update only the Stacks testnet USDCx identity to the contract currently registered by Circle
|
|
12
|
+
xReserve remote domain `10003` and proven by an official successful bridge mint:
|
|
13
|
+
`ST2WK9SGBJ15RHZ33KK0KYVSXBEBHM1XDM8C96EC4.usdcx`. Mainnet remains unchanged.
|
|
14
|
+
- Keep x402 and MPP challenge, intent, post-condition and verifier construction on the same exact
|
|
15
|
+
SIP-010 asset so clients cannot sign an obsolete testnet token while the facilitator expects the
|
|
16
|
+
current bridge output.
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- Record the source-verified v4/v3 Stacks testnet deployment under
|
|
21
|
+
`ST16EWRC01S1SFWGBP63MW47VY8P3AYFA8VGEBGE5`, STX 27/27 and official PoX-5 sBTC 30/30 complete
|
|
22
|
+
evidence, while retaining explicit overrides and unchanged published defaults.
|
|
23
|
+
- Record the v3 12-block timeout proof: preparation 20/20, settlement 12/12 and public-state
|
|
24
|
+
verification 10/10; job `u2` ended `timeout-paid` (`u6`) with zero escrow, one exact sBTC payout
|
|
25
|
+
and no completion, reputation or rating credit.
|
|
26
|
+
- Explicit support for the 12-burn-block `agentic-commerce-v4` and `sbtc-commerce-v3` review
|
|
27
|
+
candidate while preserving compatibility with the immutable 144-block v3/v2 generation.
|
|
28
|
+
- Candidate-aware job parsing for Bitcoin submission/review heights and the distinct
|
|
29
|
+
`timeout-paid` (`u6`) terminal state.
|
|
30
|
+
- Exact deny-mode STX/sBTC `settleReviewTimeout` plans and high-level client execution after the
|
|
31
|
+
candidate contract's evaluator deadline.
|
|
32
|
+
- Durable reputation synchronization reads and permissionless `retryReputationSync` plans.
|
|
33
|
+
- Versioned Clarity error mappings and same-network contract-override guidance while leaving all
|
|
34
|
+
published deployment defaults unchanged.
|
|
35
|
+
|
|
36
|
+
### Security
|
|
37
|
+
|
|
38
|
+
- Keep published deployment defaults unchanged; v4/v3 contract selection remains an explicit,
|
|
39
|
+
same-network override that is safe only after source-verified deployment.
|
|
40
|
+
- Timeout settlement reads the current escrow, provider, and job-pinned sBTC token before
|
|
41
|
+
constructing a contract-principal post-condition for the exact amount and funded token.
|
|
42
|
+
- Reputation retry has no asset transfer and remains deny-mode. The SDK does not interpret a
|
|
43
|
+
timeout payout as completion or reputation evidence.
|
|
44
|
+
|
|
45
|
+
## 0.5.0 - 2026-08-28
|
|
46
|
+
|
|
47
|
+
### Added
|
|
48
|
+
|
|
49
|
+
- A standards-based MPP PaymentAuth adapter for `method="usdc"`, `intent="charge"` and the direct
|
|
50
|
+
USDCx on Stacks profile, separate from the existing x402 routes.
|
|
51
|
+
- RFC 8785 canonical challenge, credential and receipt codecs; `WWW-Authenticate: Payment`
|
|
52
|
+
challenges select `Payment-Authorization` so OAuth Bearer credentials remain independent.
|
|
53
|
+
- Official mainnet and testnet USDCx method details, CAIP-10 payer sources, base64 SIP-005
|
|
54
|
+
transaction credentials and `Payment-Receipt` settlement pointers.
|
|
55
|
+
- An MPP-specific unsigned transaction builder that reuses the existing payer intent and spending
|
|
56
|
+
policy while selecting the required `OnChainOnly` anchor mode.
|
|
57
|
+
- Public integration documentation and a safe offline MPP/USDCx quickstart.
|
|
58
|
+
|
|
59
|
+
### Security
|
|
60
|
+
|
|
61
|
+
- Bind each MPP challenge to a trusted Nayori quote and actual protected request, including HTTP
|
|
62
|
+
body digest, amount, recipient, asset, merchant and expiry.
|
|
63
|
+
- Reuse exact SIP-010 transfer, memo, signature and post-condition verification, adding strict
|
|
64
|
+
profile fields, canonical envelopes, standard single-signature authorization and low-s signing.
|
|
65
|
+
- Keep sponsorship disabled and leave live nonce/balance checks, durable replay reservation,
|
|
66
|
+
broadcast, confirmation and delivery at the hosted Platform boundary.
|
|
67
|
+
|
|
68
|
+
## 0.4.0 - 2026-08-28
|
|
69
|
+
|
|
7
70
|
### Added
|
|
8
71
|
|
|
9
72
|
- `NayoriPartnerClient` for invitation-bound wallet challenges, one-time OAuth client enrollment,
|
package/README.md
CHANGED
|
@@ -9,13 +9,15 @@ This repository is the continuation of `PerkOS-xyz/PerkOS-Agent-SDK`, renamed to
|
|
|
9
9
|
public SDK with the Nayori product identity. The npm package remains `@perkos/agent-sdk` and the
|
|
10
10
|
complete Git history, releases, issues, and pull requests are preserved.
|
|
11
11
|
|
|
12
|
-
> Status: 0.
|
|
12
|
+
> Status: 0.5.1 developer release. Read clients, transaction builders, browser and headless signer
|
|
13
13
|
> adapters, confirmation receipts, safety policies, and a transactional testnet quickstart are
|
|
14
14
|
> implemented. The x402 v2 client and Stacks facilitator foundations are implemented; this release
|
|
15
15
|
> adds wallet-linked OAuth and MCP support for the planned invite-only testnet pilot. Hosted rollout,
|
|
16
16
|
> external review and adoption evidence remain before Milestone 2 completion. The direct x402
|
|
17
17
|
> profile includes request-bound pure verification
|
|
18
18
|
> and payer-side intent, policy, Leather, and remote-signer foundations for STX, sBTC, and USDCx.
|
|
19
|
+
> The SDK also implements the MPP PaymentAuth `usdc`/`charge` Stacks profile for direct USDCx,
|
|
20
|
+
> including canonical challenges, credentials, pure verification and settlement receipts.
|
|
19
21
|
> Every payment signature remains delegated to the configured wallet or custody boundary. Mainnet
|
|
20
22
|
> facilitator settlement remains disabled.
|
|
21
23
|
|
|
@@ -66,6 +68,14 @@ network call, and does not request a wallet signature or broadcast:
|
|
|
66
68
|
npm run quickstart:x402:payer
|
|
67
69
|
```
|
|
68
70
|
|
|
71
|
+
The MPP PaymentAuth quickstart creates a standard `WWW-Authenticate: Payment` USDCx challenge,
|
|
72
|
+
applies the same payer policy and builds an unsigned `OnChainOnly` Stacks transaction. It is
|
|
73
|
+
offline, contains no private key and does not request a wallet signature or broadcast:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npm run quickstart:mpp
|
|
77
|
+
```
|
|
78
|
+
|
|
69
79
|
The transactional quickstart is also safe by default: it only prints a seven-step sBTC testnet
|
|
70
80
|
lifecycle and its funding-policy decision.
|
|
71
81
|
|
|
@@ -128,6 +138,60 @@ Settlement helpers read the job and escrow balance before building exact contrac
|
|
|
128
138
|
post-conditions. This protects both wallet-originated and headless transactions from transferring
|
|
129
139
|
more than the job requires.
|
|
130
140
|
|
|
141
|
+
## Versioned escrow candidate
|
|
142
|
+
|
|
143
|
+
The SDK can target the versioned contract interfaces introduced for Nayori's pre-launch security
|
|
144
|
+
review, but the published mainnet and testnet defaults remain on the currently verified contracts.
|
|
145
|
+
Do not override them until the chosen network has source-verified candidate deployments.
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
import { PerkOSClient, type ContractId } from "@perkos/agent-sdk";
|
|
149
|
+
|
|
150
|
+
const deployer = "ST16EWRC01S1SFWGBP63MW47VY8P3AYFA8VGEBGE5";
|
|
151
|
+
const perkos = new PerkOSClient({
|
|
152
|
+
network: "testnet",
|
|
153
|
+
contracts: {
|
|
154
|
+
stxCommerce: `${deployer}.agentic-commerce-v4` as ContractId,
|
|
155
|
+
sbtcCommerce: `${deployer}.sbtc-commerce-v3` as ContractId,
|
|
156
|
+
reputationRegistry: `${deployer}.reputation-registry-v3` as ContractId,
|
|
157
|
+
},
|
|
158
|
+
signer,
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
const job = await perkos.getJob("sbtc", 7n);
|
|
162
|
+
console.log(job?.submittedAtBurn, job?.reviewDeadline, job?.status);
|
|
163
|
+
|
|
164
|
+
// After the on-chain Bitcoin review deadline, any signer may trigger the
|
|
165
|
+
// exact provider payout. The plan remains deny-mode with exact escrow outflow.
|
|
166
|
+
await perkos.settleReviewTimeout("sbtc", 7n);
|
|
167
|
+
|
|
168
|
+
const sync = await perkos.getReputationSync("sbtc", 7n);
|
|
169
|
+
if (sync?.pending) await perkos.retryReputationSync("sbtc", 7n);
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
The candidate's fixed 12-burn-block review window is readable through `getReviewWindow(asset)`.
|
|
173
|
+
Evaluator completion/rejection is available through the exact deadline; timeout settlement is
|
|
174
|
+
available only after it. Timeout payout is returned as the distinct `timeout-paid` (`u6`) status
|
|
175
|
+
and must not be counted as a completed job or reputation success. A failed reputation write never
|
|
176
|
+
rolls back economic settlement and can be retried permissionlessly.
|
|
177
|
+
|
|
178
|
+
For `sbtc-commerce-v2` and `sbtc-commerce-v3`, high-level settlement helpers also read the token
|
|
179
|
+
pinned when the job was funded. Both the trait argument and exact fungible-token post-condition use
|
|
180
|
+
that historical token, so rotating the contract's future funding default cannot strand an existing
|
|
181
|
+
escrow.
|
|
182
|
+
|
|
183
|
+
The previous v3/v2 testnet generation remains supported and immutable at 144 blocks. The v4/v3
|
|
184
|
+
overrides above are deployed and source-verified only on Stacks testnet from contracts/Web merge
|
|
185
|
+
`b15544d601bd4e49610be854f7ad33a0af90c0a7`. Controlled STX and official PoX-5 sBTC complete paths
|
|
186
|
+
pass 27/27 and 30/30. The real timeout path passes preparation 20/20, settlement 12/12 and
|
|
187
|
+
separate public-state verification 10/10. Job `u2` settled at burn `11290` in
|
|
188
|
+
[`0x06537111…15bb9`](https://explorer.hiro.so/txid/0x06537111ef6c75d3c5d750154f97a3b4a0c233a84639583f7af18b2386915bb9?chain=testnet),
|
|
189
|
+
ending in `timeout-paid` (`u6`) with zero escrow, one exact 1,000-atomic-unit sBTC payout and no
|
|
190
|
+
completion, reputation or rating credit. The frozen evidence is documented in the
|
|
191
|
+
[contracts/Web repository](https://github.com/PerkOS-xyz/PerkOS-Nayori/blob/main/docs/TESTNET_SECURITY_EVIDENCE.md).
|
|
192
|
+
Keep the explicit overrides above: published package defaults remain unchanged until the external
|
|
193
|
+
review and release gate close.
|
|
194
|
+
|
|
131
195
|
## Browser signer (Leather and other Stacks wallets)
|
|
132
196
|
|
|
133
197
|
`StacksConnectSigner` adapts the official Stacks Connect request API. The application supplies
|
|
@@ -369,6 +433,48 @@ facilitator request body. See [`docs/X402_PAYMENTS.md`](docs/X402_PAYMENTS.md) f
|
|
|
369
433
|
Direct payments and `perkos-escrow-v1` are complementary. Use direct payments for immediate
|
|
370
434
|
resources and escrow for jobs that require delivery, evaluation, payout, or reputation.
|
|
371
435
|
|
|
436
|
+
## MPP PaymentAuth with USDCx on Stacks
|
|
437
|
+
|
|
438
|
+
MPP is a separate standards-based commerce path beside x402. Nayori implements the official
|
|
439
|
+
`Payment` HTTP authentication scheme with `method="usdc"`, `intent="charge"` and the direct Stacks
|
|
440
|
+
USDCx profile. The server issues a canonical `WWW-Authenticate: Payment` challenge and selects
|
|
441
|
+
`Payment-Authorization` for the payment credential, leaving `Authorization: Bearer` available for
|
|
442
|
+
OAuth.
|
|
443
|
+
|
|
444
|
+
```ts
|
|
445
|
+
import {
|
|
446
|
+
createNayoriMppUsdcStacksChallenge,
|
|
447
|
+
createNayoriMppUsdcStacksCredential,
|
|
448
|
+
encodeNayoriMppCredentialHeader,
|
|
449
|
+
} from "@perkos/agent-sdk";
|
|
450
|
+
|
|
451
|
+
const { challenge, wwwAuthenticate } =
|
|
452
|
+
await createNayoriMppUsdcStacksChallenge({
|
|
453
|
+
quote: trustedUsdcxQuote,
|
|
454
|
+
realm: "api.nayori.ai",
|
|
455
|
+
description: "Nayori paid agent request",
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
const credential = createNayoriMppUsdcStacksCredential({
|
|
459
|
+
challenge,
|
|
460
|
+
source: `stacks:2147483648:${payerAddress}`,
|
|
461
|
+
transaction: walletSignedTransactionHex,
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
console.log(wwwAuthenticate);
|
|
465
|
+
console.log(encodeNayoriMppCredentialHeader(credential));
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
The verifier reuses Nayori's exact request-bound Stacks transaction checks and adds the MPP rules:
|
|
469
|
+
RFC 8785 envelopes, CAIP-10 source, canonical official USDCx identity, `OnChainOnly`, standard
|
|
470
|
+
single-signature authorization and low-s signing. Replay persistence, nonce/balance preflight,
|
|
471
|
+
broadcast, confirmations, receipt delivery and merchant authentication remain hosted Platform
|
|
472
|
+
responsibilities. See [MPP payments](docs/MPP_PAYMENTS.md) for the complete flow and trust boundary.
|
|
473
|
+
|
|
474
|
+
The testnet registry follows Circle xReserve remote domain `10003` and the current canonical token
|
|
475
|
+
`ST2WK9SGBJ15RHZ33KK0KYVSXBEBHM1XDM8C96EC4.usdcx`. Mainnet remains
|
|
476
|
+
`SP120SBRBQJ00MCWS7TM5R8WJNTTKD5K0HFRC2CNE.usdcx`.
|
|
477
|
+
|
|
372
478
|
## x402 v2 Stacks facilitator
|
|
373
479
|
|
|
374
480
|
`PerkOSX402Facilitator` implements the official `SchemeNetworkFacilitator` interface. It reloads
|
|
@@ -414,6 +520,8 @@ or facilitator-submitted signed transaction.
|
|
|
414
520
|
- Set a budget and fund escrow.
|
|
415
521
|
- Assign a provider and submit a deliverable.
|
|
416
522
|
- Complete, reject, or expire a job.
|
|
523
|
+
- Settle an overdue candidate review to the provider with exact post-conditions.
|
|
524
|
+
- Read and retry durable candidate reputation synchronization.
|
|
417
525
|
- Rate a provider and read reputation.
|
|
418
526
|
|
|
419
527
|
## Security model
|
|
@@ -429,6 +537,9 @@ or facilitator-submitted signed transaction.
|
|
|
429
537
|
- Automated workflows can wait for an explicit terminal confirmation before their next action.
|
|
430
538
|
- x402 quotes are bound to the configured network, escrow contract, asset, job, and exact budget.
|
|
431
539
|
- x402 settlement verifies current chain evidence and atomically consumes each funding txid once.
|
|
540
|
+
- MPP USDCx credentials echo a request-bound challenge and require a canonical, low-s,
|
|
541
|
+
`OnChainOnly` Stacks transfer; hosted settlement must still consume challenge and replay keys
|
|
542
|
+
atomically before broadcast.
|
|
432
543
|
- Partner OAuth enrollment signs an exact, short-lived, invitation-bound message in the wallet;
|
|
433
544
|
the SDK normalizes the public signature but never receives a private key.
|
|
434
545
|
- OAuth client secrets and access tokens are application secrets. The SDK returns them to the
|
|
@@ -437,7 +548,8 @@ or facilitator-submitted signed transaction.
|
|
|
437
548
|
This package has not yet completed the external security review required for PerkOS Milestone 2.
|
|
438
549
|
Do not treat the developer release as audited software.
|
|
439
550
|
|
|
440
|
-
See [Architecture](docs/ARCHITECTURE.md), [
|
|
551
|
+
See [Architecture](docs/ARCHITECTURE.md), [x402 payments](docs/X402_PAYMENTS.md),
|
|
552
|
+
[MPP payments](docs/MPP_PAYMENTS.md), [Partner pilot](docs/PARTNER_PILOT.md) and
|
|
441
553
|
[Security](SECURITY.md) for the trust boundaries and
|
|
442
554
|
responsible disclosure process.
|
|
443
555
|
|
package/SECURITY.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Release status
|
|
4
4
|
|
|
5
|
-
`@perkos/agent-sdk` 0.
|
|
5
|
+
`@perkos/agent-sdk` 0.5.0 is an M2 developer release and has not completed the external security
|
|
6
6
|
review required for the PerkOS Stacks Endowment milestone.
|
|
7
7
|
|
|
8
8
|
Do not use this developer release to control material funds without your own review. Inspect every
|
|
@@ -40,6 +40,10 @@ disclosure.
|
|
|
40
40
|
- Explicit direct-payment recipient, HTTPS origin, merchant, amount, fee, and session limits.
|
|
41
41
|
- Concurrent payment reservations that prevent asynchronous agents from oversubscribing a budget.
|
|
42
42
|
- Independent verification of every signed direct-payment transaction before facilitator submission.
|
|
43
|
+
- MPP PaymentAuth challenge binding, canonical JCS/base64url envelopes, CAIP-10 source matching,
|
|
44
|
+
official USDCx identity, `OnChainOnly`, standard single-signature authorization and low-s checks.
|
|
45
|
+
- MPP sponsorship is disabled; the pure verifier never represents a wallet approval, broadcast or
|
|
46
|
+
mempool response as confirmed settlement.
|
|
43
47
|
- Invitation-bound partner enrollment through exact Stacks message signing, with compressed public
|
|
44
48
|
key and recoverable-signature validation before API submission.
|
|
45
49
|
- OAuth client secrets and tokens remain caller-owned and are never persisted or automatically
|
|
@@ -86,3 +90,8 @@ The SDK prepares, validates, and submits transaction plans through an applicatio
|
|
|
86
90
|
signer. It does not prove that the signer implementation is safe. Applications must protect
|
|
87
91
|
private keys, verify wallet prompts, authenticate agent commands, and treat external tool or
|
|
88
92
|
model output as untrusted.
|
|
93
|
+
|
|
94
|
+
The MPP verifier does not authenticate merchants, check live nonces or balances, inspect token
|
|
95
|
+
pause/blocklist controls, persist challenge or transaction replay state, broadcast, reconcile,
|
|
96
|
+
confirm or deliver resources. A hosted deployment must enforce those controls atomically and must
|
|
97
|
+
only issue `Payment-Receipt` after its configured confirmation threshold is met.
|
package/dist/builders.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AssignProviderInput, ContractCallPlan, CreateJobInput, FundJobInput, JobAmountInput, RateProviderInput, RegisterAgentInput, ResolvedPerkOSConfig, SettleJobInput, SubmitWorkInput, UpdateAgentInput } from "./types.js";
|
|
1
|
+
import type { AssignProviderInput, ContractCallPlan, CreateJobInput, FundJobInput, JobAmountInput, PaymentAsset, RateProviderInput, RegisterAgentInput, ResolvedPerkOSConfig, SettleJobInput, SubmitWorkInput, UpdateAgentInput } from "./types.js";
|
|
2
2
|
export declare class PerkOSTransactionBuilder {
|
|
3
3
|
readonly config: ResolvedPerkOSConfig;
|
|
4
4
|
constructor(config: ResolvedPerkOSConfig);
|
|
@@ -13,6 +13,8 @@ export declare class PerkOSTransactionBuilder {
|
|
|
13
13
|
completeJob(input: SettleJobInput): ContractCallPlan;
|
|
14
14
|
rejectJob(input: SettleJobInput): ContractCallPlan;
|
|
15
15
|
expireJob(input: SettleJobInput): ContractCallPlan;
|
|
16
|
+
settleReviewTimeout(input: SettleJobInput): ContractCallPlan;
|
|
17
|
+
retryReputationSync(asset: PaymentAsset, jobIdInput: bigint | number | string): ContractCallPlan;
|
|
16
18
|
rateProvider(input: RateProviderInput): ContractCallPlan;
|
|
17
19
|
private settlement;
|
|
18
20
|
}
|
package/dist/builders.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAEhB,cAAc,EACd,YAAY,EACZ,cAAc,
|
|
1
|
+
{"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAEhB,cAAc,EACd,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAkFpB,qBAAa,wBAAwB;IACnC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;gBAE1B,MAAM,EAAE,oBAAoB;IAIxC,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,gBAAgB;IA8B1D,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,gBAAgB;IAuBtD,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,gBAAgB;IAWzE,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,gBAAgB;IAsBlD,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,gBAAgB;IAYlD,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,gBAAgB;IA2B9C,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,gBAAgB;IAiB5D,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,gBAAgB;IAWpD,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,gBAAgB;IAIpD,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,gBAAgB;IAIlD,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,gBAAgB;IAIlD,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,gBAAgB;IAI5D,mBAAmB,CACjB,KAAK,EAAE,YAAY,EACnB,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GACnC,gBAAgB;IAWnB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,gBAAgB;IAgBxD,OAAO,CAAC,UAAU;CAoCnB"}
|
package/dist/builders.js
CHANGED
|
@@ -16,20 +16,20 @@ function plan(config, contract, functionName, functionArgs, intent, postConditio
|
|
|
16
16
|
intent,
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
function tokenArg(config) {
|
|
20
|
-
const token = parseContractId(
|
|
19
|
+
function tokenArg(config, tokenContract = config.contracts.sbtcToken) {
|
|
20
|
+
const token = parseContractId(tokenContract, "sbtcToken", config.network);
|
|
21
21
|
return Cl.contractPrincipal(token.address, token.name);
|
|
22
22
|
}
|
|
23
|
-
function escrowArgs(config, asset, baseArgs) {
|
|
24
|
-
return asset === "sbtc" ? [...baseArgs, tokenArg(config)] : baseArgs;
|
|
23
|
+
function escrowArgs(config, asset, baseArgs, sbtcToken) {
|
|
24
|
+
return asset === "sbtc" ? [...baseArgs, tokenArg(config, sbtcToken)] : baseArgs;
|
|
25
25
|
}
|
|
26
|
-
function exactTransfer(config, asset, sender, amount) {
|
|
26
|
+
function exactTransfer(config, asset, sender, amount, sbtcToken) {
|
|
27
27
|
if (asset === "stx") {
|
|
28
28
|
return Pc.principal(sender).willSendEq(amount).ustx();
|
|
29
29
|
}
|
|
30
30
|
return Pc.principal(sender)
|
|
31
31
|
.willSendEq(amount)
|
|
32
|
-
.ft(config.contracts.sbtcToken, config.contracts.sbtcAssetName);
|
|
32
|
+
.ft(sbtcToken ?? config.contracts.sbtcToken, config.contracts.sbtcAssetName);
|
|
33
33
|
}
|
|
34
34
|
function deliverableBuffer(value) {
|
|
35
35
|
const bytes = typeof value === "string"
|
|
@@ -153,6 +153,13 @@ export class PerkOSTransactionBuilder {
|
|
|
153
153
|
expireJob(input) {
|
|
154
154
|
return this.settlement("expire-job", input);
|
|
155
155
|
}
|
|
156
|
+
settleReviewTimeout(input) {
|
|
157
|
+
return this.settlement("settle-review-timeout", input);
|
|
158
|
+
}
|
|
159
|
+
retryReputationSync(asset, jobIdInput) {
|
|
160
|
+
const jobId = toUint(jobIdInput, "jobId");
|
|
161
|
+
return plan(this.config, commerceContract(this.config, asset), "retry-reputation-sync", [Cl.uint(jobId)], { operation: "retry-reputation-sync", asset, jobId });
|
|
162
|
+
}
|
|
156
163
|
rateProvider(input) {
|
|
157
164
|
const jobId = toUint(input.jobId, "jobId");
|
|
158
165
|
const score = toUint(input.score, "score");
|
|
@@ -167,8 +174,15 @@ export class PerkOSTransactionBuilder {
|
|
|
167
174
|
const amount = toUint(input.amount, "amount", true);
|
|
168
175
|
assertPrincipal(input.recipient, "recipient", this.config.network);
|
|
169
176
|
const contract = commerceContract(this.config, input.asset);
|
|
170
|
-
const
|
|
171
|
-
|
|
177
|
+
const sbtcToken = input.asset === "sbtc"
|
|
178
|
+
? input.sbtcToken ?? this.config.contracts.sbtcToken
|
|
179
|
+
: undefined;
|
|
180
|
+
if (sbtcToken)
|
|
181
|
+
parseContractId(sbtcToken, "sbtcToken", this.config.network);
|
|
182
|
+
const postConditions = amount > 0n
|
|
183
|
+
? [exactTransfer(this.config, input.asset, contract, amount, sbtcToken)]
|
|
184
|
+
: [];
|
|
185
|
+
return plan(this.config, contract, operation, escrowArgs(this.config, input.asset, [Cl.uint(jobId)], sbtcToken), {
|
|
172
186
|
operation,
|
|
173
187
|
asset: input.asset,
|
|
174
188
|
amount,
|
package/dist/builders.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builders.js","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAgB1C,OAAO,EACL,WAAW,EACX,eAAe,EACf,eAAe,EACf,MAAM,GACP,MAAM,iBAAiB,CAAC;AAEzB,SAAS,gBAAgB,CAAC,MAA4B,EAAE,KAAmB;IACzE,OAAO,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC;AACzF,CAAC;AAED,SAAS,IAAI,CACX,MAA4B,EAC5B,QAAoB,EACpB,YAAoB,EACpB,YAAqC,EACrC,MAAkC,EAClC,iBAA2C,EAAE;IAE7C,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,QAAQ;QAC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e,CAAC,SAAS,EAAE,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC5E,MAAM,cAAc,GAClB,MAAM,GAAG,EAAE;YACT,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;YACxE,CAAC,CAAC,EAAE,CAAC;QACT,OAAO,IAAI,CACT,IAAI,CAAC,MAAM,EACX,QAAQ,EACR,SAAS,EACT,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,EACjE;YACE,SAAS;YACT,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,MAAM;YACN,KAAK;YACL,SAAS,EAAE,KAAK,CAAC,SAAS;SAC3B,EACD,cAAc,CACf,CAAC;IACJ,CAAC;CACF"}
|
package/dist/clarity.d.ts
CHANGED
|
@@ -8,4 +8,5 @@ export declare function expectPrincipal(value: ClarityValue | undefined, context
|
|
|
8
8
|
export declare function expectBoolean(value: ClarityValue | undefined, context: string): boolean;
|
|
9
9
|
export declare function optionalPrincipal(value: ClarityValue | undefined, context: string): string | undefined;
|
|
10
10
|
export declare function optionalBuffer(value: ClarityValue | undefined, context: string): string | undefined;
|
|
11
|
+
export declare function optionalUint(value: ClarityValue | undefined, context: string): bigint | undefined;
|
|
11
12
|
//# sourceMappingURL=clarity.d.ts.map
|
package/dist/clarity.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clarity.d.ts","sourceRoot":"","sources":["../src/clarity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EAKZ,OAAO,EACR,MAAM,sBAAsB,CAAC;AAQ9B,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAA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AAO,EAAE,MAAM,GAAG,SAAS,YAAY,EAAE,CAKxF;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAKnF;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAQrF;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CASxF;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAKvF;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,YAAY,GAAG,SAAS,EAC/B,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,SAAS,CAMpB;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,YAAY,GAAG,SAAS,EAC/B,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,SAAS,CAUpB;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,YAAY,GAAG,SAAS,EAC/B,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,SAAS,CAMpB"}
|
package/dist/clarity.js
CHANGED
|
@@ -77,4 +77,12 @@ export function optionalBuffer(value, context) {
|
|
|
77
77
|
}
|
|
78
78
|
return inner.value;
|
|
79
79
|
}
|
|
80
|
+
export function optionalUint(value, context) {
|
|
81
|
+
if (!value || value.type === ClarityType.OptionalNone)
|
|
82
|
+
return undefined;
|
|
83
|
+
if (value.type !== ClarityType.OptionalSome) {
|
|
84
|
+
throw new PerkOSError("READ_FAILED", `${context} must be a Clarity optional.`);
|
|
85
|
+
}
|
|
86
|
+
return expectUint(value.value, context);
|
|
87
|
+
}
|
|
80
88
|
//# sourceMappingURL=clarity.js.map
|
package/dist/clarity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3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AED,MAAM,UAAU,cAAc,CAC5B,KAA+B,EAC/B,OAAe;IAEf,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC,YAAY;QAAE,OAAO,SAAS,CAAC;IACxE,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC,YAAY,EAAE,CAAC;QAC5C,MAAM,IAAI,WAAW,CAAC,aAAa,EAAE,GAAG,OAAO,8BAA8B,CAAC,CAAC;IACjF,CAAC;IACD,MAAM,KAAK,GAAI,KAA8B,CAAC,KAAK,CAAC;IACpD,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC,MAAM,EAAE,CAAC;QACtC,MAAM,IAAI,WAAW,CAAC,aAAa,EAAE,GAAG,OAAO,iCAAiC,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,KAAK,CAAC,KAAK,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,KAA+B,EAC/B,OAAe;IAEf,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC,YAAY;QAAE,OAAO,SAAS,CAAC;IACxE,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC,YAAY,EAAE,CAAC;QAC5C,MAAM,IAAI,WAAW,CAAC,aAAa,EAAE,GAAG,OAAO,8BAA8B,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,UAAU,CAAE,KAA8B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACpE,CAAC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PerkOSTransactionBuilder } from "./builders.js";
|
|
2
2
|
import { SpendingPolicy } from "./policy.js";
|
|
3
|
-
import type { AgentRecord, AssignProviderInput, ConfirmationOptions, ConfirmedTransactionReceipt, ContractCallPlan, CreateJobInput, FundJobInput, JobAmountInput, JobRecord, PaymentAsset, PerkOSConfig, RateProviderInput, RegisterAgentInput, ReputationRecord, SpendingApproval, SubmitWorkInput, TransactionConfirmation, TransactionReceipt, TransactionTrackerLike, UpdateAgentInput } from "./types.js";
|
|
3
|
+
import type { AgentRecord, AssignProviderInput, ConfirmationOptions, ConfirmedTransactionReceipt, ContractCallPlan, ContractId, CreateJobInput, FundJobInput, JobAmountInput, JobRecord, PaymentAsset, PerkOSConfig, RateProviderInput, RegisterAgentInput, ReputationRecord, ReputationSyncRecord, SpendingApproval, SubmitWorkInput, TransactionConfirmation, TransactionReceipt, TransactionTrackerLike, UpdateAgentInput } from "./types.js";
|
|
4
4
|
export declare class PerkOSClient {
|
|
5
5
|
readonly config: import("./types.js").ResolvedPerkOSConfig;
|
|
6
6
|
readonly transactions: PerkOSTransactionBuilder;
|
|
@@ -19,6 +19,9 @@ export declare class PerkOSClient {
|
|
|
19
19
|
getJob(asset: PaymentAsset, jobIdInput: bigint | number | string): Promise<JobRecord | null>;
|
|
20
20
|
getEscrowBalance(asset: PaymentAsset, jobIdInput: bigint | number | string): Promise<bigint>;
|
|
21
21
|
getConfiguredSbtcToken(): Promise<string>;
|
|
22
|
+
getJobPaymentToken(jobIdInput: bigint | number | string): Promise<ContractId>;
|
|
23
|
+
getReviewWindow(asset: PaymentAsset): Promise<bigint>;
|
|
24
|
+
getReputationSync(asset: PaymentAsset, jobIdInput: bigint | number | string): Promise<ReputationSyncRecord | null>;
|
|
22
25
|
getReputation(agent: string): Promise<ReputationRecord>;
|
|
23
26
|
registerAgent(input: RegisterAgentInput): Promise<TransactionReceipt>;
|
|
24
27
|
updateAgent(input: UpdateAgentInput): Promise<TransactionReceipt>;
|
|
@@ -31,6 +34,8 @@ export declare class PerkOSClient {
|
|
|
31
34
|
completeJob(asset: PaymentAsset, jobIdInput: bigint | number | string): Promise<TransactionReceipt>;
|
|
32
35
|
rejectJob(asset: PaymentAsset, jobIdInput: bigint | number | string): Promise<TransactionReceipt>;
|
|
33
36
|
expireJob(asset: PaymentAsset, jobIdInput: bigint | number | string): Promise<TransactionReceipt>;
|
|
37
|
+
settleReviewTimeout(asset: PaymentAsset, jobIdInput: bigint | number | string): Promise<TransactionReceipt>;
|
|
38
|
+
retryReputationSync(asset: PaymentAsset, jobIdInput: bigint | number | string): Promise<TransactionReceipt>;
|
|
34
39
|
rateProvider(input: RateProviderInput): Promise<TransactionReceipt>;
|
|
35
40
|
private settlementInput;
|
|
36
41
|
private requireSignerAddress;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,2BAA2B,EAC3B,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,YAAY,EACZ,cAAc,EACd,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,iBAAiB,EAGjB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EAEpB,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AA4BpB,qBAAa,YAAY;IACvB,QAAQ,CAAC,MAAM,4CAAC;IAChB,QAAQ,CAAC,YAAY,EAAE,wBAAwB,CAAC;IAChD,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IACxB,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAoB;gBAE1C,KAAK,EAAE,YAAY;IAc/B,OAAO,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB;IAI3C,OAAO,CAAC,IAA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
-
import { expectBoolean, expectList, expectPrincipal, expectString, expectTuple, expectUint, optionalBuffer, optionalPrincipal, unwrapResponse, } from "./clarity.js";
|
|
3
|
+
import { expectBoolean, expectList, expectPrincipal, expectString, expectTuple, expectUint, optionalBuffer, optionalPrincipal, optionalUint, unwrapResponse, } from "./clarity.js";
|
|
4
4
|
import { PerkOSError } from "./errors.js";
|
|
5
5
|
import { PerkOSTransactionBuilder } from "./builders.js";
|
|
6
6
|
import { SpendingPolicy } from "./policy.js";
|
|
7
7
|
import { TransactionTracker } from "./tracker.js";
|
|
8
8
|
import { normalizeTxid } from "./txid.js";
|
|
9
9
|
import { assertPrincipal, parseContractId, resolveConfig, toUint } from "./validation.js";
|
|
10
|
+
const PINNED_TOKEN_SBTC_CONTRACTS = new Set([
|
|
11
|
+
"sbtc-commerce-v2",
|
|
12
|
+
"sbtc-commerce-v3",
|
|
13
|
+
]);
|
|
10
14
|
function contractForAsset(contracts, asset) {
|
|
11
15
|
return asset === "sbtc" ? contracts.sbtcCommerce : contracts.stxCommerce;
|
|
12
16
|
}
|
|
@@ -151,6 +155,8 @@ export class PerkOSClient {
|
|
|
151
155
|
}
|
|
152
156
|
const provider = optionalPrincipal(tuple.provider, "job.provider");
|
|
153
157
|
const deliverable = optionalBuffer(tuple.deliverable, "job.deliverable");
|
|
158
|
+
const submittedAtBurn = optionalUint(tuple["submitted-at-burn"], "job.submitted-at-burn");
|
|
159
|
+
const reviewDeadline = optionalUint(tuple["review-deadline"], "job.review-deadline");
|
|
154
160
|
return {
|
|
155
161
|
id: jobId,
|
|
156
162
|
asset,
|
|
@@ -163,12 +169,17 @@ export class PerkOSClient {
|
|
|
163
169
|
status,
|
|
164
170
|
statusCode,
|
|
165
171
|
...(deliverable ? { deliverable } : {}),
|
|
172
|
+
...(submittedAtBurn !== undefined ? { submittedAtBurn } : {}),
|
|
173
|
+
...(reviewDeadline !== undefined ? { reviewDeadline } : {}),
|
|
166
174
|
};
|
|
167
175
|
}
|
|
168
176
|
catch (error) {
|
|
169
177
|
if (error instanceof PerkOSError &&
|
|
170
178
|
error.code === "CONTRACT_ERROR" &&
|
|
171
|
-
(error.details?.clarityCode === 202n ||
|
|
179
|
+
(error.details?.clarityCode === 202n ||
|
|
180
|
+
error.details?.clarityCode === 302n ||
|
|
181
|
+
error.details?.clarityCode === 602n ||
|
|
182
|
+
error.details?.clarityCode === 702n)) {
|
|
172
183
|
return null;
|
|
173
184
|
}
|
|
174
185
|
throw error;
|
|
@@ -185,6 +196,51 @@ export class PerkOSClient {
|
|
|
185
196
|
const value = unwrapResponse(await this.read(this.config.contracts.sbtcCommerce, "get-payment-token"), "get-payment-token");
|
|
186
197
|
return expectPrincipal(value, "get-payment-token");
|
|
187
198
|
}
|
|
199
|
+
async getJobPaymentToken(jobIdInput) {
|
|
200
|
+
const jobId = toUint(jobIdInput, "jobId");
|
|
201
|
+
const value = unwrapResponse(await this.read(this.config.contracts.sbtcCommerce, "get-job-payment-token", [
|
|
202
|
+
Cl.uint(jobId),
|
|
203
|
+
]), "get-job-payment-token");
|
|
204
|
+
const token = expectPrincipal(value, "get-job-payment-token");
|
|
205
|
+
parseContractId(token, "get-job-payment-token", this.config.network);
|
|
206
|
+
return token;
|
|
207
|
+
}
|
|
208
|
+
async getReviewWindow(asset) {
|
|
209
|
+
const value = unwrapResponse(await this.read(contractForAsset(this.config.contracts, asset), "get-review-window"), "get-review-window");
|
|
210
|
+
return expectUint(value, "get-review-window");
|
|
211
|
+
}
|
|
212
|
+
async getReputationSync(asset, jobIdInput) {
|
|
213
|
+
const jobId = toUint(jobIdInput, "jobId");
|
|
214
|
+
try {
|
|
215
|
+
const value = unwrapResponse(await this.read(contractForAsset(this.config.contracts, asset), "get-reputation-sync", [Cl.uint(jobId)]), "get-reputation-sync");
|
|
216
|
+
const tuple = expectTuple(value, "get-reputation-sync");
|
|
217
|
+
const outcomeCode = expectUint(tuple.outcome, "reputation-sync.outcome");
|
|
218
|
+
const outcome = outcomeCode === 1n
|
|
219
|
+
? "completed"
|
|
220
|
+
: outcomeCode === 2n
|
|
221
|
+
? "disputed"
|
|
222
|
+
: undefined;
|
|
223
|
+
if (!outcome) {
|
|
224
|
+
throw new PerkOSError("READ_FAILED", `Unknown reputation synchronization outcome ${outcomeCode}.`);
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
jobId,
|
|
228
|
+
asset,
|
|
229
|
+
outcome,
|
|
230
|
+
outcomeCode,
|
|
231
|
+
pending: expectBoolean(tuple.pending, "reputation-sync.pending"),
|
|
232
|
+
lastError: expectUint(tuple["last-error"], "reputation-sync.last-error"),
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
if (error instanceof PerkOSError &&
|
|
237
|
+
error.code === "CONTRACT_ERROR" &&
|
|
238
|
+
(error.details?.clarityCode === 623n || error.details?.clarityCode === 723n)) {
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
throw error;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
188
244
|
async getReputation(agent) {
|
|
189
245
|
assertPrincipal(agent, "agent", this.config.network);
|
|
190
246
|
const value = unwrapResponse(await this.read(this.config.contracts.reputationRegistry, "get-reputation", [
|
|
@@ -249,25 +305,44 @@ export class PerkOSClient {
|
|
|
249
305
|
const settlement = await this.settlementInput("expire-job", asset, jobIdInput);
|
|
250
306
|
return this.execute(this.transactions.expireJob(settlement));
|
|
251
307
|
}
|
|
308
|
+
async settleReviewTimeout(asset, jobIdInput) {
|
|
309
|
+
const settlement = await this.settlementInput("settle-review-timeout", asset, jobIdInput);
|
|
310
|
+
return this.execute(this.transactions.settleReviewTimeout(settlement));
|
|
311
|
+
}
|
|
312
|
+
retryReputationSync(asset, jobIdInput) {
|
|
313
|
+
return this.execute(this.transactions.retryReputationSync(asset, jobIdInput));
|
|
314
|
+
}
|
|
252
315
|
rateProvider(input) {
|
|
253
316
|
return this.execute(this.transactions.rateProvider(input));
|
|
254
317
|
}
|
|
255
318
|
async settlementInput(operation, asset, jobIdInput) {
|
|
256
319
|
const jobId = toUint(jobIdInput, "jobId");
|
|
320
|
+
const sbtcContractName = parseContractId(this.config.contracts.sbtcCommerce, "contracts.sbtcCommerce", this.config.network).name;
|
|
321
|
+
const readsPinnedToken = asset === "sbtc" &&
|
|
322
|
+
PINNED_TOKEN_SBTC_CONTRACTS.has(sbtcContractName);
|
|
257
323
|
const [job, amount] = await Promise.all([
|
|
258
324
|
this.getJob(asset, jobId),
|
|
259
325
|
this.getEscrowBalance(asset, jobId),
|
|
260
326
|
]);
|
|
327
|
+
const sbtcToken = readsPinnedToken && amount > 0n
|
|
328
|
+
? await this.getJobPaymentToken(jobId)
|
|
329
|
+
: undefined;
|
|
261
330
|
if (!job) {
|
|
262
331
|
throw new PerkOSError("INPUT_INVALID", `Job ${jobId} does not exist.`);
|
|
263
332
|
}
|
|
264
|
-
const recipient = operation === "complete-job"
|
|
333
|
+
const recipient = operation === "complete-job" || operation === "settle-review-timeout"
|
|
265
334
|
? job.provider
|
|
266
335
|
: job.client;
|
|
267
336
|
if (!recipient) {
|
|
268
337
|
throw new PerkOSError("INPUT_INVALID", `Job ${jobId} has no provider to receive settlement.`);
|
|
269
338
|
}
|
|
270
|
-
return {
|
|
339
|
+
return {
|
|
340
|
+
asset,
|
|
341
|
+
jobId,
|
|
342
|
+
amount,
|
|
343
|
+
recipient,
|
|
344
|
+
...(sbtcToken ? { sbtcToken } : {}),
|
|
345
|
+
};
|
|
271
346
|
}
|
|
272
347
|
async requireSignerAddress() {
|
|
273
348
|
if (!this.signer) {
|