@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.
Files changed (119) hide show
  1. package/block-polling/package.json +6 -0
  2. package/coinbase-accept-list/package.json +6 -0
  3. package/dist/block-polling.d.ts +33 -0
  4. package/dist/block-polling.js +10 -0
  5. package/dist/cjs/block-polling.d.ts +33 -0
  6. package/dist/cjs/block-polling.js +15 -0
  7. package/dist/cjs/client.d.ts +9 -1
  8. package/dist/cjs/client.js +8 -5
  9. package/dist/cjs/coinbase-accept-list.d.ts +101 -0
  10. package/dist/cjs/coinbase-accept-list.js +97 -0
  11. package/dist/cjs/crossing-decision.d.ts +166 -0
  12. package/dist/cjs/crossing-decision.js +169 -0
  13. package/dist/cjs/crossing-vector-guard.d.ts +45 -0
  14. package/dist/cjs/crossing-vector-guard.js +139 -0
  15. package/dist/cjs/exchange-deposit-board.d.ts +50 -0
  16. package/dist/cjs/exchange-deposit-board.js +70 -0
  17. package/dist/cjs/exchange-deposit-chain.d.ts +146 -0
  18. package/dist/cjs/exchange-deposit-chain.js +228 -0
  19. package/dist/cjs/exchange-deposit-constants.d.ts +10 -0
  20. package/dist/cjs/exchange-deposit-constants.js +6 -0
  21. package/dist/cjs/exchange-deposit-factory-calls.d.ts +245 -0
  22. package/dist/cjs/exchange-deposit-factory-calls.js +103 -0
  23. package/dist/cjs/exchange-deposit-factory.d.ts +87 -0
  24. package/dist/cjs/exchange-deposit-factory.js +110 -0
  25. package/dist/cjs/exchange-deposit-fake.d.ts +67 -0
  26. package/dist/cjs/exchange-deposit-fake.js +179 -0
  27. package/dist/cjs/exchange-deposit-index.d.ts +77 -0
  28. package/dist/cjs/exchange-deposit-index.js +40 -0
  29. package/dist/cjs/exchange-deposit-issuance.d.ts +327 -0
  30. package/dist/cjs/exchange-deposit-issuance.js +244 -0
  31. package/dist/cjs/exchange-deposit-path.d.ts +16 -0
  32. package/dist/cjs/exchange-deposit-path.js +15 -0
  33. package/dist/cjs/exchange-deposit-pow.d.ts +163 -0
  34. package/dist/cjs/exchange-deposit-pow.js +101 -0
  35. package/dist/cjs/exchange-deposit-recipient.d.ts +66 -0
  36. package/dist/cjs/exchange-deposit-recipient.js +35 -0
  37. package/dist/cjs/exchange-deposit-self-cross.d.ts +163 -0
  38. package/dist/cjs/exchange-deposit-self-cross.js +60 -0
  39. package/dist/cjs/exchange-deposit-signin.d.ts +275 -0
  40. package/dist/cjs/exchange-deposit-signin.js +166 -0
  41. package/dist/cjs/exchange-deposit-watch.d.ts +133 -0
  42. package/dist/cjs/exchange-deposit-watch.js +58 -0
  43. package/dist/cjs/exchange-deposit.d.ts +440 -0
  44. package/dist/cjs/exchange-deposit.js +154 -0
  45. package/dist/cjs/exchange-sender-guides.d.ts +29 -0
  46. package/dist/cjs/exchange-sender-guides.js +25 -0
  47. package/dist/cjs/image.d.ts +18 -0
  48. package/dist/cjs/image.js +11 -9
  49. package/dist/cjs/index.d.ts +4 -0
  50. package/dist/cjs/index.js +32 -1
  51. package/dist/cjs/kraken-accept-list.d.ts +70 -0
  52. package/dist/cjs/kraken-accept-list.js +24 -0
  53. package/dist/cjs/unlisted-token.d.ts +26 -0
  54. package/dist/cjs/unlisted-token.js +34 -0
  55. package/dist/client.d.ts +9 -1
  56. package/dist/client.js +8 -5
  57. package/dist/coinbase-accept-list.d.ts +101 -0
  58. package/dist/coinbase-accept-list.js +89 -0
  59. package/dist/crossing-decision.d.ts +166 -0
  60. package/dist/crossing-decision.js +162 -0
  61. package/dist/crossing-vector-guard.d.ts +45 -0
  62. package/dist/crossing-vector-guard.js +134 -0
  63. package/dist/exchange-deposit-board.d.ts +50 -0
  64. package/dist/exchange-deposit-board.js +28 -0
  65. package/dist/exchange-deposit-chain.d.ts +146 -0
  66. package/dist/exchange-deposit-chain.js +218 -0
  67. package/dist/exchange-deposit-constants.d.ts +10 -0
  68. package/dist/exchange-deposit-constants.js +3 -0
  69. package/dist/exchange-deposit-factory-calls.d.ts +245 -0
  70. package/dist/exchange-deposit-factory-calls.js +97 -0
  71. package/dist/exchange-deposit-factory.d.ts +87 -0
  72. package/dist/exchange-deposit-factory.js +104 -0
  73. package/dist/exchange-deposit-fake.d.ts +67 -0
  74. package/dist/exchange-deposit-fake.js +171 -0
  75. package/dist/exchange-deposit-index.d.ts +77 -0
  76. package/dist/exchange-deposit-index.js +34 -0
  77. package/dist/exchange-deposit-issuance.d.ts +327 -0
  78. package/dist/exchange-deposit-issuance.js +224 -0
  79. package/dist/exchange-deposit-path.d.ts +16 -0
  80. package/dist/exchange-deposit-path.js +11 -0
  81. package/dist/exchange-deposit-pow.d.ts +163 -0
  82. package/dist/exchange-deposit-pow.js +93 -0
  83. package/dist/exchange-deposit-recipient.d.ts +66 -0
  84. package/dist/exchange-deposit-recipient.js +28 -0
  85. package/dist/exchange-deposit-self-cross.d.ts +163 -0
  86. package/dist/exchange-deposit-self-cross.js +46 -0
  87. package/dist/exchange-deposit-signin.d.ts +275 -0
  88. package/dist/exchange-deposit-signin.js +147 -0
  89. package/dist/exchange-deposit-watch.d.ts +133 -0
  90. package/dist/exchange-deposit-watch.js +44 -0
  91. package/dist/exchange-deposit.d.ts +440 -0
  92. package/dist/exchange-deposit.js +138 -0
  93. package/dist/exchange-sender-guides.d.ts +29 -0
  94. package/dist/exchange-sender-guides.js +21 -0
  95. package/dist/image.d.ts +18 -0
  96. package/dist/image.js +8 -8
  97. package/dist/index.d.ts +4 -0
  98. package/dist/index.js +4 -0
  99. package/dist/kraken-accept-list.d.ts +70 -0
  100. package/dist/kraken-accept-list.js +17 -0
  101. package/dist/unlisted-token.d.ts +26 -0
  102. package/dist/unlisted-token.js +30 -0
  103. package/exchange-deposit/package.json +6 -0
  104. package/exchange-deposit-board/package.json +6 -0
  105. package/exchange-deposit-chain/package.json +6 -0
  106. package/exchange-deposit-factory/package.json +6 -0
  107. package/exchange-deposit-fake/package.json +6 -0
  108. package/exchange-deposit-issuance/package.json +6 -0
  109. package/exchange-deposit-path/package.json +6 -0
  110. package/exchange-deposit-pow/package.json +6 -0
  111. package/exchange-deposit-recipient/package.json +6 -0
  112. package/exchange-deposit-self-cross/package.json +6 -0
  113. package/exchange-deposit-signin/package.json +6 -0
  114. package/exchange-deposit-watch/package.json +6 -0
  115. package/exchange-sender-guides/package.json +6 -0
  116. package/kraken-accept-list/package.json +6 -0
  117. package/llms.txt +1 -0
  118. package/package.json +487 -6
  119. package/unlisted-token/package.json +6 -0
