@parity/product-sdk-terminal 0.12.0 → 0.13.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/README.md +12 -13
- package/dist/{chunk-GHOFKVUG.js → chunk-I3KMQJLW.js} +2 -2
- package/dist/chunk-I3KMQJLW.js.map +1 -0
- package/dist/{chunk-EORPX5XL.js → chunk-L75TTEEA.js} +4 -4
- package/dist/chunk-L75TTEEA.js.map +1 -0
- package/dist/{host-_G9M0isV.d.ts → host-Dk5G2hVc.d.ts} +4 -4
- package/dist/host.d.ts +2 -2
- package/dist/host.js +1 -1
- package/dist/index.d.ts +32 -21
- package/dist/index.js +26 -44
- package/dist/index.js.map +1 -1
- package/dist/testing.js +1 -1
- package/package.json +12 -10
- package/dist/chunk-EORPX5XL.js.map +0 -1
- package/dist/chunk-GHOFKVUG.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { cacheFilePath, withFileLock, loadJsonCache, saveJsonCache } from './chunk-
|
|
2
|
-
export { requestResourceAllocation, sendResourceAllocation } from './chunk-
|
|
3
|
-
import { createNodeStorageAdapter, sanitizeKey } from './chunk-
|
|
4
|
-
export { createNodeStorageAdapter } from './chunk-
|
|
1
|
+
import { cacheFilePath, withFileLock, loadJsonCache, saveJsonCache } from './chunk-L75TTEEA.js';
|
|
2
|
+
export { requestResourceAllocation, sendResourceAllocation } from './chunk-L75TTEEA.js';
|
|
3
|
+
import { createNodeStorageAdapter, sanitizeKey } from './chunk-I3KMQJLW.js';
|
|
4
|
+
export { createNodeStorageAdapter } from './chunk-I3KMQJLW.js';
|
|
5
5
|
import { SS_PREVIEW_STAGE_ENDPOINTS, createPappAdapter, AllowanceError } from '@novasamatech/host-papp';
|
|
6
6
|
export { AllowanceError, SS_STABLE_STAGE_ENDPOINTS } from '@novasamatech/host-papp';
|
|
7
7
|
import { createLazyClient, createPapiStatementStoreAdapter, NoAllowanceError } from '@novasamatech/statement-store';
|
|
@@ -10,6 +10,7 @@ import { getWsProvider } from '@polkadot-api/ws-provider';
|
|
|
10
10
|
import { deriveProductAccountPublicKey } from '@parity/product-sdk-keys';
|
|
11
11
|
import { AllowanceExpiredError } from '@parity/product-sdk-signer/errors';
|
|
12
12
|
export { AllowanceExpiredError, SignerError } from '@parity/product-sdk-signer/errors';
|
|
13
|
+
import { createHostTxCreator } from '@parity/product-sdk-host/tx-creator';
|
|
13
14
|
import { toHex, fromHex } from '@polkadot-api/utils';
|
|
14
15
|
import { gcm } from '@noble/ciphers/aes.js';
|
|
15
16
|
import { blake2b } from '@noble/hashes/blake2.js';
|
|
@@ -197,30 +198,20 @@ function toAllowanceExpiredError(error) {
|
|
|
197
198
|
function toProductAccountId(ref) {
|
|
198
199
|
return [ref.productId, { tag: "Index", value: ref.derivationIndex }];
|
|
199
200
|
}
|
|
200
|
-
function buildCreateTransactionRequest(productAccountId,
|
|
201
|
-
const checkGenesis = signedExtensions.CheckGenesis;
|
|
202
|
-
if (!checkGenesis) {
|
|
203
|
-
throw new Error(
|
|
204
|
-
"Cannot build transaction: chain did not provide the CheckGenesis signed extension"
|
|
205
|
-
);
|
|
206
|
-
}
|
|
201
|
+
function buildCreateTransactionRequest(productAccountId, request) {
|
|
207
202
|
return {
|
|
208
203
|
payload: {
|
|
209
204
|
tag: "v1",
|
|
210
205
|
value: {
|
|
211
206
|
signer: productAccountId,
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
(
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
additionalSigned
|
|
221
|
-
})
|
|
222
|
-
),
|
|
223
|
-
txExtVersion
|
|
207
|
+
genesisHash: request.genesisHash,
|
|
208
|
+
callData: fromHex(request.callData),
|
|
209
|
+
extensions: request.extensions.map(({ id, extra, additionalSigned }) => ({
|
|
210
|
+
id,
|
|
211
|
+
extra: fromHex(extra),
|
|
212
|
+
additionalSigned: fromHex(additionalSigned)
|
|
213
|
+
})),
|
|
214
|
+
txExtVersion: request.txExtVersion
|
|
224
215
|
}
|
|
225
216
|
}
|
|
226
217
|
};
|
|
@@ -234,17 +225,6 @@ async function requestSignedTransaction(session, request) {
|
|
|
234
225
|
}
|
|
235
226
|
return result.value;
|
|
236
227
|
}
|
|
237
|
-
function makeTxSignTx(session, productAccountId, txExtVersion) {
|
|
238
|
-
return async (callData, signedExtensions) => requestSignedTransaction(
|
|
239
|
-
session,
|
|
240
|
-
buildCreateTransactionRequest(
|
|
241
|
-
productAccountId,
|
|
242
|
-
callData,
|
|
243
|
-
signedExtensions,
|
|
244
|
-
txExtVersion
|
|
245
|
-
)
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
228
|
function makeRawBytesSignCallback(session, productAccountId) {
|
|
249
229
|
return async (data) => {
|
|
250
230
|
const result = await session.signRaw({
|
|
@@ -275,17 +255,17 @@ async function deriveProductPublicKey(session, ref, options) {
|
|
|
275
255
|
async function buildSessionSigner(session, ref, options) {
|
|
276
256
|
const productAccountId = toProductAccountId(ref);
|
|
277
257
|
const publicKey = ref.publicKey ?? await deriveProductPublicKey(session, ref, options);
|
|
278
|
-
return
|
|
258
|
+
return createHostTxCreator(
|
|
279
259
|
publicKey,
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
260
|
+
async (request) => toHex(
|
|
261
|
+
await requestSignedTransaction(
|
|
262
|
+
session,
|
|
263
|
+
buildCreateTransactionRequest(productAccountId, request)
|
|
264
|
+
)
|
|
265
|
+
),
|
|
266
|
+
makeRawBytesSignCallback(session, productAccountId),
|
|
267
|
+
options?.txExtVersion ?? 0
|
|
268
|
+
);
|
|
289
269
|
}
|
|
290
270
|
function createSessionSigner(session, adapter, publicKey, options) {
|
|
291
271
|
return buildSessionSigner(
|
|
@@ -347,6 +327,8 @@ function resolveSessionId(adapter, sessionId) {
|
|
|
347
327
|
async function getBulletinSigner(adapter, productId, sessionId) {
|
|
348
328
|
const resolvedSessionId = resolveSessionId(adapter, sessionId);
|
|
349
329
|
return adapter.allowance.getBulletinSigner(resolvedSessionId, productId).match(
|
|
330
|
+
// host-papp 0.12 builds this with `getTxCreator`, so it carries
|
|
331
|
+
// `publicKey` and `signBytes`, but its declared type is plain `TxCreator`.
|
|
350
332
|
(signer) => signer,
|
|
351
333
|
(err) => {
|
|
352
334
|
throw err;
|