Skip to content

Commit 94ea0e5

Browse files
authored
refactor: returning number[] from getAuxData(...) (#211)
* refactor: returning number[] from getAuxData(...) * chore: version bump
1 parent ab6502b commit 94ea0e5

14 files changed

+33
-33
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@aztec/bridge-clients",
3-
"version": "0.1.51",
3+
"version": "0.1.52",
44
"description": "This repo contains the solidity files and typescript helper class for all of the Aztec Connect Bridge Contracts",
55
"repository": "[email protected]:AztecProtocol/aztec-connect-bridges.git",
66
"license": "Apache-2.0",

src/client/aave/aave-bridge-data.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ export class AaveBridgeData implements BridgeDataFieldGetters {
4848
inputAssetB: AztecAsset,
4949
outputAssetA: AztecAsset,
5050
outputAssetB: AztecAsset,
51-
): Promise<bigint[]> {
52-
return [0n];
51+
): Promise<number[]> {
52+
return [0];
5353
}
5454

5555
async getUnderlyingAndEntering(

src/client/bridge-data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export interface BridgeDataFieldGetters {
6262
inputAssetB: AztecAsset,
6363
outputAssetA: AztecAsset,
6464
outputAssetB: AztecAsset,
65-
): Promise<bigint[]>;
65+
): Promise<number[]>;
6666

6767
/**
6868
* @dev This public variable defines the structure of the auxData

src/client/compound/compound-bridge-data.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe("compound lending bridge data", () => {
8080

8181
// Test the code using mocked controller
8282
const auxDataRedeem = await compoundBridgeData.getAuxData(ethAsset, emptyAsset, cethAsset, emptyAsset);
83-
expect(auxDataRedeem[0]).toBe(0n);
83+
expect(auxDataRedeem[0]).toBe(0);
8484
});
8585

8686
it("should correctly fetch auxData when redeeming", async () => {
@@ -102,7 +102,7 @@ describe("compound lending bridge data", () => {
102102

103103
// Test the code using mocked controller
104104
const auxDataRedeem = await compoundBridgeData.getAuxData(cethAsset, emptyAsset, ethAsset, emptyAsset);
105-
expect(auxDataRedeem[0]).toBe(1n);
105+
expect(auxDataRedeem[0]).toBe(1);
106106
});
107107

108108
it("should throw when getting auxData for unsupported inputAssetA", async () => {

src/client/compound/compound-bridge-data.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class CompoundBridgeData implements BridgeDataFieldGetters {
4848
inputAssetB: AztecAsset,
4949
outputAssetA: AztecAsset,
5050
outputAssetB: AztecAsset,
51-
): Promise<bigint[]> {
51+
): Promise<number[]> {
5252
const allMarkets = await this.getAllMarkets();
5353

5454
if (!(await this.isSupportedAsset(inputAssetA))) {
@@ -59,9 +59,9 @@ export class CompoundBridgeData implements BridgeDataFieldGetters {
5959
}
6060

6161
if (allMarkets.some(addr => addr.equals(inputAssetA.erc20Address))) {
62-
return [1n];
62+
return [1];
6363
} else if (allMarkets.some(addr => addr.equals(outputAssetA.erc20Address))) {
64-
return [0n];
64+
return [0];
6565
} else {
6666
throw "Invalid input and/or output asset";
6767
}

src/client/curve/curve-steth/curve-bridge-data.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export class CurveStethBridgeData implements BridgeDataFieldGetters {
6363
inputAssetB: AztecAsset,
6464
outputAssetA: AztecAsset,
6565
outputAssetB: AztecAsset,
66-
): Promise<bigint[]> {
67-
return [0n];
66+
): Promise<number[]> {
67+
return [0];
6868
}
6969

7070
async getExpectedOutput(

src/client/donation/donation-bridge-data.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export class DonationBridgeData implements BridgeDataFieldGetters {
3131
inputAssetB: AztecAsset,
3232
outputAssetA: AztecAsset,
3333
outputAssetB: AztecAsset,
34-
): Promise<bigint[]> {
35-
return [0n];
34+
): Promise<number[]> {
35+
return [0];
3636
}
3737

3838
async getExpectedOutput(

src/client/element/element-bridge-data.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ export class ElementBridgeData implements BridgeDataFieldGetters {
242242
inputAssetB: AztecAsset,
243243
outputAssetA: AztecAsset,
244244
outputAssetB: AztecAsset,
245-
): Promise<bigint[]> {
245+
): Promise<number[]> {
246246
const assetExpiries = await this.elementBridgeContract.getAssetExpiries(inputAssetA.erc20Address.toString());
247247
if (assetExpiries && assetExpiries.length) {
248-
return assetExpiries.map(a => a.toBigInt());
248+
return assetExpiries.map(a => a.toNumber());
249249
}
250250
return [];
251251
}

src/client/erc4626/erc4626-bridge-data.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe("ERC4626 bridge data", () => {
5555

5656
// Test the code using mocked controller
5757
const auxDataIssue = await erc4626BridgeData.getAuxData(mplAsset, emptyAsset, xmplAsset, emptyAsset);
58-
expect(auxDataIssue[0]).toBe(0n);
58+
expect(auxDataIssue[0]).toBe(0);
5959
});
6060

6161
it("should correctly fetch auxData when redeeming shares", async () => {
@@ -70,7 +70,7 @@ describe("ERC4626 bridge data", () => {
7070

7171
// Test the code using mocked controller
7272
const auxDataRedeem = await erc4626BridgeData.getAuxData(xmplAsset, emptyAsset, mplAsset, emptyAsset);
73-
expect(auxDataRedeem[0]).toBe(1n);
73+
expect(auxDataRedeem[0]).toBe(1);
7474
});
7575

7676
it("should correctly compute expected output when issuing shares", async () => {

src/client/erc4626/erc4626-bridge-data.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ export class ERC4626BridgeData implements BridgeDataFieldGetters {
2929
inputAssetB: AztecAsset,
3030
outputAssetA: AztecAsset,
3131
outputAssetB: AztecAsset,
32-
): Promise<bigint[]> {
32+
): Promise<number[]> {
3333
// First check whether outputAssetA is a share by calling asset() on it
3434
let vault = IERC4626__factory.connect(outputAssetA.erc20Address.toString(), this.ethersProvider);
3535
try {
3636
const vaultAsset = EthAddress.fromString(await vault.asset());
3737
if (vaultAsset.equals(inputAssetA.erc20Address)) {
38-
return [0n];
38+
return [0];
3939
} else {
4040
throw "Address of vault's asset isn't equal to inputAssetA.erc20address";
4141
}
@@ -48,7 +48,7 @@ export class ERC4626BridgeData implements BridgeDataFieldGetters {
4848
try {
4949
const vaultAsset = EthAddress.fromString(await vault.asset());
5050
if (vaultAsset.equals(outputAssetA.erc20Address)) {
51-
return [1n];
51+
return [1];
5252
} else {
5353
throw "Address of vault's asset isn't equal to outputAssetA.erc20address";
5454
}

src/client/example/example-bridge-data.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export class ExampleBridgeData implements BridgeDataFieldGetters {
2222
inputAssetB: AztecAsset,
2323
outputAssetA: AztecAsset,
2424
outputAssetB: AztecAsset,
25-
): Promise<bigint[]> {
26-
return [0n];
25+
): Promise<number[]> {
26+
return [0];
2727
}
2828

2929
public auxDataConfig: AuxDataConfig[] = [

src/client/lido/lido-bridge-data.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export class LidoBridgeData implements BridgeDataFieldGetters {
6363
inputAssetB: AztecAsset,
6464
outputAssetA: AztecAsset,
6565
outputAssetB: AztecAsset,
66-
): Promise<bigint[]> {
67-
return [0n];
66+
): Promise<number[]> {
67+
return [0];
6868
}
6969

7070
async getExpectedOutput(

src/client/yearn/yearn-bridge-data.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ describe("Testing Yearn auxData", () => {
104104

105105
const yearnBridgeData = YearnBridgeData.create({} as any);
106106
const auxDataDepositERC20 = await yearnBridgeData.getAuxData(daiAsset, emptyAsset, yvDaiAsset, emptyAsset);
107-
expect(auxDataDepositERC20[0]).toBe(0n);
107+
expect(auxDataDepositERC20[0]).toBe(0);
108108
const auxDataDepositETH = await yearnBridgeData.getAuxData(ethAsset, emptyAsset, yvEthAsset, emptyAsset);
109-
expect(auxDataDepositETH[0]).toBe(0n);
109+
expect(auxDataDepositETH[0]).toBe(0);
110110
});
111111

112112
it("should correctly fetch auxData for withdrawal", async () => {
@@ -145,9 +145,9 @@ describe("Testing Yearn auxData", () => {
145145

146146
const yearnBridgeData = YearnBridgeData.create({} as any);
147147
const auxDataDepositERC20 = await yearnBridgeData.getAuxData(yvDaiAsset, emptyAsset, daiAsset, emptyAsset);
148-
expect(auxDataDepositERC20[0]).toBe(1n);
148+
expect(auxDataDepositERC20[0]).toBe(1);
149149
const auxDataDepositETH = await yearnBridgeData.getAuxData(yvEthAsset, emptyAsset, ethAsset, emptyAsset);
150-
expect(auxDataDepositETH[0]).toBe(1n);
150+
expect(auxDataDepositETH[0]).toBe(1);
151151
});
152152

153153
it("should throw when getting auxData for unsupported inputAssetA", async () => {

src/client/yearn/yearn-bridge-data.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class YearnBridgeData implements BridgeDataFieldGetters {
5050
inputAssetB: AztecAsset,
5151
outputAssetA: AztecAsset,
5252
outputAssetB: AztecAsset,
53-
): Promise<bigint[]> {
53+
): Promise<number[]> {
5454
const [allYvETH, allVaultsForTokens] = await this.getAllVaultsAndTokens();
5555

5656
if (!(await this.isSupportedAsset(inputAssetA))) {
@@ -66,13 +66,13 @@ export class YearnBridgeData implements BridgeDataFieldGetters {
6666
outputAssetA.assetType == AztecAssetType.ERC20 && // Check if we are receiving ERC20
6767
allYvETH.findIndex(token => token.toString() === outputAssetA.erc20Address.toString()) > -1 // Check if we are receiving yvETH
6868
) {
69-
return [0n]; // deposit via zap
69+
return [0]; // deposit via zap
7070
} else if (
7171
inputAssetA.assetType == AztecAssetType.ERC20 && // Check if we are withdrawing ERC20
7272
allYvETH.findIndex(token => token.toString() === inputAssetA.erc20Address.toString()) > -1 && // Check if we are withdrawing from yvETH
7373
outputAssetA.assetType == AztecAssetType.ETH // Check if we are receiving ETH
7474
) {
75-
return [1n]; // withdraw via zap
75+
return [1]; // withdraw via zap
7676
} else {
7777
throw "Invalid input and/or output asset";
7878
}
@@ -84,7 +84,7 @@ export class YearnBridgeData implements BridgeDataFieldGetters {
8484
token => token.toString() === outputAssetA.erc20Address.toString(),
8585
) > -1;
8686
if (matchDepositSituation) {
87-
return [0n];
87+
return [0];
8888
}
8989

9090
// standard withdraw
@@ -93,7 +93,7 @@ export class YearnBridgeData implements BridgeDataFieldGetters {
9393
token => token.toString() === inputAssetA.erc20Address.toString(),
9494
) > -1;
9595
if (matchWithdrawSituation) {
96-
return [1n];
96+
return [1];
9797
}
9898
throw "Invalid input and/or output asset";
9999
}

0 commit comments

Comments
 (0)