@dynamic-labs/waas-sui 4.12.0 → 4.12.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,4 +1,11 @@
1
1
 
2
+ ### [4.12.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.12.0...v4.12.1) (2025-04-15)
3
+
4
+
5
+ ### Features
6
+
7
+ * add dedicated sui wallet client for waas to override transactions ([#8539](https://github.com/dynamic-labs/dynamic-auth/issues/8539)) ([b37b336](https://github.com/dynamic-labs/dynamic-auth/commit/b37b336060dbfd2ad621c86ae78bd07d44a5fe1e))
8
+
2
9
  ## [4.12.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.11.2...v4.12.0) (2025-04-14)
3
10
 
4
11
 
@@ -18,6 +18,18 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18
18
  PERFORMANCE OF THIS SOFTWARE.
19
19
  ***************************************************************************** */
20
20
 
21
+ function __rest(s, e) {
22
+ var t = {};
23
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
24
+ t[p] = s[p];
25
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
26
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
27
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
28
+ t[p[i]] = s[p[i]];
29
+ }
30
+ return t;
31
+ }
32
+
21
33
  function __awaiter(thisArg, _arguments, P, generator) {
22
34
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
35
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -34,3 +46,4 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
34
46
  };
35
47
 
36
48
  exports.__awaiter = __awaiter;
49
+ exports.__rest = __rest;
@@ -14,6 +14,18 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
15
  ***************************************************************************** */
16
16
 
17
+ function __rest(s, e) {
18
+ var t = {};
19
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
20
+ t[p] = s[p];
21
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
22
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
23
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
24
+ t[p[i]] = s[p[i]];
25
+ }
26
+ return t;
27
+ }
28
+
17
29
  function __awaiter(thisArg, _arguments, P, generator) {
18
30
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
31
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -29,4 +41,4 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
29
41
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
30
42
  };
31
43
 
32
- export { __awaiter };
44
+ export { __awaiter, __rest };
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.12.0";
6
+ var version = "4.12.1";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.12.0";
2
+ var version = "4.12.1";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/waas-sui",
3
- "version": "4.12.0",
3
+ "version": "4.12.1",
4
4
  "description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
5
5
  "author": "Dynamic Labs, Inc.",
6
6
  "license": "MIT",
@@ -21,13 +21,13 @@
21
21
  "@dynamic-labs-wallet/sui": "0.0.60",
22
22
  "@mysten/sui": "1.24.0",
23
23
  "@mysten/wallet-standard": "0.13.29",
24
- "@dynamic-labs/sui": "4.12.0",
25
- "@dynamic-labs/assert-package-version": "4.12.0",
26
- "@dynamic-labs/logger": "4.12.0",
27
- "@dynamic-labs/rpc-providers": "4.12.0",
28
- "@dynamic-labs/utils": "4.12.0",
29
- "@dynamic-labs/wallet-book": "4.12.0",
30
- "@dynamic-labs/wallet-connector-core": "4.12.0"
24
+ "@dynamic-labs/sui": "4.12.1",
25
+ "@dynamic-labs/assert-package-version": "4.12.1",
26
+ "@dynamic-labs/logger": "4.12.1",
27
+ "@dynamic-labs/rpc-providers": "4.12.1",
28
+ "@dynamic-labs/utils": "4.12.1",
29
+ "@dynamic-labs/wallet-book": "4.12.1",
30
+ "@dynamic-labs/wallet-connector-core": "4.12.1"
31
31
  },
32
32
  "peerDependencies": {}
33
33
  }
@@ -9,10 +9,12 @@ var client = require('@mysten/sui/client');
9
9
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
10
10
  var utils = require('@dynamic-labs/utils');
11
11
  var sui = require('@dynamic-labs/sui');
12
+ var WaasSuiWallet = require('../wallet/WaasSuiWallet.cjs');
12
13
 
