Merge commit 'd803bfe2b1fe7f5e219e50ac20d6801a0a58ac75' as 'vendor/ruvector'

This commit is contained in:
ruv
2026-02-28 14:39:40 -05:00
7854 changed files with 3522914 additions and 0 deletions

View File

@@ -0,0 +1,303 @@
# @ruvector/economy-wasm - CRDT Credit Economy for Distributed Compute
[![npm version](https://img.shields.io/npm/v/ruvector-economy-wasm.svg)](https://www.npmjs.com/package/ruvector-economy-wasm)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ruvnet/ruvector)
[![Bundle Size](https://img.shields.io/badge/bundle%20size-177KB%20gzip-green.svg)](https://www.npmjs.com/package/ruvector-economy-wasm)
[![WebAssembly](https://img.shields.io/badge/WebAssembly-654FF0?logo=webassembly&logoColor=white)](https://webassembly.org/)
A **CRDT-based autonomous credit economy** for distributed compute networks. Provides conflict-free P2P credit tracking, stake/slash mechanics, and reputation scoring - a blockchain alternative for edge computing and AI agent coordination.
## Key Features
- **CRDT Ledger**: G-Counter and PN-Counter for P2P-safe credit tracking with guaranteed eventual consistency
- **10x Early Adopter Curve**: Contribution multiplier decaying from 10x to 1x baseline as network grows
- **Stake/Slash Mechanics**: Participation requirements with slashing for sybil attacks, double-spending, and bad behavior
- **Reputation Scoring**: Multi-factor composite score based on accuracy, uptime, and stake weight
- **Merkle State Root**: Fast ledger verification with cryptographic proofs
- **WASM-Optimized**: Runs in browsers, Node.js, and edge runtimes
## Installation
```bash
npm install ruvector-economy-wasm
# or
yarn add ruvector-economy-wasm
# or
pnpm add ruvector-economy-wasm
```
## Quick Start
### TypeScript/JavaScript
```typescript
import init, {
CreditLedger,
ReputationScore,
StakeManager,
contribution_multiplier,
SlashReason
} from 'ruvector-economy-wasm';
// Initialize WASM module
await init();
// Create a credit ledger for a node
const ledger = new CreditLedger("node-123");
// Earn credits for completed tasks
ledger.credit(100n, "task:compute-job-456");
console.log(`Balance: ${ledger.balance()}`);
// Check early adopter multiplier
const mult = contribution_multiplier(50000.0); // 50K network compute hours
console.log(`Multiplier: ${mult.toFixed(2)}x`); // ~8.5x for early adopters
// Credit with multiplier applied
ledger.creditWithMultiplier(50n, "task:bonus-789");
// Track reputation
const rep = new ReputationScore(0.95, 0.98, 1000n);
console.log(`Composite score: ${rep.compositeScore()}`);
console.log(`Tier: ${rep.tierName()}`);
```
## Understanding CRDTs
**Conflict-free Replicated Data Types (CRDTs)** enable distributed systems to:
- Merge updates in any order with identical results
- Operate offline and sync later without conflicts
- Scale horizontally without coordination bottlenecks
This package uses:
- **G-Counter**: Grow-only counter for earned credits (monotonically increasing)
- **PN-Counter**: Positive-negative counter for spending (allows refunds/disputes)
```typescript
// P2P merge example - works regardless of message order
const nodeA = new CreditLedger("node-A");
const nodeB = new CreditLedger("node-B");
// Both nodes earn credits independently
nodeA.credit(100n, "job-1");
nodeB.credit(50n, "job-2");
// Export for P2P sync
const earnedA = nodeA.exportEarned();
const spentA = nodeA.exportSpent();
// Merge on node B - associative, commutative, idempotent
const merged = nodeB.merge(earnedA, spentA);
console.log(`Merged ${merged} updates`);
```
## Contribution Curve
Early network contributors receive higher rewards that decay as the network matures:
```
Multiplier = 1 + 9 * exp(-compute_hours / 100,000)
Network Hours | Multiplier
---------------|------------
0 | 10.0x (Genesis)
10,000 | ~9.0x
50,000 | ~6.0x
100,000 | ~4.3x
200,000 | ~2.2x
500,000 | ~1.0x (Baseline)
```
```typescript
import { contribution_multiplier, get_tier_name, get_tiers_json } from 'ruvector-economy-wasm';
// Check current multiplier
const hours = 25000;
const mult = contribution_multiplier(hours);
console.log(`At ${hours} hours: ${mult.toFixed(2)}x multiplier`);
// Get tier name
const tier = get_tier_name(hours); // "Pioneer"
// Get all tier definitions
const tiers = JSON.parse(get_tiers_json());
```
## Stake/Slash Mechanics
```typescript
import { StakeManager, SlashReason } from 'ruvector-economy-wasm';
const stakeManager = new StakeManager();
// Stake credits for network participation
stakeManager.stake("node-123", 1000n);
console.log(`Staked: ${stakeManager.getStake("node-123")}`);
// Check if node meets minimum stake
if (stakeManager.meetsMinimum("node-123")) {
console.log("Node can participate");
}
// Delegate stake to another node
stakeManager.delegate("node-123", "validator-1", 500n);
console.log(`Effective stake: ${stakeManager.getEffectiveStake("validator-1")}`);
// Slash for bad behavior
const slashedAmount = stakeManager.slash(
"bad-actor",
SlashReason.DoubleSpend,
"Evidence: duplicate transaction IDs"
);
console.log(`Slashed ${slashedAmount} credits`);
```
### Slash Reasons
| Reason | Severity | Description |
|--------|----------|-------------|
| `InvalidResult` | Medium | Submitted incorrect computation results |
| `DoubleSpend` | High | Attempted to spend same credits twice |
| `SybilAttack` | Critical | Multiple fake identities detected |
| `Downtime` | Low | Excessive offline periods |
| `Spam` | Medium | Flooding the network |
| `Malicious` | Critical | Intentional harmful behavior |
## Reputation System
```typescript
import { ReputationScore, composite_reputation } from 'ruvector-economy-wasm';
// Create reputation with tracking
const rep = ReputationScore.newWithTracking(
950n, // tasks completed
50n, // tasks failed
BigInt(30 * 24 * 3600), // uptime seconds
BigInt(31 * 24 * 3600), // total seconds
5000n // stake amount
);
// Record task outcomes
rep.recordSuccess();
rep.recordFailure();
// Calculate composite score
// Formula: accuracy^2 * uptime * stake_weight
const score = rep.compositeScore();
console.log(`Composite: ${(score * 100).toFixed(1)}%`);
// Get tier
console.log(`Tier: ${rep.tierName()}`); // "Elite", "Trusted", "Standard", etc.
// Check participation eligibility
if (rep.meetsMinimum(0.9, 0.95, 100n)) {
console.log("Eligible for premium tasks");
}
// Compare reputations
const rep2 = new ReputationScore(0.92, 0.96, 3000n);
console.log(`Better reputation: ${rep.isBetterThan(rep2) ? 'rep1' : 'rep2'}`);
```
### Reputation Tiers
| Tier | Score Range | Benefits |
|------|-------------|----------|
| Elite | >= 0.95 | Priority task assignment, lowest fees |
| Trusted | >= 0.85 | High-value tasks, reduced collateral |
| Standard | >= 0.70 | Normal participation |
| Probation | >= 0.50 | Limited task types |
| Restricted | < 0.50 | Basic tasks only, increased monitoring |
## Merkle State Verification
```typescript
const ledger = new CreditLedger("node-123");
ledger.credit(100n, "job-1");
ledger.credit(200n, "job-2");
// Get state root for verification
const stateRoot = ledger.stateRoot();
const stateRootHex = ledger.stateRootHex();
console.log(`State root: ${stateRootHex}`);
// Verify state integrity
const isValid = ledger.verifyStateRoot(expectedRoot);
```
## API Reference
### CreditLedger
| Method | Description |
|--------|-------------|
| `new(node_id)` | Create ledger for node |
| `credit(amount, reason)` | Earn credits |
| `creditWithMultiplier(base_amount, reason)` | Earn with network multiplier |
| `deduct(amount)` | Spend credits |
| `refund(event_id, amount)` | Refund a deduction |
| `balance()` | Get available balance |
| `stake(amount)` | Lock credits for participation |
| `slash(amount)` | Penalty for bad behavior |
| `merge(other_earned, other_spent)` | CRDT merge operation |
| `exportEarned()` / `exportSpent()` | Export for P2P sync |
| `stateRoot()` / `stateRootHex()` | Merkle verification |
### ReputationScore
| Method | Description |
|--------|-------------|
| `new(accuracy, uptime, stake)` | Create with scores |
| `newWithTracking(...)` | Create with detailed tracking |
| `compositeScore()` | Calculate composite (0.0-1.0) |
| `tierName()` | Get reputation tier |
| `recordSuccess()` / `recordFailure()` | Track task outcomes |
| `stakeWeight()` | Logarithmic stake weight |
| `meetsMinimum(accuracy, uptime, stake)` | Check eligibility |
### StakeManager
| Method | Description |
|--------|-------------|
| `new()` | Create manager |
| `stake(node_id, amount)` | Stake credits |
| `unstake(node_id, amount)` | Unstake (if unlocked) |
| `delegate(from, to, amount)` | Delegate to another node |
| `slash(node_id, reason, evidence)` | Slash for violation |
| `getEffectiveStake(node_id)` | Own + delegated stake |
| `meetsMinimum(node_id)` | Check stake requirement |
## Use Cases
- **Distributed AI Training**: Reward compute contributors fairly
- **Edge Computing Networks**: Track and reward edge node participation
- **Federated Learning**: Incentivize model training contributions
- **P2P Storage**: Credit-based storage allocation
- **Agent Coordination**: Economic layer for multi-agent systems
- **Decentralized Inference**: Pay-per-inference without blockchain overhead
## Bundle Size
- **WASM binary**: ~177KB (uncompressed)
- **Gzip compressed**: ~65KB
- **JavaScript glue**: ~8KB
## Related Packages
- [ruvector-learning-wasm](https://www.npmjs.com/package/ruvector-learning-wasm) - MicroLoRA adaptation
- [ruvector-exotic-wasm](https://www.npmjs.com/package/ruvector-exotic-wasm) - NAO governance, morphogenetic networks
- [ruvector-nervous-system-wasm](https://www.npmjs.com/package/ruvector-nervous-system-wasm) - Bio-inspired neural components
## License
MIT
## Links
- [GitHub Repository](https://github.com/ruvnet/ruvector)
- [Full Documentation](https://ruv.io)
- [Bug Reports](https://github.com/ruvnet/ruvector/issues)
---
**Keywords**: CRDT, distributed systems, credits, P2P, peer-to-peer, blockchain alternative, reputation, stake, slash, economy, WebAssembly, WASM, edge computing, decentralized, conflict-free, eventual consistency, G-Counter, PN-Counter

View File

@@ -0,0 +1,43 @@
{
"name": "@ruvector/economy-wasm",
"type": "module",
"collaborators": [
"RuVector Team"
],
"author": "RuVector Team <ruvnet@users.noreply.github.com>",
"description": "CRDT-based autonomous credit economy for distributed compute networks - WASM optimized",
"version": "0.1.29",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/ruvnet/ruvector"
},
"bugs": {
"url": "https://github.com/ruvnet/ruvector/issues"
},
"files": [
"ruvector_economy_wasm_bg.wasm",
"ruvector_economy_wasm.js",
"ruvector_economy_wasm.d.ts",
"ruvector_economy_wasm_bg.wasm.d.ts",
"README.md"
],
"main": "ruvector_economy_wasm.js",
"homepage": "https://ruv.io",
"types": "ruvector_economy_wasm.d.ts",
"sideEffects": [
"./snippets/*"
],
"keywords": [
"wasm",
"crdt",
"distributed-economy",
"p2p-credits",
"reputation",
"ruvector",
"webassembly",
"distributed-systems",
"autonomous-economy",
"consensus"
]
}

View File

@@ -0,0 +1,468 @@
/* tslint:disable */
/* eslint-disable */
export class CreditLedger {
free(): void;
[Symbol.dispose](): void;
/**
* Get the state root (Merkle root of ledger state)
*/
stateRoot(): Uint8Array;
/**
* Get event count
*/
eventCount(): number;
/**
* Get total credits spent
*/
totalSpent(): bigint;
/**
* Export spent counter for P2P sync
*/
exportSpent(): Uint8Array;
/**
* Get total credits ever earned (before spending)
*/
totalEarned(): bigint;
/**
* Export earned counter for P2P sync
*/
exportEarned(): Uint8Array;
/**
* Get staked amount
*/
stakedAmount(): bigint;
/**
* Get state root as hex string
*/
stateRootHex(): string;
/**
* Get network compute hours
*/
networkCompute(): number;
/**
* Verify state root matches current state
*/
verifyStateRoot(expected_root: Uint8Array): boolean;
/**
* Get current contribution multiplier
*/
currentMultiplier(): number;
/**
* Credit with multiplier applied (for task rewards)
*/
creditWithMultiplier(base_amount: bigint, reason: string): string;
/**
* Update network compute hours (from P2P sync)
*/
updateNetworkCompute(hours: number): void;
/**
* Create a new credit ledger for a node
*/
constructor(node_id: string);
/**
* Merge with another ledger (CRDT merge operation)
*
* This is the core CRDT operation - associative, commutative, and idempotent.
* Safe to apply in any order with any number of concurrent updates.
*/
merge(other_earned: Uint8Array, other_spent: Uint8Array): number;
/**
* Slash staked credits (penalty for bad behavior)
*
* Returns the actual amount slashed (may be less if stake is insufficient)
*/
slash(amount: bigint): bigint;
/**
* Stake credits for participation
*/
stake(amount: bigint): void;
/**
* Credit the ledger (earn credits)
*
* This updates the G-Counter which is monotonically increasing.
* Safe for concurrent P2P updates.
*/
credit(amount: bigint, _reason: string): string;
/**
* Deduct from the ledger (spend credits)
*
* This updates the PN-Counter positive side.
* Spending can be disputed/refunded by updating the negative side.
*/
deduct(amount: bigint): string;
/**
* Refund a previous deduction (dispute resolution)
*
* This updates the PN-Counter negative side for the given event.
*/
refund(event_id: string, amount: bigint): void;
/**
* Get current available balance (earned - spent - staked)
*/
balance(): bigint;
/**
* Get the node ID
*/
nodeId(): string;
/**
* Unstake credits
*/
unstake(amount: bigint): void;
}
export class ReputationScore {
free(): void;
[Symbol.dispose](): void;
/**
* Get total tasks
*/
totalTasks(): bigint;
/**
* Calculate stake weight using logarithmic scaling
*
* Uses log10(stake + 1) / 6 capped at 1.0
* This means:
* - 0 stake = 0.0 weight
* - 100 stake = ~0.33 weight
* - 10,000 stake = ~0.67 weight
* - 1,000,000 stake = 1.0 weight (capped)
*/
stakeWeight(): number;
/**
* Get tasks failed
*/
tasksFailed(): bigint;
/**
* Update stake amount
*/
updateStake(new_stake: bigint): void;
/**
* Check if node meets minimum reputation for participation
*/
meetsMinimum(min_accuracy: number, min_uptime: number, min_stake: bigint): boolean;
/**
* Update uptime tracking
*/
updateUptime(online_seconds: bigint, total_seconds: bigint): void;
/**
* Check if this reputation is better than another
*/
isBetterThan(other: ReputationScore): boolean;
/**
* Record a failed/disputed task
*/
recordFailure(): void;
/**
* Record a successful task completion
*/
recordSuccess(): void;
/**
* Calculate composite reputation score
*
* Formula: accuracy^2 * uptime * stake_weight
*
* Returns a value between 0.0 and 1.0
*/
compositeScore(): number;
/**
* Get tasks completed
*/
tasksCompleted(): bigint;
/**
* Create with detailed tracking
*/
static newWithTracking(tasks_completed: bigint, tasks_failed: bigint, uptime_seconds: bigint, total_seconds: bigint, stake: bigint): ReputationScore;
/**
* Create a new reputation score
*/
constructor(accuracy: number, uptime: number, stake: bigint);
/**
* Serialize to JSON
*/
toJson(): string;
/**
* Deserialize from JSON
*/
static fromJson(json: string): ReputationScore;
/**
* Get reputation tier based on composite score
*/
tierName(): string;
/**
* Get stake amount
*/
readonly stake: bigint;
/**
* Get uptime score (0.0 - 1.0)
*/
readonly uptime: number;
/**
* Get accuracy score (0.0 - 1.0)
*/
readonly accuracy: number;
}
/**
* Reasons for slashing stake
*/
export enum SlashReason {
/**
* Invalid task result
*/
InvalidResult = 0,
/**
* Double-spending attempt
*/
DoubleSpend = 1,
/**
* Sybil attack detected
*/
SybilAttack = 2,
/**
* Excessive downtime
*/
Downtime = 3,
/**
* Spam/flooding
*/
Spam = 4,
/**
* Malicious behavior
*/
Malicious = 5,
}
export class StakeManager {
free(): void;
[Symbol.dispose](): void;
/**
* Undelegate stake
*/
undelegate(from_node: string, to_node: string, amount: bigint): void;
/**
* Export stake data as JSON
*/
exportJson(): string;
/**
* Get number of stakers
*/
stakerCount(): number;
/**
* Get total network staked
*/
totalStaked(): bigint;
/**
* Check if node meets minimum stake
*/
meetsMinimum(node_id: string): boolean;
/**
* Get total slashed
*/
totalSlashed(): bigint;
/**
* Get slash count for a node
*/
getSlashCount(node_id: string): number;
/**
* Create with custom parameters
*/
static newWithParams(min_stake: bigint, lock_period_ms: bigint): StakeManager;
/**
* Get lock timestamp for a node
*/
getLockTimestamp(node_id: string): bigint;
/**
* Get delegator count
*/
getDelegatorCount(node_id: string): number;
/**
* Get effective stake (own + delegated)
*/
getEffectiveStake(node_id: string): bigint;
/**
* Get total amount slashed from a node
*/
getNodeTotalSlashed(node_id: string): bigint;
/**
* Create a new stake manager
*/
constructor();
/**
* Slash stake for bad behavior
*/
slash(node_id: string, reason: SlashReason, evidence: string): bigint;
/**
* Stake credits for a node
*/
stake(node_id: string, amount: bigint): void;
/**
* Unstake credits (if lock period has passed)
*/
unstake(node_id: string, amount: bigint): bigint;
/**
* Delegate stake to another node
*/
delegate(from_node: string, to_node: string, amount: bigint): void;
/**
* Get stake for a node
*/
getStake(node_id: string): bigint;
/**
* Check if stake is locked
*/
isLocked(node_id: string): boolean;
/**
* Get minimum stake requirement
*/
minStake(): bigint;
}
/**
* Calculate reward with multiplier (WASM export)
*/
export function calculate_reward(base_reward: bigint, network_compute_hours: number): bigint;
/**
* Calculate composite reputation score (WASM export)
*/
export function composite_reputation(accuracy: number, uptime: number, stake: bigint): number;
/**
* Calculate contribution multiplier (WASM export)
*
* Returns the reward multiplier based on total network compute hours.
* Early adopters get up to 10x rewards, decaying to 1x as network grows.
*/
export function contribution_multiplier(network_compute_hours: number): number;
/**
* Get tier name based on compute level (WASM export)
*/
export function get_tier_name(network_compute_hours: number): string;
/**
* Get tier information as JSON (WASM export)
*/
export function get_tiers_json(): string;
/**
* Initialize panic hook for better error messages in console
*/
export function init_panic_hook(): void;
/**
* Calculate stake weight (WASM export)
*/
export function stake_weight(stake: bigint): number;
/**
* Get the current version of the economy module
*/
export function version(): string;
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
export interface InitOutput {
readonly memory: WebAssembly.Memory;
readonly __wbg_creditledger_free: (a: number, b: number) => void;
readonly __wbg_reputationscore_free: (a: number, b: number) => void;
readonly __wbg_stakemanager_free: (a: number, b: number) => void;
readonly calculate_reward: (a: bigint, b: number) => bigint;
readonly composite_reputation: (a: number, b: number, c: bigint) => number;
readonly contribution_multiplier: (a: number) => number;
readonly creditledger_balance: (a: number) => bigint;
readonly creditledger_credit: (a: number, b: number, c: bigint, d: number, e: number) => void;
readonly creditledger_creditWithMultiplier: (a: number, b: number, c: bigint, d: number, e: number) => void;
readonly creditledger_currentMultiplier: (a: number) => number;
readonly creditledger_deduct: (a: number, b: number, c: bigint) => void;
readonly creditledger_eventCount: (a: number) => number;
readonly creditledger_exportEarned: (a: number, b: number) => void;
readonly creditledger_exportSpent: (a: number, b: number) => void;
readonly creditledger_merge: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
readonly creditledger_networkCompute: (a: number) => number;
readonly creditledger_new: (a: number, b: number, c: number) => void;
readonly creditledger_nodeId: (a: number, b: number) => void;
readonly creditledger_refund: (a: number, b: number, c: number, d: number, e: bigint) => void;
readonly creditledger_slash: (a: number, b: number, c: bigint) => void;
readonly creditledger_stake: (a: number, b: number, c: bigint) => void;
readonly creditledger_stakedAmount: (a: number) => bigint;
readonly creditledger_stateRoot: (a: number, b: number) => void;
readonly creditledger_stateRootHex: (a: number, b: number) => void;
readonly creditledger_totalEarned: (a: number) => bigint;
readonly creditledger_totalSpent: (a: number) => bigint;
readonly creditledger_unstake: (a: number, b: number, c: bigint) => void;
readonly creditledger_updateNetworkCompute: (a: number, b: number) => void;
readonly creditledger_verifyStateRoot: (a: number, b: number, c: number) => number;
readonly get_tier_name: (a: number, b: number) => void;
readonly get_tiers_json: (a: number) => void;
readonly reputationscore_accuracy: (a: number) => number;
readonly reputationscore_compositeScore: (a: number) => number;
readonly reputationscore_fromJson: (a: number, b: number, c: number) => void;
readonly reputationscore_isBetterThan: (a: number, b: number) => number;
readonly reputationscore_meetsMinimum: (a: number, b: number, c: number, d: bigint) => number;
readonly reputationscore_new: (a: number, b: number, c: bigint) => number;
readonly reputationscore_newWithTracking: (a: bigint, b: bigint, c: bigint, d: bigint, e: bigint) => number;
readonly reputationscore_recordFailure: (a: number) => void;
readonly reputationscore_recordSuccess: (a: number) => void;
readonly reputationscore_stake: (a: number) => bigint;
readonly reputationscore_stakeWeight: (a: number) => number;
readonly reputationscore_tasksCompleted: (a: number) => bigint;
readonly reputationscore_tasksFailed: (a: number) => bigint;
readonly reputationscore_tierName: (a: number, b: number) => void;
readonly reputationscore_toJson: (a: number, b: number) => void;
readonly reputationscore_totalTasks: (a: number) => bigint;
readonly reputationscore_updateStake: (a: number, b: bigint) => void;
readonly reputationscore_updateUptime: (a: number, b: bigint, c: bigint) => void;
readonly reputationscore_uptime: (a: number) => number;
readonly stake_weight: (a: bigint) => number;
readonly stakemanager_delegate: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => void;
readonly stakemanager_exportJson: (a: number, b: number) => void;
readonly stakemanager_getDelegatorCount: (a: number, b: number, c: number) => number;
readonly stakemanager_getEffectiveStake: (a: number, b: number, c: number) => bigint;
readonly stakemanager_getLockTimestamp: (a: number, b: number, c: number) => bigint;
readonly stakemanager_getNodeTotalSlashed: (a: number, b: number, c: number) => bigint;
readonly stakemanager_getSlashCount: (a: number, b: number, c: number) => number;
readonly stakemanager_getStake: (a: number, b: number, c: number) => bigint;
readonly stakemanager_isLocked: (a: number, b: number, c: number) => number;
readonly stakemanager_meetsMinimum: (a: number, b: number, c: number) => number;
readonly stakemanager_new: () => number;
readonly stakemanager_newWithParams: (a: bigint, b: bigint) => number;
readonly stakemanager_slash: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
readonly stakemanager_stake: (a: number, b: number, c: number, d: number, e: bigint) => void;
readonly stakemanager_stakerCount: (a: number) => number;
readonly stakemanager_totalSlashed: (a: number) => bigint;
readonly stakemanager_totalStaked: (a: number) => bigint;
readonly stakemanager_undelegate: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => void;
readonly stakemanager_unstake: (a: number, b: number, c: number, d: number, e: bigint) => void;
readonly version: (a: number) => void;
readonly init_panic_hook: () => void;
readonly stakemanager_minStake: (a: number) => bigint;
readonly __wbindgen_export: (a: number, b: number, c: number) => void;
readonly __wbindgen_export2: (a: number, b: number) => number;
readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
readonly __wbindgen_start: () => void;
}
export type SyncInitInput = BufferSource | WebAssembly.Module;
/**
* Instantiates the given `module`, which can either be bytes or
* a precompiled `WebAssembly.Module`.
*
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
*
* @returns {InitOutput}
*/
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
/**
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
* for everything else, calls `WebAssembly.instantiate` directly.
*
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
*
* @returns {Promise<InitOutput>}
*/
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,81 @@
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export const __wbg_creditledger_free: (a: number, b: number) => void;
export const __wbg_reputationscore_free: (a: number, b: number) => void;
export const __wbg_stakemanager_free: (a: number, b: number) => void;
export const calculate_reward: (a: bigint, b: number) => bigint;
export const composite_reputation: (a: number, b: number, c: bigint) => number;
export const contribution_multiplier: (a: number) => number;
export const creditledger_balance: (a: number) => bigint;
export const creditledger_credit: (a: number, b: number, c: bigint, d: number, e: number) => void;
export const creditledger_creditWithMultiplier: (a: number, b: number, c: bigint, d: number, e: number) => void;
export const creditledger_currentMultiplier: (a: number) => number;
export const creditledger_deduct: (a: number, b: number, c: bigint) => void;
export const creditledger_eventCount: (a: number) => number;
export const creditledger_exportEarned: (a: number, b: number) => void;
export const creditledger_exportSpent: (a: number, b: number) => void;
export const creditledger_merge: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
export const creditledger_networkCompute: (a: number) => number;
export const creditledger_new: (a: number, b: number, c: number) => void;
export const creditledger_nodeId: (a: number, b: number) => void;
export const creditledger_refund: (a: number, b: number, c: number, d: number, e: bigint) => void;
export const creditledger_slash: (a: number, b: number, c: bigint) => void;
export const creditledger_stake: (a: number, b: number, c: bigint) => void;
export const creditledger_stakedAmount: (a: number) => bigint;
export const creditledger_stateRoot: (a: number, b: number) => void;
export const creditledger_stateRootHex: (a: number, b: number) => void;
export const creditledger_totalEarned: (a: number) => bigint;
export const creditledger_totalSpent: (a: number) => bigint;
export const creditledger_unstake: (a: number, b: number, c: bigint) => void;
export const creditledger_updateNetworkCompute: (a: number, b: number) => void;
export const creditledger_verifyStateRoot: (a: number, b: number, c: number) => number;
export const get_tier_name: (a: number, b: number) => void;
export const get_tiers_json: (a: number) => void;
export const reputationscore_accuracy: (a: number) => number;
export const reputationscore_compositeScore: (a: number) => number;
export const reputationscore_fromJson: (a: number, b: number, c: number) => void;
export const reputationscore_isBetterThan: (a: number, b: number) => number;
export const reputationscore_meetsMinimum: (a: number, b: number, c: number, d: bigint) => number;
export const reputationscore_new: (a: number, b: number, c: bigint) => number;
export const reputationscore_newWithTracking: (a: bigint, b: bigint, c: bigint, d: bigint, e: bigint) => number;
export const reputationscore_recordFailure: (a: number) => void;
export const reputationscore_recordSuccess: (a: number) => void;
export const reputationscore_stake: (a: number) => bigint;
export const reputationscore_stakeWeight: (a: number) => number;
export const reputationscore_tasksCompleted: (a: number) => bigint;
export const reputationscore_tasksFailed: (a: number) => bigint;
export const reputationscore_tierName: (a: number, b: number) => void;
export const reputationscore_toJson: (a: number, b: number) => void;
export const reputationscore_totalTasks: (a: number) => bigint;
export const reputationscore_updateStake: (a: number, b: bigint) => void;
export const reputationscore_updateUptime: (a: number, b: bigint, c: bigint) => void;
export const reputationscore_uptime: (a: number) => number;
export const stake_weight: (a: bigint) => number;
export const stakemanager_delegate: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => void;
export const stakemanager_exportJson: (a: number, b: number) => void;
export const stakemanager_getDelegatorCount: (a: number, b: number, c: number) => number;
export const stakemanager_getEffectiveStake: (a: number, b: number, c: number) => bigint;
export const stakemanager_getLockTimestamp: (a: number, b: number, c: number) => bigint;
export const stakemanager_getNodeTotalSlashed: (a: number, b: number, c: number) => bigint;
export const stakemanager_getSlashCount: (a: number, b: number, c: number) => number;
export const stakemanager_getStake: (a: number, b: number, c: number) => bigint;
export const stakemanager_isLocked: (a: number, b: number, c: number) => number;
export const stakemanager_meetsMinimum: (a: number, b: number, c: number) => number;
export const stakemanager_new: () => number;
export const stakemanager_newWithParams: (a: bigint, b: bigint) => number;
export const stakemanager_slash: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
export const stakemanager_stake: (a: number, b: number, c: number, d: number, e: bigint) => void;
export const stakemanager_stakerCount: (a: number) => number;
export const stakemanager_totalSlashed: (a: number) => bigint;
export const stakemanager_totalStaked: (a: number) => bigint;
export const stakemanager_undelegate: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => void;
export const stakemanager_unstake: (a: number, b: number, c: number, d: number, e: bigint) => void;
export const version: (a: number) => void;
export const init_panic_hook: () => void;
export const stakemanager_minStake: (a: number) => bigint;
export const __wbindgen_export: (a: number, b: number, c: number) => void;
export const __wbindgen_export2: (a: number, b: number) => number;
export const __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
export const __wbindgen_start: () => void;