Skip to content

Commit

Permalink
🛠 fix node build
Browse files Browse the repository at this point in the history
  • Loading branch information
bohendo committed Aug 19, 2020
1 parent 1e09edb commit ea801a6
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion modules/node/src/cfCore/cfCore.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class CFCoreService {
assertNoChallenges(channel);
const amount = toBN(params.amount);
const { assetId, nonce, recipient } = params;
const json = ChannelSerializer.toJSON(channel);
const json = ChannelSerializer.toJSON(channel)!;
const contractAddresses = this.configService.getContractAddresses(channel.chainId);
const multisigOwners = [
getSignerAddressFromPublicIdentifier(json.userIdentifiers[0]),
Expand Down
14 changes: 7 additions & 7 deletions modules/node/src/challenge/challenge.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export class ChallengeService implements OnModuleInit {
): Promise<ChallengeInitiatedResponse> {
this.assertWatcher();
await this.channelRepository.findByMultisigAddressOrThrow(multisigAddress);
const appInstance = await this.appInstanceRepository.findByIdentityHashOrThrow(appIdentityHash);
return this.watcher.initiate(appInstance.identityHash);
const app = await this.appInstanceRepository.findByIdentityHashOrThrow(appIdentityHash)!;
return this.watcher!.initiate(app.identityHash);
}

async cancelChallenge(
Expand All @@ -49,11 +49,11 @@ export class ChallengeService implements OnModuleInit {
this.assertWatcher();
// Verify the signature is on the proper nonce
const channel = await this.channelRepository.findByMultisigAddressOrThrow(multisigAddress);
const appInstance = await this.appInstanceRepository.findByIdentityHashOrThrow(appIdentityHash);
const app = await this.appInstanceRepository.findByIdentityHashOrThrow(appIdentityHash)!;

const hash = computeCancelDisputeHash(
appInstance.identityHash,
BigNumber.from(appInstance.latestVersionNumber),
app.identityHash,
BigNumber.from(app.latestVersionNumber),
);
const recovered = await recoverAddressFromChannelMessage(hash, userSignature);
const userSignerAddress = getSignerAddressFromPublicIdentifier(channel.userIdentifier);
Expand All @@ -67,12 +67,12 @@ export class ChallengeService implements OnModuleInit {
const nodeSignature = await signer.signMessage(hash);
const req = {
signatures: [nodeSignature, userSignature],
versionNumber: BigNumber.from(appInstance.latestVersionNumber),
versionNumber: BigNumber.from(app.latestVersionNumber),
};

// Call cancel challenge
// TODO: remove challenge from channel entry iff cancelled
return this.watcher.cancel(appInstance.identityHash, req);
return this.watcher!.cancel(app.identityHash, req);
}

private assertWatcher() {
Expand Down
2 changes: 1 addition & 1 deletion modules/node/src/channel/channel.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class Channel {
transactions!: OnchainTransaction[];

@OneToMany((type: any) => Challenge, (challenge: Challenge) => challenge.channel)
challenges: Challenge[];
challenges!: Challenge[];

@CreateDateColumn()
createdAt!: Date;
Expand Down
2 changes: 1 addition & 1 deletion modules/node/src/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class ConfigService implements OnModuleInit {
return Wallet.fromMnemonic(this.get(`INDRA_MNEMONIC`)).privateKey;
}

getSigner(chainId: number): IChannelSigner {
getSigner(chainId?: number): IChannelSigner {
if (chainId) {
const providers = this.getIndraChainProviders();
const provider = getEthProvider(providers[chainId], chainId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,12 @@ export class OnchainTransactionService implements OnModuleInit {
multisigAddress: string,
): Promise<providers.TransactionResponse> {
const channel = await this.channelRepository.findByMultisigAddressOrThrow(multisigAddress);
const queue = this.queues.get(chainId);
if (!queue) {
throw new Error(`Unsupported chainId ${chainId}. Expected one of: ${Array.from(this.queues.keys())}`);
}
const tx: OnchainTransactionResponse = await new Promise((resolve, reject) => {
this.queues.get(chainId).add(() => {
queue.add(() => {
this.sendTransaction(transaction, TransactionReason.DISPUTE, channel)
.then((result) => resolve(result))
.catch((error) => reject(error.message));
Expand Down
2 changes: 1 addition & 1 deletion modules/node/src/test/e2e/happy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { env, ethProviderUrl, expect, MockConfigService } from "../utils";
const { AddressZero } = constants;
const { parseEther } = utils;

describe.only("Mostly happy paths", () => {
describe("Mostly happy paths", () => {
const log = new ColorfulLogger("MostlyHappy", env.logLevel, true, "Test");

let app: INestApplication;
Expand Down
2 changes: 1 addition & 1 deletion ops/start-chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ else
opts="--entrypoint bash --mount type=bind,source=$root,target=/root"
fi

echo "Running ${INDRA_ENV}-mode image for testnet ${chain_id}: ${image}"
echo "Running ${INDRA_ENV:-dev}-mode image for testnet ${chain_id}: ${image}"

docker run $opts \
--detach \
Expand Down

0 comments on commit ea801a6

Please sign in to comment.