@gibs/bridge-client 1.29.0 → 1.32.0
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/block-polling/package.json +6 -0
- package/coinbase-accept-list/package.json +6 -0
- package/dist/block-polling.d.ts +33 -0
- package/dist/block-polling.js +10 -0
- package/dist/cjs/block-polling.d.ts +33 -0
- package/dist/cjs/block-polling.js +15 -0
- package/dist/cjs/client.d.ts +9 -1
- package/dist/cjs/client.js +8 -5
- package/dist/cjs/coinbase-accept-list.d.ts +101 -0
- package/dist/cjs/coinbase-accept-list.js +97 -0
- package/dist/cjs/crossing-decision.d.ts +166 -0
- package/dist/cjs/crossing-decision.js +169 -0
- package/dist/cjs/crossing-vector-guard.d.ts +45 -0
- package/dist/cjs/crossing-vector-guard.js +139 -0
- package/dist/cjs/exchange-deposit-board.d.ts +50 -0
- package/dist/cjs/exchange-deposit-board.js +70 -0
- package/dist/cjs/exchange-deposit-chain.d.ts +146 -0
- package/dist/cjs/exchange-deposit-chain.js +228 -0
- package/dist/cjs/exchange-deposit-constants.d.ts +10 -0
- package/dist/cjs/exchange-deposit-constants.js +6 -0
- package/dist/cjs/exchange-deposit-factory-calls.d.ts +245 -0
- package/dist/cjs/exchange-deposit-factory-calls.js +103 -0
- package/dist/cjs/exchange-deposit-factory.d.ts +87 -0
- package/dist/cjs/exchange-deposit-factory.js +110 -0
- package/dist/cjs/exchange-deposit-fake.d.ts +67 -0
- package/dist/cjs/exchange-deposit-fake.js +179 -0
- package/dist/cjs/exchange-deposit-index.d.ts +77 -0
- package/dist/cjs/exchange-deposit-index.js +40 -0
- package/dist/cjs/exchange-deposit-issuance.d.ts +327 -0
- package/dist/cjs/exchange-deposit-issuance.js +244 -0
- package/dist/cjs/exchange-deposit-path.d.ts +16 -0
- package/dist/cjs/exchange-deposit-path.js +15 -0
- package/dist/cjs/exchange-deposit-pow.d.ts +163 -0
- package/dist/cjs/exchange-deposit-pow.js +101 -0
- package/dist/cjs/exchange-deposit-recipient.d.ts +66 -0
- package/dist/cjs/exchange-deposit-recipient.js +35 -0
- package/dist/cjs/exchange-deposit-self-cross.d.ts +163 -0
- package/dist/cjs/exchange-deposit-self-cross.js +60 -0
- package/dist/cjs/exchange-deposit-signin.d.ts +275 -0
- package/dist/cjs/exchange-deposit-signin.js +166 -0
- package/dist/cjs/exchange-deposit-watch.d.ts +133 -0
- package/dist/cjs/exchange-deposit-watch.js +58 -0
- package/dist/cjs/exchange-deposit.d.ts +440 -0
- package/dist/cjs/exchange-deposit.js +154 -0
- package/dist/cjs/exchange-sender-guides.d.ts +29 -0
- package/dist/cjs/exchange-sender-guides.js +25 -0
- package/dist/cjs/image.d.ts +18 -0
- package/dist/cjs/image.js +11 -9
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.js +32 -1
- package/dist/cjs/kraken-accept-list.d.ts +70 -0
- package/dist/cjs/kraken-accept-list.js +24 -0
- package/dist/cjs/unlisted-token.d.ts +26 -0
- package/dist/cjs/unlisted-token.js +34 -0
- package/dist/client.d.ts +9 -1
- package/dist/client.js +8 -5
- package/dist/coinbase-accept-list.d.ts +101 -0
- package/dist/coinbase-accept-list.js +89 -0
- package/dist/crossing-decision.d.ts +166 -0
- package/dist/crossing-decision.js +162 -0
- package/dist/crossing-vector-guard.d.ts +45 -0
- package/dist/crossing-vector-guard.js +134 -0
- package/dist/exchange-deposit-board.d.ts +50 -0
- package/dist/exchange-deposit-board.js +28 -0
- package/dist/exchange-deposit-chain.d.ts +146 -0
- package/dist/exchange-deposit-chain.js +218 -0
- package/dist/exchange-deposit-constants.d.ts +10 -0
- package/dist/exchange-deposit-constants.js +3 -0
- package/dist/exchange-deposit-factory-calls.d.ts +245 -0
- package/dist/exchange-deposit-factory-calls.js +97 -0
- package/dist/exchange-deposit-factory.d.ts +87 -0
- package/dist/exchange-deposit-factory.js +104 -0
- package/dist/exchange-deposit-fake.d.ts +67 -0
- package/dist/exchange-deposit-fake.js +171 -0
- package/dist/exchange-deposit-index.d.ts +77 -0
- package/dist/exchange-deposit-index.js +34 -0
- package/dist/exchange-deposit-issuance.d.ts +327 -0
- package/dist/exchange-deposit-issuance.js +224 -0
- package/dist/exchange-deposit-path.d.ts +16 -0
- package/dist/exchange-deposit-path.js +11 -0
- package/dist/exchange-deposit-pow.d.ts +163 -0
- package/dist/exchange-deposit-pow.js +93 -0
- package/dist/exchange-deposit-recipient.d.ts +66 -0
- package/dist/exchange-deposit-recipient.js +28 -0
- package/dist/exchange-deposit-self-cross.d.ts +163 -0
- package/dist/exchange-deposit-self-cross.js +46 -0
- package/dist/exchange-deposit-signin.d.ts +275 -0
- package/dist/exchange-deposit-signin.js +147 -0
- package/dist/exchange-deposit-watch.d.ts +133 -0
- package/dist/exchange-deposit-watch.js +44 -0
- package/dist/exchange-deposit.d.ts +440 -0
- package/dist/exchange-deposit.js +138 -0
- package/dist/exchange-sender-guides.d.ts +29 -0
- package/dist/exchange-sender-guides.js +21 -0
- package/dist/image.d.ts +18 -0
- package/dist/image.js +8 -8
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/kraken-accept-list.d.ts +70 -0
- package/dist/kraken-accept-list.js +17 -0
- package/dist/unlisted-token.d.ts +26 -0
- package/dist/unlisted-token.js +30 -0
- package/exchange-deposit/package.json +6 -0
- package/exchange-deposit-board/package.json +6 -0
- package/exchange-deposit-chain/package.json +6 -0
- package/exchange-deposit-factory/package.json +6 -0
- package/exchange-deposit-fake/package.json +6 -0
- package/exchange-deposit-issuance/package.json +6 -0
- package/exchange-deposit-path/package.json +6 -0
- package/exchange-deposit-pow/package.json +6 -0
- package/exchange-deposit-recipient/package.json +6 -0
- package/exchange-deposit-self-cross/package.json +6 -0
- package/exchange-deposit-signin/package.json +6 -0
- package/exchange-deposit-watch/package.json +6 -0
- package/exchange-sender-guides/package.json +6 -0
- package/kraken-accept-list/package.json +6 -0
- package/llms.txt +1 -0
- package/package.json +487 -6
- package/unlisted-token/package.json +6 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { type Hex } from 'viem';
|
|
2
|
+
import type { WorkStats } from '@msgboard/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* The proof-of-work engine a page may use. It names the WebAssembly build only. This module imports nothing from the
|
|
5
|
+
* msgboard SDK at run time, so the proof-of-work worker stays small: it loads only this file and the grinder.
|
|
6
|
+
*
|
|
7
|
+
* THE ENGINE CONTRACT. The engine searches consecutive nonces from `startNonce`, and it returns the absolute nonce it
|
|
8
|
+
* found. A grind is cut into calls of `attemptsPerCall` nonces, so the worker can report progress between calls.
|
|
9
|
+
*/
|
|
10
|
+
export declare const POW_ENGINE_WEBASSEMBLY: "webassembly";
|
|
11
|
+
/** The nonces tried in one engine call. Small enough that progress is reported about once a second. */
|
|
12
|
+
export declare const ATTEMPTS_PER_CALL = 1000000;
|
|
13
|
+
/** The most nonces a grind may try before it gives up. A stamp at any real difficulty is far below this. */
|
|
14
|
+
export declare const MAXIMUM_ATTEMPTS: number;
|
|
15
|
+
/**
|
|
16
|
+
* Raised when the WebAssembly engine cannot load, fails its self-test, or stops in the middle of a grind. There is no
|
|
17
|
+
* fallback: the caller shows the reason and the post does not happen.
|
|
18
|
+
*/
|
|
19
|
+
export declare class PowEngineUnavailableError extends Error {
|
|
20
|
+
/** Why the engine cannot run, in plain words. */
|
|
21
|
+
readonly reason: string;
|
|
22
|
+
/** @param reason - Why the engine cannot run. */
|
|
23
|
+
constructor(reason: string);
|
|
24
|
+
}
|
|
25
|
+
/** The request the grinder's `stamp` export takes. `version` is always 1. */
|
|
26
|
+
export interface PowEngineRequest {
|
|
27
|
+
readonly category: Uint8Array;
|
|
28
|
+
readonly data: Uint8Array;
|
|
29
|
+
readonly workMultiplier: number;
|
|
30
|
+
readonly workDivisor: number;
|
|
31
|
+
readonly blockHash: Uint8Array;
|
|
32
|
+
readonly version: number;
|
|
33
|
+
readonly startNonce: number;
|
|
34
|
+
readonly maxIters: number;
|
|
35
|
+
}
|
|
36
|
+
/** The grinder's raw `stamp` export: 40 bytes (nonce then hash) when it finds one, or nothing when the budget ran out. */
|
|
37
|
+
export type PowEngineStamp = (request: PowEngineRequest) => Uint8Array | null | undefined;
|
|
38
|
+
/** The two pieces the loader needs. Injectable, so tests can make each one fail. */
|
|
39
|
+
export interface PowEngineModule {
|
|
40
|
+
/** Instantiates the WebAssembly module. */
|
|
41
|
+
readonly init: () => Promise<unknown>;
|
|
42
|
+
/** The grinder's raw `stamp` export. */
|
|
43
|
+
readonly stamp: PowEngineStamp;
|
|
44
|
+
}
|
|
45
|
+
/** What a stamp is asked to grind. The same shape the msgboard SDK sends its stamper. */
|
|
46
|
+
export interface StampInput {
|
|
47
|
+
readonly category: Hex;
|
|
48
|
+
readonly data: Hex;
|
|
49
|
+
readonly workMultiplier: bigint;
|
|
50
|
+
readonly workDivisor: bigint;
|
|
51
|
+
readonly blockHash: Hex;
|
|
52
|
+
}
|
|
53
|
+
/** A found stamp: the winning nonce and the hash it produces. */
|
|
54
|
+
export interface Stamp {
|
|
55
|
+
readonly nonce: bigint;
|
|
56
|
+
readonly hash: Hex;
|
|
57
|
+
}
|
|
58
|
+
/** A stamper: grinds one input. It is the shape the msgboard SDK accepts as its `stamper`. */
|
|
59
|
+
export type Stamper = (input: StampInput) => Stamp | Promise<Stamp>;
|
|
60
|
+
/**
|
|
61
|
+
* The cheapest valid stamp request. The difficulty is (2^24 + 10000 * data length) * multiplier / divisor, so an empty
|
|
62
|
+
* payload with multiplier 1 and divisor 2^24 gives difficulty 1. The first nonce passes.
|
|
63
|
+
*/
|
|
64
|
+
export declare const SELF_TEST_INPUT: StampInput;
|
|
65
|
+
/** Options for one grind. */
|
|
66
|
+
export interface GrindOptions {
|
|
67
|
+
/** Nonces tried per engine call. Defaults to {@link ATTEMPTS_PER_CALL}. */
|
|
68
|
+
readonly attemptsPerCall?: number;
|
|
69
|
+
/** Receives the number of nonces tried so far, after each call that found nothing. */
|
|
70
|
+
readonly onAttempts?: (attempts: number) => void;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Grind one input with the engine, in calls of `attemptsPerCall` nonces. The stamp returned carries the absolute nonce,
|
|
74
|
+
* so a grind split into small calls finds the same stamp as one large call.
|
|
75
|
+
*
|
|
76
|
+
* @param engine - the grinder's `stamp` export
|
|
77
|
+
* @param input - the message to grind
|
|
78
|
+
* @param options - the call size and the progress receiver
|
|
79
|
+
* @throws when no nonce is found within {@link MAXIMUM_ATTEMPTS}
|
|
80
|
+
*/
|
|
81
|
+
export declare const grindWithEngine: (engine: PowEngineStamp, input: StampInput, options?: GrindOptions) => Stamp;
|
|
82
|
+
/** A verified engine: its grind throws {@link PowEngineUnavailableError} when the engine fails. */
|
|
83
|
+
export interface VerifiedEngine {
|
|
84
|
+
/**
|
|
85
|
+
* Grind one input. Progress arrives through `onAttempts`.
|
|
86
|
+
*
|
|
87
|
+
* @param input - the message to grind
|
|
88
|
+
* @param onAttempts - receives the attempts so far
|
|
89
|
+
*/
|
|
90
|
+
readonly grind: (input: StampInput, onAttempts: (attempts: number) => void) => Stamp;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Load the WebAssembly engine and run the self-test. Nothing is returned unless the self-test stamp is well formed.
|
|
94
|
+
*
|
|
95
|
+
* @param engine - the engine's `init` and `stamp`
|
|
96
|
+
* @throws {PowEngineUnavailableError} when loading or the self-test fails
|
|
97
|
+
*/
|
|
98
|
+
export declare const loadVerifiedEngine: (engine: PowEngineModule) => Promise<VerifiedEngine>;
|
|
99
|
+
/** A stamper plus a record of whether the stamper threw. */
|
|
100
|
+
export interface GuardedStamper {
|
|
101
|
+
/** Pass this to the client. */
|
|
102
|
+
readonly stamper: Stamper;
|
|
103
|
+
/** The halt error once the stamper has thrown, or null while it has not. */
|
|
104
|
+
readonly failure: () => PowEngineUnavailableError | null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Wrap a stamper so a thrown error is remembered and `onFailure` runs. The msgboard SDK swallows a stamper error and
|
|
108
|
+
* grinds in JavaScript instead, so `onFailure` is where the caller stops the client.
|
|
109
|
+
*
|
|
110
|
+
* @param stamper - the stamper to wrap
|
|
111
|
+
* @param onFailure - called with the error, once for each throw
|
|
112
|
+
*/
|
|
113
|
+
export declare const guardStamper: (stamper: Stamper, onFailure: () => void) => GuardedStamper;
|
|
114
|
+
/** What the page shows while a grind runs. Numbers only, so it crosses a thread boundary as it is. */
|
|
115
|
+
export interface PowProgress {
|
|
116
|
+
/** Nonces tried so far. */
|
|
117
|
+
readonly attempts: number;
|
|
118
|
+
/** The difficulty of the message being ground. */
|
|
119
|
+
readonly difficulty: number;
|
|
120
|
+
/** Seconds since the grind began. */
|
|
121
|
+
readonly elapsedSeconds: number;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The page's view of the msgboard statistics. Big integers become plain numbers, which the page can show.
|
|
125
|
+
*
|
|
126
|
+
* @param stats - the statistics the msgboard SDK reports
|
|
127
|
+
*/
|
|
128
|
+
export declare const progressOf: (stats: WorkStats) => PowProgress;
|
|
129
|
+
/**
|
|
130
|
+
* What the page asks of the proof-of-work worker. Every request carries an `id`, so replies can be matched to it. `check`
|
|
131
|
+
* proves the engine runs. `grind` returns one stamp for one input.
|
|
132
|
+
*/
|
|
133
|
+
export type PowWorkerRequest = {
|
|
134
|
+
readonly id: number;
|
|
135
|
+
readonly type: 'check';
|
|
136
|
+
} | {
|
|
137
|
+
readonly id: number;
|
|
138
|
+
readonly type: 'grind';
|
|
139
|
+
readonly input: StampInput;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* What the worker answers. `ready` means the engine passed its self-test. `progress` counts the attempts of a grind.
|
|
143
|
+
* `error` carries `isEngineUnavailable`, which is true only when the WebAssembly engine itself failed. The page treats
|
|
144
|
+
* that as a stop, not a retry in JavaScript.
|
|
145
|
+
*/
|
|
146
|
+
export type PowWorkerResponse = {
|
|
147
|
+
readonly id: number;
|
|
148
|
+
readonly type: 'ready';
|
|
149
|
+
readonly engine: typeof POW_ENGINE_WEBASSEMBLY;
|
|
150
|
+
} | {
|
|
151
|
+
readonly id: number;
|
|
152
|
+
readonly type: 'progress';
|
|
153
|
+
readonly attempts: number;
|
|
154
|
+
} | {
|
|
155
|
+
readonly id: number;
|
|
156
|
+
readonly type: 'stamped';
|
|
157
|
+
readonly stamp: Stamp;
|
|
158
|
+
} | {
|
|
159
|
+
readonly id: number;
|
|
160
|
+
readonly type: 'error';
|
|
161
|
+
readonly message: string;
|
|
162
|
+
readonly isEngineUnavailable: boolean;
|
|
163
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.progressOf = exports.guardStamper = exports.loadVerifiedEngine = exports.grindWithEngine = exports.SELF_TEST_INPUT = exports.PowEngineUnavailableError = exports.MAXIMUM_ATTEMPTS = exports.ATTEMPTS_PER_CALL = exports.POW_ENGINE_WEBASSEMBLY = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
exports.POW_ENGINE_WEBASSEMBLY = 'webassembly';
|
|
6
|
+
exports.ATTEMPTS_PER_CALL = 1_000_000;
|
|
7
|
+
exports.MAXIMUM_ATTEMPTS = 2 ** 40;
|
|
8
|
+
class PowEngineUnavailableError extends Error {
|
|
9
|
+
reason;
|
|
10
|
+
constructor(reason) {
|
|
11
|
+
super(`proof of work unavailable: ${reason}`);
|
|
12
|
+
this.name = 'PowEngineUnavailableError';
|
|
13
|
+
this.reason = reason;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.PowEngineUnavailableError = PowEngineUnavailableError;
|
|
17
|
+
exports.SELF_TEST_INPUT = {
|
|
18
|
+
category: `0x${'11'.repeat(32)}`,
|
|
19
|
+
data: '0x',
|
|
20
|
+
workMultiplier: 1n,
|
|
21
|
+
workDivisor: 2n ** 24n,
|
|
22
|
+
blockHash: `0x${'22'.repeat(32)}`,
|
|
23
|
+
};
|
|
24
|
+
const HASH_PATTERN = /^0x[0-9a-f]{64}$/i;
|
|
25
|
+
const describeFailure = (error) => (error instanceof Error ? error.message : String(error));
|
|
26
|
+
const stampOf = (answer) => ({
|
|
27
|
+
nonce: BigInt((0, viem_1.bytesToHex)(answer.subarray(0, 8))),
|
|
28
|
+
hash: (0, viem_1.bytesToHex)(answer.subarray(8, 40)),
|
|
29
|
+
});
|
|
30
|
+
const isWellFormedStamp = (stamp) => typeof stamp.nonce === 'bigint' && stamp.nonce >= 0n && HASH_PATTERN.test(stamp.hash);
|
|
31
|
+
const grindWithEngine = (engine, input, options = {}) => {
|
|
32
|
+
const attemptsPerCall = options.attemptsPerCall ?? exports.ATTEMPTS_PER_CALL;
|
|
33
|
+
const onAttempts = options.onAttempts ?? (() => undefined);
|
|
34
|
+
const fixed = {
|
|
35
|
+
category: (0, viem_1.hexToBytes)(input.category, { size: 32 }),
|
|
36
|
+
data: (0, viem_1.hexToBytes)(input.data),
|
|
37
|
+
workMultiplier: Number(input.workMultiplier),
|
|
38
|
+
workDivisor: Number(input.workDivisor),
|
|
39
|
+
blockHash: (0, viem_1.hexToBytes)(input.blockHash, { size: 32 }),
|
|
40
|
+
version: 1,
|
|
41
|
+
};
|
|
42
|
+
for (let startNonce = 0; startNonce < exports.MAXIMUM_ATTEMPTS; startNonce += attemptsPerCall) {
|
|
43
|
+
const answer = engine({ ...fixed, startNonce, maxIters: attemptsPerCall });
|
|
44
|
+
if (answer !== undefined && answer !== null)
|
|
45
|
+
return stampOf(answer);
|
|
46
|
+
onAttempts(startNonce + attemptsPerCall);
|
|
47
|
+
}
|
|
48
|
+
throw new Error(`no nonce found within ${exports.MAXIMUM_ATTEMPTS} attempts`);
|
|
49
|
+
};
|
|
50
|
+
exports.grindWithEngine = grindWithEngine;
|
|
51
|
+
const loadVerifiedEngine = async (engine) => {
|
|
52
|
+
try {
|
|
53
|
+
await engine.init();
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
throw new PowEngineUnavailableError(`WebAssembly failed to load (${describeFailure(error)})`);
|
|
57
|
+
}
|
|
58
|
+
let selfTest;
|
|
59
|
+
try {
|
|
60
|
+
selfTest = (0, exports.grindWithEngine)(engine.stamp, exports.SELF_TEST_INPUT);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
throw new PowEngineUnavailableError(`self-test failed (${describeFailure(error)})`);
|
|
64
|
+
}
|
|
65
|
+
if (!isWellFormedStamp(selfTest))
|
|
66
|
+
throw new PowEngineUnavailableError('self-test returned a malformed stamp');
|
|
67
|
+
return {
|
|
68
|
+
grind: (input, onAttempts) => {
|
|
69
|
+
try {
|
|
70
|
+
return (0, exports.grindWithEngine)(engine.stamp, input, { onAttempts });
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
throw new PowEngineUnavailableError(`stamp failed (${describeFailure(error)})`);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
exports.loadVerifiedEngine = loadVerifiedEngine;
|
|
79
|
+
const guardStamper = (stamper, onFailure) => {
|
|
80
|
+
let failed = null;
|
|
81
|
+
return {
|
|
82
|
+
stamper: async (input) => {
|
|
83
|
+
try {
|
|
84
|
+
return await stamper(input);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
failed = new PowEngineUnavailableError(`stamp failed (${describeFailure(error)})`);
|
|
88
|
+
onFailure();
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
failure: () => failed,
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
exports.guardStamper = guardStamper;
|
|
96
|
+
const progressOf = (stats) => ({
|
|
97
|
+
attempts: Number(stats.iterations),
|
|
98
|
+
difficulty: Number(stats.difficulty),
|
|
99
|
+
elapsedSeconds: stats.duration / 1000,
|
|
100
|
+
});
|
|
101
|
+
exports.progressOf = progressOf;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type Address } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* Reading a recipient the reader typed or pasted.
|
|
4
|
+
*
|
|
5
|
+
* The deposit address depends only on its settings, so ANY PulseChain address can
|
|
6
|
+
* be the recipient: a cold wallet needs no connection. The connected wallet is
|
|
7
|
+
* only the default.
|
|
8
|
+
*/
|
|
9
|
+
/** What reading a recipient found. */
|
|
10
|
+
export type RecipientReading = {
|
|
11
|
+
readonly status: 'empty';
|
|
12
|
+
} | {
|
|
13
|
+
readonly status: 'malformed';
|
|
14
|
+
} | {
|
|
15
|
+
readonly status: 'bad-checksum';
|
|
16
|
+
} | {
|
|
17
|
+
readonly status: 'zero-address';
|
|
18
|
+
} | {
|
|
19
|
+
readonly status: 'valid';
|
|
20
|
+
readonly address: Address;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Reads a recipient.
|
|
24
|
+
*
|
|
25
|
+
* - An all-lowercase or all-uppercase address is accepted, and the checksummed
|
|
26
|
+
* form is returned so the reader sees what will be used.
|
|
27
|
+
* - A mixed-case address must carry the right checksum. A wrong one is the
|
|
28
|
+
* typo the checksum exists to catch, so it is refused.
|
|
29
|
+
* - The zero address is refused: nothing can be received there.
|
|
30
|
+
*
|
|
31
|
+
* @param input - the text, as typed or pasted
|
|
32
|
+
*/
|
|
33
|
+
export declare const readRecipient: (input: string) => RecipientReading;
|
|
34
|
+
/**
|
|
35
|
+
* Whether two addresses are the same address, ignoring case.
|
|
36
|
+
*
|
|
37
|
+
* @param left - an address, or null
|
|
38
|
+
* @param right - an address, or null
|
|
39
|
+
*/
|
|
40
|
+
export declare const sameAddress: (left: string | null, right: string | null) => boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the recipient is a different address from the connected wallet. With no wallet connected there is no
|
|
43
|
+
* default to differ from, so nothing differs. The page warns on a true answer before any address can be copied.
|
|
44
|
+
*
|
|
45
|
+
* @param input.recipient - the recipient the funds reach
|
|
46
|
+
* @param input.connected - the connected wallet, or null when none is connected
|
|
47
|
+
* @returns true only when a wallet is connected and the recipient is not its address
|
|
48
|
+
*/
|
|
49
|
+
export declare const recipientDiffersFromWallet: ({ recipient, connected, }: {
|
|
50
|
+
recipient: string;
|
|
51
|
+
connected: string | null;
|
|
52
|
+
}) => boolean;
|
|
53
|
+
/** The picture that stands for an address: a mirrored grid of cells and a hue. */
|
|
54
|
+
export interface RecipientIdenticon {
|
|
55
|
+
/** Hue in degrees, 0 to 359. */
|
|
56
|
+
readonly hue: number;
|
|
57
|
+
/** Five rows of five cells; true is filled. Mirrored left to right. */
|
|
58
|
+
readonly cells: readonly (readonly boolean[])[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A small picture for an address, so a changed address looks different at a
|
|
62
|
+
* glance. Pure: the same address always gives the same picture.
|
|
63
|
+
*
|
|
64
|
+
* @param address - the address
|
|
65
|
+
*/
|
|
66
|
+
export declare const recipientIdenticon: (address: string) => RecipientIdenticon;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.recipientIdenticon = exports.recipientDiffersFromWallet = exports.sameAddress = exports.readRecipient = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const readRecipient = (input) => {
|
|
6
|
+
const text = input.trim();
|
|
7
|
+
if (text === '')
|
|
8
|
+
return { status: 'empty' };
|
|
9
|
+
if (!/^0x[0-9a-fA-F]{40}$/.test(text))
|
|
10
|
+
return { status: 'malformed' };
|
|
11
|
+
const lowered = text.slice(2).toLowerCase();
|
|
12
|
+
const isMixedCase = text.slice(2) !== lowered && text.slice(2) !== text.slice(2).toUpperCase();
|
|
13
|
+
if (isMixedCase && !(0, viem_1.isAddress)(text, { strict: true }))
|
|
14
|
+
return { status: 'bad-checksum' };
|
|
15
|
+
const address = (0, viem_1.getAddress)(text.toLowerCase());
|
|
16
|
+
if (address === (0, viem_1.getAddress)(viem_1.zeroAddress))
|
|
17
|
+
return { status: 'zero-address' };
|
|
18
|
+
return { status: 'valid', address };
|
|
19
|
+
};
|
|
20
|
+
exports.readRecipient = readRecipient;
|
|
21
|
+
const sameAddress = (left, right) => left !== null && right !== null && left.toLowerCase() === right.toLowerCase();
|
|
22
|
+
exports.sameAddress = sameAddress;
|
|
23
|
+
const recipientDiffersFromWallet = ({ recipient, connected, }) => connected !== null && !(0, exports.sameAddress)(recipient, connected);
|
|
24
|
+
exports.recipientDiffersFromWallet = recipientDiffersFromWallet;
|
|
25
|
+
const recipientIdenticon = (address) => {
|
|
26
|
+
const digits = address.toLowerCase().replace(/^0x/, '');
|
|
27
|
+
const nibble = (position) => Number.parseInt(digits[position] ?? '0', 16);
|
|
28
|
+
const hue = (Number.parseInt(digits.slice(0, 4), 16) % 360);
|
|
29
|
+
const cells = Array.from({ length: 5 }, (_, row) => {
|
|
30
|
+
const left = [0, 1, 2].map((column) => nibble(4 + row * 3 + column) % 2 === 1);
|
|
31
|
+
return [left[0], left[1], left[2], left[1], left[0]];
|
|
32
|
+
});
|
|
33
|
+
return { hue, cells };
|
|
34
|
+
};
|
|
35
|
+
exports.recipientIdenticon = recipientIdenticon;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { type Address } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* The fee rate of an address that takes no fee. The validators do not cross it, so the reader crosses it alone and
|
|
4
|
+
* pays the Ethereum gas. Zero is 0 percent, in 1e18 fixed point.
|
|
5
|
+
*/
|
|
6
|
+
export declare const NO_FEE_RATE_E18 = 0n;
|
|
7
|
+
/**
|
|
8
|
+
* How many times the flush gas the reader's ether must cover before "No fee" becomes the default. The margin leaves
|
|
9
|
+
* room for the gas price to rise between the page's read and the press.
|
|
10
|
+
*/
|
|
11
|
+
export declare const SELF_CROSS_GAS_MARGIN_MULTIPLE = 2n;
|
|
12
|
+
/** The deposit amount that the "per $100" figure states a fee for, when the reader's amount is not known. */
|
|
13
|
+
export declare const PER_HUNDRED_DOLLARS = 100;
|
|
14
|
+
/** The flush of one address, read from the gas table of its network. */
|
|
15
|
+
export type SelfCrossInput = {
|
|
16
|
+
/** The Ethereum chain the flush runs on. */
|
|
17
|
+
readonly chainId: bigint;
|
|
18
|
+
/** The token of the deposit. The zero address is ether. */
|
|
19
|
+
readonly tokenAddress: Address;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The gas limit of one flush, before the refund, from the network's table. Use it for the limit and for the
|
|
23
|
+
* affordability check, because the node needs that much available while the flush runs.
|
|
24
|
+
*
|
|
25
|
+
* @param input.chainId - the Ethereum chain the flush runs on
|
|
26
|
+
* @param input.tokenAddress - the token of the deposit
|
|
27
|
+
* @throws when the interface chose no gas table for the chain
|
|
28
|
+
*/
|
|
29
|
+
export declare const selfCrossGasLimitOf: ({ chainId, tokenAddress }: SelfCrossInput) => bigint;
|
|
30
|
+
/**
|
|
31
|
+
* The gas one flush really uses, after the refund. Use it for the cost the reader sees.
|
|
32
|
+
*
|
|
33
|
+
* @param input.chainId - the Ethereum chain the flush runs on
|
|
34
|
+
* @param input.tokenAddress - the token of the deposit
|
|
35
|
+
* @throws when the interface chose no gas table for the chain
|
|
36
|
+
*/
|
|
37
|
+
export declare const selfCrossPaidGasOf: ({ chainId, tokenAddress }: SelfCrossInput) => bigint;
|
|
38
|
+
/**
|
|
39
|
+
* The cost, in wei of ether, of crossing one address alone at a gas price.
|
|
40
|
+
*
|
|
41
|
+
* @param input.chainId - the Ethereum chain the flush runs on
|
|
42
|
+
* @param input.tokenAddress - the token of the deposit
|
|
43
|
+
* @param input.gasPriceWei - the gas price per unit, in wei
|
|
44
|
+
*/
|
|
45
|
+
export declare const selfCrossCostWeiOf: ({ chainId, tokenAddress, gasPriceWei, }: SelfCrossInput & {
|
|
46
|
+
readonly gasPriceWei: bigint;
|
|
47
|
+
}) => bigint;
|
|
48
|
+
/**
|
|
49
|
+
* Whether the reader's ether on the network covers the flush gas, with the margin, at the gas price now. An unread
|
|
50
|
+
* gas price is never affordable.
|
|
51
|
+
*
|
|
52
|
+
* @param input.balanceWei - the reader's ether on the network, in wei
|
|
53
|
+
* @param input.chainId - the Ethereum chain the flush runs on
|
|
54
|
+
* @param input.tokenAddress - the token of the deposit
|
|
55
|
+
* @param input.gasPriceWei - the gas price now, in wei per unit, or null when the page has not read it
|
|
56
|
+
*/
|
|
57
|
+
export declare const isSelfCrossAffordable: ({ balanceWei, chainId, tokenAddress, gasPriceWei, }: SelfCrossInput & {
|
|
58
|
+
readonly balanceWei: bigint;
|
|
59
|
+
readonly gasPriceWei: bigint | null;
|
|
60
|
+
}) => boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The fee rate an address starts with. "No fee" is the default only when the reader can pay the gas to cross it
|
|
63
|
+
* alone. Otherwise the default is the highest preset, as before, and the page says why.
|
|
64
|
+
*
|
|
65
|
+
* @param input.isSelfCrossAffordable - the result of {@link isSelfCrossAffordable}
|
|
66
|
+
*/
|
|
67
|
+
export declare const exchangeDepositDefaultFeeRateOf: ({ isSelfCrossAffordable: affordable, }: {
|
|
68
|
+
readonly isSelfCrossAffordable: boolean;
|
|
69
|
+
}) => bigint;
|
|
70
|
+
/**
|
|
71
|
+
* The dollar amount of a fee. With the deposit's dollar value it is the fee on that value. Without it, the fee on
|
|
72
|
+
* {@link PER_HUNDRED_DOLLARS}, which the interface shows as "per $100".
|
|
73
|
+
*
|
|
74
|
+
* @param input.feeRateE18 - the fee rate, in 1e18 fixed point
|
|
75
|
+
* @param input.depositUsd - the deposit's dollar value, or null when the amount is not known
|
|
76
|
+
*/
|
|
77
|
+
export declare const feeDollarsOf: ({ feeRateE18, depositUsd, }: {
|
|
78
|
+
readonly feeRateE18: bigint;
|
|
79
|
+
readonly depositUsd: number | null;
|
|
80
|
+
}) => number;
|
|
81
|
+
/**
|
|
82
|
+
* The dollar cost of crossing one address alone at a gas price, using the ether price in dollars.
|
|
83
|
+
*
|
|
84
|
+
* @param input.chainId - the Ethereum chain the flush runs on
|
|
85
|
+
* @param input.tokenAddress - the token of the deposit
|
|
86
|
+
* @param input.gasPriceWei - the gas price per unit, in wei
|
|
87
|
+
* @param input.etherUsd - one ether in dollars
|
|
88
|
+
*/
|
|
89
|
+
export declare const selfCrossDollarsOf: ({ chainId, tokenAddress, gasPriceWei, etherUsd, }: SelfCrossInput & {
|
|
90
|
+
readonly gasPriceWei: bigint;
|
|
91
|
+
readonly etherUsd: number;
|
|
92
|
+
}) => number;
|
|
93
|
+
/** Why "No fee" is or is not the default: it is the default only when the reader can pay the flush. */
|
|
94
|
+
export type SelfCrossReason = 'affordable' | 'no-balance' | 'short-of-ether' | 'no-gas-price';
|
|
95
|
+
/** The affordability of crossing one address alone, read from the page's live figures. */
|
|
96
|
+
export type SelfCrossState = {
|
|
97
|
+
/** Why the default is or is not "No fee". */
|
|
98
|
+
readonly reason: SelfCrossReason;
|
|
99
|
+
/** Whether "No fee" is the default. True only for the reason `affordable`. */
|
|
100
|
+
readonly affordable: boolean;
|
|
101
|
+
/** The gas price per unit, in wei: the base fee plus the tip. Null when the page has not read the fees. */
|
|
102
|
+
readonly gasPriceWei: bigint | null;
|
|
103
|
+
/** The gas one flush costs at that price, in wei. Null when the gas price is not known. */
|
|
104
|
+
readonly costWei: bigint | null;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* The gas price a crossing pays now, in wei per unit: the Ethereum base fee plus the tip.
|
|
108
|
+
*
|
|
109
|
+
* @param input.baseFeeWei - the base fee, in wei per gas
|
|
110
|
+
* @param input.priorityFeeWei - the tip, in wei per gas
|
|
111
|
+
*/
|
|
112
|
+
export declare const gasPriceWeiOf: ({ baseFeeWei, priorityFeeWei, }: {
|
|
113
|
+
readonly baseFeeWei: bigint;
|
|
114
|
+
readonly priorityFeeWei: bigint;
|
|
115
|
+
}) => bigint;
|
|
116
|
+
/**
|
|
117
|
+
* The affordability of crossing one address alone, from the reader's ether on Ethereum and the live gas price. The
|
|
118
|
+
* reason is checked in order: no gas price, then no balance (no wallet, or not read yet), then the ether short of the
|
|
119
|
+
* margin. The interface shows the reason and never decides it.
|
|
120
|
+
*
|
|
121
|
+
* @param input.balanceWei - the reader's ether on Ethereum, in wei, or null when there is no wallet or it is not read
|
|
122
|
+
* @param input.chainId - the Ethereum chain the flush runs on
|
|
123
|
+
* @param input.tokenAddress - the token of the deposit
|
|
124
|
+
* @param input.gasPriceWei - the gas price now, in wei per unit, or null when the page has not read it
|
|
125
|
+
*/
|
|
126
|
+
export declare const selfCrossStateOf: ({ balanceWei, chainId, tokenAddress, gasPriceWei, }: SelfCrossInput & {
|
|
127
|
+
readonly balanceWei: bigint | null;
|
|
128
|
+
readonly gasPriceWei: bigint | null;
|
|
129
|
+
}) => SelfCrossState;
|
|
130
|
+
/** The state of one live read: not answered yet, answered, or refused. */
|
|
131
|
+
export type SelfCrossRead = 'pending' | 'loaded' | 'failed';
|
|
132
|
+
/** The state of the balance read. With no wallet there is nothing to read, so the state is `no-wallet`. */
|
|
133
|
+
export type SelfCrossBalanceRead = SelfCrossRead | 'no-wallet';
|
|
134
|
+
/**
|
|
135
|
+
* Whether the page has decided the starting fee rate. `deciding` means a read is still open, so the page shows no
|
|
136
|
+
* address. `no-fee` and `default-rate` are final once the page latches them.
|
|
137
|
+
*/
|
|
138
|
+
export type SelfCrossDecision = 'deciding' | 'no-fee' | 'default-rate';
|
|
139
|
+
/**
|
|
140
|
+
* The starting fee decision from the state of the reads. It waits while the gas or the balance is still pending. A
|
|
141
|
+
* failed read settles on the default rate at once, because the reader cannot be shown a figure that was never read.
|
|
142
|
+
* With no wallet the balance is absent, so the default rate stands.
|
|
143
|
+
*
|
|
144
|
+
* @param input.gasRead - the state of the gas price read
|
|
145
|
+
* @param input.balanceRead - the state of the balance read, or `no-wallet`
|
|
146
|
+
* @param input.affordable - whether the reader can cross alone, from {@link selfCrossStateOf}; read only when both reads loaded
|
|
147
|
+
*/
|
|
148
|
+
export declare const selfCrossDecisionOf: ({ gasRead, balanceRead, affordable, }: {
|
|
149
|
+
readonly gasRead: SelfCrossRead;
|
|
150
|
+
readonly balanceRead: SelfCrossBalanceRead;
|
|
151
|
+
readonly affordable: boolean;
|
|
152
|
+
}) => SelfCrossDecision;
|
|
153
|
+
/**
|
|
154
|
+
* The decision the page keeps. Once a decision is settled it stays, whatever the live reads say later. Only a
|
|
155
|
+
* reader's own choice of fee changes the rate after that.
|
|
156
|
+
*
|
|
157
|
+
* @param input.settled - the decision the page already settled, or `deciding` when none
|
|
158
|
+
* @param input.live - the decision from the reads now, from {@link selfCrossDecisionOf}
|
|
159
|
+
*/
|
|
160
|
+
export declare const settledSelfCrossDecisionOf: ({ settled, live, }: {
|
|
161
|
+
readonly settled: SelfCrossDecision;
|
|
162
|
+
readonly live: SelfCrossDecision;
|
|
163
|
+
}) => SelfCrossDecision;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.settledSelfCrossDecisionOf = exports.selfCrossDecisionOf = exports.selfCrossStateOf = exports.gasPriceWeiOf = exports.selfCrossDollarsOf = exports.feeDollarsOf = exports.exchangeDepositDefaultFeeRateOf = exports.isSelfCrossAffordable = exports.selfCrossCostWeiOf = exports.selfCrossPaidGasOf = exports.selfCrossGasLimitOf = exports.PER_HUNDRED_DOLLARS = exports.SELF_CROSS_GAS_MARGIN_MULTIPLE = exports.NO_FEE_RATE_E18 = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const exchange_deposit_js_1 = require("./exchange-deposit.js");
|
|
6
|
+
const exchange_deposit_constants_js_1 = require("./exchange-deposit-constants.js");
|
|
7
|
+
exports.NO_FEE_RATE_E18 = 0n;
|
|
8
|
+
exports.SELF_CROSS_GAS_MARGIN_MULTIPLE = 2n;
|
|
9
|
+
exports.PER_HUNDRED_DOLLARS = 100;
|
|
10
|
+
const isEtherAddress = (tokenAddress) => tokenAddress.toLowerCase() === viem_1.zeroAddress;
|
|
11
|
+
const selfCrossGasLimitOf = ({ chainId, tokenAddress }) => {
|
|
12
|
+
const { beforeRefund } = (0, exchange_deposit_js_1.exchangeDepositGasTableOf)(chainId).gasModel;
|
|
13
|
+
return isEtherAddress(tokenAddress) ? beforeRefund.etherFlushGas : beforeRefund.tokenFlushGas;
|
|
14
|
+
};
|
|
15
|
+
exports.selfCrossGasLimitOf = selfCrossGasLimitOf;
|
|
16
|
+
const selfCrossPaidGasOf = ({ chainId, tokenAddress }) => {
|
|
17
|
+
const { paid } = (0, exchange_deposit_js_1.exchangeDepositGasTableOf)(chainId).gasModel;
|
|
18
|
+
return isEtherAddress(tokenAddress) ? paid.etherFlushGas : paid.tokenFlushGas;
|
|
19
|
+
};
|
|
20
|
+
exports.selfCrossPaidGasOf = selfCrossPaidGasOf;
|
|
21
|
+
const selfCrossCostWeiOf = ({ chainId, tokenAddress, gasPriceWei, }) => (0, exports.selfCrossPaidGasOf)({ chainId, tokenAddress }) * gasPriceWei;
|
|
22
|
+
exports.selfCrossCostWeiOf = selfCrossCostWeiOf;
|
|
23
|
+
const isSelfCrossAffordable = ({ balanceWei, chainId, tokenAddress, gasPriceWei, }) => {
|
|
24
|
+
if (gasPriceWei === null)
|
|
25
|
+
return false;
|
|
26
|
+
const requiredWei = (0, exports.selfCrossGasLimitOf)({ chainId, tokenAddress }) * gasPriceWei * exports.SELF_CROSS_GAS_MARGIN_MULTIPLE;
|
|
27
|
+
return balanceWei >= requiredWei;
|
|
28
|
+
};
|
|
29
|
+
exports.isSelfCrossAffordable = isSelfCrossAffordable;
|
|
30
|
+
const exchangeDepositDefaultFeeRateOf = ({ isSelfCrossAffordable: affordable, }) => (affordable ? exports.NO_FEE_RATE_E18 : exchange_deposit_js_1.EXCHANGE_DEPOSIT_DEFAULT_FEE_RATE_E18);
|
|
31
|
+
exports.exchangeDepositDefaultFeeRateOf = exchangeDepositDefaultFeeRateOf;
|
|
32
|
+
const feeDollarsOf = ({ feeRateE18, depositUsd, }) => {
|
|
33
|
+
const basisUsd = depositUsd ?? exports.PER_HUNDRED_DOLLARS;
|
|
34
|
+
return (basisUsd * Number(feeRateE18)) / Number(exchange_deposit_js_1.FEE_RATE_SCALE);
|
|
35
|
+
};
|
|
36
|
+
exports.feeDollarsOf = feeDollarsOf;
|
|
37
|
+
const selfCrossDollarsOf = ({ chainId, tokenAddress, gasPriceWei, etherUsd, }) => (Number((0, exports.selfCrossCostWeiOf)({ chainId, tokenAddress, gasPriceWei })) / Number(exchange_deposit_constants_js_1.WEI_PER_ETHER)) * etherUsd;
|
|
38
|
+
exports.selfCrossDollarsOf = selfCrossDollarsOf;
|
|
39
|
+
const gasPriceWeiOf = ({ baseFeeWei, priorityFeeWei, }) => baseFeeWei + priorityFeeWei;
|
|
40
|
+
exports.gasPriceWeiOf = gasPriceWeiOf;
|
|
41
|
+
const selfCrossStateOf = ({ balanceWei, chainId, tokenAddress, gasPriceWei, }) => {
|
|
42
|
+
if (gasPriceWei === null)
|
|
43
|
+
return { reason: 'no-gas-price', affordable: false, gasPriceWei, costWei: null };
|
|
44
|
+
const costWei = (0, exports.selfCrossCostWeiOf)({ chainId, tokenAddress, gasPriceWei });
|
|
45
|
+
if (balanceWei === null)
|
|
46
|
+
return { reason: 'no-balance', affordable: false, gasPriceWei, costWei };
|
|
47
|
+
const affordable = (0, exports.isSelfCrossAffordable)({ balanceWei, chainId, tokenAddress, gasPriceWei });
|
|
48
|
+
return { reason: affordable ? 'affordable' : 'short-of-ether', affordable, gasPriceWei, costWei };
|
|
49
|
+
};
|
|
50
|
+
exports.selfCrossStateOf = selfCrossStateOf;
|
|
51
|
+
const selfCrossDecisionOf = ({ gasRead, balanceRead, affordable, }) => {
|
|
52
|
+
if (gasRead === 'failed' || balanceRead === 'failed')
|
|
53
|
+
return 'default-rate';
|
|
54
|
+
if (gasRead === 'pending' || balanceRead === 'pending')
|
|
55
|
+
return 'deciding';
|
|
56
|
+
return affordable ? 'no-fee' : 'default-rate';
|
|
57
|
+
};
|
|
58
|
+
exports.selfCrossDecisionOf = selfCrossDecisionOf;
|
|
59
|
+
const settledSelfCrossDecisionOf = ({ settled, live, }) => (settled === 'deciding' ? live : settled);
|
|
60
|
+
exports.settledSelfCrossDecisionOf = settledSelfCrossDecisionOf;
|