@airgap/groestlcoin 0.13.45-beta.3 → 0.13.45-beta.5
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/package.json +5 -5
- package/v0/index.js +5 -5
- package/v0/index.js.map +1 -1
- package/v0/protocol/GroestlcoinProtocol.js +49 -40
- package/v0/protocol/GroestlcoinProtocol.js.map +1 -1
- package/v0/protocol/GroestlcoinProtocolOptions.js +111 -45
- package/v0/protocol/GroestlcoinProtocolOptions.js.map +1 -1
- package/v0/protocol/GroestlcoinTestnetProtocol.js +32 -25
- package/v0/protocol/GroestlcoinTestnetProtocol.js.map +1 -1
- package/v1/block-explorer/CryptoIDBlockExplorer.js +61 -12
- package/v1/block-explorer/CryptoIDBlockExplorer.js.map +1 -1
- package/v1/index.js +3 -3
- package/v1/index.js.map +1 -1
- package/v1/module/GroestlcoinModule.d.ts +1 -1
- package/v1/module/GroestlcoinModule.js +95 -37
- package/v1/module/GroestlcoinModule.js.map +1 -1
- package/v1/module.js +3 -2
- package/v1/module.js.map +1 -1
- package/v1/protocol/GroestlcoinProtocol.js +426 -195
- package/v1/protocol/GroestlcoinProtocol.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +6 -5
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/serializer-companion.js +148 -69
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/serializer/v3/validators/transaction-validator.js +23 -3
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
- package/v1/serializer/v3/validators/validators.js +1 -1
- package/v1/serializer/v3/validators/validators.js.map +1 -1
- package/v1/types/crypto.d.ts +1 -1
- package/v1/types/protocol.d.ts +2 -2
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
14
|
if (k2 === undefined) k2 = k;
|
|
4
15
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -15,38 +26,62 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
26
|
}) : function(o, v) {
|
|
16
27
|
o["default"] = v;
|
|
17
28
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) ||
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
return function (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
+
function step(op) {
|
|
50
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
+
while (_) try {
|
|
52
|
+
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;
|
|
53
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
+
switch (op[0]) {
|
|
55
|
+
case 0: case 1: t = op; break;
|
|
56
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
+
default:
|
|
60
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
+
if (t[2]) _.ops.pop();
|
|
65
|
+
_.trys.pop(); continue;
|
|
66
|
+
}
|
|
67
|
+
op = body.call(thisArg, _);
|
|
68
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
35
72
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.GROESTLCOIN_TESTNET_PROTOCOL_NETWORK = exports.GROESTLCOIN_MAINNET_PROTOCOL_NETWORK = exports.GroestlcoinProtocolImpl = void 0;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const BitcoinProtocol_1 = require("@airgap/bitcoin/v1/protocol/BitcoinProtocol");
|
|
40
|
-
const coinlib_core_1 = require("@airgap/coinlib-core");
|
|
73
|
+
exports.createGroestlcoinProtocolOptions = exports.GROESTLCOIN_TESTNET_PROTOCOL_NETWORK = exports.GROESTLCOIN_MAINNET_PROTOCOL_NETWORK = exports.createGroestlcoinProtocol = exports.GroestlcoinProtocolImpl = void 0;
|
|
74
|
+
var BitcoinProtocol_1 = require("@airgap/bitcoin/v1/protocol/BitcoinProtocol");
|
|
75
|
+
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
41
76
|
// @ts-ignore
|
|
42
|
-
|
|
77
|
+
var bitGoUTXO = __importStar(require("@airgap/coinlib-core/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/index"));
|
|
43
78
|
// @ts-ignore
|
|
44
|
-
|
|
45
|
-
|
|
79
|
+
var groestlcoinJSMessage = __importStar(require("@airgap/coinlib-core/dependencies/src/groestlcoinjs-message-2.1.0/index"));
|
|
80
|
+
var module_kit_1 = require("@airgap/module-kit");
|
|
46
81
|
// Implementation
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
82
|
+
var BITCOINJS_MAINNET_NETWORK = 'groestlcoin';
|
|
83
|
+
var GroestlcoinProtocolImpl = /** @class */ (function () {
|
|
84
|
+
function GroestlcoinProtocolImpl(options) {
|
|
50
85
|
// Common
|
|
51
86
|
this.units = {
|
|
52
87
|
GRS: {
|
|
@@ -76,7 +111,7 @@ class GroestlcoinProtocolImpl {
|
|
|
76
111
|
defaults: this.feeDefaults
|
|
77
112
|
},
|
|
78
113
|
account: {
|
|
79
|
-
standardDerivationPath:
|
|
114
|
+
standardDerivationPath: "m/44'/17'/0'",
|
|
80
115
|
address: {
|
|
81
116
|
isCaseSensitive: true,
|
|
82
117
|
placeholder: 'Fdb...',
|
|
@@ -86,185 +121,380 @@ class GroestlcoinProtocolImpl {
|
|
|
86
121
|
};
|
|
87
122
|
this.bitcoinUnits = undefined;
|
|
88
123
|
this.options = createGroestlcoinProtocolOptions(options.network);
|
|
89
|
-
this.bitcoinProtocol = new BitcoinProtocol_1.BitcoinProtocolImpl({
|
|
90
|
-
...this.options,
|
|
91
|
-
network: {
|
|
92
|
-
...this.options.network,
|
|
93
|
-
type: 'custom',
|
|
94
|
-
bitcoinjsNetworkName: BITCOINJS_MAINNET_NETWORK
|
|
95
|
-
}
|
|
96
|
-
}, undefined, bitGoUTXO, groestlcoinJSMessage);
|
|
97
|
-
}
|
|
98
|
-
async getMetadata() {
|
|
99
|
-
return this.metadata;
|
|
100
|
-
}
|
|
101
|
-
async getAddressFromPublicKey(publicKey) {
|
|
102
|
-
return this.bitcoinProtocol.getAddressFromPublicKey(publicKey);
|
|
103
|
-
}
|
|
104
|
-
async deriveFromExtendedPublicKey(extendedPublicKey, visibilityIndex, addressIndex) {
|
|
105
|
-
return this.bitcoinProtocol.deriveFromExtendedPublicKey(extendedPublicKey, visibilityIndex, addressIndex);
|
|
106
|
-
}
|
|
107
|
-
async getDetailsFromTransaction(transaction, publicKey) {
|
|
108
|
-
const bitcoinTransactions = await this.bitcoinProtocol.getDetailsFromTransaction(transaction, publicKey);
|
|
109
|
-
return Promise.all(bitcoinTransactions.map((transaction) => this.fromBitcoinAirGapTransaction(transaction)));
|
|
110
|
-
}
|
|
111
|
-
async verifyMessageWithPublicKey(message, signature, publicKey) {
|
|
112
|
-
return this.bitcoinProtocol.verifyMessageWithPublicKey(message, signature, publicKey);
|
|
113
|
-
}
|
|
114
|
-
async encryptAsymmetricWithPublicKey(payload, publicKey) {
|
|
115
|
-
return this.bitcoinProtocol.encryptAsymmetricWithPublicKey(payload, publicKey);
|
|
124
|
+
this.bitcoinProtocol = new BitcoinProtocol_1.BitcoinProtocolImpl(__assign(__assign({}, this.options), { network: __assign(__assign({}, this.options.network), { type: 'custom', bitcoinjsNetworkName: BITCOINJS_MAINNET_NETWORK }) }), undefined, bitGoUTXO, groestlcoinJSMessage);
|
|
116
125
|
}
|
|
126
|
+
GroestlcoinProtocolImpl.prototype.getMetadata = function () {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
128
|
+
return __generator(this, function (_a) {
|
|
129
|
+
return [2 /*return*/, this.metadata];
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
GroestlcoinProtocolImpl.prototype.getAddressFromPublicKey = function (publicKey) {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
135
|
+
return __generator(this, function (_a) {
|
|
136
|
+
return [2 /*return*/, this.bitcoinProtocol.getAddressFromPublicKey(publicKey)];
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
GroestlcoinProtocolImpl.prototype.deriveFromExtendedPublicKey = function (extendedPublicKey, visibilityIndex, addressIndex) {
|
|
141
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
142
|
+
return __generator(this, function (_a) {
|
|
143
|
+
return [2 /*return*/, this.bitcoinProtocol.deriveFromExtendedPublicKey(extendedPublicKey, visibilityIndex, addressIndex)];
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
GroestlcoinProtocolImpl.prototype.getDetailsFromTransaction = function (transaction, publicKey) {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
149
|
+
var bitcoinTransactions;
|
|
150
|
+
var _this = this;
|
|
151
|
+
return __generator(this, function (_a) {
|
|
152
|
+
switch (_a.label) {
|
|
153
|
+
case 0: return [4 /*yield*/, this.bitcoinProtocol.getDetailsFromTransaction(transaction, publicKey)];
|
|
154
|
+
case 1:
|
|
155
|
+
bitcoinTransactions = _a.sent();
|
|
156
|
+
return [2 /*return*/, Promise.all(bitcoinTransactions.map(function (transaction) { return _this.fromBitcoinAirGapTransaction(transaction); }))];
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
GroestlcoinProtocolImpl.prototype.verifyMessageWithPublicKey = function (message, signature, publicKey) {
|
|
162
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
163
|
+
return __generator(this, function (_a) {
|
|
164
|
+
return [2 /*return*/, this.bitcoinProtocol.verifyMessageWithPublicKey(message, signature, publicKey)];
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
GroestlcoinProtocolImpl.prototype.encryptAsymmetricWithPublicKey = function (payload, publicKey) {
|
|
169
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
170
|
+
return __generator(this, function (_a) {
|
|
171
|
+
return [2 /*return*/, this.bitcoinProtocol.encryptAsymmetricWithPublicKey(payload, publicKey)];
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
};
|
|
117
175
|
// Offline
|
|
118
|
-
|
|
119
|
-
return this
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return this
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
176
|
+
GroestlcoinProtocolImpl.prototype.getCryptoConfiguration = function () {
|
|
177
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
178
|
+
return __generator(this, function (_a) {
|
|
179
|
+
return [2 /*return*/, this.bitcoinProtocol.getCryptoConfiguration()];
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
GroestlcoinProtocolImpl.prototype.getKeyPairFromDerivative = function (derivative) {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
185
|
+
return __generator(this, function (_a) {
|
|
186
|
+
return [2 /*return*/, this.bitcoinProtocol.getKeyPairFromDerivative(derivative)];
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
GroestlcoinProtocolImpl.prototype.getExtendedKeyPairFromDerivative = function (derivative) {
|
|
191
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
192
|
+
return __generator(this, function (_a) {
|
|
193
|
+
return [2 /*return*/, this.bitcoinProtocol.getExtendedKeyPairFromDerivative(derivative)];
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
GroestlcoinProtocolImpl.prototype.deriveFromExtendedSecretKey = function (extendedSecretKey, visibilityIndex, addressIndex) {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
+
return __generator(this, function (_a) {
|
|
200
|
+
return [2 /*return*/, this.bitcoinProtocol.deriveFromExtendedSecretKey(extendedSecretKey, visibilityIndex, addressIndex)];
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
GroestlcoinProtocolImpl.prototype.signTransactionWithSecretKey = function (transaction, secretKey) {
|
|
205
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
206
|
+
return __generator(this, function (_a) {
|
|
207
|
+
return [2 /*return*/, this.bitcoinProtocol.signTransactionWithSecretKey(transaction, secretKey)];
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
GroestlcoinProtocolImpl.prototype.signMessageWithKeyPair = function (message, keyPair) {
|
|
212
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
213
|
+
return __generator(this, function (_a) {
|
|
214
|
+
return [2 /*return*/, this.bitcoinProtocol.signMessageWithKeyPair(message, keyPair)];
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
GroestlcoinProtocolImpl.prototype.decryptAsymmetricWithKeyPair = function (payload, keyPair) {
|
|
219
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
220
|
+
return __generator(this, function (_a) {
|
|
221
|
+
return [2 /*return*/, this.bitcoinProtocol.decryptAsymmetricWithKeyPair(payload, keyPair)];
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
GroestlcoinProtocolImpl.prototype.encryptAESWithSecretKey = function (payload, secretKey) {
|
|
226
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
227
|
+
return __generator(this, function (_a) {
|
|
228
|
+
return [2 /*return*/, this.bitcoinProtocol.encryptAESWithSecretKey(payload, secretKey)];
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
GroestlcoinProtocolImpl.prototype.decryptAESWithSecretKey = function (payload, secretKey) {
|
|
233
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
234
|
+
return __generator(this, function (_a) {
|
|
235
|
+
return [2 /*return*/, this.bitcoinProtocol.decryptAESWithSecretKey(payload, secretKey)];
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
};
|
|
145
239
|
// Online
|
|
146
|
-
|
|
147
|
-
return this
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return this.fromBitcoinAirGapTransactionWithCursor(bitcoinTransactions);
|
|
152
|
-
}
|
|
153
|
-
async getTransactionsForAddress(address, limit, cursor) {
|
|
154
|
-
const bitcoinTransactions = await this.bitcoinProtocol.getTransactionsForAddress(address, limit, cursor);
|
|
155
|
-
return this.fromBitcoinAirGapTransactionWithCursor(bitcoinTransactions);
|
|
156
|
-
}
|
|
157
|
-
async getTransactionsForAddresses(addresses, limit, cursor) {
|
|
158
|
-
const bitcoinTransactions = await this.bitcoinProtocol.getTransactionsForAddresses(addresses, limit, cursor);
|
|
159
|
-
return this.fromBitcoinAirGapTransactionWithCursor(bitcoinTransactions);
|
|
160
|
-
}
|
|
161
|
-
async getBalanceOfPublicKey(publicKey) {
|
|
162
|
-
const bitcoinBalance = await this.bitcoinProtocol.getBalanceOfPublicKey(publicKey);
|
|
163
|
-
return this.fromBitcoinBalance(bitcoinBalance);
|
|
164
|
-
}
|
|
165
|
-
async getBalanceOfAddress(address) {
|
|
166
|
-
const bitcoinBalance = await this.bitcoinProtocol.getBalanceOfAddress(address);
|
|
167
|
-
return this.fromBitcoinBalance(bitcoinBalance);
|
|
168
|
-
}
|
|
169
|
-
async getBalanceOfAddresses(addresses) {
|
|
170
|
-
const bitcoinBalance = await this.bitcoinProtocol.getBalanceOfAddresses(addresses);
|
|
171
|
-
return this.fromBitcoinBalance(bitcoinBalance);
|
|
172
|
-
}
|
|
173
|
-
async getTransactionMaxAmountWithPublicKey(publicKey, to, configuration) {
|
|
174
|
-
const bitcoinFee = configuration?.fee ? this.toBitcoinAmount(configuration.fee) : undefined;
|
|
175
|
-
const bitcoinMax = await this.bitcoinProtocol.getTransactionMaxAmountWithPublicKey(publicKey, to, {
|
|
176
|
-
...configuration,
|
|
177
|
-
fee: bitcoinFee
|
|
240
|
+
GroestlcoinProtocolImpl.prototype.getNetwork = function () {
|
|
241
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
242
|
+
return __generator(this, function (_a) {
|
|
243
|
+
return [2 /*return*/, this.options.network];
|
|
244
|
+
});
|
|
178
245
|
});
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
fee: bitcoinFee
|
|
246
|
+
};
|
|
247
|
+
GroestlcoinProtocolImpl.prototype.getTransactionsForPublicKey = function (publicKey, limit, cursor) {
|
|
248
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
249
|
+
var bitcoinTransactions;
|
|
250
|
+
return __generator(this, function (_a) {
|
|
251
|
+
switch (_a.label) {
|
|
252
|
+
case 0: return [4 /*yield*/, this.bitcoinProtocol.getTransactionsForPublicKey(publicKey, limit, cursor)];
|
|
253
|
+
case 1:
|
|
254
|
+
bitcoinTransactions = _a.sent();
|
|
255
|
+
return [2 /*return*/, this.fromBitcoinAirGapTransactionWithCursor(bitcoinTransactions)];
|
|
256
|
+
}
|
|
257
|
+
});
|
|
192
258
|
});
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return this
|
|
196
|
-
|
|
259
|
+
};
|
|
260
|
+
GroestlcoinProtocolImpl.prototype.getTransactionsForAddress = function (address, limit, cursor) {
|
|
261
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
262
|
+
var bitcoinTransactions;
|
|
263
|
+
return __generator(this, function (_a) {
|
|
264
|
+
switch (_a.label) {
|
|
265
|
+
case 0: return [4 /*yield*/, this.bitcoinProtocol.getTransactionsForAddress(address, limit, cursor)];
|
|
266
|
+
case 1:
|
|
267
|
+
bitcoinTransactions = _a.sent();
|
|
268
|
+
return [2 /*return*/, this.fromBitcoinAirGapTransactionWithCursor(bitcoinTransactions)];
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
};
|
|
273
|
+
GroestlcoinProtocolImpl.prototype.getTransactionsForAddresses = function (addresses, limit, cursor) {
|
|
274
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
275
|
+
var bitcoinTransactions;
|
|
276
|
+
return __generator(this, function (_a) {
|
|
277
|
+
switch (_a.label) {
|
|
278
|
+
case 0: return [4 /*yield*/, this.bitcoinProtocol.getTransactionsForAddresses(addresses, limit, cursor)];
|
|
279
|
+
case 1:
|
|
280
|
+
bitcoinTransactions = _a.sent();
|
|
281
|
+
return [2 /*return*/, this.fromBitcoinAirGapTransactionWithCursor(bitcoinTransactions)];
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
GroestlcoinProtocolImpl.prototype.getBalanceOfPublicKey = function (publicKey) {
|
|
287
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
288
|
+
var bitcoinBalance;
|
|
289
|
+
return __generator(this, function (_a) {
|
|
290
|
+
switch (_a.label) {
|
|
291
|
+
case 0: return [4 /*yield*/, this.bitcoinProtocol.getBalanceOfPublicKey(publicKey)];
|
|
292
|
+
case 1:
|
|
293
|
+
bitcoinBalance = _a.sent();
|
|
294
|
+
return [2 /*return*/, this.fromBitcoinBalance(bitcoinBalance)];
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
};
|
|
299
|
+
GroestlcoinProtocolImpl.prototype.getBalanceOfAddress = function (address) {
|
|
300
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
301
|
+
var bitcoinBalance;
|
|
302
|
+
return __generator(this, function (_a) {
|
|
303
|
+
switch (_a.label) {
|
|
304
|
+
case 0: return [4 /*yield*/, this.bitcoinProtocol.getBalanceOfAddress(address)];
|
|
305
|
+
case 1:
|
|
306
|
+
bitcoinBalance = _a.sent();
|
|
307
|
+
return [2 /*return*/, this.fromBitcoinBalance(bitcoinBalance)];
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
};
|
|
312
|
+
GroestlcoinProtocolImpl.prototype.getBalanceOfAddresses = function (addresses) {
|
|
313
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
314
|
+
var bitcoinBalance;
|
|
315
|
+
return __generator(this, function (_a) {
|
|
316
|
+
switch (_a.label) {
|
|
317
|
+
case 0: return [4 /*yield*/, this.bitcoinProtocol.getBalanceOfAddresses(addresses)];
|
|
318
|
+
case 1:
|
|
319
|
+
bitcoinBalance = _a.sent();
|
|
320
|
+
return [2 /*return*/, this.fromBitcoinBalance(bitcoinBalance)];
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
};
|
|
325
|
+
GroestlcoinProtocolImpl.prototype.getTransactionMaxAmountWithPublicKey = function (publicKey, to, configuration) {
|
|
326
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
327
|
+
var bitcoinFee, bitcoinMax;
|
|
328
|
+
return __generator(this, function (_a) {
|
|
329
|
+
switch (_a.label) {
|
|
330
|
+
case 0:
|
|
331
|
+
bitcoinFee = (configuration === null || configuration === void 0 ? void 0 : configuration.fee) ? this.toBitcoinAmount(configuration.fee) : undefined;
|
|
332
|
+
return [4 /*yield*/, this.bitcoinProtocol.getTransactionMaxAmountWithPublicKey(publicKey, to, __assign(__assign({}, configuration), { fee: bitcoinFee }))];
|
|
333
|
+
case 1:
|
|
334
|
+
bitcoinMax = _a.sent();
|
|
335
|
+
return [2 /*return*/, this.fromBitcoinAmount(bitcoinMax)];
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
};
|
|
340
|
+
GroestlcoinProtocolImpl.prototype.getTransactionFeeWithPublicKey = function (publicKey, details, configuration) {
|
|
341
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
342
|
+
var bitcoinDetails, bitcoinFeeEstimation;
|
|
343
|
+
var _this = this;
|
|
344
|
+
return __generator(this, function (_a) {
|
|
345
|
+
switch (_a.label) {
|
|
346
|
+
case 0:
|
|
347
|
+
bitcoinDetails = details.map(function (details) {
|
|
348
|
+
return _this.toBitcoinTransactionDetails(details);
|
|
349
|
+
});
|
|
350
|
+
return [4 /*yield*/, this.bitcoinProtocol.getTransactionFeeWithPublicKey(publicKey, bitcoinDetails, configuration)];
|
|
351
|
+
case 1:
|
|
352
|
+
bitcoinFeeEstimation = _a.sent();
|
|
353
|
+
return [2 /*return*/, this.fromBitcoinFeeEstimation(bitcoinFeeEstimation)];
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
};
|
|
358
|
+
GroestlcoinProtocolImpl.prototype.prepareTransactionWithPublicKey = function (publicKey, details, configuration) {
|
|
359
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
360
|
+
var bitcoinDetails, bitcoinFee;
|
|
361
|
+
var _this = this;
|
|
362
|
+
return __generator(this, function (_a) {
|
|
363
|
+
bitcoinDetails = details.map(function (details) {
|
|
364
|
+
return _this.toBitcoinTransactionDetails(details);
|
|
365
|
+
});
|
|
366
|
+
bitcoinFee = (configuration === null || configuration === void 0 ? void 0 : configuration.fee) ? this.toBitcoinAmount(configuration.fee) : undefined;
|
|
367
|
+
return [2 /*return*/, this.bitcoinProtocol.prepareTransactionWithPublicKey(publicKey, bitcoinDetails, __assign(__assign({}, configuration), { fee: bitcoinFee }))];
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
};
|
|
371
|
+
GroestlcoinProtocolImpl.prototype.broadcastTransaction = function (transaction) {
|
|
372
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
373
|
+
return __generator(this, function (_a) {
|
|
374
|
+
return [2 /*return*/, this.bitcoinProtocol.broadcastTransaction(transaction)];
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
};
|
|
197
378
|
// Custom
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
this
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
379
|
+
GroestlcoinProtocolImpl.prototype.fromBitcoinAirGapTransaction = function (transaction) {
|
|
380
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
381
|
+
var _a, amount, fee;
|
|
382
|
+
return __generator(this, function (_b) {
|
|
383
|
+
switch (_b.label) {
|
|
384
|
+
case 0: return [4 /*yield*/, Promise.all([
|
|
385
|
+
this.fromBitcoinAmount(transaction.amount),
|
|
386
|
+
this.fromBitcoinAmount(transaction.fee)
|
|
387
|
+
])];
|
|
388
|
+
case 1:
|
|
389
|
+
_a = _b.sent(), amount = _a[0], fee = _a[1];
|
|
390
|
+
return [2 /*return*/, __assign(__assign({}, transaction), { amount: amount, fee: fee })];
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
};
|
|
395
|
+
GroestlcoinProtocolImpl.prototype.fromBitcoinAirGapTransactionWithCursor = function (transactionsWithCursor) {
|
|
396
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
397
|
+
var _a;
|
|
398
|
+
var _this = this;
|
|
399
|
+
return __generator(this, function (_b) {
|
|
400
|
+
switch (_b.label) {
|
|
401
|
+
case 0:
|
|
402
|
+
_a = {};
|
|
403
|
+
return [4 /*yield*/, Promise.all(transactionsWithCursor.transactions.map(function (transaction) {
|
|
404
|
+
return _this.fromBitcoinAirGapTransaction(transaction);
|
|
405
|
+
}))];
|
|
406
|
+
case 1: return [2 /*return*/, (_a.transactions = _b.sent(),
|
|
407
|
+
_a.cursor = {
|
|
408
|
+
hasNext: transactionsWithCursor.cursor.hasNext,
|
|
409
|
+
page: transactionsWithCursor.cursor.page
|
|
410
|
+
},
|
|
411
|
+
_a)];
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
});
|
|
415
|
+
};
|
|
416
|
+
GroestlcoinProtocolImpl.prototype.fromBitcoinBalance = function (balance) {
|
|
417
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
418
|
+
var _a, total, transferable;
|
|
419
|
+
return __generator(this, function (_b) {
|
|
420
|
+
switch (_b.label) {
|
|
421
|
+
case 0: return [4 /*yield*/, Promise.all([
|
|
422
|
+
this.fromBitcoinAmount(balance.total),
|
|
423
|
+
balance.transferable ? this.fromBitcoinAmount(balance.transferable) : Promise.resolve(undefined)
|
|
424
|
+
])];
|
|
425
|
+
case 1:
|
|
426
|
+
_a = _b.sent(), total = _a[0], transferable = _a[1];
|
|
427
|
+
return [2 /*return*/, { total: total, transferable: transferable }];
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
};
|
|
432
|
+
GroestlcoinProtocolImpl.prototype.fromBitcoinFeeEstimation = function (feeEstimation) {
|
|
433
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
434
|
+
return __generator(this, function (_a) {
|
|
435
|
+
// const [low, medium, high]: [Amount<GroestlcoinUnits>, Amount<GroestlcoinUnits>, Amount<GroestlcoinUnits>] = await Promise.all([
|
|
436
|
+
// this.fromBitcoinAmount(feeEstimation.low),
|
|
437
|
+
// this.fromBitcoinAmount(feeEstimation.medium),
|
|
438
|
+
// this.fromBitcoinAmount(feeEstimation.high)
|
|
439
|
+
// ])
|
|
440
|
+
return [2 /*return*/, __assign({}, this.feeDefaults)];
|
|
441
|
+
});
|
|
442
|
+
});
|
|
443
|
+
};
|
|
444
|
+
GroestlcoinProtocolImpl.prototype.fromBitcoinAmount = function (amount) {
|
|
445
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
446
|
+
var bitcoinUnits;
|
|
447
|
+
return __generator(this, function (_a) {
|
|
448
|
+
switch (_a.label) {
|
|
449
|
+
case 0: return [4 /*yield*/, this.getBitcoinUnits()];
|
|
450
|
+
case 1:
|
|
451
|
+
bitcoinUnits = _a.sent();
|
|
452
|
+
return [2 /*return*/, this.convertAmount(amount, bitcoinUnits)];
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
};
|
|
457
|
+
GroestlcoinProtocolImpl.prototype.toBitcoinTransactionDetails = function (details) {
|
|
458
|
+
return __assign(__assign({}, details), { amount: this.toBitcoinAmount(details.amount) });
|
|
459
|
+
};
|
|
460
|
+
GroestlcoinProtocolImpl.prototype.toBitcoinAmount = function (amount) {
|
|
244
461
|
return this.convertAmount(amount, this.units);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
this
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
462
|
+
};
|
|
463
|
+
GroestlcoinProtocolImpl.prototype.getBitcoinUnits = function () {
|
|
464
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
465
|
+
var metadata;
|
|
466
|
+
return __generator(this, function (_a) {
|
|
467
|
+
switch (_a.label) {
|
|
468
|
+
case 0:
|
|
469
|
+
if (!(this.bitcoinUnits === undefined)) return [3 /*break*/, 2];
|
|
470
|
+
return [4 /*yield*/, this.bitcoinProtocol.getMetadata()];
|
|
471
|
+
case 1:
|
|
472
|
+
metadata = _a.sent();
|
|
473
|
+
this.bitcoinUnits = metadata.units;
|
|
474
|
+
_a.label = 2;
|
|
475
|
+
case 2: return [2 /*return*/, this.bitcoinUnits];
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
};
|
|
480
|
+
GroestlcoinProtocolImpl.prototype.convertAmount = function (amount, fromUnits) {
|
|
254
481
|
return (0, module_kit_1.newAmount)((0, module_kit_1.newAmount)(amount).blockchain(fromUnits).value, 'blockchain');
|
|
255
|
-
}
|
|
256
|
-
|
|
482
|
+
};
|
|
483
|
+
return GroestlcoinProtocolImpl;
|
|
484
|
+
}());
|
|
257
485
|
exports.GroestlcoinProtocolImpl = GroestlcoinProtocolImpl;
|
|
258
486
|
// Factory
|
|
259
|
-
function createGroestlcoinProtocol(options
|
|
487
|
+
function createGroestlcoinProtocol(options) {
|
|
488
|
+
if (options === void 0) { options = {}; }
|
|
260
489
|
return new GroestlcoinProtocolImpl(options);
|
|
261
490
|
}
|
|
491
|
+
exports.createGroestlcoinProtocol = createGroestlcoinProtocol;
|
|
262
492
|
exports.GROESTLCOIN_MAINNET_PROTOCOL_NETWORK = {
|
|
263
493
|
name: 'Mainnet',
|
|
264
494
|
type: 'mainnet',
|
|
265
495
|
rpcUrl: '',
|
|
266
496
|
blockExplorerUrl: 'https://chainz.cryptoid.info/grs',
|
|
267
|
-
indexerApi:
|
|
497
|
+
indexerApi: "https://cors-proxy.airgap.prod.gke.papers.tech/proxy?url=".concat('https://blockbook.groestlcoin.org')
|
|
268
498
|
};
|
|
269
499
|
exports.GROESTLCOIN_TESTNET_PROTOCOL_NETWORK = {
|
|
270
500
|
name: 'Testnet',
|
|
@@ -273,12 +503,13 @@ exports.GROESTLCOIN_TESTNET_PROTOCOL_NETWORK = {
|
|
|
273
503
|
blockExplorerUrl: 'https://chainz.cryptoid.info/grs-test',
|
|
274
504
|
indexerApi: 'https://blockbook-test.groestlcoin.org/'
|
|
275
505
|
};
|
|
276
|
-
|
|
277
|
-
function createGroestlcoinProtocolOptions(network
|
|
506
|
+
var DEFAULT_GROESTLCOIN_PROTOCOL_NETWORK = exports.GROESTLCOIN_MAINNET_PROTOCOL_NETWORK;
|
|
507
|
+
function createGroestlcoinProtocolOptions(network) {
|
|
508
|
+
if (network === void 0) { network = {}; }
|
|
278
509
|
return {
|
|
279
510
|
network: network.type === 'custom'
|
|
280
|
-
? {
|
|
281
|
-
: { ...DEFAULT_GROESTLCOIN_PROTOCOL_NETWORK, ...network }
|
|
511
|
+
? __assign(__assign(__assign({}, DEFAULT_GROESTLCOIN_PROTOCOL_NETWORK), { bitcoinjsNetworkName: BITCOINJS_MAINNET_NETWORK }), network) : __assign(__assign({}, DEFAULT_GROESTLCOIN_PROTOCOL_NETWORK), network)
|
|
282
512
|
};
|
|
283
513
|
}
|
|
514
|
+
exports.createGroestlcoinProtocolOptions = createGroestlcoinProtocolOptions;
|
|
284
515
|
//# sourceMappingURL=GroestlcoinProtocol.js.map
|