@vleap/warps-adapter-fastset 0.1.0-beta.47 → 0.1.0-beta.49
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.d.cts +10 -4
- package/dist/index.d.ts +10 -4
- package/dist/index.js +235 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +231 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WarpChainAsset, ChainAdapterFactory, AdapterWarpExecutor, WarpClientConfig, WarpChainInfo, WarpExecutable, WarpAdapterGenericTransaction, AdapterWarpWallet, WarpWalletDetails } from '@vleap/warps';
|
|
1
|
+
import { WarpChainAsset, ChainAdapterFactory, AdapterWarpExecutor, WarpClientConfig, WarpChainInfo, WarpExecutable, WarpAdapterGenericTransaction, AdapterWarpWallet, WarpWalletProvider, WarpWalletDetails } from '@vleap/warps';
|
|
2
2
|
|
|
3
3
|
declare const NativeTokenSet: WarpChainAsset;
|
|
4
4
|
declare const FastsetAdapter: ChainAdapterFactory;
|
|
@@ -18,16 +18,22 @@ declare class WarpFastsetWallet implements AdapterWarpWallet {
|
|
|
18
18
|
private config;
|
|
19
19
|
private chain;
|
|
20
20
|
private client;
|
|
21
|
+
private walletProvider;
|
|
22
|
+
private cachedAddress;
|
|
23
|
+
private cachedPublicKey;
|
|
21
24
|
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
22
25
|
signTransaction(tx: WarpAdapterGenericTransaction): Promise<WarpAdapterGenericTransaction>;
|
|
23
|
-
signMessage(message: string): Promise<string>;
|
|
24
26
|
signTransactions(txs: WarpAdapterGenericTransaction[]): Promise<WarpAdapterGenericTransaction[]>;
|
|
27
|
+
signMessage(message: string): Promise<string>;
|
|
25
28
|
sendTransaction(tx: WarpAdapterGenericTransaction): Promise<string>;
|
|
26
29
|
sendTransactions(txs: WarpAdapterGenericTransaction[]): Promise<string[]>;
|
|
27
|
-
create(mnemonic: string): WarpWalletDetails;
|
|
28
|
-
generate(): WarpWalletDetails;
|
|
30
|
+
create(provider: WarpWalletProvider, mnemonic: string): WarpWalletDetails;
|
|
31
|
+
generate(provider: WarpWalletProvider): WarpWalletDetails;
|
|
29
32
|
getAddress(): string | null;
|
|
30
33
|
getPublicKey(): string | null;
|
|
34
|
+
private createProvider;
|
|
35
|
+
private initializeCache;
|
|
36
|
+
private createProviderForOperation;
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
export { FastsetAdapter, NativeTokenSet, WarpFastsetExecutor, WarpFastsetWallet };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WarpChainAsset, ChainAdapterFactory, AdapterWarpExecutor, WarpClientConfig, WarpChainInfo, WarpExecutable, WarpAdapterGenericTransaction, AdapterWarpWallet, WarpWalletDetails } from '@vleap/warps';
|
|
1
|
+
import { WarpChainAsset, ChainAdapterFactory, AdapterWarpExecutor, WarpClientConfig, WarpChainInfo, WarpExecutable, WarpAdapterGenericTransaction, AdapterWarpWallet, WarpWalletProvider, WarpWalletDetails } from '@vleap/warps';
|
|
2
2
|
|
|
3
3
|
declare const NativeTokenSet: WarpChainAsset;
|
|
4
4
|
declare const FastsetAdapter: ChainAdapterFactory;
|
|
@@ -18,16 +18,22 @@ declare class WarpFastsetWallet implements AdapterWarpWallet {
|
|
|
18
18
|
private config;
|
|
19
19
|
private chain;
|
|
20
20
|
private client;
|
|
21
|
+
private walletProvider;
|
|
22
|
+
private cachedAddress;
|
|
23
|
+
private cachedPublicKey;
|
|
21
24
|
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
22
25
|
signTransaction(tx: WarpAdapterGenericTransaction): Promise<WarpAdapterGenericTransaction>;
|
|
23
|
-
signMessage(message: string): Promise<string>;
|
|
24
26
|
signTransactions(txs: WarpAdapterGenericTransaction[]): Promise<WarpAdapterGenericTransaction[]>;
|
|
27
|
+
signMessage(message: string): Promise<string>;
|
|
25
28
|
sendTransaction(tx: WarpAdapterGenericTransaction): Promise<string>;
|
|
26
29
|
sendTransactions(txs: WarpAdapterGenericTransaction[]): Promise<string[]>;
|
|
27
|
-
create(mnemonic: string): WarpWalletDetails;
|
|
28
|
-
generate(): WarpWalletDetails;
|
|
30
|
+
create(provider: WarpWalletProvider, mnemonic: string): WarpWalletDetails;
|
|
31
|
+
generate(provider: WarpWalletProvider): WarpWalletDetails;
|
|
29
32
|
getAddress(): string | null;
|
|
30
33
|
getPublicKey(): string | null;
|
|
34
|
+
private createProvider;
|
|
35
|
+
private initializeCache;
|
|
36
|
+
private createProviderForOperation;
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
export { FastsetAdapter, NativeTokenSet, WarpFastsetExecutor, WarpFastsetWallet };
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ __export(index_exports, {
|
|
|
40
40
|
module.exports = __toCommonJS(index_exports);
|
|
41
41
|
|
|
42
42
|
// src/main.ts
|
|
43
|
-
var
|
|
43
|
+
var import_warps9 = require("@vleap/warps");
|
|
44
44
|
|
|
45
45
|
// src/helpers/encode.ts
|
|
46
46
|
var encoder = new TextEncoder();
|
|
@@ -51,9 +51,6 @@ function uint8ArrayToHex(uint8Array) {
|
|
|
51
51
|
function hexToUint8Array(hex) {
|
|
52
52
|
return new Uint8Array(Buffer.from(hex, "hex"));
|
|
53
53
|
}
|
|
54
|
-
function stringToUint8Array(str) {
|
|
55
|
-
return new Uint8Array(Buffer.from(str, "utf8"));
|
|
56
|
-
}
|
|
57
54
|
|
|
58
55
|
// src/helpers/general.ts
|
|
59
56
|
var import_warps = require("@vleap/warps");
|
|
@@ -1957,13 +1954,17 @@ var WarpFastsetOutput = class {
|
|
|
1957
1954
|
};
|
|
1958
1955
|
|
|
1959
1956
|
// src/WarpFastsetWallet.ts
|
|
1957
|
+
var import_warps8 = require("@vleap/warps");
|
|
1958
|
+
|
|
1959
|
+
// src/providers/MnemonicWalletProvider.ts
|
|
1960
1960
|
var bip39 = __toESM(require("@scure/bip39"), 1);
|
|
1961
|
+
var import_english = require("@scure/bip39/wordlists/english");
|
|
1961
1962
|
var import_warps5 = require("@vleap/warps");
|
|
1962
1963
|
|
|
1963
1964
|
// src/sdk/ed25519-setup.ts
|
|
1964
1965
|
var ed25519 = __toESM(require("@noble/ed25519"), 1);
|
|
1965
1966
|
|
|
1966
|
-
// node_modules/@noble/hashes/utils.js
|
|
1967
|
+
// ../../node_modules/@noble/hashes/utils.js
|
|
1967
1968
|
function isBytes2(a) {
|
|
1968
1969
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
1969
1970
|
}
|
|
@@ -2013,7 +2014,7 @@ var oidNist = (suffix) => ({
|
|
|
2013
2014
|
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
|
|
2014
2015
|
});
|
|
2015
2016
|
|
|
2016
|
-
// node_modules/@noble/hashes/_md.js
|
|
2017
|
+
// ../../node_modules/@noble/hashes/_md.js
|
|
2017
2018
|
var HashMD = class {
|
|
2018
2019
|
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
2019
2020
|
__publicField(this, "blockLen");
|
|
@@ -2128,7 +2129,7 @@ var SHA512_IV = /* @__PURE__ */ Uint32Array.from([
|
|
|
2128
2129
|
327033209
|
|
2129
2130
|
]);
|
|
2130
2131
|
|
|
2131
|
-
// node_modules/@noble/hashes/_u64.js
|
|
2132
|
+
// ../../node_modules/@noble/hashes/_u64.js
|
|
2132
2133
|
var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
2133
2134
|
var _32n = /* @__PURE__ */ BigInt(32);
|
|
2134
2135
|
function fromBig(n, le = false) {
|
|
@@ -2163,7 +2164,7 @@ var add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0
|
|
|
2163
2164
|
var add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
2164
2165
|
var add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
|
|
2165
2166
|
|
|
2166
|
-
// node_modules/@noble/hashes/sha2.js
|
|
2167
|
+
// ../../node_modules/@noble/hashes/sha2.js
|
|
2167
2168
|
var K512 = /* @__PURE__ */ (() => split([
|
|
2168
2169
|
"0x428a2f98d728ae22",
|
|
2169
2170
|
"0x7137449123ef65cd",
|
|
@@ -2375,82 +2376,265 @@ var sha512 = /* @__PURE__ */ createHasher(
|
|
|
2375
2376
|
ed25519.hashes.sha512 = sha512;
|
|
2376
2377
|
var ed = ed25519;
|
|
2377
2378
|
|
|
2378
|
-
// src/
|
|
2379
|
-
var
|
|
2379
|
+
// src/providers/MnemonicWalletProvider.ts
|
|
2380
|
+
var _MnemonicWalletProvider = class _MnemonicWalletProvider {
|
|
2380
2381
|
constructor(config, chain2) {
|
|
2381
2382
|
this.config = config;
|
|
2382
2383
|
this.chain = chain2;
|
|
2383
|
-
this.
|
|
2384
|
+
this.privateKey = null;
|
|
2385
|
+
}
|
|
2386
|
+
async getAddress() {
|
|
2387
|
+
try {
|
|
2388
|
+
const privateKey = this.getPrivateKey();
|
|
2389
|
+
const publicKey = ed.getPublicKey(privateKey);
|
|
2390
|
+
return FastsetClient.encodeBech32Address(publicKey);
|
|
2391
|
+
} catch {
|
|
2392
|
+
return null;
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
async getPublicKey() {
|
|
2396
|
+
try {
|
|
2397
|
+
const privateKey = this.getPrivateKey();
|
|
2398
|
+
const publicKey = ed.getPublicKey(privateKey);
|
|
2399
|
+
return uint8ArrayToHex(publicKey);
|
|
2400
|
+
} catch {
|
|
2401
|
+
return null;
|
|
2402
|
+
}
|
|
2384
2403
|
}
|
|
2385
2404
|
async signTransaction(tx) {
|
|
2405
|
+
const privateKey = this.getPrivateKey();
|
|
2386
2406
|
const msg = Transaction.serialize(tx);
|
|
2387
2407
|
const msgBytes = msg.toBytes();
|
|
2388
2408
|
const prefix = new TextEncoder().encode("Transaction::");
|
|
2389
2409
|
const dataToSign = new Uint8Array(prefix.length + msgBytes.length);
|
|
2390
2410
|
dataToSign.set(prefix, 0);
|
|
2391
2411
|
dataToSign.set(msgBytes, prefix.length);
|
|
2392
|
-
const
|
|
2393
|
-
if (!privateKey) throw new Error("Wallet not initialized - no private key provided");
|
|
2394
|
-
const privateKeyBytes = hexToUint8Array(privateKey);
|
|
2395
|
-
const signature = ed.sign(dataToSign, privateKeyBytes);
|
|
2412
|
+
const signature = ed.sign(dataToSign, privateKey);
|
|
2396
2413
|
return { ...tx, signature };
|
|
2397
2414
|
}
|
|
2398
2415
|
async signMessage(message) {
|
|
2399
|
-
const
|
|
2400
|
-
const
|
|
2401
|
-
|
|
2402
|
-
const privateKeyBytes = hexToUint8Array(privateKey);
|
|
2403
|
-
const signature = ed.sign(messageBytes, privateKeyBytes);
|
|
2416
|
+
const privateKey = this.getPrivateKey();
|
|
2417
|
+
const messageBytes = new TextEncoder().encode(message);
|
|
2418
|
+
const signature = ed.sign(messageBytes, privateKey);
|
|
2404
2419
|
return uint8ArrayToHex(signature);
|
|
2405
2420
|
}
|
|
2406
|
-
async signTransactions(txs) {
|
|
2407
|
-
return Promise.all(txs.map(async (tx) => this.signTransaction(tx)));
|
|
2408
|
-
}
|
|
2409
|
-
async sendTransaction(tx) {
|
|
2410
|
-
const { signature, ...transactionWithoutSignature } = tx;
|
|
2411
|
-
const _cert = await this.client.submitTransaction(transactionWithoutSignature, signature ?? null);
|
|
2412
|
-
return "TODO";
|
|
2413
|
-
}
|
|
2414
|
-
async sendTransactions(txs) {
|
|
2415
|
-
return Promise.all(txs.map(async (tx) => this.sendTransaction(tx)));
|
|
2416
|
-
}
|
|
2417
2421
|
create(mnemonic) {
|
|
2418
2422
|
const seed = bip39.mnemonicToSeedSync(mnemonic);
|
|
2419
2423
|
const privateKey = seed.slice(0, 32);
|
|
2420
2424
|
const publicKey = ed.getPublicKey(privateKey);
|
|
2421
2425
|
const address = FastsetClient.encodeBech32Address(publicKey);
|
|
2422
|
-
return {
|
|
2426
|
+
return {
|
|
2427
|
+
provider: _MnemonicWalletProvider.PROVIDER_NAME,
|
|
2428
|
+
address,
|
|
2429
|
+
privateKey: null,
|
|
2430
|
+
mnemonic
|
|
2431
|
+
};
|
|
2423
2432
|
}
|
|
2424
2433
|
generate() {
|
|
2425
|
-
const
|
|
2434
|
+
const mnemonic = bip39.generateMnemonic(import_english.wordlist);
|
|
2435
|
+
const seed = bip39.mnemonicToSeedSync(mnemonic);
|
|
2436
|
+
const privateKey = seed.slice(0, 32);
|
|
2426
2437
|
const publicKey = ed.getPublicKey(privateKey);
|
|
2427
2438
|
const address = FastsetClient.encodeBech32Address(publicKey);
|
|
2428
|
-
return {
|
|
2439
|
+
return {
|
|
2440
|
+
provider: _MnemonicWalletProvider.PROVIDER_NAME,
|
|
2441
|
+
address,
|
|
2442
|
+
privateKey: null,
|
|
2443
|
+
mnemonic
|
|
2444
|
+
};
|
|
2429
2445
|
}
|
|
2430
|
-
|
|
2431
|
-
|
|
2446
|
+
getPrivateKey() {
|
|
2447
|
+
if (this.privateKey) return this.privateKey;
|
|
2448
|
+
const mnemonic = (0, import_warps5.getWarpWalletMnemonicFromConfig)(this.config, this.chain.name);
|
|
2449
|
+
if (!mnemonic) throw new Error("No mnemonic provided");
|
|
2450
|
+
const seed = bip39.mnemonicToSeedSync(mnemonic);
|
|
2451
|
+
this.privateKey = seed.slice(0, 32);
|
|
2452
|
+
return this.privateKey;
|
|
2432
2453
|
}
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2454
|
+
};
|
|
2455
|
+
_MnemonicWalletProvider.PROVIDER_NAME = "mnemonic";
|
|
2456
|
+
var MnemonicWalletProvider = _MnemonicWalletProvider;
|
|
2457
|
+
|
|
2458
|
+
// src/providers/PrivateKeyWalletProvider.ts
|
|
2459
|
+
var import_warps6 = require("@vleap/warps");
|
|
2460
|
+
var _PrivateKeyWalletProvider = class _PrivateKeyWalletProvider {
|
|
2461
|
+
constructor(config, chain2) {
|
|
2462
|
+
this.config = config;
|
|
2463
|
+
this.chain = chain2;
|
|
2464
|
+
this.privateKey = null;
|
|
2465
|
+
}
|
|
2466
|
+
async getAddress() {
|
|
2467
|
+
try {
|
|
2468
|
+
const privateKey = this.getPrivateKey();
|
|
2469
|
+
const publicKey = ed.getPublicKey(privateKey);
|
|
2470
|
+
return FastsetClient.encodeBech32Address(publicKey);
|
|
2471
|
+
} catch {
|
|
2472
|
+
return null;
|
|
2439
2473
|
}
|
|
2440
|
-
|
|
2441
|
-
|
|
2474
|
+
}
|
|
2475
|
+
async getPublicKey() {
|
|
2442
2476
|
try {
|
|
2443
|
-
const
|
|
2444
|
-
|
|
2477
|
+
const privateKey = this.getPrivateKey();
|
|
2478
|
+
const publicKey = ed.getPublicKey(privateKey);
|
|
2479
|
+
return uint8ArrayToHex(publicKey);
|
|
2445
2480
|
} catch {
|
|
2446
2481
|
return null;
|
|
2447
2482
|
}
|
|
2448
2483
|
}
|
|
2484
|
+
async signTransaction(tx) {
|
|
2485
|
+
const privateKey = this.getPrivateKey();
|
|
2486
|
+
const msg = Transaction.serialize(tx);
|
|
2487
|
+
const msgBytes = msg.toBytes();
|
|
2488
|
+
const prefix = new TextEncoder().encode("Transaction::");
|
|
2489
|
+
const dataToSign = new Uint8Array(prefix.length + msgBytes.length);
|
|
2490
|
+
dataToSign.set(prefix, 0);
|
|
2491
|
+
dataToSign.set(msgBytes, prefix.length);
|
|
2492
|
+
const signature = ed.sign(dataToSign, privateKey);
|
|
2493
|
+
return { ...tx, signature };
|
|
2494
|
+
}
|
|
2495
|
+
async signMessage(message) {
|
|
2496
|
+
const privateKey = this.getPrivateKey();
|
|
2497
|
+
const messageBytes = new TextEncoder().encode(message);
|
|
2498
|
+
const signature = ed.sign(messageBytes, privateKey);
|
|
2499
|
+
return uint8ArrayToHex(signature);
|
|
2500
|
+
}
|
|
2501
|
+
create(mnemonic) {
|
|
2502
|
+
throw new Error("PrivateKeyWalletProvider does not support creating wallets from mnemonics. Use MnemonicWalletProvider instead.");
|
|
2503
|
+
}
|
|
2504
|
+
generate() {
|
|
2505
|
+
const privateKey = ed.utils.randomSecretKey();
|
|
2506
|
+
const publicKey = ed.getPublicKey(privateKey);
|
|
2507
|
+
const address = FastsetClient.encodeBech32Address(publicKey);
|
|
2508
|
+
return {
|
|
2509
|
+
provider: _PrivateKeyWalletProvider.PROVIDER_NAME,
|
|
2510
|
+
address,
|
|
2511
|
+
privateKey: uint8ArrayToHex(privateKey),
|
|
2512
|
+
mnemonic: null
|
|
2513
|
+
};
|
|
2514
|
+
}
|
|
2515
|
+
getPrivateKey() {
|
|
2516
|
+
if (this.privateKey) return this.privateKey;
|
|
2517
|
+
const privateKeyHex = (0, import_warps6.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
|
|
2518
|
+
if (!privateKeyHex) throw new Error("No private key provided");
|
|
2519
|
+
this.privateKey = hexToUint8Array(privateKeyHex);
|
|
2520
|
+
return this.privateKey;
|
|
2521
|
+
}
|
|
2522
|
+
};
|
|
2523
|
+
_PrivateKeyWalletProvider.PROVIDER_NAME = "privateKey";
|
|
2524
|
+
var PrivateKeyWalletProvider = _PrivateKeyWalletProvider;
|
|
2525
|
+
|
|
2526
|
+
// src/providers/ReadOnlyWalletProvider.ts
|
|
2527
|
+
var import_warps7 = require("@vleap/warps");
|
|
2528
|
+
var ReadOnlyWalletProvider = class {
|
|
2529
|
+
constructor(config, chain2) {
|
|
2530
|
+
this.config = config;
|
|
2531
|
+
this.chain = chain2;
|
|
2532
|
+
}
|
|
2533
|
+
async getAddress() {
|
|
2534
|
+
return (0, import_warps7.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
|
|
2535
|
+
}
|
|
2536
|
+
async getPublicKey() {
|
|
2537
|
+
return null;
|
|
2538
|
+
}
|
|
2539
|
+
async signTransaction(tx) {
|
|
2540
|
+
const address = await this.getAddress();
|
|
2541
|
+
throw new Error(`Wallet can not be used for signing: ${address}`);
|
|
2542
|
+
}
|
|
2543
|
+
async signMessage(message) {
|
|
2544
|
+
const address = await this.getAddress();
|
|
2545
|
+
throw new Error(`Wallet can not be used for signing: ${address}`);
|
|
2546
|
+
}
|
|
2547
|
+
create(mnemonic) {
|
|
2548
|
+
const address = (0, import_warps7.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
|
|
2549
|
+
throw new Error(`Wallet can not be used for signing: ${address}`);
|
|
2550
|
+
}
|
|
2551
|
+
generate() {
|
|
2552
|
+
const address = (0, import_warps7.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
|
|
2553
|
+
throw new Error(`Wallet can not be used for signing: ${address}`);
|
|
2554
|
+
}
|
|
2555
|
+
};
|
|
2556
|
+
|
|
2557
|
+
// src/WarpFastsetWallet.ts
|
|
2558
|
+
var WarpFastsetWallet = class {
|
|
2559
|
+
constructor(config, chain2) {
|
|
2560
|
+
this.config = config;
|
|
2561
|
+
this.chain = chain2;
|
|
2562
|
+
this.cachedAddress = null;
|
|
2563
|
+
this.cachedPublicKey = null;
|
|
2564
|
+
this.client = getConfiguredFastsetClient(this.config, this.chain);
|
|
2565
|
+
this.walletProvider = this.createProvider();
|
|
2566
|
+
this.initializeCache();
|
|
2567
|
+
}
|
|
2568
|
+
async signTransaction(tx) {
|
|
2569
|
+
if (!tx || typeof tx !== "object") throw new Error("Invalid transaction object");
|
|
2570
|
+
if (!this.walletProvider) throw new Error("No wallet provider available");
|
|
2571
|
+
if (this.walletProvider instanceof ReadOnlyWalletProvider) throw new Error(`Wallet (${this.chain.name}) is read-only`);
|
|
2572
|
+
return await this.walletProvider.signTransaction(tx);
|
|
2573
|
+
}
|
|
2574
|
+
async signTransactions(txs) {
|
|
2575
|
+
if (txs.length === 0) return [];
|
|
2576
|
+
const signedTxs = [];
|
|
2577
|
+
for (const tx of txs) {
|
|
2578
|
+
signedTxs.push(await this.signTransaction(tx));
|
|
2579
|
+
}
|
|
2580
|
+
return signedTxs;
|
|
2581
|
+
}
|
|
2582
|
+
async signMessage(message) {
|
|
2583
|
+
if (!this.walletProvider) throw new Error("No wallet provider available");
|
|
2584
|
+
if (this.walletProvider instanceof ReadOnlyWalletProvider) throw new Error(`Wallet (${this.chain.name}) is read-only`);
|
|
2585
|
+
return await this.walletProvider.signMessage(message);
|
|
2586
|
+
}
|
|
2587
|
+
async sendTransaction(tx) {
|
|
2588
|
+
const { signature, ...transactionWithoutSignature } = tx;
|
|
2589
|
+
const _cert = await this.client.submitTransaction(transactionWithoutSignature, signature ?? null);
|
|
2590
|
+
return "TODO";
|
|
2591
|
+
}
|
|
2592
|
+
async sendTransactions(txs) {
|
|
2593
|
+
return Promise.all(txs.map(async (tx) => this.sendTransaction(tx)));
|
|
2594
|
+
}
|
|
2595
|
+
create(provider, mnemonic) {
|
|
2596
|
+
const walletProvider = this.createProviderForOperation(provider);
|
|
2597
|
+
return walletProvider.create(mnemonic);
|
|
2598
|
+
}
|
|
2599
|
+
generate(provider) {
|
|
2600
|
+
const walletProvider = this.createProviderForOperation(provider);
|
|
2601
|
+
return walletProvider.generate();
|
|
2602
|
+
}
|
|
2603
|
+
getAddress() {
|
|
2604
|
+
return this.cachedAddress;
|
|
2605
|
+
}
|
|
2606
|
+
getPublicKey() {
|
|
2607
|
+
return this.cachedPublicKey;
|
|
2608
|
+
}
|
|
2609
|
+
createProvider() {
|
|
2610
|
+
const wallet = this.config.user?.wallets?.[this.chain.name];
|
|
2611
|
+
if (!wallet) return null;
|
|
2612
|
+
if (typeof wallet === "string") return new ReadOnlyWalletProvider(this.config, this.chain);
|
|
2613
|
+
return this.createProviderForOperation(wallet.provider);
|
|
2614
|
+
}
|
|
2615
|
+
initializeCache() {
|
|
2616
|
+
(0, import_warps8.initializeWalletCache)(this.walletProvider).then((cache) => {
|
|
2617
|
+
this.cachedAddress = cache.address;
|
|
2618
|
+
this.cachedPublicKey = cache.publicKey;
|
|
2619
|
+
});
|
|
2620
|
+
}
|
|
2621
|
+
createProviderForOperation(provider) {
|
|
2622
|
+
const customWalletProviders = this.config.walletProviders?.[this.chain.name];
|
|
2623
|
+
const providerFactory = customWalletProviders?.[provider];
|
|
2624
|
+
if (providerFactory) {
|
|
2625
|
+
const walletProvider = providerFactory(this.config, this.chain);
|
|
2626
|
+
if (!walletProvider) throw new Error(`Custom wallet provider factory returned null for ${provider}`);
|
|
2627
|
+
return walletProvider;
|
|
2628
|
+
}
|
|
2629
|
+
if (provider === "privateKey") return new PrivateKeyWalletProvider(this.config, this.chain);
|
|
2630
|
+
if (provider === "mnemonic") return new MnemonicWalletProvider(this.config, this.chain);
|
|
2631
|
+
throw new Error(`Unsupported wallet provider for ${this.chain.name}: ${provider}`);
|
|
2632
|
+
}
|
|
2449
2633
|
};
|
|
2450
2634
|
|
|
2451
2635
|
// src/main.ts
|
|
2452
2636
|
var NativeTokenSet = {
|
|
2453
|
-
chain:
|
|
2637
|
+
chain: import_warps9.WarpChainName.Fastset,
|
|
2454
2638
|
identifier: "SET",
|
|
2455
2639
|
name: "SET",
|
|
2456
2640
|
symbol: "SET",
|
|
@@ -2477,9 +2661,9 @@ function createFastsetAdapter(chainName, chainInfos) {
|
|
|
2477
2661
|
};
|
|
2478
2662
|
};
|
|
2479
2663
|
}
|
|
2480
|
-
var FastsetAdapter = createFastsetAdapter(
|
|
2664
|
+
var FastsetAdapter = createFastsetAdapter(import_warps9.WarpChainName.Fastset, {
|
|
2481
2665
|
mainnet: {
|
|
2482
|
-
name:
|
|
2666
|
+
name: import_warps9.WarpChainName.Fastset,
|
|
2483
2667
|
displayName: "FastSet",
|
|
2484
2668
|
chainId: "1",
|
|
2485
2669
|
blockTime: 1e3,
|
|
@@ -2489,7 +2673,7 @@ var FastsetAdapter = createFastsetAdapter(import_warps6.WarpChainName.Fastset, {
|
|
|
2489
2673
|
nativeToken: NativeTokenSet
|
|
2490
2674
|
},
|
|
2491
2675
|
testnet: {
|
|
2492
|
-
name:
|
|
2676
|
+
name: import_warps9.WarpChainName.Fastset,
|
|
2493
2677
|
displayName: "FastSet Testnet",
|
|
2494
2678
|
chainId: "testnet",
|
|
2495
2679
|
blockTime: 1e3,
|
|
@@ -2499,7 +2683,7 @@ var FastsetAdapter = createFastsetAdapter(import_warps6.WarpChainName.Fastset, {
|
|
|
2499
2683
|
nativeToken: NativeTokenSet
|
|
2500
2684
|
},
|
|
2501
2685
|
devnet: {
|
|
2502
|
-
name:
|
|
2686
|
+
name: import_warps9.WarpChainName.Fastset,
|
|
2503
2687
|
displayName: "FastSet Devnet",
|
|
2504
2688
|
chainId: "devnet",
|
|
2505
2689
|
blockTime: 1e3,
|