@atomiqlabs/chain-evm 1.0.0-dev.95 → 1.0.0-dev.97

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.
@@ -10,4 +10,5 @@ import { EVMSpvWithdrawalData } from "../../evm/spv_swap/EVMSpvWithdrawalData";
10
10
  import { EVMSwapContract } from "../../evm/swaps/EVMSwapContract";
11
11
  import { EVMBtcRelay } from "../../evm/btcrelay/EVMBtcRelay";
12
12
  import { EVMSpvVaultContract } from "../../evm/spv_swap/EVMSpvVaultContract";
13
- export type BotanixChainType = ChainType<"BOTANIX", never, EVMPreFetchVerification, EVMTx, EVMSigner, EVMSwapData, EVMSwapContract<"BOTANIX">, EVMChainInterface<"BOTANIX">, EVMChainEventsBrowser, EVMBtcRelay<any>, EVMSpvVaultData, EVMSpvWithdrawalData, EVMSpvVaultContract<"BOTANIX">>;
13
+ import { Signer } from "ethers";
14
+ export type BotanixChainType = ChainType<"BOTANIX", never, EVMPreFetchVerification, EVMTx, EVMSigner, Signer, EVMSwapData, EVMSwapContract<"BOTANIX">, EVMChainInterface<"BOTANIX">, EVMChainEventsBrowser, EVMBtcRelay<any>, EVMSpvVaultData, EVMSpvWithdrawalData, EVMSpvVaultContract<"BOTANIX">>;
@@ -10,4 +10,5 @@ import { EVMSpvWithdrawalData } from "../../evm/spv_swap/EVMSpvWithdrawalData";
10
10
  import { CitreaSwapContract } from "./CitreaSwapContract";
11
11
  import { CitreaBtcRelay } from "./CitreaBtcRelay";
12
12
  import { CitreaSpvVaultContract } from "./CitreaSpvVaultContract";
13
- export type CitreaChainType = ChainType<"CITREA", never, EVMPreFetchVerification, EVMTx, EVMSigner, EVMSwapData, CitreaSwapContract, EVMChainInterface<"CITREA">, EVMChainEventsBrowser, CitreaBtcRelay<any>, EVMSpvVaultData, EVMSpvWithdrawalData, CitreaSpvVaultContract>;
13
+ import { Signer } from "ethers";
14
+ export type CitreaChainType = ChainType<"CITREA", never, EVMPreFetchVerification, EVMTx, EVMSigner, Signer, EVMSwapData, CitreaSwapContract, EVMChainInterface<"CITREA">, EVMChainEventsBrowser, CitreaBtcRelay<any>, EVMSpvVaultData, EVMSpvWithdrawalData, CitreaSpvVaultContract>;
@@ -1,11 +1,11 @@
1
1
  import { ChainInterface, TransactionConfirmationOptions } from "@atomiqlabs/base";
2
2
  import { LoggerType } from "../../utils/Utils";
3
- import { JsonRpcApiProvider, Transaction, TransactionRequest } from "ethers";
3
+ import { JsonRpcApiProvider, Signer, Transaction, TransactionRequest } from "ethers";
4
4
  import { EVMBlocks, EVMBlockTag } from "./modules/EVMBlocks";
5
5
  import { EVMEvents } from "./modules/EVMEvents";
6
6
  import { EVMFees } from "./modules/EVMFees";
7
7
  import { EVMTokens } from "./modules/EVMTokens";
8
- import { EVMTransactions } from "./modules/EVMTransactions";
8
+ import { EVMTransactions, EVMTx } from "./modules/EVMTransactions";
9
9
  import { EVMSignatures } from "./modules/EVMSignatures";
10
10
  import { EVMSigner } from "../wallet/EVMSigner";
