質問編集履歴

2

どこでエラーが発生するのか

2019/07/21 01:09

投稿

kazumasamatsumo
kazumasamatsumo

スコア41

test CHANGED
File without changes
test CHANGED
@@ -335,3 +335,9 @@
335
335
  </style>
336
336
 
337
337
  ```
338
+
339
+
340
+
341
+ QRコードを読み込んだら別のページに戻る処理をしています。
342
+
343
+ そこでページ遷移はできているのですがそれとは引き換えにエラーがたくさん発生するようになっています

1

コード追加

2019/07/21 01:09

投稿

kazumasamatsumo
kazumasamatsumo

スコア41

test CHANGED
File without changes
test CHANGED
@@ -13,3 +13,325 @@
13
13
 
14
14
 
15
15
  この定義の仕方はどうすればいいですか?
16
+
17
+
18
+
19
+ ```
20
+
21
+ <template>
22
+
23
+ <div class="qrReader">
24
+
25
+ <qrcode-reader @init="onInit" @decode="onDecode"></qrcode-reader>
26
+
27
+ </div>
28
+
29
+ </template>
30
+
31
+
32
+
33
+ <script lang="ts">
34
+
35
+
36
+
37
+ import Vue from 'vue';
38
+
39
+ import { AccountHttp, MosaicHttp, NamespaceHttp, MosaicService, Address, PublicAccount, PlainMessage, TransactionHttp,
40
+
41
+ SimpleWallet, Password, NetworkType, NetworkCurrencyMosaic, AggregateTransaction, Account, TransferTransaction, Deadline } from 'nem2-sdk';
42
+
43
+ import Nem2Client from '../libs/Nem2Client';
44
+
45
+ import settingModel from '@/libs/settingModel';
46
+
47
+ import { QrcodeReader } from 'vue-qrcode-reader';
48
+
49
+
50
+
51
+ export default {
52
+
53
+ components: { QrcodeReader },
54
+
55
+ name: "qrReader",
56
+
57
+ data: () => ({
58
+
59
+ nem: new settingModel(),
60
+
61
+ qrJson: '',
62
+
63
+ isLoading: false,
64
+
65
+ rules: {
66
+
67
+ senderAddrLimit: (value: string) => (value && (value.length === 46 || value.length === 40)) || '送金先アドレス(-除く)は40文字です。',
68
+
69
+ senderAddrInput: (value: string) => {
70
+
71
+ const pattern = /^[a-zA-Z0-9-]+$/
72
+
73
+ return pattern.test(value) || '送金先の入力が不正です'
74
+
75
+ },
76
+
77
+ amountLimit: (value:number) => (value >= 0) || '数量を入力してください',
78
+
79
+ amountInput: (value:string) => {
80
+
81
+ const pattern = /^[0-9.]+$/
82
+
83
+ return (pattern.test(value) && !isNaN(Number(value))) || '数字の入力が不正です'
84
+
85
+ },
86
+
87
+ messageRules: (value:string) => (value.length <= 1024) || 'メッセージの最大文字数が超えています。'
88
+
89
+ }
90
+
91
+ }),
92
+
93
+ methods: {
94
+
95
+ async onInit (promise: any) {
96
+
97
+ // show loading indicator
98
+
99
+ try {
100
+
101
+ await promise
102
+
103
+ // successfully initialized
104
+
105
+ } catch (error) {
106
+
107
+ if (error.name === 'NotAllowedError') {
108
+
109
+ // user denied camera access permisson
110
+
111
+ } else if (error.name === 'NotFoundError') {
112
+
113
+ // no suitable camera device installed
114
+
115
+ } else if (error.name === 'NotSupportedError') {
116
+
117
+ // page is not served over HTTPS (or localhost)
118
+
119
+ } else if (error.name === 'NotReadableError') {
120
+
121
+ // maybe camera is already in use
122
+
123
+ } else if (error.name === 'OverconstrainedError') {
124
+
125
+ // passed constraints don't match any camera. Did you requested the front camera although there is none?
126
+
127
+ } else {
128
+
129
+ // browser is probably lacking features (WebRTC, Canvas)
130
+
131
+ }
132
+
133
+ } finally {
134
+
135
+ // hide loading indicator
136
+
137
+ }
138
+
139
+ },
140
+
141
+ onDecode(content: any){
142
+
143
+ // とりあえず呼ばれているか確認
144
+
145
+ console.log(content)
146
+
147
+
148
+
149
+ //
150
+
151
+ if (content !== '') {
152
+
153
+ let qrJson = JSON.parse(content)
154
+
155
+ console.log(qrJson)
156
+
157
+ console.log(qrJson.data.msg)
158
+
159
+ this.sendMultisig(qrJson)
160
+
161
+ }
162
+
163
+ this.$router.push({name: "sendbutton"})
164
+
165
+ },
166
+
167
+ /**
168
+
169
+ * 今現在マルチシグ送金を行いたいがよくわからないので一つずつ処理できればと思う
170
+
171
+ * */
172
+
173
+ async sendMultisig(qrContent: any) {
174
+
175
+ // 公開鍵を調べる
176
+
177
+ const accountHttp = new AccountHttp('http://localhost:3000');
178
+
179
+ const address = Address.createFromRawAddress('SD5DT3-CH4BLA-BL5HIM-EKP2TA-PUKF4N-Y3L5HR-IR54');
180
+
181
+
182
+
183
+ accountHttp
184
+
185
+ .getAccountInfo(address)
186
+
187
+ .subscribe(accountInfo => console.log(accountInfo), err => console.error(err));
188
+
189
+
190
+
191
+ // テストとしてアカウントの作成が行われるか試す
192
+
193
+ // const account = Account.generateNewAccount(NetworkType.MIJIN_TEST);
194
+
195
+ // console.log('Your new account address is:', account.address.pretty(), 'and its private key', account.privateKey);
196
+
197
+ // 1個目
198
+
199
+ // Your new account address is: SC7B5U-GMABRU-QC24YU-ME4JAW-GZBNKF-4AO6WQ-77FW
200
+
201
+ // and its private key
202
+
203
+ // 46E0D6466801F9202A227F67E86B0E4A6CC616833E9E1FD6A16BD98DCB21A87D
204
+
205
+
206
+
207
+ // 2個目
208
+
209
+ // Your new account address is: SCLIPO-74NVXP-MNHT6O-EB6PXH-SFMX7S-EN5HB5-VWIZ
210
+
211
+ // and its private key
212
+
213
+ // 3329530DA473FF9F57FEBCF6DFC96996F0726BA2131AD7B184DA5BB0C966160D
214
+
215
+
216
+
217
+ // 3個目
218
+
219
+ // Your new account address is: SAGIBM-SJUL2J-IUBQU6-3LVZJY-K75QUI-N6XA3Z-2DIL
220
+
221
+ // and its private key
222
+
223
+ // 32DCAFD970C64BC73433E0E9094B90F2F910E9A7EC493C9ABB79B79DF363E906
224
+
225
+
226
+
227
+ // おそらくこの時点ではマルチシグに必要な変数定義のみが行われていると思う
228
+
229
+ // const transactionHttp = new TransactionHttp( 'http://localhost:3000');
230
+
231
+
232
+
233
+ // // 送信者の秘密鍵
234
+
235
+ // const cosignatoryPrivateKey = process.env.COSIGNATORY_1_PRIVATE_KEY as string;
236
+
237
+ // const cosignatoryAccount = Account.createFromPrivateKey(cosignatoryPrivateKey, NetworkType.MIJIN_TEST);
238
+
239
+
240
+
241
+ // // マルチシグアカウントのパブリックキー
242
+
243
+ // const multisigAccountPublicKey = process.env.MULTISIG_ACCOUNT_PUBLIC_KEY as string;
244
+
245
+ // const multisigAccount = PublicAccount.createFromPublicKey(multisigAccountPublicKey, NetworkType.MIJIN_TEST);
246
+
247
+
248
+
249
+ // // 受信者のアドレス
250
+
251
+ // const recipientAddress = Address.createFromRawAddress('SD5DT3-CH4BLA-BL5HIM-EKP2TA-PUKF4N-Y3L5HR-IR54');
252
+
253
+
254
+
255
+ // // 通常のトランザクションの作成
256
+
257
+ // const transferTransaction = TransferTransaction.create(
258
+
259
+ // Deadline.create(),
260
+
261
+ // recipientAddress,
262
+
263
+ // [NetworkCurrencyMosaic.createRelative(10)],
264
+
265
+ // PlainMessage.create('sending 10 cat.currency'),
266
+
267
+ // NetworkType.MIJIN_TEST);
268
+
269
+
270
+
271
+ // アグリゲートトランザクションの作成
272
+
273
+ // const aggregateTransaction = AggregateTransaction.createComplete(
274
+
275
+ // Deadline.create(),
276
+
277
+ // [transferTransaction.toAggregate(multisigAccount),],
278
+
279
+ // NetworkType.MIJIN_TEST,
280
+
281
+ // []);
282
+
283
+
284
+
285
+ // 多分これは連署者の署名の実装
286
+
287
+ // const networkGenerationHash = process.env.NETWORK_GENERATION_HASH as string;
288
+
289
+ // const signedTransaction = cosignatoryAccount.sign(networkGenerationHash);
290
+
291
+
292
+
293
+ //transactionHttp
294
+
295
+ //.announce(signedTransaction)
296
+
297
+ //.subscribe(x => console.log(x), err => console.error(err));
298
+
299
+ }
300
+
301
+ },
302
+
303
+ };
304
+
305
+ </script>
306
+
307
+
308
+
309
+ <style>
310
+
311
+ .qrReader {
312
+
313
+ position: absolute;
314
+
315
+ left: 0px;
316
+
317
+ right: 0px;
318
+
319
+ top: 0px;
320
+
321
+ bottom: 0px;
322
+
323
+ margin: auto;
324
+
325
+ width: 300px;/*幅*/
326
+
327
+ height: 300px;/*高さ*/
328
+
329
+ text-align: center;/*中央寄せ*/
330
+
331
+ transition: .3s;/*滑らかな動きに*/
332
+
333
+ }
334
+
335
+ </style>
336
+
337
+ ```