@arcblock/did-playground 2.13.69 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,636 +1,527 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getMessage = exports.getActionParams = exports.getActionName = exports.actions = void 0;
7
- var _mustache = _interopRequireDefault(require("mustache"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- async function createSwapOrder(api) {
10
- const res = await api.post('/api/did/swap', {});
11
- return {
12
- tid: res.data.traceId
13
- };
1
+ import _ from "mustache";
2
+ async function c(a) {
3
+ return { tid: (await a.post("/api/did/swap", {})).data.traceId };
14
4
  }
15
- const getValidPayAmount = (payAmount, price) => {
16
- if (Number(payAmount) >= 0) {
17
- return payAmount;
18
- }
19
- if (Number(price) >= 0) {
20
- return price;
21
- }
22
- return 1;
23
- };
24
- const getMessage = exports.getMessage = function getMessage() {
25
- let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
26
- let session = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5
+ const n = (a, e) => Number(a) >= 0 ? a : Number(e) >= 0 ? e : 1, t = (a = "", e = {}) => {
27
6
  try {
28
- return _mustache.default.render(message, {
29
- user: session.user || {},
30
- token: session.token || {},
31
- balance: session.balance || {}
32
- }, {}, ['(%', '%)']);
33
- } catch (err) {
34
- console.error('Cannot render message', {
35
- message,
36
- session
37
- });
38
- return message;
7
+ return _.render(
8
+ a,
9
+ {
10
+ user: e.user || {},
11
+ token: e.token || {},
12
+ balance: e.balance || {}
13
+ },
14
+ {},
15
+ ["(%", "%)"]
16
+ );
17
+ } catch {
18
+ return console.error("Cannot render message", { message: a, session: e }), a;
39
19
  }
40
- };
41
-
42
- // https://github.com/ArcBlock/gatsby-extensions/issues/56
43
- const actions = exports.actions = {
20
+ }, m = {
44
21
  // Currency
45
22
  receive_local_token: {
46
- action: 'receive_token',
47
- extraParams: props => ({
48
- chain: 'local',
49
- amount: props.amount || 1
50
- })
23
+ action: "receive_token",
24
+ extraParams: (a) => ({ chain: "local", amount: a.amount || 1 })
51
25
  },
52
26
  receive_foreign_token: {
53
- action: 'receive_token',
54
- extraParams: props => ({
55
- chain: 'foreign',
56
- amount: props.amount || 1
57
- })
27
+ action: "receive_token",
28
+ extraParams: (a) => ({ chain: "foreign", amount: a.amount || 1 })
58
29
  },
59
30
  send_local_token: {
60
- action: 'send_token',
61
- extraParams: props => ({
62
- chain: 'local',
63
- amount: props.amount || 1
64
- })
31
+ action: "send_token",
32
+ extraParams: (a) => ({ chain: "local", amount: a.amount || 1 })
65
33
  },
66
34
  send_foreign_token: {
67
- action: 'send_token',
68
- extraParams: props => ({
69
- chain: 'foreign',
70
- amount: props.amount || 1
71
- })
35
+ action: "send_token",
36
+ extraParams: (a) => ({ chain: "foreign", amount: a.amount || 1 })
72
37
  },
73
38
  exchange_to_foreign_token: {
74
- action: 'swap_token',
75
- onStart: createSwapOrder,
76
- extraParams: props => ({
77
- action: 'buy',
78
- rate: props.exchangeRate,
79
- amount: props.amount || 1
80
- })
39
+ action: "swap_token",
40
+ onStart: c,
41
+ extraParams: (a) => ({ action: "buy", rate: a.exchangeRate, amount: a.amount || 1 })
81
42
  },
82
43
  exchange_to_local_token: {
83
- action: 'swap_token',
84
- onStart: createSwapOrder,
85
- extraParams: props => ({
86
- action: 'sell',
87
- rate: props.exchangeRate,
88
- amount: props.amount || 1
89
- })
44
+ action: "swap_token",
45
+ onStart: c,
46
+ extraParams: (a) => ({ action: "sell", rate: a.exchangeRate, amount: a.amount || 1 })
90
47
  },
91
48
  exchange_to_foreign_token_v2: {
92
- action: 'swap_token_v2',
93
- onStart: createSwapOrder,
94
- extraParams: props => ({
95
- action: 'buy',
96
- rate: props.exchangeRate,
97
- amount: props.amount || 1
98
- })
49
+ action: "swap_token_v2",
50
+ onStart: c,
51
+ extraParams: (a) => ({ action: "buy", rate: a.exchangeRate, amount: a.amount || 1 })
99
52
  },
100
53
  exchange_to_local_token_v2: {
101
- action: 'swap_token_v2',
102
- onStart: createSwapOrder,
103
- extraParams: props => ({
104
- action: 'sell',
105
- rate: props.exchangeRate,
106
- amount: props.amount || 1
107
- })
54
+ action: "swap_token_v2",
55
+ onStart: c,
56
+ extraParams: (a) => ({ action: "sell", rate: a.exchangeRate, amount: a.amount || 1 })
108
57
  },
109
58
  // Cross chain assets and tokens
110
59
  buy_foreign_certificate_with_local_token: {
111
- action: 'swap_asset',
112
- onStart: createSwapOrder,
113
- extraParams: (props, session) => ({
114
- action: 'buy',
115
- type: 'certificate',
116
- pfc: 'local',
117
- price: props.price || 1,
118
- name: getMessage(props.name, session),
119
- desc: getMessage(props.description, session),
120
- loc: getMessage(props.location, session),
121
- bg: props.backgroundUrl,
122
- logo: props.logoUrl
60
+ action: "swap_asset",
61
+ onStart: c,
62
+ extraParams: (a, e) => ({
63
+ action: "buy",
64
+ type: "certificate",
65
+ pfc: "local",
66
+ price: a.price || 1,
67
+ name: t(a.name, e),
68
+ desc: t(a.description, e),
69
+ loc: t(a.location, e),
70
+ bg: a.backgroundUrl,
71
+ logo: a.logoUrl
123
72
  })
124
73
  },
125
74
  buy_foreign_badge_with_local_token: {
126
- action: 'swap_asset',
127
- onStart: createSwapOrder,
128
- extraParams: (props, session) => ({
129
- action: 'buy',
130
- type: 'badge',
131
- pfc: 'local',
132
- price: props.price || 1,
133
- name: getMessage(props.name, session),
134
- desc: getMessage(props.description, session),
135
- loc: getMessage(props.location, session),
136
- bg: props.backgroundUrl,
137
- logo: props.logoUrl,
138
- svg: props.svg
75
+ action: "swap_asset",
76
+ onStart: c,
77
+ extraParams: (a, e) => ({
78
+ action: "buy",
79
+ type: "badge",
80
+ pfc: "local",
81
+ price: a.price || 1,
82
+ name: t(a.name, e),
83
+ desc: t(a.description, e),
84
+ loc: t(a.location, e),
85
+ bg: a.backgroundUrl,
86
+ logo: a.logoUrl,
87
+ svg: a.svg
139
88
  })
140
89
  },
141
90
  buy_foreign_ticket_with_local_token: {
142
- action: 'swap_asset',
143
- onStart: createSwapOrder,
144
- extraParams: (props, session) => ({
145
- action: 'buy',
146
- type: 'ticket',
147
- pfc: 'local',
148
- price: props.price || 1,
149
- name: getMessage(props.name, session),
150
- desc: getMessage(props.description, session),
151
- loc: getMessage(props.location, session),
152
- bg: props.backgroundUrl,
153
- logo: props.logoUrl
91
+ action: "swap_asset",
92
+ onStart: c,
93
+ extraParams: (a, e) => ({
94
+ action: "buy",
95
+ type: "ticket",
96
+ pfc: "local",
97
+ price: a.price || 1,
98
+ name: t(a.name, e),
99
+ desc: t(a.description, e),
100
+ loc: t(a.location, e),
101
+ bg: a.backgroundUrl,
102
+ logo: a.logoUrl
154
103
  })
155
104
  },
156
105
  sell_foreign_certificate_for_local_token: {
157
- action: 'swap_asset',
158
- onStart: createSwapOrder,
159
- extraParams: (props, session) => ({
160
- action: 'sell',
161
- type: 'certificate',
162
- pfc: 'local',
163
- price: props.price || 1,
164
- name: getMessage(props.name, session)
106
+ action: "swap_asset",
107
+ onStart: c,
108
+ extraParams: (a, e) => ({
109
+ action: "sell",
110
+ type: "certificate",
111
+ pfc: "local",
112
+ price: a.price || 1,
113
+ name: t(a.name, e)
165
114
  })
166
115
  },
167
116
  sell_foreign_badge_for_local_token: {
168
- action: 'swap_asset',
169
- onStart: createSwapOrder,
170
- extraParams: (props, session) => ({
171
- action: 'sell',
172
- type: 'badge',
173
- pfc: 'local',
174
- price: props.price || 1,
175
- name: getMessage(props.name, session)
117
+ action: "swap_asset",
118
+ onStart: c,
119
+ extraParams: (a, e) => ({
120
+ action: "sell",
121
+ type: "badge",
122
+ pfc: "local",
123
+ price: a.price || 1,
124
+ name: t(a.name, e)
176
125
  })
177
126
  },
178
127
  sell_foreign_ticket_for_local_token: {
179
- action: 'swap_asset',
180
- onStart: createSwapOrder,
181
- extraParams: (props, session) => ({
182
- action: 'sell',
183
- type: 'ticket',
184
- pfc: 'local',
185
- price: props.price || 1,
186
- name: getMessage(props.name, session)
128
+ action: "swap_asset",
129
+ onStart: c,
130
+ extraParams: (a, e) => ({
131
+ action: "sell",
132
+ type: "ticket",
133
+ pfc: "local",
134
+ price: a.price || 1,
135
+ name: t(a.name, e)
187
136
  })
188
137
  },
189
138
  buy_foreign_certificate_with_local_token_v2: {
190
- action: 'swap_asset_v2',
191
- extraParams: (props, session) => ({
192
- action: 'buy',
193
- type: 'certificate',
194
- pfc: 'local',
195
- price: props.price || 1,
196
- name: getMessage(props.name, session),
197
- desc: getMessage(props.description, session),
198
- loc: getMessage(props.location, session),
199
- bg: props.backgroundUrl,
200
- logo: props.logoUrl
139
+ action: "swap_asset_v2",
140
+ extraParams: (a, e) => ({
141
+ action: "buy",
142
+ type: "certificate",
143
+ pfc: "local",
144
+ price: a.price || 1,
145
+ name: t(a.name, e),
146
+ desc: t(a.description, e),
147
+ loc: t(a.location, e),
148
+ bg: a.backgroundUrl,
149
+ logo: a.logoUrl
201
150
  })
202
151
  },
203
152
  buy_foreign_badge_with_local_token_v2: {
204
- action: 'swap_asset_v2',
205
- extraParams: (props, session) => ({
206
- action: 'buy',
207
- type: 'badge',
208
- pfc: 'local',
209
- price: props.price || 1,
210
- name: getMessage(props.name, session),
211
- desc: getMessage(props.description, session),
212
- loc: getMessage(props.location, session),
213
- bg: props.backgroundUrl,
214
- logo: props.logoUrl,
215
- svg: props.svg
153
+ action: "swap_asset_v2",
154
+ extraParams: (a, e) => ({
155
+ action: "buy",
156
+ type: "badge",
157
+ pfc: "local",
158
+ price: a.price || 1,
159
+ name: t(a.name, e),
160
+ desc: t(a.description, e),
161
+ loc: t(a.location, e),
162
+ bg: a.backgroundUrl,
163
+ logo: a.logoUrl,
164
+ svg: a.svg
216
165
  })
217
166
  },
218
167
  buy_foreign_ticket_with_local_token_v2: {
219
- action: 'swap_asset_v2',
220
- extraParams: (props, session) => ({
221
- action: 'buy',
222
- type: 'ticket',
223
- pfc: 'local',
224
- price: props.price || 1,
225
- name: getMessage(props.name, session),
226
- desc: getMessage(props.description, session),
227
- loc: getMessage(props.location, session),
228
- bg: props.backgroundUrl,
229
- logo: props.logoUrl
168
+ action: "swap_asset_v2",
169
+ extraParams: (a, e) => ({
170
+ action: "buy",
171
+ type: "ticket",
172
+ pfc: "local",
173
+ price: a.price || 1,
174
+ name: t(a.name, e),
175
+ desc: t(a.description, e),
176
+ loc: t(a.location, e),
177
+ bg: a.backgroundUrl,
178
+ logo: a.logoUrl
230
179
  })
231
180
  },
232
181
  sell_foreign_certificate_for_local_token_v2: {
233
- action: 'swap_asset_v2',
234
- extraParams: (props, session) => ({
235
- action: 'sell',
236
- type: 'certificate',
237
- pfc: 'local',
238
- price: props.price || 1,
239
- name: getMessage(props.name, session)
182
+ action: "swap_asset_v2",
183
+ extraParams: (a, e) => ({
184
+ action: "sell",
185
+ type: "certificate",
186
+ pfc: "local",
187
+ price: a.price || 1,
188
+ name: t(a.name, e)
240
189
  })
241
190
  },
242
191
  sell_foreign_badge_for_local_token_v2: {
243
- action: 'swap_asset_v2',
244
- extraParams: (props, session) => ({
245
- action: 'sell',
246
- type: 'badge',
247
- pfc: 'local',
248
- price: props.price || 1,
249
- name: getMessage(props.name, session)
192
+ action: "swap_asset_v2",
193
+ extraParams: (a, e) => ({
194
+ action: "sell",
195
+ type: "badge",
196
+ pfc: "local",
197
+ price: a.price || 1,
198
+ name: t(a.name, e)
250
199
  })
251
200
  },
252
201
  sell_foreign_ticket_for_local_token_v2: {
253
- action: 'swap_asset_v2',
254
- extraParams: (props, session) => ({
255
- action: 'sell',
256
- type: 'ticket',
257
- pfc: 'local',
258
- price: props.price || 1,
259
- name: getMessage(props.name, session)
202
+ action: "swap_asset_v2",
203
+ extraParams: (a, e) => ({
204
+ action: "sell",
205
+ type: "ticket",
206
+ pfc: "local",
207
+ price: a.price || 1,
208
+ name: t(a.name, e)
260
209
  })
261
210
  },
262
211
  buy_local_certificate_with_foreign_token: {
263
- action: 'swap_asset',
264
- onStart: createSwapOrder,
265
- extraParams: (props, session) => ({
266
- action: 'buy',
267
- type: 'certificate',
268
- pfc: 'foreign',
269
- price: props.price || 1,
270
- name: getMessage(props.name, session),
271
- desc: getMessage(props.description, session),
272
- loc: getMessage(props.location, session),
273
- bg: props.backgroundUrl,
274
- logo: props.logoUrl
212
+ action: "swap_asset",
213
+ onStart: c,
214
+ extraParams: (a, e) => ({
215
+ action: "buy",
216
+ type: "certificate",
217
+ pfc: "foreign",
218
+ price: a.price || 1,
219
+ name: t(a.name, e),
220
+ desc: t(a.description, e),
221
+ loc: t(a.location, e),
222
+ bg: a.backgroundUrl,
223
+ logo: a.logoUrl
275
224
  })
276
225
  },
277
226
  buy_local_badge_with_foreign_token: {
278
- action: 'swap_asset',
279
- onStart: createSwapOrder,
280
- extraParams: (props, session) => ({
281
- action: 'buy',
282
- type: 'badge',
283
- pfc: 'foreign',
284
- price: props.price || 0,
285
- name: getMessage(props.name, session),
286
- desc: getMessage(props.description, session),
287
- loc: getMessage(props.location, session),
288
- bg: props.backgroundUrl,
289
- logo: props.logoUrl,
290
- svg: props.svg
227
+ action: "swap_asset",
228
+ onStart: c,
229
+ extraParams: (a, e) => ({
230
+ action: "buy",
231
+ type: "badge",
232
+ pfc: "foreign",
233
+ price: a.price || 0,
234
+ name: t(a.name, e),
235
+ desc: t(a.description, e),
236
+ loc: t(a.location, e),
237
+ bg: a.backgroundUrl,
238
+ logo: a.logoUrl,
239
+ svg: a.svg
291
240
  })
292
241
  },
293
242
  buy_local_ticket_with_foreign_token: {
294
- action: 'swap_asset',
295
- onStart: createSwapOrder,
296
- extraParams: (props, session) => ({
297
- action: 'buy',
298
- type: 'ticket',
299
- pfc: 'foreign',
300
- price: props.price || 1,
301
- name: getMessage(props.name, session),
302
- desc: getMessage(props.description, session),
303
- loc: getMessage(props.location, session),
304
- bg: props.backgroundUrl,
305
- logo: props.logoUrl
243
+ action: "swap_asset",
244
+ onStart: c,
245
+ extraParams: (a, e) => ({
246
+ action: "buy",
247
+ type: "ticket",
248
+ pfc: "foreign",
249
+ price: a.price || 1,
250
+ name: t(a.name, e),
251
+ desc: t(a.description, e),
252
+ loc: t(a.location, e),
253
+ bg: a.backgroundUrl,
254
+ logo: a.logoUrl
306
255
  })
307
256
  },
308
257
  sell_local_certificate_for_foreign_token: {
309
- action: 'swap_asset',
310
- onStart: createSwapOrder,
311
- extraParams: (props, session) => ({
312
- action: 'sell',
313
- type: 'certificate',
314
- pfc: 'foreign',
315
- price: props.price || 1,
316
- name: getMessage(props.name, session)
258
+ action: "swap_asset",
259
+ onStart: c,
260
+ extraParams: (a, e) => ({
261
+ action: "sell",
262
+ type: "certificate",
263
+ pfc: "foreign",
264
+ price: a.price || 1,
265
+ name: t(a.name, e)
317
266
  })
318
267
  },
319
268
  sell_local_badge_for_foreign_token: {
320
- action: 'swap_asset',
321
- onStart: createSwapOrder,
322
- extraParams: (props, session) => ({
323
- action: 'sell',
324
- type: 'vc',
325
- pfc: 'foreign',
326
- price: props.price || 1,
327
- name: getMessage(props.name, session)
269
+ action: "swap_asset",
270
+ onStart: c,
271
+ extraParams: (a, e) => ({
272
+ action: "sell",
273
+ type: "vc",
274
+ pfc: "foreign",
275
+ price: a.price || 1,
276
+ name: t(a.name, e)
328
277
  })
329
278
  },
330
279
  sell_local_ticket_for_foreign_token: {
331
- action: 'swap_asset',
332
- onStart: createSwapOrder,
333
- extraParams: (props, session) => ({
334
- action: 'sell',
335
- type: 'ticket',
336
- pfc: 'foreign',
337
- price: props.price || 1,
338
- name: getMessage(props.name, session)
280
+ action: "swap_asset",
281
+ onStart: c,
282
+ extraParams: (a, e) => ({
283
+ action: "sell",
284
+ type: "ticket",
285
+ pfc: "foreign",
286
+ price: a.price || 1,
287
+ name: t(a.name, e)
339
288
  })
340
289
  },
341
290
  buy_local_certificate_with_foreign_token_v2: {
342
- action: 'swap_asset_v2',
343
- extraParams: (props, session) => ({
344
- pa: getValidPayAmount(props.payAmount, props.price),
345
- pt: 'token',
346
- ra: props.receiveAmount || 1,
347
- rt: 'certificate',
348
- name: getMessage(props.name, session),
349
- desc: getMessage(props.description, session),
350
- loc: getMessage(props.location, session),
351
- bg: props.backgroundUrl,
352
- logo: props.logoUrl
291
+ action: "swap_asset_v2",
292
+ extraParams: (a, e) => ({
293
+ pa: n(a.payAmount, a.price),
294
+ pt: "token",
295
+ ra: a.receiveAmount || 1,
296
+ rt: "certificate",
297
+ name: t(a.name, e),
298
+ desc: t(a.description, e),
299
+ loc: t(a.location, e),
300
+ bg: a.backgroundUrl,
301
+ logo: a.logoUrl
353
302
  })
354
303
  },
355
304
  buy_local_badge_with_foreign_token_v2: {
356
- action: 'swap_asset_v2',
357
- extraParams: (props, session) => ({
358
- pa: getValidPayAmount(props.payAmount, props.price),
359
- pt: 'token',
360
- ra: props.receiveAmount || 1,
361
- rt: 'badge',
362
- name: getMessage(props.name, session),
363
- desc: getMessage(props.description, session),
364
- loc: getMessage(props.location, session),
365
- bg: props.backgroundUrl,
366
- logo: props.logoUrl,
367
- svg: props.svg
305
+ action: "swap_asset_v2",
306
+ extraParams: (a, e) => ({
307
+ pa: n(a.payAmount, a.price),
308
+ pt: "token",
309
+ ra: a.receiveAmount || 1,
310
+ rt: "badge",
311
+ name: t(a.name, e),
312
+ desc: t(a.description, e),
313
+ loc: t(a.location, e),
314
+ bg: a.backgroundUrl,
315
+ logo: a.logoUrl,
316
+ svg: a.svg
368
317
  })
369
318
  },
370
319
  buy_local_ticket_with_foreign_token_v2: {
371
- action: 'swap_asset_v2',
372
- extraParams: (props, session) => ({
373
- pa: getValidPayAmount(props.payAmount, props.price),
374
- pt: 'token',
375
- ra: props.receiveAmount || 1,
376
- rt: 'badge',
377
- name: getMessage(props.name, session),
378
- desc: getMessage(props.description, session),
379
- loc: getMessage(props.location, session),
380
- bg: props.backgroundUrl,
381
- logo: props.logoUrl
320
+ action: "swap_asset_v2",
321
+ extraParams: (a, e) => ({
322
+ pa: n(a.payAmount, a.price),
323
+ pt: "token",
324
+ ra: a.receiveAmount || 1,
325
+ rt: "badge",
326
+ name: t(a.name, e),
327
+ desc: t(a.description, e),
328
+ loc: t(a.location, e),
329
+ bg: a.backgroundUrl,
330
+ logo: a.logoUrl
382
331
  })
383
332
  },
384
333
  sell_local_certificate_for_foreign_token_v2: {
385
- action: 'swap_asset_v2',
386
- extraParams: (props, session) => ({
387
- pa: props.payAmount || 1,
388
- pt: 'certificate',
389
- ra: getValidPayAmount(props.receiveAmount, props.price),
390
- rt: 'token',
391
- name: getMessage(props.name, session)
334
+ action: "swap_asset_v2",
335
+ extraParams: (a, e) => ({
336
+ pa: a.payAmount || 1,
337
+ pt: "certificate",
338
+ ra: n(a.receiveAmount, a.price),
339
+ rt: "token",
340
+ name: t(a.name, e)
392
341
  })
393
342
  },
394
343
  sell_local_badge_for_foreign_token_v2: {
395
- action: 'swap_asset_v2',
396
- extraParams: (props, session) => ({
397
- pa: props.payAmount || 1,
398
- pt: 'badge',
399
- ra: getValidPayAmount(props.receiveAmount, props.price),
400
- rt: 'token',
401
- name: getMessage(props.name, session)
344
+ action: "swap_asset_v2",
345
+ extraParams: (a, e) => ({
346
+ pa: a.payAmount || 1,
347
+ pt: "badge",
348
+ ra: n(a.receiveAmount, a.price),
349
+ rt: "token",
350
+ name: t(a.name, e)
402
351
  })
403
352
  },
404
353
  sell_local_ticket_for_foreign_token_v2: {
405
- action: 'swap_asset_v2',
406
- extraParams: (props, session) => ({
407
- pa: props.payAmount || 1,
408
- pt: 'ticket',
409
- ra: getValidPayAmount(props.receiveAmount, props.price),
410
- rt: 'token',
411
- name: getMessage(props.name, session)
354
+ action: "swap_asset_v2",
355
+ extraParams: (a, e) => ({
356
+ pa: a.payAmount || 1,
357
+ pt: "ticket",
358
+ ra: n(a.receiveAmount, a.price),
359
+ rt: "token",
360
+ name: t(a.name, e)
412
361
  })
413
362
  },
414
363
  // Exchange Scenarios
415
364
  buy_local_certificate_with_local_token: {
416
- action: 'exchange_assets',
417
- extraParams: (props, session) => ({
418
- pa: getValidPayAmount(props.payAmount, props.price),
419
- pt: 'token',
420
- ra: props.receiveAmount || 1,
421
- rt: 'certificate',
422
- name: getMessage(props.name, session),
423
- desc: getMessage(props.description, session),
424
- loc: getMessage(props.location, session),
425
- bg: props.backgroundUrl,
426
- logo: props.logoUrl
365
+ action: "exchange_assets",
366
+ extraParams: (a, e) => ({
367
+ pa: n(a.payAmount, a.price),
368
+ pt: "token",
369
+ ra: a.receiveAmount || 1,
370
+ rt: "certificate",
371
+ name: t(a.name, e),
372
+ desc: t(a.description, e),
373
+ loc: t(a.location, e),
374
+ bg: a.backgroundUrl,
375
+ logo: a.logoUrl
427
376
  })
428
377
  },
429
378
  sell_local_certificate_for_local_token: {
430
- action: 'exchange_assets',
431
- extraParams: (props, session) => ({
432
- pa: props.payAmount || 1,
433
- pt: 'certificate',
434
- ra: getValidPayAmount(props.receiveAmount, props.price),
435
- rt: 'token',
436
- name: getMessage(props.name, session)
379
+ action: "exchange_assets",
380
+ extraParams: (a, e) => ({
381
+ pa: a.payAmount || 1,
382
+ pt: "certificate",
383
+ ra: n(a.receiveAmount, a.price),
384
+ rt: "token",
385
+ name: t(a.name, e)
437
386
  })
438
387
  },
439
388
  buy_local_badge_with_local_token: {
440
- action: 'exchange_assets',
441
- extraParams: (props, session) => ({
442
- pa: getValidPayAmount(props.payAmount, props.price),
443
- pt: 'token',
444
- ra: props.receiveAmount || 1,
445
- rt: 'badge',
446
- name: getMessage(props.name, session),
447
- desc: getMessage(props.description, session),
448
- loc: getMessage(props.location, session),
449
- bg: props.backgroundUrl,
450
- logo: props.logoUrl,
451
- svg: props.svg
389
+ action: "exchange_assets",
390
+ extraParams: (a, e) => ({
391
+ pa: n(a.payAmount, a.price),
392
+ pt: "token",
393
+ ra: a.receiveAmount || 1,
394
+ rt: "badge",
395
+ name: t(a.name, e),
396
+ desc: t(a.description, e),
397
+ loc: t(a.location, e),
398
+ bg: a.backgroundUrl,
399
+ logo: a.logoUrl,
400
+ svg: a.svg
452
401
  })
453
402
  },
454
403
  sell_local_badge_for_local_token: {
455
- action: 'exchange_assets',
456
- extraParams: (props, session) => ({
457
- pa: props.payAmount || 1,
458
- pt: 'badge',
459
- ra: getValidPayAmount(props.receiveAmount, props.price),
460
- rt: 'token',
461
- name: getMessage(props.name, session)
404
+ action: "exchange_assets",
405
+ extraParams: (a, e) => ({
406
+ pa: a.payAmount || 1,
407
+ pt: "badge",
408
+ ra: n(a.receiveAmount, a.price),
409
+ rt: "token",
410
+ name: t(a.name, e)
462
411
  })
463
412
  },
464
413
  buy_local_ticket_with_local_token: {
465
- action: 'exchange_assets',
466
- extraParams: (props, session) => ({
467
- pa: getValidPayAmount(props.payAmount, props.price),
468
- pt: 'token',
469
- ra: props.receiveAmount || 1,
470
- rt: 'ticket',
471
- name: getMessage(props.name, session),
472
- desc: getMessage(props.description, session),
473
- loc: getMessage(props.location, session),
474
- bg: props.backgroundUrl,
475
- logo: props.logoUrl
414
+ action: "exchange_assets",
415
+ extraParams: (a, e) => ({
416
+ pa: n(a.payAmount, a.price),
417
+ pt: "token",
418
+ ra: a.receiveAmount || 1,
419
+ rt: "ticket",
420
+ name: t(a.name, e),
421
+ desc: t(a.description, e),
422
+ loc: t(a.location, e),
423
+ bg: a.backgroundUrl,
424
+ logo: a.logoUrl
476
425
  })
477
426
  },
478
427
  sell_local_ticket_for_local_token: {
479
- action: 'exchange_assets',
480
- extraParams: (props, session) => ({
481
- pa: props.payAmount || 1,
482
- pt: 'ticket',
483
- ra: getValidPayAmount(props.receiveAmount, props.price),
484
- rt: 'token',
485
- name: getMessage(props.name, session)
428
+ action: "exchange_assets",
429
+ extraParams: (a, e) => ({
430
+ pa: a.payAmount || 1,
431
+ pt: "ticket",
432
+ ra: n(a.receiveAmount, a.price),
433
+ rt: "token",
434
+ name: t(a.name, e)
486
435
  })
487
436
  },
488
437
  buy_local_ticket_with_local_certificate: {
489
- action: 'exchange_assets',
490
- extraParams: (props, session) => ({
491
- pa: props.payAmount || 1,
492
- pt: 'certificate',
493
- ra: props.receiveAmount || 1,
494
- rt: 'ticket',
495
- name: getMessage(props.name, session)
438
+ action: "exchange_assets",
439
+ extraParams: (a, e) => ({
440
+ pa: a.payAmount || 1,
441
+ pt: "certificate",
442
+ ra: a.receiveAmount || 1,
443
+ rt: "ticket",
444
+ name: t(a.name, e)
496
445
  })
497
446
  },
498
447
  buy_local_certificate_with_local_ticket: {
499
- action: 'exchange_assets',
500
- extraParams: (props, session) => ({
501
- pa: props.payAmount || 1,
502
- pt: 'ticket',
503
- ra: props.receiveAmount || 1,
504
- rt: 'certificate',
505
- name: getMessage(props.name, session)
448
+ action: "exchange_assets",
449
+ extraParams: (a, e) => ({
450
+ pa: a.payAmount || 1,
451
+ pt: "ticket",
452
+ ra: a.receiveAmount || 1,
453
+ rt: "certificate",
454
+ name: t(a.name, e)
506
455
  })
507
456
  },
508
457
  consume_local_asset: {
509
- action: 'consume_asset',
510
- extraParams: (_ref, session) => {
511
- let {
512
- type,
513
- typeUrl,
514
- name,
515
- did
516
- } = _ref;
517
- return {
518
- pfc: 'local',
519
- type,
520
- tu: typeUrl,
521
- name: getMessage(name, session),
522
- did
523
- };
524
- }
458
+ action: "consume_asset",
459
+ extraParams: ({ type: a, typeUrl: e, name: o, did: i }, r) => ({
460
+ pfc: "local",
461
+ type: a,
462
+ tu: e,
463
+ name: t(o, r),
464
+ did: i
465
+ })
525
466
  },
526
467
  consume_foreign_asset: {
527
- action: 'consume_asset',
528
- extraParams: (_ref2, session) => {
529
- let {
530
- type,
531
- typeUrl,
532
- name,
533
- did
534
- } = _ref2;
535
- return {
536
- pfc: 'foreign',
537
- type,
538
- tu: typeUrl,
539
- name: getMessage(name, session),
540
- did
541
- };
542
- }
468
+ action: "consume_asset",
469
+ extraParams: ({ type: a, typeUrl: e, name: o, did: i }, r) => ({
470
+ pfc: "foreign",
471
+ type: a,
472
+ tu: e,
473
+ name: t(o, r),
474
+ did: i
475
+ })
543
476
  },
544
477
  consume_local_asset_by_name: {
545
- action: 'consume_asset',
546
- extraParams: (_ref3, session) => {
547
- let {
548
- name
549
- } = _ref3;
550
- return {
551
- pfc: 'local',
552
- name: getMessage(name, session)
553
- };
554
- }
478
+ action: "consume_asset",
479
+ extraParams: ({ name: a }, e) => ({
480
+ pfc: "local",
481
+ name: t(a, e)
482
+ })
555
483
  },
556
484
  consume_foreign_asset_by_name: {
557
- action: 'consume_asset',
558
- extraParams: (_ref4, session) => {
559
- let {
560
- name
561
- } = _ref4;
562
- return {
563
- pfc: 'foreign',
564
- name: getMessage(name, session)
565
- };
566
- }
485
+ action: "consume_asset",
486
+ extraParams: ({ name: a }, e) => ({
487
+ pfc: "foreign",
488
+ name: t(a, e)
489
+ })
567
490
  },
568
491
  consume_local_asset_by_did: {
569
- action: 'consume_asset',
570
- extraParams: _ref5 => {
571
- let {
572
- did
573
- } = _ref5;
574
- return {
575
- pfc: 'local',
576
- did
577
- };
578
- }
492
+ action: "consume_asset",
493
+ extraParams: ({ did: a }) => ({
494
+ pfc: "local",
495
+ did: a
496
+ })
579
497
  },
580
498
  consume_foreign_asset_by_did: {
581
- action: 'consume_asset',
582
- extraParams: _ref6 => {
583
- let {
584
- did
585
- } = _ref6;
586
- return {
587
- pfc: 'foreign',
588
- did
589
- };
590
- }
499
+ action: "consume_asset",
500
+ extraParams: ({ did: a }) => ({
501
+ pfc: "foreign",
502
+ did: a
503
+ })
591
504
  },
592
505
  claim_signature: {
593
- action: 'claim_signature',
594
- extraParams: _ref7 => {
595
- let {
596
- type
597
- } = _ref7;
598
- return {
599
- type
600
- };
601
- }
506
+ action: "claim_signature",
507
+ extraParams: ({ type: a }) => ({ type: a })
602
508
  },
603
509
  consume_email_vc: {
604
- action: 'consume_vc',
510
+ action: "consume_vc",
605
511
  extraParams: {}
606
512
  }
513
+ }, g = (a, e) => {
514
+ if (typeof a == "string")
515
+ return a;
516
+ if (typeof a.action == "string")
517
+ return a.action;
518
+ if (typeof a.action == "function")
519
+ return a.action(e);
520
+ throw new Error("Cannot determine playground button action");
521
+ }, u = (a, e, o) => typeof a == "string" ? {} : a.extraParams ? typeof a.extraParams == "function" ? a.extraParams(e, o) : typeof a.extraParams == "object" ? a.extraParams : {} : {};
522
+ export {
523
+ m as actions,
524
+ g as getActionName,
525
+ u as getActionParams,
526
+ t as getMessage
607
527
  };
608
- const getActionName = (config, props) => {
609
- if (typeof config === 'string') {
610
- return config;
611
- }
612
- if (typeof config.action === 'string') {
613
- return config.action;
614
- }
615
- if (typeof config.action === 'function') {
616
- return config.action(props);
617
- }
618
- throw new Error('Cannot determine playground button action');
619
- };
620
- exports.getActionName = getActionName;
621
- const getActionParams = (config, props, session) => {
622
- if (typeof config === 'string') {
623
- return {};
624
- }
625
- if (!config.extraParams) {
626
- return {};
627
- }
628
- if (typeof config.extraParams === 'function') {
629
- return config.extraParams(props, session);
630
- }
631
- if (typeof config.extraParams === 'object') {
632
- return config.extraParams;
633
- }
634
- return {};
635
- };
636
- exports.getActionParams = getActionParams;