-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: compatible ckb-cli tx multisig file (#3169)
- Loading branch information
1 parent
ee2fa9b
commit 77d99fb
Showing
9 changed files
with
170 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export const snakeToCamel = (str: string): string => { | ||
if (!str) return '' | ||
return str.replace(/([-_][a-z])/gi, c => c.toUpperCase().replace(/[-_]/g, '')) | ||
} | ||
|
||
export const deepCamelizeKeys = (item: unknown): unknown => { | ||
if (Array.isArray(item)) { | ||
return item.map((el: unknown) => deepCamelizeKeys(el)) | ||
} else if (typeof item === 'function' || item !== Object(item)) { | ||
return item | ||
} | ||
return Object.fromEntries( | ||
Object.entries(item as Record<string, unknown>).map(([key, value]: [string, unknown]) => [ | ||
key.replace(/([-_][a-z])/gi, c => c.toUpperCase().replace(/[-_]/g, '')), | ||
deepCamelizeKeys(value), | ||
]) | ||
) | ||
} | ||
|
||
export default { deepCamelizeKeys, snakeToCamel } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
packages/neuron-wallet/tests/utils/deep-camelize-keys/fixtures.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
{ | ||
"value": { | ||
"version": "0x0", | ||
"cell_deps": [ | ||
{ | ||
"out_point": { | ||
"tx_hash": "0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37", | ||
"index": "0x1" | ||
}, | ||
"dep_type": "dep_group" | ||
} | ||
], | ||
"header_deps": [], | ||
"inputs": [ | ||
{ | ||
"since": "0x0", | ||
"previous_output": { | ||
"tx_hash": "0x00bc60fd23dd556a9bd139791e4cb95d678550054953793b79c864abcc733eae", | ||
"index": "0x1" | ||
} | ||
}, | ||
{ | ||
"previous_output": { | ||
"txHash": "0x8b37ded770fe457e1d3969e93722873308aef1e6810757d248f437de4d009d8f", | ||
"index": "0x1" | ||
}, | ||
"since": "0x0" | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"capacity": "6600000000", | ||
"lock": { | ||
"args": "0x2d8765d2d0e007aa227e61d9bc1ebd7343360a58", | ||
"code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", | ||
"hash_type": "type" | ||
}, | ||
"type": null | ||
}, | ||
{ | ||
"capacity": "10399999375", | ||
"lock": { | ||
"args": "0x5b34cc4f76644ec6da564c1ace41711ee0f1e071", | ||
"code_hash": "0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8", | ||
"hash_type": "type" | ||
}, | ||
"type": null | ||
} | ||
], | ||
"outputs_data": ["0x", "0x"], | ||
"witnesses": [] | ||
}, | ||
"expected": { | ||
"version": "0x0", | ||
"inputs": [ | ||
{ | ||
"since": "0x0", | ||
"previousOutput": { | ||
"index": "0x1", | ||
"txHash": "0x00bc60fd23dd556a9bd139791e4cb95d678550054953793b79c864abcc733eae" | ||
} | ||
}, | ||
{ | ||
"since": "0x0", | ||
"previousOutput": { | ||
"txHash": "0x8b37ded770fe457e1d3969e93722873308aef1e6810757d248f437de4d009d8f", | ||
"index": "0x1" | ||
} | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"capacity": "6600000000", | ||
"lock": { | ||
"args": "0x2d8765d2d0e007aa227e61d9bc1ebd7343360a58", | ||
"codeHash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", | ||
"hashType": "type" | ||
}, | ||
"type": null | ||
}, | ||
{ | ||
"capacity": "10399999375", | ||
"lock": { | ||
"args": "0x5b34cc4f76644ec6da564c1ace41711ee0f1e071", | ||
"codeHash": "0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8", | ||
"hashType": "type" | ||
}, | ||
"type": null | ||
} | ||
], | ||
"witnesses": [], | ||
"cellDeps": [ | ||
{ | ||
"outPoint": { "index": "0x1", "txHash": "0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37" }, | ||
"depType": "dep_group" | ||
} | ||
], | ||
"headerDeps": [], | ||
"outputsData": ["0x", "0x"] | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
packages/neuron-wallet/tests/utils/deep-camelize-keys/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { deepCamelizeKeys } from '../../../src/utils/deep-camelize-keys' | ||
import fixtures from './fixtures.json' | ||
|
||
describe('test json to hump', () => { | ||
it('json to hump', () => { | ||
const result = deepCamelizeKeys(fixtures.value) | ||
expect(fixtures.expected).toEqual(result) | ||
}) | ||
}) |