@sidhujag/sysweb3-keyring 1.0.491
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 +201 -0
- package/cjs/errorUtils.js +75 -0
- package/cjs/errorUtils.js.map +1 -0
- package/cjs/hardware-wallet-manager.js +462 -0
- package/cjs/hardware-wallet-manager.js.map +1 -0
- package/cjs/index.js +31 -0
- package/cjs/index.js.map +1 -0
- package/cjs/initial-state.js +105 -0
- package/cjs/initial-state.js.map +1 -0
- package/cjs/keyring-manager.js +1687 -0
- package/cjs/keyring-manager.js.map +1 -0
- package/cjs/ledger/bitcoin_client/index.js +47 -0
- package/cjs/ledger/bitcoin_client/index.js.map +1 -0
- package/cjs/ledger/bitcoin_client/lib/appClient.js +408 -0
- package/cjs/ledger/bitcoin_client/lib/appClient.js.map +1 -0
- package/cjs/ledger/bitcoin_client/lib/bip32.js +61 -0
- package/cjs/ledger/bitcoin_client/lib/bip32.js.map +1 -0
- package/cjs/ledger/bitcoin_client/lib/buffertools.js +126 -0
- package/cjs/ledger/bitcoin_client/lib/buffertools.js.map +1 -0
- package/cjs/ledger/bitcoin_client/lib/clientCommands.js +270 -0
- package/cjs/ledger/bitcoin_client/lib/clientCommands.js.map +1 -0
- package/cjs/ledger/bitcoin_client/lib/constants.js +16 -0
- package/cjs/ledger/bitcoin_client/lib/constants.js.map +1 -0
- package/cjs/ledger/bitcoin_client/lib/merkelizedPsbt.js +54 -0
- package/cjs/ledger/bitcoin_client/lib/merkelizedPsbt.js.map +1 -0
- package/cjs/ledger/bitcoin_client/lib/merkle.js +109 -0
- package/cjs/ledger/bitcoin_client/lib/merkle.js.map +1 -0
- package/cjs/ledger/bitcoin_client/lib/merkleMap.js +46 -0
- package/cjs/ledger/bitcoin_client/lib/merkleMap.js.map +1 -0
- package/cjs/ledger/bitcoin_client/lib/policy.js +66 -0
- package/cjs/ledger/bitcoin_client/lib/policy.js.map +1 -0
- package/cjs/ledger/bitcoin_client/lib/psbtv2.js +640 -0
- package/cjs/ledger/bitcoin_client/lib/psbtv2.js.map +1 -0
- package/cjs/ledger/bitcoin_client/lib/varint.js +113 -0
- package/cjs/ledger/bitcoin_client/lib/varint.js.map +1 -0
- package/cjs/ledger/consts.js +7 -0
- package/cjs/ledger/consts.js.map +1 -0
- package/cjs/ledger/index.js +319 -0
- package/cjs/ledger/index.js.map +1 -0
- package/cjs/ledger/types.js +3 -0
- package/cjs/ledger/types.js.map +1 -0
- package/cjs/network-utils.js +76 -0
- package/cjs/network-utils.js.map +1 -0
- package/cjs/providers.js +270 -0
- package/cjs/providers.js.map +1 -0
- package/cjs/signers.js +64 -0
- package/cjs/signers.js.map +1 -0
- package/cjs/storage.js +30 -0
- package/cjs/storage.js.map +1 -0
- package/cjs/transactions/__tests__/integration.test.js +237 -0
- package/cjs/transactions/__tests__/integration.test.js.map +1 -0
- package/cjs/transactions/__tests__/syscoin.test.js +361 -0
- package/cjs/transactions/__tests__/syscoin.test.js.map +1 -0
- package/cjs/transactions/ethereum.js +1577 -0
- package/cjs/transactions/ethereum.js.map +1 -0
- package/cjs/transactions/index.js +19 -0
- package/cjs/transactions/index.js.map +1 -0
- package/cjs/transactions/syscoin.js +328 -0
- package/cjs/transactions/syscoin.js.map +1 -0
- package/cjs/trezor/index.js +718 -0
- package/cjs/trezor/index.js.map +1 -0
- package/cjs/types.js +12 -0
- package/cjs/types.js.map +1 -0
- package/cjs/utils/derivation-paths.js +99 -0
- package/cjs/utils/derivation-paths.js.map +1 -0
- package/cjs/utils/psbt.js +60 -0
- package/cjs/utils/psbt.js.map +1 -0
- package/cjs/utils.js +130 -0
- package/cjs/utils.js.map +1 -0
- package/package.json +46 -0
- package/types/errorUtils.d.ts +1 -0
- package/types/hardware-wallet-manager.d.ts +110 -0
- package/types/index.d.ts +12 -0
- package/types/initial-state.d.ts +79 -0
- package/types/keyring-manager.d.ts +184 -0
- package/types/ledger/bitcoin_client/index.d.ts +5 -0
- package/types/ledger/bitcoin_client/lib/appClient.d.ts +106 -0
- package/types/ledger/bitcoin_client/lib/bip32.d.ts +11 -0
- package/types/ledger/bitcoin_client/lib/buffertools.d.ts +28 -0
- package/types/ledger/bitcoin_client/lib/clientCommands.d.ts +77 -0
- package/types/ledger/bitcoin_client/lib/constants.d.ts +12 -0
- package/types/ledger/bitcoin_client/lib/merkelizedPsbt.d.ts +24 -0
- package/types/ledger/bitcoin_client/lib/merkle.d.ts +32 -0
- package/types/ledger/bitcoin_client/lib/merkleMap.d.ts +23 -0
- package/types/ledger/bitcoin_client/lib/policy.d.ts +36 -0
- package/types/ledger/bitcoin_client/lib/psbtv2.d.ts +167 -0
- package/types/ledger/bitcoin_client/lib/varint.d.ts +23 -0
- package/types/ledger/consts.d.ts +3 -0
- package/types/ledger/index.d.ts +51 -0
- package/types/ledger/types.d.ts +48 -0
- package/types/network-utils.d.ts +14 -0
- package/types/providers.d.ts +47 -0
- package/types/signers.d.ts +95 -0
- package/types/storage.d.ts +2 -0
- package/types/transactions/__tests__/integration.test.d.ts +1 -0
- package/types/transactions/__tests__/syscoin.test.d.ts +1 -0
- package/types/transactions/ethereum.d.ts +80 -0
- package/types/transactions/index.d.ts +2 -0
- package/types/transactions/syscoin.d.ts +61 -0
- package/types/trezor/index.d.ts +170 -0
- package/types/types.d.ts +294 -0
- package/types/utils/derivation-paths.d.ts +35 -0
- package/types/utils/psbt.d.ts +17 -0
- package/types/utils.d.ts +4 -0
package/cjs/providers.js
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomL2JsonRpcProvider = exports.CustomJsonRpcProvider = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const utils_1 = require("ethers/lib/utils");
|
|
6
|
+
const zksync_ethers_1 = require("zksync-ethers");
|
|
7
|
+
const errorUtils_1 = require("./errorUtils");
|
|
8
|
+
const utils_2 = require("./utils");
|
|
9
|
+
class BaseProvider extends ethers_1.ethers.providers.JsonRpcProvider {
|
|
10
|
+
constructor(signal, url, network) {
|
|
11
|
+
super(url, network);
|
|
12
|
+
this.isPossibleGetChainId = true;
|
|
13
|
+
this.cooldownTime = 120 * 1000;
|
|
14
|
+
this.rateLimit = 30;
|
|
15
|
+
this.requestCount = 0;
|
|
16
|
+
this.lastRequestTime = 0;
|
|
17
|
+
this.currentChainId = '';
|
|
18
|
+
this.currentId = 1;
|
|
19
|
+
this.isInCooldown = false;
|
|
20
|
+
this.errorMessage = '';
|
|
21
|
+
this.serverHasAnError = false;
|
|
22
|
+
this.throttledRequest = (requestFn) => {
|
|
23
|
+
if (!this.canMakeRequest()) {
|
|
24
|
+
return this.cooldown();
|
|
25
|
+
}
|
|
26
|
+
// Execute request immediately without timeout delay
|
|
27
|
+
return requestFn().catch((error) => {
|
|
28
|
+
if (error.name === 'AbortError') {
|
|
29
|
+
console.log('Aborted request', error);
|
|
30
|
+
return Promise.reject(error);
|
|
31
|
+
}
|
|
32
|
+
throw error;
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
this.canMakeRequest = () => {
|
|
36
|
+
const now = Date.now();
|
|
37
|
+
let elapsedTime = 0;
|
|
38
|
+
if (this.lastRequestTime > 0) {
|
|
39
|
+
elapsedTime = now - this.lastRequestTime;
|
|
40
|
+
}
|
|
41
|
+
if (elapsedTime <= this.cooldownTime && this.serverHasAnError) {
|
|
42
|
+
this.isInCooldown = true;
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
if (elapsedTime >= this.cooldownTime && this.serverHasAnError) {
|
|
46
|
+
this.requestCount = 0;
|
|
47
|
+
this.serverHasAnError = false;
|
|
48
|
+
this.isInCooldown = true;
|
|
49
|
+
return false; //One last blocked request before cooldown ends
|
|
50
|
+
}
|
|
51
|
+
if (this.requestCount < this.rateLimit || !this.serverHasAnError) {
|
|
52
|
+
this.requestCount++;
|
|
53
|
+
if (elapsedTime > 1000) {
|
|
54
|
+
//Uncomment the console.log to see the request per second
|
|
55
|
+
// console.log(
|
|
56
|
+
// `Request/sec to Provider(${this.connection.url}): ${this.requestCount}`
|
|
57
|
+
// );
|
|
58
|
+
this.requestCount = 1;
|
|
59
|
+
this.lastRequestTime = now;
|
|
60
|
+
}
|
|
61
|
+
else if (this.lastRequestTime === 0) {
|
|
62
|
+
this.lastRequestTime = now;
|
|
63
|
+
}
|
|
64
|
+
this.isInCooldown = false;
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
this.cooldown = async () => {
|
|
69
|
+
const now = Date.now();
|
|
70
|
+
const elapsedTime = now - this.lastRequestTime;
|
|
71
|
+
console.error('Cant make request, rpc cooldown is active for the next: ', (this.cooldownTime - elapsedTime) / 1000, ' seconds');
|
|
72
|
+
throw {
|
|
73
|
+
message: `Cant make request, rpc cooldown is active for the next: ${(this.cooldownTime - elapsedTime) / 1000} seconds`,
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
this.send = async (method, params) => {
|
|
77
|
+
if (!this.isPossibleGetChainId && method === 'eth_chainId') {
|
|
78
|
+
return this.currentChainId;
|
|
79
|
+
}
|
|
80
|
+
const headers = {
|
|
81
|
+
'Content-Type': 'application/json',
|
|
82
|
+
};
|
|
83
|
+
const options = {
|
|
84
|
+
method: 'POST',
|
|
85
|
+
headers,
|
|
86
|
+
body: JSON.stringify({
|
|
87
|
+
jsonrpc: '2.0',
|
|
88
|
+
method,
|
|
89
|
+
params,
|
|
90
|
+
id: this.currentId,
|
|
91
|
+
}),
|
|
92
|
+
signal: this.signal,
|
|
93
|
+
};
|
|
94
|
+
const result = await this.throttledRequest(() => fetch(this.connection.url, options)
|
|
95
|
+
.then(async (response) => {
|
|
96
|
+
if (!response.ok) {
|
|
97
|
+
let errorBody = {
|
|
98
|
+
error: undefined,
|
|
99
|
+
message: undefined,
|
|
100
|
+
};
|
|
101
|
+
try {
|
|
102
|
+
errorBody = await response.json();
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
console.warn('No body in request', error);
|
|
106
|
+
}
|
|
107
|
+
this.errorMessage =
|
|
108
|
+
errorBody.error ||
|
|
109
|
+
errorBody.message ||
|
|
110
|
+
'No message from Provider';
|
|
111
|
+
(0, errorUtils_1.handleStatusCodeError)(response.status, this.errorMessage);
|
|
112
|
+
}
|
|
113
|
+
switch (response.status) {
|
|
114
|
+
case 200:
|
|
115
|
+
return response.json();
|
|
116
|
+
default:
|
|
117
|
+
throw {
|
|
118
|
+
message: `Unexpected HTTP status code: ${response.status}`,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
.then((json) => {
|
|
123
|
+
if (json.error) {
|
|
124
|
+
if (json.error.message.includes('insufficient funds')) {
|
|
125
|
+
console.error({
|
|
126
|
+
errorMessage: json.error.message,
|
|
127
|
+
});
|
|
128
|
+
this.errorMessage = json.error.message;
|
|
129
|
+
throw new Error(json.error.message);
|
|
130
|
+
}
|
|
131
|
+
this.errorMessage = json.error.message;
|
|
132
|
+
console.log({ requestData: { method, params }, error: json.error });
|
|
133
|
+
console.error({
|
|
134
|
+
errorMessage: json.error.message,
|
|
135
|
+
});
|
|
136
|
+
throw new Error(json.error.message);
|
|
137
|
+
}
|
|
138
|
+
if (method === 'eth_chainId') {
|
|
139
|
+
this.currentChainId = json.result;
|
|
140
|
+
this.isPossibleGetChainId = false;
|
|
141
|
+
}
|
|
142
|
+
this.currentId++;
|
|
143
|
+
this.serverHasAnError = false;
|
|
144
|
+
return json.result;
|
|
145
|
+
}));
|
|
146
|
+
return result;
|
|
147
|
+
};
|
|
148
|
+
this.signal = signal;
|
|
149
|
+
this._pendingBatchAggregator = null;
|
|
150
|
+
this._pendingBatch = null;
|
|
151
|
+
this.bindMethods();
|
|
152
|
+
}
|
|
153
|
+
bindMethods() {
|
|
154
|
+
const proto = Object.getPrototypeOf(this);
|
|
155
|
+
for (const key of Object.getOwnPropertyNames(proto)) {
|
|
156
|
+
if (typeof this[key] === 'function' && key !== 'constructor') {
|
|
157
|
+
this[key] = this[key].bind(this);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async perform(method, params) {
|
|
162
|
+
// Legacy networks do not like the type field being passed along (which
|
|
163
|
+
// is fair), so we delete type if it is 0 and a non-EIP-1559 network
|
|
164
|
+
if (method === 'call' || method === 'estimateGas') {
|
|
165
|
+
const tx = params.transaction;
|
|
166
|
+
if (tx && tx.type != null && ethers_1.BigNumber.from(tx.type).isZero()) {
|
|
167
|
+
// If there are no EIP-1559 properties, it might be non-EIP-1559
|
|
168
|
+
if (tx.maxFeePerGas == null && tx.maxPriorityFeePerGas == null) {
|
|
169
|
+
const feeData = await this.getFeeData();
|
|
170
|
+
if (feeData.maxFeePerGas == null &&
|
|
171
|
+
feeData.maxPriorityFeePerGas == null) {
|
|
172
|
+
// Network doesn't know about EIP-1559 (and hence type)
|
|
173
|
+
params = (0, utils_1.shallowCopy)(params);
|
|
174
|
+
params.transaction = (0, utils_1.shallowCopy)(tx);
|
|
175
|
+
delete params.transaction.type;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const args = this.prepareRequest(method, params);
|
|
181
|
+
if (args == null) {
|
|
182
|
+
ethers_1.logger.throwError(method + ' not implemented', utils_1.Logger.errors.NOT_IMPLEMENTED, { operation: method });
|
|
183
|
+
}
|
|
184
|
+
try {
|
|
185
|
+
return await this.send(args[0], args[1]);
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
return (0, utils_2.checkError)(method, error, params);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
async sendBatch(method, params) {
|
|
192
|
+
// Create batch request array
|
|
193
|
+
const requests = params.map((param, index) => ({
|
|
194
|
+
jsonrpc: '2.0',
|
|
195
|
+
id: this.currentId + index,
|
|
196
|
+
method,
|
|
197
|
+
params: param,
|
|
198
|
+
}));
|
|
199
|
+
this.currentId += requests.length;
|
|
200
|
+
const headers = {
|
|
201
|
+
'Content-Type': 'application/json',
|
|
202
|
+
};
|
|
203
|
+
const options = {
|
|
204
|
+
method: 'POST',
|
|
205
|
+
headers,
|
|
206
|
+
body: JSON.stringify(requests),
|
|
207
|
+
signal: this.signal,
|
|
208
|
+
};
|
|
209
|
+
const results = await this.throttledRequest(() => fetch(this.connection.url, options)
|
|
210
|
+
.then(async (response) => {
|
|
211
|
+
if (!response.ok) {
|
|
212
|
+
let errorBody = {
|
|
213
|
+
error: undefined,
|
|
214
|
+
message: undefined,
|
|
215
|
+
};
|
|
216
|
+
try {
|
|
217
|
+
errorBody = await response.json();
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
console.warn('No body in request', error);
|
|
221
|
+
}
|
|
222
|
+
this.errorMessage =
|
|
223
|
+
errorBody.error ||
|
|
224
|
+
errorBody.message ||
|
|
225
|
+
'No message from Provider';
|
|
226
|
+
(0, errorUtils_1.handleStatusCodeError)(response.status, this.errorMessage);
|
|
227
|
+
}
|
|
228
|
+
return response.json();
|
|
229
|
+
})
|
|
230
|
+
.then((jsonArray) => {
|
|
231
|
+
// Sort results by ID to ensure correct order
|
|
232
|
+
const sortedResults = jsonArray.sort((a, b) => a.id - b.id);
|
|
233
|
+
// Extract results or throw errors
|
|
234
|
+
return sortedResults.map((json) => {
|
|
235
|
+
if (json.error) {
|
|
236
|
+
this.errorMessage = json.error.message;
|
|
237
|
+
console.error({
|
|
238
|
+
errorMessage: json.error.message,
|
|
239
|
+
});
|
|
240
|
+
throw new Error(json.error.message);
|
|
241
|
+
}
|
|
242
|
+
return json.result;
|
|
243
|
+
});
|
|
244
|
+
}));
|
|
245
|
+
return results;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
class CustomJsonRpcProvider extends BaseProvider {
|
|
249
|
+
constructor(signal, url, network) {
|
|
250
|
+
super(signal, url, network);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
exports.CustomJsonRpcProvider = CustomJsonRpcProvider;
|
|
254
|
+
class CustomL2JsonRpcProvider extends zksync_ethers_1.Provider {
|
|
255
|
+
constructor(signal, url, network) {
|
|
256
|
+
super(url, network);
|
|
257
|
+
this.baseProvider = new BaseProvider(signal, url, network);
|
|
258
|
+
}
|
|
259
|
+
perform(method, params) {
|
|
260
|
+
return this.baseProvider.perform(method, params);
|
|
261
|
+
}
|
|
262
|
+
send(method, params) {
|
|
263
|
+
return this.baseProvider.send(method, params);
|
|
264
|
+
}
|
|
265
|
+
sendBatch(method, params) {
|
|
266
|
+
return this.baseProvider.sendBatch(method, params);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
exports.CustomL2JsonRpcProvider = CustomL2JsonRpcProvider;
|
|
270
|
+
//# sourceMappingURL=providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/providers.ts"],"names":[],"mappings":";;;AACA,mCAAmD;AACnD,4CAAuE;AACvE,iDAAyC;AAEzC,6CAAqD;AACrD,mCAAqC;AAErC,MAAM,YAAa,SAAQ,eAAM,CAAC,SAAS,CAAC,eAAe;IAmBzD,YACE,MAAmB,EACnB,GAA6B,EAC7B,OAAoB;QAEpB,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAvBd,yBAAoB,GAAG,IAAI,CAAC;QAC5B,iBAAY,GAAG,GAAG,GAAG,IAAI,CAAC;QAC1B,cAAS,GAAG,EAAE,CAAC;QACf,iBAAY,GAAG,CAAC,CAAC;QACjB,oBAAe,GAAG,CAAC,CAAC;QACpB,mBAAc,GAAG,EAAE,CAAC;QACpB,cAAS,GAAG,CAAC,CAAC;QACf,iBAAY,GAAG,KAAK,CAAC;QACrB,iBAAY,GAAQ,EAAE,CAAC;QACvB,qBAAgB,GAAG,KAAK,CAAC;QA+BxB,qBAAgB,GAAG,CAAI,SAA2B,EAAc,EAAE;YACxE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;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AAmB,EACnB,GAA6B,EAC7B,OAAoB;QAEpB,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC;CACF;AARD,sDAQC;AAED,MAAa,uBAAwB,SAAQ,wBAAQ;IAGnD,YACE,MAAmB,EACnB,GAA6B,EAC7B,OAAqC;QAErC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACpB,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,CAAC,MAAc,EAAE,MAAW;QACjC,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,CAAC,MAAc,EAAE,MAAa;QAChC,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;IAED,SAAS,CAAC,MAAc,EAAE,MAAoB;QAC5C,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;CACF;AAvBD,0DAuBC"}
|
package/cjs/signers.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getSyscoinSigners = void 0;
|
|
37
|
+
const syscoinjs = __importStar(require("syscoinjs-lib"));
|
|
38
|
+
const getSyscoinSigners = ({ mnemonic, rpc, }) => {
|
|
39
|
+
const { url, slip44, currency } = rpc.formattedNetwork;
|
|
40
|
+
let config = null;
|
|
41
|
+
let pubTypes = null;
|
|
42
|
+
let networks = null;
|
|
43
|
+
let isTestnet = false;
|
|
44
|
+
// Determine if this is a testnet based on slip44 and currency
|
|
45
|
+
isTestnet =
|
|
46
|
+
slip44 === 1 || Boolean(currency && currency.toLowerCase().startsWith('t'));
|
|
47
|
+
if (rpc.networkConfig) {
|
|
48
|
+
const { networkConfig } = rpc;
|
|
49
|
+
const { networks: _networkConfig, types } = networkConfig;
|
|
50
|
+
config = isTestnet ? _networkConfig.testnet : _networkConfig.mainnet;
|
|
51
|
+
networks = _networkConfig;
|
|
52
|
+
pubTypes = types.zPubType;
|
|
53
|
+
}
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
const hd = new syscoinjs.utils.HDSigner(mnemonic, null, isTestnet, // Use proper testnet flag
|
|
56
|
+
networks, slip44, pubTypes, 84);
|
|
57
|
+
const main = new syscoinjs.SyscoinJSLib(hd, url, config);
|
|
58
|
+
return {
|
|
59
|
+
hd,
|
|
60
|
+
main,
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
exports.getSyscoinSigners = getSyscoinSigners;
|
|
64
|
+
//# sourceMappingURL=signers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signers.js","sourceRoot":"","sources":["../../src/signers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,yDAA2C;AAEpC,MAAM,iBAAiB,GAAG,CAAC,EAChC,QAAQ,EACR,GAAG,GACkB,EAAsC,EAAE;IAC7D,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC,gBAAgB,CAAC;IACvD,IAAI,MAAM,GAA0B,IAAI,CAAC;IACzC,IAAI,QAAQ,GAAqB,IAAI,CAAC;IACtC,IAAI,QAAQ,GACV,IAAI,CAAC;IACP,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,8DAA8D;IAC9D,SAAS;QACP,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IAE9E,IAAI,GAAG,CAAC,aAAa,EAAE,CAAC;QACtB,MAAM,EAAE,aAAa,EAAE,GAAG,GAAG,CAAC;QAC9B,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC;QAE1D,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC;QACrE,QAAQ,GAAG,cAAc,CAAC;QAC1B,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;IAC5B,CAAC;IAED,aAAa;IACb,MAAM,EAAE,GAAoB,IAAI,SAAS,CAAC,KAAK,CAAC,QAAQ,CACtD,QAAQ,EACR,IAAI,EACJ,SAAS,EAAE,0BAA0B;IACrC,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,EAAE,CACH,CAAC;IAEF,MAAM,IAAI,GAAQ,IAAI,SAAS,CAAC,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IAE9D,OAAO;QACL,EAAE;QACF,IAAI;KACL,CAAC;AACJ,CAAC,CAAC;AAzCW,QAAA,iBAAiB,qBAyC5B"}
|
package/cjs/storage.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getDecryptedVault = exports.setEncryptedVault = void 0;
|
|
7
|
+
const sysweb3_core_1 = require("@sidhujag/sysweb3-core");
|
|
8
|
+
const crypto_js_1 = __importDefault(require("crypto-js"));
|
|
9
|
+
const storage = sysweb3_core_1.sysweb3Di.getStateStorageDb();
|
|
10
|
+
// Single vault for all networks - stores the mnemonic and can derive accounts for any slip44
|
|
11
|
+
const setEncryptedVault = async (decryptedVault, pwd) => {
|
|
12
|
+
const encryptedVault = crypto_js_1.default.AES.encrypt(JSON.stringify(decryptedVault), pwd);
|
|
13
|
+
// Always use single 'vault' key for all networks
|
|
14
|
+
await storage.set('vault', encryptedVault.toString());
|
|
15
|
+
};
|
|
16
|
+
exports.setEncryptedVault = setEncryptedVault;
|
|
17
|
+
const getDecryptedVault = async (pwd) => {
|
|
18
|
+
// Always use single 'vault' key
|
|
19
|
+
const vault = await storage.get('vault');
|
|
20
|
+
if (!vault) {
|
|
21
|
+
throw new Error('Vault not found');
|
|
22
|
+
}
|
|
23
|
+
const decryptedVault = crypto_js_1.default.AES.decrypt(vault, pwd).toString(crypto_js_1.default.enc.Utf8);
|
|
24
|
+
if (!decryptedVault) {
|
|
25
|
+
throw new Error('Failed to decrypt vault - invalid password or corrupted data');
|
|
26
|
+
}
|
|
27
|
+
return JSON.parse(decryptedVault);
|
|
28
|
+
};
|
|
29
|
+
exports.getDecryptedVault = getDecryptedVault;
|
|
30
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/storage.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAmD;AACnD,0DAAiC;AAEjC,MAAM,OAAO,GAAG,wBAAS,CAAC,iBAAiB,EAAE,CAAC;AAE9C,6FAA6F;AACtF,MAAM,iBAAiB,GAAG,KAAK,EAAE,cAAmB,EAAE,GAAW,EAAE,EAAE;IAC1E,MAAM,cAAc,GAAG,mBAAQ,CAAC,GAAG,CAAC,OAAO,CACzC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,EAC9B,GAAG,CACJ,CAAC;IAEF,iDAAiD;IACjD,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC;AACxD,CAAC,CAAC;AARW,QAAA,iBAAiB,qBAQ5B;AAEK,MAAM,iBAAiB,GAAG,KAAK,EAAE,GAAW,EAAE,EAAE;IACrD,gCAAgC;IAChC,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAEzC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,cAAc,GAAG,mBAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,QAAQ,CAC9D,mBAAQ,CAAC,GAAG,CAAC,IAAI,CAClB,CAAC;IAEF,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AACpC,CAAC,CAAC;AAnBW,QAAA,iBAAiB,qBAmB5B"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const types_1 = require("../../types");
|
|
4
|
+
const syscoin_1 = require("../syscoin");
|
|
5
|
+
// Integration tests for the complete transaction flow
|
|
6
|
+
describe('PSBT Transaction Flow Integration', () => {
|
|
7
|
+
let syscoinTransactions;
|
|
8
|
+
let mockSigner;
|
|
9
|
+
let mockState;
|
|
10
|
+
let mockLedger;
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
// Setup comprehensive mocks
|
|
13
|
+
mockSigner = {
|
|
14
|
+
hd: {
|
|
15
|
+
Signer: { network: 'mainnet' },
|
|
16
|
+
sign: jest.fn().mockResolvedValue('signed-psbt'),
|
|
17
|
+
},
|
|
18
|
+
main: {
|
|
19
|
+
blockbookURL: 'https://blockbook.test',
|
|
20
|
+
createPSBTFromRes: jest.fn().mockResolvedValue('unsigned-psbt'),
|
|
21
|
+
assetAllocationSend: jest.fn().mockResolvedValue({
|
|
22
|
+
psbt: 'unsigned-token-psbt',
|
|
23
|
+
}),
|
|
24
|
+
send: jest.fn().mockResolvedValue({
|
|
25
|
+
extractTransaction: () => ({ getId: () => 'final-txid' }),
|
|
26
|
+
}),
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
mockState = {
|
|
30
|
+
activeAccountId: 0,
|
|
31
|
+
activeAccountType: types_1.KeyringAccountType.HDAccount,
|
|
32
|
+
accounts: {
|
|
33
|
+
[types_1.KeyringAccountType.HDAccount]: {
|
|
34
|
+
0: { xpub: 'xpub123', id: 0 },
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
activeNetwork: { currency: 'sys', chainId: 57 },
|
|
38
|
+
};
|
|
39
|
+
mockLedger = {
|
|
40
|
+
ledgerTransport: true,
|
|
41
|
+
ledgerUtxoClient: {
|
|
42
|
+
getMasterFingerprint: jest.fn().mockResolvedValue('fingerprint'),
|
|
43
|
+
signPsbt: jest.fn().mockResolvedValue([[0, { signature: 'sig' }]]),
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
const mockGetAddress = jest.fn().mockResolvedValue('change-address');
|
|
47
|
+
const mockTrezor = {
|
|
48
|
+
init: jest.fn(),
|
|
49
|
+
convertToTrezorFormat: jest.fn(),
|
|
50
|
+
signUtxoTransaction: jest.fn(),
|
|
51
|
+
};
|
|
52
|
+
syscoinTransactions = new syscoin_1.SyscoinTransactions(() => mockSigner, () => mockSigner, // getReadOnlySigner - same mock for testing
|
|
53
|
+
() => mockState, mockGetAddress, mockLedger, mockTrezor);
|
|
54
|
+
});
|
|
55
|
+
describe('Complete Native Transaction Flow', () => {
|
|
56
|
+
it('should handle native transaction from creation to broadcast', async () => {
|
|
57
|
+
// Step 1: Create unsigned PSBT and get fee
|
|
58
|
+
const { fee, psbt: unsignedPsbt } = await syscoinTransactions.getEstimateSysTransactionFee({
|
|
59
|
+
amount: 1,
|
|
60
|
+
receivingAddress: 'sys1qtest',
|
|
61
|
+
feeRate: 0.00001,
|
|
62
|
+
});
|
|
63
|
+
expect(fee).toBeGreaterThan(0);
|
|
64
|
+
expect(unsignedPsbt).toBeDefined();
|
|
65
|
+
// Step 2: Sign the PSBT
|
|
66
|
+
const signedPsbt = await syscoinTransactions.signPSBT({
|
|
67
|
+
psbt: unsignedPsbt,
|
|
68
|
+
isTrezor: false,
|
|
69
|
+
isLedger: false,
|
|
70
|
+
});
|
|
71
|
+
// Step 3: Send the signed PSBT
|
|
72
|
+
const result = await syscoinTransactions.sendTransaction(signedPsbt);
|
|
73
|
+
expect(result.txid).toBe('final-txid');
|
|
74
|
+
expect(mockSigner.main.send).toHaveBeenCalledWith(signedPsbt);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
describe('Complete Token Transaction Flow', () => {
|
|
78
|
+
it('should handle token transaction from creation to broadcast', async () => {
|
|
79
|
+
// Mock token lookup
|
|
80
|
+
jest.doMock('@sidhujag/sysweb3-utils', () => ({
|
|
81
|
+
getAsset: jest.fn().mockResolvedValue({
|
|
82
|
+
assetGuid: 'token123',
|
|
83
|
+
decimals: 8,
|
|
84
|
+
}),
|
|
85
|
+
}));
|
|
86
|
+
// Step 1: Create unsigned token PSBT and get fee
|
|
87
|
+
const { fee, psbt: unsignedPsbt } = await syscoinTransactions.getEstimateSysTransactionFee({
|
|
88
|
+
amount: 100,
|
|
89
|
+
receivingAddress: 'sys1qtest',
|
|
90
|
+
token: { guid: 'token123', symbol: 'TEST' },
|
|
91
|
+
});
|
|
92
|
+
expect(fee).toBeGreaterThan(0);
|
|
93
|
+
expect(unsignedPsbt).toBeDefined();
|
|
94
|
+
expect(mockSigner.main.assetAllocationSend).toHaveBeenCalledWith(expect.any(Object), expect.any(Map), 'change-address', expect.any(Object), 'xpub123');
|
|
95
|
+
// Step 2: Sign the token PSBT
|
|
96
|
+
const signedPsbt = await syscoinTransactions.signPSBT({
|
|
97
|
+
psbt: unsignedPsbt,
|
|
98
|
+
isTrezor: false,
|
|
99
|
+
isLedger: false,
|
|
100
|
+
});
|
|
101
|
+
// Step 3: Send the signed PSBT
|
|
102
|
+
const result = await syscoinTransactions.sendTransaction(signedPsbt);
|
|
103
|
+
expect(result.txid).toBe('final-txid');
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
describe('Hardware Wallet Integration', () => {
|
|
107
|
+
it('should handle Trezor transaction flow', async () => {
|
|
108
|
+
const mockTrezor = {
|
|
109
|
+
init: jest.fn(),
|
|
110
|
+
convertToTrezorFormat: jest.fn().mockReturnValue('trezor-format'),
|
|
111
|
+
signUtxoTransaction: jest.fn().mockResolvedValue('trezor-signed-psbt'),
|
|
112
|
+
};
|
|
113
|
+
syscoinTransactions.trezor = mockTrezor;
|
|
114
|
+
// Create unsigned PSBT
|
|
115
|
+
const { fee, psbt: unsignedPsbt } = await syscoinTransactions.getEstimateSysTransactionFee({
|
|
116
|
+
amount: 1,
|
|
117
|
+
receivingAddress: 'sys1qtest',
|
|
118
|
+
});
|
|
119
|
+
expect(fee).toBeGreaterThan(0);
|
|
120
|
+
expect(unsignedPsbt).toBeDefined();
|
|
121
|
+
// Sign with Trezor
|
|
122
|
+
const signedPsbt = await syscoinTransactions.signPSBT({
|
|
123
|
+
psbt: unsignedPsbt,
|
|
124
|
+
isTrezor: true,
|
|
125
|
+
});
|
|
126
|
+
expect(mockTrezor.init).toHaveBeenCalled();
|
|
127
|
+
expect(mockTrezor.signUtxoTransaction).toHaveBeenCalled();
|
|
128
|
+
expect(signedPsbt).toBe('trezor-signed-psbt');
|
|
129
|
+
// Send
|
|
130
|
+
const result = await syscoinTransactions.sendTransaction(signedPsbt);
|
|
131
|
+
expect(result.txid).toBe('final-txid');
|
|
132
|
+
});
|
|
133
|
+
it('should handle Ledger transaction flow', async () => {
|
|
134
|
+
mockState.activeAccountType = types_1.KeyringAccountType.Ledger;
|
|
135
|
+
mockState.accounts[types_1.KeyringAccountType.Ledger] = {
|
|
136
|
+
0: { xpub: 'ledger-xpub', id: 0, isLedgerWallet: true },
|
|
137
|
+
};
|
|
138
|
+
// Mock Psbt for Ledger
|
|
139
|
+
jest.doMock('syscoinjs-lib', () => ({
|
|
140
|
+
Psbt: {
|
|
141
|
+
fromBase64: jest.fn().mockReturnValue({
|
|
142
|
+
updateInput: jest.fn(),
|
|
143
|
+
finalizeAllInputs: jest.fn(),
|
|
144
|
+
toBase64: jest.fn().mockReturnValue('ledger-signed-psbt'),
|
|
145
|
+
}),
|
|
146
|
+
},
|
|
147
|
+
}));
|
|
148
|
+
// Create unsigned PSBT
|
|
149
|
+
const { fee, psbt: unsignedPsbt } = await syscoinTransactions.getEstimateSysTransactionFee({
|
|
150
|
+
amount: 1,
|
|
151
|
+
receivingAddress: 'sys1qtest',
|
|
152
|
+
});
|
|
153
|
+
expect(fee).toBeGreaterThan(0);
|
|
154
|
+
expect(unsignedPsbt).toBeDefined();
|
|
155
|
+
// Sign with Ledger
|
|
156
|
+
const signedPsbt = await syscoinTransactions.signPSBT({
|
|
157
|
+
psbt: unsignedPsbt,
|
|
158
|
+
isLedger: true,
|
|
159
|
+
});
|
|
160
|
+
expect(mockLedger.ledgerUtxoClient.signPsbt).toHaveBeenCalled();
|
|
161
|
+
expect(signedPsbt).toBeDefined();
|
|
162
|
+
// Send
|
|
163
|
+
const result = await syscoinTransactions.sendTransaction(signedPsbt);
|
|
164
|
+
expect(result.txid).toBe('final-txid');
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
describe('Error Scenarios', () => {
|
|
168
|
+
it('should handle signing errors separately from sending errors', async () => {
|
|
169
|
+
// Test signing error
|
|
170
|
+
mockSigner.hd.sign = jest
|
|
171
|
+
.fn()
|
|
172
|
+
.mockRejectedValue(new Error('Device disconnected'));
|
|
173
|
+
await expect(syscoinTransactions.getEstimateSysTransactionFee({
|
|
174
|
+
amount: 1,
|
|
175
|
+
receivingAddress: 'sys1qtest',
|
|
176
|
+
})).rejects.toThrow('Failed to sign transaction: Device disconnected');
|
|
177
|
+
// Test sending error
|
|
178
|
+
mockSigner.main.send = jest
|
|
179
|
+
.fn()
|
|
180
|
+
.mockRejectedValue(new Error('Network error'));
|
|
181
|
+
await expect(syscoinTransactions.sendTransaction('valid-psbt')).rejects.toThrow('Failed to send transaction');
|
|
182
|
+
});
|
|
183
|
+
it('should require PSBT for sendTransaction', async () => {
|
|
184
|
+
await expect(syscoinTransactions.sendTransaction('')).rejects.toThrow('Pre-signed PSBT is required');
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
describe('Fee Calculation', () => {
|
|
188
|
+
it('should calculate correct fees for multi-input transactions', async () => {
|
|
189
|
+
// Mock multiple UTXOs
|
|
190
|
+
const mockUtxos = [
|
|
191
|
+
{ txid: 'tx1', vout: 0, value: '50000000' },
|
|
192
|
+
{ txid: 'tx2', vout: 1, value: '30000000' },
|
|
193
|
+
{ txid: 'tx3', vout: 0, value: '20000000' },
|
|
194
|
+
];
|
|
195
|
+
jest.doMock('syscoinjs-lib', () => ({
|
|
196
|
+
utils: {
|
|
197
|
+
fetchBackendUTXOS: jest.fn().mockResolvedValue(mockUtxos),
|
|
198
|
+
sanitizeBlockbookUTXOs: jest.fn().mockReturnValue(mockUtxos),
|
|
199
|
+
},
|
|
200
|
+
}));
|
|
201
|
+
jest.doMock('coinselectsyscoin', () => ({
|
|
202
|
+
utils: {
|
|
203
|
+
transactionBytes: jest.fn().mockReturnValue(500), // Larger tx with multiple inputs
|
|
204
|
+
},
|
|
205
|
+
}));
|
|
206
|
+
const { fee } = await syscoinTransactions.getEstimateSysTransactionFee({
|
|
207
|
+
amount: 0.8, // Amount that requires multiple UTXOs
|
|
208
|
+
receivingAddress: 'sys1qtest',
|
|
209
|
+
feeRate: 0.00001,
|
|
210
|
+
});
|
|
211
|
+
// Fee should be proportional to transaction size
|
|
212
|
+
expect(fee).toBeGreaterThan(0.00001); // More than minimum
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
describe('RBF Support', () => {
|
|
216
|
+
it('should create RBF-enabled transactions by default', async () => {
|
|
217
|
+
await syscoinTransactions.getEstimateSysTransactionFee({
|
|
218
|
+
amount: 1,
|
|
219
|
+
receivingAddress: 'sys1qtest',
|
|
220
|
+
});
|
|
221
|
+
// Check that RBF was enabled in the transaction options
|
|
222
|
+
expect(mockSigner.main.createPSBTFromRes).toHaveBeenCalled();
|
|
223
|
+
const callArgs = mockSigner.main.createPSBTFromRes.mock.calls[0];
|
|
224
|
+
expect(callArgs[0]).toMatchObject({ rbf: true });
|
|
225
|
+
});
|
|
226
|
+
it('should disable RBF when requested', async () => {
|
|
227
|
+
await syscoinTransactions.getEstimateSysTransactionFee({
|
|
228
|
+
amount: 1,
|
|
229
|
+
receivingAddress: 'sys1qtest',
|
|
230
|
+
txOptions: { rbf: false },
|
|
231
|
+
});
|
|
232
|
+
const callArgs = mockSigner.main.createPSBTFromRes.mock.calls[0];
|
|
233
|
+
expect(callArgs[0]).toMatchObject({ rbf: false });
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
//# sourceMappingURL=integration.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration.test.js","sourceRoot":"","sources":["../../../../src/transactions/__tests__/integration.test.ts"],"names":[],"mappings":";;AAAA,uCAAiD;AACjD,wCAAiD;AAEjD,sDAAsD;AACtD,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;IACjD,IAAI,mBAAwC,CAAC;IAC7C,IAAI,UAAe,CAAC;IACpB,IAAI,SAAc,CAAC;IACnB,IAAI,UAAe,CAAC;IAEpB,UAAU,CAAC,GAAG,EAAE;QACd,4BAA4B;QAC5B,UAAU,GAAG;YACX,EAAE,EAAE;gBACF,MAAM,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;gBAC9B,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,aAAa,CAAC;aACjD;YACD,IAAI,EAAE;gBACJ,YAAY,EAAE,wBAAwB;gBACtC,iBAAiB,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC;gBAC/D,mBAAmB,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC;oBAC/C,IAAI,EAAE,qBAAqB;iBAC5B,CAAC;gBACF,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC;oBAChC,kBAAkB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,YAAY,EAAE,CA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