@shapeshiftoss/unchained-client 10.3.0 → 10.4.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.
@@ -0,0 +1,3 @@
1
+ import { JsonFragment } from '@ethersproject/abi/lib/fragments';
2
+ declare const thorAvalanche: JsonFragment[];
3
+ export default thorAvalanche;
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const thorAvalanche = [
4
+ { inputs: [], stateMutability: 'nonpayable', type: 'constructor' },
5
+ {
6
+ anonymous: false,
7
+ inputs: [
8
+ { indexed: true, internalType: 'address', name: 'to', type: 'address' },
9
+ { indexed: true, internalType: 'address', name: 'asset', type: 'address' },
10
+ { indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' },
11
+ { indexed: false, internalType: 'string', name: 'memo', type: 'string' },
12
+ ],
13
+ name: 'Deposit',
14
+ type: 'event',
15
+ },
16
+ {
17
+ anonymous: false,
18
+ inputs: [
19
+ { indexed: true, internalType: 'address', name: 'oldVault', type: 'address' },
20
+ { indexed: true, internalType: 'address', name: 'newVault', type: 'address' },
21
+ { indexed: false, internalType: 'address', name: 'asset', type: 'address' },
22
+ { indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' },
23
+ { indexed: false, internalType: 'string', name: 'memo', type: 'string' },
24
+ ],
25
+ name: 'TransferAllowance',
26
+ type: 'event',
27
+ },
28
+ {
29
+ anonymous: false,
30
+ inputs: [
31
+ { indexed: true, internalType: 'address', name: 'vault', type: 'address' },
32
+ { indexed: true, internalType: 'address', name: 'to', type: 'address' },
33
+ { indexed: false, internalType: 'address', name: 'asset', type: 'address' },
34
+ { indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' },
35
+ { indexed: false, internalType: 'string', name: 'memo', type: 'string' },
36
+ ],
37
+ name: 'TransferOut',
38
+ type: 'event',
39
+ },
40
+ {
41
+ anonymous: false,
42
+ inputs: [
43
+ { indexed: true, internalType: 'address', name: 'vault', type: 'address' },
44
+ { indexed: false, internalType: 'address', name: 'target', type: 'address' },
45
+ { indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' },
46
+ { indexed: false, internalType: 'address', name: 'finalAsset', type: 'address' },
47
+ { indexed: false, internalType: 'address', name: 'to', type: 'address' },
48
+ { indexed: false, internalType: 'uint256', name: 'amountOutMin', type: 'uint256' },
49
+ { indexed: false, internalType: 'string', name: 'memo', type: 'string' },
50
+ ],
51
+ name: 'TransferOutAndCall',
52
+ type: 'event',
53
+ },
54
+ {
55
+ anonymous: false,
56
+ inputs: [
57
+ { indexed: true, internalType: 'address', name: 'oldVault', type: 'address' },
58
+ { indexed: true, internalType: 'address', name: 'newVault', type: 'address' },
59
+ {
60
+ components: [
61
+ { internalType: 'address', name: 'asset', type: 'address' },
62
+ { internalType: 'uint256', name: 'amount', type: 'uint256' },
63
+ ],
64
+ indexed: false,
65
+ internalType: 'struct AvaxRouter.Coin[]',
66
+ name: 'coins',
67
+ type: 'tuple[]',
68
+ },
69
+ { indexed: false, internalType: 'string', name: 'memo', type: 'string' },
70
+ ],
71
+ name: 'VaultTransfer',
72
+ type: 'event',
73
+ },
74
+ {
75
+ inputs: [
76
+ { internalType: 'address payable', name: 'vault', type: 'address' },
77
+ { internalType: 'address', name: 'asset', type: 'address' },
78
+ { internalType: 'uint256', name: 'amount', type: 'uint256' },
79
+ { internalType: 'string', name: 'memo', type: 'string' },
80
+ ],
81
+ name: 'deposit',
82
+ outputs: [],
83
+ stateMutability: 'payable',
84
+ type: 'function',
85
+ },
86
+ {
87
+ inputs: [
88
+ { internalType: 'address payable', name: 'vault', type: 'address' },
89
+ { internalType: 'address', name: 'asset', type: 'address' },
90
+ { internalType: 'uint256', name: 'amount', type: 'uint256' },
91
+ { internalType: 'string', name: 'memo', type: 'string' },
92
+ { internalType: 'uint256', name: 'expiration', type: 'uint256' },
93
+ ],
94
+ name: 'depositWithExpiry',
95
+ outputs: [],
96
+ stateMutability: 'payable',
97
+ type: 'function',
98
+ },
99
+ {
100
+ inputs: [
101
+ { internalType: 'address', name: 'router', type: 'address' },
102
+ { internalType: 'address payable', name: 'asgard', type: 'address' },
103
+ {
104
+ components: [
105
+ { internalType: 'address', name: 'asset', type: 'address' },
106
+ { internalType: 'uint256', name: 'amount', type: 'uint256' },
107
+ ],
108
+ internalType: 'struct AvaxRouter.Coin[]',
109
+ name: 'coins',
110
+ type: 'tuple[]',
111
+ },
112
+ { internalType: 'string', name: 'memo', type: 'string' },
113
+ ],
114
+ name: 'returnVaultAssets',
115
+ outputs: [],
116
+ stateMutability: 'payable',
117
+ type: 'function',
118
+ },
119
+ {
120
+ inputs: [
121
+ { internalType: 'address', name: 'router', type: 'address' },
122
+ { internalType: 'address', name: 'newVault', type: 'address' },
123
+ { internalType: 'address', name: 'asset', type: 'address' },
124
+ { internalType: 'uint256', name: 'amount', type: 'uint256' },
125
+ { internalType: 'string', name: 'memo', type: 'string' },
126
+ ],
127
+ name: 'transferAllowance',
128
+ outputs: [],
129
+ stateMutability: 'nonpayable',
130
+ type: 'function',
131
+ },
132
+ {
133
+ inputs: [
134
+ { internalType: 'address payable', name: 'to', type: 'address' },
135
+ { internalType: 'address', name: 'asset', type: 'address' },
136
+ { internalType: 'uint256', name: 'amount', type: 'uint256' },
137
+ { internalType: 'string', name: 'memo', type: 'string' },
138
+ ],
139
+ name: 'transferOut',
140
+ outputs: [],
141
+ stateMutability: 'payable',
142
+ type: 'function',
143
+ },
144
+ {
145
+ inputs: [
146
+ { internalType: 'address payable', name: 'target', type: 'address' },
147
+ { internalType: 'address', name: 'finalToken', type: 'address' },
148
+ { internalType: 'address', name: 'to', type: 'address' },
149
+ { internalType: 'uint256', name: 'amountOutMin', type: 'uint256' },
150
+ { internalType: 'string', name: 'memo', type: 'string' },
151
+ ],
152
+ name: 'transferOutAndCall',
153
+ outputs: [],
154
+ stateMutability: 'payable',
155
+ type: 'function',
156
+ },
157
+ {
158
+ inputs: [
159
+ { internalType: 'address', name: 'vault', type: 'address' },
160
+ { internalType: 'address', name: 'token', type: 'address' },
161
+ ],
162
+ name: 'vaultAllowance',
163
+ outputs: [{ internalType: 'uint256', name: 'amount', type: 'uint256' }],
164
+ stateMutability: 'view',
165
+ type: 'function',
166
+ },
167
+ ];
168
+ exports.default = thorAvalanche;
@@ -0,0 +1,3 @@
1
+ import { JsonFragment } from '@ethersproject/abi/lib/fragments';
2
+ declare const thorEthereum: JsonFragment[];
3
+ export default thorEthereum;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const thor = [
3
+ const thorEthereum = [
4
4
  { inputs: [], stateMutability: 'nonpayable', type: 'constructor' },
5
5
  {
6
6
  anonymous: false,
@@ -151,4 +151,4 @@ const thor = [
151
151
  type: 'function',
152
152
  },
153
153
  ];
154
- exports.default = thor;
154
+ exports.default = thorEthereum;
@@ -1,7 +1,7 @@
1
1
  export declare const SHAPE_SHIFT_ROUTER_CONTRACT = "0x6a1e73f12018D8e5f966ce794aa2921941feB17E";
2
2
  export declare const UNI_V2_ROUTER_CONTRACT = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D";
3
- export declare const THOR_ROUTER_CONTRACT_MAINNET = "0xC145990E84155416144C532E31f89B840Ca8c2cE";
4
- export declare const THOR_ROUTER_CONTRACT_ROPSTEN = "0xefA28233838f46a80AaaC8c309077a9ba70D123A";
3
+ export declare const THOR_ROUTER_CONTRACT_ETH_MAINNET = "0xC145990E84155416144C532E31f89B840Ca8c2cE";
4
+ export declare const THOR_ROUTER_CONTRACT_AVAX_MAINNET = "0x8F66c4AE756BEbC49Ec8B81966DD8bba9f127549";
5
5
  export declare const FOXY_STAKING_CONTRACT = "0xee77aa3Fd23BbeBaf94386dD44b548e9a785ea4b";
6
6
  export declare const WETH_CONTRACT_MAINNET = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
7
7
  export declare const WETH_CONTRACT_ROPSTEN = "0xc778417E063141139Fce010982780140Aa0cD5Ab";
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.COWSWAP_CONTRACT_MAINNET = exports.UNI_V2_FOX_STAKING_REWARDS_V3 = exports.WETH_CONTRACT_ROPSTEN = exports.WETH_CONTRACT_MAINNET = exports.FOXY_STAKING_CONTRACT = exports.THOR_ROUTER_CONTRACT_ROPSTEN = exports.THOR_ROUTER_CONTRACT_MAINNET = exports.UNI_V2_ROUTER_CONTRACT = exports.SHAPE_SHIFT_ROUTER_CONTRACT = void 0;
3
+ exports.COWSWAP_CONTRACT_MAINNET = exports.UNI_V2_FOX_STAKING_REWARDS_V3 = exports.WETH_CONTRACT_ROPSTEN = exports.WETH_CONTRACT_MAINNET = exports.FOXY_STAKING_CONTRACT = exports.THOR_ROUTER_CONTRACT_AVAX_MAINNET = exports.THOR_ROUTER_CONTRACT_ETH_MAINNET = exports.UNI_V2_ROUTER_CONTRACT = exports.SHAPE_SHIFT_ROUTER_CONTRACT = void 0;
4
4
  exports.SHAPE_SHIFT_ROUTER_CONTRACT = '0x6a1e73f12018D8e5f966ce794aa2921941feB17E';
5
5
  exports.UNI_V2_ROUTER_CONTRACT = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D';
6
- exports.THOR_ROUTER_CONTRACT_MAINNET = '0xC145990E84155416144C532E31f89B840Ca8c2cE';
7
- exports.THOR_ROUTER_CONTRACT_ROPSTEN = '0xefA28233838f46a80AaaC8c309077a9ba70D123A';
6
+ exports.THOR_ROUTER_CONTRACT_ETH_MAINNET = '0xC145990E84155416144C532E31f89B840Ca8c2cE';
7
+ exports.THOR_ROUTER_CONTRACT_AVAX_MAINNET = '0x8F66c4AE756BEbC49Ec8B81966DD8bba9f127549';
8
8
  exports.FOXY_STAKING_CONTRACT = '0xee77aa3Fd23BbeBaf94386dD44b548e9a785ea4b';
9
9
  exports.WETH_CONTRACT_MAINNET = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
10
10
  exports.WETH_CONTRACT_ROPSTEN = '0xc778417E063141139Fce010982780140Aa0cD5Ab';
@@ -10,13 +10,15 @@ export interface ParserArgs {
10
10
  chainId: ChainId;
11
11
  rpcUrl: string;
12
12
  }
13
+ interface SupportedFunctions {
14
+ depositSigHash: string;
15
+ transferOutSigHash: string;
16
+ }
13
17
  export declare class Parser implements SubParser<Tx> {
14
18
  readonly routerContract: string;
15
19
  readonly abiInterface: ethers.utils.Interface;
16
- readonly supportedFunctions: {
17
- depositSigHash: string;
18
- transferOutSigHash: string;
19
- };
20
+ readonly supportedFunctions: SupportedFunctions;
20
21
  constructor(args: ParserArgs);
21
22
  parse(tx: Tx): Promise<TxSpecific | undefined>;
22
23
  }
24
+ export {};
@@ -4,15 +4,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Parser = void 0;
7
+ const caip_1 = require("@shapeshiftoss/caip");
7
8
  const ethers_1 = require("ethers");
8
9
  const types_1 = require("../../../types");
9
10
  const parser_1 = require("../../parser");
10
- const thor_1 = __importDefault(require("./abi/thor"));
11
+ const thorAvalanche_1 = __importDefault(require("./abi/thorAvalanche"));
12
+ const thorEthereum_1 = __importDefault(require("./abi/thorEthereum"));
11
13
  const constants_1 = require("./constants");
12
14
  const SWAP_TYPES = ['SWAP', '=', 's'];
13
15
  class Parser {
14
16
  constructor(args) {
15
- this.abiInterface = new ethers_1.ethers.utils.Interface(thor_1.default);
17
+ this.abiInterface = (() => {
18
+ switch (args.chainId) {
19
+ case caip_1.ethChainId:
20
+ return new ethers_1.ethers.utils.Interface(thorEthereum_1.default);
21
+ case caip_1.avalancheChainId:
22
+ return new ethers_1.ethers.utils.Interface(thorAvalanche_1.default);
23
+ default:
24
+ throw new Error(`chainId is not supported. (supported chainIds: ${caip_1.ethChainId}, ${caip_1.avalancheChainId})`);
25
+ }
26
+ })();
16
27
  this.supportedFunctions = {
17
28
  depositSigHash: this.abiInterface.getSighash('deposit'),
18
29
  transferOutSigHash: this.abiInterface.getSighash('transferOut'),
@@ -21,12 +32,12 @@ class Parser {
21
32
  // We will also need to know all past router contract addresses if we intend on using receive address as the means for detection
22
33
  this.routerContract = (() => {
23
34
  switch (args.chainId) {
24
- case 'eip155:1':
25
- return constants_1.THOR_ROUTER_CONTRACT_MAINNET;
26
- case 'eip155:3':
27
- return constants_1.THOR_ROUTER_CONTRACT_ROPSTEN;
35
+ case caip_1.ethChainId:
36
+ return constants_1.THOR_ROUTER_CONTRACT_ETH_MAINNET;
37
+ case caip_1.avalancheChainId:
38
+ return constants_1.THOR_ROUTER_CONTRACT_AVAX_MAINNET;
28
39
  default:
29
- throw new Error('chainId is not supported. (supported chainIds: eip155:1, eip155:3)');
40
+ throw new Error(`chainId is not supported. (supported chainIds: ${caip_1.ethChainId}, ${caip_1.avalancheChainId})`);
30
41
  }
31
42
  })();
32
43
  }
@@ -1,6 +1,6 @@
1
1
  import { BaseTxMetadata } from '../../types';
2
- import { type Tx } from '../parser/types';
3
2
  import { type SubParser, type TxSpecific } from '.';
3
+ import { type Tx } from './types';
4
4
  export interface TxMetadata extends BaseTxMetadata {
5
5
  parser: 'zrx';
6
6
  }
@@ -31,6 +31,11 @@ export interface GetValidatorRequest {
31
31
  export interface SendTxRequest {
32
32
  body?: EstimateGasRequest;
33
33
  }
34
+ export interface ValidatorTxHistoryRequest {
35
+ pubkey: string;
36
+ cursor?: string;
37
+ pageSize?: number;
38
+ }
34
39
  /**
35
40
  *
36
41
  */
@@ -99,4 +104,12 @@ export declare class V1Api extends runtime.BaseAPI {
99
104
  * Sends raw transaction to be broadcast to the node.
100
105
  */
101
106
  sendTx(requestParameters?: SendTxRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<string>;
107
+ /**
108
+ * Get paginated transaction history for a validator.
109
+ */
110
+ validatorTxHistoryRaw(requestParameters: ValidatorTxHistoryRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<TxHistory>>;
111
+ /**
112
+ * Get paginated transaction history for a validator.
113
+ */
114
+ validatorTxHistory(requestParameters: ValidatorTxHistoryRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<TxHistory>;
102
115
  }
@@ -234,5 +234,35 @@ class V1Api extends runtime.BaseAPI {
234
234
  const response = await this.sendTxRaw(requestParameters, initOverrides);
235
235
  return await response.value();
236
236
  }
237
+ /**
238
+ * Get paginated transaction history for a validator.
239
+ */
240
+ async validatorTxHistoryRaw(requestParameters, initOverrides) {
241
+ if (requestParameters.pubkey === null || requestParameters.pubkey === undefined) {
242
+ throw new runtime.RequiredError('pubkey', 'Required parameter requestParameters.pubkey was null or undefined when calling validatorTxHistory.');
243
+ }
244
+ const queryParameters = {};
245
+ if (requestParameters.cursor !== undefined) {
246
+ queryParameters['cursor'] = requestParameters.cursor;
247
+ }
248
+ if (requestParameters.pageSize !== undefined) {
249
+ queryParameters['pageSize'] = requestParameters.pageSize;
250
+ }
251
+ const headerParameters = {};
252
+ const response = await this.request({
253
+ path: `/api/v1/validators/{pubkey}/txs`.replace(`{${"pubkey"}}`, encodeURIComponent(String(requestParameters.pubkey))),
254
+ method: 'GET',
255
+ headers: headerParameters,
256
+ query: queryParameters,
257
+ }, initOverrides);
258
+ return new runtime.JSONApiResponse(response, (jsonValue) => (0, models_1.TxHistoryFromJSON)(jsonValue));
259
+ }
260
+ /**
261
+ * Get paginated transaction history for a validator.
262
+ */
263
+ async validatorTxHistory(requestParameters, initOverrides) {
264
+ const response = await this.validatorTxHistoryRaw(requestParameters, initOverrides);
265
+ return await response.value();
266
+ }
237
267
  }
238
268
  exports.V1Api = V1Api;
@@ -31,6 +31,11 @@ export interface GetValidatorRequest {
31
31
  export interface SendTxRequest {
32
32
  body?: EstimateGasRequest;
33
33
  }
34
+ export interface ValidatorTxHistoryRequest {
35
+ pubkey: string;
36
+ cursor?: string;
37
+ pageSize?: number;
38
+ }
34
39
  /**
35
40
  *
36
41
  */
@@ -99,4 +104,12 @@ export declare class V1Api extends runtime.BaseAPI {
99
104
  * Sends raw transaction to be broadcast to the node.
100
105
  */
101
106
  sendTx(requestParameters?: SendTxRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<string>;
107
+ /**
108
+ * Get paginated transaction history for a validator.
109
+ */
110
+ validatorTxHistoryRaw(requestParameters: ValidatorTxHistoryRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<TxHistory>>;
111
+ /**
112
+ * Get paginated transaction history for a validator.
113
+ */
114
+ validatorTxHistory(requestParameters: ValidatorTxHistoryRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<TxHistory>;
102
115
  }
@@ -234,5 +234,35 @@ class V1Api extends runtime.BaseAPI {
234
234
  const response = await this.sendTxRaw(requestParameters, initOverrides);
235
235
  return await response.value();
236
236
  }
237
+ /**
238
+ * Get paginated transaction history for a validator.
239
+ */
240
+ async validatorTxHistoryRaw(requestParameters, initOverrides) {
241
+ if (requestParameters.pubkey === null || requestParameters.pubkey === undefined) {
242
+ throw new runtime.RequiredError('pubkey', 'Required parameter requestParameters.pubkey was null or undefined when calling validatorTxHistory.');
243
+ }
244
+ const queryParameters = {};
245
+ if (requestParameters.cursor !== undefined) {
246
+ queryParameters['cursor'] = requestParameters.cursor;
247
+ }
248
+ if (requestParameters.pageSize !== undefined) {
249
+ queryParameters['pageSize'] = requestParameters.pageSize;
250
+ }
251
+ const headerParameters = {};
252
+ const response = await this.request({
253
+ path: `/api/v1/validators/{pubkey}/txs`.replace(`{${"pubkey"}}`, encodeURIComponent(String(requestParameters.pubkey))),
254
+ method: 'GET',
255
+ headers: headerParameters,
256
+ query: queryParameters,
257
+ }, initOverrides);
258
+ return new runtime.JSONApiResponse(response, (jsonValue) => (0, models_1.TxHistoryFromJSON)(jsonValue));
259
+ }
260
+ /**
261
+ * Get paginated transaction history for a validator.
262
+ */
263
+ async validatorTxHistory(requestParameters, initOverrides) {
264
+ const response = await this.validatorTxHistoryRaw(requestParameters, initOverrides);
265
+ return await response.value();
266
+ }
237
267
  }
238
268
  exports.V1Api = V1Api;
package/dist/types.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  export declare enum Dex {
2
2
  Thor = "THORChain",
3
3
  Zrx = "0x",
4
- CowSwap = "CowSwap"
4
+ CowSwap = "CowSwap",
5
+ Osmosis = "Osmosis"
5
6
  }
6
7
  export interface Fee {
7
8
  assetId: string;
package/dist/types.js CHANGED
@@ -7,6 +7,7 @@ var Dex;
7
7
  Dex["Thor"] = "THORChain";
8
8
  Dex["Zrx"] = "0x";
9
9
  Dex["CowSwap"] = "CowSwap";
10
+ Dex["Osmosis"] = "Osmosis";
10
11
  })(Dex = exports.Dex || (exports.Dex = {}));
11
12
  // these are user facing values, and should be rendered as such
12
13
  var TxStatus;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/unchained-client",
3
- "version": "10.3.0",
3
+ "version": "10.4.1",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "source": "src/index.ts",
@@ -1,3 +0,0 @@
1
- import { JsonFragment } from '@ethersproject/abi/lib/fragments';
2
- declare const thor: JsonFragment[];
3
- export default thor;