UNPKG

6.07 kBTypeScriptView Raw
1import type { AnyJson, AnyNumber, AnyTuple, AnyU8a, Codec } from '@polkadot/types-codec/types';
2import type { HexString } from '@polkadot/util/types';
3import type { ExtrinsicStatus } from '../interfaces/author';
4import type { EcdsaSignature, Ed25519Signature, Sr25519Signature } from '../interfaces/extrinsics';
5import type { Address, Call, H256, Hash } from '../interfaces/runtime';
6import type { DispatchError, DispatchInfo, EventRecord } from '../interfaces/system';
7import type { ICompact, IKeyringPair, IMethod, INumber, IRuntimeVersionBase } from './interfaces';
8import type { Registry } from './registry';
9export interface ISubmittableResult {
10 readonly dispatchError?: DispatchError;
11 readonly dispatchInfo?: DispatchInfo;
12 readonly events: EventRecord[];
13 readonly internalError?: Error;
14 readonly status: ExtrinsicStatus;
15 readonly isCompleted: boolean;
16 readonly isError: boolean;
17 readonly isFinalized: boolean;
18 readonly isInBlock: boolean;
19 readonly isWarning: boolean;
20 readonly txHash: Hash;
21 readonly txIndex?: number;
22 filterRecords(section: string, method: string): EventRecord[];
23 findRecord(section: string, method: string): EventRecord | undefined;
24 toHuman(isExtended?: boolean): AnyJson;
25}
26export interface SignerPayloadJSON {
27 /**
28 * @description The ss-58 encoded address
29 */
30 address: string;
31 /**
32 * @description The checkpoint hash of the block, in hex
33 */
34 blockHash: string;
35 /**
36 * @description The checkpoint block number, in hex
37 */
38 blockNumber: string;
39 /**
40 * @description The era for this transaction, in hex
41 */
42 era: string;
43 /**
44 * @description The genesis hash of the chain, in hex
45 */
46 genesisHash: string;
47 /**
48 * @description The encoded method (with arguments) in hex
49 */
50 method: string;
51 /**
52 * @description The nonce for this transaction, in hex
53 */
54 nonce: string;
55 /**
56 * @description The current spec version for the runtime
57 */
58 specVersion: string;
59 /**
60 * @description The tip for this transaction, in hex
61 */
62 tip: string;
63 /**
64 * @description The current transaction version for the runtime
65 */
66 transactionVersion: string;
67 /**
68 * @description The applicable signed extensions for this runtime
69 */
70 signedExtensions: string[];
71 /**
72 * @description The version of the extrinsic we are dealing with
73 */
74 version: number;
75}
76export interface SignerPayloadRawBase {
77 /**
78 * @description The hex-encoded data for this request
79 */
80 data: string;
81 /**
82 * @description The type of the contained data
83 */
84 type?: 'bytes' | 'payload';
85}
86export interface SignerPayloadRaw extends SignerPayloadRawBase {
87 /**
88 * @description The ss-58 encoded address
89 */
90 address: string;
91 /**
92 * @description The type of the contained data
93 */
94 type: 'bytes' | 'payload';
95}
96export interface ISignerPayload {
97 toPayload(): SignerPayloadJSON;
98 toRaw(): SignerPayloadRaw;
99}
100export interface SignerResult {
101 /**
102 * @description The id for this request
103 */
104 id: number;
105 /**
106 * @description The resulting signature in hex
107 */
108 signature: HexString;
109}
110export interface Signer {
111 /**
112 * @description signs an extrinsic payload from a serialized form
113 */
114 signPayload?: (payload: SignerPayloadJSON) => Promise<SignerResult>;
115 /**
116 * @description signs a raw payload, only the bytes data as supplied
117 */
118 signRaw?: (raw: SignerPayloadRaw) => Promise<SignerResult>;
119 /**
120 * @description Receives an update for the extrinsic signed by a `signer.sign`
121 */
122 update?: (id: number, status: H256 | ISubmittableResult) => void;
123}
124export interface IExtrinsicEra extends Codec {
125 asImmortalEra: Codec;
126 asMortalEra: Codec;
127}
128export interface SignatureOptions {
129 blockHash: Uint8Array | string;
130 era?: IExtrinsicEra;
131 genesisHash: Uint8Array | string;
132 nonce: AnyNumber;
133 runtimeVersion: IRuntimeVersionBase;
134 signedExtensions?: string[];
135 signer?: Signer;
136 tip?: AnyNumber;
137 assetId?: AnyNumber;
138}
139interface ExtrinsicSignatureBase {
140 readonly isSigned: boolean;
141 readonly era: IExtrinsicEra;
142 readonly nonce: ICompact<INumber>;
143 readonly signature: EcdsaSignature | Ed25519Signature | Sr25519Signature;
144 readonly signer: Address;
145 readonly tip: ICompact<INumber>;
146}
147export interface ExtrinsicPayloadValue {
148 blockHash: AnyU8a;
149 era: AnyU8a | IExtrinsicEra;
150 genesisHash: AnyU8a;
151 method: AnyU8a | IMethod<AnyTuple>;
152 nonce: AnyNumber;
153 specVersion: AnyNumber;
154 tip: AnyNumber;
155 transactionVersion: AnyNumber;
156 assetId?: AnyNumber;
157}
158export interface IExtrinsicSignature extends ExtrinsicSignatureBase, Codec {
159 addSignature(signer: Address | Uint8Array | string, signature: Uint8Array | HexString, payload: Uint8Array | HexString): IExtrinsicSignature;
160 sign(method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature;
161 signFake(method: Call, address: Address | Uint8Array | string, options: SignatureOptions): IExtrinsicSignature;
162 readonly registry: Registry;
163}
164interface IExtrinsicSignable<T> extends Codec {
165 addSignature(signer: Address | Uint8Array | string, signature: Uint8Array | HexString, payload: ExtrinsicPayloadValue | Uint8Array | HexString): T;
166 sign(account: IKeyringPair, options: SignatureOptions): T;
167 signFake(address: Address | Uint8Array | string, options: SignatureOptions): T;
168 readonly registry: Registry;
169}
170export interface IExtrinsicImpl extends IExtrinsicSignable<IExtrinsicImpl> {
171 readonly method: Call;
172 readonly signature: IExtrinsicSignature;
173 readonly version: number;
174}
175export interface IExtrinsic<A extends AnyTuple = AnyTuple> extends IExtrinsicSignable<IExtrinsic<A>>, ExtrinsicSignatureBase, IMethod<A> {
176 readonly length: number;
177 readonly method: IMethod<A>;
178 readonly type: number;
179 readonly version: number;
180}
181export {};