@shapeshiftoss/swapper 1.15.0 → 1.15.4

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.
@@ -62,7 +62,7 @@ const getUsdRate = async (input) => {
62
62
  const rateResponse = await zrxService_1.zrxService.get('/swap/v1/price', {
63
63
  params: {
64
64
  buyToken: 'USDC',
65
- buyAmount: '1000000',
65
+ buyAmount: '1000000000',
66
66
  sellToken: tokenId || symbol
67
67
  }
68
68
  });
@@ -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
- try {
109
- signedTx = await adapter.signTransaction({ txToSign: grantAllowanceTxToSign, wallet });
110
- }
111
- catch (error) {
112
- throw new Error(`grantAllowance - signTransaction: ${error}`);
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
- try {
115
- broadcastedTxId = await adapter.broadcastTransaction(signedTx);
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
- catch (error) {
118
- throw new Error(`grantAllowance - broadcastTransaction: ${error}`);
138
+ else {
139
+ throw new api_1.SwapError('grantAllowance - invalid HDWallet config');
119
140
  }
120
- return broadcastedTxId;
121
141
  };
122
142
  exports.grantAllowance = grantAllowance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/swapper",
3
- "version": "1.15.0",
3
+ "version": "1.15.4",
4
4
  "description": "TODO: description",
5
5
  "repository": "https://github.com/shapeshift/lib",
6
6
  "license": "MIT",
@@ -28,17 +28,17 @@
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@shapeshiftoss/asset-service": "^1.6.1",
31
- "@shapeshiftoss/caip": "^1.6.1",
32
- "@shapeshiftoss/chain-adapters": "^1.15.3",
31
+ "@shapeshiftoss/caip": "^1.11.0",
32
+ "@shapeshiftoss/chain-adapters": "^1.33.0",
33
33
  "@shapeshiftoss/hdwallet-core": "^1.18.2",
34
- "@shapeshiftoss/types": "^1.13.1"
34
+ "@shapeshiftoss/types": "^1.23.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@shapeshiftoss/asset-service": "^1.6.1",
38
- "@shapeshiftoss/caip": "^1.6.1",
39
- "@shapeshiftoss/chain-adapters": "^1.16.2",
38
+ "@shapeshiftoss/caip": "^1.11.0",
39
+ "@shapeshiftoss/chain-adapters": "^1.33.0",
40
40
  "@shapeshiftoss/hdwallet-core": "^1.18.2",
41
- "@shapeshiftoss/types": "^1.13.1",
41
+ "@shapeshiftoss/types": "^1.23.0",
42
42
  "@types/readline-sync": "^1.4.4",
43
43
  "readline-sync": "^1.4.10",
44
44
  "web3-utils": "^1.5.2"