@txnlab/use-wallet 3.7.0 → 3.7.2

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);
@@ -3570,7 +3694,6 @@ var WalletConnect = class extends BaseWallet {
3570
3694
  modal = null;
3571
3695
  modalOptions;
3572
3696
  session = null;
3573
- chains;
3574
3697
  store;
3575
3698
  constructor({
3576
3699
  id,
@@ -3601,7 +3724,6 @@ var WalletConnect = class extends BaseWallet {
3601
3724
  metadata: clientMetadata
3602
3725
  };
3603
3726
  this.modalOptions = modalOptions;
3604
- this.chains = Object.values(caipChainId);
3605
3727
  this.store = store;
3606
3728
  }
3607
3729
  static defaultMetadata = {
@@ -3756,7 +3878,6 @@ var WalletConnect = class extends BaseWallet {
3756
3878
  const WalletConnectModal = (await import("@walletconnect/modal")).WalletConnectModal;
3757
3879
  const modal = new WalletConnectModal({
3758
3880
  projectId: this.options.projectId,
3759
- chains: this.chains,
3760
3881
  ...this.modalOptions
3761
3882
  });
3762
3883
  modal.subscribeModal((state) => this.logger.info(`Modal ${state.open ? "open" : "closed"}`));
@@ -3803,6 +3924,14 @@ var WalletConnect = class extends BaseWallet {
3803
3924
  this.session = session;
3804
3925
  return walletAccounts;
3805
3926
  }
3927
+ get activeChainId() {
3928
+ const chainId = caipChainId[this.activeNetwork];
3929
+ if (!chainId) {
3930
+ this.logger.warn(`No CAIP-2 chain ID found for network: ${this.activeNetwork}`);
3931
+ return "";
3932
+ }
3933
+ return chainId;
3934
+ }
3806
3935
  connect = async () => {
3807
3936
  this.logger.info("Connecting...");
3808
3937
  try {
@@ -3810,7 +3939,7 @@ var WalletConnect = class extends BaseWallet {
3810
3939
  const modal = this.modal || await this.initializeModal();
3811
3940
  const requiredNamespaces = {
3812
3941
  algorand: {
3813
- chains: this.chains,
3942
+ chains: [this.activeChainId],
3814
3943
  methods: ["algo_signTxn"],
3815
3944
  events: []
3816
3945
  }
@@ -3877,7 +4006,7 @@ var WalletConnect = class extends BaseWallet {
3877
4006
  const txnsToSign = [];
3878
4007
  txnGroup.forEach((txn, index) => {
3879
4008
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
3880
- const signer = import_algosdk.default.encodeAddress(txn.from.publicKey);
4009
+ const signer = import_algosdk2.default.encodeAddress(txn.from.publicKey);
3881
4010
  const canSignTxn = this.addresses.includes(signer);
3882
4011
  const txnString = byteArrayToBase64(txn.toByte());
3883
4012
  if (isIndexMatch && canSignTxn) {
@@ -3891,11 +4020,11 @@ var WalletConnect = class extends BaseWallet {
3891
4020
  processEncodedTxns(txnGroup, indexesToSign) {
3892
4021
  const txnsToSign = [];
3893
4022
  txnGroup.forEach((txnBuffer, index) => {
3894
- const txnDecodeObj = import_algosdk.default.decodeObj(txnBuffer);
4023
+ const txnDecodeObj = import_algosdk2.default.decodeObj(txnBuffer);
3895
4024
  const isSigned = isSignedTxn(txnDecodeObj);
3896
- const txn = isSigned ? import_algosdk.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk.default.decodeUnsignedTransaction(txnBuffer);
4025
+ const txn = isSigned ? import_algosdk2.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk2.default.decodeUnsignedTransaction(txnBuffer);
3897
4026
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
3898
- const signer = import_algosdk.default.encodeAddress(txn.from.publicKey);
4027
+ const signer = import_algosdk2.default.encodeAddress(txn.from.publicKey);
3899
4028
  const canSignTxn = !isSigned && this.addresses.includes(signer);
3900
4029
  const txnString = byteArrayToBase64(txn.toByte());
3901
4030
  if (isIndexMatch && canSignTxn) {
@@ -3925,7 +4054,7 @@ var WalletConnect = class extends BaseWallet {
3925
4054
  this.logger.debug("Sending processed transactions to wallet...", [txnsToSign]);
3926
4055
  const request = formatJsonRpcRequest("algo_signTxn", [txnsToSign]);
3927
4056
  const signTxnsResult = await client.request({
3928
- chainId: caipChainId[this.activeNetwork],
4057
+ chainId: this.activeChainId,
3929
4058
  topic: this.session.topic,
3930
4059
  request
3931
4060
  });
@@ -3978,56 +4107,170 @@ var BiatecWallet = class extends WalletConnect {
3978
4107
  };
3979
4108
  };
3980
4109
 
3981
- // src/wallets/defly.ts
3982
- var import_algosdk2 = __toESM(require("algosdk"), 1);
4110
+ // src/wallets/custom.ts
3983
4111
  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" />
4112
+ <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
4113
+ <rect width="24" height="24" fill="#525252" />
3988
4114
  </svg>
3989
4115
  `)}`;
3990
- var DeflyWallet = class extends BaseWallet {
3991
- client = null;
3992
- options;
4116
+ var CustomWallet = class extends BaseWallet {
4117
+ provider;
3993
4118
  store;
3994
4119
  constructor({
3995
4120
  id,
3996
4121
  store,
3997
4122
  subscribe,
3998
4123
  getAlgodClient,
3999
- options = {},
4124
+ options,
4000
4125
  metadata = {}
4001
4126
  }) {
4002
4127
  super({ id, metadata, getAlgodClient, store, subscribe });
4003
- this.options = options;
4128
+ if (!options?.provider) {
4129
+ this.logger.error("Missing required option: provider");
4130
+ throw new Error("Missing required option: provider");
4131
+ }
4132
+ this.provider = options.provider;
4004
4133
  this.store = store;
4005
4134
  }
4006
4135
  static defaultMetadata = {
4007
- name: "Defly",
4136
+ name: "Custom",
4008
4137
  icon: ICON3
4009
4138
  };
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 () => {
4139
+ connect = async (args) => {
4020
4140
  this.logger.info("Connecting...");
4021
- const currentActiveWallet = this.store.state.activeWallet;
4022
- if (currentActiveWallet && currentActiveWallet !== this.id) {
4023
- this.manageWalletConnectSession("backup", currentActiveWallet);
4141
+ try {
4142
+ if (!this.provider.connect) {
4143
+ this.logger.error("Method not supported: connect");
4144
+ throw new Error("Method not supported: connect");
4145
+ }
4146
+ const walletAccounts = await this.provider.connect(args);
4147
+ if (walletAccounts.length === 0) {
4148
+ this.logger.error("No accounts found!");
4149
+ throw new Error("No accounts found!");
4150
+ }
4151
+ const activeAccount = walletAccounts[0];
4152
+ const walletState = {
4153
+ accounts: walletAccounts,
4154
+ activeAccount
4155
+ };
4156
+ addWallet(this.store, {
4157
+ walletId: this.id,
4158
+ wallet: walletState
4159
+ });
4160
+ this.logger.info("\u2705 Connected.", walletState);
4161
+ return walletAccounts;
4162
+ } catch (error) {
4163
+ this.logger.error("Error connecting:", error.message || error);
4164
+ throw error;
4024
4165
  }
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!");
4166
+ };
4167
+ disconnect = async () => {
4168
+ this.logger.info("Disconnecting...");
4169
+ this.onDisconnect();
4170
+ await this.provider.disconnect?.();
4171
+ };
4172
+ resumeSession = async () => {
4173
+ try {
4174
+ const state = this.store.state;
4175
+ const walletState = state.wallets[this.id];
4176
+ if (!walletState) {
4177
+ this.logger.info("No session to resume");
4178
+ return;
4179
+ }
4180
+ this.logger.info("Resuming session...");
4181
+ const result = await this.provider.resumeSession?.();
4182
+ if (Array.isArray(result)) {
4183
+ const walletAccounts = result;
4184
+ if (walletAccounts.length === 0) {
4185
+ this.logger.error("No accounts found!");
4186
+ throw new Error("No accounts found!");
4187
+ }
4188
+ const match = compareAccounts(walletAccounts, walletState.accounts);
4189
+ if (!match) {
4190
+ this.logger.warn("Session accounts mismatch, updating accounts", {
4191
+ prev: walletState.accounts,
4192
+ current: walletAccounts
4193
+ });
4194
+ setAccounts(this.store, {
4195
+ walletId: this.id,
4196
+ accounts: walletAccounts
4197
+ });
4198
+ }
4199
+ }
4200
+ this.logger.info("Session resumed.");
4201
+ } catch (error) {
4202
+ this.logger.error("Error resuming session:", error.message);
4203
+ throw error;
4204
+ }
4205
+ };
4206
+ signTransactions = async (txnGroup, indexesToSign) => {
4207
+ if (!this.provider.signTransactions) {
4208
+ this.logger.error("Method not supported: signTransactions");
4209
+ throw new Error("Method not supported: signTransactions");
4210
+ }
4211
+ this.logger.debug("Signing transactions...", { txnGroup, indexesToSign });
4212
+ return await this.provider.signTransactions(txnGroup, indexesToSign);
4213
+ };
4214
+ transactionSigner = async (txnGroup, indexesToSign) => {
4215
+ if (!this.provider.transactionSigner) {
4216
+ this.logger.error("Method not supported: transactionSigner");
4217
+ throw new Error("Method not supported: transactionSigner");
4218
+ }
4219
+ this.logger.debug("Transaction signer called...", { txnGroup, indexesToSign });
4220
+ return await this.provider.transactionSigner(txnGroup, indexesToSign);
4221
+ };
4222
+ };
4223
+
4224
+ // src/wallets/defly.ts
4225
+ var import_algosdk3 = __toESM(require("algosdk"), 1);
4226
+ var ICON4 = `data:image/svg+xml;base64,${btoa(`
4227
+ <svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
4228
+ <rect width="1024" height="1024" />
4229
+ <path fill="#FFFFFF" d="M779.9,684.4L512,230L244.1,684.4L512,529.5L779.9,684.4z" />
4230
+ <path fill="#FFFFFF" d="M733.1,730L512,613.5L290.9,730L512,658L733.1,730z" />
4231
+ </svg>
4232
+ `)}`;
4233
+ var DeflyWallet = class extends BaseWallet {
4234
+ client = null;
4235
+ options;
4236
+ store;
4237
+ constructor({
4238
+ id,
4239
+ store,
4240
+ subscribe,
4241
+ getAlgodClient,
4242
+ options = {},
4243
+ metadata = {}
4244
+ }) {
4245
+ super({ id, metadata, getAlgodClient, store, subscribe });
4246
+ this.options = options;
4247
+ this.store = store;
4248
+ }
4249
+ static defaultMetadata = {
4250
+ name: "Defly",
4251
+ icon: ICON4
4252
+ };
4253
+ async initializeClient() {
4254
+ this.logger.info("Initializing client...");
4255
+ const module2 = await import("@blockshake/defly-connect");
4256
+ const DeflyWalletConnect = module2.default ? module2.default.DeflyWalletConnect : module2.DeflyWalletConnect;
4257
+ const client = new DeflyWalletConnect(this.options);
4258
+ this.client = client;
4259
+ this.logger.info("Client initialized");
4260
+ return client;
4261
+ }
4262
+ connect = async () => {
4263
+ this.logger.info("Connecting...");
4264
+ const currentActiveWallet = this.store.state.activeWallet;
4265
+ if (currentActiveWallet && currentActiveWallet !== this.id) {
4266
+ this.manageWalletConnectSession("backup", currentActiveWallet);
4267
+ }
4268
+ const client = this.client || await this.initializeClient();
4269
+ const accounts = await client.connect();
4270
+ client.connector?.on("disconnect", this.onDisconnect);
4271
+ if (accounts.length === 0) {
4272
+ this.logger.error("No accounts found!");
4273
+ throw new Error("No accounts found!");
4031
4274
  }
4032
4275
  const walletAccounts = accounts.map((address, idx) => ({
4033
4276
  name: `${this.metadata.name} Account ${idx + 1}`,
@@ -4111,7 +4354,7 @@ var DeflyWallet = class extends BaseWallet {
4111
4354
  const txnsToSign = [];
4112
4355
  txnGroup.forEach((txn, index) => {
4113
4356
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
4114
- const signer = import_algosdk2.default.encodeAddress(txn.from.publicKey);
4357
+ const signer = import_algosdk3.default.encodeAddress(txn.from.publicKey);
4115
4358
  const canSignTxn = this.addresses.includes(signer);
4116
4359
  if (isIndexMatch && canSignTxn) {
4117
4360
  txnsToSign.push({ txn });
@@ -4124,11 +4367,11 @@ var DeflyWallet = class extends BaseWallet {
4124
4367
  processEncodedTxns(txnGroup, indexesToSign) {
4125
4368
  const txnsToSign = [];
4126
4369
  txnGroup.forEach((txnBuffer, index) => {
4127
- const txnDecodeObj = import_algosdk2.default.decodeObj(txnBuffer);
4370
+ const txnDecodeObj = import_algosdk3.default.decodeObj(txnBuffer);
4128
4371
  const isSigned = isSignedTxn(txnDecodeObj);
4129
- const txn = isSigned ? import_algosdk2.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk2.default.decodeUnsignedTransaction(txnBuffer);
4372
+ const txn = isSigned ? import_algosdk3.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk3.default.decodeUnsignedTransaction(txnBuffer);
4130
4373
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
4131
- const signer = import_algosdk2.default.encodeAddress(txn.from.publicKey);
4374
+ const signer = import_algosdk3.default.encodeAddress(txn.from.publicKey);
4132
4375
  const canSignTxn = !isSigned && this.addresses.includes(signer);
4133
4376
  if (isIndexMatch && canSignTxn) {
4134
4377
  txnsToSign.push({ txn });
@@ -4174,8 +4417,8 @@ var DeflyWallet = class extends BaseWallet {
4174
4417
  };
4175
4418
 
4176
4419
  // src/wallets/exodus.ts
4177
- var import_algosdk3 = __toESM(require("algosdk"), 1);
4178
- var ICON4 = `data:image/svg+xml;base64,${btoa(`
4420
+ var import_algosdk4 = __toESM(require("algosdk"), 1);
4421
+ var ICON5 = `data:image/svg+xml;base64,${btoa(`
4179
4422
  <svg viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg">
4180
4423
  <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
4424
  <stop offset="0" stop-color="#0B46F9" />
@@ -4219,7 +4462,7 @@ var ExodusWallet = class extends BaseWallet {
4219
4462
  }
4220
4463
  static defaultMetadata = {
4221
4464
  name: "Exodus",
4222
- icon: ICON4
4465
+ icon: ICON5
4223
4466
  };
4224
4467
  async initializeClient() {
4225
4468
  this.logger.info("Initializing client...");
@@ -4286,7 +4529,7 @@ var ExodusWallet = class extends BaseWallet {
4286
4529
  const txnsToSign = [];
4287
4530
  txnGroup.forEach((txn, index) => {
4288
4531
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
4289
- const signer = import_algosdk3.default.encodeAddress(txn.from.publicKey);
4532
+ const signer = import_algosdk4.default.encodeAddress(txn.from.publicKey);
4290
4533
  const canSignTxn = this.addresses.includes(signer);
4291
4534
  const txnString = byteArrayToBase64(txn.toByte());
4292
4535
  if (isIndexMatch && canSignTxn) {
@@ -4300,11 +4543,11 @@ var ExodusWallet = class extends BaseWallet {
4300
4543
  processEncodedTxns(txnGroup, indexesToSign) {
4301
4544
  const txnsToSign = [];
4302
4545
  txnGroup.forEach((txnBuffer, index) => {
4303
- const txnDecodeObj = import_algosdk3.default.decodeObj(txnBuffer);
4546
+ const txnDecodeObj = import_algosdk4.default.decodeObj(txnBuffer);
4304
4547
  const isSigned = isSignedTxn(txnDecodeObj);
4305
- const txn = isSigned ? import_algosdk3.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk3.default.decodeUnsignedTransaction(txnBuffer);
4548
+ const txn = isSigned ? import_algosdk4.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk4.default.decodeUnsignedTransaction(txnBuffer);
4306
4549
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
4307
- const signer = import_algosdk3.default.encodeAddress(txn.from.publicKey);
4550
+ const signer = import_algosdk4.default.encodeAddress(txn.from.publicKey);
4308
4551
  const canSignTxn = !isSigned && this.addresses.includes(signer);
4309
4552
  const txnString = byteArrayToBase64(txn.toByte());
4310
4553
  if (isIndexMatch && canSignTxn) {
@@ -4346,12 +4589,12 @@ var ExodusWallet = class extends BaseWallet {
4346
4589
  };
4347
4590
 
4348
4591
  // src/wallets/kibisis.ts
4349
- var import_algosdk4 = __toESM(require("algosdk"), 1);
4592
+ var import_algosdk5 = __toESM(require("algosdk"), 1);
4350
4593
  function isAVMWebProviderSDKError(error) {
4351
4594
  return typeof error === "object" && "code" in error && "message" in error;
4352
4595
  }
4353
4596
  var KIBISIS_AVM_WEB_PROVIDER_ID = "f6d1c86b-4493-42fb-b88d-a62407b4cdf6";
4354
- var ICON5 = `data:image/svg+xml;base64,${btoa(`
4597
+ var ICON6 = `data:image/svg+xml;base64,${btoa(`
4355
4598
  <svg viewBox="0 0 480 480" xmlns="http://www.w3.org/2000/svg">
4356
4599
  <rect fill="#801C96" width="480" height="480" />
4357
4600
  <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 +4617,7 @@ var KibisisWallet = class extends BaseWallet {
4374
4617
  }
4375
4618
  static defaultMetadata = {
4376
4619
  name: "Kibisis",
4377
- icon: ICON5
4620
+ icon: ICON6
4378
4621
  };
4379
4622
  /**
4380
4623
  * private functions
@@ -4666,7 +4909,7 @@ var KibisisWallet = class extends BaseWallet {
4666
4909
  const txnsToSign = [];
4667
4910
  txnGroup.forEach((txn, index) => {
4668
4911
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
4669
- const signer = import_algosdk4.default.encodeAddress(txn.from.publicKey);
4912
+ const signer = import_algosdk5.default.encodeAddress(txn.from.publicKey);
4670
4913
  const canSignTxn = this.addresses.includes(signer);
4671
4914
  const txnString = byteArrayToBase64(txn.toByte());
4672
4915
  if (isIndexMatch && canSignTxn) {
@@ -4680,11 +4923,11 @@ var KibisisWallet = class extends BaseWallet {
4680
4923
  processEncodedTxns(txnGroup, indexesToSign) {
4681
4924
  const txnsToSign = [];
4682
4925
  txnGroup.forEach((txnBuffer, index) => {
4683
- const txnDecodeObj = import_algosdk4.default.decodeObj(txnBuffer);
4926
+ const txnDecodeObj = import_algosdk5.default.decodeObj(txnBuffer);
4684
4927
  const isSigned = isSignedTxn(txnDecodeObj);
4685
- const txn = isSigned ? import_algosdk4.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk4.default.decodeUnsignedTransaction(txnBuffer);
4928
+ const txn = isSigned ? import_algosdk5.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk5.default.decodeUnsignedTransaction(txnBuffer);
4686
4929
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
4687
- const signer = import_algosdk4.default.encodeAddress(txn.from.publicKey);
4930
+ const signer = import_algosdk5.default.encodeAddress(txn.from.publicKey);
4688
4931
  const canSignTxn = !isSigned && this.addresses.includes(signer);
4689
4932
  const txnString = byteArrayToBase64(txn.toByte());
4690
4933
  if (isIndexMatch && canSignTxn) {
@@ -4728,8 +4971,8 @@ var KibisisWallet = class extends BaseWallet {
4728
4971
  };
4729
4972
 
4730
4973
  // src/wallets/kmd.ts
4731
- var import_algosdk5 = __toESM(require("algosdk"), 1);
4732
- var ICON6 = `data:image/svg+xml;base64,${btoa(`
4974
+ var import_algosdk6 = __toESM(require("algosdk"), 1);
4975
+ var ICON7 = `data:image/svg+xml;base64,${btoa(`
4733
4976
  <svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
4734
4977
  <linearGradient id="algokitGradient" gradientUnits="userSpaceOnUse" x1="0" y1="400" x2="400" y2="0">
4735
4978
  <stop offset="0" style="stop-color:#31D8EE"/>
@@ -4767,12 +5010,12 @@ var KmdWallet = class extends BaseWallet {
4767
5010
  }
4768
5011
  static defaultMetadata = {
4769
5012
  name: "KMD",
4770
- icon: ICON6
5013
+ icon: ICON7
4771
5014
  };
4772
5015
  async initializeClient() {
4773
5016
  this.logger.info("Initializing client...");
4774
5017
  const { token, baseServer, port } = this.options;
4775
- const client = new import_algosdk5.default.Kmd(token, baseServer, port);
5018
+ const client = new import_algosdk6.default.Kmd(token, baseServer, port);
4776
5019
  this.client = client;
4777
5020
  this.logger.info("Client initialized");
4778
5021
  return client;
@@ -4835,7 +5078,7 @@ var KmdWallet = class extends BaseWallet {
4835
5078
  const txnsToSign = [];
4836
5079
  txnGroup.forEach((txn, index) => {
4837
5080
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
4838
- const signer = import_algosdk5.default.encodeAddress(txn.from.publicKey);
5081
+ const signer = import_algosdk6.default.encodeAddress(txn.from.publicKey);
4839
5082
  const canSignTxn = this.addresses.includes(signer);
4840
5083
  if (isIndexMatch && canSignTxn) {
4841
5084
  txnsToSign.push(txn);
@@ -4846,11 +5089,11 @@ var KmdWallet = class extends BaseWallet {
4846
5089
  processEncodedTxns(txnGroup, indexesToSign) {
4847
5090
  const txnsToSign = [];
4848
5091
  txnGroup.forEach((txnBuffer, index) => {
4849
- const txnDecodeObj = import_algosdk5.default.decodeObj(txnBuffer);
5092
+ const txnDecodeObj = import_algosdk6.default.decodeObj(txnBuffer);
4850
5093
  const isSigned = isSignedTxn(txnDecodeObj);
4851
- const txn = isSigned ? import_algosdk5.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk5.default.decodeUnsignedTransaction(txnBuffer);
5094
+ const txn = isSigned ? import_algosdk6.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk6.default.decodeUnsignedTransaction(txnBuffer);
4852
5095
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
4853
- const signer = import_algosdk5.default.encodeAddress(txn.from.publicKey);
5096
+ const signer = import_algosdk6.default.encodeAddress(txn.from.publicKey);
4854
5097
  const canSignTxn = !isSigned && this.addresses.includes(signer);
4855
5098
  if (isIndexMatch && canSignTxn) {
4856
5099
  txnsToSign.push(txn);
@@ -4934,11 +5177,11 @@ var KmdWallet = class extends BaseWallet {
4934
5177
  };
4935
5178
 
4936
5179
  // src/wallets/lute.ts
4937
- var import_algosdk6 = __toESM(require("algosdk"), 1);
5180
+ var import_algosdk7 = __toESM(require("algosdk"), 1);
4938
5181
  function isSignTxnsError(error) {
4939
5182
  return error instanceof Error && "code" in error;
4940
5183
  }
4941
- var ICON7 = `data:image/svg+xml;base64,${btoa(`
5184
+ var ICON8 = `data:image/svg+xml;base64,${btoa(`
4942
5185
  <svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
4943
5186
  <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-7.1,8.8-9.9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-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
5187
  </svg>
@@ -4965,7 +5208,7 @@ var LuteWallet = class extends BaseWallet {
4965
5208
  }
4966
5209
  static defaultMetadata = {
4967
5210
  name: "Lute",
4968
- icon: ICON7
5211
+ icon: ICON8
4969
5212
  };
4970
5213
  async initializeClient() {
4971
5214
  this.logger.info("Initializing client...");
@@ -5032,7 +5275,7 @@ var LuteWallet = class extends BaseWallet {
5032
5275
  const txnsToSign = [];
5033
5276
  txnGroup.forEach((txn, index) => {
5034
5277
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5035
- const signer = import_algosdk6.default.encodeAddress(txn.from.publicKey);
5278
+ const signer = import_algosdk7.default.encodeAddress(txn.from.publicKey);
5036
5279
  const canSignTxn = this.addresses.includes(signer);
5037
5280
  const txnString = byteArrayToBase64(txn.toByte());
5038
5281
  if (isIndexMatch && canSignTxn) {
@@ -5046,11 +5289,11 @@ var LuteWallet = class extends BaseWallet {
5046
5289
  processEncodedTxns(txnGroup, indexesToSign) {
5047
5290
  const txnsToSign = [];
5048
5291
  txnGroup.forEach((txnBuffer, index) => {
5049
- const txnDecodeObj = import_algosdk6.default.decodeObj(txnBuffer);
5292
+ const txnDecodeObj = import_algosdk7.default.decodeObj(txnBuffer);
5050
5293
  const isSigned = isSignedTxn(txnDecodeObj);
5051
- const txn = isSigned ? import_algosdk6.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk6.default.decodeUnsignedTransaction(txnBuffer);
5294
+ const txn = isSigned ? import_algosdk7.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk7.default.decodeUnsignedTransaction(txnBuffer);
5052
5295
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5053
- const signer = import_algosdk6.default.encodeAddress(txn.from.publicKey);
5296
+ const signer = import_algosdk7.default.encodeAddress(txn.from.publicKey);
5054
5297
  const canSignTxn = !isSigned && this.addresses.includes(signer);
5055
5298
  const txnString = byteArrayToBase64(txn.toByte());
5056
5299
  if (isIndexMatch && canSignTxn) {
@@ -5089,8 +5332,8 @@ var LuteWallet = class extends BaseWallet {
5089
5332
  };
5090
5333
 
5091
5334
  // src/wallets/magic.ts
5092
- var import_algosdk7 = __toESM(require("algosdk"), 1);
5093
- var ICON8 = `data:image/svg+xml;base64,${btoa(`
5335
+ var import_algosdk8 = __toESM(require("algosdk"), 1);
5336
+ var ICON9 = `data:image/svg+xml;base64,${btoa(`
5094
5337
  <svg viewBox="0 0 47 47" xmlns="http://www.w3.org/2000/svg">
5095
5338
  <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
5339
  </svg>
@@ -5118,7 +5361,7 @@ var MagicAuth = class extends BaseWallet {
5118
5361
  }
5119
5362
  static defaultMetadata = {
5120
5363
  name: "Magic",
5121
- icon: ICON8
5364
+ icon: ICON9
5122
5365
  };
5123
5366
  async initializeClient() {
5124
5367
  this.logger.info("Initializing client...");
@@ -5236,7 +5479,7 @@ var MagicAuth = class extends BaseWallet {
5236
5479
  const txnsToSign = [];
5237
5480
  txnGroup.forEach((txn, index) => {
5238
5481
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5239
- const signer = import_algosdk7.default.encodeAddress(txn.from.publicKey);
5482
+ const signer = import_algosdk8.default.encodeAddress(txn.from.publicKey);
5240
5483
  const canSignTxn = this.addresses.includes(signer);
5241
5484
  const txnString = byteArrayToBase64(txn.toByte());
5242
5485
  if (isIndexMatch && canSignTxn) {
@@ -5250,11 +5493,11 @@ var MagicAuth = class extends BaseWallet {
5250
5493
  processEncodedTxns(txnGroup, indexesToSign) {
5251
5494
  const txnsToSign = [];
5252
5495
  txnGroup.forEach((txnBuffer, index) => {
5253
- const txnDecodeObj = import_algosdk7.default.decodeObj(txnBuffer);
5496
+ const txnDecodeObj = import_algosdk8.default.decodeObj(txnBuffer);
5254
5497
  const isSigned = isSignedTxn(txnDecodeObj);
5255
- const txn = isSigned ? import_algosdk7.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk7.default.decodeUnsignedTransaction(txnBuffer);
5498
+ const txn = isSigned ? import_algosdk8.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk8.default.decodeUnsignedTransaction(txnBuffer);
5256
5499
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5257
- const signer = import_algosdk7.default.encodeAddress(txn.from.publicKey);
5500
+ const signer = import_algosdk8.default.encodeAddress(txn.from.publicKey);
5258
5501
  const canSignTxn = !isSigned && this.addresses.includes(signer);
5259
5502
  const txnString = byteArrayToBase64(txn.toByte());
5260
5503
  if (isIndexMatch && canSignTxn) {
@@ -5298,9 +5541,9 @@ var MagicAuth = class extends BaseWallet {
5298
5541
  };
5299
5542
 
5300
5543
  // src/wallets/mnemonic.ts
5301
- var import_algosdk8 = __toESM(require("algosdk"), 1);
5544
+ var import_algosdk9 = __toESM(require("algosdk"), 1);
5302
5545
  var LOCAL_STORAGE_MNEMONIC_KEY = `${LOCAL_STORAGE_KEY}_mnemonic`;
5303
- var ICON9 = `data:image/svg+xml;base64,${btoa(`
5546
+ var ICON10 = `data:image/svg+xml;base64,${btoa(`
5304
5547
  <svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
5305
5548
  <rect fill="#525252" width="400" height="400" />
5306
5549
  <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 +5573,7 @@ var MnemonicWallet = class extends BaseWallet {
5330
5573
  }
5331
5574
  static defaultMetadata = {
5332
5575
  name: "Mnemonic",
5333
- icon: ICON9
5576
+ icon: ICON10
5334
5577
  };
5335
5578
  loadMnemonicFromStorage() {
5336
5579
  return StorageAdapter.getItem(LOCAL_STORAGE_MNEMONIC_KEY);
@@ -5366,7 +5609,7 @@ var MnemonicWallet = class extends BaseWallet {
5366
5609
  this.saveMnemonicToStorage(mnemonic);
5367
5610
  }
5368
5611
  }
5369
- const account = import_algosdk8.default.mnemonicToSecretKey(mnemonic);
5612
+ const account = import_algosdk9.default.mnemonicToSecretKey(mnemonic);
5370
5613
  this.account = account;
5371
5614
  return account;
5372
5615
  }
@@ -5410,7 +5653,7 @@ var MnemonicWallet = class extends BaseWallet {
5410
5653
  const txnsToSign = [];
5411
5654
  txnGroup.forEach((txn, index) => {
5412
5655
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5413
- const signer = import_algosdk8.default.encodeAddress(txn.from.publicKey);
5656
+ const signer = import_algosdk9.default.encodeAddress(txn.from.publicKey);
5414
5657
  const canSignTxn = signer === this.account.addr;
5415
5658
  if (isIndexMatch && canSignTxn) {
5416
5659
  txnsToSign.push(txn);
@@ -5421,11 +5664,11 @@ var MnemonicWallet = class extends BaseWallet {
5421
5664
  processEncodedTxns(txnGroup, indexesToSign) {
5422
5665
  const txnsToSign = [];
5423
5666
  txnGroup.forEach((txnBuffer, index) => {
5424
- const txnDecodeObj = import_algosdk8.default.decodeObj(txnBuffer);
5667
+ const txnDecodeObj = import_algosdk9.default.decodeObj(txnBuffer);
5425
5668
  const isSigned = isSignedTxn(txnDecodeObj);
5426
- const txn = isSigned ? import_algosdk8.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk8.default.decodeUnsignedTransaction(txnBuffer);
5669
+ const txn = isSigned ? import_algosdk9.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk9.default.decodeUnsignedTransaction(txnBuffer);
5427
5670
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5428
- const signer = import_algosdk8.default.encodeAddress(txn.from.publicKey);
5671
+ const signer = import_algosdk9.default.encodeAddress(txn.from.publicKey);
5429
5672
  const canSignTxn = !isSigned && signer === this.account.addr;
5430
5673
  if (isIndexMatch && canSignTxn) {
5431
5674
  txnsToSign.push(txn);
@@ -5456,8 +5699,8 @@ var MnemonicWallet = class extends BaseWallet {
5456
5699
  };
5457
5700
 
5458
5701
  // src/wallets/pera.ts
5459
- var import_algosdk9 = __toESM(require("algosdk"), 1);
5460
- var ICON10 = `data:image/svg+xml;base64,${btoa(`
5702
+ var import_algosdk10 = __toESM(require("algosdk"), 1);
5703
+ var ICON11 = `data:image/svg+xml;base64,${btoa(`
5461
5704
  <svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
5462
5705
  <rect fill="#FFEE55" width="200" height="200" />
5463
5706
  <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 +5729,7 @@ var PeraWallet = class extends BaseWallet {
5486
5729
  }
5487
5730
  static defaultMetadata = {
5488
5731
  name: "Pera",
5489
- icon: ICON10
5732
+ icon: ICON11
5490
5733
  };
5491
5734
  async initializeClient() {
5492
5735
  this.logger.info("Initializing client...");
@@ -5592,7 +5835,7 @@ var PeraWallet = class extends BaseWallet {
5592
5835
  const txnsToSign = [];
5593
5836
  txnGroup.forEach((txn, index) => {
5594
5837
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5595
- const signer = import_algosdk9.default.encodeAddress(txn.from.publicKey);
5838
+ const signer = import_algosdk10.default.encodeAddress(txn.from.publicKey);
5596
5839
  const canSignTxn = this.addresses.includes(signer);
5597
5840
  if (isIndexMatch && canSignTxn) {
5598
5841
  txnsToSign.push({ txn });
@@ -5605,11 +5848,11 @@ var PeraWallet = class extends BaseWallet {
5605
5848
  processEncodedTxns(txnGroup, indexesToSign) {
5606
5849
  const txnsToSign = [];
5607
5850
  txnGroup.forEach((txnBuffer, index) => {
5608
- const txnDecodeObj = import_algosdk9.default.decodeObj(txnBuffer);
5851
+ const txnDecodeObj = import_algosdk10.default.decodeObj(txnBuffer);
5609
5852
  const isSigned = isSignedTxn(txnDecodeObj);
5610
- const txn = isSigned ? import_algosdk9.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk9.default.decodeUnsignedTransaction(txnBuffer);
5853
+ const txn = isSigned ? import_algosdk10.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk10.default.decodeUnsignedTransaction(txnBuffer);
5611
5854
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5612
- const signer = import_algosdk9.default.encodeAddress(txn.from.publicKey);
5855
+ const signer = import_algosdk10.default.encodeAddress(txn.from.publicKey);
5613
5856
  const canSignTxn = !isSigned && this.addresses.includes(signer);
5614
5857
  if (isIndexMatch && canSignTxn) {
5615
5858
  txnsToSign.push({ txn });
@@ -5655,8 +5898,8 @@ var PeraWallet = class extends BaseWallet {
5655
5898
  };
5656
5899
 
5657
5900
  // src/wallets/pera2.ts
5658
- var import_algosdk10 = __toESM(require("algosdk"), 1);
5659
- var ICON11 = `data:image/svg+xml;base64,${btoa(`
5901
+ var import_algosdk11 = __toESM(require("algosdk"), 1);
5902
+ var ICON12 = `data:image/svg+xml;base64,${btoa(`
5660
5903
  <svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
5661
5904
  <rect fill="#FFEE55" width="200" height="200" />
5662
5905
  <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 +5932,7 @@ var PeraWallet2 = class extends BaseWallet {
5689
5932
  }
5690
5933
  static defaultMetadata = {
5691
5934
  name: "Pera",
5692
- icon: ICON11
5935
+ icon: ICON12
5693
5936
  };
5694
5937
  async initializeClient() {
5695
5938
  this.logger.info("Initializing client...");
@@ -5773,7 +6016,7 @@ var PeraWallet2 = class extends BaseWallet {
5773
6016
  const txnsToSign = [];
5774
6017
  txnGroup.forEach((txn, index) => {
5775
6018
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5776
- const signer = import_algosdk10.default.encodeAddress(txn.from.publicKey);
6019
+ const signer = import_algosdk11.default.encodeAddress(txn.from.publicKey);
5777
6020
  const canSignTxn = this.addresses.includes(signer);
5778
6021
  if (isIndexMatch && canSignTxn) {
5779
6022
  txnsToSign.push({ txn });
@@ -5786,11 +6029,11 @@ var PeraWallet2 = class extends BaseWallet {
5786
6029
  processEncodedTxns(txnGroup, indexesToSign) {
5787
6030
  const txnsToSign = [];
5788
6031
  txnGroup.forEach((txnBuffer, index) => {
5789
- const txnDecodeObj = import_algosdk10.default.decodeObj(txnBuffer);
6032
+ const txnDecodeObj = import_algosdk11.default.decodeObj(txnBuffer);
5790
6033
  const isSigned = isSignedTxn(txnDecodeObj);
5791
- const txn = isSigned ? import_algosdk10.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk10.default.decodeUnsignedTransaction(txnBuffer);
6034
+ const txn = isSigned ? import_algosdk11.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk11.default.decodeUnsignedTransaction(txnBuffer);
5792
6035
  const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
5793
- const signer = import_algosdk10.default.encodeAddress(txn.from.publicKey);
6036
+ const signer = import_algosdk11.default.encodeAddress(txn.from.publicKey);
5794
6037
  const canSignTxn = !isSigned && this.addresses.includes(signer);
5795
6038
  if (isIndexMatch && canSignTxn) {
5796
6039
  txnsToSign.push({ txn });
@@ -5938,242 +6181,6 @@ function deepMerge(target, source) {
5938
6181
  return target;
5939
6182
  }
5940
6183
 
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
6184
  // src/manager.ts
6178
6185
  var WalletManager = class {
6179
6186
  _clients = /* @__PURE__ */ new Map();