@multiversx/sdk-dapp-liquidity 1.1.0-alpha.9 → 1.1.1-alpha.1
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/README.md +1 -2
- package/api/checkAccount.d.ts +9 -0
- package/api/checkAccount.js +22 -0
- package/api/checkAccount.mjs +21 -0
- package/api/getChains.d.ts +3 -1
- package/api/getChains.js +10 -4
- package/api/getChains.mjs +10 -4
- package/api/getTokens.d.ts +3 -1
- package/api/getTokens.js +13 -4
- package/api/getTokens.mjs +13 -4
- package/api/getTokensBalances.d.ts +2 -1
- package/api/getTokensBalances.js +9 -4
- package/api/getTokensBalances.mjs +9 -4
- package/api/getTransactions.d.ts +2 -1
- package/api/getTransactions.js +9 -4
- package/api/getTransactions.mjs +9 -4
- package/api/index.d.ts +2 -0
- package/api/index.js +4 -0
- package/api/index.mjs +4 -0
- package/api/linkAccount.d.ts +10 -0
- package/api/linkAccount.js +32 -0
- package/api/linkAccount.mjs +31 -0
- package/api/tests/getChains.spec.js +10 -3
- package/api/tests/getChains.spec.mjs +10 -3
- package/api/tests/getTokens.spec.js +16 -5
- package/api/tests/getTokens.spec.mjs +16 -5
- package/api/tests/getTransactions.spec.js +16 -10
- package/api/tests/getTransactions.spec.mjs +16 -10
- package/dto/Chain.dto.d.ts +4 -1
- package/dto/CheckAccount.dto.d.ts +4 -0
- package/dto/CheckAccount.dto.js +2 -0
- package/dto/CheckAccount.dto.mjs +1 -0
- package/dto/Token.dto.d.ts +6 -2
- package/dto/Transaction.dto.d.ts +1 -0
- package/getConnections-BBxOUh4c.mjs +50 -0
- package/getConnections-DufiP2Qa.js +50 -0
- package/index.js +8 -6
- package/index.mjs +8 -6
- package/package.json +5 -5
- package/reactjs/components/AmountInput/AmountInput.d.ts +1 -1
- package/reactjs/components/BridgeForm/BridgeForm.d.ts +8 -2
- package/reactjs/components/BridgeForm/BridgeForm.js +58 -710
- package/reactjs/components/BridgeForm/BridgeForm.mjs +60 -712
- package/reactjs/components/BridgeForm/Deposit.d.ts +23 -0
- package/reactjs/components/BridgeForm/Deposit.js +848 -0
- package/reactjs/components/BridgeForm/Deposit.mjs +847 -0
- package/reactjs/components/BridgeForm/Transfer.d.ts +23 -0
- package/reactjs/components/BridgeForm/Transfer.js +727 -0
- package/reactjs/components/BridgeForm/Transfer.mjs +726 -0
- package/reactjs/components/BridgeHistory/BridgeHistory.js +16 -7
- package/reactjs/components/BridgeHistory/BridgeHistory.mjs +16 -7
- package/reactjs/components/Connect/BridgeAccountDisplay.js +59 -4
- package/reactjs/components/Connect/BridgeAccountDisplay.mjs +59 -4
- package/reactjs/components/Connect/BridgeConnectButton.js +1 -1
- package/reactjs/components/Connect/BridgeConnectButton.mjs +1 -1
- package/reactjs/components/Connect/MvxConnectButton.d.ts +2 -4
- package/reactjs/components/Connect/MvxConnectButton.js +2 -2
- package/reactjs/components/Connect/MvxConnectButton.mjs +2 -2
- package/reactjs/components/ToggleDirection/ToggleDirection.d.ts +3 -0
- package/reactjs/components/ToggleDirection/ToggleDirection.js +23 -0
- package/reactjs/components/ToggleDirection/ToggleDirection.mjs +22 -0
- package/reactjs/components/TokenSelector/TokenSelector.d.ts +2 -1
- package/reactjs/components/TokenSelector/TokenSelector.js +12 -4
- package/reactjs/components/TokenSelector/TokenSelector.mjs +12 -4
- package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.d.ts +2 -1
- package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.js +8 -2
- package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.mjs +8 -2
- package/reactjs/components/TokenSelector/components/ChainSelect/components/ChainOptionLabel.d.ts +1 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/components/ChainOptionLabel.js +2 -2
- package/reactjs/components/TokenSelector/components/ChainSelect/components/ChainOptionLabel.mjs +2 -2
- package/reactjs/components/TokenSelector/components/ChainSelect/components/SelectedChainOption.js +2 -2
- package/reactjs/components/TokenSelector/components/ChainSelect/components/SelectedChainOption.mjs +2 -2
- package/reactjs/components/TokenSelector/components/ChainSelect/types/chainSelectOption.d.ts +1 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/types/partialChainOption.d.ts +1 -0
- package/reactjs/components/TokenSelector/components/SelectContent.d.ts +2 -1
- package/reactjs/components/TokenSelector/components/SelectContent.js +4 -1
- package/reactjs/components/TokenSelector/components/SelectContent.mjs +4 -1
- package/reactjs/components/TokenSelector/components/TokenIcon.js +2 -2
- package/reactjs/components/TokenSelector/components/TokenIcon.mjs +2 -2
- package/reactjs/components/TokenSelector/components/TokenItem.js +5 -10
- package/reactjs/components/TokenSelector/components/TokenItem.mjs +5 -10
- package/reactjs/components/TokenSelector/components/TokenList.js +1 -1
- package/reactjs/components/TokenSelector/components/TokenList.mjs +1 -1
- package/reactjs/context/Web3AppProvider.d.ts +12 -1
- package/reactjs/context/Web3AppProvider.js +15 -3
- package/reactjs/context/Web3AppProvider.mjs +15 -3
- package/reactjs/hooks/index.js +1 -1
- package/reactjs/hooks/index.mjs +2 -2
- package/reactjs/hooks/useBalances.d.ts +2 -3
- package/reactjs/hooks/useBalances.js +51 -4
- package/reactjs/hooks/useBalances.mjs +51 -4
- package/reactjs/hooks/useBridgeFormik.d.ts +4 -4
- package/reactjs/hooks/useBridgeFormik.js +38 -64
- package/reactjs/hooks/useBridgeFormik.mjs +39 -65
- package/reactjs/hooks/useFetchBridgeData.d.ts +12 -5
- package/reactjs/hooks/useFetchBridgeData.js +0 -2
- package/reactjs/hooks/useFetchBridgeData.mjs +0 -2
- package/reactjs/hooks/useFetchTokens.d.ts +13 -6
- package/reactjs/hooks/useFetchTokens.js +19 -15
- package/reactjs/hooks/useFetchTokens.mjs +19 -15
- package/reactjs/hooks/useGenericSignMessage.d.ts +3 -0
- package/reactjs/hooks/useGenericSignMessage.js +42 -0
- package/reactjs/hooks/useGenericSignMessage.mjs +41 -0
- package/reactjs/hooks/useResolveTokenChain.js +1 -1
- package/reactjs/hooks/useResolveTokenChain.mjs +1 -1
- package/reactjs/hooks/useSignTransaction.d.ts +94 -67
- package/reactjs/hooks/useSignTransaction.js +46 -4
- package/reactjs/hooks/useSignTransaction.mjs +46 -4
- package/reactjs/index.js +4 -6
- package/reactjs/index.mjs +4 -6
- package/reactjs/init/init.d.ts +219 -0
- package/reactjs/init/init.js +2 -5
- package/reactjs/init/init.mjs +2 -5
- package/reactjs/queries/index.d.ts +1 -2
- package/reactjs/queries/index.js +3 -5
- package/reactjs/queries/index.mjs +3 -5
- package/reactjs/queries/useCheckAccount.query.d.ts +3 -0
- package/reactjs/queries/useCheckAccount.query.js +50 -0
- package/reactjs/queries/useCheckAccount.query.mjs +49 -0
- package/reactjs/queries/useGetAllTokens.query.d.ts +4 -1
- package/reactjs/queries/useGetAllTokens.query.js +8 -3
- package/reactjs/queries/useGetAllTokens.query.mjs +8 -3
- package/reactjs/queries/useGetChains.query.js +6 -2
- package/reactjs/queries/useGetChains.query.mjs +6 -2
- package/reactjs/queries/useGetHistory.query.js +6 -2
- package/reactjs/queries/useGetHistory.query.mjs +6 -2
- package/reactjs/queries/useGetMvxTokensBalances.query.d.ts +6 -2
- package/reactjs/queries/useGetMvxTokensBalances.query.js +15 -4
- package/reactjs/queries/useGetMvxTokensBalances.query.mjs +15 -4
- package/reactjs/queries/{useGetEvmTokensBalances.query.d.ts → useGetNonMvxTokensBalances.query.d.ts} +7 -3
- package/reactjs/queries/{useGetEvmTokensBalances.query.js → useGetNonMvxTokensBalances.query.js} +17 -11
- package/reactjs/queries/{useGetEvmTokensBalances.query.mjs → useGetNonMvxTokensBalances.query.mjs} +17 -11
- package/reactjs/queries/useLinkAccount.mutation.d.ts +6 -0
- package/reactjs/queries/useLinkAccount.mutation.js +19 -0
- package/reactjs/queries/useLinkAccount.mutation.mjs +18 -0
- package/reactjs/reexports.d.ts +2 -1
- package/reactjs/utils/getInitialTokens.d.ts +4 -1
- package/reactjs/utils/getInitialTokens.js +3 -3
- package/reactjs/utils/getInitialTokens.mjs +3 -3
- package/style.css +13 -0
- package/types/chainType.d.ts +6 -0
- package/types/chainType.js +11 -0
- package/types/chainType.mjs +10 -0
- package/types/linkAccount.d.ts +6 -0
- package/types/linkAccount.js +2 -0
- package/types/linkAccount.mjs +1 -0
- package/types/providerType.d.ts +1 -1
- package/types/providerType.js +1 -1
- package/types/providerType.mjs +1 -1
- package/types/transaction.d.ts +17 -1
- package/types/utxo.d.ts +11 -0
- package/types/utxo.js +2 -0
- package/types/utxo.mjs +1 -0
- package/reactjs/hooks/useFiatData.d.ts +0 -29
- package/reactjs/hooks/useFiatData.js +0 -68
- package/reactjs/hooks/useFiatData.mjs +0 -67
- package/reactjs/queries/useGetTokens.query.d.ts +0 -3
- package/reactjs/queries/useGetTokens.query.js +0 -34
- package/reactjs/queries/useGetTokens.query.mjs +0 -33
- package/useBalances-FCILRNAy.js +0 -196
- package/useBalances-rRug6Uza.mjs +0 -196
package/README.md
CHANGED
|
@@ -161,12 +161,11 @@ const App = () => {
|
|
|
161
161
|
|
|
162
162
|
return (
|
|
163
163
|
// Wrap your app with Web3AppProvider to enable multi-chain connections
|
|
164
|
-
<Web3AppProvider appKit={provider.appKit} config={provider.config} options={provider.options}>
|
|
164
|
+
<Web3AppProvider appKit={provider.appKit} config={provider.config} options={provider.options} nativeAuthToken={nativeAuthToken}>
|
|
165
165
|
<BridgeForm
|
|
166
166
|
mvxChainId={"44"}
|
|
167
167
|
mvxAddress={mvxAccount?.address}
|
|
168
168
|
username={mvxAccount?.username}
|
|
169
|
-
nativeAuthToken={nativeAuthToken}
|
|
170
169
|
callbackRoute={"/deposit"}
|
|
171
170
|
showHistory={showHistory}
|
|
172
171
|
onSuccessfullySentTransaction={(txHashes) => {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CheckAccountDto } from '../dto/CheckAccount.dto';
|
|
2
|
+
import { AxiosResponse } from 'axios';
|
|
3
|
+
|
|
4
|
+
export declare function checkAccount({ url, walletAddress, chainId, nativeAuthToken }: {
|
|
5
|
+
url: string;
|
|
6
|
+
walletAddress: string;
|
|
7
|
+
chainId: string;
|
|
8
|
+
nativeAuthToken: string;
|
|
9
|
+
}): Promise<AxiosResponse<CheckAccountDto>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const axios = require("axios");
|
|
5
|
+
async function checkAccount({
|
|
6
|
+
url,
|
|
7
|
+
walletAddress,
|
|
8
|
+
chainId,
|
|
9
|
+
nativeAuthToken
|
|
10
|
+
}) {
|
|
11
|
+
const config = {
|
|
12
|
+
baseURL: url,
|
|
13
|
+
headers: {
|
|
14
|
+
Authorization: `Bearer ${nativeAuthToken}`
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
return await axios.get(
|
|
18
|
+
`/user/checkAccount?walletAddress=${walletAddress}&chainId=${chainId}`,
|
|
19
|
+
config
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
exports.checkAccount = checkAccount;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
async function checkAccount({
|
|
3
|
+
url,
|
|
4
|
+
walletAddress,
|
|
5
|
+
chainId,
|
|
6
|
+
nativeAuthToken
|
|
7
|
+
}) {
|
|
8
|
+
const config = {
|
|
9
|
+
baseURL: url,
|
|
10
|
+
headers: {
|
|
11
|
+
Authorization: `Bearer ${nativeAuthToken}`
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
return await axios.get(
|
|
15
|
+
`/user/checkAccount?walletAddress=${walletAddress}&chainId=${chainId}`,
|
|
16
|
+
config
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
checkAccount
|
|
21
|
+
};
|
package/api/getChains.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ChainDTO } from '../dto/Chain.dto';
|
|
2
2
|
import { AxiosResponse } from 'axios';
|
|
3
3
|
|
|
4
|
-
export declare function getChains({ url }: {
|
|
4
|
+
export declare function getChains({ url, nativeAuthToken, bridgeOnly }: {
|
|
5
5
|
url: string;
|
|
6
|
+
nativeAuthToken: string;
|
|
7
|
+
bridgeOnly: boolean;
|
|
6
8
|
}): Promise<AxiosResponse<ChainDTO[]>>;
|
package/api/getChains.js
CHANGED
|
@@ -3,10 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
const axios = require("axios");
|
|
5
5
|
async function getChains({
|
|
6
|
-
url
|
|
6
|
+
url,
|
|
7
|
+
nativeAuthToken,
|
|
8
|
+
bridgeOnly
|
|
7
9
|
}) {
|
|
8
|
-
|
|
9
|
-
baseURL: url
|
|
10
|
-
|
|
10
|
+
const config = {
|
|
11
|
+
baseURL: url,
|
|
12
|
+
headers: {
|
|
13
|
+
Authorization: `Bearer ${nativeAuthToken}`
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
return await axios.get(`/chains?isBridge=${bridgeOnly}`, config);
|
|
11
17
|
}
|
|
12
18
|
exports.getChains = getChains;
|
package/api/getChains.mjs
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
async function getChains({
|
|
3
|
-
url
|
|
3
|
+
url,
|
|
4
|
+
nativeAuthToken,
|
|
5
|
+
bridgeOnly
|
|
4
6
|
}) {
|
|
5
|
-
|
|
6
|
-
baseURL: url
|
|
7
|
-
|
|
7
|
+
const config = {
|
|
8
|
+
baseURL: url,
|
|
9
|
+
headers: {
|
|
10
|
+
Authorization: `Bearer ${nativeAuthToken}`
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
return await axios.get(`/chains?isBridge=${bridgeOnly}`, config);
|
|
8
14
|
}
|
|
9
15
|
export {
|
|
10
16
|
getChains
|
package/api/getTokens.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { TokenType } from '../types/token';
|
|
2
2
|
import { AxiosResponse } from 'axios';
|
|
3
3
|
|
|
4
|
-
export declare function getTokens({ url, chainId }: {
|
|
4
|
+
export declare function getTokens({ url, chainId, nativeAuthToken, bridgeOnly }: {
|
|
5
5
|
url: string;
|
|
6
6
|
chainId?: number;
|
|
7
|
+
nativeAuthToken: string;
|
|
8
|
+
bridgeOnly: boolean;
|
|
7
9
|
}): Promise<AxiosResponse<TokenType[]>>;
|
package/api/getTokens.js
CHANGED
|
@@ -4,11 +4,20 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
4
4
|
const axios = require("axios");
|
|
5
5
|
async function getTokens({
|
|
6
6
|
url,
|
|
7
|
-
chainId
|
|
7
|
+
chainId,
|
|
8
|
+
nativeAuthToken,
|
|
9
|
+
bridgeOnly
|
|
8
10
|
}) {
|
|
11
|
+
const config = {
|
|
12
|
+
baseURL: url,
|
|
13
|
+
headers: {
|
|
14
|
+
Authorization: `Bearer ${nativeAuthToken}`
|
|
15
|
+
}
|
|
16
|
+
};
|
|
9
17
|
const endpoint = chainId ? `/tokens/${chainId}` : "/tokens";
|
|
10
|
-
return await axios.get(
|
|
11
|
-
|
|
12
|
-
|
|
18
|
+
return await axios.get(
|
|
19
|
+
`${endpoint}?isBridge=${bridgeOnly}`,
|
|
20
|
+
config
|
|
21
|
+
);
|
|
13
22
|
}
|
|
14
23
|
exports.getTokens = getTokens;
|
package/api/getTokens.mjs
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
async function getTokens({
|
|
3
3
|
url,
|
|
4
|
-
chainId
|
|
4
|
+
chainId,
|
|
5
|
+
nativeAuthToken,
|
|
6
|
+
bridgeOnly
|
|
5
7
|
}) {
|
|
8
|
+
const config = {
|
|
9
|
+
baseURL: url,
|
|
10
|
+
headers: {
|
|
11
|
+
Authorization: `Bearer ${nativeAuthToken}`
|
|
12
|
+
}
|
|
13
|
+
};
|
|
6
14
|
const endpoint = chainId ? `/tokens/${chainId}` : "/tokens";
|
|
7
|
-
return await axios.get(
|
|
8
|
-
|
|
9
|
-
|
|
15
|
+
return await axios.get(
|
|
16
|
+
`${endpoint}?isBridge=${bridgeOnly}`,
|
|
17
|
+
config
|
|
18
|
+
);
|
|
10
19
|
}
|
|
11
20
|
export {
|
|
12
21
|
getTokens
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { TokenBalanceDTO } from '../dto/TokenBalance.dto';
|
|
2
2
|
import { AxiosResponse } from 'axios';
|
|
3
3
|
|
|
4
|
-
export declare function getTokensBalances({ url, userAddress, chainId }: {
|
|
4
|
+
export declare function getTokensBalances({ url, userAddress, chainId, nativeAuthToken }: {
|
|
5
5
|
url: string;
|
|
6
6
|
userAddress: string;
|
|
7
7
|
chainId: string;
|
|
8
|
+
nativeAuthToken: string;
|
|
8
9
|
}): Promise<AxiosResponse<TokenBalanceDTO[]>>;
|
package/api/getTokensBalances.js
CHANGED
|
@@ -5,13 +5,18 @@ const axios = require("axios");
|
|
|
5
5
|
async function getTokensBalances({
|
|
6
6
|
url,
|
|
7
7
|
userAddress,
|
|
8
|
-
chainId
|
|
8
|
+
chainId,
|
|
9
|
+
nativeAuthToken
|
|
9
10
|
}) {
|
|
11
|
+
const config = {
|
|
12
|
+
baseURL: url,
|
|
13
|
+
headers: {
|
|
14
|
+
Authorization: `Bearer ${nativeAuthToken}`
|
|
15
|
+
}
|
|
16
|
+
};
|
|
10
17
|
return await axios.get(
|
|
11
18
|
`/tokens/balances/${userAddress}/${chainId}`,
|
|
12
|
-
|
|
13
|
-
baseURL: url
|
|
14
|
-
}
|
|
19
|
+
config
|
|
15
20
|
);
|
|
16
21
|
}
|
|
17
22
|
exports.getTokensBalances = getTokensBalances;
|
|
@@ -2,13 +2,18 @@ import axios from "axios";
|
|
|
2
2
|
async function getTokensBalances({
|
|
3
3
|
url,
|
|
4
4
|
userAddress,
|
|
5
|
-
chainId
|
|
5
|
+
chainId,
|
|
6
|
+
nativeAuthToken
|
|
6
7
|
}) {
|
|
8
|
+
const config = {
|
|
9
|
+
baseURL: url,
|
|
10
|
+
headers: {
|
|
11
|
+
Authorization: `Bearer ${nativeAuthToken}`
|
|
12
|
+
}
|
|
13
|
+
};
|
|
7
14
|
return await axios.get(
|
|
8
15
|
`/tokens/balances/${userAddress}/${chainId}`,
|
|
9
|
-
|
|
10
|
-
baseURL: url
|
|
11
|
-
}
|
|
16
|
+
config
|
|
12
17
|
);
|
|
13
18
|
}
|
|
14
19
|
export {
|
package/api/getTransactions.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ProviderType } from 'types/providerType';
|
|
|
2
2
|
import { TransactionDTO } from 'dto/Transaction.dto';
|
|
3
3
|
import { AxiosResponse } from 'axios';
|
|
4
4
|
|
|
5
|
-
export declare function getTransactions({ url, address, sender, provider, status, tokenIn, tokenOut }: {
|
|
5
|
+
export declare function getTransactions({ url, address, sender, provider, status, tokenIn, tokenOut, nativeAuthToken }: {
|
|
6
6
|
url: string;
|
|
7
7
|
address: string;
|
|
8
8
|
sender?: string;
|
|
@@ -10,4 +10,5 @@ export declare function getTransactions({ url, address, sender, provider, status
|
|
|
10
10
|
status?: string;
|
|
11
11
|
tokenIn?: string;
|
|
12
12
|
tokenOut?: string;
|
|
13
|
+
nativeAuthToken: string;
|
|
13
14
|
}): Promise<AxiosResponse<TransactionDTO[]>>;
|
package/api/getTransactions.js
CHANGED
|
@@ -9,7 +9,8 @@ async function getTransactions({
|
|
|
9
9
|
provider,
|
|
10
10
|
status,
|
|
11
11
|
tokenIn,
|
|
12
|
-
tokenOut
|
|
12
|
+
tokenOut,
|
|
13
|
+
nativeAuthToken
|
|
13
14
|
}) {
|
|
14
15
|
const queryParams = new URLSearchParams({
|
|
15
16
|
receiver: address || "",
|
|
@@ -27,8 +28,12 @@ async function getTransactions({
|
|
|
27
28
|
}
|
|
28
29
|
const queryString = queryParams.toString();
|
|
29
30
|
const endpointWithParams = `/transactions?${queryString}`;
|
|
30
|
-
|
|
31
|
-
baseURL: url
|
|
32
|
-
|
|
31
|
+
const config = {
|
|
32
|
+
baseURL: url,
|
|
33
|
+
headers: {
|
|
34
|
+
Authorization: `Bearer ${nativeAuthToken}`
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return await axios.get(endpointWithParams, config);
|
|
33
38
|
}
|
|
34
39
|
exports.getTransactions = getTransactions;
|
package/api/getTransactions.mjs
CHANGED
|
@@ -6,7 +6,8 @@ async function getTransactions({
|
|
|
6
6
|
provider,
|
|
7
7
|
status,
|
|
8
8
|
tokenIn,
|
|
9
|
-
tokenOut
|
|
9
|
+
tokenOut,
|
|
10
|
+
nativeAuthToken
|
|
10
11
|
}) {
|
|
11
12
|
const queryParams = new URLSearchParams({
|
|
12
13
|
receiver: address || "",
|
|
@@ -24,9 +25,13 @@ async function getTransactions({
|
|
|
24
25
|
}
|
|
25
26
|
const queryString = queryParams.toString();
|
|
26
27
|
const endpointWithParams = `/transactions?${queryString}`;
|
|
27
|
-
|
|
28
|
-
baseURL: url
|
|
29
|
-
|
|
28
|
+
const config = {
|
|
29
|
+
baseURL: url,
|
|
30
|
+
headers: {
|
|
31
|
+
Authorization: `Bearer ${nativeAuthToken}`
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return await axios.get(endpointWithParams, config);
|
|
30
35
|
}
|
|
31
36
|
export {
|
|
32
37
|
getTransactions
|
package/api/index.d.ts
CHANGED
package/api/index.js
CHANGED
|
@@ -8,6 +8,8 @@ const api_getTokens = require("./getTokens.js");
|
|
|
8
8
|
const api_getTokensBalances = require("./getTokensBalances.js");
|
|
9
9
|
const api_getTransactions = require("./getTransactions.js");
|
|
10
10
|
const api_sendTransactions = require("./sendTransactions.js");
|
|
11
|
+
const api_checkAccount = require("./checkAccount.js");
|
|
12
|
+
const api_linkAccount = require("./linkAccount.js");
|
|
11
13
|
exports.confirmRate = api_confirmRate.confirmRate;
|
|
12
14
|
exports.getChains = api_getChains.getChains;
|
|
13
15
|
exports.getRate = api_getRate.getRate;
|
|
@@ -15,3 +17,5 @@ exports.getTokens = api_getTokens.getTokens;
|
|
|
15
17
|
exports.getTokensBalances = api_getTokensBalances.getTokensBalances;
|
|
16
18
|
exports.getTransactions = api_getTransactions.getTransactions;
|
|
17
19
|
exports.sendTransactions = api_sendTransactions.sendTransactions;
|
|
20
|
+
exports.checkAccount = api_checkAccount.checkAccount;
|
|
21
|
+
exports.linkAccount = api_linkAccount.linkAccount;
|
package/api/index.mjs
CHANGED
|
@@ -5,12 +5,16 @@ import { getTokens } from "./getTokens.mjs";
|
|
|
5
5
|
import { getTokensBalances } from "./getTokensBalances.mjs";
|
|
6
6
|
import { getTransactions } from "./getTransactions.mjs";
|
|
7
7
|
import { sendTransactions } from "./sendTransactions.mjs";
|
|
8
|
+
import { checkAccount } from "./checkAccount.mjs";
|
|
9
|
+
import { linkAccount } from "./linkAccount.mjs";
|
|
8
10
|
export {
|
|
11
|
+
checkAccount,
|
|
9
12
|
confirmRate,
|
|
10
13
|
getChains,
|
|
11
14
|
getRate,
|
|
12
15
|
getTokens,
|
|
13
16
|
getTokensBalances,
|
|
14
17
|
getTransactions,
|
|
18
|
+
linkAccount,
|
|
15
19
|
sendTransactions
|
|
16
20
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LinkAccountRequestBody } from '../types/linkAccount';
|
|
2
|
+
import { AxiosResponse } from 'axios';
|
|
3
|
+
|
|
4
|
+
interface LinkAccountProps {
|
|
5
|
+
url: string;
|
|
6
|
+
nativeAuthToken: string;
|
|
7
|
+
body: LinkAccountRequestBody;
|
|
8
|
+
}
|
|
9
|
+
export declare function linkAccount({ url, nativeAuthToken, body }: LinkAccountProps): Promise<AxiosResponse>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const axios = require("axios");
|
|
5
|
+
const helpers_decodeToken = require("../helpers/decodeToken.js");
|
|
6
|
+
async function linkAccount({
|
|
7
|
+
url,
|
|
8
|
+
nativeAuthToken,
|
|
9
|
+
body
|
|
10
|
+
}) {
|
|
11
|
+
var _a;
|
|
12
|
+
const config = {
|
|
13
|
+
baseURL: url,
|
|
14
|
+
headers: {
|
|
15
|
+
Authorization: `Bearer ${nativeAuthToken}`
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
if (!nativeAuthToken) {
|
|
19
|
+
(_a = config.headers) == null ? true : delete _a.Authorization;
|
|
20
|
+
}
|
|
21
|
+
const decodedToken = await helpers_decodeToken.decodeToken(nativeAuthToken);
|
|
22
|
+
config.headers = {
|
|
23
|
+
...config.headers,
|
|
24
|
+
origin: decodedToken == null ? void 0 : decodedToken.origin
|
|
25
|
+
};
|
|
26
|
+
return await axios.post(
|
|
27
|
+
`/user/linkAccount`,
|
|
28
|
+
body,
|
|
29
|
+
config
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
exports.linkAccount = linkAccount;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { decodeToken } from "../helpers/decodeToken.mjs";
|
|
3
|
+
async function linkAccount({
|
|
4
|
+
url,
|
|
5
|
+
nativeAuthToken,
|
|
6
|
+
body
|
|
7
|
+
}) {
|
|
8
|
+
var _a;
|
|
9
|
+
const config = {
|
|
10
|
+
baseURL: url,
|
|
11
|
+
headers: {
|
|
12
|
+
Authorization: `Bearer ${nativeAuthToken}`
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
if (!nativeAuthToken) {
|
|
16
|
+
(_a = config.headers) == null ? true : delete _a.Authorization;
|
|
17
|
+
}
|
|
18
|
+
const decodedToken = await decodeToken(nativeAuthToken);
|
|
19
|
+
config.headers = {
|
|
20
|
+
...config.headers,
|
|
21
|
+
origin: decodedToken == null ? void 0 : decodedToken.origin
|
|
22
|
+
};
|
|
23
|
+
return await axios.post(
|
|
24
|
+
`/user/linkAccount`,
|
|
25
|
+
body,
|
|
26
|
+
config
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
linkAccount
|
|
31
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
const axios = require("axios");
|
|
4
|
+
const types_chainType = require("../../types/chainType.js");
|
|
4
5
|
const api_getChains = require("../getChains.js");
|
|
5
6
|
jest.mock("axios");
|
|
6
7
|
const mockedAxios = axios;
|
|
@@ -13,7 +14,7 @@ describe("getChains", () => {
|
|
|
13
14
|
chainName: "msx",
|
|
14
15
|
pngUrl: "https://devnet-tools.multiversx.com/liquidity-sdk/ethereum/icon.png",
|
|
15
16
|
svgUrl: "https://devnet-tools.multiversx.com/liquidity-sdk/ethereum/icon.svg",
|
|
16
|
-
chainType:
|
|
17
|
+
chainType: types_chainType.ChainType.evm,
|
|
17
18
|
rpc: "rpc1",
|
|
18
19
|
blockExplorerUrls: ["explorer1"],
|
|
19
20
|
nativeCurrency: {
|
|
@@ -26,12 +27,18 @@ describe("getChains", () => {
|
|
|
26
27
|
}
|
|
27
28
|
];
|
|
28
29
|
mockedAxios.get.mockResolvedValue({ data: response });
|
|
29
|
-
const result = await api_getChains.getChains({
|
|
30
|
+
const result = await api_getChains.getChains({
|
|
31
|
+
url,
|
|
32
|
+
nativeAuthToken: "ZKssadass",
|
|
33
|
+
bridgeOnly: false
|
|
34
|
+
});
|
|
30
35
|
expect(mockedAxios.get).toHaveBeenCalledWith("/chains", { baseURL: url });
|
|
31
36
|
expect(result.data).toEqual(response);
|
|
32
37
|
});
|
|
33
38
|
it("handles error when fetching chains", async () => {
|
|
34
39
|
mockedAxios.get.mockRejectedValue(new Error("Network Error"));
|
|
35
|
-
await expect(
|
|
40
|
+
await expect(
|
|
41
|
+
api_getChains.getChains({ url, nativeAuthToken: "ZKssadass", bridgeOnly: false })
|
|
42
|
+
).rejects.toThrow("Network Error");
|
|
36
43
|
});
|
|
37
44
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
+
import { ChainType } from "../../types/chainType.mjs";
|
|
2
3
|
import { getChains } from "../getChains.mjs";
|
|
3
4
|
jest.mock("axios");
|
|
4
5
|
const mockedAxios = axios;
|
|
@@ -11,7 +12,7 @@ describe("getChains", () => {
|
|
|
11
12
|
chainName: "msx",
|
|
12
13
|
pngUrl: "https://devnet-tools.multiversx.com/liquidity-sdk/ethereum/icon.png",
|
|
13
14
|
svgUrl: "https://devnet-tools.multiversx.com/liquidity-sdk/ethereum/icon.svg",
|
|
14
|
-
chainType:
|
|
15
|
+
chainType: ChainType.evm,
|
|
15
16
|
rpc: "rpc1",
|
|
16
17
|
blockExplorerUrls: ["explorer1"],
|
|
17
18
|
nativeCurrency: {
|
|
@@ -24,12 +25,18 @@ describe("getChains", () => {
|
|
|
24
25
|
}
|
|
25
26
|
];
|
|
26
27
|
mockedAxios.get.mockResolvedValue({ data: response });
|
|
27
|
-
const result = await getChains({
|
|
28
|
+
const result = await getChains({
|
|
29
|
+
url,
|
|
30
|
+
nativeAuthToken: "ZKssadass",
|
|
31
|
+
bridgeOnly: false
|
|
32
|
+
});
|
|
28
33
|
expect(mockedAxios.get).toHaveBeenCalledWith("/chains", { baseURL: url });
|
|
29
34
|
expect(result.data).toEqual(response);
|
|
30
35
|
});
|
|
31
36
|
it("handles error when fetching chains", async () => {
|
|
32
37
|
mockedAxios.get.mockRejectedValue(new Error("Network Error"));
|
|
33
|
-
await expect(
|
|
38
|
+
await expect(
|
|
39
|
+
getChains({ url, nativeAuthToken: "ZKssadass", bridgeOnly: false })
|
|
40
|
+
).rejects.toThrow("Network Error");
|
|
34
41
|
});
|
|
35
42
|
});
|
|
@@ -9,7 +9,7 @@ describe("getTokens", () => {
|
|
|
9
9
|
it("fetches tokens successfully without chainId", async () => {
|
|
10
10
|
const response = [
|
|
11
11
|
{
|
|
12
|
-
chainId: 1,
|
|
12
|
+
chainId: "1",
|
|
13
13
|
address: "0x123",
|
|
14
14
|
name: "Token One",
|
|
15
15
|
symbol: "T1",
|
|
@@ -24,7 +24,11 @@ describe("getTokens", () => {
|
|
|
24
24
|
}
|
|
25
25
|
];
|
|
26
26
|
mockedAxios.get.mockResolvedValue({ data: response });
|
|
27
|
-
const result = await api_getTokens.getTokens({
|
|
27
|
+
const result = await api_getTokens.getTokens({
|
|
28
|
+
url,
|
|
29
|
+
nativeAuthToken: "",
|
|
30
|
+
bridgeOnly: false
|
|
31
|
+
});
|
|
28
32
|
expect(mockedAxios.get).toHaveBeenCalledWith("/tokens", { baseURL: url });
|
|
29
33
|
expect(result.data).toEqual(response);
|
|
30
34
|
});
|
|
@@ -32,7 +36,7 @@ describe("getTokens", () => {
|
|
|
32
36
|
const chainId = 1;
|
|
33
37
|
const response = [
|
|
34
38
|
{
|
|
35
|
-
chainId: 1,
|
|
39
|
+
chainId: "1",
|
|
36
40
|
address: "0x123",
|
|
37
41
|
name: "Token One",
|
|
38
42
|
symbol: "T1",
|
|
@@ -47,7 +51,12 @@ describe("getTokens", () => {
|
|
|
47
51
|
}
|
|
48
52
|
];
|
|
49
53
|
mockedAxios.get.mockResolvedValue({ data: response });
|
|
50
|
-
const result = await api_getTokens.getTokens({
|
|
54
|
+
const result = await api_getTokens.getTokens({
|
|
55
|
+
url,
|
|
56
|
+
chainId,
|
|
57
|
+
nativeAuthToken: "",
|
|
58
|
+
bridgeOnly: false
|
|
59
|
+
});
|
|
51
60
|
expect(mockedAxios.get).toHaveBeenCalledWith(`/tokens/${chainId}`, {
|
|
52
61
|
baseURL: url
|
|
53
62
|
});
|
|
@@ -55,6 +64,8 @@ describe("getTokens", () => {
|
|
|
55
64
|
});
|
|
56
65
|
it("handles error when fetching tokens", async () => {
|
|
57
66
|
mockedAxios.get.mockRejectedValue(new Error("Network Error"));
|
|
58
|
-
await expect(
|
|
67
|
+
await expect(
|
|
68
|
+
api_getTokens.getTokens({ url, nativeAuthToken: "", bridgeOnly: false })
|
|
69
|
+
).rejects.toThrow("Network Error");
|
|
59
70
|
});
|
|
60
71
|
});
|
|
@@ -7,7 +7,7 @@ describe("getTokens", () => {
|
|
|
7
7
|
it("fetches tokens successfully without chainId", async () => {
|
|
8
8
|
const response = [
|
|
9
9
|
{
|
|
10
|
-
chainId: 1,
|
|
10
|
+
chainId: "1",
|
|
11
11
|
address: "0x123",
|
|
12
12
|
name: "Token One",
|
|
13
13
|
symbol: "T1",
|
|
@@ -22,7 +22,11 @@ describe("getTokens", () => {
|
|
|
22
22
|
}
|
|
23
23
|
];
|
|
24
24
|
mockedAxios.get.mockResolvedValue({ data: response });
|
|
25
|
-
const result = await getTokens({
|
|
25
|
+
const result = await getTokens({
|
|
26
|
+
url,
|
|
27
|
+
nativeAuthToken: "",
|
|
28
|
+
bridgeOnly: false
|
|
29
|
+
});
|
|
26
30
|
expect(mockedAxios.get).toHaveBeenCalledWith("/tokens", { baseURL: url });
|
|
27
31
|
expect(result.data).toEqual(response);
|
|
28
32
|
});
|
|
@@ -30,7 +34,7 @@ describe("getTokens", () => {
|
|
|
30
34
|
const chainId = 1;
|
|
31
35
|
const response = [
|
|
32
36
|
{
|
|
33
|
-
chainId: 1,
|
|
37
|
+
chainId: "1",
|
|
34
38
|
address: "0x123",
|
|
35
39
|
name: "Token One",
|
|
36
40
|
symbol: "T1",
|
|
@@ -45,7 +49,12 @@ describe("getTokens", () => {
|
|
|
45
49
|
}
|
|
46
50
|
];
|
|
47
51
|
mockedAxios.get.mockResolvedValue({ data: response });
|
|
48
|
-
const result = await getTokens({
|
|
52
|
+
const result = await getTokens({
|
|
53
|
+
url,
|
|
54
|
+
chainId,
|
|
55
|
+
nativeAuthToken: "",
|
|
56
|
+
bridgeOnly: false
|
|
57
|
+
});
|
|
49
58
|
expect(mockedAxios.get).toHaveBeenCalledWith(`/tokens/${chainId}`, {
|
|
50
59
|
baseURL: url
|
|
51
60
|
});
|
|
@@ -53,6 +62,8 @@ describe("getTokens", () => {
|
|
|
53
62
|
});
|
|
54
63
|
it("handles error when fetching tokens", async () => {
|
|
55
64
|
mockedAxios.get.mockRejectedValue(new Error("Network Error"));
|
|
56
|
-
await expect(
|
|
65
|
+
await expect(
|
|
66
|
+
getTokens({ url, nativeAuthToken: "", bridgeOnly: false })
|
|
67
|
+
).rejects.toThrow("Network Error");
|
|
57
68
|
});
|
|
58
69
|
});
|