Skip to content

Commit

Permalink
refactor: test
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscotobar committed Jan 24, 2024
1 parent 4a05fd6 commit cd88907
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions src/RelayServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,6 @@ export class RelayServer extends EventEmitter {
): Promise<void> {
const verifier = await envelopingTransaction.relayRequest.relayData
.callVerifier;
const {
relayRequest: {
request: { tokenContract },
},
} = envelopingTransaction;

if (!this.isTrustedVerifier(verifier)) {
throw new Error('Invalid verifier');
Expand All @@ -336,12 +331,9 @@ export class RelayServer extends EventEmitter {
const provider = getProvider();

try {
if (
isDeployTransaction(envelopingTransaction) &&
tokenContract != constants.AddressZero
) {
if (isDeployTransaction(envelopingTransaction)) {
verifierContract = IDeployVerifier__factory.connect(verifier, provider);
} else if (!isDeployTransaction(envelopingTransaction)) {
} else {
verifierContract = IRelayVerifier__factory.connect(verifier, provider);
}
} catch (e) {
Expand All @@ -361,29 +353,24 @@ export class RelayServer extends EventEmitter {

try {
let verifyMethod: PopulatedTransaction;
if (
isDeployTransaction(envelopingTransaction) &&
tokenContract != constants.AddressZero
) {
if (isDeployTransaction(envelopingTransaction)) {
verifyMethod = await (
verifierContract! as IDeployVerifier
verifierContract as IDeployVerifier
).populateTransaction.verifyRelayedCall(
envelopingTransaction.relayRequest,
envelopingTransaction.metadata.signature,
{ from: this.workerAddress }
);
} else if (!isDeployTransaction(envelopingTransaction)) {
} else {
verifyMethod = await (
verifierContract! as IRelayVerifier
verifierContract as IRelayVerifier
).populateTransaction.verifyRelayedCall(
envelopingTransaction.relayRequest as RelayRequest,
envelopingTransaction.metadata.signature
);
}

if (tokenContract != constants.AddressZero) {
await provider.call(verifyMethod!, 'pending');
}
await provider.call(verifyMethod, 'pending');
} catch (e) {
const error = e as Error;
throw new Error(`Verification by verifier failed: ${error.message}`);
Expand Down

0 comments on commit cd88907

Please sign in to comment.