veilioexchange 0.1.0 → 0.3.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/CHANGELOG.md +37 -0
- package/LICENSE +21 -21
- package/README.md +225 -113
- package/dist/cjs/auth.d.ts +15 -0
- package/dist/cjs/auth.d.ts.map +1 -1
- package/dist/cjs/auth.js +32 -0
- package/dist/cjs/auth.js.map +1 -1
- package/dist/cjs/deployments.js +2 -2
- package/dist/cjs/index.d.ts +260 -6
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +221 -62
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/servicesApi.d.ts +86 -0
- package/dist/cjs/servicesApi.d.ts.map +1 -0
- package/dist/cjs/servicesApi.js +177 -0
- package/dist/cjs/servicesApi.js.map +1 -0
- package/dist/cjs/solana/auction.d.ts +230 -0
- package/dist/cjs/solana/auction.d.ts.map +1 -0
- package/dist/cjs/solana/auction.js +546 -0
- package/dist/cjs/solana/auction.js.map +1 -0
- package/dist/cjs/solana/client.d.ts +100 -0
- package/dist/cjs/solana/client.d.ts.map +1 -0
- package/dist/cjs/solana/client.js +368 -0
- package/dist/cjs/solana/client.js.map +1 -0
- package/dist/cjs/solana/escrow.d.ts +193 -0
- package/dist/cjs/solana/escrow.d.ts.map +1 -0
- package/dist/cjs/solana/escrow.js +463 -0
- package/dist/cjs/solana/escrow.js.map +1 -0
- package/dist/cjs/solana/index.d.ts +9 -0
- package/dist/cjs/solana/index.d.ts.map +1 -0
- package/dist/cjs/solana/index.js +35 -0
- package/dist/cjs/solana/index.js.map +1 -0
- package/dist/cjs/solana/registry.d.ts +112 -0
- package/dist/cjs/solana/registry.d.ts.map +1 -0
- package/dist/cjs/solana/registry.js +305 -0
- package/dist/cjs/solana/registry.js.map +1 -0
- package/dist/esm/auth.d.ts +15 -0
- package/dist/esm/auth.d.ts.map +1 -1
- package/dist/esm/auth.js +28 -0
- package/dist/esm/auth.js.map +1 -1
- package/dist/esm/deployments.js +2 -2
- package/dist/esm/index.d.ts +260 -6
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +218 -61
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/servicesApi.d.ts +86 -0
- package/dist/esm/servicesApi.d.ts.map +1 -0
- package/dist/esm/servicesApi.js +174 -0
- package/dist/esm/servicesApi.js.map +1 -0
- package/dist/esm/solana/auction.d.ts +230 -0
- package/dist/esm/solana/auction.d.ts.map +1 -0
- package/dist/esm/solana/auction.js +523 -0
- package/dist/esm/solana/auction.js.map +1 -0
- package/dist/esm/solana/client.d.ts +100 -0
- package/dist/esm/solana/client.d.ts.map +1 -0
- package/dist/esm/solana/client.js +361 -0
- package/dist/esm/solana/client.js.map +1 -0
- package/dist/esm/solana/escrow.d.ts +193 -0
- package/dist/esm/solana/escrow.d.ts.map +1 -0
- package/dist/esm/solana/escrow.js +444 -0
- package/dist/esm/solana/escrow.js.map +1 -0
- package/dist/esm/solana/index.d.ts +9 -0
- package/dist/esm/solana/index.d.ts.map +1 -0
- package/dist/esm/solana/index.js +9 -0
- package/dist/esm/solana/index.js.map +1 -0
- package/dist/esm/solana/registry.d.ts +112 -0
- package/dist/esm/solana/registry.d.ts.map +1 -0
- package/dist/esm/solana/registry.js +289 -0
- package/dist/esm/solana/registry.js.map +1 -0
- package/package.json +82 -55
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- **Auction lifecycle (EVM, VeilNFTV4):** `settleAuction`, `finalizeSettlement`, `requestRefund(auctionId, evidenceHash)`,
|
|
7
|
+
`withdrawRefund`, `getPendingRefund`, `isNftAuction`, `waitForTransaction`. `finalizeSettlement` is the
|
|
8
|
+
completion path for NFT auctions (`acceptDataset` is blocked on-chain for NFTs); `claimAsset` now throws a
|
|
9
|
+
clear error for NFT auctions instead of sending a transaction that reverts.
|
|
10
|
+
- **Base Sepolia auctions:** `createVeilioAgent({ chainId: 84532 })` picks the Base Sepolia auction and Services
|
|
11
|
+
escrow defaults from `VEILIO_DEPLOYMENTS`. New exports: `VEILIO_SUPPORTED_CHAIN_IDS`, `getVeilioDeployment`,
|
|
12
|
+
`assertVeilioChainId`, `veilAuctionAbi`.
|
|
13
|
+
- **Off-chain Services API helper:** `createVeilioServicesApi({ apiBaseUrl, signer })` with `notifyDeposit`,
|
|
14
|
+
`submit` (requires `deliveryTxHash`, the on-chain `submitDelivery` tx), `requestRevision`, `approve`,
|
|
15
|
+
`cancel`, each signed with `signServiceAuth`. It never sends a `network` field; the server derives the
|
|
16
|
+
chain from the order. Session-authenticated reads: `getOrder`, `getPaymentRequest`, `listConversations`,
|
|
17
|
+
`getConversationMessages`, `getSession`, `getSessionHeaders`.
|
|
18
|
+
- **Read session auth:** `signServiceSession`, `isServiceSessionFresh`, `encodeServiceAuthHeader`,
|
|
19
|
+
`SERVICE_AUTH_HEADER` (`x-veilio-auth`), `SERVICE_SESSION_MAX_AGE_MS` (30 min).
|
|
20
|
+
- **Solana auction client:** `settleAuction`, `requestRefund`, `finalizeInspectionTimeout`, `finalizeRefundTimeout`.
|
|
21
|
+
- **Solana escrow:** `platformReviewer` / `platformFeeRecipient` client options used as defaults by `deposit()`.
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- Every agent write (`commitBid`, `revealBid`, lifecycle calls) now checks `walletClient.chain` against the
|
|
25
|
+
agent's `chainId` and throws `CHAIN_MISMATCH` before sending.
|
|
26
|
+
- `PreparedBid.chainId` is the agent's actual chain (was always 97).
|
|
27
|
+
- `createVeilioAgent().services` uses the agent's `chainId` (was always 97).
|
|
28
|
+
- `revealBid` rejects reveals after `revealEndTime` with a hint to call `settleAuction`.
|
|
29
|
+
- `getAuctionResult` adds `chainId` and `winningBid`; `winningBidBnb` is kept as a deprecated alias.
|
|
30
|
+
- Solana `deposit()`: `reviewer` / `feeRecipient` are now optional (default to the platform options) and a
|
|
31
|
+
reviewer equal to the buyer or seller is rejected. The deployed program still accepts any buyer-chosen
|
|
32
|
+
reviewer; see the README security note.
|
|
33
|
+
- Solana `reveal_bid` instruction marks the bidder account writable (it receives the over-deposit refund).
|
|
34
|
+
|
|
35
|
+
## 0.2.0
|
|
36
|
+
|
|
37
|
+
- Previous published release.
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 VEILIO
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 VEILIO
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,113 +1,225 @@
|
|
|
1
|
-
# veilioexchange
|
|
2
|
-
|
|
3
|
-
TypeScript SDK for **VEILIO**: sealed-bid auctions for digital assets and milestone service escrow, built on [viem](https://viem.sh).
|
|
4
|
-
|
|
5
|
-
- **Networks:** BNB Smart Chain Testnet (97)
|
|
6
|
-
- **Formats:** ESM and CommonJS, with TypeScript types.
|
|
7
|
-
- **Runtime:** Node.js 18+ or any modern browser.
|
|
8
|
-
|
|
9
|
-
```sh
|
|
10
|
-
npm install veilioexchange viem
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
`viem` is a peer dependency, so your app and the SDK share one copy.
|
|
14
|
-
|
|
15
|
-
## Auctions
|
|
16
|
-
|
|
17
|
-
```ts
|
|
18
|
-
import { createPublicClient, createWalletClient, http } from 'viem';
|
|
19
|
-
import { bscTestnet } from 'viem/chains';
|
|
20
|
-
import { privateKeyToAccount } from 'viem/accounts';
|
|
21
|
-
import { createVeilioAgent } from 'veilioexchange';
|
|
22
|
-
|
|
23
|
-
const account = privateKeyToAccount(process.env.AGENT_PRIVATE_KEY as `0x${string}`);
|
|
24
|
-
const publicClient = createPublicClient({ chain: bscTestnet, transport: http() });
|
|
25
|
-
const walletClient = createWalletClient({ account, chain: bscTestnet, transport: http() });
|
|
26
|
-
|
|
27
|
-
const agent = createVeilioAgent({
|
|
28
|
-
publicClient,
|
|
29
|
-
walletClient,
|
|
30
|
-
account: account.address,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
await agent.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
```ts
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
1
|
+
# veilioexchange
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for **VEILIO**: sealed-bid auctions for digital assets and milestone service escrow, built on [viem](https://viem.sh).
|
|
4
|
+
|
|
5
|
+
- **Networks:** BNB Smart Chain Testnet (97), Base Sepolia (84532) and Solana Devnet. Testnet only.
|
|
6
|
+
- **Formats:** ESM and CommonJS, with TypeScript types.
|
|
7
|
+
- **Runtime:** Node.js 18+ or any modern browser.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install veilioexchange viem
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`viem` is a peer dependency, so your app and the SDK share one copy.
|
|
14
|
+
|
|
15
|
+
## Auctions
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { createPublicClient, createWalletClient, http } from 'viem';
|
|
19
|
+
import { bscTestnet } from 'viem/chains';
|
|
20
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
21
|
+
import { createVeilioAgent } from 'veilioexchange';
|
|
22
|
+
|
|
23
|
+
const account = privateKeyToAccount(process.env.AGENT_PRIVATE_KEY as `0x${string}`);
|
|
24
|
+
const publicClient = createPublicClient({ chain: bscTestnet, transport: http() });
|
|
25
|
+
const walletClient = createWalletClient({ account, chain: bscTestnet, transport: http() });
|
|
26
|
+
|
|
27
|
+
const agent = createVeilioAgent({
|
|
28
|
+
publicClient,
|
|
29
|
+
walletClient,
|
|
30
|
+
account: account.address,
|
|
31
|
+
chainId: 97, // default; 84532 = Base Sepolia (use viem's baseSepolia clients)
|
|
32
|
+
apiBaseUrl: 'https://your-veilio-host', // needed for searchAssets / getAssetDetails
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const { auctions } = await agent.listAuctions({ limit: 20 });
|
|
36
|
+
const auctionId = auctions[0].id;
|
|
37
|
+
|
|
38
|
+
// Sealed bid: random 32-byte secret + keccak256 commitment, computed locally.
|
|
39
|
+
const bid = agent.prepareBid(auctionId, '0.05'); // max bid in BNB
|
|
40
|
+
// Store `bid` (including bid.secret) somewhere durable and encrypted.
|
|
41
|
+
// If the secret is lost the bid can never be revealed.
|
|
42
|
+
|
|
43
|
+
await agent.commitBid(bid, '0.08'); // deposit >= max bid; over-deposit to hide your ceiling
|
|
44
|
+
await agent.revealBid(bid); // during the Revealing window
|
|
45
|
+
|
|
46
|
+
// After revealEndTime anyone can settle; a winner moves the auction into Inspection.
|
|
47
|
+
await agent.waitForTransaction(await agent.settleAuction(auctionId));
|
|
48
|
+
|
|
49
|
+
const result = await agent.getAuctionResult(auctionId);
|
|
50
|
+
if (result.isWinner) {
|
|
51
|
+
if (await agent.isNftAuction(auctionId)) {
|
|
52
|
+
// NFT auctions: acceptDataset is blocked on-chain. Once inspection ends,
|
|
53
|
+
// finalizeSettlement() delivers the NFT and pays the seller (anyone can call it).
|
|
54
|
+
await agent.finalizeSettlement(auctionId);
|
|
55
|
+
} else {
|
|
56
|
+
await agent.claimAsset(auctionId); // acceptDataset
|
|
57
|
+
// or dispute during inspection: agent.requestRefund(auctionId, 'ipfs://QmEvidence')
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Losing deposits, over-deposits, seller proceeds and approved refunds are pull payments:
|
|
62
|
+
if ((await agent.getPendingRefund()) > 0n) await agent.withdrawRefund();
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Auction lifecycle (VeilNFTV4)
|
|
66
|
+
|
|
67
|
+
| Step | Method | Who | When |
|
|
68
|
+
|---|---|---|---|
|
|
69
|
+
| Commit | `commitBid(bid, deposit)` | bidder | Bidding |
|
|
70
|
+
| Reveal | `revealBid(bid)` | bidder | Revealing, before `revealEndTime` |
|
|
71
|
+
| Settle | `settleAuction(id)` | anyone | after `revealEndTime` |
|
|
72
|
+
| Accept (datasets only) | `claimAsset(id)` | winner | Inspection, before `inspectionEndTime` |
|
|
73
|
+
| Dispute | `requestRefund(id, evidenceHash)` | winner | Inspection, before `inspectionEndTime` |
|
|
74
|
+
| Complete (required for NFTs) | `finalizeSettlement(id)` | anyone | Inspection, after `inspectionEndTime` |
|
|
75
|
+
| Withdraw | `withdrawRefund()` | anyone with `getPendingRefund() > 0` | any time |
|
|
76
|
+
|
|
77
|
+
All write methods return the transaction hash; `waitForTransaction(hash)` waits and throws `TRANSACTION_REVERTED` on failure.
|
|
78
|
+
Every write checks that `walletClient.chain` matches the agent's `chainId` and throws `CHAIN_MISMATCH` before sending otherwise.
|
|
79
|
+
A refund request on the EVM contracts has no timeout: it stays open until the VEILIO reviewer resolves it.
|
|
80
|
+
|
|
81
|
+
## Services escrow
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { createVeilioServicesClient, signServiceAuth } from 'veilioexchange';
|
|
85
|
+
|
|
86
|
+
const services = createVeilioServicesClient({
|
|
87
|
+
publicClient,
|
|
88
|
+
walletClient,
|
|
89
|
+
account: account.address,
|
|
90
|
+
chainId: 97, // or 84532 for Base Sepolia (use matching viem clients)
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const orderId = 'srv-order-uuid-101';
|
|
94
|
+
|
|
95
|
+
const deposit = await services.deposit({
|
|
96
|
+
orderId,
|
|
97
|
+
seller: '0xSeller...',
|
|
98
|
+
deadline: Math.floor(Date.now() / 1000) + 3 * 86400,
|
|
99
|
+
amount: '0.25',
|
|
100
|
+
});
|
|
101
|
+
await deposit.wait();
|
|
102
|
+
|
|
103
|
+
const order = await services.getOrder(orderId); // status: 'Funded'
|
|
104
|
+
await (await services.submitDelivery(orderId, 'ipfs://QmProof')).wait(); // seller
|
|
105
|
+
await (await services.releaseFunds(orderId)).wait(); // buyer; 5% fee on release
|
|
106
|
+
|
|
107
|
+
// Fee-free exits: services.refund(orderId, reason), services.refundTimeout(orderId),
|
|
108
|
+
// services.dispute(orderId, reason)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Keeping the VEILIO app in sync (off-chain API)
|
|
112
|
+
|
|
113
|
+
The escrow contract moves funds, but the order status in the VEILIO app only changes when the API
|
|
114
|
+
is told about each step. `createVeilioServicesApi` signs every call with `signServiceAuth` (EIP-191):
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
import { createVeilioServicesApi } from 'veilioexchange';
|
|
118
|
+
|
|
119
|
+
const api = createVeilioServicesApi({ apiBaseUrl: 'https://your-veilio-host', signer: account });
|
|
120
|
+
|
|
121
|
+
await api.notifyDeposit({ orderId, txHash: deposit.txHash }); // buyer -> InProgress
|
|
122
|
+
const delivery = await services.submitDelivery(orderId, 'ipfs://QmProof'); // seller, on-chain first
|
|
123
|
+
await delivery.wait();
|
|
124
|
+
await api.submit({ orderId, deliveryTxHash: delivery.txHash, description: 'v1 delivered', deliverableReferences: ['ipfs://QmProof'] });
|
|
125
|
+
await api.requestRevision({ orderId, feedback: 'Please add the appendix' }); // buyer
|
|
126
|
+
await api.approve({ orderId, releaseTxHash: release.txHash }); // buyer -> Completed
|
|
127
|
+
await api.cancel({ orderId, reason: 'Mutual cancellation', txHash }); // funded orders need the refund tx
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
No `network` field is sent: the server derives the chain from the order. `submit` requires the
|
|
131
|
+
confirmed on-chain `submitDelivery` transaction (`deliveryTxHash`); the server checks its
|
|
132
|
+
`DeliverySubmitted` event. For custom requests, `signServiceAuth(account, action, orderId)` returns
|
|
133
|
+
the `{ address, signature, timestamp, nonce }` payload.
|
|
134
|
+
|
|
135
|
+
Reads use a 30-minute session signed once (`signServiceSession`) and sent in the `x-veilio-auth`
|
|
136
|
+
header; the helper caches it and re-signs a minute before expiry. It never authorizes state changes.
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
const { order } = await api.getOrder(orderId); // status, paymentStatus, network
|
|
140
|
+
const { conversations } = await api.listConversations();
|
|
141
|
+
await api.getPaymentRequest(paymentRequestId);
|
|
142
|
+
await api.getConversationMessages(conversationId);
|
|
143
|
+
const headers = await api.getSessionHeaders(); // for your own GET requests
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Solana Devnet
|
|
147
|
+
|
|
148
|
+
Solana lives in its own entry point so EVM-only users never load `@solana/web3.js`:
|
|
149
|
+
|
|
150
|
+
```sh
|
|
151
|
+
npm install veilioexchange @solana/web3.js
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
import { Connection, Keypair, clusterApiUrl } from '@solana/web3.js';
|
|
156
|
+
import { createVeilioSolanaClient, keypairSigner } from 'veilioexchange/solana';
|
|
157
|
+
|
|
158
|
+
const connection = new Connection(clusterApiUrl('devnet'), 'confirmed');
|
|
159
|
+
const agentKey = Keypair.fromSecretKey(/* load your devnet key from a secret store */);
|
|
160
|
+
|
|
161
|
+
const solana = createVeilioSolanaClient({
|
|
162
|
+
connection,
|
|
163
|
+
signer: keypairSigner(agentKey), // or a Phantom provider: window.phantom.solana
|
|
164
|
+
platformReviewer: 'VeilioReviewerWallet...', // default dispute reviewer for deposit()
|
|
165
|
+
platformFeeRecipient: 'VeilioFeeWallet...', // default fee recipient for deposit()
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// Sealed-bid auction
|
|
169
|
+
const auctions = await solana.listAuctions();
|
|
170
|
+
const bid = solana.prepareBid(auctions[0].auctionId, '0.25'); // max bid in SOL
|
|
171
|
+
// Store `bid` (salt included) in encrypted storage before committing.
|
|
172
|
+
await solana.commitBid(bid, '0.3');
|
|
173
|
+
await solana.revealBid(bid);
|
|
174
|
+
await solana.settleAuction(bid.auctionId); // anyone, after reveal_end_time
|
|
175
|
+
// Winner during inspection: solana.acceptDataset(id, seller) or solana.requestRefund(id, sha256Hex)
|
|
176
|
+
// Anyone after inspection: solana.finalizeInspectionTimeout(id) (pays the seller)
|
|
177
|
+
// Winner, reviewer silent for 7 days: solana.finalizeRefundTimeout(id)
|
|
178
|
+
await solana.claimRefund(bid.auctionId); // losing bidders reclaim deposits
|
|
179
|
+
|
|
180
|
+
// Service escrow (reviewer / feeRecipient default to the platform options above)
|
|
181
|
+
await solana.deposit({
|
|
182
|
+
orderId: 'ord-1739-abc12', // up to 32 bytes, or 32-byte hex
|
|
183
|
+
seller: 'SellerBase58...',
|
|
184
|
+
amountSol: '1.5',
|
|
185
|
+
deadline: Math.floor(Date.now() / 1000) + 3 * 86400,
|
|
186
|
+
});
|
|
187
|
+
await solana.submitDelivery('ord-1739-abc12', 'ipfs://QmProof'); // seller
|
|
188
|
+
await solana.releaseFunds('ord-1739-abc12'); // buyer
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Solana support needs Node.js 18+ (it uses `node:crypto`). Base58 addresses are case-sensitive; never lowercase them.
|
|
192
|
+
|
|
193
|
+
> **Reviewer risk (Solana escrow).** The deployed escrow program stores whatever `reviewer` and
|
|
194
|
+
> `feeRecipient` the buyer passes to `deposit`; there is no on-chain platform config yet. A reviewer
|
|
195
|
+
> controlled by one party can resolve a dispute 100% in its favour. The SDK defaults both to
|
|
196
|
+
> `platformReviewer` / `platformFeeRecipient` and rejects a reviewer equal to the buyer or seller,
|
|
197
|
+
> but a buyer using another client can still pick any wallet. Sellers should check
|
|
198
|
+
> `(await solana.getEscrowOrder(id))?.reviewer` before starting work.
|
|
199
|
+
|
|
200
|
+
| Program (Devnet) | ID |
|
|
201
|
+
|---|---|
|
|
202
|
+
| Auction | `5Tw1iJGN1hhyRzepbD5eLoaRoZTEiKcqrh2HoZYhYEta` |
|
|
203
|
+
| Service escrow | `5Vj4y8BT74PDe5VwLuDp9agTR5ak4vtZdwxnBfRW3R8s` |
|
|
204
|
+
|
|
205
|
+
## Contract addresses
|
|
206
|
+
|
|
207
|
+
Defaults live in `VEILIO_DEPLOYMENTS` (also `getVeilioDeployment(chainId)`) and are picked by `chainId`. Every client takes a `contractAddress` option to point at your own deployment. Both EVM auction addresses are `VeilNFTV4`.
|
|
208
|
+
|
|
209
|
+
| Network | Auction | Service escrow |
|
|
210
|
+
|---|---|---|
|
|
211
|
+
| BNB Testnet (97) | `0xc12EcD53B9dAE1753409B87f10Bf00684BF7d8B1` | `0x794f1610B5588a55B19D8c82e4381448a388C965` |
|
|
212
|
+
| Base Sepolia (84532) | `0xc12EcD53B9dAE1753409B87f10Bf00684BF7d8B1` | `0x794f1610B5588a55B19D8c82e4381448a388C965` |
|
|
213
|
+
|
|
214
|
+
## Errors
|
|
215
|
+
|
|
216
|
+
Failures are thrown as `VeilioSdkError` with a typed `code` (`INVALID_INPUT`, `CHAIN_MISMATCH`, `WALLET_REQUIRED`, `TRANSACTION_REVERTED`, ...) and a `retryable` flag.
|
|
217
|
+
|
|
218
|
+
## Security
|
|
219
|
+
|
|
220
|
+
- Use a dedicated testnet wallet for agents and load its key from the environment. Never commit it.
|
|
221
|
+
- Bid deposits and bidder addresses are public on-chain; only the bid value is sealed until reveal.
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
MIT
|
package/dist/cjs/auth.d.ts
CHANGED
|
@@ -28,4 +28,19 @@ export declare function createServiceAuthMessage(input: {
|
|
|
28
28
|
* (e.g. 'accept-payment-request', 'verify-deposit', 'submit', 'revision', 'approve', 'cancel').
|
|
29
29
|
*/
|
|
30
30
|
export declare function signServiceAuth(signer: MessageSigner, action: string, orderId: string): Promise<ServiceAuthPayload>;
|
|
31
|
+
export declare const SERVICE_SESSION_ACTION = "services-session";
|
|
32
|
+
export declare const SERVICE_SESSION_SCOPE = "session";
|
|
33
|
+
/** The server accepts a session for 30 minutes after its timestamp. */
|
|
34
|
+
export declare const SERVICE_SESSION_MAX_AGE_MS: number;
|
|
35
|
+
/** Header that carries the JSON-encoded session payload on GET requests. */
|
|
36
|
+
export declare const SERVICE_AUTH_HEADER = "x-veilio-auth";
|
|
37
|
+
/**
|
|
38
|
+
* Signs a reusable read/chat session (nonce not consumed by the server). It authorizes reads and
|
|
39
|
+
* chat only, never escrow state changes, which need `signServiceAuth` per request.
|
|
40
|
+
*/
|
|
41
|
+
export declare function signServiceSession(signer: MessageSigner): Promise<ServiceAuthPayload>;
|
|
42
|
+
/** True while a session is at least one minute away from server-side expiry. */
|
|
43
|
+
export declare function isServiceSessionFresh(auth: ServiceAuthPayload | null | undefined, address?: string): boolean;
|
|
44
|
+
/** `{ 'x-veilio-auth': JSON }` header map for a session payload. */
|
|
45
|
+
export declare function encodeServiceAuthHeader(auth: ServiceAuthPayload): Record<string, string>;
|
|
31
46
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/cjs/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAGzC,mEAAmE;AACnE,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,GAAG,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,gGAAgG;AAChG,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CAC1D;AAED,4EAA4E;AAC5E,wBAAgB,iBAAiB,IAAI,MAAM,CAU1C;AAED,kFAAkF;AAClF,wBAAgB,wBAAwB,CAAC,KAAK,EAAE;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM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,4EAA4E;AAC5E,eAAO,MAAM,mBAAmB,kBAAkB,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAErF;AAED,gFAAgF;AAChF,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAI5G;AAED,oEAAoE;AACpE,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAExF"}
|
package/dist/cjs/auth.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SERVICE_AUTH_HEADER = exports.SERVICE_SESSION_MAX_AGE_MS = exports.SERVICE_SESSION_SCOPE = exports.SERVICE_SESSION_ACTION = void 0;
|
|
3
4
|
exports.generateAuthNonce = generateAuthNonce;
|
|
4
5
|
exports.createServiceAuthMessage = createServiceAuthMessage;
|
|
5
6
|
exports.signServiceAuth = signServiceAuth;
|
|
7
|
+
exports.signServiceSession = signServiceSession;
|
|
8
|
+
exports.isServiceSessionFresh = isServiceSessionFresh;
|
|
9
|
+
exports.encodeServiceAuthHeader = encodeServiceAuthHeader;
|
|
6
10
|
const errors_js_1 = require("./errors.js");
|
|
7
11
|
/** Random 16-hex-character nonce from a cryptographically secure source. */
|
|
8
12
|
function generateAuthNonce() {
|
|
@@ -39,4 +43,32 @@ async function signServiceAuth(signer, action, orderId) {
|
|
|
39
43
|
const signature = await signer.signMessage({ message });
|
|
40
44
|
return { address: signer.address, signature, timestamp, nonce };
|
|
41
45
|
}
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
// Read / chat session (matches the VEILIO server's lib/serviceAuth.ts scheme)
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
exports.SERVICE_SESSION_ACTION = 'services-session';
|
|
50
|
+
exports.SERVICE_SESSION_SCOPE = 'session';
|
|
51
|
+
/** The server accepts a session for 30 minutes after its timestamp. */
|
|
52
|
+
exports.SERVICE_SESSION_MAX_AGE_MS = 30 * 60 * 1000;
|
|
53
|
+
/** Header that carries the JSON-encoded session payload on GET requests. */
|
|
54
|
+
exports.SERVICE_AUTH_HEADER = 'x-veilio-auth';
|
|
55
|
+
/**
|
|
56
|
+
* Signs a reusable read/chat session (nonce not consumed by the server). It authorizes reads and
|
|
57
|
+
* chat only, never escrow state changes, which need `signServiceAuth` per request.
|
|
58
|
+
*/
|
|
59
|
+
function signServiceSession(signer) {
|
|
60
|
+
return signServiceAuth(signer, exports.SERVICE_SESSION_ACTION, exports.SERVICE_SESSION_SCOPE);
|
|
61
|
+
}
|
|
62
|
+
/** True while a session is at least one minute away from server-side expiry. */
|
|
63
|
+
function isServiceSessionFresh(auth, address) {
|
|
64
|
+
if (!auth?.signature)
|
|
65
|
+
return false;
|
|
66
|
+
if (address && auth.address.toLowerCase() !== address.toLowerCase())
|
|
67
|
+
return false;
|
|
68
|
+
return Date.now() - auth.timestamp < exports.SERVICE_SESSION_MAX_AGE_MS - 60 * 1000;
|
|
69
|
+
}
|
|
70
|
+
/** `{ 'x-veilio-auth': JSON }` header map for a session payload. */
|
|
71
|
+
function encodeServiceAuthHeader(auth) {
|
|
72
|
+
return { [exports.SERVICE_AUTH_HEADER]: JSON.stringify(auth) };
|
|
73
|
+
}
|
|
42
74
|
//# sourceMappingURL=auth.js.map
|
package/dist/cjs/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":";;;AAkBA,8CAUC;AAGD,4DAgBC;AAMD,0CAUC;AAiBD,gDAEC;AAG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17
|
chainId: 84532,
|
|
18
|
-
auction: '
|
|
19
|
-
serviceEscrow: '
|
|
18
|
+
auction: '0xc12EcD53B9dAE1753409B87f10Bf00684BF7d8B1',
|
|
19
|
+
serviceEscrow: '0x794f1610B5588a55B19D8c82e4381448a388C965',
|
|
20
20
|
serviceRegistry: '0x74a6Bf3ed462898F7b3E13e7F4d1c444570bCb88',
|
|
21
21
|
},
|
|
22
22
|
};
|