Skip to content

Commit

Permalink
feat(jellyfish-transaction-builder): add transferdomain (#2106)
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?:

---------

Co-authored-by: canonbrother <[email protected]>
Co-authored-by: Lyka Labrada <[email protected]>
Co-authored-by: thedoublejay <[email protected]>
  • Loading branch information
4 people authored Jul 14, 2023
1 parent cf27d7e commit 89b2dd1
Show file tree
Hide file tree
Showing 8 changed files with 768 additions and 14 deletions.
4 changes: 2 additions & 2 deletions 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:master-8594d0aec
image: defi/defichain:master-91a01aea0
ports:
- "19554:19554"
command: >
Expand Down Expand Up @@ -42,7 +42,7 @@ services:
-grandcentralheight=16
-grandcentralepilogueheight=17
-nextnetworkupgradeheight=18
-changiintermediateheight=18
-changiintermediateheight=19
-regtest-skip-loan-collateral-validation
-regtest-minttoken-simulate-mainnet=0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,11 @@ describe('TransferDomain', () => {
const [dvmBalance1, tokenId1] = dvmAcc1[0].split('@')
expect(tokenId1).toStrictEqual(tokenId0)

// check: dvm balance is transfered
// check: dvm balance is transferred
expect(new BigNumber(dvmBalance1))
.toStrictEqual(new BigNumber(dvmBalance0).minus(3))

// check: evm balance = dvm balance - tranferred
// check: evm balance = dvm balance - transferred
const withoutEthRes = await client.account.getTokenBalances({}, false)
const [withoutEth] = withoutEthRes[0].split('@')

Expand Down Expand Up @@ -408,11 +408,11 @@ describe('TransferDomain', () => {
const [dvmBalance1, tokenId1] = dvmAcc1[0].split('@')
expect(tokenId1).toStrictEqual(tokenId0)

// check: dvm balance is transfered
// check: dvm balance is transferred
expect(new BigNumber(dvmBalance1))
.toStrictEqual(new BigNumber(dvmBalance0).minus(3 + 4))

// check: evm balance = dvm balance - tranferred
// check: evm balance = dvm balance - transferred
const withoutEthRes = await client.account.getTokenBalances({}, false)
const [withoutEth] = withoutEthRes[0].split('@')

Expand Down
17 changes: 14 additions & 3 deletions packages/jellyfish-transaction-builder/__tests__/provider.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,20 @@ export class MockProviders {
return Eth.fromPubKeyUncompressed(pubKeyUncompressed)
}

async setupMocks (): Promise<void> {
async setupMocks (evm = false): Promise<void> {
// full nodes need importprivkey or else it can't list unspent
const wif = WIF.encode(0xef, await this.ellipticPair.privateKey())
await this.container.call('importprivkey', [wif])
const privKey = await this.ellipticPair.privateKey()

// TODO(canonbrother): try..catch to skip the err to allow import raw privkey again to support evm addr
// due to wif was imported beforehand
// https://github.com/BirthdayResearch/jellyfishsdk/blob/60ebb395ce78ca8d395ede56f90e46c18c0da935/packages/testcontainers/src/containers/RegTestContainer/Masternode.ts#L59-L60
// remove once auto import is done
try {
evm
? await this.container.call('importprivkey', [privKey.toString('hex')])
: await this.container.call('importprivkey', [WIF.encode(0xef, privKey)])
} catch (err) {
console.log('err: ', err)
}
}
}
Loading

0 comments on commit 89b2dd1

Please sign in to comment.