suidouble 2.17.0-1 → 2.17.0-3

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.
@@ -118,6 +118,33 @@ export default class SuiInBrowser extends SuiCommonMethods {
118
118
  return await this._activeAdapter.signPersonalMessage(enriched);
119
119
  }
120
120
 
121
+ createBoundSigner() {
122
+ const adapter = this._activeAdapter;
123
+ const address = this._connectedAddress;
124
+ const chain = this._connectedChain;
125
+ return {
126
+ get activeAdapter() { return adapter; },
127
+ get connectedAddress() { return address; },
128
+ toSuiAddress() { return address; },
129
+ signTransaction(params) {
130
+ const enriched = { account: { address }, chain, ...params };
131
+ return adapter.signTransaction(enriched);
132
+ },
133
+ signAndExecuteTransaction(params) {
134
+ const enriched = { account: { address }, chain, ...params };
135
+ return adapter.signAndExecuteTransaction(enriched);
136
+ },
137
+ signAndExecuteTransactionBlock(params) {
138
+ const enriched = { account: { address }, chain, ...params };
139
+ return adapter.signAndExecuteTransactionBlock(enriched);
140
+ },
141
+ signPersonalMessage(params) {
142
+ const enriched = { account: { address }, chain, ...params };
143
+ return adapter.signPersonalMessage(enriched);
144
+ },
145
+ };
146
+ }
147
+
121
148
  /** @returns {*} The gRPC client instance, or null if not yet initialised. */
122
149
  get client() {
123
150
  return this._client;
@@ -345,7 +372,7 @@ export default class SuiInBrowser extends SuiCommonMethods {
345
372
 
346
373
  this._suiMaster = new SuiMaster({
347
374
  debug: this._debug,
348
- signer: this,
375
+ signer: this._activeAdapter ? this.createBoundSigner() : null,
349
376
  client: this._client,
350
377
  });
351
378
  }
@@ -229,8 +229,11 @@ export default class SuiInBrowserAdapter extends SuiCommonMethods {
229
229
  if (this._standardAdapter && this._standardAdapter.accounts && this._standardAdapter.accounts.length) {
230
230
  this._connectedAddress = this._standardAdapter.accounts[0].address;
231
231
  const accountChains = this._standardAdapter.accounts[0].chains;
232
- if (this._preferredChain && accountChains.includes(this._preferredChain)) {
233
- this._connectedChain = this._preferredChain;
232
+ const normalize = (c) => c ? c.replace(/^sui:/, '') : c;
233
+ const preferredNorm = normalize(this._preferredChain);
234
+ const match = this._preferredChain && accountChains.find(c => normalize(c) === preferredNorm);
235
+ if (match) {
236
+ this._connectedChain = match;
234
237
  } else {
235
238
  this._connectedChain = accountChains[0];
236
239
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suidouble",
3
- "version": "2.17.0-1",
3
+ "version": "2.17.0-3",
4
4
  "description": "JavaScript library for Sui Move smart contracts. Publish, upgrade, and test packages; call contract methods; query objects and events — same code works on Node.js and in the browser.",
5
5
  "main": "index.js",
6
6
  "types": "types/index.d.ts",
@@ -94,6 +94,15 @@ export default class SuiInBrowser extends SuiCommonMethods {
94
94
  * @returns {Promise<*>}
95
95
  */
96
96
  signPersonalMessage(params: any): Promise<any>;
97
+ createBoundSigner(): {
98
+ readonly activeAdapter: SuiInBrowserAdapter;
99
+ readonly connectedAddress: string;
100
+ toSuiAddress(): string;
101
+ signTransaction(params: any): Promise<import("@mysten/sui/cryptography").SignatureWithBytes>;
102
+ signAndExecuteTransaction(params: any): Promise<any>;
103
+ signAndExecuteTransactionBlock(params: any): Promise<any>;
104
+ signPersonalMessage(params: any): Promise<any>;
105
+ };
97
106
  /** @returns {*} The gRPC client instance, or null if not yet initialised. */
98
107
  get client(): any;
99
108
  toSuiAddress(): string;