@@ -1,3 +1,4 @@
1
+ import * as imageLinks from '@gibs/bridge-sdk/image-links';
1
2
  /**
2
3
  * Chain-logo resolution, in one place.
3
4
  *
@@ -47,6 +48,23 @@ export declare const chainLogoUrl: ({ chainId, displayPx, }: {
47
48
  chainId: number;
48
49
  displayPx?: number;
49
50
  }) => string;
51
+ /**
52
+ * The other chain a native coin comes from, or null when the coin is at home
53
+ * (or the chain is not in the table).
54
+ *
55
+ * @param chainId - the chain the coin is being shown on
56
+ * @returns the home chain id, or null
57
+ */
58
+ export declare const nativeHomeChainOf: (chainId: number) => number | null;
59
+ /**
60
+ * The picture url of any token, for every surface that draws one: the single
61
+ * pure {@link imageLinks.tokenImageUrl} plus the one fact it cannot know itself,
62
+ * where a native coin comes from.
63
+ *
64
+ * @param token - what is known about the token
65
+ * @returns the image url
66
+ */
67
+ export declare const tokenImage: (token: Omit<imageLinks.TokenImageInput, "nativeHomeChainId">) => string;
50
68
  /**
51
69
  * The gib.show sources for a chain's NATIVE COIN, best first.
52
70
  *
package/dist/cjs/image.js CHANGED
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.nativeCoinLogoUrl = exports.nativeCoinImageSources = exports.chainLogoUrl = exports.relayChainIconUrl = void 0;
36
+ exports.nativeCoinLogoUrl = exports.nativeCoinImageSources = exports.tokenImage = exports.nativeHomeChainOf = exports.chainLogoUrl = exports.relayChainIconUrl = void 0;
37
37
  const imageLinks = __importStar(require("@gibs/bridge-sdk/image-links"));
38
38
  const relay_quote_1 = require("@gibs/bridge-sdk/relay-quote");
39
39
  const viem_1 = require("viem");
@@ -64,16 +64,18 @@ const chainLogoUrl = ({ chainId, displayPx, }) => {
64
64
  exports.chainLogoUrl = chainLogoUrl;
65
65
  const homeChainOfSymbol = new Map([...chain_table_js_1.chainTable].reverse().map((entry) => [entry.nativeCurrency.symbol, entry.id]));
66
66
  const symbolOfChain = new Map(chain_table_js_1.chainTable.map((entry) => [entry.id, entry.nativeCurrency.symbol]));
67
- const nativeCoinImageSources = (chainId) => {
68
- const sources = [`${chainId}/${viem_1.zeroAddress}`];
67
+ const nativeHomeChainOf = (chainId) => {
69
68
  const symbol = symbolOfChain.get(chainId);
70
69
  const home = symbol === undefined ? undefined : homeChainOfSymbol.get(symbol);
71
- if (home !== undefined && home !== chainId) {
72
- sources.push(`${home}/${viem_1.zeroAddress}`);
73
- }
74
- sources.push(`${chainId}/`);
75
- return sources;
70
+ return home === undefined || home === chainId ? null : home;
71
+ };
72
+ exports.nativeHomeChainOf = nativeHomeChainOf;
73
+ const tokenImage = (token) => imageLinks.tokenImageUrl({ ...token, nativeHomeChainId: (0, exports.nativeHomeChainOf)(Number(token.chainId)) });
74
+ exports.tokenImage = tokenImage;
75
+ const nativeCoinImageSources = (chainId) => {
76
+ const home = (0, exports.nativeHomeChainOf)(chainId);
77
+ return [`${chainId}/${viem_1.zeroAddress}`, ...(home === null ? [] : [`${home}/${viem_1.zeroAddress}`]), `${chainId}/`];
76
78
  };
77
79
  exports.nativeCoinImageSources = nativeCoinImageSources;
78
- const nativeCoinLogoUrl = (chainId) => imageLinks.images((0, exports.nativeCoinImageSources)(chainId));
80
+ const nativeCoinLogoUrl = (chainId) => (0, exports.tokenImage)({ chainId, address: viem_1.zeroAddress });
79
81
  exports.nativeCoinLogoUrl = nativeCoinLogoUrl;
@@ -13,10 +13,14 @@
13
13
  * `/endpoints`, `/image` and so on — so that importing one does not pull the
14
14
  * rest. This barrel exists for consumers that would rather not think about it.
15
15
  */
