@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.
Files changed (35) hide show
  1. package/README.md +72 -0
  2. package/lib/index.d.ts +1 -0
  3. package/lib/index.js +14 -0
  4. package/lib/index.js.map +1 -0
  5. package/lib/providers/blockcypher/blockcypher-api-types.d.ts +96 -0
  6. package/lib/providers/blockcypher/blockcypher-api-types.js +11 -0
  7. package/lib/providers/blockcypher/blockcypher-api-types.js.map +1 -0
  8. package/lib/providers/blockcypher/blockcypher-api.d.ts +69 -0
  9. package/lib/providers/blockcypher/blockcypher-api.js +233 -0
  10. package/lib/providers/blockcypher/blockcypher-api.js.map +1 -0
  11. package/lib/providers/blockcypher/blockcypher-data-provider.d.ts +52 -0
  12. package/lib/providers/blockcypher/blockcypher-data-provider.js +366 -0
  13. package/lib/providers/blockcypher/blockcypher-data-provider.js.map +1 -0
  14. package/lib/providers/haskoin/haskoin-api-types.d.ts +113 -0
  15. package/lib/providers/haskoin/haskoin-api-types.js +14 -0
  16. package/lib/providers/haskoin/haskoin-api-types.js.map +1 -0
  17. package/lib/providers/haskoin/haskoin-api.d.ts +150 -0
  18. package/lib/providers/haskoin/haskoin-api.js +485 -0
  19. package/lib/providers/haskoin/haskoin-api.js.map +1 -0
  20. package/lib/providers/haskoin/haskoin-data-provider.d.ts +37 -0
  21. package/lib/providers/haskoin/haskoin-data-provider.js +269 -0
  22. package/lib/providers/haskoin/haskoin-data-provider.js.map +1 -0
  23. package/lib/providers/index.d.ts +8 -0
  24. package/lib/providers/index.js +34 -0
  25. package/lib/providers/index.js.map +1 -0
  26. package/lib/providers/sochainv3/sochain-api-types.d.ts +101 -0
  27. package/lib/providers/sochainv3/sochain-api-types.js +13 -0
  28. package/lib/providers/sochainv3/sochain-api-types.js.map +1 -0
  29. package/lib/providers/sochainv3/sochain-api.d.ts +113 -0
  30. package/lib/providers/sochainv3/sochain-api.js +354 -0
  31. package/lib/providers/sochainv3/sochain-api.js.map +1 -0
  32. package/lib/providers/sochainv3/sochain-data-provider.d.ts +42 -0
  33. package/lib/providers/sochainv3/sochain-data-provider.js +312 -0
  34. package/lib/providers/sochainv3/sochain-data-provider.js.map +1 -0
  35. package/package.json +45 -0
