@mento-protocol/mento-sdk 1.15.2 → 1.15.4
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/dist/cjs/constants/tokens.11142220.js +1 -1
- package/dist/cjs/constants/tokens.42220.js +1 -1
- package/dist/cjs/constants/tokens.44787.js +1 -1
- package/dist/cjs/constants/tokens.d.ts +0 -14
- package/dist/cjs/constants/tokens.js +62 -84
- package/dist/cjs/mento.js +26 -4
- package/dist/cjs/utils.d.ts +16 -3
- package/dist/cjs/utils.js +30 -12
- package/dist/esm/constants/tokens.11142220.js +1 -1
- package/dist/esm/constants/tokens.42220.js +1 -1
- package/dist/esm/constants/tokens.44787.js +1 -1
- package/dist/esm/constants/tokens.d.ts +0 -14
- package/dist/esm/constants/tokens.js +61 -81
- package/dist/esm/mento.js +3 -4
- package/dist/esm/utils.d.ts +16 -3
- package/dist/esm/utils.js +25 -9
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// This file is auto-generated. Do not edit manually.
|
|
3
|
-
// Generated on 2025-10-
|
|
3
|
+
// Generated on 2025-10-06T16:08:43.517Z
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.tokens11142220 = void 0;
|
|
6
6
|
const mento_1 = require("../mento");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// This file is auto-generated. Do not edit manually.
|
|
3
|
-
// Generated on 2025-10-
|
|
3
|
+
// Generated on 2025-10-06T16:08:23.483Z
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.tokens42220 = void 0;
|
|
6
6
|
const mento_1 = require("../mento");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// This file is auto-generated. Do not edit manually.
|
|
3
|
-
// Generated on 2025-10-
|
|
3
|
+
// Generated on 2025-10-06T16:08:33.900Z
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.tokens44787 = void 0;
|
|
6
6
|
const mento_1 = require("../mento");
|
|
@@ -51,17 +51,3 @@ export declare enum TokenSymbol {
|
|
|
51
51
|
export declare const TOKEN_ADDRESSES_BY_CHAIN: {
|
|
52
52
|
[chainId: number]: Partial<Record<TokenSymbol, string>>;
|
|
53
53
|
};
|
|
54
|
-
/**
|
|
55
|
-
* Helper function to get token address by symbol for a specific chain
|
|
56
|
-
* @param symbol - The token symbol
|
|
57
|
-
* @param chainId - The chain ID
|
|
58
|
-
* @returns The token address or undefined if not found
|
|
59
|
-
*/
|
|
60
|
-
export declare function getTokenAddress(symbol: TokenSymbol, chainId: number): string | undefined;
|
|
61
|
-
/**
|
|
62
|
-
* Helper function to find a token by symbol in the cached tokens
|
|
63
|
-
* @param symbol - The token symbol to search for
|
|
64
|
-
* @param chainId - The chain ID
|
|
65
|
-
* @returns The token object or undefined if not found
|
|
66
|
-
*/
|
|
67
|
-
export declare function findTokenBySymbol(symbol: string, chainId: number): Token | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// This file is auto-generated. Do not edit manually.
|
|
3
|
-
// Generated on 2025-10-
|
|
3
|
+
// Generated on 2025-10-06T16:08:43.519Z
|
|
4
4
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
5
|
if (k2 === undefined) k2 = k;
|
|
6
6
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -34,7 +34,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
34
34
|
});
|
|
35
35
|
};
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.
|
|
37
|
+
exports.TOKEN_ADDRESSES_BY_CHAIN = exports.TokenSymbol = exports.getCachedTokensSync = exports.getCachedTokens = void 0;
|
|
38
38
|
/**
|
|
39
39
|
* Gets cached tokens for a specific chain ID
|
|
40
40
|
* @param chainId - The chain ID to get cached tokens for
|
|
@@ -117,91 +117,69 @@ var TokenSymbol;
|
|
|
117
117
|
*/
|
|
118
118
|
exports.TOKEN_ADDRESSES_BY_CHAIN = {
|
|
119
119
|
42220: {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
120
|
+
axlEUROC: '0x061cc5a2C863E0C1Cb404006D559dB18A34C762d',
|
|
121
|
+
axlUSDC: '0xEB466342C4d449BC9f53A865D5Cb90586f405215',
|
|
122
|
+
cAUD: '0x7175504C455076F15c04A2F90a8e352281F492F9',
|
|
123
|
+
cCAD: '0xff4Ab19391af240c311c54200a492233052B6325',
|
|
124
|
+
cCHF: '0xb55a79F398E759E43C95b979163f30eC87Ee131D',
|
|
125
|
+
cCOP: '0x8A567e2aE79CA692Bd748aB832081C45de4041eA',
|
|
126
|
+
CELO: '0x471EcE3750Da237f93B8E339c536989b8978a438',
|
|
127
|
+
cEUR: '0xD8763CBa276a3738E6DE85b4b3bF5FDed6D6cA73',
|
|
128
|
+
cGBP: '0xCCF663b1fF11028f0b19058d0f7B674004a40746',
|
|
129
|
+
cGHS: '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
|
|
130
|
+
cJPY: '0xc45eCF20f3CD864B32D9794d6f76814aE8892e20',
|
|
131
|
+
cKES: '0x456a3D042C0DbD3db53D5489e98dFb038553B0d0',
|
|
132
|
+
cNGN: '0xE2702Bd97ee33c88c8f6f92DA3B733608aa76F71',
|
|
133
|
+
cREAL: '0xe8537a3d056DA446677B9E9d6c5dB704EaAb4787',
|
|
134
|
+
cUSD: '0x765DE816845861e75A25fCA122bb6898B8B1282a',
|
|
135
|
+
cZAR: '0x4c35853A3B4e647fD266f4de678dCc8fEC410BF6',
|
|
136
|
+
eXOF: '0x73F93dcc49cB8A239e2032663e9475dd5ef29A08',
|
|
137
|
+
PUSO: '0x105d4A9306D2E55a71d2Eb95B81553AE1dC20d7B',
|
|
138
|
+
'USD₮': '0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e',
|
|
139
|
+
USDC: '0xcebA9300f2b948710d2653dD7B07f33A8B32118C',
|
|
140
140
|
},
|
|
141
141
|
44787: {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
142
|
+
BridgedEUROC: '0x6e673502c5b55F3169657C004e5797fFE5be6653',
|
|
143
|
+
BridgedUSDC: '0x87D61dA3d668797786D73BC674F053f87111570d',
|
|
144
|
+
cAUD: '0x84CBD49F5aE07632B6B88094E81Cce8236125Fe0',
|
|
145
|
+
cCAD: '0x02EC9E0D2Fd73e89168C1709e542a48f58d7B133',
|
|
146
|
+
cCHF: '0xADC57C2C34aD021Df4421230a6532F4e2E1dCE4F',
|
|
147
|
+
cCOP: '0xe6A57340f0df6E020c1c0a80bC6E13048601f0d4',
|
|
148
|
+
CELO: '0xF194afDf50B03e69Bd7D057c1Aa9e10c9954E4C9',
|
|
149
|
+
cEUR: '0x10c892A6EC43a53E45D0B916B4b7D383B1b78C0F',
|
|
150
|
+
cGBP: '0x47f2Fb88105155a18c390641C8a73f1402B2BB12',
|
|
151
|
+
cGHS: '0x295B66bE7714458Af45E6A6Ea142A5358A6cA375',
|
|
152
|
+
cJPY: '0x2E51F41238cA36a421C9B8b3e189e8Cc7653FE67',
|
|
153
|
+
cKES: '0x1E0433C1769271ECcF4CFF9FDdD515eefE6CdF92',
|
|
154
|
+
cNGN: '0x4a5b03B8b16122D330306c65e4CA4BC5Dd6511d0',
|
|
155
|
+
cREAL: '0xE4D517785D091D3c54818832dB6094bcc2744545',
|
|
156
|
+
cUSD: '0x874069Fa1Eb16D44d622F2e0Ca25eeA172369bC1',
|
|
157
|
+
cZAR: '0x1e5b44015Ff90610b54000DAad31C89b3284df4d',
|
|
158
|
+
eXOF: '0xB0FA15e002516d0301884059c0aaC0F0C72b019D',
|
|
159
|
+
PUSO: '0x5E0E3c9419C42a1B04e2525991FB1A2C467AB8bF',
|
|
160
|
+
USDC: '0x2F25deB3848C207fc8E0c34035B3Ba7fC157602B',
|
|
161
|
+
USDT: '0xBba91F588d031469ABCCA566FE80fB1Ad8Ee3287',
|
|
162
162
|
},
|
|
163
163
|
11142220: {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
164
|
+
axlEUROC: '0x9883d788d40F1C7595a780ed881Ea833C7743B4B',
|
|
165
|
+
axlUSDC: '0x6285De9DA7C1d329C0451628638908915002d9d1',
|
|
166
|
+
cAUD: '0x5873Faeb42F3563dcD77F0fbbdA818E6d6DA3139',
|
|
167
|
+
cCAD: '0xF151c9a13b78C84f93f50B8b3bC689fedc134F60',
|
|
168
|
+
cCHF: '0x284E9b7B623eAE866914b7FA0eB720C2Bb3C2980',
|
|
169
|
+
cCOP: '0x5F8d55c3627d2dc0a2B4afa798f877242F382F67',
|
|
170
|
+
CELO: '0x471EcE3750Da237f93B8E339c536989b8978a438',
|
|
171
|
+
cEUR: '0xA99dC247d6b7B2E3ab48a1fEE101b83cD6aCd82a',
|
|
172
|
+
cGBP: '0x85F5181Abdbf0e1814Fc4358582Ae07b8eBA3aF3',
|
|
173
|
+
cGHS: '0x5e94B8C872bD47BC4255E60ECBF44D5E66e7401C',
|
|
174
|
+
cJPY: '0x85Bee67D435A39f7467a8a9DE34a5B73D25Df426',
|
|
175
|
+
cKES: '0xC7e4635651E3e3Af82b61d3E23c159438daE3BbF',
|
|
176
|
+
cNGN: '0x3d5ae86F34E2a82771496D140daFAEf3789dF888',
|
|
177
|
+
cREAL: '0x2294298942fdc79417DE9E0D740A4957E0e7783a',
|
|
178
|
+
cUSD: '0xdE9e4C3ce781b4bA68120d6261cbad65ce0aB00b',
|
|
179
|
+
cZAR: '0x10CCfB235b0E1Ed394bACE4560C3ed016697687e',
|
|
180
|
+
eXOF: '0x5505b70207aE3B826c1A7607F19F3Bf73444A082',
|
|
181
|
+
PUSO: '0x0352976d940a2C3FBa0C3623198947Ee1d17869E',
|
|
182
|
+
USDC: '0xBD63e46Be8eF8D89dFde3054E7b9ECAEb8Ad83e9',
|
|
183
|
+
USDT: '0xCA53d9b72646B254d29EBeEb4c5cde7BB4bb59e0',
|
|
184
184
|
},
|
|
185
185
|
};
|
|
186
|
-
/**
|
|
187
|
-
* Helper function to get token address by symbol for a specific chain
|
|
188
|
-
* @param symbol - The token symbol
|
|
189
|
-
* @param chainId - The chain ID
|
|
190
|
-
* @returns The token address or undefined if not found
|
|
191
|
-
*/
|
|
192
|
-
function getTokenAddress(symbol, chainId) {
|
|
193
|
-
var _a;
|
|
194
|
-
return (_a = exports.TOKEN_ADDRESSES_BY_CHAIN[chainId]) === null || _a === void 0 ? void 0 : _a[symbol];
|
|
195
|
-
}
|
|
196
|
-
exports.getTokenAddress = getTokenAddress;
|
|
197
|
-
/**
|
|
198
|
-
* Helper function to find a token by symbol in the cached tokens
|
|
199
|
-
* @param symbol - The token symbol to search for
|
|
200
|
-
* @param chainId - The chain ID
|
|
201
|
-
* @returns The token object or undefined if not found
|
|
202
|
-
*/
|
|
203
|
-
function findTokenBySymbol(symbol, chainId) {
|
|
204
|
-
const tokens = getCachedTokensSync(chainId);
|
|
205
|
-
return tokens.find((token) => token.symbol === symbol);
|
|
206
|
-
}
|
|
207
|
-
exports.findTokenBySymbol = findTokenBySymbol;
|
package/dist/cjs/mento.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -175,7 +198,7 @@ class Mento {
|
|
|
175
198
|
* @throws Error if no cached tokens are available for the current chain or if chainId is not yet initialized
|
|
176
199
|
*/
|
|
177
200
|
getTokens() {
|
|
178
|
-
if (this.cachedChainId
|
|
201
|
+
if (!this.cachedChainId) {
|
|
179
202
|
throw new Error('Chain ID not yet initialized. Use Mento.create() to initialize the SDK, or use getTokensAsync() instead.');
|
|
180
203
|
}
|
|
181
204
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
@@ -196,8 +219,7 @@ class Mento {
|
|
|
196
219
|
return __awaiter(this, void 0, void 0, function* () {
|
|
197
220
|
// If cached is true, try to use the static cache first
|
|
198
221
|
if (cached) {
|
|
199
|
-
|
|
200
|
-
const { getCachedTokens } = require('./constants/tokens');
|
|
222
|
+
const { getCachedTokens } = yield Promise.resolve().then(() => __importStar(require('./constants/tokens')));
|
|
201
223
|
const chainId = yield this.chainId();
|
|
202
224
|
const cachedTokens = yield getCachedTokens(chainId);
|
|
203
225
|
if (cachedTokens) {
|
|
@@ -629,7 +651,7 @@ class Mento {
|
|
|
629
651
|
}
|
|
630
652
|
chainId() {
|
|
631
653
|
return __awaiter(this, void 0, void 0, function* () {
|
|
632
|
-
if (this.cachedChainId
|
|
654
|
+
if (!this.cachedChainId) {
|
|
633
655
|
this.cachedChainId = yield (0, utils_1.getChainId)(this.signerOrProvider);
|
|
634
656
|
}
|
|
635
657
|
return this.cachedChainId;
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -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
|
|
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/cjs/utils.js
CHANGED
|
@@ -9,8 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.capitalize = exports.
|
|
12
|
+
exports.findTokenBySymbol = exports.getTokenAddress = exports.capitalize = exports.findTokenAddressBySymbolInTradablePairs = exports.increaseAllowance = exports.getDecimalsFromTokenAddress = exports.getNameFromTokenAddress = exports.getSymbolFromTokenAddress = exports.validateSignerOrProvider = exports.validateSigner = exports.getChainId = void 0;
|
|
13
13
|
const ethers_1 = require("ethers");
|
|
14
|
+
const tokens_1 = require("./constants/tokens");
|
|
14
15
|
/**
|
|
15
16
|
* Gets the chain ID from a signer or provider
|
|
16
17
|
* @param signerOrProvider an ethers provider or signer
|
|
@@ -123,18 +124,35 @@ exports.increaseAllowance = increaseAllowance;
|
|
|
123
124
|
* @param symbol the token symbol to find (case-insensitive)
|
|
124
125
|
* @returns the token address if found, null otherwise
|
|
125
126
|
*/
|
|
126
|
-
function
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return null;
|
|
127
|
+
function findTokenAddressBySymbolInTradablePairs(symbol, pairs) {
|
|
128
|
+
var _a, _b;
|
|
129
|
+
return ((_b = (_a = pairs
|
|
130
|
+
.flatMap((pair) => pair.assets)
|
|
131
|
+
.find((asset) => asset.symbol.toLowerCase() === symbol.toLowerCase())) === null || _a === void 0 ? void 0 : _a.address) !== null && _b !== void 0 ? _b : null);
|
|
135
132
|
}
|
|
136
|
-
exports.
|
|
133
|
+
exports.findTokenAddressBySymbolInTradablePairs = findTokenAddressBySymbolInTradablePairs;
|
|
137
134
|
function capitalize(str) {
|
|
138
135
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
139
|
-
}
|
|
136
|
+
} /**
|
|
137
|
+
* Helper function to get token address by symbol for a specific chain
|
|
138
|
+
* @param symbol - The token symbol
|
|
139
|
+
* @param chainId - The chain ID
|
|
140
|
+
* @returns The token address or undefined if not found
|
|
141
|
+
*/
|
|
140
142
|
exports.capitalize = capitalize;
|
|
143
|
+
function getTokenAddress(symbol, chainId) {
|
|
144
|
+
var _a;
|
|
145
|
+
return (_a = tokens_1.TOKEN_ADDRESSES_BY_CHAIN[chainId]) === null || _a === void 0 ? void 0 : _a[symbol];
|
|
146
|
+
}
|
|
147
|
+
exports.getTokenAddress = getTokenAddress;
|
|
148
|
+
/**
|
|
149
|
+
* Helper function to find a token by symbol in the cached tokens
|
|
150
|
+
* @param symbol - The token symbol to search for
|
|
151
|
+
* @param chainId - The chain ID
|
|
152
|
+
* @returns The token object or undefined if not found
|
|
153
|
+
*/
|
|
154
|
+
function findTokenBySymbol(symbol, chainId) {
|
|
155
|
+
const tokens = (0, tokens_1.getCachedTokensSync)(chainId);
|
|
156
|
+
return tokens.find((token) => token.symbol === symbol);
|
|
157
|
+
}
|
|
158
|
+
exports.findTokenBySymbol = findTokenBySymbol;
|
|
@@ -51,17 +51,3 @@ export declare enum TokenSymbol {
|
|
|
51
51
|
export declare const TOKEN_ADDRESSES_BY_CHAIN: {
|
|
52
52
|
[chainId: number]: Partial<Record<TokenSymbol, string>>;
|
|
53
53
|
};
|
|
54
|
-
/**
|
|
55
|
-
* Helper function to get token address by symbol for a specific chain
|
|
56
|
-
* @param symbol - The token symbol
|
|
57
|
-
* @param chainId - The chain ID
|
|
58
|
-
* @returns The token address or undefined if not found
|
|
59
|
-
*/
|
|
60
|
-
export declare function getTokenAddress(symbol: TokenSymbol, chainId: number): string | undefined;
|
|
61
|
-
/**
|
|
62
|
-
* Helper function to find a token by symbol in the cached tokens
|
|
63
|
-
* @param symbol - The token symbol to search for
|
|
64
|
-
* @param chainId - The chain ID
|
|
65
|
-
* @returns The token object or undefined if not found
|
|
66
|
-
*/
|
|
67
|
-
export declare function findTokenBySymbol(symbol: string, chainId: number): Token | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// This file is auto-generated. Do not edit manually.
|
|
2
|
-
// Generated on 2025-10-
|
|
2
|
+
// Generated on 2025-10-06T16:08:43.519Z
|
|
3
3
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
4
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
5
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -89,89 +89,69 @@ export var TokenSymbol;
|
|
|
89
89
|
*/
|
|
90
90
|
export const TOKEN_ADDRESSES_BY_CHAIN = {
|
|
91
91
|
42220: {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
92
|
+
axlEUROC: '0x061cc5a2C863E0C1Cb404006D559dB18A34C762d',
|
|
93
|
+
axlUSDC: '0xEB466342C4d449BC9f53A865D5Cb90586f405215',
|
|
94
|
+
cAUD: '0x7175504C455076F15c04A2F90a8e352281F492F9',
|
|
95
|
+
cCAD: '0xff4Ab19391af240c311c54200a492233052B6325',
|
|
96
|
+
cCHF: '0xb55a79F398E759E43C95b979163f30eC87Ee131D',
|
|
97
|
+
cCOP: '0x8A567e2aE79CA692Bd748aB832081C45de4041eA',
|
|
98
|
+
CELO: '0x471EcE3750Da237f93B8E339c536989b8978a438',
|
|
99
|
+
cEUR: '0xD8763CBa276a3738E6DE85b4b3bF5FDed6D6cA73',
|
|
100
|
+
cGBP: '0xCCF663b1fF11028f0b19058d0f7B674004a40746',
|
|
101
|
+
cGHS: '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
|
|
102
|
+
cJPY: '0xc45eCF20f3CD864B32D9794d6f76814aE8892e20',
|
|
103
|
+
cKES: '0x456a3D042C0DbD3db53D5489e98dFb038553B0d0',
|
|
104
|
+
cNGN: '0xE2702Bd97ee33c88c8f6f92DA3B733608aa76F71',
|
|
105
|
+
cREAL: '0xe8537a3d056DA446677B9E9d6c5dB704EaAb4787',
|
|
106
|
+
cUSD: '0x765DE816845861e75A25fCA122bb6898B8B1282a',
|
|
107
|
+
cZAR: '0x4c35853A3B4e647fD266f4de678dCc8fEC410BF6',
|
|
108
|
+
eXOF: '0x73F93dcc49cB8A239e2032663e9475dd5ef29A08',
|
|
109
|
+
PUSO: '0x105d4A9306D2E55a71d2Eb95B81553AE1dC20d7B',
|
|
110
|
+
'USD₮': '0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e',
|
|
111
|
+
USDC: '0xcebA9300f2b948710d2653dD7B07f33A8B32118C',
|
|
112
112
|
},
|
|
113
113
|
44787: {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
114
|
+
BridgedEUROC: '0x6e673502c5b55F3169657C004e5797fFE5be6653',
|
|
115
|
+
BridgedUSDC: '0x87D61dA3d668797786D73BC674F053f87111570d',
|
|
116
|
+
cAUD: '0x84CBD49F5aE07632B6B88094E81Cce8236125Fe0',
|
|
117
|
+
cCAD: '0x02EC9E0D2Fd73e89168C1709e542a48f58d7B133',
|
|
118
|
+
cCHF: '0xADC57C2C34aD021Df4421230a6532F4e2E1dCE4F',
|
|
119
|
+
cCOP: '0xe6A57340f0df6E020c1c0a80bC6E13048601f0d4',
|
|
120
|
+
CELO: '0xF194afDf50B03e69Bd7D057c1Aa9e10c9954E4C9',
|
|
121
|
+
cEUR: '0x10c892A6EC43a53E45D0B916B4b7D383B1b78C0F',
|
|
122
|
+
cGBP: '0x47f2Fb88105155a18c390641C8a73f1402B2BB12',
|
|
123
|
+
cGHS: '0x295B66bE7714458Af45E6A6Ea142A5358A6cA375',
|
|
124
|
+
cJPY: '0x2E51F41238cA36a421C9B8b3e189e8Cc7653FE67',
|
|
125
|
+
cKES: '0x1E0433C1769271ECcF4CFF9FDdD515eefE6CdF92',
|
|
126
|
+
cNGN: '0x4a5b03B8b16122D330306c65e4CA4BC5Dd6511d0',
|
|
127
|
+
cREAL: '0xE4D517785D091D3c54818832dB6094bcc2744545',
|
|
128
|
+
cUSD: '0x874069Fa1Eb16D44d622F2e0Ca25eeA172369bC1',
|
|
129
|
+
cZAR: '0x1e5b44015Ff90610b54000DAad31C89b3284df4d',
|
|
130
|
+
eXOF: '0xB0FA15e002516d0301884059c0aaC0F0C72b019D',
|
|
131
|
+
PUSO: '0x5E0E3c9419C42a1B04e2525991FB1A2C467AB8bF',
|
|
132
|
+
USDC: '0x2F25deB3848C207fc8E0c34035B3Ba7fC157602B',
|
|
133
|
+
USDT: '0xBba91F588d031469ABCCA566FE80fB1Ad8Ee3287',
|
|
134
134
|
},
|
|
135
135
|
11142220: {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
136
|
+
axlEUROC: '0x9883d788d40F1C7595a780ed881Ea833C7743B4B',
|
|
137
|
+
axlUSDC: '0x6285De9DA7C1d329C0451628638908915002d9d1',
|
|
138
|
+
cAUD: '0x5873Faeb42F3563dcD77F0fbbdA818E6d6DA3139',
|
|
139
|
+
cCAD: '0xF151c9a13b78C84f93f50B8b3bC689fedc134F60',
|
|
140
|
+
cCHF: '0x284E9b7B623eAE866914b7FA0eB720C2Bb3C2980',
|
|
141
|
+
cCOP: '0x5F8d55c3627d2dc0a2B4afa798f877242F382F67',
|
|
142
|
+
CELO: '0x471EcE3750Da237f93B8E339c536989b8978a438',
|
|
143
|
+
cEUR: '0xA99dC247d6b7B2E3ab48a1fEE101b83cD6aCd82a',
|
|
144
|
+
cGBP: '0x85F5181Abdbf0e1814Fc4358582Ae07b8eBA3aF3',
|
|
145
|
+
cGHS: '0x5e94B8C872bD47BC4255E60ECBF44D5E66e7401C',
|
|
146
|
+
cJPY: '0x85Bee67D435A39f7467a8a9DE34a5B73D25Df426',
|
|
147
|
+
cKES: '0xC7e4635651E3e3Af82b61d3E23c159438daE3BbF',
|
|
148
|
+
cNGN: '0x3d5ae86F34E2a82771496D140daFAEf3789dF888',
|
|
149
|
+
cREAL: '0x2294298942fdc79417DE9E0D740A4957E0e7783a',
|
|
150
|
+
cUSD: '0xdE9e4C3ce781b4bA68120d6261cbad65ce0aB00b',
|
|
151
|
+
cZAR: '0x10CCfB235b0E1Ed394bACE4560C3ed016697687e',
|
|
152
|
+
eXOF: '0x5505b70207aE3B826c1A7607F19F3Bf73444A082',
|
|
153
|
+
PUSO: '0x0352976d940a2C3FBa0C3623198947Ee1d17869E',
|
|
154
|
+
USDC: '0xBD63e46Be8eF8D89dFde3054E7b9ECAEb8Ad83e9',
|
|
155
|
+
USDT: '0xCA53d9b72646B254d29EBeEb4c5cde7BB4bb59e0',
|
|
156
156
|
},
|
|
157
157
|
};
|
|
158
|
-
/**
|
|
159
|
-
* Helper function to get token address by symbol for a specific chain
|
|
160
|
-
* @param symbol - The token symbol
|
|
161
|
-
* @param chainId - The chain ID
|
|
162
|
-
* @returns The token address or undefined if not found
|
|
163
|
-
*/
|
|
164
|
-
export function getTokenAddress(symbol, chainId) {
|
|
165
|
-
var _a;
|
|
166
|
-
return (_a = TOKEN_ADDRESSES_BY_CHAIN[chainId]) === null || _a === void 0 ? void 0 : _a[symbol];
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Helper function to find a token by symbol in the cached tokens
|
|
170
|
-
* @param symbol - The token symbol to search for
|
|
171
|
-
* @param chainId - The chain ID
|
|
172
|
-
* @returns The token object or undefined if not found
|
|
173
|
-
*/
|
|
174
|
-
export function findTokenBySymbol(symbol, chainId) {
|
|
175
|
-
const tokens = getCachedTokensSync(chainId);
|
|
176
|
-
return tokens.find((token) => token.symbol === symbol);
|
|
177
|
-
}
|
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
|
|
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
|
-
|
|
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
|
|
627
|
+
if (!this.cachedChainId) {
|
|
629
628
|
this.cachedChainId = yield getChainId(this.signerOrProvider);
|
|
630
629
|
}
|
|
631
630
|
return this.cachedChainId;
|
package/dist/esm/utils.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
}
|