Skip to content

Commit

Permalink
refactor: allowed destinations
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscotobar committed Feb 13, 2024
1 parent e6760c1 commit dc9af6e
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 61 deletions.
1 change: 0 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ File [./config/default.json5](config/default.json5) contains all configuration p
fixedUsdFee: 0 ,

sponsoredDestinations: [],
allowedDestinations: [],
requestMinValidSeconds: 43200,

},
Expand Down
1 change: 0 additions & 1 deletion config/default.json5
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
fixedUsdFee: 0 ,

sponsoredDestinations: [],
allowedDestinations: [],
requestMinValidSeconds: 43200,

},
Expand Down
99 changes: 59 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/RelayServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ import {
convertGasToTokenAndNative,
calculateFee,
validateExpirationTime,
isDestinationAllowed,
} from './relayServerUtils';
import { getPastEventsForHub } from './getPastEventsForHub';
import type { PastEventOptions } from './definitions';
Expand Down Expand Up @@ -295,8 +294,6 @@ export class RelayServer extends EventEmitter {
relayRequest.request.validUntilTime,
requestMinValidSeconds
);

await isDestinationAllowed(relayRequest, this.config.app);
}

async validateVerifier(
Expand Down
1 change: 0 additions & 1 deletion src/ServerConfigParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ type AppConfig = {
gasFeePercentage: number;
disableSponsoredTx: boolean;
sponsoredDestinations: Array<string>;
allowedDestinations: Array<string>;
requestMinValidSeconds: number;
transferFeePercentage: number;
fixedUsdFee: number;
Expand Down
14 changes: 0 additions & 14 deletions src/relayServerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,6 @@ async function isSponsorshipAllowed(
);
}

async function isDestinationAllowed(
envelopingRequest: EnvelopingRequest,
config: AppConfig
): Promise<void> {
const { allowedDestinations } = config;

const to = await envelopingRequest.request.to;

if (to != constants.AddressZero && !allowedDestinations.includes(to)) {
throw new Error('Destination contract is not allowed');
}
}

function getMethodHashFromData(data: string) {
return data.substring(2, 10);
}
Expand Down Expand Up @@ -413,7 +400,6 @@ export {
calculateFee,
convertGasToTokenAndNative,
isSponsorshipAllowed,
isDestinationAllowed,
TRANSFER_HASH,
TRANSFER_FROM_HASH,
validateExpirationTime,
Expand Down
1 change: 0 additions & 1 deletion src/serverConfigParamsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const appSchema = Joi.object({
fixedUsdFee: Joi.number().optional(),
disableSponsoredTx: Joi.boolean().required(),
sponsoredDestinations: Joi.array().items(Joi.string().custom(isAddress)),
allowedDestinations: Joi.array().items(Joi.string().custom(isAddress)),
requestMinValidSeconds: Joi.number().min(0).required(),
});

Expand Down

0 comments on commit dc9af6e

Please sign in to comment.