@obscura-fhe/sdk 1.0.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 +19 -0
- package/LICENSE +21 -0
- package/README.md +124 -0
- package/dist/index.cjs +670 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +488 -0
- package/dist/index.d.ts +488 -0
- package/dist/index.js +647 -0
- package/dist/index.js.map +1 -0
- package/package.json +70 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@obscura-fhe/sdk` are documented in this file.
|
|
4
|
+
|
|
5
|
+
## [1.0.0] - 2026-05-29
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Initial public release of the official Obscura TypeScript SDK
|
|
10
|
+
- **Pay module** — shielded balance reads, shield/unshield/transfer transaction builders
|
|
11
|
+
- **Credit module** — canonical market address, supply/borrow/repay transaction builders
|
|
12
|
+
- **Vote module** — proposal reads, cast vote and delegate transaction builders
|
|
13
|
+
- **Reputation module** — off-chain reputation summary via obscura-api
|
|
14
|
+
- **Activity module** — Supabase activity feed with pay/credit/vote event filters
|
|
15
|
+
- **Notifications module** — VAPID key, push prefs, subscribe/unsubscribe
|
|
16
|
+
- Injectable `FheProvider` interface for CoFHE encrypt/decrypt (host-supplied)
|
|
17
|
+
- Arbitrum Sepolia defaults (chain, RPC, API, contract addresses)
|
|
18
|
+
- ESM + CJS dual build with TypeScript declarations
|
|
19
|
+
- Framework-agnostic design (viem peer dependency, no React/wagmi)
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Obscura Protocol
|
|
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
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# @obscura-fhe/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK for **Obscura Pay**, **Credit**, and Vote on Arbitrum Sepolia.
|
|
4
|
+
|
|
5
|
+
Privacy-first DeFi with FHE (Fully Homomorphic Encryption). Framework-agnostic — works in Node.js, browsers, and automation scripts.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @obscura-fhe/sdk viem
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`viem` is a peer dependency (v2+).
|
|
14
|
+
|
|
15
|
+
## Quick start
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { ObscuraSDK } from "@obscura-fhe/sdk";
|
|
19
|
+
|
|
20
|
+
const sdk = ObscuraSDK.create({
|
|
21
|
+
supabaseAnonKey: process.env.OBSCURA_SUPABASE_ANON_KEY, // required for activity feed
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Reputation (off-chain, obscura-api)
|
|
25
|
+
const summary = await sdk.reputation.getSummary("0xYourWallet...");
|
|
26
|
+
console.log(summary.tier, summary.totalCappedWeight);
|
|
27
|
+
|
|
28
|
+
// Activity feed (Supabase)
|
|
29
|
+
const { items, hasMore } = await sdk.activity.listForWallet("0xYourWallet...", {
|
|
30
|
+
filter: "credit",
|
|
31
|
+
page: 0,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Notifications
|
|
35
|
+
const vapidKey = await sdk.notifications.getVapidPublicKey();
|
|
36
|
+
const prefs = await sdk.notifications.getPrefs("0xYourWallet...");
|
|
37
|
+
|
|
38
|
+
// On-chain reads
|
|
39
|
+
const balanceCtHash = await sdk.pay.getShieldedBalance("0xYourWallet...");
|
|
40
|
+
const proposalCount = await sdk.vote.getProposalCount();
|
|
41
|
+
|
|
42
|
+
// Transaction builders (return ContractCall — sign with your wallet)
|
|
43
|
+
const call = await sdk.pay.buildTransfer(to, amount, encryptedAmount);
|
|
44
|
+
const calldata = sdk.encodeCall(call);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Modules
|
|
48
|
+
|
|
49
|
+
| Module | Methods | Backend |
|
|
50
|
+
|--------|---------|---------|
|
|
51
|
+
| `pay` | `getShieldedBalance`, `buildShield`, `buildUnshield`, `buildTransfer` | On-chain (ocUSDC_Pay) |
|
|
52
|
+
| `credit` | `getMarketAddress`, `buildSupplyCollateral`, `buildBorrow`, `buildRepay` | On-chain (credit market) |
|
|
53
|
+
| `vote` | `getProposalCount`, `getProposal`, `buildCastVote`, `buildDelegate` | On-chain (ObscuraVote) |
|
|
54
|
+
| `reputation` | `getSummary` | obscura-api REST |
|
|
55
|
+
| `activity` | `listForWallet`, `getEventFilters` | Supabase |
|
|
56
|
+
| `notifications` | `getVapidPublicKey`, `getPrefs`, `savePrefs`, `subscribe`, `unsubscribe` | obscura-api REST |
|
|
57
|
+
|
|
58
|
+
## Configuration
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
ObscuraSDK.create({
|
|
62
|
+
chainId: 421614, // default: Arbitrum Sepolia
|
|
63
|
+
rpcUrl: "https://...", // default: Arbitrum Sepolia RPC
|
|
64
|
+
apiUrl: "https://...", // default: obscura-api production
|
|
65
|
+
supabaseUrl: "https://...", // default: Obscura Supabase project
|
|
66
|
+
supabaseAnonKey: "...", // required for activity module
|
|
67
|
+
addresses: { ocUSDC_Pay: "0x..." }, // override deployment registry
|
|
68
|
+
publicClient, // inject viem PublicClient
|
|
69
|
+
walletClient, // optional — for sdk.sendCall()
|
|
70
|
+
fhe: myFheAdapter, // optional — for encrypted writes
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## FHE (encrypted writes)
|
|
75
|
+
|
|
76
|
+
Encrypted contract inputs require a host-supplied `FheProvider` (typically wrapping `@cofhe/sdk`):
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import type { FheProvider } from "@obscura-fhe/sdk";
|
|
80
|
+
|
|
81
|
+
const fhe: FheProvider = {
|
|
82
|
+
async encryptUint64(value, { contractAddress }) {
|
|
83
|
+
// wrap @cofhe/sdk encrypt here
|
|
84
|
+
return { ctHash, securityZone, utype, signature };
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const sdk = ObscuraSDK.create({ fhe });
|
|
89
|
+
await sdk.pay.buildShield(1000n); // encrypts via adapter
|
|
90
|
+
|
|
91
|
+
// Or pass pre-encrypted input directly:
|
|
92
|
+
await sdk.pay.buildShield(1000n, preEncryptedInEuint64);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Sending transactions
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
const call = sdk.vote.buildDelegate("0xDelegatee...");
|
|
99
|
+
const hash = await sdk.sendCall(call, account); // requires walletClient
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Defaults (Arbitrum Sepolia)
|
|
103
|
+
|
|
104
|
+
| Setting | Value |
|
|
105
|
+
|---------|-------|
|
|
106
|
+
| Chain ID | `421614` |
|
|
107
|
+
| ocUSDC_Pay | `0xEd46020Df8abe7BB1E096f27d089F4326D223a53` |
|
|
108
|
+
| Vote | `0xe358776AfdbA95d7c9F040e6ef1f5A021aF91730` |
|
|
109
|
+
| Credit market | `0x1Ec113297c7F9516A6604aa3b18C180559a6f551` |
|
|
110
|
+
| API | `https://obscura-api-n62v.onrender.com` |
|
|
111
|
+
|
|
112
|
+
## Exports
|
|
113
|
+
|
|
114
|
+
Core: `ObscuraSDK`, `ObscuraSDKConfig`, `ContractCall`, `InEuint64`, `FheProvider`, `FheRequiredError`
|
|
115
|
+
|
|
116
|
+
Types: `ReputationSummary`, `ActivityItem`, `NotificationPrefs`, `ProposalState`, …
|
|
117
|
+
|
|
118
|
+
Constants: `DEFAULT_ADDRESSES`, `ARBITRUM_SEPOLIA_CHAIN_ID`, `ACTIVITY_EVENT_FILTERS`
|
|
119
|
+
|
|
120
|
+
Utilities: `encodeCall`, `normalizeWallet`, `toContractInEuint64`, `HttpError`
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT — see [LICENSE](./LICENSE).
|