@aptos-labs/wallet-adapter-core 0.2.0 → 0.2.1

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,5 +1,11 @@
1
1
  # @aptos-labs/wallet-adapter-core
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 1c3576e: Throw Sign Transaction is not supported error
8
+
3
9
  ## 0.2.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.js CHANGED
@@ -138,6 +138,12 @@ var WalletSignTransactionError = class extends WalletError {
138
138
  this.name = "WalletSignTransactionError";
139
139
  }
140
140
  };
141
+ var WalletNotSupportedMethod = class extends WalletError {
142
+ constructor() {
143
+ super(...arguments);
144
+ this.name = "WalletNotSupportedMethod";
145
+ }
146
+ };
141
147
 
142
148
  // src/utils/scopePollingDetectionStrategy.ts
143
149
  function scopePollingDetectionStrategy(detect) {
@@ -318,9 +324,13 @@ var WalletCore = class extends import_eventemitter3.default {
318
324
  }
319
325
  }
320
326
  async signTransaction(transaction) {
327
+ var _a;
328
+ if (this._wallet && !("signTransaction" in this._wallet)) {
329
+ throw new WalletNotSupportedMethod(
330
+ `Sign Transaction is not supported by ${(_a = this.wallet) == null ? void 0 : _a.name}`
331
+ ).message;
332
+ }
321
333
  try {
322
- if (this._wallet && !("signTransaction" in this._wallet))
323
- return null;
324
334
  this.doesWalletExist();
325
335
  const response = await this._wallet.signTransaction(transaction);
326
336
  return response;
package/dist/index.mjs CHANGED
@@ -104,6 +104,12 @@ var WalletSignTransactionError = class extends WalletError {
104
104
  this.name = "WalletSignTransactionError";
105
105
  }
106
106
  };
107
+ var WalletNotSupportedMethod = class extends WalletError {
108
+ constructor() {
109
+ super(...arguments);
110
+ this.name = "WalletNotSupportedMethod";
111
+ }
112
+ };
107
113
 
108
114
  // src/utils/scopePollingDetectionStrategy.ts
109
115
  function scopePollingDetectionStrategy(detect) {
@@ -284,9 +290,13 @@ var WalletCore = class extends EventEmitter {
284
290
  }
285
291
  }
286
292
  async signTransaction(transaction) {
293
+ var _a;
294
+ if (this._wallet && !("signTransaction" in this._wallet)) {
295
+ throw new WalletNotSupportedMethod(
296
+ `Sign Transaction is not supported by ${(_a = this.wallet) == null ? void 0 : _a.name}`
297
+ ).message;
298
+ }
287
299
  try {
288
- if (this._wallet && !("signTransaction" in this._wallet))
289
- return null;
290
300
  this.doesWalletExist();
291
301
  const response = await this._wallet.signTransaction(transaction);
292
302
  return response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aptos-labs/wallet-adapter-core",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Aptos Wallet Adapter Core",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
package/src/WalletCore.ts CHANGED
@@ -14,6 +14,7 @@ import {
14
14
  WalletNotConnectedError,
15
15
  WalletNotReadyError,
16
16
  WalletNotSelectedError,
17
+ WalletNotSupportedMethod,
17
18
  WalletSignAndSubmitMessageError,
18
19
  WalletSignMessageAndVerifyError,
19
20
  WalletSignMessageError,
@@ -240,8 +241,13 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
240
241
  async signTransaction(
241
242
  transaction: Types.TransactionPayload
242
243
  ): Promise<Uint8Array | null> {
244
+ if (this._wallet && !("signTransaction" in this._wallet)) {
245
+ throw new WalletNotSupportedMethod(
246
+ `Sign Transaction is not supported by ${this.wallet?.name}`
247
+ ).message;
248
+ }
249
+
243
250
  try {
244
- if (this._wallet && !("signTransaction" in this._wallet)) return null;
245
251
  this.doesWalletExist();
246
252
  const response = await (this._wallet as any).signTransaction(transaction);
247
253
  return response;
@@ -98,3 +98,7 @@ export class WalletWindowClosedError extends WalletError {
98
98
  export class WalletResponseError extends WalletError {
99
99
  name = "WalletResponseError";
100
100
  }
101
+
102
+ export class WalletNotSupportedMethod extends WalletError {
103
+ name = "WalletNotSupportedMethod";
104
+ }