@funkit/core 1.0.13 → 1.0.14
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/src/apis/index.d.ts +0 -6
- package/dist/src/apis/index.js +0 -6
- package/dist/src/apis/index.js.map +1 -1
- package/dist/src/apis/types.d.ts +0 -5
- package/dist/src/apis/types.js.map +1 -1
- package/dist/src/utils/ChainUtils.js +27 -5
- package/dist/src/utils/ChainUtils.js.map +1 -1
- package/dist/src/utils/index.d.ts +0 -1
- package/dist/src/utils/index.js +0 -1
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/viem/Converter.d.ts +16 -16
- package/dist/src/wallet/FunWallet.d.ts +7 -6
- package/dist/src/wallet/FunWallet.js +60 -20
- package/dist/src/wallet/FunWallet.js.map +1 -1
- package/package.json +3 -2
- package/dist/src/apis/AssetApis.d.ts +0 -89
- package/dist/src/apis/AssetApis.js +0 -110
- package/dist/src/apis/AssetApis.js.map +0 -1
- package/dist/src/apis/CheckoutApis.d.ts +0 -55
- package/dist/src/apis/CheckoutApis.js +0 -174
- package/dist/src/apis/CheckoutApis.js.map +0 -1
- package/dist/src/apis/FaucetApis.d.ts +0 -1
- package/dist/src/apis/FaucetApis.js +0 -10
- package/dist/src/apis/FaucetApis.js.map +0 -1
- package/dist/src/apis/MeshApis.d.ts +0 -44
- package/dist/src/apis/MeshApis.js +0 -109
- package/dist/src/apis/MeshApis.js.map +0 -1
- package/dist/src/apis/OnOffRampApis.d.ts +0 -37
- package/dist/src/apis/OnOffRampApis.js +0 -63
- package/dist/src/apis/OnOffRampApis.js.map +0 -1
- package/dist/src/apis/OnOffRampUtils.d.ts +0 -2
- package/dist/src/apis/OnOffRampUtils.js +0 -23
- package/dist/src/apis/OnOffRampUtils.js.map +0 -1
- package/dist/src/apis/SupportApis.d.ts +0 -6
- package/dist/src/apis/SupportApis.js +0 -16
- package/dist/src/apis/SupportApis.js.map +0 -1
- package/dist/src/apis/TurnkeyApis.d.ts +0 -3
- package/dist/src/apis/TurnkeyApis.js +0 -19
- package/dist/src/apis/TurnkeyApis.js.map +0 -1
- package/dist/src/utils/AssetUtils.d.ts +0 -9
- package/dist/src/utils/AssetUtils.js +0 -48
- package/dist/src/utils/AssetUtils.js.map +0 -1
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export declare function getOnRampUrl(walletAddr: string, currencyCode?: string): Promise<string>;
|
|
2
|
-
export declare function getMoonpayUrlSignature(url: string, isSandbox?: boolean, apiKey?: string): Promise<string>;
|
|
3
|
-
export declare function getMoonpayBuyQuoteForCreditCard({ currencyCode, baseCurrencyCode, quoteCurrencyAmount, baseCurrencyAmount, extraFeePercentage, areFeesIncluded, apiKey, }: {
|
|
4
|
-
currencyCode: string;
|
|
5
|
-
baseCurrencyCode: string;
|
|
6
|
-
quoteCurrencyAmount: string;
|
|
7
|
-
baseCurrencyAmount?: number;
|
|
8
|
-
extraFeePercentage?: number;
|
|
9
|
-
areFeesIncluded?: boolean;
|
|
10
|
-
apiKey?: string;
|
|
11
|
-
}): Promise<string>;
|
|
12
|
-
export declare function getOffRampUrl(walletAddr: string): Promise<string>;
|
|
13
|
-
export interface Currency {
|
|
14
|
-
id: string;
|
|
15
|
-
name: string;
|
|
16
|
-
code: string;
|
|
17
|
-
createdAt?: string;
|
|
18
|
-
updatedAt?: string;
|
|
19
|
-
type?: string;
|
|
20
|
-
precision?: number;
|
|
21
|
-
addressRegex?: string;
|
|
22
|
-
testnetAddressRegex?: string;
|
|
23
|
-
maxAmount?: number;
|
|
24
|
-
maxBuyAmount?: number;
|
|
25
|
-
maxSellAmount?: number;
|
|
26
|
-
minAmount?: number;
|
|
27
|
-
minBuyAmount?: number;
|
|
28
|
-
minSellAmount?: number;
|
|
29
|
-
supportsAddressTag?: boolean;
|
|
30
|
-
addressTagRegex?: string;
|
|
31
|
-
supportsTestMode?: boolean;
|
|
32
|
-
isSuspended?: boolean;
|
|
33
|
-
isSupportedInUS?: boolean;
|
|
34
|
-
isSellSupported?: boolean;
|
|
35
|
-
notAllowedUSStates?: string[];
|
|
36
|
-
}
|
|
37
|
-
export declare function getOnRampSupportedCurrencies(): Promise<Currency[]>;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOnRampSupportedCurrencies = exports.getOffRampUrl = exports.getMoonpayBuyQuoteForCreditCard = exports.getMoonpayUrlSignature = exports.getOnRampUrl = void 0;
|
|
4
|
-
const constants_1 = require("../common/constants");
|
|
5
|
-
const errors_1 = require("../errors");
|
|
6
|
-
const ApiUtils_1 = require("../utils/ApiUtils");
|
|
7
|
-
async function getOnRampUrl(walletAddr, currencyCode) {
|
|
8
|
-
const endpoint = `on-ramp/${walletAddr}?provider=moonpay`;
|
|
9
|
-
if (currencyCode) {
|
|
10
|
-
endpoint.concat(`¤cyCode=${currencyCode}`);
|
|
11
|
-
}
|
|
12
|
-
const url = (await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, endpoint))?.url;
|
|
13
|
-
if (!url) {
|
|
14
|
-
throw new errors_1.InternalFailureError(errors_1.ErrorCode.UnknownServerError, 'No onramp url found.', { walletAddr }, 'This is an internal error, please contact support.', 'https://docs.fun.xyz');
|
|
15
|
-
}
|
|
16
|
-
return url;
|
|
17
|
-
}
|
|
18
|
-
exports.getOnRampUrl = getOnRampUrl;
|
|
19
|
-
async function getMoonpayUrlSignature(url, isSandbox, apiKey) {
|
|
20
|
-
const signature = await (0, ApiUtils_1.sendPostRequest)(constants_1.API_URL, `on-ramp/moonpay-signature/`, { url, isSandbox }, apiKey);
|
|
21
|
-
if (!signature) {
|
|
22
|
-
throw new errors_1.InternalFailureError(errors_1.ErrorCode.UnknownServerError, 'No onramp url found.', { url }, 'This is an internal error, please contact support.', 'https://docs.fun.xyz');
|
|
23
|
-
}
|
|
24
|
-
return signature.url;
|
|
25
|
-
}
|
|
26
|
-
exports.getMoonpayUrlSignature = getMoonpayUrlSignature;
|
|
27
|
-
async function getMoonpayBuyQuoteForCreditCard({ currencyCode, baseCurrencyCode, quoteCurrencyAmount, baseCurrencyAmount, extraFeePercentage, areFeesIncluded, apiKey, }) {
|
|
28
|
-
const params = new URLSearchParams({
|
|
29
|
-
currencyCode,
|
|
30
|
-
baseCurrencyCode,
|
|
31
|
-
quoteCurrencyAmount,
|
|
32
|
-
paymentMethod: 'credit_debit_card',
|
|
33
|
-
...(baseCurrencyAmount == null
|
|
34
|
-
? {}
|
|
35
|
-
: { baseCurrencyAmount: baseCurrencyAmount.toString() }),
|
|
36
|
-
...(extraFeePercentage == null
|
|
37
|
-
? {}
|
|
38
|
-
: { extraFeePercentage: extraFeePercentage.toString() }),
|
|
39
|
-
...(areFeesIncluded == null
|
|
40
|
-
? {}
|
|
41
|
-
: { areFeesIncluded: areFeesIncluded.toString() }),
|
|
42
|
-
}).toString();
|
|
43
|
-
const res = await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, `on-ramp/moonpay-buy-quote?${params}`, apiKey, { maxAttempts: 1 });
|
|
44
|
-
return res;
|
|
45
|
-
}
|
|
46
|
-
exports.getMoonpayBuyQuoteForCreditCard = getMoonpayBuyQuoteForCreditCard;
|
|
47
|
-
async function getOffRampUrl(walletAddr) {
|
|
48
|
-
const url = (await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, `off-ramp/${walletAddr}?provider=moonpay`))?.url;
|
|
49
|
-
if (!url) {
|
|
50
|
-
throw new errors_1.InternalFailureError(errors_1.ErrorCode.UnknownServerError, 'No offramp url found.', { walletAddr }, 'This is an internal error, please contact support.', 'https://docs.fun.xyz');
|
|
51
|
-
}
|
|
52
|
-
return url;
|
|
53
|
-
}
|
|
54
|
-
exports.getOffRampUrl = getOffRampUrl;
|
|
55
|
-
async function getOnRampSupportedCurrencies() {
|
|
56
|
-
const currencies = await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, 'on-ramp/currencies');
|
|
57
|
-
if (!currencies || !currencies.length) {
|
|
58
|
-
throw new errors_1.InternalFailureError(errors_1.ErrorCode.UnknownServerError, 'No supported currencies found.', {}, 'This is an internal error, please contact support.', 'https://docs.fun.xyz');
|
|
59
|
-
}
|
|
60
|
-
return currencies;
|
|
61
|
-
}
|
|
62
|
-
exports.getOnRampSupportedCurrencies = getOnRampSupportedCurrencies;
|
|
63
|
-
//# sourceMappingURL=OnOffRampApis.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OnOffRampApis.js","sourceRoot":"","sources":["../../../src/apis/OnOffRampApis.ts"],"names":[],"mappings":";;;AAAA,mDAA6C;AAC7C,sCAA2D;AAC3D,gDAAmE;AAE5D,KAAK,UAAU,YAAY,CAChC,UAAkB,EAClB,YAAqB;IAErB,MAAM,QAAQ,GAAG,WAAW,UAAU,mBAAmB,CAAA;IACzD,IAAI,YAAY,EAAE,CAAC;QACjB,QAAQ,CAAC,MAAM,CAAC,iBAAiB,YAAY,EAAE,CAAC,CAAA;IAClD,CAAC;IACD,MAAM,GAAG,GAAW,CAAC,MAAM,IAAA,yBAAc,EAAC,mBAAO,EAAE,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAA;IAClE,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,6BAAoB,CAC5B,kBAAS,CAAC,kBAAkB,EAC5B,sBAAsB,EACtB,EAAE,UAAU,EAAE,EACd,oDAAoD,EACpD,sBAAsB,CACvB,CAAA;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAnBD,oCAmBC;AAEM,KAAK,UAAU,sBAAsB,CAC1C,GAAW,EACX,SAAmB,EACnB,MAAe;IAEf,MAAM,SAAS,GAAG,MAAM,IAAA,0BAAe,EACrC,mBAAO,EACP,4BAA4B,EAC5B,EAAE,GAAG,EAAE,SAAS,EAAE,EAClB,MAAM,CACP,CAAA;IACD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,6BAAoB,CAC5B,kBAAS,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,EAAE,CAAC;QACT,MAAM,IAAI,6BAAoB,CAC5B,kBAAS,CAAC,kBAAkB,EAC5B,uBAAuB,EACvB,EAAE,UAAU,EAAE,EACd,oDAAoD,EACpD,sBAAsB,CACvB,CAAA;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAdD,sCAcC;AA2BM,KAAK,UAAU,4BAA4B;IAChD,MAAM,UAAU,GAAe,MAAM,IAAA,yBAAc,EACjD,mBAAO,EACP,oBAAoB,CACrB,CAAA;IACD,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;QACtC,MAAM,IAAI,6BAAoB,CAC5B,kBAAS,CAAC,kBAAkB,EAC5B,gCAAgC,EAChC,EAAE,EACF,oDAAoD,EACpD,sBAAsB,CACvB,CAAA;IACH,CAAC;IACD,OAAO,UAAU,CAAA;AACnB,CAAC;AAfD,oEAeC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOffRampUrl = exports.getOnRampUrl = void 0;
|
|
4
|
-
const constants_1 = require("../common/constants");
|
|
5
|
-
const errors_1 = require("../errors");
|
|
6
|
-
const ApiUtils_1 = require("../utils/ApiUtils");
|
|
7
|
-
async function getOnRampUrl(walletAddr) {
|
|
8
|
-
const url = (await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, `on-ramp/${walletAddr}?provider=moonpay`))?.url;
|
|
9
|
-
if (!url) {
|
|
10
|
-
throw new errors_1.InternalFailureError(errors_1.ErrorCode.ServerFailure, `fail to get on ramp url for ${walletAddr}`, { walletAddr }, 'retry later. if it still fails, please contact us.', 'https://docs.fun.xyz');
|
|
11
|
-
}
|
|
12
|
-
return url;
|
|
13
|
-
}
|
|
14
|
-
exports.getOnRampUrl = getOnRampUrl;
|
|
15
|
-
async function getOffRampUrl(walletAddr) {
|
|
16
|
-
const url = (await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, `off-ramp/${walletAddr}?provider=moonpay`))?.url;
|
|
17
|
-
if (!url) {
|
|
18
|
-
throw new errors_1.InternalFailureError(errors_1.ErrorCode.ServerFailure, `fail to get off ramp url for ${walletAddr}`, { walletAddr }, 'retry later. if it still fails, please contact us.', 'https://docs.fun.xyz');
|
|
19
|
-
}
|
|
20
|
-
return url;
|
|
21
|
-
}
|
|
22
|
-
exports.getOffRampUrl = getOffRampUrl;
|
|
23
|
-
//# sourceMappingURL=OnOffRampUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OnOffRampUtils.js","sourceRoot":"","sources":["../../../src/apis/OnOffRampUtils.ts"],"names":[],"mappings":";;;AAAA,mDAA6C;AAC7C,sCAA2D;AAC3D,gDAAkD;AAE3C,KAAK,UAAU,YAAY,CAAC,UAAkB;IACnD,MAAM,GAAG,GAAG,CACV,MAAM,IAAA,yBAAc,EAAC,mBAAO,EAAE,WAAW,UAAU,mBAAmB,CAAC,CACxE,EAAE,GAAG,CAAA;IACN,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,6BAAoB,CAC5B,kBAAS,CAAC,aAAa,EACvB,+BAA+B,UAAU,EAAE,EAC3C,EAAE,UAAU,EAAE,EACd,oDAAoD,EACpD,sBAAsB,CACvB,CAAA;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAdD,oCAcC;AAEM,KAAK,UAAU,aAAa,CAAC,UAAkB;IACpD,MAAM,GAAG,GAAG,CACV,MAAM,IAAA,yBAAc,EAAC,mBAAO,EAAE,YAAY,UAAU,mBAAmB,CAAC,CACzE,EAAE,GAAG,CAAA;IACN,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,6BAAoB,CAC5B,kBAAS,CAAC,aAAa,EACvB,gCAAgC,UAAU,EAAE,EAC5C,EAAE,UAAU,EAAE,EACd,oDAAoD,EACpD,sBAAsB,CACvB,CAAA;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAdD,sCAcC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendSupportMessage = void 0;
|
|
4
|
-
const constants_1 = require("../common/constants");
|
|
5
|
-
const ApiUtils_1 = require("../utils/ApiUtils");
|
|
6
|
-
async function sendSupportMessage({ title, description, userEmail, apiKey, }) {
|
|
7
|
-
try {
|
|
8
|
-
await (0, ApiUtils_1.sendPostRequest)(constants_1.API_URL, `support/send-message`, { title, description, userEmail }, apiKey, { maxAttempts: 1 });
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
catch (err) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.sendSupportMessage = sendSupportMessage;
|
|
16
|
-
//# sourceMappingURL=SupportApis.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SupportApis.js","sourceRoot":"","sources":["../../../src/apis/SupportApis.ts"],"names":[],"mappings":";;;AAAA,mDAA6C;AAC7C,gDAAmD;AAE5C,KAAK,UAAU,kBAAkB,CAAC,EACvC,KAAK,EACL,WAAW,EACX,SAAS,EACT,MAAM,GAMP;IACC,IAAI,CAAC;QACH,MAAM,IAAA,0BAAe,EACnB,mBAAO,EACP,sBAAsB,EACtB,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,EACjC,MAAM,EACN,EAAE,WAAW,EAAE,CAAC,EAAE,CACnB,CAAA;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAvBD,gDAuBC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createTurnkeyPrivateKey = exports.createTurnkeySubOrg = void 0;
|
|
4
|
-
const constants_1 = require("../common/constants");
|
|
5
|
-
const ApiUtils_1 = require("../utils/ApiUtils");
|
|
6
|
-
async function createTurnkeySubOrg(createSubOrgRequest) {
|
|
7
|
-
const res = await (0, ApiUtils_1.sendPostRequest)(constants_1.API_URL, 'turnkey/sub-org', createSubOrgRequest);
|
|
8
|
-
return res;
|
|
9
|
-
}
|
|
10
|
-
exports.createTurnkeySubOrg = createTurnkeySubOrg;
|
|
11
|
-
async function createTurnkeyPrivateKey(signedRequest) {
|
|
12
|
-
const res = await (0, ApiUtils_1.sendPostRequest)(constants_1.API_URL, 'turnkey/private-key', signedRequest);
|
|
13
|
-
return {
|
|
14
|
-
id: res.id,
|
|
15
|
-
address: res.address,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
exports.createTurnkeyPrivateKey = createTurnkeyPrivateKey;
|
|
19
|
-
//# sourceMappingURL=TurnkeyApis.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TurnkeyApis.js","sourceRoot":"","sources":["../../../src/apis/TurnkeyApis.ts"],"names":[],"mappings":";;;AAAA,mDAA6C;AAC7C,gDAAmD;AAG5C,KAAK,UAAU,mBAAmB,CACvC,mBAA2B;IAE3B,MAAM,GAAG,GAAG,MAAM,IAAA,0BAAe,EAC/B,mBAAO,EACP,iBAAiB,EACjB,mBAAmB,CACpB,CAAA;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AATD,kDASC;AAEM,KAAK,UAAU,uBAAuB,CAC3C,aAAqB;IAErB,MAAM,GAAG,GAAG,MAAM,IAAA,0BAAe,EAC/B,mBAAO,EACP,qBAAqB,EACrB,aAAa,CACd,CAAA;IACD,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,OAAO,EAAE,GAAG,CAAC,OAAO;KACrB,CAAA;AACH,CAAC;AAZD,0DAYC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get all tokens on all supported chains. Merge tokens by symbol
|
|
3
|
-
* @param {string} walletAddress the wallet address
|
|
4
|
-
* @param {string} chainIdInput string version of the chainId or ALL. If empty, then default to the one in globalEnvOption
|
|
5
|
-
* @param {*} onlyVerifiedTokens true if you want to filter out spam tokens(Uses alchemy lists)
|
|
6
|
-
* @param {boolean} checkStatus true if you want to check if the address has any pending lido withdrawals
|
|
7
|
-
* @returns JSON of all tokens owned by address
|
|
8
|
-
*/
|
|
9
|
-
export declare function getAssetsByWalletAddress(walletAddress: any, chainIdInput?: string, onlyVerifiedTokens?: boolean, checkStatus?: boolean): Promise<{}>;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAssetsByWalletAddress = void 0;
|
|
4
|
-
const apis_1 = require("../apis");
|
|
5
|
-
const data_1 = require("../data");
|
|
6
|
-
/**
|
|
7
|
-
* Get all tokens on all supported chains. Merge tokens by symbol
|
|
8
|
-
* @param {string} walletAddress the wallet address
|
|
9
|
-
* @param {string} chainIdInput string version of the chainId or ALL. If empty, then default to the one in globalEnvOption
|
|
10
|
-
* @param {*} onlyVerifiedTokens true if you want to filter out spam tokens(Uses alchemy lists)
|
|
11
|
-
* @param {boolean} checkStatus true if you want to check if the address has any pending lido withdrawals
|
|
12
|
-
* @returns JSON of all tokens owned by address
|
|
13
|
-
*/
|
|
14
|
-
async function getAssetsByWalletAddress(walletAddress, chainIdInput, onlyVerifiedTokens = false, checkStatus = false) {
|
|
15
|
-
if (!walletAddress)
|
|
16
|
-
return {};
|
|
17
|
-
let chainId;
|
|
18
|
-
if (!chainIdInput) {
|
|
19
|
-
const chain = await data_1.Chain.getChain({
|
|
20
|
-
chainIdentifier: globalThis.globalEnvOption.chain,
|
|
21
|
-
});
|
|
22
|
-
chainId = await chain.getChainId();
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
chainId = chainIdInput;
|
|
26
|
-
}
|
|
27
|
-
let tokens = {}, lidoWithdrawals = {};
|
|
28
|
-
if (chainId === 'ALL') {
|
|
29
|
-
tokens = await (0, apis_1.getAllTokens)(walletAddress, onlyVerifiedTokens);
|
|
30
|
-
if (checkStatus) {
|
|
31
|
-
const ethMainnetLidoWithdrawals = await (0, apis_1.getLidoWithdrawals)('1', walletAddress);
|
|
32
|
-
const goerliLidoWithdrawals = await (0, apis_1.getLidoWithdrawals)('5', walletAddress);
|
|
33
|
-
lidoWithdrawals = {
|
|
34
|
-
...ethMainnetLidoWithdrawals,
|
|
35
|
-
...goerliLidoWithdrawals,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
tokens = await (0, apis_1.getTokens)(chainId, walletAddress, onlyVerifiedTokens);
|
|
41
|
-
if (checkStatus) {
|
|
42
|
-
lidoWithdrawals = await (0, apis_1.getLidoWithdrawals)(chainId, walletAddress);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return { ...lidoWithdrawals, ...tokens };
|
|
46
|
-
}
|
|
47
|
-
exports.getAssetsByWalletAddress = getAssetsByWalletAddress;
|
|
48
|
-
//# sourceMappingURL=AssetUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AssetUtils.js","sourceRoot":"","sources":["../../../src/utils/AssetUtils.ts"],"names":[],"mappings":";;;AAAA,kCAAqE;AACrE,kCAA+B;AAE/B;;;;;;;GAOG;AACI,KAAK,UAAU,wBAAwB,CAC5C,aAAa,EACb,YAAqB,EACrB,kBAAkB,GAAG,KAAK,EAC1B,WAAW,GAAG,KAAK;IAEnB,IAAI,CAAC,aAAa;QAAE,OAAO,EAAE,CAAA;IAE7B,IAAI,OAAO,CAAA;IACX,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,KAAK,GAAG,MAAM,YAAK,CAAC,QAAQ,CAAC;YACjC,eAAe,EAAG,UAAkB,CAAC,eAAe,CAAC,KAAK;SAC3D,CAA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