@txnlab/use-wallet 3.0.0-beta.1 → 3.0.0-beta.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.
- package/dist/index.cjs +84 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -25
- package/dist/index.d.ts +25 -25
- package/dist/index.js +84 -64
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
package/dist/index.cjs
CHANGED
|
@@ -125,17 +125,17 @@ var BaseWallet = class {
|
|
|
125
125
|
this.metadata = { ...ctor.defaultMetadata, ...metadata };
|
|
126
126
|
}
|
|
127
127
|
static defaultMetadata = { name: "Base Wallet", icon: "" };
|
|
128
|
-
setActive() {
|
|
128
|
+
setActive = () => {
|
|
129
129
|
console.info(`[Wallet] Set active wallet: ${this.id}`);
|
|
130
130
|
setActiveWallet(this.store, { walletId: this.id });
|
|
131
|
-
}
|
|
132
|
-
setActiveAccount(account) {
|
|
131
|
+
};
|
|
132
|
+
setActiveAccount = (account) => {
|
|
133
133
|
console.info(`[Wallet] Set active account: ${account}`);
|
|
134
134
|
setActiveAccount(this.store, {
|
|
135
135
|
walletId: this.id,
|
|
136
136
|
address: account
|
|
137
137
|
});
|
|
138
|
-
}
|
|
138
|
+
};
|
|
139
139
|
// ---------- Derived Properties ------------------------------------ //
|
|
140
140
|
get name() {
|
|
141
141
|
return this.id.toUpperCase();
|
|
@@ -223,7 +223,7 @@ var ExodusWallet = class extends BaseWallet {
|
|
|
223
223
|
this.client = client;
|
|
224
224
|
return client;
|
|
225
225
|
}
|
|
226
|
-
async
|
|
226
|
+
connect = async () => {
|
|
227
227
|
console.info("[ExodusWallet] Connecting...");
|
|
228
228
|
try {
|
|
229
229
|
const client = this.client || await this.initializeClient();
|
|
@@ -252,12 +252,12 @@ var ExodusWallet = class extends BaseWallet {
|
|
|
252
252
|
}
|
|
253
253
|
return [];
|
|
254
254
|
}
|
|
255
|
-
}
|
|
256
|
-
async
|
|
255
|
+
};
|
|
256
|
+
disconnect = async () => {
|
|
257
257
|
console.info("[ExodusWallet] Disconnecting...");
|
|
258
258
|
this.onDisconnect();
|
|
259
|
-
}
|
|
260
|
-
async
|
|
259
|
+
};
|
|
260
|
+
resumeSession = async () => {
|
|
261
261
|
try {
|
|
262
262
|
const state = this.store.state;
|
|
263
263
|
const walletState = state.wallets[this.id];
|
|
@@ -273,7 +273,7 @@ var ExodusWallet = class extends BaseWallet {
|
|
|
273
273
|
console.error(`[ExodusWallet] Error resuming session: ${error.message}`);
|
|
274
274
|
this.onDisconnect();
|
|
275
275
|
}
|
|
276
|
-
}
|
|
276
|
+
};
|
|
277
277
|
signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
|
|
278
278
|
if (!this.client) {
|
|
279
279
|
throw new Error("[ExodusWallet] Client not initialized!");
|
|
@@ -289,7 +289,7 @@ var ExodusWallet = class extends BaseWallet {
|
|
|
289
289
|
const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
|
|
290
290
|
const txnBuffer = msgpackTxnGroup[idx];
|
|
291
291
|
const txn = isSigned ? import_algosdk.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk.default.decodeUnsignedTransaction(txnBuffer);
|
|
292
|
-
const txnBase64 =
|
|
292
|
+
const txnBase64 = byteArrayToBase64(txn.toByte());
|
|
293
293
|
if (shouldSign) {
|
|
294
294
|
txnsToSign.push({ txn: txnBase64 });
|
|
295
295
|
signedIndexes.push(idx);
|
|
@@ -299,7 +299,7 @@ var ExodusWallet = class extends BaseWallet {
|
|
|
299
299
|
});
|
|
300
300
|
const signTxnsResult = await this.client.signTxns(txnsToSign);
|
|
301
301
|
const signedTxnsBase64 = signTxnsResult.filter(Boolean);
|
|
302
|
-
const signedTxns = signedTxnsBase64.map((txn) =>
|
|
302
|
+
const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
|
|
303
303
|
const txnGroupSigned = mergeSignedTxnsWithGroup(
|
|
304
304
|
signedTxns,
|
|
305
305
|
msgpackTxnGroup,
|
|
@@ -313,7 +313,7 @@ var ExodusWallet = class extends BaseWallet {
|
|
|
313
313
|
throw new Error("[ExodusWallet] Client not initialized!");
|
|
314
314
|
}
|
|
315
315
|
const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
|
|
316
|
-
const txnBase64 =
|
|
316
|
+
const txnBase64 = byteArrayToBase64(txn.toByte());
|
|
317
317
|
if (indexesToSign.includes(idx)) {
|
|
318
318
|
acc.push({ txn: txnBase64 });
|
|
319
319
|
} else {
|
|
@@ -323,7 +323,7 @@ var ExodusWallet = class extends BaseWallet {
|
|
|
323
323
|
}, []);
|
|
324
324
|
const signTxnsResult = await this.client.signTxns(txnsToSign);
|
|
325
325
|
const signedTxnsBase64 = signTxnsResult.filter(Boolean);
|
|
326
|
-
const signedTxns = signedTxnsBase64.map((txn) =>
|
|
326
|
+
const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
|
|
327
327
|
return signedTxns;
|
|
328
328
|
};
|
|
329
329
|
};
|
|
@@ -530,7 +530,7 @@ var KibisisWallet = class _KibisisWallet extends BaseWallet {
|
|
|
530
530
|
};
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
|
-
async
|
|
533
|
+
connect = async () => {
|
|
534
534
|
console.info("[KibisisWallet] Connecting...");
|
|
535
535
|
try {
|
|
536
536
|
await this.getSupportedMethods();
|
|
@@ -552,14 +552,14 @@ var KibisisWallet = class _KibisisWallet extends BaseWallet {
|
|
|
552
552
|
console.error(`[KibisisWallet] Error connecting: ${error.message}`);
|
|
553
553
|
return [];
|
|
554
554
|
}
|
|
555
|
-
}
|
|
556
|
-
async
|
|
555
|
+
};
|
|
556
|
+
disconnect = async () => {
|
|
557
557
|
console.info("[KibisisWallet] Disconnecting...");
|
|
558
558
|
this.onDisconnect();
|
|
559
|
-
}
|
|
560
|
-
resumeSession() {
|
|
559
|
+
};
|
|
560
|
+
resumeSession = () => {
|
|
561
561
|
return Promise.resolve();
|
|
562
|
-
}
|
|
562
|
+
};
|
|
563
563
|
signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
|
|
564
564
|
try {
|
|
565
565
|
await this.getSupportedMethods();
|
|
@@ -574,7 +574,7 @@ var KibisisWallet = class _KibisisWallet extends BaseWallet {
|
|
|
574
574
|
const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
|
|
575
575
|
const txnBuffer = msgpackTxnGroup[idx];
|
|
576
576
|
const txn = isSigned ? import_algosdk2.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk2.default.decodeUnsignedTransaction(txnBuffer);
|
|
577
|
-
const txnBase64 =
|
|
577
|
+
const txnBase64 = byteArrayToBase64(txn.toByte());
|
|
578
578
|
if (shouldSign) {
|
|
579
579
|
txnsToSign.push({ txn: txnBase64 });
|
|
580
580
|
signedIndexes.push(idx);
|
|
@@ -584,7 +584,7 @@ var KibisisWallet = class _KibisisWallet extends BaseWallet {
|
|
|
584
584
|
});
|
|
585
585
|
const signTxnsResult = await this.signTxns(txnsToSign);
|
|
586
586
|
const signedTxnsBase64 = signTxnsResult.filter(Boolean);
|
|
587
|
-
const signedTxns = signedTxnsBase64.map((txn) =>
|
|
587
|
+
const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
|
|
588
588
|
const txnGroupSigned = mergeSignedTxnsWithGroup(
|
|
589
589
|
signedTxns,
|
|
590
590
|
msgpackTxnGroup,
|
|
@@ -602,7 +602,7 @@ var KibisisWallet = class _KibisisWallet extends BaseWallet {
|
|
|
602
602
|
transactionSigner = async (txnGroup, indexesToSign) => {
|
|
603
603
|
try {
|
|
604
604
|
const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
|
|
605
|
-
const txnBase64 =
|
|
605
|
+
const txnBase64 = byteArrayToBase64(txn.toByte());
|
|
606
606
|
if (indexesToSign.includes(idx)) {
|
|
607
607
|
acc.push({ txn: txnBase64 });
|
|
608
608
|
} else {
|
|
@@ -612,7 +612,7 @@ var KibisisWallet = class _KibisisWallet extends BaseWallet {
|
|
|
612
612
|
}, []);
|
|
613
613
|
const signTxnsResult = await this.signTxns(txnsToSign);
|
|
614
614
|
const signedTxnsBase64 = signTxnsResult.filter(Boolean);
|
|
615
|
-
const signedTxns = signedTxnsBase64.map((txn) =>
|
|
615
|
+
const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
|
|
616
616
|
return signedTxns;
|
|
617
617
|
} catch (error) {
|
|
618
618
|
console.error(
|
|
@@ -660,7 +660,7 @@ var KmdWallet = class extends BaseWallet {
|
|
|
660
660
|
this.client = client;
|
|
661
661
|
return client;
|
|
662
662
|
}
|
|
663
|
-
async
|
|
663
|
+
connect = async () => {
|
|
664
664
|
console.info("[KmdWallet] Connecting...");
|
|
665
665
|
try {
|
|
666
666
|
if (!this.client) {
|
|
@@ -690,11 +690,11 @@ var KmdWallet = class extends BaseWallet {
|
|
|
690
690
|
console.error("[KmdWallet] Error connecting:", error);
|
|
691
691
|
return [];
|
|
692
692
|
}
|
|
693
|
-
}
|
|
694
|
-
async
|
|
693
|
+
};
|
|
694
|
+
disconnect = async () => {
|
|
695
695
|
console.info("[KmdWallet] Disconnecting...");
|
|
696
696
|
this.onDisconnect();
|
|
697
|
-
}
|
|
697
|
+
};
|
|
698
698
|
resumeSession = async () => {
|
|
699
699
|
try {
|
|
700
700
|
const state = this.store.state;
|
|
@@ -854,7 +854,7 @@ var LuteWallet = class extends BaseWallet {
|
|
|
854
854
|
const genesisId = `${genesis.network}-${genesis.id}`;
|
|
855
855
|
return genesisId;
|
|
856
856
|
}
|
|
857
|
-
async
|
|
857
|
+
connect = async () => {
|
|
858
858
|
console.info("[LuteWallet] Connecting...");
|
|
859
859
|
try {
|
|
860
860
|
const client = this.client || await this.initializeClient();
|
|
@@ -880,12 +880,12 @@ var LuteWallet = class extends BaseWallet {
|
|
|
880
880
|
console.error(`[LuteWallet] Error connecting: ${error.message}`);
|
|
881
881
|
return [];
|
|
882
882
|
}
|
|
883
|
-
}
|
|
884
|
-
async
|
|
883
|
+
};
|
|
884
|
+
disconnect = async () => {
|
|
885
885
|
console.info("[LuteWallet] Disconnecting...");
|
|
886
886
|
this.onDisconnect();
|
|
887
|
-
}
|
|
888
|
-
async
|
|
887
|
+
};
|
|
888
|
+
resumeSession = async () => {
|
|
889
889
|
try {
|
|
890
890
|
const state = this.store.state;
|
|
891
891
|
const walletState = state.wallets[this.id];
|
|
@@ -898,7 +898,7 @@ var LuteWallet = class extends BaseWallet {
|
|
|
898
898
|
console.error(`[LuteWallet] Error resuming session: ${error.message}`);
|
|
899
899
|
this.onDisconnect();
|
|
900
900
|
}
|
|
901
|
-
}
|
|
901
|
+
};
|
|
902
902
|
signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
|
|
903
903
|
try {
|
|
904
904
|
if (!this.client) {
|
|
@@ -915,7 +915,7 @@ var LuteWallet = class extends BaseWallet {
|
|
|
915
915
|
const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
|
|
916
916
|
const txnBuffer = msgpackTxnGroup[idx];
|
|
917
917
|
const txn = isSigned ? import_algosdk4.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk4.default.decodeUnsignedTransaction(txnBuffer);
|
|
918
|
-
const txnBase64 =
|
|
918
|
+
const txnBase64 = byteArrayToBase64(txn.toByte());
|
|
919
919
|
if (shouldSign) {
|
|
920
920
|
txnsToSign.push({ txn: txnBase64 });
|
|
921
921
|
signedIndexes.push(idx);
|
|
@@ -945,7 +945,7 @@ var LuteWallet = class extends BaseWallet {
|
|
|
945
945
|
throw new Error("[LuteWallet] Client not initialized!");
|
|
946
946
|
}
|
|
947
947
|
const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
|
|
948
|
-
const txnBase64 =
|
|
948
|
+
const txnBase64 = byteArrayToBase64(txn.toByte());
|
|
949
949
|
if (indexesToSign.includes(idx)) {
|
|
950
950
|
acc.push({ txn: txnBase64 });
|
|
951
951
|
} else {
|
|
@@ -999,7 +999,7 @@ var MnemonicWallet = class extends BaseWallet {
|
|
|
999
999
|
this.account = account;
|
|
1000
1000
|
return account;
|
|
1001
1001
|
}
|
|
1002
|
-
async
|
|
1002
|
+
connect = async () => {
|
|
1003
1003
|
console.info("[MnemonicWallet] Connecting...");
|
|
1004
1004
|
try {
|
|
1005
1005
|
const account = this.initializeAccount();
|
|
@@ -1019,8 +1019,8 @@ var MnemonicWallet = class extends BaseWallet {
|
|
|
1019
1019
|
console.error("[MnemonicWallet] Error connecting:", error);
|
|
1020
1020
|
throw error;
|
|
1021
1021
|
}
|
|
1022
|
-
}
|
|
1023
|
-
async
|
|
1022
|
+
};
|
|
1023
|
+
disconnect = async () => {
|
|
1024
1024
|
console.info("[MnemonicWallet] Disconnecting...");
|
|
1025
1025
|
try {
|
|
1026
1026
|
this.account = null;
|
|
@@ -1028,8 +1028,8 @@ var MnemonicWallet = class extends BaseWallet {
|
|
|
1028
1028
|
} catch (error) {
|
|
1029
1029
|
console.error(error);
|
|
1030
1030
|
}
|
|
1031
|
-
}
|
|
1032
|
-
async
|
|
1031
|
+
};
|
|
1032
|
+
resumeSession = async () => {
|
|
1033
1033
|
const state = this.store.state;
|
|
1034
1034
|
const walletState = state.wallets[this.id];
|
|
1035
1035
|
if (walletState) {
|
|
@@ -1040,7 +1040,7 @@ var MnemonicWallet = class extends BaseWallet {
|
|
|
1040
1040
|
console.error(error);
|
|
1041
1041
|
}
|
|
1042
1042
|
}
|
|
1043
|
-
}
|
|
1043
|
+
};
|
|
1044
1044
|
signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
|
|
1045
1045
|
if (!this.account) {
|
|
1046
1046
|
throw new Error("[MnemonicWallet] Client not initialized!");
|
|
@@ -1109,7 +1109,7 @@ var PeraWallet = class extends BaseWallet {
|
|
|
1109
1109
|
this.client = client;
|
|
1110
1110
|
return client;
|
|
1111
1111
|
}
|
|
1112
|
-
async
|
|
1112
|
+
connect = async () => {
|
|
1113
1113
|
console.info("[PeraWallet] Connecting...");
|
|
1114
1114
|
try {
|
|
1115
1115
|
const client = this.client || await this.initializeClient();
|
|
@@ -1138,8 +1138,8 @@ var PeraWallet = class extends BaseWallet {
|
|
|
1138
1138
|
}
|
|
1139
1139
|
return [];
|
|
1140
1140
|
}
|
|
1141
|
-
}
|
|
1142
|
-
async
|
|
1141
|
+
};
|
|
1142
|
+
disconnect = async () => {
|
|
1143
1143
|
console.info("[PeraWallet] Disconnecting...");
|
|
1144
1144
|
try {
|
|
1145
1145
|
await this.client?.disconnect();
|
|
@@ -1147,8 +1147,8 @@ var PeraWallet = class extends BaseWallet {
|
|
|
1147
1147
|
} catch (error) {
|
|
1148
1148
|
console.error(error);
|
|
1149
1149
|
}
|
|
1150
|
-
}
|
|
1151
|
-
async
|
|
1150
|
+
};
|
|
1151
|
+
resumeSession = async () => {
|
|
1152
1152
|
try {
|
|
1153
1153
|
const state = this.store.state;
|
|
1154
1154
|
const walletState = state.wallets[this.id];
|
|
@@ -1177,7 +1177,7 @@ var PeraWallet = class extends BaseWallet {
|
|
|
1177
1177
|
console.error(`[PeraWallet] Error resuming session: ${error.message}`);
|
|
1178
1178
|
this.onDisconnect();
|
|
1179
1179
|
}
|
|
1180
|
-
}
|
|
1180
|
+
};
|
|
1181
1181
|
signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
|
|
1182
1182
|
if (!this.client) {
|
|
1183
1183
|
throw new Error("[PeraWallet] Client not initialized!");
|
|
@@ -1334,7 +1334,7 @@ var WalletConnect = class extends BaseWallet {
|
|
|
1334
1334
|
this.session = session;
|
|
1335
1335
|
return walletAccounts;
|
|
1336
1336
|
}
|
|
1337
|
-
async
|
|
1337
|
+
connect = async () => {
|
|
1338
1338
|
console.info("[WalletConnect] Connecting...");
|
|
1339
1339
|
try {
|
|
1340
1340
|
const client = this.client || await this.initializeClient();
|
|
@@ -1360,8 +1360,8 @@ var WalletConnect = class extends BaseWallet {
|
|
|
1360
1360
|
} finally {
|
|
1361
1361
|
this.modal?.closeModal();
|
|
1362
1362
|
}
|
|
1363
|
-
}
|
|
1364
|
-
async
|
|
1363
|
+
};
|
|
1364
|
+
disconnect = async () => {
|
|
1365
1365
|
console.info("[WalletConnect] Disconnecting...");
|
|
1366
1366
|
try {
|
|
1367
1367
|
if (this.client && this.session) {
|
|
@@ -1374,8 +1374,8 @@ var WalletConnect = class extends BaseWallet {
|
|
|
1374
1374
|
} catch (error) {
|
|
1375
1375
|
console.error(error);
|
|
1376
1376
|
}
|
|
1377
|
-
}
|
|
1378
|
-
async
|
|
1377
|
+
};
|
|
1378
|
+
resumeSession = async () => {
|
|
1379
1379
|
try {
|
|
1380
1380
|
const state = this.store.state;
|
|
1381
1381
|
const walletState = state.wallets[this.id];
|
|
@@ -1393,7 +1393,7 @@ var WalletConnect = class extends BaseWallet {
|
|
|
1393
1393
|
console.error(`[WalletConnect] Error resuming session: ${error.message}`);
|
|
1394
1394
|
this.onDisconnect();
|
|
1395
1395
|
}
|
|
1396
|
-
}
|
|
1396
|
+
};
|
|
1397
1397
|
signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
|
|
1398
1398
|
if (!this.client) {
|
|
1399
1399
|
throw new Error("[WalletConnect] Client not initialized!");
|
|
@@ -1415,7 +1415,7 @@ var WalletConnect = class extends BaseWallet {
|
|
|
1415
1415
|
const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
|
|
1416
1416
|
const txnBuffer = msgpackTxnGroup[idx];
|
|
1417
1417
|
const txn = isSigned ? import_algosdk7.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk7.default.decodeUnsignedTransaction(txnBuffer);
|
|
1418
|
-
const txnBase64 =
|
|
1418
|
+
const txnBase64 = byteArrayToBase64(txn.toByte());
|
|
1419
1419
|
if (shouldSign) {
|
|
1420
1420
|
txnsToSign.push({ txn: txnBase64 });
|
|
1421
1421
|
signedIndexes.push(idx);
|
|
@@ -1430,7 +1430,7 @@ var WalletConnect = class extends BaseWallet {
|
|
|
1430
1430
|
request
|
|
1431
1431
|
});
|
|
1432
1432
|
const signedTxnsBase64 = signTxnsResult.filter(Boolean);
|
|
1433
|
-
const signedTxns = signedTxnsBase64.map((txn) =>
|
|
1433
|
+
const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
|
|
1434
1434
|
const txnGroupSigned = mergeSignedTxnsWithGroup(
|
|
1435
1435
|
signedTxns,
|
|
1436
1436
|
msgpackTxnGroup,
|
|
@@ -1450,7 +1450,7 @@ var WalletConnect = class extends BaseWallet {
|
|
|
1450
1450
|
throw new Error(`[WalletConnect] Invalid network: ${this.activeNetwork}`);
|
|
1451
1451
|
}
|
|
1452
1452
|
const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
|
|
1453
|
-
const txnBase64 =
|
|
1453
|
+
const txnBase64 = byteArrayToBase64(txn.toByte());
|
|
1454
1454
|
if (indexesToSign.includes(idx)) {
|
|
1455
1455
|
acc.push({ txn: txnBase64 });
|
|
1456
1456
|
} else {
|
|
@@ -1465,7 +1465,7 @@ var WalletConnect = class extends BaseWallet {
|
|
|
1465
1465
|
request
|
|
1466
1466
|
});
|
|
1467
1467
|
const signedTxnsBase64 = signTxnsResult.filter(Boolean);
|
|
1468
|
-
const signedTxns = signedTxnsBase64.map((txn) =>
|
|
1468
|
+
const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
|
|
1469
1469
|
return signedTxns;
|
|
1470
1470
|
};
|
|
1471
1471
|
};
|
|
@@ -1496,6 +1496,26 @@ function compareAccounts(accounts, compareTo) {
|
|
|
1496
1496
|
}
|
|
1497
1497
|
return true;
|
|
1498
1498
|
}
|
|
1499
|
+
function base64ToByteArray(blob) {
|
|
1500
|
+
return stringToByteArray(atob(blob));
|
|
1501
|
+
}
|
|
1502
|
+
function byteArrayToBase64(array) {
|
|
1503
|
+
return btoa(byteArrayToString(array));
|
|
1504
|
+
}
|
|
1505
|
+
function stringToByteArray(str) {
|
|
1506
|
+
const array = new Uint8Array(str.length);
|
|
1507
|
+
for (let i = 0; i < str.length; i++) {
|
|
1508
|
+
array[i] = str.charCodeAt(i);
|
|
1509
|
+
}
|
|
1510
|
+
return array;
|
|
1511
|
+
}
|
|
1512
|
+
function byteArrayToString(array) {
|
|
1513
|
+
let result = "";
|
|
1514
|
+
for (let i = 0; i < array.length; i++) {
|
|
1515
|
+
result += String.fromCharCode(array[i]);
|
|
1516
|
+
}
|
|
1517
|
+
return result;
|
|
1518
|
+
}
|
|
1499
1519
|
function isTransaction(item) {
|
|
1500
1520
|
if (Array.isArray(item)) {
|
|
1501
1521
|
return item.every(
|
|
@@ -1610,7 +1630,7 @@ var DeflyWallet = class extends BaseWallet {
|
|
|
1610
1630
|
this.client = client;
|
|
1611
1631
|
return client;
|
|
1612
1632
|
}
|
|
1613
|
-
async
|
|
1633
|
+
connect = async () => {
|
|
1614
1634
|
console.info("[DeflyWallet] Connecting...");
|
|
1615
1635
|
try {
|
|
1616
1636
|
const client = this.client || await this.initializeClient();
|
|
@@ -1639,8 +1659,8 @@ var DeflyWallet = class extends BaseWallet {
|
|
|
1639
1659
|
}
|
|
1640
1660
|
return [];
|
|
1641
1661
|
}
|
|
1642
|
-
}
|
|
1643
|
-
async
|
|
1662
|
+
};
|
|
1663
|
+
disconnect = async () => {
|
|
1644
1664
|
console.info("[DeflyWallet] Disconnecting...");
|
|
1645
1665
|
try {
|
|
1646
1666
|
await this.client?.disconnect();
|
|
@@ -1648,8 +1668,8 @@ var DeflyWallet = class extends BaseWallet {
|
|
|
1648
1668
|
} catch (error) {
|
|
1649
1669
|
console.error(error);
|
|
1650
1670
|
}
|
|
1651
|
-
}
|
|
1652
|
-
async
|
|
1671
|
+
};
|
|
1672
|
+
resumeSession = async () => {
|
|
1653
1673
|
try {
|
|
1654
1674
|
const state = this.store.state;
|
|
1655
1675
|
const walletState = state.wallets[this.id];
|
|
@@ -1678,7 +1698,7 @@ var DeflyWallet = class extends BaseWallet {
|
|
|
1678
1698
|
console.error(`[DeflyWallet] Error resuming session: ${error.message}`);
|
|
1679
1699
|
this.onDisconnect();
|
|
1680
1700
|
}
|
|
1681
|
-
}
|
|
1701
|
+
};
|
|
1682
1702
|
signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
|
|
1683
1703
|
if (!this.client) {
|
|
1684
1704
|
throw new Error("[DeflyWallet] Client not initialized!");
|