Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
canonbrother committed May 25, 2021
2 parents af773e7 + fd323e5 commit 9aeb58c
Show file tree
Hide file tree
Showing 112 changed files with 3,318 additions and 1,490 deletions.
18 changes: 10 additions & 8 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@

/.github/ @fuxingloh
/.husky/ @fuxingloh
/.idea/ @fuxingloh
/.github/workflows/oss-governance-bot.yml @fuxingloh
/.github/governance.yml @fuxingloh
/.idea/ @fuxingloh @jingyi2811 @thedoublejay

/website/ @fuxingloh
/website/ @fuxingloh @canonbrother

/packages/jellyfish/ @fuxingloh
/packages/jellyfish-address/ @fuxingloh @ivan-zynesis
/packages/jellyfish-api-core/ @fuxingloh @canonbrother @jingyi2811
/packages/jellyfish-api-jsonrpc/ @fuxingloh
/packages/jellyfish-api-core/ @fuxingloh @canonbrother @jingyi2811 @thedoublejay
/packages/jellyfish-api-jsonrpc/ @fuxingloh @thedoublejay
/packages/jellyfish-crypto/ @fuxingloh
/packages/jellyfish-json/ @fuxingloh @canonbrother
/packages/jellyfish-network/ @fuxingloh
/packages/jellyfish-transaction/ @fuxingloh

/packages/jellyfish-transaction/ @fuxingloh
/packages/jellyfish-transaction/src/script/ @fuxingloh @canonbrother @jingyi2811
/packages/jellyfish-transaction/src/script/defi/ @fuxingloh @canonbrother

/packages/jellyfish-transaction-builder/ @fuxingloh @ivan-zynesis
/packages/jellyfish-wallet/ @fuxingloh
/packages/jellyfish-wallet-mnemonic/ @fuxingloh
Expand All @@ -29,6 +31,6 @@ jest.config.js @fuxingloh
package.json @fuxingloh
package-lock.json @fuxingloh

CONTRIBUTING.md @fuxingloh
CONTRIBUTING.md @fuxingloh @canonbrother
README.md @fuxingloh
LICENSE @fuxingloh
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/setup-node@v2.1.5
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
- uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
with:
node-version: '15'

Expand All @@ -26,8 +26,8 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/setup-node@v2.1.5
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
- uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
with:
node-version: '15'

Expand All @@ -39,8 +39,8 @@ jobs:
name: Size Limit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/setup-node@v2.1.5
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
- uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
with:
node-version: '15'

Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: "CodeQL"
name: CodeQL

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
Expand All @@ -19,8 +17,7 @@ jobs:
language: [ javascript ]

steps:
- name: Checkout repository
uses: actions/[email protected]
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/oss-governance-bot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: OSS
name: Governance

on:
pull_request_target:
branches: [ master, main ]
types: [ synchronize, opened, labeled, unlabeled ]
issues:
types: [ opened, labeled, unlabeled ]
Expand All @@ -11,10 +10,10 @@ on:

jobs:
main:
name: Governance
name: OSS
runs-on: ubuntu-latest
steps:
- uses: DeFiCh/oss-governance-bot@v2.0.5
- uses: DeFiCh/oss-governance-bot@833b5984684295040d750c1970d05dc8beaa8724
with:
github-token: ${{ secrets.DEFICHAIN_BOT_GITHUB_TOKEN }}

2 changes: 1 addition & 1 deletion .github/workflows/oss-governance-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Labeler
runs-on: ubuntu-latest
steps:
- uses: fuxingloh/multi-labeler@v1.5.1
- uses: fuxingloh/multi-labeler@1d6d95ddcc7ef8b928d514329663ba4e0ff0eaf5
with:
github-token: ${{ secrets.DEFICHAIN_BOT_GITHUB_TOKEN }}
config-path: .github/labeler.yml
21 changes: 21 additions & 0 deletions .github/workflows/oss-governance-project-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Governance

on:
issues:
types: [ opened, labeled ]

jobs:
main:
name: DeFi Products
runs-on: ubuntu-latest
if: contains(github.event.issue.labels.*.name, 'triage/accepted')
steps:
- uses: actions/github-script@a3e7071a34d7e1f219a8a4de9a5e0a34d1ee1293
with:
github-token: ${{ secrets.DEFICHAIN_BOT_GITHUB_TOKEN }}
script: |
github.projects.createCard({
column_id: 13687171,
content_id: context.payload.issue.id,
content_type: 'Issue',
})
28 changes: 28 additions & 0 deletions .github/workflows/oss-governance-project-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Governance

