@mento-protocol/mento-sdk 1.15.2 → 1.15.5

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.
@@ -17,8 +17,6 @@ export function getCachedTradablePairs(chainId) {
17
17
  switch (chainId) {
18
18
  case 42220:
19
19
  return yield import('./tradablePairs.42220').then((module) => module.tradablePairs42220);
20
- case 44787:
21
- return yield import('./tradablePairs.44787').then((module) => module.tradablePairs44787);
22
20
  case 11142220:
23
21
  return yield import('./tradablePairs.11142220').then((module) => module.tradablePairs11142220);
24
22
  default:
package/dist/esm/mento.js CHANGED
@@ -171,7 +171,7 @@ export class Mento {
171
171
  * @throws Error if no cached tokens are available for the current chain or if chainId is not yet initialized
172
172
  */
173
173
  getTokens() {
174
- if (this.cachedChainId === null) {
174
+ if (!this.cachedChainId) {
175
175
  throw new Error('Chain ID not yet initialized. Use Mento.create() to initialize the SDK, or use getTokensAsync() instead.');
176
176
  }
177
177
  // eslint-disable-next-line @typescript-eslint/no-var-requires
@@ -192,8 +192,7 @@ export class Mento {
192
192
  return __awaiter(this, void 0, void 0, function* () {
193
193
  // If cached is true, try to use the static cache first
194
194
  if (cached) {
195
- // eslint-disable-next-line @typescript-eslint/no-var-requires
196
- const { getCachedTokens } = require('./constants/tokens');
195
+ const { getCachedTokens } = yield import('./constants/tokens');
197
196
  const chainId = yield this.chainId();
198
197
  const cachedTokens = yield getCachedTokens(chainId);
199
198
  if (cachedTokens) {
@@ -625,7 +624,7 @@ export class Mento {
625
624
  }
626
625
  chainId() {
627
626
  return __awaiter(this, void 0, void 0, function* () {
628
- if (this.cachedChainId == null) {
627
+ if (!this.cachedChainId) {
629
628
  this.cachedChainId = yield getChainId(this.signerOrProvider);
630
629
  }
631
630
  return this.cachedChainId;
@@ -1,7 +1,7 @@
1
1
  import { BigNumberish, providers, Signer } from 'ethers';
2
2
  import { TokenSymbol } from './constants';
3
3
  import { Address } from './interfaces';
4
- import { TradablePair } from './mento';
4
+ import { Token, TradablePair } from './mento';
5
5
  /**
6
6
  * Gets the chain ID from a signer or provider
7
7
  * @param signerOrProvider an ethers provider or signer
@@ -56,5 +56,18 @@ export declare function increaseAllowance(tokenAddr: string, spender: string, am
56
56
  * @param symbol the token symbol to find (case-insensitive)
57
57
  * @returns the token address if found, null otherwise
58
58
  */
59
- export declare function findTokenBySymbolInTradablePairs(pairs: readonly TradablePair[], symbol: string): string | null;
60
- export declare function capitalize(str: string): string;
59
+ export declare function findTokenAddressBySymbolInTradablePairs(symbol: TokenSymbol, pairs: readonly TradablePair[]): Address | null;
60
+ export declare function capitalize(str: string): string; /**
61
+ * Helper function to get token address by symbol for a specific chain
62
+ * @param symbol - The token symbol
63
+ * @param chainId - The chain ID
64
+ * @returns The token address or undefined if not found
65
+ */
66
+ export declare function getTokenAddress(symbol: TokenSymbol, chainId: number): string | undefined;
67
+ /**
68
+ * Helper function to find a token by symbol in the cached tokens
69
+ * @param symbol - The token symbol to search for
70
+ * @param chainId - The chain ID
71
+ * @returns The token object or undefined if not found
72
+ */
73
+ export declare function findTokenBySymbol(symbol: string, chainId: number): Token | undefined;
package/dist/esm/utils.js CHANGED
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { Contract, providers, Signer } from 'ethers';
11
+ import { getCachedTokensSync, TOKEN_ADDRESSES_BY_CHAIN } from './constants/tokens';
11
12
  /**
12
13
  * Gets the chain ID from a signer or provider
13
14
  * @param signerOrProvider an ethers provider or signer
@@ -113,16 +114,31 @@ export function increaseAllowance(tokenAddr, spender, amount, signerOrProvider)
113
114
  * @param symbol the token symbol to find (case-insensitive)
114
115
  * @returns the token address if found, null otherwise
115
116
  */
116
- export function findTokenBySymbolInTradablePairs(pairs, symbol) {
117
- for (const pair of pairs) {
118
- for (const asset of pair.assets) {
119
- if (asset.symbol.toLowerCase() === symbol.toLowerCase()) {
120
- return asset.address;
121
- }
122
- }
123
- }
124
- return null;
117
+ export function findTokenAddressBySymbolInTradablePairs(symbol, pairs) {
118
+ var _a, _b;
119
+ return ((_b = (_a = pairs
120
+ .flatMap((pair) => pair.assets)
121
+ .find((asset) => asset.symbol.toLowerCase() === symbol.toLowerCase())) === null || _a === void 0 ? void 0 : _a.address) !== null && _b !== void 0 ? _b : null);
125
122
  }
126
123
  export function capitalize(str) {
127
124
  return str.charAt(0).toUpperCase() + str.slice(1);
125
+ } /**
126
+ * Helper function to get token address by symbol for a specific chain
127
+ * @param symbol - The token symbol
128
+ * @param chainId - The chain ID
129
+ * @returns The token address or undefined if not found
130
+ */
131
+ export function getTokenAddress(symbol, chainId) {
132
+ var _a;
133
+ return (_a = TOKEN_ADDRESSES_BY_CHAIN[chainId]) === null || _a === void 0 ? void 0 : _a[symbol];
134
+ }
135
+ /**
136
+ * Helper function to find a token by symbol in the cached tokens
137
+ * @param symbol - The token symbol to search for
138
+ * @param chainId - The chain ID
139
+ * @returns The token object or undefined if not found
140
+ */
141
+ export function findTokenBySymbol(symbol, chainId) {
142
+ const tokens = getCachedTokensSync(chainId);
143
+ return tokens.find((token) => token.symbol === symbol);
128
144
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mento-protocol/mento-sdk",
3
3
  "description": "Official SDK for interacting with the Mento Protocol",
4
- "version": "1.15.2",
4
+ "version": "1.15.5",
5
5
  "license": "MIT",
6
6
  "author": "Mento Labs",
7
7
  "keywords": [
@@ -59,7 +59,6 @@
59
59
  "engines": {
60
60
  "node": ">=22"
61
61
  },
62
- "packageManager": "yarn@3",
63
62
  "size-limit": [
64
63
  {
65
64
  "path": "dist/sdk.cjs.production.min.js",
@@ -1,2 +0,0 @@
1
- import { Token } from '../mento';
2
- export declare const tokens44787: readonly Token[];
@@ -1,128 +0,0 @@
1
- "use strict";
2
- // This file is auto-generated. Do not edit manually.
3
- // Generated on 2025-10-06T12:14:20.430Z
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.tokens44787 = void 0;
6
- const mento_1 = require("../mento");
7
- exports.tokens44787 = [
8
- {
9
- address: '0x6e673502c5b55F3169657C004e5797fFE5be6653',
10
- symbol: mento_1.TokenSymbol.BridgedEUROC,
11
- name: 'mockBridgedEUROC',
12
- decimals: 6,
13
- },
14
- {
15
- address: '0x87D61dA3d668797786D73BC674F053f87111570d',
16
- symbol: mento_1.TokenSymbol.BridgedUSDC,
17
- name: 'mockBridgedUSDC',
18
- decimals: 6,
19
- },
20
- {
21
- address: '0x84CBD49F5aE07632B6B88094E81Cce8236125Fe0',
22
- symbol: mento_1.TokenSymbol.cAUD,
23
- name: 'Celo Australian Dollar',
24
- decimals: 18,
25
- },
26
- {
27
- address: '0x02EC9E0D2Fd73e89168C1709e542a48f58d7B133',
28
- symbol: mento_1.TokenSymbol.cCAD,
29
- name: 'Celo Canadian Dollar',
30
- decimals: 18,
31
- },
32
- {
33
- address: '0xADC57C2C34aD021Df4421230a6532F4e2E1dCE4F',
34
- symbol: mento_1.TokenSymbol.cCHF,
35
- name: 'Celo Swiss Franc',
36
- decimals: 18,
37
- },
38
- {
39
- address: '0xe6A57340f0df6E020c1c0a80bC6E13048601f0d4',
40
- symbol: mento_1.TokenSymbol.cCOP,
41
- name: 'Celo Colombian Peso',
42
- decimals: 18,
43
- },
44
- {
45
- address: '0xF194afDf50B03e69Bd7D057c1Aa9e10c9954E4C9',
46
- symbol: mento_1.TokenSymbol.CELO,
47
- name: 'Celo native asset',
48
- decimals: 18,
49
- },
50
- {
51
- address: '0x10c892A6EC43a53E45D0B916B4b7D383B1b78C0F',
52
- symbol: mento_1.TokenSymbol.cEUR,
53
- name: 'Celo Euro',
54
- decimals: 18,
55
- },
56
- {
57
- address: '0x47f2Fb88105155a18c390641C8a73f1402B2BB12',
58
- symbol: mento_1.TokenSymbol.cGBP,
59
- name: 'Celo British Pound',
60
- decimals: 18,
61
- },
62
- {
63
- address: '0x295B66bE7714458Af45E6A6Ea142A5358A6cA375',
64
- symbol: mento_1.TokenSymbol.cGHS,
65
- name: 'cGHS',
66
- decimals: 18,
67
- },
68
- {
69
- address: '0x2E51F41238cA36a421C9B8b3e189e8Cc7653FE67',
70
- symbol: mento_1.TokenSymbol.cJPY,
71
- name: 'Celo Japanese Yen',
72
- decimals: 18,
73
- },
74
- {
75
- address: '0x1E0433C1769271ECcF4CFF9FDdD515eefE6CdF92',
76
- symbol: mento_1.TokenSymbol.cKES,
77
- name: 'Celo Kenyan Shilling',
78
- decimals: 18,
79
- },
80
- {
81
- address: '0x4a5b03B8b16122D330306c65e4CA4BC5Dd6511d0',
82
- symbol: mento_1.TokenSymbol.cNGN,
83
- name: 'Celo Nigerian Naira',
84
- decimals: 18,
85
- },
86
- {
87
- address: '0xE4D517785D091D3c54818832dB6094bcc2744545',
88
- symbol: mento_1.TokenSymbol.cREAL,
89
- name: 'Celo Brazilian Real',
90
- decimals: 18,
91
- },
92
- {
93
- address: '0x874069Fa1Eb16D44d622F2e0Ca25eeA172369bC1',
94
- symbol: mento_1.TokenSymbol.cUSD,
95
- name: 'Celo Dollar',
96
- decimals: 18,
97
- },
98
- {
99
- address: '0x1e5b44015Ff90610b54000DAad31C89b3284df4d',
100
- symbol: mento_1.TokenSymbol.cZAR,
101
- name: 'Celo South African Rand',
102
- decimals: 18,
103
- },
104
- {
105
- address: '0xB0FA15e002516d0301884059c0aaC0F0C72b019D',
106
- symbol: mento_1.TokenSymbol.eXOF,
107
- name: 'ECO CFA',
108
- decimals: 18,
109
- },
110
- {
111
- address: '0x5E0E3c9419C42a1B04e2525991FB1A2C467AB8bF',
112
- symbol: mento_1.TokenSymbol.PUSO,
113
- name: 'PUSO',
114
- decimals: 18,
115
- },
116
- {
117
- address: '0x2F25deB3848C207fc8E0c34035B3Ba7fC157602B',
118
- symbol: mento_1.TokenSymbol.USDC,
119
- name: 'USDC',
120
- decimals: 6,
121
- },
122
- {
123
- address: '0xBba91F588d031469ABCCA566FE80fB1Ad8Ee3287',
124
- symbol: mento_1.TokenSymbol.USDT,
125
- name: 'mockNativeUSDT',
126
- decimals: 6,
127
- },
128
- ];
@@ -1,2 +0,0 @@
1
- import { TradablePairWithSpread } from './tradablePairs';
2
- export declare const tradablePairs44787: TradablePairWithSpread[];