@ledgerhq/wallet-api-acre-module 0.1.0-nightly.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/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2017-present Ledger https://www.ledger.com/
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/lib/index.d.ts ADDED
@@ -0,0 +1,39 @@
1
+ /// <reference types="node" />
2
+ import { CustomModule, Transaction } from "@ledgerhq/wallet-api-client";
3
+ import { AcreMessage, SignOptions, TransactionOptions } from "./types";
4
+ export * from "./types";
5
+ export declare class AcreModule extends CustomModule {
6
+ /**
7
+ * Let the user sign the provided message.
8
+ * @param accountId - Ledger Live id of the account
9
+ * @param message - Message the user should sign
10
+ * @param derivationPath - The derivation path is a relative derivation path from the account
11
+ * e.g to use the first address of an account, one will request for the “0/0“ derivation path
12
+ * @param options - Extra parameters
13
+ *
14
+ * @returns Message signed
15
+ * @throws {@link RpcError} if an error occured on server side
16
+ */
17
+ messageSign(accountId: string, message: AcreMessage, derivationPath?: string, options?: SignOptions, meta?: Record<string, unknown>): Promise<Buffer>;
18
+ /**
19
+ * Let the user sign a transaction that won't be broadcasted by the connected wallet
20
+ * @param accountId - id of the account
21
+ * @param transaction - The transaction object in the currency family-specific format
22
+ * @param options - Extra parameters
23
+ *
24
+ * @returns The raw signed transaction
25
+ * @throws {@link RpcError} if an error occured on server side
26
+ */
27
+ transactionSign(accountId: string, transaction: Transaction, options?: TransactionOptions, meta?: Record<string, unknown>): Promise<Buffer>;
28
+ /**
29
+ * Let the user sign and broadcast a transaction
30
+ * @param accountId - id of the account
31
+ * @param transaction - The transaction object in the currency family-specific format
32
+ * @param options - Extra parameters
33
+ *
34
+ * @returns The transaction hash
35
+ * @throws {@link RpcError} if an error occured on server side
36
+ */
37
+ transactionSignAndBroadcast(accountId: string, transaction: Transaction, options?: TransactionOptions, meta?: Record<string, unknown>): Promise<string>;
38
+ }
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAwB,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC9F,OAAO,EACL,WAAW,EAGX,WAAW,EACX,kBAAkB,EAKnB,MAAM,SAAS,CAAC;AAEjB,cAAc,SAAS,CAAC;AAGxB,qBAAa,UAAW,SAAQ,YAAY;IAC1C;;;;;;;;;;OAUG;IACG,WAAW,CACf,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,WAAW,EACpB,cAAc,CAAC,EAAE,MAAM,EACvB,OAAO,CAAC,EAAE,WAAW,EACrB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAgBhC;;;;;;;;OAQG;IACG,eAAe,CACnB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,kBAAkB,EAC5B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,MAAM,CAAC;IAclB;;;;;;;;OAQG;IACG,2BAA2B,CAC/B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,kBAAkB,EAC5B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,MAAM,CAAC;CAanB"}
package/lib/index.js ADDED
@@ -0,0 +1,96 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.AcreModule = void 0;
27
+ const wallet_api_client_1 = require("@ledgerhq/wallet-api-client");
28
+ __exportStar(require("./types"), exports);
29
+ // TODO maybe find a better way to type the available custom requests with correct types
30
+ class AcreModule extends wallet_api_client_1.CustomModule {
31
+ /**
32
+ * Let the user sign the provided message.
33
+ * @param accountId - Ledger Live id of the account
34
+ * @param message - Message the user should sign
35
+ * @param derivationPath - The derivation path is a relative derivation path from the account
36
+ * e.g to use the first address of an account, one will request for the “0/0“ derivation path
37
+ * @param options - Extra parameters
38
+ *
39
+ * @returns Message signed
40
+ * @throws {@link RpcError} if an error occured on server side
41
+ */
42
+ messageSign(accountId, message, derivationPath, options, meta) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const result = yield this.request("custom.acre.messageSign", {
45
+ accountId,
46
+ message,
47
+ derivationPath,
48
+ options,
49
+ meta,
50
+ });
51
+ return Buffer.from(result.hexSignedMessage, "hex");
52
+ });
53
+ }
54
+ /**
55
+ * Let the user sign a transaction that won't be broadcasted by the connected wallet
56
+ * @param accountId - id of the account
57
+ * @param transaction - The transaction object in the currency family-specific format
58
+ * @param options - Extra parameters
59
+ *
60
+ * @returns The raw signed transaction
61
+ * @throws {@link RpcError} if an error occured on server side
62
+ */
63
+ transactionSign(accountId, transaction, options, meta) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ const result = yield this.request("custom.acre.transactionSign", {
66
+ accountId,
67
+ rawTransaction: (0, wallet_api_client_1.serializeTransaction)(transaction),
68
+ options,
69
+ meta,
70
+ });
71
+ return Buffer.from(result.signedTransactionHex, "hex");
72
+ });
73
+ }
74
+ /**
75
+ * Let the user sign and broadcast a transaction
76
+ * @param accountId - id of the account
77
+ * @param transaction - The transaction object in the currency family-specific format
78
+ * @param options - Extra parameters
79
+ *
80
+ * @returns The transaction hash
81
+ * @throws {@link RpcError} if an error occured on server side
82
+ */
83
+ transactionSignAndBroadcast(accountId, transaction, options, meta) {
84
+ return __awaiter(this, void 0, void 0, function* () {
85
+ const result = yield this.request("custom.acre.transactionSignAndBroadcast", {
86
+ accountId,
87
+ rawTransaction: (0, wallet_api_client_1.serializeTransaction)(transaction),
88
+ options,
89
+ meta,
90
+ });
91
+ return result.transactionHash;
92
+ });
93
+ }
94
+ }
95
+ exports.AcreModule = AcreModule;
96
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAA8F;AAa9F,0CAAwB;AAExB,wFAAwF;AACxF,MAAa,UAAW,SAAQ,gCAAY;IAC1C;;;;;;;;;;OAUG;IACG,WAAW,CACf,SAAiB,EACjB,OAAoB,EACpB,cAAuB,EACvB,OAAqB,EACrB,IAA8B;;YAE9B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAC/B,yBAAyB,EACzB;gBACE,SAAS;gBACT,OAAO;gBACP,cAAc;gBACd,OAAO;gBACP,IAAI;aACL,CACF,CAAC;YAEF,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;QACrD,CAAC;KAAA;IAED;;;;;;;;OAQG;IACG,eAAe,CACnB,SAAiB,EACjB,WAAwB,EACxB,OAA4B,EAC5B,IAA8B;;YAE9B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAC/B,6BAA6B,EAC7B;gBACE,SAAS;gBACT,cAAc,EAAE,IAAA,wCAAoB,EAAC,WAAW,CAAC;gBACjD,OAAO;gBACP,IAAI;aACL,CACF,CAAC;YAEF,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;QACzD,CAAC;KAAA;IAED;;;;;;;;OAQG;IACG,2BAA2B,CAC/B,SAAiB,EACjB,WAAwB,EACxB,OAA4B,EAC5B,IAA8B;;YAE9B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAG/B,yCAAyC,EAAE;gBAC3C,SAAS;gBACT,cAAc,EAAE,IAAA,wCAAoB,EAAC,WAAW,CAAC;gBACjD,OAAO;gBACP,IAAI;aACL,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC,eAAe,CAAC;QAChC,CAAC;KAAA;CACF;AAxFD,gCAwFC"}
package/lib/types.d.ts ADDED
@@ -0,0 +1,65 @@
1
+ import { RawTransaction } from "@ledgerhq/wallet-api-core";
2
+ export declare enum AcreMessageType {
3
+ Withdraw = "Withdraw",
4
+ SignIn = "SignIn"
5
+ }
6
+ export interface AcreWithdrawalData {
7
+ to: string;
8
+ value: string;
9
+ data: string;
10
+ operation: string;
11
+ safeTxGas: string;
12
+ baseGas: string;
13
+ gasPrice: string;
14
+ gasToken: string;
15
+ refundReceiver: string;
16
+ nonce: string;
17
+ }
18
+ export type AcreMessageWithdraw = {
19
+ type: AcreMessageType.Withdraw;
20
+ message: AcreWithdrawalData;
21
+ };
22
+ export type AcreMessageSignIn = {
23
+ type: AcreMessageType.SignIn;
24
+ message: unknown;
25
+ };
26
+ export type AcreMessage = AcreMessageWithdraw | AcreMessageSignIn;
27
+ export type SignOptions = {
28
+ hwAppId?: string;
29
+ dependencies?: string[];
30
+ };
31
+ export type MessageSignParams = {
32
+ accountId: string;
33
+ message: AcreMessage;
34
+ derivationPath?: string;
35
+ options?: SignOptions;
36
+ meta?: Record<string, unknown>;
37
+ };
38
+ export type MessageSignResult = {
39
+ hexSignedMessage: string;
40
+ };
41
+ export type TransactionOptions = {
42
+ hwAppId?: string;
43
+ dependencies?: string[];
44
+ };
45
+ export type TransactionSignParams = {
46
+ accountId: string;
47
+ rawTransaction: RawTransaction;
48
+ options?: TransactionOptions;
49
+ meta?: Record<string, unknown>;
50
+ tokenCurrency?: string;
51
+ };
52
+ export type TransactionSignResult = {
53
+ signedTransactionHex: string;
54
+ };
55
+ export type TransactionSignAndBroadcastParams = {
56
+ accountId: string;
57
+ rawTransaction: RawTransaction;
58
+ options?: TransactionOptions;
59
+ meta?: Record<string, unknown>;
60
+ tokenCurrency?: string;
61
+ };
62
+ export type TransactionSignAndBroadcastResult = {
63
+ transactionHash: string;
64
+ };
65
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,oBAAY,eAAe;IACzB,QAAQ,aAAa;IACrB,MAAM,WAAW;CAClB;AAID,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC;IAC/B,OAAO,EAAE,kBAAkB,CAAC;CAC7B,CAAC;AAGF,MAAM,MAAM,iBAAiB,GAAG;IAAE,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAEnF,MAAM,MAAM,WAAW,GAAG,mBAAmB,GAAG,iBAAiB,CAAC;AAElE,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,WAAW,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,cAAc,CAAC;IAC/B,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,cAAc,CAAC;IAC/B,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC"}
package/lib/types.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AcreMessageType = void 0;
4
+ var AcreMessageType;
5
+ (function (AcreMessageType) {
6
+ AcreMessageType["Withdraw"] = "Withdraw";
7
+ AcreMessageType["SignIn"] = "SignIn";
8
+ })(AcreMessageType || (exports.AcreMessageType = AcreMessageType = {}));
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAEA,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,wCAAqB,CAAA;IACrB,oCAAiB,CAAA;AACnB,CAAC,EAHW,eAAe,+BAAf,eAAe,QAG1B"}
@@ -0,0 +1,39 @@
1
+ /// <reference types="node" />
2
+ import { CustomModule, Transaction } from "@ledgerhq/wallet-api-client";
3
+ import { AcreMessage, SignOptions, TransactionOptions } from "./types";
4
+ export * from "./types";
5
+ export declare class AcreModule extends CustomModule {
6
+ /**
7
+ * Let the user sign the provided message.
8
+ * @param accountId - Ledger Live id of the account
9
+ * @param message - Message the user should sign
10
+ * @param derivationPath - The derivation path is a relative derivation path from the account
11
+ * e.g to use the first address of an account, one will request for the “0/0“ derivation path
12
+ * @param options - Extra parameters
13
+ *
14
+ * @returns Message signed
15
+ * @throws {@link RpcError} if an error occured on server side
16
+ */
17
+ messageSign(accountId: string, message: AcreMessage, derivationPath?: string, options?: SignOptions, meta?: Record<string, unknown>): Promise<Buffer>;
18
+ /**
19
+ * Let the user sign a transaction that won't be broadcasted by the connected wallet
20
+ * @param accountId - id of the account
21
+ * @param transaction - The transaction object in the currency family-specific format
22
+ * @param options - Extra parameters
23
+ *
24
+ * @returns The raw signed transaction
25
+ * @throws {@link RpcError} if an error occured on server side
26
+ */
27
+ transactionSign(accountId: string, transaction: Transaction, options?: TransactionOptions, meta?: Record<string, unknown>): Promise<Buffer>;
28
+ /**
29
+ * Let the user sign and broadcast a transaction
30
+ * @param accountId - id of the account
31
+ * @param transaction - The transaction object in the currency family-specific format
32
+ * @param options - Extra parameters
33
+ *
34
+ * @returns The transaction hash
35
+ * @throws {@link RpcError} if an error occured on server side
36
+ */
37
+ transactionSignAndBroadcast(accountId: string, transaction: Transaction, options?: TransactionOptions, meta?: Record<string, unknown>): Promise<string>;
38
+ }
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAwB,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC9F,OAAO,EACL,WAAW,EAGX,WAAW,EACX,kBAAkB,EAKnB,MAAM,SAAS,CAAC;AAEjB,cAAc,SAAS,CAAC;AAGxB,qBAAa,UAAW,SAAQ,YAAY;IAC1C;;;;;;;;;;OAUG;IACG,WAAW,CACf,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,WAAW,EACpB,cAAc,CAAC,EAAE,MAAM,EACvB,OAAO,CAAC,EAAE,WAAW,EACrB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAgBhC;;;;;;;;OAQG;IACG,eAAe,CACnB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,kBAAkB,EAC5B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,MAAM,CAAC;IAclB;;;;;;;;OAQG;IACG,2BAA2B,CAC/B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,kBAAkB,EAC5B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,MAAM,CAAC;CAanB"}
@@ -0,0 +1,78 @@
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
+ import { CustomModule, serializeTransaction } from "@ledgerhq/wallet-api-client";
11
+ export * from "./types";
12
+ // TODO maybe find a better way to type the available custom requests with correct types
13
+ export class AcreModule extends CustomModule {
14
+ /**
15
+ * Let the user sign the provided message.
16
+ * @param accountId - Ledger Live id of the account
17
+ * @param message - Message the user should sign
18
+ * @param derivationPath - The derivation path is a relative derivation path from the account
19
+ * e.g to use the first address of an account, one will request for the “0/0“ derivation path
20
+ * @param options - Extra parameters
21
+ *
22
+ * @returns Message signed
23
+ * @throws {@link RpcError} if an error occured on server side
24
+ */
25
+ messageSign(accountId, message, derivationPath, options, meta) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ const result = yield this.request("custom.acre.messageSign", {
28
+ accountId,
29
+ message,
30
+ derivationPath,
31
+ options,
32
+ meta,
33
+ });
34
+ return Buffer.from(result.hexSignedMessage, "hex");
35
+ });
36
+ }
37
+ /**
38
+ * Let the user sign a transaction that won't be broadcasted by the connected wallet
39
+ * @param accountId - id of the account
40
+ * @param transaction - The transaction object in the currency family-specific format
41
+ * @param options - Extra parameters
42
+ *
43
+ * @returns The raw signed transaction
44
+ * @throws {@link RpcError} if an error occured on server side
45
+ */
46
+ transactionSign(accountId, transaction, options, meta) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ const result = yield this.request("custom.acre.transactionSign", {
49
+ accountId,
50
+ rawTransaction: serializeTransaction(transaction),
51
+ options,
52
+ meta,
53
+ });
54
+ return Buffer.from(result.signedTransactionHex, "hex");
55
+ });
56
+ }
57
+ /**
58
+ * Let the user sign and broadcast a transaction
59
+ * @param accountId - id of the account
60
+ * @param transaction - The transaction object in the currency family-specific format
61
+ * @param options - Extra parameters
62
+ *
63
+ * @returns The transaction hash
64
+ * @throws {@link RpcError} if an error occured on server side
65
+ */
66
+ transactionSignAndBroadcast(accountId, transaction, options, meta) {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ const result = yield this.request("custom.acre.transactionSignAndBroadcast", {
69
+ accountId,
70
+ rawTransaction: serializeTransaction(transaction),
71
+ options,
72
+ meta,
73
+ });
74
+ return result.transactionHash;
75
+ });
76
+ }
77
+ }
78
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAe,MAAM,6BAA6B,CAAC;AAa9F,cAAc,SAAS,CAAC;AAExB,wFAAwF;AACxF,MAAM,OAAO,UAAW,SAAQ,YAAY;IAC1C;;;;;;;;;;OAUG;IACG,WAAW,CACf,SAAiB,EACjB,OAAoB,EACpB,cAAuB,EACvB,OAAqB,EACrB,IAA8B;;YAE9B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAC/B,yBAAyB,EACzB;gBACE,SAAS;gBACT,OAAO;gBACP,cAAc;gBACd,OAAO;gBACP,IAAI;aACL,CACF,CAAC;YAEF,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;QACrD,CAAC;KAAA;IAED;;;;;;;;OAQG;IACG,eAAe,CACnB,SAAiB,EACjB,WAAwB,EACxB,OAA4B,EAC5B,IAA8B;;YAE9B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAC/B,6BAA6B,EAC7B;gBACE,SAAS;gBACT,cAAc,EAAE,oBAAoB,CAAC,WAAW,CAAC;gBACjD,OAAO;gBACP,IAAI;aACL,CACF,CAAC;YAEF,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;QACzD,CAAC;KAAA;IAED;;;;;;;;OAQG;IACG,2BAA2B,CAC/B,SAAiB,EACjB,WAAwB,EACxB,OAA4B,EAC5B,IAA8B;;YAE9B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAG/B,yCAAyC,EAAE;gBAC3C,SAAS;gBACT,cAAc,EAAE,oBAAoB,CAAC,WAAW,CAAC;gBACjD,OAAO;gBACP,IAAI;aACL,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC,eAAe,CAAC;QAChC,CAAC;KAAA;CACF"}
@@ -0,0 +1 @@
1
+ { "type": "module" }
@@ -0,0 +1,65 @@
1
+ import { RawTransaction } from "@ledgerhq/wallet-api-core";
2
+ export declare enum AcreMessageType {
3
+ Withdraw = "Withdraw",
4
+ SignIn = "SignIn"
5
+ }
6
+ export interface AcreWithdrawalData {
7
+ to: string;
8
+ value: string;
9
+ data: string;
10
+ operation: string;
11
+ safeTxGas: string;
12
+ baseGas: string;
13
+ gasPrice: string;
14
+ gasToken: string;
15
+ refundReceiver: string;
16
+ nonce: string;
17
+ }
18
+ export type AcreMessageWithdraw = {
19
+ type: AcreMessageType.Withdraw;
20
+ message: AcreWithdrawalData;
21
+ };
22
+ export type AcreMessageSignIn = {
23
+ type: AcreMessageType.SignIn;
24
+ message: unknown;
25
+ };
26
+ export type AcreMessage = AcreMessageWithdraw | AcreMessageSignIn;
27
+ export type SignOptions = {
28
+ hwAppId?: string;
29
+ dependencies?: string[];
30
+ };
31
+ export type MessageSignParams = {
32
+ accountId: string;
33
+ message: AcreMessage;
34
+ derivationPath?: string;
35
+ options?: SignOptions;
36
+ meta?: Record<string, unknown>;
37
+ };
38
+ export type MessageSignResult = {
39
+ hexSignedMessage: string;
40
+ };
41
+ export type TransactionOptions = {
42
+ hwAppId?: string;
43
+ dependencies?: string[];
44
+ };
45
+ export type TransactionSignParams = {
46
+ accountId: string;
47
+ rawTransaction: RawTransaction;
48
+ options?: TransactionOptions;
49
+ meta?: Record<string, unknown>;
50
+ tokenCurrency?: string;
51
+ };
52
+ export type TransactionSignResult = {
53
+ signedTransactionHex: string;
54
+ };
55
+ export type TransactionSignAndBroadcastParams = {
56
+ accountId: string;
57
+ rawTransaction: RawTransaction;
58
+ options?: TransactionOptions;
59
+ meta?: Record<string, unknown>;
60
+ tokenCurrency?: string;
61
+ };
62
+ export type TransactionSignAndBroadcastResult = {
63
+ transactionHash: string;
64
+ };
65
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,oBAAY,eAAe;IACzB,QAAQ,aAAa;IACrB,MAAM,WAAW;CAClB;AAID,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC;IAC/B,OAAO,EAAE,kBAAkB,CAAC;CAC7B,CAAC;AAGF,MAAM,MAAM,iBAAiB,GAAG;IAAE,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAEnF,MAAM,MAAM,WAAW,GAAG,mBAAmB,GAAG,iBAAiB,CAAC;AAElE,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,WAAW,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,cAAc,CAAC;IAC/B,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,cAAc,CAAC;IAC/B,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export var AcreMessageType;
2
+ (function (AcreMessageType) {
3
+ AcreMessageType["Withdraw"] = "Withdraw";
4
+ AcreMessageType["SignIn"] = "SignIn";
5
+ })(AcreMessageType || (AcreMessageType = {}));
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,wCAAqB,CAAA;IACrB,oCAAiB,CAAA;AACnB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B"}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@ledgerhq/wallet-api-acre-module",
3
+ "version": "0.1.0-nightly.0",
4
+ "description": "Wallet-API ACRE Module for Ledger Live",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "Ledger"
8
+ ],
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/LedgerHQ/ledger-live.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/LedgerHQ/ledger-live/issues"
15
+ },
16
+ "homepage": "https://github.com/LedgerHQ/ledger-live/tree/develop/libs/wallet-api-acre-module",
17
+ "main": "lib/index.js",
18
+ "module": "lib-es/index.js",
19
+ "types": "lib/index.d.ts",
20
+ "files": [
21
+ "/lib",
22
+ "/lib-es"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "dependencies": {
28
+ "@ledgerhq/wallet-api-client": "^1.6.0",
29
+ "@ledgerhq/wallet-api-core": "^1.13.0"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^20.2.5"
33
+ },
34
+ "scripts": {
35
+ "clean": "rimraf lib lib-es",
36
+ "build": "tsc && tsc -m ES6 --outDir lib-es && node scripts/createModulePackage.mjs",
37
+ "prewatch": "pnpm build",
38
+ "watch": "tsc --watch",
39
+ "lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx",
40
+ "lint:fix": "pnpm lint --fix"
41
+ }
42
+ }