-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
71 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ContractDefinition } from '../../../ContractDefinition'; | ||
import { WarpEnvironment } from '../../../Warp'; | ||
|
||
export class InvalidEnvError extends Error {} | ||
|
||
export class EnvVerifier { | ||
private readonly env: WarpEnvironment; | ||
|
||
constructor(env: WarpEnvironment) { | ||
this.env = env; | ||
} | ||
|
||
public verify(def: ContractDefinition<unknown>): void { | ||
if (def.testnet && this.env !== 'testnet') { | ||
throw new InvalidEnvError( | ||
'Trying to use testnet contract in a non-testnet env. Use the "forTestnet" factory method.' | ||
); | ||
} | ||
if (!def.testnet && this.env === 'testnet') { | ||
throw new InvalidEnvError('Trying to use non-testnet contract in a testnet env.'); | ||
} | ||
} | ||
} |