Skip to content

Commit

Permalink
feat: Updating to SDK v0.17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ashchan committed Jul 27, 2019
1 parent 476a918 commit a7cc81c
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 53 deletions.
2 changes: 1 addition & 1 deletion packages/neuron-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"last 2 chrome versions"
],
"dependencies": {
"@nervosnetwork/ckb-sdk-core": "0.16.0",
"@nervosnetwork/ckb-sdk-core": "0.17.0",
"@uifabric/experiments": "7.4.2",
"@uifabric/styling": "7.1.1",
"canvg": "2.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/neuron-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
]
},
"dependencies": {
"@nervosnetwork/ckb-sdk-core": "0.16.0",
"@nervosnetwork/ckb-sdk-utils": "0.16.0",
"@nervosnetwork/ckb-sdk-core": "0.17.0",
"@nervosnetwork/ckb-sdk-utils": "0.17.0",
"async": "3.0.1",
"bn.js": "4.11.8",
"chalk": "2.4.2",
Expand All @@ -52,7 +52,7 @@
"winston": "3.2.1"
},
"devDependencies": {
"@nervosnetwork/ckb-types": "0.16.0",
"@nervosnetwork/ckb-types": "0.17.0",
"@types/async": "3.0.0",
"@types/electron-devtools-installer": "2.2.0",
"@types/elliptic": "6.4.8",
Expand Down
6 changes: 3 additions & 3 deletions packages/neuron-wallet/src/models/keys/address.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AddressPrefix, AddressType as Type, AddressBinIdx, pubkeyToAddress } from '@nervosnetwork/ckb-sdk-utils'
import { AddressPrefix, AddressType as Type, pubkeyToAddress } from '@nervosnetwork/ckb-sdk-utils'

import { AccountExtendedPublicKey } from './key'

