@provex/utils 1.0.16 → 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.
Files changed (149) hide show
  1. package/dist/chain.d.ts +446 -0
  2. package/dist/chain.js +98 -0
  3. package/dist/chain.test.js +112 -0
  4. package/dist/contracts.d.ts +206 -0
  5. package/dist/contracts.js +292 -0
  6. package/dist/contracts.test.js +243 -0
  7. package/dist/conversionRates.d.ts +215 -0
  8. package/dist/{src/conversionRates.js → conversionRates.js} +74 -4
  9. package/dist/conversionRates.test.js +473 -0
  10. package/dist/currencies.d.ts +248 -0
  11. package/dist/{src/currencies.js → currencies.js} +119 -38
  12. package/dist/currencies.test.js +343 -0
  13. package/dist/data/countries.json +1099 -0
  14. package/dist/deposit.d.ts +69 -0
  15. package/dist/deposit.js +52 -0
  16. package/dist/depositKeys.d.ts +154 -0
  17. package/dist/depositKeys.js +104 -0
  18. package/dist/depositKeys.test.d.ts +1 -0
  19. package/dist/depositKeys.test.js +231 -0
  20. package/dist/events.d.ts +41 -0
  21. package/dist/events.js +92 -0
  22. package/dist/events.test.d.ts +1 -0
  23. package/dist/events.test.js +111 -0
  24. package/dist/fees.d.ts +136 -0
  25. package/dist/fees.js +178 -0
  26. package/dist/fees.test.d.ts +1 -0
  27. package/dist/fees.test.js +165 -0
  28. package/dist/ids.d.ts +175 -0
  29. package/dist/ids.js +231 -0
  30. package/dist/ids.test.d.ts +1 -0
  31. package/dist/ids.test.js +607 -0
  32. package/dist/index.d.ts +45 -0
  33. package/dist/index.js +45 -0
  34. package/dist/input.d.ts +26 -0
  35. package/dist/{src/input.js → input.js} +23 -4
  36. package/dist/intent.d.ts +50 -0
  37. package/dist/intent.js +28 -0
  38. package/dist/intent.test.d.ts +1 -0
  39. package/dist/intent.test.js +119 -0
  40. package/dist/json.d.ts +55 -0
  41. package/dist/json.js +80 -0
  42. package/dist/participants.d.ts +22 -0
  43. package/dist/participants.js +28 -0
  44. package/dist/payment.d.ts +481 -0
  45. package/dist/payment.js +1149 -0
  46. package/dist/payment.test.d.ts +1 -0
  47. package/dist/payment.test.js +272 -0
  48. package/dist/peer-types.d.ts +327 -0
  49. package/dist/peer-types.js +169 -0
  50. package/dist/profit.d.ts +49 -0
  51. package/dist/profit.js +57 -0
  52. package/dist/profit.test.d.ts +1 -0
  53. package/dist/profit.test.js +315 -0
  54. package/dist/reputation.d.ts +125 -0
  55. package/dist/reputation.js +188 -0
  56. package/dist/reputation.test.d.ts +1 -0
  57. package/dist/reputation.test.js +156 -0
  58. package/dist/sort.d.ts +75 -0
  59. package/dist/sort.js +70 -0
  60. package/dist/sort.test.d.ts +1 -0
  61. package/dist/sort.test.js +216 -0
  62. package/dist/stateKey.d.ts +35 -0
  63. package/dist/stateKey.js +36 -0
  64. package/dist/stats.d.ts +61 -0
  65. package/dist/stats.js +53 -0
  66. package/dist/stats.test.d.ts +1 -0
  67. package/dist/stats.test.js +104 -0
  68. package/dist/time.d.ts +104 -0
  69. package/dist/time.js +162 -0
  70. package/dist/time.test.d.ts +1 -0
  71. package/dist/time.test.js +231 -0
  72. package/dist/tokens.d.ts +15502 -0
  73. package/dist/{src/tokens.js → tokens.js} +98 -17
  74. package/dist/tokens.test.d.ts +1 -0
  75. package/dist/tokens.test.js +193 -0
  76. package/dist/units.d.ts +200 -0
  77. package/dist/units.js +279 -0
  78. package/dist/units.test.d.ts +1 -0
  79. package/dist/units.test.js +327 -0
  80. package/package.json +119 -29
  81. package/dist/scripts/convert-svg.js +0 -17
  82. package/dist/src/chain.d.ts +0 -14
  83. package/dist/src/chain.js +0 -18
  84. package/dist/src/contracts.d.ts +0 -30
  85. package/dist/src/contracts.js +0 -64
  86. package/dist/src/conversionRates.d.ts +0 -124
  87. package/dist/src/currencies.d.ts +0 -144
  88. package/dist/src/data/countries.json +0 -1099
  89. package/dist/src/deposit.d.ts +0 -1
  90. package/dist/src/events.d.ts +0 -3
  91. package/dist/src/events.js +0 -16
  92. package/dist/src/ids.d.ts +0 -72
  93. package/dist/src/ids.js +0 -81
  94. package/dist/src/index.d.ts +0 -16
  95. package/dist/src/index.js +0 -16
  96. package/dist/src/input.d.ts +0 -7
  97. package/dist/src/intent.d.ts +0 -14
  98. package/dist/src/json.d.ts +0 -18
  99. package/dist/src/json.js +0 -44
  100. package/dist/src/participants.d.ts +0 -7
  101. package/dist/src/participants.js +0 -13
  102. package/dist/src/payment.d.ts +0 -164
  103. package/dist/src/payment.js +0 -439
  104. package/dist/src/profit.d.ts +0 -28
  105. package/dist/src/profit.js +0 -34
  106. package/dist/src/sort.d.ts +0 -36
  107. package/dist/src/sort.js +0 -39
  108. package/dist/src/stats.d.ts +0 -7
  109. package/dist/src/stats.js +0 -8
  110. package/dist/src/time.d.ts +0 -54
  111. package/dist/src/time.js +0 -106
  112. package/dist/src/tokens.d.ts +0 -3675
  113. package/dist/src/units.d.ts +0 -17
  114. package/dist/src/units.js +0 -79
  115. package/dist/src/zkp2p-types.d.ts +0 -48
  116. package/dist/tsconfig.tsbuildinfo +0 -1
  117. package/scripts/convert-svg.ts +0 -22
  118. package/src/chain.ts +0 -27
  119. package/src/contracts.ts +0 -89
  120. package/src/conversionRates.ts +0 -356
  121. package/src/currencies.ts +0 -286
  122. package/src/data/countries.json +0 -1099
  123. package/src/deposit.ts +0 -2
  124. package/src/events.ts +0 -21
  125. package/src/flags/eur.svg +0 -4
  126. package/src/flags/usd.svg +0 -25
  127. package/src/flags.ts +0 -4
  128. package/src/global.d.ts +0 -9
  129. package/src/ids.ts +0 -137
  130. package/src/index.ts +0 -16
  131. package/src/input.ts +0 -35
  132. package/src/intent.ts +0 -15
  133. package/src/json.ts +0 -42
  134. package/src/participants.ts +0 -14
  135. package/src/payment.ts +0 -573
  136. package/src/profit.ts +0 -55
  137. package/src/sort.ts +0 -49
  138. package/src/stats.ts +0 -10
  139. package/src/time.ts +0 -123
  140. package/src/tokens.ts +0 -159
  141. package/src/units.ts +0 -120
  142. package/src/zkp2p-types.ts +0 -55
  143. package/tsconfig.json +0 -18
  144. /package/dist/{scripts/convert-svg.d.ts → chain.test.d.ts} +0 -0
  145. /package/dist/{src/deposit.js → contracts.test.d.ts} +0 -0
  146. /package/dist/{src/intent.js → conversionRates.test.d.ts} +0 -0
  147. /package/dist/{src/zkp2p-types.js → currencies.test.d.ts} +0 -0
  148. /package/dist/{src/flags.d.ts → flags.d.ts} +0 -0
  149. /package/dist/{src/flags.js → flags.js} +0 -0
