@atomiqlabs/chain-evm 1.0.0-dev.86 → 1.0.0-dev.88

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,4 @@ 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", 3636>, EVMChainEventsBrowser, EVMBtcRelay<any>, EVMSpvVaultData, EVMSpvWithdrawalData, EVMSpvVaultContract<"BOTANIX">>;
13
+ export type BotanixChainType = ChainType<"BOTANIX", never, EVMPreFetchVerification, EVMTx, EVMSigner, EVMSwapData, EVMSwapContract<"BOTANIX">, EVMChainInterface<"BOTANIX">, EVMChainEventsBrowser, EVMBtcRelay<any>, EVMSpvVaultData, EVMSpvWithdrawalData, EVMSpvVaultContract<"BOTANIX">>;
@@ -13,26 +13,26 @@ const EVMSwapData_1 = require("../../evm/swaps/EVMSwapData");
13
13
  const EVMSpvVaultData_1 = require("../../evm/spv_swap/EVMSpvVaultData");
14
14
  const EVMSpvWithdrawalData_1 = require("../../evm/spv_swap/EVMSpvWithdrawalData");
15
15
  const BotanixChainIds = {
16
- MAINNET: null,
16
+ MAINNET: 3637,
17
17
  TESTNET: 3636
18
18
  };
19
19
  const BotanixContractAddresses = {
20
20
  MAINNET: {
21
- executionContract: "",
22
- swapContract: "",
23
- btcRelayContract: "",
24
- btcRelayDeploymentHeight: 0,
25
- spvVaultContract: "",
26
- spvVaultDeploymentHeight: 0,
21
+ executionContract: "0x5bb0C725939cB825d1322A99a3FeB570097628c3",
22
+ swapContract: "0x8A44f1995a54fD976c904Cccf9EbaB49c3182eb3",
23
+ btcRelayContract: "0x6a373b6Adad83964727bA0fa15E22Be05173fc12",
24
+ btcRelayDeploymentHeight: 1791247,
25
+ spvVaultContract: "0xc98Ef084d3911C8447DBbE4dDa18bC2c9bB0584e",
26
+ spvVaultDeploymentHeight: 1791249,
27
27
  handlerContracts: {
28
28
  refund: {
29
- timelock: ""
29
+ timelock: "0x3887B02217726bB36958Dd595e57293fB63D5082"
30
30
  },
31
31
  claim: {
32
- [base_1.ChainSwapType.HTLC]: "",
33
- [base_1.ChainSwapType.CHAIN_TXID]: "",
34
- [base_1.ChainSwapType.CHAIN]: "",
35
- [base_1.ChainSwapType.CHAIN_NONCED]: ""
32
+ [base_1.ChainSwapType.HTLC]: "0x59A54378B6bA9C21ba66487C6A701D702baDEabE",
33
+ [base_1.ChainSwapType.CHAIN_TXID]: "0x32EB4DbDdC31e19ba908fecc7cae03F0d04F01Fa",
34
+ [base_1.ChainSwapType.CHAIN]: "0xaB2D14745362B26a732dD8B7F95daAE3D2914bBF",
35
+ [base_1.ChainSwapType.CHAIN_NONCED]: "0x2920EE496693A5027249a027A6FD3F643E743745"
36
36
  }
37
37
  }
38
38
  },
@@ -10,4 +10,4 @@ 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", 5115>, EVMChainEventsBrowser, CitreaBtcRelay<any>, EVMSpvVaultData, EVMSpvWithdrawalData, CitreaSpvVaultContract>;
13
+ export type CitreaChainType = ChainType<"CITREA", never, EVMPreFetchVerification, EVMTx, EVMSigner, EVMSwapData, CitreaSwapContract, EVMChainInterface<"CITREA">, EVMChainEventsBrowser, CitreaBtcRelay<any>, EVMSpvVaultData, EVMSpvWithdrawalData, CitreaSpvVaultContract>;
@@ -17,11 +17,11 @@ export type EVMConfiguration = {
17
17
  safeBlockTag: EVMBlockTag;
18
18
  maxLogsBlockRange: number;
19
19
  };
20
- export declare class EVMChainInterface<ChainId extends string = string, EVMChainId extends number = number> implements ChainInterface {
20
+ export declare class EVMChainInterface<ChainId extends string = string> implements ChainInterface {
21
21
  readonly chainId: ChainId;
22
22
  readonly provider: JsonRpcApiProvider;
23
23
  readonly retryPolicy: EVMRetryPolicy;
24
- readonly evmChainId: EVMChainId;
24
+ readonly evmChainId: number;
25
25
  readonly config: EVMConfiguration;
26
26
  Fees: EVMFees;
27
27
  Tokens: EVMTokens;
@@ -30,7 +30,7 @@ export declare class EVMChainInterface<ChainId extends string = string, EVMChain
30
30
  Events: EVMEvents;
31
31
  Blocks: EVMBlocks;
32
32
  protected logger: LoggerType;
33
- constructor(chainId: ChainId, evmChainId: EVMChainId, provider: JsonRpcApiProvider, config: EVMConfiguration, retryPolicy?: EVMRetryPolicy, evmFeeEstimator?: EVMFees);
33
+ constructor(chainId: ChainId, evmChainId: number, provider: JsonRpcApiProvider, config: EVMConfiguration, retryPolicy?: EVMRetryPolicy, evmFeeEstimator?: EVMFees);
34
34
  getBalance(signer: string, tokenAddress: string): Promise<bigint>;
35
35
  getNativeCurrencyAddress(): string;
36
36
  isValidToken(tokenIdentifier: string): boolean;
@@ -1,9 +1,9 @@
1
1
  import { JsonRpcApiProvider } from "ethers";
2
2
  import { EVMChainInterface, EVMRetryPolicy } from "./EVMChainInterface";
3
- export declare class EVMModule<ChainId extends string = string, EVMChainId extends number = number> {
3
+ export declare class EVMModule<ChainId extends string = string> {
4
4
  protected readonly provider: JsonRpcApiProvider;
5
5
  protected readonly retryPolicy: EVMRetryPolicy;
6
- protected readonly root: EVMChainInterface<ChainId, EVMChainId>;
6
+ protected readonly root: EVMChainInterface<ChainId>;
7
7
  protected readonly logger: import("../../utils/Utils").LoggerType;
8
- constructor(root: EVMChainInterface<ChainId, EVMChainId>);
8
+ constructor(root: EVMChainInterface<ChainId>);
9
9
  }
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ReconnectingWebSocketProvider = void 0;
4
4
  const SocketProvider_1 = require("./SocketProvider");
5
+ const Utils_1 = require("../../utils/Utils");
6
+ const logger = (0, Utils_1.getLogger)("ReconnectingWebSocketProvider: ");
5
7
  class ReconnectingWebSocketProvider extends SocketProvider_1.SocketProvider {
6
8
  constructor(url, network, options) {
7
9
  super(network, options);
@@ -23,7 +25,7 @@ class ReconnectingWebSocketProvider extends SocketProvider_1.SocketProvider {
23
25
  this._send({ method: "eth_chainId", params: [], id: 1000000000, jsonrpc: "2.0" }).catch(e => {
24
26
  //Error
25
27
  if (e.code === "NETWORK_ERROR") {
26
- console.error("Websocket ping error: ", e);
28
+ logger.error("connect(): pingInterval: Websocket ping error: ", e);
27
29
  if (this.websocket != null) {
28
30
  this.websocket.close();
29
31
  this.disconnectedAndScheduleReconnect();
@@ -31,20 +33,21 @@ class ReconnectingWebSocketProvider extends SocketProvider_1.SocketProvider {
31
33
  }
32
34
  });
33
35
  }, this.pingIntervalSeconds * 1000);
36
+ logger.info("connect(): Websocket connected!");
34
37
  };
35
38
  this.websocket.onerror = (err) => {
36
- console.error(`Websocket connection error: `, err);
39
+ logger.error(`connect(): onerror: Websocket connection error: `, err);
37
40
  this.disconnectedAndScheduleReconnect();
38
41
  };
39
42
  this.websocket.onmessage = (message) => {
40
43
  this._processMessage(message.data);
41
44
  };
42
45
  this.websocket.onclose = (event) => {
43
- console.error(`Websocket connection closed: `, event);
46
+ logger.error(`connect(): onclose: Websocket connection closed: `, event);
44
47
  this.disconnectedAndScheduleReconnect();
45
48
  };
46
49
  this.connectTimer = setTimeout(() => {
47
- console.error("Websocket connection taking too long, (above " + this.connectionTimeout + " seconds!), closing and re-attempting connection");
50
+ logger.warn("connect(): Websocket connection taking too long, (above " + this.connectionTimeout + " seconds!), closing and re-attempting connection");
48
51
  this.websocket.close();
49
52
  this.disconnectedAndScheduleReconnect();
50
53
  }, this.connectionTimeout * 1000);
@@ -55,7 +58,8 @@ class ReconnectingWebSocketProvider extends SocketProvider_1.SocketProvider {
55
58
  if (this.websocket == null)
56
59
  return;
57
60
  this.websocket.onclose = null;
58
- this.websocket.onerror = null;
61
+ //Register dummy handler, otherwise we get unhandled `error` event which crashes the whole thing
62
+ this.websocket.onerror = (err) => logger.error("disconnectedAndScheduleReconnect(): Post-close onerror: ", err);
59
63
  this.websocket.onmessage = null;
60
64
  this.websocket.onopen = null;
61
65
  this.websocket = null;
@@ -64,7 +68,7 @@ class ReconnectingWebSocketProvider extends SocketProvider_1.SocketProvider {
64
68
  if (this.connectTimer != null)
65
69
  clearInterval(this.connectTimer);
66
70
  this._disconnected();
67
- console.error(`Retrying in ${this.reconnectSeconds} seconds...`);
71
+ logger.info(`disconnectedAndScheduleReconnect(): Retrying in ${this.reconnectSeconds} seconds...`);
68
72
  this.reconnectTimer = setTimeout(() => this.connect(), this.reconnectSeconds * 1000);
69
73
  }
70
74
  async _write(message) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/chain-evm",
3
- "version": "1.0.0-dev.86",
3
+ "version": "1.0.0-dev.88",
4
4
  "description": "EVM specific base implementation",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -19,7 +19,7 @@ export type BotanixChainType = ChainType<
19
19
  EVMSigner,
20
20
  EVMSwapData,
21
21
  EVMSwapContract<"BOTANIX">,
22
- EVMChainInterface<"BOTANIX", 3636>,
22
+ EVMChainInterface<"BOTANIX">,
23
23
  EVMChainEventsBrowser,
24
24
  EVMBtcRelay<any>,
25
25
  EVMSpvVaultData,
@@ -12,27 +12,27 @@ import {EVMSpvWithdrawalData} from "../../evm/spv_swap/EVMSpvWithdrawalData";
12
12
  import {BotanixChainType} from "./BotanixChainType";
13
13
 
14
14
  const BotanixChainIds = {
15
- MAINNET: null,
15
+ MAINNET: 3637,
16
16
  TESTNET: 3636
17
17
  };
18
18
 
19
19
  const BotanixContractAddresses = {
20
20
  MAINNET: {
21
- executionContract: "",
22
- swapContract: "",
23
- btcRelayContract: "",
24
- btcRelayDeploymentHeight: 0,
25
- spvVaultContract: "",
26
- spvVaultDeploymentHeight: 0,
21
+ executionContract: "0x5bb0C725939cB825d1322A99a3FeB570097628c3",
22
+ swapContract: "0x8A44f1995a54fD976c904Cccf9EbaB49c3182eb3",
23
+ btcRelayContract: "0x6a373b6Adad83964727bA0fa15E22Be05173fc12",
24
+ btcRelayDeploymentHeight: 1791247,
25
+ spvVaultContract: "0xc98Ef084d3911C8447DBbE4dDa18bC2c9bB0584e",
26
+ spvVaultDeploymentHeight: 1791249,
27
27
  handlerContracts: {
28
28
  refund: {
29
- timelock: ""
29
+ timelock: "0x3887B02217726bB36958Dd595e57293fB63D5082"
30
30
  },
31
31
  claim: {
32
- [ChainSwapType.HTLC]: "",
33
- [ChainSwapType.CHAIN_TXID]: "",
34
- [ChainSwapType.CHAIN]: "",
35
- [ChainSwapType.CHAIN_NONCED]: ""
32
+ [ChainSwapType.HTLC]: "0x59A54378B6bA9C21ba66487C6A701D702baDEabE",
33
+ [ChainSwapType.CHAIN_TXID]: "0x32EB4DbDdC31e19ba908fecc7cae03F0d04F01Fa",
34
+ [ChainSwapType.CHAIN]: "0xaB2D14745362B26a732dD8B7F95daAE3D2914bBF",
35
+ [ChainSwapType.CHAIN_NONCED]: "0x2920EE496693A5027249a027A6FD3F643E743745"
36
36
  }
37
37
  }
38
38
  },
@@ -19,7 +19,7 @@ export type CitreaChainType = ChainType<
19
19
  EVMSigner,
20
20
  EVMSwapData,
21
21
  CitreaSwapContract,
22
- EVMChainInterface<"CITREA", 5115>,
22
+ EVMChainInterface<"CITREA">,
23
23
  EVMChainEventsBrowser,
24
24
  CitreaBtcRelay<any>,
25
25
  EVMSpvVaultData,
@@ -21,14 +21,14 @@ export type EVMConfiguration = {
21
21
  maxLogsBlockRange: number
22
22
  };
23
23
 
24
- export class EVMChainInterface<ChainId extends string = string, EVMChainId extends number = number> implements ChainInterface {
24
+ export class EVMChainInterface<ChainId extends string = string> implements ChainInterface {
25
25
 
26
26
  readonly chainId: ChainId;
27
27
 
28
28
  readonly provider: JsonRpcApiProvider;
29
29
  readonly retryPolicy: EVMRetryPolicy;
30
30
 
31
- public readonly evmChainId: EVMChainId;
31
+ public readonly evmChainId: number;
32
32
 
33
33
  public readonly config: EVMConfiguration;
34
34
 
@@ -43,7 +43,7 @@ export class EVMChainInterface<ChainId extends string = string, EVMChainId exten
43
43
 
44
44
  constructor(
45
45
  chainId: ChainId,
46
- evmChainId: EVMChainId,
46
+ evmChainId: number,
47
47
  provider: JsonRpcApiProvider,
48
48
  config: EVMConfiguration,
49
49
  retryPolicy?: EVMRetryPolicy,
@@ -2,16 +2,16 @@ import {getLogger} from "../../utils/Utils";
2
2
  import {JsonRpcApiProvider} from "ethers";
3
3
  import {EVMChainInterface, EVMRetryPolicy} from "./EVMChainInterface";
4
4
 
5
- export class EVMModule<ChainId extends string = string, EVMChainId extends number = number> {
5
+ export class EVMModule<ChainId extends string = string> {
6
6
 
7
7
  protected readonly provider: JsonRpcApiProvider;
8
8
  protected readonly retryPolicy: EVMRetryPolicy;
9
- protected readonly root: EVMChainInterface<ChainId, EVMChainId>;
9
+ protected readonly root: EVMChainInterface<ChainId>;
10
10
 
11
11
  protected readonly logger = getLogger(this.constructor.name+": ");
12
12
 
13
13
  constructor(
14
- root: EVMChainInterface<ChainId, EVMChainId>
14
+ root: EVMChainInterface<ChainId>
15
15
  ) {
16
16
  this.provider = root.provider;
17
17
  this.retryPolicy = root.retryPolicy;
@@ -1,7 +1,9 @@
1
1
  import {JsonRpcApiProviderOptions} from "ethers";
2
2
  import type {Networkish, WebSocketLike} from "ethers";
3
3
  import {SocketProvider} from "./SocketProvider";
4
+ import {getLogger} from "../../utils/Utils";
4
5
 
6
+ const logger = getLogger("ReconnectingWebSocketProvider: ");
5
7
 
6
8
  export class ReconnectingWebSocketProvider extends SocketProvider {
7
9
 
@@ -36,7 +38,7 @@ export class ReconnectingWebSocketProvider extends SocketProvider {
36
38
  this._send({method: "eth_chainId", params: [], id: 1_000_000_000, jsonrpc: "2.0"}).catch(e => {
37
39
  //Error
38
40
  if(e.code==="NETWORK_ERROR") {
39
- console.error("Websocket ping error: ", e);
41
+ logger.error("connect(): pingInterval: Websocket ping error: ", e);
40
42
  if(this.websocket!=null) {
41
43
  this.websocket.close();
42
44
  this.disconnectedAndScheduleReconnect();
@@ -44,10 +46,12 @@ export class ReconnectingWebSocketProvider extends SocketProvider {
44
46
  }
45
47
  });
46
48
  }, this.pingIntervalSeconds * 1000);
49
+
50
+ logger.info("connect(): Websocket connected!");
47
51
  };
48
52
 
49
53
  this.websocket.onerror = (err) => {
50
- console.error(`Websocket connection error: `, err);
54
+ logger.error(`connect(): onerror: Websocket connection error: `, err);
51
55
  this.disconnectedAndScheduleReconnect();
52
56
  };
53
57
 
@@ -56,12 +60,12 @@ export class ReconnectingWebSocketProvider extends SocketProvider {
56
60
  };
57
61
 
58
62
  this.websocket.onclose = (event) => {
59
- console.error(`Websocket connection closed: `, event);
63
+ logger.error(`connect(): onclose: Websocket connection closed: `, event);
60
64
  this.disconnectedAndScheduleReconnect();
61
65
  };
62
66
 
63
67
  this.connectTimer = setTimeout(() => {
64
- console.error("Websocket connection taking too long, (above "+this.connectionTimeout+" seconds!), closing and re-attempting connection");
68
+ logger.warn("connect(): Websocket connection taking too long, (above "+this.connectionTimeout+" seconds!), closing and re-attempting connection");
65
69
  this.websocket.close();
66
70
  this.disconnectedAndScheduleReconnect();
67
71
  }, this.connectionTimeout * 1000);
@@ -71,7 +75,8 @@ export class ReconnectingWebSocketProvider extends SocketProvider {
71
75
  if(this.destroyed) return;
72
76
  if(this.websocket==null) return;
73
77
  this.websocket.onclose = null;
74
- this.websocket.onerror = null;
78
+ //Register dummy handler, otherwise we get unhandled `error` event which crashes the whole thing
79
+ this.websocket.onerror = (err) => logger.error("disconnectedAndScheduleReconnect(): Post-close onerror: ", err);
75
80
  this.websocket.onmessage = null;
76
81
  this.websocket.onopen = null;
77
82
  this.websocket = null;
@@ -80,7 +85,7 @@ export class ReconnectingWebSocketProvider extends SocketProvider {
80
85
 
81
86
  this._disconnected();
82
87
 
83
- console.error(`Retrying in ${this.reconnectSeconds} seconds...`);
88
+ logger.info(`disconnectedAndScheduleReconnect(): Retrying in ${this.reconnectSeconds} seconds...`);
84
89
  this.reconnectTimer = setTimeout(() => this.connect(), this.reconnectSeconds * 1000);
85
90
  }
86
91