@gibs/bridge-sdk 1.13.0 → 1.17.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/README.md +244 -18
- package/abis/package.json +6 -0
- package/bridge-limits/package.json +6 -0
- package/chain-info/package.json +6 -0
- package/chain-names/package.json +6 -0
- package/chains/package.json +6 -0
- package/claims/package.json +6 -0
- package/config/package.json +6 -0
- package/consolidated-quote/package.json +6 -0
- package/destination-calldata/package.json +6 -0
- package/dist/chain-info.d.ts +1 -1
- package/dist/chain-info.js +11 -12
- package/dist/chains.d.ts +25 -0
- package/dist/chains.js +55 -20
- package/dist/cjs/abis.d.ts +1 -0
- package/dist/cjs/abis.js +19 -0
- package/dist/cjs/bridge-limits.d.ts +103 -0
- package/dist/cjs/bridge-limits.js +89 -0
- package/dist/cjs/chain-info.d.ts +169 -0
- package/dist/cjs/chain-info.js +452 -0
- package/dist/cjs/chain-names.d.ts +160 -0
- package/dist/cjs/chain-names.js +207 -0
- package/dist/cjs/chains.d.ts +90 -0
- package/dist/cjs/chains.js +357 -0
- package/dist/cjs/claims.d.ts +198 -0
- package/dist/cjs/claims.js +182 -0
- package/dist/cjs/config.d.ts +240 -0
- package/dist/cjs/config.js +537 -0
- package/dist/cjs/consolidated-quote.d.ts +648 -0
- package/dist/cjs/consolidated-quote.js +1048 -0
- package/dist/cjs/destination-calldata.d.ts +118 -0
- package/dist/cjs/destination-calldata.js +156 -0
- package/dist/cjs/ecosystems.d.ts +217 -0
- package/dist/cjs/ecosystems.js +298 -0
- package/dist/cjs/execution.d.ts +346 -0
- package/dist/cjs/execution.js +468 -0
- package/dist/cjs/fee-type.d.ts +10 -0
- package/dist/cjs/fee-type.js +10 -0
- package/dist/cjs/hyperliquid-execution.d.ts +152 -0
- package/dist/cjs/hyperliquid-execution.js +175 -0
- package/dist/cjs/image-links.d.ts +117 -0
- package/dist/cjs/image-links.js +153 -0
- package/dist/cjs/index.d.ts +23 -0
- package/dist/cjs/index.js +39 -0
- package/dist/cjs/lifi-execution-guard.d.ts +210 -0
- package/dist/cjs/lifi-execution-guard.js +409 -0
- package/dist/cjs/near-intents-conformance.d.ts +85 -0
- package/dist/cjs/near-intents-conformance.js +337 -0
- package/dist/cjs/near-intents-route.d.ts +47 -0
- package/dist/cjs/near-intents-route.js +303 -0
- package/dist/cjs/near-intents.d.ts +524 -0
- package/dist/cjs/near-intents.js +1071 -0
- package/dist/cjs/origin-deposit.d.ts +326 -0
- package/dist/cjs/origin-deposit.js +82 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/pre-quote.d.ts +198 -0
- package/dist/cjs/pre-quote.js +180 -0
- package/dist/cjs/prices.d.ts +107 -0
- package/dist/cjs/prices.js +172 -0
- package/dist/cjs/providers.d.ts +238 -0
- package/dist/cjs/providers.js +171 -0
- package/dist/cjs/quote-fees.d.ts +102 -0
- package/dist/cjs/quote-fees.js +201 -0
- package/dist/cjs/referral.d.ts +85 -0
- package/dist/cjs/referral.js +85 -0
- package/dist/cjs/relay-currencies.d.ts +47 -0
- package/dist/cjs/relay-currencies.js +95 -0
- package/dist/cjs/relay-depository.d.ts +2 -0
- package/dist/cjs/relay-depository.js +85 -0
- package/dist/cjs/relay-quote.d.ts +301 -0
- package/dist/cjs/relay-quote.js +996 -0
- package/dist/cjs/route-steps.d.ts +138 -0
- package/dist/cjs/route-steps.js +310 -0
- package/dist/cjs/routing/amounts.d.ts +80 -0
- package/dist/cjs/routing/amounts.js +126 -0
- package/dist/cjs/routing/candidate-route.d.ts +43 -0
- package/dist/cjs/routing/candidate-route.js +50 -0
- package/dist/cjs/routing/candidate.d.ts +237 -0
- package/dist/cjs/routing/candidate.js +100 -0
- package/dist/cjs/routing/carriers/ask-answer.d.ts +77 -0
- package/dist/cjs/routing/carriers/ask-answer.js +2 -0
- package/dist/cjs/routing/carriers/omnibridge.d.ts +137 -0
- package/dist/cjs/routing/carriers/omnibridge.js +459 -0
- package/dist/cjs/routing/carriers/pulsex-paths.d.ts +80 -0
- package/dist/cjs/routing/carriers/pulsex-paths.js +97 -0
- package/dist/cjs/routing/carriers/pulsex-split.d.ts +175 -0
- package/dist/cjs/routing/carriers/pulsex-split.js +193 -0
- package/dist/cjs/routing/carriers/pulsex.d.ts +159 -0
- package/dist/cjs/routing/carriers/pulsex.js +565 -0
- package/dist/cjs/routing/carriers/wrap.d.ts +25 -0
- package/dist/cjs/routing/carriers/wrap.js +119 -0
- package/dist/cjs/routing/composed-route-quality.d.ts +125 -0
- package/dist/cjs/routing/composed-route-quality.js +144 -0
- package/dist/cjs/routing/entry-chain-anchor.d.ts +88 -0
- package/dist/cjs/routing/entry-chain-anchor.js +59 -0
- package/dist/cjs/routing/format.d.ts +31 -0
- package/dist/cjs/routing/format.js +64 -0
- package/dist/cjs/routing/index.d.ts +38 -0
- package/dist/cjs/routing/index.js +134 -0
- package/dist/cjs/routing/producers.d.ts +770 -0
- package/dist/cjs/routing/producers.js +1617 -0
- package/dist/cjs/routing/providers.d.ts +31 -0
- package/dist/cjs/routing/providers.js +48 -0
- package/dist/cjs/routing/route-data.d.ts +355 -0
- package/dist/cjs/routing/route-data.js +2 -0
- package/dist/cjs/routing/search/compose.d.ts +168 -0
- package/dist/cjs/routing/search/compose.js +104 -0
- package/dist/cjs/routing/search/graph.d.ts +668 -0
- package/dist/cjs/routing/search/graph.js +461 -0
- package/dist/cjs/routing/search/plan-route-data.d.ts +269 -0
- package/dist/cjs/routing/search/plan-route-data.js +848 -0
- package/dist/cjs/routing/search/score.d.ts +356 -0
- package/dist/cjs/routing/search/score.js +445 -0
- package/dist/cjs/routing/swap-transactions.d.ts +91 -0
- package/dist/cjs/routing/swap-transactions.js +131 -0
- package/dist/cjs/routing/usd-value.d.ts +17 -0
- package/dist/cjs/routing/usd-value.js +29 -0
- package/dist/cjs/settings.d.ts +785 -0
- package/dist/cjs/settings.js +1074 -0
- package/dist/cjs/ton-connect.d.ts +98 -0
- package/dist/cjs/ton-connect.js +206 -0
- package/dist/cjs/ton-execution.d.ts +7 -0
- package/dist/cjs/ton-execution.js +23 -0
- package/dist/cjs/ton.d.ts +37 -0
- package/dist/cjs/ton.js +83 -0
- package/dist/cjs/tron-execution.d.ts +146 -0
- package/dist/cjs/tron-execution.js +248 -0
- package/dist/cjs/types.d.ts +51 -0
- package/dist/cjs/types.js +2 -0
- package/dist/claims.d.ts +198 -0
- package/dist/claims.js +140 -0
- package/dist/config.d.ts +24 -0
- package/dist/config.js +39 -5
- package/dist/consolidated-quote.d.ts +109 -15
- package/dist/consolidated-quote.js +310 -52
- package/dist/execution.d.ts +346 -0
- package/dist/execution.js +428 -0
- package/dist/hyperliquid-execution.js +2 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/lifi-execution-guard.d.ts +13 -2
- package/dist/lifi-execution-guard.js +4 -0
- package/dist/near-intents.js +2 -3
- package/dist/pre-quote.d.ts +6 -6
- package/dist/pre-quote.js +10 -14
- package/dist/providers.d.ts +17 -0
- package/dist/providers.js +6 -0
- package/dist/referral.d.ts +12 -4
- package/dist/referral.js +12 -4
- package/dist/relay-depository.d.ts +2 -0
- package/dist/relay-depository.js +82 -0
- package/dist/relay-quote.js +2 -3
- package/dist/routing/candidate.d.ts +3 -3
- package/dist/routing/candidate.js +3 -3
- package/dist/routing/carriers/ask-answer.d.ts +19 -0
- package/dist/routing/carriers/omnibridge.js +23 -21
- package/dist/routing/carriers/pulsex-paths.d.ts +80 -0
- package/dist/routing/carriers/pulsex-paths.js +92 -0
- package/dist/routing/carriers/pulsex-split.d.ts +175 -0
- package/dist/routing/carriers/pulsex-split.js +185 -0
- package/dist/routing/carriers/pulsex.d.ts +69 -21
- package/dist/routing/carriers/pulsex.js +184 -65
- package/dist/routing/composed-route-quality.d.ts +28 -6
- package/dist/routing/composed-route-quality.js +36 -5
- package/dist/routing/entry-chain-anchor.d.ts +1 -1
- package/dist/routing/entry-chain-anchor.js +1 -1
- package/dist/routing/index.d.ts +7 -3
- package/dist/routing/index.js +7 -3
- package/dist/routing/producers.js +1 -1
- package/dist/routing/providers.d.ts +5 -0
- package/dist/routing/providers.js +5 -0
- package/dist/routing/search/graph.d.ts +29 -0
- package/dist/routing/search/plan-route-data.d.ts +25 -0
- package/dist/routing/search/plan-route-data.js +43 -7
- package/dist/routing/search/score.d.ts +33 -1
- package/dist/routing/search/score.js +41 -6
- package/dist/routing/swap-transactions.d.ts +91 -0
- package/dist/routing/swap-transactions.js +125 -0
- package/dist/settings.d.ts +94 -1
- package/dist/settings.js +95 -3
- package/dist/ton-connect.d.ts +98 -0
- package/dist/ton-connect.js +200 -0
- package/dist/ton-execution.d.ts +4 -114
- package/dist/ton-execution.js +4 -244
- package/dist/ton.d.ts +37 -0
- package/dist/ton.js +65 -0
- package/docs/examples/example-a-ether-to-pulse.ts +300 -0
- package/docs/examples/example-b-token-pulsechain-to-ethereum.ts +270 -0
- package/docs/examples/shared.ts +261 -0
- package/docs/examples/tsconfig.json +18 -0
- package/docs/integration-guide.md +617 -0
- package/ecosystems/package.json +6 -0
- package/execution/package.json +6 -0
- package/fee-type/package.json +6 -0
- package/hyperliquid-execution/package.json +6 -0
- package/image-links/package.json +6 -0
- package/lifi-execution-guard/package.json +6 -0
- package/llms.txt +234 -0
- package/near-intents/package.json +6 -0
- package/near-intents-route/package.json +6 -0
- package/origin-deposit/package.json +6 -0
- package/package.json +818 -10
- package/pre-quote/package.json +6 -0
- package/prices/package.json +6 -0
- package/providers/package.json +6 -0
- package/quote-fees/package.json +6 -0
- package/referral/package.json +6 -0
- package/relay-currencies/package.json +6 -0
- package/relay-quote/package.json +6 -0
- package/route-steps/package.json +6 -0
- package/routing/package.json +6 -0
- package/settings/package.json +6 -0
- package/ton/package.json +6 -0
- package/ton-connect/package.json +6 -0
- package/ton-execution/package.json +6 -0
- package/tron-execution/package.json +6 -0
- package/types/package.json +6 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildHyperliquidAuthorizationRequest = exports.buildHyperliquidAuthorizationTypedData = exports.isHyperliquidExchangeSuccess = exports.buildHyperliquidExchangeRequest = exports.buildHyperliquidTypedData = exports.hyperliquidVerifyingContract = exports.hyperliquidDomainVersion = exports.hyperliquidDomainName = exports.hyperliquidExchangeUrl = void 0;
|
|
4
|
+
const url_1 = require("@gibs/common/url");
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const relay_quote_js_1 = require("./relay-quote.js");
|
|
7
|
+
/**
|
|
8
|
+
* Executing a Hyperliquid deposit, as pure data.
|
|
9
|
+
*
|
|
10
|
+
* Hyperliquid is the one origin whose deposit is never broadcast to a chain.
|
|
11
|
+
* The user signs a typed-data ACTION and that signed action is posted to
|
|
12
|
+
* Hyperliquid's own exchange API; Relay then observes the transfer and fills the
|
|
13
|
+
* route. Two details make this impossible to derive from the quote alone, and
|
|
14
|
+
* both are encoded here rather than rediscovered at a call site:
|
|
15
|
+
*
|
|
16
|
+
* 1. Relay's quote supplies `eip712Types`, `eip712PrimaryType` and the action,
|
|
17
|
+
* but NOT the signing domain. The domain is fixed by Hyperliquid and is
|
|
18
|
+
* reconstructed by {@link buildHyperliquidTypedData}.
|
|
19
|
+
* 2. Hyperliquid wants the signature split into `r`/`s`/`v` components, not the
|
|
20
|
+
* concatenated hex string a wallet returns.
|
|
21
|
+
*
|
|
22
|
+
* Kept free of transport so it is fully testable: nothing here signs, fetches,
|
|
23
|
+
* or reads a clock. The caller supplies the signature and performs the request.
|
|
24
|
+
*
|
|
25
|
+
* The shape mirrors Relay's own client, which is the only reference
|
|
26
|
+
* implementation of this exchange — their public documentation covers the
|
|
27
|
+
* generic `signature` step but not this action-bearing `transaction` step.
|
|
28
|
+
*/
|
|
29
|
+
/** Where a signed Hyperliquid action is submitted. Hyperliquid's API, not Relay's. */
|
|
30
|
+
exports.hyperliquidExchangeUrl = 'https://api.hyperliquid.xyz/exchange';
|
|
31
|
+
/** The signing domain Hyperliquid requires. Fixed; never supplied by the quote. */
|
|
32
|
+
exports.hyperliquidDomainName = 'HyperliquidSignTransaction';
|
|
33
|
+
/** The signing domain's version. Fixed alongside {@link hyperliquidDomainName}. */
|
|
34
|
+
exports.hyperliquidDomainVersion = '1';
|
|
35
|
+
/**
|
|
36
|
+
* The domain's `verifyingContract`. Hyperliquid actions are verified off-chain,
|
|
37
|
+
* so no contract is involved and the field is the all-zero address.
|
|
38
|
+
*/
|
|
39
|
+
exports.hyperliquidVerifyingContract = '0x0000000000000000000000000000000000000000';
|
|
40
|
+
/** The standard typed-data domain type, which the action's type table must include. */
|
|
41
|
+
const eip712DomainType = [
|
|
42
|
+
{ name: 'name', type: 'string' },
|
|
43
|
+
{ name: 'version', type: 'string' },
|
|
44
|
+
{ name: 'chainId', type: 'uint256' },
|
|
45
|
+
{ name: 'verifyingContract', type: 'address' },
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* Builds the typed-data payload for a Hyperliquid deposit.
|
|
49
|
+
*
|
|
50
|
+
* The message is the action's parameters plus the action `type` and a
|
|
51
|
+
* `signatureChainId`; the latter is the signing chain in hex and MUST agree
|
|
52
|
+
* with `domain.chainId`, because Hyperliquid recovers the signer using both.
|
|
53
|
+
* They are derived from the single `signatureChainId` argument so they cannot
|
|
54
|
+
* disagree.
|
|
55
|
+
*
|
|
56
|
+
* @param deposit - the parsed Hyperliquid origin deposit
|
|
57
|
+
* @param options.signatureChainId - the chain id the connected wallet signs
|
|
58
|
+
* under. Not the Relay origin chain id: it identifies the signing domain, and
|
|
59
|
+
* Relay's own client uses the wallet's active chain here.
|
|
60
|
+
* @returns the payload to sign, whose `message` doubles as the submitted action
|
|
61
|
+
*/
|
|
62
|
+
const buildHyperliquidTypedData = (deposit, { signatureChainId }) => ({
|
|
63
|
+
domain: {
|
|
64
|
+
name: exports.hyperliquidDomainName,
|
|
65
|
+
version: exports.hyperliquidDomainVersion,
|
|
66
|
+
chainId: signatureChainId,
|
|
67
|
+
verifyingContract: exports.hyperliquidVerifyingContract,
|
|
68
|
+
},
|
|
69
|
+
types: {
|
|
70
|
+
...deposit.eip712Types,
|
|
71
|
+
EIP712Domain: eip712DomainType,
|
|
72
|
+
},
|
|
73
|
+
primaryType: deposit.eip712PrimaryType,
|
|
74
|
+
message: {
|
|
75
|
+
...deposit.action.parameters,
|
|
76
|
+
type: deposit.action.type,
|
|
77
|
+
signatureChainId: `0x${signatureChainId.toString(16)}`,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
exports.buildHyperliquidTypedData = buildHyperliquidTypedData;
|
|
81
|
+
/**
|
|
82
|
+
* Builds the exchange request for an action the user has signed.
|
|
83
|
+
*
|
|
84
|
+
* The nonce is read back out of the signed message rather than passed in: it is
|
|
85
|
+
* covered by the signature, so any independently supplied value could disagree
|
|
86
|
+
* with what was signed and be rejected.
|
|
87
|
+
*
|
|
88
|
+
* @param options.typedData - the payload that was signed
|
|
89
|
+
* @param options.signature - the wallet's signature over it
|
|
90
|
+
* @returns the request body, or null when the signed action carries no usable nonce
|
|
91
|
+
*/
|
|
92
|
+
const buildHyperliquidExchangeRequest = ({ typedData, signature, }) => {
|
|
93
|
+
// Hyperliquid names it `nonce`; the older action shapes name it `time`.
|
|
94
|
+
const rawNonce = typedData.message.nonce ?? typedData.message.time;
|
|
95
|
+
if (typeof rawNonce !== 'number' && typeof rawNonce !== 'bigint') {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const { r, s, v, yParity } = (0, viem_1.parseSignature)(signature);
|
|
99
|
+
return {
|
|
100
|
+
// The exchange wants the 27/28 form. A signature whose final byte is the
|
|
101
|
+
// PARITY form (0 or 1) — which some hardware wallets and smart-account flows
|
|
102
|
+
// produce — parses with `v` absent and the parity carried separately, so
|
|
103
|
+
// reading `v` alone and defaulting would send recovery value 0: not a value
|
|
104
|
+
// the exchange accepts, and the deposit dies for those wallets only. The
|
|
105
|
+
// parity is the same fact in the other encoding, so shift it rather than
|
|
106
|
+
// guess.
|
|
107
|
+
signature: { r, s, v: v === undefined ? yParity + 27 : Number(v) },
|
|
108
|
+
nonce: Number(rawNonce),
|
|
109
|
+
action: typedData.message,
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
exports.buildHyperliquidExchangeRequest = buildHyperliquidExchangeRequest;
|
|
113
|
+
/**
|
|
114
|
+
* Whether an exchange response reports success. Hyperliquid answers with HTTP
|
|
115
|
+
* 200 even for a rejected action, so the body's own status is the only reliable
|
|
116
|
+
* signal — treating the status code as the outcome would report a failed
|
|
117
|
+
* transfer as a completed one.
|
|
118
|
+
*
|
|
119
|
+
* @param payload - the parsed response body
|
|
120
|
+
* @returns true only when the body explicitly reports success
|
|
121
|
+
*/
|
|
122
|
+
const isHyperliquidExchangeSuccess = (payload) => {
|
|
123
|
+
if (typeof payload !== 'object' || payload === null) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
return payload.status === 'ok';
|
|
127
|
+
};
|
|
128
|
+
exports.isHyperliquidExchangeSuccess = isHyperliquidExchangeSuccess;
|
|
129
|
+
/**
|
|
130
|
+
* The typed-data payload for the authorization that must be completed BEFORE
|
|
131
|
+
* the action is submitted.
|
|
132
|
+
*
|
|
133
|
+
* Relay builds the authorization against a chain it picks when quoting, but the
|
|
134
|
+
* signature is produced by whichever chain the wallet is actually on. Both the
|
|
135
|
+
* domain here and `signatureChainId` in {@link buildHyperliquidAuthorizationRequest}
|
|
136
|
+
* are therefore overridden with the active wallet chain; leaving Relay's value in
|
|
137
|
+
* place makes the recovered signer disagree with the submitted one and the
|
|
138
|
+
* authorization is rejected.
|
|
139
|
+
*
|
|
140
|
+
* @param authorization - the authorization carried by the deposit
|
|
141
|
+
* @param options.signatureChainId - the chain id the connected wallet signs under
|
|
142
|
+
* @returns the payload to sign
|
|
143
|
+
*/
|
|
144
|
+
const buildHyperliquidAuthorizationTypedData = (authorization, { signatureChainId }) => ({
|
|
145
|
+
domain: {
|
|
146
|
+
...authorization.sign.domain,
|
|
147
|
+
chainId: signatureChainId,
|
|
148
|
+
},
|
|
149
|
+
types: authorization.sign.types,
|
|
150
|
+
primaryType: authorization.sign.primaryType,
|
|
151
|
+
message: authorization.sign.value,
|
|
152
|
+
});
|
|
153
|
+
exports.buildHyperliquidAuthorizationTypedData = buildHyperliquidAuthorizationTypedData;
|
|
154
|
+
/**
|
|
155
|
+
* Builds the authorization submission for a signed authorization.
|
|
156
|
+
*
|
|
157
|
+
* @param options.authorization - the authorization that was signed
|
|
158
|
+
* @param options.signature - the wallet's signature over its typed data
|
|
159
|
+
* @param options.signatureChainId - the chain id the wallet signed under, which
|
|
160
|
+
* replaces the value Relay quoted so the body agrees with the signature
|
|
161
|
+
* @param options.baseUrl - Relay's API root; the step's endpoint is relative
|
|
162
|
+
* @returns the request to perform, or null when the endpoint is not a usable path
|
|
163
|
+
*/
|
|
164
|
+
const buildHyperliquidAuthorizationRequest = ({ authorization, signature, signatureChainId, baseUrl = relay_quote_js_1.relayApiBaseUrl, }) => {
|
|
165
|
+
const { endpoint, method, body } = authorization.post;
|
|
166
|
+
if (!endpoint.startsWith('/')) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
url: (0, url_1.buildUrl)(`${baseUrl}${endpoint}`, { signature }),
|
|
171
|
+
method,
|
|
172
|
+
body: { ...body, signatureChainId },
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
exports.buildHyperliquidAuthorizationRequest = buildHyperliquidAuthorizationRequest;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { type DepositAddressChain } from './chain-names.js';
|
|
2
|
+
/**
|
|
3
|
+
* Sets the image root for the bridge
|
|
4
|
+
* @param root - the root
|
|
5
|
+
*/
|
|
6
|
+
export declare const setImageRoot: (root: string) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Returns the image root for the bridge
|
|
9
|
+
* @returns the image root
|
|
10
|
+
*/
|
|
11
|
+
export declare const getImageRoot: () => string;
|
|
12
|
+
/** The minimal token info */
|
|
13
|
+
interface MinimalTokenInfo {
|
|
14
|
+
chainId: number;
|
|
15
|
+
address: string;
|
|
16
|
+
logoURI?: string | null;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Returns the list image for the given path
|
|
20
|
+
* @param path - the path
|
|
21
|
+
* @returns the list image
|
|
22
|
+
*/
|
|
23
|
+
export declare const list: (path: string) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Returns the network image for the given chain id
|
|
26
|
+
* @param chainId - the chain id
|
|
27
|
+
* @returns the network image
|
|
28
|
+
*/
|
|
29
|
+
export declare const network: (chainId: number) => string;
|
|
30
|
+
/**
|
|
31
|
+
* gib.show's own key for a chain this package can only name by a LOCAL,
|
|
32
|
+
* INVENTED identifier — a pay-by-hand origin (see `depositAddressChainIds`)
|
|
33
|
+
* rather than a real chain id gib.show's numeric endpoint recognizes.
|
|
34
|
+
* `network(chainId)` 404s for one of these, and the browser draws that 404 as
|
|
35
|
+
* a broken image on every chain badge and route mark drawn through it.
|
|
36
|
+
*
|
|
37
|
+
* Every route producer that draws a chain badge for a token needs this, not
|
|
38
|
+
* only the deposit-address ones: a route can START on a deposit-address chain
|
|
39
|
+
* and cross through ordinary Ethereum-Virtual-Machine chains after, so the
|
|
40
|
+
* predicate has to run on every chain id a route touches, not only the one
|
|
41
|
+
* the reader picked. Kept beside `network` rather than in the client that also
|
|
42
|
+
* resolves Relay's pseudo chains (`@gibs/bridge-client/image`'s
|
|
43
|
+
* `chainLogoUrl`) because that client sits ABOVE this package — it imports
|
|
44
|
+
* FROM `bridge-sdk` — so this package importing back from it would be a
|
|
45
|
+
* cycle. `chainLogoUrl` still adds a Relay-icon fallback for chains gib.show
|
|
46
|
+
* does not carry at ALL (Eclipse, Hyperliquid); this table is only the
|
|
47
|
+
* chains gib.show DOES carry, under a key other than their numeric id.
|
|
48
|
+
*
|
|
49
|
+
* EXPORTED, and this is the ONLY place a pay-by-hand chain's gib.show key is
|
|
50
|
+
* declared. `@gibs/bridge-client`'s `image.ts` used to hard-code its own copy
|
|
51
|
+
* of the same `zcash → 'bip122-133'` entry; it now spreads this map into its
|
|
52
|
+
* own icon table instead, because the dependency runs one way — the client
|
|
53
|
+
* already imports from this package — so there was never a cycle stopping it.
|
|
54
|
+
*/
|
|
55
|
+
export declare const pseudoChainGibShowIdentifierByChain: Record<DepositAddressChain, string>;
|
|
56
|
+
/** {@link pseudoChainGibShowIdentifierByChain}, keyed by chain id for lookup. */
|
|
57
|
+
export declare const pseudoChainGibShowIdentifier: Readonly<Record<number, string>>;
|
|
58
|
+
/**
|
|
59
|
+
* The network image for a chain id, honouring a pseudo chain's own gib.show
|
|
60
|
+
* key when its numeric id is not one gib.show's `/image/<id>` endpoint knows.
|
|
61
|
+
*
|
|
62
|
+
* @param chainId - the chain id, a deposit-address chain's local identifier included
|
|
63
|
+
* @returns a working network/chain-badge image url
|
|
64
|
+
*/
|
|
65
|
+
export declare const networkOrPseudo: (chainId: number) => string;
|
|
66
|
+
/**
|
|
67
|
+
* Returns the image url for the given token info.
|
|
68
|
+
*
|
|
69
|
+
* The gas token is asked for by BOTH of its keys, because the service keys it
|
|
70
|
+
* two ways and each chain carries only one of them. `<chain>/<zero address>` is
|
|
71
|
+
* a dedicated picture — Ethereum's ether diamond, PulseChain's mark — and
|
|
72
|
+
* Binance Smart Chain has none, so asking for it there returns a 404 the browser
|
|
73
|
+
* draws as a broken image. The empty-address form `<chain>/` is the chain's own
|
|
74
|
+
* mark, which every chain has.
|
|
75
|
+
*
|
|
76
|
+
* The order is NOT interchangeable. The service serves the first source that
|
|
77
|
+
* resolves, so a chain with a dedicated picture keeps it; reversed, Ethereum
|
|
78
|
+
* would show the network logo where the ether logo belongs (the two are
|
|
79
|
+
* genuinely different files). The pair is for the gas token alone: pairing an
|
|
80
|
+
* ordinary contract address with the chain mark would hide a missing token logo
|
|
81
|
+
* behind the network's, showing the wrong token rather than an honest fallback.
|
|
82
|
+
*
|
|
83
|
+
* @param t - the token info
|
|
84
|
+
* @returns the image url
|
|
85
|
+
*/
|
|
86
|
+
export declare const image: (t: MinimalTokenInfo) => string;
|
|
87
|
+
/**
|
|
88
|
+
* {@link image}, but falling back to the token's own CHAIN mark rather than
|
|
89
|
+
* throwing or asking the service for a picture that was never going to exist,
|
|
90
|
+
* when the token carries no address a picture can be resolved from yet.
|
|
91
|
+
*
|
|
92
|
+
* WHY THIS EXISTS SEPARATELY FROM `image`. A route producer can reach the
|
|
93
|
+
* moment it draws a DELIVERED token's picture before that token's exact
|
|
94
|
+
* on-chain address is known — a not-yet-bridged token's `assetOutAddress` is
|
|
95
|
+
* documented to arrive `null` (see the repository's own "Not-Yet-Bridged
|
|
96
|
+
* Tokens" gotcha), and a deferred crossing's landing token is exactly this
|
|
97
|
+
* case: the reader has not yet signed the leg that would settle it. `image`
|
|
98
|
+
* either throws (`getAddress` refuses a malformed or empty string) or, for a
|
|
99
|
+
* caller that swallows the throw, silently draws nothing — the same "blank
|
|
100
|
+
* disc" defect the carrier marks were fixed for, one token lower. The chain's
|
|
101
|
+
* own mark is a real, recognisable picture that is honest about what is
|
|
102
|
+
* known: THIS chain, a token not yet resolved on it — the same trade
|
|
103
|
+
* `trackerView.ts`'s `depositAddressChainLogoFallback` already makes for a
|
|
104
|
+
* pay-by-hand ORIGIN with no address of its own.
|
|
105
|
+
*
|
|
106
|
+
* @param t - the token to draw
|
|
107
|
+
* @returns the token's own picture, or its chain's mark when the token's
|
|
108
|
+
* address cannot be resolved into one
|
|
109
|
+
*/
|
|
110
|
+
export declare const tokenImageOrChainFallback: (t: MinimalTokenInfo) => string;
|
|
111
|
+
/**
|
|
112
|
+
* Returns a url that will lookup all sources for the given array
|
|
113
|
+
* @param sources - the sources
|
|
114
|
+
* @returns the images
|
|
115
|
+
*/
|
|
116
|
+
export declare const images: (sources: string[]) => string;
|
|
117
|
+
export {};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.images = exports.tokenImageOrChainFallback = exports.image = exports.networkOrPseudo = exports.pseudoChainGibShowIdentifier = exports.pseudoChainGibShowIdentifierByChain = exports.network = exports.list = exports.getImageRoot = exports.setImageRoot = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const chain_names_js_1 = require("./chain-names.js");
|
|
6
|
+
const ecosystems_js_1 = require("./ecosystems.js");
|
|
7
|
+
let imageRoot = 'https://gib.show';
|
|
8
|
+
/**
|
|
9
|
+
* Sets the image root for the bridge
|
|
10
|
+
* @param root - the root
|
|
11
|
+
*/
|
|
12
|
+
const setImageRoot = (root) => {
|
|
13
|
+
imageRoot = root;
|
|
14
|
+
};
|
|
15
|
+
exports.setImageRoot = setImageRoot;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the image root for the bridge
|
|
18
|
+
* @returns the image root
|
|
19
|
+
*/
|
|
20
|
+
const getImageRoot = () => imageRoot;
|
|
21
|
+
exports.getImageRoot = getImageRoot;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the list image for the given path
|
|
24
|
+
* @param path - the path
|
|
25
|
+
* @returns the list image
|
|
26
|
+
*/
|
|
27
|
+
const list = (path) => {
|
|
28
|
+
return `${imageRoot}/list${path}`;
|
|
29
|
+
};
|
|
30
|
+
exports.list = list;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the network image for the given chain id
|
|
33
|
+
* @param chainId - the chain id
|
|
34
|
+
* @returns the network image
|
|
35
|
+
*/
|
|
36
|
+
const network = (chainId) => `${imageRoot}/image/${Number(chainId)}`;
|
|
37
|
+
exports.network = network;
|
|
38
|
+
/**
|
|
39
|
+
* gib.show's own key for a chain this package can only name by a LOCAL,
|
|
40
|
+
* INVENTED identifier — a pay-by-hand origin (see `depositAddressChainIds`)
|
|
41
|
+
* rather than a real chain id gib.show's numeric endpoint recognizes.
|
|
42
|
+
* `network(chainId)` 404s for one of these, and the browser draws that 404 as
|
|
43
|
+
* a broken image on every chain badge and route mark drawn through it.
|
|
44
|
+
*
|
|
45
|
+
* Every route producer that draws a chain badge for a token needs this, not
|
|
46
|
+
* only the deposit-address ones: a route can START on a deposit-address chain
|
|
47
|
+
* and cross through ordinary Ethereum-Virtual-Machine chains after, so the
|
|
48
|
+
* predicate has to run on every chain id a route touches, not only the one
|
|
49
|
+
* the reader picked. Kept beside `network` rather than in the client that also
|
|
50
|
+
* resolves Relay's pseudo chains (`@gibs/bridge-client/image`'s
|
|
51
|
+
* `chainLogoUrl`) because that client sits ABOVE this package — it imports
|
|
52
|
+
* FROM `bridge-sdk` — so this package importing back from it would be a
|
|
53
|
+
* cycle. `chainLogoUrl` still adds a Relay-icon fallback for chains gib.show
|
|
54
|
+
* does not carry at ALL (Eclipse, Hyperliquid); this table is only the
|
|
55
|
+
* chains gib.show DOES carry, under a key other than their numeric id.
|
|
56
|
+
*
|
|
57
|
+
* EXPORTED, and this is the ONLY place a pay-by-hand chain's gib.show key is
|
|
58
|
+
* declared. `@gibs/bridge-client`'s `image.ts` used to hard-code its own copy
|
|
59
|
+
* of the same `zcash → 'bip122-133'` entry; it now spreads this map into its
|
|
60
|
+
* own icon table instead, because the dependency runs one way — the client
|
|
61
|
+
* already imports from this package — so there was never a cycle stopping it.
|
|
62
|
+
*/
|
|
63
|
+
exports.pseudoChainGibShowIdentifierByChain = {
|
|
64
|
+
zcash: 'bip122-133',
|
|
65
|
+
};
|
|
66
|
+
/** {@link pseudoChainGibShowIdentifierByChain}, keyed by chain id for lookup. */
|
|
67
|
+
exports.pseudoChainGibShowIdentifier = Object.fromEntries(Object.keys(chain_names_js_1.depositAddressChainIds).map((chain) => [
|
|
68
|
+
chain_names_js_1.depositAddressChainIds[chain],
|
|
69
|
+
exports.pseudoChainGibShowIdentifierByChain[chain],
|
|
70
|
+
]));
|
|
71
|
+
/**
|
|
72
|
+
* The network image for a chain id, honouring a pseudo chain's own gib.show
|
|
73
|
+
* key when its numeric id is not one gib.show's `/image/<id>` endpoint knows.
|
|
74
|
+
*
|
|
75
|
+
* @param chainId - the chain id, a deposit-address chain's local identifier included
|
|
76
|
+
* @returns a working network/chain-badge image url
|
|
77
|
+
*/
|
|
78
|
+
const networkOrPseudo = (chainId) => {
|
|
79
|
+
const identifier = exports.pseudoChainGibShowIdentifier[chainId];
|
|
80
|
+
return identifier !== undefined ? `${imageRoot}/image/${identifier}` : (0, exports.network)(chainId);
|
|
81
|
+
};
|
|
82
|
+
exports.networkOrPseudo = networkOrPseudo;
|
|
83
|
+
/**
|
|
84
|
+
* Returns the image url for the given token info.
|
|
85
|
+
*
|
|
86
|
+
* The gas token is asked for by BOTH of its keys, because the service keys it
|
|
87
|
+
* two ways and each chain carries only one of them. `<chain>/<zero address>` is
|
|
88
|
+
* a dedicated picture — Ethereum's ether diamond, PulseChain's mark — and
|
|
89
|
+
* Binance Smart Chain has none, so asking for it there returns a 404 the browser
|
|
90
|
+
* draws as a broken image. The empty-address form `<chain>/` is the chain's own
|
|
91
|
+
* mark, which every chain has.
|
|
92
|
+
*
|
|
93
|
+
* The order is NOT interchangeable. The service serves the first source that
|
|
94
|
+
* resolves, so a chain with a dedicated picture keeps it; reversed, Ethereum
|
|
95
|
+
* would show the network logo where the ether logo belongs (the two are
|
|
96
|
+
* genuinely different files). The pair is for the gas token alone: pairing an
|
|
97
|
+
* ordinary contract address with the chain mark would hide a missing token logo
|
|
98
|
+
* behind the network's, showing the wrong token rather than an honest fallback.
|
|
99
|
+
*
|
|
100
|
+
* @param t - the token info
|
|
101
|
+
* @returns the image url
|
|
102
|
+
*/
|
|
103
|
+
const image = (t) => {
|
|
104
|
+
if (t.logoURI)
|
|
105
|
+
return t.logoURI;
|
|
106
|
+
if ((0, ecosystems_js_1.isNativeAsset)(t.address, 'evm')) {
|
|
107
|
+
return (0, exports.images)([`${Number(t.chainId)}/${viem_1.zeroAddress}`, `${Number(t.chainId)}/`]);
|
|
108
|
+
}
|
|
109
|
+
return `${(0, exports.network)(t.chainId)}/${(0, viem_1.getAddress)(t.address)}`;
|
|
110
|
+
};
|
|
111
|
+
exports.image = image;
|
|
112
|
+
/**
|
|
113
|
+
* Whether `address` is a real Ethereum-Virtual-Machine address {@link image}
|
|
114
|
+
* can ask the service about — the zero address included, since that is
|
|
115
|
+
* {@link isNativeAsset}'s own case and {@link image} handles it without
|
|
116
|
+
* `getAddress` ever running.
|
|
117
|
+
*
|
|
118
|
+
* @param address - the address to check
|
|
119
|
+
* @returns true when `getAddress` can checksum it without throwing
|
|
120
|
+
*/
|
|
121
|
+
const isResolvableEvmAddress = (address) => /^0x[0-9a-fA-F]{40}$/.test(address);
|
|
122
|
+
/**
|
|
123
|
+
* {@link image}, but falling back to the token's own CHAIN mark rather than
|
|
124
|
+
* throwing or asking the service for a picture that was never going to exist,
|
|
125
|
+
* when the token carries no address a picture can be resolved from yet.
|
|
126
|
+
*
|
|
127
|
+
* WHY THIS EXISTS SEPARATELY FROM `image`. A route producer can reach the
|
|
128
|
+
* moment it draws a DELIVERED token's picture before that token's exact
|
|
129
|
+
* on-chain address is known — a not-yet-bridged token's `assetOutAddress` is
|
|
130
|
+
* documented to arrive `null` (see the repository's own "Not-Yet-Bridged
|
|
131
|
+
* Tokens" gotcha), and a deferred crossing's landing token is exactly this
|
|
132
|
+
* case: the reader has not yet signed the leg that would settle it. `image`
|
|
133
|
+
* either throws (`getAddress` refuses a malformed or empty string) or, for a
|
|
134
|
+
* caller that swallows the throw, silently draws nothing — the same "blank
|
|
135
|
+
* disc" defect the carrier marks were fixed for, one token lower. The chain's
|
|
136
|
+
* own mark is a real, recognisable picture that is honest about what is
|
|
137
|
+
* known: THIS chain, a token not yet resolved on it — the same trade
|
|
138
|
+
* `trackerView.ts`'s `depositAddressChainLogoFallback` already makes for a
|
|
139
|
+
* pay-by-hand ORIGIN with no address of its own.
|
|
140
|
+
*
|
|
141
|
+
* @param t - the token to draw
|
|
142
|
+
* @returns the token's own picture, or its chain's mark when the token's
|
|
143
|
+
* address cannot be resolved into one
|
|
144
|
+
*/
|
|
145
|
+
const tokenImageOrChainFallback = (t) => isResolvableEvmAddress(t.address) ? (0, exports.image)(t) : (0, exports.networkOrPseudo)(t.chainId);
|
|
146
|
+
exports.tokenImageOrChainFallback = tokenImageOrChainFallback;
|
|
147
|
+
/**
|
|
148
|
+
* Returns a url that will lookup all sources for the given array
|
|
149
|
+
* @param sources - the sources
|
|
150
|
+
* @returns the images
|
|
151
|
+
*/
|
|
152
|
+
const images = (sources) => `${imageRoot}/image/?${sources.map((s) => `i=${s}`).join('&')}`;
|
|
153
|
+
exports.images = images;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from './abis.js';
|
|
2
|
+
export * from './bridge-limits.js';
|
|
3
|
+
export * from './chain-info.js';
|
|
4
|
+
export * from './chains.js';
|
|
5
|
+
export * from './config.js';
|
|
6
|
+
export * from './consolidated-quote.js';
|
|
7
|
+
export * from './relay-quote.js';
|
|
8
|
+
export * from './relay-currencies.js';
|
|
9
|
+
export * from './destination-calldata.js';
|
|
10
|
+
export * from './ecosystems.js';
|
|
11
|
+
export * from './fee-type.js';
|
|
12
|
+
export * from './image-links.js';
|
|
13
|
+
export * from './lifi-execution-guard.js';
|
|
14
|
+
export * from './origin-deposit.js';
|
|
15
|
+
export * from './providers.js';
|
|
16
|
+
export * from './referral.js';
|
|
17
|
+
export * from './route-steps.js';
|
|
18
|
+
export * from './routing/index.js';
|
|
19
|
+
export * from './settings.js';
|
|
20
|
+
export * from './types.js';
|
|
21
|
+
export * from './claims.js';
|
|
22
|
+
export * from './execution.js';
|
|
23
|
+
export * from './relay-depository.js';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./abis.js"), exports);
|
|
18
|
+
__exportStar(require("./bridge-limits.js"), exports);
|
|
19
|
+
__exportStar(require("./chain-info.js"), exports);
|
|
20
|
+
__exportStar(require("./chains.js"), exports);
|
|
21
|
+
__exportStar(require("./config.js"), exports);
|
|
22
|
+
__exportStar(require("./consolidated-quote.js"), exports);
|
|
23
|
+
__exportStar(require("./relay-quote.js"), exports);
|
|
24
|
+
__exportStar(require("./relay-currencies.js"), exports);
|
|
25
|
+
__exportStar(require("./destination-calldata.js"), exports);
|
|
26
|
+
__exportStar(require("./ecosystems.js"), exports);
|
|
27
|
+
__exportStar(require("./fee-type.js"), exports);
|
|
28
|
+
__exportStar(require("./image-links.js"), exports);
|
|
29
|
+
__exportStar(require("./lifi-execution-guard.js"), exports);
|
|
30
|
+
__exportStar(require("./origin-deposit.js"), exports);
|
|
31
|
+
__exportStar(require("./providers.js"), exports);
|
|
32
|
+
__exportStar(require("./referral.js"), exports);
|
|
33
|
+
__exportStar(require("./route-steps.js"), exports);
|
|
34
|
+
__exportStar(require("./routing/index.js"), exports);
|
|
35
|
+
__exportStar(require("./settings.js"), exports);
|
|
36
|
+
__exportStar(require("./types.js"), exports);
|
|
37
|
+
__exportStar(require("./claims.js"), exports);
|
|
38
|
+
__exportStar(require("./execution.js"), exports);
|
|
39
|
+
__exportStar(require("./relay-depository.js"), exports);
|