@novasamatech/host-api 0.5.0-16 → 0.5.0-18
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/commonEncoders.d.ts +0 -7
- package/dist/commonEncoders.js +1 -7
- package/dist/createTransport.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/interactions/accounts.js +2 -1
- package/dist/interactions/commonCodecs.d.ts +7 -0
- package/dist/interactions/commonCodecs.js +8 -0
- package/dist/interactions/features.d.ts +2 -2
- package/dist/interactions/features.js +2 -2
- package/dist/interactions/message.d.ts +1704 -0
- package/dist/interactions/message.js +60 -0
- package/dist/interactions/papiProvider.d.ts +2 -2
- package/dist/interactions/papiProvider.js +3 -2
- package/dist/interactions/sign.d.ts +20 -3
- package/dist/interactions/sign.js +1 -42
- package/dist/interactions/types.d.ts +1 -0
- package/dist/interactions/types.js +1 -0
- package/dist/interactions/v1/accounts.d.ts +128 -0
- package/dist/interactions/v1/accounts.js +51 -0
- package/dist/interactions/v1/chat.d.ts +295 -0
- package/dist/interactions/v1/chat.js +73 -0
- package/dist/interactions/v1/createTransaction.d.ts +197 -0
- package/dist/interactions/v1/createTransaction.js +41 -0
- package/dist/interactions/v1/feature.d.ts +11 -0
- package/dist/interactions/v1/feature.js +7 -0
- package/dist/interactions/v1/handshake.d.ts +28 -0
- package/dist/interactions/v1/handshake.js +12 -0
- package/dist/interactions/v1/jsonRpc.d.ts +6 -0
- package/dist/interactions/v1/jsonRpc.js +6 -0
- package/dist/interactions/v1/permission.d.ts +48 -0
- package/dist/interactions/v1/permission.js +18 -0
- package/dist/interactions/v1/sign.d.ts +92 -0
- package/dist/interactions/v1/sign.js +43 -0
- package/dist/interactions/v1/statementStore.d.ts +118 -0
- package/dist/interactions/v1/statementStore.js +47 -0
- package/dist/interactions/v1/storage.d.ts +41 -0
- package/dist/interactions/v1/storage.js +16 -0
- package/dist/messageEncoder.d.ts +68 -107
- package/dist/messageEncoder.js +11 -14
- package/package.json +1 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
export declare const Topic: import("scale-ts").Codec<Uint8Array<ArrayBufferLike>>;
|
|
2
|
+
export declare const Channel: import("scale-ts").Codec<Uint8Array<ArrayBufferLike>>;
|
|
3
|
+
export declare const DecryptionKey: import("scale-ts").Codec<Uint8Array<ArrayBufferLike>>;
|
|
4
|
+
export declare const Statement: import("scale-ts").Codec<{
|
|
5
|
+
proof: {
|
|
6
|
+
tag: "Sr25519";
|
|
7
|
+
value: {
|
|
8
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
9
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
10
|
+
};
|
|
11
|
+
} | {
|
|
12
|
+
tag: "Ed25519";
|
|
13
|
+
value: {
|
|
14
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
15
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
tag: "Ecdsa";
|
|
19
|
+
value: {
|
|
20
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
21
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
22
|
+
};
|
|
23
|
+
} | {
|
|
24
|
+
tag: "OnChain";
|
|
25
|
+
value: {
|
|
26
|
+
who: Uint8Array<ArrayBufferLike>;
|
|
27
|
+
blockHash: Uint8Array<ArrayBufferLike>;
|
|
28
|
+
event: bigint;
|
|
29
|
+
};
|
|
30
|
+
} | undefined;
|
|
31
|
+
decryptionKey: Uint8Array<ArrayBufferLike> | undefined;
|
|
32
|
+
priority: number | undefined;
|
|
33
|
+
channel: Uint8Array<ArrayBufferLike> | undefined;
|
|
34
|
+
topics: Uint8Array<ArrayBufferLike>[];
|
|
35
|
+
data: Uint8Array<ArrayBufferLike> | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const StatementProofErr: import("scale-ts").Codec<{
|
|
38
|
+
tag: "Unknown";
|
|
39
|
+
value: {
|
|
40
|
+
reason: string;
|
|
41
|
+
};
|
|
42
|
+
} | {
|
|
43
|
+
tag: "UnableToSign";
|
|
44
|
+
value: undefined;
|
|
45
|
+
} | {
|
|
46
|
+
tag: "UnknownAccount";
|
|
47
|
+
value: undefined;
|
|
48
|
+
}>;
|
|
49
|
+
export declare const StatementStoreCreateProofV1_request: import("scale-ts").Codec<[[string, number], {
|
|
50
|
+
proof: {
|
|
51
|
+
tag: "Sr25519";
|
|
52
|
+
value: {
|
|
53
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
54
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
55
|
+
};
|
|
56
|
+
} | {
|
|
57
|
+
tag: "Ed25519";
|
|
58
|
+
value: {
|
|
59
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
60
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
61
|
+
};
|
|
62
|
+
} | {
|
|
63
|
+
tag: "Ecdsa";
|
|
64
|
+
value: {
|
|
65
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
66
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
67
|
+
};
|
|
68
|
+
} | {
|
|
69
|
+
tag: "OnChain";
|
|
70
|
+
value: {
|
|
71
|
+
who: Uint8Array<ArrayBufferLike>;
|
|
72
|
+
blockHash: Uint8Array<ArrayBufferLike>;
|
|
73
|
+
event: bigint;
|
|
74
|
+
};
|
|
75
|
+
} | undefined;
|
|
76
|
+
decryptionKey: Uint8Array<ArrayBufferLike> | undefined;
|
|
77
|
+
priority: number | undefined;
|
|
78
|
+
channel: Uint8Array<ArrayBufferLike> | undefined;
|
|
79
|
+
topics: Uint8Array<ArrayBufferLike>[];
|
|
80
|
+
data: Uint8Array<ArrayBufferLike> | undefined;
|
|
81
|
+
}]>;
|
|
82
|
+
export declare const StatementStoreCreateProofV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<{
|
|
83
|
+
tag: "Sr25519";
|
|
84
|
+
value: {
|
|
85
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
86
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
87
|
+
};
|
|
88
|
+
} | {
|
|
89
|
+
tag: "Ed25519";
|
|
90
|
+
value: {
|
|
91
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
92
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
93
|
+
};
|
|
94
|
+
} | {
|
|
95
|
+
tag: "Ecdsa";
|
|
96
|
+
value: {
|
|
97
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
98
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
99
|
+
};
|
|
100
|
+
} | {
|
|
101
|
+
tag: "OnChain";
|
|
102
|
+
value: {
|
|
103
|
+
who: Uint8Array<ArrayBufferLike>;
|
|
104
|
+
blockHash: Uint8Array<ArrayBufferLike>;
|
|
105
|
+
event: bigint;
|
|
106
|
+
};
|
|
107
|
+
}, {
|
|
108
|
+
tag: "Unknown";
|
|
109
|
+
value: {
|
|
110
|
+
reason: string;
|
|
111
|
+
};
|
|
112
|
+
} | {
|
|
113
|
+
tag: "UnableToSign";
|
|
114
|
+
value: undefined;
|
|
115
|
+
} | {
|
|
116
|
+
tag: "UnknownAccount";
|
|
117
|
+
value: undefined;
|
|
118
|
+
}>>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Bytes, Enum, Option, Result, Struct, Tuple, Vector, _void, u32, u64 } from 'scale-ts';
|
|
2
|
+
import { GenericErr } from '../commonCodecs.js';
|
|
3
|
+
import { ProductAccountId } from './accounts.js';
|
|
4
|
+
// structs definition
|
|
5
|
+
export const Topic = Bytes(32);
|
|
6
|
+
export const Channel = Bytes(32);
|
|
7
|
+
export const DecryptionKey = Bytes(32);
|
|
8
|
+
// Proof structures
|
|
9
|
+
const Sr25519StatementProof = Struct({
|
|
10
|
+
signature: Bytes(64),
|
|
11
|
+
signer: Bytes(32),
|
|
12
|
+
});
|
|
13
|
+
const Ed25519StatementProof = Struct({
|
|
14
|
+
signature: Bytes(64),
|
|
15
|
+
signer: Bytes(32),
|
|
16
|
+
});
|
|
17
|
+
const EcdsaStatementProof = Struct({
|
|
18
|
+
signature: Bytes(65),
|
|
19
|
+
signer: Bytes(33),
|
|
20
|
+
});
|
|
21
|
+
const OnChainStatementProof = Struct({
|
|
22
|
+
who: Bytes(32),
|
|
23
|
+
blockHash: Bytes(32),
|
|
24
|
+
event: u64,
|
|
25
|
+
});
|
|
26
|
+
const StatementProof = Enum({
|
|
27
|
+
Sr25519: Sr25519StatementProof,
|
|
28
|
+
Ed25519: Ed25519StatementProof,
|
|
29
|
+
Ecdsa: EcdsaStatementProof,
|
|
30
|
+
OnChain: OnChainStatementProof,
|
|
31
|
+
});
|
|
32
|
+
export const Statement = Struct({
|
|
33
|
+
proof: Option(StatementProof),
|
|
34
|
+
decryptionKey: Option(DecryptionKey),
|
|
35
|
+
priority: Option(u32),
|
|
36
|
+
channel: Option(Channel),
|
|
37
|
+
topics: Vector(Topic),
|
|
38
|
+
data: Option(Bytes()),
|
|
39
|
+
});
|
|
40
|
+
// creating proof
|
|
41
|
+
export const StatementProofErr = Enum({
|
|
42
|
+
UnableToSign: _void,
|
|
43
|
+
UnknownAccount: _void,
|
|
44
|
+
Unknown: GenericErr,
|
|
45
|
+
});
|
|
46
|
+
export const StatementStoreCreateProofV1_request = Tuple(ProductAccountId, Statement);
|
|
47
|
+
export const StatementStoreCreateProofV1_response = Result(StatementProof, StatementProofErr);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export declare const StorageErr: import("scale-ts").Codec<{
|
|
2
|
+
tag: "Unknown";
|
|
3
|
+
value: {
|
|
4
|
+
reason: string;
|
|
5
|
+
};
|
|
6
|
+
} | {
|
|
7
|
+
tag: "Full";
|
|
8
|
+
value: undefined;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const StorageKey: import("scale-ts").Codec<`0x${string}`>;
|
|
11
|
+
export declare const StorageValue: import("scale-ts").Codec<Uint8Array<ArrayBufferLike>>;
|
|
12
|
+
export declare const StorageReadV1_request: import("scale-ts").Codec<`0x${string}`>;
|
|
13
|
+
export declare const StorageReadV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<Uint8Array<ArrayBufferLike> | undefined, {
|
|
14
|
+
tag: "Unknown";
|
|
15
|
+
value: {
|
|
16
|
+
reason: string;
|
|
17
|
+
};
|
|
18
|
+
} | {
|
|
19
|
+
tag: "Full";
|
|
20
|
+
value: undefined;
|
|
21
|
+
}>>;
|
|
22
|
+
export declare const StorageWriteV1_request: import("scale-ts").Codec<[`0x${string}`, Uint8Array<ArrayBufferLike>]>;
|
|
23
|
+
export declare const StorageWriteV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<undefined, {
|
|
24
|
+
tag: "Unknown";
|
|
25
|
+
value: {
|
|
26
|
+
reason: string;
|
|
27
|
+
};
|
|
28
|
+
} | {
|
|
29
|
+
tag: "Full";
|
|
30
|
+
value: undefined;
|
|
31
|
+
}>>;
|
|
32
|
+
export declare const StorageClearV1_request: import("scale-ts").Codec<`0x${string}`>;
|
|
33
|
+
export declare const StorageClearV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<undefined, {
|
|
34
|
+
tag: "Unknown";
|
|
35
|
+
value: {
|
|
36
|
+
reason: string;
|
|
37
|
+
};
|
|
38
|
+
} | {
|
|
39
|
+
tag: "Full";
|
|
40
|
+
value: undefined;
|
|
41
|
+
}>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Bytes, Enum, Option, Result, Tuple, _void } from 'scale-ts';
|
|
2
|
+
import { GenericErr, Hex } from '../commonCodecs.js';
|
|
3
|
+
// common structures
|
|
4
|
+
export const StorageErr = Enum({
|
|
5
|
+
Full: _void,
|
|
6
|
+
Unknown: GenericErr,
|
|
7
|
+
});
|
|
8
|
+
export const StorageKey = Hex();
|
|
9
|
+
export const StorageValue = Bytes();
|
|
10
|
+
// actions
|
|
11
|
+
export const StorageReadV1_request = StorageKey;
|
|
12
|
+
export const StorageReadV1_response = Result(Option(StorageValue), StorageErr);
|
|
13
|
+
export const StorageWriteV1_request = Tuple(StorageKey, StorageValue);
|
|
14
|
+
export const StorageWriteV1_response = Result(_void, StorageErr);
|
|
15
|
+
export const StorageClearV1_request = StorageKey;
|
|
16
|
+
export const StorageClearV1_response = Result(_void, StorageErr);
|
package/dist/messageEncoder.d.ts
CHANGED
|
@@ -1,31 +1,18 @@
|
|
|
1
|
-
import type { CodecType } from 'scale-ts';
|
|
2
|
-
|
|
3
|
-
export declare function unwrapResultOrThrow<T>(response: CodecType<ReturnType<typeof Result<T>>>): T;
|
|
1
|
+
import type { CodecType, ResultPayload } from 'scale-ts';
|
|
2
|
+
export declare function unwrapResultOrThrow<Ok, Err>(response: ResultPayload<Ok, Err>, toError: (e: Err) => Error): Ok;
|
|
4
3
|
export type MessagePayloadSchema = CodecType<typeof messagePayloadEncoder>;
|
|
5
4
|
export declare const messagePayloadEncoder: import("scale-ts").Codec<{
|
|
6
5
|
tag: "handshakeRequestV1";
|
|
7
6
|
value: undefined;
|
|
8
7
|
} | {
|
|
9
8
|
tag: "handshakeResponseV1";
|
|
10
|
-
value:
|
|
11
|
-
tag: "Ok";
|
|
12
|
-
value: undefined;
|
|
13
|
-
} | {
|
|
14
|
-
tag: "Err";
|
|
15
|
-
value: string;
|
|
16
|
-
};
|
|
9
|
+
value: ResultPayload<undefined, string>;
|
|
17
10
|
} | {
|
|
18
11
|
tag: "getAccountsRequestV1";
|
|
19
12
|
value: undefined;
|
|
20
13
|
} | {
|
|
21
14
|
tag: "getAccountsResponseV1";
|
|
22
|
-
value:
|
|
23
|
-
tag: "Ok";
|
|
24
|
-
value: import("@polkadot-api/pjs-signer").InjectedAccount[];
|
|
25
|
-
} | {
|
|
26
|
-
tag: "Err";
|
|
27
|
-
value: string;
|
|
28
|
-
};
|
|
15
|
+
value: ResultPayload<import("@polkadot-api/pjs-signer").InjectedAccount[], string>;
|
|
29
16
|
} | {
|
|
30
17
|
tag: "accountSubscriptionV1";
|
|
31
18
|
value: undefined;
|
|
@@ -37,69 +24,62 @@ export declare const messagePayloadEncoder: import("scale-ts").Codec<{
|
|
|
37
24
|
value: {
|
|
38
25
|
tag: "chain";
|
|
39
26
|
value: {
|
|
40
|
-
|
|
27
|
+
genesisHash: `0x${string}`;
|
|
41
28
|
};
|
|
42
29
|
};
|
|
43
30
|
} | {
|
|
44
31
|
tag: "supportFeatureResponseV1";
|
|
45
|
-
value: {
|
|
46
|
-
tag: "
|
|
32
|
+
value: ResultPayload<{
|
|
33
|
+
tag: "chain";
|
|
47
34
|
value: {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
chainId: `0x${string}`;
|
|
51
|
-
result: boolean;
|
|
52
|
-
};
|
|
35
|
+
genesisHash: `0x${string}`;
|
|
36
|
+
result: boolean;
|
|
53
37
|
};
|
|
54
|
-
}
|
|
55
|
-
tag: "Err";
|
|
56
|
-
value: string;
|
|
57
|
-
};
|
|
38
|
+
}, string>;
|
|
58
39
|
} | {
|
|
59
40
|
tag: "papiProviderSendMessageV1";
|
|
60
41
|
value: {
|
|
61
|
-
|
|
42
|
+
genesisHash: `0x${string}`;
|
|
62
43
|
message: string;
|
|
63
44
|
};
|
|
64
45
|
} | {
|
|
65
46
|
tag: "papiProviderReceiveMessageV1";
|
|
66
|
-
value: {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
message: string;
|
|
71
|
-
};
|
|
72
|
-
} | {
|
|
73
|
-
tag: "Err";
|
|
74
|
-
value: string;
|
|
75
|
-
};
|
|
47
|
+
value: ResultPayload<{
|
|
48
|
+
genesisHash: `0x${string}`;
|
|
49
|
+
message: string;
|
|
50
|
+
}, string>;
|
|
76
51
|
} | {
|
|
77
52
|
tag: "signRawRequestV1";
|
|
78
53
|
value: import("@polkadot/types/types").SignerPayloadRaw;
|
|
79
54
|
} | {
|
|
80
55
|
tag: "signPayloadRequestV1";
|
|
81
|
-
value: import("@polkadot/types/types").SignerPayloadJSON;
|
|
82
|
-
} | {
|
|
83
|
-
tag: "signResponseV1";
|
|
84
56
|
value: {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
57
|
+
address: string;
|
|
58
|
+
blockHash: `0x${string}`;
|
|
59
|
+
blockNumber: `0x${string}`;
|
|
60
|
+
era: `0x${string}`;
|
|
61
|
+
genesisHash: `0x${string}`;
|
|
62
|
+
method: string;
|
|
63
|
+
nonce: `0x${string}`;
|
|
64
|
+
specVersion: `0x${string}`;
|
|
65
|
+
tip: `0x${string}`;
|
|
66
|
+
transactionVersion: `0x${string}`;
|
|
67
|
+
signedExtensions: string[];
|
|
68
|
+
version: number;
|
|
69
|
+
assetId: `0x${string}` | undefined;
|
|
70
|
+
metadataHash: `0x${string}` | undefined;
|
|
71
|
+
mode: number | undefined;
|
|
72
|
+
withSignedTransaction: boolean | undefined;
|
|
90
73
|
};
|
|
74
|
+
} | {
|
|
75
|
+
tag: "signResponseV1";
|
|
76
|
+
value: ResultPayload<import("@polkadot/types/types").SignerResult, string>;
|
|
91
77
|
} | {
|
|
92
78
|
tag: "createTransactionRequestV1";
|
|
93
79
|
value: import("./interactions/sign.js").TxPayloadV1;
|
|
94
80
|
} | {
|
|
95
81
|
tag: "createTransactionResponseV1";
|
|
96
|
-
value: {
|
|
97
|
-
tag: "Ok";
|
|
98
|
-
value: `0x${string}`;
|
|
99
|
-
} | {
|
|
100
|
-
tag: "Err";
|
|
101
|
-
value: string;
|
|
102
|
-
};
|
|
82
|
+
value: ResultPayload<`0x${string}`, string>;
|
|
103
83
|
} | {
|
|
104
84
|
tag: "locationChangedV1";
|
|
105
85
|
value: string;
|
|
@@ -112,25 +92,13 @@ export declare const messageEncoder: import("scale-ts").Codec<{
|
|
|
112
92
|
value: undefined;
|
|
113
93
|
} | {
|
|
114
94
|
tag: "handshakeResponseV1";
|
|
115
|
-
value:
|
|
116
|
-
tag: "Ok";
|
|
117
|
-
value: undefined;
|
|
118
|
-
} | {
|
|
119
|
-
tag: "Err";
|
|
120
|
-
value: string;
|
|
121
|
-
};
|
|
95
|
+
value: ResultPayload<undefined, string>;
|
|
122
96
|
} | {
|
|
123
97
|
tag: "getAccountsRequestV1";
|
|
124
98
|
value: undefined;
|
|
125
99
|
} | {
|
|
126
100
|
tag: "getAccountsResponseV1";
|
|
127
|
-
value:
|
|
128
|
-
tag: "Ok";
|
|
129
|
-
value: import("@polkadot-api/pjs-signer").InjectedAccount[];
|
|
130
|
-
} | {
|
|
131
|
-
tag: "Err";
|
|
132
|
-
value: string;
|
|
133
|
-
};
|
|
101
|
+
value: ResultPayload<import("@polkadot-api/pjs-signer").InjectedAccount[], string>;
|
|
134
102
|
} | {
|
|
135
103
|
tag: "accountSubscriptionV1";
|
|
136
104
|
value: undefined;
|
|
@@ -142,69 +110,62 @@ export declare const messageEncoder: import("scale-ts").Codec<{
|
|
|
142
110
|
value: {
|
|
143
111
|
tag: "chain";
|
|
144
112
|
value: {
|
|
145
|
-
|
|
113
|
+
genesisHash: `0x${string}`;
|
|
146
114
|
};
|
|
147
115
|
};
|
|
148
116
|
} | {
|
|
149
117
|
tag: "supportFeatureResponseV1";
|
|
150
|
-
value: {
|
|
151
|
-
tag: "
|
|
118
|
+
value: ResultPayload<{
|
|
119
|
+
tag: "chain";
|
|
152
120
|
value: {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
chainId: `0x${string}`;
|
|
156
|
-
result: boolean;
|
|
157
|
-
};
|
|
121
|
+
genesisHash: `0x${string}`;
|
|
122
|
+
result: boolean;
|
|
158
123
|
};
|
|
159
|
-
}
|
|
160
|
-
tag: "Err";
|
|
161
|
-
value: string;
|
|
162
|
-
};
|
|
124
|
+
}, string>;
|
|
163
125
|
} | {
|
|
164
126
|
tag: "papiProviderSendMessageV1";
|
|
165
127
|
value: {
|
|
166
|
-
|
|
128
|
+
genesisHash: `0x${string}`;
|
|
167
129
|
message: string;
|
|
168
130
|
};
|
|
169
131
|
} | {
|
|
170
132
|
tag: "papiProviderReceiveMessageV1";
|
|
171
|
-
value: {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
message: string;
|
|
176
|
-
};
|
|
177
|
-
} | {
|
|
178
|
-
tag: "Err";
|
|
179
|
-
value: string;
|
|
180
|
-
};
|
|
133
|
+
value: ResultPayload<{
|
|
134
|
+
genesisHash: `0x${string}`;
|
|
135
|
+
message: string;
|
|
136
|
+
}, string>;
|
|
181
137
|
} | {
|
|
182
138
|
tag: "signRawRequestV1";
|
|
183
139
|
value: import("@polkadot/types/types").SignerPayloadRaw;
|
|
184
140
|
} | {
|
|
185
141
|
tag: "signPayloadRequestV1";
|
|
186
|
-
value: import("@polkadot/types/types").SignerPayloadJSON;
|
|
187
|
-
} | {
|
|
188
|
-
tag: "signResponseV1";
|
|
189
142
|
value: {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
143
|
+
address: string;
|
|
144
|
+
blockHash: `0x${string}`;
|
|
145
|
+
blockNumber: `0x${string}`;
|
|
146
|
+
era: `0x${string}`;
|
|
147
|
+
genesisHash: `0x${string}`;
|
|
148
|
+
method: string;
|
|
149
|
+
nonce: `0x${string}`;
|
|
150
|
+
specVersion: `0x${string}`;
|
|
151
|
+
tip: `0x${string}`;
|
|
152
|
+
transactionVersion: `0x${string}`;
|
|
153
|
+
signedExtensions: string[];
|
|
154
|
+
version: number;
|
|
155
|
+
assetId: `0x${string}` | undefined;
|
|
156
|
+
metadataHash: `0x${string}` | undefined;
|
|
157
|
+
mode: number | undefined;
|
|
158
|
+
withSignedTransaction: boolean | undefined;
|
|
195
159
|
};
|
|
160
|
+
} | {
|
|
161
|
+
tag: "signResponseV1";
|
|
162
|
+
value: ResultPayload<import("@polkadot/types/types").SignerResult, string>;
|
|
196
163
|
} | {
|
|
197
164
|
tag: "createTransactionRequestV1";
|
|
198
165
|
value: import("./interactions/sign.js").TxPayloadV1;
|
|
199
166
|
} | {
|
|
200
167
|
tag: "createTransactionResponseV1";
|
|
201
|
-
value: {
|
|
202
|
-
tag: "Ok";
|
|
203
|
-
value: `0x${string}`;
|
|
204
|
-
} | {
|
|
205
|
-
tag: "Err";
|
|
206
|
-
value: string;
|
|
207
|
-
};
|
|
168
|
+
value: ResultPayload<`0x${string}`, string>;
|
|
208
169
|
} | {
|
|
209
170
|
tag: "locationChangedV1";
|
|
210
171
|
value: string;
|
package/dist/messageEncoder.js
CHANGED
|
@@ -1,34 +1,31 @@
|
|
|
1
|
-
import { Enum, Struct, str } from 'scale-ts';
|
|
2
|
-
import { Result } from './commonEncoders.js';
|
|
1
|
+
import { Enum, Result, Struct, str } from 'scale-ts';
|
|
3
2
|
import { accountSubscriptionV1Encoder, accountUnsubscriptionV1Encoder, getAccountsRequestV1Encoder, getAccountsResponseV1Encoder, } from './interactions/accounts.js';
|
|
4
3
|
import { supportFeatureRequestV1Encoder, supportFeatureResponseV1 } from './interactions/features.js';
|
|
5
4
|
import { handshakeRequestV1Encoder, handshakeResponseV1Encoder } from './interactions/handshake.js';
|
|
6
5
|
import { papiProviderReceiveMessageV1Encoder, papiProviderSendMessageV1Encoder } from './interactions/papiProvider.js';
|
|
7
6
|
import { createTransactionRequestV1Encoder, createTransactionResponseV1Encoder, signPayloadRequestV1Encoder, signRawRequestV1Encoder, signResponseV1Encoder, } from './interactions/sign.js';
|
|
8
|
-
export function unwrapResultOrThrow(response) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return response.value;
|
|
12
|
-
case 'Err':
|
|
13
|
-
throw new Error(response.value);
|
|
7
|
+
export function unwrapResultOrThrow(response, toError) {
|
|
8
|
+
if (response.success) {
|
|
9
|
+
return response.value;
|
|
14
10
|
}
|
|
11
|
+
throw toError(response.value);
|
|
15
12
|
}
|
|
16
13
|
export const messagePayloadEncoder = Enum({
|
|
17
14
|
handshakeRequestV1: handshakeRequestV1Encoder,
|
|
18
|
-
handshakeResponseV1: Result(handshakeResponseV1Encoder),
|
|
15
|
+
handshakeResponseV1: Result(handshakeResponseV1Encoder, str),
|
|
19
16
|
getAccountsRequestV1: getAccountsRequestV1Encoder,
|
|
20
|
-
getAccountsResponseV1: Result(getAccountsResponseV1Encoder),
|
|
17
|
+
getAccountsResponseV1: Result(getAccountsResponseV1Encoder, str),
|
|
21
18
|
accountSubscriptionV1: accountSubscriptionV1Encoder,
|
|
22
19
|
accountUnsubscriptionV1: accountUnsubscriptionV1Encoder,
|
|
23
20
|
supportFeatureRequestV1: supportFeatureRequestV1Encoder,
|
|
24
|
-
supportFeatureResponseV1: Result(supportFeatureResponseV1),
|
|
21
|
+
supportFeatureResponseV1: Result(supportFeatureResponseV1, str),
|
|
25
22
|
papiProviderSendMessageV1: papiProviderSendMessageV1Encoder,
|
|
26
|
-
papiProviderReceiveMessageV1: Result(papiProviderReceiveMessageV1Encoder),
|
|
23
|
+
papiProviderReceiveMessageV1: Result(papiProviderReceiveMessageV1Encoder, str),
|
|
27
24
|
signRawRequestV1: signRawRequestV1Encoder,
|
|
28
25
|
signPayloadRequestV1: signPayloadRequestV1Encoder,
|
|
29
|
-
signResponseV1: Result(signResponseV1Encoder),
|
|
26
|
+
signResponseV1: Result(signResponseV1Encoder, str),
|
|
30
27
|
createTransactionRequestV1: createTransactionRequestV1Encoder,
|
|
31
|
-
createTransactionResponseV1: Result(createTransactionResponseV1Encoder),
|
|
28
|
+
createTransactionResponseV1: Result(createTransactionResponseV1Encoder, str),
|
|
32
29
|
locationChangedV1: str,
|
|
33
30
|
});
|
|
34
31
|
export const messageEncoder = Struct({
|
package/package.json
CHANGED