@provex/utils 1.2.3 → 1.2.4
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/package.json +51 -51
- package/dist/scripts/convert-svg.d.ts +0 -1
- package/dist/scripts/convert-svg.js +0 -17
- package/dist/src/endpoints.d.ts +0 -51
- package/dist/src/endpoints.js +0 -70
- package/dist/src/endpoints.test.d.ts +0 -1
- package/dist/src/endpoints.test.js +0 -54
- package/dist/src/normalization.d.ts +0 -224
- package/dist/src/normalization.js +0 -119
- package/dist/src/normalization.test.d.ts +0 -1
- package/dist/src/normalization.test.js +0 -284
- package/dist/src/zkp2p-types.d.ts +0 -317
- package/dist/src/zkp2p-types.js +0 -169
- package/dist/tsconfig.tsbuildinfo +0 -1
- /package/dist/{src/chain.d.ts → chain.d.ts} +0 -0
- /package/dist/{src/chain.js → chain.js} +0 -0
- /package/dist/{src/chain.test.d.ts → chain.test.d.ts} +0 -0
- /package/dist/{src/chain.test.js → chain.test.js} +0 -0
- /package/dist/{src/contracts.d.ts → contracts.d.ts} +0 -0
- /package/dist/{src/contracts.js → contracts.js} +0 -0
- /package/dist/{src/contracts.test.d.ts → contracts.test.d.ts} +0 -0
- /package/dist/{src/contracts.test.js → contracts.test.js} +0 -0
- /package/dist/{src/conversionRates.d.ts → conversionRates.d.ts} +0 -0
- /package/dist/{src/conversionRates.js → conversionRates.js} +0 -0
- /package/dist/{src/conversionRates.test.d.ts → conversionRates.test.d.ts} +0 -0
- /package/dist/{src/conversionRates.test.js → conversionRates.test.js} +0 -0
- /package/dist/{src/currencies.d.ts → currencies.d.ts} +0 -0
- /package/dist/{src/currencies.js → currencies.js} +0 -0
- /package/dist/{src/currencies.test.d.ts → currencies.test.d.ts} +0 -0
- /package/dist/{src/currencies.test.js → currencies.test.js} +0 -0
- /package/dist/{src/data → data}/countries.json +0 -0
- /package/dist/{src/deposit.d.ts → deposit.d.ts} +0 -0
- /package/dist/{src/deposit.js → deposit.js} +0 -0
- /package/dist/{src/depositKeys.d.ts → depositKeys.d.ts} +0 -0
- /package/dist/{src/depositKeys.js → depositKeys.js} +0 -0
- /package/dist/{src/depositKeys.test.d.ts → depositKeys.test.d.ts} +0 -0
- /package/dist/{src/depositKeys.test.js → depositKeys.test.js} +0 -0
- /package/dist/{src/events.d.ts → events.d.ts} +0 -0
- /package/dist/{src/events.js → events.js} +0 -0
- /package/dist/{src/events.test.d.ts → events.test.d.ts} +0 -0
- /package/dist/{src/events.test.js → events.test.js} +0 -0
- /package/dist/{src/fees.d.ts → fees.d.ts} +0 -0
- /package/dist/{src/fees.js → fees.js} +0 -0
- /package/dist/{src/fees.test.d.ts → fees.test.d.ts} +0 -0
- /package/dist/{src/fees.test.js → fees.test.js} +0 -0
- /package/dist/{src/flags.d.ts → flags.d.ts} +0 -0
- /package/dist/{src/flags.js → flags.js} +0 -0
- /package/dist/{src/ids.d.ts → ids.d.ts} +0 -0
- /package/dist/{src/ids.js → ids.js} +0 -0
- /package/dist/{src/ids.test.d.ts → ids.test.d.ts} +0 -0
- /package/dist/{src/ids.test.js → ids.test.js} +0 -0
- /package/dist/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{src/index.js → index.js} +0 -0
- /package/dist/{src/input.d.ts → input.d.ts} +0 -0
- /package/dist/{src/input.js → input.js} +0 -0
- /package/dist/{src/intent.d.ts → intent.d.ts} +0 -0
- /package/dist/{src/intent.js → intent.js} +0 -0
- /package/dist/{src/intent.test.d.ts → intent.test.d.ts} +0 -0
- /package/dist/{src/intent.test.js → intent.test.js} +0 -0
- /package/dist/{src/json.d.ts → json.d.ts} +0 -0
- /package/dist/{src/json.js → json.js} +0 -0
- /package/dist/{src/participants.d.ts → participants.d.ts} +0 -0
- /package/dist/{src/participants.js → participants.js} +0 -0
- /package/dist/{src/payment.d.ts → payment.d.ts} +0 -0
- /package/dist/{src/payment.js → payment.js} +0 -0
- /package/dist/{src/payment.test.d.ts → payment.test.d.ts} +0 -0
- /package/dist/{src/payment.test.js → payment.test.js} +0 -0
- /package/dist/{src/peer-types.d.ts → peer-types.d.ts} +0 -0
- /package/dist/{src/peer-types.js → peer-types.js} +0 -0
- /package/dist/{src/profit.d.ts → profit.d.ts} +0 -0
- /package/dist/{src/profit.js → profit.js} +0 -0
- /package/dist/{src/profit.test.d.ts → profit.test.d.ts} +0 -0
- /package/dist/{src/profit.test.js → profit.test.js} +0 -0
- /package/dist/{src/reputation.d.ts → reputation.d.ts} +0 -0
- /package/dist/{src/reputation.js → reputation.js} +0 -0
- /package/dist/{src/reputation.test.d.ts → reputation.test.d.ts} +0 -0
- /package/dist/{src/reputation.test.js → reputation.test.js} +0 -0
- /package/dist/{src/sort.d.ts → sort.d.ts} +0 -0
- /package/dist/{src/sort.js → sort.js} +0 -0
- /package/dist/{src/sort.test.d.ts → sort.test.d.ts} +0 -0
- /package/dist/{src/sort.test.js → sort.test.js} +0 -0
- /package/dist/{src/stateKey.d.ts → stateKey.d.ts} +0 -0
- /package/dist/{src/stateKey.js → stateKey.js} +0 -0
- /package/dist/{src/stats.d.ts → stats.d.ts} +0 -0
- /package/dist/{src/stats.js → stats.js} +0 -0
- /package/dist/{src/stats.test.d.ts → stats.test.d.ts} +0 -0
- /package/dist/{src/stats.test.js → stats.test.js} +0 -0
- /package/dist/{src/time.d.ts → time.d.ts} +0 -0
- /package/dist/{src/time.js → time.js} +0 -0
- /package/dist/{src/time.test.d.ts → time.test.d.ts} +0 -0
- /package/dist/{src/time.test.js → time.test.js} +0 -0
- /package/dist/{src/tokens.d.ts → tokens.d.ts} +0 -0
- /package/dist/{src/tokens.js → tokens.js} +0 -0
- /package/dist/{src/tokens.test.d.ts → tokens.test.d.ts} +0 -0
- /package/dist/{src/tokens.test.js → tokens.test.js} +0 -0
- /package/dist/{src/units.d.ts → units.d.ts} +0 -0
- /package/dist/{src/units.js → units.js} +0 -0
- /package/dist/{src/units.test.d.ts → units.test.d.ts} +0 -0
- /package/dist/{src/units.test.js → units.test.js} +0 -0
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@provex/utils",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"main": "dist/
|
|
5
|
-
"types": "dist/
|
|
3
|
+
"version": "1.2.4",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -14,100 +14,100 @@
|
|
|
14
14
|
},
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
|
-
"import": "./dist/
|
|
18
|
-
"types": "./dist/
|
|
17
|
+
"import": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts"
|
|
19
19
|
},
|
|
20
20
|
"./contracts": {
|
|
21
|
-
"import": "./dist/
|
|
22
|
-
"types": "./dist/
|
|
21
|
+
"import": "./dist/contracts.js",
|
|
22
|
+
"types": "./dist/contracts.d.ts"
|
|
23
23
|
},
|
|
24
24
|
"./currencies": {
|
|
25
|
-
"import": "./dist/
|
|
26
|
-
"types": "./dist/
|
|
25
|
+
"import": "./dist/currencies.js",
|
|
26
|
+
"types": "./dist/currencies.d.ts"
|
|
27
27
|
},
|
|
28
28
|
"./units": {
|
|
29
|
-
"import": "./dist/
|
|
30
|
-
"types": "./dist/
|
|
29
|
+
"import": "./dist/units.js",
|
|
30
|
+
"types": "./dist/units.d.ts"
|
|
31
31
|
},
|
|
32
32
|
"./payment": {
|
|
33
|
-
"import": "./dist/
|
|
34
|
-
"types": "./dist/
|
|
33
|
+
"import": "./dist/payment.js",
|
|
34
|
+
"types": "./dist/payment.d.ts"
|
|
35
35
|
},
|
|
36
36
|
"./sort": {
|
|
37
|
-
"import": "./dist/
|
|
38
|
-
"types": "./dist/
|
|
37
|
+
"import": "./dist/sort.js",
|
|
38
|
+
"types": "./dist/sort.d.ts"
|
|
39
39
|
},
|
|
40
40
|
"./time": {
|
|
41
|
-
"import": "./dist/
|
|
42
|
-
"types": "./dist/
|
|
41
|
+
"import": "./dist/time.js",
|
|
42
|
+
"types": "./dist/time.d.ts"
|
|
43
43
|
},
|
|
44
44
|
"./tokens": {
|
|
45
|
-
"import": "./dist/
|
|
46
|
-
"types": "./dist/
|
|
45
|
+
"import": "./dist/tokens.js",
|
|
46
|
+
"types": "./dist/tokens.d.ts"
|
|
47
47
|
},
|
|
48
48
|
"./intent": {
|
|
49
|
-
"import": "./dist/
|
|
50
|
-
"types": "./dist/
|
|
49
|
+
"import": "./dist/intent.js",
|
|
50
|
+
"types": "./dist/intent.d.ts"
|
|
51
51
|
},
|
|
52
52
|
"./conversionRates": {
|
|
53
|
-
"import": "./dist/
|
|
54
|
-
"types": "./dist/
|
|
53
|
+
"import": "./dist/conversionRates.js",
|
|
54
|
+
"types": "./dist/conversionRates.d.ts"
|
|
55
55
|
},
|
|
56
56
|
"./json": {
|
|
57
|
-
"import": "./dist/
|
|
58
|
-
"types": "./dist/
|
|
57
|
+
"import": "./dist/json.js",
|
|
58
|
+
"types": "./dist/json.d.ts"
|
|
59
59
|
},
|
|
60
60
|
"./profit": {
|
|
61
|
-
"import": "./dist/
|
|
62
|
-
"types": "./dist/
|
|
61
|
+
"import": "./dist/profit.js",
|
|
62
|
+
"types": "./dist/profit.d.ts"
|
|
63
63
|
},
|
|
64
64
|
"./chain": {
|
|
65
|
-
"import": "./dist/
|
|
66
|
-
"types": "./dist/
|
|
65
|
+
"import": "./dist/chain.js",
|
|
66
|
+
"types": "./dist/chain.d.ts"
|
|
67
67
|
},
|
|
68
68
|
"./participants": {
|
|
69
|
-
"import": "./dist/
|
|
70
|
-
"types": "./dist/
|
|
69
|
+
"import": "./dist/participants.js",
|
|
70
|
+
"types": "./dist/participants.d.ts"
|
|
71
71
|
},
|
|
72
72
|
"./input": {
|
|
73
|
-
"import": "./dist/
|
|
74
|
-
"types": "./dist/
|
|
73
|
+
"import": "./dist/input.js",
|
|
74
|
+
"types": "./dist/input.d.ts"
|
|
75
75
|
},
|
|
76
76
|
"./stats": {
|
|
77
|
-
"import": "./dist/
|
|
78
|
-
"types": "./dist/
|
|
77
|
+
"import": "./dist/stats.js",
|
|
78
|
+
"types": "./dist/stats.d.ts"
|
|
79
79
|
},
|
|
80
80
|
"./stateKey": {
|
|
81
|
-
"import": "./dist/
|
|
82
|
-
"types": "./dist/
|
|
81
|
+
"import": "./dist/stateKey.js",
|
|
82
|
+
"types": "./dist/stateKey.d.ts"
|
|
83
83
|
},
|
|
84
84
|
"./ids": {
|
|
85
|
-
"import": "./dist/
|
|
86
|
-
"types": "./dist/
|
|
85
|
+
"import": "./dist/ids.js",
|
|
86
|
+
"types": "./dist/ids.d.ts"
|
|
87
87
|
},
|
|
88
88
|
"./events": {
|
|
89
|
-
"import": "./dist/
|
|
90
|
-
"types": "./dist/
|
|
89
|
+
"import": "./dist/events.js",
|
|
90
|
+
"types": "./dist/events.d.ts"
|
|
91
91
|
},
|
|
92
92
|
"./peer-types": {
|
|
93
|
-
"import": "./dist/
|
|
94
|
-
"types": "./dist/
|
|
93
|
+
"import": "./dist/peer-types.js",
|
|
94
|
+
"types": "./dist/peer-types.d.ts"
|
|
95
95
|
},
|
|
96
96
|
"./deposit": {
|
|
97
|
-
"import": "./dist/
|
|
98
|
-
"types": "./dist/
|
|
97
|
+
"import": "./dist/deposit.js",
|
|
98
|
+
"types": "./dist/deposit.d.ts"
|
|
99
99
|
},
|
|
100
100
|
"./fees": {
|
|
101
|
-
"import": "./dist/
|
|
102
|
-
"types": "./dist/
|
|
101
|
+
"import": "./dist/fees.js",
|
|
102
|
+
"types": "./dist/fees.d.ts"
|
|
103
103
|
},
|
|
104
104
|
"./reputation": {
|
|
105
|
-
"import": "./dist/
|
|
106
|
-
"types": "./dist/
|
|
105
|
+
"import": "./dist/reputation.js",
|
|
106
|
+
"types": "./dist/reputation.d.ts"
|
|
107
107
|
}
|
|
108
108
|
},
|
|
109
109
|
"scripts": {
|
|
110
|
-
"build": "tsx scripts/convert-svg && tsc && cp -r src/data dist/
|
|
110
|
+
"build": "tsx scripts/convert-svg && tsc && cp -r src/data dist/",
|
|
111
111
|
"test": "node --import tsx --test 'src/**/*.test.ts'",
|
|
112
112
|
"test:watch": "node --import tsx --test --watch 'src/**/*.test.ts'",
|
|
113
113
|
"test:coverage": "node --import tsx --test --experimental-test-coverage --test-coverage-exclude='src/**/*.test.ts' --test-coverage-exclude='src/data/**' --test-coverage-exclude='src/flags/**' --test-coverage-exclude='src/flags.ts' --test-coverage-exclude='src/global.d.ts' 'src/**/*.test.ts'"
|
|
@@ -132,4 +132,4 @@
|
|
|
132
132
|
"typescript": "^5.9.2",
|
|
133
133
|
"viem": "^2.38.0"
|
|
134
134
|
}
|
|
135
|
-
}
|
|
135
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
const __dirname = import.meta.dirname;
|
|
4
|
-
// Read SVG files and convert to TypeScript constants
|
|
5
|
-
const svgDir = path.join(__dirname, '../src/flags');
|
|
6
|
-
const outputFile = path.join(__dirname, '../src/flags.ts');
|
|
7
|
-
const svgFiles = ['usd.svg', 'eur.svg'];
|
|
8
|
-
let output = '// Auto-generated from SVG files\n\n';
|
|
9
|
-
svgFiles.forEach(filename => {
|
|
10
|
-
const svgPath = path.join(svgDir, filename);
|
|
11
|
-
const svgContent = fs.readFileSync(svgPath, 'utf8');
|
|
12
|
-
const cleanSvg = svgContent.replace(/[\r\n]/g, ' ').replace(/\s+/g, ' ').trim();
|
|
13
|
-
const constName = filename.replace('.svg', '').toUpperCase() + '_FLAG_SVG';
|
|
14
|
-
output += `export const ${constName} = '${cleanSvg}';\n`;
|
|
15
|
-
});
|
|
16
|
-
fs.writeFileSync(outputFile, output);
|
|
17
|
-
console.log('Generated flags.ts from SVG files');
|
package/dist/src/endpoints.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Service endpoint URLs for the Provex platform.
|
|
3
|
-
*
|
|
4
|
-
* Each URL resolves at module load time using this priority:
|
|
5
|
-
* 1. Vite env (`import.meta.env.VITE_<NAME>`)
|
|
6
|
-
* 2. Node env (`process.env.<NAME>` or `process.env.VITE_<NAME>`)
|
|
7
|
-
* 3. Hardcoded production default
|
|
8
|
-
*
|
|
9
|
-
* Override any URL by setting the corresponding environment variable
|
|
10
|
-
* before the module is imported.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* // In .env or shell
|
|
14
|
-
* VITE_SPONSOR_SERVER_URL=http://localhost:3001
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* Base URL for the gas-sponsorship relay server.
|
|
18
|
-
*
|
|
19
|
-
* The sponsor server wraps user operations in a sponsored transaction
|
|
20
|
-
* so end-users never need native gas tokens.
|
|
21
|
-
*
|
|
22
|
-
* @defaultValue `https://sponsor.provex.xyz`
|
|
23
|
-
*/
|
|
24
|
-
export declare const SPONSOR_SERVER_URL: string;
|
|
25
|
-
/**
|
|
26
|
-
* WebSocket URL for the Reclaim Protocol attestor node.
|
|
27
|
-
*
|
|
28
|
-
* Used during the ZK proof generation flow to obtain a TLS attestation
|
|
29
|
-
* of payment-provider API responses.
|
|
30
|
-
*
|
|
31
|
-
* @defaultValue `wss://attestor.reclaimprotocol.org/ws`
|
|
32
|
-
*/
|
|
33
|
-
export declare const ATTESTOR_WS_URL: string;
|
|
34
|
-
/**
|
|
35
|
-
* GraphQL endpoint for the Provex indexer.
|
|
36
|
-
*
|
|
37
|
-
* Serves deposit listings, intent history, and on-chain event data
|
|
38
|
-
* consumed by the UI and analytics dashboard.
|
|
39
|
-
*
|
|
40
|
-
* @defaultValue `https://indexer.provex.xyz/graphql`
|
|
41
|
-
*/
|
|
42
|
-
export declare const INDEXER_GRAPHQL_URL: string;
|
|
43
|
-
/**
|
|
44
|
-
* Base URL for the attestation verification service.
|
|
45
|
-
*
|
|
46
|
-
* Validates TLS attestations produced by the attestor before they
|
|
47
|
-
* are submitted on-chain as proof of payment.
|
|
48
|
-
*
|
|
49
|
-
* @defaultValue `https://attestation.provex.xyz`
|
|
50
|
-
*/
|
|
51
|
-
export declare const ATTESTATION_SERVICE_URL: string;
|
package/dist/src/endpoints.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Service endpoint URLs for the Provex platform.
|
|
3
|
-
*
|
|
4
|
-
* Each URL resolves at module load time using this priority:
|
|
5
|
-
* 1. Vite env (`import.meta.env.VITE_<NAME>`)
|
|
6
|
-
* 2. Node env (`process.env.<NAME>` or `process.env.VITE_<NAME>`)
|
|
7
|
-
* 3. Hardcoded production default
|
|
8
|
-
*
|
|
9
|
-
* Override any URL by setting the corresponding environment variable
|
|
10
|
-
* before the module is imported.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* // In .env or shell
|
|
14
|
-
* VITE_SPONSOR_SERVER_URL=http://localhost:3001
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* Read an environment variable from either Vite or Node runtime.
|
|
18
|
-
*
|
|
19
|
-
* Checks `import.meta.env.VITE_<name>` first (browser / Vite dev server),
|
|
20
|
-
* then falls back to `process.env.<name>` and `process.env.VITE_<name>`
|
|
21
|
-
* (Node / scripts).
|
|
22
|
-
*
|
|
23
|
-
* @param name - The bare variable name without the `VITE_` prefix.
|
|
24
|
-
* @returns The value if found, otherwise `undefined`.
|
|
25
|
-
*/
|
|
26
|
-
function readEnv(name) {
|
|
27
|
-
const viteVal = typeof import.meta !== 'undefined'
|
|
28
|
-
? import.meta.env?.[`VITE_${name}`]
|
|
29
|
-
: undefined;
|
|
30
|
-
const nodeVal = typeof process !== 'undefined'
|
|
31
|
-
? (process.env?.[name] ?? process.env?.[`VITE_${name}`])
|
|
32
|
-
: undefined;
|
|
33
|
-
return viteVal ?? nodeVal ?? undefined;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Base URL for the gas-sponsorship relay server.
|
|
37
|
-
*
|
|
38
|
-
* The sponsor server wraps user operations in a sponsored transaction
|
|
39
|
-
* so end-users never need native gas tokens.
|
|
40
|
-
*
|
|
41
|
-
* @defaultValue `https://sponsor.provex.xyz`
|
|
42
|
-
*/
|
|
43
|
-
export const SPONSOR_SERVER_URL = readEnv('SPONSOR_SERVER_URL') ?? 'https://sponsor.provex.xyz';
|
|
44
|
-
/**
|
|
45
|
-
* WebSocket URL for the Reclaim Protocol attestor node.
|
|
46
|
-
*
|
|
47
|
-
* Used during the ZK proof generation flow to obtain a TLS attestation
|
|
48
|
-
* of payment-provider API responses.
|
|
49
|
-
*
|
|
50
|
-
* @defaultValue `wss://attestor.reclaimprotocol.org/ws`
|
|
51
|
-
*/
|
|
52
|
-
export const ATTESTOR_WS_URL = readEnv('ATTESTOR_WS_URL') ?? 'wss://attestor.reclaimprotocol.org/ws';
|
|
53
|
-
/**
|
|
54
|
-
* GraphQL endpoint for the Provex indexer.
|
|
55
|
-
*
|
|
56
|
-
* Serves deposit listings, intent history, and on-chain event data
|
|
57
|
-
* consumed by the UI and analytics dashboard.
|
|
58
|
-
*
|
|
59
|
-
* @defaultValue `https://indexer.provex.xyz/graphql`
|
|
60
|
-
*/
|
|
61
|
-
export const INDEXER_GRAPHQL_URL = readEnv('INDEXER_GRAPHQL_URL') ?? 'https://indexer.provex.xyz/graphql';
|
|
62
|
-
/**
|
|
63
|
-
* Base URL for the attestation verification service.
|
|
64
|
-
*
|
|
65
|
-
* Validates TLS attestations produced by the attestor before they
|
|
66
|
-
* are submitted on-chain as proof of payment.
|
|
67
|
-
*
|
|
68
|
-
* @defaultValue `https://attestation.provex.xyz`
|
|
69
|
-
*/
|
|
70
|
-
export const ATTESTATION_SERVICE_URL = readEnv('ATTESTATION_SERVICE_URL') ?? 'https://attestation.provex.xyz';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { describe, it } from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import { SPONSOR_SERVER_URL, ATTESTOR_WS_URL, INDEXER_GRAPHQL_URL, ATTESTATION_SERVICE_URL, } from './endpoints.js';
|
|
4
|
-
describe('endpoints', () => {
|
|
5
|
-
const endpoints = [
|
|
6
|
-
{ name: 'SPONSOR_SERVER_URL', value: SPONSOR_SERVER_URL },
|
|
7
|
-
{ name: 'ATTESTOR_WS_URL', value: ATTESTOR_WS_URL },
|
|
8
|
-
{ name: 'INDEXER_GRAPHQL_URL', value: INDEXER_GRAPHQL_URL },
|
|
9
|
-
{ name: 'ATTESTATION_SERVICE_URL', value: ATTESTATION_SERVICE_URL },
|
|
10
|
-
];
|
|
11
|
-
for (const { name, value } of endpoints) {
|
|
12
|
-
describe(name, () => {
|
|
13
|
-
it('should be a non-empty string', () => {
|
|
14
|
-
assert.ok(typeof value === 'string', `${name} should be a string`);
|
|
15
|
-
assert.ok(value.length > 0, `${name} should not be empty`);
|
|
16
|
-
});
|
|
17
|
-
it('should start with https:// or wss://', () => {
|
|
18
|
-
assert.ok(value.startsWith('https://') || value.startsWith('wss://'), `${name} should start with https:// or wss://, got: ${value}`);
|
|
19
|
-
});
|
|
20
|
-
it('should not have a trailing slash', () => {
|
|
21
|
-
assert.ok(!value.endsWith('/'), `${name} should not end with a trailing slash, got: ${value}`);
|
|
22
|
-
});
|
|
23
|
-
it('should not contain whitespace', () => {
|
|
24
|
-
assert.equal(value, value.trim(), `${name} should not have leading/trailing whitespace`);
|
|
25
|
-
assert.ok(!/\s/.test(value), `${name} should not contain whitespace`);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
describe('default values', () => {
|
|
30
|
-
it('SPONSOR_SERVER_URL defaults to production', () => {
|
|
31
|
-
assert.equal(SPONSOR_SERVER_URL, 'https://sponsor.provex.xyz');
|
|
32
|
-
});
|
|
33
|
-
it('ATTESTOR_WS_URL defaults to Reclaim attestor', () => {
|
|
34
|
-
assert.equal(ATTESTOR_WS_URL, 'wss://attestor.reclaimprotocol.org/ws');
|
|
35
|
-
});
|
|
36
|
-
it('INDEXER_GRAPHQL_URL defaults to production GraphQL', () => {
|
|
37
|
-
assert.equal(INDEXER_GRAPHQL_URL, 'https://indexer.provex.xyz/graphql');
|
|
38
|
-
});
|
|
39
|
-
it('ATTESTATION_SERVICE_URL defaults to production', () => {
|
|
40
|
-
assert.equal(ATTESTATION_SERVICE_URL, 'https://attestation.provex.xyz');
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
describe('protocol expectations', () => {
|
|
44
|
-
it('ATTESTOR_WS_URL uses wss:// protocol', () => {
|
|
45
|
-
assert.ok(ATTESTOR_WS_URL.startsWith('wss://'), 'WebSocket URL should use wss://');
|
|
46
|
-
});
|
|
47
|
-
it('HTTPS endpoints use https:// protocol', () => {
|
|
48
|
-
const httpsEndpoints = [SPONSOR_SERVER_URL, INDEXER_GRAPHQL_URL, ATTESTATION_SERVICE_URL];
|
|
49
|
-
for (const url of httpsEndpoints) {
|
|
50
|
-
assert.ok(url.startsWith('https://'), `Expected https://, got: ${url}`);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
});
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import type { Hex } from 'viem';
|
|
2
|
-
import type { Version } from './contracts.js';
|
|
3
|
-
/**
|
|
4
|
-
* V2 Deposit structure as stored in the database.
|
|
5
|
-
* This represents the raw v2 deposit data from the indexer.
|
|
6
|
-
*/
|
|
7
|
-
export type V2DepositData = {
|
|
8
|
-
escrow: Hex;
|
|
9
|
-
localId: bigint;
|
|
10
|
-
chainId: bigint;
|
|
11
|
-
orderId: Hex;
|
|
12
|
-
logId: Hex;
|
|
13
|
-
transactionId: Hex;
|
|
14
|
-
token: Hex;
|
|
15
|
-
participantId: Hex;
|
|
16
|
-
deposited: bigint;
|
|
17
|
-
remaining: bigint;
|
|
18
|
-
minAmount: bigint;
|
|
19
|
-
maxAmount: bigint;
|
|
20
|
-
depositConversionRateCurrencies: Hex[];
|
|
21
|
-
depositConversionRateVerifiers: Hex[];
|
|
22
|
-
version: 'v2';
|
|
23
|
-
acceptingIntents: boolean;
|
|
24
|
-
delegate: Hex;
|
|
25
|
-
intentGuardian: Hex;
|
|
26
|
-
status: 'active' | 'underfunded' | 'withdrawn' | 'closed';
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* V3 Deposit structure - the normalized format.
|
|
30
|
-
* V3 deposits have the same core fields but may include additional v3-specific metadata.
|
|
31
|
-
*/
|
|
32
|
-
export type V3DepositData = Omit<V2DepositData, 'version'> & {
|
|
33
|
-
version: 'v3';
|
|
34
|
-
/**
|
|
35
|
-
* Tracks the original version if this deposit was normalized from v2.
|
|
36
|
-
* Undefined for native v3 deposits.
|
|
37
|
-
*/
|
|
38
|
-
_originalVersion?: Version;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Normalizes a V2 deposit to V3 format for unified UI consumption.
|
|
42
|
-
*
|
|
43
|
-
* Since deposits are already stored in a unified schema, this function
|
|
44
|
-
* primarily marks the deposit as "appearing" as v3 while preserving
|
|
45
|
-
* the original version information.
|
|
46
|
-
*
|
|
47
|
-
* @param v2Deposit - The v2 deposit data from the indexer
|
|
48
|
-
* @returns The deposit in v3-normalized format
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```typescript
|
|
52
|
-
* const v2Deposit = await getDeposit(escrow, depositId, chainId)
|
|
53
|
-
* if (v2Deposit.version === 'v2') {
|
|
54
|
-
* const normalized = normalizeV2Deposit(v2Deposit)
|
|
55
|
-
* // normalized.version === 'v3'
|
|
56
|
-
* // normalized._originalVersion === 'v2'
|
|
57
|
-
* }
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
export declare function normalizeV2Deposit(v2Deposit: V2DepositData): V3DepositData;
|
|
61
|
-
/**
|
|
62
|
-
* V2 Intent structure as stored in the database.
|
|
63
|
-
* V2 intents use v2Currency and v2ConversionRateChangeId for rate lookups.
|
|
64
|
-
*/
|
|
65
|
-
export type V2IntentData = {
|
|
66
|
-
intentHash: Hex;
|
|
67
|
-
orderId: Hex;
|
|
68
|
-
logId: Hex;
|
|
69
|
-
transactionId: Hex;
|
|
70
|
-
depositEscrow: Hex;
|
|
71
|
-
depositLocalId: bigint;
|
|
72
|
-
depositChainId: bigint;
|
|
73
|
-
escrow: Hex;
|
|
74
|
-
paymentMethodId: Hex;
|
|
75
|
-
ownerParticipantId: Hex;
|
|
76
|
-
toParticipantId: Hex;
|
|
77
|
-
amount: bigint;
|
|
78
|
-
fiatCurrency: Hex;
|
|
79
|
-
conversionRate: bigint;
|
|
80
|
-
timestamp: bigint;
|
|
81
|
-
/** V2-specific: Currency hash used for conversion rate lookup */
|
|
82
|
-
v2Currency: Hex;
|
|
83
|
-
/** V2-specific: Conversion rate change ID at intent time */
|
|
84
|
-
v2ConversionRateChangeId: number;
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* V3 Intent structure - the normalized format.
|
|
88
|
-
* V3 intents rely on paymentMethodId for all rate/currency information.
|
|
89
|
-
*/
|
|
90
|
-
export type V3IntentData = {
|
|
91
|
-
intentHash: Hex;
|
|
92
|
-
orderId: Hex;
|
|
93
|
-
logId: Hex;
|
|
94
|
-
transactionId: Hex;
|
|
95
|
-
depositEscrow: Hex;
|
|
96
|
-
depositLocalId: bigint;
|
|
97
|
-
depositChainId: bigint;
|
|
98
|
-
escrow: Hex;
|
|
99
|
-
paymentMethodId: Hex;
|
|
100
|
-
ownerParticipantId: Hex;
|
|
101
|
-
toParticipantId: Hex;
|
|
102
|
-
amount: bigint;
|
|
103
|
-
fiatCurrency: Hex;
|
|
104
|
-
conversionRate: bigint;
|
|
105
|
-
timestamp: bigint;
|
|
106
|
-
/** V2-specific fields are null in v3 native intents */
|
|
107
|
-
v2Currency: null;
|
|
108
|
-
v2ConversionRateChangeId: null;
|
|
109
|
-
/**
|
|
110
|
-
* Tracks the original version if this intent was normalized from v2.
|
|
111
|
-
* Undefined for native v3 intents.
|
|
112
|
-
*/
|
|
113
|
-
_originalVersion?: Version;
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* Normalizes a V2 intent to V3 format for unified UI consumption.
|
|
117
|
-
*
|
|
118
|
-
* V2 intents store currency and rate change ID explicitly, while V3 intents
|
|
119
|
-
* derive this information from the paymentMethodId relationship.
|
|
120
|
-
* This function converts v2 intent data to the v3 format.
|
|
121
|
-
*
|
|
122
|
-
* @param v2Intent - The v2 intent data from the indexer
|
|
123
|
-
* @returns The intent in v3-normalized format
|
|
124
|
-
*
|
|
125
|
-
* @example
|
|
126
|
-
* ```typescript
|
|
127
|
-
* const intent = await getIntent(intentHash)
|
|
128
|
-
* if (intent.v2Currency !== null) {
|
|
129
|
-
* const normalized = normalizeV2Intent(intent)
|
|
130
|
-
* // normalized.v2Currency === null
|
|
131
|
-
* // normalized._originalVersion === 'v2'
|
|
132
|
-
* }
|
|
133
|
-
* ```
|
|
134
|
-
*/
|
|
135
|
-
export declare function normalizeV2Intent(v2Intent: V2IntentData): V3IntentData;
|
|
136
|
-
/**
|
|
137
|
-
* V2 Payment Verification data.
|
|
138
|
-
* V2 uses ZK proofs verified on-chain via payment verifier contracts.
|
|
139
|
-
*/
|
|
140
|
-
export type V2VerificationData = {
|
|
141
|
-
intentHash: Hex;
|
|
142
|
-
verifierAddress: Hex;
|
|
143
|
-
proofTimestamp: bigint;
|
|
144
|
-
transactionId: Hex;
|
|
145
|
-
depositorAddress: Hex;
|
|
146
|
-
depositId: bigint;
|
|
147
|
-
amount: bigint;
|
|
148
|
-
};
|
|
149
|
-
/**
|
|
150
|
-
* V3-style attestation format.
|
|
151
|
-
* V3 uses EIP-712 signed attestations from trusted attesters.
|
|
152
|
-
*/
|
|
153
|
-
export type V3AttestationData = {
|
|
154
|
-
intentHash: Hex;
|
|
155
|
-
attestation: {
|
|
156
|
-
depositor: Hex;
|
|
157
|
-
depositId: bigint;
|
|
158
|
-
amount: bigint;
|
|
159
|
-
/** Payment identifier (synthesized from v2 proof data) */
|
|
160
|
-
paymentId: string;
|
|
161
|
-
timestamp: bigint;
|
|
162
|
-
};
|
|
163
|
-
/** Signature placeholder - v2 doesn't have signatures */
|
|
164
|
-
signature: null;
|
|
165
|
-
/**
|
|
166
|
-
* Tracks the original version if this attestation was normalized from v2.
|
|
167
|
-
*/
|
|
168
|
-
_originalVersion: 'v2';
|
|
169
|
-
/** Original v2 verification data preserved for reference */
|
|
170
|
-
_v2Verification: V2VerificationData;
|
|
171
|
-
};
|
|
172
|
-
/**
|
|
173
|
-
* Normalizes a V2 payment verification to V3 attestation format.
|
|
174
|
-
*
|
|
175
|
-
* V2 uses ZK proofs verified by on-chain verifier contracts, while V3 uses
|
|
176
|
-
* EIP-712 signed attestations. This function synthesizes an attestation-like
|
|
177
|
-
* structure from v2 verification data.
|
|
178
|
-
*
|
|
179
|
-
* Note: The signature field is null since v2 verifications don't use signatures.
|
|
180
|
-
* The original v2 verification data is preserved in `_v2Verification`.
|
|
181
|
-
*
|
|
182
|
-
* @param v2Verification - The v2 verification data
|
|
183
|
-
* @returns A v3-style attestation structure
|
|
184
|
-
*
|
|
185
|
-
* @example
|
|
186
|
-
* ```typescript
|
|
187
|
-
* const verification = getV2Verification(intentHash)
|
|
188
|
-
* const attestation = normalizeV2Verification(verification)
|
|
189
|
-
* // attestation.attestation.depositor === verification.depositorAddress
|
|
190
|
-
* // attestation.signature === null (v2 doesn't have signatures)
|
|
191
|
-
* // attestation._originalVersion === 'v2'
|
|
192
|
-
* ```
|
|
193
|
-
*/
|
|
194
|
-
export declare function normalizeV2Verification(v2Verification: V2VerificationData): V3AttestationData;
|
|
195
|
-
/**
|
|
196
|
-
* Type guard to check if a deposit is a v2 deposit.
|
|
197
|
-
* @param deposit - The deposit data to check
|
|
198
|
-
* @returns True if the deposit is from v2 escrow
|
|
199
|
-
*/
|
|
200
|
-
export declare function isV2Deposit(deposit: {
|
|
201
|
-
version: Version;
|
|
202
|
-
}): deposit is {
|
|
203
|
-
version: 'v2';
|
|
204
|
-
} & typeof deposit;
|
|
205
|
-
/**
|
|
206
|
-
* Type guard to check if an intent is a v2 intent.
|
|
207
|
-
* @param intent - The intent data to check
|
|
208
|
-
* @returns True if the intent has v2-specific fields populated
|
|
209
|
-
*/
|
|
210
|
-
export declare function isV2Intent(intent: {
|
|
211
|
-
v2Currency: Hex | null;
|
|
212
|
-
}): intent is {
|
|
213
|
-
v2Currency: Hex;
|
|
214
|
-
} & typeof intent;
|
|
215
|
-
/**
|
|
216
|
-
* Type guard to check if data was normalized from v2.
|
|
217
|
-
* @param data - The data to check
|
|
218
|
-
* @returns True if the data has _originalVersion === 'v2'
|
|
219
|
-
*/
|
|
220
|
-
export declare function isNormalizedFromV2(data: {
|
|
221
|
-
_originalVersion?: Version;
|
|
222
|
-
}): data is {
|
|
223
|
-
_originalVersion: 'v2';
|
|
224
|
-
} & typeof data;
|