11
11
  export type EVMRetryPolicy = {
@@ -20,7 +20,7 @@ export type EVMConfiguration = {
20
20
  maxParallelCalls: number;
21
21
  maxLogTopics: number;
22
22
  };
23
- export declare class EVMChainInterface<ChainId extends string = string> implements ChainInterface {
23
+ export declare class EVMChainInterface<ChainId extends string = string> implements ChainInterface<EVMTx, EVMSigner, ChainId, Signer> {
24
24
  readonly chainId: ChainId;
25
25
  readonly provider: JsonRpcApiProvider;
26
26
  readonly retryPolicy: EVMRetryPolicy;
@@ -51,4 +51,5 @@ export declare class EVMChainInterface<ChainId extends string = string> implemen
51
51
  getTxStatus(tx: string): Promise<"not_found" | "pending" | "success" | "reverted">;
52
52
  txsTransfer(signer: string, token: string, amount: bigint, dstAddress: string, feeRate?: string): Promise<TransactionRequest[]>;
53
53
  transfer(signer: EVMSigner, token: string, amount: bigint, dstAddress: string, txOptions?: TransactionConfirmationOptions): Promise<string>;
54
+ wrapSigner(signer: Signer): Promise<EVMSigner>;
54
55
  }
@@ -11,6 +11,7 @@ const EVMTransactions_1 = require("./modules/EVMTransactions");
11
11
  const EVMSignatures_1 = require("./modules/EVMSignatures");
12
12
  const EVMAddresses_1 = require("./modules/EVMAddresses");
13
13
  const EVMSigner_1 = require("../wallet/EVMSigner");
14
+ const EVMBrowserSigner_1 = require("../wallet/EVMBrowserSigner");
14
15
  class EVMChainInterface {
15
16
  constructor(chainId, evmChainId, provider, config, retryPolicy, evmFeeEstimator = new EVMFees_1.EVMFees(provider)) {
16
17
  var _a;
@@ -85,5 +86,12 @@ class EVMChainInterface {
85
86
  const [txId] = await this.Transactions.sendAndConfirm(signer, [tx], txOptions?.waitForConfirmation, txOptions?.abortSignal, false);
86
87
  return txId;
87
88
  }
89
+ async wrapSigner(signer) {
90
+ const address = await signer.getAddress();
91
+ if (signer instanceof ethers_1.JsonRpcSigner || signer.provider instanceof ethers_1.BrowserProvider) {
92
+ return new EVMBrowserSigner_1.EVMBrowserSigner(signer, address);
93
+ }
94
+ return new EVMSigner_1.EVMSigner(signer, address);
95
+ }
88
96
  }
89
97
  exports.EVMChainInterface = EVMChainInterface;
@@ -1,6 +1,7 @@
1
1
  import { AbstractSigner } from "@atomiqlabs/base";
2
2
  import { Signer, TransactionRequest, TransactionResponse } from "ethers";
3
3
  export declare class EVMSigner implements AbstractSigner {
4
+ type: "AtomiqAbstractSigner";
4
5
  account: Signer;
5
6
  readonly address: string;
6
7
  readonly isManagingNoncesInternally: boolean;
@@ -4,6 +4,7 @@ exports.EVMSigner = void 0;
4
4
  const ethers_1 = require("ethers");
5
5
  class EVMSigner {
6
6
  constructor(account, address, isManagingNoncesInternally = false) {
7
+ this.type = "AtomiqAbstractSigner";
7
8
  this.account = account;
8
9
  this.address = address;
9
10
  this.isManagingNoncesInternally = isManagingNoncesInternally;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/chain-evm",
3
- "version": "1.0.0-dev.95",
3
+ "version": "1.0.0-dev.97",
4
4
  "description": "EVM specific base implementation",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "author": "adambor",
24
24
  "license": "Apache-2.0",
25
25
  "dependencies": {
26
- "@atomiqlabs/base": "^10.0.0-dev.13",
26
+ "@atomiqlabs/base": "^10.0.0-dev.16",
27
27
  "@noble/hashes": "^1.8.0",
28
28
  "@scure/btc-signer": "^1.6.0",
29
29
  "buffer": "6.0.3",
@@ -10,6 +10,7 @@ import { EVMSpvWithdrawalData } from "../../evm/spv_swap/EVMSpvWithdrawalData";
10
10
  import {EVMSwapContract} from "../../evm/swaps/EVMSwapContract";
11
11
  import {EVMBtcRelay} from "../../evm/btcrelay/EVMBtcRelay";
12
12
  import {EVMSpvVaultContract} from "../../evm/spv_swap/EVMSpvVaultContract";
13
+ import {Signer} from "ethers";
13
14
 
14
15
  export type BotanixChainType = ChainType<
15
16
  "BOTANIX",
@@ -17,6 +18,7 @@ export type BotanixChainType = ChainType<
17
18
  EVMPreFetchVerification,
18
19
  EVMTx,
19
20
  EVMSigner,
21
+ Signer,
20
22
  EVMSwapData,
21
23
  EVMSwapContract<"BOTANIX">,
22
24
  EVMChainInterface<"BOTANIX">,
@@ -10,6 +10,7 @@ import { EVMSpvWithdrawalData } from "../../evm/spv_swap/EVMSpvWithdrawalData";
10
10
  import {CitreaSwapContract} from "./CitreaSwapContract";
11
11
  import {CitreaBtcRelay} from "./CitreaBtcRelay";
12
12
  import {CitreaSpvVaultContract} from "./CitreaSpvVaultContract";
13
+ import {Signer} from "ethers";
13
14
 
14
15
  export type CitreaChainType = ChainType<
15
16
  "CITREA",
@@ -17,6 +18,7 @@ export type CitreaChainType = ChainType<
17
18
  EVMPreFetchVerification,
18
19
  EVMTx,
19
20
  EVMSigner,
21
+ Signer,
20
22
  EVMSwapData,
21
23
  CitreaSwapContract,
22
24
  EVMChainInterface<"CITREA">,
@@ -1,14 +1,24 @@
1
1
  import {ChainInterface, TransactionConfirmationOptions} from "@atomiqlabs/base";
2
2
  import {getLogger, LoggerType} from "../../utils/Utils";
3
- import {JsonRpcApiProvider, Transaction, TransactionRequest, Wallet} from "ethers";
3
+ import {
4
+ BrowserProvider,
5
+ JsonRpcApiProvider,
6
+ JsonRpcSigner,
7
+ Signer,
8
+ Transaction,
9
+ TransactionRequest,
10
+ Wallet
11
+ } from "ethers";
4
12
  import {EVMBlocks, EVMBlockTag} from "./modules/EVMBlocks";
5
13
  import {EVMEvents} from "./modules/EVMEvents";
6
14
  import {EVMFees} from "./modules/EVMFees";
7
15
  import {EVMTokens} from "./modules/EVMTokens";
8
- import { EVMTransactions } from "./modules/EVMTransactions";
16
+ import {EVMTransactions, EVMTx} from "./modules/EVMTransactions";
9
17
  import { EVMSignatures } from "./modules/EVMSignatures";
10
18
  import {EVMAddresses} from "./modules/EVMAddresses";
11
19
  import {EVMSigner} from "../wallet/EVMSigner";
20
+ import {EVMBrowserSigner} from "../wallet/EVMBrowserSigner";
21
+ import {add} from "@noble/hashes/_u64";
12
22
 
13
23
  export type EVMRetryPolicy = {
14
24
  maxRetries?: number,
@@ -24,7 +34,7 @@ export type EVMConfiguration = {
24
34
  maxLogTopics: number
25
35
  };
26
36
 
27
- export class EVMChainInterface<ChainId extends string = string> implements ChainInterface {
37
+ export class EVMChainInterface<ChainId extends string = string> implements ChainInterface<EVMTx, EVMSigner, ChainId, Signer> {
28
38
 
29
39
  readonly chainId: ChainId;
30
40
 
@@ -156,4 +166,12 @@ export class EVMChainInterface<ChainId extends string = string> implements Chain
156
166
  return txId;
157
167
  }
158
168
 
169
+ async wrapSigner(signer: Signer): Promise<EVMSigner> {
170
+ const address = await signer.getAddress();
171
+ if(signer instanceof JsonRpcSigner || signer.provider instanceof BrowserProvider) {
172
+ return new EVMBrowserSigner(signer, address);
173
+ }
174
+ return new EVMSigner(signer, address);
175
+ }
176
+
159
177
  }
@@ -3,6 +3,7 @@ import {Signer, Transaction, TransactionRequest, TransactionResponse} from "ethe
3
3
 
4
4
 
5
5
  export class EVMSigner implements AbstractSigner {
6
+ type = "AtomiqAbstractSigner" as const;
6
7
 
7
8
  account: Signer;
8
9
  public readonly address: string;