16
+ export { blockPollIntervalForChain, blockPollIntervalMs, blockTimeMsByChainId, MAXIMUM_BLOCK_POLL_MS, MINIMUM_BLOCK_POLL_MS, } from './block-polling.js';
16
17
  export { Cache } from './cache.js';
17
18
  export { checkAllowance, type ApprovalParameters } from './chain-read.js';
18
19
  export { clientFromChain, rpcBatchSetting } from './client.js';
19
20
  export { add, configureEndpoints, ENDPOINTS_STORAGE_KEY, entries, get, getSnapshot, hasDefault, key, parse, productionSeed, remove, restoreDefault, setEndpoints, stringify, subscribe, testnetSeed, update, type EndpointEntry, type EndpointStorage, } from './endpoints.js';
21
+ export { FEE_RATE_SCALE, coverageOfAddress, crossingCoverage, ETHEREUM_MAINNET_CHAIN_ID, EXCHANGE_DEPOSIT_DEFAULT_FEE_RATE_E18, EXCHANGE_DEPOSIT_FEE_LIMITS_UNREADABLE, EXCHANGE_DEPOSIT_FEE_RATES, EXCHANGE_DEPOSIT_INITIAL_SELECTION, EXCHANGE_DEPOSIT_GAS_TABLE_NAME_BY_CHAIN, exchangeDepositGasTableOf, exchangeDepositSelectionReducer, assertFeeRatesWithinLimits, exchangeDepositStage, feeRateOptionsOf, feeRatePercent, SEPOLIA_CHAIN_ID, WEI_PER_ETHER, type CrossingCoverage, type CrossingCoverageInput, type ExchangeDepositAddress, type ExchangeDepositAddressOrigin, type ExchangeDepositContractGroup, type ExchangeDepositCrossing, type ExchangeDepositCrossingConditions, type ExchangeDepositRequest, type ExchangeDepositSelection, type ExchangeDepositSelectionAction, type ExchangeDepositSettings, type ExchangeDepositFeeLimits, type ExchangeDepositSource, type ExchangeDepositStage, type ExchangeDepositToken, } from './exchange-deposit.js';
22
+ export { readRecipient, recipientIdenticon, sameAddress, type RecipientIdenticon, type RecipientReading, } from './exchange-deposit-recipient.js';
20
23
  export { chainLogoUrl, relayChainIconUrl } from './image.js';
21
24
  export { evmChains, evmChainsById, isSupportedEvmChain } from './networks.js';
22
25
  export { getBridgeTokenMetadata, getStoreKey, getStoreSize, getTokenAddressFromBridge, getTokenChainIdFromBridge, getTokenMetadata, loadTokenMetadata, parseChainScopedAddress, parseTokenKey, type ChainScopedAddress, } from './token-metadata.js';
26
+ export { readUnlistedToken } from './unlisted-token.js';
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseTokenKey = exports.parseChainScopedAddress = exports.loadTokenMetadata = exports.getTokenMetadata = exports.getTokenChainIdFromBridge = exports.getTokenAddressFromBridge = exports.getStoreSize = exports.getStoreKey = exports.getBridgeTokenMetadata = exports.isSupportedEvmChain = exports.evmChainsById = exports.evmChains = exports.relayChainIconUrl = exports.chainLogoUrl = exports.update = exports.testnetSeed = exports.subscribe = exports.stringify = exports.setEndpoints = exports.restoreDefault = exports.remove = exports.productionSeed = exports.parse = exports.key = exports.hasDefault = exports.getSnapshot = exports.get = exports.entries = exports.ENDPOINTS_STORAGE_KEY = exports.configureEndpoints = exports.add = exports.rpcBatchSetting = exports.clientFromChain = exports.checkAllowance = exports.Cache = void 0;
3
+ exports.evmChainsById = exports.evmChains = exports.relayChainIconUrl = exports.chainLogoUrl = exports.sameAddress = exports.recipientIdenticon = exports.readRecipient = exports.WEI_PER_ETHER = exports.SEPOLIA_CHAIN_ID = exports.feeRatePercent = exports.feeRateOptionsOf = exports.exchangeDepositStage = exports.assertFeeRatesWithinLimits = exports.exchangeDepositSelectionReducer = exports.exchangeDepositGasTableOf = exports.EXCHANGE_DEPOSIT_GAS_TABLE_NAME_BY_CHAIN = exports.EXCHANGE_DEPOSIT_INITIAL_SELECTION = exports.EXCHANGE_DEPOSIT_FEE_RATES = exports.EXCHANGE_DEPOSIT_FEE_LIMITS_UNREADABLE = exports.EXCHANGE_DEPOSIT_DEFAULT_FEE_RATE_E18 = exports.ETHEREUM_MAINNET_CHAIN_ID = exports.crossingCoverage = exports.coverageOfAddress = exports.FEE_RATE_SCALE = exports.update = exports.testnetSeed = exports.subscribe = exports.stringify = exports.setEndpoints = exports.restoreDefault = exports.remove = exports.productionSeed = exports.parse = exports.key = exports.hasDefault = exports.getSnapshot = exports.get = exports.entries = exports.ENDPOINTS_STORAGE_KEY = exports.configureEndpoints = exports.add = exports.rpcBatchSetting = exports.clientFromChain = exports.checkAllowance = exports.Cache = exports.MINIMUM_BLOCK_POLL_MS = exports.MAXIMUM_BLOCK_POLL_MS = exports.blockTimeMsByChainId = exports.blockPollIntervalMs = exports.blockPollIntervalForChain = void 0;
4
+ exports.readUnlistedToken = exports.parseTokenKey = exports.parseChainScopedAddress = exports.loadTokenMetadata = exports.getTokenMetadata = exports.getTokenChainIdFromBridge = exports.getTokenAddressFromBridge = exports.getStoreSize = exports.getStoreKey = exports.getBridgeTokenMetadata = exports.isSupportedEvmChain = void 0;
5
+ var block_polling_js_1 = require("./block-polling.js");
6
+ Object.defineProperty(exports, "blockPollIntervalForChain", { enumerable: true, get: function () { return block_polling_js_1.blockPollIntervalForChain; } });
7
+ Object.defineProperty(exports, "blockPollIntervalMs", { enumerable: true, get: function () { return block_polling_js_1.blockPollIntervalMs; } });
8
+ Object.defineProperty(exports, "blockTimeMsByChainId", { enumerable: true, get: function () { return block_polling_js_1.blockTimeMsByChainId; } });
9
+ Object.defineProperty(exports, "MAXIMUM_BLOCK_POLL_MS", { enumerable: true, get: function () { return block_polling_js_1.MAXIMUM_BLOCK_POLL_MS; } });
10
+ Object.defineProperty(exports, "MINIMUM_BLOCK_POLL_MS", { enumerable: true, get: function () { return block_polling_js_1.MINIMUM_BLOCK_POLL_MS; } });
4
11
  var cache_js_1 = require("./cache.js");
