@rango-dev/queue-manager-rango-preset 0.1.13 → 0.1.15-next.0
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/helpers.d.ts.map +1 -1
- package/dist/queue-manager-rango-preset.cjs.development.js +47 -80
- package/dist/queue-manager-rango-preset.cjs.development.js.map +1 -1
- package/dist/queue-manager-rango-preset.cjs.production.min.js +1 -1
- package/dist/queue-manager-rango-preset.cjs.production.min.js.map +1 -1
- package/dist/queue-manager-rango-preset.esm.js +48 -81
- package/dist/queue-manager-rango-preset.esm.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/helpers.ts +25 -95
- package/src/shared.ts +1 -1
- package/src/types.ts +1 -0
package/dist/types.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export interface SwapQueueContext extends QueueContext {
|
|
|
34
34
|
switchNetwork: (wallet: WalletType, network: Network) => Promise<ConnectResult> | undefined;
|
|
35
35
|
connect: (wallet: WalletType, network: Network) => Promise<ConnectResult> | undefined;
|
|
36
36
|
state: (type: WalletType) => WalletState;
|
|
37
|
+
isMobileWallet: (type: WalletType) => boolean;
|
|
37
38
|
notifier: (data: SwapProgressNotification) => void;
|
|
38
39
|
claimedBy?: string;
|
|
39
40
|
resetClaimedBy?: () => void;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EACL,IAAI,EACJ,OAAO,EACP,WAAW,EACX,UAAU,EACX,MAAM,2BAA2B,CAAC;AACnC,OA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package.json
CHANGED
package/src/helpers.ts
CHANGED
|
@@ -330,10 +330,7 @@ export function markRunningSwapAsSwitchingNetwork({
|
|
|
330
330
|
const { type } = getRequiredWallet(swap);
|
|
331
331
|
const fromBlockchain = getCurrentBlockchainOf(swap, currentStep);
|
|
332
332
|
const reason = `Change ${type} wallet network to ${fromBlockchain}`;
|
|
333
|
-
|
|
334
|
-
if (type === WalletType.META_MASK)
|
|
335
|
-
metamaskMessage = `(Networks -> Select '${fromBlockchain}' network.)`;
|
|
336
|
-
const reasonDetail = `Please change your ${type} wallet network to ${fromBlockchain}. ${metamaskMessage}`;
|
|
333
|
+
const reasonDetail = `Please change your ${type} wallet network to ${fromBlockchain}.`;
|
|
337
334
|
|
|
338
335
|
const currentTime = new Date();
|
|
339
336
|
swap.lastNotificationTime = currentTime.getTime().toString();
|
|
@@ -528,50 +525,25 @@ export async function isNetworkMatchedForTransaction(
|
|
|
528
525
|
try {
|
|
529
526
|
const sourceWallet = swap.wallets[fromBlockChain];
|
|
530
527
|
if (sourceWallet) {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
WalletType.COIN98,
|
|
539
|
-
WalletType.EXODUS,
|
|
540
|
-
WalletType.OKX,
|
|
541
|
-
WalletType.COINBASE,
|
|
542
|
-
WalletType.TOKEN_POCKET,
|
|
543
|
-
WalletType.MATH,
|
|
544
|
-
WalletType.SAFEPAL,
|
|
545
|
-
WalletType.COSMOSTATION,
|
|
546
|
-
WalletType.CLOVER,
|
|
547
|
-
WalletType.BRAVE,
|
|
548
|
-
WalletType.FRONTIER,
|
|
549
|
-
WalletType.KUCOIN,
|
|
550
|
-
WalletType.ENKRYPT,
|
|
551
|
-
].includes(sourceWallet.walletType)
|
|
552
|
-
) {
|
|
553
|
-
const provider = getEvmProvider(providers, sourceWallet.walletType);
|
|
554
|
-
const chainId: number | string | null = await getChainId(provider);
|
|
555
|
-
if (chainId) {
|
|
556
|
-
const blockChain = getBlockChainNameFromId(
|
|
557
|
-
chainId,
|
|
558
|
-
Object.entries(meta.blockchains).map(
|
|
559
|
-
([, blockchainMeta]) => blockchainMeta
|
|
560
|
-
)
|
|
561
|
-
);
|
|
562
|
-
if (
|
|
563
|
-
blockChain &&
|
|
564
|
-
blockChain.toLowerCase() === fromBlockChain.toLowerCase()
|
|
565
|
-
)
|
|
566
|
-
return true;
|
|
567
|
-
if (
|
|
568
|
-
blockChain &&
|
|
569
|
-
blockChain.toLowerCase() !== fromBlockChain.toLowerCase()
|
|
528
|
+
const provider = getEvmProvider(providers, sourceWallet.walletType);
|
|
529
|
+
const chainId: number | string | null = await getChainId(provider);
|
|
530
|
+
if (chainId) {
|
|
531
|
+
const blockChain = getBlockChainNameFromId(
|
|
532
|
+
chainId,
|
|
533
|
+
Object.entries(meta.blockchains).map(
|
|
534
|
+
([, blockchainMeta]) => blockchainMeta
|
|
570
535
|
)
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
536
|
+
);
|
|
537
|
+
if (
|
|
538
|
+
blockChain &&
|
|
539
|
+
blockChain.toLowerCase() === fromBlockChain.toLowerCase()
|
|
540
|
+
)
|
|
541
|
+
return true;
|
|
542
|
+
if (
|
|
543
|
+
blockChain &&
|
|
544
|
+
blockChain.toLowerCase() !== fromBlockChain.toLowerCase()
|
|
545
|
+
)
|
|
546
|
+
return false;
|
|
575
547
|
}
|
|
576
548
|
}
|
|
577
549
|
} catch (e) {
|
|
@@ -822,7 +794,7 @@ export function singTransaction(
|
|
|
822
794
|
actions: ExecuterActions<SwapStorage, SwapActionTypes, SwapQueueContext>
|
|
823
795
|
): void {
|
|
824
796
|
const { getStorage, setStorage, failed, next, schedule, context } = actions;
|
|
825
|
-
const { meta, getSigners, notifier } = context;
|
|
797
|
+
const { meta, getSigners, notifier, isMobileWallet } = context;
|
|
826
798
|
const swap = getStorage().swapDetails;
|
|
827
799
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
828
800
|
const currentStep = getCurrentStep(swap)!;
|
|
@@ -840,6 +812,7 @@ export function singTransaction(
|
|
|
840
812
|
const sourceWallet = getRelatedWallet(swap, currentStep);
|
|
841
813
|
const walletAddress = getCurrentAddressOf(swap, currentStep);
|
|
842
814
|
const walletSigners = getSigners(sourceWallet.walletType);
|
|
815
|
+
const mobileWallet = isMobileWallet(sourceWallet.walletType);
|
|
843
816
|
|
|
844
817
|
const onFinish = () => {
|
|
845
818
|
// TODO resetClaimedBy is undefined here
|
|
@@ -858,9 +831,7 @@ export function singTransaction(
|
|
|
858
831
|
|
|
859
832
|
// Update swap status
|
|
860
833
|
const message = `Waiting for approval of ${currentStep?.fromSymbol} coin ${
|
|
861
|
-
|
|
862
|
-
? 'on your mobile phone'
|
|
863
|
-
: ''
|
|
834
|
+
mobileWallet ? 'on your mobile phone' : ''
|
|
864
835
|
}`;
|
|
865
836
|
const updateResult = updateSwapStatus({
|
|
866
837
|
getStorage,
|
|
@@ -942,9 +913,7 @@ export function singTransaction(
|
|
|
942
913
|
} else if (!!tronApprovalTransaction) {
|
|
943
914
|
// Update swap status
|
|
944
915
|
const message = `Waiting for approval of ${currentStep?.fromSymbol} coin ${
|
|
945
|
-
|
|
946
|
-
? 'on your mobile phone'
|
|
947
|
-
: ''
|
|
916
|
+
mobileWallet ? 'on your mobile phone' : ''
|
|
948
917
|
}`;
|
|
949
918
|
const updateResult = updateSwapStatus({
|
|
950
919
|
getStorage,
|
|
@@ -1023,9 +992,7 @@ export function singTransaction(
|
|
|
1023
992
|
} else if (!!starknetApprovalTransaction) {
|
|
1024
993
|
// Update swap status
|
|
1025
994
|
const message = `Waiting for approval of ${currentStep?.fromSymbol} coin ${
|
|
1026
|
-
|
|
1027
|
-
? 'on your mobile phone'
|
|
1028
|
-
: ''
|
|
995
|
+
mobileWallet ? 'on your mobile phone' : ''
|
|
1029
996
|
}`;
|
|
1030
997
|
const updateResult = updateSwapStatus({
|
|
1031
998
|
getStorage,
|
|
@@ -1113,12 +1080,7 @@ export function singTransaction(
|
|
|
1113
1080
|
const executeMessage = hasAlreadyProceededToSign
|
|
1114
1081
|
? 'Transaction is expired. Please try again'
|
|
1115
1082
|
: 'executing transaction';
|
|
1116
|
-
const executeDetails =
|
|
1117
|
-
sourceWallet.walletType === WalletType.WALLET_CONNECT
|
|
1118
|
-
? 'Check your mobile phone'
|
|
1119
|
-
: ''
|
|
1120
|
-
}`;
|
|
1121
|
-
|
|
1083
|
+
const executeDetails = mobileWallet ? 'Check your mobile phone' : '';
|
|
1122
1084
|
if (!!transferTransaction) {
|
|
1123
1085
|
const updateResult = updateSwapStatus({
|
|
1124
1086
|
getStorage,
|
|
@@ -1265,38 +1227,6 @@ export function singTransaction(
|
|
|
1265
1227
|
failed();
|
|
1266
1228
|
onFinish();
|
|
1267
1229
|
} else {
|
|
1268
|
-
// If keplr wallet is executing contracts on terra, throw error. keplr doesn't support transfer or execute contracts. only IBC messages are supported
|
|
1269
|
-
if (
|
|
1270
|
-
(currentStep?.swapperId.toString() === 'TerraSwap' ||
|
|
1271
|
-
(currentStep?.swapperId.toString() === 'ThorChain' &&
|
|
1272
|
-
currentStep?.fromBlockchain === Network.TERRA) ||
|
|
1273
|
-
(currentStep?.swapperId.toString() === 'Terra Bridge' &&
|
|
1274
|
-
currentStep.fromBlockchain === Network.TERRA)) && // here we must allow ibc on terrastatus
|
|
1275
|
-
sourceWallet.walletType === WalletType.KEPLR
|
|
1276
|
-
) {
|
|
1277
|
-
const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
|
|
1278
|
-
prettifyErrorMessage(
|
|
1279
|
-
'Keplr only supports IBC Transactions on Terra. ' +
|
|
1280
|
-
'Using Terra Bridge, TerraSwap and THORChain is not possible with Keplr. Please use TerraStation or Leap wallet'
|
|
1281
|
-
);
|
|
1282
|
-
const updateResult = updateSwapStatus({
|
|
1283
|
-
getStorage,
|
|
1284
|
-
setStorage,
|
|
1285
|
-
nextStatus: 'failed',
|
|
1286
|
-
nextStepStatus: 'failed',
|
|
1287
|
-
message: extraMessage,
|
|
1288
|
-
details: extraMessageDetail,
|
|
1289
|
-
errorCode: extraMessageErrorCode,
|
|
1290
|
-
});
|
|
1291
|
-
notifier({
|
|
1292
|
-
eventType: 'smart_contract_call_failed',
|
|
1293
|
-
...updateResult,
|
|
1294
|
-
});
|
|
1295
|
-
failed();
|
|
1296
|
-
onFinish();
|
|
1297
|
-
return;
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
1230
|
walletSigners
|
|
1301
1231
|
.getSigner(TransactionType.COSMOS)
|
|
1302
1232
|
.signAndSendTx(cosmosTransaction, walletAddress, null)
|
package/src/shared.ts
CHANGED
|
@@ -338,7 +338,7 @@ export function getRelatedWallet(
|
|
|
338
338
|
const wallet = walletKV?.v || null;
|
|
339
339
|
|
|
340
340
|
const walletType = wallet?.walletType;
|
|
341
|
-
if (
|
|
341
|
+
if (wallet === null)
|
|
342
342
|
throw PrettyError.AssertionFailed(
|
|
343
343
|
`Wallet for source ${blockchain} not passed: walletType: ${walletType}`
|
|
344
344
|
);
|
package/src/types.ts
CHANGED
|
@@ -60,6 +60,7 @@ export interface SwapQueueContext extends QueueContext {
|
|
|
60
60
|
network: Network
|
|
61
61
|
) => Promise<ConnectResult> | undefined;
|
|
62
62
|
state: (type: WalletType) => WalletState;
|
|
63
|
+
isMobileWallet: (type: WalletType) => boolean;
|
|
63
64
|
notifier: (data: SwapProgressNotification) => void;
|
|
64
65
|
|
|
65
66
|
// Dynamically will be added to context.
|