@totemsdk/provider-bond 0.1.0 → 0.1.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 Totem SDK
3
+ Copyright (c) 2024 Totem SDK Contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -30,18 +30,18 @@ Provider trust layer for Totem Edge — prove, record, score and filter infrastr
30
30
  | | provider-bond | liquidity-bond (future) |
31
31
  |---|---|---|
32
32
  | **Scope** | Provider trust, identity, reputation | LP deposits, shares, rewards, withdrawals |
33
- | **Bonds** | Declared MINIMA hard collateral | Productive liquidity positions |
33
+ | **Bonds** | Declared hard collateral | Productive liquidity positions |
34
34
  | **Scoring** | Identity + bond + reliability + incidents | LP performance, fee generation |
35
35
  | **Policy** | Provider selection and filtering | Liquidity allocation and routing |
36
36
 
37
37
  `liquidityBondRefs` are string references to a future `@totemsdk/liquidity-bond` package. They do not count as collateral in v0.1.
38
38
 
39
- ## MINIMA-first provider trust model
39
+ ## Asset-agnostic provider trust model
40
40
 
41
41
  - `MINIMA` is the default hard-collateral and bond asset
42
- - `TOTEM` cannot satisfy MINIMA hard-collateral policy
42
+ - Any token declared as `hard-collateral` (e.g. stablecoins via `LiquidityAsset`) satisfies bond scoring equally — `computeProviderScore` does not discriminate by asset
43
43
  - `TOTEM` may satisfy service-level or reputation policies only if explicitly accepted
44
- - Other tokens cannot satisfy MINIMA hard-collateral policy unless explicitly accepted
44
+ - Specific policy requirements (e.g. `requireMinimaHardCollateral`) are opt-in and can be combined with `acceptedAssets` for non-Minima collateral
45
45
  - Liquidity references do not count as bond collateral in v0.1
46
46
 
47
47
  ## Manifest compatibility
@@ -78,7 +78,7 @@ Incidents track provider issues: downtime, high-latency, failed-probe, invalid-r
78
78
  Scores are computed deterministically from four components:
79
79
 
80
80
  - **Identity** (25%) — is an identity address declared?
81
- - **Bond** (30%) — is there an active MINIMA hard-collateral bond with proof?
81
+ - **Bond** (30%) — is there an active hard-collateral bond with proof?
82
82
  - **Reliability** (30%) — probe success rate and latency
83
83
  - **Incidents** (15%) — open, critical, and high-severity incidents
84
84
 
@@ -86,7 +86,7 @@ Recommendations: `recommended` (80+), `acceptable` (60+), `risky` (40+), `avoid`
86
86
 
87
87
  ## Policy filtering
88
88
 
89
- Policies filter providers by: service type, minimum score, identity requirement, active bond requirement, MINIMA hard collateral requirement, minimum bond amount, accepted assets/purposes, maximum incident severity, and maximum heartbeat age.
89
+ Policies filter providers by: service type, minimum score, identity requirement, active bond requirement, MINIMA hard collateral requirement (opt-in), minimum bond amount, accepted assets/purposes, maximum incident severity, and maximum heartbeat age.
90
90
 
91
91
  ## Pear/Bare compatibility
92
92
 
@@ -137,7 +137,7 @@ if (!result.ok) {
137
137
  }
138
138
  ```
139
139
 
140
- ### Attach MINIMA bond proof
140
+ ### Attach bond proof
141
141
 
142
142
  ```ts
143
143
  import { attachBondProof } from '@totemsdk/provider-bond';
package/dist/manifest.js CHANGED
@@ -13,7 +13,9 @@ function hexToBytes(hex) {
13
13
  return (0, core_1.hexToBytes)(hex);
14
14
  }
15
15
  function bytesToHex(bytes) {
16
- return (0, core_1.bytesToHex)(bytes);
16
+ return '0x' + Array.from(bytes)
17
+ .map((b) => b.toString(16).padStart(2, '0'))
18
+ .join('');
17
19
  }
