Skip to content

Commit

Permalink
Refactor new daemon into Watchtower.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ava's DAO committed Dec 18, 2023
1 parent 212f371 commit d984b6b
Show file tree
Hide file tree
Showing 13 changed files with 241 additions and 32 deletions.
5 changes: 5 additions & 0 deletions watchtower/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ A cross-chain daemon used by the [__Wardens__](https://docs.nexa.exchange/warden
- [ ] SmartBCH Testnet (SBCH)
- [ ] Solana Testnet (SOL)
- [ ] Tron Testnet (TRX)


## Oracle Daemons

Manages Oracle price & data feeds.
File renamed without changes.
1 change: 1 addition & 0 deletions watchtower/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"license": "MIT",
"dependencies": {
"@bitauth/libauth": "1.19.1",
"@generalprotocols/price-oracle": "1.6.1",
"moment": "2.29.4",
"nexajs": "23.10.25",
"numeral": "2.0.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ import {
sendToken,
} from '@nexajs/token'

// nexa:tzs4e8n7dqtsyk0axx7zvcgt2snzt3t7z07ued0nu89hlvp6ggqqqdrypc4ea
const NXL_ID_HEX = 'a15c9e7e68170259fd31bc26610b542625c57e13fdccb5f3e1cb7fb03a420000' // NXL
// nexa:tztnyazksgqpkphrx2m2fgxapllufqmuwp6k07xtlc8k4xcjpqqqq99lxywr8
const STUDIO_ID_HEX = '9732745682001b06e332b6a4a0dd0fffc4837c707567f8cbfe0f6a9b12080000' // STUDIO

export default async (_wallet, isLive = false) => {
let coins
Expand All @@ -75,17 +75,17 @@ export default async (_wallet, isLive = false) => {
/* Filter tokens. */
// NOTE: Currently limited to a "single" Id.
tokens = tokens.filter(_token => {
return _token.tokenidHex === NXL_ID_HEX
return _token.tokenidHex === STUDIO_ID_HEX
})
// console.log('\n Tokens (filtered):', tokens)

if (tokens.length === 1) {
throw new Error('Oops! There are NO $NXL tokens to melt..')
throw new Error('Oops! There are NO $STUDIO tokens to melt..')
}

userData = [
'MELT',
'NXL',
'STUDIO',
]

/* Initialize hex data. */
Expand All @@ -101,7 +101,7 @@ export default async (_wallet, isLive = false) => {
// NOTE: Return the authority baton.
receivers.push({
address: _wallet.address,
tokenid: NXL_ID_HEX, // TODO Allow auto-format conversion.
tokenid: STUDIO_ID_HEX, // TODO Allow auto-format conversion.
tokens: BigInt(0xfc00000000000000), // All permissions enabled
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ import {
sendToken,
} from '@nexajs/token'

// nexa:tzs4e8n7dqtsyk0axx7zvcgt2snzt3t7z07ued0nu89hlvp6ggqqqdrypc4ea
const NXL_ID_HEX = 'a15c9e7e68170259fd31bc26610b542625c57e13fdccb5f3e1cb7fb03a420000' // NXL
// nexa:tztnyazksgqpkphrx2m2fgxapllufqmuwp6k07xtlc8k4xcjpqqqq99lxywr8
const STUDIO_ID_HEX = '9732745682001b06e332b6a4a0dd0fffc4837c707567f8cbfe0f6a9b12080000' // STUDIO

export default async (_wallet, _receiver, _amount, isLive = false) => {
let coins
Expand All @@ -75,13 +75,13 @@ export default async (_wallet, _receiver, _amount, isLive = false) => {
/* Filter tokens. */
// NOTE: Currently limited to a "single" Id.
tokens = tokens.filter(_token => {
return _token.tokenidHex === NXL_ID_HEX
return _token.tokenidHex === STUDIO_ID_HEX
})
// console.log('\n Tokens (filtered):', tokens)

userData = [
'MINT',
'NXL',
'STUDIO',
]

/* Initialize hex data. */
Expand All @@ -94,15 +94,15 @@ export default async (_wallet, _receiver, _amount, isLive = false) => {
},
{
address: _receiver,
tokenid: NXL_ID_HEX, // TODO Allow auto-format conversion.
tokenid: STUDIO_ID_HEX, // TODO Allow auto-format conversion.
tokens: BigInt(_amount),
},
]

// NOTE: Return the authority baton.
receivers.push({
address: _wallet.address,
tokenid: NXL_ID_HEX, // TODO Allow auto-format conversion.
tokenid: STUDIO_ID_HEX, // TODO Allow auto-format conversion.
tokens: BigInt(0xfc00000000000000), // All permissions enabled
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ import {
sendToken,
} from '@nexajs/token'

const TOKEN_ID = 'nexa:tzs4e8n7dqtsyk0axx7zvcgt2snzt3t7z07ued0nu89hlvp6ggqqqdrypc4ea' // NXL
const TOKEN_ID_HEX = 'a15c9e7e68170259fd31bc26610b542625c57e13fdccb5f3e1cb7fb03a420000' // NXL
const TOKEN_ID = 'nexa:tztnyazksgqpkphrx2m2fgxapllufqmuwp6k07xtlc8k4xcjpqqqq99lxywr8' // STUDIO
const TOKEN_ID_HEX = '9732745682001b06e332b6a4a0dd0fffc4837c707567f8cbfe0f6a9b12080000' // STUDIO

export default async () => {
let coins
Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions watchtower/src/meltGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ import {
sendToken,
} from '@nexajs/token'

// nexa:tztnyazksgqpkphrx2m2fgxapllufqmuwp6k07xtlc8k4xcjpqqqq99lxywr8
const STUDIO_ID_HEX = '9732745682001b06e332b6a4a0dd0fffc4837c707567f8cbfe0f6a9b12080000' // STUDIO
// nexa:tzs4e8n7dqtsyk0axx7zvcgt2snzt3t7z07ued0nu89hlvp6ggqqqdrypc4ea
const NXL_ID_HEX = 'a15c9e7e68170259fd31bc26610b542625c57e13fdccb5f3e1cb7fb03a420000' // NXL

export default async (_wallet, isLive = false) => {
let coins
Expand All @@ -75,17 +75,17 @@ export default async (_wallet, isLive = false) => {
/* Filter tokens. */
// NOTE: Currently limited to a "single" Id.
tokens = tokens.filter(_token => {
return _token.tokenidHex === STUDIO_ID_HEX
return _token.tokenidHex === NXL_ID_HEX
})
// console.log('\n Tokens (filtered):', tokens)

if (tokens.length === 1) {
throw new Error('Oops! There are NO $STUDIO tokens to melt..')
throw new Error('Oops! There are NO $NXL tokens to melt..')
}

userData = [
'MELT',
'STUDIO',
'NXL',
]

/* Initialize hex data. */
Expand All @@ -101,7 +101,7 @@ export default async (_wallet, isLive = false) => {
// NOTE: Return the authority baton.
receivers.push({
address: _wallet.address,
tokenid: STUDIO_ID_HEX, // TODO Allow auto-format conversion.
tokenid: NXL_ID_HEX, // TODO Allow auto-format conversion.
tokens: BigInt(0xfc00000000000000), // All permissions enabled
})

Expand Down
12 changes: 6 additions & 6 deletions watchtower/src/mintGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ import {
sendToken,
} from '@nexajs/token'

// nexa:tztnyazksgqpkphrx2m2fgxapllufqmuwp6k07xtlc8k4xcjpqqqq99lxywr8
const STUDIO_ID_HEX = '9732745682001b06e332b6a4a0dd0fffc4837c707567f8cbfe0f6a9b12080000' // STUDIO
// nexa:tzs4e8n7dqtsyk0axx7zvcgt2snzt3t7z07ued0nu89hlvp6ggqqqdrypc4ea
const NXL_ID_HEX = 'a15c9e7e68170259fd31bc26610b542625c57e13fdccb5f3e1cb7fb03a420000' // NXL

export default async (_wallet, _receiver, _amount, isLive = false) => {
let coins
Expand All @@ -75,13 +75,13 @@ export default async (_wallet, _receiver, _amount, isLive = false) => {
/* Filter tokens. */
// NOTE: Currently limited to a "single" Id.
tokens = tokens.filter(_token => {
return _token.tokenidHex === STUDIO_ID_HEX
return _token.tokenidHex === NXL_ID_HEX
})
// console.log('\n Tokens (filtered):', tokens)

userData = [
'MINT',
'STUDIO',
'NXL',
]

/* Initialize hex data. */
Expand All @@ -94,15 +94,15 @@ export default async (_wallet, _receiver, _amount, isLive = false) => {
},
{
address: _receiver,
tokenid: STUDIO_ID_HEX, // TODO Allow auto-format conversion.
tokenid: NXL_ID_HEX, // TODO Allow auto-format conversion.
tokens: BigInt(_amount),
},
]

// NOTE: Return the authority baton.
receivers.push({
address: _wallet.address,
tokenid: STUDIO_ID_HEX, // TODO Allow auto-format conversion.
tokenid: NXL_ID_HEX, // TODO Allow auto-format conversion.
tokens: BigInt(0xfc00000000000000), // All permissions enabled
})

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions watchtower/src/signMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ import {
sendToken,
} from '@nexajs/token'

const TOKEN_ID = 'nexa:tztnyazksgqpkphrx2m2fgxapllufqmuwp6k07xtlc8k4xcjpqqqq99lxywr8' // STUDIO
const TOKEN_ID_HEX = '9732745682001b06e332b6a4a0dd0fffc4837c707567f8cbfe0f6a9b12080000' // STUDIO
const TOKEN_ID = 'nexa:tzs4e8n7dqtsyk0axx7zvcgt2snzt3t7z07ued0nu89hlvp6ggqqqdrypc4ea' // NXL
const TOKEN_ID_HEX = 'a15c9e7e68170259fd31bc26610b542625c57e13fdccb5f3e1cb7fb03a420000' // NXL

export default async () => {
let coins
Expand Down
Loading

0 comments on commit d984b6b

Please sign in to comment.