Skip to content

Commit f50d244

Browse files
authored
Merge pull request #59 from SetProtocol/justin_chen-add-caller
Add caller to the batch fetch methods so that gas can be estimated
2 parents e418f66 + 2009741 commit f50d244

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
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": "set.js",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "A javascript library for interacting with the Set Protocol v2",
55
"keywords": [
66
"set.js",

src/api/SetTokenAPI.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,18 @@ export default class SetTokenAPI {
202202
* @param userAddress Address of the user
203203
* @returns The balances of the ERC20 tokens for the user in array of BigNumbers format
204204
*/
205-
public async batchFetchBalancesOfAsync(tokenAddresses: Address[], userAddress: Address): Promise<BigNumber[]> {
205+
public async batchFetchBalancesOfAsync(
206+
tokenAddresses: Address[],
207+
userAddress: Address,
208+
callerAddress: Address = undefined
209+
): Promise<BigNumber[]> {
206210
this.assert.schema.isValidAddress('userAddress', userAddress);
207211
const ownerAddresses = tokenAddresses.map(tokenAddress => {
208212
this.assert.schema.isValidAddress('tokenAddress', tokenAddress);
209213
return userAddress;
210214
});
211215

212-
return await this.protocolViewerWrapper.batchFetchBalancesOf(tokenAddresses, ownerAddresses);
216+
return await this.protocolViewerWrapper.batchFetchBalancesOf(tokenAddresses, ownerAddresses, callerAddress);
213217
}
214218

215219
/**
@@ -222,7 +226,8 @@ export default class SetTokenAPI {
222226
public async batchFetchAllowancesAsync(
223227
tokenAddresses: Address[],
224228
ownerAddress: Address,
225-
spenderAddress: Address
229+
spenderAddress: Address,
230+
callerAddress: Address = undefined
226231
): Promise<BigNumber[]> {
227232
this.assert.schema.isValidAddress('ownerAddress', ownerAddress);
228233
this.assert.schema.isValidAddress('spenderAddress', spenderAddress);
@@ -238,7 +243,8 @@ export default class SetTokenAPI {
238243
return await this.protocolViewerWrapper.batchFetchAllowances(
239244
tokenAddresses,
240245
ownerAddresses,
241-
spenderAddresses
246+
spenderAddresses,
247+
callerAddress
242248
);
243249
}
244250

0 commit comments

Comments
 (0)