starknet 3.10.2 → 3.10.3

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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [3.10.3](https://github.com/seanjameshan/starknet.js/compare/v3.10.2...v3.10.3) (2022-05-04)
2
+
3
+ ### Bug Fixes
4
+
5
+ - **encode:** maximum call stack size exceeded ([3cd8195](https://github.com/seanjameshan/starknet.js/commit/3cd8195d0fcde7d2cf6460959bb2c9f45ef7d066))
6
+
1
7
  ## [3.10.2](https://github.com/seanjameshan/starknet.js/compare/v3.10.1...v3.10.2) (2022-04-27)
2
8
 
3
9
  ### Bug Fixes
@@ -36,7 +36,9 @@ test('build tx', async () => {
36
36
 
37
37
  const selector = hash.getSelectorFromName('transfer');
38
38
 
39
- expect(selector).toMatchInlineSnapshot();
39
+ expect(selector).toMatchInlineSnapshot(
40
+ `"0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e"`
41
+ );
40
42
 
41
43
  const calls = [{ contractAddress: '1', entrypoint: 'transfer', calldata: ['6', '7'] }];
42
44
  const calldata = fromCallsToExecuteCalldataWithNonce(calls, 0);
@@ -1,3 +1,2 @@
1
1
  export * from './interface';
2
2
  export * from './default';
3
- export * from './ledger';
@@ -12,4 +12,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./interface"), exports);
14
14
  __exportStar(require("./default"), exports);
15
- __exportStar(require("./ledger"), exports);
@@ -30,7 +30,7 @@ exports.utf8ToArray = exports.sanitizeHex = exports.sanitizeBytes = exports.calc
30
30
  exports.IS_BROWSER = typeof window !== 'undefined';
31
31
  var STRING_ZERO = '0';
32
32
  function arrayBufferToString(array) {
33
- return String.fromCharCode.apply(null, array);
33
+ return new Uint8Array(array).reduce(function (data, byte) { return data + String.fromCharCode(byte); }, '');
34
34
  }
35
35
  exports.arrayBufferToString = arrayBufferToString;
36
36
  function btoaUniversal(b) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starknet",
3
- "version": "3.10.2",
3
+ "version": "3.10.3",
4
4
  "description": "JavaScript library for StarkNet",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -61,9 +61,6 @@
61
61
  "typescript": "^4.4.4"
62
62
  },
63
63
  "dependencies": {
64
- "@ledgerhq/hw-app-eth": "^6.26.0",
65
- "@ledgerhq/hw-transport": "^6.24.1",
66
- "@ledgerhq/hw-transport-webhid": "^6.24.1",
67
64
  "axios": "^0.23.0",
68
65
  "bn.js": "^5.2.0",
69
66
  "elliptic": "^6.5.4",
package/signer/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export * from './interface';
2
2
  export * from './default';
3
- export * from './ledger';
package/signer/index.js CHANGED
@@ -25,4 +25,3 @@ var __exportStar =
25
25
  Object.defineProperty(exports, '__esModule', { value: true });
26
26
  __exportStar(require('./interface'), exports);
27
27
  __exportStar(require('./default'), exports);
28
- __exportStar(require('./ledger'), exports);
@@ -1,3 +1,2 @@
1
1
  export * from './interface';
2
2
  export * from './default';
3
- export * from './ledger';
@@ -4,7 +4,7 @@ export const IS_BROWSER = typeof window !== 'undefined';
4
4
  const STRING_ZERO = '0';
5
5
 
6
6
  export function arrayBufferToString(array: ArrayBuffer): string {
7
- return String.fromCharCode.apply(null, array as unknown as number[]);
7
+ return new Uint8Array(array).reduce((data, byte) => data + String.fromCharCode(byte), '');
8
8
  }
9
9
 
10
10
  export function btoaUniversal(b: ArrayBuffer): string {
package/utils/encode.js CHANGED
@@ -50,7 +50,9 @@ exports.utf8ToArray =
50
50
  exports.IS_BROWSER = typeof window !== 'undefined';
51
51
  var STRING_ZERO = '0';
52
52
  function arrayBufferToString(array) {
53
- return String.fromCharCode.apply(null, array);
53
+ return new Uint8Array(array).reduce(function (data, byte) {
54
+ return data + String.fromCharCode(byte);
55
+ }, '');
54
56
  }
55
57
  exports.arrayBufferToString = arrayBufferToString;
56
58
  function btoaUniversal(b) {
@@ -73,7 +73,7 @@ const config = {
73
73
  },
74
74
  // {to: '/blog', label: 'Blog', position: 'left'},
75
75
  {
76
- href: 'https://github.com/facebook/docusaurus',
76
+ href: 'https://github.com/0xs34n/starknet.js',
77
77
  label: 'GitHub',
78
78
  position: 'right',
79
79
  },
@@ -1,12 +0,0 @@
1
- import { Invocation, InvocationsSignerDetails, Signature } from '../types';
2
- import { TypedData } from '../utils/typedData';
3
- import { SignerInterface } from './interface';
4
- export declare class LedgerBlindSigner implements SignerInterface {
5
- derivationPath: string;
6
- private transport;
7
- private getEthApp;
8
- getPubKey(): Promise<string>;
9
- signTransaction(transactions: Invocation[], transactionsDetail: InvocationsSignerDetails): Promise<Signature>;
10
- signMessage(typedData: TypedData, accountAddress: string): Promise<Signature>;
11
- protected sign(msgHash: string): Promise<Signature>;
12
- }
@@ -1,140 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.LedgerBlindSigner = void 0;
43
- var hw_app_eth_1 = __importDefault(require("@ledgerhq/hw-app-eth"));
44
- var hw_transport_webhid_1 = __importDefault(require("@ledgerhq/hw-transport-webhid"));
45
- var encode_1 = require("../utils/encode");
46
- var hash_1 = require("../utils/hash");
47
- var transaction_1 = require("../utils/transaction");
48
- var typedData_1 = require("../utils/typedData");
49
- function hexZeroPad(hash, length) {
50
- var value = hash;
51
- if (value.length > 2 * length + 2) {
52
- throw new Error('value out of range');
53
- }
54
- while (value.length < 2 * length + 2) {
55
- value = "0x0" + value.substring(2);
56
- }
57
- return value;
58
- }
59
- var LedgerBlindSigner = /** @class */ (function () {
60
- function LedgerBlindSigner() {
61
- this.derivationPath = "/2645'/579218131'/1148870696'/0'/0'/0";
62
- }
63
- LedgerBlindSigner.prototype.getEthApp = function () {
64
- return __awaiter(this, void 0, void 0, function () {
65
- var _a, _b;
66
- return __generator(this, function (_c) {
67
- switch (_c.label) {
68
- case 0:
69
- if (!!this.transport) return [3 /*break*/, 4];
70
- _c.label = 1;
71
- case 1:
72
- _c.trys.push([1, 3, , 4]);
73
- _a = this;
74
- return [4 /*yield*/, hw_transport_webhid_1.default.create()];
75
- case 2:
76
- _a.transport = _c.sent();
77
- return [3 /*break*/, 4];
78
- case 3:
79
- _b = _c.sent();
80
- throw new Error('Device connection error');
81
- case 4: return [2 /*return*/, new hw_app_eth_1.default(this.transport)];
82
- }
83
- });
84
- });
85
- };
86
- LedgerBlindSigner.prototype.getPubKey = function () {
87
- return __awaiter(this, void 0, void 0, function () {
88
- var eth, response, starkPub;
89
- return __generator(this, function (_a) {
90
- switch (_a.label) {
91
- case 0: return [4 /*yield*/, this.getEthApp()];
92
- case 1:
93
- eth = _a.sent();
94
- return [4 /*yield*/, eth.starkGetPublicKey(this.derivationPath)];
95
- case 2:
96
- response = _a.sent();
97
- starkPub = "0x" + response.slice(1, 1 + 32).toString('hex');
98
- return [2 /*return*/, starkPub];
99
- }
100
- });
101
- });
102
- };
103
- LedgerBlindSigner.prototype.signTransaction = function (transactions, transactionsDetail) {
104
- return __awaiter(this, void 0, void 0, function () {
105
- var calldata, msgHash;
106
- return __generator(this, function (_a) {
107
- calldata = (0, transaction_1.fromCallsToExecuteCalldataWithNonce)(transactions, transactionsDetail.nonce);
108
- msgHash = (0, hash_1.calculcateTransactionHash)(transactionsDetail.walletAddress, transactionsDetail.version, (0, hash_1.getSelectorFromName)('__execute__'), calldata, transactionsDetail.maxFee, transactionsDetail.chainId);
109
- return [2 /*return*/, this.sign(msgHash)];
110
- });
111
- });
112
- };
113
- LedgerBlindSigner.prototype.signMessage = function (typedData, accountAddress) {
114
- return __awaiter(this, void 0, void 0, function () {
115
- var msgHash;
116
- return __generator(this, function (_a) {
117
- msgHash = (0, typedData_1.getMessageHash)(typedData, accountAddress);
118
- return [2 /*return*/, this.sign(msgHash)];
119
- });
120
- });
121
- };
122
- LedgerBlindSigner.prototype.sign = function (msgHash) {
123
- return __awaiter(this, void 0, void 0, function () {
124
- var eth, _a, r, s;
125
- return __generator(this, function (_b) {
126
- switch (_b.label) {
127
- case 0: return [4 /*yield*/, this.getEthApp()];
128
- case 1:
129
- eth = _b.sent();
130
- return [4 /*yield*/, eth.starkUnsafeSign(this.derivationPath, hexZeroPad(msgHash, 32))];
131
- case 2:
132
- _a = (_b.sent()), r = _a.r, s = _a.s;
133
- return [2 /*return*/, [(0, encode_1.addHexPrefix)(r), (0, encode_1.addHexPrefix)(s)]];
134
- }
135
- });
136
- });
137
- };
138
- return LedgerBlindSigner;
139
- }());
140
- exports.LedgerBlindSigner = LedgerBlindSigner;
@@ -1,15 +0,0 @@
1
- import { Invocation, InvocationsSignerDetails, Signature } from '../types';
2
- import { TypedData } from '../utils/typedData';
3
- import { SignerInterface } from './interface';
4
- export declare class LedgerBlindSigner implements SignerInterface {
5
- derivationPath: string;
6
- private transport;
7
- private getEthApp;
8
- getPubKey(): Promise<string>;
9
- signTransaction(
10
- transactions: Invocation[],
11
- transactionsDetail: InvocationsSignerDetails
12
- ): Promise<Signature>;
13
- signMessage(typedData: TypedData, accountAddress: string): Promise<Signature>;
14
- protected sign(msgHash: string): Promise<Signature>;
15
- }
package/signer/ledger.js DELETED
@@ -1,250 +0,0 @@
1
- 'use strict';
2
- var __awaiter =
3
- (this && this.__awaiter) ||
4
- function (thisArg, _arguments, P, generator) {
5
- function adopt(value) {
6
- return value instanceof P
7
- ? value
8
- : new P(function (resolve) {
9
- resolve(value);
10
- });
11
- }
12
- return new (P || (P = Promise))(function (resolve, reject) {
13
- function fulfilled(value) {
14
- try {
15
- step(generator.next(value));
16
- } catch (e) {
17
- reject(e);
18
- }
19
- }
20
- function rejected(value) {
21
- try {
22
- step(generator['throw'](value));
23
- } catch (e) {
24
- reject(e);
25
- }
26
- }
27
- function step(result) {
28
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
29
- }
30
- step((generator = generator.apply(thisArg, _arguments || [])).next());
31
- });
32
- };
33
- var __generator =
34
- (this && this.__generator) ||
35
- function (thisArg, body) {
36
- var _ = {
37
- label: 0,
38
- sent: function () {
39
- if (t[0] & 1) throw t[1];
40
- return t[1];
41
- },
42
- trys: [],
43
- ops: [],
44
- },
45
- f,
46
- y,
47
- t,
48
- g;
49
- return (
50
- (g = { next: verb(0), throw: verb(1), return: verb(2) }),
51
- typeof Symbol === 'function' &&
52
- (g[Symbol.iterator] = function () {
53
- return this;
54
- }),
55
- g
56
- );
57
- function verb(n) {
58
- return function (v) {
59
- return step([n, v]);
60
- };
61
- }
62
- function step(op) {
63
- if (f) throw new TypeError('Generator is already executing.');
64
- while (_)
65
- try {
66
- if (
67
- ((f = 1),
68
- y &&
69
- (t =
70
- op[0] & 2
71
- ? y['return']
72
- : op[0]
73
- ? y['throw'] || ((t = y['return']) && t.call(y), 0)
74
- : y.next) &&
75
- !(t = t.call(y, op[1])).done)
76
- )
77
- return t;
78
- if (((y = 0), t)) op = [op[0] & 2, t.value];
79
- switch (op[0]) {
80
- case 0:
81
- case 1:
82
- t = op;
83
- break;
84
- case 4:
85
- _.label++;
86
- return { value: op[1], done: false };
87
- case 5:
88
- _.label++;
89
- y = op[1];
90
- op = [0];
91
- continue;
92
- case 7:
93
- op = _.ops.pop();
94
- _.trys.pop();
95
- continue;
96
- default:
97
- if (
98
- !((t = _.trys), (t = t.length > 0 && t[t.length - 1])) &&
99
- (op[0] === 6 || op[0] === 2)
100
- ) {
101
- _ = 0;
102
- continue;
103
- }
104
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
105
- _.label = op[1];
106
- break;
107
- }
108
- if (op[0] === 6 && _.label < t[1]) {
109
- _.label = t[1];
110
- t = op;
111
- break;
112
- }
113
- if (t && _.label < t[2]) {
114
- _.label = t[2];
115
- _.ops.push(op);
116
- break;
117
- }
118
- if (t[2]) _.ops.pop();
119
- _.trys.pop();
120
- continue;
121
- }
122
- op = body.call(thisArg, _);
123
- } catch (e) {
124
- op = [6, e];
125
- y = 0;
126
- } finally {
127
- f = t = 0;
128
- }
129
- if (op[0] & 5) throw op[1];
130
- return { value: op[0] ? op[1] : void 0, done: true };
131
- }
132
- };
133
- var __importDefault =
134
- (this && this.__importDefault) ||
135
- function (mod) {
136
- return mod && mod.__esModule ? mod : { default: mod };
137
- };
138
- Object.defineProperty(exports, '__esModule', { value: true });
139
- exports.LedgerBlindSigner = void 0;
140
- var hw_app_eth_1 = __importDefault(require('@ledgerhq/hw-app-eth'));
141
- var hw_transport_webhid_1 = __importDefault(require('@ledgerhq/hw-transport-webhid'));
142
- var encode_1 = require('../utils/encode');
143
- var hash_1 = require('../utils/hash');
144
- var transaction_1 = require('../utils/transaction');
145
- var typedData_1 = require('../utils/typedData');
146
- function hexZeroPad(hash, length) {
147
- var value = hash;
148
- if (value.length > 2 * length + 2) {
149
- throw new Error('value out of range');
150
- }
151
- while (value.length < 2 * length + 2) {
152
- value = '0x0' + value.substring(2);
153
- }
154
- return value;
155
- }
156
- var LedgerBlindSigner = /** @class */ (function () {
157
- function LedgerBlindSigner() {
158
- this.derivationPath = "/2645'/579218131'/1148870696'/0'/0'/0";
159
- }
160
- LedgerBlindSigner.prototype.getEthApp = function () {
161
- return __awaiter(this, void 0, void 0, function () {
162
- var _a, _b;
163
- return __generator(this, function (_c) {
164
- switch (_c.label) {
165
- case 0:
166
- if (!!this.transport) return [3 /*break*/, 4];
167
- _c.label = 1;
168
- case 1:
169
- _c.trys.push([1, 3, , 4]);
170
- _a = this;
171
- return [4 /*yield*/, hw_transport_webhid_1.default.create()];
172
- case 2:
173
- _a.transport = _c.sent();
174
- return [3 /*break*/, 4];
175
- case 3:
176
- _b = _c.sent();
177
- throw new Error('Device connection error');
178
- case 4:
179
- return [2 /*return*/, new hw_app_eth_1.default(this.transport)];
180
- }
181
- });
182
- });
183
- };
184
- LedgerBlindSigner.prototype.getPubKey = function () {
185
- return __awaiter(this, void 0, void 0, function () {
186
- var eth, response, starkPub;
187
- return __generator(this, function (_a) {
188
- switch (_a.label) {
189
- case 0:
190
- return [4 /*yield*/, this.getEthApp()];
191
- case 1:
192
- eth = _a.sent();
193
- return [4 /*yield*/, eth.starkGetPublicKey(this.derivationPath)];
194
- case 2:
195
- response = _a.sent();
196
- starkPub = '0x' + response.slice(1, 1 + 32).toString('hex');
197
- return [2 /*return*/, starkPub];
198
- }
199
- });
200
- });
201
- };
202
- LedgerBlindSigner.prototype.signTransaction = function (transactions, transactionsDetail) {
203
- return __awaiter(this, void 0, void 0, function () {
204
- var calldata, msgHash;
205
- return __generator(this, function (_a) {
206
- calldata = (0, transaction_1.fromCallsToExecuteCalldataWithNonce)(
207
- transactions,
208
- transactionsDetail.nonce
209
- );
210
- msgHash = (0, hash_1.calculcateTransactionHash)(
211
- transactionsDetail.walletAddress,
212
- transactionsDetail.version,
213
- (0, hash_1.getSelectorFromName)('__execute__'),
214
- calldata,
215
- transactionsDetail.maxFee,
216
- transactionsDetail.chainId
217
- );
218
- return [2 /*return*/, this.sign(msgHash)];
219
- });
220
- });
221
- };
222
- LedgerBlindSigner.prototype.signMessage = function (typedData, accountAddress) {
223
- return __awaiter(this, void 0, void 0, function () {
224
- var msgHash;
225
- return __generator(this, function (_a) {
226
- msgHash = (0, typedData_1.getMessageHash)(typedData, accountAddress);
227
- return [2 /*return*/, this.sign(msgHash)];
228
- });
229
- });
230
- };
231
- LedgerBlindSigner.prototype.sign = function (msgHash) {
232
- return __awaiter(this, void 0, void 0, function () {
233
- var eth, _a, r, s;
234
- return __generator(this, function (_b) {
235
- switch (_b.label) {
236
- case 0:
237
- return [4 /*yield*/, this.getEthApp()];
238
- case 1:
239
- eth = _b.sent();
240
- return [4 /*yield*/, eth.starkUnsafeSign(this.derivationPath, hexZeroPad(msgHash, 32))];
241
- case 2:
242
- (_a = _b.sent()), (r = _a.r), (s = _a.s);
243
- return [2 /*return*/, [(0, encode_1.addHexPrefix)(r), (0, encode_1.addHexPrefix)(s)]];
244
- }
245
- });
246
- });
247
- };
248
- return LedgerBlindSigner;
249
- })();
250
- exports.LedgerBlindSigner = LedgerBlindSigner;
@@ -1,86 +0,0 @@
1
- import Eth from '@ledgerhq/hw-app-eth';
2
- import Transport from '@ledgerhq/hw-transport';
3
- import TransportWebHID from '@ledgerhq/hw-transport-webhid';
4
-
5
- import { Invocation, InvocationsSignerDetails, Signature } from '../types';
6
- import { addHexPrefix } from '../utils/encode';
7
- import { calculcateTransactionHash, getSelectorFromName } from '../utils/hash';
8
- import { fromCallsToExecuteCalldataWithNonce } from '../utils/transaction';
9
- import { TypedData, getMessageHash } from '../utils/typedData';
10
- import { SignerInterface } from './interface';
11
-
12
- function hexZeroPad(hash: string, length: number): string {
13
- let value = hash;
14
- if (value.length > 2 * length + 2) {
15
- throw new Error('value out of range');
16
- }
17
- while (value.length < 2 * length + 2) {
18
- value = `0x0${value.substring(2)}`;
19
- }
20
- return value;
21
- }
22
-
23
- export class LedgerBlindSigner implements SignerInterface {
24
- public derivationPath = "/2645'/579218131'/1148870696'/0'/0'/0";
25
-
26
- private transport: Transport | undefined;
27
-
28
- private async getEthApp(): Promise<Eth> {
29
- if (!this.transport) {
30
- try {
31
- this.transport = await TransportWebHID.create();
32
- } catch {
33
- throw new Error('Device connection error');
34
- }
35
- }
36
- return new Eth(this.transport);
37
- }
38
-
39
- public async getPubKey(): Promise<string> {
40
- const eth = await this.getEthApp();
41
- const response = await eth.starkGetPublicKey(this.derivationPath);
42
- const starkPub = `0x${response.slice(1, 1 + 32).toString('hex')}`;
43
- return starkPub;
44
- }
45
-
46
- public async signTransaction(
47
- transactions: Invocation[],
48
- transactionsDetail: InvocationsSignerDetails
49
- ): Promise<Signature> {
50
- const calldata = fromCallsToExecuteCalldataWithNonce(transactions, transactionsDetail.nonce);
51
-
52
- const msgHash = calculcateTransactionHash(
53
- transactionsDetail.walletAddress,
54
- transactionsDetail.version,
55
- getSelectorFromName('__execute__'),
56
- calldata,
57
- transactionsDetail.maxFee,
58
- transactionsDetail.chainId
59
- );
60
-
61
- return this.sign(msgHash);
62
- }
63
-
64
- public async signMessage(typedData: TypedData, accountAddress: string): Promise<Signature> {
65
- const msgHash = getMessageHash(typedData, accountAddress);
66
-
67
- return this.sign(msgHash);
68
- }
69
-
70
- protected async sign(msgHash: string): Promise<Signature> {
71
- const eth = await this.getEthApp();
72
-
73
- const {
74
- r,
75
- s,
76
- }: {
77
- r: string;
78
- s: string;
79
- } = (await eth.starkUnsafeSign(this.derivationPath, hexZeroPad(msgHash, 32))) as {
80
- r: string;
81
- s: string;
82
- };
83
-
84
- return [addHexPrefix(r), addHexPrefix(s)];
85
- }
86
- }