@gibs/bridge-client 1.30.1 → 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/coinbase-accept-list/package.json +6 -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/index.d.ts +2 -0
- package/dist/cjs/index.js +24 -1
- package/dist/cjs/kraken-accept-list.d.ts +70 -0
- package/dist/cjs/kraken-accept-list.js +24 -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/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/kraken-accept-list.d.ts +70 -0
- package/dist/kraken-accept-list.js +17 -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/package.json +429 -4
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fakeExchangeDepositSource = exports.FAKE_EXCHANGE_DEPOSIT_FEE_LIMITS = exports.FAKE_CONTRACT_RECIPIENT = exports.FAKE_EXCHANGE_DEPOSIT_SEED = exports.settingsOfRequest = exports.fakeExchangeDepositAddress = exports.FAKE_EXCHANGE_DEPOSIT_CONDITIONS = exports.fakeDeriveExchangeDepositAddress = exports.isFakeExchangeDepositScenario = exports.FAKE_EXCHANGE_DEPOSIT_SCENARIOS = exports.FAKE_EXCHANGE_DEPOSIT_TOKENS = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const exchange_deposit_js_1 = require("./exchange-deposit.js");
|
|
6
|
+
const exchange_deposit_index_js_1 = require("./exchange-deposit-index.js");
|
|
7
|
+
const USDC = {
|
|
8
|
+
symbol: 'USDC',
|
|
9
|
+
name: 'USD Coin',
|
|
10
|
+
address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
11
|
+
decimals: 6,
|
|
12
|
+
contractGroup: 'single',
|
|
13
|
+
};
|
|
14
|
+
const USDT = {
|
|
15
|
+
symbol: 'USDT',
|
|
16
|
+
name: 'Tether',
|
|
17
|
+
address: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
|
|
18
|
+
decimals: 6,
|
|
19
|
+
contractGroup: 'single',
|
|
20
|
+
};
|
|
21
|
+
const DAI = {
|
|
22
|
+
symbol: 'DAI',
|
|
23
|
+
name: 'Dai',
|
|
24
|
+
address: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
|
|
25
|
+
decimals: 18,
|
|
26
|
+
contractGroup: 'single',
|
|
27
|
+
};
|
|
28
|
+
const ETHER = {
|
|
29
|
+
symbol: 'ETH',
|
|
30
|
+
name: 'Ether',
|
|
31
|
+
address: viem_1.zeroAddress,
|
|
32
|
+
decimals: 18,
|
|
33
|
+
contractGroup: 'ether',
|
|
34
|
+
};
|
|
35
|
+
const WBTC = {
|
|
36
|
+
symbol: 'WBTC',
|
|
37
|
+
name: 'Wrapped Bitcoin',
|
|
38
|
+
address: '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599',
|
|
39
|
+
decimals: 8,
|
|
40
|
+
contractGroup: 'single',
|
|
41
|
+
};
|
|
42
|
+
const PLS = {
|
|
43
|
+
symbol: 'PLS',
|
|
44
|
+
name: 'Pulse',
|
|
45
|
+
address: '0xA882606494D86804B5514E07e6Bd2D6a6eE6d68A',
|
|
46
|
+
decimals: 18,
|
|
47
|
+
contractGroup: 'single',
|
|
48
|
+
};
|
|
49
|
+
exports.FAKE_EXCHANGE_DEPOSIT_TOKENS = [USDC, USDT, DAI, ETHER, WBTC, PLS];
|
|
50
|
+
exports.FAKE_EXCHANGE_DEPOSIT_SCENARIOS = [
|
|
51
|
+
'empty',
|
|
52
|
+
'partway',
|
|
53
|
+
'ready',
|
|
54
|
+
'crossing',
|
|
55
|
+
];
|
|
56
|
+
const isFakeExchangeDepositScenario = (value) => exports.FAKE_EXCHANGE_DEPOSIT_SCENARIOS.includes(value);
|
|
57
|
+
exports.isFakeExchangeDepositScenario = isFakeExchangeDepositScenario;
|
|
58
|
+
const tokenOfSettings = (settings) => exports.FAKE_EXCHANGE_DEPOSIT_TOKENS.find((candidate) => candidate.address.toLowerCase() === settings.tokenAddress.toLowerCase());
|
|
59
|
+
const fakeDeriveExchangeDepositAddress = (settings) => {
|
|
60
|
+
const token = tokenOfSettings(settings);
|
|
61
|
+
const group = token?.contractGroup ?? 'single';
|
|
62
|
+
const singleToken = group === 'single' ? settings.tokenAddress.toLowerCase() : viem_1.zeroAddress;
|
|
63
|
+
const hash = (0, viem_1.keccak256)((0, viem_1.encodePacked)(['address', 'string', 'address', 'uint256', 'bool', 'uint256'], [
|
|
64
|
+
settings.recipient,
|
|
65
|
+
group,
|
|
66
|
+
singleToken,
|
|
67
|
+
settings.feeRateE18,
|
|
68
|
+
settings.unwrapToNativePls,
|
|
69
|
+
settings.index,
|
|
70
|
+
]));
|
|
71
|
+
return (0, viem_1.getAddress)(`0x${hash.slice(-40)}`);
|
|
72
|
+
};
|
|
73
|
+
exports.fakeDeriveExchangeDepositAddress = fakeDeriveExchangeDepositAddress;
|
|
74
|
+
exports.FAKE_EXCHANGE_DEPOSIT_CONDITIONS = {
|
|
75
|
+
gasTable: (0, exchange_deposit_js_1.exchangeDepositGasTableOf)(exchange_deposit_js_1.ETHEREUM_MAINNET_CHAIN_ID),
|
|
76
|
+
baseFeeWei: 1200000000n,
|
|
77
|
+
priorityFeeWei: 100000000n,
|
|
78
|
+
multipleThousandths: 2000n,
|
|
79
|
+
weiPerWholeTokenByAddress: {
|
|
80
|
+
[USDC.address.toLowerCase()]: exchange_deposit_js_1.WEI_PER_ETHER / 3200n,
|
|
81
|
+
[USDT.address.toLowerCase()]: exchange_deposit_js_1.WEI_PER_ETHER / 3200n,
|
|
82
|
+
[DAI.address.toLowerCase()]: exchange_deposit_js_1.WEI_PER_ETHER / 3200n,
|
|
83
|
+
[ETHER.address.toLowerCase()]: exchange_deposit_js_1.WEI_PER_ETHER,
|
|
84
|
+
[WBTC.address.toLowerCase()]: 20n * exchange_deposit_js_1.WEI_PER_ETHER,
|
|
85
|
+
[PLS.address.toLowerCase()]: exchange_deposit_js_1.WEI_PER_ETHER / 300000n,
|
|
86
|
+
},
|
|
87
|
+
minimumPerTxByAddress: {
|
|
88
|
+
[USDC.address.toLowerCase()]: 0n,
|
|
89
|
+
[USDT.address.toLowerCase()]: 0n,
|
|
90
|
+
[DAI.address.toLowerCase()]: 0n,
|
|
91
|
+
[ETHER.address.toLowerCase()]: 0n,
|
|
92
|
+
[WBTC.address.toLowerCase()]: 0n,
|
|
93
|
+
[PLS.address.toLowerCase()]: 0n,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
const situationKey = (symbol, feeRateE18) => `${symbol}:${feeRateE18}`;
|
|
97
|
+
const [, ONE_PERCENT, HALF_PERCENT] = exchange_deposit_js_1.EXCHANGE_DEPOSIT_FEE_RATES;
|
|
98
|
+
const situationsByScenario = {
|
|
99
|
+
empty: {},
|
|
100
|
+
partway: {
|
|
101
|
+
[situationKey('USDC', ONE_PERCENT)]: { balance: '120' },
|
|
102
|
+
[situationKey('USDT', HALF_PERCENT)]: { balance: '90' },
|
|
103
|
+
[situationKey('ETH', ONE_PERCENT)]: { balance: '0.03' },
|
|
104
|
+
},
|
|
105
|
+
ready: {
|
|
106
|
+
[situationKey('USDC', ONE_PERCENT)]: { balance: '300' },
|
|
107
|
+
[situationKey('USDT', HALF_PERCENT)]: { balance: '600' },
|
|
108
|
+
[situationKey('ETH', ONE_PERCENT)]: { balance: '0.09' },
|
|
109
|
+
},
|
|
110
|
+
crossing: {
|
|
111
|
+
[situationKey('USDC', ONE_PERCENT)]: { balance: '300', crossing: true },
|
|
112
|
+
[situationKey('USDT', HALF_PERCENT)]: { balance: '600' },
|
|
113
|
+
[situationKey('ETH', ONE_PERCENT)]: { balance: '0.09' },
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
const FAKE_CROSSING_HASH = `0x${'ab'.repeat(32)}`;
|
|
117
|
+
const crossingOf = (situation) => situation?.crossing === true
|
|
118
|
+
? { transactionHash: FAKE_CROSSING_HASH, startedAtMs: Date.now() - 45_000 }
|
|
119
|
+
: null;
|
|
120
|
+
const fakeExchangeDepositAddress = ({ settings, scenario, }) => {
|
|
121
|
+
const token = tokenOfSettings(settings);
|
|
122
|
+
if (token === undefined)
|
|
123
|
+
throw new Error(`the fake source has no token ${settings.tokenAddress}`);
|
|
124
|
+
const situation = settings.counter === 0 ? situationsByScenario[scenario][situationKey(token.symbol, settings.feeRateE18)] : undefined;
|
|
125
|
+
return {
|
|
126
|
+
origin: 'placeholder',
|
|
127
|
+
address: (0, exports.fakeDeriveExchangeDepositAddress)(settings),
|
|
128
|
+
settings,
|
|
129
|
+
token,
|
|
130
|
+
waiting: situation === undefined ? 0n : (0, viem_1.parseUnits)(situation.balance, token.decimals),
|
|
131
|
+
crossing: crossingOf(situation),
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
exports.fakeExchangeDepositAddress = fakeExchangeDepositAddress;
|
|
135
|
+
const settingsOfRequest = (request) => ({
|
|
136
|
+
recipient: request.recipient,
|
|
137
|
+
tokenAddress: request.tokenAddress,
|
|
138
|
+
feeRateE18: request.feeRateE18,
|
|
139
|
+
counter: request.counter,
|
|
140
|
+
index: (0, exchange_deposit_index_js_1.factoryIndexOf)({
|
|
141
|
+
seed: request.seed,
|
|
142
|
+
tokenAddress: request.tokenAddress,
|
|
143
|
+
feeRateE18: request.feeRateE18,
|
|
144
|
+
counter: request.counter,
|
|
145
|
+
}),
|
|
146
|
+
unwrapToNativePls: request.tokenAddress.toLowerCase() === PLS.address.toLowerCase(),
|
|
147
|
+
});
|
|
148
|
+
exports.settingsOfRequest = settingsOfRequest;
|
|
149
|
+
exports.FAKE_EXCHANGE_DEPOSIT_SEED = (0, viem_1.keccak256)((0, viem_1.toHex)('fake-exchange-deposit-seed'));
|
|
150
|
+
exports.FAKE_CONTRACT_RECIPIENT = (0, viem_1.getAddress)('0x000000000000000000000000000000000000c0de');
|
|
151
|
+
exports.FAKE_EXCHANGE_DEPOSIT_FEE_LIMITS = {
|
|
152
|
+
maximumFeeRateE18: 10n ** 16n,
|
|
153
|
+
maximumPartnerRateE18: 10n ** 16n,
|
|
154
|
+
};
|
|
155
|
+
const fakeExchangeDepositSource = (scenario) => ({
|
|
156
|
+
listTokens: async () => exports.FAKE_EXCHANGE_DEPOSIT_TOKENS,
|
|
157
|
+
feeLimits: async () => exports.FAKE_EXCHANGE_DEPOSIT_FEE_LIMITS,
|
|
158
|
+
addressFor: async (request) => {
|
|
159
|
+
(0, exchange_deposit_js_1.assertFeeRatesWithinLimits)({ feeRateE18: request.feeRateE18, partnerRateE18: 0n, limits: exports.FAKE_EXCHANGE_DEPOSIT_FEE_LIMITS });
|
|
160
|
+
return (0, exports.fakeExchangeDepositAddress)({ settings: (0, exports.settingsOfRequest)(request), scenario });
|
|
161
|
+
},
|
|
162
|
+
nextCounterFor: ({ startCounter, ...request }) => {
|
|
163
|
+
(0, exchange_deposit_js_1.assertFeeRatesWithinLimits)({ feeRateE18: request.feeRateE18, partnerRateE18: 0n, limits: exports.FAKE_EXCHANGE_DEPOSIT_FEE_LIMITS });
|
|
164
|
+
return (0, exchange_deposit_index_js_1.firstUnusedIndexFrom)({
|
|
165
|
+
start: startCounter,
|
|
166
|
+
isUsed: async (counter) => {
|
|
167
|
+
const address = await (0, exports.fakeExchangeDepositAddress)({
|
|
168
|
+
settings: (0, exports.settingsOfRequest)({ ...request, counter }),
|
|
169
|
+
scenario,
|
|
170
|
+
});
|
|
171
|
+
return address.waiting > 0n || address.crossing !== null;
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
signerCodeKind: async () => 'no-code',
|
|
176
|
+
crossingConditions: async () => exports.FAKE_EXCHANGE_DEPOSIT_CONDITIONS,
|
|
177
|
+
recipientHasCode: async (recipient) => recipient.toLowerCase().endsWith('c0de'),
|
|
178
|
+
});
|
|
179
|
+
exports.fakeExchangeDepositSource = fakeExchangeDepositSource;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type Address, type Hex } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* The index of the next free deposit address.
|
|
4
|
+
*
|
|
5
|
+
* An address is for one deposit (single-use, owner decision 2026-11-13). A new deposit takes the LOWEST index whose
|
|
6
|
+
* address is free: it holds no balance and the factory has not recorded a use of it. The caller decides what
|
|
7
|
+
* "used" means for an address (see {@link exchangeDepositAddressIsUsed}); this file only scans.
|
|
8
|
+
*/
|
|
9
|
+
/** How many addresses are read at once. A walk reads two, so the wait stays short on a slow node and few reads are in flight. */
|
|
10
|
+
export declare const EXCHANGE_DEPOSIT_INDEX_SCAN_BATCH_SIZE = 2;
|
|
11
|
+
/** How many indexes a walk checks from its start before it gives up. A reader who uses a thousand addresses needs a new design. */
|
|
12
|
+
export declare const EXCHANGE_DEPOSIT_INDEX_SCAN_LIMIT = 1000;
|
|
13
|
+
/** What the facts of one address say about whether it is in use. */
|
|
14
|
+
export interface ExchangeDepositAddressFacts {
|
|
15
|
+
/** The balance of the address's token, in base units. For ether, the whole ether balance. */
|
|
16
|
+
readonly balance: bigint;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the factory logged a flush, a rescue or a retirement of the address. A flushed address ends with no
|
|
19
|
+
* balance and no code, so this event is the only record of the use.
|
|
20
|
+
*/
|
|
21
|
+
readonly hasFactoryEvent: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Whether an address is used: it holds a balance now, or the factory has logged a use of it. A flushed address
|
|
25
|
+
* with no balance is still used, because its flush is logged.
|
|
26
|
+
*
|
|
27
|
+
* @param facts - the balance of the address and whether the factory logged a use of it
|
|
28
|
+
*/
|
|
29
|
+
export declare const exchangeDepositAddressIsUsed: ({ balance, hasFactoryEvent }: ExchangeDepositAddressFacts) => boolean;
|
|
30
|
+
/** The options of {@link firstUnusedIndexFrom}. */
|
|
31
|
+
export interface FirstUnusedIndexOptions {
|
|
32
|
+
/** The first index the walk checks. */
|
|
33
|
+
readonly start: number;
|
|
34
|
+
/** Whether the address at an index is used. Called once per index, in batches. */
|
|
35
|
+
readonly isUsed: (index: number) => Promise<boolean>;
|
|
36
|
+
/** How many indexes are read at once. */
|
|
37
|
+
readonly batchSize?: number;
|
|
38
|
+
/** How many indexes, counted from the start, the walk checks before it gives up. */
|
|
39
|
+
readonly limit?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The first free index at or after a start index, walking forward in small batches. The walk never reads below its
|
|
43
|
+
* start, so it never rescans indexes the caller already knows about. The caller decides where the start is: a
|
|
44
|
+
* recovery walk starts at 0, and a new address starts after the highest address already issued.
|
|
45
|
+
*
|
|
46
|
+
* @param options - the start, the used check, the batch size and the limit
|
|
47
|
+
* @returns the first index at or after the start for which `isUsed` is false
|
|
48
|
+
* @throws when every index in the walk's window is used, or when the start is not a whole number from 0
|
|
49
|
+
*/
|
|
50
|
+
export declare const firstUnusedIndexFrom: ({ start, isUsed, batchSize, limit, }: FirstUnusedIndexOptions) => Promise<number>;
|
|
51
|
+
/**
|
|
52
|
+
* The 32-byte seed an address family grows from. It is the same for every address of one recipient on one chain and
|
|
53
|
+
* factory: an ordinary wallet gives it through {@link exchangeDepositSeedOfSignature}, and a smart-contract wallet
|
|
54
|
+
* through a random 32 bytes. Nobody can compute it from public facts.
|
|
55
|
+
*/
|
|
56
|
+
export type ExchangeDepositSeed = Hex;
|
|
57
|
+
/**
|
|
58
|
+
* The factory index of one address: the uint256 the factory takes as `index`. It is a keccak256 hash of the seed and
|
|
59
|
+
* the settings that vary, with the counter last. A reader who does not hold the seed cannot compute it, so nobody can
|
|
60
|
+
* guess an address, pre-draw it or burn a scan range (threat analysis, section 6 (ii)).
|
|
61
|
+
*
|
|
62
|
+
* The hash uses `abi.encode`, so every field has a fixed width and no two inputs share an encoding. The counter is
|
|
63
|
+
* the number of the address within the settings: 0 is the first, and each new deposit takes the next counter.
|
|
64
|
+
*
|
|
65
|
+
* @param input.seed - the 32-byte seed of the recipient on this chain and factory
|
|
66
|
+
* @param input.tokenAddress - the token of the address
|
|
67
|
+
* @param input.feeRateE18 - the exact fee of the address, in 1e18 fixed point
|
|
68
|
+
* @param input.counter - the position of the address among those of the same settings, from 0
|
|
69
|
+
* @returns the factory index, a uint256 that is 256 bits wide in practice
|
|
70
|
+
* @throws when the counter is negative or not a safe integer
|
|
71
|
+
*/
|
|
72
|
+
export declare const factoryIndexOf: ({ seed, tokenAddress, feeRateE18, counter, }: {
|
|
73
|
+
seed: ExchangeDepositSeed;
|
|
74
|
+
tokenAddress: Address;
|
|
75
|
+
feeRateE18: bigint;
|
|
76
|
+
counter: number;
|
|
77
|
+
}) => bigint;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.factoryIndexOf = exports.firstUnusedIndexFrom = exports.exchangeDepositAddressIsUsed = exports.EXCHANGE_DEPOSIT_INDEX_SCAN_LIMIT = exports.EXCHANGE_DEPOSIT_INDEX_SCAN_BATCH_SIZE = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
exports.EXCHANGE_DEPOSIT_INDEX_SCAN_BATCH_SIZE = 2;
|
|
6
|
+
exports.EXCHANGE_DEPOSIT_INDEX_SCAN_LIMIT = 1000;
|
|
7
|
+
const exchangeDepositAddressIsUsed = ({ balance, hasFactoryEvent }) => balance > 0n || hasFactoryEvent;
|
|
8
|
+
exports.exchangeDepositAddressIsUsed = exchangeDepositAddressIsUsed;
|
|
9
|
+
const firstUnusedIndexFrom = async ({ start, isUsed, batchSize = exports.EXCHANGE_DEPOSIT_INDEX_SCAN_BATCH_SIZE, limit = exports.EXCHANGE_DEPOSIT_INDEX_SCAN_LIMIT, }) => {
|
|
10
|
+
if (!Number.isSafeInteger(start) || start < 0)
|
|
11
|
+
throw new Error(`the walk must start at a whole number from 0, not ${start}`);
|
|
12
|
+
const end = start + limit;
|
|
13
|
+
for (let batchStart = start; batchStart < end; batchStart += batchSize) {
|
|
14
|
+
const indexes = Array.from({ length: Math.min(batchSize, end - batchStart) }, (_, offset) => batchStart + offset);
|
|
15
|
+
const usedFlags = await Promise.all(indexes.map((index) => isUsed(index)));
|
|
16
|
+
const firstFree = usedFlags.indexOf(false);
|
|
17
|
+
if (firstFree !== -1)
|
|
18
|
+
return indexes[firstFree];
|
|
19
|
+
}
|
|
20
|
+
throw new Error(`every deposit address from index ${start} to ${end - 1} is in use`);
|
|
21
|
+
};
|
|
22
|
+
exports.firstUnusedIndexFrom = firstUnusedIndexFrom;
|
|
23
|
+
const INDEX_DOMAIN_TAG = (0, viem_1.keccak256)((0, viem_1.toHex)('gibs-deposit-index-v1'));
|
|
24
|
+
const NO_PARTNER_ADDRESS = viem_1.zeroAddress;
|
|
25
|
+
const NO_PARTNER_RATE_E18 = 0n;
|
|
26
|
+
const factoryIndexOf = ({ seed, tokenAddress, feeRateE18, counter, }) => {
|
|
27
|
+
if (!Number.isSafeInteger(counter) || counter < 0)
|
|
28
|
+
throw new Error(`the address counter must be a whole number from 0, not ${counter}`);
|
|
29
|
+
const encoded = (0, viem_1.encodeAbiParameters)([
|
|
30
|
+
{ type: 'bytes32' },
|
|
31
|
+
{ type: 'bytes32' },
|
|
32
|
+
{ type: 'address' },
|
|
33
|
+
{ type: 'uint256' },
|
|
34
|
+
{ type: 'address' },
|
|
35
|
+
{ type: 'uint256' },
|
|
36
|
+
{ type: 'uint256' },
|
|
37
|
+
], [INDEX_DOMAIN_TAG, seed, tokenAddress, feeRateE18, NO_PARTNER_ADDRESS, NO_PARTNER_RATE_E18, BigInt(counter)]);
|
|
38
|
+
return BigInt((0, viem_1.keccak256)(encoded));
|
|
39
|
+
};
|
|
40
|
+
exports.factoryIndexOf = factoryIndexOf;
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { type Address, type Hex } from 'viem';
|
|
2
|
+
import { type ExchangeDepositSeed } from './exchange-deposit-index.js';
|
|
3
|
+
import { type ExchangeDepositSigninStorage, type StoredSigninRecord } from './exchange-deposit-signin.js';
|
|
4
|
+
/**
|
|
5
|
+
* The issuance record: a private log of the deposit addresses this browser has shown, so a reload offers the next
|
|
6
|
+
* address and not a used one. The interface chooses a counter from these records first, and from the chain only to
|
|
7
|
+
* confirm an address is free (threat analysis, section 6 (iv) and 7). The chain is never scanned to choose a counter.
|
|
8
|
+
*
|
|
9
|
+
* TWO HOMES FOR A RECORD. The browser keeps a plain copy. A copy is also posted
|
|
10
|
+
* to the msgboard archive, as ciphertext that only the seed can open, so a reader who clears the browser can recover
|
|
11
|
+
* the highest counter. Nothing in this file talks to a network except {@link fetchArchivedRecordBodies}, which takes
|
|
12
|
+
* its fetch function as an input.
|
|
13
|
+
*
|
|
14
|
+
* SMART-CONTRACT WALLETS. A smart-contract wallet has a random seed (see `exchange-deposit-signin.ts`), which exists
|
|
15
|
+
* only in this browser. The archive cannot help it, because nobody else holds the seed to find or open the records.
|
|
16
|
+
* Its records stay local only, and the posting step must skip them.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* The domain tag of the record category. It differs from the index tag and the key tag, so no hash in this file can
|
|
20
|
+
* equal a hash of another value this module makes.
|
|
21
|
+
*/
|
|
22
|
+
export declare const ISSUANCE_CATEGORY_TAG: Hex;
|
|
23
|
+
/** One deposit address this browser issued: its token, its fee, its counter and its factory index. */
|
|
24
|
+
export interface IssuedAddressRecord {
|
|
25
|
+
/** The token of the address. */
|
|
26
|
+
readonly tokenAddress: Address;
|
|
27
|
+
/** The exact fee of the address, in 1e18 fixed point. */
|
|
28
|
+
readonly feeRateE18: bigint;
|
|
29
|
+
/** The counter of the address among those of the same token and fee. */
|
|
30
|
+
readonly counter: number;
|
|
31
|
+
/** The factory index of the address. It must recompute from the seed, or the record is ignored. */
|
|
32
|
+
readonly index: bigint;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The category one address's record is posted under. It hashes the seed, the token, the fee and the counter with its
|
|
36
|
+
* own tag, so every address has its own category. Only the seed holder can name it. A flood of junk in one category
|
|
37
|
+
* cannot hide another address's record, and the posts of different counters cannot be linked by category.
|
|
38
|
+
*
|
|
39
|
+
* @param input.seed - the 32-byte seed of the recipient
|
|
40
|
+
* @param input.tokenAddress - the token of the address
|
|
41
|
+
* @param input.feeRateE18 - the exact fee of the address
|
|
42
|
+
* @param input.counter - the counter of the address, a whole number from 0
|
|
43
|
+
* @returns the 32-byte category, lower case hex
|
|
44
|
+
* @throws when the counter is not a whole number from 0
|
|
45
|
+
*/
|
|
46
|
+
export declare const issuanceCategoryOf: ({ seed, tokenAddress, feeRateE18, counter, }: {
|
|
47
|
+
seed: ExchangeDepositSeed;
|
|
48
|
+
tokenAddress: Address;
|
|
49
|
+
feeRateE18: bigint;
|
|
50
|
+
counter: number;
|
|
51
|
+
}) => Hex;
|
|
52
|
+
/**
|
|
53
|
+
* The record of one address, with its factory index worked out from the seed and the fields.
|
|
54
|
+
*
|
|
55
|
+
* @param input.seed - the 32-byte seed of the recipient
|
|
56
|
+
* @param input.tokenAddress - the token of the address
|
|
57
|
+
* @param input.feeRateE18 - the exact fee of the address
|
|
58
|
+
* @param input.counter - the counter of the address
|
|
59
|
+
* @throws when the counter is not a whole number from 0
|
|
60
|
+
*/
|
|
61
|
+
export declare const issuedAddressRecordOf: ({ seed, tokenAddress, feeRateE18, counter, }: {
|
|
62
|
+
seed: ExchangeDepositSeed;
|
|
63
|
+
tokenAddress: Address;
|
|
64
|
+
feeRateE18: bigint;
|
|
65
|
+
counter: number;
|
|
66
|
+
}) => IssuedAddressRecord;
|
|
67
|
+
/**
|
|
68
|
+
* Seals one record: AES-GCM ciphertext under the seed's key, bound to the record's own category. The body is the
|
|
69
|
+
* version byte, the nonce, then the ciphertext with its tag. The category is the additional authenticated data, so a
|
|
70
|
+
* body posted under another category fails to open.
|
|
71
|
+
*
|
|
72
|
+
* @param input.seed - the 32-byte seed of the recipient
|
|
73
|
+
* @param input.record - the record to seal, with its index
|
|
74
|
+
* @param input.nonce - 12 random bytes, drawn fresh for each body. A test passes fixed bytes.
|
|
75
|
+
* @returns the body as hex, ready to post under `issuanceCategoryOf` of the record
|
|
76
|
+
* @throws when the nonce is not 12 bytes
|
|
77
|
+
*/
|
|
78
|
+
export declare const sealIssuedAddressRecord: ({ seed, record, nonce, }: {
|
|
79
|
+
seed: ExchangeDepositSeed;
|
|
80
|
+
record: IssuedAddressRecord;
|
|
81
|
+
nonce?: Uint8Array;
|
|
82
|
+
}) => Promise<Hex>;
|
|
83
|
+
/**
|
|
84
|
+
* Whether a record's index recomputes from the seed and its own fields. A record whose index does not recompute was
|
|
85
|
+
* not made by this seed, so it is never offered.
|
|
86
|
+
*
|
|
87
|
+
* @param input.seed - the 32-byte seed of the recipient
|
|
88
|
+
* @param input.record - the record to check
|
|
89
|
+
*/
|
|
90
|
+
export declare const issuedRecordIndexRecomputes: ({ seed, record, }: {
|
|
91
|
+
seed: ExchangeDepositSeed;
|
|
92
|
+
record: IssuedAddressRecord;
|
|
93
|
+
}) => boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Opens one body posted under a category. The record is returned only when the body has the right version, opens
|
|
96
|
+
* under the seed's key and the given category, decodes, has an index that recomputes from the seed, and its own
|
|
97
|
+
* category (from its fields) is the category it was posted under. Every other body reads as null.
|
|
98
|
+
*
|
|
99
|
+
* @param input.seed - the 32-byte seed of the recipient
|
|
100
|
+
* @param input.category - the category the body was posted under
|
|
101
|
+
* @param input.body - the body as hex, as the archive or the board returns it
|
|
102
|
+
*/
|
|
103
|
+
export declare const openIssuedAddressRecord: ({ seed, category, body, }: {
|
|
104
|
+
seed: ExchangeDepositSeed;
|
|
105
|
+
category: string;
|
|
106
|
+
body: string;
|
|
107
|
+
}) => Promise<IssuedAddressRecord | null>;
|
|
108
|
+
/** A body and the category it was posted under. */
|
|
109
|
+
export interface PostedIssuanceBody {
|
|
110
|
+
/** The category the body was posted under. */
|
|
111
|
+
readonly category: Hex;
|
|
112
|
+
/** The body as hex. */
|
|
113
|
+
readonly body: Hex;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The records a list of posted bodies holds for a seed. A body that does not open under its own category is dropped,
|
|
117
|
+
* so a flood of junk costs nothing but the bodies it sent.
|
|
118
|
+
*
|
|
119
|
+
* @param input.seed - the 32-byte seed of the recipient
|
|
120
|
+
* @param input.posts - the bodies and their categories
|
|
121
|
+
*/
|
|
122
|
+
export declare const openIssuedAddressRecords: ({ seed, posts, }: {
|
|
123
|
+
seed: ExchangeDepositSeed;
|
|
124
|
+
posts: readonly PostedIssuanceBody[];
|
|
125
|
+
}) => Promise<readonly IssuedAddressRecord[]>;
|
|
126
|
+
/**
|
|
127
|
+
* The highest counter the records hold for one token and fee, or null when they hold none. The token compares without
|
|
128
|
+
* case, and the fee exactly, because they name the address with its settings.
|
|
129
|
+
*
|
|
130
|
+
* @param input.records - the records to search, from any source
|
|
131
|
+
* @param input.tokenAddress - the token of the address
|
|
132
|
+
* @param input.feeRateE18 - the exact fee of the address
|
|
133
|
+
*/
|
|
134
|
+
export declare const highestIssuedCounterOf: ({ records, tokenAddress, feeRateE18, }: {
|
|
135
|
+
records: readonly IssuedAddressRecord[];
|
|
136
|
+
tokenAddress: Address;
|
|
137
|
+
feeRateE18: bigint;
|
|
138
|
+
}) => number | null;
|
|
139
|
+
/** The longest a read of the archive may take before it counts as down, in milliseconds. */
|
|
140
|
+
export declare const EXCHANGE_DEPOSIT_ARCHIVE_TIMEOUT_MS = 5000;
|
|
141
|
+
/** The public archive that holds the posted records, read through its GraphQL interface. */
|
|
142
|
+
export declare const EXCHANGE_DEPOSIT_ARCHIVE_ENDPOINT = "https://archive.msgboard.xyz/v1/graphql";
|
|
143
|
+
/** How many counters one archive request covers. Each counter is one aliased field in the request. */
|
|
144
|
+
export declare const EXCHANGE_DEPOSIT_ARCHIVE_COUNTER_WINDOW = 64;
|
|
145
|
+
/**
|
|
146
|
+
* The newest rows read per category. Each category has its own field, so a flood of junk in one category cannot use up
|
|
147
|
+
* the rows of another.
|
|
148
|
+
*/
|
|
149
|
+
export declare const EXCHANGE_DEPOSIT_ARCHIVE_ROWS_PER_CATEGORY = 20;
|
|
150
|
+
/**
|
|
151
|
+
* The bodies the archive holds for one board and a list of categories. The read never throws: an archive that is down,
|
|
152
|
+
* slow or answers with an error gives no bodies, and the interface then behaves as if there were no archive.
|
|
153
|
+
*
|
|
154
|
+
* @param input.chainId - the board's chain, such as 1 for the mainnet factory
|
|
155
|
+
* @param input.categories - the categories to read, from {@link issuanceCategoryOf}
|
|
156
|
+
* @param input.fetchFunction - the fetch function to use. A test passes a fake.
|
|
157
|
+
* @param input.endpoint - the archive's GraphQL address
|
|
158
|
+
* @returns the hex bodies with their categories. Empty when the archive gave nothing usable.
|
|
159
|
+
*/
|
|
160
|
+
export declare const fetchArchivedPosts: ({ chainId, categories, fetchFunction, endpoint, }: {
|
|
161
|
+
chainId: bigint;
|
|
162
|
+
categories: readonly Hex[];
|
|
163
|
+
fetchFunction?: typeof fetch;
|
|
164
|
+
endpoint?: string;
|
|
165
|
+
}) => Promise<readonly PostedIssuanceBody[]>;
|
|
166
|
+
/**
|
|
167
|
+
* The records the archive holds for one token and fee, found by walking the counters in windows. A window is read
|
|
168
|
+
* only while the window before it held a record, so the walk ends at the first window with nothing in it. A junk
|
|
169
|
+
* record never counts, because it does not open under its own category.
|
|
170
|
+
*
|
|
171
|
+
* An archive that is down gives no records, so the result is the same as no archive.
|
|
172
|
+
*
|
|
173
|
+
* @param input.seed - the 32-byte seed of the recipient
|
|
174
|
+
* @param input.chainId - the board's chain
|
|
175
|
+
* @param input.tokenAddress - the token of the addresses
|
|
176
|
+
* @param input.feeRateE18 - the exact fee of the addresses
|
|
177
|
+
* @param input.fetchFunction - the fetch function to use. A test passes a fake.
|
|
178
|
+
* @param input.endpoint - the archive's GraphQL address
|
|
179
|
+
*/
|
|
180
|
+
export declare const archivedIssuedRecordsOf: ({ seed, chainId, tokenAddress, feeRateE18, fetchFunction, endpoint, }: {
|
|
181
|
+
seed: ExchangeDepositSeed;
|
|
182
|
+
chainId: bigint;
|
|
183
|
+
tokenAddress: Address;
|
|
184
|
+
feeRateE18: bigint;
|
|
185
|
+
fetchFunction?: typeof fetch;
|
|
186
|
+
endpoint?: string;
|
|
187
|
+
}) => Promise<readonly IssuedAddressRecord[]>;
|
|
188
|
+
/** The public demo key of the board. It is the default; the interface passes the key it uses, so a new key needs no change here. */
|
|
189
|
+
export declare const EXCHANGE_DEPOSIT_BOARD_DEMO_KEY = "vk_demo";
|
|
190
|
+
/**
|
|
191
|
+
* The board's endpoint for one chain. The key sits in the path, as the board operator issues it.
|
|
192
|
+
*
|
|
193
|
+
* @param input.key - the board key
|
|
194
|
+
* @param input.chainId - the chain the board serves
|
|
195
|
+
* @returns the endpoint address
|
|
196
|
+
*/
|
|
197
|
+
export declare const boardRpcUrlOf: ({ key, chainId }: {
|
|
198
|
+
key: string;
|
|
199
|
+
chainId: bigint;
|
|
200
|
+
}) => string;
|
|
201
|
+
/** Where one sealed record is posted: the board's chain and its endpoint with the key. */
|
|
202
|
+
export interface IssuedRecordBoardPlan {
|
|
203
|
+
/** The chain the board serves. */
|
|
204
|
+
readonly chainId: bigint;
|
|
205
|
+
/** The board's endpoint for the chain, with its key. */
|
|
206
|
+
readonly rpcUrl: string;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Where a record is posted, or null when it stays in this browser. Only the mainnet factory has a board and an archive,
|
|
210
|
+
* and only an ordinary wallet's seed can be found again from them: a random seed exists in this browser alone. With no
|
|
211
|
+
* sign-in record there is no method, so nothing is posted.
|
|
212
|
+
*
|
|
213
|
+
* @param input.chainId - the chain of the factory
|
|
214
|
+
* @param input.method - how the seed was made, or null when no sign-in record is stored
|
|
215
|
+
* @param input.boardKey - the board key the interface uses
|
|
216
|
+
* @returns the plan, or null when the record is never posted
|
|
217
|
+
*/
|
|
218
|
+
export declare const issuedRecordBoardPlanOf: ({ chainId, method, boardKey, }: {
|
|
219
|
+
chainId: bigint;
|
|
220
|
+
method: StoredSigninRecord["method"] | null;
|
|
221
|
+
boardKey: string;
|
|
222
|
+
}) => IssuedRecordBoardPlan | null;
|
|
223
|
+
/** One sealed record ready to post: the board endpoint, the category and the body. */
|
|
224
|
+
export interface IssuedRecordPost {
|
|
225
|
+
/** The board's endpoint for the chain, with its key. */
|
|
226
|
+
readonly rpcUrl: string;
|
|
227
|
+
/** The category the body is posted under. */
|
|
228
|
+
readonly category: Hex;
|
|
229
|
+
/** The sealed body. */
|
|
230
|
+
readonly body: Hex;
|
|
231
|
+
}
|
|
232
|
+
/** Posts one sealed record to the board. It rejects on failure, and the caller logs it. */
|
|
233
|
+
export type PostIssuedRecord = (post: IssuedRecordPost) => Promise<unknown>;
|
|
234
|
+
/** What the interface needs to remember and post the counters it shows for one sign-in. */
|
|
235
|
+
export interface IssuanceContext {
|
|
236
|
+
/** The chain of the factory. */
|
|
237
|
+
readonly chainId: bigint;
|
|
238
|
+
/** The browser storage that holds the sign-in record. */
|
|
239
|
+
readonly storage: ExchangeDepositSigninStorage;
|
|
240
|
+
/** The key of the sign-in record for this chain, factory, recipient and signer, or null when there is none. */
|
|
241
|
+
readonly storageKey: string | null;
|
|
242
|
+
/** The board key the interface posts with. */
|
|
243
|
+
readonly boardKey: string;
|
|
244
|
+
/** Posts one sealed record to the board. */
|
|
245
|
+
readonly postIssuedRecord: PostIssuedRecord;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* The category and sealed body of one counter, ready to post.
|
|
249
|
+
*
|
|
250
|
+
* @param input.seed - the 32-byte seed of the recipient
|
|
251
|
+
* @param input.tokenAddress - the token of the address
|
|
252
|
+
* @param input.feeRateE18 - the exact fee of the address
|
|
253
|
+
* @param input.counter - the counter shown
|
|
254
|
+
*/
|
|
255
|
+
export declare const sealedIssuedRecordOf: ({ seed, tokenAddress, feeRateE18, counter, }: {
|
|
256
|
+
seed: ExchangeDepositSeed;
|
|
257
|
+
tokenAddress: Address;
|
|
258
|
+
feeRateE18: bigint;
|
|
259
|
+
counter: number;
|
|
260
|
+
}) => Promise<PostedIssuanceBody>;
|
|
261
|
+
/**
|
|
262
|
+
* The highest counter this browser or the archive holds for a token and fee, or null when neither holds one. It does not
|
|
263
|
+
* read the chain: the chain is read separately for its use. The archive is read only where records are posted.
|
|
264
|
+
*
|
|
265
|
+
* @param input.context - the issuance context
|
|
266
|
+
* @param input.seed - the 32-byte seed of the recipient
|
|
267
|
+
* @param input.tokenAddress - the token of the address
|
|
268
|
+
* @param input.feeRateE18 - the exact fee of the address
|
|
269
|
+
*/
|
|
270
|
+
export declare const knownHighestCounterOf: ({ context, seed, tokenAddress, feeRateE18, }: {
|
|
271
|
+
context: IssuanceContext;
|
|
272
|
+
seed: ExchangeDepositSeed;
|
|
273
|
+
tokenAddress: Address;
|
|
274
|
+
feeRateE18: bigint;
|
|
275
|
+
}) => Promise<number | null>;
|
|
276
|
+
/**
|
|
277
|
+
* Whether a counter is new to the records: it is above the highest known one, or none is known. A new counter is the
|
|
278
|
+
* one that is written and posted.
|
|
279
|
+
*
|
|
280
|
+
* @param input.knownHighest - the highest counter the records hold, or null
|
|
281
|
+
* @param input.counter - the counter shown
|
|
282
|
+
*/
|
|
283
|
+
export declare const issuedCounterIsNew: ({ knownHighest, counter }: {
|
|
284
|
+
knownHighest: number | null;
|
|
285
|
+
counter: number;
|
|
286
|
+
}) => boolean;
|
|
287
|
+
/**
|
|
288
|
+
* The highest counter the chain shows in use, from the first counter the chain shows free. Usually the walk from 0 gives
|
|
289
|
+
* one or two reads.
|
|
290
|
+
*
|
|
291
|
+
* @param input.firstFreeCounter - the first counter from 0 with no use on the chain
|
|
292
|
+
* @returns the counter before it, or null when counter 0 is already free
|
|
293
|
+
*/
|
|
294
|
+
export declare const highestUsedCounterOf: ({ firstFreeCounter }: {
|
|
295
|
+
firstFreeCounter: number;
|
|
296
|
+
}) => number | null;
|
|
297
|
+
/**
|
|
298
|
+
* The counter to show on load: the highest of the chain's used counter, the browser record and the archive. With none
|
|
299
|
+
* of them, it is 0. A used address is shown again, because addresses are reusable.
|
|
300
|
+
*
|
|
301
|
+
* @param input.highestUsed - the highest counter used on the chain, or null
|
|
302
|
+
* @param input.knownHighest - the highest counter in the browser record or the archive, or null
|
|
303
|
+
*/
|
|
304
|
+
export declare const counterOnLoadOf: ({ highestUsed, knownHighest, }: {
|
|
305
|
+
highestUsed: number | null;
|
|
306
|
+
knownHighest: number | null;
|
|
307
|
+
}) => number;
|
|
308
|
+
/**
|
|
309
|
+
* Records one counter the interface has shown. The browser record is raised at once, in this call and before any wait.
|
|
310
|
+
* When the counter is new and the record is an ordinary wallet's on the mainnet factory, the sealed record is posted in
|
|
311
|
+
* the background. A failed post is logged and ignored, so it never stops an address from being shown.
|
|
312
|
+
*
|
|
313
|
+
* @param input.context - the issuance context
|
|
314
|
+
* @param input.seed - the 32-byte seed of the recipient
|
|
315
|
+
* @param input.tokenAddress - the token of the address
|
|
316
|
+
* @param input.feeRateE18 - the exact fee of the address
|
|
317
|
+
* @param input.counter - the counter shown
|
|
318
|
+
* @param input.knownHighest - the highest counter already known, or null
|
|
319
|
+
*/
|
|
320
|
+
export declare const recordShownCounter: ({ context, seed, tokenAddress, feeRateE18, counter, knownHighest, }: {
|
|
321
|
+
context: IssuanceContext;
|
|
322
|
+
seed: ExchangeDepositSeed;
|
|
323
|
+
tokenAddress: Address;
|
|
324
|
+
feeRateE18: bigint;
|
|
325
|
+
counter: number;
|
|
326
|
+
knownHighest: number | null;
|
|
327
|
+
}) => Promise<void>;
|