on:
pull_request:
types: [ opened ]

jobs:
main:
name: DeFi Products
runs-on: ubuntu-latest
if: github.event.sender.type == 'User' && github.event.pull_request.head.repo.full_name == github.repository
steps:
- uses: actions/github-script@a3e7071a34d7e1f219a8a4de9a5e0a34d1ee1293
with:
github-token: ${{ secrets.DEFICHAIN_BOT_GITHUB_TOKEN }}
script: |
github.projects.createCard({
column_id: 14389251,
content_id: context.payload.pull_request.id,
content_type: 'PullRequest',
})
github.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
assignees: [context.payload.sender.login]
})
19 changes: 0 additions & 19 deletions .github/workflows/oss-governance-project.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
runs-on: ubuntu-latest
environment: NPM Release Publishing
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/setup-node@v2.1.5
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
- uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
with:
node-version: '15'

- uses: actions/github-script@v4.0.2
- uses: actions/github-script@a3e7071a34d7e1f219a8a4de9a5e0a34d1ee1293
id: version
with:
script: |
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/sync-labels.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: sync labels
name: Labels

on:
push:
Expand All @@ -7,9 +7,10 @@ on:

jobs:
main:
name: Syncer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f

- uses: micnncim/action-label-syncer@0e9c5104859d0e78219af63791636eba42382b5d
with:
Expand Down
1 change: 1 addition & 0 deletions .idea/dictionaries/fuxing.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 32 additions & 32 deletions packages/jellyfish-address/__tests__/p2pkh.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ describe('P2PKH', () => {
it('should get the type precisely', () => {
const p2pkh = DeFiAddress.from('mainnet', p2pkhFixture.mainnet)
expect(p2pkh.valid).toBeTruthy()
expect(p2pkh.type).toBe('P2PKH')
expect(p2pkh.constructor.name).toBe('P2PKH')
expect(p2pkh.network).toBe(MainNet)
expect(p2pkh.type).toStrictEqual('P2PKH')
expect(p2pkh.constructor.name).toStrictEqual('P2PKH')
expect(p2pkh.network).toStrictEqual(MainNet)
})

it('should work for all recognized network type', () => {
const testnet = DeFiAddress.from('testnet', p2pkhFixture.testnet)
expect(testnet.valid).toBeTruthy()
expect(testnet.type).toBe('P2PKH')
expect(testnet.constructor.name).toBe('P2PKH')
expect(testnet.network).toBe(TestNet)
expect(testnet.type).toStrictEqual('P2PKH')
expect(testnet.constructor.name).toStrictEqual('P2PKH')
expect(testnet.network).toStrictEqual(TestNet)

const regtest = DeFiAddress.from('regtest', p2pkhFixture.regtest)
expect(regtest.valid).toBeTruthy()
expect(regtest.type).toBe('P2PKH')
expect(regtest.constructor.name).toBe('P2PKH')
expect(regtest.network).toBe(RegTest)
expect(regtest.type).toStrictEqual('P2PKH')
expect(regtest.constructor.name).toStrictEqual('P2PKH')
expect(regtest.network).toStrictEqual(RegTest)
})
})

Expand All @@ -57,8 +57,8 @@ describe('P2PKH', () => {
// valid address, used on different network
const p2pkh = DeFiAddress.from('testnet', p2pkhFixture.mainnet)
expect(p2pkh.valid).toBeFalsy()
// expect(p2pkh.type).toBe('P2PKH') // invalid address guessed type is not promising, as p2pkh and p2sh are versy similar
expect(p2pkh.network).toBe(TestNet)
// expect(p2pkh.type).toStrictEqual('P2PKH') // invalid address guessed type is not promising, as p2pkh and p2sh are versy similar
expect(p2pkh.network).toStrictEqual(TestNet)
})

