@getpara/web-sdk 2.0.0-alpha.6 → 2.0.0-alpha.60
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/dist/LocalStorage.js +1 -1
- package/dist/ParaWeb.d.ts +13 -1
- package/dist/ParaWeb.js +149 -9
- package/dist/SessionStorage.js +1 -1
- package/dist/WebUtils.d.ts +2 -2
- package/dist/WebUtils.js +62 -50
- package/dist/chunk-YJOFEY2L.js +52 -0
- package/dist/cryptography/webAuth.js +1 -1
- package/dist/errors.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -3
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/onRamp.d.ts +66 -0
- package/dist/types/onRamp.js +1 -0
- package/dist/utils/emailUtils.js +1 -1
- package/dist/utils/formattingUtils.js +1 -1
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/isMobile.js +1 -1
- package/dist/utils/isPasskeySupported.js +1 -1
- package/dist/utils/offrampSend.d.ts +5 -0
- package/dist/utils/offrampSend.js +67 -0
- package/dist/utils/truncateEthAddress.js +1 -1
- package/dist/wallet/keygen.d.ts +1 -0
- package/dist/wallet/keygen.js +161 -88
- package/dist/wallet/privateKey.js +17 -7
- package/dist/wallet/signing.js +64 -25
- package/dist/wasm/wasm_exec.js +1 -1
- package/dist/workers/walletUtils.d.ts +1 -3
- package/dist/workers/walletUtils.js +95 -69
- package/dist/workers/worker.d.ts +9 -1
- package/dist/workers/worker.js +65 -11
- package/dist/workers/workerWrapper.d.ts +1 -1
- package/dist/workers/workerWrapper.js +54 -14
- package/package.json +30 -25
- package/dist/chunk-M66XENHI.js +0 -25
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../chunk-YJOFEY2L.js";
|
|
5
|
+
import { hexStringToBase64 } from "@getpara/core-sdk";
|
|
6
|
+
function offRampSend(_0, _1, _2) {
|
|
7
|
+
return __async(this, arguments, function* (para, { id: purchaseId, provider, walletId, walletType, address, testMode = false }, { assetQuantity, fiat, fiatQuantity, chainId, destinationAddress, contractAddress }) {
|
|
8
|
+
var _a, _b, _c;
|
|
9
|
+
if (!purchaseId || !walletId || !walletType || !provider) {
|
|
10
|
+
throw new Error("Missing required fields");
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
const { tx, message, network, asset } = yield para.ctx.client.generateOffRampTx(para.getUserId(), {
|
|
14
|
+
walletId,
|
|
15
|
+
walletType,
|
|
16
|
+
provider,
|
|
17
|
+
chainId,
|
|
18
|
+
destinationAddress,
|
|
19
|
+
sourceAddress: address,
|
|
20
|
+
contractAddress,
|
|
21
|
+
testMode,
|
|
22
|
+
assetQuantity
|
|
23
|
+
});
|
|
24
|
+
let signature;
|
|
25
|
+
switch (walletType) {
|
|
26
|
+
case "EVM":
|
|
27
|
+
signature = (_a = yield para.signTransaction({
|
|
28
|
+
walletId,
|
|
29
|
+
rlpEncodedTxBase64: hexStringToBase64(tx),
|
|
30
|
+
chainId
|
|
31
|
+
})) == null ? void 0 : _a.signature;
|
|
32
|
+
break;
|
|
33
|
+
case "SOLANA":
|
|
34
|
+
signature = (_b = yield para.signMessage({ walletId, messageBase64: message })) == null ? void 0 : _b.signature;
|
|
35
|
+
break;
|
|
36
|
+
default:
|
|
37
|
+
throw new Error(`Unsupported wallet type: ${walletType}`);
|
|
38
|
+
}
|
|
39
|
+
const { txHash } = yield para.ctx.client.sendOffRampTx(para.getUserId(), {
|
|
40
|
+
tx,
|
|
41
|
+
signature: walletType === "EVM" ? `0x${signature}` : signature,
|
|
42
|
+
sourceAddress: address,
|
|
43
|
+
network,
|
|
44
|
+
walletId,
|
|
45
|
+
walletType
|
|
46
|
+
});
|
|
47
|
+
const updatedOnRampPurchase = yield para.ctx.client.updateOnRampPurchase({
|
|
48
|
+
userId: para.getUserId(),
|
|
49
|
+
walletId,
|
|
50
|
+
purchaseId,
|
|
51
|
+
updates: {
|
|
52
|
+
fiat,
|
|
53
|
+
fiatQuantity,
|
|
54
|
+
assetQuantity,
|
|
55
|
+
network,
|
|
56
|
+
asset
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return { txHash, updatedOnRampPurchase };
|
|
60
|
+
} catch (e) {
|
|
61
|
+
throw new Error(((_c = e.response) == null ? void 0 : _c.data) || e.message);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
offRampSend
|
|
67
|
+
};
|
package/dist/wallet/keygen.d.ts
CHANGED
package/dist/wallet/keygen.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
__async
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-YJOFEY2L.js";
|
|
5
5
|
import { setupWorker } from "../workers/workerWrapper.js";
|
|
6
6
|
import { distributeNewShare, waitUntilTrue } from "@getpara/core-sdk";
|
|
7
|
+
import * as uuid from "uuid";
|
|
7
8
|
function isKeygenComplete(ctx, userId, walletId) {
|
|
8
9
|
return __async(this, null, function* () {
|
|
9
10
|
const wallets = yield ctx.client.getWallets(userId);
|
|
@@ -25,34 +26,44 @@ function isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, wallet
|
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
28
|
function keygen(ctx, userId, type, secretKey, skipDistribute = false, sessionCookie, emailProps = {}) {
|
|
28
|
-
return new Promise((resolve) => __async(this, null, function* () {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
30
|
+
const workId = uuid.v4();
|
|
31
|
+
let worker = null;
|
|
32
|
+
worker = yield setupWorker(
|
|
33
|
+
ctx,
|
|
34
|
+
(res) => __async(this, null, function* () {
|
|
35
|
+
yield waitUntilTrue(() => __async(this, null, function* () {
|
|
36
|
+
return isKeygenComplete(ctx, userId, res.walletId);
|
|
37
|
+
}), 15e3, 1e3);
|
|
38
|
+
if (skipDistribute) {
|
|
39
|
+
resolve({
|
|
40
|
+
signer: res.signer,
|
|
41
|
+
walletId: res.walletId,
|
|
42
|
+
recoveryShare: null
|
|
43
|
+
});
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const recoveryShare = yield distributeNewShare({
|
|
47
|
+
ctx,
|
|
48
|
+
userId,
|
|
49
|
+
walletId: res.walletId,
|
|
50
|
+
userShare: res.signer,
|
|
51
|
+
emailProps,
|
|
52
|
+
isEnclaveUser: false,
|
|
53
|
+
walletScheme: "DKLS"
|
|
54
|
+
// since `isEnclaveUser` is false, we can use `DKLS` here as it won't be used
|
|
55
|
+
});
|
|
34
56
|
resolve({
|
|
35
57
|
signer: res.signer,
|
|
36
58
|
walletId: res.walletId,
|
|
37
|
-
recoveryShare
|
|
59
|
+
recoveryShare
|
|
38
60
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
walletId: res.walletId,
|
|
46
|
-
userShare: res.signer,
|
|
47
|
-
emailProps
|
|
48
|
-
});
|
|
49
|
-
resolve({
|
|
50
|
-
signer: res.signer,
|
|
51
|
-
walletId: res.walletId,
|
|
52
|
-
recoveryShare
|
|
53
|
-
});
|
|
54
|
-
worker.terminate();
|
|
55
|
-
}));
|
|
61
|
+
}),
|
|
62
|
+
(error) => {
|
|
63
|
+
reject(error);
|
|
64
|
+
},
|
|
65
|
+
workId
|
|
66
|
+
);
|
|
56
67
|
worker.postMessage({
|
|
57
68
|
env: ctx.env,
|
|
58
69
|
apiKey: ctx.apiKey,
|
|
@@ -64,27 +75,36 @@ function keygen(ctx, userId, type, secretKey, skipDistribute = false, sessionCoo
|
|
|
64
75
|
sessionCookie,
|
|
65
76
|
useDKLS: ctx.useDKLS,
|
|
66
77
|
disableWebSockets: ctx.disableWebSockets,
|
|
67
|
-
wasmOverride: ctx.wasmOverride
|
|
78
|
+
wasmOverride: ctx.wasmOverride,
|
|
79
|
+
workId
|
|
68
80
|
});
|
|
69
81
|
}));
|
|
70
82
|
}
|
|
71
83
|
function preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey, _skipDistribute = false, partnerId, sessionCookie) {
|
|
72
|
-
return new Promise((resolve) => __async(this, null, function* () {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
85
|
+
const workId = uuid.v4();
|
|
86
|
+
let worker = null;
|
|
87
|
+
worker = yield setupWorker(
|
|
88
|
+
ctx,
|
|
89
|
+
(res) => __async(this, null, function* () {
|
|
90
|
+
yield waitUntilTrue(
|
|
91
|
+
() => __async(this, null, function* () {
|
|
92
|
+
return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
|
|
93
|
+
}),
|
|
94
|
+
15e3,
|
|
95
|
+
1e3
|
|
96
|
+
);
|
|
97
|
+
resolve({
|
|
98
|
+
signer: res.signer,
|
|
99
|
+
walletId: res.walletId,
|
|
100
|
+
recoveryShare: null
|
|
101
|
+
});
|
|
102
|
+
}),
|
|
103
|
+
(error) => {
|
|
104
|
+
reject(error);
|
|
105
|
+
},
|
|
106
|
+
workId
|
|
107
|
+
);
|
|
88
108
|
const email = void 0;
|
|
89
109
|
const params = { pregenIdentifier, pregenIdentifierType, type, secretKey, partnerId, email };
|
|
90
110
|
if (pregenIdentifierType === "EMAIL") {
|
|
@@ -101,25 +121,35 @@ function preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey,
|
|
|
101
121
|
sessionCookie,
|
|
102
122
|
useDKLS: ctx.useDKLS,
|
|
103
123
|
disableWebSockets: ctx.disableWebSockets,
|
|
104
|
-
wasmOverride: ctx.wasmOverride
|
|
124
|
+
wasmOverride: ctx.wasmOverride,
|
|
125
|
+
workId
|
|
105
126
|
});
|
|
106
127
|
}));
|
|
107
128
|
}
|
|
108
129
|
function refresh(ctx, sessionCookie, userId, walletId, share, oldPartnerId, newPartnerId, keyShareProtocolId) {
|
|
109
|
-
return new Promise((resolve) => __async(this, null, function* () {
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
130
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
131
|
+
const workId = uuid.v4();
|
|
132
|
+
let worker = null;
|
|
133
|
+
worker = yield setupWorker(
|
|
134
|
+
ctx,
|
|
135
|
+
(res) => __async(this, null, function* () {
|
|
136
|
+
if (!(yield waitUntilTrue(() => __async(this, null, function* () {
|
|
137
|
+
return isRefreshComplete(ctx, userId, walletId, newPartnerId);
|
|
138
|
+
}), 15e3, 1e3))) {
|
|
139
|
+
reject(new Error("refresh failed"));
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const { protocolId, signer } = res;
|
|
143
|
+
resolve({
|
|
144
|
+
signer,
|
|
145
|
+
protocolId
|
|
146
|
+
});
|
|
147
|
+
}),
|
|
148
|
+
(error) => {
|
|
149
|
+
reject(error);
|
|
150
|
+
},
|
|
151
|
+
workId
|
|
152
|
+
);
|
|
123
153
|
worker.postMessage({
|
|
124
154
|
env: ctx.env,
|
|
125
155
|
apiKey: ctx.apiKey,
|
|
@@ -130,23 +160,32 @@ function refresh(ctx, sessionCookie, userId, walletId, share, oldPartnerId, newP
|
|
|
130
160
|
useDKLS: ctx.useDKLS,
|
|
131
161
|
disableWebSockets: ctx.disableWebSockets,
|
|
132
162
|
wasmOverride: ctx.wasmOverride,
|
|
133
|
-
returnObject: true
|
|
163
|
+
returnObject: true,
|
|
164
|
+
workId
|
|
134
165
|
});
|
|
135
166
|
}));
|
|
136
167
|
}
|
|
137
168
|
function ed25519Keygen(ctx, userId, sessionCookie, _emailProps = {}) {
|
|
138
|
-
return new Promise((resolve) => __async(this, null, function* () {
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
169
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
170
|
+
const workId = uuid.v4();
|
|
171
|
+
let worker = null;
|
|
172
|
+
worker = yield setupWorker(
|
|
173
|
+
ctx,
|
|
174
|
+
(res) => __async(this, null, function* () {
|
|
175
|
+
yield waitUntilTrue(() => __async(this, null, function* () {
|
|
176
|
+
return isKeygenComplete(ctx, userId, res.walletId);
|
|
177
|
+
}), 15e3, 1e3);
|
|
178
|
+
resolve({
|
|
179
|
+
signer: res.signer,
|
|
180
|
+
walletId: res.walletId,
|
|
181
|
+
recoveryShare: null
|
|
182
|
+
});
|
|
183
|
+
}),
|
|
184
|
+
(error) => {
|
|
185
|
+
reject(error);
|
|
186
|
+
},
|
|
187
|
+
workId
|
|
188
|
+
);
|
|
150
189
|
worker.postMessage({
|
|
151
190
|
env: ctx.env,
|
|
152
191
|
apiKey: ctx.apiKey,
|
|
@@ -156,27 +195,36 @@ function ed25519Keygen(ctx, userId, sessionCookie, _emailProps = {}) {
|
|
|
156
195
|
disableWorkers: ctx.disableWorkers,
|
|
157
196
|
sessionCookie,
|
|
158
197
|
disableWebSockets: ctx.disableWebSockets,
|
|
159
|
-
wasmOverride: ctx.wasmOverride
|
|
198
|
+
wasmOverride: ctx.wasmOverride,
|
|
199
|
+
workId
|
|
160
200
|
});
|
|
161
201
|
}));
|
|
162
202
|
}
|
|
163
203
|
function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie) {
|
|
164
|
-
return new Promise((resolve) => __async(this, null, function* () {
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
204
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
205
|
+
const workId = uuid.v4();
|
|
206
|
+
let worker = null;
|
|
207
|
+
worker = yield setupWorker(
|
|
208
|
+
ctx,
|
|
209
|
+
(res) => __async(this, null, function* () {
|
|
210
|
+
yield waitUntilTrue(
|
|
211
|
+
() => __async(this, null, function* () {
|
|
212
|
+
return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
|
|
213
|
+
}),
|
|
214
|
+
15e3,
|
|
215
|
+
1e3
|
|
216
|
+
);
|
|
217
|
+
resolve({
|
|
218
|
+
signer: res.signer,
|
|
219
|
+
walletId: res.walletId,
|
|
220
|
+
recoveryShare: null
|
|
221
|
+
});
|
|
222
|
+
}),
|
|
223
|
+
(error) => {
|
|
224
|
+
reject(error);
|
|
225
|
+
},
|
|
226
|
+
workId
|
|
227
|
+
);
|
|
180
228
|
const email = void 0;
|
|
181
229
|
const params = { pregenIdentifier, pregenIdentifierType, email };
|
|
182
230
|
if (pregenIdentifierType === "EMAIL") {
|
|
@@ -191,13 +239,38 @@ function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCo
|
|
|
191
239
|
disableWorkers: ctx.disableWorkers,
|
|
192
240
|
sessionCookie,
|
|
193
241
|
disableWebSockets: ctx.disableWebSockets,
|
|
194
|
-
wasmOverride: ctx.wasmOverride
|
|
242
|
+
wasmOverride: ctx.wasmOverride,
|
|
243
|
+
workId
|
|
195
244
|
});
|
|
196
245
|
}));
|
|
197
246
|
}
|
|
247
|
+
function initializeWorker(ctx) {
|
|
248
|
+
return __async(this, null, function* () {
|
|
249
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
250
|
+
const workId = uuid.v4();
|
|
251
|
+
const worker = yield setupWorker(
|
|
252
|
+
ctx,
|
|
253
|
+
() => __async(this, null, function* () {
|
|
254
|
+
resolve();
|
|
255
|
+
}),
|
|
256
|
+
(error) => {
|
|
257
|
+
reject(error);
|
|
258
|
+
},
|
|
259
|
+
workId
|
|
260
|
+
);
|
|
261
|
+
worker.postMessage({
|
|
262
|
+
env: ctx.env,
|
|
263
|
+
apiKey: ctx.apiKey,
|
|
264
|
+
functionType: "INIT",
|
|
265
|
+
workId
|
|
266
|
+
});
|
|
267
|
+
}));
|
|
268
|
+
});
|
|
269
|
+
}
|
|
198
270
|
export {
|
|
199
271
|
ed25519Keygen,
|
|
200
272
|
ed25519PreKeygen,
|
|
273
|
+
initializeWorker,
|
|
201
274
|
keygen,
|
|
202
275
|
preKeygen,
|
|
203
276
|
refresh
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
__async
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-YJOFEY2L.js";
|
|
5
5
|
import { setupWorker } from "../workers/workerWrapper.js";
|
|
6
|
+
import * as uuid from "uuid";
|
|
6
7
|
function getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
|
|
7
8
|
return __async(this, null, function* () {
|
|
8
|
-
return
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
10
|
+
const workId = uuid.v4();
|
|
11
|
+
let worker = null;
|
|
12
|
+
worker = yield setupWorker(
|
|
13
|
+
ctx,
|
|
14
|
+
(res) => __async(this, null, function* () {
|
|
15
|
+
resolve((res == null ? void 0 : res.privateKey) || res);
|
|
16
|
+
}),
|
|
17
|
+
(error) => {
|
|
18
|
+
reject(error);
|
|
19
|
+
},
|
|
20
|
+
workId
|
|
21
|
+
);
|
|
13
22
|
worker.postMessage({
|
|
14
23
|
env: ctx.env,
|
|
15
24
|
apiKey: ctx.apiKey,
|
|
@@ -21,7 +30,8 @@ function getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
|
|
|
21
30
|
sessionCookie,
|
|
22
31
|
useDKLS: ctx.useDKLS,
|
|
23
32
|
disableWebSockets: ctx.disableWebSockets,
|
|
24
|
-
wasmOverride: ctx.wasmOverride
|
|
33
|
+
wasmOverride: ctx.wasmOverride,
|
|
34
|
+
workId
|
|
25
35
|
});
|
|
26
36
|
}));
|
|
27
37
|
});
|
package/dist/wallet/signing.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
__async
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-YJOFEY2L.js";
|
|
5
5
|
import { setupWorker } from "../workers/workerWrapper.js";
|
|
6
|
+
import * as uuid from "uuid";
|
|
6
7
|
function signTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
|
|
7
8
|
return __async(this, null, function* () {
|
|
8
|
-
return
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
10
|
+
const workId = uuid.v4();
|
|
11
|
+
let worker = null;
|
|
12
|
+
worker = yield setupWorker(
|
|
13
|
+
ctx,
|
|
14
|
+
(sendTransactionRes) => __async(this, null, function* () {
|
|
15
|
+
resolve(sendTransactionRes);
|
|
16
|
+
}),
|
|
17
|
+
(error) => {
|
|
18
|
+
reject(error);
|
|
19
|
+
},
|
|
20
|
+
workId
|
|
21
|
+
);
|
|
13
22
|
worker.postMessage({
|
|
14
23
|
env: ctx.env,
|
|
15
24
|
apiKey: ctx.apiKey,
|
|
@@ -21,18 +30,27 @@ function signTransaction(ctx, userId, walletId, share, tx, chainId, sessionCooki
|
|
|
21
30
|
sessionCookie,
|
|
22
31
|
useDKLS: isDKLS,
|
|
23
32
|
disableWebSockets: ctx.disableWebSockets,
|
|
24
|
-
wasmOverride: ctx.wasmOverride
|
|
33
|
+
wasmOverride: ctx.wasmOverride,
|
|
34
|
+
workId
|
|
25
35
|
});
|
|
26
36
|
}));
|
|
27
37
|
});
|
|
28
38
|
}
|
|
29
39
|
function sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
|
|
30
40
|
return __async(this, null, function* () {
|
|
31
|
-
return
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
42
|
+
const workId = uuid.v4();
|
|
43
|
+
let worker = null;
|
|
44
|
+
worker = yield setupWorker(
|
|
45
|
+
ctx,
|
|
46
|
+
(sendTransactionRes) => __async(this, null, function* () {
|
|
47
|
+
resolve(sendTransactionRes);
|
|
48
|
+
}),
|
|
49
|
+
(error) => {
|
|
50
|
+
reject(error);
|
|
51
|
+
},
|
|
52
|
+
workId
|
|
53
|
+
);
|
|
36
54
|
worker.postMessage({
|
|
37
55
|
env: ctx.env,
|
|
38
56
|
apiKey: ctx.apiKey,
|
|
@@ -44,18 +62,28 @@ function sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCooki
|
|
|
44
62
|
sessionCookie,
|
|
45
63
|
useDKLS: isDKLS,
|
|
46
64
|
disableWebSockets: ctx.disableWebSockets,
|
|
47
|
-
wasmOverride: ctx.wasmOverride
|
|
65
|
+
wasmOverride: ctx.wasmOverride,
|
|
66
|
+
workId
|
|
48
67
|
});
|
|
49
68
|
}));
|
|
50
69
|
});
|
|
51
70
|
}
|
|
52
71
|
function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, cosmosSignDoc) {
|
|
53
72
|
return __async(this, null, function* () {
|
|
54
|
-
return
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
73
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
74
|
+
const workId = uuid.v4();
|
|
75
|
+
let worker = null;
|
|
76
|
+
worker = yield setupWorker(
|
|
77
|
+
ctx,
|
|
78
|
+
(signMessageRes) => __async(this, null, function* () {
|
|
79
|
+
resolve(signMessageRes);
|
|
80
|
+
}),
|
|
81
|
+
(error) => {
|
|
82
|
+
console.error(`Worker error in signMessage for userId ${userId}, walletId ${walletId}:`, error);
|
|
83
|
+
reject(error);
|
|
84
|
+
},
|
|
85
|
+
workId
|
|
86
|
+
);
|
|
59
87
|
worker.postMessage({
|
|
60
88
|
env: ctx.env,
|
|
61
89
|
apiKey: ctx.apiKey,
|
|
@@ -67,18 +95,28 @@ function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKL
|
|
|
67
95
|
sessionCookie,
|
|
68
96
|
useDKLS: isDKLS,
|
|
69
97
|
disableWebSockets: ctx.disableWebSockets,
|
|
70
|
-
wasmOverride: ctx.wasmOverride
|
|
98
|
+
wasmOverride: ctx.wasmOverride,
|
|
99
|
+
workId
|
|
71
100
|
});
|
|
72
101
|
}));
|
|
73
102
|
});
|
|
74
103
|
}
|
|
75
104
|
function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
|
|
76
105
|
return __async(this, null, function* () {
|
|
77
|
-
return
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
106
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
107
|
+
const workId = uuid.v4();
|
|
108
|
+
let worker = null;
|
|
109
|
+
worker = yield setupWorker(
|
|
110
|
+
ctx,
|
|
111
|
+
(signMessageRes) => __async(this, null, function* () {
|
|
112
|
+
resolve(signMessageRes);
|
|
113
|
+
}),
|
|
114
|
+
(error) => {
|
|
115
|
+
console.error(`Worker error in ed25519Sign for userId ${userId}, walletId ${walletId}:`, error);
|
|
116
|
+
reject(error);
|
|
117
|
+
},
|
|
118
|
+
workId
|
|
119
|
+
);
|
|
82
120
|
worker.postMessage({
|
|
83
121
|
env: ctx.env,
|
|
84
122
|
apiKey: ctx.apiKey,
|
|
@@ -88,7 +126,8 @@ function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
|
|
|
88
126
|
disableWorkers: ctx.disableWorkers,
|
|
89
127
|
sessionCookie,
|
|
90
128
|
disableWebSockets: ctx.disableWebSockets,
|
|
91
|
-
wasmOverride: ctx.wasmOverride
|
|
129
|
+
wasmOverride: ctx.wasmOverride,
|
|
130
|
+
workId
|
|
92
131
|
});
|
|
93
132
|
}));
|
|
94
133
|
});
|
package/dist/wasm/wasm_exec.js
CHANGED
|
@@ -7,9 +7,7 @@ export declare function ed25519PreKeygen(ctx: Ctx, pregenIdentifier: string, pre
|
|
|
7
7
|
signer: string;
|
|
8
8
|
walletId: string;
|
|
9
9
|
}>;
|
|
10
|
-
export declare function ed25519Sign(ctx: Ctx, share: string, userId: string, walletId: string, base64Bytes: string): Promise<
|
|
11
|
-
signature: string;
|
|
12
|
-
}>;
|
|
10
|
+
export declare function ed25519Sign(ctx: Ctx, share: string, userId: string, walletId: string, base64Bytes: string): Promise<SignatureRes>;
|
|
13
11
|
export declare function keygen(ctx: Ctx, userId: string, type: Exclude<TWalletType, 'SOLANA'>, secretKey: string | null): Promise<{
|
|
14
12
|
signer: string;
|
|
15
13
|
walletId: string;
|