@vleap/warps-adapter-fastset 0.1.0-beta.52 → 0.1.0-beta.54

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 CHANGED
@@ -1,4 +1,4 @@
1
- import { WarpChainAsset, ChainAdapterFactory, AdapterWarpExecutor, WarpClientConfig, WarpChainInfo, WarpExecutable, WarpAdapterGenericTransaction, AdapterWarpWallet, WarpWalletProvider, WarpWalletDetails } from '@vleap/warps';
1
+ import { WarpChainAsset, ChainAdapterFactory, AdapterWarpExecutor, WarpClientConfig, WarpChainInfo, WarpExecutable, WarpAdapterGenericTransaction, AdapterWarpWallet, WarpWalletDetails, WarpWalletProvider } from '@vleap/warps';
2
2
 
3
3
  declare const NativeTokenSet: WarpChainAsset;
4
4
  declare const FastsetAdapter: ChainAdapterFactory;
@@ -27,8 +27,10 @@ declare class WarpFastsetWallet implements AdapterWarpWallet {
27
27
  signMessage(message: string): Promise<string>;
28
28
  sendTransaction(tx: WarpAdapterGenericTransaction): Promise<string>;
29
29
  sendTransactions(txs: WarpAdapterGenericTransaction[]): Promise<string[]>;
30
- create(provider: WarpWalletProvider, mnemonic: string): WarpWalletDetails;
31
- generate(provider: WarpWalletProvider): WarpWalletDetails;
30
+ importFromMnemonic(mnemonic: string): Promise<WarpWalletDetails>;
31
+ importFromPrivateKey(privateKey: string): Promise<WarpWalletDetails>;
32
+ export(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
33
+ generate(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
32
34
  getAddress(): string | null;
33
35
  getPublicKey(): string | null;
34
36
  private createProvider;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { WarpChainAsset, ChainAdapterFactory, AdapterWarpExecutor, WarpClientConfig, WarpChainInfo, WarpExecutable, WarpAdapterGenericTransaction, AdapterWarpWallet, WarpWalletProvider, WarpWalletDetails } from '@vleap/warps';
1
+ import { WarpChainAsset, ChainAdapterFactory, AdapterWarpExecutor, WarpClientConfig, WarpChainInfo, WarpExecutable, WarpAdapterGenericTransaction, AdapterWarpWallet, WarpWalletDetails, WarpWalletProvider } from '@vleap/warps';
2
2
 
3
3
  declare const NativeTokenSet: WarpChainAsset;
4
4
  declare const FastsetAdapter: ChainAdapterFactory;
@@ -27,8 +27,10 @@ declare class WarpFastsetWallet implements AdapterWarpWallet {
27
27
  signMessage(message: string): Promise<string>;
28
28
  sendTransaction(tx: WarpAdapterGenericTransaction): Promise<string>;
29
29
  sendTransactions(txs: WarpAdapterGenericTransaction[]): Promise<string[]>;
30
- create(provider: WarpWalletProvider, mnemonic: string): WarpWalletDetails;
31
- generate(provider: WarpWalletProvider): WarpWalletDetails;
30
+ importFromMnemonic(mnemonic: string): Promise<WarpWalletDetails>;
31
+ importFromPrivateKey(privateKey: string): Promise<WarpWalletDetails>;
32
+ export(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
33
+ generate(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
32
34
  getAddress(): string | null;
33
35
  getPublicKey(): string | null;
34
36
  private createProvider;
package/dist/index.js CHANGED
@@ -2424,19 +2424,47 @@ var _MnemonicWalletProvider = class _MnemonicWalletProvider {
2424
2424
  const signature = ed.sign(messageBytes, privateKey);
2425
2425
  return uint8ArrayToHex(signature);
2426
2426
  }
2427
- create(mnemonic) {
2427
+ async importFromMnemonic(mnemonic) {
2428
2428
  const seed = bip39.mnemonicToSeedSync(mnemonic);
2429
2429
  const privateKey = seed.slice(0, 32);
2430
2430
  const publicKey = ed.getPublicKey(privateKey);
2431
2431
  const address = FastsetClient.encodeBech32Address(publicKey);
2432
- return {
2432
+ const walletDetails = {
2433
2433
  provider: _MnemonicWalletProvider.PROVIDER_NAME,
2434
2434
  address,
2435
- privateKey: null,
2435
+ privateKey: uint8ArrayToHex(privateKey),
2436
2436
  mnemonic
2437
2437
  };
2438
+ (0, import_warps5.setWarpWalletInConfig)(this.config, this.chain.name, walletDetails);
2439
+ return walletDetails;
2438
2440
  }
2439
- generate() {
2441
+ async importFromPrivateKey(privateKey) {
2442
+ const privateKeyBytes = Buffer.from(privateKey, "hex");
2443
+ const publicKey = ed.getPublicKey(new Uint8Array(privateKeyBytes));
2444
+ const address = FastsetClient.encodeBech32Address(publicKey);
2445
+ const walletDetails = {
2446
+ provider: _MnemonicWalletProvider.PROVIDER_NAME,
2447
+ address,
2448
+ privateKey,
2449
+ mnemonic: null
2450
+ };
2451
+ (0, import_warps5.setWarpWalletInConfig)(this.config, this.chain.name, walletDetails);
2452
+ return walletDetails;
2453
+ }
2454
+ async export() {
2455
+ const privateKey = this.getPrivateKey();
2456
+ const mnemonic = (0, import_warps5.getWarpWalletMnemonicFromConfig)(this.config, this.chain.name);
2457
+ const privateKeyHex = (0, import_warps5.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
2458
+ const publicKey = ed.getPublicKey(privateKey);
2459
+ const address = FastsetClient.encodeBech32Address(publicKey);
2460
+ return {
2461
+ provider: _MnemonicWalletProvider.PROVIDER_NAME,
2462
+ address,
2463
+ privateKey: privateKeyHex || null,
2464
+ mnemonic: mnemonic || null
2465
+ };
2466
+ }
2467
+ async generate() {
2440
2468
  const mnemonic = bip39.generateMnemonic(import_english.wordlist);
2441
2469
  const seed = bip39.mnemonicToSeedSync(mnemonic);
2442
2470
  const privateKey = seed.slice(0, 32);
@@ -2505,19 +2533,47 @@ var _PrivateKeyWalletProvider = class _PrivateKeyWalletProvider {
2505
2533
  const signature = ed.sign(messageBytes, privateKey);
2506
2534
  return uint8ArrayToHex(signature);
2507
2535
  }
2508
- create(mnemonic) {
2536
+ async importFromMnemonic(mnemonic) {
2509
2537
  const seed = bip392.mnemonicToSeedSync(mnemonic);
2510
2538
  const privateKey = seed.slice(0, 32);
2511
2539
  const publicKey = ed.getPublicKey(privateKey);
2512
2540
  const address = FastsetClient.encodeBech32Address(publicKey);
2513
- return {
2541
+ const walletDetails = {
2514
2542
  provider: _PrivateKeyWalletProvider.PROVIDER_NAME,
2515
2543
  address,
2516
2544
  privateKey: uint8ArrayToHex(privateKey),
2545
+ mnemonic
2546
+ };
2547
+ (0, import_warps6.setWarpWalletInConfig)(this.config, this.chain.name, walletDetails);
2548
+ return walletDetails;
2549
+ }
2550
+ async importFromPrivateKey(privateKey) {
2551
+ const privateKeyBytes = hexToUint8Array(privateKey);
2552
+ const publicKey = ed.getPublicKey(privateKeyBytes);
2553
+ const address = FastsetClient.encodeBech32Address(publicKey);
2554
+ const walletDetails = {
2555
+ provider: _PrivateKeyWalletProvider.PROVIDER_NAME,
2556
+ address,
2557
+ privateKey,
2517
2558
  mnemonic: null
2518
2559
  };
2560
+ (0, import_warps6.setWarpWalletInConfig)(this.config, this.chain.name, walletDetails);
2561
+ return walletDetails;
2519
2562
  }
2520
- generate() {
2563
+ async export() {
2564
+ const privateKey = this.getPrivateKey();
2565
+ const privateKeyHex = (0, import_warps6.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
2566
+ const mnemonic = (0, import_warps6.getWarpWalletMnemonicFromConfig)(this.config, this.chain.name);
2567
+ const publicKey = ed.getPublicKey(privateKey);
2568
+ const address = FastsetClient.encodeBech32Address(publicKey);
2569
+ return {
2570
+ provider: _PrivateKeyWalletProvider.PROVIDER_NAME,
2571
+ address,
2572
+ privateKey: privateKeyHex || null,
2573
+ mnemonic: mnemonic || null
2574
+ };
2575
+ }
2576
+ async generate() {
2521
2577
  const privateKey = ed.utils.randomSecretKey();
2522
2578
  const publicKey = ed.getPublicKey(privateKey);
2523
2579
  const address = FastsetClient.encodeBech32Address(publicKey);
@@ -2560,11 +2616,19 @@ var ReadOnlyWalletProvider = class {
2560
2616
  const address = await this.getAddress();
2561
2617
  throw new Error(`Wallet can not be used for signing: ${address}`);
2562
2618
  }
2563
- create(mnemonic) {
2619
+ async importFromMnemonic(mnemonic) {
2620
+ const address = (0, import_warps7.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
2621
+ throw new Error(`Wallet can not be used for signing: ${address}`);
2622
+ }
2623
+ async importFromPrivateKey(privateKey) {
2564
2624
  const address = (0, import_warps7.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
2565
2625
  throw new Error(`Wallet can not be used for signing: ${address}`);
2566
2626
  }
2567
- generate() {
2627
+ async export() {
2628
+ const address = (0, import_warps7.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
2629
+ throw new Error(`Wallet can not be used for signing: ${address}`);
2630
+ }
2631
+ async generate() {
2568
2632
  const address = (0, import_warps7.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
2569
2633
  throw new Error(`Wallet can not be used for signing: ${address}`);
2570
2634
  }
@@ -2608,13 +2672,21 @@ var WarpFastsetWallet = class {
2608
2672
  async sendTransactions(txs) {
2609
2673
  return Promise.all(txs.map(async (tx) => this.sendTransaction(tx)));
2610
2674
  }
2611
- create(provider, mnemonic) {
2675
+ async importFromMnemonic(mnemonic) {
2676
+ const walletProvider = this.createProviderForOperation("mnemonic");
2677
+ return await walletProvider.importFromMnemonic(mnemonic);
2678
+ }
2679
+ async importFromPrivateKey(privateKey) {
2680
+ const walletProvider = this.createProviderForOperation("privateKey");
2681
+ return await walletProvider.importFromPrivateKey(privateKey);
2682
+ }
2683
+ async export(provider) {
2612
2684
  const walletProvider = this.createProviderForOperation(provider);
2613
- return walletProvider.create(mnemonic);
2685
+ return await walletProvider.export();
2614
2686
  }
2615
- generate(provider) {
2687
+ async generate(provider) {
2616
2688
  const walletProvider = this.createProviderForOperation(provider);
2617
- return walletProvider.generate();
2689
+ return await walletProvider.generate();
2618
2690
  }
2619
2691
  getAddress() {
2620
2692
  return this.cachedAddress;