@arcblock/did-playground 2.13.70 → 3.0.1
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.
- package/lib/Action/actions.js +391 -500
- package/lib/Action/index.js +192 -261
- package/lib/Action/session.js +8 -17
- package/lib/index.js +8 -32
- package/package.json +13 -20
- package/src/Action/{index.js → index.jsx} +51 -24
- package/vite.config.mjs +29 -0
- /package/src/Action/{actions.js → actions.jsx} +0 -0
- /package/src/Action/{session.js → session.jsx} +0 -0
package/lib/Action/actions.js
CHANGED
|
@@ -1,636 +1,527 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
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
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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:
|
|
47
|
-
extraParams:
|
|
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:
|
|
54
|
-
extraParams:
|
|
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:
|
|
61
|
-
extraParams:
|
|
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:
|
|
68
|
-
extraParams:
|
|
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:
|
|
75
|
-
onStart:
|
|
76
|
-
extraParams:
|
|
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:
|
|
84
|
-
onStart:
|
|
85
|
-
extraParams:
|
|
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:
|
|
93
|
-
onStart:
|
|
94
|
-
extraParams:
|
|
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:
|
|
102
|
-
onStart:
|
|
103
|
-
extraParams:
|
|
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:
|
|
112
|
-
onStart:
|
|
113
|
-
extraParams: (
|
|
114
|
-
action:
|
|
115
|
-
type:
|
|
116
|
-
pfc:
|
|
117
|
-
price:
|
|
118
|
-
name:
|
|
119
|
-
desc:
|
|
120
|
-
loc:
|
|
121
|
-
bg:
|
|
122
|
-
logo:
|
|
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:
|
|
127
|
-
onStart:
|
|
128
|
-
extraParams: (
|
|
129
|
-
action:
|
|
130
|
-
type:
|
|
131
|
-
pfc:
|
|
132
|
-
price:
|
|
133
|
-
name:
|
|
134
|
-
desc:
|
|
135
|
-
loc:
|
|
136
|
-
bg:
|
|
137
|
-
logo:
|
|
138
|
-
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:
|
|
143
|
-
onStart:
|
|
144
|
-
extraParams: (
|
|
145
|
-
action:
|
|
146
|
-
type:
|
|
147
|
-
pfc:
|
|
148
|
-
price:
|
|
149
|
-
name:
|
|
150
|
-
desc:
|
|
151
|
-
loc:
|
|
152
|
-
bg:
|
|
153
|
-
logo:
|
|
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:
|
|
158
|
-
onStart:
|
|
159
|
-
extraParams: (
|
|
160
|
-
action:
|
|
161
|
-
type:
|
|
162
|
-
pfc:
|
|
163
|
-
price:
|
|
164
|
-
name:
|
|
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:
|
|
169
|
-
onStart:
|
|
170
|
-
extraParams: (
|
|
171
|
-
action:
|
|
172
|
-
type:
|
|
173
|
-
pfc:
|
|
174
|
-
price:
|
|
175
|
-
name:
|
|
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:
|
|
180
|
-
onStart:
|
|
181
|
-
extraParams: (
|
|
182
|
-
action:
|
|
183
|
-
type:
|
|
184
|
-
pfc:
|
|
185
|
-
price:
|
|
186
|
-
name:
|
|
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:
|
|
191
|
-
extraParams: (
|
|
192
|
-
action:
|
|
193
|
-
type:
|
|
194
|
-
pfc:
|
|
195
|
-
price:
|
|
196
|
-
name:
|
|
197
|
-
desc:
|
|
198
|
-
loc:
|
|
199
|
-
bg:
|
|
200
|
-
logo:
|
|
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:
|
|
205
|
-
extraParams: (
|
|
206
|
-
action:
|
|
207
|
-
type:
|
|
208
|
-
pfc:
|
|
209
|
-
price:
|
|
210
|
-
name:
|
|
211
|
-
desc:
|
|
212
|
-
loc:
|
|
213
|
-
bg:
|
|
214
|
-
logo:
|
|
215
|
-
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:
|
|
220
|
-
extraParams: (
|
|
221
|
-
action:
|
|
222
|
-
type:
|
|
223
|
-
pfc:
|
|
224
|
-
price:
|
|
225
|
-
name:
|
|
226
|
-
desc:
|
|
227
|
-
loc:
|
|
228
|
-
bg:
|
|
229
|
-
logo:
|
|
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:
|
|
234
|
-
extraParams: (
|
|
235
|
-
action:
|
|
236
|
-
type:
|
|
237
|
-
pfc:
|
|
238
|
-
price:
|
|
239
|
-
name:
|
|
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:
|
|
244
|
-
extraParams: (
|
|
245
|
-
action:
|
|
246
|
-
type:
|
|
247
|
-
pfc:
|
|
248
|
-
price:
|
|
249
|
-
name:
|
|
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:
|
|
254
|
-
extraParams: (
|
|
255
|
-
action:
|
|
256
|
-
type:
|
|
257
|
-
pfc:
|
|
258
|
-
price:
|
|
259
|
-
name:
|
|
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:
|
|
264
|
-
onStart:
|
|
265
|
-
extraParams: (
|
|
266
|
-
action:
|
|
267
|
-
type:
|
|
268
|
-
pfc:
|
|
269
|
-
price:
|
|
270
|
-
name:
|
|
271
|
-
desc:
|
|
272
|
-
loc:
|
|
273
|
-
bg:
|
|
274
|
-
logo:
|
|
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:
|
|
279
|
-
onStart:
|
|
280
|
-
extraParams: (
|
|
281
|
-
action:
|
|
282
|
-
type:
|
|
283
|
-
pfc:
|
|
284
|
-
price:
|
|
285
|
-
name:
|
|
286
|
-
desc:
|
|
287
|
-
loc:
|
|
288
|
-
bg:
|
|
289
|
-
logo:
|
|
290
|
-
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:
|
|
295
|
-
onStart:
|
|
296
|
-
extraParams: (
|
|
297
|
-
action:
|
|
298
|
-
type:
|
|
299
|
-
pfc:
|
|
300
|
-
price:
|
|
301
|
-
name:
|
|
302
|
-
desc:
|
|
303
|
-
loc:
|
|
304
|
-
bg:
|
|
305
|
-
logo:
|
|
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:
|
|
310
|
-
onStart:
|
|
311
|
-
extraParams: (
|
|
312
|
-
action:
|
|
313
|
-
type:
|
|
314
|
-
pfc:
|
|
315
|
-
price:
|
|
316
|
-
name:
|
|
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:
|
|
321
|
-
onStart:
|
|
322
|
-
extraParams: (
|
|
323
|
-
action:
|
|
324
|
-
type:
|
|
325
|
-
pfc:
|
|
326
|
-
price:
|
|
327
|
-
name:
|
|
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:
|
|
332
|
-
onStart:
|
|
333
|
-
extraParams: (
|
|
334
|
-
action:
|
|
335
|
-
type:
|
|
336
|
-
pfc:
|
|
337
|
-
price:
|
|
338
|
-
name:
|
|
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:
|
|
343
|
-
extraParams: (
|
|
344
|
-
pa:
|
|
345
|
-
pt:
|
|
346
|
-
ra:
|
|
347
|
-
rt:
|
|
348
|
-
name:
|
|
349
|
-
desc:
|
|
350
|
-
loc:
|
|
351
|
-
bg:
|
|
352
|
-
logo:
|
|
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:
|
|
357
|
-
extraParams: (
|
|
358
|
-
pa:
|
|
359
|
-
pt:
|
|
360
|
-
ra:
|
|
361
|
-
rt:
|
|
362
|
-
name:
|
|
363
|
-
desc:
|
|
364
|
-
loc:
|
|
365
|
-
bg:
|
|
366
|
-
logo:
|
|
367
|
-
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:
|
|
372
|
-
extraParams: (
|
|
373
|
-
pa:
|
|
374
|
-
pt:
|
|
375
|
-
ra:
|
|
376
|
-
rt:
|
|
377
|
-
name:
|
|
378
|
-
desc:
|
|
379
|
-
loc:
|
|
380
|
-
bg:
|
|
381
|
-
logo:
|
|
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:
|
|
386
|
-
extraParams: (
|
|
387
|
-
pa:
|
|
388
|
-
pt:
|
|
389
|
-
ra:
|
|
390
|
-
rt:
|
|
391
|
-
name:
|
|
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:
|
|
396
|
-
extraParams: (
|
|
397
|
-
pa:
|
|
398
|
-
pt:
|
|
399
|
-
ra:
|
|
400
|
-
rt:
|
|
401
|
-
name:
|
|
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:
|
|
406
|
-
extraParams: (
|
|
407
|
-
pa:
|
|
408
|
-
pt:
|
|
409
|
-
ra:
|
|
410
|
-
rt:
|
|
411
|
-
name:
|
|
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:
|
|
417
|
-
extraParams: (
|
|
418
|
-
pa:
|
|
419
|
-
pt:
|
|
420
|
-
ra:
|
|
421
|
-
rt:
|
|
422
|
-
name:
|
|
423
|
-
desc:
|
|
424
|
-
loc:
|
|
425
|
-
bg:
|
|
426
|
-
logo:
|
|
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:
|
|
431
|
-
extraParams: (
|
|
432
|
-
pa:
|
|
433
|
-
pt:
|
|
434
|
-
ra:
|
|
435
|
-
rt:
|
|
436
|
-
name:
|
|
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:
|
|
441
|
-
extraParams: (
|
|
442
|
-
pa:
|
|
443
|
-
pt:
|
|
444
|
-
ra:
|
|
445
|
-
rt:
|
|
446
|
-
name:
|
|
447
|
-
desc:
|
|
448
|
-
loc:
|
|
449
|
-
bg:
|
|
450
|
-
logo:
|
|
451
|
-
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:
|
|
456
|
-
extraParams: (
|
|
457
|
-
pa:
|
|
458
|
-
pt:
|
|
459
|
-
ra:
|
|
460
|
-
rt:
|
|
461
|
-
name:
|
|
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:
|
|
466
|
-
extraParams: (
|
|
467
|
-
pa:
|
|
468
|
-
pt:
|
|
469
|
-
ra:
|
|
470
|
-
rt:
|
|
471
|
-
name:
|
|
472
|
-
desc:
|
|
473
|
-
loc:
|
|
474
|
-
bg:
|
|
475
|
-
logo:
|
|
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:
|
|
480
|
-
extraParams: (
|
|
481
|
-
pa:
|
|
482
|
-
pt:
|
|
483
|
-
ra:
|
|
484
|
-
rt:
|
|
485
|
-
name:
|
|
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:
|
|
490
|
-
extraParams: (
|
|
491
|
-
pa:
|
|
492
|
-
pt:
|
|
493
|
-
ra:
|
|
494
|
-
rt:
|
|
495
|
-
name:
|
|
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:
|
|
500
|
-
extraParams: (
|
|
501
|
-
pa:
|
|
502
|
-
pt:
|
|
503
|
-
ra:
|
|
504
|
-
rt:
|
|
505
|
-
name:
|
|
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:
|
|
510
|
-
extraParams: (
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
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:
|
|
528
|
-
extraParams: (
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
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:
|
|
546
|
-
extraParams: (
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
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:
|
|
558
|
-
extraParams: (
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
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:
|
|
570
|
-
extraParams:
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
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:
|
|
582
|
-
extraParams:
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
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:
|
|
594
|
-
extraParams:
|
|
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:
|
|
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;
|