13
14
  class DynamicWaasSuiConnector extends sui.SuiWalletConnector {
14
15
  constructor(props) {
15
16
  super('Dynamic Waas', props);
17
+ this.ChainWallet = WaasSuiWallet.WaasSuiWallet;
16
18
  this.switchNetworkOnlyFromWallet = false;
17
19
  this.name = 'Dynamic Waas';
18
20
  this.overrideKey = 'dynamicwaas';
@@ -21,7 +23,9 @@ class DynamicWaasSuiConnector extends sui.SuiWalletConnector {
21
23
  connect() {
22
24
  return _tslib.__awaiter(this, void 0, void 0, function* () {
23
25
  this.getWaasWalletClient();
24
- this.activeNetworkId = '501'; // default to mainnet
26
+ if (!this.activeNetworkId) {
27
+ this.activeNetworkId = '501'; // default to mainnet
28
+ }
25
29
  });
26
30
  }
27
31
  getNetwork() {
@@ -81,6 +85,11 @@ class DynamicWaasSuiConnector extends sui.SuiWalletConnector {
81
85
  setActiveAccountAddress(accountAddress) {
82
86
  this.activeAccountAddress = accountAddress;
83
87
  }
88
+ getActiveAccountAddress() {
89
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
90
+ return this.activeAccountAddress;
91
+ });
92
+ }
84
93
  createDynamicWaasClient() {
85
94
  var _a;
86
95
  const authToken = (_a = this.getAuthToken) === null || _a === void 0 ? void 0 : _a.call(this);
@@ -4,7 +4,9 @@ import { Transaction } from '@mysten/sui/transactions';
4
4
  import { SignedTransaction } from '@mysten/wallet-standard';
5
5
  import { IDynamicWaasConnector } from '@dynamic-labs/wallet-connector-core';
6
6
  import { SuiWalletConnector, SuiWalletConnectorProps } from '@dynamic-labs/sui';
7
+ import { WaasSuiWallet } from '../wallet/WaasSuiWallet';
7
8
  export declare class DynamicWaasSuiConnector extends SuiWalletConnector implements IDynamicWaasConnector {
9
+ ChainWallet: typeof WaasSuiWallet;
8
10
  switchNetworkOnlyFromWallet: boolean;
9
11
  constructor(props: SuiWalletConnectorProps);
10
12
  connect(): Promise<void>;
@@ -28,6 +30,7 @@ export declare class DynamicWaasSuiConnector extends SuiWalletConnector implemen
28
30
  setBaseApiUrl(baseApiUrl: string): void;
29
31
  setRelayUrl(relayUrl: string): void;
30
32
  private setActiveAccountAddress;
33
+ getActiveAccountAddress(): Promise<string | undefined>;
31
34
  createDynamicWaasClient(): DynamicSuiWalletClient;
32
35
  getWaasWalletClient(): DynamicSuiWalletClient;
33
36
  validateActiveWallet(expectedAddress: string): Promise<void>;
@@ -5,10 +5,12 @@ import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
5
5
  import { isSameAddress } from '@dynamic-labs/wallet-connector-core';
6
6
  import { DynamicError } from '@dynamic-labs/utils';
7
7
  import { SuiWalletConnector } from '@dynamic-labs/sui';
8
+ import { WaasSuiWallet } from '../wallet/WaasSuiWallet.js';
8
9
 
9
10
  class DynamicWaasSuiConnector extends SuiWalletConnector {
10
11
  constructor(props) {
11
12
  super('Dynamic Waas', props);
13
+ this.ChainWallet = WaasSuiWallet;
12
14
  this.switchNetworkOnlyFromWallet = false;
13
15
  this.name = 'Dynamic Waas';
14
16
  this.overrideKey = 'dynamicwaas';
@@ -17,7 +19,9 @@ class DynamicWaasSuiConnector extends SuiWalletConnector {
17
19
  connect() {
18
20
  return __awaiter(this, void 0, void 0, function* () {
19
21
  this.getWaasWalletClient();
20
- this.activeNetworkId = '501'; // default to mainnet
22
+ if (!this.activeNetworkId) {
23
+ this.activeNetworkId = '501'; // default to mainnet
24
+ }
21
25
  });
22
26
  }
23
27
  getNetwork() {
@@ -77,6 +81,11 @@ class DynamicWaasSuiConnector extends SuiWalletConnector {
77
81
  setActiveAccountAddress(accountAddress) {
78
82
  this.activeAccountAddress = accountAddress;
79
83
  }
84
+ getActiveAccountAddress() {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ return this.activeAccountAddress;
87
+ });
88
+ }
80
89
  createDynamicWaasClient() {
81
90
  var _a;
82
91
  const authToken = (_a = this.getAuthToken) === null || _a === void 0 ? void 0 : _a.call(this);
@@ -0,0 +1,82 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../_virtual/_tslib.cjs');
7
+ var transactions = require('@mysten/sui/transactions');
8
+ var sui = require('@dynamic-labs/sui');
9
+ var utils = require('@dynamic-labs/utils');
10
+
11
+ class WaasSuiWallet extends sui.SuiWallet {
12
+ constructor(_a) {
13
+ var { connector } = _a, props = _tslib.__rest(_a, ["connector"]);
14
+ super(Object.assign({ connector }, props));
15
+ }
16
+ /**
17
+ * Sends the native balance of the wallet to the given address.
18
+ * @param amount - The amount of balance
19
+ * @param toAddress - The address to send the balance to.
20
+ * @returns The transaction as base64 encoded bcs.
21
+ */
22
+ sendBalance(_a) {
23
+ return _tslib.__awaiter(this, arguments, void 0, function* ({ amount, toAddress }) {
24
+ const suiWalletConnector = this
25
+ ._connector;
26
+ if (!suiWalletConnector) {
27
+ throw new Error('SUI wallet connector not found');
28
+ }
29
+ yield suiWalletConnector.connect();
30
+ // Build transaction
31
+ const value = amount.toString();
32
+ const transactionRequest = new transactions.Transaction();
33
+ const sender = this.address;
34
+ transactionRequest.setSender(sender);
35
+ transactionRequest.setGasPrice(1000);
36
+ transactionRequest.setGasBudget(10000000);
37
+ const [coin] = transactionRequest.splitCoins(transactionRequest.gas, [
38
+ Number(value) * sui.MIST_PER_SUI,
39
+ ]);
40
+ transactionRequest.transferObjects([coin], toAddress);
41
+ // Execute transaction
42
+ suiWalletConnector.getWalletClientByAddress({
43
+ accountAddress: this.address,
44
+ });
45
+ const { digest } = yield suiWalletConnector.signAndExecuteTransaction(transactionRequest);
46
+ return digest;
47
+ });
48
+ }
49
+ /**
50
+ * Signs a Sui [Transaction].
51
+ * @param transaction - The [Transaction] to sign.
52
+ * @returns The signature of the signed transaction.
53
+ */
54
+ signTransaction(transaction) {
55
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
56
+ const suiWalletConnector = this
57
+ ._connector;
58
+ if (!suiWalletConnector) {
59
+ throw new Error('SUI wallet connector not found');
60
+ }
61
+ yield suiWalletConnector.connect();
62
+ const signedTransaction = yield suiWalletConnector.signTransaction(transaction);
63
+ return signedTransaction;
64
+ });
65
+ }
66
+ getActiveNetwork() {
67
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
68
+ const suiWalletConnector = this
69
+ ._connector;
70
+ if (!suiWalletConnector) {
71
+ throw new Error('SUI wallet connector not found');
72
+ }
73
+ const activeNetworkName = yield suiWalletConnector.getNetworkName();
74
+ if (!activeNetworkName) {
75
+ throw new utils.DynamicError('Unable to retrieve Sui active network');
76
+ }
77
+ return activeNetworkName;
78
+ });
79
+ }
80
+ }
81
+
82
+ exports.WaasSuiWallet = WaasSuiWallet;
@@ -0,0 +1,22 @@
1
+ import { Transaction } from '@mysten/sui/transactions';
2
+ import { SignedTransaction } from '@mysten/wallet-standard';
3
+ import { WalletProps } from '@dynamic-labs/wallet-connector-core';
4
+ import { SuiWallet, SuiSendBalanceProps } from '@dynamic-labs/sui';
5
+ import { DynamicWaasSuiConnector } from '../connector/DynamicWaasSuiConnector';
6
+ export declare class WaasSuiWallet extends SuiWallet {
7
+ constructor({ connector, ...props }: WalletProps<DynamicWaasSuiConnector>);
8
+ /**
9
+ * Sends the native balance of the wallet to the given address.
10
+ * @param amount - The amount of balance
11
+ * @param toAddress - The address to send the balance to.
12
+ * @returns The transaction as base64 encoded bcs.
13
+ */
14
+ sendBalance({ amount, toAddress }: SuiSendBalanceProps): Promise<string>;
15
+ /**
16
+ * Signs a Sui [Transaction].
17
+ * @param transaction - The [Transaction] to sign.
18
+ * @returns The signature of the signed transaction.
19
+ */
20
+ signTransaction(transaction: Transaction): Promise<SignedTransaction>;
21
+ getActiveNetwork(): Promise<string | undefined>;
22
+ }
@@ -0,0 +1,78 @@
1
+ 'use client'
2
+ import { __rest, __awaiter } from '../../_virtual/_tslib.js';
3
+ import { Transaction } from '@mysten/sui/transactions';
4
+ import { SuiWallet, MIST_PER_SUI } from '@dynamic-labs/sui';
5
+ import { DynamicError } from '@dynamic-labs/utils';
6
+
7
+ class WaasSuiWallet extends SuiWallet {
8
+ constructor(_a) {
9
+ var { connector } = _a, props = __rest(_a, ["connector"]);
10
+ super(Object.assign({ connector }, props));
11
+ }
12
+ /**
13
+ * Sends the native balance of the wallet to the given address.
14
+ * @param amount - The amount of balance
15
+ * @param toAddress - The address to send the balance to.
16
+ * @returns The transaction as base64 encoded bcs.
17
+ */
18
+ sendBalance(_a) {
19
+ return __awaiter(this, arguments, void 0, function* ({ amount, toAddress }) {
20
+ const suiWalletConnector = this
21
+ ._connector;
22
+ if (!suiWalletConnector) {
23
+ throw new Error('SUI wallet connector not found');
24
+ }
25
+ yield suiWalletConnector.connect();
26
+ // Build transaction
27
+ const value = amount.toString();
28
+ const transactionRequest = new Transaction();
29
+ const sender = this.address;
30
+ transactionRequest.setSender(sender);
31
+ transactionRequest.setGasPrice(1000);
32
+ transactionRequest.setGasBudget(10000000);
33
+ const [coin] = transactionRequest.splitCoins(transactionRequest.gas, [
34
+ Number(value) * MIST_PER_SUI,
35
+ ]);
36
+ transactionRequest.transferObjects([coin], toAddress);
37
+ // Execute transaction
38
+ suiWalletConnector.getWalletClientByAddress({
39
+ accountAddress: this.address,
40
+ });
41
+ const { digest } = yield suiWalletConnector.signAndExecuteTransaction(transactionRequest);
42
+ return digest;
43
+ });
44
+ }
45
+ /**
46
+ * Signs a Sui [Transaction].
47
+ * @param transaction - The [Transaction] to sign.
48
+ * @returns The signature of the signed transaction.
49
+ */
50
+ signTransaction(transaction) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ const suiWalletConnector = this
53
+ ._connector;
54
+ if (!suiWalletConnector) {
55
+ throw new Error('SUI wallet connector not found');
56
+ }
57
+ yield suiWalletConnector.connect();
58
+ const signedTransaction = yield suiWalletConnector.signTransaction(transaction);
59
+ return signedTransaction;
60
+ });
61
+ }
62
+ getActiveNetwork() {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ const suiWalletConnector = this
65
+ ._connector;
66
+ if (!suiWalletConnector) {
67
+ throw new Error('SUI wallet connector not found');
68
+ }
69
+ const activeNetworkName = yield suiWalletConnector.getNetworkName();
70
+ if (!activeNetworkName) {
71
+ throw new DynamicError('Unable to retrieve Sui active network');
72
+ }
73
+ return activeNetworkName;
74
+ });
75
+ }
76
+ }
77
+
78
+ export { WaasSuiWallet };