Skip to content

Commit 0620473

Browse files
Try circumventing compiler bug again
1 parent e7a7c2a commit 0620473

1 file changed

Lines changed: 29 additions & 52 deletions

File tree

tests/core.test.ts

Lines changed: 29 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -50,64 +50,41 @@ const DEFAULT_BLOCK_NUMBER = BigInt.fromI32(99);
5050
const DEFAULT_TIMESTAMP = BigInt.fromI32(1234);
5151

5252
class EventOverrides {
53-
poolId: Bytes | null = null;
54-
token0: Address | null = null;
55-
token1: Address | null = null;
56-
core: Address | null = null;
57-
extension: Address | null = null;
58-
fee: BigInt | null = null;
59-
typeConfig: BigInt | null = null;
60-
tick: BigInt | null = null;
61-
sqrtRatio: BigInt | null = null;
62-
blockNumber: BigInt | null = null;
63-
timestamp: BigInt | null = null;
64-
txHash: Bytes | null = null;
65-
txIndex: BigInt | null = null;
66-
logIndex: BigInt | null = null;
53+
poolId: Bytes = DEFAULT_POOL_ID;
54+
token0: Address = DEFAULT_TOKEN0;
55+
token1: Address = DEFAULT_TOKEN1;
56+
core: Address = DEFAULT_CORE;
57+
extension: Address = DEFAULT_EXTENSION;
58+
fee: BigInt = BigInt.fromU64(DEFAULT_FEE);
59+
typeConfig: BigInt = BigInt.fromU32(DEFAULT_TYPE_CONFIG);
60+
tick: BigInt = BigInt.fromI32(DEFAULT_TICK);
61+
sqrtRatio: BigInt = DEFAULT_SQRT_RATIO;
62+
blockNumber: BigInt = DEFAULT_BLOCK_NUMBER;
63+
timestamp: BigInt = DEFAULT_TIMESTAMP;
64+
txHash: Bytes = DEFAULT_TX_HASH;
65+
txIndex: BigInt = DEFAULT_TX_INDEX;
66+
logIndex: BigInt = DEFAULT_EVENT_INDEX;
6767
}
6868

6969
function createPoolInitializedEvent(
70-
overrides: EventOverrides | null = null,
70+
overrides: EventOverrides = new EventOverrides(),
7171
): PoolInitializedEvent {
72-
let poolId = DEFAULT_POOL_ID;
73-
let token0 = DEFAULT_TOKEN0;
74-
let token1 = DEFAULT_TOKEN1;
75-
let core = DEFAULT_CORE;
76-
let extension = DEFAULT_EXTENSION;
72+
const poolId = overrides.poolId;
73+
const token0 = overrides.token0;
74+
const token1 = overrides.token1;
75+
const core = overrides.core;
76+
const extension = overrides.extension;
7777

78-
let fee = DEFAULT_FEE;
79-
let typeConfig = DEFAULT_TYPE_CONFIG;
78+
const fee = overrides.fee.toU64();
79+
const typeConfig = overrides.typeConfig.toU32();
8080

81-
let tick = DEFAULT_TICK;
82-
let sqrtRatio = DEFAULT_SQRT_RATIO;
83-
let blockNumber = DEFAULT_BLOCK_NUMBER;
84-
let timestamp = DEFAULT_TIMESTAMP;
85-
let txHash = DEFAULT_TX_HASH;
86-
let txIndex = DEFAULT_TX_INDEX;
87-
let logIndex = DEFAULT_EVENT_INDEX;
88-
89-
if (overrides != null) {
90-
if (overrides.poolId != null) poolId = overrides.poolId as Bytes;
91-
if (overrides.token0 != null) token0 = overrides.token0 as Address;
92-
if (overrides.token1 != null) token1 = overrides.token1 as Address;
93-
if (overrides.core != null) core = overrides.core as Address;
94-
if (overrides.extension != null) extension = overrides.extension as Address;
95-
96-
if (overrides.fee != null) fee = (overrides.fee as BigInt).toU64();
97-
if (overrides.typeConfig != null) {
98-
typeConfig = (overrides.typeConfig as BigInt).toU32();
99-
}
100-
101-
if (overrides.tick != null) tick = (overrides.tick as BigInt).toI32();
102-
if (overrides.sqrtRatio != null) sqrtRatio = overrides.sqrtRatio as BigInt;
103-
if (overrides.blockNumber != null) {
104-
blockNumber = overrides.blockNumber as BigInt;
105-
}
106-
if (overrides.timestamp != null) timestamp = overrides.timestamp as BigInt;
107-
if (overrides.txHash != null) txHash = overrides.txHash as Bytes;
108-
if (overrides.txIndex != null) txIndex = overrides.txIndex as BigInt;
109-
if (overrides.logIndex != null) logIndex = overrides.logIndex as BigInt;
110-
}
81+
const tick = overrides.tick.toI32();
82+
const sqrtRatio = overrides.sqrtRatio;
83+
const blockNumber = overrides.blockNumber;
84+
const timestamp = overrides.timestamp;
85+
const txHash = overrides.txHash;
86+
const txIndex = overrides.txIndex;
87+
const logIndex = overrides.logIndex;
11188

11289
const config = new Uint8Array(32);
11390
const extensionBytes = extension as Bytes;

0 commit comments

Comments
 (0)