phantasma-sdk-ts 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/core/link/easyConnect.js +20 -2
- package/dist/cjs/core/link/phantasmaLink.js +85 -4
- package/dist/esm/core/link/easyConnect.js +20 -2
- package/dist/esm/core/link/phantasmaLink.js +86 -5
- package/dist/types/core/link/easyConnect.d.ts +3 -1
- package/dist/types/core/link/easyConnect.d.ts.map +1 -1
- package/dist/types/core/link/phantasmaLink.d.ts +9 -1
- package/dist/types/core/link/phantasmaLink.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -13,8 +13,7 @@ class EasyConnect {
|
|
|
13
13
|
this.link = new phantasmaLink_js_1.PhantasmaLink('easyConnect', false);
|
|
14
14
|
this.connected = false;
|
|
15
15
|
this.requiredVersion = 4;
|
|
16
|
-
|
|
17
|
-
this.nexus = easyScript_js_1.Nexus.Mainnet;
|
|
16
|
+
this.nexus = null;
|
|
18
17
|
if (_options == null) {
|
|
19
18
|
this.setConfig('auto');
|
|
20
19
|
}
|
|
@@ -59,6 +58,12 @@ class EasyConnect {
|
|
|
59
58
|
//Console Logging for Debugging Purposes
|
|
60
59
|
if (data) {
|
|
61
60
|
that.connected = true;
|
|
61
|
+
that.nexus =
|
|
62
|
+
that.link.nexus === easyScript_js_1.Nexus.Mainnet ||
|
|
63
|
+
that.link.nexus === easyScript_js_1.Nexus.Simnet ||
|
|
64
|
+
that.link.nexus === easyScript_js_1.Nexus.Testnet
|
|
65
|
+
? that.link.nexus
|
|
66
|
+
: null;
|
|
62
67
|
onSuccess(data);
|
|
63
68
|
logger_js_1.logger.log('%c[EasyConnect Connected]', 'color:green');
|
|
64
69
|
logger_js_1.logger.log("Wallet Address '" + that.link.account.address + "' connected via " + that.link.wallet);
|
|
@@ -72,6 +77,7 @@ class EasyConnect {
|
|
|
72
77
|
disconnect(_message = 'Graceful Disconect') {
|
|
73
78
|
this.link.disconnect(_message);
|
|
74
79
|
this.connected = false;
|
|
80
|
+
this.nexus = null;
|
|
75
81
|
}
|
|
76
82
|
async query(_type = null, _arguments = null, _callback = (data) => {
|
|
77
83
|
logger_js_1.logger.log(data);
|
|
@@ -160,6 +166,18 @@ class EasyConnect {
|
|
|
160
166
|
onFail(message);
|
|
161
167
|
}
|
|
162
168
|
}
|
|
169
|
+
signPrebuiltTransaction(tx, onSuccess = (data) => { }, onFail = (data) => {
|
|
170
|
+
logger_js_1.logger.log('%cError: ' + data, 'color:red');
|
|
171
|
+
}) {
|
|
172
|
+
if (this.connected == true) {
|
|
173
|
+
this.link.signPrebuiltTransaction(tx, onSuccess, onFail);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
const message = 'Wallet is not connected';
|
|
177
|
+
logger_js_1.logger.log('%c' + message, 'color:red');
|
|
178
|
+
onFail(message);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
163
181
|
invokeScript(script, _callback) {
|
|
164
182
|
this.link.invokeScript(script, _callback);
|
|
165
183
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PhantasmaLink = void 0;
|
|
4
|
+
const Transaction_js_1 = require("../tx/Transaction.js");
|
|
4
5
|
const index_js_1 = require("../vm/index.js");
|
|
5
6
|
const ProofOfWork_js_1 = require("./interfaces/ProofOfWork.js");
|
|
6
7
|
const CarbonBlob_js_1 = require("../types/Carbon/CarbonBlob.js");
|
|
7
8
|
const Hex_js_1 = require("../utils/Hex.js");
|
|
9
|
+
const index_js_2 = require("../types/index.js");
|
|
8
10
|
const logger_js_1 = require("../utils/logger.js");
|
|
9
11
|
class PhantasmaLink {
|
|
10
12
|
//Construct The Link
|
|
@@ -20,7 +22,7 @@ class PhantasmaLink {
|
|
|
20
22
|
}
|
|
21
23
|
};
|
|
22
24
|
this.version = 4;
|
|
23
|
-
this.nexus = '
|
|
25
|
+
this.nexus = '';
|
|
24
26
|
this.chain = 'main';
|
|
25
27
|
this.platform = 'poltergeist';
|
|
26
28
|
//Turn On|Off Console Logging
|
|
@@ -204,19 +206,26 @@ class PhantasmaLink {
|
|
|
204
206
|
signTxSignature(tx, callback, onErrorCallback, signature = 'Ed25519') {
|
|
205
207
|
if (!this.socket) {
|
|
206
208
|
this.onMessage('not logged in');
|
|
209
|
+
if (onErrorCallback) {
|
|
210
|
+
onErrorCallback('Wallet is not connected');
|
|
211
|
+
}
|
|
207
212
|
return;
|
|
208
213
|
}
|
|
209
214
|
if (tx == null) {
|
|
210
215
|
this.onMessage('invalid data, sorry :(');
|
|
216
|
+
if (onErrorCallback) {
|
|
217
|
+
onErrorCallback('Invalid transaction data');
|
|
218
|
+
}
|
|
211
219
|
return;
|
|
212
220
|
}
|
|
213
|
-
if (tx.length >=
|
|
221
|
+
if (tx.length >= 65536) {
|
|
214
222
|
this.onMessage('data too big, sorry :(');
|
|
215
223
|
if (onErrorCallback) {
|
|
216
|
-
onErrorCallback();
|
|
224
|
+
onErrorCallback('Transaction data is too big');
|
|
217
225
|
}
|
|
218
226
|
return;
|
|
219
227
|
}
|
|
228
|
+
this.onError = onErrorCallback;
|
|
220
229
|
let signDataStr = 'signTxSignature/' + tx + '/' + signature + '/' + this.platform;
|
|
221
230
|
var that = this; //Allows the use of 'this' inside sendLinkRequest Object
|
|
222
231
|
this.sendLinkRequest(signDataStr, function (result) {
|
|
@@ -228,11 +237,78 @@ class PhantasmaLink {
|
|
|
228
237
|
}
|
|
229
238
|
else {
|
|
230
239
|
if (onErrorCallback) {
|
|
231
|
-
onErrorCallback();
|
|
240
|
+
onErrorCallback(that.describeFailure(result, 'Wallet rejected transaction signature'));
|
|
232
241
|
}
|
|
233
242
|
}
|
|
234
243
|
});
|
|
235
244
|
}
|
|
245
|
+
decodeWalletSignatureBytes(signatureHex, signature) {
|
|
246
|
+
if (signature !== 'Ed25519') {
|
|
247
|
+
throw new Error(`Unsupported transaction signature type: ${signature}`);
|
|
248
|
+
}
|
|
249
|
+
const reader = new index_js_2.PBinaryReader((0, Hex_js_1.hexToBytes)(signatureHex));
|
|
250
|
+
const rawSignatureHex = reader.readByteArray();
|
|
251
|
+
if (typeof rawSignatureHex !== 'string' || rawSignatureHex.length === 0) {
|
|
252
|
+
throw new Error('Wallet returned an empty transaction signature');
|
|
253
|
+
}
|
|
254
|
+
return (0, Hex_js_1.hexToBytes)(rawSignatureHex);
|
|
255
|
+
}
|
|
256
|
+
signPrebuiltTransaction(tx, callback, onErrorCallback, signature = 'Ed25519') {
|
|
257
|
+
if (!tx) {
|
|
258
|
+
const message = 'Error: Invalid transaction';
|
|
259
|
+
this.onMessage(message);
|
|
260
|
+
if (onErrorCallback) {
|
|
261
|
+
onErrorCallback(message);
|
|
262
|
+
}
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
let unsignedTxHex;
|
|
266
|
+
try {
|
|
267
|
+
unsignedTxHex = tx.ToStringEncoded(false).toUpperCase();
|
|
268
|
+
}
|
|
269
|
+
catch (err) {
|
|
270
|
+
const message = 'Error: Unable to encode unsigned transaction';
|
|
271
|
+
this.onMessage(message + (err?.message ? ` (${err.message})` : ''));
|
|
272
|
+
if (onErrorCallback) {
|
|
273
|
+
onErrorCallback(message);
|
|
274
|
+
}
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
this.signTxSignature(unsignedTxHex, (result) => {
|
|
278
|
+
if (!result?.success || typeof result.signature !== 'string' || result.signature.length === 0) {
|
|
279
|
+
const failure = this.describeFailure(result, 'Wallet rejected transaction signature');
|
|
280
|
+
if (onErrorCallback) {
|
|
281
|
+
onErrorCallback(failure);
|
|
282
|
+
}
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
try {
|
|
286
|
+
const signedTx = Transaction_js_1.Transaction.FromBytes(unsignedTxHex);
|
|
287
|
+
signedTx.signatures = [
|
|
288
|
+
new index_js_2.Ed25519Signature(this.decodeWalletSignatureBytes(result.signature, signature)),
|
|
289
|
+
];
|
|
290
|
+
if (this.account?.address && !signedTx.VerifySignature(this.account.address)) {
|
|
291
|
+
throw new Error('Wallet returned a signature that does not match the connected account');
|
|
292
|
+
}
|
|
293
|
+
callback({
|
|
294
|
+
success: true,
|
|
295
|
+
signature: result.signature,
|
|
296
|
+
signedTx: signedTx.ToStringEncoded(true).toUpperCase(),
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
catch (err) {
|
|
300
|
+
const message = err?.message || 'Unable to assemble signed transaction';
|
|
301
|
+
if (onErrorCallback) {
|
|
302
|
+
onErrorCallback(message);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}, (message) => {
|
|
306
|
+
const failure = message || this.lastSocketErrorMessage || 'Wallet rejected transaction signature';
|
|
307
|
+
if (onErrorCallback) {
|
|
308
|
+
onErrorCallback(failure);
|
|
309
|
+
}
|
|
310
|
+
}, signature);
|
|
311
|
+
}
|
|
236
312
|
multiSig(subject, callback, onErrorCallback, signature = 'Ed25519') {
|
|
237
313
|
if (!this.socket) {
|
|
238
314
|
this.onMessage('not logged in');
|
|
@@ -307,6 +383,9 @@ class PhantasmaLink {
|
|
|
307
383
|
//Sends Signiture Request To Connected Wallet For Script
|
|
308
384
|
this.sendLinkRequest('getNexus/', function (result) {
|
|
309
385
|
if (result.success) {
|
|
386
|
+
if (typeof result.nexus === 'string') {
|
|
387
|
+
that.nexus = result.nexus;
|
|
388
|
+
}
|
|
310
389
|
that.onMessage('Nexus Query,: ' + result);
|
|
311
390
|
if (callback) {
|
|
312
391
|
callback(result);
|
|
@@ -395,6 +474,7 @@ class PhantasmaLink {
|
|
|
395
474
|
this.lastSocketErrorMessage = null;
|
|
396
475
|
this.token = null;
|
|
397
476
|
this.account = null;
|
|
477
|
+
this.nexus = '';
|
|
398
478
|
this.requestID = 0;
|
|
399
479
|
let authorizeRequest = 'authorize/' + this.dapp + '/' + this.version;
|
|
400
480
|
let getAccountRequest = 'getAccount/' + this.platform;
|
|
@@ -412,6 +492,7 @@ class PhantasmaLink {
|
|
|
412
492
|
if (result.success) {
|
|
413
493
|
that.token = result.token;
|
|
414
494
|
that.wallet = result.wallet;
|
|
495
|
+
that.nexus = typeof result.nexus === 'string' ? result.nexus : '';
|
|
415
496
|
that.onMessage('Authorized, obtaining account info...');
|
|
416
497
|
that.sendLinkRequest(getAccountRequest, function (result) {
|
|
417
498
|
if (result.success) {
|
|
@@ -10,8 +10,7 @@ export class EasyConnect {
|
|
|
10
10
|
this.link = new PhantasmaLink('easyConnect', false);
|
|
11
11
|
this.connected = false;
|
|
12
12
|
this.requiredVersion = 4;
|
|
13
|
-
|
|
14
|
-
this.nexus = Nexus.Mainnet;
|
|
13
|
+
this.nexus = null;
|
|
15
14
|
if (_options == null) {
|
|
16
15
|
this.setConfig('auto');
|
|
17
16
|
}
|
|
@@ -56,6 +55,12 @@ export class EasyConnect {
|
|
|
56
55
|
//Console Logging for Debugging Purposes
|
|
57
56
|
if (data) {
|
|
58
57
|
that.connected = true;
|
|
58
|
+
that.nexus =
|
|
59
|
+
that.link.nexus === Nexus.Mainnet ||
|
|
60
|
+
that.link.nexus === Nexus.Simnet ||
|
|
61
|
+
that.link.nexus === Nexus.Testnet
|
|
62
|
+
? that.link.nexus
|
|
63
|
+
: null;
|
|
59
64
|
onSuccess(data);
|
|
60
65
|
logger.log('%c[EasyConnect Connected]', 'color:green');
|
|
61
66
|
logger.log("Wallet Address '" + that.link.account.address + "' connected via " + that.link.wallet);
|
|
@@ -69,6 +74,7 @@ export class EasyConnect {
|
|
|
69
74
|
disconnect(_message = 'Graceful Disconect') {
|
|
70
75
|
this.link.disconnect(_message);
|
|
71
76
|
this.connected = false;
|
|
77
|
+
this.nexus = null;
|
|
72
78
|
}
|
|
73
79
|
async query(_type = null, _arguments = null, _callback = (data) => {
|
|
74
80
|
logger.log(data);
|
|
@@ -157,6 +163,18 @@ export class EasyConnect {
|
|
|
157
163
|
onFail(message);
|
|
158
164
|
}
|
|
159
165
|
}
|
|
166
|
+
signPrebuiltTransaction(tx, onSuccess = (data) => { }, onFail = (data) => {
|
|
167
|
+
logger.log('%cError: ' + data, 'color:red');
|
|
168
|
+
}) {
|
|
169
|
+
if (this.connected == true) {
|
|
170
|
+
this.link.signPrebuiltTransaction(tx, onSuccess, onFail);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
const message = 'Wallet is not connected';
|
|
174
|
+
logger.log('%c' + message, 'color:red');
|
|
175
|
+
onFail(message);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
160
178
|
invokeScript(script, _callback) {
|
|
161
179
|
this.link.invokeScript(script, _callback);
|
|
162
180
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { Transaction } from '../tx/Transaction.js';
|
|
1
2
|
import { ScriptBuilder } from '../vm/index.js';
|
|
2
3
|
import { ProofOfWork } from './interfaces/ProofOfWork.js';
|
|
3
4
|
import { CarbonBlob } from '../types/Carbon/CarbonBlob.js';
|
|
4
|
-
import { bytesToHex } from '../utils/Hex.js';
|
|
5
|
+
import { bytesToHex, hexToBytes } from '../utils/Hex.js';
|
|
6
|
+
import { Ed25519Signature, PBinaryReader } from '../types/index.js';
|
|
5
7
|
import { logger } from '../utils/logger.js';
|
|
6
8
|
export class PhantasmaLink {
|
|
7
9
|
//Construct The Link
|
|
@@ -17,7 +19,7 @@ export class PhantasmaLink {
|
|
|
17
19
|
}
|
|
18
20
|
};
|
|
19
21
|
this.version = 4;
|
|
20
|
-
this.nexus = '
|
|
22
|
+
this.nexus = '';
|
|
21
23
|
this.chain = 'main';
|
|
22
24
|
this.platform = 'poltergeist';
|
|
23
25
|
//Turn On|Off Console Logging
|
|
@@ -201,19 +203,26 @@ export class PhantasmaLink {
|
|
|
201
203
|
signTxSignature(tx, callback, onErrorCallback, signature = 'Ed25519') {
|
|
202
204
|
if (!this.socket) {
|
|
203
205
|
this.onMessage('not logged in');
|
|
206
|
+
if (onErrorCallback) {
|
|
207
|
+
onErrorCallback('Wallet is not connected');
|
|
208
|
+
}
|
|
204
209
|
return;
|
|
205
210
|
}
|
|
206
211
|
if (tx == null) {
|
|
207
212
|
this.onMessage('invalid data, sorry :(');
|
|
213
|
+
if (onErrorCallback) {
|
|
214
|
+
onErrorCallback('Invalid transaction data');
|
|
215
|
+
}
|
|
208
216
|
return;
|
|
209
217
|
}
|
|
210
|
-
if (tx.length >=
|
|
218
|
+
if (tx.length >= 65536) {
|
|
211
219
|
this.onMessage('data too big, sorry :(');
|
|
212
220
|
if (onErrorCallback) {
|
|
213
|
-
onErrorCallback();
|
|
221
|
+
onErrorCallback('Transaction data is too big');
|
|
214
222
|
}
|
|
215
223
|
return;
|
|
216
224
|
}
|
|
225
|
+
this.onError = onErrorCallback;
|
|
217
226
|
let signDataStr = 'signTxSignature/' + tx + '/' + signature + '/' + this.platform;
|
|
218
227
|
var that = this; //Allows the use of 'this' inside sendLinkRequest Object
|
|
219
228
|
this.sendLinkRequest(signDataStr, function (result) {
|
|
@@ -225,11 +234,78 @@ export class PhantasmaLink {
|
|
|
225
234
|
}
|
|
226
235
|
else {
|
|
227
236
|
if (onErrorCallback) {
|
|
228
|
-
onErrorCallback();
|
|
237
|
+
onErrorCallback(that.describeFailure(result, 'Wallet rejected transaction signature'));
|
|
229
238
|
}
|
|
230
239
|
}
|
|
231
240
|
});
|
|
232
241
|
}
|
|
242
|
+
decodeWalletSignatureBytes(signatureHex, signature) {
|
|
243
|
+
if (signature !== 'Ed25519') {
|
|
244
|
+
throw new Error(`Unsupported transaction signature type: ${signature}`);
|
|
245
|
+
}
|
|
246
|
+
const reader = new PBinaryReader(hexToBytes(signatureHex));
|
|
247
|
+
const rawSignatureHex = reader.readByteArray();
|
|
248
|
+
if (typeof rawSignatureHex !== 'string' || rawSignatureHex.length === 0) {
|
|
249
|
+
throw new Error('Wallet returned an empty transaction signature');
|
|
250
|
+
}
|
|
251
|
+
return hexToBytes(rawSignatureHex);
|
|
252
|
+
}
|
|
253
|
+
signPrebuiltTransaction(tx, callback, onErrorCallback, signature = 'Ed25519') {
|
|
254
|
+
if (!tx) {
|
|
255
|
+
const message = 'Error: Invalid transaction';
|
|
256
|
+
this.onMessage(message);
|
|
257
|
+
if (onErrorCallback) {
|
|
258
|
+
onErrorCallback(message);
|
|
259
|
+
}
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
let unsignedTxHex;
|
|
263
|
+
try {
|
|
264
|
+
unsignedTxHex = tx.ToStringEncoded(false).toUpperCase();
|
|
265
|
+
}
|
|
266
|
+
catch (err) {
|
|
267
|
+
const message = 'Error: Unable to encode unsigned transaction';
|
|
268
|
+
this.onMessage(message + (err?.message ? ` (${err.message})` : ''));
|
|
269
|
+
if (onErrorCallback) {
|
|
270
|
+
onErrorCallback(message);
|
|
271
|
+
}
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
this.signTxSignature(unsignedTxHex, (result) => {
|
|
275
|
+
if (!result?.success || typeof result.signature !== 'string' || result.signature.length === 0) {
|
|
276
|
+
const failure = this.describeFailure(result, 'Wallet rejected transaction signature');
|
|
277
|
+
if (onErrorCallback) {
|
|
278
|
+
onErrorCallback(failure);
|
|
279
|
+
}
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
try {
|
|
283
|
+
const signedTx = Transaction.FromBytes(unsignedTxHex);
|
|
284
|
+
signedTx.signatures = [
|
|
285
|
+
new Ed25519Signature(this.decodeWalletSignatureBytes(result.signature, signature)),
|
|
286
|
+
];
|
|
287
|
+
if (this.account?.address && !signedTx.VerifySignature(this.account.address)) {
|
|
288
|
+
throw new Error('Wallet returned a signature that does not match the connected account');
|
|
289
|
+
}
|
|
290
|
+
callback({
|
|
291
|
+
success: true,
|
|
292
|
+
signature: result.signature,
|
|
293
|
+
signedTx: signedTx.ToStringEncoded(true).toUpperCase(),
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
catch (err) {
|
|
297
|
+
const message = err?.message || 'Unable to assemble signed transaction';
|
|
298
|
+
if (onErrorCallback) {
|
|
299
|
+
onErrorCallback(message);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}, (message) => {
|
|
303
|
+
const failure = message || this.lastSocketErrorMessage || 'Wallet rejected transaction signature';
|
|
304
|
+
if (onErrorCallback) {
|
|
305
|
+
onErrorCallback(failure);
|
|
306
|
+
}
|
|
307
|
+
}, signature);
|
|
308
|
+
}
|
|
233
309
|
multiSig(subject, callback, onErrorCallback, signature = 'Ed25519') {
|
|
234
310
|
if (!this.socket) {
|
|
235
311
|
this.onMessage('not logged in');
|
|
@@ -304,6 +380,9 @@ export class PhantasmaLink {
|
|
|
304
380
|
//Sends Signiture Request To Connected Wallet For Script
|
|
305
381
|
this.sendLinkRequest('getNexus/', function (result) {
|
|
306
382
|
if (result.success) {
|
|
383
|
+
if (typeof result.nexus === 'string') {
|
|
384
|
+
that.nexus = result.nexus;
|
|
385
|
+
}
|
|
307
386
|
that.onMessage('Nexus Query,: ' + result);
|
|
308
387
|
if (callback) {
|
|
309
388
|
callback(result);
|
|
@@ -392,6 +471,7 @@ export class PhantasmaLink {
|
|
|
392
471
|
this.lastSocketErrorMessage = null;
|
|
393
472
|
this.token = null;
|
|
394
473
|
this.account = null;
|
|
474
|
+
this.nexus = '';
|
|
395
475
|
this.requestID = 0;
|
|
396
476
|
let authorizeRequest = 'authorize/' + this.dapp + '/' + this.version;
|
|
397
477
|
let getAccountRequest = 'getAccount/' + this.platform;
|
|
@@ -409,6 +489,7 @@ export class PhantasmaLink {
|
|
|
409
489
|
if (result.success) {
|
|
410
490
|
that.token = result.token;
|
|
411
491
|
that.wallet = result.wallet;
|
|
492
|
+
that.nexus = typeof result.nexus === 'string' ? result.nexus : '';
|
|
412
493
|
that.onMessage('Authorized, obtaining account info...');
|
|
413
494
|
that.sendLinkRequest(getAccountRequest, function (result) {
|
|
414
495
|
if (result.success) {
|
|
@@ -2,6 +2,7 @@ import { PhantasmaLink } from './phantasmaLink.js';
|
|
|
2
2
|
import { ProofOfWork } from './interfaces/ProofOfWork.js';
|
|
3
3
|
import { EasyScript, Nexus } from './easyScript.js';
|
|
4
4
|
import { TxMsg } from '../types/Carbon/Blockchain/index.js';
|
|
5
|
+
import { Transaction } from '../tx/Transaction.js';
|
|
5
6
|
export declare class EasyConnect {
|
|
6
7
|
requiredVersion: number;
|
|
7
8
|
platform: string;
|
|
@@ -9,7 +10,7 @@ export declare class EasyConnect {
|
|
|
9
10
|
link: PhantasmaLink;
|
|
10
11
|
connected: boolean;
|
|
11
12
|
script: EasyScript;
|
|
12
|
-
nexus: Nexus;
|
|
13
|
+
nexus: Nexus | null;
|
|
13
14
|
constructor(_options?: Array<string>);
|
|
14
15
|
setConfig(_provider: string): void;
|
|
15
16
|
connect(onSuccess?: any, onFail?: any): void;
|
|
@@ -19,6 +20,7 @@ export declare class EasyConnect {
|
|
|
19
20
|
signTransaction(script: string, payload?: any, onSuccess?: any, onFail?: any): void;
|
|
20
21
|
signData(data: any, onSuccess?: any, onFail?: any): void;
|
|
21
22
|
signCarbonTransaction(txMsg: TxMsg, onSuccess?: any, onFail?: any): void;
|
|
23
|
+
signPrebuiltTransaction(tx: Transaction, onSuccess?: any, onFail?: any): void;
|
|
22
24
|
invokeScript(script: string, _callback: any): void;
|
|
23
25
|
deployContract(script: string, payload?: any, proofOfWork?: ProofOfWork, onSuccess?: any, onFail?: any): void;
|
|
24
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"easyConnect.d.ts","sourceRoot":"","sources":["../../../../src/core/link/easyConnect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"easyConnect.d.ts","sourceRoot":"","sources":["../../../../src/core/link/easy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IAWH,uBAAuB,CACrB,EAAE,EAAE,WAAW,EACf,SAAS,GAAE,GAAkB,EAC7B,MAAM,GAAE,GAEP;IAWH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG;IAI3C,cAAc,CACZ,MAAM,EAAE,MAAM,EACd,OAAO,MAAO,EACd,WAAW,GAAE,WAAiC,EAC9C,SAAS,GAAE,GAAkB,EAC7B,MAAM,GAAE,GAEP;CAIJ"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { Transaction } from '../tx/Transaction.js';
|
|
1
2
|
import { ProofOfWork } from './interfaces/ProofOfWork.js';
|
|
2
3
|
import { IAccount } from './interfaces/IAccount.js';
|
|
3
4
|
import { TxMsg } from '../types/Carbon/Blockchain/index.js';
|
|
5
|
+
export interface PrebuiltTransactionSignResult {
|
|
6
|
+
success: true;
|
|
7
|
+
signature: string;
|
|
8
|
+
signedTx: string;
|
|
9
|
+
}
|
|
4
10
|
export declare class PhantasmaLink {
|
|
5
11
|
host: string;
|
|
6
12
|
dapp: any;
|
|
@@ -28,7 +34,9 @@ export declare class PhantasmaLink {
|
|
|
28
34
|
invokeScript(script: string, callback: (message: string) => void): void;
|
|
29
35
|
signTx(script: any, payload: string | null, callback: (arg0: string) => void, onErrorCallback: () => void, pow?: ProofOfWork, signature?: string): void;
|
|
30
36
|
signCarbonTxAndBroadcast(txMsg: TxMsg, callback?: (result: any) => void, onErrorCallback?: (message?: string) => void): void;
|
|
31
|
-
signTxSignature(tx: string, callback: (result: string) => void, onErrorCallback: () => void, signature?: string): void;
|
|
37
|
+
signTxSignature(tx: string, callback: (result: string) => void, onErrorCallback: (message?: string) => void, signature?: string): void;
|
|
38
|
+
private decodeWalletSignatureBytes;
|
|
39
|
+
signPrebuiltTransaction(tx: Transaction, callback: (result: PrebuiltTransactionSignResult) => void, onErrorCallback: (message?: string) => void, signature?: string): void;
|
|
32
40
|
multiSig(subject: string, callback: (result: string) => void, onErrorCallback: () => void, signature?: string): void;
|
|
33
41
|
getPeer(callback: (result: string) => void, onErrorCallback: () => void): void;
|
|
34
42
|
fetchWallet(callback: (result: any) => void, onErrorCallback: (message: any) => void): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phantasmaLink.d.ts","sourceRoot":"","sources":["../../../../src/core/link/phantasmaLink.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"phantasmaLink.d.ts","sourceRoot":"","sources":["../../../../src/core/link/phantasmaLink.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAM5D,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,IAAI,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,aAAa;IAExB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAC7B,YAAY,EAAE,GAAG,CAAC;IAClB,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IAChC,MAAM,EAAE,GAAG,CAAC;IACZ,eAAe,EAAE,GAAG,CAAC;IACrB,OAAO,CAAC,sBAAsB,CAAuB;IACrD,eAAe,EAAE,WAAW,GAAG,UAAU,GAAG,IAAI,CAAQ;IACxD,UAAU,EAAE,OAAO,CAAS;IAC5B,KAAK,EAAE,GAAG,CAAC;IACX,SAAS,EAAE,MAAM,CAAK;IACtB,OAAO,EAAE,QAAQ,CAAC;IAClB,MAAM,EAAE,GAAG,CAAC;IACZ,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,M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