@portal-hq/provider 0.2.7 → 0.2.9

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.
@@ -1,58 +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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const keychain_1 = require("@portal-hq/keychain");
13
- const utils_1 = require("@portal-hq/utils");
14
- class HttpSigner {
15
- constructor(opts) {
16
- if (!opts.portal) {
17
- throw new utils_1.MissingOptionError({
18
- className: 'HttpSigner',
19
- option: 'portal',
20
- });
21
- }
22
- this.keychain = new keychain_1.Keychain();
23
- this.portal = opts.portal;
24
- }
25
- sign(message, provider) {
26
- return __awaiter(this, void 0, void 0, function* () {
27
- const address = yield this.keychain.getAddress();
28
- const arrayMethods = ['personal_sign'];
29
- const { chainId, method, params } = message;
30
- switch (method) {
31
- case 'eth_requestAccounts':
32
- return [address];
33
- case 'eth_accounts':
34
- return [address];
35
- default:
36
- break;
37
- }
38
- console.log(`[Portal:HttpSigner] Requesting signature from exchange for:`, JSON.stringify({
39
- chainId,
40
- method,
41
- params: JSON.stringify([params]),
42
- }, null, 2));
43
- const signatureResponse = yield this.portal.post('/api/v1/clients/transactions/sign', {
44
- body: {
45
- chainId,
46
- method,
47
- params: JSON.stringify([params]),
48
- },
49
- headers: {
50
- Authorization: `Bearer ${provider.apiKey}`,
51
- 'Content-Type': 'application/json',
52
- },
53
- });
54
- return signatureResponse;
55
- });
56
- }
57
- }
58
- exports.default = HttpSigner;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.MpcSigner = exports.HttpSigner = exports.Signer = void 0;
7
- var abstract_1 = require("./abstract");
8
- Object.defineProperty(exports, "Signer", { enumerable: true, get: function () { return __importDefault(abstract_1).default; } });
9
- var http_1 = require("./http");
10
- Object.defineProperty(exports, "HttpSigner", { enumerable: true, get: function () { return __importDefault(http_1).default; } });
11
- var mpc_1 = require("./mpc");
12
- Object.defineProperty(exports, "MpcSigner", { enumerable: true, get: function () { return __importDefault(mpc_1).default; } });
@@ -1,75 +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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const react_native_1 = require("react-native");
13
- const utils_1 = require("@portal-hq/utils");
14
- class MpcSigner {
15
- constructor(opts) {
16
- this.buildParams = (method, txParams) => {
17
- let params = txParams;
18
- switch (method) {
19
- case 'eth_sign':
20
- case 'personal_sign':
21
- if (!Array.isArray(txParams)) {
22
- params = [txParams];
23
- }
24
- break;
25
- default:
26
- if (Array.isArray(txParams)) {
27
- params = txParams[0];
28
- }
29
- }
30
- return params;
31
- };
32
- this.keychain = opts.keychain;
33
- this.mpc = react_native_1.NativeModules.PortalMobileMpc;
34
- this.mpcUrl = opts.mpcUrl;
35
- if (!this.mpc) {
36
- throw new Error(`[Portal.Provider.MpcSigner] The MPC module could not be found by the signer. This is usually an issue with React Native linking. Please verify that the 'PortalReactNative' module is properly linked to this project.`);
37
- }
38
- }
39
- get address() {
40
- return (() => __awaiter(this, void 0, void 0, function* () {
41
- if (this._address) {
42
- return this._address;
43
- }
44
- const address = yield this.keychain.getAddress();
45
- this._address = address;
46
- return address;
47
- }))();
48
- }
49
- sign(message, provider) {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- const address = yield this.keychain.getAddress();
52
- const apiKey = provider.apiKey;
53
- const { method, params } = message;
54
- switch (method) {
55
- case 'eth_requestAccounts':
56
- return [address];
57
- case 'eth_accounts':
58
- return [address];
59
- default:
60
- break;
61
- }
62
- console.log(`[Portal:MpcSigner] Requesting signature from PortalMobileMpc for:`, JSON.stringify(message, null, 2));
63
- const dkg = yield this.keychain.getDkgResult();
64
- console.log(`[PortalMpcSigner] RPC URL: ${provider.rpcUrl}`);
65
- const result = yield this.mpc.sign(apiKey, this.mpcUrl, dkg, message.method, JSON.stringify(this.buildParams(method, params)), provider.rpcUrl, provider.chainId.toString());
66
- console.log(`[PortalMpcSigner] Result: `, result);
67
- const { data, error } = JSON.parse(String(result));
68
- if (error && error.length) {
69
- throw new utils_1.MpcSigningError(error);
70
- }
71
- return data;
72
- });
73
- }
74
- }
75
- exports.default = MpcSigner;
package/lib/esm/index.js DELETED
@@ -1 +0,0 @@
1
- export { default as Provider } from './providers';
@@ -1,381 +0,0 @@
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 { InvalidApiKeyError, InvalidChainIdError, InvalidGatewayConfigError, ProviderRpcError, RpcErrorCodes, } from '@portal-hq/utils';
11
- import { HttpRequester } from '../requesters';
12
- import { HttpSigner, MpcSigner } from '../signers';
13
- const passiveSignerMethods = [
14
- 'eth_accounts',
15
- 'eth_chainId',
16
- 'eth_requestAccounts',
17
- ];
18
- const signerMethods = [
19
- 'eth_accounts',
20
- 'eth_chainId',
21
- 'eth_requestAccounts',
22
- 'eth_sendTransaction',
23
- 'eth_sign',
24
- 'eth_signTransaction',
25
- 'eth_signTypedData',
26
- 'personal_sign',
27
- ];
28
- class Provider {
29
- constructor({
30
- // Required options
31
- apiKey, chainId, keychain,
32
- // Optional options
33
- apiUrl = 'api.portalhq.io', autoApprove = false, enableMpc = true, mpcUrl = 'mpc.portalhq.io', gatewayConfig = {}, }) {
34
- // Handle required fields
35
- if (!apiKey || apiKey.length === 0) {
36
- throw new InvalidApiKeyError();
37
- }
38
- if (!chainId) {
39
- throw new InvalidChainIdError();
40
- }
41
- if (!gatewayConfig) {
42
- throw new InvalidGatewayConfigError();
43
- }
44
- // Handle the stuff we can auto-set
45
- this.apiKey = apiKey;
46
- this.apiUrl = apiUrl;
47
- this.autoApprove = autoApprove;
48
- this.chainId = chainId;
49
- this.events = {};
50
- this.isMPC = enableMpc;
51
- this.keychain = keychain;
52
- this.log = console;
53
- this.mpcUrl = mpcUrl;
54
- this.portal = new HttpRequester({
55
- baseUrl: this.apiUrl,
56
- });
57
- // Handle RPC Initialization
58
- this.gatewayConfig = gatewayConfig;
59
- this.rpc = new HttpRequester({
60
- baseUrl: this.getRpcUrl(),
61
- });
62
- if (this.isMPC) {
63
- // If MPC is enabled, initialize an MpcSigner
64
- this.signer = new MpcSigner({
65
- mpcUrl: this.mpcUrl,
66
- keychain: this.keychain,
67
- });
68
- }
69
- else {
70
- // If MPC is disabled, initialize an HttpSigner, talking to whatever httpHost was provided
71
- this.signer = new HttpSigner({
72
- portal: this.portal,
73
- });
74
- }
75
- this.dispatchConnect();
76
- }
77
- get address() {
78
- return this._address;
79
- }
80
- set address(value) {
81
- this._address = value;
82
- if (this.signer && this.isMPC) {
83
- ;
84
- this.signer._address = value;
85
- }
86
- }
87
- get rpcUrl() {
88
- return this.getRpcUrl();
89
- }
90
- /**
91
- * Invokes all registered event handlers with the data provided
92
- * - If any `once` handlers exist, they are removed after all handlers are invoked
93
- *
94
- * @param event The name of the event to be handled
95
- * @param data The data to be passed to registered event handlers
96
- * @returns BaseProvider
97
- */
98
- emit(event, data) {
99
- // Grab the registered event handlers if any are available
100
- const handlers = this.events[event] || [];
101
- // Execute every event handler
102
- for (const registeredEventHandler of handlers) {
103
- registeredEventHandler.handler(data);
104
- }
105
- // Remove any registered event handlers with the `once` flag
106
- this.events[event] = handlers.filter((handler) => !handler.once);
107
- return this;
108
- }
109
- /**
110
- * Registers an event handler for the provided event
111
- *
112
- * @param event The event name to add a handler to
113
- * @param callback The callback to be invoked when the event is emitted
114
- * @returns BaseProvider
115
- */
116
- on(event, callback) {
117
- // If no handlers are registered for this event, create an entry for the event
118
- if (!this.events[event]) {
119
- this.events[event] = [];
120
- }
121
- // Register event handler with the rudimentary event bus
122
- if (typeof callback !== 'undefined') {
123
- this.events[event].push({
124
- handler: callback,
125
- once: false,
126
- });
127
- }
128
- return this;
129
- }
130
- /**
131
- * Registers a single-execution event handler for the provided event
132
- *
133
- * @param event The event name to add a handler to
134
- * @param callback The callback to be invoked the next time the event is emitted
135
- * @returns BaseProvider
136
- */
137
- once(event, callback) {
138
- // If no handlers are registered for this event, create an entry for the event
139
- if (!this.events[event]) {
140
- this.events[event] = [];
141
- }
142
- // Register event handler with the rudimentary event bus
143
- if (typeof callback !== 'undefined') {
144
- this.events[event].push({
145
- handler: callback,
146
- once: true,
147
- });
148
- }
149
- return this;
150
- }
151
- removeEventListener(event, listenerToRemove) {
152
- if (!this.events[event]) {
153
- this.log.info(`[PortalProvider] Attempted to remove a listener from unregistered event '${event}'. Ignoring.`);
154
- return;
155
- }
156
- if (!listenerToRemove) {
157
- this.events[event] = [];
158
- }
159
- else {
160
- const filterEventHandlers = (registeredEventHandler) => {
161
- return registeredEventHandler.handler !== listenerToRemove;
162
- };
163
- this.events[event] = this.events[event].filter(filterEventHandlers);
164
- }
165
- }
166
- /**
167
- * Handles request routing in compliance with the EIP-1193 Ethereum Javascript Provider API
168
- * - See here for more info: https://eips.ethereum.org/EIPS/eip-1193
169
- *
170
- * @param args The arguments of the request being made
171
- * @returns Promise<any>
172
- */
173
- request({ method, params }) {
174
- return __awaiter(this, void 0, void 0, function* () {
175
- if (method === 'eth_chainId') {
176
- return this.chainId;
177
- }
178
- const isSignerMethod = signerMethods.includes(method);
179
- let result;
180
- if (!isSignerMethod && !method.startsWith('wallet_')) {
181
- // Send to Gateway for RPC calls
182
- const response = yield this.handleGatewayRequests({ method, params });
183
- this.emit('portal_signatureReceived', {
184
- method,
185
- params,
186
- signature: response,
187
- });
188
- if (response.error) {
189
- throw new ProviderRpcError(response.error);
190
- }
191
- result = response.result;
192
- }
193
- else if (isSignerMethod) {
194
- // Handle signing
195
- const transactionHash = yield this.handleSigningRequests({
196
- method,
197
- params,
198
- });
199
- if (transactionHash) {
200
- console.log(`Received transaction hash: `, transactionHash);
201
- this.emit('portal_signatureReceived', {
202
- method,
203
- params,
204
- signature: transactionHash,
205
- });
206
- result = transactionHash;
207
- }
208
- }
209
- else {
210
- // Unsupported method
211
- throw new ProviderRpcError({
212
- code: RpcErrorCodes.UnsupportedMethod,
213
- data: {
214
- method,
215
- params,
216
- },
217
- });
218
- }
219
- return result;
220
- });
221
- }
222
- /**
223
- * Updates the chainId of this instance and builds a new RPC HttpRequester for
224
- * the gateway used for the new chain
225
- *
226
- * @param chainId A hex string of the chainId to use for this connection
227
- * @returns BaseProvider
228
- */
229
- updateChainId(chainId) {
230
- return __awaiter(this, void 0, void 0, function* () {
231
- this.chainId = Number(`${chainId}`);
232
- this.rpc = new HttpRequester({
233
- baseUrl: this.getRpcUrl(),
234
- });
235
- this.emit('chainChanged', { chainId });
236
- return this;
237
- });
238
- }
239
- /**
240
- * Kicks off the approval flow for a given request
241
- *
242
- * @param args The arguments of the request being made
243
- */
244
- getApproval({ method, params, }) {
245
- return __awaiter(this, void 0, void 0, function* () {
246
- // If autoApprove is enabled, just resolve to true
247
- if (this.autoApprove) {
248
- return true;
249
- }
250
- if (!this.events['portal_signingRequested']) {
251
- throw new Error(`[PortalProvider] Auto-approve is disabled. Cannot perform signing requests without an event handler for the 'portal_signingRequested' event.`);
252
- }
253
- return new Promise((resolve) => {
254
- // Remove already used listeners
255
- this.removeEventListener('portal_signingApproved');
256
- this.removeEventListener('portal_signingRejected');
257
- // If the signing has been approved, resolve to true
258
- this.once('portal_signingApproved', ({ method: approvedMethod, params: approvedParams }) => {
259
- console.log(`[PortalProvider] Signing Approved`, method, params);
260
- // Remove already used listeners
261
- this.removeEventListener('portal_signingApproved');
262
- this.removeEventListener('portal_signingRejected');
263
- // First verify that this is the same signing request
264
- if (method === approvedMethod &&
265
- JSON.stringify(params) === JSON.stringify(approvedParams)) {
266
- resolve(true);
267
- }
268
- });
269
- // If the signing request has been rejected, resolve to false
270
- this.once('portal_signingRejected', ({ method: rejectedMethod, params: rejectedParams }) => {
271
- console.log(`[PortalProvider] Signing Approved`, method, params);
272
- // Remove already used listeners
273
- this.removeEventListener('portal_signingApproved');
274
- this.removeEventListener('portal_signingRejected');
275
- // First verify that this is the same signing request
276
- if (method === rejectedMethod &&
277
- JSON.stringify(params) === JSON.stringify(rejectedParams)) {
278
- resolve(false);
279
- }
280
- });
281
- // Tell any listening clients that signing has been requested
282
- this.emit('portal_signingRequested', {
283
- method,
284
- params,
285
- });
286
- });
287
- });
288
- }
289
- dispatchConnect() {
290
- return __awaiter(this, void 0, void 0, function* () {
291
- console.log(`[PortalProvider] Connected on chainId: 0x${this.chainId.toString(16)}`);
292
- this.emit('connect', {
293
- chainId: `0x${this.chainId.toString(16)}`,
294
- });
295
- });
296
- }
297
- dispatchDisconnect() {
298
- return __awaiter(this, void 0, void 0, function* () {
299
- this.emit('disconnect', {
300
- error: new ProviderRpcError({
301
- code: RpcErrorCodes.Disconnected,
302
- }),
303
- });
304
- });
305
- }
306
- /**
307
- * Determines the RPC URL to be used for the current chain
308
- *
309
- * @returns string
310
- */
311
- getRpcUrl() {
312
- if (typeof this.gatewayConfig === 'string') {
313
- // If the gatewayConfig is just a static URL, return that
314
- return this.gatewayConfig;
315
- }
316
- else if (typeof this.gatewayConfig === 'object' &&
317
- !this.gatewayConfig.hasOwnProperty(this.chainId)) {
318
- // If there's no explicit mapping for the current chainId, error out
319
- throw new Error(`[PortalProvider] No RPC endpoint configured for chainId: ${this.chainId}`);
320
- }
321
- // Get the entry for the current chainId from the gatewayConfig
322
- const config = this.gatewayConfig[this.chainId];
323
- if (typeof config === 'string') {
324
- return config;
325
- }
326
- // If we got this far, there's no way to support the chain with the current config
327
- throw new Error(`[PortalProvider] Could not find a valid gatewayConfig entry for chainId: ${this.chainId}`);
328
- }
329
- /**
330
- * Sends the provided request payload along to the RPC HttpRequester
331
- *
332
- * @param args The arguments of the request being made
333
- * @returns Promise<any>
334
- */
335
- handleGatewayRequests({ method, params, }) {
336
- return __awaiter(this, void 0, void 0, function* () {
337
- // Pass request off to the gateway
338
- return yield this.rpc.post('', {
339
- body: {
340
- jsonrpc: '2.0',
341
- id: this.chainId,
342
- method,
343
- params,
344
- },
345
- });
346
- });
347
- }
348
- /**
349
- * Sends the provided request payload along to the Signer
350
- *
351
- * @param args The arguments of the request being made
352
- * @returns Promise<any>
353
- */
354
- handleSigningRequests({ method, params, }) {
355
- var _a;
356
- return __awaiter(this, void 0, void 0, function* () {
357
- const isApproved = passiveSignerMethods.includes(method)
358
- ? true
359
- : yield this.getApproval({ method, params });
360
- if (!isApproved) {
361
- this.log.info(`[PortalProvider] Request for signing method '${method}' could not be completed because it was not approved by the user.`);
362
- return;
363
- }
364
- switch (method) {
365
- case 'eth_chainId':
366
- return `0x${this.chainId.toString(16)}`;
367
- case 'eth_accounts':
368
- case 'eth_requestAccounts':
369
- case 'eth_sendTransaction':
370
- case 'eth_sign':
371
- case 'eth_signTransaction':
372
- case 'eth_signTypedData':
373
- case 'personal_sign':
374
- return yield ((_a = this.signer) === null || _a === void 0 ? void 0 : _a.sign({ chainId: this.chainId, method, params }, this));
375
- default:
376
- throw new Error('[PortalProvider] Method "' + method + '" not supported');
377
- }
378
- });
379
- }
380
- }
381
- export default Provider;
@@ -1,50 +0,0 @@
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 { HttpRequest } from '@portal-hq/utils';
11
- class HttpRequester {
12
- constructor({ baseUrl }) {
13
- this.baseUrl = baseUrl.startsWith('https://')
14
- ? baseUrl
15
- : `https://${baseUrl}`;
16
- }
17
- get(path, options) {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- const requestOptions = {
20
- method: 'GET',
21
- url: `${this.baseUrl}${path}`,
22
- };
23
- if (options && options.headers) {
24
- requestOptions.headers = this.buildHeaders(options.headers);
25
- }
26
- const request = new HttpRequest(requestOptions);
27
- const response = (yield request.send());
28
- return response;
29
- });
30
- }
31
- post(path, options) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- const requestOptions = {
34
- method: 'POST',
35
- url: `${this.baseUrl}${path}`,
36
- };
37
- requestOptions.headers = this.buildHeaders(options && options.headers ? options.headers : {});
38
- if (options && options.body) {
39
- requestOptions.body = options.body;
40
- }
41
- const request = new HttpRequest(requestOptions);
42
- const response = (yield request.send());
43
- return response;
44
- });
45
- }
46
- buildHeaders(headers) {
47
- return Object.assign({ 'Content-Type': 'application/json' }, headers);
48
- }
49
- }
50
- export default HttpRequester;
@@ -1 +0,0 @@
1
- export { default as HttpRequester } from './http';
@@ -1,17 +0,0 @@
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
- class Signer {
11
- sign(message, provider) {
12
- return __awaiter(this, void 0, void 0, function* () {
13
- throw new Error('[Portal] sign() method must be implemented in a child of BaseSigner');
14
- });
15
- }
16
- }
17
- export default Signer;
@@ -1,56 +0,0 @@
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 { Keychain } from '@portal-hq/keychain';
11
- import { MissingOptionError } from '@portal-hq/utils';
12
- class HttpSigner {
13
- constructor(opts) {
14
- if (!opts.portal) {
15
- throw new MissingOptionError({
16
- className: 'HttpSigner',
17
- option: 'portal',
18
- });
19
- }
20
- this.keychain = new Keychain();
21
- this.portal = opts.portal;
22
- }
23
- sign(message, provider) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- const address = yield this.keychain.getAddress();
26
- const arrayMethods = ['personal_sign'];
27
- const { chainId, method, params } = message;
28
- switch (method) {
29
- case 'eth_requestAccounts':
30
- return [address];
31
- case 'eth_accounts':
32
- return [address];
33
- default:
34
- break;
35
- }
36
- console.log(`[Portal:HttpSigner] Requesting signature from exchange for:`, JSON.stringify({
37
- chainId,
38
- method,
39
- params: JSON.stringify([params]),
40
- }, null, 2));
41
- const signatureResponse = yield this.portal.post('/api/v1/clients/transactions/sign', {
42
- body: {
43
- chainId,
44
- method,
45
- params: JSON.stringify([params]),
46
- },
47
- headers: {
48
- Authorization: `Bearer ${provider.apiKey}`,
49
- 'Content-Type': 'application/json',
50
- },
51
- });
52
- return signatureResponse;
53
- });
54
- }
55
- }
56
- export default HttpSigner;
@@ -1,3 +0,0 @@
1
- export { default as Signer } from './abstract';
2
- export { default as HttpSigner } from './http';
3
- export { default as MpcSigner } from './mpc';