@ledgerhq/wallet-api-exchange-module 0.9.0 → 0.10.0-nightly.1
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/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +58 -81
- package/lib/index.js.map +1 -1
- package/lib-es/index.d.ts +1 -0
- package/lib-es/index.d.ts.map +1 -1
- package/lib-es/index.js +58 -81
- package/lib-es/index.js.map +1 -1
- package/package.json +6 -6
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { CustomModule, Transaction } from "@ledgerhq/wallet-api-client";
|
|
3
4
|
import { ExchangeCompleteParams, ExchangeStartSellParams, ExchangeStartSwapParams, SwapLiveError } from "./types";
|
|
4
5
|
export * from "./types";
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAwB,MAAM,6BAA6B,CAAC;AAC9F,OAAO,EACL,sBAAsB,EAItB,uBAAuB,EACvB,uBAAuB,EACvB,aAAa,EACd,MAAM,SAAS,CAAC;AAEjB,cAAc,SAAS,CAAC;AAGxB,qBAAa,cAAe,SAAQ,YAAY;IAC9C;;;;;OAKG;IACG,SAAS;IAWf;;;;;OAKG;IACG,SAAS,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,IAAI,CAAC,uBAAuB,EAAE,cAAc,CAAC;IAa1F;;;;;OAKG;IACG,SAAS,CAAC,EACd,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,WAAW,EACX,aAAa,GACd,EAAE,uBAAuB;;;;;;;IA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C;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAC;QACnD,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,GAAG,OAAO,CAAC,MAAM,CAAC;CAiBpB"}
|
package/lib/index.js
CHANGED
|
@@ -13,15 +13,6 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
17
|
exports.ExchangeModule = void 0;
|
|
27
18
|
const wallet_api_client_1 = require("@ledgerhq/wallet-api-client");
|
|
@@ -34,13 +25,11 @@ class ExchangeModule extends wallet_api_client_1.CustomModule {
|
|
|
34
25
|
*
|
|
35
26
|
* @returns - A transaction ID used to complete the exchange process
|
|
36
27
|
*/
|
|
37
|
-
startFund() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
exchangeType: "FUND",
|
|
41
|
-
});
|
|
42
|
-
return result.transactionId;
|
|
28
|
+
async startFund() {
|
|
29
|
+
const result = await this.request("custom.exchange.start", {
|
|
30
|
+
exchangeType: "FUND",
|
|
43
31
|
});
|
|
32
|
+
return result.transactionId;
|
|
44
33
|
}
|
|
45
34
|
/**
|
|
46
35
|
* Start the exchange process by generating a nonce on Ledger device
|
|
@@ -48,15 +37,13 @@ class ExchangeModule extends wallet_api_client_1.CustomModule {
|
|
|
48
37
|
*
|
|
49
38
|
* @returns - A transaction ID used to complete the exchange process
|
|
50
39
|
*/
|
|
51
|
-
startSell(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
fromAccountId,
|
|
57
|
-
});
|
|
58
|
-
return result.transactionId;
|
|
40
|
+
async startSell({ provider, fromAccountId }) {
|
|
41
|
+
const result = await this.request("custom.exchange.start", {
|
|
42
|
+
exchangeType: "SELL",
|
|
43
|
+
provider,
|
|
44
|
+
fromAccountId,
|
|
59
45
|
});
|
|
46
|
+
return result.transactionId;
|
|
60
47
|
}
|
|
61
48
|
/**
|
|
62
49
|
* Start the swap process by generating a nonce on Ledger device
|
|
@@ -64,20 +51,18 @@ class ExchangeModule extends wallet_api_client_1.CustomModule {
|
|
|
64
51
|
*
|
|
65
52
|
* @returns - A transaction ID used to complete the exchange process
|
|
66
53
|
*/
|
|
67
|
-
startSwap(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
tokenCurrency,
|
|
75
|
-
});
|
|
76
|
-
return {
|
|
77
|
-
transactionId: result.transactionId,
|
|
78
|
-
device: result.device,
|
|
79
|
-
};
|
|
54
|
+
async startSwap({ exchangeType, provider, fromAccountId, toAccountId, tokenCurrency, }) {
|
|
55
|
+
const result = await this.request("custom.exchange.start", {
|
|
56
|
+
exchangeType,
|
|
57
|
+
provider,
|
|
58
|
+
fromAccountId,
|
|
59
|
+
toAccountId,
|
|
60
|
+
tokenCurrency,
|
|
80
61
|
});
|
|
62
|
+
return {
|
|
63
|
+
transactionId: result.transactionId,
|
|
64
|
+
device: result.device,
|
|
65
|
+
};
|
|
81
66
|
}
|
|
82
67
|
/**
|
|
83
68
|
* Complete an exchange swap process by passing by the exchange content and its signature.
|
|
@@ -95,22 +80,20 @@ class ExchangeModule extends wallet_api_client_1.CustomModule {
|
|
|
95
80
|
*
|
|
96
81
|
* @returns - The broadcasted transaction hash.
|
|
97
82
|
*/
|
|
98
|
-
completeSwap(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
tokenCurrency,
|
|
111
|
-
});
|
|
112
|
-
return result.transactionHash;
|
|
83
|
+
async completeSwap({ provider, fromAccountId, toAccountId, swapId, transaction, binaryPayload, signature, feeStrategy, tokenCurrency, }) {
|
|
84
|
+
const result = await this.request("custom.exchange.complete", {
|
|
85
|
+
exchangeType: "SWAP",
|
|
86
|
+
provider,
|
|
87
|
+
fromAccountId,
|
|
88
|
+
toAccountId,
|
|
89
|
+
swapId,
|
|
90
|
+
rawTransaction: (0, wallet_api_client_1.serializeTransaction)(transaction),
|
|
91
|
+
hexBinaryPayload: binaryPayload,
|
|
92
|
+
hexSignature: signature,
|
|
93
|
+
feeStrategy,
|
|
94
|
+
tokenCurrency,
|
|
113
95
|
});
|
|
96
|
+
return result.transactionHash;
|
|
114
97
|
}
|
|
115
98
|
/**
|
|
116
99
|
* Complete an exchange sell process by passing by the exchange content and its signature.
|
|
@@ -125,30 +108,26 @@ class ExchangeModule extends wallet_api_client_1.CustomModule {
|
|
|
125
108
|
*
|
|
126
109
|
* @returns - The broadcasted transaction hash.
|
|
127
110
|
*/
|
|
128
|
-
completeSell(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
feeStrategy,
|
|
138
|
-
});
|
|
139
|
-
return result.transactionHash;
|
|
111
|
+
async completeSell({ provider, fromAccountId, transaction, binaryPayload, signature, feeStrategy, }) {
|
|
112
|
+
const result = await this.request("custom.exchange.complete", {
|
|
113
|
+
exchangeType: "SELL",
|
|
114
|
+
provider,
|
|
115
|
+
fromAccountId,
|
|
116
|
+
rawTransaction: (0, wallet_api_client_1.serializeTransaction)(transaction),
|
|
117
|
+
hexBinaryPayload: typeof binaryPayload === "string" ? binaryPayload : binaryPayload.toString("hex"),
|
|
118
|
+
hexSignature: typeof signature === "string" ? signature : signature.toString("hex"),
|
|
119
|
+
feeStrategy,
|
|
140
120
|
});
|
|
121
|
+
return result.transactionHash;
|
|
141
122
|
}
|
|
142
123
|
/**
|
|
143
124
|
* open a drawer to display errors that Ledger live can't display itself
|
|
144
125
|
* @param error, the error to display
|
|
145
126
|
* @returns nothing
|
|
146
127
|
*/
|
|
147
|
-
throwExchangeErrorToLedgerLive(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return;
|
|
151
|
-
});
|
|
128
|
+
async throwExchangeErrorToLedgerLive({ error, }) {
|
|
129
|
+
await this.request("custom.exchange.error", error);
|
|
130
|
+
return;
|
|
152
131
|
}
|
|
153
132
|
/**
|
|
154
133
|
* Complete an exchange fund process by passing by the exchange content and its signature.
|
|
@@ -163,20 +142,18 @@ class ExchangeModule extends wallet_api_client_1.CustomModule {
|
|
|
163
142
|
*
|
|
164
143
|
* @returns - The broadcasted transaction hash.
|
|
165
144
|
*/
|
|
166
|
-
completeFund(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
tokenCurrency,
|
|
177
|
-
});
|
|
178
|
-
return result.transactionHash;
|
|
145
|
+
async completeFund({ provider, fromAccountId, transaction, binaryPayload, signature, feeStrategy, tokenCurrency, }) {
|
|
146
|
+
const result = await this.request("custom.exchange.complete", {
|
|
147
|
+
exchangeType: "FUND",
|
|
148
|
+
provider,
|
|
149
|
+
fromAccountId,
|
|
150
|
+
rawTransaction: (0, wallet_api_client_1.serializeTransaction)(transaction),
|
|
151
|
+
hexBinaryPayload: binaryPayload.toString("hex"),
|
|
152
|
+
hexSignature: signature.toString("hex"),
|
|
153
|
+
feeStrategy,
|
|
154
|
+
tokenCurrency,
|
|
179
155
|
});
|
|
156
|
+
return result.transactionHash;
|
|
180
157
|
}
|
|
181
158
|
}
|
|
182
159
|
exports.ExchangeModule = ExchangeModule;
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mEAA8F;AAW9F,0CAAwB;AAExB,wFAAwF;AACxF,MAAa,cAAe,SAAQ,gCAAY;IAC9C;;;;;OAKG;IACH,KAAK,CAAC,SAAS;QACb,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAC/B,uBAAuB,EACvB;YACE,YAAY,EAAE,MAAM;SACrB,CACF,CAAC;QAEF,OAAO,MAAM,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAiD;QACxF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAC/B,uBAAuB,EACvB;YACE,YAAY,EAAE,MAAM;YACpB,QAAQ;YACR,aAAa;SACd,CACF,CAAC;QAEF,OAAO,MAAM,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,SAAS,CAAC,EACd,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,WAAW,EACX,aAAa,GACW;QACxB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAC/B,uBAAuB,EACvB;YACE,YAAY;YACZ,QAAQ;YACR,aAAa;YACb,WAAW;YACX,aAAa;SACd,C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AIG;IACH,KAAK,CAAC,8BAA8B,CAAC,EACnC,KAAK,GAGN;QACC,MAAM,IAAI,CAAC,OAAO,CAAkC,uBAAuB,EAAE,KAAK,CAAC,CAAC;QACpF,OAAO;IACT,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,YAAY,CAAC,EACjB,QAAQ,EACR,aAAa,EACb,WAAW,EACX,aAAa,EACb,SAAS,EACT,WAAW,EACX,aAAa,GASd;QACC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAC/B,0BAA0B,EAC1B;YACE,YAAY,EAAE,MAAM;YACpB,QAAQ;YACR,aAAa;YACb,cAAc,EAAE,IAAA,wCAAoB,EAAC,WAAW,CAAC;YACjD,gBAAgB,EAAE,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC;YAC/C,YAAY,EAAE,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;YACvC,WAAW;YACX,aAAa;SACd,CACF,CAAC;QAEF,OAAO,MAAM,CAAC,eAAe,CAAC;IAChC,CAAC;CACF;AApOD,wCAoOC"}
|
package/lib-es/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { CustomModule, Transaction } from "@ledgerhq/wallet-api-client";
|
|
3
4
|
import { ExchangeCompleteParams, ExchangeStartSellParams, ExchangeStartSwapParams, SwapLiveError } from "./types";
|
|
4
5
|
export * from "./types";
|
package/lib-es/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAwB,MAAM,6BAA6B,CAAC;AAC9F,OAAO,EACL,sBAAsB,EAItB,uBAAuB,EACvB,uBAAuB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AC,EACnC,KAAK,GACN,EAAE;QACD,KAAK,EAAE,aAAa,GAAG,SAAS,CAAC;KAClC,GAAG,OAAO,CAAC,IAAI,CAAC;IAKjB;;;;;;;;;;;;OAYG;IACG,YAAY,CAAC,EACjB,QAAQ,EACR,aAAa,EACb,WAAW,EACX,aAAa,EACb,SAAS,EACT,WAAW,EACX,aAAa,GACd,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,WAAW,CAAC;QACzB,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAC;QACnD,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,GAAG,OAAO,CAAC,MAAM,CAAC;CAiBpB"}
|
package/lib-es/index.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { CustomModule, serializeTransaction } from "@ledgerhq/wallet-api-client";
|
|
11
2
|
export * from "./types";
|
|
12
3
|
// TODO maybe find a better way to type the available custom requests with correct types
|
|
@@ -17,13 +8,11 @@ export class ExchangeModule extends CustomModule {
|
|
|
17
8
|
*
|
|
18
9
|
* @returns - A transaction ID used to complete the exchange process
|
|
19
10
|
*/
|
|
20
|
-
startFund() {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
exchangeType: "FUND",
|
|
24
|
-
});
|
|
25
|
-
return result.transactionId;
|
|
11
|
+
async startFund() {
|
|
12
|
+
const result = await this.request("custom.exchange.start", {
|
|
13
|
+
exchangeType: "FUND",
|
|
26
14
|
});
|
|
15
|
+
return result.transactionId;
|
|
27
16
|
}
|
|
28
17
|
/**
|
|
29
18
|
* Start the exchange process by generating a nonce on Ledger device
|
|
@@ -31,15 +20,13 @@ export class ExchangeModule extends CustomModule {
|
|
|
31
20
|
*
|
|
32
21
|
* @returns - A transaction ID used to complete the exchange process
|
|
33
22
|
*/
|
|
34
|
-
startSell(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
fromAccountId,
|
|
40
|
-
});
|
|
41
|
-
return result.transactionId;
|
|
23
|
+
async startSell({ provider, fromAccountId }) {
|
|
24
|
+
const result = await this.request("custom.exchange.start", {
|
|
25
|
+
exchangeType: "SELL",
|
|
26
|
+
provider,
|
|
27
|
+
fromAccountId,
|
|
42
28
|
});
|
|
29
|
+
return result.transactionId;
|
|
43
30
|
}
|
|
44
31
|
/**
|
|
45
32
|
* Start the swap process by generating a nonce on Ledger device
|
|
@@ -47,20 +34,18 @@ export class ExchangeModule extends CustomModule {
|
|
|
47
34
|
*
|
|
48
35
|
* @returns - A transaction ID used to complete the exchange process
|
|
49
36
|
*/
|
|
50
|
-
startSwap(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
tokenCurrency,
|
|
58
|
-
});
|
|
59
|
-
return {
|
|
60
|
-
transactionId: result.transactionId,
|
|
61
|
-
device: result.device,
|
|
62
|
-
};
|
|
37
|
+
async startSwap({ exchangeType, provider, fromAccountId, toAccountId, tokenCurrency, }) {
|
|
38
|
+
const result = await this.request("custom.exchange.start", {
|
|
39
|
+
exchangeType,
|
|
40
|
+
provider,
|
|
41
|
+
fromAccountId,
|
|
42
|
+
toAccountId,
|
|
43
|
+
tokenCurrency,
|
|
63
44
|
});
|
|
45
|
+
return {
|
|
46
|
+
transactionId: result.transactionId,
|
|
47
|
+
device: result.device,
|
|
48
|
+
};
|
|
64
49
|
}
|
|
65
50
|
/**
|
|
66
51
|
* Complete an exchange swap process by passing by the exchange content and its signature.
|
|
@@ -78,22 +63,20 @@ export class ExchangeModule extends CustomModule {
|
|
|
78
63
|
*
|
|
79
64
|
* @returns - The broadcasted transaction hash.
|
|
80
65
|
*/
|
|
81
|
-
completeSwap(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
tokenCurrency,
|
|
94
|
-
});
|
|
95
|
-
return result.transactionHash;
|
|
66
|
+
async completeSwap({ provider, fromAccountId, toAccountId, swapId, transaction, binaryPayload, signature, feeStrategy, tokenCurrency, }) {
|
|
67
|
+
const result = await this.request("custom.exchange.complete", {
|
|
68
|
+
exchangeType: "SWAP",
|
|
69
|
+
provider,
|
|
70
|
+
fromAccountId,
|
|
71
|
+
toAccountId,
|
|
72
|
+
swapId,
|
|
73
|
+
rawTransaction: serializeTransaction(transaction),
|
|
74
|
+
hexBinaryPayload: binaryPayload,
|
|
75
|
+
hexSignature: signature,
|
|
76
|
+
feeStrategy,
|
|
77
|
+
tokenCurrency,
|
|
96
78
|
});
|
|
79
|
+
return result.transactionHash;
|
|
97
80
|
}
|
|
98
81
|
/**
|
|
99
82
|
* Complete an exchange sell process by passing by the exchange content and its signature.
|
|
@@ -108,30 +91,26 @@ export class ExchangeModule extends CustomModule {
|
|
|
108
91
|
*
|
|
109
92
|
* @returns - The broadcasted transaction hash.
|
|
110
93
|
*/
|
|
111
|
-
completeSell(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
feeStrategy,
|
|
121
|
-
});
|
|
122
|
-
return result.transactionHash;
|
|
94
|
+
async completeSell({ provider, fromAccountId, transaction, binaryPayload, signature, feeStrategy, }) {
|
|
95
|
+
const result = await this.request("custom.exchange.complete", {
|
|
96
|
+
exchangeType: "SELL",
|
|
97
|
+
provider,
|
|
98
|
+
fromAccountId,
|
|
99
|
+
rawTransaction: serializeTransaction(transaction),
|
|
100
|
+
hexBinaryPayload: typeof binaryPayload === "string" ? binaryPayload : binaryPayload.toString("hex"),
|
|
101
|
+
hexSignature: typeof signature === "string" ? signature : signature.toString("hex"),
|
|
102
|
+
feeStrategy,
|
|
123
103
|
});
|
|
104
|
+
return result.transactionHash;
|
|
124
105
|
}
|
|
125
106
|
/**
|
|
126
107
|
* open a drawer to display errors that Ledger live can't display itself
|
|
127
108
|
* @param error, the error to display
|
|
128
109
|
* @returns nothing
|
|
129
110
|
*/
|
|
130
|
-
throwExchangeErrorToLedgerLive(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return;
|
|
134
|
-
});
|
|
111
|
+
async throwExchangeErrorToLedgerLive({ error, }) {
|
|
112
|
+
await this.request("custom.exchange.error", error);
|
|
113
|
+
return;
|
|
135
114
|
}
|
|
136
115
|
/**
|
|
137
116
|
* Complete an exchange fund process by passing by the exchange content and its signature.
|
|
@@ -146,20 +125,18 @@ export class ExchangeModule extends CustomModule {
|
|
|
146
125
|
*
|
|
147
126
|
* @returns - The broadcasted transaction hash.
|
|
148
127
|
*/
|
|
149
|
-
completeFund(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
tokenCurrency,
|
|
160
|
-
});
|
|
161
|
-
return result.transactionHash;
|
|
128
|
+
async completeFund({ provider, fromAccountId, transaction, binaryPayload, signature, feeStrategy, tokenCurrency, }) {
|
|
129
|
+
const result = await this.request("custom.exchange.complete", {
|
|
130
|
+
exchangeType: "FUND",
|
|
131
|
+
provider,
|
|
132
|
+
fromAccountId,
|
|
133
|
+
rawTransaction: serializeTransaction(transaction),
|
|
134
|
+
hexBinaryPayload: binaryPayload.toString("hex"),
|
|
135
|
+
hexSignature: signature.toString("hex"),
|
|
136
|
+
feeStrategy,
|
|
137
|
+
tokenCurrency,
|
|
162
138
|
});
|
|
139
|
+
return result.transactionHash;
|
|
163
140
|
}
|
|
164
141
|
}
|
|
165
142
|
//# sourceMappingURL=index.js.map
|
package/lib-es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAW9F,cAAc,SAAS,CAAC;AAExB,wFAAwF;AACxF,MAAM,OAAO,cAAe,SAAQ,YAAY;IAC9C;;;;;OAKG;IACH,KAAK,CAAC,SAAS;QACb,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAC/B,uBAAuB,EACvB;YACE,YAAY,EAAE,MAAM;SACrB,CACF,CAAC;QAEF,OAAO,MAAM,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAiD;QACxF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAC/B,uBAAuB,EACvB;YACE,YAAY,EAAE,MAAM;YACpB,QAAQ;YACR,aAAa;SACd,CACF,CAAC;QAEF,OAAO,MAAM,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,SAAS,CAAC,EACd,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,WAAW,EACX,aAAa,GACW;QACxB,MAAM,MAAM,GAAG,MA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,CAAC;YACnF,WAAW;SACZ,CACF,CAAC;QAEF,OAAO,MAAM,CAAC,eAAe,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,8BAA8B,CAAC,EACnC,KAAK,GAGN;QACC,MAAM,IAAI,CAAC,OAAO,CAAkC,uBAAuB,EAAE,KAAK,CAAC,CAAC;QACpF,OAAO;IACT,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,YAAY,CAAC,EACjB,QAAQ,EACR,aAAa,EACb,WAAW,EACX,aAAa,EACb,SAAS,EACT,WAAW,EACX,aAAa,GASd;QACC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAC/B,0BAA0B,EAC1B;YACE,YAAY,EAAE,MAAM;YACpB,QAAQ;YACR,aAAa;YACb,cAAc,EAAE,oBAAoB,CAAC,WAAW,CAAC;YACjD,gBAAgB,EAAE,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC;YAC/C,YAAY,EAAE,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;YACvC,WAAW;YACX,aAAa;SACd,CACF,CAAC;QAEF,OAAO,MAAM,CAAC,eAAe,CAAC;IAChC,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/wallet-api-exchange-module",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0-nightly.1",
|
|
4
4
|
"description": "Wallet-API Exchange Module for Ledger Live",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@ledgerhq/wallet-api-client": "^1.6.
|
|
29
|
-
"@ledgerhq/wallet-api-core": "^1.
|
|
28
|
+
"@ledgerhq/wallet-api-client": "^1.6.2",
|
|
29
|
+
"@ledgerhq/wallet-api-core": "^1.15.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/node": "^
|
|
32
|
+
"@types/node": "^22.10.10"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"clean": "rimraf lib lib-es",
|
|
36
|
-
"build": "tsc && tsc -m
|
|
36
|
+
"build": "tsc && tsc -m esnext --moduleResolution bundler --outDir lib-es && node scripts/createModulePackage.mjs",
|
|
37
37
|
"prewatch": "pnpm build",
|
|
38
38
|
"watch": "tsc --watch",
|
|
39
|
-
"watch:es": "tsc --watch -m
|
|
39
|
+
"watch:es": "tsc --watch -m esnext --moduleResolution bundler --outDir lib-es",
|
|
40
40
|
"lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx",
|
|
41
41
|
"lint:fix": "pnpm lint --fix"
|
|
42
42
|
}
|