it('should get the type precisely', () => {
Expand All @@ -70,24 +70,24 @@ describe('P2PKH', () => {
describe('to()', () => {
it('should be able to build a new address using a public key hash (20 bytes, 40 char hex string)', () => {
const pubKeyHash = '134b0749882c225e8647df3a3417507c6f5b2797'
expect(pubKeyHash.length).toEqual(40)
expect(pubKeyHash.length).toStrictEqual(40)

const p2pkh = P2PKH.to('regtest', pubKeyHash)
expect(p2pkh.type).toEqual('P2PKH')
expect(p2pkh.type).toStrictEqual('P2PKH')
expect(p2pkh.valid).toBeTruthy()

const scriptStack = p2pkh.getScript()
expect(scriptStack.stack.length).toEqual(5)
expect(scriptStack.stack[0]).toEqual(OP_CODES.OP_DUP)
expect(scriptStack.stack[1]).toEqual(OP_CODES.OP_HASH160)
expect(scriptStack.stack[2]).toEqual(OP_CODES.OP_PUSHDATA_HEX_LE(pubKeyHash))
expect(scriptStack.stack[3]).toEqual(OP_CODES.OP_EQUALVERIFY)
expect(scriptStack.stack[4]).toEqual(OP_CODES.OP_CHECKSIG)
expect(scriptStack.stack.length).toStrictEqual(5)
expect(scriptStack.stack[0]).toStrictEqual(OP_CODES.OP_DUP)
expect(scriptStack.stack[1]).toStrictEqual(OP_CODES.OP_HASH160)
expect(scriptStack.stack[2]).toStrictEqual(OP_CODES.OP_PUSHDATA_HEX_LE(pubKeyHash))
expect(scriptStack.stack[3]).toStrictEqual(OP_CODES.OP_EQUALVERIFY)
expect(scriptStack.stack[4]).toStrictEqual(OP_CODES.OP_CHECKSIG)
})

it('should reject invalid data - not 20 bytes data', () => {
const pubKeyHash = '134b0749882c225e8647df3a3417507c6f5b27'
expect(pubKeyHash.length).toEqual(38)
expect(pubKeyHash.length).toStrictEqual(38)

expect(() => {
P2PKH.to('regtest', pubKeyHash)
Expand All @@ -102,40 +102,40 @@ describe('P2PKH', () => {
try {
invalid.getScript()
} catch (e) {
expect(e.message).toBe('InvalidDefiAddress')
expect(e.message).toStrictEqual('InvalidDefiAddress')
}
})

it('should be able to build script', async () => {
const p2pkh = DeFiAddress.from('mainnet', p2pkhFixture.mainnet)
const scriptStack = p2pkh.getScript()

expect(scriptStack.stack.length).toEqual(5)
expect(scriptStack.stack[0]).toEqual(OP_CODES.OP_DUP)
expect(scriptStack.stack[1]).toEqual(OP_CODES.OP_HASH160)
expect(scriptStack.stack[2].type).toEqual('OP_PUSHDATA') // tested in `to()`
expect(scriptStack.stack[3]).toEqual(OP_CODES.OP_EQUALVERIFY)
expect(scriptStack.stack[4]).toEqual(OP_CODES.OP_CHECKSIG)
expect(scriptStack.stack.length).toStrictEqual(5)
expect(scriptStack.stack[0]).toStrictEqual(OP_CODES.OP_DUP)
expect(scriptStack.stack[1]).toStrictEqual(OP_CODES.OP_HASH160)
expect(scriptStack.stack[2].type).toStrictEqual('OP_PUSHDATA') // tested in `to()`
expect(scriptStack.stack[3]).toStrictEqual(OP_CODES.OP_EQUALVERIFY)
expect(scriptStack.stack[4]).toStrictEqual(OP_CODES.OP_CHECKSIG)
})
})

it('validate()', () => {
const hex = bs58.decode(p2pkhFixture.mainnet).toString('hex').substring(2, 42) // take 20 bytes data only
const p2pkh = new P2PKH(MainNet, p2pkhFixture.mainnet, hex)

expect(p2pkh.validatorPassed).toEqual(0)
expect(p2pkh.validatorPassed).toStrictEqual(0)
expect(p2pkh.valid).toBeFalsy()

const isValid = p2pkh.validate()
expect(p2pkh.validatorPassed).toEqual(5)
expect(p2pkh.validatorPassed).toStrictEqual(5)
expect(isValid).toBeTruthy()
})

it('guess()', () => {
const p2pkh = DeFiAddress.guess(p2pkhFixture.mainnet)
expect(p2pkh.valid).toBeTruthy()
expect(p2pkh.type).toBe('P2PKH')
expect(p2pkh.constructor.name).toBe('P2PKH')
expect(p2pkh.network).toBe(MainNet)
expect(p2pkh.type).toStrictEqual('P2PKH')
expect(p2pkh.constructor.name).toStrictEqual('P2PKH')
expect(p2pkh.network).toStrictEqual(MainNet)
})
})
Loading

0 comments on commit 9aeb58c

Please sign in to comment.