Skip to content

Commit

Permalink
Merge pull request #2122 from Emurgo/ruslan/ergo-flow-fixes
Browse files Browse the repository at this point in the history
Ergo Flow and Lint fixes
  • Loading branch information
vsubhuman authored Jun 1, 2021
2 parents 9d8780e + 9720b3d commit ead01b8
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/yoroi-extension/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ module.exports = {
'no-undef-init': 0, // need this to improve Flow type inference
'no-unneeded-ternary': ['error', { defaultAssignment: true }],
'prefer-template': 0,
'no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'no-trailing-spaces': 1,
'padded-blocks': 0,
'no-undef': 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ beforeAll(async () => {
});

test('Generate Catalyst registration tx', async () => {
const paymentKey = RustModule.WalletV4.PublicKey.from_bytes(
Buffer.from('3273a5316e4de228863bd7cf8dac90d57149e1a595f3dd131073b84e35546676', 'hex')
);
// const paymentKey = RustModule.WalletV4.PublicKey.from_bytes(
// Buffer.from('3273a5316e4de228863bd7cf8dac90d57149e1a595f3dd131073b84e35546676', 'hex')
// );
const stakePrivateKey = RustModule.WalletV4.PrivateKey.from_normal_bytes(
Buffer.from('f5beaeff7932a4164d270afde7716067582412e8977e67986cd9b456fc082e3a', 'hex')
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export default class ConnectorStore extends Store<StoresMap, ActionsMap> {
this.connectingMessage = response;
});
})
// eslint-disable-next-line no-console
.catch(err => console.error(err));
};

Expand All @@ -177,6 +178,7 @@ export default class ConnectorStore extends Store<StoresMap, ActionsMap> {
this.signingMessage = response;
});
})
// eslint-disable-next-line no-console
.catch(err => console.error(err));
};

Expand Down
3 changes: 2 additions & 1 deletion packages/yoroi-extension/chrome/extension/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ chrome.runtime.onMessage.addListener(async (
}
const utxos = await canGetAllUtxos.getAllUtxos();
const stateFetcher = await getStateFetcher(localStorageApi);
const bestBlock = await stateFetcher.getBestBlock({ network: wallet.getParent().getNetworkInfo() });
const bestBlock = await stateFetcher
.getBestBlock({ network: wallet.getParent().getNetworkInfo() });
return await connectorSignTx(wallet, password, utxos, bestBlock, tx, indices);
},
db,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ export async function connectorSignTx(
timestamp: Date.now(),
nBits: 682315684511744, // TODO: where to get difficulty? (does this impact signing?)
height: bestBlock.height + 1,
votes: "040000", // TODO: where to get votes? (does this impact signing?)
votes: '040000', // TODO: where to get votes? (does this impact signing?)
});
const blockHeader = RustModule.SigmaRust.BlockHeader.from_json(headerJson);
const preHeader = RustModule.SigmaRust.PreHeader.from_block_header(blockHeader);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// @flow

import type { WalletChecksum } from '@emurgo/cip4-js';
import {PublicDeriver} from '../../../app/api/ada/lib/storage/models/PublicDeriver/index';
import {MultiToken} from '../../../app/api/common/lib/MultiToken';
import {RustModule} from '../../../app/api/ada/lib/cardanoCrypto/rustLoader';
import { PublicDeriver } from '../../../app/api/ada/lib/storage/models/PublicDeriver/index';
import { MultiToken } from '../../../app/api/common/lib/MultiToken';
import { RustModule } from '../../../app/api/ada/lib/cardanoCrypto/rustLoader';

// ----- Types used in the dApp <-> Yoroi connection bridge ----- //

Expand All @@ -22,7 +22,7 @@ export function asAddress(input: any): Address {

export function asBoxCandidate(
input: any,
wasmInstance: typeof RustModule.SigmaRust
// wasmInstance: typeof RustModule.SigmaRust
): ErgoBoxCandidateJson {
try {
if (typeof input === 'object' &&
Expand Down Expand Up @@ -302,7 +302,7 @@ export function asTx(
return {
inputs: tx.inputs.map(input => asUnsignedInput(input, wasmInstance)),
dataInputs: tx.dataInputs.map(asDataInput),
outputs: tx.outputs.map(output => asBoxCandidate(output, wasmInstance)),
outputs: tx.outputs.map(output => asBoxCandidate(output /* , wasmInstance */)),
};
}
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,12 @@ declare module 'ergo-lib-wasm-browser' { // need to wrap flowgen output into mod
*/
get(index: number): ErgoBox;
}
declare export class BlockHeader {
static from_json(json: string): BlockHeader;
}
declare export class PreHeader {
static from_block_header(block_header: BlockHeader): PreHeader;
}
/**
* TBD
*/
Expand All @@ -795,6 +801,8 @@ declare module 'ergo-lib-wasm-browser' { // need to wrap flowgen output into mod
* @returns {ErgoStateContext}
*/
static dummy(): ErgoStateContext;

constructor(pre_header: PreHeader): this;
}
/**
* The root of ErgoScript IR. Serialized instances of this class are self sufficient and can be passed around.
Expand Down
6 changes: 5 additions & 1 deletion packages/yoroi-extension/package-lock.json

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

0 comments on commit ead01b8

Please sign in to comment.