This project is no longer being maintained. It was originally developed together with the Sidestream unified auctions ui. See the removal PR here.
"Unified Auctions Notification Service" is a server-side application with the purpose of updating users to a specific blockchain contract. Whenever a change is made to this contract the user will be informed via email or other methods. This is to ensure quick response times, when changes were made that could break our products.
The bots can be hosted by any user, provided, they configure related environment variables. For more details, please
refer to Environment variables
section below.
# install dependencies
$ npm install
# rebuild and launch server
$ npm run dev
# build for production and launch server
$ npm run build
$ npm run start
Note: env variables are accessible via the secret
command under auction-ui/${environment}/notification-service
.
INFURA_PROJECT_ID
: (required) infura project id (can be found in: dashboard -> ethereum ->ETHERSCAN_API_KEY
: (required) Etherscan API Key, which is used to automatically download ABIsETHEREUM_NETWORK
: (optional, defaultmainnet
) – internal network name on which the bot poll for auctions.SMTP_*
: (optional, required for email usage) - SMTP data for the service to send emailsSMTP_HOST
: (required) - SMTP host addressSMTP_PORT
: (optional) - SMTP port. Defaults to465
SMTP_USERNAME
: (required) - SMTP usernameSMTP_PASSWORD
: (required) - SMTP passwordSMTP_EMAIL
: (required) - The outgoing address which is displayed to the user
RECEIVERS
: (required) - a json-string-formatted array ofReceivers
(See explanation below)POWERED_BY
: (optional) - the operator of the servicePOWERED_BY_LINK
: (optional) - a link on which you can contact the operator of the service
Every Receiver requires the following values:
receiver
- A custom value depending on the notifier type (see examples below)type
- The type of notifier (we currently supportemail
anddiscord
)subscriptions
- An array of Subscription Ids
You can find examples below:
{
"receiver": "[email protected]",
"type": "email",
"subscriptions": ["ChainLogUpdateAddress"]
}
Please make sure to include the required Environment variables
.
{
"receiver": "https://discord.com/api/webhooks/YOUR_WEBHOOK_ADDRESS",
"type": "discord",
"subscriptions": ["ChainLogUpdateAddress"]
}
Please provide a Discord Webhook URL to which we can send updates.
You do not need to update any other environment variables to setup a discord notifier.
Users can add their own custom event subscriptions. By default, the project comes with a few predefined subscriptions, however these may need to change depending on the use case or network.
The subscriptions can be found in ./src/constants/SUBSCRIPTIONS.ts
.
Every subscription requires the following values:
id
- Unique identifier. Used for references in email and console logsaddress
- The Ethereum address which expected to emit the eventeventName
- The name of the event you want to observeformatData
- A function that takes the emitted event data and have to return a markdown string that will be displayed in through the different notifiers. It has two values provided to help with the formatting:event
- the entire data returned by the event being calledformatEtherscanLink
- a helper function that takes intype
(eitheraddress
ortx
) and the content (either theaddress
ortransactionHash
).
Example:
export const SUBSCRIPTIONS: EventSubscription[] = [
{
id: 'ChainLogUpdateAddress',
address: '0xdA0Ab1e0017DEbCd72Be8599041a2aa3bA7e740F',
eventName: 'UpdateAddress',
formatData: (event, formatEtherscanLink) => {
return `> Key: ${ethers.utils.formatBytes32String(event.args.key)}<br />
> Address: [${event.args.addr}](${formatEtherscanLink('address', event.args.addr)})`;
},
},
]
Please see this centralized guide to get started with your development setup. Namely, you should:
- have a minimum
node
andnpm
version (seepackage.json
engine
section) - have a certain formatting and linting setup
- don't forget to create
./notification-service/.env
file
Help on both things is given in the linked resources above.