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