Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DDW-254] Address validation upgrade to use cardano-addresses CLI via…
… IPC (#2041) * WIP address introspection via IPC, using cardano-addresses CLI tool executued as a child process * Address introspection via IPC, using cardano-addresses CLI tool executed in a child process * Hoist stake_reference to AddressBase * [DDW-254] Integrate latest cardano js and update address validation logic - updates * [DDW-254] Integrate latest cardano js and update address validation logic - fixes * [DDW-254] Integrate latest cardano js and update address validation logic - fixes * [DDW-254] Integrate latest cardano js and update address validation logic - fixes * [DDW-254] Integrate latest cardano js and update address validation logic - fixes * [DDW-254] Integrate latest cardano js and update address validation logic - fixes * [DDW-254] Integrate latest cardano js and update address validation logic - fixes * [DDW-254] Integrate latest cardano js and update address validation logic - fixes * [DDW-254] Integrate latest cardano js and update address validation logic - fixes * [DDW-254] Integrate latest cardano js and update address validation logic - fixes * cardano-address: add to daedalus bridge (cherry picked from commit e6efdae) * add cardanoAddressBin and autocompletions to shell (cherry picked from commit f47fa50) * daedalus-bridge: fix errors copying files that exist * [DDW-254] Integrate latest cardano js and update address validation logic - fixes * [DDW] Bump cardano-wallet revision * [DDW-254] Integrate latest cardano js and update address validation logic - fixes * [DDW-254] Integrate latest cardano js and update address validation logic - updates * cardano-wallet: bump for new cardano-address fix * Reject non validation errors from introspect-address onReceieve. This does not include client-side handling * Bump cardano-wallet rev * Bump cardano-wallet rev via nix-shell -A devops --run "niv update cardano-wallet * Wallet row fixes * [DDW-254] Integrate latest cardano js and update address validation logic - fixes * [DDW-254] Integrate latest cardano js and update address validation logic - fixes * fix(address-introspection): refactor to spawning a child process Rather than the single line `exec`, this uses Node.js cross-platform API to pass stdin * fix(address-introspection): bump cardano-wallet * fix(address-introspection): bump cardano-wallet, switch to spawnSync removes the async complexity to produce a reliable and easy to reason about implementation. Given the nature of the operation, this is a fair use of the subprocess executor. Also adds renderer error handler to catch and log non-validation errors * fix(address-introspection): Check for empty buffer to detect error, generalise to user error matching * [DDW-254] Integrate latest cardano js and update address validation logic - fixes * [DDW-254] Integrate latest cardano js and update address validation logic - fixes * [DDW-254] Integrate latest cardano js and update address validation logic - fixes * [DDW-254] Integrate latest cardano js and update address validation logic - fixes * Bump cardano-wallet * Add cardano-address to the Jormungandr bridge * fix(address-introspection): Shelley testnet address network discrimination removal * [DDW-254] Integrate latest cardano js and update address validation logic - changelog * [DDW-254] Integrate latest cardano js and update address validation logic - fixes for Shelley * [DDW-254] Integrate latest cardano js and update address validation logic - fixes for Shelley testnet * [DDW-254] Integrate latest cardano js and update address validation logic - fixes for Shelley testnet * Apply valid mainnet_candidate_4 network ID to "Shelley Testnet" * [DDW-254] Integrate latest cardano js and update address validation logic - fixes for Shelley testnet * Bump cardano-wallet * DDW-296 Deadalus review fixes * [DDW-254] Integrate latest cardano js and update address validation logic - fixes * [DDW-254] Integrate latest cardano js and update address validation logic - fixes * [DDW-254] Prevent connecting issue report while blokchaing verification is is progress * DDW-296 Deadalus review fixes * Run translation manager * Fix flow error * Fix flow issues * Fix explorer URLs on Mainnet * BUmp Daedalus version * [DDW-254] Fix flow issue Co-authored-by: Aleksandar Djordjevic <aca_eliminator@hotmail.com> Co-authored-by: Samuel Leathers <samuel.leathers@iohk.io> Co-authored-by: Nikola Glumac <niglumac@gmail.com> Co-authored-by: Tomislav Horaček <tomislav.horacek@thespian.hr>
- Loading branch information
1 parent
aba9f98
commit b267153
Showing
20 changed files
with
208 additions
and
40 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,54 @@ | ||
// @flow | ||
|
||
export type IntrospectAddressRequest = { | ||
input: string, | ||
}; | ||
|
||
export type AddressStyle = 'Byron' | 'Icarus' | 'Jormungandr' | 'Shelley'; | ||
|
||
export type ChainPointer = { | ||
slot_num: number, | ||
transaction_index: number, | ||
output_index: number, | ||
}; | ||
|
||
export type AddressBase = { | ||
address_style: AddressStyle, | ||
network_tag: number | null, | ||
stake_reference: 'none' | 'by pointer' | 'by value', | ||
}; | ||
|
||
export type ByronAddress = AddressBase & { | ||
address_root: string, | ||
derivation_path: string, | ||
}; | ||
|
||
export type IcarusAddress = AddressBase & { | ||
address_root: string, | ||
}; | ||
|
||
export type JormungandrAddress = AddressBase & { | ||
address_type: 'single' | 'group' | 'account' | 'multisig', | ||
account_key?: string, | ||
merkle_root?: string, | ||
spending_key?: string, | ||
stake_key?: string, | ||
}; | ||
|
||
export type ShelleyAddress = AddressBase & { | ||
pointer?: ChainPointer, | ||
script_hash?: string, | ||
spending_key_hash?: string, | ||
stake_key_hash?: string, | ||
stake_script_hash?: string, | ||
}; | ||
|
||
export type IntrospectAddressResponse = | ||
| { | ||
introspection: | ||
| ByronAddress | ||
| IcarusAddress | ||
| JormungandrAddress | ||
| ShelleyAddress, | ||
} | ||
| 'Invalid'; |
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,35 @@ | ||
// @flow | ||
import { spawnSync } from 'child_process'; | ||
import { MainIpcChannel } from './lib/MainIpcChannel'; | ||
import { INTROSPECT_ADDRESS_CHANNEL } from '../../common/ipc/api'; | ||
import type { | ||
IntrospectAddressRendererRequest, | ||
IntrospectAddressMainResponse, | ||
} from '../../common/ipc/api'; | ||
|
||
// IpcChannel<Incoming, Outgoing> | ||
|
||
export const introspectAddressChannel: MainIpcChannel< | ||
IntrospectAddressRendererRequest, | ||
IntrospectAddressMainResponse | ||
> = new MainIpcChannel(INTROSPECT_ADDRESS_CHANNEL); | ||
|
||
export const handleAddressIntrospectionRequests = () => { | ||
introspectAddressChannel.onReceive( | ||
({ input }: IntrospectAddressRendererRequest) => | ||
new Promise((resolve, reject) => { | ||
const { stdout, stderr } = spawnSync( | ||
'cardano-address', | ||
['address', 'inspect'], | ||
{ input } | ||
); | ||
if (stderr.toString() !== '') { | ||
if (stderr.toString().match(/user error/g) !== null) { | ||
return resolve('Invalid'); | ||
} | ||
return reject(new Error(stderr.toString())); | ||
} | ||
return resolve({ introspection: JSON.parse(stdout.toString()) }); | ||
}) | ||
); | ||
}; |
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,13 @@ | ||
// @flow | ||
import { RendererIpcChannel } from './lib/RendererIpcChannel'; | ||
import { INTROSPECT_ADDRESS_CHANNEL } from '../../../common/ipc/api'; | ||
import type { | ||
IntrospectAddressRendererRequest, | ||
IntrospectAddressMainResponse, | ||
} from '../../../common/ipc/api'; | ||
|
||
// IpcChannel<Incoming, Outgoing> | ||
export const introspectAddressChannel: RendererIpcChannel< | ||
IntrospectAddressMainResponse, | ||
IntrospectAddressRendererRequest | ||
> = new RendererIpcChannel(INTROSPECT_ADDRESS_CHANNEL); |
Oops, something went wrong.