PHP WebShell
Текущая директория: /usr/lib/node_modules/bitgo/node_modules/@substrate/txwrapper-core/lib/core/construct
Просмотр файла: createSigningPayloadToU8a.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSigningPayloadToU8a = void 0;
const types_1 = require("@polkadot/types");
/**
* Create a signing payload with the method prefix removed.
* If the length of the payload is above 256, then it will be hashed using
* blake2_256.
*
* Ref: https://github.com/paritytech/substrate/blob/master/primitives/runtime/src/generic/unchecked_extrinsic.rs#L171-L220
*
* This is specifically useful for external signers who will not be using
* `ExtrinsicPayload.sign(<KeyPair>)`, but instead their own method.
*
* @param unsigned UnsignedTransaction to be passed in
* @param options Registry used for constructing the payload.
*/
function createSigningPayloadToU8a(unsigned, options) {
const { registry } = options;
const payload = new types_1.GenericSignerPayload(registry, {
...unsigned,
runtimeVersion: {
specVersion: unsigned.specVersion,
transactionVersion: unsigned.transactionVersion,
},
}).toPayload();
const extrinsicPayload = registry.createType('ExtrinsicPayload', payload, {
version: payload.version,
});
/**
* Makes sure that the method bytes in the payload doesnt have a length prefix
* included.
*/
const extrinsicPayloadU8a = extrinsicPayload.toU8a({ method: true });
return extrinsicPayloadU8a.length > 256
? registry.hash(extrinsicPayloadU8a)
: extrinsicPayloadU8a;
}
exports.createSigningPayloadToU8a = createSigningPayloadToU8a;
//# sourceMappingURL=createSigningPayloadToU8a.js.mapВыполнить команду
Для локальной разработки. Не используйте в интернете!