5
12
  Object.defineProperty(exports, "Cache", { enumerable: true, get: function () { return cache_js_1.Cache; } });
6
13
  var chain_read_js_1 = require("./chain-read.js");
@@ -26,6 +33,28 @@ Object.defineProperty(exports, "stringify", { enumerable: true, get: function ()
26
33
  Object.defineProperty(exports, "subscribe", { enumerable: true, get: function () { return endpoints_js_1.subscribe; } });
27
34
  Object.defineProperty(exports, "testnetSeed", { enumerable: true, get: function () { return endpoints_js_1.testnetSeed; } });
28
35
  Object.defineProperty(exports, "update", { enumerable: true, get: function () { return endpoints_js_1.update; } });
36
+ var exchange_deposit_js_1 = require("./exchange-deposit.js");
37
+ Object.defineProperty(exports, "FEE_RATE_SCALE", { enumerable: true, get: function () { return exchange_deposit_js_1.FEE_RATE_SCALE; } });
38
+ Object.defineProperty(exports, "coverageOfAddress", { enumerable: true, get: function () { return exchange_deposit_js_1.coverageOfAddress; } });
39
+ Object.defineProperty(exports, "crossingCoverage", { enumerable: true, get: function () { return exchange_deposit_js_1.crossingCoverage; } });
40
+ Object.defineProperty(exports, "ETHEREUM_MAINNET_CHAIN_ID", { enumerable: true, get: function () { return exchange_deposit_js_1.ETHEREUM_MAINNET_CHAIN_ID; } });
41
+ Object.defineProperty(exports, "EXCHANGE_DEPOSIT_DEFAULT_FEE_RATE_E18", { enumerable: true, get: function () { return exchange_deposit_js_1.EXCHANGE_DEPOSIT_DEFAULT_FEE_RATE_E18; } });
42
+ Object.defineProperty(exports, "EXCHANGE_DEPOSIT_FEE_LIMITS_UNREADABLE", { enumerable: true, get: function () { return exchange_deposit_js_1.EXCHANGE_DEPOSIT_FEE_LIMITS_UNREADABLE; } });
43
+ Object.defineProperty(exports, "EXCHANGE_DEPOSIT_FEE_RATES", { enumerable: true, get: function () { return exchange_deposit_js_1.EXCHANGE_DEPOSIT_FEE_RATES; } });
44
+ Object.defineProperty(exports, "EXCHANGE_DEPOSIT_INITIAL_SELECTION", { enumerable: true, get: function () { return exchange_deposit_js_1.EXCHANGE_DEPOSIT_INITIAL_SELECTION; } });
45
+ Object.defineProperty(exports, "EXCHANGE_DEPOSIT_GAS_TABLE_NAME_BY_CHAIN", { enumerable: true, get: function () { return exchange_deposit_js_1.EXCHANGE_DEPOSIT_GAS_TABLE_NAME_BY_CHAIN; } });
46
+ Object.defineProperty(exports, "exchangeDepositGasTableOf", { enumerable: true, get: function () { return exchange_deposit_js_1.exchangeDepositGasTableOf; } });
47
+ Object.defineProperty(exports, "exchangeDepositSelectionReducer", { enumerable: true, get: function () { return exchange_deposit_js_1.exchangeDepositSelectionReducer; } });
48
+ Object.defineProperty(exports, "assertFeeRatesWithinLimits", { enumerable: true, get: function () { return exchange_deposit_js_1.assertFeeRatesWithinLimits; } });
49
+ Object.defineProperty(exports, "exchangeDepositStage", { enumerable: true, get: function () { return exchange_deposit_js_1.exchangeDepositStage; } });
50
+ Object.defineProperty(exports, "feeRateOptionsOf", { enumerable: true, get: function () { return exchange_deposit_js_1.feeRateOptionsOf; } });
51
+ Object.defineProperty(exports, "feeRatePercent", { enumerable: true, get: function () { return exchange_deposit_js_1.feeRatePercent; } });
52
+ Object.defineProperty(exports, "SEPOLIA_CHAIN_ID", { enumerable: true, get: function () { return exchange_deposit_js_1.SEPOLIA_CHAIN_ID; } });
53
+ Object.defineProperty(exports, "WEI_PER_ETHER", { enumerable: true, get: function () { return exchange_deposit_js_1.WEI_PER_ETHER; } });
54
+ var exchange_deposit_recipient_js_1 = require("./exchange-deposit-recipient.js");
55
+ Object.defineProperty(exports, "readRecipient", { enumerable: true, get: function () { return exchange_deposit_recipient_js_1.readRecipient; } });
56
+ Object.defineProperty(exports, "recipientIdenticon", { enumerable: true, get: function () { return exchange_deposit_recipient_js_1.recipientIdenticon; } });
57
+ Object.defineProperty(exports, "sameAddress", { enumerable: true, get: function () { return exchange_deposit_recipient_js_1.sameAddress; } });
29
58
  var image_js_1 = require("./image.js");
30
59
  Object.defineProperty(exports, "chainLogoUrl", { enumerable: true, get: function () { return image_js_1.chainLogoUrl; } });
31
60
  Object.defineProperty(exports, "relayChainIconUrl", { enumerable: true, get: function () { return image_js_1.relayChainIconUrl; } });
@@ -43,3 +72,5 @@ Object.defineProperty(exports, "getTokenMetadata", { enumerable: true, get: func
43
72
  Object.defineProperty(exports, "loadTokenMetadata", { enumerable: true, get: function () { return token_metadata_js_1.loadTokenMetadata; } });
44
73
  Object.defineProperty(exports, "parseChainScopedAddress", { enumerable: true, get: function () { return token_metadata_js_1.parseChainScopedAddress; } });
45
74
  Object.defineProperty(exports, "parseTokenKey", { enumerable: true, get: function () { return token_metadata_js_1.parseTokenKey; } });
75
+ var unlisted_token_js_1 = require("./unlisted-token.js");
76
+ Object.defineProperty(exports, "readUnlistedToken", { enumerable: true, get: function () { return unlisted_token_js_1.readUnlistedToken; } });
@@ -0,0 +1,70 @@
1
+ /**
2
+ * The Kraken deposit minimums this interface routes against. Kraken publishes no public, keyless list of the networks
3
+ * it credits (its account API needs a key), so this table is copied by hand from Kraken's deposit page. Every row is
4
+ * on that page. A route to an asset not on the page is refused.
5
+ *
6
+ * Source: https://support.kraken.com/articles/360000292886-cryptocurrency-deposit-fees-and-minimums
7
+ * Dated: the page reads "Last updated: September 3, 2026".
8
+ */
9
+ export declare const KRAKEN_DEPOSIT_SOURCE_URL = "https://support.kraken.com/articles/360000292886-cryptocurrency-deposit-fees-and-minimums";
10
+ /** The "Last updated" date the source page prints. The table is only as current as this date. */
11
+ export declare const KRAKEN_DEPOSIT_SOURCE_DATE = "September 3, 2026";
12
+ /**
13
+ * One asset Kraken credits on one EVM chain, and the deposit minimum below which Kraken says the funds are permanently
14
+ * lost. `tokenAddress` is `null` for the chain's native coin. `minimumAmount` is a whole-token decimal string, the way
15
+ * Kraken prints it.
16
+ */
17
+ export interface KrakenDepositRule {
18
+ readonly chainId: number;
19
+ readonly tokenAddress: string | null;
20
+ readonly symbol: string;
21
+ readonly minimumAmount: string;
22
+ }
23
+ /** The Kraken deposit rules from the source page above: Ethereum mainnet and Base only. */
24
+ export declare const KRAKEN_DEPOSIT_RULES: readonly KrakenDepositRule[];
25
+ /**
26
+ * Finds the Kraken rule for one asset on one chain. Matching is by chain and contract address, compared in lower case,
27
+ * never by symbol. A `null` address means the chain's native coin.
28
+ *
29
+ * @param target - The chain and token address (`null` for native).
30
+ * @returns The rule, or `null` when Kraken does not credit that asset on that chain.
31
+ */
32
+ export declare const krakenDepositRuleFor: (target: {
33
+ readonly chainId: number;
34
+ readonly tokenAddress: string | null;
35
+ }) => KrakenDepositRule | null;
36
+ /**
37
+ * Says whether Kraken credits a route's final asset on the route's final chain.
38
+ *
39
+ * @param target - The chain and token address (`null` for native).
40
+ * @returns `true` only when the source page lists that asset on that chain.
41
+ */
42
+ export declare const isKrakenAcceptedDestination: (target: {
43
+ readonly chainId: number;
44
+ readonly tokenAddress: string | null;
45
+ }) => boolean;
46
+ /**
47
+ * The deposit minimum Kraken prints for an asset, as a whole-token decimal string, or `null` when Kraken does not
48
+ * credit that asset. A deposit below the minimum is lost, so the minimum is a refusal, not a warning.
49
+ *
50
+ * @param target - The chain and token address (`null` for native).
51
+ * @returns The minimum, such as `"2.5"`, or `null` when the asset is not on the table.
52
+ */
53
+ export declare const krakenDepositMinimumFor: (target: {
54
+ readonly chainId: number;
55
+ readonly tokenAddress: string | null;
56
+ }) => string | null;
57
+ /**
58
+ * Says whether a delivered amount is strictly below an exchange's minimum. Both sides are compared in base units, so no
59
+ * floating point number is involved. viem rounds a minimum that has more decimal places than the token has.
60
+ *
61
+ * @param options.deliveredBaseUnits - The delivered amount in the token's base units.
62
+ * @param options.decimals - How many places the token divides into.
63
+ * @param options.minimumAmount - The minimum as a whole-token decimal string.
64
+ * @returns `true` only when the delivered amount is below the minimum. An amount exactly at the minimum passes.
65
+ */
66
+ export declare const isBelowDepositMinimum: ({ deliveredBaseUnits, decimals, minimumAmount, }: {
67
+ readonly deliveredBaseUnits: bigint;
68
+ readonly decimals: number;
69
+ readonly minimumAmount: string;
70
+ }) => boolean;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isBelowDepositMinimum = exports.krakenDepositMinimumFor = exports.isKrakenAcceptedDestination = exports.krakenDepositRuleFor = exports.KRAKEN_DEPOSIT_RULES = exports.KRAKEN_DEPOSIT_SOURCE_DATE = exports.KRAKEN_DEPOSIT_SOURCE_URL = void 0;
4
+ const viem_1 = require("viem");
5
+ exports.KRAKEN_DEPOSIT_SOURCE_URL = 'https://support.kraken.com/articles/360000292886-cryptocurrency-deposit-fees-and-minimums';
6
+ exports.KRAKEN_DEPOSIT_SOURCE_DATE = 'September 3, 2026';
7
+ exports.KRAKEN_DEPOSIT_RULES = [
8
+ { chainId: 1, tokenAddress: null, symbol: 'ETH', minimumAmount: '0.004' },
9
+ { chainId: 1, tokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', symbol: 'USDC', minimumAmount: '2.5' },
10
+ { chainId: 1, tokenAddress: '0xdAC17F958D2ee523a2206206994597C13D831ec7', symbol: 'USDT', minimumAmount: '2.5' },
11
+ { chainId: 8453, tokenAddress: null, symbol: 'ETH', minimumAmount: '0.0025' },
12
+ { chainId: 8453, tokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', symbol: 'USDC', minimumAmount: '2.5' },
13
+ ];
14
+ const krakenDepositRuleFor = (target) => {
15
+ const lowerAddress = target.tokenAddress?.toLowerCase() ?? null;
16
+ return (exports.KRAKEN_DEPOSIT_RULES.find((rule) => rule.chainId === target.chainId && (rule.tokenAddress?.toLowerCase() ?? null) === lowerAddress) ?? null);
17
+ };
18
+ exports.krakenDepositRuleFor = krakenDepositRuleFor;
19
+ const isKrakenAcceptedDestination = (target) => (0, exports.krakenDepositRuleFor)(target) !== null;
20
+ exports.isKrakenAcceptedDestination = isKrakenAcceptedDestination;
21
+ const krakenDepositMinimumFor = (target) => (0, exports.krakenDepositRuleFor)(target)?.minimumAmount ?? null;
22
+ exports.krakenDepositMinimumFor = krakenDepositMinimumFor;
23
+ const isBelowDepositMinimum = ({ deliveredBaseUnits, decimals, minimumAmount, }) => deliveredBaseUnits < (0, viem_1.parseUnits)(minimumAmount, decimals);
24
+ exports.isBelowDepositMinimum = isBelowDepositMinimum;
@@ -0,0 +1,26 @@
1
+ import type { Token } from '@gibs/bridge-sdk/types';
2
+ import { type PublicClient } from 'viem';
3
+ /**
4
+ * Reads the name, symbol and decimals of a token that no token list carries.
5
+ * The read is one multicall on the token's own chain.
6
+ *
7
+ * The logo comes from the one image builder (`tokenImage`), never a hand-built
8
+ * url: the token's own picture first, then the token it pairs with. An
9
+ * unlisted bridged copy rarely has a picture of its own.
10
+ *
11
+ * @param params.chainId - the decimal chain id of the token
12
+ * @param params.address - the token address, or null
13
+ * @param params.counterpart - the token this one pairs with, used as the image
14
+ * fallback, or null
15
+ * @param params.client - a public client on the token's own chain
16
+ * @returns the token, or null when there is no address or the read fails
17
+ */
18
+ export declare const readUnlistedToken: ({ chainId, address, counterpart, client, }: {
19
+ chainId: number;
20
+ address: string | null;
21
+ counterpart: {
22
+ chainId: number;
23
+ address: string;
24
+ } | null;
25
+ client: PublicClient;
26
+ }) => Promise<Token | null>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readUnlistedToken = void 0;
4
+ const chains_1 = require("@gibs/bridge-sdk/chains");
5
+ const config_1 = require("@gibs/bridge-sdk/config");
6
+ const erc20_1 = require("@gibs/common/erc20");
7
+ const viem_1 = require("viem");
8
+ const image_js_1 = require("./image.js");
9
+ const readUnlistedToken = async ({ chainId, address, counterpart, client, }) => {
10
+ if (!address)
11
+ return null;
12
+ const checksummed = (0, viem_1.getAddress)(address);
13
+ const metadata = await (0, erc20_1.multicallErc20)({
14
+ client,
15
+ chain: chains_1.chainsMetadata[(0, config_1.toChain)(chainId)],
16
+ target: checksummed,
17
+ }).catch(() => null);
18
+ if (!metadata)
19
+ return null;
20
+ const [name, symbol, decimals] = metadata;
21
+ return {
22
+ name,
23
+ symbol,
24
+ decimals,
25
+ chainId,
26
+ address: checksummed,
27
+ logoURI: (0, image_js_1.tokenImage)({
28
+ chainId,
29
+ address: checksummed,
30
+ counterparts: counterpart ? [counterpart] : null,
31
+ }),
32
+ };
33
+ };
34
+ exports.readUnlistedToken = readUnlistedToken;
package/dist/client.d.ts CHANGED
@@ -14,6 +14,14 @@ import type { HttpTransportConfig, PublicClient } from 'viem';
14
14
  * @returns `false` when batching must be disabled, otherwise the batch config
15
15
  */
16
16
  export declare const rpcBatchSetting: (chainId: number) => HttpTransportConfig["batch"];
17
+ /** The options of {@link clientFromChain}. */
18
+ export interface ClientFromChainOptions {
19
+ /**
20
+ * The longest one endpoint may take to answer a request before the next endpoint is asked. A reader that must not
21
+ * wait on a dead endpoint sets it. The client is then cached apart from the shared one.
22
+ */
23
+ readonly attemptTimeoutMs?: number;
24
+ }
17
25
  /**
18
26
  * Returns a viem {@link PublicClient} for a chain, reusing the cached instance
19
27
  * while the chain's endpoint list is unchanged. The cache key is derived from the
@@ -30,4 +38,4 @@ export declare const rpcBatchSetting: (chainId: number) => HttpTransportConfig["
30
38
  * @param chainId - the chain to build a client for
31
39
  * @returns the cached or freshly built public client
32
40
  */
33
- export declare const clientFromChain: (chainId: number) => PublicClient;
41
+ export declare const clientFromChain: (chainId: number, options?: ClientFromChainOptions) => PublicClient;
package/dist/client.js CHANGED
@@ -22,18 +22,21 @@ const defaultUrlsFor = (chainId) => {
22
22
  const { http } = chain.rpcUrls.default;
23
23
  return [...(http ?? [])];
24
24
  };
25
- export const clientFromChain = (chainId) => {
25
+ export const clientFromChain = (chainId, options = {}) => {
26
26
  const stored = endpoints.get(chainId);
27
27
  const urls = (stored?.length ? stored : defaultUrlsFor(chainId)).filter((url) => Boolean(url));
28
28
  const key = chainKey(chainId, urls);
29
- const existing = clientCache.get(chainId);
30
- if (existing && existing.key === key) {
31
- return existing.client;
32
- }
33
29
  const chain = evmChainsById.get(chainId);
34
30
  if (!chain) {
35
31
  throw new Error(`Chain ${chainId} is not one of the supported networks.`);
36
32
  }
33
+ if (options.attemptTimeoutMs !== undefined) {
34
+ return buildClient({ chain, urls, batch: rpcBatchSetting(chainId), attemptTimeoutMs: options.attemptTimeoutMs });
35
+ }
36
+ const existing = clientCache.get(chainId);
37
+ if (existing && existing.key === key) {
38
+ return existing.client;
39
+ }
37
40
  const client = buildClient({ chain, urls, batch: rpcBatchSetting(chainId) });
38
41
  clientCache.set(chainId, { key, client });
39
42
  return client;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * The public currency list of Coinbase's institutional exchange (not the retail Coinbase app). It needs no key and
3
+ * allows any origin. The list says which assets the exchange credits on which networks.
4
+ */
5
+ export declare const COINBASE_EXCHANGE_CURRENCIES_URL = "https://api.exchange.coinbase.com/currencies";
6
+ /** How long a fetched accept list stays fresh, in milliseconds. */
7
+ export declare const COINBASE_ACCEPT_LIST_TIME_TO_LIVE_MILLISECONDS: number;
8
+ /**
9
+ * One Coinbase exchange network id mapped to the EVM chain it names, and to the currency id that is that chain's
10
+ * gas asset. Only networks checked by hand belong here. Any other network is refused.
11
+ */
12
+ export interface CoinbaseExchangeNetworkMapping {
13
+ readonly chainId: number;
14
+ readonly nativeCurrencyId: string | null;
15
+ }
16
+ /** The verified Coinbase exchange network ids. Chain 369 (PulseChain) is absent on purpose: the exchange does not list it. */
17
+ export declare const COINBASE_EXCHANGE_NETWORK_MAPPINGS: Readonly<Record<string, CoinbaseExchangeNetworkMapping>>;
18
+ /** One network entry inside a Coinbase exchange currency. Only the fields this module reads are typed. */
19
+ export interface CoinbaseExchangeNetwork {
20
+ readonly id: string;
21
+ readonly status: string;
22
+ readonly contract_address: string | null;
23
+ readonly is_evm_network: boolean;
24
+ readonly destination_tag_regex: string | null;
25
+ }
26
+ /** One currency from the Coinbase exchange currency list. */
27
+ export interface CoinbaseExchangeCurrency {
28
+ readonly id: string;
29
+ readonly status: string;
30
+ readonly supported_networks: readonly CoinbaseExchangeNetwork[];
31
+ }
32
+ /** An asset the exchange credits on one EVM chain. A native asset has no contract address. */
33
+ export type CoinbaseAcceptedAsset = {
34
+ readonly kind: 'native';
35
+ readonly chainId: number;
36
+ readonly currencyId: string;
37
+ } | {
38
+ readonly kind: 'token';
39
+ readonly chainId: number;
40
+ readonly currencyId: string;
41
+ /** The contract address in lower case. Matching is by this address, never by symbol. */
42
+ readonly address: string;
43
+ };
44
+ /** The accept list: every asset the exchange credits on a network this interface can route to. */
45
+ export interface CoinbaseAcceptList {
46
+ readonly assets: readonly CoinbaseAcceptedAsset[];
47
+ }
48
+ /**
49
+ * Turns one network of one currency into an accepted asset, or `null` when the exchange does not credit it on a
50
+ * network we can route to. Every refusal is a guard clause, in this order: unknown network, non-EVM network, network
51
+ * or currency not online, destination tag required, and an empty address on a currency that is not the chain's gas
52
+ * asset (USDC on Base reports an empty address, but it is an ERC-20 and has no address this module can match).
53
+ *
54
+ * @param currency - One currency from the exchange list.
55
+ * @param network - One network entry of that currency.
56
+ * @returns The accepted asset, or `null` when refused.
57
+ */
58
+ export declare const acceptedAssetFromExchangeNetwork: (currency: CoinbaseExchangeCurrency, network: CoinbaseExchangeNetwork) => CoinbaseAcceptedAsset | null;
59
+ /**
60
+ * Builds the accept list from a parsed exchange currency list.
61
+ *
62
+ * @param currencies - The currencies from the exchange list.
63
+ * @returns The accept list with every accepted asset.
64
+ */
65
+ export declare const buildCoinbaseAcceptList: (currencies: readonly CoinbaseExchangeCurrency[]) => CoinbaseAcceptList;
66
+ /**
67
+ * Says whether the exchange credits a route's final asset. The asset is named by chain and contract address, never by
68
+ * symbol. A `null` address means the chain's native asset.
69
+ *
70
+ * @param acceptList - The accept list.
71
+ * @param target - The route's final chain and token address (`null` for native).
72
+ * @returns `true` when the exchange credits exactly that asset on that chain.
73
+ */
74
+ export declare const isCoinbaseAcceptedDestination: (acceptList: CoinbaseAcceptList, target: {
75
+ readonly chainId: number;
76
+ readonly tokenAddress: string | null;
77
+ }) => boolean;
78
+ /**
79
+ * Reads the exchange response body. It must be an array; anything else throws.
80
+ *
81
+ * @param body - The parsed JSON body.
82
+ * @returns The currency list.
83
+ */
84
+ export declare const parseCoinbaseExchangeCurrencies: (body: unknown) => readonly CoinbaseExchangeCurrency[];
85
+ /** Options for {@link createCoinbaseAcceptListLoader}. */
86
+ export interface CoinbaseAcceptListLoaderOptions {
87
+ /** The fetch to use. Defaults to the global `fetch`. */
88
+ readonly fetchImplementation?: typeof fetch;
89
+ /** How long a loaded list stays fresh. Defaults to {@link COINBASE_ACCEPT_LIST_TIME_TO_LIVE_MILLISECONDS}. */
90
+ readonly timeToLiveMilliseconds?: number;
91
+ /** The clock. Defaults to `Date.now`. */
92
+ readonly now?: () => number;
93
+ }
94
+ /**
95
+ * Makes a loader that fetches the accept list once, then reuses it until it goes stale. Concurrent calls share one
96
+ * request. A failed request is not cached, so the next call retries.
97
+ *
98
+ * @param options - The fetch, the time to live, and the clock.
99
+ * @returns A function that resolves the accept list.
100
+ */
101
+ export declare const createCoinbaseAcceptListLoader: (options?: CoinbaseAcceptListLoaderOptions) => () => Promise<CoinbaseAcceptList>;
@@ -0,0 +1,89 @@
1
+ import { isAddress } from 'viem';
2
+ export const COINBASE_EXCHANGE_CURRENCIES_URL = 'https://api.exchange.coinbase.com/currencies';
3
+ export const COINBASE_ACCEPT_LIST_TIME_TO_LIVE_MILLISECONDS = 10 * 60 * 1000;
4
+ export const COINBASE_EXCHANGE_NETWORK_MAPPINGS = {
5
+ ethereum: { chainId: 1, nativeCurrencyId: 'ETH' },
6
+ optimism: { chainId: 10, nativeCurrencyId: 'ETH' },
7
+ bsc: { chainId: 56, nativeCurrencyId: 'BNB' },
8
+ polygon: { chainId: 137, nativeCurrencyId: null },
9
+ base: { chainId: 8453, nativeCurrencyId: 'ETH' },
10
+ arbitrum: { chainId: 42161, nativeCurrencyId: 'ETH' },
11
+ };
12
+ export const acceptedAssetFromExchangeNetwork = (currency, network) => {
13
+ const mapping = COINBASE_EXCHANGE_NETWORK_MAPPINGS[network.id];
14
+ if (mapping === undefined)
15
+ return null;
16
+ if (!network.is_evm_network)
17
+ return null;
18
+ if (network.status !== 'online' || currency.status !== 'online')
19
+ return null;
20
+ if (network.destination_tag_regex)
21
+ return null;
22
+ const rawAddress = (network.contract_address ?? '').trim();
23
+ const isGasCurrency = mapping.nativeCurrencyId === currency.id;
24
+ if (rawAddress === '') {
25
+ if (!isGasCurrency)
26
+ return null;
27
+ return { kind: 'native', chainId: mapping.chainId, currencyId: currency.id };
28
+ }
29
+ if (!isAddress(rawAddress, { strict: false }))
30
+ return null;
31
+ return {
32
+ kind: 'token',
33
+ chainId: mapping.chainId,
34
+ currencyId: currency.id,
35
+ address: rawAddress.toLowerCase(),
36
+ };
37
+ };
38
+ export const buildCoinbaseAcceptList = (currencies) => ({
39
+ assets: currencies.flatMap((currency) => currency.supported_networks.flatMap((network) => {
40
+ const asset = acceptedAssetFromExchangeNetwork(currency, network);
41
+ return asset === null ? [] : [asset];
42
+ })),
43
+ });
44
+ export const isCoinbaseAcceptedDestination = (acceptList, target) => {
45
+ const lowerAddress = target.tokenAddress?.toLowerCase() ?? null;
46
+ return acceptList.assets.some((asset) => {
47
+ if (asset.chainId !== target.chainId)
48
+ return false;
49
+ if (lowerAddress === null)
50
+ return asset.kind === 'native';
51
+ return asset.kind === 'token' && asset.address === lowerAddress;
52
+ });
53
+ };
54
+ export const parseCoinbaseExchangeCurrencies = (body) => {
55
+ if (!Array.isArray(body))
56
+ throw new Error('Coinbase exchange currency list is not an array');
57
+ return body;
58
+ };
59
+ export const createCoinbaseAcceptListLoader = (options = {}) => {
60
+ const fetchImplementation = options.fetchImplementation ?? fetch;
61
+ const timeToLiveMilliseconds = options.timeToLiveMilliseconds ?? COINBASE_ACCEPT_LIST_TIME_TO_LIVE_MILLISECONDS;
62
+ const now = options.now ?? Date.now;
63
+ let cached = null;
64
+ let inFlight = null;
65
+ const fetchAcceptList = async () => {
66
+ const response = await fetchImplementation(COINBASE_EXCHANGE_CURRENCIES_URL, {
67
+ headers: { accept: 'application/json' },
68
+ });
69
+ if (!response.ok)
70
+ throw new Error(`Coinbase exchange currency list returned ${response.status}`);
71
+ const currencies = parseCoinbaseExchangeCurrencies(await response.json());
72
+ return buildCoinbaseAcceptList(currencies);
73
+ };
74
+ return async () => {
75
+ if (cached !== null && now() - cached.loadedAt < timeToLiveMilliseconds)
76
+ return cached.acceptList;
77
+ if (inFlight !== null)
78
+ return inFlight;
79
+ inFlight = fetchAcceptList().then((acceptList) => {
80
+ cached = { loadedAt: now(), acceptList };
81
+ inFlight = null;
82
+ return acceptList;
83
+ }, (error) => {
84
+ inFlight = null;
85
+ throw error;
86
+ });
87
+ return inFlight;
88
+ };
89
+ };