import { readFileSync , writeFileSync } from 'fs' ; import { join } from 'path' ; import dotenv from 'dotenv' ; import { formatSecrets , cliPrint , runAndHandleErrors , runShellCommand } from '../../src' ; interface Secrets { MNEMONIC : string ; RINKEBY_PROVIDER_URL : string ; AWS_ACCESS_KEY_ID : string ; AWS_SECRET_ACCESS_KEY : string ; AWS_SESSION_TOKEN ? : string ; } let secrets ; const chooseIntegration = ( ) => { const content = JSON . stringify ( { integration : 'coingecko' , airnodeType : 'aws' , network : 'rinkeby' , mnemonic : secrets . MNEMONIC , providerUrl : secrets . RINKEBY_PROVIDER_URL , } , null , 2 ) ; writeFileSync ( join ( __dirname , '../../integration-info.json' ) , content ) ; } ; const createAwsSecrets = ( ) => { const content = formatSecrets ( [ `# Generated by ${ __filename }` , `AWS_ACCESS_KEY_ID=${ secrets . AWS_ACCESS_KEY_ID }` , `AWS_SECRET_ACCESS_KEY=${ secrets . AWS_SECRET_ACCESS_KEY }` , `AWS_SESSION_TOKEN=${ secrets . AWS_SESSION_TOKEN }` , ] ) ; writeFileSync ( join ( __dirname , '../../aws.env' ) , content ) ; } ; const main = async ( ) => { cliPrint . info ( 'Running coingecko integration with Airnode deployed on AWS and rinkeby' ) ; const secretsFile = readFileSync ( join ( __dirname , './coingecko-aws-secrets.env' ) ) . toString ( ) ; secrets = dotenv . parse ( secretsFile ) as unknown as Secrets ; chooseIntegration ( ) ; runShellCommand ( 'yarn deploy-rrp' ) ; createAwsSecrets ( ) ; runShellCommand ( 'yarn create-airnode-secrets' ) ; runShellCommand ( 'yarn deploy-airnode' ) ; runShellCommand ( 'yarn deploy-requester' ) ; runShellCommand ( 'yarn derive-and-fund-sponsor-wallet' ) ; runShellCommand ( 'yarn sponsor-requester' ) ; runShellCommand ( 'yarn make-request' ) ; runShellCommand ( 'yarn remove-airnode' ) ; } ; runAndHandleErrors ( main ) ;