@warganetwork/sdk 0.0.0-stage → 1.4.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 ADDED
@@ -0,0 +1,43 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@warganetwork/sdk` are documented in this file.
4
+
5
+ ## [1.4.0] - 2026-12-03
6
+
7
+ ### Added
8
+ - **Multi-RPC Automatic Failover (`fallbackRpcUrls`):** `WargaClient` automatically fails over to backup RPC endpoints on transient network/5xx errors without losing deterministic JSON-RPC error semantics.
9
+ - **Offline Zero-Trust Transaction Scanner (`scanTransactionLocal`):** Strictly validates transaction schemas and detects `approve(max_uint256)`, `setApprovalForAll(true)`, `permit`, and phishing origins 100% locally in the browser with zero dependency on external servers.
10
+ - **Full Transaction & Event Helpers:** Added `estimateGas()`, `getTransactionCount()`, `sendRawTransaction()`, `getTransactionReceipt()`, `waitForTransaction()`, `getLogs()`, and browser-native `pollLogs()`.
11
+ - **Standard ERC-20 LP Token ABI (`WRG-LP`):** Synced updated `WargaSwapV3Pool.vy` (`implements: IERC20` LP token) and `MerchantEscrow.vy` (`resolve_dispute` + 24h timelock) into `src/abis/index.js` & `dist/index.cjs` (`16/16` live CI tests PASS).
12
+
13
+ ## [1.3.0] - 2026-12-03
14
+
15
+ ### Added
16
+ - **High-Level Zero-Dependency Contract Helpers (`src/helpers.js`):** Added `WargaEscrow`, `WargaPool` (with `quoteSwap` & `computeMinOut`), and `WargaKycBadge` (`verifyBadge`, `mintBadge`, `revokeBadge`) working with optional `ethers` v6 / `viem` peer dependencies.
17
+ - **Resilient Networking:** Added automatic exponential-backoff retry (`retries`, `retryDelayMs`) on transient `429`/`5xx`/network failures and `batchRpc([...])` on `WargaClient`.
18
+ - **Hardened v2 Contract ABIs Synced:** Updated all 10 inlined Vyper `0.4.3` ABIs (`claim_expired_order`, `open_dispute`, `set_daily_mint_limit`, `propose_owner`/`accept_owner`, AMM `toggle_pause`, ERC-5192 `Unlocked`) across ESM (`src/abis/index.js`) and CJS (`dist/index.cjs`).
19
+ - **Expanded CI Test Suite (`13/13 PASS`):** Verified retry/backoff, `batchRpc`, high-level wrappers, browser purity across `src/index.js` + `src/abis/index.js` + `src/helpers.js`, dual ESM+CJS parity, and live RPC + NIST FIPS 204 `ML-DSA-65` verification.
20
+
21
+ ## [1.2.0] - 2026-12-03
22
+
23
+ ### Added
24
+ - **Real NIST FIPS 204 (`ML-DSA-65` / Dilithium3) Client Methods:** Added `getPqcPubKey()`, `getPqcAttestation()`, and `verifyMLDSA65()` on `WargaClient`, plus standalone browser/Node `@noble/post-quantum` example in `examples/quantum/mldsa65-sign-and-verify.js`.
25
+ - **On-Chain Shor-Resistant Vault Support:** Embedded `QuantumGuardVaultAbi` (10th Vyper `0.4.3` ABI) in `src/abis/index.js` & `dist/index.cjs` + pure WebCrypto browser-native `computeQuantumAnchor()` helper (zero `node:*` imports).
26
+ - **Expanded OpenAPI & Live CI Tests (`11/11 PASS`):** Documented `/api/pqc/pubkey`, `/api/pqc/attestation`, and `/api/pqc/verify` in `openapi/warga-public-api.yaml` and verified live NIST FIPS 204 `ML-DSA-65` signatures in `npm run test:live`.
27
+
28
+ ## [1.1.0] - 2026-12-03
29
+
30
+ ### Fixed
31
+ - **Full Browser & Edge Runtime Compatibility:** Removed all `node:fs` and `node:path` imports from `src/index.js`. All 9 compiled Vyper `0.4.3` contract ABIs are now embedded as pure tree-shakeable JS exports in `src/abis/index.js`, working natively in browsers, Cloudflare Workers, Deno, Bun, and Node.js `>= 18`.
32
+
33
+ ### Added
34
+ - **Dual ESM + CommonJS Package Exports:** Added `dist/index.cjs` and `scripts/build-cjs.mjs` (`npm run build`) with `"sideEffects": false` for tree-shaking and full `import` + `require()` compatibility.
35
+ - **Structured Error Handling:** Exported `WargaRpcError` (with `.code`, `.method`, `.status`) and timeout abort handling on `WargaClient`.
36
+ - **Real-World Integration Examples:** Added `examples/escrow/lock-and-release.js`, `examples/swap/quote-and-swap.js`, `examples/kyc-badge/check-and-mint-badge.js`, `examples/hardhat/hardhat.config.js`, `examples/foundry/foundry.toml`, and `examples/merchant-webhook/verify-webhook.js`.
37
+ - **Ecosystem Standards:** Added verified Uniswap-standard `tokenlist/warga.tokenlist.json` (18 decimals matched to `.vy` sources) and `openapi/warga-public-api.yaml` (OpenAPI `3.0.3`, 5 live-verified public routes).
38
+ - **Expanded CI Verification (`10` Tests):** Added browser-purity guard (zero `node:*` imports in `src/`), ESM/CJS parity test, TokenList/OpenAPI/Webhook tests, and opt-in live RPC integration check (`npm run test:live`).
39
+
40
+ ## [1.0.0] - 2026-12-03
41
+
42
+ ### Added
43
+ - Initial release of `@warganetwork/sdk` with `WARGA_MAINNET` (`882026`), `WARGA_TESTNET` (`2027`), 9 verified Vyper `0.4.3` contract addresses & ABIs, `WargaClient`, `formatWrg`, `parseWrg`, TypeScript definitions, and GitHub Actions CI.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 PT UMKM RUMAHAN DIGITAL
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,3 +1,190 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <img src="./assets/logo-transparent.png" alt="Warga Network & UMKM Rumahan Digital Logo" width="140" />
3
+ </p>
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
5
+ # `@warganetwork/sdk` — Official Warga Network Layer-1 & WargaPay Web3 SDK
6
+
7
+ [![Warga SDK CI](https://github.com/Faang21/warga-sdk/actions/workflows/sdk-ci.yml/badge.svg)](https://github.com/Faang21/warga-sdk/actions/workflows/sdk-ci.yml)
8
+
9
+ **Browser-native**, zero-dependency JavaScript / TypeScript client SDK (**dual ESM + CommonJS**, tree-shakeable inlined ABIs — **zero `node:fs` / `node:path` imports**) and verified **Vyper `0.4.3`** contract ABIs for **Warga Network Layer-1** (`Chain ID: 882026`, RPC: `https://warganetwork.org/rpc`) and **UMKM Rumahan Digital**.
10
+
11
+ Works natively in **modern browsers**, **Cloudflare Workers / Edge runtimes**, **Deno**, **Bun**, **Node.js `>= 18`**, **`ethers` v6**, and **`viem`**.
12
+
13
+ ## Installation
14
+
15
+ Install directly from GitHub:
16
+
17
+ ```bash
18
+ npm install github:Faang21/warga-sdk
19
+ ```
20
+
21
+ Both ESM (`import`) and CommonJS (`require`) work out of the box:
22
+
23
+ ```js
24
+ // ESM / Modern Browser / TypeScript
25
+ import {
26
+ WargaClient,
27
+ WargaEscrow,
28
+ WargaPool,
29
+ WargaKycBadge,
30
+ CONTRACTS,
31
+ ABIS,
32
+ WargaRpcError,
33
+ } from "@warganetwork/sdk";
34
+
35
+ // CommonJS (Node.js)
36
+ const { WargaClient, WargaEscrow, WargaPool, CONTRACTS, ABIS } = require("@warganetwork/sdk");
37
+ ```
38
+
39
+ ### High-Level Contract Helpers (`WargaEscrow`, `WargaPool`, `WargaKycBadge`)
40
+
41
+ ```js
42
+ import { ethers } from "ethers";
43
+ import { WargaEscrow, WargaPool, WargaKycBadge, parseWrg } from "@warganetwork/sdk";
44
+
45
+ const escrow = WargaEscrow.create(ethers.Contract, signer);
46
+ await escrow.lockOrder(ethers.id("ORD-001"), merchantAddr, parseWrg("50000"));
47
+ // If undisputed & past expiry, buyer reclaims funds directly:
48
+ // await escrow.claimExpiredOrder(ethers.id("ORD-001"));
49
+
50
+ const pool = WargaPool.create(ethers.Contract, provider);
51
+ const { amountOut, minAmountOut } = await pool.quoteSwap(CONTRACTS.WargaCoin, parseWrg("100"), 50);
52
+
53
+ const badge = WargaKycBadge.create(ethers.Contract, provider);
54
+ const { isErc5192, isLocked, owner } = await badge.verifyBadge(1);
55
+ ```
56
+
57
+ ## Quick Start & Structured Error Handling
58
+
59
+ ```js
60
+ import { WargaClient, CONTRACTS, WargaRpcError } from "@warganetwork/sdk";
61
+
62
+ const client = new WargaClient({ timeoutMs: 8000 });
63
+
64
+ try {
65
+ console.log("Chain ID:", await client.getChainId()); // 882026
66
+ console.log("Latest Block:", await client.getBlockNumber());
67
+
68
+ const balance = await client.getBalance("0x2cba461c86d314195b5d8e99c93d551fd4f74435");
69
+ console.log("WRG Balance:", balance.wrg);
70
+
71
+ // Anti-drainer heuristic scan before signing
72
+ const scan = await client.scanTransaction({
73
+ to: CONTRACTS.WargaCoin,
74
+ data: "0x095ea7b3...",
75
+ });
76
+ console.log("Tx Risk Analysis:", scan.analysis);
77
+ } catch (err) {
78
+ if (err instanceof WargaRpcError) {
79
+ console.error(`RPC Error [${err.code ?? err.status}] on ${err.method}:`, err.message);
80
+ } else {
81
+ throw err;
82
+ }
83
+ }
84
+ ```
85
+
86
+ ## Real-World Integration Examples
87
+
88
+ ### 1. Lock & Release `MerchantEscrow.vy` (`ethers` v6)
89
+
90
+ ```js
91
+ import { ethers } from "ethers";
92
+ import { WARGA_MAINNET, CONTRACTS, ABIS, parseWrg } from "@warganetwork/sdk";
93
+
94
+ const provider = new ethers.JsonRpcProvider(WARGA_MAINNET.rpcUrls.default.http[0], WARGA_MAINNET.id);
95
+ const buyer = new ethers.Wallet(process.env.BUYER_PRIVATE_KEY, provider);
96
+ const idr = new ethers.Contract(CONTRACTS.IDRToken, ABIS.IDRToken, buyer);
97
+ const escrow = new ethers.Contract(CONTRACTS.MerchantEscrow, ABIS.MerchantEscrow, buyer);
98
+
99
+ const orderId = ethers.id("ORD-UMKM-2026-001");
100
+ const amount = parseWrg("50000"); // 50,000 IDR (18 decimals)
101
+
102
+ await (await idr.approve(CONTRACTS.MerchantEscrow, amount)).wait(1);
103
+ await (await escrow.lock_order(orderId, merchantAddress, amount)).wait(1);
104
+ // Full end-to-end lock & operator release script: examples/escrow/lock-and-release.js
105
+ ```
106
+
107
+ ### 2. Quote & Swap on `WargaSwapV3Pool.vy` (Constant Product $x \cdot y = k$ + Slippage Guard)
108
+
109
+ ```js
110
+ import { ethers } from "ethers";
111
+ import { WARGA_MAINNET, CONTRACTS, ABIS, parseWrg } from "@warganetwork/sdk";
112
+
113
+ const pool = new ethers.Contract(CONTRACTS.WargaSwapV3Pool, ABIS.WargaSwapV3Pool, signer);
114
+ const amountIn = parseWrg("100");
115
+ const quotedOut = await pool.get_amount_out(CONTRACTS.WargaCoin, amountIn);
116
+ const minOut = (quotedOut * 9950n) / 10000n; // 0.50% slippage guard
117
+
118
+ await (await pool.swap(CONTRACTS.WargaCoin, amountIn, minOut, signer.address)).wait(1);
119
+ // Full swap script: examples/swap/quote-and-swap.js
120
+ ```
121
+
122
+ ### 3. Verify ERC-5192 Soulbound `MerchantKYCBadgeNFT.vy` (`viem`)
123
+
124
+ ```js
125
+ import { createPublicClient, http } from "viem";
126
+ import { WARGA_MAINNET, CONTRACTS, MerchantKYCBadgeNFTAbi } from "@warganetwork/sdk";
127
+
128
+ const publicClient = createPublicClient({ chain: WARGA_MAINNET, transport: http() });
129
+
130
+ const [isErc5192, isLocked] = await Promise.all([
131
+ publicClient.readContract({
132
+ address: CONTRACTS.MerchantKYCBadgeNFT,
133
+ abi: MerchantKYCBadgeNFTAbi,
134
+ functionName: "supportsInterface",
135
+ args: ["0xb45a3c0e"],
136
+ }),
137
+ publicClient.readContract({
138
+ address: CONTRACTS.MerchantKYCBadgeNFT,
139
+ abi: MerchantKYCBadgeNFTAbi,
140
+ functionName: "locked",
141
+ args: [1n],
142
+ }),
143
+ ]);
144
+ // Full verify & minter script: examples/kyc-badge/check-and-mint-badge.js
145
+ ```
146
+
147
+ ## Verified Contract Addresses (`Chain ID 882026`)
148
+
149
+ | Contract | Address | Source Code |
150
+ | :--- | :--- | :--- |
151
+ | `WargaCoin` (`WRG`) | `0x71c7656ec7ab88b098defb751b7401b5f6d8976f` | [WargaCoin.vy](https://github.com/Faang21/warga-contracts/blob/main/WargaCoin.vy) |
152
+ | `WrgVault` | `0xb59057f75ab910c587993d84a56da7c5b8442fdc` | [WrgVault.vy](https://github.com/Faang21/warga-contracts/blob/main/WrgVault.vy) |
153
+ | `MerchantEscrow` | `0x8fab0a68e8f0722c20f1285c30fb97d735e575fe` | [MerchantEscrow.vy](https://github.com/Faang21/warga-contracts/blob/main/MerchantEscrow.vy) |
154
+ | `MerchantKYCBadgeNFT` | `0x05c622c9664b2876e0dd69fcbb20f0aaef3becc1` | [MerchantKYCBadgeNFT.vy](https://github.com/Faang21/warga-contracts/blob/main/MerchantKYCBadgeNFT.vy) |
155
+ | `WargaSwapV3Pool` | `0xc6e96ec9b017e3c924e6a0332a89e839dffcbbe7` | [WargaSwapV3Pool.vy](https://github.com/Faang21/warga-contracts/blob/main/WargaSwapV3Pool.vy) |
156
+ | `ValidatorRegistry` | `0x069ccee0cb1fc3ee67eb0772188b1fdd1103df9e` | [ValidatorRegistry.vy](https://github.com/Faang21/warga-contracts/blob/main/ValidatorRegistry.vy) |
157
+ | `IDRToken` | `0x4044b274536c7e4d371cfe47f9c3dd4d7811b26c` | [IDRToken.vy](https://github.com/Faang21/warga-contracts/blob/main/IDRToken.vy) |
158
+ | `USDTToken` | `0x99ed79a6435be307d025d61831c8688b2a7ff7cb` | [USDTToken.vy](https://github.com/Faang21/warga-contracts/blob/main/USDTToken.vy) |
159
+ | `JPYToken` | `0xbae92c718537c5e4eb8b230bc060af4a43450536` | [JPYToken.vy](https://github.com/Faang21/warga-contracts/blob/main/JPYToken.vy) |
160
+
161
+ ## Developer Resources Included
162
+
163
+ - **Uniswap-Standard TokenList:** [`tokenlist/warga.tokenlist.json`](tokenlist/warga.tokenlist.json) (`WRG`, `IDR`, `USDT`, `JPY` — `Chain ID 882026`, `18` decimals)
164
+ - **OpenAPI 3.0.3 Public API Spec (Postman / Swagger ready, 8 live endpoints incl. NIST FIPS 204 ML-DSA-65):** [`openapi/warga-public-api.yaml`](openapi/warga-public-api.yaml)
165
+ - **Post-Quantum NIST FIPS 204 (`ML-DSA-65`) + `QuantumGuardVault` Example:** [`examples/quantum/mldsa65-sign-and-verify.js`](examples/quantum/mldsa65-sign-and-verify.js)
166
+ - **Examples:** [`examples/escrow/`](examples/escrow/lock-and-release.js), [`examples/swap/`](examples/swap/quote-and-swap.js), [`examples/kyc-badge/`](examples/kyc-badge/check-and-mint-badge.js), [`examples/hardhat/`](examples/hardhat/hardhat.config.js), [`examples/foundry/`](examples/foundry/foundry.toml), [`examples/merchant-webhook/`](examples/merchant-webhook/verify-webhook.js)
167
+ - **Version History:** [`CHANGELOG.md`](CHANGELOG.md)
168
+
169
+ ## Build & Run Tests
170
+
171
+ ```bash
172
+ # Rebuild CommonJS bundle (dist/index.cjs)
173
+ npm run build
174
+
175
+ # Run offline unit, browser-purity, ESM/CJS parity, TokenList & OpenAPI tests
176
+ npm test
177
+
178
+ # Run full suite INCLUDING live RPC integration test against https://warganetwork.org/rpc
179
+ npm run test:live
180
+ ```
181
+
182
+ ## Security & Audit
183
+
184
+ - Smart Contract Suite & Titanoboa 10k Invariant CI: https://github.com/Faang21/warga-contracts
185
+ - Sanitized Security Audit Report: https://github.com/Faang21/warga-contracts/blob/main/SECURITY_AUDIT.md
186
+ - Developer Portal: https://warganetwork.org/developer
187
+
188
+ ## License
189
+
190
+ MIT License — PT UMKM RUMAHAN DIGITAL
Binary file
Binary file
Binary file