@txnlab/use-wallet 3.7.0 → 3.7.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/dist/index.cjs CHANGED
@@ -3247,7 +3247,7 @@ __export(src_exports, {
3247
3247
  CustomWallet: () => CustomWallet,
3248
3248
  DeflyWallet: () => DeflyWallet,
3249
3249
  ExodusWallet: () => ExodusWallet,
3250
- ICON: () => ICON5,
3250
+ ICON: () => ICON6,
3251
3251
  KIBISIS_AVM_WEB_PROVIDER_ID: () => KIBISIS_AVM_WEB_PROVIDER_ID,
3252
3252
  KibisisWallet: () => KibisisWallet,
3253
3253
  KmdWallet: () => KmdWallet,
@@ -3418,7 +3418,159 @@ var StorageAdapter = class {
3418
3418
  };
3419
3419
 
3420
3420
  // src/store.ts
3421
- var import_algosdk11 = __toESM(require("algosdk"), 1);
3421
+ var import_algosdk = __toESM(require("algosdk"), 1);
3422
+
3423
+ // src/wallets/types.ts
3424
+ var WalletId = /* @__PURE__ */ ((WalletId2) => {
3425
+ WalletId2["BIATEC"] = "biatec";
3426
+ WalletId2["DEFLY"] = "defly";
3427
+ WalletId2["CUSTOM"] = "custom";
3428
+ WalletId2["EXODUS"] = "exodus";
3429
+ WalletId2["KIBISIS"] = "kibisis";
3430
+ WalletId2["KMD"] = "kmd";
3431
+ WalletId2["LUTE"] = "lute";
3432
+ WalletId2["MAGIC"] = "magic";
3433
+ WalletId2["MNEMONIC"] = "mnemonic";
3434
+ WalletId2["PERA"] = "pera";
3435
+ WalletId2["PERA2"] = "pera-beta";
3436
+ WalletId2["WALLETCONNECT"] = "walletconnect";
3437
+ return WalletId2;
3438
+ })(WalletId || {});
3439
+ var SignTxnsError = class extends Error {
3440
+ code;
3441
+ data;
3442
+ constructor(message, code, data) {
3443
+ super(message);
3444
+ this.name = "SignTxnsError";
3445
+ this.code = code;
3446
+ this.data = data;
3447
+ }
3448
+ };
3449
+
3450
+ // src/store.ts
3451
+ var defaultState = {
3452
+ wallets: {},
3453
+ activeWallet: null,
3454
+ activeNetwork: "testnet" /* TESTNET */,
3455
+ algodClient: new import_algosdk.default.Algodv2("", "https://testnet-api.4160.nodely.dev/")
3456
+ };
3457
+ var LOCAL_STORAGE_KEY = "@txnlab/use-wallet:v3";
3458
+ function addWallet(store, { walletId, wallet }) {
3459
+ store.setState((state) => {
3460
+ const updatedWallets = {
3461
+ ...state.wallets,
3462
+ [walletId]: {
3463
+ accounts: wallet.accounts.map((account) => ({ ...account })),
3464
+ activeAccount: wallet.activeAccount ? { ...wallet.activeAccount } : null
3465
+ }
3466
+ };
3467
+ return {
3468
+ ...state,
3469
+ wallets: updatedWallets,
3470
+ activeWallet: walletId
3471
+ };
3472
+ });
3473
+ }
3474
+ function removeWallet(store, { walletId }) {
3475
+ store.setState((state) => {
3476
+ const updatedWallets = { ...state.wallets };
3477
+ delete updatedWallets[walletId];
3478
+ return {
3479
+ ...state,
3480
+ wallets: updatedWallets,
3481
+ activeWallet: state.activeWallet === walletId ? null : state.activeWallet
3482
+ };
3483
+ });
3484
+ }
3485
+ function setActiveWallet(store, { walletId }) {
3486
+ store.setState((state) => ({
3487
+ ...state,
3488
+ activeWallet: walletId
3489
+ }));
3490
+ }
3491
+ function setActiveAccount(store, { walletId, address }) {
3492
+ store.setState((state) => {
3493
+ const wallet = state.wallets[walletId];
3494
+ if (!wallet) {
3495
+ logger.warn(`Wallet with id "${walletId}" not found`);
3496
+ return state;
3497
+ }
3498
+ const newActiveAccount = wallet.accounts.find((a2) => a2.address === address);
3499
+ if (!newActiveAccount) {
3500
+ logger.warn(`Account with address ${address} not found in wallet "${walletId}"`);
3501
+ return state;
3502
+ }
3503
+ const updatedWallet = {
3504
+ ...wallet,
3505
+ accounts: wallet.accounts.map((account) => ({ ...account })),
3506
+ activeAccount: { ...newActiveAccount }
3507
+ };
3508
+ const updatedWallets = {
3509
+ ...state.wallets,
3510
+ [walletId]: updatedWallet
3511
+ };
3512
+ return {
3513
+ ...state,
3514
+ wallets: updatedWallets
3515
+ };
3516
+ });
3517
+ }
3518
+ function setAccounts(store, { walletId, accounts }) {
3519
+ store.setState((state) => {
3520
+ const wallet = state.wallets[walletId];
3521
+ if (!wallet) {
3522
+ logger.warn(`Wallet with id "${walletId}" not found`);
3523
+ return state;
3524
+ }
3525
+ const newAccounts = accounts.map((account) => ({ ...account }));
3526
+ const isActiveAccountConnected = newAccounts.some(
3527
+ (account) => account.address === wallet.activeAccount?.address
3528
+ );
3529
+ const newActiveAccount = isActiveAccountConnected ? { ...wallet.activeAccount } : newAccounts[0] || null;
3530
+ const updatedWallet = {
3531
+ ...wallet,
3532
+ accounts: newAccounts,
3533
+ activeAccount: newActiveAccount
3534
+ };
3535
+ const updatedWallets = {
3536
+ ...state.wallets,
3537
+ [walletId]: updatedWallet
3538
+ };
3539
+ return {
3540
+ ...state,
3541
+ wallets: updatedWallets
3542
+ };
3543
+ });
3544
+ }
3545
+ function setActiveNetwork(store, { networkId, algodClient }) {
3546
+ store.setState((state) => ({
3547
+ ...state,
3548
+ activeNetwork: networkId,
3549
+ algodClient
3550
+ }));
3551
+ }
3552
+ function isValidWalletId(walletId) {
3553
+ return Object.values(WalletId).includes(walletId);
3554
+ }
3555
+ function isValidWalletAccount(account) {
3556
+ return typeof account === "object" && account !== null && typeof account.name === "string" && typeof account.address === "string";
3557
+ }
3558
+ function isValidWalletState(wallet) {
3559
+ return typeof wallet === "object" && wallet !== null && Array.isArray(wallet.accounts) && wallet.accounts.every(isValidWalletAccount) && (wallet.activeAccount === null || isValidWalletAccount(wallet.activeAccount));
3560
+ }
3561
+ function isValidState(state) {
3562
+ if (!state || typeof state !== "object") return false;
3563
+ if (typeof state.wallets !== "object") return false;
3564
+ for (const [walletId, wallet] of Object.entries(state.wallets)) {
3565
+ if (!isValidWalletId(walletId) || !isValidWalletState(wallet)) return false;
3566
+ }
3567
+ if (state.activeWallet !== null && !isValidWalletId(state.activeWallet)) return false;
3568
+ if (!isValidNetworkId(state.activeNetwork)) return false;
3569
+ return true;
3570
+ }
3571
+
3572
+ // src/wallets/walletconnect.ts
3573
+ var import_algosdk2 = __toESM(require("algosdk"), 1);
3422
3574
 
3423
3575
  // src/wallets/base.ts
3424
3576
  var BaseWallet = class {
@@ -3523,35 +3675,7 @@ var BaseWallet = class {
3523
3675
  };
3524
3676
  };
3525
3677
 
3526
- // src/wallets/types.ts
3527
- var WalletId = /* @__PURE__ */ ((WalletId2) => {
3528
- WalletId2["BIATEC"] = "biatec";
3529
- WalletId2["DEFLY"] = "defly";
3530
- WalletId2["CUSTOM"] = "custom";
3531
- WalletId2["EXODUS"] = "exodus";
3532
- WalletId2["KIBISIS"] = "kibisis";
3533
- WalletId2["KMD"] = "kmd";
3534
- WalletId2["LUTE"] = "lute";
3535
- WalletId2["MAGIC"] = "magic";
3536
- WalletId2["MNEMONIC"] = "mnemonic";
3537
- WalletId2["PERA"] = "pera";
3538
- WalletId2["PERA2"] = "pera-beta";
3539
- WalletId2["WALLETCONNECT"] = "walletconnect";
3540
- return WalletId2;
3541
- })(WalletId || {});
3542
- var SignTxnsError = class extends Error {
3543
- code;
3544
- data;
3545
- constructor(message, code, data) {
3546
- super(message);
3547
- this.name = "SignTxnsError";
3548
- this.code = code;
3549
- this.data = data;
3550
- }
3551
- };
3552
-
3553
3678
  // src/wallets/walletconnect.ts
3554
- var import_algosdk = __toESM(require("algosdk"), 1);
3555
3679
  var SessionError = class extends Error {
3556
3680
  constructor(message) {
3557
3681
  super(message);
@@ -3877,7 +4001,7 @@ var WalletConnect = class extends BaseWallet {
3877
4001
  const txnsToSign = [];
3878
4002
  txnGroup.forEach((txn, index) => {
3879
4003
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
3880
- const signer = import_algosdk.default.encodeAddress(txn.from.publicKey);
4004
+ const signer = import_algosdk2.default.encodeAddress(txn.from.publicKey);
3881
4005
  const canSignTxn = this.addresses.includes(signer);
3882
4006
  const txnString = byteArrayToBase64(txn.toByte());
3883
4007
  if (isIndexMatch && canSignTxn) {
@@ -3891,11 +4015,11 @@ var WalletConnect = class extends BaseWallet {
3891
4015
  processEncodedTxns(txnGroup, indexesToSign) {
3892
4016
  const txnsToSign = [];
3893
4017
  txnGroup.forEach((txnBuffer, index) => {
3894
- const txnDecodeObj = import_algosdk.default.decodeObj(txnBuffer);
4018
+ const txnDecodeObj = import_algosdk2.default.decodeObj(txnBuffer);
3895
4019
  const isSigned = isSignedTxn(txnDecodeObj);
3896
- const txn = isSigned ? import_algosdk.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk.default.decodeUnsignedTransaction(txnBuffer);
4020
+ const txn = isSigned ? import_algosdk2.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk2.default.decodeUnsignedTransaction(txnBuffer);
3897
4021
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
3898
- const signer = import_algosdk.default.encodeAddress(txn.from.publicKey);
4022
+ const signer = import_algosdk2.default.encodeAddress(txn.from.publicKey);
3899
4023
  const canSignTxn = !isSigned && this.addresses.includes(signer);
3900
4024
  const txnString = byteArrayToBase64(txn.toByte());
3901
4025
  if (isIndexMatch && canSignTxn) {
@@ -3978,59 +4102,173 @@ var BiatecWallet = class extends WalletConnect {
3978
4102
  };
3979
4103
  };
3980
4104
 
3981
- // src/wallets/defly.ts
3982
- var import_algosdk2 = __toESM(require("algosdk"), 1);
4105
+ // src/wallets/custom.ts
3983
4106
  var ICON3 = `data:image/svg+xml;base64,${btoa(`
3984
- <svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
3985
- <rect width="1024" height="1024" />
3986
- <path fill="#FFFFFF" d="M779.9,684.4L512,230L244.1,684.4L512,529.5L779.9,684.4z" />
3987
- <path fill="#FFFFFF" d="M733.1,730L512,613.5L290.9,730L512,658L733.1,730z" />
4107
+ <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
4108
+ <rect width="24" height="24" fill="#525252" />
3988
4109
  </svg>
3989
4110
  `)}`;
3990
- var DeflyWallet = class extends BaseWallet {
3991
- client = null;
3992
- options;
4111
+ var CustomWallet = class extends BaseWallet {
4112
+ provider;
3993
4113
  store;
3994
4114
  constructor({
3995
4115
  id,
3996
4116
  store,
3997
4117
  subscribe,
3998
4118
  getAlgodClient,
3999
- options = {},
4119
+ options,
4000
4120
  metadata = {}
4001
4121
  }) {
4002
4122
  super({ id, metadata, getAlgodClient, store, subscribe });
4003
- this.options = options;
4123
+ if (!options?.provider) {
4124
+ this.logger.error("Missing required option: provider");
4125
+ throw new Error("Missing required option: provider");
4126
+ }
4127
+ this.provider = options.provider;
4004
4128
  this.store = store;
4005
4129
  }
4006
4130
  static defaultMetadata = {
4007
- name: "Defly",
4131
+ name: "Custom",
4008
4132
  icon: ICON3
4009
4133
  };
4010
- async initializeClient() {
4011
- this.logger.info("Initializing client...");
4012
- const module2 = await import("@blockshake/defly-connect");
4013
- const DeflyWalletConnect = module2.default ? module2.default.DeflyWalletConnect : module2.DeflyWalletConnect;
4014
- const client = new DeflyWalletConnect(this.options);
4015
- this.client = client;
4016
- this.logger.info("Client initialized");
4017
- return client;
4018
- }
4019
- connect = async () => {
4134
+ connect = async (args) => {
4020
4135
  this.logger.info("Connecting...");
4021
- const currentActiveWallet = this.store.state.activeWallet;
4022
- if (currentActiveWallet && currentActiveWallet !== this.id) {
4023
- this.manageWalletConnectSession("backup", currentActiveWallet);
4024
- }
4025
- const client = this.client || await this.initializeClient();
4026
- const accounts = await client.connect();
4027
- client.connector?.on("disconnect", this.onDisconnect);
4028
- if (accounts.length === 0) {
4029
- this.logger.error("No accounts found!");
4030
- throw new Error("No accounts found!");
4136
+ try {
4137
+ if (!this.provider.connect) {
4138
+ this.logger.error("Method not supported: connect");
4139
+ throw new Error("Method not supported: connect");
4140
+ }
4141
+ const walletAccounts = await this.provider.connect(args);
4142
+ if (walletAccounts.length === 0) {
4143
+ this.logger.error("No accounts found!");
4144
+ throw new Error("No accounts found!");
4145
+ }
4146
+ const activeAccount = walletAccounts[0];
4147
+ const walletState = {
4148
+ accounts: walletAccounts,
4149
+ activeAccount
4150
+ };
4151
+ addWallet(this.store, {
4152
+ walletId: this.id,
4153
+ wallet: walletState
4154
+ });
4155
+ this.logger.info("\u2705 Connected.", walletState);
4156
+ return walletAccounts;
4157
+ } catch (error) {
4158
+ this.logger.error("Error connecting:", error.message || error);
4159
+ throw error;
4031
4160
  }
4032
- const walletAccounts = accounts.map((address, idx) => ({
4033
- name: `${this.metadata.name} Account ${idx + 1}`,
4161
+ };
4162
+ disconnect = async () => {
4163
+ this.logger.info("Disconnecting...");
4164
+ this.onDisconnect();
4165
+ await this.provider.disconnect?.();
4166
+ };
4167
+ resumeSession = async () => {
4168
+ try {
4169
+ const state = this.store.state;
4170
+ const walletState = state.wallets[this.id];
4171
+ if (!walletState) {
4172
+ this.logger.info("No session to resume");
4173
+ return;
4174
+ }
4175
+ this.logger.info("Resuming session...");
4176
+ const result = await this.provider.resumeSession?.();
4177
+ if (Array.isArray(result)) {
4178
+ const walletAccounts = result;
4179
+ if (walletAccounts.length === 0) {
4180
+ this.logger.error("No accounts found!");
4181
+ throw new Error("No accounts found!");
4182
+ }
4183
+ const match = compareAccounts(walletAccounts, walletState.accounts);
4184
+ if (!match) {
4185
+ this.logger.warn("Session accounts mismatch, updating accounts", {
4186
+ prev: walletState.accounts,
4187
+ current: walletAccounts
4188
+ });
4189
+ setAccounts(this.store, {
4190
+ walletId: this.id,
4191
+ accounts: walletAccounts
4192
+ });
4193
+ }
4194
+ }
4195
+ this.logger.info("Session resumed.");
4196
+ } catch (error) {
4197
+ this.logger.error("Error resuming session:", error.message);
4198
+ throw error;
4199
+ }
4200
+ };
4201
+ signTransactions = async (txnGroup, indexesToSign) => {
4202
+ if (!this.provider.signTransactions) {
4203
+ this.logger.error("Method not supported: signTransactions");
4204
+ throw new Error("Method not supported: signTransactions");
4205
+ }
4206
+ this.logger.debug("Signing transactions...", { txnGroup, indexesToSign });
4207
+ return await this.provider.signTransactions(txnGroup, indexesToSign);
4208
+ };
4209
+ transactionSigner = async (txnGroup, indexesToSign) => {
4210
+ if (!this.provider.transactionSigner) {
4211
+ this.logger.error("Method not supported: transactionSigner");
4212
+ throw new Error("Method not supported: transactionSigner");
4213
+ }
4214
+ this.logger.debug("Transaction signer called...", { txnGroup, indexesToSign });
4215
+ return await this.provider.transactionSigner(txnGroup, indexesToSign);
4216
+ };
4217
+ };
4218
+
4219
+ // src/wallets/defly.ts
4220
+ var import_algosdk3 = __toESM(require("algosdk"), 1);
4221
+ var ICON4 = `data:image/svg+xml;base64,${btoa(`
4222
+ <svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
4223
+ <rect width="1024" height="1024" />
4224
+ <path fill="#FFFFFF" d="M779.9,684.4L512,230L244.1,684.4L512,529.5L779.9,684.4z" />
4225
+ <path fill="#FFFFFF" d="M733.1,730L512,613.5L290.9,730L512,658L733.1,730z" />
4226
+ </svg>
4227
+ `)}`;
4228
+ var DeflyWallet = class extends BaseWallet {
4229
+ client = null;
4230
+ options;
4231
+ store;
4232
+ constructor({
4233
+ id,
4234
+ store,
4235
+ subscribe,
4236
+ getAlgodClient,
4237
+ options = {},
4238
+ metadata = {}
4239
+ }) {
4240
+ super({ id, metadata, getAlgodClient, store, subscribe });
4241
+ this.options = options;
4242
+ this.store = store;
4243
+ }
4244
+ static defaultMetadata = {
4245
+ name: "Defly",
4246
+ icon: ICON4
4247
+ };
4248
+ async initializeClient() {
4249
+ this.logger.info("Initializing client...");
4250
+ const module2 = await import("@blockshake/defly-connect");
4251
+ const DeflyWalletConnect = module2.default ? module2.default.DeflyWalletConnect : module2.DeflyWalletConnect;
4252
+ const client = new DeflyWalletConnect(this.options);
4253
+ this.client = client;
4254
+ this.logger.info("Client initialized");
4255
+ return client;
4256
+ }
4257
+ connect = async () => {
4258
+ this.logger.info("Connecting...");
4259
+ const currentActiveWallet = this.store.state.activeWallet;
4260
+ if (currentActiveWallet && currentActiveWallet !== this.id) {
4261
+ this.manageWalletConnectSession("backup", currentActiveWallet);
4262
+ }
4263
+ const client = this.client || await this.initializeClient();
4264
+ const accounts = await client.connect();
4265
+ client.connector?.on("disconnect", this.onDisconnect);
4266
+ if (accounts.length === 0) {
4267
+ this.logger.error("No accounts found!");
4268
+ throw new Error("No accounts found!");
4269
+ }
4270
+ const walletAccounts = accounts.map((address, idx) => ({
4271
+ name: `${this.metadata.name} Account ${idx + 1}`,
4034
4272
  address
4035
4273
  }));
4036
4274
  const activeAccount = walletAccounts[0];
@@ -4111,7 +4349,7 @@ var DeflyWallet = class extends BaseWallet {
4111
4349
  const txnsToSign = [];
4112
4350
  txnGroup.forEach((txn, index) => {
4113
4351
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
4114
- const signer = import_algosdk2.default.encodeAddress(txn.from.publicKey);
4352
+ const signer = import_algosdk3.default.encodeAddress(txn.from.publicKey);
4115
4353
  const canSignTxn = this.addresses.includes(signer);
4116
4354
  if (isIndexMatch && canSignTxn) {
4117
4355
  txnsToSign.push({ txn });
@@ -4124,11 +4362,11 @@ var DeflyWallet = class extends BaseWallet {
4124
4362
  processEncodedTxns(txnGroup, indexesToSign) {
4125
4363
  const txnsToSign = [];
4126
4364
  txnGroup.forEach((txnBuffer, index) => {
4127
- const txnDecodeObj = import_algosdk2.default.decodeObj(txnBuffer);
4365
+ const txnDecodeObj = import_algosdk3.default.decodeObj(txnBuffer);
4128
4366
  const isSigned = isSignedTxn(txnDecodeObj);
4129
- const txn = isSigned ? import_algosdk2.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk2.default.decodeUnsignedTransaction(txnBuffer);
4367
+ const txn = isSigned ? import_algosdk3.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk3.default.decodeUnsignedTransaction(txnBuffer);
4130
4368
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
4131
- const signer = import_algosdk2.default.encodeAddress(txn.from.publicKey);
4369
+ const signer = import_algosdk3.default.encodeAddress(txn.from.publicKey);
4132
4370
  const canSignTxn = !isSigned && this.addresses.includes(signer);
4133
4371
  if (isIndexMatch && canSignTxn) {
4134
4372
  txnsToSign.push({ txn });
@@ -4174,8 +4412,8 @@ var DeflyWallet = class extends BaseWallet {
4174
4412
  };
4175
4413
 
4176
4414
  // src/wallets/exodus.ts
4177
- var import_algosdk3 = __toESM(require("algosdk"), 1);
4178
- var ICON4 = `data:image/svg+xml;base64,${btoa(`
4415
+ var import_algosdk4 = __toESM(require("algosdk"), 1);
4416
+ var ICON5 = `data:image/svg+xml;base64,${btoa(`
4179
4417
  <svg viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg">
4180
4418
  <linearGradient id="grad1" gradientUnits="userSpaceOnUse" x1="246.603" y1="9.2212" x2="174.158" y2="308.5426" gradientTransform="matrix(1 0 0 -1 0 302)">
4181
4419
  <stop offset="0" stop-color="#0B46F9" />
@@ -4219,7 +4457,7 @@ var ExodusWallet = class extends BaseWallet {
4219
4457
  }
4220
4458
  static defaultMetadata = {
4221
4459
  name: "Exodus",
4222
- icon: ICON4
4460
+ icon: ICON5
4223
4461
  };
4224
4462
  async initializeClient() {
4225
4463
  this.logger.info("Initializing client...");
@@ -4286,7 +4524,7 @@ var ExodusWallet = class extends BaseWallet {
4286
4524
  const txnsToSign = [];
4287
4525
  txnGroup.forEach((txn, index) => {
4288
4526
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
4289
- const signer = import_algosdk3.default.encodeAddress(txn.from.publicKey);
4527
+ const signer = import_algosdk4.default.encodeAddress(txn.from.publicKey);
4290
4528
  const canSignTxn = this.addresses.includes(signer);
4291
4529
  const txnString = byteArrayToBase64(txn.toByte());
4292
4530
  if (isIndexMatch && canSignTxn) {
@@ -4300,11 +4538,11 @@ var ExodusWallet = class extends BaseWallet {
4300
4538
  processEncodedTxns(txnGroup, indexesToSign) {
4301
4539
  const txnsToSign = [];
4302
4540
  txnGroup.forEach((txnBuffer, index) => {
4303
- const txnDecodeObj = import_algosdk3.default.decodeObj(txnBuffer);
4541
+ const txnDecodeObj = import_algosdk4.default.decodeObj(txnBuffer);
4304
4542
  const isSigned = isSignedTxn(txnDecodeObj);
4305
- const txn = isSigned ? import_algosdk3.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk3.default.decodeUnsignedTransaction(txnBuffer);
4543
+ const txn = isSigned ? import_algosdk4.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk4.default.decodeUnsignedTransaction(txnBuffer);
4306
4544
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
4307
- const signer = import_algosdk3.default.encodeAddress(txn.from.publicKey);
4545
+ const signer = import_algosdk4.default.encodeAddress(txn.from.publicKey);
4308
4546
  const canSignTxn = !isSigned && this.addresses.includes(signer);
4309
4547
  const txnString = byteArrayToBase64(txn.toByte());
4310
4548
  if (isIndexMatch && canSignTxn) {
@@ -4346,12 +4584,12 @@ var ExodusWallet = class extends BaseWallet {
4346
4584
  };
4347
4585
 
4348
4586
  // src/wallets/kibisis.ts
4349
- var import_algosdk4 = __toESM(require("algosdk"), 1);
4587
+ var import_algosdk5 = __toESM(require("algosdk"), 1);
4350
4588
  function isAVMWebProviderSDKError(error) {
4351
4589
  return typeof error === "object" && "code" in error && "message" in error;
4352
4590
  }
4353
4591
  var KIBISIS_AVM_WEB_PROVIDER_ID = "f6d1c86b-4493-42fb-b88d-a62407b4cdf6";
4354
- var ICON5 = `data:image/svg+xml;base64,${btoa(`
4592
+ var ICON6 = `data:image/svg+xml;base64,${btoa(`
4355
4593
  <svg viewBox="0 0 480 480" xmlns="http://www.w3.org/2000/svg">
4356
4594
  <rect fill="#801C96" width="480" height="480" />
4357
4595
  <path fill="#FFFFFF" d="M393.5,223.2c0-7.3-0.6-14.6-1.6-21.6c-0.9-6.5-2.3-12.8-4-18.9c-18-64.9-77.4-112.5-148-112.5c-70.6,0-130,47.6-148,112.5c-1.7,6.2-3,12.5-4,19c-1,7.1-1.6,14.3-1.6,21.6h0v85.5h19.7v-85.5c0-7.2,0.6-14.4,1.8-21.4c14,1.1,27.6,4.3,40.5,9.5c15.9,6.4,30.3,15.6,42.6,27.3c12.3,11.7,22,25.4,28.7,40.6c6.9,15.6,10.5,32.2,10.5,49.2v81.4h0.1h19.6h0.1v-81.5c0.1-17.1,3.6-33.7,10.5-49.2c6.7-15.2,16.4-28.8,28.7-40.6c4.2-4,8.6-7.7,13.2-11.1v132.2h19.7V223.2h0c0-2.5-0.1-5-0.4-7.4c3.3-1.6,6.6-3.1,10-4.5c12.9-5.2,26.4-8.4,40.4-9.5c1.2,7,1.7,14.2,1.8,21.4v85.5h19.7L393.5,223.2L393.5,223.2z M240.1,277.3c-11.6-29.3-32.7-54.1-59.8-71c2.9-10,8.2-19.1,15.8-26.6c11.8-11.8,27.4-18.2,44-18.2s32.3,6.5,44,18.2c4.1,4.1,7.5,8.7,10.3,13.6c5.6-3.4,11.4-6.4,17.4-9.2c-14-25.2-40.9-42.3-71.8-42.3c-35.9,0-66.3,23-77.5,55.1c-15.5-7.1-32.5-11.8-50.4-13.5c1.3-4,2.7-7.9,4.3-11.8c6.7-15.9,16.4-30.3,28.7-42.6s26.6-22,42.6-28.7c16.5-7,34-10.5,52.1-10.5s35.6,3.5,52.1,10.5c15.9,6.7,30.3,16.4,42.6,28.7s22,26.6,28.7,42.6c1.6,3.9,3.1,7.8,4.3,11.8C309,189.2,260.1,226.5,240.1,277.3z" />
@@ -4374,7 +4612,7 @@ var KibisisWallet = class extends BaseWallet {
4374
4612
  }
4375
4613
  static defaultMetadata = {
4376
4614
  name: "Kibisis",
4377
- icon: ICON5
4615
+ icon: ICON6
4378
4616
  };
4379
4617
  /**
4380
4618
  * private functions
@@ -4666,7 +4904,7 @@ var KibisisWallet = class extends BaseWallet {
4666
4904
  const txnsToSign = [];
4667
4905
  txnGroup.forEach((txn, index) => {
4668
4906
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
4669
- const signer = import_algosdk4.default.encodeAddress(txn.from.publicKey);
4907
+ const signer = import_algosdk5.default.encodeAddress(txn.from.publicKey);
4670
4908
  const canSignTxn = this.addresses.includes(signer);
4671
4909
  const txnString = byteArrayToBase64(txn.toByte());
4672
4910
  if (isIndexMatch && canSignTxn) {
@@ -4680,11 +4918,11 @@ var KibisisWallet = class extends BaseWallet {
4680
4918
  processEncodedTxns(txnGroup, indexesToSign) {
4681
4919
  const txnsToSign = [];
4682
4920
  txnGroup.forEach((txnBuffer, index) => {
4683
- const txnDecodeObj = import_algosdk4.default.decodeObj(txnBuffer);
4921
+ const txnDecodeObj = import_algosdk5.default.decodeObj(txnBuffer);
4684
4922
  const isSigned = isSignedTxn(txnDecodeObj);
4685
- const txn = isSigned ? import_algosdk4.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk4.default.decodeUnsignedTransaction(txnBuffer);
4923
+ const txn = isSigned ? import_algosdk5.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk5.default.decodeUnsignedTransaction(txnBuffer);
4686
4924
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
4687
- const signer = import_algosdk4.default.encodeAddress(txn.from.publicKey);
4925
+ const signer = import_algosdk5.default.encodeAddress(txn.from.publicKey);
4688
4926
  const canSignTxn = !isSigned && this.addresses.includes(signer);
4689
4927
  const txnString = byteArrayToBase64(txn.toByte());
4690
4928
  if (isIndexMatch && canSignTxn) {
@@ -4728,8 +4966,8 @@ var KibisisWallet = class extends BaseWallet {
4728
4966
  };
4729
4967
 
4730
4968
  // src/wallets/kmd.ts
4731
- var import_algosdk5 = __toESM(require("algosdk"), 1);
4732
- var ICON6 = `data:image/svg+xml;base64,${btoa(`
4969
+ var import_algosdk6 = __toESM(require("algosdk"), 1);
4970
+ var ICON7 = `data:image/svg+xml;base64,${btoa(`
4733
4971
  <svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
4734
4972
  <linearGradient id="algokitGradient" gradientUnits="userSpaceOnUse" x1="0" y1="400" x2="400" y2="0">
4735
4973
  <stop offset="0" style="stop-color:#31D8EE"/>
@@ -4767,12 +5005,12 @@ var KmdWallet = class extends BaseWallet {
4767
5005
  }
4768
5006
  static defaultMetadata = {
4769
5007
  name: "KMD",
4770
- icon: ICON6
5008
+ icon: ICON7
4771
5009
  };
4772
5010
  async initializeClient() {
4773
5011
  this.logger.info("Initializing client...");
4774
5012
  const { token, baseServer, port } = this.options;
4775
- const client = new import_algosdk5.default.Kmd(token, baseServer, port);
5013
+ const client = new import_algosdk6.default.Kmd(token, baseServer, port);
4776
5014
  this.client = client;
4777
5015
  this.logger.info("Client initialized");
4778
5016
  return client;
@@ -4835,7 +5073,7 @@ var KmdWallet = class extends BaseWallet {
4835
5073
  const txnsToSign = [];
4836
5074
  txnGroup.forEach((txn, index) => {
4837
5075
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
4838
- const signer = import_algosdk5.default.encodeAddress(txn.from.publicKey);
5076
+ const signer = import_algosdk6.default.encodeAddress(txn.from.publicKey);
4839
5077
  const canSignTxn = this.addresses.includes(signer);
4840
5078
  if (isIndexMatch && canSignTxn) {
4841
5079
  txnsToSign.push(txn);
@@ -4846,11 +5084,11 @@ var KmdWallet = class extends BaseWallet {
4846
5084
  processEncodedTxns(txnGroup, indexesToSign) {
4847
5085
  const txnsToSign = [];
4848
5086
  txnGroup.forEach((txnBuffer, index) => {
4849
- const txnDecodeObj = import_algosdk5.default.decodeObj(txnBuffer);
5087
+ const txnDecodeObj = import_algosdk6.default.decodeObj(txnBuffer);
4850
5088
  const isSigned = isSignedTxn(txnDecodeObj);
4851
- const txn = isSigned ? import_algosdk5.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk5.default.decodeUnsignedTransaction(txnBuffer);
5089
+ const txn = isSigned ? import_algosdk6.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk6.default.decodeUnsignedTransaction(txnBuffer);
4852
5090
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
4853
- const signer = import_algosdk5.default.encodeAddress(txn.from.publicKey);
5091
+ const signer = import_algosdk6.default.encodeAddress(txn.from.publicKey);
4854
5092
  const canSignTxn = !isSigned && this.addresses.includes(signer);
4855
5093
  if (isIndexMatch && canSignTxn) {
4856
5094
  txnsToSign.push(txn);
@@ -4934,11 +5172,11 @@ var KmdWallet = class extends BaseWallet {
4934
5172
  };
4935
5173
 
4936
5174
  // src/wallets/lute.ts
4937
- var import_algosdk6 = __toESM(require("algosdk"), 1);
5175
+ var import_algosdk7 = __toESM(require("algosdk"), 1);
4938
5176
  function isSignTxnsError(error) {
4939
5177
  return error instanceof Error && "code" in error;
4940
5178
  }
4941
- var ICON7 = `data:image/svg+xml;base64,${btoa(`
5179
+ var ICON8 = `data:image/svg+xml;base64,${btoa(`
4942
5180
  <svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
4943
5181
  <path fill="#AB47BC" d="M283.7,263.6c-0.6,0-1.3-0.1-1.8-0.4c-0.6-0.3-1.1-0.8-1.5-1.3c-0.4-0.6-0.7-1.3-0.8-2 c-0.1-0.8-0.1-1.7,0.1-2.5c0.2-0.9,0.6-1.8,1.2-2.6c0.6-0.8,1.4-1.7,2.2-2.3c0.9-0.7,2.1-1.2,3.2-1.6c1.2-0.4,2.7-0.5,4-0.5 c1.4,0,3,0.3,4.4,0.8c1.5,0.5,3.1,1.4,4.3,2.3c1.4,1,2.8,2.4,3.8,3.7c1.1,1.5,2.1,3.3,2.8,5.1c0.7,1.9,1.2,4.1,1.3,6.1 c0.2,2.1,0,4.6-0.4,6.7c-0.5,2.2-1.4,4.7-2.4,6.7c-1.1,2.1-2.8,4.4-4.4,6.2c-1.8,1.9-4.1,3.7-6.3,5c-2.3,1.4-5.2,2.6-7.9,3.3 c-2.8,0.7-6.1,1.1-8.9,1.1c-3,0-6.5-0.6-9.3-1.4c-3-0.9-6.4-2.4-9.1-4c-2.8-1.7-5.8-4.2-8-6.6c-2.3-2.5-4.6-5.8-6.2-8.9 c-1.7-3.2-3.1-7.1-3.8-10.7c-0.8-3.7-1.1-8-0.9-11.8c0.2-3.9,1.1-8.3,2.3-12c1.3-3.8,3.4-8.1,5.7-11.4c2.3-3.5,5.6-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9,0-6.2,0.4-8.9,1.1c-2.6,0.7-5.5,1.9-7.9,3.3c-2.2,1.3-4.5,3.2-6.3,5c-1.7,1.8-3.3,4-4.4,6.2c-1.1,2-2,4.5-2.4,6.7 c-0.4,2.1-0.6,4.5-0.4,6.7c0.2,2,0.6,4.2,1.3,6.1c0.6,1.7,1.7,3.6,2.8,5.1c1,1.3,2.4,2.7,3.8,3.7c1.3,0.9,2.8,1.8,4.3,2.3 c1.3,0.5,2.9,0.8,4.4,0.8c1.3,0,2.7-0.1,4-0.5c1.1-0.3,2.3-0.9,3.2-1.6c0.8-0.6,1.7-1.4,2.2-2.3c0.5-0.7,0.9-1.7,1.2-2.6 c0.2-0.8,0.2-1.7,0.1-2.5c-0.1-0.7-0.4-1.4-0.8-2c-0.4-0.5-0.9-1-1.5-1.3C285,263.7,284.3,263.6,283.7,263.6L283.7,263.6z" />
4944
5182
  </svg>
@@ -4965,7 +5203,7 @@ var LuteWallet = class extends BaseWallet {
4965
5203
  }
4966
5204
  static defaultMetadata = {
4967
5205
  name: "Lute",
4968
- icon: ICON7
5206
+ icon: ICON8
4969
5207
  };
4970
5208
  async initializeClient() {
4971
5209
  this.logger.info("Initializing client...");
@@ -5032,7 +5270,7 @@ var LuteWallet = class extends BaseWallet {
5032
5270
  const txnsToSign = [];
5033
5271
  txnGroup.forEach((txn, index) => {
5034
5272
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5035
- const signer = import_algosdk6.default.encodeAddress(txn.from.publicKey);
5273
+ const signer = import_algosdk7.default.encodeAddress(txn.from.publicKey);
5036
5274
  const canSignTxn = this.addresses.includes(signer);
5037
5275
  const txnString = byteArrayToBase64(txn.toByte());
5038
5276
  if (isIndexMatch && canSignTxn) {
@@ -5046,11 +5284,11 @@ var LuteWallet = class extends BaseWallet {
5046
5284
  processEncodedTxns(txnGroup, indexesToSign) {
5047
5285
  const txnsToSign = [];
5048
5286
  txnGroup.forEach((txnBuffer, index) => {
5049
- const txnDecodeObj = import_algosdk6.default.decodeObj(txnBuffer);
5287
+ const txnDecodeObj = import_algosdk7.default.decodeObj(txnBuffer);
5050
5288
  const isSigned = isSignedTxn(txnDecodeObj);
5051
- const txn = isSigned ? import_algosdk6.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk6.default.decodeUnsignedTransaction(txnBuffer);
5289
+ const txn = isSigned ? import_algosdk7.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk7.default.decodeUnsignedTransaction(txnBuffer);
5052
5290
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5053
- const signer = import_algosdk6.default.encodeAddress(txn.from.publicKey);
5291
+ const signer = import_algosdk7.default.encodeAddress(txn.from.publicKey);
5054
5292
  const canSignTxn = !isSigned && this.addresses.includes(signer);
5055
5293
  const txnString = byteArrayToBase64(txn.toByte());
5056
5294
  if (isIndexMatch && canSignTxn) {
@@ -5089,8 +5327,8 @@ var LuteWallet = class extends BaseWallet {
5089
5327
  };
5090
5328
 
5091
5329
  // src/wallets/magic.ts
5092
- var import_algosdk7 = __toESM(require("algosdk"), 1);
5093
- var ICON8 = `data:image/svg+xml;base64,${btoa(`
5330
+ var import_algosdk8 = __toESM(require("algosdk"), 1);
5331
+ var ICON9 = `data:image/svg+xml;base64,${btoa(`
5094
5332
  <svg viewBox="0 0 47 47" xmlns="http://www.w3.org/2000/svg">
5095
5333
  <path fill="#6851FF" d="M 23.960861 1.80769 C 25.835077 4.103153 27.902216 6.23489 30.137539 8.178169 C 28.647968 13.009323 27.846092 18.142094 27.846092 23.462154 C 27.846092 28.782307 28.648062 33.915169 30.13763 38.746368 C 27.902216 40.689724 25.835077 42.821476 23.960861 45.116985 C 22.086554 42.821476 20.019415 40.689632 17.783998 38.746368 C 19.273476 33.915169 20.075445 28.7824 20.075445 23.462337 C 20.075445 18.142277 19.273476 13.009506 17.783998 8.178318 C 20.019415 6.235001 22.086554 4.10321 23.960861 1.80769 Z M 13.511427 35.406403 C 11.145139 33.747814 8.633816 32.282063 6.000269 31.031937 C 6.730776 28.637476 7.123754 26.095783 7.123754 23.462429 C 7.123754 20.828892 6.730762 18.287201 6.000235 15.892738 C 8.633816 14.642616 11.145175 13.176861 13.511501 11.518276 C 14.416311 15.352554 14.895074 19.351414 14.895074 23.462154 C 14.895074 27.572985 14.416283 31.571938 13.511427 35.406403 Z M 33.027046 23.462337 C 33.027046 27.572985 33.505753 31.571846 34.410553 35.406124 C 36.776859 33.747631 39.288094 32.281876 41.921539 31.031845 C 41.191017 28.637384 40.798061 26.095692 40.798061 23.462246 C 40.798061 20.8288 41.191017 18.287201 41.921539 15.89283 C 39.288094 14.642708 36.776768 13.177048 34.410553 11.518555 C 33.505753 15.352831 33.027046 19.351692 33.027046 23.462337 Z" />
5096
5334
  </svg>
@@ -5118,7 +5356,7 @@ var MagicAuth = class extends BaseWallet {
5118
5356
  }
5119
5357
  static defaultMetadata = {
5120
5358
  name: "Magic",
5121
- icon: ICON8
5359
+ icon: ICON9
5122
5360
  };
5123
5361
  async initializeClient() {
5124
5362
  this.logger.info("Initializing client...");
@@ -5236,7 +5474,7 @@ var MagicAuth = class extends BaseWallet {
5236
5474
  const txnsToSign = [];
5237
5475
  txnGroup.forEach((txn, index) => {
5238
5476
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5239
- const signer = import_algosdk7.default.encodeAddress(txn.from.publicKey);
5477
+ const signer = import_algosdk8.default.encodeAddress(txn.from.publicKey);
5240
5478
  const canSignTxn = this.addresses.includes(signer);
5241
5479
  const txnString = byteArrayToBase64(txn.toByte());
5242
5480
  if (isIndexMatch && canSignTxn) {
@@ -5250,11 +5488,11 @@ var MagicAuth = class extends BaseWallet {
5250
5488
  processEncodedTxns(txnGroup, indexesToSign) {
5251
5489
  const txnsToSign = [];
5252
5490
  txnGroup.forEach((txnBuffer, index) => {
5253
- const txnDecodeObj = import_algosdk7.default.decodeObj(txnBuffer);
5491
+ const txnDecodeObj = import_algosdk8.default.decodeObj(txnBuffer);
5254
5492
  const isSigned = isSignedTxn(txnDecodeObj);
5255
- const txn = isSigned ? import_algosdk7.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk7.default.decodeUnsignedTransaction(txnBuffer);
5493
+ const txn = isSigned ? import_algosdk8.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk8.default.decodeUnsignedTransaction(txnBuffer);
5256
5494
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5257
- const signer = import_algosdk7.default.encodeAddress(txn.from.publicKey);
5495
+ const signer = import_algosdk8.default.encodeAddress(txn.from.publicKey);
5258
5496
  const canSignTxn = !isSigned && this.addresses.includes(signer);
5259
5497
  const txnString = byteArrayToBase64(txn.toByte());
5260
5498
  if (isIndexMatch && canSignTxn) {
@@ -5298,9 +5536,9 @@ var MagicAuth = class extends BaseWallet {
5298
5536
  };
5299
5537
 
5300
5538
  // src/wallets/mnemonic.ts
5301
- var import_algosdk8 = __toESM(require("algosdk"), 1);
5539
+ var import_algosdk9 = __toESM(require("algosdk"), 1);
5302
5540
  var LOCAL_STORAGE_MNEMONIC_KEY = `${LOCAL_STORAGE_KEY}_mnemonic`;
5303
- var ICON9 = `data:image/svg+xml;base64,${btoa(`
5541
+ var ICON10 = `data:image/svg+xml;base64,${btoa(`
5304
5542
  <svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
5305
5543
  <rect fill="#525252" width="400" height="400" />
5306
5544
  <path fill="#FFFFFF" d="M309.2,309.3H275l-22.2-82.7l-47.9,82.7h-38.3l73.9-128l-11.9-44.5l-99.6,172.6H90.8L217.1,90.6 h33.5l14.7,54.3h34.6l-23.6,41L309.2,309.3z" />
@@ -5330,7 +5568,7 @@ var MnemonicWallet = class extends BaseWallet {
5330
5568
  }
5331
5569
  static defaultMetadata = {
5332
5570
  name: "Mnemonic",
5333
- icon: ICON9
5571
+ icon: ICON10
5334
5572
  };
5335
5573
  loadMnemonicFromStorage() {
5336
5574
  return StorageAdapter.getItem(LOCAL_STORAGE_MNEMONIC_KEY);
@@ -5366,7 +5604,7 @@ var MnemonicWallet = class extends BaseWallet {
5366
5604
  this.saveMnemonicToStorage(mnemonic);
5367
5605
  }
5368
5606
  }
5369
- const account = import_algosdk8.default.mnemonicToSecretKey(mnemonic);
5607
+ const account = import_algosdk9.default.mnemonicToSecretKey(mnemonic);
5370
5608
  this.account = account;
5371
5609
  return account;
5372
5610
  }
@@ -5410,7 +5648,7 @@ var MnemonicWallet = class extends BaseWallet {
5410
5648
  const txnsToSign = [];
5411
5649
  txnGroup.forEach((txn, index) => {
5412
5650
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5413
- const signer = import_algosdk8.default.encodeAddress(txn.from.publicKey);
5651
+ const signer = import_algosdk9.default.encodeAddress(txn.from.publicKey);
5414
5652
  const canSignTxn = signer === this.account.addr;
5415
5653
  if (isIndexMatch && canSignTxn) {
5416
5654
  txnsToSign.push(txn);
@@ -5421,11 +5659,11 @@ var MnemonicWallet = class extends BaseWallet {
5421
5659
  processEncodedTxns(txnGroup, indexesToSign) {
5422
5660
  const txnsToSign = [];
5423
5661
  txnGroup.forEach((txnBuffer, index) => {
5424
- const txnDecodeObj = import_algosdk8.default.decodeObj(txnBuffer);
5662
+ const txnDecodeObj = import_algosdk9.default.decodeObj(txnBuffer);
5425
5663
  const isSigned = isSignedTxn(txnDecodeObj);
5426
- const txn = isSigned ? import_algosdk8.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk8.default.decodeUnsignedTransaction(txnBuffer);
5664
+ const txn = isSigned ? import_algosdk9.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk9.default.decodeUnsignedTransaction(txnBuffer);
5427
5665
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5428
- const signer = import_algosdk8.default.encodeAddress(txn.from.publicKey);
5666
+ const signer = import_algosdk9.default.encodeAddress(txn.from.publicKey);
5429
5667
  const canSignTxn = !isSigned && signer === this.account.addr;
5430
5668
  if (isIndexMatch && canSignTxn) {
5431
5669
  txnsToSign.push(txn);
@@ -5456,8 +5694,8 @@ var MnemonicWallet = class extends BaseWallet {
5456
5694
  };
5457
5695
 
5458
5696
  // src/wallets/pera.ts
5459
- var import_algosdk9 = __toESM(require("algosdk"), 1);
5460
- var ICON10 = `data:image/svg+xml;base64,${btoa(`
5697
+ var import_algosdk10 = __toESM(require("algosdk"), 1);
5698
+ var ICON11 = `data:image/svg+xml;base64,${btoa(`
5461
5699
  <svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
5462
5700
  <rect fill="#FFEE55" width="200" height="200" />
5463
5701
  <path fill="#1C1C1C" d="M106.1,64.3c2.2,9.1,1.5,17-1.7,17.8c-3.1,0.8-7.4-6-9.6-15c-2.2-9.1-1.5-17,1.7-17.8 C99.6,48.5,103.9,55.2,106.1,64.3z" />
@@ -5486,7 +5724,7 @@ var PeraWallet = class extends BaseWallet {
5486
5724
  }
5487
5725
  static defaultMetadata = {
5488
5726
  name: "Pera",
5489
- icon: ICON10
5727
+ icon: ICON11
5490
5728
  };
5491
5729
  async initializeClient() {
5492
5730
  this.logger.info("Initializing client...");
@@ -5592,7 +5830,7 @@ var PeraWallet = class extends BaseWallet {
5592
5830
  const txnsToSign = [];
5593
5831
  txnGroup.forEach((txn, index) => {
5594
5832
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5595
- const signer = import_algosdk9.default.encodeAddress(txn.from.publicKey);
5833
+ const signer = import_algosdk10.default.encodeAddress(txn.from.publicKey);
5596
5834
  const canSignTxn = this.addresses.includes(signer);
5597
5835
  if (isIndexMatch && canSignTxn) {
5598
5836
  txnsToSign.push({ txn });
@@ -5605,11 +5843,11 @@ var PeraWallet = class extends BaseWallet {
5605
5843
  processEncodedTxns(txnGroup, indexesToSign) {
5606
5844
  const txnsToSign = [];
5607
5845
  txnGroup.forEach((txnBuffer, index) => {
5608
- const txnDecodeObj = import_algosdk9.default.decodeObj(txnBuffer);
5846
+ const txnDecodeObj = import_algosdk10.default.decodeObj(txnBuffer);
5609
5847
  const isSigned = isSignedTxn(txnDecodeObj);
5610
- const txn = isSigned ? import_algosdk9.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk9.default.decodeUnsignedTransaction(txnBuffer);
5848
+ const txn = isSigned ? import_algosdk10.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk10.default.decodeUnsignedTransaction(txnBuffer);
5611
5849
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5612
- const signer = import_algosdk9.default.encodeAddress(txn.from.publicKey);
5850
+ const signer = import_algosdk10.default.encodeAddress(txn.from.publicKey);
5613
5851
  const canSignTxn = !isSigned && this.addresses.includes(signer);
5614
5852
  if (isIndexMatch && canSignTxn) {
5615
5853
  txnsToSign.push({ txn });
@@ -5655,8 +5893,8 @@ var PeraWallet = class extends BaseWallet {
5655
5893
  };
5656
5894
 
5657
5895
  // src/wallets/pera2.ts
5658
- var import_algosdk10 = __toESM(require("algosdk"), 1);
5659
- var ICON11 = `data:image/svg+xml;base64,${btoa(`
5896
+ var import_algosdk11 = __toESM(require("algosdk"), 1);
5897
+ var ICON12 = `data:image/svg+xml;base64,${btoa(`
5660
5898
  <svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
5661
5899
  <rect fill="#FFEE55" width="200" height="200" />
5662
5900
  <path fill="#1C1C1C" d="M106.1,64.3c2.2,9.1,1.5,17-1.7,17.8c-3.1,0.8-7.4-6-9.6-15c-2.2-9.1-1.5-17,1.7-17.8 C99.6,48.5,103.9,55.2,106.1,64.3z" />
@@ -5689,7 +5927,7 @@ var PeraWallet2 = class extends BaseWallet {
5689
5927
  }
5690
5928
  static defaultMetadata = {
5691
5929
  name: "Pera",
5692
- icon: ICON11
5930
+ icon: ICON12
5693
5931
  };
5694
5932
  async initializeClient() {
5695
5933
  this.logger.info("Initializing client...");
@@ -5773,7 +6011,7 @@ var PeraWallet2 = class extends BaseWallet {
5773
6011
  const txnsToSign = [];
5774
6012
  txnGroup.forEach((txn, index) => {
5775
6013
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5776
- const signer = import_algosdk10.default.encodeAddress(txn.from.publicKey);
6014
+ const signer = import_algosdk11.default.encodeAddress(txn.from.publicKey);
5777
6015
  const canSignTxn = this.addresses.includes(signer);
5778
6016
  if (isIndexMatch && canSignTxn) {
5779
6017
  txnsToSign.push({ txn });
@@ -5786,11 +6024,11 @@ var PeraWallet2 = class extends BaseWallet {
5786
6024
  processEncodedTxns(txnGroup, indexesToSign) {
5787
6025
  const txnsToSign = [];
5788
6026
  txnGroup.forEach((txnBuffer, index) => {
5789
- const txnDecodeObj = import_algosdk10.default.decodeObj(txnBuffer);
6027
+ const txnDecodeObj = import_algosdk11.default.decodeObj(txnBuffer);
5790
6028
  const isSigned = isSignedTxn(txnDecodeObj);
5791
- const txn = isSigned ? import_algosdk10.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk10.default.decodeUnsignedTransaction(txnBuffer);
6029
+ const txn = isSigned ? import_algosdk11.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk11.default.decodeUnsignedTransaction(txnBuffer);
5792
6030
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5793
- const signer = import_algosdk10.default.encodeAddress(txn.from.publicKey);
6031
+ const signer = import_algosdk11.default.encodeAddress(txn.from.publicKey);
5794
6032
  const canSignTxn = !isSigned && this.addresses.includes(signer);
5795
6033
  if (isIndexMatch && canSignTxn) {
5796
6034
  txnsToSign.push({ txn });
@@ -5938,242 +6176,6 @@ function deepMerge(target, source) {
5938
6176
  return target;
5939
6177
  }
5940
6178
 
5941
- // src/wallets/custom.ts
5942
- var ICON12 = `data:image/svg+xml;base64,${btoa(`
5943
- <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
5944
- <rect width="24" height="24" fill="#525252" />
5945
- </svg>
5946
- `)}`;
5947
- var CustomWallet = class extends BaseWallet {
5948
- provider;
5949
- store;
5950
- constructor({
5951
- id,
5952
- store,
5953
- subscribe,
5954
- getAlgodClient,
5955
- options,
5956
- metadata = {}
5957
- }) {
5958
- super({ id, metadata, getAlgodClient, store, subscribe });
5959
- if (!options?.provider) {
5960
- this.logger.error("Missing required option: provider");
5961
- throw new Error("Missing required option: provider");
5962
- }
5963
- this.provider = options.provider;
5964
- this.store = store;
5965
- }
5966
- static defaultMetadata = {
5967
- name: "Custom",
5968
- icon: ICON12
5969
- };
5970
- connect = async (args) => {
5971
- this.logger.info("Connecting...");
5972
- try {
5973
- if (!this.provider.connect) {
5974
- this.logger.error("Method not supported: connect");
5975
- throw new Error("Method not supported: connect");
5976
- }
5977
- const walletAccounts = await this.provider.connect(args);
5978
- if (walletAccounts.length === 0) {
5979
- this.logger.error("No accounts found!");
5980
- throw new Error("No accounts found!");
5981
- }
5982
- const activeAccount = walletAccounts[0];
5983
- const walletState = {
5984
- accounts: walletAccounts,
5985
- activeAccount
5986
- };
5987
- addWallet(this.store, {
5988
- walletId: this.id,
5989
- wallet: walletState
5990
- });
5991
- this.logger.info("\u2705 Connected.", walletState);
5992
- return walletAccounts;
5993
- } catch (error) {
5994
- this.logger.error("Error connecting:", error.message || error);
5995
- throw error;
5996
- }
5997
- };
5998
- disconnect = async () => {
5999
- this.logger.info("Disconnecting...");
6000
- this.onDisconnect();
6001
- await this.provider.disconnect?.();
6002
- };
6003
- resumeSession = async () => {
6004
- try {
6005
- const state = this.store.state;
6006
- const walletState = state.wallets[this.id];
6007
- if (!walletState) {
6008
- this.logger.info("No session to resume");
6009
- return;
6010
- }
6011
- this.logger.info("Resuming session...");
6012
- const result = await this.provider.resumeSession?.();
6013
- if (Array.isArray(result)) {
6014
- const walletAccounts = result;
6015
- if (walletAccounts.length === 0) {
6016
- this.logger.error("No accounts found!");
6017
- throw new Error("No accounts found!");
6018
- }
6019
- const match = compareAccounts(walletAccounts, walletState.accounts);
6020
- if (!match) {
6021
- this.logger.warn("Session accounts mismatch, updating accounts", {
6022
- prev: walletState.accounts,
6023
- current: walletAccounts
6024
- });
6025
- setAccounts(this.store, {
6026
- walletId: this.id,
6027
- accounts: walletAccounts
6028
- });
6029
- }
6030
- }
6031
- this.logger.info("Session resumed.");
6032
- } catch (error) {
6033
- this.logger.error("Error resuming session:", error.message);
6034
- throw error;
6035
- }
6036
- };
6037
- signTransactions = async (txnGroup, indexesToSign) => {
6038
- if (!this.provider.signTransactions) {
6039
- this.logger.error("Method not supported: signTransactions");
6040
- throw new Error("Method not supported: signTransactions");
6041
- }
6042
- this.logger.debug("Signing transactions...", { txnGroup, indexesToSign });
6043
- return await this.provider.signTransactions(txnGroup, indexesToSign);
6044
- };
6045
- transactionSigner = async (txnGroup, indexesToSign) => {
6046
- if (!this.provider.transactionSigner) {
6047
- this.logger.error("Method not supported: transactionSigner");
6048
- throw new Error("Method not supported: transactionSigner");
6049
- }
6050
- this.logger.debug("Transaction signer called...", { txnGroup, indexesToSign });
6051
- return await this.provider.transactionSigner(txnGroup, indexesToSign);
6052
- };
6053
- };
6054
-
6055
- // src/store.ts
6056
- var defaultState = {
6057
- wallets: {},
6058
- activeWallet: null,
6059
- activeNetwork: "testnet" /* TESTNET */,
6060
- algodClient: new import_algosdk11.default.Algodv2("", "https://testnet-api.4160.nodely.dev/")
6061
- };
6062
- var LOCAL_STORAGE_KEY = "@txnlab/use-wallet:v3";
6063
- function addWallet(store, { walletId, wallet }) {
6064
- store.setState((state) => {
6065
- const updatedWallets = {
6066
- ...state.wallets,
6067
- [walletId]: {
6068
- accounts: wallet.accounts.map((account) => ({ ...account })),
6069
- activeAccount: wallet.activeAccount ? { ...wallet.activeAccount } : null
6070
- }
6071
- };
6072
- return {
6073
- ...state,
6074
- wallets: updatedWallets,
6075
- activeWallet: walletId
6076
- };
6077
- });
6078
- }
6079
- function removeWallet(store, { walletId }) {
6080
- store.setState((state) => {
6081
- const updatedWallets = { ...state.wallets };
6082
- delete updatedWallets[walletId];
6083
- return {
6084
- ...state,
6085
- wallets: updatedWallets,
6086
- activeWallet: state.activeWallet === walletId ? null : state.activeWallet
6087
- };
6088
- });
6089
- }
6090
- function setActiveWallet(store, { walletId }) {
6091
- store.setState((state) => ({
6092
- ...state,
6093
- activeWallet: walletId
6094
- }));
6095
- }
6096
- function setActiveAccount(store, { walletId, address }) {
6097
- store.setState((state) => {
6098
- const wallet = state.wallets[walletId];
6099
- if (!wallet) {
6100
- logger.warn(`Wallet with id "${walletId}" not found`);
6101
- return state;
6102
- }
6103
- const newActiveAccount = wallet.accounts.find((a2) => a2.address === address);
6104
- if (!newActiveAccount) {
6105
- logger.warn(`Account with address ${address} not found in wallet "${walletId}"`);
6106
- return state;
6107
- }
6108
- const updatedWallet = {
6109
- ...wallet,
6110
- accounts: wallet.accounts.map((account) => ({ ...account })),
6111
- activeAccount: { ...newActiveAccount }
6112
- };
6113
- const updatedWallets = {
6114
- ...state.wallets,
6115
- [walletId]: updatedWallet
6116
- };
6117
- return {
6118
- ...state,
6119
- wallets: updatedWallets
6120
- };
6121
- });
6122
- }
6123
- function setAccounts(store, { walletId, accounts }) {
6124
- store.setState((state) => {
6125
- const wallet = state.wallets[walletId];
6126
- if (!wallet) {
6127
- logger.warn(`Wallet with id "${walletId}" not found`);
6128
- return state;
6129
- }
6130
- const newAccounts = accounts.map((account) => ({ ...account }));
6131
- const isActiveAccountConnected = newAccounts.some(
6132
- (account) => account.address === wallet.activeAccount?.address
6133
- );
6134
- const newActiveAccount = isActiveAccountConnected ? { ...wallet.activeAccount } : newAccounts[0] || null;
6135
- const updatedWallet = {
6136
- ...wallet,
6137
- accounts: newAccounts,
6138
- activeAccount: newActiveAccount
6139
- };
6140
- const updatedWallets = {
6141
- ...state.wallets,
6142
- [walletId]: updatedWallet
6143
- };
6144
- return {
6145
- ...state,
6146
- wallets: updatedWallets
6147
- };
6148
- });
6149
- }
6150
- function setActiveNetwork(store, { networkId, algodClient }) {
6151
- store.setState((state) => ({
6152
- ...state,
6153
- activeNetwork: networkId,
6154
- algodClient
6155
- }));
6156
- }
6157
- function isValidWalletId(walletId) {
6158
- return Object.values(WalletId).includes(walletId);
6159
- }
6160
- function isValidWalletAccount(account) {
6161
- return typeof account === "object" && account !== null && typeof account.name === "string" && typeof account.address === "string";
6162
- }
6163
- function isValidWalletState(wallet) {
6164
- return typeof wallet === "object" && wallet !== null && Array.isArray(wallet.accounts) && wallet.accounts.every(isValidWalletAccount) && (wallet.activeAccount === null || isValidWalletAccount(wallet.activeAccount));
6165
- }
6166
- function isValidState(state) {
6167
- if (!state || typeof state !== "object") return false;
6168
- if (typeof state.wallets !== "object") return false;
6169
- for (const [walletId, wallet] of Object.entries(state.wallets)) {
6170
- if (!isValidWalletId(walletId) || !isValidWalletState(wallet)) return false;
6171
- }
6172
- if (state.activeWallet !== null && !isValidWalletId(state.activeWallet)) return false;
6173
- if (!isValidNetworkId(state.activeNetwork)) return false;
6174
- return true;
6175
- }
6176
-
6177
6179
  // src/manager.ts
6178
6180
  var WalletManager = class {
6179
6181
  _clients = /* @__PURE__ */ new Map();