@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.
- package/dist/chain.d.ts +446 -0
- package/dist/chain.js +98 -0
- package/dist/chain.test.js +112 -0
- package/dist/contracts.d.ts +206 -0
- package/dist/contracts.js +292 -0
- package/dist/contracts.test.js +243 -0
- package/dist/conversionRates.d.ts +215 -0
- package/dist/{src/conversionRates.js → conversionRates.js} +74 -4
- package/dist/conversionRates.test.js +473 -0
- package/dist/currencies.d.ts +248 -0
- package/dist/{src/currencies.js → currencies.js} +119 -38
- package/dist/currencies.test.js +343 -0
- package/dist/data/countries.json +1099 -0
- package/dist/deposit.d.ts +69 -0
- package/dist/deposit.js +52 -0
- package/dist/depositKeys.d.ts +154 -0
- package/dist/depositKeys.js +104 -0
- package/dist/depositKeys.test.d.ts +1 -0
- package/dist/depositKeys.test.js +231 -0
- package/dist/events.d.ts +41 -0
- package/dist/events.js +92 -0
- package/dist/events.test.d.ts +1 -0
- package/dist/events.test.js +111 -0
- package/dist/fees.d.ts +136 -0
- package/dist/fees.js +178 -0
- package/dist/fees.test.d.ts +1 -0
- package/dist/fees.test.js +165 -0
- package/dist/ids.d.ts +175 -0
- package/dist/ids.js +231 -0
- package/dist/ids.test.d.ts +1 -0
- package/dist/ids.test.js +607 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +45 -0
- package/dist/input.d.ts +26 -0
- package/dist/{src/input.js → input.js} +23 -4
- package/dist/intent.d.ts +50 -0
- package/dist/intent.js +28 -0
- package/dist/intent.test.d.ts +1 -0
- package/dist/intent.test.js +119 -0
- package/dist/json.d.ts +55 -0
- package/dist/json.js +80 -0
- package/dist/participants.d.ts +22 -0
- package/dist/participants.js +28 -0
- package/dist/payment.d.ts +481 -0
- package/dist/payment.js +1149 -0
- package/dist/payment.test.d.ts +1 -0
- package/dist/payment.test.js +272 -0
- package/dist/peer-types.d.ts +327 -0
- package/dist/peer-types.js +169 -0
- package/dist/profit.d.ts +49 -0
- package/dist/profit.js +57 -0
- package/dist/profit.test.d.ts +1 -0
- package/dist/profit.test.js +315 -0
- package/dist/reputation.d.ts +125 -0
- package/dist/reputation.js +188 -0
- package/dist/reputation.test.d.ts +1 -0
- package/dist/reputation.test.js +156 -0
- package/dist/sort.d.ts +75 -0
- package/dist/sort.js +70 -0
- package/dist/sort.test.d.ts +1 -0
- package/dist/sort.test.js +216 -0
- package/dist/stateKey.d.ts +35 -0
- package/dist/stateKey.js +36 -0
- package/dist/stats.d.ts +61 -0
- package/dist/stats.js +53 -0
- package/dist/stats.test.d.ts +1 -0
- package/dist/stats.test.js +104 -0
- package/dist/time.d.ts +104 -0
- package/dist/time.js +162 -0
- package/dist/time.test.d.ts +1 -0
- package/dist/time.test.js +231 -0
- package/dist/tokens.d.ts +15502 -0
- package/dist/{src/tokens.js → tokens.js} +98 -17
- package/dist/tokens.test.d.ts +1 -0
- package/dist/tokens.test.js +193 -0
- package/dist/units.d.ts +200 -0
- package/dist/units.js +279 -0
- package/dist/units.test.d.ts +1 -0
- package/dist/units.test.js +327 -0
- package/package.json +119 -29
- package/dist/scripts/convert-svg.js +0 -17
- package/dist/src/chain.d.ts +0 -14
- package/dist/src/chain.js +0 -18
- package/dist/src/contracts.d.ts +0 -30
- package/dist/src/contracts.js +0 -64
- package/dist/src/conversionRates.d.ts +0 -124
- package/dist/src/currencies.d.ts +0 -144
- package/dist/src/data/countries.json +0 -1099
- package/dist/src/deposit.d.ts +0 -1
- package/dist/src/events.d.ts +0 -3
- package/dist/src/events.js +0 -16
- package/dist/src/ids.d.ts +0 -72
- package/dist/src/ids.js +0 -81
- package/dist/src/index.d.ts +0 -16
- package/dist/src/index.js +0 -16
- package/dist/src/input.d.ts +0 -7
- package/dist/src/intent.d.ts +0 -14
- package/dist/src/json.d.ts +0 -18
- package/dist/src/json.js +0 -44
- package/dist/src/participants.d.ts +0 -7
- package/dist/src/participants.js +0 -13
- package/dist/src/payment.d.ts +0 -164
- package/dist/src/payment.js +0 -439
- package/dist/src/profit.d.ts +0 -28
- package/dist/src/profit.js +0 -34
- package/dist/src/sort.d.ts +0 -36
- package/dist/src/sort.js +0 -39
- package/dist/src/stats.d.ts +0 -7
- package/dist/src/stats.js +0 -8
- package/dist/src/time.d.ts +0 -54
- package/dist/src/time.js +0 -106
- package/dist/src/tokens.d.ts +0 -3675
- package/dist/src/units.d.ts +0 -17
- package/dist/src/units.js +0 -79
- package/dist/src/zkp2p-types.d.ts +0 -48
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/scripts/convert-svg.ts +0 -22
- package/src/chain.ts +0 -27
- package/src/contracts.ts +0 -89
- package/src/conversionRates.ts +0 -356
- package/src/currencies.ts +0 -286
- package/src/data/countries.json +0 -1099
- package/src/deposit.ts +0 -2
- package/src/events.ts +0 -21
- package/src/flags/eur.svg +0 -4
- package/src/flags/usd.svg +0 -25
- package/src/flags.ts +0 -4
- package/src/global.d.ts +0 -9
- package/src/ids.ts +0 -137
- package/src/index.ts +0 -16
- package/src/input.ts +0 -35
- package/src/intent.ts +0 -15
- package/src/json.ts +0 -42
- package/src/participants.ts +0 -14
- package/src/payment.ts +0 -573
- package/src/profit.ts +0 -55
- package/src/sort.ts +0 -49
- package/src/stats.ts +0 -10
- package/src/time.ts +0 -123
- package/src/tokens.ts +0 -159
- package/src/units.ts +0 -120
- package/src/zkp2p-types.ts +0 -55
- package/tsconfig.json +0 -18
- /package/dist/{scripts/convert-svg.d.ts → chain.test.d.ts} +0 -0
- /package/dist/{src/deposit.js → contracts.test.d.ts} +0 -0
- /package/dist/{src/intent.js → conversionRates.test.d.ts} +0 -0
- /package/dist/{src/zkp2p-types.js → currencies.test.d.ts} +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/deposit.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type StatusMutatingAction = "deposit" | "withdrawal" | "closed" | "exchange";
|
package/dist/src/events.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const eventOrder: readonly ["deposit", "verifier_added", "currency_added", "rate_update", "intent", "exchange", "pruned", "withdrawal", "closed"];
|
|
2
|
-
export type EventType = (typeof eventOrder)[number];
|
|
3
|
-
export declare const eventOrderId: Map<"deposit" | "withdrawal" | "closed" | "exchange" | "verifier_added" | "currency_added" | "rate_update" | "intent" | "pruned", number>;
|
package/dist/src/events.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export const eventOrder = [
|
|
2
|
-
// deposit open events
|
|
3
|
-
'deposit',
|
|
4
|
-
'verifier_added',
|
|
5
|
-
'currency_added',
|
|
6
|
-
// configuration events
|
|
7
|
-
'rate_update',
|
|
8
|
-
// intent events
|
|
9
|
-
'intent',
|
|
10
|
-
'exchange',
|
|
11
|
-
'pruned',
|
|
12
|
-
// deposit close events
|
|
13
|
-
'withdrawal',
|
|
14
|
-
'closed',
|
|
15
|
-
];
|
|
16
|
-
export const eventOrderId = new Map(eventOrder.map((event, index) => [event, index]));
|
package/dist/src/ids.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { type Hex } from "viem";
|
|
2
|
-
import { type EventType } from "./events.js";
|
|
3
|
-
import { type TimeResolutionKey } from "./time.js";
|
|
4
|
-
import type { StatAction } from "./stats.js";
|
|
5
|
-
export type DepositVerifierInputs = {
|
|
6
|
-
verifier: Hex;
|
|
7
|
-
depositId: Hex;
|
|
8
|
-
};
|
|
9
|
-
export type DepositCurrencyInputs = DepositVerifierInputs & {
|
|
10
|
-
currency: Hex;
|
|
11
|
-
};
|
|
12
|
-
export type ConversionRateUpdatedInputs = DepositCurrencyInputs & {
|
|
13
|
-
changeId: number;
|
|
14
|
-
};
|
|
15
|
-
export type ProviderHashInputs = {
|
|
16
|
-
chainId: bigint | number;
|
|
17
|
-
hash: Hex;
|
|
18
|
-
};
|
|
19
|
-
export type OnChainHashInputs = {
|
|
20
|
-
chainId: bigint | number;
|
|
21
|
-
hash: Hex;
|
|
22
|
-
};
|
|
23
|
-
export type OnChainAddressInputs = {
|
|
24
|
-
chainId: bigint | number;
|
|
25
|
-
address: Hex;
|
|
26
|
-
};
|
|
27
|
-
export declare const onChainHash: ({ chainId, hash }: OnChainHashInputs) => `0x${string}`;
|
|
28
|
-
export declare const onChainAddress: ({ chainId, address }: OnChainAddressInputs) => `0x${string}`;
|
|
29
|
-
export declare const ids: {
|
|
30
|
-
block: ({ chainId, hash }: OnChainHashInputs) => `0x${string}`;
|
|
31
|
-
transaction: ({ chainId, hash }: OnChainHashInputs) => `0x${string}`;
|
|
32
|
-
participant: ({ chainId, address }: OnChainAddressInputs) => `0x${string}`;
|
|
33
|
-
providerHash: ({ chainId, hash }: OnChainHashInputs) => `0x${string}`;
|
|
34
|
-
verifier: ({ chainId, address }: OnChainAddressInputs) => `0x${string}`;
|
|
35
|
-
depositVerifierAdded: ({ depositId, verifier }: DepositVerifierInputs) => `0x${string}`;
|
|
36
|
-
depositCurrencyAdded: ({ depositId, currency, verifier }: DepositCurrencyInputs) => `0x${string}`;
|
|
37
|
-
depositConversionRateUpdated: ({ currency, verifier, depositId, changeId }: ConversionRateUpdatedInputs) => `0x${string}`;
|
|
38
|
-
};
|
|
39
|
-
export type OrderIdInputs = {
|
|
40
|
-
timestamp: bigint;
|
|
41
|
-
chainId: bigint;
|
|
42
|
-
};
|
|
43
|
-
export type OrderIdTransactionInputs = OrderIdInputs & {
|
|
44
|
-
transactionIndex: bigint;
|
|
45
|
-
};
|
|
46
|
-
export type OrderIdLogInputs = OrderIdTransactionInputs & {
|
|
47
|
-
logIndex: bigint;
|
|
48
|
-
};
|
|
49
|
-
export type OrderIdOrderInputs = OrderIdLogInputs & {
|
|
50
|
-
name: EventType;
|
|
51
|
-
};
|
|
52
|
-
export type DepositIdInputs = {
|
|
53
|
-
chainId: bigint | number;
|
|
54
|
-
depositId: bigint | number;
|
|
55
|
-
};
|
|
56
|
-
export type LogStatsIdInputs = {
|
|
57
|
-
timestamp: bigint;
|
|
58
|
-
type: TimeResolutionKey;
|
|
59
|
-
action: StatAction;
|
|
60
|
-
currency: Hex | null;
|
|
61
|
-
token: Hex;
|
|
62
|
-
verifier: Hex;
|
|
63
|
-
chainId: bigint | number;
|
|
64
|
-
};
|
|
65
|
-
export declare const orderId: {
|
|
66
|
-
deposit: ({ chainId, depositId }: DepositIdInputs) => `0x${string}`;
|
|
67
|
-
block: ({ timestamp, chainId }: OrderIdInputs) => `0x${string}`;
|
|
68
|
-
transaction: ({ timestamp, chainId, transactionIndex }: OrderIdTransactionInputs) => `0x${string}`;
|
|
69
|
-
log: ({ timestamp, chainId, transactionIndex, logIndex }: OrderIdLogInputs) => `0x${string}`;
|
|
70
|
-
order: ({ timestamp, chainId, transactionIndex, logIndex, name }: OrderIdOrderInputs) => `0x${string}`;
|
|
71
|
-
stat: ({ timestamp, type, action, currency, verifier, token, chainId }: LogStatsIdInputs) => `0x${string}`;
|
|
72
|
-
};
|
package/dist/src/ids.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { concatHex, keccak256, numberToHex, stringToHex } from "viem";
|
|
2
|
-
import { eventOrderId } from "./events.js";
|
|
3
|
-
import { interval } from "./time.js";
|
|
4
|
-
export const onChainHash = ({ chainId, hash }) => (keccak256(concatHex([
|
|
5
|
-
numberToHex(chainId, { size: 8 }),
|
|
6
|
-
hash,
|
|
7
|
-
])));
|
|
8
|
-
export const onChainAddress = ({ chainId, address }) => (onChainHash({ chainId, hash: address }));
|
|
9
|
-
export const ids = {
|
|
10
|
-
block: onChainHash,
|
|
11
|
-
transaction: onChainHash,
|
|
12
|
-
participant: onChainAddress,
|
|
13
|
-
providerHash: onChainHash,
|
|
14
|
-
verifier: onChainAddress,
|
|
15
|
-
depositVerifierAdded: ({ depositId, verifier }) => {
|
|
16
|
-
return keccak256(concatHex([depositId, verifier]));
|
|
17
|
-
},
|
|
18
|
-
depositCurrencyAdded: ({ depositId, currency, verifier }) => {
|
|
19
|
-
return keccak256(concatHex([
|
|
20
|
-
ids.depositVerifierAdded({ verifier, depositId }),
|
|
21
|
-
currency,
|
|
22
|
-
]));
|
|
23
|
-
},
|
|
24
|
-
depositConversionRateUpdated: ({ currency, verifier, depositId, changeId }) => {
|
|
25
|
-
return concatHex([
|
|
26
|
-
ids.depositCurrencyAdded({ currency, verifier, depositId }),
|
|
27
|
-
numberToHex(changeId, { size: 4 }),
|
|
28
|
-
]);
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
const hourFactor = BigInt(interval.hour) / BigInt(interval.second);
|
|
32
|
-
const dayFactor = BigInt(interval.day) / BigInt(interval.second);
|
|
33
|
-
const monthFactor = BigInt(interval.month) / BigInt(interval.second);
|
|
34
|
-
export const orderId = {
|
|
35
|
-
deposit: ({ chainId, depositId }) => concatHex([
|
|
36
|
-
numberToHex(depositId, { size: 8 }),
|
|
37
|
-
numberToHex(chainId, { size: 4 }),
|
|
38
|
-
]),
|
|
39
|
-
block: ({ timestamp, chainId }) => concatHex([
|
|
40
|
-
numberToHex(timestamp, { size: 8 }),
|
|
41
|
-
numberToHex(chainId, { size: 4 }),
|
|
42
|
-
]),
|
|
43
|
-
transaction: ({ timestamp, chainId, transactionIndex }) => concatHex([
|
|
44
|
-
numberToHex(timestamp, { size: 8 }),
|
|
45
|
-
numberToHex(transactionIndex, { size: 4 }),
|
|
46
|
-
numberToHex(chainId, { size: 4 }),
|
|
47
|
-
]),
|
|
48
|
-
log: ({ timestamp, chainId, transactionIndex, logIndex }) => concatHex([
|
|
49
|
-
numberToHex(timestamp, { size: 8 }),
|
|
50
|
-
numberToHex(transactionIndex, { size: 4 }),
|
|
51
|
-
numberToHex(logIndex, { size: 4 }),
|
|
52
|
-
numberToHex(chainId, { size: 4 }),
|
|
53
|
-
]),
|
|
54
|
-
order: ({ timestamp, chainId, transactionIndex, logIndex, name }) => concatHex([
|
|
55
|
-
numberToHex(timestamp, { size: 8 }),
|
|
56
|
-
numberToHex(transactionIndex, { size: 4 }),
|
|
57
|
-
numberToHex(eventOrderId.get(name), { size: 1 }),
|
|
58
|
-
numberToHex(logIndex, { size: 4 }),
|
|
59
|
-
numberToHex(chainId, { size: 4 }),
|
|
60
|
-
]),
|
|
61
|
-
stat: ({ timestamp, type, action, currency, verifier, token, chainId }) => {
|
|
62
|
-
const hour = (timestamp / hourFactor) * hourFactor;
|
|
63
|
-
const day = (timestamp / dayFactor) * dayFactor;
|
|
64
|
-
const month = (timestamp / monthFactor) * monthFactor;
|
|
65
|
-
let time = timestamp;
|
|
66
|
-
if (type === "hour") {
|
|
67
|
-
time = hour;
|
|
68
|
-
}
|
|
69
|
-
if (type === "day") {
|
|
70
|
-
time = day;
|
|
71
|
-
}
|
|
72
|
-
if (type === "month") {
|
|
73
|
-
time = month;
|
|
74
|
-
}
|
|
75
|
-
return concatHex([
|
|
76
|
-
numberToHex(time, { size: 8 }),
|
|
77
|
-
`0x${keccak256(concatHex([stringToHex(type), stringToHex(action), token, currency ?? '0x', verifier])).slice(26)}`,
|
|
78
|
-
numberToHex(chainId, { size: 4 }),
|
|
79
|
-
]);
|
|
80
|
-
},
|
|
81
|
-
};
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export * from './currencies.js';
|
|
2
|
-
export * from './units.js';
|
|
3
|
-
export * from './contracts.js';
|
|
4
|
-
export * from './participants.js';
|
|
5
|
-
export * from './chain.js';
|
|
6
|
-
export * from './intent.js';
|
|
7
|
-
export * from './conversionRates.js';
|
|
8
|
-
export * from './payment.js';
|
|
9
|
-
export * from './sort.js';
|
|
10
|
-
export * from './time.js';
|
|
11
|
-
export * from './tokens.js';
|
|
12
|
-
export * from './stats.js';
|
|
13
|
-
export * from './deposit.js';
|
|
14
|
-
export * from './ids.js';
|
|
15
|
-
export * from './events.js';
|
|
16
|
-
export * from './zkp2p-types.js';
|
package/dist/src/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export * from './currencies.js';
|
|
2
|
-
export * from './units.js';
|
|
3
|
-
export * from './contracts.js';
|
|
4
|
-
export * from './participants.js';
|
|
5
|
-
export * from './chain.js';
|
|
6
|
-
export * from './intent.js';
|
|
7
|
-
export * from './conversionRates.js';
|
|
8
|
-
export * from './payment.js';
|
|
9
|
-
export * from './sort.js';
|
|
10
|
-
export * from './time.js';
|
|
11
|
-
export * from './tokens.js';
|
|
12
|
-
export * from './stats.js';
|
|
13
|
-
export * from './deposit.js';
|
|
14
|
-
export * from './ids.js';
|
|
15
|
-
export * from './events.js';
|
|
16
|
-
export * from './zkp2p-types.js';
|
package/dist/src/input.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adjust the lowest decimal place directly on the string, preserving all trailing zeros
|
|
3
|
-
* @param inputVal - The input value
|
|
4
|
-
* @param direction - The direction to adjust the decimal place
|
|
5
|
-
* @returns The adjusted value
|
|
6
|
-
*/
|
|
7
|
-
export declare const adjustLowestDecimal: (inputVal: string, direction: 1 | -1) => string;
|
package/dist/src/intent.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Hex } from "viem";
|
|
2
|
-
/**
|
|
3
|
-
* Structure for an intent
|
|
4
|
-
*/
|
|
5
|
-
export interface IntentStruct {
|
|
6
|
-
owner: Hex;
|
|
7
|
-
to: Hex;
|
|
8
|
-
depositId: bigint;
|
|
9
|
-
amount: bigint;
|
|
10
|
-
timestamp: bigint;
|
|
11
|
-
paymentVerifier: Hex;
|
|
12
|
-
fiatCurrency: Hex;
|
|
13
|
-
conversionRate: bigint;
|
|
14
|
-
}
|
package/dist/src/json.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JSON serializer
|
|
3
|
-
*/
|
|
4
|
-
export declare const jsonSerializer: {
|
|
5
|
-
/**
|
|
6
|
-
* Parse a JSON string
|
|
7
|
-
* @param str - The JSON string to parse
|
|
8
|
-
* @returns The parsed object
|
|
9
|
-
*/
|
|
10
|
-
parse: (text: string, reviver?: (this: any, key: string, value: any) => any) => any;
|
|
11
|
-
/**
|
|
12
|
-
* Stringify an object
|
|
13
|
-
* @param obj - The object to stringify
|
|
14
|
-
* @returns The stringified object
|
|
15
|
-
*/
|
|
16
|
-
stringify: (obj: unknown) => string;
|
|
17
|
-
};
|
|
18
|
-
export declare function mapBigIntFields<T>(obj: T, fields: string[]): T;
|
package/dist/src/json.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JSON serializer
|
|
3
|
-
*/
|
|
4
|
-
export const jsonSerializer = {
|
|
5
|
-
/**
|
|
6
|
-
* Parse a JSON string
|
|
7
|
-
* @param str - The JSON string to parse
|
|
8
|
-
* @returns The parsed object
|
|
9
|
-
*/
|
|
10
|
-
parse: JSON.parse,
|
|
11
|
-
/**
|
|
12
|
-
* Stringify an object
|
|
13
|
-
* @param obj - The object to stringify
|
|
14
|
-
* @returns The stringified object
|
|
15
|
-
*/
|
|
16
|
-
stringify: (obj) => JSON.stringify(obj, (_key, value) => {
|
|
17
|
-
if (typeof value === 'bigint') {
|
|
18
|
-
return value.toString();
|
|
19
|
-
}
|
|
20
|
-
return value;
|
|
21
|
-
})
|
|
22
|
-
};
|
|
23
|
-
// Recursively convert specified fields to BigInt in an object or array
|
|
24
|
-
export function mapBigIntFields(obj, fields) {
|
|
25
|
-
if (Array.isArray(obj)) {
|
|
26
|
-
return obj.map(item => mapBigIntFields(item, fields));
|
|
27
|
-
}
|
|
28
|
-
if (obj && typeof obj === 'object') {
|
|
29
|
-
const result = {};
|
|
30
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
31
|
-
if (fields.includes(key) && typeof value === 'string' && value.match(/^-?\d+$/)) {
|
|
32
|
-
result[key] = BigInt(value);
|
|
33
|
-
}
|
|
34
|
-
else if (Array.isArray(value) || (value && typeof value === 'object')) {
|
|
35
|
-
result[key] = mapBigIntFields(value, fields);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
result[key] = value;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return result;
|
|
42
|
-
}
|
|
43
|
-
return obj;
|
|
44
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate a participantId from chainId and address using the same logic as the indexer
|
|
3
|
-
* @param chainId - The chain ID
|
|
4
|
-
* @param address - The address
|
|
5
|
-
* @returns The participant ID
|
|
6
|
-
*/
|
|
7
|
-
export declare function generateParticipantId(chainId: number | bigint, address: string): string;
|
package/dist/src/participants.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { concatHex, keccak256, numberToHex } from 'viem';
|
|
2
|
-
/**
|
|
3
|
-
* Generate a participantId from chainId and address using the same logic as the indexer
|
|
4
|
-
* @param chainId - The chain ID
|
|
5
|
-
* @param address - The address
|
|
6
|
-
* @returns The participant ID
|
|
7
|
-
*/
|
|
8
|
-
export function generateParticipantId(chainId, address) {
|
|
9
|
-
return keccak256(concatHex([
|
|
10
|
-
numberToHex(chainId, { size: 8 }),
|
|
11
|
-
address
|
|
12
|
-
]));
|
|
13
|
-
}
|
package/dist/src/payment.d.ts
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { type Hex } from "viem";
|
|
2
|
-
import type { TokenInfo } from "./tokens.js";
|
|
3
|
-
import type { ConversionRateInfo, ProviderRates } from "./conversionRates.js";
|
|
4
|
-
import { ChainId } from "./chain.js";
|
|
5
|
-
/**
|
|
6
|
-
* Payment providers, including manual
|
|
7
|
-
*/
|
|
8
|
-
export declare const providers: {
|
|
9
|
-
readonly VENMO: "venmo";
|
|
10
|
-
readonly ZELLE: "zelle";
|
|
11
|
-
readonly CASHAPP: "cashapp";
|
|
12
|
-
readonly REVOLUT: "revolut";
|
|
13
|
-
readonly WISE: "wise";
|
|
14
|
-
readonly MERCADOPAGO: "mercadopago";
|
|
15
|
-
readonly MANUAL: "manual";
|
|
16
|
-
readonly PAYPAL: "paypal";
|
|
17
|
-
readonly MONZO: "monzo";
|
|
18
|
-
};
|
|
19
|
-
export type ProviderKey = typeof providers[keyof typeof providers];
|
|
20
|
-
/** Distinct keys for payment sub-providers (currently only used by Zelle) */
|
|
21
|
-
export declare const subProviders: {
|
|
22
|
-
readonly CHASE: "chase";
|
|
23
|
-
readonly BANK_OF_AMERICA: "bank_of_america";
|
|
24
|
-
readonly CITI: "citi";
|
|
25
|
-
};
|
|
26
|
-
/** Sub-provider key (providers within providers) */
|
|
27
|
-
export type SubProviderKey = typeof subProviders[keyof typeof subProviders];
|
|
28
|
-
/** Action type for a provider */
|
|
29
|
-
export type ProviderKeyActionType = 'transfer' | 'send';
|
|
30
|
-
/** Validatable provider key */
|
|
31
|
-
export type ValidatableProviderKey = Exclude<ProviderKey, typeof providers.MANUAL>;
|
|
32
|
-
/** Transparent platforms */
|
|
33
|
-
export type TransparentPlatforms = typeof providers.ZELLE;
|
|
34
|
-
/** Platform key */
|
|
35
|
-
export type PlatformKey = Exclude<ValidatableProviderKey, TransparentPlatforms> | SubProviderKey;
|
|
36
|
-
/** Action type */
|
|
37
|
-
export type ActionType = `${ProviderKeyActionType}_${ProviderKey}`;
|
|
38
|
-
/** Provider key to validation key */
|
|
39
|
-
export declare const providerKeyToValidationKey: Record<ValidatableProviderKey, string>;
|
|
40
|
-
/** Validation key */
|
|
41
|
-
export type ValidationKey = typeof providerKeyToValidationKey[keyof typeof providerKeyToValidationKey];
|
|
42
|
-
/** Limits for a payment method */
|
|
43
|
-
export type Limits = {
|
|
44
|
-
min: number;
|
|
45
|
-
};
|
|
46
|
-
/** Send link options */
|
|
47
|
-
export type SendLinkOptions = {
|
|
48
|
-
username: string;
|
|
49
|
-
amount: bigint;
|
|
50
|
-
subProvider?: SubProviderKey;
|
|
51
|
-
qrCode?: boolean;
|
|
52
|
-
};
|
|
53
|
-
/** Send link */
|
|
54
|
-
export type SendLink = (options: SendLinkOptions) => string | null;
|
|
55
|
-
/** Payment sub-provider config */
|
|
56
|
-
export type PaymentSubProviderConfig = {
|
|
57
|
-
key: SubProviderKey;
|
|
58
|
-
name: string;
|
|
59
|
-
icon?: string;
|
|
60
|
-
color?: string;
|
|
61
|
-
usernameType?: string;
|
|
62
|
-
verifiers: (chain: ChainId) => Hex[];
|
|
63
|
-
sendLink: SendLink;
|
|
64
|
-
paymentMethod: number;
|
|
65
|
-
};
|
|
66
|
-
/** Payment config */
|
|
67
|
-
export type PaymentConfig = {
|
|
68
|
-
icon: string;
|
|
69
|
-
key: ProviderKey;
|
|
70
|
-
name: string;
|
|
71
|
-
color: string;
|
|
72
|
-
usernameType: string;
|
|
73
|
-
validationKey: ValidationKey | null;
|
|
74
|
-
verifiers: string[];
|
|
75
|
-
limits: Limits;
|
|
76
|
-
/**
|
|
77
|
-
* Set of sub-provider keys that this payment method supports. Empty when none.
|
|
78
|
-
*/
|
|
79
|
-
subProviders: Set<PaymentSubProviderConfig>;
|
|
80
|
-
list: Hex[];
|
|
81
|
-
sendLink?: SendLink;
|
|
82
|
-
};
|
|
83
|
-
/** Validation deposit data payment identifier */
|
|
84
|
-
export type ValidationDepositDataPaymentIdentifier = Partial<{
|
|
85
|
-
[key in Exclude<ValidationKey, null>]: string;
|
|
86
|
-
}>;
|
|
87
|
-
/** Validation deposit data */
|
|
88
|
-
export type ValidationDepositData = ValidationDepositDataPaymentIdentifier & {
|
|
89
|
-
telegramUsername: string;
|
|
90
|
-
};
|
|
91
|
-
/** Data encoding for zelle urls */
|
|
92
|
-
export declare const dataEncoding: (data: string) => string;
|
|
93
|
-
/** Default Zelle send link */
|
|
94
|
-
export declare const defaultZelleSendLink: (options: SendLinkOptions) => string | null;
|
|
95
|
-
/** Global configuration for all supported sub-providers. Other modules can import this directly. */
|
|
96
|
-
export declare const subProviderConfigs: Partial<Record<ProviderKey, Record<SubProviderKey, PaymentSubProviderConfig>>>;
|
|
97
|
-
/** Payment method icon mappings */
|
|
98
|
-
export declare const providerConfigs: (chainId: ChainId) => Record<ProviderKey, PaymentConfig>;
|
|
99
|
-
/** Payment verifier to key map */
|
|
100
|
-
export declare const paymentVerifierToKey: (chainId: ChainId | null) => Map<string, ProviderKey>;
|
|
101
|
-
/** Provider key to verifiers map */
|
|
102
|
-
export declare const providerKeyToVerifiersMap: (chainId: ChainId) => Map<ProviderKey, `0x${string}`[]>;
|
|
103
|
-
/** Provider key to verifiers */
|
|
104
|
-
export declare const providerKeyToVerifiers: (chainId: ChainId, providerKey: ProviderKey) => Hex[] | null;
|
|
105
|
-
/** Verifier gets key */
|
|
106
|
-
export declare const verifierGetsKey: (chainId: ChainId | null, verifierAddress: string) => ProviderKey;
|
|
107
|
-
/**
|
|
108
|
-
* Utility function to get payment method icon
|
|
109
|
-
* @param key - The provider key
|
|
110
|
-
* @returns The icon string used for iconify
|
|
111
|
-
*/
|
|
112
|
-
export declare const getPaymentIcon: (chainId: ChainId | null, key: ProviderKey) => string;
|
|
113
|
-
/**
|
|
114
|
-
* Utility function to get payment method configuration by verifier address
|
|
115
|
-
* @param verifierAddress - The verifier address
|
|
116
|
-
* @returns The payment method configuration
|
|
117
|
-
*/
|
|
118
|
-
export declare const getPaymentMethodConfig: (chainId: ChainId | null, verifierAddress: string) => PaymentConfig | null;
|
|
119
|
-
/**
|
|
120
|
-
* Utility function to get payment method minimum limit by verifier address
|
|
121
|
-
* @param key - The provider key
|
|
122
|
-
* @returns The minimum limit
|
|
123
|
-
*/
|
|
124
|
-
export declare const getPaymentMethodMinimum: (chainId: ChainId | null, key: ProviderKey) => number;
|
|
125
|
-
/**
|
|
126
|
-
* Utility function to get payment method name by verifier address
|
|
127
|
-
*/
|
|
128
|
-
export declare const getPaymentMethodName: (chainId: ChainId | null, verifierAddress: string | ProviderKey) => string;
|
|
129
|
-
/**
|
|
130
|
-
* Calculate effective minimum amount (higher of user minimum or payment provider minimum)
|
|
131
|
-
* @param userMinAmountWei - The user minimum amount
|
|
132
|
-
* @param tokenInfo - The token info
|
|
133
|
-
* @param providerRates - The provider rates
|
|
134
|
-
* @returns The effective minimum amount
|
|
135
|
-
*/
|
|
136
|
-
export declare function calculateEffectiveMinimum(chainId: ChainId, userMinAmountWei: string | bigint, tokenInfo: TokenInfo, providerRates?: ProviderRates<ConversionRateInfo>): {
|
|
137
|
-
userMinAmountWei: bigint;
|
|
138
|
-
providerMinAmountWei: bigint;
|
|
139
|
-
effectiveMinAmountWei: bigint;
|
|
140
|
-
formattedEffectiveMin: string;
|
|
141
|
-
};
|
|
142
|
-
/**
|
|
143
|
-
* Helper function to get payment provider minimum limit (returns decimal number for config)
|
|
144
|
-
* @param key - The provider key
|
|
145
|
-
* @returns The minimum limit
|
|
146
|
-
*/
|
|
147
|
-
export declare function getPaymentProviderMinimum(chainId: ChainId, key: ProviderKey): number;
|
|
148
|
-
/**
|
|
149
|
-
* Check if a payment method is known
|
|
150
|
-
* @param chainId - The chain ID
|
|
151
|
-
* @param verifierAddress - The verifier address
|
|
152
|
-
* @returns True if the payment method is known, false otherwise
|
|
153
|
-
*/
|
|
154
|
-
export declare const isPaymentMethodKnown: (chainId: ChainId | null, verifierAddress: string) => boolean;
|
|
155
|
-
/**
|
|
156
|
-
* Get all payment methods
|
|
157
|
-
* @returns All payment methods
|
|
158
|
-
*/
|
|
159
|
-
export declare const getAllPaymentMethods: (chainId: ChainId) => ProviderKey[];
|
|
160
|
-
/**
|
|
161
|
-
* Get all verifiable payment methods
|
|
162
|
-
* @returns All verifiable payment methods
|
|
163
|
-
*/
|
|
164
|
-
export declare const verifiablePaymentMethods: (chainId: ChainId) => ProviderKey[];
|