Expand All @@ -12,8 +12,8 @@ export enum AddressType {
export const publicKeyToAddress = (publicKey: string, prefix = AddressPrefix.Testnet) =>
pubkeyToAddress(publicKey, {
prefix,
type: Type.BinIdx,
binIdx: AddressBinIdx.P2PH,
type: Type.HashIdx,
codeHashIndex: '0x00',
})

export default class Address {
Expand Down
4 changes: 2 additions & 2 deletions packages/neuron-wallet/src/models/lock-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ export default class LockUtils {
const prefix = env.testnet ? core.utils.AddressPrefix.Testnet : core.utils.AddressPrefix.Mainnet
return core.utils.bech32Address(blake160, {
prefix,
type: core.utils.AddressType.BinIdx,
binIdx: core.utils.AddressBinIdx.P2PH,
type: core.utils.AddressType.HashIdx,
codeHashIndex: '0x00',
})
}

Expand Down
1 change: 1 addition & 0 deletions packages/neuron-wallet/src/types/cell-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ export interface CellOutPoint {
export interface Script {
args?: string[]
codeHash?: string | null
hashType: string
}
4 changes: 2 additions & 2 deletions packages/neuron-wallet/tests/database/address/dao.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import AddressDao, { Address } from '../../../src/database/address/dao'
describe('Address Dao tests', () => {
const address: Address = {
walletId: '1',
address: 'ckt1q9gry5zgxmpjnmtrp4kww5r39frh2sm89tdt2l6v234ygf',
address: 'ckt1qyqrdsefa43s6m882pcj53m4gdnj4k440axqswmu83',
path: "m/44'/309'/0'/0/0",
addressType: AddressType.Receiving,
addressIndex: 0,
Expand All @@ -21,7 +21,7 @@ describe('Address Dao tests', () => {

const usedAddress: Address = {
walletId: '2',
address: 'ckt1q9gry5zgxmpjnmtrp4kww5r39frh2sm89tdt2l6v234ygf',
address: 'ckt1qyqrdsefa43s6m882pcj53m4gdnj4k440axqswmu83',
path: "m/44'/309'/0'/0/0",
addressType: AddressType.Receiving,
addressIndex: 0,
Expand Down
6 changes: 3 additions & 3 deletions packages/neuron-wallet/tests/models/keys/address.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ describe('address', () => {
const publicKey = '0x024a501efd328e062c8675f2365970728c859c592beeefd6be8ead3d901330bc01'
const path = `m/44'/309'/0'/0/0`
const address = Address.fromPublicKey(publicKey, `m/44'/309'/0'/0/0`)
expect(address.address).toEqual('ckt1q9gry5zgxmpjnmtrp4kww5r39frh2sm89tdt2l6v234ygf')
expect(address.address).toEqual('ckt1qyqrdsefa43s6m882pcj53m4gdnj4k440axqswmu83')
expect(address.path).toEqual(path)
})

it('Generate testnet address from public key', () => {
const publicKey = '0x024a501efd328e062c8675f2365970728c859c592beeefd6be8ead3d901330bc01'
const address = publicKeyToAddress(publicKey)
expect('ckt1q9gry5zgxmpjnmtrp4kww5r39frh2sm89tdt2l6v234ygf').toBe(address)
expect('ckt1qyqrdsefa43s6m882pcj53m4gdnj4k440axqswmu83').toBe(address)
})

it('Generate mainnet address from public key', () => {
const publicKey = '0x024a501efd328e062c8675f2365970728c859c592beeefd6be8ead3d901330bc01'
const address = publicKeyToAddress(publicKey, AddressPrefix.Mainnet)
expect('ckb1q9gry5zgxmpjnmtrp4kww5r39frh2sm89tdt2l6vqdd7em').toBe(address)
expect('ckb1qyqrdsefa43s6m882pcj53m4gdnj4k440axqdt9rtd').toBe(address)
})
})
2 changes: 1 addition & 1 deletion packages/neuron-wallet/tests/models/lock-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('LockUtils Test', () => {
args: ['0x36c329ed630d6ce750712a477543672adab57f4c'],
},
lockHash: '0x3dbdeb3538b7abe1b1f85a86b150805728c29b26faceb5051fb6c7f92c346ed8',
address: 'ckt1q9gry5zgxmpjnmtrp4kww5r39frh2sm89tdt2l6v234ygf',
address: 'ckt1qyqrdsefa43s6m882pcj53m4gdnj4k440axqswmu83',
blake160: '0x36c329ed630d6ce750712a477543672adab57f4c',
}

Expand Down
8 changes: 4 additions & 4 deletions packages/neuron-wallet/tests/services/address.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ describe('Key tests', () => {

expect(2).toBe(addresses.testnetReceiving.length)
expect("m/44'/309'/0'/0/0").toBe(addresses.testnetReceiving[0].path)
expect('ckt1q9gry5zgqt5rp0t0uxv39lahkzcnfjl9x9utn683yv9zxs').toBe(addresses.testnetReceiving[0].address)
expect('ckt1qyqq96psh4h7rxgjl7mmpvf5e0jnz79earcsyrlxrx').toBe(addresses.testnetReceiving[0].address)

// will include testnet address and mainnet address, [0] and [1] will be same
expect(2).toBe(addresses.testnetChange.length)
expect("m/44'/309'/0'/1/1").toBe(addresses.testnetChange[1].path)
expect('ckt1q9gry5zg7r0qgqc3vnvy8pwr0q8mkgvgywfjazg9xlz2ev').toBe(addresses.testnetChange[1].address)
expect('ckt1qyq0phsyqvgkfkzrshphsramyxyz8yew3yzsl76naf').toBe(addresses.testnetChange[1].address)
})

it('toAddress', () => {
Expand All @@ -45,7 +45,7 @@ describe('Key tests', () => {
describe('Key tests with db', () => {
const address: Address = {
walletId: '1',
address: 'ckt1q9gry5zgxmpjnmtrp4kww5r39frh2sm89tdt2l6v234ygf',
address: 'ckt1qyqrdsefa43s6m882pcj53m4gdnj4k440axqswmu83',
path: "m/44'/309'/0'/0/0",
addressType: AddressType.Receiving,
addressIndex: 0,
Expand All @@ -60,7 +60,7 @@ describe('Key tests with db', () => {

const usedAddress: Address = {
walletId: '2',
address: 'ckt1q9gry5zgxmpjnmtrp4kww5r39frh2sm89tdt2l6v234ygf',
address: 'ckt1qyqrdsefa43s6m882pcj53m4gdnj4k440axqswmu83',
path: "m/44'/309'/0'/0/0",
addressType: AddressType.Receiving,
addressIndex: 0,
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-wallet/tests/services/transactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import TransactionsService, { SearchType } from '../../src/services/transactions
describe('transactions service', () => {
describe('filterSearchType', () => {
it('ckt prefix', () => {
const address = 'ckt1q9gry5zgxmpjnmtrp4kww5r39frh2sm89tdt2l6v234ygf'
const address = 'ckt1qyqrdsefa43s6m882pcj53m4gdnj4k440axqswmu83'
const type = TransactionsService.filterSearchType(address)
expect(type).toBe(SearchType.Address)
})
Expand Down
66 changes: 33 additions & 33 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2291,45 +2291,45 @@
call-me-maybe "^1.0.1"
glob-to-regexp "^0.3.0"

"@nervosnetwork/ckb-sdk-address@0.16.0":
version "0.16.0"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-sdk-address/-/ckb-sdk-address-0.16.0.tgz#971c5495f727e3412e0d803629ae9f5aa34fa44b"
integrity sha512-X0eClB7qujZdZtwQOfy70jkaSU/PqlGg3GUTBaR0mYJCevMcdS9F3VHugyKNp7PQdxJpo9fSsZMOuNmOImkIAg==
dependencies:
"@nervosnetwork/ckb-sdk-utils" "0.16.0"
"@nervosnetwork/ckb-types" "0.16.0"

"@nervosnetwork/ckb-sdk-core@0.16.0":
version "0.16.0"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-sdk-core/-/ckb-sdk-core-0.16.0.tgz#f4d8ee0928da46a5d2a9ccb7177218b43b0819a0"
integrity sha512-PJy+/AdMEOqZSKpeWew6T5nlh7vTbcIVbUQ4wD0Y2cNc5fxjS9yWe3uYu/kW9fexOm19tIl5hj/Xlm9SQj0sYA==
dependencies:
"@nervosnetwork/ckb-sdk-address" "0.16.0"
"@nervosnetwork/ckb-sdk-rpc" "0.16.0"
"@nervosnetwork/ckb-sdk-utils" "0.16.0"
"@nervosnetwork/ckb-types" "0.16.0"

"@nervosnetwork/ckb-sdk-rpc@0.16.0":
version "0.16.0"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-sdk-rpc/-/ckb-sdk-rpc-0.16.0.tgz#d09d9d185e6346b4754886ab9d6b32926d960021"
integrity sha512-CTT86CH3hDo+s8Q39y9/OLMOAQvtscuLV91FqPM1wqNcgLmfe7bk0Q2YDM9PD1E4goUAi6LNMISfb9PefJM1OA==
dependencies:
"@nervosnetwork/ckb-sdk-utils" "0.16.0"
"@nervosnetwork/ckb-sdk-address@0.17.0":
version "0.17.0"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-sdk-address/-/ckb-sdk-address-0.17.0.tgz#12a46cd69303b2d08ee0410dce1e6ad9a860850b"
integrity sha512-PGgiDm+4ByfYTjzbM6O+ltkP+drAnHeD9IA4xqs61kSSZzTXTcBXprnc3b2IWSq1HQwa2iL0Hv2aj4KY6HFWeQ==
dependencies:
"@nervosnetwork/ckb-sdk-utils" "0.17.0"
"@nervosnetwork/ckb-types" "0.17.0"

"@nervosnetwork/ckb-sdk-core@0.17.0":
version "0.17.0"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-sdk-core/-/ckb-sdk-core-0.17.0.tgz#2588141eb69d031f9f29c13c55d9214f5403e2ec"
integrity sha512-E2iBV9ZIyjPHJdKdLcCzKPln2WITtsyLakcKDROrBHmKcAUNxFHSLK9IpqFzWNVhD1Jh+P4gYPYbuXYVKoWr3Q==
dependencies:
"@nervosnetwork/ckb-sdk-address" "0.17.0"
"@nervosnetwork/ckb-sdk-rpc" "0.17.0"
"@nervosnetwork/ckb-sdk-utils" "0.17.0"
"@nervosnetwork/ckb-types" "0.17.0"

"@nervosnetwork/ckb-sdk-rpc@0.17.0":
version "0.17.0"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-sdk-rpc/-/ckb-sdk-rpc-0.17.0.tgz#a6f21535f712a36d4773f6a051866c4a1ce0ab07"
integrity sha512-YHs6Zcie9SgCtcA8Dc8w6vcP/AuAV0uozOS2JFDv719oTzsUkEex5dmEepr0dTNdHWgLqFycZndf974FiaRzgw==
dependencies:
"@nervosnetwork/ckb-sdk-utils" "0.17.0"
axios "0.19.0"

"@nervosnetwork/ckb-sdk-utils@0.16.0":
version "0.16.0"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-sdk-utils/-/ckb-sdk-utils-0.16.0.tgz#eba3249d8d1c381ec0eeabf2a9c831935b7da5a2"
integrity sha512-/SWHOPwiJI8yMXch65bPCfH0aay1uQyN7ZLTUL3mpu5FW2a4irbfdmNjMAQd4LE0DWoIaRFPFjXePGBqPNKLSA==
"@nervosnetwork/ckb-sdk-utils@0.17.0":
version "0.17.0"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-sdk-utils/-/ckb-sdk-utils-0.17.0.tgz#ea29b0f95ed36fe3b811a138b2eea3e7c9699aec"
integrity sha512-xhJW+TcHjH4rVUJP2bCAA9SnD1zy7m5W1Jb26QjuKPNy7qIV1xavldqdD8Jn9uFrJAMwpyZ+TG8DHk61TjXIDA==
dependencies:
"@nervosnetwork/ckb-types" "0.16.0"
"@nervosnetwork/ckb-types" "0.17.0"
blake2b-wasm "1.1.7"
elliptic "6.4.1"

"@nervosnetwork/ckb-types@0.16.0":
version "0.16.0"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-types/-/ckb-types-0.16.0.tgz#ed47de5da923d58e7754e6a52064331851fc16fe"
integrity sha512-vbV+RFkN8dhf6VG/hYoVeb45Tb21sFT/tFFsHW3ObK/sVc2OkKGsvSZOK2y6mzrgGPkAF3sgeVRWVsiJnMM/4g==
"@nervosnetwork/ckb-types@0.17.0":
version "0.17.0"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-types/-/ckb-types-0.17.0.tgz#a72b1dcc38c9bf10657865d11723c8c2f203b1ff"
integrity sha512-CBvEXE6a4RckwNvHiyo/Z2gVhEVCQAJBxxSnPjrE6+1Q2VKUUdj+oGgomlWOfpkPniejYrXrluIivSswWW0Njw==

"@nodelib/fs.stat@^1.1.2":
version "1.1.3"
Expand Down

0 comments on commit a7cc81c

Please sign in to comment.