@onekeyfe/onekey-polkadot-provider 2.1.12 → 2.1.13

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.
@@ -122,9 +122,16 @@ class ProviderPolkadot extends ProviderPolkadotBase {
122
122
  });
123
123
  }
124
124
  web3Accounts(anyType) {
125
- return this._callBridge({
126
- method: 'web3Accounts',
127
- params: anyType !== null && anyType !== void 0 ? anyType : false,
125
+ const _super = Object.create(null, {
126
+ emit: { get: () => super.emit }
127
+ });
128
+ return __awaiter(this, void 0, void 0, function* () {
129
+ const accounts = yield this._callBridge({
130
+ method: 'web3Accounts',
131
+ params: anyType !== null && anyType !== void 0 ? anyType : false,
132
+ });
133
+ _super.emit.call(this, 'accountChanged', accounts);
134
+ return accounts;
128
135
  });
129
136
  }
130
137
  web3AccountsSubscribe(cb) {
@@ -128,9 +128,16 @@ class ProviderPolkadot extends ProviderPolkadotBase_1.ProviderPolkadotBase {
128
128
  });
129
129
  }
130
130
  web3Accounts(anyType) {
131
- return this._callBridge({
132
- method: 'web3Accounts',
133
- params: anyType !== null && anyType !== void 0 ? anyType : false,
131
+ const _super = Object.create(null, {
132
+ emit: { get: () => super.emit }
133
+ });
134
+ return __awaiter(this, void 0, void 0, function* () {
135
+ const accounts = yield this._callBridge({
136
+ method: 'web3Accounts',
137
+ params: anyType !== null && anyType !== void 0 ? anyType : false,
138
+ });
139
+ _super.emit.call(this, 'accountChanged', accounts);
140
+ return accounts;
134
141
  });
135
142
  }
136
143
  web3AccountsSubscribe(cb) {
@@ -16,7 +16,16 @@ class default_1 {
16
16
  return this.provider.web3Accounts(anyType);
17
17
  });
18
18
  this.subscribe = (cb) => {
19
- return this.provider.web3AccountsSubscribe(cb);
19
+ // listener for account change
20
+ const unsub = this.provider.web3AccountsSubscribe(cb);
21
+ void this.get();
22
+ return unsub;
23
+ };
24
+ }
25
+ toJSON() {
26
+ return {
27
+ get: {},
28
+ subscribe: {},
20
29
  };
21
30
  }
22
31
  }
@@ -12,5 +12,13 @@ class default_1 {
12
12
  this.provider = undefined;
13
13
  this.signer = new Signer_1.default(provider);
14
14
  }
15
+ toJSON() {
16
+ return {
17
+ accounts: this.accounts,
18
+ metadata: this.metadata,
19
+ provider: this.provider,
20
+ signer: this.signer,
21
+ };
22
+ }
15
23
  }
16
24
  exports.default = default_1;
@@ -19,5 +19,8 @@ class Signer {
19
19
  return this.provider.web3SignRaw(payload);
20
20
  });
21
21
  }
22
+ toJSON() {
23
+ return {};
24
+ }
22
25
  }
23
26
  exports.default = Signer;
@@ -6,4 +6,8 @@ export default class implements InjectedAccounts {
6
6
  constructor(provider: ProviderPolkadot);
7
7
  get: (anyType?: boolean) => Promise<InjectedAccount[]>;
8
8
  subscribe: (cb: (accounts: InjectedAccount[]) => unknown) => Unsubcall;
9
+ toJSON(): {
10
+ get: {};
11
+ subscribe: {};
12
+ };
9
13
  }
@@ -14,7 +14,16 @@ export default class {
14
14
  return this.provider.web3Accounts(anyType);
15
15
  });
16
16
  this.subscribe = (cb) => {
17
- return this.provider.web3AccountsSubscribe(cb);
17
+ // listener for account change
18
+ const unsub = this.provider.web3AccountsSubscribe(cb);
19
+ void this.get();
20
+ return unsub;
21
+ };
22
+ }
23
+ toJSON() {
24
+ return {
25
+ get: {},
26
+ subscribe: {},
18
27
  };
19
28
  }
20
29
  }
@@ -8,4 +8,10 @@ export default class implements Injected {
8
8
  readonly provider: InjectedProvider | undefined;
9
9
  readonly signer: Signer;
10
10
  constructor(provider: ProviderPolkadot);
11
+ toJSON(): {
12
+ accounts: Accounts;
13
+ metadata: InjectedMetadata | undefined;
14
+ provider: InjectedProvider | undefined;
15
+ signer: Signer;
16
+ };
11
17
  }
@@ -7,4 +7,12 @@ export default class {
7
7
  this.provider = undefined;
8
8
  this.signer = new Signer(provider);
9
9
  }
10
+ toJSON() {
11
+ return {
12
+ accounts: this.accounts,
13
+ metadata: this.metadata,
14
+ provider: this.provider,
15
+ signer: this.signer,
16
+ };
17
+ }
10
18
  }
@@ -5,4 +5,5 @@ export default class Signer {
5
5
  constructor(provider: ProviderPolkadot);
6
6
  signPayload: (payload: SignerPayloadJSON) => Promise<SignerResult>;
7
7
  signRaw: (payload: SignerPayloadRaw) => Promise<SignerResult>;
8
+ toJSON(): {};
8
9
  }
@@ -17,4 +17,7 @@ export default class Signer {
17
17
  return this.provider.web3SignRaw(payload);
18
18
  });
19
19
  }
20
+ toJSON() {
21
+ return {};
22
+ }
20
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/onekey-polkadot-provider",
3
- "version": "2.1.12",
3
+ "version": "2.1.13",
4
4
  "keywords": [
5
5
  "cross-inpage-provider"
6
6
  ],
@@ -29,14 +29,14 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@noble/hashes": "^1.3.0",
32
- "@onekeyfe/cross-inpage-provider-core": "2.1.12",
33
- "@onekeyfe/cross-inpage-provider-errors": "2.1.12",
34
- "@onekeyfe/cross-inpage-provider-types": "2.1.12",
35
- "@onekeyfe/extension-bridge-injected": "2.1.12",
32
+ "@onekeyfe/cross-inpage-provider-core": "2.1.13",
33
+ "@onekeyfe/cross-inpage-provider-errors": "2.1.13",
34
+ "@onekeyfe/cross-inpage-provider-types": "2.1.13",
35
+ "@onekeyfe/extension-bridge-injected": "2.1.13",
36
36
  "@polkadot/extension-inject": "^0.46.3",
37
37
  "eth-rpc-errors": "^4.0.3",
38
38
  "long": "^5.2.1",
39
39
  "mitt": "^3.0.0"
40
40
  },
41
- "gitHead": "5407a590d267cfd0a5fccd4fab057e0d9ff45732"
41
+ "gitHead": "84a01657418560bc3254344067531e559cbb45f4"
42
42
  }