@txnlab/use-wallet 4.0.0-beta.1 → 4.0.0-beta.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 +720 -364
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +133 -66
- package/dist/index.d.ts +133 -66
- package/dist/index.js +718 -362
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -3267,9 +3267,11 @@ var src_exports = {};
|
|
|
3267
3267
|
__export(src_exports, {
|
|
3268
3268
|
BaseWallet: () => BaseWallet,
|
|
3269
3269
|
CustomWallet: () => CustomWallet,
|
|
3270
|
+
DEFAULT_NETWORKS: () => DEFAULT_NETWORKS,
|
|
3271
|
+
DEFAULT_STATE: () => DEFAULT_STATE,
|
|
3270
3272
|
DeflyWallet: () => DeflyWallet,
|
|
3271
3273
|
ExodusWallet: () => ExodusWallet,
|
|
3272
|
-
ICON: () =>
|
|
3274
|
+
ICON: () => ICON7,
|
|
3273
3275
|
KIBISIS_AVM_WEB_PROVIDER_ID: () => KIBISIS_AVM_WEB_PROVIDER_ID,
|
|
3274
3276
|
KibisisWallet: () => KibisisWallet,
|
|
3275
3277
|
KmdWallet: () => KmdWallet,
|
|
@@ -3286,8 +3288,6 @@ __export(src_exports, {
|
|
|
3286
3288
|
WalletConnect: () => WalletConnect,
|
|
3287
3289
|
WalletId: () => WalletId,
|
|
3288
3290
|
WalletManager: () => WalletManager,
|
|
3289
|
-
defaultState: () => defaultState,
|
|
3290
|
-
isAVMWebProviderSDKError: () => isAVMWebProviderSDKError,
|
|
3291
3291
|
webpackFallback: () => webpackFallback
|
|
3292
3292
|
});
|
|
3293
3293
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -3366,58 +3366,175 @@ var import_store14 = require("@tanstack/store");
|
|
|
3366
3366
|
var import_algosdk13 = __toESM(require("algosdk"), 1);
|
|
3367
3367
|
|
|
3368
3368
|
// src/network.ts
|
|
3369
|
+
var DEFAULT_NETWORKS = {
|
|
3370
|
+
mainnet: {
|
|
3371
|
+
name: "MainNet",
|
|
3372
|
+
algod: {
|
|
3373
|
+
token: "",
|
|
3374
|
+
baseServer: "https://mainnet-api.4160.nodely.dev",
|
|
3375
|
+
headers: {}
|
|
3376
|
+
},
|
|
3377
|
+
isTestnet: false,
|
|
3378
|
+
genesisHash: "wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=",
|
|
3379
|
+
genesisId: "mainnet-v1.0",
|
|
3380
|
+
caipChainId: "algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73k"
|
|
3381
|
+
},
|
|
3382
|
+
testnet: {
|
|
3383
|
+
name: "TestNet",
|
|
3384
|
+
algod: {
|
|
3385
|
+
token: "",
|
|
3386
|
+
baseServer: "https://testnet-api.4160.nodely.dev",
|
|
3387
|
+
headers: {}
|
|
3388
|
+
},
|
|
3389
|
+
isTestnet: true,
|
|
3390
|
+
genesisHash: "SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=",
|
|
3391
|
+
genesisId: "testnet-v1.0",
|
|
3392
|
+
caipChainId: "algorand:SGO1GKSzyE7IEPItTxCByw9x8FmnrCDe"
|
|
3393
|
+
},
|
|
3394
|
+
betanet: {
|
|
3395
|
+
name: "BetaNet",
|
|
3396
|
+
algod: {
|
|
3397
|
+
token: "",
|
|
3398
|
+
baseServer: "https://betanet-api.4160.nodely.dev",
|
|
3399
|
+
headers: {}
|
|
3400
|
+
},
|
|
3401
|
+
isTestnet: true,
|
|
3402
|
+
genesisHash: "mFgazF-2uRS1tMiL9dsj01hJGySEmPN2OvOTQHJ6iQg=",
|
|
3403
|
+
genesisId: "betanet-v1.0",
|
|
3404
|
+
caipChainId: "algorand:mFgazF-2uRS1tMiL9dsj01hJGySEmPN2"
|
|
3405
|
+
},
|
|
3406
|
+
fnet: {
|
|
3407
|
+
name: "FNet",
|
|
3408
|
+
algod: {
|
|
3409
|
+
token: "",
|
|
3410
|
+
baseServer: "https://fnet-api.4160.nodely.dev",
|
|
3411
|
+
headers: {}
|
|
3412
|
+
},
|
|
3413
|
+
isTestnet: true,
|
|
3414
|
+
genesisHash: "kUt08LxeVAAGHnh4JoAoAMM9ql_hBwSoRrQQKWSVgxk=",
|
|
3415
|
+
genesisId: "fnet-v1.0",
|
|
3416
|
+
caipChainId: "algorand:kUt08LxeVAAGHnh4JoAoAMM9ql_hBwSo"
|
|
3417
|
+
},
|
|
3418
|
+
localnet: {
|
|
3419
|
+
name: "LocalNet",
|
|
3420
|
+
algod: {
|
|
3421
|
+
token: "a".repeat(64),
|
|
3422
|
+
baseServer: "http://localhost",
|
|
3423
|
+
port: 4001,
|
|
3424
|
+
headers: {}
|
|
3425
|
+
},
|
|
3426
|
+
isTestnet: true
|
|
3427
|
+
}
|
|
3428
|
+
};
|
|
3429
|
+
var NetworkConfigBuilder = class {
|
|
3430
|
+
networks;
|
|
3431
|
+
constructor() {
|
|
3432
|
+
this.networks = new Map(Object.entries(DEFAULT_NETWORKS));
|
|
3433
|
+
}
|
|
3434
|
+
// Methods to customize default networks
|
|
3435
|
+
mainnet(config) {
|
|
3436
|
+
this.networks.set("mainnet", {
|
|
3437
|
+
...DEFAULT_NETWORKS.mainnet,
|
|
3438
|
+
...config,
|
|
3439
|
+
genesisHash: DEFAULT_NETWORKS.mainnet.genesisHash,
|
|
3440
|
+
genesisId: DEFAULT_NETWORKS.mainnet.genesisId,
|
|
3441
|
+
caipChainId: DEFAULT_NETWORKS.mainnet.caipChainId,
|
|
3442
|
+
algod: {
|
|
3443
|
+
...DEFAULT_NETWORKS.mainnet.algod,
|
|
3444
|
+
...config.algod || {}
|
|
3445
|
+
}
|
|
3446
|
+
});
|
|
3447
|
+
return this;
|
|
3448
|
+
}
|
|
3449
|
+
testnet(config) {
|
|
3450
|
+
this.networks.set("testnet", {
|
|
3451
|
+
...DEFAULT_NETWORKS.testnet,
|
|
3452
|
+
...config,
|
|
3453
|
+
genesisHash: DEFAULT_NETWORKS.testnet.genesisHash,
|
|
3454
|
+
genesisId: DEFAULT_NETWORKS.testnet.genesisId,
|
|
3455
|
+
caipChainId: DEFAULT_NETWORKS.testnet.caipChainId,
|
|
3456
|
+
algod: {
|
|
3457
|
+
...DEFAULT_NETWORKS.testnet.algod,
|
|
3458
|
+
...config.algod || {}
|
|
3459
|
+
}
|
|
3460
|
+
});
|
|
3461
|
+
return this;
|
|
3462
|
+
}
|
|
3463
|
+
betanet(config) {
|
|
3464
|
+
this.networks.set("betanet", {
|
|
3465
|
+
...DEFAULT_NETWORKS.betanet,
|
|
3466
|
+
...config,
|
|
3467
|
+
genesisHash: DEFAULT_NETWORKS.betanet.genesisHash,
|
|
3468
|
+
genesisId: DEFAULT_NETWORKS.betanet.genesisId,
|
|
3469
|
+
caipChainId: DEFAULT_NETWORKS.betanet.caipChainId,
|
|
3470
|
+
algod: {
|
|
3471
|
+
...DEFAULT_NETWORKS.betanet.algod,
|
|
3472
|
+
...config.algod || {}
|
|
3473
|
+
}
|
|
3474
|
+
});
|
|
3475
|
+
return this;
|
|
3476
|
+
}
|
|
3477
|
+
fnet(config) {
|
|
3478
|
+
this.networks.set("fnet", {
|
|
3479
|
+
...DEFAULT_NETWORKS.fnet,
|
|
3480
|
+
...config,
|
|
3481
|
+
genesisHash: DEFAULT_NETWORKS.fnet.genesisHash,
|
|
3482
|
+
genesisId: DEFAULT_NETWORKS.fnet.genesisId,
|
|
3483
|
+
caipChainId: DEFAULT_NETWORKS.fnet.caipChainId,
|
|
3484
|
+
algod: {
|
|
3485
|
+
...DEFAULT_NETWORKS.fnet.algod,
|
|
3486
|
+
...config.algod || {}
|
|
3487
|
+
}
|
|
3488
|
+
});
|
|
3489
|
+
return this;
|
|
3490
|
+
}
|
|
3491
|
+
localnet(config) {
|
|
3492
|
+
this.networks.set("localnet", {
|
|
3493
|
+
...DEFAULT_NETWORKS.localnet,
|
|
3494
|
+
...config,
|
|
3495
|
+
algod: {
|
|
3496
|
+
...DEFAULT_NETWORKS.localnet.algod,
|
|
3497
|
+
...config.algod || {}
|
|
3498
|
+
}
|
|
3499
|
+
});
|
|
3500
|
+
return this;
|
|
3501
|
+
}
|
|
3502
|
+
// Method to add custom networks (still needs full NetworkConfig)
|
|
3503
|
+
addNetwork(id, config) {
|
|
3504
|
+
if (DEFAULT_NETWORKS[id]) {
|
|
3505
|
+
throw new Error(
|
|
3506
|
+
`Cannot add network with reserved id "${id}". Use the ${id}() method instead.`
|
|
3507
|
+
);
|
|
3508
|
+
}
|
|
3509
|
+
this.networks.set(id, config);
|
|
3510
|
+
return this;
|
|
3511
|
+
}
|
|
3512
|
+
build() {
|
|
3513
|
+
return Object.fromEntries(this.networks);
|
|
3514
|
+
}
|
|
3515
|
+
};
|
|
3516
|
+
var createNetworkConfig = () => new NetworkConfigBuilder().build();
|
|
3517
|
+
function isValidToken(token) {
|
|
3518
|
+
if (typeof token === "string") return true;
|
|
3519
|
+
if (typeof token !== "object" || token === null) return false;
|
|
3520
|
+
if ("X-Algo-API-Token" in token && typeof token["X-Algo-API-Token"] === "string") return true;
|
|
3521
|
+
if ("get" in token && "post" in token && "delete" in token) return true;
|
|
3522
|
+
return Object.values(token).every((value) => typeof value === "string");
|
|
3523
|
+
}
|
|
3524
|
+
function isNetworkConfig(config) {
|
|
3525
|
+
if (typeof config !== "object" || config === null) return false;
|
|
3526
|
+
const { name, algod, isTestnet, genesisHash, genesisId, caipChainId } = config;
|
|
3527
|
+
const isValidAlgod = typeof algod === "object" && algod !== null && isValidToken(algod.token) && typeof algod.baseServer === "string";
|
|
3528
|
+
return typeof name === "string" && isValidAlgod && (isTestnet === void 0 || typeof isTestnet === "boolean") && (genesisHash === void 0 || typeof genesisHash === "string") && (genesisId === void 0 || typeof genesisId === "string") && (caipChainId === void 0 || typeof caipChainId === "string");
|
|
3529
|
+
}
|
|
3369
3530
|
var NetworkId = /* @__PURE__ */ ((NetworkId2) => {
|
|
3370
3531
|
NetworkId2["MAINNET"] = "mainnet";
|
|
3371
3532
|
NetworkId2["TESTNET"] = "testnet";
|
|
3372
3533
|
NetworkId2["BETANET"] = "betanet";
|
|
3373
3534
|
NetworkId2["FNET"] = "fnet";
|
|
3374
3535
|
NetworkId2["LOCALNET"] = "localnet";
|
|
3375
|
-
NetworkId2["VOIMAIN"] = "voimain";
|
|
3376
|
-
NetworkId2["ARAMIDMAIN"] = "aramidmain";
|
|
3377
3536
|
return NetworkId2;
|
|
3378
3537
|
})(NetworkId || {});
|
|
3379
|
-
function isValidNetworkId(networkId) {
|
|
3380
|
-
return Object.values(NetworkId).includes(networkId);
|
|
3381
|
-
}
|
|
3382
|
-
function isNetworkConfigMap(config) {
|
|
3383
|
-
const networkKeys = Object.values(NetworkId);
|
|
3384
|
-
return Object.keys(config).some((key) => networkKeys.includes(key));
|
|
3385
|
-
}
|
|
3386
|
-
var nodeServerMap = {
|
|
3387
|
-
["mainnet" /* MAINNET */]: "https://mainnet-api.4160.nodely.dev",
|
|
3388
|
-
["testnet" /* TESTNET */]: "https://testnet-api.4160.nodely.dev",
|
|
3389
|
-
["betanet" /* BETANET */]: "https://betanet-api.4160.nodely.dev",
|
|
3390
|
-
["fnet" /* FNET */]: "https://fnet-api.4160.nodely.dev",
|
|
3391
|
-
["voimain" /* VOIMAIN */]: "https://mainnet-api.voi.nodely.dev",
|
|
3392
|
-
["aramidmain" /* ARAMIDMAIN */]: "https://algod.aramidmain.a-wallet.net"
|
|
3393
|
-
};
|
|
3394
|
-
function createDefaultNetworkConfig() {
|
|
3395
|
-
const localnetConfig = {
|
|
3396
|
-
token: "a".repeat(64),
|
|
3397
|
-
baseServer: "http://localhost",
|
|
3398
|
-
port: 4001,
|
|
3399
|
-
headers: {}
|
|
3400
|
-
};
|
|
3401
|
-
return Object.values(NetworkId).reduce((configMap, value) => {
|
|
3402
|
-
const network = value;
|
|
3403
|
-
const isLocalnet = network === "localnet" /* LOCALNET */;
|
|
3404
|
-
configMap[network] = isLocalnet ? localnetConfig : {
|
|
3405
|
-
token: "",
|
|
3406
|
-
baseServer: nodeServerMap[network],
|
|
3407
|
-
port: "",
|
|
3408
|
-
headers: {}
|
|
3409
|
-
};
|
|
3410
|
-
return configMap;
|
|
3411
|
-
}, {});
|
|
3412
|
-
}
|
|
3413
|
-
var caipChainId = {
|
|
3414
|
-
["mainnet" /* MAINNET */]: "algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73k",
|
|
3415
|
-
["testnet" /* TESTNET */]: "algorand:SGO1GKSzyE7IEPItTxCByw9x8FmnrCDe",
|
|
3416
|
-
["betanet" /* BETANET */]: "algorand:mFgazF-2uRS1tMiL9dsj01hJGySEmPN2",
|
|
3417
|
-
["fnet" /* FNET */]: "algorand:kUt08LxeVAAGHnh4JoAoAMM9ql_hBwSo",
|
|
3418
|
-
["voimain" /* VOIMAIN */]: "algorand:r20fSQI8gWe_kFZziNonSPCXLwcQmH_n",
|
|
3419
|
-
["aramidmain" /* ARAMIDMAIN */]: "algorand:PgeQVJJgx_LYKJfIEz7dbfNPuXmDyJ-O"
|
|
3420
|
-
};
|
|
3421
3538
|
|
|
3422
3539
|
// src/storage.ts
|
|
3423
3540
|
var StorageAdapter = class {
|
|
@@ -3448,6 +3565,7 @@ var import_algosdk = __toESM(require("algosdk"), 1);
|
|
|
3448
3565
|
var WalletId = /* @__PURE__ */ ((WalletId2) => {
|
|
3449
3566
|
WalletId2["BIATEC"] = "biatec";
|
|
3450
3567
|
WalletId2["DEFLY"] = "defly";
|
|
3568
|
+
WalletId2["DEFLY_WEB"] = "defly-web";
|
|
3451
3569
|
WalletId2["CUSTOM"] = "custom";
|
|
3452
3570
|
WalletId2["EXODUS"] = "exodus";
|
|
3453
3571
|
WalletId2["KIBISIS"] = "kibisis";
|
|
@@ -3473,10 +3591,10 @@ var SignTxnsError = class extends Error {
|
|
|
3473
3591
|
};
|
|
3474
3592
|
|
|
3475
3593
|
// src/store.ts
|
|
3476
|
-
var
|
|
3594
|
+
var DEFAULT_STATE = {
|
|
3477
3595
|
wallets: {},
|
|
3478
3596
|
activeWallet: null,
|
|
3479
|
-
activeNetwork: "testnet"
|
|
3597
|
+
activeNetwork: "testnet",
|
|
3480
3598
|
algodClient: new import_algosdk.default.Algodv2("", "https://testnet-api.4160.nodely.dev/")
|
|
3481
3599
|
};
|
|
3482
3600
|
var LOCAL_STORAGE_KEY = "@txnlab/use-wallet:v3";
|
|
@@ -3590,7 +3708,7 @@ function isValidState(state) {
|
|
|
3590
3708
|
if (!isValidWalletId(walletId) || !isValidWalletState(wallet)) return false;
|
|
3591
3709
|
}
|
|
3592
3710
|
if (state.activeWallet !== null && !isValidWalletId(state.activeWallet)) return false;
|
|
3593
|
-
if (
|
|
3711
|
+
if (typeof state.activeNetwork !== "string") return false;
|
|
3594
3712
|
return true;
|
|
3595
3713
|
}
|
|
3596
3714
|
|
|
@@ -3604,6 +3722,7 @@ var import_algosdk2 = __toESM(require("algosdk"), 1);
|
|
|
3604
3722
|
var BaseWallet = class {
|
|
3605
3723
|
id;
|
|
3606
3724
|
metadata;
|
|
3725
|
+
networks;
|
|
3607
3726
|
store;
|
|
3608
3727
|
getAlgodClient;
|
|
3609
3728
|
subscribe;
|
|
@@ -3613,12 +3732,14 @@ var BaseWallet = class {
|
|
|
3613
3732
|
metadata,
|
|
3614
3733
|
store,
|
|
3615
3734
|
subscribe,
|
|
3616
|
-
getAlgodClient
|
|
3735
|
+
getAlgodClient,
|
|
3736
|
+
networks
|
|
3617
3737
|
}) {
|
|
3618
3738
|
this.id = id;
|
|
3619
3739
|
this.store = store;
|
|
3620
3740
|
this.subscribe = subscribe;
|
|
3621
3741
|
this.getAlgodClient = getAlgodClient;
|
|
3742
|
+
this.networks = networks;
|
|
3622
3743
|
const ctor = this.constructor;
|
|
3623
3744
|
this.metadata = { ...ctor.defaultMetadata, ...metadata };
|
|
3624
3745
|
this.logger = logger.createScopedLogger(`Wallet:${this.id.toUpperCase()}`);
|
|
@@ -3678,6 +3799,17 @@ var BaseWallet = class {
|
|
|
3678
3799
|
const state = this.store.state;
|
|
3679
3800
|
return state.activeWallet === this.id;
|
|
3680
3801
|
}
|
|
3802
|
+
// Make networks accessible for testing
|
|
3803
|
+
get networkConfig() {
|
|
3804
|
+
return this.networks;
|
|
3805
|
+
}
|
|
3806
|
+
get activeNetworkConfig() {
|
|
3807
|
+
const config = this.networks[this.activeNetwork];
|
|
3808
|
+
if (!config) {
|
|
3809
|
+
throw new Error(`No configuration found for network: ${this.activeNetwork}`);
|
|
3810
|
+
}
|
|
3811
|
+
return config;
|
|
3812
|
+
}
|
|
3681
3813
|
// ---------- Protected Methods ------------------------------------- //
|
|
3682
3814
|
onDisconnect = () => {
|
|
3683
3815
|
this.logger.debug(`Removing wallet from store...`);
|
|
@@ -3729,9 +3861,10 @@ var WalletConnect = class extends BaseWallet {
|
|
|
3729
3861
|
subscribe,
|
|
3730
3862
|
getAlgodClient,
|
|
3731
3863
|
options,
|
|
3732
|
-
metadata = {}
|
|
3864
|
+
metadata = {},
|
|
3865
|
+
networks
|
|
3733
3866
|
}) {
|
|
3734
|
-
super({ id, metadata, getAlgodClient, store, subscribe });
|
|
3867
|
+
super({ id, metadata, getAlgodClient, store, subscribe, networks });
|
|
3735
3868
|
if (!options?.projectId) {
|
|
3736
3869
|
this.logger.error("Missing required option: projectId");
|
|
3737
3870
|
throw new Error("Missing required option: projectId");
|
|
@@ -3953,12 +4086,12 @@ var WalletConnect = class extends BaseWallet {
|
|
|
3953
4086
|
return walletAccounts;
|
|
3954
4087
|
}
|
|
3955
4088
|
get activeChainId() {
|
|
3956
|
-
const
|
|
3957
|
-
if (!
|
|
4089
|
+
const network = this.networks[this.activeNetwork];
|
|
4090
|
+
if (!network?.caipChainId) {
|
|
3958
4091
|
this.logger.warn(`No CAIP-2 chain ID found for network: ${this.activeNetwork}`);
|
|
3959
4092
|
return "";
|
|
3960
4093
|
}
|
|
3961
|
-
return
|
|
4094
|
+
return network.caipChainId;
|
|
3962
4095
|
}
|
|
3963
4096
|
connect = async () => {
|
|
3964
4097
|
this.logger.info("Connecting...");
|
|
@@ -4149,10 +4282,11 @@ var CustomWallet = class extends BaseWallet {
|
|
|
4149
4282
|
store,
|
|
4150
4283
|
subscribe,
|
|
4151
4284
|
getAlgodClient,
|
|
4285
|
+
networks,
|
|
4152
4286
|
options,
|
|
4153
4287
|
metadata = {}
|
|
4154
4288
|
}) {
|
|
4155
|
-
super({ id, metadata, getAlgodClient, store, subscribe });
|
|
4289
|
+
super({ id, metadata, getAlgodClient, store, subscribe, networks });
|
|
4156
4290
|
if (!options?.provider) {
|
|
4157
4291
|
this.logger.error("Missing required option: provider");
|
|
4158
4292
|
throw new Error("Missing required option: provider");
|
|
@@ -4268,9 +4402,10 @@ var DeflyWallet = class extends BaseWallet {
|
|
|
4268
4402
|
subscribe,
|
|
4269
4403
|
getAlgodClient,
|
|
4270
4404
|
options = {},
|
|
4271
|
-
metadata = {}
|
|
4405
|
+
metadata = {},
|
|
4406
|
+
networks
|
|
4272
4407
|
}) {
|
|
4273
|
-
super({ id, metadata, getAlgodClient, store, subscribe });
|
|
4408
|
+
super({ id, metadata, getAlgodClient, store, subscribe, networks });
|
|
4274
4409
|
this.options = options;
|
|
4275
4410
|
this.store = store;
|
|
4276
4411
|
}
|
|
@@ -4444,9 +4579,408 @@ var DeflyWallet = class extends BaseWallet {
|
|
|
4444
4579
|
};
|
|
4445
4580
|
};
|
|
4446
4581
|
|
|
4447
|
-
// src/wallets/
|
|
4582
|
+
// src/wallets/avm-web-provider.ts
|
|
4448
4583
|
var import_algosdk4 = __toESM(require("algosdk"), 1);
|
|
4584
|
+
function isAVMWebProviderSDKError(error) {
|
|
4585
|
+
return typeof error === "object" && "code" in error && "message" in error;
|
|
4586
|
+
}
|
|
4587
|
+
var AVMProvider = class extends BaseWallet {
|
|
4588
|
+
avmWebClient = null;
|
|
4589
|
+
avmWebProviderSDK = null;
|
|
4590
|
+
providerId;
|
|
4591
|
+
constructor(args) {
|
|
4592
|
+
super(args);
|
|
4593
|
+
this.providerId = args.providerId;
|
|
4594
|
+
}
|
|
4595
|
+
async _initializeAVMWebProviderSDK() {
|
|
4596
|
+
if (!this.avmWebProviderSDK) {
|
|
4597
|
+
this.logger.info("Initializing @agoralabs-sh/avm-web-provider...");
|
|
4598
|
+
const module2 = await import("@agoralabs-sh/avm-web-provider");
|
|
4599
|
+
this.avmWebProviderSDK = module2.default ? module2.default : module2;
|
|
4600
|
+
if (!this.avmWebProviderSDK) {
|
|
4601
|
+
throw new Error(
|
|
4602
|
+
"Failed to initialize, the @agoralabs-sh/avm-web-provider SDK was not provided"
|
|
4603
|
+
);
|
|
4604
|
+
}
|
|
4605
|
+
if (!this.avmWebProviderSDK.AVMWebClient) {
|
|
4606
|
+
throw new Error(
|
|
4607
|
+
"Failed to initialize, AVMWebClient missing from @agoralabs-sh/avm-web-provider SDK"
|
|
4608
|
+
);
|
|
4609
|
+
}
|
|
4610
|
+
this.logger.info("@agoralabs-sh/avm-web-provider SDK initialized");
|
|
4611
|
+
}
|
|
4612
|
+
return this.avmWebProviderSDK;
|
|
4613
|
+
}
|
|
4614
|
+
async _initializeAVMWebClient() {
|
|
4615
|
+
const avmWebProviderSDK = await this._initializeAVMWebProviderSDK();
|
|
4616
|
+
if (!avmWebProviderSDK.AVMWebClient) {
|
|
4617
|
+
throw new Error("Failed to initialize, AVMWebClient not found");
|
|
4618
|
+
}
|
|
4619
|
+
if (!this.avmWebClient) {
|
|
4620
|
+
this.logger.info("Initializing new AVM Web Client...");
|
|
4621
|
+
this.avmWebClient = avmWebProviderSDK.AVMWebClient.init();
|
|
4622
|
+
this.logger.info("AVM Web Client initialized");
|
|
4623
|
+
}
|
|
4624
|
+
return this.avmWebClient;
|
|
4625
|
+
}
|
|
4626
|
+
async _getGenesisHash() {
|
|
4627
|
+
const network = this.activeNetworkConfig;
|
|
4628
|
+
if (network.genesisHash) {
|
|
4629
|
+
return network.genesisHash;
|
|
4630
|
+
}
|
|
4631
|
+
const algodClient = this.getAlgodClient();
|
|
4632
|
+
const version = await algodClient.versionsCheck().do();
|
|
4633
|
+
return import_algosdk4.default.bytesToBase64(version.genesisHashB64);
|
|
4634
|
+
}
|
|
4635
|
+
_mapAVMWebProviderAccountToWalletAccounts(accounts) {
|
|
4636
|
+
return accounts.map(({ address, name }, idx) => ({
|
|
4637
|
+
name: name || `[${this.metadata.name}] Account ${idx + 1}`,
|
|
4638
|
+
address
|
|
4639
|
+
}));
|
|
4640
|
+
}
|
|
4641
|
+
processTxns(txnGroup, indexesToSign) {
|
|
4642
|
+
const txnsToSign = [];
|
|
4643
|
+
txnGroup.forEach((txn, index) => {
|
|
4644
|
+
const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
|
|
4645
|
+
const signer = txn.sender.toString();
|
|
4646
|
+
const canSignTxn = this.addresses.includes(signer);
|
|
4647
|
+
const txnString = byteArrayToBase64(txn.toByte());
|
|
4648
|
+
if (isIndexMatch && canSignTxn) {
|
|
4649
|
+
txnsToSign.push({ txn: txnString });
|
|
4650
|
+
} else {
|
|
4651
|
+
txnsToSign.push({ txn: txnString, signers: [] });
|
|
4652
|
+
}
|
|
4653
|
+
});
|
|
4654
|
+
return txnsToSign;
|
|
4655
|
+
}
|
|
4656
|
+
processEncodedTxns(txnGroup, indexesToSign) {
|
|
4657
|
+
const txnsToSign = [];
|
|
4658
|
+
txnGroup.forEach((txnBuffer, index) => {
|
|
4659
|
+
const decodedObj = import_algosdk4.default.msgpackRawDecode(txnBuffer);
|
|
4660
|
+
const isSigned = isSignedTxn(decodedObj);
|
|
4661
|
+
const txn = isSigned ? import_algosdk4.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk4.default.decodeUnsignedTransaction(txnBuffer);
|
|
4662
|
+
const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
|
|
4663
|
+
const signer = txn.sender.toString();
|
|
4664
|
+
const canSignTxn = !isSigned && this.addresses.includes(signer);
|
|
4665
|
+
const txnString = byteArrayToBase64(txn.toByte());
|
|
4666
|
+
if (isIndexMatch && canSignTxn) {
|
|
4667
|
+
txnsToSign.push({ txn: txnString });
|
|
4668
|
+
} else {
|
|
4669
|
+
txnsToSign.push({ txn: txnString, signers: [] });
|
|
4670
|
+
}
|
|
4671
|
+
});
|
|
4672
|
+
return txnsToSign;
|
|
4673
|
+
}
|
|
4674
|
+
/**
|
|
4675
|
+
* Common methods
|
|
4676
|
+
* These methods can be overridden by specific wallet providers if needed
|
|
4677
|
+
*/
|
|
4678
|
+
async connect() {
|
|
4679
|
+
try {
|
|
4680
|
+
this.logger.info("Connecting...");
|
|
4681
|
+
const result = await this._enable();
|
|
4682
|
+
this.logger.info(`Successfully connected on network "${result.genesisId}"`);
|
|
4683
|
+
const walletAccounts = this._mapAVMWebProviderAccountToWalletAccounts(result.accounts);
|
|
4684
|
+
const walletState = {
|
|
4685
|
+
accounts: walletAccounts,
|
|
4686
|
+
activeAccount: walletAccounts[0]
|
|
4687
|
+
};
|
|
4688
|
+
addWallet(this.store, {
|
|
4689
|
+
walletId: this.id,
|
|
4690
|
+
wallet: walletState
|
|
4691
|
+
});
|
|
4692
|
+
this.logger.info("\u2705 Connected.", walletState);
|
|
4693
|
+
return walletAccounts;
|
|
4694
|
+
} catch (error) {
|
|
4695
|
+
this.logger.error(
|
|
4696
|
+
"Error connecting: ",
|
|
4697
|
+
isAVMWebProviderSDKError(error) ? `${error.message} (code: ${error.code})` : error.message
|
|
4698
|
+
);
|
|
4699
|
+
throw error;
|
|
4700
|
+
}
|
|
4701
|
+
}
|
|
4702
|
+
async disconnect() {
|
|
4703
|
+
try {
|
|
4704
|
+
this.logger.info("Disconnecting...");
|
|
4705
|
+
this.onDisconnect();
|
|
4706
|
+
const result = await this._disable();
|
|
4707
|
+
this.logger.info(
|
|
4708
|
+
`Successfully disconnected${result.sessionIds && result.sessionIds.length ? ` sessions [${result.sessionIds.join(",")}]` : ""} on network "${result.genesisId}"`
|
|
4709
|
+
);
|
|
4710
|
+
} catch (error) {
|
|
4711
|
+
this.logger.error(
|
|
4712
|
+
"Error disconnecting: ",
|
|
4713
|
+
isAVMWebProviderSDKError(error) ? `${error.message} (code: ${error.code})` : error.message
|
|
4714
|
+
);
|
|
4715
|
+
throw error;
|
|
4716
|
+
}
|
|
4717
|
+
}
|
|
4718
|
+
async resumeSession() {
|
|
4719
|
+
const state = this.store.state;
|
|
4720
|
+
const walletState = state.wallets[this.id];
|
|
4721
|
+
if (!walletState) {
|
|
4722
|
+
this.logger.info("No session to resume");
|
|
4723
|
+
return;
|
|
4724
|
+
}
|
|
4725
|
+
try {
|
|
4726
|
+
this.logger.info("Resuming session...");
|
|
4727
|
+
const result = await this._enable();
|
|
4728
|
+
if (result.accounts.length === 0) {
|
|
4729
|
+
throw new Error("No accounts found!");
|
|
4730
|
+
}
|
|
4731
|
+
const walletAccounts = this._mapAVMWebProviderAccountToWalletAccounts(result.accounts);
|
|
4732
|
+
const match = compareAccounts(walletAccounts, walletState.accounts);
|
|
4733
|
+
if (!match) {
|
|
4734
|
+
this.logger.warn("Session accounts mismatch, updating accounts", {
|
|
4735
|
+
prev: walletState.accounts,
|
|
4736
|
+
current: walletAccounts
|
|
4737
|
+
});
|
|
4738
|
+
setAccounts(this.store, {
|
|
4739
|
+
walletId: this.id,
|
|
4740
|
+
accounts: walletAccounts
|
|
4741
|
+
});
|
|
4742
|
+
}
|
|
4743
|
+
this.logger.info("Session resumed successfully");
|
|
4744
|
+
} catch (error) {
|
|
4745
|
+
this.logger.error(
|
|
4746
|
+
"Error resuming session: ",
|
|
4747
|
+
isAVMWebProviderSDKError(error) ? `${error.message} (code: ${error.code})` : error.message
|
|
4748
|
+
);
|
|
4749
|
+
this.onDisconnect();
|
|
4750
|
+
throw error;
|
|
4751
|
+
}
|
|
4752
|
+
}
|
|
4753
|
+
async signTransactions(txnGroup, indexesToSign) {
|
|
4754
|
+
try {
|
|
4755
|
+
this.logger.debug("Signing transactions...", { txnGroup, indexesToSign });
|
|
4756
|
+
let txnsToSign = [];
|
|
4757
|
+
if (isTransactionArray(txnGroup)) {
|
|
4758
|
+
const flatTxns = flattenTxnGroup(txnGroup);
|
|
4759
|
+
txnsToSign = this.processTxns(flatTxns, indexesToSign);
|
|
4760
|
+
} else {
|
|
4761
|
+
const flatTxns = flattenTxnGroup(txnGroup);
|
|
4762
|
+
txnsToSign = this.processEncodedTxns(flatTxns, indexesToSign);
|
|
4763
|
+
}
|
|
4764
|
+
this.logger.debug("Sending processed transactions to wallet...", txnsToSign);
|
|
4765
|
+
const signTxnsResult = await this._signTransactions(txnsToSign);
|
|
4766
|
+
this.logger.debug("Received signed transactions from wallet", signTxnsResult);
|
|
4767
|
+
const result = signTxnsResult.stxns.map((value) => {
|
|
4768
|
+
if (value === null) {
|
|
4769
|
+
return null;
|
|
4770
|
+
}
|
|
4771
|
+
return base64ToByteArray(value);
|
|
4772
|
+
});
|
|
4773
|
+
this.logger.debug("Transactions signed successfully", result);
|
|
4774
|
+
return result;
|
|
4775
|
+
} catch (error) {
|
|
4776
|
+
this.logger.error(
|
|
4777
|
+
"Error signing transactions: ",
|
|
4778
|
+
isAVMWebProviderSDKError(error) ? `${error.message} (code: ${error.code})` : error.message
|
|
4779
|
+
);
|
|
4780
|
+
throw error;
|
|
4781
|
+
}
|
|
4782
|
+
}
|
|
4783
|
+
};
|
|
4784
|
+
|
|
4785
|
+
// src/wallets/defly-web.ts
|
|
4786
|
+
var DEFLY_WEB_PROVIDER_ID = "95426e60-5f2e-49e9-b912-c488577be962";
|
|
4449
4787
|
var ICON5 = `data:image/svg+xml;base64,${btoa(`
|
|
4788
|
+
<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
|
|
4789
|
+
<rect width="1024" height="1024" />
|
|
4790
|
+
<path fill="#FFFFFF" d="M779.9,684.4L512,230L244.1,684.4L512,529.5L779.9,684.4z" />
|
|
4791
|
+
<path fill="#FFFFFF" d="M733.1,730L512,613.5L290.9,730L512,658L733.1,730z" />
|
|
4792
|
+
</svg>
|
|
4793
|
+
`)}`;
|
|
4794
|
+
var DeflyWebWallet = class extends AVMProvider {
|
|
4795
|
+
constructor({
|
|
4796
|
+
id,
|
|
4797
|
+
store,
|
|
4798
|
+
subscribe,
|
|
4799
|
+
getAlgodClient,
|
|
4800
|
+
metadata = {},
|
|
4801
|
+
networks
|
|
4802
|
+
}) {
|
|
4803
|
+
super({
|
|
4804
|
+
id,
|
|
4805
|
+
metadata,
|
|
4806
|
+
getAlgodClient,
|
|
4807
|
+
store,
|
|
4808
|
+
subscribe,
|
|
4809
|
+
networks,
|
|
4810
|
+
providerId: DEFLY_WEB_PROVIDER_ID
|
|
4811
|
+
});
|
|
4812
|
+
}
|
|
4813
|
+
static defaultMetadata = {
|
|
4814
|
+
name: "Defly Web Wallet",
|
|
4815
|
+
icon: ICON5
|
|
4816
|
+
};
|
|
4817
|
+
/**
|
|
4818
|
+
* Calls the "enable" method on the provider. This method will timeout after 3 minutes.
|
|
4819
|
+
* @returns {Promise<AVMWebProviderSDK.IEnableResult>} a promise that resolves to the result.
|
|
4820
|
+
* @protected
|
|
4821
|
+
* @throws {MethodCanceledError} if the method was cancelled by the user.
|
|
4822
|
+
* @throws {MethodNotSupportedError} if the method is not supported for the configured network.
|
|
4823
|
+
* @throws {MethodTimedOutError} if the method timed out by lack of response (>= 3 minutes).
|
|
4824
|
+
* @throws {NetworkNotSupportedError} if the network is not supported for the configured network.
|
|
4825
|
+
* @throws {UnknownError} if the response result is empty.
|
|
4826
|
+
*/
|
|
4827
|
+
async _enable() {
|
|
4828
|
+
const {
|
|
4829
|
+
ARC0027MethodEnum,
|
|
4830
|
+
ARC0027MethodTimedOutError,
|
|
4831
|
+
ARC0027UnknownError,
|
|
4832
|
+
DEFAULT_REQUEST_TIMEOUT
|
|
4833
|
+
} = await this._initializeAVMWebProviderSDK();
|
|
4834
|
+
const avmWebClient = await this._initializeAVMWebClient();
|
|
4835
|
+
const genesisHash = await this._getGenesisHash();
|
|
4836
|
+
return new Promise((resolve, reject) => {
|
|
4837
|
+
const timerId = window.setTimeout(() => {
|
|
4838
|
+
avmWebClient.removeListener(listenerId);
|
|
4839
|
+
reject(
|
|
4840
|
+
new ARC0027MethodTimedOutError({
|
|
4841
|
+
method: ARC0027MethodEnum.Enable,
|
|
4842
|
+
message: `no response from provider "${this.metadata.name}"`,
|
|
4843
|
+
providerId: DEFLY_WEB_PROVIDER_ID
|
|
4844
|
+
})
|
|
4845
|
+
);
|
|
4846
|
+
}, DEFAULT_REQUEST_TIMEOUT);
|
|
4847
|
+
const listenerId = avmWebClient.onEnable(({ error, method, result }) => {
|
|
4848
|
+
avmWebClient.removeListener(listenerId);
|
|
4849
|
+
window.clearTimeout(timerId);
|
|
4850
|
+
if (error) {
|
|
4851
|
+
return reject(error);
|
|
4852
|
+
}
|
|
4853
|
+
if (!result) {
|
|
4854
|
+
return reject(
|
|
4855
|
+
new ARC0027UnknownError({
|
|
4856
|
+
message: `received response, but "${method}" request details were empty for provider "${this.metadata.name}"`,
|
|
4857
|
+
providerId: DEFLY_WEB_PROVIDER_ID
|
|
4858
|
+
})
|
|
4859
|
+
);
|
|
4860
|
+
}
|
|
4861
|
+
return resolve(result);
|
|
4862
|
+
});
|
|
4863
|
+
avmWebClient.enable({
|
|
4864
|
+
genesisHash,
|
|
4865
|
+
providerId: DEFLY_WEB_PROVIDER_ID
|
|
4866
|
+
});
|
|
4867
|
+
});
|
|
4868
|
+
}
|
|
4869
|
+
/**
|
|
4870
|
+
* Calls the "disable" method on the provider. This method will timeout after 0.75 seconds.
|
|
4871
|
+
* @returns {Promise<AVMWebProviderSDK.IDisableResult>} a promise that resolves to the result.
|
|
4872
|
+
* @protected
|
|
4873
|
+
* @throws {MethodNotSupportedError} if the method is not supported for the configured network.
|
|
4874
|
+
* @throws {MethodTimedOutError} if the method timed out by lack of response (>= 3 minutes).
|
|
4875
|
+
* @throws {NetworkNotSupportedError} if the network is not supported for the configured network.
|
|
4876
|
+
* @throws {UnknownError} if the response result is empty.
|
|
4877
|
+
*/
|
|
4878
|
+
async _disable() {
|
|
4879
|
+
const {
|
|
4880
|
+
ARC0027MethodEnum,
|
|
4881
|
+
ARC0027MethodTimedOutError,
|
|
4882
|
+
ARC0027UnknownError,
|
|
4883
|
+
LOWER_REQUEST_TIMEOUT
|
|
4884
|
+
} = await this._initializeAVMWebProviderSDK();
|
|
4885
|
+
const avmWebClient = await this._initializeAVMWebClient();
|
|
4886
|
+
const genesisHash = await this._getGenesisHash();
|
|
4887
|
+
return new Promise((resolve, reject) => {
|
|
4888
|
+
const timerId = window.setTimeout(() => {
|
|
4889
|
+
avmWebClient.removeListener(listenerId);
|
|
4890
|
+
reject(
|
|
4891
|
+
new ARC0027MethodTimedOutError({
|
|
4892
|
+
method: ARC0027MethodEnum.Disable,
|
|
4893
|
+
message: `no response from provider "${this.metadata.name}"`,
|
|
4894
|
+
providerId: DEFLY_WEB_PROVIDER_ID
|
|
4895
|
+
})
|
|
4896
|
+
);
|
|
4897
|
+
}, LOWER_REQUEST_TIMEOUT);
|
|
4898
|
+
const listenerId = avmWebClient.onDisable(({ error, method, result }) => {
|
|
4899
|
+
avmWebClient.removeListener(listenerId);
|
|
4900
|
+
window.clearTimeout(timerId);
|
|
4901
|
+
if (error) {
|
|
4902
|
+
return reject(error);
|
|
4903
|
+
}
|
|
4904
|
+
if (!result) {
|
|
4905
|
+
return reject(
|
|
4906
|
+
new ARC0027UnknownError({
|
|
4907
|
+
message: `received response, but "${method}" request details were empty for provider "${this.metadata.name}"`,
|
|
4908
|
+
providerId: DEFLY_WEB_PROVIDER_ID
|
|
4909
|
+
})
|
|
4910
|
+
);
|
|
4911
|
+
}
|
|
4912
|
+
this.logger.debug("Disable successful", { result });
|
|
4913
|
+
return resolve(result);
|
|
4914
|
+
});
|
|
4915
|
+
this.logger.debug("Sending disable request...", { genesisHash });
|
|
4916
|
+
avmWebClient.disable({
|
|
4917
|
+
genesisHash,
|
|
4918
|
+
providerId: DEFLY_WEB_PROVIDER_ID
|
|
4919
|
+
});
|
|
4920
|
+
});
|
|
4921
|
+
}
|
|
4922
|
+
/**
|
|
4923
|
+
* Calls the "signTransactions" method to sign the supplied ARC-0001 transactions. This method will timeout after 3
|
|
4924
|
+
* minutes.
|
|
4925
|
+
* @returns {Promise<AVMWebProviderSDK.ISignTransactionsResult>} a promise that resolves to the result.
|
|
4926
|
+
* @protected
|
|
4927
|
+
* @throws {InvalidInputError} if computed group ID for the txns does not match the assigned group ID.
|
|
4928
|
+
* @throws {InvalidGroupIdError} if the unsigned txns is malformed or not conforming to ARC-0001.
|
|
4929
|
+
* @throws {MethodCanceledError} if the method was cancelled by the user.
|
|
4930
|
+
* @throws {MethodNotSupportedError} if the method is not supported for the configured network.
|
|
4931
|
+
* @throws {MethodTimedOutError} if the method timed out by lack of response (>= 3 minutes).
|
|
4932
|
+
* @throws {NetworkNotSupportedError} if the network is not supported for the configured network.
|
|
4933
|
+
* @throws {UnauthorizedSignerError} if a signer in the request is not authorized by the provider.
|
|
4934
|
+
* @throws {UnknownError} if the response result is empty.
|
|
4935
|
+
*/
|
|
4936
|
+
async _signTransactions(txns) {
|
|
4937
|
+
const {
|
|
4938
|
+
ARC0027MethodEnum,
|
|
4939
|
+
ARC0027MethodTimedOutError,
|
|
4940
|
+
ARC0027UnknownError,
|
|
4941
|
+
DEFAULT_REQUEST_TIMEOUT
|
|
4942
|
+
} = await this._initializeAVMWebProviderSDK();
|
|
4943
|
+
const avmWebClient = await this._initializeAVMWebClient();
|
|
4944
|
+
return new Promise((resolve, reject) => {
|
|
4945
|
+
const timerId = window.setTimeout(() => {
|
|
4946
|
+
avmWebClient.removeListener(listenerId);
|
|
4947
|
+
reject(
|
|
4948
|
+
new ARC0027MethodTimedOutError({
|
|
4949
|
+
method: ARC0027MethodEnum.SignTransactions,
|
|
4950
|
+
message: `no response from provider "${this.metadata.name}"`,
|
|
4951
|
+
providerId: DEFLY_WEB_PROVIDER_ID
|
|
4952
|
+
})
|
|
4953
|
+
);
|
|
4954
|
+
}, DEFAULT_REQUEST_TIMEOUT);
|
|
4955
|
+
const listenerId = avmWebClient.onSignTransactions(({ error, method, result }) => {
|
|
4956
|
+
avmWebClient.removeListener(listenerId);
|
|
4957
|
+
window.clearTimeout(timerId);
|
|
4958
|
+
if (error) {
|
|
4959
|
+
return reject(error);
|
|
4960
|
+
}
|
|
4961
|
+
if (!result) {
|
|
4962
|
+
return reject(
|
|
4963
|
+
new ARC0027UnknownError({
|
|
4964
|
+
message: `received response, but "${method}" request details were empty for provider "${this.metadata.name}"`,
|
|
4965
|
+
providerId: DEFLY_WEB_PROVIDER_ID
|
|
4966
|
+
})
|
|
4967
|
+
);
|
|
4968
|
+
}
|
|
4969
|
+
this.logger.debug("Sign transactions successful", { result });
|
|
4970
|
+
return resolve(result);
|
|
4971
|
+
});
|
|
4972
|
+
this.logger.debug("Sending sign transactions request...", { txns });
|
|
4973
|
+
avmWebClient.signTransactions({
|
|
4974
|
+
txns,
|
|
4975
|
+
providerId: DEFLY_WEB_PROVIDER_ID
|
|
4976
|
+
});
|
|
4977
|
+
});
|
|
4978
|
+
}
|
|
4979
|
+
};
|
|
4980
|
+
|
|
4981
|
+
// src/wallets/exodus.ts
|
|
4982
|
+
var import_algosdk5 = __toESM(require("algosdk"), 1);
|
|
4983
|
+
var ICON6 = `data:image/svg+xml;base64,${btoa(`
|
|
4450
4984
|
<svg viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg">
|
|
4451
4985
|
<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)">
|
|
4452
4986
|
<stop offset="0" stop-color="#0B46F9" />
|
|
@@ -4482,15 +5016,16 @@ var ExodusWallet = class extends BaseWallet {
|
|
|
4482
5016
|
subscribe,
|
|
4483
5017
|
getAlgodClient,
|
|
4484
5018
|
options = {},
|
|
4485
|
-
metadata = {}
|
|
5019
|
+
metadata = {},
|
|
5020
|
+
networks
|
|
4486
5021
|
}) {
|
|
4487
|
-
super({ id, metadata, getAlgodClient, store, subscribe });
|
|
5022
|
+
super({ id, metadata, getAlgodClient, store, subscribe, networks });
|
|
4488
5023
|
this.options = options;
|
|
4489
5024
|
this.store = store;
|
|
4490
5025
|
}
|
|
4491
5026
|
static defaultMetadata = {
|
|
4492
5027
|
name: "Exodus",
|
|
4493
|
-
icon:
|
|
5028
|
+
icon: ICON6
|
|
4494
5029
|
};
|
|
4495
5030
|
async initializeClient() {
|
|
4496
5031
|
this.logger.info("Initializing client...");
|
|
@@ -4571,9 +5106,9 @@ var ExodusWallet = class extends BaseWallet {
|
|
|
4571
5106
|
processEncodedTxns(txnGroup, indexesToSign) {
|
|
4572
5107
|
const txnsToSign = [];
|
|
4573
5108
|
txnGroup.forEach((txnBuffer, index) => {
|
|
4574
|
-
const decodedObj =
|
|
5109
|
+
const decodedObj = import_algosdk5.default.msgpackRawDecode(txnBuffer);
|
|
4575
5110
|
const isSigned = isSignedTxn(decodedObj);
|
|
4576
|
-
const txn = isSigned ?
|
|
5111
|
+
const txn = isSigned ? import_algosdk5.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk5.default.decodeUnsignedTransaction(txnBuffer);
|
|
4577
5112
|
const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
|
|
4578
5113
|
const signer = txn.sender.toString();
|
|
4579
5114
|
const canSignTxn = !isSigned && this.addresses.includes(signer);
|
|
@@ -4617,69 +5152,68 @@ var ExodusWallet = class extends BaseWallet {
|
|
|
4617
5152
|
};
|
|
4618
5153
|
|
|
4619
5154
|
// src/wallets/kibisis.ts
|
|
4620
|
-
var import_algosdk5 = __toESM(require("algosdk"), 1);
|
|
4621
|
-
function isAVMWebProviderSDKError(error) {
|
|
4622
|
-
return typeof error === "object" && "code" in error && "message" in error;
|
|
4623
|
-
}
|
|
4624
5155
|
var KIBISIS_AVM_WEB_PROVIDER_ID = "f6d1c86b-4493-42fb-b88d-a62407b4cdf6";
|
|
4625
|
-
var
|
|
5156
|
+
var ICON7 = `data:image/svg+xml;base64,${btoa(`
|
|
4626
5157
|
<svg viewBox="0 0 480 480" xmlns="http://www.w3.org/2000/svg">
|
|
4627
5158
|
<rect fill="#801C96" width="480" height="480" />
|
|
4628
5159
|
<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" />
|
|
4629
5160
|
<path fill="#FFFFFF" d="M158.1,359.8h19.7V245.5c-6.1-5.4-12.7-10-19.7-14V359.8z" />
|
|
4630
5161
|
</svg>
|
|
4631
5162
|
`)}`;
|
|
4632
|
-
var KibisisWallet = class extends
|
|
4633
|
-
avmWebClient = null;
|
|
4634
|
-
avmWebProviderSDK = null;
|
|
4635
|
-
store;
|
|
5163
|
+
var KibisisWallet = class extends AVMProvider {
|
|
4636
5164
|
constructor({
|
|
4637
5165
|
id,
|
|
4638
5166
|
store,
|
|
4639
5167
|
subscribe,
|
|
4640
5168
|
getAlgodClient,
|
|
4641
|
-
metadata = {}
|
|
5169
|
+
metadata = {},
|
|
5170
|
+
networks
|
|
4642
5171
|
}) {
|
|
4643
|
-
super({
|
|
4644
|
-
|
|
5172
|
+
super({
|
|
5173
|
+
id,
|
|
5174
|
+
metadata,
|
|
5175
|
+
getAlgodClient,
|
|
5176
|
+
store,
|
|
5177
|
+
subscribe,
|
|
5178
|
+
networks,
|
|
5179
|
+
providerId: KIBISIS_AVM_WEB_PROVIDER_ID
|
|
5180
|
+
});
|
|
4645
5181
|
}
|
|
4646
5182
|
static defaultMetadata = {
|
|
4647
5183
|
name: "Kibisis",
|
|
4648
|
-
icon:
|
|
5184
|
+
icon: ICON7
|
|
4649
5185
|
};
|
|
4650
5186
|
/**
|
|
4651
|
-
*
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
*
|
|
4655
|
-
* @returns {Promise<AVMWebProviderSDK.IDisableResult>} a promise that resolves to the result.
|
|
4656
|
-
* @private
|
|
5187
|
+
* Calls the "enable" method on the provider. This method will timeout after 3 minutes.
|
|
5188
|
+
* @returns {Promise<AVMWebProviderSDK.IEnableResult>} a promise that resolves to the result.
|
|
5189
|
+
* @protected
|
|
5190
|
+
* @throws {MethodCanceledError} if the method was cancelled by the user.
|
|
4657
5191
|
* @throws {MethodNotSupportedError} if the method is not supported for the configured network.
|
|
4658
5192
|
* @throws {MethodTimedOutError} if the method timed out by lack of response (>= 3 minutes).
|
|
4659
5193
|
* @throws {NetworkNotSupportedError} if the network is not supported for the configured network.
|
|
4660
5194
|
* @throws {UnknownError} if the response result is empty.
|
|
4661
5195
|
*/
|
|
4662
|
-
async
|
|
5196
|
+
async _enable() {
|
|
4663
5197
|
const {
|
|
4664
5198
|
ARC0027MethodEnum,
|
|
4665
5199
|
ARC0027MethodTimedOutError,
|
|
4666
5200
|
ARC0027UnknownError,
|
|
4667
|
-
|
|
4668
|
-
} =
|
|
4669
|
-
const avmWebClient =
|
|
5201
|
+
DEFAULT_REQUEST_TIMEOUT
|
|
5202
|
+
} = await this._initializeAVMWebProviderSDK();
|
|
5203
|
+
const avmWebClient = await this._initializeAVMWebClient();
|
|
4670
5204
|
const genesisHash = await this._getGenesisHash();
|
|
4671
5205
|
return new Promise((resolve, reject) => {
|
|
4672
5206
|
const timerId = window.setTimeout(() => {
|
|
4673
5207
|
avmWebClient.removeListener(listenerId);
|
|
4674
5208
|
reject(
|
|
4675
5209
|
new ARC0027MethodTimedOutError({
|
|
4676
|
-
method: ARC0027MethodEnum.
|
|
5210
|
+
method: ARC0027MethodEnum.Enable,
|
|
4677
5211
|
message: `no response from provider "${this.metadata.name}"`,
|
|
4678
5212
|
providerId: KIBISIS_AVM_WEB_PROVIDER_ID
|
|
4679
5213
|
})
|
|
4680
5214
|
);
|
|
4681
|
-
},
|
|
4682
|
-
const listenerId = avmWebClient.
|
|
5215
|
+
}, DEFAULT_REQUEST_TIMEOUT);
|
|
5216
|
+
const listenerId = avmWebClient.onEnable(({ error, method, result }) => {
|
|
4683
5217
|
avmWebClient.removeListener(listenerId);
|
|
4684
5218
|
window.clearTimeout(timerId);
|
|
4685
5219
|
if (error) {
|
|
@@ -4693,47 +5227,44 @@ var KibisisWallet = class extends BaseWallet {
|
|
|
4693
5227
|
})
|
|
4694
5228
|
);
|
|
4695
5229
|
}
|
|
4696
|
-
this.logger.debug("Disable successful", { result });
|
|
4697
5230
|
return resolve(result);
|
|
4698
5231
|
});
|
|
4699
|
-
|
|
4700
|
-
avmWebClient.disable({
|
|
5232
|
+
avmWebClient.enable({
|
|
4701
5233
|
genesisHash,
|
|
4702
5234
|
providerId: KIBISIS_AVM_WEB_PROVIDER_ID
|
|
4703
5235
|
});
|
|
4704
5236
|
});
|
|
4705
5237
|
}
|
|
4706
5238
|
/**
|
|
4707
|
-
* Calls the "
|
|
4708
|
-
* @returns {Promise<AVMWebProviderSDK.
|
|
4709
|
-
* @
|
|
4710
|
-
* @throws {MethodCanceledError} if the method was cancelled by the user.
|
|
5239
|
+
* Calls the "disable" method on the provider. This method will timeout after 0.75 seconds.
|
|
5240
|
+
* @returns {Promise<AVMWebProviderSDK.IDisableResult>} a promise that resolves to the result.
|
|
5241
|
+
* @protected
|
|
4711
5242
|
* @throws {MethodNotSupportedError} if the method is not supported for the configured network.
|
|
4712
5243
|
* @throws {MethodTimedOutError} if the method timed out by lack of response (>= 3 minutes).
|
|
4713
5244
|
* @throws {NetworkNotSupportedError} if the network is not supported for the configured network.
|
|
4714
5245
|
* @throws {UnknownError} if the response result is empty.
|
|
4715
5246
|
*/
|
|
4716
|
-
async
|
|
5247
|
+
async _disable() {
|
|
4717
5248
|
const {
|
|
4718
5249
|
ARC0027MethodEnum,
|
|
4719
5250
|
ARC0027MethodTimedOutError,
|
|
4720
5251
|
ARC0027UnknownError,
|
|
4721
|
-
|
|
4722
|
-
} =
|
|
4723
|
-
const avmWebClient =
|
|
5252
|
+
LOWER_REQUEST_TIMEOUT
|
|
5253
|
+
} = await this._initializeAVMWebProviderSDK();
|
|
5254
|
+
const avmWebClient = await this._initializeAVMWebClient();
|
|
4724
5255
|
const genesisHash = await this._getGenesisHash();
|
|
4725
5256
|
return new Promise((resolve, reject) => {
|
|
4726
5257
|
const timerId = window.setTimeout(() => {
|
|
4727
5258
|
avmWebClient.removeListener(listenerId);
|
|
4728
5259
|
reject(
|
|
4729
5260
|
new ARC0027MethodTimedOutError({
|
|
4730
|
-
method: ARC0027MethodEnum.
|
|
5261
|
+
method: ARC0027MethodEnum.Disable,
|
|
4731
5262
|
message: `no response from provider "${this.metadata.name}"`,
|
|
4732
5263
|
providerId: KIBISIS_AVM_WEB_PROVIDER_ID
|
|
4733
5264
|
})
|
|
4734
5265
|
);
|
|
4735
|
-
},
|
|
4736
|
-
const listenerId = avmWebClient.
|
|
5266
|
+
}, LOWER_REQUEST_TIMEOUT);
|
|
5267
|
+
const listenerId = avmWebClient.onDisable(({ error, method, result }) => {
|
|
4737
5268
|
avmWebClient.removeListener(listenerId);
|
|
4738
5269
|
window.clearTimeout(timerId);
|
|
4739
5270
|
if (error) {
|
|
@@ -4747,60 +5278,21 @@ var KibisisWallet = class extends BaseWallet {
|
|
|
4747
5278
|
})
|
|
4748
5279
|
);
|
|
4749
5280
|
}
|
|
4750
|
-
this.logger.debug("
|
|
5281
|
+
this.logger.debug("Disable successful", { result });
|
|
4751
5282
|
return resolve(result);
|
|
4752
5283
|
});
|
|
4753
|
-
this.logger.debug("Sending
|
|
4754
|
-
avmWebClient.
|
|
5284
|
+
this.logger.debug("Sending disable request...", { genesisHash });
|
|
5285
|
+
avmWebClient.disable({
|
|
4755
5286
|
genesisHash,
|
|
4756
5287
|
providerId: KIBISIS_AVM_WEB_PROVIDER_ID
|
|
4757
5288
|
});
|
|
4758
5289
|
});
|
|
4759
5290
|
}
|
|
4760
|
-
async _getGenesisHash() {
|
|
4761
|
-
const algodClient = this.getAlgodClient();
|
|
4762
|
-
const version = await algodClient.versionsCheck().do();
|
|
4763
|
-
return import_algosdk5.default.bytesToBase64(version.genesisHashB64);
|
|
4764
|
-
}
|
|
4765
|
-
async _initializeAVMWebClient() {
|
|
4766
|
-
const avmWebProviderSDK = this.avmWebProviderSDK || await this._initializeAVMWebProviderSDK();
|
|
4767
|
-
if (!this.avmWebClient) {
|
|
4768
|
-
this.logger.info("Initializing new AVM Web Client...");
|
|
4769
|
-
this.avmWebClient = avmWebProviderSDK.AVMWebClient.init();
|
|
4770
|
-
this.logger.info("AVM Web Client initialized");
|
|
4771
|
-
}
|
|
4772
|
-
return this.avmWebClient;
|
|
4773
|
-
}
|
|
4774
|
-
async _initializeAVMWebProviderSDK() {
|
|
4775
|
-
if (!this.avmWebProviderSDK) {
|
|
4776
|
-
this.logger.info("Initializing @agoralabs-sh/avm-web-provider...");
|
|
4777
|
-
const module2 = await import("@agoralabs-sh/avm-web-provider");
|
|
4778
|
-
this.avmWebProviderSDK = module2.default ? module2.default : module2;
|
|
4779
|
-
if (!this.avmWebProviderSDK) {
|
|
4780
|
-
throw new Error(
|
|
4781
|
-
"Failed to initialize, the @agoralabs-sh/avm-web-provider SDK was not provided"
|
|
4782
|
-
);
|
|
4783
|
-
}
|
|
4784
|
-
if (!this.avmWebProviderSDK.AVMWebClient) {
|
|
4785
|
-
throw new Error(
|
|
4786
|
-
"Failed to initialize, AVMWebClient missing from @agoralabs-sh/avm-web-provider SDK"
|
|
4787
|
-
);
|
|
4788
|
-
}
|
|
4789
|
-
this.logger.info("@agoralabs-sh/avm-web-provider initialized");
|
|
4790
|
-
}
|
|
4791
|
-
return this.avmWebProviderSDK;
|
|
4792
|
-
}
|
|
4793
|
-
_mapAVMWebProviderAccountToWalletAccounts(accounts) {
|
|
4794
|
-
return accounts.map(({ address, name }, idx) => ({
|
|
4795
|
-
name: name || `[${this.metadata.name}] Account ${idx + 1}`,
|
|
4796
|
-
address
|
|
4797
|
-
}));
|
|
4798
|
-
}
|
|
4799
5291
|
/**
|
|
4800
5292
|
* Calls the "signTransactions" method to sign the supplied ARC-0001 transactions. This method will timeout after 3
|
|
4801
5293
|
* minutes.
|
|
4802
5294
|
* @returns {Promise<AVMWebProviderSDK.ISignTransactionsResult>} a promise that resolves to the result.
|
|
4803
|
-
* @
|
|
5295
|
+
* @protected
|
|
4804
5296
|
* @throws {InvalidInputError} if computed group ID for the txns does not match the assigned group ID.
|
|
4805
5297
|
* @throws {InvalidGroupIdError} if the unsigned txns is malformed or not conforming to ARC-0001.
|
|
4806
5298
|
* @throws {MethodCanceledError} if the method was cancelled by the user.
|
|
@@ -4816,8 +5308,8 @@ var KibisisWallet = class extends BaseWallet {
|
|
|
4816
5308
|
ARC0027MethodTimedOutError,
|
|
4817
5309
|
ARC0027UnknownError,
|
|
4818
5310
|
DEFAULT_REQUEST_TIMEOUT
|
|
4819
|
-
} =
|
|
4820
|
-
const avmWebClient =
|
|
5311
|
+
} = await this._initializeAVMWebProviderSDK();
|
|
5312
|
+
const avmWebClient = await this._initializeAVMWebClient();
|
|
4821
5313
|
return new Promise((resolve, reject) => {
|
|
4822
5314
|
const timerId = window.setTimeout(() => {
|
|
4823
5315
|
avmWebClient.removeListener(listenerId);
|
|
@@ -4853,154 +5345,11 @@ var KibisisWallet = class extends BaseWallet {
|
|
|
4853
5345
|
});
|
|
4854
5346
|
});
|
|
4855
5347
|
}
|
|
4856
|
-
/**
|
|
4857
|
-
* public functions
|
|
4858
|
-
*/
|
|
4859
|
-
async connect() {
|
|
4860
|
-
let result;
|
|
4861
|
-
try {
|
|
4862
|
-
this.logger.info("Connecting...");
|
|
4863
|
-
result = await this._enable();
|
|
4864
|
-
this.logger.info(`Successfully connected on network "${result.genesisId}"`);
|
|
4865
|
-
} catch (error) {
|
|
4866
|
-
this.logger.error(
|
|
4867
|
-
"Error connecting:",
|
|
4868
|
-
isAVMWebProviderSDKError(error) ? `${error.message} (code: ${error.code})` : error.message
|
|
4869
|
-
);
|
|
4870
|
-
throw error;
|
|
4871
|
-
}
|
|
4872
|
-
const walletAccounts = this._mapAVMWebProviderAccountToWalletAccounts(result.accounts);
|
|
4873
|
-
const walletState = {
|
|
4874
|
-
accounts: walletAccounts,
|
|
4875
|
-
activeAccount: walletAccounts[0]
|
|
4876
|
-
};
|
|
4877
|
-
addWallet(this.store, {
|
|
4878
|
-
walletId: this.id,
|
|
4879
|
-
wallet: walletState
|
|
4880
|
-
});
|
|
4881
|
-
this.logger.info("\u2705 Connected.", walletState);
|
|
4882
|
-
return walletAccounts;
|
|
4883
|
-
}
|
|
4884
|
-
async disconnect() {
|
|
4885
|
-
try {
|
|
4886
|
-
this.logger.info("Disconnecting...");
|
|
4887
|
-
this.onDisconnect();
|
|
4888
|
-
const result = await this._disable();
|
|
4889
|
-
this.logger.info(
|
|
4890
|
-
`Successfully disconnected${result.sessionIds && result.sessionIds.length ? ` sessions [${result.sessionIds.join(",")}]` : ""} on network "${result.genesisId}"`
|
|
4891
|
-
);
|
|
4892
|
-
} catch (error) {
|
|
4893
|
-
this.logger.error(
|
|
4894
|
-
"Error disconnecting:",
|
|
4895
|
-
isAVMWebProviderSDKError(error) ? `${error.message} (code: ${error.code})` : error.message
|
|
4896
|
-
);
|
|
4897
|
-
throw error;
|
|
4898
|
-
}
|
|
4899
|
-
}
|
|
4900
|
-
async resumeSession() {
|
|
4901
|
-
const state = this.store.state;
|
|
4902
|
-
const walletState = state.wallets[this.id];
|
|
4903
|
-
let result;
|
|
4904
|
-
if (!walletState) {
|
|
4905
|
-
this.logger.info("No session to resume");
|
|
4906
|
-
return;
|
|
4907
|
-
}
|
|
4908
|
-
try {
|
|
4909
|
-
this.logger.info("Resuming session...");
|
|
4910
|
-
result = await this._enable();
|
|
4911
|
-
if (result.accounts.length === 0) {
|
|
4912
|
-
throw new Error("No accounts found!");
|
|
4913
|
-
}
|
|
4914
|
-
const walletAccounts = this._mapAVMWebProviderAccountToWalletAccounts(result.accounts);
|
|
4915
|
-
const match = compareAccounts(walletAccounts, walletState.accounts);
|
|
4916
|
-
if (!match) {
|
|
4917
|
-
this.logger.warn("Session accounts mismatch, updating accounts", {
|
|
4918
|
-
prev: walletState.accounts,
|
|
4919
|
-
current: walletAccounts
|
|
4920
|
-
});
|
|
4921
|
-
setAccounts(this.store, {
|
|
4922
|
-
walletId: this.id,
|
|
4923
|
-
accounts: walletAccounts
|
|
4924
|
-
});
|
|
4925
|
-
}
|
|
4926
|
-
this.logger.info("Session resumed successfully");
|
|
4927
|
-
} catch (error) {
|
|
4928
|
-
this.logger.error(
|
|
4929
|
-
"Error resuming session:",
|
|
4930
|
-
isAVMWebProviderSDKError(error) ? `${error.message} (code: ${error.code})` : error.message
|
|
4931
|
-
);
|
|
4932
|
-
this.onDisconnect();
|
|
4933
|
-
throw error;
|
|
4934
|
-
}
|
|
4935
|
-
}
|
|
4936
|
-
processTxns(txnGroup, indexesToSign) {
|
|
4937
|
-
const txnsToSign = [];
|
|
4938
|
-
txnGroup.forEach((txn, index) => {
|
|
4939
|
-
const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
|
|
4940
|
-
const signer = txn.sender.toString();
|
|
4941
|
-
const canSignTxn = this.addresses.includes(signer);
|
|
4942
|
-
const txnString = byteArrayToBase64(txn.toByte());
|
|
4943
|
-
if (isIndexMatch && canSignTxn) {
|
|
4944
|
-
txnsToSign.push({ txn: txnString });
|
|
4945
|
-
} else {
|
|
4946
|
-
txnsToSign.push({ txn: txnString, signers: [] });
|
|
4947
|
-
}
|
|
4948
|
-
});
|
|
4949
|
-
return txnsToSign;
|
|
4950
|
-
}
|
|
4951
|
-
processEncodedTxns(txnGroup, indexesToSign) {
|
|
4952
|
-
const txnsToSign = [];
|
|
4953
|
-
txnGroup.forEach((txnBuffer, index) => {
|
|
4954
|
-
const decodedObj = import_algosdk5.default.msgpackRawDecode(txnBuffer);
|
|
4955
|
-
const isSigned = isSignedTxn(decodedObj);
|
|
4956
|
-
const txn = isSigned ? import_algosdk5.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk5.default.decodeUnsignedTransaction(txnBuffer);
|
|
4957
|
-
const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
|
|
4958
|
-
const signer = txn.sender.toString();
|
|
4959
|
-
const canSignTxn = !isSigned && this.addresses.includes(signer);
|
|
4960
|
-
const txnString = byteArrayToBase64(txn.toByte());
|
|
4961
|
-
if (isIndexMatch && canSignTxn) {
|
|
4962
|
-
txnsToSign.push({ txn: txnString });
|
|
4963
|
-
} else {
|
|
4964
|
-
txnsToSign.push({ txn: txnString, signers: [] });
|
|
4965
|
-
}
|
|
4966
|
-
});
|
|
4967
|
-
return txnsToSign;
|
|
4968
|
-
}
|
|
4969
|
-
signTransactions = async (txnGroup, indexesToSign) => {
|
|
4970
|
-
try {
|
|
4971
|
-
this.logger.debug("Signing transactions...", { txnGroup, indexesToSign });
|
|
4972
|
-
let txnsToSign = [];
|
|
4973
|
-
if (isTransactionArray(txnGroup)) {
|
|
4974
|
-
const flatTxns = flattenTxnGroup(txnGroup);
|
|
4975
|
-
txnsToSign = this.processTxns(flatTxns, indexesToSign);
|
|
4976
|
-
} else {
|
|
4977
|
-
const flatTxns = flattenTxnGroup(txnGroup);
|
|
4978
|
-
txnsToSign = this.processEncodedTxns(flatTxns, indexesToSign);
|
|
4979
|
-
}
|
|
4980
|
-
this.logger.debug("Sending processed transactions to wallet...", txnsToSign);
|
|
4981
|
-
const signTxnsResult = await this._signTransactions(txnsToSign);
|
|
4982
|
-
this.logger.debug("Received signed transactions from wallet", signTxnsResult);
|
|
4983
|
-
const result = signTxnsResult.stxns.map((value) => {
|
|
4984
|
-
if (value === null) {
|
|
4985
|
-
return null;
|
|
4986
|
-
}
|
|
4987
|
-
return base64ToByteArray(value);
|
|
4988
|
-
});
|
|
4989
|
-
this.logger.debug("Transactions signed successfully", result);
|
|
4990
|
-
return result;
|
|
4991
|
-
} catch (error) {
|
|
4992
|
-
this.logger.error(
|
|
4993
|
-
"Error signing transactions:",
|
|
4994
|
-
isAVMWebProviderSDKError(error) ? `${error.message} (code: ${error.code})` : error.message
|
|
4995
|
-
);
|
|
4996
|
-
throw error;
|
|
4997
|
-
}
|
|
4998
|
-
};
|
|
4999
5348
|
};
|
|
5000
5349
|
|
|
5001
5350
|
// src/wallets/kmd.ts
|
|
5002
5351
|
var import_algosdk6 = __toESM(require("algosdk"), 1);
|
|
5003
|
-
var
|
|
5352
|
+
var ICON8 = `data:image/svg+xml;base64,${btoa(`
|
|
5004
5353
|
<svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
|
|
5005
5354
|
<linearGradient id="algokitGradient" gradientUnits="userSpaceOnUse" x1="0" y1="400" x2="400" y2="0">
|
|
5006
5355
|
<stop offset="0" style="stop-color:#31D8EE"/>
|
|
@@ -5022,10 +5371,11 @@ var KmdWallet = class extends BaseWallet {
|
|
|
5022
5371
|
store,
|
|
5023
5372
|
subscribe,
|
|
5024
5373
|
getAlgodClient,
|
|
5374
|
+
networks,
|
|
5025
5375
|
options,
|
|
5026
5376
|
metadata = {}
|
|
5027
5377
|
}) {
|
|
5028
|
-
super({ id, metadata, getAlgodClient, store, subscribe });
|
|
5378
|
+
super({ id, metadata, getAlgodClient, store, subscribe, networks });
|
|
5029
5379
|
const {
|
|
5030
5380
|
token = "a".repeat(64),
|
|
5031
5381
|
baseServer = "http://127.0.0.1",
|
|
@@ -5038,7 +5388,7 @@ var KmdWallet = class extends BaseWallet {
|
|
|
5038
5388
|
}
|
|
5039
5389
|
static defaultMetadata = {
|
|
5040
5390
|
name: "KMD",
|
|
5041
|
-
icon:
|
|
5391
|
+
icon: ICON8
|
|
5042
5392
|
};
|
|
5043
5393
|
async initializeClient() {
|
|
5044
5394
|
this.logger.info("Initializing client...");
|
|
@@ -5205,7 +5555,7 @@ var KmdWallet = class extends BaseWallet {
|
|
|
5205
5555
|
};
|
|
5206
5556
|
|
|
5207
5557
|
// src/wallets/liquid.ts
|
|
5208
|
-
var
|
|
5558
|
+
var ICON9 = `data:image/svg+xml;base64,${btoa(`
|
|
5209
5559
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="249" height="249" viewBox="0 0 249 249" xml:space="preserve">
|
|
5210
5560
|
<g transform="matrix(2.52 0 0 2.52 124.74 124.74)">
|
|
5211
5561
|
<circle style="stroke: rgb(0,0,0); stroke-width: 19; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;" cx="0" cy="0" r="40"/>
|
|
@@ -5228,9 +5578,10 @@ var LiquidWallet = class extends BaseWallet {
|
|
|
5228
5578
|
subscribe,
|
|
5229
5579
|
getAlgodClient,
|
|
5230
5580
|
options,
|
|
5231
|
-
metadata = {}
|
|
5581
|
+
metadata = {},
|
|
5582
|
+
networks
|
|
5232
5583
|
}) {
|
|
5233
|
-
super({ id, metadata, getAlgodClient, store, subscribe });
|
|
5584
|
+
super({ id, metadata, getAlgodClient, store, subscribe, networks });
|
|
5234
5585
|
this.store = store;
|
|
5235
5586
|
this.options = options ?? {
|
|
5236
5587
|
RTC_config_username: "username",
|
|
@@ -5239,7 +5590,7 @@ var LiquidWallet = class extends BaseWallet {
|
|
|
5239
5590
|
}
|
|
5240
5591
|
static defaultMetadata = {
|
|
5241
5592
|
name: "Liquid",
|
|
5242
|
-
icon:
|
|
5593
|
+
icon: ICON9
|
|
5243
5594
|
};
|
|
5244
5595
|
async initializeClient() {
|
|
5245
5596
|
this.logger.info("Initializing client...");
|
|
@@ -5323,7 +5674,7 @@ var import_algosdk7 = __toESM(require("algosdk"), 1);
|
|
|
5323
5674
|
function isSignTxnsError(error) {
|
|
5324
5675
|
return error instanceof Error && "code" in error;
|
|
5325
5676
|
}
|
|
5326
|
-
var
|
|
5677
|
+
var ICON10 = `data:image/svg+xml;base64,${btoa(`
|
|
5327
5678
|
<svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
|
|
5328
5679
|
<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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8,7.3c4.5,1.7,9.9,2.9,14.7,3.3c4.6,0.4,10,0.2,14.6-0.7c4.4-0.8,9.4-2.4,13.5-4.3 c3.9-1.9,8.2-4.6,11.5-7.5c3.2-2.7,6.4-6.4,8.8-9.9c2.3-3.4,4.4-7.6,5.7-11.4c1.2-3.7,2.1-8.1,2.3-12c0.2-3.7-0.1-8.1-0.9-11.8 c-0.8-3.5-2.2-7.5-3.8-10.7c-1.6-3.1-3.9-6.3-6.2-8.9c-2.2-2.4-5.2-4.9-8-6.6c-2.7-1.7-6-3.2-9.1-4c-2.9-0.8-6.3-1.4-9.3-1.4 c-2.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" />
|
|
5329
5680
|
</svg>
|
|
@@ -5338,9 +5689,10 @@ var LuteWallet = class extends BaseWallet {
|
|
|
5338
5689
|
subscribe,
|
|
5339
5690
|
getAlgodClient,
|
|
5340
5691
|
options,
|
|
5341
|
-
metadata = {}
|
|
5692
|
+
metadata = {},
|
|
5693
|
+
networks
|
|
5342
5694
|
}) {
|
|
5343
|
-
super({ id, metadata, getAlgodClient, store, subscribe });
|
|
5695
|
+
super({ id, metadata, getAlgodClient, store, subscribe, networks });
|
|
5344
5696
|
if (!options?.siteName) {
|
|
5345
5697
|
this.logger.error("Missing required option: siteName");
|
|
5346
5698
|
throw new Error("Missing required option: siteName");
|
|
@@ -5350,7 +5702,7 @@ var LuteWallet = class extends BaseWallet {
|
|
|
5350
5702
|
}
|
|
5351
5703
|
static defaultMetadata = {
|
|
5352
5704
|
name: "Lute",
|
|
5353
|
-
icon:
|
|
5705
|
+
icon: ICON10
|
|
5354
5706
|
};
|
|
5355
5707
|
async initializeClient() {
|
|
5356
5708
|
this.logger.info("Initializing client...");
|
|
@@ -5362,13 +5714,16 @@ var LuteWallet = class extends BaseWallet {
|
|
|
5362
5714
|
return client;
|
|
5363
5715
|
}
|
|
5364
5716
|
async getGenesisId() {
|
|
5717
|
+
const network = this.activeNetworkConfig;
|
|
5718
|
+
if (network.genesisId) {
|
|
5719
|
+
return network.genesisId;
|
|
5720
|
+
}
|
|
5365
5721
|
const algodClient = this.getAlgodClient();
|
|
5366
5722
|
const genesisStr = await algodClient.genesis().do();
|
|
5367
5723
|
const genesis = import_algosdk7.default.parseJSON(genesisStr, {
|
|
5368
5724
|
intDecoding: import_algosdk7.default.IntDecoding.MIXED
|
|
5369
5725
|
});
|
|
5370
|
-
|
|
5371
|
-
return genesisId;
|
|
5726
|
+
return `${genesis.network}-${genesis.id}`;
|
|
5372
5727
|
}
|
|
5373
5728
|
connect = async () => {
|
|
5374
5729
|
this.logger.info("Connecting...");
|
|
@@ -5478,7 +5833,7 @@ var LuteWallet = class extends BaseWallet {
|
|
|
5478
5833
|
|
|
5479
5834
|
// src/wallets/magic.ts
|
|
5480
5835
|
var import_algosdk8 = __toESM(require("algosdk"), 1);
|
|
5481
|
-
var
|
|
5836
|
+
var ICON11 = `data:image/svg+xml;base64,${btoa(`
|
|
5482
5837
|
<svg viewBox="0 0 47 47" xmlns="http://www.w3.org/2000/svg">
|
|
5483
5838
|
<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" />
|
|
5484
5839
|
</svg>
|
|
@@ -5494,9 +5849,10 @@ var MagicAuth = class extends BaseWallet {
|
|
|
5494
5849
|
subscribe,
|
|
5495
5850
|
getAlgodClient,
|
|
5496
5851
|
options,
|
|
5497
|
-
metadata = {}
|
|
5852
|
+
metadata = {},
|
|
5853
|
+
networks
|
|
5498
5854
|
}) {
|
|
5499
|
-
super({ id, metadata, getAlgodClient, store, subscribe });
|
|
5855
|
+
super({ id, metadata, getAlgodClient, store, subscribe, networks });
|
|
5500
5856
|
if (!options?.apiKey) {
|
|
5501
5857
|
this.logger.error("Missing required option: apiKey");
|
|
5502
5858
|
throw new Error("Missing required option: apiKey");
|
|
@@ -5506,7 +5862,7 @@ var MagicAuth = class extends BaseWallet {
|
|
|
5506
5862
|
}
|
|
5507
5863
|
static defaultMetadata = {
|
|
5508
5864
|
name: "Magic",
|
|
5509
|
-
icon:
|
|
5865
|
+
icon: ICON11
|
|
5510
5866
|
};
|
|
5511
5867
|
async initializeClient() {
|
|
5512
5868
|
this.logger.info("Initializing client...");
|
|
@@ -5688,7 +6044,7 @@ var MagicAuth = class extends BaseWallet {
|
|
|
5688
6044
|
// src/wallets/mnemonic.ts
|
|
5689
6045
|
var import_algosdk9 = __toESM(require("algosdk"), 1);
|
|
5690
6046
|
var LOCAL_STORAGE_MNEMONIC_KEY = `${LOCAL_STORAGE_KEY}_mnemonic`;
|
|
5691
|
-
var
|
|
6047
|
+
var ICON12 = `data:image/svg+xml;base64,${btoa(`
|
|
5692
6048
|
<svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
|
|
5693
6049
|
<rect fill="#525252" width="400" height="400" />
|
|
5694
6050
|
<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" />
|
|
@@ -5704,9 +6060,10 @@ var MnemonicWallet = class extends BaseWallet {
|
|
|
5704
6060
|
subscribe,
|
|
5705
6061
|
getAlgodClient,
|
|
5706
6062
|
options,
|
|
5707
|
-
metadata = {}
|
|
6063
|
+
metadata = {},
|
|
6064
|
+
networks
|
|
5708
6065
|
}) {
|
|
5709
|
-
super({ id, metadata, getAlgodClient, store, subscribe });
|
|
6066
|
+
super({ id, metadata, getAlgodClient, store, subscribe, networks });
|
|
5710
6067
|
const { persistToStorage = false } = options || {};
|
|
5711
6068
|
this.options = { persistToStorage };
|
|
5712
6069
|
this.store = store;
|
|
@@ -5718,7 +6075,7 @@ var MnemonicWallet = class extends BaseWallet {
|
|
|
5718
6075
|
}
|
|
5719
6076
|
static defaultMetadata = {
|
|
5720
6077
|
name: "Mnemonic",
|
|
5721
|
-
icon:
|
|
6078
|
+
icon: ICON12
|
|
5722
6079
|
};
|
|
5723
6080
|
loadMnemonicFromStorage() {
|
|
5724
6081
|
return StorageAdapter.getItem(LOCAL_STORAGE_MNEMONIC_KEY);
|
|
@@ -5731,12 +6088,12 @@ var MnemonicWallet = class extends BaseWallet {
|
|
|
5731
6088
|
}
|
|
5732
6089
|
checkMainnet() {
|
|
5733
6090
|
try {
|
|
5734
|
-
const network = this.
|
|
5735
|
-
if (network
|
|
6091
|
+
const network = this.activeNetworkConfig;
|
|
6092
|
+
if (!network.isTestnet) {
|
|
5736
6093
|
this.logger.warn(
|
|
5737
6094
|
"The Mnemonic wallet provider is insecure and intended for testing only. Any private key mnemonics used should never hold real Algos (i.e., on MainNet)."
|
|
5738
6095
|
);
|
|
5739
|
-
throw new Error("
|
|
6096
|
+
throw new Error("Production network detected. Aborting.");
|
|
5740
6097
|
}
|
|
5741
6098
|
} catch (error) {
|
|
5742
6099
|
this.disconnect();
|
|
@@ -5861,7 +6218,7 @@ var MnemonicWallet = class extends BaseWallet {
|
|
|
5861
6218
|
|
|
5862
6219
|
// src/wallets/pera.ts
|
|
5863
6220
|
var import_algosdk10 = __toESM(require("algosdk"), 1);
|
|
5864
|
-
var
|
|
6221
|
+
var ICON13 = `data:image/svg+xml;base64,${btoa(`
|
|
5865
6222
|
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
|
|
5866
6223
|
<rect fill="#FFEE55" width="200" height="200" />
|
|
5867
6224
|
<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" />
|
|
@@ -5882,15 +6239,16 @@ var PeraWallet = class extends BaseWallet {
|
|
|
5882
6239
|
subscribe,
|
|
5883
6240
|
getAlgodClient,
|
|
5884
6241
|
options = {},
|
|
5885
|
-
metadata = {}
|
|
6242
|
+
metadata = {},
|
|
6243
|
+
networks
|
|
5886
6244
|
}) {
|
|
5887
|
-
super({ id, metadata, getAlgodClient, store, subscribe });
|
|
6245
|
+
super({ id, metadata, getAlgodClient, store, subscribe, networks });
|
|
5888
6246
|
this.options = options;
|
|
5889
6247
|
this.store = store;
|
|
5890
6248
|
}
|
|
5891
6249
|
static defaultMetadata = {
|
|
5892
6250
|
name: "Pera",
|
|
5893
|
-
icon:
|
|
6251
|
+
icon: ICON13
|
|
5894
6252
|
};
|
|
5895
6253
|
async initializeClient() {
|
|
5896
6254
|
this.logger.info("Initializing client...");
|
|
@@ -6060,7 +6418,7 @@ var PeraWallet = class extends BaseWallet {
|
|
|
6060
6418
|
|
|
6061
6419
|
// src/wallets/pera2.ts
|
|
6062
6420
|
var import_algosdk11 = __toESM(require("algosdk"), 1);
|
|
6063
|
-
var
|
|
6421
|
+
var ICON14 = `data:image/svg+xml;base64,${btoa(`
|
|
6064
6422
|
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
|
|
6065
6423
|
<rect fill="#FFEE55" width="200" height="200" />
|
|
6066
6424
|
<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" />
|
|
@@ -6081,9 +6439,10 @@ var PeraWallet2 = class extends BaseWallet {
|
|
|
6081
6439
|
subscribe,
|
|
6082
6440
|
getAlgodClient,
|
|
6083
6441
|
options,
|
|
6084
|
-
metadata = {}
|
|
6442
|
+
metadata = {},
|
|
6443
|
+
networks
|
|
6085
6444
|
}) {
|
|
6086
|
-
super({ id, metadata, getAlgodClient, store, subscribe });
|
|
6445
|
+
super({ id, metadata, getAlgodClient, store, subscribe, networks });
|
|
6087
6446
|
if (!options?.projectId) {
|
|
6088
6447
|
this.logger.error("Missing required option: projectId");
|
|
6089
6448
|
throw new Error("Missing required option: projectId");
|
|
@@ -6093,7 +6452,7 @@ var PeraWallet2 = class extends BaseWallet {
|
|
|
6093
6452
|
}
|
|
6094
6453
|
static defaultMetadata = {
|
|
6095
6454
|
name: "Pera",
|
|
6096
|
-
icon:
|
|
6455
|
+
icon: ICON14
|
|
6097
6456
|
};
|
|
6098
6457
|
async initializeClient() {
|
|
6099
6458
|
this.logger.info("Initializing client...");
|
|
@@ -6245,6 +6604,7 @@ function createWalletMap() {
|
|
|
6245
6604
|
["biatec" /* BIATEC */]: BiatecWallet,
|
|
6246
6605
|
["custom" /* CUSTOM */]: CustomWallet,
|
|
6247
6606
|
["defly" /* DEFLY */]: DeflyWallet,
|
|
6607
|
+
["defly-web" /* DEFLY_WEB */]: DeflyWebWallet,
|
|
6248
6608
|
["exodus" /* EXODUS */]: ExodusWallet,
|
|
6249
6609
|
["kibisis" /* KIBISIS */]: KibisisWallet,
|
|
6250
6610
|
["kmd" /* KMD */]: KmdWallet,
|
|
@@ -6330,24 +6690,6 @@ function formatJsonRpcRequest(method, params) {
|
|
|
6330
6690
|
params
|
|
6331
6691
|
};
|
|
6332
6692
|
}
|
|
6333
|
-
function deepMerge(target, source) {
|
|
6334
|
-
const isObject = (obj) => obj && typeof obj === "object";
|
|
6335
|
-
if (!isObject(target) || !isObject(source)) {
|
|
6336
|
-
throw new Error("Target and source must be objects");
|
|
6337
|
-
}
|
|
6338
|
-
Object.keys(source).forEach((key) => {
|
|
6339
|
-
const targetValue = target[key];
|
|
6340
|
-
const sourceValue = source[key];
|
|
6341
|
-
if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
|
|
6342
|
-
target[key] = targetValue.concat(sourceValue);
|
|
6343
|
-
} else if (isObject(targetValue) && isObject(sourceValue)) {
|
|
6344
|
-
target[key] = deepMerge(Object.assign({}, targetValue), sourceValue);
|
|
6345
|
-
} else {
|
|
6346
|
-
target[key] = sourceValue;
|
|
6347
|
-
}
|
|
6348
|
-
});
|
|
6349
|
-
return target;
|
|
6350
|
-
}
|
|
6351
6693
|
|
|
6352
6694
|
// src/manager.ts
|
|
6353
6695
|
var WalletManager = class {
|
|
@@ -6359,24 +6701,27 @@ var WalletManager = class {
|
|
|
6359
6701
|
logger;
|
|
6360
6702
|
constructor({
|
|
6361
6703
|
wallets = [],
|
|
6362
|
-
|
|
6363
|
-
|
|
6704
|
+
networks,
|
|
6705
|
+
defaultNetwork = "testnet",
|
|
6364
6706
|
options = {}
|
|
6365
6707
|
} = {}) {
|
|
6366
6708
|
this.logger = this.initializeLogger(options);
|
|
6367
6709
|
this.logger.debug("Initializing WalletManager with config:", {
|
|
6368
6710
|
wallets,
|
|
6369
|
-
|
|
6370
|
-
|
|
6711
|
+
networks,
|
|
6712
|
+
defaultNetwork,
|
|
6371
6713
|
options
|
|
6372
6714
|
});
|
|
6373
|
-
this.networkConfig = this.initNetworkConfig(
|
|
6715
|
+
this.networkConfig = this.initNetworkConfig(networks);
|
|
6374
6716
|
this.options = { resetNetwork: options.resetNetwork || false };
|
|
6375
6717
|
const persistedState = this.loadPersistedState();
|
|
6376
|
-
const activeNetwork = this.options.resetNetwork ?
|
|
6718
|
+
const activeNetwork = this.options.resetNetwork ? defaultNetwork : persistedState?.activeNetwork || defaultNetwork;
|
|
6719
|
+
if (!this.networkConfig[activeNetwork]) {
|
|
6720
|
+
throw new Error(`Network "${activeNetwork}" not found in network configuration`);
|
|
6721
|
+
}
|
|
6377
6722
|
const algodClient = this.createAlgodClient(activeNetwork);
|
|
6378
6723
|
const initialState = {
|
|
6379
|
-
...
|
|
6724
|
+
...DEFAULT_STATE,
|
|
6380
6725
|
...persistedState,
|
|
6381
6726
|
activeNetwork,
|
|
6382
6727
|
algodClient
|
|
@@ -6469,7 +6814,8 @@ var WalletManager = class {
|
|
|
6469
6814
|
options: walletOptions,
|
|
6470
6815
|
getAlgodClient: this.getAlgodClient,
|
|
6471
6816
|
store: this.store,
|
|
6472
|
-
subscribe: this.subscribe
|
|
6817
|
+
subscribe: this.subscribe,
|
|
6818
|
+
networks: this.networkConfig
|
|
6473
6819
|
});
|
|
6474
6820
|
this._clients.set(walletId, walletInstance);
|
|
6475
6821
|
this.logger.info(`\u2705 Initialized ${walletId}`);
|
|
@@ -6502,20 +6848,24 @@ var WalletManager = class {
|
|
|
6502
6848
|
await Promise.all(promises);
|
|
6503
6849
|
}
|
|
6504
6850
|
// ---------- Network ----------------------------------------------- //
|
|
6505
|
-
initNetworkConfig(
|
|
6506
|
-
this.logger.info("Initializing network...");
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6851
|
+
initNetworkConfig(networks) {
|
|
6852
|
+
this.logger.info("Initializing network configuration...");
|
|
6853
|
+
const config = networks || createNetworkConfig();
|
|
6854
|
+
for (const [id, network] of Object.entries(config)) {
|
|
6855
|
+
if (!isNetworkConfig(network)) {
|
|
6856
|
+
throw new Error(`Invalid network configuration for "${id}"`);
|
|
6857
|
+
}
|
|
6512
6858
|
}
|
|
6513
|
-
this.logger.debug("
|
|
6514
|
-
return
|
|
6859
|
+
this.logger.debug("Network configuration:", config);
|
|
6860
|
+
return config;
|
|
6515
6861
|
}
|
|
6516
6862
|
createAlgodClient(networkId) {
|
|
6517
6863
|
this.logger.info(`Creating Algodv2 client for ${networkId}...`);
|
|
6518
|
-
const
|
|
6864
|
+
const network = this.networkConfig[networkId];
|
|
6865
|
+
if (!network) {
|
|
6866
|
+
throw new Error(`Network "${networkId}" not found in network configuration`);
|
|
6867
|
+
}
|
|
6868
|
+
const { token = "", baseServer, port = "", headers = {} } = network.algod;
|
|
6519
6869
|
return new import_algosdk13.default.Algodv2(token, baseServer, port, headers);
|
|
6520
6870
|
}
|
|
6521
6871
|
getAlgodClient = () => {
|
|
@@ -6525,13 +6875,19 @@ var WalletManager = class {
|
|
|
6525
6875
|
if (this.activeNetwork === networkId) {
|
|
6526
6876
|
return;
|
|
6527
6877
|
}
|
|
6878
|
+
if (!this.networkConfig[networkId]) {
|
|
6879
|
+
throw new Error(`Network "${networkId}" not found in network configuration`);
|
|
6880
|
+
}
|
|
6528
6881
|
const algodClient = this.createAlgodClient(networkId);
|
|
6529
6882
|
setActiveNetwork(this.store, { networkId, algodClient });
|
|
6530
|
-
this.logger.info(`\u2705 Active network set to ${networkId}
|
|
6883
|
+
this.logger.info(`\u2705 Active network set to ${networkId}`);
|
|
6531
6884
|
};
|
|
6532
6885
|
get activeNetwork() {
|
|
6533
6886
|
return this.store.state.activeNetwork;
|
|
6534
6887
|
}
|
|
6888
|
+
get networks() {
|
|
6889
|
+
return { ...this.networkConfig };
|
|
6890
|
+
}
|
|
6535
6891
|
// ---------- Active Wallet ----------------------------------------- //
|
|
6536
6892
|
get activeWallet() {
|
|
6537
6893
|
const state = this.store.state;
|
|
@@ -6599,6 +6955,8 @@ var webpackFallback = {
|
|
|
6599
6955
|
0 && (module.exports = {
|
|
6600
6956
|
BaseWallet,
|
|
6601
6957
|
CustomWallet,
|
|
6958
|
+
DEFAULT_NETWORKS,
|
|
6959
|
+
DEFAULT_STATE,
|
|
6602
6960
|
DeflyWallet,
|
|
6603
6961
|
ExodusWallet,
|
|
6604
6962
|
ICON,
|
|
@@ -6618,8 +6976,6 @@ var webpackFallback = {
|
|
|
6618
6976
|
WalletConnect,
|
|
6619
6977
|
WalletId,
|
|
6620
6978
|
WalletManager,
|
|
6621
|
-
defaultState,
|
|
6622
|
-
isAVMWebProviderSDKError,
|
|
6623
6979
|
webpackFallback
|
|
6624
6980
|
});
|
|
6625
6981
|
//# sourceMappingURL=index.cjs.map
|