@funkit/core 1.0.13 → 1.0.15
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/common/constants.d.ts +615 -183
- 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 +68 -68
- 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,174 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.requestCheckoutRefuel = exports.getPaymasterDataForCheckoutSponsoredTransfer = exports.getCheckoutsByRecipientAddress = exports.getCheckoutsByFunWalletAddress = exports.getCheckoutByDepositAddress = exports.initializeCheckout = exports.getCheckoutQuote = void 0;
|
|
7
|
-
const big_js_1 = __importDefault(require("big.js"));
|
|
8
|
-
const viem_1 = require("viem");
|
|
9
|
-
const constants_1 = require("../common/constants");
|
|
10
|
-
const errors_1 = require("../errors");
|
|
11
|
-
const ApiUtils_1 = require("../utils/ApiUtils");
|
|
12
|
-
const CheckoutUtils_1 = require("../utils/CheckoutUtils");
|
|
13
|
-
/**
|
|
14
|
-
* Gets a checkout quote (estimation).
|
|
15
|
-
* @param fromChainId The ID of the chain where funds will be provided from.
|
|
16
|
-
* @param fromTokenAddress The asset to fund the checkout. This must be either a chain native token or an ERC-20, on the fromChainId.
|
|
17
|
-
* @param toChainId The ID of the chain where the checkout operation is to be performed.
|
|
18
|
-
* @param toTokenAddress The wanted asset for the checkout operation. This must be either a chain native token or an ERC-20, on the target chain.
|
|
19
|
-
* @param toTokenAmount The amount of wanted asset for the checkout operation in base units.
|
|
20
|
-
* @param expirationTimestampMs The amount of time (duration) from now before the checkout operation expires.
|
|
21
|
-
* @param apiKey A valid fun api key.
|
|
22
|
-
* @return {Promise<CheckoutCoreQuoteResponse>} The formatted quote object
|
|
23
|
-
*/
|
|
24
|
-
async function getCheckoutQuote({ fromChainId, fromTokenAddress, toChainId, toTokenAddress, toTokenAmount, expirationTimestampMs, sponsorInitialTransferGasLimit, recipientAddr, needsRefuel, apiKey, }) {
|
|
25
|
-
try {
|
|
26
|
-
const toDecimals = await (0, CheckoutUtils_1.getDecimals)({
|
|
27
|
-
chainId: toChainId,
|
|
28
|
-
tokenAddress: toTokenAddress,
|
|
29
|
-
});
|
|
30
|
-
const toMultipler = 10 ** toDecimals;
|
|
31
|
-
const toAmountBaseUnitBI = BigInt(Math.floor(toTokenAmount * toMultipler));
|
|
32
|
-
const queryParams = {
|
|
33
|
-
fromChainId,
|
|
34
|
-
fromTokenAddress,
|
|
35
|
-
toChainId,
|
|
36
|
-
toTokenAddress,
|
|
37
|
-
toAmountBaseUnit: toAmountBaseUnitBI.toString(),
|
|
38
|
-
// Only pass in recipientAddr if specified
|
|
39
|
-
...((0, viem_1.isAddress)(recipientAddr || '') ? { recipientAddr } : {}),
|
|
40
|
-
// Rounding nearest tenth second (instead of seconds) to better support backend quote caching feature
|
|
41
|
-
// Reference: https://vintage-heaven-3cd.notion.site/API-Gateway-Caching-and-Pre-Warming-System-Draft-ee7909d9b85f43c793ce7bd2607bec02?pvs=4
|
|
42
|
-
// Note: Rounding *down* instead of a regular round to safeguard against edge case of timing passing frontend range validation but failing backend range validation
|
|
43
|
-
checkoutExpirationTimestampSeconds: (0, CheckoutUtils_1.roundToNearestBottomTenth)(Math.round((Date.now() + expirationTimestampMs) / 1000)).toString(),
|
|
44
|
-
sponsorInitialTransferGasLimit,
|
|
45
|
-
refuel: needsRefuel.toString(),
|
|
46
|
-
};
|
|
47
|
-
const searchParams = new URLSearchParams(queryParams);
|
|
48
|
-
const url = `checkout/quote?${searchParams}`;
|
|
49
|
-
const quoteRes = (await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, url, apiKey));
|
|
50
|
-
const fromDecimals = await (0, CheckoutUtils_1.getDecimals)({
|
|
51
|
-
chainId: fromChainId,
|
|
52
|
-
tokenAddress: fromTokenAddress,
|
|
53
|
-
});
|
|
54
|
-
const fromMultipler = 10 ** fromDecimals;
|
|
55
|
-
// Format the response for frontend usage
|
|
56
|
-
return {
|
|
57
|
-
quoteId: quoteRes.quoteId,
|
|
58
|
-
fromTokenAddress: quoteRes.fromTokenAddress,
|
|
59
|
-
estFeesUsd: quoteRes.estFeesUsd,
|
|
60
|
-
estSubtotalUsd: quoteRes.estSubtotalUsd,
|
|
61
|
-
estTotalUsd: quoteRes.estTotalUsd,
|
|
62
|
-
estCheckoutTimeMs: quoteRes.estCheckoutTimeMs,
|
|
63
|
-
estTotalFromAmountBaseUnit: quoteRes.estTotalFromAmountBaseUnit,
|
|
64
|
-
estSubtotalFromAmountBaseUnit: quoteRes.estSubtotalFromAmountBaseUnit,
|
|
65
|
-
estFeesFromAmountBaseUnit: quoteRes.estFeesFromAmountBaseUnit,
|
|
66
|
-
// Added fields
|
|
67
|
-
estFeesFromAmount: new big_js_1.default(quoteRes.estFeesFromAmountBaseUnit)
|
|
68
|
-
.div(fromMultipler)
|
|
69
|
-
.toString(),
|
|
70
|
-
estSubtotalFromAmount: new big_js_1.default(quoteRes.estSubtotalFromAmountBaseUnit)
|
|
71
|
-
.div(fromMultipler)
|
|
72
|
-
.toString(),
|
|
73
|
-
estTotalFromAmount: new big_js_1.default(quoteRes.estTotalFromAmountBaseUnit)
|
|
74
|
-
.div(fromMultipler)
|
|
75
|
-
.toString(),
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
catch (err) {
|
|
79
|
-
throw new Error(`An error occured trying to generate a checkout quote: ${err.message}`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
exports.getCheckoutQuote = getCheckoutQuote;
|
|
83
|
-
/**
|
|
84
|
-
* Initializes a checkout
|
|
85
|
-
* @param userOp The checkout UserOp, signed.
|
|
86
|
-
* @param quoteId The quoteId specific to the checkout.
|
|
87
|
-
* @param apiKey A valid fun api key.
|
|
88
|
-
* @return {Address} The generated deposit address
|
|
89
|
-
*/
|
|
90
|
-
async function initializeCheckout({ userOp, quoteId, sourceOfFund, apiKey, clientMetadata, }) {
|
|
91
|
-
const body = {
|
|
92
|
-
...(userOp ? { userOp } : {}),
|
|
93
|
-
quoteId,
|
|
94
|
-
sourceOfFund,
|
|
95
|
-
salt: (0, CheckoutUtils_1.generateRandomCheckoutSalt)(),
|
|
96
|
-
clientMetadata,
|
|
97
|
-
};
|
|
98
|
-
const res = await (0, ApiUtils_1.sendPostRequest)(constants_1.API_URL, 'checkout', body, apiKey);
|
|
99
|
-
if (!res?.depositAddr) {
|
|
100
|
-
throw new errors_1.ResourceNotFoundError(errors_1.ErrorCode.CheckoutInitDepositAddrNotFound, 'Unable to initialize checkout', body, '', 'https://docs.fun.xyz');
|
|
101
|
-
}
|
|
102
|
-
return res.depositAddr;
|
|
103
|
-
}
|
|
104
|
-
exports.initializeCheckout = initializeCheckout;
|
|
105
|
-
/**
|
|
106
|
-
* Gets a checkout given a depositAddress
|
|
107
|
-
* @param depositAddress A unique deposit address associated with a backend checkout item.
|
|
108
|
-
* @param apiKey A valid fun api key.
|
|
109
|
-
* // TODO: Return interface
|
|
110
|
-
* @returns The checkout object if exists. Otherwise, null.
|
|
111
|
-
*/
|
|
112
|
-
async function getCheckoutByDepositAddress({ depositAddress, apiKey, }) {
|
|
113
|
-
try {
|
|
114
|
-
return await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, `checkout/${depositAddress}`, apiKey);
|
|
115
|
-
}
|
|
116
|
-
catch (err) {
|
|
117
|
-
if (err instanceof errors_1.ResourceNotFoundError) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
throw err;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.getCheckoutByDepositAddress = getCheckoutByDepositAddress;
|
|
124
|
-
/**
|
|
125
|
-
* Gets all checkouts associated with a funWallet
|
|
126
|
-
* @param funWalletAddress A funWallet address.
|
|
127
|
-
* @param apiKey A valid fun api key.
|
|
128
|
-
* @returns A list of checkout objects if exists. Otherwise, an empty array.
|
|
129
|
-
*/
|
|
130
|
-
async function getCheckoutsByFunWalletAddress({ funWalletAddress, apiKey, }) {
|
|
131
|
-
const url = `checkout/fun-wallet/${funWalletAddress}`;
|
|
132
|
-
const res = await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, url, apiKey);
|
|
133
|
-
return res || [];
|
|
134
|
-
}
|
|
135
|
-
exports.getCheckoutsByFunWalletAddress = getCheckoutsByFunWalletAddress;
|
|
136
|
-
/**
|
|
137
|
-
* Gets all checkouts associated with a recipient address
|
|
138
|
-
* @param recipientAddress A wallet address.
|
|
139
|
-
* @param apiKey A valid fun api key.
|
|
140
|
-
* @returns A list of checkout objects if exists. Otherwise, an empty array.
|
|
141
|
-
*/
|
|
142
|
-
async function getCheckoutsByRecipientAddress({ recipientAddress, apiKey, }) {
|
|
143
|
-
const url = `checkout/recipient/${recipientAddress}`;
|
|
144
|
-
const res = await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, url, apiKey);
|
|
145
|
-
return res || [];
|
|
146
|
-
}
|
|
147
|
-
exports.getCheckoutsByRecipientAddress = getCheckoutsByRecipientAddress;
|
|
148
|
-
async function getPaymasterDataForCheckoutSponsoredTransfer({ depositAddress, transferUserOp, apiKey, }) {
|
|
149
|
-
const body = {
|
|
150
|
-
depositAddress,
|
|
151
|
-
userOp: transferUserOp,
|
|
152
|
-
};
|
|
153
|
-
const res = await (0, ApiUtils_1.sendPostRequest)(constants_1.API_URL, 'checkout/sponsor-transfer', body, apiKey);
|
|
154
|
-
if (!res) {
|
|
155
|
-
// TODO: Better error handling
|
|
156
|
-
throw new Error('Unable to get sponsorship information');
|
|
157
|
-
}
|
|
158
|
-
return res;
|
|
159
|
-
}
|
|
160
|
-
exports.getPaymasterDataForCheckoutSponsoredTransfer = getPaymasterDataForCheckoutSponsoredTransfer;
|
|
161
|
-
async function requestCheckoutRefuel({ signedTxData, depositAddress, apiKey, }) {
|
|
162
|
-
const body = {
|
|
163
|
-
depositAddr: depositAddress,
|
|
164
|
-
signedTx: signedTxData,
|
|
165
|
-
};
|
|
166
|
-
const res = await (0, ApiUtils_1.sendPostRequest)(constants_1.API_URL, 'checkout/refuel', body, apiKey);
|
|
167
|
-
if (!res) {
|
|
168
|
-
// TODO: Better error handling
|
|
169
|
-
throw new Error('Unable to perform refuelling');
|
|
170
|
-
}
|
|
171
|
-
return res;
|
|
172
|
-
}
|
|
173
|
-
exports.requestCheckoutRefuel = requestCheckoutRefuel;
|
|
174
|
-
//# sourceMappingURL=CheckoutApis.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CheckoutApis.js","sourceRoot":"","sources":["../../../src/apis/CheckoutApis.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAwB;AACxB,+BAAyC;AAEzC,mDAA6C;AAC7C,sCAA4D;AAC5D,gDAAmE;AACnE,0DAI+B;AAkB/B;;;;;;;;;;GAUG;AACI,KAAK,UAAU,gBAAgB,CAAC,EACrC,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,8BAA8B,EAC9B,aAAa,EACb,WAAW,EACX,MAAM,GACkB;IACxB,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,IAAA,2BAAW,EAAC;YACnC,OAAO,EAAE,SAAS;YAClB,YAAY,EAAE,cAAc;SAC7B,CAAC,CAAA;QACF,MAAM,WAAW,GAAG,EAAE,IAAI,UAAU,CAAA;QACpC,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,WAAW,CAAC,CAAC,CAAA;QAE1E,MAAM,WAAW,GAAG;YAClB,WAAW;YACX,gBAAgB;YAChB,SAAS;YACT,cAAc;YACd,gBAAgB,EAAE,kBAAkB,CAAC,QAAQ,EAAE;YAC/C,0CAA0C;YAC1C,GAAG,CAAC,IAAA,gBAAS,EAAC,aA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AAqB,CAAC,EAC1C,YAAY,EACZ,cAAc,EACd,MAAM,GAC0B;IAChC,MAAM,IAAI,GAAG;QACX,WAAW,EAAE,cAAc;QAC3B,QAAQ,EAAE,YAAY;KACW,CAAA;IACnC,MAAM,GAAG,GAAG,MAAM,IAAA,0BAAe,EAAC,mBAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;IAC3E,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,8BAA8B;QAC9B,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;IACjD,CAAC;IACD,OAAO,GAAoC,CAAA;AAC7C,CAAC;AAfD,sDAeC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const sendAsset: (token: string, chain: string, walletAddress: string) => Promise<any>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendAsset = void 0;
|
|
4
|
-
const common_1 = require("../common");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
const sendAsset = async function (token, chain, walletAddress) {
|
|
7
|
-
return await (0, utils_1.sendGetRequest)(common_1.FUN_FAUCET_URL, `get-faucet?token=${token}&testnet=${chain}&addr=${walletAddress}`);
|
|
8
|
-
};
|
|
9
|
-
exports.sendAsset = sendAsset;
|
|
10
|
-
//# sourceMappingURL=FaucetApis.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FaucetApis.js","sourceRoot":"","sources":["../../../src/apis/FaucetApis.ts"],"names":[],"mappings":";;;AAAA,sCAA0C;AAC1C,oCAAyC;AAElC,MAAM,SAAS,GAAG,KAAK,WAC5B,KAAa,EACb,KAAa,EACb,aAAqB;IAErB,OAAO,MAAM,IAAA,sBAAc,EACzB,uBAAc,EACd,oBAAoB,KAAK,YAAY,KAAK,SAAS,aAAa,EAAE,CACnE,CAAA;AACH,CAAC,CAAA;AATY,QAAA,SAAS,aASrB"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param authToken The authentication token to send the asset from.
|
|
3
|
-
* @param type The type of the integration to send the asset from.
|
|
4
|
-
* @return https://docs.meshconnect.com/reference/post_api-v1-holdings-get
|
|
5
|
-
*/
|
|
6
|
-
export declare function meshGetCryptocurrencyHoldings(authToken: string, type: string, apiKey?: string): Promise<any>;
|
|
7
|
-
/**
|
|
8
|
-
* @return https://docs.meshconnect.com/reference/get_api-v1-transfers-managed-integrations
|
|
9
|
-
*/
|
|
10
|
-
export declare function meshGetTransferIntegrations(apiKey?: string): Promise<any>;
|
|
11
|
-
/**
|
|
12
|
-
* @param userId A unique Id representing the end user. Typically this will be a user Id from the
|
|
13
|
-
client application. Personally identifiable information, such as an email address or phone number,
|
|
14
|
-
should not be used. 50 characters length maximum.
|
|
15
|
-
* @param integrationId A unique identifier representing a specific integration obtained from the list of available integrations.
|
|
16
|
-
* @param restrictMultipleAccounts The final screen of Link allows users to “continue” back to your app or “Link another account.”
|
|
17
|
-
If this param is present then this button will be hidden.
|
|
18
|
-
* @param transferOptions Encapsulates transaction-related parameters, including destination addresses and the amount to transfer in fiat currency.
|
|
19
|
-
* @return https://docs.meshconnect.com/reference/post_api-v1-linktoken
|
|
20
|
-
*/
|
|
21
|
-
export declare function meshGetLinkToken(userId: string, integrationId?: string | null, restrictMultipleAccounts?: boolean, transferOptions?: any | null, apiKey?: string): Promise<any>;
|
|
22
|
-
/**
|
|
23
|
-
* @param fromAuthToken The authentication token to send the asset from.
|
|
24
|
-
* @param fromType The type of the integration to send the asset from.
|
|
25
|
-
* @param toAuthToken The authentication token of the target integration. Can be used alternatively to the address in the ToAddress field. If used, toType should also be provided.
|
|
26
|
-
* @param toType The type of the target integration to send assets to. Used along with the toAuthToken alternatively to ToAddress.
|
|
27
|
-
* @param networkId The network to send the asset over. This is generated by Mesh, it isn't a chainId or chain name.
|
|
28
|
-
* @param symbol The symbol of the digital asset to send.
|
|
29
|
-
* @param toAddress The target address to send the asset to.
|
|
30
|
-
* @param amount The amount to send, in crypto.
|
|
31
|
-
* @param amountInFiat The amount to send, in fiat currency. Can be used alternatively to Amount.
|
|
32
|
-
* @param fiatCurrency Fiat currency that is to get corresponding converted fiat values of transfer and fee amounts. If not provided, defaults to USD.
|
|
33
|
-
* @returns https://docs.meshconnect.com/reference/post_api-v1-transfers-managed-preview
|
|
34
|
-
*/
|
|
35
|
-
export declare function meshPreviewTransfer(fromAuthToken: string, fromType: string, toAuthToken?: string | null, toType?: string | null, networkId?: string, symbol?: string | null, toAddress?: string | null, amount?: string | null, amountInFiat?: string | null, fiatCurrency?: string | null, apiKey?: string): Promise<any>;
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
* @param fromAuthToken The authentication token to send the asset from.
|
|
39
|
-
* @param fromType The type of the integration to send the asset from.
|
|
40
|
-
* @param previewId The preview ID of the transfer to execute.
|
|
41
|
-
* @param mfaCode Multi-factor auth code that should be provided if the status of the transfer was MfaRequired.
|
|
42
|
-
* @returns https://docs.meshconnect.com/reference/post_api-v1-transfers-managed-execute
|
|
43
|
-
*/
|
|
44
|
-
export declare function meshExecuteTransfer(fromAuthToken: string, fromType: string, previewId: string, mfaCode?: string | null, apiKey?: string): Promise<any>;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.meshExecuteTransfer = exports.meshPreviewTransfer = exports.meshGetLinkToken = exports.meshGetTransferIntegrations = exports.meshGetCryptocurrencyHoldings = void 0;
|
|
4
|
-
const constants_1 = require("../common/constants");
|
|
5
|
-
const ApiUtils_1 = require("../utils/ApiUtils");
|
|
6
|
-
/**
|
|
7
|
-
* @param authToken The authentication token to send the asset from.
|
|
8
|
-
* @param type The type of the integration to send the asset from.
|
|
9
|
-
* @return https://docs.meshconnect.com/reference/post_api-v1-holdings-get
|
|
10
|
-
*/
|
|
11
|
-
async function meshGetCryptocurrencyHoldings(authToken, type, apiKey) {
|
|
12
|
-
const res = await (0, ApiUtils_1.sendPostRequest)(constants_1.API_URL, 'mesh/holdings/get', { authToken, type }, apiKey);
|
|
13
|
-
return res;
|
|
14
|
-
}
|
|
15
|
-
exports.meshGetCryptocurrencyHoldings = meshGetCryptocurrencyHoldings;
|
|
16
|
-
/**
|
|
17
|
-
* @return https://docs.meshconnect.com/reference/get_api-v1-transfers-managed-integrations
|
|
18
|
-
*/
|
|
19
|
-
async function meshGetTransferIntegrations(apiKey) {
|
|
20
|
-
const res = await (0, ApiUtils_1.sendGetRequest)(constants_1.API_URL, 'mesh/transfers/managed/integrations', apiKey);
|
|
21
|
-
return res;
|
|
22
|
-
}
|
|
23
|
-
exports.meshGetTransferIntegrations = meshGetTransferIntegrations;
|
|
24
|
-
/**
|
|
25
|
-
* @param userId A unique Id representing the end user. Typically this will be a user Id from the
|
|
26
|
-
client application. Personally identifiable information, such as an email address or phone number,
|
|
27
|
-
should not be used. 50 characters length maximum.
|
|
28
|
-
* @param integrationId A unique identifier representing a specific integration obtained from the list of available integrations.
|
|
29
|
-
* @param restrictMultipleAccounts The final screen of Link allows users to “continue” back to your app or “Link another account.”
|
|
30
|
-
If this param is present then this button will be hidden.
|
|
31
|
-
* @param transferOptions Encapsulates transaction-related parameters, including destination addresses and the amount to transfer in fiat currency.
|
|
32
|
-
* @return https://docs.meshconnect.com/reference/post_api-v1-linktoken
|
|
33
|
-
*/
|
|
34
|
-
async function meshGetLinkToken(userId, integrationId, restrictMultipleAccounts, transferOptions, apiKey) {
|
|
35
|
-
let body = { userId };
|
|
36
|
-
if (integrationId) {
|
|
37
|
-
body = { ...body, integrationId };
|
|
38
|
-
}
|
|
39
|
-
if (restrictMultipleAccounts) {
|
|
40
|
-
body = { ...body, restrictMultipleAccounts };
|
|
41
|
-
}
|
|
42
|
-
if (transferOptions) {
|
|
43
|
-
body = { ...body, transferOptions };
|
|
44
|
-
}
|
|
45
|
-
const res = await (0, ApiUtils_1.sendPostRequest)(constants_1.API_URL, 'mesh/linktoken', body, apiKey);
|
|
46
|
-
return res;
|
|
47
|
-
}
|
|
48
|
-
exports.meshGetLinkToken = meshGetLinkToken;
|
|
49
|
-
/**
|
|
50
|
-
* @param fromAuthToken The authentication token to send the asset from.
|
|
51
|
-
* @param fromType The type of the integration to send the asset from.
|
|
52
|
-
* @param toAuthToken The authentication token of the target integration. Can be used alternatively to the address in the ToAddress field. If used, toType should also be provided.
|
|
53
|
-
* @param toType The type of the target integration to send assets to. Used along with the toAuthToken alternatively to ToAddress.
|
|
54
|
-
* @param networkId The network to send the asset over. This is generated by Mesh, it isn't a chainId or chain name.
|
|
55
|
-
* @param symbol The symbol of the digital asset to send.
|
|
56
|
-
* @param toAddress The target address to send the asset to.
|
|
57
|
-
* @param amount The amount to send, in crypto.
|
|
58
|
-
* @param amountInFiat The amount to send, in fiat currency. Can be used alternatively to Amount.
|
|
59
|
-
* @param fiatCurrency Fiat currency that is to get corresponding converted fiat values of transfer and fee amounts. If not provided, defaults to USD.
|
|
60
|
-
* @returns https://docs.meshconnect.com/reference/post_api-v1-transfers-managed-preview
|
|
61
|
-
*/
|
|
62
|
-
async function meshPreviewTransfer(fromAuthToken, fromType, toAuthToken, toType, networkId, symbol, toAddress, amount, amountInFiat, fiatCurrency, apiKey) {
|
|
63
|
-
let body = { fromAuthToken, fromType };
|
|
64
|
-
if (toAuthToken) {
|
|
65
|
-
body = { ...body, toAuthToken };
|
|
66
|
-
}
|
|
67
|
-
if (toType) {
|
|
68
|
-
body = { ...body, toType };
|
|
69
|
-
}
|
|
70
|
-
if (networkId) {
|
|
71
|
-
body = { ...body, networkId };
|
|
72
|
-
}
|
|
73
|
-
if (symbol) {
|
|
74
|
-
body = { ...body, symbol };
|
|
75
|
-
}
|
|
76
|
-
if (toAddress) {
|
|
77
|
-
body = { ...body, toAddress };
|
|
78
|
-
}
|
|
79
|
-
if (amount) {
|
|
80
|
-
body = { ...body, amount };
|
|
81
|
-
}
|
|
82
|
-
if (amountInFiat) {
|
|
83
|
-
body = { ...body, amountInFiat };
|
|
84
|
-
}
|
|
85
|
-
if (fiatCurrency) {
|
|
86
|
-
body = { ...body, fiatCurrency };
|
|
87
|
-
}
|
|
88
|
-
const res = await (0, ApiUtils_1.sendPostRequest)(constants_1.API_URL, 'mesh/transfers/managed/preview', body, apiKey, { maxAttempts: 1 });
|
|
89
|
-
return res;
|
|
90
|
-
}
|
|
91
|
-
exports.meshPreviewTransfer = meshPreviewTransfer;
|
|
92
|
-
/**
|
|
93
|
-
*
|
|
94
|
-
* @param fromAuthToken The authentication token to send the asset from.
|
|
95
|
-
* @param fromType The type of the integration to send the asset from.
|
|
96
|
-
* @param previewId The preview ID of the transfer to execute.
|
|
97
|
-
* @param mfaCode Multi-factor auth code that should be provided if the status of the transfer was MfaRequired.
|
|
98
|
-
* @returns https://docs.meshconnect.com/reference/post_api-v1-transfers-managed-execute
|
|
99
|
-
*/
|
|
100
|
-
async function meshExecuteTransfer(fromAuthToken, fromType, previewId, mfaCode, apiKey) {
|
|
101
|
-
let body = { fromAuthToken, fromType, previewId };
|
|
102
|
-
if (mfaCode) {
|
|
103
|
-
body = { ...body, mfaCode };
|
|
104
|
-
}
|
|
105
|
-
const res = await (0, ApiUtils_1.sendPostRequest)(constants_1.API_URL, 'mesh/transfers/managed/execute', body, apiKey);
|
|
106
|
-
return res;
|
|
107
|
-
}
|
|
108
|
-
exports.meshExecuteTransfer = meshExecuteTransfer;
|
|
109
|
-
//# sourceMappingURL=MeshApis.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MeshApis.js","sourceRoot":"","sources":["../../../src/apis/MeshApis.ts"],"names":[],"mappings":";;;AAAA,mDAA6C;AAC7C,gDAAmE;AAEnE;;;;GAIG;AACI,KAAK,UAAU,6BAA6B,CACjD,SAAiB,EACjB,IAAY,EACZ,MAAe;IAEf,MAAM,GAAG,GAAG,MAAM,IAAA,0BAAe,EAC/B,mBAAO,EACP,m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,CAAA;IAC7B,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,IAAA,0BAAe,EAC/B,mBAAO,EACP,gCAAgC,EAChC,IAAI,EACJ,MAAM,CACP,CAAA;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAlBD,kDAkBC"}
|
|
@@ -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,k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,GAAG,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;SAC3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