@@ -0,0 +1,269 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ var __generator = (this && this.__generator) || function (thisArg, body) {
31
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
32
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
33
+ function verb(n) { return function (v) { return step([n, v]); }; }
34
+ function step(op) {
35
+ if (f) throw new TypeError("Generator is already executing.");
36
+ while (_) try {
37
+ 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;
38
+ if (y = 0, t) op = [op[0] & 2, t.value];
39
+ switch (op[0]) {
40
+ case 0: case 1: t = op; break;
41
+ case 4: _.label++; return { value: op[1], done: false };
42
+ case 5: _.label++; y = op[1]; op = [0]; continue;
43
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
44
+ default:
45
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
46
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
47
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
48
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
49
+ if (t[2]) _.ops.pop();
50
+ _.trys.pop(); continue;
51
+ }
52
+ op = body.call(thisArg, _);
53
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
54
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
55
+ }
56
+ };
57
+ Object.defineProperty(exports, "__esModule", { value: true });
58
+ exports.HaskoinProvider = void 0;
59
+ var xchain_client_1 = require("@xchainjs/xchain-client");
60
+ var xchain_util_1 = require("@xchainjs/xchain-util");
61
+ var haskoin = __importStar(require("./haskoin-api"));
62
+ var HaskoinProvider = /** @class */ (function () {
63
+ function HaskoinProvider(baseUrl, chain, asset, assetDecimals, haskoinNetwork) {
64
+ if (baseUrl === void 0) { baseUrl = 'https://api.haskoin.com/'; }
65
+ this.baseUrl = baseUrl;
66
+ this.chain = chain;
67
+ this.asset = asset;
68
+ this.assetDecimals = assetDecimals;
69
+ this.haskoinNetwork = haskoinNetwork;
70
+ this.asset;
71
+ this.chain;
72
+ }
73
+ HaskoinProvider.prototype.broadcastTx = function (txHex) {
74
+ return __awaiter(this, void 0, void 0, function () {
75
+ return __generator(this, function (_a) {
76
+ switch (_a.label) {
77
+ case 0: return [4 /*yield*/, haskoin.broadcastTx({
78
+ haskoinUrl: this.baseUrl,
79
+ haskoinNetwork: this.haskoinNetwork,
80
+ txHex: txHex,
81
+ })];
82
+ case 1: return [2 /*return*/, _a.sent()];
83
+ }
84
+ });
85
+ });
86
+ };
87
+ HaskoinProvider.prototype.getConfirmedUnspentTxs = function (address) {
88
+ return __awaiter(this, void 0, void 0, function () {
89
+ var allUnspent, confirmedUnspent;
90
+ return __generator(this, function (_a) {
91
+ switch (_a.label) {
92
+ case 0: return [4 /*yield*/, haskoin.getUnspentTransactions({
93
+ haskoinUrl: this.baseUrl,
94
+ network: this.haskoinNetwork,
95
+ address: address,
96
+ })];
97
+ case 1:
98
+ allUnspent = _a.sent();
99
+ confirmedUnspent = allUnspent.filter(function (i) { return i.block; }) //if it has a block noumber it's been confirmed
100
+ ;
101
+ return [2 /*return*/, this.mapUTXOs(confirmedUnspent)];
102
+ }
103
+ });
104
+ });
105
+ };
106
+ HaskoinProvider.prototype.getUnspentTxs = function (address) {
107
+ return __awaiter(this, void 0, void 0, function () {
108
+ var allUnspent;
109
+ return __generator(this, function (_a) {
110
+ switch (_a.label) {
111
+ case 0: return [4 /*yield*/, haskoin.getUnspentTxs({
112
+ haskoinUrl: this.baseUrl,
113
+ network: this.haskoinNetwork,
114
+ address: address,
115
+ })];
116
+ case 1:
117
+ allUnspent = _a.sent();
118
+ return [4 /*yield*/, this.mapUTXOs(allUnspent)];
119
+ case 2: return [2 /*return*/, _a.sent()];
120
+ }
121
+ });
122
+ });
123
+ };
124
+ HaskoinProvider.prototype.getBalance = function (address, assets /*ignored*/, confirmedOnly) {
125
+ return __awaiter(this, void 0, void 0, function () {
126
+ var amount;
127
+ return __generator(this, function (_a) {
128
+ switch (_a.label) {
129
+ case 0:
130
+ assets; // TODO can we fix this?
131
+ return [4 /*yield*/, haskoin.getBalance({
132
+ haskoinUrl: this.baseUrl,
133
+ haskoinNetwork: this.haskoinNetwork,
134
+ address: address,
135
+ confirmedOnly: !!confirmedOnly,
136
+ assetDecimals: this.assetDecimals,
137
+ })];
138
+ case 1:
139
+ amount = _a.sent();
140
+ return [2 /*return*/, [{ amount: amount, asset: this.asset }]];
141
+ }
142
+ });
143
+ });
144
+ };
145
+ /**
146
+ * Get transaction history of a given address with pagination options.
147
+ * By default it will return the transaction history of the current wallet.
148
+ *
149
+ * @param {TxHistoryParams} params The options to get transaction history. (optional)
150
+ * @returns {TxsPage} The transaction history.
151
+ */
152
+ HaskoinProvider.prototype.getTransactions = function (params) {
153
+ var _a;
154
+ return __awaiter(this, void 0, void 0, function () {
155
+ var offset, limit, response, txs, result;
156
+ var _this = this;
157
+ return __generator(this, function (_b) {
158
+ switch (_b.label) {
159
+ case 0:
160
+ offset = (_a = params === null || params === void 0 ? void 0 : params.offset) !== null && _a !== void 0 ? _a : 0;
161
+ limit = (params === null || params === void 0 ? void 0 : params.limit) || 10;
162
+ if (offset + limit > 2000)
163
+ throw Error('cannot fetch more than last 2000 txs');
164
+ if (offset < 0 || limit < 0)
165
+ throw Error('ofset and limit must be equal or greater than 0');
166
+ return [4 /*yield*/, haskoin.getTxs({
167
+ address: "" + (params === null || params === void 0 ? void 0 : params.address),
168
+ haskoinUrl: this.baseUrl,
169
+ network: this.haskoinNetwork,
170
+ limit: limit,
171
+ offset: offset,
172
+ })];
173
+ case 1:
174
+ response = _b.sent();
175
+ txs = response.map(function (i) { return _this.mapTransactionToTx(i); });
176
+ result = {
177
+ total: txs.length,
178
+ txs: txs,
179
+ };
180
+ return [2 /*return*/, result];
181
+ }
182
+ });
183
+ });
184
+ };
185
+ HaskoinProvider.prototype.mapTransactionToTx = function (rawTx) {
186
+ var _this = this;
187
+ return {
188
+ asset: this.asset,
189
+ from: rawTx.inputs.map(function (i) { return ({
190
+ from: i.address,
191
+ amount: xchain_util_1.baseAmount(i.value, _this.assetDecimals),
192
+ }); }),
193
+ to: rawTx.outputs
194
+ .filter(function (i) { return i.script !== 'null-data'; }) //filter out op_return outputs
195
+ .map(function (i) { return ({ to: i.address, amount: xchain_util_1.baseAmount(i.value, _this.assetDecimals) }); }),
196
+ date: new Date(rawTx.time),
197
+ type: xchain_client_1.TxType.Transfer,
198
+ hash: rawTx.txid,
199
+ };
200
+ };
201
+ /**
202
+ * Get the transaction details of a given transaction id.
203
+ *
204
+ * @param {string} txId The transaction id.
205
+ * @returns {Tx} The transaction details of the given transaction id.
206
+ */
207
+ HaskoinProvider.prototype.getTransactionData = function (txId) {
208
+ return __awaiter(this, void 0, void 0, function () {
209
+ var rawTx, error_1;
210
+ return __generator(this, function (_a) {
211
+ switch (_a.label) {
212
+ case 0:
213
+ _a.trys.push([0, 2, , 3]);
214
+ return [4 /*yield*/, haskoin.getTx({
215
+ haskoinUrl: this.baseUrl,
216
+ network: this.haskoinNetwork,
217
+ txId: txId,
218
+ })];
219
+ case 1:
220
+ rawTx = _a.sent();
221
+ return [2 /*return*/, this.mapTransactionToTx(rawTx)];
222
+ case 2:
223
+ error_1 = _a.sent();
224
+ console.error(error_1);
225
+ throw error_1;
226
+ case 3: return [2 /*return*/];
227
+ }
228
+ });
229
+ });
230
+ };
231
+ /**
232
+ *
233
+ * @param utxos
234
+ * @returns utxo array
235
+ */
236
+ HaskoinProvider.prototype.mapUTXOs = function (utxos) {
237
+ return __awaiter(this, void 0, void 0, function () {
238
+ var _this = this;
239
+ return __generator(this, function (_a) {
240
+ switch (_a.label) {
241
+ case 0: return [4 /*yield*/, Promise.all(utxos.map(function (utxo) { return __awaiter(_this, void 0, void 0, function () {
242
+ var _a;
243
+ return __generator(this, function (_b) {
244
+ switch (_b.label) {
245
+ case 0:
246
+ _a = {
247
+ hash: utxo.txid,
248
+ index: utxo.index,
249
+ value: xchain_util_1.baseAmount(utxo.value, this.assetDecimals).amount().toNumber(),
250
+ witnessUtxo: {
251
+ value: xchain_util_1.baseAmount(utxo.value, this.assetDecimals).amount().toNumber(),
252
+ script: Buffer.from(utxo.pkscript, 'hex'),
253
+ }
254
+ };
255
+ return [4 /*yield*/, haskoin.getTxHex({ haskoinUrl: this.baseUrl, txId: utxo.txid, network: this.haskoinNetwork })];
256
+ case 1: return [2 /*return*/, (_a.txHex = _b.sent(),
257
+ _a)];
258
+ }
259
+ });
260
+ }); }))];
261
+ case 1: return [2 /*return*/, _a.sent()];
262
+ }
263
+ });
264
+ });
265
+ };
266
+ return HaskoinProvider;
267
+ }());
268
+ exports.HaskoinProvider = HaskoinProvider;
269
+ //# sourceMappingURL=haskoin-data-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"haskoin-data-provider.js","sourceRoot":"","sources":["../../../src/providers/haskoin/haskoin-data-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDASgC;AAChC,qDAAyE;AAEzE,qDAAwC;AAGxC;IAOE,yBACE,OAAoC,EACpC,KAAY,EACZ,KAAY,EACZ,aAAqB,EACrB,cAA8B;QAJ9B,wBAAA,EAAA,oCAAoC;QAMpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAA;QACpC,IAAI,CAAC,KAAK,CAAA;QACV,IAAI,CAAC,KAAK,CAAA;IACZ,CAAC;IACK,qCAAW,GAAjB,UAAkB,KAAa;;;;4BACtB,qBAAM,OAAO,CAAC,WAAW,CAAC;4BAC/B,UAAU,EAAE,IAAI,CAAC,OAAO;4BACxB,cAAc,EAAE,IAAI,CAAC,c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U,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;4CACrE,WAAW,EAAE;gDACX,KAAK,EAAE,wBAAU,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;gDACrE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC;6CAC1C;;wCACM,qBAAM,OAAO,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,EAAA;4CARlF,sBAAA,CAQxB,QAAK,GAAE,SAAmG;+CAC1G,EAAA;;;6BAAA,CAAC,CACJ,EAAA;4BAXD,sBAAO,SAWN,EAAA;;;;KACF;IACH,sBAAC;AAAD,CAAC,AA/ID,IA+IC;AA/IY,0CAAe"}
@@ -0,0 +1,8 @@
1
+ export * from './sochainv3/sochain-api-types';
2
+ export * from './sochainv3/sochain-api';
3
+ export * from './sochainv3/sochain-data-provider';
4
+ export { AddressDTO, AddressParams, AddressUTXO, BalanceData, GetTxsDTO, HaskoinNetwork, HaskoinResponse, Transaction, TxConfirmedStatus, TxHashParams, } from './haskoin/haskoin-api-types';
5
+ export { getAddress, getBalance, getConfirmedTxStatus, getConfirmedUnspentTxs, getAccount, getIsTxConfirmed, getTx, getTxs, getUnspentTxs, broadcastTx, } from './haskoin/haskoin-api';
6
+ export * from './haskoin/haskoin-data-provider';
7
+ export * from './blockcypher/blockcypher-data-provider';
8
+ export { BlockcypherNetwork } from './blockcypher/blockcypher-api-types';
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.BlockcypherNetwork = exports.broadcastTx = exports.getUnspentTxs = exports.getTxs = exports.getTx = exports.getIsTxConfirmed = exports.getAccount = exports.getConfirmedUnspentTxs = exports.getConfirmedTxStatus = exports.getBalance = exports.getAddress = exports.HaskoinNetwork = void 0;
14
+ __exportStar(require("./sochainv3/sochain-api-types"), exports);
15
+ __exportStar(require("./sochainv3/sochain-api"), exports);
16
+ __exportStar(require("./sochainv3/sochain-data-provider"), exports);
17
+ var haskoin_api_types_1 = require("./haskoin/haskoin-api-types");
18
+ Object.defineProperty(exports, "HaskoinNetwork", { enumerable: true, get: function () { return haskoin_api_types_1.HaskoinNetwork; } });
19
+ var haskoin_api_1 = require("./haskoin/haskoin-api");
20
+ Object.defineProperty(exports, "getAddress", { enumerable: true, get: function () { return haskoin_api_1.getAddress; } });
21
+ Object.defineProperty(exports, "getBalance", { enumerable: true, get: function () { return haskoin_api_1.getBalance; } });
22
+ Object.defineProperty(exports, "getConfirmedTxStatus", { enumerable: true, get: function () { return haskoin_api_1.getConfirmedTxStatus; } });
23
+ Object.defineProperty(exports, "getConfirmedUnspentTxs", { enumerable: true, get: function () { return haskoin_api_1.getConfirmedUnspentTxs; } });
24
+ Object.defineProperty(exports, "getAccount", { enumerable: true, get: function () { return haskoin_api_1.getAccount; } });
25
+ Object.defineProperty(exports, "getIsTxConfirmed", { enumerable: true, get: function () { return haskoin_api_1.getIsTxConfirmed; } });
26
+ Object.defineProperty(exports, "getTx", { enumerable: true, get: function () { return haskoin_api_1.getTx; } });
27
+ Object.defineProperty(exports, "getTxs", { enumerable: true, get: function () { return haskoin_api_1.getTxs; } });
28
+ Object.defineProperty(exports, "getUnspentTxs", { enumerable: true, get: function () { return haskoin_api_1.getUnspentTxs; } });
29
+ Object.defineProperty(exports, "broadcastTx", { enumerable: true, get: function () { return haskoin_api_1.broadcastTx; } });
30
+ __exportStar(require("./haskoin/haskoin-data-provider"), exports);
31
+ __exportStar(require("./blockcypher/blockcypher-data-provider"), exports);
32
+ var blockcypher_api_types_1 = require("./blockcypher/blockcypher-api-types");
33
+ Object.defineProperty(exports, "BlockcypherNetwork", { enumerable: true, get: function () { return blockcypher_api_types_1.BlockcypherNetwork; } });
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,gEAA6C;AAC7C,0DAAuC;AACvC,oEAAiD;AACjD,iEAWoC;AALlC,mHAAA,cAAc,OAAA;AAMhB,qDAW8B;AAV5B,yGAAA,UAAU,OAAA;AACV,yGAAA,UAAU,OAAA;AACV,mHAAA,oBAAoB,OAAA;AACpB,qHAAA,sBAAsB,OAAA;AACtB,yGAAA,UAAU,OAAA;AACV,+GAAA,gBAAgB,OAAA;AAChB,oGAAA,KAAK,OAAA;AACL,qGAAA,MAAM,OAAA;AACN,4GAAA,aAAa,OAAA;AACb,0GAAA,WAAW,OAAA;AAEb,kEAA+C;AAC/C,0EAAuD;AACvD,6EAAwE;AAA/D,2HAAA,kBAAkB,OAAA"}
@@ -0,0 +1,101 @@
1
+ import { TxHash } from '@xchainjs/xchain-client';
2
+ export declare enum SochainNetwork {
3
+ BTC = "BTC",
4
+ BTCTEST = "BTCTEST",
5
+ LTC = "LTC",
6
+ LTCTEST = "LTCTEST",
7
+ DOGE = "DOGE",
8
+ DOGETEST = "DOGETEST"
9
+ }
10
+ export declare type AddressParams = {
11
+ apiKey: string;
12
+ sochainUrl: string;
13
+ network: SochainNetwork;
14
+ address: string;
15
+ page: number;
16
+ };
17
+ export declare type BalanceParams = {
18
+ apiKey: string;
19
+ sochainUrl: string;
20
+ network: SochainNetwork;
21
+ address: string;
22
+ confirmedOnly: boolean;
23
+ assetDecimals: number;
24
+ };
25
+ export declare type TxHashParams = {
26
+ apiKey: string;
27
+ sochainUrl: string;
28
+ network: SochainNetwork;
29
+ hash: TxHash;
30
+ };
31
+ export declare type TxBroadcastParams = {
32
+ apiKey: string;
33
+ sochainUrl: string;
34
+ network: SochainNetwork;
35
+ txHex: string;
36
+ };
37
+ export interface SochainResponse<T> {
38
+ data: T;
39
+ status: string;
40
+ }
41
+ export interface TxIO {
42
+ index: number;
43
+ value: string;
44
+ address: string;
45
+ type?: string;
46
+ script: string;
47
+ }
48
+ export interface Transaction {
49
+ hash: string;
50
+ block_hash: string;
51
+ confirmations: number;
52
+ time: number;
53
+ tx_hex: string;
54
+ inputs: TxIO[];
55
+ outputs: TxIO[];
56
+ }
57
+ export declare type AddressUTXO = {
58
+ hash: string;
59
+ index: number;
60
+ script: string;
61
+ address: string;
62
+ tx_hex: string;
63
+ value: string;
64
+ block: number;
65
+ };
66
+ export declare type AddressTxDTO = {
67
+ hash: string;
68
+ block: number;
69
+ time: number;
70
+ };
71
+ export declare type AddressDTO = {
72
+ network: string;
73
+ address: string;
74
+ balance: string;
75
+ received_value: string;
76
+ pending_value: string;
77
+ total_txs: number;
78
+ };
79
+ export declare type GetTxsDTO = {
80
+ transactions: AddressTxDTO[];
81
+ };
82
+ export declare type GetBalanceDTO = {
83
+ confirmed: string;
84
+ unconfirmed: string;
85
+ };
86
+ export declare type BroadcastDTO = {
87
+ tx_hex: string;
88
+ };
89
+ export declare type UnspentTxsDTO = {
90
+ outputs: AddressUTXO[];
91
+ };
92
+ export declare type BroadcastTransfer = {
93
+ network: string;
94
+ txid: string;
95
+ };
96
+ export declare type TxConfirmedStatus = {
97
+ network: string;
98
+ txid: string;
99
+ confirmations: number;
100
+ is_confirmed: boolean;
101
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SochainNetwork = void 0;
4
+ var SochainNetwork;
5
+ (function (SochainNetwork) {
6
+ SochainNetwork["BTC"] = "BTC";
7
+ SochainNetwork["BTCTEST"] = "BTCTEST";
8
+ SochainNetwork["LTC"] = "LTC";
9
+ SochainNetwork["LTCTEST"] = "LTCTEST";
10
+ SochainNetwork["DOGE"] = "DOGE";
11
+ SochainNetwork["DOGETEST"] = "DOGETEST";
12
+ })(SochainNetwork = exports.SochainNetwork || (exports.SochainNetwork = {}));
13
+ //# sourceMappingURL=sochain-api-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sochain-api-types.js","sourceRoot":"","sources":["../../../src/providers/sochainv3/sochain-api-types.ts"],"names":[],"mappings":";;;AAEA,IAAY,cAOX;AAPD,WAAY,cAAc;IACxB,6BAAW,CAAA;IACX,qCAAmB,CAAA;IACnB,6BAAW,CAAA;IACX,qCAAmB,CAAA;IACnB,+BAAa,CAAA;IACb,uCAAqB,CAAA;AACvB,CAAC,EAPW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAOzB"}
@@ -0,0 +1,113 @@
1
+ import { TxHash } from '@xchainjs/xchain-client';
2
+ import { BaseAmount } from '@xchainjs/xchain-util';
3
+ import { AddressDTO, AddressParams, AddressUTXO, BalanceParams, GetTxsDTO, SochainNetwork, Transaction, TxConfirmedStatus, TxHashParams } from './sochain-api-types';
4
+ /**
5
+ * Get address information.
6
+ *
7
+ * @param {string} sochainUrl The sochain node url.
8
+ * @param {string} network
9
+ * @param {string} address
10
+ * @returns {AddressDTO}
11
+ */
12
+ export declare const getAddress: ({ apiKey, sochainUrl, network, address }: AddressParams) => Promise<AddressDTO>;
13
+ /**
14
+ * Get transaction by hash.
15
+ *
16
+ * @see https://sochain.com/api#get-tx
17
+ *
18
+ * @param {string} sochainUrl The sochain node url.
19
+ * @param {string} network network id
20
+ * @param {string} hash The transaction hash.
21
+ * @returns {Transactions}
22
+ */
23
+ export declare const getTx: ({ apiKey, sochainUrl, network, hash }: TxHashParams) => Promise<Transaction>;
24
+ /**
25
+ * Get transactions
26
+ *
27
+ * @see https://sochain.com/api#get-tx
28
+ *
29
+ * @param {string} sochainUrl The sochain node url.
30
+ * @param {string} network network id
31
+ * @param {string} hash The transaction hash.
32
+ * @returns {Transactions}
33
+ */
34
+ export declare const getTxs: ({ apiKey, address, sochainUrl, network, page, }: {
35
+ apiKey: string;
36
+ address: string;
37
+ sochainUrl: string;
38
+ network: SochainNetwork;
39
+ page: number;
40
+ }) => Promise<GetTxsDTO>;
41
+ /**
42
+ * Get address balance.
43
+ *
44
+ * @see https://sochain.com/api#get-balance
45
+ *
46
+ * @param {string} sochainUrl The sochain node url.
47
+ * @param {string} network Network
48
+ * @param {string} address Address
49
+ * @param {boolean} confirmedOnly Flag whether to get balances of confirmed txs only or for all
50
+ * @returns {number}
51
+ */
52
+ export declare const getBalance: ({ apiKey, sochainUrl, network, address, confirmedOnly, assetDecimals, }: BalanceParams) => Promise<BaseAmount>;
53
+ /**
54
+ * Get unspent txs
55
+ *
56
+ * @see https://sochain.com/api#get-unspent-tx
57
+ *
58
+ * @param {string} sochainUrl The sochain node url.
59
+ * @param {string} network
60
+ * @param {string} address
61
+ * @returns {AddressUTXO[]}
62
+ */
63
+ export declare const getUnspentTxs: ({ apiKey, sochainUrl, network, address, page, }: AddressParams) => Promise<AddressUTXO[]>;
64
+ /**
65
+ * Get Tx Confirmation status
66
+ *
67
+ * @see https://sochain.com/api#get-is-tx-confirmed
68
+ *
69
+ * @param {string} sochainUrl The sochain node url.
70
+ * @param {Network} network
71
+ * @param {string} hash tx id
72
+ * @returns {TxConfirmedStatus}
73
+ */
74
+ export declare const getIsTxConfirmed: ({ apiKey, sochainUrl, network, hash, }: TxHashParams) => Promise<TxConfirmedStatus>;
75
+ /**
76
+ * Helper to get `confirmed` status of a tx.
77
+ *
78
+ * It will get it from cache or try to get it from Sochain (if not cached before)
79
+ */
80
+ export declare const getConfirmedTxStatus: ({ apiKey, txHash, sochainUrl, network, }: {
81
+ apiKey: string;
82
+ sochainUrl: string;
83
+ txHash: TxHash;
84
+ network: SochainNetwork;
85
+ }) => Promise<boolean>;
86
+ /**
87
+ * Get unspent txs and filter out pending UTXOs
88
+ *
89
+ * @see https://sochain.com/api#get-unspent-tx
90
+ *
91
+ * @param {string} sochainUrl The sochain node url.
92
+ * @param {Network} network
93
+ * @param {string} address
94
+ * @returns {AddressUTXO[]}
95
+ */
96
+ export declare const getConfirmedUnspentTxs: ({ apiKey, sochainUrl, network, address, }: AddressParams) => Promise<AddressUTXO[]>;
97
+ /**
98
+ * Get address balance.
99
+ *
100
+ * @see https://sochain.com/api#get-balance
101
+ *
102
+ * @param {string} sochainUrl The sochain node url.
103
+ * @param {string} network Network
104
+ * @param {string} address Address
105
+ * @param {boolean} confirmedOnly Flag whether to get balances of confirmed txs only or for all
106
+ * @returns {number}
107
+ */
108
+ export declare const broadcastTx: ({ apiKey, sochainUrl, network, txHex, }: {
109
+ apiKey: string;
110
+ sochainUrl: string;
111
+ txHex: string;
112
+ network: SochainNetwork;
113
+ }) => Promise<TxHash>;