18
20
  function createProviderBondManifest(params) {
19
21
  const edgeServiceManifestId = (0, manifest_1.computeManifestId)(params.edgeService);
package/dist/scoring.js CHANGED
@@ -18,19 +18,19 @@ function computeProviderScore(params) {
18
18
  }
19
19
  let bondScore = 0;
20
20
  const hasBond = provider.providerBond.bondStack && provider.providerBond.bondStack.length > 0;
21
- const hasMinimaBond = hasBond && provider.providerBond.bondStack.some((d) => d.asset === 'MINIMA' && d.purpose === 'hard-collateral' && d.status === 'active');
21
+ const hasHardCollateralBond = hasBond && provider.providerBond.bondStack.some((d) => d.purpose === 'hard-collateral' && d.status === 'active');
22
22
  const hasProof = bondProofs && bondProofs.length > 0;
23
- if (hasMinimaBond && hasProof) {
23
+ if (hasHardCollateralBond && hasProof) {
24
24
  bondScore = 100;
25
- reasons.push('Active MINIMA hard-collateral bond with proof');
25
+ reasons.push('Active hard-collateral bond with proof');
26
26
  }
27
- else if (hasMinimaBond) {
27
+ else if (hasHardCollateralBond) {
28
28
  bondScore = 70;
29
- reasons.push('MINIMA bond declared but no proof attached');
29
+ reasons.push('Hard-collateral bond declared but no proof attached');
30
30
  }
31
31
  else if (hasBond) {
32
32
  bondScore = 40;
33
- reasons.push('Bond declared but not MINIMA hard-collateral');
33
+ reasons.push('Bond declared but not hard-collateral');
34
34
  }
35
35
  else {
36
36
  reasons.push('No bond declared');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@totemsdk/provider-bond",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Provider trust layer for Totem Edge — prove, record, score and filter infrastructure providers",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,38 +11,25 @@
11
11
  "import": "./dist/index.js"
12
12
  }
13
13
  },
14
- "scripts": {
15
- "build": "tsc",
16
- "prepare": "tsc",
17
- "clean": "rm -rf dist",
18
- "test": "jest --passWithNoTests"
19
- },
20
14
  "files": [
21
15
  "dist",
16
+ "rust/pkg/",
17
+ "rust/pkg-node/",
22
18
  "README.md",
23
19
  "LICENSE"
24
20
  ],
25
21
  "dependencies": {
26
- "@totemsdk/core": "^1.1.0",
27
- "@totemsdk/identity": "^0.1.2",
28
- "@totemsdk/manifest": "^0.1.2",
29
- "@totemsdk/proof": "^0.1.1"
30
- },
31
- "peerDependencies": {
32
- "@noble/hashes": "^2.0.0"
33
- },
34
- "peerDependenciesMeta": {
35
- "@noble/hashes": {
36
- "optional": false
37
- }
22
+ "@totemsdk/core": "^1.2.8",
23
+ "@totemsdk/manifest": "^0.1.3",
24
+ "@totemsdk/proof": "^0.1.2",
25
+ "@totemsdk/identity": "^0.1.4"
38
26
  },
39
27
  "devDependencies": {
40
- "@noble/hashes": "^2.2.0",
41
- "@types/jest": "^29.5.14",
28
+ "@types/jest": "^30.0.0",
42
29
  "@types/node": "^20.19.43",
43
- "jest": "^29.7.0",
30
+ "jest": "^30.4.2",
44
31
  "ts-jest": "^29.4.11",
45
- "typescript": "^5.0.0"
32
+ "typescript": "^7.0.2"
46
33
  },
47
34
  "engines": {
48
35
  "node": ">=18.0.0"
@@ -52,14 +39,14 @@
52
39
  },
53
40
  "license": "MIT",
54
41
  "author": "Totem SDK",
55
- "homepage": "https://totemsdk.com",
42
+ "homepage": "https://totem.ing",
56
43
  "bugs": {
57
- "url": "https://github.com/MrGheek/axia-totem/issues"
44
+ "url": "https://github.com/totem-sdk/totem-sdk/issues"
58
45
  },
59
46
  "repository": {
60
47
  "type": "git",
61
- "url": "git+https://github.com/MrGheek/axia-totem.git",
62
- "directory": "packages/totem-sdk/packages/provider-bond"
48
+ "url": "git+https://github.com/totem-sdk/totem-sdk.git",
49
+ "directory": "packages/provider-bond"
63
50
  },
64
51
  "keywords": [
65
52
  "totem",
@@ -68,9 +55,16 @@
68
55
  "blockchain",
69
56
  "quantum-resistant",
70
57
  "wots",
58
+ "utxo",
71
59
  "provider",
72
60
  "bond",
73
61
  "reputation",
74
62
  "trust"
75
- ]
76
- }
63
+ ],
64
+ "scripts": {
65
+ "build": "npm run build:wasm && tsc && node ../../scripts/clean-wasm-output-ignores.mjs",
66
+ "clean": "rm -rf dist rust/pkg rust/pkg-node rust/target",
67
+ "test": "jest",
68
+ "build:wasm": "cd rust && wasm-pack build --target bundler --out-dir pkg && wasm-pack build --target nodejs --out-dir pkg-node"
69
+ }
70
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "provider-bond-wasm",
3
+ "type": "module",
4
+ "collaborators": [
5
+ "Totem SDK Contributors"
6
+ ],
7
+ "description": "Provider bond computation layer — scoring engine, policy filtering, incident severity ranking, bond stack verification (Rust/WASM)",
8
+ "version": "0.1.0",
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/totem-sdk/totem-sdk"
13
+ },
14
+ "files": [
15
+ "provider_bond_wasm_bg.wasm",
16
+ "provider_bond_wasm.js",
17
+ "provider_bond_wasm_bg.js",
18
+ "provider_bond_wasm.d.ts"
19
+ ],
20
+ "main": "provider_bond_wasm.js",
21
+ "homepage": "https://totem.ing",
22
+ "types": "provider_bond_wasm.d.ts",
23
+ "sideEffects": [
24
+ "./provider_bond_wasm.js",
25
+ "./snippets/*"
26
+ ]
27
+ }
@@ -0,0 +1,10 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export function compute_provider_score_wasm(provider_js: any, probes_js: any, incidents_js: any, now: bigint, weights_js: any): any;
5
+
6
+ export function compute_recommendation_wasm(score: number): string;
7
+
8
+ export function filter_providers_by_policy_wasm(provider_js: any, policy_js: any, score_js: any | null | undefined, probes_js: any, incidents_js: any): any;
9
+
10
+ export function init(): void;
@@ -0,0 +1,9 @@
1
+ /* @ts-self-types="./provider_bond_wasm.d.ts" */
2
+ import * as wasm from "./provider_bond_wasm_bg.wasm";
3
+ import { __wbg_set_wasm } from "./provider_bond_wasm_bg.js";
4
+
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ compute_provider_score_wasm, compute_recommendation_wasm, filter_providers_by_policy_wasm, init
9
+ } from "./provider_bond_wasm_bg.js";
@@ -0,0 +1,456 @@
1
+ /**
2
+ * @param {any} provider_js
3
+ * @param {any} probes_js
4
+ * @param {any} incidents_js
5
+ * @param {bigint} now
6
+ * @param {any} weights_js
7
+ * @returns {any}
8
+ */
9
+ export function compute_provider_score_wasm(provider_js, probes_js, incidents_js, now, weights_js) {
10
+ const ret = wasm.compute_provider_score_wasm(provider_js, probes_js, incidents_js, now, weights_js);
11
+ if (ret[2]) {
12
+ throw takeFromExternrefTable0(ret[1]);
13
+ }
14
+ return takeFromExternrefTable0(ret[0]);
15
+ }
16
+
17
+ /**
18
+ * @param {number} score
19
+ * @returns {string}
20
+ */
21
+ export function compute_recommendation_wasm(score) {
22
+ let deferred1_0;
23
+ let deferred1_1;
24
+ try {
25
+ const ret = wasm.compute_recommendation_wasm(score);
26
+ deferred1_0 = ret[0];
27
+ deferred1_1 = ret[1];
28
+ return getStringFromWasm0(ret[0], ret[1]);
29
+ } finally {
30
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
31
+ }
32
+ }
33
+
34
+ /**
35
+ * @param {any} provider_js
36
+ * @param {any} policy_js
37
+ * @param {any | null | undefined} score_js
38
+ * @param {any} probes_js
39
+ * @param {any} incidents_js
40
+ * @returns {any}
41
+ */
42
+ export function filter_providers_by_policy_wasm(provider_js, policy_js, score_js, probes_js, incidents_js) {
43
+ const ret = wasm.filter_providers_by_policy_wasm(provider_js, policy_js, isLikeNone(score_js) ? 0 : addToExternrefTable0(score_js), probes_js, incidents_js);
44
+ if (ret[2]) {
45
+ throw takeFromExternrefTable0(ret[1]);
46
+ }
47
+ return takeFromExternrefTable0(ret[0]);
48
+ }
49
+
50
+ export function init() {
51
+ wasm.init();
52
+ }
53
+ export function __wbg_Error_92b29b0548f8b746(arg0, arg1) {
54
+ const ret = Error(getStringFromWasm0(arg0, arg1));
55
+ return ret;
56
+ }
57
+ export function __wbg_Number_9a4e0ecb0fa16705(arg0) {
58
+ const ret = Number(arg0);
59
+ return ret;
60
+ }
61
+ export function __wbg_String_8564e559799eccda(arg0, arg1) {
62
+ const ret = String(arg1);
63
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
64
+ const len1 = WASM_VECTOR_LEN;
65
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
66
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
67
+ }
68
+ export function __wbg___wbindgen_bigint_get_as_i64_d968e41184ae354f(arg0, arg1) {
69
+ const v = arg1;
70
+ const ret = typeof(v) === 'bigint' ? v : undefined;
71
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
72
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
73
+ }
74
+ export function __wbg___wbindgen_boolean_get_fa956cfa2d1bd751(arg0) {
75
+ const v = arg0;
76
+ const ret = typeof(v) === 'boolean' ? v : undefined;
77
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
78
+ }
79
+ export function __wbg___wbindgen_debug_string_c25d447a39f5578f(arg0, arg1) {
80
+ const ret = debugString(arg1);
81
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
82
+ const len1 = WASM_VECTOR_LEN;
83
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
84
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
85
+ }
86
+ export function __wbg___wbindgen_in_aca499c5de7ff5e5(arg0, arg1) {
87
+ const ret = arg0 in arg1;
88
+ return ret;
89
+ }
90
+ export function __wbg___wbindgen_is_bigint_2f76dc55065b4273(arg0) {
91
+ const ret = typeof(arg0) === 'bigint';
92
+ return ret;
93
+ }
94
+ export function __wbg___wbindgen_is_function_1ff95bcc5517c252(arg0) {
95
+ const ret = typeof(arg0) === 'function';
96
+ return ret;
97
+ }
98
+ export function __wbg___wbindgen_is_object_a27215656b807791(arg0) {
99
+ const val = arg0;
100
+ const ret = typeof(val) === 'object' && val !== null;
101
+ return ret;
102
+ }
103
+ export function __wbg___wbindgen_is_undefined_c05833b95a3cf397(arg0) {
104
+ const ret = arg0 === undefined;
105
+ return ret;
106
+ }
107
+ export function __wbg___wbindgen_jsval_eq_e659fcf7b0e32763(arg0, arg1) {
108
+ const ret = arg0 === arg1;
109
+ return ret;
110
+ }
111
+ export function __wbg___wbindgen_jsval_loose_eq_db4c3b15f63fc170(arg0, arg1) {
112
+ const ret = arg0 == arg1;
113
+ return ret;
114
+ }
115
+ export function __wbg___wbindgen_number_get_394265ed1e1b84ee(arg0, arg1) {
116
+ const obj = arg1;
117
+ const ret = typeof(obj) === 'number' ? obj : undefined;
118
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
119
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
120
+ }
121
+ export function __wbg___wbindgen_string_get_b0ca35b86a603356(arg0, arg1) {
122
+ const obj = arg1;
123
+ const ret = typeof(obj) === 'string' ? obj : undefined;
124
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
125
+ var len1 = WASM_VECTOR_LEN;
126
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
127
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
128
+ }
129
+ export function __wbg___wbindgen_throw_344f42d3211c4765(arg0, arg1) {
130
+ throw new Error(getStringFromWasm0(arg0, arg1));
131
+ }
132
+ export function __wbg_call_8a2dd23819f8a60a() { return handleError(function (arg0, arg1) {
133
+ const ret = arg0.call(arg1);
134
+ return ret;
135
+ }, arguments); }
136
+ export function __wbg_done_89b2b13e91a60321(arg0) {
137
+ const ret = arg0.done;
138
+ return ret;
139
+ }
140
+ export function __wbg_error_a6fa202b58aa1cd3(arg0, arg1) {
141
+ let deferred0_0;
142
+ let deferred0_1;
143
+ try {
144
+ deferred0_0 = arg0;
145
+ deferred0_1 = arg1;
146
+ console.error(getStringFromWasm0(arg0, arg1));
147
+ } finally {
148
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
149
+ }
150
+ }
151
+ export function __wbg_get_c7eb1f358a7654df() { return handleError(function (arg0, arg1) {
152
+ const ret = Reflect.get(arg0, arg1);
153
+ return ret;
154
+ }, arguments); }
155
+ export function __wbg_get_unchecked_6e0ad6d2a41b06f6(arg0, arg1) {
156
+ const ret = arg0[arg1 >>> 0];
157
+ return ret;
158
+ }
159
+ export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
160
+ const ret = arg0[arg1];
161
+ return ret;
162
+ }
163
+ export function __wbg_instanceof_ArrayBuffer_4480b9e0068a8adb(arg0) {
164
+ let result;
165
+ try {
166
+ result = arg0 instanceof ArrayBuffer;
167
+ } catch (_) {
168
+ result = false;
169
+ }
170
+ const ret = result;
171
+ return ret;
172
+ }
173
+ export function __wbg_instanceof_Uint8Array_309b927aaf7a3fc7(arg0) {
174
+ let result;
175
+ try {
176
+ result = arg0 instanceof Uint8Array;
177
+ } catch (_) {
178
+ result = false;
179
+ }
180
+ const ret = result;
181
+ return ret;
182
+ }
183
+ export function __wbg_isArray_0677c962b281d01a(arg0) {
184
+ const ret = Array.isArray(arg0);
185
+ return ret;
186
+ }
187
+ export function __wbg_isSafeInteger_04f36e4056f1b851(arg0) {
188
+ const ret = Number.isSafeInteger(arg0);
189
+ return ret;
190
+ }
191
+ export function __wbg_iterator_6f722e4a93058b71() {
192
+ const ret = Symbol.iterator;
193
+ return ret;
194
+ }
195
+ export function __wbg_length_1f0964f4a5e2c6d8(arg0) {
196
+ const ret = arg0.length;
197
+ return ret;
198
+ }
199
+ export function __wbg_length_370319915dc99107(arg0) {
200
+ const ret = arg0.length;
201
+ return ret;
202
+ }
203
+ export function __wbg_new_227d7c05414eb861() {
204
+ const ret = new Error();
205
+ return ret;
206
+ }
207
+ export function __wbg_new_32b398fb48b6d94a() {
208
+ const ret = new Array();
209
+ return ret;
210
+ }
211
+ export function __wbg_new_cd45aabdf6073e84(arg0) {
212
+ const ret = new Uint8Array(arg0);
213
+ return ret;
214
+ }
215
+ export function __wbg_new_da52cf8fe3429cb2() {
216
+ const ret = new Object();
217
+ return ret;
218
+ }
219
+ export function __wbg_next_6dbf2c0ac8cde20f(arg0) {
220
+ const ret = arg0.next;
221
+ return ret;
222
+ }
223
+ export function __wbg_next_71f2aa1cb3d1e37e() { return handleError(function (arg0) {
224
+ const ret = arg0.next();
225
+ return ret;
226
+ }, arguments); }
227
+ export function __wbg_prototypesetcall_4770620bbe4688a0(arg0, arg1, arg2) {
228
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
229
+ }
230
+ export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
231
+ arg0[arg1] = arg2;
232
+ }
233
+ export function __wbg_set_8a16b38e4805b298(arg0, arg1, arg2) {
234
+ arg0[arg1 >>> 0] = arg2;
235
+ }
236
+ export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
237
+ const ret = arg1.stack;
238
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
239
+ const len1 = WASM_VECTOR_LEN;
240
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
241
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
242
+ }
243
+ export function __wbg_value_a5d5488a9589444a(arg0) {
244
+ const ret = arg0.value;
245
+ return ret;
246
+ }
247
+ export function __wbindgen_cast_0000000000000001(arg0) {
248
+ // Cast intrinsic for `F64 -> Externref`.
249
+ const ret = arg0;
250
+ return ret;
251
+ }
252
+ export function __wbindgen_cast_0000000000000002(arg0, arg1) {
253
+ // Cast intrinsic for `Ref(String) -> Externref`.
254
+ const ret = getStringFromWasm0(arg0, arg1);
255
+ return ret;
256
+ }
257
+ export function __wbindgen_cast_0000000000000003(arg0) {
258
+ // Cast intrinsic for `U64 -> Externref`.
259
+ const ret = BigInt.asUintN(64, arg0);
260
+ return ret;
261
+ }
262
+ export function __wbindgen_init_externref_table() {
263
+ const table = wasm.__wbindgen_externrefs;
264
+ const offset = table.grow(4);
265
+ table.set(0, undefined);
266
+ table.set(offset + 0, undefined);
267
+ table.set(offset + 1, null);
268
+ table.set(offset + 2, true);
269
+ table.set(offset + 3, false);
270
+ }
271
+ function addToExternrefTable0(obj) {
272
+ const idx = wasm.__externref_table_alloc();
273
+ wasm.__wbindgen_externrefs.set(idx, obj);
274
+ return idx;
275
+ }
276
+
277
+ function debugString(val) {
278
+ // primitive types
279
+ const type = typeof val;
280
+ if (type == 'number' || type == 'boolean' || val == null) {
281
+ return `${val}`;
282
+ }
283
+ if (type == 'string') {
284
+ return `"${val}"`;
285
+ }
286
+ if (type == 'symbol') {
287
+ const description = val.description;
288
+ if (description == null) {
289
+ return 'Symbol';
290
+ } else {
291
+ return `Symbol(${description})`;
292
+ }
293
+ }
294
+ if (type == 'function') {
295
+ const name = val.name;
296
+ if (typeof name == 'string' && name.length > 0) {
297
+ return `Function(${name})`;
298
+ } else {
299
+ return 'Function';
300
+ }
301
+ }
302
+ // objects
303
+ if (Array.isArray(val)) {
304
+ const length = val.length;
305
+ let debug = '[';
306
+ if (length > 0) {
307
+ debug += debugString(val[0]);
308
+ }
309
+ for(let i = 1; i < length; i++) {
310
+ debug += ', ' + debugString(val[i]);
311
+ }
312
+ debug += ']';
313
+ return debug;
314
+ }
315
+ // Test for built-in
316
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
317
+ let className;
318
+ if (builtInMatches && builtInMatches.length > 1) {
319
+ className = builtInMatches[1];
320
+ } else {
321
+ // Failed to match the standard '[object ClassName]'
322
+ return toString.call(val);
323
+ }
324
+ if (className == 'Object') {
325
+ // we're a user defined class or Object
326
+ // JSON.stringify avoids problems with cycles, and is generally much
327
+ // easier than looping through ownProperties of `val`.
328
+ try {
329
+ return 'Object(' + JSON.stringify(val) + ')';
330
+ } catch (_) {
331
+ return 'Object';
332
+ }
333
+ }
334
+ // errors
335
+ if (val instanceof Error) {
336
+ return `${val.name}: ${val.message}\n${val.stack}`;
337
+ }
338
+ // TODO we could test for more things here, like `Set`s and `Map`s.
339
+ return className;
340
+ }
341
+
342
+ function getArrayU8FromWasm0(ptr, len) {
343
+ ptr = ptr >>> 0;
344
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
345
+ }
346
+
347
+ let cachedDataViewMemory0 = null;
348
+ function getDataViewMemory0() {
349
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
350
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
351
+ }
352
+ return cachedDataViewMemory0;
353
+ }
354
+
355
+ function getStringFromWasm0(ptr, len) {
356
+ return decodeText(ptr >>> 0, len);
357
+ }
358
+
359
+ let cachedUint8ArrayMemory0 = null;
360
+ function getUint8ArrayMemory0() {
361
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
362
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
363
+ }
364
+ return cachedUint8ArrayMemory0;
365
+ }
366
+
367
+ function handleError(f, args) {
368
+ try {
369
+ return f.apply(this, args);
370
+ } catch (e) {
371
+ const idx = addToExternrefTable0(e);
372
+ wasm.__wbindgen_exn_store(idx);
373
+ }
374
+ }
375
+
376
+ function isLikeNone(x) {
377
+ return x === undefined || x === null;
378
+ }
379
+
380
+ function passStringToWasm0(arg, malloc, realloc) {
381
+ if (realloc === undefined) {
382
+ const buf = cachedTextEncoder.encode(arg);
383
+ const ptr = malloc(buf.length, 1) >>> 0;
384
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
385
+ WASM_VECTOR_LEN = buf.length;
386
+ return ptr;
387
+ }
388
+
389
+ let len = arg.length;
390
+ let ptr = malloc(len, 1) >>> 0;
391
+
392
+ const mem = getUint8ArrayMemory0();
393
+
394
+ let offset = 0;
395
+
396
+ for (; offset < len; offset++) {
397
+ const code = arg.charCodeAt(offset);
398
+ if (code > 0x7F) break;
399
+ mem[ptr + offset] = code;
400
+ }
401
+ if (offset !== len) {
402
+ if (offset !== 0) {
403
+ arg = arg.slice(offset);
404
+ }
405
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
406
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
407
+ const ret = cachedTextEncoder.encodeInto(arg, view);
408
+
409
+ offset += ret.written;
410
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
411
+ }
412
+
413
+ WASM_VECTOR_LEN = offset;
414
+ return ptr;
415
+ }
416
+
417
+ function takeFromExternrefTable0(idx) {
418
+ const value = wasm.__wbindgen_externrefs.get(idx);
419
+ wasm.__externref_table_dealloc(idx);
420
+ return value;
421
+ }
422
+
423
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
424
+ cachedTextDecoder.decode();
425
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
426
+ let numBytesDecoded = 0;
427
+ function decodeText(ptr, len) {
428
+ numBytesDecoded += len;
429
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
430
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
431
+ cachedTextDecoder.decode();
432
+ numBytesDecoded = len;
433
+ }
434
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
435
+ }
436
+
437
+ const cachedTextEncoder = new TextEncoder();
438
+
439
+ if (!('encodeInto' in cachedTextEncoder)) {
440
+ cachedTextEncoder.encodeInto = function (arg, view) {
441
+ const buf = cachedTextEncoder.encode(arg);
442
+ view.set(buf);
443
+ return {
444
+ read: arg.length,
445
+ written: buf.length
446
+ };
447
+ };
448
+ }
449
+
450
+ let WASM_VECTOR_LEN = 0;
451
+
452
+
453
+ let wasm;
454
+ export function __wbg_set_wasm(val) {
455
+ wasm = val;
456
+ }
@@ -0,0 +1,15 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const compute_provider_score_wasm: (a: any, b: any, c: any, d: bigint, e: any) => [number, number, number];
5
+ export const compute_recommendation_wasm: (a: number) => [number, number];
6
+ export const filter_providers_by_policy_wasm: (a: any, b: any, c: number, d: any, e: any) => [number, number, number];
7
+ export const init: () => void;
8
+ export const __wbindgen_malloc: (a: number, b: number) => number;
9
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
10
+ export const __wbindgen_exn_store: (a: number) => void;
11
+ export const __externref_table_alloc: () => number;
12
+ export const __wbindgen_externrefs: WebAssembly.Table;
13
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
14
+ export const __externref_table_dealloc: (a: number) => void;
15
+ export const __wbindgen_start: () => void;
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "provider-bond-wasm",
3
+ "collaborators": [
4
+ "Totem SDK Contributors"
5
+ ],
6
+ "description": "Provider bond computation layer — scoring engine, policy filtering, incident severity ranking, bond stack verification (Rust/WASM)",
7
+ "version": "0.1.0",
8
+ "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/totem-sdk/totem-sdk"
12
+ },
13
+ "files": [
14
+ "provider_bond_wasm_bg.wasm",
15
+ "provider_bond_wasm.js",
16
+ "provider_bond_wasm.d.ts"
17
+ ],
18
+ "main": "provider_bond_wasm.js",
19
+ "homepage": "https://totem.ing",
20
+ "types": "provider_bond_wasm.d.ts"
21
+ }
@@ -0,0 +1,10 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export function compute_provider_score_wasm(provider_js: any, probes_js: any, incidents_js: any, now: bigint, weights_js: any): any;
5
+
6
+ export function compute_recommendation_wasm(score: number): string;
7
+
8
+ export function filter_providers_by_policy_wasm(provider_js: any, policy_js: any, score_js: any | null | undefined, probes_js: any, incidents_js: any): any;
9
+
10
+ export function init(): void;
@@ -0,0 +1,465 @@
1
+ /* @ts-self-types="./provider_bond_wasm.d.ts" */
2
+
3
+ /**
4
+ * @param {any} provider_js
5
+ * @param {any} probes_js
6
+ * @param {any} incidents_js
7
+ * @param {bigint} now
8
+ * @param {any} weights_js
9
+ * @returns {any}
10
+ */
11
+ function compute_provider_score_wasm(provider_js, probes_js, incidents_js, now, weights_js) {
12
+ const ret = wasm.compute_provider_score_wasm(provider_js, probes_js, incidents_js, now, weights_js);
13
+ if (ret[2]) {
14
+ throw takeFromExternrefTable0(ret[1]);
15
+ }
16
+ return takeFromExternrefTable0(ret[0]);
17
+ }
18
+ exports.compute_provider_score_wasm = compute_provider_score_wasm;
19
+
20
+ /**
21
+ * @param {number} score
22
+ * @returns {string}
23
+ */
24
+ function compute_recommendation_wasm(score) {
25
+ let deferred1_0;
26
+ let deferred1_1;
27
+ try {
28
+ const ret = wasm.compute_recommendation_wasm(score);
29
+ deferred1_0 = ret[0];
30
+ deferred1_1 = ret[1];
31
+ return getStringFromWasm0(ret[0], ret[1]);
32
+ } finally {
33
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
34
+ }
35
+ }
36
+ exports.compute_recommendation_wasm = compute_recommendation_wasm;
37
+
38
+ /**
39
+ * @param {any} provider_js
40
+ * @param {any} policy_js
41
+ * @param {any | null | undefined} score_js
42
+ * @param {any} probes_js
43
+ * @param {any} incidents_js
44
+ * @returns {any}
45
+ */
46
+ function filter_providers_by_policy_wasm(provider_js, policy_js, score_js, probes_js, incidents_js) {
47
+ const ret = wasm.filter_providers_by_policy_wasm(provider_js, policy_js, isLikeNone(score_js) ? 0 : addToExternrefTable0(score_js), probes_js, incidents_js);
48
+ if (ret[2]) {
49
+ throw takeFromExternrefTable0(ret[1]);
50
+ }
51
+ return takeFromExternrefTable0(ret[0]);
52
+ }
53
+ exports.filter_providers_by_policy_wasm = filter_providers_by_policy_wasm;
54
+
55
+ function init() {
56
+ wasm.init();
57
+ }
58
+ exports.init = init;
59
+ function __wbg_get_imports() {
60
+ const import0 = {
61
+ __proto__: null,
62
+ __wbg_Error_92b29b0548f8b746: function(arg0, arg1) {
63
+ const ret = Error(getStringFromWasm0(arg0, arg1));
64
+ return ret;
65
+ },
66
+ __wbg_Number_9a4e0ecb0fa16705: function(arg0) {
67
+ const ret = Number(arg0);
68
+ return ret;
69
+ },
70
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
71
+ const ret = String(arg1);
72
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
73
+ const len1 = WASM_VECTOR_LEN;
74
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
75
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
76
+ },
77
+ __wbg___wbindgen_bigint_get_as_i64_d968e41184ae354f: function(arg0, arg1) {
78
+ const v = arg1;
79
+ const ret = typeof(v) === 'bigint' ? v : undefined;
80
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
81
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
82
+ },
83
+ __wbg___wbindgen_boolean_get_fa956cfa2d1bd751: function(arg0) {
84
+ const v = arg0;
85
+ const ret = typeof(v) === 'boolean' ? v : undefined;
86
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
87
+ },
88
+ __wbg___wbindgen_debug_string_c25d447a39f5578f: function(arg0, arg1) {
89
+ const ret = debugString(arg1);
90
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
91
+ const len1 = WASM_VECTOR_LEN;
92
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
93
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
94
+ },
95
+ __wbg___wbindgen_in_aca499c5de7ff5e5: function(arg0, arg1) {
96
+ const ret = arg0 in arg1;
97
+ return ret;
98
+ },
99
+ __wbg___wbindgen_is_bigint_2f76dc55065b4273: function(arg0) {
100
+ const ret = typeof(arg0) === 'bigint';
101
+ return ret;
102
+ },
103
+ __wbg___wbindgen_is_function_1ff95bcc5517c252: function(arg0) {
104
+ const ret = typeof(arg0) === 'function';
105
+ return ret;
106
+ },
107
+ __wbg___wbindgen_is_object_a27215656b807791: function(arg0) {
108
+ const val = arg0;
109
+ const ret = typeof(val) === 'object' && val !== null;
110
+ return ret;
111
+ },
112
+ __wbg___wbindgen_is_undefined_c05833b95a3cf397: function(arg0) {
113
+ const ret = arg0 === undefined;
114
+ return ret;
115
+ },
116
+ __wbg___wbindgen_jsval_eq_e659fcf7b0e32763: function(arg0, arg1) {
117
+ const ret = arg0 === arg1;
118
+ return ret;
119
+ },
120
+ __wbg___wbindgen_jsval_loose_eq_db4c3b15f63fc170: function(arg0, arg1) {
121
+ const ret = arg0 == arg1;
122
+ return ret;
123
+ },
124
+ __wbg___wbindgen_number_get_394265ed1e1b84ee: function(arg0, arg1) {
125
+ const obj = arg1;
126
+ const ret = typeof(obj) === 'number' ? obj : undefined;
127
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
128
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
129
+ },
130
+ __wbg___wbindgen_string_get_b0ca35b86a603356: function(arg0, arg1) {
131
+ const obj = arg1;
132
+ const ret = typeof(obj) === 'string' ? obj : undefined;
133
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
134
+ var len1 = WASM_VECTOR_LEN;
135
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
136
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
137
+ },
138
+ __wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
139
+ throw new Error(getStringFromWasm0(arg0, arg1));
140
+ },
141
+ __wbg_call_8a2dd23819f8a60a: function() { return handleError(function (arg0, arg1) {
142
+ const ret = arg0.call(arg1);
143
+ return ret;
144
+ }, arguments); },
145
+ __wbg_done_89b2b13e91a60321: function(arg0) {
146
+ const ret = arg0.done;
147
+ return ret;
148
+ },
149
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
150
+ let deferred0_0;
151
+ let deferred0_1;
152
+ try {
153
+ deferred0_0 = arg0;
154
+ deferred0_1 = arg1;
155
+ console.error(getStringFromWasm0(arg0, arg1));
156
+ } finally {
157
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
158
+ }
159
+ },
160
+ __wbg_get_c7eb1f358a7654df: function() { return handleError(function (arg0, arg1) {
161
+ const ret = Reflect.get(arg0, arg1);
162
+ return ret;
163
+ }, arguments); },
164
+ __wbg_get_unchecked_6e0ad6d2a41b06f6: function(arg0, arg1) {
165
+ const ret = arg0[arg1 >>> 0];
166
+ return ret;
167
+ },
168
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
169
+ const ret = arg0[arg1];
170
+ return ret;
171
+ },
172
+ __wbg_instanceof_ArrayBuffer_4480b9e0068a8adb: function(arg0) {
173
+ let result;
174
+ try {
175
+ result = arg0 instanceof ArrayBuffer;
176
+ } catch (_) {
177
+ result = false;
178
+ }
179
+ const ret = result;
180
+ return ret;
181
+ },
182
+ __wbg_instanceof_Uint8Array_309b927aaf7a3fc7: function(arg0) {
183
+ let result;
184
+ try {
185
+ result = arg0 instanceof Uint8Array;
186
+ } catch (_) {
187
+ result = false;
188
+ }
189
+ const ret = result;
190
+ return ret;
191
+ },
192
+ __wbg_isArray_0677c962b281d01a: function(arg0) {
193
+ const ret = Array.isArray(arg0);
194
+ return ret;
195
+ },
196
+ __wbg_isSafeInteger_04f36e4056f1b851: function(arg0) {
197
+ const ret = Number.isSafeInteger(arg0);
198
+ return ret;
199
+ },
200
+ __wbg_iterator_6f722e4a93058b71: function() {
201
+ const ret = Symbol.iterator;
202
+ return ret;
203
+ },
204
+ __wbg_length_1f0964f4a5e2c6d8: function(arg0) {
205
+ const ret = arg0.length;
206
+ return ret;
207
+ },
208
+ __wbg_length_370319915dc99107: function(arg0) {
209
+ const ret = arg0.length;
210
+ return ret;
211
+ },
212
+ __wbg_new_227d7c05414eb861: function() {
213
+ const ret = new Error();
214
+ return ret;
215
+ },
216
+ __wbg_new_32b398fb48b6d94a: function() {
217
+ const ret = new Array();
218
+ return ret;
219
+ },
220
+ __wbg_new_cd45aabdf6073e84: function(arg0) {
221
+ const ret = new Uint8Array(arg0);
222
+ return ret;
223
+ },
224
+ __wbg_new_da52cf8fe3429cb2: function() {
225
+ const ret = new Object();
226
+ return ret;
227
+ },
228
+ __wbg_next_6dbf2c0ac8cde20f: function(arg0) {
229
+ const ret = arg0.next;
230
+ return ret;
231
+ },
232
+ __wbg_next_71f2aa1cb3d1e37e: function() { return handleError(function (arg0) {
233
+ const ret = arg0.next();
234
+ return ret;
235
+ }, arguments); },
236
+ __wbg_prototypesetcall_4770620bbe4688a0: function(arg0, arg1, arg2) {
237
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
238
+ },
239
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
240
+ arg0[arg1] = arg2;
241
+ },
242
+ __wbg_set_8a16b38e4805b298: function(arg0, arg1, arg2) {
243
+ arg0[arg1 >>> 0] = arg2;
244
+ },
245
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
246
+ const ret = arg1.stack;
247
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
248
+ const len1 = WASM_VECTOR_LEN;
249
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
250
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
251
+ },
252
+ __wbg_value_a5d5488a9589444a: function(arg0) {
253
+ const ret = arg0.value;
254
+ return ret;
255
+ },
256
+ __wbindgen_cast_0000000000000001: function(arg0) {
257
+ // Cast intrinsic for `F64 -> Externref`.
258
+ const ret = arg0;
259
+ return ret;
260
+ },
261
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
262
+ // Cast intrinsic for `Ref(String) -> Externref`.
263
+ const ret = getStringFromWasm0(arg0, arg1);
264
+ return ret;
265
+ },
266
+ __wbindgen_cast_0000000000000003: function(arg0) {
267
+ // Cast intrinsic for `U64 -> Externref`.
268
+ const ret = BigInt.asUintN(64, arg0);
269
+ return ret;
270
+ },
271
+ __wbindgen_init_externref_table: function() {
272
+ const table = wasm.__wbindgen_externrefs;
273
+ const offset = table.grow(4);
274
+ table.set(0, undefined);
275
+ table.set(offset + 0, undefined);
276
+ table.set(offset + 1, null);
277
+ table.set(offset + 2, true);
278
+ table.set(offset + 3, false);
279
+ },
280
+ };
281
+ return {
282
+ __proto__: null,
283
+ "./provider_bond_wasm_bg.js": import0,
284
+ };
285
+ }
286
+
287
+ function addToExternrefTable0(obj) {
288
+ const idx = wasm.__externref_table_alloc();
289
+ wasm.__wbindgen_externrefs.set(idx, obj);
290
+ return idx;
291
+ }
292
+
293
+ function debugString(val) {
294
+ // primitive types
295
+ const type = typeof val;
296
+ if (type == 'number' || type == 'boolean' || val == null) {
297
+ return `${val}`;
298
+ }
299
+ if (type == 'string') {
300
+ return `"${val}"`;
301
+ }
302
+ if (type == 'symbol') {
303
+ const description = val.description;
304
+ if (description == null) {
305
+ return 'Symbol';
306
+ } else {
307
+ return `Symbol(${description})`;
308
+ }
309
+ }
310
+ if (type == 'function') {
311
+ const name = val.name;
312
+ if (typeof name == 'string' && name.length > 0) {
313
+ return `Function(${name})`;
314
+ } else {
315
+ return 'Function';
316
+ }
317
+ }
318
+ // objects
319
+ if (Array.isArray(val)) {
320
+ const length = val.length;
321
+ let debug = '[';
322
+ if (length > 0) {
323
+ debug += debugString(val[0]);
324
+ }
325
+ for(let i = 1; i < length; i++) {
326
+ debug += ', ' + debugString(val[i]);
327
+ }
328
+ debug += ']';
329
+ return debug;
330
+ }
331
+ // Test for built-in
332
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
333
+ let className;
334
+ if (builtInMatches && builtInMatches.length > 1) {
335
+ className = builtInMatches[1];
336
+ } else {
337
+ // Failed to match the standard '[object ClassName]'
338
+ return toString.call(val);
339
+ }
340
+ if (className == 'Object') {
341
+ // we're a user defined class or Object
342
+ // JSON.stringify avoids problems with cycles, and is generally much
343
+ // easier than looping through ownProperties of `val`.
344
+ try {
345
+ return 'Object(' + JSON.stringify(val) + ')';
346
+ } catch (_) {
347
+ return 'Object';
348
+ }
349
+ }
350
+ // errors
351
+ if (val instanceof Error) {
352
+ return `${val.name}: ${val.message}\n${val.stack}`;
353
+ }
354
+ // TODO we could test for more things here, like `Set`s and `Map`s.
355
+ return className;
356
+ }
357
+
358
+ function getArrayU8FromWasm0(ptr, len) {
359
+ ptr = ptr >>> 0;
360
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
361
+ }
362
+
363
+ let cachedDataViewMemory0 = null;
364
+ function getDataViewMemory0() {
365
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
366
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
367
+ }
368
+ return cachedDataViewMemory0;
369
+ }
370
+
371
+ function getStringFromWasm0(ptr, len) {
372
+ return decodeText(ptr >>> 0, len);
373
+ }
374
+
375
+ let cachedUint8ArrayMemory0 = null;
376
+ function getUint8ArrayMemory0() {
377
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
378
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
379
+ }
380
+ return cachedUint8ArrayMemory0;
381
+ }
382
+
383
+ function handleError(f, args) {
384
+ try {
385
+ return f.apply(this, args);
386
+ } catch (e) {
387
+ const idx = addToExternrefTable0(e);
388
+ wasm.__wbindgen_exn_store(idx);
389
+ }
390
+ }
391
+
392
+ function isLikeNone(x) {
393
+ return x === undefined || x === null;
394
+ }
395
+
396
+ function passStringToWasm0(arg, malloc, realloc) {
397
+ if (realloc === undefined) {
398
+ const buf = cachedTextEncoder.encode(arg);
399
+ const ptr = malloc(buf.length, 1) >>> 0;
400
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
401
+ WASM_VECTOR_LEN = buf.length;
402
+ return ptr;
403
+ }
404
+
405
+ let len = arg.length;
406
+ let ptr = malloc(len, 1) >>> 0;
407
+
408
+ const mem = getUint8ArrayMemory0();
409
+
410
+ let offset = 0;
411
+
412
+ for (; offset < len; offset++) {
413
+ const code = arg.charCodeAt(offset);
414
+ if (code > 0x7F) break;
415
+ mem[ptr + offset] = code;
416
+ }
417
+ if (offset !== len) {
418
+ if (offset !== 0) {
419
+ arg = arg.slice(offset);
420
+ }
421
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
422
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
423
+ const ret = cachedTextEncoder.encodeInto(arg, view);
424
+
425
+ offset += ret.written;
426
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
427
+ }
428
+
429
+ WASM_VECTOR_LEN = offset;
430
+ return ptr;
431
+ }
432
+
433
+ function takeFromExternrefTable0(idx) {
434
+ const value = wasm.__wbindgen_externrefs.get(idx);
435
+ wasm.__externref_table_dealloc(idx);
436
+ return value;
437
+ }
438
+
439
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
440
+ cachedTextDecoder.decode();
441
+ function decodeText(ptr, len) {
442
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
443
+ }
444
+
445
+ const cachedTextEncoder = new TextEncoder();
446
+
447
+ if (!('encodeInto' in cachedTextEncoder)) {
448
+ cachedTextEncoder.encodeInto = function (arg, view) {
449
+ const buf = cachedTextEncoder.encode(arg);
450
+ view.set(buf);
451
+ return {
452
+ read: arg.length,
453
+ written: buf.length
454
+ };
455
+ };
456
+ }
457
+
458
+ let WASM_VECTOR_LEN = 0;
459
+
460
+ const wasmPath = `${__dirname}/provider_bond_wasm_bg.wasm`;
461
+ const wasmBytes = require('fs').readFileSync(wasmPath);
462
+ const wasmModule = new WebAssembly.Module(wasmBytes);
463
+ let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
464
+ let wasm = wasmInstance.exports;
465
+ wasm.__wbindgen_start();
@@ -0,0 +1,15 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const compute_provider_score_wasm: (a: any, b: any, c: any, d: bigint, e: any) => [number, number, number];
5
+ export const compute_recommendation_wasm: (a: number) => [number, number];
6
+ export const filter_providers_by_policy_wasm: (a: any, b: any, c: number, d: any, e: any) => [number, number, number];
7
+ export const init: () => void;
8
+ export const __wbindgen_malloc: (a: number, b: number) => number;
9
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
10
+ export const __wbindgen_exn_store: (a: number) => void;
11
+ export const __externref_table_alloc: () => number;
12
+ export const __wbindgen_externrefs: WebAssembly.Table;
13
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
14
+ export const __externref_table_dealloc: (a: number) => void;
15
+ export const __wbindgen_start: () => void;