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

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.
@@ -38,6 +38,7 @@ export declare class EVMChainInterface<ChainId extends string = string> implemen
38
38
  getNativeCurrencyAddress(): string;
39
39
  isValidToken(tokenIdentifier: string): boolean;
40
40
  isValidAddress(address: string): boolean;
41
+ normalizeAddress(address: string): string;
41
42
  offBeforeTxReplace(callback: (oldTx: string, oldTxId: string, newTx: string, newTxId: string) => Promise<void>): boolean;
42
43
  onBeforeTxReplace(callback: (oldTx: string, oldTxId: string, newTx: string, newTxId: string) => Promise<void>): void;
43
44
  onBeforeTxSigned(callback: (tx: TransactionRequest) => Promise<void>): void;
@@ -42,6 +42,9 @@ class EVMChainInterface {
42
42
  isValidAddress(address) {
43
43
  return EVMAddresses_1.EVMAddresses.isValidAddress(address);
44
44
  }
45
+ normalizeAddress(address) {
46
+ return (0, ethers_1.getAddress)(address);
47
+ }
45
48
  ///////////////////////////////////
46
49
  //// Callbacks & handlers
47
50
  offBeforeTxReplace(callback) {
@@ -10,7 +10,7 @@ class EVMSigner {
10
10
  this.isManagingNoncesInternally = isManagingNoncesInternally;
11
11
  }
12
12
  getAddress() {
13
- return this.address;
13
+ return (0, ethers_1.getAddress)(this.address);
14
14
  }
15
15
  async signTransaction(transaction) {
16
16
  return this.account.signTransaction(transaction);
@@ -18,7 +18,10 @@ class EVMSigner {
18
18
  async sendTransaction(transaction, onBeforePublish) {
19
19
  const txResponse = await this.account.sendTransaction(transaction);
20
20
  if (onBeforePublish != null)
21
- await onBeforePublish(txResponse.hash, ethers_1.Transaction.from(txResponse).serialized);
21
+ await onBeforePublish(txResponse.hash, ethers_1.Transaction.from({
22
+ ...txResponse,
23
+ chainId: transaction.chainId
24
+ }).serialized);
22
25
  return txResponse;
23
26
  }
24
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/chain-evm",
3
- "version": "1.0.0-dev.97",
3
+ "version": "1.0.0-dev.99",
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.16",
26
+ "@atomiqlabs/base": "^10.0.0-dev.18",
27
27
  "@noble/hashes": "^1.8.0",
28
28
  "@scure/btc-signer": "^1.6.0",
29
29
  "buffer": "6.0.3",
@@ -7,7 +7,8 @@ import {
7
7
  Signer,
8
8
  Transaction,
9
9
  TransactionRequest,
10
- Wallet
10
+ Wallet,
11
+ getAddress
11
12
  } from "ethers";
12
13
  import {EVMBlocks, EVMBlockTag} from "./modules/EVMBlocks";
13
14
  import {EVMEvents} from "./modules/EVMEvents";
@@ -18,7 +19,6 @@ import { EVMSignatures } from "./modules/EVMSignatures";
18
19
  import {EVMAddresses} from "./modules/EVMAddresses";
19
20
  import {EVMSigner} from "../wallet/EVMSigner";
20
21
  import {EVMBrowserSigner} from "../wallet/EVMBrowserSigner";
21
- import {add} from "@noble/hashes/_u64";
22
22
 
23
23
  export type EVMRetryPolicy = {
24
24
  maxRetries?: number,
@@ -97,6 +97,10 @@ export class EVMChainInterface<ChainId extends string = string> implements Chain
97
97
  return EVMAddresses.isValidAddress(address);
98
98
  }
99
99
 
100
+ normalizeAddress(address: string): string {
101
+ return getAddress(address);
102
+ }
103
+
100
104
  ///////////////////////////////////
101
105
  //// Callbacks & handlers
102
106
  offBeforeTxReplace(callback: (oldTx: string, oldTxId: string, newTx: string, newTxId: string) => Promise<void>): boolean {
@@ -1,5 +1,5 @@
1
1
  import {AbstractSigner} from "@atomiqlabs/base";
2
- import {Signer, Transaction, TransactionRequest, TransactionResponse} from "ethers";
2
+ import {getAddress, Signer, Transaction, TransactionRequest, TransactionResponse} from "ethers";
3
3
 
4
4
 
5
5
  export class EVMSigner implements AbstractSigner {
@@ -16,7 +16,7 @@ export class EVMSigner implements AbstractSigner {
16
16
  }
17
17
 
18
18
  getAddress(): string {
19
- return this.address;
19
+ return getAddress(this.address);
20
20
  }
21
21
 
22
22
  async signTransaction?(transaction: TransactionRequest): Promise<string> {
@@ -25,7 +25,10 @@ export class EVMSigner implements AbstractSigner {
25
25
 
26
26
  async sendTransaction(transaction: TransactionRequest, onBeforePublish?: (txId: string, rawTx: string) => Promise<void>): Promise<TransactionResponse> {
27
27
  const txResponse = await this.account.sendTransaction(transaction);
28
- if(onBeforePublish!=null) await onBeforePublish(txResponse.hash, Transaction.from(txResponse).serialized);
28
+ if(onBeforePublish!=null) await onBeforePublish(txResponse.hash, Transaction.from({
29
+ ...txResponse,
30
+ chainId: transaction.chainId
31
+ }).serialized);
29
32
  return txResponse;
30
33
  }
31
34