@portal-hq/provider 0.2.0-beta9 → 0.2.2

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.
@@ -30,7 +30,7 @@ const signerMethods = [
30
30
  class Provider {
31
31
  constructor({
32
32
  // Required options
33
- apiKey, chainId,
33
+ apiKey, chainId, keychain,
34
34
  // Optional options
35
35
  apiUrl = 'api.portalhq.io', autoApprove = false, enableMpc = true, mpcUrl = 'mpc.portalhq.io', gatewayConfig = {}, }) {
36
36
  // Handle required fields
@@ -50,6 +50,7 @@ class Provider {
50
50
  this.chainId = chainId;
51
51
  this.events = {};
52
52
  this.isMPC = enableMpc;
53
+ this.keychain = keychain;
53
54
  this.log = console;
54
55
  this.mpcUrl = mpcUrl;
55
56
  this.portal = new requesters_1.HttpRequester({
@@ -64,6 +65,7 @@ class Provider {
64
65
  // If MPC is enabled, initialize an MpcSigner
65
66
  this.signer = new signers_1.MpcSigner({
66
67
  mpcUrl: this.mpcUrl,
68
+ keychain: this.keychain,
67
69
  });
68
70
  }
69
71
  else {
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const react_native_1 = require("react-native");
13
- const keychain_1 = require("@portal-hq/keychain");
14
13
  const utils_1 = require("@portal-hq/utils");
15
14
  class MpcSigner {
16
15
  constructor(opts) {
@@ -30,12 +29,12 @@ class MpcSigner {
30
29
  }
31
30
  return params;
32
31
  };
32
+ this.keychain = opts.keychain;
33
33
  this.mpc = react_native_1.NativeModules.PortalMobileMpc;
34
34
  this.mpcUrl = opts.mpcUrl;
35
35
  if (!this.mpc) {
36
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
37
  }
38
- this.keychain = new keychain_1.Keychain();
39
38
  }
40
39
  get address() {
41
40
  return (() => __awaiter(this, void 0, void 0, function* () {
@@ -28,7 +28,7 @@ const signerMethods = [
28
28
  class Provider {
29
29
  constructor({
30
30
  // Required options
31
- apiKey, chainId,
31
+ apiKey, chainId, keychain,
32
32
  // Optional options
33
33
  apiUrl = 'api.portalhq.io', autoApprove = false, enableMpc = true, mpcUrl = 'mpc.portalhq.io', gatewayConfig = {}, }) {
34
34
  // Handle required fields
@@ -48,6 +48,7 @@ class Provider {
48
48
  this.chainId = chainId;
49
49
  this.events = {};
50
50
  this.isMPC = enableMpc;
51
+ this.keychain = keychain;
51
52
  this.log = console;
52
53
  this.mpcUrl = mpcUrl;
53
54
  this.portal = new HttpRequester({
@@ -62,6 +63,7 @@ class Provider {
62
63
  // If MPC is enabled, initialize an MpcSigner
63
64
  this.signer = new MpcSigner({
64
65
  mpcUrl: this.mpcUrl,
66
+ keychain: this.keychain,
65
67
  });
66
68
  }
67
69
  else {
@@ -8,7 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { NativeModules } from 'react-native';
11
- import { Keychain } from '@portal-hq/keychain';
12
11
  import { MpcSigningError } from '@portal-hq/utils';
13
12
  class MpcSigner {
14
13
  constructor(opts) {
@@ -28,12 +27,12 @@ class MpcSigner {
28
27
  }
29
28
  return params;
30
29
  };
30
+ this.keychain = opts.keychain;
31
31
  this.mpc = NativeModules.PortalMobileMpc;
32
32
  this.mpcUrl = opts.mpcUrl;
33
33
  if (!this.mpc) {
34
34
  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.`);
35
35
  }
36
- this.keychain = new Keychain();
37
36
  }
38
37
  get address() {
39
38
  return (() => __awaiter(this, void 0, void 0, function* () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portal-hq/provider",
3
- "version": "0.2.0-beta9",
3
+ "version": "0.2.2",
4
4
  "license": "MIT",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -17,8 +17,7 @@
17
17
  "prepare:esm": "tsc --outDir lib/esm --module es2015 --target es2015"
18
18
  },
19
19
  "dependencies": {
20
- "@portal-hq/keychain": "^0.2.0-beta9",
21
- "@portal-hq/utils": "^0.2.0-beta9"
20
+ "@portal-hq/utils": "^0.2.2"
22
21
  },
23
22
  "devDependencies": {
24
23
  "typescript": "^4.8.4"
@@ -2,6 +2,7 @@ import {
2
2
  InvalidApiKeyError,
3
3
  InvalidChainIdError,
4
4
  InvalidGatewayConfigError,
5
+ KeychainAdapter,
5
6
  ProviderRpcError,
6
7
  RpcErrorCodes,
7
8
  } from '@portal-hq/utils'
@@ -46,6 +47,7 @@ class Provider {
46
47
  private apiUrl: string
47
48
  private autoApprove?: boolean
48
49
  private events: Record<string, RegisteredEventHandler[]>
50
+ private keychain: KeychainAdapter
49
51
  private log: Console
50
52
  private gatewayConfig: GatewayLike
51
53
  private rpc: HttpRequester
@@ -56,6 +58,7 @@ class Provider {
56
58
  // Required options
57
59
  apiKey,
58
60
  chainId,
61
+ keychain,
59
62
 
60
63
  // Optional options
61
64
  apiUrl = 'api.portalhq.io',
@@ -82,6 +85,7 @@ class Provider {
82
85
  this.chainId = chainId
83
86
  this.events = {}
84
87
  this.isMPC = enableMpc
88
+ this.keychain = keychain
85
89
  this.log = console
86
90
  this.mpcUrl = mpcUrl
87
91
  this.portal = new HttpRequester({
@@ -99,6 +103,7 @@ class Provider {
99
103
  // If MPC is enabled, initialize an MpcSigner
100
104
  this.signer = new MpcSigner({
101
105
  mpcUrl: this.mpcUrl,
106
+ keychain: this.keychain,
102
107
  })
103
108
  } else {
104
109
  // If MPC is disabled, initialize an HttpSigner, talking to whatever httpHost was provided
@@ -1,6 +1,5 @@
1
1
  import { NativeModules } from 'react-native'
2
- import { Keychain } from '@portal-hq/keychain'
3
- import { MpcSigningError } from '@portal-hq/utils'
2
+ import { KeychainAdapter, MpcSigningError } from '@portal-hq/utils'
4
3
 
5
4
  import { Provider } from '../index'
6
5
  import Signer from './abstract'
@@ -14,11 +13,12 @@ import {
14
13
 
15
14
  class MpcSigner implements Signer {
16
15
  public _address: string
17
- private keychain: Keychain
16
+ private keychain: KeychainAdapter
18
17
  private mpc: PortalMobileMpc
19
18
  private mpcUrl: string
20
19
 
21
20
  constructor(opts: MpcSignerOptions) {
21
+ this.keychain = opts.keychain
22
22
  this.mpc = NativeModules.PortalMobileMpc
23
23
  this.mpcUrl = opts.mpcUrl
24
24
 
@@ -27,8 +27,6 @@ class MpcSigner implements Signer {
27
27
  `[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.`,
28
28
  )
29
29
  }
30
-
31
- this.keychain = new Keychain()
32
30
  }
33
31
 
34
32
  public get address() {
package/types.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  // Types
2
2
 
3
+ import { KeychainAdapter } from '@portal-hq/utils'
4
+
3
5
  export type EventHandler = (data: any) => void
4
6
 
5
7
  export type GatewayLike = GatewayConfig | string
@@ -21,6 +23,7 @@ export interface HttpSignerOptions extends SignerOptions {
21
23
  }
22
24
 
23
25
  export interface MpcSignerOptions extends SignerOptions {
26
+ keychain: KeychainAdapter
24
27
  mpcUrl: string
25
28
  }
26
29
 
@@ -47,6 +50,7 @@ export interface ProviderOptions {
47
50
  // Required options
48
51
  apiKey: string
49
52
  chainId: number
53
+ keychain: KeychainAdapter
50
54
  gatewayConfig: GatewayLike
51
55
 
52
56
  // Optional options