Skip to content

Commit

Permalink
Merge pull request #191 from wbobeirne/webln-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
wbobeirne authored Mar 21, 2019
2 parents a6d756a + bbe19a6 commit 1676497
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"tslint-react": "^3.6.0",
"typescript": "3.1.6",
"url-loader": "^1.1.1",
"webln": "0.0.3",
"webln": "0.2.0",
"webpack": "^4.19.0",
"webpack-cli": "^3.1.0",
"zip-webpack-plugin": "3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/sign/reducers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import types from './types';
import { SignMessageResponse } from 'webln/lib/provider';
import { SignMessageResponse } from 'webln';

export interface SignState {
signReceipt: SignMessageResponse | null;
Expand Down
19 changes: 16 additions & 3 deletions src/app/modules/sign/sagas.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
import { SagaIterator } from 'redux-saga';
import { takeLatest, select, call, put } from 'redux-saga/effects';
import { SignMessageResponse as WebLNSignMessageResponse } from 'webln';
import { selectNodeLibOrThrow } from 'modules/node/selectors';
import { requirePassword } from 'modules/crypto/sagas';
import { signMessage, verifyMessage } from './actions';
import types from './types';
import { SignMessageResponse, VerifyMessageResponse } from 'lib/lnd-http/types';
import {
SignMessageResponse as LndSignMessageResponse,
VerifyMessageResponse as LndVerifyMessageResponse,
} from 'lib/lnd-http/types';
import { safeGetNodeInfo } from 'utils/misc';

export function* handleSignMessage(action: ReturnType<typeof signMessage>): SagaIterator {
try {
yield call(requirePassword);
const nodeLib: Yielded<typeof selectNodeLibOrThrow> = yield select(selectNodeLibOrThrow);
const payload: Yielded<SignMessageResponse> = yield call(nodeLib.signMessage, action.payload);
const res: Yielded<LndSignMessageResponse> = yield call(nodeLib.signMessage, action.payload);

if (!res.signature) {
throw new Error('Message failed to sign, missing signature');
}

const payload: WebLNSignMessageResponse = {
message: action.payload,
signature: res.signature,
};

yield put({
type: types.SIGN_MESSAGE_SUCCESS,
Expand All @@ -29,7 +42,7 @@ export function* handleVerifyMessage(action: ReturnType<typeof verifyMessage>):
try {
yield call(requirePassword);
const nodeLib: Yielded<typeof selectNodeLibOrThrow> = yield select(selectNodeLibOrThrow);
const verification: Yielded<VerifyMessageResponse> = yield call(nodeLib.verifyMessage, action.payload);
const verification: Yielded<LndVerifyMessageResponse> = yield call(nodeLib.verifyMessage, action.payload);
const nodeInfo: Yielded<typeof nodeLib.getNodeInfo> = yield call(safeGetNodeInfo, nodeLib, verification.pubkey);
const payload = {
...verification,
Expand Down
10 changes: 5 additions & 5 deletions src/app/modules/sign/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
enum SignTypes {
SIGN_MESSAGE = 'SIGN_MESSAGE',
SIGN_MESSAGE_SUCCESS = "SIGN_MESSAGE_SUCCESS",
SIGN_MESSAGE_FAILURE = "SIGN_MESSAGE_FAILURE",
SIGN_MESSAGE_SUCCESS = 'SIGN_MESSAGE_SUCCESS',
SIGN_MESSAGE_FAILURE = 'SIGN_MESSAGE_FAILURE',
VERIFY_MESSAGE = 'VERIFY_MESSAGE',
VERIFY_MESSAGE_VALID = "VERIFY_MESSAGE_VALID",
VERIFY_MESSAGE_INVALID = "VERIFY_MESSAGE_INVALID",
VERIFY_MESSAGE_FAILURE = "VERIFY_MESSAGE_FAILURE",
VERIFY_MESSAGE_VALID = 'VERIFY_MESSAGE_VALID',
VERIFY_MESSAGE_INVALID = 'VERIFY_MESSAGE_INVALID',
VERIFY_MESSAGE_FAILURE = 'VERIFY_MESSAGE_FAILURE',
}

export default SignTypes;
2 changes: 1 addition & 1 deletion src/app/prompts/invoice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import BN from 'bn.js';
import { connect } from 'react-redux';
import { Form, Input, Select, Button } from 'antd';
import { RequestInvoiceArgs, RequestInvoiceResponse } from 'webln/lib/provider';
import { RequestInvoiceArgs, RequestInvoiceResponse } from 'webln';
import PromptTemplate from 'components/PromptTemplate';
import { getPromptArgs, getPromptOrigin, watchUntilPropChange, OriginData } from 'utils/prompt';
import { removeDomainPrefix } from 'utils/formatters';
Expand Down
2 changes: 1 addition & 1 deletion src/app/prompts/payment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import moment from 'moment';
import { connect } from 'react-redux';
import { Tabs, Input, Select } from 'antd';
import { SendPaymentResponse } from 'webln/lib/provider';
import { SendPaymentResponse } from 'webln';
import PromptTemplate from 'components/PromptTemplate';
import NodeInfo from 'components/PromptTemplate/NodeInfo';
import Loader from 'components/Loader';
Expand Down
2 changes: 1 addition & 1 deletion src/app/prompts/sign.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { connect } from 'react-redux';
import { SignMessageResponse } from 'webln/lib/provider';
import { SignMessageResponse } from 'webln';
import { AppState } from 'store/reducers';
import PromptTemplate from 'components/PromptTemplate';
import SwapGraphic from 'components/PromptTemplate/SwapGraphic';
Expand Down
2 changes: 1 addition & 1 deletion src/background_script/getNodeInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GetInfoResponse } from 'webln/lib/provider';
import { GetInfoResponse } from 'webln';
import runSelector from '../content_script/runSelector';
import { LndHttpClient } from 'lib/lnd-http';
import { selectSyncedUnencryptedNodeState } from 'modules/node/selectors';
Expand Down
2 changes: 1 addition & 1 deletion src/webln/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
RequestInvoiceArgs,
RequestInvoiceResponse,
SignMessageResponse,
} from 'webln/lib/provider';
} from 'webln';
import { PROMPT_TYPE } from './types';

export default class JouleWebLNProvider implements WebLNProvider {
Expand Down
7 changes: 4 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7778,9 +7778,10 @@ webidl-conversions@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad"

[email protected]:
version "0.0.3"
resolved "https://registry.yarnpkg.com/webln/-/webln-0.0.3.tgz#d8bd43accfb2f85216441a3f67f58349835c9aa9"
[email protected]:
version "0.2.0"
resolved "https://registry.yarnpkg.com/webln/-/webln-0.2.0.tgz#841a19a315efb407dc065ab6827bd64e61051cdd"
integrity sha512-8fuN3k6Aif6HkAeKtvhnWHUdkOwZDf5igQc+jtOR3Id1x1q6/hklJqnixSOIARu1VUrhInLeVBTr1QdKatGlkw==
dependencies:
"@types/chrome" "0.0.74"

Expand Down

0 comments on commit 1676497

Please sign in to comment.