package/package.json CHANGED
@@ -1,45 +1,135 @@
1
1
  {
2
2
  "name": "@provex/utils",
3
- "version": "1.0.16",
4
- "main": "dist/src/index.js",
5
- "types": "dist/src/index.d.ts",
3
+ "version": "1.2.4",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
6
  "type": "module",
7
- "access": "public",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/provex-tech/monorepo.git",
10
+ "directory": "packages/utils"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
8
15
  "exports": {
9
- ".": "./dist/src/index.js",
10
- "./contracts": "./dist/src/contracts.js",
11
- "./currencies": "./dist/src/currencies.js",
12
- "./units": "./dist/src/units.js",
13
- "./payment": "./dist/src/payment.js",
14
- "./sort": "./dist/src/sort.js",
15
- "./time": "./dist/src/time.js",
16
- "./tokens": "./dist/src/tokens.js",
17
- "./intent": "./dist/src/intent.js",
18
- "./conversionRates": "./dist/src/conversionRates.js",
19
- "./json": "./dist/src/json.js",
20
- "./profit": "./dist/src/profit.js",
21
- "./chain": "./dist/src/chain.js",
22
- "./participants": "./dist/src/participants.js",
23
- "./input": "./dist/src/input.js",
24
- "./stats": "./dist/src/stats.js",
25
- "./ids": "./dist/src/ids.js",
26
- "./events": "./dist/src/events.js",
27
- "./zkp2p-types": "./dist/src/zkp2p-types.js",
28
- "./deposit": "./dist/src/deposit.js"
16
+ ".": {
17
+ "import": "./dist/index.js",
18
+ "types": "./dist/index.d.ts"
19
+ },
20
+ "./contracts": {
21
+ "import": "./dist/contracts.js",
22
+ "types": "./dist/contracts.d.ts"
23
+ },
24
+ "./currencies": {
25
+ "import": "./dist/currencies.js",
26
+ "types": "./dist/currencies.d.ts"
27
+ },
28
+ "./units": {
29
+ "import": "./dist/units.js",
30
+ "types": "./dist/units.d.ts"
31
+ },
32
+ "./payment": {
33
+ "import": "./dist/payment.js",
34
+ "types": "./dist/payment.d.ts"
35
+ },
36
+ "./sort": {
37
+ "import": "./dist/sort.js",
38
+ "types": "./dist/sort.d.ts"
39
+ },
40
+ "./time": {
41
+ "import": "./dist/time.js",
42
+ "types": "./dist/time.d.ts"
43
+ },
44
+ "./tokens": {
45
+ "import": "./dist/tokens.js",
46
+ "types": "./dist/tokens.d.ts"
47
+ },
48
+ "./intent": {
49
+ "import": "./dist/intent.js",
50
+ "types": "./dist/intent.d.ts"
51
+ },
52
+ "./conversionRates": {
53
+ "import": "./dist/conversionRates.js",
54
+ "types": "./dist/conversionRates.d.ts"
55
+ },
56
+ "./json": {
57
+ "import": "./dist/json.js",
58
+ "types": "./dist/json.d.ts"
59
+ },
60
+ "./profit": {
61
+ "import": "./dist/profit.js",
62
+ "types": "./dist/profit.d.ts"
63
+ },
64
+ "./chain": {
65
+ "import": "./dist/chain.js",
66
+ "types": "./dist/chain.d.ts"
67
+ },
68
+ "./participants": {
69
+ "import": "./dist/participants.js",
70
+ "types": "./dist/participants.d.ts"
71
+ },
72
+ "./input": {
73
+ "import": "./dist/input.js",
74
+ "types": "./dist/input.d.ts"
75
+ },
76
+ "./stats": {
77
+ "import": "./dist/stats.js",
78
+ "types": "./dist/stats.d.ts"
79
+ },
80
+ "./stateKey": {
81
+ "import": "./dist/stateKey.js",
82
+ "types": "./dist/stateKey.d.ts"
83
+ },
84
+ "./ids": {
85
+ "import": "./dist/ids.js",
86
+ "types": "./dist/ids.d.ts"
87
+ },
88
+ "./events": {
89
+ "import": "./dist/events.js",
90
+ "types": "./dist/events.d.ts"
91
+ },
92
+ "./peer-types": {
93
+ "import": "./dist/peer-types.js",
94
+ "types": "./dist/peer-types.d.ts"
95
+ },
96
+ "./deposit": {
97
+ "import": "./dist/deposit.js",
98
+ "types": "./dist/deposit.d.ts"
99
+ },
100
+ "./fees": {
101
+ "import": "./dist/fees.js",
102
+ "types": "./dist/fees.d.ts"
103
+ },
104
+ "./reputation": {
105
+ "import": "./dist/reputation.js",
106
+ "types": "./dist/reputation.d.ts"
107
+ }
29
108
  },
30
109
  "scripts": {
31
- "build": "tsx scripts/convert-svg && tsc && cp -r src/data dist/src/"
110
+ "build": "tsx scripts/convert-svg && tsc && cp -r src/data dist/",
111
+ "test": "node --import tsx --test 'src/**/*.test.ts'",
112
+ "test:watch": "node --import tsx --test --watch 'src/**/*.test.ts'",
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'"
32
114
  },
33
115
  "keywords": [],
34
116
  "author": "",
35
117
  "license": "ISC",
36
118
  "description": "",
119
+ "files": [
120
+ "dist",
121
+ "README.md"
122
+ ],
37
123
  "dependencies": {
124
+ "@zkp2p/providers": "^7.8.0"
125
+ },
126
+ "peerDependencies": {
127
+ "viem": "^2.0.0"
128
+ },
129
+ "devDependencies": {
130
+ "@types/node": "^22.0.0",
38
131
  "tsx": "^4.20.3",
39
132
  "typescript": "^5.9.2",
40
133
  "viem": "^2.38.0"
41
- },
42
- "devDependencies": {
43
- "@types/node": "^22.0.0"
44
134
  }
45
- }
135
+ }
@@ -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');
@@ -1,14 +0,0 @@
1
- import { type Chain } from 'viem/chains';
2
- export declare const chains: [Chain, ...Chain[]];
3
- export declare const chainIds: number[];
4
- export type ChainId = (typeof chainIds)[number];
5
- /**
6
- * Get the explorer URL for a given chain, type, and hash
7
- * @param chain - The chain to get the explorer URL for
8
- * @param type - The type of explorer to use (tx or address)
9
- * @param hash - The hash to get the explorer URL for
10
- * @returns The explorer URL
11
- */
12
- export declare function getExplorerUrl(chain: Chain, type: 'tx' | 'address', hash: string): string;
13
- export declare const chainIdToChain: Map<number, Chain>;
14
- export declare const chainIdToTargetBlockTime: Map<number, number>;
package/dist/src/chain.js DELETED
@@ -1,18 +0,0 @@
1
- import { base, pulsechain } from 'viem/chains';
2
- export const chains = [pulsechain, base];
3
- export const chainIds = chains.map((chain) => chain.id);
4
- /**
5
- * Get the explorer URL for a given chain, type, and hash
6
- * @param chain - The chain to get the explorer URL for
7
- * @param type - The type of explorer to use (tx or address)
8
- * @param hash - The hash to get the explorer URL for
9
- * @returns The explorer URL
10
- */
11
- export function getExplorerUrl(chain, type, hash) {
12
- return `${chain.blockExplorers?.default.url}/${type}/${hash}`;
13
- }
14
- export const chainIdToChain = new Map(chains.map((chain) => [chain.id, chain]));
15
- export const chainIdToTargetBlockTime = new Map([
16
- [369, 10_000],
17
- [8453, 2_000],
18
- ]);
@@ -1,30 +0,0 @@
1
- import { type Hex } from 'viem';
2
- import type { ChainId } from './chain.js';
3
- /**
4
- * Contracts for the app
5
- */
6
- export type Contracts = {
7
- gatingService: Hex;
8
- usdc: Hex;
9
- escrow: Hex[];
10
- venmoReclaimVerifier: Hex[];
11
- revolutReclaimVerifier: Hex[];
12
- cashappReclaimVerifier: Hex[];
13
- wiseReclaimVerifier: Hex[];
14
- mercadopagoReclaimVerifier: Hex[];
15
- zelleBaseVerifier: Hex[];
16
- zelleBoAReclaimVerifier: Hex[];
17
- zelleChaseReclaimVerifier: Hex[];
18
- zelleCitiReclaimVerifier: Hex[];
19
- paypalReclaimVerifier: Hex[];
20
- monzoReclaimVerifier: Hex[];
21
- };
22
- export declare const reclaimSigners: {
23
- readonly zkp2pWitnessSigner: "0x0636c417755E3ae25C6c166D181c0607F4C572A3";
24
- readonly reclaimWitnessSigner: "0x244897572368eadf65bfbc5aec98d8e5443a9072";
25
- };
26
- export declare const baseContracts: Contracts;
27
- export declare const pulsechainContracts: Contracts;
28
- export declare const contractsByChainId: Map<number, Contracts>;
29
- export declare const getContracts: (chainId: ChainId) => Contracts | null;
30
- export declare const getLatestContract: (chainId: ChainId, key: keyof Contracts) => `0x${string}` | null;
@@ -1,64 +0,0 @@
1
- import { getAddress } from 'viem';
2
- import { base, pulsechain } from 'viem/chains';
3
- export const reclaimSigners = {
4
- zkp2pWitnessSigner: '0x0636c417755E3ae25C6c166D181c0607F4C572A3',
5
- reclaimWitnessSigner: '0x244897572368eadf65bfbc5aec98d8e5443a9072',
6
- };
7
- export const baseContracts = {
8
- gatingService: getAddress('0x396D31055Db28C0C6f36e8b36f18FE7227248a97'),
9
- usdc: getAddress('0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'),
10
- escrow: [getAddress('0xCA38607D85E8F6294Dc10728669605E6664C2D70')],
11
- venmoReclaimVerifier: [getAddress('0x9a733B55a875D0DB4915c6B36350b24F8AB99dF5')],
12
- revolutReclaimVerifier: [getAddress('0xAA5A1B62B01781E789C900d616300717CD9A41aB')],
13
- cashappReclaimVerifier: [getAddress('0x76D33A33068D86016B806dF02376dDBb23Dd3703')],
14
- wiseReclaimVerifier: [getAddress('0xFF0149799631D7A5bdE2e7eA9b306c42b3d9a9ca')],
15
- mercadopagoReclaimVerifier: [
16
- // getAddress('0x00d003c73eab8feaec04bab976235915fe7641e3'),
17
- getAddress('0xf2AC5be14F32Cbe6A613CFF8931d95460D6c33A3'),
18
- ],
19
- zelleBaseVerifier: [
20
- // getAddress('0x1783f040783c0827fb64d128ece548d9b3613ad5'),
21
- getAddress('0x431a078A5029146aAB239c768A615CD484519aF7'),
22
- ],
23
- zelleChaseReclaimVerifier: [getAddress('0xBcD7C6BBcA5869fBefe3E322263EE1090221D7A9')],
24
- zelleBoAReclaimVerifier: [getAddress('0x809c7A20A2dbBB3210fC73Dd7C01Cd7Fa70C195F')],
25
- zelleCitiReclaimVerifier: [getAddress('0x3128badc46dbe2e37bdd2d64f33fb3b3a639570e')],
26
- paypalReclaimVerifier: [getAddress('0x03d17E9371C858072E171276979f6B44571C5DeA')],
27
- monzoReclaimVerifier: [getAddress('0x0dE46433bD251027f73eD8f28E01eF05DA36a2E0')],
28
- };
29
- export const pulsechainContracts = {
30
- gatingService: getAddress('0x4Bd6364FCC4D8A537aBfee33B16E959794fDf9Cf'),
31
- usdc: getAddress('0x15D38573d2feeb82e7ad5187aB8c1D52810B1f07'),
32
- escrow: [getAddress('0x2932E08BFD212Ef0732257bDd6463BF55E9b97d7')],
33
- cashappReclaimVerifier: [getAddress('0x9224433D6AD9a5A774ca74Ca33c01747FA710A9d')],
34
- mercadopagoReclaimVerifier: [getAddress('0xc4D0cf4DF12e329f9c951d1D9BB815da6138850A')],
35
- monzoReclaimVerifier: [getAddress('0xBde2c79c1897459e66C0fdF6764EED0c6839C878')],
36
- nullifierRegistry: [getAddress('0x471D3c6C9E32CE2556d0117aC161Aa82AEac17d8')],
37
- paypalReclaimVerifier: [getAddress('0x1DdBfd39a141C5A2329d849CADa6a83404E0Ce4F')],
38
- revolutReclaimVerifier: [getAddress('0x8234AA463C8B94778f58eA0bFEfcBAC3683341A9')],
39
- venmoReclaimVerifier: [getAddress('0x0Dd524dA03f610480aF3F433B411b6016cFBDeab')],
40
- wiseReclaimVerifier: [getAddress('0x7B72d7CfAfDfD397E2460c933e84D16dc121845a')],
41
- zelleBaseVerifier: [getAddress('0x539566771f9c38c6038aafc1946bf11af9cdb201')],
42
- zelleBoAReclaimVerifier: [getAddress('0x506a746b8228F9f9d4522105b973Dc7223A64EAC')],
43
- zelleChaseReclaimVerifier: [getAddress('0xB0aA0a58959465bBCf0eCbD62A84B743A5435c99')],
44
- zelleCitiReclaimVerifier: [getAddress('0x5624E479924eBFb25B51F36e3FDaE605dADb448b')],
45
- };
46
- export const contractsByChainId = new Map([
47
- [base.id, baseContracts],
48
- [pulsechain.id, pulsechainContracts],
49
- ]);
50
- export const getContracts = (chainId) => {
51
- return contractsByChainId.get(chainId) ?? null;
52
- };
53
- export const getLatestContract = (chainId, key) => {
54
- const contracts = getContracts(chainId);
55
- if (!contracts)
56
- return null;
57
- const target = contracts[key];
58
- if (!target)
59
- return null;
60
- if (Array.isArray(target)) {
61
- return target[target.length - 1] ?? null;
62
- }
63
- return target;
64
- };
@@ -1,124 +0,0 @@
1
- import type { Hex } from 'viem';
2
- import { Currency } from './currencies.js';
3
- import { type ProviderKey } from './payment.js';
4
- import type { SortDirection } from './sort.js';
5
- import type { TokenInfo } from './tokens.js';
6
- import type { ChainId } from './chain.js';
7
- /**
8
- * Conversion rate info
9
- */
10
- export interface ConversionRateInfo {
11
- depositConversionRateUpdatedId: string;
12
- currency: string;
13
- verifier: string;
14
- value: string;
15
- orderId: string;
16
- depositId: string;
17
- transaction: {
18
- hash: string;
19
- block: {
20
- timestamp: string;
21
- };
22
- };
23
- }
24
- /**
25
- * Conversion rate info with current deposit conversion rate updated
26
- */
27
- export interface ConversionRateInfoWithCurrent extends ConversionRateInfo {
28
- currentDepositConversionRateUpdatedId: string;
29
- currentDepositConversionRateUpdated: {
30
- value: string;
31
- };
32
- }
33
- /**
34
- * Provider rates
35
- */
36
- export type ProviderRates<RateInfo> = Map<ProviderKey, Map<Hex, RateInfo>>;
37
- /**
38
- * Process conversion rates options
39
- */
40
- interface ProcessConversionRatesOptions {
41
- chainId: ChainId;
42
- events: ConversionRateInfoWithCurrent[];
43
- sortOrder?: SortDirection;
44
- includeHistorical?: boolean;
45
- }
46
- /**
47
- * Get conversion rate options
48
- */
49
- interface GetConversionRateOptions {
50
- events: ConversionRateInfoWithCurrent[];
51
- currency: Hex;
52
- verifier: string;
53
- chainId: ChainId;
54
- includeHistory?: boolean;
55
- fallbackRate?: {
56
- currency: string;
57
- value: string;
58
- verifier: string;
59
- } | null;
60
- }
61
- /**
62
- * Extract currencies options
63
- */
64
- interface ExtractCurrenciesOptions {
65
- providerRates: ProviderRates<ConversionRateInfo[]>;
66
- providersOnly?: ProviderKey[];
67
- currenciesOnly?: string[];
68
- }
69
- /**
70
- * Process deposit currency added events into organized conversion rates
71
- */
72
- export declare function processConversionRates(options: ProcessConversionRatesOptions): ProviderRates<ConversionRateInfo[]>;
73
- /**
74
- * Get conversion rate for a specific currency and verifier combination
75
- */
76
- export declare function getConversionRate(options: GetConversionRateOptions): ConversionRateInfo | ConversionRateInfo[] | null;
77
- /**
78
- * Extract unique currencies from processed provider rates
79
- */
80
- export declare function extractCurrencies(options: ExtractCurrenciesOptions): string[];
81
- /**
82
- * Get the latest conversion rate across all providers for a currency
83
- */
84
- export declare function getLatestRateForCurrency(options: {
85
- providerRates: ProviderRates<ConversionRateInfo>;
86
- currency: Hex;
87
- preferredProvider?: ProviderKey;
88
- }): ConversionRateInfo | null;
89
- /**
90
- * Get the primary conversion rate from processed provider rates
91
- * Returns the first available rate, prioritizing by provider order
92
- */
93
- export declare function getPrimaryConversionRate(providerRates: ProviderRates<ConversionRateInfo>): ConversionRateInfo | null;
94
- /**
95
- * Get primary conversion rate for a specific currency across all providers
96
- */
97
- export declare function getPrimaryRateForCurrency(providerRates: ProviderRates<ConversionRateInfo>, currency: Hex): ConversionRateInfo | null;
98
- /**
99
- * Get the primary verifier (payment provider) from conversion rates
100
- */
101
- export declare function getPrimaryVerifier(providerRates: ProviderRates<ConversionRateInfo>): string | null;
102
- /**
103
- * Get the primary currency from conversion rates
104
- */
105
- export declare function getPrimaryCurrency(providerRates: ProviderRates<ConversionRateInfo>): string | null;
106
- /**
107
- * Convert token input to currency
108
- */
109
- export declare const convertTokenInputToCurrency: ({ token, amountOutInt, rate }: {
110
- token: TokenInfo;
111
- amountOutInt: bigint;
112
- rate: bigint;
113
- }) => bigint;
114
- /**
115
- * Convert currency amount to token amount out (inverse of convertTokenInputToCurrency)
116
- * This accounts for the cent-rounding applied in the original function
117
- */
118
- export declare const convertCurrencyToTokenOutput: ({ token, currency, currencyAmountInt, rate, }: {
119
- token: TokenInfo;
120
- currency: Currency;
121
- currencyAmountInt: bigint;
122
- rate: bigint;
123
- }) => bigint;
124
- export {};
@@ -1,144 +0,0 @@
1
- import { type Hex } from 'viem';
2
- import { type FormatRateDisplayOptions } from './units.js';
3
- /**
4
- * Relevant info for a currency
5
- */
6
- export interface CurrencyInfo {
7
- ticker: string;
8
- symbol: string;
9
- name: string;
10
- decimals: number;
11
- contractId: Hex;
12
- flag: string;
13
- }
14
- /**
15
- * Country info from the countries.json file
16
- */
17
- export interface CountryInfo {
18
- code: string;
19
- name: string;
20
- country: string;
21
- countryCode: string;
22
- flag?: string;
23
- }
24
- /**
25
- * Convert a ticker to a contract ID
26
- * @param ticker - The ticker to convert
27
- * @returns The contract ID
28
- */
29
- export declare const tickerToContractId: (ticker: string) => Hex;
30
- /**
31
- * Currency class that automatically generates contract ID
32
- * @param code - The currency code
33
- * @param symbol - The currency symbol
34
- * @param name - The currency name
35
- * @param decimals - The number of decimals
36
- * @param flag - The flag image path
37
- */
38
- export declare class Currency implements CurrencyInfo {
39
- readonly ticker: string;
40
- readonly symbol: string;
41
- readonly name: string;
42
- readonly decimals: number;
43
- readonly contractId: Hex;
44
- readonly flag: string;
45
- constructor(code: string, symbol: string, name: string, decimals: number, flag?: string);
46
- /**
47
- * Generate a contract ID for the currency
48
- * @returns The contract ID
49
- */
50
- private generateContractId;
51
- /**
52
- * Parse an amount to a bigint
53
- * @param amount - The amount to parse
54
- * @returns The amount as a bigint
55
- */
56
- parseAmount(amount: string): bigint | null;
57
- /**
58
- * Format an amount to a string
59
- * @param amount - The amount to format
60
- * @returns The amount as a string
61
- */
62
- formatAmount(amount: bigint | null, options?: Partial<FormatRateDisplayOptions>): string | null;
63
- /**
64
- * Convert to plain object for compatibility
65
- * @returns The currency info
66
- */
67
- toJSON(): CurrencyInfo;
68
- }
69
- /**
70
- * Generate contract ID for a currency code (standalone function for backward compatibility)
71
- * @param currencyCode - The currency code
72
- */
73
- export declare function generateCurrencyId(currencyCode: string): string;
74
- export declare const SUPPORTED_CURRENCIES: {
75
- readonly USD: Currency;
76
- readonly EUR: Currency;
77
- readonly GBP: Currency;
78
- readonly AUD: Currency;
79
- readonly CAD: Currency;
80
- readonly NZD: Currency;
81
- readonly CHF: Currency;
82
- readonly SEK: Currency;
83
- readonly NOK: Currency;
84
- readonly DKK: Currency;
85
- readonly PLN: Currency;
86
- readonly CZK: Currency;
87
- readonly ARS: Currency;
88
- readonly CNY: Currency;
89
- readonly MXN: Currency;
90
- readonly JPY: Currency;
91
- readonly THB: Currency;
92
- readonly RUB: Currency;
93
- readonly AED: Currency;
94
- readonly ZAR: Currency;
95
- readonly HKD: Currency;
96
- readonly SGD: Currency;
97
- readonly SAR: Currency;
98
- readonly ILS: Currency;
99
- readonly IDR: Currency;
100
- readonly MYR: Currency;
101
- readonly PHP: Currency;
102
- readonly VND: Currency;
103
- readonly KRW: Currency;
104
- readonly INR: Currency;
105
- readonly BRL: Currency;
106
- readonly KES: Currency;
107
- readonly TRY: Currency;
108
- readonly UGX: Currency;
109
- readonly RON: Currency;
110
- readonly HUF: Currency;
111
- };
112
- /** Supported currency code */
113
- export type SupportedCurrencyCode = keyof typeof SUPPORTED_CURRENCIES;
114
- export declare const currencyById: Map<`0x${string}`, Currency>;
115
- /**
116
- * Get the currency info for a currency code
117
- * @param currencyCode - The currency code
118
- * @returns The currency info
119
- */
120
- export declare function getCurrencyInfo(currencyCode: string): CurrencyInfo | null;
121
- /**
122
- * Get the currency info for a contract ID
123
- * @param contractId - The contract ID
124
- * @returns The currency info
125
- */
126
- export declare function getCurrencyByContractId(contractId: string): Currency | null;
127
- /**
128
- * Format a currency amount
129
- * @param amount - The amount to format
130
- * @param currencyCode - The currency code
131
- * @returns The formatted currency amount
132
- */
133
- export declare function formatCurrencyAmount(amount: string | number, currencyCode: string): string;
134
- /**
135
- * Get all supported currencies
136
- * @returns All supported currencies
137
- */
138
- export declare function getAllSupportedCurrencies(): CurrencyInfo[];
139
- /**
140
- * Check if a currency is supported
141
- * @param currencyCode - The currency code
142
- * @returns True if the currency is supported, false otherwise
143
- */
144
- export declare function isSupportedCurrency(currencyCode: string): boolean;