@xchainjs/xchain-utxo-providers 0.1.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/README.md +72 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +14 -0
- package/lib/index.js.map +1 -0
- package/lib/providers/blockcypher/blockcypher-api-types.d.ts +96 -0
- package/lib/providers/blockcypher/blockcypher-api-types.js +11 -0
- package/lib/providers/blockcypher/blockcypher-api-types.js.map +1 -0
- package/lib/providers/blockcypher/blockcypher-api.d.ts +69 -0
- package/lib/providers/blockcypher/blockcypher-api.js +233 -0
- package/lib/providers/blockcypher/blockcypher-api.js.map +1 -0
- package/lib/providers/blockcypher/blockcypher-data-provider.d.ts +52 -0
- package/lib/providers/blockcypher/blockcypher-data-provider.js +366 -0
- package/lib/providers/blockcypher/blockcypher-data-provider.js.map +1 -0
- package/lib/providers/haskoin/haskoin-api-types.d.ts +113 -0
- package/lib/providers/haskoin/haskoin-api-types.js +14 -0
- package/lib/providers/haskoin/haskoin-api-types.js.map +1 -0
- package/lib/providers/haskoin/haskoin-api.d.ts +150 -0
- package/lib/providers/haskoin/haskoin-api.js +485 -0
- package/lib/providers/haskoin/haskoin-api.js.map +1 -0
- package/lib/providers/haskoin/haskoin-data-provider.d.ts +37 -0
- package/lib/providers/haskoin/haskoin-data-provider.js +269 -0
- package/lib/providers/haskoin/haskoin-data-provider.js.map +1 -0
- package/lib/providers/index.d.ts +8 -0
- package/lib/providers/index.js +34 -0
- package/lib/providers/index.js.map +1 -0
- package/lib/providers/sochainv3/sochain-api-types.d.ts +101 -0
- package/lib/providers/sochainv3/sochain-api-types.js +13 -0
- package/lib/providers/sochainv3/sochain-api-types.js.map +1 -0
- package/lib/providers/sochainv3/sochain-api.d.ts +113 -0
- package/lib/providers/sochainv3/sochain-api.js +354 -0
- package/lib/providers/sochainv3/sochain-api.js.map +1 -0
- package/lib/providers/sochainv3/sochain-data-provider.d.ts +42 -0
- package/lib/providers/sochainv3/sochain-data-provider.js +312 -0
- package/lib/providers/sochainv3/sochain-data-provider.js.map +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.broadcastTx = exports.getConfirmedUnspentTxs = exports.getConfirmedTxStatus = exports.getIsTxConfirmed = exports.getUnspentTxs = exports.getBalance = exports.getTxs = exports.getTx = exports.getAddress = void 0;
|
|
43
|
+
var xchain_util_1 = require("@xchainjs/xchain-util");
|
|
44
|
+
var axios_1 = __importDefault(require("axios"));
|
|
45
|
+
/**
|
|
46
|
+
* Get address information.
|
|
47
|
+
*
|
|
48
|
+
* @param {string} sochainUrl The sochain node url.
|
|
49
|
+
* @param {string} network
|
|
50
|
+
* @param {string} address
|
|
51
|
+
* @returns {AddressDTO}
|
|
52
|
+
*/
|
|
53
|
+
var getAddress = function (_a) {
|
|
54
|
+
var apiKey = _a.apiKey, sochainUrl = _a.sochainUrl, network = _a.network, address = _a.address;
|
|
55
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var url, response, addressResponse;
|
|
57
|
+
return __generator(this, function (_b) {
|
|
58
|
+
switch (_b.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
url = sochainUrl + "/address_summary/" + network + "/" + address;
|
|
61
|
+
return [4 /*yield*/, axios_1.default.get(url, { headers: { 'API-KEY': apiKey } })];
|
|
62
|
+
case 1:
|
|
63
|
+
response = _b.sent();
|
|
64
|
+
addressResponse = response.data;
|
|
65
|
+
return [2 /*return*/, addressResponse.data];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
exports.getAddress = getAddress;
|
|
71
|
+
/**
|
|
72
|
+
* Get transaction by hash.
|
|
73
|
+
*
|
|
74
|
+
* @see https://sochain.com/api#get-tx
|
|
75
|
+
*
|
|
76
|
+
* @param {string} sochainUrl The sochain node url.
|
|
77
|
+
* @param {string} network network id
|
|
78
|
+
* @param {string} hash The transaction hash.
|
|
79
|
+
* @returns {Transactions}
|
|
80
|
+
*/
|
|
81
|
+
var getTx = function (_a) {
|
|
82
|
+
var apiKey = _a.apiKey, sochainUrl = _a.sochainUrl, network = _a.network, hash = _a.hash;
|
|
83
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
84
|
+
var url, response, tx;
|
|
85
|
+
return __generator(this, function (_b) {
|
|
86
|
+
switch (_b.label) {
|
|
87
|
+
case 0:
|
|
88
|
+
url = sochainUrl + "/transaction/" + network + "/" + hash;
|
|
89
|
+
return [4 /*yield*/, axios_1.default.get(url, { headers: { 'API-KEY': apiKey } })];
|
|
90
|
+
case 1:
|
|
91
|
+
response = _b.sent();
|
|
92
|
+
tx = response.data;
|
|
93
|
+
return [2 /*return*/, tx.data];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
exports.getTx = getTx;
|
|
99
|
+
/**
|
|
100
|
+
* Get transactions
|
|
101
|
+
*
|
|
102
|
+
* @see https://sochain.com/api#get-tx
|
|
103
|
+
*
|
|
104
|
+
* @param {string} sochainUrl The sochain node url.
|
|
105
|
+
* @param {string} network network id
|
|
106
|
+
* @param {string} hash The transaction hash.
|
|
107
|
+
* @returns {Transactions}
|
|
108
|
+
*/
|
|
109
|
+
var getTxs = function (_a) {
|
|
110
|
+
var apiKey = _a.apiKey, address = _a.address, sochainUrl = _a.sochainUrl, network = _a.network, page = _a.page;
|
|
111
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
112
|
+
var url, response, txs;
|
|
113
|
+
return __generator(this, function (_b) {
|
|
114
|
+
switch (_b.label) {
|
|
115
|
+
case 0:
|
|
116
|
+
url = sochainUrl + "/transactions/" + network + "/" + address + "/" + page //TODO support paging
|
|
117
|
+
;
|
|
118
|
+
return [4 /*yield*/, axios_1.default.get(url, { headers: { 'API-KEY': apiKey } })];
|
|
119
|
+
case 1:
|
|
120
|
+
response = _b.sent();
|
|
121
|
+
txs = response.data;
|
|
122
|
+
return [2 /*return*/, txs.data];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
exports.getTxs = getTxs;
|
|
128
|
+
/**
|
|
129
|
+
* Get address balance.
|
|
130
|
+
*
|
|
131
|
+
* @see https://sochain.com/api#get-balance
|
|
132
|
+
*
|
|
133
|
+
* @param {string} sochainUrl The sochain node url.
|
|
134
|
+
* @param {string} network Network
|
|
135
|
+
* @param {string} address Address
|
|
136
|
+
* @param {boolean} confirmedOnly Flag whether to get balances of confirmed txs only or for all
|
|
137
|
+
* @returns {number}
|
|
138
|
+
*/
|
|
139
|
+
var getBalance = function (_a) {
|
|
140
|
+
var apiKey = _a.apiKey, sochainUrl = _a.sochainUrl, network = _a.network, address = _a.address, confirmedOnly = _a.confirmedOnly, assetDecimals = _a.assetDecimals;
|
|
141
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
142
|
+
var url, response, balanceResponse, confirmed, unconfirmed, netAmt, result;
|
|
143
|
+
return __generator(this, function (_b) {
|
|
144
|
+
switch (_b.label) {
|
|
145
|
+
case 0:
|
|
146
|
+
url = sochainUrl + "/balance/" + network + "/" + address;
|
|
147
|
+
return [4 /*yield*/, axios_1.default.get(url, { headers: { 'API-KEY': apiKey } })];
|
|
148
|
+
case 1:
|
|
149
|
+
response = _b.sent();
|
|
150
|
+
balanceResponse = response.data;
|
|
151
|
+
confirmed = xchain_util_1.assetAmount(balanceResponse.data.confirmed, assetDecimals);
|
|
152
|
+
unconfirmed = xchain_util_1.assetAmount(balanceResponse.data.unconfirmed, assetDecimals);
|
|
153
|
+
netAmt = confirmedOnly ? confirmed : confirmed.plus(unconfirmed);
|
|
154
|
+
result = xchain_util_1.assetToBase(netAmt);
|
|
155
|
+
return [2 /*return*/, result];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
exports.getBalance = getBalance;
|
|
161
|
+
/**
|
|
162
|
+
* Get unspent txs
|
|
163
|
+
*
|
|
164
|
+
* @see https://sochain.com/api#get-unspent-tx
|
|
165
|
+
*
|
|
166
|
+
* @param {string} sochainUrl The sochain node url.
|
|
167
|
+
* @param {string} network
|
|
168
|
+
* @param {string} address
|
|
169
|
+
* @returns {AddressUTXO[]}
|
|
170
|
+
*/
|
|
171
|
+
var getUnspentTxs = function (_a) {
|
|
172
|
+
var apiKey = _a.apiKey, sochainUrl = _a.sochainUrl, network = _a.network, address = _a.address, page = _a.page;
|
|
173
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
174
|
+
var url, resp, response, txs, nextBatch;
|
|
175
|
+
return __generator(this, function (_b) {
|
|
176
|
+
switch (_b.label) {
|
|
177
|
+
case 0:
|
|
178
|
+
url = [sochainUrl, 'unspent_outputs', network, address, page].filter(function (v) { return !!v; }).join('/');
|
|
179
|
+
return [4 /*yield*/, axios_1.default.get(url, { headers: { 'API-KEY': apiKey } })];
|
|
180
|
+
case 1:
|
|
181
|
+
resp = _b.sent();
|
|
182
|
+
response = resp.data;
|
|
183
|
+
txs = response.data.outputs;
|
|
184
|
+
if (!(txs.length === 10)) return [3 /*break*/, 3];
|
|
185
|
+
return [4 /*yield*/, exports.getUnspentTxs({
|
|
186
|
+
apiKey: apiKey,
|
|
187
|
+
sochainUrl: sochainUrl,
|
|
188
|
+
network: network,
|
|
189
|
+
address: address,
|
|
190
|
+
page: page + 1,
|
|
191
|
+
})];
|
|
192
|
+
case 2:
|
|
193
|
+
nextBatch = _b.sent();
|
|
194
|
+
return [2 /*return*/, txs.concat(nextBatch)];
|
|
195
|
+
case 3: return [2 /*return*/, txs];
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
exports.getUnspentTxs = getUnspentTxs;
|
|
201
|
+
/**
|
|
202
|
+
* Get Tx Confirmation status
|
|
203
|
+
*
|
|
204
|
+
* @see https://sochain.com/api#get-is-tx-confirmed
|
|
205
|
+
*
|
|
206
|
+
* @param {string} sochainUrl The sochain node url.
|
|
207
|
+
* @param {Network} network
|
|
208
|
+
* @param {string} hash tx id
|
|
209
|
+
* @returns {TxConfirmedStatus}
|
|
210
|
+
*/
|
|
211
|
+
var getIsTxConfirmed = function (_a) {
|
|
212
|
+
var apiKey = _a.apiKey, sochainUrl = _a.sochainUrl, network = _a.network, hash = _a.hash;
|
|
213
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
214
|
+
var tx;
|
|
215
|
+
return __generator(this, function (_b) {
|
|
216
|
+
switch (_b.label) {
|
|
217
|
+
case 0: return [4 /*yield*/, exports.getTx({ apiKey: apiKey, sochainUrl: sochainUrl, network: network, hash: hash })];
|
|
218
|
+
case 1:
|
|
219
|
+
tx = _b.sent();
|
|
220
|
+
return [2 /*return*/, {
|
|
221
|
+
network: network,
|
|
222
|
+
txid: hash,
|
|
223
|
+
confirmations: tx.confirmations,
|
|
224
|
+
is_confirmed: tx.confirmations >= 1,
|
|
225
|
+
}];
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
exports.getIsTxConfirmed = getIsTxConfirmed;
|
|
231
|
+
/**
|
|
232
|
+
* List of confirmed txs
|
|
233
|
+
*
|
|
234
|
+
* Stores a list of confirmed txs (hashes) in memory to avoid requesting same data
|
|
235
|
+
*/
|
|
236
|
+
var confirmedTxs = [];
|
|
237
|
+
/**
|
|
238
|
+
* Helper to get `confirmed` status of a tx.
|
|
239
|
+
*
|
|
240
|
+
* It will get it from cache or try to get it from Sochain (if not cached before)
|
|
241
|
+
*/
|
|
242
|
+
var getConfirmedTxStatus = function (_a) {
|
|
243
|
+
var apiKey = _a.apiKey, txHash = _a.txHash, sochainUrl = _a.sochainUrl, network = _a.network;
|
|
244
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
245
|
+
var is_confirmed;
|
|
246
|
+
return __generator(this, function (_b) {
|
|
247
|
+
switch (_b.label) {
|
|
248
|
+
case 0:
|
|
249
|
+
// try to get it from cache
|
|
250
|
+
if (confirmedTxs.includes(txHash))
|
|
251
|
+
return [2 /*return*/, true
|
|
252
|
+
// or get status from Sochain
|
|
253
|
+
];
|
|
254
|
+
return [4 /*yield*/, exports.getIsTxConfirmed({
|
|
255
|
+
apiKey: apiKey,
|
|
256
|
+
sochainUrl: sochainUrl,
|
|
257
|
+
network: network,
|
|
258
|
+
hash: txHash,
|
|
259
|
+
})
|
|
260
|
+
// cache status
|
|
261
|
+
];
|
|
262
|
+
case 1:
|
|
263
|
+
is_confirmed = (_b.sent()).is_confirmed;
|
|
264
|
+
// cache status
|
|
265
|
+
confirmedTxs.push(txHash);
|
|
266
|
+
return [2 /*return*/, is_confirmed];
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
exports.getConfirmedTxStatus = getConfirmedTxStatus;
|
|
272
|
+
/**
|
|
273
|
+
* Get unspent txs and filter out pending UTXOs
|
|
274
|
+
*
|
|
275
|
+
* @see https://sochain.com/api#get-unspent-tx
|
|
276
|
+
*
|
|
277
|
+
* @param {string} sochainUrl The sochain node url.
|
|
278
|
+
* @param {Network} network
|
|
279
|
+
* @param {string} address
|
|
280
|
+
* @returns {AddressUTXO[]}
|
|
281
|
+
*/
|
|
282
|
+
var getConfirmedUnspentTxs = function (_a) {
|
|
283
|
+
var apiKey = _a.apiKey, sochainUrl = _a.sochainUrl, network = _a.network, address = _a.address;
|
|
284
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
285
|
+
var txs, confirmedUTXOs;
|
|
286
|
+
return __generator(this, function (_b) {
|
|
287
|
+
switch (_b.label) {
|
|
288
|
+
case 0: return [4 /*yield*/, exports.getUnspentTxs({
|
|
289
|
+
apiKey: apiKey,
|
|
290
|
+
sochainUrl: sochainUrl,
|
|
291
|
+
network: network,
|
|
292
|
+
address: address,
|
|
293
|
+
page: 1,
|
|
294
|
+
})];
|
|
295
|
+
case 1:
|
|
296
|
+
txs = _b.sent();
|
|
297
|
+
confirmedUTXOs = [];
|
|
298
|
+
return [4 /*yield*/, Promise.all(txs.map(function (tx) { return __awaiter(void 0, void 0, void 0, function () {
|
|
299
|
+
var confirmed;
|
|
300
|
+
return __generator(this, function (_a) {
|
|
301
|
+
switch (_a.label) {
|
|
302
|
+
case 0: return [4 /*yield*/, exports.getConfirmedTxStatus({
|
|
303
|
+
apiKey: apiKey,
|
|
304
|
+
sochainUrl: sochainUrl,
|
|
305
|
+
network: network,
|
|
306
|
+
txHash: tx.hash,
|
|
307
|
+
})];
|
|
308
|
+
case 1:
|
|
309
|
+
confirmed = _a.sent();
|
|
310
|
+
if (confirmed) {
|
|
311
|
+
confirmedUTXOs.push(tx);
|
|
312
|
+
}
|
|
313
|
+
return [2 /*return*/];
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
}); }))];
|
|
317
|
+
case 2:
|
|
318
|
+
_b.sent();
|
|
319
|
+
return [2 /*return*/, confirmedUTXOs];
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
exports.getConfirmedUnspentTxs = getConfirmedUnspentTxs;
|
|
325
|
+
/**
|
|
326
|
+
* Get address balance.
|
|
327
|
+
*
|
|
328
|
+
* @see https://sochain.com/api#get-balance
|
|
329
|
+
*
|
|
330
|
+
* @param {string} sochainUrl The sochain node url.
|
|
331
|
+
* @param {string} network Network
|
|
332
|
+
* @param {string} address Address
|
|
333
|
+
* @param {boolean} confirmedOnly Flag whether to get balances of confirmed txs only or for all
|
|
334
|
+
* @returns {number}
|
|
335
|
+
*/
|
|
336
|
+
var broadcastTx = function (_a) {
|
|
337
|
+
var apiKey = _a.apiKey, sochainUrl = _a.sochainUrl, network = _a.network, txHex = _a.txHex;
|
|
338
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
339
|
+
var url, response, broadcastResponse;
|
|
340
|
+
return __generator(this, function (_b) {
|
|
341
|
+
switch (_b.label) {
|
|
342
|
+
case 0:
|
|
343
|
+
url = sochainUrl + "/broadcast_transaction/" + network;
|
|
344
|
+
return [4 /*yield*/, axios_1.default.post(url, { tx_hex: txHex }, { headers: { 'API-KEY': apiKey } })];
|
|
345
|
+
case 1:
|
|
346
|
+
response = _b.sent();
|
|
347
|
+
broadcastResponse = response.data;
|
|
348
|
+
return [2 /*return*/, broadcastResponse.tx_hex];
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
};
|
|
353
|
+
exports.broadcastTx = broadcastTx;
|
|
354
|
+
//# sourceMappingURL=sochain-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sochain-api.js","sourceRoot":"","sources":["../../../src/providers/sochainv3/sochain-api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qDAA4E;AAC5E,gDAAyB;AAkBzB;;;;;;;GAOG;AACI,IAAM,UAAU,GAAG,UAAO,EAAuD;QAArD,MAAM,YAAA,EAAE,UAAU,gBAAA,EAAE,OAAO,aAAA,EAAE,OAAO,aAAA;;;;;;oBAC/D,GAAG,GAAM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;AAhCY,QAAA,sBAAsB,0BAgClC;AAED;;;;;;;;;;GAUG;AACI,IAAM,WAAW,GAAG,UAAO,EAUjC;QATC,MAAM,YAAA,EACN,UAAU,gBAAA,EACV,OAAO,aAAA,EACP,KAAK,WAAA;;;;;;oBAOC,GAAG,GAAM,UAAU,+BAA0B,OAAS,CAAA;oBAC3C,qBAAM,eAAK,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC,EAAA;;oBAAvF,QAAQ,GAAG,SAA4E;oBACvF,iBAAiB,GAAiB,QAAQ,CAAC,IAAI,CAAA;oBACrD,sBAAO,iBAAiB,CAAC,MAAM,EAAA;;;;CAChC,CAAA;AAfY,QAAA,WAAW,eAevB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Balance, Tx, TxHash, TxHistoryParams, TxsPage, UTXO, UtxoOnlineDataProvider } from '@xchainjs/xchain-client';
|
|
2
|
+
import { Address, Asset, Chain } from '@xchainjs/xchain-util';
|
|
3
|
+
import { SochainNetwork } from './sochain-api-types';
|
|
4
|
+
export declare class SochainProvider implements UtxoOnlineDataProvider {
|
|
5
|
+
private baseUrl;
|
|
6
|
+
private _apiKey;
|
|
7
|
+
private chain;
|
|
8
|
+
private asset;
|
|
9
|
+
private assetDecimals;
|
|
10
|
+
private sochainNetwork;
|
|
11
|
+
constructor(baseUrl: string, apiKey: string, chain: Chain, asset: Asset, assetDecimals: number, sochainNetwork: SochainNetwork);
|
|
12
|
+
get apiKey(): string;
|
|
13
|
+
set apiKey(value: string);
|
|
14
|
+
broadcastTx(txHex: string): Promise<TxHash>;
|
|
15
|
+
getConfirmedUnspentTxs(address: string): Promise<UTXO[]>;
|
|
16
|
+
getUnspentTxs(address: string): Promise<UTXO[]>;
|
|
17
|
+
getBalance(address: Address, assets?: Asset[], confirmedOnly?: boolean): Promise<Balance[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Get transaction history of a given address with pagination options.
|
|
20
|
+
* By default it will return the transaction history of the current wallet.
|
|
21
|
+
*
|
|
22
|
+
* @param {TxHistoryParams} params The options to get transaction history. (optional)
|
|
23
|
+
* @returns {TxsPage} The transaction history.
|
|
24
|
+
*/
|
|
25
|
+
getTransactions(params?: TxHistoryParams): Promise<TxsPage>;
|
|
26
|
+
/**
|
|
27
|
+
* Get the transaction details of a given transaction id.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} txId The transaction id.
|
|
30
|
+
* @returns {Tx} The transaction details of the given transaction id.
|
|
31
|
+
*/
|
|
32
|
+
getTransactionData(txId: string): Promise<Tx>;
|
|
33
|
+
private mapUTXOs;
|
|
34
|
+
/**
|
|
35
|
+
* helper function tto limit adding to an array
|
|
36
|
+
*
|
|
37
|
+
* @param arr array to be added to
|
|
38
|
+
* @param toAdd elements to add
|
|
39
|
+
* @param limit do not add more than this limit
|
|
40
|
+
*/
|
|
41
|
+
private addArrayUpToLimit;
|
|
42
|
+
}
|