Skip to content

Commit

Permalink
chore(): 4.0.9 (#2181)
Browse files Browse the repository at this point in the history
<!--  Thanks for sending a pull request! -->

#### What this PR does / why we need it:

#### Which issue(s) does this PR fixes?:
<!--
(Optional) Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

#### Additional comments?:
  • Loading branch information
canonbrother authored Feb 23, 2024
1 parent 26b8eb1 commit 767aa71
Show file tree
Hide file tree
Showing 47 changed files with 651 additions and 610 deletions.
86 changes: 43 additions & 43 deletions apps/playground-api/__tests__/modules/PlaygroundModule.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RegTestFoundationKeys } from '@defichain/jellyfish-network'
import { ConsortiumKey } from '../../src/ConsortiumKey'
// import { RegTestFoundationKeys } from '@defichain/jellyfish-network'
// import { ConsortiumKey } from '../../src/ConsortiumKey'
import { PlaygroundApiTesting } from '../../testing/PlaygroundApiTesting'

const pg = PlaygroundApiTesting.create()
Expand Down Expand Up @@ -63,46 +63,46 @@ it('should have gov set', async () => {
const gov = await testing.container.call('getgov', ['ATTRIBUTES'])
expect(gov).toStrictEqual({
ATTRIBUTES: {
'v0/consortium/1/members': {
'01': {
backingId: 'backing_address_btc_1_c',
mintLimit: 50,
mintLimitDaily: 5,
name: 'Waves HQ',
ownerAddress: ConsortiumKey.address,
status: 0
},
'02': {
backingId: 'backing_address_btc_1_br, backing_address_btc_2_br',
mintLimit: 50,
mintLimitDaily: 5,
name: 'Alexandria',
ownerAddress: RegTestFoundationKeys[RegTestFoundationKeys.length - 1].owner.address,
status: 0
}
},
'v0/consortium/2/members': {
'01': {
backingId: 'backing_address_eth_1_c',
mintLimit: 10,
mintLimitDaily: 5,
name: 'Waves HQ',
ownerAddress: ConsortiumKey.address,
status: 0
},
'02': {
backingId: 'backing_address_eth_1_br, backing_address_eth_2_br',
mintLimit: 10,
mintLimitDaily: 5,
name: 'Alexandria',
ownerAddress: RegTestFoundationKeys[RegTestFoundationKeys.length - 1].owner.address,
status: 0
}
},
'v0/consortium/1/mint_limit': '50',
'v0/consortium/1/mint_limit_daily': '5',
'v0/consortium/2/mint_limit': '20',
'v0/consortium/2/mint_limit_daily': '10',
// 'v0/consortium/1/members': {
// '01': {
// backingId: 'backing_address_btc_1_c',
// mintLimit: 50,
// mintLimitDaily: 5,
// name: 'Waves HQ',
// ownerAddress: ConsortiumKey.address,
// status: 0
// },
// '02': {
// backingId: 'backing_address_btc_1_br, backing_address_btc_2_br',
// mintLimit: 50,
// mintLimitDaily: 5,
// name: 'Alexandria',
// ownerAddress: RegTestFoundationKeys[RegTestFoundationKeys.length - 1].owner.address,
// status: 0
// }
// },
// 'v0/consortium/2/members': {
// '01': {
// backingId: 'backing_address_eth_1_c',
// mintLimit: 10,
// mintLimitDaily: 5,
// name: 'Waves HQ',
// ownerAddress: ConsortiumKey.address,
// status: 0
// },
// '02': {
// backingId: 'backing_address_eth_1_br, backing_address_eth_2_br',
// mintLimit: 10,
// mintLimitDaily: 5,
// name: 'Alexandria',
// ownerAddress: RegTestFoundationKeys[RegTestFoundationKeys.length - 1].owner.address,
// status: 0
// }
// },
// 'v0/consortium/1/mint_limit': '50',
// 'v0/consortium/1/mint_limit_daily': '5',
// 'v0/consortium/2/mint_limit': '20',
// 'v0/consortium/2/mint_limit_daily': '10',
'v0/live/economy/evm/block/fee_burnt': 0,
'v0/live/economy/evm/block/fee_burnt_max': 0,
'v0/live/economy/evm/block/fee_burnt_max_hash': expect.any(String),
Expand All @@ -118,7 +118,7 @@ it('should have gov set', async () => {
'v0/params/dfip2203/block_period': '20',
'v0/params/dfip2203/fee_pct': '0.05',
'v0/params/dfip2203/reward_pct': '0.05',
'v0/params/feature/consortium': 'true',
// 'v0/params/feature/consortium': 'true',
'v0/params/feature/gov': 'true',
'v0/token/0/fixed_interval_price_id': 'DFI/USD',
'v0/token/0/loan_collateral_enabled': 'true',
Expand Down
96 changes: 48 additions & 48 deletions apps/playground-api/src/setups/setup.gov.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,54 +67,54 @@ export class SetupGov extends PlaygroundSetup<Record<string, any>> {
'v0/vaults/dusd-vault/enabled': 'true',

// On-chain governance
'v0/params/feature/gov': 'true',

// Enable consortium
'v0/params/feature/consortium': 'true',

// Set a consortium global limit for dBTC
'v0/consortium/1/mint_limit': '50',
'v0/consortium/1/mint_limit_daily': '5',

// Set a consortium member for dBTC
'v0/consortium/1/members': {
'01': {
name: 'Waves HQ',
ownerAddress: this.consortiumOwnerAddress1,
backingId: 'backing_address_btc_1_c',
mintLimitDaily: '5.00000000',
mintLimit: '50.00000000'
},
'02': {
name: 'Alexandria',
ownerAddress: this.consortiumOwnerAddress2,
backingId: 'backing_address_btc_1_br, backing_address_btc_2_br',
mintLimitDaily: '5.00000000',
mintLimit: '50.00000000'
}
},

// Consortium global limit for dETH
'v0/consortium/2/mint_limit': '20',
'v0/consortium/2/mint_limit_daily': '10',

// Set a consortium member for dETH
'v0/consortium/2/members': {
'01': {
name: 'Waves HQ',
ownerAddress: this.consortiumOwnerAddress1,
backingId: 'backing_address_eth_1_c',
mintLimitDaily: '5.00000000',
mintLimit: '10.00000000'
},
'02': {
name: 'Alexandria',
ownerAddress: this.consortiumOwnerAddress2,
backingId: 'backing_address_eth_1_br, backing_address_eth_2_br',
mintLimitDaily: '5.00000000',
mintLimit: '10.00000000'
}
}
'v0/params/feature/gov': 'true'

// // Enable consortium
// 'v0/params/feature/consortium': 'true'

// // Set a consortium global limit for dBTC
// 'v0/consortium/1/mint_limit': '50',
// 'v0/consortium/1/mint_limit_daily': '5',

// // Set a consortium member for dBTC
// 'v0/consortium/1/members': {
// '01': {
// name: 'Waves HQ',
// ownerAddress: this.consortiumOwnerAddress1,
// backingId: 'backing_address_btc_1_c',
// mintLimitDaily: '5.00000000',
// mintLimit: '50.00000000'
// },
// '02': {
// name: 'Alexandria',
// ownerAddress: this.consortiumOwnerAddress2,
// backingId: 'backing_address_btc_1_br, backing_address_btc_2_br',
// mintLimitDaily: '5.00000000',
// mintLimit: '50.00000000'
// }
// },

// // Consortium global limit for dETH
// 'v0/consortium/2/mint_limit': '20',
// 'v0/consortium/2/mint_limit_daily': '10',

// // Set a consortium member for dETH
// 'v0/consortium/2/members': {
// '01': {
// name: 'Waves HQ',
// ownerAddress: this.consortiumOwnerAddress1,
// backingId: 'backing_address_eth_1_c',
// mintLimitDaily: '5.00000000',
// mintLimit: '10.00000000'
// },
// '02': {
// name: 'Alexandria',
// ownerAddress: this.consortiumOwnerAddress2,
// backingId: 'backing_address_eth_1_br, backing_address_eth_2_br',
// mintLimitDaily: '5.00000000',
// mintLimit: '10.00000000'
// }
// }
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion apps/whale-api/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.7"

services:
defi-blockchain:
image: defi/defichain:4.0.5
image: defi/defichain:4.0.9

ports:
- "19554:19554"
Expand Down
13 changes: 11 additions & 2 deletions apps/whale-api/src/module.api/address.controller.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Testing } from '@defichain/jellyfish-testing'
import { ForbiddenException } from '@nestjs/common'
import BigNumber from 'bignumber.js'
import { RegTestFoundationKeys } from '@defichain/jellyfish-network'
import { RpcApiError } from '@defichain/jellyfish-api-core/dist/index'

const container = new MasterNodeRegTestContainer()
let app: NestFastifyApplication
Expand Down Expand Up @@ -1077,7 +1078,15 @@ describe('listTokens', () => {
})

it('should return empty and page undefined while listTokens with invalid address', async () => {
const tokens = await controller.listTokens('invalid', { size: 30 })
expect(tokens).toStrictEqual(expect.objectContaining({ data: [], page: undefined }))
try {
await controller.listTokens('invalid', { size: 30 })
} catch (err: any) {
expect(err).toBeInstanceOf(RpcApiError)
expect(err.payload).toStrictEqual({
code: -5,
message: 'Invalid owner address',
method: 'getaccount'
})
}
})
})
13 changes: 11 additions & 2 deletions apps/whale-api/src/module.api/address.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Testing } from '@defichain/jellyfish-testing'
import BigNumber from 'bignumber.js'
import { createTestingApp, stopTestingApp } from '../e2e.module'
import { NestFastifyApplication } from '@nestjs/platform-fastify'
import { RpcApiError } from '@defichain/jellyfish-api-core/dist/index'

const container = new MasterNodeRegTestContainer()
const testing = Testing.create(container)
Expand Down Expand Up @@ -175,7 +176,15 @@ describe('listTokens', () => {
})

it('should return empty and page undefined while listTokens with invalid address', async () => {
const tokens = await controller.listTokens('invalid', { size: 30 })
expect(tokens).toStrictEqual(expect.objectContaining({ data: [], page: undefined }))
try {
await controller.listTokens('invalid', { size: 30 })
} catch (err: any) {
expect(err).toBeInstanceOf(RpcApiError)
expect(err.payload).toStrictEqual({
code: -5,
message: 'Invalid owner address',
method: 'getaccount'
})
}
})
})
4 changes: 2 additions & 2 deletions apps/whale-api/src/module.api/consortium.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ async function setup (): Promise<void> {
}])
}

