@shapeshiftoss/swapper 1.15.0 → 1.15.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.
|
@@ -73,7 +73,7 @@ const getUsdRate = async (input) => {
|
|
|
73
73
|
};
|
|
74
74
|
exports.getUsdRate = getUsdRate;
|
|
75
75
|
const grantAllowance = async ({ quote, wallet, adapter, erc20Abi, web3 }) => {
|
|
76
|
-
var _a, _b, _c, _d;
|
|
76
|
+
var _a, _b, _c, _d, _e;
|
|
77
77
|
if (!quote.sellAsset.tokenId) {
|
|
78
78
|
throw new Error('sellAsset.tokenId is required');
|
|
79
79
|
}
|
|
@@ -105,18 +105,38 @@ const grantAllowance = async ({ quote, wallet, adapter, erc20Abi, web3 }) => {
|
|
|
105
105
|
catch (error) {
|
|
106
106
|
throw new Error(`grantAllowance - buildSendTransaction: ${error}`);
|
|
107
107
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
if (wallet.supportsOfflineSigning()) {
|
|
109
|
+
try {
|
|
110
|
+
signedTx = await adapter.signTransaction({ txToSign: grantAllowanceTxToSign, wallet });
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
throw new api_1.SwapError(`grantAllowance - signTransaction error: ${error}`);
|
|
114
|
+
}
|
|
115
|
+
if (!signedTx) {
|
|
116
|
+
throw new api_1.SwapError(`grantAllowance - Signed transaction is required: ${signedTx}`);
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
broadcastedTxId = await adapter.broadcastTransaction(signedTx);
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
throw new api_1.SwapError(`grantAllowance - broadcastTransaction error: ${error}`);
|
|
123
|
+
}
|
|
124
|
+
return broadcastedTxId;
|
|
113
125
|
}
|
|
114
|
-
|
|
115
|
-
|
|
126
|
+
else if (wallet.supportsBroadcast() && adapter.signAndBroadcastTransaction) {
|
|
127
|
+
try {
|
|
128
|
+
broadcastedTxId = await ((_e = adapter.signAndBroadcastTransaction) === null || _e === void 0 ? void 0 : _e.call(adapter, {
|
|
129
|
+
txToSign: grantAllowanceTxToSign,
|
|
130
|
+
wallet
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
throw new api_1.SwapError(`grantAllowance - signAndBroadcastTransaction error: ${error}`);
|
|
135
|
+
}
|
|
136
|
+
return broadcastedTxId;
|
|
116
137
|
}
|
|
117
|
-
|
|
118
|
-
throw new
|
|
138
|
+
else {
|
|
139
|
+
throw new api_1.SwapError('grantAllowance - invalid HDWallet config');
|
|
119
140
|
}
|
|
120
|
-
return broadcastedTxId;
|
|
121
141
|
};
|
|
122
142
|
exports.grantAllowance = grantAllowance;
|