describe('getAssetBreakdown', () => {
describe.skip('getAssetBreakdown', () => {
it('should return an empty list if theres no consortium members or tokens initialized', async () => {
const info = await controller.getAssetBreakdown()
expect(info).toStrictEqual([])
Expand Down Expand Up @@ -188,7 +188,7 @@ describe('getAssetBreakdown', () => {
})
})

describe('getMemberStats', () => {
describe.skip('getMemberStats', () => {
it('should throw an error if given consortium member id does not exists', async () => {
await setup()

Expand Down
31 changes: 25 additions & 6 deletions apps/whale-api/src/module.api/stats.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller, Get } from '@nestjs/common'
import { Controller, Get, Inject, NotFoundException } from '@nestjs/common'
import { BurnData, RewardDistributionData, StatsData, SupplyData } from '@defichain/whale-api-client/dist/api/stats'
import { SemaphoreCache } from '@defichain-apps/libs/caches'
import { JsonRpcClient } from '@defichain/jellyfish-api-jsonrpc'
Expand All @@ -11,6 +11,7 @@ import { BlockchainInfo } from '@defichain/jellyfish-api-core/dist/category/bloc
import { getBlockSubsidy } from './subsidy'
import {
BlockSubsidy,
NetworkName,
getBlockRewardDistribution
} from '@defichain/jellyfish-network'
import { BurnInfo } from '@defichain/jellyfish-api-core/dist/category/account'
Expand All @@ -27,7 +28,8 @@ export class StatsController {
protected readonly poolPairService: PoolPairService,
protected readonly rpcClient: JsonRpcClient,
protected readonly cache: SemaphoreCache,
protected readonly blockSubsidy: BlockSubsidy
protected readonly blockSubsidy: BlockSubsidy,
@Inject('NETWORK') protected readonly network: NetworkName
) {
}

Expand Down Expand Up @@ -210,13 +212,30 @@ export class StatsController {
}
}

private getBurnAddress (): string {
switch (this.network) {
case 'mainnet':
return '8defichainBurnAddressXXXXXXXdRQkSm'
case 'testnet':
case 'changi':
case 'devnet':
return '7DefichainBurnAddressXXXXXXXdMUE5n'
case 'regtest':
return 'mfburnZSAM7Gs1hpDeNaMotJXSGA7edosG'
default:
throw new NotFoundException('Unable to get burn address due to unknown network')
}
}

/**
* '76a914f7874e8821097615ec345f74c7e5bcf61b12e2ee88ac' is '8defichainBurnAddressXXXXXXXdRQkSm'
* using the hex representation as it's applicable in all network
* ~~'76a914f7874e8821097615ec345f74c7e5bcf61b12e2ee88ac' is '8defichainBurnAddressXXXXXXXdRQkSm'~~
* ~~using the hex representation as it's applicable in all network~~
* update: https://github.com/DeFiCh/ain/pull/2798
* rpc `getaccount` only expects regular address, no more scriptpubkey
*/
private async getBurnedTotal (): Promise<BigNumber> {
const address = '76a914f7874e8821097615ec345f74c7e5bcf61b12e2ee88ac'
const tokens = await this.rpcClient.account.getAccount(address)
const burnAddress = this.getBurnAddress()
const tokens = await this.rpcClient.account.getAccount(burnAddress)
const burnInfo = await this.getBurnInfo()

const utxo = burnInfo.amount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ it('should getBurnInfo', async () => {
tokens: ['50.00000000@GOLD'],
feeburn: new BigNumber('2'),
auctionburn: new BigNumber(0),
consortiumtokens: [],
// consortiumtokens: [],
emissionburn: new BigNumber('6274'),
paybackburn: [],
paybackfees: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ describe('TransferDomain', () => {
}
])
await expect(promise).rejects.toThrow(RpcApiError)
await expect(promise).rejects.toThrow('Failed to create and sign TX: Invalid address')
await expect(promise).rejects.toThrow('Dst address must be an ERC55 address in case of "EVM" domain')
})

it('(evm -> dvm) should fail if src address is not ERC55 address in case of "EVM" domain', async () => {
Expand Down Expand Up @@ -488,7 +488,7 @@ describe('TransferDomain', () => {
}
])
await expect(promise).rejects.toThrow(RpcApiError)
await expect(promise).rejects.toThrow('Failed to create and sign TX: Invalid address')
await expect(promise).rejects.toThrow('Cannot transfer inside same domain')
})

it('(evm -> evm) should fail if transfer within same domain', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ describe('setGov ATTRIBUTES loan dusd burn keys', () => {
})
})

describe('setGov consortium ATTRIBUTES', () => {
describe.skip('setGov consortium ATTRIBUTES', () => {
const tGroup = TestingGroup.create(2)
let account0: string, account1: string
let idBTC: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ describe('Update Masternode', () => {

const promise = container.call('sendrawtransaction', [signedTx.hex])
await expect(promise).rejects.toThrow(DeFiDRpcError)
await expect(promise).rejects.toThrow(`DeFiDRpcError: 'bad-txns-collateral-locked, tried to spend locked collateral for ${masternodeId} (code 16)', code: -26`)
await expect(promise).rejects.toThrow(`DeFiDRpcError: 'bad-txns-collateral-locked, tried to spend locked collateral for ${masternodeId}', code: -26`)
})
})

Expand Down
Loading

0 comments on commit 767aa71

Please sign in to comment.